adnbn 0.14.0 → 0.15.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 (115) hide show
  1. package/dist/cli/builders/app/build.d.ts +7 -0
  2. package/dist/cli/builders/app/build.js +58 -0
  3. package/dist/cli/builders/app/build.js.map +1 -0
  4. package/dist/cli/builders/app/index.d.ts +6 -1
  5. package/dist/cli/builders/app/index.js +49 -14
  6. package/dist/cli/builders/app/index.js.map +1 -1
  7. package/dist/cli/builders/app/{command.d.ts → watch.d.ts} +0 -1
  8. package/dist/cli/builders/app/{command.js → watch.js} +1 -26
  9. package/dist/cli/builders/app/watch.js.map +1 -0
  10. package/dist/cli/builders/manifest/ManifestBase.d.ts +5 -1
  11. package/dist/cli/builders/manifest/ManifestBase.js +16 -0
  12. package/dist/cli/builders/manifest/ManifestBase.js.map +1 -1
  13. package/dist/cli/builders/manifest/ManifestV2.js +3 -15
  14. package/dist/cli/builders/manifest/ManifestV2.js.map +1 -1
  15. package/dist/cli/builders/manifest/ManifestV3.js +3 -15
  16. package/dist/cli/builders/manifest/ManifestV3.js.map +1 -1
  17. package/dist/cli/bundler/plugins/entrypoint/EntrypointPlugin.js +4 -0
  18. package/dist/cli/bundler/plugins/entrypoint/EntrypointPlugin.js.map +1 -1
  19. package/dist/cli/index.js +16 -3
  20. package/dist/cli/index.js.map +1 -1
  21. package/dist/cli/plugins/action.d.ts +2 -0
  22. package/dist/cli/plugins/action.js +13 -0
  23. package/dist/cli/plugins/action.js.map +1 -0
  24. package/dist/cli/plugins/index.d.ts +1 -0
  25. package/dist/cli/plugins/index.js +52 -50
  26. package/dist/cli/plugins/index.js.map +1 -1
  27. package/dist/cli/plugins/offscreen/index.js +2 -4
  28. package/dist/cli/plugins/offscreen/index.js.map +1 -1
  29. package/dist/cli/plugins/style/index.js +34 -31
  30. package/dist/cli/plugins/style/index.js.map +1 -1
  31. package/dist/cli/plugins/style/rebase.d.ts +14 -0
  32. package/dist/cli/plugins/style/rebase.js +63 -0
  33. package/dist/cli/plugins/style/rebase.js.map +1 -0
  34. package/dist/cli/plugins/style/utils.d.ts +5 -1
  35. package/dist/cli/plugins/style/utils.js +21 -8
  36. package/dist/cli/plugins/style/utils.js.map +1 -1
  37. package/dist/cli/plugins/typescript/TypescriptConfig.js +2 -2
  38. package/dist/cli/plugins/typescript/TypescriptConfig.js.map +1 -1
  39. package/dist/cli/resolvers/bundler.js +9 -1
  40. package/dist/cli/resolvers/bundler.js.map +1 -1
  41. package/dist/cli/resolvers/config.js +5 -1
  42. package/dist/cli/resolvers/config.js.map +1 -1
  43. package/dist/cli/utils/path.js +1 -1
  44. package/dist/cli/utils/path.js.map +1 -1
  45. package/dist/entry/relay/Builder.d.ts +4 -3
  46. package/dist/entry/relay/Builder.js.map +1 -1
  47. package/dist/entry/relay/index.d.ts +4 -3
  48. package/dist/entry/relay/index.js.map +1 -1
  49. package/dist/locale/adapters/react/hooks/use-locale.js +1 -1
  50. package/dist/locale/adapters/react/hooks/use-locale.js.map +1 -1
  51. package/dist/locale/adapters/react/hooks/use-native-locale.js +1 -1
  52. package/dist/locale/adapters/react/hooks/use-native-locale.js.map +1 -1
  53. package/dist/locale/index.d.ts +1 -0
  54. package/dist/locale/index.js +3 -1
  55. package/dist/locale/index.js.map +1 -1
  56. package/dist/locale/{providers → observers}/ObservableLocale.js +2 -2
  57. package/dist/locale/observers/ObservableLocale.js.map +1 -0
  58. package/dist/locale/observers/index.d.ts +1 -0
  59. package/dist/locale/observers/index.js +5 -0
  60. package/dist/locale/observers/index.js.map +1 -0
  61. package/dist/locale/providers/index.d.ts +0 -1
  62. package/dist/locale/providers/index.js +1 -3
  63. package/dist/locale/providers/index.js.map +1 -1
  64. package/dist/main/config.d.ts +1 -0
  65. package/dist/main/config.js.map +1 -1
  66. package/dist/main/relay.d.ts +1 -0
  67. package/dist/main/relay.js +2 -0
  68. package/dist/main/relay.js.map +1 -1
  69. package/dist/message/adapters/react/index.d.ts +1 -1
  70. package/dist/message/adapters/react/index.js +1 -1
  71. package/dist/message/adapters/react/index.js.map +1 -1
  72. package/dist/message/adapters/react/{useMessageHandler.js → use-message-handler.js} +6 -4
  73. package/dist/message/adapters/react/use-message-handler.js.map +1 -0
  74. package/dist/message/handlers/MapHandler.js +2 -1
  75. package/dist/message/handlers/MapHandler.js.map +1 -1
  76. package/dist/message/handlers/SingleHandler.js +2 -1
  77. package/dist/message/handlers/SingleHandler.js.map +1 -1
  78. package/dist/message/providers/Message.js +1 -1
  79. package/dist/message/providers/Message.js.map +1 -1
  80. package/dist/relay/RelayPermission.js +8 -2
  81. package/dist/relay/RelayPermission.js.map +1 -1
  82. package/dist/relay/adapters/RelayScriptingAdapter.d.ts +1 -0
  83. package/dist/relay/adapters/RelayScriptingAdapter.js +30 -64
  84. package/dist/relay/adapters/RelayScriptingAdapter.js.map +1 -1
  85. package/dist/relay/adapters/invoke-relay.d.ts +3 -0
  86. package/dist/relay/adapters/invoke-relay.js +69 -0
  87. package/dist/relay/adapters/invoke-relay.js.map +1 -0
  88. package/dist/relay/adapters/scripting-response.d.ts +12 -0
  89. package/dist/relay/adapters/scripting-response.js +1 -0
  90. package/dist/relay/adapters/scripting-response.js.map +1 -0
  91. package/dist/relay/result.d.ts +3 -0
  92. package/dist/relay/result.js +7 -0
  93. package/dist/relay/result.js.map +1 -1
  94. package/dist/types/action.d.ts +8 -0
  95. package/dist/types/action.js +1 -0
  96. package/dist/types/action.js.map +1 -0
  97. package/dist/types/config.d.ts +17 -1
  98. package/dist/types/content/definition.d.ts +2 -1
  99. package/dist/types/manifest.d.ts +3 -0
  100. package/dist/types/manifest.js.map +1 -1
  101. package/dist/types/popup.d.ts +2 -1
  102. package/dist/types/sidebar.d.ts +2 -1
  103. package/dist/types/sidebar.js.map +1 -1
  104. package/package.json +18 -31
  105. package/dist/cli/builders/app/command.js.map +0 -1
  106. package/dist/locale/providers/ObservableLocale.js.map +0 -1
  107. package/dist/message/adapters/react/useMessageHandler.js.map +0 -1
  108. package/scripts/clean-dist.js +0 -7
  109. package/scripts/copy-dts.js +0 -29
  110. package/scripts/merge-coverage.mjs +0 -12
  111. package/scripts/pre-commit.mjs +0 -22
  112. package/scripts/test-inventory.mjs +0 -38
  113. package/scripts/test-run.mjs +0 -25
  114. /package/dist/locale/{providers → observers}/ObservableLocale.d.ts +0 -0
  115. /package/dist/message/adapters/react/{useMessageHandler.d.ts → use-message-handler.d.ts} +0 -0
@@ -11,6 +11,12 @@ class RelayFrameTimeoutError extends Error {
11
11
  }
12
12
  timeoutMs;
13
13
  }
14
+ class RelayProtocolError extends Error {
15
+ constructor(relayName) {
16
+ super(`Relay "${relayName}" returned an invalid scripting response envelope.`);
17
+ this.name = "RelayProtocolError";
18
+ }
19
+ }
14
20
  const fulfilledRelayFrame = (target, result) => ({
15
21
  target,
16
22
  status: "fulfilled",
@@ -78,6 +84,7 @@ const sortRelayFrameResults = (results) => {
78
84
  };
79
85
  export {
80
86
  RelayFrameTimeoutError,
87
+ RelayProtocolError,
81
88
  fulfilledRelayFrame,
82
89
  injectScriptErrorKind,
83
90
  messageErrorKind,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/relay/result.ts"],"sourcesContent":["import {serializeError} from \"@message/error\";\n\nimport {InjectScriptTargetErrorKind} from \"@addon-core/inject-script\";\n\nimport {\n RelayFrameErrorKind,\n type RelayFrameResult,\n type RelayFramesResult,\n type RelayResultTarget,\n} from \"@typing/relay\";\n\nexport class RelayFrameTimeoutError extends Error {\n public constructor(public readonly timeoutMs: number) {\n super(`Relay frame did not respond within ${timeoutMs}ms.`);\n this.name = \"RelayFrameTimeoutError\";\n }\n}\n\nexport const fulfilledRelayFrame = <T>(target: RelayResultTarget, result: T): RelayFrameResult<T> => ({\n target,\n status: \"fulfilled\",\n result,\n});\n\nexport const rejectedRelayFrame = <T>(\n target: RelayResultTarget,\n error: unknown,\n kind: RelayFrameErrorKind\n): RelayFrameResult<T> => ({\n target,\n status: \"rejected\",\n error: {\n kind,\n ...serializeError(error),\n },\n});\n\nexport const messageErrorKind = (error: unknown): RelayFrameErrorKind => {\n const message = error instanceof Error ? error.message : String(error);\n\n if (\n /receiving end does not exist|no matching message handler|frame.*(?:removed|not found)|no frame with id|invalid frame id/i.test(\n message\n )\n ) {\n return RelayFrameErrorKind.TargetGone;\n }\n\n return RelayFrameErrorKind.Delivery;\n};\n\nexport const injectScriptErrorKind = (kind: `${InjectScriptTargetErrorKind}`): RelayFrameErrorKind => {\n switch (kind) {\n case InjectScriptTargetErrorKind.Execution:\n return RelayFrameErrorKind.Execution;\n case InjectScriptTargetErrorKind.Delivery:\n return RelayFrameErrorKind.Delivery;\n case InjectScriptTargetErrorKind.Timeout:\n return RelayFrameErrorKind.Timeout;\n case InjectScriptTargetErrorKind.TargetGone:\n return RelayFrameErrorKind.TargetGone;\n case InjectScriptTargetErrorKind.Unobservable:\n return RelayFrameErrorKind.Unobservable;\n default:\n throw new TypeError(`Unsupported Inject Script target error kind: ${kind}`);\n }\n};\n\nexport const withRelayTimeout = <T>(promise: Promise<T>, timeoutMs?: number): Promise<T> => {\n if (timeoutMs === undefined) {\n return promise;\n }\n\n return new Promise<T>((resolve, reject) => {\n const timeout = setTimeout(() => reject(new RelayFrameTimeoutError(timeoutMs)), timeoutMs);\n\n promise.then(\n result => {\n clearTimeout(timeout);\n resolve(result);\n },\n error => {\n clearTimeout(timeout);\n reject(error);\n }\n );\n });\n};\n\nexport const sortRelayFrameResults = <T>(results: RelayFramesResult<T>): RelayFramesResult<T> => {\n return [...results].sort((a, b) => {\n const frameDifference =\n (a.target.frameId ?? Number.MAX_SAFE_INTEGER) - (b.target.frameId ?? Number.MAX_SAFE_INTEGER);\n\n if (frameDifference !== 0) {\n return frameDifference;\n }\n\n return (a.target.documentId ?? \"\").localeCompare(b.target.documentId ?? \"\");\n });\n};\n"],"mappings":"AAAA,SAAQ,sBAAqB;AAE7B,SAAQ,mCAAkC;AAE1C;AAAA,EACI;AAAA,OAIG;AAEA,MAAM,+BAA+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,WAAS;AACL,qBAAa,OAAO;AACpB,eAAO,KAAK;AAAA,MAChB;AAAA,IACJ;AAAA,EACJ,CAAC;AACL;AAEO,MAAM,wBAAwB,CAAI,YAAwD;AAC7F,SAAO,CAAC,GAAG,OAAO,EAAE,KAAK,CAAC,GAAG,MAAM;AAC/B,UAAM,mBACD,EAAE,OAAO,WAAW,OAAO,qBAAqB,EAAE,OAAO,WAAW,OAAO;AAEhF,QAAI,oBAAoB,GAAG;AACvB,aAAO;AAAA,IACX;AAEA,YAAQ,EAAE,OAAO,cAAc,IAAI,cAAc,EAAE,OAAO,cAAc,EAAE;AAAA,EAC9E,CAAC;AACL;","names":[]}
1
+ {"version":3,"sources":["../../src/relay/result.ts"],"sourcesContent":["import {serializeError} from \"@message/error\";\n\nimport {InjectScriptTargetErrorKind} from \"@addon-core/inject-script\";\n\nimport {\n RelayFrameErrorKind,\n type RelayFrameResult,\n type RelayFramesResult,\n type RelayResultTarget,\n} from \"@typing/relay\";\n\nexport class RelayFrameTimeoutError extends Error {\n public constructor(public readonly timeoutMs: number) {\n super(`Relay frame did not respond within ${timeoutMs}ms.`);\n this.name = \"RelayFrameTimeoutError\";\n }\n}\n\nexport class RelayProtocolError extends Error {\n public constructor(relayName: string) {\n super(`Relay \"${relayName}\" returned an invalid scripting response envelope.`);\n this.name = \"RelayProtocolError\";\n }\n}\n\nexport const fulfilledRelayFrame = <T>(target: RelayResultTarget, result: T): RelayFrameResult<T> => ({\n target,\n status: \"fulfilled\",\n result,\n});\n\nexport const rejectedRelayFrame = <T>(\n target: RelayResultTarget,\n error: unknown,\n kind: RelayFrameErrorKind\n): RelayFrameResult<T> => ({\n target,\n status: \"rejected\",\n error: {\n kind,\n ...serializeError(error),\n },\n});\n\nexport const messageErrorKind = (error: unknown): RelayFrameErrorKind => {\n const message = error instanceof Error ? error.message : String(error);\n\n if (\n /receiving end does not exist|no matching message handler|frame.*(?:removed|not found)|no frame with id|invalid frame id/i.test(\n message\n )\n ) {\n return RelayFrameErrorKind.TargetGone;\n }\n\n return RelayFrameErrorKind.Delivery;\n};\n\nexport const injectScriptErrorKind = (kind: `${InjectScriptTargetErrorKind}`): RelayFrameErrorKind => {\n switch (kind) {\n case InjectScriptTargetErrorKind.Execution:\n return RelayFrameErrorKind.Execution;\n case InjectScriptTargetErrorKind.Delivery:\n return RelayFrameErrorKind.Delivery;\n case InjectScriptTargetErrorKind.Timeout:\n return RelayFrameErrorKind.Timeout;\n case InjectScriptTargetErrorKind.TargetGone:\n return RelayFrameErrorKind.TargetGone;\n case InjectScriptTargetErrorKind.Unobservable:\n return RelayFrameErrorKind.Unobservable;\n default:\n throw new TypeError(`Unsupported Inject Script target error kind: ${kind}`);\n }\n};\n\nexport const withRelayTimeout = <T>(promise: Promise<T>, timeoutMs?: number): Promise<T> => {\n if (timeoutMs === undefined) {\n return promise;\n }\n\n return new Promise<T>((resolve, reject) => {\n const timeout = setTimeout(() => reject(new RelayFrameTimeoutError(timeoutMs)), timeoutMs);\n\n promise.then(\n result => {\n clearTimeout(timeout);\n resolve(result);\n },\n error => {\n clearTimeout(timeout);\n reject(error);\n }\n );\n });\n};\n\nexport const sortRelayFrameResults = <T>(results: RelayFramesResult<T>): RelayFramesResult<T> => {\n return [...results].sort((a, b) => {\n const frameDifference =\n (a.target.frameId ?? Number.MAX_SAFE_INTEGER) - (b.target.frameId ?? Number.MAX_SAFE_INTEGER);\n\n if (frameDifference !== 0) {\n return frameDifference;\n }\n\n return (a.target.documentId ?? \"\").localeCompare(b.target.documentId ?? \"\");\n });\n};\n"],"mappings":"AAAA,SAAQ,sBAAqB;AAE7B,SAAQ,mCAAkC;AAE1C;AAAA,EACI;AAAA,OAIG;AAEA,MAAM,+BAA+B,MAAM;AAAA,EACvC,YAA4B,WAAmB;AAClD,UAAM,sCAAsC,SAAS,KAAK;AAD3B;AAE/B,SAAK,OAAO;AAAA,EAChB;AAAA,EAHmC;AAIvC;AAEO,MAAM,2BAA2B,MAAM;AAAA,EACnC,YAAY,WAAmB;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AAA,IACJ;AAAA,EACJ,CAAC;AACL;AAEO,MAAM,wBAAwB,CAAI,YAAwD;AAC7F,SAAO,CAAC,GAAG,OAAO,EAAE,KAAK,CAAC,GAAG,MAAM;AAC/B,UAAM,mBACD,EAAE,OAAO,WAAW,OAAO,qBAAqB,EAAE,OAAO,WAAW,OAAO;AAEhF,QAAI,oBAAoB,GAAG;AACvB,aAAO;AAAA,IACX;AAEA,YAAQ,EAAE,OAAO,cAAc,IAAI,cAAc,EAAE,OAAO,cAAc,EAAE;AAAA,EAC9E,CAAC;AACL;","names":[]}
@@ -0,0 +1,8 @@
1
+ import type { IconName } from "./icon.js";
2
+ /** Default appearance of the extension's toolbar button. */
3
+ export interface ActionOptions {
4
+ /** Icon group name. Falls back to `config.icon` when omitted. */
5
+ icon?: IconName;
6
+ /** Tooltip text or locale key, such as `@action.title`. Defaults to the extension name. */
7
+ title?: string;
8
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -7,6 +7,7 @@ import { Plugin } from "./plugin.js";
7
7
  import { Language } from "./locale.js";
8
8
  import { Awaiter } from "./helpers.js";
9
9
  import { EnvFilterOptions, EnvFilterVariant } from "./env.js";
10
+ import { ActionOptions } from "./action.js";
10
11
  /**
11
12
  * Configuration options for building a browser extension. This interface defines
12
13
  * all the properties required to customize the build process, extension metadata,
@@ -136,6 +137,18 @@ export interface Config {
136
137
  * - "disable"
137
138
  */
138
139
  icon: string;
140
+ /**
141
+ * Default appearance of the toolbar button (`action` in MV3, `browser_action` in MV2).
142
+ * An explicit object, including `{}`, declares the button without requiring a popup or command.
143
+ * It does not register a click handler.
144
+ *
145
+ * The applied popup overrides each explicitly specified icon/title independently.
146
+ * Missing values fall back to these settings, then to `icon` and the extension name.
147
+ * When omitted, only an applied popup or execute-action command declares the button.
148
+ *
149
+ * @example {icon: "active", title: "@action.title"}
150
+ */
151
+ action?: ActionOptions;
139
152
  /**
140
153
  * Browser-specific settings (populate manifest.browser_specific_settings).
141
154
  *
@@ -405,7 +418,10 @@ export interface Config {
405
418
  concatContentScripts: boolean;
406
419
  /**
407
420
  * Flag indicating whether to merge styles from App and Shared directories.
408
- * When `true`, styles from both directories will be combined.
421
+ * When `true`, importing a shared stylesheet also compiles the app stylesheet at the same
422
+ * relative path into the same CSS module, with shared rules before app rules. Relative `@use`
423
+ * and `@forward` requests and literal `url(...)` values in the merged sources resolve from the
424
+ * file that declares them.
409
425
  *
410
426
  * @default true
411
427
  */
@@ -1,6 +1,6 @@
1
1
  import type { ContentScriptPrepareHandler } from "./prepare.js";
2
2
  import type { ContentScriptBoundaryHandler } from "./boundary.js";
3
- import type { ContentScriptAnchor, ContentScriptAnchorGetter, ContentScriptAppend, ContentScriptContainerCreator, ContentScriptContainerFactory, ContentScriptContainerOptions, ContentScriptContainerTag, ContentScriptFramePageOptions, ContentScriptFrameRenderOptions, ContentScriptFrameSourceOptions, ContentScriptIsolation, ContentScriptIsolationFrameOptions, ContentScriptIsolationOptions, ContentScriptIsolationShadowOptions, ContentScriptMainFunction, ContentScriptMarkerGetter, ContentScriptMarkerResolver, ContentScriptMarkerType, ContentScriptMountFunction, ContentScriptOptions, ContentScriptWatchStrategy } from "./common.js";
3
+ import type { ContentScriptAnchor, ContentScriptAnchorGetter, ContentScriptBuilder, ContentScriptAppend, ContentScriptContainerCreator, ContentScriptContainerFactory, ContentScriptContainerOptions, ContentScriptContainerTag, ContentScriptFramePageOptions, ContentScriptFrameRenderOptions, ContentScriptFrameSourceOptions, ContentScriptIsolation, ContentScriptIsolationFrameOptions, ContentScriptIsolationOptions, ContentScriptIsolationShadowOptions, ContentScriptMainFunction, ContentScriptMarkerGetter, ContentScriptMarkerResolver, ContentScriptMarkerType, ContentScriptMountFunction, ContentScriptOptions, ContentScriptWatchStrategy } from "./common.js";
4
4
  import type { ContentScriptRenderHandler, ContentScriptRenderValue } from "./render.js";
5
5
  import type { ContentScriptTarget, ContentScriptTargetCreator } from "./target.js";
6
6
  export interface ContentScriptDefinitionBase<Data = unknown> extends Partial<ContentScriptOptions> {
@@ -50,6 +50,7 @@ export type ContentScriptRenderDefinition<Data = unknown, Isolation extends `${C
50
50
  isolation: unknown;
51
51
  });
52
52
  export type ContentScriptDefinition<Data = unknown, Isolation extends `${ContentScriptIsolation}` = `${ContentScriptIsolation}`> = ContentScriptDefinitionBase<Data> & ContentScriptRenderDefinition<Data, Isolation>;
53
+ export type ContentScriptBuilderConstructor<Data = unknown, Isolation extends `${ContentScriptIsolation}` = `${ContentScriptIsolation}`> = new (definition: ContentScriptDefinition<Data, NoInfer<Isolation>>) => ContentScriptBuilder;
53
54
  export interface ContentScriptResolvedDefinition<Data = unknown> extends Omit<ContentScriptDefinitionBase<Data>, "anchor" | "marker" | "mount" | "container" | "watch"> {
54
55
  isolation: ContentScriptIsolationOptions;
55
56
  boundary?: ContentScriptBoundaryHandler<Data>;
@@ -5,6 +5,7 @@ import { Language } from "./locale.js";
5
5
  import { BrowserSpecific, DataCollectionPermission } from "./browser.js";
6
6
  import { CspConfig } from "./csp.js";
7
7
  import { SandboxCspConfig } from "./sandbox.js";
8
+ import { ActionOptions } from "./action.js";
8
9
  export declare const ManifestMatchSchemes: ReadonlySet<string>;
9
10
  export declare const ManifestSpecialSchemes: ReadonlySet<string>;
10
11
  export declare enum ManifestIncognito {
@@ -16,6 +17,7 @@ type ManifestCommon = chrome.runtime.Manifest;
16
17
  type ManifestBase = chrome.runtime.ManifestBase;
17
18
  export type ManifestPermission = chrome.runtime.ManifestPermission;
18
19
  export type ManifestOptionalPermission = chrome.runtime.ManifestOptionalPermission;
20
+ export type ManifestAction = NonNullable<chrome.runtime.ManifestV3["action"]>;
19
21
  type ManifestFixed<T extends ManifestBase> = Omit<T, "manifest_version"> & {
20
22
  manifest_version: ManifestVersion;
21
23
  };
@@ -78,6 +80,7 @@ export interface ManifestBuilder<T extends CoreManifest = Manifest> {
78
80
  mergeSpecific(settings: BrowserSpecific): this;
79
81
  setIcons(icons?: ManifestIcons): this;
80
82
  setIcon(icon?: string): this;
83
+ setAction(action?: ActionOptions): this;
81
84
  setBackground(background?: ManifestBackground): this;
82
85
  setCommands(commands?: ManifestCommands): this;
83
86
  setContentScripts(contentScripts?: ManifestContentScripts): this;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/manifest.ts"],"sourcesContent":["import {ContentScriptConfig} from \"@typing/content\";\nimport {BackgroundConfig} from \"@typing/background\";\nimport {CommandConfig} from \"@typing/command\";\nimport {Language} from \"@typing/locale\";\nimport {BrowserSpecific, DataCollectionPermission} from \"@typing/browser\";\nimport {CspConfig} from \"@typing/csp\";\nimport {SandboxCspConfig} from \"@typing/sandbox\";\n\nexport const ManifestMatchSchemes: ReadonlySet<string> = new Set<string>([\"http\", \"https\", \"file\", \"ftp\", \"ws\", \"wss\"]);\n\nexport const ManifestSpecialSchemes: ReadonlySet<string> = new Set<string>([\n \"chrome-extension\",\n \"moz-extension\",\n \"data\",\n \"blob\",\n \"filesystem\",\n \"about\",\n \"chrome\",\n \"resource\",\n]);\n\nexport enum ManifestIncognito {\n Spanning = \"spanning\",\n Split = \"split\",\n NotAllowed = \"not_allowed\",\n}\n\ntype ManifestCommon = chrome.runtime.Manifest;\n\ntype ManifestBase = chrome.runtime.ManifestBase;\n\nexport type ManifestPermission = chrome.runtime.ManifestPermission;\n\nexport type ManifestOptionalPermission = chrome.runtime.ManifestOptionalPermission;\n\ntype ManifestFixed<T extends ManifestBase> = Omit<T, \"manifest_version\"> & {\n manifest_version: ManifestVersion;\n};\n\ninterface ManifestUnstable {\n permissions?: (ManifestPermission | (string & Record<never, never>))[];\n web_accessible_resources?: string[] | chrome.runtime.ManifestV3[\"web_accessible_resources\"];\n}\n\nexport type ManifestVersion = 2 | 3;\n\nexport type ManifestIncognitoValue = ManifestIncognito | `${ManifestIncognito}`;\n\nexport type CoreManifest = ManifestFixed<ManifestBase>;\n\nexport type ChromeManifest = ManifestFixed<ManifestCommon>;\n\nexport type FirefoxManifest = ChromeManifest & {\n action?: chrome.runtime.ManifestV3[\"action\"] & {\n browser_style?: boolean;\n };\n browser_action?: chrome.runtime.ManifestV2[\"browser_action\"] & {\n browser_style?: boolean;\n };\n page_action?: chrome.runtime.ManifestV2[\"page_action\"] & {\n browser_style?: boolean;\n };\n browser_specific_settings?: {\n gecko?: {\n id?: string;\n strict_min_version?: string;\n strict_max_version?: string;\n update_url?: string;\n data_collection_permissions?: {\n required?: [\"none\"] | `${DataCollectionPermission}`[];\n optional?: `${DataCollectionPermission}`[];\n };\n };\n gecko_android?: {\n strict_min_version?: string;\n strict_max_version?: string;\n };\n };\n} & ManifestUnstable;\n\nexport type SafariManifest = ChromeManifest & {\n browser_specific_settings?: {\n safari?: {\n strict_min_version?: string;\n strict_max_version?: string;\n };\n };\n} & ManifestUnstable;\n\nexport type Manifest = ChromeManifest | FirefoxManifest | SafariManifest;\n\nexport type OptionalManifest = Partial<Omit<Manifest, \"manifest_version\">>;\n\nexport interface ManifestBuilder<T extends CoreManifest = Manifest> {\n setName(name: string): this;\n\n setShortName(shortName?: string): this;\n\n setDescription(description?: string): this;\n\n setAuthor(author?: string): this;\n\n setHomepage(homepage?: string): this;\n\n setVersion(version?: string): this;\n\n setIncognito(incognito?: ManifestIncognitoValue): this;\n\n setMinimumVersion(minimumVersion?: string): this;\n\n setLocale(lang?: Language): this;\n\n // Specific settings\n setSpecific(settings?: BrowserSpecific): this;\n\n mergeSpecific(settings: BrowserSpecific): this;\n\n // Icons\n setIcons(icons?: ManifestIcons): this;\n\n setIcon(icon?: string): this; // name of an icon set for manifest.icons\n\n // Entry\n setBackground(background?: ManifestBackground): this;\n\n setCommands(commands?: ManifestCommands): this;\n\n setContentScripts(contentScripts?: ManifestContentScripts): this;\n\n setPopup(popup?: ManifestPopup): this;\n\n setSidebar(sidebar?: ManifestSidebar): this;\n\n setOptions(options?: ManifestOptions): this;\n\n setOverride(override?: ManifestOverride): this;\n\n // Sandbox\n addSandbox(sandbox: ManifestSandbox): this;\n\n appendSandboxes(sandboxes: Iterable<ManifestSandbox>): this;\n\n addSandboxCsp(csp: SandboxCspConfig): this;\n\n appendSandboxCsp(csps: Iterable<SandboxCspConfig>): this;\n\n // Content Security Policy\n addCsp(csp: CspConfig): this;\n\n appendCsp(csps: Iterable<CspConfig>): this;\n\n // System\n setDependencies(dependencies: ManifestDependencies): this;\n\n // Permissions\n addPermission(permission: ManifestPermission): this;\n\n setPermissions(permissions: ManifestPermissions): this;\n\n appendPermissions(permissions: ManifestPermissions): this;\n\n // Optional Permissions\n addOptionalPermission(permission: ManifestOptionalPermission): this;\n\n setOptionalPermissions(permissions: ManifestOptionalPermissions): this;\n\n appendOptionalPermissions(permissions: ManifestOptionalPermissions): this;\n\n // Host Permissions\n addHostPermission(permission: string): this;\n\n setHostPermissions(permissions: ManifestHostPermissions): this;\n\n appendHostPermissions(permissions: ManifestHostPermissions): this;\n\n // Optional Host Permissions\n addOptionalHostPermission(permission: string): this;\n\n setOptionalHostPermissions(permissions: ManifestHostPermissions): this;\n\n appendOptionalHostPermissions(permissions: ManifestHostPermissions): this;\n\n // Web Accessible Resource\n setAccessibleResource(accessibleResources: ManifestAccessibleResources): this;\n\n appendAccessibleResources(accessibleResources: ManifestAccessibleResources): this;\n\n addAccessibleResource(accessibleResource: ManifestAccessibleResource): this;\n\n getWebAccessibleResources(): ManifestAccessibleResource[];\n\n // Getter\n get(): T;\n\n raw(manifest: OptionalManifest): this;\n}\n\ntype Entry = string;\n\nexport interface ManifestEntry {\n entry: Entry;\n}\n\nexport type ManifestBackground = ManifestEntry & BackgroundConfig;\n\nexport type ManifestContentScript = ManifestEntry & ContentScriptConfig;\n\nexport type ManifestContentScripts = Set<ManifestContentScript>;\n\nexport type ManifestCommand = CommandConfig;\n\nexport type ManifestCommands = Set<ManifestCommand>;\n\nexport interface ManifestPopup {\n /**\n * Represents the group name of an icon that can be used in UI elements.\n * This property is optional and, if defined, should typically refer to a string\n * that matches the name of an icon resource available in the application or icon library.\n */\n icon?: string;\n /**\n * Represents an optional title or name or locale key that can be assigned to an entity.\n */\n title?: string;\n /**\n * Represents an optional HTML path.\n */\n path?: string;\n}\n\nexport interface ManifestSidebar {\n /**\n * Represents the group name of an icon that can be used in UI elements.\n * This property is optional and, if defined, should typically refer to a string\n * that matches the name of an icon resource available in the application or icon library.\n */\n icon?: string;\n /**\n * Represents an optional title or name or locale key that can be assigned to an entity.\n */\n title?: string;\n /**\n * Represents an optional HTML path.\n */\n path?: string;\n}\n\nexport interface ManifestOptions {\n /**\n * Path to the options page HTML file relative to the extension root.\n * Written to `options_ui.page` in the manifest.\n */\n path: string;\n /**\n * Whether the options page should open in a browser tab.\n * Written to `options_ui.open_in_tab` and defaults to `true` when omitted.\n * Set to `false` to request an embedded page where supported by the browser.\n */\n openInTab?: boolean;\n}\n\nexport type ManifestOverridePage = \"newtab\" | \"bookmarks\" | \"history\";\n\n/**\n * Chromium refuses to load an extension that overrides more than one page and other browsers\n * only support `newtab`, so the manifest holds a single override instead of a dictionary.\n */\nexport interface ManifestOverride {\n /**\n * Built-in browser page replaced by the extension.\n * Written as the key of `chrome_url_overrides` in the manifest.\n */\n page: ManifestOverridePage;\n /**\n * Path to the replacement HTML file relative to the extension root.\n * Written as the value of `chrome_url_overrides[page]`.\n */\n path: string;\n}\n\nexport interface ManifestAccessibleResource {\n resources: string[];\n matches?: string[];\n extensionIds?: string[];\n useDynamicUrl?: boolean;\n}\n\nexport type ManifestAccessibleResources = Set<ManifestAccessibleResource>;\n\nexport type ManifestSandbox = string;\n\nexport type ManifestSandboxes = Set<ManifestSandbox>;\n\nexport interface ManifestDependency {\n /** Initial scripts, in execution order. */\n js: Set<string>;\n /** Initial styles delivered by the manifest. */\n css: Set<string>;\n /** Runtime resources, including lazy JS/CSS and other emitted files. */\n assets: Set<string>;\n}\n\nexport type ManifestIcon = Map<number, string>;\n\nexport type ManifestIcons = Map<string, ManifestIcon>;\n\nexport type ManifestDependencies = Map<Entry, ManifestDependency>;\n\nexport type ManifestPermissions = Set<ManifestPermission>;\n\nexport type ManifestOptionalPermissions = Set<ManifestOptionalPermission>;\n\nexport type ManifestHostPermissions = Set<string>;\n"],"mappings":"AAQO,MAAM,uBAA4C,oBAAI,IAAY,CAAC,QAAQ,SAAS,QAAQ,OAAO,MAAM,KAAK,CAAC;AAE/G,MAAM,yBAA8C,oBAAI,IAAY;AAAA,EACvE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,CAAC;AAEM,IAAK,oBAAL,kBAAKA,uBAAL;AACH,EAAAA,mBAAA,cAAW;AACX,EAAAA,mBAAA,WAAQ;AACR,EAAAA,mBAAA,gBAAa;AAHL,SAAAA;AAAA,GAAA;","names":["ManifestIncognito"]}
1
+ {"version":3,"sources":["../../src/types/manifest.ts"],"sourcesContent":["import {ContentScriptConfig} from \"@typing/content\";\nimport {BackgroundConfig} from \"@typing/background\";\nimport {CommandConfig} from \"@typing/command\";\nimport {Language} from \"@typing/locale\";\nimport {BrowserSpecific, DataCollectionPermission} from \"@typing/browser\";\nimport {CspConfig} from \"@typing/csp\";\nimport {SandboxCspConfig} from \"@typing/sandbox\";\nimport {ActionOptions} from \"@typing/action\";\n\nexport const ManifestMatchSchemes: ReadonlySet<string> = new Set<string>([\"http\", \"https\", \"file\", \"ftp\", \"ws\", \"wss\"]);\n\nexport const ManifestSpecialSchemes: ReadonlySet<string> = new Set<string>([\n \"chrome-extension\",\n \"moz-extension\",\n \"data\",\n \"blob\",\n \"filesystem\",\n \"about\",\n \"chrome\",\n \"resource\",\n]);\n\nexport enum ManifestIncognito {\n Spanning = \"spanning\",\n Split = \"split\",\n NotAllowed = \"not_allowed\",\n}\n\ntype ManifestCommon = chrome.runtime.Manifest;\n\ntype ManifestBase = chrome.runtime.ManifestBase;\n\nexport type ManifestPermission = chrome.runtime.ManifestPermission;\n\nexport type ManifestOptionalPermission = chrome.runtime.ManifestOptionalPermission;\n\nexport type ManifestAction = NonNullable<chrome.runtime.ManifestV3[\"action\"]>;\n\ntype ManifestFixed<T extends ManifestBase> = Omit<T, \"manifest_version\"> & {\n manifest_version: ManifestVersion;\n};\n\ninterface ManifestUnstable {\n permissions?: (ManifestPermission | (string & Record<never, never>))[];\n web_accessible_resources?: string[] | chrome.runtime.ManifestV3[\"web_accessible_resources\"];\n}\n\nexport type ManifestVersion = 2 | 3;\n\nexport type ManifestIncognitoValue = ManifestIncognito | `${ManifestIncognito}`;\n\nexport type CoreManifest = ManifestFixed<ManifestBase>;\n\nexport type ChromeManifest = ManifestFixed<ManifestCommon>;\n\nexport type FirefoxManifest = ChromeManifest & {\n action?: chrome.runtime.ManifestV3[\"action\"] & {\n browser_style?: boolean;\n };\n browser_action?: chrome.runtime.ManifestV2[\"browser_action\"] & {\n browser_style?: boolean;\n };\n page_action?: chrome.runtime.ManifestV2[\"page_action\"] & {\n browser_style?: boolean;\n };\n browser_specific_settings?: {\n gecko?: {\n id?: string;\n strict_min_version?: string;\n strict_max_version?: string;\n update_url?: string;\n data_collection_permissions?: {\n required?: [\"none\"] | `${DataCollectionPermission}`[];\n optional?: `${DataCollectionPermission}`[];\n };\n };\n gecko_android?: {\n strict_min_version?: string;\n strict_max_version?: string;\n };\n };\n} & ManifestUnstable;\n\nexport type SafariManifest = ChromeManifest & {\n browser_specific_settings?: {\n safari?: {\n strict_min_version?: string;\n strict_max_version?: string;\n };\n };\n} & ManifestUnstable;\n\nexport type Manifest = ChromeManifest | FirefoxManifest | SafariManifest;\n\nexport type OptionalManifest = Partial<Omit<Manifest, \"manifest_version\">>;\n\nexport interface ManifestBuilder<T extends CoreManifest = Manifest> {\n setName(name: string): this;\n\n setShortName(shortName?: string): this;\n\n setDescription(description?: string): this;\n\n setAuthor(author?: string): this;\n\n setHomepage(homepage?: string): this;\n\n setVersion(version?: string): this;\n\n setIncognito(incognito?: ManifestIncognitoValue): this;\n\n setMinimumVersion(minimumVersion?: string): this;\n\n setLocale(lang?: Language): this;\n\n // Specific settings\n setSpecific(settings?: BrowserSpecific): this;\n\n mergeSpecific(settings: BrowserSpecific): this;\n\n // Icons\n setIcons(icons?: ManifestIcons): this;\n\n setIcon(icon?: string): this; // name of an icon set for manifest.icons\n\n // Toolbar button\n setAction(action?: ActionOptions): this;\n\n // Entry\n setBackground(background?: ManifestBackground): this;\n\n setCommands(commands?: ManifestCommands): this;\n\n setContentScripts(contentScripts?: ManifestContentScripts): this;\n\n setPopup(popup?: ManifestPopup): this;\n\n setSidebar(sidebar?: ManifestSidebar): this;\n\n setOptions(options?: ManifestOptions): this;\n\n setOverride(override?: ManifestOverride): this;\n\n // Sandbox\n addSandbox(sandbox: ManifestSandbox): this;\n\n appendSandboxes(sandboxes: Iterable<ManifestSandbox>): this;\n\n addSandboxCsp(csp: SandboxCspConfig): this;\n\n appendSandboxCsp(csps: Iterable<SandboxCspConfig>): this;\n\n // Content Security Policy\n addCsp(csp: CspConfig): this;\n\n appendCsp(csps: Iterable<CspConfig>): this;\n\n // System\n setDependencies(dependencies: ManifestDependencies): this;\n\n // Permissions\n addPermission(permission: ManifestPermission): this;\n\n setPermissions(permissions: ManifestPermissions): this;\n\n appendPermissions(permissions: ManifestPermissions): this;\n\n // Optional Permissions\n addOptionalPermission(permission: ManifestOptionalPermission): this;\n\n setOptionalPermissions(permissions: ManifestOptionalPermissions): this;\n\n appendOptionalPermissions(permissions: ManifestOptionalPermissions): this;\n\n // Host Permissions\n addHostPermission(permission: string): this;\n\n setHostPermissions(permissions: ManifestHostPermissions): this;\n\n appendHostPermissions(permissions: ManifestHostPermissions): this;\n\n // Optional Host Permissions\n addOptionalHostPermission(permission: string): this;\n\n setOptionalHostPermissions(permissions: ManifestHostPermissions): this;\n\n appendOptionalHostPermissions(permissions: ManifestHostPermissions): this;\n\n // Web Accessible Resource\n setAccessibleResource(accessibleResources: ManifestAccessibleResources): this;\n\n appendAccessibleResources(accessibleResources: ManifestAccessibleResources): this;\n\n addAccessibleResource(accessibleResource: ManifestAccessibleResource): this;\n\n getWebAccessibleResources(): ManifestAccessibleResource[];\n\n // Getter\n get(): T;\n\n raw(manifest: OptionalManifest): this;\n}\n\ntype Entry = string;\n\nexport interface ManifestEntry {\n entry: Entry;\n}\n\nexport type ManifestBackground = ManifestEntry & BackgroundConfig;\n\nexport type ManifestContentScript = ManifestEntry & ContentScriptConfig;\n\nexport type ManifestContentScripts = Set<ManifestContentScript>;\n\nexport type ManifestCommand = CommandConfig;\n\nexport type ManifestCommands = Set<ManifestCommand>;\n\nexport interface ManifestPopup {\n /**\n * Represents the group name of an icon that can be used in UI elements.\n * This property is optional and, if defined, should typically refer to a string\n * that matches the name of an icon resource available in the application or icon library.\n */\n icon?: string;\n /**\n * Represents an optional title or name or locale key that can be assigned to an entity.\n */\n title?: string;\n /**\n * Represents an optional HTML path.\n */\n path?: string;\n}\n\nexport interface ManifestSidebar {\n /**\n * Represents the group name of an icon that can be used in UI elements.\n * This property is optional and, if defined, should typically refer to a string\n * that matches the name of an icon resource available in the application or icon library.\n */\n icon?: string;\n /**\n * Represents an optional title or name or locale key that can be assigned to an entity.\n */\n title?: string;\n /**\n * Represents an optional HTML path.\n */\n path?: string;\n}\n\nexport interface ManifestOptions {\n /**\n * Path to the options page HTML file relative to the extension root.\n * Written to `options_ui.page` in the manifest.\n */\n path: string;\n /**\n * Whether the options page should open in a browser tab.\n * Written to `options_ui.open_in_tab` and defaults to `true` when omitted.\n * Set to `false` to request an embedded page where supported by the browser.\n */\n openInTab?: boolean;\n}\n\nexport type ManifestOverridePage = \"newtab\" | \"bookmarks\" | \"history\";\n\n/**\n * Chromium refuses to load an extension that overrides more than one page and other browsers\n * only support `newtab`, so the manifest holds a single override instead of a dictionary.\n */\nexport interface ManifestOverride {\n /**\n * Built-in browser page replaced by the extension.\n * Written as the key of `chrome_url_overrides` in the manifest.\n */\n page: ManifestOverridePage;\n /**\n * Path to the replacement HTML file relative to the extension root.\n * Written as the value of `chrome_url_overrides[page]`.\n */\n path: string;\n}\n\nexport interface ManifestAccessibleResource {\n resources: string[];\n matches?: string[];\n extensionIds?: string[];\n useDynamicUrl?: boolean;\n}\n\nexport type ManifestAccessibleResources = Set<ManifestAccessibleResource>;\n\nexport type ManifestSandbox = string;\n\nexport type ManifestSandboxes = Set<ManifestSandbox>;\n\nexport interface ManifestDependency {\n /** Initial scripts, in execution order. */\n js: Set<string>;\n /** Initial styles delivered by the manifest. */\n css: Set<string>;\n /** Runtime resources, including lazy JS/CSS and other emitted files. */\n assets: Set<string>;\n}\n\nexport type ManifestIcon = Map<number, string>;\n\nexport type ManifestIcons = Map<string, ManifestIcon>;\n\nexport type ManifestDependencies = Map<Entry, ManifestDependency>;\n\nexport type ManifestPermissions = Set<ManifestPermission>;\n\nexport type ManifestOptionalPermissions = Set<ManifestOptionalPermission>;\n\nexport type ManifestHostPermissions = Set<string>;\n"],"mappings":"AASO,MAAM,uBAA4C,oBAAI,IAAY,CAAC,QAAQ,SAAS,QAAQ,OAAO,MAAM,KAAK,CAAC;AAE/G,MAAM,yBAA8C,oBAAI,IAAY;AAAA,EACvE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,CAAC;AAEM,IAAK,oBAAL,kBAAKA,uBAAL;AACH,EAAAA,mBAAA,cAAW;AACX,EAAAA,mBAAA,WAAQ;AACR,EAAAA,mBAAA,gBAAa;AAHL,SAAAA;AAAA,GAAA;","names":["ManifestIncognito"]}
@@ -2,6 +2,7 @@ import { ViewDefinition, ViewOptions } from "./view/index.js";
2
2
  import { CspOptions } from "./csp.js";
3
3
  import { PermissionsOptions } from "./permissions.js";
4
4
  import type { ManifestPopup } from "./manifest.js";
5
+ import type { IconName } from "./icon.js";
5
6
  /**
6
7
  * Empty because popup aliases depend on the consuming application's entrypoints.
7
8
  * Generated `.adnbn/popup.d.ts` declarations augment `adnbn`, adding discovered aliases as keys with value `true`.
@@ -11,7 +12,7 @@ export interface PopupAliasRegistry {
11
12
  export type PopupAlias = keyof PopupAliasRegistry extends never ? string : Extract<keyof PopupAliasRegistry, string>;
12
13
  export type PopupMap = Map<PopupAlias, ManifestPopup>;
13
14
  export interface PopupConfig {
14
- icon?: string;
15
+ icon?: IconName;
15
16
  apply?: boolean;
16
17
  }
17
18
  export type PopupEntrypointOptions = PopupConfig & PermissionsOptions & CspOptions & ViewOptions;
@@ -3,6 +3,7 @@ import { Browser } from "./browser.js";
3
3
  import { CspOptions } from "./csp.js";
4
4
  import { PermissionsOptions } from "./permissions.js";
5
5
  import type { ManifestSidebar } from "./manifest.js";
6
+ import type { IconName } from "./icon.js";
6
7
  export declare const SidebarAlternativeBrowsers: ReadonlySet<Browser>;
7
8
  /**
8
9
  * Empty because sidebar aliases depend on the consuming application's entrypoints.
@@ -13,7 +14,7 @@ export interface SidebarAliasRegistry {
13
14
  export type SidebarAlias = keyof SidebarAliasRegistry extends never ? string : Extract<keyof SidebarAliasRegistry, string>;
14
15
  export type SidebarMap = Map<SidebarAlias, ManifestSidebar>;
15
16
  export interface SidebarConfig {
16
- icon?: string;
17
+ icon?: IconName;
17
18
  apply?: boolean;
18
19
  }
19
20
  export type SidebarEntrypointOptions = SidebarConfig & PermissionsOptions & CspOptions & ViewOptions;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/sidebar.ts"],"sourcesContent":["import {ViewDefinition, ViewOptions} from \"@typing/view\";\nimport {Browser} from \"@typing/browser\";\nimport {CspOptions} from \"@typing/csp\";\nimport {PermissionsOptions} from \"@typing/permissions\";\nimport type {ManifestSidebar} from \"@typing/manifest\";\n\nexport const SidebarAlternativeBrowsers: ReadonlySet<Browser> = new Set([Browser.Opera, Browser.Firefox]);\n\n/**\n * Empty because sidebar aliases depend on the consuming application's entrypoints.\n * Generated `.adnbn/sidebar.d.ts` declarations augment `adnbn`, adding discovered aliases as keys with value `true`.\n */\nexport interface SidebarAliasRegistry {}\n\nexport type SidebarAlias = keyof SidebarAliasRegistry extends never\n ? string\n : Extract<keyof SidebarAliasRegistry, string>;\n\nexport type SidebarMap = Map<SidebarAlias, ManifestSidebar>;\n\nexport interface SidebarConfig {\n icon?: string;\n apply?: boolean;\n}\n\nexport type SidebarEntrypointOptions = SidebarConfig & PermissionsOptions & CspOptions & ViewOptions;\n\nexport type SidebarProps = SidebarEntrypointOptions;\n\nexport type SidebarDefinition = SidebarEntrypointOptions & ViewDefinition<SidebarProps>;\n"],"mappings":"AACA,SAAQ,eAAc;AAKf,MAAM,6BAAmD,oBAAI,IAAI,CAAC,QAAQ,OAAO,QAAQ,OAAO,CAAC;","names":[]}
1
+ {"version":3,"sources":["../../src/types/sidebar.ts"],"sourcesContent":["import {ViewDefinition, ViewOptions} from \"@typing/view\";\nimport {Browser} from \"@typing/browser\";\nimport {CspOptions} from \"@typing/csp\";\nimport {PermissionsOptions} from \"@typing/permissions\";\nimport type {ManifestSidebar} from \"@typing/manifest\";\nimport type {IconName} from \"@typing/icon\";\n\nexport const SidebarAlternativeBrowsers: ReadonlySet<Browser> = new Set([Browser.Opera, Browser.Firefox]);\n\n/**\n * Empty because sidebar aliases depend on the consuming application's entrypoints.\n * Generated `.adnbn/sidebar.d.ts` declarations augment `adnbn`, adding discovered aliases as keys with value `true`.\n */\nexport interface SidebarAliasRegistry {}\n\nexport type SidebarAlias = keyof SidebarAliasRegistry extends never\n ? string\n : Extract<keyof SidebarAliasRegistry, string>;\n\nexport type SidebarMap = Map<SidebarAlias, ManifestSidebar>;\n\nexport interface SidebarConfig {\n icon?: IconName;\n apply?: boolean;\n}\n\nexport type SidebarEntrypointOptions = SidebarConfig & PermissionsOptions & CspOptions & ViewOptions;\n\nexport type SidebarProps = SidebarEntrypointOptions;\n\nexport type SidebarDefinition = SidebarEntrypointOptions & ViewDefinition<SidebarProps>;\n"],"mappings":"AACA,SAAQ,eAAc;AAMf,MAAM,6BAAmD,oBAAI,IAAI,CAAC,QAAQ,OAAO,QAAQ,OAAO,CAAC;","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "adnbn",
3
3
  "type": "module",
4
- "version": "0.14.0",
4
+ "version": "0.15.0",
5
5
  "description": "Addon Bone - Cross-browser web extension framework with shared code base",
6
6
  "homepage": "https://addonbone.com",
7
7
  "author": "Anjey Tsibylskij (https://github.com/atldays)",
@@ -31,9 +31,9 @@
31
31
  "module": "./dist/index.js",
32
32
  "types": "./dist/index.d.ts",
33
33
  "files": [
34
- "bin",
34
+ "bin/adnbn.js",
35
35
  "dist",
36
- "scripts",
36
+ "scripts/check-node-version.js",
37
37
  "types"
38
38
  ],
39
39
  "engines": {
@@ -114,39 +114,28 @@
114
114
  "prepublishOnly": "npm run build",
115
115
  "build": "node ./scripts/clean-dist.js && tsup && tsc -p tsconfig.build.json && node ./scripts/copy-dts.js && tsc-alias -p tsconfig.build.json -f -fe .js",
116
116
  "format": "prettier --write .",
117
- "typecheck": "tsc -p tsconfig.json --noEmit",
118
- "prepare:integration": "npm run build && tsx tests/integration/prepare.ts",
119
- "typecheck:integration": "npm run build && tsx tests/integration/typecheck.ts --prepare",
120
- "test:integration": "npm run build && node scripts/test-run.mjs --selectProjects build types chrome firefox",
121
- "test:integration:build": "npm run test:build --",
117
+ "check": "tsx tests/check.ts",
122
118
  "check:node-version": "node ./scripts/check-node-version.js",
119
+ "typecheck": "tsc -p tsconfig.json --noEmit",
120
+ "typecheck:fixtures": "npm run build && tsx tests/integration/typecheck.ts --prepare",
121
+ "fixtures:prepare": "npm run build && tsx tests/integration/prepare.ts",
123
122
  "test": "npm run build && node scripts/test-run.mjs",
124
- "test:ci": "npm run test -- --ci --coverage",
125
- "test:ci:non-browser": "npm run test -- --ci --coverage --selectProjects unit-node unit-dom build types",
126
- "test:watch": "node scripts/test-run.mjs --selectProjects unit-node unit-dom --watch",
127
- "test:offscreen": "node scripts/test-run.mjs --testPathPatterns=Offscreen",
128
- "test:chrome": "npm run build && node scripts/test-run.mjs --selectProjects chrome",
129
- "test:firefox": "npm run build && node scripts/test-run.mjs --selectProjects firefox",
130
- "test:message": "node scripts/test-run.mjs --testPathPatterns=src/message",
131
- "test:service": "node scripts/test-run.mjs --testPathPatterns=Service",
132
- "test:relay": "npm run test -- --testPathPatterns=Relay",
133
- "test:locale": "npm run test -- --testPathPatterns=Locale",
134
- "test:manifest": "node scripts/test-run.mjs --testPathPatterns=src/cli/builders/manifest",
135
- "test:entrypoint": "node scripts/test-run.mjs --testPathPatterns=src/cli/entrypoint",
136
- "test:plugins": "npm run test -- --testPathPatterns=src/cli/plugins",
137
- "release": "release-it",
138
- "release:preview": "release-it --no-github.release --no-npm.publish --no-git.tag --ci",
139
123
  "test:unit": "node scripts/test-run.mjs --selectProjects unit-node unit-dom --verbose=false",
140
- "test:build": "npm run build && node scripts/test-run.mjs --selectProjects build",
141
- "test:types": "npm run typecheck:integration && node scripts/test-run.mjs --selectProjects types",
124
+ "test:watch": "node scripts/test-run.mjs --selectProjects unit-node unit-dom --watch",
125
+ "test:build": "npm run build && node scripts/test-run.mjs --selectProjects build --verbose=false",
126
+ "test:types": "npm run build && node scripts/test-run.mjs --selectProjects types --verbose=false",
127
+ "test:browser": "npm run build && node scripts/test-run.mjs --selectProjects chrome firefox --verbose=false",
128
+ "test:browser:chrome": "npm run build && node scripts/test-run.mjs --selectProjects chrome --verbose=false",
129
+ "test:browser:firefox": "npm run build && node scripts/test-run.mjs --selectProjects firefox --verbose=false",
142
130
  "test:inventory": "node scripts/test-inventory.mjs",
143
- "test:pre-push": "tsx tests/pre-push.ts",
144
- "test:run": "node scripts/test-run.mjs"
131
+ "test:run": "node scripts/test-run.mjs",
132
+ "release": "release-it",
133
+ "release:preview": "release-it --release-version --dry-run --no-git.requireBranch --no-git.requireCleanWorkingDir --no-git.push --no-github.release --no-npm.publish --ci && release-it --changelog --dry-run --no-git.requireBranch --no-git.requireCleanWorkingDir --no-git.push --no-github.release --no-npm.publish --ci"
145
134
  },
146
135
  "dependencies": {
147
- "@addon-core/browser": "^0.7.2",
136
+ "@addon-core/browser": "^0.9.0",
148
137
  "@addon-core/inject-script": "^0.5.0",
149
- "@addon-core/storage": "^0.7.0",
138
+ "@addon-core/storage": "^0.8.0",
150
139
  "@rsdoctor/rspack-plugin": "^1.5.1",
151
140
  "@rspack/cli": "^1.7.5",
152
141
  "@rspack/core": "^1.7.5",
@@ -172,7 +161,6 @@
172
161
  "sass": "^1.83.4",
173
162
  "sass-loader": "^16.0.4",
174
163
  "semver": "^7.7.3",
175
- "source-modifier-loader": "^1.0.2",
176
164
  "tsconfig-paths": "^4.2.0",
177
165
  "type-fest": "^4.37.0",
178
166
  "typescript": "^5.7.3",
@@ -212,7 +200,6 @@
212
200
  "istanbul-reports": "^3.2.0",
213
201
  "jest": "^30.2.0",
214
202
  "jest-environment-jsdom": "^30.0.0",
215
- "jest-webextension-mock": "^4.0.0",
216
203
  "prettier": "^3.6.2",
217
204
  "react": "^19.2.8",
218
205
  "react-dom": "^19.2.8",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/cli/builders/app/command.ts"],"sourcesContent":["import {Compiler} from \"@rspack/core\";\n\nexport const build = (compiler: Compiler) => {\n compiler.run((err, stats) => {\n if (err) {\n console.error(\"Rspack compilation error:\", err);\n process.exit(1);\n }\n\n if (stats?.hasErrors()) {\n console.error(\n stats.toString({\n colors: true,\n errors: true,\n })\n );\n\n process.exit(1);\n }\n\n console.log(stats?.toString({colors: true}));\n\n compiler.close(closeErr => {\n if (closeErr) {\n console.error(\"Rspack close error:\", closeErr);\n process.exit(1);\n }\n });\n });\n};\n\nexport const watch = (compiler: Compiler) => {\n const watching = compiler.watch(\n {\n aggregateTimeout: 300,\n ignored: /node_modules/,\n },\n (err, stats) => {\n if (err) {\n console.error(\"Rspack watch error:\", err);\n process.exit(1);\n }\n\n if (stats?.hasErrors()) {\n console.error(\n stats.toString({\n colors: true,\n errors: true,\n })\n );\n\n return;\n }\n\n console.log(stats?.toString({colors: true}));\n }\n );\n\n process.on(\"SIGINT\", () => {\n watching.close(() => {\n console.log(\"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":3,"sources":["../../../src/locale/providers/ObservableLocale.ts"],"sourcesContent":["import DynamicLocale from \"./DynamicLocale\";\nimport CustomLocale from \"./CustomLocale\";\n\nimport {LocaleStorage} from \"../storage\";\n\nimport type {\n Language,\n LocaleDynamicProvider,\n LocaleNonPluralKeys,\n LocalePluralKeys,\n LocaleRegistry,\n LocaleSnapshot,\n LocaleStorageDriver,\n LocaleSubstitutionArgs,\n LocaleSubstitutionValue,\n} from \"@typing/locale\";\n\n/** Dynamic translations with shared instances and subscriptions independent of any UI framework. */\nexport default class ObservableLocale<T extends object = LocaleRegistry> implements LocaleDynamicProvider<T> {\n private static defaultInstance?: ObservableLocale;\n private static memoryInstance?: ObservableLocale;\n\n private static readonly drivers = new WeakMap<LocaleStorageDriver, ObservableLocale>();\n\n public static getInstance(storage?: LocaleStorageDriver | false): ObservableLocale {\n if (typeof storage === \"object\") {\n let instance = this.drivers.get(storage);\n\n if (!instance) {\n instance = new ObservableLocale(storage);\n this.drivers.set(storage, instance);\n }\n\n return instance;\n }\n\n if (storage === false) {\n return (this.memoryInstance ??= new ObservableLocale(false));\n }\n\n return (this.defaultInstance ??= new ObservableLocale());\n }\n\n private readonly locale = new DynamicLocale<T>(false);\n private readonly storage?: LocaleStorageDriver;\n private readonly listeners = new Set<() => void>();\n private readonly languages: ReadonlySet<Language>;\n private readonly languageNames: ReadonlyMap<Language, string>;\n private currentSnapshot: LocaleSnapshot<T>;\n private revision = 0;\n private writes: Promise<void> = Promise.resolve();\n private pendingWrites = 0;\n private unsubscribe?: () => void;\n\n constructor(storage?: LocaleStorageDriver | false) {\n this.storage = storage === false ? undefined : (storage ?? new LocaleStorage());\n this.languages = this.langs();\n this.languageNames = this.langNames();\n this.currentSnapshot = this.createSnapshot();\n }\n\n public lang(): Language {\n return this.locale.lang();\n }\n\n public langs(): ReadonlySet<Language> {\n return this.locale.langs();\n }\n\n public langNames(): ReadonlyMap<Language, string> {\n return this.locale.langNames();\n }\n\n public keys(): Set<keyof T> {\n return this.locale.keys();\n }\n\n public get<K extends keyof T & string>(key: K, substitutions?: Record<string, LocaleSubstitutionValue>): string {\n return this.locale.get(key, substitutions);\n }\n\n public trans<K extends LocaleNonPluralKeys<T>>(key: K, ...args: LocaleSubstitutionArgs<T, K>): string {\n return this.locale.trans(key, ...args);\n }\n\n public choice<K extends LocalePluralKeys<T>>(key: K, count: number, ...args: LocaleSubstitutionArgs<T, K>): string {\n return this.locale.choice(key, count, ...args);\n }\n\n public readonly snapshot = (): LocaleSnapshot<T> => this.currentSnapshot;\n\n public readonly subscribe = (listener: () => void): (() => void) => {\n // Each subscription owns its cleanup, even when the same callback is subscribed twice.\n const notify = () => listener();\n\n this.listeners.add(notify);\n\n try {\n this.connect();\n } catch (error) {\n this.listeners.delete(notify);\n throw error;\n }\n\n if (this.listeners.size === 1) {\n void this.refresh();\n }\n\n return () => {\n this.listeners.delete(notify);\n this.disconnect();\n };\n };\n\n public readonly change = async (lang: Language): Promise<Language> => {\n this.locale.select(lang);\n\n const storage = this.storage;\n\n if (!storage) {\n this.publish();\n return lang;\n }\n\n this.revision++;\n\n // Register persistence before notifying: a subscriber may select another language immediately.\n this.pendingWrites++;\n\n const saved = this.writes.then(() => storage.set(lang));\n\n this.writes = saved.catch(() => undefined);\n\n this.publish();\n\n let succeeded = false;\n\n try {\n await saved;\n succeeded = true;\n\n return lang;\n } finally {\n if (--this.pendingWrites === 0 && succeeded) {\n void this.refresh();\n }\n }\n };\n\n public async sync(): Promise<Language> {\n if (!this.storage) {\n throw new Error(\"Language is not saving in storage\");\n }\n\n if (this.pendingWrites) {\n return this.lang();\n }\n\n const revision = ++this.revision;\n const lang = await this.storage.get();\n\n if (revision !== this.revision || this.pendingWrites) {\n return this.lang();\n }\n\n if (lang === undefined) {\n return this.lang();\n }\n\n if (!this.langs().has(lang)) {\n console.warn(`Incorrect language code in storage - \"${lang}\"`);\n\n return this.lang();\n }\n\n this.locale.select(lang);\n\n this.publish();\n\n return this.lang();\n }\n\n private connect(): void {\n if (!this.storage || this.unsubscribe) {\n return;\n }\n\n this.unsubscribe = this.storage.watch(() => {\n void this.refresh();\n });\n }\n\n private disconnect(): void {\n if (this.listeners.size) {\n return;\n }\n\n this.revision++;\n\n this.unsubscribe?.();\n this.unsubscribe = undefined;\n }\n\n private async refresh(): Promise<void> {\n if (!this.storage || this.pendingWrites) {\n return;\n }\n\n try {\n await this.sync();\n } catch (error) {\n console.error(\"[ObservableLocale] Cannot synchronize language:\", error);\n }\n }\n\n private createSnapshot(): LocaleSnapshot<T> {\n const lang = this.lang();\n const langs = this.languages;\n const langNames = this.languageNames;\n\n const reader = new CustomLocale<T>(lang, this.locale.messages());\n\n return Object.freeze({\n lang: () => lang,\n langs: () => langs,\n langNames: () => langNames,\n get: reader.get.bind(reader),\n });\n }\n\n private publish(): void {\n if (this.currentSnapshot.lang() === this.lang()) {\n return;\n }\n\n this.currentSnapshot = this.createSnapshot();\n\n for (const listener of [...this.listeners]) {\n try {\n listener();\n } catch (error) {\n console.error(\"[ObservableLocale] Language subscriber failed:\", error);\n }\n }\n }\n}\n"],"mappings":"AAAA,OAAO,mBAAmB;AAC1B,OAAO,kBAAkB;AAEzB,SAAQ,qBAAoB;AAe5B,MAAO,iBAAsG;AAAA,EACzG,OAAe;AAAA,EACf,OAAe;AAAA,EAEf,OAAwB,UAAU,oBAAI,QAA+C;AAAA,EAErF,OAAc,YAAY,SAAyD;AAC/E,QAAI,OAAO,YAAY,UAAU;AAC7B,UAAI,WAAW,KAAK,QAAQ,IAAI,OAAO;AAEvC,UAAI,CAAC,UAAU;AACX,mBAAW,IAAI,iBAAiB,OAAO;AACvC,aAAK,QAAQ,IAAI,SAAS,QAAQ;AAAA,MACtC;AAEA,aAAO;AAAA,IACX;AAEA,QAAI,YAAY,OAAO;AACnB,aAAQ,KAAK,mBAAL,KAAK,iBAAmB,IAAI,iBAAiB,KAAK;AAAA,IAC9D;AAEA,WAAQ,KAAK,oBAAL,KAAK,kBAAoB,IAAI,iBAAiB;AAAA,EAC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K,WAAW,KAAK,aAAa;AACnC;AAAA,IACJ;AAEA,SAAK,cAAc,KAAK,QAAQ,MAAM,MAAM;AACxC,WAAK,KAAK,QAAQ;AAAA,IACtB,CAAC;AAAA,EACL;AAAA,EAEQ,aAAmB;AAhM/B;AAiMQ,QAAI,KAAK,UAAU,MAAM;AACrB;AAAA,IACJ;AAEA,SAAK;AAEL,eAAK,gBAAL;AACA,SAAK,cAAc;AAAA,EACvB;AAAA,EAEA,MAAc,UAAyB;AACnC,QAAI,CAAC,KAAK,WAAW,KAAK,eAAe;AACrC;AAAA,IACJ;AAEA,QAAI;AACA,YAAM,KAAK,KAAK;AAAA,IACpB,SAAS,OAAO;AACZ,cAAQ,MAAM,mDAAmD,KAAK;AAAA,IAC1E;AAAA,EACJ;AAAA,EAEQ,iBAAoC;AACxC,UAAM,OAAO,KAAK,KAAK;AACvB,UAAM,QAAQ,KAAK;AACnB,UAAM,YAAY,KAAK;AAEvB,UAAM,SAAS,IAAI,aAAgB,MAAM,KAAK,OAAO,SAAS,CAAC;AAE/D,WAAO,OAAO,OAAO;AAAA,MACjB,MAAM,MAAM;AAAA,MACZ,OAAO,MAAM;AAAA,MACb,WAAW,MAAM;AAAA,MACjB,KAAK,OAAO,IAAI,KAAK,MAAM;AAAA,IAC/B,CAAC;AAAA,EACL;AAAA,EAEQ,UAAgB;AACpB,QAAI,KAAK,gBAAgB,KAAK,MAAM,KAAK,KAAK,GAAG;AAC7C;AAAA,IACJ;AAEA,SAAK,kBAAkB,KAAK,eAAe;AAE3C,eAAW,YAAY,CAAC,GAAG,KAAK,SAAS,GAAG;AACxC,UAAI;AACA,iBAAS;AAAA,MACb,SAAS,OAAO;AACZ,gBAAQ,MAAM,kDAAkD,KAAK;AAAA,MACzE;AAAA,IACJ;AAAA,EACJ;AACJ;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/message/adapters/react/useMessageHandler.ts"],"sourcesContent":["import {useCallback, useEffect, useRef} from \"react\";\nimport {MessageDictionary, MessageTargetHandler, MessageType} from \"@typing/message\";\n\nimport {Message} from \"@message/providers\";\n\nexport default function useMessageHandler<K extends MessageType<T>, T extends MessageDictionary = MessageDictionary>(\n type: K,\n handler: MessageTargetHandler<T, K>\n): void {\n const messageRef = useRef<Message<T> | null>(null);\n\n if (!messageRef.current) {\n messageRef.current = Message.getInstance<T>();\n }\n\n const handlerRef = useRef(handler);\n handlerRef.current = handler;\n\n const stableWrapper = useCallback<MessageTargetHandler<T, K>>((data, sender) => {\n return handlerRef.current(data, sender);\n }, []);\n\n useEffect(() => {\n return messageRef.current!.watch(type, stableWrapper);\n }, [type, stableWrapper]);\n}\n"],"mappings":"AAAA,SAAQ,aAAa,WAAW,cAAa;AAG7C,SAAQ,eAAc;AAEP,SAAR,kBACH,MACA,SACI;AACJ,QAAM,aAAa,OAA0B,IAAI;AAEjD,MAAI,CAAC,WAAW,SAAS;AACrB,eAAW,UAAU,QAAQ,YAAe;AAAA,EAChD;AAEA,QAAM,aAAa,OAAO,OAAO;AACjC,aAAW,UAAU;AAErB,QAAM,gBAAgB,YAAwC,CAAC,MAAM,WAAW;AAC5E,WAAO,WAAW,QAAQ,MAAM,MAAM;AAAA,EAC1C,GAAG,CAAC,CAAC;AAEL,YAAU,MAAM;AACZ,WAAO,WAAW,QAAS,MAAM,MAAM,aAAa;AAAA,EACxD,GAAG,CAAC,MAAM,aAAa,CAAC;AAC5B;","names":[]}
@@ -1,7 +0,0 @@
1
- import {rm} from "fs/promises";
2
- import {dirname, join} from "path";
3
- import {fileURLToPath} from "url";
4
-
5
- const __dirname = dirname(fileURLToPath(import.meta.url));
6
-
7
- await rm(join(__dirname, "..", "dist"), {force: true, recursive: true});
@@ -1,29 +0,0 @@
1
- import {globby} from "globby";
2
- import {cp, mkdir} from "fs/promises";
3
- import {dirname, join, relative} from "path";
4
- import {fileURLToPath} from "url";
5
-
6
- const __dirname = dirname(fileURLToPath(import.meta.url));
7
- const root = join(__dirname, "..");
8
- const distRoot = join(root, "dist");
9
-
10
- const files = await globby(
11
- [
12
- "src/**/*.d.ts",
13
- "!src/**/tests/**/*",
14
- "!src/**/__tests__/**/*",
15
- "!src/**/__mocks__/**/*",
16
- "!src/**/*.test.d.ts",
17
- "!src/**/*.spec.d.ts",
18
- ],
19
- {cwd: root, dot: true}
20
- );
21
-
22
- for (const file of files) {
23
- const rel = relative("src", file);
24
- const dest = join(distRoot, rel);
25
- await mkdir(dirname(dest), {recursive: true});
26
- await cp(join(root, file), dest, {force: true, recursive: false});
27
- }
28
-
29
- console.log(`DTS Copied ${files.length} .d.ts files to dist`);
@@ -1,12 +0,0 @@
1
- import {readFile} from "node:fs/promises";
2
- import path from "node:path";
3
- import coverage from "istanbul-lib-coverage";
4
- import report from "istanbul-lib-report";
5
- import reports from "istanbul-reports";
6
-
7
- const files = process.argv.slice(2);
8
- if (files.length < 2) throw new Error("Pass the unit and build coverage-final.json files");
9
- const map = coverage.createCoverageMap({});
10
- for (const file of files) map.merge(JSON.parse(await readFile(file, "utf8")));
11
- const context = report.createContext({dir: path.resolve("coverage/merged"), coverageMap: map});
12
- for (const format of ["json", "lcov", "text-summary"]) reports.create(format).execute(context);
@@ -1,22 +0,0 @@
1
- import {execFileSync} from "node:child_process";
2
- import path from "node:path";
3
- import * as prettier from "prettier";
4
-
5
- const root = path.resolve(import.meta.dirname, "..");
6
- const git = args => execFileSync("git", args, {cwd: root, encoding: "utf8"});
7
- const changed = git(["diff", "--cached", "--name-only", "--diff-filter=ACMR", "-z"]).split("\0").filter(Boolean);
8
- const unformatted = [];
9
-
10
- for (const file of changed) {
11
- const filepath = path.join(root, file);
12
- const info = await prettier.getFileInfo(filepath, {ignorePath: path.join(root, ".prettierignore")});
13
- if (info.ignored || !info.inferredParser) continue;
14
- // Check the staged contents; never rewrite unstaged work or silently stage it.
15
- const contents = git(["show", `:${file}`]);
16
- if (!(await prettier.check(contents, {...(await prettier.resolveConfig(filepath)), filepath})))
17
- unformatted.push(file);
18
- }
19
- if (unformatted.length) {
20
- console.error(`Format and stage these files before committing:\n${unformatted.join("\n")}`);
21
- process.exit(1);
22
- }
@@ -1,38 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import {execFile} from "node:child_process";
3
- import {existsSync} from "node:fs";
4
- import path from "node:path";
5
- import {promisify} from "node:util";
6
-
7
- const execute = promisify(execFile);
8
- const root = path.resolve(import.meta.dirname, "..");
9
- const jest = path.join(root, "scripts/test-run.mjs");
10
- const options = {cwd: root, maxBuffer: 10 * 1024 * 1024};
11
- const {stdout: configuration} = await execute(process.execPath, [jest, "--showConfig"], options);
12
- const projects = JSON.parse(configuration).configs.map(config => config.displayName.name);
13
- const {stdout: tracked} = await execute(
14
- "git",
15
- ["ls-files", "--cached", "--others", "--exclude-standard", "-z"],
16
- options
17
- );
18
- const expected = new Set(
19
- tracked.split("\0").filter(file => file.endsWith(".test.ts") && existsSync(path.join(root, file)))
20
- );
21
- const owners = new Map();
22
-
23
- for (const project of projects) {
24
- const {stdout} = await execute(
25
- process.execPath,
26
- [jest, "--selectProjects", project, "--listTests", "--json", "--runInBand"],
27
- options
28
- );
29
- const files = JSON.parse(stdout);
30
- console.info(`${project}: ${files.length} files`);
31
- for (const filename of files) {
32
- const file = path.relative(root, filename).split(path.sep).join("/");
33
- assert(!owners.has(file), `${file} belongs to both ${owners.get(file)} and ${project}`);
34
- owners.set(file, project);
35
- }
36
- }
37
- assert.deepEqual(new Set(owners.keys()), expected, "Every test file must belong to exactly one Jest project");
38
- console.info(`${expected.size} test files, each in exactly one project`);
@@ -1,25 +0,0 @@
1
- import {spawn} from "node:child_process";
2
- import {constants} from "node:os";
3
- import path from "node:path";
4
-
5
- const root = path.resolve(import.meta.dirname, "..");
6
- // Keep the workaround scoped to the environment where this project reproduces nodejs/node#62393.
7
- const flags = process.platform === "darwin" && process.arch === "arm64" ? ["--no-sparkplug"] : [];
8
- const child = spawn(
9
- process.execPath,
10
- [...flags, path.join(root, "node_modules/jest/bin/jest.js"), ...process.argv.slice(2)],
11
- {stdio: "inherit"}
12
- );
13
-
14
- const forward = signal => child.kill(signal);
15
- const signals = ["SIGINT", "SIGTERM", "SIGHUP"];
16
- for (const signal of signals) process.on(signal, forward);
17
- child.once("error", error => {
18
- console.error(error);
19
- process.exitCode = 1;
20
- });
21
- child.once("close", (code, signal) => {
22
- for (const signal of signals) process.off(signal, forward);
23
- if (signal) console.error(`Jest terminated with ${signal}`);
24
- process.exitCode = code ?? (signal ? 128 + constants.signals[signal] : 1);
25
- });