@lark.js/mvc 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +147 -120
- package/dist/compiler.cjs +15366 -0
- package/dist/compiler.d.cts +76 -0
- package/dist/compiler.d.ts +76 -0
- package/dist/compiler.js +15353 -0
- package/dist/index.cjs +80 -842
- package/dist/index.d.cts +34 -97
- package/dist/index.d.ts +34 -97
- package/dist/index.js +70 -830
- package/package.json +15 -5
- package/src/client.d.ts +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -137,13 +137,13 @@ declare class View implements ViewInterface {
|
|
|
137
137
|
* Set up a leave confirmation for route changes and page unload.
|
|
138
138
|
*/
|
|
139
139
|
leaveTip(message: string, condition: () => boolean): void;
|
|
140
|
-
/** Collected
|
|
141
|
-
static
|
|
140
|
+
/** Collected makes from mixins */
|
|
141
|
+
static makes?: AnyFunc[];
|
|
142
142
|
/**
|
|
143
143
|
* Prepare a View subclass by scanning its prototype for event method patterns.
|
|
144
144
|
* Pattern: `$?name<eventType1,eventType2>(&modifiers)`
|
|
145
145
|
*
|
|
146
|
-
* Only runs once per View subclass (guarded by
|
|
146
|
+
* Only runs once per View subclass (guarded by makes marker).
|
|
147
147
|
* Called from Frame.mountView before creating the view instance.
|
|
148
148
|
*/
|
|
149
149
|
static prepare(oView: typeof View): AnyFunc[];
|
|
@@ -461,7 +461,7 @@ declare class Cache<T = unknown> implements CacheInterface<T> {
|
|
|
461
461
|
* (recommended for complex cases)
|
|
462
462
|
* - Service: API request management with caching, queuing, and deduplication
|
|
463
463
|
* - Frame: view frame managing view mount/unmount lifecycle
|
|
464
|
-
* - Updater: view data binding and
|
|
464
|
+
* - Updater: view data binding and DOM diff (in-memory real DOM diff) renderer
|
|
465
465
|
*
|
|
466
466
|
* Designed for single-page application (SPA) development.
|
|
467
467
|
*/
|
|
@@ -643,23 +643,23 @@ interface RouteChangeEvent extends ChangeEvent {
|
|
|
643
643
|
* Carries route diff information. Triggered after route change is confirmed and URL is updated.
|
|
644
644
|
*/
|
|
645
645
|
type RouteChangedEvent = LocationDiff & ChangeEvent;
|
|
646
|
-
interface
|
|
646
|
+
interface DomRef {
|
|
647
647
|
/** ID update list: [element, newId][] */
|
|
648
648
|
idUpdates: [Element, string][];
|
|
649
649
|
/** Views that need post-processing */
|
|
650
650
|
views: ViewInterface[];
|
|
651
651
|
/** DOM operation list: [opCode, parent, newChild?, oldChild?][] */
|
|
652
|
-
domOps:
|
|
652
|
+
domOps: DomOp[];
|
|
653
653
|
/** Whether anything changed */
|
|
654
654
|
hasChanged: number;
|
|
655
655
|
}
|
|
656
656
|
/**
|
|
657
|
-
* Encoded
|
|
657
|
+
* Encoded DOM mutation. The op code matches `Node.appendChild` family at the
|
|
658
658
|
* DOM level — parents are always Elements (you can't appendChild onto text)
|
|
659
659
|
* but the moving / replaced child can be any ChildNode (Element / Text /
|
|
660
660
|
* Comment), so the child slots are typed as ChildNode.
|
|
661
661
|
*/
|
|
662
|
-
type
|
|
662
|
+
type DomOp = [1, Element, ChildNode] | [2, Element, ChildNode] | [4, Element, ChildNode, ChildNode] | [8, Element, ChildNode, ChildNode];
|
|
663
663
|
interface FrameInvokeEntry {
|
|
664
664
|
/** Method name */
|
|
665
665
|
name: string;
|
|
@@ -841,7 +841,7 @@ interface ViewInterface extends EventEmitterInterface<ViewInterface> {
|
|
|
841
841
|
*/
|
|
842
842
|
owner: FrameInterface | number;
|
|
843
843
|
/**
|
|
844
|
-
* Updater instance managing view data binding and
|
|
844
|
+
* Updater instance managing view data binding and DOM rendering.
|
|
845
845
|
*/
|
|
846
846
|
updater: UpdaterInterface;
|
|
847
847
|
/**
|
|
@@ -892,7 +892,7 @@ interface ViewInterface extends EventEmitterInterface<ViewInterface> {
|
|
|
892
892
|
endUpdatePendingFlag?: number;
|
|
893
893
|
/**
|
|
894
894
|
* Notify view that HTML update is about to begin for a specific region.
|
|
895
|
-
* Framework unmounts child Frames in that region to prevent
|
|
895
|
+
* Framework unmounts child Frames in that region to prevent DOM diff from operating on unmounted nodes.
|
|
896
896
|
* @param id Region node ID to update, defaults to current view
|
|
897
897
|
*/
|
|
898
898
|
beginUpdate: (id?: string) => void;
|
|
@@ -952,7 +952,7 @@ interface ViewInterface extends EventEmitterInterface<ViewInterface> {
|
|
|
952
952
|
leaveTip: (message: string, condition: () => boolean) => void;
|
|
953
953
|
/**
|
|
954
954
|
* Assign method for incremental DOM updates.
|
|
955
|
-
* Framework uses
|
|
955
|
+
* Framework uses DOM diff (in-memory real DOM diff) to update only changed portions,
|
|
956
956
|
* automatically handling child view mounting and unmounting.
|
|
957
957
|
* Returns true if DOM changed, undefined if no change.
|
|
958
958
|
* @param options Incremental update config, used internally by framework
|
|
@@ -1083,7 +1083,7 @@ interface FrameInterface extends EventEmitterInterface<FrameInterface> {
|
|
|
1083
1083
|
* Minimal Updater interface needed by View.
|
|
1084
1084
|
* View updater responsible for view data binding and data/page updates.
|
|
1085
1085
|
* Each View instance has an Updater, triggering data/page updates via set/digest.
|
|
1086
|
-
* Internally executes complete pipeline: template rendering →
|
|
1086
|
+
* Internally executes complete pipeline: template rendering → DOM diff (in-memory real DOM diff) → DOM operations.
|
|
1087
1087
|
*/
|
|
1088
1088
|
interface UpdaterInterface {
|
|
1089
1089
|
/**
|
|
@@ -1103,7 +1103,7 @@ interface UpdaterInterface {
|
|
|
1103
1103
|
/**
|
|
1104
1104
|
* Trigger page re-render.
|
|
1105
1105
|
* After set, must explicitly call `digest()` to commit changes to page.
|
|
1106
|
-
* Internally executes complete pipeline: template rendering →
|
|
1106
|
+
* Internally executes complete pipeline: template rendering → DOM diff (in-memory real DOM diff) → DOM operations.
|
|
1107
1107
|
* @param data Optional data object, if provided calls `set()` first to set data
|
|
1108
1108
|
* @param excludes Set of keys to exclude from change tracking
|
|
1109
1109
|
* @param callback Callback executed after render completes
|
|
@@ -1714,6 +1714,8 @@ interface FrameworkConfig {
|
|
|
1714
1714
|
* Also accessible via `window.crossConfigs` for build-time injection.
|
|
1715
1715
|
*/
|
|
1716
1716
|
crossConfigs?: CrossSiteConfig[];
|
|
1717
|
+
/** Default false. */
|
|
1718
|
+
virtualDOM?: boolean;
|
|
1717
1719
|
/** Dynamic config access, custom config items */
|
|
1718
1720
|
[key: string]: unknown;
|
|
1719
1721
|
}
|
|
@@ -1740,8 +1742,8 @@ interface CrossSiteConfig {
|
|
|
1740
1742
|
/** Optional business code for multi-tenant scenarios */
|
|
1741
1743
|
bizCode?: string;
|
|
1742
1744
|
}
|
|
1743
|
-
/** Element with
|
|
1744
|
-
interface
|
|
1745
|
+
/** Element with DOM diff cached compare key */
|
|
1746
|
+
interface DomElement extends Element {
|
|
1745
1747
|
/** Whether compare key is cached */
|
|
1746
1748
|
compareKeyCached?: number | undefined;
|
|
1747
1749
|
/** Cached compare key */
|
|
@@ -1993,45 +1995,45 @@ declare const CrossSite: typeof View;
|
|
|
1993
1995
|
/**
|
|
1994
1996
|
* Unmount frames within a DOM node.
|
|
1995
1997
|
*/
|
|
1996
|
-
declare function
|
|
1998
|
+
declare function domUnmountFrames(frame: FrameInterface, node: ChildNode): void;
|
|
1997
1999
|
/**
|
|
1998
2000
|
* Parse HTML string into a DOM element.
|
|
1999
2001
|
* Handles special elements (table, SVG, MathML) with wrapper elements.
|
|
2000
2002
|
*/
|
|
2001
|
-
declare function
|
|
2003
|
+
declare function domGetNode(html: string, refNode: Element): Element;
|
|
2002
2004
|
/**
|
|
2003
2005
|
* Get compare key for a DOM node (for keyed diff).
|
|
2004
|
-
* Uses id
|
|
2006
|
+
* Uses id or v-lark path.
|
|
2005
2007
|
*/
|
|
2006
|
-
declare function
|
|
2008
|
+
declare function domGetCompareKey(node: ChildNode): string | undefined;
|
|
2007
2009
|
/**
|
|
2008
2010
|
* Special diff for form elements (value, checked, selected).
|
|
2009
2011
|
* Form elements carry state on the DOM node (e.g. `input.value`) that isn't
|
|
2010
2012
|
* reflected in attributes, so we have to sync those properties separately.
|
|
2011
2013
|
*/
|
|
2012
|
-
declare function
|
|
2014
|
+
declare function domSpecialDiff(oldNode: ChildNode, newNode: ChildNode): number;
|
|
2013
2015
|
/**
|
|
2014
2016
|
* Set attributes from new element onto old element, tracking changes in ref.
|
|
2015
2017
|
*/
|
|
2016
|
-
declare function
|
|
2018
|
+
declare function domSetAttributes(oldNode: Element, newNode: Element, ref: DomRef, keepId?: boolean): void;
|
|
2017
2019
|
/**
|
|
2018
2020
|
* Set child nodes from new parent onto old parent using keyed diff algorithm.
|
|
2019
2021
|
*/
|
|
2020
|
-
declare function
|
|
2022
|
+
declare function domSetChildNodes(oldParent: Element, newParent: Element, ref: DomRef, frame: FrameInterface, keys_?: ReadonlySet<string>): void;
|
|
2021
2023
|
/**
|
|
2022
2024
|
* Diff two DOM nodes and apply changes.
|
|
2023
2025
|
*/
|
|
2024
|
-
declare function
|
|
2026
|
+
declare function domSetNode(oldNode: ChildNode, newNode: ChildNode, oldParent: Element, ref: DomRef, frame: FrameInterface, keys_?: ReadonlySet<string>): void;
|
|
2025
2027
|
/**
|
|
2026
|
-
* Create an empty
|
|
2028
|
+
* Create an empty DomRef for tracking diff operations.
|
|
2027
2029
|
*/
|
|
2028
|
-
declare function
|
|
2030
|
+
declare function createDomRef(): DomRef;
|
|
2029
2031
|
/**
|
|
2030
|
-
* Apply
|
|
2032
|
+
* Apply DOM diff operations to the DOM.
|
|
2031
2033
|
*/
|
|
2032
|
-
declare function
|
|
2034
|
+
declare function applyDomOps(ops: DomOp[]): void;
|
|
2033
2035
|
/**
|
|
2034
|
-
* Apply ID updates from
|
|
2036
|
+
* Apply ID updates from DOM diff.
|
|
2035
2037
|
*/
|
|
2036
2038
|
declare function applyIdUpdates(updates: [Element, string][]): void;
|
|
2037
2039
|
/** Encode value for safe HTML output */
|
|
@@ -2045,7 +2047,7 @@ declare function encodeQ(v: unknown): string;
|
|
|
2045
2047
|
|
|
2046
2048
|
/**
|
|
2047
2049
|
* Updater class for view data binding.
|
|
2048
|
-
* Manages view-local data with change detection and
|
|
2050
|
+
* Manages view-local data with change detection and DOM diff triggering.
|
|
2049
2051
|
*
|
|
2050
2052
|
*/
|
|
2051
2053
|
declare class Updater implements UpdaterInterface {
|
|
@@ -2081,11 +2083,11 @@ declare class Updater implements UpdaterInterface {
|
|
|
2081
2083
|
*/
|
|
2082
2084
|
set(data: Record<string, unknown>, excludes?: ReadonlySet<string>): this;
|
|
2083
2085
|
/**
|
|
2084
|
-
* Detect changes and trigger
|
|
2086
|
+
* Detect changes and trigger DOM re-render.
|
|
2085
2087
|
*
|
|
2086
2088
|
* The core rendering pipeline:
|
|
2087
2089
|
* 1. Set data if provided
|
|
2088
|
-
* 2. If changed, run
|
|
2090
|
+
* 2. If changed, run DOM diff (template → new DOM → diff against old DOM)
|
|
2089
2091
|
* 3. Apply DOM operations
|
|
2090
2092
|
* 4. Apply ID updates
|
|
2091
2093
|
* 5. Call endUpdate on views that need re-rendering
|
|
@@ -2513,69 +2515,4 @@ declare function serializeFrameTree(): SerializedFrameTree;
|
|
|
2513
2515
|
*/
|
|
2514
2516
|
declare function installFrameVisualizerBridge(): void;
|
|
2515
2517
|
|
|
2516
|
-
|
|
2517
|
-
* @lark.js/mvc Template Compiler
|
|
2518
|
-
*
|
|
2519
|
-
* convertArtSyntax() ({{}} → <% %>)
|
|
2520
|
-
* processViewEvents() (@event prefix + param encoding)
|
|
2521
|
-
* compileToFunction() (<% %> → JS template function)
|
|
2522
|
-
* extractGlobalVars() (AST-based global var analysis via @babel/parser)
|
|
2523
|
-
*
|
|
2524
|
-
* - All template operators: = (escape), ! (raw), @ (ref lookup), : (binding)
|
|
2525
|
-
* - @event attribute processing with $splitter prefix + \x1e separator
|
|
2526
|
-
* - $strSafe (null-safe toString), $encHtml (HTML entity encode), $encUri (URI encode), $encQuote (quote encode), $refFn (ref lookup)
|
|
2527
|
-
* - Debug mode with line tracking ($dbgExpr/$dbgArt/$dbgLine) and try-catch error wrapper
|
|
2528
|
-
* - View ID injection (\x1f → '+$viewId+')
|
|
2529
|
-
* - Post-processing cleanup of empty concatenations
|
|
2530
|
-
* - 0 configuration: auto-extract variables via AST analysis
|
|
2531
|
-
*
|
|
2532
|
-
* Template syntax:
|
|
2533
|
-
* {{=variable}} → escaped output
|
|
2534
|
-
* {{:variable}} → two-way binding (same as = for rendering)
|
|
2535
|
-
* {{!variable}} → raw output (no HTML escaping)
|
|
2536
|
-
* {{@variable}} → reference lookup for component data passing
|
|
2537
|
-
* {{forOf list as item}} → loop
|
|
2538
|
-
* {{forOf list as item idx}} → loop with index
|
|
2539
|
-
* {{forIn obj as val key}} → object iteration
|
|
2540
|
-
* {{for(let i=0;i<n;i++)}} → generic for loop
|
|
2541
|
-
* {{if condition}} → conditional
|
|
2542
|
-
* {{else if condition}} → else-if
|
|
2543
|
-
* {{else}} → else
|
|
2544
|
-
* {{/if}} / {{/forOf}} / {{/forIn}} / {{/for}} → close blocks
|
|
2545
|
-
* {{set a = b}} → variable declaration
|
|
2546
|
-
*/
|
|
2547
|
-
|
|
2548
|
-
/**
|
|
2549
|
-
* Compile an HTML template string into a JS module string.
|
|
2550
|
-
* This is the main entry point for both Vite and Webpack loaders.
|
|
2551
|
-
*
|
|
2552
|
-
* The output is an ES module that exports a function with the signature:
|
|
2553
|
-
* (data, viewId, refData) => string
|
|
2554
|
-
*
|
|
2555
|
-
* Internally it calls the compiled template function with the standard
|
|
2556
|
-
* signature: ($data,$viewId,$refAlt,$encHtml,$strSafe,$encUri,$refFn,$encQuote)
|
|
2557
|
-
*
|
|
2558
|
-
* @param source - The raw HTML template content
|
|
2559
|
-
* @param options - Compilation options
|
|
2560
|
-
* @returns ES module source code exporting the compiled template function
|
|
2561
|
-
*/
|
|
2562
|
-
declare function compileTemplate(source: string, options?: CompileOptions): string;
|
|
2563
|
-
/**
|
|
2564
|
-
* Extract global variable names from a template source using AST analysis.
|
|
2565
|
-
*
|
|
2566
|
-
* 1. Convert template commands (<% %> blocks) into a form parseable by an AST parser
|
|
2567
|
-
* 2. Walk the AST to find all Identifier nodes
|
|
2568
|
-
* 3. Track variable declarations (VariableDeclarator, FunctionDeclaration) as local vars
|
|
2569
|
-
* 4. Track function parameters as local vars
|
|
2570
|
-
* 5. Remaining identifiers that are not local and not in the exclusion list are "global" —
|
|
2571
|
-
* they must be passed in as part of the data context ($$)
|
|
2572
|
-
*
|
|
2573
|
-
* This replaces the old regex-based `extractVariables()` with proper scope analysis,
|
|
2574
|
-
* eliminating false positives from local template variables and function parameters.
|
|
2575
|
-
*
|
|
2576
|
-
* @param source - The raw HTML template content (with {{ }} syntax)
|
|
2577
|
-
* @returns Array of global variable names found in the template
|
|
2578
|
-
*/
|
|
2579
|
-
declare function extractGlobalVars(source: string): string[];
|
|
2580
|
-
|
|
2581
|
-
export { type AnyFunc, CALL_BREAK_TIME, Cache, type CacheEntry, type CacheInterface, type CacheOptions, type ChangeEvent, type CompileOptions, CrossSite, type CrossSiteConfig, 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 PayloadEntry, 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 ServiceEntry, type ServiceEvent, type ServiceInterface, type ServiceMetaEntry, type ServiceOptions, State, type StateInterface, type StoreApi, TAG_NAME_REGEXP, Updater, type UpdaterInterface, type VDomOp, type VDomRef, VIEW_EVENT_METHOD_REGEXP, type VdomElement, View, type ViewEvent, type ViewEventSelectorEntry, type ViewGlobalEventEntry, type ViewInterface, type ViewLocationObserved, type ViewObserveLocation, type ViewResourceEntry, type ViewTemplate, type VoidFunc, applyIdUpdates, applyStyle, applyVdomOps, assign, bindStore, compileTemplate, computed, create, createVdomRef, defineStore, defineView, encodeHTML, encodeQ, encodeSafe, encodeURIExtra, ensureElementId, extractGlobalVars, config as frameworkConfig, funcWithTry, generateId, getAttribute, getById, getRouteMode, hasOwnProperty, installFrameVisualizerBridge, invalidateViewClass, isPlainObject, isPrimitive, isPrimitiveOrFunc, keys, mark, markBooted, markRouterBooted, nextCounter, nodeInside, noop, now, parseUri, registerViewClass, resetProjectsMap, safeguard, serializeFrameTree, setData, syncCounter, toMap, toUri, translateData, unmark, use, useUrlState, vdomGetCompareKey, vdomGetNode, vdomSetAttributes, vdomSetChildNodes, vdomSetNode, vdomSpecialDiff, vdomUnmountFrames };
|
|
2518
|
+
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 PayloadEntry, 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 ServiceEntry, type ServiceEvent, type ServiceInterface, 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, applyDomOps, applyIdUpdates, applyStyle, assign, bindStore, computed, create, createDomRef, defineStore, defineView, domGetCompareKey, domGetNode, domSetAttributes, domSetChildNodes, domSetNode, domSpecialDiff, domUnmountFrames, encodeHTML, encodeQ, encodeSafe, encodeURIExtra, ensureElementId, config as frameworkConfig, funcWithTry, generateId, getAttribute, getById, getRouteMode, hasOwnProperty, installFrameVisualizerBridge, invalidateViewClass, isPlainObject, isPrimitive, isPrimitiveOrFunc, keys, mark, markBooted, markRouterBooted, nextCounter, nodeInside, noop, now, parseUri, registerViewClass, resetProjectsMap, safeguard, serializeFrameTree, setData, syncCounter, toMap, toUri, translateData, unmark, use, useUrlState };
|
package/dist/index.d.ts
CHANGED
|
@@ -137,13 +137,13 @@ declare class View implements ViewInterface {
|
|
|
137
137
|
* Set up a leave confirmation for route changes and page unload.
|
|
138
138
|
*/
|
|
139
139
|
leaveTip(message: string, condition: () => boolean): void;
|
|
140
|
-
/** Collected
|
|
141
|
-
static
|
|
140
|
+
/** Collected makes from mixins */
|
|
141
|
+
static makes?: AnyFunc[];
|
|
142
142
|
/**
|
|
143
143
|
* Prepare a View subclass by scanning its prototype for event method patterns.
|
|
144
144
|
* Pattern: `$?name<eventType1,eventType2>(&modifiers)`
|
|
145
145
|
*
|
|
146
|
-
* Only runs once per View subclass (guarded by
|
|
146
|
+
* Only runs once per View subclass (guarded by makes marker).
|
|
147
147
|
* Called from Frame.mountView before creating the view instance.
|
|
148
148
|
*/
|
|
149
149
|
static prepare(oView: typeof View): AnyFunc[];
|
|
@@ -461,7 +461,7 @@ declare class Cache<T = unknown> implements CacheInterface<T> {
|
|
|
461
461
|
* (recommended for complex cases)
|
|
462
462
|
* - Service: API request management with caching, queuing, and deduplication
|
|
463
463
|
* - Frame: view frame managing view mount/unmount lifecycle
|
|
464
|
-
* - Updater: view data binding and
|
|
464
|
+
* - Updater: view data binding and DOM diff (in-memory real DOM diff) renderer
|
|
465
465
|
*
|
|
466
466
|
* Designed for single-page application (SPA) development.
|
|
467
467
|
*/
|
|
@@ -643,23 +643,23 @@ interface RouteChangeEvent extends ChangeEvent {
|
|
|
643
643
|
* Carries route diff information. Triggered after route change is confirmed and URL is updated.
|
|
644
644
|
*/
|
|
645
645
|
type RouteChangedEvent = LocationDiff & ChangeEvent;
|
|
646
|
-
interface
|
|
646
|
+
interface DomRef {
|
|
647
647
|
/** ID update list: [element, newId][] */
|
|
648
648
|
idUpdates: [Element, string][];
|
|
649
649
|
/** Views that need post-processing */
|
|
650
650
|
views: ViewInterface[];
|
|
651
651
|
/** DOM operation list: [opCode, parent, newChild?, oldChild?][] */
|
|
652
|
-
domOps:
|
|
652
|
+
domOps: DomOp[];
|
|
653
653
|
/** Whether anything changed */
|
|
654
654
|
hasChanged: number;
|
|
655
655
|
}
|
|
656
656
|
/**
|
|
657
|
-
* Encoded
|
|
657
|
+
* Encoded DOM mutation. The op code matches `Node.appendChild` family at the
|
|
658
658
|
* DOM level — parents are always Elements (you can't appendChild onto text)
|
|
659
659
|
* but the moving / replaced child can be any ChildNode (Element / Text /
|
|
660
660
|
* Comment), so the child slots are typed as ChildNode.
|
|
661
661
|
*/
|
|
662
|
-
type
|
|
662
|
+
type DomOp = [1, Element, ChildNode] | [2, Element, ChildNode] | [4, Element, ChildNode, ChildNode] | [8, Element, ChildNode, ChildNode];
|
|
663
663
|
interface FrameInvokeEntry {
|
|
664
664
|
/** Method name */
|
|
665
665
|
name: string;
|
|
@@ -841,7 +841,7 @@ interface ViewInterface extends EventEmitterInterface<ViewInterface> {
|
|
|
841
841
|
*/
|
|
842
842
|
owner: FrameInterface | number;
|
|
843
843
|
/**
|
|
844
|
-
* Updater instance managing view data binding and
|
|
844
|
+
* Updater instance managing view data binding and DOM rendering.
|
|
845
845
|
*/
|
|
846
846
|
updater: UpdaterInterface;
|
|
847
847
|
/**
|
|
@@ -892,7 +892,7 @@ interface ViewInterface extends EventEmitterInterface<ViewInterface> {
|
|
|
892
892
|
endUpdatePendingFlag?: number;
|
|
893
893
|
/**
|
|
894
894
|
* Notify view that HTML update is about to begin for a specific region.
|
|
895
|
-
* Framework unmounts child Frames in that region to prevent
|
|
895
|
+
* Framework unmounts child Frames in that region to prevent DOM diff from operating on unmounted nodes.
|
|
896
896
|
* @param id Region node ID to update, defaults to current view
|
|
897
897
|
*/
|
|
898
898
|
beginUpdate: (id?: string) => void;
|
|
@@ -952,7 +952,7 @@ interface ViewInterface extends EventEmitterInterface<ViewInterface> {
|
|
|
952
952
|
leaveTip: (message: string, condition: () => boolean) => void;
|
|
953
953
|
/**
|
|
954
954
|
* Assign method for incremental DOM updates.
|
|
955
|
-
* Framework uses
|
|
955
|
+
* Framework uses DOM diff (in-memory real DOM diff) to update only changed portions,
|
|
956
956
|
* automatically handling child view mounting and unmounting.
|
|
957
957
|
* Returns true if DOM changed, undefined if no change.
|
|
958
958
|
* @param options Incremental update config, used internally by framework
|
|
@@ -1083,7 +1083,7 @@ interface FrameInterface extends EventEmitterInterface<FrameInterface> {
|
|
|
1083
1083
|
* Minimal Updater interface needed by View.
|
|
1084
1084
|
* View updater responsible for view data binding and data/page updates.
|
|
1085
1085
|
* Each View instance has an Updater, triggering data/page updates via set/digest.
|
|
1086
|
-
* Internally executes complete pipeline: template rendering →
|
|
1086
|
+
* Internally executes complete pipeline: template rendering → DOM diff (in-memory real DOM diff) → DOM operations.
|
|
1087
1087
|
*/
|
|
1088
1088
|
interface UpdaterInterface {
|
|
1089
1089
|
/**
|
|
@@ -1103,7 +1103,7 @@ interface UpdaterInterface {
|
|
|
1103
1103
|
/**
|
|
1104
1104
|
* Trigger page re-render.
|
|
1105
1105
|
* After set, must explicitly call `digest()` to commit changes to page.
|
|
1106
|
-
* Internally executes complete pipeline: template rendering →
|
|
1106
|
+
* Internally executes complete pipeline: template rendering → DOM diff (in-memory real DOM diff) → DOM operations.
|
|
1107
1107
|
* @param data Optional data object, if provided calls `set()` first to set data
|
|
1108
1108
|
* @param excludes Set of keys to exclude from change tracking
|
|
1109
1109
|
* @param callback Callback executed after render completes
|
|
@@ -1714,6 +1714,8 @@ interface FrameworkConfig {
|
|
|
1714
1714
|
* Also accessible via `window.crossConfigs` for build-time injection.
|
|
1715
1715
|
*/
|
|
1716
1716
|
crossConfigs?: CrossSiteConfig[];
|
|
1717
|
+
/** Default false. */
|
|
1718
|
+
virtualDOM?: boolean;
|
|
1717
1719
|
/** Dynamic config access, custom config items */
|
|
1718
1720
|
[key: string]: unknown;
|
|
1719
1721
|
}
|
|
@@ -1740,8 +1742,8 @@ interface CrossSiteConfig {
|
|
|
1740
1742
|
/** Optional business code for multi-tenant scenarios */
|
|
1741
1743
|
bizCode?: string;
|
|
1742
1744
|
}
|
|
1743
|
-
/** Element with
|
|
1744
|
-
interface
|
|
1745
|
+
/** Element with DOM diff cached compare key */
|
|
1746
|
+
interface DomElement extends Element {
|
|
1745
1747
|
/** Whether compare key is cached */
|
|
1746
1748
|
compareKeyCached?: number | undefined;
|
|
1747
1749
|
/** Cached compare key */
|
|
@@ -1993,45 +1995,45 @@ declare const CrossSite: typeof View;
|
|
|
1993
1995
|
/**
|
|
1994
1996
|
* Unmount frames within a DOM node.
|
|
1995
1997
|
*/
|
|
1996
|
-
declare function
|
|
1998
|
+
declare function domUnmountFrames(frame: FrameInterface, node: ChildNode): void;
|
|
1997
1999
|
/**
|
|
1998
2000
|
* Parse HTML string into a DOM element.
|
|
1999
2001
|
* Handles special elements (table, SVG, MathML) with wrapper elements.
|
|
2000
2002
|
*/
|
|
2001
|
-
declare function
|
|
2003
|
+
declare function domGetNode(html: string, refNode: Element): Element;
|
|
2002
2004
|
/**
|
|
2003
2005
|
* Get compare key for a DOM node (for keyed diff).
|
|
2004
|
-
* Uses id
|
|
2006
|
+
* Uses id or v-lark path.
|
|
2005
2007
|
*/
|
|
2006
|
-
declare function
|
|
2008
|
+
declare function domGetCompareKey(node: ChildNode): string | undefined;
|
|
2007
2009
|
/**
|
|
2008
2010
|
* Special diff for form elements (value, checked, selected).
|
|
2009
2011
|
* Form elements carry state on the DOM node (e.g. `input.value`) that isn't
|
|
2010
2012
|
* reflected in attributes, so we have to sync those properties separately.
|
|
2011
2013
|
*/
|
|
2012
|
-
declare function
|
|
2014
|
+
declare function domSpecialDiff(oldNode: ChildNode, newNode: ChildNode): number;
|
|
2013
2015
|
/**
|
|
2014
2016
|
* Set attributes from new element onto old element, tracking changes in ref.
|
|
2015
2017
|
*/
|
|
2016
|
-
declare function
|
|
2018
|
+
declare function domSetAttributes(oldNode: Element, newNode: Element, ref: DomRef, keepId?: boolean): void;
|
|
2017
2019
|
/**
|
|
2018
2020
|
* Set child nodes from new parent onto old parent using keyed diff algorithm.
|
|
2019
2021
|
*/
|
|
2020
|
-
declare function
|
|
2022
|
+
declare function domSetChildNodes(oldParent: Element, newParent: Element, ref: DomRef, frame: FrameInterface, keys_?: ReadonlySet<string>): void;
|
|
2021
2023
|
/**
|
|
2022
2024
|
* Diff two DOM nodes and apply changes.
|
|
2023
2025
|
*/
|
|
2024
|
-
declare function
|
|
2026
|
+
declare function domSetNode(oldNode: ChildNode, newNode: ChildNode, oldParent: Element, ref: DomRef, frame: FrameInterface, keys_?: ReadonlySet<string>): void;
|
|
2025
2027
|
/**
|
|
2026
|
-
* Create an empty
|
|
2028
|
+
* Create an empty DomRef for tracking diff operations.
|
|
2027
2029
|
*/
|
|
2028
|
-
declare function
|
|
2030
|
+
declare function createDomRef(): DomRef;
|
|
2029
2031
|
/**
|
|
2030
|
-
* Apply
|
|
2032
|
+
* Apply DOM diff operations to the DOM.
|
|
2031
2033
|
*/
|
|
2032
|
-
declare function
|
|
2034
|
+
declare function applyDomOps(ops: DomOp[]): void;
|
|
2033
2035
|
/**
|
|
2034
|
-
* Apply ID updates from
|
|
2036
|
+
* Apply ID updates from DOM diff.
|
|
2035
2037
|
*/
|
|
2036
2038
|
declare function applyIdUpdates(updates: [Element, string][]): void;
|
|
2037
2039
|
/** Encode value for safe HTML output */
|
|
@@ -2045,7 +2047,7 @@ declare function encodeQ(v: unknown): string;
|
|
|
2045
2047
|
|
|
2046
2048
|
/**
|
|
2047
2049
|
* Updater class for view data binding.
|
|
2048
|
-
* Manages view-local data with change detection and
|
|
2050
|
+
* Manages view-local data with change detection and DOM diff triggering.
|
|
2049
2051
|
*
|
|
2050
2052
|
*/
|
|
2051
2053
|
declare class Updater implements UpdaterInterface {
|
|
@@ -2081,11 +2083,11 @@ declare class Updater implements UpdaterInterface {
|
|
|
2081
2083
|
*/
|
|
2082
2084
|
set(data: Record<string, unknown>, excludes?: ReadonlySet<string>): this;
|
|
2083
2085
|
/**
|
|
2084
|
-
* Detect changes and trigger
|
|
2086
|
+
* Detect changes and trigger DOM re-render.
|
|
2085
2087
|
*
|
|
2086
2088
|
* The core rendering pipeline:
|
|
2087
2089
|
* 1. Set data if provided
|
|
2088
|
-
* 2. If changed, run
|
|
2090
|
+
* 2. If changed, run DOM diff (template → new DOM → diff against old DOM)
|
|
2089
2091
|
* 3. Apply DOM operations
|
|
2090
2092
|
* 4. Apply ID updates
|
|
2091
2093
|
* 5. Call endUpdate on views that need re-rendering
|
|
@@ -2513,69 +2515,4 @@ declare function serializeFrameTree(): SerializedFrameTree;
|
|
|
2513
2515
|
*/
|
|
2514
2516
|
declare function installFrameVisualizerBridge(): void;
|
|
2515
2517
|
|
|
2516
|
-
|
|
2517
|
-
* @lark.js/mvc Template Compiler
|
|
2518
|
-
*
|
|
2519
|
-
* convertArtSyntax() ({{}} → <% %>)
|
|
2520
|
-
* processViewEvents() (@event prefix + param encoding)
|
|
2521
|
-
* compileToFunction() (<% %> → JS template function)
|
|
2522
|
-
* extractGlobalVars() (AST-based global var analysis via @babel/parser)
|
|
2523
|
-
*
|
|
2524
|
-
* - All template operators: = (escape), ! (raw), @ (ref lookup), : (binding)
|
|
2525
|
-
* - @event attribute processing with $splitter prefix + \x1e separator
|
|
2526
|
-
* - $strSafe (null-safe toString), $encHtml (HTML entity encode), $encUri (URI encode), $encQuote (quote encode), $refFn (ref lookup)
|
|
2527
|
-
* - Debug mode with line tracking ($dbgExpr/$dbgArt/$dbgLine) and try-catch error wrapper
|
|
2528
|
-
* - View ID injection (\x1f → '+$viewId+')
|
|
2529
|
-
* - Post-processing cleanup of empty concatenations
|
|
2530
|
-
* - 0 configuration: auto-extract variables via AST analysis
|
|
2531
|
-
*
|
|
2532
|
-
* Template syntax:
|
|
2533
|
-
* {{=variable}} → escaped output
|
|
2534
|
-
* {{:variable}} → two-way binding (same as = for rendering)
|
|
2535
|
-
* {{!variable}} → raw output (no HTML escaping)
|
|
2536
|
-
* {{@variable}} → reference lookup for component data passing
|
|
2537
|
-
* {{forOf list as item}} → loop
|
|
2538
|
-
* {{forOf list as item idx}} → loop with index
|
|
2539
|
-
* {{forIn obj as val key}} → object iteration
|
|
2540
|
-
* {{for(let i=0;i<n;i++)}} → generic for loop
|
|
2541
|
-
* {{if condition}} → conditional
|
|
2542
|
-
* {{else if condition}} → else-if
|
|
2543
|
-
* {{else}} → else
|
|
2544
|
-
* {{/if}} / {{/forOf}} / {{/forIn}} / {{/for}} → close blocks
|
|
2545
|
-
* {{set a = b}} → variable declaration
|
|
2546
|
-
*/
|
|
2547
|
-
|
|
2548
|
-
/**
|
|
2549
|
-
* Compile an HTML template string into a JS module string.
|
|
2550
|
-
* This is the main entry point for both Vite and Webpack loaders.
|
|
2551
|
-
*
|
|
2552
|
-
* The output is an ES module that exports a function with the signature:
|
|
2553
|
-
* (data, viewId, refData) => string
|
|
2554
|
-
*
|
|
2555
|
-
* Internally it calls the compiled template function with the standard
|
|
2556
|
-
* signature: ($data,$viewId,$refAlt,$encHtml,$strSafe,$encUri,$refFn,$encQuote)
|
|
2557
|
-
*
|
|
2558
|
-
* @param source - The raw HTML template content
|
|
2559
|
-
* @param options - Compilation options
|
|
2560
|
-
* @returns ES module source code exporting the compiled template function
|
|
2561
|
-
*/
|
|
2562
|
-
declare function compileTemplate(source: string, options?: CompileOptions): string;
|
|
2563
|
-
/**
|
|
2564
|
-
* Extract global variable names from a template source using AST analysis.
|
|
2565
|
-
*
|
|
2566
|
-
* 1. Convert template commands (<% %> blocks) into a form parseable by an AST parser
|
|
2567
|
-
* 2. Walk the AST to find all Identifier nodes
|
|
2568
|
-
* 3. Track variable declarations (VariableDeclarator, FunctionDeclaration) as local vars
|
|
2569
|
-
* 4. Track function parameters as local vars
|
|
2570
|
-
* 5. Remaining identifiers that are not local and not in the exclusion list are "global" —
|
|
2571
|
-
* they must be passed in as part of the data context ($$)
|
|
2572
|
-
*
|
|
2573
|
-
* This replaces the old regex-based `extractVariables()` with proper scope analysis,
|
|
2574
|
-
* eliminating false positives from local template variables and function parameters.
|
|
2575
|
-
*
|
|
2576
|
-
* @param source - The raw HTML template content (with {{ }} syntax)
|
|
2577
|
-
* @returns Array of global variable names found in the template
|
|
2578
|
-
*/
|
|
2579
|
-
declare function extractGlobalVars(source: string): string[];
|
|
2580
|
-
|
|
2581
|
-
export { type AnyFunc, CALL_BREAK_TIME, Cache, type CacheEntry, type CacheInterface, type CacheOptions, type ChangeEvent, type CompileOptions, CrossSite, type CrossSiteConfig, 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 PayloadEntry, 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 ServiceEntry, type ServiceEvent, type ServiceInterface, type ServiceMetaEntry, type ServiceOptions, State, type StateInterface, type StoreApi, TAG_NAME_REGEXP, Updater, type UpdaterInterface, type VDomOp, type VDomRef, VIEW_EVENT_METHOD_REGEXP, type VdomElement, View, type ViewEvent, type ViewEventSelectorEntry, type ViewGlobalEventEntry, type ViewInterface, type ViewLocationObserved, type ViewObserveLocation, type ViewResourceEntry, type ViewTemplate, type VoidFunc, applyIdUpdates, applyStyle, applyVdomOps, assign, bindStore, compileTemplate, computed, create, createVdomRef, defineStore, defineView, encodeHTML, encodeQ, encodeSafe, encodeURIExtra, ensureElementId, extractGlobalVars, config as frameworkConfig, funcWithTry, generateId, getAttribute, getById, getRouteMode, hasOwnProperty, installFrameVisualizerBridge, invalidateViewClass, isPlainObject, isPrimitive, isPrimitiveOrFunc, keys, mark, markBooted, markRouterBooted, nextCounter, nodeInside, noop, now, parseUri, registerViewClass, resetProjectsMap, safeguard, serializeFrameTree, setData, syncCounter, toMap, toUri, translateData, unmark, use, useUrlState, vdomGetCompareKey, vdomGetNode, vdomSetAttributes, vdomSetChildNodes, vdomSetNode, vdomSpecialDiff, vdomUnmountFrames };
|
|
2518
|
+
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 PayloadEntry, 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 ServiceEntry, type ServiceEvent, type ServiceInterface, 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, applyDomOps, applyIdUpdates, applyStyle, assign, bindStore, computed, create, createDomRef, defineStore, defineView, domGetCompareKey, domGetNode, domSetAttributes, domSetChildNodes, domSetNode, domSpecialDiff, domUnmountFrames, encodeHTML, encodeQ, encodeSafe, encodeURIExtra, ensureElementId, config as frameworkConfig, funcWithTry, generateId, getAttribute, getById, getRouteMode, hasOwnProperty, installFrameVisualizerBridge, invalidateViewClass, isPlainObject, isPrimitive, isPrimitiveOrFunc, keys, mark, markBooted, markRouterBooted, nextCounter, nodeInside, noop, now, parseUri, registerViewClass, resetProjectsMap, safeguard, serializeFrameTree, setData, syncCounter, toMap, toUri, translateData, unmark, use, useUrlState };
|