@lark.js/mvc 0.0.13 → 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 -5
- package/dist/apply-style.d.ts +9 -0
- package/dist/cache.d.ts +69 -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 +15843 -15805
- package/dist/compiler.d.cts +1 -30
- package/dist/compiler.d.ts +1 -30
- package/dist/compiler.js +15840 -15789
- package/dist/cross-site.d.ts +29 -0
- package/dist/devtool.cjs +4139 -3166
- package/dist/devtool.d.cts +2 -1
- package/dist/devtool.d.ts +2 -1
- package/dist/devtool.js +4149 -3092
- 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 -4484
- package/dist/index.d.cts +10 -19
- package/dist/index.d.ts +10 -19
- package/dist/index.js +5919 -4419
- 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 +15927 -15877
- package/dist/rspack.d.cts +45 -23
- package/dist/rspack.d.ts +45 -23
- package/dist/rspack.js +15926 -15870
- 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 +15940 -15898
- package/dist/vite.d.cts +10 -8
- package/dist/vite.d.ts +10 -8
- package/dist/vite.js +15937 -15890
- package/dist/webpack.cjs +15977 -15877
- package/dist/webpack.d.cts +36 -14
- package/dist/webpack.d.ts +36 -14
- package/dist/webpack.js +15976 -15870
- package/package.json +6 -5
- package/dist/chunk-66OZBBSP.js +0 -108
- /package/{src → dist}/client.d.ts +0 -0
package/dist/store.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @lark.js/mvc Store
|
|
3
|
+
*
|
|
4
|
+
* Zustand-aligned state management for Lark MVC.
|
|
5
|
+
*
|
|
6
|
+
* Core API:
|
|
7
|
+
* - create(name, creator): define a store with (set, get) => initialState
|
|
8
|
+
* - store.getState(): read current state snapshot
|
|
9
|
+
* - store.setState(partial | updater): shallow-merge state and notify listeners
|
|
10
|
+
* - store.subscribe(listener): listen for state changes
|
|
11
|
+
* - store.destroy(): tear down the store
|
|
12
|
+
* - computed(deps, fn): derived state that auto-recomputes when deps change
|
|
13
|
+
* - bindStore(view, store, selector?): Lark View lifecycle binding
|
|
14
|
+
*/
|
|
15
|
+
type Listener<T> = (state: T, prevState: T) => void;
|
|
16
|
+
export interface StoreApi<T = Record<string, unknown>> {
|
|
17
|
+
getState(): T;
|
|
18
|
+
setState(partial: Partial<T> | ((prev: T) => Partial<T>)): void;
|
|
19
|
+
subscribe(listener: Listener<T>): () => void;
|
|
20
|
+
destroy(): void;
|
|
21
|
+
}
|
|
22
|
+
type StateCreator<T> = (set: (partial: Partial<T> | ((prev: T) => Partial<T>)) => void, get: () => T) => T;
|
|
23
|
+
/**
|
|
24
|
+
* Declare a derived (computed) store property.
|
|
25
|
+
*
|
|
26
|
+
* Usage inside a `create` creator:
|
|
27
|
+
* ```ts
|
|
28
|
+
* const store = create("counter", (set, get) => ({
|
|
29
|
+
* count: 0,
|
|
30
|
+
* doubled: computed(["count"], () => get().count * 2),
|
|
31
|
+
* }));
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* `deps` lists the state keys the computed reads. Whenever any dep changes
|
|
35
|
+
* via `setState`, the computed re-evaluates before listeners are notified.
|
|
36
|
+
* Writes to a computed key via `setState` are silently ignored.
|
|
37
|
+
*/
|
|
38
|
+
export declare function computed<T>(deps: readonly string[], fn: () => T): T;
|
|
39
|
+
export declare function create<T>(name: string, creator: StateCreator<T>): StoreApi<T>;
|
|
40
|
+
/**
|
|
41
|
+
* Bind a store to a Lark View. Subscribes to state changes and auto-unsubscribes
|
|
42
|
+
* when the view is destroyed.
|
|
43
|
+
*
|
|
44
|
+
* @param view - Lark View instance (must have updater.set/digest and on("destroy"))
|
|
45
|
+
* @param store - Store created via `create()`
|
|
46
|
+
* @param selector - Optional function to pick a subset of state for the updater.
|
|
47
|
+
* If omitted, only non-function state keys are forwarded.
|
|
48
|
+
* @returns unsubscribe function
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* // Observe all state
|
|
53
|
+
* bindStore(this, useCountStore);
|
|
54
|
+
*
|
|
55
|
+
* // Observe with selector
|
|
56
|
+
* bindStore(this, useCountStore, (s) => ({ count: s.count }));
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function bindStore<T>(view: unknown, store: StoreApi<T>, selector?: (state: T) => Record<string, unknown>): () => void;
|
|
60
|
+
export {};
|