@lark.js/mvc 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/devtool.cjs +272 -257
- package/dist/devtool.js +273 -258
- package/dist/index.cjs +278 -269
- package/dist/index.d.cts +61 -2
- package/dist/index.d.ts +61 -2
- package/dist/index.js +277 -269
- package/dist/rspack.cjs +8 -4
- package/dist/rspack.js +8 -4
- package/dist/runtime.js +1 -1
- package/dist/vite.cjs +51 -5
- package/dist/vite.d.cts +7 -1
- package/dist/vite.d.ts +7 -1
- package/dist/vite.js +53 -4
- package/dist/webpack.cjs +8 -4
- package/dist/webpack.js +8 -4
- package/package.json +1 -1
- package/src/client.d.ts +8 -0
- /package/dist/{chunk-RIV4NK3K.js → chunk-66OZBBSP.js} +0 -0
package/dist/index.js
CHANGED
|
@@ -21,7 +21,6 @@ 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
23
|
var V_TEXT_NODE = 0;
|
|
24
|
-
var TAG_STATIC_KEY = "_";
|
|
25
24
|
var VDOM_NS_MAP = {
|
|
26
25
|
svg: SVG_NS,
|
|
27
26
|
math: MATH_NS
|
|
@@ -1827,7 +1826,7 @@ function vdomCreate(tag, props, children, specials) {
|
|
|
1827
1826
|
} else if (value === true) {
|
|
1828
1827
|
propsObj[prop] = value = specialsObj[prop] ? value : "";
|
|
1829
1828
|
}
|
|
1830
|
-
if ((prop === "#" || prop === "id"
|
|
1829
|
+
if ((prop === "#" || prop === "id") && !compareKey) {
|
|
1831
1830
|
compareKey = value;
|
|
1832
1831
|
if (prop !== "id") {
|
|
1833
1832
|
delete propsObj[prop];
|
|
@@ -1874,18 +1873,6 @@ function vdomCreate(tag, props, children, specials) {
|
|
|
1874
1873
|
function isSameVDomNode(a, b) {
|
|
1875
1874
|
return a.compareKey && b.compareKey === a.compareKey || !a.compareKey && !b.compareKey && a.tag === b.tag || a.tag === SPLITTER || b.tag === SPLITTER;
|
|
1876
1875
|
}
|
|
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
1876
|
function vdomCreateNode(vnode, owner, ref) {
|
|
1890
1877
|
const tag = vnode.tag;
|
|
1891
1878
|
if (tag === V_TEXT_NODE) {
|
|
@@ -1974,9 +1961,10 @@ function vdomSetNode(realNode, oldParent, lastVDom, newVDom, ref, frame, keys2,
|
|
|
1974
1961
|
return;
|
|
1975
1962
|
}
|
|
1976
1963
|
if (lastTag === newTag) {
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1964
|
+
if (lastVDom.attrs === newVDom.attrs && lastVDom.html === newVDom.html) {
|
|
1965
|
+
if (newVDom.hasSpecials) {
|
|
1966
|
+
vdomSyncFormState(realNode, newVDom);
|
|
1967
|
+
}
|
|
1980
1968
|
return;
|
|
1981
1969
|
}
|
|
1982
1970
|
let attrChanged = 0;
|
|
@@ -2017,261 +2005,209 @@ function vdomSetNode(realNode, oldParent, lastVDom, newVDom, ref, frame, keys2,
|
|
|
2017
2005
|
oldParent.replaceChild(vdomCreateNode(newVDom, oldParent, ref), realNode);
|
|
2018
2006
|
}
|
|
2019
2007
|
}
|
|
2008
|
+
function computeLIS(sequence) {
|
|
2009
|
+
const len = sequence.length;
|
|
2010
|
+
if (len === 0) return [];
|
|
2011
|
+
const result = [];
|
|
2012
|
+
const tails = [];
|
|
2013
|
+
const predecessors = new Array(len);
|
|
2014
|
+
let lisLength = 0;
|
|
2015
|
+
for (let i = 0; i < len; i++) {
|
|
2016
|
+
const value = sequence[i];
|
|
2017
|
+
if (value < 0) continue;
|
|
2018
|
+
let lo = 0;
|
|
2019
|
+
let hi = lisLength;
|
|
2020
|
+
while (lo < hi) {
|
|
2021
|
+
const mid = lo + hi >>> 1;
|
|
2022
|
+
if (sequence[tails[mid]] < value) lo = mid + 1;
|
|
2023
|
+
else hi = mid;
|
|
2024
|
+
}
|
|
2025
|
+
tails[lo] = i;
|
|
2026
|
+
predecessors[i] = lo > 0 ? tails[lo - 1] : -1;
|
|
2027
|
+
if (lo === lisLength) lisLength++;
|
|
2028
|
+
}
|
|
2029
|
+
let cursor = tails[lisLength - 1];
|
|
2030
|
+
for (let i = lisLength - 1; i >= 0; i--) {
|
|
2031
|
+
result[i] = cursor;
|
|
2032
|
+
cursor = predecessors[cursor];
|
|
2033
|
+
}
|
|
2034
|
+
return result;
|
|
2035
|
+
}
|
|
2020
2036
|
function vdomSetChildNodes(realNode, lastVDom, newVDom, ref, frame, keys2, view, ready) {
|
|
2021
2037
|
if (!lastVDom) {
|
|
2022
2038
|
ref.changed = 1;
|
|
2023
2039
|
realNode.innerHTML = newVDom.html;
|
|
2040
|
+
callFunction(ready, []);
|
|
2024
2041
|
return;
|
|
2025
2042
|
}
|
|
2026
2043
|
if (lastVDom.html === newVDom.html) {
|
|
2044
|
+
callFunction(ready, []);
|
|
2027
2045
|
return;
|
|
2028
2046
|
}
|
|
2029
2047
|
const oldChildren = lastVDom.children;
|
|
2030
2048
|
const newChildren = newVDom.children;
|
|
2031
2049
|
const oldLen = oldChildren?.length || 0;
|
|
2032
2050
|
const newLen = newChildren?.length || 0;
|
|
2033
|
-
if (oldLen === 0 && newLen === 0)
|
|
2051
|
+
if (oldLen === 0 && newLen === 0) {
|
|
2052
|
+
callFunction(ready, []);
|
|
2053
|
+
return;
|
|
2054
|
+
}
|
|
2034
2055
|
const nodes = realNode.childNodes;
|
|
2035
|
-
|
|
2036
|
-
let
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
let
|
|
2041
|
-
let
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
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];
|
|
2056
|
+
const oldDomNodes = new Array(oldLen);
|
|
2057
|
+
for (let i = 0; i < oldLen; i++) {
|
|
2058
|
+
oldDomNodes[i] = nodes[i];
|
|
2059
|
+
}
|
|
2060
|
+
const usedOldDomNodes = /* @__PURE__ */ new Set();
|
|
2061
|
+
let headIdx = 0;
|
|
2062
|
+
let tailIdx = oldLen - 1;
|
|
2063
|
+
let newHead = 0;
|
|
2064
|
+
let newTail = newLen - 1;
|
|
2065
|
+
while (headIdx <= tailIdx && newHead <= newTail) {
|
|
2066
|
+
const oc = oldChildren[headIdx];
|
|
2067
|
+
const nc = newChildren[newHead];
|
|
2068
|
+
if (!isSameVDomNode(nc, oc)) break;
|
|
2069
|
+
if (nc.tag === SPLITTER || oc.tag === SPLITTER) break;
|
|
2070
|
+
vdomSetNode(
|
|
2071
|
+
oldDomNodes[headIdx],
|
|
2072
|
+
realNode,
|
|
2073
|
+
oc,
|
|
2074
|
+
nc,
|
|
2075
|
+
ref,
|
|
2076
|
+
frame,
|
|
2077
|
+
keys2,
|
|
2078
|
+
view,
|
|
2079
|
+
ready
|
|
2080
|
+
);
|
|
2081
|
+
usedOldDomNodes.add(oldDomNodes[headIdx]);
|
|
2082
|
+
headIdx++;
|
|
2083
|
+
newHead++;
|
|
2084
|
+
}
|
|
2085
|
+
while (headIdx <= tailIdx && newHead <= newTail) {
|
|
2086
|
+
const oc = oldChildren[tailIdx];
|
|
2087
|
+
const nc = newChildren[newTail];
|
|
2088
|
+
if (!isSameVDomNode(nc, oc)) break;
|
|
2089
|
+
if (nc.tag === SPLITTER || oc.tag === SPLITTER) break;
|
|
2090
|
+
vdomSetNode(
|
|
2091
|
+
oldDomNodes[tailIdx],
|
|
2092
|
+
realNode,
|
|
2093
|
+
oc,
|
|
2094
|
+
nc,
|
|
2095
|
+
ref,
|
|
2096
|
+
frame,
|
|
2097
|
+
keys2,
|
|
2098
|
+
view,
|
|
2099
|
+
ready
|
|
2100
|
+
);
|
|
2101
|
+
usedOldDomNodes.add(oldDomNodes[tailIdx]);
|
|
2102
|
+
tailIdx--;
|
|
2103
|
+
newTail--;
|
|
2104
|
+
}
|
|
2105
|
+
if (headIdx > tailIdx && newHead > newTail) {
|
|
2106
|
+
if (ref.asyncCount === 0) callFunction(ready, []);
|
|
2107
|
+
return;
|
|
2108
|
+
}
|
|
2109
|
+
const keyMap = {};
|
|
2110
|
+
for (let i = headIdx; i <= tailIdx; i++) {
|
|
2111
|
+
const c = oldChildren[i];
|
|
2112
|
+
if (c?.compareKey) {
|
|
2113
|
+
if (!keyMap[c.compareKey]) keyMap[c.compareKey] = [];
|
|
2114
|
+
keyMap[c.compareKey].push({ domNode: oldDomNodes[i], vdomNode: c });
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
const newRemaining = newTail - newHead + 1;
|
|
2118
|
+
const sequence = new Array(newRemaining);
|
|
2119
|
+
for (let i = 0; i < newRemaining; i++) {
|
|
2120
|
+
const nc = newChildren[newHead + i];
|
|
2121
|
+
const cKey = nc.compareKey;
|
|
2122
|
+
const entries = cKey ? keyMap[cKey] : void 0;
|
|
2123
|
+
if (entries && entries.length > 0) {
|
|
2124
|
+
const entry = entries.shift();
|
|
2125
|
+
if (entries.length === 0) delete keyMap[cKey];
|
|
2126
|
+
const oldIdx = oldChildren.indexOf(entry.vdomNode, headIdx);
|
|
2127
|
+
sequence[i] = oldIdx >= 0 ? oldIdx : -1;
|
|
2128
|
+
usedOldDomNodes.add(entry.domNode);
|
|
2165
2129
|
} else {
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
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) {
|
|
2130
|
+
sequence[i] = -1;
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
if (newHead > newTail) {
|
|
2134
|
+
for (let i = 0; i < oldLen; i++) {
|
|
2135
|
+
const domNode = oldDomNodes[i];
|
|
2136
|
+
if (domNode && !usedOldDomNodes.has(domNode) && domNode.parentNode === realNode) {
|
|
2137
|
+
domUnmountFrames(frame, domNode);
|
|
2212
2138
|
ref.changed = 1;
|
|
2213
|
-
|
|
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
|
-
);
|
|
2139
|
+
realNode.removeChild(domNode);
|
|
2229
2140
|
}
|
|
2230
|
-
realStart++;
|
|
2231
|
-
oldStartNode = oldChildren?.[++oldStart];
|
|
2232
|
-
newStartNode = newChildren?.[++newStart];
|
|
2233
2141
|
}
|
|
2142
|
+
if (ref.asyncCount === 0) callFunction(ready, []);
|
|
2143
|
+
return;
|
|
2144
|
+
}
|
|
2145
|
+
if (headIdx > tailIdx) {
|
|
2146
|
+
const insertRef = tailIdx < oldLen ? oldDomNodes[tailIdx + 1] ?? null : null;
|
|
2147
|
+
for (let i = newHead; i <= newTail; i++) {
|
|
2148
|
+
ref.changed = 1;
|
|
2149
|
+
const newNode = vdomCreateNode(newChildren[i], realNode, ref);
|
|
2150
|
+
realNode.insertBefore(newNode, insertRef);
|
|
2151
|
+
}
|
|
2152
|
+
if (ref.asyncCount === 0) callFunction(ready, []);
|
|
2153
|
+
return;
|
|
2234
2154
|
}
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2155
|
+
const lis = computeLIS(sequence);
|
|
2156
|
+
let lisCursor = lis.length - 1;
|
|
2157
|
+
let nextNode = tailIdx + 1 < oldLen ? oldDomNodes[tailIdx + 1] : null;
|
|
2158
|
+
for (let j = newRemaining - 1; j >= 0; j--) {
|
|
2159
|
+
const newIdx = newHead + j;
|
|
2160
|
+
const nc = newChildren[newIdx];
|
|
2161
|
+
if (lisCursor >= 0 && lis[lisCursor] === j) {
|
|
2162
|
+
const oldIdx = sequence[j];
|
|
2163
|
+
vdomSetNode(
|
|
2164
|
+
oldDomNodes[oldIdx],
|
|
2165
|
+
realNode,
|
|
2166
|
+
oldChildren[oldIdx],
|
|
2167
|
+
nc,
|
|
2168
|
+
ref,
|
|
2169
|
+
frame,
|
|
2170
|
+
keys2,
|
|
2171
|
+
view,
|
|
2172
|
+
ready
|
|
2173
|
+
);
|
|
2174
|
+
nextNode = oldDomNodes[oldIdx];
|
|
2175
|
+
lisCursor--;
|
|
2176
|
+
} else if (sequence[j] >= 0) {
|
|
2177
|
+
const oldIdx = sequence[j];
|
|
2178
|
+
ref.changed = 1;
|
|
2179
|
+
realNode.insertBefore(oldDomNodes[oldIdx], nextNode);
|
|
2180
|
+
vdomSetNode(
|
|
2181
|
+
oldDomNodes[oldIdx],
|
|
2182
|
+
realNode,
|
|
2183
|
+
oldChildren[oldIdx],
|
|
2184
|
+
nc,
|
|
2185
|
+
ref,
|
|
2186
|
+
frame,
|
|
2187
|
+
keys2,
|
|
2188
|
+
view,
|
|
2189
|
+
ready
|
|
2190
|
+
);
|
|
2191
|
+
nextNode = oldDomNodes[oldIdx];
|
|
2192
|
+
} else {
|
|
2238
2193
|
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
2194
|
const newNode = vdomCreateNode(nc, realNode, ref);
|
|
2246
|
-
realNode.insertBefore(newNode,
|
|
2195
|
+
realNode.insertBefore(newNode, nextNode);
|
|
2196
|
+
nextNode = newNode;
|
|
2247
2197
|
}
|
|
2248
2198
|
}
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
realNode.removeChild(node);
|
|
2256
|
-
}
|
|
2199
|
+
for (let i = 0; i < oldLen; i++) {
|
|
2200
|
+
const domNode = oldDomNodes[i];
|
|
2201
|
+
if (domNode && !usedOldDomNodes.has(domNode) && domNode.parentNode === realNode) {
|
|
2202
|
+
domUnmountFrames(frame, domNode);
|
|
2203
|
+
ref.changed = 1;
|
|
2204
|
+
realNode.removeChild(domNode);
|
|
2257
2205
|
}
|
|
2258
2206
|
}
|
|
2259
2207
|
if (ref.asyncCount === 0) {
|
|
2260
2208
|
callFunction(ready, []);
|
|
2261
2209
|
}
|
|
2262
2210
|
}
|
|
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
2211
|
function createVDomRef(viewId) {
|
|
2276
2212
|
return {
|
|
2277
2213
|
viewId,
|
|
@@ -2414,9 +2350,6 @@ var Updater = class {
|
|
|
2414
2350
|
view,
|
|
2415
2351
|
ready
|
|
2416
2352
|
);
|
|
2417
|
-
if (ref.asyncCount === 0) {
|
|
2418
|
-
ready();
|
|
2419
|
-
}
|
|
2420
2353
|
} else {
|
|
2421
2354
|
const html = template(
|
|
2422
2355
|
this.data,
|
|
@@ -2515,6 +2448,63 @@ var Updater = class {
|
|
|
2515
2448
|
}
|
|
2516
2449
|
};
|
|
2517
2450
|
|
|
2451
|
+
// src/view-registry.ts
|
|
2452
|
+
var viewClassRegistry = {};
|
|
2453
|
+
function getViewClass(path) {
|
|
2454
|
+
return viewClassRegistry[path];
|
|
2455
|
+
}
|
|
2456
|
+
function registerViewClass(viewPath, ViewClass) {
|
|
2457
|
+
const parsed = parseUri(viewPath);
|
|
2458
|
+
const path = parsed.path;
|
|
2459
|
+
if (path) {
|
|
2460
|
+
viewClassRegistry[path] = ViewClass;
|
|
2461
|
+
}
|
|
2462
|
+
}
|
|
2463
|
+
function invalidateViewClass(viewPath) {
|
|
2464
|
+
const parsed = parseUri(viewPath);
|
|
2465
|
+
const path = parsed.path;
|
|
2466
|
+
if (path) {
|
|
2467
|
+
Reflect.deleteProperty(viewClassRegistry, path);
|
|
2468
|
+
}
|
|
2469
|
+
}
|
|
2470
|
+
function getViewClassRegistry() {
|
|
2471
|
+
return viewClassRegistry;
|
|
2472
|
+
}
|
|
2473
|
+
|
|
2474
|
+
// src/hmr.ts
|
|
2475
|
+
function reloadViews(viewPath) {
|
|
2476
|
+
const allFrames = Frame.getAll();
|
|
2477
|
+
const toReload = [];
|
|
2478
|
+
for (const [, frame] of allFrames) {
|
|
2479
|
+
if (frame.viewPath) {
|
|
2480
|
+
const parsed = parseUri(frame.viewPath);
|
|
2481
|
+
if (parsed.path === viewPath) {
|
|
2482
|
+
toReload.push({ frame, fullPath: frame.viewPath });
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
for (const { frame, fullPath } of toReload) {
|
|
2487
|
+
frame.mountView(fullPath);
|
|
2488
|
+
}
|
|
2489
|
+
}
|
|
2490
|
+
function acceptView(hot, viewPath) {
|
|
2491
|
+
hot.accept((newModule) => {
|
|
2492
|
+
const candidate = newModule?.default ?? newModule;
|
|
2493
|
+
if (typeof candidate === "function") {
|
|
2494
|
+
const NewViewClass = candidate;
|
|
2495
|
+
registerViewClass(viewPath, NewViewClass);
|
|
2496
|
+
reloadViews(viewPath);
|
|
2497
|
+
} else {
|
|
2498
|
+
hot.invalidate();
|
|
2499
|
+
}
|
|
2500
|
+
});
|
|
2501
|
+
}
|
|
2502
|
+
function disposeView(hot, viewPath) {
|
|
2503
|
+
hot.dispose(() => {
|
|
2504
|
+
invalidateViewClass(viewPath);
|
|
2505
|
+
});
|
|
2506
|
+
}
|
|
2507
|
+
|
|
2518
2508
|
// src/view.ts
|
|
2519
2509
|
var VIEW_GLOBALS = {};
|
|
2520
2510
|
if (typeof window !== "undefined") {
|
|
@@ -3105,34 +3095,51 @@ var View = class _View {
|
|
|
3105
3095
|
_View.mergeMixins(mixins, this, existingCtors);
|
|
3106
3096
|
return this;
|
|
3107
3097
|
}
|
|
3098
|
+
// ============================================================
|
|
3099
|
+
// HMR support (static accept / dispose)
|
|
3100
|
+
// ============================================================
|
|
3101
|
+
/**
|
|
3102
|
+
* Set up HMR accept handler for this view module.
|
|
3103
|
+
*
|
|
3104
|
+
* When the module is hot-replaced, the new View class is extracted from
|
|
3105
|
+
* the new module, registered in the view registry, and all currently
|
|
3106
|
+
* mounted frames using this viewPath are re-mounted.
|
|
3107
|
+
*
|
|
3108
|
+
* No-op when `hot` is undefined (production / non-HMR environment).
|
|
3109
|
+
*
|
|
3110
|
+
* ```ts
|
|
3111
|
+
* if (import.meta.hot) {
|
|
3112
|
+
* HomeView.accept(import.meta.hot, 'home');
|
|
3113
|
+
* }
|
|
3114
|
+
* ```
|
|
3115
|
+
*/
|
|
3116
|
+
static accept(hot, viewPath) {
|
|
3117
|
+
if (!hot) return;
|
|
3118
|
+
acceptView(hot, viewPath);
|
|
3119
|
+
}
|
|
3120
|
+
/**
|
|
3121
|
+
* Set up HMR dispose handler for this view module.
|
|
3122
|
+
*
|
|
3123
|
+
* When the module is about to be replaced, the old View class is removed
|
|
3124
|
+
* from the registry so subsequent lookups don't return the stale class.
|
|
3125
|
+
*
|
|
3126
|
+
* No-op when `hot` is undefined (production / non-HMR environment).
|
|
3127
|
+
*
|
|
3128
|
+
* ```ts
|
|
3129
|
+
* if (import.meta.hot) {
|
|
3130
|
+
* HomeView.dispose(import.meta.hot, 'home');
|
|
3131
|
+
* }
|
|
3132
|
+
* ```
|
|
3133
|
+
*/
|
|
3134
|
+
static dispose(hot, viewPath) {
|
|
3135
|
+
if (!hot) return;
|
|
3136
|
+
disposeView(hot, viewPath);
|
|
3137
|
+
}
|
|
3108
3138
|
};
|
|
3109
3139
|
function defineView(props, statics) {
|
|
3110
3140
|
return View.extend(props, statics);
|
|
3111
3141
|
}
|
|
3112
3142
|
|
|
3113
|
-
// src/view-registry.ts
|
|
3114
|
-
var viewClassRegistry = {};
|
|
3115
|
-
function getViewClass(path) {
|
|
3116
|
-
return viewClassRegistry[path];
|
|
3117
|
-
}
|
|
3118
|
-
function registerViewClass(viewPath, ViewClass) {
|
|
3119
|
-
const parsed = parseUri(viewPath);
|
|
3120
|
-
const path = parsed.path;
|
|
3121
|
-
if (path) {
|
|
3122
|
-
viewClassRegistry[path] = ViewClass;
|
|
3123
|
-
}
|
|
3124
|
-
}
|
|
3125
|
-
function invalidateViewClass(viewPath) {
|
|
3126
|
-
const parsed = parseUri(viewPath);
|
|
3127
|
-
const path = parsed.path;
|
|
3128
|
-
if (path) {
|
|
3129
|
-
Reflect.deleteProperty(viewClassRegistry, path);
|
|
3130
|
-
}
|
|
3131
|
-
}
|
|
3132
|
-
function getViewClassRegistry() {
|
|
3133
|
-
return viewClassRegistry;
|
|
3134
|
-
}
|
|
3135
|
-
|
|
3136
3143
|
// src/frame.ts
|
|
3137
3144
|
var frameRegistry = /* @__PURE__ */ new Map();
|
|
3138
3145
|
var rootFrame;
|
|
@@ -4813,6 +4820,7 @@ export {
|
|
|
4813
4820
|
markRouterBooted,
|
|
4814
4821
|
nextCounter,
|
|
4815
4822
|
registerViewClass,
|
|
4823
|
+
reloadViews,
|
|
4816
4824
|
resetProjectsMap,
|
|
4817
4825
|
safeguard,
|
|
4818
4826
|
unmark,
|
package/dist/rspack.cjs
CHANGED
|
@@ -33,9 +33,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
33
33
|
));
|
|
34
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
35
|
|
|
36
|
-
// ../../node_modules/.pnpm/tsup@8.5.1_@swc+core@1.15.
|
|
36
|
+
// ../../node_modules/.pnpm/tsup@8.5.1_@swc+core@1.15.4_34a04ed47198e6dd24361ae1f6711a67/node_modules/tsup/assets/cjs_shims.js
|
|
37
37
|
var init_cjs_shims = __esm({
|
|
38
|
-
"../../node_modules/.pnpm/tsup@8.5.1_@swc+core@1.15.
|
|
38
|
+
"../../node_modules/.pnpm/tsup@8.5.1_@swc+core@1.15.4_34a04ed47198e6dd24361ae1f6711a67/node_modules/tsup/assets/cjs_shims.js"() {
|
|
39
39
|
"use strict";
|
|
40
40
|
}
|
|
41
41
|
});
|
|
@@ -15956,7 +15956,6 @@ var LarkMvcPlugin = class {
|
|
|
15956
15956
|
*/
|
|
15957
15957
|
apply(compiler) {
|
|
15958
15958
|
const { debug, virtualDom, useSwc, test, exclude } = this.options;
|
|
15959
|
-
const loaderPath = __filename;
|
|
15960
15959
|
compiler.options.module = compiler.options.module || {};
|
|
15961
15960
|
compiler.options.module.rules = compiler.options.module.rules || [];
|
|
15962
15961
|
compiler.options.module.rules.push({
|
|
@@ -15964,7 +15963,12 @@ var LarkMvcPlugin = class {
|
|
|
15964
15963
|
exclude,
|
|
15965
15964
|
use: [
|
|
15966
15965
|
{
|
|
15967
|
-
loader
|
|
15966
|
+
// Resolve the loader path (this file).
|
|
15967
|
+
// Deprecated implementation
|
|
15968
|
+
// isCjs() ? __filename : fileURLToPath(import.meta.url);
|
|
15969
|
+
// __filename is provided by tsup's ESM shim (shims: true) in ESM output,
|
|
15970
|
+
// and is a native CJS global in CJS output.
|
|
15971
|
+
loader: __filename,
|
|
15968
15972
|
options: { debug, virtualDom, useSwc }
|
|
15969
15973
|
}
|
|
15970
15974
|
]
|