@nasti-toolchain/nasti 2.5.0 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +1504 -183
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1495 -174
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +1455 -134
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1452 -131
- package/dist/index.js.map +1 -1
- package/package.json +5 -1
package/dist/index.cjs
CHANGED
|
@@ -5,16 +5,25 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __glob = (map) => (
|
|
9
|
-
var fn = map[
|
|
8
|
+
var __glob = (map) => (path23) => {
|
|
9
|
+
var fn = map[path23];
|
|
10
10
|
if (fn) return fn();
|
|
11
|
-
throw new Error("Module not found in bundle: " +
|
|
11
|
+
throw new Error("Module not found in bundle: " + path23);
|
|
12
12
|
};
|
|
13
|
-
var __esm = (fn, res) => function __init() {
|
|
14
|
-
|
|
13
|
+
var __esm = (fn, res, err) => function __init() {
|
|
14
|
+
if (err) throw err[0];
|
|
15
|
+
try {
|
|
16
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
17
|
+
} catch (e) {
|
|
18
|
+
throw err = [e], e;
|
|
19
|
+
}
|
|
15
20
|
};
|
|
16
21
|
var __commonJS = (cb, mod) => function __require2() {
|
|
17
|
-
|
|
22
|
+
try {
|
|
23
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
24
|
+
} catch (e) {
|
|
25
|
+
throw mod = 0, e;
|
|
26
|
+
}
|
|
18
27
|
};
|
|
19
28
|
var __export = (target, all) => {
|
|
20
29
|
for (var name in all)
|
|
@@ -138,7 +147,7 @@ function createLogger(level = "info", options = {}) {
|
|
|
138
147
|
const canClearScreen = allowClearScreen && process.stdout.isTTY && !process.env.CI;
|
|
139
148
|
const clear = canClearScreen ? clearScreen : () => {
|
|
140
149
|
};
|
|
141
|
-
function
|
|
150
|
+
function format2(type, msg, options2 = {}) {
|
|
142
151
|
if (options2.timestamp) {
|
|
143
152
|
const tag = type === "info" ? import_picocolors.default.cyan(import_picocolors.default.bold(prefix)) : type === "warn" ? import_picocolors.default.yellow(import_picocolors.default.bold(prefix)) : import_picocolors.default.red(import_picocolors.default.bold(prefix));
|
|
144
153
|
return `${import_picocolors.default.dim(timeFormatter.format(/* @__PURE__ */ new Date()))} ${tag} ${msg}`;
|
|
@@ -155,16 +164,16 @@ function createLogger(level = "info", options = {}) {
|
|
|
155
164
|
if (type === lastType && msg === lastMsg) {
|
|
156
165
|
sameCount++;
|
|
157
166
|
clear();
|
|
158
|
-
console_[method](
|
|
167
|
+
console_[method](format2(type, msg, options2), import_picocolors.default.yellow(`(x${sameCount + 1})`));
|
|
159
168
|
} else {
|
|
160
169
|
sameCount = 0;
|
|
161
170
|
lastMsg = msg;
|
|
162
171
|
lastType = type;
|
|
163
172
|
if (options2.clear) clear();
|
|
164
|
-
console_[method](
|
|
173
|
+
console_[method](format2(type, msg, options2));
|
|
165
174
|
}
|
|
166
175
|
} else {
|
|
167
|
-
console_[method](
|
|
176
|
+
console_[method](format2(type, msg, options2));
|
|
168
177
|
}
|
|
169
178
|
}
|
|
170
179
|
const warnedMessages = /* @__PURE__ */ new Set();
|
|
@@ -888,27 +897,27 @@ var require_process = __commonJS({
|
|
|
888
897
|
var require_filesystem = __commonJS({
|
|
889
898
|
"node_modules/detect-libc/lib/filesystem.js"(exports2, module2) {
|
|
890
899
|
"use strict";
|
|
891
|
-
var
|
|
900
|
+
var fs17 = require("fs");
|
|
892
901
|
var LDD_PATH = "/usr/bin/ldd";
|
|
893
902
|
var SELF_PATH = "/proc/self/exe";
|
|
894
903
|
var MAX_LENGTH = 2048;
|
|
895
|
-
var readFileSync = (
|
|
896
|
-
const fd =
|
|
904
|
+
var readFileSync = (path23) => {
|
|
905
|
+
const fd = fs17.openSync(path23, "r");
|
|
897
906
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
898
|
-
const bytesRead =
|
|
899
|
-
|
|
907
|
+
const bytesRead = fs17.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
908
|
+
fs17.close(fd, () => {
|
|
900
909
|
});
|
|
901
910
|
return buffer.subarray(0, bytesRead);
|
|
902
911
|
};
|
|
903
|
-
var readFile = (
|
|
904
|
-
|
|
912
|
+
var readFile = (path23) => new Promise((resolve, reject) => {
|
|
913
|
+
fs17.open(path23, "r", (err, fd) => {
|
|
905
914
|
if (err) {
|
|
906
915
|
reject(err);
|
|
907
916
|
} else {
|
|
908
917
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
909
|
-
|
|
918
|
+
fs17.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
|
|
910
919
|
resolve(buffer.subarray(0, bytesRead));
|
|
911
|
-
|
|
920
|
+
fs17.close(fd, () => {
|
|
912
921
|
});
|
|
913
922
|
});
|
|
914
923
|
}
|
|
@@ -1020,11 +1029,11 @@ var require_detect_libc = __commonJS({
|
|
|
1020
1029
|
}
|
|
1021
1030
|
return null;
|
|
1022
1031
|
};
|
|
1023
|
-
var familyFromInterpreterPath = (
|
|
1024
|
-
if (
|
|
1025
|
-
if (
|
|
1032
|
+
var familyFromInterpreterPath = (path23) => {
|
|
1033
|
+
if (path23) {
|
|
1034
|
+
if (path23.includes("/ld-musl-")) {
|
|
1026
1035
|
return MUSL;
|
|
1027
|
-
} else if (
|
|
1036
|
+
} else if (path23.includes("/ld-linux-")) {
|
|
1028
1037
|
return GLIBC;
|
|
1029
1038
|
}
|
|
1030
1039
|
}
|
|
@@ -1071,8 +1080,8 @@ var require_detect_libc = __commonJS({
|
|
|
1071
1080
|
cachedFamilyInterpreter = null;
|
|
1072
1081
|
try {
|
|
1073
1082
|
const selfContent = await readFile(SELF_PATH);
|
|
1074
|
-
const
|
|
1075
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
1083
|
+
const path23 = interpreterPath(selfContent);
|
|
1084
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path23);
|
|
1076
1085
|
} catch (e) {
|
|
1077
1086
|
}
|
|
1078
1087
|
return cachedFamilyInterpreter;
|
|
@@ -1084,8 +1093,8 @@ var require_detect_libc = __commonJS({
|
|
|
1084
1093
|
cachedFamilyInterpreter = null;
|
|
1085
1094
|
try {
|
|
1086
1095
|
const selfContent = readFileSync(SELF_PATH);
|
|
1087
|
-
const
|
|
1088
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
1096
|
+
const path23 = interpreterPath(selfContent);
|
|
1097
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path23);
|
|
1089
1098
|
} catch (e) {
|
|
1090
1099
|
}
|
|
1091
1100
|
return cachedFamilyInterpreter;
|
|
@@ -2308,8 +2317,8 @@ function vuePlugin(config, environmentName = "client") {
|
|
|
2308
2317
|
let cached2 = descriptorCache.get(filePath);
|
|
2309
2318
|
if (!cached2) {
|
|
2310
2319
|
try {
|
|
2311
|
-
const
|
|
2312
|
-
const rawSource =
|
|
2320
|
+
const fs17 = await import("fs");
|
|
2321
|
+
const rawSource = fs17.readFileSync(filePath, "utf-8");
|
|
2313
2322
|
const transformedSfc = await applySourceTransform(
|
|
2314
2323
|
vueOptions.transformSfc,
|
|
2315
2324
|
rawSource,
|
|
@@ -4004,7 +4013,7 @@ async function build(inlineConfig = {}) {
|
|
|
4004
4013
|
const startTime = performance.now();
|
|
4005
4014
|
logger.info(
|
|
4006
4015
|
import_picocolors4.default.cyan(`
|
|
4007
|
-
nasti v${"2.5.
|
|
4016
|
+
nasti v${"2.5.1"} `) + import_picocolors4.default.green(`building for ${config.mode}...`)
|
|
4008
4017
|
);
|
|
4009
4018
|
debug5?.(`root: ${config.root}`);
|
|
4010
4019
|
const buildableNames = Object.keys(config.environments).filter((name) => {
|
|
@@ -4979,8 +4988,8 @@ function rewriteExternalRequires(code, baseDir, root) {
|
|
|
4979
4988
|
}
|
|
4980
4989
|
async function injectCjsNamedExports(code, entryFile) {
|
|
4981
4990
|
try {
|
|
4982
|
-
const { createRequire:
|
|
4983
|
-
const req =
|
|
4991
|
+
const { createRequire: createRequire7 } = await import("module");
|
|
4992
|
+
const req = createRequire7(entryFile);
|
|
4984
4993
|
const cjsExports = req(entryFile);
|
|
4985
4994
|
if (!cjsExports || typeof cjsExports !== "object" && typeof cjsExports !== "function" || Array.isArray(cjsExports)) return code;
|
|
4986
4995
|
const namedKeys = Object.keys(cjsExports).filter(
|
|
@@ -5838,6 +5847,1310 @@ var init_hmr = __esm({
|
|
|
5838
5847
|
}
|
|
5839
5848
|
});
|
|
5840
5849
|
|
|
5850
|
+
// node_modules/import-meta-resolve/lib/errors.js
|
|
5851
|
+
function formatList(array, type = "and") {
|
|
5852
|
+
return array.length < 3 ? array.join(` ${type} `) : `${array.slice(0, -1).join(", ")}, ${type} ${array[array.length - 1]}`;
|
|
5853
|
+
}
|
|
5854
|
+
function createError(sym, value, constructor) {
|
|
5855
|
+
messages.set(sym, value);
|
|
5856
|
+
return makeNodeErrorWithCode(constructor, sym);
|
|
5857
|
+
}
|
|
5858
|
+
function makeNodeErrorWithCode(Base, key) {
|
|
5859
|
+
return NodeError;
|
|
5860
|
+
function NodeError(...parameters) {
|
|
5861
|
+
const limit = Error.stackTraceLimit;
|
|
5862
|
+
if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0;
|
|
5863
|
+
const error = new Base();
|
|
5864
|
+
if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit;
|
|
5865
|
+
const message = getMessage(key, parameters, error);
|
|
5866
|
+
Object.defineProperties(error, {
|
|
5867
|
+
// Note: no need to implement `kIsNodeError` symbol, would be hard,
|
|
5868
|
+
// probably.
|
|
5869
|
+
message: {
|
|
5870
|
+
value: message,
|
|
5871
|
+
enumerable: false,
|
|
5872
|
+
writable: true,
|
|
5873
|
+
configurable: true
|
|
5874
|
+
},
|
|
5875
|
+
toString: {
|
|
5876
|
+
/** @this {Error} */
|
|
5877
|
+
value() {
|
|
5878
|
+
return `${this.name} [${key}]: ${this.message}`;
|
|
5879
|
+
},
|
|
5880
|
+
enumerable: false,
|
|
5881
|
+
writable: true,
|
|
5882
|
+
configurable: true
|
|
5883
|
+
}
|
|
5884
|
+
});
|
|
5885
|
+
captureLargerStackTrace(error);
|
|
5886
|
+
error.code = key;
|
|
5887
|
+
return error;
|
|
5888
|
+
}
|
|
5889
|
+
}
|
|
5890
|
+
function isErrorStackTraceLimitWritable() {
|
|
5891
|
+
try {
|
|
5892
|
+
if (import_node_v8.default.startupSnapshot.isBuildingSnapshot()) {
|
|
5893
|
+
return false;
|
|
5894
|
+
}
|
|
5895
|
+
} catch {
|
|
5896
|
+
}
|
|
5897
|
+
const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
|
|
5898
|
+
if (desc === void 0) {
|
|
5899
|
+
return Object.isExtensible(Error);
|
|
5900
|
+
}
|
|
5901
|
+
return own.call(desc, "writable") && desc.writable !== void 0 ? desc.writable : desc.set !== void 0;
|
|
5902
|
+
}
|
|
5903
|
+
function hideStackFrames(wrappedFunction) {
|
|
5904
|
+
const hidden = nodeInternalPrefix + wrappedFunction.name;
|
|
5905
|
+
Object.defineProperty(wrappedFunction, "name", { value: hidden });
|
|
5906
|
+
return wrappedFunction;
|
|
5907
|
+
}
|
|
5908
|
+
function getMessage(key, parameters, self) {
|
|
5909
|
+
const message = messages.get(key);
|
|
5910
|
+
import_node_assert.default.ok(message !== void 0, "expected `message` to be found");
|
|
5911
|
+
if (typeof message === "function") {
|
|
5912
|
+
import_node_assert.default.ok(
|
|
5913
|
+
message.length <= parameters.length,
|
|
5914
|
+
// Default options do not count.
|
|
5915
|
+
`Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${message.length}).`
|
|
5916
|
+
);
|
|
5917
|
+
return Reflect.apply(message, self, parameters);
|
|
5918
|
+
}
|
|
5919
|
+
const regex = /%[dfijoOs]/g;
|
|
5920
|
+
let expectedLength = 0;
|
|
5921
|
+
while (regex.exec(message) !== null) expectedLength++;
|
|
5922
|
+
import_node_assert.default.ok(
|
|
5923
|
+
expectedLength === parameters.length,
|
|
5924
|
+
`Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${expectedLength}).`
|
|
5925
|
+
);
|
|
5926
|
+
if (parameters.length === 0) return message;
|
|
5927
|
+
parameters.unshift(message);
|
|
5928
|
+
return Reflect.apply(import_node_util.format, null, parameters);
|
|
5929
|
+
}
|
|
5930
|
+
function determineSpecificType(value) {
|
|
5931
|
+
if (value === null || value === void 0) {
|
|
5932
|
+
return String(value);
|
|
5933
|
+
}
|
|
5934
|
+
if (typeof value === "function" && value.name) {
|
|
5935
|
+
return `function ${value.name}`;
|
|
5936
|
+
}
|
|
5937
|
+
if (typeof value === "object") {
|
|
5938
|
+
if (value.constructor && value.constructor.name) {
|
|
5939
|
+
return `an instance of ${value.constructor.name}`;
|
|
5940
|
+
}
|
|
5941
|
+
return `${(0, import_node_util.inspect)(value, { depth: -1 })}`;
|
|
5942
|
+
}
|
|
5943
|
+
let inspected = (0, import_node_util.inspect)(value, { colors: false });
|
|
5944
|
+
if (inspected.length > 28) {
|
|
5945
|
+
inspected = `${inspected.slice(0, 25)}...`;
|
|
5946
|
+
}
|
|
5947
|
+
return `type ${typeof value} (${inspected})`;
|
|
5948
|
+
}
|
|
5949
|
+
var import_node_v8, import_node_assert, import_node_util, own, classRegExp, kTypes, codes, messages, nodeInternalPrefix, userStackTraceLimit, captureLargerStackTrace;
|
|
5950
|
+
var init_errors = __esm({
|
|
5951
|
+
"node_modules/import-meta-resolve/lib/errors.js"() {
|
|
5952
|
+
"use strict";
|
|
5953
|
+
import_node_v8 = __toESM(require("v8"), 1);
|
|
5954
|
+
import_node_assert = __toESM(require("assert"), 1);
|
|
5955
|
+
import_node_util = require("util");
|
|
5956
|
+
own = {}.hasOwnProperty;
|
|
5957
|
+
classRegExp = /^([A-Z][a-z\d]*)+$/;
|
|
5958
|
+
kTypes = /* @__PURE__ */ new Set([
|
|
5959
|
+
"string",
|
|
5960
|
+
"function",
|
|
5961
|
+
"number",
|
|
5962
|
+
"object",
|
|
5963
|
+
// Accept 'Function' and 'Object' as alternative to the lower cased version.
|
|
5964
|
+
"Function",
|
|
5965
|
+
"Object",
|
|
5966
|
+
"boolean",
|
|
5967
|
+
"bigint",
|
|
5968
|
+
"symbol"
|
|
5969
|
+
]);
|
|
5970
|
+
codes = {};
|
|
5971
|
+
messages = /* @__PURE__ */ new Map();
|
|
5972
|
+
nodeInternalPrefix = "__node_internal_";
|
|
5973
|
+
codes.ERR_INVALID_ARG_TYPE = createError(
|
|
5974
|
+
"ERR_INVALID_ARG_TYPE",
|
|
5975
|
+
/**
|
|
5976
|
+
* @param {string} name
|
|
5977
|
+
* @param {Array<string> | string} expected
|
|
5978
|
+
* @param {unknown} actual
|
|
5979
|
+
*/
|
|
5980
|
+
(name, expected, actual) => {
|
|
5981
|
+
import_node_assert.default.ok(typeof name === "string", "'name' must be a string");
|
|
5982
|
+
if (!Array.isArray(expected)) {
|
|
5983
|
+
expected = [expected];
|
|
5984
|
+
}
|
|
5985
|
+
let message = "The ";
|
|
5986
|
+
if (name.endsWith(" argument")) {
|
|
5987
|
+
message += `${name} `;
|
|
5988
|
+
} else {
|
|
5989
|
+
const type = name.includes(".") ? "property" : "argument";
|
|
5990
|
+
message += `"${name}" ${type} `;
|
|
5991
|
+
}
|
|
5992
|
+
message += "must be ";
|
|
5993
|
+
const types = [];
|
|
5994
|
+
const instances = [];
|
|
5995
|
+
const other = [];
|
|
5996
|
+
for (const value of expected) {
|
|
5997
|
+
import_node_assert.default.ok(
|
|
5998
|
+
typeof value === "string",
|
|
5999
|
+
"All expected entries have to be of type string"
|
|
6000
|
+
);
|
|
6001
|
+
if (kTypes.has(value)) {
|
|
6002
|
+
types.push(value.toLowerCase());
|
|
6003
|
+
} else if (classRegExp.exec(value) === null) {
|
|
6004
|
+
import_node_assert.default.ok(
|
|
6005
|
+
value !== "object",
|
|
6006
|
+
'The value "object" should be written as "Object"'
|
|
6007
|
+
);
|
|
6008
|
+
other.push(value);
|
|
6009
|
+
} else {
|
|
6010
|
+
instances.push(value);
|
|
6011
|
+
}
|
|
6012
|
+
}
|
|
6013
|
+
if (instances.length > 0) {
|
|
6014
|
+
const pos = types.indexOf("object");
|
|
6015
|
+
if (pos !== -1) {
|
|
6016
|
+
types.slice(pos, 1);
|
|
6017
|
+
instances.push("Object");
|
|
6018
|
+
}
|
|
6019
|
+
}
|
|
6020
|
+
if (types.length > 0) {
|
|
6021
|
+
message += `${types.length > 1 ? "one of type" : "of type"} ${formatList(
|
|
6022
|
+
types,
|
|
6023
|
+
"or"
|
|
6024
|
+
)}`;
|
|
6025
|
+
if (instances.length > 0 || other.length > 0) message += " or ";
|
|
6026
|
+
}
|
|
6027
|
+
if (instances.length > 0) {
|
|
6028
|
+
message += `an instance of ${formatList(instances, "or")}`;
|
|
6029
|
+
if (other.length > 0) message += " or ";
|
|
6030
|
+
}
|
|
6031
|
+
if (other.length > 0) {
|
|
6032
|
+
if (other.length > 1) {
|
|
6033
|
+
message += `one of ${formatList(other, "or")}`;
|
|
6034
|
+
} else {
|
|
6035
|
+
if (other[0].toLowerCase() !== other[0]) message += "an ";
|
|
6036
|
+
message += `${other[0]}`;
|
|
6037
|
+
}
|
|
6038
|
+
}
|
|
6039
|
+
message += `. Received ${determineSpecificType(actual)}`;
|
|
6040
|
+
return message;
|
|
6041
|
+
},
|
|
6042
|
+
TypeError
|
|
6043
|
+
);
|
|
6044
|
+
codes.ERR_INVALID_MODULE_SPECIFIER = createError(
|
|
6045
|
+
"ERR_INVALID_MODULE_SPECIFIER",
|
|
6046
|
+
/**
|
|
6047
|
+
* @param {string} request
|
|
6048
|
+
* @param {string} reason
|
|
6049
|
+
* @param {string} [base]
|
|
6050
|
+
*/
|
|
6051
|
+
(request, reason, base = void 0) => {
|
|
6052
|
+
return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
|
|
6053
|
+
},
|
|
6054
|
+
TypeError
|
|
6055
|
+
);
|
|
6056
|
+
codes.ERR_INVALID_PACKAGE_CONFIG = createError(
|
|
6057
|
+
"ERR_INVALID_PACKAGE_CONFIG",
|
|
6058
|
+
/**
|
|
6059
|
+
* @param {string} path
|
|
6060
|
+
* @param {string} [base]
|
|
6061
|
+
* @param {string} [message]
|
|
6062
|
+
*/
|
|
6063
|
+
(path23, base, message) => {
|
|
6064
|
+
return `Invalid package config ${path23}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
|
|
6065
|
+
},
|
|
6066
|
+
Error
|
|
6067
|
+
);
|
|
6068
|
+
codes.ERR_INVALID_PACKAGE_TARGET = createError(
|
|
6069
|
+
"ERR_INVALID_PACKAGE_TARGET",
|
|
6070
|
+
/**
|
|
6071
|
+
* @param {string} packagePath
|
|
6072
|
+
* @param {string} key
|
|
6073
|
+
* @param {unknown} target
|
|
6074
|
+
* @param {boolean} [isImport=false]
|
|
6075
|
+
* @param {string} [base]
|
|
6076
|
+
*/
|
|
6077
|
+
(packagePath, key, target, isImport = false, base = void 0) => {
|
|
6078
|
+
const relatedError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
|
|
6079
|
+
if (key === ".") {
|
|
6080
|
+
import_node_assert.default.ok(isImport === false);
|
|
6081
|
+
return `Invalid "exports" main target ${JSON.stringify(target)} defined in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
|
|
6082
|
+
}
|
|
6083
|
+
return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(
|
|
6084
|
+
target
|
|
6085
|
+
)} defined for '${key}' in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
|
|
6086
|
+
},
|
|
6087
|
+
Error
|
|
6088
|
+
);
|
|
6089
|
+
codes.ERR_MODULE_NOT_FOUND = createError(
|
|
6090
|
+
"ERR_MODULE_NOT_FOUND",
|
|
6091
|
+
/**
|
|
6092
|
+
* @param {string} path
|
|
6093
|
+
* @param {string} base
|
|
6094
|
+
* @param {boolean} [exactUrl]
|
|
6095
|
+
*/
|
|
6096
|
+
(path23, base, exactUrl = false) => {
|
|
6097
|
+
return `Cannot find ${exactUrl ? "module" : "package"} '${path23}' imported from ${base}`;
|
|
6098
|
+
},
|
|
6099
|
+
Error
|
|
6100
|
+
);
|
|
6101
|
+
codes.ERR_NETWORK_IMPORT_DISALLOWED = createError(
|
|
6102
|
+
"ERR_NETWORK_IMPORT_DISALLOWED",
|
|
6103
|
+
"import of '%s' by %s is not supported: %s",
|
|
6104
|
+
Error
|
|
6105
|
+
);
|
|
6106
|
+
codes.ERR_PACKAGE_IMPORT_NOT_DEFINED = createError(
|
|
6107
|
+
"ERR_PACKAGE_IMPORT_NOT_DEFINED",
|
|
6108
|
+
/**
|
|
6109
|
+
* @param {string} specifier
|
|
6110
|
+
* @param {string} packagePath
|
|
6111
|
+
* @param {string} base
|
|
6112
|
+
*/
|
|
6113
|
+
(specifier, packagePath, base) => {
|
|
6114
|
+
return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath}package.json` : ""} imported from ${base}`;
|
|
6115
|
+
},
|
|
6116
|
+
TypeError
|
|
6117
|
+
);
|
|
6118
|
+
codes.ERR_PACKAGE_PATH_NOT_EXPORTED = createError(
|
|
6119
|
+
"ERR_PACKAGE_PATH_NOT_EXPORTED",
|
|
6120
|
+
/**
|
|
6121
|
+
* @param {string} packagePath
|
|
6122
|
+
* @param {string} subpath
|
|
6123
|
+
* @param {string} [base]
|
|
6124
|
+
*/
|
|
6125
|
+
(packagePath, subpath, base = void 0) => {
|
|
6126
|
+
if (subpath === ".")
|
|
6127
|
+
return `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
|
|
6128
|
+
return `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
|
|
6129
|
+
},
|
|
6130
|
+
Error
|
|
6131
|
+
);
|
|
6132
|
+
codes.ERR_UNSUPPORTED_DIR_IMPORT = createError(
|
|
6133
|
+
"ERR_UNSUPPORTED_DIR_IMPORT",
|
|
6134
|
+
"Directory import '%s' is not supported resolving ES modules imported from %s",
|
|
6135
|
+
Error
|
|
6136
|
+
);
|
|
6137
|
+
codes.ERR_UNSUPPORTED_RESOLVE_REQUEST = createError(
|
|
6138
|
+
"ERR_UNSUPPORTED_RESOLVE_REQUEST",
|
|
6139
|
+
'Failed to resolve module specifier "%s" from "%s": Invalid relative URL or base scheme is not hierarchical.',
|
|
6140
|
+
TypeError
|
|
6141
|
+
);
|
|
6142
|
+
codes.ERR_UNKNOWN_FILE_EXTENSION = createError(
|
|
6143
|
+
"ERR_UNKNOWN_FILE_EXTENSION",
|
|
6144
|
+
/**
|
|
6145
|
+
* @param {string} extension
|
|
6146
|
+
* @param {string} path
|
|
6147
|
+
*/
|
|
6148
|
+
(extension, path23) => {
|
|
6149
|
+
return `Unknown file extension "${extension}" for ${path23}`;
|
|
6150
|
+
},
|
|
6151
|
+
TypeError
|
|
6152
|
+
);
|
|
6153
|
+
codes.ERR_INVALID_ARG_VALUE = createError(
|
|
6154
|
+
"ERR_INVALID_ARG_VALUE",
|
|
6155
|
+
/**
|
|
6156
|
+
* @param {string} name
|
|
6157
|
+
* @param {unknown} value
|
|
6158
|
+
* @param {string} [reason='is invalid']
|
|
6159
|
+
*/
|
|
6160
|
+
(name, value, reason = "is invalid") => {
|
|
6161
|
+
let inspected = (0, import_node_util.inspect)(value);
|
|
6162
|
+
if (inspected.length > 128) {
|
|
6163
|
+
inspected = `${inspected.slice(0, 128)}...`;
|
|
6164
|
+
}
|
|
6165
|
+
const type = name.includes(".") ? "property" : "argument";
|
|
6166
|
+
return `The ${type} '${name}' ${reason}. Received ${inspected}`;
|
|
6167
|
+
},
|
|
6168
|
+
TypeError
|
|
6169
|
+
// Note: extra classes have been shaken out.
|
|
6170
|
+
// , RangeError
|
|
6171
|
+
);
|
|
6172
|
+
captureLargerStackTrace = hideStackFrames(
|
|
6173
|
+
/**
|
|
6174
|
+
* @param {Error} error
|
|
6175
|
+
* @returns {Error}
|
|
6176
|
+
*/
|
|
6177
|
+
// @ts-expect-error: fine
|
|
6178
|
+
function(error) {
|
|
6179
|
+
const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
|
|
6180
|
+
if (stackTraceLimitIsWritable) {
|
|
6181
|
+
userStackTraceLimit = Error.stackTraceLimit;
|
|
6182
|
+
Error.stackTraceLimit = Number.POSITIVE_INFINITY;
|
|
6183
|
+
}
|
|
6184
|
+
Error.captureStackTrace(error);
|
|
6185
|
+
if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit;
|
|
6186
|
+
return error;
|
|
6187
|
+
}
|
|
6188
|
+
);
|
|
6189
|
+
}
|
|
6190
|
+
});
|
|
6191
|
+
|
|
6192
|
+
// node_modules/import-meta-resolve/lib/package-json-reader.js
|
|
6193
|
+
function read(jsonPath, { base, specifier }) {
|
|
6194
|
+
const existing = cache.get(jsonPath);
|
|
6195
|
+
if (existing) {
|
|
6196
|
+
return existing;
|
|
6197
|
+
}
|
|
6198
|
+
let string;
|
|
6199
|
+
try {
|
|
6200
|
+
string = import_node_fs12.default.readFileSync(import_node_path15.default.toNamespacedPath(jsonPath), "utf8");
|
|
6201
|
+
} catch (error) {
|
|
6202
|
+
const exception = (
|
|
6203
|
+
/** @type {ErrnoException} */
|
|
6204
|
+
error
|
|
6205
|
+
);
|
|
6206
|
+
if (exception.code !== "ENOENT") {
|
|
6207
|
+
throw exception;
|
|
6208
|
+
}
|
|
6209
|
+
}
|
|
6210
|
+
const result = {
|
|
6211
|
+
exists: false,
|
|
6212
|
+
pjsonPath: jsonPath,
|
|
6213
|
+
main: void 0,
|
|
6214
|
+
name: void 0,
|
|
6215
|
+
type: "none",
|
|
6216
|
+
// Ignore unknown types for forwards compatibility
|
|
6217
|
+
exports: void 0,
|
|
6218
|
+
imports: void 0
|
|
6219
|
+
};
|
|
6220
|
+
if (string !== void 0) {
|
|
6221
|
+
let parsed;
|
|
6222
|
+
try {
|
|
6223
|
+
parsed = JSON.parse(string);
|
|
6224
|
+
} catch (error_) {
|
|
6225
|
+
const cause = (
|
|
6226
|
+
/** @type {ErrnoException} */
|
|
6227
|
+
error_
|
|
6228
|
+
);
|
|
6229
|
+
const error = new ERR_INVALID_PACKAGE_CONFIG(
|
|
6230
|
+
jsonPath,
|
|
6231
|
+
(base ? `"${specifier}" from ` : "") + (0, import_node_url4.fileURLToPath)(base || specifier),
|
|
6232
|
+
cause.message
|
|
6233
|
+
);
|
|
6234
|
+
error.cause = cause;
|
|
6235
|
+
throw error;
|
|
6236
|
+
}
|
|
6237
|
+
result.exists = true;
|
|
6238
|
+
if (hasOwnProperty.call(parsed, "name") && typeof parsed.name === "string") {
|
|
6239
|
+
result.name = parsed.name;
|
|
6240
|
+
}
|
|
6241
|
+
if (hasOwnProperty.call(parsed, "main") && typeof parsed.main === "string") {
|
|
6242
|
+
result.main = parsed.main;
|
|
6243
|
+
}
|
|
6244
|
+
if (hasOwnProperty.call(parsed, "exports")) {
|
|
6245
|
+
result.exports = parsed.exports;
|
|
6246
|
+
}
|
|
6247
|
+
if (hasOwnProperty.call(parsed, "imports")) {
|
|
6248
|
+
result.imports = parsed.imports;
|
|
6249
|
+
}
|
|
6250
|
+
if (hasOwnProperty.call(parsed, "type") && (parsed.type === "commonjs" || parsed.type === "module")) {
|
|
6251
|
+
result.type = parsed.type;
|
|
6252
|
+
}
|
|
6253
|
+
}
|
|
6254
|
+
cache.set(jsonPath, result);
|
|
6255
|
+
return result;
|
|
6256
|
+
}
|
|
6257
|
+
function getPackageScopeConfig(resolved) {
|
|
6258
|
+
let packageJSONUrl = new URL("package.json", resolved);
|
|
6259
|
+
while (true) {
|
|
6260
|
+
const packageJSONPath2 = packageJSONUrl.pathname;
|
|
6261
|
+
if (packageJSONPath2.endsWith("node_modules/package.json")) {
|
|
6262
|
+
break;
|
|
6263
|
+
}
|
|
6264
|
+
const packageConfig = read((0, import_node_url4.fileURLToPath)(packageJSONUrl), {
|
|
6265
|
+
specifier: resolved
|
|
6266
|
+
});
|
|
6267
|
+
if (packageConfig.exists) {
|
|
6268
|
+
return packageConfig;
|
|
6269
|
+
}
|
|
6270
|
+
const lastPackageJSONUrl = packageJSONUrl;
|
|
6271
|
+
packageJSONUrl = new URL("../package.json", packageJSONUrl);
|
|
6272
|
+
if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) {
|
|
6273
|
+
break;
|
|
6274
|
+
}
|
|
6275
|
+
}
|
|
6276
|
+
const packageJSONPath = (0, import_node_url4.fileURLToPath)(packageJSONUrl);
|
|
6277
|
+
return {
|
|
6278
|
+
pjsonPath: packageJSONPath,
|
|
6279
|
+
exists: false,
|
|
6280
|
+
type: "none"
|
|
6281
|
+
};
|
|
6282
|
+
}
|
|
6283
|
+
function getPackageType(url) {
|
|
6284
|
+
return getPackageScopeConfig(url).type;
|
|
6285
|
+
}
|
|
6286
|
+
var import_node_fs12, import_node_path15, import_node_url4, hasOwnProperty, ERR_INVALID_PACKAGE_CONFIG, cache;
|
|
6287
|
+
var init_package_json_reader = __esm({
|
|
6288
|
+
"node_modules/import-meta-resolve/lib/package-json-reader.js"() {
|
|
6289
|
+
"use strict";
|
|
6290
|
+
import_node_fs12 = __toESM(require("fs"), 1);
|
|
6291
|
+
import_node_path15 = __toESM(require("path"), 1);
|
|
6292
|
+
import_node_url4 = require("url");
|
|
6293
|
+
init_errors();
|
|
6294
|
+
hasOwnProperty = {}.hasOwnProperty;
|
|
6295
|
+
({ ERR_INVALID_PACKAGE_CONFIG } = codes);
|
|
6296
|
+
cache = /* @__PURE__ */ new Map();
|
|
6297
|
+
}
|
|
6298
|
+
});
|
|
6299
|
+
|
|
6300
|
+
// node_modules/import-meta-resolve/lib/get-format.js
|
|
6301
|
+
function mimeToFormat(mime) {
|
|
6302
|
+
if (mime && /\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(mime))
|
|
6303
|
+
return "module";
|
|
6304
|
+
if (mime === "application/json") return "json";
|
|
6305
|
+
return null;
|
|
6306
|
+
}
|
|
6307
|
+
function getDataProtocolModuleFormat(parsed) {
|
|
6308
|
+
const { 1: mime } = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(
|
|
6309
|
+
parsed.pathname
|
|
6310
|
+
) || [null, null, null];
|
|
6311
|
+
return mimeToFormat(mime);
|
|
6312
|
+
}
|
|
6313
|
+
function extname(url) {
|
|
6314
|
+
const pathname = url.pathname;
|
|
6315
|
+
let index2 = pathname.length;
|
|
6316
|
+
while (index2--) {
|
|
6317
|
+
const code = pathname.codePointAt(index2);
|
|
6318
|
+
if (code === 47) {
|
|
6319
|
+
return "";
|
|
6320
|
+
}
|
|
6321
|
+
if (code === 46) {
|
|
6322
|
+
return pathname.codePointAt(index2 - 1) === 47 ? "" : pathname.slice(index2);
|
|
6323
|
+
}
|
|
6324
|
+
}
|
|
6325
|
+
return "";
|
|
6326
|
+
}
|
|
6327
|
+
function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
|
|
6328
|
+
const value = extname(url);
|
|
6329
|
+
if (value === ".js") {
|
|
6330
|
+
const packageType = getPackageType(url);
|
|
6331
|
+
if (packageType !== "none") {
|
|
6332
|
+
return packageType;
|
|
6333
|
+
}
|
|
6334
|
+
return "commonjs";
|
|
6335
|
+
}
|
|
6336
|
+
if (value === "") {
|
|
6337
|
+
const packageType = getPackageType(url);
|
|
6338
|
+
if (packageType === "none" || packageType === "commonjs") {
|
|
6339
|
+
return "commonjs";
|
|
6340
|
+
}
|
|
6341
|
+
return "module";
|
|
6342
|
+
}
|
|
6343
|
+
const format2 = extensionFormatMap[value];
|
|
6344
|
+
if (format2) return format2;
|
|
6345
|
+
if (ignoreErrors) {
|
|
6346
|
+
return void 0;
|
|
6347
|
+
}
|
|
6348
|
+
const filepath = (0, import_node_url5.fileURLToPath)(url);
|
|
6349
|
+
throw new ERR_UNKNOWN_FILE_EXTENSION(value, filepath);
|
|
6350
|
+
}
|
|
6351
|
+
function getHttpProtocolModuleFormat() {
|
|
6352
|
+
}
|
|
6353
|
+
function defaultGetFormatWithoutErrors(url, context) {
|
|
6354
|
+
const protocol = url.protocol;
|
|
6355
|
+
if (!hasOwnProperty2.call(protocolHandlers, protocol)) {
|
|
6356
|
+
return null;
|
|
6357
|
+
}
|
|
6358
|
+
return protocolHandlers[protocol](url, context, true) || null;
|
|
6359
|
+
}
|
|
6360
|
+
var import_node_url5, ERR_UNKNOWN_FILE_EXTENSION, hasOwnProperty2, extensionFormatMap, protocolHandlers;
|
|
6361
|
+
var init_get_format = __esm({
|
|
6362
|
+
"node_modules/import-meta-resolve/lib/get-format.js"() {
|
|
6363
|
+
"use strict";
|
|
6364
|
+
import_node_url5 = require("url");
|
|
6365
|
+
init_package_json_reader();
|
|
6366
|
+
init_errors();
|
|
6367
|
+
({ ERR_UNKNOWN_FILE_EXTENSION } = codes);
|
|
6368
|
+
hasOwnProperty2 = {}.hasOwnProperty;
|
|
6369
|
+
extensionFormatMap = {
|
|
6370
|
+
// @ts-expect-error: hush.
|
|
6371
|
+
__proto__: null,
|
|
6372
|
+
".cjs": "commonjs",
|
|
6373
|
+
".js": "module",
|
|
6374
|
+
".json": "json",
|
|
6375
|
+
".mjs": "module"
|
|
6376
|
+
};
|
|
6377
|
+
protocolHandlers = {
|
|
6378
|
+
// @ts-expect-error: hush.
|
|
6379
|
+
__proto__: null,
|
|
6380
|
+
"data:": getDataProtocolModuleFormat,
|
|
6381
|
+
"file:": getFileProtocolModuleFormat,
|
|
6382
|
+
"http:": getHttpProtocolModuleFormat,
|
|
6383
|
+
"https:": getHttpProtocolModuleFormat,
|
|
6384
|
+
"node:"() {
|
|
6385
|
+
return "builtin";
|
|
6386
|
+
}
|
|
6387
|
+
};
|
|
6388
|
+
}
|
|
6389
|
+
});
|
|
6390
|
+
|
|
6391
|
+
// node_modules/import-meta-resolve/lib/utils.js
|
|
6392
|
+
function getDefaultConditions() {
|
|
6393
|
+
return DEFAULT_CONDITIONS;
|
|
6394
|
+
}
|
|
6395
|
+
function getDefaultConditionsSet() {
|
|
6396
|
+
return DEFAULT_CONDITIONS_SET;
|
|
6397
|
+
}
|
|
6398
|
+
function getConditionsSet(conditions) {
|
|
6399
|
+
if (conditions !== void 0 && conditions !== getDefaultConditions()) {
|
|
6400
|
+
if (!Array.isArray(conditions)) {
|
|
6401
|
+
throw new ERR_INVALID_ARG_VALUE(
|
|
6402
|
+
"conditions",
|
|
6403
|
+
conditions,
|
|
6404
|
+
"expected an array"
|
|
6405
|
+
);
|
|
6406
|
+
}
|
|
6407
|
+
return new Set(conditions);
|
|
6408
|
+
}
|
|
6409
|
+
return getDefaultConditionsSet();
|
|
6410
|
+
}
|
|
6411
|
+
var ERR_INVALID_ARG_VALUE, DEFAULT_CONDITIONS, DEFAULT_CONDITIONS_SET;
|
|
6412
|
+
var init_utils = __esm({
|
|
6413
|
+
"node_modules/import-meta-resolve/lib/utils.js"() {
|
|
6414
|
+
"use strict";
|
|
6415
|
+
init_errors();
|
|
6416
|
+
({ ERR_INVALID_ARG_VALUE } = codes);
|
|
6417
|
+
DEFAULT_CONDITIONS = Object.freeze(["node", "import"]);
|
|
6418
|
+
DEFAULT_CONDITIONS_SET = new Set(DEFAULT_CONDITIONS);
|
|
6419
|
+
}
|
|
6420
|
+
});
|
|
6421
|
+
|
|
6422
|
+
// node_modules/import-meta-resolve/lib/resolve.js
|
|
6423
|
+
function emitInvalidSegmentDeprecation(target, request, match, packageJsonUrl, internal, base, isTarget) {
|
|
6424
|
+
if (import_node_process.default.noDeprecation) {
|
|
6425
|
+
return;
|
|
6426
|
+
}
|
|
6427
|
+
const pjsonPath = (0, import_node_url6.fileURLToPath)(packageJsonUrl);
|
|
6428
|
+
const double = doubleSlashRegEx.exec(isTarget ? target : request) !== null;
|
|
6429
|
+
import_node_process.default.emitWarning(
|
|
6430
|
+
`Use of deprecated ${double ? "double slash" : "leading or trailing slash matching"} resolving "${target}" for module request "${request}" ${request === match ? "" : `matched to "${match}" `}in the "${internal ? "imports" : "exports"}" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${(0, import_node_url6.fileURLToPath)(base)}` : ""}.`,
|
|
6431
|
+
"DeprecationWarning",
|
|
6432
|
+
"DEP0166"
|
|
6433
|
+
);
|
|
6434
|
+
}
|
|
6435
|
+
function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
|
|
6436
|
+
if (import_node_process.default.noDeprecation) {
|
|
6437
|
+
return;
|
|
6438
|
+
}
|
|
6439
|
+
const format2 = defaultGetFormatWithoutErrors(url, { parentURL: base.href });
|
|
6440
|
+
if (format2 !== "module") return;
|
|
6441
|
+
const urlPath = (0, import_node_url6.fileURLToPath)(url.href);
|
|
6442
|
+
const packagePath = (0, import_node_url6.fileURLToPath)(new URL(".", packageJsonUrl));
|
|
6443
|
+
const basePath = (0, import_node_url6.fileURLToPath)(base);
|
|
6444
|
+
if (!main) {
|
|
6445
|
+
import_node_process.default.emitWarning(
|
|
6446
|
+
`No "main" or "exports" field defined in the package.json for ${packagePath} resolving the main entry point "${urlPath.slice(
|
|
6447
|
+
packagePath.length
|
|
6448
|
+
)}", imported from ${basePath}.
|
|
6449
|
+
Default "index" lookups for the main are deprecated for ES modules.`,
|
|
6450
|
+
"DeprecationWarning",
|
|
6451
|
+
"DEP0151"
|
|
6452
|
+
);
|
|
6453
|
+
} else if (import_node_path16.default.resolve(packagePath, main) !== urlPath) {
|
|
6454
|
+
import_node_process.default.emitWarning(
|
|
6455
|
+
`Package ${packagePath} has a "main" field set to "${main}", excluding the full filename and extension to the resolved file at "${urlPath.slice(
|
|
6456
|
+
packagePath.length
|
|
6457
|
+
)}", imported from ${basePath}.
|
|
6458
|
+
Automatic extension resolution of the "main" field is deprecated for ES modules.`,
|
|
6459
|
+
"DeprecationWarning",
|
|
6460
|
+
"DEP0151"
|
|
6461
|
+
);
|
|
6462
|
+
}
|
|
6463
|
+
}
|
|
6464
|
+
function tryStatSync(path23) {
|
|
6465
|
+
try {
|
|
6466
|
+
return (0, import_node_fs13.statSync)(path23);
|
|
6467
|
+
} catch {
|
|
6468
|
+
}
|
|
6469
|
+
}
|
|
6470
|
+
function fileExists(url) {
|
|
6471
|
+
const stats = (0, import_node_fs13.statSync)(url, { throwIfNoEntry: false });
|
|
6472
|
+
const isFile = stats ? stats.isFile() : void 0;
|
|
6473
|
+
return isFile === null || isFile === void 0 ? false : isFile;
|
|
6474
|
+
}
|
|
6475
|
+
function legacyMainResolve(packageJsonUrl, packageConfig, base) {
|
|
6476
|
+
let guess;
|
|
6477
|
+
if (packageConfig.main !== void 0) {
|
|
6478
|
+
guess = new URL(packageConfig.main, packageJsonUrl);
|
|
6479
|
+
if (fileExists(guess)) return guess;
|
|
6480
|
+
const tries2 = [
|
|
6481
|
+
`./${packageConfig.main}.js`,
|
|
6482
|
+
`./${packageConfig.main}.json`,
|
|
6483
|
+
`./${packageConfig.main}.node`,
|
|
6484
|
+
`./${packageConfig.main}/index.js`,
|
|
6485
|
+
`./${packageConfig.main}/index.json`,
|
|
6486
|
+
`./${packageConfig.main}/index.node`
|
|
6487
|
+
];
|
|
6488
|
+
let i2 = -1;
|
|
6489
|
+
while (++i2 < tries2.length) {
|
|
6490
|
+
guess = new URL(tries2[i2], packageJsonUrl);
|
|
6491
|
+
if (fileExists(guess)) break;
|
|
6492
|
+
guess = void 0;
|
|
6493
|
+
}
|
|
6494
|
+
if (guess) {
|
|
6495
|
+
emitLegacyIndexDeprecation(
|
|
6496
|
+
guess,
|
|
6497
|
+
packageJsonUrl,
|
|
6498
|
+
base,
|
|
6499
|
+
packageConfig.main
|
|
6500
|
+
);
|
|
6501
|
+
return guess;
|
|
6502
|
+
}
|
|
6503
|
+
}
|
|
6504
|
+
const tries = ["./index.js", "./index.json", "./index.node"];
|
|
6505
|
+
let i = -1;
|
|
6506
|
+
while (++i < tries.length) {
|
|
6507
|
+
guess = new URL(tries[i], packageJsonUrl);
|
|
6508
|
+
if (fileExists(guess)) break;
|
|
6509
|
+
guess = void 0;
|
|
6510
|
+
}
|
|
6511
|
+
if (guess) {
|
|
6512
|
+
emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
|
|
6513
|
+
return guess;
|
|
6514
|
+
}
|
|
6515
|
+
throw new ERR_MODULE_NOT_FOUND(
|
|
6516
|
+
(0, import_node_url6.fileURLToPath)(new URL(".", packageJsonUrl)),
|
|
6517
|
+
(0, import_node_url6.fileURLToPath)(base)
|
|
6518
|
+
);
|
|
6519
|
+
}
|
|
6520
|
+
function finalizeResolution(resolved, base, preserveSymlinks) {
|
|
6521
|
+
if (encodedSeparatorRegEx.exec(resolved.pathname) !== null) {
|
|
6522
|
+
throw new ERR_INVALID_MODULE_SPECIFIER(
|
|
6523
|
+
resolved.pathname,
|
|
6524
|
+
'must not include encoded "/" or "\\" characters',
|
|
6525
|
+
(0, import_node_url6.fileURLToPath)(base)
|
|
6526
|
+
);
|
|
6527
|
+
}
|
|
6528
|
+
let filePath;
|
|
6529
|
+
try {
|
|
6530
|
+
filePath = (0, import_node_url6.fileURLToPath)(resolved);
|
|
6531
|
+
} catch (error) {
|
|
6532
|
+
const cause = (
|
|
6533
|
+
/** @type {ErrnoException} */
|
|
6534
|
+
error
|
|
6535
|
+
);
|
|
6536
|
+
Object.defineProperty(cause, "input", { value: String(resolved) });
|
|
6537
|
+
Object.defineProperty(cause, "module", { value: String(base) });
|
|
6538
|
+
throw cause;
|
|
6539
|
+
}
|
|
6540
|
+
const stats = tryStatSync(
|
|
6541
|
+
filePath.endsWith("/") ? filePath.slice(-1) : filePath
|
|
6542
|
+
);
|
|
6543
|
+
if (stats && stats.isDirectory()) {
|
|
6544
|
+
const error = new ERR_UNSUPPORTED_DIR_IMPORT(filePath, (0, import_node_url6.fileURLToPath)(base));
|
|
6545
|
+
error.url = String(resolved);
|
|
6546
|
+
throw error;
|
|
6547
|
+
}
|
|
6548
|
+
if (!stats || !stats.isFile()) {
|
|
6549
|
+
const error = new ERR_MODULE_NOT_FOUND(
|
|
6550
|
+
filePath || resolved.pathname,
|
|
6551
|
+
base && (0, import_node_url6.fileURLToPath)(base),
|
|
6552
|
+
true
|
|
6553
|
+
);
|
|
6554
|
+
error.url = String(resolved);
|
|
6555
|
+
throw error;
|
|
6556
|
+
}
|
|
6557
|
+
if (!preserveSymlinks) {
|
|
6558
|
+
const real = (0, import_node_fs13.realpathSync)(filePath);
|
|
6559
|
+
const { search, hash } = resolved;
|
|
6560
|
+
resolved = (0, import_node_url6.pathToFileURL)(real + (filePath.endsWith(import_node_path16.default.sep) ? "/" : ""));
|
|
6561
|
+
resolved.search = search;
|
|
6562
|
+
resolved.hash = hash;
|
|
6563
|
+
}
|
|
6564
|
+
return resolved;
|
|
6565
|
+
}
|
|
6566
|
+
function importNotDefined(specifier, packageJsonUrl, base) {
|
|
6567
|
+
return new ERR_PACKAGE_IMPORT_NOT_DEFINED(
|
|
6568
|
+
specifier,
|
|
6569
|
+
packageJsonUrl && (0, import_node_url6.fileURLToPath)(new URL(".", packageJsonUrl)),
|
|
6570
|
+
(0, import_node_url6.fileURLToPath)(base)
|
|
6571
|
+
);
|
|
6572
|
+
}
|
|
6573
|
+
function exportsNotFound(subpath, packageJsonUrl, base) {
|
|
6574
|
+
return new ERR_PACKAGE_PATH_NOT_EXPORTED(
|
|
6575
|
+
(0, import_node_url6.fileURLToPath)(new URL(".", packageJsonUrl)),
|
|
6576
|
+
subpath,
|
|
6577
|
+
base && (0, import_node_url6.fileURLToPath)(base)
|
|
6578
|
+
);
|
|
6579
|
+
}
|
|
6580
|
+
function throwInvalidSubpath(request, match, packageJsonUrl, internal, base) {
|
|
6581
|
+
const reason = `request is not a valid match in pattern "${match}" for the "${internal ? "imports" : "exports"}" resolution of ${(0, import_node_url6.fileURLToPath)(packageJsonUrl)}`;
|
|
6582
|
+
throw new ERR_INVALID_MODULE_SPECIFIER(
|
|
6583
|
+
request,
|
|
6584
|
+
reason,
|
|
6585
|
+
base && (0, import_node_url6.fileURLToPath)(base)
|
|
6586
|
+
);
|
|
6587
|
+
}
|
|
6588
|
+
function invalidPackageTarget(subpath, target, packageJsonUrl, internal, base) {
|
|
6589
|
+
target = typeof target === "object" && target !== null ? JSON.stringify(target, null, "") : `${target}`;
|
|
6590
|
+
return new ERR_INVALID_PACKAGE_TARGET(
|
|
6591
|
+
(0, import_node_url6.fileURLToPath)(new URL(".", packageJsonUrl)),
|
|
6592
|
+
subpath,
|
|
6593
|
+
target,
|
|
6594
|
+
internal,
|
|
6595
|
+
base && (0, import_node_url6.fileURLToPath)(base)
|
|
6596
|
+
);
|
|
6597
|
+
}
|
|
6598
|
+
function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base, pattern, internal, isPathMap, conditions) {
|
|
6599
|
+
if (subpath !== "" && !pattern && target[target.length - 1] !== "/")
|
|
6600
|
+
throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
6601
|
+
if (!target.startsWith("./")) {
|
|
6602
|
+
if (internal && !target.startsWith("../") && !target.startsWith("/")) {
|
|
6603
|
+
let isURL = false;
|
|
6604
|
+
try {
|
|
6605
|
+
new URL(target);
|
|
6606
|
+
isURL = true;
|
|
6607
|
+
} catch {
|
|
6608
|
+
}
|
|
6609
|
+
if (!isURL) {
|
|
6610
|
+
const exportTarget = pattern ? RegExpPrototypeSymbolReplace.call(
|
|
6611
|
+
patternRegEx,
|
|
6612
|
+
target,
|
|
6613
|
+
() => subpath
|
|
6614
|
+
) : target + subpath;
|
|
6615
|
+
return packageResolve(exportTarget, packageJsonUrl, conditions);
|
|
6616
|
+
}
|
|
6617
|
+
}
|
|
6618
|
+
throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
6619
|
+
}
|
|
6620
|
+
if (invalidSegmentRegEx.exec(target.slice(2)) !== null) {
|
|
6621
|
+
if (deprecatedInvalidSegmentRegEx.exec(target.slice(2)) === null) {
|
|
6622
|
+
if (!isPathMap) {
|
|
6623
|
+
const request = pattern ? match.replace("*", () => subpath) : match + subpath;
|
|
6624
|
+
const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(
|
|
6625
|
+
patternRegEx,
|
|
6626
|
+
target,
|
|
6627
|
+
() => subpath
|
|
6628
|
+
) : target;
|
|
6629
|
+
emitInvalidSegmentDeprecation(
|
|
6630
|
+
resolvedTarget,
|
|
6631
|
+
request,
|
|
6632
|
+
match,
|
|
6633
|
+
packageJsonUrl,
|
|
6634
|
+
internal,
|
|
6635
|
+
base,
|
|
6636
|
+
true
|
|
6637
|
+
);
|
|
6638
|
+
}
|
|
6639
|
+
} else {
|
|
6640
|
+
throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
6641
|
+
}
|
|
6642
|
+
}
|
|
6643
|
+
const resolved = new URL(target, packageJsonUrl);
|
|
6644
|
+
const resolvedPath = resolved.pathname;
|
|
6645
|
+
const packagePath = new URL(".", packageJsonUrl).pathname;
|
|
6646
|
+
if (!resolvedPath.startsWith(packagePath))
|
|
6647
|
+
throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
6648
|
+
if (subpath === "") return resolved;
|
|
6649
|
+
if (invalidSegmentRegEx.exec(subpath) !== null) {
|
|
6650
|
+
const request = pattern ? match.replace("*", () => subpath) : match + subpath;
|
|
6651
|
+
if (deprecatedInvalidSegmentRegEx.exec(subpath) === null) {
|
|
6652
|
+
if (!isPathMap) {
|
|
6653
|
+
const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(
|
|
6654
|
+
patternRegEx,
|
|
6655
|
+
target,
|
|
6656
|
+
() => subpath
|
|
6657
|
+
) : target;
|
|
6658
|
+
emitInvalidSegmentDeprecation(
|
|
6659
|
+
resolvedTarget,
|
|
6660
|
+
request,
|
|
6661
|
+
match,
|
|
6662
|
+
packageJsonUrl,
|
|
6663
|
+
internal,
|
|
6664
|
+
base,
|
|
6665
|
+
false
|
|
6666
|
+
);
|
|
6667
|
+
}
|
|
6668
|
+
} else {
|
|
6669
|
+
throwInvalidSubpath(request, match, packageJsonUrl, internal, base);
|
|
6670
|
+
}
|
|
6671
|
+
}
|
|
6672
|
+
if (pattern) {
|
|
6673
|
+
return new URL(
|
|
6674
|
+
RegExpPrototypeSymbolReplace.call(
|
|
6675
|
+
patternRegEx,
|
|
6676
|
+
resolved.href,
|
|
6677
|
+
() => subpath
|
|
6678
|
+
)
|
|
6679
|
+
);
|
|
6680
|
+
}
|
|
6681
|
+
return new URL(subpath, resolved);
|
|
6682
|
+
}
|
|
6683
|
+
function isArrayIndex(key) {
|
|
6684
|
+
const keyNumber = Number(key);
|
|
6685
|
+
if (`${keyNumber}` !== key) return false;
|
|
6686
|
+
return keyNumber >= 0 && keyNumber < 4294967295;
|
|
6687
|
+
}
|
|
6688
|
+
function resolvePackageTarget(packageJsonUrl, target, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions) {
|
|
6689
|
+
if (typeof target === "string") {
|
|
6690
|
+
return resolvePackageTargetString(
|
|
6691
|
+
target,
|
|
6692
|
+
subpath,
|
|
6693
|
+
packageSubpath,
|
|
6694
|
+
packageJsonUrl,
|
|
6695
|
+
base,
|
|
6696
|
+
pattern,
|
|
6697
|
+
internal,
|
|
6698
|
+
isPathMap,
|
|
6699
|
+
conditions
|
|
6700
|
+
);
|
|
6701
|
+
}
|
|
6702
|
+
if (Array.isArray(target)) {
|
|
6703
|
+
const targetList = target;
|
|
6704
|
+
if (targetList.length === 0) return null;
|
|
6705
|
+
let lastException;
|
|
6706
|
+
let i = -1;
|
|
6707
|
+
while (++i < targetList.length) {
|
|
6708
|
+
const targetItem = targetList[i];
|
|
6709
|
+
let resolveResult;
|
|
6710
|
+
try {
|
|
6711
|
+
resolveResult = resolvePackageTarget(
|
|
6712
|
+
packageJsonUrl,
|
|
6713
|
+
targetItem,
|
|
6714
|
+
subpath,
|
|
6715
|
+
packageSubpath,
|
|
6716
|
+
base,
|
|
6717
|
+
pattern,
|
|
6718
|
+
internal,
|
|
6719
|
+
isPathMap,
|
|
6720
|
+
conditions
|
|
6721
|
+
);
|
|
6722
|
+
} catch (error) {
|
|
6723
|
+
const exception = (
|
|
6724
|
+
/** @type {ErrnoException} */
|
|
6725
|
+
error
|
|
6726
|
+
);
|
|
6727
|
+
lastException = exception;
|
|
6728
|
+
if (exception.code === "ERR_INVALID_PACKAGE_TARGET") continue;
|
|
6729
|
+
throw error;
|
|
6730
|
+
}
|
|
6731
|
+
if (resolveResult === void 0) continue;
|
|
6732
|
+
if (resolveResult === null) {
|
|
6733
|
+
lastException = null;
|
|
6734
|
+
continue;
|
|
6735
|
+
}
|
|
6736
|
+
return resolveResult;
|
|
6737
|
+
}
|
|
6738
|
+
if (lastException === void 0 || lastException === null) {
|
|
6739
|
+
return null;
|
|
6740
|
+
}
|
|
6741
|
+
throw lastException;
|
|
6742
|
+
}
|
|
6743
|
+
if (typeof target === "object" && target !== null) {
|
|
6744
|
+
const keys = Object.getOwnPropertyNames(target);
|
|
6745
|
+
let i = -1;
|
|
6746
|
+
while (++i < keys.length) {
|
|
6747
|
+
const key = keys[i];
|
|
6748
|
+
if (isArrayIndex(key)) {
|
|
6749
|
+
throw new ERR_INVALID_PACKAGE_CONFIG2(
|
|
6750
|
+
(0, import_node_url6.fileURLToPath)(packageJsonUrl),
|
|
6751
|
+
base,
|
|
6752
|
+
'"exports" cannot contain numeric property keys.'
|
|
6753
|
+
);
|
|
6754
|
+
}
|
|
6755
|
+
}
|
|
6756
|
+
i = -1;
|
|
6757
|
+
while (++i < keys.length) {
|
|
6758
|
+
const key = keys[i];
|
|
6759
|
+
if (key === "default" || conditions && conditions.has(key)) {
|
|
6760
|
+
const conditionalTarget = (
|
|
6761
|
+
/** @type {unknown} */
|
|
6762
|
+
target[key]
|
|
6763
|
+
);
|
|
6764
|
+
const resolveResult = resolvePackageTarget(
|
|
6765
|
+
packageJsonUrl,
|
|
6766
|
+
conditionalTarget,
|
|
6767
|
+
subpath,
|
|
6768
|
+
packageSubpath,
|
|
6769
|
+
base,
|
|
6770
|
+
pattern,
|
|
6771
|
+
internal,
|
|
6772
|
+
isPathMap,
|
|
6773
|
+
conditions
|
|
6774
|
+
);
|
|
6775
|
+
if (resolveResult === void 0) continue;
|
|
6776
|
+
return resolveResult;
|
|
6777
|
+
}
|
|
6778
|
+
}
|
|
6779
|
+
return null;
|
|
6780
|
+
}
|
|
6781
|
+
if (target === null) {
|
|
6782
|
+
return null;
|
|
6783
|
+
}
|
|
6784
|
+
throw invalidPackageTarget(
|
|
6785
|
+
packageSubpath,
|
|
6786
|
+
target,
|
|
6787
|
+
packageJsonUrl,
|
|
6788
|
+
internal,
|
|
6789
|
+
base
|
|
6790
|
+
);
|
|
6791
|
+
}
|
|
6792
|
+
function isConditionalExportsMainSugar(exports2, packageJsonUrl, base) {
|
|
6793
|
+
if (typeof exports2 === "string" || Array.isArray(exports2)) return true;
|
|
6794
|
+
if (typeof exports2 !== "object" || exports2 === null) return false;
|
|
6795
|
+
const keys = Object.getOwnPropertyNames(exports2);
|
|
6796
|
+
let isConditionalSugar = false;
|
|
6797
|
+
let i = 0;
|
|
6798
|
+
let keyIndex = -1;
|
|
6799
|
+
while (++keyIndex < keys.length) {
|
|
6800
|
+
const key = keys[keyIndex];
|
|
6801
|
+
const currentIsConditionalSugar = key === "" || key[0] !== ".";
|
|
6802
|
+
if (i++ === 0) {
|
|
6803
|
+
isConditionalSugar = currentIsConditionalSugar;
|
|
6804
|
+
} else if (isConditionalSugar !== currentIsConditionalSugar) {
|
|
6805
|
+
throw new ERR_INVALID_PACKAGE_CONFIG2(
|
|
6806
|
+
(0, import_node_url6.fileURLToPath)(packageJsonUrl),
|
|
6807
|
+
base,
|
|
6808
|
+
`"exports" cannot contain some keys starting with '.' and some not. The exports object must either be an object of package subpath keys or an object of main entry condition name keys only.`
|
|
6809
|
+
);
|
|
6810
|
+
}
|
|
6811
|
+
}
|
|
6812
|
+
return isConditionalSugar;
|
|
6813
|
+
}
|
|
6814
|
+
function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) {
|
|
6815
|
+
if (import_node_process.default.noDeprecation) {
|
|
6816
|
+
return;
|
|
6817
|
+
}
|
|
6818
|
+
const pjsonPath = (0, import_node_url6.fileURLToPath)(pjsonUrl);
|
|
6819
|
+
if (emittedPackageWarnings.has(pjsonPath + "|" + match)) return;
|
|
6820
|
+
emittedPackageWarnings.add(pjsonPath + "|" + match);
|
|
6821
|
+
import_node_process.default.emitWarning(
|
|
6822
|
+
`Use of deprecated trailing slash pattern mapping "${match}" in the "exports" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${(0, import_node_url6.fileURLToPath)(base)}` : ""}. Mapping specifiers ending in "/" is no longer supported.`,
|
|
6823
|
+
"DeprecationWarning",
|
|
6824
|
+
"DEP0155"
|
|
6825
|
+
);
|
|
6826
|
+
}
|
|
6827
|
+
function packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions) {
|
|
6828
|
+
let exports2 = packageConfig.exports;
|
|
6829
|
+
if (isConditionalExportsMainSugar(exports2, packageJsonUrl, base)) {
|
|
6830
|
+
exports2 = { ".": exports2 };
|
|
6831
|
+
}
|
|
6832
|
+
if (own2.call(exports2, packageSubpath) && !packageSubpath.includes("*") && !packageSubpath.endsWith("/")) {
|
|
6833
|
+
const target = exports2[packageSubpath];
|
|
6834
|
+
const resolveResult = resolvePackageTarget(
|
|
6835
|
+
packageJsonUrl,
|
|
6836
|
+
target,
|
|
6837
|
+
"",
|
|
6838
|
+
packageSubpath,
|
|
6839
|
+
base,
|
|
6840
|
+
false,
|
|
6841
|
+
false,
|
|
6842
|
+
false,
|
|
6843
|
+
conditions
|
|
6844
|
+
);
|
|
6845
|
+
if (resolveResult === null || resolveResult === void 0) {
|
|
6846
|
+
throw exportsNotFound(packageSubpath, packageJsonUrl, base);
|
|
6847
|
+
}
|
|
6848
|
+
return resolveResult;
|
|
6849
|
+
}
|
|
6850
|
+
let bestMatch = "";
|
|
6851
|
+
let bestMatchSubpath = "";
|
|
6852
|
+
const keys = Object.getOwnPropertyNames(exports2);
|
|
6853
|
+
let i = -1;
|
|
6854
|
+
while (++i < keys.length) {
|
|
6855
|
+
const key = keys[i];
|
|
6856
|
+
const patternIndex = key.indexOf("*");
|
|
6857
|
+
if (patternIndex !== -1 && packageSubpath.startsWith(key.slice(0, patternIndex))) {
|
|
6858
|
+
if (packageSubpath.endsWith("/")) {
|
|
6859
|
+
emitTrailingSlashPatternDeprecation(
|
|
6860
|
+
packageSubpath,
|
|
6861
|
+
packageJsonUrl,
|
|
6862
|
+
base
|
|
6863
|
+
);
|
|
6864
|
+
}
|
|
6865
|
+
const patternTrailer = key.slice(patternIndex + 1);
|
|
6866
|
+
if (packageSubpath.length >= key.length && packageSubpath.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
|
|
6867
|
+
bestMatch = key;
|
|
6868
|
+
bestMatchSubpath = packageSubpath.slice(
|
|
6869
|
+
patternIndex,
|
|
6870
|
+
packageSubpath.length - patternTrailer.length
|
|
6871
|
+
);
|
|
6872
|
+
}
|
|
6873
|
+
}
|
|
6874
|
+
}
|
|
6875
|
+
if (bestMatch) {
|
|
6876
|
+
const target = (
|
|
6877
|
+
/** @type {unknown} */
|
|
6878
|
+
exports2[bestMatch]
|
|
6879
|
+
);
|
|
6880
|
+
const resolveResult = resolvePackageTarget(
|
|
6881
|
+
packageJsonUrl,
|
|
6882
|
+
target,
|
|
6883
|
+
bestMatchSubpath,
|
|
6884
|
+
bestMatch,
|
|
6885
|
+
base,
|
|
6886
|
+
true,
|
|
6887
|
+
false,
|
|
6888
|
+
packageSubpath.endsWith("/"),
|
|
6889
|
+
conditions
|
|
6890
|
+
);
|
|
6891
|
+
if (resolveResult === null || resolveResult === void 0) {
|
|
6892
|
+
throw exportsNotFound(packageSubpath, packageJsonUrl, base);
|
|
6893
|
+
}
|
|
6894
|
+
return resolveResult;
|
|
6895
|
+
}
|
|
6896
|
+
throw exportsNotFound(packageSubpath, packageJsonUrl, base);
|
|
6897
|
+
}
|
|
6898
|
+
function patternKeyCompare(a, b) {
|
|
6899
|
+
const aPatternIndex = a.indexOf("*");
|
|
6900
|
+
const bPatternIndex = b.indexOf("*");
|
|
6901
|
+
const baseLengthA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
|
|
6902
|
+
const baseLengthB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
|
|
6903
|
+
if (baseLengthA > baseLengthB) return -1;
|
|
6904
|
+
if (baseLengthB > baseLengthA) return 1;
|
|
6905
|
+
if (aPatternIndex === -1) return 1;
|
|
6906
|
+
if (bPatternIndex === -1) return -1;
|
|
6907
|
+
if (a.length > b.length) return -1;
|
|
6908
|
+
if (b.length > a.length) return 1;
|
|
6909
|
+
return 0;
|
|
6910
|
+
}
|
|
6911
|
+
function packageImportsResolve(name, base, conditions) {
|
|
6912
|
+
if (name === "#" || name.startsWith("#/") || name.endsWith("/")) {
|
|
6913
|
+
const reason = "is not a valid internal imports specifier name";
|
|
6914
|
+
throw new ERR_INVALID_MODULE_SPECIFIER(name, reason, (0, import_node_url6.fileURLToPath)(base));
|
|
6915
|
+
}
|
|
6916
|
+
let packageJsonUrl;
|
|
6917
|
+
const packageConfig = getPackageScopeConfig(base);
|
|
6918
|
+
if (packageConfig.exists) {
|
|
6919
|
+
packageJsonUrl = (0, import_node_url6.pathToFileURL)(packageConfig.pjsonPath);
|
|
6920
|
+
const imports = packageConfig.imports;
|
|
6921
|
+
if (imports) {
|
|
6922
|
+
if (own2.call(imports, name) && !name.includes("*")) {
|
|
6923
|
+
const resolveResult = resolvePackageTarget(
|
|
6924
|
+
packageJsonUrl,
|
|
6925
|
+
imports[name],
|
|
6926
|
+
"",
|
|
6927
|
+
name,
|
|
6928
|
+
base,
|
|
6929
|
+
false,
|
|
6930
|
+
true,
|
|
6931
|
+
false,
|
|
6932
|
+
conditions
|
|
6933
|
+
);
|
|
6934
|
+
if (resolveResult !== null && resolveResult !== void 0) {
|
|
6935
|
+
return resolveResult;
|
|
6936
|
+
}
|
|
6937
|
+
} else {
|
|
6938
|
+
let bestMatch = "";
|
|
6939
|
+
let bestMatchSubpath = "";
|
|
6940
|
+
const keys = Object.getOwnPropertyNames(imports);
|
|
6941
|
+
let i = -1;
|
|
6942
|
+
while (++i < keys.length) {
|
|
6943
|
+
const key = keys[i];
|
|
6944
|
+
const patternIndex = key.indexOf("*");
|
|
6945
|
+
if (patternIndex !== -1 && name.startsWith(key.slice(0, -1))) {
|
|
6946
|
+
const patternTrailer = key.slice(patternIndex + 1);
|
|
6947
|
+
if (name.length >= key.length && name.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
|
|
6948
|
+
bestMatch = key;
|
|
6949
|
+
bestMatchSubpath = name.slice(
|
|
6950
|
+
patternIndex,
|
|
6951
|
+
name.length - patternTrailer.length
|
|
6952
|
+
);
|
|
6953
|
+
}
|
|
6954
|
+
}
|
|
6955
|
+
}
|
|
6956
|
+
if (bestMatch) {
|
|
6957
|
+
const target = imports[bestMatch];
|
|
6958
|
+
const resolveResult = resolvePackageTarget(
|
|
6959
|
+
packageJsonUrl,
|
|
6960
|
+
target,
|
|
6961
|
+
bestMatchSubpath,
|
|
6962
|
+
bestMatch,
|
|
6963
|
+
base,
|
|
6964
|
+
true,
|
|
6965
|
+
true,
|
|
6966
|
+
false,
|
|
6967
|
+
conditions
|
|
6968
|
+
);
|
|
6969
|
+
if (resolveResult !== null && resolveResult !== void 0) {
|
|
6970
|
+
return resolveResult;
|
|
6971
|
+
}
|
|
6972
|
+
}
|
|
6973
|
+
}
|
|
6974
|
+
}
|
|
6975
|
+
}
|
|
6976
|
+
throw importNotDefined(name, packageJsonUrl, base);
|
|
6977
|
+
}
|
|
6978
|
+
function parsePackageName(specifier, base) {
|
|
6979
|
+
let separatorIndex = specifier.indexOf("/");
|
|
6980
|
+
let validPackageName = true;
|
|
6981
|
+
let isScoped = false;
|
|
6982
|
+
if (specifier[0] === "@") {
|
|
6983
|
+
isScoped = true;
|
|
6984
|
+
if (separatorIndex === -1 || specifier.length === 0) {
|
|
6985
|
+
validPackageName = false;
|
|
6986
|
+
} else {
|
|
6987
|
+
separatorIndex = specifier.indexOf("/", separatorIndex + 1);
|
|
6988
|
+
}
|
|
6989
|
+
}
|
|
6990
|
+
const packageName = separatorIndex === -1 ? specifier : specifier.slice(0, separatorIndex);
|
|
6991
|
+
if (invalidPackageNameRegEx.exec(packageName) !== null) {
|
|
6992
|
+
validPackageName = false;
|
|
6993
|
+
}
|
|
6994
|
+
if (!validPackageName) {
|
|
6995
|
+
throw new ERR_INVALID_MODULE_SPECIFIER(
|
|
6996
|
+
specifier,
|
|
6997
|
+
"is not a valid package name",
|
|
6998
|
+
(0, import_node_url6.fileURLToPath)(base)
|
|
6999
|
+
);
|
|
7000
|
+
}
|
|
7001
|
+
const packageSubpath = "." + (separatorIndex === -1 ? "" : specifier.slice(separatorIndex));
|
|
7002
|
+
return { packageName, packageSubpath, isScoped };
|
|
7003
|
+
}
|
|
7004
|
+
function packageResolve(specifier, base, conditions) {
|
|
7005
|
+
if (import_node_module7.builtinModules.includes(specifier)) {
|
|
7006
|
+
return new URL("node:" + specifier);
|
|
7007
|
+
}
|
|
7008
|
+
const { packageName, packageSubpath, isScoped } = parsePackageName(
|
|
7009
|
+
specifier,
|
|
7010
|
+
base
|
|
7011
|
+
);
|
|
7012
|
+
const packageConfig = getPackageScopeConfig(base);
|
|
7013
|
+
if (packageConfig.exists) {
|
|
7014
|
+
const packageJsonUrl2 = (0, import_node_url6.pathToFileURL)(packageConfig.pjsonPath);
|
|
7015
|
+
if (packageConfig.name === packageName && packageConfig.exports !== void 0 && packageConfig.exports !== null) {
|
|
7016
|
+
return packageExportsResolve(
|
|
7017
|
+
packageJsonUrl2,
|
|
7018
|
+
packageSubpath,
|
|
7019
|
+
packageConfig,
|
|
7020
|
+
base,
|
|
7021
|
+
conditions
|
|
7022
|
+
);
|
|
7023
|
+
}
|
|
7024
|
+
}
|
|
7025
|
+
let packageJsonUrl = new URL(
|
|
7026
|
+
"./node_modules/" + packageName + "/package.json",
|
|
7027
|
+
base
|
|
7028
|
+
);
|
|
7029
|
+
let packageJsonPath = (0, import_node_url6.fileURLToPath)(packageJsonUrl);
|
|
7030
|
+
let lastPath;
|
|
7031
|
+
do {
|
|
7032
|
+
const stat = tryStatSync(packageJsonPath.slice(0, -13));
|
|
7033
|
+
if (!stat || !stat.isDirectory()) {
|
|
7034
|
+
lastPath = packageJsonPath;
|
|
7035
|
+
packageJsonUrl = new URL(
|
|
7036
|
+
(isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json",
|
|
7037
|
+
packageJsonUrl
|
|
7038
|
+
);
|
|
7039
|
+
packageJsonPath = (0, import_node_url6.fileURLToPath)(packageJsonUrl);
|
|
7040
|
+
continue;
|
|
7041
|
+
}
|
|
7042
|
+
const packageConfig2 = read(packageJsonPath, { base, specifier });
|
|
7043
|
+
if (packageConfig2.exports !== void 0 && packageConfig2.exports !== null) {
|
|
7044
|
+
return packageExportsResolve(
|
|
7045
|
+
packageJsonUrl,
|
|
7046
|
+
packageSubpath,
|
|
7047
|
+
packageConfig2,
|
|
7048
|
+
base,
|
|
7049
|
+
conditions
|
|
7050
|
+
);
|
|
7051
|
+
}
|
|
7052
|
+
if (packageSubpath === ".") {
|
|
7053
|
+
return legacyMainResolve(packageJsonUrl, packageConfig2, base);
|
|
7054
|
+
}
|
|
7055
|
+
return new URL(packageSubpath, packageJsonUrl);
|
|
7056
|
+
} while (packageJsonPath.length !== lastPath.length);
|
|
7057
|
+
throw new ERR_MODULE_NOT_FOUND(packageName, (0, import_node_url6.fileURLToPath)(base), false);
|
|
7058
|
+
}
|
|
7059
|
+
function isRelativeSpecifier(specifier) {
|
|
7060
|
+
if (specifier[0] === ".") {
|
|
7061
|
+
if (specifier.length === 1 || specifier[1] === "/") return true;
|
|
7062
|
+
if (specifier[1] === "." && (specifier.length === 2 || specifier[2] === "/")) {
|
|
7063
|
+
return true;
|
|
7064
|
+
}
|
|
7065
|
+
}
|
|
7066
|
+
return false;
|
|
7067
|
+
}
|
|
7068
|
+
function shouldBeTreatedAsRelativeOrAbsolutePath(specifier) {
|
|
7069
|
+
if (specifier === "") return false;
|
|
7070
|
+
if (specifier[0] === "/") return true;
|
|
7071
|
+
return isRelativeSpecifier(specifier);
|
|
7072
|
+
}
|
|
7073
|
+
function moduleResolve(specifier, base, conditions, preserveSymlinks) {
|
|
7074
|
+
if (conditions === void 0) {
|
|
7075
|
+
conditions = getConditionsSet();
|
|
7076
|
+
}
|
|
7077
|
+
const protocol = base.protocol;
|
|
7078
|
+
const isData = protocol === "data:";
|
|
7079
|
+
const isRemote = isData || protocol === "http:" || protocol === "https:";
|
|
7080
|
+
let resolved;
|
|
7081
|
+
if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) {
|
|
7082
|
+
try {
|
|
7083
|
+
resolved = new URL(specifier, base);
|
|
7084
|
+
} catch (error_) {
|
|
7085
|
+
const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
|
|
7086
|
+
error.cause = error_;
|
|
7087
|
+
throw error;
|
|
7088
|
+
}
|
|
7089
|
+
} else if (protocol === "file:" && specifier[0] === "#") {
|
|
7090
|
+
resolved = packageImportsResolve(specifier, base, conditions);
|
|
7091
|
+
} else {
|
|
7092
|
+
try {
|
|
7093
|
+
resolved = new URL(specifier);
|
|
7094
|
+
} catch (error_) {
|
|
7095
|
+
if (isRemote && !import_node_module7.builtinModules.includes(specifier)) {
|
|
7096
|
+
const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
|
|
7097
|
+
error.cause = error_;
|
|
7098
|
+
throw error;
|
|
7099
|
+
}
|
|
7100
|
+
resolved = packageResolve(specifier, base, conditions);
|
|
7101
|
+
}
|
|
7102
|
+
}
|
|
7103
|
+
import_node_assert2.default.ok(resolved !== void 0, "expected to be defined");
|
|
7104
|
+
if (resolved.protocol !== "file:") {
|
|
7105
|
+
return resolved;
|
|
7106
|
+
}
|
|
7107
|
+
return finalizeResolution(resolved, base, preserveSymlinks);
|
|
7108
|
+
}
|
|
7109
|
+
var import_node_assert2, import_node_fs13, import_node_process, import_node_url6, import_node_path16, import_node_module7, RegExpPrototypeSymbolReplace, ERR_NETWORK_IMPORT_DISALLOWED, ERR_INVALID_MODULE_SPECIFIER, ERR_INVALID_PACKAGE_CONFIG2, ERR_INVALID_PACKAGE_TARGET, ERR_MODULE_NOT_FOUND, ERR_PACKAGE_IMPORT_NOT_DEFINED, ERR_PACKAGE_PATH_NOT_EXPORTED, ERR_UNSUPPORTED_DIR_IMPORT, ERR_UNSUPPORTED_RESOLVE_REQUEST, own2, invalidSegmentRegEx, deprecatedInvalidSegmentRegEx, invalidPackageNameRegEx, patternRegEx, encodedSeparatorRegEx, emittedPackageWarnings, doubleSlashRegEx;
|
|
7110
|
+
var init_resolve2 = __esm({
|
|
7111
|
+
"node_modules/import-meta-resolve/lib/resolve.js"() {
|
|
7112
|
+
"use strict";
|
|
7113
|
+
import_node_assert2 = __toESM(require("assert"), 1);
|
|
7114
|
+
import_node_fs13 = require("fs");
|
|
7115
|
+
import_node_process = __toESM(require("process"), 1);
|
|
7116
|
+
import_node_url6 = require("url");
|
|
7117
|
+
import_node_path16 = __toESM(require("path"), 1);
|
|
7118
|
+
import_node_module7 = require("module");
|
|
7119
|
+
init_get_format();
|
|
7120
|
+
init_errors();
|
|
7121
|
+
init_package_json_reader();
|
|
7122
|
+
init_utils();
|
|
7123
|
+
RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace];
|
|
7124
|
+
({
|
|
7125
|
+
ERR_NETWORK_IMPORT_DISALLOWED,
|
|
7126
|
+
ERR_INVALID_MODULE_SPECIFIER,
|
|
7127
|
+
ERR_INVALID_PACKAGE_CONFIG: ERR_INVALID_PACKAGE_CONFIG2,
|
|
7128
|
+
ERR_INVALID_PACKAGE_TARGET,
|
|
7129
|
+
ERR_MODULE_NOT_FOUND,
|
|
7130
|
+
ERR_PACKAGE_IMPORT_NOT_DEFINED,
|
|
7131
|
+
ERR_PACKAGE_PATH_NOT_EXPORTED,
|
|
7132
|
+
ERR_UNSUPPORTED_DIR_IMPORT,
|
|
7133
|
+
ERR_UNSUPPORTED_RESOLVE_REQUEST
|
|
7134
|
+
} = codes);
|
|
7135
|
+
own2 = {}.hasOwnProperty;
|
|
7136
|
+
invalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i;
|
|
7137
|
+
deprecatedInvalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i;
|
|
7138
|
+
invalidPackageNameRegEx = /^\.|%|\\/;
|
|
7139
|
+
patternRegEx = /\*/g;
|
|
7140
|
+
encodedSeparatorRegEx = /%2f|%5c/i;
|
|
7141
|
+
emittedPackageWarnings = /* @__PURE__ */ new Set();
|
|
7142
|
+
doubleSlashRegEx = /[/\\]{2}/;
|
|
7143
|
+
}
|
|
7144
|
+
});
|
|
7145
|
+
|
|
7146
|
+
// node_modules/import-meta-resolve/index.js
|
|
7147
|
+
var init_import_meta_resolve = __esm({
|
|
7148
|
+
"node_modules/import-meta-resolve/index.js"() {
|
|
7149
|
+
"use strict";
|
|
7150
|
+
init_resolve2();
|
|
7151
|
+
}
|
|
7152
|
+
});
|
|
7153
|
+
|
|
5841
7154
|
// src/server/runnable-environment.ts
|
|
5842
7155
|
var runnable_environment_exports = {};
|
|
5843
7156
|
__export(runnable_environment_exports, {
|
|
@@ -5852,25 +7165,27 @@ function createModuleRunner(environment) {
|
|
|
5852
7165
|
}
|
|
5853
7166
|
return new NastiModuleRunner(environment);
|
|
5854
7167
|
}
|
|
5855
|
-
var
|
|
7168
|
+
var import_node_path17, import_node_fs14, import_node_module8, import_node_url7, debug6, NODE_BUILTINS3, NastiModuleRunner, AsyncFunction;
|
|
5856
7169
|
var init_runnable_environment = __esm({
|
|
5857
7170
|
"src/server/runnable-environment.ts"() {
|
|
5858
7171
|
"use strict";
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
7172
|
+
import_node_path17 = __toESM(require("path"), 1);
|
|
7173
|
+
import_node_fs14 = __toESM(require("fs"), 1);
|
|
7174
|
+
import_node_module8 = require("module");
|
|
7175
|
+
import_node_url7 = require("url");
|
|
7176
|
+
init_import_meta_resolve();
|
|
5863
7177
|
init_transformer();
|
|
5864
7178
|
init_env();
|
|
5865
7179
|
init_debug();
|
|
5866
7180
|
debug6 = createDebugger("nasti:ssr");
|
|
5867
|
-
NODE_BUILTINS3 = /* @__PURE__ */ new Set([...
|
|
7181
|
+
NODE_BUILTINS3 = /* @__PURE__ */ new Set([...import_node_module8.builtinModules, ...import_node_module8.builtinModules.map((m) => `node:${m}`)]);
|
|
5868
7182
|
NastiModuleRunner = class {
|
|
5869
7183
|
environment;
|
|
5870
7184
|
config;
|
|
5871
7185
|
cache = /* @__PURE__ */ new Map();
|
|
5872
7186
|
envDefine;
|
|
5873
|
-
|
|
7187
|
+
externalImportParent;
|
|
7188
|
+
externalImportConditions;
|
|
5874
7189
|
constructor(environment) {
|
|
5875
7190
|
this.environment = environment;
|
|
5876
7191
|
this.config = environment.config;
|
|
@@ -5879,10 +7194,15 @@ var init_runnable_environment = __esm({
|
|
|
5879
7194
|
this.config.mode,
|
|
5880
7195
|
ssrDefineOverrides(environment.consumer)
|
|
5881
7196
|
);
|
|
5882
|
-
this.
|
|
7197
|
+
this.externalImportParent = (0, import_node_url7.pathToFileURL)(import_node_path17.default.join(this.config.root, "package.json"));
|
|
7198
|
+
this.externalImportConditions = /* @__PURE__ */ new Set([
|
|
7199
|
+
...environment.options.resolve.conditions.filter((condition) => condition !== "require"),
|
|
7200
|
+
"node",
|
|
7201
|
+
"import"
|
|
7202
|
+
]);
|
|
5883
7203
|
const handlers = {
|
|
5884
7204
|
fetchModule: async (id, importer) => this.fetchModule(id, importer),
|
|
5885
|
-
getBuiltins: () => [/^node:/, ...
|
|
7205
|
+
getBuiltins: () => [/^node:/, ...import_node_module8.builtinModules]
|
|
5886
7206
|
};
|
|
5887
7207
|
environment.hot.setInvokeHandler?.(handlers);
|
|
5888
7208
|
}
|
|
@@ -5903,9 +7223,9 @@ var init_runnable_environment = __esm({
|
|
|
5903
7223
|
this.cache.clear();
|
|
5904
7224
|
}
|
|
5905
7225
|
resolveToId(rawUrl) {
|
|
5906
|
-
if (
|
|
7226
|
+
if (import_node_path17.default.isAbsolute(rawUrl) && import_node_fs14.default.existsSync(rawUrl.split("?")[0])) return rawUrl;
|
|
5907
7227
|
const clean = rawUrl.replace(/^\//, "");
|
|
5908
|
-
return
|
|
7228
|
+
return import_node_path17.default.resolve(this.config.root, clean);
|
|
5909
7229
|
}
|
|
5910
7230
|
/**
|
|
5911
7231
|
* fetchModule(invoke 契约方法):环境管线产出 runner 可执行代码。
|
|
@@ -5914,14 +7234,14 @@ var init_runnable_environment = __esm({
|
|
|
5914
7234
|
*/
|
|
5915
7235
|
async fetchModule(id, importer) {
|
|
5916
7236
|
if (NODE_BUILTINS3.has(id)) return { externalize: id };
|
|
5917
|
-
if (!id.startsWith(".") && !
|
|
7237
|
+
if (!id.startsWith(".") && !import_node_path17.default.isAbsolute(id) && !id.startsWith("\0")) {
|
|
5918
7238
|
return { externalize: id };
|
|
5919
7239
|
}
|
|
5920
7240
|
const container = this.environment.pluginContainer;
|
|
5921
7241
|
let resolvedId = id;
|
|
5922
7242
|
if (id.startsWith(".") && importer) {
|
|
5923
7243
|
const resolved = await container.resolveId(id, importer);
|
|
5924
|
-
resolvedId = resolved ? typeof resolved === "string" ? resolved : resolved.id :
|
|
7244
|
+
resolvedId = resolved ? typeof resolved === "string" ? resolved : resolved.id : import_node_path17.default.resolve(import_node_path17.default.dirname(importer.split("?")[0]), id);
|
|
5925
7245
|
}
|
|
5926
7246
|
resolvedId = this.completeExtension(resolvedId);
|
|
5927
7247
|
const cleanId = resolvedId.split("?")[0];
|
|
@@ -5929,8 +7249,8 @@ var init_runnable_environment = __esm({
|
|
|
5929
7249
|
const loaded = await container.load(resolvedId);
|
|
5930
7250
|
if (loaded != null) {
|
|
5931
7251
|
code = typeof loaded === "string" ? loaded : loaded.code;
|
|
5932
|
-
} else if (
|
|
5933
|
-
code =
|
|
7252
|
+
} else if (import_node_fs14.default.existsSync(cleanId)) {
|
|
7253
|
+
code = import_node_fs14.default.readFileSync(cleanId, "utf-8");
|
|
5934
7254
|
} else {
|
|
5935
7255
|
throw new Error(`[nasti:ssr] cannot load module: ${resolvedId}`);
|
|
5936
7256
|
}
|
|
@@ -5984,19 +7304,19 @@ var init_runnable_environment = __esm({
|
|
|
5984
7304
|
completeExtension(id) {
|
|
5985
7305
|
const clean = id.split("?")[0];
|
|
5986
7306
|
const query = id.includes("?") ? id.slice(id.indexOf("?")) : "";
|
|
5987
|
-
if (
|
|
7307
|
+
if (import_node_fs14.default.existsSync(clean) && import_node_fs14.default.statSync(clean).isFile()) return id;
|
|
5988
7308
|
const jsMatch = clean.match(/^(.*)\.([mc]?)jsx?$/);
|
|
5989
7309
|
if (jsMatch) {
|
|
5990
7310
|
for (const tsExt of [`.${jsMatch[2]}ts`, `.${jsMatch[2]}tsx`]) {
|
|
5991
|
-
if (
|
|
7311
|
+
if (import_node_fs14.default.existsSync(jsMatch[1] + tsExt)) return jsMatch[1] + tsExt + query;
|
|
5992
7312
|
}
|
|
5993
7313
|
}
|
|
5994
7314
|
for (const ext of this.config.resolve.extensions) {
|
|
5995
|
-
if (
|
|
7315
|
+
if (import_node_fs14.default.existsSync(clean + ext)) return clean + ext + query;
|
|
5996
7316
|
}
|
|
5997
7317
|
for (const ext of this.config.resolve.extensions) {
|
|
5998
|
-
const indexPath =
|
|
5999
|
-
if (
|
|
7318
|
+
const indexPath = import_node_path17.default.join(clean, `index${ext}`);
|
|
7319
|
+
if (import_node_fs14.default.existsSync(indexPath)) return indexPath;
|
|
6000
7320
|
}
|
|
6001
7321
|
return id;
|
|
6002
7322
|
}
|
|
@@ -6023,10 +7343,10 @@ var init_runnable_environment = __esm({
|
|
|
6023
7343
|
return;
|
|
6024
7344
|
}
|
|
6025
7345
|
const ssrImport = async (dep) => {
|
|
6026
|
-
if (NODE_BUILTINS3.has(dep) || !dep.startsWith(".") && !
|
|
7346
|
+
if (NODE_BUILTINS3.has(dep) || !dep.startsWith(".") && !import_node_path17.default.isAbsolute(dep) && !dep.startsWith("\0")) {
|
|
6027
7347
|
return this.importExternal(dep);
|
|
6028
7348
|
}
|
|
6029
|
-
const depId = dep.startsWith(".") ? this.completeExtension(
|
|
7349
|
+
const depId = dep.startsWith(".") ? this.completeExtension(import_node_path17.default.resolve(import_node_path17.default.dirname(fetched.id.split("?")[0]), dep)) : this.completeExtension(dep);
|
|
6030
7350
|
return this.instantiate(depId);
|
|
6031
7351
|
};
|
|
6032
7352
|
const ssrExportAll = (sourceModule) => {
|
|
@@ -6041,7 +7361,7 @@ var init_runnable_environment = __esm({
|
|
|
6041
7361
|
}
|
|
6042
7362
|
};
|
|
6043
7363
|
const importMeta = {
|
|
6044
|
-
url: (0,
|
|
7364
|
+
url: (0, import_node_url7.pathToFileURL)(fetched.id.split("?")[0]).href,
|
|
6045
7365
|
env: { SSR: true, MODE: this.config.mode, DEV: this.config.mode !== "production", PROD: this.config.mode === "production" },
|
|
6046
7366
|
hot: void 0
|
|
6047
7367
|
};
|
|
@@ -6058,20 +7378,21 @@ var init_runnable_environment = __esm({
|
|
|
6058
7378
|
}
|
|
6059
7379
|
async importExternal(spec) {
|
|
6060
7380
|
try {
|
|
6061
|
-
return await (spec.startsWith("node:") || !
|
|
7381
|
+
return await (spec.startsWith("node:") || !import_node_path17.default.isAbsolute(spec) ? import(this.resolveExternalSpecifier(spec)) : import((0, import_node_url7.pathToFileURL)(spec).href));
|
|
6062
7382
|
} catch (err) {
|
|
6063
7383
|
throw new Error(`[nasti:ssr] failed to import external "${spec}": ${err.message}`);
|
|
6064
7384
|
}
|
|
6065
7385
|
}
|
|
6066
|
-
/** bare specifier → 项目 node_modules
|
|
7386
|
+
/** bare specifier → 项目 node_modules 的 ESM URL(避免相对 Nasti 自身解析) */
|
|
6067
7387
|
resolveExternalSpecifier(spec) {
|
|
6068
7388
|
if (spec.startsWith("node:")) return spec;
|
|
6069
7389
|
if (NODE_BUILTINS3.has(spec)) return `node:${spec}`;
|
|
6070
|
-
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
7390
|
+
return moduleResolve(
|
|
7391
|
+
spec,
|
|
7392
|
+
this.externalImportParent,
|
|
7393
|
+
this.externalImportConditions,
|
|
7394
|
+
false
|
|
7395
|
+
).href;
|
|
6075
7396
|
}
|
|
6076
7397
|
};
|
|
6077
7398
|
AsyncFunction = Object.getPrototypeOf(async function() {
|
|
@@ -6165,7 +7486,7 @@ async function createBundledDevServer(opts) {
|
|
|
6165
7486
|
}
|
|
6166
7487
|
const url = `/${patchPath}`;
|
|
6167
7488
|
logger.info(
|
|
6168
|
-
import_picocolors8.default.green("hmr update ") + import_picocolors8.default.dim(changedFiles.map((f) =>
|
|
7489
|
+
import_picocolors8.default.green("hmr update ") + import_picocolors8.default.dim(changedFiles.map((f) => import_node_path18.default.relative(config.root, f)).join(", ")),
|
|
6169
7490
|
{ timestamp: true }
|
|
6170
7491
|
);
|
|
6171
7492
|
sendTo(clientId, { type: "hmr:update", path: url, url });
|
|
@@ -6320,7 +7641,7 @@ async function createBundledDevServer(opts) {
|
|
|
6320
7641
|
return;
|
|
6321
7642
|
}
|
|
6322
7643
|
res.setHeader("ETag", hit.etag);
|
|
6323
|
-
res.setHeader("Content-Type", MIME_TYPES[
|
|
7644
|
+
res.setHeader("Content-Type", MIME_TYPES[import_node_path18.default.extname(fileName)] ?? "application/octet-stream");
|
|
6324
7645
|
res.setHeader("Cache-Control", "no-cache");
|
|
6325
7646
|
res.once("finish", () => {
|
|
6326
7647
|
void engine.notifyPayloadDelivered(fileName).catch(
|
|
@@ -6361,7 +7682,7 @@ function stripCatchAllLoad(plugins) {
|
|
|
6361
7682
|
);
|
|
6362
7683
|
}
|
|
6363
7684
|
function createReactRefreshRuntimePlugin(entryPoints) {
|
|
6364
|
-
const entryIds = new Set(entryPoints.map((p) =>
|
|
7685
|
+
const entryIds = new Set(entryPoints.map((p) => import_node_path18.default.resolve(p)));
|
|
6365
7686
|
return {
|
|
6366
7687
|
name: "nasti:bundled-react-refresh",
|
|
6367
7688
|
resolveId(source) {
|
|
@@ -6379,7 +7700,7 @@ function createReactRefreshRuntimePlugin(entryPoints) {
|
|
|
6379
7700
|
return null;
|
|
6380
7701
|
},
|
|
6381
7702
|
transform(code, id) {
|
|
6382
|
-
if (!entryIds.has(
|
|
7703
|
+
if (!entryIds.has(import_node_path18.default.resolve(id.split("?")[0]))) return null;
|
|
6383
7704
|
return { code: `import ${JSON.stringify(PREAMBLE_SPEC)};
|
|
6384
7705
|
${code}`, map: null };
|
|
6385
7706
|
}
|
|
@@ -6429,11 +7750,11 @@ async function renderBundledIndexHtml(html, config, entryFileNames) {
|
|
|
6429
7750
|
}
|
|
6430
7751
|
return processed;
|
|
6431
7752
|
}
|
|
6432
|
-
var
|
|
7753
|
+
var import_node_path18, import_node_crypto3, import_ws2, import_picocolors8, debug7, MIME_TYPES, MemoryFiles, PREAMBLE_SPEC, RESOLVED_PREAMBLE_ID, REFRESH_RUNTIME_URL, BUNDLED_PREAMBLE_CODE, WRAPPER_RUNTIME_HELPERS;
|
|
6433
7754
|
var init_dev_engine = __esm({
|
|
6434
7755
|
"src/server/bundled/dev-engine.ts"() {
|
|
6435
7756
|
"use strict";
|
|
6436
|
-
|
|
7757
|
+
import_node_path18 = __toESM(require("path"), 1);
|
|
6437
7758
|
import_node_crypto3 = __toESM(require("crypto"), 1);
|
|
6438
7759
|
import_ws2 = require("ws");
|
|
6439
7760
|
import_picocolors8 = __toESM(require("picocolors"), 1);
|
|
@@ -6643,19 +7964,19 @@ async function createServer(inlineConfig = {}) {
|
|
|
6643
7964
|
app.use(bundledServer.middleware);
|
|
6644
7965
|
}
|
|
6645
7966
|
const ignoredSegments = /* @__PURE__ */ new Set(["node_modules", ".git", ".nasti"]);
|
|
6646
|
-
const outDirAbs =
|
|
7967
|
+
const outDirAbs = import_node_path19.default.resolve(config.root, config.build.outDir);
|
|
6647
7968
|
const linkedPackageRoots = getLinkedPackageRoots(config.root).filter(
|
|
6648
7969
|
(r) => r !== config.root && !isUnderRoot(config.root, r)
|
|
6649
7970
|
);
|
|
6650
7971
|
const watchTargets = [config.root, ...linkedPackageRoots];
|
|
6651
7972
|
const watcher = (0, import_chokidar.watch)(watchTargets, {
|
|
6652
7973
|
ignored: (filePath) => {
|
|
6653
|
-
if (filePath === outDirAbs || filePath.startsWith(outDirAbs +
|
|
7974
|
+
if (filePath === outDirAbs || filePath.startsWith(outDirAbs + import_node_path19.default.sep)) return true;
|
|
6654
7975
|
for (const watchRoot of watchTargets) {
|
|
6655
7976
|
if (filePath === watchRoot) return false;
|
|
6656
|
-
const rel =
|
|
6657
|
-
if (!rel || rel.startsWith("..") ||
|
|
6658
|
-
for (const seg of rel.split(
|
|
7977
|
+
const rel = import_node_path19.default.relative(watchRoot, filePath);
|
|
7978
|
+
if (!rel || rel.startsWith("..") || import_node_path19.default.isAbsolute(rel)) continue;
|
|
7979
|
+
for (const seg of rel.split(import_node_path19.default.sep)) {
|
|
6659
7980
|
if (ignoredSegments.has(seg)) return true;
|
|
6660
7981
|
}
|
|
6661
7982
|
return false;
|
|
@@ -6787,7 +8108,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
6787
8108
|
});
|
|
6788
8109
|
};
|
|
6789
8110
|
watcher.on("change", (file) => {
|
|
6790
|
-
if (file.includes(`${
|
|
8111
|
+
if (file.includes(`${import_node_path19.default.sep}node_modules${import_node_path19.default.sep}`) || file.endsWith(`${import_node_path19.default.sep}node_modules`)) {
|
|
6791
8112
|
clearLinkedPackageRootsCache();
|
|
6792
8113
|
}
|
|
6793
8114
|
ssrRunner?.invalidateFile(file);
|
|
@@ -6795,7 +8116,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
6795
8116
|
notifyEnvironmentDrivers(file, "change");
|
|
6796
8117
|
});
|
|
6797
8118
|
watcher.on("add", (file) => {
|
|
6798
|
-
if (file.includes(`${
|
|
8119
|
+
if (file.includes(`${import_node_path19.default.sep}node_modules${import_node_path19.default.sep}`) || file.endsWith(`${import_node_path19.default.sep}node_modules`)) {
|
|
6799
8120
|
clearLinkedPackageRootsCache();
|
|
6800
8121
|
}
|
|
6801
8122
|
ssrRunner?.invalidateFile(file);
|
|
@@ -6803,7 +8124,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
6803
8124
|
notifyEnvironmentDrivers(file, "add");
|
|
6804
8125
|
});
|
|
6805
8126
|
watcher.on("unlink", (file) => {
|
|
6806
|
-
if (file.includes(`${
|
|
8127
|
+
if (file.includes(`${import_node_path19.default.sep}node_modules${import_node_path19.default.sep}`) || file.endsWith(`${import_node_path19.default.sep}node_modules`)) {
|
|
6807
8128
|
clearLinkedPackageRootsCache();
|
|
6808
8129
|
}
|
|
6809
8130
|
ssrRunner?.invalidateFile(file);
|
|
@@ -6835,7 +8156,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
6835
8156
|
const readyIn = Math.ceil(performance.now() - startTime);
|
|
6836
8157
|
logger.info(
|
|
6837
8158
|
`
|
|
6838
|
-
${import_picocolors9.default.cyan(import_picocolors9.default.bold("NASTI"))} ${import_picocolors9.default.cyan(`v${"2.5.
|
|
8159
|
+
${import_picocolors9.default.cyan(import_picocolors9.default.bold("NASTI"))} ${import_picocolors9.default.cyan(`v${"2.5.1"}`)} ${import_picocolors9.default.dim("ready in")} ${import_picocolors9.default.bold(readyIn)} ${import_picocolors9.default.dim("ms")}
|
|
6839
8160
|
`
|
|
6840
8161
|
);
|
|
6841
8162
|
printServerUrls(
|
|
@@ -6932,7 +8253,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
6932
8253
|
throw error;
|
|
6933
8254
|
}
|
|
6934
8255
|
app.use(transformMiddleware(transformContexts.get("client")));
|
|
6935
|
-
const publicDir =
|
|
8256
|
+
const publicDir = import_node_path19.default.resolve(config.root, "public");
|
|
6936
8257
|
app.use((0, import_sirv.default)(publicDir, { dev: true, etag: true }));
|
|
6937
8258
|
app.use((0, import_sirv.default)(config.root, { dev: true, etag: true }));
|
|
6938
8259
|
const postMiddlewares = [];
|
|
@@ -6958,12 +8279,12 @@ function getNetworkAddress() {
|
|
|
6958
8279
|
}
|
|
6959
8280
|
return "localhost";
|
|
6960
8281
|
}
|
|
6961
|
-
var import_node_http,
|
|
8282
|
+
var import_node_http, import_node_path19, import_node_os, import_connect, import_sirv, import_chokidar, import_picocolors9;
|
|
6962
8283
|
var init_server = __esm({
|
|
6963
8284
|
"src/server/index.ts"() {
|
|
6964
8285
|
"use strict";
|
|
6965
8286
|
import_node_http = __toESM(require("http"), 1);
|
|
6966
|
-
|
|
8287
|
+
import_node_path19 = __toESM(require("path"), 1);
|
|
6967
8288
|
import_node_os = __toESM(require("os"), 1);
|
|
6968
8289
|
import_connect = __toESM(require("connect"), 1);
|
|
6969
8290
|
import_sirv = __toESM(require("sirv"), 1);
|
|
@@ -7063,7 +8384,7 @@ async function buildElectron(inlineConfig = {}) {
|
|
|
7063
8384
|
const config = await resolveConfig({ ...inlineConfig, target: "electron" }, "build");
|
|
7064
8385
|
const startTime = performance.now();
|
|
7065
8386
|
assertElectronVersion(config);
|
|
7066
|
-
console.log(import_picocolors5.default.cyan("\n\u26A1 nasti build (electron)") + import_picocolors5.default.dim(` v${"2.5.
|
|
8387
|
+
console.log(import_picocolors5.default.cyan("\n\u26A1 nasti build (electron)") + import_picocolors5.default.dim(` v${"2.5.1"}`));
|
|
7067
8388
|
console.log(import_picocolors5.default.dim(` root: ${config.root}`));
|
|
7068
8389
|
console.log(import_picocolors5.default.dim(` mode: ${config.mode}`));
|
|
7069
8390
|
console.log(import_picocolors5.default.dim(` target: electron (\u2265 ${config.electron.minVersion})`));
|
|
@@ -7193,8 +8514,8 @@ function createElectronRendererConfig(config, inlineConfig = {}, overrides = {})
|
|
|
7193
8514
|
}
|
|
7194
8515
|
};
|
|
7195
8516
|
}
|
|
7196
|
-
function outFileName(outDir, base,
|
|
7197
|
-
const ext =
|
|
8517
|
+
function outFileName(outDir, base, format2) {
|
|
8518
|
+
const ext = format2 === "cjs" ? ".cjs" : ".mjs";
|
|
7198
8519
|
return import_node_path11.default.join(outDir, base + ext);
|
|
7199
8520
|
}
|
|
7200
8521
|
function normalizePreload(preload, root) {
|
|
@@ -7236,9 +8557,9 @@ function detectInstalledElectron(root) {
|
|
|
7236
8557
|
init_server();
|
|
7237
8558
|
|
|
7238
8559
|
// src/server/electron-dev.ts
|
|
7239
|
-
var
|
|
7240
|
-
var
|
|
7241
|
-
var
|
|
8560
|
+
var import_node_path20 = __toESM(require("path"), 1);
|
|
8561
|
+
var import_node_fs15 = __toESM(require("fs"), 1);
|
|
8562
|
+
var import_node_module9 = require("module");
|
|
7242
8563
|
var import_node_child_process = require("child_process");
|
|
7243
8564
|
var import_chokidar2 = __toESM(require("chokidar"), 1);
|
|
7244
8565
|
var import_picocolors10 = __toESM(require("picocolors"), 1);
|
|
@@ -7251,7 +8572,7 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
7251
8572
|
const { noSpawn, ...rest } = inlineConfig;
|
|
7252
8573
|
const config = await resolveConfig({ ...rest, target: "electron" }, "serve");
|
|
7253
8574
|
warnElectronVersion(config);
|
|
7254
|
-
console.log(import_picocolors10.default.cyan("\n\u26A1 nasti electron dev") + import_picocolors10.default.dim(` v${"2.5.
|
|
8575
|
+
console.log(import_picocolors10.default.cyan("\n\u26A1 nasti electron dev") + import_picocolors10.default.dim(` v${"2.5.1"}`));
|
|
7255
8576
|
const { createServer: createServer2 } = await Promise.resolve().then(() => (init_server(), server_exports));
|
|
7256
8577
|
const server = await createServer2({
|
|
7257
8578
|
...rest,
|
|
@@ -7261,11 +8582,11 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
7261
8582
|
await server.listen();
|
|
7262
8583
|
const devUrl = `http://localhost:${server.config.server.port}` + electronRendererDevPath(config.electron.renderer);
|
|
7263
8584
|
console.log(import_picocolors10.default.dim(` renderer: ${devUrl}`));
|
|
7264
|
-
const stageDir =
|
|
7265
|
-
|
|
7266
|
-
const mainEntry =
|
|
8585
|
+
const stageDir = import_node_path20.default.resolve(config.root, ".nasti");
|
|
8586
|
+
import_node_fs15.default.mkdirSync(stageDir, { recursive: true });
|
|
8587
|
+
const mainEntry = import_node_path20.default.resolve(config.root, config.electron.main);
|
|
7267
8588
|
const preloadEntries = normalizePreload(config.electron.preload, config.root);
|
|
7268
|
-
const builtMainFile =
|
|
8589
|
+
const builtMainFile = import_node_path20.default.join(stageDir, "main" + extFor(config.electron.mainFormat));
|
|
7269
8590
|
const builtPreloadFiles = [];
|
|
7270
8591
|
const compileAll = async () => {
|
|
7271
8592
|
await compileNode(config, mainEntry, {
|
|
@@ -7275,9 +8596,9 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
7275
8596
|
});
|
|
7276
8597
|
builtPreloadFiles.length = 0;
|
|
7277
8598
|
for (const entry of preloadEntries) {
|
|
7278
|
-
if (!
|
|
7279
|
-
const base =
|
|
7280
|
-
const out =
|
|
8599
|
+
if (!import_node_fs15.default.existsSync(entry)) continue;
|
|
8600
|
+
const base = import_node_path20.default.basename(entry).replace(/\.[^.]+$/, "");
|
|
8601
|
+
const out = import_node_path20.default.join(stageDir, base + extFor(config.electron.preloadFormat));
|
|
7281
8602
|
await compileNode(config, entry, {
|
|
7282
8603
|
outFile: out,
|
|
7283
8604
|
format: config.electron.preloadFormat,
|
|
@@ -7316,7 +8637,7 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
7316
8637
|
};
|
|
7317
8638
|
spawnElectron();
|
|
7318
8639
|
if (config.electron.autoRestart) {
|
|
7319
|
-
const watchTargets = [mainEntry, ...preloadEntries].filter(
|
|
8640
|
+
const watchTargets = [mainEntry, ...preloadEntries].filter(import_node_fs15.default.existsSync);
|
|
7320
8641
|
const watcher = import_chokidar2.default.watch(watchTargets, { ignoreInitial: true });
|
|
7321
8642
|
let restarting = null;
|
|
7322
8643
|
let pending = false;
|
|
@@ -7363,8 +8684,8 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
7363
8684
|
});
|
|
7364
8685
|
}
|
|
7365
8686
|
}
|
|
7366
|
-
function extFor(
|
|
7367
|
-
return
|
|
8687
|
+
function extFor(format2) {
|
|
8688
|
+
return format2 === "cjs" ? ".cjs" : ".mjs";
|
|
7368
8689
|
}
|
|
7369
8690
|
async function compileNode(config, entry, opts) {
|
|
7370
8691
|
const env = loadEnv(config.mode, config.root, config.envPrefix);
|
|
@@ -7403,7 +8724,7 @@ async function compileNode(config, entry, opts) {
|
|
|
7403
8724
|
platform: "node",
|
|
7404
8725
|
plugins: [oxcTransformPlugin, electronPlugin(config), resolvePlugin(config)]
|
|
7405
8726
|
});
|
|
7406
|
-
|
|
8727
|
+
import_node_fs15.default.mkdirSync(import_node_path20.default.dirname(opts.outFile), { recursive: true });
|
|
7407
8728
|
await bundle2.write({
|
|
7408
8729
|
file: opts.outFile,
|
|
7409
8730
|
format: opts.format === "cjs" ? "cjs" : "esm",
|
|
@@ -7416,18 +8737,18 @@ async function compileNode(config, entry, opts) {
|
|
|
7416
8737
|
await bundle2.close();
|
|
7417
8738
|
}
|
|
7418
8739
|
function electronRendererDevPath(renderer) {
|
|
7419
|
-
const normalized = renderer.split(
|
|
8740
|
+
const normalized = renderer.split(import_node_path20.default.sep).join("/").replace(/^\.?\//, "");
|
|
7420
8741
|
return normalized === "index.html" ? "/" : `/${normalized}`;
|
|
7421
8742
|
}
|
|
7422
8743
|
function resolveElectronBinary(config) {
|
|
7423
|
-
if (config.electron.electronPath &&
|
|
8744
|
+
if (config.electron.electronPath && import_node_fs15.default.existsSync(config.electron.electronPath)) {
|
|
7424
8745
|
return config.electron.electronPath;
|
|
7425
8746
|
}
|
|
7426
8747
|
try {
|
|
7427
|
-
const require2 = (0,
|
|
8748
|
+
const require2 = (0, import_node_module9.createRequire)(import_node_path20.default.resolve(config.root, "package.json"));
|
|
7428
8749
|
const pathFile = require2.resolve("electron");
|
|
7429
8750
|
const electronModule = require2(pathFile);
|
|
7430
|
-
if (typeof electronModule === "string" &&
|
|
8751
|
+
if (typeof electronModule === "string" && import_node_fs15.default.existsSync(electronModule)) {
|
|
7431
8752
|
return electronModule;
|
|
7432
8753
|
}
|
|
7433
8754
|
} catch {
|
|
@@ -7454,10 +8775,10 @@ function warnElectronVersion(config) {
|
|
|
7454
8775
|
}
|
|
7455
8776
|
|
|
7456
8777
|
// src/plugins/monaco-editor.ts
|
|
7457
|
-
var
|
|
7458
|
-
var
|
|
8778
|
+
var import_node_path21 = __toESM(require("path"), 1);
|
|
8779
|
+
var import_node_fs16 = __toESM(require("fs"), 1);
|
|
7459
8780
|
var import_node_crypto4 = __toESM(require("crypto"), 1);
|
|
7460
|
-
var
|
|
8781
|
+
var import_node_module10 = require("module");
|
|
7461
8782
|
var DEFAULT_WORKERS = {
|
|
7462
8783
|
editorWorkerService: "monaco-editor/esm/vs/editor/editor.worker",
|
|
7463
8784
|
css: "monaco-editor/esm/vs/language/css/css.worker",
|
|
@@ -7476,9 +8797,9 @@ function normalizePublicPath(p) {
|
|
|
7476
8797
|
}
|
|
7477
8798
|
function readMonacoVersion(root) {
|
|
7478
8799
|
try {
|
|
7479
|
-
const require2 = (0,
|
|
8800
|
+
const require2 = (0, import_node_module10.createRequire)(import_node_path21.default.resolve(root, "package.json"));
|
|
7480
8801
|
const pkgJsonPath = require2.resolve("monaco-editor/package.json", { paths: [root] });
|
|
7481
|
-
const pkg = JSON.parse(
|
|
8802
|
+
const pkg = JSON.parse(import_node_fs16.default.readFileSync(pkgJsonPath, "utf-8"));
|
|
7482
8803
|
return typeof pkg.version === "string" ? pkg.version : "unknown";
|
|
7483
8804
|
} catch {
|
|
7484
8805
|
return "unknown";
|
|
@@ -7498,20 +8819,20 @@ function monacoEditorPlugin(options = {}) {
|
|
|
7498
8819
|
let cacheDir = "";
|
|
7499
8820
|
const building = /* @__PURE__ */ new Map();
|
|
7500
8821
|
async function buildWorker(worker) {
|
|
7501
|
-
const cacheFile =
|
|
7502
|
-
if (
|
|
8822
|
+
const cacheFile = import_node_path21.default.join(cacheDir, `${worker.label}.worker.js`);
|
|
8823
|
+
if (import_node_fs16.default.existsSync(cacheFile)) return cacheFile;
|
|
7503
8824
|
const existing = building.get(worker.label);
|
|
7504
8825
|
if (existing) return existing;
|
|
7505
8826
|
const task = (async () => {
|
|
7506
8827
|
const { rolldown: rolldown4 } = await import("rolldown");
|
|
7507
|
-
const require2 = (0,
|
|
8828
|
+
const require2 = (0, import_node_module10.createRequire)(import_node_path21.default.resolve(resolvedConfig.root, "package.json"));
|
|
7508
8829
|
let entry;
|
|
7509
8830
|
try {
|
|
7510
8831
|
entry = require2.resolve(worker.entry, { paths: [resolvedConfig.root] });
|
|
7511
8832
|
} catch {
|
|
7512
8833
|
entry = require2.resolve(worker.entry + ".js", { paths: [resolvedConfig.root] });
|
|
7513
8834
|
}
|
|
7514
|
-
|
|
8835
|
+
import_node_fs16.default.mkdirSync(cacheDir, { recursive: true });
|
|
7515
8836
|
const bundle2 = await rolldown4({
|
|
7516
8837
|
input: entry,
|
|
7517
8838
|
platform: "browser"
|
|
@@ -7571,15 +8892,15 @@ function monacoEditorPlugin(options = {}) {
|
|
|
7571
8892
|
resolvedConfig = config;
|
|
7572
8893
|
const version = readMonacoVersion(config.root);
|
|
7573
8894
|
const key = import_node_crypto4.default.createHash("sha1").update(version + "|" + publicPath).digest("hex").slice(0, 8);
|
|
7574
|
-
cacheDir =
|
|
8895
|
+
cacheDir = import_node_path21.default.resolve(config.root, "node_modules/.nasti/monaco", key);
|
|
7575
8896
|
},
|
|
7576
8897
|
async configureServer(server) {
|
|
7577
8898
|
const shouldBuild = !isCDN(publicPath) || forceBuildCDN;
|
|
7578
8899
|
const watcher = server.watcher;
|
|
7579
|
-
const monacoLogical =
|
|
8900
|
+
const monacoLogical = import_node_path21.default.resolve(resolvedConfig.root, "node_modules/monaco-editor");
|
|
7580
8901
|
const monacoPaths = /* @__PURE__ */ new Set([monacoLogical]);
|
|
7581
8902
|
try {
|
|
7582
|
-
monacoPaths.add(
|
|
8903
|
+
monacoPaths.add(import_node_fs16.default.realpathSync(monacoLogical));
|
|
7583
8904
|
} catch {
|
|
7584
8905
|
}
|
|
7585
8906
|
for (const monacoDir of monacoPaths) {
|
|
@@ -7613,7 +8934,7 @@ function monacoEditorPlugin(options = {}) {
|
|
|
7613
8934
|
const file = await buildWorker(worker);
|
|
7614
8935
|
res.setHeader("Content-Type", "application/javascript; charset=utf-8");
|
|
7615
8936
|
res.setHeader("Cache-Control", "public, max-age=604800, immutable");
|
|
7616
|
-
|
|
8937
|
+
import_node_fs16.default.createReadStream(file).pipe(res);
|
|
7617
8938
|
} catch (e) {
|
|
7618
8939
|
res.statusCode = 500;
|
|
7619
8940
|
res.end(`Monaco worker build failed: ${e.message}`);
|
|
@@ -7648,16 +8969,16 @@ self.monaco = monaco;`,
|
|
|
7648
8969
|
resolvedConfig.root,
|
|
7649
8970
|
resolvedConfig.build.outDir,
|
|
7650
8971
|
resolvedConfig.base
|
|
7651
|
-
) : isCDN(publicPath) ?
|
|
8972
|
+
) : isCDN(publicPath) ? import_node_path21.default.resolve(resolvedConfig.root, resolvedConfig.build.outDir, "monaco") : import_node_path21.default.resolve(
|
|
7652
8973
|
resolvedConfig.root,
|
|
7653
8974
|
resolvedConfig.build.outDir,
|
|
7654
8975
|
publicPath.replace(/^\//, "")
|
|
7655
8976
|
);
|
|
7656
|
-
|
|
8977
|
+
import_node_fs16.default.mkdirSync(outDir, { recursive: true });
|
|
7657
8978
|
for (const worker of workers) {
|
|
7658
8979
|
try {
|
|
7659
8980
|
const cacheFile = await buildWorker(worker);
|
|
7660
|
-
|
|
8981
|
+
import_node_fs16.default.copyFileSync(cacheFile, import_node_path21.default.join(outDir, `${worker.label}.worker.js`));
|
|
7661
8982
|
} catch (e) {
|
|
7662
8983
|
throw new Error(
|
|
7663
8984
|
`[nasti:monaco-editor] worker build failed for "${worker.label}": ${e.message}
|
|
@@ -7670,8 +8991,8 @@ ${e.stack || ""}`
|
|
|
7670
8991
|
}
|
|
7671
8992
|
|
|
7672
8993
|
// src/plugins/rsc.ts
|
|
7673
|
-
var
|
|
7674
|
-
var
|
|
8994
|
+
var import_node_fs17 = __toESM(require("fs"), 1);
|
|
8995
|
+
var import_node_path22 = __toESM(require("path"), 1);
|
|
7675
8996
|
var import_oxc_parser = require("oxc-parser");
|
|
7676
8997
|
init_transformer();
|
|
7677
8998
|
var SERVER_RUNTIME_ID = "virtual:nasti-rsc/server-runtime";
|
|
@@ -7691,7 +9012,7 @@ function rsc(options = {}) {
|
|
|
7691
9012
|
name: "nasti:rsc",
|
|
7692
9013
|
enforce: "post",
|
|
7693
9014
|
config(config, env) {
|
|
7694
|
-
const root =
|
|
9015
|
+
const root = import_node_path22.default.resolve(config.root ?? ".");
|
|
7695
9016
|
const include = options.include ?? config.react?.include ?? /\.[tj]sx?$/;
|
|
7696
9017
|
const exclude = options.exclude ?? config.react?.exclude ?? /node_modules/;
|
|
7697
9018
|
const discoveredClients = env.command === "build" ? discoverDirectiveModules(root, options.scanDirectories, include, exclude) : [];
|
|
@@ -7943,21 +9264,21 @@ function manifestReferences(root, result, references) {
|
|
|
7943
9264
|
}
|
|
7944
9265
|
function discoverDirectiveModules(root, scanDirectories, include, exclude) {
|
|
7945
9266
|
const requested = scanDirectories ?? ["app", "src"];
|
|
7946
|
-
const roots = requested.map((directory) =>
|
|
9267
|
+
const roots = requested.map((directory) => import_node_path22.default.resolve(root, directory)).filter((directory) => import_node_fs17.default.existsSync(directory));
|
|
7947
9268
|
if (roots.length === 0) roots.push(root);
|
|
7948
9269
|
const output = [];
|
|
7949
9270
|
for (const directory of roots) walk(directory);
|
|
7950
9271
|
return output;
|
|
7951
9272
|
function walk(directory) {
|
|
7952
|
-
for (const entry of
|
|
9273
|
+
for (const entry of import_node_fs17.default.readdirSync(directory, { withFileTypes: true })) {
|
|
7953
9274
|
if (entry.name === "node_modules" || entry.name === ".git" || entry.name === ".nasti") continue;
|
|
7954
|
-
const id =
|
|
9275
|
+
const id = import_node_path22.default.join(directory, entry.name);
|
|
7955
9276
|
if (entry.isDirectory()) {
|
|
7956
9277
|
walk(id);
|
|
7957
9278
|
continue;
|
|
7958
9279
|
}
|
|
7959
9280
|
if (!entry.isFile() || !matchesReactFilter(id, include, exclude)) continue;
|
|
7960
|
-
const module2 = scanModule(id,
|
|
9281
|
+
const module2 = scanModule(id, import_node_fs17.default.readFileSync(id, "utf-8"));
|
|
7961
9282
|
if (module2) output.push({ id, module: module2 });
|
|
7962
9283
|
}
|
|
7963
9284
|
}
|
|
@@ -7968,15 +9289,15 @@ function collectClientSeeds(root, config, client, configured) {
|
|
|
7968
9289
|
...normalizeEntries(configured)
|
|
7969
9290
|
];
|
|
7970
9291
|
if (explicit.length > 0) return explicit;
|
|
7971
|
-
const htmlFile =
|
|
7972
|
-
if (
|
|
7973
|
-
const html =
|
|
7974
|
-
const htmlDir =
|
|
7975
|
-
const entries = [...html.matchAll(/<script[^>]+src=["']([^"']+)["'][^>]*>/gi)].map((match) => match[1]?.split(/[?#]/, 1)[0]).filter((entry) => !!entry && !entry.startsWith("http")).map((entry) => entry.startsWith("/") ?
|
|
9292
|
+
const htmlFile = import_node_path22.default.resolve(root, client.html ?? "index.html");
|
|
9293
|
+
if (import_node_fs17.default.existsSync(htmlFile)) {
|
|
9294
|
+
const html = import_node_fs17.default.readFileSync(htmlFile, "utf-8");
|
|
9295
|
+
const htmlDir = import_node_path22.default.dirname(htmlFile);
|
|
9296
|
+
const entries = [...html.matchAll(/<script[^>]+src=["']([^"']+)["'][^>]*>/gi)].map((match) => match[1]?.split(/[?#]/, 1)[0]).filter((entry) => !!entry && !entry.startsWith("http")).map((entry) => entry.startsWith("/") ? import_node_path22.default.resolve(root, entry.slice(1)) : import_node_path22.default.resolve(htmlDir, entry));
|
|
7976
9297
|
if (entries.length > 0) return entries;
|
|
7977
9298
|
}
|
|
7978
9299
|
for (const entry of ["src/main.ts", "src/main.tsx", "src/main.js", "src/index.ts", "src/index.tsx", "src/index.js"]) {
|
|
7979
|
-
if (
|
|
9300
|
+
if (import_node_fs17.default.existsSync(import_node_path22.default.resolve(root, entry))) return [entry];
|
|
7980
9301
|
}
|
|
7981
9302
|
return [];
|
|
7982
9303
|
}
|
|
@@ -7997,9 +9318,9 @@ function cleanModuleId(id) {
|
|
|
7997
9318
|
return id.split(/[?#]/, 1)[0];
|
|
7998
9319
|
}
|
|
7999
9320
|
function referenceModuleId(root, id) {
|
|
8000
|
-
if (!root || !
|
|
8001
|
-
const relative =
|
|
8002
|
-
return relative.startsWith("../") ? id.replaceAll(
|
|
9321
|
+
if (!root || !import_node_path22.default.isAbsolute(id)) return id.replaceAll(import_node_path22.default.sep, "/");
|
|
9322
|
+
const relative = import_node_path22.default.relative(root, id).replaceAll(import_node_path22.default.sep, "/");
|
|
9323
|
+
return relative.startsWith("../") ? id.replaceAll(import_node_path22.default.sep, "/") : `/${relative}`;
|
|
8003
9324
|
}
|
|
8004
9325
|
function displayId(root, id) {
|
|
8005
9326
|
return referenceModuleId(root, id);
|