preact-sigma 3.0.2 → 4.0.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.
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  ## Installation
8
8
 
9
9
  ```bash
10
- npm install preact-sigma
10
+ npm install preact-sigma @preact/signals immer preact
11
11
  ```
12
12
 
13
13
  ## Quick Example
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { ReadonlySignal, action, batch, computed, effect, untracked } from "@preact/signals";
2
- import { Patch, freeze, immerable } from "immer";
1
+ import { ReadonlySignal } from "@preact/signals";
2
+ import { Patch } from "immer";
3
3
 
4
4
  //#region src/internal/symbols.d.ts
5
5
  declare const signalPrefix = "#";
@@ -342,4 +342,4 @@ declare function useSigma<T extends AnySigmaState>(create: () => T, setupArgs?:
342
342
  */
343
343
  declare function useListener<TTarget extends EventTarget | AnySigmaState, TEvent extends InferEventType<TTarget>>(target: TTarget | null, name: TEvent, listener: InferListener<TTarget, TEvent>): void;
344
344
  //#endregion
345
- export { type AnyDefaultState, type AnyEvents, type AnyResource, type AnySigmaState, type AnySigmaStateWithEvents, type AnyState, EventParameters, InferEventType, InferListener, type InferSetupArgs, type SigmaObserveChange, type SigmaObserveOptions, type SigmaRef, type SigmaState, SigmaTarget, SigmaType, action, batch, computed, effect, freeze, immerable, isSigmaState, listen, query, replaceState, reservedKeys, setAutoFreeze, sigmaEventsBrand, sigmaRefBrand, sigmaStateBrand, sigmaTypeBrand, signalPrefix, snapshot, untracked, useListener, useSigma };
345
+ export { type AnyDefaultState, type AnyEvents, type AnyResource, type AnySigmaState, type AnySigmaStateWithEvents, type AnyState, EventParameters, InferEventType, InferListener, type InferSetupArgs, type SigmaObserveChange, type SigmaObserveOptions, type SigmaRef, type SigmaState, SigmaTarget, SigmaType, isSigmaState, listen, query, replaceState, reservedKeys, setAutoFreeze, sigmaEventsBrand, sigmaRefBrand, sigmaStateBrand, sigmaTypeBrand, signalPrefix, snapshot, useListener, useSigma };
package/dist/index.mjs CHANGED
@@ -1,6 +1,5 @@
1
- import { action, batch, batch as batch$1, computed, computed as computed$1, effect, signal, untracked, untracked as untracked$1 } from "@preact/signals";
1
+ import { batch, computed, signal, untracked } from "@preact/signals";
2
2
  import * as immer from "immer";
3
- import { freeze, immerable } from "immer";
4
3
  import { useEffect, useRef, useState } from "preact/hooks";
5
4
  //#region src/internal/context.ts
6
5
  const disabledContextOptions = {
@@ -232,7 +231,7 @@ function initializeSigmaInstance(publicInstance, type, initialState) {
232
231
  enumerable: true
233
232
  });
234
233
  }
235
- for (const key in type._computeFunctions) Object.defineProperty(publicInstance, "#" + key, { value: computed$1(() => type._computeFunctions[key].call(getContext(instance, "computedReadonly"))) });
234
+ for (const key in type._computeFunctions) Object.defineProperty(publicInstance, "#" + key, { value: computed(() => type._computeFunctions[key].call(getContext(instance, "computedReadonly"))) });
236
235
  registerSigmaInternals(publicInstance, instance);
237
236
  }
238
237
  function buildQueryMethod(queryFunction) {
@@ -240,7 +239,7 @@ function buildQueryMethod(queryFunction) {
240
239
  const instance = getSigmaInternals(this);
241
240
  const owner = getContextOwner(this);
242
241
  if (owner) return queryFunction.apply(getContext(owner, "queryDraftAware"), args);
243
- return computed$1(() => queryFunction.apply(getContext(instance, "queryCommitted"), args)).value;
242
+ return computed(() => queryFunction.apply(getContext(instance, "queryCommitted"), args)).value;
244
243
  };
245
244
  }
246
245
  function buildActionMethod(actionName, actionFn) {
@@ -311,7 +310,7 @@ function runActionInvocation(context, actionName, actionFn, args) {
311
310
  const isAdHocAction = actionName === "act()";
312
311
  const actionIsAsync = isAsyncFunction(actionFn);
313
312
  if (actionIsAsync && isAdHocAction) throw new Error("[preact-sigma] act() callbacks must stay synchronous");
314
- return untracked$1(() => {
313
+ return untracked(() => {
315
314
  let owner;
316
315
  const callerOwner = getContextOwner(context);
317
316
  if (callerOwner && callerOwner.instance === instance && !actionIsAsync) owner = callerOwner;
@@ -432,7 +431,7 @@ function isPromiseLike(value) {
432
431
  return value != null && typeof value.then === "function";
433
432
  }
434
433
  function publishState(instance, finalized) {
435
- batch$1(() => {
434
+ batch(() => {
436
435
  for (const key of instance.stateKeys) {
437
436
  const nextValue = finalized.newState[key];
438
437
  if (isAutoFreeze()) immer.freeze(nextValue, true);
@@ -548,7 +547,7 @@ function isSigmaState(value) {
548
547
  * that do not need to live on the sigma-state instance.
549
548
  */
550
549
  function query(fn) {
551
- return ((...args) => computed$1(() => fn(...args)).value);
550
+ return ((...args) => computed(() => fn(...args)).value);
552
551
  }
553
552
  /**
554
553
  * Builds sigma-state constructors by accumulating default state, computeds,
@@ -738,4 +737,4 @@ function useListener(target, name, listener) {
738
737
  }, [target, name]);
739
738
  }
740
739
  //#endregion
741
- export { SigmaTarget, SigmaType, action, batch, computed, effect, freeze, immerable, isSigmaState, listen, query, replaceState, setAutoFreeze, snapshot, untracked, useListener, useSigma };
740
+ export { SigmaTarget, SigmaType, isSigmaState, listen, query, replaceState, setAutoFreeze, snapshot, useListener, useSigma };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "preact-sigma",
3
- "version": "3.0.2",
3
+ "version": "4.0.0",
4
4
  "keywords": [],
5
5
  "license": "MIT",
6
6
  "author": "Alec Larson",
@@ -20,11 +20,6 @@
20
20
  "import": "./dist/index.mjs"
21
21
  }
22
22
  },
23
- "dependencies": {
24
- "@preact/signals": "^2.8.2",
25
- "immer": "^11.1.4",
26
- "preact": "11.0.0-beta.1"
27
- },
28
23
  "devDependencies": {
29
24
  "@preact/preset-vite": "^2.10.5",
30
25
  "@types/node": "^25.5.0",
@@ -38,6 +33,11 @@
38
33
  "vite": "^8.0.2",
39
34
  "vitest": "^4.1.1"
40
35
  },
36
+ "peerDependencies": {
37
+ "@preact/signals": ">=2",
38
+ "immer": ">=11",
39
+ "preact": ">=10"
40
+ },
41
41
  "scripts": {
42
42
  "build": "tsdown",
43
43
  "test": "vitest run",