@fluixi/reactive 1.0.0-alpha.84 → 1.0.0-alpha.86

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.
Files changed (70) hide show
  1. package/dist/cdn/reactive.cjs +52 -3
  2. package/dist/cdn/reactive.global.js +2 -2
  3. package/dist/cdn/reactive.mjs +52 -3
  4. package/dist/cdn/signal.cjs +1 -1
  5. package/dist/cdn/signal.global.js +2 -2
  6. package/dist/cdn/signal.mjs +1 -1
  7. package/dist/index.cjs +52 -3
  8. package/dist/index.mjs +52 -3
  9. package/dist/lib/index.cjs +53 -4
  10. package/dist/lib/index.mjs +53 -4
  11. package/dist/lib/observable/index.cjs +1 -1
  12. package/dist/lib/observable/index.mjs +1 -1
  13. package/dist/lib/signal/api.cjs +1 -1
  14. package/dist/lib/signal/api.mjs +1 -1
  15. package/dist/lib/signal/cached-resource.cjs +2 -2
  16. package/dist/lib/signal/cached-resource.mjs +2 -2
  17. package/dist/lib/signal/graph/children.cjs +1 -1
  18. package/dist/lib/signal/graph/children.mjs +1 -1
  19. package/dist/lib/signal/graph/compat.cjs +2 -2
  20. package/dist/lib/signal/graph/compat.mjs +2 -2
  21. package/dist/lib/signal/graph/core.cjs +2 -2
  22. package/dist/lib/signal/graph/core.mjs +2 -2
  23. package/dist/lib/signal/graph/debounced.cjs +1 -1
  24. package/dist/lib/signal/graph/debounced.mjs +1 -1
  25. package/dist/lib/signal/graph/derived.cjs +1 -1
  26. package/dist/lib/signal/graph/derived.mjs +1 -1
  27. package/dist/lib/signal/graph/error-boundary.cjs +1 -1
  28. package/dist/lib/signal/graph/error-boundary.mjs +1 -1
  29. package/dist/lib/signal/graph/index.cjs +2 -2
  30. package/dist/lib/signal/graph/index.mjs +2 -2
  31. package/dist/lib/signal/graph/observe.cjs +1 -1
  32. package/dist/lib/signal/graph/observe.mjs +1 -1
  33. package/dist/lib/signal/graph/resource.cjs +1 -1
  34. package/dist/lib/signal/graph/resource.mjs +1 -1
  35. package/dist/lib/signal/graph/runtime.cjs +1 -1
  36. package/dist/lib/signal/graph/runtime.mjs +1 -1
  37. package/dist/lib/signal/graph/signal-next.cjs +2 -2
  38. package/dist/lib/signal/graph/signal-next.mjs +2 -2
  39. package/dist/lib/signal/graph/state.cjs +1 -1
  40. package/dist/lib/signal/graph/state.mjs +1 -1
  41. package/dist/lib/signal/graph/suspense.cjs +1 -1
  42. package/dist/lib/signal/graph/suspense.mjs +1 -1
  43. package/dist/lib/signal/index-legacy.cjs +2 -2
  44. package/dist/lib/signal/index-legacy.mjs +2 -2
  45. package/dist/lib/signal/index.cjs +2 -2
  46. package/dist/lib/signal/index.mjs +2 -2
  47. package/dist/lib/signal/list.cjs +1 -1
  48. package/dist/lib/signal/list.mjs +1 -1
  49. package/dist/lib/signal/resource-api.cjs +1 -1
  50. package/dist/lib/signal/resource-api.d.ts +14 -22
  51. package/dist/lib/signal/resource-api.d.ts.map +1 -1
  52. package/dist/lib/signal/resource-api.mjs +1 -1
  53. package/dist/lib/signal/signal.cjs +1 -1
  54. package/dist/lib/signal/signal.mjs +1 -1
  55. package/dist/lib/signal/utilities.cjs +2 -2
  56. package/dist/lib/signal/utilities.mjs +2 -2
  57. package/dist/lib/store/api.cjs +52 -3
  58. package/dist/lib/store/api.mjs +52 -3
  59. package/dist/lib/store/index.cjs +53 -4
  60. package/dist/lib/store/index.mjs +53 -4
  61. package/dist/lib/store/store.cjs +52 -3
  62. package/dist/lib/store/store.d.ts.map +1 -1
  63. package/dist/lib/store/store.js +90 -3
  64. package/dist/lib/store/store.mjs +52 -3
  65. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  66. package/dist/version.generated.cjs +2 -2
  67. package/dist/version.generated.d.ts +1 -1
  68. package/dist/version.generated.js +1 -1
  69. package/dist/version.generated.mjs +2 -2
  70. package/package.json +2 -2
@@ -28,7 +28,7 @@ module.exports = __toCommonJS(api_exports);
28
28
  var import_signal = require("@fluixi/reactive/signal");
29
29
 
30
30
  // src/version.generated.ts
31
- var VERSION = "1.0.0-alpha.84";
31
+ var VERSION = "1.0.0-alpha.86";
32
32
 
33
33
  // src/lib/signal/graph/state.ts
34
34
  var MAJOR = VERSION.split(".")[0];
@@ -373,12 +373,61 @@ function applySet(root, args) {
373
373
  mergeInto(root, first);
374
374
  return;
375
375
  }
376
- if (Array.isArray(args[1]) && args.length >= 3) {
377
- applyPath(root, `${first}.${args[1].join(".")}`, args[2]);
376
+ if (args.length >= 3) {
377
+ setDeep(root, args.slice(0, -1), args[args.length - 1]);
378
378
  return;
379
379
  }
380
380
  applyPath(root, String(first), args[1]);
381
381
  }
382
+ function selectKeys(current, selector) {
383
+ if (typeof selector === "function") {
384
+ if (!Array.isArray(current)) return [];
385
+ const keys = [];
386
+ for (let i = 0; i < current.length; i++) if (selector(current[i], i)) keys.push(i);
387
+ return keys;
388
+ }
389
+ if (Array.isArray(selector)) {
390
+ return Array.isArray(current) ? selector.map(Number) : selector.map(String);
391
+ }
392
+ if (selector && typeof selector === "object" && ("from" in selector || "to" in selector || "by" in selector)) {
393
+ if (!Array.isArray(current)) return [];
394
+ const by = selector.by ?? 1;
395
+ const from = selector.from ?? 0;
396
+ const to = selector.to ?? current.length - 1;
397
+ const keys = [];
398
+ for (let i = from; i <= to; i += by) if (i >= 0 && i < current.length) keys.push(i);
399
+ return keys;
400
+ }
401
+ if (selector === "*") {
402
+ return Array.isArray(current) ? current.map((_, i) => i) : Object.keys(current ?? {});
403
+ }
404
+ return [selector];
405
+ }
406
+ function setDeep(current, selectors, value) {
407
+ if (current == null) return;
408
+ const [head, ...rest] = selectors;
409
+ if (typeof head === "string") {
410
+ const parts = parsePath(head);
411
+ if (parts.length > 1) {
412
+ setDeep(current, [...parts, ...rest], value);
413
+ return;
414
+ }
415
+ }
416
+ const keys = selectKeys(current, head);
417
+ if (rest.length === 0) {
418
+ for (const key of keys) writeKey(current, key, nextValue(value, current[key]));
419
+ return;
420
+ }
421
+ for (const key of keys) {
422
+ let next = current[key];
423
+ if (next == null || typeof next !== "object") {
424
+ const lookahead = rest[0];
425
+ next = typeof lookahead === "number" || /^\d+$/.test(String(lookahead)) ? [] : {};
426
+ writeKey(current, key, next);
427
+ }
428
+ setDeep(next, rest, value);
429
+ }
430
+ }
382
431
  function clone(value) {
383
432
  if (value == null || typeof value !== "object") return value;
384
433
  if (Array.isArray(value)) return value.map(clone);
@@ -9,7 +9,7 @@ import {
9
9
  } from "@fluixi/reactive/signal";
10
10
 
11
11
  // src/version.generated.ts
12
- var VERSION = "1.0.0-alpha.84";
12
+ var VERSION = "1.0.0-alpha.86";
13
13
 
14
14
  // src/lib/signal/graph/state.ts
15
15
  var MAJOR = VERSION.split(".")[0];
@@ -354,12 +354,61 @@ function applySet(root, args) {
354
354
  mergeInto(root, first);
355
355
  return;
356
356
  }
357
- if (Array.isArray(args[1]) && args.length >= 3) {
358
- applyPath(root, `${first}.${args[1].join(".")}`, args[2]);
357
+ if (args.length >= 3) {
358
+ setDeep(root, args.slice(0, -1), args[args.length - 1]);
359
359
  return;
360
360
  }
361
361
  applyPath(root, String(first), args[1]);
362
362
  }
363
+ function selectKeys(current, selector) {
364
+ if (typeof selector === "function") {
365
+ if (!Array.isArray(current)) return [];
366
+ const keys = [];
367
+ for (let i = 0; i < current.length; i++) if (selector(current[i], i)) keys.push(i);
368
+ return keys;
369
+ }
370
+ if (Array.isArray(selector)) {
371
+ return Array.isArray(current) ? selector.map(Number) : selector.map(String);
372
+ }
373
+ if (selector && typeof selector === "object" && ("from" in selector || "to" in selector || "by" in selector)) {
374
+ if (!Array.isArray(current)) return [];
375
+ const by = selector.by ?? 1;
376
+ const from = selector.from ?? 0;
377
+ const to = selector.to ?? current.length - 1;
378
+ const keys = [];
379
+ for (let i = from; i <= to; i += by) if (i >= 0 && i < current.length) keys.push(i);
380
+ return keys;
381
+ }
382
+ if (selector === "*") {
383
+ return Array.isArray(current) ? current.map((_, i) => i) : Object.keys(current ?? {});
384
+ }
385
+ return [selector];
386
+ }
387
+ function setDeep(current, selectors, value) {
388
+ if (current == null) return;
389
+ const [head, ...rest] = selectors;
390
+ if (typeof head === "string") {
391
+ const parts = parsePath(head);
392
+ if (parts.length > 1) {
393
+ setDeep(current, [...parts, ...rest], value);
394
+ return;
395
+ }
396
+ }
397
+ const keys = selectKeys(current, head);
398
+ if (rest.length === 0) {
399
+ for (const key of keys) writeKey(current, key, nextValue(value, current[key]));
400
+ return;
401
+ }
402
+ for (const key of keys) {
403
+ let next = current[key];
404
+ if (next == null || typeof next !== "object") {
405
+ const lookahead = rest[0];
406
+ next = typeof lookahead === "number" || /^\d+$/.test(String(lookahead)) ? [] : {};
407
+ writeKey(current, key, next);
408
+ }
409
+ setDeep(next, rest, value);
410
+ }
411
+ }
363
412
  function clone(value) {
364
413
  if (value == null || typeof value !== "object") return value;
365
414
  if (Array.isArray(value)) return value.map(clone);
@@ -1,4 +1,4 @@
1
- /*! @fluixi/reactive v1.0.0-alpha.84 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
1
+ /*! @fluixi/reactive v1.0.0-alpha.86 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
2
  "use strict";
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -52,7 +52,7 @@ module.exports = __toCommonJS(index_exports);
52
52
  var import_signal = require("@fluixi/reactive/signal");
53
53
 
54
54
  // src/version.generated.ts
55
- var VERSION = "1.0.0-alpha.84";
55
+ var VERSION = "1.0.0-alpha.86";
56
56
 
57
57
  // src/lib/signal/graph/state.ts
58
58
  var MAJOR = VERSION.split(".")[0];
@@ -399,12 +399,61 @@ function applySet(root, args) {
399
399
  mergeInto(root, first);
400
400
  return;
401
401
  }
402
- if (Array.isArray(args[1]) && args.length >= 3) {
403
- applyPath(root, `${first}.${args[1].join(".")}`, args[2]);
402
+ if (args.length >= 3) {
403
+ setDeep(root, args.slice(0, -1), args[args.length - 1]);
404
404
  return;
405
405
  }
406
406
  applyPath(root, String(first), args[1]);
407
407
  }
408
+ function selectKeys(current, selector) {
409
+ if (typeof selector === "function") {
410
+ if (!Array.isArray(current)) return [];
411
+ const keys = [];
412
+ for (let i = 0; i < current.length; i++) if (selector(current[i], i)) keys.push(i);
413
+ return keys;
414
+ }
415
+ if (Array.isArray(selector)) {
416
+ return Array.isArray(current) ? selector.map(Number) : selector.map(String);
417
+ }
418
+ if (selector && typeof selector === "object" && ("from" in selector || "to" in selector || "by" in selector)) {
419
+ if (!Array.isArray(current)) return [];
420
+ const by = selector.by ?? 1;
421
+ const from = selector.from ?? 0;
422
+ const to = selector.to ?? current.length - 1;
423
+ const keys = [];
424
+ for (let i = from; i <= to; i += by) if (i >= 0 && i < current.length) keys.push(i);
425
+ return keys;
426
+ }
427
+ if (selector === "*") {
428
+ return Array.isArray(current) ? current.map((_, i) => i) : Object.keys(current ?? {});
429
+ }
430
+ return [selector];
431
+ }
432
+ function setDeep(current, selectors, value) {
433
+ if (current == null) return;
434
+ const [head, ...rest] = selectors;
435
+ if (typeof head === "string") {
436
+ const parts = parsePath(head);
437
+ if (parts.length > 1) {
438
+ setDeep(current, [...parts, ...rest], value);
439
+ return;
440
+ }
441
+ }
442
+ const keys = selectKeys(current, head);
443
+ if (rest.length === 0) {
444
+ for (const key of keys) writeKey(current, key, nextValue(value, current[key]));
445
+ return;
446
+ }
447
+ for (const key of keys) {
448
+ let next = current[key];
449
+ if (next == null || typeof next !== "object") {
450
+ const lookahead = rest[0];
451
+ next = typeof lookahead === "number" || /^\d+$/.test(String(lookahead)) ? [] : {};
452
+ writeKey(current, key, next);
453
+ }
454
+ setDeep(next, rest, value);
455
+ }
456
+ }
408
457
  function clone(value) {
409
458
  if (value == null || typeof value !== "object") return value;
410
459
  if (Array.isArray(value)) return value.map(clone);
@@ -1,4 +1,4 @@
1
- /*! @fluixi/reactive v1.0.0-alpha.84 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
1
+ /*! @fluixi/reactive v1.0.0-alpha.86 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
2
 
3
3
  // src/lib/store/store.ts
4
4
  import {
@@ -11,7 +11,7 @@ import {
11
11
  } from "@fluixi/reactive/signal";
12
12
 
13
13
  // src/version.generated.ts
14
- var VERSION = "1.0.0-alpha.84";
14
+ var VERSION = "1.0.0-alpha.86";
15
15
 
16
16
  // src/lib/signal/graph/state.ts
17
17
  var MAJOR = VERSION.split(".")[0];
@@ -358,12 +358,61 @@ function applySet(root, args) {
358
358
  mergeInto(root, first);
359
359
  return;
360
360
  }
361
- if (Array.isArray(args[1]) && args.length >= 3) {
362
- applyPath(root, `${first}.${args[1].join(".")}`, args[2]);
361
+ if (args.length >= 3) {
362
+ setDeep(root, args.slice(0, -1), args[args.length - 1]);
363
363
  return;
364
364
  }
365
365
  applyPath(root, String(first), args[1]);
366
366
  }
367
+ function selectKeys(current, selector) {
368
+ if (typeof selector === "function") {
369
+ if (!Array.isArray(current)) return [];
370
+ const keys = [];
371
+ for (let i = 0; i < current.length; i++) if (selector(current[i], i)) keys.push(i);
372
+ return keys;
373
+ }
374
+ if (Array.isArray(selector)) {
375
+ return Array.isArray(current) ? selector.map(Number) : selector.map(String);
376
+ }
377
+ if (selector && typeof selector === "object" && ("from" in selector || "to" in selector || "by" in selector)) {
378
+ if (!Array.isArray(current)) return [];
379
+ const by = selector.by ?? 1;
380
+ const from = selector.from ?? 0;
381
+ const to = selector.to ?? current.length - 1;
382
+ const keys = [];
383
+ for (let i = from; i <= to; i += by) if (i >= 0 && i < current.length) keys.push(i);
384
+ return keys;
385
+ }
386
+ if (selector === "*") {
387
+ return Array.isArray(current) ? current.map((_, i) => i) : Object.keys(current ?? {});
388
+ }
389
+ return [selector];
390
+ }
391
+ function setDeep(current, selectors, value) {
392
+ if (current == null) return;
393
+ const [head, ...rest] = selectors;
394
+ if (typeof head === "string") {
395
+ const parts = parsePath(head);
396
+ if (parts.length > 1) {
397
+ setDeep(current, [...parts, ...rest], value);
398
+ return;
399
+ }
400
+ }
401
+ const keys = selectKeys(current, head);
402
+ if (rest.length === 0) {
403
+ for (const key of keys) writeKey(current, key, nextValue(value, current[key]));
404
+ return;
405
+ }
406
+ for (const key of keys) {
407
+ let next = current[key];
408
+ if (next == null || typeof next !== "object") {
409
+ const lookahead = rest[0];
410
+ next = typeof lookahead === "number" || /^\d+$/.test(String(lookahead)) ? [] : {};
411
+ writeKey(current, key, next);
412
+ }
413
+ setDeep(next, rest, value);
414
+ }
415
+ }
367
416
  function clone(value) {
368
417
  if (value == null || typeof value !== "object") return value;
369
418
  if (Array.isArray(value)) return value.map(clone);
@@ -47,7 +47,7 @@ module.exports = __toCommonJS(store_exports);
47
47
  var import_signal = require("@fluixi/reactive/signal");
48
48
 
49
49
  // src/version.generated.ts
50
- var VERSION = "1.0.0-alpha.84";
50
+ var VERSION = "1.0.0-alpha.86";
51
51
 
52
52
  // src/lib/signal/graph/state.ts
53
53
  var MAJOR = VERSION.split(".")[0];
@@ -394,12 +394,61 @@ function applySet(root, args) {
394
394
  mergeInto(root, first);
395
395
  return;
396
396
  }
397
- if (Array.isArray(args[1]) && args.length >= 3) {
398
- applyPath(root, `${first}.${args[1].join(".")}`, args[2]);
397
+ if (args.length >= 3) {
398
+ setDeep(root, args.slice(0, -1), args[args.length - 1]);
399
399
  return;
400
400
  }
401
401
  applyPath(root, String(first), args[1]);
402
402
  }
403
+ function selectKeys(current, selector) {
404
+ if (typeof selector === "function") {
405
+ if (!Array.isArray(current)) return [];
406
+ const keys = [];
407
+ for (let i = 0; i < current.length; i++) if (selector(current[i], i)) keys.push(i);
408
+ return keys;
409
+ }
410
+ if (Array.isArray(selector)) {
411
+ return Array.isArray(current) ? selector.map(Number) : selector.map(String);
412
+ }
413
+ if (selector && typeof selector === "object" && ("from" in selector || "to" in selector || "by" in selector)) {
414
+ if (!Array.isArray(current)) return [];
415
+ const by = selector.by ?? 1;
416
+ const from = selector.from ?? 0;
417
+ const to = selector.to ?? current.length - 1;
418
+ const keys = [];
419
+ for (let i = from; i <= to; i += by) if (i >= 0 && i < current.length) keys.push(i);
420
+ return keys;
421
+ }
422
+ if (selector === "*") {
423
+ return Array.isArray(current) ? current.map((_, i) => i) : Object.keys(current ?? {});
424
+ }
425
+ return [selector];
426
+ }
427
+ function setDeep(current, selectors, value) {
428
+ if (current == null) return;
429
+ const [head, ...rest] = selectors;
430
+ if (typeof head === "string") {
431
+ const parts = parsePath(head);
432
+ if (parts.length > 1) {
433
+ setDeep(current, [...parts, ...rest], value);
434
+ return;
435
+ }
436
+ }
437
+ const keys = selectKeys(current, head);
438
+ if (rest.length === 0) {
439
+ for (const key of keys) writeKey(current, key, nextValue(value, current[key]));
440
+ return;
441
+ }
442
+ for (const key of keys) {
443
+ let next = current[key];
444
+ if (next == null || typeof next !== "object") {
445
+ const lookahead = rest[0];
446
+ next = typeof lookahead === "number" || /^\d+$/.test(String(lookahead)) ? [] : {};
447
+ writeKey(current, key, next);
448
+ }
449
+ setDeep(next, rest, value);
450
+ }
451
+ }
403
452
  function clone(value) {
404
453
  if (value == null || typeof value !== "object") return value;
405
454
  if (Array.isArray(value)) return value.map(clone);
@@ -1 +1 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/lib/store/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,EAKN,MAAM,yBAAyB,CAAC;AAQjC,OAAO,KAAK,EAAE,gBAAgB,IAAI,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACvF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAgBnD,KAAK,SAAS,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC,CAAC,GAAG;IAAE,OAAO,EAAE,CAAC,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAC;AAEzE,UAAU,YAAY,CAA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
352
  * set(state => newState) whole-state updater, merged back
353
353
  * set(partialObject) per-key merge
354
354
  * set([[path, valOrFn], ...]) batch of path updates
355
- * set(path, ['seg', ...], val) path plus extra segments
355
+ * set(path, ...steps, val) a step per argument: key, index, [indices],
356
+ * { from, to, by }, a predicate, or '*'
356
357
  * set(path, val | updater) the common form (dotted, [n], [*])
357
358
  */
358
359
  function applySet(root, args) {
@@ -388,12 +389,98 @@ function applySet(root, args) {
388
389
  mergeInto(root, first);
389
390
  return;
390
391
  }
391
- if (Array.isArray(args[1]) && args.length >= 3) {
392
- applyPath(root, `${first}.${args[1].join('.')}`, args[2]);
392
+ // Three or more arguments: every one but the last selects a step, the last is the
393
+ // value. This used to read `args[1]` as the value and ignore the rest, so
394
+ // `set('items', 0, 'done', true)` wrote the number 0 over `items`, accepted by the
395
+ // typings, and silent.
396
+ if (args.length >= 3) {
397
+ setDeep(root, args.slice(0, -1), args[args.length - 1]);
393
398
  return;
394
399
  }
395
400
  applyPath(root, String(first), args[1]);
396
401
  }
402
+ /**
403
+ * Which keys a selector names at this level.
404
+ *
405
+ * The typings offer four shapes for the steps between a path and a value, and each one
406
+ * resolves here rather than at a call site:
407
+ * 'name' | 2 a single key, dotted paths expanded by the caller
408
+ * [0, 2] several indices of an array
409
+ * { from, to, by } a range of indices
410
+ * (item, i) => bool a predicate over an array
411
+ * '*' every key
412
+ */
413
+ function selectKeys(current, selector) {
414
+ if (typeof selector === 'function') {
415
+ if (!Array.isArray(current))
416
+ return [];
417
+ const keys = [];
418
+ for (let i = 0; i < current.length; i++)
419
+ if (selector(current[i], i))
420
+ keys.push(i);
421
+ return keys;
422
+ }
423
+ if (Array.isArray(selector)) {
424
+ // Against an array these are indices. Against anything else there is nothing to
425
+ // index, so they are path segments: the form this function used to be given.
426
+ return Array.isArray(current) ? selector.map(Number) : selector.map(String);
427
+ }
428
+ if (selector &&
429
+ typeof selector === 'object' &&
430
+ ('from' in selector || 'to' in selector || 'by' in selector)) {
431
+ if (!Array.isArray(current))
432
+ return [];
433
+ const by = selector.by ?? 1;
434
+ const from = selector.from ?? 0;
435
+ const to = selector.to ?? current.length - 1;
436
+ const keys = [];
437
+ for (let i = from; i <= to; i += by)
438
+ if (i >= 0 && i < current.length)
439
+ keys.push(i);
440
+ return keys;
441
+ }
442
+ if (selector === '*') {
443
+ return Array.isArray(current)
444
+ ? current.map((_, i) => i)
445
+ : Object.keys(current ?? {});
446
+ }
447
+ return [selector];
448
+ }
449
+ /**
450
+ * Walk the selectors, writing the value at every leaf they reach.
451
+ *
452
+ * A string step is expanded first, so `set('a.b', 'c', v)` and `set('a', 'b', 'c', v)`
453
+ * land in the same place. Missing containers are created on the way down, as an array
454
+ * when the next step looks like an index.
455
+ */
456
+ function setDeep(current, selectors, value) {
457
+ if (current == null)
458
+ return;
459
+ // Expand a dotted or bracketed string into its own steps before selecting.
460
+ const [head, ...rest] = selectors;
461
+ if (typeof head === 'string') {
462
+ const parts = parsePath(head);
463
+ if (parts.length > 1) {
464
+ setDeep(current, [...parts, ...rest], value);
465
+ return;
466
+ }
467
+ }
468
+ const keys = selectKeys(current, head);
469
+ if (rest.length === 0) {
470
+ for (const key of keys)
471
+ writeKey(current, key, nextValue(value, current[key]));
472
+ return;
473
+ }
474
+ for (const key of keys) {
475
+ let next = current[key];
476
+ if (next == null || typeof next !== 'object') {
477
+ const lookahead = rest[0];
478
+ next = typeof lookahead === 'number' || /^\d+$/.test(String(lookahead)) ? [] : {};
479
+ writeKey(current, key, next);
480
+ }
481
+ setDeep(next, rest, value);
482
+ }
483
+ }
397
484
  function clone(value) {
398
485
  if (value == null || typeof value !== 'object')
399
486
  return value;
@@ -9,7 +9,7 @@ import {
9
9
  } from "@fluixi/reactive/signal";
10
10
 
11
11
  // src/version.generated.ts
12
- var VERSION = "1.0.0-alpha.84";
12
+ var VERSION = "1.0.0-alpha.86";
13
13
 
14
14
  // src/lib/signal/graph/state.ts
15
15
  var MAJOR = VERSION.split(".")[0];
@@ -356,12 +356,61 @@ function applySet(root, args) {
356
356
  mergeInto(root, first);
357
357
  return;
358
358
  }
359
- if (Array.isArray(args[1]) && args.length >= 3) {
360
- applyPath(root, `${first}.${args[1].join(".")}`, args[2]);
359
+ if (args.length >= 3) {
360
+ setDeep(root, args.slice(0, -1), args[args.length - 1]);
361
361
  return;
362
362
  }
363
363
  applyPath(root, String(first), args[1]);
364
364
  }
365
+ function selectKeys(current, selector) {
366
+ if (typeof selector === "function") {
367
+ if (!Array.isArray(current)) return [];
368
+ const keys = [];
369
+ for (let i = 0; i < current.length; i++) if (selector(current[i], i)) keys.push(i);
370
+ return keys;
371
+ }
372
+ if (Array.isArray(selector)) {
373
+ return Array.isArray(current) ? selector.map(Number) : selector.map(String);
374
+ }
375
+ if (selector && typeof selector === "object" && ("from" in selector || "to" in selector || "by" in selector)) {
376
+ if (!Array.isArray(current)) return [];
377
+ const by = selector.by ?? 1;
378
+ const from = selector.from ?? 0;
379
+ const to = selector.to ?? current.length - 1;
380
+ const keys = [];
381
+ for (let i = from; i <= to; i += by) if (i >= 0 && i < current.length) keys.push(i);
382
+ return keys;
383
+ }
384
+ if (selector === "*") {
385
+ return Array.isArray(current) ? current.map((_, i) => i) : Object.keys(current ?? {});
386
+ }
387
+ return [selector];
388
+ }
389
+ function setDeep(current, selectors, value) {
390
+ if (current == null) return;
391
+ const [head, ...rest] = selectors;
392
+ if (typeof head === "string") {
393
+ const parts = parsePath(head);
394
+ if (parts.length > 1) {
395
+ setDeep(current, [...parts, ...rest], value);
396
+ return;
397
+ }
398
+ }
399
+ const keys = selectKeys(current, head);
400
+ if (rest.length === 0) {
401
+ for (const key of keys) writeKey(current, key, nextValue(value, current[key]));
402
+ return;
403
+ }
404
+ for (const key of keys) {
405
+ let next = current[key];
406
+ if (next == null || typeof next !== "object") {
407
+ const lookahead = rest[0];
408
+ next = typeof lookahead === "number" || /^\d+$/.test(String(lookahead)) ? [] : {};
409
+ writeKey(current, key, next);
410
+ }
411
+ setDeep(next, rest, value);
412
+ }
413
+ }
365
414
  function clone(value) {
366
415
  if (value == null || typeof value !== "object") return value;
367
416
  if (Array.isArray(value)) return value.map(clone);