x-runtime-lib 0.2.0 → 0.2.2

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,2 @@
1
- import { ZPkg } from '../types';
2
- export declare const pkgs: {
3
- [key: string]: ZPkg;
4
- };
1
+ import { ZPkgs } from '../types';
2
+ export declare const pkgs: ZPkgs;
@@ -0,0 +1,2 @@
1
+ import { ZPkgs } from '../types';
2
+ export declare const pkgs: ZPkgs;
@@ -0,0 +1,3 @@
1
+ import { ZPkg } from '../../types';
2
+ declare const pkg: ZPkg;
3
+ export default pkg;
@@ -0,0 +1,2 @@
1
+ import { ZElements } from './types';
2
+ export declare const elements: ZElements;
@@ -1,6 +1,4 @@
1
- import { ZElement } from './types';
2
- export declare const elements: {
3
- [key: string]: ZElement;
4
- };
1
+ export * from './elements';
5
2
  export * from './types';
6
- export * from './_pkg';
3
+ export * from './_pkgs';
4
+ export * from './utils';
@@ -35,6 +35,9 @@ export type ZProp = {
35
35
  static?: boolean;
36
36
  value?: unknown;
37
37
  };
38
+ export type ZProps = {
39
+ [key: string]: ZProp[];
40
+ };
38
41
  export type ZElement = {
39
42
  key: string;
40
43
  name: string;
@@ -42,9 +45,11 @@ export type ZElement = {
42
45
  leaf: boolean;
43
46
  events: ZEvent[];
44
47
  methods: ZMethod[];
45
- props: {
46
- [key: string]: ZProp[];
47
- };
48
+ props: ZProps;
49
+ internal?: boolean;
50
+ };
51
+ export type ZElements = {
52
+ [key: string]: ZElement;
48
53
  };
49
54
  export type ZGroup = {
50
55
  key: string;
@@ -53,7 +58,11 @@ export type ZGroup = {
53
58
  };
54
59
  export type ZPkg = {
55
60
  version: string;
61
+ elements: Set<string>;
56
62
  globalityKey: string;
57
63
  refKey: string;
58
64
  groups: ZGroup[];
59
65
  };
66
+ export type ZPkgs = {
67
+ [key: string]: ZPkg;
68
+ };
@@ -0,0 +1,4 @@
1
+ export declare function getPropTag(type: string, subtype: string): string | undefined;
2
+ export declare function spawnNode(type: string, subtype: string, version: string, ref: {
3
+ id: string;
4
+ }, key: string): object | undefined;
package/dist/index.js CHANGED
@@ -1,21 +1,21 @@
1
- import { resolveComponent as a, openBlock as l, createBlock as i, nextTick as r } from "vue";
2
- const m = (t, n) => {
3
- const e = t.__vccOpts || t;
4
- for (const [s, o] of n)
5
- e[s] = o;
6
- return e;
7
- }, u = {};
8
- function p(t, n) {
9
- const e = a("v-btn");
10
- return l(), i(e);
1
+ import { resolveComponent as b, openBlock as _, createBlock as p, nextTick as h } from "vue";
2
+ const $ = (e, o) => {
3
+ const n = e.__vccOpts || e;
4
+ for (const [r, t] of o)
5
+ n[r] = t;
6
+ return n;
7
+ }, w = {};
8
+ function x(e, o) {
9
+ const n = b("v-btn");
10
+ return _(), p(n);
11
11
  }
12
- const v = /* @__PURE__ */ m(u, [["render", p]]), f = (t) => {
13
- t.component("z-btn-v1", v);
14
- }, _ = [
12
+ const M = /* @__PURE__ */ $(w, [["render", x]]), P = (e) => {
13
+ e.component("z-btn-v1", M);
14
+ }, C = [
15
15
  { title: "default", value: "default" },
16
16
  { title: "comfortable", value: "comfortable" },
17
17
  { title: "compact", value: "compact" }
18
- ], c = {
18
+ ], m = {
19
19
  key: "settings",
20
20
  keyFlag: !0,
21
21
  name: "settings",
@@ -24,11 +24,11 @@ const v = /* @__PURE__ */ m(u, [["render", p]]), f = (t) => {
24
24
  key: "density",
25
25
  name: "density",
26
26
  ui: "select",
27
- items: _,
27
+ items: C,
28
28
  default: "default"
29
29
  }
30
30
  ]
31
- }, b = {
31
+ }, I = {
32
32
  key: "btn_v1",
33
33
  name: "button",
34
34
  comp: "z-btn-v1",
@@ -41,39 +41,137 @@ const v = /* @__PURE__ */ m(u, [["render", p]]), f = (t) => {
41
41
  ],
42
42
  methods: [],
43
43
  props: {
44
- pageCommon: [c],
45
- compCommon: [c]
44
+ pageCommon: [m],
45
+ compCommon: [m]
46
46
  }
47
- }, y = [
47
+ }, d = {
48
+ // basic
49
+ btn_v1: I
50
+ }, E = /* @__PURE__ */ new Set([
51
+ "globality_v1",
52
+ "btn_v1",
53
+ "ref_v1"
54
+ ]), K = [
48
55
  {
49
56
  key: "basic",
50
57
  name: "basic",
51
58
  items: ["globality_v1", "btn_v1"]
52
59
  }
53
- ], d = {
60
+ ], N = {
54
61
  version: "v1",
55
62
  globalityKey: "globality_v1",
56
63
  refKey: "ref_v1",
57
- groups: y
58
- }, x = {
59
- v1: d
60
- }, w = {
61
- // basic
62
- btn_v1: b
63
- }, g = (t, n) => {
64
- const e = t[n];
65
- return e ? typeof e == "function" ? e() : Promise.resolve(e) : new Promise((s, o) => {
66
- (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(o.bind(null, new Error("Unknown variable dynamic import: " + n)));
64
+ elements: E,
65
+ groups: K
66
+ }, O = {
67
+ v1: N
68
+ }, g = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
69
+ function z(e) {
70
+ let o = "";
71
+ for (let n = 0; n < e; n++) {
72
+ const r = Math.floor(Math.random() * g.length);
73
+ o += g[r];
74
+ }
75
+ return o;
76
+ }
77
+ function B(e, o) {
78
+ if (e === "page") {
79
+ if (o == "common")
80
+ return "pageCommon";
81
+ } else if (e === "comp" && o === "common")
82
+ return "compCommon";
83
+ }
84
+ function y(e) {
85
+ return JSON.parse(JSON.stringify(e));
86
+ }
87
+ function v(e) {
88
+ if (e.array)
89
+ return e.default instanceof Array ? y(e.default) : [];
90
+ switch (e.ui) {
91
+ case "void":
92
+ return e.default !== void 0 ? y(e.default) : null;
93
+ case "strInput":
94
+ return typeof e.default == "string" ? e.default : "";
95
+ case "numInput":
96
+ return typeof e.default == "number" ? e.default : 0;
97
+ default:
98
+ console.assert(!1, `not implemented ui=${e.ui}`);
99
+ }
100
+ }
101
+ function k(e, o) {
102
+ function n(r, t) {
103
+ t.static || (t.children ? t.array ? r[t.key] = v(t) : t.children.forEach((s) => {
104
+ t.keyFlag ? n(r, s) : (r[t.key] = {}, n(r[t.key], s));
105
+ }) : r[t.key] = v(t));
106
+ }
107
+ o.forEach((r) => n(e, r));
108
+ }
109
+ function q(e, o, n, r, t) {
110
+ const s = B(e, o);
111
+ if (!s) {
112
+ console.error("invalid prop tag");
113
+ return;
114
+ }
115
+ const a = O[n];
116
+ if (!a) {
117
+ console.error(`pkg not found version=${n}`);
118
+ return;
119
+ }
120
+ const c = {}, f = z(16);
121
+ if (r) {
122
+ const l = a.refKey;
123
+ if (!a.elements.has(l)) {
124
+ console.error(`[ref] element not found in pkg key=${t}`);
125
+ return;
126
+ }
127
+ const i = d[l];
128
+ if (!i) {
129
+ console.error(`[ref] element not found in global key=${t}`);
130
+ return;
131
+ }
132
+ const u = i.props[s];
133
+ if (!u) {
134
+ console.error(`[ref] props not found key=${t} tag=${s}`);
135
+ return;
136
+ }
137
+ k(c, u), c.id = f, c.ref = {
138
+ id: t
139
+ };
140
+ } else {
141
+ if (!a.elements.has(t)) {
142
+ console.error(`[key] element not found in pkg key=${t}`);
143
+ return;
144
+ }
145
+ const l = d[t];
146
+ if (!l) {
147
+ console.error(`[key] element not found in global key=${t}`);
148
+ return;
149
+ }
150
+ const i = l.props[s];
151
+ if (!i) {
152
+ console.error(`[key] props not found key=${t} tag=${s}`);
153
+ return;
154
+ }
155
+ k(c, i), c.id = f, c.key = t, l.leaf || (c.children = []);
156
+ }
157
+ return c;
158
+ }
159
+ const S = (e, o) => {
160
+ const n = e[o];
161
+ return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((r, t) => {
162
+ (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(t.bind(null, new Error("Unknown variable dynamic import: " + o)));
67
163
  });
68
164
  };
69
- async function M(t, n) {
70
- const e = await g(/* @__PURE__ */ Object.assign({ "./locales/en.ts": () => import("./en-DKTWxIj4.js"), "./locales/zhHans.ts": () => import("./zhHans-QtZriYRu.js") }), `./locales/${n}.ts`);
71
- return t.global.setLocaleMessage(n, e.default), r();
165
+ async function D(e, o) {
166
+ const n = await S(/* @__PURE__ */ Object.assign({ "./locales/en.ts": () => import("./en-DKTWxIj4.js"), "./locales/zhHans.ts": () => import("./zhHans-QtZriYRu.js") }), `./locales/${o}.ts`);
167
+ return e.global.setLocaleMessage(o, n.default), h();
72
168
  }
73
- const h = { install: f };
169
+ const F = { install: P };
74
170
  export {
75
- h as default,
76
- w as elements,
77
- M as loadLocaleMessageElement,
78
- x as pkgs
171
+ F as default,
172
+ d as elements,
173
+ B as getPropTag,
174
+ D as loadLocaleMessageElement,
175
+ O as pkgs,
176
+ q as spawnNode
79
177
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "x-runtime-lib",
3
3
  "private": false,
4
- "version": "0.2.0",
4
+ "version": "0.2.2",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",