@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.cjs
CHANGED
|
@@ -53,6 +53,7 @@ __export(index_exports, {
|
|
|
53
53
|
markRouterBooted: () => markRouterBooted,
|
|
54
54
|
nextCounter: () => nextCounter,
|
|
55
55
|
registerViewClass: () => registerViewClass,
|
|
56
|
+
reloadViews: () => reloadViews,
|
|
56
57
|
resetProjectsMap: () => resetProjectsMap,
|
|
57
58
|
safeguard: () => safeguard,
|
|
58
59
|
unmark: () => unmark,
|
|
@@ -85,7 +86,6 @@ var MATH_NS = "http://www.w3.org/1998/Math/MathML";
|
|
|
85
86
|
var TAG_NAME_REGEXP = /<([a-z][^/\0>\x20\t\r\n\f]+)/i;
|
|
86
87
|
var CALL_BREAK_TIME = 48;
|
|
87
88
|
var V_TEXT_NODE = 0;
|
|
88
|
-
var TAG_STATIC_KEY = "_";
|
|
89
89
|
var VDOM_NS_MAP = {
|
|
90
90
|
svg: SVG_NS,
|
|
91
91
|
math: MATH_NS
|
|
@@ -1891,7 +1891,7 @@ function vdomCreate(tag, props, children, specials) {
|
|
|
1891
1891
|
} else if (value === true) {
|
|
1892
1892
|
propsObj[prop] = value = specialsObj[prop] ? value : "";
|
|
1893
1893
|
}
|
|
1894
|
-
if ((prop === "#" || prop === "id"
|
|
1894
|
+
if ((prop === "#" || prop === "id") && !compareKey) {
|
|
1895
1895
|
compareKey = value;
|
|
1896
1896
|
if (prop !== "id") {
|
|
1897
1897
|
delete propsObj[prop];
|
|
@@ -1938,18 +1938,6 @@ function vdomCreate(tag, props, children, specials) {
|
|
|
1938
1938
|
function isSameVDomNode(a, b) {
|
|
1939
1939
|
return a.compareKey && b.compareKey === a.compareKey || !a.compareKey && !b.compareKey && a.tag === b.tag || a.tag === SPLITTER || b.tag === SPLITTER;
|
|
1940
1940
|
}
|
|
1941
|
-
function getKeyNodes(list, nodes, start, end, realEnd) {
|
|
1942
|
-
const keyedNodes = {};
|
|
1943
|
-
for (let i = end, re = realEnd; i >= start; i--, re--) {
|
|
1944
|
-
const oc = list[i];
|
|
1945
|
-
const cKey = oc.compareKey;
|
|
1946
|
-
if (cKey) {
|
|
1947
|
-
const bucket = keyedNodes[cKey] || (keyedNodes[cKey] = []);
|
|
1948
|
-
bucket.push(nodes[re]);
|
|
1949
|
-
}
|
|
1950
|
-
}
|
|
1951
|
-
return keyedNodes;
|
|
1952
|
-
}
|
|
1953
1941
|
function vdomCreateNode(vnode, owner, ref) {
|
|
1954
1942
|
const tag = vnode.tag;
|
|
1955
1943
|
if (tag === V_TEXT_NODE) {
|
|
@@ -2038,9 +2026,10 @@ function vdomSetNode(realNode, oldParent, lastVDom, newVDom, ref, frame, keys2,
|
|
|
2038
2026
|
return;
|
|
2039
2027
|
}
|
|
2040
2028
|
if (lastTag === newTag) {
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2029
|
+
if (lastVDom.attrs === newVDom.attrs && lastVDom.html === newVDom.html) {
|
|
2030
|
+
if (newVDom.hasSpecials) {
|
|
2031
|
+
vdomSyncFormState(realNode, newVDom);
|
|
2032
|
+
}
|
|
2044
2033
|
return;
|
|
2045
2034
|
}
|
|
2046
2035
|
let attrChanged = 0;
|
|
@@ -2081,261 +2070,209 @@ function vdomSetNode(realNode, oldParent, lastVDom, newVDom, ref, frame, keys2,
|
|
|
2081
2070
|
oldParent.replaceChild(vdomCreateNode(newVDom, oldParent, ref), realNode);
|
|
2082
2071
|
}
|
|
2083
2072
|
}
|
|
2073
|
+
function computeLIS(sequence) {
|
|
2074
|
+
const len = sequence.length;
|
|
2075
|
+
if (len === 0) return [];
|
|
2076
|
+
const result = [];
|
|
2077
|
+
const tails = [];
|
|
2078
|
+
const predecessors = new Array(len);
|
|
2079
|
+
let lisLength = 0;
|
|
2080
|
+
for (let i = 0; i < len; i++) {
|
|
2081
|
+
const value = sequence[i];
|
|
2082
|
+
if (value < 0) continue;
|
|
2083
|
+
let lo = 0;
|
|
2084
|
+
let hi = lisLength;
|
|
2085
|
+
while (lo < hi) {
|
|
2086
|
+
const mid = lo + hi >>> 1;
|
|
2087
|
+
if (sequence[tails[mid]] < value) lo = mid + 1;
|
|
2088
|
+
else hi = mid;
|
|
2089
|
+
}
|
|
2090
|
+
tails[lo] = i;
|
|
2091
|
+
predecessors[i] = lo > 0 ? tails[lo - 1] : -1;
|
|
2092
|
+
if (lo === lisLength) lisLength++;
|
|
2093
|
+
}
|
|
2094
|
+
let cursor = tails[lisLength - 1];
|
|
2095
|
+
for (let i = lisLength - 1; i >= 0; i--) {
|
|
2096
|
+
result[i] = cursor;
|
|
2097
|
+
cursor = predecessors[cursor];
|
|
2098
|
+
}
|
|
2099
|
+
return result;
|
|
2100
|
+
}
|
|
2084
2101
|
function vdomSetChildNodes(realNode, lastVDom, newVDom, ref, frame, keys2, view, ready) {
|
|
2085
2102
|
if (!lastVDom) {
|
|
2086
2103
|
ref.changed = 1;
|
|
2087
2104
|
realNode.innerHTML = newVDom.html;
|
|
2105
|
+
callFunction(ready, []);
|
|
2088
2106
|
return;
|
|
2089
2107
|
}
|
|
2090
2108
|
if (lastVDom.html === newVDom.html) {
|
|
2109
|
+
callFunction(ready, []);
|
|
2091
2110
|
return;
|
|
2092
2111
|
}
|
|
2093
2112
|
const oldChildren = lastVDom.children;
|
|
2094
2113
|
const newChildren = newVDom.children;
|
|
2095
2114
|
const oldLen = oldChildren?.length || 0;
|
|
2096
2115
|
const newLen = newChildren?.length || 0;
|
|
2097
|
-
if (oldLen === 0 && newLen === 0)
|
|
2116
|
+
if (oldLen === 0 && newLen === 0) {
|
|
2117
|
+
callFunction(ready, []);
|
|
2118
|
+
return;
|
|
2119
|
+
}
|
|
2098
2120
|
const nodes = realNode.childNodes;
|
|
2099
|
-
|
|
2100
|
-
let
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
let
|
|
2105
|
-
let
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
realEnd--;
|
|
2173
|
-
oldEndNode = oldChildren?.[--oldEnd];
|
|
2174
|
-
newEndNode = newChildren?.[--newEnd];
|
|
2175
|
-
} else if (isSameVDomNode(newEndNode, oldStartNode)) {
|
|
2176
|
-
if (newEndNode.tag === SPLITTER || oldStartNode.tag === SPLITTER) {
|
|
2177
|
-
ref.changed = 1;
|
|
2178
|
-
domUnmountFrames(frame, realNode);
|
|
2179
|
-
realNode.innerHTML = newEndNode.tag === SPLITTER ? newEndNode.html : "";
|
|
2180
|
-
if (newEndNode.tag !== SPLITTER) {
|
|
2181
|
-
realNode.appendChild(vdomCreateNode(newEndNode, realNode, ref));
|
|
2182
|
-
}
|
|
2183
|
-
} else {
|
|
2184
|
-
const oi = nodes[realStart];
|
|
2185
|
-
realNode.insertBefore(oi, nodes[realEnd + 1] || null);
|
|
2186
|
-
vdomSetNode(
|
|
2187
|
-
oi,
|
|
2188
|
-
realNode,
|
|
2189
|
-
oldStartNode,
|
|
2190
|
-
newEndNode,
|
|
2191
|
-
ref,
|
|
2192
|
-
frame,
|
|
2193
|
-
keys2,
|
|
2194
|
-
view,
|
|
2195
|
-
ready
|
|
2196
|
-
);
|
|
2197
|
-
}
|
|
2198
|
-
reduceCached(keyedNodes, oldStartNode, nodes[realStart]);
|
|
2199
|
-
realStart++;
|
|
2200
|
-
oldStartNode = oldChildren?.[++oldStart];
|
|
2201
|
-
newEndNode = newChildren?.[--newEnd];
|
|
2202
|
-
} else if (isSameVDomNode(newStartNode, oldEndNode)) {
|
|
2203
|
-
if (newStartNode.tag === SPLITTER || oldEndNode.tag === SPLITTER) {
|
|
2204
|
-
ref.changed = 1;
|
|
2205
|
-
domUnmountFrames(frame, realNode);
|
|
2206
|
-
realNode.innerHTML = newStartNode.tag === SPLITTER ? newStartNode.html : "";
|
|
2207
|
-
if (newStartNode.tag !== SPLITTER) {
|
|
2208
|
-
realNode.appendChild(vdomCreateNode(newStartNode, realNode, ref));
|
|
2209
|
-
}
|
|
2210
|
-
} else {
|
|
2211
|
-
const oi = nodes[realEnd];
|
|
2212
|
-
realNode.insertBefore(oi, nodes[realStart]);
|
|
2213
|
-
vdomSetNode(
|
|
2214
|
-
oi,
|
|
2215
|
-
realNode,
|
|
2216
|
-
oldEndNode,
|
|
2217
|
-
newStartNode,
|
|
2218
|
-
ref,
|
|
2219
|
-
frame,
|
|
2220
|
-
keys2,
|
|
2221
|
-
view,
|
|
2222
|
-
ready
|
|
2223
|
-
);
|
|
2224
|
-
}
|
|
2225
|
-
reduceCached(keyedNodes, oldEndNode, nodes[realEnd]);
|
|
2226
|
-
realEnd--;
|
|
2227
|
-
oldEndNode = oldChildren?.[--oldEnd];
|
|
2228
|
-
newStartNode = newChildren?.[++newStart];
|
|
2121
|
+
const oldDomNodes = new Array(oldLen);
|
|
2122
|
+
for (let i = 0; i < oldLen; i++) {
|
|
2123
|
+
oldDomNodes[i] = nodes[i];
|
|
2124
|
+
}
|
|
2125
|
+
const usedOldDomNodes = /* @__PURE__ */ new Set();
|
|
2126
|
+
let headIdx = 0;
|
|
2127
|
+
let tailIdx = oldLen - 1;
|
|
2128
|
+
let newHead = 0;
|
|
2129
|
+
let newTail = newLen - 1;
|
|
2130
|
+
while (headIdx <= tailIdx && newHead <= newTail) {
|
|
2131
|
+
const oc = oldChildren[headIdx];
|
|
2132
|
+
const nc = newChildren[newHead];
|
|
2133
|
+
if (!isSameVDomNode(nc, oc)) break;
|
|
2134
|
+
if (nc.tag === SPLITTER || oc.tag === SPLITTER) break;
|
|
2135
|
+
vdomSetNode(
|
|
2136
|
+
oldDomNodes[headIdx],
|
|
2137
|
+
realNode,
|
|
2138
|
+
oc,
|
|
2139
|
+
nc,
|
|
2140
|
+
ref,
|
|
2141
|
+
frame,
|
|
2142
|
+
keys2,
|
|
2143
|
+
view,
|
|
2144
|
+
ready
|
|
2145
|
+
);
|
|
2146
|
+
usedOldDomNodes.add(oldDomNodes[headIdx]);
|
|
2147
|
+
headIdx++;
|
|
2148
|
+
newHead++;
|
|
2149
|
+
}
|
|
2150
|
+
while (headIdx <= tailIdx && newHead <= newTail) {
|
|
2151
|
+
const oc = oldChildren[tailIdx];
|
|
2152
|
+
const nc = newChildren[newTail];
|
|
2153
|
+
if (!isSameVDomNode(nc, oc)) break;
|
|
2154
|
+
if (nc.tag === SPLITTER || oc.tag === SPLITTER) break;
|
|
2155
|
+
vdomSetNode(
|
|
2156
|
+
oldDomNodes[tailIdx],
|
|
2157
|
+
realNode,
|
|
2158
|
+
oc,
|
|
2159
|
+
nc,
|
|
2160
|
+
ref,
|
|
2161
|
+
frame,
|
|
2162
|
+
keys2,
|
|
2163
|
+
view,
|
|
2164
|
+
ready
|
|
2165
|
+
);
|
|
2166
|
+
usedOldDomNodes.add(oldDomNodes[tailIdx]);
|
|
2167
|
+
tailIdx--;
|
|
2168
|
+
newTail--;
|
|
2169
|
+
}
|
|
2170
|
+
if (headIdx > tailIdx && newHead > newTail) {
|
|
2171
|
+
if (ref.asyncCount === 0) callFunction(ready, []);
|
|
2172
|
+
return;
|
|
2173
|
+
}
|
|
2174
|
+
const keyMap = {};
|
|
2175
|
+
for (let i = headIdx; i <= tailIdx; i++) {
|
|
2176
|
+
const c = oldChildren[i];
|
|
2177
|
+
if (c?.compareKey) {
|
|
2178
|
+
if (!keyMap[c.compareKey]) keyMap[c.compareKey] = [];
|
|
2179
|
+
keyMap[c.compareKey].push({ domNode: oldDomNodes[i], vdomNode: c });
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
const newRemaining = newTail - newHead + 1;
|
|
2183
|
+
const sequence = new Array(newRemaining);
|
|
2184
|
+
for (let i = 0; i < newRemaining; i++) {
|
|
2185
|
+
const nc = newChildren[newHead + i];
|
|
2186
|
+
const cKey = nc.compareKey;
|
|
2187
|
+
const entries = cKey ? keyMap[cKey] : void 0;
|
|
2188
|
+
if (entries && entries.length > 0) {
|
|
2189
|
+
const entry = entries.shift();
|
|
2190
|
+
if (entries.length === 0) delete keyMap[cKey];
|
|
2191
|
+
const oldIdx = oldChildren.indexOf(entry.vdomNode, headIdx);
|
|
2192
|
+
sequence[i] = oldIdx >= 0 ? oldIdx : -1;
|
|
2193
|
+
usedOldDomNodes.add(entry.domNode);
|
|
2229
2194
|
} else {
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
);
|
|
2238
|
-
}
|
|
2239
|
-
const cKey = newStartNode.compareKey;
|
|
2240
|
-
let found;
|
|
2241
|
-
let compareKey;
|
|
2242
|
-
if (cKey && keyedNodes) {
|
|
2243
|
-
found = keyedNodes[cKey];
|
|
2244
|
-
compareKey = void 0;
|
|
2245
|
-
while (found && found.length > 0) {
|
|
2246
|
-
compareKey = found.pop();
|
|
2247
|
-
if (compareKey) break;
|
|
2248
|
-
}
|
|
2249
|
-
if (found && found.length === 0) delete keyedNodes[cKey];
|
|
2250
|
-
}
|
|
2251
|
-
if (compareKey) {
|
|
2252
|
-
if (compareKey !== nodes[realStart]) {
|
|
2253
|
-
for (let j = oldStart + 1; j <= oldEnd; j++) {
|
|
2254
|
-
const oc = oldChildren?.[j];
|
|
2255
|
-
if (oc && nodes[realStart + (j - oldStart)] === compareKey) {
|
|
2256
|
-
oldChildren[j] = void 0;
|
|
2257
|
-
break;
|
|
2258
|
-
}
|
|
2259
|
-
}
|
|
2260
|
-
realNode.insertBefore(compareKey, nodes[realStart]);
|
|
2261
|
-
}
|
|
2262
|
-
vdomSetNode(
|
|
2263
|
-
compareKey,
|
|
2264
|
-
realNode,
|
|
2265
|
-
oldStartNode,
|
|
2266
|
-
newStartNode,
|
|
2267
|
-
ref,
|
|
2268
|
-
frame,
|
|
2269
|
-
keys2,
|
|
2270
|
-
view,
|
|
2271
|
-
ready
|
|
2272
|
-
);
|
|
2273
|
-
} else if (oldStartNode.compareKey && lastVDom.reused?.[oldStartNode.compareKey] && newVDom.reused?.[oldStartNode.compareKey] || nodes[realStart]?.id && realNode.querySelectorAll?.(
|
|
2274
|
-
`#${nodes[realStart].id}`
|
|
2275
|
-
)?.length && !newStartNode.isLarkView) {
|
|
2195
|
+
sequence[i] = -1;
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
if (newHead > newTail) {
|
|
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);
|
|
2276
2203
|
ref.changed = 1;
|
|
2277
|
-
|
|
2278
|
-
realNode.insertBefore(newNode, nodes[realStart]);
|
|
2279
|
-
realStart--;
|
|
2280
|
-
realEnd++;
|
|
2281
|
-
} else {
|
|
2282
|
-
vdomSetNode(
|
|
2283
|
-
nodes[realStart],
|
|
2284
|
-
realNode,
|
|
2285
|
-
oldStartNode,
|
|
2286
|
-
newStartNode,
|
|
2287
|
-
ref,
|
|
2288
|
-
frame,
|
|
2289
|
-
keys2,
|
|
2290
|
-
view,
|
|
2291
|
-
ready
|
|
2292
|
-
);
|
|
2204
|
+
realNode.removeChild(domNode);
|
|
2293
2205
|
}
|
|
2294
|
-
realStart++;
|
|
2295
|
-
oldStartNode = oldChildren?.[++oldStart];
|
|
2296
|
-
newStartNode = newChildren?.[++newStart];
|
|
2297
2206
|
}
|
|
2207
|
+
if (ref.asyncCount === 0) callFunction(ready, []);
|
|
2208
|
+
return;
|
|
2209
|
+
}
|
|
2210
|
+
if (headIdx > tailIdx) {
|
|
2211
|
+
const insertRef = tailIdx < oldLen ? oldDomNodes[tailIdx + 1] ?? null : null;
|
|
2212
|
+
for (let i = newHead; i <= newTail; i++) {
|
|
2213
|
+
ref.changed = 1;
|
|
2214
|
+
const newNode = vdomCreateNode(newChildren[i], realNode, ref);
|
|
2215
|
+
realNode.insertBefore(newNode, insertRef);
|
|
2216
|
+
}
|
|
2217
|
+
if (ref.asyncCount === 0) callFunction(ready, []);
|
|
2218
|
+
return;
|
|
2298
2219
|
}
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2220
|
+
const lis = computeLIS(sequence);
|
|
2221
|
+
let lisCursor = lis.length - 1;
|
|
2222
|
+
let nextNode = tailIdx + 1 < oldLen ? oldDomNodes[tailIdx + 1] : null;
|
|
2223
|
+
for (let j = newRemaining - 1; j >= 0; j--) {
|
|
2224
|
+
const newIdx = newHead + j;
|
|
2225
|
+
const nc = newChildren[newIdx];
|
|
2226
|
+
if (lisCursor >= 0 && lis[lisCursor] === j) {
|
|
2227
|
+
const oldIdx = sequence[j];
|
|
2228
|
+
vdomSetNode(
|
|
2229
|
+
oldDomNodes[oldIdx],
|
|
2230
|
+
realNode,
|
|
2231
|
+
oldChildren[oldIdx],
|
|
2232
|
+
nc,
|
|
2233
|
+
ref,
|
|
2234
|
+
frame,
|
|
2235
|
+
keys2,
|
|
2236
|
+
view,
|
|
2237
|
+
ready
|
|
2238
|
+
);
|
|
2239
|
+
nextNode = oldDomNodes[oldIdx];
|
|
2240
|
+
lisCursor--;
|
|
2241
|
+
} else if (sequence[j] >= 0) {
|
|
2242
|
+
const oldIdx = sequence[j];
|
|
2243
|
+
ref.changed = 1;
|
|
2244
|
+
realNode.insertBefore(oldDomNodes[oldIdx], nextNode);
|
|
2245
|
+
vdomSetNode(
|
|
2246
|
+
oldDomNodes[oldIdx],
|
|
2247
|
+
realNode,
|
|
2248
|
+
oldChildren[oldIdx],
|
|
2249
|
+
nc,
|
|
2250
|
+
ref,
|
|
2251
|
+
frame,
|
|
2252
|
+
keys2,
|
|
2253
|
+
view,
|
|
2254
|
+
ready
|
|
2255
|
+
);
|
|
2256
|
+
nextNode = oldDomNodes[oldIdx];
|
|
2257
|
+
} else {
|
|
2302
2258
|
ref.changed = 1;
|
|
2303
|
-
const nc = newChildren[i];
|
|
2304
|
-
if (nc.tag === SPLITTER) {
|
|
2305
|
-
domUnmountFrames(frame, realNode);
|
|
2306
|
-
realNode.innerHTML = nc.html;
|
|
2307
|
-
return;
|
|
2308
|
-
}
|
|
2309
2259
|
const newNode = vdomCreateNode(nc, realNode, ref);
|
|
2310
|
-
realNode.insertBefore(newNode,
|
|
2260
|
+
realNode.insertBefore(newNode, nextNode);
|
|
2261
|
+
nextNode = newNode;
|
|
2311
2262
|
}
|
|
2312
2263
|
}
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
realNode.removeChild(node);
|
|
2320
|
-
}
|
|
2264
|
+
for (let i = 0; i < oldLen; i++) {
|
|
2265
|
+
const domNode = oldDomNodes[i];
|
|
2266
|
+
if (domNode && !usedOldDomNodes.has(domNode) && domNode.parentNode === realNode) {
|
|
2267
|
+
domUnmountFrames(frame, domNode);
|
|
2268
|
+
ref.changed = 1;
|
|
2269
|
+
realNode.removeChild(domNode);
|
|
2321
2270
|
}
|
|
2322
2271
|
}
|
|
2323
2272
|
if (ref.asyncCount === 0) {
|
|
2324
2273
|
callFunction(ready, []);
|
|
2325
2274
|
}
|
|
2326
2275
|
}
|
|
2327
|
-
function reduceCached(keyedNodes, node, compared) {
|
|
2328
|
-
if (!keyedNodes || !node.compareKey) return;
|
|
2329
|
-
const bucket = keyedNodes[node.compareKey];
|
|
2330
|
-
if (bucket) {
|
|
2331
|
-
for (let i = bucket.length; i--; ) {
|
|
2332
|
-
if (bucket[i] === compared) {
|
|
2333
|
-
bucket[i] = void 0;
|
|
2334
|
-
break;
|
|
2335
|
-
}
|
|
2336
|
-
}
|
|
2337
|
-
}
|
|
2338
|
-
}
|
|
2339
2276
|
function createVDomRef(viewId) {
|
|
2340
2277
|
return {
|
|
2341
2278
|
viewId,
|
|
@@ -2478,9 +2415,6 @@ var Updater = class {
|
|
|
2478
2415
|
view,
|
|
2479
2416
|
ready
|
|
2480
2417
|
);
|
|
2481
|
-
if (ref.asyncCount === 0) {
|
|
2482
|
-
ready();
|
|
2483
|
-
}
|
|
2484
2418
|
} else {
|
|
2485
2419
|
const html = template(
|
|
2486
2420
|
this.data,
|
|
@@ -2579,6 +2513,63 @@ var Updater = class {
|
|
|
2579
2513
|
}
|
|
2580
2514
|
};
|
|
2581
2515
|
|
|
2516
|
+
// src/view-registry.ts
|
|
2517
|
+
var viewClassRegistry = {};
|
|
2518
|
+
function getViewClass(path) {
|
|
2519
|
+
return viewClassRegistry[path];
|
|
2520
|
+
}
|
|
2521
|
+
function registerViewClass(viewPath, ViewClass) {
|
|
2522
|
+
const parsed = parseUri(viewPath);
|
|
2523
|
+
const path = parsed.path;
|
|
2524
|
+
if (path) {
|
|
2525
|
+
viewClassRegistry[path] = ViewClass;
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2528
|
+
function invalidateViewClass(viewPath) {
|
|
2529
|
+
const parsed = parseUri(viewPath);
|
|
2530
|
+
const path = parsed.path;
|
|
2531
|
+
if (path) {
|
|
2532
|
+
Reflect.deleteProperty(viewClassRegistry, path);
|
|
2533
|
+
}
|
|
2534
|
+
}
|
|
2535
|
+
function getViewClassRegistry() {
|
|
2536
|
+
return viewClassRegistry;
|
|
2537
|
+
}
|
|
2538
|
+
|
|
2539
|
+
// src/hmr.ts
|
|
2540
|
+
function reloadViews(viewPath) {
|
|
2541
|
+
const allFrames = Frame.getAll();
|
|
2542
|
+
const toReload = [];
|
|
2543
|
+
for (const [, frame] of allFrames) {
|
|
2544
|
+
if (frame.viewPath) {
|
|
2545
|
+
const parsed = parseUri(frame.viewPath);
|
|
2546
|
+
if (parsed.path === viewPath) {
|
|
2547
|
+
toReload.push({ frame, fullPath: frame.viewPath });
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2550
|
+
}
|
|
2551
|
+
for (const { frame, fullPath } of toReload) {
|
|
2552
|
+
frame.mountView(fullPath);
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
function acceptView(hot, viewPath) {
|
|
2556
|
+
hot.accept((newModule) => {
|
|
2557
|
+
const candidate = newModule?.default ?? newModule;
|
|
2558
|
+
if (typeof candidate === "function") {
|
|
2559
|
+
const NewViewClass = candidate;
|
|
2560
|
+
registerViewClass(viewPath, NewViewClass);
|
|
2561
|
+
reloadViews(viewPath);
|
|
2562
|
+
} else {
|
|
2563
|
+
hot.invalidate();
|
|
2564
|
+
}
|
|
2565
|
+
});
|
|
2566
|
+
}
|
|
2567
|
+
function disposeView(hot, viewPath) {
|
|
2568
|
+
hot.dispose(() => {
|
|
2569
|
+
invalidateViewClass(viewPath);
|
|
2570
|
+
});
|
|
2571
|
+
}
|
|
2572
|
+
|
|
2582
2573
|
// src/view.ts
|
|
2583
2574
|
var VIEW_GLOBALS = {};
|
|
2584
2575
|
if (typeof window !== "undefined") {
|
|
@@ -3169,34 +3160,51 @@ var View = class _View {
|
|
|
3169
3160
|
_View.mergeMixins(mixins, this, existingCtors);
|
|
3170
3161
|
return this;
|
|
3171
3162
|
}
|
|
3163
|
+
// ============================================================
|
|
3164
|
+
// HMR support (static accept / dispose)
|
|
3165
|
+
// ============================================================
|
|
3166
|
+
/**
|
|
3167
|
+
* Set up HMR accept handler for this view module.
|
|
3168
|
+
*
|
|
3169
|
+
* When the module is hot-replaced, the new View class is extracted from
|
|
3170
|
+
* the new module, registered in the view registry, and all currently
|
|
3171
|
+
* mounted frames using this viewPath are re-mounted.
|
|
3172
|
+
*
|
|
3173
|
+
* No-op when `hot` is undefined (production / non-HMR environment).
|
|
3174
|
+
*
|
|
3175
|
+
* ```ts
|
|
3176
|
+
* if (import.meta.hot) {
|
|
3177
|
+
* HomeView.accept(import.meta.hot, 'home');
|
|
3178
|
+
* }
|
|
3179
|
+
* ```
|
|
3180
|
+
*/
|
|
3181
|
+
static accept(hot, viewPath) {
|
|
3182
|
+
if (!hot) return;
|
|
3183
|
+
acceptView(hot, viewPath);
|
|
3184
|
+
}
|
|
3185
|
+
/**
|
|
3186
|
+
* Set up HMR dispose handler for this view module.
|
|
3187
|
+
*
|
|
3188
|
+
* When the module is about to be replaced, the old View class is removed
|
|
3189
|
+
* from the registry so subsequent lookups don't return the stale class.
|
|
3190
|
+
*
|
|
3191
|
+
* No-op when `hot` is undefined (production / non-HMR environment).
|
|
3192
|
+
*
|
|
3193
|
+
* ```ts
|
|
3194
|
+
* if (import.meta.hot) {
|
|
3195
|
+
* HomeView.dispose(import.meta.hot, 'home');
|
|
3196
|
+
* }
|
|
3197
|
+
* ```
|
|
3198
|
+
*/
|
|
3199
|
+
static dispose(hot, viewPath) {
|
|
3200
|
+
if (!hot) return;
|
|
3201
|
+
disposeView(hot, viewPath);
|
|
3202
|
+
}
|
|
3172
3203
|
};
|
|
3173
3204
|
function defineView(props, statics) {
|
|
3174
3205
|
return View.extend(props, statics);
|
|
3175
3206
|
}
|
|
3176
3207
|
|
|
3177
|
-
// src/view-registry.ts
|
|
3178
|
-
var viewClassRegistry = {};
|
|
3179
|
-
function getViewClass(path) {
|
|
3180
|
-
return viewClassRegistry[path];
|
|
3181
|
-
}
|
|
3182
|
-
function registerViewClass(viewPath, ViewClass) {
|
|
3183
|
-
const parsed = parseUri(viewPath);
|
|
3184
|
-
const path = parsed.path;
|
|
3185
|
-
if (path) {
|
|
3186
|
-
viewClassRegistry[path] = ViewClass;
|
|
3187
|
-
}
|
|
3188
|
-
}
|
|
3189
|
-
function invalidateViewClass(viewPath) {
|
|
3190
|
-
const parsed = parseUri(viewPath);
|
|
3191
|
-
const path = parsed.path;
|
|
3192
|
-
if (path) {
|
|
3193
|
-
Reflect.deleteProperty(viewClassRegistry, path);
|
|
3194
|
-
}
|
|
3195
|
-
}
|
|
3196
|
-
function getViewClassRegistry() {
|
|
3197
|
-
return viewClassRegistry;
|
|
3198
|
-
}
|
|
3199
|
-
|
|
3200
3208
|
// src/frame.ts
|
|
3201
3209
|
var frameRegistry = /* @__PURE__ */ new Map();
|
|
3202
3210
|
var rootFrame;
|
|
@@ -4878,6 +4886,7 @@ function bindStore(view, store, selector) {
|
|
|
4878
4886
|
markRouterBooted,
|
|
4879
4887
|
nextCounter,
|
|
4880
4888
|
registerViewClass,
|
|
4889
|
+
reloadViews,
|
|
4881
4890
|
resetProjectsMap,
|
|
4882
4891
|
safeguard,
|
|
4883
4892
|
unmark,
|