@source-crafter/xzor-runtime 0.1.8 → 0.1.10
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/entity-set.d.ts +35 -0
- package/fine.d.ts +62 -0
- package/index-qhyvdf2k.js +1050 -0
- package/index-qhyvdf2k.js.map +10 -0
- package/index.d.ts +48 -1
- package/index.js +37 -961
- package/index.js.map +3 -4
- package/model.d.ts +118 -0
- package/model.js +1458 -0
- package/model.js.map +12 -0
- package/package.json +8 -4
package/model.js
ADDED
|
@@ -0,0 +1,1458 @@
|
|
|
1
|
+
import {
|
|
2
|
+
$inSvg,
|
|
3
|
+
$isFragment,
|
|
4
|
+
ComponentBase,
|
|
5
|
+
FINE,
|
|
6
|
+
SVG,
|
|
7
|
+
disposeIsland,
|
|
8
|
+
patchIsland,
|
|
9
|
+
setFineHooks,
|
|
10
|
+
setRenderObserver
|
|
11
|
+
} from "./index-qhyvdf2k.js";
|
|
12
|
+
|
|
13
|
+
// runtime/entity-set.ts
|
|
14
|
+
class EntitySet extends Array {
|
|
15
|
+
static get [Symbol.species]() {
|
|
16
|
+
return Array;
|
|
17
|
+
}
|
|
18
|
+
static track(type, items) {
|
|
19
|
+
const set = new EntitySet;
|
|
20
|
+
if (items)
|
|
21
|
+
for (const item of items)
|
|
22
|
+
Array.prototype.push.call(set, new type(item));
|
|
23
|
+
return set;
|
|
24
|
+
}
|
|
25
|
+
#original;
|
|
26
|
+
#owner;
|
|
27
|
+
#index = 0;
|
|
28
|
+
#subs;
|
|
29
|
+
$own(owner, index) {
|
|
30
|
+
this.#owner = owner;
|
|
31
|
+
this.#index = index;
|
|
32
|
+
}
|
|
33
|
+
$watch(dep) {
|
|
34
|
+
const subs = this.#subs ??= [];
|
|
35
|
+
dep.slot = subs.length;
|
|
36
|
+
subs.push(dep);
|
|
37
|
+
}
|
|
38
|
+
$unwatch(dep) {
|
|
39
|
+
const subs = this.#subs;
|
|
40
|
+
if (subs === undefined || subs.length === 0)
|
|
41
|
+
return;
|
|
42
|
+
const last = subs.pop();
|
|
43
|
+
if (last !== dep) {
|
|
44
|
+
const slot = dep.slot;
|
|
45
|
+
subs[slot] = last;
|
|
46
|
+
last.slot = slot;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
[Symbol.iterator]() {
|
|
50
|
+
Model.$reader?.(this, 0);
|
|
51
|
+
return super[Symbol.iterator]();
|
|
52
|
+
}
|
|
53
|
+
get view() {
|
|
54
|
+
Model.$reader?.(this, 0);
|
|
55
|
+
return this.filter((item) => !item.hasState(8 /* Deleted */));
|
|
56
|
+
}
|
|
57
|
+
get hasChanges() {
|
|
58
|
+
Model.$reader?.(this, 0);
|
|
59
|
+
if (this.#moved())
|
|
60
|
+
return true;
|
|
61
|
+
for (let i = 0;i < this.length; i++)
|
|
62
|
+
if (this[i].hasChanges)
|
|
63
|
+
return true;
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
get hasErrors() {
|
|
67
|
+
Model.$reader?.(this, 0);
|
|
68
|
+
for (let i = 0;i < this.length; i++)
|
|
69
|
+
if (this[i].hasErrors)
|
|
70
|
+
return true;
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
get changes() {
|
|
74
|
+
const result = [];
|
|
75
|
+
for (let i = 0;i < this.length; i++) {
|
|
76
|
+
const changes = this[i].changes;
|
|
77
|
+
if (changes)
|
|
78
|
+
result.push(changes);
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
delete(...items) {
|
|
83
|
+
let touched = false;
|
|
84
|
+
for (const item of items) {
|
|
85
|
+
if (item.hasState(4 /* Added */)) {
|
|
86
|
+
const at = this.indexOf(item);
|
|
87
|
+
if (at >= 0) {
|
|
88
|
+
this.#snapshot();
|
|
89
|
+
super.splice(at, 1);
|
|
90
|
+
touched = true;
|
|
91
|
+
}
|
|
92
|
+
} else if (!item.hasState(1 /* Detached */)) {
|
|
93
|
+
item.markDeleted();
|
|
94
|
+
touched = true;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (touched)
|
|
98
|
+
this.#notify();
|
|
99
|
+
return this;
|
|
100
|
+
}
|
|
101
|
+
revertChanges() {
|
|
102
|
+
const original = this.#original;
|
|
103
|
+
let touched = original !== undefined;
|
|
104
|
+
if (original !== undefined) {
|
|
105
|
+
this.#original = undefined;
|
|
106
|
+
super.splice(0, this.length, ...original);
|
|
107
|
+
}
|
|
108
|
+
for (let i = 0;i < this.length; i++)
|
|
109
|
+
if (this[i].hasChanges) {
|
|
110
|
+
this[i].revertChanges();
|
|
111
|
+
touched = true;
|
|
112
|
+
}
|
|
113
|
+
if (touched)
|
|
114
|
+
this.#notify();
|
|
115
|
+
return this;
|
|
116
|
+
}
|
|
117
|
+
confirmChanges(items) {
|
|
118
|
+
let touched = this.#original !== undefined;
|
|
119
|
+
const length = this.length;
|
|
120
|
+
const limit = items ? Math.min(items.length, length) : length;
|
|
121
|
+
let w = 0;
|
|
122
|
+
for (let r = 0;r < length; r++) {
|
|
123
|
+
const item = this[r];
|
|
124
|
+
if (r < limit) {
|
|
125
|
+
const confirmed = items?.[r];
|
|
126
|
+
if (confirmed === null || item.hasState(8 /* Deleted */))
|
|
127
|
+
continue;
|
|
128
|
+
item.confirmChanges(confirmed);
|
|
129
|
+
}
|
|
130
|
+
this[w++] = item;
|
|
131
|
+
}
|
|
132
|
+
if (w !== length) {
|
|
133
|
+
this.length = w;
|
|
134
|
+
touched = true;
|
|
135
|
+
}
|
|
136
|
+
this.#original = undefined;
|
|
137
|
+
if (touched)
|
|
138
|
+
this.#notify();
|
|
139
|
+
return this;
|
|
140
|
+
}
|
|
141
|
+
push(item) {
|
|
142
|
+
const count = arguments.length;
|
|
143
|
+
if (count !== 0) {
|
|
144
|
+
this.#snapshot();
|
|
145
|
+
if (count === 1)
|
|
146
|
+
super.push(item);
|
|
147
|
+
else
|
|
148
|
+
super.push(...Array.prototype.slice.call(arguments));
|
|
149
|
+
this.#notify();
|
|
150
|
+
}
|
|
151
|
+
return this.length;
|
|
152
|
+
}
|
|
153
|
+
unshift(...items) {
|
|
154
|
+
if (items.length !== 0) {
|
|
155
|
+
this.#snapshot();
|
|
156
|
+
super.unshift(...items);
|
|
157
|
+
this.#notify();
|
|
158
|
+
}
|
|
159
|
+
return this.length;
|
|
160
|
+
}
|
|
161
|
+
pop() {
|
|
162
|
+
if (this.length === 0)
|
|
163
|
+
return;
|
|
164
|
+
this.#snapshot();
|
|
165
|
+
const item = super.pop();
|
|
166
|
+
this.#notify();
|
|
167
|
+
return item;
|
|
168
|
+
}
|
|
169
|
+
shift() {
|
|
170
|
+
if (this.length === 0)
|
|
171
|
+
return;
|
|
172
|
+
this.#snapshot();
|
|
173
|
+
const item = super.shift();
|
|
174
|
+
this.#notify();
|
|
175
|
+
return item;
|
|
176
|
+
}
|
|
177
|
+
splice(start, deleteCount, ...items) {
|
|
178
|
+
if (items.length === 0) {
|
|
179
|
+
const length = this.length;
|
|
180
|
+
const from = start < 0 ? Math.max(length + start, 0) : Math.min(start, length);
|
|
181
|
+
if (from >= length || deleteCount !== undefined && deleteCount <= 0)
|
|
182
|
+
return [];
|
|
183
|
+
}
|
|
184
|
+
this.#snapshot();
|
|
185
|
+
const removed = deleteCount === undefined && items.length === 0 ? super.splice(start) : super.splice(start, deleteCount, ...items);
|
|
186
|
+
this.#notify();
|
|
187
|
+
return removed;
|
|
188
|
+
}
|
|
189
|
+
sort(compare) {
|
|
190
|
+
this.#snapshot();
|
|
191
|
+
super.sort(compare);
|
|
192
|
+
this.#notify();
|
|
193
|
+
return this;
|
|
194
|
+
}
|
|
195
|
+
reverse() {
|
|
196
|
+
this.#snapshot();
|
|
197
|
+
super.reverse();
|
|
198
|
+
this.#notify();
|
|
199
|
+
return this;
|
|
200
|
+
}
|
|
201
|
+
#snapshot() {
|
|
202
|
+
this.#original ??= this.slice();
|
|
203
|
+
}
|
|
204
|
+
#moved() {
|
|
205
|
+
const original = this.#original;
|
|
206
|
+
if (original === undefined)
|
|
207
|
+
return false;
|
|
208
|
+
if (original.length !== this.length)
|
|
209
|
+
return true;
|
|
210
|
+
for (let i = 0;i < original.length; i++)
|
|
211
|
+
if (original[i] !== this[i])
|
|
212
|
+
return true;
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
#notify() {
|
|
216
|
+
this.#owner?.$touched(this.#index);
|
|
217
|
+
const subs = this.#subs;
|
|
218
|
+
if (subs !== undefined)
|
|
219
|
+
for (let i = 0;i < subs.length; i++)
|
|
220
|
+
$notify(subs[i], 0);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
// runtime/fine.ts
|
|
224
|
+
var TEXT = 0;
|
|
225
|
+
var ATTR = 1;
|
|
226
|
+
var REGION = 2;
|
|
227
|
+
var LIST = 3;
|
|
228
|
+
var ISLAND = 4;
|
|
229
|
+
var KIND = 7;
|
|
230
|
+
var QUEUED = 8;
|
|
231
|
+
var MANY = 16;
|
|
232
|
+
var DEAD = 32;
|
|
233
|
+
var LOOSE = 64;
|
|
234
|
+
var ITEM = 128;
|
|
235
|
+
var bitOf = (index) => index === -1 ? 1 << 31 : index < 30 ? 1 << index : 1 << 30;
|
|
236
|
+
var collecting;
|
|
237
|
+
var holder;
|
|
238
|
+
function collect(source, index) {
|
|
239
|
+
const b = collecting;
|
|
240
|
+
const bit = bitOf(index);
|
|
241
|
+
const own = b.model;
|
|
242
|
+
if (own === source) {
|
|
243
|
+
b.mask |= bit;
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
if (own === undefined) {
|
|
247
|
+
b.model = source;
|
|
248
|
+
b.mask = bit;
|
|
249
|
+
source.$watch(b);
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
let deps;
|
|
253
|
+
if ((b.flags & MANY) !== 0)
|
|
254
|
+
deps = own;
|
|
255
|
+
else {
|
|
256
|
+
const first = { model: own, owner: b, mask: b.mask, slot: 0 };
|
|
257
|
+
own.$unwatch(b);
|
|
258
|
+
own.$watch(first);
|
|
259
|
+
b.model = deps = new Map([[own, first]]);
|
|
260
|
+
b.flags |= MANY;
|
|
261
|
+
}
|
|
262
|
+
let dep = deps.get(source);
|
|
263
|
+
if (dep === undefined) {
|
|
264
|
+
dep = { model: source, owner: b, mask: 0, slot: 0 };
|
|
265
|
+
source.$watch(dep);
|
|
266
|
+
deps.set(source, dep);
|
|
267
|
+
}
|
|
268
|
+
dep.mask |= bit;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
class Binding {
|
|
272
|
+
flags;
|
|
273
|
+
node;
|
|
274
|
+
read;
|
|
275
|
+
data;
|
|
276
|
+
model = undefined;
|
|
277
|
+
mask = 0;
|
|
278
|
+
slot = 0;
|
|
279
|
+
next = undefined;
|
|
280
|
+
constructor(flags, node, read, data) {
|
|
281
|
+
this.flags = flags;
|
|
282
|
+
this.node = node;
|
|
283
|
+
this.read = read;
|
|
284
|
+
this.data = data;
|
|
285
|
+
}
|
|
286
|
+
get owner() {
|
|
287
|
+
return this;
|
|
288
|
+
}
|
|
289
|
+
get component() {
|
|
290
|
+
return this;
|
|
291
|
+
}
|
|
292
|
+
get renders() {
|
|
293
|
+
return 0;
|
|
294
|
+
}
|
|
295
|
+
get at() {
|
|
296
|
+
return (this.flags & (QUEUED | DEAD)) !== 0 ? 0 : -1;
|
|
297
|
+
}
|
|
298
|
+
set at(value) {
|
|
299
|
+
if ((this.flags & DEAD) === 0)
|
|
300
|
+
this.flags = value < 0 ? this.flags & ~QUEUED : this.flags | QUEUED;
|
|
301
|
+
}
|
|
302
|
+
#reset() {
|
|
303
|
+
this.mask = 0;
|
|
304
|
+
if ((this.flags & MANY) !== 0)
|
|
305
|
+
for (const dep of this.model.values())
|
|
306
|
+
dep.mask = 0;
|
|
307
|
+
}
|
|
308
|
+
#sweep() {
|
|
309
|
+
const own = this.model;
|
|
310
|
+
if (own === undefined)
|
|
311
|
+
return this.#loose();
|
|
312
|
+
if ((this.flags & MANY) === 0) {
|
|
313
|
+
if (this.mask === 0) {
|
|
314
|
+
own.$unwatch(this);
|
|
315
|
+
this.model = undefined;
|
|
316
|
+
this.#loose();
|
|
317
|
+
}
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
const deps = own;
|
|
321
|
+
for (const [source, dep] of deps)
|
|
322
|
+
if (dep.mask === 0) {
|
|
323
|
+
source.$unwatch(dep);
|
|
324
|
+
deps.delete(source);
|
|
325
|
+
}
|
|
326
|
+
if (deps.size === 0) {
|
|
327
|
+
this.model = undefined;
|
|
328
|
+
this.flags &= ~MANY;
|
|
329
|
+
this.#loose();
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
#loose() {
|
|
333
|
+
if ((this.flags & (LOOSE | DEAD)) !== 0 || holder === undefined)
|
|
334
|
+
return;
|
|
335
|
+
this.flags |= LOOSE;
|
|
336
|
+
holder.ctx.loose.push(this);
|
|
337
|
+
}
|
|
338
|
+
#run(parent) {
|
|
339
|
+
const prev = collecting;
|
|
340
|
+
const reader = Model.$reader;
|
|
341
|
+
collecting = this;
|
|
342
|
+
Model.$reader = collect;
|
|
343
|
+
this.#reset();
|
|
344
|
+
try {
|
|
345
|
+
return (this.flags & ITEM) !== 0 ? this.read(this.data.item, parent) : this.read(parent);
|
|
346
|
+
} finally {
|
|
347
|
+
collecting = prev;
|
|
348
|
+
Model.$reader = reader;
|
|
349
|
+
this.#sweep();
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
stateHasChanged() {
|
|
353
|
+
const flags = this.flags;
|
|
354
|
+
if ((flags & DEAD) !== 0)
|
|
355
|
+
return;
|
|
356
|
+
switch (flags & KIND) {
|
|
357
|
+
case TEXT: {
|
|
358
|
+
const value = this.#run();
|
|
359
|
+
if ($isFragment(value))
|
|
360
|
+
return this.#becomeIsland();
|
|
361
|
+
const text = textOf(value);
|
|
362
|
+
const node = this.node;
|
|
363
|
+
if (node.data !== text)
|
|
364
|
+
node.data = text;
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
case ATTR:
|
|
368
|
+
return setAttr(this.node, (flags & ITEM) !== 0 ? this.read.$n : this.data, this.#run());
|
|
369
|
+
case REGION: {
|
|
370
|
+
const region = this.data;
|
|
371
|
+
disposeAll(region);
|
|
372
|
+
const end = this.node;
|
|
373
|
+
const parent = end.parentNode;
|
|
374
|
+
while (region.start.nextSibling !== end)
|
|
375
|
+
parent.removeChild(region.start.nextSibling);
|
|
376
|
+
const frag = document.createDocumentFragment();
|
|
377
|
+
within(region, () => this.#run(frag));
|
|
378
|
+
parent.insertBefore(frag, end);
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
case LIST:
|
|
382
|
+
return reconcile(this, this.#run());
|
|
383
|
+
case ISLAND:
|
|
384
|
+
this.#run();
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
#becomeIsland() {
|
|
389
|
+
const read = this.read;
|
|
390
|
+
const h = this.data;
|
|
391
|
+
const value = (this.flags & ITEM) !== 0 ? () => read(h.item) : read;
|
|
392
|
+
const text = this.node;
|
|
393
|
+
const end = text.parentNode.insertBefore(document.createComment(""), text.nextSibling);
|
|
394
|
+
text.parentNode.removeChild(text);
|
|
395
|
+
this.node = end;
|
|
396
|
+
this.flags = this.flags & ~(KIND | ITEM) | ISLAND;
|
|
397
|
+
island(this, h.ctx, (b) => {
|
|
398
|
+
const v = value();
|
|
399
|
+
if ($isFragment(v))
|
|
400
|
+
v(b);
|
|
401
|
+
else
|
|
402
|
+
b.addContent(v);
|
|
403
|
+
});
|
|
404
|
+
this.stateHasChanged();
|
|
405
|
+
}
|
|
406
|
+
dispose() {
|
|
407
|
+
if ((this.flags & DEAD) !== 0)
|
|
408
|
+
return;
|
|
409
|
+
const kind = this.flags & KIND;
|
|
410
|
+
if (kind === REGION)
|
|
411
|
+
disposeAll(this.data);
|
|
412
|
+
else if (kind === LIST)
|
|
413
|
+
for (const row of this.data.order)
|
|
414
|
+
disposeAll(row);
|
|
415
|
+
else if (kind === ISLAND) {
|
|
416
|
+
disposeIsland(this.data.tree);
|
|
417
|
+
this.data.tree = [];
|
|
418
|
+
}
|
|
419
|
+
this.#reset();
|
|
420
|
+
this.#sweep();
|
|
421
|
+
this.flags = DEAD;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
function island(b, ctx, build) {
|
|
425
|
+
const state = { ctx, tree: [], build };
|
|
426
|
+
b.data = state;
|
|
427
|
+
b.read = () => {
|
|
428
|
+
state.tree = patchIsland(ctx.owner, ctx.app, ctx.scope, b.node, state.tree, build);
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
function refreshLoose(ctx) {
|
|
432
|
+
const loose = ctx.loose;
|
|
433
|
+
for (let i = 0;i < loose.length; ) {
|
|
434
|
+
const b = loose[i];
|
|
435
|
+
if ((b.flags & DEAD) !== 0 || b.model !== undefined) {
|
|
436
|
+
b.flags &= ~LOOSE;
|
|
437
|
+
loose[i] = loose[loose.length - 1];
|
|
438
|
+
loose.pop();
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
b.stateHasChanged();
|
|
442
|
+
i++;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
function afterHandler(ctx, result) {
|
|
446
|
+
$flush();
|
|
447
|
+
refreshLoose(ctx);
|
|
448
|
+
if (result instanceof Promise)
|
|
449
|
+
result.then(() => refreshLoose(ctx));
|
|
450
|
+
}
|
|
451
|
+
function within(h, run) {
|
|
452
|
+
const prev = holder;
|
|
453
|
+
holder = h;
|
|
454
|
+
try {
|
|
455
|
+
run();
|
|
456
|
+
} finally {
|
|
457
|
+
holder = prev;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
function track(b) {
|
|
461
|
+
const h = holder;
|
|
462
|
+
b.next = h.bindings;
|
|
463
|
+
h.bindings = b;
|
|
464
|
+
b.stateHasChanged();
|
|
465
|
+
}
|
|
466
|
+
function disposeAll(h) {
|
|
467
|
+
for (let b = h.bindings;b !== undefined; b = b.next)
|
|
468
|
+
b.dispose();
|
|
469
|
+
h.bindings = undefined;
|
|
470
|
+
}
|
|
471
|
+
function refreshAll(h) {
|
|
472
|
+
for (let b = h.bindings;b !== undefined; b = b.next) {
|
|
473
|
+
b.stateHasChanged();
|
|
474
|
+
if ((b.flags & KIND) === LIST)
|
|
475
|
+
for (const row of b.data.order)
|
|
476
|
+
refreshAll(row);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
var textOf = (value) => value === null || value === undefined || value === false ? "" : String(value);
|
|
480
|
+
function setAttr(el, name, value) {
|
|
481
|
+
if (value === null || value === undefined || value === false) {
|
|
482
|
+
if (el.hasAttribute(name))
|
|
483
|
+
el.removeAttribute(name);
|
|
484
|
+
if (name === "checked" && "checked" in el)
|
|
485
|
+
el.checked = false;
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
const text = value === true ? "" : String(value);
|
|
489
|
+
if (el.getAttribute(name) !== text)
|
|
490
|
+
el.setAttribute(name, text);
|
|
491
|
+
if (name === "value" && "value" in el && el.value !== text)
|
|
492
|
+
el.value = text;
|
|
493
|
+
else if (name === "checked" && "checked" in el)
|
|
494
|
+
el.checked = true;
|
|
495
|
+
}
|
|
496
|
+
function removeRange(head, tail) {
|
|
497
|
+
const parent = head.parentNode;
|
|
498
|
+
for (let node = head;; ) {
|
|
499
|
+
const next = node.nextSibling;
|
|
500
|
+
parent.removeChild(node);
|
|
501
|
+
if (node === tail)
|
|
502
|
+
return;
|
|
503
|
+
node = next;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
function reconcile(list, items) {
|
|
507
|
+
const state = list.data;
|
|
508
|
+
const end = list.node;
|
|
509
|
+
const parent = end.parentNode;
|
|
510
|
+
const next = Array.isArray(items) ? items : [...items];
|
|
511
|
+
const keep = new Set(next);
|
|
512
|
+
for (const [item, row] of state.rows)
|
|
513
|
+
if (!keep.has(item)) {
|
|
514
|
+
disposeAll(row);
|
|
515
|
+
removeRange(row.head, row.tail);
|
|
516
|
+
state.rows.delete(item);
|
|
517
|
+
}
|
|
518
|
+
let cursor = end;
|
|
519
|
+
for (const row of state.order)
|
|
520
|
+
if (row.head.parentNode === parent) {
|
|
521
|
+
cursor = row.head;
|
|
522
|
+
break;
|
|
523
|
+
}
|
|
524
|
+
const order = [];
|
|
525
|
+
for (const item of next) {
|
|
526
|
+
let row = state.rows.get(item);
|
|
527
|
+
if (row === undefined) {
|
|
528
|
+
const frag = document.createDocumentFragment();
|
|
529
|
+
const made = { bindings: undefined, ctx: state.ctx, head: frag, tail: frag, item, reads: state.reads };
|
|
530
|
+
within(made, () => state.build(frag, item));
|
|
531
|
+
if (frag.firstChild === null)
|
|
532
|
+
frag.appendChild(document.createComment(""));
|
|
533
|
+
made.head = frag.firstChild;
|
|
534
|
+
made.tail = frag.lastChild;
|
|
535
|
+
parent.insertBefore(frag, cursor);
|
|
536
|
+
state.rows.set(item, row = made);
|
|
537
|
+
} else if (row.head !== cursor) {
|
|
538
|
+
for (let node = row.head;; ) {
|
|
539
|
+
const after = node.nextSibling;
|
|
540
|
+
parent.insertBefore(node, cursor);
|
|
541
|
+
if (node === row.tail)
|
|
542
|
+
break;
|
|
543
|
+
node = after;
|
|
544
|
+
}
|
|
545
|
+
} else
|
|
546
|
+
cursor = row.tail.nextSibling;
|
|
547
|
+
order.push(row);
|
|
548
|
+
}
|
|
549
|
+
state.order = order;
|
|
550
|
+
}
|
|
551
|
+
function make(spec, svg = false) {
|
|
552
|
+
if (spec === null)
|
|
553
|
+
return document.createComment("");
|
|
554
|
+
if (typeof spec === "string")
|
|
555
|
+
return document.createTextNode(spec);
|
|
556
|
+
const tag = spec[0];
|
|
557
|
+
const el = svg || tag === "svg" ? document.createElementNS(SVG, tag) : document.createElement(tag);
|
|
558
|
+
const attrs = spec[1];
|
|
559
|
+
if (attrs !== 0)
|
|
560
|
+
for (let i = 0;i < attrs.length; i += 2)
|
|
561
|
+
el.setAttribute(attrs[i], attrs[i + 1]);
|
|
562
|
+
const inner = $inSvg(el);
|
|
563
|
+
for (let i = 2;i < spec.length; i++)
|
|
564
|
+
el.appendChild(make(spec[i], inner));
|
|
565
|
+
return el;
|
|
566
|
+
}
|
|
567
|
+
var DELEGATED = new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
|
|
568
|
+
var keys = new Map;
|
|
569
|
+
var HOLDER = Symbol("xzor.fine.holder");
|
|
570
|
+
function keyOf(type) {
|
|
571
|
+
let key = keys.get(type);
|
|
572
|
+
if (key === undefined) {
|
|
573
|
+
keys.set(type, key = Symbol(type));
|
|
574
|
+
document.addEventListener(type, dispatch);
|
|
575
|
+
document.addEventListener(type, dispatchAtTarget, true);
|
|
576
|
+
}
|
|
577
|
+
return key;
|
|
578
|
+
}
|
|
579
|
+
function fire(node, e) {
|
|
580
|
+
const handler = node[keys.get(e.type)];
|
|
581
|
+
if (handler === undefined)
|
|
582
|
+
return false;
|
|
583
|
+
const h = node[HOLDER];
|
|
584
|
+
Object.defineProperty(e, "currentTarget", { configurable: true, value: node });
|
|
585
|
+
afterHandler(h.ctx, h.reads !== undefined ? handler(h.item)(e) : handler(e));
|
|
586
|
+
return e.cancelBubble;
|
|
587
|
+
}
|
|
588
|
+
function dispatch(e) {
|
|
589
|
+
for (let node = e.target;node !== null && !fire(node, e); node = node.parentNode)
|
|
590
|
+
;
|
|
591
|
+
}
|
|
592
|
+
function dispatchAtTarget(e) {
|
|
593
|
+
if (!e.bubbles && e.target !== null)
|
|
594
|
+
fire(e.target, e);
|
|
595
|
+
}
|
|
596
|
+
function on(el, event, handler, h) {
|
|
597
|
+
if (DELEGATED.has(event)) {
|
|
598
|
+
const target = el;
|
|
599
|
+
target[keyOf(event)] = handler;
|
|
600
|
+
target[HOLDER] = h;
|
|
601
|
+
} else
|
|
602
|
+
el.addEventListener(event, (e) => afterHandler(h.ctx, handler(e)));
|
|
603
|
+
}
|
|
604
|
+
function region(start, end, build, item, flags) {
|
|
605
|
+
const region2 = { bindings: undefined, ctx: holder.ctx, start, item };
|
|
606
|
+
track(new Binding(REGION | flags, end, build, region2));
|
|
607
|
+
}
|
|
608
|
+
function list(end, items, reads, build) {
|
|
609
|
+
const state = { build, ctx: holder.ctx, rows: new Map, order: [], reads };
|
|
610
|
+
track(new Binding(LIST, end, items, state));
|
|
611
|
+
}
|
|
612
|
+
var anchor = (parent) => parent.appendChild(document.createComment(""));
|
|
613
|
+
var fine = {
|
|
614
|
+
template(specs) {
|
|
615
|
+
let node;
|
|
616
|
+
let used = false;
|
|
617
|
+
const build = () => {
|
|
618
|
+
const first = specs[0];
|
|
619
|
+
if (specs.length === 1 && Array.isArray(first))
|
|
620
|
+
return make(first);
|
|
621
|
+
const frag = document.createDocumentFragment();
|
|
622
|
+
for (const spec of specs)
|
|
623
|
+
frag.appendChild(make(spec));
|
|
624
|
+
return frag;
|
|
625
|
+
};
|
|
626
|
+
return () => {
|
|
627
|
+
if (node !== undefined)
|
|
628
|
+
return node.cloneNode(true);
|
|
629
|
+
if (!used) {
|
|
630
|
+
used = true;
|
|
631
|
+
return build();
|
|
632
|
+
}
|
|
633
|
+
node = build();
|
|
634
|
+
return node.cloneNode(true);
|
|
635
|
+
};
|
|
636
|
+
},
|
|
637
|
+
el(parent, tag) {
|
|
638
|
+
return parent.appendChild($inSvg(parent) ? document.createElementNS(SVG, tag) : document.createElement(tag));
|
|
639
|
+
},
|
|
640
|
+
on(el, event, handler) {
|
|
641
|
+
const h = holder;
|
|
642
|
+
on(el, event, h.reads !== undefined && DELEGATED.has(event) ? () => handler : handler, h);
|
|
643
|
+
},
|
|
644
|
+
onItem(el, event, i) {
|
|
645
|
+
const row = holder;
|
|
646
|
+
const read = row.reads[i];
|
|
647
|
+
if (DELEGATED.has(event))
|
|
648
|
+
on(el, event, read, row);
|
|
649
|
+
else
|
|
650
|
+
el.addEventListener(event, (e) => afterHandler(row.ctx, read(row.item)(e)));
|
|
651
|
+
},
|
|
652
|
+
t(parent, text) {
|
|
653
|
+
parent.appendChild(document.createTextNode(text));
|
|
654
|
+
},
|
|
655
|
+
text(parent, read) {
|
|
656
|
+
fine.textAt(parent.appendChild(document.createTextNode("")), read);
|
|
657
|
+
},
|
|
658
|
+
textAt(node, read) {
|
|
659
|
+
track(new Binding(TEXT, node, read, holder));
|
|
660
|
+
},
|
|
661
|
+
textItem(node, i) {
|
|
662
|
+
const row = holder;
|
|
663
|
+
track(new Binding(TEXT | ITEM, node, row.reads[i], row));
|
|
664
|
+
},
|
|
665
|
+
attr(el, name, read) {
|
|
666
|
+
track(new Binding(ATTR, el, read, name));
|
|
667
|
+
},
|
|
668
|
+
attrItem(el, name, i) {
|
|
669
|
+
const row = holder;
|
|
670
|
+
const read = row.reads[i];
|
|
671
|
+
read.$n = name;
|
|
672
|
+
track(new Binding(ATTR | ITEM, el, read, row));
|
|
673
|
+
},
|
|
674
|
+
region(parent, build) {
|
|
675
|
+
region(anchor(parent), anchor(parent), build, undefined, 0);
|
|
676
|
+
},
|
|
677
|
+
regionAt(end, build) {
|
|
678
|
+
region(end.previousSibling, end, build, undefined, 0);
|
|
679
|
+
},
|
|
680
|
+
regionItem(end, i) {
|
|
681
|
+
const row = holder;
|
|
682
|
+
region(end.previousSibling, end, row.reads[i], row.item, ITEM);
|
|
683
|
+
},
|
|
684
|
+
list(parent, items, build) {
|
|
685
|
+
list(anchor(parent), items, undefined, build);
|
|
686
|
+
},
|
|
687
|
+
listAt(end, items, reads, build) {
|
|
688
|
+
list(end, items, reads, build);
|
|
689
|
+
},
|
|
690
|
+
island(parent, build) {
|
|
691
|
+
fine.islandAt(anchor(parent), build);
|
|
692
|
+
},
|
|
693
|
+
islandAt(end, build) {
|
|
694
|
+
const b = new Binding(ISLAND, end, noop, undefined);
|
|
695
|
+
island(b, holder.ctx, build);
|
|
696
|
+
track(b);
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
var noop = () => {};
|
|
700
|
+
var FIELDS = Symbol("xzor.fine.fields");
|
|
701
|
+
|
|
702
|
+
class FineComponent extends ComponentBase {
|
|
703
|
+
#subs;
|
|
704
|
+
static get $reader() {
|
|
705
|
+
return Model.$reader;
|
|
706
|
+
}
|
|
707
|
+
static same(a, b) {
|
|
708
|
+
return Model.same(a, b);
|
|
709
|
+
}
|
|
710
|
+
static $define(cls, names) {
|
|
711
|
+
const counts = cls;
|
|
712
|
+
const at = counts[FIELDS] ?? 0;
|
|
713
|
+
counts[FIELDS] = at + names.length;
|
|
714
|
+
return at;
|
|
715
|
+
}
|
|
716
|
+
$watch(dep) {
|
|
717
|
+
const subs = this.#subs ??= [];
|
|
718
|
+
dep.slot = subs.length;
|
|
719
|
+
subs.push(dep);
|
|
720
|
+
}
|
|
721
|
+
$unwatch(dep) {
|
|
722
|
+
const subs = this.#subs;
|
|
723
|
+
if (subs === undefined || subs.length === 0)
|
|
724
|
+
return;
|
|
725
|
+
const last = subs.pop();
|
|
726
|
+
if (last !== dep) {
|
|
727
|
+
subs[dep.slot] = last;
|
|
728
|
+
last.slot = dep.slot;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
$changed(index, _previous) {
|
|
732
|
+
const subs = this.#subs;
|
|
733
|
+
if (subs !== undefined)
|
|
734
|
+
for (let i = 0;i < subs.length; i++)
|
|
735
|
+
$notify(subs[i], index);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
FineComponent.prototype[FINE] = true;
|
|
739
|
+
var CTX = Symbol("xzor.fine.ctx");
|
|
740
|
+
setFineHooks({
|
|
741
|
+
create(build, owner, app, scope) {
|
|
742
|
+
const frag = document.createDocumentFragment();
|
|
743
|
+
const start = frag.appendChild(document.createComment(""));
|
|
744
|
+
const ctx = { owner, app, scope, loose: [] };
|
|
745
|
+
owner[CTX] = ctx;
|
|
746
|
+
const root = { bindings: undefined, ctx, start, end: start };
|
|
747
|
+
const reader = Model.$reader;
|
|
748
|
+
Model.$reader = undefined;
|
|
749
|
+
try {
|
|
750
|
+
within(root, () => build(frag));
|
|
751
|
+
} finally {
|
|
752
|
+
Model.$reader = reader;
|
|
753
|
+
}
|
|
754
|
+
root.end = frag.appendChild(document.createComment(""));
|
|
755
|
+
return root;
|
|
756
|
+
},
|
|
757
|
+
refresh: (root) => refreshAll(root),
|
|
758
|
+
dispose: (root) => disposeAll(root),
|
|
759
|
+
handled(owner, result) {
|
|
760
|
+
const ctx = owner[CTX];
|
|
761
|
+
if (ctx !== undefined)
|
|
762
|
+
afterHandler(ctx, result);
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
|
|
766
|
+
// runtime/model.ts
|
|
767
|
+
var State;
|
|
768
|
+
((State2) => {
|
|
769
|
+
State2[State2["Detached"] = 1] = "Detached";
|
|
770
|
+
State2[State2["Unchanged"] = 2] = "Unchanged";
|
|
771
|
+
State2[State2["Added"] = 4] = "Added";
|
|
772
|
+
State2[State2["Deleted"] = 8] = "Deleted";
|
|
773
|
+
State2[State2["Modified"] = 16] = "Modified";
|
|
774
|
+
})(State ||= {});
|
|
775
|
+
var Changed = 4 /* Added */ | 8 /* Deleted */ | 16 /* Modified */;
|
|
776
|
+
|
|
777
|
+
class ModelChangeEvent extends Event {
|
|
778
|
+
property;
|
|
779
|
+
value;
|
|
780
|
+
previous;
|
|
781
|
+
index;
|
|
782
|
+
constructor(property, value, previous, index) {
|
|
783
|
+
super("change");
|
|
784
|
+
this.property = property;
|
|
785
|
+
this.value = value;
|
|
786
|
+
this.previous = previous;
|
|
787
|
+
this.index = index;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
var stateIndex = -1;
|
|
791
|
+
var StateKey = Symbol("xzor.state");
|
|
792
|
+
var meta = Symbol("xzor.model.meta");
|
|
793
|
+
var empty = { names: [], tracked: new Set, persisted: [], ignored: new Set, validators: [], serialized: [] };
|
|
794
|
+
var pendingPersist;
|
|
795
|
+
var pendingIgnored;
|
|
796
|
+
var pendingValidators;
|
|
797
|
+
var silent = 0;
|
|
798
|
+
function metaOf(model) {
|
|
799
|
+
return model.constructor[meta] ?? empty;
|
|
800
|
+
}
|
|
801
|
+
function serialized(of) {
|
|
802
|
+
return of.serialized ??= of.names.concat(of.persisted).filter((name) => !of.ignored.has(name));
|
|
803
|
+
}
|
|
804
|
+
function captureOf(options) {
|
|
805
|
+
return typeof options === "object" && options !== null ? options.capture === true : options === true;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
class Model extends EventTarget {
|
|
809
|
+
static $reader;
|
|
810
|
+
#state;
|
|
811
|
+
#originals;
|
|
812
|
+
#watched;
|
|
813
|
+
#subs;
|
|
814
|
+
constructor(data) {
|
|
815
|
+
super();
|
|
816
|
+
const state = data?.$$;
|
|
817
|
+
this.#state = state ?? (data ? 2 /* Unchanged */ : 1 /* Detached */);
|
|
818
|
+
}
|
|
819
|
+
static $define(cls, names) {
|
|
820
|
+
const base = cls[meta];
|
|
821
|
+
const all = base ? base.names.concat(names) : names;
|
|
822
|
+
const own = {
|
|
823
|
+
names: all,
|
|
824
|
+
tracked: new Set(all),
|
|
825
|
+
persisted: base ? base.persisted.slice() : [],
|
|
826
|
+
ignored: new Set(base?.ignored),
|
|
827
|
+
validators: base ? base.validators.map(([name, list2]) => [name, list2.slice()]) : []
|
|
828
|
+
};
|
|
829
|
+
if (pendingValidators) {
|
|
830
|
+
for (const [name, list2] of pendingValidators) {
|
|
831
|
+
const known = own.validators.find((entry) => entry[0] === name);
|
|
832
|
+
if (known)
|
|
833
|
+
known[1].push(...list2);
|
|
834
|
+
else
|
|
835
|
+
own.validators.push([name, list2]);
|
|
836
|
+
}
|
|
837
|
+
pendingValidators = undefined;
|
|
838
|
+
}
|
|
839
|
+
if (pendingPersist) {
|
|
840
|
+
for (const name of pendingPersist)
|
|
841
|
+
own.persisted.push(name);
|
|
842
|
+
pendingPersist = undefined;
|
|
843
|
+
}
|
|
844
|
+
if (pendingIgnored) {
|
|
845
|
+
for (const name of pendingIgnored)
|
|
846
|
+
own.ignored.add(name);
|
|
847
|
+
pendingIgnored = undefined;
|
|
848
|
+
}
|
|
849
|
+
Object.defineProperty(cls, meta, { value: own });
|
|
850
|
+
return base ? base.names.length : 0;
|
|
851
|
+
}
|
|
852
|
+
static same(a, b) {
|
|
853
|
+
if (Object.is(a, b))
|
|
854
|
+
return true;
|
|
855
|
+
if (a === null || b === null || typeof a !== "object" || typeof b !== "object")
|
|
856
|
+
return false;
|
|
857
|
+
if (a instanceof Date || b instanceof Date)
|
|
858
|
+
return a instanceof Date && b instanceof Date && a.getTime() === b.getTime();
|
|
859
|
+
if (a instanceof Model || b instanceof Model || "$own" in a || "$own" in b)
|
|
860
|
+
return false;
|
|
861
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
862
|
+
if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length)
|
|
863
|
+
return false;
|
|
864
|
+
return a.every((value, i) => Model.same(value, b[i]));
|
|
865
|
+
}
|
|
866
|
+
const left = a;
|
|
867
|
+
const right = b;
|
|
868
|
+
const names = Object.keys(left);
|
|
869
|
+
if (names.length !== Object.keys(right).length)
|
|
870
|
+
return false;
|
|
871
|
+
return names.every((name) => Model.same(left[name], right[name]));
|
|
872
|
+
}
|
|
873
|
+
get [StateKey]() {
|
|
874
|
+
Model.$reader?.(this, stateIndex);
|
|
875
|
+
return this.#state;
|
|
876
|
+
}
|
|
877
|
+
set [StateKey](value) {
|
|
878
|
+
if (value === this.#state)
|
|
879
|
+
return;
|
|
880
|
+
this.#state = value;
|
|
881
|
+
const subs = this.#subs;
|
|
882
|
+
if (subs !== undefined)
|
|
883
|
+
for (let i = 0;i < subs.length; i++)
|
|
884
|
+
changed(subs[i], stateIndex);
|
|
885
|
+
if (!this.#listens("state"))
|
|
886
|
+
return;
|
|
887
|
+
const depth = silent;
|
|
888
|
+
silent = 0;
|
|
889
|
+
try {
|
|
890
|
+
this.dispatchEvent(new Event("state"));
|
|
891
|
+
} finally {
|
|
892
|
+
silent = depth;
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
hasState(flags) {
|
|
896
|
+
Model.$reader?.(this, stateIndex);
|
|
897
|
+
return (this.#state & flags) !== 0;
|
|
898
|
+
}
|
|
899
|
+
get hasChanges() {
|
|
900
|
+
Model.$reader?.(this, stateIndex);
|
|
901
|
+
if ((this.#state & Changed) !== 0)
|
|
902
|
+
return true;
|
|
903
|
+
for (const name of metaOf(this).names)
|
|
904
|
+
if (valueHasChanges(this[name]))
|
|
905
|
+
return true;
|
|
906
|
+
return false;
|
|
907
|
+
}
|
|
908
|
+
get hasErrors() {
|
|
909
|
+
Model.$reader?.(this, stateIndex);
|
|
910
|
+
if ((this.#state & (1 /* Detached */ | 8 /* Deleted */)) !== 0)
|
|
911
|
+
return false;
|
|
912
|
+
const own = metaOf(this);
|
|
913
|
+
const values = this;
|
|
914
|
+
for (let i = 0;i < own.validators.length; i++) {
|
|
915
|
+
const [name, list2] = own.validators[i];
|
|
916
|
+
for (const validate of list2)
|
|
917
|
+
if (typeof validate(values[name], this) === "string")
|
|
918
|
+
return true;
|
|
919
|
+
}
|
|
920
|
+
for (const name of own.names)
|
|
921
|
+
if (valueHasErrors(values[name]))
|
|
922
|
+
return true;
|
|
923
|
+
return false;
|
|
924
|
+
}
|
|
925
|
+
get errors() {
|
|
926
|
+
const result = Object.create(null);
|
|
927
|
+
Model.$reader?.(this, stateIndex);
|
|
928
|
+
if ((this.#state & (1 /* Detached */ | 8 /* Deleted */)) !== 0)
|
|
929
|
+
return result;
|
|
930
|
+
if (this.#originals === undefined && (this.#state & (4 /* Added */ | 16 /* Modified */)) === 0)
|
|
931
|
+
return result;
|
|
932
|
+
const values = this;
|
|
933
|
+
const validators = metaOf(this).validators;
|
|
934
|
+
for (let i = 0;i < validators.length; i++) {
|
|
935
|
+
const [name, list2] = validators[i];
|
|
936
|
+
const messages = result[name] = [];
|
|
937
|
+
for (const validate of list2) {
|
|
938
|
+
const message = validate(values[name], this);
|
|
939
|
+
if (typeof message === "string")
|
|
940
|
+
messages.push(message);
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
return result;
|
|
944
|
+
}
|
|
945
|
+
get hasValidChanges() {
|
|
946
|
+
return this.hasChanges && !this.hasErrors;
|
|
947
|
+
}
|
|
948
|
+
get changes() {
|
|
949
|
+
if (!this.hasChanges)
|
|
950
|
+
return null;
|
|
951
|
+
const values = this;
|
|
952
|
+
const result = { $$: this.#state };
|
|
953
|
+
for (const name of serialized(metaOf(this))) {
|
|
954
|
+
const value = values[name];
|
|
955
|
+
if (isSerializable(value))
|
|
956
|
+
result[name] = changesOf(value);
|
|
957
|
+
}
|
|
958
|
+
return result;
|
|
959
|
+
}
|
|
960
|
+
toJSON() {
|
|
961
|
+
const values = this;
|
|
962
|
+
const result = { $$: this.#state };
|
|
963
|
+
for (const name of serialized(metaOf(this)))
|
|
964
|
+
result[name] = values[name];
|
|
965
|
+
return result;
|
|
966
|
+
}
|
|
967
|
+
revertChanges() {
|
|
968
|
+
const own = metaOf(this);
|
|
969
|
+
const originals = this.#originals;
|
|
970
|
+
const values = this;
|
|
971
|
+
if (originals) {
|
|
972
|
+
this.#originals = undefined;
|
|
973
|
+
silent++;
|
|
974
|
+
try {
|
|
975
|
+
for (const name in originals) {
|
|
976
|
+
const previous = values[name];
|
|
977
|
+
const value = originals[name];
|
|
978
|
+
values[name] = value;
|
|
979
|
+
this.#emit(name, value, previous);
|
|
980
|
+
}
|
|
981
|
+
} finally {
|
|
982
|
+
silent--;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
for (const name of own.names)
|
|
986
|
+
revertValue(values[name]);
|
|
987
|
+
if ((this.#state & 4 /* Added */) !== 0)
|
|
988
|
+
this[StateKey] = 1 /* Detached */;
|
|
989
|
+
else if ((this.#state & (8 /* Deleted */ | 16 /* Modified */)) !== 0)
|
|
990
|
+
this[StateKey] = 2 /* Unchanged */;
|
|
991
|
+
return this;
|
|
992
|
+
}
|
|
993
|
+
confirmChanges(values) {
|
|
994
|
+
const own = metaOf(this);
|
|
995
|
+
const data = values;
|
|
996
|
+
const target = this;
|
|
997
|
+
this.#originals = undefined;
|
|
998
|
+
silent++;
|
|
999
|
+
try {
|
|
1000
|
+
for (const name of own.names) {
|
|
1001
|
+
const current = target[name];
|
|
1002
|
+
const given = data !== undefined && Object.hasOwn(data, name);
|
|
1003
|
+
if (current !== null && typeof current === "object" && typeof current.confirmChanges === "function") {
|
|
1004
|
+
current.confirmChanges(given ? data[name] : undefined);
|
|
1005
|
+
} else if (given) {
|
|
1006
|
+
const value = data[name];
|
|
1007
|
+
if (Model.same(current, value))
|
|
1008
|
+
continue;
|
|
1009
|
+
target[name] = value;
|
|
1010
|
+
this.#emit(name, value, current);
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
} finally {
|
|
1014
|
+
silent--;
|
|
1015
|
+
}
|
|
1016
|
+
if ((this.#state & (4 /* Added */ | 16 /* Modified */)) !== 0)
|
|
1017
|
+
this[StateKey] = 2 /* Unchanged */;
|
|
1018
|
+
return this;
|
|
1019
|
+
}
|
|
1020
|
+
markAdded() {
|
|
1021
|
+
this[StateKey] = 4 /* Added */;
|
|
1022
|
+
return this;
|
|
1023
|
+
}
|
|
1024
|
+
markModified() {
|
|
1025
|
+
if ((this.#state & 4 /* Added */) === 0)
|
|
1026
|
+
this[StateKey] = 16 /* Modified */;
|
|
1027
|
+
return this;
|
|
1028
|
+
}
|
|
1029
|
+
markUnchanged() {
|
|
1030
|
+
this[StateKey] = 2 /* Unchanged */;
|
|
1031
|
+
return this;
|
|
1032
|
+
}
|
|
1033
|
+
markDeleted() {
|
|
1034
|
+
if ((this.#state & 1 /* Detached */) === 0)
|
|
1035
|
+
this[StateKey] = 8 /* Deleted */;
|
|
1036
|
+
return this;
|
|
1037
|
+
}
|
|
1038
|
+
assign(data) {
|
|
1039
|
+
const names = metaOf(this).names;
|
|
1040
|
+
const target = this;
|
|
1041
|
+
if (data) {
|
|
1042
|
+
const tracked = metaOf(this).tracked;
|
|
1043
|
+
const source = data;
|
|
1044
|
+
if (source["$$"] != null)
|
|
1045
|
+
this.#state = source["$$"];
|
|
1046
|
+
silent++;
|
|
1047
|
+
try {
|
|
1048
|
+
for (const name in source)
|
|
1049
|
+
if (tracked.has(name))
|
|
1050
|
+
try {
|
|
1051
|
+
target[name] = source[name];
|
|
1052
|
+
} catch (error) {
|
|
1053
|
+
if (!(error instanceof TypeError))
|
|
1054
|
+
throw error;
|
|
1055
|
+
}
|
|
1056
|
+
} finally {
|
|
1057
|
+
silent--;
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
const reader = Model.$reader;
|
|
1061
|
+
Model.$reader = undefined;
|
|
1062
|
+
try {
|
|
1063
|
+
for (let i = 0;i < names.length; i++)
|
|
1064
|
+
try {
|
|
1065
|
+
attach(target[names[i]], this, i);
|
|
1066
|
+
} catch (error) {
|
|
1067
|
+
if (!(error instanceof TypeError))
|
|
1068
|
+
throw error;
|
|
1069
|
+
}
|
|
1070
|
+
} finally {
|
|
1071
|
+
Model.$reader = reader;
|
|
1072
|
+
}
|
|
1073
|
+
return this;
|
|
1074
|
+
}
|
|
1075
|
+
addEventListener(type, callback, options) {
|
|
1076
|
+
if (!callback || type !== "change" && type !== "state") {
|
|
1077
|
+
super.addEventListener(type, callback, options);
|
|
1078
|
+
return;
|
|
1079
|
+
}
|
|
1080
|
+
const settings = typeof options === "object" && options !== null ? options : undefined;
|
|
1081
|
+
if (settings?.signal?.aborted)
|
|
1082
|
+
return;
|
|
1083
|
+
const capture = captureOf(options);
|
|
1084
|
+
const watched = this.#watched ??= [];
|
|
1085
|
+
for (const known of watched)
|
|
1086
|
+
if (known.type === type && known.callback === callback && known.capture === capture)
|
|
1087
|
+
return;
|
|
1088
|
+
const watch = { type, callback, capture };
|
|
1089
|
+
watched.push(watch);
|
|
1090
|
+
if (settings?.once)
|
|
1091
|
+
watch.wrapped = (event) => {
|
|
1092
|
+
this.#forget(watch);
|
|
1093
|
+
if (typeof callback === "function")
|
|
1094
|
+
callback.call(this, event);
|
|
1095
|
+
else
|
|
1096
|
+
callback.handleEvent(event);
|
|
1097
|
+
};
|
|
1098
|
+
super.addEventListener(type, watch.wrapped ?? callback, options);
|
|
1099
|
+
settings?.signal?.addEventListener("abort", () => this.#forget(watch), { once: true });
|
|
1100
|
+
}
|
|
1101
|
+
removeEventListener(type, callback, options) {
|
|
1102
|
+
let target = callback;
|
|
1103
|
+
const watched = this.#watched;
|
|
1104
|
+
if (callback && watched) {
|
|
1105
|
+
const capture = captureOf(options);
|
|
1106
|
+
for (let i = 0;i < watched.length; i++) {
|
|
1107
|
+
const watch = watched[i];
|
|
1108
|
+
if (watch.type === type && watch.callback === callback && watch.capture === capture) {
|
|
1109
|
+
watched.splice(i, 1);
|
|
1110
|
+
target = watch.wrapped ?? callback;
|
|
1111
|
+
break;
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
super.removeEventListener(type, target, options);
|
|
1116
|
+
}
|
|
1117
|
+
$changed(index, previous) {
|
|
1118
|
+
if (silent !== 0)
|
|
1119
|
+
return;
|
|
1120
|
+
const name = metaOf(this).names[index];
|
|
1121
|
+
const originals = this.#originals ??= Object.create(null);
|
|
1122
|
+
if (!(name in originals))
|
|
1123
|
+
originals[name] = previous;
|
|
1124
|
+
if ((this.#state & 1 /* Detached */) !== 0)
|
|
1125
|
+
this[StateKey] = 4 /* Added */;
|
|
1126
|
+
else if ((this.#state & 2 /* Unchanged */) !== 0)
|
|
1127
|
+
this[StateKey] = 16 /* Modified */;
|
|
1128
|
+
const reader = Model.$reader;
|
|
1129
|
+
Model.$reader = undefined;
|
|
1130
|
+
const value = this[name];
|
|
1131
|
+
Model.$reader = reader;
|
|
1132
|
+
attach(value, this, index);
|
|
1133
|
+
this.#emit(name, value, previous, index);
|
|
1134
|
+
}
|
|
1135
|
+
$touched(index) {
|
|
1136
|
+
const name = metaOf(this).names[index];
|
|
1137
|
+
const reader = Model.$reader;
|
|
1138
|
+
Model.$reader = undefined;
|
|
1139
|
+
const value = this[name];
|
|
1140
|
+
Model.$reader = reader;
|
|
1141
|
+
this.#emit(name, value, value, index);
|
|
1142
|
+
}
|
|
1143
|
+
#emit(name, value, previous, index) {
|
|
1144
|
+
if (!this.#hasListener("change")) {
|
|
1145
|
+
const subs = this.#subs;
|
|
1146
|
+
if (subs === undefined || subs.length === 0)
|
|
1147
|
+
return;
|
|
1148
|
+
const at = index ?? metaOf(this).names.indexOf(name);
|
|
1149
|
+
for (let i = 0;i < subs.length; i++)
|
|
1150
|
+
changed(subs[i], at);
|
|
1151
|
+
return;
|
|
1152
|
+
}
|
|
1153
|
+
const depth = silent;
|
|
1154
|
+
silent = 0;
|
|
1155
|
+
try {
|
|
1156
|
+
this.dispatchEvent(new ModelChangeEvent(name, value, previous, index));
|
|
1157
|
+
} finally {
|
|
1158
|
+
silent = depth;
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
$watch(dep) {
|
|
1162
|
+
const subs = this.#subs ??= [];
|
|
1163
|
+
dep.slot = subs.length;
|
|
1164
|
+
subs.push(dep);
|
|
1165
|
+
}
|
|
1166
|
+
$unwatch(dep) {
|
|
1167
|
+
const subs = this.#subs;
|
|
1168
|
+
if (subs === undefined || subs.length === 0)
|
|
1169
|
+
return;
|
|
1170
|
+
const last = subs.pop();
|
|
1171
|
+
if (last !== dep) {
|
|
1172
|
+
subs[dep.slot] = last;
|
|
1173
|
+
last.slot = dep.slot;
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
dispatchEvent(event) {
|
|
1177
|
+
const subs = this.#subs;
|
|
1178
|
+
if (subs !== undefined && subs.length !== 0 && event.type === "change") {
|
|
1179
|
+
const e = event;
|
|
1180
|
+
const index = e.index ?? metaOf(this).names.indexOf(e.property);
|
|
1181
|
+
if (index >= 0)
|
|
1182
|
+
for (let i = 0;i < subs.length; i++)
|
|
1183
|
+
changed(subs[i], index);
|
|
1184
|
+
}
|
|
1185
|
+
return super.dispatchEvent(event);
|
|
1186
|
+
}
|
|
1187
|
+
#listens(type) {
|
|
1188
|
+
if (type === "change" && this.#subs !== undefined && this.#subs.length !== 0)
|
|
1189
|
+
return true;
|
|
1190
|
+
return this.#hasListener(type);
|
|
1191
|
+
}
|
|
1192
|
+
#hasListener(type) {
|
|
1193
|
+
const watched = this.#watched;
|
|
1194
|
+
if (watched === undefined)
|
|
1195
|
+
return false;
|
|
1196
|
+
for (let i = 0;i < watched.length; i++)
|
|
1197
|
+
if (watched[i].type === type)
|
|
1198
|
+
return true;
|
|
1199
|
+
return false;
|
|
1200
|
+
}
|
|
1201
|
+
#forget(watch) {
|
|
1202
|
+
const watched = this.#watched;
|
|
1203
|
+
if (!watched)
|
|
1204
|
+
return;
|
|
1205
|
+
const i = watched.indexOf(watch);
|
|
1206
|
+
if (i >= 0)
|
|
1207
|
+
watched.splice(i, 1);
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
function Persist(_getter, context) {
|
|
1211
|
+
(pendingPersist ??= []).push(context.name);
|
|
1212
|
+
}
|
|
1213
|
+
function Validate(...validators) {
|
|
1214
|
+
return (_member, context) => {
|
|
1215
|
+
(pendingValidators ??= []).push([context.name, validators]);
|
|
1216
|
+
};
|
|
1217
|
+
}
|
|
1218
|
+
function Ignore(_member, context) {
|
|
1219
|
+
(pendingIgnored ??= []).push(context.name);
|
|
1220
|
+
}
|
|
1221
|
+
function Untracked(_value, _context) {}
|
|
1222
|
+
function isLike(a, b) {
|
|
1223
|
+
return Model.same(a, b);
|
|
1224
|
+
}
|
|
1225
|
+
function attach(value, owner, index) {
|
|
1226
|
+
if (value !== null && typeof value === "object") {
|
|
1227
|
+
const set = value;
|
|
1228
|
+
if (typeof set.$own === "function")
|
|
1229
|
+
set.$own(owner, index);
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
function valueHasChanges(value) {
|
|
1233
|
+
if (value === null || typeof value !== "object" || value instanceof Date)
|
|
1234
|
+
return false;
|
|
1235
|
+
const changes = value.hasChanges;
|
|
1236
|
+
if (typeof changes === "boolean")
|
|
1237
|
+
return changes;
|
|
1238
|
+
if (Array.isArray(value))
|
|
1239
|
+
return value.some(valueHasChanges);
|
|
1240
|
+
return Object.values(value).some(valueHasChanges);
|
|
1241
|
+
}
|
|
1242
|
+
function valueHasErrors(value) {
|
|
1243
|
+
if (value === null || typeof value !== "object" || value instanceof Date)
|
|
1244
|
+
return false;
|
|
1245
|
+
const errors = value.hasErrors;
|
|
1246
|
+
if (typeof errors === "boolean")
|
|
1247
|
+
return errors;
|
|
1248
|
+
if (Array.isArray(value))
|
|
1249
|
+
return value.some(valueHasErrors);
|
|
1250
|
+
return Object.values(value).some(valueHasErrors);
|
|
1251
|
+
}
|
|
1252
|
+
function isSerializable(value) {
|
|
1253
|
+
if (value === null)
|
|
1254
|
+
return true;
|
|
1255
|
+
const type = typeof value;
|
|
1256
|
+
if (type === "string" || type === "number" || type === "boolean")
|
|
1257
|
+
return true;
|
|
1258
|
+
return value instanceof Date || valueHasChanges(value);
|
|
1259
|
+
}
|
|
1260
|
+
function changesOf(value) {
|
|
1261
|
+
if (value === null || typeof value !== "object" || value instanceof Date)
|
|
1262
|
+
return value;
|
|
1263
|
+
const owner = value;
|
|
1264
|
+
if (typeof owner.hasChanges === "boolean")
|
|
1265
|
+
return owner.changes;
|
|
1266
|
+
if (Array.isArray(value))
|
|
1267
|
+
return value.filter(valueHasChanges).map(changesOf);
|
|
1268
|
+
const result = {};
|
|
1269
|
+
for (const [name, nested] of Object.entries(value))
|
|
1270
|
+
if (isSerializable(nested))
|
|
1271
|
+
result[name] = changesOf(nested);
|
|
1272
|
+
return result;
|
|
1273
|
+
}
|
|
1274
|
+
function revertValue(value) {
|
|
1275
|
+
if (value === null || typeof value !== "object")
|
|
1276
|
+
return;
|
|
1277
|
+
const owner = value;
|
|
1278
|
+
if (typeof owner.revertChanges === "function") {
|
|
1279
|
+
if (owner.hasChanges)
|
|
1280
|
+
owner.revertChanges();
|
|
1281
|
+
} else if (Array.isArray(value))
|
|
1282
|
+
value.forEach(revertValue);
|
|
1283
|
+
}
|
|
1284
|
+
var required = (value) => value !== undefined && value !== null && (typeof value !== "string" || value.trim() !== "") ? true : "Field is required";
|
|
1285
|
+
var emailTest = /^((([a-z]|\d|[!#$%&'*+\-\/=?^_`{|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#$%&'*+\-\/=?^_`{|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)(((([\x20\x09])*(\x0d\x0a))?([\x20\x09])+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*((([\x20\x09])*(\x0d\x0a))?([\x20\x09])+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i;
|
|
1286
|
+
var email = (value) => (value ?? "").length <= 254 && emailTest.test(value ?? "") ? true : "Field should be a valid e-mail";
|
|
1287
|
+
var phoneTest = /^(\+\s?)?((?<!\+.*)\(\+?\d+([\s\-.]?\d+)?\)|\d)(?:\d|[\s\-.]\d|[\s\-.]?\(\d+(?:[\s\-.]?\d+)?\))*(\s?(x|ext\.?)\s?\d+)?$/i;
|
|
1288
|
+
function isValidPhone(value) {
|
|
1289
|
+
return value == null || phoneTest.test(value);
|
|
1290
|
+
}
|
|
1291
|
+
var phone = (value) => isValidPhone(value ?? null) ? true : "Field should be a valid phone";
|
|
1292
|
+
var maxLength = (length) => (value) => `${value}`.length <= length ? true : `Field length is limited to ${length}`;
|
|
1293
|
+
var minLength = (length) => (value) => `${value}`.length >= length ? true : `Field min length is ${length} characters`;
|
|
1294
|
+
var requiredIdValue = (value) => required(value) === true && value > 0 ? true : "Field is required";
|
|
1295
|
+
var nonZero = (value) => value > 0 ? true : "Value must be greater than 0";
|
|
1296
|
+
var minValue = (min, inclusive = true) => (value) => (inclusive ? value >= min : value > min) ? true : `Field must be greater than ${inclusive ? "or equal to " : ""}${min}`;
|
|
1297
|
+
var maxValue = (max, inclusive = true) => (value) => (inclusive ? value <= max : value < max) ? true : `Field must be less than ${inclusive ? "or equal to " : ""}${max}`;
|
|
1298
|
+
var reads = Symbol("xzor.model.reads");
|
|
1299
|
+
var readsOf = (c) => c[reads];
|
|
1300
|
+
var stack = [];
|
|
1301
|
+
var queued = [];
|
|
1302
|
+
var current;
|
|
1303
|
+
var currentReads;
|
|
1304
|
+
var bitOf2 = (index) => index === stateIndex ? 1 << 31 : index < 30 ? 1 << index : 1 << 30;
|
|
1305
|
+
function subscribe(own, model) {
|
|
1306
|
+
const dep = { model, owner: own, mask: 0, epoch: own.epoch, slot: 0 };
|
|
1307
|
+
model.$watch(dep);
|
|
1308
|
+
own.size++;
|
|
1309
|
+
own.seen++;
|
|
1310
|
+
return dep;
|
|
1311
|
+
}
|
|
1312
|
+
function read(model, index) {
|
|
1313
|
+
let own = currentReads;
|
|
1314
|
+
if (own === undefined) {
|
|
1315
|
+
own = currentReads = {
|
|
1316
|
+
component: current,
|
|
1317
|
+
first: undefined,
|
|
1318
|
+
more: undefined,
|
|
1319
|
+
epoch: 1,
|
|
1320
|
+
renders: 1,
|
|
1321
|
+
at: -1,
|
|
1322
|
+
size: 0,
|
|
1323
|
+
seen: 0
|
|
1324
|
+
};
|
|
1325
|
+
current[reads] = own;
|
|
1326
|
+
}
|
|
1327
|
+
let dep = own.first;
|
|
1328
|
+
if (dep === undefined)
|
|
1329
|
+
dep = own.first = subscribe(own, model);
|
|
1330
|
+
else if (dep.model !== model) {
|
|
1331
|
+
dep = own.more?.get(model);
|
|
1332
|
+
if (dep === undefined) {
|
|
1333
|
+
dep = subscribe(own, model);
|
|
1334
|
+
(own.more ??= new Map).set(model, dep);
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
if (dep.epoch !== own.epoch) {
|
|
1338
|
+
dep.epoch = own.epoch;
|
|
1339
|
+
dep.mask = 0;
|
|
1340
|
+
own.seen++;
|
|
1341
|
+
}
|
|
1342
|
+
dep.mask |= bitOf2(index);
|
|
1343
|
+
}
|
|
1344
|
+
function changed(dep, index) {
|
|
1345
|
+
if ((dep.mask & bitOf2(index)) === 0)
|
|
1346
|
+
return;
|
|
1347
|
+
const own = dep.owner;
|
|
1348
|
+
if (own.at < 0) {
|
|
1349
|
+
queued.push(own);
|
|
1350
|
+
if (queued.length === 1)
|
|
1351
|
+
queueMicrotask(flush);
|
|
1352
|
+
}
|
|
1353
|
+
own.at = own.renders;
|
|
1354
|
+
}
|
|
1355
|
+
function flush() {
|
|
1356
|
+
for (const own of queued.splice(0)) {
|
|
1357
|
+
const at = own.at;
|
|
1358
|
+
own.at = -1;
|
|
1359
|
+
if (own.renders === at)
|
|
1360
|
+
own.component.stateHasChanged();
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
var $notify = changed;
|
|
1364
|
+
var $flush = flush;
|
|
1365
|
+
function sweep(own) {
|
|
1366
|
+
const more = own.more;
|
|
1367
|
+
if (more !== undefined) {
|
|
1368
|
+
for (const dep of more.values())
|
|
1369
|
+
if (dep.epoch !== own.epoch) {
|
|
1370
|
+
dep.model.$unwatch(dep);
|
|
1371
|
+
more.delete(dep.model);
|
|
1372
|
+
own.size--;
|
|
1373
|
+
}
|
|
1374
|
+
if (more.size === 0)
|
|
1375
|
+
own.more = undefined;
|
|
1376
|
+
}
|
|
1377
|
+
const first = own.first;
|
|
1378
|
+
if (first !== undefined && first.epoch !== own.epoch) {
|
|
1379
|
+
first.model.$unwatch(first);
|
|
1380
|
+
own.first = undefined;
|
|
1381
|
+
own.size--;
|
|
1382
|
+
const rest = own.more;
|
|
1383
|
+
if (rest !== undefined) {
|
|
1384
|
+
for (const [model, dep] of rest) {
|
|
1385
|
+
own.first = dep;
|
|
1386
|
+
rest.delete(model);
|
|
1387
|
+
break;
|
|
1388
|
+
}
|
|
1389
|
+
if (rest.size === 0)
|
|
1390
|
+
own.more = undefined;
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
setRenderObserver({
|
|
1395
|
+
begin(component) {
|
|
1396
|
+
stack.push(component);
|
|
1397
|
+
current = component;
|
|
1398
|
+
const own = currentReads = readsOf(component);
|
|
1399
|
+
if (own !== undefined) {
|
|
1400
|
+
own.epoch++;
|
|
1401
|
+
own.renders++;
|
|
1402
|
+
own.seen = 0;
|
|
1403
|
+
}
|
|
1404
|
+
Model.$reader = read;
|
|
1405
|
+
},
|
|
1406
|
+
end(_component) {
|
|
1407
|
+
const own = currentReads;
|
|
1408
|
+
if (own !== undefined && own.seen !== own.size)
|
|
1409
|
+
sweep(own);
|
|
1410
|
+
stack.pop();
|
|
1411
|
+
current = stack[stack.length - 1];
|
|
1412
|
+
currentReads = current === undefined ? undefined : readsOf(current);
|
|
1413
|
+
if (current === undefined)
|
|
1414
|
+
Model.$reader = undefined;
|
|
1415
|
+
},
|
|
1416
|
+
dispose(component) {
|
|
1417
|
+
const own = readsOf(component);
|
|
1418
|
+
if (own === undefined)
|
|
1419
|
+
return;
|
|
1420
|
+
if (own.first !== undefined)
|
|
1421
|
+
own.first.model.$unwatch(own.first);
|
|
1422
|
+
if (own.more !== undefined)
|
|
1423
|
+
for (const dep of own.more.values())
|
|
1424
|
+
dep.model.$unwatch(dep);
|
|
1425
|
+
own.first = own.more = undefined;
|
|
1426
|
+
own.size = 0;
|
|
1427
|
+
own.renders++;
|
|
1428
|
+
}
|
|
1429
|
+
});
|
|
1430
|
+
export {
|
|
1431
|
+
$flush,
|
|
1432
|
+
$notify,
|
|
1433
|
+
EntitySet,
|
|
1434
|
+
FineComponent,
|
|
1435
|
+
Ignore,
|
|
1436
|
+
Model,
|
|
1437
|
+
ModelChangeEvent,
|
|
1438
|
+
Persist,
|
|
1439
|
+
State,
|
|
1440
|
+
StateKey,
|
|
1441
|
+
Untracked,
|
|
1442
|
+
Validate,
|
|
1443
|
+
email,
|
|
1444
|
+
fine,
|
|
1445
|
+
isLike,
|
|
1446
|
+
isValidPhone,
|
|
1447
|
+
maxLength,
|
|
1448
|
+
maxValue,
|
|
1449
|
+
minLength,
|
|
1450
|
+
minValue,
|
|
1451
|
+
nonZero,
|
|
1452
|
+
phone,
|
|
1453
|
+
required,
|
|
1454
|
+
requiredIdValue
|
|
1455
|
+
};
|
|
1456
|
+
|
|
1457
|
+
//# debugId=61B5F3F4B8CDA71064756E2164756E21
|
|
1458
|
+
//# sourceMappingURL=model.js.map
|