@lark.js/mvc 0.0.10 → 0.0.11
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 +10 -10
- package/dist/chunk-RIV4NK3K.js +108 -0
- package/dist/compiler.cjs +654 -114
- package/dist/compiler.d.cts +35 -35
- package/dist/compiler.d.ts +35 -35
- package/dist/compiler.js +651 -114
- package/dist/devtool.cjs +3421 -0
- package/dist/devtool.d.cts +83 -0
- package/dist/devtool.d.ts +83 -0
- package/dist/devtool.js +3333 -0
- package/dist/index.cjs +754 -147
- package/dist/index.d.cts +88 -85
- package/dist/index.d.ts +88 -85
- package/dist/index.js +751 -143
- package/dist/rspack.cjs +15978 -0
- package/dist/rspack.d.cts +122 -0
- package/dist/rspack.d.ts +122 -0
- package/dist/{chunk-SIQF4YLC.js → rspack.js} +765 -149
- package/dist/runtime.cjs +7 -7
- package/dist/runtime.d.cts +4 -4
- package/dist/runtime.d.ts +4 -4
- package/dist/runtime.js +10 -54
- package/dist/vite.cjs +709 -151
- package/dist/vite.d.cts +3 -0
- package/dist/vite.d.ts +3 -0
- package/dist/vite.js +15917 -10
- package/dist/webpack.cjs +756 -159
- package/dist/webpack.d.cts +60 -4
- package/dist/webpack.d.ts +60 -4
- package/dist/webpack.js +15962 -14
- package/package.json +25 -2
package/dist/index.js
CHANGED
|
@@ -20,6 +20,12 @@ var SVG_NS = "http://www.w3.org/2000/svg";
|
|
|
20
20
|
var MATH_NS = "http://www.w3.org/1998/Math/MathML";
|
|
21
21
|
var TAG_NAME_REGEXP = /<([a-z][^/\0>\x20\t\r\n\f]+)/i;
|
|
22
22
|
var CALL_BREAK_TIME = 48;
|
|
23
|
+
var V_TEXT_NODE = 0;
|
|
24
|
+
var TAG_STATIC_KEY = "_";
|
|
25
|
+
var VDOM_NS_MAP = {
|
|
26
|
+
svg: SVG_NS,
|
|
27
|
+
math: MATH_NS
|
|
28
|
+
};
|
|
23
29
|
function nextCounter() {
|
|
24
30
|
return ++globalCounter;
|
|
25
31
|
}
|
|
@@ -32,7 +38,7 @@ var HTML_ENT_MAP = {
|
|
|
32
38
|
"`": "#96"
|
|
33
39
|
};
|
|
34
40
|
var HTML_ENT_REGEXP = /[&<>"'`]/g;
|
|
35
|
-
function
|
|
41
|
+
function strSafe(v) {
|
|
36
42
|
return String(v == null ? "" : v);
|
|
37
43
|
}
|
|
38
44
|
function encodeHTML(v) {
|
|
@@ -50,14 +56,14 @@ var URI_ENT_MAP = {
|
|
|
50
56
|
};
|
|
51
57
|
var URI_ENT_REGEXP = /[!')(*]/g;
|
|
52
58
|
function encodeURIExtra(v) {
|
|
53
|
-
return encodeURIComponent(
|
|
59
|
+
return encodeURIComponent(strSafe(v)).replace(
|
|
54
60
|
URI_ENT_REGEXP,
|
|
55
61
|
(m) => URI_ENT_MAP[m]
|
|
56
62
|
);
|
|
57
63
|
}
|
|
58
64
|
var QUOTE_ENT_REGEXP = /['"\\]/g;
|
|
59
|
-
function
|
|
60
|
-
return
|
|
65
|
+
function encodeQuote(v) {
|
|
66
|
+
return strSafe(v).replace(QUOTE_ENT_REGEXP, "\\$&");
|
|
61
67
|
}
|
|
62
68
|
function refFn(ref, value, key) {
|
|
63
69
|
const counter = ref[SPLITTER];
|
|
@@ -79,11 +85,66 @@ function isRefToken(s) {
|
|
|
79
85
|
}
|
|
80
86
|
|
|
81
87
|
// src/utils.ts
|
|
88
|
+
var CALL_BREAK_TIME2 = 9;
|
|
89
|
+
var callQueue = [];
|
|
90
|
+
var callScheduled = false;
|
|
91
|
+
var schedulerYield = (() => {
|
|
92
|
+
try {
|
|
93
|
+
if (typeof globalThis?.scheduler?.yield === "function") {
|
|
94
|
+
return globalThis.scheduler.yield.bind(globalThis.scheduler);
|
|
95
|
+
}
|
|
96
|
+
} catch {
|
|
97
|
+
}
|
|
98
|
+
return void 0;
|
|
99
|
+
})();
|
|
100
|
+
async function startCall() {
|
|
101
|
+
callScheduled = false;
|
|
102
|
+
const startTime = performance.now();
|
|
103
|
+
while (callQueue.length > 0) {
|
|
104
|
+
const task2 = callQueue.shift();
|
|
105
|
+
try {
|
|
106
|
+
task2();
|
|
107
|
+
} catch (e) {
|
|
108
|
+
console.error("scheduler task error:", e);
|
|
109
|
+
}
|
|
110
|
+
if (callQueue.length > 0 && performance.now() - startTime > CALL_BREAK_TIME2) {
|
|
111
|
+
if (schedulerYield) {
|
|
112
|
+
await schedulerYield();
|
|
113
|
+
} else {
|
|
114
|
+
scheduleNextChunk();
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function scheduleNextChunk() {
|
|
121
|
+
setTimeout(() => startCall(), 0);
|
|
122
|
+
callScheduled = true;
|
|
123
|
+
}
|
|
124
|
+
function callFunction(fn, args) {
|
|
125
|
+
callQueue.push(() => fn(...args));
|
|
126
|
+
if (!callScheduled) {
|
|
127
|
+
scheduleNextChunk();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
82
130
|
function isPlainObject(value) {
|
|
83
131
|
if (typeof value !== "object" || value === null) return false;
|
|
84
132
|
const proto = Object.getPrototypeOf(value);
|
|
85
133
|
return proto === null || proto === Object.prototype;
|
|
86
134
|
}
|
|
135
|
+
function isRecord(value) {
|
|
136
|
+
return typeof value === "object" && value !== null;
|
|
137
|
+
}
|
|
138
|
+
function asRecord(value) {
|
|
139
|
+
if (isRecord(value)) {
|
|
140
|
+
return value;
|
|
141
|
+
}
|
|
142
|
+
console.error("fallback to Object.fromEntries, even an empty object {}.");
|
|
143
|
+
if (Array.isArray(value)) {
|
|
144
|
+
return Object.fromEntries(value.entries());
|
|
145
|
+
}
|
|
146
|
+
return {};
|
|
147
|
+
}
|
|
87
148
|
function isPrimitiveOrFunc(value) {
|
|
88
149
|
return !value || typeof value !== "object" && typeof value !== "function";
|
|
89
150
|
}
|
|
@@ -137,13 +198,13 @@ function setData(newData, oldData, changedKeys2, excludes) {
|
|
|
137
198
|
let changed = false;
|
|
138
199
|
for (const p in newData) {
|
|
139
200
|
if (hasOwnProperty(newData, p)) {
|
|
140
|
-
const
|
|
201
|
+
const now = newData[p];
|
|
141
202
|
const old = oldData[p];
|
|
142
|
-
if ((!isPrimitiveOrFunc(
|
|
203
|
+
if ((!isPrimitiveOrFunc(now) || old !== now) && !excludes.has(p)) {
|
|
143
204
|
changedKeys2.add(p);
|
|
144
205
|
changed = true;
|
|
145
206
|
}
|
|
146
|
-
oldData[p] =
|
|
207
|
+
oldData[p] = now;
|
|
147
208
|
}
|
|
148
209
|
}
|
|
149
210
|
return changed;
|
|
@@ -236,9 +297,6 @@ function toMap(list, key) {
|
|
|
236
297
|
}
|
|
237
298
|
return map;
|
|
238
299
|
}
|
|
239
|
-
function now() {
|
|
240
|
-
return Date.now();
|
|
241
|
-
}
|
|
242
300
|
|
|
243
301
|
// src/apply-style.ts
|
|
244
302
|
var injectedStyleIds = /* @__PURE__ */ new Set();
|
|
@@ -990,10 +1048,7 @@ var Router = {
|
|
|
990
1048
|
if (lastChanged["path"]) {
|
|
991
1049
|
document.title = defaultTitle || document.title;
|
|
992
1050
|
}
|
|
993
|
-
emitter2.fire(
|
|
994
|
-
RouterEvents.CHANGED,
|
|
995
|
-
lastChanged
|
|
996
|
-
);
|
|
1051
|
+
emitter2.fire(RouterEvents.CHANGED, asRecord(lastChanged));
|
|
997
1052
|
}
|
|
998
1053
|
silent = 0;
|
|
999
1054
|
if (typeof window.__lark_Debug !== "undefined" && window.__lark_Debug && lastChanged) {
|
|
@@ -1124,10 +1179,7 @@ var Router = {
|
|
|
1124
1179
|
suspend = 1;
|
|
1125
1180
|
}
|
|
1126
1181
|
};
|
|
1127
|
-
Router.fire(
|
|
1128
|
-
RouterEvents.CHANGE,
|
|
1129
|
-
changeEvent
|
|
1130
|
-
);
|
|
1182
|
+
Router.fire(RouterEvents.CHANGE, changeEvent);
|
|
1131
1183
|
if (suspend || changeEvent.p) {
|
|
1132
1184
|
return;
|
|
1133
1185
|
}
|
|
@@ -1401,6 +1453,53 @@ var EventDelegator = {
|
|
|
1401
1453
|
}
|
|
1402
1454
|
};
|
|
1403
1455
|
|
|
1456
|
+
// src/module-loader.ts
|
|
1457
|
+
var config = {
|
|
1458
|
+
rootId: "root",
|
|
1459
|
+
routeMode: "history",
|
|
1460
|
+
hashbang: "#!",
|
|
1461
|
+
error: (error) => {
|
|
1462
|
+
throw error;
|
|
1463
|
+
}
|
|
1464
|
+
};
|
|
1465
|
+
function use(names, callback) {
|
|
1466
|
+
const nameList = typeof names === "string" ? [names] : names;
|
|
1467
|
+
const loadPromise = (() => {
|
|
1468
|
+
if (config.require) {
|
|
1469
|
+
const result = config.require(nameList);
|
|
1470
|
+
if (result && typeof result.then === "function") {
|
|
1471
|
+
return result;
|
|
1472
|
+
}
|
|
1473
|
+
return Promise.resolve([]);
|
|
1474
|
+
}
|
|
1475
|
+
return Promise.all(
|
|
1476
|
+
nameList.map((name) => {
|
|
1477
|
+
const importPath = name.startsWith(".") || name.startsWith("/") ? name : `./${name}`;
|
|
1478
|
+
return import(
|
|
1479
|
+
/* @vite-ignore */
|
|
1480
|
+
/* webpackIgnore: true */
|
|
1481
|
+
importPath
|
|
1482
|
+
).then((mod) => {
|
|
1483
|
+
return mod && (mod["__esModule"] || // For Webpack
|
|
1484
|
+
typeof mod["default"] === "function") ? mod["default"] : mod;
|
|
1485
|
+
}).catch((err) => {
|
|
1486
|
+
const errorHandler = config.error;
|
|
1487
|
+
if (errorHandler) {
|
|
1488
|
+
errorHandler(err instanceof Error ? err : new Error(String(err)));
|
|
1489
|
+
}
|
|
1490
|
+
return void 0;
|
|
1491
|
+
});
|
|
1492
|
+
})
|
|
1493
|
+
);
|
|
1494
|
+
})();
|
|
1495
|
+
if (callback) {
|
|
1496
|
+
loadPromise.then((modules) => {
|
|
1497
|
+
callback(...modules);
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1500
|
+
return loadPromise;
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1404
1503
|
// src/dom.ts
|
|
1405
1504
|
var wrapMeta = {
|
|
1406
1505
|
option: [1, "<select multiple>"],
|
|
@@ -1476,13 +1575,11 @@ function domGetCompareKey(node) {
|
|
|
1476
1575
|
function domSpecialDiff(oldNode, newNode) {
|
|
1477
1576
|
const specials = DomSpecials[oldNode.nodeName];
|
|
1478
1577
|
if (!specials) return 0;
|
|
1479
|
-
const oldEl = oldNode;
|
|
1480
|
-
const newEl = newNode;
|
|
1481
1578
|
let result = 0;
|
|
1482
1579
|
for (const prop of specials) {
|
|
1483
|
-
if (
|
|
1580
|
+
if (Reflect.get(oldNode, prop) !== Reflect.get(newNode, prop)) {
|
|
1484
1581
|
result = 1;
|
|
1485
|
-
|
|
1582
|
+
Reflect.set(oldNode, prop, Reflect.get(newNode, prop));
|
|
1486
1583
|
}
|
|
1487
1584
|
}
|
|
1488
1585
|
return result;
|
|
@@ -1664,6 +1761,528 @@ function applyIdUpdates(updates) {
|
|
|
1664
1761
|
}
|
|
1665
1762
|
}
|
|
1666
1763
|
|
|
1764
|
+
// src/vdom.ts
|
|
1765
|
+
var DOM_SPECIALS = {
|
|
1766
|
+
INPUT: ["value", "checked"],
|
|
1767
|
+
TEXTAREA: ["value"],
|
|
1768
|
+
OPTION: ["selected"]
|
|
1769
|
+
};
|
|
1770
|
+
function vdomCreate(tag, props, children, specials) {
|
|
1771
|
+
if (!tag) {
|
|
1772
|
+
return {
|
|
1773
|
+
tag: children ? SPLITTER : V_TEXT_NODE,
|
|
1774
|
+
html: String(props ?? "")
|
|
1775
|
+
};
|
|
1776
|
+
}
|
|
1777
|
+
const propsObj = props || {};
|
|
1778
|
+
const specialsObj = specials || {};
|
|
1779
|
+
const unary = children === 1;
|
|
1780
|
+
let compareKey;
|
|
1781
|
+
let innerHTML = "";
|
|
1782
|
+
let newChildren;
|
|
1783
|
+
let reused;
|
|
1784
|
+
let reusedTotal = 0;
|
|
1785
|
+
let viewList;
|
|
1786
|
+
let isLarkView2;
|
|
1787
|
+
let attrs = `<${tag}`;
|
|
1788
|
+
let hasSpecials;
|
|
1789
|
+
let prevChild;
|
|
1790
|
+
if (children && children !== 1) {
|
|
1791
|
+
for (const c of children) {
|
|
1792
|
+
if (c.attrs !== void 0) {
|
|
1793
|
+
innerHTML += c.attrs + (c.selfClose ? "/>" : `>${c.html}</${c.tag}>`);
|
|
1794
|
+
} else {
|
|
1795
|
+
if (c.tag === V_TEXT_NODE) {
|
|
1796
|
+
innerHTML += encodeHTML(c.html);
|
|
1797
|
+
} else {
|
|
1798
|
+
innerHTML += c.html;
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
if (c.tag === V_TEXT_NODE && prevChild && prevChild.tag === V_TEXT_NODE) {
|
|
1802
|
+
prevChild.html += c.html;
|
|
1803
|
+
} else {
|
|
1804
|
+
if (!newChildren) newChildren = [];
|
|
1805
|
+
newChildren.push(c);
|
|
1806
|
+
prevChild = c;
|
|
1807
|
+
}
|
|
1808
|
+
if (c.compareKey) {
|
|
1809
|
+
if (!reused) reused = {};
|
|
1810
|
+
reused[c.compareKey] = (reused[c.compareKey] || 0) + 1;
|
|
1811
|
+
reusedTotal++;
|
|
1812
|
+
}
|
|
1813
|
+
if (c.views) {
|
|
1814
|
+
if (!viewList) viewList = [];
|
|
1815
|
+
viewList.push(...c.views);
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
hasSpecials = specials || void 0;
|
|
1820
|
+
for (const prop in propsObj) {
|
|
1821
|
+
let value = propsObj[prop];
|
|
1822
|
+
if (value === false || value == null) {
|
|
1823
|
+
if (!specialsObj[prop]) {
|
|
1824
|
+
delete propsObj[prop];
|
|
1825
|
+
}
|
|
1826
|
+
continue;
|
|
1827
|
+
} else if (value === true) {
|
|
1828
|
+
propsObj[prop] = value = specialsObj[prop] ? value : "";
|
|
1829
|
+
}
|
|
1830
|
+
if ((prop === "#" || prop === "id" || prop === TAG_STATIC_KEY) && !compareKey) {
|
|
1831
|
+
compareKey = value;
|
|
1832
|
+
if (prop !== "id") {
|
|
1833
|
+
delete propsObj[prop];
|
|
1834
|
+
continue;
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
if (prop === LARK_VIEW && value) {
|
|
1838
|
+
const parsed = parseUri(value);
|
|
1839
|
+
isLarkView2 = parsed.path;
|
|
1840
|
+
if (!viewList) viewList = [];
|
|
1841
|
+
viewList.push([
|
|
1842
|
+
isLarkView2,
|
|
1843
|
+
propsObj["lark-owner"],
|
|
1844
|
+
value,
|
|
1845
|
+
parsed.params
|
|
1846
|
+
]);
|
|
1847
|
+
if (!compareKey) {
|
|
1848
|
+
compareKey = tag + SPLITTER + isLarkView2;
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
if (prop === "value" && tag === "textarea") {
|
|
1852
|
+
innerHTML = String(value);
|
|
1853
|
+
delete propsObj[prop];
|
|
1854
|
+
continue;
|
|
1855
|
+
}
|
|
1856
|
+
attrs += ` ${prop}="${value && encodeHTML(value)}"`;
|
|
1857
|
+
}
|
|
1858
|
+
return {
|
|
1859
|
+
tag,
|
|
1860
|
+
html: innerHTML,
|
|
1861
|
+
attrs,
|
|
1862
|
+
attrsMap: propsObj,
|
|
1863
|
+
attrsSpecials: specialsObj,
|
|
1864
|
+
hasSpecials,
|
|
1865
|
+
children: newChildren,
|
|
1866
|
+
compareKey,
|
|
1867
|
+
reused,
|
|
1868
|
+
reusedTotal,
|
|
1869
|
+
views: viewList,
|
|
1870
|
+
selfClose: unary,
|
|
1871
|
+
isLarkView: isLarkView2
|
|
1872
|
+
};
|
|
1873
|
+
}
|
|
1874
|
+
function isSameVDomNode(a, b) {
|
|
1875
|
+
return a.compareKey && b.compareKey === a.compareKey || !a.compareKey && !b.compareKey && a.tag === b.tag || a.tag === SPLITTER || b.tag === SPLITTER;
|
|
1876
|
+
}
|
|
1877
|
+
function getKeyNodes(list, nodes, start, end, realEnd) {
|
|
1878
|
+
const keyedNodes = {};
|
|
1879
|
+
for (let i = end, re = realEnd; i >= start; i--, re--) {
|
|
1880
|
+
const oc = list[i];
|
|
1881
|
+
const cKey = oc.compareKey;
|
|
1882
|
+
if (cKey) {
|
|
1883
|
+
const bucket = keyedNodes[cKey] || (keyedNodes[cKey] = []);
|
|
1884
|
+
bucket.push(nodes[re]);
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
return keyedNodes;
|
|
1888
|
+
}
|
|
1889
|
+
function vdomCreateNode(vnode, owner, ref) {
|
|
1890
|
+
const tag = vnode.tag;
|
|
1891
|
+
if (tag === V_TEXT_NODE) {
|
|
1892
|
+
return document.createTextNode(vnode.html);
|
|
1893
|
+
}
|
|
1894
|
+
const sTag = typeof tag === "string" ? tag : tag.toString();
|
|
1895
|
+
const ns = VDOM_NS_MAP[sTag] || owner.namespaceURI;
|
|
1896
|
+
const el = document.createElementNS(ns, sTag);
|
|
1897
|
+
vdomSetAttributes(el, vnode, ref);
|
|
1898
|
+
el.innerHTML = vnode.html;
|
|
1899
|
+
return el;
|
|
1900
|
+
}
|
|
1901
|
+
function vdomSetAttributes(realNode, newVDom, ref, lastVDom) {
|
|
1902
|
+
let changed = 0;
|
|
1903
|
+
const nMap = newVDom.attrsMap || {};
|
|
1904
|
+
const nsMap = newVDom.attrsSpecials || {};
|
|
1905
|
+
if (lastVDom) {
|
|
1906
|
+
const oMap = lastVDom.attrsMap || {};
|
|
1907
|
+
const osMap = lastVDom.attrsSpecials || {};
|
|
1908
|
+
for (const key in oMap) {
|
|
1909
|
+
if (!hasOwnProperty(nMap, key)) {
|
|
1910
|
+
changed = 1;
|
|
1911
|
+
const sValue = osMap[key];
|
|
1912
|
+
if (sValue) {
|
|
1913
|
+
if (ref) {
|
|
1914
|
+
ref.nodeProps.push([realNode, sValue, ""]);
|
|
1915
|
+
} else {
|
|
1916
|
+
Reflect.set(realNode, sValue, "");
|
|
1917
|
+
}
|
|
1918
|
+
} else {
|
|
1919
|
+
realNode.removeAttribute(key);
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
for (const key in nMap) {
|
|
1925
|
+
const value = nMap[key];
|
|
1926
|
+
const sKey = nsMap[key];
|
|
1927
|
+
if (sKey) {
|
|
1928
|
+
if (Reflect.get(realNode, sKey) !== value) {
|
|
1929
|
+
changed = 1;
|
|
1930
|
+
if (ref) {
|
|
1931
|
+
ref.nodeProps.push([realNode, sKey, value]);
|
|
1932
|
+
} else {
|
|
1933
|
+
Reflect.set(realNode, sKey, value);
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
} else {
|
|
1937
|
+
const oldMap = lastVDom?.attrsMap;
|
|
1938
|
+
if (!oldMap || oldMap[key] !== value) {
|
|
1939
|
+
changed = 1;
|
|
1940
|
+
realNode.setAttribute(key, String(value ?? ""));
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
return changed;
|
|
1945
|
+
}
|
|
1946
|
+
function vdomSyncFormState(realNode, newVDom) {
|
|
1947
|
+
const specials = DOM_SPECIALS[realNode.nodeName];
|
|
1948
|
+
if (!specials) return 0;
|
|
1949
|
+
const nMap = newVDom.attrsMap || {};
|
|
1950
|
+
let result = 0;
|
|
1951
|
+
for (const prop of specials) {
|
|
1952
|
+
const newVal = nMap[prop];
|
|
1953
|
+
if (newVal !== void 0 && Reflect.get(realNode, prop) !== newVal) {
|
|
1954
|
+
result = 1;
|
|
1955
|
+
Reflect.set(realNode, prop, newVal);
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
return result;
|
|
1959
|
+
}
|
|
1960
|
+
function vdomSetNode(realNode, oldParent, lastVDom, newVDom, ref, frame, keys2, rootView, ready) {
|
|
1961
|
+
const lastTag = lastVDom.tag;
|
|
1962
|
+
const newTag = newVDom.tag;
|
|
1963
|
+
if (lastTag === V_TEXT_NODE || newTag === V_TEXT_NODE) {
|
|
1964
|
+
if (lastTag === newTag) {
|
|
1965
|
+
if (lastVDom.html !== newVDom.html) {
|
|
1966
|
+
ref.changed = 1;
|
|
1967
|
+
realNode.nodeValue = newVDom.html;
|
|
1968
|
+
}
|
|
1969
|
+
} else {
|
|
1970
|
+
ref.changed = 1;
|
|
1971
|
+
domUnmountFrames(frame, realNode);
|
|
1972
|
+
oldParent.replaceChild(vdomCreateNode(newVDom, oldParent, ref), realNode);
|
|
1973
|
+
}
|
|
1974
|
+
return;
|
|
1975
|
+
}
|
|
1976
|
+
if (lastTag === newTag) {
|
|
1977
|
+
const lastAMap = lastVDom.attrsMap || {};
|
|
1978
|
+
const newAMap = newVDom.attrsMap || {};
|
|
1979
|
+
if (lastVDom.compareKey && lastVDom.compareKey === newVDom.compareKey && !lastAMap["id"] && !newAMap["id"]) {
|
|
1980
|
+
return;
|
|
1981
|
+
}
|
|
1982
|
+
let attrChanged = 0;
|
|
1983
|
+
if (lastVDom.attrs !== newVDom.attrs || newVDom.hasSpecials) {
|
|
1984
|
+
attrChanged = vdomSetAttributes(
|
|
1985
|
+
realNode,
|
|
1986
|
+
newVDom,
|
|
1987
|
+
ref,
|
|
1988
|
+
lastVDom
|
|
1989
|
+
);
|
|
1990
|
+
if (attrChanged) ref.changed = 1;
|
|
1991
|
+
}
|
|
1992
|
+
let updateChildren = true;
|
|
1993
|
+
if (newVDom.isLarkView) {
|
|
1994
|
+
const oldFrameId = realNode.getAttribute("id") || "";
|
|
1995
|
+
const newViewPath = newVDom.isLarkView;
|
|
1996
|
+
const oldViewPath = lastVDom.isLarkView || "";
|
|
1997
|
+
if (oldFrameId && newViewPath === oldViewPath) {
|
|
1998
|
+
updateChildren = false;
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
vdomSyncFormState(realNode, newVDom);
|
|
2002
|
+
if (updateChildren && !newVDom.selfClose) {
|
|
2003
|
+
vdomSetChildNodes(
|
|
2004
|
+
realNode,
|
|
2005
|
+
lastVDom,
|
|
2006
|
+
newVDom,
|
|
2007
|
+
ref,
|
|
2008
|
+
frame,
|
|
2009
|
+
keys2,
|
|
2010
|
+
rootView,
|
|
2011
|
+
ready
|
|
2012
|
+
);
|
|
2013
|
+
}
|
|
2014
|
+
} else {
|
|
2015
|
+
ref.changed = 1;
|
|
2016
|
+
domUnmountFrames(frame, realNode);
|
|
2017
|
+
oldParent.replaceChild(vdomCreateNode(newVDom, oldParent, ref), realNode);
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
function vdomSetChildNodes(realNode, lastVDom, newVDom, ref, frame, keys2, view, ready) {
|
|
2021
|
+
if (!lastVDom) {
|
|
2022
|
+
ref.changed = 1;
|
|
2023
|
+
realNode.innerHTML = newVDom.html;
|
|
2024
|
+
return;
|
|
2025
|
+
}
|
|
2026
|
+
if (lastVDom.html === newVDom.html) {
|
|
2027
|
+
return;
|
|
2028
|
+
}
|
|
2029
|
+
const oldChildren = lastVDom.children;
|
|
2030
|
+
const newChildren = newVDom.children;
|
|
2031
|
+
const oldLen = oldChildren?.length || 0;
|
|
2032
|
+
const newLen = newChildren?.length || 0;
|
|
2033
|
+
if (oldLen === 0 && newLen === 0) return;
|
|
2034
|
+
const nodes = realNode.childNodes;
|
|
2035
|
+
let oldStart = 0;
|
|
2036
|
+
let oldEnd = oldLen - 1;
|
|
2037
|
+
let newStart = 0;
|
|
2038
|
+
let newEnd = newLen - 1;
|
|
2039
|
+
let realStart = oldStart;
|
|
2040
|
+
let realEnd = oldEnd;
|
|
2041
|
+
let keyedNodes;
|
|
2042
|
+
const oldReusedTotal = lastVDom.reusedTotal || 0;
|
|
2043
|
+
const newReusedTotal = newVDom.reusedTotal || 0;
|
|
2044
|
+
let oldStartNode = oldChildren?.[oldStart];
|
|
2045
|
+
let oldEndNode = oldChildren?.[oldEnd];
|
|
2046
|
+
let newStartNode = newChildren?.[newStart];
|
|
2047
|
+
let newEndNode = newChildren?.[newEnd];
|
|
2048
|
+
while (oldStart <= oldEnd && newStart <= newEnd) {
|
|
2049
|
+
if (!oldStartNode) {
|
|
2050
|
+
oldStartNode = oldChildren?.[++oldStart];
|
|
2051
|
+
realStart++;
|
|
2052
|
+
continue;
|
|
2053
|
+
}
|
|
2054
|
+
if (!oldEndNode) {
|
|
2055
|
+
oldEndNode = oldChildren?.[--oldEnd];
|
|
2056
|
+
realEnd--;
|
|
2057
|
+
continue;
|
|
2058
|
+
}
|
|
2059
|
+
if (isSameVDomNode(newStartNode, oldStartNode)) {
|
|
2060
|
+
if (newStartNode.tag === SPLITTER || oldStartNode.tag === SPLITTER) {
|
|
2061
|
+
ref.changed = 1;
|
|
2062
|
+
domUnmountFrames(frame, realNode);
|
|
2063
|
+
if (newStartNode.tag === SPLITTER) {
|
|
2064
|
+
realNode.innerHTML = newStartNode.html;
|
|
2065
|
+
} else {
|
|
2066
|
+
realNode.innerHTML = "";
|
|
2067
|
+
realNode.appendChild(vdomCreateNode(newStartNode, realNode, ref));
|
|
2068
|
+
}
|
|
2069
|
+
} else {
|
|
2070
|
+
vdomSetNode(
|
|
2071
|
+
nodes[realStart],
|
|
2072
|
+
realNode,
|
|
2073
|
+
oldStartNode,
|
|
2074
|
+
newStartNode,
|
|
2075
|
+
ref,
|
|
2076
|
+
frame,
|
|
2077
|
+
keys2,
|
|
2078
|
+
view,
|
|
2079
|
+
ready
|
|
2080
|
+
);
|
|
2081
|
+
}
|
|
2082
|
+
reduceCached(keyedNodes, oldStartNode, nodes[realStart]);
|
|
2083
|
+
realStart++;
|
|
2084
|
+
oldStartNode = oldChildren?.[++oldStart];
|
|
2085
|
+
newStartNode = newChildren?.[++newStart];
|
|
2086
|
+
} else if (isSameVDomNode(newEndNode, oldEndNode)) {
|
|
2087
|
+
if (newEndNode.tag === SPLITTER || oldEndNode.tag === SPLITTER) {
|
|
2088
|
+
ref.changed = 1;
|
|
2089
|
+
domUnmountFrames(frame, realNode);
|
|
2090
|
+
realNode.innerHTML = newEndNode.tag === SPLITTER ? newEndNode.html : "";
|
|
2091
|
+
if (newEndNode.tag !== SPLITTER) {
|
|
2092
|
+
realNode.appendChild(vdomCreateNode(newEndNode, realNode, ref));
|
|
2093
|
+
}
|
|
2094
|
+
} else {
|
|
2095
|
+
vdomSetNode(
|
|
2096
|
+
nodes[realEnd],
|
|
2097
|
+
realNode,
|
|
2098
|
+
oldEndNode,
|
|
2099
|
+
newEndNode,
|
|
2100
|
+
ref,
|
|
2101
|
+
frame,
|
|
2102
|
+
keys2,
|
|
2103
|
+
view,
|
|
2104
|
+
ready
|
|
2105
|
+
);
|
|
2106
|
+
}
|
|
2107
|
+
reduceCached(keyedNodes, oldEndNode, nodes[realEnd]);
|
|
2108
|
+
realEnd--;
|
|
2109
|
+
oldEndNode = oldChildren?.[--oldEnd];
|
|
2110
|
+
newEndNode = newChildren?.[--newEnd];
|
|
2111
|
+
} else if (isSameVDomNode(newEndNode, oldStartNode)) {
|
|
2112
|
+
if (newEndNode.tag === SPLITTER || oldStartNode.tag === SPLITTER) {
|
|
2113
|
+
ref.changed = 1;
|
|
2114
|
+
domUnmountFrames(frame, realNode);
|
|
2115
|
+
realNode.innerHTML = newEndNode.tag === SPLITTER ? newEndNode.html : "";
|
|
2116
|
+
if (newEndNode.tag !== SPLITTER) {
|
|
2117
|
+
realNode.appendChild(vdomCreateNode(newEndNode, realNode, ref));
|
|
2118
|
+
}
|
|
2119
|
+
} else {
|
|
2120
|
+
const oi = nodes[realStart];
|
|
2121
|
+
realNode.insertBefore(oi, nodes[realEnd + 1] || null);
|
|
2122
|
+
vdomSetNode(
|
|
2123
|
+
oi,
|
|
2124
|
+
realNode,
|
|
2125
|
+
oldStartNode,
|
|
2126
|
+
newEndNode,
|
|
2127
|
+
ref,
|
|
2128
|
+
frame,
|
|
2129
|
+
keys2,
|
|
2130
|
+
view,
|
|
2131
|
+
ready
|
|
2132
|
+
);
|
|
2133
|
+
}
|
|
2134
|
+
reduceCached(keyedNodes, oldStartNode, nodes[realStart]);
|
|
2135
|
+
realStart++;
|
|
2136
|
+
oldStartNode = oldChildren?.[++oldStart];
|
|
2137
|
+
newEndNode = newChildren?.[--newEnd];
|
|
2138
|
+
} else if (isSameVDomNode(newStartNode, oldEndNode)) {
|
|
2139
|
+
if (newStartNode.tag === SPLITTER || oldEndNode.tag === SPLITTER) {
|
|
2140
|
+
ref.changed = 1;
|
|
2141
|
+
domUnmountFrames(frame, realNode);
|
|
2142
|
+
realNode.innerHTML = newStartNode.tag === SPLITTER ? newStartNode.html : "";
|
|
2143
|
+
if (newStartNode.tag !== SPLITTER) {
|
|
2144
|
+
realNode.appendChild(vdomCreateNode(newStartNode, realNode, ref));
|
|
2145
|
+
}
|
|
2146
|
+
} else {
|
|
2147
|
+
const oi = nodes[realEnd];
|
|
2148
|
+
realNode.insertBefore(oi, nodes[realStart]);
|
|
2149
|
+
vdomSetNode(
|
|
2150
|
+
oi,
|
|
2151
|
+
realNode,
|
|
2152
|
+
oldEndNode,
|
|
2153
|
+
newStartNode,
|
|
2154
|
+
ref,
|
|
2155
|
+
frame,
|
|
2156
|
+
keys2,
|
|
2157
|
+
view,
|
|
2158
|
+
ready
|
|
2159
|
+
);
|
|
2160
|
+
}
|
|
2161
|
+
reduceCached(keyedNodes, oldEndNode, nodes[realEnd]);
|
|
2162
|
+
realEnd--;
|
|
2163
|
+
oldEndNode = oldChildren?.[--oldEnd];
|
|
2164
|
+
newStartNode = newChildren?.[++newStart];
|
|
2165
|
+
} else {
|
|
2166
|
+
if (!keyedNodes && newReusedTotal > 0 && oldReusedTotal > 0) {
|
|
2167
|
+
keyedNodes = getKeyNodes(
|
|
2168
|
+
oldChildren,
|
|
2169
|
+
nodes,
|
|
2170
|
+
oldStart,
|
|
2171
|
+
oldEnd,
|
|
2172
|
+
realEnd
|
|
2173
|
+
);
|
|
2174
|
+
}
|
|
2175
|
+
const cKey = newStartNode.compareKey;
|
|
2176
|
+
let found;
|
|
2177
|
+
let compareKey;
|
|
2178
|
+
if (cKey && keyedNodes) {
|
|
2179
|
+
found = keyedNodes[cKey];
|
|
2180
|
+
compareKey = void 0;
|
|
2181
|
+
while (found && found.length > 0) {
|
|
2182
|
+
compareKey = found.pop();
|
|
2183
|
+
if (compareKey) break;
|
|
2184
|
+
}
|
|
2185
|
+
if (found && found.length === 0) delete keyedNodes[cKey];
|
|
2186
|
+
}
|
|
2187
|
+
if (compareKey) {
|
|
2188
|
+
if (compareKey !== nodes[realStart]) {
|
|
2189
|
+
for (let j = oldStart + 1; j <= oldEnd; j++) {
|
|
2190
|
+
const oc = oldChildren?.[j];
|
|
2191
|
+
if (oc && nodes[realStart + (j - oldStart)] === compareKey) {
|
|
2192
|
+
oldChildren[j] = void 0;
|
|
2193
|
+
break;
|
|
2194
|
+
}
|
|
2195
|
+
}
|
|
2196
|
+
realNode.insertBefore(compareKey, nodes[realStart]);
|
|
2197
|
+
}
|
|
2198
|
+
vdomSetNode(
|
|
2199
|
+
compareKey,
|
|
2200
|
+
realNode,
|
|
2201
|
+
oldStartNode,
|
|
2202
|
+
newStartNode,
|
|
2203
|
+
ref,
|
|
2204
|
+
frame,
|
|
2205
|
+
keys2,
|
|
2206
|
+
view,
|
|
2207
|
+
ready
|
|
2208
|
+
);
|
|
2209
|
+
} else if (oldStartNode.compareKey && lastVDom.reused?.[oldStartNode.compareKey] && newVDom.reused?.[oldStartNode.compareKey] || nodes[realStart]?.id && realNode.querySelectorAll?.(
|
|
2210
|
+
`#${nodes[realStart].id}`
|
|
2211
|
+
)?.length && !newStartNode.isLarkView) {
|
|
2212
|
+
ref.changed = 1;
|
|
2213
|
+
const newNode = vdomCreateNode(newStartNode, realNode, ref);
|
|
2214
|
+
realNode.insertBefore(newNode, nodes[realStart]);
|
|
2215
|
+
realStart--;
|
|
2216
|
+
realEnd++;
|
|
2217
|
+
} else {
|
|
2218
|
+
vdomSetNode(
|
|
2219
|
+
nodes[realStart],
|
|
2220
|
+
realNode,
|
|
2221
|
+
oldStartNode,
|
|
2222
|
+
newStartNode,
|
|
2223
|
+
ref,
|
|
2224
|
+
frame,
|
|
2225
|
+
keys2,
|
|
2226
|
+
view,
|
|
2227
|
+
ready
|
|
2228
|
+
);
|
|
2229
|
+
}
|
|
2230
|
+
realStart++;
|
|
2231
|
+
oldStartNode = oldChildren?.[++oldStart];
|
|
2232
|
+
newStartNode = newChildren?.[++newStart];
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
if (newStart <= newEnd) {
|
|
2236
|
+
const refNode = nodes[realEnd + 1] || null;
|
|
2237
|
+
for (let i = newStart; i <= newEnd; i++) {
|
|
2238
|
+
ref.changed = 1;
|
|
2239
|
+
const nc = newChildren[i];
|
|
2240
|
+
if (nc.tag === SPLITTER) {
|
|
2241
|
+
domUnmountFrames(frame, realNode);
|
|
2242
|
+
realNode.innerHTML = nc.html;
|
|
2243
|
+
return;
|
|
2244
|
+
}
|
|
2245
|
+
const newNode = vdomCreateNode(nc, realNode, ref);
|
|
2246
|
+
realNode.insertBefore(newNode, refNode);
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
if (oldStart <= oldEnd) {
|
|
2250
|
+
for (let i = realEnd; i >= realStart; i--) {
|
|
2251
|
+
const node = nodes[i];
|
|
2252
|
+
if (node) {
|
|
2253
|
+
domUnmountFrames(frame, node);
|
|
2254
|
+
ref.changed = 1;
|
|
2255
|
+
realNode.removeChild(node);
|
|
2256
|
+
}
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
if (ref.asyncCount === 0) {
|
|
2260
|
+
callFunction(ready, []);
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
function reduceCached(keyedNodes, node, compared) {
|
|
2264
|
+
if (!keyedNodes || !node.compareKey) return;
|
|
2265
|
+
const bucket = keyedNodes[node.compareKey];
|
|
2266
|
+
if (bucket) {
|
|
2267
|
+
for (let i = bucket.length; i--; ) {
|
|
2268
|
+
if (bucket[i] === compared) {
|
|
2269
|
+
bucket[i] = void 0;
|
|
2270
|
+
break;
|
|
2271
|
+
}
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
function createVDomRef(viewId) {
|
|
2276
|
+
return {
|
|
2277
|
+
viewId,
|
|
2278
|
+
viewRenders: [],
|
|
2279
|
+
nodeProps: [],
|
|
2280
|
+
asyncCount: 0,
|
|
2281
|
+
changed: 0,
|
|
2282
|
+
domOps: []
|
|
2283
|
+
};
|
|
2284
|
+
}
|
|
2285
|
+
|
|
1667
2286
|
// src/updater.ts
|
|
1668
2287
|
var Updater = class {
|
|
1669
2288
|
/** View ID (same as owner frame ID) */
|
|
@@ -1686,6 +2305,8 @@ var Updater = class {
|
|
|
1686
2305
|
version = 0;
|
|
1687
2306
|
/** Snapshot of `version` taken by `snapshot()`, used by `altered()`. */
|
|
1688
2307
|
snapshotVersion;
|
|
2308
|
+
/** Last rendered VDOM tree (only used when virtualDom is enabled) */
|
|
2309
|
+
vdom;
|
|
1689
2310
|
constructor(viewId) {
|
|
1690
2311
|
this.viewId = viewId;
|
|
1691
2312
|
this.data = { vId: viewId };
|
|
@@ -1765,28 +2386,61 @@ var Updater = class {
|
|
|
1765
2386
|
if (changed && view && node && view.signature > 0 && frame) {
|
|
1766
2387
|
const template = view.template;
|
|
1767
2388
|
if (typeof template === "function") {
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
this.viewId,
|
|
1771
|
-
this.
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
2389
|
+
if (config.virtualDom) {
|
|
2390
|
+
const vdomTemplate = template;
|
|
2391
|
+
const newVDom = vdomTemplate(this.data, this.viewId, this.refData);
|
|
2392
|
+
const ref = createVDomRef(this.viewId);
|
|
2393
|
+
const ready = () => {
|
|
2394
|
+
this.vdom = newVDom;
|
|
2395
|
+
if (ref.changed || !view.rendered) {
|
|
2396
|
+
view.endUpdate(this.viewId);
|
|
2397
|
+
}
|
|
2398
|
+
for (const [el, prop, val] of ref.nodeProps) {
|
|
2399
|
+
Reflect.set(el, prop, val);
|
|
2400
|
+
}
|
|
2401
|
+
for (const v of ref.viewRenders) {
|
|
2402
|
+
if (v.render) {
|
|
2403
|
+
funcWithTry(v.render, [], v, noop);
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
};
|
|
2407
|
+
vdomSetChildNodes(
|
|
2408
|
+
node,
|
|
2409
|
+
this.vdom,
|
|
2410
|
+
newVDom,
|
|
2411
|
+
ref,
|
|
2412
|
+
frame,
|
|
2413
|
+
keys2,
|
|
2414
|
+
view,
|
|
2415
|
+
ready
|
|
2416
|
+
);
|
|
2417
|
+
if (ref.asyncCount === 0) {
|
|
2418
|
+
ready();
|
|
2419
|
+
}
|
|
2420
|
+
} else {
|
|
2421
|
+
const html = template(
|
|
2422
|
+
this.data,
|
|
2423
|
+
this.viewId,
|
|
2424
|
+
this.refData,
|
|
2425
|
+
encodeHTML,
|
|
2426
|
+
strSafe,
|
|
2427
|
+
encodeURIExtra,
|
|
2428
|
+
refFn,
|
|
2429
|
+
encodeQuote
|
|
2430
|
+
);
|
|
2431
|
+
const newDom = domGetNode(html, node);
|
|
2432
|
+
const ref = createDomRef();
|
|
2433
|
+
domSetChildNodes(node, newDom, ref, frame, keys2);
|
|
2434
|
+
applyIdUpdates(ref.idUpdates);
|
|
2435
|
+
applyDomOps(ref.domOps);
|
|
2436
|
+
for (const v of ref.views) {
|
|
2437
|
+
if (v.render) {
|
|
2438
|
+
funcWithTry(v.render, [], v, noop);
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
if (ref.hasChanged || !view.rendered) {
|
|
2442
|
+
view.endUpdate(this.viewId);
|
|
1786
2443
|
}
|
|
1787
|
-
}
|
|
1788
|
-
if (ref.hasChanged || !view.rendered) {
|
|
1789
|
-
view.endUpdate(this.viewId);
|
|
1790
2444
|
}
|
|
1791
2445
|
}
|
|
1792
2446
|
}
|
|
@@ -2137,17 +2791,16 @@ var View = class _View {
|
|
|
2137
2791
|
}
|
|
2138
2792
|
const makes = [];
|
|
2139
2793
|
oView.makes = makes;
|
|
2140
|
-
const proto = oView.prototype;
|
|
2141
2794
|
const eventsObject = {};
|
|
2142
2795
|
const eventsList = [];
|
|
2143
2796
|
const selectorObject = {};
|
|
2144
|
-
const mixins =
|
|
2797
|
+
const mixins = Reflect.get(oView.prototype, "mixins");
|
|
2145
2798
|
if (mixins && Array.isArray(mixins)) {
|
|
2146
2799
|
_View.mergeMixins(mixins, oView, makes);
|
|
2147
2800
|
}
|
|
2148
|
-
for (const p in
|
|
2149
|
-
if (!hasOwnProperty(
|
|
2150
|
-
const currentFn =
|
|
2801
|
+
for (const p in oView.prototype) {
|
|
2802
|
+
if (!hasOwnProperty(oView.prototype, p)) continue;
|
|
2803
|
+
const currentFn = Reflect.get(oView.prototype, p);
|
|
2151
2804
|
if (typeof currentFn !== "function") continue;
|
|
2152
2805
|
const matches = p.match(VIEW_EVENT_METHOD_REGEXP);
|
|
2153
2806
|
if (!matches) continue;
|
|
@@ -2189,29 +2842,30 @@ var View = class _View {
|
|
|
2189
2842
|
}
|
|
2190
2843
|
eventsObject[item] = (eventsObject[item] || 0) | mask;
|
|
2191
2844
|
const combinedKey = selectorOrCallback + SPLITTER + item;
|
|
2192
|
-
const existingFn =
|
|
2845
|
+
const existingFn = Reflect.get(oView.prototype, combinedKey);
|
|
2193
2846
|
if (!existingFn) {
|
|
2194
|
-
|
|
2847
|
+
Reflect.set(oView.prototype, combinedKey, currentFn);
|
|
2195
2848
|
} else if (typeof existingFn === "function") {
|
|
2196
2849
|
const mixinFn = currentFn;
|
|
2197
2850
|
const existingMixin = existingFn;
|
|
2198
2851
|
if (existingMixin.marker) {
|
|
2199
2852
|
if (mixinFn.marker) {
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2853
|
+
Reflect.set(
|
|
2854
|
+
oView.prototype,
|
|
2855
|
+
combinedKey,
|
|
2856
|
+
_View.processMixinsSameEvent(mixinFn, existingMixin)
|
|
2203
2857
|
);
|
|
2204
|
-
} else if (hasOwnProperty(
|
|
2205
|
-
|
|
2858
|
+
} else if (hasOwnProperty(oView.prototype, p)) {
|
|
2859
|
+
Reflect.set(oView.prototype, combinedKey, currentFn);
|
|
2206
2860
|
}
|
|
2207
2861
|
}
|
|
2208
2862
|
}
|
|
2209
2863
|
}
|
|
2210
2864
|
}
|
|
2211
|
-
_View.wrapMethod(
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2865
|
+
_View.wrapMethod(asRecord(oView.prototype), "render", "$renderWrap");
|
|
2866
|
+
Reflect.set(oView.prototype, "$evtObjMap", eventsObject);
|
|
2867
|
+
Reflect.set(oView.prototype, "$globalEvtList", eventsList);
|
|
2868
|
+
Reflect.set(oView.prototype, "$selMap", selectorObject);
|
|
2215
2869
|
return makes;
|
|
2216
2870
|
}
|
|
2217
2871
|
/**
|
|
@@ -2302,7 +2956,7 @@ var View = class _View {
|
|
|
2302
2956
|
this.signature++;
|
|
2303
2957
|
this.fire("render");
|
|
2304
2958
|
_View.destroyAllResources(this, false);
|
|
2305
|
-
const lookup = this;
|
|
2959
|
+
const lookup = asRecord(this);
|
|
2306
2960
|
const candidate = lookup[fnName];
|
|
2307
2961
|
const instanceFn = typeof candidate === "function" ? candidate : originalAsFn;
|
|
2308
2962
|
const fnToCall = instanceFn === wrapped ? originalAsFn : instanceFn;
|
|
@@ -2338,7 +2992,7 @@ var View = class _View {
|
|
|
2338
2992
|
* Merge an array of mixin objects into the view prototype.
|
|
2339
2993
|
*/
|
|
2340
2994
|
static mergeMixins(mixins, viewClass, makes) {
|
|
2341
|
-
const proto = viewClass.prototype;
|
|
2995
|
+
const proto = asRecord(viewClass.prototype);
|
|
2342
2996
|
const temp = {};
|
|
2343
2997
|
for (const node of mixins) {
|
|
2344
2998
|
for (const p in node) {
|
|
@@ -2429,17 +3083,15 @@ var View = class _View {
|
|
|
2429
3083
|
}
|
|
2430
3084
|
}
|
|
2431
3085
|
};
|
|
2432
|
-
const proto = ChildView.prototype;
|
|
2433
3086
|
for (const key in definedProps) {
|
|
2434
3087
|
if (hasOwnProperty(definedProps, key) && key !== "make") {
|
|
2435
|
-
|
|
3088
|
+
Reflect.set(ChildView.prototype, key, definedProps[key]);
|
|
2436
3089
|
}
|
|
2437
3090
|
}
|
|
2438
3091
|
if (statics) {
|
|
2439
|
-
const staticTarget = ChildView;
|
|
2440
3092
|
for (const key in statics) {
|
|
2441
3093
|
if (hasOwnProperty(statics, key)) {
|
|
2442
|
-
|
|
3094
|
+
Reflect.set(ChildView, key, statics[key]);
|
|
2443
3095
|
}
|
|
2444
3096
|
}
|
|
2445
3097
|
}
|
|
@@ -2458,53 +3110,6 @@ function defineView(props, statics) {
|
|
|
2458
3110
|
return View.extend(props, statics);
|
|
2459
3111
|
}
|
|
2460
3112
|
|
|
2461
|
-
// src/module-loader.ts
|
|
2462
|
-
var config = {
|
|
2463
|
-
rootId: "root",
|
|
2464
|
-
routeMode: "history",
|
|
2465
|
-
hashbang: "#!",
|
|
2466
|
-
error: (error) => {
|
|
2467
|
-
throw error;
|
|
2468
|
-
}
|
|
2469
|
-
};
|
|
2470
|
-
function use(names, callback) {
|
|
2471
|
-
const nameList = typeof names === "string" ? [names] : names;
|
|
2472
|
-
const loadPromise = (() => {
|
|
2473
|
-
if (config.require) {
|
|
2474
|
-
const result = config.require(nameList);
|
|
2475
|
-
if (result && typeof result.then === "function") {
|
|
2476
|
-
return result;
|
|
2477
|
-
}
|
|
2478
|
-
return Promise.resolve([]);
|
|
2479
|
-
}
|
|
2480
|
-
return Promise.all(
|
|
2481
|
-
nameList.map((name) => {
|
|
2482
|
-
const importPath = name.startsWith(".") || name.startsWith("/") ? name : `./${name}`;
|
|
2483
|
-
return import(
|
|
2484
|
-
/* @vite-ignore */
|
|
2485
|
-
/* webpackIgnore: true */
|
|
2486
|
-
importPath
|
|
2487
|
-
).then((mod) => {
|
|
2488
|
-
return mod && (mod["__esModule"] || // For Webpack
|
|
2489
|
-
typeof mod["default"] === "function") ? mod["default"] : mod;
|
|
2490
|
-
}).catch((err) => {
|
|
2491
|
-
const errorHandler = config.error;
|
|
2492
|
-
if (errorHandler) {
|
|
2493
|
-
errorHandler(err instanceof Error ? err : new Error(String(err)));
|
|
2494
|
-
}
|
|
2495
|
-
return void 0;
|
|
2496
|
-
});
|
|
2497
|
-
})
|
|
2498
|
-
);
|
|
2499
|
-
})();
|
|
2500
|
-
if (callback) {
|
|
2501
|
-
loadPromise.then((modules) => {
|
|
2502
|
-
callback(...modules);
|
|
2503
|
-
});
|
|
2504
|
-
}
|
|
2505
|
-
return loadPromise;
|
|
2506
|
-
}
|
|
2507
|
-
|
|
2508
3113
|
// src/view-registry.ts
|
|
2509
3114
|
var viewClassRegistry = {};
|
|
2510
3115
|
function getViewClass(path) {
|
|
@@ -2651,9 +3256,15 @@ var Frame = class _Frame extends EventEmitter {
|
|
|
2651
3256
|
*/
|
|
2652
3257
|
doMountView(ViewClass, params, node, sign) {
|
|
2653
3258
|
if (sign !== this.signature) return;
|
|
2654
|
-
const
|
|
2655
|
-
const
|
|
2656
|
-
const view = new
|
|
3259
|
+
const mixinConstructors = View.prepare(ViewClass);
|
|
3260
|
+
const Constructor = ViewClass;
|
|
3261
|
+
const view = new Constructor(
|
|
3262
|
+
this.id,
|
|
3263
|
+
this,
|
|
3264
|
+
params,
|
|
3265
|
+
node,
|
|
3266
|
+
mixinConstructors
|
|
3267
|
+
);
|
|
2657
3268
|
this.viewInstance = view;
|
|
2658
3269
|
view.signature = 1;
|
|
2659
3270
|
View.delegateEvents(view);
|
|
@@ -2814,8 +3425,7 @@ var Frame = class _Frame extends EventEmitter {
|
|
|
2814
3425
|
let result;
|
|
2815
3426
|
const view = this.view;
|
|
2816
3427
|
if (view && view.rendered) {
|
|
2817
|
-
const
|
|
2818
|
-
const fn = lookup[name];
|
|
3428
|
+
const fn = Reflect.get(view, name);
|
|
2819
3429
|
if (typeof fn === "function") {
|
|
2820
3430
|
result = funcWithTry(fn, args || [], view, noop);
|
|
2821
3431
|
}
|
|
@@ -3370,7 +3980,7 @@ var Service = class {
|
|
|
3370
3980
|
}
|
|
3371
3981
|
const cached = this._payloadCache.get(cacheKey);
|
|
3372
3982
|
if (cached && cached.cacheInfo) {
|
|
3373
|
-
if (now() - cached.cacheInfo.time > cache) {
|
|
3983
|
+
if (Date.now() - cached.cacheInfo.time > cache) {
|
|
3374
3984
|
this._payloadCache.del(cacheKey);
|
|
3375
3985
|
return void 0;
|
|
3376
3986
|
}
|
|
@@ -3528,7 +4138,7 @@ function serviceSend(service, attrs, done, flag, save) {
|
|
|
3528
4138
|
const list = pendingCacheKeys[cacheKey];
|
|
3529
4139
|
const entity = list.entity;
|
|
3530
4140
|
if (entity instanceof Payload && entity.cacheInfo) {
|
|
3531
|
-
entity.cacheInfo.time = now();
|
|
4141
|
+
entity.cacheInfo.time = Date.now();
|
|
3532
4142
|
internals.payloadCache.set(cacheKey, entity);
|
|
3533
4143
|
}
|
|
3534
4144
|
Reflect.deleteProperty(pendingCacheKeys, cacheKey);
|
|
@@ -3546,20 +4156,19 @@ function serviceSend(service, attrs, done, flag, save) {
|
|
|
3546
4156
|
}
|
|
3547
4157
|
}
|
|
3548
4158
|
|
|
3549
|
-
// src/
|
|
3550
|
-
var
|
|
3551
|
-
MSG_PING: "
|
|
3552
|
-
MSG_PONG: "
|
|
3553
|
-
MSG_REQUEST_TREE: "
|
|
3554
|
-
MSG_TREE: "
|
|
3555
|
-
MSG_TREE_DELTA: "
|
|
4159
|
+
// src/devtool.ts
|
|
4160
|
+
var FrameDevtoolBridge = {
|
|
4161
|
+
MSG_PING: "LARK_DEVTOOL_PING",
|
|
4162
|
+
MSG_PONG: "LARK_DEVTOOL_PONG",
|
|
4163
|
+
MSG_REQUEST_TREE: "LARK_DEVTOOL_REQUEST_TREE",
|
|
4164
|
+
MSG_TREE: "LARK_DEVTOOL_TREE",
|
|
4165
|
+
MSG_TREE_DELTA: "LARK_DEVTOOL_TREE_DELTA"
|
|
3556
4166
|
};
|
|
3557
4167
|
function serializeView(view) {
|
|
3558
4168
|
const evtMap = view.eventObjectMap;
|
|
3559
4169
|
const eventMethodKeys = evtMap ? Object.keys(evtMap) : [];
|
|
3560
4170
|
const resourceKeys = view.resources ? Object.keys(view.resources) : [];
|
|
3561
|
-
const
|
|
3562
|
-
const hasAssign = typeof lookup["assign"] === "function";
|
|
4171
|
+
const hasAssign = typeof view["assign"] === "function";
|
|
3563
4172
|
let updaterData = null;
|
|
3564
4173
|
try {
|
|
3565
4174
|
const ref = view.updater?.refData;
|
|
@@ -3637,7 +4246,7 @@ function serializeFrameTree() {
|
|
|
3637
4246
|
}
|
|
3638
4247
|
var bridgeInstalled = false;
|
|
3639
4248
|
var lastTreeJson = "";
|
|
3640
|
-
function
|
|
4249
|
+
function installFrameDevtoolBridge() {
|
|
3641
4250
|
if (bridgeInstalled) return;
|
|
3642
4251
|
if (typeof window === "undefined") return;
|
|
3643
4252
|
bridgeInstalled = true;
|
|
@@ -3645,22 +4254,22 @@ function installFrameVisualizerBridge() {
|
|
|
3645
4254
|
const data = event.data;
|
|
3646
4255
|
if (!data || typeof data !== "object") return;
|
|
3647
4256
|
const type = data.type;
|
|
3648
|
-
if (type ===
|
|
4257
|
+
if (type === FrameDevtoolBridge.MSG_PING) {
|
|
3649
4258
|
const source = event.source;
|
|
3650
4259
|
if (source) {
|
|
3651
4260
|
source.postMessage(
|
|
3652
|
-
{ type:
|
|
4261
|
+
{ type: FrameDevtoolBridge.MSG_PONG },
|
|
3653
4262
|
{ targetOrigin: "*" }
|
|
3654
4263
|
);
|
|
3655
4264
|
}
|
|
3656
4265
|
return;
|
|
3657
4266
|
}
|
|
3658
|
-
if (type ===
|
|
4267
|
+
if (type === FrameDevtoolBridge.MSG_REQUEST_TREE) {
|
|
3659
4268
|
const tree = serializeFrameTree();
|
|
3660
4269
|
const source = event.source;
|
|
3661
4270
|
if (source) {
|
|
3662
4271
|
source.postMessage(
|
|
3663
|
-
{ type:
|
|
4272
|
+
{ type: FrameDevtoolBridge.MSG_TREE, data: tree },
|
|
3664
4273
|
{ targetOrigin: "*" }
|
|
3665
4274
|
);
|
|
3666
4275
|
}
|
|
@@ -3680,7 +4289,7 @@ function pushTreeUpdate() {
|
|
|
3680
4289
|
if (treeJson !== lastTreeJson) {
|
|
3681
4290
|
lastTreeJson = treeJson;
|
|
3682
4291
|
window.parent.postMessage(
|
|
3683
|
-
{ type:
|
|
4292
|
+
{ type: FrameDevtoolBridge.MSG_TREE_DELTA, data: tree },
|
|
3684
4293
|
"*"
|
|
3685
4294
|
);
|
|
3686
4295
|
}
|
|
@@ -3693,7 +4302,7 @@ var taskIndex = 0;
|
|
|
3693
4302
|
var taskScheduled = false;
|
|
3694
4303
|
function executeTaskChunk(deadline) {
|
|
3695
4304
|
const hasDeadline = !!deadline;
|
|
3696
|
-
const startTime = now();
|
|
4305
|
+
const startTime = Date.now();
|
|
3697
4306
|
while (true) {
|
|
3698
4307
|
const fn = taskList[taskIndex];
|
|
3699
4308
|
if (!fn) {
|
|
@@ -3707,7 +4316,7 @@ function executeTaskChunk(deadline) {
|
|
|
3707
4316
|
scheduleTaskChunk();
|
|
3708
4317
|
return;
|
|
3709
4318
|
}
|
|
3710
|
-
} else if (now() - startTime > CALL_BREAK_TIME && taskList.length > taskIndex + 3) {
|
|
4319
|
+
} else if (Date.now() - startTime > CALL_BREAK_TIME && taskList.length > taskIndex + 3) {
|
|
3711
4320
|
scheduleTaskChunk();
|
|
3712
4321
|
return;
|
|
3713
4322
|
}
|
|
@@ -3839,10 +4448,10 @@ function waitZoneViewsRendered(viewId, timeout) {
|
|
|
3839
4448
|
timeout = 30 * 1e3;
|
|
3840
4449
|
}
|
|
3841
4450
|
const checkFrame = Frame.get(viewId);
|
|
3842
|
-
const endTime = now() + timeout;
|
|
4451
|
+
const endTime = Date.now() + timeout;
|
|
3843
4452
|
return new Promise((resolve) => {
|
|
3844
4453
|
const check = () => {
|
|
3845
|
-
const currentTime = now();
|
|
4454
|
+
const currentTime = Date.now();
|
|
3846
4455
|
if (currentTime > endTime || !checkFrame) {
|
|
3847
4456
|
resolve(WAIT_TIMEOUT_OR_NOT_FOUND);
|
|
3848
4457
|
} else if (checkFrame.childrenCount === checkFrame.readyCount) {
|
|
@@ -3904,7 +4513,7 @@ var Framework = {
|
|
|
3904
4513
|
booted3 = true;
|
|
3905
4514
|
markBooted();
|
|
3906
4515
|
markRouterBooted();
|
|
3907
|
-
|
|
4516
|
+
installFrameDevtoolBridge();
|
|
3908
4517
|
const rootFrame2 = Frame.createRoot(config.rootId);
|
|
3909
4518
|
Router._bind();
|
|
3910
4519
|
const defaultView = config.defaultView || "";
|
|
@@ -4178,7 +4787,6 @@ export {
|
|
|
4178
4787
|
EventDelegator,
|
|
4179
4788
|
EventEmitter,
|
|
4180
4789
|
Frame,
|
|
4181
|
-
FrameVisualBridge,
|
|
4182
4790
|
Framework,
|
|
4183
4791
|
LARK_VIEW,
|
|
4184
4792
|
Payload,
|
|
@@ -4195,10 +4803,10 @@ export {
|
|
|
4195
4803
|
bindStore,
|
|
4196
4804
|
computed,
|
|
4197
4805
|
create,
|
|
4806
|
+
createVDomRef,
|
|
4198
4807
|
defineView,
|
|
4199
4808
|
config as frameworkConfig,
|
|
4200
4809
|
getRouteMode,
|
|
4201
|
-
installFrameVisualizerBridge,
|
|
4202
4810
|
invalidateViewClass,
|
|
4203
4811
|
mark,
|
|
4204
4812
|
markBooted,
|
|
@@ -4207,8 +4815,8 @@ export {
|
|
|
4207
4815
|
registerViewClass,
|
|
4208
4816
|
resetProjectsMap,
|
|
4209
4817
|
safeguard,
|
|
4210
|
-
serializeFrameTree,
|
|
4211
4818
|
unmark,
|
|
4212
4819
|
use,
|
|
4213
|
-
useUrlState
|
|
4820
|
+
useUrlState,
|
|
4821
|
+
vdomCreate
|
|
4214
4822
|
};
|