@lark.js/mvc 0.0.15 → 0.0.17
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 +324 -215
- package/dist/chunk-OGPBFCIK.js +105 -0
- package/dist/client.d.cts +63 -0
- package/dist/client.d.ts +10 -34
- package/dist/compiler.cjs +15534 -15854
- package/dist/compiler.d.cts +1 -1
- package/dist/compiler.d.ts +1 -1
- package/dist/compiler.js +15519 -15851
- package/dist/devtool.cjs +2617 -4152
- package/dist/devtool.d.cts +1 -2
- package/dist/devtool.d.ts +1 -2
- package/dist/devtool.js +2543 -4159
- package/dist/index.cjs +4128 -6008
- package/dist/index.d.cts +571 -1291
- package/dist/index.d.ts +571 -1291
- package/dist/index.js +4058 -5976
- package/dist/rspack.cjs +15648 -15935
- package/dist/rspack.d.cts +8 -45
- package/dist/rspack.d.ts +8 -45
- package/dist/rspack.js +15641 -15934
- package/dist/runtime.cjs +79 -79
- package/dist/runtime.js +19 -85
- package/dist/vite.cjs +15841 -15957
- package/dist/vite.d.cts +6 -7
- package/dist/vite.d.ts +6 -7
- package/dist/vite.js +15834 -15955
- package/dist/webpack.cjs +15648 -15985
- package/dist/webpack.d.cts +5 -33
- package/dist/webpack.d.ts +5 -33
- package/dist/webpack.js +15641 -15984
- package/package.json +3 -4
- package/dist/apply-style.d.ts +0 -9
- package/dist/cache.d.ts +0 -69
- package/dist/common.d.ts +0 -64
- package/dist/compiler/compile-template.d.ts +0 -16
- package/dist/compiler/compile-to-vdom-function.d.ts +0 -13
- package/dist/compiler/extract-global-vars.d.ts +0 -17
- package/dist/compiler/template-syntax.d.ts +0 -61
- package/dist/cross-site.d.ts +0 -29
- package/dist/dom.d.ts +0 -45
- package/dist/event-delegator.d.ts +0 -28
- package/dist/event-emitter.d.ts +0 -38
- package/dist/frame.d.ts +0 -143
- package/dist/framework.d.ts +0 -9
- package/dist/hmr.d.ts +0 -53
- package/dist/index.amd.js +0 -6285
- package/dist/index.umd.js +0 -6272
- package/dist/mark.d.ts +0 -26
- package/dist/module-loader.d.ts +0 -20
- package/dist/router.d.ts +0 -14
- package/dist/runtime.amd.js +0 -94
- package/dist/runtime.umd.js +0 -98
- package/dist/service.d.ts +0 -173
- package/dist/state.d.ts +0 -8
- package/dist/store.d.ts +0 -60
- package/dist/types.d.ts +0 -1259
- package/dist/updater.d.ts +0 -90
- package/dist/url-state.d.ts +0 -32
- package/dist/utils.d.ts +0 -90
- package/dist/vdom.d.ts +0 -45
- package/dist/view-registry.d.ts +0 -20
- package/dist/view.d.ts +0 -214
package/dist/updater.d.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import type { UpdaterInterface } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* Updater class for view data binding.
|
|
4
|
-
* Manages view-local data with change detection and DOM diff triggering.
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
export declare class Updater implements UpdaterInterface {
|
|
8
|
-
/** View ID (same as owner frame ID) */
|
|
9
|
-
private viewId;
|
|
10
|
-
/** Current data object */
|
|
11
|
-
private data;
|
|
12
|
-
/** Ref data for template rendering */
|
|
13
|
-
refData: Record<string, unknown>;
|
|
14
|
-
/** Changed keys in current digest cycle */
|
|
15
|
-
private changedKeys;
|
|
16
|
-
/** Whether data has changed since last digest */
|
|
17
|
-
private hasChangedFlag;
|
|
18
|
-
/**
|
|
19
|
-
* Digesting queue: supports re-digest during digest.
|
|
20
|
-
* Holds pending callbacks; `null` is used as a sentinel marking the start
|
|
21
|
-
* of an active digest cycle, so `runDigest` can detect re-entrant calls.
|
|
22
|
-
*/
|
|
23
|
-
private digestingQueue;
|
|
24
|
-
/** Monotonically increasing version, bumped each time data actually changes. */
|
|
25
|
-
private version;
|
|
26
|
-
/** Snapshot of `version` taken by `snapshot()`, used by `altered()`. */
|
|
27
|
-
private snapshotVersion;
|
|
28
|
-
/** Last rendered VDOM tree (only used when virtualDom is enabled) */
|
|
29
|
-
private vdom?;
|
|
30
|
-
constructor(viewId: string);
|
|
31
|
-
/**
|
|
32
|
-
* Get data by key.
|
|
33
|
-
* Returns entire data object if key is omitted.
|
|
34
|
-
*/
|
|
35
|
-
get<T = unknown>(key?: string): T;
|
|
36
|
-
/**
|
|
37
|
-
* Set data, tracking changed keys.
|
|
38
|
-
* Returns this for chaining.
|
|
39
|
-
*/
|
|
40
|
-
set(data: Record<string, unknown>, excludes?: ReadonlySet<string>): this;
|
|
41
|
-
/**
|
|
42
|
-
* Detect changes and trigger DOM re-render.
|
|
43
|
-
*
|
|
44
|
-
* The core rendering pipeline:
|
|
45
|
-
* 1. Set data if provided
|
|
46
|
-
* 2. If changed, run DOM diff (template → new DOM → diff against old DOM)
|
|
47
|
-
* 3. Apply DOM operations
|
|
48
|
-
* 4. Apply ID updates
|
|
49
|
-
* 5. Call endUpdate on views that need re-rendering
|
|
50
|
-
* 6. Support re-digest during digest via queue
|
|
51
|
-
*/
|
|
52
|
-
digest(data?: Record<string, unknown>, excludes?: ReadonlySet<string>, callback?: () => void): void;
|
|
53
|
-
/**
|
|
54
|
-
* Core digest execution.
|
|
55
|
-
*/
|
|
56
|
-
private runDigest;
|
|
57
|
-
/**
|
|
58
|
-
* Save a snapshot of the current data version for `altered()` detection.
|
|
59
|
-
* Cheap O(1) — records the current monotonic version, no serialization.
|
|
60
|
-
*/
|
|
61
|
-
snapshot(): this;
|
|
62
|
-
/**
|
|
63
|
-
* Check whether data has changed since the last snapshot.
|
|
64
|
-
* Returns undefined when no snapshot has been taken yet.
|
|
65
|
-
*/
|
|
66
|
-
altered(): boolean | undefined;
|
|
67
|
-
/**
|
|
68
|
-
* Translate a refData reference back to its original value.
|
|
69
|
-
*
|
|
70
|
-
* The ref protocol is `SPLITTER` + ascii decimal digits — the exact format
|
|
71
|
-
* emitted by `refFn`. We require that exact shape so a user-supplied
|
|
72
|
-
* string that merely begins with SPLITTER is never accidentally resolved
|
|
73
|
-
* (or mishandled as a "missing ref").
|
|
74
|
-
*/
|
|
75
|
-
translate(data: unknown): unknown;
|
|
76
|
-
/**
|
|
77
|
-
* Resolve a dotted property path against refData.
|
|
78
|
-
*
|
|
79
|
-
* Only safe property-path syntax is supported: `a`, `a.b`, `a.b.c`.
|
|
80
|
-
* Numeric literals (e.g. `1`, `1.5`) are returned as numbers. Anything else
|
|
81
|
-
* returns `undefined` — we no longer evaluate arbitrary JavaScript via
|
|
82
|
-
* `new Function`, so the method is CSP-safe and cannot be used as an
|
|
83
|
-
* injection vector.
|
|
84
|
-
*/
|
|
85
|
-
parse(expr: string): unknown;
|
|
86
|
-
/**
|
|
87
|
-
* Get the set of keys changed since the last digest (for external inspection).
|
|
88
|
-
*/
|
|
89
|
-
getChangedKeys(): ReadonlySet<string>;
|
|
90
|
-
}
|
package/dist/url-state.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { ViewInterface } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* Sync view state with URL query parameters.
|
|
4
|
-
*
|
|
5
|
-
* @param view - The view instance to bind to (for auto location observation and lifecycle)
|
|
6
|
-
* @param initialState - Default values for each URL param key. Keys not present
|
|
7
|
-
* in the URL will use these defaults. Keys present in the URL override defaults.
|
|
8
|
-
* @returns A tuple `[state, setState]`:
|
|
9
|
-
* - `state`: current values read from the URL, merged with defaults
|
|
10
|
-
* - `setState`: update URL params. Accepts a partial object or an updater function.
|
|
11
|
-
* Only the specified keys are changed; other URL params are preserved.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* export default View.extend({
|
|
16
|
-
* template,
|
|
17
|
-
* init() {
|
|
18
|
-
* const [state, setState] = useUrlState(this, { page: "1", size: "20" });
|
|
19
|
-
* this.updater.set({ page: state.page, size: state.size }).digest();
|
|
20
|
-
* this.setState = setState;
|
|
21
|
-
* },
|
|
22
|
-
* assign() {
|
|
23
|
-
* const [state] = useUrlState(this, { page: "1", size: "20" });
|
|
24
|
-
* this.updater.set({ page: state.page, size: state.size });
|
|
25
|
-
* },
|
|
26
|
-
* "nextPage<click>"() {
|
|
27
|
-
* this.setState((prev) => ({ page: String(Number(prev.page) + 1) }));
|
|
28
|
-
* },
|
|
29
|
-
* });
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
export declare function useUrlState<S extends Record<string, string>>(view: ViewInterface, initialState?: S): [Readonly<S>, (patch: Partial<S> | ((prev: S) => Partial<S>)) => void];
|
package/dist/utils.d.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lark framework utility functions.
|
|
3
|
-
*/
|
|
4
|
-
import type { AnyFunc, ParsedUri } from "./types";
|
|
5
|
-
/**
|
|
6
|
-
* Schedule a task for deferred execution.
|
|
7
|
-
*
|
|
8
|
-
* Tasks are processed in FIFO order within time-sliced batches (9ms budget).
|
|
9
|
-
* When the budget is exceeded, the scheduler yields to the browser:
|
|
10
|
-
* 1. scheduler.yield() — pause-resume within the same batch (Chrome 115+)
|
|
11
|
-
* 2. setTimeout(0) — end batch, start a new one in the next event loop tick
|
|
12
|
-
*
|
|
13
|
-
* Use this to defer DOM operations and callbacks so that:
|
|
14
|
-
* 1. Multiple view updates within the same digest cycle are batched
|
|
15
|
-
* 2. The browser can process user input and paint between batches
|
|
16
|
-
* 3. Very large updates are split across frames to maintain responsiveness
|
|
17
|
-
*
|
|
18
|
-
* @param fn - The function to execute
|
|
19
|
-
* @param args - Arguments to pass to the function
|
|
20
|
-
*/
|
|
21
|
-
export declare function callFunction<T extends unknown[]>(fn: (...args: T) => void, args: T): void;
|
|
22
|
-
/** Check if value is a plain object (not null, not array, typeof object) */
|
|
23
|
-
export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
24
|
-
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
25
|
-
export declare function asRecord(value: unknown): Record<string, unknown>;
|
|
26
|
-
/** Check if value is primitive or function (not a complex object) */
|
|
27
|
-
export declare function isPrimitiveOrFunc(value: unknown): boolean;
|
|
28
|
-
/** Check if value is primitive (not object, not function) */
|
|
29
|
-
export declare function isPrimitive(value: unknown): boolean;
|
|
30
|
-
export declare function generateId(prefix?: string): string;
|
|
31
|
-
/** Sync local counter with global counter */
|
|
32
|
-
export declare function syncCounter(val: number): void;
|
|
33
|
-
export declare function noop(): void;
|
|
34
|
-
/** Safe hasOwnProperty check */
|
|
35
|
-
export declare function hasOwnProperty<T extends object>(owner: T | undefined | null, prop: PropertyKey): boolean;
|
|
36
|
-
/** Get object keys (own enumerable) */
|
|
37
|
-
export declare function keys<T extends object>(obj: T): string[];
|
|
38
|
-
/** Assign properties from sources to target (like Object.assign but safer) */
|
|
39
|
-
export declare function assign<T extends object>(target: T, ...sources: Partial<T>[]): T;
|
|
40
|
-
/**
|
|
41
|
-
* Execute functions in try-catch, ignoring errors.
|
|
42
|
-
* Returns the result of the last successfully executed function.
|
|
43
|
-
*/
|
|
44
|
-
export declare function funcWithTry(fns: AnyFunc | AnyFunc[], args: unknown[], context: unknown, configError?: (e: unknown) => void): unknown;
|
|
45
|
-
/** Shared empty Set used as default value to avoid per-call allocation. */
|
|
46
|
-
export declare const EMPTY_STRING_SET: ReadonlySet<string>;
|
|
47
|
-
/**
|
|
48
|
-
* Set newData into oldData, tracking changed keys.
|
|
49
|
-
* Returns whether any value changed.
|
|
50
|
-
*/
|
|
51
|
-
export declare function setData(newData: Record<string, unknown>, oldData: Record<string, unknown>, changedKeys: Set<string>, excludes: ReadonlySet<string>): boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Translate compiled refData references back to their original values.
|
|
54
|
-
*
|
|
55
|
-
* A reference token has the exact shape `SPLITTER + ascii decimal digits`
|
|
56
|
-
* (as emitted by `refFn`). This shape check ensures user data that
|
|
57
|
-
* merely happens to begin with the SPLITTER character is never mistaken
|
|
58
|
-
* for a ref.
|
|
59
|
-
*/
|
|
60
|
-
export declare function translateData(data: object, value: unknown): unknown;
|
|
61
|
-
/** Get element by ID, or return the element itself if already an element */
|
|
62
|
-
export declare function getById(id: string | Element | null): Element | null;
|
|
63
|
-
/** Get attribute from element safely */
|
|
64
|
-
export declare function getAttribute(element: Element, attr: string): string;
|
|
65
|
-
/** Ensure element has an ID, generating one if missing. Returns the ID. */
|
|
66
|
-
export declare function ensureElementId(element: HTMLElement, prefix?: string): string;
|
|
67
|
-
/**
|
|
68
|
-
* Check if node A is inside node B (or is the same node).
|
|
69
|
-
* Uses compareDocumentPosition for efficiency.
|
|
70
|
-
*/
|
|
71
|
-
export declare function nodeInside(a: string | HTMLElement, b: string | HTMLElement): boolean;
|
|
72
|
-
/**
|
|
73
|
-
* Parse URI string into path and params object.
|
|
74
|
-
* e.g. "/xxx/?a=b&c=d" => { path: "/xxx/", params: { a: "b", c: "d" } }
|
|
75
|
-
*
|
|
76
|
-
* The accumulator is function-local, so nested / re-entrant calls
|
|
77
|
-
* (e.g. invoking `parseUri` again inside a replace callback) are safe.
|
|
78
|
-
*/
|
|
79
|
-
export declare function parseUri(uri: string): ParsedUri;
|
|
80
|
-
/**
|
|
81
|
-
* Convert path and params to URI string.
|
|
82
|
-
* e.g. toUri("/xxx/", { a: "b", c: "d" }) => "/xxx/?a=b&c=d"
|
|
83
|
-
*/
|
|
84
|
-
export declare function toUri(path: string, params: Record<string, unknown>, keepEmpty?: ReadonlySet<string>): string;
|
|
85
|
-
/**
|
|
86
|
-
* Convert array to map/hash object.
|
|
87
|
-
* For simple arrays, counts occurrences.
|
|
88
|
-
* For object arrays, uses specified key as map key.
|
|
89
|
-
*/
|
|
90
|
-
export declare function toMap<T>(list: T[] | null | undefined, key?: keyof T): Record<string, T | number>;
|
package/dist/vdom.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { VDomNode, VDomRef, FrameInterface, ViewInterface } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* Create a virtual DOM node.
|
|
4
|
-
*
|
|
5
|
-
* Text node: `vdomCreate(0, 'text content')`
|
|
6
|
-
* Element: `vdomCreate('div', { class: 'row' }, [child1, child2])`
|
|
7
|
-
* Self-closing: `vdomCreate('br', null, 1)`
|
|
8
|
-
* Raw HTML: `vdomCreate(0, '<b>bold</b>', 1)` (children truthy → raw HTML node)
|
|
9
|
-
* Root: `vdomCreate(viewId, 0, [children])`
|
|
10
|
-
*/
|
|
11
|
-
export declare function vdomCreate(tag: string | number, props?: Record<string, unknown> | string | number | null, children?: VDomNode[] | string | number | null, specials?: Record<string, string>): VDomNode;
|
|
12
|
-
/**
|
|
13
|
-
* Create a real DOM node from a VDomNode.
|
|
14
|
-
*
|
|
15
|
-
* Text node → `document.createTextNode(html)`
|
|
16
|
-
* Element → `createElementNS` + `vdomSetAttributes` + `innerHTML`
|
|
17
|
-
*/
|
|
18
|
-
export declare function vdomCreateNode(vnode: VDomNode, owner: Element, ref: VDomRef): ChildNode;
|
|
19
|
-
/**
|
|
20
|
-
* Set/update attributes on a real DOM element from a VDomNode.
|
|
21
|
-
*
|
|
22
|
-
* If `lastVDom` is provided, removes old attributes not present in new.
|
|
23
|
-
* Special attributes are set as DOM properties; others via setAttribute.
|
|
24
|
-
*
|
|
25
|
-
* Returns 1 if any attribute changed, 0 otherwise.
|
|
26
|
-
*/
|
|
27
|
-
export declare function vdomSetAttributes(realNode: Element, newVDom: VDomNode, ref: VDomRef, lastVDom?: VDomNode): number;
|
|
28
|
-
/**
|
|
29
|
-
* Diff children of a real DOM parent against old and new VDOM trees.
|
|
30
|
-
*
|
|
31
|
-
* Three-phase algorithm:
|
|
32
|
-
* 1. Head fast-path: match identical nodes from the start
|
|
33
|
-
* 2. Tail fast-path: match identical nodes from the end
|
|
34
|
-
* 3. KeyMap reconciliation: build key→node index, process remaining children
|
|
35
|
-
*
|
|
36
|
-
* Old DOM node references are snapshotted before any mutations to ensure
|
|
37
|
-
* correct removal regardless of DOM position shifts.
|
|
38
|
-
*
|
|
39
|
-
* Fast path: on first render (lastVDom undefined), sets innerHTML directly.
|
|
40
|
-
*/
|
|
41
|
-
export declare function vdomSetChildNodes(realNode: Element, lastVDom: VDomNode | undefined, newVDom: VDomNode, ref: VDomRef, frame: FrameInterface, keys: ReadonlySet<string>, view: ViewInterface, ready: () => void): void;
|
|
42
|
-
/**
|
|
43
|
-
* Create an empty VDomRef for tracking diff operations.
|
|
44
|
-
*/
|
|
45
|
-
export declare function createVDomRef(viewId: string): VDomRef;
|
package/dist/view-registry.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { View } from "./view";
|
|
2
|
-
/**
|
|
3
|
-
* Look up a previously registered View class by path.
|
|
4
|
-
* Returns `undefined` if no class is registered for `path`.
|
|
5
|
-
*/
|
|
6
|
-
export declare function getViewClass(path: string): typeof View | undefined;
|
|
7
|
-
/**
|
|
8
|
-
* Register a View class for a given view path.
|
|
9
|
-
* Called after module loading completes (or up front during boot).
|
|
10
|
-
*/
|
|
11
|
-
export declare function registerViewClass(viewPath: string, ViewClass: typeof View): void;
|
|
12
|
-
/**
|
|
13
|
-
* Invalidate a View class from the registry.
|
|
14
|
-
* Used by HMR to force re-loading of a view module.
|
|
15
|
-
*/
|
|
16
|
-
export declare function invalidateViewClass(viewPath: string): void;
|
|
17
|
-
/**
|
|
18
|
-
* Get the full view class registry (for HMR / debugging).
|
|
19
|
-
*/
|
|
20
|
-
export declare function getViewClassRegistry(): Record<string, typeof View>;
|
package/dist/view.d.ts
DELETED
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import type { HotContext } from "./hmr";
|
|
2
|
-
import type { AnyFunc, ViewInterface, ViewTemplate, FrameInterface, UpdaterInterface, ViewLocationObserved, ViewGlobalEventEntry, ViewEventSelectorEntry, ViewResourceEntry } from "./types";
|
|
3
|
-
/**
|
|
4
|
-
* Base View class.
|
|
5
|
-
* Views are created via View.extend() and mounted by Frame.
|
|
6
|
-
*/
|
|
7
|
-
export declare class View implements ViewInterface {
|
|
8
|
-
/** View ID (same as owner frame ID) */
|
|
9
|
-
id: string;
|
|
10
|
-
/** Owner frame */
|
|
11
|
-
owner: FrameInterface | number;
|
|
12
|
-
/** Updater instance */
|
|
13
|
-
updater: UpdaterInterface;
|
|
14
|
-
/** Signature: > 0 means active, incremented on render, 0 = destroyed */
|
|
15
|
-
signature: number;
|
|
16
|
-
/** Whether rendered at least once */
|
|
17
|
-
rendered?: boolean;
|
|
18
|
-
/** Whether view has template */
|
|
19
|
-
template?: ViewTemplate;
|
|
20
|
-
/** Location observation config */
|
|
21
|
-
locationObserved: ViewLocationObserved;
|
|
22
|
-
/** Observed state keys */
|
|
23
|
-
observedStateKeys?: string[];
|
|
24
|
-
/** Resource map */
|
|
25
|
-
resources: Record<string, ViewResourceEntry>;
|
|
26
|
-
/** Whether endUpdate pending */
|
|
27
|
-
endUpdatePending?: number;
|
|
28
|
-
/** Internal event storage */
|
|
29
|
-
private _events;
|
|
30
|
-
/** Prototype-stored event maps shape (set by View.prepare). */
|
|
31
|
-
private get protoEventState();
|
|
32
|
-
/**
|
|
33
|
-
* Event bitmask map: eventType -> bitmask (1=root, 2=selector).
|
|
34
|
-
* Read from prototype ($evtObjMap) set by View.prepare.
|
|
35
|
-
* Using a getter avoids ES6 class field shadowing the prototype value.
|
|
36
|
-
*/
|
|
37
|
-
get eventObjectMap(): Record<string, number>;
|
|
38
|
-
/**
|
|
39
|
-
* Selector event map: eventType -> selector list.
|
|
40
|
-
* Read from prototype ($selMap) set by View.prepare.
|
|
41
|
-
*/
|
|
42
|
-
get eventSelectorMap(): Record<string, ViewEventSelectorEntry>;
|
|
43
|
-
/**
|
|
44
|
-
* Global event list: [{handler, element, eventName, modifiers}].
|
|
45
|
-
* Read from prototype ($globalEvtList) set by View.prepare.
|
|
46
|
-
*/
|
|
47
|
-
get globalEventList(): ViewGlobalEventEntry[];
|
|
48
|
-
/**
|
|
49
|
-
* Initialize view (called by Frame when mounting).
|
|
50
|
-
*/
|
|
51
|
-
init(): void;
|
|
52
|
-
/**
|
|
53
|
-
* Render view template (called by Frame after init).
|
|
54
|
-
* Wrapped by View.wrapMethod to manage signature + resources.
|
|
55
|
-
*/
|
|
56
|
-
render(): void;
|
|
57
|
-
on(event: string, handler: AnyFunc): this;
|
|
58
|
-
off(event: string, handler?: AnyFunc): this;
|
|
59
|
-
fire(event: string, data?: Record<string, unknown>, remove?: boolean, lastToFirst?: boolean): this;
|
|
60
|
-
/** Get the owning frame, asserting it has been bound. */
|
|
61
|
-
private get ownerFrame();
|
|
62
|
-
/**
|
|
63
|
-
* Notify view that HTML update is about to begin.
|
|
64
|
-
* Unmounts child frames in the update zone.
|
|
65
|
-
*/
|
|
66
|
-
beginUpdate(id?: string): void;
|
|
67
|
-
/**
|
|
68
|
-
* Notify view that HTML update has ended.
|
|
69
|
-
* Mounts child frames in the update zone and runs deferred invokes.
|
|
70
|
-
*/
|
|
71
|
-
endUpdate(id?: string, inner?: boolean): void;
|
|
72
|
-
/**
|
|
73
|
-
* Wrap an async callback to check view signature before executing.
|
|
74
|
-
* If the view has been re-rendered or destroyed, the callback is skipped.
|
|
75
|
-
*/
|
|
76
|
-
wrapAsync<Fn extends AnyFunc>(fn: Fn, context?: unknown): (...args: Parameters<Fn>) => ReturnType<Fn> | undefined;
|
|
77
|
-
/**
|
|
78
|
-
* Observe location parameters or path changes.
|
|
79
|
-
* When observed keys change, render() is called automatically.
|
|
80
|
-
*/
|
|
81
|
-
observeLocation(params: string | string[] | Record<string, unknown>, observePath?: boolean): void;
|
|
82
|
-
/**
|
|
83
|
-
* Observe State data keys for changes.
|
|
84
|
-
* When observed keys change via State.digest(), render() is called.
|
|
85
|
-
*/
|
|
86
|
-
observeState(observedKeys: string | string[]): void;
|
|
87
|
-
/**
|
|
88
|
-
* Capture (register) a resource under a key.
|
|
89
|
-
* If a resource already exists at that key, it's destroyed first.
|
|
90
|
-
* When destroyOnRender=true, the resource is destroyed on next render call.
|
|
91
|
-
*/
|
|
92
|
-
capture(key: string, resource?: unknown, destroyOnRender?: boolean): unknown;
|
|
93
|
-
/**
|
|
94
|
-
* Release a captured resource.
|
|
95
|
-
* If destroy=true, calls the resource's destroy() method.
|
|
96
|
-
*/
|
|
97
|
-
release(key: string, destroy?: boolean): unknown;
|
|
98
|
-
/**
|
|
99
|
-
* Set up a leave confirmation for route changes and page unload.
|
|
100
|
-
*/
|
|
101
|
-
leaveTip(message: string, condition: () => boolean): void;
|
|
102
|
-
/** Collected ctors from mixins */
|
|
103
|
-
static ctors?: AnyFunc[];
|
|
104
|
-
/**
|
|
105
|
-
* Prepare a View subclass by scanning its prototype for event method patterns.
|
|
106
|
-
* Pattern: `$?name<eventType1,eventType2>(&modifiers)`
|
|
107
|
-
*
|
|
108
|
-
* Only runs once per View subclass (guarded by ctors marker).
|
|
109
|
-
* Called from Frame.mountView before creating the view instance.
|
|
110
|
-
*/
|
|
111
|
-
static prepare(oView: typeof View): AnyFunc[];
|
|
112
|
-
/**
|
|
113
|
-
* Bind or unbind event delegation for a view instance.
|
|
114
|
-
* Called from Frame during mount/unmount.
|
|
115
|
-
*/
|
|
116
|
-
static delegateEvents(view: ViewInterface, destroy?: boolean): void;
|
|
117
|
-
/**
|
|
118
|
-
* Destroy all resources managed by a view.
|
|
119
|
-
* If lastly=true, destroy ALL resources; otherwise only destroyOnRender ones.
|
|
120
|
-
*/
|
|
121
|
-
static destroyAllResources(view: ViewInterface, lastly: boolean): void;
|
|
122
|
-
/**
|
|
123
|
-
* Process deferred invoke calls on a frame.
|
|
124
|
-
*/
|
|
125
|
-
static runInvokes(frame: FrameInterface): void;
|
|
126
|
-
/**
|
|
127
|
-
* Wrap a method on the prototype to add signature checking and resource cleanup.
|
|
128
|
-
*/
|
|
129
|
-
private static wrapMethod;
|
|
130
|
-
/**
|
|
131
|
-
* When two mixins define the same event method, merge them into
|
|
132
|
-
* a single function that calls both in sequence.
|
|
133
|
-
*/
|
|
134
|
-
private static processMixinsSameEvent;
|
|
135
|
-
/**
|
|
136
|
-
* Merge an array of mixin objects into the view prototype.
|
|
137
|
-
*/
|
|
138
|
-
private static mergeMixins;
|
|
139
|
-
/**
|
|
140
|
-
* Destroy a single resource entry.
|
|
141
|
-
*/
|
|
142
|
-
private static destroyResource;
|
|
143
|
-
/**
|
|
144
|
-
* Extend View to create a new View subclass.
|
|
145
|
-
*
|
|
146
|
-
* Supports:
|
|
147
|
-
* - props.ctor: constructor-like init (called with initParams + {node, deep})
|
|
148
|
-
* - props.mixins: array of mixin objects
|
|
149
|
-
* - Event method patterns: `'name<click>'` etc.
|
|
150
|
-
*/
|
|
151
|
-
static extend(props?: ThisType<ViewInterface> & Record<string, unknown>, statics?: Record<string, unknown>): typeof View;
|
|
152
|
-
/**
|
|
153
|
-
* Merge mixins into View prototype.
|
|
154
|
-
*/
|
|
155
|
-
static merge(this: typeof View, ...mixins: Record<string, unknown>[]): typeof View;
|
|
156
|
-
/**
|
|
157
|
-
* Set up HMR accept handler for this view module.
|
|
158
|
-
*
|
|
159
|
-
* When the module is hot-replaced, the new View class is extracted from
|
|
160
|
-
* the new module, registered in the view registry, and all currently
|
|
161
|
-
* mounted frames using this viewPath are re-mounted.
|
|
162
|
-
*
|
|
163
|
-
* No-op when `hot` is undefined (production / non-HMR environment).
|
|
164
|
-
*
|
|
165
|
-
* ```ts
|
|
166
|
-
* if (import.meta.hot) {
|
|
167
|
-
* HomeView.accept(import.meta.hot, 'home');
|
|
168
|
-
* }
|
|
169
|
-
* ```
|
|
170
|
-
*/
|
|
171
|
-
static accept(hot: HotContext | undefined, viewPath: string): void;
|
|
172
|
-
/**
|
|
173
|
-
* Set up HMR dispose handler for this view module.
|
|
174
|
-
*
|
|
175
|
-
* When the module is about to be replaced, the old View class is removed
|
|
176
|
-
* from the registry so subsequent lookups don't return the stale class.
|
|
177
|
-
*
|
|
178
|
-
* No-op when `hot` is undefined (production / non-HMR environment).
|
|
179
|
-
*
|
|
180
|
-
* ```ts
|
|
181
|
-
* if (import.meta.hot) {
|
|
182
|
-
* HomeView.dispose(import.meta.hot, 'home');
|
|
183
|
-
* }
|
|
184
|
-
* ```
|
|
185
|
-
*/
|
|
186
|
-
static dispose(hot: HotContext | undefined, viewPath: string): void;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Type-safe wrapper around `View.extend()`.
|
|
190
|
-
*
|
|
191
|
-
* `View.extend({...})` accepts any object literal, and inside its methods
|
|
192
|
-
* `this` is typed only as the base `ViewInterface` — so any custom state
|
|
193
|
-
* field or helper method requires a `(this as MyView).foo` strong-cast at
|
|
194
|
-
* every call site.
|
|
195
|
-
*
|
|
196
|
-
* `defineView()` threads the literal's own shape back into `this` via
|
|
197
|
-
* `ThisType<P & ViewInterface>`, so `this.foo` is typed automatically:
|
|
198
|
-
*
|
|
199
|
-
* ```ts
|
|
200
|
-
* const HomeView = defineView({
|
|
201
|
-
* $title: "Home",
|
|
202
|
-
* init() {
|
|
203
|
-
* this.updater.set({ title: this.$title }); // both typed
|
|
204
|
-
* },
|
|
205
|
-
* greet() {
|
|
206
|
-
* return `hello ${this.$title}`;
|
|
207
|
-
* },
|
|
208
|
-
* });
|
|
209
|
-
* ```
|
|
210
|
-
*
|
|
211
|
-
* Runtime semantics are identical to `View.extend(props, statics)` — this is
|
|
212
|
-
* a zero-cost type-only wrapper.
|
|
213
|
-
*/
|
|
214
|
-
export declare function defineView<P extends Record<string, unknown>>(props: P & ThisType<P & ViewInterface>, statics?: Record<string, unknown>): typeof View;
|