@vmz/core 0.1.28 → 0.1.29
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/dist/dom-core.d.ts +17 -0
- package/dist/dom-core.js +91 -6
- package/dist/dom-ssr.js +20 -0
- package/package.json +7 -7
package/dist/dom-core.d.ts
CHANGED
|
@@ -142,6 +142,23 @@ export declare const directApi: {
|
|
|
142
142
|
* @param {{ stable: string[], branches: Array<{ cond?: => any, deps: string[] }> } | null | undefined} [cf]
|
|
143
143
|
*/
|
|
144
144
|
bindAttr(inst: any, bindingId: any, deps: any, get: any, el: any, name: any, cf: any): void;
|
|
145
|
+
/**
|
|
146
|
+
* Specialized single-field attr bind (0.1.29): compile-time field name, no generic get closure in artifact.
|
|
147
|
+
* @param {object} inst
|
|
148
|
+
* @param {number|string|null} bindingId
|
|
149
|
+
* @param {string} fieldName
|
|
150
|
+
* @param {Element} el
|
|
151
|
+
* @param {string} name
|
|
152
|
+
*/
|
|
153
|
+
specFieldAttr(inst: any, bindingId: any, fieldName: any, el: any, name: any): void;
|
|
154
|
+
/**
|
|
155
|
+
* Specialized single-field text bind (0.1.29): compile-time field name in generated artifact.
|
|
156
|
+
* @param {object} inst
|
|
157
|
+
* @param {number|string|null} bindingId
|
|
158
|
+
* @param {string} fieldName
|
|
159
|
+
* @param {Text} textNode
|
|
160
|
+
*/
|
|
161
|
+
specFieldText(inst: any, bindingId: any, fieldName: any, textNode: any): void;
|
|
145
162
|
setHtml(el: any, value: any): void;
|
|
146
163
|
/**
|
|
147
164
|
* Trusted HTML binding (`html={expr}`). Author/plugin responsibility.
|
package/dist/dom-core.js
CHANGED
|
@@ -404,9 +404,13 @@ export const directApi = {
|
|
|
404
404
|
* @param {{ skipFlush?: boolean } | null | undefined} [opts]
|
|
405
405
|
*/
|
|
406
406
|
onMethod(el, type, methodName, opts) {
|
|
407
|
-
|
|
407
|
+
// Prefer each-block owner: item create often runs during flush when `_inst` is unset.
|
|
408
|
+
const eachOwner = directApi._eachCtx && directApi._eachCtx.inst;
|
|
409
|
+
const inst = eachOwner || directApi._inst;
|
|
410
|
+
if (!inst)
|
|
411
|
+
return;
|
|
408
412
|
let skipFlush = !!(opts && opts.skipFlush);
|
|
409
|
-
|
|
413
|
+
const invoke = (ev) => {
|
|
410
414
|
if (type === 'submit' && ev && typeof ev.preventDefault === 'function') {
|
|
411
415
|
ev.preventDefault();
|
|
412
416
|
}
|
|
@@ -429,7 +433,15 @@ export const directApi = {
|
|
|
429
433
|
skipFlush = true;
|
|
430
434
|
}
|
|
431
435
|
}
|
|
432
|
-
}
|
|
436
|
+
};
|
|
437
|
+
if (directApi._eachCtx) {
|
|
438
|
+
/** @type {Record<string, Function>} */
|
|
439
|
+
const bag = el.__vmzEvt || (el.__vmzEvt = Object.create(null));
|
|
440
|
+
bag[type] = (ev) => invoke(ev);
|
|
441
|
+
directApi._eachCtx.needDelegate(type);
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
el.addEventListener(type, (ev) => invoke(ev));
|
|
433
445
|
},
|
|
434
446
|
/**
|
|
435
447
|
* @param {object} inst
|
|
@@ -467,6 +479,44 @@ export const directApi = {
|
|
|
467
479
|
}
|
|
468
480
|
}, cf);
|
|
469
481
|
},
|
|
482
|
+
/**
|
|
483
|
+
* Specialized single-field attr bind (0.1.29): compile-time field name, no generic get closure in artifact.
|
|
484
|
+
* @param {object} inst
|
|
485
|
+
* @param {number|string|null} bindingId
|
|
486
|
+
* @param {string} fieldName
|
|
487
|
+
* @param {Element} el
|
|
488
|
+
* @param {string} name
|
|
489
|
+
*/
|
|
490
|
+
specFieldAttr(inst, bindingId, fieldName, el, name) {
|
|
491
|
+
wireDirectBind(inst, bindingId, [fieldName], function specFieldAttrGet() {
|
|
492
|
+
return this[fieldName];
|
|
493
|
+
}, (raw) => {
|
|
494
|
+
if (name === 'class' || name === 'className') {
|
|
495
|
+
const s = String(raw ?? '');
|
|
496
|
+
if (s)
|
|
497
|
+
el.setAttribute('class', s);
|
|
498
|
+
else if (el.hasAttribute('class'))
|
|
499
|
+
el.removeAttribute('class');
|
|
500
|
+
}
|
|
501
|
+
else {
|
|
502
|
+
applyDomAttr(el, name, raw);
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
},
|
|
506
|
+
/**
|
|
507
|
+
* Specialized single-field text bind (0.1.29): compile-time field name in generated artifact.
|
|
508
|
+
* @param {object} inst
|
|
509
|
+
* @param {number|string|null} bindingId
|
|
510
|
+
* @param {string} fieldName
|
|
511
|
+
* @param {Text} textNode
|
|
512
|
+
*/
|
|
513
|
+
specFieldText(inst, bindingId, fieldName, textNode) {
|
|
514
|
+
wireDirectBind(inst, bindingId, [fieldName], function specFieldTextGet() {
|
|
515
|
+
return this[fieldName];
|
|
516
|
+
}, (raw) => {
|
|
517
|
+
textNode.textContent = String(raw ?? '');
|
|
518
|
+
});
|
|
519
|
+
},
|
|
470
520
|
setHtml(el, value) {
|
|
471
521
|
el.innerHTML = value == null ? '' : String(value);
|
|
472
522
|
},
|
|
@@ -1153,7 +1203,9 @@ export const directApi = {
|
|
|
1153
1203
|
delegateTypes.add(type);
|
|
1154
1204
|
ensureDelegateAttached();
|
|
1155
1205
|
};
|
|
1156
|
-
|
|
1206
|
+
// `inst` must ride eachCtx: month/list rebuilds call createItem during flush
|
|
1207
|
+
// when `directApi._inst` is null (unlike ifBlock branch create which sets it).
|
|
1208
|
+
const eachCtx = { inst, noteItemBind, needDelegate };
|
|
1157
1209
|
const clearDomEvt = (root) => {
|
|
1158
1210
|
if (!root || root.nodeType !== 1)
|
|
1159
1211
|
return;
|
|
@@ -1657,8 +1709,20 @@ export const directApi = {
|
|
|
1657
1709
|
attrEls[i] = attrSlots[i].get(root);
|
|
1658
1710
|
for (let i = 0; i < nOn; i++) {
|
|
1659
1711
|
const el = onSlots[i].get(root);
|
|
1660
|
-
|
|
1661
|
-
|
|
1712
|
+
const slot = onSlots[i];
|
|
1713
|
+
if (slot.directMethod) {
|
|
1714
|
+
/** @type {Record<string, Function>} */
|
|
1715
|
+
const bag = el.__vmzEvt || (el.__vmzEvt = Object.create(null));
|
|
1716
|
+
const method = slot.method;
|
|
1717
|
+
bag[slot.type] = (ev) => {
|
|
1718
|
+
const fn = inst[method];
|
|
1719
|
+
if (typeof fn !== 'function')
|
|
1720
|
+
return;
|
|
1721
|
+
runDomEventHandler(inst, method, () => fn.call(inst, ev));
|
|
1722
|
+
};
|
|
1723
|
+
}
|
|
1724
|
+
else if (!el.__vmzAct) {
|
|
1725
|
+
el.__vmzAct = slot.method;
|
|
1662
1726
|
}
|
|
1663
1727
|
}
|
|
1664
1728
|
for (let i = 0; i < nText; i++) {
|
|
@@ -1834,6 +1898,17 @@ export const directApi = {
|
|
|
1834
1898
|
api.on(el, type, handler);
|
|
1835
1899
|
recordFailed = true;
|
|
1836
1900
|
},
|
|
1901
|
+
onMethod(el, type, methodName, opts) {
|
|
1902
|
+
if (!recordFailed) {
|
|
1903
|
+
pending.ons.push({
|
|
1904
|
+
node: el,
|
|
1905
|
+
type,
|
|
1906
|
+
method: methodName,
|
|
1907
|
+
directMethod: true,
|
|
1908
|
+
});
|
|
1909
|
+
}
|
|
1910
|
+
api.onMethod(el, type, methodName, opts);
|
|
1911
|
+
},
|
|
1837
1912
|
});
|
|
1838
1913
|
const dom = userCreateItem.call(inst, recordingApi, box);
|
|
1839
1914
|
if (!recordFailed && dom && dom.nodeType === 1 && root === dom && (pending.texts.length > 0 || pending.attrs.length > 0)) {
|
|
@@ -1915,6 +1990,7 @@ export const directApi = {
|
|
|
1915
1990
|
path,
|
|
1916
1991
|
type: p.type,
|
|
1917
1992
|
method: p.method,
|
|
1993
|
+
directMethod: !!p.directMethod,
|
|
1918
1994
|
get: makeChildGetter(path),
|
|
1919
1995
|
});
|
|
1920
1996
|
}
|
|
@@ -2070,8 +2146,10 @@ export const directApi = {
|
|
|
2070
2146
|
const patches0 = [];
|
|
2071
2147
|
const prevPatches = directApi._itemPatches;
|
|
2072
2148
|
const prevCtx = directApi._eachCtx;
|
|
2149
|
+
const prevInst = directApi._inst;
|
|
2073
2150
|
directApi._itemPatches = patches0;
|
|
2074
2151
|
directApi._eachCtx = eachCtx;
|
|
2152
|
+
directApi._inst = inst;
|
|
2075
2153
|
let dom0 = null;
|
|
2076
2154
|
try {
|
|
2077
2155
|
dom0 = createItem(directApi, box0, patches0);
|
|
@@ -2079,6 +2157,7 @@ export const directApi = {
|
|
|
2079
2157
|
finally {
|
|
2080
2158
|
directApi._itemPatches = prevPatches;
|
|
2081
2159
|
directApi._eachCtx = prevCtx;
|
|
2160
|
+
directApi._inst = prevInst;
|
|
2082
2161
|
}
|
|
2083
2162
|
if (applied !== gen || inst.__vmzDestroyed)
|
|
2084
2163
|
return;
|
|
@@ -2203,8 +2282,10 @@ export const directApi = {
|
|
|
2203
2282
|
const patches = [];
|
|
2204
2283
|
const prevPatches = directApi._itemPatches;
|
|
2205
2284
|
const prevCtx = directApi._eachCtx;
|
|
2285
|
+
const prevInst = directApi._inst;
|
|
2206
2286
|
directApi._itemPatches = patches;
|
|
2207
2287
|
directApi._eachCtx = eachCtx;
|
|
2288
|
+
directApi._inst = inst;
|
|
2208
2289
|
let dom = null;
|
|
2209
2290
|
try {
|
|
2210
2291
|
dom = createItem(directApi, box, patches);
|
|
@@ -2212,6 +2293,7 @@ export const directApi = {
|
|
|
2212
2293
|
finally {
|
|
2213
2294
|
directApi._itemPatches = prevPatches;
|
|
2214
2295
|
directApi._eachCtx = prevCtx;
|
|
2296
|
+
directApi._inst = prevInst;
|
|
2215
2297
|
}
|
|
2216
2298
|
if (applied !== gen || inst.__vmzDestroyed)
|
|
2217
2299
|
return;
|
|
@@ -2326,8 +2408,10 @@ export const directApi = {
|
|
|
2326
2408
|
const patches = [];
|
|
2327
2409
|
const prevPatches = directApi._itemPatches;
|
|
2328
2410
|
const prevCtx = directApi._eachCtx;
|
|
2411
|
+
const prevInst = directApi._inst;
|
|
2329
2412
|
directApi._itemPatches = patches;
|
|
2330
2413
|
directApi._eachCtx = eachCtx;
|
|
2414
|
+
directApi._inst = inst;
|
|
2331
2415
|
let dom = null;
|
|
2332
2416
|
try {
|
|
2333
2417
|
dom = createItem(directApi, box, patches);
|
|
@@ -2335,6 +2419,7 @@ export const directApi = {
|
|
|
2335
2419
|
finally {
|
|
2336
2420
|
directApi._itemPatches = prevPatches;
|
|
2337
2421
|
directApi._eachCtx = prevCtx;
|
|
2422
|
+
directApi._inst = prevInst;
|
|
2338
2423
|
}
|
|
2339
2424
|
if (applied !== gen || inst.__vmzDestroyed)
|
|
2340
2425
|
return;
|
package/dist/dom-ssr.js
CHANGED
|
@@ -591,6 +591,16 @@ const serializeApi = {
|
|
|
591
591
|
}
|
|
592
592
|
textNode.value = String(raw ?? '');
|
|
593
593
|
},
|
|
594
|
+
specFieldText(inst, _bindingId, fieldName, textNode) {
|
|
595
|
+
let raw;
|
|
596
|
+
try {
|
|
597
|
+
raw = inst[fieldName];
|
|
598
|
+
}
|
|
599
|
+
catch {
|
|
600
|
+
raw = '';
|
|
601
|
+
}
|
|
602
|
+
textNode.value = String(raw ?? '');
|
|
603
|
+
},
|
|
594
604
|
bindAttr(inst, bindingId, deps, get, el, name) {
|
|
595
605
|
let raw;
|
|
596
606
|
try {
|
|
@@ -601,6 +611,16 @@ const serializeApi = {
|
|
|
601
611
|
}
|
|
602
612
|
applySerializeAttr(el, name, raw);
|
|
603
613
|
},
|
|
614
|
+
specFieldAttr(inst, _bindingId, fieldName, el, name) {
|
|
615
|
+
let raw;
|
|
616
|
+
try {
|
|
617
|
+
raw = inst[fieldName];
|
|
618
|
+
}
|
|
619
|
+
catch {
|
|
620
|
+
raw = null;
|
|
621
|
+
}
|
|
622
|
+
applySerializeAttr(el, name, raw);
|
|
623
|
+
},
|
|
604
624
|
bindComponentProp() {
|
|
605
625
|
/* SSR: props already resolved into the child instance at create */
|
|
606
626
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vmz/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.29",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "VMZ production runtime core — DOM / SSR / HTTP / WriteBarrier (no compiler)",
|
|
6
6
|
"exports": {
|
|
@@ -66,12 +66,12 @@
|
|
|
66
66
|
"linkedom": "^0.18.13"
|
|
67
67
|
},
|
|
68
68
|
"optionalDependencies": {
|
|
69
|
-
"@vmz/vmz-win32-x64": "0.1.
|
|
70
|
-
"@vmz/vmz-win32-arm64": "0.1.
|
|
71
|
-
"@vmz/vmz-darwin-x64": "0.1.
|
|
72
|
-
"@vmz/vmz-darwin-arm64": "0.1.
|
|
73
|
-
"@vmz/vmz-linux-x64": "0.1.
|
|
74
|
-
"@vmz/vmz-linux-arm64": "0.1.
|
|
69
|
+
"@vmz/vmz-win32-x64": "0.1.29",
|
|
70
|
+
"@vmz/vmz-win32-arm64": "0.1.29",
|
|
71
|
+
"@vmz/vmz-darwin-x64": "0.1.29",
|
|
72
|
+
"@vmz/vmz-darwin-arm64": "0.1.29",
|
|
73
|
+
"@vmz/vmz-linux-x64": "0.1.29",
|
|
74
|
+
"@vmz/vmz-linux-arm64": "0.1.29"
|
|
75
75
|
},
|
|
76
76
|
"publishConfig": {
|
|
77
77
|
"access": "public"
|