@luna-park/plugin 1.1.0 → 1.2.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.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("node:fs"),p=require("./index-4fa4mAH8.cjs"),f=require("typescript"),U=require("path"),q=require("fs");function j(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const o in t)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(e,o,n.get?n:{enumerable:!0,get:()=>t[o]})}}return e.default=t,Object.freeze(e)}const m=j(f),O=j(U),J=j(q);function T(t,e={}){if(typeof t!="object"||t===null)return JSON.stringify(t);const o={};for(const n of["default","description","name","target","promise","optional","example","enum"])t[n]&&(o[n]=t[n]);if(t.type===p.i.array)return S(`LogicType.${t.type}`,[T(t.items,e),d(o)]);if(t.type===p.i.interface)return S(`LogicType.${t.type}`,[JSON.stringify(t.className),d(o)]);if(t.type===p.i.union)return S(`LogicType.${t.type}`,[`[${t.elements.map(n=>T(n,e)).join(", ")}]`,d(o)]);if(t.type===p.i.function)return S(`LogicType.${t.type}`,[T(t.inputs,e),T(t.output,e),d(o)]);if(t.type===p.i.object)return S(`LogicType.${t.type}`,[d(p.ot(t.properties,({value:n})=>T(n,e)),!0),d(o)]);if(t.type===p.i.type){const n=t.target.at(-1),i=d(o);return i!=="{}"?n:`{ ...${n}, ${i.slice(1,-1)} }`}return S(`LogicType.${t.type}`,[d(o)])}function S(t,e){const o=e.findLastIndex(n=>n!=="{}");return`${t}(${e.slice(0,o+1).join(", ")})`}function d(t,e){return`{${Object.entries(t).map(([o,n])=>`${P(o)}: ${e?n:JSON.stringify(n)}`).join(", ")}}`}function P(t){return/^[a-zA-Z]+$/.test(t)?t:JSON.stringify(t)}function V(t,e){const o=[],n=t.components.default;Object.keys(t.types);for(const r of["properties","slots","models","emits"])n[r]&&Object.keys(n[r]).length&&o.push({key:r,value:Object.entries(n[r]).map(([l,s])=>`${P(l)}: ${T(s,{})}`).join(`,
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("node:fs"),p=require("./index-CWrYVK_G.cjs"),f=require("typescript"),U=require("path"),q=require("fs");function j(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const o in t)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(e,o,n.get?n:{enumerable:!0,get:()=>t[o]})}}return e.default=t,Object.freeze(e)}const m=j(f),O=j(U),J=j(q);function T(t,e={}){if(typeof t!="object"||t===null)return JSON.stringify(t);const o={};for(const n of["default","description","name","target","promise","optional","example","enum"])t[n]&&(o[n]=t[n]);if(t.type===p.i.array)return S(`LogicType.${t.type}`,[T(t.items,e),d(o)]);if(t.type===p.i.interface)return S(`LogicType.${t.type}`,[JSON.stringify(t.className),d(o)]);if(t.type===p.i.union)return S(`LogicType.${t.type}`,[`[${t.elements.map(n=>T(n,e)).join(", ")}]`,d(o)]);if(t.type===p.i.function)return S(`LogicType.${t.type}`,[T(t.inputs,e),T(t.output,e),d(o)]);if(t.type===p.i.object)return S(`LogicType.${t.type}`,[d(p.ot(t.properties,({value:n})=>T(n,e)),!0),d(o)]);if(t.type===p.i.type){const n=t.target.at(-1),i=d(o);return i!=="{}"?n:`{ ...${n}, ${i.slice(1,-1)} }`}return S(`LogicType.${t.type}`,[d(o)])}function S(t,e){const o=e.findLastIndex(n=>n!=="{}");return`${t}(${e.slice(0,o+1).join(", ")})`}function d(t,e){return`{${Object.entries(t).map(([o,n])=>`${P(o)}: ${e?n:JSON.stringify(n)}`).join(", ")}}`}function P(t){return/^[a-zA-Z]+$/.test(t)?t:JSON.stringify(t)}function V(t,e){const o=[],n=t.components.default;Object.keys(t.types);for(const r of["properties","slots","models","emits"])n[r]&&Object.keys(n[r]).length&&o.push({key:r,value:Object.entries(n[r]).map(([l,s])=>`${P(l)}: ${T(s,{})}`).join(`,
2
2
  `)});const i=Object.entries(t.types).map(([r,l])=>`const ${r} = ${T(l,{})};`).join(`
3
3
 
4
4
  `);return`import { LogicType, type TComponent } from "@luna-park/plugin";
package/dist/extractor.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import M from "node:fs";
2
- import { i as m, o as F, F as d, u as x, a as I, m as U } from "./index-QMG2c0JW.js";
2
+ import { i as m, o as F, F as d, u as x, a as I, m as U } from "./index-Dv9uuje9.js";
3
3
  import * as y from "typescript";
4
4
  import p from "typescript";
5
5
  import * as j from "path";
@@ -0,0 +1,5 @@
1
+ "use strict";function E(e){if(typeof e!="object")return e;try{return JSON.parse(JSON.stringify(e))}catch{return structuredClone(e)}}function h(e){if(Array.isArray(e))return e.map(h);if(typeof e!="object")return e;const n={};for(const[r,o]of Object.entries(e)){if(typeof o=="function"){n[r]=o;continue}n[r]=h(o)}return n}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 J(e){e=E(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"})},d={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 O=(e=>(e.function="function",e.macro="macro",e.operation="operation",e))(O||{}),N=(e=>(e.Frontend="frontend",e.Backend="backend",e.Desktop="desktop",e.Shared="shared",e))(N||{});function Z(e){return e}function j(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 x=[["(",")"],["[","]"],["{","}"],["<",">"],["'","'"],['"','"']];function k(e){return m(a(e,";"))}function p(e,n,r=1){const o=[];for(x.find(i=>i[1]===n)?.[0];e.length&&(e[0],!(e[0]===n&&(r--,r<=0)));){const i=b(e);if(o.push(i),r===0&&typeof i=="object"&&i.type==="wrap"&&i.style.endsWith(n))break}return e.shift(),o}function q(e,n){for(;e.length;){if(e[0]===n){e.shift();break}e.shift()}}function a(e,n){const r=[[]];for(;e.length;){if(e[0]===n){r.push([]),e.shift();continue}r.at(-1).push(b(e))}return r.filter(o=>o.length)}function b(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 q(e,";"),b(e)}if(n==="declare"&&(n=e.shift()),n==="namespace"){const o=e.shift();e.shift();const i=a(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=a(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=a(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[z,W]=u.split("=");return[JSON.parse(W),z]}return[o,o]}));return{name:o,type:"enum",options:s}}if(typeof n=="string"&&n.startsWith("/*"))return{type:"comment",content:F(n)};for(const o of x)if(n===o[0])return{type:"wrap",content:a(p(e,o[1]),";").map(i=>a(i,",")).map(i=>a(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 F(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 A(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 w(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)?d[e.className.toLocaleLowerCase()](e.options.template[0]):["Omit","Pick"].includes(e.className)?d[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):w(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 A(t.union(v(e,r=>r==="|").map(r=>c(r)),n));if(e.includes("&"))return A(t.union(v(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)),w(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 v(e,n){const r=[[]];for(const o of e)n(o)?r.push([]):r[r.length-1].push(o);return r}function L(e){try{if(/^[A-Za-z]+\??:/.test(e)){const[,n,r,o]=e.match(/([A-Za-z]+)(\??):(.*)/),i=c(k(j(o)));return i.name=n,r==="?"&&(i.optional=!0),i}return c(k(j(e)))}catch(n){return console.error("Failed to parse type",e),console.error(n),t.unknown()}}function l(e,n){if(e=n(e)||e,e.type===f.object)for(const r in e.properties)e.properties[r]=l(e.properties[r],n);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)for(const r in e.elements)e.elements[r]=l(e.elements[r],n);return e}exports.F=J;exports.J=N;exports.T=Z;exports._=O;exports.i=f;exports.m=l;exports.ot=y;exports.ot$1=L;exports.u=t;exports.x=d;exports.y=h;
@@ -1,4 +1,4 @@
1
- function x(e) {
1
+ function z(e) {
2
2
  if (typeof e != "object")
3
3
  return e;
4
4
  try {
@@ -7,18 +7,33 @@ function x(e) {
7
7
  return structuredClone(e);
8
8
  }
9
9
  }
10
+ function d(e) {
11
+ if (Array.isArray(e))
12
+ return e.map(d);
13
+ if (typeof e != "object")
14
+ return e;
15
+ const n = {};
16
+ for (const [r, o] of Object.entries(e)) {
17
+ if (typeof o == "function") {
18
+ n[r] = o;
19
+ continue;
20
+ }
21
+ n[r] = d(o);
22
+ }
23
+ return n;
24
+ }
10
25
  function y(e, n) {
11
26
  return e ? Object.fromEntries(
12
27
  Object.entries(e).map(([r, o]) => [r, n({ key: r, value: o })])
13
28
  ) : {};
14
29
  }
15
- function d(e, n) {
30
+ function b(e, n) {
16
31
  return e ? Object.fromEntries(
17
32
  Object.entries(e).filter(([r, o]) => n({ key: r, value: o }))
18
33
  ) : {};
19
34
  }
20
- function q(e) {
21
- e = x(e);
35
+ function J(e) {
36
+ e = z(e);
22
37
  for (const r in e)
23
38
  n(e, r);
24
39
  function n(r, o) {
@@ -85,7 +100,7 @@ const t = {
85
100
  omit(e, n) {
86
101
  return {
87
102
  ...e,
88
- properties: d(
103
+ properties: b(
89
104
  e.properties,
90
105
  ({ key: r }) => !n.includes(r)
91
106
  )
@@ -103,7 +118,7 @@ const t = {
103
118
  pick(e, n) {
104
119
  return {
105
120
  ...e,
106
- properties: d(
121
+ properties: b(
107
122
  e.properties,
108
123
  ({ key: r }) => n.includes(r)
109
124
  )
@@ -122,11 +137,11 @@ const t = {
122
137
  };
123
138
  }
124
139
  };
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 J(e) {
140
+ var W = /* @__PURE__ */ ((e) => (e.function = "function", e.macro = "macro", e.operation = "operation", e))(W || {}), E = /* @__PURE__ */ ((e) => (e.Frontend = "frontend", e.Backend = "backend", e.Desktop = "desktop", e.Shared = "shared", e))(E || {});
141
+ function L(e) {
127
142
  return e;
128
143
  }
129
- function b(e) {
144
+ function j(e) {
130
145
  const n = [];
131
146
  for (e = e.replaceAll(/ +/g, " "), e = e.replaceAll(/\s*\n\s*/g, `
132
147
  `); e.length; ) {
@@ -158,7 +173,7 @@ function b(e) {
158
173
  }
159
174
  return n;
160
175
  }
161
- const v = [
176
+ const O = [
162
177
  ["(", ")"],
163
178
  ["[", "]"],
164
179
  ["{", "}"],
@@ -166,19 +181,19 @@ const v = [
166
181
  ["'", "'"],
167
182
  ['"', '"']
168
183
  ];
169
- function j(e) {
184
+ function k(e) {
170
185
  return m(a(e, ";"));
171
186
  }
172
187
  function p(e, n, r = 1) {
173
188
  const o = [];
174
- for (v.find((i) => i[1] === n)?.[0]; e.length && (e[0], !(e[0] === n && (r--, r <= 0))); ) {
189
+ for (O.find((i) => i[1] === n)?.[0]; e.length && (e[0], !(e[0] === n && (r--, r <= 0))); ) {
175
190
  const i = h(e);
176
191
  if (o.push(i), r === 0 && typeof i == "object" && i.type === "wrap" && i.style.endsWith(n))
177
192
  break;
178
193
  }
179
194
  return e.shift(), o;
180
195
  }
181
- function E(e, n) {
196
+ function Z(e, n) {
182
197
  for (; e.length; ) {
183
198
  if (e[0] === n) {
184
199
  e.shift();
@@ -204,7 +219,7 @@ function h(e) {
204
219
  if (r = !0, n = e.shift(), n === "=")
205
220
  return { type: "export", content: e.shift() };
206
221
  if (n === "as")
207
- return E(e, ";"), h(e);
222
+ return Z(e, ";"), h(e);
208
223
  }
209
224
  if (n === "declare" && (n = e.shift()), n === "namespace") {
210
225
  const o = e.shift();
@@ -235,16 +250,16 @@ function h(e) {
235
250
  e.unshift(";");
236
251
  const s = Object.fromEntries(i.join("").split(",").filter((u) => u.trim()).map((u) => {
237
252
  if (u.includes("=")) {
238
- const [O, N] = u.split("=");
239
- return [JSON.parse(N), O];
253
+ const [N, x] = u.split("=");
254
+ return [JSON.parse(x), N];
240
255
  }
241
256
  return [o, o];
242
257
  }));
243
258
  return { name: o, type: "enum", options: s };
244
259
  }
245
260
  if (typeof n == "string" && n.startsWith("/*"))
246
- return { type: "comment", content: Z(n) };
247
- for (const o of v)
261
+ return { type: "comment", content: q(n) };
262
+ for (const o of O)
248
263
  if (n === o[0])
249
264
  return {
250
265
  type: "wrap",
@@ -256,7 +271,7 @@ function h(e) {
256
271
  function m(e) {
257
272
  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
273
  }
259
- function Z(e) {
274
+ function q(e) {
260
275
  return e = e.trim(), e.startsWith("/**") && e.endsWith("*/") ? (e = e.slice(3, -2).split(`
261
276
  `).map((n) => {
262
277
  const r = n.trim();
@@ -264,7 +279,7 @@ function Z(e) {
264
279
  }).join(`
265
280
  `).trim(), e.trim()) : e;
266
281
  }
267
- function k(e) {
282
+ function A(e) {
268
283
  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
284
  const n = e.elements.filter((i) => i.type === f.union);
270
285
  if (n.length > 0) {
@@ -294,7 +309,7 @@ function k(e) {
294
309
  }
295
310
  return e.elements.length === 0 ? t.void() : e;
296
311
  }
297
- function A(e) {
312
+ function w(e) {
298
313
  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
314
  t.string(),
300
315
  t.number()
@@ -302,18 +317,18 @@ function A(e) {
302
317
  }
303
318
  function c(e, n = {}) {
304
319
  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));
320
+ 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) : w(t.interface(e, n));
306
321
  if (Array.isArray(e)) {
307
322
  if (e[0] === "readonly" && e.shift(), e.length === 1)
308
323
  return c(e[0], n);
309
324
  if (e.includes("|"))
310
- return k(t.union(
311
- w(e, (r) => r === "|").map((r) => c(r)),
325
+ return A(t.union(
326
+ v(e, (r) => r === "|").map((r) => c(r)),
312
327
  n
313
328
  ));
314
329
  if (e.includes("&"))
315
- return k(t.union(
316
- w(e, (r) => r === "&").map((r) => c(r)),
330
+ return A(t.union(
331
+ v(e, (r) => r === "&").map((r) => c(r)),
317
332
  n
318
333
  ));
319
334
  if (e.at(-1)?.type === "wrap" && e.at(-1).style === "[]")
@@ -322,7 +337,7 @@ function c(e, n = {}) {
322
337
  return c(e.slice(3), n);
323
338
  if (e.length === 2 && e[1].type === "wrap" && e[1].style === "<>") {
324
339
  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 } }));
340
+ 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)), w(t.interface(e[0], { ...n, options: { template: r } }));
326
341
  }
327
342
  if (e.length === 3 && e[1] === "=>") {
328
343
  const r = !e[0].content.length || Array.isArray(e[0].content[0]) ? e[0].content : [e[0].content];
@@ -354,19 +369,19 @@ function c(e, n = {}) {
354
369
  }
355
370
  return console.log("Unknown element"), console.log(e), t.unknown();
356
371
  }
357
- function w(e, n) {
372
+ function v(e, n) {
358
373
  const r = [[]];
359
374
  for (const o of e)
360
375
  n(o) ? r.push([]) : r[r.length - 1].push(o);
361
376
  return r;
362
377
  }
363
- function L(e) {
378
+ function P(e) {
364
379
  try {
365
380
  if (/^[A-Za-z]+\??:/.test(e)) {
366
- const [, n, r, o] = e.match(/([A-Za-z]+)(\??):(.*)/), i = c(j(b(o)));
381
+ const [, n, r, o] = e.match(/([A-Za-z]+)(\??):(.*)/), i = c(k(j(o)));
367
382
  return i.name = n, r === "?" && (i.optional = !0), i;
368
383
  }
369
- return c(j(b(e)));
384
+ return c(k(j(e)));
370
385
  } catch (n) {
371
386
  return console.error("Failed to parse type", e), console.error(n), t.unknown();
372
387
  }
@@ -381,14 +396,15 @@ function l(e, n) {
381
396
  return e;
382
397
  }
383
398
  export {
384
- q as F,
385
- W as J,
386
- J as T,
387
- z as _,
388
- L as a,
399
+ J as F,
400
+ E as J,
401
+ L as T,
402
+ W as _,
403
+ P as a,
389
404
  f as i,
390
405
  l as m,
391
406
  y as o,
392
407
  t as u,
393
- g as x
408
+ g as x,
409
+ d as y
394
410
  };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-4fa4mAH8.cjs");var n=(i=>(i.Color="color",i.FontSize="font-size",i.FontWeight="font-weight",i.FontFamily="font-family",i.Length="length",i.Time="time",i))(n||{});function e(i){return i}async function r(i,o){return typeof i=="function"?i({app:o.app,config:o.config,internal:o.internal,mode:o.mode||"editor"}):i}exports.ELogicScope=t.J;exports.ELogicType=t._;exports.EVarType=t.i;exports.LogicType=t.u;exports.LogicUtil=t.x;exports.makeLogicNode=t.T;exports.ETokenType=n;exports.getPluginParam=r;exports.makePlugin=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CWrYVK_G.cjs");var a=(i=>(i.ViteImport="viteImport",i.VitePlugin="vitePlugin",i.AppImport="appImport",i.AppBody="appBody",i.Style="style",i.ServerImport="serverImport",i.ServerBody="serverBody",i))(a||{}),g=(i=>(i.Color="color",i.FontSize="font-size",i.FontWeight="font-weight",i.FontFamily="font-family",i.Length="length",i.Time="time",i))(g||{});function c(i){return i}async function p(i,o){const r=t.y(i),u=o.app?.config?.plugins?.[i.id]?.config;for(const e of["build","editor","inject"])if(r[e])for(const n in r[e])r[e][n]=await l(r[e][n],{...o,config:u});return r}async function l(i,o){return typeof i=="function"?i({app:o.app,config:o.config,internal:o.internal,mode:o.mode||"editor"}):i}exports.ELogicScope=t.J;exports.ELogicType=t._;exports.EVarType=t.i;exports.LogicType=t.u;exports.LogicUtil=t.x;exports.makeLogicNode=t.T;exports.EInjectionKey=a;exports.ETokenType=g;exports.getPluginParam=l;exports.loadPlugin=p;exports.makePlugin=c;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Component } from 'vue';
2
2
  import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
3
- import { PluginOption } from 'vite';
4
3
 
5
4
  declare type Component_2 = {
6
5
  name: string;
@@ -65,6 +64,16 @@ declare enum EHistoryMode {
65
64
  Memory = "memory"
66
65
  }
67
66
 
67
+ export declare enum EInjectionKey {
68
+ ViteImport = "viteImport",
69
+ VitePlugin = "vitePlugin",
70
+ AppImport = "appImport",
71
+ AppBody = "appBody",
72
+ Style = "style",
73
+ ServerImport = "serverImport",
74
+ ServerBody = "serverBody"
75
+ }
76
+
68
77
  declare enum ELayoutElement {
69
78
  input = "input",
70
79
  div = "div",
@@ -150,6 +159,8 @@ export declare enum EVarType {
150
159
 
151
160
  export declare function getPluginParam<T>(target: TOption<TEnv, T>, env: Partial<TEnv>): Promise<T>;
152
161
 
162
+ export declare function loadPlugin<TConfig extends TSchema, TInternal>(plugin: TPlugin<TConfig, TInternal>, env: Partial<TEnv>): Promise<TBasePlugin<TConfig, TInternal>>;
163
+
153
164
  export declare const LogicType: {
154
165
  type: <T extends TSchema>(target: Array<string>, args?: TArguments) => TType<T>;
155
166
  array: <T extends TSchema, TArgs extends TArguments<Array<T>>>(items: T, args?: TArgs) => TArray<T> & TArgs;
@@ -339,6 +350,48 @@ declare interface TArray<T extends TSchema = TSchema> {
339
350
  static: Array<Static<T>>;
340
351
  }
341
352
 
353
+ export declare type TBasePlugin<TConfig extends TSchema = TSchema, TInternal = unknown> = {
354
+ build?: {
355
+ backImports?: Array<{
356
+ name: string;
357
+ version?: string;
358
+ }>;
359
+ frontImports?: Array<{
360
+ name: string;
361
+ version?: string;
362
+ }>;
363
+ injections?: Partial<Record<EInjectionKey, string>>;
364
+ };
365
+ config?: TConfig;
366
+ dependencies?: Array<{
367
+ id: string;
368
+ name: string;
369
+ target: string;
370
+ }>;
371
+ description?: string;
372
+ editor?: {
373
+ components?: Array<TComponent>;
374
+ nodes?: Array<TLogicNode>;
375
+ templates?: Array<TTemplate>;
376
+ tokens?: Array<TToken>;
377
+ wrapper?: TComponent;
378
+ };
379
+ icon: string;
380
+ id: string;
381
+ inject?: {
382
+ css?: string;
383
+ js?: string;
384
+ };
385
+ interface?: Component;
386
+ internal?: TInternal;
387
+ lifecycle?: {
388
+ mount?: (env: TEnv<TConfig, TInternal>) => Promise<void> | void;
389
+ unmount?: (env: TEnv<TConfig, TInternal>) => Promise<void> | void;
390
+ update?: (env: TEnv<TConfig, TInternal>) => Promise<void> | void;
391
+ };
392
+ name: string;
393
+ };
394
+
342
395
  declare interface TBoolean {
343
396
  type: EVarType.boolean;
344
397
  static: boolean;
@@ -755,48 +808,22 @@ declare type TOnlyVarsOf<TNodeInterfaceDescriptor> = {
755
808
  [TAnchor in keyof TNodeInterfaceDescriptor as TNodeInterfaceDescriptor[TAnchor] extends TExec ? never : TAnchor]: TNodeInterfaceDescriptor[TAnchor];
756
809
  };
757
810
 
758
- declare type TOption<TParams = unknown, TResult = unknown> = TResult | ((env: TParams) => Promise<TResult> | TResult | undefined);
811
+ declare type TOption<TParams = unknown, TResult = unknown> = TResult | ((env: TParams) => Promise<TResult> | TResult);
759
812
 
760
- export declare type TPlugin<TConfig extends TSchema = TSchema, TInternal = unknown> = {
761
- build?: {
762
- imports?: TOption<TEnv<TConfig, TInternal>, Array<{
763
- name: string;
764
- version?: string;
765
- }>>;
766
- plugins?: TOption<TEnv<TConfig, TInternal>, Array<PluginOption>>;
767
- };
768
- config?: TConfig;
769
- dependencies?: Array<{
770
- id: string;
771
- name: string;
772
- target: string;
773
- }>;
774
- description?: string;
775
- editor?: {
776
- components?: TOption<TEnv<TConfig, TInternal>, Array<TComponent>>;
777
- nodes?: TOption<TEnv<TConfig, TInternal>, Array<TLogicNode>>;
778
- templates?: TOption<TEnv<TConfig, TInternal>, Array<TTemplate>>;
779
- tokens?: TOption<TEnv<TConfig, TInternal>, Array<TToken>>;
780
- wrapper?: TOption<TEnv<TConfig, TInternal>, TComponent>;
813
+ export declare type TPlugin<TConfig extends TSchema = TSchema, TInternal = unknown, TBase extends TBasePlugin<TConfig, TInternal> = TBasePlugin<TConfig, TInternal>> = Omit<TBase, "build" | "editor" | "inject"> & {
814
+ [TCategory in "build" | "editor" | "inject"]?: {
815
+ [TKey in keyof NonNullable<TBase[TCategory]>]: TOption<TEnv<TConfig, TInternal>, NonNullable<TBase[TCategory]>[TKey]>;
781
816
  };
782
- icon: string;
783
- id: string;
784
- inject?: {
785
- css?: TOption<TEnv<TConfig, TInternal>, string>;
786
- js?: TOption<TEnv<TConfig, TInternal>, string>;
787
- };
788
- interface?: Component;
789
- internal?: TInternal;
790
- lifecycle?: {
791
- mount?: (env: TEnv<TConfig, TInternal>) => Promise<void> | void;
792
- unmount?: (env: TEnv<TConfig, TInternal>) => Promise<void> | void;
793
- update?: (env: TEnv<TConfig, TInternal>) => Promise<void> | void;
794
- };
795
- name: string;
796
817
  };
797
818
 
798
819
  declare type TProperties = Record<string, TSchema>;
799
820
 
821
+ export declare type TProxyPlugin<TConfig extends TSchema = TSchema, TInternal = unknown, TBase extends TBasePlugin<TConfig, TInternal> = TBasePlugin<TConfig, TInternal>> = Omit<TBase, "build" | "editor" | "inject"> & {
822
+ [TCategory in "build" | "editor" | "inject"]?: {
823
+ [TKey in keyof NonNullable<TBase[TCategory]>]: Promise<NonNullable<TBase[TCategory]>[TKey]>;
824
+ };
825
+ };
826
+
800
827
  declare interface TRecord<TKey extends TString | TNumber = TString, TValue extends TSchema = TSchema> {
801
828
  type: EVarType.record;
802
829
  key: TKey;
package/dist/index.js CHANGED
@@ -1,24 +1,35 @@
1
- import { J as e, _ as f, i as g, u as l, x as m, T as u } from "./index-QMG2c0JW.js";
2
- var t = /* @__PURE__ */ ((i) => (i.Color = "color", i.FontSize = "font-size", i.FontWeight = "font-weight", i.FontFamily = "font-family", i.Length = "length", i.Time = "time", i))(t || {});
3
- function n(i) {
4
- return i;
1
+ import { y as p } from "./index-Dv9uuje9.js";
2
+ import { J as d, _ as y, i as L, u as P, x as S, T as h } from "./index-Dv9uuje9.js";
3
+ var e = /* @__PURE__ */ ((o) => (o.ViteImport = "viteImport", o.VitePlugin = "vitePlugin", o.AppImport = "appImport", o.AppBody = "appBody", o.Style = "style", o.ServerImport = "serverImport", o.ServerBody = "serverBody", o))(e || {}), f = /* @__PURE__ */ ((o) => (o.Color = "color", o.FontSize = "font-size", o.FontWeight = "font-weight", o.FontFamily = "font-family", o.Length = "length", o.Time = "time", o))(f || {});
4
+ function l(o) {
5
+ return o;
5
6
  }
6
- async function a(i, o) {
7
- return typeof i == "function" ? i({
8
- app: o.app,
9
- config: o.config,
10
- internal: o.internal,
11
- mode: o.mode || "editor"
12
- }) : i;
7
+ async function m(o, r) {
8
+ const t = p(o), n = r.app?.config?.plugins?.[o.id]?.config;
9
+ for (const i of ["build", "editor", "inject"])
10
+ if (t[i])
11
+ for (const a in t[i])
12
+ t[i][a] = await g(t[i][a], { ...r, config: n });
13
+ return t;
14
+ }
15
+ async function g(o, r) {
16
+ return typeof o == "function" ? o({
17
+ app: r.app,
18
+ config: r.config,
19
+ internal: r.internal,
20
+ mode: r.mode || "editor"
21
+ }) : o;
13
22
  }
14
23
  export {
15
- e as ELogicScope,
16
- f as ELogicType,
17
- t as ETokenType,
18
- g as EVarType,
19
- l as LogicType,
20
- m as LogicUtil,
21
- a as getPluginParam,
22
- u as makeLogicNode,
23
- n as makePlugin
24
+ e as EInjectionKey,
25
+ d as ELogicScope,
26
+ y as ELogicType,
27
+ f as ETokenType,
28
+ L as EVarType,
29
+ P as LogicType,
30
+ S as LogicUtil,
31
+ g as getPluginParam,
32
+ m as loadPlugin,
33
+ h as makeLogicNode,
34
+ l as makePlugin
24
35
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luna-park/plugin",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "private": false,
5
5
  "description": "Plugin helper for Luna Park.",
6
6
  "homepage": "https://luna-park.app",
@@ -50,9 +50,9 @@
50
50
  "vite": "^7.2.7",
51
51
  "vitest": "^4.0.15",
52
52
  "vue": "^3.5.25",
53
- "@luna-park/utils": "^2.0.0",
54
53
  "@luna-park/logicnodes": "^2.0.0",
55
- "@luna-park/shared": "^1.0.0"
54
+ "@luna-park/shared": "^1.0.0",
55
+ "@luna-park/utils": "^2.0.0"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "@fastify/cors": "^11.1.0",
@@ -1,5 +0,0 @@
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 J(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 Z(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 Z(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:q(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 q(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 F(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=J;exports._=v;exports.i=f;exports.m=a;exports.ot=y;exports.ot$1=F;exports.u=t;exports.x=h;