Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3366c1e35f | |||
| 82be31a408 | |||
| d767f3f598 | |||
| 48967c7c5f | |||
| 6c4da7225d | |||
| e9025fb13e | |||
| 8db6b3187b | |||
| a19f9e12c4 | |||
| a82eb46511 |
@@ -32,6 +32,8 @@ const chromeExtensionIds = [
|
||||
'khjdmjcmpolknpccmaaipmidphjokhdf', // WorkFlowy MultiFlow
|
||||
'fencadnndhdeggodopebjgdfdlhcimfk', // 香草布丁🌿🍮- https://github.com/Xdy1579883916/vanilla-pudding
|
||||
'bnacincmbaknlbegecpioobkfgejlojp', // MaxFocus: Link Preview
|
||||
'bcpgdpedphodjcjlminjbdeejccjbimp', // 汇率转换-中文版本
|
||||
'loeilaonggnalkaiiaepbegccilkmjjp', // Currency Converter Plus
|
||||
];
|
||||
|
||||
const { data, err, isLoading } = useListExtensionDetails(chromeExtensionIds);
|
||||
|
||||
@@ -17,7 +17,7 @@ In WXT, you create an entrypoint by adding a file to the `entrypoints/` director
|
||||
|
||||
Some entrypoint filesname patterns are reserved by WXT and effect how the manifest is generated.
|
||||
|
||||
- `popup` adds a `action` to the manifest
|
||||
- `popup` adds an `action` to the manifest
|
||||
- `background` adds a background script/service worker
|
||||
- `*.content.ts` adds a content script
|
||||
- ...
|
||||
|
||||
@@ -229,7 +229,7 @@ The `manifest` option can also be set equal to a function, letting you use logic
|
||||
```ts
|
||||
// wxt.config.ts
|
||||
export default defineConfig({
|
||||
manifest: ({ manifestVersion, browser, mode, comamnd }) => {
|
||||
manifest: ({ manifestVersion, browser, mode, command }) => {
|
||||
return { ... }
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,5 +1,30 @@
|
||||
# Changelog
|
||||
|
||||
## v0.18.14
|
||||
|
||||
[compare changes](https://github.com/wxt-dev/wxt/compare/wxt-v0.18.13...wxt-v0.18.14)
|
||||
|
||||
### 🩹 Fixes
|
||||
|
||||
- **modules:** Add types from all wxt node_modules, not just ones with config ([#817](https://github.com/wxt-dev/wxt/pull/817))
|
||||
|
||||
## v0.18.13
|
||||
|
||||
[compare changes](https://github.com/wxt-dev/wxt/compare/wxt-v0.18.12...wxt-v0.18.13)
|
||||
|
||||
### 🚀 Enhancements
|
||||
|
||||
- **config:** `dev.server.hostname` ([#807](https://github.com/wxt-dev/wxt/pull/807))
|
||||
- Add XPath support to getAnchor() ([#813](https://github.com/wxt-dev/wxt/pull/813))
|
||||
|
||||
### 🩹 Fixes
|
||||
|
||||
- Add debug logs for vite builder ([#816](https://github.com/wxt-dev/wxt/pull/816))
|
||||
|
||||
### ❤️ Contributors
|
||||
|
||||
- Ayub Kokabi ([@sir-kokabi](http://github.com/sir-kokabi))
|
||||
|
||||
## v0.18.12
|
||||
|
||||
[compare changes](https://github.com/wxt-dev/wxt/compare/wxt-v0.18.11...wxt-v0.18.12)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "wxt",
|
||||
"type": "module",
|
||||
"version": "0.18.12",
|
||||
"version": "0.18.14",
|
||||
"description": "Next gen framework for developing web extensions",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -252,6 +252,24 @@ describe('Content Script UIs', () => {
|
||||
document.querySelector('#parent > div[data-wxt-integrated]'),
|
||||
).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should append the element using an XPath string', () => {
|
||||
vi.stubGlobal('XPathResult', { FIRST_ORDERED_NODE_TYPE: 9 });
|
||||
document.evaluate = vi.fn().mockReturnValue({
|
||||
singleNodeValue: document.querySelector('#three'),
|
||||
});
|
||||
|
||||
const ui = createIntegratedUi(ctx, {
|
||||
position: 'inline',
|
||||
onMount: appendTestApp,
|
||||
anchor: '//p[@id="three"]',
|
||||
});
|
||||
ui.mount();
|
||||
|
||||
expect(
|
||||
document.querySelector('#three > div[data-wxt-integrated]'),
|
||||
).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Element', () => {
|
||||
|
||||
@@ -199,8 +199,25 @@ function getAnchor(options: ContentScriptAnchoredOptions): Element | undefined {
|
||||
|
||||
let resolved =
|
||||
typeof options.anchor === 'function' ? options.anchor() : options.anchor;
|
||||
if (typeof resolved === 'string')
|
||||
return document.querySelector<Element>(resolved) ?? undefined;
|
||||
|
||||
if (typeof resolved === 'string') {
|
||||
// If the string is an XPath expression (starts with '//' or '/')
|
||||
if (resolved.startsWith('/')) {
|
||||
// Evaluate the XPath and return the first ordered node
|
||||
const result = document.evaluate(
|
||||
resolved,
|
||||
document,
|
||||
null,
|
||||
XPathResult.FIRST_ORDERED_NODE_TYPE,
|
||||
null,
|
||||
);
|
||||
return (result.singleNodeValue as Element) ?? undefined;
|
||||
} else {
|
||||
// If the string is a CSS selector, query the document and return the element
|
||||
return document.querySelector<Element>(resolved) ?? undefined;
|
||||
}
|
||||
}
|
||||
|
||||
return resolved ?? undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ export type ContentScriptPositioningOptions =
|
||||
|
||||
export interface ContentScriptAnchoredOptions {
|
||||
/**
|
||||
* A CSS selector, element, or function that returns one of the two. Along with `append`, the
|
||||
* A CSS selector, XPath expression, element, or function that returns one of the three. Along with `append`, the
|
||||
* `anchor` dictates where in the page the UI will be added.
|
||||
*/
|
||||
anchor?:
|
||||
|
||||
@@ -30,8 +30,7 @@ export async function generateTypesDir(
|
||||
// in <root>/modules are already apart of the project, so we don't need to
|
||||
// add them.
|
||||
wxt.config.userModules.forEach((module) => {
|
||||
if (module.type === 'node_module' && module.configKey != null)
|
||||
entries.push({ module: module.id });
|
||||
if (module.type === 'node_module') entries.push({ module: module.id });
|
||||
});
|
||||
|
||||
// browser.runtime.getURL
|
||||
|
||||
@@ -126,7 +126,7 @@ export async function resolveConfig(
|
||||
}
|
||||
devServerConfig = {
|
||||
port,
|
||||
hostname: 'localhost',
|
||||
hostname: mergedConfig.dev?.server?.hostname ?? 'localhost',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -228,11 +228,17 @@ async function mergeInlineConfig(
|
||||
inlineConfig.transformManifest?.(manifest);
|
||||
};
|
||||
|
||||
const merged = defu(inlineConfig, userConfig);
|
||||
|
||||
// Builders
|
||||
const builderConfig = await mergeBuilderConfig(inlineConfig, userConfig);
|
||||
const builderConfig = await mergeBuilderConfig(
|
||||
merged.logger ?? consola,
|
||||
inlineConfig,
|
||||
userConfig,
|
||||
);
|
||||
|
||||
return {
|
||||
...defu(inlineConfig, userConfig),
|
||||
...merged,
|
||||
// Custom merge values
|
||||
transformManifest,
|
||||
imports,
|
||||
@@ -397,10 +403,13 @@ const COMMAND_MODES: Record<WxtCommand, string> = {
|
||||
};
|
||||
|
||||
export async function mergeBuilderConfig(
|
||||
logger: Logger,
|
||||
inlineConfig: InlineConfig,
|
||||
userConfig: UserConfig,
|
||||
): Promise<Pick<InlineConfig, 'vite'>> {
|
||||
const vite = await import('vite').catch(() => void 0);
|
||||
const vite = await import('vite').catch((err) => {
|
||||
logger.debug('Failed to import vite:', err);
|
||||
});
|
||||
if (vite) {
|
||||
return {
|
||||
vite: async (env) => {
|
||||
|
||||
@@ -338,6 +338,12 @@ export interface InlineConfig {
|
||||
* Port to run the dev server on. Defaults to the first open port from 3000 to 3010.
|
||||
*/
|
||||
port?: number;
|
||||
/**
|
||||
* Hostname to run the dev server on.
|
||||
*
|
||||
* @default "localhost"
|
||||
*/
|
||||
hostname?: string;
|
||||
};
|
||||
/**
|
||||
* Controls whether a custom keyboard shortcut command, `Alt+R`, is added during dev mode to
|
||||
|
||||
Reference in New Issue
Block a user