preact-sigma 6.2.0 → 6.2.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.
package/README.md CHANGED
@@ -49,7 +49,4 @@ console.log(counter.doubled); // 2
49
49
  - Persistence-specific guidance lives in [`docs/persist.md`](./docs/persist.md).
50
50
  - Migration guidance from v5 lives in [`docs/migrations/v5-to-v6.md`](./docs/migrations/v5-to-v6.md).
51
51
  - Runnable usage patterns live in [`examples/`](./examples/).
52
- - [`examples/basic-counter.ts`](./examples/basic-counter.ts)
53
- - [`examples/command-palette.tsx`](./examples/command-palette.tsx)
54
- - [`examples/external-query-sync.tsx`](./examples/external-query-sync.tsx)
55
52
  - Exact exported signatures and public API comments live in `dist/index.d.mts` and `dist/persist.d.mts` after `pnpm build`.
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as SigmaRef, c as castProtected, d as sigma, f as Draft, h as Cleanup, i as SigmaDefinition, l as query, m as typeSymbol, n as ReadableSigma, o as SigmaState, p as Immutable, r as Sigma, s as SigmaTarget, t as Protected, u as setAutoFreeze } from "./sigma-BfaJUPWw.mjs";
1
+ import { a as SigmaRef, c as castProtected, d as sigma, f as Draft, h as Cleanup, i as SigmaDefinition, l as query, m as typeSymbol, n as ReadableSigma, o as SigmaState, p as Immutable, r as Sigma, s as SigmaTarget, t as Protected, u as setAutoFreeze } from "./sigma-cb2HeDjg.mjs";
2
2
 
3
3
  //#region src/defaults.d.ts
4
4
  /**
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as setAutoFreeze, c as listenersSymbol, i as query, n as SigmaTarget, o as sigma, r as castProtected, s as isPlainObject, t as Sigma } from "./sigma-DEKK3bHd.mjs";
1
+ import { a as setAutoFreeze, c as listenersSymbol, i as query, n as SigmaTarget, o as sigma, r as castProtected, s as isPlainObject, t as Sigma } from "./sigma-B7kPkW-M.mjs";
2
2
  import { useEffect, useRef } from "preact/hooks";
3
3
  //#region src/defaults.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { n as ReadableSigma, p as Immutable, r as Sigma } from "./sigma-BfaJUPWw.mjs";
1
+ import { n as ReadableSigma, p as Immutable, r as Sigma } from "./sigma-cb2HeDjg.mjs";
2
2
 
3
3
  //#region src/persist.d.ts
4
4
  type MaybePromise<T> = T | Promise<T>;
package/dist/persist.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { o as sigma, s as isPlainObject } from "./sigma-DEKK3bHd.mjs";
1
+ import { o as sigma, s as isPlainObject } from "./sigma-B7kPkW-M.mjs";
2
2
  //#region src/persist.ts
3
3
  function createIdentityCodec() {
4
4
  return {
@@ -418,22 +418,23 @@ var SigmaTarget = class SigmaTarget extends Sigma {
418
418
  /** Helpers for observing, accessing, capturing, and replacing committed sigma state. */
419
419
  const sigma = /* @__PURE__ */ Object.freeze({
420
420
  subscribe: ((instance, keyOrListener, listenerOrOptions) => {
421
+ const source = instance;
421
422
  if (typeof keyOrListener === "string") {
422
- const signal = getStateSignal(instance, keyOrListener);
423
+ const signal = getStateSignal(source, keyOrListener);
423
424
  if (!signal) throw new Error(`[preact-sigma] Property named "${keyOrListener}" is not signal-backed.`);
424
425
  return signal.subscribe(listenerOrOptions);
425
426
  }
426
427
  const listener = keyOrListener;
427
428
  if (listenerOrOptions?.patches) patchListeners.add(listener);
428
- let subscriptions = changeListenersMap.get(instance);
429
+ let subscriptions = changeListenersMap.get(source);
429
430
  if (!subscriptions) {
430
431
  subscriptions = /* @__PURE__ */ new Set();
431
- changeListenersMap.set(instance, subscriptions);
432
+ changeListenersMap.set(source, subscriptions);
432
433
  }
433
434
  subscriptions.add(listener);
434
435
  return () => {
435
436
  subscriptions.delete(listener);
436
- if (!subscriptions.size) changeListenersMap.delete(instance);
437
+ if (!subscriptions.size) changeListenersMap.delete(source);
437
438
  };
438
439
  }),
439
440
  getSignal(instance, key) {
@@ -141,14 +141,14 @@ declare class SigmaTarget<TEvents extends object = {}, TState extends object = {
141
141
  /** Helpers for observing, accessing, capturing, and replacing committed sigma state. */
142
142
  declare const sigma: Readonly<{
143
143
  /** Subscribes to committed state publishes or to one signal-backed top-level state key. */subscribe: {
144
- <TState extends object>(instance: Sigma<TState>, listener: (nextState: Immutable<TState>, baseState: Immutable<TState>, patches: Patch[], inversePatches: Patch[]) => void, options: {
144
+ <TState extends object>(instance: ReadableSigma<TState>, listener: (nextState: Immutable<TState>, baseState: Immutable<TState>, patches: Patch[], inversePatches: Patch[]) => void, options: {
145
145
  patches: true;
146
146
  }): Cleanup;
147
- <TState extends object>(instance: Sigma<TState>, listener: (nextState: Immutable<TState>, baseState: Immutable<TState>, patches: Patch[] | undefined, inversePatches: Patch[] | undefined) => void, options: {
147
+ <TState extends object>(instance: ReadableSigma<TState>, listener: (nextState: Immutable<TState>, baseState: Immutable<TState>, patches: Patch[] | undefined, inversePatches: Patch[] | undefined) => void, options: {
148
148
  patches: boolean;
149
149
  }): Cleanup;
150
- <TState extends object>(instance: Sigma<TState>, listener: (nextState: Immutable<TState>, baseState: Immutable<TState>) => void): Cleanup;
151
- <TState extends object, TKey extends Extract<keyof TState, string>>(instance: Sigma<TState>, key: TKey, listener: (value: Immutable<TState[TKey]>) => void): Cleanup;
150
+ <TState extends object>(instance: ReadableSigma<TState>, listener: (nextState: Immutable<TState>, baseState: Immutable<TState>) => void): Cleanup;
151
+ <TState extends object, TKey extends Extract<keyof TState, string>>(instance: ReadableSigma<TState>, key: TKey, listener: (value: Immutable<TState[TKey]>) => void): Cleanup;
152
152
  }; /** Returns the readonly signal backing one top-level state key. */
153
153
  getSignal<TState extends object, TKey extends Extract<keyof TState, string>>(instance: Sigma<TState>, key: TKey): ReadonlySignal<Immutable<TState[TKey]>>; /** Captures the current committed top-level state snapshot. */
154
154
  captureState<TState extends object>(instance: ReadableSigma<TState>): Immutable<TState>; /** Publishes a plain-object snapshot, including readonly captured snapshots, as committed state. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "preact-sigma",
3
- "version": "6.2.0",
3
+ "version": "6.2.1",
4
4
  "keywords": [],
5
5
  "license": "MIT",
6
6
  "author": "Alec Larson",