@crxjs/vite-plugin 1.0.14 → 2.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.cjs +2 -3565
- package/dist/index.d.ts +33 -20
- package/dist/index.mjs +1292 -3007
- package/package.json +41 -43
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ConfigEnv, Plugin,
|
|
2
|
-
import { PluginContext, OutputBundle, OutputOptions } from 'rollup';
|
|
1
|
+
import { ConfigEnv, Plugin, PluginOption } from 'vite';
|
|
3
2
|
import { Options } from 'fast-glob';
|
|
3
|
+
import { PluginContext, OutputBundle } from 'rollup';
|
|
4
4
|
|
|
5
5
|
interface DeclarativeNetRequestResource {
|
|
6
6
|
id: string;
|
|
@@ -202,14 +202,15 @@ declare const defineManifest: (manifest: ManifestV3Export) => ManifestV3Export;
|
|
|
202
202
|
*
|
|
203
203
|
* You don't need to define a match pattern for dynamic content script
|
|
204
204
|
* resources, but if you want to do so, you can use the helper function
|
|
205
|
-
* `defineDynamicResource` to define your web accessible resources in a
|
|
205
|
+
* `defineDynamicResource` to define your web accessible resources in a
|
|
206
|
+
* TypeScript file:
|
|
206
207
|
*
|
|
207
208
|
* ```typescript
|
|
208
209
|
* import { crx, defineManifest, defineDynamicResource }
|
|
209
210
|
* const manifest = defineManifest({
|
|
210
211
|
* "web_accessible_resources": [
|
|
211
212
|
* defineDynamicResource({
|
|
212
|
-
* matches: ["https://
|
|
213
|
+
* matches: ["https://example.com/*", "file:///*.mp3", "..."]
|
|
213
214
|
* use_dynamic_url?: true
|
|
214
215
|
* })
|
|
215
216
|
* ]
|
|
@@ -218,13 +219,25 @@ declare const defineManifest: (manifest: ManifestV3Export) => ManifestV3Export;
|
|
|
218
219
|
*/
|
|
219
220
|
declare const defineDynamicResource: ({ matches, use_dynamic_url, }: Omit<WebAccessibleResourceByMatch, 'resources'>) => WebAccessibleResourceByMatch;
|
|
220
221
|
|
|
222
|
+
declare type CrxDevAssetId = {
|
|
223
|
+
id: string;
|
|
224
|
+
type: 'asset';
|
|
225
|
+
source?: string | Uint8Array;
|
|
226
|
+
};
|
|
227
|
+
declare type CrxDevScriptId = {
|
|
228
|
+
id: string;
|
|
229
|
+
type: 'module' | 'iife';
|
|
230
|
+
};
|
|
221
231
|
interface CrxPlugin extends Plugin {
|
|
222
|
-
/** Runs during
|
|
223
|
-
fileWriterStart?: (server: ViteDevServer) => Promise<void> | void;
|
|
224
|
-
/** Runs during the transform hook for the manifest. */
|
|
232
|
+
/** Runs during the transform hook for the manifest. Filenames use input filenames. */
|
|
225
233
|
transformCrxManifest?: (this: PluginContext, manifest: ManifestV3) => Promise<ManifestV3 | null | undefined> | ManifestV3 | null | undefined;
|
|
226
|
-
/** Runs during generateBundle, before manifest output. */
|
|
234
|
+
/** Runs during generateBundle, before manifest output. Filenames use output filenames. */
|
|
227
235
|
renderCrxManifest?: (this: PluginContext, manifest: ManifestV3, bundle: OutputBundle) => Promise<ManifestV3 | null | undefined> | ManifestV3 | null | undefined;
|
|
236
|
+
/**
|
|
237
|
+
* Runs in the file writer on content scripts during development. `script.id`
|
|
238
|
+
* is Vite URL format.
|
|
239
|
+
*/
|
|
240
|
+
renderCrxDevScript?: (code: string, script: CrxDevScriptId) => Promise<string | null | undefined> | string | null | undefined;
|
|
228
241
|
}
|
|
229
242
|
interface CrxOptions {
|
|
230
243
|
contentScripts?: {
|
|
@@ -235,21 +248,21 @@ interface CrxOptions {
|
|
|
235
248
|
fastGlobOptions?: Options;
|
|
236
249
|
}
|
|
237
250
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
declare
|
|
251
|
+
/** Resolves when all existing files in scriptFiles are written. */
|
|
252
|
+
declare function allFilesReady(): Promise<void>;
|
|
253
|
+
|
|
254
|
+
declare type FileWriterId = {
|
|
255
|
+
type: CrxDevAssetId['type'] | CrxDevScriptId['type'] | 'loader';
|
|
256
|
+
id: string;
|
|
257
|
+
};
|
|
258
|
+
/** Resolves when file and dependencies are written. */
|
|
259
|
+
declare function fileReady(script: FileWriterId): Promise<void>;
|
|
247
260
|
|
|
248
|
-
declare const crx: (
|
|
261
|
+
declare const crx: (options: {
|
|
249
262
|
manifest: ManifestV3Export;
|
|
250
263
|
} & CrxOptions) => PluginOption[];
|
|
251
|
-
declare const chromeExtension: (
|
|
264
|
+
declare const chromeExtension: (options: {
|
|
252
265
|
manifest: ManifestV3Export;
|
|
253
266
|
} & CrxOptions) => PluginOption[];
|
|
254
267
|
|
|
255
|
-
export { CrxPlugin, ManifestV3Export, chromeExtension, crx, defineDynamicResource, defineManifest, filesReady
|
|
268
|
+
export { CrxPlugin, ManifestV3Export, allFilesReady, chromeExtension, crx, defineDynamicResource, defineManifest, fileReady as filesReady };
|