@opentray/esbuild-plugin 0.18.0 → 0.19.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { dirname, join, resolve } 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 OpenTrayEsbuildPluginOptions {\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 the esbuild\n * `outdir`/`outfile` option or defaults to `dist`.\n */\n readonly outDir?: string;\n /**\n * Explicit mode override. Defaults to `production`.\n */\n readonly mode?: string;\n}\n\n/**\n * Structural view of the esbuild initial options the adapter consumes. Only the\n * staging-relevant fields are declared, so esbuild never has to be imported.\n */\nexport interface EsbuildInitialOptionsLike {\n readonly outdir?: string;\n readonly outfile?: string;\n readonly entryPoints?: readonly string[] | Readonly<Record<string, string>>;\n readonly absWorkingDir?: string;\n}\n\nexport interface EsbuildBuildLike {\n readonly initialOptions: EsbuildInitialOptionsLike;\n onEnd(callback: (result: unknown) => Promise<void> | void): void;\n}\n\nexport interface EsbuildPlugin {\n readonly name: string;\n readonly setup: (build: EsbuildBuildLike) => void;\n}\n\nexport interface OpenTrayEsbuildPlugin extends EsbuildPlugin {\n readonly name: \"opentray-packaging\";\n /** Returns the last staging result. Only populated after `onEnd` runs. */\n readonly getLastResult: () => OpenTrayPackageResult | undefined;\n}\n\nexport interface OpenTrayEsbuildAppBundlePluginOptions\n extends Omit<DarwinAppBundleOptions, \"bundlePath\" | \"reinitialize\"> {\n readonly bundlePath?: string;\n}\n\nexport interface OpenTrayEsbuildAppBundlePlugin extends EsbuildPlugin {\n readonly name: \"opentray-app-bundle\";\n readonly getLastResult: () => OpenTrayDarwinAppBundleResult | undefined;\n}\n\n/** esbuild lifecycle adapter for the shared Darwin app bundle contract. */\nexport const openTrayAppBundlePlugin = (\n options: OpenTrayEsbuildAppBundlePluginOptions,\n): OpenTrayEsbuildAppBundlePlugin => {\n let lastResult: OpenTrayDarwinAppBundleResult | undefined;\n return {\n name: \"opentray-app-bundle\",\n setup(build) {\n build.onEnd(async () => {\n const cwd = build.initialOptions.absWorkingDir ?? process.cwd();\n const bundlePath =\n options.bundlePath === undefined\n ? join(resolveEsbuildBundleOutputDir(build.initialOptions, cwd), `${options.appName}.app`)\n : resolve(cwd, options.bundlePath);\n lastResult = await buildDarwinAppBundle({ ...options, bundlePath });\n });\n },\n getLastResult: () => lastResult,\n };\n};\n\nexport const openTrayEsbuildPlugin = (\n options: OpenTrayEsbuildPluginOptions,\n): OpenTrayEsbuildPlugin => {\n let lastResult: OpenTrayPackageResult | undefined;\n\n // esbuild validates the enumerable own keys of a plugin object and rejects\n // anything beyond { name, setup }. Keep `getLastResult` non-enumerable so the\n // adapter can still expose the staging result to programmatic callers without\n // tripping esbuild's plugin validation.\n const plugin: OpenTrayEsbuildPlugin = {\n name: \"opentray-packaging\",\n setup(build) {\n build.onEnd(async () => {\n lastResult = await stageOpenTrayPackage({\n app: options.app,\n outDir: resolveEsbuildOutDir(options, build.initialOptions),\n entry: options.entry ?? resolveEsbuildEntry(build.initialOptions),\n adapter: { name: \"esbuild\", mode: options.mode ?? \"production\" },\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 ? {} : { manifestPath: options.manifestPath }),\n });\n });\n },\n getLastResult: () => lastResult,\n };\n Object.defineProperty(plugin, \"getLastResult\", { enumerable: false });\n return plugin;\n};\n\nconst resolveEsbuildOutDir = (\n options: OpenTrayEsbuildPluginOptions,\n initialOptions: EsbuildInitialOptionsLike,\n): string => {\n const cwd = initialOptions.absWorkingDir ?? process.cwd();\n if (options.outDir !== undefined) {\n return resolve(cwd, options.outDir);\n }\n if (initialOptions.outdir !== undefined && initialOptions.outdir.length > 0) {\n return resolve(cwd, initialOptions.outdir);\n }\n if (initialOptions.outfile !== undefined && initialOptions.outfile.length > 0) {\n return resolve(cwd, dirname(initialOptions.outfile));\n }\n return resolve(process.cwd(), \"dist\");\n};\n\nconst resolveEsbuildBundleOutputDir = (\n initialOptions: EsbuildInitialOptionsLike,\n cwd: string,\n): string => {\n if (initialOptions.outdir !== undefined && initialOptions.outdir.length > 0) {\n return resolve(cwd, initialOptions.outdir);\n }\n if (initialOptions.outfile !== undefined && initialOptions.outfile.length > 0) {\n return resolve(cwd, dirname(initialOptions.outfile));\n }\n return resolve(cwd, \"dist\");\n};\n\nexport const resolveEsbuildEntry = (initialOptions: EsbuildInitialOptionsLike): string => {\n const entryPoints = initialOptions.entryPoints;\n if (entryPoints === undefined) {\n throw new Error(\n \"OpenTray esbuild packaging requires esbuild entryPoints or an explicit entry option\",\n );\n }\n if (Array.isArray(entryPoints)) {\n if (entryPoints.length === 0) {\n throw new Error(\n \"OpenTray esbuild packaging requires esbuild entryPoints or an explicit entry option\",\n );\n }\n return entryPoints[0] as string;\n }\n const first = Object.values(entryPoints)[0];\n if (first === undefined) {\n throw new Error(\n \"OpenTray esbuild packaging requires esbuild entryPoints or an explicit entry option\",\n );\n }\n return first;\n};\n\nexport type { OpenTrayPackageManifest, OpenTrayPackageResult };\n"],"mappings":";;;;AAqEA,MAAa,2BACX,YACmC;CACnC,IAAI;CACJ,OAAO;EACL,MAAM;EACN,MAAM,OAAO;GACX,MAAM,MAAM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,eAAe,YAAY,KAAA,KAAa,eAAe,QAAQ,SAAS,GAC1E,OAAO,QAAQ,KAAK,QAAQ,eAAe,OAAO,CAAC;CAErD,OAAO,QAAQ,QAAQ,IAAI,GAAG,MAAM;AACtC;AAEA,MAAM,iCACJ,gBACA,QACW;CACX,IAAI,eAAe,WAAW,KAAA,KAAa,eAAe,OAAO,SAAS,GACxE,OAAO,QAAQ,KAAK,eAAe,MAAM;CAE3C,IAAI,eAAe,YAAY,KAAA,KAAa,eAAe,QAAQ,SAAS,GAC1E,OAAO,QAAQ,KAAK,QAAQ,eAAe,OAAO,CAAC;CAErD,OAAO,QAAQ,KAAK,MAAM;AAC5B;AAEA,MAAa,uBAAuB,mBAAsD;CACxF,MAAM,cAAc,eAAe;CACnC,IAAI,gBAAgB,KAAA,GAClB,MAAM,IAAI,MACR,qFACF;CAEF,IAAI,MAAM,QAAQ,WAAW,GAAG;EAC9B,IAAI,YAAY,WAAW,GACzB,MAAM,IAAI,MACR,qFACF;EAEF,OAAO,YAAY;CACrB;CACA,MAAM,QAAQ,OAAO,OAAO,WAAW,EAAE;CACzC,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,MACR,qFACF;CAEF,OAAO;AACT"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { dirname, join, resolve } 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 OpenTrayEsbuildPluginOptions {\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 the esbuild\n * `outdir`/`outfile` option or defaults to `dist`.\n */\n readonly outDir?: string;\n /**\n * Explicit mode override. Defaults to `production`.\n */\n readonly mode?: string;\n}\n\n/**\n * Structural view of the esbuild initial options the adapter consumes. Only the\n * staging-relevant fields are declared, so esbuild never has to be imported.\n */\nexport interface EsbuildInitialOptionsLike {\n readonly outdir?: string;\n readonly outfile?: string;\n readonly entryPoints?: readonly string[] | Readonly<Record<string, string>>;\n readonly absWorkingDir?: string;\n}\n\nexport interface EsbuildBuildLike {\n readonly initialOptions: EsbuildInitialOptionsLike;\n onEnd(callback: (result: unknown) => Promise<void> | void): void;\n}\n\nexport interface EsbuildPlugin {\n readonly name: string;\n readonly setup: (build: EsbuildBuildLike) => void;\n}\n\nexport interface OpenTrayEsbuildPlugin extends EsbuildPlugin {\n readonly name: \"opentray-packaging\";\n /** Returns the last staging result. Only populated after `onEnd` runs. */\n readonly getLastResult: () => OpenTrayPackageResult | undefined;\n}\n\nexport interface OpenTrayEsbuildAppBundlePluginOptions\n extends Omit<DarwinAppBundleOptions, \"bundlePath\" | \"reinitialize\"> {\n readonly bundlePath?: string;\n}\n\nexport interface OpenTrayEsbuildAppBundlePlugin extends EsbuildPlugin {\n readonly name: \"opentray-app-bundle\";\n readonly getLastResult: () => OpenTrayDarwinAppBundleResult | undefined;\n}\n\n/** esbuild lifecycle adapter for the shared Darwin app bundle contract. */\nexport const openTrayAppBundlePlugin = (\n options: OpenTrayEsbuildAppBundlePluginOptions,\n): OpenTrayEsbuildAppBundlePlugin => {\n let lastResult: OpenTrayDarwinAppBundleResult | undefined;\n return {\n name: \"opentray-app-bundle\",\n setup(build) {\n build.onEnd(async () => {\n const cwd = build.initialOptions.absWorkingDir ?? process.cwd();\n const bundlePath =\n options.bundlePath === undefined\n ? join(resolveEsbuildBundleOutputDir(build.initialOptions, cwd), `${options.appName}.app`)\n : resolve(cwd, options.bundlePath);\n lastResult = await buildDarwinAppBundle({ ...options, bundlePath });\n });\n },\n getLastResult: () => lastResult,\n };\n};\n\nexport const openTrayEsbuildPlugin = (\n options: OpenTrayEsbuildPluginOptions,\n): OpenTrayEsbuildPlugin => {\n let lastResult: OpenTrayPackageResult | undefined;\n\n // esbuild validates the enumerable own keys of a plugin object and rejects\n // anything beyond { name, setup }. Keep `getLastResult` non-enumerable so the\n // adapter can still expose the staging result to programmatic callers without\n // tripping esbuild's plugin validation.\n const plugin: OpenTrayEsbuildPlugin = {\n name: \"opentray-packaging\",\n setup(build) {\n build.onEnd(async () => {\n lastResult = await stageOpenTrayPackage({\n app: options.app,\n outDir: resolveEsbuildOutDir(options, build.initialOptions),\n entry: options.entry ?? resolveEsbuildEntry(build.initialOptions),\n adapter: { name: \"esbuild\", mode: options.mode ?? \"production\" },\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 ? {} : { manifestPath: options.manifestPath }),\n });\n });\n },\n getLastResult: () => lastResult,\n };\n Object.defineProperty(plugin, \"getLastResult\", { enumerable: false });\n return plugin;\n};\n\nconst resolveEsbuildOutDir = (\n options: OpenTrayEsbuildPluginOptions,\n initialOptions: EsbuildInitialOptionsLike,\n): string => {\n const cwd = initialOptions.absWorkingDir ?? process.cwd();\n if (options.outDir !== undefined) {\n return resolve(cwd, options.outDir);\n }\n if (initialOptions.outdir !== undefined && initialOptions.outdir.length > 0) {\n return resolve(cwd, initialOptions.outdir);\n }\n if (initialOptions.outfile !== undefined && initialOptions.outfile.length > 0) {\n return resolve(cwd, dirname(initialOptions.outfile));\n }\n return resolve(process.cwd(), \"dist\");\n};\n\nconst resolveEsbuildBundleOutputDir = (\n initialOptions: EsbuildInitialOptionsLike,\n cwd: string,\n): string => {\n if (initialOptions.outdir !== undefined && initialOptions.outdir.length > 0) {\n return resolve(cwd, initialOptions.outdir);\n }\n if (initialOptions.outfile !== undefined && initialOptions.outfile.length > 0) {\n return resolve(cwd, dirname(initialOptions.outfile));\n }\n return resolve(cwd, \"dist\");\n};\n\nexport const resolveEsbuildEntry = (initialOptions: EsbuildInitialOptionsLike): string => {\n const entryPoints = initialOptions.entryPoints;\n if (entryPoints === undefined) {\n throw new Error(\n \"OpenTray esbuild packaging requires esbuild entryPoints or an explicit entry option\",\n );\n }\n if (Array.isArray(entryPoints)) {\n if (entryPoints.length === 0) {\n throw new Error(\n \"OpenTray esbuild packaging requires esbuild entryPoints or an explicit entry option\",\n );\n }\n return entryPoints[0] as string;\n }\n const first = Object.values(entryPoints)[0];\n if (first === undefined) {\n throw new Error(\n \"OpenTray esbuild packaging requires esbuild entryPoints or an explicit entry option\",\n );\n }\n return first;\n};\n\nexport type { OpenTrayPackageManifest, OpenTrayPackageResult };\n"],"mappings":";;;;AAqEA,MAAa,2BACX,YACmC;CACnC,IAAI;CACJ,OAAO;EACL,MAAM;EACN,MAAM,OAAO;GACX,MAAM,MAAM,YAAY;IACtB,MAAM,MAAM,MAAM,eAAe,iBAAiB,QAAQ,IAAI;IAC9D,MAAM,aACJ,QAAQ,eAAe,KAAA,IACnB,KAAK,8BAA8B,MAAM,gBAAgB,GAAG,GAAG,GAAG,QAAQ,QAAQ,KAAK,IACvF,QAAQ,KAAK,QAAQ,UAAU;IACrC,aAAa,MAAM,qBAAqB;KAAE,GAAG;KAAS;IAAW,CAAC;GACpE,CAAC;EACH;EACA,qBAAqB;CACvB;AACF;AAEA,MAAa,yBACX,YAC0B;CAC1B,IAAI;CAMJ,MAAM,SAAgC;EACpC,MAAM;EACN,MAAM,OAAO;GACX,MAAM,MAAM,YAAY;IACtB,aAAa,MAAM,qBAAqB;KACtC,KAAK,QAAQ;KACb,QAAQ,qBAAqB,SAAS,MAAM,cAAc;KAC1D,OAAO,QAAQ,SAAS,oBAAoB,MAAM,cAAc;KAChE,SAAS;MAAE,MAAM;MAAW,MAAM,QAAQ,QAAQ;KAAa;KAC/D,aAA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ACF;EAEF,OAAO,YAAY;CACrB;CACA,MAAM,QAAQ,OAAO,OAAO,WAAW,CAAC,CAAC;CACzC,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,MACR,qFACF;CAEF,OAAO;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentray/esbuild-plugin",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "description": "esbuild 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.18.0"
24
+ "@opentray/packaging": "0.19.0"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "esbuild": ">=0.20"