@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.
package/README.md ADDED
@@ -0,0 +1,139 @@
1
+ # @luna-park/plugin
2
+
3
+ This package provides the core types and helper functions for creating plugins for **Luna Park**, a visual scripting platform.
4
+
5
+ It exports the necessary interfaces to define plugin configurations, editor components, logic nodes, and lifecycle hooks.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @luna-park/plugin
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ The primary way to define a plugin is using the `makePlugin` helper function. This ensures type safety for your plugin configuration.
16
+
17
+ ```typescript
18
+ import { makePlugin, ELogicType } from "@luna-park/plugin";
19
+ import awesomeIcon from "./awesome-icon.svg"; // Icon URL
20
+
21
+ // Define your plugin's configuration schema (optional)
22
+ const config = LogicType.object({
23
+ apiKey: LogicType.string(),
24
+ theme: LogicType.string({enum: ["light", "dark"], default: "dark"}),
25
+ }) satisfies TSchema;
26
+
27
+ export default makePlugin({
28
+ id: "my-awesome-plugin",
29
+ name: "My Awesome Plugin",
30
+ icon: awesomeIcon, // Icon URL
31
+ description: "Adds amazing capabilities to Luna Park.",
32
+
33
+ // Plugin configuration schema
34
+ config: ConfigSchema,
35
+
36
+ // Lifecycle hooks
37
+ lifecycle: {
38
+ mount: async (env) => {
39
+ console.log("Plugin mounted", env.config.apiKey);
40
+ },
41
+ update: async ({config}) => {
42
+ console.log("Config updated", config);
43
+ },
44
+ unmount: (env) => {
45
+ console.log("Plugin unmounted");
46
+ },
47
+ },
48
+
49
+ // Extend the editor
50
+ editor: {
51
+ // Register custom Vue components for the editor
52
+ components: [
53
+ {
54
+ name: "Element/Avatar",
55
+ component: MyAvatarComponent,
56
+ properties: {
57
+ src: LogicType.string({ name: "Avatar URL" }),
58
+ name: LogicType.string({ name: "Name" }),
59
+ },
60
+ slots: {
61
+ default: LogicType.void()
62
+ }
63
+ }
64
+ // ... component definitions
65
+ ],
66
+ // Register custom logic nodes
67
+ nodes: [
68
+ makeLogicNode({
69
+ name: "log/stuff",
70
+ inputs: {
71
+ in_exec: LogicType.exec(),
72
+ in_stuff: LogicType.string({ name: "Stuff" })
73
+ },
74
+ outputs: {
75
+ out_exec: LogicType.exec()
76
+ },
77
+ methods: {
78
+ async in_exec() {
79
+ console.log(this.in_stuff);
80
+ await this.out_exec();
81
+ }
82
+ },
83
+ display: {
84
+ name: "Log stuff"
85
+ }
86
+ })
87
+ // ... node definitions
88
+ ],
89
+ wrapper : MyWrapperComponent, // Custom wrapper component for the editor
90
+ },
91
+
92
+ // Code injection options
93
+ inject: {
94
+ css: "body { background-color: #000; }",
95
+ js: "console.log('Hello world!')"
96
+ }
97
+ });
98
+ ```
99
+
100
+ ## API Reference
101
+
102
+ ### `makePlugin(plugin)`
103
+
104
+ A helper identity function that takes a `TPlugin` object and returns it. It is used to infer types for the configuration and internal state.
105
+
106
+ ### `TPlugin<TConfig, TInternal>`
107
+
108
+ The main interface for defining a plugin.
109
+
110
+ | Property | Type | Description |
111
+ | :--- | :--- | :--- |
112
+ | `id` | `string` | **Required**. Unique identifier for the plugin. |
113
+ | `name` | `string` | **Required**. Display name of the plugin. |
114
+ | `icon` | `string` | **Required**. Icon for the plugin. |
115
+ | `description` | `string` | Brief description of what the plugin does. |
116
+ | `config` | `TSchema` | Schema definition for the plugin's configuration settings. |
117
+ | `lifecycle` | `object` | Lifecycle hooks (`mount`, `unmount`, `update`). |
118
+ | `editor` | `object` | Extensions for the editor (components, nodes, tokens, wrapper). |
119
+ | `build` | `object` | Build-time configurations (Vite plugins, imports). |
120
+ | `inject` | `object` | CSS/JS injection options. |
121
+
122
+ ### `TEnv<TConfig, TInternal>`
123
+
124
+ The environment object passed to lifecycle hooks and dynamic options.
125
+
126
+ | Property | Type | Description |
127
+ | :--- | :--- | :--- |
128
+ | `app` | `TApplicationExport` | Access to the core application instance. |
129
+ | `config` | `Static<TConfig>` | The resolved configuration values based on the schema. |
130
+ | `mode` | `"build" \| "editor"` | The current running mode. |
131
+ | `internal` | `TInternal` | Internal state (if defined). |
132
+
133
+ ### `TOption<TEnv, T>`
134
+
135
+ Many properties in `TPlugin` can be either a static value `T` or a function that returns `T` (or `Promise<T>`). This allows for dynamic configuration based on the environment.
136
+
137
+ ```typescript
138
+ type TOption<TEnv, T> = T | ((env: TEnv) => T | Promise<T>);
139
+ ```
@@ -0,0 +1,16 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("node:fs"),p=require("./index-DmZsz62R.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
+ `)});const i=Object.entries(t.types).map(([r,l])=>`const ${r} = ${T(l,{})};`).join(`
3
+
4
+ `);return`import { LogicType, type TComponent } from "@luna-park/plugin";
5
+ import ${e.name} from "${e.path}";
6
+
7
+ ${i}
8
+
9
+ export const ${e.name.toLocaleLowerCase()}: TComponent = {
10
+ name: "${e.name}",
11
+ component: ${e.name},
12
+ ${o.map(({key:r,value:l})=>`${r}: {
13
+ ${l}
14
+ }`).join(`,
15
+ `)}
16
+ }`}function h(t,e){const o={description:x(t.getDocumentationComment(e))||void 0};for(const n of t.getJsDocTags()){if(n.name==="param"){o.params||(o.params={});let i=x(n.text?.slice(1)).trim();i.startsWith("- ")&&(i=i.slice(2));const r=n.text[0]?.text;o.params[r]=i;continue}o[n.name]=x(n.text)}return p.F(o)}function x(t=[]){return t.map(e=>e.text).join("")}function w(t,e){const o=e.checker.getPropertiesOfType(t),n={};return o.forEach(i=>{const r=A(e.checker.getTypeOfSymbol(i)).type,s=e.checker.getSignaturesOfType(r,m.SignatureKind.Call)[0]?.parameters?.[0];if(s){const c=e.checker.getTypeOfSymbol(s);n[i.name]={type:e.typeToString(c)},e.extractType(c)}else n[i.name]={type:"{}"}}),n}function N(t,e){const o=e.checker.getPropertiesOfType(t),n={},i={};return o.forEach(r=>{if(["onVnode","ref_"].some(s=>r.name.startsWith(s))||["ref","class","style","key"].includes(r.name))return;const l=e.checker.getTypeOfSymbol(r);if(e.extractType(l),W(r.name)){i[H(r.name)]=L(l,r,e);return}n[r.name]=L(l,r,e)}),{emits:i,props:n}}function v(t){return t.models=Object.keys(t.properties??{}).reduce((e,o)=>(t.emits?.[`update:${o}`]&&(e[o]=t.properties[o],delete t.properties[o],delete t.emits[`update:${o}`]),e),{}),t}function A(t){if(t.isUnion()){const e=t.types.filter(o=>o.flags!==m.TypeFlags.Undefined);if(e.length===1)return{optional:!0,type:e[0]}}return{type:t}}function L(t,e,o){const n=A(t);return p.F({description:h(e,o.checker).description,optional:n.optional,type:o.typeToString(n.type)})}function W(t){return/^on[A-Z]/.test(t)}function H(t){return t=t.slice(2),t.charAt(0).toLowerCase()+t.slice(1)}function K(t,e){return Object.fromEntries((t.getTypeParameters()??[]).map(o=>{let n="unknown";const i=o.getDefault();i&&(n=e.typeToString(i));const r=o.getConstraint();return r&&(n=e.typeToString(r)),[o.symbol.name,n]}))}function Q(t,e){const o=new Map,n=t.getExportsOfModule(e);for(const i of n){let r=i;for(;r.flags&m.SymbolFlags.Alias;)r=t.getAliasedSymbol(r);o.set(i.name,r)}return o}function k(t,e){let o=t.getFullyQualifiedName(e);return o.includes('".')&&(o=o.split('".').pop()),o.includes(").")&&(o=o.split(").").pop()),o}function F(t,e){for(const[o,n]of Object.entries(e))t=t.replace(new RegExp(`\\b${o}\\b`,"g"),n);return t}function R(t){const e=[];return t.members.forEach(n=>{const i=n.name.getText();if(n.initializer){let r;m.isStringLiteral(n.initializer)?r=`"${n.initializer.text}"`:m.isNumericLiteral(n.initializer)?r=n.initializer.text:r=n.initializer.getText(),e.push(`${i} = ${r}`)}else e.push(i)}),`{ ${e.join(", ")} }`}function $(t){if(t.getFlags()&(f.TypeFlags.StringLike|f.TypeFlags.NumberLike|f.TypeFlags.BooleanLike|f.TypeFlags.ESSymbolLike|f.TypeFlags.Void|f.TypeFlags.Undefined|f.TypeFlags.Null|f.TypeFlags.Any|f.TypeFlags.Unknown|f.TypeFlags.Never))return!1;const o=t.getSymbol();if(!o)return!0;const n=o.declarations?.[0];if(!n)return!0;const i=n.getSourceFile();return!(/lib\..*\.d\.ts$/.test(i.fileName)||i.fileName.startsWith("/@vue/"))}const E=f.TypeFormatFlags.WriteArrowStyleSignature|f.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope|f.TypeFormatFlags.NoTruncation|f.TypeFormatFlags.UseFullyQualifiedType;class D{constructor(e){this.program=e,this.checker=e.getTypeChecker()}checker;index;cache=new Set;result;get(e){if(this.index=this.program.getSourceFile(e),!this.index)throw new Error(`Cannot find file ${e}`);const o=this.checker.getSymbolAtLocation(this.index);if(!o)throw new Error(`Cannot find module ${e}`);this.result={components:{},functions:{},types:{}};const n=this.index.statements.find(i=>f.isExportAssignment(i));if(n){const r=this.checker.getTypeAtLocation(n.expression).getCallSignatures()[0];r&&this.exportFunction("default",r)}return this.exportModule(o),this.result}exportModule(e){const o=Q(this.checker,e);for(const[n,i]of o.entries()){let r=this.checker.getTypeOfSymbol(i);if(r.symbol&&r.symbol.flags&f.SymbolFlags.Module){const s=r.symbol.exports?.get("default");s&&(r=this.checker.getTypeOfSymbol(s))}const l=r.symbol||r.aliasSymbol;if(l?.flags&f.SymbolFlags.Function){const s=this.checker.getTypeOfSymbol(l),c=this.checker.getSignaturesOfType(s,f.SignatureKind.Call)[0];if(c){const a=k(this.checker,l);this.exportFunction(a,c)}}else if(this.typeToString(r).includes("DefineComponent<"))try{this.exportComponent(n,r)}catch(c){console.error(`Fail to export component ${n}`),console.error(c)}}}exportComponent(e,o){const n=o.getConstructSignatures()[0];if(!n)return;const i=this.checker.getReturnTypeOfSignature(n),r={},l=this.checker.getPropertyOfType(i,"$props");if(l){const c=this.checker.getTypeOfSymbol(l),a=N(c,this);r.properties=a.props,r.emits=a.emits}const s=this.checker.getPropertyOfType(i,"$slots");if(s){const c=this.checker.getTypeOfSymbol(s);r.slots=w(c,this)}this.result.components[e]=v(r)}exportFunction(e,o){const n=h(o,this.checker),i=K(o,this),r=o.getParameters().map(s=>{const c=s.valueDeclaration??this.index,a=this.checker.getTypeOfSymbol(s);this.extractType(a,c);const u=s.valueDeclaration?.initializer?.getText();return p.F({default:u,description:n.params?.[s.name],name:s.name,optional:!!c.questionToken||u!==void 0||void 0,type:F(this.typeToString(a),i)})});if(r.some(s=>s.name?.startsWith("__VLS_"))){const s={},c=r.findIndex(y=>y.name==="__VLS_props"),a=o.getParameters()[c];if(a){const y=this.checker.getTypeOfSymbol(a),b=N(y,this);s.properties=b.props,s.emits=b.emits,Object.values(s.properties).forEach(C=>{C.type=F(C.type,i)})}const u=r.findIndex(y=>y.name==="__VLS_slots"),g=o.getParameters()[u];if(g){const y=this.checker.getTypeOfSymbol(g);s.slots=w(y,this),Object.values(s.slots).forEach(b=>{b.type=F(b.type,i)})}this.result.components[e]=v(s);return}const l=this.checker.getReturnTypeOfSignature(o);this.extractType(l),this.result.functions[e]=p.F({description:n.description,parameters:r,return:{description:n.returns,type:F(this.typeToString(l),i)}})}extractType(e,o=this.index){if(this.cache.has(e))return;this.cache.add(e);const n=e.symbol||e.aliasSymbol;if((e.isUnion()||e.isIntersection())&&!(n?.flags&f.SymbolFlags.Enum)&&e.types.forEach(i=>{this.extractType(i,o)}),n){if(this.checker.getFullyQualifiedName(n).includes("/@vue/"))return;const i=k(this.checker,n);if(n.flags&f.SymbolFlags.Enum){const r=n.valueDeclaration||n.declarations?.[0];if(r&&f.isEnumDeclaration(r)){const l=k(this.checker,n);this.result.types[l]=p.F({...h(n,this.checker),type:R(r)})}return}if(n.flags&f.SymbolFlags.Namespace){const r=n;this.exportModule(r)}if(n.flags&f.SymbolFlags.TypeAlias){const r=n.valueDeclaration||n.declarations?.[0];if(!r)return;const l=Object.fromEntries((r?.typeParameters??[]).map(s=>{let c="unknown";const a=s.default;if(a){const g=this.checker.getTypeFromTypeNode(a);c=this.typeToString(g)}const u=s.constraint;if(u){const g=this.checker.getTypeFromTypeNode(u);c=this.typeToString(g)}return[s.symbol.name,c]}));this.result.types[i]={...h(n,this.checker),type:F(this.typeToString(e,E|f.TypeFormatFlags.InTypeAlias),l)}}if(n.flags&f.SymbolFlags.Interface&&$(e)){const r=n.getDeclarations()[0];if(r){const l=this.checker.getPropertiesOfType(e),s={};l.forEach(c=>{const a=this.checker.getTypeOfSymbol(c);this.extractType(a,r),s[c.name]={...h(c,this.checker),optional:!!(c.flags&f.SymbolFlags.Optional)||void 0,type:this.typeToString(a)}}),this.result.types[i]={...h(n,this.checker),type:s}}}if(n.flags&f.SymbolFlags.TypeLiteral){const r=k(this.checker,e.aliasSymbol||e.symbol),l=this.checker.getPropertiesOfType(e),s={};if(["Promise","Partial","Pick","Omit","Required"].includes(r)){this.cache.delete(e),this.extractType(e.aliasTypeArguments[0]);return}if(e.aliasTypeArguments?.some(c=>!$(c)))return;l.forEach(c=>{const a=this.checker.getTypeOfSymbol(c);s[c.name]={...h(c,this.checker),optional:!!(c.flags&f.SymbolFlags.Optional),type:this.typeToString(a)}}),r!=="__type"&&(this.result.types[r]={...h(n,this.checker),type:s})}}if(e.flags&f.TypeFlags.Object){const i=e;if($(e)&&this.checker.getPropertiesOfType(e).forEach(l=>{const s=this.checker.getTypeOfSymbol(l);this.extractType(s,o)}),i.objectFlags&f.ObjectFlags.Reference){const r=i;this.checker.getTypeArguments(r).forEach(s=>{this.extractType(s,o)})}}}typeToString(e,o=E){return this.checker.typeToString(e,void 0,o)}}function M(t,e="unknown"){const o={components:{},functions:{},types:{}};for(const[s,c]of Object.entries(t.types))o.types[s]=n(c,s);for(const[s,c]of Object.entries(t.functions))o.functions[s]=i(c,s);for(const[s,c]of Object.entries(t.components))o.components[s]=r(c,s);return o;function n(s,c=""){if(typeof s.type=="string"){if(s.type==="{}")return p.u.void();const a={...l(p.ot$1(s.type)),...p.F({description:s.description,name:c?.split(".").pop()||void 0,optional:s.optional})};if(s.default)switch(a.type){case p.i.boolean:a.default=s.default==="true";break;case p.i.number:a.default=Number(s.default);break;case p.i.string:a.default=s.default;break}return a.type===p.i.object&&!Object.keys(a.properties).length&&(a.customizable=!0),a}else{const a=p.u.object(p.ot(s.type,({key:u,value:g})=>n(g,u)),p.F({description:s.description,name:c?.split(".").pop(),optional:s.optional}));return Object.keys(a.properties).length||(a.customizable=!0),a}}function i(s,c=""){return{...p.F({description:s.description,name:c?.split(".").pop()}),parameters:(s.parameters??[]).map(a=>n(a,a.name)),return:n(s.return,"result")}}function r(s,c=""){return{...p.F({name:c?.split(".").pop()}),emits:p.ot(s.emits,({value:a})=>n(a)),models:p.ot(s.models,({value:a})=>n(a)),properties:p.ot(s.properties,({key:a,value:u})=>n(u,a)),slots:p.ot(s.slots,({value:a})=>n(a))}}function l(s,c=""){return p.d(s,u=>{if(u.type===p.i.interface)return{...a(u.className,c),description:u.description,name:u.name,optional:u.optional}});function a(u,g=""){let y=`${g}${u}`;for(;!t.types[y]&&y.indexOf(".")!==-1;)y=y.substring(y.indexOf(".")+1);return t.types[y]?p.u.type(["packages",e,...y.split(".")]):p.u.interface(u)}}}function Z(t){for(;;){const e=O.join(t,"tsconfig.json");if(J.existsSync(e))return e;const o=O.dirname(t);if(o===t)return;t=o}}function B(t){const e=m.readConfigFile(t,m.sys.readFile);if(e.error)throw new Error(`Failed to read tsconfig.json: ${e.error.messageText}`);return m.parseJsonConfigFileContent(e.config,m.sys,O.dirname(t))}function G(t,e){const o=O.join(process.cwd(),"__temp__.ts"),n=m.createCompilerHost(e),i=m.resolveModuleName(t,o,e,n);if(i.resolvedModule)return i.resolvedModule.resolvedFileName}function z(t){const e=Z(t);if(!e)throw new Error(`Could not find tsconfig.json for: ${t}`);const n=B(e).options,i=G(t,n);if(!i)throw new Error(`Could not resolve module: ${t}`);const r=m.createCompilerHost(n),l=m.createProgram({host:r,options:n,rootNames:[i]}),s=l.getSourceFile(i);if(!s)throw new Error(`Could not get source file for: ${i}`);return{program:l,sourceFile:s}}const _=I.promises;async function X(t,e){const o=t.split("/").pop().split(".")[0],{program:n,sourceFile:i}=z(t),l=new D(n).get(i.fileName),s=M(l,o);if(s.components.default){const c=V(s,{name:o,path:t});await _.mkdir(e.split("/").slice(0,-1).join("/"),{recursive:!0}),await _.writeFile(e,c)}}exports.CTypeExport=D;exports.extractFile=X;exports.generateNodes=M;exports.getSourceFile=z;
@@ -0,0 +1,245 @@
1
+ import { default as default_2 } from 'typescript';
2
+ import * as ts from 'typescript';
3
+
4
+ export declare class CTypeExport {
5
+ program: default_2.Program;
6
+ checker: default_2.TypeChecker;
7
+ index?: default_2.SourceFile;
8
+ private cache;
9
+ private result?;
10
+ constructor(program: default_2.Program);
11
+ get(target: string): TExportResult;
12
+ exportModule(module: default_2.Symbol): void;
13
+ exportComponent(name: string, type: default_2.Type): void;
14
+ exportFunction(name: string, signature: default_2.Signature): void;
15
+ extractType(type: default_2.Type, ctxNode?: default_2.Node): void;
16
+ typeToString(type: default_2.Type, flags?: number): string;
17
+ }
18
+
19
+ declare enum EVarType {
20
+ exec = "exec",
21
+ number = "number",
22
+ string = "string",
23
+ boolean = "boolean",
24
+ object = "object",
25
+ record = "record",
26
+ array = "array",
27
+ interface = "interface",
28
+ type = "type",
29
+ function = "function",
30
+ union = "union",
31
+ unknown = "unknown",
32
+ undefined = "undefined",
33
+ void = "void"
34
+ }
35
+
36
+ export declare function extractFile(filePath: string, target: string): Promise<void>;
37
+
38
+ export declare function generateNodes(exportResult: TExportResult, packageName?: string): TExportLogicResult;
39
+
40
+ export declare function getSourceFile(moduleName: string): {
41
+ program: ts.Program;
42
+ sourceFile: ts.SourceFile;
43
+ };
44
+
45
+ declare type OptionalKeys<T extends TProperties> = {
46
+ [K in keyof T]: T[K] extends {
47
+ optional: true;
48
+ } ? K : never;
49
+ }[keyof T];
50
+
51
+ declare type RequiredKeys<T extends TProperties> = Exclude<keyof T, OptionalKeys<T>>;
52
+
53
+ declare type Static<T extends TSchema> = T extends {
54
+ optional: true;
55
+ } ? (T["static"] | undefined) : T["static"];
56
+
57
+ declare type StaticFunction<TInputs extends TObject, TOutput extends TSchema> = (...args: Array<Static<TInputs>[string]>) => Promise<Static<TOutput>>;
58
+
59
+ declare type StaticObject<T extends TProperties> = {
60
+ [K in RequiredKeys<T>]: Static<T[K]>;
61
+ } & {
62
+ [K in OptionalKeys<T>]?: Static<T[K]>;
63
+ };
64
+
65
+ declare type StaticRecord<TKey extends TSchema, TValue extends TSchema> = Record<Static<TKey>, Static<TValue>>;
66
+
67
+ declare type StaticUnion<T extends Array<TSchema>> = {
68
+ [K in keyof T]: Static<T[K]>;
69
+ }[number];
70
+
71
+ declare type TAnyLogic = TExec | TObject | TRecord<any, any> | TInterface | TType | TArray<any> | TString | TNumber | TBoolean | TUnknown | TUndefined | TUnion<any> | TFunction<any, any> | TVoid;
72
+
73
+ declare interface TArguments<TType = any> {
74
+ name?: string;
75
+ build?: (arg: unknown) => unknown;
76
+ customizable?: boolean;
77
+ default?: TType;
78
+ defaultType?: TSchema;
79
+ description?: string;
80
+ dynamic?: ((arg: {
81
+ config: Record<string, unknown>;
82
+ inputs: Record<string, TSchema>;
83
+ outputs: Record<string, TSchema>;
84
+ }) => TSchema);
85
+ enum?: TEnum<TType>;
86
+ example?: unknown;
87
+ format?: "date-time" | "email" | "color";
88
+ multiple?: boolean;
89
+ optional?: boolean;
90
+ options?: {
91
+ format?: (arg: TType) => TType;
92
+ freeze?: boolean;
93
+ } & Record<string, unknown>;
94
+ parse?: (arg: unknown) => unknown;
95
+ placeholder?: string;
96
+ priority?: boolean;
97
+ promise?: boolean;
98
+ required?: boolean;
99
+ static?: unknown;
100
+ sub?: TSchema;
101
+ }
102
+
103
+ declare interface TArray<T extends TSchema = TSchema> {
104
+ type: EVarType.array;
105
+ items: T;
106
+ static: Array<Static<T>>;
107
+ }
108
+
109
+ declare interface TBoolean {
110
+ type: EVarType.boolean;
111
+ static: boolean;
112
+ }
113
+
114
+ declare type TEnum<TEnumType> = Array<TEnumType> | Record<string, TEnumType>;
115
+
116
+ declare interface TExec {
117
+ type: EVarType.exec;
118
+ }
119
+
120
+ declare type TExportComponent = {
121
+ emits?: Record<string, Array<TExportType>>;
122
+ models?: Record<string, TExportType>;
123
+ properties?: Record<string, TExportType>;
124
+ slots?: Record<string, TExportType>;
125
+ };
126
+
127
+ declare type TExportFunction = {
128
+ description?: string;
129
+ parameters?: Array<{
130
+ default?: string;
131
+ description?: string;
132
+ name: string;
133
+ optional?: boolean;
134
+ type: string;
135
+ }>;
136
+ return: {
137
+ description?: string;
138
+ type: string;
139
+ };
140
+ type: string;
141
+ };
142
+
143
+ declare type TExportLogicComponent = {
144
+ emits: Record<string, TSchema>;
145
+ models: Record<string, TSchema>;
146
+ properties: Record<string, TSchema>;
147
+ slots: Record<string, TSchema>;
148
+ };
149
+
150
+ declare type TExportLogicResult = {
151
+ components: Record<string, TExportLogicComponent>;
152
+ functions: Record<string, TExportNodeFunction>;
153
+ types: Record<string, TSchema>;
154
+ };
155
+
156
+ declare type TExportNodeFunction = {
157
+ description?: string;
158
+ name?: string;
159
+ parameters?: Array<TSchema>;
160
+ return?: TSchema;
161
+ };
162
+
163
+ declare type TExportResult = {
164
+ components: Record<string, TExportComponent>;
165
+ functions: Record<string, TExportFunction>;
166
+ types: Record<string, TExportType>;
167
+ };
168
+
169
+ declare type TExportType = {
170
+ default?: string;
171
+ description?: string;
172
+ optional?: boolean;
173
+ properties?: Record<string, TExportType>;
174
+ type: string | Record<string, TExportType>;
175
+ };
176
+
177
+ declare interface TFunction<TInputs extends TObject = TObject, TOutput extends TSchema = TUnknown> {
178
+ type: EVarType.function;
179
+ inputs: TInputs;
180
+ output: TOutput;
181
+ static: StaticFunction<TInputs, TOutput>;
182
+ }
183
+
184
+ declare interface TInterface<T = unknown> {
185
+ type: EVarType.interface;
186
+ class?: new (...args: any) => T;
187
+ className: string;
188
+ static: T;
189
+ }
190
+
191
+ declare interface TNumber {
192
+ type: EVarType.number;
193
+ static: number;
194
+ }
195
+
196
+ declare interface TObject<T extends TProperties = TProperties> {
197
+ type: EVarType.object;
198
+ properties: T;
199
+ static: StaticObject<T>;
200
+ }
201
+
202
+ declare type TProperties = Record<string, TSchema>;
203
+
204
+ declare interface TRecord<TKey extends TString | TNumber = TString, TValue extends TSchema = TSchema> {
205
+ type: EVarType.record;
206
+ key: TKey;
207
+ static: StaticRecord<TKey, TValue>;
208
+ value: TValue;
209
+ }
210
+
211
+ declare type TSchema<TLogic extends TAnyLogic = TAnyLogic> = TArguments & TLogic;
212
+
213
+ declare interface TString {
214
+ type: EVarType.string;
215
+ static: string;
216
+ }
217
+
218
+ declare interface TType<T extends TSchema = TSchema> {
219
+ type: EVarType.type;
220
+ static: T;
221
+ target: Array<string>;
222
+ }
223
+
224
+ declare interface TUndefined {
225
+ type: EVarType.undefined;
226
+ static: undefined;
227
+ }
228
+
229
+ declare interface TUnion<T extends Array<TSchema> = Array<TSchema>> {
230
+ type: EVarType.union;
231
+ elements: T;
232
+ static: StaticUnion<T>;
233
+ }
234
+
235
+ declare interface TUnknown {
236
+ type: EVarType.unknown;
237
+ static: unknown;
238
+ }
239
+
240
+ declare interface TVoid {
241
+ type: EVarType.void;
242
+ static: void;
243
+ }
244
+
245
+ export { }