@reckona/mreact-reactive-core 0.0.135 → 0.0.137

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.
package/README.md CHANGED
@@ -38,6 +38,20 @@ dispose();
38
38
  - `batchAsync()` groups updates across `await` points into one flush. Use it only around intentionally scoped async work because reactive flushes are deferred until the callback settles.
39
39
  - `untrack()` reads values without subscribing.
40
40
 
41
+ ## Update Scheduling
42
+
43
+ `cell.set()` updates the stored value immediately and propagates `computed` invalidation synchronously, but effects (including the DOM bindings emitted by the compiler) run in a single microtask scheduled at the first update. Reads through `.get()` always observe the latest value even before that flush runs.
44
+
45
+ Because browsers drain the microtask queue before any rendering steps, this scheduling is compatible with `document.startViewTransition()`: a `cell.set()` made inside the update callback is committed to the DOM before the browser captures the new-state snapshot, so no `flushSync` wrapper is required.
46
+
47
+ ```ts
48
+ document.startViewTransition(() => {
49
+ selectedMediaId.set(mediaId);
50
+ });
51
+ ```
52
+
53
+ If you need the DOM committed synchronously before the current task continues, for example to measure layout right after an update, wrap the update in `flushSync` from the React DOM-compatible entrypoint (`react-dom` in mreact apps, `@reckona/mreact-dom` standalone), which drains pending reactive computations before returning. Updates deferred through `startTransition` or `useDeferredValue` run on a macrotask scheduler and are not guaranteed to land inside a view transition capture.
54
+
41
55
  ## Testing
42
56
 
43
57
  `@reckona/mreact-reactive-core/testing` exports `flushMicrotasks()` and
@@ -1,5 +1,6 @@
1
1
  export type { Scheduler } from "./scheduler.js";
2
2
  export { registerCleanup, withCleanupScope } from "./cleanup-scope.js";
3
3
  export { flushQueuedComputations, schedulePendingFlush, setScheduler } from "./scheduler.js";
4
+ export { flushPendingComputed } from "./tracking.js";
4
5
  export { getGlobalRuntimeState } from "./runtime-state.js";
5
6
  //# sourceMappingURL=internal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC7F,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC7F,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/internal.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { registerCleanup, withCleanupScope } from "./cleanup-scope.js";
2
2
  export { flushQueuedComputations, schedulePendingFlush, setScheduler } from "./scheduler.js";
3
+ export { flushPendingComputed } from "./tracking.js";
3
4
  export { getGlobalRuntimeState } from "./runtime-state.js";
4
5
  //# sourceMappingURL=internal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC7F,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export type { Scheduler } from \"./scheduler.js\";\nexport { registerCleanup, withCleanupScope } from \"./cleanup-scope.js\";\nexport { flushQueuedComputations, schedulePendingFlush, setScheduler } from \"./scheduler.js\";\nexport { getGlobalRuntimeState } from \"./runtime-state.js\";\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC7F,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export type { Scheduler } from \"./scheduler.js\";\nexport { registerCleanup, withCleanupScope } from \"./cleanup-scope.js\";\nexport { flushQueuedComputations, schedulePendingFlush, setScheduler } from \"./scheduler.js\";\nexport { flushPendingComputed } from \"./tracking.js\";\nexport { getGlobalRuntimeState } from \"./runtime-state.js\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reckona/mreact-reactive-core",
3
- "version": "0.0.135",
3
+ "version": "0.0.137",
4
4
  "description": "Fine-grained reactive primitives used across mreact.",
5
5
  "keywords": [
6
6
  "jsx",
package/src/internal.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export type { Scheduler } from "./scheduler.js";
2
2
  export { registerCleanup, withCleanupScope } from "./cleanup-scope.js";
3
3
  export { flushQueuedComputations, schedulePendingFlush, setScheduler } from "./scheduler.js";
4
+ export { flushPendingComputed } from "./tracking.js";
4
5
  export { getGlobalRuntimeState } from "./runtime-state.js";