@opentray/tsdown-plugin 0.18.0 → 0.19.1

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 { 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 OpenTrayTsdownPluginOptions {\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 writeBundle\n * output options (`options.dir`) 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 Rolldown output options the adapter consumes. Only the\n * staging-relevant fields are declared, so tsdown never has to be imported.\n */\nexport interface TsdownOutputOptionsLike {\n readonly dir?: string;\n readonly file?: string;\n}\n\nexport interface TsdownOutputChunkLike {\n readonly type?: string;\n readonly isEntry?: boolean;\n readonly fileName?: string;\n readonly facadeModuleId?: string | null;\n readonly name?: string;\n}\n\nexport type TsdownBundleLike = Readonly<Record<string, unknown>>;\n\nexport interface OpenTrayTsdownPlugin {\n readonly name: \"opentray-packaging\";\n writeBundle(options: TsdownOutputOptionsLike, bundle: TsdownBundleLike): Promise<void>;\n readonly getLastResult: () => OpenTrayPackageResult | undefined;\n}\n\nexport interface OpenTrayTsdownAppBundlePluginOptions\n extends Omit<DarwinAppBundleOptions, \"bundlePath\" | \"reinitialize\"> {\n readonly bundlePath?: string;\n}\n\nexport interface OpenTrayTsdownAppBundlePlugin {\n readonly name: \"opentray-app-bundle\";\n writeBundle(options: TsdownOutputOptionsLike): Promise<void>;\n readonly getLastResult: () => OpenTrayDarwinAppBundleResult | undefined;\n}\n\n/** tsdown lifecycle adapter for the shared Darwin app bundle contract. */\nexport const openTrayAppBundlePlugin = (\n options: OpenTrayTsdownAppBundlePluginOptions,\n): OpenTrayTsdownAppBundlePlugin => {\n let lastResult: OpenTrayDarwinAppBundleResult | undefined;\n return {\n name: \"opentray-app-bundle\",\n async writeBundle(outputOptions) {\n const outDir = resolveTsdownBundleOutputDir(outputOptions);\n const bundlePath =\n options.bundlePath === undefined\n ? join(outDir, `${options.appName}.app`)\n : resolve(options.bundlePath);\n lastResult = await buildDarwinAppBundle({ ...options, bundlePath });\n },\n getLastResult: () => lastResult,\n };\n};\n\nconst resolveTsdownBundleOutputDir = (\n outputOptions: TsdownOutputOptionsLike,\n): string => {\n if (outputOptions.dir !== undefined && outputOptions.dir.length > 0) {\n return outputOptions.dir;\n }\n if (outputOptions.file !== undefined && outputOptions.file.length > 0) {\n return resolve(outputOptions.file, \"..\");\n }\n return resolve(process.cwd(), \"dist\");\n};\n\nexport const openTrayTsdownPlugin = (\n options: OpenTrayTsdownPluginOptions,\n): OpenTrayTsdownPlugin => {\n let lastResult: OpenTrayPackageResult | undefined;\n\n return {\n name: \"opentray-packaging\",\n async writeBundle(outputOptions, bundle) {\n lastResult = await stageOpenTrayPackage({\n app: options.app,\n outDir: resolveOutDir(options, outputOptions),\n entry: options.entry ?? resolveTsdownEntry(bundle),\n adapter: { name: \"tsdown\", 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 getLastResult: () => lastResult,\n };\n};\n\nconst resolveOutDir = (\n options: OpenTrayTsdownPluginOptions,\n outputOptions: TsdownOutputOptionsLike,\n): string => {\n if (options.outDir !== undefined) {\n return resolve(options.outDir);\n }\n if (outputOptions.dir !== undefined && outputOptions.dir.length > 0) {\n return outputOptions.dir;\n }\n if (outputOptions.file !== undefined && outputOptions.file.length > 0) {\n return resolve(outputOptions.file, \"..\");\n }\n return resolve(process.cwd(), \"dist\");\n};\n\nexport const resolveTsdownEntry = (bundle: TsdownBundleLike): string => {\n const entry = Object.values(bundle)\n .map(asOutputChunk)\n .find((chunk): chunk is TsdownOutputChunkLike => chunk?.isEntry === true);\n const identity = entry?.facadeModuleId ?? entry?.fileName ?? entry?.name;\n if (identity === undefined || identity.length === 0) {\n throw new Error(\n \"OpenTray tsdown packaging requires a bundle entry chunk or explicit entry option\",\n );\n }\n return identity;\n};\n\nconst asOutputChunk = (value: unknown): TsdownOutputChunkLike | undefined => {\n if (typeof value !== \"object\" || value === null) {\n return undefined;\n }\n const record = value as Record<string, unknown>;\n return {\n ...(record.type === \"chunk\" ? { type: \"chunk\" } : {}),\n ...(typeof record.isEntry === \"boolean\" ? { isEntry: record.isEntry } : {}),\n ...(typeof record.fileName === \"string\" ? { fileName: record.fileName } : {}),\n ...(typeof record.facadeModuleId === \"string\" || record.facadeModuleId === null\n ? { facadeModuleId: record.facadeModuleId }\n : {}),\n ...(typeof record.name === \"string\" ? { name: record.name } : {}),\n };\n};\n\nexport type { OpenTrayPackageManifest, OpenTrayPackageResult };\n"],"mappings":";;;;AAoEA,MAAa,2BACX,YACkC;CAClC,IAAI;CACJ,OAAO;EACL,MAAM;EACN,MAAM,YAAY,eAAe;GAC/B,MAAM,SAAS,6BAA6B,aAAa;GACzD,MAAM,aACJ,QAAQ,eAAe,KAAA,IACnB,KAAK,QAAQ,GAAG,QAAQ,QAAQ,KAAK,IACrC,QAAQ,QAAQ,UAAU;GAChC,aAAa,MAAM,qBAAqB;IAAE,GAAG;IAAS;GAAW,CAA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aAAa,EACjB,MAAM,UAA0C,OAAO,YAAY,IAAI;CAC1E,MAAM,WAAW,OAAO,kBAAkB,OAAO,YAAY,OAAO;CACpE,IAAI,aAAa,KAAA,KAAa,SAAS,WAAW,GAChD,MAAM,IAAI,MACR,kFACF;CAEF,OAAO;AACT;AAEA,MAAM,iBAAiB,UAAsD;CAC3E,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC;CAEF,MAAM,SAAS;CACf,OAAO;EACL,GAAI,OAAO,SAAS,UAAU,EAAE,MAAM,QAAQ,IAAI,CAAC;EACnD,GAAI,OAAO,OAAO,YAAY,YAAY,EAAE,SAAS,OAAO,QAAQ,IAAI,CAAC;EACzE,GAAI,OAAO,OAAO,aAAa,WAAW,EAAE,UAAU,OAAO,SAAS,IAAI,CAAC;EAC3E,GAAI,OAAO,OAAO,mBAAmB,YAAY,OAAO,mBAAmB,OACvE,EAAE,gBAAgB,OAAO,eAAe,IACxC,CAAC;EACL,GAAI,OAAO,OAAO,SAAS,WAAW,EAAE,MAAM,OAAO,KAAK,IAAI,CAAC;CACjE;AACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { 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 OpenTrayTsdownPluginOptions {\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 writeBundle\n * output options (`options.dir`) 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 Rolldown output options the adapter consumes. Only the\n * staging-relevant fields are declared, so tsdown never has to be imported.\n */\nexport interface TsdownOutputOptionsLike {\n readonly dir?: string;\n readonly file?: string;\n}\n\nexport interface TsdownOutputChunkLike {\n readonly type?: string;\n readonly isEntry?: boolean;\n readonly fileName?: string;\n readonly facadeModuleId?: string | null;\n readonly name?: string;\n}\n\nexport type TsdownBundleLike = Readonly<Record<string, unknown>>;\n\nexport interface OpenTrayTsdownPlugin {\n readonly name: \"opentray-packaging\";\n writeBundle(options: TsdownOutputOptionsLike, bundle: TsdownBundleLike): Promise<void>;\n readonly getLastResult: () => OpenTrayPackageResult | undefined;\n}\n\nexport interface OpenTrayTsdownAppBundlePluginOptions\n extends Omit<DarwinAppBundleOptions, \"bundlePath\" | \"reinitialize\"> {\n readonly bundlePath?: string;\n}\n\nexport interface OpenTrayTsdownAppBundlePlugin {\n readonly name: \"opentray-app-bundle\";\n writeBundle(options: TsdownOutputOptionsLike): Promise<void>;\n readonly getLastResult: () => OpenTrayDarwinAppBundleResult | undefined;\n}\n\n/** tsdown lifecycle adapter for the shared Darwin app bundle contract. */\nexport const openTrayAppBundlePlugin = (\n options: OpenTrayTsdownAppBundlePluginOptions,\n): OpenTrayTsdownAppBundlePlugin => {\n let lastResult: OpenTrayDarwinAppBundleResult | undefined;\n return {\n name: \"opentray-app-bundle\",\n async writeBundle(outputOptions) {\n const outDir = resolveTsdownBundleOutputDir(outputOptions);\n const bundlePath =\n options.bundlePath === undefined\n ? join(outDir, `${options.appName}.app`)\n : resolve(options.bundlePath);\n lastResult = await buildDarwinAppBundle({ ...options, bundlePath });\n },\n getLastResult: () => lastResult,\n };\n};\n\nconst resolveTsdownBundleOutputDir = (\n outputOptions: TsdownOutputOptionsLike,\n): string => {\n if (outputOptions.dir !== undefined && outputOptions.dir.length > 0) {\n return outputOptions.dir;\n }\n if (outputOptions.file !== undefined && outputOptions.file.length > 0) {\n return resolve(outputOptions.file, \"..\");\n }\n return resolve(process.cwd(), \"dist\");\n};\n\nexport const openTrayTsdownPlugin = (\n options: OpenTrayTsdownPluginOptions,\n): OpenTrayTsdownPlugin => {\n let lastResult: OpenTrayPackageResult | undefined;\n\n return {\n name: \"opentray-packaging\",\n async writeBundle(outputOptions, bundle) {\n lastResult = await stageOpenTrayPackage({\n app: options.app,\n outDir: resolveOutDir(options, outputOptions),\n entry: options.entry ?? resolveTsdownEntry(bundle),\n adapter: { name: \"tsdown\", 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 getLastResult: () => lastResult,\n };\n};\n\nconst resolveOutDir = (\n options: OpenTrayTsdownPluginOptions,\n outputOptions: TsdownOutputOptionsLike,\n): string => {\n if (options.outDir !== undefined) {\n return resolve(options.outDir);\n }\n if (outputOptions.dir !== undefined && outputOptions.dir.length > 0) {\n return outputOptions.dir;\n }\n if (outputOptions.file !== undefined && outputOptions.file.length > 0) {\n return resolve(outputOptions.file, \"..\");\n }\n return resolve(process.cwd(), \"dist\");\n};\n\nexport const resolveTsdownEntry = (bundle: TsdownBundleLike): string => {\n const entry = Object.values(bundle)\n .map(asOutputChunk)\n .find((chunk): chunk is TsdownOutputChunkLike => chunk?.isEntry === true);\n const identity = entry?.facadeModuleId ?? entry?.fileName ?? entry?.name;\n if (identity === undefined || identity.length === 0) {\n throw new Error(\n \"OpenTray tsdown packaging requires a bundle entry chunk or explicit entry option\",\n );\n }\n return identity;\n};\n\nconst asOutputChunk = (value: unknown): TsdownOutputChunkLike | undefined => {\n if (typeof value !== \"object\" || value === null) {\n return undefined;\n }\n const record = value as Record<string, unknown>;\n return {\n ...(record.type === \"chunk\" ? { type: \"chunk\" } : {}),\n ...(typeof record.isEntry === \"boolean\" ? { isEntry: record.isEntry } : {}),\n ...(typeof record.fileName === \"string\" ? { fileName: record.fileName } : {}),\n ...(typeof record.facadeModuleId === \"string\" || record.facadeModuleId === null\n ? { facadeModuleId: record.facadeModuleId }\n : {}),\n ...(typeof record.name === \"string\" ? { name: record.name } : {}),\n };\n};\n\nexport type { OpenTrayPackageManifest, OpenTrayPackageResult };\n"],"mappings":";;;;AAoEA,MAAa,2BACX,YACkC;CAClC,IAAI;CACJ,OAAO;EACL,MAAM;EACN,MAAM,YAAY,eAAe;GAC/B,MAAM,SAAS,6BAA6B,aAAa;GACzD,MAAM,aACJ,QAAQ,eAAe,KAAA,IACnB,KAAK,QAAQ,GAAG,QAAQ,QAAQ,KAAK,IACrC,QAAQ,QAAQ,UAAU;GAChC,aAAa,MAAM,qBAAqB;IAAE,GAAG;IAAS;GAAW,CAAC;EACpE;EACA,qBAAqB;CACvB;AACF;AAEA,MAAM,gCACJ,kBACW;CACX,IAAI,cAAc,QAAQ,KAAA,KAAa,cAAc,IAAI,SAAS,GAChE,OAAO,cAAc;CAEvB,IAAI,cAAc,SAAS,KAAA,KAAa,cAAc,KAAK,SAAS,GAClE,OAAO,QAAQ,cAAc,MAAM,IAAI;CAEzC,OAAO,QAAQ,QAAQ,IAAI,GAAG,MAAM;AACtC;AAEA,MAAa,wBACX,YACyB;CACzB,IAAI;CAEJ,OAAO;EACL,MAAM;EACN,MAAM,YAAY,eAAe,QAAQ;GACvC,aAAa,MAAM,qBAAqB;IACtC,KAAK,QAAQ;IACb,QAAQ,cAAc,SAAS,aAAa;IAC5C,OAAO,QAAQ,SAAS,mBAAmB,MAAM;IACjD,SAAS;KAAE,MAAM;KAAU,MAAM,QAAQ,QAAQ;IAAa;IAC9D,aAAa,QAAQ;IACrB,GAAI,QAAQ,oBAAoB,KAAA,IAC5B,CAAC,IACD,EAAE,iBAAiB,QAAQ,gBAAgB;IAC/C,GAAI,QAAQ,oBAAoB,KAAA,IAC5B,CAAC,IAC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ANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentray/tsdown-plugin",
3
- "version": "0.18.0",
3
+ "version": "0.19.1",
4
4
  "description": "tsdown 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.1"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "tsdown": ">=0.20"