@luna-park/plugin 1.0.1 → 1.0.3

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.
@@ -0,0 +1,394 @@
1
+ function x(e) {
2
+ if (typeof e != "object")
3
+ return e;
4
+ try {
5
+ return JSON.parse(JSON.stringify(e));
6
+ } catch {
7
+ return structuredClone(e);
8
+ }
9
+ }
10
+ function y(e, n) {
11
+ return e ? Object.fromEntries(
12
+ Object.entries(e).map(([r, o]) => [r, n({ key: r, value: o })])
13
+ ) : {};
14
+ }
15
+ function d(e, n) {
16
+ return e ? Object.fromEntries(
17
+ Object.entries(e).filter(([r, o]) => n({ key: r, value: o }))
18
+ ) : {};
19
+ }
20
+ function Z(e) {
21
+ e = x(e);
22
+ for (const r in e)
23
+ n(e, r);
24
+ function n(r, o) {
25
+ if (typeof r[o] == "object") {
26
+ for (const i in r[o])
27
+ n(r[o], i);
28
+ Object.keys(r[o]).length === 0 && delete r[o];
29
+ }
30
+ }
31
+ return e;
32
+ }
33
+ var f = /* @__PURE__ */ ((e) => (e.exec = "exec", e.number = "number", e.string = "string", e.boolean = "boolean", e.object = "object", e.record = "record", e.array = "array", e.interface = "interface", e.type = "type", e.function = "function", e.union = "union", e.unknown = "unknown", e.undefined = "undefined", e.void = "void", e))(f || {});
34
+ const t = {
35
+ type: (e, n = {}) => ({ ...n, type: "type", target: e }),
36
+ array: (e, n = {}) => ({ ...n, type: "array", items: e }),
37
+ boolean: (e = {}) => ({
38
+ ...e,
39
+ type: "boolean"
40
+ /* boolean */
41
+ }),
42
+ exec: (e = {}) => ({
43
+ ...e,
44
+ type: "exec"
45
+ /* exec */
46
+ }),
47
+ function: (e = { type: "object", properties: {} }, n = {
48
+ type: "void"
49
+ /* void */
50
+ }, r = {}) => ({ ...r, type: "function", inputs: e, output: n }),
51
+ interface: (e, n = {}) => ({
52
+ ...n,
53
+ type: "interface",
54
+ className: typeof e == "string" ? e : e.name
55
+ }),
56
+ number: (e = {}) => ({
57
+ ...e,
58
+ type: "number"
59
+ /* number */
60
+ }),
61
+ object: (e = {}, n = {}) => ({ ...n, type: "object", properties: e }),
62
+ record: (e, n, r = {}) => ({ ...r, type: "record", key: e, value: n }),
63
+ string: (e = {}) => ({
64
+ ...e,
65
+ type: "string"
66
+ /* string */
67
+ }),
68
+ undefined: (e = {}) => ({
69
+ ...e,
70
+ type: "undefined"
71
+ /* undefined */
72
+ }),
73
+ union: (e, n = {}) => ({ ...n, type: "union", elements: e }),
74
+ unknown: (e = {}) => ({
75
+ ...e,
76
+ type: "unknown"
77
+ /* unknown */
78
+ }),
79
+ void: (e = {}) => ({
80
+ ...e,
81
+ type: "void"
82
+ /* void */
83
+ })
84
+ }, g = {
85
+ omit(e, n) {
86
+ return {
87
+ ...e,
88
+ properties: d(
89
+ e.properties,
90
+ ({ key: r }) => !n.includes(r)
91
+ )
92
+ };
93
+ },
94
+ partial(e, n = !1) {
95
+ return {
96
+ ...e,
97
+ properties: y(
98
+ e.properties,
99
+ ({ value: r }) => ({ ...r, optional: !n || !r.required })
100
+ )
101
+ };
102
+ },
103
+ pick(e, n) {
104
+ return {
105
+ ...e,
106
+ properties: d(
107
+ e.properties,
108
+ ({ key: r }) => n.includes(r)
109
+ )
110
+ };
111
+ },
112
+ promise(e) {
113
+ return { ...e, promise: !0 };
114
+ },
115
+ required(e) {
116
+ return {
117
+ ...e,
118
+ properties: y(
119
+ e.properties,
120
+ ({ value: n }) => ({ ...n, optional: !1 })
121
+ )
122
+ };
123
+ }
124
+ };
125
+ var z = /* @__PURE__ */ ((e) => (e.function = "function", e.macro = "macro", e.operation = "operation", e))(z || {}), W = /* @__PURE__ */ ((e) => (e.Frontend = "frontend", e.Backend = "backend", e.Desktop = "desktop", e.Shared = "shared", e))(W || {});
126
+ function q(e) {
127
+ return e;
128
+ }
129
+ function b(e) {
130
+ const n = [];
131
+ for (e = e.replaceAll(/ +/g, " "), e = e.replaceAll(/\s*\n\s*/g, `
132
+ `); e.length; ) {
133
+ if ([" ", `
134
+ `].includes(e[0])) {
135
+ e = e.slice(1);
136
+ continue;
137
+ }
138
+ if (e.startsWith("/*")) {
139
+ const i = e.indexOf("*/");
140
+ n.push(e.slice(0, i + 2)), e = e.slice(i + 2);
141
+ continue;
142
+ }
143
+ const r = e.match(/^([a-zA-Z_][a-zA-Z0-9_.]*)/)?.[0];
144
+ if (r) {
145
+ e = e.slice(r.length), n.push(r);
146
+ continue;
147
+ }
148
+ const o = e.match(/^([0-9]+)/)?.[0];
149
+ if (o) {
150
+ e = e.slice(o.length), n.push(o);
151
+ continue;
152
+ }
153
+ if (e[0] === ">" && n.at(-1) === "=") {
154
+ n.pop(), n.push("=>"), e = e.slice(1);
155
+ continue;
156
+ }
157
+ n.push(e[0]), e = e.slice(1);
158
+ }
159
+ return n;
160
+ }
161
+ const v = [
162
+ ["(", ")"],
163
+ ["[", "]"],
164
+ ["{", "}"],
165
+ ["<", ">"],
166
+ ["'", "'"],
167
+ ['"', '"']
168
+ ];
169
+ function j(e) {
170
+ return m(a(e, ";"));
171
+ }
172
+ function p(e, n, r = 1) {
173
+ const o = [];
174
+ for (v.find((i) => i[1] === n)?.[0]; e.length && (e[0], !(e[0] === n && (r--, r <= 0))); ) {
175
+ const i = h(e);
176
+ if (o.push(i), r === 0 && typeof i == "object" && i.type === "wrap" && i.style.endsWith(n))
177
+ break;
178
+ }
179
+ return e.shift(), o;
180
+ }
181
+ function E(e, n) {
182
+ for (; e.length; ) {
183
+ if (e[0] === n) {
184
+ e.shift();
185
+ break;
186
+ }
187
+ e.shift();
188
+ }
189
+ }
190
+ function a(e, n) {
191
+ const r = [[]];
192
+ for (; e.length; ) {
193
+ if (e[0] === n) {
194
+ r.push([]), e.shift();
195
+ continue;
196
+ }
197
+ r.at(-1).push(h(e));
198
+ }
199
+ return r.filter((o) => o.length);
200
+ }
201
+ function h(e) {
202
+ let n = e.shift(), r = !1;
203
+ if (n === "export") {
204
+ if (r = !0, n = e.shift(), n === "=")
205
+ return { type: "export", content: e.shift() };
206
+ if (n === "as")
207
+ return E(e, ";"), h(e);
208
+ }
209
+ if (n === "declare" && (n = e.shift()), n === "namespace") {
210
+ const o = e.shift();
211
+ e.shift();
212
+ const i = a(p(e, "}", 0), ";");
213
+ return e.unshift(";"), { name: o, type: n, content: i, export: r };
214
+ }
215
+ if (n === "function") {
216
+ const o = e.shift(), i = e.shift(), s = { name: o, type: n };
217
+ i === "<" && (s.template = p(e, ">"), e.shift());
218
+ const u = a(p(e, ")", 0), ",");
219
+ return s.export = r, s.params = u, e[0] === ":" && (e.shift(), s.returns = p(e, ";")), e.unshift(";"), s;
220
+ }
221
+ if (n === "interface") {
222
+ const o = e.shift();
223
+ e.shift();
224
+ const i = a(p(e, "}", 0), ";");
225
+ return e.unshift(";"), { name: o, type: "interface", content: i };
226
+ }
227
+ if (n === "type" && /^[A-Za-z0-9]*$/.test(e[0])) {
228
+ const o = e.shift(), i = e.shift(), s = { name: o, type: n };
229
+ return i === "<" && (s.template = p(e, ">"), e.shift()), s.content = p(e, ";"), e.unshift(";"), s;
230
+ }
231
+ if (n === "enum") {
232
+ const o = e.shift();
233
+ e.shift();
234
+ const i = p(e, "}");
235
+ e.unshift(";");
236
+ const s = Object.fromEntries(i.join("").split(",").filter((u) => u.trim()).map((u) => {
237
+ if (u.includes("=")) {
238
+ const [O, N] = u.split("=");
239
+ return [JSON.parse(N), O];
240
+ }
241
+ return [o, o];
242
+ }));
243
+ return { name: o, type: "enum", options: s };
244
+ }
245
+ if (typeof n == "string" && n.startsWith("/*"))
246
+ return { type: "comment", content: F(n) };
247
+ for (const o of v)
248
+ if (n === o[0])
249
+ return {
250
+ type: "wrap",
251
+ content: a(p(e, o[1]), ";").map((i) => a(i, ",")).map((i) => a(i, "|")),
252
+ style: o.join("")
253
+ };
254
+ return n;
255
+ }
256
+ function m(e) {
257
+ return Array.isArray(e) ? e.length === 1 ? m(e[0]) : e.map((n) => m(n)) : typeof e == "object" && e !== null ? y(e, ({ value: n }) => m(n)) : e;
258
+ }
259
+ function F(e) {
260
+ return e = e.trim(), e.startsWith("/**") && e.endsWith("*/") ? (e = e.slice(3, -2).split(`
261
+ `).map((n) => {
262
+ const r = n.trim();
263
+ return r.startsWith("* ") ? r.slice(2) : r;
264
+ }).join(`
265
+ `).trim(), e.trim()) : e;
266
+ }
267
+ function k(e) {
268
+ e.elements.find((i) => [f.undefined, f.void].includes(i.type)) && (e.optional = !0, e.elements = e.elements.filter((i) => ![f.undefined, f.void].includes(i.type)));
269
+ const n = e.elements.filter((i) => i.type === f.union);
270
+ if (n.length > 0) {
271
+ e.elements = e.elements.filter((i) => i.type !== f.union);
272
+ for (const i of n)
273
+ e.elements.push(...i.elements);
274
+ }
275
+ const r = e.elements.filter((i) => i.type === f.string);
276
+ if (r.length > 1) {
277
+ const i = [];
278
+ let s = !1;
279
+ for (const u of r)
280
+ u.enum ? i.push(...u.enum) : s = !0;
281
+ e.elements = e.elements.filter((u) => u.type !== f.string), s ? e.elements.push(t.string()) : e.elements.push(t.string({ enum: i }));
282
+ }
283
+ const o = e.elements.filter((i) => i.type === f.number);
284
+ if (o.length > 1) {
285
+ const i = [];
286
+ let s = !1;
287
+ for (const u of o)
288
+ u.enum ? i.push(...u.enum) : s = !0;
289
+ e.elements = e.elements.filter((u) => u.type !== f.number), s ? e.elements.push(t.number()) : e.elements.push(t.number({ enum: i }));
290
+ }
291
+ if (e.elements.length === 1) {
292
+ const i = e.elements[0];
293
+ return i.optional = e.optional, i;
294
+ }
295
+ return e.elements.length === 0 ? t.void() : e;
296
+ }
297
+ function A(e) {
298
+ return e.className === "Array" ? t.array(e.options.template[0]) : e.className === "keyof" ? t.string() : e.className === "Record" ? t.object({}) : e.className === "PropertyKey" ? t.union([
299
+ t.string(),
300
+ t.number()
301
+ ]) : ["Promise", "Partial", "Required"].includes(e.className) ? g[e.className.toLocaleLowerCase()](e.options.template[0]) : ["Omit", "Pick"].includes(e.className) ? g[e.className.toLocaleLowerCase()](e.options.template[0], e.options.template[1]?.enum) : e;
302
+ }
303
+ function c(e, n = {}) {
304
+ if (typeof e == "string")
305
+ return e === "string" ? t.string(n) : e === "number" ? t.number(n) : e === "boolean" ? t.boolean(n) : e === "undefined" ? t.void(n) : ["unknown", "any"].includes(e) ? t.unknown(n) : ["undefined", "null"].includes(e) ? t.undefined(n) : A(t.interface(e, n));
306
+ if (Array.isArray(e)) {
307
+ if (e[0] === "readonly" && e.shift(), e.length === 1)
308
+ return c(e[0], n);
309
+ if (e.includes("|"))
310
+ return k(t.union(
311
+ w(e, (r) => r === "|").map((r) => c(r)),
312
+ n
313
+ ));
314
+ if (e.includes("&"))
315
+ return k(t.union(
316
+ w(e, (r) => r === "&").map((r) => c(r)),
317
+ n
318
+ ));
319
+ if (e.at(-1)?.type === "wrap" && e.at(-1).style === "[]")
320
+ return t.array(c(e.slice(0, -1)), n);
321
+ if (e[0] === "import" && e[2] === ".")
322
+ return c(e.slice(3), n);
323
+ if (e.length === 2 && e[1].type === "wrap" && e[1].style === "<>") {
324
+ let r = e[1].content;
325
+ return Array.isArray(r) || (r = [r]), Array.isArray(r[0]) || (r.some((o) => o.type === "wrap" && o.style === "[]") || r.some((o) => o.type === "wrap" && o.style === "<>") || r.includes("&") || r.includes("|") ? r = [r] : r = r.map((o) => [o])), r = r.map((o) => c(o)), A(t.interface(e[0], { ...n, options: { template: r } }));
326
+ }
327
+ if (e.length === 3 && e[1] === "=>") {
328
+ const r = !e[0].content.length || Array.isArray(e[0].content[0]) ? e[0].content : [e[0].content];
329
+ return t.function(
330
+ t.object(
331
+ Object.fromEntries(r.map((o) => [o[0], c(o.slice(2))]))
332
+ ),
333
+ c(e[2])
334
+ );
335
+ }
336
+ return c(e[0], n);
337
+ }
338
+ if (typeof e == "object" && e !== null && e.type === "wrap") {
339
+ if (["''", '""'].includes(e.style))
340
+ return t.string({ ...n, enum: [e.content] });
341
+ if (e.style === "{}") {
342
+ const r = !e.content.length || Array.isArray(e.content[0]) ? e.content : [e.content];
343
+ return t.object(
344
+ Object.fromEntries(
345
+ r.filter((o) => typeof o[0] == "string").map((o) => [o[0], o[1] === "?" ? c(o.slice(3), { optional: !0 }) : c(o.slice(2))])
346
+ ),
347
+ n
348
+ );
349
+ }
350
+ if (e.style === "[]")
351
+ return e.content[1] === ":" ? t.array(c(e.content.slice(2)), n) : t.array(c(e.content), n);
352
+ if (e.style === "()")
353
+ return c(e.content, n);
354
+ }
355
+ return console.log("Unknown element"), console.log(e), t.unknown();
356
+ }
357
+ function w(e, n) {
358
+ const r = [[]];
359
+ for (const o of e)
360
+ n(o) ? r.push([]) : r[r.length - 1].push(o);
361
+ return r;
362
+ }
363
+ function J(e) {
364
+ try {
365
+ if (/^[A-Za-z]+\??:/.test(e)) {
366
+ const [, n, r, o] = e.match(/([A-Za-z]+)(\??):(.*)/), i = c(j(b(o)));
367
+ return i.name = n, r === "?" && (i.optional = !0), i;
368
+ }
369
+ return c(j(b(e)));
370
+ } catch (n) {
371
+ return console.error("Failed to parse type", e), console.error(n), t.unknown();
372
+ }
373
+ }
374
+ function l(e, n) {
375
+ if (e = n(e) || e, e.type === f.object)
376
+ for (const r in e.properties)
377
+ e.properties[r] = l(e.properties[r], n);
378
+ if (e.type === f.array && (e.items = l(e.items, n)), e.type === f.function && (e.inputs = l(e.inputs, n), e.output = l(e.output, n)), e.type === f.union)
379
+ for (const r in e.elements)
380
+ e.elements[r] = l(e.elements[r], n);
381
+ return e;
382
+ }
383
+ export {
384
+ Z as F,
385
+ W as J,
386
+ q as T,
387
+ z as _,
388
+ J as a,
389
+ l as d,
390
+ f as i,
391
+ y as o,
392
+ t as u,
393
+ g as x
394
+ };
@@ -0,0 +1,5 @@
1
+ "use strict";function W(e){if(typeof e!="object")return e;try{return JSON.parse(JSON.stringify(e))}catch{return structuredClone(e)}}function y(e,n){return e?Object.fromEntries(Object.entries(e).map(([r,o])=>[r,n({key:r,value:o})])):{}}function g(e,n){return e?Object.fromEntries(Object.entries(e).filter(([r,o])=>n({key:r,value:o}))):{}}function E(e){e=W(e);for(const r in e)n(e,r);function n(r,o){if(typeof r[o]=="object"){for(const i in r[o])n(r[o],i);Object.keys(r[o]).length===0&&delete r[o]}}return e}var f=(e=>(e.exec="exec",e.number="number",e.string="string",e.boolean="boolean",e.object="object",e.record="record",e.array="array",e.interface="interface",e.type="type",e.function="function",e.union="union",e.unknown="unknown",e.undefined="undefined",e.void="void",e))(f||{});const t={type:(e,n={})=>({...n,type:"type",target:e}),array:(e,n={})=>({...n,type:"array",items:e}),boolean:(e={})=>({...e,type:"boolean"}),exec:(e={})=>({...e,type:"exec"}),function:(e={type:"object",properties:{}},n={type:"void"},r={})=>({...r,type:"function",inputs:e,output:n}),interface:(e,n={})=>({...n,type:"interface",className:typeof e=="string"?e:e.name}),number:(e={})=>({...e,type:"number"}),object:(e={},n={})=>({...n,type:"object",properties:e}),record:(e,n,r={})=>({...r,type:"record",key:e,value:n}),string:(e={})=>({...e,type:"string"}),undefined:(e={})=>({...e,type:"undefined"}),union:(e,n={})=>({...n,type:"union",elements:e}),unknown:(e={})=>({...e,type:"unknown"}),void:(e={})=>({...e,type:"void"})},h={omit(e,n){return{...e,properties:g(e.properties,({key:r})=>!n.includes(r))}},partial(e,n=!1){return{...e,properties:y(e.properties,({value:r})=>({...r,optional:!n||!r.required}))}},pick(e,n){return{...e,properties:g(e.properties,({key:r})=>n.includes(r))}},promise(e){return{...e,promise:!0}},required(e){return{...e,properties:y(e.properties,({value:n})=>({...n,optional:!1}))}}};var v=(e=>(e.function="function",e.macro="macro",e.operation="operation",e))(v||{}),O=(e=>(e.Frontend="frontend",e.Backend="backend",e.Desktop="desktop",e.Shared="shared",e))(O||{});function F(e){return e}function b(e){const n=[];for(e=e.replaceAll(/ +/g," "),e=e.replaceAll(/\s*\n\s*/g,`
2
+ `);e.length;){if([" ",`
3
+ `].includes(e[0])){e=e.slice(1);continue}if(e.startsWith("/*")){const i=e.indexOf("*/");n.push(e.slice(0,i+2)),e=e.slice(i+2);continue}const r=e.match(/^([a-zA-Z_][a-zA-Z0-9_.]*)/)?.[0];if(r){e=e.slice(r.length),n.push(r);continue}const o=e.match(/^([0-9]+)/)?.[0];if(o){e=e.slice(o.length),n.push(o);continue}if(e[0]===">"&&n.at(-1)==="="){n.pop(),n.push("=>"),e=e.slice(1);continue}n.push(e[0]),e=e.slice(1)}return n}const N=[["(",")"],["[","]"],["{","}"],["<",">"],["'","'"],['"','"']];function j(e){return m(l(e,";"))}function p(e,n,r=1){const o=[];for(N.find(i=>i[1]===n)?.[0];e.length&&(e[0],!(e[0]===n&&(r--,r<=0)));){const i=d(e);if(o.push(i),r===0&&typeof i=="object"&&i.type==="wrap"&&i.style.endsWith(n))break}return e.shift(),o}function J(e,n){for(;e.length;){if(e[0]===n){e.shift();break}e.shift()}}function l(e,n){const r=[[]];for(;e.length;){if(e[0]===n){r.push([]),e.shift();continue}r.at(-1).push(d(e))}return r.filter(o=>o.length)}function d(e){let n=e.shift(),r=!1;if(n==="export"){if(r=!0,n=e.shift(),n==="=")return{type:"export",content:e.shift()};if(n==="as")return J(e,";"),d(e)}if(n==="declare"&&(n=e.shift()),n==="namespace"){const o=e.shift();e.shift();const i=l(p(e,"}",0),";");return e.unshift(";"),{name:o,type:n,content:i,export:r}}if(n==="function"){const o=e.shift(),i=e.shift(),s={name:o,type:n};i==="<"&&(s.template=p(e,">"),e.shift());const u=l(p(e,")",0),",");return s.export=r,s.params=u,e[0]===":"&&(e.shift(),s.returns=p(e,";")),e.unshift(";"),s}if(n==="interface"){const o=e.shift();e.shift();const i=l(p(e,"}",0),";");return e.unshift(";"),{name:o,type:"interface",content:i}}if(n==="type"&&/^[A-Za-z0-9]*$/.test(e[0])){const o=e.shift(),i=e.shift(),s={name:o,type:n};return i==="<"&&(s.template=p(e,">"),e.shift()),s.content=p(e,";"),e.unshift(";"),s}if(n==="enum"){const o=e.shift();e.shift();const i=p(e,"}");e.unshift(";");const s=Object.fromEntries(i.join("").split(",").filter(u=>u.trim()).map(u=>{if(u.includes("=")){const[x,z]=u.split("=");return[JSON.parse(z),x]}return[o,o]}));return{name:o,type:"enum",options:s}}if(typeof n=="string"&&n.startsWith("/*"))return{type:"comment",content:Z(n)};for(const o of N)if(n===o[0])return{type:"wrap",content:l(p(e,o[1]),";").map(i=>l(i,",")).map(i=>l(i,"|")),style:o.join("")};return n}function m(e){return Array.isArray(e)?e.length===1?m(e[0]):e.map(n=>m(n)):typeof e=="object"&&e!==null?y(e,({value:n})=>m(n)):e}function Z(e){return e=e.trim(),e.startsWith("/**")&&e.endsWith("*/")?(e=e.slice(3,-2).split(`
4
+ `).map(n=>{const r=n.trim();return r.startsWith("* ")?r.slice(2):r}).join(`
5
+ `).trim(),e.trim()):e}function k(e){e.elements.find(i=>[f.undefined,f.void].includes(i.type))&&(e.optional=!0,e.elements=e.elements.filter(i=>![f.undefined,f.void].includes(i.type)));const n=e.elements.filter(i=>i.type===f.union);if(n.length>0){e.elements=e.elements.filter(i=>i.type!==f.union);for(const i of n)e.elements.push(...i.elements)}const r=e.elements.filter(i=>i.type===f.string);if(r.length>1){const i=[];let s=!1;for(const u of r)u.enum?i.push(...u.enum):s=!0;e.elements=e.elements.filter(u=>u.type!==f.string),s?e.elements.push(t.string()):e.elements.push(t.string({enum:i}))}const o=e.elements.filter(i=>i.type===f.number);if(o.length>1){const i=[];let s=!1;for(const u of o)u.enum?i.push(...u.enum):s=!0;e.elements=e.elements.filter(u=>u.type!==f.number),s?e.elements.push(t.number()):e.elements.push(t.number({enum:i}))}if(e.elements.length===1){const i=e.elements[0];return i.optional=e.optional,i}return e.elements.length===0?t.void():e}function A(e){return e.className==="Array"?t.array(e.options.template[0]):e.className==="keyof"?t.string():e.className==="Record"?t.object({}):e.className==="PropertyKey"?t.union([t.string(),t.number()]):["Promise","Partial","Required"].includes(e.className)?h[e.className.toLocaleLowerCase()](e.options.template[0]):["Omit","Pick"].includes(e.className)?h[e.className.toLocaleLowerCase()](e.options.template[0],e.options.template[1]?.enum):e}function c(e,n={}){if(typeof e=="string")return e==="string"?t.string(n):e==="number"?t.number(n):e==="boolean"?t.boolean(n):e==="undefined"?t.void(n):["unknown","any"].includes(e)?t.unknown(n):["undefined","null"].includes(e)?t.undefined(n):A(t.interface(e,n));if(Array.isArray(e)){if(e[0]==="readonly"&&e.shift(),e.length===1)return c(e[0],n);if(e.includes("|"))return k(t.union(w(e,r=>r==="|").map(r=>c(r)),n));if(e.includes("&"))return k(t.union(w(e,r=>r==="&").map(r=>c(r)),n));if(e.at(-1)?.type==="wrap"&&e.at(-1).style==="[]")return t.array(c(e.slice(0,-1)),n);if(e[0]==="import"&&e[2]===".")return c(e.slice(3),n);if(e.length===2&&e[1].type==="wrap"&&e[1].style==="<>"){let r=e[1].content;return Array.isArray(r)||(r=[r]),Array.isArray(r[0])||(r.some(o=>o.type==="wrap"&&o.style==="[]")||r.some(o=>o.type==="wrap"&&o.style==="<>")||r.includes("&")||r.includes("|")?r=[r]:r=r.map(o=>[o])),r=r.map(o=>c(o)),A(t.interface(e[0],{...n,options:{template:r}}))}if(e.length===3&&e[1]==="=>"){const r=!e[0].content.length||Array.isArray(e[0].content[0])?e[0].content:[e[0].content];return t.function(t.object(Object.fromEntries(r.map(o=>[o[0],c(o.slice(2))]))),c(e[2]))}return c(e[0],n)}if(typeof e=="object"&&e!==null&&e.type==="wrap"){if(["''",'""'].includes(e.style))return t.string({...n,enum:[e.content]});if(e.style==="{}"){const r=!e.content.length||Array.isArray(e.content[0])?e.content:[e.content];return t.object(Object.fromEntries(r.filter(o=>typeof o[0]=="string").map(o=>[o[0],o[1]==="?"?c(o.slice(3),{optional:!0}):c(o.slice(2))])),n)}if(e.style==="[]")return e.content[1]===":"?t.array(c(e.content.slice(2)),n):t.array(c(e.content),n);if(e.style==="()")return c(e.content,n)}return console.log("Unknown element"),console.log(e),t.unknown()}function w(e,n){const r=[[]];for(const o of e)n(o)?r.push([]):r[r.length-1].push(o);return r}function q(e){try{if(/^[A-Za-z]+\??:/.test(e)){const[,n,r,o]=e.match(/([A-Za-z]+)(\??):(.*)/),i=c(j(b(o)));return i.name=n,r==="?"&&(i.optional=!0),i}return c(j(b(e)))}catch(n){return console.error("Failed to parse type",e),console.error(n),t.unknown()}}function a(e,n){if(e=n(e)||e,e.type===f.object)for(const r in e.properties)e.properties[r]=a(e.properties[r],n);if(e.type===f.array&&(e.items=a(e.items,n)),e.type===f.function&&(e.inputs=a(e.inputs,n),e.output=a(e.output,n)),e.type===f.union)for(const r in e.elements)e.elements[r]=a(e.elements[r],n);return e}exports.F=E;exports.J=O;exports.T=F;exports._=v;exports.d=a;exports.i=f;exports.ot=y;exports.ot$1=q;exports.u=t;exports.x=h;
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-DmZsz62R.cjs");function o(e){return e}async function r(e,n){return typeof e=="function"?e({app:n.app,config:n.config,internal:n.internal,mode:n.mode||"editor"}):e}exports.ELogicScope=i.J;exports.ELogicType=i._;exports.EVarType=i.i;exports.LogicType=i.u;exports.LogicUtil=i.x;exports.makeLogicNode=i.T;exports.getPluginParam=r;exports.makePlugin=o;