thinkwell 0.5.5 → 0.5.7
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/agent.d.ts.map +1 -1
- package/dist/agent.js +232 -278
- package/dist/agent.js.map +1 -1
- package/dist/build.js +44 -98
- package/dist/cli/build.js +92 -227
- package/dist/cli/bundle.js +570 -1136
- package/dist/cli/check.js +125 -214
- package/dist/cli/commands.js +63 -177
- package/dist/cli/compiler-host.js +81 -190
- package/dist/cli/dependency-check.js +125 -269
- package/dist/cli/dependency-errors.js +12 -84
- package/dist/cli/fmt.js +1 -13
- package/dist/cli/init-command.js +21 -68
- package/dist/cli/init.js +90 -220
- package/dist/cli/loader.js +95 -361
- package/dist/cli/new-command.js +25 -73
- package/dist/cli/package-manager.js +50 -117
- package/dist/cli/schema.d.ts.map +1 -1
- package/dist/cli/schema.js +91 -245
- package/dist/cli/schema.js.map +1 -1
- package/dist/cli/workspace.js +92 -226
- package/dist/connectors/index.js +1 -7
- package/dist/generated/features.d.ts +6 -0
- package/dist/generated/features.d.ts.map +1 -0
- package/dist/generated/features.js +5 -0
- package/dist/generated/features.js.map +1 -0
- package/dist/index.js +0 -5
- package/dist/schema.js +3 -36
- package/dist/session.js +50 -82
- package/dist/think-builder.d.ts.map +1 -1
- package/dist/think-builder.js +287 -368
- package/dist/think-builder.js.map +1 -1
- package/dist/thought-event.d.ts +1 -0
- package/dist/thought-event.d.ts.map +1 -1
- package/dist/thought-event.js +0 -1
- package/dist/thought-stream.js +60 -96
- package/dist-pkg/acp.cjs +13386 -1876
- package/dist-pkg/cli-build.cjs +264 -446
- package/dist-pkg/cli-bundle.cjs +433 -818
- package/dist-pkg/cli-check.cjs +302 -499
- package/dist-pkg/cli-dependency-check.cjs +39 -82
- package/dist-pkg/cli-dependency-errors.cjs +9 -41
- package/dist-pkg/cli-loader.cjs +91 -173
- package/dist-pkg/protocol.cjs +2 -8
- package/dist-pkg/thinkwell.cjs +927 -1846
- package/package.json +9 -7
package/dist-pkg/cli-bundle.cjs
CHANGED
|
@@ -973,7 +973,7 @@ is not a problem with esbuild. You need to fix your environment instead.
|
|
|
973
973
|
let latestResultPromise;
|
|
974
974
|
let provideLatestResult;
|
|
975
975
|
if (isContext)
|
|
976
|
-
requestCallbacks["on-end"] = (id, request2) => new Promise((
|
|
976
|
+
requestCallbacks["on-end"] = (id, request2) => new Promise((resolve3) => {
|
|
977
977
|
buildResponseToResult(request2, (err, result, onEndErrors, onEndWarnings) => {
|
|
978
978
|
const response = {
|
|
979
979
|
errors: onEndErrors,
|
|
@@ -983,7 +983,7 @@ is not a problem with esbuild. You need to fix your environment instead.
|
|
|
983
983
|
latestResultPromise = void 0;
|
|
984
984
|
provideLatestResult = void 0;
|
|
985
985
|
sendResponse(id, response);
|
|
986
|
-
|
|
986
|
+
resolve3();
|
|
987
987
|
});
|
|
988
988
|
});
|
|
989
989
|
sendRequest(refs, request, (error, response) => {
|
|
@@ -1000,10 +1000,10 @@ is not a problem with esbuild. You need to fix your environment instead.
|
|
|
1000
1000
|
let didDispose = false;
|
|
1001
1001
|
const result = {
|
|
1002
1002
|
rebuild: /* @__PURE__ */ __name(() => {
|
|
1003
|
-
if (!latestResultPromise) latestResultPromise = new Promise((
|
|
1003
|
+
if (!latestResultPromise) latestResultPromise = new Promise((resolve3, reject) => {
|
|
1004
1004
|
let settlePromise;
|
|
1005
1005
|
provideLatestResult = /* @__PURE__ */ __name((err, result2) => {
|
|
1006
|
-
if (!settlePromise) settlePromise = /* @__PURE__ */ __name(() => err ? reject(err) :
|
|
1006
|
+
if (!settlePromise) settlePromise = /* @__PURE__ */ __name(() => err ? reject(err) : resolve3(result2), "settlePromise");
|
|
1007
1007
|
}, "provideLatestResult");
|
|
1008
1008
|
const triggerAnotherBuild = /* @__PURE__ */ __name(() => {
|
|
1009
1009
|
const request2 = {
|
|
@@ -1024,7 +1024,7 @@ is not a problem with esbuild. You need to fix your environment instead.
|
|
|
1024
1024
|
});
|
|
1025
1025
|
return latestResultPromise;
|
|
1026
1026
|
}, "rebuild"),
|
|
1027
|
-
watch: /* @__PURE__ */ __name((options2 = {}) => new Promise((
|
|
1027
|
+
watch: /* @__PURE__ */ __name((options2 = {}) => new Promise((resolve3, reject) => {
|
|
1028
1028
|
if (!streamIn.hasFS) throw new Error(`Cannot use the "watch" API in this environment`);
|
|
1029
1029
|
const keys = {};
|
|
1030
1030
|
const delay = getFlag(options2, keys, "delay", mustBeInteger);
|
|
@@ -1036,10 +1036,10 @@ is not a problem with esbuild. You need to fix your environment instead.
|
|
|
1036
1036
|
if (delay) request2.delay = delay;
|
|
1037
1037
|
sendRequest(refs, request2, (error2) => {
|
|
1038
1038
|
if (error2) reject(new Error(error2));
|
|
1039
|
-
else
|
|
1039
|
+
else resolve3(void 0);
|
|
1040
1040
|
});
|
|
1041
1041
|
}), "watch"),
|
|
1042
|
-
serve: /* @__PURE__ */ __name((options2 = {}) => new Promise((
|
|
1042
|
+
serve: /* @__PURE__ */ __name((options2 = {}) => new Promise((resolve3, reject) => {
|
|
1043
1043
|
if (!streamIn.hasFS) throw new Error(`Cannot use the "serve" API in this environment`);
|
|
1044
1044
|
const keys = {};
|
|
1045
1045
|
const port = getFlag(options2, keys, "port", mustBeValidPortNumber);
|
|
@@ -1077,28 +1077,28 @@ is not a problem with esbuild. You need to fix your environment instead.
|
|
|
1077
1077
|
sendResponse(id, {});
|
|
1078
1078
|
};
|
|
1079
1079
|
}
|
|
1080
|
-
|
|
1080
|
+
resolve3(response2);
|
|
1081
1081
|
});
|
|
1082
1082
|
}), "serve"),
|
|
1083
|
-
cancel: /* @__PURE__ */ __name(() => new Promise((
|
|
1084
|
-
if (didDispose) return
|
|
1083
|
+
cancel: /* @__PURE__ */ __name(() => new Promise((resolve3) => {
|
|
1084
|
+
if (didDispose) return resolve3();
|
|
1085
1085
|
const request2 = {
|
|
1086
1086
|
command: "cancel",
|
|
1087
1087
|
key: buildKey
|
|
1088
1088
|
};
|
|
1089
1089
|
sendRequest(refs, request2, () => {
|
|
1090
|
-
|
|
1090
|
+
resolve3();
|
|
1091
1091
|
});
|
|
1092
1092
|
}), "cancel"),
|
|
1093
|
-
dispose: /* @__PURE__ */ __name(() => new Promise((
|
|
1094
|
-
if (didDispose) return
|
|
1093
|
+
dispose: /* @__PURE__ */ __name(() => new Promise((resolve3) => {
|
|
1094
|
+
if (didDispose) return resolve3();
|
|
1095
1095
|
didDispose = true;
|
|
1096
1096
|
const request2 = {
|
|
1097
1097
|
command: "dispose",
|
|
1098
1098
|
key: buildKey
|
|
1099
1099
|
};
|
|
1100
1100
|
sendRequest(refs, request2, () => {
|
|
1101
|
-
|
|
1101
|
+
resolve3();
|
|
1102
1102
|
scheduleOnDisposeCallbacks();
|
|
1103
1103
|
refs.unref();
|
|
1104
1104
|
});
|
|
@@ -1139,7 +1139,7 @@ is not a problem with esbuild. You need to fix your environment instead.
|
|
|
1139
1139
|
onLoad: []
|
|
1140
1140
|
};
|
|
1141
1141
|
i++;
|
|
1142
|
-
let
|
|
1142
|
+
let resolve3 = /* @__PURE__ */ __name((path3, options = {}) => {
|
|
1143
1143
|
if (!isSetupDone) throw new Error('Cannot call "resolve" before plugin setup has completed');
|
|
1144
1144
|
if (typeof path3 !== "string") throw new Error(`The path to resolve must be a string`);
|
|
1145
1145
|
let keys2 = /* @__PURE__ */ Object.create(null);
|
|
@@ -1183,7 +1183,7 @@ is not a problem with esbuild. You need to fix your environment instead.
|
|
|
1183
1183
|
}, "resolve");
|
|
1184
1184
|
let promise = setup({
|
|
1185
1185
|
initialOptions,
|
|
1186
|
-
resolve:
|
|
1186
|
+
resolve: resolve3,
|
|
1187
1187
|
onStart(callback) {
|
|
1188
1188
|
let registeredText = `This error came from the "onStart" callback registered here:`;
|
|
1189
1189
|
let registeredNote = extractCallerV8(new Error(registeredText), streamIn, "onStart");
|
|
@@ -2077,46 +2077,46 @@ More information: The file containing the code for esbuild's JavaScript API (${_
|
|
|
2077
2077
|
}
|
|
2078
2078
|
};
|
|
2079
2079
|
longLivedService = {
|
|
2080
|
-
build: /* @__PURE__ */ __name((options) => new Promise((
|
|
2080
|
+
build: /* @__PURE__ */ __name((options) => new Promise((resolve3, reject) => {
|
|
2081
2081
|
service.buildOrContext({
|
|
2082
2082
|
callName: "build",
|
|
2083
2083
|
refs,
|
|
2084
2084
|
options,
|
|
2085
2085
|
isTTY: isTTY(),
|
|
2086
2086
|
defaultWD,
|
|
2087
|
-
callback: /* @__PURE__ */ __name((err, res) => err ? reject(err) :
|
|
2087
|
+
callback: /* @__PURE__ */ __name((err, res) => err ? reject(err) : resolve3(res), "callback")
|
|
2088
2088
|
});
|
|
2089
2089
|
}), "build"),
|
|
2090
|
-
context: /* @__PURE__ */ __name((options) => new Promise((
|
|
2090
|
+
context: /* @__PURE__ */ __name((options) => new Promise((resolve3, reject) => service.buildOrContext({
|
|
2091
2091
|
callName: "context",
|
|
2092
2092
|
refs,
|
|
2093
2093
|
options,
|
|
2094
2094
|
isTTY: isTTY(),
|
|
2095
2095
|
defaultWD,
|
|
2096
|
-
callback: /* @__PURE__ */ __name((err, res) => err ? reject(err) :
|
|
2096
|
+
callback: /* @__PURE__ */ __name((err, res) => err ? reject(err) : resolve3(res), "callback")
|
|
2097
2097
|
})), "context"),
|
|
2098
|
-
transform: /* @__PURE__ */ __name((input, options) => new Promise((
|
|
2098
|
+
transform: /* @__PURE__ */ __name((input, options) => new Promise((resolve3, reject) => service.transform({
|
|
2099
2099
|
callName: "transform",
|
|
2100
2100
|
refs,
|
|
2101
2101
|
input,
|
|
2102
2102
|
options: options || {},
|
|
2103
2103
|
isTTY: isTTY(),
|
|
2104
2104
|
fs: fsAsync,
|
|
2105
|
-
callback: /* @__PURE__ */ __name((err, res) => err ? reject(err) :
|
|
2105
|
+
callback: /* @__PURE__ */ __name((err, res) => err ? reject(err) : resolve3(res), "callback")
|
|
2106
2106
|
})), "transform"),
|
|
2107
|
-
formatMessages: /* @__PURE__ */ __name((messages, options) => new Promise((
|
|
2107
|
+
formatMessages: /* @__PURE__ */ __name((messages, options) => new Promise((resolve3, reject) => service.formatMessages({
|
|
2108
2108
|
callName: "formatMessages",
|
|
2109
2109
|
refs,
|
|
2110
2110
|
messages,
|
|
2111
2111
|
options,
|
|
2112
|
-
callback: /* @__PURE__ */ __name((err, res) => err ? reject(err) :
|
|
2112
|
+
callback: /* @__PURE__ */ __name((err, res) => err ? reject(err) : resolve3(res), "callback")
|
|
2113
2113
|
})), "formatMessages"),
|
|
2114
|
-
analyzeMetafile: /* @__PURE__ */ __name((metafile, options) => new Promise((
|
|
2114
|
+
analyzeMetafile: /* @__PURE__ */ __name((metafile, options) => new Promise((resolve3, reject) => service.analyzeMetafile({
|
|
2115
2115
|
callName: "analyzeMetafile",
|
|
2116
2116
|
refs,
|
|
2117
2117
|
metafile: typeof metafile === "string" ? metafile : JSON.stringify(metafile),
|
|
2118
2118
|
options,
|
|
2119
|
-
callback: /* @__PURE__ */ __name((err, res) => err ? reject(err) :
|
|
2119
|
+
callback: /* @__PURE__ */ __name((err, res) => err ? reject(err) : resolve3(res), "callback")
|
|
2120
2120
|
})), "analyzeMetafile")
|
|
2121
2121
|
};
|
|
2122
2122
|
return longLivedService;
|
|
@@ -2194,13 +2194,13 @@ error: ${text}`);
|
|
|
2194
2194
|
worker.postMessage(msg);
|
|
2195
2195
|
let status = Atomics.wait(sharedBufferView, 0, 0);
|
|
2196
2196
|
if (status !== "ok" && status !== "not-equal") throw new Error("Internal error: Atomics.wait() failed: " + status);
|
|
2197
|
-
let { message: { id: id2, resolve:
|
|
2197
|
+
let { message: { id: id2, resolve: resolve3, reject, properties } } = worker_threads2.receiveMessageOnPort(mainPort);
|
|
2198
2198
|
if (id !== id2) throw new Error(`Internal error: Expected id ${id} but got id ${id2}`);
|
|
2199
2199
|
if (reject) {
|
|
2200
2200
|
applyProperties(reject, properties);
|
|
2201
2201
|
throw reject;
|
|
2202
2202
|
}
|
|
2203
|
-
return
|
|
2203
|
+
return resolve3;
|
|
2204
2204
|
}, "runCallSync");
|
|
2205
2205
|
worker.unref();
|
|
2206
2206
|
return {
|
|
@@ -2781,16 +2781,16 @@ var require_typescript = __commonJS({
|
|
|
2781
2781
|
var tsp;
|
|
2782
2782
|
(function(tsp2) {
|
|
2783
2783
|
const activeProgramTransformers = /* @__PURE__ */ new Set();
|
|
2784
|
-
const { dirname:
|
|
2784
|
+
const { dirname: dirname5 } = require("path");
|
|
2785
2785
|
function getProjectDir(compilerOptions) {
|
|
2786
|
-
return compilerOptions.configFilePath &&
|
|
2786
|
+
return compilerOptions.configFilePath && dirname5(compilerOptions.configFilePath);
|
|
2787
2787
|
}
|
|
2788
2788
|
__name(getProjectDir, "getProjectDir");
|
|
2789
2789
|
function getProjectConfig(compilerOptions, rootFileNames) {
|
|
2790
2790
|
let configFilePath = compilerOptions.configFilePath;
|
|
2791
2791
|
let projectDir = getProjectDir(compilerOptions);
|
|
2792
2792
|
if (configFilePath === void 0) {
|
|
2793
|
-
const baseDir = rootFileNames.length > 0 ?
|
|
2793
|
+
const baseDir = rootFileNames.length > 0 ? dirname5(rootFileNames[0]) : projectDir ?? process.cwd();
|
|
2794
2794
|
configFilePath = tsp2.tsShim.findConfigFile(baseDir, tsp2.tsShim.sys.fileExists);
|
|
2795
2795
|
if (configFilePath) {
|
|
2796
2796
|
const config = readConfig(configFilePath);
|
|
@@ -2802,7 +2802,7 @@ var require_typescript = __commonJS({
|
|
|
2802
2802
|
}
|
|
2803
2803
|
__name(getProjectConfig, "getProjectConfig");
|
|
2804
2804
|
function readConfig(configFileNamePath) {
|
|
2805
|
-
const projectDir =
|
|
2805
|
+
const projectDir = dirname5(configFileNamePath);
|
|
2806
2806
|
const result = tsp2.tsShim.readConfigFile(configFileNamePath, tsp2.tsShim.sys.readFile);
|
|
2807
2807
|
if (result.error)
|
|
2808
2808
|
throw new tsp2.TsPatchError("Error in tsconfig.json: " + result.error.messageText);
|
|
@@ -133711,7 +133711,7 @@ ${lanes.join("\n")}
|
|
|
133711
133711
|
}
|
|
133712
133712
|
__name(createImportCallExpressionUMD, "createImportCallExpressionUMD");
|
|
133713
133713
|
function createImportCallExpressionAMD(arg, containsLexicalThis) {
|
|
133714
|
-
const
|
|
133714
|
+
const resolve3 = factory2.createUniqueName("resolve");
|
|
133715
133715
|
const reject = factory2.createUniqueName("reject");
|
|
133716
133716
|
const parameters = [
|
|
133717
133717
|
factory2.createParameterDeclaration(
|
|
@@ -133720,7 +133720,7 @@ ${lanes.join("\n")}
|
|
|
133720
133720
|
/*dotDotDotToken*/
|
|
133721
133721
|
void 0,
|
|
133722
133722
|
/*name*/
|
|
133723
|
-
|
|
133723
|
+
resolve3
|
|
133724
133724
|
),
|
|
133725
133725
|
factory2.createParameterDeclaration(
|
|
133726
133726
|
/*modifiers*/
|
|
@@ -133737,7 +133737,7 @@ ${lanes.join("\n")}
|
|
|
133737
133737
|
factory2.createIdentifier("require"),
|
|
133738
133738
|
/*typeArguments*/
|
|
133739
133739
|
void 0,
|
|
133740
|
-
[factory2.createArrayLiteralExpression([arg || factory2.createOmittedExpression()]),
|
|
133740
|
+
[factory2.createArrayLiteralExpression([arg || factory2.createOmittedExpression()]), resolve3, reject]
|
|
133741
133741
|
)
|
|
133742
133742
|
)
|
|
133743
133743
|
]);
|
|
@@ -147273,10 +147273,10 @@ ${lanes.join("\n")}
|
|
|
147273
147273
|
/*ignoreCase*/
|
|
147274
147274
|
false
|
|
147275
147275
|
)) {
|
|
147276
|
-
const
|
|
147277
|
-
if (
|
|
147276
|
+
const basename3 = getBaseFileName(a.fileName);
|
|
147277
|
+
if (basename3 === "lib.d.ts" || basename3 === "lib.es6.d.ts")
|
|
147278
147278
|
return 0;
|
|
147279
|
-
const name = removeSuffix(removePrefix(
|
|
147279
|
+
const name = removeSuffix(removePrefix(basename3, "lib."), ".d.ts");
|
|
147280
147280
|
const index = libs.indexOf(name);
|
|
147281
147281
|
if (index !== -1)
|
|
147282
147282
|
return index + 1;
|
|
@@ -214049,8 +214049,8 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
214049
214049
|
}
|
|
214050
214050
|
}, "createProjectWatcher");
|
|
214051
214051
|
for (const file of files) {
|
|
214052
|
-
const
|
|
214053
|
-
if (
|
|
214052
|
+
const basename3 = getBaseFileName(file);
|
|
214053
|
+
if (basename3 === "package.json" || basename3 === "bower.json") {
|
|
214054
214054
|
createProjectWatcher(
|
|
214055
214055
|
file,
|
|
214056
214056
|
"FileWatcher"
|
|
@@ -217796,8 +217796,8 @@ All files are: ${JSON.stringify(names)}`,
|
|
|
217796
217796
|
var _a;
|
|
217797
217797
|
const fileOrDirectoryPath = removeIgnoredPath(this.toPath(fileOrDirectory));
|
|
217798
217798
|
if (!fileOrDirectoryPath) return;
|
|
217799
|
-
const
|
|
217800
|
-
if (((_a = result.affectedModuleSpecifierCacheProjects) == null ? void 0 : _a.size) && (
|
|
217799
|
+
const basename3 = getBaseFileName(fileOrDirectoryPath);
|
|
217800
|
+
if (((_a = result.affectedModuleSpecifierCacheProjects) == null ? void 0 : _a.size) && (basename3 === "package.json" || basename3 === "node_modules")) {
|
|
217801
217801
|
result.affectedModuleSpecifierCacheProjects.forEach((project) => {
|
|
217802
217802
|
var _a2;
|
|
217803
217803
|
(_a2 = project.getModuleSpecifierCache()) == null ? void 0 : _a2.clear();
|
|
@@ -224383,8 +224383,8 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
|
|
|
224383
224383
|
installPackage(options) {
|
|
224384
224384
|
this.packageInstallId++;
|
|
224385
224385
|
const request = { kind: "installPackage", ...options, id: this.packageInstallId };
|
|
224386
|
-
const promise = new Promise((
|
|
224387
|
-
(this.packageInstalledPromise ?? (this.packageInstalledPromise = /* @__PURE__ */ new Map())).set(this.packageInstallId, { resolve:
|
|
224386
|
+
const promise = new Promise((resolve3, reject) => {
|
|
224387
|
+
(this.packageInstalledPromise ?? (this.packageInstalledPromise = /* @__PURE__ */ new Map())).set(this.packageInstallId, { resolve: resolve3, reject });
|
|
224388
224388
|
});
|
|
224389
224389
|
this.installer.send(request);
|
|
224390
224390
|
return promise;
|
|
@@ -224787,12 +224787,12 @@ function __metadata(metadataKey, metadataValue) {
|
|
|
224787
224787
|
}
|
|
224788
224788
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
224789
224789
|
function adopt(value) {
|
|
224790
|
-
return value instanceof P ? value : new P(function(
|
|
224791
|
-
|
|
224790
|
+
return value instanceof P ? value : new P(function(resolve3) {
|
|
224791
|
+
resolve3(value);
|
|
224792
224792
|
});
|
|
224793
224793
|
}
|
|
224794
224794
|
__name(adopt, "adopt");
|
|
224795
|
-
return new (P || (P = Promise))(function(
|
|
224795
|
+
return new (P || (P = Promise))(function(resolve3, reject) {
|
|
224796
224796
|
function fulfilled(value) {
|
|
224797
224797
|
try {
|
|
224798
224798
|
step(generator.next(value));
|
|
@@ -224810,7 +224810,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
224810
224810
|
}
|
|
224811
224811
|
__name(rejected, "rejected");
|
|
224812
224812
|
function step(result) {
|
|
224813
|
-
result.done ?
|
|
224813
|
+
result.done ? resolve3(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
224814
224814
|
}
|
|
224815
224815
|
__name(step, "step");
|
|
224816
224816
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
@@ -225012,15 +225012,15 @@ function __asyncValues(o) {
|
|
|
225012
225012
|
}, i);
|
|
225013
225013
|
function verb(n) {
|
|
225014
225014
|
i[n] = o[n] && function(v) {
|
|
225015
|
-
return new Promise(function(
|
|
225016
|
-
v = o[n](v), settle(
|
|
225015
|
+
return new Promise(function(resolve3, reject) {
|
|
225016
|
+
v = o[n](v), settle(resolve3, reject, v.done, v.value);
|
|
225017
225017
|
});
|
|
225018
225018
|
};
|
|
225019
225019
|
}
|
|
225020
225020
|
__name(verb, "verb");
|
|
225021
|
-
function settle(
|
|
225021
|
+
function settle(resolve3, reject, d, v) {
|
|
225022
225022
|
Promise.resolve(v).then(function(v2) {
|
|
225023
|
-
|
|
225023
|
+
resolve3({ value: v2, done: d });
|
|
225024
225024
|
}, reject);
|
|
225025
225025
|
}
|
|
225026
225026
|
__name(settle, "settle");
|
|
@@ -225668,7 +225668,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
225668
225668
|
return circularValue;
|
|
225669
225669
|
}
|
|
225670
225670
|
let res = "";
|
|
225671
|
-
let
|
|
225671
|
+
let join7 = ",";
|
|
225672
225672
|
const originalIndentation = indentation;
|
|
225673
225673
|
if (Array.isArray(value)) {
|
|
225674
225674
|
if (value.length === 0) {
|
|
@@ -225682,7 +225682,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
225682
225682
|
indentation += spacer;
|
|
225683
225683
|
res += `
|
|
225684
225684
|
${indentation}`;
|
|
225685
|
-
|
|
225685
|
+
join7 = `,
|
|
225686
225686
|
${indentation}`;
|
|
225687
225687
|
}
|
|
225688
225688
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -225690,13 +225690,13 @@ ${indentation}`;
|
|
|
225690
225690
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
225691
225691
|
const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
225692
225692
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
225693
|
-
res +=
|
|
225693
|
+
res += join7;
|
|
225694
225694
|
}
|
|
225695
225695
|
const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
225696
225696
|
res += tmp !== void 0 ? tmp : "null";
|
|
225697
225697
|
if (value.length - 1 > maximumBreadth) {
|
|
225698
225698
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
225699
|
-
res += `${
|
|
225699
|
+
res += `${join7}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
225700
225700
|
}
|
|
225701
225701
|
if (spacer !== "") {
|
|
225702
225702
|
res += `
|
|
@@ -225717,7 +225717,7 @@ ${originalIndentation}`;
|
|
|
225717
225717
|
let separator = "";
|
|
225718
225718
|
if (spacer !== "") {
|
|
225719
225719
|
indentation += spacer;
|
|
225720
|
-
|
|
225720
|
+
join7 = `,
|
|
225721
225721
|
${indentation}`;
|
|
225722
225722
|
whitespace = " ";
|
|
225723
225723
|
}
|
|
@@ -225731,13 +225731,13 @@ ${indentation}`;
|
|
|
225731
225731
|
const tmp = stringifyFnReplacer(key3, value, stack, replacer, spacer, indentation);
|
|
225732
225732
|
if (tmp !== void 0) {
|
|
225733
225733
|
res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
|
|
225734
|
-
separator =
|
|
225734
|
+
separator = join7;
|
|
225735
225735
|
}
|
|
225736
225736
|
}
|
|
225737
225737
|
if (keyLength > maximumBreadth) {
|
|
225738
225738
|
const removedKeys = keyLength - maximumBreadth;
|
|
225739
225739
|
res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
|
|
225740
|
-
separator =
|
|
225740
|
+
separator = join7;
|
|
225741
225741
|
}
|
|
225742
225742
|
if (spacer !== "" && separator.length > 1) {
|
|
225743
225743
|
res = `
|
|
@@ -225779,7 +225779,7 @@ ${originalIndentation}`;
|
|
|
225779
225779
|
}
|
|
225780
225780
|
const originalIndentation = indentation;
|
|
225781
225781
|
let res = "";
|
|
225782
|
-
let
|
|
225782
|
+
let join7 = ",";
|
|
225783
225783
|
if (Array.isArray(value)) {
|
|
225784
225784
|
if (value.length === 0) {
|
|
225785
225785
|
return "[]";
|
|
@@ -225792,7 +225792,7 @@ ${originalIndentation}`;
|
|
|
225792
225792
|
indentation += spacer;
|
|
225793
225793
|
res += `
|
|
225794
225794
|
${indentation}`;
|
|
225795
|
-
|
|
225795
|
+
join7 = `,
|
|
225796
225796
|
${indentation}`;
|
|
225797
225797
|
}
|
|
225798
225798
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -225800,13 +225800,13 @@ ${indentation}`;
|
|
|
225800
225800
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
225801
225801
|
const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
225802
225802
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
225803
|
-
res +=
|
|
225803
|
+
res += join7;
|
|
225804
225804
|
}
|
|
225805
225805
|
const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
225806
225806
|
res += tmp !== void 0 ? tmp : "null";
|
|
225807
225807
|
if (value.length - 1 > maximumBreadth) {
|
|
225808
225808
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
225809
|
-
res += `${
|
|
225809
|
+
res += `${join7}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
225810
225810
|
}
|
|
225811
225811
|
if (spacer !== "") {
|
|
225812
225812
|
res += `
|
|
@@ -225819,7 +225819,7 @@ ${originalIndentation}`;
|
|
|
225819
225819
|
let whitespace = "";
|
|
225820
225820
|
if (spacer !== "") {
|
|
225821
225821
|
indentation += spacer;
|
|
225822
|
-
|
|
225822
|
+
join7 = `,
|
|
225823
225823
|
${indentation}`;
|
|
225824
225824
|
whitespace = " ";
|
|
225825
225825
|
}
|
|
@@ -225828,7 +225828,7 @@ ${indentation}`;
|
|
|
225828
225828
|
const tmp = stringifyArrayReplacer(key3, value[key3], stack, replacer, spacer, indentation);
|
|
225829
225829
|
if (tmp !== void 0) {
|
|
225830
225830
|
res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
|
|
225831
|
-
separator =
|
|
225831
|
+
separator = join7;
|
|
225832
225832
|
}
|
|
225833
225833
|
}
|
|
225834
225834
|
if (spacer !== "" && separator.length > 1) {
|
|
@@ -225887,20 +225887,20 @@ ${originalIndentation}`;
|
|
|
225887
225887
|
indentation += spacer;
|
|
225888
225888
|
let res2 = `
|
|
225889
225889
|
${indentation}`;
|
|
225890
|
-
const
|
|
225890
|
+
const join8 = `,
|
|
225891
225891
|
${indentation}`;
|
|
225892
225892
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
225893
225893
|
let i = 0;
|
|
225894
225894
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
225895
225895
|
const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
225896
225896
|
res2 += tmp2 !== void 0 ? tmp2 : "null";
|
|
225897
|
-
res2 +=
|
|
225897
|
+
res2 += join8;
|
|
225898
225898
|
}
|
|
225899
225899
|
const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
225900
225900
|
res2 += tmp !== void 0 ? tmp : "null";
|
|
225901
225901
|
if (value.length - 1 > maximumBreadth) {
|
|
225902
225902
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
225903
|
-
res2 += `${
|
|
225903
|
+
res2 += `${join8}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
225904
225904
|
}
|
|
225905
225905
|
res2 += `
|
|
225906
225906
|
${originalIndentation}`;
|
|
@@ -225916,16 +225916,16 @@ ${originalIndentation}`;
|
|
|
225916
225916
|
return '"[Object]"';
|
|
225917
225917
|
}
|
|
225918
225918
|
indentation += spacer;
|
|
225919
|
-
const
|
|
225919
|
+
const join7 = `,
|
|
225920
225920
|
${indentation}`;
|
|
225921
225921
|
let res = "";
|
|
225922
225922
|
let separator = "";
|
|
225923
225923
|
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
225924
225924
|
if (isTypedArrayWithEntries(value)) {
|
|
225925
|
-
res += stringifyTypedArray(value,
|
|
225925
|
+
res += stringifyTypedArray(value, join7, maximumBreadth);
|
|
225926
225926
|
keys = keys.slice(value.length);
|
|
225927
225927
|
maximumPropertiesToStringify -= value.length;
|
|
225928
|
-
separator =
|
|
225928
|
+
separator = join7;
|
|
225929
225929
|
}
|
|
225930
225930
|
if (deterministic) {
|
|
225931
225931
|
keys = sort(keys, comparator);
|
|
@@ -225936,13 +225936,13 @@ ${indentation}`;
|
|
|
225936
225936
|
const tmp = stringifyIndent(key3, value[key3], stack, spacer, indentation);
|
|
225937
225937
|
if (tmp !== void 0) {
|
|
225938
225938
|
res += `${separator}${strEscape(key3)}: ${tmp}`;
|
|
225939
|
-
separator =
|
|
225939
|
+
separator = join7;
|
|
225940
225940
|
}
|
|
225941
225941
|
}
|
|
225942
225942
|
if (keyLength > maximumBreadth) {
|
|
225943
225943
|
const removedKeys = keyLength - maximumBreadth;
|
|
225944
225944
|
res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
|
|
225945
|
-
separator =
|
|
225945
|
+
separator = join7;
|
|
225946
225946
|
}
|
|
225947
225947
|
if (separator !== "") {
|
|
225948
225948
|
res = `
|
|
@@ -237417,10 +237417,10 @@ var require_commonjs5 = __commonJS({
|
|
|
237417
237417
|
* Return a void Promise that resolves once the stream ends.
|
|
237418
237418
|
*/
|
|
237419
237419
|
async promise() {
|
|
237420
|
-
return new Promise((
|
|
237420
|
+
return new Promise((resolve3, reject) => {
|
|
237421
237421
|
this.on(DESTROYED, () => reject(new Error("stream destroyed")));
|
|
237422
237422
|
this.on("error", (er) => reject(er));
|
|
237423
|
-
this.on("end", () =>
|
|
237423
|
+
this.on("end", () => resolve3());
|
|
237424
237424
|
});
|
|
237425
237425
|
}
|
|
237426
237426
|
/**
|
|
@@ -237444,7 +237444,7 @@ var require_commonjs5 = __commonJS({
|
|
|
237444
237444
|
return Promise.resolve({ done: false, value: res });
|
|
237445
237445
|
if (this[EOF])
|
|
237446
237446
|
return stop();
|
|
237447
|
-
let
|
|
237447
|
+
let resolve3;
|
|
237448
237448
|
let reject;
|
|
237449
237449
|
const onerr = /* @__PURE__ */ __name((er) => {
|
|
237450
237450
|
this.off("data", ondata);
|
|
@@ -237458,19 +237458,19 @@ var require_commonjs5 = __commonJS({
|
|
|
237458
237458
|
this.off("end", onend);
|
|
237459
237459
|
this.off(DESTROYED, ondestroy);
|
|
237460
237460
|
this.pause();
|
|
237461
|
-
|
|
237461
|
+
resolve3({ value, done: !!this[EOF] });
|
|
237462
237462
|
}, "ondata");
|
|
237463
237463
|
const onend = /* @__PURE__ */ __name(() => {
|
|
237464
237464
|
this.off("error", onerr);
|
|
237465
237465
|
this.off("data", ondata);
|
|
237466
237466
|
this.off(DESTROYED, ondestroy);
|
|
237467
237467
|
stop();
|
|
237468
|
-
|
|
237468
|
+
resolve3({ done: true, value: void 0 });
|
|
237469
237469
|
}, "onend");
|
|
237470
237470
|
const ondestroy = /* @__PURE__ */ __name(() => onerr(new Error("stream destroyed")), "ondestroy");
|
|
237471
237471
|
return new Promise((res2, rej) => {
|
|
237472
237472
|
reject = rej;
|
|
237473
|
-
|
|
237473
|
+
resolve3 = res2;
|
|
237474
237474
|
this.once(DESTROYED, ondestroy);
|
|
237475
237475
|
this.once("error", onerr);
|
|
237476
237476
|
this.once("end", onend);
|
|
@@ -238495,9 +238495,9 @@ var require_commonjs6 = __commonJS({
|
|
|
238495
238495
|
if (this.#asyncReaddirInFlight) {
|
|
238496
238496
|
await this.#asyncReaddirInFlight;
|
|
238497
238497
|
} else {
|
|
238498
|
-
let
|
|
238498
|
+
let resolve3 = /* @__PURE__ */ __name(() => {
|
|
238499
238499
|
}, "resolve");
|
|
238500
|
-
this.#asyncReaddirInFlight = new Promise((res) =>
|
|
238500
|
+
this.#asyncReaddirInFlight = new Promise((res) => resolve3 = res);
|
|
238501
238501
|
try {
|
|
238502
238502
|
for (const e of await this.#fs.promises.readdir(fullpath, {
|
|
238503
238503
|
withFileTypes: true
|
|
@@ -238510,7 +238510,7 @@ var require_commonjs6 = __commonJS({
|
|
|
238510
238510
|
children.provisional = 0;
|
|
238511
238511
|
}
|
|
238512
238512
|
this.#asyncReaddirInFlight = void 0;
|
|
238513
|
-
|
|
238513
|
+
resolve3();
|
|
238514
238514
|
}
|
|
238515
238515
|
return children.slice(0, children.provisional);
|
|
238516
238516
|
}
|
|
@@ -240851,8 +240851,8 @@ __export(bundle_exports, {
|
|
|
240851
240851
|
showBundleHelp: () => showBundleHelp
|
|
240852
240852
|
});
|
|
240853
240853
|
module.exports = __toCommonJS(bundle_exports);
|
|
240854
|
-
var
|
|
240855
|
-
var
|
|
240854
|
+
var import_node_fs5 = require("node:fs");
|
|
240855
|
+
var import_node_path6 = require("node:path");
|
|
240856
240856
|
var import_node_url = require("node:url");
|
|
240857
240857
|
var import_node_util2 = require("node:util");
|
|
240858
240858
|
var import_node_os = require("node:os");
|
|
@@ -240866,14 +240866,14 @@ var whiteBold = /* @__PURE__ */ __name((t) => (0, import_node_util.styleText)(["
|
|
|
240866
240866
|
var dim = /* @__PURE__ */ __name((t) => (0, import_node_util.styleText)("dim", t), "dim");
|
|
240867
240867
|
|
|
240868
240868
|
// dist/cli/bundle.js
|
|
240869
|
-
var
|
|
240869
|
+
var import_node_crypto2 = require("node:crypto");
|
|
240870
240870
|
var import_node_child_process2 = require("node:child_process");
|
|
240871
240871
|
var esbuild = __toESM(require_main(), 1);
|
|
240872
240872
|
|
|
240873
240873
|
// dist/cli/schema.js
|
|
240874
240874
|
var import_typescript = __toESM(require_typescript(), 1);
|
|
240875
|
-
var
|
|
240876
|
-
var
|
|
240875
|
+
var import_node_path3 = require("node:path");
|
|
240876
|
+
var import_node_module2 = require("node:module");
|
|
240877
240877
|
|
|
240878
240878
|
// dist/build.js
|
|
240879
240879
|
var import_node_path = require("node:path");
|
|
@@ -240881,61 +240881,49 @@ var import_node_fs = require("node:fs");
|
|
|
240881
240881
|
var import_ts_json_schema_generator = __toESM(require_dist(), 1);
|
|
240882
240882
|
function findTsConfig(startDir) {
|
|
240883
240883
|
let dir = startDir;
|
|
240884
|
-
|
|
240884
|
+
for (; ; ) {
|
|
240885
240885
|
const configPath = (0, import_node_path.join)(dir, "tsconfig.json");
|
|
240886
|
-
if ((0, import_node_fs.existsSync)(configPath))
|
|
240886
|
+
if ((0, import_node_fs.existsSync)(configPath))
|
|
240887
240887
|
return configPath;
|
|
240888
|
-
}
|
|
240889
240888
|
const parent = (0, import_node_path.dirname)(dir);
|
|
240890
|
-
if (parent === dir)
|
|
240891
|
-
return
|
|
240892
|
-
}
|
|
240889
|
+
if (parent === dir)
|
|
240890
|
+
return;
|
|
240893
240891
|
dir = parent;
|
|
240894
240892
|
}
|
|
240895
240893
|
}
|
|
240896
240894
|
__name(findTsConfig, "findTsConfig");
|
|
240897
240895
|
function inlineRefs(obj, definitions) {
|
|
240898
|
-
if (obj === null || typeof obj
|
|
240896
|
+
if (obj === null || typeof obj != "object")
|
|
240899
240897
|
return obj;
|
|
240900
|
-
|
|
240901
|
-
if (Array.isArray(obj)) {
|
|
240898
|
+
if (Array.isArray(obj))
|
|
240902
240899
|
return obj.map((item) => inlineRefs(item, definitions));
|
|
240903
|
-
}
|
|
240904
240900
|
const record = obj;
|
|
240905
|
-
if (typeof record
|
|
240906
|
-
const
|
|
240907
|
-
|
|
240908
|
-
if (match && definitions[match[1]]) {
|
|
240901
|
+
if (typeof record.$ref == "string") {
|
|
240902
|
+
const match = record.$ref.match(/^#\/definitions\/(.+)$/);
|
|
240903
|
+
if (match && definitions[match[1]])
|
|
240909
240904
|
return inlineRefs(definitions[match[1]], definitions);
|
|
240910
|
-
}
|
|
240911
240905
|
}
|
|
240912
240906
|
const result = {};
|
|
240913
|
-
for (const [key2, value] of Object.entries(record))
|
|
240907
|
+
for (const [key2, value] of Object.entries(record))
|
|
240914
240908
|
result[key2] = inlineRefs(value, definitions);
|
|
240915
|
-
}
|
|
240916
240909
|
return result;
|
|
240917
240910
|
}
|
|
240918
240911
|
__name(inlineRefs, "inlineRefs");
|
|
240919
240912
|
function cleanSchema(typeName, schema) {
|
|
240920
240913
|
const definitions = schema.definitions || {};
|
|
240921
240914
|
let result = definitions[typeName] || schema;
|
|
240922
|
-
result = inlineRefs(result, definitions)
|
|
240923
|
-
if (typeof result === "object" && result !== null) {
|
|
240915
|
+
if (result = inlineRefs(result, definitions), typeof result == "object" && result !== null) {
|
|
240924
240916
|
const cleaned = { ...result };
|
|
240925
|
-
delete cleaned
|
|
240926
|
-
delete cleaned["definitions"];
|
|
240927
|
-
return cleaned;
|
|
240917
|
+
return delete cleaned.$schema, delete cleaned.definitions, cleaned;
|
|
240928
240918
|
}
|
|
240929
240919
|
return result;
|
|
240930
240920
|
}
|
|
240931
240921
|
__name(cleanSchema, "cleanSchema");
|
|
240932
240922
|
function generateSchemas(filePath, typeNames) {
|
|
240933
240923
|
const schemas = /* @__PURE__ */ new Map();
|
|
240934
|
-
if (typeNames.length === 0)
|
|
240924
|
+
if (typeNames.length === 0)
|
|
240935
240925
|
return schemas;
|
|
240936
|
-
|
|
240937
|
-
const configPath = findTsConfig((0, import_node_path.dirname)(filePath));
|
|
240938
|
-
const generator = (0, import_ts_json_schema_generator.createGenerator)({
|
|
240926
|
+
const configPath = findTsConfig((0, import_node_path.dirname)(filePath)), generator = (0, import_ts_json_schema_generator.createGenerator)({
|
|
240939
240927
|
path: filePath,
|
|
240940
240928
|
...configPath && { tsconfig: configPath },
|
|
240941
240929
|
skipTypeCheck: true,
|
|
@@ -240949,11 +240937,25 @@ function generateSchemas(filePath, typeNames) {
|
|
|
240949
240937
|
}
|
|
240950
240938
|
__name(generateSchemas, "generateSchemas");
|
|
240951
240939
|
|
|
240940
|
+
// dist/cli/loader.js
|
|
240941
|
+
var import_node_fs2 = require("node:fs");
|
|
240942
|
+
var import_node_path2 = require("node:path");
|
|
240943
|
+
var import_node_crypto = require("node:crypto");
|
|
240944
|
+
var import_node_module = require("node:module");
|
|
240945
|
+
function extractShebang(source) {
|
|
240946
|
+
if (source.startsWith("#!")) {
|
|
240947
|
+
const newlineIndex = source.indexOf(`
|
|
240948
|
+
`);
|
|
240949
|
+
return newlineIndex !== -1 ? [source.slice(0, newlineIndex + 1), source.slice(newlineIndex + 1)] : [source, ""];
|
|
240950
|
+
}
|
|
240951
|
+
return ["", source];
|
|
240952
|
+
}
|
|
240953
|
+
__name(extractShebang, "extractShebang");
|
|
240954
|
+
|
|
240952
240955
|
// dist/cli/schema.js
|
|
240953
240956
|
var JSONSCHEMA_TAG = "JSONSchema";
|
|
240954
240957
|
function hasJsDocTag(node, tagName) {
|
|
240955
|
-
|
|
240956
|
-
return jsDocNodes.some((tag) => tag.tagName.text === tagName);
|
|
240958
|
+
return import_typescript.default.getJSDocTags(node).some((tag) => tag.tagName.text === tagName);
|
|
240957
240959
|
}
|
|
240958
240960
|
__name(hasJsDocTag, "hasJsDocTag");
|
|
240959
240961
|
function findMarkedTypes(path, source) {
|
|
@@ -240963,48 +240965,36 @@ function findMarkedTypes(path, source) {
|
|
|
240963
240965
|
import_typescript.default.ScriptTarget.Latest,
|
|
240964
240966
|
true
|
|
240965
240967
|
// setParentNodes - needed for JSDoc traversal
|
|
240966
|
-
);
|
|
240967
|
-
|
|
240968
|
-
|
|
240969
|
-
|
|
240970
|
-
if (
|
|
240971
|
-
const
|
|
240972
|
-
|
|
240973
|
-
|
|
240974
|
-
|
|
240975
|
-
|
|
240976
|
-
|
|
240977
|
-
|
|
240978
|
-
|
|
240979
|
-
|
|
240980
|
-
|
|
240981
|
-
|
|
240982
|
-
|
|
240983
|
-
|
|
240984
|
-
|
|
240985
|
-
node,
|
|
240986
|
-
startPosition: node.getStart(),
|
|
240987
|
-
endPosition: node.getEnd(),
|
|
240988
|
-
line: line + 1,
|
|
240989
|
-
column: character + 1,
|
|
240990
|
-
declarationLength,
|
|
240991
|
-
isExported
|
|
240992
|
-
});
|
|
240993
|
-
}
|
|
240968
|
+
), results = [];
|
|
240969
|
+
return import_typescript.default.forEachChild(sourceFile, /* @__PURE__ */ __name(function visit(node) {
|
|
240970
|
+
if ((import_typescript.default.isInterfaceDeclaration(node) || import_typescript.default.isTypeAliasDeclaration(node) || import_typescript.default.isEnumDeclaration(node) || import_typescript.default.isClassDeclaration(node)) && hasJsDocTag(node, JSONSCHEMA_TAG)) {
|
|
240971
|
+
const name = node.name?.text;
|
|
240972
|
+
if (name) {
|
|
240973
|
+
const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
|
240974
|
+
let keyword = "interface";
|
|
240975
|
+
import_typescript.default.isTypeAliasDeclaration(node) ? keyword = "type" : import_typescript.default.isEnumDeclaration(node) ? keyword = "enum" : import_typescript.default.isClassDeclaration(node) && (keyword = "class");
|
|
240976
|
+
const declarationLength = keyword.length + 1 + name.length, isExported = node.modifiers?.some((m) => m.kind === import_typescript.default.SyntaxKind.ExportKeyword) ?? false;
|
|
240977
|
+
results.push({
|
|
240978
|
+
name,
|
|
240979
|
+
node,
|
|
240980
|
+
startPosition: node.getStart(),
|
|
240981
|
+
endPosition: node.getEnd(),
|
|
240982
|
+
line: line + 1,
|
|
240983
|
+
column: character + 1,
|
|
240984
|
+
declarationLength,
|
|
240985
|
+
isExported
|
|
240986
|
+
});
|
|
240994
240987
|
}
|
|
240995
240988
|
}
|
|
240996
240989
|
import_typescript.default.forEachChild(node, visit);
|
|
240997
|
-
}, "visit"));
|
|
240998
|
-
return results;
|
|
240990
|
+
}, "visit")), results;
|
|
240999
240991
|
}
|
|
241000
240992
|
__name(findMarkedTypes, "findMarkedTypes");
|
|
241001
240993
|
function resolveGenerateSchemas(projectDir) {
|
|
241002
240994
|
if (projectDir) {
|
|
241003
|
-
const
|
|
241004
|
-
|
|
241005
|
-
if (typeof buildMod.generateSchemas === "function") {
|
|
240995
|
+
const buildMod = (0, import_node_module2.createRequire)((0, import_node_path3.join)(projectDir, "package.json"))("thinkwell/build");
|
|
240996
|
+
if (typeof buildMod.generateSchemas == "function")
|
|
241006
240997
|
return buildMod.generateSchemas;
|
|
241007
|
-
}
|
|
241008
240998
|
throw new Error(`thinkwell/build resolved from ${projectDir} but does not export generateSchemas. This may indicate a version mismatch \u2014 try updating the thinkwell dependency.`);
|
|
241009
240999
|
}
|
|
241010
241000
|
return generateSchemas;
|
|
@@ -241012,18 +241002,14 @@ function resolveGenerateSchemas(projectDir) {
|
|
|
241012
241002
|
__name(resolveGenerateSchemas, "resolveGenerateSchemas");
|
|
241013
241003
|
function generateSchemas2(path, types, sourceCode, projectDir) {
|
|
241014
241004
|
const schemas = /* @__PURE__ */ new Map();
|
|
241015
|
-
if (types.length === 0)
|
|
241005
|
+
if (types.length === 0)
|
|
241016
241006
|
return schemas;
|
|
241017
|
-
}
|
|
241018
241007
|
const buildGenerateSchemas = resolveGenerateSchemas(projectDir);
|
|
241019
241008
|
for (const typeInfo of types) {
|
|
241020
241009
|
const { name, line, column } = typeInfo;
|
|
241021
241010
|
try {
|
|
241022
|
-
const
|
|
241023
|
-
|
|
241024
|
-
if (schema) {
|
|
241025
|
-
schemas.set(name, schema);
|
|
241026
|
-
}
|
|
241011
|
+
const schema = buildGenerateSchemas(path, [name]).get(name);
|
|
241012
|
+
schema && schemas.set(name, schema);
|
|
241027
241013
|
} catch (error) {
|
|
241028
241014
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
241029
241015
|
throw new Error(`Failed to generate schema for type '${name}' at ${path}:${line}:${column}
|
|
@@ -241036,27 +241022,27 @@ function generateSchemas2(path, types, sourceCode, projectDir) {
|
|
|
241036
241022
|
__name(generateSchemas2, "generateSchemas");
|
|
241037
241023
|
var ACP_NAMESPACE = "$$__thinkwell__acp__$$";
|
|
241038
241024
|
function generateNamespace(name, schema, isExported) {
|
|
241039
|
-
const schemaJson = JSON.stringify(schema, null, 2).split(
|
|
241040
|
-
|
|
241025
|
+
const schemaJson = JSON.stringify(schema, null, 2).split(`
|
|
241026
|
+
`).map((line, i) => i === 0 ? line : " " + line).join(`
|
|
241027
|
+
`);
|
|
241041
241028
|
return [
|
|
241042
|
-
`${
|
|
241029
|
+
`${isExported ? "export " : ""}namespace ${name} {`,
|
|
241043
241030
|
` export const Schema: ${ACP_NAMESPACE}.SchemaProvider<${name}> = {`,
|
|
241044
241031
|
` toJsonSchema: () => (${schemaJson}) as ${ACP_NAMESPACE}.JsonSchema,`,
|
|
241045
|
-
|
|
241046
|
-
|
|
241047
|
-
].join(
|
|
241032
|
+
" };",
|
|
241033
|
+
"}"
|
|
241034
|
+
].join(`
|
|
241035
|
+
`);
|
|
241048
241036
|
}
|
|
241049
241037
|
__name(generateNamespace, "generateNamespace");
|
|
241050
241038
|
function generateInsertions(types, schemas) {
|
|
241051
241039
|
const insertions = [];
|
|
241052
241040
|
for (const { name, endPosition, isExported } of types) {
|
|
241053
241041
|
const schema = schemas.get(name);
|
|
241054
|
-
|
|
241055
|
-
continue;
|
|
241056
|
-
}
|
|
241057
|
-
insertions.push({
|
|
241042
|
+
schema && insertions.push({
|
|
241058
241043
|
position: endPosition,
|
|
241059
|
-
code:
|
|
241044
|
+
code: `
|
|
241045
|
+
` + generateNamespace(name, schema, isExported)
|
|
241060
241046
|
});
|
|
241061
241047
|
}
|
|
241062
241048
|
return insertions.sort((a, b) => b.position - a.position);
|
|
@@ -241068,9 +241054,8 @@ function generateSchemaImport() {
|
|
|
241068
241054
|
__name(generateSchemaImport, "generateSchemaImport");
|
|
241069
241055
|
function applyInsertions(source, insertions) {
|
|
241070
241056
|
let result = source;
|
|
241071
|
-
for (const { position, code } of insertions)
|
|
241057
|
+
for (const { position, code } of insertions)
|
|
241072
241058
|
result = result.slice(0, position) + code + result.slice(position);
|
|
241073
|
-
}
|
|
241074
241059
|
return result;
|
|
241075
241060
|
}
|
|
241076
241061
|
__name(applyInsertions, "applyInsertions");
|
|
@@ -241079,29 +241064,27 @@ function hasJsonSchemaMarkers(source) {
|
|
|
241079
241064
|
}
|
|
241080
241065
|
__name(hasJsonSchemaMarkers, "hasJsonSchemaMarkers");
|
|
241081
241066
|
function transformJsonSchemas(path, source, projectDir) {
|
|
241082
|
-
if (!hasJsonSchemaMarkers(source))
|
|
241067
|
+
if (!hasJsonSchemaMarkers(source))
|
|
241083
241068
|
return source;
|
|
241084
|
-
}
|
|
241085
241069
|
const markedTypes = findMarkedTypes(path, source);
|
|
241086
|
-
if (markedTypes.length === 0)
|
|
241070
|
+
if (markedTypes.length === 0)
|
|
241087
241071
|
return source;
|
|
241088
|
-
|
|
241089
|
-
const schemas = generateSchemas2(path, markedTypes, source, projectDir);
|
|
241090
|
-
const insertions = generateInsertions(markedTypes, schemas);
|
|
241072
|
+
const schemas = generateSchemas2(path, markedTypes, source, projectDir), insertions = generateInsertions(markedTypes, schemas);
|
|
241091
241073
|
let modifiedSource = applyInsertions(source, insertions);
|
|
241092
|
-
|
|
241093
|
-
return modifiedSource
|
|
241074
|
+
const [shebang, rest] = extractShebang(modifiedSource);
|
|
241075
|
+
return modifiedSource = shebang + generateSchemaImport() + `
|
|
241076
|
+
` + rest, modifiedSource;
|
|
241094
241077
|
}
|
|
241095
241078
|
__name(transformJsonSchemas, "transformJsonSchemas");
|
|
241096
241079
|
|
|
241097
241080
|
// dist/cli/dependency-check.js
|
|
241098
|
-
var
|
|
241099
|
-
var
|
|
241081
|
+
var import_node_fs4 = require("node:fs");
|
|
241082
|
+
var import_node_path5 = require("node:path");
|
|
241100
241083
|
var import_node_child_process = require("node:child_process");
|
|
241101
241084
|
|
|
241102
241085
|
// dist/cli/package-manager.js
|
|
241103
|
-
var
|
|
241104
|
-
var
|
|
241086
|
+
var import_node_fs3 = require("node:fs");
|
|
241087
|
+
var import_node_path4 = require("node:path");
|
|
241105
241088
|
var LOCKFILES = [
|
|
241106
241089
|
{ file: "pnpm-lock.yaml", pm: "pnpm" },
|
|
241107
241090
|
{ file: "yarn.lock", pm: "yarn" },
|
|
@@ -241109,34 +241092,26 @@ var LOCKFILES = [
|
|
|
241109
241092
|
];
|
|
241110
241093
|
function detectByLockfile(projectDir) {
|
|
241111
241094
|
for (const { file, pm } of LOCKFILES) {
|
|
241112
|
-
const lockfilePath = (0,
|
|
241113
|
-
if ((0,
|
|
241095
|
+
const lockfilePath = (0, import_node_path4.join)(projectDir, file);
|
|
241096
|
+
if ((0, import_node_fs3.existsSync)(lockfilePath))
|
|
241114
241097
|
return { pm, lockfile: file };
|
|
241115
|
-
}
|
|
241116
241098
|
}
|
|
241117
241099
|
return null;
|
|
241118
241100
|
}
|
|
241119
241101
|
__name(detectByLockfile, "detectByLockfile");
|
|
241120
241102
|
function parsePackageManagerField(value) {
|
|
241121
|
-
if (typeof value
|
|
241103
|
+
if (typeof value != "string")
|
|
241122
241104
|
return null;
|
|
241123
|
-
|
|
241124
|
-
|
|
241125
|
-
const name = atIndex > 0 ? value.slice(0, atIndex) : value;
|
|
241126
|
-
if (name === "pnpm" || name === "npm" || name === "yarn") {
|
|
241127
|
-
return name;
|
|
241128
|
-
}
|
|
241129
|
-
return null;
|
|
241105
|
+
const atIndex = value.indexOf("@"), name = atIndex > 0 ? value.slice(0, atIndex) : value;
|
|
241106
|
+
return name === "pnpm" || name === "npm" || name === "yarn" ? name : null;
|
|
241130
241107
|
}
|
|
241131
241108
|
__name(parsePackageManagerField, "parsePackageManagerField");
|
|
241132
241109
|
function detectByPackageJson(projectDir) {
|
|
241133
|
-
const pkgPath = (0,
|
|
241134
|
-
if (!(0,
|
|
241110
|
+
const pkgPath = (0, import_node_path4.join)(projectDir, "package.json");
|
|
241111
|
+
if (!(0, import_node_fs3.existsSync)(pkgPath))
|
|
241135
241112
|
return null;
|
|
241136
|
-
}
|
|
241137
241113
|
try {
|
|
241138
|
-
const content = (0,
|
|
241139
|
-
const pkg = JSON.parse(content);
|
|
241114
|
+
const content = (0, import_node_fs3.readFileSync)(pkgPath, "utf-8"), pkg = JSON.parse(content);
|
|
241140
241115
|
return parsePackageManagerField(pkg.packageManager);
|
|
241141
241116
|
} catch {
|
|
241142
241117
|
return null;
|
|
@@ -241172,25 +241147,20 @@ function createPackageManagerInfo(name, lockfile) {
|
|
|
241172
241147
|
__name(createPackageManagerInfo, "createPackageManagerInfo");
|
|
241173
241148
|
function detectPackageManager(projectDir) {
|
|
241174
241149
|
const lockfileResult = detectByLockfile(projectDir);
|
|
241175
|
-
if (lockfileResult)
|
|
241150
|
+
if (lockfileResult)
|
|
241176
241151
|
return createPackageManagerInfo(lockfileResult.pm, lockfileResult.lockfile);
|
|
241177
|
-
}
|
|
241178
241152
|
const fromField = detectByPackageJson(projectDir);
|
|
241179
|
-
|
|
241180
|
-
return createPackageManagerInfo(fromField, null);
|
|
241181
|
-
}
|
|
241182
|
-
return createPackageManagerInfo("npm", null);
|
|
241153
|
+
return createPackageManagerInfo(fromField || "npm", null);
|
|
241183
241154
|
}
|
|
241184
241155
|
__name(detectPackageManager, "detectPackageManager");
|
|
241185
241156
|
|
|
241186
241157
|
// dist/cli/dependency-check.js
|
|
241187
241158
|
function readPackageJson(dir) {
|
|
241188
|
-
const pkgPath = (0,
|
|
241189
|
-
if (!(0,
|
|
241159
|
+
const pkgPath = (0, import_node_path5.join)(dir, "package.json");
|
|
241160
|
+
if (!(0, import_node_fs4.existsSync)(pkgPath))
|
|
241190
241161
|
return null;
|
|
241191
|
-
}
|
|
241192
241162
|
try {
|
|
241193
|
-
const content = (0,
|
|
241163
|
+
const content = (0, import_node_fs4.readFileSync)(pkgPath, "utf-8");
|
|
241194
241164
|
return JSON.parse(content);
|
|
241195
241165
|
} catch {
|
|
241196
241166
|
return null;
|
|
@@ -241204,42 +241174,31 @@ function checkPackageJsonDirect(pkg, packageName) {
|
|
|
241204
241174
|
pkg.peerDependencies,
|
|
241205
241175
|
pkg.optionalDependencies
|
|
241206
241176
|
];
|
|
241207
|
-
for (const deps of depTypes)
|
|
241208
|
-
if (deps && packageName in deps)
|
|
241177
|
+
for (const deps of depTypes)
|
|
241178
|
+
if (deps && packageName in deps)
|
|
241209
241179
|
return {
|
|
241210
241180
|
found: true,
|
|
241211
241181
|
version: deps[packageName],
|
|
241212
241182
|
source: "package.json"
|
|
241213
241183
|
};
|
|
241214
|
-
}
|
|
241215
|
-
}
|
|
241216
241184
|
return null;
|
|
241217
241185
|
}
|
|
241218
241186
|
__name(checkPackageJsonDirect, "checkPackageJsonDirect");
|
|
241219
241187
|
function execCommand(cmd, cwd) {
|
|
241220
|
-
return new Promise((
|
|
241221
|
-
const [command, ...args] = cmd
|
|
241222
|
-
const proc = (0, import_node_child_process.spawn)(command, args, {
|
|
241188
|
+
return new Promise((resolve3, reject) => {
|
|
241189
|
+
const [command, ...args] = cmd, proc = (0, import_node_child_process.spawn)(command, args, {
|
|
241223
241190
|
cwd,
|
|
241224
241191
|
stdio: ["ignore", "pipe", "pipe"]
|
|
241225
241192
|
});
|
|
241226
|
-
let stdout = "";
|
|
241227
|
-
let stderr = "";
|
|
241193
|
+
let stdout = "", stderr = "";
|
|
241228
241194
|
proc.stdout.on("data", (data) => {
|
|
241229
241195
|
stdout += data.toString();
|
|
241230
|
-
})
|
|
241231
|
-
proc.stderr.on("data", (data) => {
|
|
241196
|
+
}), proc.stderr.on("data", (data) => {
|
|
241232
241197
|
stderr += data.toString();
|
|
241233
|
-
})
|
|
241234
|
-
proc.on("error", (err) => {
|
|
241198
|
+
}), proc.on("error", (err) => {
|
|
241235
241199
|
reject(err);
|
|
241236
|
-
})
|
|
241237
|
-
|
|
241238
|
-
if (code === 0) {
|
|
241239
|
-
resolve2({ stdout, stderr });
|
|
241240
|
-
} else {
|
|
241241
|
-
reject(new Error(`Command failed with exit code ${code}: ${stderr}`));
|
|
241242
|
-
}
|
|
241200
|
+
}), proc.on("close", (code) => {
|
|
241201
|
+
code === 0 ? resolve3({ stdout, stderr }) : reject(new Error(`Command failed with exit code ${code}: ${stderr}`));
|
|
241243
241202
|
});
|
|
241244
241203
|
});
|
|
241245
241204
|
}
|
|
@@ -241247,15 +241206,11 @@ __name(execCommand, "execCommand");
|
|
|
241247
241206
|
function parsePnpmWhyOutput(stdout, packageName) {
|
|
241248
241207
|
try {
|
|
241249
241208
|
const result = JSON.parse(stdout);
|
|
241250
|
-
|
|
241251
|
-
|
|
241252
|
-
|
|
241253
|
-
|
|
241254
|
-
|
|
241255
|
-
source: "workspace"
|
|
241256
|
-
};
|
|
241257
|
-
}
|
|
241258
|
-
return null;
|
|
241209
|
+
return result && typeof result == "object" && packageName in result ? {
|
|
241210
|
+
found: true,
|
|
241211
|
+
version: result[packageName]?.version,
|
|
241212
|
+
source: "workspace"
|
|
241213
|
+
} : null;
|
|
241259
241214
|
} catch {
|
|
241260
241215
|
return null;
|
|
241261
241216
|
}
|
|
@@ -241264,15 +241219,11 @@ __name(parsePnpmWhyOutput, "parsePnpmWhyOutput");
|
|
|
241264
241219
|
function parseNpmWhyOutput(stdout, _packageName) {
|
|
241265
241220
|
try {
|
|
241266
241221
|
const result = JSON.parse(stdout);
|
|
241267
|
-
|
|
241268
|
-
|
|
241269
|
-
|
|
241270
|
-
|
|
241271
|
-
|
|
241272
|
-
source: "workspace"
|
|
241273
|
-
};
|
|
241274
|
-
}
|
|
241275
|
-
return null;
|
|
241222
|
+
return Array.isArray(result) && result.length > 0 ? {
|
|
241223
|
+
found: true,
|
|
241224
|
+
version: result[0]?.version,
|
|
241225
|
+
source: "workspace"
|
|
241226
|
+
} : null;
|
|
241276
241227
|
} catch {
|
|
241277
241228
|
return null;
|
|
241278
241229
|
}
|
|
@@ -241282,7 +241233,8 @@ function parseYarnWhyOutput(stdout, _packageName) {
|
|
|
241282
241233
|
if (stdout.trim().length > 0) {
|
|
241283
241234
|
let version;
|
|
241284
241235
|
try {
|
|
241285
|
-
const lines = stdout.trim().split(
|
|
241236
|
+
const lines = stdout.trim().split(`
|
|
241237
|
+
`);
|
|
241286
241238
|
for (const line of lines) {
|
|
241287
241239
|
const obj = JSON.parse(line);
|
|
241288
241240
|
if (obj.type === "info" && obj.data) {
|
|
@@ -241322,31 +241274,21 @@ async function checkViaPackageManager(pm, packageName, cwd) {
|
|
|
241322
241274
|
}
|
|
241323
241275
|
__name(checkViaPackageManager, "checkViaPackageManager");
|
|
241324
241276
|
async function checkDependencies(projectDir) {
|
|
241325
|
-
const pm = detectPackageManager(projectDir);
|
|
241326
|
-
|
|
241327
|
-
let thinkwellStatus = { found: false };
|
|
241328
|
-
let typescriptStatus = { found: false };
|
|
241277
|
+
const pm = detectPackageManager(projectDir), pkg = readPackageJson(projectDir);
|
|
241278
|
+
let thinkwellStatus = { found: false }, typescriptStatus = { found: false };
|
|
241329
241279
|
if (pkg) {
|
|
241330
241280
|
const thinkwellDirect = checkPackageJsonDirect(pkg, "thinkwell");
|
|
241331
|
-
|
|
241332
|
-
thinkwellStatus = thinkwellDirect;
|
|
241333
|
-
}
|
|
241281
|
+
thinkwellDirect && (thinkwellStatus = thinkwellDirect);
|
|
241334
241282
|
const typescriptDirect = checkPackageJsonDirect(pkg, "typescript");
|
|
241335
|
-
|
|
241336
|
-
typescriptStatus = typescriptDirect;
|
|
241337
|
-
}
|
|
241283
|
+
typescriptDirect && (typescriptStatus = typescriptDirect);
|
|
241338
241284
|
}
|
|
241339
241285
|
if (!thinkwellStatus.found) {
|
|
241340
241286
|
const result = await checkViaPackageManager(pm, "thinkwell", projectDir);
|
|
241341
|
-
|
|
241342
|
-
thinkwellStatus = result;
|
|
241343
|
-
}
|
|
241287
|
+
result && (thinkwellStatus = result);
|
|
241344
241288
|
}
|
|
241345
241289
|
if (!typescriptStatus.found) {
|
|
241346
241290
|
const result = await checkViaPackageManager(pm, "typescript", projectDir);
|
|
241347
|
-
|
|
241348
|
-
typescriptStatus = result;
|
|
241349
|
-
}
|
|
241291
|
+
result && (typescriptStatus = result);
|
|
241350
241292
|
}
|
|
241351
241293
|
return {
|
|
241352
241294
|
thinkwell: thinkwellStatus,
|
|
@@ -241357,14 +241299,12 @@ async function checkDependencies(projectDir) {
|
|
|
241357
241299
|
__name(checkDependencies, "checkDependencies");
|
|
241358
241300
|
function findProjectRoot(startDir) {
|
|
241359
241301
|
let dir = startDir;
|
|
241360
|
-
|
|
241361
|
-
if ((0,
|
|
241302
|
+
for (; ; ) {
|
|
241303
|
+
if ((0, import_node_fs4.existsSync)((0, import_node_path5.join)(dir, "package.json")))
|
|
241362
241304
|
return dir;
|
|
241363
|
-
|
|
241364
|
-
|
|
241365
|
-
|
|
241366
|
-
return void 0;
|
|
241367
|
-
}
|
|
241305
|
+
const parent = (0, import_node_path5.dirname)(dir);
|
|
241306
|
+
if (parent === dir)
|
|
241307
|
+
return;
|
|
241368
241308
|
dir = parent;
|
|
241369
241309
|
}
|
|
241370
241310
|
}
|
|
@@ -241372,55 +241312,23 @@ __name(findProjectRoot, "findProjectRoot");
|
|
|
241372
241312
|
|
|
241373
241313
|
// dist/cli/dependency-errors.js
|
|
241374
241314
|
function formatMissingDependencyError(result) {
|
|
241375
|
-
const { thinkwell, typescript, packageManager } = result;
|
|
241376
|
-
|
|
241377
|
-
const missing = [];
|
|
241378
|
-
if (!thinkwell.found)
|
|
241379
|
-
missing.push("thinkwell");
|
|
241380
|
-
if (!typescript.found)
|
|
241381
|
-
missing.push("typescript");
|
|
241382
|
-
if (missing.length === 0) {
|
|
241315
|
+
const { thinkwell, typescript, packageManager } = result, pm = packageManager, missing = [];
|
|
241316
|
+
if (thinkwell.found || missing.push("thinkwell"), typescript.found || missing.push("typescript"), missing.length === 0)
|
|
241383
241317
|
return "";
|
|
241384
|
-
}
|
|
241385
241318
|
const lines = [];
|
|
241386
|
-
|
|
241387
|
-
|
|
241388
|
-
} else {
|
|
241389
|
-
lines.push(`Error: This project has a package.json but is missing required dependencies.`);
|
|
241390
|
-
}
|
|
241391
|
-
lines.push("");
|
|
241392
|
-
lines.push("When a project has explicit configuration, thinkwell expects explicit dependencies.");
|
|
241393
|
-
lines.push("This ensures you get the versions you expect, not versions bundled with the CLI.");
|
|
241394
|
-
lines.push("");
|
|
241395
|
-
lines.push("Run 'thinkwell init' to add the required dependencies, or add them manually:");
|
|
241396
|
-
if (!thinkwell.found) {
|
|
241397
|
-
lines.push(` ${pm.addCommand("thinkwell")}`);
|
|
241398
|
-
}
|
|
241399
|
-
if (!typescript.found) {
|
|
241400
|
-
lines.push(` ${pm.addCommand("typescript", true)}`);
|
|
241401
|
-
}
|
|
241402
|
-
return lines.join("\n");
|
|
241319
|
+
return missing.length === 1 ? lines.push(`Error: This project has a package.json but no dependency on '${missing[0]}'.`) : lines.push("Error: This project has a package.json but is missing required dependencies."), lines.push(""), lines.push("When a project has explicit configuration, thinkwell expects explicit dependencies."), lines.push("This ensures you get the versions you expect, not versions bundled with the CLI."), lines.push(""), lines.push("Run 'thinkwell init' to add the required dependencies, or add them manually:"), thinkwell.found || lines.push(` ${pm.addCommand("thinkwell")}`), typescript.found || lines.push(` ${pm.addCommand("typescript", true)}`), lines.join(`
|
|
241320
|
+
`);
|
|
241403
241321
|
}
|
|
241404
241322
|
__name(formatMissingDependencyError, "formatMissingDependencyError");
|
|
241405
241323
|
function hasMissingDeps(result, options) {
|
|
241406
|
-
|
|
241407
|
-
return true;
|
|
241408
|
-
if (options.requireTypescript && !result.typescript.found)
|
|
241409
|
-
return true;
|
|
241410
|
-
return false;
|
|
241324
|
+
return !!(!result.thinkwell.found || options.requireTypescript && !result.typescript.found);
|
|
241411
241325
|
}
|
|
241412
241326
|
__name(hasMissingDeps, "hasMissingDeps");
|
|
241413
241327
|
function formatMissingDepsError(result, options) {
|
|
241414
|
-
|
|
241415
|
-
|
|
241416
|
-
|
|
241417
|
-
|
|
241418
|
-
return formatMissingDependencyError({
|
|
241419
|
-
...result,
|
|
241420
|
-
typescript: { found: true }
|
|
241421
|
-
});
|
|
241422
|
-
}
|
|
241423
|
-
return formatMissingDependencyError(result);
|
|
241328
|
+
return !options.requireTypescript && result.thinkwell.found ? "" : options.requireTypescript ? formatMissingDependencyError(result) : formatMissingDependencyError({
|
|
241329
|
+
...result,
|
|
241330
|
+
typescript: { found: true }
|
|
241331
|
+
});
|
|
241424
241332
|
}
|
|
241425
241333
|
__name(formatMissingDepsError, "formatMissingDepsError");
|
|
241426
241334
|
|
|
@@ -241429,26 +241337,16 @@ var import_meta = {};
|
|
|
241429
241337
|
var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
241430
241338
|
var SPINNER_INTERVAL = 80;
|
|
241431
241339
|
function createSpinnerImpl(options) {
|
|
241432
|
-
let text = options.text;
|
|
241433
|
-
|
|
241434
|
-
|
|
241435
|
-
|
|
241436
|
-
|
|
241437
|
-
const clearLine = /* @__PURE__ */ __name(() => {
|
|
241438
|
-
if (isTTY()) {
|
|
241439
|
-
process.stderr.write("\r\x1B[K");
|
|
241440
|
-
}
|
|
241441
|
-
}, "clearLine");
|
|
241442
|
-
const render = /* @__PURE__ */ __name(() => {
|
|
241443
|
-
if (isSilent)
|
|
241444
|
-
return;
|
|
241445
|
-
if (isTTY()) {
|
|
241340
|
+
let text = options.text, interval, frameIndex = 0;
|
|
241341
|
+
const isSilent = options.isSilent ?? false, isTTY = /* @__PURE__ */ __name(() => process.stderr.isTTY === true, "isTTY"), clearLine = /* @__PURE__ */ __name(() => {
|
|
241342
|
+
isTTY() && process.stderr.write("\r\x1B[K");
|
|
241343
|
+
}, "clearLine"), render = /* @__PURE__ */ __name(() => {
|
|
241344
|
+
if (!isSilent && isTTY()) {
|
|
241446
241345
|
const frame = SPINNER_FRAMES[frameIndex % SPINNER_FRAMES.length];
|
|
241447
|
-
process.stderr.write(`\r${frame} ${text}`)
|
|
241448
|
-
frameIndex++;
|
|
241346
|
+
process.stderr.write(`\r${frame} ${text}`), frameIndex++;
|
|
241449
241347
|
}
|
|
241450
241348
|
}, "render");
|
|
241451
|
-
|
|
241349
|
+
return {
|
|
241452
241350
|
get text() {
|
|
241453
241351
|
return text;
|
|
241454
241352
|
},
|
|
@@ -241456,66 +241354,32 @@ function createSpinnerImpl(options) {
|
|
|
241456
241354
|
text = value;
|
|
241457
241355
|
},
|
|
241458
241356
|
start(newText) {
|
|
241459
|
-
|
|
241460
|
-
|
|
241461
|
-
if (isSilent)
|
|
241462
|
-
return this;
|
|
241463
|
-
if (isTTY()) {
|
|
241464
|
-
render();
|
|
241465
|
-
interval = setInterval(render, SPINNER_INTERVAL);
|
|
241466
|
-
} else {
|
|
241467
|
-
process.stderr.write(`- ${text}
|
|
241468
|
-
`);
|
|
241469
|
-
}
|
|
241470
|
-
return this;
|
|
241357
|
+
return newText && (text = newText), isSilent ? this : (isTTY() ? (render(), interval = setInterval(render, SPINNER_INTERVAL)) : process.stderr.write(`- ${text}
|
|
241358
|
+
`), this);
|
|
241471
241359
|
},
|
|
241472
241360
|
stop() {
|
|
241473
|
-
|
|
241474
|
-
clearInterval(interval);
|
|
241475
|
-
interval = void 0;
|
|
241476
|
-
}
|
|
241477
|
-
clearLine();
|
|
241478
|
-
return this;
|
|
241361
|
+
return interval && (clearInterval(interval), interval = void 0), clearLine(), this;
|
|
241479
241362
|
},
|
|
241480
241363
|
succeed(successText) {
|
|
241481
|
-
if (interval)
|
|
241482
|
-
clearInterval(interval);
|
|
241483
|
-
interval = void 0;
|
|
241484
|
-
}
|
|
241485
|
-
if (isSilent)
|
|
241364
|
+
if (interval && (clearInterval(interval), interval = void 0), isSilent)
|
|
241486
241365
|
return this;
|
|
241487
241366
|
const finalText = successText ?? text;
|
|
241488
|
-
|
|
241489
|
-
|
|
241490
|
-
`);
|
|
241491
|
-
} else {
|
|
241492
|
-
process.stderr.write(`\u2714 ${finalText}
|
|
241493
|
-
`);
|
|
241494
|
-
}
|
|
241495
|
-
return this;
|
|
241367
|
+
return isTTY() ? process.stderr.write(`\r\x1B[K\u2714 ${finalText}
|
|
241368
|
+
`) : process.stderr.write(`\u2714 ${finalText}
|
|
241369
|
+
`), this;
|
|
241496
241370
|
},
|
|
241497
241371
|
fail(failText) {
|
|
241498
|
-
if (interval)
|
|
241499
|
-
clearInterval(interval);
|
|
241500
|
-
interval = void 0;
|
|
241501
|
-
}
|
|
241502
|
-
if (isSilent)
|
|
241372
|
+
if (interval && (clearInterval(interval), interval = void 0), isSilent)
|
|
241503
241373
|
return this;
|
|
241504
241374
|
const finalText = failText ?? text;
|
|
241505
|
-
|
|
241506
|
-
|
|
241507
|
-
`);
|
|
241508
|
-
} else {
|
|
241509
|
-
process.stderr.write(`\u2716 ${finalText}
|
|
241510
|
-
`);
|
|
241511
|
-
}
|
|
241512
|
-
return this;
|
|
241375
|
+
return isTTY() ? process.stderr.write(`\r\x1B[K\u2716 ${finalText}
|
|
241376
|
+
`) : process.stderr.write(`\u2716 ${finalText}
|
|
241377
|
+
`), this;
|
|
241513
241378
|
}
|
|
241514
241379
|
};
|
|
241515
|
-
return spinner;
|
|
241516
241380
|
}
|
|
241517
241381
|
__name(createSpinnerImpl, "createSpinnerImpl");
|
|
241518
|
-
var __dirname2 = typeof import_meta?.url
|
|
241382
|
+
var __dirname2 = typeof import_meta?.url == "string" ? (0, import_node_path6.dirname)((0, import_node_url.fileURLToPath)(import_meta.url)) : globalThis.__dirname || (0, import_node_path6.dirname)(process.argv[1]);
|
|
241519
241383
|
var TARGET_MAP = {
|
|
241520
241384
|
"darwin-arm64": "node24-macos-arm64",
|
|
241521
241385
|
"darwin-x64": "node24-macos-x64",
|
|
@@ -241523,8 +241387,7 @@ var TARGET_MAP = {
|
|
|
241523
241387
|
"linux-arm64": "node24-linux-arm64"
|
|
241524
241388
|
};
|
|
241525
241389
|
function detectHostTarget() {
|
|
241526
|
-
const platform = process.platform;
|
|
241527
|
-
const arch = process.arch;
|
|
241390
|
+
const platform = process.platform, arch = process.arch;
|
|
241528
241391
|
if (platform === "darwin" && arch === "arm64")
|
|
241529
241392
|
return "darwin-arm64";
|
|
241530
241393
|
if (platform === "darwin" && arch === "x64")
|
|
@@ -241537,46 +241400,26 @@ function detectHostTarget() {
|
|
|
241537
241400
|
}
|
|
241538
241401
|
__name(detectHostTarget, "detectHostTarget");
|
|
241539
241402
|
function readPackageJsonConfig(dir) {
|
|
241540
|
-
const pkgPath = (0,
|
|
241541
|
-
if (
|
|
241542
|
-
|
|
241543
|
-
|
|
241544
|
-
|
|
241545
|
-
|
|
241546
|
-
|
|
241547
|
-
|
|
241548
|
-
|
|
241549
|
-
|
|
241550
|
-
|
|
241551
|
-
|
|
241552
|
-
|
|
241553
|
-
|
|
241554
|
-
}
|
|
241555
|
-
if (Array.isArray(config.targets)) {
|
|
241556
|
-
const validTargets = ["darwin-arm64", "darwin-x64", "linux-x64", "linux-arm64", "host"];
|
|
241557
|
-
result.targets = config.targets.filter((t) => typeof t === "string" && validTargets.includes(t));
|
|
241558
|
-
}
|
|
241559
|
-
if (Array.isArray(config.include)) {
|
|
241560
|
-
result.include = config.include.filter((i) => typeof i === "string");
|
|
241561
|
-
}
|
|
241562
|
-
if (Array.isArray(config.external)) {
|
|
241563
|
-
result.external = config.external.filter((e) => typeof e === "string");
|
|
241564
|
-
}
|
|
241565
|
-
if (typeof config.minify === "boolean") {
|
|
241566
|
-
result.minify = config.minify;
|
|
241403
|
+
const pkgPath = (0, import_node_path6.join)(dir, "package.json");
|
|
241404
|
+
if ((0, import_node_fs5.existsSync)(pkgPath))
|
|
241405
|
+
try {
|
|
241406
|
+
const content = (0, import_node_fs5.readFileSync)(pkgPath, "utf-8"), config = JSON.parse(content)?.thinkwell?.bundle;
|
|
241407
|
+
if (!config || typeof config != "object")
|
|
241408
|
+
return;
|
|
241409
|
+
const result = {};
|
|
241410
|
+
if (typeof config.output == "string" && (result.output = config.output), Array.isArray(config.targets)) {
|
|
241411
|
+
const validTargets = ["darwin-arm64", "darwin-x64", "linux-x64", "linux-arm64", "host"];
|
|
241412
|
+
result.targets = config.targets.filter((t) => typeof t == "string" && validTargets.includes(t));
|
|
241413
|
+
}
|
|
241414
|
+
return Array.isArray(config.include) && (result.include = config.include.filter((i) => typeof i == "string")), Array.isArray(config.external) && (result.external = config.external.filter((e) => typeof e == "string")), typeof config.minify == "boolean" && (result.minify = config.minify), result;
|
|
241415
|
+
} catch {
|
|
241416
|
+
return;
|
|
241567
241417
|
}
|
|
241568
|
-
return result;
|
|
241569
|
-
} catch {
|
|
241570
|
-
return void 0;
|
|
241571
|
-
}
|
|
241572
241418
|
}
|
|
241573
241419
|
__name(readPackageJsonConfig, "readPackageJsonConfig");
|
|
241574
241420
|
function mergeWithPackageConfig(options, entryDir) {
|
|
241575
241421
|
const pkgConfig = readPackageJsonConfig(entryDir);
|
|
241576
|
-
|
|
241577
|
-
return options;
|
|
241578
|
-
}
|
|
241579
|
-
return {
|
|
241422
|
+
return pkgConfig ? {
|
|
241580
241423
|
...options,
|
|
241581
241424
|
output: options.output ?? pkgConfig.output,
|
|
241582
241425
|
targets: options.targets && options.targets.length > 0 ? options.targets : pkgConfig.targets ?? options.targets,
|
|
@@ -241589,7 +241432,7 @@ function mergeWithPackageConfig(options, entryDir) {
|
|
|
241589
241432
|
...options.external || []
|
|
241590
241433
|
],
|
|
241591
241434
|
minify: options.minify ?? pkgConfig.minify
|
|
241592
|
-
};
|
|
241435
|
+
} : options;
|
|
241593
241436
|
}
|
|
241594
241437
|
__name(mergeWithPackageConfig, "mergeWithPackageConfig");
|
|
241595
241438
|
function parseBundleArgs(args) {
|
|
@@ -241600,88 +241443,68 @@ function parseBundleArgs(args) {
|
|
|
241600
241443
|
external: []
|
|
241601
241444
|
};
|
|
241602
241445
|
let i = 0;
|
|
241603
|
-
|
|
241446
|
+
for (; i < args.length; ) {
|
|
241604
241447
|
const arg = args[i];
|
|
241605
241448
|
if (arg === "-o" || arg === "--output") {
|
|
241606
|
-
i
|
|
241607
|
-
if (i >= args.length) {
|
|
241449
|
+
if (i++, i >= args.length)
|
|
241608
241450
|
throw new Error("Missing value for --output");
|
|
241609
|
-
}
|
|
241610
241451
|
options.output = args[i];
|
|
241611
241452
|
} else if (arg === "-t" || arg === "--target") {
|
|
241612
|
-
i
|
|
241613
|
-
if (i >= args.length) {
|
|
241453
|
+
if (i++, i >= args.length)
|
|
241614
241454
|
throw new Error("Missing value for --target");
|
|
241615
|
-
|
|
241616
|
-
|
|
241617
|
-
const validTargets = ["darwin-arm64", "darwin-x64", "linux-x64", "linux-arm64", "host"];
|
|
241618
|
-
if (!validTargets.includes(target2)) {
|
|
241455
|
+
const target2 = args[i], validTargets = ["darwin-arm64", "darwin-x64", "linux-x64", "linux-arm64", "host"];
|
|
241456
|
+
if (!validTargets.includes(target2))
|
|
241619
241457
|
throw new Error(`Invalid target '${target2}'. Valid targets: ${validTargets.join(", ")}`);
|
|
241620
|
-
}
|
|
241621
241458
|
options.targets.push(target2);
|
|
241622
241459
|
} else if (arg === "--include") {
|
|
241623
|
-
i
|
|
241624
|
-
if (i >= args.length) {
|
|
241460
|
+
if (i++, i >= args.length)
|
|
241625
241461
|
throw new Error("Missing value for --include");
|
|
241626
|
-
}
|
|
241627
241462
|
options.include.push(args[i]);
|
|
241628
241463
|
} else if (arg === "--external" || arg === "-e") {
|
|
241629
|
-
i
|
|
241630
|
-
if (i >= args.length) {
|
|
241464
|
+
if (i++, i >= args.length)
|
|
241631
241465
|
throw new Error("Missing value for --external");
|
|
241632
|
-
}
|
|
241633
241466
|
options.external.push(args[i]);
|
|
241634
|
-
} else if (arg === "--verbose" || arg === "-v")
|
|
241467
|
+
} else if (arg === "--verbose" || arg === "-v")
|
|
241635
241468
|
options.verbose = true;
|
|
241636
|
-
|
|
241469
|
+
else if (arg === "--quiet" || arg === "-q")
|
|
241637
241470
|
options.quiet = true;
|
|
241638
|
-
|
|
241471
|
+
else if (arg === "--dry-run" || arg === "-n")
|
|
241639
241472
|
options.dryRun = true;
|
|
241640
|
-
|
|
241473
|
+
else if (arg === "--minify" || arg === "-m")
|
|
241641
241474
|
options.minify = true;
|
|
241642
|
-
|
|
241475
|
+
else if (arg === "--watch" || arg === "-w")
|
|
241643
241476
|
options.watch = true;
|
|
241644
|
-
|
|
241645
|
-
|
|
241646
|
-
|
|
241647
|
-
if (options.entry)
|
|
241477
|
+
else {
|
|
241478
|
+
if (arg.startsWith("-"))
|
|
241479
|
+
throw new Error(`Unknown option: ${arg}`);
|
|
241480
|
+
if (options.entry)
|
|
241648
241481
|
throw new Error(`Unexpected argument: ${arg}`);
|
|
241649
|
-
}
|
|
241650
241482
|
options.entry = arg;
|
|
241651
241483
|
}
|
|
241652
241484
|
i++;
|
|
241653
241485
|
}
|
|
241654
|
-
if (!options.entry)
|
|
241486
|
+
if (!options.entry)
|
|
241655
241487
|
throw new Error("No entry file specified");
|
|
241656
|
-
|
|
241657
|
-
if (options.targets.length === 0) {
|
|
241658
|
-
options.targets = ["host"];
|
|
241659
|
-
}
|
|
241660
|
-
return options;
|
|
241488
|
+
return options.targets.length === 0 && (options.targets = ["host"]), options;
|
|
241661
241489
|
}
|
|
241662
241490
|
__name(parseBundleArgs, "parseBundleArgs");
|
|
241663
241491
|
function initBundleContext(options) {
|
|
241664
|
-
const entryPath = (0,
|
|
241665
|
-
if (!(0,
|
|
241666
|
-
const suggestion = options.entry.endsWith(".ts") || options.entry.endsWith(".js") ? "" :
|
|
241492
|
+
const entryPath = (0, import_node_path6.isAbsolute)(options.entry) ? options.entry : (0, import_node_path6.resolve)(process.cwd(), options.entry);
|
|
241493
|
+
if (!(0, import_node_fs5.existsSync)(entryPath)) {
|
|
241494
|
+
const suggestion = options.entry.endsWith(".ts") || options.entry.endsWith(".js") ? "" : `
|
|
241495
|
+
Did you mean to add a .ts or .js extension?`;
|
|
241667
241496
|
throw new Error(`Entry file not found: ${options.entry}${suggestion}
|
|
241668
241497
|
Working directory: ${process.cwd()}`);
|
|
241669
241498
|
}
|
|
241670
|
-
const entryBasename = (0,
|
|
241671
|
-
const entryDir = (0, import_node_path5.dirname)(entryPath);
|
|
241499
|
+
const entryBasename = (0, import_node_path6.basename)(entryPath).replace(/\.(ts|js|mts|mjs|cts|cjs)$/, ""), entryDir = (0, import_node_path6.dirname)(entryPath);
|
|
241672
241500
|
let mergedOptions = mergeWithPackageConfig(options, entryDir);
|
|
241673
|
-
|
|
241674
|
-
|
|
241675
|
-
|
|
241676
|
-
const buildDir = (0, import_node_fs4.mkdtempSync)((0, import_node_path5.join)((0, import_node_os.tmpdir)(), `thinkwell-bundle-${entryBasename}-`));
|
|
241677
|
-
const thinkwellDistPkg = (0, import_node_path5.resolve)(__dirname2, "../../dist-pkg");
|
|
241678
|
-
if (!(0, import_node_fs4.existsSync)(thinkwellDistPkg)) {
|
|
241501
|
+
entryDir !== process.cwd() && (mergedOptions = mergeWithPackageConfig(mergedOptions, process.cwd()));
|
|
241502
|
+
const buildDir = (0, import_node_fs5.mkdtempSync)((0, import_node_path6.join)((0, import_node_os.tmpdir)(), `thinkwell-bundle-${entryBasename}-`)), thinkwellDistPkg = (0, import_node_path6.resolve)(__dirname2, "../../dist-pkg");
|
|
241503
|
+
if (!(0, import_node_fs5.existsSync)(thinkwellDistPkg))
|
|
241679
241504
|
throw new Error(`Thinkwell dist-pkg not found at ${thinkwellDistPkg}.
|
|
241680
241505
|
This may indicate a corrupted installation.
|
|
241681
241506
|
Try reinstalling thinkwell: npm install thinkwell`);
|
|
241682
|
-
|
|
241683
|
-
const resolvedTargets = mergedOptions.targets.map((t) => t === "host" ? detectHostTarget() : t);
|
|
241684
|
-
const uniqueTargets = [...new Set(resolvedTargets)];
|
|
241507
|
+
const resolvedTargets = mergedOptions.targets.map((t) => t === "host" ? detectHostTarget() : t), uniqueTargets = [...new Set(resolvedTargets)];
|
|
241685
241508
|
return {
|
|
241686
241509
|
entryPath,
|
|
241687
241510
|
entryBasename,
|
|
@@ -241694,16 +241517,7 @@ function initBundleContext(options) {
|
|
|
241694
241517
|
}
|
|
241695
241518
|
__name(initBundleContext, "initBundleContext");
|
|
241696
241519
|
function getOutputPath(ctx, target2) {
|
|
241697
|
-
|
|
241698
|
-
if (ctx.resolvedTargets.length === 1) {
|
|
241699
|
-
return (0, import_node_path5.isAbsolute)(ctx.options.output) ? ctx.options.output : (0, import_node_path5.resolve)(process.cwd(), ctx.options.output);
|
|
241700
|
-
} else {
|
|
241701
|
-
const base = (0, import_node_path5.isAbsolute)(ctx.options.output) ? ctx.options.output : (0, import_node_path5.resolve)(process.cwd(), ctx.options.output);
|
|
241702
|
-
return `${base}-${target2}`;
|
|
241703
|
-
}
|
|
241704
|
-
} else {
|
|
241705
|
-
return (0, import_node_path5.resolve)(process.cwd(), `${ctx.entryBasename}-${target2}`);
|
|
241706
|
-
}
|
|
241520
|
+
return ctx.options.output ? ctx.resolvedTargets.length === 1 ? (0, import_node_path6.isAbsolute)(ctx.options.output) ? ctx.options.output : (0, import_node_path6.resolve)(process.cwd(), ctx.options.output) : `${(0, import_node_path6.isAbsolute)(ctx.options.output) ? ctx.options.output : (0, import_node_path6.resolve)(process.cwd(), ctx.options.output)}-${target2}` : (0, import_node_path6.resolve)(process.cwd(), `${ctx.entryBasename}-${target2}`);
|
|
241707
241521
|
}
|
|
241708
241522
|
__name(getOutputPath, "getOutputPath");
|
|
241709
241523
|
function generateWrapperSource(userBundlePath) {
|
|
@@ -241725,15 +241539,13 @@ global.__bundled__ = {
|
|
|
241725
241539
|
};
|
|
241726
241540
|
|
|
241727
241541
|
// Load the user's bundled code
|
|
241728
|
-
require('./${(0,
|
|
241542
|
+
require('./${(0, import_node_path6.basename)(userBundlePath)}');
|
|
241729
241543
|
`;
|
|
241730
241544
|
}
|
|
241731
241545
|
__name(generateWrapperSource, "generateWrapperSource");
|
|
241732
241546
|
async function bundleUserScript(ctx) {
|
|
241733
|
-
const outputFile = (0,
|
|
241734
|
-
|
|
241735
|
-
console.log(` Bundling ${ctx.entryPath}...`);
|
|
241736
|
-
}
|
|
241547
|
+
const outputFile = (0, import_node_path6.join)(ctx.buildDir, `${ctx.entryBasename}-bundle.cjs`);
|
|
241548
|
+
ctx.options.verbose && console.log(` Bundling ${ctx.entryPath}...`);
|
|
241737
241549
|
try {
|
|
241738
241550
|
const externalPackages = ["node:*", ...ctx.options.external || []];
|
|
241739
241551
|
await esbuild.build({
|
|
@@ -241776,27 +241588,20 @@ require.main = __origRequire.main;
|
|
|
241776
241588
|
name: "jsonschema-transformer",
|
|
241777
241589
|
setup(build2) {
|
|
241778
241590
|
build2.onLoad({ filter: /\.(ts|tsx|mts|cts)$/ }, async (args) => {
|
|
241779
|
-
if (args.path.includes("node_modules"))
|
|
241591
|
+
if (args.path.includes("node_modules"))
|
|
241780
241592
|
return null;
|
|
241781
|
-
|
|
241782
|
-
|
|
241783
|
-
|
|
241784
|
-
return null;
|
|
241785
|
-
}
|
|
241786
|
-
const transformed = transformJsonSchemas(args.path, source, ctx.projectDir);
|
|
241787
|
-
return {
|
|
241788
|
-
contents: transformed,
|
|
241593
|
+
const source = (0, import_node_fs5.readFileSync)(args.path, "utf-8");
|
|
241594
|
+
return hasJsonSchemaMarkers(source) ? {
|
|
241595
|
+
contents: transformJsonSchemas(args.path, source, ctx.projectDir),
|
|
241789
241596
|
loader: args.path.endsWith(".tsx") ? "tsx" : "ts"
|
|
241790
|
-
};
|
|
241597
|
+
} : null;
|
|
241791
241598
|
});
|
|
241792
241599
|
}
|
|
241793
241600
|
},
|
|
241794
241601
|
{
|
|
241795
241602
|
name: "thinkwell-resolver",
|
|
241796
241603
|
setup(build2) {
|
|
241797
|
-
build2.onResolve({ filter: /^(thinkwell|@thinkwell\/(acp|protocol))$/ }, (args) => {
|
|
241798
|
-
return { path: args.path, external: true };
|
|
241799
|
-
});
|
|
241604
|
+
build2.onResolve({ filter: /^(thinkwell|@thinkwell\/(acp|protocol))$/ }, (args) => ({ path: args.path, external: true }));
|
|
241800
241605
|
}
|
|
241801
241606
|
}
|
|
241802
241607
|
],
|
|
@@ -241810,18 +241615,14 @@ require.main = __origRequire.main;
|
|
|
241810
241615
|
} catch (error) {
|
|
241811
241616
|
const message = error instanceof Error ? error.message : String(error);
|
|
241812
241617
|
if (message.includes("Could not resolve")) {
|
|
241813
|
-
const match = message.match(/Could not resolve "([^"]+)"/);
|
|
241814
|
-
const moduleName = match ? match[1] : "unknown module";
|
|
241618
|
+
const match = message.match(/Could not resolve "([^"]+)"/), moduleName = match ? match[1] : "unknown module";
|
|
241815
241619
|
throw new Error(`Could not resolve dependency "${moduleName}".
|
|
241816
241620
|
Make sure all dependencies are installed: npm install
|
|
241817
241621
|
If this is a dev dependency, it may need to be a regular dependency.`);
|
|
241818
241622
|
}
|
|
241819
|
-
|
|
241820
|
-
throw new Error(`Unsupported file type in import.
|
|
241623
|
+
throw message.includes("No loader is configured") ? new Error(`Unsupported file type in import.
|
|
241821
241624
|
esbuild cannot bundle this file type by default.
|
|
241822
|
-
Consider using --include to embed the file as an asset instead.`);
|
|
241823
|
-
}
|
|
241824
|
-
throw error;
|
|
241625
|
+
Consider using --include to embed the file as an asset instead.`) : error;
|
|
241825
241626
|
}
|
|
241826
241627
|
return outputFile;
|
|
241827
241628
|
}
|
|
@@ -241829,98 +241630,80 @@ __name(bundleUserScript, "bundleUserScript");
|
|
|
241829
241630
|
function copyThinkwellBundles(ctx) {
|
|
241830
241631
|
const bundles = ["thinkwell.cjs", "acp.cjs", "protocol.cjs"];
|
|
241831
241632
|
for (const bundle of bundles) {
|
|
241832
|
-
const src = (0,
|
|
241833
|
-
|
|
241834
|
-
if (!(0, import_node_fs4.existsSync)(src)) {
|
|
241633
|
+
const src = (0, import_node_path6.join)(ctx.thinkwellDistPkg, bundle), dest = (0, import_node_path6.join)(ctx.buildDir, bundle);
|
|
241634
|
+
if (!(0, import_node_fs5.existsSync)(src))
|
|
241835
241635
|
throw new Error(`Thinkwell bundle not found: ${src}`);
|
|
241836
|
-
|
|
241837
|
-
|
|
241838
|
-
(0, import_node_fs4.writeFileSync)(dest, content);
|
|
241839
|
-
if (ctx.options.verbose) {
|
|
241840
|
-
console.log(` Copied ${bundle}`);
|
|
241841
|
-
}
|
|
241636
|
+
const content = (0, import_node_fs5.readFileSync)(src);
|
|
241637
|
+
(0, import_node_fs5.writeFileSync)(dest, content), ctx.options.verbose && console.log(` Copied ${bundle}`);
|
|
241842
241638
|
}
|
|
241843
241639
|
}
|
|
241844
241640
|
__name(copyThinkwellBundles, "copyThinkwellBundles");
|
|
241845
241641
|
function isRunningFromCompiledBinary() {
|
|
241846
|
-
return typeof process.pkg
|
|
241642
|
+
return typeof process.pkg < "u";
|
|
241847
241643
|
}
|
|
241848
241644
|
__name(isRunningFromCompiledBinary, "isRunningFromCompiledBinary");
|
|
241849
241645
|
var PORTABLE_NODE_VERSION = "24.1.0";
|
|
241850
241646
|
function getCacheDir() {
|
|
241851
|
-
return process.env.THINKWELL_CACHE_DIR || (0,
|
|
241647
|
+
return process.env.THINKWELL_CACHE_DIR || (0, import_node_path6.join)((0, import_node_os.homedir)(), ".cache", "thinkwell");
|
|
241852
241648
|
}
|
|
241853
241649
|
__name(getCacheDir, "getCacheDir");
|
|
241854
241650
|
function getThinkwellVersion() {
|
|
241855
241651
|
try {
|
|
241856
|
-
const pkgPath = (0,
|
|
241857
|
-
|
|
241858
|
-
return pkg.version || "unknown";
|
|
241652
|
+
const pkgPath = (0, import_node_path6.resolve)(__dirname2, "../../package.json");
|
|
241653
|
+
return JSON.parse((0, import_node_fs5.readFileSync)(pkgPath, "utf-8")).version || "unknown";
|
|
241859
241654
|
} catch {
|
|
241860
241655
|
return "unknown";
|
|
241861
241656
|
}
|
|
241862
241657
|
}
|
|
241863
241658
|
__name(getThinkwellVersion, "getThinkwellVersion");
|
|
241864
241659
|
function getNodePlatformArch() {
|
|
241865
|
-
const platform = process.platform === "darwin" ? "darwin" : "linux";
|
|
241866
|
-
const arch = process.arch;
|
|
241660
|
+
const platform = process.platform === "darwin" ? "darwin" : "linux", arch = process.arch;
|
|
241867
241661
|
return { platform, arch };
|
|
241868
241662
|
}
|
|
241869
241663
|
__name(getNodePlatformArch, "getNodePlatformArch");
|
|
241870
241664
|
async function downloadFile(url, destPath, spinner) {
|
|
241871
241665
|
const response = await fetch(url);
|
|
241872
|
-
if (!response.ok)
|
|
241666
|
+
if (!response.ok)
|
|
241873
241667
|
throw new Error(`Failed to download ${url}: ${response.status} ${response.statusText}`);
|
|
241874
|
-
|
|
241875
|
-
|
|
241876
|
-
const
|
|
241877
|
-
|
|
241878
|
-
const fileStream = (0, import_node_fs4.createWriteStream)(destPath);
|
|
241879
|
-
const reader = response.body?.getReader();
|
|
241880
|
-
if (!reader) {
|
|
241668
|
+
const contentLength = response.headers.get("content-length"), totalBytes = contentLength ? parseInt(contentLength, 10) : 0;
|
|
241669
|
+
(0, import_node_fs5.mkdirSync)((0, import_node_path6.dirname)(destPath), { recursive: true });
|
|
241670
|
+
const fileStream = (0, import_node_fs5.createWriteStream)(destPath), reader = response.body?.getReader();
|
|
241671
|
+
if (!reader)
|
|
241881
241672
|
throw new Error("No response body");
|
|
241882
|
-
}
|
|
241883
241673
|
let downloadedBytes = 0;
|
|
241884
241674
|
try {
|
|
241885
|
-
|
|
241675
|
+
for (; ; ) {
|
|
241886
241676
|
const { done, value } = await reader.read();
|
|
241887
241677
|
if (done)
|
|
241888
241678
|
break;
|
|
241889
|
-
fileStream.write(Buffer.from(value))
|
|
241890
|
-
|
|
241891
|
-
if (spinner && totalBytes > 0) {
|
|
241892
|
-
const percent = Math.round(downloadedBytes / totalBytes * 100);
|
|
241893
|
-
const downloadedMB = (downloadedBytes / 1024 / 1024).toFixed(1);
|
|
241894
|
-
const totalMB = (totalBytes / 1024 / 1024).toFixed(1);
|
|
241679
|
+
if (fileStream.write(Buffer.from(value)), downloadedBytes += value.length, spinner && totalBytes > 0) {
|
|
241680
|
+
const percent = Math.round(downloadedBytes / totalBytes * 100), downloadedMB = (downloadedBytes / 1024 / 1024).toFixed(1), totalMB = (totalBytes / 1024 / 1024).toFixed(1);
|
|
241895
241681
|
spinner.text = `Downloading Node.js runtime... ${downloadedMB} MB / ${totalMB} MB (${percent}%)`;
|
|
241896
241682
|
}
|
|
241897
241683
|
}
|
|
241898
241684
|
} finally {
|
|
241899
241685
|
fileStream.end();
|
|
241900
241686
|
}
|
|
241901
|
-
await new Promise((
|
|
241902
|
-
fileStream.on("finish",
|
|
241903
|
-
fileStream.on("error", reject);
|
|
241687
|
+
await new Promise((resolve22, reject) => {
|
|
241688
|
+
fileStream.on("finish", resolve22), fileStream.on("error", reject);
|
|
241904
241689
|
});
|
|
241905
241690
|
}
|
|
241906
241691
|
__name(downloadFile, "downloadFile");
|
|
241907
241692
|
function hashFile(filePath) {
|
|
241908
|
-
const content = (0,
|
|
241909
|
-
return (0,
|
|
241693
|
+
const content = (0, import_node_fs5.readFileSync)(filePath);
|
|
241694
|
+
return (0, import_node_crypto2.createHash)("sha256").update(content).digest("hex");
|
|
241910
241695
|
}
|
|
241911
241696
|
__name(hashFile, "hashFile");
|
|
241912
241697
|
async function fetchExpectedChecksum(version, filename) {
|
|
241913
|
-
const url = `https://nodejs.org/dist/v${version}/SHASUMS256.txt
|
|
241914
|
-
|
|
241915
|
-
if (!response.ok) {
|
|
241698
|
+
const url = `https://nodejs.org/dist/v${version}/SHASUMS256.txt`, response = await fetch(url);
|
|
241699
|
+
if (!response.ok)
|
|
241916
241700
|
throw new Error(`Failed to fetch checksums: ${response.status}`);
|
|
241917
|
-
}
|
|
241918
241701
|
const text = await response.text();
|
|
241919
|
-
for (const line of text.split(
|
|
241702
|
+
for (const line of text.split(`
|
|
241703
|
+
`)) {
|
|
241920
241704
|
const parts = line.trim().split(/\s+/);
|
|
241921
|
-
if (parts.length === 2 && parts[1] === filename)
|
|
241705
|
+
if (parts.length === 2 && parts[1] === filename)
|
|
241922
241706
|
return parts[0];
|
|
241923
|
-
}
|
|
241924
241707
|
}
|
|
241925
241708
|
throw new Error(`Checksum not found for ${filename}`);
|
|
241926
241709
|
}
|
|
@@ -241932,132 +241715,88 @@ function extractTarGz(archivePath, destDir) {
|
|
|
241932
241715
|
}
|
|
241933
241716
|
__name(extractTarGz, "extractTarGz");
|
|
241934
241717
|
async function ensurePortableNode(spinner) {
|
|
241935
|
-
const version = PORTABLE_NODE_VERSION;
|
|
241936
|
-
|
|
241937
|
-
const cacheDir = (0, import_node_path5.join)(getCacheDir(), "node", `v${version}`);
|
|
241938
|
-
const nodeBinary = process.platform === "win32" ? "node.exe" : "node";
|
|
241939
|
-
const nodePath = (0, import_node_path5.join)(cacheDir, nodeBinary);
|
|
241940
|
-
if ((0, import_node_fs4.existsSync)(nodePath)) {
|
|
241718
|
+
const version = PORTABLE_NODE_VERSION, { platform, arch } = getNodePlatformArch(), cacheDir = (0, import_node_path6.join)(getCacheDir(), "node", `v${version}`), nodeBinary = process.platform === "win32" ? "node.exe" : "node", nodePath = (0, import_node_path6.join)(cacheDir, nodeBinary);
|
|
241719
|
+
if ((0, import_node_fs5.existsSync)(nodePath))
|
|
241941
241720
|
return nodePath;
|
|
241942
|
-
}
|
|
241943
|
-
const filename = `node-v${version}-${platform}-${arch}.tar.gz`;
|
|
241944
|
-
const url = `https://nodejs.org/dist/v${version}/${filename}`;
|
|
241945
|
-
const archivePath = (0, import_node_path5.join)(cacheDir, filename);
|
|
241721
|
+
const filename = `node-v${version}-${platform}-${arch}.tar.gz`, url = `https://nodejs.org/dist/v${version}/${filename}`, archivePath = (0, import_node_path6.join)(cacheDir, filename);
|
|
241946
241722
|
spinner?.start("Downloading Node.js runtime (first time only)...");
|
|
241947
241723
|
try {
|
|
241948
|
-
(0,
|
|
241949
|
-
await
|
|
241950
|
-
|
|
241951
|
-
|
|
241952
|
-
const actualHash = hashFile(archivePath);
|
|
241953
|
-
if (actualHash !== expectedHash) {
|
|
241954
|
-
(0, import_node_fs4.rmSync)(archivePath, { force: true });
|
|
241955
|
-
throw new Error(`Node.js download verification failed.
|
|
241724
|
+
(0, import_node_fs5.mkdirSync)(cacheDir, { recursive: true }), await downloadFile(url, archivePath, spinner), spinner?.start("Verifying download integrity...");
|
|
241725
|
+
const expectedHash = await fetchExpectedChecksum(version, filename), actualHash = hashFile(archivePath);
|
|
241726
|
+
if (actualHash !== expectedHash)
|
|
241727
|
+
throw (0, import_node_fs5.rmSync)(archivePath, { force: true }), new Error(`Node.js download verification failed.
|
|
241956
241728
|
|
|
241957
241729
|
Expected: ${expectedHash}
|
|
241958
241730
|
Actual: ${actualHash}
|
|
241959
241731
|
|
|
241960
241732
|
This may indicate a corrupted download or network interference.
|
|
241961
241733
|
Please retry or report this issue.`);
|
|
241962
|
-
|
|
241963
|
-
|
|
241964
|
-
|
|
241965
|
-
const extractedDir = (0, import_node_path5.join)(cacheDir, `node-v${version}-${platform}-${arch}`);
|
|
241966
|
-
const extractedBin = (0, import_node_path5.join)(extractedDir, "bin", nodeBinary);
|
|
241967
|
-
(0, import_node_fs4.copyFileSync)(extractedBin, nodePath);
|
|
241968
|
-
(0, import_node_fs4.chmodSync)(nodePath, 493);
|
|
241969
|
-
(0, import_node_fs4.rmSync)(extractedDir, { recursive: true, force: true });
|
|
241970
|
-
(0, import_node_fs4.rmSync)(archivePath, { force: true });
|
|
241971
|
-
spinner?.succeed(`Node.js v${version} cached to ${cacheDir}`);
|
|
241972
|
-
return nodePath;
|
|
241734
|
+
spinner?.start("Extracting Node.js..."), extractTarGz(archivePath, cacheDir);
|
|
241735
|
+
const extractedDir = (0, import_node_path6.join)(cacheDir, `node-v${version}-${platform}-${arch}`), extractedBin = (0, import_node_path6.join)(extractedDir, "bin", nodeBinary);
|
|
241736
|
+
return (0, import_node_fs5.copyFileSync)(extractedBin, nodePath), (0, import_node_fs5.chmodSync)(nodePath, 493), (0, import_node_fs5.rmSync)(extractedDir, { recursive: true, force: true }), (0, import_node_fs5.rmSync)(archivePath, { force: true }), spinner?.succeed(`Node.js v${version} cached to ${cacheDir}`), nodePath;
|
|
241973
241737
|
} catch (error) {
|
|
241974
|
-
(0,
|
|
241738
|
+
(0, import_node_fs5.rmSync)(cacheDir, { recursive: true, force: true });
|
|
241975
241739
|
const message = error instanceof Error ? error.message : String(error);
|
|
241976
|
-
|
|
241977
|
-
throw new Error(`Failed to download Node.js runtime.
|
|
241740
|
+
throw message.includes("ETIMEDOUT") || message.includes("ENOTFOUND") ? new Error(`Failed to download Node.js runtime.
|
|
241978
241741
|
|
|
241979
241742
|
URL: ${url}
|
|
241980
241743
|
Error: ${message}
|
|
241981
241744
|
|
|
241982
241745
|
Check your network connection and try again.
|
|
241983
|
-
If behind a proxy, set HTTPS_PROXY environment variable.`);
|
|
241984
|
-
}
|
|
241985
|
-
throw error;
|
|
241746
|
+
If behind a proxy, set HTTPS_PROXY environment variable.`) : error;
|
|
241986
241747
|
}
|
|
241987
241748
|
}
|
|
241988
241749
|
__name(ensurePortableNode, "ensurePortableNode");
|
|
241989
241750
|
function ensurePkgCli() {
|
|
241990
|
-
const version = getThinkwellVersion();
|
|
241991
|
-
|
|
241992
|
-
const cacheDir = (0, import_node_path5.join)(pkgCliBaseDir, version);
|
|
241993
|
-
const pkgCliPath = (0, import_node_path5.join)(cacheDir, "pkg-cli.cjs");
|
|
241994
|
-
const preludeCheck = (0, import_node_path5.join)(cacheDir, "pkg-prelude", "bootstrap.js");
|
|
241995
|
-
if ((0, import_node_fs4.existsSync)(pkgCliPath) && (0, import_node_fs4.existsSync)(preludeCheck)) {
|
|
241751
|
+
const version = getThinkwellVersion(), pkgCliBaseDir = (0, import_node_path6.join)(getCacheDir(), "pkg-cli"), cacheDir = (0, import_node_path6.join)(pkgCliBaseDir, version), pkgCliPath = (0, import_node_path6.join)(cacheDir, "pkg-cli.cjs"), preludeCheck = (0, import_node_path6.join)(cacheDir, "pkg-prelude", "bootstrap.js");
|
|
241752
|
+
if ((0, import_node_fs5.existsSync)(pkgCliPath) && (0, import_node_fs5.existsSync)(preludeCheck))
|
|
241996
241753
|
return pkgCliPath;
|
|
241997
|
-
|
|
241998
|
-
|
|
241999
|
-
const cliSrc = (0, import_node_path5.join)(distPkgPath, "pkg-cli.cjs");
|
|
242000
|
-
if (!(0, import_node_fs4.existsSync)(cliSrc)) {
|
|
241754
|
+
const distPkgPath = (0, import_node_path6.resolve)(__dirname2, "../../dist-pkg"), cliSrc = (0, import_node_path6.join)(distPkgPath, "pkg-cli.cjs");
|
|
241755
|
+
if (!(0, import_node_fs5.existsSync)(cliSrc))
|
|
242001
241756
|
throw new Error(`pkg CLI not found in compiled binary assets.
|
|
242002
241757
|
Expected at: ${cliSrc}
|
|
242003
241758
|
|
|
242004
241759
|
This may indicate a build issue. Please report this.`);
|
|
242005
|
-
}
|
|
242006
|
-
(0,
|
|
242007
|
-
(0,
|
|
242008
|
-
const
|
|
242009
|
-
|
|
242010
|
-
(0, import_node_fs4.copyFileSync)(pkgJsonSrc, (0, import_node_path5.join)(pkgCliBaseDir, "package.json"));
|
|
242011
|
-
}
|
|
242012
|
-
const preludeDir = (0, import_node_path5.join)(cacheDir, "pkg-prelude");
|
|
242013
|
-
(0, import_node_fs4.mkdirSync)(preludeDir, { recursive: true });
|
|
241760
|
+
(0, import_node_fs5.mkdirSync)(cacheDir, { recursive: true }), (0, import_node_fs5.copyFileSync)(cliSrc, pkgCliPath);
|
|
241761
|
+
const pkgJsonSrc = (0, import_node_path6.join)(distPkgPath, "package.json");
|
|
241762
|
+
(0, import_node_fs5.existsSync)(pkgJsonSrc) && (0, import_node_fs5.copyFileSync)(pkgJsonSrc, (0, import_node_path6.join)(pkgCliBaseDir, "package.json"));
|
|
241763
|
+
const preludeDir = (0, import_node_path6.join)(cacheDir, "pkg-prelude");
|
|
241764
|
+
(0, import_node_fs5.mkdirSync)(preludeDir, { recursive: true });
|
|
242014
241765
|
for (const file of ["bootstrap.js", "diagnostic.js"]) {
|
|
242015
|
-
const src = (0,
|
|
242016
|
-
|
|
242017
|
-
(0, import_node_fs4.copyFileSync)(src, (0, import_node_path5.join)(preludeDir, file));
|
|
242018
|
-
}
|
|
242019
|
-
}
|
|
242020
|
-
const commonSrc = (0, import_node_path5.join)(distPkgPath, "pkg-common.cjs");
|
|
242021
|
-
if ((0, import_node_fs4.existsSync)(commonSrc)) {
|
|
242022
|
-
(0, import_node_fs4.copyFileSync)(commonSrc, (0, import_node_path5.join)(cacheDir, "pkg-common.cjs"));
|
|
241766
|
+
const src = (0, import_node_path6.join)(distPkgPath, "pkg-prelude", file);
|
|
241767
|
+
(0, import_node_fs5.existsSync)(src) && (0, import_node_fs5.copyFileSync)(src, (0, import_node_path6.join)(preludeDir, file));
|
|
242023
241768
|
}
|
|
242024
|
-
const
|
|
242025
|
-
(0,
|
|
241769
|
+
const commonSrc = (0, import_node_path6.join)(distPkgPath, "pkg-common.cjs");
|
|
241770
|
+
(0, import_node_fs5.existsSync)(commonSrc) && (0, import_node_fs5.copyFileSync)(commonSrc, (0, import_node_path6.join)(cacheDir, "pkg-common.cjs"));
|
|
241771
|
+
const dictionaryDir = (0, import_node_path6.join)(pkgCliBaseDir, "dictionary");
|
|
241772
|
+
(0, import_node_fs5.mkdirSync)(dictionaryDir, { recursive: true });
|
|
242026
241773
|
for (const file of ["v8-7.8.js", "v8-8.4.js", "v8-12.4.js"]) {
|
|
242027
|
-
const src = (0,
|
|
242028
|
-
|
|
242029
|
-
(0, import_node_fs4.copyFileSync)(src, (0, import_node_path5.join)(dictionaryDir, file));
|
|
242030
|
-
}
|
|
241774
|
+
const src = (0, import_node_path6.join)(distPkgPath, "pkg-dictionary", file);
|
|
241775
|
+
(0, import_node_fs5.existsSync)(src) && (0, import_node_fs5.copyFileSync)(src, (0, import_node_path6.join)(dictionaryDir, file));
|
|
242031
241776
|
}
|
|
242032
241777
|
return pkgCliPath;
|
|
242033
241778
|
}
|
|
242034
241779
|
__name(ensurePkgCli, "ensurePkgCli");
|
|
242035
241780
|
function spawnAsync(command, args, options = {}) {
|
|
242036
|
-
return new Promise((
|
|
241781
|
+
return new Promise((resolve22) => {
|
|
242037
241782
|
const proc = (0, import_node_child_process2.spawn)(command, args, {
|
|
242038
241783
|
cwd: options.cwd,
|
|
242039
241784
|
env: options.env || process.env,
|
|
242040
241785
|
stdio: options.verbose ? "inherit" : "pipe"
|
|
242041
241786
|
});
|
|
242042
|
-
let stdout = "";
|
|
242043
|
-
|
|
242044
|
-
|
|
242045
|
-
|
|
242046
|
-
|
|
242047
|
-
|
|
242048
|
-
|
|
242049
|
-
stderr += data.toString();
|
|
242050
|
-
});
|
|
242051
|
-
}
|
|
242052
|
-
proc.on("close", (code) => {
|
|
242053
|
-
resolve2({
|
|
241787
|
+
let stdout = "", stderr = "";
|
|
241788
|
+
options.verbose || (proc.stdout?.on("data", (data) => {
|
|
241789
|
+
stdout += data.toString();
|
|
241790
|
+
}), proc.stderr?.on("data", (data) => {
|
|
241791
|
+
stderr += data.toString();
|
|
241792
|
+
})), proc.on("close", (code) => {
|
|
241793
|
+
resolve22({
|
|
242054
241794
|
exitCode: code ?? 1,
|
|
242055
241795
|
stdout,
|
|
242056
241796
|
stderr
|
|
242057
241797
|
});
|
|
242058
|
-
})
|
|
242059
|
-
|
|
242060
|
-
resolve2({
|
|
241798
|
+
}), proc.on("error", (error) => {
|
|
241799
|
+
resolve22({
|
|
242061
241800
|
exitCode: 1,
|
|
242062
241801
|
stdout,
|
|
242063
241802
|
stderr: error.message
|
|
@@ -242067,13 +241806,8 @@ function spawnAsync(command, args, options = {}) {
|
|
|
242067
241806
|
}
|
|
242068
241807
|
__name(spawnAsync, "spawnAsync");
|
|
242069
241808
|
async function compileWithPkgSubprocess(ctx, wrapperPath, target2, outputPath, spinner) {
|
|
242070
|
-
const nodePath = await ensurePortableNode(spinner);
|
|
242071
|
-
|
|
242072
|
-
const pkgTarget = TARGET_MAP[target2];
|
|
242073
|
-
const outputDir = (0, import_node_path5.dirname)(outputPath);
|
|
242074
|
-
if (!(0, import_node_fs4.existsSync)(outputDir)) {
|
|
242075
|
-
(0, import_node_fs4.mkdirSync)(outputDir, { recursive: true });
|
|
242076
|
-
}
|
|
241809
|
+
const nodePath = await ensurePortableNode(spinner), pkgCliPath = ensurePkgCli(), pkgTarget = TARGET_MAP[target2], outputDir = (0, import_node_path6.dirname)(outputPath);
|
|
241810
|
+
(0, import_node_fs5.existsSync)(outputDir) || (0, import_node_fs5.mkdirSync)(outputDir, { recursive: true });
|
|
242077
241811
|
const args = [
|
|
242078
241812
|
pkgCliPath,
|
|
242079
241813
|
wrapperPath,
|
|
@@ -242085,18 +241819,16 @@ async function compileWithPkgSubprocess(ctx, wrapperPath, target2, outputPath, s
|
|
|
242085
241819
|
"experimental-transform-types,disable-warning=ExperimentalWarning",
|
|
242086
241820
|
"--public"
|
|
242087
241821
|
];
|
|
242088
|
-
if (ctx.options.include && ctx.options.include.length > 0)
|
|
242089
|
-
for (const pattern of ctx.options.include)
|
|
241822
|
+
if (ctx.options.include && ctx.options.include.length > 0)
|
|
241823
|
+
for (const pattern of ctx.options.include)
|
|
242090
241824
|
args.push("--assets", pattern);
|
|
242091
|
-
}
|
|
242092
|
-
}
|
|
242093
241825
|
spinner?.start(`Compiling for ${target2}...`);
|
|
242094
241826
|
const result = await spawnAsync(nodePath, args, {
|
|
242095
241827
|
cwd: ctx.buildDir,
|
|
242096
241828
|
env: {
|
|
242097
241829
|
...process.env,
|
|
242098
241830
|
// Set pkg cache path for pkg-fetch downloads
|
|
242099
|
-
PKG_CACHE_PATH: (0,
|
|
241831
|
+
PKG_CACHE_PATH: (0, import_node_path6.join)(getCacheDir(), "pkg-cache")
|
|
242100
241832
|
},
|
|
242101
241833
|
verbose: ctx.options.verbose
|
|
242102
241834
|
});
|
|
@@ -242115,12 +241847,8 @@ async function compileWithPkg(ctx, wrapperPath, target2, outputPath, spinner) {
|
|
|
242115
241847
|
await compileWithPkgSubprocess(ctx, wrapperPath, target2, outputPath, spinner);
|
|
242116
241848
|
return;
|
|
242117
241849
|
}
|
|
242118
|
-
const { exec } = await import("@yao-pkg/pkg");
|
|
242119
|
-
|
|
242120
|
-
const outputDir = (0, import_node_path5.dirname)(outputPath);
|
|
242121
|
-
if (!(0, import_node_fs4.existsSync)(outputDir)) {
|
|
242122
|
-
(0, import_node_fs4.mkdirSync)(outputDir, { recursive: true });
|
|
242123
|
-
}
|
|
241850
|
+
const { exec } = await import("@yao-pkg/pkg"), pkgTarget = TARGET_MAP[target2], outputDir = (0, import_node_path6.dirname)(outputPath);
|
|
241851
|
+
(0, import_node_fs5.existsSync)(outputDir) || (0, import_node_fs5.mkdirSync)(outputDir, { recursive: true });
|
|
242124
241852
|
const pkgConfig = [
|
|
242125
241853
|
wrapperPath,
|
|
242126
241854
|
"--targets",
|
|
@@ -242132,69 +241860,43 @@ async function compileWithPkg(ctx, wrapperPath, target2, outputPath, spinner) {
|
|
|
242132
241860
|
"--public"
|
|
242133
241861
|
// Include source instead of bytecode (required for cross-compilation)
|
|
242134
241862
|
];
|
|
242135
|
-
if (ctx.options.include && ctx.options.include.length > 0)
|
|
242136
|
-
for (const pattern of ctx.options.include)
|
|
241863
|
+
if (ctx.options.include && ctx.options.include.length > 0)
|
|
241864
|
+
for (const pattern of ctx.options.include)
|
|
242137
241865
|
pkgConfig.push("--assets", pattern);
|
|
242138
|
-
}
|
|
242139
|
-
}
|
|
242140
241866
|
await exec(pkgConfig);
|
|
242141
241867
|
}
|
|
242142
241868
|
__name(compileWithPkg, "compileWithPkg");
|
|
242143
241869
|
function detectTopLevelAwait(filePath) {
|
|
242144
|
-
const
|
|
242145
|
-
|
|
242146
|
-
|
|
242147
|
-
let depth = 0;
|
|
242148
|
-
let inMultiLineComment = false;
|
|
241870
|
+
const lines = (0, import_node_fs5.readFileSync)(filePath, "utf-8").split(`
|
|
241871
|
+
`), awaits = [];
|
|
241872
|
+
let depth = 0, inMultiLineComment = false;
|
|
242149
241873
|
for (let i = 0; i < lines.length; i++) {
|
|
242150
241874
|
let line = lines[i];
|
|
242151
241875
|
if (inMultiLineComment) {
|
|
242152
241876
|
const endIdx = line.indexOf("*/");
|
|
242153
|
-
if (endIdx !== -1)
|
|
242154
|
-
line = line.slice(endIdx + 2);
|
|
242155
|
-
|
|
242156
|
-
} else {
|
|
241877
|
+
if (endIdx !== -1)
|
|
241878
|
+
line = line.slice(endIdx + 2), inMultiLineComment = false;
|
|
241879
|
+
else
|
|
242157
241880
|
continue;
|
|
242158
|
-
}
|
|
242159
241881
|
}
|
|
242160
241882
|
const singleLineCommentIdx = line.indexOf("//");
|
|
242161
|
-
|
|
242162
|
-
line = line.slice(0, singleLineCommentIdx);
|
|
242163
|
-
}
|
|
241883
|
+
singleLineCommentIdx !== -1 && (line = line.slice(0, singleLineCommentIdx));
|
|
242164
241884
|
const multiLineStart = line.indexOf("/*");
|
|
242165
241885
|
if (multiLineStart !== -1) {
|
|
242166
241886
|
const multiLineEnd = line.indexOf("*/", multiLineStart);
|
|
242167
|
-
|
|
242168
|
-
line = line.slice(0, multiLineStart) + line.slice(multiLineEnd + 2);
|
|
242169
|
-
} else {
|
|
242170
|
-
line = line.slice(0, multiLineStart);
|
|
242171
|
-
inMultiLineComment = true;
|
|
242172
|
-
}
|
|
242173
|
-
}
|
|
242174
|
-
const openBraces = (line.match(/\{/g) || []).length;
|
|
242175
|
-
const closeBraces = (line.match(/\}/g) || []).length;
|
|
242176
|
-
if (/\b(function|class|async\s+function)\b/.test(line) && line.includes("{")) {
|
|
242177
|
-
depth += 1;
|
|
242178
|
-
} else if (/=>\s*\{/.test(line)) {
|
|
242179
|
-
depth += 1;
|
|
241887
|
+
multiLineEnd !== -1 ? line = line.slice(0, multiLineStart) + line.slice(multiLineEnd + 2) : (line = line.slice(0, multiLineStart), inMultiLineComment = true);
|
|
242180
241888
|
}
|
|
242181
|
-
|
|
242182
|
-
if (depth < 0)
|
|
242183
|
-
depth = 0;
|
|
242184
|
-
if (depth === 0 && /\bawait\b/.test(line)) {
|
|
241889
|
+
const openBraces = (line.match(/\{/g) || []).length, closeBraces = (line.match(/\}/g) || []).length;
|
|
241890
|
+
if ((/\b(function|class|async\s+function)\b/.test(line) && line.includes("{") || /=>\s*\{/.test(line)) && (depth += 1), depth += openBraces - closeBraces, depth < 0 && (depth = 0), depth === 0 && /\bawait\b/.test(line)) {
|
|
242185
241891
|
const withoutStrings = line.replace(/(["'`])(?:(?!\1)[^\\]|\\.)*\1/g, "");
|
|
242186
|
-
|
|
242187
|
-
awaits.push(i + 1);
|
|
242188
|
-
}
|
|
241892
|
+
/\bawait\b/.test(withoutStrings) && awaits.push(i + 1);
|
|
242189
241893
|
}
|
|
242190
241894
|
}
|
|
242191
241895
|
return awaits;
|
|
242192
241896
|
}
|
|
242193
241897
|
__name(detectTopLevelAwait, "detectTopLevelAwait");
|
|
242194
241898
|
function log(ctx, message) {
|
|
242195
|
-
|
|
242196
|
-
console.log(message);
|
|
242197
|
-
}
|
|
241899
|
+
ctx.options.quiet || console.log(message);
|
|
242198
241900
|
}
|
|
242199
241901
|
__name(log, "log");
|
|
242200
241902
|
function createSpinner(ctx, text) {
|
|
@@ -242205,61 +241907,37 @@ function createSpinner(ctx, text) {
|
|
|
242205
241907
|
}
|
|
242206
241908
|
__name(createSpinner, "createSpinner");
|
|
242207
241909
|
function runDryRun(ctx) {
|
|
242208
|
-
console.log((0, import_node_util2.styleText)("bold",
|
|
242209
|
-
|
|
242210
|
-
|
|
242211
|
-
`);
|
|
242212
|
-
console.log((0, import_node_util2.styleText)("bold", "Targets:"));
|
|
241910
|
+
console.log((0, import_node_util2.styleText)("bold", `Dry run mode - no files will be created
|
|
241911
|
+
`)), console.log((0, import_node_util2.styleText)("bold", "Entry point:")), console.log(` ${ctx.entryPath}
|
|
241912
|
+
`), console.log((0, import_node_util2.styleText)("bold", "Targets:"));
|
|
242213
241913
|
for (const target2 of ctx.resolvedTargets) {
|
|
242214
241914
|
const outputPath = getOutputPath(ctx, target2);
|
|
242215
241915
|
console.log(` ${target2} \u2192 ${outputPath}`);
|
|
242216
241916
|
}
|
|
242217
|
-
console.log()
|
|
242218
|
-
if (ctx.options.include && ctx.options.include.length > 0) {
|
|
241917
|
+
if (console.log(), ctx.options.include && ctx.options.include.length > 0) {
|
|
242219
241918
|
console.log((0, import_node_util2.styleText)("bold", "Assets to include:"));
|
|
242220
|
-
for (const pattern of ctx.options.include)
|
|
241919
|
+
for (const pattern of ctx.options.include)
|
|
242221
241920
|
console.log(` ${pattern}`);
|
|
242222
|
-
}
|
|
242223
241921
|
console.log();
|
|
242224
241922
|
}
|
|
242225
241923
|
if (ctx.options.external && ctx.options.external.length > 0) {
|
|
242226
241924
|
console.log((0, import_node_util2.styleText)("bold", "External packages (not bundled):"));
|
|
242227
|
-
for (const pkg of ctx.options.external)
|
|
241925
|
+
for (const pkg of ctx.options.external)
|
|
242228
241926
|
console.log(` ${pkg}`);
|
|
242229
|
-
}
|
|
242230
241927
|
console.log();
|
|
242231
241928
|
}
|
|
242232
|
-
|
|
242233
|
-
console.log((0, import_node_util2.styleText)("bold", "Minification:"), "enabled");
|
|
242234
|
-
console.log();
|
|
242235
|
-
}
|
|
242236
|
-
console.log((0, import_node_util2.styleText)("bold", "Build steps:"));
|
|
242237
|
-
console.log(" 1. Bundle user script with esbuild");
|
|
242238
|
-
console.log(" 2. Copy thinkwell packages");
|
|
242239
|
-
console.log(" 3. Generate wrapper entry point");
|
|
242240
|
-
console.log(` 4. Compile with pkg for ${ctx.resolvedTargets.length} target(s)`);
|
|
242241
|
-
console.log();
|
|
241929
|
+
ctx.options.minify && (console.log((0, import_node_util2.styleText)("bold", "Minification:"), "enabled"), console.log()), console.log((0, import_node_util2.styleText)("bold", "Build steps:")), console.log(" 1. Bundle user script with esbuild"), console.log(" 2. Copy thinkwell packages"), console.log(" 3. Generate wrapper entry point"), console.log(` 4. Compile with pkg for ${ctx.resolvedTargets.length} target(s)`), console.log();
|
|
242242
241930
|
const topLevelAwaits = detectTopLevelAwait(ctx.entryPath);
|
|
242243
|
-
|
|
242244
|
-
|
|
242245
|
-
console.log(" Top-level await is not supported in compiled binaries.");
|
|
242246
|
-
console.log(` Found at line(s): ${topLevelAwaits.join(", ")}`);
|
|
242247
|
-
console.log(" Wrap async code in an async main() function instead.\n");
|
|
242248
|
-
}
|
|
242249
|
-
console.log((0, import_node_util2.styleText)("dim", "Run without --dry-run to build."));
|
|
241931
|
+
topLevelAwaits.length > 0 && (console.log((0, import_node_util2.styleText)("yellow", "Warning: Top-level await detected")), console.log(" Top-level await is not supported in compiled binaries."), console.log(` Found at line(s): ${topLevelAwaits.join(", ")}`), console.log(` Wrap async code in an async main() function instead.
|
|
241932
|
+
`)), console.log((0, import_node_util2.styleText)("dim", "Run without --dry-run to build."));
|
|
242250
241933
|
}
|
|
242251
241934
|
__name(runDryRun, "runDryRun");
|
|
242252
241935
|
async function runBundle(options) {
|
|
242253
|
-
const entryPath = (0,
|
|
242254
|
-
|
|
242255
|
-
|
|
242256
|
-
|
|
242257
|
-
|
|
242258
|
-
const depCheck = await checkDependencies(projectRoot);
|
|
242259
|
-
if (hasMissingDeps(depCheck, { requireTypescript })) {
|
|
242260
|
-
process.stderr.write(formatMissingDepsError(depCheck, { requireTypescript }) + "\n");
|
|
242261
|
-
process.exit(2);
|
|
242262
|
-
}
|
|
241936
|
+
const entryPath = (0, import_node_path6.isAbsolute)(options.entry) ? options.entry : (0, import_node_path6.resolve)(process.cwd(), options.entry), projectRoot = findProjectRoot((0, import_node_path6.dirname)(entryPath));
|
|
241937
|
+
if (projectRoot && (0, import_node_fs5.existsSync)(entryPath)) {
|
|
241938
|
+
const source = (0, import_node_fs5.readFileSync)(entryPath, "utf-8"), requireTypescript = hasJsonSchemaMarkers(source), depCheck = await checkDependencies(projectRoot);
|
|
241939
|
+
hasMissingDeps(depCheck, { requireTypescript }) && (process.stderr.write(formatMissingDepsError(depCheck, { requireTypescript }) + `
|
|
241940
|
+
`), process.exit(2));
|
|
242263
241941
|
}
|
|
242264
241942
|
if (options.watch) {
|
|
242265
241943
|
await runWatchMode(options, projectRoot);
|
|
@@ -242268,162 +241946,98 @@ async function runBundle(options) {
|
|
|
242268
241946
|
const ctx = initBundleContext(options);
|
|
242269
241947
|
ctx.projectDir = projectRoot;
|
|
242270
241948
|
const topLevelAwaits = detectTopLevelAwait(ctx.entryPath);
|
|
242271
|
-
if (topLevelAwaits.length > 0) {
|
|
242272
|
-
|
|
242273
|
-
console.log(" Top-level await is not supported in compiled binaries.");
|
|
242274
|
-
console.log(` Found at line(s): ${topLevelAwaits.join(", ")}`);
|
|
242275
|
-
console.log(" Wrap async code in an async main() function instead.\n");
|
|
242276
|
-
}
|
|
242277
|
-
if (options.dryRun) {
|
|
241949
|
+
if (topLevelAwaits.length > 0 && (console.log((0, import_node_util2.styleText)("yellow", "Warning: Top-level await detected")), console.log(" Top-level await is not supported in compiled binaries."), console.log(` Found at line(s): ${topLevelAwaits.join(", ")}`), console.log(` Wrap async code in an async main() function instead.
|
|
241950
|
+
`)), options.dryRun) {
|
|
242278
241951
|
runDryRun(ctx);
|
|
242279
241952
|
return;
|
|
242280
241953
|
}
|
|
242281
241954
|
log(ctx, `Building ${(0, import_node_util2.styleText)("bold", ctx.entryBasename)}...
|
|
242282
|
-
`);
|
|
242283
|
-
if ((0, import_node_fs4.existsSync)(ctx.buildDir)) {
|
|
242284
|
-
(0, import_node_fs4.rmSync)(ctx.buildDir, { recursive: true });
|
|
242285
|
-
}
|
|
242286
|
-
(0, import_node_fs4.mkdirSync)(ctx.buildDir, { recursive: true });
|
|
241955
|
+
`), (0, import_node_fs5.existsSync)(ctx.buildDir) && (0, import_node_fs5.rmSync)(ctx.buildDir, { recursive: true }), (0, import_node_fs5.mkdirSync)(ctx.buildDir, { recursive: true });
|
|
242287
241956
|
try {
|
|
242288
241957
|
let spinner = createSpinner(ctx, "Bundling with esbuild...");
|
|
242289
241958
|
spinner.start();
|
|
242290
241959
|
const userBundlePath = await bundleUserScript(ctx);
|
|
242291
|
-
spinner.succeed("User script bundled");
|
|
242292
|
-
|
|
242293
|
-
|
|
242294
|
-
copyThinkwellBundles(ctx);
|
|
242295
|
-
spinner.succeed("Thinkwell packages ready");
|
|
242296
|
-
const wrapperPath = (0, import_node_path5.join)(ctx.buildDir, "wrapper.cjs");
|
|
242297
|
-
const wrapperSource = generateWrapperSource(userBundlePath);
|
|
242298
|
-
(0, import_node_fs4.writeFileSync)(wrapperPath, wrapperSource);
|
|
242299
|
-
if (ctx.options.verbose) {
|
|
242300
|
-
log(ctx, " Generated wrapper entry point");
|
|
242301
|
-
}
|
|
241960
|
+
spinner.succeed("User script bundled"), spinner = createSpinner(ctx, "Preparing thinkwell packages..."), spinner.start(), copyThinkwellBundles(ctx), spinner.succeed("Thinkwell packages ready");
|
|
241961
|
+
const wrapperPath = (0, import_node_path6.join)(ctx.buildDir, "wrapper.cjs"), wrapperSource = generateWrapperSource(userBundlePath);
|
|
241962
|
+
(0, import_node_fs5.writeFileSync)(wrapperPath, wrapperSource), ctx.options.verbose && log(ctx, " Generated wrapper entry point");
|
|
242302
241963
|
const outputs = [];
|
|
242303
241964
|
for (const target2 of ctx.resolvedTargets) {
|
|
242304
241965
|
const outputPath = getOutputPath(ctx, target2);
|
|
242305
|
-
spinner = createSpinner(ctx, `Compiling for ${target2}...`);
|
|
242306
|
-
spinner.start();
|
|
242307
|
-
await compileWithPkg(ctx, wrapperPath, target2, outputPath, spinner);
|
|
242308
|
-
outputs.push(outputPath);
|
|
242309
|
-
spinner.succeed(`Built ${(0, import_node_path5.basename)(outputPath)}`);
|
|
241966
|
+
spinner = createSpinner(ctx, `Compiling for ${target2}...`), spinner.start(), await compileWithPkg(ctx, wrapperPath, target2, outputPath, spinner), outputs.push(outputPath), spinner.succeed(`Built ${(0, import_node_path6.basename)(outputPath)}`);
|
|
242310
241967
|
}
|
|
242311
|
-
log(ctx, "");
|
|
242312
|
-
|
|
242313
|
-
log(ctx, "");
|
|
242314
|
-
log(ctx, (0, import_node_util2.styleText)("bold", "Output:"));
|
|
242315
|
-
for (const output of outputs) {
|
|
241968
|
+
log(ctx, ""), log(ctx, (0, import_node_util2.styleText)("green", "Build complete!")), log(ctx, ""), log(ctx, (0, import_node_util2.styleText)("bold", "Output:"));
|
|
241969
|
+
for (const output of outputs)
|
|
242316
241970
|
log(ctx, ` ${output}`);
|
|
242317
|
-
}
|
|
242318
241971
|
} finally {
|
|
242319
|
-
if (
|
|
241972
|
+
if (ctx.options.verbose)
|
|
241973
|
+
log(ctx, `
|
|
241974
|
+
Build artifacts preserved in: ${ctx.buildDir}`);
|
|
241975
|
+
else
|
|
242320
241976
|
try {
|
|
242321
|
-
(0,
|
|
241977
|
+
(0, import_node_fs5.rmSync)(ctx.buildDir, { recursive: true });
|
|
242322
241978
|
} catch {
|
|
242323
241979
|
}
|
|
242324
|
-
} else {
|
|
242325
|
-
log(ctx, `
|
|
242326
|
-
Build artifacts preserved in: ${ctx.buildDir}`);
|
|
242327
|
-
}
|
|
242328
241980
|
}
|
|
242329
241981
|
}
|
|
242330
241982
|
__name(runBundle, "runBundle");
|
|
242331
241983
|
async function runWatchMode(options, projectDir) {
|
|
242332
241984
|
const ctx = initBundleContext(options);
|
|
242333
|
-
ctx.projectDir = projectDir
|
|
242334
|
-
|
|
242335
|
-
|
|
242336
|
-
let buildInProgress = false;
|
|
242337
|
-
let rebuildQueued = false;
|
|
242338
|
-
let debounceTimer = null;
|
|
241985
|
+
ctx.projectDir = projectDir, console.log((0, import_node_util2.styleText)("bold", `Watching ${ctx.entryBasename} for changes...`)), console.log((0, import_node_util2.styleText)("dim", `Press Ctrl+C to stop.
|
|
241986
|
+
`));
|
|
241987
|
+
let buildInProgress = false, rebuildQueued = false, debounceTimer = null;
|
|
242339
241988
|
const DEBOUNCE_MS = 100;
|
|
242340
241989
|
async function doBuild() {
|
|
242341
241990
|
if (buildInProgress) {
|
|
242342
241991
|
rebuildQueued = true;
|
|
242343
241992
|
return;
|
|
242344
241993
|
}
|
|
242345
|
-
buildInProgress = true;
|
|
242346
|
-
rebuildQueued = false;
|
|
241994
|
+
buildInProgress = true, rebuildQueued = false;
|
|
242347
241995
|
const startTime = Date.now();
|
|
242348
241996
|
console.log((0, import_node_util2.styleText)("dim", `[${(/* @__PURE__ */ new Date()).toLocaleTimeString()}] Building...`));
|
|
242349
241997
|
try {
|
|
242350
241998
|
const freshCtx = initBundleContext(options);
|
|
242351
|
-
|
|
242352
|
-
(0, import_node_fs4.rmSync)(freshCtx.buildDir, { recursive: true });
|
|
242353
|
-
}
|
|
242354
|
-
(0, import_node_fs4.mkdirSync)(freshCtx.buildDir, { recursive: true });
|
|
241999
|
+
(0, import_node_fs5.existsSync)(freshCtx.buildDir) && (0, import_node_fs5.rmSync)(freshCtx.buildDir, { recursive: true }), (0, import_node_fs5.mkdirSync)(freshCtx.buildDir, { recursive: true });
|
|
242355
242000
|
const userBundlePath = await bundleUserScript(freshCtx);
|
|
242356
242001
|
copyThinkwellBundles(freshCtx);
|
|
242357
|
-
const wrapperPath = (0,
|
|
242358
|
-
|
|
242359
|
-
(0, import_node_fs4.writeFileSync)(wrapperPath, wrapperSource);
|
|
242002
|
+
const wrapperPath = (0, import_node_path6.join)(freshCtx.buildDir, "wrapper.cjs"), wrapperSource = generateWrapperSource(userBundlePath);
|
|
242003
|
+
(0, import_node_fs5.writeFileSync)(wrapperPath, wrapperSource);
|
|
242360
242004
|
const outputs = [];
|
|
242361
242005
|
for (const target2 of freshCtx.resolvedTargets) {
|
|
242362
242006
|
const outputPath = getOutputPath(freshCtx, target2);
|
|
242363
|
-
await compileWithPkg(freshCtx, wrapperPath, target2, outputPath);
|
|
242364
|
-
outputs.push(outputPath);
|
|
242007
|
+
await compileWithPkg(freshCtx, wrapperPath, target2, outputPath), outputs.push(outputPath);
|
|
242365
242008
|
}
|
|
242366
|
-
if (!freshCtx.options.verbose)
|
|
242009
|
+
if (!freshCtx.options.verbose)
|
|
242367
242010
|
try {
|
|
242368
|
-
(0,
|
|
242011
|
+
(0, import_node_fs5.rmSync)(freshCtx.buildDir, { recursive: true });
|
|
242369
242012
|
} catch {
|
|
242370
242013
|
}
|
|
242371
|
-
}
|
|
242372
242014
|
const elapsed = Date.now() - startTime;
|
|
242373
242015
|
console.log((0, import_node_util2.styleText)("green", `\u2713 Built in ${elapsed}ms`));
|
|
242374
|
-
for (const output of outputs)
|
|
242375
|
-
console.log((0, import_node_util2.styleText)("dim", ` ${(0,
|
|
242376
|
-
}
|
|
242016
|
+
for (const output of outputs)
|
|
242017
|
+
console.log((0, import_node_util2.styleText)("dim", ` ${(0, import_node_path6.basename)(output)}`));
|
|
242377
242018
|
console.log();
|
|
242378
242019
|
} catch (error) {
|
|
242379
242020
|
const message = error instanceof Error ? error.message : String(error);
|
|
242380
|
-
console.log((0, import_node_util2.styleText)("red", `\u2717 Build failed: ${message}`));
|
|
242381
|
-
console.log();
|
|
242021
|
+
console.log((0, import_node_util2.styleText)("red", `\u2717 Build failed: ${message}`)), console.log();
|
|
242382
242022
|
} finally {
|
|
242383
|
-
buildInProgress = false;
|
|
242384
|
-
if (rebuildQueued) {
|
|
242385
|
-
doBuild();
|
|
242386
|
-
}
|
|
242023
|
+
buildInProgress = false, rebuildQueued && doBuild();
|
|
242387
242024
|
}
|
|
242388
242025
|
}
|
|
242389
242026
|
__name(doBuild, "doBuild");
|
|
242390
242027
|
function scheduleRebuild() {
|
|
242391
|
-
|
|
242392
|
-
|
|
242393
|
-
}
|
|
242394
|
-
debounceTimer = setTimeout(() => {
|
|
242395
|
-
debounceTimer = null;
|
|
242396
|
-
doBuild();
|
|
242028
|
+
debounceTimer && clearTimeout(debounceTimer), debounceTimer = setTimeout(() => {
|
|
242029
|
+
debounceTimer = null, doBuild();
|
|
242397
242030
|
}, DEBOUNCE_MS);
|
|
242398
242031
|
}
|
|
242399
242032
|
__name(scheduleRebuild, "scheduleRebuild");
|
|
242400
242033
|
await doBuild();
|
|
242401
|
-
const watchDir = ctx.entryDir
|
|
242402
|
-
|
|
242403
|
-
|
|
242404
|
-
|
|
242405
|
-
|
|
242406
|
-
return;
|
|
242407
|
-
}
|
|
242408
|
-
if (!/\.(ts|tsx|js|jsx|mts|mjs|cts|cjs|json)$/.test(filename)) {
|
|
242409
|
-
return;
|
|
242410
|
-
}
|
|
242411
|
-
if (ctx.options.verbose) {
|
|
242412
|
-
console.log((0, import_node_util2.styleText)("dim", ` Changed: ${filename}`));
|
|
242413
|
-
}
|
|
242414
|
-
scheduleRebuild();
|
|
242415
|
-
});
|
|
242416
|
-
const cleanup = /* @__PURE__ */ __name(() => {
|
|
242417
|
-
watcher.close();
|
|
242418
|
-
if (debounceTimer) {
|
|
242419
|
-
clearTimeout(debounceTimer);
|
|
242420
|
-
}
|
|
242421
|
-
console.log("\nStopped watching.");
|
|
242422
|
-
process.exit(0);
|
|
242034
|
+
const watchDir = ctx.entryDir, watcher = (0, import_node_fs5.watch)(watchDir, { recursive: true }, (_eventType, filename) => {
|
|
242035
|
+
filename && (filename.includes("node_modules") || filename.startsWith(".") || filename.endsWith(".d.ts") || /\.(ts|tsx|js|jsx|mts|mjs|cts|cjs|json)$/.test(filename) && (ctx.options.verbose && console.log((0, import_node_util2.styleText)("dim", ` Changed: ${filename}`)), scheduleRebuild()));
|
|
242036
|
+
}), cleanup = /* @__PURE__ */ __name(() => {
|
|
242037
|
+
watcher.close(), debounceTimer && clearTimeout(debounceTimer), console.log(`
|
|
242038
|
+
Stopped watching.`), process.exit(0);
|
|
242423
242039
|
}, "cleanup");
|
|
242424
|
-
process.on("SIGINT", cleanup)
|
|
242425
|
-
process.on("SIGTERM", cleanup);
|
|
242426
|
-
await new Promise(() => {
|
|
242040
|
+
process.on("SIGINT", cleanup), process.on("SIGTERM", cleanup), await new Promise(() => {
|
|
242427
242041
|
});
|
|
242428
242042
|
}
|
|
242429
242043
|
__name(runWatchMode, "runWatchMode");
|
|
@@ -242489,7 +242103,8 @@ ${greenBold("Configuration via package.json:")}
|
|
|
242489
242103
|
|
|
242490
242104
|
${dim("Note: Binaries are ~70-90 MB due to the embedded Node.js runtime.")}
|
|
242491
242105
|
${dim(" Use --minify to reduce bundle size (though Node.js runtime dominates).")}
|
|
242492
|
-
`.trim() +
|
|
242106
|
+
`.trim() + `
|
|
242107
|
+
`);
|
|
242493
242108
|
}
|
|
242494
242109
|
__name(showBundleHelp, "showBundleHelp");
|
|
242495
242110
|
// Annotate the CommonJS export names for ESM import in node:
|