@happyvertical/smrt-core 0.56.1 → 0.57.0
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/AGENTS.md +6 -0
- package/agents/browser-entry.md +5 -0
- package/agents/generators.md +24 -0
- package/agents/object-runtime.md +17 -0
- package/dist/browser.d.ts +1 -0
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/interceptors.d.ts +7 -0
- package/dist/interceptors.d.ts.map +1 -1
- package/dist/interceptors.js +15 -1
- package/dist/interceptors.js.map +1 -1
- package/dist/manifest/browser-capability.generated.d.ts.map +1 -1
- package/dist/manifest/browser-capability.generated.js +13 -0
- package/dist/manifest/browser-capability.generated.js.map +1 -1
- package/dist/manifest/manifest-loader.d.ts.map +1 -1
- package/dist/manifest/manifest-loader.js +1 -2
- package/dist/manifest/manifest-loader.js.map +1 -1
- package/dist/manifest/static-manifest.js +1 -1
- package/dist/manifest/static-manifest.js.map +1 -1
- package/dist/manifest/store.js +1 -1
- package/dist/manifest.json +1 -1
- package/dist/mcp-serializer.js +1 -1
- package/dist/object.d.ts +1 -0
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +44 -13
- package/dist/object.js.map +1 -1
- package/dist/registry/collection-exposure.d.ts +99 -0
- package/dist/registry/collection-exposure.d.ts.map +1 -0
- package/dist/registry/collection-exposure.js +135 -0
- package/dist/registry/collection-exposure.js.map +1 -0
- package/dist/registry.d.ts +8 -1
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +76 -3
- package/dist/registry.js.map +1 -1
- package/dist/scanner/manifest-generator.d.ts +14 -0
- package/dist/scanner/manifest-generator.d.ts.map +1 -1
- package/dist/scanner/manifest-generator.js +66 -13
- package/dist/scanner/manifest-generator.js.map +1 -1
- package/dist/smrt-knowledge.json +11 -11
- package/dist/testing/file-cleanup.d.ts +9 -0
- package/dist/testing/file-cleanup.d.ts.map +1 -0
- package/dist/utils/sha256.js +2 -2
- package/dist/vite-plugin/index.js +1 -1
- package/dist/vite-plugin/sveltekit-generator.d.ts.map +1 -1
- package/dist/vite-plugin/sveltekit-generator.js +4 -0
- package/dist/vite-plugin/sveltekit-generator.js.map +1 -1
- package/package.json +4 -4
- package/dist/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/_md.js +0 -169
- package/dist/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/_md.js.map +0 -1
- package/dist/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/_u64.js +0 -13
- package/dist/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/_u64.js.map +0 -1
- package/dist/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/sha2.js +0 -198
- package/dist/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/sha2.js.map +0 -1
- package/dist/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/utils.js +0 -243
- package/dist/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/utils.js.map +0 -1
- package/dist/node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js +0 -51
- package/dist/node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js.map +0 -1
- package/dist/node_modules/.pnpm/brace-expansion@5.0.11/node_modules/brace-expansion/dist/esm/index.js +0 -202
- package/dist/node_modules/.pnpm/brace-expansion@5.0.11/node_modules/brace-expansion/dist/esm/index.js.map +0 -1
- package/dist/node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/index.js +0 -34
- package/dist/node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/index.js.map +0 -1
- package/dist/node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/errors.js +0 -343
- package/dist/node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/errors.js.map +0 -1
- package/dist/node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/get-format.js +0 -109
- package/dist/node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/get-format.js.map +0 -1
- package/dist/node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/package-json-reader.js +0 -102
- package/dist/node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/package-json-reader.js.map +0 -1
- package/dist/node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/resolve.js +0 -673
- package/dist/node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/resolve.js.map +0 -1
- package/dist/node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/utils.js +0 -32
- package/dist/node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/utils.js.map +0 -1
- package/dist/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/assert-valid-pattern.js +0 -10
- package/dist/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/assert-valid-pattern.js.map +0 -1
- package/dist/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/ast.js +0 -514
- package/dist/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/ast.js.map +0 -1
- package/dist/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/brace-expressions.js +0 -124
- package/dist/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/brace-expressions.js.map +0 -1
- package/dist/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/escape.js +0 -21
- package/dist/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/escape.js.map +0 -1
- package/dist/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/index.js +0 -629
- package/dist/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/index.js.map +0 -1
- package/dist/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/unescape.js +0 -28
- package/dist/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/unescape.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../../../../../node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/index.js"],"sourcesContent":["/**\n * @typedef {import('./lib/errors.js').ErrnoException} ErrnoException\n */\n\nimport {defaultResolve} from './lib/resolve.js'\n\nexport {moduleResolve} from './lib/resolve.js'\n\n/**\n * Match `import.meta.resolve` except that `parent` is required (you can pass\n * `import.meta.url`).\n *\n * @param {string} specifier\n * The module specifier to resolve relative to parent\n * (`/example.js`, `./example.js`, `../example.js`, `some-package`, `fs`,\n * etc).\n * @param {string} parent\n * The absolute parent module URL to resolve from.\n * You must pass `import.meta.url` or something else.\n * @returns {string}\n * Returns a string to a full `file:`, `data:`, or `node:` URL\n * to the found thing.\n */\nexport function resolve(specifier, parent) {\n if (!parent) {\n throw new Error(\n 'Please pass `parent`: `import-meta-resolve` cannot ponyfill that'\n )\n }\n\n try {\n return defaultResolve(specifier, {parentURL: parent}).url\n } catch (error) {\n // See: <https://github.com/nodejs/node/blob/45f5c9b/lib/internal/modules/esm/initialize_import_meta.js#L34>\n const exception = /** @type {ErrnoException} */ (error)\n\n if (\n (exception.code === 'ERR_UNSUPPORTED_DIR_IMPORT' ||\n exception.code === 'ERR_MODULE_NOT_FOUND') &&\n typeof exception.url === 'string'\n ) {\n return exception.url\n }\n\n throw error\n }\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;;;AAuBA,SAAgB,QAAQ,WAAW,QAAQ;CACzC,IAAI,CAAC,QACH,MAAM,IAAI,MACR,kEACF;CAGF,IAAI;EACF,OAAO,eAAe,WAAW,EAAC,WAAW,OAAM,CAAC,CAAC,CAAC;CACxD,SAAS,OAAO;EAEd,MAAM,YAA2C;EAEjD,KACG,UAAU,SAAS,gCAClB,UAAU,SAAS,2BACrB,OAAO,UAAU,QAAQ,UAEzB,OAAO,UAAU;EAGnB,MAAM;CACR;AACF"}
|
|
@@ -1,343 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import v8 from "node:v8";
|
|
3
|
-
import { format, inspect } from "node:util";
|
|
4
|
-
//#region ../../node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/errors.js
|
|
5
|
-
/**
|
|
6
|
-
* @typedef ErrnoExceptionFields
|
|
7
|
-
* @property {number | undefined} [errnode]
|
|
8
|
-
* @property {string | undefined} [code]
|
|
9
|
-
* @property {string | undefined} [path]
|
|
10
|
-
* @property {string | undefined} [syscall]
|
|
11
|
-
* @property {string | undefined} [url]
|
|
12
|
-
*
|
|
13
|
-
* @typedef {Error & ErrnoExceptionFields} ErrnoException
|
|
14
|
-
*/
|
|
15
|
-
/**
|
|
16
|
-
* @typedef {(...parameters: Array<any>) => string} MessageFunction
|
|
17
|
-
*/
|
|
18
|
-
var own = {}.hasOwnProperty;
|
|
19
|
-
var classRegExp = /^([A-Z][a-z\d]*)+$/;
|
|
20
|
-
var kTypes = /* @__PURE__ */ new Set([
|
|
21
|
-
"string",
|
|
22
|
-
"function",
|
|
23
|
-
"number",
|
|
24
|
-
"object",
|
|
25
|
-
"Function",
|
|
26
|
-
"Object",
|
|
27
|
-
"boolean",
|
|
28
|
-
"bigint",
|
|
29
|
-
"symbol"
|
|
30
|
-
]);
|
|
31
|
-
var codes = {};
|
|
32
|
-
/**
|
|
33
|
-
* Create a list string in the form like 'A and B' or 'A, B, ..., and Z'.
|
|
34
|
-
* We cannot use Intl.ListFormat because it's not available in
|
|
35
|
-
* --without-intl builds.
|
|
36
|
-
*
|
|
37
|
-
* @param {Array<string>} array
|
|
38
|
-
* An array of strings.
|
|
39
|
-
* @param {string} [type]
|
|
40
|
-
* The list type to be inserted before the last element.
|
|
41
|
-
* @returns {string}
|
|
42
|
-
*/
|
|
43
|
-
function formatList(array, type = "and") {
|
|
44
|
-
return array.length < 3 ? array.join(` ${type} `) : `${array.slice(0, -1).join(", ")}, ${type} ${array[array.length - 1]}`;
|
|
45
|
-
}
|
|
46
|
-
/** @type {Map<string, MessageFunction | string>} */
|
|
47
|
-
var messages = /* @__PURE__ */ new Map();
|
|
48
|
-
var nodeInternalPrefix = "__node_internal_";
|
|
49
|
-
/** @type {number} */
|
|
50
|
-
var userStackTraceLimit;
|
|
51
|
-
codes.ERR_INVALID_ARG_TYPE = createError(
|
|
52
|
-
"ERR_INVALID_ARG_TYPE",
|
|
53
|
-
/**
|
|
54
|
-
* @param {string} name
|
|
55
|
-
* @param {Array<string> | string} expected
|
|
56
|
-
* @param {unknown} actual
|
|
57
|
-
*/
|
|
58
|
-
(name, expected, actual) => {
|
|
59
|
-
assert.ok(typeof name === "string", "'name' must be a string");
|
|
60
|
-
if (!Array.isArray(expected)) expected = [expected];
|
|
61
|
-
let message = "The ";
|
|
62
|
-
if (name.endsWith(" argument")) message += `${name} `;
|
|
63
|
-
else {
|
|
64
|
-
const type = name.includes(".") ? "property" : "argument";
|
|
65
|
-
message += `"${name}" ${type} `;
|
|
66
|
-
}
|
|
67
|
-
message += "must be ";
|
|
68
|
-
/** @type {Array<string>} */
|
|
69
|
-
const types = [];
|
|
70
|
-
/** @type {Array<string>} */
|
|
71
|
-
const instances = [];
|
|
72
|
-
/** @type {Array<string>} */
|
|
73
|
-
const other = [];
|
|
74
|
-
for (const value of expected) {
|
|
75
|
-
assert.ok(typeof value === "string", "All expected entries have to be of type string");
|
|
76
|
-
if (kTypes.has(value)) types.push(value.toLowerCase());
|
|
77
|
-
else if (classRegExp.exec(value) === null) {
|
|
78
|
-
assert.ok(value !== "object", "The value \"object\" should be written as \"Object\"");
|
|
79
|
-
other.push(value);
|
|
80
|
-
} else instances.push(value);
|
|
81
|
-
}
|
|
82
|
-
if (instances.length > 0) {
|
|
83
|
-
const pos = types.indexOf("object");
|
|
84
|
-
if (pos !== -1) {
|
|
85
|
-
types.slice(pos, 1);
|
|
86
|
-
instances.push("Object");
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (types.length > 0) {
|
|
90
|
-
message += `${types.length > 1 ? "one of type" : "of type"} ${formatList(types, "or")}`;
|
|
91
|
-
if (instances.length > 0 || other.length > 0) message += " or ";
|
|
92
|
-
}
|
|
93
|
-
if (instances.length > 0) {
|
|
94
|
-
message += `an instance of ${formatList(instances, "or")}`;
|
|
95
|
-
if (other.length > 0) message += " or ";
|
|
96
|
-
}
|
|
97
|
-
if (other.length > 0) if (other.length > 1) message += `one of ${formatList(other, "or")}`;
|
|
98
|
-
else {
|
|
99
|
-
if (other[0].toLowerCase() !== other[0]) message += "an ";
|
|
100
|
-
message += `${other[0]}`;
|
|
101
|
-
}
|
|
102
|
-
message += `. Received ${determineSpecificType(actual)}`;
|
|
103
|
-
return message;
|
|
104
|
-
},
|
|
105
|
-
TypeError
|
|
106
|
-
);
|
|
107
|
-
codes.ERR_INVALID_MODULE_SPECIFIER = createError(
|
|
108
|
-
"ERR_INVALID_MODULE_SPECIFIER",
|
|
109
|
-
/**
|
|
110
|
-
* @param {string} request
|
|
111
|
-
* @param {string} reason
|
|
112
|
-
* @param {string} [base]
|
|
113
|
-
*/
|
|
114
|
-
(request, reason, base = void 0) => {
|
|
115
|
-
return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
|
|
116
|
-
},
|
|
117
|
-
TypeError
|
|
118
|
-
);
|
|
119
|
-
codes.ERR_INVALID_PACKAGE_CONFIG = createError(
|
|
120
|
-
"ERR_INVALID_PACKAGE_CONFIG",
|
|
121
|
-
/**
|
|
122
|
-
* @param {string} path
|
|
123
|
-
* @param {string} [base]
|
|
124
|
-
* @param {string} [message]
|
|
125
|
-
*/
|
|
126
|
-
(path, base, message) => {
|
|
127
|
-
return `Invalid package config ${path}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
|
|
128
|
-
},
|
|
129
|
-
Error
|
|
130
|
-
);
|
|
131
|
-
codes.ERR_INVALID_PACKAGE_TARGET = createError(
|
|
132
|
-
"ERR_INVALID_PACKAGE_TARGET",
|
|
133
|
-
/**
|
|
134
|
-
* @param {string} packagePath
|
|
135
|
-
* @param {string} key
|
|
136
|
-
* @param {unknown} target
|
|
137
|
-
* @param {boolean} [isImport=false]
|
|
138
|
-
* @param {string} [base]
|
|
139
|
-
*/
|
|
140
|
-
(packagePath, key, target, isImport = false, base = void 0) => {
|
|
141
|
-
const relatedError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
|
|
142
|
-
if (key === ".") {
|
|
143
|
-
assert.ok(isImport === false);
|
|
144
|
-
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 \"./\"" : ""}`;
|
|
145
|
-
}
|
|
146
|
-
return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(target)} defined for '${key}' in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? "; targets must start with \"./\"" : ""}`;
|
|
147
|
-
},
|
|
148
|
-
Error
|
|
149
|
-
);
|
|
150
|
-
codes.ERR_MODULE_NOT_FOUND = createError(
|
|
151
|
-
"ERR_MODULE_NOT_FOUND",
|
|
152
|
-
/**
|
|
153
|
-
* @param {string} path
|
|
154
|
-
* @param {string} base
|
|
155
|
-
* @param {boolean} [exactUrl]
|
|
156
|
-
*/
|
|
157
|
-
(path, base, exactUrl = false) => {
|
|
158
|
-
return `Cannot find ${exactUrl ? "module" : "package"} '${path}' imported from ${base}`;
|
|
159
|
-
},
|
|
160
|
-
Error
|
|
161
|
-
);
|
|
162
|
-
codes.ERR_NETWORK_IMPORT_DISALLOWED = createError("ERR_NETWORK_IMPORT_DISALLOWED", "import of '%s' by %s is not supported: %s", Error);
|
|
163
|
-
codes.ERR_PACKAGE_IMPORT_NOT_DEFINED = createError(
|
|
164
|
-
"ERR_PACKAGE_IMPORT_NOT_DEFINED",
|
|
165
|
-
/**
|
|
166
|
-
* @param {string} specifier
|
|
167
|
-
* @param {string} packagePath
|
|
168
|
-
* @param {string} base
|
|
169
|
-
*/
|
|
170
|
-
(specifier, packagePath, base) => {
|
|
171
|
-
return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath}package.json` : ""} imported from ${base}`;
|
|
172
|
-
},
|
|
173
|
-
TypeError
|
|
174
|
-
);
|
|
175
|
-
codes.ERR_PACKAGE_PATH_NOT_EXPORTED = createError(
|
|
176
|
-
"ERR_PACKAGE_PATH_NOT_EXPORTED",
|
|
177
|
-
/**
|
|
178
|
-
* @param {string} packagePath
|
|
179
|
-
* @param {string} subpath
|
|
180
|
-
* @param {string} [base]
|
|
181
|
-
*/
|
|
182
|
-
(packagePath, subpath, base = void 0) => {
|
|
183
|
-
if (subpath === ".") return `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
|
|
184
|
-
return `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
|
|
185
|
-
},
|
|
186
|
-
Error
|
|
187
|
-
);
|
|
188
|
-
codes.ERR_UNSUPPORTED_DIR_IMPORT = createError("ERR_UNSUPPORTED_DIR_IMPORT", "Directory import '%s' is not supported resolving ES modules imported from %s", Error);
|
|
189
|
-
codes.ERR_UNSUPPORTED_RESOLVE_REQUEST = createError("ERR_UNSUPPORTED_RESOLVE_REQUEST", "Failed to resolve module specifier \"%s\" from \"%s\": Invalid relative URL or base scheme is not hierarchical.", TypeError);
|
|
190
|
-
codes.ERR_UNKNOWN_FILE_EXTENSION = createError(
|
|
191
|
-
"ERR_UNKNOWN_FILE_EXTENSION",
|
|
192
|
-
/**
|
|
193
|
-
* @param {string} extension
|
|
194
|
-
* @param {string} path
|
|
195
|
-
*/
|
|
196
|
-
(extension, path) => {
|
|
197
|
-
return `Unknown file extension "${extension}" for ${path}`;
|
|
198
|
-
},
|
|
199
|
-
TypeError
|
|
200
|
-
);
|
|
201
|
-
codes.ERR_INVALID_ARG_VALUE = createError(
|
|
202
|
-
"ERR_INVALID_ARG_VALUE",
|
|
203
|
-
/**
|
|
204
|
-
* @param {string} name
|
|
205
|
-
* @param {unknown} value
|
|
206
|
-
* @param {string} [reason='is invalid']
|
|
207
|
-
*/
|
|
208
|
-
(name, value, reason = "is invalid") => {
|
|
209
|
-
let inspected = inspect(value);
|
|
210
|
-
if (inspected.length > 128) inspected = `${inspected.slice(0, 128)}...`;
|
|
211
|
-
return `The ${name.includes(".") ? "property" : "argument"} '${name}' ${reason}. Received ${inspected}`;
|
|
212
|
-
},
|
|
213
|
-
TypeError
|
|
214
|
-
);
|
|
215
|
-
/**
|
|
216
|
-
* Utility function for registering the error codes. Only used here. Exported
|
|
217
|
-
* *only* to allow for testing.
|
|
218
|
-
* @param {string} sym
|
|
219
|
-
* @param {MessageFunction | string} value
|
|
220
|
-
* @param {ErrorConstructor} constructor
|
|
221
|
-
* @returns {new (...parameters: Array<any>) => Error}
|
|
222
|
-
*/
|
|
223
|
-
function createError(sym, value, constructor) {
|
|
224
|
-
messages.set(sym, value);
|
|
225
|
-
return makeNodeErrorWithCode(constructor, sym);
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* @param {ErrorConstructor} Base
|
|
229
|
-
* @param {string} key
|
|
230
|
-
* @returns {ErrorConstructor}
|
|
231
|
-
*/
|
|
232
|
-
function makeNodeErrorWithCode(Base, key) {
|
|
233
|
-
return NodeError;
|
|
234
|
-
/**
|
|
235
|
-
* @param {Array<unknown>} parameters
|
|
236
|
-
*/
|
|
237
|
-
function NodeError(...parameters) {
|
|
238
|
-
const limit = Error.stackTraceLimit;
|
|
239
|
-
if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0;
|
|
240
|
-
const error = new Base();
|
|
241
|
-
if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit;
|
|
242
|
-
const message = getMessage(key, parameters, error);
|
|
243
|
-
Object.defineProperties(error, {
|
|
244
|
-
message: {
|
|
245
|
-
value: message,
|
|
246
|
-
enumerable: false,
|
|
247
|
-
writable: true,
|
|
248
|
-
configurable: true
|
|
249
|
-
},
|
|
250
|
-
toString: {
|
|
251
|
-
/** @this {Error} */
|
|
252
|
-
value() {
|
|
253
|
-
return `${this.name} [${key}]: ${this.message}`;
|
|
254
|
-
},
|
|
255
|
-
enumerable: false,
|
|
256
|
-
writable: true,
|
|
257
|
-
configurable: true
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
captureLargerStackTrace(error);
|
|
261
|
-
error.code = key;
|
|
262
|
-
return error;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* @returns {boolean}
|
|
267
|
-
*/
|
|
268
|
-
function isErrorStackTraceLimitWritable() {
|
|
269
|
-
try {
|
|
270
|
-
if (v8.startupSnapshot.isBuildingSnapshot()) return false;
|
|
271
|
-
} catch {}
|
|
272
|
-
const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
|
|
273
|
-
if (desc === void 0) return Object.isExtensible(Error);
|
|
274
|
-
return own.call(desc, "writable") && desc.writable !== void 0 ? desc.writable : desc.set !== void 0;
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* This function removes unnecessary frames from Node.js core errors.
|
|
278
|
-
* @template {(...parameters: unknown[]) => unknown} T
|
|
279
|
-
* @param {T} wrappedFunction
|
|
280
|
-
* @returns {T}
|
|
281
|
-
*/
|
|
282
|
-
function hideStackFrames(wrappedFunction) {
|
|
283
|
-
const hidden = nodeInternalPrefix + wrappedFunction.name;
|
|
284
|
-
Object.defineProperty(wrappedFunction, "name", { value: hidden });
|
|
285
|
-
return wrappedFunction;
|
|
286
|
-
}
|
|
287
|
-
var captureLargerStackTrace = hideStackFrames(
|
|
288
|
-
/**
|
|
289
|
-
* @param {Error} error
|
|
290
|
-
* @returns {Error}
|
|
291
|
-
*/
|
|
292
|
-
function(error) {
|
|
293
|
-
const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
|
|
294
|
-
if (stackTraceLimitIsWritable) {
|
|
295
|
-
userStackTraceLimit = Error.stackTraceLimit;
|
|
296
|
-
Error.stackTraceLimit = Number.POSITIVE_INFINITY;
|
|
297
|
-
}
|
|
298
|
-
Error.captureStackTrace(error);
|
|
299
|
-
if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit;
|
|
300
|
-
return error;
|
|
301
|
-
}
|
|
302
|
-
);
|
|
303
|
-
/**
|
|
304
|
-
* @param {string} key
|
|
305
|
-
* @param {Array<unknown>} parameters
|
|
306
|
-
* @param {Error} self
|
|
307
|
-
* @returns {string}
|
|
308
|
-
*/
|
|
309
|
-
function getMessage(key, parameters, self) {
|
|
310
|
-
const message = messages.get(key);
|
|
311
|
-
assert.ok(message !== void 0, "expected `message` to be found");
|
|
312
|
-
if (typeof message === "function") {
|
|
313
|
-
assert.ok(message.length <= parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${message.length}).`);
|
|
314
|
-
return Reflect.apply(message, self, parameters);
|
|
315
|
-
}
|
|
316
|
-
const regex = /%[dfijoOs]/g;
|
|
317
|
-
let expectedLength = 0;
|
|
318
|
-
while (regex.exec(message) !== null) expectedLength++;
|
|
319
|
-
assert.ok(expectedLength === parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${expectedLength}).`);
|
|
320
|
-
if (parameters.length === 0) return message;
|
|
321
|
-
parameters.unshift(message);
|
|
322
|
-
return Reflect.apply(format, null, parameters);
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Determine the specific type of a value for type-mismatch errors.
|
|
326
|
-
* @param {unknown} value
|
|
327
|
-
* @returns {string}
|
|
328
|
-
*/
|
|
329
|
-
function determineSpecificType(value) {
|
|
330
|
-
if (value === null || value === void 0) return String(value);
|
|
331
|
-
if (typeof value === "function" && value.name) return `function ${value.name}`;
|
|
332
|
-
if (typeof value === "object") {
|
|
333
|
-
if (value.constructor && value.constructor.name) return `an instance of ${value.constructor.name}`;
|
|
334
|
-
return `${inspect(value, { depth: -1 })}`;
|
|
335
|
-
}
|
|
336
|
-
let inspected = inspect(value, { colors: false });
|
|
337
|
-
if (inspected.length > 28) inspected = `${inspected.slice(0, 25)}...`;
|
|
338
|
-
return `type ${typeof value} (${inspected})`;
|
|
339
|
-
}
|
|
340
|
-
//#endregion
|
|
341
|
-
export { codes };
|
|
342
|
-
|
|
343
|
-
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","names":[],"sources":["../../../../../../../../../node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/errors.js"],"sourcesContent":["/**\n * @typedef ErrnoExceptionFields\n * @property {number | undefined} [errnode]\n * @property {string | undefined} [code]\n * @property {string | undefined} [path]\n * @property {string | undefined} [syscall]\n * @property {string | undefined} [url]\n *\n * @typedef {Error & ErrnoExceptionFields} ErrnoException\n */\n\n/**\n * @typedef {(...parameters: Array<any>) => string} MessageFunction\n */\n\n// Manually “tree shaken” from:\n// <https://github.com/nodejs/node/blob/45f5c9b/lib/internal/errors.js>\n// Last checked on: Apr 29, 2024.\nimport v8 from 'node:v8'\nimport assert from 'node:assert'\nimport {format, inspect} from 'node:util'\n\nconst own = {}.hasOwnProperty\n\nconst classRegExp = /^([A-Z][a-z\\d]*)+$/\n// Sorted by a rough estimate on most frequently used entries.\nconst kTypes = new Set([\n 'string',\n 'function',\n 'number',\n 'object',\n // Accept 'Function' and 'Object' as alternative to the lower cased version.\n 'Function',\n 'Object',\n 'boolean',\n 'bigint',\n 'symbol'\n])\n\nexport const codes = {}\n\n/**\n * Create a list string in the form like 'A and B' or 'A, B, ..., and Z'.\n * We cannot use Intl.ListFormat because it's not available in\n * --without-intl builds.\n *\n * @param {Array<string>} array\n * An array of strings.\n * @param {string} [type]\n * The list type to be inserted before the last element.\n * @returns {string}\n */\nfunction formatList(array, type = 'and') {\n return array.length < 3\n ? array.join(` ${type} `)\n : `${array.slice(0, -1).join(', ')}, ${type} ${array[array.length - 1]}`\n}\n\n/** @type {Map<string, MessageFunction | string>} */\nconst messages = new Map()\nconst nodeInternalPrefix = '__node_internal_'\n/** @type {number} */\nlet userStackTraceLimit\n\ncodes.ERR_INVALID_ARG_TYPE = createError(\n 'ERR_INVALID_ARG_TYPE',\n /**\n * @param {string} name\n * @param {Array<string> | string} expected\n * @param {unknown} actual\n */\n (name, expected, actual) => {\n assert.ok(typeof name === 'string', \"'name' must be a string\")\n if (!Array.isArray(expected)) {\n expected = [expected]\n }\n\n let message = 'The '\n if (name.endsWith(' argument')) {\n // For cases like 'first argument'\n message += `${name} `\n } else {\n const type = name.includes('.') ? 'property' : 'argument'\n message += `\"${name}\" ${type} `\n }\n\n message += 'must be '\n\n /** @type {Array<string>} */\n const types = []\n /** @type {Array<string>} */\n const instances = []\n /** @type {Array<string>} */\n const other = []\n\n for (const value of expected) {\n assert.ok(\n typeof value === 'string',\n 'All expected entries have to be of type string'\n )\n\n if (kTypes.has(value)) {\n types.push(value.toLowerCase())\n } else if (classRegExp.exec(value) === null) {\n assert.ok(\n value !== 'object',\n 'The value \"object\" should be written as \"Object\"'\n )\n other.push(value)\n } else {\n instances.push(value)\n }\n }\n\n // Special handle `object` in case other instances are allowed to outline\n // the differences between each other.\n if (instances.length > 0) {\n const pos = types.indexOf('object')\n if (pos !== -1) {\n types.slice(pos, 1)\n instances.push('Object')\n }\n }\n\n if (types.length > 0) {\n message += `${types.length > 1 ? 'one of type' : 'of type'} ${formatList(\n types,\n 'or'\n )}`\n if (instances.length > 0 || other.length > 0) message += ' or '\n }\n\n if (instances.length > 0) {\n message += `an instance of ${formatList(instances, 'or')}`\n if (other.length > 0) message += ' or '\n }\n\n if (other.length > 0) {\n if (other.length > 1) {\n message += `one of ${formatList(other, 'or')}`\n } else {\n if (other[0].toLowerCase() !== other[0]) message += 'an '\n message += `${other[0]}`\n }\n }\n\n message += `. Received ${determineSpecificType(actual)}`\n\n return message\n },\n TypeError\n)\n\ncodes.ERR_INVALID_MODULE_SPECIFIER = createError(\n 'ERR_INVALID_MODULE_SPECIFIER',\n /**\n * @param {string} request\n * @param {string} reason\n * @param {string} [base]\n */\n (request, reason, base = undefined) => {\n return `Invalid module \"${request}\" ${reason}${\n base ? ` imported from ${base}` : ''\n }`\n },\n TypeError\n)\n\ncodes.ERR_INVALID_PACKAGE_CONFIG = createError(\n 'ERR_INVALID_PACKAGE_CONFIG',\n /**\n * @param {string} path\n * @param {string} [base]\n * @param {string} [message]\n */\n (path, base, message) => {\n return `Invalid package config ${path}${\n base ? ` while importing ${base}` : ''\n }${message ? `. ${message}` : ''}`\n },\n Error\n)\n\ncodes.ERR_INVALID_PACKAGE_TARGET = createError(\n 'ERR_INVALID_PACKAGE_TARGET',\n /**\n * @param {string} packagePath\n * @param {string} key\n * @param {unknown} target\n * @param {boolean} [isImport=false]\n * @param {string} [base]\n */\n (packagePath, key, target, isImport = false, base = undefined) => {\n const relatedError =\n typeof target === 'string' &&\n !isImport &&\n target.length > 0 &&\n !target.startsWith('./')\n if (key === '.') {\n assert.ok(isImport === false)\n return (\n `Invalid \"exports\" main target ${JSON.stringify(target)} defined ` +\n `in the package config ${packagePath}package.json${\n base ? ` imported from ${base}` : ''\n }${relatedError ? '; targets must start with \"./\"' : ''}`\n )\n }\n\n return `Invalid \"${\n isImport ? 'imports' : 'exports'\n }\" target ${JSON.stringify(\n target\n )} defined for '${key}' in the package config ${packagePath}package.json${\n base ? ` imported from ${base}` : ''\n }${relatedError ? '; targets must start with \"./\"' : ''}`\n },\n Error\n)\n\ncodes.ERR_MODULE_NOT_FOUND = createError(\n 'ERR_MODULE_NOT_FOUND',\n /**\n * @param {string} path\n * @param {string} base\n * @param {boolean} [exactUrl]\n */\n (path, base, exactUrl = false) => {\n return `Cannot find ${\n exactUrl ? 'module' : 'package'\n } '${path}' imported from ${base}`\n },\n Error\n)\n\ncodes.ERR_NETWORK_IMPORT_DISALLOWED = createError(\n 'ERR_NETWORK_IMPORT_DISALLOWED',\n \"import of '%s' by %s is not supported: %s\",\n Error\n)\n\ncodes.ERR_PACKAGE_IMPORT_NOT_DEFINED = createError(\n 'ERR_PACKAGE_IMPORT_NOT_DEFINED',\n /**\n * @param {string} specifier\n * @param {string} packagePath\n * @param {string} base\n */\n (specifier, packagePath, base) => {\n return `Package import specifier \"${specifier}\" is not defined${\n packagePath ? ` in package ${packagePath}package.json` : ''\n } imported from ${base}`\n },\n TypeError\n)\n\ncodes.ERR_PACKAGE_PATH_NOT_EXPORTED = createError(\n 'ERR_PACKAGE_PATH_NOT_EXPORTED',\n /**\n * @param {string} packagePath\n * @param {string} subpath\n * @param {string} [base]\n */\n (packagePath, subpath, base = undefined) => {\n if (subpath === '.')\n return `No \"exports\" main defined in ${packagePath}package.json${\n base ? ` imported from ${base}` : ''\n }`\n return `Package subpath '${subpath}' is not defined by \"exports\" in ${packagePath}package.json${\n base ? ` imported from ${base}` : ''\n }`\n },\n Error\n)\n\ncodes.ERR_UNSUPPORTED_DIR_IMPORT = createError(\n 'ERR_UNSUPPORTED_DIR_IMPORT',\n \"Directory import '%s' is not supported \" +\n 'resolving ES modules imported from %s',\n Error\n)\n\ncodes.ERR_UNSUPPORTED_RESOLVE_REQUEST = createError(\n 'ERR_UNSUPPORTED_RESOLVE_REQUEST',\n 'Failed to resolve module specifier \"%s\" from \"%s\": Invalid relative URL or base scheme is not hierarchical.',\n TypeError\n)\n\ncodes.ERR_UNKNOWN_FILE_EXTENSION = createError(\n 'ERR_UNKNOWN_FILE_EXTENSION',\n /**\n * @param {string} extension\n * @param {string} path\n */\n (extension, path) => {\n return `Unknown file extension \"${extension}\" for ${path}`\n },\n TypeError\n)\n\ncodes.ERR_INVALID_ARG_VALUE = createError(\n 'ERR_INVALID_ARG_VALUE',\n /**\n * @param {string} name\n * @param {unknown} value\n * @param {string} [reason='is invalid']\n */\n (name, value, reason = 'is invalid') => {\n let inspected = inspect(value)\n\n if (inspected.length > 128) {\n inspected = `${inspected.slice(0, 128)}...`\n }\n\n const type = name.includes('.') ? 'property' : 'argument'\n\n return `The ${type} '${name}' ${reason}. Received ${inspected}`\n },\n TypeError\n // Note: extra classes have been shaken out.\n // , RangeError\n)\n\n/**\n * Utility function for registering the error codes. Only used here. Exported\n * *only* to allow for testing.\n * @param {string} sym\n * @param {MessageFunction | string} value\n * @param {ErrorConstructor} constructor\n * @returns {new (...parameters: Array<any>) => Error}\n */\nfunction createError(sym, value, constructor) {\n // Special case for SystemError that formats the error message differently\n // The SystemErrors only have SystemError as their base classes.\n messages.set(sym, value)\n\n return makeNodeErrorWithCode(constructor, sym)\n}\n\n/**\n * @param {ErrorConstructor} Base\n * @param {string} key\n * @returns {ErrorConstructor}\n */\nfunction makeNodeErrorWithCode(Base, key) {\n // @ts-expect-error It’s a Node error.\n return NodeError\n /**\n * @param {Array<unknown>} parameters\n */\n function NodeError(...parameters) {\n const limit = Error.stackTraceLimit\n if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0\n const error = new Base()\n // Reset the limit and setting the name property.\n if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit\n const message = getMessage(key, parameters, error)\n Object.defineProperties(error, {\n // Note: no need to implement `kIsNodeError` symbol, would be hard,\n // probably.\n message: {\n value: message,\n enumerable: false,\n writable: true,\n configurable: true\n },\n toString: {\n /** @this {Error} */\n value() {\n return `${this.name} [${key}]: ${this.message}`\n },\n enumerable: false,\n writable: true,\n configurable: true\n }\n })\n\n captureLargerStackTrace(error)\n // @ts-expect-error It’s a Node error.\n error.code = key\n return error\n }\n}\n\n/**\n * @returns {boolean}\n */\nfunction isErrorStackTraceLimitWritable() {\n // Do no touch Error.stackTraceLimit as V8 would attempt to install\n // it again during deserialization.\n try {\n if (v8.startupSnapshot.isBuildingSnapshot()) {\n return false\n }\n } catch {}\n\n const desc = Object.getOwnPropertyDescriptor(Error, 'stackTraceLimit')\n if (desc === undefined) {\n return Object.isExtensible(Error)\n }\n\n return own.call(desc, 'writable') && desc.writable !== undefined\n ? desc.writable\n : desc.set !== undefined\n}\n\n/**\n * This function removes unnecessary frames from Node.js core errors.\n * @template {(...parameters: unknown[]) => unknown} T\n * @param {T} wrappedFunction\n * @returns {T}\n */\nfunction hideStackFrames(wrappedFunction) {\n // We rename the functions that will be hidden to cut off the stacktrace\n // at the outermost one\n const hidden = nodeInternalPrefix + wrappedFunction.name\n Object.defineProperty(wrappedFunction, 'name', {value: hidden})\n return wrappedFunction\n}\n\nconst captureLargerStackTrace = hideStackFrames(\n /**\n * @param {Error} error\n * @returns {Error}\n */\n // @ts-expect-error: fine\n function (error) {\n const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable()\n if (stackTraceLimitIsWritable) {\n userStackTraceLimit = Error.stackTraceLimit\n Error.stackTraceLimit = Number.POSITIVE_INFINITY\n }\n\n Error.captureStackTrace(error)\n\n // Reset the limit\n if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit\n\n return error\n }\n)\n\n/**\n * @param {string} key\n * @param {Array<unknown>} parameters\n * @param {Error} self\n * @returns {string}\n */\nfunction getMessage(key, parameters, self) {\n const message = messages.get(key)\n assert.ok(message !== undefined, 'expected `message` to be found')\n\n if (typeof message === 'function') {\n assert.ok(\n message.length <= parameters.length, // Default options do not count.\n `Code: ${key}; The provided arguments length (${parameters.length}) does not ` +\n `match the required ones (${message.length}).`\n )\n return Reflect.apply(message, self, parameters)\n }\n\n const regex = /%[dfijoOs]/g\n let expectedLength = 0\n while (regex.exec(message) !== null) expectedLength++\n assert.ok(\n expectedLength === parameters.length,\n `Code: ${key}; The provided arguments length (${parameters.length}) does not ` +\n `match the required ones (${expectedLength}).`\n )\n if (parameters.length === 0) return message\n\n parameters.unshift(message)\n return Reflect.apply(format, null, parameters)\n}\n\n/**\n * Determine the specific type of a value for type-mismatch errors.\n * @param {unknown} value\n * @returns {string}\n */\nfunction determineSpecificType(value) {\n if (value === null || value === undefined) {\n return String(value)\n }\n\n if (typeof value === 'function' && value.name) {\n return `function ${value.name}`\n }\n\n if (typeof value === 'object') {\n if (value.constructor && value.constructor.name) {\n return `an instance of ${value.constructor.name}`\n }\n\n return `${inspect(value, {depth: -1})}`\n }\n\n let inspected = inspect(value, {colors: false})\n\n if (inspected.length > 28) {\n inspected = `${inspected.slice(0, 25)}...`\n }\n\n return `type ${typeof value} (${inspected})`\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;AAsBA,IAAM,MAAM,CAAC,EAAE;AAEf,IAAM,cAAc;AAEpB,IAAM,yBAAS,IAAI,IAAI;CACrB;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,IAAa,QAAQ,CAAC;;;;;;;;;;;;AAatB,SAAS,WAAW,OAAO,OAAO,OAAO;CACvC,OAAO,MAAM,SAAS,IAClB,MAAM,KAAK,IAAI,KAAK,EAAE,IACtB,GAAG,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE,IAAI,KAAK,GAAG,MAAM,MAAM,SAAS;AACxE;;AAGA,IAAM,2BAAW,IAAI,IAAI;AACzB,IAAM,qBAAqB;;AAE3B,IAAI;AAEJ,MAAM,uBAAuB;CAC3B;;;;;;EAMC,MAAM,UAAU,WAAW;EAC1B,OAAO,GAAG,OAAO,SAAS,UAAU,yBAAyB;EAC7D,IAAI,CAAC,MAAM,QAAQ,QAAQ,GACzB,WAAW,CAAC,QAAQ;EAGtB,IAAI,UAAU;EACd,IAAI,KAAK,SAAS,WAAW,GAE3B,WAAW,GAAG,KAAK;OACd;GACL,MAAM,OAAO,KAAK,SAAS,GAAG,IAAI,aAAa;GAC/C,WAAW,IAAI,KAAK,IAAI,KAAK;EAC/B;EAEA,WAAW;;EAGX,MAA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G3B,IAAI,OAAO,UAAU,UAAU;EAC7B,IAAI,MAAM,eAAe,MAAM,YAAY,MACzC,OAAO,kBAAkB,MAAM,YAAY;EAG7C,OAAO,GAAG,QAAQ,OAAO,EAAC,OAAO,GAAE,CAAC;CACtC;CAEA,IAAI,YAAY,QAAQ,OAAO,EAAC,QAAQ,MAAK,CAAC;CAE9C,IAAI,UAAU,SAAS,IACrB,YAAY,GAAG,UAAU,MAAM,GAAG,EAAE,EAAE;CAGxC,OAAO,QAAQ,OAAO,MAAM,IAAI,UAAU;AAC5C"}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { codes } from "./errors.js";
|
|
2
|
-
import { getPackageType } from "./package-json-reader.js";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
//#region ../../node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/get-format.js
|
|
5
|
-
var { ERR_UNKNOWN_FILE_EXTENSION } = codes;
|
|
6
|
-
var hasOwnProperty = {}.hasOwnProperty;
|
|
7
|
-
/** @type {Record<string, string>} */
|
|
8
|
-
var extensionFormatMap = {
|
|
9
|
-
__proto__: null,
|
|
10
|
-
".cjs": "commonjs",
|
|
11
|
-
".js": "module",
|
|
12
|
-
".json": "json",
|
|
13
|
-
".mjs": "module"
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* @param {string | null} mime
|
|
17
|
-
* @returns {string | null}
|
|
18
|
-
*/
|
|
19
|
-
function mimeToFormat(mime) {
|
|
20
|
-
if (mime && /\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(mime)) return "module";
|
|
21
|
-
if (mime === "application/json") return "json";
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* @callback ProtocolHandler
|
|
26
|
-
* @param {URL} parsed
|
|
27
|
-
* @param {{parentURL: string, source?: Buffer}} context
|
|
28
|
-
* @param {boolean} ignoreErrors
|
|
29
|
-
* @returns {string | null | void}
|
|
30
|
-
*/
|
|
31
|
-
/**
|
|
32
|
-
* @type {Record<string, ProtocolHandler>}
|
|
33
|
-
*/
|
|
34
|
-
var protocolHandlers = {
|
|
35
|
-
__proto__: null,
|
|
36
|
-
"data:": getDataProtocolModuleFormat,
|
|
37
|
-
"file:": getFileProtocolModuleFormat,
|
|
38
|
-
"http:": getHttpProtocolModuleFormat,
|
|
39
|
-
"https:": getHttpProtocolModuleFormat,
|
|
40
|
-
"node:"() {
|
|
41
|
-
return "builtin";
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* @param {URL} parsed
|
|
46
|
-
*/
|
|
47
|
-
function getDataProtocolModuleFormat(parsed) {
|
|
48
|
-
const { 1: mime } = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(parsed.pathname) || [
|
|
49
|
-
null,
|
|
50
|
-
null,
|
|
51
|
-
null
|
|
52
|
-
];
|
|
53
|
-
return mimeToFormat(mime);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Returns the file extension from a URL.
|
|
57
|
-
*
|
|
58
|
-
* Should give similar result to
|
|
59
|
-
* `require('node:path').extname(require('node:url').fileURLToPath(url))`
|
|
60
|
-
* when used with a `file:` URL.
|
|
61
|
-
*
|
|
62
|
-
* @param {URL} url
|
|
63
|
-
* @returns {string}
|
|
64
|
-
*/
|
|
65
|
-
function extname(url) {
|
|
66
|
-
const pathname = url.pathname;
|
|
67
|
-
let index = pathname.length;
|
|
68
|
-
while (index--) {
|
|
69
|
-
const code = pathname.codePointAt(index);
|
|
70
|
-
if (code === 47) return "";
|
|
71
|
-
if (code === 46) return pathname.codePointAt(index - 1) === 47 ? "" : pathname.slice(index);
|
|
72
|
-
}
|
|
73
|
-
return "";
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* @type {ProtocolHandler}
|
|
77
|
-
*/
|
|
78
|
-
function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
|
|
79
|
-
const value = extname(url);
|
|
80
|
-
if (value === ".js") {
|
|
81
|
-
const packageType = getPackageType(url);
|
|
82
|
-
if (packageType !== "none") return packageType;
|
|
83
|
-
return "commonjs";
|
|
84
|
-
}
|
|
85
|
-
if (value === "") {
|
|
86
|
-
const packageType = getPackageType(url);
|
|
87
|
-
if (packageType === "none" || packageType === "commonjs") return "commonjs";
|
|
88
|
-
return "module";
|
|
89
|
-
}
|
|
90
|
-
const format = extensionFormatMap[value];
|
|
91
|
-
if (format) return format;
|
|
92
|
-
if (ignoreErrors) return;
|
|
93
|
-
throw new ERR_UNKNOWN_FILE_EXTENSION(value, fileURLToPath(url));
|
|
94
|
-
}
|
|
95
|
-
function getHttpProtocolModuleFormat() {}
|
|
96
|
-
/**
|
|
97
|
-
* @param {URL} url
|
|
98
|
-
* @param {{parentURL: string}} context
|
|
99
|
-
* @returns {string | null}
|
|
100
|
-
*/
|
|
101
|
-
function defaultGetFormatWithoutErrors(url, context) {
|
|
102
|
-
const protocol = url.protocol;
|
|
103
|
-
if (!hasOwnProperty.call(protocolHandlers, protocol)) return null;
|
|
104
|
-
return protocolHandlers[protocol](url, context, true) || null;
|
|
105
|
-
}
|
|
106
|
-
//#endregion
|
|
107
|
-
export { defaultGetFormatWithoutErrors };
|
|
108
|
-
|
|
109
|
-
//# sourceMappingURL=get-format.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-format.js","names":[],"sources":["../../../../../../../../../node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/get-format.js"],"sourcesContent":["// Manually “tree shaken” from:\n// <https://github.com/nodejs/node/blob/7c3dce0/lib/internal/modules/esm/get_format.js>\n// Last checked on: Apr 29, 2024.\n\nimport {fileURLToPath} from 'node:url'\nimport {getPackageType} from './package-json-reader.js'\nimport {codes} from './errors.js'\n\nconst {ERR_UNKNOWN_FILE_EXTENSION} = codes\n\nconst hasOwnProperty = {}.hasOwnProperty\n\n/** @type {Record<string, string>} */\nconst extensionFormatMap = {\n // @ts-expect-error: hush.\n __proto__: null,\n '.cjs': 'commonjs',\n '.js': 'module',\n '.json': 'json',\n '.mjs': 'module'\n}\n\n/**\n * @param {string | null} mime\n * @returns {string | null}\n */\nfunction mimeToFormat(mime) {\n if (\n mime &&\n /\\s*(text|application)\\/javascript\\s*(;\\s*charset=utf-?8\\s*)?/i.test(mime)\n )\n return 'module'\n if (mime === 'application/json') return 'json'\n return null\n}\n\n/**\n * @callback ProtocolHandler\n * @param {URL} parsed\n * @param {{parentURL: string, source?: Buffer}} context\n * @param {boolean} ignoreErrors\n * @returns {string | null | void}\n */\n\n/**\n * @type {Record<string, ProtocolHandler>}\n */\nconst protocolHandlers = {\n // @ts-expect-error: hush.\n __proto__: null,\n 'data:': getDataProtocolModuleFormat,\n 'file:': getFileProtocolModuleFormat,\n 'http:': getHttpProtocolModuleFormat,\n 'https:': getHttpProtocolModuleFormat,\n 'node:'() {\n return 'builtin'\n }\n}\n\n/**\n * @param {URL} parsed\n */\nfunction getDataProtocolModuleFormat(parsed) {\n const {1: mime} = /^([^/]+\\/[^;,]+)[^,]*?(;base64)?,/.exec(\n parsed.pathname\n ) || [null, null, null]\n return mimeToFormat(mime)\n}\n\n/**\n * Returns the file extension from a URL.\n *\n * Should give similar result to\n * `require('node:path').extname(require('node:url').fileURLToPath(url))`\n * when used with a `file:` URL.\n *\n * @param {URL} url\n * @returns {string}\n */\nfunction extname(url) {\n const pathname = url.pathname\n let index = pathname.length\n\n while (index--) {\n const code = pathname.codePointAt(index)\n\n if (code === 47 /* `/` */) {\n return ''\n }\n\n if (code === 46 /* `.` */) {\n return pathname.codePointAt(index - 1) === 47 /* `/` */\n ? ''\n : pathname.slice(index)\n }\n }\n\n return ''\n}\n\n/**\n * @type {ProtocolHandler}\n */\nfunction getFileProtocolModuleFormat(url, _context, ignoreErrors) {\n const value = extname(url)\n\n if (value === '.js') {\n const packageType = getPackageType(url)\n\n if (packageType !== 'none') {\n return packageType\n }\n\n return 'commonjs'\n }\n\n if (value === '') {\n const packageType = getPackageType(url)\n\n // Legacy behavior\n if (packageType === 'none' || packageType === 'commonjs') {\n return 'commonjs'\n }\n\n // Note: we don’t implement WASM, so we don’t need\n // `getFormatOfExtensionlessFile` from `formats`.\n return 'module'\n }\n\n const format = extensionFormatMap[value]\n if (format) return format\n\n // Explicit undefined return indicates load hook should rerun format check\n if (ignoreErrors) {\n return undefined\n }\n\n const filepath = fileURLToPath(url)\n throw new ERR_UNKNOWN_FILE_EXTENSION(value, filepath)\n}\n\nfunction getHttpProtocolModuleFormat() {\n // To do: HTTPS imports.\n}\n\n/**\n * @param {URL} url\n * @param {{parentURL: string}} context\n * @returns {string | null}\n */\nexport function defaultGetFormatWithoutErrors(url, context) {\n const protocol = url.protocol\n\n if (!hasOwnProperty.call(protocolHandlers, protocol)) {\n return null\n }\n\n return protocolHandlers[protocol](url, context, true) || null\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;AAQA,IAAM,EAAC,+BAA8B;AAErC,IAAM,iBAAiB,CAAC,EAAE;;AAG1B,IAAM,qBAAqB;CAEzB,WAAW;CACX,QAAQ;CACR,OAAO;CACP,SAAS;CACT,QAAQ;AACV;;;;;AAMA,SAAS,aAAa,MAAM;CAC1B,IACE,QACA,gEAAgE,KAAK,IAAI,GAEzE,OAAO;CACT,IAAI,SAAS,oBAAoB,OAAO;CACxC,OAAO;AACT;;;;;;;;;;;AAaA,IAAM,mBAAmB;CAEvB,WAAW;CACX,SAAS;CACT,SAAS;CACT,SAAS;CACT,UAAU;CACV,UAAU;EACR,OAAO;CACT;AACF;;;;AAKA,SAAS,4BAA4B,QAAQ;CAC3C,MAAM,EAAC,GAAG,SAAQ,oCAAoC,KACpD,OAAO,QACT,KAAK;EAAC;EAAM;EAAM;CAAI;CACtB,OAAO,aAAa,IAAI;AAC1B;;;;;;;;;;;AAYA,SAAS,QAAQ,KAAK;CACpB,MAAM,WAAW,IAAI;CACrB,IAAI,QAAQ,SAAS;CAErB,OAAO,SAAS;EACd,MAAM,OAAO,SAAS,YAAY,KAAK;EAEvC,IAAI,SAAS,IACX,OAAO;EAGT,IAAI,SAAS,IACX,OAAO,SAAS,YAAY,QAAQ,CAAC,MAAM,KACvC,KACA,SAAS,MAAM,KAAK;CAE5B;CAEA,OAAO;AACT;;;;AAKA,SAAS,4BAA4B,KAAK,UAAU,cAAc;CAChE,MAAM,QAAQ,QAAQ,GAAG;CAEzB,IAAI,UAAU,OAAO;EACnB,MAAM,cAAc,eAAe,GAAG;EAEtC,IAAI,gBAAgB,QAClB,OAAO;EAGT,OAAO;CACT;CAEA,IAAI,UAAU,IAAI;EAChB,MAAM,cAAc,eAAe,GAAG;EAGtC,IAAI,gBAAgB,UAAU,gBAAgB,YAC5C,OAAO;EAKT,OAAO;CACT;CAEA,MAAM,SAAS,mBAAmB;CAClC,IAAI,QAAQ,OAAO;CAGnB,IAAI,cACF;CAIF,MAAM,IAAI,2BAA2B,OADpB,cAAc,GACa,CAAQ;AACtD;AAEA,SAAS,8BAA8B,CAEvC;;;;;;AAOA,SAAgB,8BAA8B,KAAK,SAAS;CAC1D,MAAM,WAAW,IAAI;CAErB,IAAI,CAAC,eAAe,KAAK,kBAAkB,QAAQ,GACjD,OAAO;CAGT,OAAO,iBAAiB,SAAS,CAAC,KAAK,SAAS,IAAI,KAAK;AAC3D"}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { codes } from "./errors.js";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
import fs from "node:fs";
|
|
5
|
-
//#region ../../node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/package-json-reader.js
|
|
6
|
-
/**
|
|
7
|
-
* @import {ErrnoException} from './errors.js'
|
|
8
|
-
*
|
|
9
|
-
* @typedef {'commonjs' | 'module' | 'none'} PackageType
|
|
10
|
-
*
|
|
11
|
-
* @typedef PackageConfig
|
|
12
|
-
* @property {string} pjsonPath
|
|
13
|
-
* @property {boolean} exists
|
|
14
|
-
* @property {string | undefined} [main]
|
|
15
|
-
* @property {string | undefined} [name]
|
|
16
|
-
* @property {PackageType} type
|
|
17
|
-
* @property {Record<string, unknown> | undefined} [exports]
|
|
18
|
-
* @property {Record<string, unknown> | undefined} [imports]
|
|
19
|
-
*/
|
|
20
|
-
var hasOwnProperty = {}.hasOwnProperty;
|
|
21
|
-
var { ERR_INVALID_PACKAGE_CONFIG } = codes;
|
|
22
|
-
/** @type {Map<string, PackageConfig>} */
|
|
23
|
-
var cache = /* @__PURE__ */ new Map();
|
|
24
|
-
/**
|
|
25
|
-
* @param {string} jsonPath
|
|
26
|
-
* @param {{specifier: URL | string, base?: URL}} options
|
|
27
|
-
* @returns {PackageConfig}
|
|
28
|
-
*/
|
|
29
|
-
function read(jsonPath, { base, specifier }) {
|
|
30
|
-
const existing = cache.get(jsonPath);
|
|
31
|
-
if (existing) return existing;
|
|
32
|
-
/** @type {string | undefined} */
|
|
33
|
-
let string;
|
|
34
|
-
try {
|
|
35
|
-
string = fs.readFileSync(path.toNamespacedPath(jsonPath), "utf8");
|
|
36
|
-
} catch (error) {
|
|
37
|
-
const exception = error;
|
|
38
|
-
if (exception.code !== "ENOENT") throw exception;
|
|
39
|
-
}
|
|
40
|
-
/** @type {PackageConfig} */
|
|
41
|
-
const result = {
|
|
42
|
-
exists: false,
|
|
43
|
-
pjsonPath: jsonPath,
|
|
44
|
-
main: void 0,
|
|
45
|
-
name: void 0,
|
|
46
|
-
type: "none",
|
|
47
|
-
exports: void 0,
|
|
48
|
-
imports: void 0
|
|
49
|
-
};
|
|
50
|
-
if (string !== void 0) {
|
|
51
|
-
/** @type {Record<string, unknown>} */
|
|
52
|
-
let parsed;
|
|
53
|
-
try {
|
|
54
|
-
parsed = JSON.parse(string);
|
|
55
|
-
} catch (error_) {
|
|
56
|
-
const cause = error_;
|
|
57
|
-
const error = new ERR_INVALID_PACKAGE_CONFIG(jsonPath, (base ? `"${specifier}" from ` : "") + fileURLToPath(base || specifier), cause.message);
|
|
58
|
-
error.cause = cause;
|
|
59
|
-
throw error;
|
|
60
|
-
}
|
|
61
|
-
result.exists = true;
|
|
62
|
-
if (hasOwnProperty.call(parsed, "name") && typeof parsed.name === "string") result.name = parsed.name;
|
|
63
|
-
if (hasOwnProperty.call(parsed, "main") && typeof parsed.main === "string") result.main = parsed.main;
|
|
64
|
-
if (hasOwnProperty.call(parsed, "exports")) result.exports = parsed.exports;
|
|
65
|
-
if (hasOwnProperty.call(parsed, "imports")) result.imports = parsed.imports;
|
|
66
|
-
if (hasOwnProperty.call(parsed, "type") && (parsed.type === "commonjs" || parsed.type === "module")) result.type = parsed.type;
|
|
67
|
-
}
|
|
68
|
-
cache.set(jsonPath, result);
|
|
69
|
-
return result;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* @param {URL | string} resolved
|
|
73
|
-
* @returns {PackageConfig}
|
|
74
|
-
*/
|
|
75
|
-
function getPackageScopeConfig(resolved) {
|
|
76
|
-
let packageJSONUrl = new URL("package.json", resolved);
|
|
77
|
-
while (true) {
|
|
78
|
-
if (packageJSONUrl.pathname.endsWith("node_modules/package.json")) break;
|
|
79
|
-
const packageConfig = read(fileURLToPath(packageJSONUrl), { specifier: resolved });
|
|
80
|
-
if (packageConfig.exists) return packageConfig;
|
|
81
|
-
const lastPackageJSONUrl = packageJSONUrl;
|
|
82
|
-
packageJSONUrl = new URL("../package.json", packageJSONUrl);
|
|
83
|
-
if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) break;
|
|
84
|
-
}
|
|
85
|
-
return {
|
|
86
|
-
pjsonPath: fileURLToPath(packageJSONUrl),
|
|
87
|
-
exists: false,
|
|
88
|
-
type: "none"
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Returns the package type for a given URL.
|
|
93
|
-
* @param {URL} url - The URL to get the package type for.
|
|
94
|
-
* @returns {PackageType}
|
|
95
|
-
*/
|
|
96
|
-
function getPackageType(url) {
|
|
97
|
-
return getPackageScopeConfig(url).type;
|
|
98
|
-
}
|
|
99
|
-
//#endregion
|
|
100
|
-
export { getPackageScopeConfig, getPackageType, read };
|
|
101
|
-
|
|
102
|
-
//# sourceMappingURL=package-json-reader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package-json-reader.js","names":[],"sources":["../../../../../../../../../node_modules/.pnpm/import-meta-resolve@4.2.0/node_modules/import-meta-resolve/lib/package-json-reader.js"],"sourcesContent":["// Manually “tree shaken” from:\n// <https://github.com/nodejs/node/blob/7c3dce0/lib/internal/modules/package_json_reader.js>\n// Last checked on: Apr 29, 2024.\n// Removed the native dependency.\n// Also: no need to cache, we do that in resolve already.\n\n/**\n * @import {ErrnoException} from './errors.js'\n *\n * @typedef {'commonjs' | 'module' | 'none'} PackageType\n *\n * @typedef PackageConfig\n * @property {string} pjsonPath\n * @property {boolean} exists\n * @property {string | undefined} [main]\n * @property {string | undefined} [name]\n * @property {PackageType} type\n * @property {Record<string, unknown> | undefined} [exports]\n * @property {Record<string, unknown> | undefined} [imports]\n */\n\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport {fileURLToPath} from 'node:url'\nimport {codes} from './errors.js'\n\nconst hasOwnProperty = {}.hasOwnProperty\n\nconst {ERR_INVALID_PACKAGE_CONFIG} = codes\n\n/** @type {Map<string, PackageConfig>} */\nconst cache = new Map()\n\n/**\n * @param {string} jsonPath\n * @param {{specifier: URL | string, base?: URL}} options\n * @returns {PackageConfig}\n */\nexport function read(jsonPath, {base, specifier}) {\n const existing = cache.get(jsonPath)\n\n if (existing) {\n return existing\n }\n\n /** @type {string | undefined} */\n let string\n\n try {\n string = fs.readFileSync(path.toNamespacedPath(jsonPath), 'utf8')\n } catch (error) {\n const exception = /** @type {ErrnoException} */ (error)\n\n if (exception.code !== 'ENOENT') {\n throw exception\n }\n }\n\n /** @type {PackageConfig} */\n const result = {\n exists: false,\n pjsonPath: jsonPath,\n main: undefined,\n name: undefined,\n type: 'none', // Ignore unknown types for forwards compatibility\n exports: undefined,\n imports: undefined\n }\n\n if (string !== undefined) {\n /** @type {Record<string, unknown>} */\n let parsed\n\n try {\n parsed = JSON.parse(string)\n } catch (error_) {\n const cause = /** @type {ErrnoException} */ (error_)\n const error = new ERR_INVALID_PACKAGE_CONFIG(\n jsonPath,\n (base ? `\"${specifier}\" from ` : '') + fileURLToPath(base || specifier),\n cause.message\n )\n error.cause = cause\n throw error\n }\n\n result.exists = true\n\n if (\n hasOwnProperty.call(parsed, 'name') &&\n typeof parsed.name === 'string'\n ) {\n result.name = parsed.name\n }\n\n if (\n hasOwnProperty.call(parsed, 'main') &&\n typeof parsed.main === 'string'\n ) {\n result.main = parsed.main\n }\n\n if (hasOwnProperty.call(parsed, 'exports')) {\n // @ts-expect-error: assume valid.\n result.exports = parsed.exports\n }\n\n if (hasOwnProperty.call(parsed, 'imports')) {\n // @ts-expect-error: assume valid.\n result.imports = parsed.imports\n }\n\n // Ignore unknown types for forwards compatibility\n if (\n hasOwnProperty.call(parsed, 'type') &&\n (parsed.type === 'commonjs' || parsed.type === 'module')\n ) {\n result.type = parsed.type\n }\n }\n\n cache.set(jsonPath, result)\n\n return result\n}\n\n/**\n * @param {URL | string} resolved\n * @returns {PackageConfig}\n */\nexport function getPackageScopeConfig(resolved) {\n // Note: in Node, this is now a native module.\n let packageJSONUrl = new URL('package.json', resolved)\n\n while (true) {\n const packageJSONPath = packageJSONUrl.pathname\n if (packageJSONPath.endsWith('node_modules/package.json')) {\n break\n }\n\n const packageConfig = read(fileURLToPath(packageJSONUrl), {\n specifier: resolved\n })\n\n if (packageConfig.exists) {\n return packageConfig\n }\n\n const lastPackageJSONUrl = packageJSONUrl\n packageJSONUrl = new URL('../package.json', packageJSONUrl)\n\n // Terminates at root where ../package.json equals ../../package.json\n // (can't just check \"/package.json\" for Windows support).\n if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) {\n break\n }\n }\n\n const packageJSONPath = fileURLToPath(packageJSONUrl)\n // ^^ Note: in Node, this is now a native module.\n\n return {\n pjsonPath: packageJSONPath,\n exists: false,\n type: 'none'\n }\n}\n\n/**\n * Returns the package type for a given URL.\n * @param {URL} url - The URL to get the package type for.\n * @returns {PackageType}\n */\nexport function getPackageType(url) {\n // To do @anonrig: Write a C++ function that returns only \"type\".\n return getPackageScopeConfig(url).type\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;;AA0BA,IAAM,iBAAiB,CAAC,EAAE;AAE1B,IAAM,EAAC,+BAA8B;;AAGrC,IAAM,wBAAQ,IAAI,IAAI;;;;;;AAOtB,SAAgB,KAAK,UAAU,EAAC,MAAM,aAAY;CAChD,MAAM,WAAW,MAAM,IAAI,QAAQ;CAEnC,IAAI,UACF,OAAO;;CAIT,IAAI;CAEJ,IAAI;EACF,SAAS,GAAG,aAAa,KAAK,iBAAiB,QAAQ,GAAG,MAAM;CAClE,SAAS,OAAO;EACd,MAAM,YAA2C;EAEjD,IAAI,UAAU,SAAS,UACrB,MAAM;CAEV;;CAGA,MAAM,SAAS;EACb,QAAQ;EACR,WAAW;EACX,MAAM,KAAA;EACN,MAAM,KAAA;EACN,MAAM;EACN,SAAS,KAAA;EACT,SAAS,KAAA;CACX;CAEA,IAAI,WAAW,KAAA,GAAW;;EAExB,IAAI;EAEJ,IAAI;GACF,SAAS,KAAK,MAAM,MAAM;EAC5B,SAAS,QAAQ;GACf,MAAM,QAAuC;GAC7C,MAAM,QAAQ,IAAI,2BAChB,WACC,OAAO,IAAI,UAAU,WAAW,MAAM,cAAc,QAAQ,SAAS,GACtE,MAAM,OACR;GACA,MAAM,QAAQ;GACd,MAAM;EACR;EAEA,OAAO,SAAS;EAEhB,IACE,eAAe,KAAK,QAAQ,MAAM,KAClC,OAAO,OAAO,SAAS,UAEvB,OAAO,OAAO,OAAO;EAGvB,IACE,eAAe,KAAK,QAAQ,MAAM,KAClC,OAAO,OAAO,SAAS,UAEvB,OAAO,OAAO,OAAO;EAGvB,IAAI,eAA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