x-runtime-lib 0.2.1 → 0.2.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.
@@ -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,4 +1,4 @@
1
- import { ZElements } from './types';
2
- export declare const elements: ZElements;
1
+ export * from './elements';
3
2
  export * from './types';
4
- export * from './_pkg';
3
+ export * from './_pkgs';
4
+ export * from './utils';
@@ -58,6 +58,7 @@ export type ZGroup = {
58
58
  };
59
59
  export type ZPkg = {
60
60
  version: string;
61
+ elements: Set<string>;
61
62
  globalityKey: string;
62
63
  refKey: string;
63
64
  groups: ZGroup[];
@@ -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 h, nextTick as p } 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 _(), h(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,139 @@ 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
+ case "select":
98
+ return typeof e.default == "string" ? e.default : "";
99
+ default:
100
+ console.assert(!1, `get prop default failed, not implemented ui=${e.ui}`);
101
+ }
102
+ }
103
+ function k(e, o) {
104
+ function n(r, t) {
105
+ t.static || (t.children ? t.array ? r[t.key] = v(t) : t.children.forEach((s) => {
106
+ t.keyFlag ? n(r, s) : (r[t.key] = {}, n(r[t.key], s));
107
+ }) : r[t.key] = v(t));
108
+ }
109
+ o.forEach((r) => n(e, r));
110
+ }
111
+ function q(e, o, n, r, t) {
112
+ const s = B(e, o);
113
+ if (!s) {
114
+ console.error("invalid prop tag");
115
+ return;
116
+ }
117
+ const a = O[n];
118
+ if (!a) {
119
+ console.error(`pkg not found version=${n}`);
120
+ return;
121
+ }
122
+ const l = {}, f = z(16);
123
+ if (r) {
124
+ const c = a.refKey;
125
+ if (!a.elements.has(c)) {
126
+ console.error(`[ref] element not found in pkg key=${t}`);
127
+ return;
128
+ }
129
+ const i = d[c];
130
+ if (!i) {
131
+ console.error(`[ref] element not found in global key=${t}`);
132
+ return;
133
+ }
134
+ const u = i.props[s];
135
+ if (!u) {
136
+ console.error(`[ref] props not found key=${t} tag=${s}`);
137
+ return;
138
+ }
139
+ k(l, u), l.id = f, l.ref = {
140
+ id: t
141
+ };
142
+ } else {
143
+ if (!a.elements.has(t)) {
144
+ console.error(`[key] element not found in pkg key=${t}`);
145
+ return;
146
+ }
147
+ const c = d[t];
148
+ if (!c) {
149
+ console.error(`[key] element not found in global key=${t}`);
150
+ return;
151
+ }
152
+ const i = c.props[s];
153
+ if (!i) {
154
+ console.error(`[key] props not found key=${t} tag=${s}`);
155
+ return;
156
+ }
157
+ k(l, i), l.id = f, l.key = t, c.leaf || (l.children = []);
158
+ }
159
+ return l;
160
+ }
161
+ const S = (e, o) => {
162
+ const n = e[o];
163
+ return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((r, t) => {
164
+ (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(t.bind(null, new Error("Unknown variable dynamic import: " + o)));
67
165
  });
68
166
  };
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();
167
+ async function D(e, o) {
168
+ const n = await S(/* @__PURE__ */ Object.assign({ "./locales/en.ts": () => import("./en-DKTWxIj4.js"), "./locales/zhHans.ts": () => import("./zhHans-QtZriYRu.js") }), `./locales/${o}.ts`);
169
+ return e.global.setLocaleMessage(o, n.default), p();
72
170
  }
73
- const h = { install: f };
171
+ const F = { install: P };
74
172
  export {
75
- h as default,
76
- w as elements,
77
- M as loadLocaleMessageElement,
78
- x as pkgs
173
+ F as default,
174
+ d as elements,
175
+ B as getPropTag,
176
+ D as loadLocaleMessageElement,
177
+ O as pkgs,
178
+ q as spawnNode
79
179
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "x-runtime-lib",
3
3
  "private": false,
4
- "version": "0.2.1",
4
+ "version": "0.2.3",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",