@lark.js/mvc 0.0.9 → 0.0.10

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/dist/index.d.ts CHANGED
@@ -1,3 +1,88 @@
1
+ /**
2
+ * Lark framework constants.
3
+ */
4
+ /** Internal splitter character (U+001E Record Separator, invisible, used as namespace separator).
5
+ * Uses String.fromCharCode to survive bundlers that strip control-char literals. */
6
+ declare const SPLITTER: string;
7
+ declare const RouterEvents: {
8
+ CHANGE: string;
9
+ CHANGED: string;
10
+ PAGE_UNLOAD: string;
11
+ };
12
+ /** Attribute name: v-lark */
13
+ declare const LARK_VIEW = "v-lark";
14
+ /** View event method regex: e.g. "app\x1eclickHandler(click)" or "clickHandler()"
15
+ * Group 1: optional frame ID (before SPLITTER)
16
+ * Group 2: handler name
17
+ * Group 3: params string
18
+ */
19
+ declare const EVENT_METHOD_REGEXP: RegExp;
20
+ /** View event method name regex: e.g. "name<click,mousedown>" or "$selector<click>" */
21
+ declare const VIEW_EVENT_METHOD_REGEXP: RegExp;
22
+ /** Tag name regexp for I_GetNode */
23
+ declare const TAG_NAME_REGEXP: RegExp;
24
+ /** Async task break time (ms) */
25
+ declare const CALL_BREAK_TIME = 48;
26
+ /** Increment global counter and return new value */
27
+ declare function nextCounter(): number;
28
+
29
+ /**
30
+ * Dynamically inject CSS styles into the document head.
31
+ * Returns a cleanup function to remove the injected styles.
32
+ *
33
+ * @param styleIdOrPairs - Style ID string or array of [id, content] pairs
34
+ * @param css - CSS content string (only used when first arg is string)
35
+ * @returns Cleanup function to remove the styles
36
+ */
37
+ declare function applyStyle(styleIdOrPairs: string | string[], css?: string): () => void;
38
+
39
+ /**
40
+ * Mark/Unmark: signature-based lifecycle tracking for async callbacks.
41
+ *
42
+ * `mark(host, key)` returns a validity checker. The checker returns `false`
43
+ * once the host is unmarked (e.g. when a view re-renders or is destroyed),
44
+ * so stale async callbacks can short-circuit and skip work.
45
+ *
46
+ * State is stored in a module-level WeakMap, not on the host object, so
47
+ * `mark/unmark` never pollutes user objects with magic keys, never breaks
48
+ * on `Object.freeze`-ed inputs, and never shows up in debug snapshots.
49
+ */
50
+ /**
51
+ * Create a mark for tracking async callback validity.
52
+ * Returns a function that returns true while the mark is still valid.
53
+ *
54
+ * @param host - Object to associate the mark with (typically a view)
55
+ * @param key - Key to track (typically "render" or a specific async-op identifier)
56
+ */
57
+ declare function mark(host: object, key: string): () => boolean;
58
+ /**
59
+ * Clear all marks for a host object, invalidating every existing checker.
60
+ * Called when a view re-renders or is destroyed.
61
+ *
62
+ * @param host - Object whose marks should be invalidated
63
+ */
64
+ declare function unmark(host: object): void;
65
+
66
+ /**
67
+ * Safeguard: Proxy-based debug protection for data objects.
68
+ *
69
+ * In DEBUG mode, wraps data objects with Proxy to:
70
+ * 1. Warn when data is read from a different page than where it was set
71
+ * 2. Prevent direct mutation (forces use of State.set/digest)
72
+ * 3. Track access patterns for debugging
73
+ */
74
+ /**
75
+ * Wrap data with a Proxy for debug-mode protection.
76
+ * Only active when window.__lark_Debug is true and Proxy is available.
77
+ *
78
+ * @param data - Data to wrap
79
+ * @param getter - Optional callback when properties are read
80
+ * @param setter - Optional callback when properties are written
81
+ * @param isRoot - Whether this is the root data object
82
+ * @returns Proxied data or original data if debug mode is off
83
+ */
84
+ declare function safeguard<T>(data: T, getter?: ((key: string) => void) | null, setter?: ((path: string, value: unknown) => void) | null, isRoot?: boolean): T;
85
+
1
86
  /**
2
87
  * Multi-cast event emitter class.
3
88
  *
@@ -59,8 +144,6 @@ declare class View implements ViewInterface {
59
144
  observedStateKeys?: string[];
60
145
  /** Resource map */
61
146
  resources: Record<string, ViewResourceEntry>;
62
- /** Assign method reference */
63
- assignMethod?: AnyFunc;
64
147
  /** Whether endUpdate pending */
65
148
  endUpdatePending?: number;
66
149
  /** Internal event storage */
@@ -303,15 +386,15 @@ declare class Frame extends EventEmitter implements FrameInterface {
303
386
  /**
304
387
  * Unmount a child frame.
305
388
  */
306
- unmountFrame(id?: string, _inner?: boolean): void;
389
+ unmountFrame(id?: string): void;
307
390
  /**
308
391
  * Mount all views in a zone.
309
392
  */
310
- mountZone(zoneId?: string, _inner?: boolean): void;
393
+ mountZone(zoneId?: string): void;
311
394
  /**
312
395
  * Unmount all views in a zone.
313
396
  */
314
- unmountZone(zoneId?: string, _inner?: boolean): void;
397
+ unmountZone(zoneId?: string): void;
315
398
  /**
316
399
  * Get all child frame IDs.
317
400
  */
@@ -363,15 +446,6 @@ declare class Frame extends EventEmitter implements FrameInterface {
363
446
  * `Framework.boot()` is the canonical caller; user code rarely needs this.
364
447
  */
365
448
  static createRoot(rootId?: string): Frame;
366
- /**
367
- * @deprecated Use `Frame.getRoot()` for read-only access or
368
- * `Frame.createRoot(id)` to create the root explicitly. The single-method
369
- * `root()` blurred the distinction and was a common source of bugs in
370
- * Micro-Frontend hosts.
371
- *
372
- * Kept for backward compatibility — behavior unchanged.
373
- */
374
- static root(rootId?: string): Frame;
375
449
  /** Bind event listener (static) */
376
450
  static on(event: string, handler: AnyFunc): typeof Frame;
377
451
  /** Unbind event listener (static) */
@@ -380,75 +454,6 @@ declare class Frame extends EventEmitter implements FrameInterface {
380
454
  static fire(event: string, data?: Record<string, unknown>): void;
381
455
  }
382
456
 
383
- /**
384
- * Cache class with LFU-style eviction.
385
- * Keys are prefixed with SPLITTER for namespace isolation.
386
- *
387
- * @example
388
- * const cache = new Cache({ maxSize: 20, bufferSize: 5 });
389
- * cache.set('user', { name: 'Alice' });
390
- * const user = cache.get('user');
391
- * cache.has('user'); // true
392
- * cache.del('user');
393
- */
394
- declare class Cache<T = unknown> implements CacheInterface<T> {
395
- /** Cache entries array */
396
- private entries;
397
- /** Fast lookup: prefixed key -> entry */
398
- private lookup;
399
- /** Buffer size for eviction */
400
- private readonly bufferSize;
401
- /** Maximum cache size */
402
- private readonly maxSize;
403
- /** Total capacity (maxSize + bufferSize) */
404
- private readonly capacity;
405
- /** Callback when entry is removed */
406
- private readonly onRemove?;
407
- /** Sort comparator */
408
- private readonly comparator;
409
- constructor(options?: CacheOptions<T>);
410
- /** Prefix a key with SPLITTER for namespace isolation */
411
- private prefixKey;
412
- /**
413
- * Get a cached value by key.
414
- * Updates frequency and timestamp for cache sorting.
415
- */
416
- get(key: string): T | undefined;
417
- /**
418
- * Iterate all cached values.
419
- */
420
- forEach(callback: (value: T | undefined) => void): void;
421
- /**
422
- * Set or update a cached value.
423
- * If key already exists, updates value and increments frequency.
424
- * If cache exceeds capacity, triggers eviction.
425
- */
426
- set(key: string, value: T): void;
427
- /**
428
- * Delete a cached entry. Removes it immediately from both the lookup map
429
- * and the entries array so the GC can reclaim the value without waiting
430
- * for the next eviction sweep.
431
- */
432
- del(key: string): void;
433
- /**
434
- * Check if a key exists in cache.
435
- */
436
- has(key: string): boolean;
437
- /** Get current cache size */
438
- get size(): number;
439
- /** Clear all entries */
440
- clear(): void;
441
- /**
442
- * Evict the `bufferSize` worst entries from the cache.
443
- *
444
- * Uses single-pass partial selection (O(n·k)) instead of sorting the entire
445
- * `entries` array (O(n log n)). For the typical `bufferSize = 5` this is
446
- * effectively a linear scan with at most 5 in-bucket comparisons per
447
- * iteration — and it avoids mutating the rest of `entries`.
448
- */
449
- private evictEntries;
450
- }
451
-
452
457
  /**
453
458
  * Lark framework type definitions.
454
459
  * All shared types are defined here to eliminate type cheats across modules.
@@ -872,8 +877,6 @@ interface ViewInterface extends EventEmitterInterface<ViewInterface> {
872
877
  eventObjectMap: Record<string, number>;
873
878
  /** Global event list */
874
879
  globalEventList: ViewGlobalEventEntry[];
875
- /** Assign method reference */
876
- assignMethod?: AnyFunc;
877
880
  /** Whether endUpdate has been called (1 = pending) */
878
881
  endUpdatePending?: number;
879
882
  /** Render method (wrapped) */
@@ -1022,18 +1025,17 @@ interface FrameInterface extends EventEmitterInterface<FrameInterface> {
1022
1025
  * Unmount child Frame from specified DOM node.
1023
1026
  * @param id DOM node ID, defaults to current Frame if omitted
1024
1027
  */
1025
- unmountFrame: (id?: string, inner?: boolean) => void;
1028
+ unmountFrame: (id?: string) => void;
1026
1029
  /**
1027
1030
  * Render all child views under specified node (scans v-lark attributes and mounts).
1028
1031
  * @param zoneId DOM node ID, defaults to current Frame
1029
- * @param inner Whether this is an internal framework call
1030
1032
  */
1031
- mountZone: (zoneId?: string, inner?: boolean) => void;
1033
+ mountZone: (zoneId?: string) => void;
1032
1034
  /**
1033
1035
  * Unmount all child views under specified node.
1034
1036
  * @param zoneId DOM node ID, defaults to current Frame
1035
1037
  */
1036
- unmountZone: (zoneId?: string, inner?: boolean) => void;
1038
+ unmountZone: (zoneId?: string) => void;
1037
1039
  /**
1038
1040
  * Get ancestor Frame, defaults to parent Frame (level=1).
1039
1041
  * @param level Levels to traverse upward, defaults to 1
@@ -1254,24 +1256,6 @@ interface ServiceOptions {
1254
1256
  /** POST data */
1255
1257
  data?: unknown;
1256
1258
  }
1257
- interface PayloadEntry {
1258
- /** Payload data */
1259
- data: Record<string, unknown>;
1260
- }
1261
- interface ServiceEntry {
1262
- /** Service ID */
1263
- id: string;
1264
- /** Service URL */
1265
- url: string;
1266
- /** Cache time in ms, 0 = no cache */
1267
- cacheTime: number;
1268
- /** Payload instance */
1269
- payload?: PayloadEntry;
1270
- /** Whether loading */
1271
- loading?: boolean;
1272
- /** Error info */
1273
- error?: Error;
1274
- }
1275
1259
  /** Pending cache entry for deduplication (internal to Service) */
1276
1260
  interface PendingCacheEntry extends Array<unknown> {
1277
1261
  /** Reference to the pending Payload entity */
@@ -1321,103 +1305,6 @@ interface ServiceMetaEntry {
1321
1305
  /** Additional properties */
1322
1306
  [key: string]: unknown;
1323
1307
  }
1324
- interface ServiceInternals {
1325
- metaList: Record<string, ServiceMetaEntry>;
1326
- payloadCache: CacheInterface<PayloadInterface>;
1327
- pendingCacheKeys: Record<string, PendingCacheEntry>;
1328
- syncFn: (payload: PayloadInterface, callback: () => void) => void;
1329
- staticEmitter: EventEmitterInterface;
1330
- }
1331
- interface ServiceInterface {
1332
- id: string;
1333
- destroyed: number;
1334
- busy: number;
1335
- taskQueue: AnyFunc[];
1336
- prevArgs: unknown[];
1337
- emitter: EventEmitterInterface;
1338
- internals: ServiceInternals;
1339
- /**
1340
- * Send all requests in parallel, execute done callback when all requests complete (success or failure).
1341
- * If endpoint specifies cache and cache is valid, uses cached data directly.
1342
- * @param metaList Endpoint name string, params object, or array of them
1343
- * @param done Callback when all requests complete, first param is error array, followed by each endpoint's Payload
1344
- */
1345
- all(metaList: string | Record<string, unknown> | (string | Record<string, unknown>)[], done: AnyFunc): ServiceInterface;
1346
- /**
1347
- * Execute callback after each request succeeds, callback may be called multiple times.
1348
- * @param metaList Endpoint name string, params object, or array of them
1349
- * @param done Callback
1350
- */
1351
- one(attrs: string | Record<string, unknown> | (string | Record<string, unknown>)[], done: AnyFunc): ServiceInterface;
1352
- /**
1353
- * Similar to all, but always skips cache and forces actual requests.
1354
- * @param metaList Endpoint name string, params object, or array of them
1355
- * @param done Callback
1356
- */
1357
- save(metaList: string | Record<string, unknown> | (string | Record<string, unknown>)[], done: AnyFunc): ServiceInterface;
1358
- /**
1359
- * Queue task for execution, executes next task after previous all/one/save task completes, similar to Promise chain.
1360
- * @param callback Callback invoked after task completes
1361
- */
1362
- enqueue(callback: AnyFunc): ServiceInterface;
1363
- /**
1364
- * Dequeue and execute next task in queue.
1365
- */
1366
- dequeue(...args: unknown[]): void;
1367
- /**
1368
- * Destroy current Service instance, cannot send new requests or invoke callbacks after destruction.
1369
- */
1370
- destroy(): void;
1371
- /**
1372
- * Add endpoint metadata, register one or more API endpoints.
1373
- * @param metaList Endpoint metadata array, or single metadata object
1374
- */
1375
- add(attrs: ServiceMetaEntry | ServiceMetaEntry[]): void;
1376
- /**
1377
- * Get metadata object.
1378
- * @param attrs Endpoint metadata object or name string
1379
- */
1380
- meta(attrs: string | Record<string, unknown>): ServiceMetaEntry;
1381
- /**
1382
- * Create Payload object from endpoint metadata.
1383
- * @param meta Endpoint metadata object or name string
1384
- */
1385
- create(meta: Record<string, unknown>): PayloadInterface;
1386
- /**
1387
- * Get or create Payload object from cache.
1388
- * @param meta Endpoint metadata object
1389
- * @param createNew Whether to create new Payload object; if false, prioritizes getting from cache
1390
- */
1391
- get(meta: Record<string, unknown>, createNew?: boolean): {
1392
- entity: PayloadInterface;
1393
- needsUpdate: boolean;
1394
- };
1395
- /**
1396
- * Get Payload object from cache, returns undefined if cache doesn't exist or has expired.
1397
- * @param meta Endpoint metadata object
1398
- */
1399
- cached(meta: Record<string, unknown>): PayloadInterface | undefined;
1400
- /**
1401
- * Clear cached data for specified endpoint.
1402
- * @param names Comma-separated endpoint name string or string array
1403
- */
1404
- clear(names: string | string[]): void;
1405
- /**
1406
- * Inherit to create new Service subclass, bind custom data sync function.
1407
- * @param sync Method to sync data, typically exchanges data with server
1408
- * @param cacheMax Maximum cache entries
1409
- * @param cacheBuffer Cache buffer size
1410
- */
1411
- extend(newSyncFn: (payload: PayloadInterface, callback: () => void) => void, newCacheMax?: number, newCacheBuffer?: number): ServiceInterface;
1412
- /**
1413
- * Triggered before endpoint sends request.
1414
- */
1415
- onBegin?: (e?: ServiceEvent) => void;
1416
- /**
1417
- * Triggered when endpoint request completes, whether success or failure.
1418
- */
1419
- onEnd?: (e?: ServiceEvent) => void;
1420
- }
1421
1308
  /** Cache info attached to Payload entity */
1422
1309
  interface ServiceCacheInfo {
1423
1310
  /** Endpoint name */
@@ -1633,7 +1520,7 @@ interface FrameworkInterface {
1633
1520
  }
1634
1521
  /**
1635
1522
  * Framework configuration interface, global config passed to app during `Framework.boot()`.
1636
- * All config items can be accessed at runtime via `Framework.config('key')`.
1523
+ * All config items can be accessed at runtime via `Framework.getConfig('key')`.
1637
1524
  */
1638
1525
  interface FrameworkConfig {
1639
1526
  /**
@@ -1775,150 +1662,73 @@ interface CompileOptions {
1775
1662
  }
1776
1663
 
1777
1664
  /**
1778
- * Lark framework utility functions.
1779
- */
1780
-
1781
- /** Check if value is a plain object (not null, not array, typeof object) */
1782
- declare function isPlainObject(value: unknown): value is Record<string, unknown>;
1783
- /** Check if value is primitive or function (not a complex object) */
1784
- declare function isPrimitiveOrFunc(value: unknown): boolean;
1785
- /** Check if value is primitive (not object, not function) */
1786
- declare function isPrimitive(value: unknown): boolean;
1787
- declare function generateId(prefix?: string): string;
1788
- /** Sync local counter with global counter */
1789
- declare function syncCounter(val: number): void;
1790
- declare function noop(): void;
1791
- /** Safe hasOwnProperty check */
1792
- declare function hasOwnProperty<T extends object>(owner: T | undefined | null, prop: PropertyKey): boolean;
1793
- /** Get object keys (own enumerable) */
1794
- declare function keys<T extends object>(obj: T): string[];
1795
- /** Assign properties from sources to target (like Object.assign but safer) */
1796
- declare function assign<T extends object>(target: T, ...sources: Partial<T>[]): T;
1797
- /**
1798
- * Execute functions in try-catch, ignoring errors.
1799
- * Returns the result of the last successfully executed function.
1800
- */
1801
- declare function funcWithTry(fns: AnyFunc | AnyFunc[], args: unknown[], context: unknown, configError?: (e: unknown) => void): unknown;
1802
- /**
1803
- * Set newData into oldData, tracking changed keys.
1804
- * Returns whether any value changed.
1805
- */
1806
- declare function setData(newData: Record<string, unknown>, oldData: Record<string, unknown>, changedKeys: Set<string>, excludes: ReadonlySet<string>): boolean;
1807
- declare function translateData(data: object, value: unknown): unknown;
1808
- /** Get element by ID, or return the element itself if already an element */
1809
- declare function getById(id: string | Element | null): Element | null;
1810
- /** Get attribute from element safely */
1811
- declare function getAttribute(element: Element, attr: string): string;
1812
- /** Ensure element has an ID, generating one if missing. Returns the ID. */
1813
- declare function ensureElementId(element: HTMLElement): string;
1814
- /**
1815
- * Check if node A is inside node B (or is the same node).
1816
- * Uses compareDocumentPosition for efficiency.
1817
- */
1818
- declare function nodeInside(a: string | HTMLElement, b: string | HTMLElement): boolean;
1819
- /**
1820
- * Parse URI string into path and params object.
1821
- * e.g. "/xxx/?a=b&c=d" => { path: "/xxx/", params: { a: "b", c: "d" } }
1822
- *
1823
- * The accumulator is function-local, so nested / re-entrant calls
1824
- * (e.g. invoking `parseUri` again inside a replace callback) are safe.
1825
- */
1826
- declare function parseUri(uri: string): ParsedUri;
1827
- /**
1828
- * Convert path and params to URI string.
1829
- * e.g. toUri("/xxx/", { a: "b", c: "d" }) => "/xxx/?a=b&c=d"
1830
- */
1831
- declare function toUri(path: string, params: Record<string, unknown>, keepEmpty?: ReadonlySet<string>): string;
1832
- /**
1833
- * Convert array to map/hash object.
1834
- * For simple arrays, counts occurrences.
1835
- * For object arrays, uses specified key as map key.
1836
- */
1837
- declare function toMap<T>(list: T[] | null | undefined, key?: keyof T): Record<string, T | number>;
1838
- /** Get current timestamp */
1839
- declare function now(): number;
1840
-
1841
- /** Internal splitter character (U+001E Record Separator, invisible, used as namespace separator).
1842
- * Uses String.fromCharCode to survive bundlers that strip control-char literals. */
1843
- declare const SPLITTER: string;
1844
- declare const RouterEvents: {
1845
- CHANGE: string;
1846
- CHANGED: string;
1847
- PAGE_UNLOAD: string;
1848
- };
1849
- /** Attribute name: v-lark */
1850
- declare const LARK_VIEW = "v-lark";
1851
- /** View event method regex: e.g. "app\x1eclickHandler(click)" or "clickHandler()"
1852
- * Group 1: optional frame ID (before SPLITTER)
1853
- * Group 2: handler name
1854
- * Group 3: params string
1855
- */
1856
- declare const EVENT_METHOD_REGEXP: RegExp;
1857
- /** View event method name regex: e.g. "name<click,mousedown>" or "$selector<click>" */
1858
- declare const VIEW_EVENT_METHOD_REGEXP: RegExp;
1859
- /** Tag name regexp for I_GetNode */
1860
- declare const TAG_NAME_REGEXP: RegExp;
1861
- /** Async task break time (ms) */
1862
- declare const CALL_BREAK_TIME = 48;
1863
- /** Increment global counter and return new value */
1864
- declare function nextCounter(): number;
1865
-
1866
- /**
1867
- * Dynamically inject CSS styles into the document head.
1868
- * Returns a cleanup function to remove the injected styles.
1869
- *
1870
- * @param styleIdOrPairs - Style ID string or array of [id, content] pairs
1871
- * @param css - CSS content string (only used when first arg is string)
1872
- * @returns Cleanup function to remove the styles
1873
- */
1874
- declare function applyStyle(styleIdOrPairs: string | string[], css?: string): () => void;
1875
-
1876
- /**
1877
- * Mark/Unmark: signature-based lifecycle tracking for async callbacks.
1878
- *
1879
- * `mark(host, key)` returns a validity checker. The checker returns `false`
1880
- * once the host is unmarked (e.g. when a view re-renders or is destroyed),
1881
- * so stale async callbacks can short-circuit and skip work.
1882
- *
1883
- * State is stored in a module-level WeakMap, not on the host object, so
1884
- * `mark/unmark` never pollutes user objects with magic keys, never breaks
1885
- * on `Object.freeze`-ed inputs, and never shows up in debug snapshots.
1886
- */
1887
- /**
1888
- * Create a mark for tracking async callback validity.
1889
- * Returns a function that returns true while the mark is still valid.
1890
- *
1891
- * @param host - Object to associate the mark with (typically a view)
1892
- * @param key - Key to track (typically "render" or a specific async-op identifier)
1893
- */
1894
- declare function mark(host: object, key: string): () => boolean;
1895
- /**
1896
- * Clear all marks for a host object, invalidating every existing checker.
1897
- * Called when a view re-renders or is destroyed.
1898
- *
1899
- * @param host - Object whose marks should be invalidated
1900
- */
1901
- declare function unmark(host: object): void;
1902
-
1903
- /**
1904
- * Safeguard: Proxy-based debug protection for data objects.
1905
- *
1906
- * In DEBUG mode, wraps data objects with Proxy to:
1907
- * 1. Warn when data is read from a different page than where it was set
1908
- * 2. Prevent direct mutation (forces use of State.set/digest)
1909
- * 3. Track access patterns for debugging
1910
- */
1911
- /**
1912
- * Wrap data with a Proxy for debug-mode protection.
1913
- * Only active when window.__lark_Debug is true and Proxy is available.
1665
+ * Cache class with LFU-style eviction.
1666
+ * Keys are prefixed with SPLITTER for namespace isolation.
1914
1667
  *
1915
- * @param data - Data to wrap
1916
- * @param getter - Optional callback when properties are read
1917
- * @param setter - Optional callback when properties are written
1918
- * @param isRoot - Whether this is the root data object
1919
- * @returns Proxied data or original data if debug mode is off
1668
+ * @example
1669
+ * const cache = new Cache({ maxSize: 20, bufferSize: 5 });
1670
+ * cache.set('user', { name: 'Alice' });
1671
+ * const user = cache.get('user');
1672
+ * cache.has('user'); // true
1673
+ * cache.del('user');
1920
1674
  */
1921
- declare function safeguard<T>(data: T, getter?: ((key: string) => void) | null, setter?: ((path: string, value: unknown) => void) | null, isRoot?: boolean): T;
1675
+ declare class Cache<T = unknown> implements CacheInterface<T> {
1676
+ /** Cache entries array */
1677
+ private entries;
1678
+ /** Fast lookup: prefixed key -> entry */
1679
+ private lookup;
1680
+ /** Buffer size for eviction */
1681
+ private readonly bufferSize;
1682
+ /** Maximum cache size */
1683
+ private readonly maxSize;
1684
+ /** Total capacity (maxSize + bufferSize) */
1685
+ private readonly capacity;
1686
+ /** Callback when entry is removed */
1687
+ private readonly onRemove?;
1688
+ /** Sort comparator */
1689
+ private readonly comparator;
1690
+ constructor(options?: CacheOptions<T>);
1691
+ /** Prefix a key with SPLITTER for namespace isolation */
1692
+ private prefixKey;
1693
+ /**
1694
+ * Get a cached value by key.
1695
+ * Updates frequency and timestamp for cache sorting.
1696
+ */
1697
+ get(key: string): T | undefined;
1698
+ /**
1699
+ * Iterate all cached values.
1700
+ */
1701
+ forEach(callback: (value: T | undefined) => void): void;
1702
+ /**
1703
+ * Set or update a cached value.
1704
+ * If key already exists, updates value and increments frequency.
1705
+ * If cache exceeds capacity, triggers eviction.
1706
+ */
1707
+ set(key: string, value: T): void;
1708
+ /**
1709
+ * Delete a cached entry. Removes it immediately from both the lookup map
1710
+ * and the entries array so the GC can reclaim the value without waiting
1711
+ * for the next eviction sweep.
1712
+ */
1713
+ del(key: string): void;
1714
+ /**
1715
+ * Check if a key exists in cache.
1716
+ */
1717
+ has(key: string): boolean;
1718
+ /** Get current cache size */
1719
+ get size(): number;
1720
+ /** Clear all entries */
1721
+ clear(): void;
1722
+ /**
1723
+ * Evict the `bufferSize` worst entries from the cache.
1724
+ *
1725
+ * Uses single-pass partial selection (O(n·k)) instead of sorting the entire
1726
+ * `entries` array (O(n log n)). For the typical `bufferSize = 5` this is
1727
+ * effectively a linear scan with at most 5 in-bucket comparisons per
1728
+ * iteration — and it avoids mutating the rest of `entries`.
1729
+ */
1730
+ private evictEntries;
1731
+ }
1922
1732
 
1923
1733
  /** Mark framework as booted (called from Framework.boot) */
1924
1734
  declare function markBooted(): void;
@@ -1992,59 +1802,6 @@ declare function resetProjectsMap(): void;
1992
1802
  */
1993
1803
  declare const CrossSite: typeof View;
1994
1804
 
1995
- /**
1996
- * Unmount frames within a DOM node.
1997
- */
1998
- declare function domUnmountFrames(frame: FrameInterface, node: ChildNode): void;
1999
- /**
2000
- * Parse HTML string into a DOM element.
2001
- * Handles special elements (table, SVG, MathML) with wrapper elements.
2002
- */
2003
- declare function domGetNode(html: string, refNode: Element): Element;
2004
- /**
2005
- * Get compare key for a DOM node (for keyed diff).
2006
- * Uses id or v-lark path.
2007
- */
2008
- declare function domGetCompareKey(node: ChildNode): string | undefined;
2009
- /**
2010
- * Special diff for form elements (value, checked, selected).
2011
- * Form elements carry state on the DOM node (e.g. `input.value`) that isn't
2012
- * reflected in attributes, so we have to sync those properties separately.
2013
- */
2014
- declare function domSpecialDiff(oldNode: ChildNode, newNode: ChildNode): number;
2015
- /**
2016
- * Set attributes from new element onto old element, tracking changes in ref.
2017
- */
2018
- declare function domSetAttributes(oldNode: Element, newNode: Element, ref: DomRef, keepId?: boolean): void;
2019
- /**
2020
- * Set child nodes from new parent onto old parent using keyed diff algorithm.
2021
- */
2022
- declare function domSetChildNodes(oldParent: Element, newParent: Element, ref: DomRef, frame: FrameInterface, keys_?: ReadonlySet<string>): void;
2023
- /**
2024
- * Diff two DOM nodes and apply changes.
2025
- */
2026
- declare function domSetNode(oldNode: ChildNode, newNode: ChildNode, oldParent: Element, ref: DomRef, frame: FrameInterface, keys_?: ReadonlySet<string>): void;
2027
- /**
2028
- * Create an empty DomRef for tracking diff operations.
2029
- */
2030
- declare function createDomRef(): DomRef;
2031
- /**
2032
- * Apply DOM diff operations to the DOM.
2033
- */
2034
- declare function applyDomOps(ops: DomOp[]): void;
2035
- /**
2036
- * Apply ID updates from DOM diff.
2037
- */
2038
- declare function applyIdUpdates(updates: [Element, string][]): void;
2039
- /** Encode value for safe HTML output */
2040
- declare function encodeHTML(v: unknown): string;
2041
- /** Safe string conversion */
2042
- declare function encodeSafe(v: unknown): string;
2043
- /** URI-encode a value with extra character encoding */
2044
- declare function encodeURIExtra(v: unknown): string;
2045
- /** Quote-encode a value for attribute use */
2046
- declare function encodeQ(v: unknown): string;
2047
-
2048
1805
  /**
2049
1806
  * Updater class for view data binding.
2050
1807
  * Manages view-local data with change detection and DOM diff triggering.
@@ -2112,7 +1869,7 @@ declare class Updater implements UpdaterInterface {
2112
1869
  * Translate a refData reference back to its original value.
2113
1870
  *
2114
1871
  * The ref protocol is `SPLITTER` + ascii decimal digits — the exact format
2115
- * emitted by `updaterRef`. We require that exact shape so a user-supplied
1872
+ * emitted by `refFn`. We require that exact shape so a user-supplied
2116
1873
  * string that merely begins with SPLITTER is never accidentally resolved
2117
1874
  * (or mishandled as a "missing ref").
2118
1875
  */
@@ -2427,11 +2184,7 @@ declare function create<T>(name: string, creator: StateCreator<T>): StoreApi<T>;
2427
2184
  * bindStore(this, useCountStore, (s) => ({ count: s.count }));
2428
2185
  * ```
2429
2186
  */
2430
- declare function bindStore<T extends Record<string, unknown>>(view: unknown, store: StoreApi<T>, selector?: (state: T) => Record<string, unknown>): () => void;
2431
- /**
2432
- * @deprecated Use `create()` instead. This is a temporary alias.
2433
- */
2434
- declare const defineStore: typeof create;
2187
+ declare function bindStore<T>(view: unknown, store: StoreApi<T>, selector?: (state: T) => Record<string, unknown>): () => void;
2435
2188
 
2436
2189
  /** Serialized view info attached to a frame node */
2437
2190
  interface SerializedViewInfo {
@@ -2515,4 +2268,4 @@ declare function serializeFrameTree(): SerializedFrameTree;
2515
2268
  */
2516
2269
  declare function installFrameVisualizerBridge(): void;
2517
2270
 
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 };
2271
+ 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 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 ServiceEvent, 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, applyStyle, bindStore, computed, create, defineView, config as frameworkConfig, getRouteMode, installFrameVisualizerBridge, invalidateViewClass, mark, markBooted, markRouterBooted, nextCounter, registerViewClass, resetProjectsMap, safeguard, serializeFrameTree, unmark, use, useUrlState };