@lark.js/mvc 0.0.6 → 0.0.8
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 +145 -118
- 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 +32 -774
- package/dist/index.d.cts +4 -69
- package/dist/index.d.ts +4 -69
- package/dist/index.js +32 -772
- package/package.json +13 -3
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[];
|
|
@@ -2513,69 +2513,4 @@ declare function serializeFrameTree(): SerializedFrameTree;
|
|
|
2513
2513
|
*/
|
|
2514
2514
|
declare function installFrameVisualizerBridge(): void;
|
|
2515
2515
|
|
|
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 };
|
|
2516
|
+
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, computed, create, createVdomRef, defineStore, defineView, 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, vdomGetCompareKey, vdomGetNode, vdomSetAttributes, vdomSetChildNodes, vdomSetNode, vdomSpecialDiff, vdomUnmountFrames };
|
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[];
|
|
@@ -2513,69 +2513,4 @@ declare function serializeFrameTree(): SerializedFrameTree;
|
|
|
2513
2513
|
*/
|
|
2514
2514
|
declare function installFrameVisualizerBridge(): void;
|
|
2515
2515
|
|
|
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 };
|
|
2516
|
+
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, computed, create, createVdomRef, defineStore, defineView, 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, vdomGetCompareKey, vdomGetNode, vdomSetAttributes, vdomSetChildNodes, vdomSetNode, vdomSpecialDiff, vdomUnmountFrames };
|