r-state-tree 0.4.6 → 0.4.7

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/dist/api.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { Snapshot, SnapshotDiff } from "./types";
2
- import Store from "./store/Store";
3
- import Model from "./model/Model";
1
+ import type { Snapshot, SnapshotDiff } from "./types";
2
+ import type Store from "./store/Store";
3
+ import type Model from "./model/Model";
4
4
  export declare function mount<T extends Store>(container: T): T;
5
5
  export declare function unmount<S extends Store>(container: S): void;
6
6
  export declare function toSnapshot<T extends Model>(model: T): Snapshot<T>;
@@ -1,2 +1,2 @@
1
- import { ComputedNode } from "./observables";
1
+ import type { ComputedNode } from "./observables";
2
2
  export default function <T extends Record<PropertyKey, any>>(computed: ComputedNode<T>): T;
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import Model from "./model/Model";
4
4
  import { mount, unmount, onSnapshot, toSnapshot, applySnapshot, onSnapshotDiff } from "./api";
5
5
  import { createContext } from "./context";
6
6
  export { createStore, Store, Model, mount, unmount, updateStore, onSnapshot, onSnapshotDiff, toSnapshot, applySnapshot, createContext, };
7
- export { observable, computed, source, reportChanged, reportObserved, getSignal, isObservable, reaction, Signal, ReadonlySignal, batch, untracked, effect, Observable, signal, } from "./observables";
7
+ export { observable, computed, source, reportChanged, reportObserved, getSignal, isObservable, reaction, Signal, type ReadonlySignal, batch, untracked, effect, Observable, signal, } from "./observables";
8
8
  export * from "./decorators";
9
9
  export type { Configuration, Snapshot, IdType, SnapshotDiff } from "./types";
10
10
  export type { Context } from "./context";
@@ -1,4 +1,4 @@
1
- import { ModelConfiguration, Snapshot } from "../types";
1
+ import type { ModelConfiguration, Snapshot } from "../types";
2
2
  type ExtractModelDidInitArgs<T extends Model> = T extends {
3
3
  modelDidInit(...args: infer Args): unknown;
4
4
  } ? Args extends [infer Snapshot, ...infer Rest] ? Rest : [] : [];
@@ -1,6 +1,7 @@
1
- import { PreactObjectAdministration, ComputedNode, AtomNode } from "../observables";
1
+ import { PreactObjectAdministration } from "../observables";
2
+ import type { ComputedNode, AtomNode } from "../observables";
2
3
  import Model from "../model/Model";
3
- import { ModelConfiguration, Snapshot, SnapshotChange } from "../types";
4
+ import type { ModelConfiguration, Snapshot, SnapshotChange } from "../types";
4
5
  export declare function getConfigurationFromSnapshot(snapshot: object): ModelConfiguration<unknown> | undefined;
5
6
  export declare function getModelAdm<T extends Model>(model: T): ModelAdministration;
6
7
  export declare class ModelAdministration extends PreactObjectAdministration<any> {
@@ -1,5 +1,5 @@
1
- import { IdType } from "../types";
2
- import Model from "./Model";
1
+ import type { IdType } from "../types";
2
+ import type Model from "./Model";
3
3
  export declare function onSnapshotLoad<T>(fn: () => T): T;
4
4
  export declare function setIdentifier(model: Model, id: string | number): void;
5
5
  export declare function getIdentifier(model: Model): IdType | undefined;
@@ -1,4 +1,4 @@
1
- import { AtomNode } from "./preact";
1
+ import type { AtomNode } from "./preact";
2
2
  import { Administration } from "./internal/Administration";
3
3
  import { SignalMap } from "./internal/NodeMap";
4
4
  export declare class ArrayAdministration<T> extends Administration<T[]> {
@@ -1,4 +1,4 @@
1
- import { AtomNode } from "./preact";
1
+ import type { AtomNode } from "./preact";
2
2
  import { Administration } from "./internal/Administration";
3
3
  import { AtomMap, SignalMap } from "./internal/NodeMap";
4
4
  type Collection<K, V> = Set<K> | Map<K, V>;
@@ -3,4 +3,4 @@ export { ArrayAdministration } from "./array";
3
3
  export { CollectionAdministration } from "./collection";
4
4
  export { DateAdministration } from "./date";
5
5
  export { ObjectAdministration } from "./object";
6
- export { AtomNode, reaction, SignalNode, createAtom, batch, createComputed, createSignal, untracked, ListenerNode, createListener, ComputedNode, PreactObjectAdministration, getSignal, source, reportChanged, reportObserved, observable, computed, Signal, ReadonlySignal, effect, signal, Observable, } from "./preact";
6
+ export { type AtomNode, reaction, type SignalNode, createAtom, batch, createComputed, createSignal, untracked, type ListenerNode, createListener, type ComputedNode, PreactObjectAdministration, getSignal, source, reportChanged, reportObserved, observable, computed, Signal, type ReadonlySignal, effect, signal, Observable, } from "./preact";
@@ -1,5 +1,5 @@
1
- import { ObservedAtomNode } from "../preact";
2
- import { SignalMap } from "./NodeMap";
1
+ import type { ObservedAtomNode } from "../preact";
2
+ import type { SignalMap } from "./NodeMap";
3
3
  export declare class Administration<T extends object = any> {
4
4
  static readonly proxyTraps: ProxyHandler<object>;
5
5
  readonly proxy: T;
@@ -1,4 +1,4 @@
1
- import { AtomNode, ObservedAtomNode, SignalNode } from "../preact";
1
+ import type { AtomNode, ObservedAtomNode, SignalNode } from "../preact";
2
2
  declare class NodeMap<K = unknown, GraphNode extends AtomNode | SignalNode<unknown> = AtomNode | SignalNode<unknown>> {
3
3
  private map;
4
4
  private weakMap;
@@ -2,7 +2,7 @@ import { CollectionAdministration } from "../collection";
2
2
  import { PreactObjectAdministration } from "../preact";
3
3
  import { ArrayAdministration } from "../array";
4
4
  import { DateAdministration } from "../date";
5
- import { Administration } from "./Administration";
5
+ import type { Administration } from "./Administration";
6
6
  export declare function getAdministration<T extends object>(obj: T): T extends Set<infer S> ? CollectionAdministration<S> : T extends Map<infer K, infer V> ? CollectionAdministration<K, V> : T extends Array<infer R> ? ArrayAdministration<R> : T extends Date ? DateAdministration : PreactObjectAdministration<any>;
7
7
  export declare function getSource<T>(obj: T): T;
8
8
  export declare function getAction<T extends Function>(fn: T): T;
@@ -1,4 +1,4 @@
1
- import { AtomNode, ComputedNode, SignalNode } from "../preact";
1
+ import type { AtomNode, ComputedNode, SignalNode } from "../preact";
2
2
  export declare function defaultEquals<T>(a: T, b: T): boolean;
3
3
  export declare function isNonPrimitive(val: unknown): val is object;
4
4
  export declare function isPropertyKey(val: unknown): val is string | number | symbol;
@@ -1,5 +1,5 @@
1
- import { AtomNode, ComputedNode } from "./preact";
2
- import { PropertyType } from "./internal/utils";
1
+ import type { AtomNode, ComputedNode } from "./preact";
2
+ import type { PropertyType } from "./internal/utils";
3
3
  import { Administration } from "./internal/Administration";
4
4
  import { AtomMap, SignalMap } from "./internal/NodeMap";
5
5
  export declare class ObjectAdministration<T extends object> extends Administration<T> {
@@ -1,4 +1,5 @@
1
- import { signal, Signal, ReadonlySignal, batch, effect, untracked } from "@preact/signals-core";
1
+ import { signal, Signal, batch, effect, untracked } from "@preact/signals-core";
2
+ import type { ReadonlySignal } from "@preact/signals-core";
2
3
  import { ObjectAdministration } from "./object";
3
4
  export { isObservable } from "./index";
4
5
  export declare class PreactObjectAdministration<T extends object> extends ObjectAdministration<T> {
@@ -39,7 +40,8 @@ export declare function createObservedAtom(): {
39
40
  };
40
41
  export declare function createSignal<T>(initialValue: T): SignalNode<T>;
41
42
  export declare function createAtom(): AtomNode;
42
- export { effect, signal, batch, untracked, Signal, ReadonlySignal };
43
+ export { effect, signal, batch, untracked, Signal };
44
+ export type { ReadonlySignal };
43
45
  export declare function reaction<T>(fn: () => T, callback: (value: T) => void): () => void;
44
46
  export type Listener = {
45
47
  dispose: () => void;
@@ -2485,10 +2485,6 @@ const modelRef = makeChildDecorator(modelRefType);
2485
2485
  const model = makeDecorator(modelType);
2486
2486
  const id = makeDecorator(idType);
2487
2487
  const state = makeDecorator(stateType);
2488
- Object.defineProperty(exports, "ReadonlySignal", {
2489
- enumerable: true,
2490
- get: () => signalsCore.ReadonlySignal
2491
- });
2492
2488
  Object.defineProperty(exports, "Signal", {
2493
2489
  enumerable: true,
2494
2490
  get: () => signalsCore.Signal
@@ -1,5 +1,5 @@
1
1
  import { batch, Signal, signal, computed as computed$1, untracked, effect } from "@preact/signals-core";
2
- import { ReadonlySignal, Signal as Signal2, batch as batch2, effect as effect2, signal as signal2, untracked as untracked2 } from "@preact/signals-core";
2
+ import { Signal as Signal2, batch as batch2, effect as effect2, signal as signal2, untracked as untracked2 } from "@preact/signals-core";
3
3
  var lib = {};
4
4
  var hasRequiredLib;
5
5
  function requireLib() {
@@ -2487,7 +2487,6 @@ const state = makeDecorator(stateType);
2487
2487
  export {
2488
2488
  Model,
2489
2489
  Observable,
2490
- ReadonlySignal,
2491
2490
  Signal2 as Signal,
2492
2491
  Store,
2493
2492
  applySnapshot,
@@ -1,4 +1,4 @@
1
- import { Props, StoreProps, StoreConfiguration } from "../types";
1
+ import type { Props, StoreProps, StoreConfiguration } from "../types";
2
2
  export declare function allowNewStore<T>(fn: () => T): T;
3
3
  type CreateStoreProps<T extends Record<string, any>> = {
4
4
  [K in keyof T as undefined extends T[K] ? K : never]?: T[K] extends infer U ? U extends undefined ? never : undefined extends U ? U | undefined : U : never;
@@ -1,6 +1,6 @@
1
1
  import { PreactObjectAdministration as ObjectAdministration } from "../observables";
2
- import Store from "./Store";
3
- import { StoreConfiguration, Props } from "../types";
2
+ import type Store from "./Store";
3
+ import type { StoreConfiguration, Props } from "../types";
4
4
  export declare function updateProps(props: Props, newProps: Props): void;
5
5
  export declare function getStoreAdm(store: Store): StoreAdministration;
6
6
  export declare class StoreAdministration<StoreType extends Store = Store> extends ObjectAdministration<Store> {
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import Store from "./store/Store";
2
- import Model from "./model/Model";
1
+ import type Store from "./store/Store";
2
+ import type Model from "./model/Model";
3
3
  export type StoreElement = {
4
4
  Type: new (...args: unknown[]) => Store;
5
5
  props: Props;
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ModelConfiguration } from "./types";
1
+ import type { ModelConfiguration } from "./types";
2
2
  export declare function getPropertyDescriptor(obj: object, key: PropertyKey): PropertyDescriptor | undefined;
3
3
  export declare function getParentConstructor(Ctor: Function | undefined): Function | undefined;
4
4
  export declare function clone<T>(val: T): T;
package/package.json CHANGED
@@ -1,59 +1,58 @@
1
1
  {
2
- "name": "r-state-tree",
3
- "version": "0.4.6",
4
- "description": "reactive state management library",
5
- "main": "dist/r-state-tree.cjs",
6
- "module": "dist/r-state-tree.js",
7
- "types": "dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/r-state-tree.js",
12
- "require": "./dist/r-state-tree.cjs"
13
- }
14
- },
15
- "files": [
16
- "dist/*",
17
- "README.md",
18
- "LICENSE"
19
- ],
20
- "scripts": {
21
- "test": "vitest run",
22
- "test:watch": "vitest",
23
- "test:cover": "vitest run --coverage",
24
- "build": "vite build && pnpm run build:types",
25
- "build:types": "tsc --emitDeclarationOnly",
26
- "lint": "eslint ./src ./tests --ext .ts",
27
- "format": "prettier --cache --write \"src/**/*.ts\" \"tests/**/*.ts\"",
28
- "prepublishOnly": "pnpm run build"
29
- },
30
- "repository": {
31
- "type": "git",
32
- "url": "git+https://github.com/melnikov-s/r-state-tree.git"
33
- },
34
- "author": "Sergey Melnikov",
35
- "license": "MIT",
36
- "bugs": {
37
- "url": "https://github.com/melnikov-s/r-state-tree/issues"
38
- },
39
- "homepage": "https://github.com/melnikov-s/r-state-tree#readme",
40
- "devDependencies": {
41
- "@tsmetadata/polyfill": "^1.1.3",
42
- "@typescript-eslint/eslint-plugin": "^5.8.1",
43
- "@typescript-eslint/parser": "^5.8.1",
44
- "eslint": "^8.5.0",
45
- "eslint-config-airbnb": "^19.0.4",
46
- "eslint-config-prettier": "^8.3.0",
47
- "eslint-import-resolver-typescript": "^2.5.0",
48
- "eslint-plugin-import": "^2.25.3",
49
- "eslint-plugin-prettier": "^4.0.0",
50
- "prettier": "^2.8.4",
51
- "tslib": "^2.5.0",
52
- "typescript": "5.9.3",
53
- "vite": "7.1.9",
54
- "vitest": "3.2.4"
55
- },
56
- "dependencies": {
57
- "@preact/signals-core": "^1.12.1"
58
- }
59
- }
2
+ "name": "r-state-tree",
3
+ "version": "0.4.7",
4
+ "description": "reactive state management library",
5
+ "main": "dist/r-state-tree.cjs",
6
+ "module": "dist/r-state-tree.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/r-state-tree.js",
12
+ "require": "./dist/r-state-tree.cjs"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist/*",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/melnikov-s/r-state-tree.git"
23
+ },
24
+ "author": "Sergey Melnikov",
25
+ "license": "MIT",
26
+ "bugs": {
27
+ "url": "https://github.com/melnikov-s/r-state-tree/issues"
28
+ },
29
+ "homepage": "https://github.com/melnikov-s/r-state-tree#readme",
30
+ "devDependencies": {
31
+ "@tsmetadata/polyfill": "^1.1.3",
32
+ "@typescript-eslint/eslint-plugin": "^5.8.1",
33
+ "@typescript-eslint/parser": "^5.8.1",
34
+ "eslint": "^8.5.0",
35
+ "eslint-config-airbnb": "^19.0.4",
36
+ "eslint-config-prettier": "^8.3.0",
37
+ "eslint-import-resolver-typescript": "^2.5.0",
38
+ "eslint-plugin-import": "^2.25.3",
39
+ "eslint-plugin-prettier": "^4.0.0",
40
+ "prettier": "^2.8.4",
41
+ "tslib": "^2.5.0",
42
+ "typescript": "5.9.3",
43
+ "vite": "7.1.9",
44
+ "vitest": "3.2.4"
45
+ },
46
+ "dependencies": {
47
+ "@preact/signals-core": "^1.12.1"
48
+ },
49
+ "scripts": {
50
+ "test": "vitest run",
51
+ "test:watch": "vitest",
52
+ "test:cover": "vitest run --coverage",
53
+ "build": "vite build && pnpm run build:types",
54
+ "build:types": "tsc --emitDeclarationOnly",
55
+ "lint": "eslint ./src ./tests --ext .ts",
56
+ "format": "prettier --cache --write \"src/**/*.ts\" \"tests/**/*.ts\""
57
+ }
58
+ }