@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.cjs
CHANGED
|
@@ -40,65 +40,30 @@ __export(index_exports, {
|
|
|
40
40
|
Updater: () => Updater,
|
|
41
41
|
VIEW_EVENT_METHOD_REGEXP: () => VIEW_EVENT_METHOD_REGEXP,
|
|
42
42
|
View: () => View,
|
|
43
|
-
applyIdUpdates: () => applyIdUpdates,
|
|
44
43
|
applyStyle: () => applyStyle,
|
|
45
|
-
applyVdomOps: () => applyVdomOps,
|
|
46
|
-
assign: () => assign,
|
|
47
44
|
bindStore: () => bindStore,
|
|
48
45
|
computed: () => computed,
|
|
49
46
|
create: () => create,
|
|
50
|
-
createVdomRef: () => createVdomRef,
|
|
51
|
-
defineStore: () => defineStore,
|
|
52
47
|
defineView: () => defineView,
|
|
53
|
-
encodeHTML: () => encodeHTML,
|
|
54
|
-
encodeQ: () => encodeQ,
|
|
55
|
-
encodeSafe: () => encodeSafe,
|
|
56
|
-
encodeURIExtra: () => encodeURIExtra,
|
|
57
|
-
ensureElementId: () => ensureElementId,
|
|
58
48
|
frameworkConfig: () => config,
|
|
59
|
-
funcWithTry: () => funcWithTry,
|
|
60
|
-
generateId: () => generateId,
|
|
61
|
-
getAttribute: () => getAttribute,
|
|
62
|
-
getById: () => getById,
|
|
63
49
|
getRouteMode: () => getRouteMode,
|
|
64
|
-
hasOwnProperty: () => hasOwnProperty,
|
|
65
50
|
installFrameVisualizerBridge: () => installFrameVisualizerBridge,
|
|
66
51
|
invalidateViewClass: () => invalidateViewClass,
|
|
67
|
-
isPlainObject: () => isPlainObject,
|
|
68
|
-
isPrimitive: () => isPrimitive,
|
|
69
|
-
isPrimitiveOrFunc: () => isPrimitiveOrFunc,
|
|
70
|
-
keys: () => keys,
|
|
71
52
|
mark: () => mark,
|
|
72
53
|
markBooted: () => markBooted,
|
|
73
54
|
markRouterBooted: () => markRouterBooted,
|
|
74
55
|
nextCounter: () => nextCounter,
|
|
75
|
-
nodeInside: () => nodeInside,
|
|
76
|
-
noop: () => noop,
|
|
77
|
-
now: () => now,
|
|
78
|
-
parseUri: () => parseUri,
|
|
79
56
|
registerViewClass: () => registerViewClass,
|
|
80
57
|
resetProjectsMap: () => resetProjectsMap,
|
|
81
58
|
safeguard: () => safeguard,
|
|
82
59
|
serializeFrameTree: () => serializeFrameTree,
|
|
83
|
-
setData: () => setData,
|
|
84
|
-
syncCounter: () => syncCounter,
|
|
85
|
-
toMap: () => toMap,
|
|
86
|
-
toUri: () => toUri,
|
|
87
|
-
translateData: () => translateData,
|
|
88
60
|
unmark: () => unmark,
|
|
89
61
|
use: () => use,
|
|
90
|
-
useUrlState: () => useUrlState
|
|
91
|
-
vdomGetCompareKey: () => vdomGetCompareKey,
|
|
92
|
-
vdomGetNode: () => vdomGetNode,
|
|
93
|
-
vdomSetAttributes: () => vdomSetAttributes,
|
|
94
|
-
vdomSetChildNodes: () => vdomSetChildNodes,
|
|
95
|
-
vdomSetNode: () => vdomSetNode,
|
|
96
|
-
vdomSpecialDiff: () => vdomSpecialDiff,
|
|
97
|
-
vdomUnmountFrames: () => vdomUnmountFrames
|
|
62
|
+
useUrlState: () => useUrlState
|
|
98
63
|
});
|
|
99
64
|
module.exports = __toCommonJS(index_exports);
|
|
100
65
|
|
|
101
|
-
// src/
|
|
66
|
+
// src/common.ts
|
|
102
67
|
var globalCounter = 0;
|
|
103
68
|
var SPLITTER = String.fromCharCode(30);
|
|
104
69
|
var RouterEvents = {
|
|
@@ -106,14 +71,6 @@ var RouterEvents = {
|
|
|
106
71
|
CHANGED: "changed",
|
|
107
72
|
PAGE_UNLOAD: "page_unload"
|
|
108
73
|
};
|
|
109
|
-
var LarkInnerKeys = {
|
|
110
|
-
/** Attribute name: ldk (static key for skipping VDOM diff) */
|
|
111
|
-
DIFF_KEY: "ldk",
|
|
112
|
-
/** Attribute name: lak (static attribute key) */
|
|
113
|
-
ATTR_KEY: "lak",
|
|
114
|
-
/** Attribute name: lvk (view key for assign) */
|
|
115
|
-
VIEW_KEY: "lvk"
|
|
116
|
-
};
|
|
117
74
|
var LARK_VIEW = "v-lark";
|
|
118
75
|
var EVENT_METHOD_REGEXP = new RegExp(
|
|
119
76
|
`(?:([\\w-]+)${SPLITTER})?([^(]+)\\(([\\s\\S]*?)?\\)`
|
|
@@ -122,6 +79,7 @@ var VIEW_EVENT_METHOD_REGEXP = /^(\$?)([\w]*)<(.*?)>(?:<([\w ,]*)>)?$/;
|
|
|
122
79
|
var URL_TRIM_HASH_REGEXP = /(?:^.*\/\/[^/]+|#.*$)/gi;
|
|
123
80
|
var URL_TRIM_QUERY_REGEXP = /^[^#]*#?!?/;
|
|
124
81
|
var URL_PARAM_REGEXP = /([^=&?/#]+)=?([^&#?]*)/g;
|
|
82
|
+
var IS_URL_PARAMS = /(?!^)=|&/;
|
|
125
83
|
var URL_QUERY_HASH_REGEXP = /[#?].*$/;
|
|
126
84
|
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
127
85
|
var MATH_NS = "http://www.w3.org/1998/Math/MathML";
|
|
@@ -130,13 +88,66 @@ var CALL_BREAK_TIME = 48;
|
|
|
130
88
|
function nextCounter() {
|
|
131
89
|
return ++globalCounter;
|
|
132
90
|
}
|
|
91
|
+
var HTML_ENT_MAP = {
|
|
92
|
+
"&": "amp",
|
|
93
|
+
"<": "lt",
|
|
94
|
+
">": "gt",
|
|
95
|
+
'"': "#34",
|
|
96
|
+
"'": "#39",
|
|
97
|
+
"`": "#96"
|
|
98
|
+
};
|
|
99
|
+
var HTML_ENT_REGEXP = /[&<>"'`]/g;
|
|
100
|
+
function encodeSafe(v) {
|
|
101
|
+
return String(v == null ? "" : v);
|
|
102
|
+
}
|
|
103
|
+
function encodeHTML(v) {
|
|
104
|
+
return String(v == null ? "" : v).replace(
|
|
105
|
+
HTML_ENT_REGEXP,
|
|
106
|
+
(m) => "&" + HTML_ENT_MAP[m] + ";"
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
var URI_ENT_MAP = {
|
|
110
|
+
"!": "%21",
|
|
111
|
+
"'": "%27",
|
|
112
|
+
"(": "%28",
|
|
113
|
+
")": "%29",
|
|
114
|
+
"*": "%2A"
|
|
115
|
+
};
|
|
116
|
+
var URI_ENT_REGEXP = /[!')(*]/g;
|
|
117
|
+
function encodeURIExtra(v) {
|
|
118
|
+
return encodeURIComponent(encodeSafe(v)).replace(
|
|
119
|
+
URI_ENT_REGEXP,
|
|
120
|
+
(m) => URI_ENT_MAP[m]
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
var QUOTE_ENT_REGEXP = /['"\\]/g;
|
|
124
|
+
function encodeQ(v) {
|
|
125
|
+
return encodeSafe(v).replace(QUOTE_ENT_REGEXP, "\\$&");
|
|
126
|
+
}
|
|
127
|
+
function refFn(ref, value, key) {
|
|
128
|
+
const counter = ref[SPLITTER];
|
|
129
|
+
for (let i = counter; --i; ) {
|
|
130
|
+
key = SPLITTER + i;
|
|
131
|
+
if (ref[key] === value) return key;
|
|
132
|
+
}
|
|
133
|
+
key = SPLITTER + ref[SPLITTER]++;
|
|
134
|
+
ref[key] = value;
|
|
135
|
+
return key;
|
|
136
|
+
}
|
|
137
|
+
function isRefToken(s) {
|
|
138
|
+
if (s.length < 2 || s[0] !== SPLITTER) return false;
|
|
139
|
+
for (let i = 1; i < s.length; i++) {
|
|
140
|
+
const c = s.charCodeAt(i);
|
|
141
|
+
if (c < "0".charCodeAt(0) || c > "9".charCodeAt(0)) return false;
|
|
142
|
+
}
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
133
145
|
|
|
134
146
|
// src/utils.ts
|
|
135
147
|
function isPlainObject(value) {
|
|
136
148
|
if (typeof value !== "object" || value === null) return false;
|
|
137
149
|
const proto = Object.getPrototypeOf(value);
|
|
138
|
-
|
|
139
|
-
return proto === Object.prototype || proto === null;
|
|
150
|
+
return proto === null || proto === Object.prototype;
|
|
140
151
|
}
|
|
141
152
|
function isPrimitiveOrFunc(value) {
|
|
142
153
|
return !value || typeof value !== "object" && typeof value !== "function";
|
|
@@ -148,9 +159,6 @@ var _localCounter = 0;
|
|
|
148
159
|
function generateId(prefix) {
|
|
149
160
|
return (prefix || "lark_") + _localCounter++;
|
|
150
161
|
}
|
|
151
|
-
function syncCounter(val) {
|
|
152
|
-
_localCounter = val;
|
|
153
|
-
}
|
|
154
162
|
function noop() {
|
|
155
163
|
}
|
|
156
164
|
function hasOwnProperty(owner, prop) {
|
|
@@ -205,14 +213,6 @@ function setData(newData, oldData, changedKeys2, excludes) {
|
|
|
205
213
|
}
|
|
206
214
|
return changed;
|
|
207
215
|
}
|
|
208
|
-
function isRefToken(s) {
|
|
209
|
-
if (s.length < 2 || s[0] !== SPLITTER) return false;
|
|
210
|
-
for (let i = 1; i < s.length; i++) {
|
|
211
|
-
const c = s.charCodeAt(i);
|
|
212
|
-
if (c < 48 || c > 57) return false;
|
|
213
|
-
}
|
|
214
|
-
return true;
|
|
215
|
-
}
|
|
216
216
|
function translateData(data, value) {
|
|
217
217
|
if (isPrimitive(value)) {
|
|
218
218
|
const prop = String(value);
|
|
@@ -241,11 +241,11 @@ function getById(id) {
|
|
|
241
241
|
function getAttribute(element, attr) {
|
|
242
242
|
return Element.prototype.getAttribute.call(element, attr) ?? "";
|
|
243
243
|
}
|
|
244
|
-
function ensureElementId(element) {
|
|
244
|
+
function ensureElementId(element, prefix) {
|
|
245
245
|
const id = element.getAttribute("id");
|
|
246
246
|
if (id) return id;
|
|
247
247
|
element.autoId = 1;
|
|
248
|
-
const newId = generateId();
|
|
248
|
+
const newId = generateId(prefix);
|
|
249
249
|
element.id = newId;
|
|
250
250
|
return newId;
|
|
251
251
|
}
|
|
@@ -275,11 +275,6 @@ function parseUri(uri) {
|
|
|
275
275
|
});
|
|
276
276
|
return { path: actualPath, params };
|
|
277
277
|
}
|
|
278
|
-
var IS_URL_PARAMS = {
|
|
279
|
-
test(s) {
|
|
280
|
-
return /(?!^)=|&/.test(s);
|
|
281
|
-
}
|
|
282
|
-
};
|
|
283
278
|
function toUri(path, params, keepEmpty) {
|
|
284
279
|
const pairs = [];
|
|
285
280
|
let hasParams = false;
|
|
@@ -307,7 +302,7 @@ function toMap(list, key) {
|
|
|
307
302
|
return map;
|
|
308
303
|
}
|
|
309
304
|
function now() {
|
|
310
|
-
return Date.now
|
|
305
|
+
return Date.now();
|
|
311
306
|
}
|
|
312
307
|
|
|
313
308
|
// src/apply-style.ts
|
|
@@ -946,14 +941,12 @@ function getChanged(oldLoc, newLoc) {
|
|
|
946
941
|
setDiff("path", oldLoc["path"], newLoc["path"]);
|
|
947
942
|
if (changedParams["path"]) {
|
|
948
943
|
result["path"] = changedParams["path"];
|
|
949
|
-
hasChanged = true;
|
|
950
944
|
result.changed = true;
|
|
951
945
|
}
|
|
952
946
|
const viewKey = "view";
|
|
953
947
|
setDiff(viewKey, oldLoc.view, newLoc.view);
|
|
954
948
|
if (changedParams[viewKey]) {
|
|
955
949
|
result.view = changedParams[viewKey];
|
|
956
|
-
hasChanged = true;
|
|
957
950
|
result.changed = true;
|
|
958
951
|
}
|
|
959
952
|
const finalResult = {
|
|
@@ -1473,7 +1466,7 @@ var EventDelegator = {
|
|
|
1473
1466
|
}
|
|
1474
1467
|
};
|
|
1475
1468
|
|
|
1476
|
-
// src/
|
|
1469
|
+
// src/dom.ts
|
|
1477
1470
|
var wrapMeta = {
|
|
1478
1471
|
option: [1, "<select multiple>"],
|
|
1479
1472
|
thead: [1, "<table>"],
|
|
@@ -1493,12 +1486,12 @@ var VDoc = document.implementation.createHTMLDocument("");
|
|
|
1493
1486
|
var VBase = VDoc.createElement("base");
|
|
1494
1487
|
VBase.href = document.location.href;
|
|
1495
1488
|
VDoc.head.appendChild(VBase);
|
|
1496
|
-
var
|
|
1489
|
+
var DomSpecials = {
|
|
1497
1490
|
INPUT: ["value", "checked"],
|
|
1498
1491
|
TEXTAREA: ["value"],
|
|
1499
1492
|
OPTION: ["selected"]
|
|
1500
1493
|
};
|
|
1501
|
-
function
|
|
1494
|
+
function domUnmountFrames(frame, node) {
|
|
1502
1495
|
if (!(node instanceof Element)) return;
|
|
1503
1496
|
const id = node.getAttribute("id");
|
|
1504
1497
|
if (!id) return;
|
|
@@ -1507,7 +1500,7 @@ function vdomUnmountFrames(frame, node) {
|
|
|
1507
1500
|
frame.unmountFrame(id);
|
|
1508
1501
|
}
|
|
1509
1502
|
}
|
|
1510
|
-
function
|
|
1503
|
+
function domGetNode(html, refNode) {
|
|
1511
1504
|
const tmp = VDoc.createElement("div");
|
|
1512
1505
|
const ns = refNode.namespaceURI;
|
|
1513
1506
|
let tag;
|
|
@@ -1528,16 +1521,13 @@ function vdomGetNode(html, refNode) {
|
|
|
1528
1521
|
}
|
|
1529
1522
|
return tmp;
|
|
1530
1523
|
}
|
|
1531
|
-
function
|
|
1524
|
+
function domGetCompareKey(node) {
|
|
1532
1525
|
if (node.nodeType !== 1) return void 0;
|
|
1533
1526
|
const el = node;
|
|
1534
1527
|
if (el.compareKeyCached) {
|
|
1535
1528
|
return el.cachedCompareKey;
|
|
1536
1529
|
}
|
|
1537
1530
|
let key = el.autoId ? "" : el.getAttribute("id") || void 0;
|
|
1538
|
-
if (!key) {
|
|
1539
|
-
key = el.getAttribute(LarkInnerKeys.DIFF_KEY) || void 0;
|
|
1540
|
-
}
|
|
1541
1531
|
if (!key) {
|
|
1542
1532
|
const larkView = el.getAttribute(LARK_VIEW);
|
|
1543
1533
|
if (larkView) {
|
|
@@ -1548,8 +1538,8 @@ function vdomGetCompareKey(node) {
|
|
|
1548
1538
|
el.cachedCompareKey = key || "";
|
|
1549
1539
|
return key;
|
|
1550
1540
|
}
|
|
1551
|
-
function
|
|
1552
|
-
const specials =
|
|
1541
|
+
function domSpecialDiff(oldNode, newNode) {
|
|
1542
|
+
const specials = DomSpecials[oldNode.nodeName];
|
|
1553
1543
|
if (!specials) return 0;
|
|
1554
1544
|
const oldEl = oldNode;
|
|
1555
1545
|
const newEl = newNode;
|
|
@@ -1562,7 +1552,7 @@ function vdomSpecialDiff(oldNode, newNode) {
|
|
|
1562
1552
|
}
|
|
1563
1553
|
return result;
|
|
1564
1554
|
}
|
|
1565
|
-
function
|
|
1555
|
+
function domSetAttributes(oldNode, newNode, ref, keepId) {
|
|
1566
1556
|
const oldEl = oldNode;
|
|
1567
1557
|
Reflect.deleteProperty(oldEl, "compareKeyCached");
|
|
1568
1558
|
const oldAttrs = oldNode.attributes;
|
|
@@ -1594,7 +1584,7 @@ function vdomSetAttributes(oldNode, newNode, ref, keepId) {
|
|
|
1594
1584
|
}
|
|
1595
1585
|
}
|
|
1596
1586
|
}
|
|
1597
|
-
function
|
|
1587
|
+
function domSetChildNodes(oldParent, newParent, ref, frame, keys_) {
|
|
1598
1588
|
let oldNode = oldParent.lastChild;
|
|
1599
1589
|
let newNode = newParent.firstChild;
|
|
1600
1590
|
let extra = 0;
|
|
@@ -1602,7 +1592,7 @@ function vdomSetChildNodes(oldParent, newParent, ref, frame, keys_) {
|
|
|
1602
1592
|
const newKeyedNodes = /* @__PURE__ */ new Map();
|
|
1603
1593
|
while (oldNode) {
|
|
1604
1594
|
extra++;
|
|
1605
|
-
const nodeKey =
|
|
1595
|
+
const nodeKey = domGetCompareKey(oldNode);
|
|
1606
1596
|
if (nodeKey) {
|
|
1607
1597
|
let bucket = keyedNodes.get(nodeKey);
|
|
1608
1598
|
if (!bucket) {
|
|
@@ -1614,7 +1604,7 @@ function vdomSetChildNodes(oldParent, newParent, ref, frame, keys_) {
|
|
|
1614
1604
|
oldNode = oldNode.previousSibling;
|
|
1615
1605
|
}
|
|
1616
1606
|
while (newNode) {
|
|
1617
|
-
const nodeKey =
|
|
1607
|
+
const nodeKey = domGetCompareKey(newNode);
|
|
1618
1608
|
if (nodeKey) {
|
|
1619
1609
|
newKeyedNodes.set(nodeKey, (newKeyedNodes.get(nodeKey) ?? 0) + 1);
|
|
1620
1610
|
}
|
|
@@ -1626,7 +1616,7 @@ function vdomSetChildNodes(oldParent, newParent, ref, frame, keys_) {
|
|
|
1626
1616
|
extra--;
|
|
1627
1617
|
const tempNew = newNode;
|
|
1628
1618
|
newNode = newNode.nextSibling;
|
|
1629
|
-
const nodeKey =
|
|
1619
|
+
const nodeKey = domGetCompareKey(tempNew);
|
|
1630
1620
|
let foundNode = nodeKey ? keyedNodes.get(nodeKey) : void 0;
|
|
1631
1621
|
if (foundNode && (foundNode = foundNode.slice()) && foundNode.length) {
|
|
1632
1622
|
const matched = foundNode.pop();
|
|
@@ -1641,17 +1631,17 @@ function vdomSetChildNodes(oldParent, newParent, ref, frame, keys_) {
|
|
|
1641
1631
|
const c = newKeyedNodes.get(nodeKey);
|
|
1642
1632
|
if (c) newKeyedNodes.set(nodeKey, c - 1);
|
|
1643
1633
|
}
|
|
1644
|
-
|
|
1634
|
+
domSetNode(matched, tempNew, oldParent, ref, frame, keys_);
|
|
1645
1635
|
} else if (oldNode) {
|
|
1646
1636
|
const tempOld2 = oldNode;
|
|
1647
|
-
const oldKey =
|
|
1637
|
+
const oldKey = domGetCompareKey(tempOld2);
|
|
1648
1638
|
if (oldKey && keyedNodes.has(oldKey) && newKeyedNodes.get(oldKey)) {
|
|
1649
1639
|
extra++;
|
|
1650
1640
|
ref.hasChanged = 1;
|
|
1651
1641
|
ref.domOps.push([8, oldParent, tempNew, tempOld2]);
|
|
1652
1642
|
} else {
|
|
1653
1643
|
oldNode = oldNode.nextSibling;
|
|
1654
|
-
|
|
1644
|
+
domSetNode(tempOld2, tempNew, oldParent, ref, frame, keys_);
|
|
1655
1645
|
}
|
|
1656
1646
|
} else {
|
|
1657
1647
|
ref.hasChanged = 1;
|
|
@@ -1661,29 +1651,23 @@ function vdomSetChildNodes(oldParent, newParent, ref, frame, keys_) {
|
|
|
1661
1651
|
let tempOld = oldParent.lastChild;
|
|
1662
1652
|
while (extra-- > 0) {
|
|
1663
1653
|
if (tempOld) {
|
|
1664
|
-
|
|
1654
|
+
domUnmountFrames(frame, tempOld);
|
|
1665
1655
|
ref.domOps.push([2, oldParent, tempOld]);
|
|
1666
1656
|
tempOld = tempOld.previousSibling;
|
|
1667
1657
|
ref.hasChanged = 1;
|
|
1668
1658
|
}
|
|
1669
1659
|
}
|
|
1670
1660
|
}
|
|
1671
|
-
function
|
|
1661
|
+
function domSetNode(oldNode, newNode, oldParent, ref, frame, keys_) {
|
|
1672
1662
|
const oldAsEl = oldNode instanceof Element ? oldNode : null;
|
|
1673
1663
|
const newAsEl = newNode instanceof Element ? newNode : null;
|
|
1674
|
-
const hasViewKey = !!oldAsEl?.hasAttribute(LarkInnerKeys.VIEW_KEY);
|
|
1675
1664
|
const equalAsNodes = oldAsEl !== null && newAsEl !== null && oldAsEl.isEqualNode && oldAsEl.isEqualNode(newAsEl);
|
|
1676
|
-
if (
|
|
1665
|
+
if (domSpecialDiff(oldNode, newNode) || !equalAsNodes) {
|
|
1677
1666
|
if (oldNode.nodeType === newNode.nodeType && oldNode.nodeName === newNode.nodeName) {
|
|
1678
1667
|
if (oldAsEl !== null && newAsEl !== null) {
|
|
1679
1668
|
const oldEl = oldAsEl;
|
|
1680
1669
|
const newEl = newAsEl;
|
|
1681
|
-
const staticKey = newEl.getAttribute(LarkInnerKeys.DIFF_KEY);
|
|
1682
|
-
if (staticKey && staticKey === oldEl.getAttribute(LarkInnerKeys.DIFF_KEY)) {
|
|
1683
|
-
return;
|
|
1684
|
-
}
|
|
1685
1670
|
const newLarkView = newEl.getAttribute(LARK_VIEW);
|
|
1686
|
-
const updateAttribute = !newEl.getAttribute(LarkInnerKeys.ATTR_KEY) || newEl.getAttribute(LarkInnerKeys.ATTR_KEY) !== oldEl.getAttribute(LarkInnerKeys.ATTR_KEY);
|
|
1687
1671
|
let updateChildren = true;
|
|
1688
1672
|
if (newLarkView) {
|
|
1689
1673
|
const oldFrameId = oldEl.getAttribute("id") || "";
|
|
@@ -1694,11 +1678,9 @@ function vdomSetNode(oldNode, newNode, oldParent, ref, frame, keys_) {
|
|
|
1694
1678
|
updateChildren = false;
|
|
1695
1679
|
}
|
|
1696
1680
|
}
|
|
1697
|
-
|
|
1698
|
-
vdomSetAttributes(oldEl, newEl, ref, !!newLarkView);
|
|
1699
|
-
}
|
|
1681
|
+
domSetAttributes(oldEl, newEl, ref, !!newLarkView);
|
|
1700
1682
|
if (updateChildren) {
|
|
1701
|
-
|
|
1683
|
+
domSetChildNodes(oldEl, newEl, ref, frame, keys_);
|
|
1702
1684
|
}
|
|
1703
1685
|
} else if (oldNode.nodeValue !== newNode.nodeValue) {
|
|
1704
1686
|
ref.hasChanged = 1;
|
|
@@ -1706,12 +1688,12 @@ function vdomSetNode(oldNode, newNode, oldParent, ref, frame, keys_) {
|
|
|
1706
1688
|
}
|
|
1707
1689
|
} else {
|
|
1708
1690
|
ref.hasChanged = 1;
|
|
1709
|
-
|
|
1691
|
+
domUnmountFrames(frame, oldNode);
|
|
1710
1692
|
ref.domOps.push([4, oldParent, newNode, oldNode]);
|
|
1711
1693
|
}
|
|
1712
1694
|
}
|
|
1713
1695
|
}
|
|
1714
|
-
function
|
|
1696
|
+
function createDomRef() {
|
|
1715
1697
|
return {
|
|
1716
1698
|
idUpdates: [],
|
|
1717
1699
|
views: [],
|
|
@@ -1719,7 +1701,7 @@ function createVdomRef() {
|
|
|
1719
1701
|
hasChanged: 0
|
|
1720
1702
|
};
|
|
1721
1703
|
}
|
|
1722
|
-
function
|
|
1704
|
+
function applyDomOps(ops) {
|
|
1723
1705
|
for (const op of ops) {
|
|
1724
1706
|
switch (op[0]) {
|
|
1725
1707
|
case 1:
|
|
@@ -1746,57 +1728,8 @@ function applyIdUpdates(updates) {
|
|
|
1746
1728
|
}
|
|
1747
1729
|
}
|
|
1748
1730
|
}
|
|
1749
|
-
var EncoderMap = {
|
|
1750
|
-
"&": "amp",
|
|
1751
|
-
"<": "lt",
|
|
1752
|
-
">": "gt",
|
|
1753
|
-
'"': "#34",
|
|
1754
|
-
"'": "#39",
|
|
1755
|
-
"`": "#96"
|
|
1756
|
-
};
|
|
1757
|
-
var ENCODE_REGEXP = /[&<>"'`]/g;
|
|
1758
|
-
function encodeHTML(v) {
|
|
1759
|
-
return String(v == null ? "" : v).replace(
|
|
1760
|
-
ENCODE_REGEXP,
|
|
1761
|
-
(m) => "&" + EncoderMap[m] + ";"
|
|
1762
|
-
);
|
|
1763
|
-
}
|
|
1764
|
-
function encodeSafe(v) {
|
|
1765
|
-
return String(v == null ? "" : v);
|
|
1766
|
-
}
|
|
1767
|
-
var URIMap = {
|
|
1768
|
-
"!": "%21",
|
|
1769
|
-
"'": "%27",
|
|
1770
|
-
"(": "%28",
|
|
1771
|
-
")": "%29",
|
|
1772
|
-
"*": "%2A"
|
|
1773
|
-
};
|
|
1774
|
-
var URI_ENCODE_REGEXP = /[!')(*]/g;
|
|
1775
|
-
function encodeURIExtra(v) {
|
|
1776
|
-
return encodeURIComponent(encodeSafe(v)).replace(
|
|
1777
|
-
URI_ENCODE_REGEXP,
|
|
1778
|
-
(m) => URIMap[m]
|
|
1779
|
-
);
|
|
1780
|
-
}
|
|
1781
|
-
var QUOTE_REGEXP = /['"\\]/g;
|
|
1782
|
-
function encodeQ(v) {
|
|
1783
|
-
return encodeSafe(v).replace(QUOTE_REGEXP, "\\$&");
|
|
1784
|
-
}
|
|
1785
1731
|
|
|
1786
1732
|
// src/updater.ts
|
|
1787
|
-
function updaterRef(refDataIn, value, key) {
|
|
1788
|
-
const refData = refDataIn;
|
|
1789
|
-
const counter = refData[SPLITTER];
|
|
1790
|
-
for (let i = counter; --i; ) {
|
|
1791
|
-
key = SPLITTER + i;
|
|
1792
|
-
if (refData[key] === value) {
|
|
1793
|
-
return key;
|
|
1794
|
-
}
|
|
1795
|
-
}
|
|
1796
|
-
key = SPLITTER + refData[SPLITTER]++;
|
|
1797
|
-
refData[key] = value;
|
|
1798
|
-
return key;
|
|
1799
|
-
}
|
|
1800
1733
|
var Updater = class {
|
|
1801
1734
|
/** View ID (same as owner frame ID) */
|
|
1802
1735
|
viewId;
|
|
@@ -1858,11 +1791,11 @@ var Updater = class {
|
|
|
1858
1791
|
return this;
|
|
1859
1792
|
}
|
|
1860
1793
|
/**
|
|
1861
|
-
* Detect changes and trigger
|
|
1794
|
+
* Detect changes and trigger DOM re-render.
|
|
1862
1795
|
*
|
|
1863
1796
|
* The core rendering pipeline:
|
|
1864
1797
|
* 1. Set data if provided
|
|
1865
|
-
* 2. If changed, run
|
|
1798
|
+
* 2. If changed, run DOM diff (template → new DOM → diff against old DOM)
|
|
1866
1799
|
* 3. Apply DOM operations
|
|
1867
1800
|
* 4. Apply ID updates
|
|
1868
1801
|
* 5. Call endUpdate on views that need re-rendering
|
|
@@ -1904,14 +1837,14 @@ var Updater = class {
|
|
|
1904
1837
|
encodeHTML,
|
|
1905
1838
|
encodeSafe,
|
|
1906
1839
|
encodeURIExtra,
|
|
1907
|
-
|
|
1840
|
+
refFn,
|
|
1908
1841
|
encodeQ
|
|
1909
1842
|
);
|
|
1910
|
-
const newDom =
|
|
1911
|
-
const ref =
|
|
1912
|
-
|
|
1843
|
+
const newDom = domGetNode(html, node);
|
|
1844
|
+
const ref = createDomRef();
|
|
1845
|
+
domSetChildNodes(node, newDom, ref, frame, keys2);
|
|
1913
1846
|
applyIdUpdates(ref.idUpdates);
|
|
1914
|
-
|
|
1847
|
+
applyDomOps(ref.domOps);
|
|
1915
1848
|
for (const v of ref.views) {
|
|
1916
1849
|
if (v.render) {
|
|
1917
1850
|
funcWithTry(v.render, [], v, noop);
|
|
@@ -1952,17 +1885,12 @@ var Updater = class {
|
|
|
1952
1885
|
* Translate a refData reference back to its original value.
|
|
1953
1886
|
*
|
|
1954
1887
|
* The ref protocol is `SPLITTER` + ascii decimal digits — the exact format
|
|
1955
|
-
* emitted by `
|
|
1888
|
+
* emitted by `refFn`. We require that exact shape so a user-supplied
|
|
1956
1889
|
* string that merely begins with SPLITTER is never accidentally resolved
|
|
1957
1890
|
* (or mishandled as a "missing ref").
|
|
1958
1891
|
*/
|
|
1959
1892
|
translate(data) {
|
|
1960
|
-
if (typeof data !== "string") return data;
|
|
1961
|
-
if (data.length < 2 || data[0] !== SPLITTER) return data;
|
|
1962
|
-
for (let i = 1; i < data.length; i++) {
|
|
1963
|
-
const c = data.charCodeAt(i);
|
|
1964
|
-
if (c < 48 || c > 57) return data;
|
|
1965
|
-
}
|
|
1893
|
+
if (typeof data !== "string" || !isRefToken(data)) return data;
|
|
1966
1894
|
return hasOwnProperty(this.refData, data) ? this.refData[data] : data;
|
|
1967
1895
|
}
|
|
1968
1896
|
/**
|
|
@@ -2029,8 +1957,6 @@ var View = class _View {
|
|
|
2029
1957
|
observedStateKeys;
|
|
2030
1958
|
/** Resource map */
|
|
2031
1959
|
resources = {};
|
|
2032
|
-
/** Assign method reference */
|
|
2033
|
-
assignMethod;
|
|
2034
1960
|
/** Whether endUpdate pending */
|
|
2035
1961
|
endUpdatePending;
|
|
2036
1962
|
/** Internal event storage */
|
|
@@ -2107,7 +2033,7 @@ var View = class _View {
|
|
|
2107
2033
|
*/
|
|
2108
2034
|
beginUpdate(id) {
|
|
2109
2035
|
if (this.signature > 0 && this.endUpdatePending !== void 0) {
|
|
2110
|
-
this.ownerFrame.unmountZone(id
|
|
2036
|
+
this.ownerFrame.unmountZone(id);
|
|
2111
2037
|
}
|
|
2112
2038
|
}
|
|
2113
2039
|
/**
|
|
@@ -2126,7 +2052,7 @@ var View = class _View {
|
|
|
2126
2052
|
this.rendered = true;
|
|
2127
2053
|
}
|
|
2128
2054
|
const ownerFrame = this.ownerFrame;
|
|
2129
|
-
ownerFrame.mountZone(updateId
|
|
2055
|
+
ownerFrame.mountZone(updateId);
|
|
2130
2056
|
if (!flag) {
|
|
2131
2057
|
setTimeout(
|
|
2132
2058
|
this.wrapAsync(() => {
|
|
@@ -2351,7 +2277,6 @@ var View = class _View {
|
|
|
2351
2277
|
proto["$evtObjMap"] = eventsObject;
|
|
2352
2278
|
proto["$globalEvtList"] = eventsList;
|
|
2353
2279
|
proto["$selMap"] = selectorObject;
|
|
2354
|
-
proto["$assignFn"] = proto["assign"];
|
|
2355
2280
|
return makes;
|
|
2356
2281
|
}
|
|
2357
2282
|
/**
|
|
@@ -2865,7 +2790,7 @@ var Frame = class _Frame extends EventEmitter {
|
|
|
2865
2790
|
/**
|
|
2866
2791
|
* Unmount a child frame.
|
|
2867
2792
|
*/
|
|
2868
|
-
unmountFrame(id
|
|
2793
|
+
unmountFrame(id) {
|
|
2869
2794
|
const targetId = id ? this.childrenMap[id] : this.id;
|
|
2870
2795
|
const frame = frameRegistry.get(targetId);
|
|
2871
2796
|
if (!frame) return;
|
|
@@ -2887,7 +2812,7 @@ var Frame = class _Frame extends EventEmitter {
|
|
|
2887
2812
|
/**
|
|
2888
2813
|
* Mount all views in a zone.
|
|
2889
2814
|
*/
|
|
2890
|
-
mountZone(zoneId
|
|
2815
|
+
mountZone(zoneId) {
|
|
2891
2816
|
const targetZone = zoneId || this.id;
|
|
2892
2817
|
this.holdFireCreated = 1;
|
|
2893
2818
|
const rootEl = document.getElementById(targetZone);
|
|
@@ -2897,7 +2822,7 @@ var Frame = class _Frame extends EventEmitter {
|
|
|
2897
2822
|
viewElements.forEach((el) => {
|
|
2898
2823
|
if (!(el instanceof HTMLElement)) return;
|
|
2899
2824
|
if (htmlElIsBound(el)) return;
|
|
2900
|
-
const elId =
|
|
2825
|
+
const elId = ensureElementId(el, "frame_");
|
|
2901
2826
|
el.frameBound = 1;
|
|
2902
2827
|
const viewPath = getAttribute(el, LARK_VIEW);
|
|
2903
2828
|
frames.push([elId, viewPath]);
|
|
@@ -2911,7 +2836,7 @@ var Frame = class _Frame extends EventEmitter {
|
|
|
2911
2836
|
/**
|
|
2912
2837
|
* Unmount all views in a zone.
|
|
2913
2838
|
*/
|
|
2914
|
-
unmountZone(zoneId
|
|
2839
|
+
unmountZone(zoneId) {
|
|
2915
2840
|
for (const childId in this.childrenMap) {
|
|
2916
2841
|
if (hasOwnProperty(this.childrenMap, childId)) {
|
|
2917
2842
|
if (!zoneId || childId !== zoneId) {
|
|
@@ -3040,17 +2965,6 @@ var Frame = class _Frame extends EventEmitter {
|
|
|
3040
2965
|
}
|
|
3041
2966
|
return rootFrame;
|
|
3042
2967
|
}
|
|
3043
|
-
/**
|
|
3044
|
-
* @deprecated Use `Frame.getRoot()` for read-only access or
|
|
3045
|
-
* `Frame.createRoot(id)` to create the root explicitly. The single-method
|
|
3046
|
-
* `root()` blurred the distinction and was a common source of bugs in
|
|
3047
|
-
* Micro-Frontend hosts.
|
|
3048
|
-
*
|
|
3049
|
-
* Kept for backward compatibility — behavior unchanged.
|
|
3050
|
-
*/
|
|
3051
|
-
static root(rootId) {
|
|
3052
|
-
return _Frame.createRoot(rootId);
|
|
3053
|
-
}
|
|
3054
2968
|
/** Bind event listener (static) */
|
|
3055
2969
|
static on(event, handler) {
|
|
3056
2970
|
staticEmitter.on(event, handler);
|
|
@@ -3069,14 +2983,6 @@ var Frame = class _Frame extends EventEmitter {
|
|
|
3069
2983
|
function htmlElIsBound(element) {
|
|
3070
2984
|
return !!element.frameBound;
|
|
3071
2985
|
}
|
|
3072
|
-
function ensureElementId2(element) {
|
|
3073
|
-
const id = element.getAttribute("id");
|
|
3074
|
-
if (id) return id;
|
|
3075
|
-
element.autoId = 1;
|
|
3076
|
-
const newId = generateId("frame_");
|
|
3077
|
-
element.id = newId;
|
|
3078
|
-
return newId;
|
|
3079
|
-
}
|
|
3080
2986
|
function removeFrame(id, wasCreated) {
|
|
3081
2987
|
const frameInstance = frameRegistry.get(id);
|
|
3082
2988
|
if (!frameInstance) return;
|
|
@@ -4257,18 +4163,14 @@ function create(name, creator) {
|
|
|
4257
4163
|
changedKeys2.add(key);
|
|
4258
4164
|
}
|
|
4259
4165
|
}
|
|
4260
|
-
let recomputed = false;
|
|
4261
4166
|
for (const [key, def] of computedDefs) {
|
|
4262
4167
|
if (def.deps.some((dep) => changedKeys2.has(dep))) {
|
|
4263
4168
|
const newVal = def.fn();
|
|
4264
4169
|
if (!Object.is(state[key], newVal)) {
|
|
4265
4170
|
state[key] = newVal;
|
|
4266
|
-
recomputed = true;
|
|
4267
4171
|
}
|
|
4268
4172
|
}
|
|
4269
4173
|
}
|
|
4270
|
-
if (recomputed) {
|
|
4271
|
-
}
|
|
4272
4174
|
};
|
|
4273
4175
|
const subscribe = (listener) => {
|
|
4274
4176
|
listeners.add(listener);
|
|
@@ -4333,7 +4235,6 @@ function bindStore(view, store, selector) {
|
|
|
4333
4235
|
view.on("destroy", off);
|
|
4334
4236
|
return off;
|
|
4335
4237
|
}
|
|
4336
|
-
var defineStore = create;
|
|
4337
4238
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4338
4239
|
0 && (module.exports = {
|
|
4339
4240
|
CALL_BREAK_TIME,
|
|
@@ -4356,59 +4257,24 @@ var defineStore = create;
|
|
|
4356
4257
|
Updater,
|
|
4357
4258
|
VIEW_EVENT_METHOD_REGEXP,
|
|
4358
4259
|
View,
|
|
4359
|
-
applyIdUpdates,
|
|
4360
4260
|
applyStyle,
|
|
4361
|
-
applyVdomOps,
|
|
4362
|
-
assign,
|
|
4363
4261
|
bindStore,
|
|
4364
4262
|
computed,
|
|
4365
4263
|
create,
|
|
4366
|
-
createVdomRef,
|
|
4367
|
-
defineStore,
|
|
4368
4264
|
defineView,
|
|
4369
|
-
encodeHTML,
|
|
4370
|
-
encodeQ,
|
|
4371
|
-
encodeSafe,
|
|
4372
|
-
encodeURIExtra,
|
|
4373
|
-
ensureElementId,
|
|
4374
4265
|
frameworkConfig,
|
|
4375
|
-
funcWithTry,
|
|
4376
|
-
generateId,
|
|
4377
|
-
getAttribute,
|
|
4378
|
-
getById,
|
|
4379
4266
|
getRouteMode,
|
|
4380
|
-
hasOwnProperty,
|
|
4381
4267
|
installFrameVisualizerBridge,
|
|
4382
4268
|
invalidateViewClass,
|
|
4383
|
-
isPlainObject,
|
|
4384
|
-
isPrimitive,
|
|
4385
|
-
isPrimitiveOrFunc,
|
|
4386
|
-
keys,
|
|
4387
4269
|
mark,
|
|
4388
4270
|
markBooted,
|
|
4389
4271
|
markRouterBooted,
|
|
4390
4272
|
nextCounter,
|
|
4391
|
-
nodeInside,
|
|
4392
|
-
noop,
|
|
4393
|
-
now,
|
|
4394
|
-
parseUri,
|
|
4395
4273
|
registerViewClass,
|
|
4396
4274
|
resetProjectsMap,
|
|
4397
4275
|
safeguard,
|
|
4398
4276
|
serializeFrameTree,
|
|
4399
|
-
setData,
|
|
4400
|
-
syncCounter,
|
|
4401
|
-
toMap,
|
|
4402
|
-
toUri,
|
|
4403
|
-
translateData,
|
|
4404
4277
|
unmark,
|
|
4405
4278
|
use,
|
|
4406
|
-
useUrlState
|
|
4407
|
-
vdomGetCompareKey,
|
|
4408
|
-
vdomGetNode,
|
|
4409
|
-
vdomSetAttributes,
|
|
4410
|
-
vdomSetChildNodes,
|
|
4411
|
-
vdomSetNode,
|
|
4412
|
-
vdomSpecialDiff,
|
|
4413
|
-
vdomUnmountFrames
|
|
4279
|
+
useUrlState
|
|
4414
4280
|
});
|