essor 0.0.17-beta.2 → 0.0.17-beta.3

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.
@@ -1,12 +1,12 @@
1
1
  /**
2
- * essor v0.0.17-beta.2
3
- * build time 2026-06-04T10:32:03.793Z
2
+ * essor v0.0.17-beta.3
3
+ * build time 2026-06-13T06:38:24.171Z
4
4
  * (c) 2023-Present jiangxd <jiangxd2016@gmail.com>
5
5
  * @license MIT
6
6
  **/
7
7
 
8
8
  // src/version.ts
9
- var __version = "0.0.17-beta.2";
9
+ var __version = "0.0.17-beta.3";
10
10
 
11
11
  // ../shared/dist/shared.dev.js
12
12
  var isObject = (val) => val !== null && typeof val === "object";
@@ -575,11 +575,6 @@ function createArrayInstrumentations() {
575
575
  const arr = toRaw(this);
576
576
  const isShallowMode = isShallow(this);
577
577
  track(arr, ARRAY_ITERATE_KEY);
578
- if (key === "toSpliced") {
579
- for (let i = 0, l = arr.length; i < l; i++) {
580
- track(arr, `${i}`);
581
- }
582
- }
583
578
  const res = Array.prototype[key].apply(arr, args);
584
579
  if (!Array.isArray(res)) {
585
580
  return res;
@@ -1419,39 +1414,39 @@ var EffectScope = class {
1419
1414
  this.detached = detached;
1420
1415
  this.parent = parent;
1421
1416
  this._active = true;
1422
- this.effects = [];
1423
- this.scopes = [];
1417
+ this.effects = /* @__PURE__ */ new Set();
1418
+ this.scopes = /* @__PURE__ */ new Set();
1424
1419
  this.cleanups = [];
1425
1420
  if (!detached && activeEffectScope) {
1426
1421
  this.parent = activeEffectScope;
1427
- activeEffectScope.scopes.push(this);
1422
+ activeEffectScope.scopes.add(this);
1428
1423
  }
1429
1424
  }
1430
1425
  get active() {
1431
1426
  return this._active;
1432
1427
  }
1433
1428
  pause() {
1434
- var _a52, _b2;
1429
+ var _a52;
1435
1430
  if (!this._active) {
1436
1431
  return;
1437
1432
  }
1438
- for (let i = 0; i < this.scopes.length; i++) {
1439
- this.scopes[i].pause();
1433
+ for (const scope of this.scopes) {
1434
+ scope.pause();
1440
1435
  }
1441
- for (let i = 0; i < this.effects.length; i++) {
1442
- (_b2 = (_a52 = this.effects[i]).pause) == null ? void 0 : _b2.call(_a52);
1436
+ for (const effect2 of this.effects) {
1437
+ (_a52 = effect2.pause) == null ? void 0 : _a52.call(effect2);
1443
1438
  }
1444
1439
  }
1445
1440
  resume() {
1446
- var _a52, _b2;
1441
+ var _a52;
1447
1442
  if (!this._active) {
1448
1443
  return;
1449
1444
  }
1450
- for (let i = 0; i < this.scopes.length; i++) {
1451
- this.scopes[i].resume();
1445
+ for (const scope of this.scopes) {
1446
+ scope.resume();
1452
1447
  }
1453
- for (let i = 0; i < this.effects.length; i++) {
1454
- (_b2 = (_a52 = this.effects[i]).resume) == null ? void 0 : _b2.call(_a52);
1448
+ for (const effect2 of this.effects) {
1449
+ (_a52 = effect2.resume) == null ? void 0 : _a52.call(effect2);
1455
1450
  }
1456
1451
  }
1457
1452
  run(fn) {
@@ -1474,12 +1469,12 @@ var EffectScope = class {
1474
1469
  return;
1475
1470
  }
1476
1471
  this._active = false;
1477
- for (let i = 0; i < this.scopes.length; i++) {
1478
- this.scopes[i].stop(true);
1472
+ for (const scope of this.scopes) {
1473
+ scope.stop(true);
1479
1474
  }
1480
- this.scopes.length = 0;
1481
- const effects = this.effects.slice();
1482
- this.effects.length = 0;
1475
+ this.scopes.clear();
1476
+ const effects = Array.from(this.effects);
1477
+ this.effects.clear();
1483
1478
  for (const effect2 of effects) {
1484
1479
  effect2.stop();
1485
1480
  }
@@ -1488,22 +1483,16 @@ var EffectScope = class {
1488
1483
  }
1489
1484
  this.cleanups.length = 0;
1490
1485
  if (!fromParent && this.parent) {
1491
- const index = this.parent.scopes.indexOf(this);
1492
- if (index >= 0) {
1493
- this.parent.scopes.splice(index, 1);
1494
- }
1486
+ this.parent.scopes.delete(this);
1495
1487
  }
1496
1488
  this.parent = void 0;
1497
1489
  }
1498
1490
  _record(effect2) {
1499
- this.effects.push(effect2);
1491
+ this.effects.add(effect2);
1500
1492
  effect2.scope = this;
1501
1493
  }
1502
1494
  _remove(effect2) {
1503
- const index = this.effects.indexOf(effect2);
1504
- if (index >= 0) {
1505
- this.effects.splice(index, 1);
1506
- }
1495
+ this.effects.delete(effect2);
1507
1496
  }
1508
1497
  _pushCleanup(fn) {
1509
1498
  this.cleanups.push(fn);
@@ -2031,64 +2020,45 @@ function createOptionsStore(options) {
2031
2020
  const reactiveState = reactive(state);
2032
2021
  const subscriptions = /* @__PURE__ */ new Set();
2033
2022
  const actionCallbacks = /* @__PURE__ */ new Set();
2034
- const notifySubscribers = (state2) => {
2023
+ const notify = (state2) => {
2035
2024
  subscriptions.forEach((callback) => callback(state2));
2036
2025
  actionCallbacks.forEach((callback) => callback(state2));
2037
2026
  };
2027
+ const addCallback = (set, callback, label) => {
2028
+ if (!callback) {
2029
+ warn(`${label} is required`);
2030
+ return () => {
2031
+ };
2032
+ }
2033
+ set.add(callback);
2034
+ return () => set.delete(callback);
2035
+ };
2036
+ const commit = (mutate) => {
2037
+ batch(mutate);
2038
+ notify(reactiveState);
2039
+ };
2038
2040
  const defaultActions = {
2039
- /**
2040
- * Applies a partial patch to the reactive store state.
2041
- */
2042
- patch$(payload) {
2041
+ $patch(payload) {
2043
2042
  if (!payload) {
2044
2043
  warn("Patch payload is required");
2045
2044
  return;
2046
2045
  }
2047
- batch(() => {
2048
- Object.assign(reactiveState, payload);
2049
- });
2050
- notifySubscribers(reactiveState);
2046
+ commit(() => Object.assign(reactiveState, payload));
2051
2047
  },
2052
- /**
2053
- * Registers a store subscriber callback.
2054
- */
2055
- subscribe$(callback) {
2056
- if (!callback) {
2057
- warn("Subscribe callback is required");
2058
- return;
2059
- }
2060
- subscriptions.add(callback);
2048
+ $subscribe(callback) {
2049
+ return addCallback(subscriptions, callback, "Subscribe callback");
2061
2050
  },
2062
- /**
2063
- * Removes a previously registered store subscriber.
2064
- */
2065
- unsubscribe$(callback) {
2051
+ $unsubscribe(callback) {
2066
2052
  subscriptions.delete(callback);
2067
2053
  },
2068
- /**
2069
- * Registers a callback for store action notifications.
2070
- */
2071
- onAction$(callback) {
2072
- if (!callback) {
2073
- warn("Action callback is required");
2074
- return;
2075
- }
2076
- actionCallbacks.add(callback);
2054
+ $onAction(callback) {
2055
+ return addCallback(actionCallbacks, callback, "Action callback");
2077
2056
  },
2078
- /**
2079
- * Removes a previously registered action callback.
2080
- */
2081
- offAction$(callback) {
2057
+ $offAction(callback) {
2082
2058
  actionCallbacks.delete(callback);
2083
2059
  },
2084
- /**
2085
- * Resets the reactive state back to its initial snapshot.
2086
- */
2087
- reset$() {
2088
- batch(() => {
2089
- Object.assign(reactiveState, initState);
2090
- });
2091
- notifySubscribers(reactiveState);
2060
+ $reset() {
2061
+ commit(() => Object.assign(reactiveState, initState));
2092
2062
  }
2093
2063
  };
2094
2064
  const store = {};
@@ -2369,7 +2339,7 @@ function watch(source, callback, options = {}) {
2369
2339
  return stop2;
2370
2340
  }
2371
2341
 
2372
- // ../template/dist/chunk-R6JICOKI.dev.js
2342
+ // ../template/dist/chunk-PYFF2HI3.dev.js
2373
2343
  var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
2374
2344
  var __hasOwnProp2 = Object.prototype.hasOwnProperty;
2375
2345
  var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
@@ -2458,6 +2428,10 @@ function disposeScope(scope) {
2458
2428
  return;
2459
2429
  }
2460
2430
  scope.isDestroyed = true;
2431
+ if ((_a6 = scope.parent) == null ? void 0 : _a6.children) {
2432
+ scope.parent.children.delete(scope);
2433
+ }
2434
+ scope.parent = null;
2461
2435
  if (scope.children && scope.children.size > 0) {
2462
2436
  for (const child2 of scope.children) {
2463
2437
  if (child2) {
@@ -2491,9 +2465,6 @@ function disposeScope(scope) {
2491
2465
  }
2492
2466
  setActiveScope(prevScope);
2493
2467
  scope.effectScope.stop();
2494
- if ((_a6 = scope.parent) == null ? void 0 : _a6.children) {
2495
- scope.parent.children.delete(scope);
2496
- }
2497
2468
  if (scope.provides) {
2498
2469
  scope.provides.clear();
2499
2470
  scope.provides = null;
@@ -2501,7 +2472,6 @@ function disposeScope(scope) {
2501
2472
  scope.onMount = null;
2502
2473
  scope.onUpdate = null;
2503
2474
  scope.children = null;
2504
- scope.parent = null;
2505
2475
  }
2506
2476
  function onCleanup(fn) {
2507
2477
  const scope = activeScope;
@@ -3436,6 +3406,7 @@ var Component = class {
3436
3406
  for (const key of Object.getOwnPropertyNames(this.reactiveProps)) {
3437
3407
  delete this.reactiveProps[key];
3438
3408
  }
3409
+ this.state = 0;
3439
3410
  }
3440
3411
  /**
3441
3412
  * Apply props that bind to the root DOM element rather than flowing into
@@ -3574,8 +3545,8 @@ function createApp(component, target) {
3574
3545
  return {
3575
3546
  root: rootNode,
3576
3547
  unmount: () => {
3577
- disposeScope(scope);
3578
3548
  rootNode == null ? void 0 : rootNode.destroy();
3549
+ disposeScope(scope);
3579
3550
  }
3580
3551
  };
3581
3552
  }
@@ -3607,8 +3578,8 @@ function hydrate(component, target) {
3607
3578
  return {
3608
3579
  root: rootNode,
3609
3580
  unmount: () => {
3610
- disposeScope(scope);
3611
3581
  rootNode == null ? void 0 : rootNode.destroy();
3582
+ disposeScope(scope);
3612
3583
  }
3613
3584
  };
3614
3585
  }
@@ -4318,6 +4289,7 @@ function defineClientAsyncComponent(loader, options) {
4318
4289
  };
4319
4290
  const render = (fn, fnProps) => {
4320
4291
  if (!alive) return;
4292
+ if (owner && owner.isDestroyed) return;
4321
4293
  if (viewScope) {
4322
4294
  disposeScope(viewScope);
4323
4295
  viewScope = null;
@@ -4433,9 +4405,7 @@ function For(props) {
4433
4405
  };
4434
4406
  const clearFallback = () => {
4435
4407
  for (const node of fallbackNodes) {
4436
- if (node.parentNode) {
4437
- node.parentNode.removeChild(node);
4438
- }
4408
+ removeNode(node);
4439
4409
  }
4440
4410
  fallbackNodes = [];
4441
4411
  };