@luna-park/plugin 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,85 @@
1
+ // ../utils/dist/index.mjs
2
+ const NPM_CDN_ORIGIN = "https://esm.sh";
3
+ function getNpmCdnUrl(target, externals = []) {
4
+ const url = `${NPM_CDN_ORIGIN}/${target}`;
5
+ return externals.length ? `${url}?external=${externals.join(",")}` : url;
6
+ }
7
+ function cloneDeep(object) {
8
+ if (typeof object !== "object") return object;
9
+ const strategies = [
10
+ () => JSON.parse(JSON.stringify(object)),
11
+ () => structuredClone(object),
12
+ () => safeClone(object)
13
+ ];
14
+ let lastError;
15
+ for (const strategy of strategies) try {
16
+ return strategy();
17
+ } catch (error) {
18
+ lastError = error;
19
+ continue;
20
+ }
21
+ console.error("Failed to deep clone object:", object);
22
+ throw new Error(String(lastError));
23
+ }
24
+ function safeClone(object) {
25
+ const seen = /* @__PURE__ */ new WeakSet();
26
+ return recursiveClone(object);
27
+ function recursiveClone(object) {
28
+ if (typeof object !== "object" || object === null) return object;
29
+ if (seen.has(object)) return { recursive: true };
30
+ seen.add(object);
31
+ if (Array.isArray(object)) return object.map((element) => recursiveClone(element));
32
+ const clone = {};
33
+ for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(object))) clone[key] = recursiveClone(descriptor.value);
34
+ return clone;
35
+ }
36
+ }
37
+ function cloneWithFunctions(object) {
38
+ if (Array.isArray(object)) return object.map(cloneWithFunctions);
39
+ if (typeof object !== "object" || object === null) return object;
40
+ const clone = {};
41
+ for (const [key, value] of Object.entries(object)) clone[key] = typeof value === "function" ? value : cloneWithFunctions(value);
42
+ return clone;
43
+ }
44
+ function assertType(_arg) {}
45
+ function objectMap(source, func) {
46
+ if (!source) return {};
47
+ return Object.fromEntries(Object.entries(source).map(([key, value]) => [key, func({
48
+ key,
49
+ value
50
+ })]));
51
+ }
52
+ function objectFilter(source, func) {
53
+ if (!source) return {};
54
+ return Object.fromEntries(Object.entries(source).filter(([key, value]) => func({
55
+ key,
56
+ value
57
+ })));
58
+ }
59
+ function objectFullMap(source, func) {
60
+ if (!source) return {};
61
+ return Object.fromEntries(Object.entries(source).map(([key, value]) => {
62
+ const result = func({
63
+ key,
64
+ value
65
+ });
66
+ return [result.key, result.value];
67
+ }));
68
+ }
69
+ function cleanObject(target) {
70
+ const record = cloneDeep(target);
71
+ for (const key in record) cleanDeep(record, key);
72
+ function cleanDeep(value, key) {
73
+ const child = value[key];
74
+ if (child && typeof child === "object") {
75
+ for (const childKey in child) cleanDeep(child, childKey);
76
+ if (Object.keys(child).length === 0) delete value[key];
77
+ }
78
+ }
79
+ return record;
80
+ }
81
+ function isRawObject(target) {
82
+ if (target !== null && typeof target === "object") return Object.getPrototypeOf(target) === Object.prototype;
83
+ return false;
84
+ }
85
+ export { getNpmCdnUrl as a, objectFullMap as c, cloneWithFunctions as i, objectMap as l, cleanObject as n, isRawObject as o, cloneDeep as r, objectFilter as s, assertType as t };
@@ -1,82 +1,4 @@
1
- // ../utils/dist/index.mjs
2
- function cloneDeep(object) {
3
- if (typeof object !== "object") return object;
4
- const strategies = [
5
- () => JSON.parse(JSON.stringify(object)),
6
- () => structuredClone(object),
7
- () => safeClone(object)
8
- ];
9
- let lastError;
10
- for (const strategy of strategies) try {
11
- return strategy();
12
- } catch (error) {
13
- lastError = error;
14
- continue;
15
- }
16
- console.error("Failed to deep clone object:", object);
17
- throw new Error(String(lastError));
18
- }
19
- function safeClone(object) {
20
- const seen = /* @__PURE__ */ new WeakSet();
21
- return recursiveClone(object);
22
- function recursiveClone(object) {
23
- if (typeof object !== "object" || object === null) return object;
24
- if (seen.has(object)) return { recursive: true };
25
- seen.add(object);
26
- if (Array.isArray(object)) return object.map((element) => recursiveClone(element));
27
- const clone = {};
28
- for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(object))) clone[key] = recursiveClone(descriptor.value);
29
- return clone;
30
- }
31
- }
32
- function cloneWithFunctions(object) {
33
- if (Array.isArray(object)) return object.map(cloneWithFunctions);
34
- if (typeof object !== "object" || object === null) return object;
35
- const clone = {};
36
- for (const [key, value] of Object.entries(object)) clone[key] = typeof value === "function" ? value : cloneWithFunctions(value);
37
- return clone;
38
- }
39
- function assertType(_arg) {}
40
- function objectMap(source, func) {
41
- if (!source) return {};
42
- return Object.fromEntries(Object.entries(source).map(([key, value]) => [key, func({
43
- key,
44
- value
45
- })]));
46
- }
47
- function objectFilter(source, func) {
48
- if (!source) return {};
49
- return Object.fromEntries(Object.entries(source).filter(([key, value]) => func({
50
- key,
51
- value
52
- })));
53
- }
54
- function objectFullMap(source, func) {
55
- if (!source) return {};
56
- return Object.fromEntries(Object.entries(source).map(([key, value]) => {
57
- const result = func({
58
- key,
59
- value
60
- });
61
- return [result.key, result.value];
62
- }));
63
- }
64
- function cleanObject(target) {
65
- const record = cloneDeep(target);
66
- for (const key in record) cleanDeep(record, key);
67
- function cleanDeep(value, key) {
68
- const child = value[key];
69
- if (child && typeof child === "object") {
70
- for (const childKey in child) cleanDeep(child, childKey);
71
- if (Object.keys(child).length === 0) delete value[key];
72
- }
73
- }
74
- return record;
75
- }
76
- function isRawObject(target) {
77
- if (target !== null && typeof target === "object") return Object.getPrototypeOf(target) === Object.prototype;
78
- return false;
79
- }
1
+ import { c as objectFullMap, l as objectMap, o as isRawObject, r as cloneDeep, s as objectFilter, t as assertType } from "./dist-BBW6rNSm.mjs";
80
2
  // ../logicnodes/dist/index.mjs
81
3
  const interfaceConfigs = {};
82
4
  function isInterfaceConstant(value) {
@@ -368,6 +290,7 @@ function objectToSchema(object, args = {}) {
368
290
  switch (typeof object) {
369
291
  case "object":
370
292
  if (Array.isArray(object)) {
293
+ assertType(args);
371
294
  if (object.length === 0) return LogicType.array(LogicType.unknown(), {
372
295
  ...args,
373
296
  customizable: true
@@ -378,10 +301,17 @@ function objectToSchema(object, args = {}) {
378
301
  if (object === null) return LogicType.unknown(args);
379
302
  if (isInterfaceConstant(object)) return LogicType.interface(object._interface, args);
380
303
  if (object._dynamic) return LogicType.unknown(args);
304
+ assertType(args);
381
305
  return LogicType.object(objectMap(object, ({ key, value }) => objectToSchema(value, { name: key })), args);
382
- case "boolean": return LogicType.boolean(args);
383
- case "number": return LogicType.number(args);
384
- case "string": return LogicType.string(args);
306
+ case "boolean":
307
+ assertType(args);
308
+ return LogicType.boolean(args);
309
+ case "number":
310
+ assertType(args);
311
+ return LogicType.number(args);
312
+ case "string":
313
+ assertType(args);
314
+ return LogicType.string(args);
385
315
  default: return LogicType.unknown(args);
386
316
  }
387
317
  }
@@ -823,7 +753,10 @@ function schemaLoop(schema, func, key) {
823
753
  schema.inputs = schemaLoop(schema.inputs, func);
824
754
  schema.output = schemaLoop(schema.output, func);
825
755
  }
826
- if (["union", "intersection"].includes(schema.type)) for (const key in schema.elements) schema.elements[key] = schemaLoop(schema.elements[key], func);
756
+ if (["union", "intersection"].includes(schema.type)) {
757
+ assertType(schema);
758
+ for (const key in schema.elements) schema.elements[key] = schemaLoop(schema.elements[key], func);
759
+ }
827
760
  return schema;
828
761
  }
829
762
  function getSubSchema(schema) {
@@ -891,4 +824,4 @@ function createInterfaceInstance(className) {
891
824
  return;
892
825
  }
893
826
  }
894
- export { LogicUtil as a, mergeIntersection as c, assertType as d, cleanObject as f, LogicType as i, schemaLoop as l, objectMap as m, ELogicType as n, getSchemaDefault as o, cloneWithFunctions as p, EVarType as r, makeLogicNode as s, ELogicScope as t, typeToSchema as u };
827
+ export { LogicUtil as a, mergeIntersection as c, LogicType as i, schemaLoop as l, ELogicType as n, getSchemaDefault as o, EVarType as r, makeLogicNode as s, ELogicScope as t, typeToSchema as u };
@@ -1,4 +1,4 @@
1
- import { d as TSchema } from "./index-B4kxQtaL.mjs";
1
+ import { d as TSchema } from "./index-w5zIwwtu.mjs";
2
2
  import * as ts$1 from "typescript";
3
3
  import ts from "typescript";
4
4
  type TExportResult = {
@@ -1,4 +1,5 @@
1
- import { d as assertType, f as cleanObject, i as LogicType, l as schemaLoop, m as objectMap, r as EVarType, u as typeToSchema } from "./dist-CZjmIqBC.mjs";
1
+ import { l as objectMap, n as cleanObject, t as assertType } from "./dist-BBW6rNSm.mjs";
2
+ import { i as LogicType, l as schemaLoop, r as EVarType, u as typeToSchema } from "./dist-Dyisk4Ug.mjs";
2
3
  import fs from "node:fs";
3
4
  import ts, * as ts$1 from "typescript";
4
5
  import * as path from "path";
@@ -43,8 +43,9 @@ declare enum EVarType {
43
43
  void = "void"
44
44
  }
45
45
  type TProperties = Record<string, TSchema>;
46
- /** Schema options, augmentable by the packages that own each option with `declare module "@luna-park/logicnodes"`. */
46
+ /** Schema options, augmentable by the packages that own each option with `declare module "@luna-park/logicnodes"`. Other keys are free for plugin inputs. */
47
47
  interface TSchemaOptions {
48
+ [key: string]: unknown;
48
49
  access?: TSchema<TObject>;
49
50
  clamp?: boolean;
50
51
  clean?: boolean;
@@ -196,21 +197,21 @@ type TSchema<TLogic extends TAnyLogic = TAnyLogic> = TLogic & TArguments;
196
197
  declare const LogicType: {
197
198
  array: <T extends TSchema, TArgs extends TSchemaArguments<Array<StaticSchema<T>>>>(items: T, args?: TArgs) => TSchema<TArray<T>> & NoInfer<TArgs>;
198
199
  boolean: <TArgs extends TSchemaArguments<boolean>>(args?: TArgs) => TSchema<TBoolean> & NoInfer<TArgs>;
199
- exec: <const TArgs extends TArguments = {}>(args?: TArgs) => TSchema<TExec> & NoInfer<TArgs>;
200
+ exec: <const TArgs extends TArguments = {}>(args?: TArgs & TArguments) => TSchema<TExec> & NoInfer<TArgs>;
200
201
  function: typeof createFunction;
201
202
  interface: <T = unknown, TArgs extends TSchemaArguments<T> = TSchemaArguments<T>>(interfaceClass: (new (...args: Array<never>) => T) | string, args?: TArgs) => TSchema<TInterface<T>> & NoInfer<TArgs>;
202
- intersection: <const T extends ReadonlyArray<TSchema>, const TArgs extends TSchemaArguments<StaticIntersection<T>> = {}>(elements: T, args?: TArgs) => TSchema<TIntersection<T>> & NoInfer<TArgs>;
203
+ intersection: <const T extends ReadonlyArray<TSchema>, const TArgs extends TSchemaArguments<StaticIntersection<T>> = {}>(elements: T, args?: TArgs & TSchemaArguments<StaticIntersection<T>>) => TSchema<TIntersection<T>> & NoInfer<TArgs>;
203
204
  number: <TArgs extends TSchemaArguments<number>>(args?: TArgs) => TSchema<TNumber> & NoInfer<TArgs>;
204
205
  object: <T extends TProperties, TArgs extends TSchemaArguments<object>>(properties?: T, args?: TArgs) => TSchema<TObject<T>> & NoInfer<TArgs>;
205
- record: <TKey extends TRecordKey, TValue extends TSchema, const TArgs extends TSchemaArguments<StaticRecord<TKey, TValue>> = {}>(key: TKey, value: TValue, args?: TArgs) => TSchema<TRecord<TKey, TValue>> & NoInfer<TArgs>;
206
+ record: <TKey extends TRecordKey, TValue extends TSchema, const TArgs extends TSchemaArguments<StaticRecord<TKey, TValue>> = {}>(key: TKey, value: TValue, args?: TArgs & TSchemaArguments<StaticRecord<TKey, TValue>>) => TSchema<TRecord<TKey, TValue>> & NoInfer<TArgs>;
206
207
  string: <const TValue extends string = string, TArgs extends TSchemaArguments<string> = TSchemaArguments<string>>(args?: TArgs & {
207
208
  enum?: TEnum<TValue>;
208
209
  }) => TSchema<TString<TValue>> & NoInfer<TArgs>;
209
210
  type: typeof createType;
210
- undefined: <const TArgs extends TSchemaArguments<undefined> = {}>(args?: TArgs) => TSchema<TUndefined> & NoInfer<TArgs>;
211
- union: <const T extends ReadonlyArray<TSchema>, const TArgs extends TSchemaArguments<StaticUnion<T>> = {}>(elements: T, args?: TArgs) => TSchema<TUnion<T>> & NoInfer<TArgs>;
211
+ undefined: <const TArgs extends TSchemaArguments<undefined> = {}>(args?: TArgs & TSchemaArguments<undefined>) => TSchema<TUndefined> & NoInfer<TArgs>;
212
+ union: <const T extends ReadonlyArray<TSchema>, const TArgs extends TSchemaArguments<StaticUnion<T>> = {}>(elements: T, args?: TArgs & TSchemaArguments<StaticUnion<T>>) => TSchema<TUnion<T>> & NoInfer<TArgs>;
212
213
  unknown: <T = unknown, TArgs extends TSchemaArguments<T> = TSchemaArguments<T>>(args?: TArgs) => TSchema<TUnknown<T>> & NoInfer<TArgs>;
213
- void: <const TArgs extends TSchemaArguments<void> = {}>(args?: TArgs) => TSchema<TVoid> & NoInfer<TArgs>;
214
+ void: <const TArgs extends TSchemaArguments<void> = {}>(args?: TArgs & TSchemaArguments<void>) => TSchema<TVoid> & NoInfer<TArgs>;
214
215
  };
215
216
  type OptionalKeys<T extends TProperties> = { [K in keyof T]: T[K] extends {
216
217
  optional: true;
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as TVector, a as LogicUtil, c as TInterfaceConstantValue, d as TSchema, f as TVoid, g as MaybePromise, h as DeepPartial, i as LogicType, l as TLogicNode, m as CVector, n as ELogicType, o as Static, p as makeLogicNode, r as EVarType, s as TInterfaceConfig, t as ELogicScope, u as TObject } from "./index-B4kxQtaL.mjs";
1
+ import { _ as TVector, a as LogicUtil, c as TInterfaceConstantValue, d as TSchema, f as TVoid, g as MaybePromise, h as DeepPartial, i as LogicType, l as TLogicNode, m as CVector, n as ELogicType, o as Static, p as makeLogicNode, r as EVarType, s as TInterfaceConfig, t as ELogicScope, u as TObject } from "./index-w5zIwwtu.mjs";
2
2
  import { Component, ComputedRef, Directive } from "vue";
3
3
  import "@sinclair/typebox";
4
4
  import { IconDefinition } from "@fortawesome/fontawesome-svg-core";
package/dist/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
- import { a as LogicUtil, c as mergeIntersection, i as LogicType, n as ELogicType, o as getSchemaDefault, p as cloneWithFunctions, r as EVarType, s as makeLogicNode, t as ELogicScope } from "./dist-CZjmIqBC.mjs";
1
+ import { i as cloneWithFunctions } from "./dist-BBW6rNSm.mjs";
2
+ import { a as LogicUtil, c as mergeIntersection, i as LogicType, n as ELogicType, o as getSchemaDefault, r as EVarType, s as makeLogicNode, t as ELogicScope } from "./dist-Dyisk4Ug.mjs";
2
3
  import { createElementBlock, openBlock, renderSlot } from "vue";
3
4
  import { Type } from "@sinclair/typebox";
4
5
  // \0/plugin-vue/export-helper
package/dist/preview.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { a as getNpmCdnUrl } from "./dist-BBW6rNSm.mjs";
1
2
  import { extname, join } from "path";
2
3
  import { existsSync, readFileSync } from "fs";
3
4
  import fastifyCors from "@fastify/cors";
@@ -7,10 +8,10 @@ import Fastify from "fastify";
7
8
  function transformImports(content, externals) {
8
9
  return content.replace(/\bimport\s+(.*?)\s+from\s+['"]([^.'/][^'"]*)['"];/g, (match, imports, pkg) => {
9
10
  if (externals.includes(pkg)) return match;
10
- return `import ${imports} from 'https://esm.sh/${pkg}';`;
11
+ return `import ${imports} from '${getNpmCdnUrl(pkg)}';`;
11
12
  }).replace(/\bimport\s+['"]([^.'/][^'"]*)['"];/g, (match, pkg) => {
12
13
  if (externals.includes(pkg)) return match;
13
- return `import 'https://esm.sh/${pkg}';`;
14
+ return `import '${getNpmCdnUrl(pkg)}';`;
14
15
  });
15
16
  }
16
17
  // src/preview/server.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luna-park/plugin",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "private": false,
5
5
  "description": "Plugin helper for Luna Park.",
6
6
  "homepage": "https://luna-park.app",