essor 0.0.17-beta.3 → 0.0.17-beta.5

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.3
3
- * build time 2026-06-13T06:38:24.171Z
2
+ * essor v0.0.17-beta.5
3
+ * build time 2026-06-16T09:16:05.600Z
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.3";
9
+ var __version = "0.0.17-beta.5";
10
10
 
11
11
  // ../shared/dist/shared.dev.js
12
12
  var isObject = (val) => val !== null && typeof val === "object";
@@ -17,6 +17,9 @@ var isArray = Array.isArray;
17
17
  function isString(val) {
18
18
  return typeof val === "string";
19
19
  }
20
+ function isNumber(val) {
21
+ return typeof val === "number";
22
+ }
20
23
  function isSymbol(val) {
21
24
  return typeof val === "symbol";
22
25
  }
@@ -129,22 +132,6 @@ function normalizeClassName(classValue) {
129
132
  }
130
133
 
131
134
  // ../signals/dist/signals.dev.js
132
- var __defProp = Object.defineProperty;
133
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
134
- var __hasOwnProp = Object.prototype.hasOwnProperty;
135
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
136
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
137
- var __spreadValues = (a, b) => {
138
- for (var prop in b || (b = {}))
139
- if (__hasOwnProp.call(b, prop))
140
- __defNormalProp(a, prop, b[prop]);
141
- if (__getOwnPropSymbols)
142
- for (var prop of __getOwnPropSymbols(b)) {
143
- if (__propIsEnum.call(b, prop))
144
- __defNormalProp(a, prop, b[prop]);
145
- }
146
- return a;
147
- };
148
135
  var TriggerOpTypes = {
149
136
  SET: "SET",
150
137
  ADD: "ADD",
@@ -1053,11 +1040,12 @@ var objectHandlers = (shallow) => ({
1053
1040
  return valueUnwrapped;
1054
1041
  },
1055
1042
  set: (target, key, value, receiver) => {
1043
+ const hadKey = hasOwn(target, key);
1056
1044
  const oldValue = Reflect.get(target, key, receiver);
1057
1045
  const rawValue = toRaw(value);
1058
1046
  const result = Reflect.set(target, key, rawValue, receiver);
1059
1047
  if (hasStoredValueChanged(rawValue, oldValue)) {
1060
- trigger(target, TriggerOpTypes.SET, key, rawValue);
1048
+ trigger(target, hadKey ? TriggerOpTypes.SET : TriggerOpTypes.ADD, key, rawValue);
1061
1049
  }
1062
1050
  return result;
1063
1051
  },
@@ -1068,6 +1056,10 @@ var objectHandlers = (shallow) => ({
1068
1056
  trigger(target, TriggerOpTypes.DELETE, key, void 0);
1069
1057
  }
1070
1058
  return result;
1059
+ },
1060
+ ownKeys: (target) => {
1061
+ track(target, ITERATE_KEY);
1062
+ return Reflect.ownKeys(target);
1071
1063
  }
1072
1064
  });
1073
1065
  var shallowObjectHandlers = objectHandlers(true);
@@ -1808,7 +1800,6 @@ var ComputedImpl = class {
1808
1800
  this.setter = setter;
1809
1801
  this.onTrack = onTrack;
1810
1802
  this.onTrigger = onTrigger;
1811
- this.flag |= 16;
1812
1803
  recordDisposable(this);
1813
1804
  }
1814
1805
  /**
@@ -2010,13 +2001,61 @@ function isComputed(value) {
2010
2001
  /* IS_COMPUTED */
2011
2002
  ];
2012
2003
  }
2004
+ function cloneInitialState(value, seen = /* @__PURE__ */ new WeakMap()) {
2005
+ if (!isObject(value)) {
2006
+ return value;
2007
+ }
2008
+ if (seen.has(value)) {
2009
+ return seen.get(value);
2010
+ }
2011
+ if (value instanceof Date) {
2012
+ return new Date(value.getTime());
2013
+ }
2014
+ if (value instanceof RegExp) {
2015
+ return new RegExp(value.source, value.flags);
2016
+ }
2017
+ if (value instanceof Map) {
2018
+ const clone2 = /* @__PURE__ */ new Map();
2019
+ seen.set(value, clone2);
2020
+ value.forEach((mapValue, mapKey) => {
2021
+ clone2.set(cloneInitialState(mapKey, seen), cloneInitialState(mapValue, seen));
2022
+ });
2023
+ return clone2;
2024
+ }
2025
+ if (value instanceof Set) {
2026
+ const clone2 = /* @__PURE__ */ new Set();
2027
+ seen.set(value, clone2);
2028
+ value.forEach((setValue) => {
2029
+ clone2.add(cloneInitialState(setValue, seen));
2030
+ });
2031
+ return clone2;
2032
+ }
2033
+ if (Array.isArray(value)) {
2034
+ const clone2 = [];
2035
+ seen.set(value, clone2);
2036
+ value.forEach((item, index) => {
2037
+ clone2[index] = cloneInitialState(item, seen);
2038
+ });
2039
+ return clone2;
2040
+ }
2041
+ const prototype = Object.getPrototypeOf(value);
2042
+ if (prototype !== Object.prototype && prototype !== null) {
2043
+ return value;
2044
+ }
2045
+ const clone = Object.create(prototype);
2046
+ seen.set(value, clone);
2047
+ for (const key of Reflect.ownKeys(value)) {
2048
+ clone[key] = cloneInitialState(value[key], seen);
2049
+ }
2050
+ return clone;
2051
+ }
2013
2052
  function createOptionsStore(options) {
2014
2053
  if (!options.state) {
2015
2054
  warn("Store state is required");
2016
2055
  throw new Error("Store state is required");
2017
2056
  }
2018
2057
  const { state, getters, actions } = options;
2019
- const initState = __spreadValues({}, state);
2058
+ const initState = cloneInitialState(state);
2020
2059
  const reactiveState = reactive(state);
2021
2060
  const subscriptions = /* @__PURE__ */ new Set();
2022
2061
  const actionCallbacks = /* @__PURE__ */ new Set();
@@ -2340,17 +2379,17 @@ function watch(source, callback, options = {}) {
2340
2379
  }
2341
2380
 
2342
2381
  // ../template/dist/chunk-PYFF2HI3.dev.js
2343
- var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
2344
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
2345
- var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
2382
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
2383
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
2384
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
2346
2385
  var __objRest = (source, exclude) => {
2347
2386
  var target = {};
2348
2387
  for (var prop in source)
2349
- if (__hasOwnProp2.call(source, prop) && exclude.indexOf(prop) < 0)
2388
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
2350
2389
  target[prop] = source[prop];
2351
- if (source != null && __getOwnPropSymbols2)
2352
- for (var prop of __getOwnPropSymbols2(source)) {
2353
- if (exclude.indexOf(prop) < 0 && __propIsEnum2.call(source, prop))
2390
+ if (source != null && __getOwnPropSymbols)
2391
+ for (var prop of __getOwnPropSymbols(source)) {
2392
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
2354
2393
  target[prop] = source[prop];
2355
2394
  }
2356
2395
  return target;
@@ -2634,6 +2673,7 @@ function patchClass(el, prev, next2, isSVG = false) {
2634
2673
  }
2635
2674
  var normalizeClass = normalizeClassName;
2636
2675
  var importantRE = /\s*!important$/;
2676
+ var styleDeclRE = /(?:^|;)\s*([a-z][a-z\d-]*)\s*:/gi;
2637
2677
  var prefixes = ["Webkit", "Moz", "ms"];
2638
2678
  var prefixCache = {};
2639
2679
  function patchStyle(el, prev, next2) {
@@ -2658,9 +2698,9 @@ function patchStyle(el, prev, next2) {
2658
2698
  }
2659
2699
  }
2660
2700
  } else if (prev && isString(prev)) {
2661
- const declRE = /(?:^|;)\s*([a-z][a-z\d-]*)\s*:/gi;
2701
+ styleDeclRE.lastIndex = 0;
2662
2702
  let match;
2663
- while ((match = declRE.exec(prev)) !== null) {
2703
+ while ((match = styleDeclRE.exec(prev)) !== null) {
2664
2704
  const key = match[1].trim();
2665
2705
  if (key && next2 && isObject(next2) && next2[key] == null) {
2666
2706
  setStyle(style, key, "");
@@ -2853,23 +2893,31 @@ function resolveHydrationKey(parent) {
2853
2893
  const el = parent;
2854
2894
  return (_c = (_b2 = el.dataset.hk) != null ? _b2 : (_a22 = parent.closest("[data-hk]")) == null ? void 0 : _a22.dataset.hk) != null ? _c : null;
2855
2895
  }
2896
+ function expectedHydrationSlot(parent, index) {
2897
+ if (_isHydrating && parent) {
2898
+ const key = resolveHydrationKey(parent);
2899
+ if (key) return `${key}-${index}`;
2900
+ }
2901
+ return String(index);
2902
+ }
2856
2903
  function hydrationMarker(parent, index) {
2857
- if (!_isHydrating || !parent || index < 0) return null;
2858
- const key = parent instanceof Element ? resolveHydrationKey(parent) : null;
2859
- const expected = key ? `${key}-${index}` : String(index);
2904
+ if (!parent || index < 0) return null;
2905
+ const expected = expectedHydrationSlot(parent instanceof Element ? parent : null, index);
2906
+ let fallbackIndex = 0;
2860
2907
  let cursor = parent.firstChild;
2861
2908
  while (cursor) {
2862
- if (cursor.nodeType === Node.COMMENT_NODE && cursor.data === expected) {
2863
- return cursor;
2909
+ if (cursor.nodeType === Node.COMMENT_NODE) {
2910
+ const comment = cursor;
2911
+ if (comment.data === expected) return comment;
2912
+ if (!_isHydrating && comment.data === "" && fallbackIndex++ === index) return comment;
2864
2913
  }
2865
2914
  cursor = cursor.nextSibling;
2866
2915
  }
2867
2916
  return null;
2868
2917
  }
2869
2918
  function hydrationAnchor(parent, index) {
2870
- if (!_isHydrating || !(parent instanceof Element) || index < 0) return null;
2871
- const key = resolveHydrationKey(parent);
2872
- const expected = key ? `${key}-${index}` : String(index);
2919
+ if (!(parent instanceof Element) || index < 0) return null;
2920
+ const expected = expectedHydrationSlot(parent, index);
2873
2921
  let cursor = parent.firstChild;
2874
2922
  while (cursor) {
2875
2923
  if (cursor instanceof Element && cursor.getAttribute(HYDRATION_ANCHOR_ATTR) === expected) {
@@ -3117,7 +3165,7 @@ function normalizeNode(node) {
3117
3165
  }
3118
3166
  function insert(parent, nodeFactory, before) {
3119
3167
  if (!parent) return;
3120
- const parentScope = getActiveScope();
3168
+ let parentScope = getActiveScope();
3121
3169
  let renderedNodes = [];
3122
3170
  let isFirstRun = true;
3123
3171
  const resolveNodes = (raw) => {
@@ -3159,6 +3207,7 @@ function insert(parent, nodeFactory, before) {
3159
3207
  effectRunner.stop();
3160
3208
  for (const node of renderedNodes) removeNode(node);
3161
3209
  renderedNodes = [];
3210
+ parentScope = null;
3162
3211
  });
3163
3212
  return renderedNodes;
3164
3213
  }
@@ -3292,9 +3341,9 @@ function syncDescriptors(target, source, pruneMissing = false) {
3292
3341
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
3293
3342
  }
3294
3343
  if (pruneMissing) {
3295
- const sourceKeys = Object.getOwnPropertyNames(source);
3344
+ const sourceKeySet = new Set(Object.getOwnPropertyNames(source));
3296
3345
  for (const key of Object.getOwnPropertyNames(target)) {
3297
- if (!sourceKeys.includes(key)) delete target[key];
3346
+ if (!sourceKeySet.has(key)) delete target[key];
3298
3347
  }
3299
3348
  }
3300
3349
  }
@@ -3858,7 +3907,7 @@ function bindElement(node, prop, getter, setter, modifiers = {}) {
3858
3907
  function unwrapSlotValue(raw) {
3859
3908
  let v = raw;
3860
3909
  if (Array.isArray(v) && v.length === 1) v = v[0];
3861
- return typeof v === "function" ? v() : v;
3910
+ return isFunction(v) ? v() : v;
3862
3911
  }
3863
3912
  function useChildren(props) {
3864
3913
  const desc = Object.getOwnPropertyDescriptor(props, "children");
@@ -4176,49 +4225,50 @@ function createResource(fetcher, options) {
4176
4225
  const error4 = signal(null);
4177
4226
  const state = signal("pending");
4178
4227
  let fetchId = 0;
4179
- let currentPromise = null;
4180
- let suspenseRegistered = false;
4228
+ let controller = null;
4181
4229
  const suspenseContext = inject(SuspenseContext, null);
4182
- const fetch = () => __async(null, null, function* () {
4183
- const currentFetchId = ++fetchId;
4230
+ const doFetch = () => __async(null, null, function* () {
4231
+ const id = ++fetchId;
4232
+ controller == null ? void 0 : controller.abort();
4233
+ controller = new AbortController();
4184
4234
  loading.value = true;
4185
4235
  state.value = "pending";
4186
4236
  error4.value = null;
4187
- suspenseRegistered = false;
4188
- if (suspenseContext) {
4189
- suspenseContext.increment();
4237
+ let promise;
4238
+ try {
4239
+ promise = Promise.resolve(fetcher(controller.signal));
4240
+ } catch (error_) {
4241
+ error4.value = error_ instanceof Error ? error_ : new Error(String(error_));
4242
+ state.value = "errored";
4243
+ loading.value = false;
4244
+ return;
4190
4245
  }
4246
+ suspenseContext == null ? void 0 : suspenseContext.register(promise);
4191
4247
  try {
4192
- const promise = fetcher();
4193
- currentPromise = promise;
4194
- promise.catch(() => {
4195
- });
4196
4248
  const result = yield promise;
4197
- if (currentFetchId === fetchId) {
4249
+ if (id === fetchId) {
4198
4250
  value.value = result;
4199
4251
  state.value = "ready";
4200
4252
  loading.value = false;
4201
4253
  }
4202
4254
  } catch (error_) {
4203
- if (currentFetchId === fetchId) {
4204
- error4.value = error_ instanceof Error ? error_ : new Error(String(error_));
4205
- state.value = "errored";
4255
+ if (id !== fetchId) return;
4256
+ if (error_ instanceof DOMException && error_.name === "AbortError") {
4206
4257
  loading.value = false;
4258
+ return;
4207
4259
  }
4208
- } finally {
4209
- if (suspenseContext) {
4210
- suspenseContext.decrement();
4211
- }
4260
+ error4.value = error_ instanceof Error ? error_ : new Error(String(error_));
4261
+ state.value = "errored";
4262
+ loading.value = false;
4212
4263
  }
4213
4264
  });
4214
- fetch();
4215
- const resource = (() => {
4216
- if (!suspenseRegistered && loading.value && currentPromise && suspenseContext) {
4217
- suspenseRegistered = true;
4218
- suspenseContext.register(currentPromise);
4219
- }
4220
- return value.value;
4265
+ doFetch();
4266
+ onCleanup(() => {
4267
+ fetchId++;
4268
+ controller == null ? void 0 : controller.abort();
4269
+ controller = null;
4221
4270
  });
4271
+ const resource = (() => value.value);
4222
4272
  resource.loading = loading;
4223
4273
  resource.error = error4;
4224
4274
  resource.state = state;
@@ -4229,9 +4279,7 @@ function createResource(fetcher, options) {
4229
4279
  loading.value = false;
4230
4280
  error4.value = null;
4231
4281
  },
4232
- refetch: () => __async(null, null, function* () {
4233
- yield fetch();
4234
- })
4282
+ refetch: () => doFetch()
4235
4283
  };
4236
4284
  return [resource, actions];
4237
4285
  }
@@ -4415,9 +4463,14 @@ function For(props) {
4415
4463
  const parentScope = (_a22 = getActiveScope()) != null ? _a22 : ownerScope;
4416
4464
  const scope = createScope(parentScope);
4417
4465
  let mountedNodes = [];
4418
- runWithScope(scope, () => {
4419
- mountedNodes = mountValue(renderFn(item, index), parent, before);
4420
- });
4466
+ try {
4467
+ runWithScope(scope, () => {
4468
+ mountedNodes = mountValue(renderFn(item, index), parent, before);
4469
+ });
4470
+ } catch (error4) {
4471
+ disposeScope(scope);
4472
+ throw error4;
4473
+ }
4421
4474
  return { key, item, nodes: mountedNodes, scope };
4422
4475
  };
4423
4476
  const disposeItem = (entry) => {
@@ -4618,16 +4671,17 @@ function whenTransitionEnds(el, type, explicit, resolve2) {
4618
4671
  const finish = () => {
4619
4672
  if (done) return;
4620
4673
  done = true;
4674
+ clearTimeout(timer);
4621
4675
  el.removeEventListener(info.event, onEnd);
4622
4676
  resolve2();
4623
4677
  };
4624
4678
  const onEnd = () => finish();
4625
4679
  el.addEventListener(info.event, onEnd);
4626
- setTimeout(finish, info.timeout + 1);
4680
+ const timer = setTimeout(finish, info.timeout + 1);
4627
4681
  }
4628
4682
  function resolveDuration(d, dir) {
4629
4683
  if (d == null) return null;
4630
- if (typeof d === "number") return d;
4684
+ if (isNumber(d)) return d;
4631
4685
  return d[dir];
4632
4686
  }
4633
4687
  function validateSlot(value) {
@@ -4944,9 +4998,14 @@ function TransitionGroup(props) {
4944
4998
  const parentScope = getActiveScope();
4945
4999
  const scope = createScope(parentScope);
4946
5000
  let raw;
4947
- runWithScope(scope, () => {
4948
- raw = childrenFn(item, index);
4949
- });
5001
+ try {
5002
+ runWithScope(scope, () => {
5003
+ raw = childrenFn(item, index);
5004
+ });
5005
+ } catch (error4) {
5006
+ disposeScope(scope);
5007
+ throw error4;
5008
+ }
4950
5009
  const { el, comp } = resolveItemElement(raw, wrapper);
4951
5010
  if (!el) {
4952
5011
  disposeScope(scope);