@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.d.cts CHANGED
@@ -121,6 +121,34 @@ declare class EventEmitter<T = unknown> implements EventEmitterInterface<T> {
121
121
  fire(event: string, data?: Record<string, unknown>, remove?: boolean, lastToFirst?: boolean): this;
122
122
  }
123
123
 
124
+ /**
125
+ * Minimal HMR context interface.
126
+ * Compatible with Vite's `import.meta.hot` and webpack's `module.hot`.
127
+ * Defined here to avoid depending on bundler-specific type packages.
128
+ */
129
+ interface HotContext {
130
+ /** Accept a self-update. The callback receives the new module namespace. */
131
+ accept(cb?: (mod: {
132
+ default?: unknown;
133
+ } | undefined) => void): void;
134
+ /** Register a cleanup callback that runs before this module is replaced. */
135
+ dispose(cb: (data: unknown) => void): void;
136
+ /** Force a full page reload (fallback when HMR cannot handle the update). */
137
+ invalidate(): void;
138
+ }
139
+ /**
140
+ * Find all currently mounted frames whose viewPath matches the given path,
141
+ * and re-mount them.
142
+ *
143
+ * After a new View class is registered via `registerViewClass`, calling this
144
+ * function triggers `frame.mountView()` on each matching frame. Since the new
145
+ * class is already in the registry, `Frame.mountView` takes the synchronous
146
+ * path (`getViewClass` returns the class immediately).
147
+ *
148
+ * @param viewPath - The view path to match (e.g. 'home', 'components/list')
149
+ */
150
+ declare function reloadViews(viewPath: string): void;
151
+
124
152
  /**
125
153
  * Base View class.
126
154
  * Views are created via View.extend() and mounted by Frame.
@@ -274,6 +302,37 @@ declare class View implements ViewInterface {
274
302
  * Merge mixins into View prototype.
275
303
  */
276
304
  static merge(this: typeof View, ...mixins: Record<string, unknown>[]): typeof View;
305
+ /**
306
+ * Set up HMR accept handler for this view module.
307
+ *
308
+ * When the module is hot-replaced, the new View class is extracted from
309
+ * the new module, registered in the view registry, and all currently
310
+ * mounted frames using this viewPath are re-mounted.
311
+ *
312
+ * No-op when `hot` is undefined (production / non-HMR environment).
313
+ *
314
+ * ```ts
315
+ * if (import.meta.hot) {
316
+ * HomeView.accept(import.meta.hot, 'home');
317
+ * }
318
+ * ```
319
+ */
320
+ static accept(hot: HotContext | undefined, viewPath: string): void;
321
+ /**
322
+ * Set up HMR dispose handler for this view module.
323
+ *
324
+ * When the module is about to be replaced, the old View class is removed
325
+ * from the registry so subsequent lookups don't return the stale class.
326
+ *
327
+ * No-op when `hot` is undefined (production / non-HMR environment).
328
+ *
329
+ * ```ts
330
+ * if (import.meta.hot) {
331
+ * HomeView.dispose(import.meta.hot, 'home');
332
+ * }
333
+ * ```
334
+ */
335
+ static dispose(hot: HotContext | undefined, viewPath: string): void;
277
336
  }
278
337
  /**
279
338
  * Type-safe wrapper around `View.extend()`.
@@ -665,6 +724,68 @@ interface DomRef {
665
724
  * Comment), so the child slots are typed as ChildNode.
666
725
  */
667
726
  type DomOp = [1, Element, ChildNode] | [2, Element, ChildNode] | [4, Element, ChildNode, ChildNode] | [8, Element, ChildNode, ChildNode];
727
+ /**
728
+ * Virtual DOM node. Produced by `vdomCreate`, consumed by the VDOM diff engine.
729
+ *
730
+ * Property semantics:
731
+ * - Text nodes: tag = 0 (V_TEXT_NODE), html = text content
732
+ * - Element nodes: tag = string, attrs = serialized opening tag, children = child VDomNodes
733
+ * - Raw HTML nodes: tag = SPLITTER (\x1e), html = raw HTML string
734
+ * - Self-closing: selfClose = true (children param was 1)
735
+ */
736
+ interface VDomNode {
737
+ /** Tag name for elements, 0 (V_TEXT_NODE) for text, SPLITTER for raw HTML */
738
+ tag: string | number;
739
+ /** Inner HTML (serialized children for elements, text content for text nodes) */
740
+ html: string;
741
+ /** Serialized opening tag with attributes, e.g. '<div class="row"' */
742
+ attrs?: string;
743
+ /** Attribute key-value map */
744
+ attrsMap?: Record<string, unknown>;
745
+ /** Attribute names that are set as DOM properties (not attributes) */
746
+ attrsSpecials?: Record<string, string>;
747
+ /** Original specials argument before defaulting (for change detection) */
748
+ hasSpecials?: Record<string, string> | undefined;
749
+ /** Child VDomNode array (undefined for text/raw/self-closing) */
750
+ children?: VDomNode[] | undefined;
751
+ /** Diff key: from id, #, or v-lark path */
752
+ compareKey?: string | undefined;
753
+ /** Keyed children count map (compareKey -> count) */
754
+ reused?: Record<string, number> | undefined;
755
+ /** Total count of keyed children */
756
+ reusedTotal?: number;
757
+ /** Sub-view references: [viewPath, owner, uri, params] tuples */
758
+ views?: [string, string, string, Record<string, string>][] | undefined;
759
+ /** Whether self-closing (children param was literal 1) */
760
+ selfClose?: boolean;
761
+ /** Sub-view path if this node hosts a v-lark view, otherwise falsy */
762
+ isLarkView?: string | undefined;
763
+ }
764
+ /**
765
+ * VDOM diff operation tracker. Parallel to DomRef but for the VDOM pipeline.
766
+ */
767
+ interface VDomRef {
768
+ /** View ID (for placeholder replacement) */
769
+ viewId: string;
770
+ /** Sub-views that need re-rendering after diff */
771
+ viewRenders: ViewInterface[];
772
+ /** Deferred DOM property assignments: [element, propName, value][] */
773
+ nodeProps: [Element, string, unknown][];
774
+ /** Pending async operation count */
775
+ asyncCount: number;
776
+ /** Whether the DOM actually changed */
777
+ changed: number;
778
+ /** DOM mutation operations (same format as DomOp) */
779
+ domOps: DomOp[];
780
+ }
781
+ /** VDOM node creation function signature (vdomCreate) */
782
+ type VDomCreateFn = (tag: string | number, props?: Record<string, unknown> | number | null, children?: VDomNode[] | number | null, specials?: Record<string, string>) => VDomNode;
783
+ /**
784
+ * VDOM template function signature.
785
+ * The compiled template imports vdomCreate via ES module import and
786
+ * takes only (data, viewId, refData). Extra arguments are ignored.
787
+ */
788
+ type VDomTemplate = (data: unknown, viewId: string, refData: unknown) => VDomNode;
668
789
  interface FrameInvokeEntry {
669
790
  /** Method name */
670
791
  name: string;
@@ -858,7 +979,7 @@ interface ViewInterface extends EventEmitterInterface<ViewInterface> {
858
979
  * View template function. Receives data + viewId + refData and a set of
859
980
  * encoder helpers wired in by the Updater, and returns the rendered HTML.
860
981
  */
861
- template?: ViewTemplate;
982
+ template?: ViewTemplate | VDomTemplate;
862
983
  /**
863
984
  * Mixin object array for extending view functionality.
864
985
  * Framework merges properties and methods from mixins into view prototype.
@@ -879,6 +1000,8 @@ interface ViewInterface extends EventEmitterInterface<ViewInterface> {
879
1000
  globalEventList: ViewGlobalEventEntry[];
880
1001
  /** Whether endUpdate has been called (1 = pending) */
881
1002
  endUpdatePending?: number;
1003
+ /** Last rendered VDOM tree (only used when virtualDom is enabled) */
1004
+ vdom?: VDomNode;
882
1005
  /** Render method (wrapped) */
883
1006
  render(): void;
884
1007
  /**
@@ -1602,7 +1725,7 @@ interface FrameworkConfig {
1602
1725
  */
1603
1726
  crossConfigs?: CrossSiteConfig[];
1604
1727
  /** Default false. */
1605
- virtualDOM?: boolean;
1728
+ virtualDom?: boolean;
1606
1729
  /** Dynamic config access, custom config items */
1607
1730
  [key: string]: unknown;
1608
1731
  }
@@ -1659,6 +1782,10 @@ interface CompileOptions {
1659
1782
  globalVars?: string[];
1660
1783
  /** File path for debug error messages (default: undefined) */
1661
1784
  file?: string;
1785
+ /** Generate VDOM output instead of HTML string (default: false) */
1786
+ virtualDom?: boolean;
1787
+ /** Use SWC instead of Babel for parsing (default: false) */
1788
+ useSwc?: boolean;
1662
1789
  }
1663
1790
 
1664
1791
  /**
@@ -1828,6 +1955,8 @@ declare class Updater implements UpdaterInterface {
1828
1955
  private version;
1829
1956
  /** Snapshot of `version` taken by `snapshot()`, used by `altered()`. */
1830
1957
  private snapshotVersion;
1958
+ /** Last rendered VDOM tree (only used when virtualDom is enabled) */
1959
+ private vdom?;
1831
1960
  constructor(viewId: string);
1832
1961
  /**
1833
1962
  * Get data by key.
@@ -1890,6 +2019,21 @@ declare class Updater implements UpdaterInterface {
1890
2019
  getChangedKeys(): ReadonlySet<string>;
1891
2020
  }
1892
2021
 
2022
+ /**
2023
+ * Create a virtual DOM node.
2024
+ *
2025
+ * Text node: `vdomCreate(0, 'text content')`
2026
+ * Element: `vdomCreate('div', { class: 'row' }, [child1, child2])`
2027
+ * Self-closing: `vdomCreate('br', null, 1)`
2028
+ * Raw HTML: `vdomCreate(0, '<b>bold</b>', 1)` (children truthy → raw HTML node)
2029
+ * Root: `vdomCreate(viewId, 0, [children])`
2030
+ */
2031
+ declare function vdomCreate(tag: string | number, props?: Record<string, unknown> | string | number | null, children?: VDomNode[] | string | number | null, specials?: Record<string, string>): VDomNode;
2032
+ /**
2033
+ * Create an empty VDomRef for tracking diff operations.
2034
+ */
2035
+ declare function createVDomRef(viewId: string): VDomRef;
2036
+
1893
2037
  /**
1894
2038
  * Payload wraps API response data with convenient access methods.
1895
2039
  */
@@ -2186,86 +2330,4 @@ declare function create<T>(name: string, creator: StateCreator<T>): StoreApi<T>;
2186
2330
  */
2187
2331
  declare function bindStore<T>(view: unknown, store: StoreApi<T>, selector?: (state: T) => Record<string, unknown>): () => void;
2188
2332
 
2189
- /** Serialized view info attached to a frame node */
2190
- interface SerializedViewInfo {
2191
- /** View ID (same as frame ID) */
2192
- id: string;
2193
- /** Whether the view has rendered at least once */
2194
- rendered: boolean;
2195
- /** View signature (> 0 = active) */
2196
- signature: number;
2197
- /** Observed state keys */
2198
- observedStateKeys: string[] | null;
2199
- /** Location observation config */
2200
- locationObserved: {
2201
- flag: number;
2202
- keys: string[];
2203
- observePath: boolean;
2204
- };
2205
- /** Whether view has a template function */
2206
- hasTemplate: boolean;
2207
- /** Delegated event types (keys from $evtObjMap) */
2208
- eventMethodKeys: string[];
2209
- /** Captured resource keys */
2210
- resourceKeys: string[];
2211
- /** Whether view exposes an assign method (supports CrossSite reuse) */
2212
- hasAssign: boolean;
2213
- /** Updater refData snapshot (shallow copy of current data) */
2214
- updaterData: Record<string, unknown> | null;
2215
- }
2216
- /** A single node in the serialized frame tree */
2217
- interface SerializedFrameNode {
2218
- /** Frame ID (same as owner DOM element ID) */
2219
- id: string;
2220
- /** Parent frame ID (null for root) */
2221
- parentId: string | null;
2222
- /** View path (v-lark attribute value) */
2223
- viewPath: string | null;
2224
- /** Number of child frames */
2225
- childrenCount: number;
2226
- /** Number of children that have fired 'created' */
2227
- readyCount: number;
2228
- /** Whether children have been created */
2229
- childrenCreated: number;
2230
- /** Whether children are in alter state */
2231
- childrenAlter: number;
2232
- /** Whether this frame is destroyed */
2233
- destroyed: number;
2234
- /** Serialized view info (null if no view mounted) */
2235
- view: SerializedViewInfo | null;
2236
- /** Child frame nodes */
2237
- children: SerializedFrameNode[];
2238
- }
2239
- /** Top-level serialized frame tree */
2240
- interface SerializedFrameTree {
2241
- /** Root frame node */
2242
- root: SerializedFrameNode | null;
2243
- /** Total frame count */
2244
- totalFrames: number;
2245
- /** Timestamp of serialization */
2246
- timestamp: number;
2247
- /** Root element ID */
2248
- rootId: string;
2249
- }
2250
- declare const FrameVisualBridge: {
2251
- MSG_PING: string;
2252
- MSG_PONG: string;
2253
- MSG_REQUEST_TREE: string;
2254
- MSG_TREE: string;
2255
- MSG_TREE_DELTA: string;
2256
- };
2257
- /**
2258
- * Serialize the entire Frame tree starting from root.
2259
- * Returns an empty snapshot if the app hasn't booted yet.
2260
- */
2261
- declare function serializeFrameTree(): SerializedFrameTree;
2262
- /**
2263
- * Install the Frame Visualizer Bridge.
2264
- * Listens for postMessage events from the visualizer and responds
2265
- * with serialized frame tree data.
2266
- *
2267
- * This should be called once during Framework.boot().
2268
- */
2269
- declare function installFrameVisualizerBridge(): void;
2270
-
2271
- export { type AnyFunc, CALL_BREAK_TIME, Cache, type CacheEntry, type CacheInterface, type CacheOptions, type ChangeEvent, type CompileOptions, CrossSite, type CrossSiteConfig, type DomElement, type DomOp, type DomRef, EVENT_METHOD_REGEXP, EventDelegator, EventEmitter, type EventEmitterInterface, type EventListenerEntry, Frame, type FrameBoundElement, type FrameInterface, type FrameInvokeEntry, type FrameStaticEvent, FrameVisualBridge, Framework, type FrameworkConfig, type FrameworkInterface, LARK_VIEW, type Location, type LocationDiff, type MixinEventHandler, type ParamDiff, type ParsedUri, Payload, type PayloadInterface, type PendingCacheEntry, RouterEvents as ROUTER_EVENTS, type RouteChangeEvent, type RouteChangedEvent, type RouteViewConfig, Router, type RouterInterface, SPLITTER, type SerializedFrameNode, type SerializedFrameTree, type SerializedViewInfo, Service, type ServiceCacheInfo, type ServiceEvent, type ServiceMetaEntry, type ServiceOptions, State, type StateInterface, type StoreApi, TAG_NAME_REGEXP, Updater, type UpdaterInterface, VIEW_EVENT_METHOD_REGEXP, View, type ViewEvent, type ViewEventSelectorEntry, type ViewGlobalEventEntry, type ViewInterface, type ViewLocationObserved, type ViewObserveLocation, type ViewResourceEntry, type ViewTemplate, type VoidFunc, applyStyle, bindStore, computed, create, defineView, config as frameworkConfig, getRouteMode, installFrameVisualizerBridge, invalidateViewClass, mark, markBooted, markRouterBooted, nextCounter, registerViewClass, resetProjectsMap, safeguard, serializeFrameTree, unmark, use, useUrlState };
2333
+ export { type AnyFunc, CALL_BREAK_TIME, Cache, type CacheEntry, type CacheInterface, type CacheOptions, type ChangeEvent, type CompileOptions, CrossSite, type CrossSiteConfig, type DomElement, type DomOp, type DomRef, EVENT_METHOD_REGEXP, EventDelegator, EventEmitter, type EventEmitterInterface, type EventListenerEntry, Frame, type FrameBoundElement, type FrameInterface, type FrameInvokeEntry, type FrameStaticEvent, Framework, type FrameworkConfig, type FrameworkInterface, type HotContext, LARK_VIEW, type Location, type LocationDiff, type MixinEventHandler, type ParamDiff, type ParsedUri, Payload, type PayloadInterface, type PendingCacheEntry, RouterEvents as ROUTER_EVENTS, type RouteChangeEvent, type RouteChangedEvent, type RouteViewConfig, Router, type RouterInterface, SPLITTER, Service, type ServiceCacheInfo, type ServiceEvent, type ServiceMetaEntry, type ServiceOptions, State, type StateInterface, type StoreApi, TAG_NAME_REGEXP, Updater, type UpdaterInterface, type VDomCreateFn, type VDomNode, type VDomRef, type VDomTemplate, VIEW_EVENT_METHOD_REGEXP, View, type ViewEvent, type ViewEventSelectorEntry, type ViewGlobalEventEntry, type ViewInterface, type ViewLocationObserved, type ViewObserveLocation, type ViewResourceEntry, type ViewTemplate, type VoidFunc, applyStyle, bindStore, computed, create, createVDomRef, defineView, config as frameworkConfig, getRouteMode, invalidateViewClass, mark, markBooted, markRouterBooted, nextCounter, registerViewClass, reloadViews, resetProjectsMap, safeguard, unmark, use, useUrlState, vdomCreate };
package/dist/index.d.ts CHANGED
@@ -121,6 +121,34 @@ declare class EventEmitter<T = unknown> implements EventEmitterInterface<T> {
121
121
  fire(event: string, data?: Record<string, unknown>, remove?: boolean, lastToFirst?: boolean): this;
122
122
  }
123
123
 
124
+ /**
125
+ * Minimal HMR context interface.
126
+ * Compatible with Vite's `import.meta.hot` and webpack's `module.hot`.
127
+ * Defined here to avoid depending on bundler-specific type packages.
128
+ */
129
+ interface HotContext {
130
+ /** Accept a self-update. The callback receives the new module namespace. */
131
+ accept(cb?: (mod: {
132
+ default?: unknown;
133
+ } | undefined) => void): void;
134
+ /** Register a cleanup callback that runs before this module is replaced. */
135
+ dispose(cb: (data: unknown) => void): void;
136
+ /** Force a full page reload (fallback when HMR cannot handle the update). */
137
+ invalidate(): void;
138
+ }
139
+ /**
140
+ * Find all currently mounted frames whose viewPath matches the given path,
141
+ * and re-mount them.
142
+ *
143
+ * After a new View class is registered via `registerViewClass`, calling this
144
+ * function triggers `frame.mountView()` on each matching frame. Since the new
145
+ * class is already in the registry, `Frame.mountView` takes the synchronous
146
+ * path (`getViewClass` returns the class immediately).
147
+ *
148
+ * @param viewPath - The view path to match (e.g. 'home', 'components/list')
149
+ */
150
+ declare function reloadViews(viewPath: string): void;
151
+
124
152
  /**
125
153
  * Base View class.
126
154
  * Views are created via View.extend() and mounted by Frame.
@@ -274,6 +302,37 @@ declare class View implements ViewInterface {
274
302
  * Merge mixins into View prototype.
275
303
  */
276
304
  static merge(this: typeof View, ...mixins: Record<string, unknown>[]): typeof View;
305
+ /**
306
+ * Set up HMR accept handler for this view module.
307
+ *
308
+ * When the module is hot-replaced, the new View class is extracted from
309
+ * the new module, registered in the view registry, and all currently
310
+ * mounted frames using this viewPath are re-mounted.
311
+ *
312
+ * No-op when `hot` is undefined (production / non-HMR environment).
313
+ *
314
+ * ```ts
315
+ * if (import.meta.hot) {
316
+ * HomeView.accept(import.meta.hot, 'home');
317
+ * }
318
+ * ```
319
+ */
320
+ static accept(hot: HotContext | undefined, viewPath: string): void;
321
+ /**
322
+ * Set up HMR dispose handler for this view module.
323
+ *
324
+ * When the module is about to be replaced, the old View class is removed
325
+ * from the registry so subsequent lookups don't return the stale class.
326
+ *
327
+ * No-op when `hot` is undefined (production / non-HMR environment).
328
+ *
329
+ * ```ts
330
+ * if (import.meta.hot) {
331
+ * HomeView.dispose(import.meta.hot, 'home');
332
+ * }
333
+ * ```
334
+ */
335
+ static dispose(hot: HotContext | undefined, viewPath: string): void;
277
336
  }
278
337
  /**
279
338
  * Type-safe wrapper around `View.extend()`.
@@ -665,6 +724,68 @@ interface DomRef {
665
724
  * Comment), so the child slots are typed as ChildNode.
666
725
  */
667
726
  type DomOp = [1, Element, ChildNode] | [2, Element, ChildNode] | [4, Element, ChildNode, ChildNode] | [8, Element, ChildNode, ChildNode];
727
+ /**
728
+ * Virtual DOM node. Produced by `vdomCreate`, consumed by the VDOM diff engine.
729
+ *
730
+ * Property semantics:
731
+ * - Text nodes: tag = 0 (V_TEXT_NODE), html = text content
732
+ * - Element nodes: tag = string, attrs = serialized opening tag, children = child VDomNodes
733
+ * - Raw HTML nodes: tag = SPLITTER (\x1e), html = raw HTML string
734
+ * - Self-closing: selfClose = true (children param was 1)
735
+ */
736
+ interface VDomNode {
737
+ /** Tag name for elements, 0 (V_TEXT_NODE) for text, SPLITTER for raw HTML */
738
+ tag: string | number;
739
+ /** Inner HTML (serialized children for elements, text content for text nodes) */
740
+ html: string;
741
+ /** Serialized opening tag with attributes, e.g. '<div class="row"' */
742
+ attrs?: string;
743
+ /** Attribute key-value map */
744
+ attrsMap?: Record<string, unknown>;
745
+ /** Attribute names that are set as DOM properties (not attributes) */
746
+ attrsSpecials?: Record<string, string>;
747
+ /** Original specials argument before defaulting (for change detection) */
748
+ hasSpecials?: Record<string, string> | undefined;
749
+ /** Child VDomNode array (undefined for text/raw/self-closing) */
750
+ children?: VDomNode[] | undefined;
751
+ /** Diff key: from id, #, or v-lark path */
752
+ compareKey?: string | undefined;
753
+ /** Keyed children count map (compareKey -> count) */
754
+ reused?: Record<string, number> | undefined;
755
+ /** Total count of keyed children */
756
+ reusedTotal?: number;
757
+ /** Sub-view references: [viewPath, owner, uri, params] tuples */
758
+ views?: [string, string, string, Record<string, string>][] | undefined;
759
+ /** Whether self-closing (children param was literal 1) */
760
+ selfClose?: boolean;
761
+ /** Sub-view path if this node hosts a v-lark view, otherwise falsy */
762
+ isLarkView?: string | undefined;
763
+ }
764
+ /**
765
+ * VDOM diff operation tracker. Parallel to DomRef but for the VDOM pipeline.
766
+ */
767
+ interface VDomRef {
768
+ /** View ID (for placeholder replacement) */
769
+ viewId: string;
770
+ /** Sub-views that need re-rendering after diff */
771
+ viewRenders: ViewInterface[];
772
+ /** Deferred DOM property assignments: [element, propName, value][] */
773
+ nodeProps: [Element, string, unknown][];
774
+ /** Pending async operation count */
775
+ asyncCount: number;
776
+ /** Whether the DOM actually changed */
777
+ changed: number;
778
+ /** DOM mutation operations (same format as DomOp) */
779
+ domOps: DomOp[];
780
+ }
781
+ /** VDOM node creation function signature (vdomCreate) */
782
+ type VDomCreateFn = (tag: string | number, props?: Record<string, unknown> | number | null, children?: VDomNode[] | number | null, specials?: Record<string, string>) => VDomNode;
783
+ /**
784
+ * VDOM template function signature.
785
+ * The compiled template imports vdomCreate via ES module import and
786
+ * takes only (data, viewId, refData). Extra arguments are ignored.
787
+ */
788
+ type VDomTemplate = (data: unknown, viewId: string, refData: unknown) => VDomNode;
668
789
  interface FrameInvokeEntry {
669
790
  /** Method name */
670
791
  name: string;
@@ -858,7 +979,7 @@ interface ViewInterface extends EventEmitterInterface<ViewInterface> {
858
979
  * View template function. Receives data + viewId + refData and a set of
859
980
  * encoder helpers wired in by the Updater, and returns the rendered HTML.
860
981
  */
861
- template?: ViewTemplate;
982
+ template?: ViewTemplate | VDomTemplate;
862
983
  /**
863
984
  * Mixin object array for extending view functionality.
864
985
  * Framework merges properties and methods from mixins into view prototype.
@@ -879,6 +1000,8 @@ interface ViewInterface extends EventEmitterInterface<ViewInterface> {
879
1000
  globalEventList: ViewGlobalEventEntry[];
880
1001
  /** Whether endUpdate has been called (1 = pending) */
881
1002
  endUpdatePending?: number;
1003
+ /** Last rendered VDOM tree (only used when virtualDom is enabled) */
1004
+ vdom?: VDomNode;
882
1005
  /** Render method (wrapped) */
883
1006
  render(): void;
884
1007
  /**
@@ -1602,7 +1725,7 @@ interface FrameworkConfig {
1602
1725
  */
1603
1726
  crossConfigs?: CrossSiteConfig[];
1604
1727
  /** Default false. */
1605
- virtualDOM?: boolean;
1728
+ virtualDom?: boolean;
1606
1729
  /** Dynamic config access, custom config items */
1607
1730
  [key: string]: unknown;
1608
1731
  }
@@ -1659,6 +1782,10 @@ interface CompileOptions {
1659
1782
  globalVars?: string[];
1660
1783
  /** File path for debug error messages (default: undefined) */
1661
1784
  file?: string;
1785
+ /** Generate VDOM output instead of HTML string (default: false) */
1786
+ virtualDom?: boolean;
1787
+ /** Use SWC instead of Babel for parsing (default: false) */
1788
+ useSwc?: boolean;
1662
1789
  }
1663
1790
 
1664
1791
  /**
@@ -1828,6 +1955,8 @@ declare class Updater implements UpdaterInterface {
1828
1955
  private version;
1829
1956
  /** Snapshot of `version` taken by `snapshot()`, used by `altered()`. */
1830
1957
  private snapshotVersion;
1958
+ /** Last rendered VDOM tree (only used when virtualDom is enabled) */
1959
+ private vdom?;
1831
1960
  constructor(viewId: string);
1832
1961
  /**
1833
1962
  * Get data by key.
@@ -1890,6 +2019,21 @@ declare class Updater implements UpdaterInterface {
1890
2019
  getChangedKeys(): ReadonlySet<string>;
1891
2020
  }
1892
2021
 
2022
+ /**
2023
+ * Create a virtual DOM node.
2024
+ *
2025
+ * Text node: `vdomCreate(0, 'text content')`
2026
+ * Element: `vdomCreate('div', { class: 'row' }, [child1, child2])`
2027
+ * Self-closing: `vdomCreate('br', null, 1)`
2028
+ * Raw HTML: `vdomCreate(0, '<b>bold</b>', 1)` (children truthy → raw HTML node)
2029
+ * Root: `vdomCreate(viewId, 0, [children])`
2030
+ */
2031
+ declare function vdomCreate(tag: string | number, props?: Record<string, unknown> | string | number | null, children?: VDomNode[] | string | number | null, specials?: Record<string, string>): VDomNode;
2032
+ /**
2033
+ * Create an empty VDomRef for tracking diff operations.
2034
+ */
2035
+ declare function createVDomRef(viewId: string): VDomRef;
2036
+
1893
2037
  /**
1894
2038
  * Payload wraps API response data with convenient access methods.
1895
2039
  */
@@ -2186,86 +2330,4 @@ declare function create<T>(name: string, creator: StateCreator<T>): StoreApi<T>;
2186
2330
  */
2187
2331
  declare function bindStore<T>(view: unknown, store: StoreApi<T>, selector?: (state: T) => Record<string, unknown>): () => void;
2188
2332
 
2189
- /** Serialized view info attached to a frame node */
2190
- interface SerializedViewInfo {
2191
- /** View ID (same as frame ID) */
2192
- id: string;
2193
- /** Whether the view has rendered at least once */
2194
- rendered: boolean;
2195
- /** View signature (> 0 = active) */
2196
- signature: number;
2197
- /** Observed state keys */
2198
- observedStateKeys: string[] | null;
2199
- /** Location observation config */
2200
- locationObserved: {
2201
- flag: number;
2202
- keys: string[];
2203
- observePath: boolean;
2204
- };
2205
- /** Whether view has a template function */
2206
- hasTemplate: boolean;
2207
- /** Delegated event types (keys from $evtObjMap) */
2208
- eventMethodKeys: string[];
2209
- /** Captured resource keys */
2210
- resourceKeys: string[];
2211
- /** Whether view exposes an assign method (supports CrossSite reuse) */
2212
- hasAssign: boolean;
2213
- /** Updater refData snapshot (shallow copy of current data) */
2214
- updaterData: Record<string, unknown> | null;
2215
- }
2216
- /** A single node in the serialized frame tree */
2217
- interface SerializedFrameNode {
2218
- /** Frame ID (same as owner DOM element ID) */
2219
- id: string;
2220
- /** Parent frame ID (null for root) */
2221
- parentId: string | null;
2222
- /** View path (v-lark attribute value) */
2223
- viewPath: string | null;
2224
- /** Number of child frames */
2225
- childrenCount: number;
2226
- /** Number of children that have fired 'created' */
2227
- readyCount: number;
2228
- /** Whether children have been created */
2229
- childrenCreated: number;
2230
- /** Whether children are in alter state */
2231
- childrenAlter: number;
2232
- /** Whether this frame is destroyed */
2233
- destroyed: number;
2234
- /** Serialized view info (null if no view mounted) */
2235
- view: SerializedViewInfo | null;
2236
- /** Child frame nodes */
2237
- children: SerializedFrameNode[];
2238
- }
2239
- /** Top-level serialized frame tree */
2240
- interface SerializedFrameTree {
2241
- /** Root frame node */
2242
- root: SerializedFrameNode | null;
2243
- /** Total frame count */
2244
- totalFrames: number;
2245
- /** Timestamp of serialization */
2246
- timestamp: number;
2247
- /** Root element ID */
2248
- rootId: string;
2249
- }
2250
- declare const FrameVisualBridge: {
2251
- MSG_PING: string;
2252
- MSG_PONG: string;
2253
- MSG_REQUEST_TREE: string;
2254
- MSG_TREE: string;
2255
- MSG_TREE_DELTA: string;
2256
- };
2257
- /**
2258
- * Serialize the entire Frame tree starting from root.
2259
- * Returns an empty snapshot if the app hasn't booted yet.
2260
- */
2261
- declare function serializeFrameTree(): SerializedFrameTree;
2262
- /**
2263
- * Install the Frame Visualizer Bridge.
2264
- * Listens for postMessage events from the visualizer and responds
2265
- * with serialized frame tree data.
2266
- *
2267
- * This should be called once during Framework.boot().
2268
- */
2269
- declare function installFrameVisualizerBridge(): void;
2270
-
2271
- export { type AnyFunc, CALL_BREAK_TIME, Cache, type CacheEntry, type CacheInterface, type CacheOptions, type ChangeEvent, type CompileOptions, CrossSite, type CrossSiteConfig, type DomElement, type DomOp, type DomRef, EVENT_METHOD_REGEXP, EventDelegator, EventEmitter, type EventEmitterInterface, type EventListenerEntry, Frame, type FrameBoundElement, type FrameInterface, type FrameInvokeEntry, type FrameStaticEvent, FrameVisualBridge, Framework, type FrameworkConfig, type FrameworkInterface, LARK_VIEW, type Location, type LocationDiff, type MixinEventHandler, type ParamDiff, type ParsedUri, Payload, type PayloadInterface, type PendingCacheEntry, RouterEvents as ROUTER_EVENTS, type RouteChangeEvent, type RouteChangedEvent, type RouteViewConfig, Router, type RouterInterface, SPLITTER, type SerializedFrameNode, type SerializedFrameTree, type SerializedViewInfo, Service, type ServiceCacheInfo, type ServiceEvent, type ServiceMetaEntry, type ServiceOptions, State, type StateInterface, type StoreApi, TAG_NAME_REGEXP, Updater, type UpdaterInterface, VIEW_EVENT_METHOD_REGEXP, View, type ViewEvent, type ViewEventSelectorEntry, type ViewGlobalEventEntry, type ViewInterface, type ViewLocationObserved, type ViewObserveLocation, type ViewResourceEntry, type ViewTemplate, type VoidFunc, applyStyle, bindStore, computed, create, defineView, config as frameworkConfig, getRouteMode, installFrameVisualizerBridge, invalidateViewClass, mark, markBooted, markRouterBooted, nextCounter, registerViewClass, resetProjectsMap, safeguard, serializeFrameTree, unmark, use, useUrlState };
2333
+ export { type AnyFunc, CALL_BREAK_TIME, Cache, type CacheEntry, type CacheInterface, type CacheOptions, type ChangeEvent, type CompileOptions, CrossSite, type CrossSiteConfig, type DomElement, type DomOp, type DomRef, EVENT_METHOD_REGEXP, EventDelegator, EventEmitter, type EventEmitterInterface, type EventListenerEntry, Frame, type FrameBoundElement, type FrameInterface, type FrameInvokeEntry, type FrameStaticEvent, Framework, type FrameworkConfig, type FrameworkInterface, type HotContext, LARK_VIEW, type Location, type LocationDiff, type MixinEventHandler, type ParamDiff, type ParsedUri, Payload, type PayloadInterface, type PendingCacheEntry, RouterEvents as ROUTER_EVENTS, type RouteChangeEvent, type RouteChangedEvent, type RouteViewConfig, Router, type RouterInterface, SPLITTER, Service, type ServiceCacheInfo, type ServiceEvent, type ServiceMetaEntry, type ServiceOptions, State, type StateInterface, type StoreApi, TAG_NAME_REGEXP, Updater, type UpdaterInterface, type VDomCreateFn, type VDomNode, type VDomRef, type VDomTemplate, VIEW_EVENT_METHOD_REGEXP, View, type ViewEvent, type ViewEventSelectorEntry, type ViewGlobalEventEntry, type ViewInterface, type ViewLocationObserved, type ViewObserveLocation, type ViewResourceEntry, type ViewTemplate, type VoidFunc, applyStyle, bindStore, computed, create, createVDomRef, defineView, config as frameworkConfig, getRouteMode, invalidateViewClass, mark, markBooted, markRouterBooted, nextCounter, registerViewClass, reloadViews, resetProjectsMap, safeguard, unmark, use, useUrlState, vdomCreate };