adnbn 0.0.6 → 0.0.7

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.
Files changed (50) hide show
  1. package/dist/cli/builders/app.mjs.map +1 -1
  2. package/dist/cli/builders/manifest/ManifestBase.mjs +1 -1
  3. package/dist/cli/builders/manifest/ManifestBase.mjs.map +1 -1
  4. package/dist/cli/builders/manifest/ManifestV2.mjs.map +1 -1
  5. package/dist/cli/builders/manifest/ManifestV3.mjs.map +1 -1
  6. package/dist/cli/builders/manifest/index.mjs.map +1 -1
  7. package/dist/cli/index.mjs +1 -1
  8. package/dist/cli/index.mjs.map +1 -1
  9. package/dist/cli/parsers/entrypoint/index.mjs.map +1 -1
  10. package/dist/cli/plugins/background.mjs.map +1 -1
  11. package/dist/cli/plugins/content.mjs +1 -1
  12. package/dist/cli/plugins/content.mjs.map +1 -1
  13. package/dist/cli/resolvers/config.mjs +4 -4
  14. package/dist/cli/resolvers/config.mjs.map +1 -1
  15. package/dist/cli/resolvers/path.mjs.map +1 -1
  16. package/dist/cli/resolvers/webpack.mjs +2 -2
  17. package/dist/cli/resolvers/webpack.mjs.map +1 -1
  18. package/dist/cli/utils/option.mjs.map +1 -1
  19. package/dist/cli/utils/plugin.mjs.map +1 -1
  20. package/dist/core/define.mjs.map +1 -1
  21. package/dist/types/config.mjs.map +1 -1
  22. package/package.json +4 -1
  23. package/dist/cli/builders/app.d.ts +0 -3
  24. package/dist/cli/builders/manifest/ManifestBase.d.ts +0 -24
  25. package/dist/cli/builders/manifest/ManifestV2.d.ts +0 -10
  26. package/dist/cli/builders/manifest/ManifestV3.d.ts +0 -10
  27. package/dist/cli/builders/manifest/index.d.ts +0 -4
  28. package/dist/cli/index.d.ts +0 -1
  29. package/dist/cli/parsers/entrypoint/OptionFile.d.ts +0 -10
  30. package/dist/cli/parsers/entrypoint/SourceFile.d.ts +0 -24
  31. package/dist/cli/parsers/entrypoint/index.d.ts +0 -2
  32. package/dist/cli/plugins/background.d.ts +0 -6
  33. package/dist/cli/plugins/content.d.ts +0 -3
  34. package/dist/cli/resolvers/config.d.ts +0 -3
  35. package/dist/cli/resolvers/path.d.ts +0 -5
  36. package/dist/cli/resolvers/webpack.d.ts +0 -4
  37. package/dist/cli/utils/entrypoint.d.ts +0 -3
  38. package/dist/cli/utils/option.d.ts +0 -3
  39. package/dist/cli/utils/plugin.d.ts +0 -4
  40. package/dist/cli/webpack/plugins/EntryDependenciesPlugin.d.ts +0 -8
  41. package/dist/core/define.d.ts +0 -6
  42. package/dist/index.d.ts +0 -1
  43. package/dist/index.mjs +0 -7
  44. package/dist/index.mjs.map +0 -7
  45. package/dist/types/background.d.ts +0 -7
  46. package/dist/types/base.d.ts +0 -31
  47. package/dist/types/config.d.ts +0 -45
  48. package/dist/types/content.d.ts +0 -50
  49. package/dist/types/manifest.d.ts +0 -77
  50. package/dist/types/plugin.d.ts +0 -36
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cli/builders/app.ts"],
4
- "sourcesContent": ["import webpack from 'webpack';\n\nimport {OptionalConfig} from \"@typing/config\";\nimport configResolver from \"../resolvers/config\";\nimport webpackResolver from \"../resolvers/webpack\";\n\nexport default async (config: OptionalConfig): Promise<void> => {\n const resolverConfig = await configResolver(config);\n const webpackConfig = await webpackResolver(resolverConfig);\n\n const compiler = webpack(webpackConfig);\n\n compiler.run((err, stats) => {\n if (err) {\n console.error('Webpack compilation error');\n process.exit(1);\n }\n\n console.log(stats?.toString({ colors: true }));\n });\n}"],
4
+ "sourcesContent": ["import webpack from 'webpack';\n\nimport {OptionalConfig} from \"../../types/config\";\nimport configResolver from \"../resolvers/config\";\nimport webpackResolver from \"../resolvers/webpack\";\n\nexport default async (config: OptionalConfig): Promise<void> => {\n const resolverConfig = await configResolver(config);\n const webpackConfig = await webpackResolver(resolverConfig);\n\n const compiler = webpack(webpackConfig);\n\n compiler.run((err, stats) => {\n if (err) {\n console.error('Webpack compilation error');\n process.exit(1);\n }\n\n console.log(stats?.toString({ colors: true }));\n });\n}"],
5
5
  "mappings": "AAAA,OAAO,aAAa;AAGpB,OAAO,oBAAoB;AAC3B,OAAO,qBAAqB;AAE5B,IAAO,cAAQ,OAAO,WAA0C;AAC5D,QAAM,iBAAiB,MAAM,eAAe,MAAM;AAClD,QAAM,gBAAgB,MAAM,gBAAgB,cAAc;AAE1D,QAAM,WAAW,QAAQ,aAAa;AAEtC,WAAS,IAAI,CAAC,KAAK,UAAU;AACzB,QAAI,KAAK;AACL,cAAQ,MAAM,2BAA2B;AACzC,cAAQ,KAAK,CAAC;AAAA,IAClB;AAEA,YAAQ,IAAI,OAAO,SAAS,EAAE,QAAQ,KAAK,CAAC,CAAC;AAAA,EACjD,CAAC;AACL;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- import { Browser } from "@typing/config";
1
+ import { Browser } from "../../../types/config";
2
2
  class ManifestBase_default {
3
3
  constructor(browser = Browser.Chrome) {
4
4
  this.browser = browser;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/cli/builders/manifest/ManifestBase.ts"],
4
- "sourcesContent": ["import {\n CoreManifest,\n Manifest,\n ManifestBackground,\n ManifestBuilder,\n ManifestContentScript,\n ManifestVersion\n} from \"@typing/manifest\";\n\nimport {Browser} from \"@typing/config\";\n\nexport default abstract class<T extends CoreManifest> implements ManifestBuilder<T> {\n protected name: string = \"__MSG_app_name__\";\n protected shortName: string = \"__MSG_app_short_name__\";\n protected description: string = \"__MSG_app_description__\";\n protected version: string = \"0.0.0\";\n protected background?: ManifestBackground;\n protected contentScripts: Map<string, ManifestContentScript> = new Map();\n\n public abstract getManifestVersion(): ManifestVersion;\n\n protected abstract buildBackground(): Partial<T> | undefined;\n\n protected abstract buildContentScripts(): Partial<T> | undefined;\n\n protected constructor(protected readonly browser: Browser = Browser.Chrome) {\n }\n\n public setName(name: string): this {\n this.name = name;\n\n return this;\n }\n\n public setShortName(shortName: string): this {\n this.shortName = shortName;\n\n return this;\n }\n\n public setDescription(description: string): this {\n this.description = description;\n\n return this;\n }\n\n public setVersion(version: string): this {\n this.version = version;\n\n return this;\n }\n\n public resetBackground(background: ManifestBackground): this {\n this.background = background;\n\n return this;\n }\n\n public pushContentScript(...content: ManifestContentScript[]): this {\n for (const script of content) {\n this.contentScripts.set(script.entry, script);\n }\n\n return this;\n }\n\n private marge<T extends CoreManifest>(manifest: T, ...sources: Array<Partial<T> | undefined>): T {\n sources = sources.filter((source) => source !== undefined);\n\n if (sources.length === 0) {\n return manifest;\n }\n\n return Object.assign({}, manifest, ...sources);\n }\n\n public build(): T {\n let manifest: Manifest = {\n name: this.name,\n short_name: this.shortName,\n description: this.description,\n version: this.version,\n manifest_version: this.getManifestVersion(),\n };\n\n manifest = this.marge(manifest, this.buildBackground(), this.buildContentScripts());\n\n return manifest as T;\n }\n\n public get(): T {\n return this.build();\n }\n}"],
4
+ "sourcesContent": ["import {\n CoreManifest,\n Manifest,\n ManifestBackground,\n ManifestBuilder,\n ManifestContentScript,\n ManifestVersion\n} from \"../../../types/manifest\";\n\nimport {Browser} from \"../../../types/config\";\n\nexport default abstract class<T extends CoreManifest> implements ManifestBuilder<T> {\n protected name: string = \"__MSG_app_name__\";\n protected shortName: string = \"__MSG_app_short_name__\";\n protected description: string = \"__MSG_app_description__\";\n protected version: string = \"0.0.0\";\n protected background?: ManifestBackground;\n protected contentScripts: Map<string, ManifestContentScript> = new Map();\n\n public abstract getManifestVersion(): ManifestVersion;\n\n protected abstract buildBackground(): Partial<T> | undefined;\n\n protected abstract buildContentScripts(): Partial<T> | undefined;\n\n protected constructor(protected readonly browser: Browser = Browser.Chrome) {\n }\n\n public setName(name: string): this {\n this.name = name;\n\n return this;\n }\n\n public setShortName(shortName: string): this {\n this.shortName = shortName;\n\n return this;\n }\n\n public setDescription(description: string): this {\n this.description = description;\n\n return this;\n }\n\n public setVersion(version: string): this {\n this.version = version;\n\n return this;\n }\n\n public resetBackground(background: ManifestBackground): this {\n this.background = background;\n\n return this;\n }\n\n public pushContentScript(...content: ManifestContentScript[]): this {\n for (const script of content) {\n this.contentScripts.set(script.entry, script);\n }\n\n return this;\n }\n\n private marge<T extends CoreManifest>(manifest: T, ...sources: Array<Partial<T> | undefined>): T {\n sources = sources.filter((source) => source !== undefined);\n\n if (sources.length === 0) {\n return manifest;\n }\n\n return Object.assign({}, manifest, ...sources);\n }\n\n public build(): T {\n let manifest: Manifest = {\n name: this.name,\n short_name: this.shortName,\n description: this.description,\n version: this.version,\n manifest_version: this.getManifestVersion(),\n };\n\n manifest = this.marge(manifest, this.buildBackground(), this.buildContentScripts());\n\n return manifest as T;\n }\n\n public get(): T {\n return this.build();\n }\n}"],
5
5
  "mappings": "AASA,SAAQ,eAAc;AAEtB,MAAO,qBAA6E;AAAA,EActE,YAA+B,UAAmB,QAAQ,QAAQ;AAAnC;AAAA,EACzC;AAAA,EAdU,OAAe;AAAA,EACf,YAAoB;AAAA,EACpB,cAAsB;AAAA,EACtB,UAAkB;AAAA,EAClB;AAAA,EACA,iBAAqD,oBAAI,IAAI;AAAA,EAWhE,QAAQ,MAAoB;AAC/B,SAAK,OAAO;AAEZ,WAAO;AAAA,EACX;AAAA,EAEO,aAAa,WAAyB;AACzC,SAAK,YAAY;AAEjB,WAAO;AAAA,EACX;AAAA,EAEO,eAAe,aAA2B;AAC7C,SAAK,cAAc;AAEnB,WAAO;AAAA,EACX;AAAA,EAEO,WAAW,SAAuB;AACrC,SAAK,UAAU;AAEf,WAAO;AAAA,EACX;AAAA,EAEO,gBAAgB,YAAsC;AACzD,SAAK,aAAa;AAElB,WAAO;AAAA,EACX;AAAA,EAEO,qBAAqB,SAAwC;AAChE,eAAW,UAAU,SAAS;AAC1B,WAAK,eAAe,IAAI,OAAO,OAAO,MAAM;AAAA,IAChD;AAEA,WAAO;AAAA,EACX;AAAA,EAEQ,MAA8B,aAAgB,SAA2C;AAC7F,cAAU,QAAQ,OAAO,CAAC,WAAW,WAAW,MAAS;AAEzD,QAAI,QAAQ,WAAW,GAAG;AACtB,aAAO;AAAA,IACX;AAEA,WAAO,OAAO,OAAO,CAAC,GAAG,UAAU,GAAG,OAAO;AAAA,EACjD;AAAA,EAEO,QAAW;AACd,QAAI,WAAqB;AAAA,MACrB,MAAM,KAAK;AAAA,MACX,YAAY,KAAK;AAAA,MACjB,aAAa,KAAK;AAAA,MAClB,SAAS,KAAK;AAAA,MACd,kBAAkB,KAAK,mBAAmB;AAAA,IAC9C;AAEA,eAAW,KAAK,MAAM,UAAU,KAAK,gBAAgB,GAAG,KAAK,oBAAoB,CAAC;AAElF,WAAO;AAAA,EACX;AAAA,EAEO,MAAS;AACZ,WAAO,KAAK,MAAM;AAAA,EACtB;AACJ;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/cli/builders/manifest/ManifestV2.ts"],
4
- "sourcesContent": ["import ManifestBase from \"./ManifestBase\";\n\nimport {ManifestVersion} from \"@typing/manifest\";\nimport {Browser} from \"@typing/config\";\n\nimport ManifestV2 = chrome.runtime.ManifestV2;\n\nexport default class extends ManifestBase<ManifestV2> {\n\n public constructor(browser: Browser) {\n super(browser);\n }\n\n public getManifestVersion(): ManifestVersion {\n return 2;\n }\n\n protected buildBackground(): Partial<ManifestV2> | undefined {\n if (this.background) {\n const {file, persistent} = this.background;\n\n return {background: {scripts: [file], persistent}};\n }\n }\n\n protected buildContentScripts(): Partial<ManifestV2> | undefined {\n if (this.contentScripts.size > 0) {\n const contentScripts: ManifestV2['content_scripts'] = Array.from(this.contentScripts, ([_, contentScript]) => ({\n matches: contentScript.matches,\n js: [contentScript.file],\n exclude_matches: contentScript.excludeMatches,\n all_frames: contentScript.allFrames,\n run_at: contentScript.runAt,\n exclude_globs: contentScript.excludeGlobs,\n include_globs: contentScript.includeGlobs,\n }));\n\n return {content_scripts: contentScripts};\n }\n }\n}"],
4
+ "sourcesContent": ["import ManifestBase from \"./ManifestBase\";\n\nimport {ManifestVersion} from \"../../../types/manifest\";\nimport {Browser} from \"../../../types/config\";\n\nimport ManifestV2 = chrome.runtime.ManifestV2;\n\nexport default class extends ManifestBase<ManifestV2> {\n\n public constructor(browser: Browser) {\n super(browser);\n }\n\n public getManifestVersion(): ManifestVersion {\n return 2;\n }\n\n protected buildBackground(): Partial<ManifestV2> | undefined {\n if (this.background) {\n const {file, persistent} = this.background;\n\n return {background: {scripts: [file], persistent}};\n }\n }\n\n protected buildContentScripts(): Partial<ManifestV2> | undefined {\n if (this.contentScripts.size > 0) {\n const contentScripts: ManifestV2['content_scripts'] = Array.from(this.contentScripts, ([_, contentScript]) => ({\n matches: contentScript.matches,\n js: [contentScript.file],\n exclude_matches: contentScript.excludeMatches,\n all_frames: contentScript.allFrames,\n run_at: contentScript.runAt,\n exclude_globs: contentScript.excludeGlobs,\n include_globs: contentScript.includeGlobs,\n }));\n\n return {content_scripts: contentScripts};\n }\n }\n}"],
5
5
  "mappings": "AAAA,OAAO,kBAAkB;AAOzB,MAAO,2BAAsB,aAAyB;AAAA,EAE3C,YAAY,SAAkB;AACjC,UAAM,OAAO;AAAA,EACjB;AAAA,EAEO,qBAAsC;AACzC,WAAO;AAAA,EACX;AAAA,EAEU,kBAAmD;AACzD,QAAI,KAAK,YAAY;AACjB,YAAM,EAAC,MAAM,WAAU,IAAI,KAAK;AAEhC,aAAO,EAAC,YAAY,EAAC,SAAS,CAAC,IAAI,GAAG,WAAU,EAAC;AAAA,IACrD;AAAA,EACJ;AAAA,EAEU,sBAAuD;AAC7D,QAAI,KAAK,eAAe,OAAO,GAAG;AAC9B,YAAM,iBAAgD,MAAM,KAAK,KAAK,gBAAgB,CAAC,CAAC,GAAG,aAAa,OAAO;AAAA,QAC3G,SAAS,cAAc;AAAA,QACvB,IAAI,CAAC,cAAc,IAAI;AAAA,QACvB,iBAAiB,cAAc;AAAA,QAC/B,YAAY,cAAc;AAAA,QAC1B,QAAQ,cAAc;AAAA,QACtB,eAAe,cAAc;AAAA,QAC7B,eAAe,cAAc;AAAA,MACjC,EAAE;AAEF,aAAO,EAAC,iBAAiB,eAAc;AAAA,IAC3C;AAAA,EACJ;AACJ;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/cli/builders/manifest/ManifestV3.ts"],
4
- "sourcesContent": ["import ManifestBase from \"./ManifestBase\";\n\nimport {ManifestVersion} from \"@typing/manifest\";\nimport {Browser} from \"@typing/config\";\n\nimport ManifestV3 = chrome.runtime.ManifestV3;\n\nexport default class extends ManifestBase<ManifestV3> {\n public constructor(browser: Browser) {\n super(browser);\n }\n\n public getManifestVersion(): ManifestVersion {\n return 3;\n }\n\n protected buildBackground(): Partial<ManifestV3> | undefined {\n if (this.background) {\n return {background: {service_worker: this.background.file}};\n }\n }\n\n protected buildContentScripts(): Partial<ManifestV3> | undefined {\n if (this.contentScripts.size > 0) {\n const contentScripts: ManifestV3['content_scripts'] = Array.from(this.contentScripts, ([_, contentScript]) => ({\n matches: contentScript.matches,\n exclude_matches: contentScript.excludeMatches,\n js: [contentScript.file],\n all_frames: contentScript.allFrames,\n run_at: contentScript.runAt,\n exclude_globs: contentScript.excludeGlobs,\n include_globs: contentScript.includeGlobs,\n world: contentScript.world,\n }));\n\n return {content_scripts: contentScripts};\n }\n }\n}"],
4
+ "sourcesContent": ["import ManifestBase from \"./ManifestBase\";\n\nimport {ManifestVersion} from \"../../../types/manifest\";\nimport {Browser} from \"../../../types/config\";\n\nimport ManifestV3 = chrome.runtime.ManifestV3;\n\nexport default class extends ManifestBase<ManifestV3> {\n public constructor(browser: Browser) {\n super(browser);\n }\n\n public getManifestVersion(): ManifestVersion {\n return 3;\n }\n\n protected buildBackground(): Partial<ManifestV3> | undefined {\n if (this.background) {\n return {background: {service_worker: this.background.file}};\n }\n }\n\n protected buildContentScripts(): Partial<ManifestV3> | undefined {\n if (this.contentScripts.size > 0) {\n const contentScripts: ManifestV3['content_scripts'] = Array.from(this.contentScripts, ([_, contentScript]) => ({\n matches: contentScript.matches,\n exclude_matches: contentScript.excludeMatches,\n js: [contentScript.file],\n all_frames: contentScript.allFrames,\n run_at: contentScript.runAt,\n exclude_globs: contentScript.excludeGlobs,\n include_globs: contentScript.includeGlobs,\n world: contentScript.world,\n }));\n\n return {content_scripts: contentScripts};\n }\n }\n}"],
5
5
  "mappings": "AAAA,OAAO,kBAAkB;AAOzB,MAAO,2BAAsB,aAAyB;AAAA,EAC3C,YAAY,SAAkB;AACjC,UAAM,OAAO;AAAA,EACjB;AAAA,EAEO,qBAAsC;AACzC,WAAO;AAAA,EACX;AAAA,EAEU,kBAAmD;AACzD,QAAI,KAAK,YAAY;AACjB,aAAO,EAAC,YAAY,EAAC,gBAAgB,KAAK,WAAW,KAAI,EAAC;AAAA,IAC9D;AAAA,EACJ;AAAA,EAEU,sBAAuD;AAC7D,QAAI,KAAK,eAAe,OAAO,GAAG;AAC9B,YAAM,iBAAgD,MAAM,KAAK,KAAK,gBAAgB,CAAC,CAAC,GAAG,aAAa,OAAO;AAAA,QAC3G,SAAS,cAAc;AAAA,QACvB,iBAAiB,cAAc;AAAA,QAC/B,IAAI,CAAC,cAAc,IAAI;AAAA,QACvB,YAAY,cAAc;AAAA,QAC1B,QAAQ,cAAc;AAAA,QACtB,eAAe,cAAc;AAAA,QAC7B,eAAe,cAAc;AAAA,QAC7B,OAAO,cAAc;AAAA,MACzB,EAAE;AAEF,aAAO,EAAC,iBAAiB,eAAc;AAAA,IAC3C;AAAA,EACJ;AACJ;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/cli/builders/manifest/index.ts"],
4
- "sourcesContent": ["import {ManifestBuilder, ManifestMapping, ManifestVersion} from \"@typing/manifest\";\nimport ManifestV2 from './ManifestV2';\nimport ManifestV3 from './ManifestV3';\n\nimport {Browser} from \"@typing/config\";\n\nexport default <T extends ManifestVersion>(browser: Browser, manifestVersion: T): ManifestBuilder<ManifestMapping[T]> => {\n if (manifestVersion === 2) {\n return new ManifestV2(browser);\n }\n\n return new ManifestV3(browser);\n}"],
4
+ "sourcesContent": ["import {ManifestBuilder, ManifestMapping, ManifestVersion} from \"../../../types/manifest\";\nimport ManifestV2 from './ManifestV2';\nimport ManifestV3 from './ManifestV3';\n\nimport {Browser} from \"../../../types/config\";\n\nexport default <T extends ManifestVersion>(browser: Browser, manifestVersion: T): ManifestBuilder<ManifestMapping[T]> => {\n if (manifestVersion === 2) {\n return new ManifestV2(browser);\n }\n\n return new ManifestV3(browser);\n}"],
5
5
  "mappings": "AACA,OAAO,gBAAgB;AACvB,OAAO,gBAAgB;AAIvB,IAAO,mBAAQ,CAA4B,SAAkB,oBAA4D;AACrH,MAAI,oBAAoB,GAAG;AACvB,WAAO,IAAI,WAAW,OAAO;AAAA,EACjC;AAEA,SAAO,IAAI,WAAW,OAAO;AACjC;",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,5 @@
1
1
  import cac from "cac";
2
- import { Browser } from "@typing/config";
2
+ import { Browser } from "../types/config";
3
3
  import app from "./builders/app";
4
4
  const cli = cac("addonbone");
5
5
  cli.option("--debug", "Enable debug mode");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/cli/index.ts"],
4
- "sourcesContent": ["import cac from 'cac';\n\nimport {Browser} from \"@typing/config\";\nimport app from \"./builders/app\";\n\nconst cli = cac('addonbone');\n\ncli.option('--debug', 'Enable debug mode');\n\ncli\n .command('init', 'Initialize a new project')\n .action(() => {\n console.log('init');\n });\n\ncli\n .command('[root]', 'Start dev server')\n .option('-m, --mode <mode>', 'Set env mode', {default: 'development',})\n .option('-c, --config <config>', 'Path to config file')\n .option('-a, --app <app>', 'Specify an app to run', {default: 'myapp'})\n .option('-b, --browser <browser>', 'Specify a browser')\n .option('-p, --port <port>', 'Specify a port for the dev server')\n .option('--mv2', 'Target manifest v2')\n .action((root, options) => {\n console.log(options)\n });\n\ncli\n .command('build [root]', 'Build for production')\n .option('-m, --mode <mode>', 'Set env mode', {default: 'production'})\n .option('-c, --config <config>', 'Path to config file')\n .option('-a, --app <app>', 'Specify an app to run', {default: 'myapp'})\n .option('-b, --browser <browser>', 'Specify a browser', {default: Browser.Chrome})\n .option('--mv2', 'Target manifest v2')\n .option('--analyze', 'Visualize extension bundle')\n .action(async (root, options) => {\n await app({\n mode: options.mode,\n debug: options.debug,\n app: options.app,\n browser: options.browser,\n manifestVersion: options.mv2 ? 2 : 3,\n inputDir: root,\n configFile: options.config,\n });\n });\n\ncli.help();\ncli.parse();"],
4
+ "sourcesContent": ["import cac from 'cac';\n\nimport {Browser} from \"../types/config\";\nimport app from \"./builders/app\";\n\nconst cli = cac('addonbone');\n\ncli.option('--debug', 'Enable debug mode');\n\ncli\n .command('init', 'Initialize a new project')\n .action(() => {\n console.log('init');\n });\n\ncli\n .command('[root]', 'Start dev server')\n .option('-m, --mode <mode>', 'Set env mode', {default: 'development',})\n .option('-c, --config <config>', 'Path to config file')\n .option('-a, --app <app>', 'Specify an app to run', {default: 'myapp'})\n .option('-b, --browser <browser>', 'Specify a browser')\n .option('-p, --port <port>', 'Specify a port for the dev server')\n .option('--mv2', 'Target manifest v2')\n .action((root, options) => {\n console.log(options)\n });\n\ncli\n .command('build [root]', 'Build for production')\n .option('-m, --mode <mode>', 'Set env mode', {default: 'production'})\n .option('-c, --config <config>', 'Path to config file')\n .option('-a, --app <app>', 'Specify an app to run', {default: 'myapp'})\n .option('-b, --browser <browser>', 'Specify a browser', {default: Browser.Chrome})\n .option('--mv2', 'Target manifest v2')\n .option('--analyze', 'Visualize extension bundle')\n .action(async (root, options) => {\n await app({\n mode: options.mode,\n debug: options.debug,\n app: options.app,\n browser: options.browser,\n manifestVersion: options.mv2 ? 2 : 3,\n inputDir: root,\n configFile: options.config,\n });\n });\n\ncli.help();\ncli.parse();"],
5
5
  "mappings": "AAAA,OAAO,SAAS;AAEhB,SAAQ,eAAc;AACtB,OAAO,SAAS;AAEhB,MAAM,MAAM,IAAI,WAAW;AAE3B,IAAI,OAAO,WAAW,mBAAmB;AAEzC,IACK,QAAQ,QAAQ,0BAA0B,EAC1C,OAAO,MAAM;AACV,UAAQ,IAAI,MAAM;AACtB,CAAC;AAEL,IACK,QAAQ,UAAU,kBAAkB,EACpC,OAAO,qBAAqB,gBAAgB,EAAC,SAAS,cAAc,CAAC,EACrE,OAAO,yBAAyB,qBAAqB,EACrD,OAAO,mBAAmB,yBAAyB,EAAC,SAAS,QAAO,CAAC,EACrE,OAAO,2BAA2B,mBAAmB,EACrD,OAAO,qBAAqB,mCAAmC,EAC/D,OAAO,SAAS,oBAAoB,EACpC,OAAO,CAAC,MAAM,YAAY;AACvB,UAAQ,IAAI,OAAO;AACvB,CAAC;AAEL,IACK,QAAQ,gBAAgB,sBAAsB,EAC9C,OAAO,qBAAqB,gBAAgB,EAAC,SAAS,aAAY,CAAC,EACnE,OAAO,yBAAyB,qBAAqB,EACrD,OAAO,mBAAmB,yBAAyB,EAAC,SAAS,QAAO,CAAC,EACrE,OAAO,2BAA2B,qBAAqB,EAAC,SAAS,QAAQ,OAAM,CAAC,EAChF,OAAO,SAAS,oBAAoB,EACpC,OAAO,aAAa,4BAA4B,EAChD,OAAO,OAAO,MAAM,YAAY;AAC7B,QAAM,IAAI;AAAA,IACN,MAAM,QAAQ;AAAA,IACd,OAAO,QAAQ;AAAA,IACf,KAAK,QAAQ;AAAA,IACb,SAAS,QAAQ;AAAA,IACjB,iBAAiB,QAAQ,MAAM,IAAI;AAAA,IACnC,UAAU;AAAA,IACV,YAAY,QAAQ;AAAA,EACxB,CAAC;AACL,CAAC;AAEL,IAAI,KAAK;AACT,IAAI,MAAM;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/cli/parsers/entrypoint/index.ts"],
4
- "sourcesContent": ["import OptionFile from \"./OptionFile\";\n\nimport {BackgroundEntrypointOptions} from \"@typing/background\";\nimport {BaseEntrypointOptions} from \"@typing/base\";\n\nconst commonProperties: Array<keyof BaseEntrypointOptions> = [\n 'includeApp',\n 'excludeApp',\n 'includeBrowser',\n 'excludeBrowser',\n];\n\nexport const getBackgroundOptions = (file: string): BackgroundEntrypointOptions => {\n return OptionFile.make(file)\n .setDefinition('defineBackground')\n .setProperties([...commonProperties, 'persistent'])\n .getOptions();\n}"],
4
+ "sourcesContent": ["import OptionFile from \"./OptionFile\";\n\nimport {BackgroundEntrypointOptions} from \"../../../types/background\";\nimport {BaseEntrypointOptions} from \"../../../types/base\";\n\nconst commonProperties: Array<keyof BaseEntrypointOptions> = [\n 'includeApp',\n 'excludeApp',\n 'includeBrowser',\n 'excludeBrowser',\n];\n\nexport const getBackgroundOptions = (file: string): BackgroundEntrypointOptions => {\n return OptionFile.make(file)\n .setDefinition('defineBackground')\n .setProperties([...commonProperties, 'persistent'])\n .getOptions();\n}"],
5
5
  "mappings": "AAAA,OAAO,gBAAgB;AAKvB,MAAM,mBAAuD;AAAA,EACzD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;AAEO,MAAM,uBAAuB,CAAC,SAA8C;AAC/E,SAAO,WAAW,KAAK,IAAI,EACtB,cAAc,kBAAkB,EAChC,cAAc,CAAC,GAAG,kBAAkB,YAAY,CAAC,EACjD,WAAW;AACpB;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cli/plugins/background.ts"],
4
- "sourcesContent": ["import path from \"path\";\nimport _isFunction from \"lodash/isFunction\";\n\nimport {getBackgroundOptions} from \"../parsers/entrypoint\";\n\nimport {getAppsPath, getSharedPath} from \"../resolvers/path\";\n\nimport {processPluginHandler} from \"../utils/plugin\";\nimport {isValidEntrypointOptions} from \"../utils/option\";\nimport {findBackgroundFiles} from \"../utils/entrypoint\";\n\nimport {Plugin} from \"@typing/plugin\";\nimport {BackgroundEntrypointMap} from \"@typing/background\";\n\n\nconst backgroundFilesToEntries = (files: string[]): BackgroundEntrypointMap => {\n const entries: BackgroundEntrypointMap = new Map;\n\n for (const file of files) {\n entries.set(file, getBackgroundOptions(file));\n }\n\n return entries;\n}\n\nconst findBackgroundEntries = (dir: string): BackgroundEntrypointMap => {\n return backgroundFilesToEntries(findBackgroundFiles(dir));\n}\n\nexport interface BackgroundOptions {\n name?: string;\n}\n\nexport default (options?: BackgroundOptions): Plugin => {\n const {name = 'background'} = options || {};\n\n let hasBackground: boolean = false;\n\n return {\n webpack: async ({config, webpack}) => {\n let entries: BackgroundEntrypointMap = new Map;\n\n const appBackgroundEntries = findBackgroundEntries(getAppsPath(config));\n\n if (appBackgroundEntries.size > 0) {\n entries = new Map([...entries, ...appBackgroundEntries]);\n\n if (config.debug) {\n console.info('App background added:', appBackgroundEntries);\n }\n }\n\n if (appBackgroundEntries.size > 0 && config.mergeBackground || appBackgroundEntries.size === 0) {\n const sharedBackgroundEntries = findBackgroundEntries(getSharedPath(config));\n\n if (sharedBackgroundEntries.size > 0) {\n entries = new Map([...entries, ...sharedBackgroundEntries]);\n\n if (config.debug) {\n console.info('Shared background added:', sharedBackgroundEntries);\n }\n }\n }\n\n const pluginBackgroundFiles = await Array.fromAsync(processPluginHandler(config, 'background', {\n config,\n entries\n }));\n\n console.log('pluginBackgroundFiles', pluginBackgroundFiles);\n\n if (pluginBackgroundFiles.length > 0) {\n const pluginBackgroundEntries = backgroundFilesToEntries(pluginBackgroundFiles);\n\n entries = new Map([...entries, ...pluginBackgroundEntries]);\n\n if (config.debug) {\n console.info('Plugin background added:', pluginBackgroundEntries);\n }\n }\n\n const files = Array.from(entries)\n .filter(([_, options]) => isValidEntrypointOptions(options, config))\n .map(([file]) => file);\n\n if (files.length === 0) {\n if (config.debug) {\n console.warn('Background entries not found');\n }\n\n return {};\n }\n\n hasBackground = true;\n\n if (config.debug) {\n console.info('Background entries:', entries);\n }\n\n return {\n entry: {\n [name]: files,\n },\n optimization: {\n splitChunks: {\n chunks(chunk) {\n const {chunks} = webpack.optimization?.splitChunks || {};\n\n if (_isFunction(chunks) && !chunks(chunk)) {\n return false;\n }\n\n return chunk.name !== name;\n },\n }\n }\n };\n },\n manifest: ({manifest, config}) => {\n if (hasBackground) {\n manifest.resetBackground({\n entry: name,\n file: path.join(config.jsDir, name + '.js'),\n });\n }\n }\n };\n};"],
4
+ "sourcesContent": ["import path from \"path\";\nimport _isFunction from \"lodash/isFunction\";\n\nimport {getBackgroundOptions} from \"../parsers/entrypoint\";\n\nimport {getAppsPath, getSharedPath} from \"../resolvers/path\";\n\nimport {processPluginHandler} from \"../utils/plugin\";\nimport {isValidEntrypointOptions} from \"../utils/option\";\nimport {findBackgroundFiles} from \"../utils/entrypoint\";\n\nimport {Plugin} from \"../../types/plugin\";\nimport {BackgroundEntrypointMap} from \"../../types/background\";\n\n\nconst backgroundFilesToEntries = (files: string[]): BackgroundEntrypointMap => {\n const entries: BackgroundEntrypointMap = new Map;\n\n for (const file of files) {\n entries.set(file, getBackgroundOptions(file));\n }\n\n return entries;\n}\n\nconst findBackgroundEntries = (dir: string): BackgroundEntrypointMap => {\n return backgroundFilesToEntries(findBackgroundFiles(dir));\n}\n\nexport interface BackgroundOptions {\n name?: string;\n}\n\nexport default (options?: BackgroundOptions): Plugin => {\n const {name = 'background'} = options || {};\n\n let hasBackground: boolean = false;\n\n return {\n webpack: async ({config, webpack}) => {\n let entries: BackgroundEntrypointMap = new Map;\n\n const appBackgroundEntries = findBackgroundEntries(getAppsPath(config));\n\n if (appBackgroundEntries.size > 0) {\n entries = new Map([...entries, ...appBackgroundEntries]);\n\n if (config.debug) {\n console.info('App background added:', appBackgroundEntries);\n }\n }\n\n if (appBackgroundEntries.size > 0 && config.mergeBackground || appBackgroundEntries.size === 0) {\n const sharedBackgroundEntries = findBackgroundEntries(getSharedPath(config));\n\n if (sharedBackgroundEntries.size > 0) {\n entries = new Map([...entries, ...sharedBackgroundEntries]);\n\n if (config.debug) {\n console.info('Shared background added:', sharedBackgroundEntries);\n }\n }\n }\n\n const pluginBackgroundFiles = await Array.fromAsync(processPluginHandler(config, 'background', {\n config,\n entries\n }));\n\n console.log('pluginBackgroundFiles', pluginBackgroundFiles);\n\n if (pluginBackgroundFiles.length > 0) {\n const pluginBackgroundEntries = backgroundFilesToEntries(pluginBackgroundFiles);\n\n entries = new Map([...entries, ...pluginBackgroundEntries]);\n\n if (config.debug) {\n console.info('Plugin background added:', pluginBackgroundEntries);\n }\n }\n\n const files = Array.from(entries)\n .filter(([_, options]) => isValidEntrypointOptions(options, config))\n .map(([file]) => file);\n\n if (files.length === 0) {\n if (config.debug) {\n console.warn('Background entries not found');\n }\n\n return {};\n }\n\n hasBackground = true;\n\n if (config.debug) {\n console.info('Background entries:', entries);\n }\n\n return {\n entry: {\n [name]: files,\n },\n optimization: {\n splitChunks: {\n chunks(chunk) {\n const {chunks} = webpack.optimization?.splitChunks || {};\n\n if (_isFunction(chunks) && !chunks(chunk)) {\n return false;\n }\n\n return chunk.name !== name;\n },\n }\n }\n };\n },\n manifest: ({manifest, config}) => {\n if (hasBackground) {\n manifest.resetBackground({\n entry: name,\n file: path.join(config.jsDir, name + '.js'),\n });\n }\n }\n };\n};"],
5
5
  "mappings": "AAAA,OAAO,UAAU;AACjB,OAAO,iBAAiB;AAExB,SAAQ,4BAA2B;AAEnC,SAAQ,aAAa,qBAAoB;AAEzC,SAAQ,4BAA2B;AACnC,SAAQ,gCAA+B;AACvC,SAAQ,2BAA0B;AAMlC,MAAM,2BAA2B,CAAC,UAA6C;AAC3E,QAAM,UAAmC,oBAAI;AAE7C,aAAW,QAAQ,OAAO;AACtB,YAAQ,IAAI,MAAM,qBAAqB,IAAI,CAAC;AAAA,EAChD;AAEA,SAAO;AACX;AAEA,MAAM,wBAAwB,CAAC,QAAyC;AACpE,SAAO,yBAAyB,oBAAoB,GAAG,CAAC;AAC5D;AAMA,IAAO,qBAAQ,CAAC,YAAwC;AACpD,QAAM,EAAC,OAAO,aAAY,IAAI,WAAW,CAAC;AAE1C,MAAI,gBAAyB;AAE7B,SAAO;AAAA,IACH,SAAS,OAAO,EAAC,QAAQ,QAAO,MAAM;AAClC,UAAI,UAAmC,oBAAI;AAE3C,YAAM,uBAAuB,sBAAsB,YAAY,MAAM,CAAC;AAEtE,UAAI,qBAAqB,OAAO,GAAG;AAC/B,kBAAU,IAAI,IAAI,CAAC,GAAG,SAAS,GAAG,oBAAoB,CAAC;AAEvD,YAAI,OAAO,OAAO;AACd,kBAAQ,KAAK,yBAAyB,oBAAoB;AAAA,QAC9D;AAAA,MACJ;AAEA,UAAI,qBAAqB,OAAO,KAAK,OAAO,mBAAmB,qBAAqB,SAAS,GAAG;AAC5F,cAAM,0BAA0B,sBAAsB,cAAc,MAAM,CAAC;AAE3E,YAAI,wBAAwB,OAAO,GAAG;AAClC,oBAAU,IAAI,IAAI,CAAC,GAAG,SAAS,GAAG,uBAAuB,CAAC;AAE1D,cAAI,OAAO,OAAO;AACd,oBAAQ,KAAK,4BAA4B,uBAAuB;AAAA,UACpE;AAAA,QACJ;AAAA,MACJ;AAEA,YAAM,wBAAwB,MAAM,MAAM,UAAU,qBAAqB,QAAQ,cAAc;AAAA,QAC3F;AAAA,QACA;AAAA,MACJ,CAAC,CAAC;AAEF,cAAQ,IAAI,yBAAyB,qBAAqB;AAE1D,UAAI,sBAAsB,SAAS,GAAG;AAClC,cAAM,0BAA0B,yBAAyB,qBAAqB;AAE9E,kBAAU,IAAI,IAAI,CAAC,GAAG,SAAS,GAAG,uBAAuB,CAAC;AAE1D,YAAI,OAAO,OAAO;AACd,kBAAQ,KAAK,4BAA4B,uBAAuB;AAAA,QACpE;AAAA,MACJ;AAEA,YAAM,QAAQ,MAAM,KAAK,OAAO,EAC3B,OAAO,CAAC,CAAC,GAAGA,QAAO,MAAM,yBAAyBA,UAAS,MAAM,CAAC,EAClE,IAAI,CAAC,CAAC,IAAI,MAAM,IAAI;AAEzB,UAAI,MAAM,WAAW,GAAG;AACpB,YAAI,OAAO,OAAO;AACd,kBAAQ,KAAK,8BAA8B;AAAA,QAC/C;AAEA,eAAO,CAAC;AAAA,MACZ;AAEA,sBAAgB;AAEhB,UAAI,OAAO,OAAO;AACd,gBAAQ,KAAK,uBAAuB,OAAO;AAAA,MAC/C;AAEA,aAAO;AAAA,QACH,OAAO;AAAA,UACH,CAAC,IAAI,GAAG;AAAA,QACZ;AAAA,QACA,cAAc;AAAA,UACV,aAAa;AAAA,YACT,OAAO,OAAO;AACV,oBAAM,EAAC,OAAM,IAAI,QAAQ,cAAc,eAAe,CAAC;AAEvD,kBAAI,YAAY,MAAM,KAAK,CAAC,OAAO,KAAK,GAAG;AACvC,uBAAO;AAAA,cACX;AAEA,qBAAO,MAAM,SAAS;AAAA,YAC1B;AAAA,UACJ;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAAA,IACA,UAAU,CAAC,EAAC,UAAU,OAAM,MAAM;AAC9B,UAAI,eAAe;AACf,iBAAS,gBAAgB;AAAA,UACrB,OAAO;AAAA,UACP,MAAM,KAAK,KAAK,OAAO,OAAO,OAAO,KAAK;AAAA,QAC9C,CAAC;AAAA,MACL;AAAA,IACJ;AAAA,EACJ;AACJ;",
6
6
  "names": ["options"]
7
7
  }
@@ -1,6 +1,6 @@
1
1
  import path from "path";
2
2
  import VirtualModulesPlugin from "webpack-virtual-modules";
3
- import { getAppsPath } from "@cli/resolvers/path";
3
+ import { getAppsPath } from "../resolvers/path";
4
4
  var content_default = () => {
5
5
  const contentScripts = [];
6
6
  return {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cli/plugins/content.ts"],
4
- "sourcesContent": ["import path from \"path\";\nimport {Configuration} from \"webpack\";\nimport VirtualModulesPlugin from \"webpack-virtual-modules\";\n\nimport {getAppsPath} from \"@cli/resolvers/path\";\nimport {Plugin} from \"@typing/plugin\";\nimport {ManifestContentScript} from \"@typing/manifest\";\n\n\nexport default (): Plugin => {\n const contentScripts: ManifestContentScript[] = [];\n\n return {\n webpack: async ({config}): Promise<Configuration> => {\n\n //\n // console.log(findContentFiles(getAppsPath(config)));\n // console.log(findContentFiles(getSharedPath(config)));\n\n const p = path.resolve(getAppsPath(config), 'src/some.ts');\n\n return {\n entry: {\n some: p,\n },\n plugins: [\n new VirtualModulesPlugin({\n [p]: 'console.log(\"Hello, World!\")'\n })\n ]\n };\n },\n manifest: ({manifest}) => {\n manifest.pushContentScript(...contentScripts);\n }\n };\n};"],
4
+ "sourcesContent": ["import path from \"path\";\nimport {Configuration} from \"webpack\";\nimport VirtualModulesPlugin from \"webpack-virtual-modules\";\n\nimport {getAppsPath} from \"../resolvers/path\";\nimport {Plugin} from \"../../types/plugin\";\nimport {ManifestContentScript} from \"../../types/manifest\";\n\n\nexport default (): Plugin => {\n const contentScripts: ManifestContentScript[] = [];\n\n return {\n webpack: async ({config}): Promise<Configuration> => {\n\n //\n // console.log(findContentFiles(getAppsPath(config)));\n // console.log(findContentFiles(getSharedPath(config)));\n\n const p = path.resolve(getAppsPath(config), 'src/some.ts');\n\n return {\n entry: {\n some: p,\n },\n plugins: [\n new VirtualModulesPlugin({\n [p]: 'console.log(\"Hello, World!\")'\n })\n ]\n };\n },\n manifest: ({manifest}) => {\n manifest.pushContentScript(...contentScripts);\n }\n };\n};"],
5
5
  "mappings": "AAAA,OAAO,UAAU;AAEjB,OAAO,0BAA0B;AAEjC,SAAQ,mBAAkB;AAK1B,IAAO,kBAAQ,MAAc;AACzB,QAAM,iBAA0C,CAAC;AAEjD,SAAO;AAAA,IACH,SAAS,OAAO,EAAC,OAAM,MAA8B;AAMjD,YAAM,IAAI,KAAK,QAAQ,YAAY,MAAM,GAAG,aAAa;AAEzD,aAAO;AAAA,QACH,OAAO;AAAA,UACH,MAAM;AAAA,QACV;AAAA,QACA,SAAS;AAAA,UACL,IAAI,qBAAqB;AAAA,YACrB,CAAC,CAAC,GAAG;AAAA,UACT,CAAC;AAAA,QACL;AAAA,MACJ;AAAA,IACJ;AAAA,IACA,UAAU,CAAC,EAAC,SAAQ,MAAM;AACtB,eAAS,kBAAkB,GAAG,cAAc;AAAA,IAChD;AAAA,EACJ;AACJ;",
6
6
  "names": []
7
7
  }
@@ -1,13 +1,13 @@
1
1
  import { existsSync } from "fs";
2
2
  import _isFunction from "lodash/isFunction";
3
3
  import _isPlainObject from "lodash/isPlainObject";
4
- import content from "@cli/plugins/content";
5
- import background from "@cli/plugins/background";
6
- import { getConfigFile } from "@cli/resolvers/path";
4
+ import content from "../plugins/content";
5
+ import background from "../plugins/background";
6
+ import { getConfigFile } from "./path";
7
7
  import {
8
8
  Browser,
9
9
  Mode
10
- } from "@typing/config";
10
+ } from "../../types/config";
11
11
  const getUserConfig = async (config) => {
12
12
  const configFilePath = getConfigFile(config);
13
13
  let resolvedUserConfig = {};
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cli/resolvers/config.ts"],
4
- "sourcesContent": ["import {existsSync} from \"fs\";\nimport _isFunction from \"lodash/isFunction\";\nimport _isPlainObject from \"lodash/isPlainObject\";\n\nimport content from \"@cli/plugins/content\";\nimport background from \"@cli/plugins/background\";\n\nimport {getConfigFile} from \"@cli/resolvers/path\";\n\nimport {\n Browser,\n Config,\n ConfigDefinition,\n Mode,\n OptionalConfig,\n ReadonlyConfig,\n UserConfig,\n UserConfigCallback,\n} from \"@typing/config\";\nimport {Plugin} from \"@typing/plugin\";\n\nconst getUserConfig = async (config: ReadonlyConfig): Promise<UserConfig> => {\n const configFilePath = getConfigFile(config);\n\n let resolvedUserConfig: UserConfig = {};\n\n if (existsSync(configFilePath)) {\n let {default: userConfigDefinition = undefined as ConfigDefinition | undefined} = await import(configFilePath);\n\n if (_isFunction(userConfigDefinition)) {\n let userConfigCallback: UserConfigCallback = userConfigDefinition(config);\n\n resolvedUserConfig = await userConfigCallback(config);\n } else {\n resolvedUserConfig = userConfigDefinition;\n }\n\n if (_isPlainObject(resolvedUserConfig) && config.debug) {\n console.log('Loaded user config:', configFilePath);\n } else if (config.debug) {\n console.error('Invalid user config:', configFilePath);\n }\n } else if (config.debug) {\n console.warn('Config file not found:', configFilePath);\n }\n\n return resolvedUserConfig;\n}\n\nexport default async (config: OptionalConfig): Promise<Config> => {\n let {\n debug = false,\n configFile = 'addonbone.config.ts',\n app = 'myapp',\n browser = Browser.Chrome,\n inputDir = '.',\n outputDir = 'dist',\n srcDir = 'src',\n sharedDir = 'shared',\n appsDir = 'apps',\n jsDir = 'js',\n cssDir = 'css',\n assetsDir = 'assets',\n htmlDir = '.',\n manifestVersion = [Browser.Firefox, Browser.Safari].includes(browser) ? 2 : 3,\n mode = Mode.Development,\n analyze = false,\n plugins = [],\n mergeBackground = false,\n mergeContentScripts = false,\n concatContentScripts = true,\n } = config;\n\n let resolvedConfig: Config = {\n debug,\n mode,\n app,\n browser,\n manifestVersion,\n inputDir,\n outputDir,\n srcDir,\n sharedDir,\n appsDir,\n jsDir,\n cssDir,\n assetsDir,\n htmlDir,\n plugins,\n analyze,\n configFile,\n mergeBackground,\n mergeContentScripts,\n concatContentScripts,\n };\n\n const {plugins: userPlugins = [], ...userConfig} = await getUserConfig(resolvedConfig);\n\n const corePlugins: Plugin[] = [content(), background()];\n\n return {\n ...resolvedConfig,\n ...userConfig,\n plugins: [\n ...plugins,\n ...userPlugins,\n ...corePlugins,\n ]\n };\n}"],
4
+ "sourcesContent": ["import {existsSync} from \"fs\";\nimport _isFunction from \"lodash/isFunction\";\nimport _isPlainObject from \"lodash/isPlainObject\";\n\nimport content from \"../plugins/content\";\nimport background from \"../plugins/background\";\n\nimport {getConfigFile} from \"./path\";\n\nimport {\n Browser,\n Config,\n ConfigDefinition,\n Mode,\n OptionalConfig,\n ReadonlyConfig,\n UserConfig,\n UserConfigCallback,\n} from \"../../types/config\";\nimport {Plugin} from \"../../types/plugin\";\n\nconst getUserConfig = async (config: ReadonlyConfig): Promise<UserConfig> => {\n const configFilePath = getConfigFile(config);\n\n let resolvedUserConfig: UserConfig = {};\n\n if (existsSync(configFilePath)) {\n let {default: userConfigDefinition = undefined as ConfigDefinition | undefined} = await import(configFilePath);\n\n if (_isFunction(userConfigDefinition)) {\n let userConfigCallback: UserConfigCallback = userConfigDefinition(config);\n\n resolvedUserConfig = await userConfigCallback(config);\n } else {\n resolvedUserConfig = userConfigDefinition;\n }\n\n if (_isPlainObject(resolvedUserConfig) && config.debug) {\n console.log('Loaded user config:', configFilePath);\n } else if (config.debug) {\n console.error('Invalid user config:', configFilePath);\n }\n } else if (config.debug) {\n console.warn('Config file not found:', configFilePath);\n }\n\n return resolvedUserConfig;\n}\n\nexport default async (config: OptionalConfig): Promise<Config> => {\n let {\n debug = false,\n configFile = 'addonbone.config.ts',\n app = 'myapp',\n browser = Browser.Chrome,\n inputDir = '.',\n outputDir = 'dist',\n srcDir = 'src',\n sharedDir = 'shared',\n appsDir = 'apps',\n jsDir = 'js',\n cssDir = 'css',\n assetsDir = 'assets',\n htmlDir = '.',\n manifestVersion = [Browser.Firefox, Browser.Safari].includes(browser) ? 2 : 3,\n mode = Mode.Development,\n analyze = false,\n plugins = [],\n mergeBackground = false,\n mergeContentScripts = false,\n concatContentScripts = true,\n } = config;\n\n let resolvedConfig: Config = {\n debug,\n mode,\n app,\n browser,\n manifestVersion,\n inputDir,\n outputDir,\n srcDir,\n sharedDir,\n appsDir,\n jsDir,\n cssDir,\n assetsDir,\n htmlDir,\n plugins,\n analyze,\n configFile,\n mergeBackground,\n mergeContentScripts,\n concatContentScripts,\n };\n\n const {plugins: userPlugins = [], ...userConfig} = await getUserConfig(resolvedConfig);\n\n const corePlugins: Plugin[] = [content(), background()];\n\n return {\n ...resolvedConfig,\n ...userConfig,\n plugins: [\n ...plugins,\n ...userPlugins,\n ...corePlugins,\n ]\n };\n}"],
5
5
  "mappings": "AAAA,SAAQ,kBAAiB;AACzB,OAAO,iBAAiB;AACxB,OAAO,oBAAoB;AAE3B,OAAO,aAAa;AACpB,OAAO,gBAAgB;AAEvB,SAAQ,qBAAoB;AAE5B;AAAA,EACI;AAAA,EAGA;AAAA,OAKG;AAGP,MAAM,gBAAgB,OAAO,WAAgD;AACzE,QAAM,iBAAiB,cAAc,MAAM;AAE3C,MAAI,qBAAiC,CAAC;AAEtC,MAAI,WAAW,cAAc,GAAG;AAC5B,QAAI,EAAC,SAAS,uBAAuB,OAAyC,IAAI,MAAM,OAAO;AAE/F,QAAI,YAAY,oBAAoB,GAAG;AACnC,UAAI,qBAAyC,qBAAqB,MAAM;AAExE,2BAAqB,MAAM,mBAAmB,MAAM;AAAA,IACxD,OAAO;AACH,2BAAqB;AAAA,IACzB;AAEA,QAAI,eAAe,kBAAkB,KAAK,OAAO,OAAO;AACpD,cAAQ,IAAI,uBAAuB,cAAc;AAAA,IACrD,WAAW,OAAO,OAAO;AACrB,cAAQ,MAAM,wBAAwB,cAAc;AAAA,IACxD;AAAA,EACJ,WAAW,OAAO,OAAO;AACrB,YAAQ,KAAK,0BAA0B,cAAc;AAAA,EACzD;AAEA,SAAO;AACX;AAEA,IAAO,iBAAQ,OAAO,WAA4C;AAC9D,MAAI;AAAA,IACA,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,MAAM;AAAA,IACN,UAAU,QAAQ;AAAA,IAClB,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,kBAAkB,CAAC,QAAQ,SAAS,QAAQ,MAAM,EAAE,SAAS,OAAO,IAAI,IAAI;AAAA,IAC5E,OAAO,KAAK;AAAA,IACZ,UAAU;AAAA,IACV,UAAU,CAAC;AAAA,IACX,kBAAkB;AAAA,IAClB,sBAAsB;AAAA,IACtB,uBAAuB;AAAA,EAC3B,IAAI;AAEJ,MAAI,iBAAyB;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ;AAEA,QAAM,EAAC,SAAS,cAAc,CAAC,GAAG,GAAG,WAAU,IAAI,MAAM,cAAc,cAAc;AAErF,QAAM,cAAwB,CAAC,QAAQ,GAAG,WAAW,CAAC;AAEtD,SAAO;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,IACH,SAAS;AAAA,MACL,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,IACP;AAAA,EACJ;AACJ;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cli/resolvers/path.ts"],
4
- "sourcesContent": ["import path from 'path';\n\nimport {ReadonlyConfig} from \"@typing/config\";\n\nexport const getRootPath = (to: string): string => {\n return path.resolve(process.cwd(), to);\n}\n\nexport const getConfigFile = (config: ReadonlyConfig): string => {\n return path.resolve(config.inputDir, config.configFile);\n}\n\nexport const getSharedPath = (config: ReadonlyConfig): string => {\n return path.resolve(config.inputDir, config.srcDir, config.sharedDir);\n}\n\nexport const getAppsPath = (config: ReadonlyConfig): string => {\n return path.resolve(config.inputDir, config.srcDir, config.appsDir, config.app);\n}"],
4
+ "sourcesContent": ["import path from 'path';\n\nimport {ReadonlyConfig} from \"../../types/config\";\n\nexport const getRootPath = (to: string): string => {\n return path.resolve(process.cwd(), to);\n}\n\nexport const getConfigFile = (config: ReadonlyConfig): string => {\n return path.resolve(config.inputDir, config.configFile);\n}\n\nexport const getSharedPath = (config: ReadonlyConfig): string => {\n return path.resolve(config.inputDir, config.srcDir, config.sharedDir);\n}\n\nexport const getAppsPath = (config: ReadonlyConfig): string => {\n return path.resolve(config.inputDir, config.srcDir, config.appsDir, config.app);\n}"],
5
5
  "mappings": "AAAA,OAAO,UAAU;AAIV,MAAM,cAAc,CAAC,OAAuB;AAC/C,SAAO,KAAK,QAAQ,QAAQ,IAAI,GAAG,EAAE;AACzC;AAEO,MAAM,gBAAgB,CAAC,WAAmC;AAC7D,SAAO,KAAK,QAAQ,OAAO,UAAU,OAAO,UAAU;AAC1D;AAEO,MAAM,gBAAgB,CAAC,WAAmC;AAC7D,SAAO,KAAK,QAAQ,OAAO,UAAU,OAAO,QAAQ,OAAO,SAAS;AACxE;AAEO,MAAM,cAAc,CAAC,WAAmC;AAC3D,SAAO,KAAK,QAAQ,OAAO,UAAU,OAAO,QAAQ,OAAO,SAAS,OAAO,GAAG;AAClF;",
6
6
  "names": []
7
7
  }
@@ -2,9 +2,9 @@ import { merge } from "webpack-merge";
2
2
  import path from "path";
3
3
  import TsconfigPathsPlugin from "tsconfig-paths-webpack-plugin";
4
4
  import MiniCssExtractPlugin from "mini-css-extract-plugin";
5
- import manifestFactory from "@cli/builders/manifest";
5
+ import manifestFactory from "../builders/manifest";
6
6
  import { getRootPath } from "./path";
7
- import { processPluginHandler } from "@cli/utils/plugin";
7
+ import { processPluginHandler } from "../utils/plugin";
8
8
  const getConfigFromPlugins = async (webpack, config) => {
9
9
  let mergedConfig = {};
10
10
  for await (const webpackFromPlugin of processPluginHandler(config, "webpack", { webpack, config })) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cli/resolvers/webpack.ts"],
4
- "sourcesContent": ["import {Configuration} from \"webpack\";\nimport {merge} from \"webpack-merge\";\nimport path from \"path\";\n\nimport TsconfigPathsPlugin from \"tsconfig-paths-webpack-plugin\";\nimport MiniCssExtractPlugin from \"mini-css-extract-plugin\";\n\nimport manifestFactory from \"@cli/builders/manifest\";\n\nimport {ReadonlyConfig} from \"@typing/config\";\n\nimport {getRootPath} from \"./path\";\nimport {processPluginHandler} from \"@cli/utils/plugin\";\nimport {ManifestBuilder} from \"@typing/manifest\";\n\nconst getConfigFromPlugins = async (webpack: Configuration, config: ReadonlyConfig): Promise<Configuration> => {\n let mergedConfig: Configuration = {};\n\n for await (const webpackFromPlugin of processPluginHandler(config, 'webpack', {webpack, config})) {\n mergedConfig = merge(mergedConfig, webpackFromPlugin);\n }\n\n return mergedConfig;\n}\n\nconst getConfigForManifest = async (webpack: Configuration, config: ReadonlyConfig, manifest: ManifestBuilder): Promise<Configuration> => {\n await Array.fromAsync(processPluginHandler(config, 'manifest', {manifest, config}));\n\n console.log(manifest.get());\n\n return webpack;\n}\n\nexport default async (config: ReadonlyConfig): Promise<Configuration> => {\n const manifest = manifestFactory(config.browser, config.manifestVersion);\n\n let webpack: Configuration = {\n mode: config.mode,\n cache: false,\n output: {\n path: getRootPath(config.outputDir),\n filename: path.join(config.jsDir, '[name].js'),\n assetModuleFilename: path.join(config.assetsDir, '[name]-[hash:4][ext]'),\n },\n resolve: {\n extensions: [\".ts\", \".tsx\", \".js\", \".scss\"],\n plugins: [new TsconfigPathsPlugin()],\n },\n module: {\n rules: [\n {\n test: /\\.tsx?$/,\n use: \"ts-loader\",\n exclude: /node_modules/,\n },\n {\n test: /\\.(scss|css)$/,\n use: [\n MiniCssExtractPlugin.loader,\n {\n loader: \"css-loader\",\n options: {\n modules: {\n localIdentName: \"[local]\"\n },\n }\n },\n {\n loader: \"sass-loader\",\n options: {\n implementation: import(\"sass\"),\n },\n },\n ],\n },\n {\n test: /\\.(png|apng|jpe?g|gif|webp|svg])$/i,\n type: \"asset/resource\",\n },\n ],\n }\n }\n\n webpack = merge(\n webpack,\n await getConfigFromPlugins(webpack, config),\n await getConfigForManifest(webpack, config, manifest),\n );\n\n\n return webpack;\n}"],
4
+ "sourcesContent": ["import {Configuration} from \"webpack\";\nimport {merge} from \"webpack-merge\";\nimport path from \"path\";\n\nimport TsconfigPathsPlugin from \"tsconfig-paths-webpack-plugin\";\nimport MiniCssExtractPlugin from \"mini-css-extract-plugin\";\n\nimport manifestFactory from \"../builders/manifest\";\n\nimport {ReadonlyConfig} from \"../../types/config\";\n\nimport {getRootPath} from \"./path\";\nimport {processPluginHandler} from \"../utils/plugin\";\nimport {ManifestBuilder} from \"../../types/manifest\";\n\nconst getConfigFromPlugins = async (webpack: Configuration, config: ReadonlyConfig): Promise<Configuration> => {\n let mergedConfig: Configuration = {};\n\n for await (const webpackFromPlugin of processPluginHandler(config, 'webpack', {webpack, config})) {\n mergedConfig = merge(mergedConfig, webpackFromPlugin);\n }\n\n return mergedConfig;\n}\n\nconst getConfigForManifest = async (webpack: Configuration, config: ReadonlyConfig, manifest: ManifestBuilder): Promise<Configuration> => {\n await Array.fromAsync(processPluginHandler(config, 'manifest', {manifest, config}));\n\n console.log(manifest.get());\n\n return webpack;\n}\n\nexport default async (config: ReadonlyConfig): Promise<Configuration> => {\n const manifest = manifestFactory(config.browser, config.manifestVersion);\n\n let webpack: Configuration = {\n mode: config.mode,\n cache: false,\n output: {\n path: getRootPath(config.outputDir),\n filename: path.join(config.jsDir, '[name].js'),\n assetModuleFilename: path.join(config.assetsDir, '[name]-[hash:4][ext]'),\n },\n resolve: {\n extensions: [\".ts\", \".tsx\", \".js\", \".scss\"],\n plugins: [new TsconfigPathsPlugin()],\n },\n module: {\n rules: [\n {\n test: /\\.tsx?$/,\n use: \"ts-loader\",\n exclude: /node_modules/,\n },\n {\n test: /\\.(scss|css)$/,\n use: [\n MiniCssExtractPlugin.loader,\n {\n loader: \"css-loader\",\n options: {\n modules: {\n localIdentName: \"[local]\"\n },\n }\n },\n {\n loader: \"sass-loader\",\n options: {\n implementation: import(\"sass\"),\n },\n },\n ],\n },\n {\n test: /\\.(png|apng|jpe?g|gif|webp|svg])$/i,\n type: \"asset/resource\",\n },\n ],\n }\n }\n\n webpack = merge(\n webpack,\n await getConfigFromPlugins(webpack, config),\n await getConfigForManifest(webpack, config, manifest),\n );\n\n\n return webpack;\n}"],
5
5
  "mappings": "AACA,SAAQ,aAAY;AACpB,OAAO,UAAU;AAEjB,OAAO,yBAAyB;AAChC,OAAO,0BAA0B;AAEjC,OAAO,qBAAqB;AAI5B,SAAQ,mBAAkB;AAC1B,SAAQ,4BAA2B;AAGnC,MAAM,uBAAuB,OAAO,SAAwB,WAAmD;AAC3G,MAAI,eAA8B,CAAC;AAEnC,mBAAiB,qBAAqB,qBAAqB,QAAQ,WAAW,EAAC,SAAS,OAAM,CAAC,GAAG;AAC9F,mBAAe,MAAM,cAAc,iBAAiB;AAAA,EACxD;AAEA,SAAO;AACX;AAEA,MAAM,uBAAuB,OAAO,SAAwB,QAAwB,aAAsD;AACtI,QAAM,MAAM,UAAU,qBAAqB,QAAQ,YAAY,EAAC,UAAU,OAAM,CAAC,CAAC;AAElF,UAAQ,IAAI,SAAS,IAAI,CAAC;AAE1B,SAAO;AACX;AAEA,IAAO,kBAAQ,OAAO,WAAmD;AACrE,QAAM,WAAW,gBAAgB,OAAO,SAAS,OAAO,eAAe;AAEvE,MAAI,UAAyB;AAAA,IACzB,MAAM,OAAO;AAAA,IACb,OAAO;AAAA,IACP,QAAQ;AAAA,MACJ,MAAM,YAAY,OAAO,SAAS;AAAA,MAClC,UAAU,KAAK,KAAK,OAAO,OAAO,WAAW;AAAA,MAC7C,qBAAqB,KAAK,KAAK,OAAO,WAAW,sBAAsB;AAAA,IAC3E;AAAA,IACA,SAAS;AAAA,MACL,YAAY,CAAC,OAAO,QAAQ,OAAO,OAAO;AAAA,MAC1C,SAAS,CAAC,IAAI,oBAAoB,CAAC;AAAA,IACvC;AAAA,IACA,QAAQ;AAAA,MACJ,OAAO;AAAA,QACH;AAAA,UACI,MAAM;AAAA,UACN,KAAK;AAAA,UACL,SAAS;AAAA,QACb;AAAA,QACA;AAAA,UACI,MAAM;AAAA,UACN,KAAK;AAAA,YACD,qBAAqB;AAAA,YACrB;AAAA,cACI,QAAQ;AAAA,cACR,SAAS;AAAA,gBACL,SAAS;AAAA,kBACL,gBAAgB;AAAA,gBACpB;AAAA,cACJ;AAAA,YACJ;AAAA,YACA;AAAA,cACI,QAAQ;AAAA,cACR,SAAS;AAAA,gBACL,gBAAgB,OAAO,MAAM;AAAA,cACjC;AAAA,YACJ;AAAA,UACJ;AAAA,QACJ;AAAA,QACA;AAAA,UACI,MAAM;AAAA,UACN,MAAM;AAAA,QACV;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AAEA,YAAU;AAAA,IACN;AAAA,IACA,MAAM,qBAAqB,SAAS,MAAM;AAAA,IAC1C,MAAM,qBAAqB,SAAS,QAAQ,QAAQ;AAAA,EACxD;AAGA,SAAO;AACX;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cli/utils/option.ts"],
4
- "sourcesContent": ["import {BaseEntrypointOptions} from \"@typing/base\";\nimport {ReadonlyConfig} from \"@typing/config\";\n\nexport const isValidEntrypointOptions = (options: BaseEntrypointOptions, config: ReadonlyConfig): boolean => {\n const {browser, app} = config;\n\n if (options.includeBrowser?.includes(browser) || options.includeApp?.includes(app)) {\n return true;\n }\n\n if (options.excludeBrowser?.includes(browser) || options.excludeApp?.includes(app)) {\n return false;\n }\n\n return true;\n}"],
4
+ "sourcesContent": ["import {BaseEntrypointOptions} from \"../../types/base\";\nimport {ReadonlyConfig} from \"../../types/config\";\n\nexport const isValidEntrypointOptions = (options: BaseEntrypointOptions, config: ReadonlyConfig): boolean => {\n const {browser, app} = config;\n\n if (options.includeBrowser?.includes(browser) || options.includeApp?.includes(app)) {\n return true;\n }\n\n if (options.excludeBrowser?.includes(browser) || options.excludeApp?.includes(app)) {\n return false;\n }\n\n return true;\n}"],
5
5
  "mappings": "AAGO,MAAM,2BAA2B,CAAC,SAAgC,WAAoC;AACzG,QAAM,EAAC,SAAS,IAAG,IAAI;AAEvB,MAAI,QAAQ,gBAAgB,SAAS,OAAO,KAAK,QAAQ,YAAY,SAAS,GAAG,GAAG;AAChF,WAAO;AAAA,EACX;AAEA,MAAI,QAAQ,gBAAgB,SAAS,OAAO,KAAK,QAAQ,YAAY,SAAS,GAAG,GAAG;AAChF,WAAO;AAAA,EACX;AAEA,SAAO;AACX;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/cli/utils/plugin.ts"],
4
- "sourcesContent": ["import _isFunction from \"lodash/isFunction\";\n\nimport {PluginHandler, PluginHandlerKeys, PluginHandlerOptions, PluginHandlerResult} from \"@typing/plugin\";\nimport {ReadonlyConfig} from \"@typing/config\";\n\nexport const resolvePluginHandler = async <O extends object, T>(handler: PluginHandler<O, T> | undefined, options: O): Promise<T | undefined> => {\n if (_isFunction(handler)) {\n const result = handler(options);\n\n if (result instanceof Promise) {\n return await result;\n }\n\n return result;\n }\n\n return handler;\n};\n\n\nexport const processPluginHandler = async function* <K extends PluginHandlerKeys>(config: ReadonlyConfig, key: K, options: PluginHandlerOptions<K>): AsyncGenerator<PluginHandlerResult<K>, void, void> {\n const {plugins = []} = config;\n\n for await (const plugin of plugins) {\n const handler = plugin[key] as PluginHandler<PluginHandlerOptions<K>> | undefined;\n\n const result = await resolvePluginHandler(handler, options);\n\n if (result !== undefined) {\n yield result;\n }\n }\n}"],
4
+ "sourcesContent": ["import _isFunction from \"lodash/isFunction\";\n\nimport {PluginHandler, PluginHandlerKeys, PluginHandlerOptions, PluginHandlerResult} from \"../../types/plugin\";\nimport {ReadonlyConfig} from \"../../types/config\";\n\nexport const resolvePluginHandler = async <O extends object, T>(handler: PluginHandler<O, T> | undefined, options: O): Promise<T | undefined> => {\n if (_isFunction(handler)) {\n const result = handler(options);\n\n if (result instanceof Promise) {\n return await result;\n }\n\n return result;\n }\n\n return handler;\n};\n\n\nexport const processPluginHandler = async function* <K extends PluginHandlerKeys>(config: ReadonlyConfig, key: K, options: PluginHandlerOptions<K>): AsyncGenerator<PluginHandlerResult<K>, void, void> {\n const {plugins = []} = config;\n\n for await (const plugin of plugins) {\n const handler = plugin[key] as PluginHandler<PluginHandlerOptions<K>> | undefined;\n\n const result = await resolvePluginHandler(handler, options);\n\n if (result !== undefined) {\n yield result;\n }\n }\n}"],
5
5
  "mappings": "AAAA,OAAO,iBAAiB;AAKjB,MAAM,uBAAuB,OAA4B,SAA0C,YAAuC;AAC7I,MAAI,YAAY,OAAO,GAAG;AACtB,UAAM,SAAS,QAAQ,OAAO;AAE9B,QAAI,kBAAkB,SAAS;AAC3B,aAAO,MAAM;AAAA,IACjB;AAEA,WAAO;AAAA,EACX;AAEA,SAAO;AACX;AAGO,MAAM,uBAAuB,iBAA8C,QAAwB,KAAQ,SAAsF;AACpM,QAAM,EAAC,UAAU,CAAC,EAAC,IAAI;AAEvB,mBAAiB,UAAU,SAAS;AAChC,UAAM,UAAU,OAAO,GAAG;AAE1B,UAAM,SAAS,MAAM,qBAAqB,SAAS,OAAO;AAE1D,QAAI,WAAW,QAAW;AACtB,YAAM;AAAA,IACV;AAAA,EACJ;AACJ;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/core/define.ts"],
4
- "sourcesContent": ["import {ConfigDefinition} from \"@typing/config\";\nimport {BackgroundDefinition} from \"@typing/background\";\nimport {ContentScriptDefinition} from \"@typing/content\";\n\nexport const defineConfig = (config: ConfigDefinition): ConfigDefinition => {\n return config;\n}\n\nexport const defineBackground = (options: BackgroundDefinition): BackgroundDefinition => {\n return options;\n}\n\nexport const defineContentScript = (options: ContentScriptDefinition): ContentScriptDefinition => {\n return options;\n}"],
4
+ "sourcesContent": ["import {ConfigDefinition} from \"../types/config\";\nimport {BackgroundDefinition} from \"../types/background\";\nimport {ContentScriptDefinition} from \"../types/content\";\n\nexport const defineConfig = (config: ConfigDefinition): ConfigDefinition => {\n return config;\n}\n\nexport const defineBackground = (options: BackgroundDefinition): BackgroundDefinition => {\n return options;\n}\n\nexport const defineContentScript = (options: ContentScriptDefinition): ContentScriptDefinition => {\n return options;\n}"],
5
5
  "mappings": "AAIO,MAAM,eAAe,CAAC,WAA+C;AACxE,SAAO;AACX;AAEO,MAAM,mBAAmB,CAAC,YAAwD;AACrF,SAAO;AACX;AAEO,MAAM,sBAAsB,CAAC,YAA8D;AAC9F,SAAO;AACX;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/types/config.ts"],
4
- "sourcesContent": ["import {Plugin} from \"@typing/plugin\";\nimport {ManifestVersion} from \"@typing/manifest\";\n\nexport enum Browser {\n Chrome = 'chrome',\n Chromium = 'chromium',\n Edge = 'edge',\n Firefox = 'firefox',\n Opera = 'opera',\n Safari = 'safari',\n}\n\nexport enum Mode {\n None = 'none',\n Development = 'development',\n Production = 'production',\n}\n\nexport interface Config {\n debug: boolean;\n mode: Mode;\n app: string;\n browser: Browser;\n manifestVersion: ManifestVersion;\n inputDir: string;\n outputDir: string;\n srcDir: string;\n sharedDir: string;\n appsDir: string;\n jsDir: string;\n cssDir: string;\n assetsDir: string;\n htmlDir: string;\n plugins: Plugin[];\n analyze: boolean;\n configFile: string;\n mergeBackground: boolean;\n mergeContentScripts: boolean;\n concatContentScripts: boolean;\n}\n\nexport interface ConfigOptions {\n config: ReadonlyConfig;\n}\n\nexport type OptionalConfig = Partial<Config>;\nexport type UserConfig = Omit<OptionalConfig, 'configFile'>;\nexport type ReadonlyConfig = Readonly<Config>;\n\nexport type UserConfigCallback = (config: ReadonlyConfig) => UserConfig | Promise<UserConfig>;\nexport type ConfigDefinition = UserConfigCallback | UserConfig;\n\n"],
4
+ "sourcesContent": ["import {Plugin} from \"./plugin\";\nimport {ManifestVersion} from \"./manifest\";\n\nexport enum Browser {\n Chrome = 'chrome',\n Chromium = 'chromium',\n Edge = 'edge',\n Firefox = 'firefox',\n Opera = 'opera',\n Safari = 'safari',\n}\n\nexport enum Mode {\n None = 'none',\n Development = 'development',\n Production = 'production',\n}\n\nexport interface Config {\n debug: boolean;\n mode: Mode;\n app: string;\n browser: Browser;\n manifestVersion: ManifestVersion;\n inputDir: string;\n outputDir: string;\n srcDir: string;\n sharedDir: string;\n appsDir: string;\n jsDir: string;\n cssDir: string;\n assetsDir: string;\n htmlDir: string;\n plugins: Plugin[];\n analyze: boolean;\n configFile: string;\n mergeBackground: boolean;\n mergeContentScripts: boolean;\n concatContentScripts: boolean;\n}\n\nexport interface ConfigOptions {\n config: ReadonlyConfig;\n}\n\nexport type OptionalConfig = Partial<Config>;\nexport type UserConfig = Omit<OptionalConfig, 'configFile'>;\nexport type ReadonlyConfig = Readonly<Config>;\n\nexport type UserConfigCallback = (config: ReadonlyConfig) => UserConfig | Promise<UserConfig>;\nexport type ConfigDefinition = UserConfigCallback | UserConfig;\n\n"],
5
5
  "mappings": "AAGO,IAAK,UAAL,kBAAKA,aAAL;AACH,EAAAA,SAAA,YAAS;AACT,EAAAA,SAAA,cAAW;AACX,EAAAA,SAAA,UAAO;AACP,EAAAA,SAAA,aAAU;AACV,EAAAA,SAAA,WAAQ;AACR,EAAAA,SAAA,YAAS;AAND,SAAAA;AAAA,GAAA;AASL,IAAK,OAAL,kBAAKC,UAAL;AACH,EAAAA,MAAA,UAAO;AACP,EAAAA,MAAA,iBAAc;AACd,EAAAA,MAAA,gBAAa;AAHL,SAAAA;AAAA,GAAA;",
6
6
  "names": ["Browser", "Mode"]
7
7
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "adnbn",
3
3
  "type": "module",
4
- "version": "0.0.6",
4
+ "version": "0.0.7",
5
5
  "description": "Cross browser web extension framework with shared code base",
6
6
  "main": "index.js",
7
7
  "homepage": "https://github.com/addonbone/addonbone",
@@ -40,7 +40,9 @@
40
40
  "@types/node": "^22.13.1",
41
41
  "enhanced-resolve": "^5.18.1",
42
42
  "esbuild": "^0.24.2",
43
+ "esbuild-plugin-alias": "^0.2.1",
43
44
  "esbuild-plugin-d.ts": "^1.3.1",
45
+ "esbuild-ts-paths": "^1.1.3",
44
46
  "fs-extra": "^11.3.0",
45
47
  "ts-node": "^10.9.2",
46
48
  "tsconfig-paths-webpack-plugin": "^4.2.0",
@@ -49,6 +51,7 @@
49
51
  "webpack-node-externals": "^3.0.0"
50
52
  },
51
53
  "dependencies": {
54
+ "@esbuild-plugins/tsconfig-paths": "^0.1.2",
52
55
  "@types/chrome": "^0.0.299",
53
56
  "cac": "^6.7.14",
54
57
  "css-loader": "^7.1.2",
@@ -1,3 +0,0 @@
1
- import { OptionalConfig } from "@typing/config";
2
- declare const _default: (config: OptionalConfig) => Promise<void>;
3
- export default _default;
@@ -1,24 +0,0 @@
1
- import { CoreManifest, ManifestBackground, ManifestBuilder, ManifestContentScript, ManifestVersion } from "@typing/manifest";
2
- import { Browser } from "@typing/config";
3
- export default abstract class<T extends CoreManifest> implements ManifestBuilder<T> {
4
- protected readonly browser: Browser;
5
- protected name: string;
6
- protected shortName: string;
7
- protected description: string;
8
- protected version: string;
9
- protected background?: ManifestBackground;
10
- protected contentScripts: Map<string, ManifestContentScript>;
11
- abstract getManifestVersion(): ManifestVersion;
12
- protected abstract buildBackground(): Partial<T> | undefined;
13
- protected abstract buildContentScripts(): Partial<T> | undefined;
14
- protected constructor(browser?: Browser);
15
- setName(name: string): this;
16
- setShortName(shortName: string): this;
17
- setDescription(description: string): this;
18
- setVersion(version: string): this;
19
- resetBackground(background: ManifestBackground): this;
20
- pushContentScript(...content: ManifestContentScript[]): this;
21
- private marge;
22
- build(): T;
23
- get(): T;
24
- }
@@ -1,10 +0,0 @@
1
- import ManifestBase from "./ManifestBase";
2
- import { ManifestVersion } from "@typing/manifest";
3
- import { Browser } from "@typing/config";
4
- import ManifestV2 = chrome.runtime.ManifestV2;
5
- export default class extends ManifestBase<ManifestV2> {
6
- constructor(browser: Browser);
7
- getManifestVersion(): ManifestVersion;
8
- protected buildBackground(): Partial<ManifestV2> | undefined;
9
- protected buildContentScripts(): Partial<ManifestV2> | undefined;
10
- }
@@ -1,10 +0,0 @@
1
- import ManifestBase from "./ManifestBase";
2
- import { ManifestVersion } from "@typing/manifest";
3
- import { Browser } from "@typing/config";
4
- import ManifestV3 = chrome.runtime.ManifestV3;
5
- export default class extends ManifestBase<ManifestV3> {
6
- constructor(browser: Browser);
7
- getManifestVersion(): ManifestVersion;
8
- protected buildBackground(): Partial<ManifestV3> | undefined;
9
- protected buildContentScripts(): Partial<ManifestV3> | undefined;
10
- }
@@ -1,4 +0,0 @@
1
- import { ManifestBuilder, ManifestMapping, ManifestVersion } from "@typing/manifest";
2
- import { Browser } from "@typing/config";
3
- declare const _default: <T extends ManifestVersion>(browser: Browser, manifestVersion: T) => ManifestBuilder<ManifestMapping[T]>;
4
- export default _default;
@@ -1 +0,0 @@
1
- export {};
@@ -1,10 +0,0 @@
1
- import SourceFile from "./SourceFile";
2
- export default class<T extends Record<string, unknown>> extends SourceFile {
3
- protected definition?: string;
4
- protected properties: string[];
5
- setDefinition(definition: string): this;
6
- setProperties(properties: string[]): this;
7
- getOptions(): T;
8
- protected getOptionsFromVariables(): T;
9
- protected getOptionsFromDefinition(): T;
10
- }
@@ -1,24 +0,0 @@
1
- import { Node, SourceFile } from 'typescript';
2
- export interface Variable {
3
- name: string;
4
- value: any;
5
- exported: boolean;
6
- }
7
- export type VariableMap = Map<string, Variable>;
8
- export type ImportMap = Map<string, string>;
9
- export type EnumMap = Map<string, Map<string, string | number>>;
10
- export default class EntryFile {
11
- protected readonly file: string;
12
- private sourceFile?;
13
- private variables?;
14
- private imports?;
15
- private enums?;
16
- static make<T extends EntryFile>(this: new (file: string) => T, file: string): T;
17
- constructor(file: string);
18
- getSourceFile(): SourceFile;
19
- getImports(): ImportMap;
20
- getEnums(): EnumMap;
21
- getVariables(): VariableMap;
22
- protected findPropertyAccessValue(property: Node): any;
23
- protected parseNode(node?: Node): any;
24
- }
@@ -1,2 +0,0 @@
1
- import { BackgroundEntrypointOptions } from "@typing/background";
2
- export declare const getBackgroundOptions: (file: string) => BackgroundEntrypointOptions;
@@ -1,6 +0,0 @@
1
- import { Plugin } from "@typing/plugin";
2
- export interface BackgroundOptions {
3
- name?: string;
4
- }
5
- declare const _default: (options?: BackgroundOptions) => Plugin;
6
- export default _default;
@@ -1,3 +0,0 @@
1
- import { Plugin } from "@typing/plugin";
2
- declare const _default: () => Plugin;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import { Config, OptionalConfig } from "@typing/config";
2
- declare const _default: (config: OptionalConfig) => Promise<Config>;
3
- export default _default;
@@ -1,5 +0,0 @@
1
- import { ReadonlyConfig } from "@typing/config";
2
- export declare const getRootPath: (to: string) => string;
3
- export declare const getConfigFile: (config: ReadonlyConfig) => string;
4
- export declare const getSharedPath: (config: ReadonlyConfig) => string;
5
- export declare const getAppsPath: (config: ReadonlyConfig) => string;
@@ -1,4 +0,0 @@
1
- import { Configuration } from "webpack";
2
- import { ReadonlyConfig } from "@typing/config";
3
- declare const _default: (config: ReadonlyConfig) => Promise<Configuration>;
4
- export default _default;
@@ -1,3 +0,0 @@
1
- export declare const findEntrypointFiles: (directory: string, entrypoint: string) => string[];
2
- export declare const findBackgroundFiles: (directory: string) => string[];
3
- export declare const findContentFiles: (directory: string) => string[];
@@ -1,3 +0,0 @@
1
- import { BaseEntrypointOptions } from "@typing/base";
2
- import { ReadonlyConfig } from "@typing/config";
3
- export declare const isValidEntrypointOptions: (options: BaseEntrypointOptions, config: ReadonlyConfig) => boolean;
@@ -1,4 +0,0 @@
1
- import { PluginHandler, PluginHandlerKeys, PluginHandlerOptions, PluginHandlerResult } from "@typing/plugin";
2
- import { ReadonlyConfig } from "@typing/config";
3
- export declare const resolvePluginHandler: <O extends object, T>(handler: PluginHandler<O, T> | undefined, options: O) => Promise<T | undefined>;
4
- export declare const processPluginHandler: <K extends PluginHandlerKeys>(config: ReadonlyConfig, key: K, options: PluginHandlerOptions<K>) => AsyncGenerator<PluginHandlerResult<K>, void, void>;
@@ -1,8 +0,0 @@
1
- import { Compiler } from 'webpack';
2
- export type DependencyMap = Map<string, string[]>;
3
- export default class EntryDependenciesPlugin {
4
- private callback?;
5
- private dependencyMap;
6
- constructor(callback?: ((map: DependencyMap) => void) | undefined);
7
- apply(compiler: Compiler): void;
8
- }
@@ -1,6 +0,0 @@
1
- import { ConfigDefinition } from "@typing/config";
2
- import { BackgroundDefinition } from "@typing/background";
3
- import { ContentScriptDefinition } from "@typing/content";
4
- export declare const defineConfig: (config: ConfigDefinition) => ConfigDefinition;
5
- export declare const defineBackground: (options: BackgroundDefinition) => BackgroundDefinition;
6
- export declare const defineContentScript: (options: ContentScriptDefinition) => ContentScriptDefinition;
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/dist/index.mjs DELETED
@@ -1,7 +0,0 @@
1
- import webpack from "webpack";
2
- webpack({
3
- entry: "./src/index.ts",
4
- output: {}
5
- });
6
- console.log("awdawda");
7
- //# sourceMappingURL=index.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/index.ts"],
4
- "sourcesContent": ["import webpack from \"webpack\";\n\nwebpack({\n entry: './src/index.ts',\n output: {\n\n }\n});\n\nconsole.log('awdawda')"],
5
- "mappings": "AAAA,OAAO,aAAa;AAEpB,QAAQ;AAAA,EACJ,OAAO;AAAA,EACP,QAAQ,CAER;AACJ,CAAC;AAED,QAAQ,IAAI,SAAS;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- import { BaseEntrypointOptions } from "@typing/base";
2
- export interface BackgroundConfig {
3
- persistent?: boolean;
4
- }
5
- export type BackgroundEntrypointOptions = BackgroundConfig & BaseEntrypointOptions;
6
- export type BackgroundDefinition = BackgroundEntrypointOptions;
7
- export type BackgroundEntrypointMap = Map<string, BackgroundDefinition>;
@@ -1,31 +0,0 @@
1
- import { Browser } from "@typing/config";
2
- export interface BaseEntrypointOptions {
3
- /**
4
- * List of target browsers to include this entrypoint in. Defaults to being included in all
5
- * builds. Cannot be used with `exclude`. You must choose one of the two options.
6
- *
7
- * @default undefined
8
- */
9
- includeBrowser?: Browser[];
10
- /**
11
- * List of target browsers to exclude this entrypoint from. Cannot be used with `include`. You
12
- * must choose one of the two options.
13
- *
14
- * @default undefined
15
- */
16
- excludeBrowser?: Browser[];
17
- /**
18
- * List of target apps to include this entrypoint in. Defaults to being included in all builds.
19
- * Cannot be used with `excludeApp`. You must choose one of the two options.
20
- *
21
- * @default undefined
22
- */
23
- excludeApp?: string[];
24
- /**
25
- * List of target apps to exclude this entrypoint from. Cannot be used with `includeApp`. You
26
- * must choose one of the two options.
27
- *
28
- * @default undefined
29
- */
30
- includeApp?: string[];
31
- }
@@ -1,45 +0,0 @@
1
- import { Plugin } from "@typing/plugin";
2
- import { ManifestVersion } from "@typing/manifest";
3
- export declare enum Browser {
4
- Chrome = "chrome",
5
- Chromium = "chromium",
6
- Edge = "edge",
7
- Firefox = "firefox",
8
- Opera = "opera",
9
- Safari = "safari"
10
- }
11
- export declare enum Mode {
12
- None = "none",
13
- Development = "development",
14
- Production = "production"
15
- }
16
- export interface Config {
17
- debug: boolean;
18
- mode: Mode;
19
- app: string;
20
- browser: Browser;
21
- manifestVersion: ManifestVersion;
22
- inputDir: string;
23
- outputDir: string;
24
- srcDir: string;
25
- sharedDir: string;
26
- appsDir: string;
27
- jsDir: string;
28
- cssDir: string;
29
- assetsDir: string;
30
- htmlDir: string;
31
- plugins: Plugin[];
32
- analyze: boolean;
33
- configFile: string;
34
- mergeBackground: boolean;
35
- mergeContentScripts: boolean;
36
- concatContentScripts: boolean;
37
- }
38
- export interface ConfigOptions {
39
- config: ReadonlyConfig;
40
- }
41
- export type OptionalConfig = Partial<Config>;
42
- export type UserConfig = Omit<OptionalConfig, 'configFile'>;
43
- export type ReadonlyConfig = Readonly<Config>;
44
- export type UserConfigCallback = (config: ReadonlyConfig) => UserConfig | Promise<UserConfig>;
45
- export type ConfigDefinition = UserConfigCallback | UserConfig;
@@ -1,50 +0,0 @@
1
- import ExecutionWorld = chrome.scripting.ExecutionWorld;
2
- import RunAt = chrome.userScripts.RunAt;
3
- import { BaseEntrypointOptions } from "@typing/base";
4
- export interface ContentScriptConfig {
5
- matches?: string[];
6
- /**
7
- * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
8
- * @default "documentIdle"
9
- */
10
- runAt?: RunAt;
11
- /**
12
- * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
13
- * @default false
14
- */
15
- matchAboutBlank?: boolean;
16
- /**
17
- * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
18
- * @default []
19
- */
20
- excludeMatches?: string[];
21
- /**
22
- * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
23
- * @default []
24
- */
25
- includeGlobs?: string[];
26
- /**
27
- * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
28
- * @default []
29
- */
30
- excludeGlobs?: string[];
31
- /**
32
- * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
33
- * @default false
34
- */
35
- allFrames?: boolean;
36
- /**
37
- * See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
38
- */
39
- world?: ExecutionWorld;
40
- /**
41
- * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
42
- * @default false
43
- */
44
- matchOriginAsFallback?: boolean;
45
- }
46
- export type ContentScriptEntrypointOptions = ContentScriptConfig & BaseEntrypointOptions;
47
- export type ContentScriptEntrypointMap = Map<string, ContentScriptDefinition>;
48
- export interface ContentScriptDefinition extends ContentScriptEntrypointOptions {
49
- render?(): Promise<void>;
50
- }
@@ -1,77 +0,0 @@
1
- import { ContentScriptConfig } from "@typing/content";
2
- import { BackgroundConfig } from "@typing/background";
3
- import ManifestCommon = chrome.runtime.Manifest;
4
- import ManifestBase = chrome.runtime.ManifestBase;
5
- import ManifestV3 = chrome.runtime.ManifestV3;
6
- import ManifestV2 = chrome.runtime.ManifestV2;
7
- type ManifestFixed<T extends ManifestBase> = Omit<T, 'manifest_version'> & {
8
- manifest_version: ManifestVersion;
9
- };
10
- interface ManifestUnstable {
11
- permissions?: (chrome.runtime.ManifestPermissions | (string & Record<never, never>))[];
12
- web_accessible_resources?: string[] | chrome.runtime.ManifestV3['web_accessible_resources'];
13
- }
14
- export type ManifestVersion = 2 | 3;
15
- export type ManifestMapping = {
16
- [Key in ManifestVersion]: Key extends 2 ? ManifestFixed<ManifestV2> : ManifestFixed<ManifestV3>;
17
- };
18
- export type CoreManifest = ManifestFixed<ManifestBase>;
19
- export type ChromeManifest = ManifestFixed<ManifestCommon>;
20
- export type FirefoxManifest = ChromeManifest & {
21
- action?: chrome.runtime.ManifestV3['action'] & {
22
- browser_style?: boolean;
23
- };
24
- browser_action?: chrome.runtime.ManifestV2['browser_action'] & {
25
- browser_style?: boolean;
26
- };
27
- page_action?: chrome.runtime.ManifestV2['page_action'] & {
28
- browser_style?: boolean;
29
- };
30
- browser_specific_settings?: {
31
- gecko?: {
32
- id?: string;
33
- strict_min_version?: string;
34
- strict_max_version?: string;
35
- update_url?: string;
36
- };
37
- gecko_android?: {
38
- strict_min_version?: string;
39
- strict_max_version?: string;
40
- };
41
- };
42
- } & ManifestUnstable;
43
- export type SafariManifest = ChromeManifest & {
44
- browser_specific_settings?: {
45
- safari?: {
46
- strict_min_version?: string;
47
- strict_max_version?: string;
48
- };
49
- };
50
- } & ManifestUnstable;
51
- export type Manifest = ChromeManifest | FirefoxManifest | SafariManifest;
52
- export interface ManifestBuilder<T extends CoreManifest = Manifest> {
53
- setVersion(version: string): this;
54
- setName(name: string): this;
55
- setShortName(shortName: string): this;
56
- setDescription(description: string): this;
57
- resetBackground(background: ManifestBackground): this;
58
- pushContentScript(...contentScript: ManifestContentScript[]): this;
59
- get(): T;
60
- }
61
- export interface ManifestEntry {
62
- entry: string;
63
- }
64
- export interface ManifestEntryFile extends ManifestEntry {
65
- file: string;
66
- }
67
- export type ManifestBackground = ManifestEntryFile & BackgroundConfig;
68
- export interface ManifestContentScript extends ManifestEntryFile, ContentScriptConfig {
69
- js?: string[];
70
- css?: string[];
71
- }
72
- export interface ManifestDependencies extends ManifestEntry {
73
- js?: string[];
74
- css?: string[];
75
- assets?: string[];
76
- }
77
- export {};
@@ -1,36 +0,0 @@
1
- import { ManifestBuilder } from "@typing/manifest";
2
- import { Configuration as WebpackConfig } from "webpack";
3
- import { ConfigOptions } from "@typing/config";
4
- import { ContentScriptEntrypointMap } from "@typing/content";
5
- import { BackgroundEntrypointMap } from "@typing/background";
6
- export interface PluginManifestOptions extends ConfigOptions {
7
- manifest: ManifestBuilder;
8
- }
9
- export interface PluginWebpackOptions extends ConfigOptions {
10
- webpack: Partial<WebpackConfig>;
11
- }
12
- export interface PluginContentOptions extends ConfigOptions {
13
- entries: ContentScriptEntrypointMap;
14
- }
15
- export type PluginContentResult = string | string[] | Record<string, string>;
16
- export interface PluginBackgroundOptions extends ConfigOptions {
17
- entries: BackgroundEntrypointMap;
18
- }
19
- export type PluginBackgroundResult = string;
20
- export interface Plugin {
21
- content?: PluginHandler<PluginContentOptions, PluginContentResult>;
22
- background?: PluginHandler<PluginBackgroundOptions, PluginBackgroundResult>;
23
- manifest?: PluginHandlerCallback<PluginManifestOptions>;
24
- webpack?: PluginHandler<PluginWebpackOptions, WebpackConfig>;
25
- }
26
- export type PluginHandler<O, T = void> = T | PluginHandlerCallback<O, T>;
27
- export type PluginHandlerCallback<O, T = void> = {
28
- (options: O): T | Promise<T>;
29
- };
30
- export type PluginHandlerKeys = keyof Plugin;
31
- export type PluginHandlerType<T extends Plugin[PluginHandlerKeys]> = T extends PluginHandlerCallback<infer O, infer R> ? {
32
- options: O;
33
- result: R;
34
- } : never;
35
- export type PluginHandlerOptions<K extends PluginHandlerKeys> = PluginHandlerType<Plugin[K]>['options'];
36
- export type PluginHandlerResult<K extends PluginHandlerKeys> = NonNullable<PluginHandlerType<Plugin[K]>['result']>;