@luna-park/plugin 1.3.0 → 1.4.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.
@@ -0,0 +1,368 @@
1
+ import { IconDefinition } from "@fortawesome/fontawesome-svg-core";
2
+
3
+ //#region ../utils/dist/index.d.mts
4
+ type DeepPartial<T> = { [K in keyof T]?: T[K] extends Array<unknown> ? Array<DeepPartial<T[K][number]>> : T[K] extends Record<string, unknown> ? DeepPartial<T[K]> : T[K] };
5
+ type MaybePromise<T> = T | Promise<T>;
6
+ //#endregion
7
+ //#region src/vector.d.ts
8
+ type TVector = {
9
+ x: number;
10
+ y: number;
11
+ };
12
+ declare class CVector {
13
+ x: number;
14
+ y: number;
15
+ constructor(vector: TVector);
16
+ setX(x: number): CVector;
17
+ setY(y: number): CVector;
18
+ clone(): CVector;
19
+ add(vector: TVector): CVector;
20
+ sub(vector: TVector): CVector;
21
+ mul(number: number): CVector;
22
+ div(number: number): CVector;
23
+ round(): CVector;
24
+ addX(x: number): CVector;
25
+ addY(y: number): CVector;
26
+ normalize(): CVector;
27
+ isNearlyEqual(vector: TVector): boolean;
28
+ getPointString(): string;
29
+ getMagnitude(): number;
30
+ } //#endregion
31
+ //#endregion
32
+ //#region ../logicnodes/dist/index.d.mts
33
+ //#region src/logic/type.d.ts
34
+ declare enum EVarType {
35
+ exec = "exec",
36
+ number = "number",
37
+ string = "string",
38
+ boolean = "boolean",
39
+ object = "object",
40
+ record = "record",
41
+ array = "array",
42
+ interface = "interface",
43
+ type = "type",
44
+ function = "function",
45
+ union = "union",
46
+ unknown = "unknown",
47
+ undefined = "undefined",
48
+ void = "void"
49
+ }
50
+ type TProperties = Record<string, TSchema>;
51
+ interface TArguments<TType = unknown> {
52
+ build?: (arg: unknown) => unknown;
53
+ customizable?: boolean;
54
+ default?: TType | (() => TType);
55
+ defaultType?: TSchema;
56
+ description?: string;
57
+ dynamic?: ((arg: {
58
+ config: Record<string, unknown>;
59
+ inputs: Record<string, TSchema>;
60
+ outputs: Record<string, TSchema>;
61
+ }) => TSchema);
62
+ enum?: TEnum<TType>;
63
+ example?: unknown;
64
+ format?: "date-time" | "email" | "color";
65
+ multiple?: boolean;
66
+ name?: string;
67
+ optional?: boolean;
68
+ options?: {
69
+ access?: TSchema<TObject>;
70
+ format?: (arg: TType) => TType;
71
+ freeze?: boolean;
72
+ readonly?: boolean;
73
+ } & Record<string, unknown>;
74
+ parse?: (arg: unknown) => unknown;
75
+ placeholder?: string;
76
+ priority?: boolean;
77
+ promise?: boolean;
78
+ required?: boolean;
79
+ static?: unknown;
80
+ sub?: TSchema;
81
+ }
82
+ type TEnum<TEnumType> = Array<TEnumType> | Record<string, TEnumType>;
83
+ interface TExec {
84
+ type: EVarType.exec;
85
+ }
86
+ interface TNumber {
87
+ static: number;
88
+ type: EVarType.number;
89
+ }
90
+ interface TString {
91
+ static: string;
92
+ type: EVarType.string;
93
+ }
94
+ interface TBoolean {
95
+ static: boolean;
96
+ type: EVarType.boolean;
97
+ }
98
+ interface TUnknown {
99
+ static: unknown;
100
+ type: EVarType.unknown;
101
+ }
102
+ interface TUndefined {
103
+ static: undefined;
104
+ type: EVarType.undefined;
105
+ }
106
+ interface TVoid {
107
+ static: void;
108
+ type: EVarType.void;
109
+ }
110
+ interface TObject<T extends TProperties = TProperties> {
111
+ properties: T;
112
+ static: StaticObject<T>;
113
+ type: EVarType.object;
114
+ }
115
+ interface TRecord<TKey extends TString | TNumber = TString, TValue extends TSchema = TSchema> {
116
+ key: TKey;
117
+ static: StaticRecord<TKey, TValue>;
118
+ type: EVarType.record;
119
+ value: TValue;
120
+ }
121
+ interface TInterface<T = unknown> {
122
+ class?: new (...args: Array<unknown>) => T;
123
+ className: string;
124
+ static: T;
125
+ type: EVarType.interface;
126
+ }
127
+ interface TType<T extends TSchema = TSchema> {
128
+ static: T;
129
+ target: Array<string>;
130
+ type: EVarType.type;
131
+ }
132
+ interface TArray<T extends TSchema = TSchema> {
133
+ items: T;
134
+ static: Array<Static<T>>;
135
+ type: EVarType.array;
136
+ }
137
+ interface TUnion<T extends ReadonlyArray<TSchema> = ReadonlyArray<TSchema>> {
138
+ elements: T;
139
+ static: StaticUnion<T>;
140
+ type: EVarType.union;
141
+ }
142
+ interface TFunction<TInputs extends TObject = TObject, TOutput extends TSchema = TSchema, TPromise extends boolean = false> {
143
+ inputs: TInputs;
144
+ output: TOutput;
145
+ static: StaticFunction<TInputs, TOutput, TPromise>;
146
+ type: EVarType.function;
147
+ }
148
+ type TAnyLogic = TExec | TObject | TRecord | TInterface | TType | TArray | TString | TNumber | TBoolean | TUnknown | TUndefined | TUnion | TFunction | TVoid;
149
+ type TSchema<TLogic extends TAnyLogic = TAnyLogic> = TLogic & TArguments<Static<TLogic>>;
150
+ declare const LogicType: {
151
+ array: <T extends TSchema, TArgs extends TArguments<Array<T>>>(items: T, args?: TArgs) => TArray<T> & TArgs;
152
+ boolean: <TArgs extends TArguments<boolean>>(args?: TArgs) => TBoolean & TArgs;
153
+ exec: (args?: TArguments) => TExec;
154
+ function: <TInputs extends TObject, TOutput extends TSchema = TUndefined, TPromise extends boolean = false>(inputs?: TInputs, output?: TOutput, args?: TArguments & {
155
+ promise?: TPromise;
156
+ }) => TFunction<TInputs, TOutput, TPromise>;
157
+ interface: <T = unknown, TArgs extends TArguments<T> = TArguments<T>>(interfaceClass: (new (...args: Array<unknown>) => T) | string, args?: TArgs) => TInterface<T> & TArgs;
158
+ number: <TArgs extends TArguments<number>>(args?: TArgs) => TNumber & TArgs;
159
+ object: <T extends TProperties, TArgs extends TArguments<object>>(properties?: T, args?: TArgs) => TObject<T> & TArgs;
160
+ record: <TKey extends TString | TNumber, TValue extends TSchema = TSchema<TAnyLogic>>(key: TKey, value: TValue, args?: TArguments) => TRecord<TKey, TValue>;
161
+ string: <TArgs extends TArguments<string>>(args?: TArgs) => TString & TArgs;
162
+ type: <T extends TSchema>(target: Array<string>, args?: TArguments) => TType<T>;
163
+ undefined: (args?: TArguments) => TUndefined;
164
+ union: <T extends Array<TSchema>>(elements: T, args?: TArguments) => TUnion<T>;
165
+ unknown: <TArgs extends TArguments>(args?: TArgs) => TUnknown & TArgs;
166
+ void: (args?: TArguments) => TVoid;
167
+ };
168
+ type OptionalKeys<T extends TProperties> = { [K in keyof T]: T[K] extends {
169
+ optional: true;
170
+ } ? K : never }[keyof T];
171
+ type RequiredKeys<T extends TProperties> = Exclude<keyof T, OptionalKeys<T>>;
172
+ type StaticObject<T extends TProperties> = { [K in RequiredKeys<T>]: Static<T[K]> } & { [K in OptionalKeys<T>]?: Static<T[K]> };
173
+ type StaticRecord<TKey extends TSchema<TString> | TSchema<TNumber>, TValue extends TSchema> = Record<Static<TKey>, Static<TValue>>;
174
+ type StaticUnion<T extends ReadonlyArray<TSchema>> = { [K in keyof T]: Static<T[K]> }[number];
175
+ type StaticFunction<TInputs extends TObject, TOutput extends TSchema, TPromise extends boolean = false> = TPromise extends true ? (...args: Array<Static<TInputs>[string]>) => Promise<Static<TOutput>> : (...args: Array<Static<TInputs>[string]>) => Static<TOutput>;
176
+ type Static<T extends TSchema> = T extends {
177
+ optional: true;
178
+ } ? (T["static"] | undefined) : T["static"];
179
+ declare const LogicUtil: {
180
+ omit(target: TObject, keys: Array<string>): TObject;
181
+ partial(target: TObject, force?: boolean): TObject;
182
+ pick(target: TObject, keys: Array<string>): TObject;
183
+ promise(target: TSchema): TSchema;
184
+ required(target: TObject): TObject;
185
+ }; //#endregion
186
+ //#region src/logic/node.d.ts
187
+ type Component = {
188
+ name: string;
189
+ };
190
+ type TNodeInterfaceDescriptor = Record<string, TSchema>;
191
+ declare enum ELogicType {
192
+ function = "function",
193
+ macro = "macro",
194
+ operation = "operation"
195
+ }
196
+ declare enum ELogicScope {
197
+ Frontend = "frontend",
198
+ Backend = "backend",
199
+ Desktop = "desktop",
200
+ Shared = "shared"
201
+ }
202
+ type TNodeDisplay = {
203
+ altSearch?: string;
204
+ config?: {
205
+ back?: string | IconDefinition;
206
+ data?: {
207
+ size?: {
208
+ x: number;
209
+ y: number;
210
+ };
211
+ };
212
+ fixed?: boolean;
213
+ headerless?: boolean;
214
+ hoverable?: boolean;
215
+ icon?: string | IconDefinition;
216
+ inspector?: string;
217
+ noDelete?: boolean;
218
+ noSelection?: boolean;
219
+ notFound?: boolean;
220
+ once?: boolean;
221
+ priority?: number;
222
+ scope?: ELogicScope;
223
+ transparent?: boolean;
224
+ };
225
+ custom?: Component | string;
226
+ data?: Record<string, unknown>;
227
+ inspector?: string;
228
+ interface?: Component | string;
229
+ name?: string;
230
+ priority?: number;
231
+ };
232
+ type TNodeConfigDescriptor = Record<string, TSchema>;
233
+ type TNodeIOSchema<TInterface extends TNodeInterfaceDescriptor> = { [TKey in keyof TOnlyVarsOf<TInterface>]: {
234
+ linked: boolean;
235
+ schema: TOnlyVarsOf<TInterface>[TKey];
236
+ value: Static<TOnlyVarsOf<TInterface>[TKey]>;
237
+ } };
238
+ type TNodeOptionals<TInputs extends TNodeInterfaceDescriptor, TOutputs extends TNodeInterfaceDescriptor> = { [TKey in keyof (TOnlyVarsOf<TInputs> | TOnlyVarsOf<TOutputs>)]: boolean };
239
+ type TNodeConfigSchema<TConfig extends TNodeConfigDescriptor> = {
240
+ internal?: unknown;
241
+ } & { [TKey in keyof TConfig]: Static<TConfig[TKey]> };
242
+ type TNodeDynamics<TInputs extends TNodeInterfaceDescriptor, TOutputs extends TNodeInterfaceDescriptor, TConfig extends TNodeConfigDescriptor> = {
243
+ inputs?: (ioSchema: {
244
+ config: TNodeConfigSchema<TConfig>;
245
+ inputs: TNodeIOSchema<TInputs>;
246
+ optionals: TNodeOptionals<TInputs, TOutputs>;
247
+ outputs: TNodeIOSchema<TOutputs>;
248
+ }) => Partial<TNodeInterfaceDescriptor>;
249
+ outputs?: (ioSchema: {
250
+ config: TNodeConfigSchema<TConfig>;
251
+ inputs: TNodeIOSchema<TInputs>;
252
+ optionals: TNodeOptionals<TInputs, TOutputs>;
253
+ outputs: TNodeIOSchema<TOutputs>;
254
+ }) => Partial<TNodeInterfaceDescriptor>;
255
+ };
256
+ type TDocumentation = {
257
+ description?: string;
258
+ examples?: Array<{
259
+ inputs: Array<{
260
+ key: string;
261
+ value: unknown;
262
+ }>;
263
+ outputs: Array<{
264
+ key: string;
265
+ value: unknown;
266
+ }>;
267
+ }>;
268
+ parameters?: Array<{
269
+ description: string;
270
+ name: string;
271
+ }>;
272
+ };
273
+ type TOnlyExecOf<TNodeInterfaceDescriptor> = { [TAnchor in keyof TNodeInterfaceDescriptor as TNodeInterfaceDescriptor[TAnchor] extends TExec ? TAnchor : never]: TNodeInterfaceDescriptor[TAnchor] };
274
+ type TOnlyVarsOf<TNodeInterfaceDescriptor> = { [TAnchor in keyof TNodeInterfaceDescriptor as TNodeInterfaceDescriptor[TAnchor] extends TExec ? never : TAnchor]: TNodeInterfaceDescriptor[TAnchor] };
275
+ type MethodsFrom<TInterface extends TNodeInterfaceDescriptor> = { [TKey in keyof TInterface]: (() => MaybePromise<Static<TInterface[TKey]>>) | {
276
+ async: () => Promise<Static<TInterface[TKey]>>;
277
+ sync: () => MaybePromise<Static<TInterface[TKey]>>;
278
+ } };
279
+ type TMethodsOf<TInputs extends TNodeInterfaceDescriptor, TOutputs extends TNodeInterfaceDescriptor> = MethodsFrom<TOnlyExecOf<TInputs>> & MethodsFrom<TOnlyVarsOf<TOutputs>>;
280
+ type TNodeDescriptor<TInputs extends TNodeInterfaceDescriptor, TOutputs extends TNodeInterfaceDescriptor, TConfig extends TNodeConfigDescriptor> = TNodeGenerated<TInputs, TOutputs, TConfig> & ThisType<{ [TKey in keyof TOnlyExecOf<TOutputs>]: (stack?: unknown) => Promise<void> } & { [TKey in keyof TOnlyVarsOf<TInputs>]: Static<TInputs[TKey]> } & { [TKey in keyof TOnlyVarsOf<TOutputs>]: Static<TOutputs[TKey]> } & Record<`internal_${string}`, unknown> & {
281
+ arguments: Promise<Array<unknown>>;
282
+ cache: Record<string, unknown>;
283
+ config: { [TKey in keyof TConfig]: Static<TConfig[TKey]> };
284
+ properties: Record<string, {
285
+ name: string;
286
+ value: Promise<unknown>;
287
+ }>;
288
+ stack: any;
289
+ }>;
290
+ type TNodeGenerated<TInputs extends TNodeInterfaceDescriptor, TOutputs extends TNodeInterfaceDescriptor, TConfig extends TNodeConfigDescriptor> = {
291
+ build?: {
292
+ define?: Array<{
293
+ id: (data: {
294
+ input?: TOnlyVarsOf<TInputs>;
295
+ }) => string;
296
+ values: (data: {
297
+ input?: TOnlyVarsOf<TInputs>;
298
+ }) => string;
299
+ }>;
300
+ entry?: boolean;
301
+ generate?: (data: {
302
+ config?: { [TKey in keyof TConfig]: Static<TConfig[TKey]> };
303
+ inputKeys: Array<string>;
304
+ key?: string;
305
+ }) => string;
306
+ imports?: Array<{
307
+ name: string;
308
+ target: string;
309
+ }>;
310
+ };
311
+ config?: TConfig;
312
+ display?: TNodeDisplay;
313
+ documentation?: TDocumentation;
314
+ dynamics?: TNodeDynamics<TInputs, TOutputs, TConfig>;
315
+ inputs: TInputs;
316
+ methods: Partial<TMethodsOf<TInputs, TOutputs>>;
317
+ name?: string;
318
+ outputs: TOutputs;
319
+ type?: ELogicType;
320
+ };
321
+ type TLogicNode = {
322
+ build?: {
323
+ define?: Array<{
324
+ id: (data: {
325
+ input?: Record<string, unknown>;
326
+ }) => string;
327
+ values: (data: {
328
+ input?: Record<string, unknown>;
329
+ }) => string;
330
+ }>;
331
+ entry?: boolean;
332
+ generate?: (options: {
333
+ config: Record<string, unknown>;
334
+ inputKeys: Array<string>;
335
+ key: string;
336
+ }) => string;
337
+ imports?: Array<{
338
+ name: string;
339
+ target: string;
340
+ }>;
341
+ };
342
+ config?: TNodeConfigDescriptor;
343
+ display?: TNodeDisplay;
344
+ documentation?: TDocumentation;
345
+ dynamics?: {
346
+ inputs?: (ioSchema: {
347
+ config: Record<string, unknown>;
348
+ inputs: Record<string, unknown>;
349
+ optionals: Record<string, boolean>;
350
+ outputs: Record<string, unknown>;
351
+ }) => TNodeInterfaceDescriptor;
352
+ outputs?: (ioSchema: {
353
+ config: Record<string, unknown>;
354
+ inputs: Record<string, unknown>;
355
+ optionals: Record<string, boolean>;
356
+ outputs: Record<string, unknown>;
357
+ }) => TNodeInterfaceDescriptor;
358
+ };
359
+ inputs: TNodeInterfaceDescriptor;
360
+ methods: Record<string, () => unknown>;
361
+ name: string;
362
+ outputs: TNodeInterfaceDescriptor;
363
+ type?: ELogicType;
364
+ };
365
+ declare function makeLogicNode<TInputs extends TNodeInterfaceDescriptor, TOutputs extends TNodeInterfaceDescriptor, TConfig extends TNodeConfigDescriptor>(node: TNodeDescriptor<TInputs, TOutputs, TConfig>): TLogicNode; //#endregion
366
+ //#region src/logic/lib.d.ts
367
+ //#endregion
368
+ export { LogicUtil as a, TObject as c, makeLogicNode as d, CVector as f, TVector as h, LogicType as i, TSchema as l, MaybePromise as m, ELogicType as n, Static as o, DeepPartial as p, EVarType as r, TLogicNode as s, ELogicScope as t, TVoid as u };