@lark.js/mvc 0.0.12 → 0.0.14

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.cjs CHANGED
@@ -55,7 +55,6 @@ __export(index_exports, {
55
55
  registerViewClass: () => registerViewClass,
56
56
  reloadViews: () => reloadViews,
57
57
  resetProjectsMap: () => resetProjectsMap,
58
- safeguard: () => safeguard,
59
58
  unmark: () => unmark,
60
59
  use: () => use,
61
60
  useUrlState: () => useUrlState,
@@ -431,61 +430,6 @@ function unmark(host) {
431
430
  }
432
431
  }
433
432
 
434
- // src/safeguard.ts
435
- var proxiesPool = /* @__PURE__ */ new Map();
436
- var SAFEGUARD_SENTINEL = "_safe_";
437
- function safeguard(data, getter, setter, isRoot) {
438
- if (typeof window.__lark_Debug === "undefined" || !window.__lark_Debug) {
439
- return data;
440
- }
441
- if (typeof Proxy === "undefined") {
442
- return data;
443
- }
444
- if (isPrimitive(data)) {
445
- return data;
446
- }
447
- const build = (prefix, obj) => {
448
- const cacheKey = (getter || "") + "" + (setter || "");
449
- const cached = proxiesPool.get(obj);
450
- if (cached && cached.cacheKey === cacheKey) {
451
- return cached.entity;
452
- }
453
- if (Reflect.get(obj, SAFEGUARD_SENTINEL)) {
454
- return obj;
455
- }
456
- const entity = new Proxy(obj, {
457
- set(target, property, value) {
458
- if (!setter && !prefix) {
459
- throw new Error(
460
- "Avoid write back, key: " + prefix + property + " value:" + value + " more: https://github.com/hangtiancheng/lark"
461
- );
462
- }
463
- Reflect.set(target, property, value);
464
- if (setter) {
465
- setter(prefix + property, value);
466
- }
467
- return true;
468
- },
469
- get(target, property) {
470
- if (property === SAFEGUARD_SENTINEL) {
471
- return true;
472
- }
473
- const out = Reflect.get(target, property);
474
- if (!prefix && getter) {
475
- getter(property);
476
- }
477
- if (!isRoot && hasOwnProperty(target, property) && (Array.isArray(out) || isPlainObject(out))) {
478
- return build(prefix + property + ".", out);
479
- }
480
- return out;
481
- }
482
- });
483
- proxiesPool.set(obj, { cacheKey, entity });
484
- return entity;
485
- };
486
- return build("", data);
487
- }
488
-
489
433
  // src/cache.ts
490
434
  function sortCacheEntries(a, b) {
491
435
  return b.frequency - a.frequency || b.lastTimestamp - a.lastTimestamp;
@@ -761,7 +705,6 @@ var keyRefCounts = {};
761
705
  var changedKeys = /* @__PURE__ */ new Set();
762
706
  var stashedChangedKeys = EMPTY_STRING_SET;
763
707
  var dataIsChanged = false;
764
- var dataWhereSet = {};
765
708
  var emitter = new EventEmitter();
766
709
  var booted = false;
767
710
  function markBooted() {
@@ -785,47 +728,16 @@ function teardownKeysRef(keyList) {
785
728
  if (count <= 0) {
786
729
  Reflect.deleteProperty(keyRefCounts, key);
787
730
  Reflect.deleteProperty(appData, key);
788
- if (typeof window.__lark_Debug !== "undefined" && window.__lark_Debug) {
789
- Reflect.deleteProperty(dataWhereSet, key);
790
- }
791
731
  }
792
732
  }
793
733
  }
794
734
  }
795
- var warnedKeys = /* @__PURE__ */ new Set();
796
- function clearNotify(key) {
797
- warnedKeys.delete(key);
798
- }
799
- function delayNotify(key, message) {
800
- if (warnedKeys.has(key)) return;
801
- warnedKeys.add(key);
802
- console.warn(message);
803
- }
804
735
  var State = {
805
736
  /**
806
737
  * Get data from state.
807
738
  */
808
739
  get(key) {
809
740
  const result = key ? appData[key] : appData;
810
- if (typeof window.__lark_Debug !== "undefined" && window.__lark_Debug) {
811
- return safeguard(
812
- result,
813
- (dataKey) => {
814
- if (booted && hasOwnProperty(dataWhereSet, dataKey) && dataWhereSet[dataKey] !== window.location.pathname) {
815
- console.warn(
816
- `beware! You get state:"{State}.${dataKey}" where it set by page:${dataWhereSet[dataKey]}`
817
- );
818
- }
819
- },
820
- (path, _value) => {
821
- const sub = key || path;
822
- delayNotify(
823
- sub,
824
- `beware! You direct modify "{State}.${sub}" You should call State.set() and State.digest() to notify other views`
825
- );
826
- }
827
- );
828
- }
829
741
  return result;
830
742
  },
831
743
  /**
@@ -833,11 +745,6 @@ var State = {
833
745
  */
834
746
  set(data, excludes) {
835
747
  dataIsChanged = setData(data, appData, changedKeys, excludes || EMPTY_STRING_SET) || dataIsChanged;
836
- if (typeof window.__lark_Debug !== "undefined" && window.__lark_Debug && booted) {
837
- for (const p in data) {
838
- dataWhereSet[p] = window.location.pathname;
839
- }
840
- }
841
748
  return State;
842
749
  },
843
750
  /**
@@ -848,11 +755,6 @@ var State = {
848
755
  State.set(data, excludes);
849
756
  }
850
757
  if (dataIsChanged) {
851
- if (typeof window.__lark_Debug !== "undefined" && window.__lark_Debug) {
852
- for (const p of changedKeys) {
853
- clearNotify(p);
854
- }
855
- }
856
758
  dataIsChanged = false;
857
759
  const keys2 = changedKeys;
858
760
  stashedChangedKeys = keys2;
@@ -1094,9 +996,6 @@ var Router = {
1094
996
  attachViewAndPath(location);
1095
997
  hrefCache.set(href, location);
1096
998
  }
1097
- if (typeof window.__lark_Debug !== "undefined" && window.__lark_Debug) {
1098
- location["params"] = safeguard(location["params"]);
1099
- }
1100
999
  return location;
1101
1000
  },
1102
1001
  /**
@@ -1115,9 +1014,6 @@ var Router = {
1115
1014
  emitter2.fire(RouterEvents.CHANGED, asRecord(lastChanged));
1116
1015
  }
1117
1016
  silent = 0;
1118
- if (typeof window.__lark_Debug !== "undefined" && window.__lark_Debug && lastChanged) {
1119
- lastChanged = safeguard(lastChanged);
1120
- }
1121
1017
  return lastChanged;
1122
1018
  },
1123
1019
  /**
@@ -1564,6 +1460,21 @@ function use(names, callback) {
1564
1460
  return loadPromise;
1565
1461
  }
1566
1462
 
1463
+ // src/frame-registry.ts
1464
+ var frameRegistry = /* @__PURE__ */ new Map();
1465
+ function getFrame(id) {
1466
+ return frameRegistry.get(id);
1467
+ }
1468
+ function getAllFrames() {
1469
+ return frameRegistry;
1470
+ }
1471
+ function registerFrame(id, frame) {
1472
+ frameRegistry.set(id, frame);
1473
+ }
1474
+ function removeFrame(id) {
1475
+ frameRegistry.delete(id);
1476
+ }
1477
+
1567
1478
  // src/dom.ts
1568
1479
  var wrapMeta = {
1569
1480
  option: [1, "<select multiple>"],
@@ -1874,6 +1785,13 @@ function vdomCreate(tag, props, children, specials) {
1874
1785
  reused[c.compareKey] = (reused[c.compareKey] || 0) + 1;
1875
1786
  reusedTotal++;
1876
1787
  }
1788
+ if (c.reused) {
1789
+ if (!reused) reused = {};
1790
+ for (const key in c.reused) {
1791
+ reused[key] = (reused[key] || 0) + c.reused[key];
1792
+ reusedTotal += c.reused[key];
1793
+ }
1794
+ }
1877
1795
  if (c.views) {
1878
1796
  if (!viewList) viewList = [];
1879
1797
  viewList.push(...c.views);
@@ -2325,9 +2243,6 @@ var Updater = class {
2325
2243
  if (key) {
2326
2244
  result = this.data[key];
2327
2245
  }
2328
- if (typeof window !== "undefined" && window.__lark_Debug) {
2329
- return safeguard(result);
2330
- }
2331
2246
  return result;
2332
2247
  }
2333
2248
  /**
@@ -2381,7 +2296,7 @@ var Updater = class {
2381
2296
  const changed = this.hasChangedFlag;
2382
2297
  this.hasChangedFlag = 0;
2383
2298
  this.changedKeys = /* @__PURE__ */ new Set();
2384
- const frame = Frame.get(this.viewId);
2299
+ const frame = getFrame(this.viewId);
2385
2300
  const view = frame?.view;
2386
2301
  const node = getById(this.viewId);
2387
2302
  if (changed && view && node && view.signature > 0 && frame) {
@@ -2538,7 +2453,7 @@ function getViewClassRegistry() {
2538
2453
 
2539
2454
  // src/hmr.ts
2540
2455
  function reloadViews(viewPath) {
2541
- const allFrames = Frame.getAll();
2456
+ const allFrames = getAllFrames();
2542
2457
  const toReload = [];
2543
2458
  for (const [, frame] of allFrames) {
2544
2459
  if (frame.viewPath) {
@@ -2559,9 +2474,13 @@ function acceptView(hot, viewPath) {
2559
2474
  const NewViewClass = candidate;
2560
2475
  registerViewClass(viewPath, NewViewClass);
2561
2476
  reloadViews(viewPath);
2562
- } else {
2563
- hot.invalidate();
2477
+ return;
2564
2478
  }
2479
+ if (getViewClass(viewPath)) {
2480
+ reloadViews(viewPath);
2481
+ return;
2482
+ }
2483
+ hot.invalidate();
2565
2484
  });
2566
2485
  }
2567
2486
  function disposeView(hot, viewPath) {
@@ -3206,7 +3125,6 @@ function defineView(props, statics) {
3206
3125
  }
3207
3126
 
3208
3127
  // src/frame.ts
3209
- var frameRegistry = /* @__PURE__ */ new Map();
3210
3128
  var rootFrame;
3211
3129
  var globalAlter;
3212
3130
  var MAX_FRAME_POOL = 64;
@@ -3258,7 +3176,7 @@ var Frame = class _Frame extends EventEmitter {
3258
3176
  if (parentId) {
3259
3177
  this._parentId = parentId;
3260
3178
  }
3261
- frameRegistry.set(id, this);
3179
+ registerFrame(id, this);
3262
3180
  const element = document.getElementById(id);
3263
3181
  if (element) {
3264
3182
  element.frame = this;
@@ -3389,7 +3307,7 @@ var Frame = class _Frame extends EventEmitter {
3389
3307
  */
3390
3308
  mountFrame(frameId, viewPath, viewInitParams) {
3391
3309
  notifyAlter(this, { id: frameId });
3392
- let childFrame = frameRegistry.get(frameId);
3310
+ let childFrame = getFrame(frameId);
3393
3311
  if (!childFrame) {
3394
3312
  if (!this.childrenMap[frameId]) {
3395
3313
  this.childrenCount++;
@@ -3410,17 +3328,17 @@ var Frame = class _Frame extends EventEmitter {
3410
3328
  */
3411
3329
  unmountFrame(id) {
3412
3330
  const targetId = id ? this.childrenMap[id] : this.id;
3413
- const frame = frameRegistry.get(targetId);
3331
+ const frame = getFrame(targetId);
3414
3332
  if (!frame) return;
3415
3333
  const wasCreated = frame.readyCount > 0;
3416
3334
  const pId = frame.parentId;
3417
3335
  frame.unmountView();
3418
- removeFrame(targetId, wasCreated);
3336
+ removeFrame2(targetId, wasCreated);
3419
3337
  reInitFrameForCache(frame);
3420
3338
  if (frameCache.length < MAX_FRAME_POOL) {
3421
3339
  frameCache.push(frame);
3422
3340
  }
3423
- const parent = frameRegistry.get(pId || "");
3341
+ const parent = getFrame(pId || "");
3424
3342
  if (parent && parent.childrenMap[targetId]) {
3425
3343
  Reflect.deleteProperty(parent.childrenMap, targetId);
3426
3344
  parent.childrenCount--;
@@ -3485,7 +3403,7 @@ var Frame = class _Frame extends EventEmitter {
3485
3403
  let currentPid = this.parentId;
3486
3404
  let n = level >>> 0 || 1;
3487
3405
  while (currentPid && n--) {
3488
- frame = frameRegistry.get(currentPid);
3406
+ frame = getFrame(currentPid);
3489
3407
  currentPid = frame?.parentId;
3490
3408
  }
3491
3409
  return frame;
@@ -3546,11 +3464,11 @@ var Frame = class _Frame extends EventEmitter {
3546
3464
  // ============================================================
3547
3465
  /** Get frame by ID */
3548
3466
  static get(id) {
3549
- return frameRegistry.get(id);
3467
+ return getFrame(id);
3550
3468
  }
3551
3469
  /** Get all frames */
3552
3470
  static getAll() {
3553
- return frameRegistry;
3471
+ return getAllFrames();
3554
3472
  }
3555
3473
  /**
3556
3474
  * Returns the existing root frame, or `undefined` if none has been created.
@@ -3600,10 +3518,10 @@ var Frame = class _Frame extends EventEmitter {
3600
3518
  function htmlElIsBound(element) {
3601
3519
  return !!element.frameBound;
3602
3520
  }
3603
- function removeFrame(id, wasCreated) {
3604
- const frameInstance = frameRegistry.get(id);
3521
+ function removeFrame2(id, wasCreated) {
3522
+ const frameInstance = getFrame(id);
3605
3523
  if (!frameInstance) return;
3606
- frameRegistry.delete(id);
3524
+ removeFrame(id);
3607
3525
  Frame.fire("remove", { frame: frameInstance, fcc: wasCreated });
3608
3526
  const element = document.getElementById(id);
3609
3527
  if (element) {
@@ -3620,7 +3538,7 @@ function notifyCreated(frameInstance) {
3620
3538
  }
3621
3539
  const pId = frameInstance.parentId;
3622
3540
  if (pId) {
3623
- const parent = frameRegistry.get(pId);
3541
+ const parent = getFrame(pId);
3624
3542
  if (parent && !parent.readyMap.has(frameInstance.id)) {
3625
3543
  parent.readyMap.add(frameInstance.id);
3626
3544
  parent.readyCount++;
@@ -3636,7 +3554,7 @@ function notifyAlter(frameInstance, data) {
3636
3554
  frameInstance.fire("alter", data);
3637
3555
  const pId = frameInstance.parentId;
3638
3556
  if (pId) {
3639
- const parent = frameRegistry.get(pId);
3557
+ const parent = getFrame(pId);
3640
3558
  if (parent && parent.readyMap.has(frameInstance.id)) {
3641
3559
  parent.readyCount--;
3642
3560
  parent.readyMap.delete(frameInstance.id);
@@ -3654,7 +3572,7 @@ function reInitFrame(frame, id, parentId) {
3654
3572
  frame["signature"] = 1;
3655
3573
  frame["readyMap"] = /* @__PURE__ */ new Set();
3656
3574
  frame["invokeList"] = [];
3657
- frameRegistry.set(id, frame);
3575
+ registerFrame(id, frame);
3658
3576
  }
3659
3577
  function reInitFrameForCache(frame) {
3660
3578
  Reflect.set(frame, "id", "");
@@ -3663,7 +3581,7 @@ function reInitFrameForCache(frame) {
3663
3581
  frame["readyMap"] = /* @__PURE__ */ new Set();
3664
3582
  }
3665
3583
  function translateQuery(pId, src, params) {
3666
- const parentFrame = frameRegistry.get(pId);
3584
+ const parentFrame = getFrame(pId);
3667
3585
  const parentView = parentFrame?.view;
3668
3586
  if (!parentView) return;
3669
3587
  const parentRefData = parentView.updater.refData;
@@ -4554,19 +4472,6 @@ var Framework = {
4554
4472
  }
4555
4473
  return config;
4556
4474
  },
4557
- /**
4558
- * @deprecated Use `getConfig()` / `setConfig()`. Behavior unchanged.
4559
- */
4560
- config(cfg) {
4561
- if (!cfg) {
4562
- return config;
4563
- }
4564
- if (typeof cfg === "string") {
4565
- return config[cfg];
4566
- }
4567
- assign(config, cfg);
4568
- return config;
4569
- },
4570
4475
  /**
4571
4476
  * Boot the framework.
4572
4477
  */
@@ -4662,10 +4567,6 @@ var Framework = {
4662
4567
  * Generate globally unique ID.
4663
4568
  */
4664
4569
  guid: generateId,
4665
- /**
4666
- * Proxy-based debug guard.
4667
- */
4668
- guard: safeguard,
4669
4570
  /**
4670
4571
  * Cache class.
4671
4572
  */
@@ -4888,7 +4789,6 @@ function bindStore(view, store, selector) {
4888
4789
  registerViewClass,
4889
4790
  reloadViews,
4890
4791
  resetProjectsMap,
4891
- safeguard,
4892
4792
  unmark,
4893
4793
  use,
4894
4794
  useUrlState,
package/dist/index.d.cts CHANGED
@@ -63,26 +63,6 @@ declare function mark(host: object, key: string): () => boolean;
63
63
  */
64
64
  declare function unmark(host: object): void;
65
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
-
86
66
  /**
87
67
  * Multi-cast event emitter class.
88
68
  *
@@ -1454,17 +1434,9 @@ interface FrameworkInterface {
1454
1434
  getConfig<T = unknown>(key: string): T | undefined;
1455
1435
  /**
1456
1436
  * Merge a patch into the framework configuration and return the merged
1457
- * config object. Replaces the dual-purpose overload of `config()`.
1437
+ * config object.
1458
1438
  */
1459
1439
  setConfig<T extends object = Partial<FrameworkConfig>>(patch: Partial<FrameworkConfig> & T): FrameworkConfig & T;
1460
- /**
1461
- * @deprecated Use `getConfig()` / `getConfig(key)` for reads and
1462
- * `setConfig(patch)` for writes. The overloaded `config()` blurred the
1463
- * two and confused TypeScript inference; the split is a drop-in upgrade.
1464
- */
1465
- config<T extends object = Partial<FrameworkConfig>>(cfg?: Partial<FrameworkConfig> & T): FrameworkConfig & T;
1466
- /** @deprecated See above. */
1467
- config(key: string): unknown;
1468
1440
  /**
1469
1441
  * App initialization entry point, starts framework and renders root view.
1470
1442
  * After invocation: merge config → bind route events → create root Frame → mount default view.
@@ -1485,8 +1457,9 @@ interface FrameworkInterface {
1485
1457
  * @param fns Function or function array
1486
1458
  * @param args Arguments array passed to functions
1487
1459
  * @param context `this` binding during function execution
1460
+ * @param configError Optional error callback, receives the caught exception
1488
1461
  */
1489
- toTry(fns: AnyFunc | AnyFunc[], args?: unknown[], context?: unknown): unknown;
1462
+ toTry(fns: AnyFunc | AnyFunc[], args?: unknown[], context?: unknown, configError?: (e: unknown) => void): unknown;
1490
1463
  /**
1491
1464
  * Convert path and params to URL string.
1492
1465
  * Example: `Framework.toUrl('/xxx/', {a:'b',c:'d'})` => `/xxx/?a=b&c=d`
@@ -1506,7 +1479,7 @@ interface FrameworkInterface {
1506
1479
  * @param target Target object
1507
1480
  * @param sources One or more source objects
1508
1481
  */
1509
- mix<T extends object>(target: T, ...sources: Partial<T>[]): T;
1482
+ mix<T extends object>(target: T, ...sources: Record<string, unknown>[]): T;
1510
1483
  /**
1511
1484
  * Check if object has specified own property (safe hasOwnProperty).
1512
1485
  * @param owner Object to check, supports undefined/null
@@ -1543,13 +1516,6 @@ interface FrameworkInterface {
1543
1516
  * @param callback Callback after modules are loaded
1544
1517
  */
1545
1518
  use(names: string | string[], callback?: (...modules: unknown[]) => void): void;
1546
- /**
1547
- * Protect object from direct modification in debug mode.
1548
- * Wraps data object with Proxy, intercepts read/write operations, warns to use State.set/digest for state management.
1549
- * Only effective when `window.__lark_Debug` is true.
1550
- * @param o Object to protect
1551
- */
1552
- guard<T extends object>(o: T): T;
1553
1519
  /**
1554
1520
  * Dynamically inject CSS styles into page. Returns cleanup function to remove injected styles.
1555
1521
  * Supports single and batch injection.
@@ -1784,8 +1750,6 @@ interface CompileOptions {
1784
1750
  file?: string;
1785
1751
  /** Generate VDOM output instead of HTML string (default: false) */
1786
1752
  virtualDom?: boolean;
1787
- /** Use SWC instead of Babel for parsing (default: false) */
1788
- useSwc?: boolean;
1789
1753
  }
1790
1754
 
1791
1755
  /**
@@ -2330,4 +2294,4 @@ declare function create<T>(name: string, creator: StateCreator<T>): StoreApi<T>;
2330
2294
  */
2331
2295
  declare function bindStore<T>(view: unknown, store: StoreApi<T>, selector?: (state: T) => Record<string, unknown>): () => void;
2332
2296
 
2333
- 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, Framework, type FrameworkConfig, type FrameworkInterface, type HotContext, 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, Service, type ServiceCacheInfo, type ServiceEvent, type ServiceMetaEntry, type ServiceOptions, State, type StateInterface, type StoreApi, TAG_NAME_REGEXP, Updater, type UpdaterInterface, type VDomCreateFn, type VDomNode, type VDomRef, type VDomTemplate, 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, createVDomRef, defineView, config as frameworkConfig, getRouteMode, invalidateViewClass, mark, markBooted, markRouterBooted, nextCounter, registerViewClass, reloadViews, resetProjectsMap, safeguard, unmark, use, useUrlState, vdomCreate };
2297
+ 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, Framework, type FrameworkConfig, type FrameworkInterface, type HotContext, 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, Service, type ServiceCacheInfo, type ServiceEvent, type ServiceMetaEntry, type ServiceOptions, State, type StateInterface, type StoreApi, TAG_NAME_REGEXP, Updater, type UpdaterInterface, type VDomCreateFn, type VDomNode, type VDomRef, type VDomTemplate, 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, createVDomRef, defineView, config as frameworkConfig, getRouteMode, invalidateViewClass, mark, markBooted, markRouterBooted, nextCounter, registerViewClass, reloadViews, resetProjectsMap, unmark, use, useUrlState, vdomCreate };
package/dist/index.d.ts CHANGED
@@ -63,26 +63,6 @@ declare function mark(host: object, key: string): () => boolean;
63
63
  */
64
64
  declare function unmark(host: object): void;
65
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
-
86
66
  /**
87
67
  * Multi-cast event emitter class.
88
68
  *
@@ -1454,17 +1434,9 @@ interface FrameworkInterface {
1454
1434
  getConfig<T = unknown>(key: string): T | undefined;
1455
1435
  /**
1456
1436
  * Merge a patch into the framework configuration and return the merged
1457
- * config object. Replaces the dual-purpose overload of `config()`.
1437
+ * config object.
1458
1438
  */
1459
1439
  setConfig<T extends object = Partial<FrameworkConfig>>(patch: Partial<FrameworkConfig> & T): FrameworkConfig & T;
1460
- /**
1461
- * @deprecated Use `getConfig()` / `getConfig(key)` for reads and
1462
- * `setConfig(patch)` for writes. The overloaded `config()` blurred the
1463
- * two and confused TypeScript inference; the split is a drop-in upgrade.
1464
- */
1465
- config<T extends object = Partial<FrameworkConfig>>(cfg?: Partial<FrameworkConfig> & T): FrameworkConfig & T;
1466
- /** @deprecated See above. */
1467
- config(key: string): unknown;
1468
1440
  /**
1469
1441
  * App initialization entry point, starts framework and renders root view.
1470
1442
  * After invocation: merge config → bind route events → create root Frame → mount default view.
@@ -1485,8 +1457,9 @@ interface FrameworkInterface {
1485
1457
  * @param fns Function or function array
1486
1458
  * @param args Arguments array passed to functions
1487
1459
  * @param context `this` binding during function execution
1460
+ * @param configError Optional error callback, receives the caught exception
1488
1461
  */
1489
- toTry(fns: AnyFunc | AnyFunc[], args?: unknown[], context?: unknown): unknown;
1462
+ toTry(fns: AnyFunc | AnyFunc[], args?: unknown[], context?: unknown, configError?: (e: unknown) => void): unknown;
1490
1463
  /**
1491
1464
  * Convert path and params to URL string.
1492
1465
  * Example: `Framework.toUrl('/xxx/', {a:'b',c:'d'})` => `/xxx/?a=b&c=d`
@@ -1506,7 +1479,7 @@ interface FrameworkInterface {
1506
1479
  * @param target Target object
1507
1480
  * @param sources One or more source objects
1508
1481
  */
1509
- mix<T extends object>(target: T, ...sources: Partial<T>[]): T;
1482
+ mix<T extends object>(target: T, ...sources: Record<string, unknown>[]): T;
1510
1483
  /**
1511
1484
  * Check if object has specified own property (safe hasOwnProperty).
1512
1485
  * @param owner Object to check, supports undefined/null
@@ -1543,13 +1516,6 @@ interface FrameworkInterface {
1543
1516
  * @param callback Callback after modules are loaded
1544
1517
  */
1545
1518
  use(names: string | string[], callback?: (...modules: unknown[]) => void): void;
1546
- /**
1547
- * Protect object from direct modification in debug mode.
1548
- * Wraps data object with Proxy, intercepts read/write operations, warns to use State.set/digest for state management.
1549
- * Only effective when `window.__lark_Debug` is true.
1550
- * @param o Object to protect
1551
- */
1552
- guard<T extends object>(o: T): T;
1553
1519
  /**
1554
1520
  * Dynamically inject CSS styles into page. Returns cleanup function to remove injected styles.
1555
1521
  * Supports single and batch injection.
@@ -1784,8 +1750,6 @@ interface CompileOptions {
1784
1750
  file?: string;
1785
1751
  /** Generate VDOM output instead of HTML string (default: false) */
1786
1752
  virtualDom?: boolean;
1787
- /** Use SWC instead of Babel for parsing (default: false) */
1788
- useSwc?: boolean;
1789
1753
  }
1790
1754
 
1791
1755
  /**
@@ -2330,4 +2294,4 @@ declare function create<T>(name: string, creator: StateCreator<T>): StoreApi<T>;
2330
2294
  */
2331
2295
  declare function bindStore<T>(view: unknown, store: StoreApi<T>, selector?: (state: T) => Record<string, unknown>): () => void;
2332
2296
 
2333
- 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, Framework, type FrameworkConfig, type FrameworkInterface, type HotContext, 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, Service, type ServiceCacheInfo, type ServiceEvent, type ServiceMetaEntry, type ServiceOptions, State, type StateInterface, type StoreApi, TAG_NAME_REGEXP, Updater, type UpdaterInterface, type VDomCreateFn, type VDomNode, type VDomRef, type VDomTemplate, 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, createVDomRef, defineView, config as frameworkConfig, getRouteMode, invalidateViewClass, mark, markBooted, markRouterBooted, nextCounter, registerViewClass, reloadViews, resetProjectsMap, safeguard, unmark, use, useUrlState, vdomCreate };
2297
+ 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, Framework, type FrameworkConfig, type FrameworkInterface, type HotContext, 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, Service, type ServiceCacheInfo, type ServiceEvent, type ServiceMetaEntry, type ServiceOptions, State, type StateInterface, type StoreApi, TAG_NAME_REGEXP, Updater, type UpdaterInterface, type VDomCreateFn, type VDomNode, type VDomRef, type VDomTemplate, 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, createVDomRef, defineView, config as frameworkConfig, getRouteMode, invalidateViewClass, mark, markBooted, markRouterBooted, nextCounter, registerViewClass, reloadViews, resetProjectsMap, unmark, use, useUrlState, vdomCreate };