@luna-park/plugin 1.4.2 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/preview.js +50 -50
- package/dist/{dist-hc-SHkAg.mjs → dist-Cnje_ZD3.mjs} +102 -95
- package/dist/extractor.d.mts +6 -8
- package/dist/extractor.mjs +3 -4
- package/dist/{index-X3hhfmWd.d.mts → index-DQhxmFHB.d.mts} +77 -44
- package/dist/index.d.mts +630 -526
- package/dist/index.mjs +166 -70
- package/dist/preview.d.mts +2 -3
- package/package.json +25 -25
package/bin/preview.js
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { parseArgs } from "node:util";
|
|
3
|
-
|
|
4
|
-
import { resolve } from "path";
|
|
5
|
-
|
|
6
|
-
import { startPreviewServer } from "../dist/preview.mjs";
|
|
7
|
-
|
|
8
|
-
const cwd = process.cwd();
|
|
9
|
-
|
|
10
|
-
// Parse CLI arguments
|
|
11
|
-
const { values } = parseArgs({
|
|
12
|
-
options: {
|
|
13
|
-
dist: {
|
|
14
|
-
default: "dist",
|
|
15
|
-
short: "d",
|
|
16
|
-
type: "string"
|
|
17
|
-
},
|
|
18
|
-
help: {
|
|
19
|
-
default: false,
|
|
20
|
-
short: "h",
|
|
21
|
-
type: "boolean"
|
|
22
|
-
},
|
|
23
|
-
port: {
|
|
24
|
-
default: "2084",
|
|
25
|
-
short: "p",
|
|
26
|
-
type: "string"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
if (values.help) {
|
|
32
|
-
console.log(`
|
|
33
|
-
Usage: luna-preview [options]
|
|
34
|
-
|
|
35
|
-
Options:
|
|
36
|
-
-p, --port <port> Port to run the server on (default: 2084)
|
|
37
|
-
-d, --dist <dir> Distribution directory to serve (default: dist)
|
|
38
|
-
-h, --help Show this help message
|
|
39
|
-
`);
|
|
40
|
-
process.exit(0);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const dist = resolve(cwd, values.dist);
|
|
44
|
-
const port = parseInt(values.port);
|
|
45
|
-
|
|
46
|
-
startPreviewServer({
|
|
47
|
-
dist,
|
|
48
|
-
externals: ["vue", "vue-router", "@luna-park/design"],
|
|
49
|
-
port
|
|
50
|
-
});
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { parseArgs } from "node:util";
|
|
3
|
+
|
|
4
|
+
import { resolve } from "path";
|
|
5
|
+
|
|
6
|
+
import { startPreviewServer } from "../dist/preview.mjs";
|
|
7
|
+
|
|
8
|
+
const cwd = process.cwd();
|
|
9
|
+
|
|
10
|
+
// Parse CLI arguments
|
|
11
|
+
const { values } = parseArgs({
|
|
12
|
+
options: {
|
|
13
|
+
dist: {
|
|
14
|
+
default: "dist",
|
|
15
|
+
short: "d",
|
|
16
|
+
type: "string"
|
|
17
|
+
},
|
|
18
|
+
help: {
|
|
19
|
+
default: false,
|
|
20
|
+
short: "h",
|
|
21
|
+
type: "boolean"
|
|
22
|
+
},
|
|
23
|
+
port: {
|
|
24
|
+
default: "2084",
|
|
25
|
+
short: "p",
|
|
26
|
+
type: "string"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
if (values.help) {
|
|
32
|
+
console.log(`
|
|
33
|
+
Usage: luna-preview [options]
|
|
34
|
+
|
|
35
|
+
Options:
|
|
36
|
+
-p, --port <port> Port to run the server on (default: 2084)
|
|
37
|
+
-d, --dist <dir> Distribution directory to serve (default: dist)
|
|
38
|
+
-h, --help Show this help message
|
|
39
|
+
`);
|
|
40
|
+
process.exit(0);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const dist = resolve(cwd, values.dist);
|
|
44
|
+
const port = parseInt(values.port);
|
|
45
|
+
|
|
46
|
+
startPreviewServer({
|
|
47
|
+
dist,
|
|
48
|
+
externals: ["vue", "vue-router", "@luna-park/design"],
|
|
49
|
+
port
|
|
50
|
+
});
|
|
@@ -92,99 +92,99 @@ const LogicType = {
|
|
|
92
92
|
return {
|
|
93
93
|
...args,
|
|
94
94
|
items,
|
|
95
|
-
type:
|
|
95
|
+
type: "array"
|
|
96
96
|
};
|
|
97
97
|
},
|
|
98
98
|
boolean: (args = {}) => {
|
|
99
99
|
return {
|
|
100
100
|
...args,
|
|
101
|
-
type:
|
|
101
|
+
type: "boolean"
|
|
102
102
|
};
|
|
103
103
|
},
|
|
104
104
|
exec: (args = {}) => {
|
|
105
105
|
return {
|
|
106
106
|
...args,
|
|
107
|
-
type:
|
|
108
|
-
};
|
|
109
|
-
},
|
|
110
|
-
function: (inputs = {
|
|
111
|
-
properties: {},
|
|
112
|
-
type: EVarType.object
|
|
113
|
-
}, output = { type: EVarType.void }, args = {}) => {
|
|
114
|
-
return {
|
|
115
|
-
...args,
|
|
116
|
-
inputs,
|
|
117
|
-
output,
|
|
118
|
-
type: EVarType.function
|
|
107
|
+
type: "exec"
|
|
119
108
|
};
|
|
120
109
|
},
|
|
110
|
+
function: createFunction,
|
|
121
111
|
interface: (interfaceClass, args = {}) => {
|
|
122
112
|
return {
|
|
123
113
|
...args,
|
|
124
114
|
className: typeof interfaceClass === "string" ? interfaceClass : interfaceClass.name,
|
|
125
|
-
type:
|
|
115
|
+
type: "interface"
|
|
126
116
|
};
|
|
127
117
|
},
|
|
128
118
|
number: (args = {}) => {
|
|
129
119
|
return {
|
|
130
120
|
...args,
|
|
131
|
-
type:
|
|
121
|
+
type: "number"
|
|
132
122
|
};
|
|
133
123
|
},
|
|
134
124
|
object: (properties = {}, args = {}) => {
|
|
135
125
|
return {
|
|
136
126
|
...args,
|
|
137
127
|
properties,
|
|
138
|
-
type:
|
|
128
|
+
type: "object"
|
|
139
129
|
};
|
|
140
130
|
},
|
|
141
131
|
record: (key, value, args = {}) => {
|
|
142
132
|
return {
|
|
143
133
|
...args,
|
|
144
134
|
key,
|
|
145
|
-
type:
|
|
135
|
+
type: "record",
|
|
146
136
|
value
|
|
147
137
|
};
|
|
148
138
|
},
|
|
149
139
|
string: (args = {}) => {
|
|
150
140
|
return {
|
|
151
141
|
...args,
|
|
152
|
-
type:
|
|
153
|
-
};
|
|
154
|
-
},
|
|
155
|
-
type: (target, args = {}) => {
|
|
156
|
-
return {
|
|
157
|
-
...args,
|
|
158
|
-
target,
|
|
159
|
-
type: EVarType.type
|
|
142
|
+
type: "string"
|
|
160
143
|
};
|
|
161
144
|
},
|
|
145
|
+
type: createType,
|
|
162
146
|
undefined: (args = {}) => {
|
|
163
147
|
return {
|
|
164
148
|
...args,
|
|
165
|
-
type:
|
|
149
|
+
type: "undefined"
|
|
166
150
|
};
|
|
167
151
|
},
|
|
168
152
|
union: (elements, args = {}) => {
|
|
169
153
|
return {
|
|
170
154
|
...args,
|
|
171
155
|
elements,
|
|
172
|
-
type:
|
|
156
|
+
type: "union"
|
|
173
157
|
};
|
|
174
158
|
},
|
|
175
159
|
unknown: (args = {}) => {
|
|
176
160
|
return {
|
|
177
161
|
...args,
|
|
178
|
-
type:
|
|
162
|
+
type: "unknown"
|
|
179
163
|
};
|
|
180
164
|
},
|
|
181
165
|
void: (args = {}) => {
|
|
182
166
|
return {
|
|
183
167
|
...args,
|
|
184
|
-
type:
|
|
168
|
+
type: "void"
|
|
185
169
|
};
|
|
186
170
|
}
|
|
187
171
|
};
|
|
172
|
+
function createFunction(inputs = [], output = LogicType.void(), args = {}) {
|
|
173
|
+
if (Array.isArray(inputs)) return createFunction(LogicType.object(Object.fromEntries(inputs)), output, args);
|
|
174
|
+
return {
|
|
175
|
+
...args,
|
|
176
|
+
inputs,
|
|
177
|
+
output,
|
|
178
|
+
type: "function"
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
function createType(target, args = {}) {
|
|
182
|
+
return {
|
|
183
|
+
...args,
|
|
184
|
+
target,
|
|
185
|
+
type: "type"
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
188
|
const LogicUtil = {
|
|
189
189
|
omit(target, keys) {
|
|
190
190
|
return {
|
|
@@ -239,44 +239,6 @@ let ELogicScope = /* @__PURE__ */ function(ELogicScope) {
|
|
|
239
239
|
function makeLogicNode(node) {
|
|
240
240
|
return node;
|
|
241
241
|
}
|
|
242
|
-
function scanner(input) {
|
|
243
|
-
const elements = [];
|
|
244
|
-
input = input.replaceAll(/ +/g, " ");
|
|
245
|
-
input = input.replaceAll(/\s*\n\s*/g, "\n");
|
|
246
|
-
while (input.length) {
|
|
247
|
-
if ([" ", "\n"].includes(input[0])) {
|
|
248
|
-
input = input.slice(1);
|
|
249
|
-
continue;
|
|
250
|
-
}
|
|
251
|
-
if (input.startsWith("/*")) {
|
|
252
|
-
const commentEnd = input.indexOf("*/");
|
|
253
|
-
elements.push(input.slice(0, commentEnd + 2));
|
|
254
|
-
input = input.slice(commentEnd + 2);
|
|
255
|
-
continue;
|
|
256
|
-
}
|
|
257
|
-
const startingWord = input.match(/^([a-zA-Z_][a-zA-Z0-9_.]*)/)?.[0];
|
|
258
|
-
if (startingWord) {
|
|
259
|
-
input = input.slice(startingWord.length);
|
|
260
|
-
elements.push(startingWord);
|
|
261
|
-
continue;
|
|
262
|
-
}
|
|
263
|
-
const startingNumber = input.match(/^([0-9]+)/)?.[0];
|
|
264
|
-
if (startingNumber) {
|
|
265
|
-
input = input.slice(startingNumber.length);
|
|
266
|
-
elements.push(startingNumber);
|
|
267
|
-
continue;
|
|
268
|
-
}
|
|
269
|
-
if (input[0] === ">" && elements.at(-1) === "=") {
|
|
270
|
-
elements.pop();
|
|
271
|
-
elements.push("=>");
|
|
272
|
-
input = input.slice(1);
|
|
273
|
-
continue;
|
|
274
|
-
}
|
|
275
|
-
elements.push(input[0]);
|
|
276
|
-
input = input.slice(1);
|
|
277
|
-
}
|
|
278
|
-
return elements;
|
|
279
|
-
}
|
|
280
242
|
const wrappers = [
|
|
281
243
|
["(", ")"],
|
|
282
244
|
["[", "]"],
|
|
@@ -332,8 +294,8 @@ function getFirstElement(scan) {
|
|
|
332
294
|
exportFlag = true;
|
|
333
295
|
element = scan.shift();
|
|
334
296
|
if (element === "=") return {
|
|
335
|
-
|
|
336
|
-
|
|
297
|
+
content: scan.shift(),
|
|
298
|
+
type: "export"
|
|
337
299
|
};
|
|
338
300
|
if (element === "as") {
|
|
339
301
|
eraseUntil(scan, ";");
|
|
@@ -347,10 +309,10 @@ function getFirstElement(scan) {
|
|
|
347
309
|
const content = splitUntil(getUntil(scan, "}", 0), ";");
|
|
348
310
|
scan.unshift(";");
|
|
349
311
|
return {
|
|
350
|
-
name,
|
|
351
|
-
type: element,
|
|
352
312
|
content,
|
|
353
|
-
export: exportFlag
|
|
313
|
+
export: exportFlag,
|
|
314
|
+
name,
|
|
315
|
+
type: element
|
|
354
316
|
};
|
|
355
317
|
}
|
|
356
318
|
if (element === "function") {
|
|
@@ -380,9 +342,9 @@ function getFirstElement(scan) {
|
|
|
380
342
|
const content = splitUntil(getUntil(scan, "}", 0), ";");
|
|
381
343
|
scan.unshift(";");
|
|
382
344
|
return {
|
|
345
|
+
content,
|
|
383
346
|
name,
|
|
384
|
-
type: "interface"
|
|
385
|
-
content
|
|
347
|
+
type: "interface"
|
|
386
348
|
};
|
|
387
349
|
}
|
|
388
350
|
if (element === "type" && /^[A-Za-z0-9]*$/.test(scan[0])) {
|
|
@@ -407,24 +369,24 @@ function getFirstElement(scan) {
|
|
|
407
369
|
scan.unshift(";");
|
|
408
370
|
return {
|
|
409
371
|
name,
|
|
410
|
-
type: "enum",
|
|
411
372
|
options: Object.fromEntries(content.join("").split(",").filter((item) => item.trim()).map((item) => {
|
|
412
373
|
if (item.includes("=")) {
|
|
413
374
|
const [name, value] = item.split("=");
|
|
414
375
|
return [JSON.parse(value), name];
|
|
415
376
|
}
|
|
416
377
|
return [name, name];
|
|
417
|
-
}))
|
|
378
|
+
})),
|
|
379
|
+
type: "enum"
|
|
418
380
|
};
|
|
419
381
|
}
|
|
420
382
|
if (typeof element === "string" && element.startsWith("/*")) return {
|
|
421
|
-
|
|
422
|
-
|
|
383
|
+
content: cleanComment(element),
|
|
384
|
+
type: "comment"
|
|
423
385
|
};
|
|
424
386
|
for (const wrapper of wrappers) if (element === wrapper[0]) return {
|
|
425
|
-
type: "wrap",
|
|
426
387
|
content: splitUntil(getUntil(scan, wrapper[1]), ";").map((item) => splitUntil(item, ",")).map((item) => splitUntil(item, "|")),
|
|
427
|
-
style: wrapper.join("")
|
|
388
|
+
style: wrapper.join(""),
|
|
389
|
+
type: "wrap"
|
|
428
390
|
};
|
|
429
391
|
return element;
|
|
430
392
|
}
|
|
@@ -447,32 +409,32 @@ function cleanComment(comment) {
|
|
|
447
409
|
return comment.trim();
|
|
448
410
|
}
|
|
449
411
|
function cleanUnion(schema) {
|
|
450
|
-
if (schema.elements.find((element) => [
|
|
412
|
+
if (schema.elements.find((element) => ["undefined", "void"].includes(element.type))) {
|
|
451
413
|
schema.optional = true;
|
|
452
|
-
schema.elements = schema.elements.filter((element) => ![
|
|
414
|
+
schema.elements = schema.elements.filter((element) => !["undefined", "void"].includes(element.type));
|
|
453
415
|
}
|
|
454
|
-
const childUnions = schema.elements.filter((element) => element.type ===
|
|
416
|
+
const childUnions = schema.elements.filter((element) => element.type === "union");
|
|
455
417
|
if (childUnions.length > 0) {
|
|
456
|
-
schema.elements = schema.elements.filter((element) => element.type !==
|
|
418
|
+
schema.elements = schema.elements.filter((element) => element.type !== "union");
|
|
457
419
|
for (const childUnion of childUnions) schema.elements.push(...childUnion.elements);
|
|
458
420
|
}
|
|
459
|
-
const stringElements = schema.elements.filter((element) => element.type ===
|
|
421
|
+
const stringElements = schema.elements.filter((element) => element.type === "string");
|
|
460
422
|
if (stringElements.length > 1) {
|
|
461
423
|
const enumValues = [];
|
|
462
424
|
let anyFlag = false;
|
|
463
425
|
for (const element of stringElements) if (element.enum) enumValues.push(...element.enum);
|
|
464
426
|
else anyFlag = true;
|
|
465
|
-
schema.elements = schema.elements.filter((element) => element.type !==
|
|
427
|
+
schema.elements = schema.elements.filter((element) => element.type !== "string");
|
|
466
428
|
if (anyFlag) schema.elements.push(LogicType.string());
|
|
467
429
|
else schema.elements.push(LogicType.string({ enum: enumValues }));
|
|
468
430
|
}
|
|
469
|
-
const numberElements = schema.elements.filter((element) => element.type ===
|
|
431
|
+
const numberElements = schema.elements.filter((element) => element.type === "number");
|
|
470
432
|
if (numberElements.length > 1) {
|
|
471
433
|
const enumValues = [];
|
|
472
434
|
let anyFlag = false;
|
|
473
435
|
for (const element of numberElements) if (element.enum) enumValues.push(...element.enum);
|
|
474
436
|
else anyFlag = true;
|
|
475
|
-
schema.elements = schema.elements.filter((element) => element.type !==
|
|
437
|
+
schema.elements = schema.elements.filter((element) => element.type !== "number");
|
|
476
438
|
if (anyFlag) schema.elements.push(LogicType.number());
|
|
477
439
|
else schema.elements.push(LogicType.number({ enum: enumValues }));
|
|
478
440
|
}
|
|
@@ -486,6 +448,11 @@ function cleanUnion(schema) {
|
|
|
486
448
|
}
|
|
487
449
|
function cleanInterface(schema) {
|
|
488
450
|
if (schema.className === "Array") return LogicType.array(schema.options.template[0]);
|
|
451
|
+
if (schema.className === "Type" && schema.options?.template?.[0]?.enum?.length) {
|
|
452
|
+
const reference = schema.options.template[0].enum[0];
|
|
453
|
+
const target = (Array.isArray(reference) ? reference.join("") : String(reference)).split("/");
|
|
454
|
+
return LogicType.type(target, schema.optional ? { optional: true } : {});
|
|
455
|
+
}
|
|
489
456
|
if (schema.className === "keyof") return LogicType.string();
|
|
490
457
|
if (schema.className === "Record") return LogicType.object({});
|
|
491
458
|
if (schema.className === "PropertyKey") return LogicType.union([LogicType.string(), LogicType.number()]);
|
|
@@ -497,6 +464,44 @@ function cleanInterface(schema) {
|
|
|
497
464
|
if (["Omit", "Pick"].includes(schema.className)) return LogicUtil[schema.className.toLocaleLowerCase()](schema.options.template[0], schema.options.template[1]?.enum);
|
|
498
465
|
return schema;
|
|
499
466
|
}
|
|
467
|
+
function scanner(input) {
|
|
468
|
+
const elements = [];
|
|
469
|
+
input = input.replaceAll(/ +/g, " ");
|
|
470
|
+
input = input.replaceAll(/\s*\n\s*/g, "\n");
|
|
471
|
+
while (input.length) {
|
|
472
|
+
if ([" ", "\n"].includes(input[0])) {
|
|
473
|
+
input = input.slice(1);
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
if (input.startsWith("/*")) {
|
|
477
|
+
const commentEnd = input.indexOf("*/");
|
|
478
|
+
elements.push(input.slice(0, commentEnd + 2));
|
|
479
|
+
input = input.slice(commentEnd + 2);
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
482
|
+
const startingWord = input.match(/^([a-zA-Z_][a-zA-Z0-9_.]*)/)?.[0];
|
|
483
|
+
if (startingWord) {
|
|
484
|
+
input = input.slice(startingWord.length);
|
|
485
|
+
elements.push(startingWord);
|
|
486
|
+
continue;
|
|
487
|
+
}
|
|
488
|
+
const startingNumber = input.match(/^([0-9]+)/)?.[0];
|
|
489
|
+
if (startingNumber) {
|
|
490
|
+
input = input.slice(startingNumber.length);
|
|
491
|
+
elements.push(startingNumber);
|
|
492
|
+
continue;
|
|
493
|
+
}
|
|
494
|
+
if (input[0] === ">" && elements.at(-1) === "=") {
|
|
495
|
+
elements.pop();
|
|
496
|
+
elements.push("=>");
|
|
497
|
+
input = input.slice(1);
|
|
498
|
+
continue;
|
|
499
|
+
}
|
|
500
|
+
elements.push(input[0]);
|
|
501
|
+
input = input.slice(1);
|
|
502
|
+
}
|
|
503
|
+
return elements;
|
|
504
|
+
}
|
|
500
505
|
function parser(element, options = {}) {
|
|
501
506
|
if (typeof element === "string") {
|
|
502
507
|
if (element === "string") return LogicType.string(options);
|
|
@@ -519,8 +524,10 @@ function parser(element, options = {}) {
|
|
|
519
524
|
if (element[1].style === "<>") {
|
|
520
525
|
let template = element[1].content;
|
|
521
526
|
if (!Array.isArray(template)) template = [template];
|
|
522
|
-
if (!Array.isArray(template[0]))
|
|
523
|
-
|
|
527
|
+
if (!Array.isArray(template[0])) {
|
|
528
|
+
if (template.some((element) => element.type === "wrap" && element.style === "[]") || template.some((element) => element.type === "wrap" && element.style === "<>") || template.includes("&") || template.includes("|")) template = [template];
|
|
529
|
+
else template = template.map((element) => [element]);
|
|
530
|
+
}
|
|
524
531
|
template = template.map((element) => parser(element));
|
|
525
532
|
return cleanInterface(LogicType.interface(element[0], {
|
|
526
533
|
...options,
|
|
@@ -587,13 +594,13 @@ function schemaLoop(schema, func, key) {
|
|
|
587
594
|
key,
|
|
588
595
|
schema
|
|
589
596
|
}) || schema;
|
|
590
|
-
if (schema.type ===
|
|
591
|
-
if (schema.type ===
|
|
592
|
-
if (schema.type ===
|
|
597
|
+
if (schema.type === "object") for (const key in schema.properties) schema.properties[key] = schemaLoop(schema.properties[key], func, key);
|
|
598
|
+
if (schema.type === "array") schema.items = schemaLoop(schema.items, func);
|
|
599
|
+
if (schema.type === "function") {
|
|
593
600
|
schema.inputs = schemaLoop(schema.inputs, func);
|
|
594
601
|
schema.output = schemaLoop(schema.output, func);
|
|
595
602
|
}
|
|
596
|
-
if (schema.type ===
|
|
603
|
+
if (schema.type === "union") for (const key in schema.elements) schema.elements[key] = schemaLoop(schema.elements[key], func);
|
|
597
604
|
return schema;
|
|
598
605
|
}
|
|
599
606
|
//#endregion
|
package/dist/extractor.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { l as TSchema } from "./index-
|
|
1
|
+
import { l as TSchema } from "./index-DQhxmFHB.mjs";
|
|
2
2
|
import * as ts$1 from "typescript";
|
|
3
3
|
import ts from "typescript";
|
|
4
|
-
|
|
5
4
|
//#region src/extractor/export/type.d.ts
|
|
6
5
|
type TExportResult = {
|
|
7
6
|
components: Record<string, TExportComponent>;
|
|
@@ -38,7 +37,7 @@ type TExportType = {
|
|
|
38
37
|
};
|
|
39
38
|
//#endregion
|
|
40
39
|
//#region src/extractor/export/index.d.ts
|
|
41
|
-
declare class CTypeExport {
|
|
40
|
+
export declare class CTypeExport {
|
|
42
41
|
program: ts.Program;
|
|
43
42
|
checker: ts.TypeChecker;
|
|
44
43
|
index?: ts.SourceFile;
|
|
@@ -71,15 +70,14 @@ type TExportLogicResult = {
|
|
|
71
70
|
functions: Record<string, TExportNodeFunction>;
|
|
72
71
|
types: Record<string, TSchema>;
|
|
73
72
|
};
|
|
74
|
-
declare function generateNodes(exportResult: TExportResult, packageName?: string): TExportLogicResult;
|
|
73
|
+
export declare function generateNodes(exportResult: TExportResult, packageName?: string): TExportLogicResult;
|
|
75
74
|
//#endregion
|
|
76
75
|
//#region src/extractor/source.d.ts
|
|
77
|
-
declare function getSourceFile(moduleName: string): {
|
|
76
|
+
export declare function getSourceFile(moduleName: string): {
|
|
78
77
|
program: ts$1.Program;
|
|
79
78
|
sourceFile: ts$1.SourceFile;
|
|
80
79
|
};
|
|
81
80
|
//#endregion
|
|
82
81
|
//#region src/extractor/index.d.ts
|
|
83
|
-
declare function extractFile(filePath: string, target: string): Promise<void>;
|
|
84
|
-
//#endregion
|
|
85
|
-
export { CTypeExport, extractFile, generateNodes, getSourceFile };
|
|
82
|
+
export declare function extractFile(filePath: string, target: string): Promise<void>;
|
|
83
|
+
//#endregion
|
package/dist/extractor.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as typeToSchema, d as objectMap, i as LogicType, l as cleanObject, r as EVarType, s as schemaLoop } from "./dist-
|
|
1
|
+
import { c as typeToSchema, d as objectMap, i as LogicType, l as cleanObject, r as EVarType, s as schemaLoop } from "./dist-Cnje_ZD3.mjs";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import * as ts$1 from "typescript";
|
|
4
4
|
import ts from "typescript";
|
|
@@ -233,6 +233,7 @@ function isUserType(type) {
|
|
|
233
233
|
//#region src/extractor/export/index.ts
|
|
234
234
|
const FLAGS = ts.TypeFormatFlags.WriteArrowStyleSignature | ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope | ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.UseFullyQualifiedType;
|
|
235
235
|
var CTypeExport = class {
|
|
236
|
+
program;
|
|
236
237
|
checker;
|
|
237
238
|
index;
|
|
238
239
|
cache = /* @__PURE__ */ new Set();
|
|
@@ -493,9 +494,7 @@ function generateNodes(exportResult, packageName = "unknown") {
|
|
|
493
494
|
case EVarType.number:
|
|
494
495
|
schema.default = Number(type.default);
|
|
495
496
|
break;
|
|
496
|
-
case EVarType.string:
|
|
497
|
-
schema.default = type.default;
|
|
498
|
-
break;
|
|
497
|
+
case EVarType.string: schema.default = type.default;
|
|
499
498
|
}
|
|
500
499
|
if (schema.type === EVarType.object && !Object.keys(schema.properties).length) schema.customizable = true;
|
|
501
500
|
return schema;
|