@opentray/tsdown-plugin 0.1.0 → 0.10.3
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/dist/index.d.mts +46 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +52 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +2 -2
- package/dist/com-example-tsdown-build-4d02ee39ac/native/darwin-arm64.dylib +0 -1
- package/dist/com-example-tsdown-build-4d02ee39ac/opentray-app-manifest.json +0 -26
- package/dist/com-example-tsdown-build-4d02ee39ac/runtime/com-example-tsdown-build-4d02ee39ac +0 -1
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { OpenTrayArtifactInput, OpenTrayPackageManifest, OpenTrayPackageResult, OpenTrayPackagingApp } from "@opentray/packaging";
|
|
2
|
+
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
interface OpenTrayTsdownPluginOptions {
|
|
5
|
+
readonly app: OpenTrayPackagingApp;
|
|
6
|
+
readonly runtimeHost: OpenTrayArtifactInput;
|
|
7
|
+
readonly nativeArtifacts?: Readonly<Record<string, OpenTrayArtifactInput>>;
|
|
8
|
+
readonly companionAssets?: Readonly<Record<string, OpenTrayArtifactInput>>;
|
|
9
|
+
readonly entry?: string;
|
|
10
|
+
readonly manifestPath?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Explicit outDir override. When omitted, resolved from the writeBundle
|
|
13
|
+
* output options (`options.dir`) or defaults to `dist`.
|
|
14
|
+
*/
|
|
15
|
+
readonly outDir?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Explicit mode override. Defaults to `production`.
|
|
18
|
+
*/
|
|
19
|
+
readonly mode?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Structural view of the Rolldown output options the adapter consumes. Only the
|
|
23
|
+
* staging-relevant fields are declared, so tsdown never has to be imported.
|
|
24
|
+
*/
|
|
25
|
+
interface TsdownOutputOptionsLike {
|
|
26
|
+
readonly dir?: string;
|
|
27
|
+
readonly file?: string;
|
|
28
|
+
}
|
|
29
|
+
interface TsdownOutputChunkLike {
|
|
30
|
+
readonly type?: string;
|
|
31
|
+
readonly isEntry?: boolean;
|
|
32
|
+
readonly fileName?: string;
|
|
33
|
+
readonly facadeModuleId?: string | null;
|
|
34
|
+
readonly name?: string;
|
|
35
|
+
}
|
|
36
|
+
type TsdownBundleLike = Readonly<Record<string, unknown>>;
|
|
37
|
+
interface OpenTrayTsdownPlugin {
|
|
38
|
+
readonly name: "opentray-packaging";
|
|
39
|
+
writeBundle(options: TsdownOutputOptionsLike, bundle: TsdownBundleLike): Promise<void>;
|
|
40
|
+
readonly getLastResult: () => OpenTrayPackageResult | undefined;
|
|
41
|
+
}
|
|
42
|
+
declare const openTrayTsdownPlugin: (options: OpenTrayTsdownPluginOptions) => OpenTrayTsdownPlugin;
|
|
43
|
+
declare const resolveTsdownEntry: (bundle: TsdownBundleLike) => string;
|
|
44
|
+
//#endregion
|
|
45
|
+
export { type OpenTrayPackageManifest, type OpenTrayPackageResult, OpenTrayTsdownPlugin, OpenTrayTsdownPluginOptions, TsdownBundleLike, TsdownOutputChunkLike, TsdownOutputOptionsLike, openTrayTsdownPlugin, resolveTsdownEntry };
|
|
46
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;UAUiB,2BAAA;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,SAWlB,IAAA;AAAA;;;;;UAOM,uBAAA;EAAA,SACN,GAAA;EAAA,SACA,IAAI;AAAA;AAAA,UAGE,qBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,QAAA;EAAA,SACA,cAAA;EAAA,SACA,IAAA;AAAA;AAAA,KAGC,gBAAA,GAAmB,QAAQ,CAAC,MAAA;AAAA,UAEvB,oBAAA;EAAA,SACN,IAAA;EACT,WAAA,CAAY,OAAA,EAAS,uBAAA,EAAyB,MAAA,EAAQ,gBAAA,GAAmB,OAAA;EAAA,SAChE,aAAA,QAAqB,qBAAA;AAAA;AAAA,cAGnB,oBAAA,GACX,OAAA,EAAS,2BAAA,KACR,oBAuBF;AAAA,cAkBY,kBAAA,GAAsB,MAAwB,EAAhB,gBAAgB"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { stageOpenTrayPackage } from "@opentray/packaging";
|
|
3
|
+
//#region src/index.ts
|
|
4
|
+
const openTrayTsdownPlugin = (options) => {
|
|
5
|
+
let lastResult;
|
|
6
|
+
return {
|
|
7
|
+
name: "opentray-packaging",
|
|
8
|
+
async writeBundle(outputOptions, bundle) {
|
|
9
|
+
lastResult = await stageOpenTrayPackage({
|
|
10
|
+
app: options.app,
|
|
11
|
+
outDir: resolveOutDir(options, outputOptions),
|
|
12
|
+
entry: options.entry ?? resolveTsdownEntry(bundle),
|
|
13
|
+
adapter: {
|
|
14
|
+
name: "tsdown",
|
|
15
|
+
mode: options.mode ?? "production"
|
|
16
|
+
},
|
|
17
|
+
runtimeHost: options.runtimeHost,
|
|
18
|
+
...options.nativeArtifacts === void 0 ? {} : { nativeArtifacts: options.nativeArtifacts },
|
|
19
|
+
...options.companionAssets === void 0 ? {} : { companionAssets: options.companionAssets },
|
|
20
|
+
...options.manifestPath === void 0 ? {} : { manifestPath: options.manifestPath }
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
getLastResult: () => lastResult
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
const resolveOutDir = (options, outputOptions) => {
|
|
27
|
+
if (options.outDir !== void 0) return resolve(options.outDir);
|
|
28
|
+
if (outputOptions.dir !== void 0 && outputOptions.dir.length > 0) return outputOptions.dir;
|
|
29
|
+
if (outputOptions.file !== void 0 && outputOptions.file.length > 0) return resolve(outputOptions.file, "..");
|
|
30
|
+
return resolve(process.cwd(), "dist");
|
|
31
|
+
};
|
|
32
|
+
const resolveTsdownEntry = (bundle) => {
|
|
33
|
+
const entry = Object.values(bundle).map(asOutputChunk).find((chunk) => chunk?.isEntry === true);
|
|
34
|
+
const identity = entry?.facadeModuleId ?? entry?.fileName ?? entry?.name;
|
|
35
|
+
if (identity === void 0 || identity.length === 0) throw new Error("OpenTray tsdown packaging requires a bundle entry chunk or explicit entry option");
|
|
36
|
+
return identity;
|
|
37
|
+
};
|
|
38
|
+
const asOutputChunk = (value) => {
|
|
39
|
+
if (typeof value !== "object" || value === null) return;
|
|
40
|
+
const record = value;
|
|
41
|
+
return {
|
|
42
|
+
...record.type === "chunk" ? { type: "chunk" } : {},
|
|
43
|
+
...typeof record.isEntry === "boolean" ? { isEntry: record.isEntry } : {},
|
|
44
|
+
...typeof record.fileName === "string" ? { fileName: record.fileName } : {},
|
|
45
|
+
...typeof record.facadeModuleId === "string" || record.facadeModuleId === null ? { facadeModuleId: record.facadeModuleId } : {},
|
|
46
|
+
...typeof record.name === "string" ? { name: record.name } : {}
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
//#endregion
|
|
50
|
+
export { openTrayTsdownPlugin, resolveTsdownEntry };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { resolve } from \"node:path\";\n\nimport {\n stageOpenTrayPackage,\n type OpenTrayArtifactInput,\n type OpenTrayPackagingApp,\n type OpenTrayPackageManifest,\n type OpenTrayPackageResult,\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 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":";;;AAqDA,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;I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,mBAAmB,OACvE,EAAE,gBAAgB,OAAO,eAAe,IACxC,CAAC;EACL,GAAI,OAAO,OAAO,SAAS,WAAW,EAAE,MAAM,OAAO,KAAK,IAAI,CAAC;CACjE;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentray/tsdown-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.3",
|
|
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.
|
|
24
|
+
"@opentray/packaging": "0.10.3"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"tsdown": ">=0.20"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
native-bytes
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"schemaVersion": 1,
|
|
3
|
-
"app": {
|
|
4
|
-
"id": "com.example.tsdown.build",
|
|
5
|
-
"name": "TSdown Build"
|
|
6
|
-
},
|
|
7
|
-
"artifactStem": "com-example-tsdown-build-4d02ee39ac",
|
|
8
|
-
"entry": "/Users/kzf/Dev/GitHub/jixoai-labs/opentray/packages/tsdown-plugin/examples/build-app/src/main.d.ts",
|
|
9
|
-
"adapter": {
|
|
10
|
-
"name": "tsdown",
|
|
11
|
-
"mode": "production"
|
|
12
|
-
},
|
|
13
|
-
"runtimeHost": {
|
|
14
|
-
"role": "runtime-host",
|
|
15
|
-
"path": "com-example-tsdown-build-4d02ee39ac/runtime/com-example-tsdown-build-4d02ee39ac",
|
|
16
|
-
"name": "com-example-tsdown-build-4d02ee39ac"
|
|
17
|
-
},
|
|
18
|
-
"nativeArtifacts": {
|
|
19
|
-
"darwin-arm64": {
|
|
20
|
-
"role": "native-sidecar",
|
|
21
|
-
"path": "com-example-tsdown-build-4d02ee39ac/native/darwin-arm64.dylib",
|
|
22
|
-
"name": "darwin-arm64.dylib"
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
"companionAssets": {}
|
|
26
|
-
}
|
package/dist/com-example-tsdown-build-4d02ee39ac/runtime/com-example-tsdown-build-4d02ee39ac
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
runtime-host-bytes
|