@luna-park/plugin 1.0.4 → 1.0.6

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/bin/preview.js ADDED
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env node
2
+ import { parseArgs } from "node:util";
3
+
4
+ import { resolve } from "path";
5
+
6
+ import { startPreviewServer } from "../dist/preview.js";
7
+
8
+ const cwd = process.cwd();
9
+
10
+ // Parse CLI arguments
11
+ const { values } = parseArgs({
12
+ options: {
13
+ dist: {
14
+ default: "dist",
15
+ short: "d",
16
+ type: "string"
17
+ },
18
+ help: {
19
+ default: false,
20
+ short: "h",
21
+ type: "boolean"
22
+ },
23
+ port: {
24
+ default: "2084",
25
+ short: "p",
26
+ type: "string"
27
+ }
28
+ }
29
+ });
30
+
31
+ if (values.help) {
32
+ console.log(`
33
+ Usage: luna-preview [options]
34
+
35
+ Options:
36
+ -p, --port <port> Port to run the server on (default: 2084)
37
+ -d, --dist <dir> Distribution directory to serve (default: dist)
38
+ -h, --help Show this help message
39
+ `);
40
+ process.exit(0);
41
+ }
42
+
43
+ const dist = resolve(cwd, values.dist);
44
+ const port = parseInt(values.port);
45
+
46
+ startPreviewServer({
47
+ dist,
48
+ externals: ["vue", "vue-router"],
49
+ port
50
+ });
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-DmZsz62R.cjs");function o(e){return e}async function r(e,n){return typeof e=="function"?e({app:n.app,config:n.config,internal:n.internal,mode:n.mode||"editor"}):e}exports.ELogicScope=i.J;exports.ELogicType=i._;exports.EVarType=i.i;exports.LogicType=i.u;exports.LogicUtil=i.x;exports.makeLogicNode=i.T;exports.getPluginParam=r;exports.makePlugin=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-DmZsz62R.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;
package/dist/index.d.ts CHANGED
@@ -122,7 +122,7 @@ declare enum EThemeMode {
122
122
  Auto = "auto"
123
123
  }
124
124
 
125
- declare enum ETokenType {
125
+ export declare enum ETokenType {
126
126
  Color = "color",
127
127
  FontSize = "font-size",
128
128
  FontWeight = "font-weight",
@@ -764,7 +764,7 @@ export declare type TPlugin<TConfig extends TSchema = TSchema, TInternal = unkno
764
764
  editor?: {
765
765
  components?: TOption<TEnv<TConfig, TInternal>, Array<TComponent>>;
766
766
  nodes?: TOption<TEnv<TConfig, TInternal>, Array<TLogicNode>>;
767
- tokens?: TOption<TEnv<TConfig, TInternal>, Record<ETokenType, Record<string, TToken>>>;
767
+ tokens?: TOption<TEnv<TConfig, TInternal>, Array<TToken>>;
768
768
  wrapper?: TOption<TEnv<TConfig, TInternal>, Component>;
769
769
  };
770
770
  icon: string;
@@ -852,8 +852,10 @@ declare type TTextExport = {
852
852
  state: TStateExport;
853
853
  };
854
854
 
855
- declare type TToken = {
855
+ export declare type TToken = {
856
+ id: string;
856
857
  name?: string;
858
+ type: ETokenType;
857
859
  value: string;
858
860
  };
859
861
 
package/dist/index.js CHANGED
@@ -1,22 +1,24 @@
1
- import { J as r, _ as p, i as t, u, x as f, T as g } from "./index-CxGB_fZK.js";
2
- function n(o) {
3
- return o;
1
+ import { J as e, _ as f, i as g, u as l, x as m, T as u } from "./index-CxGB_fZK.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;
4
5
  }
5
- async function a(o, i) {
6
- return typeof o == "function" ? o({
7
- app: i.app,
8
- config: i.config,
9
- internal: i.internal,
10
- mode: i.mode || "editor"
11
- }) : o;
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;
12
13
  }
13
14
  export {
14
- r as ELogicScope,
15
- p as ELogicType,
16
- t as EVarType,
17
- u as LogicType,
18
- f as LogicUtil,
15
+ e as ELogicScope,
16
+ f as ELogicType,
17
+ t as ETokenType,
18
+ g as EVarType,
19
+ l as LogicType,
20
+ m as LogicUtil,
19
21
  a as getPluginParam,
20
- g as makeLogicNode,
22
+ u as makeLogicNode,
21
23
  n as makePlugin
22
24
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@fastify/cors"),p=require("@fastify/static"),f=require("fastify"),a=require("fs"),o=require("path");function d(t,e){return t.replace(/import\s+(.*?)\s+from\s+['"]([^.'/][^'"]*)['"]/g,(r,s,n)=>e.includes(n)?r:`import ${s} from 'https://esm.sh/${n}'`).replace(/import\s+['"]([^.'/][^'"]*)['"]/g,(r,s)=>e.includes(s)?r:`import 'https://esm.sh/${s}'`)}async function m(t){const e=f({logger:!1});e.register(l,{origin:["https://luna-park.app",/localhost:[0-9]+/,/127\.0\.0\.1:[0-9]+/]}),e.addHook("onRequest",async(r,s)=>{const n=r.url==="/"?"/index.js":r.url;let i=o.join(t.dist,n);if(!a.existsSync(i)&&!o.extname(r.url)&&(i=o.join(t.dist,"index.js")),!a.existsSync(i))return;if(o.extname(i)===".js"){const c=a.readFileSync(i,"utf-8"),u=d(c,t.externals);return s.type("application/javascript").send(u),s}}),e.register(p,{prefix:"/",root:t.dist}),await e.listen({host:"127.0.0.1",port:t.port}),console.log(`Preview server started at http://127.0.0.1:${t.port}`)}exports.startPreviewServer=m;
@@ -0,0 +1,7 @@
1
+ export declare function startPreviewServer(config: {
2
+ dist: string;
3
+ externals: Array<string>;
4
+ port: number;
5
+ }): Promise<void>;
6
+
7
+ export { }
@@ -0,0 +1,39 @@
1
+ import l from "@fastify/cors";
2
+ import c from "@fastify/static";
3
+ import u from "fastify";
4
+ import { existsSync as n, readFileSync as d } from "fs";
5
+ import { join as a, extname as p } from "path";
6
+ function h(t, r) {
7
+ return t.replace(
8
+ /import\s+(.*?)\s+from\s+['"]([^.'/][^'"]*)['"]/g,
9
+ (e, s, i) => r.includes(i) ? e : `import ${s} from 'https://esm.sh/${i}'`
10
+ ).replace(
11
+ /import\s+['"]([^.'/][^'"]*)['"]/g,
12
+ (e, s) => r.includes(s) ? e : `import 'https://esm.sh/${s}'`
13
+ );
14
+ }
15
+ async function w(t) {
16
+ const r = u({ logger: !1 });
17
+ r.register(l, {
18
+ origin: [
19
+ "https://luna-park.app",
20
+ /localhost:[0-9]+/,
21
+ /127\.0\.0\.1:[0-9]+/
22
+ ]
23
+ }), r.addHook("onRequest", async (e, s) => {
24
+ const i = e.url === "/" ? "/index.js" : e.url;
25
+ let o = a(t.dist, i);
26
+ if (!n(o) && !p(e.url) && (o = a(t.dist, "index.js")), !n(o))
27
+ return;
28
+ if (p(o) === ".js") {
29
+ const f = d(o, "utf-8"), m = h(f, t.externals);
30
+ return s.type("application/javascript").send(m), s;
31
+ }
32
+ }), r.register(c, {
33
+ prefix: "/",
34
+ root: t.dist
35
+ }), await r.listen({ host: "127.0.0.1", port: t.port }), console.log(`Preview server started at http://127.0.0.1:${t.port}`);
36
+ }
37
+ export {
38
+ w as startPreviewServer
39
+ };
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@luna-park/plugin",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "private": false,
5
5
  "description": "Plugin helper for Luna Park.",
6
6
  "homepage": "https://luna-park.app",
7
+ "bin": {
8
+ "luna-preview": "./bin/preview.js"
9
+ },
7
10
  "repository": {
8
11
  "type": "git",
9
12
  "url": "https://github.com/lunapark/lunapark"
@@ -31,27 +34,31 @@
31
34
  "files": [
32
35
  "dist/**"
33
36
  ],
34
- "dependencies": {
35
- "@fortawesome/fontawesome-svg-core": "^7.1.0",
36
- "vite": "^7.2.2",
37
- "vue": "^3.5.24"
38
- },
39
37
  "devDependencies": {
38
+ "@fastify/cors": "^11.1.0",
39
+ "@fastify/static": "^8.3.0",
40
+ "@fortawesome/fontawesome-svg-core": "^7.1.0",
40
41
  "@luna-park/eslint-config": "^1.0.2",
41
42
  "@microsoft/api-extractor": "^7.55.0",
42
- "@vitest/ui": "^4.0.10",
43
+ "@vitest/ui": "^4.0.12",
43
44
  "eslint": "^9.39.1",
44
- "rimraf": "^6.1.0",
45
+ "fastify": "^5.6.2",
46
+ "rimraf": "^6.1.2",
45
47
  "typescript": "^5.9.3",
46
48
  "typescript-eslint": "^8.47.0",
47
49
  "unplugin-dts": "1.0.0-beta.6",
48
- "vitest": "^4.0.10",
50
+ "vite": "^7.2.4",
51
+ "vitest": "^4.0.12",
52
+ "vue": "^3.5.24",
49
53
  "@luna-park/logicnodes": "^2.0.0",
50
54
  "@luna-park/utils": "^2.0.0",
51
55
  "@luna-park/shared": "^1.0.0"
52
56
  },
53
57
  "peerDependencies": {
58
+ "@fastify/cors": "^11.1.0",
59
+ "@fastify/static": "^8.3.0",
54
60
  "@fortawesome/fontawesome-svg-core": "^7.1.0",
61
+ "fastify": "^5.6.2",
55
62
  "typescript": "^5.9.3",
56
63
  "vite": "^7.2.1",
57
64
  "vue": "^3.5.23"
@@ -60,6 +67,7 @@
60
67
  "build": "rimraf dist && vite build",
61
68
  "dev": "vite build --watch --minify=false",
62
69
  "dev:test": "vitest --ui",
63
- "test": "vitest"
70
+ "test": "vitest",
71
+ "test:preview": "node bin/preview.js"
64
72
  }
65
73
  }