@lark.js/mvc 0.0.8 → 0.0.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/README.md +2 -24
- package/dist/{chunk-3HSA7OHB.js → chunk-SIQF4YLC.js} +83 -83
- package/dist/compiler.cjs +83 -83
- package/dist/compiler.js +83 -83
- package/dist/index.cjs +100 -234
- package/dist/index.d.cts +177 -422
- package/dist/index.d.ts +177 -422
- package/dist/index.js +99 -198
- package/dist/runtime.cjs +34 -9
- package/dist/runtime.d.cts +22 -13
- package/dist/runtime.d.ts +22 -13
- package/dist/runtime.js +33 -10
- package/dist/vite.cjs +83 -83
- package/dist/vite.js +1 -1
- package/dist/webpack.cjs +83 -83
- package/dist/webpack.js +1 -1
- package/package.json +4 -4
- package/src/client.d.ts +2 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/common.ts
|
|
2
2
|
var globalCounter = 0;
|
|
3
3
|
var SPLITTER = String.fromCharCode(30);
|
|
4
4
|
var RouterEvents = {
|
|
@@ -6,14 +6,6 @@ var RouterEvents = {
|
|
|
6
6
|
CHANGED: "changed",
|
|
7
7
|
PAGE_UNLOAD: "page_unload"
|
|
8
8
|
};
|
|
9
|
-
var LarkInnerKeys = {
|
|
10
|
-
/** Attribute name: ldk (static key for skipping VDOM diff) */
|
|
11
|
-
DIFF_KEY: "ldk",
|
|
12
|
-
/** Attribute name: lak (static attribute key) */
|
|
13
|
-
ATTR_KEY: "lak",
|
|
14
|
-
/** Attribute name: lvk (view key for assign) */
|
|
15
|
-
VIEW_KEY: "lvk"
|
|
16
|
-
};
|
|
17
9
|
var LARK_VIEW = "v-lark";
|
|
18
10
|
var EVENT_METHOD_REGEXP = new RegExp(
|
|
19
11
|
`(?:([\\w-]+)${SPLITTER})?([^(]+)\\(([\\s\\S]*?)?\\)`
|
|
@@ -22,6 +14,7 @@ var VIEW_EVENT_METHOD_REGEXP = /^(\$?)([\w]*)<(.*?)>(?:<([\w ,]*)>)?$/;
|
|
|
22
14
|
var URL_TRIM_HASH_REGEXP = /(?:^.*\/\/[^/]+|#.*$)/gi;
|
|
23
15
|
var URL_TRIM_QUERY_REGEXP = /^[^#]*#?!?/;
|
|
24
16
|
var URL_PARAM_REGEXP = /([^=&?/#]+)=?([^&#?]*)/g;
|
|
17
|
+
var IS_URL_PARAMS = /(?!^)=|&/;
|
|
25
18
|
var URL_QUERY_HASH_REGEXP = /[#?].*$/;
|
|
26
19
|
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
27
20
|
var MATH_NS = "http://www.w3.org/1998/Math/MathML";
|
|
@@ -30,13 +23,66 @@ var CALL_BREAK_TIME = 48;
|
|
|
30
23
|
function nextCounter() {
|
|
31
24
|
return ++globalCounter;
|
|
32
25
|
}
|
|
26
|
+
var HTML_ENT_MAP = {
|
|
27
|
+
"&": "amp",
|
|
28
|
+
"<": "lt",
|
|
29
|
+
">": "gt",
|
|
30
|
+
'"': "#34",
|
|
31
|
+
"'": "#39",
|
|
32
|
+
"`": "#96"
|
|
33
|
+
};
|
|
34
|
+
var HTML_ENT_REGEXP = /[&<>"'`]/g;
|
|
35
|
+
function encodeSafe(v) {
|
|
36
|
+
return String(v == null ? "" : v);
|
|
37
|
+
}
|
|
38
|
+
function encodeHTML(v) {
|
|
39
|
+
return String(v == null ? "" : v).replace(
|
|
40
|
+
HTML_ENT_REGEXP,
|
|
41
|
+
(m) => "&" + HTML_ENT_MAP[m] + ";"
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
var URI_ENT_MAP = {
|
|
45
|
+
"!": "%21",
|
|
46
|
+
"'": "%27",
|
|
47
|
+
"(": "%28",
|
|
48
|
+
")": "%29",
|
|
49
|
+
"*": "%2A"
|
|
50
|
+
};
|
|
51
|
+
var URI_ENT_REGEXP = /[!')(*]/g;
|
|
52
|
+
function encodeURIExtra(v) {
|
|
53
|
+
return encodeURIComponent(encodeSafe(v)).replace(
|
|
54
|
+
URI_ENT_REGEXP,
|
|
55
|
+
(m) => URI_ENT_MAP[m]
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
var QUOTE_ENT_REGEXP = /['"\\]/g;
|
|
59
|
+
function encodeQ(v) {
|
|
60
|
+
return encodeSafe(v).replace(QUOTE_ENT_REGEXP, "\\$&");
|
|
61
|
+
}
|
|
62
|
+
function refFn(ref, value, key) {
|
|
63
|
+
const counter = ref[SPLITTER];
|
|
64
|
+
for (let i = counter; --i; ) {
|
|
65
|
+
key = SPLITTER + i;
|
|
66
|
+
if (ref[key] === value) return key;
|
|
67
|
+
}
|
|
68
|
+
key = SPLITTER + ref[SPLITTER]++;
|
|
69
|
+
ref[key] = value;
|
|
70
|
+
return key;
|
|
71
|
+
}
|
|
72
|
+
function isRefToken(s) {
|
|
73
|
+
if (s.length < 2 || s[0] !== SPLITTER) return false;
|
|
74
|
+
for (let i = 1; i < s.length; i++) {
|
|
75
|
+
const c = s.charCodeAt(i);
|
|
76
|
+
if (c < "0".charCodeAt(0) || c > "9".charCodeAt(0)) return false;
|
|
77
|
+
}
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
33
80
|
|
|
34
81
|
// src/utils.ts
|
|
35
82
|
function isPlainObject(value) {
|
|
36
83
|
if (typeof value !== "object" || value === null) return false;
|
|
37
84
|
const proto = Object.getPrototypeOf(value);
|
|
38
|
-
|
|
39
|
-
return proto === Object.prototype || proto === null;
|
|
85
|
+
return proto === null || proto === Object.prototype;
|
|
40
86
|
}
|
|
41
87
|
function isPrimitiveOrFunc(value) {
|
|
42
88
|
return !value || typeof value !== "object" && typeof value !== "function";
|
|
@@ -48,9 +94,6 @@ var _localCounter = 0;
|
|
|
48
94
|
function generateId(prefix) {
|
|
49
95
|
return (prefix || "lark_") + _localCounter++;
|
|
50
96
|
}
|
|
51
|
-
function syncCounter(val) {
|
|
52
|
-
_localCounter = val;
|
|
53
|
-
}
|
|
54
97
|
function noop() {
|
|
55
98
|
}
|
|
56
99
|
function hasOwnProperty(owner, prop) {
|
|
@@ -105,14 +148,6 @@ function setData(newData, oldData, changedKeys2, excludes) {
|
|
|
105
148
|
}
|
|
106
149
|
return changed;
|
|
107
150
|
}
|
|
108
|
-
function isRefToken(s) {
|
|
109
|
-
if (s.length < 2 || s[0] !== SPLITTER) return false;
|
|
110
|
-
for (let i = 1; i < s.length; i++) {
|
|
111
|
-
const c = s.charCodeAt(i);
|
|
112
|
-
if (c < 48 || c > 57) return false;
|
|
113
|
-
}
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
151
|
function translateData(data, value) {
|
|
117
152
|
if (isPrimitive(value)) {
|
|
118
153
|
const prop = String(value);
|
|
@@ -141,11 +176,11 @@ function getById(id) {
|
|
|
141
176
|
function getAttribute(element, attr) {
|
|
142
177
|
return Element.prototype.getAttribute.call(element, attr) ?? "";
|
|
143
178
|
}
|
|
144
|
-
function ensureElementId(element) {
|
|
179
|
+
function ensureElementId(element, prefix) {
|
|
145
180
|
const id = element.getAttribute("id");
|
|
146
181
|
if (id) return id;
|
|
147
182
|
element.autoId = 1;
|
|
148
|
-
const newId = generateId();
|
|
183
|
+
const newId = generateId(prefix);
|
|
149
184
|
element.id = newId;
|
|
150
185
|
return newId;
|
|
151
186
|
}
|
|
@@ -175,11 +210,6 @@ function parseUri(uri) {
|
|
|
175
210
|
});
|
|
176
211
|
return { path: actualPath, params };
|
|
177
212
|
}
|
|
178
|
-
var IS_URL_PARAMS = {
|
|
179
|
-
test(s) {
|
|
180
|
-
return /(?!^)=|&/.test(s);
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
213
|
function toUri(path, params, keepEmpty) {
|
|
184
214
|
const pairs = [];
|
|
185
215
|
let hasParams = false;
|
|
@@ -207,7 +237,7 @@ function toMap(list, key) {
|
|
|
207
237
|
return map;
|
|
208
238
|
}
|
|
209
239
|
function now() {
|
|
210
|
-
return Date.now
|
|
240
|
+
return Date.now();
|
|
211
241
|
}
|
|
212
242
|
|
|
213
243
|
// src/apply-style.ts
|
|
@@ -846,14 +876,12 @@ function getChanged(oldLoc, newLoc) {
|
|
|
846
876
|
setDiff("path", oldLoc["path"], newLoc["path"]);
|
|
847
877
|
if (changedParams["path"]) {
|
|
848
878
|
result["path"] = changedParams["path"];
|
|
849
|
-
hasChanged = true;
|
|
850
879
|
result.changed = true;
|
|
851
880
|
}
|
|
852
881
|
const viewKey = "view";
|
|
853
882
|
setDiff(viewKey, oldLoc.view, newLoc.view);
|
|
854
883
|
if (changedParams[viewKey]) {
|
|
855
884
|
result.view = changedParams[viewKey];
|
|
856
|
-
hasChanged = true;
|
|
857
885
|
result.changed = true;
|
|
858
886
|
}
|
|
859
887
|
const finalResult = {
|
|
@@ -1373,7 +1401,7 @@ var EventDelegator = {
|
|
|
1373
1401
|
}
|
|
1374
1402
|
};
|
|
1375
1403
|
|
|
1376
|
-
// src/
|
|
1404
|
+
// src/dom.ts
|
|
1377
1405
|
var wrapMeta = {
|
|
1378
1406
|
option: [1, "<select multiple>"],
|
|
1379
1407
|
thead: [1, "<table>"],
|
|
@@ -1393,12 +1421,12 @@ var VDoc = document.implementation.createHTMLDocument("");
|
|
|
1393
1421
|
var VBase = VDoc.createElement("base");
|
|
1394
1422
|
VBase.href = document.location.href;
|
|
1395
1423
|
VDoc.head.appendChild(VBase);
|
|
1396
|
-
var
|
|
1424
|
+
var DomSpecials = {
|
|
1397
1425
|
INPUT: ["value", "checked"],
|
|
1398
1426
|
TEXTAREA: ["value"],
|
|
1399
1427
|
OPTION: ["selected"]
|
|
1400
1428
|
};
|
|
1401
|
-
function
|
|
1429
|
+
function domUnmountFrames(frame, node) {
|
|
1402
1430
|
if (!(node instanceof Element)) return;
|
|
1403
1431
|
const id = node.getAttribute("id");
|
|
1404
1432
|
if (!id) return;
|
|
@@ -1407,7 +1435,7 @@ function vdomUnmountFrames(frame, node) {
|
|
|
1407
1435
|
frame.unmountFrame(id);
|
|
1408
1436
|
}
|
|
1409
1437
|
}
|
|
1410
|
-
function
|
|
1438
|
+
function domGetNode(html, refNode) {
|
|
1411
1439
|
const tmp = VDoc.createElement("div");
|
|
1412
1440
|
const ns = refNode.namespaceURI;
|
|
1413
1441
|
let tag;
|
|
@@ -1428,16 +1456,13 @@ function vdomGetNode(html, refNode) {
|
|
|
1428
1456
|
}
|
|
1429
1457
|
return tmp;
|
|
1430
1458
|
}
|
|
1431
|
-
function
|
|
1459
|
+
function domGetCompareKey(node) {
|
|
1432
1460
|
if (node.nodeType !== 1) return void 0;
|
|
1433
1461
|
const el = node;
|
|
1434
1462
|
if (el.compareKeyCached) {
|
|
1435
1463
|
return el.cachedCompareKey;
|
|
1436
1464
|
}
|
|
1437
1465
|
let key = el.autoId ? "" : el.getAttribute("id") || void 0;
|
|
1438
|
-
if (!key) {
|
|
1439
|
-
key = el.getAttribute(LarkInnerKeys.DIFF_KEY) || void 0;
|
|
1440
|
-
}
|
|
1441
1466
|
if (!key) {
|
|
1442
1467
|
const larkView = el.getAttribute(LARK_VIEW);
|
|
1443
1468
|
if (larkView) {
|
|
@@ -1448,8 +1473,8 @@ function vdomGetCompareKey(node) {
|
|
|
1448
1473
|
el.cachedCompareKey = key || "";
|
|
1449
1474
|
return key;
|
|
1450
1475
|
}
|
|
1451
|
-
function
|
|
1452
|
-
const specials =
|
|
1476
|
+
function domSpecialDiff(oldNode, newNode) {
|
|
1477
|
+
const specials = DomSpecials[oldNode.nodeName];
|
|
1453
1478
|
if (!specials) return 0;
|
|
1454
1479
|
const oldEl = oldNode;
|
|
1455
1480
|
const newEl = newNode;
|
|
@@ -1462,7 +1487,7 @@ function vdomSpecialDiff(oldNode, newNode) {
|
|
|
1462
1487
|
}
|
|
1463
1488
|
return result;
|
|
1464
1489
|
}
|
|
1465
|
-
function
|
|
1490
|
+
function domSetAttributes(oldNode, newNode, ref, keepId) {
|
|
1466
1491
|
const oldEl = oldNode;
|
|
1467
1492
|
Reflect.deleteProperty(oldEl, "compareKeyCached");
|
|
1468
1493
|
const oldAttrs = oldNode.attributes;
|
|
@@ -1494,7 +1519,7 @@ function vdomSetAttributes(oldNode, newNode, ref, keepId) {
|
|
|
1494
1519
|
}
|
|
1495
1520
|
}
|
|
1496
1521
|
}
|
|
1497
|
-
function
|
|
1522
|
+
function domSetChildNodes(oldParent, newParent, ref, frame, keys_) {
|
|
1498
1523
|
let oldNode = oldParent.lastChild;
|
|
1499
1524
|
let newNode = newParent.firstChild;
|
|
1500
1525
|
let extra = 0;
|
|
@@ -1502,7 +1527,7 @@ function vdomSetChildNodes(oldParent, newParent, ref, frame, keys_) {
|
|
|
1502
1527
|
const newKeyedNodes = /* @__PURE__ */ new Map();
|
|
1503
1528
|
while (oldNode) {
|
|
1504
1529
|
extra++;
|
|
1505
|
-
const nodeKey =
|
|
1530
|
+
const nodeKey = domGetCompareKey(oldNode);
|
|
1506
1531
|
if (nodeKey) {
|
|
1507
1532
|
let bucket = keyedNodes.get(nodeKey);
|
|
1508
1533
|
if (!bucket) {
|
|
@@ -1514,7 +1539,7 @@ function vdomSetChildNodes(oldParent, newParent, ref, frame, keys_) {
|
|
|
1514
1539
|
oldNode = oldNode.previousSibling;
|
|
1515
1540
|
}
|
|
1516
1541
|
while (newNode) {
|
|
1517
|
-
const nodeKey =
|
|
1542
|
+
const nodeKey = domGetCompareKey(newNode);
|
|
1518
1543
|
if (nodeKey) {
|
|
1519
1544
|
newKeyedNodes.set(nodeKey, (newKeyedNodes.get(nodeKey) ?? 0) + 1);
|
|
1520
1545
|
}
|
|
@@ -1526,7 +1551,7 @@ function vdomSetChildNodes(oldParent, newParent, ref, frame, keys_) {
|
|
|
1526
1551
|
extra--;
|
|
1527
1552
|
const tempNew = newNode;
|
|
1528
1553
|
newNode = newNode.nextSibling;
|
|
1529
|
-
const nodeKey =
|
|
1554
|
+
const nodeKey = domGetCompareKey(tempNew);
|
|
1530
1555
|
let foundNode = nodeKey ? keyedNodes.get(nodeKey) : void 0;
|
|
1531
1556
|
if (foundNode && (foundNode = foundNode.slice()) && foundNode.length) {
|
|
1532
1557
|
const matched = foundNode.pop();
|
|
@@ -1541,17 +1566,17 @@ function vdomSetChildNodes(oldParent, newParent, ref, frame, keys_) {
|
|
|
1541
1566
|
const c = newKeyedNodes.get(nodeKey);
|
|
1542
1567
|
if (c) newKeyedNodes.set(nodeKey, c - 1);
|
|
1543
1568
|
}
|
|
1544
|
-
|
|
1569
|
+
domSetNode(matched, tempNew, oldParent, ref, frame, keys_);
|
|
1545
1570
|
} else if (oldNode) {
|
|
1546
1571
|
const tempOld2 = oldNode;
|
|
1547
|
-
const oldKey =
|
|
1572
|
+
const oldKey = domGetCompareKey(tempOld2);
|
|
1548
1573
|
if (oldKey && keyedNodes.has(oldKey) && newKeyedNodes.get(oldKey)) {
|
|
1549
1574
|
extra++;
|
|
1550
1575
|
ref.hasChanged = 1;
|
|
1551
1576
|
ref.domOps.push([8, oldParent, tempNew, tempOld2]);
|
|
1552
1577
|
} else {
|
|
1553
1578
|
oldNode = oldNode.nextSibling;
|
|
1554
|
-
|
|
1579
|
+
domSetNode(tempOld2, tempNew, oldParent, ref, frame, keys_);
|
|
1555
1580
|
}
|
|
1556
1581
|
} else {
|
|
1557
1582
|
ref.hasChanged = 1;
|
|
@@ -1561,29 +1586,23 @@ function vdomSetChildNodes(oldParent, newParent, ref, frame, keys_) {
|
|
|
1561
1586
|
let tempOld = oldParent.lastChild;
|
|
1562
1587
|
while (extra-- > 0) {
|
|
1563
1588
|
if (tempOld) {
|
|
1564
|
-
|
|
1589
|
+
domUnmountFrames(frame, tempOld);
|
|
1565
1590
|
ref.domOps.push([2, oldParent, tempOld]);
|
|
1566
1591
|
tempOld = tempOld.previousSibling;
|
|
1567
1592
|
ref.hasChanged = 1;
|
|
1568
1593
|
}
|
|
1569
1594
|
}
|
|
1570
1595
|
}
|
|
1571
|
-
function
|
|
1596
|
+
function domSetNode(oldNode, newNode, oldParent, ref, frame, keys_) {
|
|
1572
1597
|
const oldAsEl = oldNode instanceof Element ? oldNode : null;
|
|
1573
1598
|
const newAsEl = newNode instanceof Element ? newNode : null;
|
|
1574
|
-
const hasViewKey = !!oldAsEl?.hasAttribute(LarkInnerKeys.VIEW_KEY);
|
|
1575
1599
|
const equalAsNodes = oldAsEl !== null && newAsEl !== null && oldAsEl.isEqualNode && oldAsEl.isEqualNode(newAsEl);
|
|
1576
|
-
if (
|
|
1600
|
+
if (domSpecialDiff(oldNode, newNode) || !equalAsNodes) {
|
|
1577
1601
|
if (oldNode.nodeType === newNode.nodeType && oldNode.nodeName === newNode.nodeName) {
|
|
1578
1602
|
if (oldAsEl !== null && newAsEl !== null) {
|
|
1579
1603
|
const oldEl = oldAsEl;
|
|
1580
1604
|
const newEl = newAsEl;
|
|
1581
|
-
const staticKey = newEl.getAttribute(LarkInnerKeys.DIFF_KEY);
|
|
1582
|
-
if (staticKey && staticKey === oldEl.getAttribute(LarkInnerKeys.DIFF_KEY)) {
|
|
1583
|
-
return;
|
|
1584
|
-
}
|
|
1585
1605
|
const newLarkView = newEl.getAttribute(LARK_VIEW);
|
|
1586
|
-
const updateAttribute = !newEl.getAttribute(LarkInnerKeys.ATTR_KEY) || newEl.getAttribute(LarkInnerKeys.ATTR_KEY) !== oldEl.getAttribute(LarkInnerKeys.ATTR_KEY);
|
|
1587
1606
|
let updateChildren = true;
|
|
1588
1607
|
if (newLarkView) {
|
|
1589
1608
|
const oldFrameId = oldEl.getAttribute("id") || "";
|
|
@@ -1594,11 +1613,9 @@ function vdomSetNode(oldNode, newNode, oldParent, ref, frame, keys_) {
|
|
|
1594
1613
|
updateChildren = false;
|
|
1595
1614
|
}
|
|
1596
1615
|
}
|
|
1597
|
-
|
|
1598
|
-
vdomSetAttributes(oldEl, newEl, ref, !!newLarkView);
|
|
1599
|
-
}
|
|
1616
|
+
domSetAttributes(oldEl, newEl, ref, !!newLarkView);
|
|
1600
1617
|
if (updateChildren) {
|
|
1601
|
-
|
|
1618
|
+
domSetChildNodes(oldEl, newEl, ref, frame, keys_);
|
|
1602
1619
|
}
|
|
1603
1620
|
} else if (oldNode.nodeValue !== newNode.nodeValue) {
|
|
1604
1621
|
ref.hasChanged = 1;
|
|
@@ -1606,12 +1623,12 @@ function vdomSetNode(oldNode, newNode, oldParent, ref, frame, keys_) {
|
|
|
1606
1623
|
}
|
|
1607
1624
|
} else {
|
|
1608
1625
|
ref.hasChanged = 1;
|
|
1609
|
-
|
|
1626
|
+
domUnmountFrames(frame, oldNode);
|
|
1610
1627
|
ref.domOps.push([4, oldParent, newNode, oldNode]);
|
|
1611
1628
|
}
|
|
1612
1629
|
}
|
|
1613
1630
|
}
|
|
1614
|
-
function
|
|
1631
|
+
function createDomRef() {
|
|
1615
1632
|
return {
|
|
1616
1633
|
idUpdates: [],
|
|
1617
1634
|
views: [],
|
|
@@ -1619,7 +1636,7 @@ function createVdomRef() {
|
|
|
1619
1636
|
hasChanged: 0
|
|
1620
1637
|
};
|
|
1621
1638
|
}
|
|
1622
|
-
function
|
|
1639
|
+
function applyDomOps(ops) {
|
|
1623
1640
|
for (const op of ops) {
|
|
1624
1641
|
switch (op[0]) {
|
|
1625
1642
|
case 1:
|
|
@@ -1646,57 +1663,8 @@ function applyIdUpdates(updates) {
|
|
|
1646
1663
|
}
|
|
1647
1664
|
}
|
|
1648
1665
|
}
|
|
1649
|
-
var EncoderMap = {
|
|
1650
|
-
"&": "amp",
|
|
1651
|
-
"<": "lt",
|
|
1652
|
-
">": "gt",
|
|
1653
|
-
'"': "#34",
|
|
1654
|
-
"'": "#39",
|
|
1655
|
-
"`": "#96"
|
|
1656
|
-
};
|
|
1657
|
-
var ENCODE_REGEXP = /[&<>"'`]/g;
|
|
1658
|
-
function encodeHTML(v) {
|
|
1659
|
-
return String(v == null ? "" : v).replace(
|
|
1660
|
-
ENCODE_REGEXP,
|
|
1661
|
-
(m) => "&" + EncoderMap[m] + ";"
|
|
1662
|
-
);
|
|
1663
|
-
}
|
|
1664
|
-
function encodeSafe(v) {
|
|
1665
|
-
return String(v == null ? "" : v);
|
|
1666
|
-
}
|
|
1667
|
-
var URIMap = {
|
|
1668
|
-
"!": "%21",
|
|
1669
|
-
"'": "%27",
|
|
1670
|
-
"(": "%28",
|
|
1671
|
-
")": "%29",
|
|
1672
|
-
"*": "%2A"
|
|
1673
|
-
};
|
|
1674
|
-
var URI_ENCODE_REGEXP = /[!')(*]/g;
|
|
1675
|
-
function encodeURIExtra(v) {
|
|
1676
|
-
return encodeURIComponent(encodeSafe(v)).replace(
|
|
1677
|
-
URI_ENCODE_REGEXP,
|
|
1678
|
-
(m) => URIMap[m]
|
|
1679
|
-
);
|
|
1680
|
-
}
|
|
1681
|
-
var QUOTE_REGEXP = /['"\\]/g;
|
|
1682
|
-
function encodeQ(v) {
|
|
1683
|
-
return encodeSafe(v).replace(QUOTE_REGEXP, "\\$&");
|
|
1684
|
-
}
|
|
1685
1666
|
|
|
1686
1667
|
// src/updater.ts
|
|
1687
|
-
function updaterRef(refDataIn, value, key) {
|
|
1688
|
-
const refData = refDataIn;
|
|
1689
|
-
const counter = refData[SPLITTER];
|
|
1690
|
-
for (let i = counter; --i; ) {
|
|
1691
|
-
key = SPLITTER + i;
|
|
1692
|
-
if (refData[key] === value) {
|
|
1693
|
-
return key;
|
|
1694
|
-
}
|
|
1695
|
-
}
|
|
1696
|
-
key = SPLITTER + refData[SPLITTER]++;
|
|
1697
|
-
refData[key] = value;
|
|
1698
|
-
return key;
|
|
1699
|
-
}
|
|
1700
1668
|
var Updater = class {
|
|
1701
1669
|
/** View ID (same as owner frame ID) */
|
|
1702
1670
|
viewId;
|
|
@@ -1758,11 +1726,11 @@ var Updater = class {
|
|
|
1758
1726
|
return this;
|
|
1759
1727
|
}
|
|
1760
1728
|
/**
|
|
1761
|
-
* Detect changes and trigger
|
|
1729
|
+
* Detect changes and trigger DOM re-render.
|
|
1762
1730
|
*
|
|
1763
1731
|
* The core rendering pipeline:
|
|
1764
1732
|
* 1. Set data if provided
|
|
1765
|
-
* 2. If changed, run
|
|
1733
|
+
* 2. If changed, run DOM diff (template → new DOM → diff against old DOM)
|
|
1766
1734
|
* 3. Apply DOM operations
|
|
1767
1735
|
* 4. Apply ID updates
|
|
1768
1736
|
* 5. Call endUpdate on views that need re-rendering
|
|
@@ -1804,14 +1772,14 @@ var Updater = class {
|
|
|
1804
1772
|
encodeHTML,
|
|
1805
1773
|
encodeSafe,
|
|
1806
1774
|
encodeURIExtra,
|
|
1807
|
-
|
|
1775
|
+
refFn,
|
|
1808
1776
|
encodeQ
|
|
1809
1777
|
);
|
|
1810
|
-
const newDom =
|
|
1811
|
-
const ref =
|
|
1812
|
-
|
|
1778
|
+
const newDom = domGetNode(html, node);
|
|
1779
|
+
const ref = createDomRef();
|
|
1780
|
+
domSetChildNodes(node, newDom, ref, frame, keys2);
|
|
1813
1781
|
applyIdUpdates(ref.idUpdates);
|
|
1814
|
-
|
|
1782
|
+
applyDomOps(ref.domOps);
|
|
1815
1783
|
for (const v of ref.views) {
|
|
1816
1784
|
if (v.render) {
|
|
1817
1785
|
funcWithTry(v.render, [], v, noop);
|
|
@@ -1852,17 +1820,12 @@ var Updater = class {
|
|
|
1852
1820
|
* Translate a refData reference back to its original value.
|
|
1853
1821
|
*
|
|
1854
1822
|
* The ref protocol is `SPLITTER` + ascii decimal digits — the exact format
|
|
1855
|
-
* emitted by `
|
|
1823
|
+
* emitted by `refFn`. We require that exact shape so a user-supplied
|
|
1856
1824
|
* string that merely begins with SPLITTER is never accidentally resolved
|
|
1857
1825
|
* (or mishandled as a "missing ref").
|
|
1858
1826
|
*/
|
|
1859
1827
|
translate(data) {
|
|
1860
|
-
if (typeof data !== "string") return data;
|
|
1861
|
-
if (data.length < 2 || data[0] !== SPLITTER) return data;
|
|
1862
|
-
for (let i = 1; i < data.length; i++) {
|
|
1863
|
-
const c = data.charCodeAt(i);
|
|
1864
|
-
if (c < 48 || c > 57) return data;
|
|
1865
|
-
}
|
|
1828
|
+
if (typeof data !== "string" || !isRefToken(data)) return data;
|
|
1866
1829
|
return hasOwnProperty(this.refData, data) ? this.refData[data] : data;
|
|
1867
1830
|
}
|
|
1868
1831
|
/**
|
|
@@ -1929,8 +1892,6 @@ var View = class _View {
|
|
|
1929
1892
|
observedStateKeys;
|
|
1930
1893
|
/** Resource map */
|
|
1931
1894
|
resources = {};
|
|
1932
|
-
/** Assign method reference */
|
|
1933
|
-
assignMethod;
|
|
1934
1895
|
/** Whether endUpdate pending */
|
|
1935
1896
|
endUpdatePending;
|
|
1936
1897
|
/** Internal event storage */
|
|
@@ -2007,7 +1968,7 @@ var View = class _View {
|
|
|
2007
1968
|
*/
|
|
2008
1969
|
beginUpdate(id) {
|
|
2009
1970
|
if (this.signature > 0 && this.endUpdatePending !== void 0) {
|
|
2010
|
-
this.ownerFrame.unmountZone(id
|
|
1971
|
+
this.ownerFrame.unmountZone(id);
|
|
2011
1972
|
}
|
|
2012
1973
|
}
|
|
2013
1974
|
/**
|
|
@@ -2026,7 +1987,7 @@ var View = class _View {
|
|
|
2026
1987
|
this.rendered = true;
|
|
2027
1988
|
}
|
|
2028
1989
|
const ownerFrame = this.ownerFrame;
|
|
2029
|
-
ownerFrame.mountZone(updateId
|
|
1990
|
+
ownerFrame.mountZone(updateId);
|
|
2030
1991
|
if (!flag) {
|
|
2031
1992
|
setTimeout(
|
|
2032
1993
|
this.wrapAsync(() => {
|
|
@@ -2251,7 +2212,6 @@ var View = class _View {
|
|
|
2251
2212
|
proto["$evtObjMap"] = eventsObject;
|
|
2252
2213
|
proto["$globalEvtList"] = eventsList;
|
|
2253
2214
|
proto["$selMap"] = selectorObject;
|
|
2254
|
-
proto["$assignFn"] = proto["assign"];
|
|
2255
2215
|
return makes;
|
|
2256
2216
|
}
|
|
2257
2217
|
/**
|
|
@@ -2765,7 +2725,7 @@ var Frame = class _Frame extends EventEmitter {
|
|
|
2765
2725
|
/**
|
|
2766
2726
|
* Unmount a child frame.
|
|
2767
2727
|
*/
|
|
2768
|
-
unmountFrame(id
|
|
2728
|
+
unmountFrame(id) {
|
|
2769
2729
|
const targetId = id ? this.childrenMap[id] : this.id;
|
|
2770
2730
|
const frame = frameRegistry.get(targetId);
|
|
2771
2731
|
if (!frame) return;
|
|
@@ -2787,7 +2747,7 @@ var Frame = class _Frame extends EventEmitter {
|
|
|
2787
2747
|
/**
|
|
2788
2748
|
* Mount all views in a zone.
|
|
2789
2749
|
*/
|
|
2790
|
-
mountZone(zoneId
|
|
2750
|
+
mountZone(zoneId) {
|
|
2791
2751
|
const targetZone = zoneId || this.id;
|
|
2792
2752
|
this.holdFireCreated = 1;
|
|
2793
2753
|
const rootEl = document.getElementById(targetZone);
|
|
@@ -2797,7 +2757,7 @@ var Frame = class _Frame extends EventEmitter {
|
|
|
2797
2757
|
viewElements.forEach((el) => {
|
|
2798
2758
|
if (!(el instanceof HTMLElement)) return;
|
|
2799
2759
|
if (htmlElIsBound(el)) return;
|
|
2800
|
-
const elId =
|
|
2760
|
+
const elId = ensureElementId(el, "frame_");
|
|
2801
2761
|
el.frameBound = 1;
|
|
2802
2762
|
const viewPath = getAttribute(el, LARK_VIEW);
|
|
2803
2763
|
frames.push([elId, viewPath]);
|
|
@@ -2811,7 +2771,7 @@ var Frame = class _Frame extends EventEmitter {
|
|
|
2811
2771
|
/**
|
|
2812
2772
|
* Unmount all views in a zone.
|
|
2813
2773
|
*/
|
|
2814
|
-
unmountZone(zoneId
|
|
2774
|
+
unmountZone(zoneId) {
|
|
2815
2775
|
for (const childId in this.childrenMap) {
|
|
2816
2776
|
if (hasOwnProperty(this.childrenMap, childId)) {
|
|
2817
2777
|
if (!zoneId || childId !== zoneId) {
|
|
@@ -2940,17 +2900,6 @@ var Frame = class _Frame extends EventEmitter {
|
|
|
2940
2900
|
}
|
|
2941
2901
|
return rootFrame;
|
|
2942
2902
|
}
|
|
2943
|
-
/**
|
|
2944
|
-
* @deprecated Use `Frame.getRoot()` for read-only access or
|
|
2945
|
-
* `Frame.createRoot(id)` to create the root explicitly. The single-method
|
|
2946
|
-
* `root()` blurred the distinction and was a common source of bugs in
|
|
2947
|
-
* Micro-Frontend hosts.
|
|
2948
|
-
*
|
|
2949
|
-
* Kept for backward compatibility — behavior unchanged.
|
|
2950
|
-
*/
|
|
2951
|
-
static root(rootId) {
|
|
2952
|
-
return _Frame.createRoot(rootId);
|
|
2953
|
-
}
|
|
2954
2903
|
/** Bind event listener (static) */
|
|
2955
2904
|
static on(event, handler) {
|
|
2956
2905
|
staticEmitter.on(event, handler);
|
|
@@ -2969,14 +2918,6 @@ var Frame = class _Frame extends EventEmitter {
|
|
|
2969
2918
|
function htmlElIsBound(element) {
|
|
2970
2919
|
return !!element.frameBound;
|
|
2971
2920
|
}
|
|
2972
|
-
function ensureElementId2(element) {
|
|
2973
|
-
const id = element.getAttribute("id");
|
|
2974
|
-
if (id) return id;
|
|
2975
|
-
element.autoId = 1;
|
|
2976
|
-
const newId = generateId("frame_");
|
|
2977
|
-
element.id = newId;
|
|
2978
|
-
return newId;
|
|
2979
|
-
}
|
|
2980
2921
|
function removeFrame(id, wasCreated) {
|
|
2981
2922
|
const frameInstance = frameRegistry.get(id);
|
|
2982
2923
|
if (!frameInstance) return;
|
|
@@ -4157,18 +4098,14 @@ function create(name, creator) {
|
|
|
4157
4098
|
changedKeys2.add(key);
|
|
4158
4099
|
}
|
|
4159
4100
|
}
|
|
4160
|
-
let recomputed = false;
|
|
4161
4101
|
for (const [key, def] of computedDefs) {
|
|
4162
4102
|
if (def.deps.some((dep) => changedKeys2.has(dep))) {
|
|
4163
4103
|
const newVal = def.fn();
|
|
4164
4104
|
if (!Object.is(state[key], newVal)) {
|
|
4165
4105
|
state[key] = newVal;
|
|
4166
|
-
recomputed = true;
|
|
4167
4106
|
}
|
|
4168
4107
|
}
|
|
4169
4108
|
}
|
|
4170
|
-
if (recomputed) {
|
|
4171
|
-
}
|
|
4172
4109
|
};
|
|
4173
4110
|
const subscribe = (listener) => {
|
|
4174
4111
|
listeners.add(listener);
|
|
@@ -4233,7 +4170,6 @@ function bindStore(view, store, selector) {
|
|
|
4233
4170
|
view.on("destroy", off);
|
|
4234
4171
|
return off;
|
|
4235
4172
|
}
|
|
4236
|
-
var defineStore = create;
|
|
4237
4173
|
export {
|
|
4238
4174
|
CALL_BREAK_TIME,
|
|
4239
4175
|
Cache,
|
|
@@ -4255,59 +4191,24 @@ export {
|
|
|
4255
4191
|
Updater,
|
|
4256
4192
|
VIEW_EVENT_METHOD_REGEXP,
|
|
4257
4193
|
View,
|
|
4258
|
-
applyIdUpdates,
|
|
4259
4194
|
applyStyle,
|
|
4260
|
-
applyVdomOps,
|
|
4261
|
-
assign,
|
|
4262
4195
|
bindStore,
|
|
4263
4196
|
computed,
|
|
4264
4197
|
create,
|
|
4265
|
-
createVdomRef,
|
|
4266
|
-
defineStore,
|
|
4267
4198
|
defineView,
|
|
4268
|
-
encodeHTML,
|
|
4269
|
-
encodeQ,
|
|
4270
|
-
encodeSafe,
|
|
4271
|
-
encodeURIExtra,
|
|
4272
|
-
ensureElementId,
|
|
4273
4199
|
config as frameworkConfig,
|
|
4274
|
-
funcWithTry,
|
|
4275
|
-
generateId,
|
|
4276
|
-
getAttribute,
|
|
4277
|
-
getById,
|
|
4278
4200
|
getRouteMode,
|
|
4279
|
-
hasOwnProperty,
|
|
4280
4201
|
installFrameVisualizerBridge,
|
|
4281
4202
|
invalidateViewClass,
|
|
4282
|
-
isPlainObject,
|
|
4283
|
-
isPrimitive,
|
|
4284
|
-
isPrimitiveOrFunc,
|
|
4285
|
-
keys,
|
|
4286
4203
|
mark,
|
|
4287
4204
|
markBooted,
|
|
4288
4205
|
markRouterBooted,
|
|
4289
4206
|
nextCounter,
|
|
4290
|
-
nodeInside,
|
|
4291
|
-
noop,
|
|
4292
|
-
now,
|
|
4293
|
-
parseUri,
|
|
4294
4207
|
registerViewClass,
|
|
4295
4208
|
resetProjectsMap,
|
|
4296
4209
|
safeguard,
|
|
4297
4210
|
serializeFrameTree,
|
|
4298
|
-
setData,
|
|
4299
|
-
syncCounter,
|
|
4300
|
-
toMap,
|
|
4301
|
-
toUri,
|
|
4302
|
-
translateData,
|
|
4303
4211
|
unmark,
|
|
4304
4212
|
use,
|
|
4305
|
-
useUrlState
|
|
4306
|
-
vdomGetCompareKey,
|
|
4307
|
-
vdomGetNode,
|
|
4308
|
-
vdomSetAttributes,
|
|
4309
|
-
vdomSetChildNodes,
|
|
4310
|
-
vdomSetNode,
|
|
4311
|
-
vdomSpecialDiff,
|
|
4312
|
-
vdomUnmountFrames
|
|
4213
|
+
useUrlState
|
|
4313
4214
|
};
|