@opentray/webpack-plugin 0.15.0 → 0.17.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.
package/README.md CHANGED
@@ -28,3 +28,8 @@ own tray lifecycle, sessions, backend selection, or extension dispatch.
28
28
  `compiler.options.mode`. `entry` is inferred from the webpack entry config (string,
29
29
  array, `{ main }`, or an entry map). Pass `outDir`, `mode`, or `entry` in the
30
30
  plugin options to override them.
31
+
32
+ `openTrayAppBundlePlugin()` is the Darwin `afterEmit` adapter for the shared
33
+ bundle contract. It defaults to `<compiler.options.output.path>/<appName>.app`
34
+ and accepts the same broker, template, target, and optional `appIcon` inputs as
35
+ the bundler-neutral generator.
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { OpenTrayArtifactInput, OpenTrayPackageManifest, OpenTrayPackageResult, OpenTrayPackagingApp } from "@opentray/packaging";
1
+ import { DarwinAppBundleOptions, OpenTrayArtifactInput, OpenTrayDarwinAppBundleResult, OpenTrayPackageManifest, OpenTrayPackageResult, OpenTrayPackagingApp } from "@opentray/packaging";
2
2
 
3
3
  //#region src/index.d.ts
4
4
  interface OpenTrayWebpackPluginOptions {
@@ -53,8 +53,18 @@ interface OpenTrayWebpackPlugin {
53
53
  /** Returns the last staging result. Only populated after `afterEmit` runs. */
54
54
  readonly getLastResult: () => OpenTrayPackageResult | undefined;
55
55
  }
56
+ interface OpenTrayWebpackAppBundlePluginOptions extends Omit<DarwinAppBundleOptions, "bundlePath" | "reinitialize"> {
57
+ readonly bundlePath?: string;
58
+ }
59
+ interface OpenTrayWebpackAppBundlePlugin {
60
+ readonly name: "opentray-app-bundle";
61
+ apply(compiler: WebpackCompilerLike): void;
62
+ readonly getLastResult: () => OpenTrayDarwinAppBundleResult | undefined;
63
+ }
64
+ /** webpack lifecycle adapter for the shared Darwin app bundle contract. */
65
+ declare const openTrayAppBundlePlugin: (options: OpenTrayWebpackAppBundlePluginOptions) => OpenTrayWebpackAppBundlePlugin;
56
66
  declare const openTrayWebpackPlugin: (options: OpenTrayWebpackPluginOptions) => OpenTrayWebpackPlugin;
57
67
  declare const resolveWebpackEntry: (entry: WebpackEntryLike | WebpackEntryStaticLike | undefined) => string;
58
68
  //#endregion
59
- export { type OpenTrayPackageManifest, type OpenTrayPackageResult, OpenTrayWebpackPlugin, OpenTrayWebpackPluginOptions, WebpackCompilationLike, WebpackCompilerLike, WebpackEntryLike, WebpackEntryStaticLike, WebpackOptionsLike, WebpackOutputLike, WebpackTapableHook, openTrayWebpackPlugin, resolveWebpackEntry };
69
+ export { type OpenTrayPackageManifest, type OpenTrayPackageResult, OpenTrayWebpackAppBundlePlugin, OpenTrayWebpackAppBundlePluginOptions, OpenTrayWebpackPlugin, OpenTrayWebpackPluginOptions, WebpackCompilationLike, WebpackCompilerLike, WebpackEntryLike, WebpackEntryStaticLike, WebpackOptionsLike, WebpackOutputLike, WebpackTapableHook, openTrayAppBundlePlugin, openTrayWebpackPlugin, resolveWebpackEntry };
60
70
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;UAQiB,4BAAA;EAAA,SACN,GAAA,EAAK,oBAAA;EAAA,SACL,WAAA,EAAa,qBAAA;EAAA,SACb,eAAA,GAAkB,QAAA,CAAS,MAAA,SAAe,qBAAA;EAAA,SAC1C,eAAA,GAAkB,QAAA,CAAS,MAAA,SAAe,qBAAA;EAAA,SAC1C,KAAA;EAAA,SACA,YAAA;EAH0C;;;;EAAA,SAQ1C,MAAA;EAPkB;;;;EAAA,SAYlB,IAAA;AAAA;;;;;UAOM,iBAAA;EAAA,SACN,IAAI;AAAA;AAAA,UAGE,sBAAA;EAAA,SACN,IAAI;AAAA;AAAA,KAGH,gBAAA,gCAAgD,QAAQ,CAAC,MAAA;AAAA,UAEpD,kBAAA;EAAA,SACN,IAAA;EAAA,SACA,MAAA,GAAS,iBAAA;EAAA,SACT,KAAA,GAA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AAAA,UAGrB,kBAAA;EACf,QAAA,CACE,IAAA,UACA,QAAA,GAAW,KAAA,EAAO,CAAA,EAAG,QAAA,GAAW,KAAA,GAAQ,KAAK;AAAA;AAAA,UAIhC,mBAAA;EAAA,SACN,OAAA,EAAS,kBAAA;EAAA,SACT,KAAA;IAAA,SACE,SAAA,EAAW,kBAAA,CAAmB,sBAAA;EAAA;AAAA;AAAA,UAI1B,qBAAA;EAAA,SACN,IAAA;EACT,KAAA,CAAM,QAAA,EAAU,mBAAA;EA1BiB;EAAA,SA4BxB,aAAA,QAAqB,qBAAqB;AAAA;AAAA,UAGpC,qCAAA,SACP,IAAI,CAAC,sBAAA;EAAA,SACJ,UAAA;AAAA;AAAA,UAGM,8BAAA;EAAA,SACN,IAAA;EACT,KAAA,CAAM,QAAA,EAAU,mBAAA;EAAA,SACP,aAAA,QAAqB,6BAA6B;AAAA;;cAIhD,uBAAA,GACX,OAAA,EAAS,qCAAA,KACR,8BAkBF;AAAA,cAEY,qBAAA,GACX,OAAA,EAAS,4BAAA,KACR,qBAgCF;AAAA,cAqBY,mBAAA,GACX,KAAA,EAAO,gBAAA,GAAmB,sBAAsB"}
package/dist/index.mjs CHANGED
@@ -1,5 +1,29 @@
1
- import { stageOpenTrayPackage } from "@opentray/packaging";
1
+ import { join } from "node:path";
2
+ import { buildDarwinAppBundle, stageOpenTrayPackage } from "@opentray/packaging";
2
3
  //#region src/index.ts
4
+ /** webpack lifecycle adapter for the shared Darwin app bundle contract. */
5
+ const openTrayAppBundlePlugin = (options) => {
6
+ let lastResult;
7
+ return {
8
+ name: "opentray-app-bundle",
9
+ apply(compiler) {
10
+ compiler.hooks.afterEmit.tapAsync("OpenTrayAppBundlePlugin", async (_compilation, cb) => {
11
+ try {
12
+ const outputDir = compiler.options.output?.path ?? process.cwd();
13
+ const bundlePath = options.bundlePath ?? join(outputDir, `${options.appName}.app`);
14
+ lastResult = await buildDarwinAppBundle({
15
+ ...options,
16
+ bundlePath
17
+ });
18
+ cb();
19
+ } catch (error) {
20
+ cb(error);
21
+ }
22
+ });
23
+ },
24
+ getLastResult: () => lastResult
25
+ };
26
+ };
3
27
  const openTrayWebpackPlugin = (options) => {
4
28
  let lastResult;
5
29
  return {
@@ -72,6 +96,6 @@ const resolveWebpackEntry = (entry) => {
72
96
  throw missing();
73
97
  };
74
98
  //#endregion
75
- export { openTrayWebpackPlugin, resolveWebpackEntry };
99
+ export { openTrayAppBundlePlugin, openTrayWebpackPlugin, resolveWebpackEntry };
76
100
 
77
101
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["record"],"sources":["../src/index.ts"],"sourcesContent":["import {\n stageOpenTrayPackage,\n type OpenTrayArtifactInput,\n type OpenTrayPackagingApp,\n type OpenTrayPackageManifest,\n type OpenTrayPackageResult,\n} from \"@opentray/packaging\";\n\nexport interface OpenTrayWebpackPluginOptions {\n readonly app: OpenTrayPackagingApp;\n readonly runtimeHost: OpenTrayArtifactInput;\n readonly nativeArtifacts?: Readonly<Record<string, OpenTrayArtifactInput>>;\n readonly companionAssets?: Readonly<Record<string, OpenTrayArtifactInput>>;\n readonly entry?: string;\n readonly manifestPath?: string;\n /**\n * Explicit outDir override. When omitted, resolved from\n * `compiler.options.output.path`.\n */\n readonly outDir?: string;\n /**\n * Explicit mode override. When omitted, resolved from\n * `compiler.options.mode` or defaults to `production`.\n */\n readonly mode?: string;\n}\n\n/**\n * Structural view of the webpack compiler options the adapter consumes. Only the\n * staging-relevant fields are declared, so webpack never has to be imported.\n */\nexport interface WebpackOutputLike {\n readonly path?: string;\n}\n\nexport interface WebpackEntryStaticLike {\n readonly main?: string | readonly string[];\n}\n\nexport type WebpackEntryLike = string | readonly string[] | Readonly<Record<string, unknown>>;\n\nexport interface WebpackOptionsLike {\n readonly mode?: string;\n readonly output?: WebpackOutputLike;\n readonly entry?: WebpackEntryLike | WebpackEntryStaticLike;\n}\n\nexport interface WebpackCompilationLike {\n readonly options: WebpackOptionsLike;\n}\n\nexport interface WebpackTapableHook<T> {\n tapAsync(\n name: string,\n callback: (value: T, callback: (error?: Error) => void) => void,\n ): void;\n}\n\nexport interface WebpackCompilerLike {\n readonly options: WebpackOptionsLike;\n readonly hooks: {\n readonly afterEmit: WebpackTapableHook<WebpackCompilationLike>;\n };\n}\n\nexport interface OpenTrayWebpackPlugin {\n readonly name: \"OpenTrayWebpackPlugin\";\n apply(compiler: WebpackCompilerLike): void;\n /** Returns the last staging result. Only populated after `afterEmit` runs. */\n readonly getLastResult: () => OpenTrayPackageResult | undefined;\n}\n\nexport const openTrayWebpackPlugin = (\n options: OpenTrayWebpackPluginOptions,\n): OpenTrayWebpackPlugin => {\n let lastResult: OpenTrayPackageResult | undefined;\n\n return {\n name: \"OpenTrayWebpackPlugin\",\n apply(compiler) {\n compiler.hooks.afterEmit.tapAsync(\"OpenTrayWebpackPlugin\", async (_compilation, cb) => {\n try {\n lastResult = await stageOpenTrayPackage({\n app: options.app,\n outDir: resolveWebpackOutDir(options, compiler.options),\n entry: options.entry ?? resolveWebpackEntry(compiler.options.entry),\n adapter: { name: \"webpack\", mode: resolveWebpackMode(options, compiler.options) },\n runtimeHost: options.runtimeHost,\n ...(options.nativeArtifacts === undefined\n ? {}\n : { nativeArtifacts: options.nativeArtifacts }),\n ...(options.companionAssets === undefined\n ? {}\n : { companionAssets: options.companionAssets }),\n ...(options.manifestPath === undefined\n ? {}\n : { manifestPath: options.manifestPath }),\n });\n cb();\n } catch (error) {\n cb(error as Error);\n }\n });\n },\n getLastResult: () => lastResult,\n };\n};\n\nconst resolveWebpackOutDir = (\n options: OpenTrayWebpackPluginOptions,\n compilerOptions: WebpackOptionsLike,\n): string => {\n if (options.outDir !== undefined) {\n return options.outDir;\n }\n const outputDir = compilerOptions.output?.path;\n if (outputDir !== undefined && outputDir.length > 0) {\n return outputDir;\n }\n return process.cwd();\n};\n\nconst resolveWebpackMode = (\n options: OpenTrayWebpackPluginOptions,\n compilerOptions: WebpackOptionsLike,\n): string => options.mode ?? compilerOptions.mode ?? \"production\";\n\nexport const resolveWebpackEntry = (\n entry: WebpackEntryLike | WebpackEntryStaticLike | undefined,\n): string => {\n const missing = () =>\n new Error(\n \"OpenTray webpack packaging requires a webpack entry or an explicit entry option\",\n );\n if (entry === undefined) {\n throw missing();\n }\n const fromValue = (value: unknown): string | undefined => {\n if (typeof value === \"string\") {\n return value.length > 0 ? value : undefined;\n }\n if (Array.isArray(value)) {\n const first = value[0];\n return typeof first === \"string\" && first.length > 0 ? first : undefined;\n }\n if (value !== null && typeof value === \"object\") {\n const record = value as Readonly<Record<string, unknown>>;\n const importValue = record.import;\n const fromImport = fromValue(importValue);\n if (fromImport !== undefined) {\n return fromImport;\n }\n }\n return undefined;\n };\n if (typeof entry === \"string\") {\n if (entry.length === 0) {\n throw missing();\n }\n return entry;\n }\n if (Array.isArray(entry)) {\n const first = fromValue(entry);\n if (first === undefined) {\n throw missing();\n }\n return first;\n }\n if (typeof entry === \"object\") {\n const record = entry as Readonly<Record<string, unknown>>;\n const mainValue = record.main;\n const fromMain = fromValue(mainValue);\n if (fromMain !== undefined) {\n return fromMain;\n }\n const firstValue = Object.values(record)[0];\n const fromFirst = fromValue(firstValue);\n if (fromFirst !== undefined) {\n return fromFirst;\n }\n }\n throw missing();\n};\n\nexport type { OpenTrayPackageManifest, OpenTrayPackageResult };\n"],"mappings":";;AAwEA,MAAa,yBACX,YAC0B;CAC1B,IAAI;CAEJ,OAAO;EACL,MAAM;EACN,MAAM,UAAU;GACd,SAAS,MAAM,UAAU,SAAS,yBAAyB,OAAO,cAAc,OAAO;IACrF,IAAI;KACF,aAAa,MAAM,qBAAqB;MACtC,KAAK,QAAQ;MACb,QAAQ,qBAAqB,SAAS,SAAS,OAAO;MACtD,OAAO,QAAQ,SAAS,oBAAoB,SAAS,QAAQ,KAAK;MAClE,SAAS;OAAE,MAAM;OAAW,MAAM,mBAAmB,SAAS,SAAS,OAAO;MAAE;MAChF,aAAa,QAAQ;MACrB,GAAI,QAAQ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,UAAU,KAAA,GACZ,MAAM,QAAQ;EAEhB,OAAO;CACT;CACA,IAAI,OAAO,UAAU,UAAU;EAC7B,MAAM,SAAS;EACf,MAAM,YAAY,OAAO;EACzB,MAAM,WAAW,UAAU,SAAS;EACpC,IAAI,aAAa,KAAA,GACf,OAAO;EAET,MAAM,aAAa,OAAO,OAAO,MAAM,EAAE;EACzC,MAAM,YAAY,UAAU,UAAU;EACtC,IAAI,cAAc,KAAA,GAChB,OAAO;CAEX;CACA,MAAM,QAAQ;AAChB"}
1
+ {"version":3,"file":"index.mjs","names":["record"],"sources":["../src/index.ts"],"sourcesContent":["import { join } from \"node:path\";\n\nimport {\n buildDarwinAppBundle,\n stageOpenTrayPackage,\n type DarwinAppBundleOptions,\n type OpenTrayArtifactInput,\n type OpenTrayPackagingApp,\n type OpenTrayPackageManifest,\n type OpenTrayPackageResult,\n type OpenTrayDarwinAppBundleResult,\n} from \"@opentray/packaging\";\n\nexport interface OpenTrayWebpackPluginOptions {\n readonly app: OpenTrayPackagingApp;\n readonly runtimeHost: OpenTrayArtifactInput;\n readonly nativeArtifacts?: Readonly<Record<string, OpenTrayArtifactInput>>;\n readonly companionAssets?: Readonly<Record<string, OpenTrayArtifactInput>>;\n readonly entry?: string;\n readonly manifestPath?: string;\n /**\n * Explicit outDir override. When omitted, resolved from\n * `compiler.options.output.path`.\n */\n readonly outDir?: string;\n /**\n * Explicit mode override. When omitted, resolved from\n * `compiler.options.mode` or defaults to `production`.\n */\n readonly mode?: string;\n}\n\n/**\n * Structural view of the webpack compiler options the adapter consumes. Only the\n * staging-relevant fields are declared, so webpack never has to be imported.\n */\nexport interface WebpackOutputLike {\n readonly path?: string;\n}\n\nexport interface WebpackEntryStaticLike {\n readonly main?: string | readonly string[];\n}\n\nexport type WebpackEntryLike = string | readonly string[] | Readonly<Record<string, unknown>>;\n\nexport interface WebpackOptionsLike {\n readonly mode?: string;\n readonly output?: WebpackOutputLike;\n readonly entry?: WebpackEntryLike | WebpackEntryStaticLike;\n}\n\nexport interface WebpackCompilationLike {\n readonly options: WebpackOptionsLike;\n}\n\nexport interface WebpackTapableHook<T> {\n tapAsync(\n name: string,\n callback: (value: T, callback: (error?: Error) => void) => void,\n ): void;\n}\n\nexport interface WebpackCompilerLike {\n readonly options: WebpackOptionsLike;\n readonly hooks: {\n readonly afterEmit: WebpackTapableHook<WebpackCompilationLike>;\n };\n}\n\nexport interface OpenTrayWebpackPlugin {\n readonly name: \"OpenTrayWebpackPlugin\";\n apply(compiler: WebpackCompilerLike): void;\n /** Returns the last staging result. Only populated after `afterEmit` runs. */\n readonly getLastResult: () => OpenTrayPackageResult | undefined;\n}\n\nexport interface OpenTrayWebpackAppBundlePluginOptions\n extends Omit<DarwinAppBundleOptions, \"bundlePath\" | \"reinitialize\"> {\n readonly bundlePath?: string;\n}\n\nexport interface OpenTrayWebpackAppBundlePlugin {\n readonly name: \"opentray-app-bundle\";\n apply(compiler: WebpackCompilerLike): void;\n readonly getLastResult: () => OpenTrayDarwinAppBundleResult | undefined;\n}\n\n/** webpack lifecycle adapter for the shared Darwin app bundle contract. */\nexport const openTrayAppBundlePlugin = (\n options: OpenTrayWebpackAppBundlePluginOptions,\n): OpenTrayWebpackAppBundlePlugin => {\n let lastResult: OpenTrayDarwinAppBundleResult | undefined;\n return {\n name: \"opentray-app-bundle\",\n apply(compiler) {\n compiler.hooks.afterEmit.tapAsync(\"OpenTrayAppBundlePlugin\", async (_compilation, cb) => {\n try {\n const outputDir = compiler.options.output?.path ?? process.cwd();\n const bundlePath = options.bundlePath ?? join(outputDir, `${options.appName}.app`);\n lastResult = await buildDarwinAppBundle({ ...options, bundlePath });\n cb();\n } catch (error) {\n cb(error as Error);\n }\n });\n },\n getLastResult: () => lastResult,\n };\n};\n\nexport const openTrayWebpackPlugin = (\n options: OpenTrayWebpackPluginOptions,\n): OpenTrayWebpackPlugin => {\n let lastResult: OpenTrayPackageResult | undefined;\n\n return {\n name: \"OpenTrayWebpackPlugin\",\n apply(compiler) {\n compiler.hooks.afterEmit.tapAsync(\"OpenTrayWebpackPlugin\", async (_compilation, cb) => {\n try {\n lastResult = await stageOpenTrayPackage({\n app: options.app,\n outDir: resolveWebpackOutDir(options, compiler.options),\n entry: options.entry ?? resolveWebpackEntry(compiler.options.entry),\n adapter: { name: \"webpack\", mode: resolveWebpackMode(options, compiler.options) },\n runtimeHost: options.runtimeHost,\n ...(options.nativeArtifacts === undefined\n ? {}\n : { nativeArtifacts: options.nativeArtifacts }),\n ...(options.companionAssets === undefined\n ? {}\n : { companionAssets: options.companionAssets }),\n ...(options.manifestPath === undefined\n ? {}\n : { manifestPath: options.manifestPath }),\n });\n cb();\n } catch (error) {\n cb(error as Error);\n }\n });\n },\n getLastResult: () => lastResult,\n };\n};\n\nconst resolveWebpackOutDir = (\n options: OpenTrayWebpackPluginOptions,\n compilerOptions: WebpackOptionsLike,\n): string => {\n if (options.outDir !== undefined) {\n return options.outDir;\n }\n const outputDir = compilerOptions.output?.path;\n if (outputDir !== undefined && outputDir.length > 0) {\n return outputDir;\n }\n return process.cwd();\n};\n\nconst resolveWebpackMode = (\n options: OpenTrayWebpackPluginOptions,\n compilerOptions: WebpackOptionsLike,\n): string => options.mode ?? compilerOptions.mode ?? \"production\";\n\nexport const resolveWebpackEntry = (\n entry: WebpackEntryLike | WebpackEntryStaticLike | undefined,\n): string => {\n const missing = () =>\n new Error(\n \"OpenTray webpack packaging requires a webpack entry or an explicit entry option\",\n );\n if (entry === undefined) {\n throw missing();\n }\n const fromValue = (value: unknown): string | undefined => {\n if (typeof value === \"string\") {\n return value.length > 0 ? value : undefined;\n }\n if (Array.isArray(value)) {\n const first = value[0];\n return typeof first === \"string\" && first.length > 0 ? first : undefined;\n }\n if (value !== null && typeof value === \"object\") {\n const record = value as Readonly<Record<string, unknown>>;\n const importValue = record.import;\n const fromImport = fromValue(importValue);\n if (fromImport !== undefined) {\n return fromImport;\n }\n }\n return undefined;\n };\n if (typeof entry === \"string\") {\n if (entry.length === 0) {\n throw missing();\n }\n return entry;\n }\n if (Array.isArray(entry)) {\n const first = fromValue(entry);\n if (first === undefined) {\n throw missing();\n }\n return first;\n }\n if (typeof entry === \"object\") {\n const record = entry as Readonly<Record<string, unknown>>;\n const mainValue = record.main;\n const fromMain = fromValue(mainValue);\n if (fromMain !== undefined) {\n return fromMain;\n }\n const firstValue = Object.values(record)[0];\n const fromFirst = fromValue(firstValue);\n if (fromFirst !== undefined) {\n return fromFirst;\n }\n }\n throw missing();\n};\n\nexport type { OpenTrayPackageManifest, OpenTrayPackageResult };\n"],"mappings":";;;;AAyFA,MAAa,2BACX,YACmC;CACnC,IAAI;CACJ,OAAO;EACL,MAAM;EACN,MAAM,UAAU;GACd,SAAS,MAAM,UAAU,SAAS,2BAA2B,OAAO,cAAc,OAAO;IACvF,IAAI;KACF,MAAM,YAAY,SAAS,QAAQ,QAAQ,QAAQ,QAAQ,IAAI;KAC/D,MAAM,aAAa,QAAQ,cAAc,KAAK,WAAW,GAAG,QAAQ,QAAQ,KAAK;KACjF,aAAa,MAAM,qBAAqB;MAAE,GAAG;MAAS;KAAW,CAAC;KAClE,GAAG;IACL,SAAS,OAAO;KACd,GAAG,KAAc;IACnB;GACF,CAAC;EACH;EACA,qBAAqB;CACvB;AACF;AAEA,MAAa,yBACX,YAC0B;CAC1B,IAAI;CAEJ,OAAO;EACL,MAAM;EACN,MAAM,UAAU;GACd,SAAS,MAAM,UAAU,SAAS,yBAAyB,OAAO,cAAc,OAAO;IACrF,IAAI;KACF,aAAa,MAAM,qBAAqB;MACtC,KAAK,QAAQ;MACb,QAAQ,qBAAqB,SAAS,SAAS,OAAO;MACtD,OAAO,QAAQ,SAAS,oBAAoB,SAAS,QAAQ,KAAK;MAClE,SAAS;OAAE,MAAM;OAAW,MAAM,mBAAmB,SAAS,SAAS,OAAO;MAAE;MAChF,aAAa,QAAQ;MACrB,GAAI,QAAQ,oBAAoB,KAAA,IAC5B,CAAC,IACD,EAAE,iBAAiB,QAAQ,gBAAgB;MAC/C,GAA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AU;EAC7B,MAAM,SAAS;EACf,MAAM,YAAY,OAAO;EACzB,MAAM,WAAW,UAAU,SAAS;EACpC,IAAI,aAAa,KAAA,GACf,OAAO;EAET,MAAM,aAAa,OAAO,OAAO,MAAM,EAAE;EACzC,MAAM,YAAY,UAAU,UAAU;EACtC,IAAI,cAAc,KAAA,GAChB,OAAO;CAEX;CACA,MAAM,QAAQ;AAChB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentray/webpack-plugin",
3
- "version": "0.15.0",
3
+ "version": "0.17.0",
4
4
  "description": "webpack adapter for the OpenTray runtime artifact packaging contract.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -21,7 +21,7 @@
21
21
  ],
22
22
  "sideEffects": false,
23
23
  "dependencies": {
24
- "@opentray/packaging": "0.15.0"
24
+ "@opentray/packaging": "0.17.0"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "webpack": ">=5"