@lark.js/mvc 0.0.10 → 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/index.cjs CHANGED
@@ -27,7 +27,6 @@ __export(index_exports, {
27
27
  EventDelegator: () => EventDelegator,
28
28
  EventEmitter: () => EventEmitter,
29
29
  Frame: () => Frame,
30
- FrameVisualBridge: () => FrameVisualBridge,
31
30
  Framework: () => Framework,
32
31
  LARK_VIEW: () => LARK_VIEW,
33
32
  Payload: () => Payload,
@@ -44,22 +43,23 @@ __export(index_exports, {
44
43
  bindStore: () => bindStore,
45
44
  computed: () => computed,
46
45
  create: () => create,
46
+ createVDomRef: () => createVDomRef,
47
47
  defineView: () => defineView,
48
48
  frameworkConfig: () => config,
49
49
  getRouteMode: () => getRouteMode,
50
- installFrameVisualizerBridge: () => installFrameVisualizerBridge,
51
50
  invalidateViewClass: () => invalidateViewClass,
52
51
  mark: () => mark,
53
52
  markBooted: () => markBooted,
54
53
  markRouterBooted: () => markRouterBooted,
55
54
  nextCounter: () => nextCounter,
56
55
  registerViewClass: () => registerViewClass,
56
+ reloadViews: () => reloadViews,
57
57
  resetProjectsMap: () => resetProjectsMap,
58
58
  safeguard: () => safeguard,
59
- serializeFrameTree: () => serializeFrameTree,
60
59
  unmark: () => unmark,
61
60
  use: () => use,
62
- useUrlState: () => useUrlState
61
+ useUrlState: () => useUrlState,
62
+ vdomCreate: () => vdomCreate
63
63
  });
64
64
  module.exports = __toCommonJS(index_exports);
65
65
 
@@ -85,6 +85,11 @@ var SVG_NS = "http://www.w3.org/2000/svg";
85
85
  var MATH_NS = "http://www.w3.org/1998/Math/MathML";
86
86
  var TAG_NAME_REGEXP = /<([a-z][^/\0>\x20\t\r\n\f]+)/i;
87
87
  var CALL_BREAK_TIME = 48;
88
+ var V_TEXT_NODE = 0;
89
+ var VDOM_NS_MAP = {
90
+ svg: SVG_NS,
91
+ math: MATH_NS
92
+ };
88
93
  function nextCounter() {
89
94
  return ++globalCounter;
90
95
  }
@@ -97,7 +102,7 @@ var HTML_ENT_MAP = {
97
102
  "`": "#96"
98
103
  };
99
104
  var HTML_ENT_REGEXP = /[&<>"'`]/g;
100
- function encodeSafe(v) {
105
+ function strSafe(v) {
101
106
  return String(v == null ? "" : v);
102
107
  }
103
108
  function encodeHTML(v) {
@@ -115,14 +120,14 @@ var URI_ENT_MAP = {
115
120
  };
116
121
  var URI_ENT_REGEXP = /[!')(*]/g;
117
122
  function encodeURIExtra(v) {
118
- return encodeURIComponent(encodeSafe(v)).replace(
123
+ return encodeURIComponent(strSafe(v)).replace(
119
124
  URI_ENT_REGEXP,
120
125
  (m) => URI_ENT_MAP[m]
121
126
  );
122
127
  }
123
128
  var QUOTE_ENT_REGEXP = /['"\\]/g;
124
- function encodeQ(v) {
125
- return encodeSafe(v).replace(QUOTE_ENT_REGEXP, "\\$&");
129
+ function encodeQuote(v) {
130
+ return strSafe(v).replace(QUOTE_ENT_REGEXP, "\\$&");
126
131
  }
127
132
  function refFn(ref, value, key) {
128
133
  const counter = ref[SPLITTER];
@@ -144,11 +149,66 @@ function isRefToken(s) {
144
149
  }
145
150
 
146
151
  // src/utils.ts
152
+ var CALL_BREAK_TIME2 = 9;
153
+ var callQueue = [];
154
+ var callScheduled = false;
155
+ var schedulerYield = (() => {
156
+ try {
157
+ if (typeof globalThis?.scheduler?.yield === "function") {
158
+ return globalThis.scheduler.yield.bind(globalThis.scheduler);
159
+ }
160
+ } catch {
161
+ }
162
+ return void 0;
163
+ })();
164
+ async function startCall() {
165
+ callScheduled = false;
166
+ const startTime = performance.now();
167
+ while (callQueue.length > 0) {
168
+ const task2 = callQueue.shift();
169
+ try {
170
+ task2();
171
+ } catch (e) {
172
+ console.error("scheduler task error:", e);
173
+ }
174
+ if (callQueue.length > 0 && performance.now() - startTime > CALL_BREAK_TIME2) {
175
+ if (schedulerYield) {
176
+ await schedulerYield();
177
+ } else {
178
+ scheduleNextChunk();
179
+ return;
180
+ }
181
+ }
182
+ }
183
+ }
184
+ function scheduleNextChunk() {
185
+ setTimeout(() => startCall(), 0);
186
+ callScheduled = true;
187
+ }
188
+ function callFunction(fn, args) {
189
+ callQueue.push(() => fn(...args));
190
+ if (!callScheduled) {
191
+ scheduleNextChunk();
192
+ }
193
+ }
147
194
  function isPlainObject(value) {
148
195
  if (typeof value !== "object" || value === null) return false;
149
196
  const proto = Object.getPrototypeOf(value);
150
197
  return proto === null || proto === Object.prototype;
151
198
  }
199
+ function isRecord(value) {
200
+ return typeof value === "object" && value !== null;
201
+ }
202
+ function asRecord(value) {
203
+ if (isRecord(value)) {
204
+ return value;
205
+ }
206
+ console.error("fallback to Object.fromEntries, even an empty object {}.");
207
+ if (Array.isArray(value)) {
208
+ return Object.fromEntries(value.entries());
209
+ }
210
+ return {};
211
+ }
152
212
  function isPrimitiveOrFunc(value) {
153
213
  return !value || typeof value !== "object" && typeof value !== "function";
154
214
  }
@@ -202,13 +262,13 @@ function setData(newData, oldData, changedKeys2, excludes) {
202
262
  let changed = false;
203
263
  for (const p in newData) {
204
264
  if (hasOwnProperty(newData, p)) {
205
- const now2 = newData[p];
265
+ const now = newData[p];
206
266
  const old = oldData[p];
207
- if ((!isPrimitiveOrFunc(now2) || old !== now2) && !excludes.has(p)) {
267
+ if ((!isPrimitiveOrFunc(now) || old !== now) && !excludes.has(p)) {
208
268
  changedKeys2.add(p);
209
269
  changed = true;
210
270
  }
211
- oldData[p] = now2;
271
+ oldData[p] = now;
212
272
  }
213
273
  }
214
274
  return changed;
@@ -301,9 +361,6 @@ function toMap(list, key) {
301
361
  }
302
362
  return map;
303
363
  }
304
- function now() {
305
- return Date.now();
306
- }
307
364
 
308
365
  // src/apply-style.ts
309
366
  var injectedStyleIds = /* @__PURE__ */ new Set();
@@ -1055,10 +1112,7 @@ var Router = {
1055
1112
  if (lastChanged["path"]) {
1056
1113
  document.title = defaultTitle || document.title;
1057
1114
  }
1058
- emitter2.fire(
1059
- RouterEvents.CHANGED,
1060
- lastChanged
1061
- );
1115
+ emitter2.fire(RouterEvents.CHANGED, asRecord(lastChanged));
1062
1116
  }
1063
1117
  silent = 0;
1064
1118
  if (typeof window.__lark_Debug !== "undefined" && window.__lark_Debug && lastChanged) {
@@ -1189,10 +1243,7 @@ var Router = {
1189
1243
  suspend = 1;
1190
1244
  }
1191
1245
  };
1192
- Router.fire(
1193
- RouterEvents.CHANGE,
1194
- changeEvent
1195
- );
1246
+ Router.fire(RouterEvents.CHANGE, changeEvent);
1196
1247
  if (suspend || changeEvent.p) {
1197
1248
  return;
1198
1249
  }
@@ -1466,6 +1517,53 @@ var EventDelegator = {
1466
1517
  }
1467
1518
  };
1468
1519
 
1520
+ // src/module-loader.ts
1521
+ var config = {
1522
+ rootId: "root",
1523
+ routeMode: "history",
1524
+ hashbang: "#!",
1525
+ error: (error) => {
1526
+ throw error;
1527
+ }
1528
+ };
1529
+ function use(names, callback) {
1530
+ const nameList = typeof names === "string" ? [names] : names;
1531
+ const loadPromise = (() => {
1532
+ if (config.require) {
1533
+ const result = config.require(nameList);
1534
+ if (result && typeof result.then === "function") {
1535
+ return result;
1536
+ }
1537
+ return Promise.resolve([]);
1538
+ }
1539
+ return Promise.all(
1540
+ nameList.map((name) => {
1541
+ const importPath = name.startsWith(".") || name.startsWith("/") ? name : `./${name}`;
1542
+ return import(
1543
+ /* @vite-ignore */
1544
+ /* webpackIgnore: true */
1545
+ importPath
1546
+ ).then((mod) => {
1547
+ return mod && (mod["__esModule"] || // For Webpack
1548
+ typeof mod["default"] === "function") ? mod["default"] : mod;
1549
+ }).catch((err) => {
1550
+ const errorHandler = config.error;
1551
+ if (errorHandler) {
1552
+ errorHandler(err instanceof Error ? err : new Error(String(err)));
1553
+ }
1554
+ return void 0;
1555
+ });
1556
+ })
1557
+ );
1558
+ })();
1559
+ if (callback) {
1560
+ loadPromise.then((modules) => {
1561
+ callback(...modules);
1562
+ });
1563
+ }
1564
+ return loadPromise;
1565
+ }
1566
+
1469
1567
  // src/dom.ts
1470
1568
  var wrapMeta = {
1471
1569
  option: [1, "<select multiple>"],
@@ -1541,13 +1639,11 @@ function domGetCompareKey(node) {
1541
1639
  function domSpecialDiff(oldNode, newNode) {
1542
1640
  const specials = DomSpecials[oldNode.nodeName];
1543
1641
  if (!specials) return 0;
1544
- const oldEl = oldNode;
1545
- const newEl = newNode;
1546
1642
  let result = 0;
1547
1643
  for (const prop of specials) {
1548
- if (oldEl[prop] !== newEl[prop]) {
1644
+ if (Reflect.get(oldNode, prop) !== Reflect.get(newNode, prop)) {
1549
1645
  result = 1;
1550
- oldEl[prop] = newEl[prop];
1646
+ Reflect.set(oldNode, prop, Reflect.get(newNode, prop));
1551
1647
  }
1552
1648
  }
1553
1649
  return result;
@@ -1729,6 +1825,465 @@ function applyIdUpdates(updates) {
1729
1825
  }
1730
1826
  }
1731
1827
 
1828
+ // src/vdom.ts
1829
+ var DOM_SPECIALS = {
1830
+ INPUT: ["value", "checked"],
1831
+ TEXTAREA: ["value"],
1832
+ OPTION: ["selected"]
1833
+ };
1834
+ function vdomCreate(tag, props, children, specials) {
1835
+ if (!tag) {
1836
+ return {
1837
+ tag: children ? SPLITTER : V_TEXT_NODE,
1838
+ html: String(props ?? "")
1839
+ };
1840
+ }
1841
+ const propsObj = props || {};
1842
+ const specialsObj = specials || {};
1843
+ const unary = children === 1;
1844
+ let compareKey;
1845
+ let innerHTML = "";
1846
+ let newChildren;
1847
+ let reused;
1848
+ let reusedTotal = 0;
1849
+ let viewList;
1850
+ let isLarkView2;
1851
+ let attrs = `<${tag}`;
1852
+ let hasSpecials;
1853
+ let prevChild;
1854
+ if (children && children !== 1) {
1855
+ for (const c of children) {
1856
+ if (c.attrs !== void 0) {
1857
+ innerHTML += c.attrs + (c.selfClose ? "/>" : `>${c.html}</${c.tag}>`);
1858
+ } else {
1859
+ if (c.tag === V_TEXT_NODE) {
1860
+ innerHTML += encodeHTML(c.html);
1861
+ } else {
1862
+ innerHTML += c.html;
1863
+ }
1864
+ }
1865
+ if (c.tag === V_TEXT_NODE && prevChild && prevChild.tag === V_TEXT_NODE) {
1866
+ prevChild.html += c.html;
1867
+ } else {
1868
+ if (!newChildren) newChildren = [];
1869
+ newChildren.push(c);
1870
+ prevChild = c;
1871
+ }
1872
+ if (c.compareKey) {
1873
+ if (!reused) reused = {};
1874
+ reused[c.compareKey] = (reused[c.compareKey] || 0) + 1;
1875
+ reusedTotal++;
1876
+ }
1877
+ if (c.views) {
1878
+ if (!viewList) viewList = [];
1879
+ viewList.push(...c.views);
1880
+ }
1881
+ }
1882
+ }
1883
+ hasSpecials = specials || void 0;
1884
+ for (const prop in propsObj) {
1885
+ let value = propsObj[prop];
1886
+ if (value === false || value == null) {
1887
+ if (!specialsObj[prop]) {
1888
+ delete propsObj[prop];
1889
+ }
1890
+ continue;
1891
+ } else if (value === true) {
1892
+ propsObj[prop] = value = specialsObj[prop] ? value : "";
1893
+ }
1894
+ if ((prop === "#" || prop === "id") && !compareKey) {
1895
+ compareKey = value;
1896
+ if (prop !== "id") {
1897
+ delete propsObj[prop];
1898
+ continue;
1899
+ }
1900
+ }
1901
+ if (prop === LARK_VIEW && value) {
1902
+ const parsed = parseUri(value);
1903
+ isLarkView2 = parsed.path;
1904
+ if (!viewList) viewList = [];
1905
+ viewList.push([
1906
+ isLarkView2,
1907
+ propsObj["lark-owner"],
1908
+ value,
1909
+ parsed.params
1910
+ ]);
1911
+ if (!compareKey) {
1912
+ compareKey = tag + SPLITTER + isLarkView2;
1913
+ }
1914
+ }
1915
+ if (prop === "value" && tag === "textarea") {
1916
+ innerHTML = String(value);
1917
+ delete propsObj[prop];
1918
+ continue;
1919
+ }
1920
+ attrs += ` ${prop}="${value && encodeHTML(value)}"`;
1921
+ }
1922
+ return {
1923
+ tag,
1924
+ html: innerHTML,
1925
+ attrs,
1926
+ attrsMap: propsObj,
1927
+ attrsSpecials: specialsObj,
1928
+ hasSpecials,
1929
+ children: newChildren,
1930
+ compareKey,
1931
+ reused,
1932
+ reusedTotal,
1933
+ views: viewList,
1934
+ selfClose: unary,
1935
+ isLarkView: isLarkView2
1936
+ };
1937
+ }
1938
+ function isSameVDomNode(a, b) {
1939
+ return a.compareKey && b.compareKey === a.compareKey || !a.compareKey && !b.compareKey && a.tag === b.tag || a.tag === SPLITTER || b.tag === SPLITTER;
1940
+ }
1941
+ function vdomCreateNode(vnode, owner, ref) {
1942
+ const tag = vnode.tag;
1943
+ if (tag === V_TEXT_NODE) {
1944
+ return document.createTextNode(vnode.html);
1945
+ }
1946
+ const sTag = typeof tag === "string" ? tag : tag.toString();
1947
+ const ns = VDOM_NS_MAP[sTag] || owner.namespaceURI;
1948
+ const el = document.createElementNS(ns, sTag);
1949
+ vdomSetAttributes(el, vnode, ref);
1950
+ el.innerHTML = vnode.html;
1951
+ return el;
1952
+ }
1953
+ function vdomSetAttributes(realNode, newVDom, ref, lastVDom) {
1954
+ let changed = 0;
1955
+ const nMap = newVDom.attrsMap || {};
1956
+ const nsMap = newVDom.attrsSpecials || {};
1957
+ if (lastVDom) {
1958
+ const oMap = lastVDom.attrsMap || {};
1959
+ const osMap = lastVDom.attrsSpecials || {};
1960
+ for (const key in oMap) {
1961
+ if (!hasOwnProperty(nMap, key)) {
1962
+ changed = 1;
1963
+ const sValue = osMap[key];
1964
+ if (sValue) {
1965
+ if (ref) {
1966
+ ref.nodeProps.push([realNode, sValue, ""]);
1967
+ } else {
1968
+ Reflect.set(realNode, sValue, "");
1969
+ }
1970
+ } else {
1971
+ realNode.removeAttribute(key);
1972
+ }
1973
+ }
1974
+ }
1975
+ }
1976
+ for (const key in nMap) {
1977
+ const value = nMap[key];
1978
+ const sKey = nsMap[key];
1979
+ if (sKey) {
1980
+ if (Reflect.get(realNode, sKey) !== value) {
1981
+ changed = 1;
1982
+ if (ref) {
1983
+ ref.nodeProps.push([realNode, sKey, value]);
1984
+ } else {
1985
+ Reflect.set(realNode, sKey, value);
1986
+ }
1987
+ }
1988
+ } else {
1989
+ const oldMap = lastVDom?.attrsMap;
1990
+ if (!oldMap || oldMap[key] !== value) {
1991
+ changed = 1;
1992
+ realNode.setAttribute(key, String(value ?? ""));
1993
+ }
1994
+ }
1995
+ }
1996
+ return changed;
1997
+ }
1998
+ function vdomSyncFormState(realNode, newVDom) {
1999
+ const specials = DOM_SPECIALS[realNode.nodeName];
2000
+ if (!specials) return 0;
2001
+ const nMap = newVDom.attrsMap || {};
2002
+ let result = 0;
2003
+ for (const prop of specials) {
2004
+ const newVal = nMap[prop];
2005
+ if (newVal !== void 0 && Reflect.get(realNode, prop) !== newVal) {
2006
+ result = 1;
2007
+ Reflect.set(realNode, prop, newVal);
2008
+ }
2009
+ }
2010
+ return result;
2011
+ }
2012
+ function vdomSetNode(realNode, oldParent, lastVDom, newVDom, ref, frame, keys2, rootView, ready) {
2013
+ const lastTag = lastVDom.tag;
2014
+ const newTag = newVDom.tag;
2015
+ if (lastTag === V_TEXT_NODE || newTag === V_TEXT_NODE) {
2016
+ if (lastTag === newTag) {
2017
+ if (lastVDom.html !== newVDom.html) {
2018
+ ref.changed = 1;
2019
+ realNode.nodeValue = newVDom.html;
2020
+ }
2021
+ } else {
2022
+ ref.changed = 1;
2023
+ domUnmountFrames(frame, realNode);
2024
+ oldParent.replaceChild(vdomCreateNode(newVDom, oldParent, ref), realNode);
2025
+ }
2026
+ return;
2027
+ }
2028
+ if (lastTag === newTag) {
2029
+ if (lastVDom.attrs === newVDom.attrs && lastVDom.html === newVDom.html) {
2030
+ if (newVDom.hasSpecials) {
2031
+ vdomSyncFormState(realNode, newVDom);
2032
+ }
2033
+ return;
2034
+ }
2035
+ let attrChanged = 0;
2036
+ if (lastVDom.attrs !== newVDom.attrs || newVDom.hasSpecials) {
2037
+ attrChanged = vdomSetAttributes(
2038
+ realNode,
2039
+ newVDom,
2040
+ ref,
2041
+ lastVDom
2042
+ );
2043
+ if (attrChanged) ref.changed = 1;
2044
+ }
2045
+ let updateChildren = true;
2046
+ if (newVDom.isLarkView) {
2047
+ const oldFrameId = realNode.getAttribute("id") || "";
2048
+ const newViewPath = newVDom.isLarkView;
2049
+ const oldViewPath = lastVDom.isLarkView || "";
2050
+ if (oldFrameId && newViewPath === oldViewPath) {
2051
+ updateChildren = false;
2052
+ }
2053
+ }
2054
+ vdomSyncFormState(realNode, newVDom);
2055
+ if (updateChildren && !newVDom.selfClose) {
2056
+ vdomSetChildNodes(
2057
+ realNode,
2058
+ lastVDom,
2059
+ newVDom,
2060
+ ref,
2061
+ frame,
2062
+ keys2,
2063
+ rootView,
2064
+ ready
2065
+ );
2066
+ }
2067
+ } else {
2068
+ ref.changed = 1;
2069
+ domUnmountFrames(frame, realNode);
2070
+ oldParent.replaceChild(vdomCreateNode(newVDom, oldParent, ref), realNode);
2071
+ }
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
+ }
2101
+ function vdomSetChildNodes(realNode, lastVDom, newVDom, ref, frame, keys2, view, ready) {
2102
+ if (!lastVDom) {
2103
+ ref.changed = 1;
2104
+ realNode.innerHTML = newVDom.html;
2105
+ callFunction(ready, []);
2106
+ return;
2107
+ }
2108
+ if (lastVDom.html === newVDom.html) {
2109
+ callFunction(ready, []);
2110
+ return;
2111
+ }
2112
+ const oldChildren = lastVDom.children;
2113
+ const newChildren = newVDom.children;
2114
+ const oldLen = oldChildren?.length || 0;
2115
+ const newLen = newChildren?.length || 0;
2116
+ if (oldLen === 0 && newLen === 0) {
2117
+ callFunction(ready, []);
2118
+ return;
2119
+ }
2120
+ const nodes = realNode.childNodes;
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);
2194
+ } else {
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);
2203
+ ref.changed = 1;
2204
+ realNode.removeChild(domNode);
2205
+ }
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;
2219
+ }
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 {
2258
+ ref.changed = 1;
2259
+ const newNode = vdomCreateNode(nc, realNode, ref);
2260
+ realNode.insertBefore(newNode, nextNode);
2261
+ nextNode = newNode;
2262
+ }
2263
+ }
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);
2270
+ }
2271
+ }
2272
+ if (ref.asyncCount === 0) {
2273
+ callFunction(ready, []);
2274
+ }
2275
+ }
2276
+ function createVDomRef(viewId) {
2277
+ return {
2278
+ viewId,
2279
+ viewRenders: [],
2280
+ nodeProps: [],
2281
+ asyncCount: 0,
2282
+ changed: 0,
2283
+ domOps: []
2284
+ };
2285
+ }
2286
+
1732
2287
  // src/updater.ts
1733
2288
  var Updater = class {
1734
2289
  /** View ID (same as owner frame ID) */
@@ -1751,6 +2306,8 @@ var Updater = class {
1751
2306
  version = 0;
1752
2307
  /** Snapshot of `version` taken by `snapshot()`, used by `altered()`. */
1753
2308
  snapshotVersion;
2309
+ /** Last rendered VDOM tree (only used when virtualDom is enabled) */
2310
+ vdom;
1754
2311
  constructor(viewId) {
1755
2312
  this.viewId = viewId;
1756
2313
  this.data = { vId: viewId };
@@ -1830,28 +2387,58 @@ var Updater = class {
1830
2387
  if (changed && view && node && view.signature > 0 && frame) {
1831
2388
  const template = view.template;
1832
2389
  if (typeof template === "function") {
1833
- const html = template(
1834
- this.data,
1835
- this.viewId,
1836
- this.refData,
1837
- encodeHTML,
1838
- encodeSafe,
1839
- encodeURIExtra,
1840
- refFn,
1841
- encodeQ
1842
- );
1843
- const newDom = domGetNode(html, node);
1844
- const ref = createDomRef();
1845
- domSetChildNodes(node, newDom, ref, frame, keys2);
1846
- applyIdUpdates(ref.idUpdates);
1847
- applyDomOps(ref.domOps);
1848
- for (const v of ref.views) {
1849
- if (v.render) {
1850
- funcWithTry(v.render, [], v, noop);
2390
+ if (config.virtualDom) {
2391
+ const vdomTemplate = template;
2392
+ const newVDom = vdomTemplate(this.data, this.viewId, this.refData);
2393
+ const ref = createVDomRef(this.viewId);
2394
+ const ready = () => {
2395
+ this.vdom = newVDom;
2396
+ if (ref.changed || !view.rendered) {
2397
+ view.endUpdate(this.viewId);
2398
+ }
2399
+ for (const [el, prop, val] of ref.nodeProps) {
2400
+ Reflect.set(el, prop, val);
2401
+ }
2402
+ for (const v of ref.viewRenders) {
2403
+ if (v.render) {
2404
+ funcWithTry(v.render, [], v, noop);
2405
+ }
2406
+ }
2407
+ };
2408
+ vdomSetChildNodes(
2409
+ node,
2410
+ this.vdom,
2411
+ newVDom,
2412
+ ref,
2413
+ frame,
2414
+ keys2,
2415
+ view,
2416
+ ready
2417
+ );
2418
+ } else {
2419
+ const html = template(
2420
+ this.data,
2421
+ this.viewId,
2422
+ this.refData,
2423
+ encodeHTML,
2424
+ strSafe,
2425
+ encodeURIExtra,
2426
+ refFn,
2427
+ encodeQuote
2428
+ );
2429
+ const newDom = domGetNode(html, node);
2430
+ const ref = createDomRef();
2431
+ domSetChildNodes(node, newDom, ref, frame, keys2);
2432
+ applyIdUpdates(ref.idUpdates);
2433
+ applyDomOps(ref.domOps);
2434
+ for (const v of ref.views) {
2435
+ if (v.render) {
2436
+ funcWithTry(v.render, [], v, noop);
2437
+ }
2438
+ }
2439
+ if (ref.hasChanged || !view.rendered) {
2440
+ view.endUpdate(this.viewId);
1851
2441
  }
1852
- }
1853
- if (ref.hasChanged || !view.rendered) {
1854
- view.endUpdate(this.viewId);
1855
2442
  }
1856
2443
  }
1857
2444
  }
@@ -1926,6 +2513,63 @@ var Updater = class {
1926
2513
  }
1927
2514
  };
1928
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
+
1929
2573
  // src/view.ts
1930
2574
  var VIEW_GLOBALS = {};
1931
2575
  if (typeof window !== "undefined") {
@@ -2202,17 +2846,16 @@ var View = class _View {
2202
2846
  }
2203
2847
  const makes = [];
2204
2848
  oView.makes = makes;
2205
- const proto = oView.prototype;
2206
2849
  const eventsObject = {};
2207
2850
  const eventsList = [];
2208
2851
  const selectorObject = {};
2209
- const mixins = proto["mixins"];
2852
+ const mixins = Reflect.get(oView.prototype, "mixins");
2210
2853
  if (mixins && Array.isArray(mixins)) {
2211
2854
  _View.mergeMixins(mixins, oView, makes);
2212
2855
  }
2213
- for (const p in proto) {
2214
- if (!hasOwnProperty(proto, p)) continue;
2215
- const currentFn = proto[p];
2856
+ for (const p in oView.prototype) {
2857
+ if (!hasOwnProperty(oView.prototype, p)) continue;
2858
+ const currentFn = Reflect.get(oView.prototype, p);
2216
2859
  if (typeof currentFn !== "function") continue;
2217
2860
  const matches = p.match(VIEW_EVENT_METHOD_REGEXP);
2218
2861
  if (!matches) continue;
@@ -2254,29 +2897,30 @@ var View = class _View {
2254
2897
  }
2255
2898
  eventsObject[item] = (eventsObject[item] || 0) | mask;
2256
2899
  const combinedKey = selectorOrCallback + SPLITTER + item;
2257
- const existingFn = proto[combinedKey];
2900
+ const existingFn = Reflect.get(oView.prototype, combinedKey);
2258
2901
  if (!existingFn) {
2259
- proto[combinedKey] = currentFn;
2902
+ Reflect.set(oView.prototype, combinedKey, currentFn);
2260
2903
  } else if (typeof existingFn === "function") {
2261
2904
  const mixinFn = currentFn;
2262
2905
  const existingMixin = existingFn;
2263
2906
  if (existingMixin.marker) {
2264
2907
  if (mixinFn.marker) {
2265
- proto[combinedKey] = _View.processMixinsSameEvent(
2266
- mixinFn,
2267
- existingMixin
2908
+ Reflect.set(
2909
+ oView.prototype,
2910
+ combinedKey,
2911
+ _View.processMixinsSameEvent(mixinFn, existingMixin)
2268
2912
  );
2269
- } else if (hasOwnProperty(proto, p)) {
2270
- proto[combinedKey] = currentFn;
2913
+ } else if (hasOwnProperty(oView.prototype, p)) {
2914
+ Reflect.set(oView.prototype, combinedKey, currentFn);
2271
2915
  }
2272
2916
  }
2273
2917
  }
2274
2918
  }
2275
2919
  }
2276
- _View.wrapMethod(proto, "render", "$renderWrap");
2277
- proto["$evtObjMap"] = eventsObject;
2278
- proto["$globalEvtList"] = eventsList;
2279
- proto["$selMap"] = selectorObject;
2920
+ _View.wrapMethod(asRecord(oView.prototype), "render", "$renderWrap");
2921
+ Reflect.set(oView.prototype, "$evtObjMap", eventsObject);
2922
+ Reflect.set(oView.prototype, "$globalEvtList", eventsList);
2923
+ Reflect.set(oView.prototype, "$selMap", selectorObject);
2280
2924
  return makes;
2281
2925
  }
2282
2926
  /**
@@ -2367,7 +3011,7 @@ var View = class _View {
2367
3011
  this.signature++;
2368
3012
  this.fire("render");
2369
3013
  _View.destroyAllResources(this, false);
2370
- const lookup = this;
3014
+ const lookup = asRecord(this);
2371
3015
  const candidate = lookup[fnName];
2372
3016
  const instanceFn = typeof candidate === "function" ? candidate : originalAsFn;
2373
3017
  const fnToCall = instanceFn === wrapped ? originalAsFn : instanceFn;
@@ -2403,7 +3047,7 @@ var View = class _View {
2403
3047
  * Merge an array of mixin objects into the view prototype.
2404
3048
  */
2405
3049
  static mergeMixins(mixins, viewClass, makes) {
2406
- const proto = viewClass.prototype;
3050
+ const proto = asRecord(viewClass.prototype);
2407
3051
  const temp = {};
2408
3052
  for (const node of mixins) {
2409
3053
  for (const p in node) {
@@ -2494,17 +3138,15 @@ var View = class _View {
2494
3138
  }
2495
3139
  }
2496
3140
  };
2497
- const proto = ChildView.prototype;
2498
3141
  for (const key in definedProps) {
2499
3142
  if (hasOwnProperty(definedProps, key) && key !== "make") {
2500
- proto[key] = definedProps[key];
3143
+ Reflect.set(ChildView.prototype, key, definedProps[key]);
2501
3144
  }
2502
3145
  }
2503
3146
  if (statics) {
2504
- const staticTarget = ChildView;
2505
3147
  for (const key in statics) {
2506
3148
  if (hasOwnProperty(statics, key)) {
2507
- staticTarget[key] = statics[key];
3149
+ Reflect.set(ChildView, key, statics[key]);
2508
3150
  }
2509
3151
  }
2510
3152
  }
@@ -2518,81 +3160,51 @@ var View = class _View {
2518
3160
  _View.mergeMixins(mixins, this, existingCtors);
2519
3161
  return this;
2520
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
+ }
2521
3203
  };
2522
3204
  function defineView(props, statics) {
2523
3205
  return View.extend(props, statics);
2524
3206
  }
2525
3207
 
2526
- // src/module-loader.ts
2527
- var config = {
2528
- rootId: "root",
2529
- routeMode: "history",
2530
- hashbang: "#!",
2531
- error: (error) => {
2532
- throw error;
2533
- }
2534
- };
2535
- function use(names, callback) {
2536
- const nameList = typeof names === "string" ? [names] : names;
2537
- const loadPromise = (() => {
2538
- if (config.require) {
2539
- const result = config.require(nameList);
2540
- if (result && typeof result.then === "function") {
2541
- return result;
2542
- }
2543
- return Promise.resolve([]);
2544
- }
2545
- return Promise.all(
2546
- nameList.map((name) => {
2547
- const importPath = name.startsWith(".") || name.startsWith("/") ? name : `./${name}`;
2548
- return import(
2549
- /* @vite-ignore */
2550
- /* webpackIgnore: true */
2551
- importPath
2552
- ).then((mod) => {
2553
- return mod && (mod["__esModule"] || // For Webpack
2554
- typeof mod["default"] === "function") ? mod["default"] : mod;
2555
- }).catch((err) => {
2556
- const errorHandler = config.error;
2557
- if (errorHandler) {
2558
- errorHandler(err instanceof Error ? err : new Error(String(err)));
2559
- }
2560
- return void 0;
2561
- });
2562
- })
2563
- );
2564
- })();
2565
- if (callback) {
2566
- loadPromise.then((modules) => {
2567
- callback(...modules);
2568
- });
2569
- }
2570
- return loadPromise;
2571
- }
2572
-
2573
- // src/view-registry.ts
2574
- var viewClassRegistry = {};
2575
- function getViewClass(path) {
2576
- return viewClassRegistry[path];
2577
- }
2578
- function registerViewClass(viewPath, ViewClass) {
2579
- const parsed = parseUri(viewPath);
2580
- const path = parsed.path;
2581
- if (path) {
2582
- viewClassRegistry[path] = ViewClass;
2583
- }
2584
- }
2585
- function invalidateViewClass(viewPath) {
2586
- const parsed = parseUri(viewPath);
2587
- const path = parsed.path;
2588
- if (path) {
2589
- Reflect.deleteProperty(viewClassRegistry, path);
2590
- }
2591
- }
2592
- function getViewClassRegistry() {
2593
- return viewClassRegistry;
2594
- }
2595
-
2596
3208
  // src/frame.ts
2597
3209
  var frameRegistry = /* @__PURE__ */ new Map();
2598
3210
  var rootFrame;
@@ -2716,9 +3328,15 @@ var Frame = class _Frame extends EventEmitter {
2716
3328
  */
2717
3329
  doMountView(ViewClass, params, node, sign) {
2718
3330
  if (sign !== this.signature) return;
2719
- const mixinCtors = View.prepare(ViewClass);
2720
- const Ctor = ViewClass;
2721
- const view = new Ctor(this.id, this, params, node, mixinCtors);
3331
+ const mixinConstructors = View.prepare(ViewClass);
3332
+ const Constructor = ViewClass;
3333
+ const view = new Constructor(
3334
+ this.id,
3335
+ this,
3336
+ params,
3337
+ node,
3338
+ mixinConstructors
3339
+ );
2722
3340
  this.viewInstance = view;
2723
3341
  view.signature = 1;
2724
3342
  View.delegateEvents(view);
@@ -2879,8 +3497,7 @@ var Frame = class _Frame extends EventEmitter {
2879
3497
  let result;
2880
3498
  const view = this.view;
2881
3499
  if (view && view.rendered) {
2882
- const lookup = view;
2883
- const fn = lookup[name];
3500
+ const fn = Reflect.get(view, name);
2884
3501
  if (typeof fn === "function") {
2885
3502
  result = funcWithTry(fn, args || [], view, noop);
2886
3503
  }
@@ -3435,7 +4052,7 @@ var Service = class {
3435
4052
  }
3436
4053
  const cached = this._payloadCache.get(cacheKey);
3437
4054
  if (cached && cached.cacheInfo) {
3438
- if (now() - cached.cacheInfo.time > cache) {
4055
+ if (Date.now() - cached.cacheInfo.time > cache) {
3439
4056
  this._payloadCache.del(cacheKey);
3440
4057
  return void 0;
3441
4058
  }
@@ -3593,7 +4210,7 @@ function serviceSend(service, attrs, done, flag, save) {
3593
4210
  const list = pendingCacheKeys[cacheKey];
3594
4211
  const entity = list.entity;
3595
4212
  if (entity instanceof Payload && entity.cacheInfo) {
3596
- entity.cacheInfo.time = now();
4213
+ entity.cacheInfo.time = Date.now();
3597
4214
  internals.payloadCache.set(cacheKey, entity);
3598
4215
  }
3599
4216
  Reflect.deleteProperty(pendingCacheKeys, cacheKey);
@@ -3611,20 +4228,19 @@ function serviceSend(service, attrs, done, flag, save) {
3611
4228
  }
3612
4229
  }
3613
4230
 
3614
- // src/frame-visual.ts
3615
- var FrameVisualBridge = {
3616
- MSG_PING: "LARK_VIS_PING",
3617
- MSG_PONG: "LARK_VIS_PONG",
3618
- MSG_REQUEST_TREE: "LARK_VIS_REQUEST_TREE",
3619
- MSG_TREE: "LARK_VIS_TREE",
3620
- MSG_TREE_DELTA: "LARK_VIS_TREE_DELTA"
4231
+ // src/devtool.ts
4232
+ var FrameDevtoolBridge = {
4233
+ MSG_PING: "LARK_DEVTOOL_PING",
4234
+ MSG_PONG: "LARK_DEVTOOL_PONG",
4235
+ MSG_REQUEST_TREE: "LARK_DEVTOOL_REQUEST_TREE",
4236
+ MSG_TREE: "LARK_DEVTOOL_TREE",
4237
+ MSG_TREE_DELTA: "LARK_DEVTOOL_TREE_DELTA"
3621
4238
  };
3622
4239
  function serializeView(view) {
3623
4240
  const evtMap = view.eventObjectMap;
3624
4241
  const eventMethodKeys = evtMap ? Object.keys(evtMap) : [];
3625
4242
  const resourceKeys = view.resources ? Object.keys(view.resources) : [];
3626
- const lookup = view;
3627
- const hasAssign = typeof lookup["assign"] === "function";
4243
+ const hasAssign = typeof view["assign"] === "function";
3628
4244
  let updaterData = null;
3629
4245
  try {
3630
4246
  const ref = view.updater?.refData;
@@ -3702,7 +4318,7 @@ function serializeFrameTree() {
3702
4318
  }
3703
4319
  var bridgeInstalled = false;
3704
4320
  var lastTreeJson = "";
3705
- function installFrameVisualizerBridge() {
4321
+ function installFrameDevtoolBridge() {
3706
4322
  if (bridgeInstalled) return;
3707
4323
  if (typeof window === "undefined") return;
3708
4324
  bridgeInstalled = true;
@@ -3710,22 +4326,22 @@ function installFrameVisualizerBridge() {
3710
4326
  const data = event.data;
3711
4327
  if (!data || typeof data !== "object") return;
3712
4328
  const type = data.type;
3713
- if (type === FrameVisualBridge.MSG_PING) {
4329
+ if (type === FrameDevtoolBridge.MSG_PING) {
3714
4330
  const source = event.source;
3715
4331
  if (source) {
3716
4332
  source.postMessage(
3717
- { type: FrameVisualBridge.MSG_PONG },
4333
+ { type: FrameDevtoolBridge.MSG_PONG },
3718
4334
  { targetOrigin: "*" }
3719
4335
  );
3720
4336
  }
3721
4337
  return;
3722
4338
  }
3723
- if (type === FrameVisualBridge.MSG_REQUEST_TREE) {
4339
+ if (type === FrameDevtoolBridge.MSG_REQUEST_TREE) {
3724
4340
  const tree = serializeFrameTree();
3725
4341
  const source = event.source;
3726
4342
  if (source) {
3727
4343
  source.postMessage(
3728
- { type: FrameVisualBridge.MSG_TREE, data: tree },
4344
+ { type: FrameDevtoolBridge.MSG_TREE, data: tree },
3729
4345
  { targetOrigin: "*" }
3730
4346
  );
3731
4347
  }
@@ -3745,7 +4361,7 @@ function pushTreeUpdate() {
3745
4361
  if (treeJson !== lastTreeJson) {
3746
4362
  lastTreeJson = treeJson;
3747
4363
  window.parent.postMessage(
3748
- { type: FrameVisualBridge.MSG_TREE_DELTA, data: tree },
4364
+ { type: FrameDevtoolBridge.MSG_TREE_DELTA, data: tree },
3749
4365
  "*"
3750
4366
  );
3751
4367
  }
@@ -3758,7 +4374,7 @@ var taskIndex = 0;
3758
4374
  var taskScheduled = false;
3759
4375
  function executeTaskChunk(deadline) {
3760
4376
  const hasDeadline = !!deadline;
3761
- const startTime = now();
4377
+ const startTime = Date.now();
3762
4378
  while (true) {
3763
4379
  const fn = taskList[taskIndex];
3764
4380
  if (!fn) {
@@ -3772,7 +4388,7 @@ function executeTaskChunk(deadline) {
3772
4388
  scheduleTaskChunk();
3773
4389
  return;
3774
4390
  }
3775
- } else if (now() - startTime > CALL_BREAK_TIME && taskList.length > taskIndex + 3) {
4391
+ } else if (Date.now() - startTime > CALL_BREAK_TIME && taskList.length > taskIndex + 3) {
3776
4392
  scheduleTaskChunk();
3777
4393
  return;
3778
4394
  }
@@ -3904,10 +4520,10 @@ function waitZoneViewsRendered(viewId, timeout) {
3904
4520
  timeout = 30 * 1e3;
3905
4521
  }
3906
4522
  const checkFrame = Frame.get(viewId);
3907
- const endTime = now() + timeout;
4523
+ const endTime = Date.now() + timeout;
3908
4524
  return new Promise((resolve) => {
3909
4525
  const check = () => {
3910
- const currentTime = now();
4526
+ const currentTime = Date.now();
3911
4527
  if (currentTime > endTime || !checkFrame) {
3912
4528
  resolve(WAIT_TIMEOUT_OR_NOT_FOUND);
3913
4529
  } else if (checkFrame.childrenCount === checkFrame.readyCount) {
@@ -3969,7 +4585,7 @@ var Framework = {
3969
4585
  booted3 = true;
3970
4586
  markBooted();
3971
4587
  markRouterBooted();
3972
- installFrameVisualizerBridge();
4588
+ installFrameDevtoolBridge();
3973
4589
  const rootFrame2 = Frame.createRoot(config.rootId);
3974
4590
  Router._bind();
3975
4591
  const defaultView = config.defaultView || "";
@@ -4244,7 +4860,6 @@ function bindStore(view, store, selector) {
4244
4860
  EventDelegator,
4245
4861
  EventEmitter,
4246
4862
  Frame,
4247
- FrameVisualBridge,
4248
4863
  Framework,
4249
4864
  LARK_VIEW,
4250
4865
  Payload,
@@ -4261,20 +4876,21 @@ function bindStore(view, store, selector) {
4261
4876
  bindStore,
4262
4877
  computed,
4263
4878
  create,
4879
+ createVDomRef,
4264
4880
  defineView,
4265
4881
  frameworkConfig,
4266
4882
  getRouteMode,
4267
- installFrameVisualizerBridge,
4268
4883
  invalidateViewClass,
4269
4884
  mark,
4270
4885
  markBooted,
4271
4886
  markRouterBooted,
4272
4887
  nextCounter,
4273
4888
  registerViewClass,
4889
+ reloadViews,
4274
4890
  resetProjectsMap,
4275
4891
  safeguard,
4276
- serializeFrameTree,
4277
4892
  unmark,
4278
4893
  use,
4279
- useUrlState
4894
+ useUrlState,
4895
+ vdomCreate
4280
4896
  });