@torpor/view 0.4.18 → 1.0.1

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 (72) hide show
  1. package/README.md +41 -16
  2. package/dist/Cleanup-D0wvGW5d.d.cts +9 -0
  3. package/dist/Cleanup-D0wvGW5d.d.cts.map +1 -0
  4. package/dist/Cleanup-D0wvGW5d.d.mts +9 -0
  5. package/dist/Cleanup-D0wvGW5d.d.mts.map +1 -0
  6. package/dist/Component-0MH0zd-m.d.cts +11 -0
  7. package/dist/Component-0MH0zd-m.d.cts.map +1 -0
  8. package/dist/Component-0MH0zd-m.d.mts +11 -0
  9. package/dist/Component-0MH0zd-m.d.mts.map +1 -0
  10. package/dist/Effect-BTKurOpr.d.mts +381 -0
  11. package/dist/Effect-BTKurOpr.d.mts.map +1 -0
  12. package/dist/Effect-COl3aRJV.d.cts +381 -0
  13. package/dist/Effect-COl3aRJV.d.cts.map +1 -0
  14. package/dist/compile.cjs +1734 -739
  15. package/dist/compile.d.cts +85 -50
  16. package/dist/compile.d.cts.map +1 -1
  17. package/dist/compile.d.mts +85 -50
  18. package/dist/compile.d.mts.map +1 -1
  19. package/dist/compile.mjs +1737 -741
  20. package/dist/compile.mjs.map +1 -1
  21. package/dist/dev.cjs +62 -63
  22. package/dist/dev.d.cts +4 -3
  23. package/dist/dev.d.cts.map +1 -1
  24. package/dist/dev.d.mts +4 -3
  25. package/dist/dev.d.mts.map +1 -1
  26. package/dist/dev.mjs +61 -62
  27. package/dist/dev.mjs.map +1 -1
  28. package/dist/{devContext-B3yskfhA.cjs → devContext-BulTn3U5.cjs} +6 -9
  29. package/dist/{devContext-CQ8RhBX-.mjs → devContext-ZNsPyOgB.mjs} +3 -4
  30. package/dist/devContext-ZNsPyOgB.mjs.map +1 -0
  31. package/dist/fromWebSocket-1QOjcrHE.cjs +182 -0
  32. package/dist/fromWebSocket-B52kN3-W.d.mts +91 -0
  33. package/dist/fromWebSocket-B52kN3-W.d.mts.map +1 -0
  34. package/dist/fromWebSocket-DeB35Q4w.d.cts +91 -0
  35. package/dist/fromWebSocket-DeB35Q4w.d.cts.map +1 -0
  36. package/dist/fromWebSocket-Dxc_uwm1.mjs +137 -0
  37. package/dist/fromWebSocket-Dxc_uwm1.mjs.map +1 -0
  38. package/dist/index.cjs +2109 -494
  39. package/dist/index.d.cts +608 -112
  40. package/dist/index.d.cts.map +1 -1
  41. package/dist/index.d.mts +608 -112
  42. package/dist/index.d.mts.map +1 -1
  43. package/dist/index.mjs +2088 -490
  44. package/dist/index.mjs.map +1 -1
  45. package/dist/ssr.cjs +78 -17
  46. package/dist/ssr.d.cts +64 -11
  47. package/dist/ssr.d.cts.map +1 -1
  48. package/dist/ssr.d.mts +64 -11
  49. package/dist/ssr.d.mts.map +1 -1
  50. package/dist/ssr.mjs +67 -14
  51. package/dist/ssr.mjs.map +1 -1
  52. package/package.json +21 -19
  53. package/dist/Cleanup-CYsytTEc.d.cts +0 -9
  54. package/dist/Cleanup-CYsytTEc.d.cts.map +0 -1
  55. package/dist/Cleanup-CgjyN0lW.d.mts +0 -9
  56. package/dist/Cleanup-CgjyN0lW.d.mts.map +0 -1
  57. package/dist/Component-DmWGMgak.d.mts +0 -11
  58. package/dist/Component-DmWGMgak.d.mts.map +0 -1
  59. package/dist/Component-kGLRFYg2.d.cts +0 -11
  60. package/dist/Component-kGLRFYg2.d.cts.map +0 -1
  61. package/dist/Region-Bb6HAb-F.d.cts +0 -201
  62. package/dist/Region-Bb6HAb-F.d.cts.map +0 -1
  63. package/dist/Region-CTchywkr.d.mts +0 -201
  64. package/dist/Region-CTchywkr.d.mts.map +0 -1
  65. package/dist/devContext-CQ8RhBX-.mjs.map +0 -1
  66. package/dist/formatText-BNP3P38F.d.cts +0 -17
  67. package/dist/formatText-BNP3P38F.d.cts.map +0 -1
  68. package/dist/formatText-D6Ov8Ub0.d.mts +0 -17
  69. package/dist/formatText-D6Ov8Ub0.d.mts.map +0 -1
  70. package/dist/formatText-DTIRmc3X.mjs +0 -61
  71. package/dist/formatText-DTIRmc3X.mjs.map +0 -1
  72. package/dist/formatText-Dhl2O0Ee.cjs +0 -96
package/README.md CHANGED
@@ -2,14 +2,22 @@
2
2
 
3
3
  Torpor's view library, for writing and mounting components.
4
4
 
5
- 🚧 WARNING: WORK IN PROGRESS 🚧
6
-
7
5
  ## Installation
8
6
 
9
- Use `npm` (or your preferred package manager) to add Torpor to your project:
7
+ You almost certainly want to use [torpor/build](../build), Torpor's
8
+ full-stack framework, to build a site with Torpor:
9
+
10
+ ```bash
11
+ npm init @torpor/build@latest my-project
12
+ cd my-project
13
+ npm install
14
+ npm run dev
15
+ ```
16
+
17
+ Otherwise, you can add Torpor's view layer directly to your project:
10
18
 
11
19
  ```bash
12
- npm install torpor
20
+ npm install @torpor/view
13
21
  ```
14
22
 
15
23
  ## Features
@@ -25,7 +33,7 @@ npm install torpor
25
33
  - `@if` statement
26
34
  - `@for` loop
27
35
  - `@switch` statement
28
- - `@await` statement for loading data from an async function
36
+ - `@await` async boundary (with `with` branch) for loading `$async` getters
29
37
  - And
30
38
  - `@replace` to re-run a section when a property changes
31
39
  - `@const` to declare a const variable in markup
@@ -37,7 +45,7 @@ npm install torpor
37
45
  - `$watch` to create a proxy that updates UI on property changes
38
46
  - `$cache` to cache proxy getter values that are expensive to update
39
47
  - `$run` to create an effect that is re-run when its dependencies change
40
- - `$mount` to create an effect that runs after a component has been mounted
48
+ - `$onmount` to run a function once, after a component has been mounted
41
49
  - And
42
50
  - `$unwrap` to get the target object from the proxy
43
51
  - `$peek` to get the value of a target object without re-running effects on change
@@ -54,7 +62,7 @@ npm install torpor
54
62
 
55
63
  ### Not yet
56
64
 
57
- - Animation
65
+ - Animation (beyond the in/out transitions above)
58
66
 
59
67
  ## A component
60
68
 
@@ -66,10 +74,16 @@ export default function Component($props: { name: string }) {
66
74
  // Use the $watch function to declare reactive state
67
75
  let $state = $watch({
68
76
  count: 0,
77
+ guessVersion: 0,
69
78
  get isEven() {
70
79
  return this.count % 2 === 0
71
80
  },
72
- tasks: []
81
+ tasks: [],
82
+ // An async getter: $async tracks the promise and suspends reads until
83
+ // it resolves. Reading guessVersion makes it re-fetch on "Guess again".
84
+ get guesser() {
85
+ return $async(() => guessNumber($state.guessVersion === 0 ? 1000 : 500))
86
+ }
73
87
  })
74
88
 
75
89
  // Use the $run function to declare an effect that runs whenever its dependent state changes
@@ -80,7 +94,6 @@ export default function Component($props: { name: string }) {
80
94
  })
81
95
 
82
96
  // This is an async function
83
- $state.guesser = guessNumber(1000)
84
97
  async function guessNumber(ms) {
85
98
  ...
86
99
  }
@@ -147,17 +160,19 @@ export default function Component($props: { name: string }) {
147
160
  </div>
148
161
 
149
162
  <h2>Await statements</h2>
150
- <p>There is a construct for await/then/catch.</p>
163
+ <p>Read $async getters inside @await blocks; use @try/@catch for errors.</p>
151
164
  <div class="demo">
152
165
  <p>Think of a number between 1 and 10...</p>
153
- @await ($state.guesser) {
154
- <p>Hmm...</p>
155
- } then (number) {
156
- <p>Is it {number}?</p>
166
+ @try {
167
+ @await {
168
+ <p>Is it {$state.guesser}?</p>
169
+ } with {
170
+ <p>Hmm...</p>
171
+ }
157
172
  } catch (ex) {
158
173
  <p class="error">Something went wrong: {ex}!</p>
159
174
  }
160
- <button onclick={() => $state.guesser = guessNumber(500)}>
175
+ <button onclick={() => $state.guessVersion++}>
161
176
  Guess again
162
177
  </button>
163
178
  </div>
@@ -232,9 +247,19 @@ function TaskItem() {
232
247
  ## Mounting
233
248
 
234
249
  ```
235
- import mount from "torpor/view/mount";
250
+ import { mount } from "@torpor/view";
236
251
  import Main from "./Main.torp";
237
252
 
238
253
  const root = document.getElementById("root");
239
254
  mount(root, Main);
240
255
  ```
256
+
257
+ `mount` also takes optional props and slots:
258
+
259
+ ```
260
+ mount(root, Main, { name: "World" });
261
+ ```
262
+
263
+ Components can also be compiled for server side rendering (the `ServerComponent`
264
+ type in `@torpor/view/ssr`), with `hydrate` and `unmount` from the main module
265
+ taking over on the client.
@@ -0,0 +1,9 @@
1
+ //#region src/types/Cleanup.d.ts
2
+ /**
3
+ * A function that may be returned from an effect, and is run before the effect
4
+ * is run or destroyed
5
+ */
6
+ type Cleanup = () => void;
7
+ //#endregion
8
+ export { Cleanup as t };
9
+ //# sourceMappingURL=Cleanup-D0wvGW5d.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Cleanup-D0wvGW5d.d.cts","names":[],"sources":["../src/types/Cleanup.ts"],"mappings":";;;;;KAIK"}
@@ -0,0 +1,9 @@
1
+ //#region src/types/Cleanup.d.ts
2
+ /**
3
+ * A function that may be returned from an effect, and is run before the effect
4
+ * is run or destroyed
5
+ */
6
+ type Cleanup = () => void;
7
+ //#endregion
8
+ export { Cleanup as t };
9
+ //# sourceMappingURL=Cleanup-D0wvGW5d.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Cleanup-D0wvGW5d.d.mts","names":[],"sources":["../src/types/Cleanup.ts"],"mappings":";;;;;KAIK"}
@@ -0,0 +1,11 @@
1
+ //#region src/types/SlotRender.d.ts
2
+ type SlotRender = ($sparent: ParentNode, $sanchor: Node | null, $slot?: Record<PropertyKey, any>, $context?: Record<PropertyKey, any>) => void;
3
+ //#endregion
4
+ //#region src/types/Component.d.ts
5
+ /**
6
+ * A component that can be mounted or hydrated
7
+ */
8
+ type Component = ($parent: ParentNode, $anchor: Node | null, $props?: any, $context?: Record<PropertyKey, any>, $slots?: Record<string, SlotRender>) => void;
9
+ //#endregion
10
+ export { SlotRender as n, Component as t };
11
+ //# sourceMappingURL=Component-0MH0zd-m.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Component-0MH0zd-m.d.cts","names":[],"sources":["../src/types/SlotRender.ts","../src/types/Component.ts"],"mappings":";KAAK,cACJ,UAAU,YACV,UAAU,aACV,QAAQ,OAAO,mBACf,WAAW,OAAO;;;;;;KCCd,aACJ,SAAS,YACT,SAAS,aAIT,cACA,WAAW,OAAO,mBAClB,SAAS,eAAe"}
@@ -0,0 +1,11 @@
1
+ //#region src/types/SlotRender.d.ts
2
+ type SlotRender = ($sparent: ParentNode, $sanchor: Node | null, $slot?: Record<PropertyKey, any>, $context?: Record<PropertyKey, any>) => void;
3
+ //#endregion
4
+ //#region src/types/Component.d.ts
5
+ /**
6
+ * A component that can be mounted or hydrated
7
+ */
8
+ type Component = ($parent: ParentNode, $anchor: Node | null, $props?: any, $context?: Record<PropertyKey, any>, $slots?: Record<string, SlotRender>) => void;
9
+ //#endregion
10
+ export { SlotRender as n, Component as t };
11
+ //# sourceMappingURL=Component-0MH0zd-m.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Component-0MH0zd-m.d.mts","names":[],"sources":["../src/types/SlotRender.ts","../src/types/Component.ts"],"mappings":";KAAK,cACJ,UAAU,YACV,UAAU,aACV,QAAQ,OAAO,mBACf,WAAW,OAAO;;;;;;KCCd,aACJ,SAAS,YACT,SAAS,aAIT,cACA,WAAW,OAAO,mBAClB,SAAS,eAAe"}
@@ -0,0 +1,381 @@
1
+ import { t as Cleanup } from "./Cleanup-D0wvGW5d.mjs";
2
+ //#region src/types/constants.d.ts
3
+ /**
4
+ * The type of a Signal object.
5
+ */
6
+ declare const SIGNAL_TYPE = 0;
7
+ /**
8
+ * The type of a Computed object.
9
+ */
10
+ declare const COMPUTED_TYPE = 1;
11
+ /**
12
+ * The type of an Effect object.
13
+ */
14
+ declare const EFFECT_TYPE = 2;
15
+ //#endregion
16
+ //#region src/types/ProxySignal.d.ts
17
+ /**
18
+ * A value that causes dependent Computeds and Effects to be re-run. Our signals
19
+ * are implemented as object properties.
20
+ */
21
+ interface ProxySignal {
22
+ /**
23
+ * SIGNAL.
24
+ */
25
+ type: typeof SIGNAL_TYPE;
26
+ /**
27
+ * The first Computed or Effect that is triggered when this property is changed.
28
+ */
29
+ firstTarget: Subscription | null;
30
+ /**
31
+ * When signals have been changed in a batch, this is the next changed signal.
32
+ */
33
+ nextSignalToUpdate: ProxySignal | null;
34
+ /**
35
+ * The name of the property, for debugging.
36
+ */
37
+ name?: string;
38
+ }
39
+ //#endregion
40
+ //#region src/types/Subscription.d.ts
41
+ /**
42
+ * A subscription that connects a source Signal or Computed to a target Computed
43
+ * or Effect.
44
+ */
45
+ interface Subscription {
46
+ /**
47
+ * The source Signal or Computed.
48
+ */
49
+ source: ProxySignal | Computed;
50
+ /**
51
+ * The target Computed or Effect.
52
+ */
53
+ target: Computed | Effect;
54
+ /**
55
+ * The next source subscription. After the targets have been re-run, we run
56
+ * through sources to remove any that weren't re-used.
57
+ */
58
+ nextSource: Subscription | null;
59
+ /**
60
+ * The next target subscription. When the source is changed, we run through
61
+ * targets to mark them dirty and possibly re-run them.
62
+ */
63
+ nextTarget: Subscription | null;
64
+ /**
65
+ * The previous target subscription. We remove subscriptions by looping
66
+ * through the sources list, so we only need to know the next source, but we
67
+ * need to know both the next and previous targets to properly update the
68
+ * targets list.
69
+ */
70
+ previousTarget: Subscription | null;
71
+ /**
72
+ * Whether this subscription is active. At the start of a re-run, all
73
+ * subscriptions are marked inactive and marked active if re-used. If not
74
+ * re-used, they are removed after the run.
75
+ */
76
+ active: boolean;
77
+ /**
78
+ * Whether the subscription's target may need to be recalculated (if any of
79
+ * its sources have changed).
80
+ */
81
+ recalc: boolean;
82
+ /**
83
+ * The name of the subscription, for debugging.
84
+ */
85
+ name?: string;
86
+ }
87
+ //#endregion
88
+ //#region src/types/Computed.d.ts
89
+ /**
90
+ * A computed value that is lazily refreshed when accessed from an Effect or
91
+ * another Computed. Our computed values are implemented as property getter
92
+ * functions.
93
+ */
94
+ interface Computed<T = any> {
95
+ /**
96
+ * COMPUTED.
97
+ */
98
+ type: typeof COMPUTED_TYPE;
99
+ /**
100
+ * True if this computed was created by `$async` (an async getter whose run
101
+ * returns a Promise and suspends readers until it resolves). False for
102
+ * plain `$cache` computeds. `$refresh` targets only `isAsync` computeds,
103
+ * so re-running a `$cache` getter (which would recompute a sync value for
104
+ * no reason) never happens.
105
+ */
106
+ isAsync: boolean;
107
+ /**
108
+ * The cached, computed value.
109
+ */
110
+ value: T;
111
+ /**
112
+ * The getter function to run to access this computed's value.
113
+ */
114
+ run: () => T;
115
+ /**
116
+ * The first signal or computed that causes this effect to be run.
117
+ */
118
+ firstSource: Subscription | null;
119
+ /**
120
+ * The first computed or effect that is triggered when this property is changed.
121
+ */
122
+ firstTarget: Subscription | null;
123
+ /**
124
+ * Whether the computed may need to be recalculated (if any of its sources
125
+ * have changed). We store this on the computed (as well as its
126
+ * subscription) so we don't have to check the sources every time (which may
127
+ * be expensive).
128
+ */
129
+ recalc: boolean;
130
+ /**
131
+ * Used to track cycles.
132
+ */
133
+ running: boolean;
134
+ /**
135
+ * True if the computed encountered an exception in its last run.
136
+ */
137
+ didError: boolean;
138
+ /**
139
+ * True if the computed's last run returned a pending Promise. Set by
140
+ * `$async`; read by the proxy get trap to suspend readers. Cleared when
141
+ * the promise resolves (or rejects), at which point dependents are
142
+ * propagated through the reactive graph.
143
+ */
144
+ didSuspend: boolean;
145
+ /**
146
+ * Generation counter for `$async`'s stale-resolve guard. Each run of an
147
+ * `$async` computed increments this; the `.then` handler captures the
148
+ * generation and ignores resolves from stale (previous) runs. Unused by
149
+ * plain `$cache` computeds.
150
+ */
151
+ generation: number;
152
+ /**
153
+ * True once an `$async` computed's promise has resolved or rejected at
154
+ * least once. Used by `$pending` to distinguish a first load (never
155
+ * resolved) from a refresh. Monotonic — once true it stays true across
156
+ * subsequent re-suspends. Unused by plain `$cache` computeds.
157
+ */
158
+ hasResolved: boolean;
159
+ /**
160
+ * True when the last settled result of an `$async` computed was a
161
+ * rejection. Set by the `.then` reject handler, cleared by the resolve
162
+ * handler, which also clears `staleValue` — a retry-after-error
163
+ * re-suspend must not hand the previous error to readers as "stale
164
+ * content" (it renders as a raw value, bypassing the error boundary).
165
+ * Unused by plain `$cache` computeds.
166
+ */
167
+ lastErrored: boolean;
168
+ /**
169
+ * True when the current suspend is a "bare refresh" — a re-fetch with no
170
+ * tracked dependency change, i.e. a silent `$refresh(fn, { silent: true })`
171
+ * (background revalidation), per ASYNC.md §7.4's quiet-on-refresh rule.
172
+ * `$pending` reads this to stay quiet (return `false`) on silent refreshes,
173
+ * matching Solid's stale-while-revalidate default.
174
+ *
175
+ * Captured at suspend time inside `$async`'s run: a suspend is quiet iff
176
+ * the computed has resolved before (`hasResolved`) AND the run was NOT
177
+ * source-driven (`recalc === false`, i.e. not triggered by `checkComputed`
178
+ * and not a loud `$refresh`). First loads are always loud (`hasResolved`
179
+ * is false); dependency-change refreshes and loud `$refresh` calls are
180
+ * always loud (`recalc` is true).
181
+ */
182
+ suspendQuiet: boolean;
183
+ /**
184
+ * The previously resolved value, retained across a refresh suspend for
185
+ * stale-while-revalidate (ASYNC.md §6.2). Maintained by `$async`'s
186
+ * generation-guarded settle handlers — set on resolve, cleared on
187
+ * rejection — so it always holds the last RESOLVED value, never a
188
+ * superseded run's in-flight promise (rapid prop changes would otherwise
189
+ * render "[object Promise]"). Read by `suspendRead` so readers keep
190
+ * displaying the old value instead of a placeholder while the new promise
191
+ * is in flight. `undefined` on first load (never resolved) and for plain
192
+ * `$cache` computeds (which never suspend, so `suspendRead` is never
193
+ * reached for them).
194
+ */
195
+ staleValue: any;
196
+ /**
197
+ * A subscription to roll back to when recursively updating signal targets.
198
+ */
199
+ rollback: Subscription | null;
200
+ /**
201
+ * The name of the computed property, for debugging.
202
+ */
203
+ name?: string;
204
+ }
205
+ //#endregion
206
+ //#region src/types/ErrorBoundary.d.ts
207
+ /**
208
+ * An error boundary created by `t_run_try` (`@try`/`@catch` groups and
209
+ * top-level `@error` blocks). Stored on the boundary's `Region` so that
210
+ * `routeEffectError` can find the nearest enclosing boundary by walking the
211
+ * region chain from a failing effect's owning region.
212
+ */
213
+ interface ErrorBoundary {
214
+ /**
215
+ * The error to render in the catch branch: set either by a synchronous
216
+ * build throw (handled internally by `runTry`) or by an effect error
217
+ * routed from `triggerEffects`.
218
+ */
219
+ error: any;
220
+ /**
221
+ * True when an effect error has been routed here and the boundary's
222
+ * effect needs to (re-)render the catch branch with `error`.
223
+ */
224
+ hasError: boolean;
225
+ /**
226
+ * The boundary's control effect. Re-run by `routeEffectError` to render
227
+ * the catch branch for a routed error.
228
+ */
229
+ effect: Effect | null;
230
+ /**
231
+ * Source signals held while the catch branch is showing, so the boundary
232
+ * re-runs (and re-attempts the try branch) when they change. Captured
233
+ * from the routed erroring effect's subscriptions — reads wrapped in
234
+ * nested `$run` effects (text/attribute interpolation) are tracked by
235
+ * those effects, not the boundary, so without holding them the catch
236
+ * branch would never recover.
237
+ */
238
+ heldSignals: (ProxySignal | Computed)[] | null;
239
+ }
240
+ //#endregion
241
+ //#region src/types/Region.d.ts
242
+ interface Region {
243
+ startNode: ChildNode | null;
244
+ endNode: ChildNode | null;
245
+ previousRegion: Region | null;
246
+ nextRegion: Region | null;
247
+ depth: number;
248
+ /**
249
+ * Animations that are currently running in the region, and which need to
250
+ * awaited or canceled before it is removed
251
+ */
252
+ animations: Set<Animation> | null;
253
+ /**
254
+ * The name of the region, for debugging.
255
+ */
256
+ name?: string;
257
+ /**
258
+ * Effects that are owned by this region.
259
+ */
260
+ effects: Effect[];
261
+ /**
262
+ * Set by `t_run_try` (`@try`/`@catch` groups and top-level `@error`
263
+ * blocks) when a catch/error branch exists. `routeEffectError` walks the
264
+ * region chain from a failing effect's owning region and routes the error
265
+ * to the nearest boundary.
266
+ */
267
+ errorBoundary?: ErrorBoundary;
268
+ /**
269
+ * Generation counter used by `runControl` to detect stale effects. Each
270
+ * `t_run_control` call increments this; effects from previous calls check
271
+ * it and skip execution if they're no longer current. Set ad-hoc today;
272
+ * declared here so the casts can be dropped.
273
+ */
274
+ generation?: number;
275
+ /**
276
+ * Set by `clearRegion` when a region is released but may be reused,
277
+ * forcing the next `t_run_branch` to re-render even at the same branch
278
+ * index.
279
+ */
280
+ recreate?: boolean;
281
+ }
282
+ //#endregion
283
+ //#region src/types/Effect.d.ts
284
+ /**
285
+ * An effect that is run and re-run when the properties it depends on change.
286
+ */
287
+ interface Effect {
288
+ /**
289
+ * EFFECT.
290
+ */
291
+ type: typeof EFFECT_TYPE;
292
+ /**
293
+ *
294
+ * @returns An optional cleanup function, to run when the effect is re-run or disposed.
295
+ */
296
+ run: () => Cleanup | void;
297
+ /**
298
+ * The optional cleanup function that may have been returned from the run function.
299
+ */
300
+ cleanup: Cleanup | void;
301
+ /**
302
+ * The first signal or computed that causes this effect to be run.
303
+ */
304
+ firstSource: Subscription | null;
305
+ nextEffect: Effect | null;
306
+ /**
307
+ * The number of children of this effect.
308
+ */
309
+ extent: number;
310
+ /**
311
+ * True while the effect is linked into the current run queue. Reset as
312
+ * soon as the effect is processed, so a signal write later in the same
313
+ * flush — or during the effect's own run — can correctly re-queue it.
314
+ */
315
+ queued: boolean;
316
+ /**
317
+ * True if the effect encountered an exception in its last run.
318
+ */
319
+ didError: boolean;
320
+ /**
321
+ * True if the effect's last run read a suspended (`didSuspend`) computed.
322
+ * Set by the proxy get trap's suspend-taint propagation and reset at the
323
+ * start of each run. Read by `triggerEffects` to detect a crash that may
324
+ * have been caused by a pending value.
325
+ */
326
+ didSuspend: boolean;
327
+ /**
328
+ * The suspended computeds read during the effect's current (or last
329
+ * failed) run, recorded by `suspendRead`. Cleared at the start of each
330
+ * run. Read by `triggerEffects` when a run throws with no error boundary
331
+ * to handle it: the effect is re-subscribed to these so the promise's
332
+ * resolve re-runs it, turning a crash on a pending read's `undefined`
333
+ * into a self-healing one-off error instead of a permanently dead
334
+ * effect.
335
+ */
336
+ suspendSources?: Set<Computed> | null;
337
+ /**
338
+ * The name of the effect, for debugging.
339
+ */
340
+ name?: string;
341
+ /**
342
+ * The region that was active when this effect was created, and which
343
+ * owns its cleanup. Used by `routeEffectError` to walk to the nearest
344
+ * enclosing error boundary.
345
+ */
346
+ region?: Region | null;
347
+ /**
348
+ * The effect's source signals, captured just before `clearSources` runs
349
+ * after a failed run (see `runEffect`). Read by `routeEffectError` so an
350
+ * error boundary can hold the subscriptions needed for recovery.
351
+ */
352
+ errorSources?: (ProxySignal | Computed)[] | null;
353
+ /**
354
+ * True when this effect wraps a `$onmount`/`onmount` callback (created by
355
+ * `flushMountEffects`). Mount callbacks run once per region mount and
356
+ * must NOT be force re-run by the keyed-list reconciler's
357
+ * `rerunEffectsOnRegion` — doing so would re-fire `onmount` on every item
358
+ * update. Their bodies are also run untracked, so they never gain signal
359
+ * subscriptions and never re-run reactively.
360
+ */
361
+ isMountEffect?: boolean;
362
+ /**
363
+ * When set, a bitmask of the `@for` loop-variable positions that this
364
+ * effect's body reads (computed at compile time by scanning for
365
+ * substituted data-bag paths). Bit N corresponds to the Nth for-var.
366
+ * Used by `rerunRegionEffects` on the no-proxy keyed-list path to skip
367
+ * effects that don't depend on any of the changed for-vars via a single
368
+ * bitwise AND.
369
+ *
370
+ * - `undefined`: dependency info not available — re-run unconditionally
371
+ * (backward-compatible behaviour for effects emitted outside the
372
+ * for-body builders, e.g. mount-time animations).
373
+ * - `0`: the effect reads no for-vars at all — skip on any field change
374
+ * (it has its own signal subscriptions for other reactive state).
375
+ * - `> 0`: re-run only when `(forVarMask & changedMask) !== 0`.
376
+ */
377
+ forVarMask?: number;
378
+ }
379
+ //#endregion
380
+ export { ProxySignal as i, Region as n, Computed as r, Effect as t };
381
+ //# sourceMappingURL=Effect-BTKurOpr.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Effect-BTKurOpr.d.mts","names":[],"sources":["../src/types/constants.ts","../src/types/ProxySignal.ts","../src/types/Subscription.ts","../src/types/Computed.ts","../src/types/ErrorBoundary.ts","../src/types/Region.ts","../src/types/Effect.ts"],"mappings":";;;;;cAGa;;;;cAKA;;;;cAKA;;;;;;;UCNY;;;;EAIxB,aAAa;;;;EAKb,aAAa;;;;EAKb,oBAAoB;;;;EAKpB;;;;;;;;UClBwB;;;;EAIxB,QAAQ,cAAc;;;;EAKtB,QAAQ,WAAW;;;;;EAMnB,YAAY;;;;;EAMZ,YAAY;;;;;;;EAQZ,gBAAgB;;;;;;EAOhB;;;;;EAMA;;;;EAKA;;;;;;;;;UC/CwB,SAAS;;;;EAIjC,aAAa;;;;;;;;EASb;;;;EAKA,OAAO;;;;EAKP,WAAW;;;;EAKX,aAAa;;;;EAKb,aAAa;;;;;;;EAQb;;;;EAKA;;;;EAKA;;;;;;;EAQA;;;;;;;EAQA;;;;;;;EAQA;;;;;;;;;EAUA;;;;;;;;;;;;;;;EAgBA;;;;;;;;;;;;;EAcA;;;;EAKA,UAAU;;;;EAKV;;;;;;;;;;UC3HwB;;;;;;EAMxB;;;;;EAMA;;;;;EAMA,QAAQ;;;;;;;;;EAUR,cAAc,cAAc;;;;UCnCJ;EACxB,WAAW;EACX,SAAS;EAET,gBAAgB;EAChB,YAAY;EACZ;;;;;EAMA,YAAY,IAAI;;;;EAKhB;;;;EAKA,SAAS;;;;;;;EAQT,gBAAgB;;;;;;;EAQhB;;;;;;EAOA;;;;;;;UCtCwB;;;;EAIxB,aAAa;;;;;EAMb,WAAW;;;;EAKX,SAAS;;;;EAKT,aAAa;EAKb,YAAY;;;;EAKZ;;;;;;EAOA;;;;EAKA;;;;;;;EAQA;;;;;;;;;;EAWA,iBAAiB,IAAI;;;;EAKrB;;;;;;EAOA,SAAS;;;;;;EAOT,gBAAgB,cAAc;;;;;;;;;EAU9B;;;;;;;;;;;;;;;;EAiBA"}