@praxisjs/core 2.1.0 → 2.3.0

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 (126) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/component/internals.d.ts +12 -2
  3. package/dist/component/internals.d.ts.map +1 -1
  4. package/dist/component/internals.js +25 -7
  5. package/dist/component/internals.js.map +1 -1
  6. package/dist/internal.d.ts +3 -2
  7. package/dist/internal.d.ts.map +1 -1
  8. package/dist/internal.js +3 -2
  9. package/dist/internal.js.map +1 -1
  10. package/dist/reactive/history.d.ts +2 -0
  11. package/dist/reactive/history.d.ts.map +1 -1
  12. package/dist/reactive/history.js +2 -1
  13. package/dist/reactive/history.js.map +1 -1
  14. package/dist/signal/batch.d.ts +1 -3
  15. package/dist/signal/batch.d.ts.map +1 -1
  16. package/dist/signal/batch.js +4 -16
  17. package/dist/signal/batch.js.map +1 -1
  18. package/dist/signal/computed.d.ts.map +1 -1
  19. package/dist/signal/computed.js +19 -61
  20. package/dist/signal/computed.js.map +1 -1
  21. package/dist/signal/effect.d.ts +6 -12
  22. package/dist/signal/effect.d.ts.map +1 -1
  23. package/dist/signal/effect.js +11 -74
  24. package/dist/signal/effect.js.map +1 -1
  25. package/dist/signal/graph.d.ts +111 -0
  26. package/dist/signal/graph.d.ts.map +1 -0
  27. package/dist/signal/graph.js +513 -0
  28. package/dist/signal/graph.js.map +1 -0
  29. package/dist/signal/index.d.ts +2 -1
  30. package/dist/signal/index.d.ts.map +1 -1
  31. package/dist/signal/index.js +1 -0
  32. package/dist/signal/index.js.map +1 -1
  33. package/dist/signal/peek.d.ts.map +1 -1
  34. package/dist/signal/peek.js +2 -9
  35. package/dist/signal/peek.js.map +1 -1
  36. package/dist/signal/persisted.d.ts +11 -1
  37. package/dist/signal/persisted.d.ts.map +1 -1
  38. package/dist/signal/persisted.js +39 -5
  39. package/dist/signal/persisted.js.map +1 -1
  40. package/dist/signal/selector.d.ts +5 -0
  41. package/dist/signal/selector.d.ts.map +1 -0
  42. package/dist/signal/selector.js +128 -0
  43. package/dist/signal/selector.js.map +1 -0
  44. package/dist/signal/signal.d.ts +0 -5
  45. package/dist/signal/signal.d.ts.map +1 -1
  46. package/dist/signal/signal.js +11 -81
  47. package/dist/signal/signal.js.map +1 -1
  48. package/package.json +13 -4
  49. package/src/component/internals.ts +35 -10
  50. package/src/internal.ts +27 -0
  51. package/src/reactive/history.ts +4 -1
  52. package/src/signal/batch.ts +5 -19
  53. package/src/signal/computed.ts +20 -63
  54. package/src/signal/effect.ts +12 -83
  55. package/src/signal/graph.ts +562 -0
  56. package/src/signal/index.ts +2 -1
  57. package/src/signal/peek.ts +2 -8
  58. package/src/signal/persisted.ts +54 -5
  59. package/src/signal/selector.ts +140 -0
  60. package/src/signal/signal.ts +11 -79
  61. package/dist/__tests__/batch.test.d.ts +0 -2
  62. package/dist/__tests__/batch.test.d.ts.map +0 -1
  63. package/dist/__tests__/batch.test.js +0 -73
  64. package/dist/__tests__/batch.test.js.map +0 -1
  65. package/dist/__tests__/component.test.d.ts +0 -2
  66. package/dist/__tests__/component.test.d.ts.map +0 -1
  67. package/dist/__tests__/component.test.js +0 -124
  68. package/dist/__tests__/component.test.js.map +0 -1
  69. package/dist/__tests__/computed.test.d.ts +0 -2
  70. package/dist/__tests__/computed.test.d.ts.map +0 -1
  71. package/dist/__tests__/computed.test.js +0 -252
  72. package/dist/__tests__/computed.test.js.map +0 -1
  73. package/dist/__tests__/effect.test.d.ts +0 -2
  74. package/dist/__tests__/effect.test.d.ts.map +0 -1
  75. package/dist/__tests__/effect.test.js +0 -189
  76. package/dist/__tests__/effect.test.js.map +0 -1
  77. package/dist/__tests__/peek.test.d.ts +0 -2
  78. package/dist/__tests__/peek.test.d.ts.map +0 -1
  79. package/dist/__tests__/peek.test.js +0 -26
  80. package/dist/__tests__/peek.test.js.map +0 -1
  81. package/dist/__tests__/persisted-signal.test.d.ts +0 -2
  82. package/dist/__tests__/persisted-signal.test.d.ts.map +0 -1
  83. package/dist/__tests__/persisted-signal.test.js +0 -156
  84. package/dist/__tests__/persisted-signal.test.js.map +0 -1
  85. package/dist/__tests__/reactive.test.d.ts +0 -2
  86. package/dist/__tests__/reactive.test.d.ts.map +0 -1
  87. package/dist/__tests__/reactive.test.js +0 -264
  88. package/dist/__tests__/reactive.test.js.map +0 -1
  89. package/dist/__tests__/resource-focus.test.d.ts +0 -2
  90. package/dist/__tests__/resource-focus.test.d.ts.map +0 -1
  91. package/dist/__tests__/resource-focus.test.js +0 -50
  92. package/dist/__tests__/resource-focus.test.js.map +0 -1
  93. package/dist/__tests__/resource-server-pass.test.d.ts +0 -2
  94. package/dist/__tests__/resource-server-pass.test.d.ts.map +0 -1
  95. package/dist/__tests__/resource-server-pass.test.js +0 -78
  96. package/dist/__tests__/resource-server-pass.test.js.map +0 -1
  97. package/dist/__tests__/resource.test.d.ts +0 -2
  98. package/dist/__tests__/resource.test.d.ts.map +0 -1
  99. package/dist/__tests__/resource.test.js +0 -336
  100. package/dist/__tests__/resource.test.js.map +0 -1
  101. package/dist/__tests__/signal.test.d.ts +0 -2
  102. package/dist/__tests__/signal.test.d.ts.map +0 -1
  103. package/dist/__tests__/signal.test.js +0 -186
  104. package/dist/__tests__/signal.test.js.map +0 -1
  105. package/dist/__tests__/synced.test.d.ts +0 -2
  106. package/dist/__tests__/synced.test.d.ts.map +0 -1
  107. package/dist/__tests__/synced.test.js +0 -142
  108. package/dist/__tests__/synced.test.js.map +0 -1
  109. package/dist/__tests__/track.test.d.ts +0 -2
  110. package/dist/__tests__/track.test.d.ts.map +0 -1
  111. package/dist/__tests__/track.test.js +0 -54
  112. package/dist/__tests__/track.test.js.map +0 -1
  113. package/src/__tests__/batch.test.ts +0 -87
  114. package/src/__tests__/component.test.ts +0 -165
  115. package/src/__tests__/computed.test.ts +0 -290
  116. package/src/__tests__/effect.test.ts +0 -226
  117. package/src/__tests__/peek.test.ts +0 -31
  118. package/src/__tests__/persisted-signal.test.ts +0 -194
  119. package/src/__tests__/reactive.test.ts +0 -305
  120. package/src/__tests__/resource-focus.test.ts +0 -61
  121. package/src/__tests__/resource-server-pass.test.ts +0 -90
  122. package/src/__tests__/resource.test.ts +0 -421
  123. package/src/__tests__/signal.test.ts +0 -213
  124. package/src/__tests__/synced.test.ts +0 -173
  125. package/src/__tests__/track.test.ts +0 -61
  126. package/tsconfig.json +0 -8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # @praxisjs/core
2
2
 
3
+ ## 2.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 75115a9: DevTools: a Performance panel and `profiler` that record signal writes, effect runs and computed recomputations with their cost, grouped by the component that created each effect; `@Debug({ log, break })`, reactive observation of accessor fields (props included), promise-aware method timing, `@Trace({ slow })`, inert decorators in production builds, and a faster registry. Core exposes the observer hooks the profiler uses (`setReactiveObserver`, `setCurrentOwner`, `getEffectOwner` in `@praxisjs/core/internal`), which cost one null check while no observer is installed; the runtime marks the rendering component as the owner of the effects it creates.
8
+ - 75115a9: Rendering and reactivity performance overhaul. `@praxisjs/core` has a new push-pull reactive graph (linked dependencies reused across runs, version-checked computeds, glitch-free effects) and keeps component internals on the instance. `@praxisjs/decorators` shares one accessor pair per `@State`/`@Prop` field, creates `@Computed` lazily, and `@Component` no longer wraps the class. `@praxisjs/runtime` adds the compiled-template helpers, a shared event dispatcher, leaner scopes and reactive children, skipped no-op prop writes, cheaper component mounting and a detached fill for large `For` renders, and fixes a static `<select>` value being lost. `@praxisjs/vite-plugin` compiles JSX trees of host elements into templates cloned per render (`templates` option, on by default).
9
+ - 75115a9: Add a keyed selection primitive. `selector(source, equals?)` in `@praxisjs/core/internal` and the `@Selector(field, { equals })` field decorator expose `isSelected(key)`, whose subscribers are grouped by key: a change to the source re-runs only the effects that read the previous or the next key, instead of every row comparing against it. Key buckets and the source subscription are released when their effects are disposed.
10
+
11
+ ### Patch Changes
12
+
13
+ - 75115a9: Edge-case fixes in the new fast paths. `@praxisjs/vite-plugin` keeps a claimed field's initializer in the field's own scope instead of moving it into the constructor, where a constructor parameter or local of the same name shadowed what it read (and `new.target` fields are claimed too). `selector()` from `@praxisjs/core` compares against the current source value when read outside an effect, also inside a batch or an event handler before its subscribers are notified. `@praxisjs/runtime` keeps updating a hydrated element through a reactive child that fills it alone, rebuilds compiled templates when `render()` runs with another global document (a new SSG window), and always writes `open`, `selectedIndex`, media and scroll props from reactive bindings so a re-run restores what the user changed. Compiled templates keep the leading whitespace of JSX text (`{v} / {m}` lost its first space) and keep tabs inside a line, as the JSX transform does. Methods of `@Bind`, `@Emit` and the other built-in method decorators can be spied on with `vi.spyOn(instance, name)` before their first read again. `@praxisjs/router`'s `Link` removes its `class` attribute when it stops being active instead of leaving `class=""`.
14
+ - 75115a9: Published packages no longer contain their tests: package builds compile `src` without `src/**/__tests__` (through a `tsconfig.build.json`), and each package's `files` leaves test sources and stale compiled tests out of the tarball. `pnpm typecheck` still type-checks the tests.
15
+ - 75115a9: Cheaper creation of rows and components. `@praxisjs/runtime` builds and clones compiled templates in the inert `<template>` document (live document for templates with custom elements) and no longer touches `document` at import time, binds template event props without a listener (one capture listener per event type on the document and on each render container attaches an element's own listener on first use, same dispatch semantics), runs reactive props and children through shared functions with per-binding records instead of closures, creates text natively without JS wrappers, forks a reactive child's scope only when a run asks for it, stops wrapping single-root components in comments, writes only-child text with `textContent` and inserts arrays without a fragment. Compiled event props bind through a per-module target (`_$event`/`_$onEvent`) and reactive `class` props through `_$className`, skipping the generic prop dispatch. `@praxisjs/core`'s `getComponentAnchor()` returns a `Node` (a single-root component is anchored on its root) and every `selector()` shares one bucket class, `createContextEffect()` runs an effect whose shared function reads its state from `this.ctx`; effects record their owner even when no reactive observer is installed (`getEffectOwner()` reads it from the node). `@praxisjs/vite-plugin` also compiles lone elements that have something static or a reactive child, emits the delegated event bindings, emits a template that is an arrow function's whole body or a `return` operand as plain statements, leaves no placeholder for a reactive only child, hoists one event target per event prop name and module, emits a dedicated binding for a reactive `class`/`className`, and no longer wraps a JSX tree used as an attribute value of a compiled element in braces. Both packages keep one inert instance of each hot internal class (graph nodes and links, selector buckets, scopes, list rows, reactive children) so their V8 hidden classes survive a full GC after a list is cleared, and every list row gets the same hidden class whatever it renders.
16
+ - 75115a9: Smaller production bundles. The framework and feature packages are marked `"sideEffects": false`, so bundlers leave out the modules an app does not use (`For`/`Index` and `selector()` were kept in every bundle by their shape keepers). `@praxisjs/core`'s graph gates its observer instrumentation on a boolean that minifiers fold away when no observer is ever installed. `@praxisjs/runtime` passes `Index`'s positional update to the list view, so `For`-only apps leave it out, and builds its event prop table from camel-case names. `@praxisjs/devtools` is built one file per module and its decorators check `process.env.NODE_ENV` inline, so `@Trace`/`@Debug` in production code no longer bundle the registry and the panel. `@praxisjs/vite-plugin` serves TypeScript's decorator helpers and the claimed fields' helper from one virtual module (`virtual:praxisjs/decorators`) instead of writing them into every decorated file, and replaces the identical copies `tsc` wrote into ES module libraries.
17
+ - Updated dependencies [75115a9]
18
+ - Updated dependencies [75115a9]
19
+ - @praxisjs/shared@0.3.2
20
+
21
+ ## 2.2.0
22
+
23
+ ### Minor Changes
24
+
25
+ - a97a37c: `batch()` deduplicates queued effects with a `Set` (was an O(n²) array scan). Fixed a bug where an effect that threw during a batch flush skipped the remaining effects and left stale entries in the queue; the flush now runs every effect and rethrows the last error afterwards.
26
+
27
+ Subscriber lists switch from an array to a `Set` once they hold more than 16 effects, so a signal read by thousands of bindings no longer updates in quadratic time (one signal driving 20,000 effects: ~47 ms → ~1.6 ms per update in a browser benchmark). Subscription order is unchanged.
28
+
29
+ `persistedSignal()` gains a `close()` method that removes its `storage` listener.
30
+
31
+ `persistedSignal()` takes a `writeDelay` option that coalesces `localStorage` writes (flushed on `pagehide` and `close()`). `history()` gains `destroy()`, and `computed` gains an internal `dispose()` that releases its source subscriptions when nothing depends on it.
32
+
3
33
  ## 2.1.0
4
34
 
5
35
  ### Minor Changes
@@ -6,11 +6,21 @@ export declare function getComponentRawProp(instance: object, name: string): unk
6
6
  export declare function getComponentDefault(instance: object, name: string): unknown;
7
7
  export declare function setComponentDefault(instance: object, name: string, value: unknown): void;
8
8
  export declare function getComponentDefaults(instance: object): Record<string, unknown>;
9
- export declare function getComponentAnchor(instance: object): Comment | undefined;
10
- export declare function setComponentAnchor(instance: object, anchor: Comment | undefined): void;
9
+ /**
10
+ * A node of the mounted component's output: its only root node, or the comment that closes its
11
+ * region when it renders several nodes. Its `parentElement` is the element the component sits in.
12
+ */
13
+ export declare function getComponentAnchor(instance: object): Node | undefined;
14
+ export declare function setComponentAnchor(instance: object, anchor: Node | undefined): void;
11
15
  export declare function isComponentMounted(instance: object): boolean;
12
16
  export declare function setComponentMounted(instance: object, mounted: boolean): void;
13
17
  export declare function markStateDirty(instance: object): void;
14
18
  export declare function isStateDirty(instance: object): boolean;
15
19
  export declare function setStateDirty(instance: object, stateDirty: boolean): void;
20
+ /**
21
+ * The comment that opens a component's region, when it has one: a component whose render sets it
22
+ * (with the closing comment as its anchor) brings its own boundaries, and mountComponent adds none.
23
+ */
24
+ export declare function getComponentStart(instance: object): Comment | undefined;
25
+ export declare function setComponentStart(instance: object, start: Comment | undefined): void;
16
26
  //# sourceMappingURL=internals.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"internals.d.ts","sourceRoot":"","sources":["../../src/component/internals.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,EAAE,OAAO,MAA4C,CAAC;AAoBrF,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GACZ,IAAI,CAON;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,IAAI,CAMN;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MA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Internals = new WeakMap();
2
+ // Kept on the instance under a symbol rather than in a WeakMap: every @Prop read goes through
3
+ // here, and a property load is much cheaper than a WeakMap lookup.
4
+ const INTERNALS = Symbol("praxis.internals");
3
5
  function getInternals(instance) {
4
- const internals = componentInternals.get(instance);
6
+ const internals = instance[INTERNALS];
5
7
  if (!internals) {
6
8
  throw new TypeError("Expected a PraxisJS component instance.");
7
9
  }
8
10
  return internals;
9
11
  }
10
12
  export function initComponentInternals(instance, props) {
11
- componentInternals.set(instance, {
13
+ instance[INTERNALS] = {
12
14
  rawProps: { ...props },
13
15
  mounted: false,
16
+ anchor: undefined,
17
+ start: undefined,
14
18
  defaults: {},
15
19
  stateDirty: false,
16
- });
20
+ };
17
21
  }
18
22
  export function getComponentProps(instance) {
19
23
  return getInternals(instance).rawProps;
@@ -37,6 +41,10 @@ export function setComponentDefault(instance, name, value) {
37
41
  export function getComponentDefaults(instance) {
38
42
  return getInternals(instance).defaults;
39
43
  }
44
+ /**
45
+ * A node of the mounted component's output: its only root node, or the comment that closes its
46
+ * region when it renders several nodes. Its `parentElement` is the element the component sits in.
47
+ */
40
48
  export function getComponentAnchor(instance) {
41
49
  return getInternals(instance).anchor;
42
50
  }
@@ -50,21 +58,31 @@ export function setComponentMounted(instance, mounted) {
50
58
  getInternals(instance).mounted = mounted;
51
59
  }
52
60
  export function markStateDirty(instance) {
53
- const internals = componentInternals.get(instance);
61
+ const internals = instance[INTERNALS];
54
62
  if (internals) {
55
63
  internals.stateDirty = true;
56
64
  }
57
65
  }
58
66
  export function isStateDirty(instance) {
59
- const internals = componentInternals.get(instance);
67
+ const internals = instance[INTERNALS];
60
68
  if (internals)
61
69
  return internals.stateDirty;
62
70
  return false;
63
71
  }
64
72
  export function setStateDirty(instance, stateDirty) {
65
- const internals = componentInternals.get(instance);
73
+ const internals = instance[INTERNALS];
66
74
  if (internals) {
67
75
  internals.stateDirty = stateDirty;
68
76
  }
69
77
  }
78
+ /**
79
+ * The comment that opens a component's region, when it has one: a component whose render sets it
80
+ * (with the closing comment as its anchor) brings its own boundaries, and mountComponent adds none.
81
+ */
82
+ export function getComponentStart(instance) {
83
+ return getInternals(instance).start;
84
+ }
85
+ export function setComponentStart(instance, start) {
86
+ getInternals(instance).start = start;
87
+ }
70
88
  //# sourceMappingURL=internals.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"internals.js","sourceRoot":"","sources":["../../src/component/internals.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAkB,MAAM,CAAC,2BAA2B,CAAC,CAAC;AAUrF,MAAM,kBAAkB,GAAG,IAAI,OAAO,EAAsC,CAAC;AAE7E,SAAS,YAAY,CAAC,QAAgB;IACpC,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACnD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,SAAS,CAAC,yCAAyC,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,QAAgB,EAChB,KAAa;IAEb,kBAAkB,CAAC,GAAG,CAAC,QAAQ,EAAE;QAC/B,QAAQ,EAAE,EAAE,GAAG,KAAK,EAAE;QACtB,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,KAAK;KAClB,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,QAAgB;IAChD,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,QAAgB,EAChB,KAA8B;IAE9B,MAAM,QAAQ,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC,QAAmC,CAAC;IAC5E,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QACpC,OAAO,CAAC,cAAc,CAAC,QAAQ,EAAE,G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M,GAAG,MAAM,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IACjD,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,QAAgB,EAChB,OAAgB;IAEhB,YAAY,CAAC,QAAQ,CAAC,CAAC,OAAO,GAAG,OAAO,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC7C,MAAM,SAAS,GAAI,QAA0B,CAAC,SAAS,CAAC,CAAC;IACzD,IAAI,SAAS,EAAE,CAAC;QACd,SAAS,CAAC,UAAU,GAAG,IAAI,CAAC;IAC9B,CAAC;AACH,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,QAAgB;IAC3C,MAAM,SAAS,GAAI,QAA0B,CAAC,SAAS,CAAC,CAAC;IACzD,IAAI,SAAS;QAAE,OAAO,SAAS,CAAC,UAAU,CAAC;IAC3C,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,QAAgB,EAChB,UAAmB;IAEnB,MAAM,SAAS,GAAI,QAA0B,CAAC,SAAS,CAAC,CAAC;IACzD,IAAI,SAAS,EAAE,CAAC;QACd,SAAS,CAAC,UAAU,GAAG,UAAU,CAAC;IACpC,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAgB;IAChD,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,QAAgB,EAAE,KAA0B;IAC5E,YAAY,CAAC,QAAQ,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC;AACvC,CAAC"}
@@ -1,7 +1,8 @@
1
1
  export { debounced, until, when, history, type HistoryElement, } from "./reactive";
2
- export { signal, persistedSignal, syncedSignal, peek, computed, writableComputed, batch, effect, untrack, type PersistedSignalOptions, type SyncedSignal, } from "./signal";
2
+ export { signal, persistedSignal, syncedSignal, peek, computed, writableComputed, batch, effect, untrack, selector, type Selector, type SelectorEquals, type PersistedSignalOptions, type PersistedSignal, type SyncedSignal, } from "./signal";
3
3
  export { RootComponent } from "./component";
4
- export { componentPropsType, getComponentAnchor, getComponentDefault, getComponentDefaults, getComponentProps, getComponentRawProp, isComponentMounted, isStateDirty, markStateDirty, setComponentAnchor, setComponentDefault, setComponentMounted, setComponentProps, setStateDirty, } from "./component/internals";
4
+ export { createEffect, createContextEffect, disposeEffect, startBatch, endBatch, EffectNode, SignalNode, readSignal, writeSignal, ComputedNode, readComputed, type ReactiveNode, pauseTracking, resumeTracking, setReactiveObserver, setCurrentOwner, getEffectOwner, type ReactiveObserver, type EffectCleanup, } from "./signal/graph";
5
+ export { componentPropsType, getComponentAnchor, getComponentDefault, getComponentDefaults, getComponentProps, getComponentRawProp, getComponentStart, setComponentStart, isComponentMounted, isStateDirty, markStateDirty, setComponentAnchor, setComponentDefault, setComponentMounted, setComponentProps, setStateDirty, } from "./component/internals";
5
6
  export { resource, createResource, flushPendingResources, type ResourceStatus, type Resource, type ResourceOptions, } from "./async/resource";
6
7
  export { invalidateResource, trackPendingResource, _clearCache } from "./async/resource-cache";
7
8
  export { setServerRenderPass, isServerRenderPass } from "./async/server-mode";
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,EACL,IAAI,EACJ,OAAO,EACP,KAAK,cAAc,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,MAAM,EACN,eAAe,EACf,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,gBAAgB,EAChB,KAAK,EACL,MAAM,EACN,OAAO,EACP,KAAK,sBAAsB,EAC3B,KAAK,YAAY,GAClB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,GACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,QAAQ,EACR,cAAc,EACd,qBAAqB,EACrB,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,eAAe,GACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,EACL,IAAI,EACJ,OAAO,EACP,KAAK,cAAc,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,MAAM,EACN,eAAe,EACf,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,gBAAgB,EAChB,KAAK,EACL,MAAM,EACN,OAAO,EACP,QAAQ,EACR,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,YAAY,GAClB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,QAAQ,EACR,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,KAAK,YAAY,EACjB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,KAAK,gBAAgB,EACrB,KAAK,aAAa,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,GACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,QAAQ,EACR,cAAc,EACd,qBAAqB,EACrB,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,eAAe,GACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
package/dist/internal.js CHANGED
@@ -1,7 +1,8 @@
1
1
  export { debounced, until, when, history, } from "./reactive";
2
- export { signal, persistedSignal, syncedSignal, peek, computed, writableComputed, batch, effect, untrack, } from "./signal";
2
+ export { signal, persistedSignal, syncedSignal, peek, computed, writableComputed, batch, effect, untrack, selector, } from "./signal";
3
3
  export { RootComponent } from "./component";
4
- export { componentPropsType, getComponentAnchor, getComponentDefault, getComponentDefaults, getComponentProps, getComponentRawProp, isComponentMounted, isStateDirty, markStateDirty, setComponentAnchor, setComponentDefault, setComponentMounted, setComponentProps, setStateDirty, } from "./component/internals";
4
+ export { createEffect, createContextEffect, disposeEffect, startBatch, endBatch, EffectNode, SignalNode, readSignal, writeSignal, ComputedNode, readComputed, pauseTracking, resumeTracking, setReactiveObserver, setCurrentOwner, getEffectOwner, } from "./signal/graph";
5
+ export { componentPropsType, getComponentAnchor, getComponentDefault, getComponentDefaults, getComponentProps, getComponentRawProp, getComponentStart, setComponentStart, isComponentMounted, isStateDirty, markStateDirty, setComponentAnchor, setComponentDefault, setComponentMounted, setComponentProps, setStateDirty, } from "./component/internals";
5
6
  export { resource, createResource, flushPendingResources, } from "./async/resource";
6
7
  export { invalidateResource, trackPendingResource, _clearCache } from "./async/resource-cache";
7
8
  export { setServerRenderPass, isServerRenderPass } from "./async/server-mode";
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,EACL,IAAI,EACJ,OAAO,GAER,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,MAAM,EACN,eAAe,EACf,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,gBAAgB,EAChB,KAAK,EACL,MAAM,EACN,OAAO,GAGR,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,GACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,QAAQ,EACR,cAAc,EACd,qBAAqB,GAItB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,EACL,IAAI,EACJ,OAAO,GAER,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,MAAM,EACN,eAAe,EACf,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,gBAAgB,EAChB,KAAK,EACL,MAAM,EACN,OAAO,EACP,QAAQ,GAMT,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,QAAQ,EACR,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,YAAY,EACZ,YAAY,EAEZ,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,cAAc,GAGf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,GACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,QAAQ,EACR,cAAc,EACd,qBAAqB,GAItB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -7,6 +7,8 @@ export interface HistoryElement<T> {
7
7
  undo(): void;
8
8
  redo(): void;
9
9
  clear(): void;
10
+ /** Stops tracking the source. Existing entries stay readable; no new ones are recorded. */
11
+ destroy(): void;
10
12
  }
11
13
  export declare function history<T>(source: Signal<T> | Computed<T>, limit?: number): HistoryElement<T>;
12
14
  //# sourceMappingURL=history.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/reactive/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAMzD,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,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
  const _current = signal(source());
8
8
  let _ignoreNext = false;
9
9
  let _initialized = false;
10
- effect(() => {
10
+ const stop = effect(() => {
11
11
  const value = source();
12
12
  if (!_initialized) {
13
13
  _initialized = true;
@@ -59,6 +59,7 @@ export function history(source, limit = 50) {
59
59
  _past.set([]);
60
60
  _future.set([]);
61
61
  },
62
+ destroy: stop,
62
63
  };
63
64
  }
64
65
  //# sourceMappingURL=history.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"history.js","sourceRoot":"","sources":["../../src/reactive/history.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAY1C,MAAM,UAAU,OAAO,CACrB,MAA+B,EAC/B,KAAK,GAAG,EAAE;IAEV,MAAM,KAAK,GAAG,MAAM,CAAM,EAAE,CAAC,CAAC;IAC9B,MAAM,OAAO,GAAG,MAAM,CAAM,EAAE,CAAC,CAAC;IAChC,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAElC,IAAI,WAAW,GAAG,KAAK,CAAC;IACxB,IAAI,YAAY,GAAG,KAAK,CAAC;IAEzB,MAAM,CAAC,GAAG,EAAE;QACV,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC;QAEvB,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,YAAY,GAAG,IAAI,CAAC;YACpB,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO;QACT,CAAC;QAED,IAAI,WAAW,EAAE,CAAC;YAChB,WAAW,GAAG,KAAK,CAAC;YACpB,OAAO;QACT,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,MAAM,IAAI,GAAG,CAAC,GAAG,IAAI,EAAE,IAAI,CAAC,Q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,CAAC"}
@@ -1,5 +1,3 @@
1
- import type { Effect } from "./effect";
2
- export declare function isBatching(): boolean;
3
- export declare function enqueueEffect(effect: Effect): void;
1
+ /** Runs `fn` and defers every effect it invalidates until it returns, so each runs once. */
4
2
  export declare function batch(fn: () => void): void;
5
3
  //# sourceMappingURL=batch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../src/signal/batch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAKvC,wBAAgB,UAAU,IAAI,OAAO,CAEpC;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAElD;AAED,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,IAAI,QAWnC"}
1
+ {"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../src/signal/batch.ts"],"names":[],"mappings":"AAEA,4FAA4F;AAC5F,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAO1C"}
@@ -1,24 +1,12 @@
1
- const batchEffects = [];
2
- let batchDepth = 0;
3
- export function isBatching() {
4
- return batchDepth > 0;
5
- }
6
- export function enqueueEffect(effect) {
7
- if (!batchEffects.includes(effect))
8
- batchEffects.push(effect);
9
- }
1
+ import { endBatch, startBatch } from "./graph";
2
+ /** Runs `fn` and defers every effect it invalidates until it returns, so each runs once. */
10
3
  export function batch(fn) {
11
- batchDepth++;
4
+ startBatch();
12
5
  try {
13
6
  fn();
14
7
  }
15
8
  finally {
16
- if (--batchDepth === 0) {
17
- const n = batchEffects.length;
18
- for (let i = 0; i < n; i++)
19
- batchEffects[i]();
20
- batchEffects.length = 0;
21
- }
9
+ endBatch();
22
10
  }
23
11
  }
24
12
  //# sourceMappingURL=batch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"batch.js","sourceRoot":"","sources":["../../src/signal/batch.ts"],"names":[],"mappings":"AAEA,MAAM,YAAY,GAAa,EAAE,CAAC;AAClC,IAAI,UAAU,GAAG,CAAC,CAAC;AAEnB,MAAM,UAAU,UAAU;IACxB,OAAO,UAAU,GAAG,CAAC,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,MAAc;IAC1C,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,EAAc;IAClC,UAAU,EAAE,CAAC;IACb,IAAI,CAAC;QACH,EAAE,EAAE,CAAC;IACP,CAAC;YAAS,CAAC;QACT,IAAI,EAAE,UAAU,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC;YAC9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;gBAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;YAC9C,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"batch.js","sourceRoot":"","sources":["../../src/signal/batch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE/C,4FAA4F;AAC5F,MAAM,UAAU,KAAK,CAAC,EAAc;IAClC,UAAU,EAAE,CAAC;IACb,IAAI,CAAC;QACH,EAAE,EAAE,CAAC;IACP,CAAC;YAAS,CAAC;QACT,QAAQ,EAAE,CAAC;IACb,CAAC;AACH,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"computed.d.ts","sourceRoot":"","sources":["../../src/signal/computed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAWnE,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CA8DxD;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAMpG"}
1
+ {"version":3,"file":"computed.d.ts","sourceRoot":"","sources":["../../src/signal/computed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAKnE,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAyBxD;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAMpG"}
@@ -1,66 +1,24 @@
1
- import { activeEffect, cleanupEffectDeps, runEffect } from "./effect";
2
- import { addSub, removeSub, notifySubs } from "./signal";
3
- function isComputedRecompute(eff) {
4
- return eff.__isComputedRecompute === true;
5
- }
1
+ import { untrack } from "./effect";
2
+ import { ComputedNode, createEffect, DIRTY, disposeEffect, readComputed, unlinkDeps } from "./graph";
6
3
  export function computed(getter) {
7
- let cachedValue;
8
- let dirty = true;
9
- const computedHolder = { subs: null };
10
- const leafHolder = { subs: null };
11
- let scheduled = false;
12
- let recompute = null;
13
- function getRecompute() {
14
- if (recompute !== null)
15
- return recompute;
16
- recompute = function markDirty() {
17
- if (dirty)
18
- return;
19
- dirty = true;
20
- if (computedHolder.subs !== null)
21
- notifySubs(computedHolder.subs, false);
22
- if (leafHolder.subs !== null && !scheduled) {
23
- scheduled = true;
24
- queueMicrotask(() => {
25
- scheduled = false;
26
- if (leafHolder.subs !== null)
27
- notifySubs(leafHolder.subs, false);
28
- });
29
- }
30
- };
31
- recompute.__isComputedRecompute = true;
32
- return recompute;
33
- }
34
- function read() {
35
- if (activeEffect !== null) {
36
- if (isComputedRecompute(activeEffect)) {
37
- addSub(computedHolder, activeEffect);
38
- }
39
- else {
40
- addSub(leafHolder, activeEffect);
41
- }
42
- }
43
- if (dirty) {
44
- const prevEffect = activeEffect;
45
- const recomputeEffect = getRecompute();
46
- cleanupEffectDeps(recomputeEffect);
47
- runEffect(recomputeEffect);
48
- try {
49
- cachedValue = getter();
50
- dirty = false;
51
- }
52
- finally {
53
- runEffect(prevEffect);
54
- }
55
- }
56
- return cachedValue;
57
- }
58
- const c = read;
4
+ const node = new ComputedNode(getter);
5
+ const c = (() => readComputed(node));
6
+ // Drops this computed's subscriptions to its sources so an unreachable one (e.g. an evicted
7
+ // @Memo entry) isn't kept alive by the signals it read. Does nothing while anything still
8
+ // depends on it: detaching then would leave those dependents silently stale.
9
+ c.dispose = () => {
10
+ if (node.subs !== undefined)
11
+ return;
12
+ unlinkDeps(node);
13
+ node.flags |= DIRTY;
14
+ node.value = undefined;
15
+ };
59
16
  c.subscribe = (fn) => {
60
- const wrapped = () => { fn(read()); };
61
- addSub(leafHolder, wrapped);
62
- wrapped();
63
- return () => { removeSub(leafHolder, wrapped); };
17
+ const sub = createEffect(() => {
18
+ const value = readComputed(node);
19
+ untrack(() => { fn(value); });
20
+ });
21
+ return () => { disposeEffect(sub); };
64
22
  };
65
23
  c.__isComputed = true;
66
24
  return c;
@@ -1 +1 @@
1
- {"version":3,"file":"computed.js","sourceRoot":"","sources":["../../src/signal/computed.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,SAAS,EAA6B,MAAM,UAAU,CAAC;AACjG,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAIzD,SAAS,mBAAmB,CAAC,GAAW;IACtC,OAAQ,GAAkC,CAAC,qBAAqB,KAAK,IAAI,CAAC;AAC5E,CAAC;A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AG,MAAM,CAAC;IACf,CAAC,CAAC,MAAM,GAAG,CAAC,OAAO,EAAE,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,CAAC,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAC9B,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -1,15 +1,9 @@
1
+ import { type EffectCleanup } from "./graph";
1
2
  export type Effect = () => void;
2
- export type SubList = Effect | Effect[] | null;
3
- export interface SubscriberHolder {
4
- subs: SubList;
5
- }
6
- export declare let activeEffect: Effect | null;
7
- export declare function recordDependency(eff: Effect, holder: SubscriberHolder): void;
8
- export declare function cleanupEffectDeps(eff: Effect): void;
9
- export declare function track(effect: Effect): void;
10
- export declare function runEffect(effect: Effect | null): void;
11
3
  export declare function untrack<T>(fn: () => T): T;
12
- type Cleanup = (() => void) | void;
13
- export declare function effect(fn: () => Cleanup): () => void;
14
- export {};
4
+ /**
5
+ * Runs `fn` now and again whenever a signal or computed it read changes. A returned function is
6
+ * called before each re-run and on stop. Returns the stop function.
7
+ */
8
+ export declare function effect(fn: () => EffectCleanup): () => void;
15
9
  //# sourceMappingURL=effect.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../../src/signal/effect.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC;AAChC,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;AAC/C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,OAAO,CAAC;CACf;AAID,eAAO,IAAI,YAAY,EAAE,MAAM,GAAG,IAAW,CAAC;AAe9C,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAI5E;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAMnD;AAED,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,QAUnC;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,QAE9C;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAQzC;AAGD,KAAK,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC;AAEnC,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,OAAO,SAmBd,IAAI,CAO7B"}
1
+ {"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../../src/signal/effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwD,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAEnG,MAAM,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC;AAEhC,wBAAgB,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAQzC;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,aAAa,GAAG,MAAM,IAAI,CAG1D"}
@@ -1,84 +1,21 @@
1
- export let activeEffect = null;
2
- const effectStack = [];
3
- function removeTrackedSub(holder, eff) {
4
- const subs = holder.subs;
5
- if (subs === null)
6
- return;
7
- if (typeof subs === "function") {
8
- if (subs === eff)
9
- holder.subs = null;
10
- return;
11
- }
12
- const idx = subs.indexOf(eff);
13
- if (idx >= 0)
14
- subs.splice(idx, 1);
15
- if (subs.length === 0)
16
- holder.subs = null;
17
- }
18
- export function recordDependency(eff, holder) {
19
- const tracked = eff;
20
- tracked.__deps ??= new Set();
21
- tracked.__deps.add(holder);
22
- }
23
- export function cleanupEffectDeps(eff) {
24
- const tracked = eff;
25
- const deps = tracked.__deps;
26
- if (!deps)
27
- return;
28
- for (const holder of deps)
29
- removeTrackedSub(holder, eff);
30
- deps.clear();
31
- }
32
- export function track(effect) {
33
- cleanupEffectDeps(effect);
34
- effectStack.push(effect);
35
- activeEffect = effect;
36
- try {
37
- effect();
38
- }
39
- finally {
40
- effectStack.pop();
41
- activeEffect = effectStack[effectStack.length - 1] ?? null;
42
- }
43
- }
44
- export function runEffect(effect) {
45
- activeEffect = effect;
46
- }
1
+ import { activeSub, createEffect, disposeEffect, setActiveSub } from "./graph";
47
2
  export function untrack(fn) {
48
- const prev = activeEffect;
49
- activeEffect = null;
3
+ if (activeSub === undefined)
4
+ return fn();
5
+ const prev = setActiveSub(undefined);
50
6
  try {
51
7
  return fn();
52
8
  }
53
9
  finally {
54
- activeEffect = prev;
10
+ setActiveSub(prev);
55
11
  }
56
12
  }
13
+ /**
14
+ * Runs `fn` now and again whenever a signal or computed it read changes. A returned function is
15
+ * called before each re-run and on stop. Returns the stop function.
16
+ */
57
17
  export function effect(fn) {
58
- let cleanup;
59
- let stopped = false;
60
- function run() {
61
- if (stopped)
62
- return;
63
- cleanupEffectDeps(run);
64
- cleanup?.();
65
- const prev = activeEffect;
66
- activeEffect = run;
67
- try {
68
- cleanup = fn();
69
- }
70
- finally {
71
- activeEffect = prev;
72
- }
73
- }
74
- run();
75
- return function stop() {
76
- if (stopped)
77
- return;
78
- stopped = true;
79
- cleanupEffectDeps(run);
80
- cleanup?.();
81
- cleanup = undefined;
82
- };
18
+ const node = createEffect(fn);
19
+ return () => { disposeEffect(node); };
83
20
  }
84
21
  //# sourceMappingURL=effect.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"effect.js","sourceRoot":"","sources":["../../src/signal/effect.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,IAAI,YAAY,GAAkB,IAAI,CAAC;AAC9C,MAAM,WAAW,GAAa,EAAE,CAAC;AAEjC,SAAS,gBAAgB,CAAC,MAAwB,EAAE,GAAW;IAC7D,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IACzB,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO;IAC1B,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/B,IAA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