@stryke/capnp 0.10.0 → 0.10.2
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/bin/capnpc.cjs +62 -30
- package/bin/capnpc.js +62 -30
- package/dist/chunk-3IOIINHW.js +895 -0
- package/dist/chunk-3ZOLKZQQ.cjs +895 -0
- package/dist/chunk-55455L4M.cjs +4103 -0
- package/dist/chunk-5VHN3KGS.js +3305 -0
- package/dist/chunk-CCU32X36.js +15 -0
- package/dist/chunk-GWW6WBAL.js +4103 -0
- package/dist/chunk-IBMXNAOT.cjs +4877 -0
- package/dist/chunk-KXWOF6H4.cjs +3305 -0
- package/dist/chunk-N2KNXTXN.js +4877 -0
- package/dist/chunk-R2JXWA7Q.cjs +15 -0
- package/dist/compile.cjs +7 -72
- package/dist/compile.d.cts +3 -3
- package/dist/compile.d.ts +3 -3
- package/dist/compile.js +6 -71
- package/dist/helpers.cjs +4 -49
- package/dist/helpers.d.cts +2 -2
- package/dist/helpers.d.ts +2 -2
- package/dist/helpers.js +3 -48
- package/dist/index.cjs +138 -4
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +138 -4
- package/dist/rpc.cjs +6 -117
- package/dist/rpc.js +5 -116
- package/dist/types.cjs +3 -8
- package/dist/types.d.cts +13 -4
- package/dist/types.d.ts +13 -4
- package/dist/types.js +3 -8
- package/dts/index.d.cts +14 -5
- package/dts/index.d.ts +14 -5
- package/package.json +4 -4
- package/schemas/persistent.cjs +20 -20
- package/schemas/persistent.js +1 -1
- package/schemas/rpc-twoparty.cjs +32 -32
- package/schemas/rpc-twoparty.js +1 -1
- package/schemas/rpc.cjs +495 -495
- package/schemas/rpc.js +1 -1
- package/schemas/schema.cjs +675 -675
- package/schemas/schema.js +1 -1
- /package/schemas/{chunk-ZGPCLBI4.cjs → chunk-BM2HWFSD.cjs} +0 -0
- /package/schemas/{chunk-3CJYH45H.js → chunk-TAKPBFYZ.js} +0 -0
|
@@ -0,0 +1,895 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkUSNT2KNTcjs = require('./chunk-USNT2KNT.cjs');
|
|
4
|
+
|
|
5
|
+
// src/helpers.ts
|
|
6
|
+
var _console = require('@storm-software/config-tools/logger/console');
|
|
7
|
+
|
|
8
|
+
// ../convert/src/to-array.ts
|
|
9
|
+
function toArray(array) {
|
|
10
|
+
array = _nullishCoalesce(array, () => ( []));
|
|
11
|
+
return Array.isArray(array) ? array : [
|
|
12
|
+
array
|
|
13
|
+
];
|
|
14
|
+
}
|
|
15
|
+
_chunkUSNT2KNTcjs.__name.call(void 0, toArray, "toArray");
|
|
16
|
+
|
|
17
|
+
// ../type-checks/src/get-object-tag.ts
|
|
18
|
+
var getObjectTag = /* @__PURE__ */ _chunkUSNT2KNTcjs.__name.call(void 0, (value) => {
|
|
19
|
+
if (value == null) {
|
|
20
|
+
return value === void 0 ? "[object Undefined]" : "[object Null]";
|
|
21
|
+
}
|
|
22
|
+
return Object.prototype.toString.call(value);
|
|
23
|
+
}, "getObjectTag");
|
|
24
|
+
|
|
25
|
+
// ../type-checks/src/is-plain-object.ts
|
|
26
|
+
var isObjectLike = /* @__PURE__ */ _chunkUSNT2KNTcjs.__name.call(void 0, (obj) => {
|
|
27
|
+
return typeof obj === "object" && obj !== null;
|
|
28
|
+
}, "isObjectLike");
|
|
29
|
+
var isPlainObject = /* @__PURE__ */ _chunkUSNT2KNTcjs.__name.call(void 0, (obj) => {
|
|
30
|
+
if (!isObjectLike(obj) || getObjectTag(obj) !== "[object Object]") {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
if (Object.getPrototypeOf(obj) === null) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
let proto = obj;
|
|
37
|
+
while (Object.getPrototypeOf(proto) !== null) {
|
|
38
|
+
proto = Object.getPrototypeOf(proto);
|
|
39
|
+
}
|
|
40
|
+
return Object.getPrototypeOf(obj) === proto;
|
|
41
|
+
}, "isPlainObject");
|
|
42
|
+
|
|
43
|
+
// ../type-checks/src/is-object.ts
|
|
44
|
+
var isObject = /* @__PURE__ */ _chunkUSNT2KNTcjs.__name.call(void 0, (value) => {
|
|
45
|
+
try {
|
|
46
|
+
return typeof value === "object" || Boolean(value) && _optionalChain([value, 'optionalAccess', _ => _.constructor]) === Object || isPlainObject(value);
|
|
47
|
+
} catch (e) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}, "isObject");
|
|
51
|
+
|
|
52
|
+
// ../type-checks/src/is-string.ts
|
|
53
|
+
var isString = /* @__PURE__ */ _chunkUSNT2KNTcjs.__name.call(void 0, (value) => {
|
|
54
|
+
try {
|
|
55
|
+
return typeof value === "string";
|
|
56
|
+
} catch (e2) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}, "isString");
|
|
60
|
+
|
|
61
|
+
// ../json/src/storm-json.ts
|
|
62
|
+
var _jsoncparser = require('jsonc-parser');
|
|
63
|
+
var _buffer = require('buffer');
|
|
64
|
+
var _superjson = require('superjson'); var _superjson2 = _interopRequireDefault(_superjson);
|
|
65
|
+
|
|
66
|
+
// ../types/src/base.ts
|
|
67
|
+
var EMPTY_STRING = "";
|
|
68
|
+
var $NestedValue = Symbol("NestedValue");
|
|
69
|
+
|
|
70
|
+
// ../json/src/utils/strip-comments.ts
|
|
71
|
+
var singleComment = Symbol("singleComment");
|
|
72
|
+
var multiComment = Symbol("multiComment");
|
|
73
|
+
function stripWithoutWhitespace() {
|
|
74
|
+
return "";
|
|
75
|
+
}
|
|
76
|
+
_chunkUSNT2KNTcjs.__name.call(void 0, stripWithoutWhitespace, "stripWithoutWhitespace");
|
|
77
|
+
function stripWithWhitespace(value, start, end) {
|
|
78
|
+
return value.slice(start, end).replace(/\S/g, " ");
|
|
79
|
+
}
|
|
80
|
+
_chunkUSNT2KNTcjs.__name.call(void 0, stripWithWhitespace, "stripWithWhitespace");
|
|
81
|
+
function isEscaped(value, quotePosition) {
|
|
82
|
+
let index = quotePosition - 1;
|
|
83
|
+
let backslashCount = 0;
|
|
84
|
+
while (value[index] === "\\") {
|
|
85
|
+
index -= 1;
|
|
86
|
+
backslashCount += 1;
|
|
87
|
+
}
|
|
88
|
+
return Boolean(backslashCount % 2);
|
|
89
|
+
}
|
|
90
|
+
_chunkUSNT2KNTcjs.__name.call(void 0, isEscaped, "isEscaped");
|
|
91
|
+
function stripComments(value, { whitespace = true, trailingCommas = false } = {}) {
|
|
92
|
+
if (typeof value !== "string") {
|
|
93
|
+
throw new TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof value}\``);
|
|
94
|
+
}
|
|
95
|
+
const strip = whitespace ? stripWithWhitespace : stripWithoutWhitespace;
|
|
96
|
+
let isInsideString = false;
|
|
97
|
+
let isInsideComment = false;
|
|
98
|
+
let offset = 0;
|
|
99
|
+
let buffer = "";
|
|
100
|
+
let result = "";
|
|
101
|
+
let commaIndex = -1;
|
|
102
|
+
for (let index = 0; index < value.length; index++) {
|
|
103
|
+
const currentCharacter = value[index];
|
|
104
|
+
const nextCharacter = value[index + 1];
|
|
105
|
+
if (!isInsideComment && currentCharacter === '"') {
|
|
106
|
+
const escaped = isEscaped(value, index);
|
|
107
|
+
if (!escaped) {
|
|
108
|
+
isInsideString = !isInsideString;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (isInsideString) {
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (!isInsideComment && currentCharacter + (_nullishCoalesce(nextCharacter, () => ( EMPTY_STRING))) === "//") {
|
|
115
|
+
buffer += value.slice(offset, index);
|
|
116
|
+
offset = index;
|
|
117
|
+
isInsideComment = singleComment;
|
|
118
|
+
index++;
|
|
119
|
+
} else if (isInsideComment === singleComment && currentCharacter + (_nullishCoalesce(nextCharacter, () => ( EMPTY_STRING))) === "\r\n") {
|
|
120
|
+
index++;
|
|
121
|
+
isInsideComment = false;
|
|
122
|
+
buffer += strip(value, offset, index);
|
|
123
|
+
offset = index;
|
|
124
|
+
} else if (isInsideComment === singleComment && currentCharacter === "\n") {
|
|
125
|
+
isInsideComment = false;
|
|
126
|
+
buffer += strip(value, offset, index);
|
|
127
|
+
offset = index;
|
|
128
|
+
} else if (!isInsideComment && currentCharacter + (_nullishCoalesce(nextCharacter, () => ( EMPTY_STRING))) === "/*") {
|
|
129
|
+
buffer += value.slice(offset, index);
|
|
130
|
+
offset = index;
|
|
131
|
+
isInsideComment = multiComment;
|
|
132
|
+
index++;
|
|
133
|
+
} else if (isInsideComment === multiComment && currentCharacter + (_nullishCoalesce(nextCharacter, () => ( EMPTY_STRING))) === "*/") {
|
|
134
|
+
index++;
|
|
135
|
+
isInsideComment = false;
|
|
136
|
+
buffer += strip(value, offset, index + 1);
|
|
137
|
+
offset = index + 1;
|
|
138
|
+
} else if (trailingCommas && !isInsideComment) {
|
|
139
|
+
if (commaIndex !== -1) {
|
|
140
|
+
if (currentCharacter === "}" || currentCharacter === "]") {
|
|
141
|
+
buffer += value.slice(offset, index);
|
|
142
|
+
result += strip(buffer, 0, 1) + buffer.slice(1);
|
|
143
|
+
buffer = "";
|
|
144
|
+
offset = index;
|
|
145
|
+
commaIndex = -1;
|
|
146
|
+
} else if (currentCharacter !== " " && currentCharacter !== " " && currentCharacter !== "\r" && currentCharacter !== "\n") {
|
|
147
|
+
buffer += value.slice(offset, index);
|
|
148
|
+
offset = index;
|
|
149
|
+
commaIndex = -1;
|
|
150
|
+
}
|
|
151
|
+
} else if (currentCharacter === ",") {
|
|
152
|
+
result += buffer + value.slice(offset, index);
|
|
153
|
+
buffer = "";
|
|
154
|
+
offset = index;
|
|
155
|
+
commaIndex = index;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return result + buffer + (isInsideComment ? strip(value.slice(offset)) : value.slice(offset));
|
|
160
|
+
}
|
|
161
|
+
_chunkUSNT2KNTcjs.__name.call(void 0, stripComments, "stripComments");
|
|
162
|
+
|
|
163
|
+
// ../json/src/utils/parse.ts
|
|
164
|
+
var suspectProtoRx = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/;
|
|
165
|
+
var suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
|
|
166
|
+
var JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(?:\.\d{1,17})?(?:E[+-]?\d+)?\s*$/i;
|
|
167
|
+
function jsonParseTransform(key, value) {
|
|
168
|
+
if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
|
|
169
|
+
console.warn(`Dropping "${key}" key to prevent prototype pollution.`);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
return value;
|
|
173
|
+
}
|
|
174
|
+
_chunkUSNT2KNTcjs.__name.call(void 0, jsonParseTransform, "jsonParseTransform");
|
|
175
|
+
function parse(value, options = {}) {
|
|
176
|
+
if (typeof value !== "string") {
|
|
177
|
+
return value;
|
|
178
|
+
}
|
|
179
|
+
let stripped = stripComments(value);
|
|
180
|
+
if (stripped[0] === '"' && stripped[stripped.length - 1] === '"' && !stripped.includes("\\")) {
|
|
181
|
+
return stripped.slice(1, -1);
|
|
182
|
+
}
|
|
183
|
+
stripped = stripped.trim();
|
|
184
|
+
if (stripped.length <= 9) {
|
|
185
|
+
switch (stripped.toLowerCase()) {
|
|
186
|
+
case "true": {
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
case "false": {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
case "undefined": {
|
|
193
|
+
return void 0;
|
|
194
|
+
}
|
|
195
|
+
case "null": {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
case "nan": {
|
|
199
|
+
return Number.NaN;
|
|
200
|
+
}
|
|
201
|
+
case "infinity": {
|
|
202
|
+
return Number.POSITIVE_INFINITY;
|
|
203
|
+
}
|
|
204
|
+
case "-infinity": {
|
|
205
|
+
return Number.NEGATIVE_INFINITY;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (!JsonSigRx.test(stripped)) {
|
|
210
|
+
if (options.strict) {
|
|
211
|
+
throw new Error("Invalid JSON");
|
|
212
|
+
}
|
|
213
|
+
return stripped;
|
|
214
|
+
}
|
|
215
|
+
try {
|
|
216
|
+
if (suspectProtoRx.test(stripped) || suspectConstructorRx.test(stripped)) {
|
|
217
|
+
if (options.strict) {
|
|
218
|
+
throw new Error("Possible prototype pollution");
|
|
219
|
+
}
|
|
220
|
+
return JSON.parse(stripped, jsonParseTransform);
|
|
221
|
+
}
|
|
222
|
+
return JSON.parse(stripped);
|
|
223
|
+
} catch (error) {
|
|
224
|
+
if (options.strict) {
|
|
225
|
+
throw error;
|
|
226
|
+
}
|
|
227
|
+
return value;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
_chunkUSNT2KNTcjs.__name.call(void 0, parse, "parse");
|
|
231
|
+
|
|
232
|
+
// ../json/src/utils/parse-error.ts
|
|
233
|
+
|
|
234
|
+
var _linesandcolumns = require('lines-and-columns');
|
|
235
|
+
|
|
236
|
+
// ../json/src/utils/code-frames.ts
|
|
237
|
+
var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
|
|
238
|
+
function getMarkerLines(loc, source, opts = {}) {
|
|
239
|
+
const startLoc = {
|
|
240
|
+
column: 0,
|
|
241
|
+
line: -1,
|
|
242
|
+
...loc.start
|
|
243
|
+
};
|
|
244
|
+
const endLoc = {
|
|
245
|
+
...startLoc,
|
|
246
|
+
...loc.end
|
|
247
|
+
};
|
|
248
|
+
const { linesAbove = 2, linesBelow = 3 } = opts || {};
|
|
249
|
+
const startLine = startLoc.line;
|
|
250
|
+
const startColumn = startLoc.column;
|
|
251
|
+
const endLine = endLoc.line;
|
|
252
|
+
const endColumn = endLoc.column;
|
|
253
|
+
let start = Math.max(startLine - (linesAbove + 1), 0);
|
|
254
|
+
let end = Math.min(source.length, endLine + linesBelow);
|
|
255
|
+
if (startLine === -1) {
|
|
256
|
+
start = 0;
|
|
257
|
+
}
|
|
258
|
+
if (endLine === -1) {
|
|
259
|
+
end = source.length;
|
|
260
|
+
}
|
|
261
|
+
const lineDiff = endLine - startLine;
|
|
262
|
+
const markerLines = {};
|
|
263
|
+
if (lineDiff) {
|
|
264
|
+
for (let i = 0; i <= lineDiff; i++) {
|
|
265
|
+
const lineNumber = i + startLine;
|
|
266
|
+
if (!startColumn) {
|
|
267
|
+
markerLines[lineNumber] = true;
|
|
268
|
+
} else if (i === 0) {
|
|
269
|
+
const sourceLength = _nullishCoalesce(_optionalChain([source, 'access', _2 => _2[lineNumber - 1], 'optionalAccess', _3 => _3.length]), () => ( 0));
|
|
270
|
+
markerLines[lineNumber] = [
|
|
271
|
+
startColumn,
|
|
272
|
+
sourceLength - startColumn + 1
|
|
273
|
+
];
|
|
274
|
+
} else if (i === lineDiff) {
|
|
275
|
+
markerLines[lineNumber] = [
|
|
276
|
+
0,
|
|
277
|
+
endColumn
|
|
278
|
+
];
|
|
279
|
+
} else {
|
|
280
|
+
const sourceLength = _nullishCoalesce(_optionalChain([source, 'access', _4 => _4[lineNumber - i], 'optionalAccess', _5 => _5.length]), () => ( 0));
|
|
281
|
+
markerLines[lineNumber] = [
|
|
282
|
+
0,
|
|
283
|
+
sourceLength
|
|
284
|
+
];
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
} else if (startColumn === endColumn) {
|
|
288
|
+
markerLines[startLine] = startColumn ? [
|
|
289
|
+
startColumn,
|
|
290
|
+
0
|
|
291
|
+
] : true;
|
|
292
|
+
} else {
|
|
293
|
+
markerLines[startLine] = [
|
|
294
|
+
startColumn,
|
|
295
|
+
endColumn - startColumn
|
|
296
|
+
];
|
|
297
|
+
}
|
|
298
|
+
return {
|
|
299
|
+
start,
|
|
300
|
+
end,
|
|
301
|
+
markerLines
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
_chunkUSNT2KNTcjs.__name.call(void 0, getMarkerLines, "getMarkerLines");
|
|
305
|
+
function codeFrameColumns(rawLines, loc, opts = {}) {
|
|
306
|
+
const lines = rawLines.split(NEWLINE);
|
|
307
|
+
const { start, end, markerLines } = getMarkerLines(loc, lines, opts);
|
|
308
|
+
const numberMaxWidth = String(end).length;
|
|
309
|
+
const highlightedLines = opts.highlight ? opts.highlight(rawLines) : rawLines;
|
|
310
|
+
const frame = highlightedLines.split(NEWLINE).slice(start, end).map((line, index) => {
|
|
311
|
+
const number = start + 1 + index;
|
|
312
|
+
const paddedNumber = ` ${number}`.slice(-numberMaxWidth);
|
|
313
|
+
const gutter = ` ${paddedNumber} | `;
|
|
314
|
+
const hasMarker = Boolean(_nullishCoalesce(markerLines[number], () => ( false)));
|
|
315
|
+
if (hasMarker) {
|
|
316
|
+
let markerLine = "";
|
|
317
|
+
if (Array.isArray(hasMarker)) {
|
|
318
|
+
const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
|
|
319
|
+
const numberOfMarkers = hasMarker[1] || 1;
|
|
320
|
+
markerLine = [
|
|
321
|
+
"\n ",
|
|
322
|
+
gutter.replace(/\d/g, " "),
|
|
323
|
+
markerSpacing,
|
|
324
|
+
"^".repeat(numberOfMarkers)
|
|
325
|
+
].join("");
|
|
326
|
+
}
|
|
327
|
+
return [
|
|
328
|
+
">",
|
|
329
|
+
gutter,
|
|
330
|
+
line,
|
|
331
|
+
markerLine
|
|
332
|
+
].join("");
|
|
333
|
+
}
|
|
334
|
+
return ` ${gutter}${line}`;
|
|
335
|
+
}).join("\n");
|
|
336
|
+
return frame;
|
|
337
|
+
}
|
|
338
|
+
_chunkUSNT2KNTcjs.__name.call(void 0, codeFrameColumns, "codeFrameColumns");
|
|
339
|
+
|
|
340
|
+
// ../json/src/utils/parse-error.ts
|
|
341
|
+
function formatParseError(input, parseError) {
|
|
342
|
+
const { error, offset, length } = parseError;
|
|
343
|
+
const result = new (0, _linesandcolumns.LinesAndColumns)(input).locationForIndex(offset);
|
|
344
|
+
let line = _nullishCoalesce(_optionalChain([result, 'optionalAccess', _6 => _6.line]), () => ( 0));
|
|
345
|
+
let column = _nullishCoalesce(_optionalChain([result, 'optionalAccess', _7 => _7.column]), () => ( 0));
|
|
346
|
+
line++;
|
|
347
|
+
column++;
|
|
348
|
+
return `${_jsoncparser.printParseErrorCode.call(void 0, error)} in JSON at ${line}:${column}
|
|
349
|
+
${codeFrameColumns(input, {
|
|
350
|
+
start: {
|
|
351
|
+
line,
|
|
352
|
+
column
|
|
353
|
+
},
|
|
354
|
+
end: {
|
|
355
|
+
line,
|
|
356
|
+
column: column + length
|
|
357
|
+
}
|
|
358
|
+
})}
|
|
359
|
+
`;
|
|
360
|
+
}
|
|
361
|
+
_chunkUSNT2KNTcjs.__name.call(void 0, formatParseError, "formatParseError");
|
|
362
|
+
|
|
363
|
+
// ../type-checks/src/is-number.ts
|
|
364
|
+
var isNumber = /* @__PURE__ */ _chunkUSNT2KNTcjs.__name.call(void 0, (value) => {
|
|
365
|
+
try {
|
|
366
|
+
return value instanceof Number || typeof value === "number" || Number(value) === value;
|
|
367
|
+
} catch (e3) {
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
}, "isNumber");
|
|
371
|
+
|
|
372
|
+
// ../type-checks/src/is-undefined.ts
|
|
373
|
+
var isUndefined = /* @__PURE__ */ _chunkUSNT2KNTcjs.__name.call(void 0, (value) => {
|
|
374
|
+
return value === void 0;
|
|
375
|
+
}, "isUndefined");
|
|
376
|
+
|
|
377
|
+
// ../json/src/utils/stringify.ts
|
|
378
|
+
var invalidKeyChars = [
|
|
379
|
+
"@",
|
|
380
|
+
"/",
|
|
381
|
+
"#",
|
|
382
|
+
"$",
|
|
383
|
+
" ",
|
|
384
|
+
":",
|
|
385
|
+
";",
|
|
386
|
+
",",
|
|
387
|
+
".",
|
|
388
|
+
"!",
|
|
389
|
+
"?",
|
|
390
|
+
"&",
|
|
391
|
+
"=",
|
|
392
|
+
"+",
|
|
393
|
+
"-",
|
|
394
|
+
"*",
|
|
395
|
+
"%",
|
|
396
|
+
"^",
|
|
397
|
+
"~",
|
|
398
|
+
"|",
|
|
399
|
+
"\\",
|
|
400
|
+
'"',
|
|
401
|
+
"'",
|
|
402
|
+
"`",
|
|
403
|
+
"{",
|
|
404
|
+
"}",
|
|
405
|
+
"[",
|
|
406
|
+
"]",
|
|
407
|
+
"(",
|
|
408
|
+
")",
|
|
409
|
+
"<",
|
|
410
|
+
">"
|
|
411
|
+
];
|
|
412
|
+
var stringify = /* @__PURE__ */ _chunkUSNT2KNTcjs.__name.call(void 0, (value, spacing = 2) => {
|
|
413
|
+
const space = isNumber(spacing) ? " ".repeat(spacing) : spacing;
|
|
414
|
+
switch (value) {
|
|
415
|
+
case null: {
|
|
416
|
+
return "null";
|
|
417
|
+
}
|
|
418
|
+
case void 0: {
|
|
419
|
+
return '"undefined"';
|
|
420
|
+
}
|
|
421
|
+
case true: {
|
|
422
|
+
return "true";
|
|
423
|
+
}
|
|
424
|
+
case false: {
|
|
425
|
+
return "false";
|
|
426
|
+
}
|
|
427
|
+
case Number.POSITIVE_INFINITY: {
|
|
428
|
+
return "infinity";
|
|
429
|
+
}
|
|
430
|
+
case Number.NEGATIVE_INFINITY: {
|
|
431
|
+
return "-infinity";
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
if (Array.isArray(value)) {
|
|
435
|
+
return `[${space}${value.map((v) => stringify(v, space)).join(`,${space}`)}${space}]`;
|
|
436
|
+
}
|
|
437
|
+
if (value instanceof Uint8Array) {
|
|
438
|
+
return value.toString();
|
|
439
|
+
}
|
|
440
|
+
switch (typeof value) {
|
|
441
|
+
case "number": {
|
|
442
|
+
return `${value}`;
|
|
443
|
+
}
|
|
444
|
+
case "string": {
|
|
445
|
+
return JSON.stringify(value);
|
|
446
|
+
}
|
|
447
|
+
case "object": {
|
|
448
|
+
const keys = Object.keys(value).filter((key) => !isUndefined(value[key]));
|
|
449
|
+
return `{${space}${keys.map((key) => `${invalidKeyChars.some((invalidKeyChar) => key.includes(invalidKeyChar)) ? `"${key}"` : key}: ${space}${stringify(value[key], space)}`).join(`,${space}`)}${space}}`;
|
|
450
|
+
}
|
|
451
|
+
default:
|
|
452
|
+
return "null";
|
|
453
|
+
}
|
|
454
|
+
}, "stringify");
|
|
455
|
+
|
|
456
|
+
// ../json/src/storm-json.ts
|
|
457
|
+
var StormJSON = class _StormJSON extends _superjson2.default {
|
|
458
|
+
static {
|
|
459
|
+
_chunkUSNT2KNTcjs.__name.call(void 0, this, "StormJSON");
|
|
460
|
+
}
|
|
461
|
+
static #instance;
|
|
462
|
+
static get instance() {
|
|
463
|
+
if (!_StormJSON.#instance) {
|
|
464
|
+
_StormJSON.#instance = new _StormJSON();
|
|
465
|
+
}
|
|
466
|
+
return _StormJSON.#instance;
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Deserialize the given value with superjson using the given metadata
|
|
470
|
+
*/
|
|
471
|
+
static deserialize(payload) {
|
|
472
|
+
return _StormJSON.instance.deserialize(payload);
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Serialize the given value with superjson
|
|
476
|
+
*/
|
|
477
|
+
static serialize(object) {
|
|
478
|
+
return _StormJSON.instance.serialize(object);
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Parse the given string value with superjson using the given metadata
|
|
482
|
+
*
|
|
483
|
+
* @param value - The string value to parse
|
|
484
|
+
* @returns The parsed data
|
|
485
|
+
*/
|
|
486
|
+
static parse(value) {
|
|
487
|
+
return parse(value);
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Serializes the given data to a JSON string.
|
|
491
|
+
* By default the JSON string is formatted with a 2 space indentation to be easy readable.
|
|
492
|
+
*
|
|
493
|
+
* @param value - Object which should be serialized to JSON
|
|
494
|
+
* @param _options - JSON serialize options
|
|
495
|
+
* @returns the formatted JSON representation of the object
|
|
496
|
+
*/
|
|
497
|
+
static stringify(value, _options) {
|
|
498
|
+
const customTransformer = _StormJSON.instance.customTransformerRegistry.findApplicable(value);
|
|
499
|
+
let result = value;
|
|
500
|
+
if (customTransformer && customTransformer.isApplicable(value)) {
|
|
501
|
+
result = customTransformer.serialize(result);
|
|
502
|
+
}
|
|
503
|
+
return stringify(result);
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Parses the given JSON string and returns the object the JSON content represents.
|
|
507
|
+
* By default javascript-style comments and trailing commas are allowed.
|
|
508
|
+
*
|
|
509
|
+
* @param strData - JSON content as string
|
|
510
|
+
* @param options - JSON parse options
|
|
511
|
+
* @returns Object the JSON content represents
|
|
512
|
+
*/
|
|
513
|
+
static parseJson(strData, options) {
|
|
514
|
+
try {
|
|
515
|
+
if (_optionalChain([options, 'optionalAccess', _8 => _8.expectComments]) === false) {
|
|
516
|
+
return _StormJSON.instance.parse(strData);
|
|
517
|
+
}
|
|
518
|
+
} catch (e4) {
|
|
519
|
+
}
|
|
520
|
+
const errors = [];
|
|
521
|
+
const opts = {
|
|
522
|
+
allowTrailingComma: true,
|
|
523
|
+
...options
|
|
524
|
+
};
|
|
525
|
+
const result = _jsoncparser.parse.call(void 0, strData, errors, opts);
|
|
526
|
+
if (errors.length > 0 && errors[0]) {
|
|
527
|
+
throw new Error(formatParseError(strData, errors[0]));
|
|
528
|
+
}
|
|
529
|
+
return result;
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Register a custom schema with superjson
|
|
533
|
+
*
|
|
534
|
+
* @param name - The name of the schema
|
|
535
|
+
* @param serialize - The function to serialize the schema
|
|
536
|
+
* @param deserialize - The function to deserialize the schema
|
|
537
|
+
* @param isApplicable - The function to check if the schema is applicable
|
|
538
|
+
*/
|
|
539
|
+
static register(name, serialize, deserialize, isApplicable) {
|
|
540
|
+
_StormJSON.instance.registerCustom({
|
|
541
|
+
isApplicable,
|
|
542
|
+
serialize,
|
|
543
|
+
deserialize
|
|
544
|
+
}, name);
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Register a class with superjson
|
|
548
|
+
*
|
|
549
|
+
* @param classConstructor - The class constructor to register
|
|
550
|
+
*/
|
|
551
|
+
static registerClass(classConstructor, options) {
|
|
552
|
+
_StormJSON.instance.registerClass(classConstructor, {
|
|
553
|
+
identifier: isString(options) ? options : _optionalChain([options, 'optionalAccess', _9 => _9.identifier]) || classConstructor.name,
|
|
554
|
+
allowProps: options && isObject(options) && _optionalChain([options, 'optionalAccess', _10 => _10.allowProps]) && Array.isArray(options.allowProps) ? options.allowProps : [
|
|
555
|
+
"__typename"
|
|
556
|
+
]
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
constructor() {
|
|
560
|
+
super({
|
|
561
|
+
dedupe: true
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
};
|
|
565
|
+
StormJSON.instance.registerCustom({
|
|
566
|
+
isApplicable: /* @__PURE__ */ _chunkUSNT2KNTcjs.__name.call(void 0, (v) => _buffer.Buffer.isBuffer(v), "isApplicable"),
|
|
567
|
+
serialize: /* @__PURE__ */ _chunkUSNT2KNTcjs.__name.call(void 0, (v) => v.toString("base64"), "serialize"),
|
|
568
|
+
deserialize: /* @__PURE__ */ _chunkUSNT2KNTcjs.__name.call(void 0, (v) => _buffer.Buffer.from(v, "base64"), "deserialize")
|
|
569
|
+
}, "Bytes");
|
|
570
|
+
|
|
571
|
+
// ../type-checks/src/is-error.ts
|
|
572
|
+
var isError = /* @__PURE__ */ _chunkUSNT2KNTcjs.__name.call(void 0, (obj) => {
|
|
573
|
+
if (!isObject(obj)) {
|
|
574
|
+
return false;
|
|
575
|
+
}
|
|
576
|
+
const tag = getObjectTag(obj);
|
|
577
|
+
return tag === "[object Error]" || tag === "[object DOMException]" || typeof _optionalChain([obj, 'optionalAccess', _11 => _11.message]) === "string" && typeof _optionalChain([obj, 'optionalAccess', _12 => _12.name]) === "string" && !isPlainObject(obj);
|
|
578
|
+
}, "isError");
|
|
579
|
+
|
|
580
|
+
// ../fs/src/read-file.ts
|
|
581
|
+
var _fs = require('fs');
|
|
582
|
+
var _promises = require('fs/promises');
|
|
583
|
+
var readFile = /* @__PURE__ */ _chunkUSNT2KNTcjs.__name.call(void 0, async (filePath) => {
|
|
584
|
+
try {
|
|
585
|
+
if (!filePath) {
|
|
586
|
+
throw new Error("No file path provided to read data");
|
|
587
|
+
}
|
|
588
|
+
return await _promises.readFile.call(void 0, filePath, {
|
|
589
|
+
encoding: "utf8"
|
|
590
|
+
});
|
|
591
|
+
} catch (e5) {
|
|
592
|
+
throw new Error("An error occurred writing data to file");
|
|
593
|
+
}
|
|
594
|
+
}, "readFile");
|
|
595
|
+
|
|
596
|
+
// ../path/src/is-file.ts
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
// ../path/src/join-paths.ts
|
|
600
|
+
var _DRIVE_LETTER_START_RE = /^[A-Z]:\//i;
|
|
601
|
+
function normalizeWindowsPath(input = "") {
|
|
602
|
+
if (!input) {
|
|
603
|
+
return input;
|
|
604
|
+
}
|
|
605
|
+
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
606
|
+
}
|
|
607
|
+
_chunkUSNT2KNTcjs.__name.call(void 0, normalizeWindowsPath, "normalizeWindowsPath");
|
|
608
|
+
var _UNC_REGEX = /^[/\\]{2}/;
|
|
609
|
+
var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i;
|
|
610
|
+
var _DRIVE_LETTER_RE = /^[A-Z]:$/i;
|
|
611
|
+
var isAbsolute = /* @__PURE__ */ _chunkUSNT2KNTcjs.__name.call(void 0, function(p) {
|
|
612
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
613
|
+
}, "isAbsolute");
|
|
614
|
+
var correctPaths = /* @__PURE__ */ _chunkUSNT2KNTcjs.__name.call(void 0, function(path) {
|
|
615
|
+
if (!path || path.length === 0) {
|
|
616
|
+
return ".";
|
|
617
|
+
}
|
|
618
|
+
path = normalizeWindowsPath(path);
|
|
619
|
+
const isUNCPath = path.match(_UNC_REGEX);
|
|
620
|
+
const isPathAbsolute = isAbsolute(path);
|
|
621
|
+
const trailingSeparator = path[path.length - 1] === "/";
|
|
622
|
+
path = normalizeString(path, !isPathAbsolute);
|
|
623
|
+
if (path.length === 0) {
|
|
624
|
+
if (isPathAbsolute) {
|
|
625
|
+
return "/";
|
|
626
|
+
}
|
|
627
|
+
return trailingSeparator ? "./" : ".";
|
|
628
|
+
}
|
|
629
|
+
if (trailingSeparator) {
|
|
630
|
+
path += "/";
|
|
631
|
+
}
|
|
632
|
+
if (_DRIVE_LETTER_RE.test(path)) {
|
|
633
|
+
path += "/";
|
|
634
|
+
}
|
|
635
|
+
if (isUNCPath) {
|
|
636
|
+
if (!isPathAbsolute) {
|
|
637
|
+
return `//./${path}`;
|
|
638
|
+
}
|
|
639
|
+
return `//${path}`;
|
|
640
|
+
}
|
|
641
|
+
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
|
642
|
+
}, "correctPaths");
|
|
643
|
+
var joinPaths = /* @__PURE__ */ _chunkUSNT2KNTcjs.__name.call(void 0, function(...segments) {
|
|
644
|
+
let path = "";
|
|
645
|
+
for (const seg of segments) {
|
|
646
|
+
if (!seg) {
|
|
647
|
+
continue;
|
|
648
|
+
}
|
|
649
|
+
if (path.length > 0) {
|
|
650
|
+
const pathTrailing = path[path.length - 1] === "/";
|
|
651
|
+
const segLeading = seg[0] === "/";
|
|
652
|
+
const both = pathTrailing && segLeading;
|
|
653
|
+
if (both) {
|
|
654
|
+
path += seg.slice(1);
|
|
655
|
+
} else {
|
|
656
|
+
path += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
657
|
+
}
|
|
658
|
+
} else {
|
|
659
|
+
path += seg;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
return correctPaths(path);
|
|
663
|
+
}, "joinPaths");
|
|
664
|
+
function normalizeString(path, allowAboveRoot) {
|
|
665
|
+
let res = "";
|
|
666
|
+
let lastSegmentLength = 0;
|
|
667
|
+
let lastSlash = -1;
|
|
668
|
+
let dots = 0;
|
|
669
|
+
let char = null;
|
|
670
|
+
for (let index = 0; index <= path.length; ++index) {
|
|
671
|
+
if (index < path.length) {
|
|
672
|
+
char = path[index];
|
|
673
|
+
} else if (char === "/") {
|
|
674
|
+
break;
|
|
675
|
+
} else {
|
|
676
|
+
char = "/";
|
|
677
|
+
}
|
|
678
|
+
if (char === "/") {
|
|
679
|
+
if (lastSlash === index - 1 || dots === 1) {
|
|
680
|
+
} else if (dots === 2) {
|
|
681
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
682
|
+
if (res.length > 2) {
|
|
683
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
684
|
+
if (lastSlashIndex === -1) {
|
|
685
|
+
res = "";
|
|
686
|
+
lastSegmentLength = 0;
|
|
687
|
+
} else {
|
|
688
|
+
res = res.slice(0, lastSlashIndex);
|
|
689
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
690
|
+
}
|
|
691
|
+
lastSlash = index;
|
|
692
|
+
dots = 0;
|
|
693
|
+
continue;
|
|
694
|
+
} else if (res.length > 0) {
|
|
695
|
+
res = "";
|
|
696
|
+
lastSegmentLength = 0;
|
|
697
|
+
lastSlash = index;
|
|
698
|
+
dots = 0;
|
|
699
|
+
continue;
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
if (allowAboveRoot) {
|
|
703
|
+
res += res.length > 0 ? "/.." : "..";
|
|
704
|
+
lastSegmentLength = 2;
|
|
705
|
+
}
|
|
706
|
+
} else {
|
|
707
|
+
if (res.length > 0) {
|
|
708
|
+
res += `/${path.slice(lastSlash + 1, index)}`;
|
|
709
|
+
} else {
|
|
710
|
+
res = path.slice(lastSlash + 1, index);
|
|
711
|
+
}
|
|
712
|
+
lastSegmentLength = index - lastSlash - 1;
|
|
713
|
+
}
|
|
714
|
+
lastSlash = index;
|
|
715
|
+
dots = 0;
|
|
716
|
+
} else if (char === "." && dots !== -1) {
|
|
717
|
+
++dots;
|
|
718
|
+
} else {
|
|
719
|
+
dots = -1;
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
return res;
|
|
723
|
+
}
|
|
724
|
+
_chunkUSNT2KNTcjs.__name.call(void 0, normalizeString, "normalizeString");
|
|
725
|
+
|
|
726
|
+
// ../path/src/regex.ts
|
|
727
|
+
var DRIVE_LETTER_START_REGEX = /^[A-Z]:\//i;
|
|
728
|
+
|
|
729
|
+
// ../path/src/slash.ts
|
|
730
|
+
function slash(path) {
|
|
731
|
+
if (path.startsWith("\\\\?\\")) {
|
|
732
|
+
return path;
|
|
733
|
+
}
|
|
734
|
+
return path.replace(/\\/g, "/");
|
|
735
|
+
}
|
|
736
|
+
_chunkUSNT2KNTcjs.__name.call(void 0, slash, "slash");
|
|
737
|
+
|
|
738
|
+
// ../path/src/correct-path.ts
|
|
739
|
+
function normalizeWindowsPath2(input = "") {
|
|
740
|
+
if (!input) {
|
|
741
|
+
return input;
|
|
742
|
+
}
|
|
743
|
+
return slash(input).replace(DRIVE_LETTER_START_REGEX, (r) => r.toUpperCase());
|
|
744
|
+
}
|
|
745
|
+
_chunkUSNT2KNTcjs.__name.call(void 0, normalizeWindowsPath2, "normalizeWindowsPath");
|
|
746
|
+
|
|
747
|
+
// ../path/src/exists.ts
|
|
748
|
+
|
|
749
|
+
|
|
750
|
+
var existsSync2 = /* @__PURE__ */ _chunkUSNT2KNTcjs.__name.call(void 0, (filePath) => {
|
|
751
|
+
return _fs.existsSync.call(void 0, filePath);
|
|
752
|
+
}, "existsSync");
|
|
753
|
+
|
|
754
|
+
// ../path/src/file-path-fns.ts
|
|
755
|
+
var _path = require('path');
|
|
756
|
+
|
|
757
|
+
// ../path/src/get-workspace-root.ts
|
|
758
|
+
var _configtools = require('@storm-software/config-tools');
|
|
759
|
+
|
|
760
|
+
// ../path/src/file-path-fns.ts
|
|
761
|
+
function findFileName(filePath, options = {}) {
|
|
762
|
+
const { requireExtension = false, withExtension = true } = options;
|
|
763
|
+
const result = _nullishCoalesce(_optionalChain([normalizeWindowsPath2, 'call', _13 => _13(filePath), 'optionalAccess', _14 => _14.split, 'call', _15 => _15(_optionalChain([filePath, 'optionalAccess', _16 => _16.includes, 'call', _17 => _17("\\")]) ? "\\" : "/"), 'optionalAccess', _18 => _18.pop, 'call', _19 => _19()]), () => ( ""));
|
|
764
|
+
if (requireExtension === true && !result.includes(".")) {
|
|
765
|
+
return EMPTY_STRING;
|
|
766
|
+
}
|
|
767
|
+
if (withExtension === false && result.includes(".")) {
|
|
768
|
+
return result.substring(0, result.lastIndexOf(".")) || EMPTY_STRING;
|
|
769
|
+
}
|
|
770
|
+
return result;
|
|
771
|
+
}
|
|
772
|
+
_chunkUSNT2KNTcjs.__name.call(void 0, findFileName, "findFileName");
|
|
773
|
+
function findFilePath(filePath) {
|
|
774
|
+
const normalizedPath = normalizeWindowsPath2(filePath);
|
|
775
|
+
const result = normalizedPath.replace(findFileName(normalizedPath, {
|
|
776
|
+
requireExtension: true
|
|
777
|
+
}), "");
|
|
778
|
+
return result === "/" ? result : result.replace(/\/$/, "");
|
|
779
|
+
}
|
|
780
|
+
_chunkUSNT2KNTcjs.__name.call(void 0, findFilePath, "findFilePath");
|
|
781
|
+
function relativePath(from, to, withEndSlash = false) {
|
|
782
|
+
return _path.relative.call(void 0, withEndSlash !== true ? from.replace(/\/$/, "") : from, withEndSlash !== true ? to.replace(/\/$/, "") : to);
|
|
783
|
+
}
|
|
784
|
+
_chunkUSNT2KNTcjs.__name.call(void 0, relativePath, "relativePath");
|
|
785
|
+
|
|
786
|
+
// ../fs/src/write-file.ts
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
// ../fs/src/helpers.ts
|
|
791
|
+
var _nanotar = require('nanotar');
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
|
|
795
|
+
// ../fs/src/json.ts
|
|
796
|
+
async function readJsonFile(path, options) {
|
|
797
|
+
const content = await readFile(path);
|
|
798
|
+
if (options) {
|
|
799
|
+
options.endsWithNewline = content.codePointAt(content.length - 1) === 10;
|
|
800
|
+
}
|
|
801
|
+
try {
|
|
802
|
+
return StormJSON.parseJson(content, options);
|
|
803
|
+
} catch (error) {
|
|
804
|
+
if (isError(error)) {
|
|
805
|
+
error.message = error.message.replace("JSON", path);
|
|
806
|
+
throw error;
|
|
807
|
+
}
|
|
808
|
+
throw new Error(`Failed to parse JSON: ${path}`);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
_chunkUSNT2KNTcjs.__name.call(void 0, readJsonFile, "readJsonFile");
|
|
812
|
+
|
|
813
|
+
// ../fs/src/list-files.ts
|
|
814
|
+
var _defu = require('defu'); var _defu2 = _interopRequireDefault(_defu);
|
|
815
|
+
var _glob = require('glob');
|
|
816
|
+
var DEFAULT_OPTIONS = {
|
|
817
|
+
dot: true
|
|
818
|
+
};
|
|
819
|
+
async function list(filesGlob, options) {
|
|
820
|
+
return _glob.glob.call(void 0, filesGlob, _defu2.default.call(void 0, _nullishCoalesce(options, () => ( {})), DEFAULT_OPTIONS));
|
|
821
|
+
}
|
|
822
|
+
_chunkUSNT2KNTcjs.__name.call(void 0, list, "list");
|
|
823
|
+
async function listFiles(filesGlob, options) {
|
|
824
|
+
const result = (await list(filesGlob, _defu2.default.call(void 0, {
|
|
825
|
+
withFileTypes: true
|
|
826
|
+
}, _nullishCoalesce(options, () => ( {}))))).filter((ret) => ret.isFile());
|
|
827
|
+
if (!_optionalChain([options, 'optionalAccess', _20 => _20.withFileTypes])) {
|
|
828
|
+
return result.map((file) => file.fullpath());
|
|
829
|
+
}
|
|
830
|
+
return result;
|
|
831
|
+
}
|
|
832
|
+
_chunkUSNT2KNTcjs.__name.call(void 0, listFiles, "listFiles");
|
|
833
|
+
|
|
834
|
+
// src/helpers.ts
|
|
835
|
+
var _typescript = require('typescript');
|
|
836
|
+
async function resolveOptions(options) {
|
|
837
|
+
const tsconfigPath = options.tsconfigPath ? options.tsconfigPath.replace("{projectRoot}", options.projectRoot).replace("{workspaceRoot}", options.workspaceRoot) : void 0;
|
|
838
|
+
const schemas = toArray(options.schemas ? Array.isArray(options.schemas) ? options.schemas.map((schema) => schema.replace("{projectRoot}", options.projectRoot).replace("{workspaceRoot}", options.workspaceRoot)) : options.schemas : joinPaths(options.projectRoot, "schemas/**/*.capnp"));
|
|
839
|
+
let resolvedTsconfig;
|
|
840
|
+
if (options.tsconfig) {
|
|
841
|
+
resolvedTsconfig = options.tsconfig;
|
|
842
|
+
} else {
|
|
843
|
+
if (!tsconfigPath || !existsSync2(tsconfigPath)) {
|
|
844
|
+
const errorMessage = tsconfigPath ? `\u2716 The specified TypeScript configuration file "${tsconfigPath}" does not exist. Please provide a valid path.` : "\u2716 The specified TypeScript configuration file does not exist. Please provide a valid path.";
|
|
845
|
+
_console.writeFatal.call(void 0, errorMessage, {
|
|
846
|
+
logLevel: "all"
|
|
847
|
+
});
|
|
848
|
+
throw new Error(errorMessage);
|
|
849
|
+
}
|
|
850
|
+
const tsconfigFile = await readJsonFile(tsconfigPath);
|
|
851
|
+
resolvedTsconfig = _typescript.parseJsonConfigFileContent.call(void 0, tsconfigFile, _typescript.sys, findFilePath(tsconfigPath));
|
|
852
|
+
if (!resolvedTsconfig) {
|
|
853
|
+
const errorMessage = `\u2716 The specified TypeScript configuration file "${tsconfigPath}" is invalid. Please provide a valid configuration.`;
|
|
854
|
+
_console.writeFatal.call(void 0, errorMessage, {
|
|
855
|
+
logLevel: "all"
|
|
856
|
+
});
|
|
857
|
+
throw new Error(errorMessage);
|
|
858
|
+
}
|
|
859
|
+
resolvedTsconfig.options.configFilePath = tsconfigPath;
|
|
860
|
+
resolvedTsconfig.options.noImplicitOverride = false;
|
|
861
|
+
resolvedTsconfig.options.noUnusedLocals = false;
|
|
862
|
+
resolvedTsconfig.options.noUnusedParameters = false;
|
|
863
|
+
}
|
|
864
|
+
const resolvedSchemas = [];
|
|
865
|
+
for (const schema of schemas) {
|
|
866
|
+
if (!schema || !schema.includes("*") && !existsSync2(schema)) {
|
|
867
|
+
if (schemas.length <= 1) {
|
|
868
|
+
throw new Error(`\u2716 The schema path "${schema}" is invalid. Please provide a valid path.`);
|
|
869
|
+
}
|
|
870
|
+
} else {
|
|
871
|
+
resolvedSchemas.push(...await listFiles(schema.includes("*") ? schema.endsWith(".capnp") ? schema : `${schema}.capnp` : joinPaths(schema, "**/*.capnp")));
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
if (resolvedSchemas.length === 0 || !resolvedSchemas[0]) {
|
|
875
|
+
_console.writeWarning.call(void 0, `\u2716 No Cap'n Proto schema files found in the specified source paths: ${schemas.join(", ")}. As a result, the Cap'n Proto compiler will not be able to generate any output files. Please ensure that the paths are correct and contain .capnp files.`, {
|
|
876
|
+
logLevel: "all"
|
|
877
|
+
});
|
|
878
|
+
return null;
|
|
879
|
+
}
|
|
880
|
+
resolvedTsconfig.options.outDir = joinPaths(options.projectRoot, relativePath(tsconfigPath ? findFilePath(tsconfigPath) : options.projectRoot, joinPaths(options.workspaceRoot, resolvedSchemas[0].endsWith(".capnp") ? findFilePath(resolvedSchemas[0]) : resolvedSchemas[0])));
|
|
881
|
+
return {
|
|
882
|
+
workspaceRoot: options.workspaceRoot,
|
|
883
|
+
projectRoot: options.projectRoot,
|
|
884
|
+
schemas: resolvedSchemas,
|
|
885
|
+
js: _nullishCoalesce(options.js, () => ( false)),
|
|
886
|
+
ts: _nullishCoalesce(options.ts, () => ( (options.noTs !== void 0 ? !options.noTs : true))),
|
|
887
|
+
dts: _nullishCoalesce(options.dts, () => ( (options.noDts !== void 0 ? !options.noDts : true))),
|
|
888
|
+
tsconfig: resolvedTsconfig
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
_chunkUSNT2KNTcjs.__name.call(void 0, resolveOptions, "resolveOptions");
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
exports.resolveOptions = resolveOptions;
|