@lark.js/mvc 0.0.14 → 0.0.15
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 +4 -4
- package/dist/apply-style.d.ts +9 -0
- package/dist/cache.d.ts +69 -0
- package/dist/client.d.ts +87 -0
- package/dist/common.d.ts +64 -0
- package/dist/compiler/compile-template.d.ts +16 -0
- package/dist/compiler/compile-to-vdom-function.d.ts +13 -0
- package/dist/compiler/extract-global-vars.d.ts +17 -0
- package/dist/compiler/template-syntax.d.ts +61 -0
- package/dist/compiler.cjs +15847 -15482
- package/dist/compiler.js +15844 -15467
- package/dist/cross-site.d.ts +29 -0
- package/dist/devtool.cjs +4138 -3183
- package/dist/devtool.d.cts +2 -1
- package/dist/devtool.d.ts +2 -1
- package/dist/devtool.js +4164 -3125
- package/dist/dom.d.ts +45 -0
- package/dist/event-delegator.d.ts +28 -0
- package/dist/event-emitter.d.ts +38 -0
- package/dist/frame.d.ts +143 -0
- package/dist/framework.d.ts +9 -0
- package/dist/hmr.d.ts +53 -0
- package/dist/index.amd.js +6285 -0
- package/dist/index.cjs +5959 -4489
- package/dist/index.d.cts +9 -8
- package/dist/index.d.ts +9 -8
- package/dist/index.js +5920 -4425
- package/dist/index.umd.js +6272 -0
- package/dist/mark.d.ts +26 -0
- package/dist/module-loader.d.ts +20 -0
- package/dist/router.d.ts +14 -0
- package/dist/rspack.cjs +15931 -15553
- package/dist/rspack.d.cts +42 -5
- package/dist/rspack.d.ts +42 -5
- package/dist/rspack.js +15930 -15546
- package/dist/runtime.amd.js +94 -0
- package/dist/runtime.cjs +79 -82
- package/dist/runtime.js +85 -19
- package/dist/runtime.umd.js +98 -0
- package/dist/service.d.ts +173 -0
- package/dist/state.d.ts +8 -0
- package/dist/store.d.ts +60 -0
- package/dist/types.d.ts +1259 -0
- package/dist/updater.d.ts +90 -0
- package/dist/url-state.d.ts +32 -0
- package/dist/utils.d.ts +90 -0
- package/dist/vdom.d.ts +45 -0
- package/dist/view-registry.d.ts +20 -0
- package/dist/view.d.ts +214 -0
- package/dist/vite.cjs +15944 -15582
- package/dist/vite.d.cts +2 -1
- package/dist/vite.d.ts +2 -1
- package/dist/vite.js +15941 -15574
- package/dist/webpack.cjs +15981 -15553
- package/dist/webpack.d.cts +32 -4
- package/dist/webpack.d.ts +32 -4
- package/dist/webpack.js +15980 -15546
- package/package.json +2 -2
- package/dist/chunk-66OZBBSP.js +0 -108
package/dist/dom.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { DomRef, DomOp, FrameInterface } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Unmount frames within a DOM node.
|
|
4
|
+
*/
|
|
5
|
+
export declare function domUnmountFrames(frame: FrameInterface, node: ChildNode): void;
|
|
6
|
+
/**
|
|
7
|
+
* Parse HTML string into a DOM element.
|
|
8
|
+
* Handles special elements (table, SVG, MathML) with wrapper elements.
|
|
9
|
+
*/
|
|
10
|
+
export declare function domGetNode(html: string, refNode: Element): Element;
|
|
11
|
+
/**
|
|
12
|
+
* Get compare key for a DOM node (for keyed diff).
|
|
13
|
+
* Uses id or v-lark path.
|
|
14
|
+
*/
|
|
15
|
+
export declare function domGetCompareKey(node: ChildNode): string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Special diff for form elements (value, checked, selected).
|
|
18
|
+
* Form elements carry state on the DOM node (e.g. `input.value`) that isn't
|
|
19
|
+
* reflected in attributes, so we have to sync those properties separately.
|
|
20
|
+
*/
|
|
21
|
+
export declare function domSpecialDiff(oldNode: ChildNode, newNode: ChildNode): number;
|
|
22
|
+
/**
|
|
23
|
+
* Set attributes from new element onto old element, tracking changes in ref.
|
|
24
|
+
*/
|
|
25
|
+
export declare function domSetAttributes(oldNode: Element, newNode: Element, ref: DomRef, keepId?: boolean): void;
|
|
26
|
+
/**
|
|
27
|
+
* Set child nodes from new parent onto old parent using keyed diff algorithm.
|
|
28
|
+
*/
|
|
29
|
+
export declare function domSetChildNodes(oldParent: Element, newParent: Element, ref: DomRef, frame: FrameInterface, keys_?: ReadonlySet<string>): void;
|
|
30
|
+
/**
|
|
31
|
+
* Diff two DOM nodes and apply changes.
|
|
32
|
+
*/
|
|
33
|
+
export declare function domSetNode(oldNode: ChildNode, newNode: ChildNode, oldParent: Element, ref: DomRef, frame: FrameInterface, keys_?: ReadonlySet<string>): void;
|
|
34
|
+
/**
|
|
35
|
+
* Create an empty DomRef for tracking diff operations.
|
|
36
|
+
*/
|
|
37
|
+
export declare function createDomRef(): DomRef;
|
|
38
|
+
/**
|
|
39
|
+
* Apply DOM diff operations to the DOM.
|
|
40
|
+
*/
|
|
41
|
+
export declare function applyDomOps(ops: DomOp[]): void;
|
|
42
|
+
/**
|
|
43
|
+
* Apply ID updates from DOM diff.
|
|
44
|
+
*/
|
|
45
|
+
export declare function applyIdUpdates(updates: [Element, string][]): void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { FrameInterface } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* DOM event delegation system.
|
|
4
|
+
* Delegates events to document body for performance.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
export declare const EventDelegator: {
|
|
8
|
+
/**
|
|
9
|
+
* Bind a DOM event type to document body.
|
|
10
|
+
*/
|
|
11
|
+
bind(eventType: string, hasSelector?: boolean): void;
|
|
12
|
+
/**
|
|
13
|
+
* Unbind a DOM event type from document body.
|
|
14
|
+
*/
|
|
15
|
+
unbind(eventType: string, hasSelector?: boolean): void;
|
|
16
|
+
/**
|
|
17
|
+
* Clean up range events for a destroyed view.
|
|
18
|
+
*/
|
|
19
|
+
clearRangeEvents(viewId: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Set the frame getter function (called by Framework.boot).
|
|
22
|
+
*/
|
|
23
|
+
setFrameGetter(getter: (id: string) => FrameInterface | undefined): void;
|
|
24
|
+
/**
|
|
25
|
+
* Get next element GUID.
|
|
26
|
+
*/
|
|
27
|
+
nextElementGuid(): number;
|
|
28
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { AnyFunc, ChangeEvent, EventEmitterInterface, EventListenerEntry } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Multi-cast event emitter class.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* const emitter = new EventEmitter();
|
|
7
|
+
* emitter.on('change', (data) => console.log(data));
|
|
8
|
+
* emitter.fire('change', { key: 'value' });
|
|
9
|
+
*/
|
|
10
|
+
export declare class EventEmitter<T = unknown> implements EventEmitterInterface<T> {
|
|
11
|
+
/** Event listeners: prefixed key -> listener array */
|
|
12
|
+
listeners: Map<string, EventListenerEntry[]>;
|
|
13
|
+
/** Number of `fire()` calls currently on the stack (re-entrancy depth). */
|
|
14
|
+
private firingDepth;
|
|
15
|
+
/** Keys whose listener list needs compaction after firing settles. */
|
|
16
|
+
private pendingCompaction;
|
|
17
|
+
/**
|
|
18
|
+
* Bind event listener.
|
|
19
|
+
*/
|
|
20
|
+
on(event: string, handler: (this: T, e: ChangeEvent) => void): this;
|
|
21
|
+
/**
|
|
22
|
+
* Unbind event listener.
|
|
23
|
+
* If handler is provided, removes only that handler.
|
|
24
|
+
* If no handler, removes all handlers for the event.
|
|
25
|
+
*/
|
|
26
|
+
off(event: string, handler?: AnyFunc): this;
|
|
27
|
+
/**
|
|
28
|
+
* Fire event, execute all bound handlers. Safe for re-entrant `off()` calls
|
|
29
|
+
* during dispatch: removed handlers are replaced with noop and compacted
|
|
30
|
+
* after the outermost fire returns.
|
|
31
|
+
*
|
|
32
|
+
* @param event - Event name
|
|
33
|
+
* @param data - Event data (type property added automatically)
|
|
34
|
+
* @param remove - Whether to remove all handlers after firing
|
|
35
|
+
* @param lastToFirst - Whether to execute handlers in reverse order
|
|
36
|
+
*/
|
|
37
|
+
fire(event: string, data?: Record<string, unknown>, remove?: boolean, lastToFirst?: boolean): this;
|
|
38
|
+
}
|
package/dist/frame.d.ts
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { EventEmitter } from "./event-emitter";
|
|
2
|
+
import { View } from "./view";
|
|
3
|
+
import type { AnyFunc, FrameInterface, FrameInvokeEntry, ViewInterface } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* Frame (View Frame) class for view lifecycle management.
|
|
6
|
+
* Each frame owns a view and manages child frames.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
export declare class Frame extends EventEmitter implements FrameInterface {
|
|
10
|
+
/** Frame ID (same as owner DOM element ID) */
|
|
11
|
+
readonly id: string;
|
|
12
|
+
/** Parent Frame ID */
|
|
13
|
+
private _parentId;
|
|
14
|
+
get parentId(): string | undefined;
|
|
15
|
+
/** Children map: id -> id */
|
|
16
|
+
childrenMap: Record<string, string>;
|
|
17
|
+
/** Children count */
|
|
18
|
+
childrenCount: number;
|
|
19
|
+
/** Ready count (children that have fired 'created') */
|
|
20
|
+
readyCount: number;
|
|
21
|
+
/** Set of child frame IDs that have fired 'created' */
|
|
22
|
+
readyMap: Set<string>;
|
|
23
|
+
/** View instance */
|
|
24
|
+
viewInstance?: ViewInterface;
|
|
25
|
+
/** Get view instance (read-only) */
|
|
26
|
+
get view(): ViewInterface | undefined;
|
|
27
|
+
/** Invoke list for deferred method calls */
|
|
28
|
+
invokeList: FrameInvokeEntry[];
|
|
29
|
+
/** Signature for async operation tracking */
|
|
30
|
+
signature: number;
|
|
31
|
+
/** Whether view has altered */
|
|
32
|
+
hasAltered: number;
|
|
33
|
+
/** Whether view is destroyed */
|
|
34
|
+
destroyed: number;
|
|
35
|
+
/** View path (v-lark attribute value) */
|
|
36
|
+
viewPath?: string;
|
|
37
|
+
/** Original template before mount */
|
|
38
|
+
originalTemplate?: string;
|
|
39
|
+
/** Hold fire created flag */
|
|
40
|
+
holdFireCreated: number;
|
|
41
|
+
/** Children created flag */
|
|
42
|
+
childrenCreated: number;
|
|
43
|
+
/** Children alter flag */
|
|
44
|
+
childrenAlter: number;
|
|
45
|
+
constructor(id: string, parentId?: string);
|
|
46
|
+
/**
|
|
47
|
+
* Mount a view to this frame.
|
|
48
|
+
*
|
|
49
|
+
* Complete flow:
|
|
50
|
+
* 1. Parse viewPath, translate query params from parent
|
|
51
|
+
* 2. Unmount current view
|
|
52
|
+
* 3. Load View class (via require or provided ViewClass)
|
|
53
|
+
* 4. View_Prepare (scan event methods)
|
|
54
|
+
* 5. Create View instance
|
|
55
|
+
* 6. View_DelegateEvents (bind DOM events)
|
|
56
|
+
* 7. Call view.init()
|
|
57
|
+
* 8. If view has template, call render via Updater
|
|
58
|
+
* 9. If no template, call endUpdate directly
|
|
59
|
+
*/
|
|
60
|
+
mountView(viewPath: string, viewInitParams?: Record<string, unknown>): void;
|
|
61
|
+
/**
|
|
62
|
+
* Internal: actually mount the view after class is loaded.
|
|
63
|
+
*/
|
|
64
|
+
doMountView(ViewClass: typeof View, params: Record<string, unknown>, node: HTMLElement, sign: number): void;
|
|
65
|
+
/**
|
|
66
|
+
* Unmount current view.
|
|
67
|
+
*/
|
|
68
|
+
unmountView(): void;
|
|
69
|
+
/**
|
|
70
|
+
* Mount a child frame.
|
|
71
|
+
*/
|
|
72
|
+
mountFrame(frameId: string, viewPath: string, viewInitParams?: Record<string, unknown>): FrameInterface;
|
|
73
|
+
/**
|
|
74
|
+
* Unmount a child frame.
|
|
75
|
+
*/
|
|
76
|
+
unmountFrame(id?: string): void;
|
|
77
|
+
/**
|
|
78
|
+
* Mount all views in a zone.
|
|
79
|
+
*/
|
|
80
|
+
mountZone(zoneId?: string): void;
|
|
81
|
+
/**
|
|
82
|
+
* Unmount all views in a zone.
|
|
83
|
+
*/
|
|
84
|
+
unmountZone(zoneId?: string): void;
|
|
85
|
+
/**
|
|
86
|
+
* Get all child frame IDs.
|
|
87
|
+
*/
|
|
88
|
+
children(): string[];
|
|
89
|
+
/**
|
|
90
|
+
* Get parent frame at given level.
|
|
91
|
+
* @param level - How many levels up (default 1)
|
|
92
|
+
*/
|
|
93
|
+
parent(level?: number): Frame | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* Invoke a method on the view.
|
|
96
|
+
*/
|
|
97
|
+
invoke(name: string, args?: unknown[]): unknown;
|
|
98
|
+
/**
|
|
99
|
+
* Type-safe variant of `invoke`.
|
|
100
|
+
*
|
|
101
|
+
* `invoke()` accepts any string and any args, which silently hides
|
|
102
|
+
* mismatched call sites when a method gets renamed. `invokeTyped` carries
|
|
103
|
+
* the view's method signature through TypeScript so the compiler catches
|
|
104
|
+
* those mistakes:
|
|
105
|
+
*
|
|
106
|
+
* ```ts
|
|
107
|
+
* type Home = View & { loadData(id: string): Promise<void> };
|
|
108
|
+
* frame.invokeTyped<Home, "loadData">("loadData", ["user-1"]);
|
|
109
|
+
* ```
|
|
110
|
+
*
|
|
111
|
+
* Behavior is identical to `invoke` at runtime — same defer / direct-call
|
|
112
|
+
* paths — so it's a drop-in safer overload.
|
|
113
|
+
*/
|
|
114
|
+
invokeTyped<V extends Record<string, unknown>, K extends keyof V & string>(name: K, args: V[K] extends (...a: infer A) => unknown ? A : never[]): V[K] extends (...a: never[]) => infer R ? R | undefined : unknown;
|
|
115
|
+
/** Get frame by ID */
|
|
116
|
+
static get(id: string): Frame | undefined;
|
|
117
|
+
/** Get all frames */
|
|
118
|
+
static getAll(): Map<string, Frame>;
|
|
119
|
+
/**
|
|
120
|
+
* Returns the existing root frame, or `undefined` if none has been created.
|
|
121
|
+
* Pure getter — never creates a Frame, never touches the DOM.
|
|
122
|
+
*
|
|
123
|
+
* Use `Frame.createRoot(id)` to create the root explicitly during framework
|
|
124
|
+
* boot. For Micro-Frontend hosts that own multiple independent containers,
|
|
125
|
+
* use `new Frame(containerId)` directly so each MF mount has its own root.
|
|
126
|
+
*/
|
|
127
|
+
static getRoot(): Frame | undefined;
|
|
128
|
+
/**
|
|
129
|
+
* Create (or return) the singleton root frame for this app.
|
|
130
|
+
*
|
|
131
|
+
* Idempotent: subsequent calls always return the original root regardless
|
|
132
|
+
* of `rootId` — so passing a different id later is silently ignored.
|
|
133
|
+
* `Framework.boot()` is the canonical caller; user code rarely needs this.
|
|
134
|
+
*/
|
|
135
|
+
static createRoot(rootId?: string): Frame;
|
|
136
|
+
/** Bind event listener (static) */
|
|
137
|
+
static on(event: string, handler: AnyFunc): typeof Frame;
|
|
138
|
+
/** Unbind event listener (static) */
|
|
139
|
+
static off(event: string, handler?: AnyFunc): typeof Frame;
|
|
140
|
+
/** Fire event (static) */
|
|
141
|
+
static fire(event: string, data?: Record<string, unknown>): void;
|
|
142
|
+
}
|
|
143
|
+
export { registerViewClass, invalidateViewClass, getViewClassRegistry, } from "./view-registry";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FrameworkInterface } from "./types";
|
|
2
|
+
/** Wait result: OK = rendered, TIMEOUT_OR_NOT_FOUND = not rendered */
|
|
3
|
+
export declare const WAIT_OK = 1;
|
|
4
|
+
export declare const WAIT_TIMEOUT_OR_NOT_FOUND = 0;
|
|
5
|
+
/**
|
|
6
|
+
* Main framework object.
|
|
7
|
+
* Provides boot, config, and all global utility methods.
|
|
8
|
+
*/
|
|
9
|
+
export declare const Framework: FrameworkInterface;
|
package/dist/hmr.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal HMR context interface.
|
|
3
|
+
* Compatible with Vite's `import.meta.hot` and webpack's `module.hot`.
|
|
4
|
+
* Defined here to avoid depending on bundler-specific type packages.
|
|
5
|
+
*/
|
|
6
|
+
export interface HotContext {
|
|
7
|
+
/** Accept a self-update. The callback receives the new module namespace. */
|
|
8
|
+
accept(cb?: (mod: {
|
|
9
|
+
default?: unknown;
|
|
10
|
+
} | undefined) => void): void;
|
|
11
|
+
/** Register a cleanup callback that runs before this module is replaced. */
|
|
12
|
+
dispose(cb: (data: unknown) => void): void;
|
|
13
|
+
/** Force a full page reload (fallback when HMR cannot handle the update). */
|
|
14
|
+
invalidate(): void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Find all currently mounted frames whose viewPath matches the given path,
|
|
18
|
+
* and re-mount them.
|
|
19
|
+
*
|
|
20
|
+
* After a new View class is registered via `registerViewClass`, calling this
|
|
21
|
+
* function triggers `frame.mountView()` on each matching frame. Since the new
|
|
22
|
+
* class is already in the registry, `Frame.mountView` takes the synchronous
|
|
23
|
+
* path (`getViewClass` returns the class immediately).
|
|
24
|
+
*
|
|
25
|
+
* @param viewPath - The view path to match (e.g. 'home', 'components/list')
|
|
26
|
+
*/
|
|
27
|
+
export declare function reloadViews(viewPath: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* Set up the HMR accept handler for a view module.
|
|
30
|
+
*
|
|
31
|
+
* When the module is updated:
|
|
32
|
+
* 1. Extracts the new View class from the new module (default export or module itself)
|
|
33
|
+
* 2. Registers the new class in the view registry
|
|
34
|
+
* 3. Re-mounts all frames currently using this viewPath
|
|
35
|
+
*
|
|
36
|
+
* If the new module doesn't export a valid View class, falls back to
|
|
37
|
+
* `hot.invalidate()` which triggers a full page reload.
|
|
38
|
+
*
|
|
39
|
+
* @param hot - The HMR context (import.meta.hot)
|
|
40
|
+
* @param viewPath - The view path identifier (e.g. 'home')
|
|
41
|
+
*/
|
|
42
|
+
export declare function acceptView(hot: HotContext, viewPath: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* Set up the HMR dispose handler for a view module.
|
|
45
|
+
*
|
|
46
|
+
* When the module is about to be replaced, removes the old View class
|
|
47
|
+
* from the registry so that subsequent `getViewClass` calls don't return
|
|
48
|
+
* the stale class.
|
|
49
|
+
*
|
|
50
|
+
* @param hot - The HMR context (import.meta.hot)
|
|
51
|
+
* @param viewPath - The view path identifier (e.g. 'home')
|
|
52
|
+
*/
|
|
53
|
+
export declare function disposeView(hot: HotContext, viewPath: string): void;
|