@kodycodes/cli 3.31.3 → 3.31.4

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 (33) hide show
  1. package/dist/bin.js +1 -1
  2. package/dist/{chunk-3G4MV7KG.js → chunk-6KT2QEN3.js} +3 -3
  3. package/dist/{chunk-PMFY674W.js → chunk-GMD3RXXS.js} +2 -2
  4. package/dist/{chunk-OJT47JLR.js → chunk-JZRF3UXG.js} +7 -7
  5. package/dist/chunk-MAIWMWV7.js +448 -0
  6. package/dist/chunk-MAIWMWV7.js.map +6 -0
  7. package/dist/{chunk-LVUVBXXK.js → chunk-SQKXY43O.js} +5 -5
  8. package/dist/{chunk-MN5PENPF.js → chunk-VVXXLY65.js} +2 -2
  9. package/dist/cli.js +1 -1
  10. package/dist/{commands-3CZ5DOQA.js → commands-I5EWVOJC.js} +2 -2
  11. package/dist/{dev-command-VBAIG6EU.js → dev-command-AFVKSXJA.js} +6 -6
  12. package/dist/local-bundle.d.ts +1 -0
  13. package/dist/{local-execute-SNWFJZVF.js → local-execute-UTLV5UDA.js} +4 -4
  14. package/dist/{local-package-graph-QAKOKW2R.js → local-package-graph-F3AJFSSG.js} +2 -2
  15. package/dist/{local-package-run-RFAIV4MZ.js → local-package-run-WMGUVB3U.js} +6 -6
  16. package/dist/{mock-local-deps-Q6GG4HKA.js → mock-local-deps-HT5NG52P.js} +4 -4
  17. package/dist/publish-builder.js +190 -6
  18. package/dist/{run-executor-J3MF4RCT.js → run-executor-N5CDFAOB.js} +2 -2
  19. package/package.json +1 -1
  20. package/dist/chunk-YBO6HUV3.js +0 -214
  21. package/dist/chunk-YBO6HUV3.js.map +0 -6
  22. /package/dist/{chunk-3G4MV7KG.js.map → chunk-6KT2QEN3.js.map} +0 -0
  23. /package/dist/{chunk-PMFY674W.js.map → chunk-GMD3RXXS.js.map} +0 -0
  24. /package/dist/{chunk-OJT47JLR.js.map → chunk-JZRF3UXG.js.map} +0 -0
  25. /package/dist/{chunk-LVUVBXXK.js.map → chunk-SQKXY43O.js.map} +0 -0
  26. /package/dist/{chunk-MN5PENPF.js.map → chunk-VVXXLY65.js.map} +0 -0
  27. /package/dist/{commands-3CZ5DOQA.js.map → commands-I5EWVOJC.js.map} +0 -0
  28. /package/dist/{dev-command-VBAIG6EU.js.map → dev-command-AFVKSXJA.js.map} +0 -0
  29. /package/dist/{local-execute-SNWFJZVF.js.map → local-execute-UTLV5UDA.js.map} +0 -0
  30. /package/dist/{local-package-graph-QAKOKW2R.js.map → local-package-graph-F3AJFSSG.js.map} +0 -0
  31. /package/dist/{local-package-run-RFAIV4MZ.js.map → local-package-run-WMGUVB3U.js.map} +0 -0
  32. /package/dist/{mock-local-deps-Q6GG4HKA.js.map → mock-local-deps-HT5NG52P.js.map} +0 -0
  33. /package/dist/{run-executor-J3MF4RCT.js.map → run-executor-N5CDFAOB.js.map} +0 -0
@@ -12,7 +12,7 @@ import {
12
12
  resolveLocalPackageBinding,
13
13
  runLocalPackageModule,
14
14
  trustedDevHostFromHostedUrl
15
- } from "./chunk-LVUVBXXK.js";
15
+ } from "./chunk-SQKXY43O.js";
16
16
  import {
17
17
  publishOutsideCloudAdvice
18
18
  } from "./chunk-ZUVFYLZA.js";
@@ -21,7 +21,7 @@ import {
21
21
  forwardLocalGatewayFetchStream,
22
22
  installMockFetchShimModules,
23
23
  startLocalRuntimeBridge
24
- } from "./chunk-MN5PENPF.js";
24
+ } from "./chunk-VVXXLY65.js";
25
25
  import {
26
26
  ensureMockTarget
27
27
  } from "./chunk-Y3GXC22T.js";
@@ -35,7 +35,7 @@ import {
35
35
  cleanWorkerdStderrLine,
36
36
  startWorkerd
37
37
  } from "./chunk-PPVTGF73.js";
38
- import "./chunk-3G4MV7KG.js";
38
+ import "./chunk-6KT2QEN3.js";
39
39
  import {
40
40
  BundleError,
41
41
  bundleInputs,
@@ -43,7 +43,7 @@ import {
43
43
  createBundleError,
44
44
  formatBundleDiagnostic,
45
45
  localBundleOptions
46
- } from "./chunk-YBO6HUV3.js";
46
+ } from "./chunk-MAIWMWV7.js";
47
47
  import {
48
48
  loadPackageManifest,
49
49
  resolveExportModulePath,
@@ -62,7 +62,7 @@ import {
62
62
  resolveLocalPackageGraph,
63
63
  runSecretEnvVar,
64
64
  writePackageModuleFiles
65
- } from "./chunk-PMFY674W.js";
65
+ } from "./chunk-GMD3RXXS.js";
66
66
  import "./chunk-F6SEQDAM.js";
67
67
  import {
68
68
  formatToolResult
@@ -5926,4 +5926,4 @@ export {
5926
5926
  chokidar/esm/index.js:
5927
5927
  (*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) *)
5928
5928
  */
5929
- //# sourceMappingURL=dev-command-VBAIG6EU.js.map
5929
+ //# sourceMappingURL=dev-command-AFVKSXJA.js.map
@@ -44,6 +44,7 @@ export declare function localBundleOptions(entry: string): {
44
44
  logLevel: "silent";
45
45
  packages: "bundle";
46
46
  external: string[];
47
+ plugins: esbuild.Plugin[];
47
48
  };
48
49
  export type LocalUserBundle = {
49
50
  code: string;
@@ -4,7 +4,7 @@ import {
4
4
  forwardLocalGatewayFetchStream,
5
5
  installMockFetchShimModules,
6
6
  startLocalRuntimeBridge
7
- } from "./chunk-MN5PENPF.js";
7
+ } from "./chunk-VVXXLY65.js";
8
8
  import {
9
9
  resolveMockFetchGateway,
10
10
  tryHandleMockGatewayFetchCall
@@ -12,7 +12,7 @@ import {
12
12
  import "./chunk-LQNGII7U.js";
13
13
  import {
14
14
  bundleLocalUserModule
15
- } from "./chunk-YBO6HUV3.js";
15
+ } from "./chunk-MAIWMWV7.js";
16
16
  import "./chunk-42R5NM3P.js";
17
17
  import {
18
18
  createLocalEntrySource,
@@ -28,7 +28,7 @@ import {
28
28
  runSecretEnvVar,
29
29
  runSecretHeader,
30
30
  writePackageModuleFiles
31
- } from "./chunk-PMFY674W.js";
31
+ } from "./chunk-GMD3RXXS.js";
32
32
  import {
33
33
  createEgressGateSource,
34
34
  egressGateModuleName,
@@ -956,4 +956,4 @@ export {
956
956
  runLocalExecute,
957
957
  savedPackageImportLocalResolveStatus
958
958
  };
959
- //# sourceMappingURL=local-execute-SNWFJZVF.js.map
959
+ //# sourceMappingURL=local-execute-UTLV5UDA.js.map
@@ -24,7 +24,7 @@ import {
24
24
  rewriteLocalModulesToPackageFacades,
25
25
  synthesizePackageGraphEntry,
26
26
  writePackageModuleFiles
27
- } from "./chunk-PMFY674W.js";
27
+ } from "./chunk-GMD3RXXS.js";
28
28
  import "./chunk-F6SEQDAM.js";
29
29
  import "./chunk-H7CJBJFA.js";
30
30
  import "./chunk-CQHQFF7B.js";
@@ -60,4 +60,4 @@ export {
60
60
  synthesizePackageGraphEntry,
61
61
  writePackageModuleFiles
62
62
  };
63
- //# sourceMappingURL=local-package-graph-QAKOKW2R.js.map
63
+ //# sourceMappingURL=local-package-graph-F3AJFSSG.js.map
@@ -4,15 +4,15 @@ import {
4
4
  packageIdMatchesLocalPackage,
5
5
  resolveLocalPackageBinding,
6
6
  runLocalPackageModule
7
- } from "./chunk-LVUVBXXK.js";
8
- import "./chunk-MN5PENPF.js";
7
+ } from "./chunk-SQKXY43O.js";
8
+ import "./chunk-VVXXLY65.js";
9
9
  import "./chunk-CB3EUH4P.js";
10
10
  import "./chunk-LQNGII7U.js";
11
- import "./chunk-3G4MV7KG.js";
12
- import "./chunk-YBO6HUV3.js";
11
+ import "./chunk-6KT2QEN3.js";
12
+ import "./chunk-MAIWMWV7.js";
13
13
  import "./chunk-EMEUJKXR.js";
14
14
  import "./chunk-42R5NM3P.js";
15
- import "./chunk-PMFY674W.js";
15
+ import "./chunk-GMD3RXXS.js";
16
16
  import "./chunk-F6SEQDAM.js";
17
17
  import "./chunk-CASGRYOF.js";
18
18
  import "./chunk-327OT6ZP.js";
@@ -31,4 +31,4 @@ export {
31
31
  resolveLocalPackageBinding,
32
32
  runLocalPackageModule
33
33
  };
34
- //# sourceMappingURL=local-package-run-RFAIV4MZ.js.map
34
+ //# sourceMappingURL=local-package-run-WMGUVB3U.js.map
@@ -4,11 +4,11 @@ import {
4
4
  parseKodyPackageSpecifier,
5
5
  resolveLocalPackageModules,
6
6
  tryLoadSelfManifest
7
- } from "./chunk-3G4MV7KG.js";
8
- import "./chunk-YBO6HUV3.js";
7
+ } from "./chunk-6KT2QEN3.js";
8
+ import "./chunk-MAIWMWV7.js";
9
9
  import "./chunk-EMEUJKXR.js";
10
10
  import "./chunk-42R5NM3P.js";
11
- import "./chunk-PMFY674W.js";
11
+ import "./chunk-GMD3RXXS.js";
12
12
  import "./chunk-F6SEQDAM.js";
13
13
  import "./chunk-H7CJBJFA.js";
14
14
  import "./chunk-CQHQFF7B.js";
@@ -24,4 +24,4 @@ export {
24
24
  resolveLocalPackageModules,
25
25
  tryLoadSelfManifest
26
26
  };
27
- //# sourceMappingURL=mock-local-deps-Q6GG4HKA.js.map
27
+ //# sourceMappingURL=mock-local-deps-HT5NG52P.js.map
@@ -185940,6 +185940,159 @@ var init_module_graph_import_rewriting = __esm({
185940
185940
  }
185941
185941
  });
185942
185942
 
185943
+ // ../shared/src/node-modules-resolution.ts
185944
+ function nodeModulesImportKind(esbuildKind) {
185945
+ return esbuildKind === "require-call" || esbuildKind === "require-resolve" ? "require" : "import";
185946
+ }
185947
+ function parseBarePackageSpecifier(specifier) {
185948
+ if (specifier.length === 0 || specifier.startsWith(".") || specifier.startsWith("/") || specifier.includes("\\") || /^[a-z][a-z0-9+.-]*:/i.test(specifier)) {
185949
+ return null;
185950
+ }
185951
+ const segments = specifier.split("/");
185952
+ const scoped = segments[0].startsWith("@");
185953
+ if (scoped && (segments.length < 2 || segments[1] === "")) return null;
185954
+ const nameSegmentCount = scoped ? 2 : 1;
185955
+ const packageName = segments.slice(0, nameSegmentCount).join("/");
185956
+ if (packageName.endsWith("/") || segments.slice(0, nameSegmentCount).includes("")) {
185957
+ return null;
185958
+ }
185959
+ const rest = segments.slice(nameSegmentCount).join("/");
185960
+ return { packageName, subpath: rest ? `./${rest}` : "." };
185961
+ }
185962
+ function listNodeModulesPackageDirectories(importerDirectory, packageName) {
185963
+ const absolute = importerDirectory.startsWith("/");
185964
+ const segments = importerDirectory.split("/").filter(Boolean);
185965
+ const lowest = /^[A-Za-z]:$/.test(segments[0] ?? "") ? 1 : 0;
185966
+ const directories = [];
185967
+ for (let depth = segments.length; depth >= lowest; depth -= 1) {
185968
+ if (depth > 0 && segments[depth - 1] === "node_modules") continue;
185969
+ const base = segments.slice(0, depth).join("/");
185970
+ const prefix2 = absolute ? `/${base}` : base;
185971
+ directories.push(
185972
+ prefix2 === "" || prefix2 === "/" ? `${prefix2}node_modules/${packageName}` : `${prefix2}/node_modules/${packageName}`
185973
+ );
185974
+ }
185975
+ return directories;
185976
+ }
185977
+ function resolveNodeModulesImport(input3) {
185978
+ const parsed = parseBarePackageSpecifier(input3.specifier);
185979
+ if (!parsed) return { kind: "not-found" };
185980
+ for (const packageDirectory of listNodeModulesPackageDirectories(
185981
+ input3.importerDirectory,
185982
+ parsed.packageName
185983
+ )) {
185984
+ const manifestSource = input3.fs.readFile(`${packageDirectory}/package.json`);
185985
+ const manifest = manifestSource == null ? null : parseManifest(manifestSource);
185986
+ if (manifest?.exports != null) {
185987
+ return resolveViaExports({
185988
+ ...input3,
185989
+ manifest,
185990
+ packageDirectory,
185991
+ packageName: parsed.packageName,
185992
+ subpath: parsed.subpath
185993
+ });
185994
+ }
185995
+ const resolved = parsed.subpath === "." ? resolveLegacyEntry(input3.fs, packageDirectory, manifest) : resolveFileOrDirectory(
185996
+ input3.fs,
185997
+ `${packageDirectory}/${parsed.subpath.slice(2)}`
185998
+ );
185999
+ if (resolved) return { kind: "resolved", path: resolved };
186000
+ }
186001
+ return { kind: "not-found" };
186002
+ }
186003
+ function parseManifest(source) {
186004
+ try {
186005
+ const parsed = JSON.parse(source);
186006
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
186007
+ } catch {
186008
+ return null;
186009
+ }
186010
+ }
186011
+ function resolveViaExports(input3) {
186012
+ let targets;
186013
+ try {
186014
+ targets = o2(
186015
+ { ...input3.manifest, name: input3.packageName },
186016
+ input3.subpath,
186017
+ {
186018
+ conditions: [input3.kind, ...nodeModulesExportConditions],
186019
+ unsafe: true
186020
+ }
186021
+ );
186022
+ } catch (error2) {
186023
+ return {
186024
+ kind: "error",
186025
+ message: `Could not resolve "${input3.specifier}" from "${input3.packageDirectory}": ${error2 instanceof Error ? error2.message : String(error2)}`
186026
+ };
186027
+ }
186028
+ for (const target of targets ?? []) {
186029
+ const path = normalizeJoin(input3.packageDirectory, target);
186030
+ if (path && input3.fs.fileExists(path)) return { kind: "resolved", path };
186031
+ }
186032
+ return {
186033
+ kind: "error",
186034
+ message: `Could not resolve "${input3.specifier}": "${input3.packageDirectory}/package.json" exports ${JSON.stringify(
186035
+ input3.subpath
186036
+ )} to a file that does not exist.`
186037
+ };
186038
+ }
186039
+ function resolveLegacyEntry(fs, packageDirectory, manifest) {
186040
+ for (const field of legacyEntryFields) {
186041
+ const entry = manifest?.[field];
186042
+ if (typeof entry !== "string" || entry.trim() === "") continue;
186043
+ const path = normalizeJoin(packageDirectory, entry);
186044
+ const resolved = path ? resolveFileOrDirectory(fs, path) : null;
186045
+ if (resolved) return resolved;
186046
+ }
186047
+ return resolveFileOrDirectory(fs, `${packageDirectory}/index`);
186048
+ }
186049
+ function resolveFileOrDirectory(fs, path) {
186050
+ const trimmed = path.replace(/\/+$/, "");
186051
+ if (fs.fileExists(trimmed) && path === trimmed) return trimmed;
186052
+ for (const extension of nodeModulesResolveExtensions) {
186053
+ if (fs.fileExists(`${trimmed}${extension}`)) return `${trimmed}${extension}`;
186054
+ }
186055
+ for (const extension of nodeModulesResolveExtensions) {
186056
+ const index = `${trimmed}/index${extension}`;
186057
+ if (fs.fileExists(index)) return index;
186058
+ }
186059
+ return null;
186060
+ }
186061
+ function normalizeJoin(directory, relativePath2) {
186062
+ const absolute = directory.startsWith("/");
186063
+ const segments = directory.split("/").filter(Boolean);
186064
+ const floor = segments.length;
186065
+ for (const segment of relativePath2.split("/")) {
186066
+ if (segment === "" || segment === ".") continue;
186067
+ if (segment === "..") {
186068
+ if (segments.length <= floor) return null;
186069
+ segments.pop();
186070
+ continue;
186071
+ }
186072
+ segments.push(segment);
186073
+ }
186074
+ const joined = segments.join("/");
186075
+ return absolute ? `/${joined}` : joined;
186076
+ }
186077
+ var nodeModulesExportConditions, nodeModulesResolveExtensions, legacyEntryFields;
186078
+ var init_node_modules_resolution = __esm({
186079
+ "../shared/src/node-modules-resolution.ts"() {
186080
+ "use strict";
186081
+ init_dist2();
186082
+ nodeModulesExportConditions = ["browser", "node"];
186083
+ nodeModulesResolveExtensions = [
186084
+ ".ts",
186085
+ ".tsx",
186086
+ ".js",
186087
+ ".jsx",
186088
+ ".mts",
186089
+ ".mjs",
186090
+ ".json"
186091
+ ];
186092
+ legacyEntryFields = ["module", "main"];
186093
+ }
186094
+ });
186095
+
185943
186096
  // ../worker/src/package-runtime/package-bundle-node-modules.ts
185944
186097
  function assertNoPlatformSuppliedNodeModules(input3) {
185945
186098
  const injected = Object.keys(input3.bundlerFiles).filter(
@@ -185952,9 +186105,40 @@ function assertNoPlatformSuppliedNodeModules(input3) {
185952
186105
  `${input3.bundleLabel} includes node_modules paths the package snapshot does not contain (${preview}${more}). Kody does not supply third-party modules to package bundles; declare and install dependencies in the package instead.`
185953
186106
  );
185954
186107
  }
186108
+ function createNodeModulesResolutionPlugin(files) {
186109
+ const fs = {
186110
+ readFile: (path) => files[path] ?? null,
186111
+ fileExists: (path) => Object.hasOwn(files, path)
186112
+ };
186113
+ return {
186114
+ name: "kody-node-modules-resolution",
186115
+ setup(build2) {
186116
+ build2.onResolve({ filter: /^[^./]/ }, (args) => {
186117
+ if (args.kind === "entry-point") return;
186118
+ const resolution = resolveNodeModulesImport({
186119
+ specifier: args.path,
186120
+ importerDirectory: normalizeWorkspaceModulePath(
186121
+ args.resolveDir ?? ""
186122
+ ),
186123
+ kind: nodeModulesImportKind(args.kind),
186124
+ fs
186125
+ });
186126
+ if (resolution.kind === "resolved") {
186127
+ return { path: resolution.path, namespace: "virtual" };
186128
+ }
186129
+ if (resolution.kind === "error") {
186130
+ return { errors: [{ text: resolution.message }] };
186131
+ }
186132
+ return void 0;
186133
+ });
186134
+ }
186135
+ };
186136
+ }
185955
186137
  var init_package_bundle_node_modules = __esm({
185956
186138
  "../worker/src/package-runtime/package-bundle-node-modules.ts"() {
185957
186139
  "use strict";
186140
+ init_node_modules_resolution();
186141
+ init_module_graph_path_basics();
185958
186142
  }
185959
186143
  });
185960
186144
 
@@ -186170,7 +186354,8 @@ async function createWorkerBundle(input3) {
186170
186354
  ...createPackageAppJsxBundleOptions(snapshotFiles),
186171
186355
  __dangerouslyUseEsBuildPluginsDoNotUseOrYouWillBeFired: [
186172
186356
  kodyRuntimeExternalsPlugin,
186173
- ...input3.linkKodyPackageImports ? [kodyLinkedPackageImportsPlugin] : []
186357
+ ...input3.linkKodyPackageImports ? [kodyLinkedPackageImportsPlugin] : [],
186358
+ createNodeModulesResolutionPlugin(input3.files)
186174
186359
  ]
186175
186360
  });
186176
186361
  }
@@ -186621,11 +186806,10 @@ async function buildKodyAppClientBundle(input3) {
186621
186806
  bundle: true,
186622
186807
  target: "es2022",
186623
186808
  ...createPackageAppJsxBundleOptions(input3.sourceFiles),
186624
- ...externals.length > 0 ? {
186625
- __dangerouslyUseEsBuildPluginsDoNotUseOrYouWillBeFired: [
186626
- createClientExternalsPlugin(externals)
186627
- ]
186628
- } : {}
186809
+ __dangerouslyUseEsBuildPluginsDoNotUseOrYouWillBeFired: [
186810
+ ...externals.length > 0 ? [createClientExternalsPlugin(externals)] : [],
186811
+ createNodeModulesResolutionPlugin(files)
186812
+ ]
186629
186813
  });
186630
186814
  const bundledModule = bundle.modules[bundle.mainModule];
186631
186815
  const source = typeof bundledModule === "string" ? bundledModule : typeof bundledModule?.js === "string" ? bundledModule.js : null;
@@ -38,7 +38,7 @@ async function runContextRun(input) {
38
38
  }
39
39
  }
40
40
  const hostCommands = input.hostCommands;
41
- const { runLocalExecute } = await import("./local-execute-SNWFJZVF.js");
41
+ const { runLocalExecute } = await import("./local-execute-UTLV5UDA.js");
42
42
  let timing;
43
43
  const result = await runLocalExecute({
44
44
  code: source.code,
@@ -85,4 +85,4 @@ async function runContextRun(input) {
85
85
  export {
86
86
  runContextRun
87
87
  };
88
- //# sourceMappingURL=run-executor-J3MF4RCT.js.map
88
+ //# sourceMappingURL=run-executor-N5CDFAOB.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kodycodes/cli",
3
- "version": "3.31.3",
3
+ "version": "3.31.4",
4
4
  "description": "Official Kody CLI: login, secure token storage, search, and execute over the OpenAPI.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,214 +0,0 @@
1
- import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
-
3
- // src/local-bundle.ts
4
- import * as esbuild from "esbuild";
5
- import { relative, resolve } from "node:path";
6
- var BundleError = class extends Error {
7
- diagnostics;
8
- constructor(message, diagnostics) {
9
- super(message);
10
- this.name = "BundleError";
11
- this.diagnostics = diagnostics;
12
- }
13
- };
14
- var nodeBuiltinModuleNames = [
15
- "_http_agent",
16
- "_http_client",
17
- "_http_common",
18
- "_http_incoming",
19
- "_http_outgoing",
20
- "_http_server",
21
- "_stream_duplex",
22
- "_stream_passthrough",
23
- "_stream_readable",
24
- "_stream_transform",
25
- "_stream_wrap",
26
- "_stream_writable",
27
- "_tls_common",
28
- "_tls_wrap",
29
- "assert",
30
- "async_hooks",
31
- "buffer",
32
- "child_process",
33
- "cluster",
34
- "console",
35
- "constants",
36
- "crypto",
37
- "dgram",
38
- "diagnostics_channel",
39
- "dns",
40
- "domain",
41
- "events",
42
- "fs",
43
- "http",
44
- "http2",
45
- "https",
46
- "inspector",
47
- "module",
48
- "net",
49
- "os",
50
- "path",
51
- "perf_hooks",
52
- "process",
53
- "punycode",
54
- "querystring",
55
- "readline",
56
- "repl",
57
- "stream",
58
- "string_decoder",
59
- "sys",
60
- "timers",
61
- "tls",
62
- "trace_events",
63
- "tty",
64
- "url",
65
- "util",
66
- "v8",
67
- "vm",
68
- "wasi",
69
- "worker_threads",
70
- "zlib"
71
- ];
72
- function bundleInputs(metafile, workingDir) {
73
- return Object.keys(metafile?.inputs ?? {}).filter((path) => {
74
- if (path.includes(":") && !/^[A-Za-z]:[\\/]/.test(path)) return false;
75
- return !path.split(/[/\\]/).includes("node_modules");
76
- }).map((path) => resolve(workingDir, path));
77
- }
78
- function localBundleOptions(entry) {
79
- return {
80
- absWorkingDir: process.cwd(),
81
- entryPoints: [entry],
82
- bundle: true,
83
- write: false,
84
- format: "esm",
85
- platform: "neutral",
86
- target: "esnext",
87
- logLevel: "silent",
88
- packages: "bundle",
89
- external: [
90
- "kody:*",
91
- "node:*",
92
- ...nodeBuiltinModuleNames.flatMap((name) => [name, `${name}/*`])
93
- ]
94
- };
95
- }
96
- async function bundleLocalUserModuleWithInputs(modulePath) {
97
- const entry = resolve(modulePath);
98
- const options = { ...localBundleOptions(entry), metafile: true };
99
- let result;
100
- try {
101
- result = await esbuild.build(options);
102
- } catch (error) {
103
- throw createBundleError(modulePath, error);
104
- }
105
- const output = result.outputFiles?.[0];
106
- if (output === void 0) {
107
- throw new BundleError(
108
- `Could not bundle ${modulePath}: esbuild produced no output.`,
109
- []
110
- );
111
- }
112
- if (result.errors.length > 0) {
113
- throw createBundleError(modulePath, { errors: result.errors });
114
- }
115
- return {
116
- code: output.text,
117
- inputs: bundleInputs(result.metafile, options.absWorkingDir)
118
- };
119
- }
120
- async function bundleLocalUserModule(modulePath) {
121
- return (await bundleLocalUserModuleWithInputs(modulePath)).code;
122
- }
123
- function createBundleError(modulePath, error, paths = {
124
- workingDir: process.cwd(),
125
- displayRoot: process.cwd()
126
- }) {
127
- const diagnostics = bundleDiagnostics(error, paths);
128
- const details = diagnostics.map(formatBundleDiagnostic).join("\n");
129
- const header = `Could not bundle ${modulePath}.`;
130
- const body = details.length > 0 ? `${header}
131
- ${details}` : header;
132
- const messages = diagnostics.map((item) => item.message).join("\n");
133
- if (/Could not resolve ["']kody:@/i.test(messages)) {
134
- return new BundleError(
135
- `${body}
136
- fix: Map the dependency in .kody/deps.json (or package.json#kody.localDeps), keep it in this package's exports, or log in so published package-graph can supply it.`,
137
- diagnostics
138
- );
139
- }
140
- if (/Could not resolve|Cannot find module|ENOENT/i.test(body)) {
141
- return new BundleError(
142
- `${body}
143
- fix: Run \`npm install\` in the package directory (and any local deps), then retry.`,
144
- diagnostics
145
- );
146
- }
147
- return new BundleError(body, diagnostics);
148
- }
149
- function formatBundleDiagnostic(item) {
150
- const where = item.file !== null ? `${item.file}${item.line !== null ? `:${item.line}` : ""}${item.col !== null ? `:${item.col}` : ""}: ` : "";
151
- return `${where}${item.message}${item.frame ? `
152
- ${item.frame}` : ""}`;
153
- }
154
- function bundleDiagnostics(error, paths) {
155
- if (isEsbuildFailure(error)) {
156
- return error.errors.filter((item) => item.text.trim().length > 0).map((item) => toDiagnostic(item, paths));
157
- }
158
- return [
159
- {
160
- file: null,
161
- line: null,
162
- col: null,
163
- message: error instanceof Error ? error.message : String(error),
164
- frame: null
165
- }
166
- ];
167
- }
168
- function toDiagnostic(item, paths) {
169
- const location = item.location;
170
- if (!location) {
171
- return {
172
- file: null,
173
- line: null,
174
- col: null,
175
- message: item.text.trim(),
176
- frame: null
177
- };
178
- }
179
- const absolute = resolve(paths.workingDir, location.file);
180
- const fromRoot = relative(paths.displayRoot, absolute);
181
- const file = fromRoot && !fromRoot.startsWith("..") ? fromRoot : absolute;
182
- return {
183
- file,
184
- line: location.line,
185
- col: location.column + 1,
186
- message: item.text.trim(),
187
- frame: codeFrame(location)
188
- };
189
- }
190
- function codeFrame(location) {
191
- if (!location.lineText) return null;
192
- const gutter = String(location.line);
193
- const pad = " ".repeat(gutter.length);
194
- const caretWidth = Math.max(
195
- 1,
196
- Math.min(location.length || 1, location.lineText.length)
197
- );
198
- return ` ${gutter} | ${location.lineText}
199
- ${pad} | ${" ".repeat(location.column)}${"^".repeat(caretWidth)}`;
200
- }
201
- function isEsbuildFailure(error) {
202
- return typeof error === "object" && error !== null && "errors" in error && Array.isArray(error.errors);
203
- }
204
-
205
- export {
206
- BundleError,
207
- bundleInputs,
208
- localBundleOptions,
209
- bundleLocalUserModuleWithInputs,
210
- bundleLocalUserModule,
211
- createBundleError,
212
- formatBundleDiagnostic
213
- };
214
- //# sourceMappingURL=chunk-YBO6HUV3.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/local-bundle.ts"],
4
- "mappings": ";;;AAAA,YAAY,aAAa;AACzB,SAAS,UAAU,eAAe;AAc3B,IAAM,cAAN,cAA0B,MAAM;AAAA,EAC7B;AAAA,EACT,YAAY,SAAiB,aAAsC;AAClE,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,cAAc;AAAA,EACpB;AACD;AASO,IAAM,yBAAyB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAMO,SAAS,aACf,UACA,YACgB;AAChB,SAAO,OA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