adnbn 0.7.1 → 0.9.0

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 (135) hide show
  1. package/dist/cli/builders/locale/LocaleStructureValidator.js +7 -0
  2. package/dist/cli/builders/locale/LocaleStructureValidator.js.map +1 -1
  3. package/dist/cli/bundler/plugins/GenerateJsonPlugin.js +3 -7
  4. package/dist/cli/bundler/plugins/GenerateJsonPlugin.js.map +1 -1
  5. package/dist/cli/entrypoint/file/injectors/core.js +9 -1
  6. package/dist/cli/entrypoint/file/injectors/core.js.map +1 -1
  7. package/dist/cli/entrypoint/finder/AbstractAssetFinder.js +22 -11
  8. package/dist/cli/entrypoint/finder/AbstractAssetFinder.js.map +1 -1
  9. package/dist/cli/entrypoint/finder/AbstractEntrypointFinder.js +7 -0
  10. package/dist/cli/entrypoint/finder/AbstractEntrypointFinder.js.map +1 -1
  11. package/dist/cli/entrypoint/finder/AbstractFinder.d.ts +0 -2
  12. package/dist/cli/entrypoint/finder/AbstractFinder.js +5 -25
  13. package/dist/cli/entrypoint/finder/AbstractFinder.js.map +1 -1
  14. package/dist/cli/entrypoint/finder/AbstractViewFinder.js +3 -4
  15. package/dist/cli/entrypoint/finder/AbstractViewFinder.js.map +1 -1
  16. package/dist/cli/entrypoint/finder/AssetPluginFinder.js +14 -1
  17. package/dist/cli/entrypoint/finder/AssetPluginFinder.js.map +1 -1
  18. package/dist/cli/entrypoint/finder/LocaleFinder.d.ts +2 -0
  19. package/dist/cli/entrypoint/finder/LocaleFinder.js +27 -0
  20. package/dist/cli/entrypoint/finder/LocaleFinder.js.map +1 -1
  21. package/dist/cli/entrypoint/finder/PluginFinder.js +12 -3
  22. package/dist/cli/entrypoint/finder/PluginFinder.js.map +1 -1
  23. package/dist/cli/entrypoint/finder/ViewCspFinder.d.ts +2 -0
  24. package/dist/cli/entrypoint/finder/ViewCspFinder.js +13 -6
  25. package/dist/cli/entrypoint/finder/ViewCspFinder.js.map +1 -1
  26. package/dist/cli/entrypoint/finder/utils/filePrecedence.d.ts +35 -0
  27. package/dist/cli/entrypoint/finder/utils/filePrecedence.js +64 -0
  28. package/dist/cli/entrypoint/finder/utils/filePrecedence.js.map +1 -0
  29. package/dist/cli/entrypoint/parser/ContentParser.d.ts +2 -2
  30. package/dist/cli/entrypoint/parser/ContentParser.js.map +1 -1
  31. package/dist/cli/entrypoint/parser/RelayParser.js +2 -1
  32. package/dist/cli/entrypoint/parser/RelayParser.js.map +1 -1
  33. package/dist/cli/index.js +2 -0
  34. package/dist/cli/index.js.map +1 -1
  35. package/dist/cli/plugins/content/ContentDriver.d.ts +21 -8
  36. package/dist/cli/plugins/content/ContentDriver.js +24 -2
  37. package/dist/cli/plugins/content/ContentDriver.js.map +1 -1
  38. package/dist/cli/plugins/content/ContentManager.d.ts +8 -3
  39. package/dist/cli/plugins/content/ContentManager.js +41 -6
  40. package/dist/cli/plugins/content/ContentManager.js.map +1 -1
  41. package/dist/cli/plugins/content/Relay.d.ts +6 -8
  42. package/dist/cli/plugins/content/Relay.js +2 -14
  43. package/dist/cli/plugins/content/Relay.js.map +1 -1
  44. package/dist/cli/plugins/content/RelayDeclaration.d.ts +0 -1
  45. package/dist/cli/plugins/content/RelayDeclaration.js +0 -3
  46. package/dist/cli/plugins/content/RelayDeclaration.js.map +1 -1
  47. package/dist/cli/plugins/content/RelayDriver.d.ts +10 -0
  48. package/dist/cli/plugins/content/RelayDriver.js +39 -0
  49. package/dist/cli/plugins/content/RelayDriver.js.map +1 -0
  50. package/dist/cli/plugins/content/index.js +1 -10
  51. package/dist/cli/plugins/content/index.js.map +1 -1
  52. package/dist/cli/plugins/content/types.d.ts +3 -0
  53. package/dist/cli/plugins/locale/Locale.js +5 -1
  54. package/dist/cli/plugins/locale/Locale.js.map +1 -1
  55. package/dist/cli/plugins/locale/declaration/LocaleDeclaration.js +2 -3
  56. package/dist/cli/plugins/locale/declaration/LocaleDeclaration.js.map +1 -1
  57. package/dist/cli/plugins/locale/declaration/locale.d.ts +3 -124
  58. package/dist/cli/virtual/index.js +2 -2
  59. package/dist/cli/virtual/virtual.d.ts +52 -147
  60. package/dist/entry/relay/index.d.ts +2 -1
  61. package/dist/entry/relay/index.js.map +1 -1
  62. package/dist/locale/adapters/react/LocaleProvider.js +2 -0
  63. package/dist/locale/adapters/react/LocaleProvider.js.map +1 -1
  64. package/dist/locale/adapters/react/context.d.ts +1 -0
  65. package/dist/locale/adapters/react/context.js +3 -2
  66. package/dist/locale/adapters/react/context.js.map +1 -1
  67. package/dist/locale/helpers.js.map +1 -1
  68. package/dist/locale/providers/AbstractLocale.d.ts +2 -0
  69. package/dist/locale/providers/AbstractLocale.js +5 -0
  70. package/dist/locale/providers/AbstractLocale.js.map +1 -1
  71. package/dist/locale/providers/NativeLocale.d.ts +3 -2
  72. package/dist/locale/providers/NativeLocale.js +1 -1
  73. package/dist/locale/providers/NativeLocale.js.map +1 -1
  74. package/dist/main/relay.d.ts +7 -6
  75. package/dist/main/relay.js +12 -5
  76. package/dist/main/relay.js.map +1 -1
  77. package/dist/message/error.d.ts +6 -0
  78. package/dist/message/error.js +21 -0
  79. package/dist/message/error.js.map +1 -1
  80. package/dist/message/index.d.ts +2 -1
  81. package/dist/message/index.js +2 -0
  82. package/dist/message/index.js.map +1 -1
  83. package/dist/message/providers/Message.d.ts +3 -0
  84. package/dist/message/providers/Message.js +36 -6
  85. package/dist/message/providers/Message.js.map +1 -1
  86. package/dist/offscreen/providers/ProxyOffscreen.d.ts +2 -2
  87. package/dist/offscreen/providers/ProxyOffscreen.js.map +1 -1
  88. package/dist/relay/RelayPermission.d.ts +6 -3
  89. package/dist/relay/RelayPermission.js +28 -12
  90. package/dist/relay/RelayPermission.js.map +1 -1
  91. package/dist/relay/adapters/RelayAdapter.d.ts +8 -0
  92. package/dist/relay/adapters/RelayAdapter.js +16 -0
  93. package/dist/relay/adapters/RelayAdapter.js.map +1 -0
  94. package/dist/relay/adapters/RelayMessagingAdapter.d.ts +11 -0
  95. package/dist/relay/adapters/RelayMessagingAdapter.js +91 -0
  96. package/dist/relay/adapters/RelayMessagingAdapter.js.map +1 -0
  97. package/dist/relay/adapters/RelayScriptingAdapter.d.ts +15 -0
  98. package/dist/relay/adapters/RelayScriptingAdapter.js +170 -0
  99. package/dist/relay/adapters/RelayScriptingAdapter.js.map +1 -0
  100. package/dist/relay/discovery/RelayDiscovery.d.ts +10 -0
  101. package/dist/relay/discovery/RelayDiscovery.js +62 -0
  102. package/dist/relay/discovery/RelayDiscovery.js.map +1 -0
  103. package/dist/relay/index.d.ts +1 -4
  104. package/dist/relay/index.js +1 -3
  105. package/dist/relay/index.js.map +1 -1
  106. package/dist/relay/providers/ProxyRelay.d.ts +20 -17
  107. package/dist/relay/providers/ProxyRelay.js +79 -52
  108. package/dist/relay/providers/ProxyRelay.js.map +1 -1
  109. package/dist/relay/providers/RegisterRelay.js +1 -2
  110. package/dist/relay/providers/RegisterRelay.js.map +1 -1
  111. package/dist/relay/result.d.ts +12 -0
  112. package/dist/relay/result.js +88 -0
  113. package/dist/relay/result.js.map +1 -0
  114. package/dist/sandbox/index.d.ts +2 -2
  115. package/dist/sandbox/index.js.map +1 -1
  116. package/dist/sandbox/providers/ProxySandbox.d.ts +2 -2
  117. package/dist/sandbox/providers/ProxySandbox.js.map +1 -1
  118. package/dist/service/providers/ProxyService.d.ts +2 -2
  119. package/dist/service/providers/ProxyService.js.map +1 -1
  120. package/dist/transport/ProxyTransport.d.ts +2 -2
  121. package/dist/transport/ProxyTransport.js.map +1 -1
  122. package/dist/transport/index.d.ts +3 -2
  123. package/dist/types/config.d.ts +8 -0
  124. package/dist/types/helpers.d.ts +0 -4
  125. package/dist/types/locale.d.ts +3 -0
  126. package/dist/types/locale.js +58 -0
  127. package/dist/types/locale.js.map +1 -1
  128. package/dist/types/relay.d.ts +130 -3
  129. package/dist/types/relay.js +16 -0
  130. package/dist/types/relay.js.map +1 -1
  131. package/dist/types/rpc.d.ts +4 -0
  132. package/dist/types/rpc.js +1 -0
  133. package/dist/types/rpc.js.map +1 -0
  134. package/dist/types/transport.d.ts +3 -2
  135. package/package.json +5 -4
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/cli/entrypoint/finder/LocaleFinder.ts"],"sourcesContent":["import _ from \"lodash\";\nimport path from \"path\";\nimport fs from \"fs\";\nimport yaml from \"js-yaml\";\n\nimport AbstractAssetFinder from \"./AbstractAssetFinder\";\nimport AssetPluginFinder from \"./AssetPluginFinder\";\n\nimport localeFactory, {LocaleStructureValidator} from \"@cli/builders/locale\";\nimport {isFileExtension} from \"@cli/utils/path\";\n\nimport {ReadonlyConfig} from \"@typing/config\";\nimport {\n Language,\n LanguageCodes,\n LocaleBuilders,\n LocaleData,\n LocaleFileExtensions,\n LocaleKeys,\n LocaleStructure,\n} from \"@typing/locale\";\n\nexport type {LocaleBuilders} from \"@typing/locale\";\n\nexport default class extends AbstractAssetFinder {\n protected _plugin?: AssetPluginFinder;\n protected _builders?: LocaleBuilders;\n protected _validator?: LocaleStructureValidator;\n protected _validated = false;\n\n public constructor(config: ReadonlyConfig) {\n super(config);\n }\n\n public isValidName(name: string): boolean {\n if (name.includes(\".\")) {\n name = name.split(\".\").slice(0, -1).join(\".\");\n }\n\n return super.isValidName(name);\n }\n\n public isValidExtension(extension: string): boolean {\n return LocaleFileExtensions.has(extension);\n }\n\n public getDirectory(): string {\n return this.config.localeDir || \"locales\";\n }\n\n public getNames(): ReadonlySet<string> {\n return LanguageCodes;\n }\n\n public canMerge(): boolean {\n return this.config.mergeLocales;\n }\n\n protected getPlugin(): AssetPluginFinder {\n return new AssetPluginFinder(this.config, \"locale\", this);\n }\n\n public plugin(): AssetPluginFinder {\n return (this._plugin ??= this.getPlugin());\n }\n\n protected async getBuilders(): Promise<LocaleBuilders> {\n return _.chain(Array.from(await this.plugin().files()))\n .groupBy(file => this.getLanguageFromFilename(file.file))\n .reduce((map, files, lang) => {\n const locale = localeFactory(lang as Language, this.config);\n\n for (const {file} of files) {\n const content = fs.readFileSync(file, \"utf8\");\n\n if (isFileExtension(file, [\"yaml\", \"yml\"])) {\n locale.merge(yaml.load(content) as LocaleData);\n } else if (isFileExtension(file, \"json\")) {\n locale.merge(JSON.parse(content));\n }\n }\n\n map.set(locale.lang(), locale);\n\n return map;\n }, new Map() as LocaleBuilders)\n .value();\n }\n\n protected getValidator(): LocaleStructureValidator {\n return (this._validator ??= new LocaleStructureValidator(this.config.lang));\n }\n\n protected getLanguageFromFilename(filename: string): Language {\n let {name} = path.parse(filename);\n\n if (name.includes(\".\")) {\n name = name.split(\".\").slice(0, -1).join(\".\");\n }\n\n if (LanguageCodes.has(name)) {\n return name as Language;\n }\n\n throw new Error(`Invalid locale filename: ${filename}`);\n }\n\n public async builders(): Promise<LocaleBuilders> {\n if (this._builders) {\n return this._builders;\n }\n\n return (this._builders = await this.getBuilders());\n }\n\n public async validate(): Promise<this> {\n if (!this._validated) {\n this.getValidator().validate(await this.builders());\n this._validated = true;\n }\n\n return this;\n }\n\n public async keys(): Promise<LocaleKeys> {\n const builders = await this.builders();\n const builder = this.getValidator().getDefaultBuilder(builders);\n\n return builder?.keys() ?? new Set();\n }\n\n public async structure(): Promise<LocaleStructure> {\n const builders = await this.builders();\n const builder = this.getValidator().getDefaultBuilder(builders);\n\n return builder?.structure() ?? {};\n }\n\n public async languages(): Promise<Set<Language>> {\n const builders = await this.builders();\n\n return new Set(builders.keys());\n }\n\n async empty(): Promise<boolean> {\n return this.plugin().empty();\n }\n\n public clear(): this {\n this.plugin().clear();\n\n this._builders = undefined;\n this._validator = undefined;\n this._validated = false;\n\n return super.clear();\n }\n}\n"],"mappings":"AAAA,OAAO,OAAO;AACd,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,OAAO,UAAU;AAEjB,OAAO,yBAAyB;AAChC,OAAO,uBAAuB;AAE9B,OAAO,iBAAgB,gCAA+B;AACtD,SAAQ,uBAAsB;AAG9B;AAAA,EAEI;AAAA,EAGA;AAAA,OAGG;AAIP,MAAO,6BAA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AAErC,WAAO,IAAI,IAAI,SAAS,KAAK,CAAC;AAAA,EAClC;AAAA,EAEA,MAAM,QAA0B;AAC5B,WAAO,KAAK,OAAO,EAAE,MAAM;AAAA,EAC/B;AAAA,EAEO,QAAc;AACjB,SAAK,OAAO,EAAE,MAAM;AAEpB,SAAK,YAAY;AACjB,SAAK,aAAa;AAClB,SAAK,aAAa;AAElB,WAAO,MAAM,MAAM;AAAA,EACvB;AACJ;","names":[]}
1
+ {"version":3,"sources":["../../../../src/cli/entrypoint/finder/LocaleFinder.ts"],"sourcesContent":["import _ from \"lodash\";\nimport path from \"path\";\nimport fs from \"fs\";\nimport yaml from \"js-yaml\";\n\nimport AbstractAssetFinder from \"./AbstractAssetFinder\";\nimport AssetPluginFinder from \"./AssetPluginFinder\";\nimport {FileLayer, FileSpecificity, getFilePrecedence} from \"./utils/filePrecedence\";\n\nimport localeFactory, {LocaleStructureValidator} from \"@cli/builders/locale\";\nimport {isFileExtension} from \"@cli/utils/path\";\n\nimport {ReadonlyConfig} from \"@typing/config\";\nimport {EntrypointFile} from \"@typing/entrypoint\";\nimport {\n Language,\n LanguageCodes,\n LocaleBuilders,\n LocaleData,\n LocaleFileExtensions,\n LocaleKeys,\n LocaleStructure,\n} from \"@typing/locale\";\n\nexport type {LocaleBuilders} from \"@typing/locale\";\n\nconst layerNames: Record<FileLayer, string> = {\n [FileLayer.Plugin]: \"plugin\",\n [FileLayer.Source]: \"source\",\n [FileLayer.Shared]: \"shared\",\n [FileLayer.App]: \"app\",\n [FileLayer.AppSource]: \"app source\",\n};\n\nconst specificityNames: Record<FileSpecificity, string> = {\n [FileSpecificity.Generic]: \"generic\",\n [FileSpecificity.Browser]: \"browser-specific\",\n};\n\nexport default class extends AbstractAssetFinder {\n protected _plugin?: AssetPluginFinder;\n protected _builders?: LocaleBuilders;\n protected _validator?: LocaleStructureValidator;\n protected _validated = false;\n\n public constructor(config: ReadonlyConfig) {\n super(config);\n }\n\n public isValidName(name: string): boolean {\n if (name.includes(\".\")) {\n name = name.split(\".\").slice(0, -1).join(\".\");\n }\n\n return super.isValidName(name);\n }\n\n public isValidExtension(extension: string): boolean {\n return LocaleFileExtensions.has(extension);\n }\n\n public getDirectory(): string {\n return this.config.localeDir || \"locales\";\n }\n\n public getNames(): ReadonlySet<string> {\n return LanguageCodes;\n }\n\n public canMerge(): boolean {\n return this.config.mergeLocales;\n }\n\n protected getPlugin(): AssetPluginFinder {\n return new AssetPluginFinder(this.config, \"locale\", this);\n }\n\n public plugin(): AssetPluginFinder {\n return (this._plugin ??= this.getPlugin());\n }\n\n protected async getBuilders(): Promise<LocaleBuilders> {\n return _.chain(Array.from(await this.plugin().files()))\n .groupBy(file => this.getLanguageFromFilename(file.file))\n .reduce((map, files, lang) => {\n this.assertUniqueFiles(lang as Language, files);\n\n const locale = localeFactory(lang as Language, this.config);\n\n for (const {file} of files) {\n const content = fs.readFileSync(file, \"utf8\");\n\n if (isFileExtension(file, [\"yaml\", \"yml\"])) {\n locale.merge(yaml.load(content) as LocaleData);\n } else if (isFileExtension(file, \"json\")) {\n locale.merge(JSON.parse(content));\n }\n }\n\n map.set(locale.lang(), locale);\n\n return map;\n }, new Map() as LocaleBuilders)\n .value();\n }\n\n protected assertUniqueFiles(lang: Language, files: EntrypointFile[]): void {\n const sources = new Map<string, EntrypointFile>();\n\n for (const file of files) {\n const {layer, order, specificity} = getFilePrecedence(file);\n const source = [layer, order, specificity].join(\":\");\n const duplicate = sources.get(source);\n\n if (duplicate) {\n throw new Error(\n `Locale \"${lang}\" has multiple ${specificityNames[specificity]} files in the ${layerNames[layer]} layer: \"${duplicate.file}\" and \"${file.file}\"`\n );\n }\n\n sources.set(source, file);\n }\n }\n\n protected getValidator(): LocaleStructureValidator {\n return (this._validator ??= new LocaleStructureValidator(this.config.lang));\n }\n\n protected getLanguageFromFilename(filename: string): Language {\n let {name} = path.parse(filename);\n\n if (name.includes(\".\")) {\n name = name.split(\".\").slice(0, -1).join(\".\");\n }\n\n if (LanguageCodes.has(name)) {\n return name as Language;\n }\n\n throw new Error(`Invalid locale filename: ${filename}`);\n }\n\n public async builders(): Promise<LocaleBuilders> {\n if (this._builders) {\n return this._builders;\n }\n\n return (this._builders = await this.getBuilders());\n }\n\n public async validate(): Promise<this> {\n if (!this._validated) {\n this.getValidator().validate(await this.builders());\n this._validated = true;\n }\n\n return this;\n }\n\n public async keys(): Promise<LocaleKeys> {\n const builders = await this.builders();\n const builder = this.getValidator().getDefaultBuilder(builders);\n\n return builder?.keys() ?? new Set();\n }\n\n public async structure(): Promise<LocaleStructure> {\n const builders = await this.builders();\n const builder = this.getValidator().getDefaultBuilder(builders);\n\n return builder?.structure() ?? {};\n }\n\n public async languages(): Promise<Set<Language>> {\n const builders = await this.builders();\n\n return new Set(builders.keys());\n }\n\n async empty(): Promise<boolean> {\n return this.plugin().empty();\n }\n\n public clear(): this {\n this.plugin().clear();\n\n this._builders = undefined;\n this._validator = undefined;\n this._validated = false;\n\n return super.clear();\n }\n}\n"],"mappings":"AAAA,OAAO,OAAO;AACd,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,OAAO,UAAU;AAEjB,OAAO,yBAAyB;AAChC,OAAO,uBAAuB;AAC9B,SAAQ,WAAW,iBAAiB,yBAAwB;AAE5D,OAAO,iBAAgB,gCAA+B;AACtD,SAAQ,uBAAsB;AAI9B;AAAA,EAEI;AAAA,EAGA;AAAA,OAGG;AAIP,MAAM,aAAwC;AAAA,EAC1C,CAAC,UAAU,MAAM,GAAG;AAAA,EACpB,CAAC,UAAU,MAAM,GAAG;AAAA,EACpB,CAAC,UAAU,MAAM,GAAG;AAAA,EACpB,CAAC,UAAU,GAAG,GAAG;AAAA,EACjB,CAAC,UAAU,SAAS,GAAG;AAC3B;AAEA,MAAM,mBAAoD;AAAA,EACtD,CAAC,gBAAgB,OAAO,GAAG;AAAA,EAC3B,CAAC,gBAAgB,OAAO,GAAG;AAC/B;AAEA,MAAO,6BAAsB,oBAAoB;AAAA,EACnC;AAAA,EACA;AAAA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,EAAE,SAAS,MAAM,KAAK,SAAS,CAAC;AAClD,WAAK,aAAa;AAAA,IACtB;AAEA,WAAO;AAAA,EACX;AAAA,EAEA,MAAa,OAA4B;AACrC,UAAM,WAAW,MAAM,KAAK,SAAS;AACrC,UAAM,UAAU,KAAK,aAAa,EAAE,kBAAkB,QAAQ;AAE9D,YAAO,mCAAS,WAAU,oBAAI,IAAI;AAAA,EACtC;AAAA,EAEA,MAAa,YAAsC;AAC/C,UAAM,WAAW,MAAM,KAAK,SAAS;AACrC,UAAM,UAAU,KAAK,aAAa,EAAE,kBAAkB,QAAQ;AAE9D,YAAO,mCAAS,gBAAe,CAAC;AAAA,EACpC;AAAA,EAEA,MAAa,YAAoC;AAC7C,UAAM,WAAW,MAAM,KAAK,SAAS;AAErC,WAAO,IAAI,IAAI,SAAS,KAAK,CAAC;AAAA,EAClC;AAAA,EAEA,MAAM,QAA0B;AAC5B,WAAO,KAAK,OAAO,EAAE,MAAM;AAAA,EAC/B;AAAA,EAEO,QAAc;AACjB,SAAK,OAAO,EAAE,MAAM;AAEpB,SAAK,YAAY;AACjB,SAAK,aAAa;AAClB,SAAK,aAAa;AAElB,WAAO,MAAM,MAAM;AAAA,EACvB;AACJ;","names":[]}
@@ -1,5 +1,6 @@
1
1
  import _ from "lodash";
2
2
  import AbstractOptionsFinder from "./AbstractOptionsFinder.js";
3
+ import { FileLayer, setFilePrecedence } from "./utils/filePrecedence.js";
3
4
  import { processPluginHandler } from "./../../../cli/resolvers/plugin.js";
4
5
  class PluginFinder_default extends AbstractOptionsFinder {
5
6
  constructor(config, key, finder) {
@@ -22,7 +23,8 @@ class PluginFinder_default extends AbstractOptionsFinder {
22
23
  })
23
24
  );
24
25
  const files = /* @__PURE__ */ new Set();
25
- for (const { name, result } of pluginResult) {
26
+ for (let pluginIndex = 0; pluginIndex < pluginResult.length; pluginIndex++) {
27
+ const { name, result } = pluginResult[pluginIndex];
26
28
  let endpoints = [];
27
29
  if (_.isBoolean(result)) {
28
30
  endpoints = [this.key];
@@ -33,8 +35,15 @@ class PluginFinder_default extends AbstractOptionsFinder {
33
35
  } else if (_.isSet(result)) {
34
36
  endpoints = Array.from(result);
35
37
  }
36
- for (const endpoint of endpoints) {
37
- files.add(_.isString(endpoint) ? this.resolve(name, endpoint) : endpoint);
38
+ for (let sequence = 0; sequence < endpoints.length; sequence++) {
39
+ const endpoint = endpoints[sequence];
40
+ const file = _.isString(endpoint) ? this.resolve(name, endpoint) : endpoint;
41
+ setFilePrecedence(file, {
42
+ layer: FileLayer.Plugin,
43
+ order: pluginIndex,
44
+ sequence
45
+ });
46
+ files.add(file);
38
47
  }
39
48
  }
40
49
  return files;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/cli/entrypoint/finder/PluginFinder.ts"],"sourcesContent":["import _ from \"lodash\";\n\nimport AbstractOptionsFinder from \"./AbstractOptionsFinder\";\n\nimport {processPluginHandler} from \"@cli/resolvers/plugin\";\n\nimport {ReadonlyConfig} from \"@typing/config\";\nimport {PluginHandlerKeys} from \"@typing/plugin\";\nimport {EntrypointFile, EntrypointOptions, EntrypointParser, EntrypointType} from \"@typing/entrypoint\";\n\nexport default class<O extends EntrypointOptions> extends AbstractOptionsFinder<O> {\n constructor(\n config: ReadonlyConfig,\n protected readonly key: PluginHandlerKeys,\n protected readonly finder: AbstractOptionsFinder<O>\n ) {\n super(config);\n }\n\n public type(): EntrypointType {\n return this.finder.type();\n }\n\n protected getParser(): EntrypointParser<O> {\n return this.finder.parser();\n }\n\n protected async getFiles(): Promise<Set<EntrypointFile>> {\n const pluginResult = await Array.fromAsync(\n processPluginHandler(this.config.plugins, this.key, {\n config: this.config,\n })\n );\n\n const files = new Set<EntrypointFile>();\n\n for (const {name, result} of pluginResult) {\n let endpoints: Array<string | EntrypointFile> = [];\n\n if (_.isBoolean(result)) {\n endpoints = [this.key];\n } else if (_.isString(result) || _.isPlainObject(result)) {\n endpoints = [result as string | EntrypointFile];\n } else if (_.isArray(result)) {\n endpoints = result;\n } else if (_.isSet(result)) {\n endpoints = Array.from(result as Set<EntrypointFile>);\n }\n\n for (const endpoint of endpoints) {\n files.add(_.isString(endpoint) ? this.resolve(name, endpoint) : endpoint);\n }\n }\n\n return files;\n }\n}\n"],"mappings":"AAAA,OAAO,OAAO;AAEd,OAAO,2BAA2B;AAElC,SAAQ,4BAA2B;AAMnC,MAAO,6BAAmD,sBAAyB;AAAA,EAC/E,YACI,QACmB,KACA,QACrB;AACE,UAAM,MAAM;AAHO;AACA;AAAA,EAGvB;AAAA,EAJuB;AAAA,EACA;AAAA,EAKhB,OAAuB;AAC1B,WAAO,KAAK,OAAO,KAAK;AAAA,EAC5B;AAAA,EAEU,YAAiC;AACvC,WAAO,KAAK,OAAO,OAAO;AAAA,EAC9B;AAAA,EAEA,MAAgB,WAAyC;AACrD,UAAM,eAAe,MAAM,MAAM;AAAA,MAC7B,qBAAqB,KAAK,OAAO,SAAS,KAAK,KAAK;AAAA,QAChD,QAAQ,KAAK;AAAA,MACjB,CAAC;AAAA,IACL;AAEA,UAAM,QAAQ,oBAAI,IAAoB;AAEtC,eAAW,EAAC,MAAM,OAAM,KAAK,cAAc;AACvC,UAAI,YAA4C,CAAC;AAEjD,UAAI,EAAE,UAAU,MAAM,GAAG;AACrB,oBAAY,CAAC,KAAK,GAAG;AAAA,MACzB,WAAW,EAAE,SAAS,MAAM,KAAK,EAAE,cAAc,MAAM,GAAG;AACtD,oBAAY,CAAC,MAAiC;AAAA,MAClD,WAAW,EAAE,QAAQ,MAAM,GAAG;AAC1B,oBAAY;AAAA,MAChB,WAAW,EAAE,MAAM,MAAM,GAAG;AACxB,oBAAY,MAAM,KAAK,MAA6B;AAAA,MACxD;AAEA,iBAAW,YAAY,WAAW;AAC9B,cAAM,IAAI,EAAE,SAAS,QAAQ,IAAI,KAAK,QAAQ,MAAM,QAAQ,IAAI,QAAQ;AAAA,MAC5E;AAAA,IACJ;AAEA,WAAO;AAAA,EACX;AACJ;","names":[]}
1
+ {"version":3,"sources":["../../../../src/cli/entrypoint/finder/PluginFinder.ts"],"sourcesContent":["import _ from \"lodash\";\n\nimport AbstractOptionsFinder from \"./AbstractOptionsFinder\";\nimport {FileLayer, setFilePrecedence} from \"./utils/filePrecedence\";\n\nimport {processPluginHandler} from \"@cli/resolvers/plugin\";\n\nimport {ReadonlyConfig} from \"@typing/config\";\nimport {PluginHandlerKeys} from \"@typing/plugin\";\nimport {EntrypointFile, EntrypointOptions, EntrypointParser, EntrypointType} from \"@typing/entrypoint\";\n\nexport default class<O extends EntrypointOptions> extends AbstractOptionsFinder<O> {\n constructor(\n config: ReadonlyConfig,\n protected readonly key: PluginHandlerKeys,\n protected readonly finder: AbstractOptionsFinder<O>\n ) {\n super(config);\n }\n\n public type(): EntrypointType {\n return this.finder.type();\n }\n\n protected getParser(): EntrypointParser<O> {\n return this.finder.parser();\n }\n\n protected async getFiles(): Promise<Set<EntrypointFile>> {\n const pluginResult = await Array.fromAsync(\n processPluginHandler(this.config.plugins, this.key, {\n config: this.config,\n })\n );\n\n const files = new Set<EntrypointFile>();\n\n for (let pluginIndex = 0; pluginIndex < pluginResult.length; pluginIndex++) {\n const {name, result} = pluginResult[pluginIndex];\n let endpoints: Array<string | EntrypointFile> = [];\n\n if (_.isBoolean(result)) {\n endpoints = [this.key];\n } else if (_.isString(result) || _.isPlainObject(result)) {\n endpoints = [result as string | EntrypointFile];\n } else if (_.isArray(result)) {\n endpoints = result;\n } else if (_.isSet(result)) {\n endpoints = Array.from(result as Set<EntrypointFile>);\n }\n\n for (let sequence = 0; sequence < endpoints.length; sequence++) {\n const endpoint = endpoints[sequence];\n const file = _.isString(endpoint) ? this.resolve(name, endpoint) : endpoint;\n\n setFilePrecedence(file, {\n layer: FileLayer.Plugin,\n order: pluginIndex,\n sequence,\n });\n files.add(file);\n }\n }\n\n return files;\n }\n}\n"],"mappings":"AAAA,OAAO,OAAO;AAEd,OAAO,2BAA2B;AAClC,SAAQ,WAAW,yBAAwB;AAE3C,SAAQ,4BAA2B;AAMn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 type CspEntrypointOptions = ViewEntrypointOptions & {
5
5
  csp?: unknown;
6
6
  };
7
7
  export default abstract class<O extends CspEntrypointOptions, Csp = CspConfig> extends AbstractViewFinder<O> {
8
+ protected _csp?: Csp[];
8
9
  protected getViews(): Promise<ViewItems<O>>;
9
10
  csp(): Promise<Csp[]>;
11
+ clear(): this;
10
12
  }
11
13
  export {};
@@ -1,21 +1,28 @@
1
1
  import AbstractViewFinder from "./AbstractViewFinder.js";
2
2
  class ViewCspFinder_default extends AbstractViewFinder {
3
+ _csp;
3
4
  async getViews() {
4
5
  const views = await super.getViews();
6
+ const policies = [];
5
7
  for (const view of views.values()) {
6
8
  const { csp, ...options } = view.options;
9
+ if (csp) {
10
+ policies.push(csp);
11
+ }
7
12
  view.options = options;
8
13
  }
14
+ this._csp = policies;
9
15
  return views;
10
16
  }
11
17
  async csp() {
12
- const policies = [];
13
- for (const [, options] of await this.plugin().options()) {
14
- if (options.csp) {
15
- policies.push(options.csp);
16
- }
18
+ if (!this._csp) {
19
+ await this.views();
17
20
  }
18
- return policies;
21
+ return this._csp ?? [];
22
+ }
23
+ clear() {
24
+ this._csp = void 0;
25
+ return super.clear();
19
26
  }
20
27
  }
21
28
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/cli/entrypoint/finder/ViewCspFinder.ts"],"sourcesContent":["import AbstractViewFinder, {ViewItems} from \"./AbstractViewFinder\";\n\nimport type {CspConfig} from \"@typing/csp\";\nimport type {ViewEntrypointOptions} from \"@typing/view\";\n\ntype CspEntrypointOptions = ViewEntrypointOptions & {csp?: unknown};\n\nexport default abstract class<O extends CspEntrypointOptions, Csp = CspConfig> extends AbstractViewFinder<O> {\n protected async getViews(): Promise<ViewItems<O>> {\n const views = await super.getViews();\n\n for (const view of views.values()) {\n const {csp, ...options} = view.options;\n\n view.options = options as O;\n }\n\n return views;\n }\n\n public async csp(): Promise<Csp[]> {\n const policies: Csp[] = [];\n\n for (const [, options] of await this.plugin().options()) {\n if (options.csp) {\n policies.push(options.csp as Csp);\n }\n }\n\n return policies;\n }\n}\n"],"mappings":"AAAA,OAAO,wBAAqC;AAO5C,MAAO,8BAAgF,mBAAsB;AAAA,EACzG,MAAgB,WAAkC;AAC9C,UAAM,QAAQ,MAAM,MAAM,SAAS;AAEnC,eAAW,QAAQ,MAAM,OAAO,GAAG;AAC/B,YAAM,EAAC,KAAK,GAAG,QAAO,IAAI,KAAK;AAE/B,WAAK,UAAU;AAAA,IACnB;AAEA,WAAO;AAAA,EACX;AAAA,EAEA,MAAa,MAAsB;AAC/B,UAAM,WAAkB,CAAC;AAEzB,eAAW,CAAC,EAAE,OAAO,KAAK,MAAM,KAAK,OAAO,EAAE,QAAQ,GAAG;AACrD,UAAI,QAAQ,KAAK;AACb,iBAAS,KAAK,QAAQ,GAAU;AAAA,MACpC;AAAA,IACJ;AAEA,WAAO;AAAA,EACX;AACJ;","names":[]}
1
+ {"version":3,"sources":["../../../../src/cli/entrypoint/finder/ViewCspFinder.ts"],"sourcesContent":["import AbstractViewFinder, {ViewItems} from \"./AbstractViewFinder\";\n\nimport type {CspConfig} from \"@typing/csp\";\nimport type {ViewEntrypointOptions} from \"@typing/view\";\n\ntype CspEntrypointOptions = ViewEntrypointOptions & {csp?: unknown};\n\nexport default abstract class<O extends CspEntrypointOptions, Csp = CspConfig> extends AbstractViewFinder<O> {\n protected _csp?: Csp[];\n\n protected async getViews(): Promise<ViewItems<O>> {\n const views = await super.getViews();\n const policies: Csp[] = [];\n\n for (const view of views.values()) {\n const {csp, ...options} = view.options;\n\n if (csp) {\n policies.push(csp as Csp);\n }\n\n view.options = options as O;\n }\n\n this._csp = policies;\n\n return views;\n }\n\n public async csp(): Promise<Csp[]> {\n if (!this._csp) {\n await this.views();\n }\n\n return this._csp ?? [];\n }\n\n public clear(): this {\n this._csp = undefined;\n\n return super.clear();\n }\n}\n"],"mappings":"AAAA,OAAO,wBAAqC;AAO5C,MAAO,8BAAgF,mBAAsB;AAAA,EAC/F;AAAA,EAEV,MAAgB,WAAkC;AAC9C,UAAM,QAAQ,MAAM,MAAM,SAAS;AACnC,UAAM,WAAkB,CAAC;AAEzB,eAAW,QAAQ,MAAM,OAAO,GAAG;AAC/B,YAAM,EAAC,KAAK,GAAG,QAAO,IAAI,KAAK;AAE/B,UAAI,KAAK;AACL,iBAAS,KAAK,GAAU;AAAA,MAC5B;AAEA,WAAK,UAAU;AAAA,IACnB;AAEA,SAAK,OAAO;AAEZ,WAAO;AAAA,EACX;AAAA,EAEA,MAAa,MAAsB;AAC/B,QAAI,CAAC,KAAK,MAAM;AACZ,YAAM,KAAK,MAAM;AAAA,IACrB;AAEA,WAAO,KAAK,QAAQ,CAAC;AAAA,EACzB;AAAA,EAEO,QAAc;AACjB,SAAK,OAAO;AAEZ,WAAO,MAAM,MAAM;AAAA,EACvB;AACJ;","names":[]}
@@ -0,0 +1,35 @@
1
+ import { EntrypointFile } from "../../../../types/entrypoint.js";
2
+ /**
3
+ * Numeric values define the composition order from the least specific layer
4
+ * to the most specific one. Consumers that merge values therefore let later
5
+ * workspace layers override plugins, while singleton consumers select the
6
+ * final candidate.
7
+ */
8
+ export declare enum FileLayer {
9
+ Plugin = 0,
10
+ Source = 1,
11
+ Shared = 2,
12
+ App = 3,
13
+ AppSource = 4
14
+ }
15
+ export type WorkspaceFileLayer = Exclude<FileLayer, FileLayer.Plugin>;
16
+ export declare enum FileSpecificity {
17
+ Generic = 0,
18
+ Browser = 1
19
+ }
20
+ export interface FilePrecedence {
21
+ layer: FileLayer;
22
+ order?: number;
23
+ sequence?: number;
24
+ specificity?: FileSpecificity;
25
+ }
26
+ /**
27
+ * Workspace discovery runs from highest to lowest priority. This lets
28
+ * non-merge consumers stop at the first non-empty layer and ensures that
29
+ * overlapping canonical paths keep their most specific layer.
30
+ */
31
+ export declare const getWorkspaceFileLayers: () => readonly WorkspaceFileLayer[];
32
+ export declare const setFilePrecedence: (file: EntrypointFile, value: FilePrecedence) => EntrypointFile;
33
+ export declare const setFileSpecificity: (file: EntrypointFile, specificity: FileSpecificity) => EntrypointFile;
34
+ export declare const getFilePrecedence: (file: EntrypointFile) => Required<FilePrecedence>;
35
+ export declare const compareFilePrecedence: (a: EntrypointFile, b: EntrypointFile) => number;
@@ -0,0 +1,64 @@
1
+ var FileLayer = /* @__PURE__ */ ((FileLayer2) => {
2
+ FileLayer2[FileLayer2["Plugin"] = 0] = "Plugin";
3
+ FileLayer2[FileLayer2["Source"] = 1] = "Source";
4
+ FileLayer2[FileLayer2["Shared"] = 2] = "Shared";
5
+ FileLayer2[FileLayer2["App"] = 3] = "App";
6
+ FileLayer2[FileLayer2["AppSource"] = 4] = "AppSource";
7
+ return FileLayer2;
8
+ })(FileLayer || {});
9
+ var FileSpecificity = /* @__PURE__ */ ((FileSpecificity2) => {
10
+ FileSpecificity2[FileSpecificity2["Generic"] = 0] = "Generic";
11
+ FileSpecificity2[FileSpecificity2["Browser"] = 1] = "Browser";
12
+ return FileSpecificity2;
13
+ })(FileSpecificity || {});
14
+ const precedence = /* @__PURE__ */ new WeakMap();
15
+ const normalize = ({
16
+ layer,
17
+ order = 0,
18
+ sequence = 0,
19
+ specificity = 0 /* Generic */
20
+ }) => ({
21
+ layer,
22
+ order,
23
+ sequence,
24
+ specificity
25
+ });
26
+ const fallback = normalize({ layer: 0 /* Plugin */ });
27
+ const isWorkspaceFileLayer = (layer) => {
28
+ return typeof layer === "number" && layer !== 0 /* Plugin */;
29
+ };
30
+ const workspaceFileLayers = Object.freeze(
31
+ Object.values(FileLayer).filter(isWorkspaceFileLayer).sort((a, b) => b - a)
32
+ );
33
+ const getWorkspaceFileLayers = () => workspaceFileLayers;
34
+ const setFilePrecedence = (file, value) => {
35
+ if (!precedence.has(file)) {
36
+ precedence.set(file, normalize(value));
37
+ }
38
+ return file;
39
+ };
40
+ const setFileSpecificity = (file, specificity) => {
41
+ precedence.set(file, {
42
+ ...precedence.get(file) ?? fallback,
43
+ specificity
44
+ });
45
+ return file;
46
+ };
47
+ const getFilePrecedence = (file) => {
48
+ return precedence.get(file) ?? fallback;
49
+ };
50
+ const compareFilePrecedence = (a, b) => {
51
+ const left = getFilePrecedence(a);
52
+ const right = getFilePrecedence(b);
53
+ return left.layer - right.layer || left.order - right.order || left.specificity - right.specificity || left.sequence - right.sequence;
54
+ };
55
+ export {
56
+ FileLayer,
57
+ FileSpecificity,
58
+ compareFilePrecedence,
59
+ getFilePrecedence,
60
+ getWorkspaceFileLayers,
61
+ setFilePrecedence,
62
+ setFileSpecificity
63
+ };
64
+ //# sourceMappingURL=filePrecedence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/cli/entrypoint/finder/utils/filePrecedence.ts"],"sourcesContent":["import {EntrypointFile} from \"@typing/entrypoint\";\n\n/**\n * Numeric values define the composition order from the least specific layer\n * to the most specific one. Consumers that merge values therefore let later\n * workspace layers override plugins, while singleton consumers select the\n * final candidate.\n */\nexport enum FileLayer {\n Plugin,\n Source,\n Shared,\n App,\n AppSource,\n}\n\nexport type WorkspaceFileLayer = Exclude<FileLayer, FileLayer.Plugin>;\n\nexport enum FileSpecificity {\n Generic,\n Browser,\n}\n\nexport interface FilePrecedence {\n layer: FileLayer;\n order?: number;\n sequence?: number;\n specificity?: FileSpecificity;\n}\n\nconst precedence = new WeakMap<EntrypointFile, Required<FilePrecedence>>();\n\nconst normalize = ({\n layer,\n order = 0,\n sequence = 0,\n specificity = FileSpecificity.Generic,\n}: FilePrecedence): Required<FilePrecedence> => ({\n layer,\n order,\n sequence,\n specificity,\n});\n\nconst fallback = normalize({layer: FileLayer.Plugin});\n\nconst isWorkspaceFileLayer = (layer: string | FileLayer): layer is WorkspaceFileLayer => {\n return typeof layer === \"number\" && layer !== FileLayer.Plugin;\n};\n\nconst workspaceFileLayers = Object.freeze(\n Object.values(FileLayer)\n .filter(isWorkspaceFileLayer)\n .sort((a, b) => b - a)\n);\n\n/**\n * Workspace discovery runs from highest to lowest priority. This lets\n * non-merge consumers stop at the first non-empty layer and ensures that\n * overlapping canonical paths keep their most specific layer.\n */\nexport const getWorkspaceFileLayers = (): readonly WorkspaceFileLayer[] => workspaceFileLayers;\n\nexport const setFilePrecedence = (file: EntrypointFile, value: FilePrecedence): EntrypointFile => {\n if (!precedence.has(file)) {\n precedence.set(file, normalize(value));\n }\n\n return file;\n};\n\nexport const setFileSpecificity = (file: EntrypointFile, specificity: FileSpecificity): EntrypointFile => {\n precedence.set(file, {\n ...(precedence.get(file) ?? fallback),\n specificity,\n });\n\n return file;\n};\n\nexport const getFilePrecedence = (file: EntrypointFile): Required<FilePrecedence> => {\n return precedence.get(file) ?? fallback;\n};\n\nexport const compareFilePrecedence = (a: EntrypointFile, b: EntrypointFile): number => {\n const left = getFilePrecedence(a);\n const right = getFilePrecedence(b);\n\n return (\n left.layer - right.layer ||\n left.order - right.order ||\n left.specificity - right.specificity ||\n left.sequence - right.sequence\n );\n};\n"],"mappings":"AAQO,IAAK,YAAL,kBAAKA,eAAL;AACH,EAAAA,sBAAA;AACA,EAAAA,sBAAA;AACA,EAAAA,sBAAA;AACA,EAAAA,sBAAA;AACA,EAAAA,sBAAA;AALQ,SAAAA;AAAA,GAAA;AAUL,IAAK,kBAAL,kBAAKC,qBAAL;AACH,EAAAA,kCAAA;AACA,EAAAA,kCAAA;AAFQ,SAAAA;AAAA,GAAA;AAYZ,MAAM,aAAa,oBAAI,QAAkD;AAEzE,MAAM,YAAY,CAAC;AAAA,EACf;AAAA,EACA,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,cAAc;AAClB,OAAiD;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;AAEA,MAAM,WAAW,UAAU,EAAC,OAAO,eAAgB,CAAC;AAEpD,MAAM,uBAAuB,CAAC,UAA2D;AACrF,SAAO,OAAO,UAAU,YAAY,UAAU;AAClD;AAEA,MAAM,sBAAsB,OAAO;AAAA,EAC/B,OAAO,OAAO,SAAS,EAClB,OAAO,oBAAoB,EAC3B,KAAK,CAAC,GAAG,MAAM,IAAI,CAAC;AAC7B;AAOO,MAAM,yBAAyB,MAAqC;AAEpE,MAAM,oBAAoB,CAAC,MAAsB,UAA0C;AAC9F,MAAI,CAAC,WAAW,IAAI,IAAI,GAAG;AACvB,eAAW,IAAI,MAAM,UAAU,KAAK,CAAC;AAAA,EACzC;AAEA,SAAO;AACX;AAEO,MAAM,qBAAqB,CAAC,MAAsB,gBAAiD;AACtG,aAAW,IAAI,MAAM;AAAA,IACjB,GAAI,WAAW,IAAI,IAAI,KAAK;AAAA,IAC5B;AAAA,EACJ,CAAC;AAED,SAAO;AACX;AAEO,MAAM,oBAAoB,CAAC,SAAmD;AACjF,SAAO,WAAW,IAAI,IAAI,KAAK;AACnC;AAEO,MAAM,wBAAwB,CAAC,GAAmB,MAA8B;AACnF,QAAM,OAAO,kBAAkB,CAAC;AAChC,QAAM,QAAQ,kBAAkB,CAAC;AAEjC,SACI,KAAK,QAAQ,MAAM,SACnB,KAAK,QAAQ,MAAM,SACnB,KAAK,cAAc,MAAM,eACzB,KAAK,WAAW,MAAM;AAE9B;","names":["FileLayer","FileSpecificity"]}
@@ -1,7 +1,7 @@
1
1
  import AbstractParser from "./AbstractParser.js";
2
2
  import { ContentScriptEntrypointOptions } from "../../../types/content.js";
3
- import { EntrypointFile } from "../../../types/entrypoint.js";
4
- export default class<O extends ContentScriptEntrypointOptions = ContentScriptEntrypointOptions> extends AbstractParser<O> {
3
+ import { EntrypointFile, EntrypointOptions } from "../../../types/entrypoint.js";
4
+ export default class<O extends EntrypointOptions = ContentScriptEntrypointOptions> extends AbstractParser<O> {
5
5
  protected definition(): string | string[];
6
6
  protected schema(): typeof this.CommonPropertiesSchema;
7
7
  options(file: EntrypointFile): O;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/cli/entrypoint/parser/ContentParser.ts"],"sourcesContent":["import z from \"zod\";\n\nimport AbstractParser from \"./AbstractParser\";\n\nimport {\n ContentScriptDeclarative,\n ContentScriptEntrypointOptions,\n ContentScriptMarker,\n ContentScriptMatches,\n} from \"@typing/content\";\nimport {EntrypointFile} from \"@typing/entrypoint\";\n\nexport default class<\n O extends ContentScriptEntrypointOptions = ContentScriptEntrypointOptions,\n> extends AbstractParser<O> {\n protected definition(): string | string[] {\n return [\"defineContentScript\", \"defineContentScriptAppend\"];\n }\n\n protected schema(): typeof this.CommonPropertiesSchema {\n return this.CommonPropertiesSchema.extend({\n matches: z.array(z.string()).optional(),\n excludeMatches: z.array(z.string()).optional(),\n matchAboutBlank: z.boolean().optional(),\n includeGlobs: z.array(z.string()).optional(),\n excludeGlobs: z.array(z.string()).optional(),\n allFrames: z.boolean().optional(),\n world: z.enum([\"ISOLATED\", \"MAIN\"]).optional(),\n runAt: z.enum([\"document_start\", \"document_end\", \"document_idle\"]).optional(),\n matchOriginAsFallback: z.boolean().optional(),\n declarative: z.union([z.nativeEnum(ContentScriptDeclarative), z.boolean()]).optional(),\n marker: z.union([z.nativeEnum(ContentScriptMarker), z.boolean()]).optional(),\n });\n }\n\n public options(file: EntrypointFile): O {\n const options = super.options(file);\n\n return {\n matches: ContentScriptMatches,\n runAt: \"document_idle\",\n ...options,\n };\n }\n}\n"],"mappings":"AAAA,OAAO,OAAO;AAEd,OAAO,oBAAoB;AAE3B;AAAA,EACI;AAAA,EAEA;AAAA,EACA;AAAA,OACG;AAGP,MAAO,8BAEG,eAAkB;AAAA,EACd,aAAgC;AACtC,WAAO,CAAC,uBAAuB,2BAA2B;AAAA,EAC9D;AAAA,EAEU,SAA6C;AACnD,WAAO,KAAK,uBAAuB,OAAO;AAAA,MACtC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,MACtC,gBAAgB,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,MAC7C,iBAAiB,EAAE,QAAQ,EAAE,SAAS;AAAA,MACtC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,MAC3C,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,MAC3C,WAAW,EAAE,QAAQ,EAAE,SAAS;AAAA,MAChC,OAAO,EAAE,KAAK,CAAC,YAAY,MAAM,CAAC,EAAE,SAAS;AAAA,MAC7C,OAAO,EAAE,KAAK,CAAC,kBAAkB,gBAAgB,eAAe,CAAC,EAAE,SAAS;AAAA,MAC5E,uBAAuB,EAAE,QAAQ,EAAE,SAAS;AAAA,MAC5C,aAAa,EAAE,MAAM,CAAC,EAAE,WAAW,wBAAwB,GAAG,EAAE,QAAQ,CAAC,CAAC,EAAE,SAAS;AAAA,MACrF,QAAQ,EAAE,MAAM,CAAC,EAAE,WAAW,mBAAmB,GAAG,EAAE,QAAQ,CAAC,CAAC,EAAE,SAAS;AAAA,IAC/E,CAAC;AAAA,EACL;AAAA,EAEO,QAAQ,MAAyB;AACpC,UAAM,UAAU,MAAM,QAAQ,IAAI;AAElC,WAAO;AAAA,MACH,SAAS;AAAA,MACT,OAAO;AAAA,MACP,GAAG;AAAA,IACP;AAAA,EACJ;AACJ;","names":[]}
1
+ {"version":3,"sources":["../../../../src/cli/entrypoint/parser/ContentParser.ts"],"sourcesContent":["import z from \"zod\";\n\nimport AbstractParser from \"./AbstractParser\";\n\nimport {\n ContentScriptDeclarative,\n ContentScriptEntrypointOptions,\n ContentScriptMarker,\n ContentScriptMatches,\n} from \"@typing/content\";\nimport {EntrypointFile, EntrypointOptions} from \"@typing/entrypoint\";\n\nexport default class<O extends EntrypointOptions = ContentScriptEntrypointOptions> extends AbstractParser<O> {\n protected definition(): string | string[] {\n return [\"defineContentScript\", \"defineContentScriptAppend\"];\n }\n\n protected schema(): typeof this.CommonPropertiesSchema {\n return this.CommonPropertiesSchema.extend({\n matches: z.array(z.string()).optional(),\n excludeMatches: z.array(z.string()).optional(),\n matchAboutBlank: z.boolean().optional(),\n includeGlobs: z.array(z.string()).optional(),\n excludeGlobs: z.array(z.string()).optional(),\n allFrames: z.boolean().optional(),\n world: z.enum([\"ISOLATED\", \"MAIN\"]).optional(),\n runAt: z.enum([\"document_start\", \"document_end\", \"document_idle\"]).optional(),\n matchOriginAsFallback: z.boolean().optional(),\n declarative: z.union([z.nativeEnum(ContentScriptDeclarative), z.boolean()]).optional(),\n marker: z.union([z.nativeEnum(ContentScriptMarker), z.boolean()]).optional(),\n });\n }\n\n public options(file: EntrypointFile): O {\n const options = super.options(file);\n\n return {\n matches: ContentScriptMatches,\n runAt: \"document_idle\",\n ...options,\n };\n }\n}\n"],"mappings":"AAAA,OAAO,OAAO;AAEd,OAAO,oBAAoB;AAE3B;AAAA,EACI;AAAA,EAEA;AAAA,EACA;AAAA,OACG;AAGP,MAAO,8BAAoF,eAAkB;AAAA,EAC/F,aAAgC;AACtC,WAAO,CAAC,uBAAuB,2BAA2B;AAAA,EAC9D;AAAA,EAEU,SAA6C;AACnD,WAAO,KAAK,uBAAuB,OAAO;AAAA,MACtC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,MACtC,gBAAgB,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,MAC7C,iBAAiB,EAAE,QAAQ,EAAE,SAAS;AAAA,MACtC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,MAC3C,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,MAC3C,WAAW,EAAE,QAAQ,EAAE,SAAS;AAAA,MAChC,OAAO,EAAE,KAAK,CAAC,YAAY,MAAM,CAAC,EAAE,SAAS;AAAA,MAC7C,OAAO,EAAE,KAAK,CAAC,kBAAkB,gBAAgB,eAAe,CAAC,EAAE,SAAS;AAAA,MAC5E,uBAAuB,EAAE,QAAQ,EAAE,SAAS;AAAA,MAC5C,aAAa,EAAE,MAAM,CAAC,EAAE,WAAW,wBAAwB,GAAG,EAAE,QAAQ,CAAC,CAAC,EAAE,SAAS;AAAA,MACrF,QAAQ,EAAE,MAAM,CAAC,EAAE,WAAW,mBAAmB,GAAG,EAAE,QAAQ,CAAC,CAAC,EAAE,SAAS;AAAA,IAC/E,CAAC;AAAA,EACL;AAAA,EAEO,QAAQ,MAAyB;AACpC,UAAM,UAAU,MAAM,QAAQ,IAAI;AAElC,WAAO;AAAA,MACH,SAAS;AAAA,MACT,OAAO;AAAA,MACP,GAAG;AAAA,IACP;AAAA,EACJ;AACJ;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import z from "zod";
2
2
  import ContentParser from "./ContentParser.js";
3
- import { RelayMethod } from "./../../../types/relay.js";
3
+ import { RelayAllFrames, RelayMethod } from "./../../../types/relay.js";
4
4
  import { ContentScriptDeclarative } from "./../../../types/content.js";
5
5
  class RelayParser_default extends ContentParser {
6
6
  definition() {
@@ -11,6 +11,7 @@ class RelayParser_default extends ContentParser {
11
11
  }
12
12
  schema() {
13
13
  return super.schema().extend({
14
+ allFrames: z.union([z.boolean(), z.nativeEnum(RelayAllFrames)]).optional(),
14
15
  name: z.string().trim().min(1).max(100).regex(/^[\p{L}_$][\p{L}\p{N}_$]*$/u, {
15
16
  message: "Key must start with a Unicode letter, `$` or `_`, and may only contain letters, digits, `$` or `_`"
16
17
  }).optional(),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/cli/entrypoint/parser/RelayParser.ts"],"sourcesContent":["import z from \"zod\";\n\nimport ContentParser from \"./ContentParser\";\n\nimport {RelayEntrypointOptions, RelayMethod} from \"@typing/relay\";\nimport {EntrypointFile} from \"@typing/entrypoint\";\nimport {ContentScriptDeclarative} from \"@typing/content\";\n\nexport default class extends ContentParser<RelayEntrypointOptions> {\n protected definition(): string {\n return \"defineRelay\";\n }\n\n protected agreement(): string {\n return \"init\";\n }\n\n protected schema(): typeof this.CommonPropertiesSchema {\n return super.schema().extend({\n name: z\n .string()\n .trim()\n .min(1)\n .max(100)\n .regex(/^[\\p{L}_$][\\p{L}\\p{N}_$]*$/u, {\n message:\n \"Key must start with a Unicode letter, `$` or `_`, and may only contain letters, digits, `$` or `_`\",\n })\n .optional(),\n method: z.nativeEnum(RelayMethod).optional(),\n });\n }\n\n public options(file: EntrypointFile): RelayEntrypointOptions {\n const {declarative, method, ...options} = super.options(file);\n\n return {\n ...options,\n method,\n declarative:\n declarative === undefined\n ? method === RelayMethod.Scripting\n ? ContentScriptDeclarative.Optional\n : undefined\n : declarative,\n };\n }\n}\n"],"mappings":"AAAA,OAAO,OAAO;AAEd,OAAO,mBAAmB;AAE1B,SAAgC,mBAAkB;AAElD,SAAQ,gCAA+B;AAEvC,MAAO,4BAAsB,cAAsC;AAAA,EACrD,aAAqB;AAC3B,WAAO;AAAA,EACX;AAAA,EAEU,YAAoB;AAC1B,WAAO;AAAA,EACX;AAAA,EAEU,SAA6C;AACnD,WAAO,MAAM,OAAO,EAAE,OAAO;AAAA,MACzB,MAAM,EACD,OAAO,EACP,KAAK,EACL,IAAI,CAAC,EACL,IAAI,GAAG,EACP,MAAM,+BAA+B;AAAA,QAClC,SACI;AAAA,MACR,CAAC,EACA,SAAS;AAAA,MACd,QAAQ,EAAE,WAAW,WAAW,EAAE,SAAS;AAAA,IAC/C,CAAC;AAAA,EACL;AAAA,EAEO,QAAQ,MAA8C;AACzD,UAAM,EAAC,aAAa,QAAQ,GAAG,QAAO,IAAI,MAAM,QAAQ,IAAI;AAE5D,WAAO;AAAA,MACH,GAAG;AAAA,MACH;AAAA,MACA,aACI,gBAAgB,SACV,WAAW,YAAY,YACnB,yBAAyB,WACzB,SACJ;AAAA,IACd;AAAA,EACJ;AACJ;","names":[]}
1
+ {"version":3,"sources":["../../../../src/cli/entrypoint/parser/RelayParser.ts"],"sourcesContent":["import z from \"zod\";\n\nimport ContentParser from \"./ContentParser\";\n\nimport {RelayAllFrames, RelayEntrypointOptions, RelayMethod} from \"@typing/relay\";\nimport {EntrypointFile} from \"@typing/entrypoint\";\nimport {ContentScriptDeclarative} from \"@typing/content\";\n\nexport default class extends ContentParser<RelayEntrypointOptions> {\n protected definition(): string {\n return \"defineRelay\";\n }\n\n protected agreement(): string {\n return \"init\";\n }\n\n protected schema(): typeof this.CommonPropertiesSchema {\n return super.schema().extend({\n allFrames: z.union([z.boolean(), z.nativeEnum(RelayAllFrames)]).optional(),\n name: z\n .string()\n .trim()\n .min(1)\n .max(100)\n .regex(/^[\\p{L}_$][\\p{L}\\p{N}_$]*$/u, {\n message:\n \"Key must start with a Unicode letter, `$` or `_`, and may only contain letters, digits, `$` or `_`\",\n })\n .optional(),\n method: z.nativeEnum(RelayMethod).optional(),\n });\n }\n\n public options(file: EntrypointFile): RelayEntrypointOptions {\n const {declarative, method, ...options} = super.options(file);\n\n return {\n ...options,\n method,\n declarative:\n declarative === undefined\n ? method === RelayMethod.Scripting\n ? ContentScriptDeclarative.Optional\n : undefined\n : declarative,\n };\n }\n}\n"],"mappings":"AAAA,OAAO,OAAO;AAEd,OAAO,mBAAmB;AAE1B,SAAQ,gBAAwC,mBAAkB;AAElE,SAAQ,gCAA+B;AAEvC,MAAO,4BAAsB,cAAsC;AAAA,EACrD,aAAqB;AAC3B,WAAO;AAAA,EACX;AAAA,EAEU,YAAoB;AAC1B,WAAO;AAAA,EACX;AAAA,EAEU,SAA6C;AACnD,WAAO,MAAM,OAAO,EAAE,OAAO;AAAA,MACzB,WAAW,EAAE,MAAM,CAAC,EAAE,QAAQ,GAAG,EAAE,WAAW,cAAc,CAAC,CAAC,EAAE,SAAS;AAAA,MACzE,MAAM,EACD,OAAO,EACP,KAAK,EACL,IAAI,CAAC,EACL,IAAI,GAAG,EACP,MAAM,+BAA+B;AAAA,QAClC,SACI;AAAA,MACR,CAAC,EACA,SAAS;AAAA,MACd,QAAQ,EAAE,WAAW,WAAW,EAAE,SAAS;AAAA,IAC/C,CAAC;AAAA,EACL;AAAA,EAEO,QAAQ,MAA8C;AACzD,UAAM,EAAC,aAAa,QAAQ,GAAG,QAAO,IAAI,MAAM,QAAQ,IAAI;AAE5D,WAAO;AAAA,MACH,GAAG;AAAA,MACH;AAAA,MACA,aACI,gBAAgB,SACV,WAAW,YAAY,YACnB,yBAAyB,WACzB,SACJ;AAAA,IACd;AAAA,EACJ;AACJ;","names":[]}
package/dist/cli/index.js CHANGED
@@ -25,6 +25,7 @@ cli.command("watch [root]", "Start watch mode").option("-m, --mode <mode>", "Set
25
25
  });
26
26
  } catch (e) {
27
27
  consola.error(e);
28
+ process.exitCode = 1;
28
29
  }
29
30
  });
30
31
  cli.command("build [root]", "Build for production").option("-m, --mode <mode>", "Set env mode", { default: "production" }).option("-c, --config <config>", "Path to config file").option("-a, --app <app>", "Specify an app to run", { default: "myapp" }).option("-b, --browser <browser>", "Specify a browser", { default: Browser.Chrome }).option("--mv2", "Target manifest v2").option("--analyze", "Visualize extension bundle").action(async (root, options) => {
@@ -42,6 +43,7 @@ cli.command("build [root]", "Build for production").option("-m, --mode <mode>",
42
43
  });
43
44
  } catch (e) {
44
45
  consola.error(e);
46
+ process.exitCode = 1;
45
47
  }
46
48
  });
47
49
  cli.version(version);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cli/index.ts"],"sourcesContent":["import cac from \"cac\";\nimport {consola} from \"consola\";\nimport fs from \"fs\";\n\nimport app from \"./builders/app\";\n\nimport {Command} from \"@typing/app\";\nimport {Browser} from \"@typing/browser\";\n\nconst pkg = fs.readFileSync(new URL(\"../../package.json\", import.meta.url), {encoding: \"utf-8\"});\nconst {name, version} = JSON.parse(pkg);\n\nconst cli = cac(name);\n\ncli.option(\"--debug\", \"Enable debug mode\");\n\ncli.command(\"init\", \"Initialize a new project\").action(() => {\n consola.box(\"Coming soon...\");\n});\n\ncli.command(\"watch [root]\", \"Start watch mode\")\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(\"--mv2\", \"Target manifest v2\")\n .action(async (root, options) => {\n try {\n await app({\n command: Command.Watch,\n mode: options.mode,\n debug: options.debug,\n app: options.app,\n browser: options.browser,\n manifestVersion: options.mv2 ? 2 : 3,\n rootDir: root,\n configFile: options.config,\n });\n } catch (e) {\n consola.error(e);\n }\n });\n\ncli.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 try {\n await app({\n command: Command.Build,\n mode: options.mode,\n debug: options.debug,\n app: options.app,\n browser: options.browser,\n manifestVersion: options.mv2 ? 2 : 3,\n rootDir: root,\n configFile: options.config,\n analyze: options.analyze,\n });\n } catch (e) {\n consola.error(e);\n }\n });\n\ncli.version(version);\ncli.help();\ncli.parse();\n"],"mappings":"AAAA,OAAO,SAAS;AAChB,SAAQ,eAAc;AACtB,OAAO,QAAQ;AAEf,OAAO,SAAS;AAEhB,SAAQ,eAAc;AACtB,SAAQ,eAAc;AAEtB,MAAM,MAAM,GAAG,aAAa,IAAI,IAAI,sBAAsB,YAAY,GAAG,GAAG,EAAC,UAAU,QAAO,CAAC;AAC/F,MAAM,EAAC,MAAM,QAAO,IAAI,KAAK,MAAM,GAAG;AAEtC,MAAM,MAAM,IAAI,IAAI;AAEpB,IAAI,OAAO,WAAW,mBAAmB;AAEzC,IAAI,QAAQ,QAAQ,0BAA0B,EAAE,OAAO,MAAM;AACzD,UAAQ,IAAI,gBAAgB;AAChC,CAAC;AAED,IAAI,QAAQ,gBAAgB,kBAAkB,EACzC,OAAO,qBAAqB,gBAAgB,EAAC,SAAS,cAAa,CAAC,EACpE,OAAO,yBAAyB,qBAAqB,EACrD,OAAO,mBAAmB,yBAAyB,EAAC,SAAS,QAAO,CAAC,EACrE,OAAO,2BAA2B,mBAAmB,EACrD,OAAO,SAAS,oBAAoB,EACpC,OAAO,OAAO,MAAM,YAAY;AAC7B,MAAI;AACA,UAAM,IAAI;AAAA,MACN,SAAS,QAAQ;AAAA,MACjB,MAAM,QAAQ;AAAA,MACd,OAAO,QAAQ;AAAA,MACf,KAAK,QAAQ;AAAA,MACb,SAAS,QAAQ;AAAA,MACjB,iBAAiB,QAAQ,MAAM,IAAI;AAAA,MACnC,SAAS;AAAA,MACT,YAAY,QAAQ;AAAA,IACxB,CAAC;AAAA,EACL,SAAS,GAAG;AACR,YAAQ,MAAM,CAAC;AAAA,EACnB;AACJ,CAAC;AAEL,IAAI,QAAQ,gBAAgB,sBAAsB,EAC7C,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,MAAI;AACA,UAAM,IAAI;AAAA,MACN,SAAS,QAAQ;AAAA,MACjB,MAAM,QAAQ;AAAA,MACd,OAAO,QAAQ;AAAA,MACf,KAAK,QAAQ;AAAA,MACb,SAAS,QAAQ;AAAA,MACjB,iBAAiB,QAAQ,MAAM,IAAI;AAAA,MACnC,SAAS;AAAA,MACT,YAAY,QAAQ;AAAA,MACpB,SAAS,QAAQ;AAAA,IACrB,CAAC;AAAA,EACL,SAAS,GAAG;AACR,YAAQ,MAAM,CAAC;AAAA,EACnB;AACJ,CAAC;AAEL,IAAI,QAAQ,OAAO;AACnB,IAAI,KAAK;AACT,IAAI,MAAM;","names":[]}
1
+ {"version":3,"sources":["../../src/cli/index.ts"],"sourcesContent":["import cac from \"cac\";\nimport {consola} from \"consola\";\nimport fs from \"fs\";\n\nimport app from \"./builders/app\";\n\nimport {Command} from \"@typing/app\";\nimport {Browser} from \"@typing/browser\";\n\nconst pkg = fs.readFileSync(new URL(\"../../package.json\", import.meta.url), {encoding: \"utf-8\"});\nconst {name, version} = JSON.parse(pkg);\n\nconst cli = cac(name);\n\ncli.option(\"--debug\", \"Enable debug mode\");\n\ncli.command(\"init\", \"Initialize a new project\").action(() => {\n consola.box(\"Coming soon...\");\n});\n\ncli.command(\"watch [root]\", \"Start watch mode\")\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(\"--mv2\", \"Target manifest v2\")\n .action(async (root, options) => {\n try {\n await app({\n command: Command.Watch,\n mode: options.mode,\n debug: options.debug,\n app: options.app,\n browser: options.browser,\n manifestVersion: options.mv2 ? 2 : 3,\n rootDir: root,\n configFile: options.config,\n });\n } catch (e) {\n consola.error(e);\n process.exitCode = 1;\n }\n });\n\ncli.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 try {\n await app({\n command: Command.Build,\n mode: options.mode,\n debug: options.debug,\n app: options.app,\n browser: options.browser,\n manifestVersion: options.mv2 ? 2 : 3,\n rootDir: root,\n configFile: options.config,\n analyze: options.analyze,\n });\n } catch (e) {\n consola.error(e);\n process.exitCode = 1;\n }\n });\n\ncli.version(version);\ncli.help();\ncli.parse();\n"],"mappings":"AAAA,OAAO,SAAS;AAChB,SAAQ,eAAc;AACtB,OAAO,QAAQ;AAEf,OAAO,SAAS;AAEhB,SAAQ,eAAc;AACtB,SAAQ,eAAc;AAEtB,MAAM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AAI;AAAA,MACN,SAAS,QAAQ;AAAA,MACjB,MAAM,QAAQ;AAAA,MACd,OAAO,QAAQ;AAAA,MACf,KAAK,QAAQ;AAAA,MACb,SAAS,QAAQ;AAAA,MACjB,iBAAiB,QAAQ,MAAM,IAAI;AAAA,MACnC,SAAS;AAAA,MACT,YAAY,QAAQ;AAAA,MACpB,SAAS,QAAQ;AAAA,IACrB,CAAC;AAAA,EACL,SAAS,GAAG;AACR,YAAQ,MAAM,CAAC;AACf,YAAQ,WAAW;AAAA,EACvB;AACJ,CAAC;AAEL,IAAI,QAAQ,OAAO;AACnB,IAAI,KAAK;AACT,IAAI,MAAM;","names":[]}
@@ -1,13 +1,26 @@
1
- import { ContentDriver, ContentItems } from "./types.js";
1
+ import { ContentDriver as ContentDriverContract, ContentItems } from "./types.js";
2
2
  import { AbstractPluginFinder } from "../../entrypoint/index.js";
3
3
  import { ContentScriptEntrypointOptions } from "../../../types/content.js";
4
- import { EntrypointNameGenerator } from "../../../types/entrypoint.js";
5
- export default class<O extends ContentScriptEntrypointOptions> implements ContentDriver<O> {
6
- protected readonly finder: AbstractPluginFinder<O>;
7
- protected _items?: ContentItems<O>;
4
+ import { EntrypointFile, EntrypointNameGenerator, EntrypointOptions } from "../../../types/entrypoint.js";
5
+ import { ManifestOptionalPermissions, ManifestPermissions } from "../../../types/manifest.js";
6
+ /**
7
+ * OutputOptions stays first so existing ContentDriver<O> consumers keep their original meaning.
8
+ * Drivers with a different input shape must override transform().
9
+ */
10
+ export default class<OutputOptions extends ContentScriptEntrypointOptions = ContentScriptEntrypointOptions, InputOptions extends EntrypointOptions = OutputOptions> implements ContentDriverContract<OutputOptions> {
11
+ protected readonly finder: AbstractPluginFinder<InputOptions>;
12
+ protected _options?: Map<EntrypointFile, InputOptions>;
13
+ protected _items?: ContentItems<OutputOptions>;
14
+ protected _permissions?: Promise<[ManifestPermissions, ManifestOptionalPermissions]>;
8
15
  protected readonly itemNames: EntrypointNameGenerator;
9
- constructor(finder: AbstractPluginFinder<O>);
10
- protected getItems(): Promise<ContentItems<O>>;
11
- items(): Promise<ContentItems<O>>;
16
+ constructor(finder: AbstractPluginFinder<InputOptions>);
17
+ protected transform(options: InputOptions): OutputOptions;
18
+ protected getOptions(): Promise<Map<EntrypointFile, InputOptions>>;
19
+ protected getItems(): Promise<ContentItems<OutputOptions>>;
20
+ items(): Promise<ContentItems<OutputOptions>>;
21
+ protected calculatePermissions(): Promise<[ManifestPermissions, ManifestOptionalPermissions]>;
22
+ protected getPermissions(): Promise<[ManifestPermissions, ManifestOptionalPermissions]>;
23
+ permissions(): Promise<ManifestPermissions>;
24
+ optionalPermissions(): Promise<ManifestOptionalPermissions>;
12
25
  clear(): this;
13
26
  }
@@ -5,21 +5,43 @@ class ContentDriver_default {
5
5
  this.itemNames = new InlineNameGenerator(this.finder.type());
6
6
  }
7
7
  finder;
8
+ _options;
8
9
  _items;
10
+ _permissions;
9
11
  itemNames;
12
+ transform(options) {
13
+ return options;
14
+ }
15
+ async getOptions() {
16
+ return this._options ?? (this._options = await this.finder.plugin().options());
17
+ }
10
18
  async getItems() {
11
19
  const items = /* @__PURE__ */ new Map();
12
- const files = await this.finder.plugin().options();
20
+ const files = await this.getOptions();
13
21
  for (const [file, options] of files) {
14
- items.set(this.itemNames.file(file), { file, options });
22
+ items.set(this.itemNames.file(file), { file, options: this.transform(options) });
15
23
  }
16
24
  return items;
17
25
  }
18
26
  async items() {
19
27
  return this._items ?? (this._items = await this.getItems());
20
28
  }
29
+ async calculatePermissions() {
30
+ return [/* @__PURE__ */ new Set(), /* @__PURE__ */ new Set()];
31
+ }
32
+ getPermissions() {
33
+ return this._permissions ?? (this._permissions = this.calculatePermissions());
34
+ }
35
+ async permissions() {
36
+ return (await this.getPermissions())[0];
37
+ }
38
+ async optionalPermissions() {
39
+ return (await this.getPermissions())[1];
40
+ }
21
41
  clear() {
42
+ this._options = void 0;
22
43
  this._items = void 0;
44
+ this._permissions = void 0;
23
45
  this.itemNames.reset();
24
46
  return this;
25
47
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/cli/plugins/content/ContentDriver.ts"],"sourcesContent":["import {ContentDriver, ContentItems} from \"./types\";\n\nimport {AbstractPluginFinder, InlineNameGenerator} from \"@cli/entrypoint/index.js\";\n\nimport {ContentScriptEntrypointOptions} from \"@typing/content\";\nimport {EntrypointNameGenerator} from \"@typing/entrypoint\";\n\nexport default class<O extends ContentScriptEntrypointOptions> implements ContentDriver<O> {\n protected _items?: ContentItems<O>;\n\n protected readonly itemNames: EntrypointNameGenerator;\n\n constructor(protected readonly finder: AbstractPluginFinder<O>) {\n this.itemNames = new InlineNameGenerator(this.finder.type());\n }\n\n protected async getItems(): Promise<ContentItems<O>> {\n const items: ContentItems<O> = new Map();\n\n const files = await this.finder.plugin().options();\n\n for (const [file, options] of files) {\n items.set(this.itemNames.file(file), {file, options});\n }\n\n return items;\n }\n\n public async items(): Promise<ContentItems<O>> {\n return (this._items ??= await this.getItems());\n }\n\n public clear(): this {\n this._items = undefined;\n\n this.itemNames.reset();\n\n return this;\n }\n}\n"],"mappings":"AAEA,SAA8B,2BAA0B;AAKxD,MAAO,sBAAoF;AAAA,EAKvF,YAA+B,QAAiC;AAAjC;AAC3B,SAAK,YAAY,IAAI,oBAAoB,KAAK,OAAO,KAAK,CAAC;AAAA,EAC/D;AAAA,EAF+B;AAAA,EAJrB;AAAA,EAES;AAAA,EAMnB,MAAgB,WAAqC;AACjD,UAAM,QAAyB,oBAAI,IAAI;AAEvC,UAAM,QAAQ,MAAM,KAAK,OAAO,OAAO,EAAE,QAAQ;AAEjD,eAAW,CAAC,MAAM,OAAO,KAAK,OAAO;AACjC,YAAM,IAAI,KAAK,UAAU,KAAK,IAAI,GAAG,EAAC,MAAM,QAAO,CAAC;AAAA,IACxD;AAEA,WAAO;AAAA,EACX;AAAA,EAEA,MAAa,QAAkC;AAC3C,WAAQ,KAAK,WAAL,KAAK,SAAW,MAAM,KAAK,SAAS;AAAA,EAChD;AAAA,EAEO,QAAc;AACjB,SAAK,SAAS;AAEd,SAAK,UAAU,MAAM;AAErB,WAAO;AAAA,EACX;AACJ;","names":[]}
1
+ {"version":3,"sources":["../../../../src/cli/plugins/content/ContentDriver.ts"],"sourcesContent":["import {ContentDriver as ContentDriverContract, ContentItems} from \"./types\";\n\nimport {AbstractPluginFinder, InlineNameGenerator} from \"@cli/entrypoint/index.js\";\n\nimport {ContentScriptEntrypointOptions} from \"@typing/content\";\nimport {EntrypointFile, EntrypointNameGenerator, EntrypointOptions} from \"@typing/entrypoint\";\nimport {ManifestOptionalPermissions, ManifestPermissions} from \"@typing/manifest\";\n\n/**\n * OutputOptions stays first so existing ContentDriver<O> consumers keep their original meaning.\n * Drivers with a different input shape must override transform().\n */\nexport default class<\n OutputOptions extends ContentScriptEntrypointOptions = ContentScriptEntrypointOptions,\n InputOptions extends EntrypointOptions = OutputOptions,\n> implements ContentDriverContract<OutputOptions> {\n protected _options?: Map<EntrypointFile, InputOptions>;\n\n protected _items?: ContentItems<OutputOptions>;\n\n protected _permissions?: Promise<[ManifestPermissions, ManifestOptionalPermissions]>;\n\n protected readonly itemNames: EntrypointNameGenerator;\n\n constructor(protected readonly finder: AbstractPluginFinder<InputOptions>) {\n this.itemNames = new InlineNameGenerator(this.finder.type());\n }\n\n protected transform(options: InputOptions): OutputOptions {\n return options as unknown as OutputOptions;\n }\n\n protected async getOptions(): Promise<Map<EntrypointFile, InputOptions>> {\n return (this._options ??= await this.finder.plugin().options());\n }\n\n protected async getItems(): Promise<ContentItems<OutputOptions>> {\n const items: ContentItems<OutputOptions> = new Map();\n\n const files = await this.getOptions();\n\n for (const [file, options] of files) {\n items.set(this.itemNames.file(file), {file, options: this.transform(options)});\n }\n\n return items;\n }\n\n public async items(): Promise<ContentItems<OutputOptions>> {\n return (this._items ??= await this.getItems());\n }\n\n protected async calculatePermissions(): Promise<[ManifestPermissions, ManifestOptionalPermissions]> {\n return [new Set(), new Set()];\n }\n\n protected getPermissions(): Promise<[ManifestPermissions, ManifestOptionalPermissions]> {\n return (this._permissions ??= this.calculatePermissions());\n }\n\n public async permissions(): Promise<ManifestPermissions> {\n return (await this.getPermissions())[0];\n }\n\n public async optionalPermissions(): Promise<ManifestOptionalPermissions> {\n return (await this.getPermissions())[1];\n }\n\n public clear(): this {\n this._options = undefined;\n this._items = undefined;\n this._permissions = undefined;\n\n this.itemNames.reset();\n\n return this;\n }\n}\n"],"mappings":"AAEA,SAA8B,2BAA0B;AAUxD,MAAO,sBAG2C;AAAA,EAS9C,YAA+B,QAA4C;AAA5C;AAC3B,SAAK,YAAY,IAAI,oBAAoB,KAAK,OAAO,KAAK,CAAC;AAAA,EAC/D;AAAA,EAF+B;AAAA,EARrB;AAAA,EAEA;AAAA,EAEA;AAAA,EAES;AAAA,EAMT,UAAU,SAAsC;AACtD,WAAO;AAAA,EACX;AAAA,EAEA,MAAgB,aAAyD;AACrE,WAAQ,KAAK,aAAL,KAAK,WAAa,MAAM,KAAK,OAAO,OAAO,EAAE,QAAQ;AAAA,EACjE;AAAA,EAEA,MAAgB,WAAiD;AAC7D,UAAM,QAAqC,oBAAI,IAAI;AAEnD,UAAM,QAAQ,MAAM,KAAK,WAAW;AAEpC,eAAW,CAAC,MAAM,OAAO,KAAK,OAAO;AACjC,YAAM,IAAI,KAAK,UAAU,KAAK,IAAI,GAAG,EAAC,MAAM,SAAS,KAAK,UAAU,OAAO,EAAC,CAAC;AAAA,IACjF;AAEA,WAAO;AAAA,EACX;AAAA,EAEA,MAAa,QAA8C;AACvD,WAAQ,KAAK,WAAL,KAAK,SAAW,MAAM,KAAK,SAAS;AAAA,EAChD;AAAA,EAEA,MAAgB,uBAAoF;AAChG,WAAO,CAAC,oBAAI,IAAI,GAAG,oBAAI,IAAI,CAAC;AAAA,EAChC;AAAA,EAEU,iBAA8E;AACpF,WAAQ,KAAK,iBAAL,KAAK,eAAiB,KAAK,qBAAqB;AAAA,EAC5D;AAAA,EAEA,MAAa,cAA4C;AACrD,YAAQ,MAAM,KAAK,eAAe,GAAG,CAAC;AAAA,EAC1C;AAAA,EAEA,MAAa,sBAA4D;AACrE,YAAQ,MAAM,KAAK,eAAe,GAAG,CAAC;AAAA,EAC1C;AAAA,EAEO,QAAc;AACjB,SAAK,WAAW;AAChB,SAAK,SAAS;AACd,SAAK,eAAe;AAEpB,SAAK,UAAU,MAAM;AAErB,WAAO;AAAA,EACX;AACJ;","names":[]}
@@ -3,12 +3,13 @@ import { ContentGroupItems, ContentProvider } from "./types.js";
3
3
  import { ReadonlyConfig } from "../../../types/config.js";
4
4
  import { ContentScriptEntrypointOptions } from "../../../types/content.js";
5
5
  import { EntrypointEntries, EntrypointFile } from "../../../types/entrypoint.js";
6
- import { ManifestContentScripts, ManifestHostPermissions } from "../../../types/manifest.js";
6
+ import { ManifestContentScripts, ManifestHostPermissions, ManifestOptionalPermissions, ManifestPermissions } from "../../../types/manifest.js";
7
7
  export default class {
8
8
  protected readonly providers: Set<ContentProvider<Partial<import("../../../types/content.js").ContentScriptOptions>>>;
9
9
  protected readonly names: ContentName;
10
10
  protected _group?: ContentGroupItems<ContentScriptEntrypointOptions>;
11
- protected _permissions?: [ManifestHostPermissions, ManifestHostPermissions];
11
+ protected _hostPermissions?: [ManifestHostPermissions, ManifestHostPermissions];
12
+ protected _permissions?: Promise<[ManifestPermissions, ManifestOptionalPermissions]>;
12
13
  constructor(config: ReadonlyConfig);
13
14
  provider(provider: ContentProvider<ContentScriptEntrypointOptions>): this;
14
15
  protected getGroup(): Promise<ContentGroupItems<ContentScriptEntrypointOptions>>;
@@ -17,7 +18,11 @@ export default class {
17
18
  manifest(): Promise<ManifestContentScripts>;
18
19
  hostPermissions(): Promise<ManifestHostPermissions>;
19
20
  optionalHostPermissions(): Promise<ManifestHostPermissions>;
20
- protected calculatePermissions(): Promise<[ManifestHostPermissions, ManifestHostPermissions]>;
21
+ protected calculateHostPermissions(): Promise<[ManifestHostPermissions, ManifestHostPermissions]>;
22
+ permissions(): Promise<ManifestPermissions>;
23
+ optionalPermissions(): Promise<ManifestOptionalPermissions>;
24
+ protected getPermissions(): Promise<[ManifestPermissions, ManifestOptionalPermissions]>;
25
+ protected calculatePermissions(): Promise<[ManifestPermissions, ManifestOptionalPermissions]>;
21
26
  virtual(file: EntrypointFile): string;
22
27
  empty(): Promise<boolean>;
23
28
  chunkName(): string;
@@ -6,6 +6,7 @@ class ContentManager_default {
6
6
  providers = /* @__PURE__ */ new Set();
7
7
  names;
8
8
  _group;
9
+ _hostPermissions;
9
10
  _permissions;
10
11
  constructor(config) {
11
12
  this.names = new ContentName(config);
@@ -46,14 +47,14 @@ class ContentManager_default {
46
47
  return manifest;
47
48
  }
48
49
  async hostPermissions() {
49
- return (await this.calculatePermissions())[0];
50
+ return (await this.calculateHostPermissions())[0];
50
51
  }
51
52
  async optionalHostPermissions() {
52
- return (await this.calculatePermissions())[1];
53
+ return (await this.calculateHostPermissions())[1];
53
54
  }
54
- async calculatePermissions() {
55
- if (this._permissions) {
56
- return this._permissions;
55
+ async calculateHostPermissions() {
56
+ if (this._hostPermissions) {
57
+ return this._hostPermissions;
57
58
  }
58
59
  const hostPermissions = /* @__PURE__ */ new Set();
59
60
  const optionalHostPermissions = /* @__PURE__ */ new Set();
@@ -77,7 +78,40 @@ class ContentManager_default {
77
78
  }
78
79
  }
79
80
  }
80
- return this._permissions = [hostPermissions, optionalHostPermissions];
81
+ return this._hostPermissions = [hostPermissions, optionalHostPermissions];
82
+ }
83
+ async permissions() {
84
+ return (await this.getPermissions())[0];
85
+ }
86
+ async optionalPermissions() {
87
+ return (await this.getPermissions())[1];
88
+ }
89
+ getPermissions() {
90
+ return this._permissions ?? (this._permissions = this.calculatePermissions());
91
+ }
92
+ async calculatePermissions() {
93
+ const permissions = /* @__PURE__ */ new Set();
94
+ const optionalPermissions = /* @__PURE__ */ new Set();
95
+ const contributions = await Promise.all(
96
+ Array.from(this.providers, async (provider) => {
97
+ const driver = provider.driver();
98
+ return Promise.all([driver.permissions(), driver.optionalPermissions()]);
99
+ })
100
+ );
101
+ for (const [required, optional] of contributions) {
102
+ for (const permission of required) {
103
+ permissions.add(permission);
104
+ }
105
+ for (const permission of optional) {
106
+ optionalPermissions.add(permission);
107
+ }
108
+ }
109
+ for (const permission of optionalPermissions) {
110
+ if (permissions.has(permission)) {
111
+ optionalPermissions.delete(permission);
112
+ }
113
+ }
114
+ return [permissions, optionalPermissions];
81
115
  }
82
116
  virtual(file) {
83
117
  for (const provider of this.providers) {
@@ -108,6 +142,7 @@ class ContentManager_default {
108
142
  }
109
143
  this.names.reset();
110
144
  this._group = void 0;
145
+ this._hostPermissions = void 0;
111
146
  this._permissions = void 0;
112
147
  return this;
113
148
  }