nemesia 1.0.2 → 1.1.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.
- package/README.md +13 -1
- package/dist/nemesia.js +205 -191
- package/dist/nemesia.js.map +1 -1
- package/dist/nemesia.umd.js +1 -1
- package/dist/nemesia.umd.js.map +1 -1
- package/dist/src/lifecycle/instantiate.d.ts.map +1 -1
- package/dist/src/public/define-component.d.ts +11 -5
- package/dist/src/public/define-component.d.ts.map +1 -1
- package/dist/src/types/entities.d.ts +23 -5
- package/dist/src/types/entities.d.ts.map +1 -1
- package/dist/src/types/public-api.d.ts +1 -1
- package/dist/src/types/public-api.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -26,9 +26,14 @@ const counter = defineComponent({
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
state: () => ({ count: 0 }),
|
|
29
|
+
computed: (ctx) => ({
|
|
30
|
+
get label() {
|
|
31
|
+
return `Count: ${ctx.state.count}`
|
|
32
|
+
}
|
|
33
|
+
}),
|
|
29
34
|
methods: (ctx) => ({
|
|
30
35
|
updateUI() {
|
|
31
|
-
ctx.refs.value.textContent =
|
|
36
|
+
ctx.refs.value.textContent = ctx.computed.label
|
|
32
37
|
},
|
|
33
38
|
increment() {
|
|
34
39
|
ctx.state.count += ctx.options.step
|
|
@@ -65,6 +70,13 @@ Public methods from `nemesia`:
|
|
|
65
70
|
- `getRef(selector, tagOrConfig?)`
|
|
66
71
|
- `getOption(attribute, typeOrConfig?)`
|
|
67
72
|
|
|
73
|
+
Component definition fields:
|
|
74
|
+
|
|
75
|
+
- `state?: () => State`
|
|
76
|
+
- `computed?: (ctx) => Computed`
|
|
77
|
+
- `methods?: (ctx) => Methods`
|
|
78
|
+
- `setup?: (ctx) => void`
|
|
79
|
+
|
|
68
80
|
Application instance methods:
|
|
69
81
|
|
|
70
82
|
- `register(component)`
|
package/dist/nemesia.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
class
|
|
1
|
+
var L = Object.defineProperty;
|
|
2
|
+
var B = (e, t, r) => t in e ? L(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var v = (e, t, r) => B(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
class I {
|
|
5
5
|
constructor() {
|
|
6
|
-
|
|
6
|
+
v(this, "items", /* @__PURE__ */ new Map());
|
|
7
7
|
}
|
|
8
8
|
register(t) {
|
|
9
9
|
if (this.items.has(t.name))
|
|
@@ -14,12 +14,12 @@ class x {
|
|
|
14
14
|
return Array.from(this.items.values());
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function M(e, t) {
|
|
18
18
|
return e instanceof Document ? !0 : e instanceof Element && e === t || e.contains(t);
|
|
19
19
|
}
|
|
20
|
-
class
|
|
20
|
+
class F {
|
|
21
21
|
constructor() {
|
|
22
|
-
|
|
22
|
+
v(this, "items", /* @__PURE__ */ new Map());
|
|
23
23
|
}
|
|
24
24
|
set(t) {
|
|
25
25
|
this.items.set(t.element, t);
|
|
@@ -37,164 +37,164 @@ class I {
|
|
|
37
37
|
return Array.from(this.items.values());
|
|
38
38
|
}
|
|
39
39
|
listInScope(t) {
|
|
40
|
-
return this.list().filter((r) =>
|
|
40
|
+
return this.list().filter((r) => M(t, r.element));
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function H(e, t, r) {
|
|
44
44
|
let n = null;
|
|
45
45
|
return {
|
|
46
|
-
start(
|
|
47
|
-
!e || n || (n = new MutationObserver((
|
|
48
|
-
for (const
|
|
49
|
-
|
|
50
|
-
(
|
|
51
|
-
}),
|
|
52
|
-
(
|
|
46
|
+
start(a = document) {
|
|
47
|
+
!e || n || (n = new MutationObserver((s) => {
|
|
48
|
+
for (const o of s)
|
|
49
|
+
o.addedNodes.forEach((u) => {
|
|
50
|
+
(u instanceof Element || u instanceof DocumentFragment) && t(u);
|
|
51
|
+
}), o.removedNodes.forEach((u) => {
|
|
52
|
+
(u instanceof Element || u instanceof DocumentFragment) && r(u);
|
|
53
53
|
});
|
|
54
|
-
}), n.observe(
|
|
54
|
+
}), n.observe(a, { childList: !0, subtree: !0 }));
|
|
55
55
|
},
|
|
56
56
|
stop() {
|
|
57
57
|
n && (n.disconnect(), n = null);
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function T(e, t, r, n) {
|
|
62
62
|
return e.addEventListener(t, r, n), () => {
|
|
63
63
|
e.removeEventListener(t, r, n);
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function f(e, t, r) {
|
|
67
67
|
if (r === void 0) {
|
|
68
68
|
console.warn(`[Nemesia:${e}] ${t}`);
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
71
|
console.warn(`[Nemesia:${e}] ${t}`, r);
|
|
72
72
|
}
|
|
73
|
-
function
|
|
73
|
+
function z(e) {
|
|
74
74
|
const t = e.trim().toLowerCase();
|
|
75
75
|
if (t === "true" || t === "1")
|
|
76
76
|
return !0;
|
|
77
77
|
if (t === "false" || t === "0")
|
|
78
78
|
return !1;
|
|
79
79
|
}
|
|
80
|
-
function
|
|
80
|
+
function R(e, t) {
|
|
81
81
|
if (e === "string")
|
|
82
82
|
return t;
|
|
83
83
|
if (e === "number") {
|
|
84
84
|
const r = Number(t);
|
|
85
85
|
return Number.isFinite(r) ? r : void 0;
|
|
86
86
|
}
|
|
87
|
-
return
|
|
87
|
+
return z(t);
|
|
88
88
|
}
|
|
89
|
-
function
|
|
89
|
+
function V(e, t, r) {
|
|
90
90
|
const n = {};
|
|
91
|
-
for (const [
|
|
92
|
-
const
|
|
93
|
-
if (
|
|
94
|
-
if (
|
|
95
|
-
n[
|
|
91
|
+
for (const [a, s] of Object.entries(r)) {
|
|
92
|
+
const o = t.getAttribute(s.attribute);
|
|
93
|
+
if (o === null) {
|
|
94
|
+
if (s.hasDefault) {
|
|
95
|
+
n[a] = s.defaultValue;
|
|
96
96
|
continue;
|
|
97
97
|
}
|
|
98
|
-
if (
|
|
99
|
-
n[
|
|
98
|
+
if (s.optional) {
|
|
99
|
+
n[a] = void 0;
|
|
100
100
|
continue;
|
|
101
101
|
}
|
|
102
|
-
return
|
|
102
|
+
return f(e, `required option "${a}" was not found`), { ok: !1 };
|
|
103
103
|
}
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
106
|
-
return
|
|
107
|
-
n[
|
|
104
|
+
const u = R(s.type, o);
|
|
105
|
+
if (u === void 0)
|
|
106
|
+
return f(e, `option "${a}" has invalid ${s.type} value`), { ok: !1 };
|
|
107
|
+
n[a] = u;
|
|
108
108
|
}
|
|
109
109
|
return { ok: !0, value: n };
|
|
110
110
|
}
|
|
111
|
-
function
|
|
111
|
+
function K(e, t) {
|
|
112
112
|
const r = [];
|
|
113
113
|
return e.matches(t) && r.push(e), e.querySelectorAll(t).forEach((n) => {
|
|
114
114
|
r.push(n);
|
|
115
115
|
}), r;
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function $(e, t) {
|
|
118
118
|
return e.tagName.toLowerCase() === t.toLowerCase();
|
|
119
119
|
}
|
|
120
|
-
function
|
|
120
|
+
function P(e, t, r) {
|
|
121
121
|
const n = {};
|
|
122
|
-
for (const [
|
|
123
|
-
const
|
|
124
|
-
if (
|
|
125
|
-
if (
|
|
126
|
-
if (
|
|
127
|
-
n[
|
|
122
|
+
for (const [a, s] of Object.entries(r)) {
|
|
123
|
+
const o = K(t, s.selector);
|
|
124
|
+
if (s.many) {
|
|
125
|
+
if (o.length === 0) {
|
|
126
|
+
if (s.optional) {
|
|
127
|
+
n[a] = [];
|
|
128
128
|
continue;
|
|
129
129
|
}
|
|
130
|
-
return
|
|
130
|
+
return f(e, `required ref "${a}" was not found`), { ok: !1 };
|
|
131
131
|
}
|
|
132
|
-
const
|
|
133
|
-
if (!
|
|
134
|
-
n[
|
|
132
|
+
const c = s.tag;
|
|
133
|
+
if (!c) {
|
|
134
|
+
n[a] = o;
|
|
135
135
|
continue;
|
|
136
136
|
}
|
|
137
|
-
if (
|
|
138
|
-
if (
|
|
139
|
-
n[
|
|
137
|
+
if (o.some((m) => !$(m, c))) {
|
|
138
|
+
if (s.optional) {
|
|
139
|
+
n[a] = [];
|
|
140
140
|
continue;
|
|
141
141
|
}
|
|
142
|
-
return
|
|
142
|
+
return f(e, `required ref "${a}" has tag mismatch`), { ok: !1 };
|
|
143
143
|
}
|
|
144
|
-
n[
|
|
144
|
+
n[a] = o;
|
|
145
145
|
continue;
|
|
146
146
|
}
|
|
147
|
-
const
|
|
148
|
-
if (!
|
|
149
|
-
if (
|
|
150
|
-
n[
|
|
147
|
+
const u = o[0] ?? null;
|
|
148
|
+
if (!u) {
|
|
149
|
+
if (s.optional) {
|
|
150
|
+
n[a] = null;
|
|
151
151
|
continue;
|
|
152
152
|
}
|
|
153
|
-
return
|
|
153
|
+
return f(e, `required ref "${a}" was not found`), { ok: !1 };
|
|
154
154
|
}
|
|
155
|
-
if (!
|
|
156
|
-
n[
|
|
155
|
+
if (!s.tag || $(u, s.tag)) {
|
|
156
|
+
n[a] = u;
|
|
157
157
|
continue;
|
|
158
158
|
}
|
|
159
|
-
if (
|
|
160
|
-
n[
|
|
159
|
+
if (s.optional) {
|
|
160
|
+
n[a] = null;
|
|
161
161
|
continue;
|
|
162
162
|
}
|
|
163
|
-
return
|
|
163
|
+
return f(e, `required ref "${a}" has tag mismatch`), { ok: !1 };
|
|
164
164
|
}
|
|
165
165
|
return { ok: !0, value: n };
|
|
166
166
|
}
|
|
167
|
-
function
|
|
167
|
+
function U(e) {
|
|
168
168
|
return Array.isArray(e) ? Array.from(new Set(e)) : [e];
|
|
169
169
|
}
|
|
170
|
-
function
|
|
171
|
-
const t = /* @__PURE__ */ new Map(), r = (
|
|
172
|
-
const
|
|
173
|
-
if (
|
|
174
|
-
for (const
|
|
175
|
-
|
|
170
|
+
function W(e) {
|
|
171
|
+
const t = /* @__PURE__ */ new Map(), r = (s) => {
|
|
172
|
+
const o = t.get(s);
|
|
173
|
+
if (o)
|
|
174
|
+
for (const u of o)
|
|
175
|
+
u();
|
|
176
176
|
}, n = new Proxy(e, {
|
|
177
|
-
set(
|
|
178
|
-
const
|
|
179
|
-
return Object.is(
|
|
177
|
+
set(s, o, u) {
|
|
178
|
+
const c = String(o), l = s[c];
|
|
179
|
+
return Object.is(l, u) || (s[c] = u, r(c)), !0;
|
|
180
180
|
}
|
|
181
181
|
});
|
|
182
182
|
return {
|
|
183
183
|
state: n,
|
|
184
|
-
setState(
|
|
185
|
-
for (const [
|
|
186
|
-
n[
|
|
184
|
+
setState(s) {
|
|
185
|
+
for (const [o, u] of Object.entries(s))
|
|
186
|
+
n[o] = u;
|
|
187
187
|
},
|
|
188
|
-
watch: (
|
|
189
|
-
const
|
|
190
|
-
for (const
|
|
191
|
-
const m = t.get(
|
|
192
|
-
m ? m.add(
|
|
188
|
+
watch: (s, o, u) => {
|
|
189
|
+
const c = U(s);
|
|
190
|
+
for (const l of c) {
|
|
191
|
+
const m = t.get(l);
|
|
192
|
+
m ? m.add(o) : t.set(l, /* @__PURE__ */ new Set([o]));
|
|
193
193
|
}
|
|
194
|
-
return
|
|
195
|
-
for (const
|
|
196
|
-
const m = t.get(
|
|
197
|
-
m && (m.delete(
|
|
194
|
+
return u != null && u.immediate && o(), () => {
|
|
195
|
+
for (const l of c) {
|
|
196
|
+
const m = t.get(l);
|
|
197
|
+
m && (m.delete(o), m.size === 0 && t.delete(l));
|
|
198
198
|
}
|
|
199
199
|
};
|
|
200
200
|
},
|
|
@@ -203,101 +203,115 @@ function P(e) {
|
|
|
203
203
|
}
|
|
204
204
|
};
|
|
205
205
|
}
|
|
206
|
-
function
|
|
206
|
+
function E(e, t, r) {
|
|
207
207
|
for (const n of r)
|
|
208
208
|
try {
|
|
209
209
|
n();
|
|
210
|
-
} catch (
|
|
211
|
-
|
|
210
|
+
} catch (a) {
|
|
211
|
+
f(e, `${t} hook failed`, a);
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
|
-
function
|
|
214
|
+
function S(e, t) {
|
|
215
215
|
for (; t.length > 0; ) {
|
|
216
216
|
const r = t.pop();
|
|
217
217
|
if (r)
|
|
218
218
|
try {
|
|
219
219
|
r();
|
|
220
220
|
} catch (n) {
|
|
221
|
-
|
|
221
|
+
f(e, "cleanup failed", n);
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
|
-
function
|
|
226
|
-
const r =
|
|
225
|
+
function D(e, t) {
|
|
226
|
+
const r = P(e.name, t, e.schema.refs);
|
|
227
227
|
if (!r.ok || !r.value)
|
|
228
228
|
return null;
|
|
229
|
-
const n =
|
|
229
|
+
const n = V(e.name, t, e.schema.options);
|
|
230
230
|
if (!n.ok || !n.value)
|
|
231
231
|
return null;
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
232
|
+
const a = G(e), s = W(a), o = {
|
|
233
|
+
element: t,
|
|
234
|
+
refs: r.value,
|
|
235
|
+
options: n.value,
|
|
236
|
+
state: s.state
|
|
237
|
+
};
|
|
238
|
+
let u = {};
|
|
239
|
+
if (e.computed)
|
|
240
|
+
try {
|
|
241
|
+
u = e.computed(o) ?? {};
|
|
242
|
+
} catch (i) {
|
|
243
|
+
return f(e.name, "computed factory failed", i), s.teardown(), null;
|
|
244
|
+
}
|
|
245
|
+
const c = [], l = [], m = [], h = [], x = (i, y, b, p) => {
|
|
246
|
+
const g = T(i, y, b, p);
|
|
247
|
+
return h.push(g), g;
|
|
248
|
+
}, d = {
|
|
236
249
|
element: t,
|
|
237
250
|
refs: r.value,
|
|
238
251
|
options: n.value,
|
|
239
|
-
state:
|
|
252
|
+
state: s.state,
|
|
253
|
+
computed: u,
|
|
240
254
|
methods: {},
|
|
241
|
-
setState(
|
|
242
|
-
|
|
255
|
+
setState(i) {
|
|
256
|
+
s.setState(i);
|
|
243
257
|
},
|
|
244
|
-
on:
|
|
245
|
-
watch(
|
|
246
|
-
const p =
|
|
247
|
-
return
|
|
258
|
+
on: x,
|
|
259
|
+
watch(i, y, b) {
|
|
260
|
+
const p = s.watch(i, y, b);
|
|
261
|
+
return h.push(p), p;
|
|
248
262
|
},
|
|
249
|
-
onMount(
|
|
250
|
-
|
|
263
|
+
onMount(i) {
|
|
264
|
+
c.push(i);
|
|
251
265
|
},
|
|
252
|
-
onRefresh(
|
|
253
|
-
|
|
266
|
+
onRefresh(i) {
|
|
267
|
+
l.push(i);
|
|
254
268
|
},
|
|
255
|
-
onUnmount(
|
|
256
|
-
|
|
269
|
+
onUnmount(i) {
|
|
270
|
+
m.push(i);
|
|
257
271
|
},
|
|
258
|
-
cleanup(
|
|
259
|
-
|
|
272
|
+
cleanup(i) {
|
|
273
|
+
h.push(i);
|
|
260
274
|
}
|
|
261
275
|
};
|
|
262
276
|
if (e.methods)
|
|
263
277
|
try {
|
|
264
|
-
|
|
265
|
-
} catch (
|
|
266
|
-
return
|
|
278
|
+
d.methods = e.methods(d);
|
|
279
|
+
} catch (i) {
|
|
280
|
+
return f(e.name, "methods factory failed", i), s.teardown(), null;
|
|
267
281
|
}
|
|
268
282
|
if (e.setup)
|
|
269
283
|
try {
|
|
270
|
-
e.setup(
|
|
271
|
-
} catch (
|
|
272
|
-
return
|
|
284
|
+
e.setup(d);
|
|
285
|
+
} catch (i) {
|
|
286
|
+
return f(e.name, "setup failed", i), S(e.name, h), s.teardown(), null;
|
|
273
287
|
}
|
|
274
|
-
|
|
275
|
-
let
|
|
288
|
+
E(e.name, "mount", c);
|
|
289
|
+
let w = !0;
|
|
276
290
|
return {
|
|
277
291
|
component: e,
|
|
278
292
|
element: t,
|
|
279
|
-
ctx:
|
|
293
|
+
ctx: d,
|
|
280
294
|
refresh() {
|
|
281
|
-
|
|
295
|
+
w && E(e.name, "refresh", l);
|
|
282
296
|
},
|
|
283
297
|
unmount() {
|
|
284
|
-
|
|
298
|
+
w && (w = !1, E(e.name, "unmount", m), S(e.name, h), s.teardown());
|
|
285
299
|
}
|
|
286
300
|
};
|
|
287
301
|
}
|
|
288
|
-
function
|
|
302
|
+
function G(e) {
|
|
289
303
|
if (!e.state)
|
|
290
304
|
return {};
|
|
291
305
|
try {
|
|
292
306
|
return e.state();
|
|
293
307
|
} catch (t) {
|
|
294
|
-
return
|
|
308
|
+
return f(e.name, "state factory failed", t), {};
|
|
295
309
|
}
|
|
296
310
|
}
|
|
297
|
-
function
|
|
311
|
+
function k(e) {
|
|
298
312
|
return e ?? document;
|
|
299
313
|
}
|
|
300
|
-
function
|
|
314
|
+
function q(e, t) {
|
|
301
315
|
if (e instanceof Document)
|
|
302
316
|
return Array.from(e.querySelectorAll(t));
|
|
303
317
|
if (e instanceof Element) {
|
|
@@ -306,97 +320,97 @@ function S(e, t) {
|
|
|
306
320
|
}
|
|
307
321
|
return Array.from(e.querySelectorAll(t));
|
|
308
322
|
}
|
|
309
|
-
function
|
|
323
|
+
function A(e, t, r) {
|
|
310
324
|
if (r.has(t))
|
|
311
325
|
return;
|
|
312
|
-
const n =
|
|
326
|
+
const n = D(e, t);
|
|
313
327
|
n && r.set(n);
|
|
314
328
|
}
|
|
315
|
-
function
|
|
329
|
+
function J(e, t) {
|
|
316
330
|
const r = t.get(e);
|
|
317
331
|
r && r.refresh();
|
|
318
332
|
}
|
|
319
|
-
function
|
|
333
|
+
function O(e, t) {
|
|
320
334
|
return {
|
|
321
335
|
mount(r) {
|
|
322
|
-
const n =
|
|
323
|
-
for (const
|
|
324
|
-
const
|
|
325
|
-
for (const
|
|
326
|
-
|
|
336
|
+
const n = k(r);
|
|
337
|
+
for (const a of e.list()) {
|
|
338
|
+
const s = a.schema.refs.root.selector;
|
|
339
|
+
for (const o of q(n, s))
|
|
340
|
+
A(a, o, t);
|
|
327
341
|
}
|
|
328
342
|
},
|
|
329
343
|
reconcile(r) {
|
|
330
|
-
const n =
|
|
331
|
-
for (const
|
|
332
|
-
const
|
|
333
|
-
for (const
|
|
334
|
-
const
|
|
335
|
-
if (!
|
|
336
|
-
|
|
344
|
+
const n = k(r);
|
|
345
|
+
for (const a of e.list()) {
|
|
346
|
+
const s = a.schema.refs.root.selector;
|
|
347
|
+
for (const o of q(n, s)) {
|
|
348
|
+
const u = t.get(o);
|
|
349
|
+
if (!u) {
|
|
350
|
+
A(a, o, t);
|
|
337
351
|
continue;
|
|
338
352
|
}
|
|
339
|
-
|
|
353
|
+
u.refresh();
|
|
340
354
|
}
|
|
341
355
|
}
|
|
342
356
|
},
|
|
343
357
|
refresh(r) {
|
|
344
|
-
|
|
358
|
+
J(r, t);
|
|
345
359
|
},
|
|
346
360
|
recreate(r) {
|
|
347
361
|
const n = t.get(r);
|
|
348
362
|
if (!n)
|
|
349
363
|
return;
|
|
350
364
|
n.unmount(), t.delete(r);
|
|
351
|
-
const
|
|
352
|
-
|
|
365
|
+
const a = D(n.component, r);
|
|
366
|
+
a && t.set(a);
|
|
353
367
|
},
|
|
354
368
|
destroy(r) {
|
|
355
|
-
const n =
|
|
356
|
-
for (const
|
|
357
|
-
|
|
369
|
+
const n = k(r);
|
|
370
|
+
for (const a of t.listInScope(n))
|
|
371
|
+
a.unmount(), t.delete(a.element);
|
|
358
372
|
}
|
|
359
373
|
};
|
|
360
374
|
}
|
|
361
|
-
function
|
|
362
|
-
const t = new
|
|
363
|
-
|
|
375
|
+
function Q(e = {}) {
|
|
376
|
+
const t = new I(), r = new F(), n = O(t, r), a = H(!!e.observeDomChanges, n.reconcile, n.destroy), s = () => {
|
|
377
|
+
a.start(document);
|
|
364
378
|
};
|
|
365
379
|
return {
|
|
366
|
-
register(
|
|
367
|
-
return t.register(
|
|
380
|
+
register(o) {
|
|
381
|
+
return t.register(o), this;
|
|
368
382
|
},
|
|
369
|
-
mount(
|
|
370
|
-
|
|
383
|
+
mount(o) {
|
|
384
|
+
s(), n.mount(o);
|
|
371
385
|
},
|
|
372
|
-
reconcile(
|
|
373
|
-
|
|
386
|
+
reconcile(o) {
|
|
387
|
+
s(), n.reconcile(o);
|
|
374
388
|
},
|
|
375
|
-
refresh(
|
|
376
|
-
n.refresh(
|
|
389
|
+
refresh(o) {
|
|
390
|
+
n.refresh(o);
|
|
377
391
|
},
|
|
378
|
-
recreate(
|
|
379
|
-
n.recreate(
|
|
392
|
+
recreate(o) {
|
|
393
|
+
n.recreate(o);
|
|
380
394
|
},
|
|
381
|
-
destroy(
|
|
382
|
-
n.destroy(
|
|
395
|
+
destroy(o) {
|
|
396
|
+
n.destroy(o), (!o || o instanceof Document) && a.stop();
|
|
383
397
|
},
|
|
384
|
-
getInstance(
|
|
385
|
-
return r.get(
|
|
398
|
+
getInstance(o) {
|
|
399
|
+
return r.get(o);
|
|
386
400
|
}
|
|
387
401
|
};
|
|
388
402
|
}
|
|
389
|
-
function
|
|
390
|
-
return
|
|
403
|
+
function C(e = {}) {
|
|
404
|
+
return Q(e);
|
|
391
405
|
}
|
|
392
|
-
function
|
|
406
|
+
function X(e) {
|
|
393
407
|
const t = e.schema.refs.root;
|
|
394
408
|
if (!t)
|
|
395
409
|
throw new Error(`[Nemesia] component "${e.name}" requires schema.refs.root`);
|
|
396
410
|
if (t.many || t.optional)
|
|
397
411
|
throw new Error(`[Nemesia] component "${e.name}" requires schema.refs.root to be required single`);
|
|
398
412
|
}
|
|
399
|
-
function
|
|
413
|
+
function ee(e) {
|
|
400
414
|
if (!e || typeof e != "object")
|
|
401
415
|
throw new Error("[Nemesia] component definition must be an object");
|
|
402
416
|
if (typeof e.name != "string" || e.name.trim() === "")
|
|
@@ -407,17 +421,17 @@ function _(e) {
|
|
|
407
421
|
throw new Error(`[Nemesia] component "${e.name}" requires schema.refs`);
|
|
408
422
|
if (!e.schema.options || typeof e.schema.options != "object")
|
|
409
423
|
throw new Error(`[Nemesia] component "${e.name}" requires schema.options`);
|
|
410
|
-
return
|
|
424
|
+
return X(e), e;
|
|
411
425
|
}
|
|
412
|
-
function
|
|
426
|
+
function j(e, t) {
|
|
413
427
|
if (typeof e != "string" || e.trim() === "")
|
|
414
428
|
throw new Error(`[Nemesia] ${t} must be a non-empty string`);
|
|
415
429
|
}
|
|
416
|
-
function
|
|
430
|
+
function N(e) {
|
|
417
431
|
if (e !== "string" && e !== "number" && e !== "boolean")
|
|
418
432
|
throw new Error(`[Nemesia] unsupported option type: ${e}`);
|
|
419
433
|
}
|
|
420
|
-
function
|
|
434
|
+
function Y(e, t) {
|
|
421
435
|
if (e === "string") {
|
|
422
436
|
if (typeof t != "string")
|
|
423
437
|
throw new Error('[Nemesia] option default must be a string for type "string"');
|
|
@@ -431,33 +445,33 @@ function Q(e, t) {
|
|
|
431
445
|
if (typeof t != "boolean")
|
|
432
446
|
throw new Error('[Nemesia] option default must be a boolean for type "boolean"');
|
|
433
447
|
}
|
|
434
|
-
function
|
|
435
|
-
|
|
436
|
-
let r, n = !1,
|
|
437
|
-
return typeof t == "string" ? r = t : t && (r = t.tag, n = !!t.optional,
|
|
448
|
+
function te(e, t) {
|
|
449
|
+
j(e, "selector");
|
|
450
|
+
let r, n = !1, a = !1;
|
|
451
|
+
return typeof t == "string" ? r = t : t && (r = t.tag, n = !!t.optional, a = !!t.many), {
|
|
438
452
|
kind: "ref",
|
|
439
453
|
selector: e,
|
|
440
454
|
tag: r ?? void 0,
|
|
441
455
|
optional: n,
|
|
442
|
-
many:
|
|
456
|
+
many: a
|
|
443
457
|
};
|
|
444
458
|
}
|
|
445
|
-
function
|
|
446
|
-
|
|
447
|
-
let r = "string", n = !1,
|
|
448
|
-
return typeof t == "string" ? (
|
|
459
|
+
function re(e, t) {
|
|
460
|
+
j(e, "option attribute");
|
|
461
|
+
let r = "string", n = !1, a = !1, s;
|
|
462
|
+
return typeof t == "string" ? (N(t), r = t) : t && (t.type && (N(t.type), r = t.type), n = !!t.optional, "default" in t && (a = !0, s = t.default, Y(r, s))), {
|
|
449
463
|
kind: "option",
|
|
450
464
|
attribute: e,
|
|
451
465
|
type: r,
|
|
452
466
|
optional: n,
|
|
453
|
-
hasDefault:
|
|
454
|
-
defaultValue:
|
|
467
|
+
hasDefault: a,
|
|
468
|
+
defaultValue: s
|
|
455
469
|
};
|
|
456
470
|
}
|
|
457
471
|
export {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
472
|
+
C as createApplication,
|
|
473
|
+
ee as defineComponent,
|
|
474
|
+
re as getOption,
|
|
475
|
+
te as getRef
|
|
462
476
|
};
|
|
463
477
|
//# sourceMappingURL=nemesia.js.map
|