@anchorlib/svelte 1.0.0-beta.18 → 1.0.0-beta.19

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 (58) hide show
  1. package/dist/anchor.d.ts +6 -4
  2. package/dist/anchor.js +57 -8
  3. package/dist/core/index.d.ts +1 -1
  4. package/dist/core/index.js +1 -3
  5. package/dist/derive.d.ts +5 -3
  6. package/dist/derive.js +30 -22
  7. package/dist/fetch.d.ts +11 -9
  8. package/dist/fetch.js +6 -6
  9. package/dist/history.d.ts +5 -3
  10. package/dist/history.js +12 -5
  11. package/dist/immutable.d.ts +5 -3
  12. package/dist/immutable.js +8 -6
  13. package/dist/index.d.ts +12 -11
  14. package/dist/index.js +13 -14
  15. package/dist/model.d.ts +6 -4
  16. package/dist/model.js +14 -6
  17. package/dist/observable.d.ts +5 -3
  18. package/dist/observable.js +32 -24
  19. package/dist/prop.d.ts +7 -8
  20. package/dist/prop.js +15 -5
  21. package/dist/reactive.d.ts +4 -3
  22. package/dist/reactive.js +45 -40
  23. package/dist/ref.d.ts +4 -3
  24. package/dist/ref.js +58 -26
  25. package/dist/storage/index.d.ts +7 -8
  26. package/dist/storage/index.js +9 -9
  27. package/dist/storage/kv.d.ts +5 -3
  28. package/dist/storage/kv.js +22 -10
  29. package/dist/storage/persistent.d.ts +5 -3
  30. package/dist/storage/persistent.js +23 -10
  31. package/dist/storage/session.d.ts +5 -3
  32. package/dist/storage/session.js +23 -10
  33. package/dist/storage/table.d.ts +6 -4
  34. package/dist/storage/table.js +42 -41
  35. package/dist/storage/types.d.ts +12 -11
  36. package/dist/storage/types.js +0 -3
  37. package/dist/types.d.ts +6 -5
  38. package/dist/types.js +0 -3
  39. package/package.json +7 -7
  40. package/dist/anchor.js.map +0 -1
  41. package/dist/core/index.js.map +0 -1
  42. package/dist/derive.js.map +0 -1
  43. package/dist/fetch.js.map +0 -1
  44. package/dist/history.js.map +0 -1
  45. package/dist/immutable.js.map +0 -1
  46. package/dist/index.js.map +0 -1
  47. package/dist/model.js.map +0 -1
  48. package/dist/observable.js.map +0 -1
  49. package/dist/prop.js.map +0 -1
  50. package/dist/reactive.js.map +0 -1
  51. package/dist/ref.js.map +0 -1
  52. package/dist/storage/index.js.map +0 -1
  53. package/dist/storage/kv.js.map +0 -1
  54. package/dist/storage/persistent.js.map +0 -1
  55. package/dist/storage/session.js.map +0 -1
  56. package/dist/storage/table.js.map +0 -1
  57. package/dist/storage/types.js.map +0 -1
  58. package/dist/types.js.map +0 -1
package/dist/anchor.d.ts CHANGED
@@ -1,4 +1,6 @@
1
- import { Linkable, LinkableSchema, StateOptions, ModelInput, ModelOutput, Immutable, ModelArray } from '@anchorlib/core';
1
+ import { Immutable, Linkable, LinkableSchema, ModelArray, ModelInput, ModelOutput, StateOptions } from "@anchorlib/core";
2
+
3
+ //#region src/anchor.d.ts
2
4
 
3
5
  /**
4
6
  * @deprecated Use 'mutable()' instead.
@@ -36,7 +38,7 @@ declare function anchorRef<S extends LinkableSchema, T extends ModelInput<S>>(in
36
38
  * @returns A reactive state containing an immutable output model based on the schema
37
39
  */
38
40
  declare function anchorRef<S extends LinkableSchema, T extends ModelInput<S>>(init: T, schema?: S, options?: StateOptions & {
39
- immutable: true;
41
+ immutable: true;
40
42
  }): Immutable<ModelOutput<S>>;
41
43
  /**
42
44
  * @deprecated Use 'mutable()' instead.
@@ -80,5 +82,5 @@ declare function flatRef<T extends unknown[], S extends ModelArray = ModelArray>
80
82
  * @returns A reactive state containing the raw value
81
83
  */
82
84
  declare function rawRef<T extends Linkable, S extends LinkableSchema = LinkableSchema>(init: T, options?: StateOptions<S>): T;
83
-
84
- export { anchorRef, flatRef, orderedRef, rawRef, reactiveRef };
85
+ //#endregion
86
+ export { anchorRef, flatRef, orderedRef, rawRef, reactiveRef };
package/dist/anchor.js CHANGED
@@ -1,19 +1,68 @@
1
- import { anchor } from '@anchorlib/core';
1
+ import { anchor } from "@anchorlib/core";
2
2
 
3
+ //#region src/anchor.ts
4
+ /**
5
+ * @deprecated Use 'mutable()' instead.
6
+ * Creates a reactive state for state management with optional schema validation.
7
+ *
8
+ * @template T - The type of the initial value
9
+ * @template S - The schema type or options
10
+ * @param init - The initial value for the state
11
+ * @param schemaOptions - Either a schema or state options
12
+ * @param options - Additional state options when schema is provided
13
+ * @returns A reactive state containing the managed state
14
+ */
3
15
  function anchorRef(init, schemaOptions, options) {
4
- return anchor(init, schemaOptions, options);
16
+ return anchor(init, schemaOptions, options);
5
17
  }
18
+ /**
19
+ * @deprecated Use 'mutable()' instead.
20
+ * Reactive state alias for anchorRef.
21
+ * @type {{<T, S=LinkableSchema extends LinkableSchema>(init: T, options?: StateOptions<S>): T, <S extends LinkableSchema, T extends ModelInput<S>>(init: T, schema?: S, options?: StateOptions): ModelOutput<S>, <S extends LinkableSchema, T extends ModelInput<S>>(init: T, schema?: S, options?: (StateOptions & {immutable: true})): Immutable<ModelOutput<S>>}}
22
+ */
6
23
  const reactiveRef = anchorRef;
24
+ /**
25
+ * @deprecated Use 'ordered()' instead.
26
+ * Creates a reactive state that maintains a sorted array state based on a comparison function.
27
+ *
28
+ * @template T - The type of elements in the array
29
+ * @template S - The schema type for array elements, extending ModelArray
30
+ * @param init - The initial array value for the state
31
+ * @param compare - A function that defines the sort order of elements
32
+ * @param options - Optional state options for the state
33
+ * @returns A reactive state containing the sorted array
34
+ */
7
35
  function orderedRef(init, compare, options) {
8
- return anchor.ordered(init, compare, options);
36
+ return anchor.ordered(init, compare, options);
9
37
  }
38
+ /**
39
+ * @deprecated Use 'flat()' instead.
40
+ * Creates a reactive state that maintains a flat array state.
41
+ *
42
+ * @template T - The type of elements in the array
43
+ * @template S - The schema type for array elements, extending ModelArray
44
+ * @param init - The initial array value for the state
45
+ * @param options - Optional state options for the state
46
+ * @returns A reactive state containing the flat array
47
+ */
10
48
  function flatRef(init, options) {
11
- return anchor.flat(init, options);
49
+ return anchor.flat(init, options);
12
50
  }
51
+ /**
52
+ * @deprecated Use 'raw()' instead.
53
+ * Creates a reactive state that mutates the underlying object.
54
+ *
55
+ * Unless you set the global options to `cloned: true`, you don't want to use this.
56
+ *
57
+ * @template T - The type of the initial value
58
+ * @template S - The schema type, extending LinkableSchema
59
+ * @param init - The initial value for the state
60
+ * @param options - Optional state options for the state
61
+ * @returns A reactive state containing the raw value
62
+ */
13
63
  function rawRef(init, options) {
14
- return anchor.raw(init, options);
64
+ return anchor.raw(init, options);
15
65
  }
16
66
 
17
- export { anchorRef, flatRef, orderedRef, rawRef, reactiveRef };
18
- //# sourceMappingURL=anchor.js.map
19
- //# sourceMappingURL=anchor.js.map
67
+ //#endregion
68
+ export { anchorRef, flatRef, orderedRef, rawRef, reactiveRef };
@@ -1 +1 @@
1
- export * from '@anchorlib/core';
1
+ export * from "@anchorlib/core";
@@ -1,3 +1 @@
1
- export * from '@anchorlib/core';
2
- //# sourceMappingURL=index.js.map
3
- //# sourceMappingURL=index.js.map
1
+ export * from "@anchorlib/core"
package/dist/derive.d.ts CHANGED
@@ -1,4 +1,6 @@
1
- import { ConstantRef } from './types.js';
1
+ import { ConstantRef } from "./types.js";
2
+
3
+ //#region src/derive.d.ts
2
4
 
3
5
  /**
4
6
  * @deprecated Use `derived()` instead.
@@ -11,5 +13,5 @@ import { ConstantRef } from './types.js';
11
13
  * @returns A read-only reference containing the derived state value
12
14
  */
13
15
  declare function derivedRef<T, R>(state: T, derive: (current: T) => R): ConstantRef<R>;
14
-
15
- export { derivedRef };
16
+ //#endregion
17
+ export { derivedRef };
package/dist/derive.js CHANGED
@@ -1,26 +1,34 @@
1
- import { anchor, subscribe } from '@anchorlib/core';
2
- import { onDestroy } from 'svelte';
3
- import { REF_REGISTRY } from './ref.js';
1
+ import { REF_REGISTRY } from "./ref.js";
2
+ import { anchor, subscribe } from "@anchorlib/core";
3
+ import { onDestroy } from "svelte";
4
4
 
5
+ //#region src/derive.ts
6
+ /**
7
+ * @deprecated Use `derived()` instead.
8
+ * Creates a derived state from a source state with an optional transformation.
9
+ *
10
+ * @template T - The type of the input state
11
+ * @template R - The type of the transformed output
12
+ * @param state - The source state
13
+ * @param derive - A function that transforms the current state value
14
+ * @returns A read-only reference containing the derived state value
15
+ */
5
16
  function derivedRef(state, derive) {
6
- const valueRef = anchor({}, { recursive: false });
7
- const stateRef = {
8
- get value() {
9
- return valueRef.value;
10
- }
11
- };
12
- REF_REGISTRY.set(stateRef, valueRef);
13
- const unsubscribe = subscribe(state, (current) => {
14
- valueRef.value = derive(current);
15
- });
16
- onDestroy(() => {
17
- anchor.destroy(valueRef);
18
- unsubscribe();
19
- REF_REGISTRY.delete(stateRef);
20
- });
21
- return stateRef;
17
+ const valueRef = anchor({}, { recursive: false });
18
+ const stateRef = { get value() {
19
+ return valueRef.value;
20
+ } };
21
+ REF_REGISTRY.set(stateRef, valueRef);
22
+ const unsubscribe = subscribe(state, (current) => {
23
+ valueRef.value = derive(current);
24
+ });
25
+ onDestroy(() => {
26
+ anchor.destroy(valueRef);
27
+ unsubscribe();
28
+ REF_REGISTRY.delete(stateRef);
29
+ });
30
+ return stateRef;
22
31
  }
23
32
 
24
- export { derivedRef };
25
- //# sourceMappingURL=derive.js.map
26
- //# sourceMappingURL=derive.js.map
33
+ //#endregion
34
+ export { derivedRef };
package/dist/fetch.d.ts CHANGED
@@ -1,4 +1,6 @@
1
- import { FetchOptions, FetchState, StreamOptions } from '@anchorlib/core';
1
+ import { FetchOptions, FetchState, StreamOptions } from "@anchorlib/core";
2
+
3
+ //#region src/fetch.d.ts
2
4
 
3
5
  /**
4
6
  * @deprecated Use 'fetchState()' or 'asyncState()' instead.
@@ -11,7 +13,7 @@ import { FetchOptions, FetchState, StreamOptions } from '@anchorlib/core';
11
13
  * @returns A `FetchState` object representing the state of the request.
12
14
  */
13
15
  declare function fetchRef<R>(init: R, options: FetchOptions & {
14
- method: 'GET' | 'DELETE';
16
+ method: 'GET' | 'DELETE';
15
17
  }): FetchState<R>;
16
18
  /**
17
19
  * @deprecated Use 'fetchState()' or 'asyncState()' instead.
@@ -25,8 +27,8 @@ declare function fetchRef<R>(init: R, options: FetchOptions & {
25
27
  * @returns A `FetchState` object representing the state of the request.
26
28
  */
27
29
  declare function fetchRef<R, P>(init: R, options: FetchOptions & {
28
- method: 'POST' | 'PUT' | 'PATCH';
29
- body: P;
30
+ method: 'POST' | 'PUT' | 'PATCH';
31
+ body: P;
30
32
  }): FetchState<R>;
31
33
  /**
32
34
  * @deprecated Use 'streamState()' instead.
@@ -39,7 +41,7 @@ declare function fetchRef<R, P>(init: R, options: FetchOptions & {
39
41
  * @returns A `FetchState` object representing the state of the request.
40
42
  */
41
43
  declare function streamRef<R>(init: R, options: StreamOptions<R> & {
42
- method: 'GET' | 'DELETE';
44
+ method: 'GET' | 'DELETE';
43
45
  }): FetchState<R>;
44
46
  /**
45
47
  * @deprecated Use 'streamState()' instead.
@@ -53,8 +55,8 @@ declare function streamRef<R>(init: R, options: StreamOptions<R> & {
53
55
  * @returns A `FetchState` object representing the state of the request.
54
56
  */
55
57
  declare function streamRef<R, P>(init: R, options: StreamOptions<R> & {
56
- method: 'POST' | 'PUT' | 'PATCH';
57
- body: P;
58
+ method: 'POST' | 'PUT' | 'PATCH';
59
+ body: P;
58
60
  }): FetchState<R>;
59
-
60
- export { fetchRef, streamRef };
61
+ //#endregion
62
+ export { fetchRef, streamRef };
package/dist/fetch.js CHANGED
@@ -1,12 +1,12 @@
1
- import { fetchState, streamState } from '@anchorlib/core';
1
+ import { fetchState, streamState } from "@anchorlib/core";
2
2
 
3
+ //#region src/fetch.ts
3
4
  function fetchRef(init, options) {
4
- return fetchState(init, options);
5
+ return fetchState(init, options);
5
6
  }
6
7
  function streamRef(init, options) {
7
- return streamState(init, options);
8
+ return streamState(init, options);
8
9
  }
9
10
 
10
- export { fetchRef, streamRef };
11
- //# sourceMappingURL=fetch.js.map
12
- //# sourceMappingURL=fetch.js.map
11
+ //#endregion
12
+ export { fetchRef, streamRef };
package/dist/history.d.ts CHANGED
@@ -1,4 +1,6 @@
1
- import { State, HistoryOptions, HistoryState } from '@anchorlib/core';
1
+ import { HistoryOptions, HistoryState, State } from "@anchorlib/core";
2
+
3
+ //#region src/history.d.ts
2
4
 
3
5
  /**
4
6
  * @deprecated Use 'history()' instead.
@@ -8,5 +10,5 @@ import { State, HistoryOptions, HistoryState } from '@anchorlib/core';
8
10
  * @returns A `HistoryState` object representing the state of the history.
9
11
  */
10
12
  declare function historyRef<T extends State>(state: T, options?: HistoryOptions): HistoryState;
11
-
12
- export { historyRef };
13
+ //#endregion
14
+ export { historyRef };
package/dist/history.js CHANGED
@@ -1,9 +1,16 @@
1
- import { history } from '@anchorlib/core';
1
+ import { history } from "@anchorlib/core";
2
2
 
3
+ //#region src/history.ts
4
+ /**
5
+ * @deprecated Use 'history()' instead.
6
+ * Creates a reactive state that reflects the history state of a given Anchor state.
7
+ * @param state The initial Anchor state.
8
+ * @param options Optional history options.
9
+ * @returns A `HistoryState` object representing the state of the history.
10
+ */
3
11
  function historyRef(state, options) {
4
- return history(state, options);
12
+ return history(state, options);
5
13
  }
6
14
 
7
- export { historyRef };
8
- //# sourceMappingURL=history.js.map
9
- //# sourceMappingURL=history.js.map
15
+ //#endregion
16
+ export { historyRef };
@@ -1,4 +1,6 @@
1
- import { State, LinkableSchema, StateOptions, Immutable, ModelInput, StateBaseOptions, ImmutableOutput, Mutable, MutationKey, MutablePart } from '@anchorlib/core';
1
+ import { Immutable, ImmutableOutput, LinkableSchema, ModelInput, Mutable, MutablePart, MutationKey, State, StateBaseOptions, StateOptions } from "@anchorlib/core";
2
+
3
+ //#region src/immutable.d.ts
2
4
 
3
5
  /**
4
6
  * @deprecated Use 'immutable()' instead.
@@ -43,5 +45,5 @@ declare function writableRef<T extends State>(state: T): Mutable<T>;
43
45
  * @returns A mutable part of the state.
44
46
  */
45
47
  declare function writableRef<T extends State, K extends MutationKey<T>[]>(state: T, contracts: K): MutablePart<T, K>;
46
-
47
- export { immutableRef, writableRef };
48
+ //#endregion
49
+ export { immutableRef, writableRef };
package/dist/immutable.js CHANGED
@@ -1,12 +1,14 @@
1
- import { anchor } from '@anchorlib/core';
1
+ import { anchor } from "@anchorlib/core";
2
2
 
3
+ //#region src/immutable.ts
4
+ /** Implementation of `immutableRef` overloads. */
3
5
  function immutableRef(init, schemaOptions, options) {
4
- return anchor.immutable(init, schemaOptions, options);
6
+ return anchor.immutable(init, schemaOptions, options);
5
7
  }
8
+ /** Implementation of `writableRef` overloads. */
6
9
  function writableRef(state, contracts) {
7
- return anchor.writable(state, contracts);
10
+ return anchor.writable(state, contracts);
8
11
  }
9
12
 
10
- export { immutableRef, writableRef };
11
- //# sourceMappingURL=immutable.js.map
12
- //# sourceMappingURL=immutable.js.map
13
+ //#endregion
14
+ export { immutableRef, writableRef };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,12 @@
1
- export { AnchorSettings, BatchHandler, Context, ContextProvider, DerivedRef, EffectHandler, FetchOptions, FetchState, FetchStatus, HistoryOptions, HistoryState, Immutable, ImmutableOutput, ImmutableRef, MicroBatch, MicroLooper, MicroPusher, MicroTask, ModelError, ModelInput, ModelObject, Mutable, MutablePart, MutableRef, PushHandler, State, StateChange, StateException, StateExceptionHandler, StateObserver, StateOptions, StateSubscriber, StateUnsubscribe, TaskHandler, Writable, anchor, derived, effect, exception, fetchState, getContext, history, immutable, isImmutableRef, isMutableRef, isValueRef, microbatch, microloop, micropush, microtask, model, mutable, ordered, setContext, shortId, streamState, subscribe, undoable, writable } from '@anchorlib/core';
2
- export { anchorRef, flatRef, orderedRef, rawRef, reactiveRef } from './anchor.js';
3
- export { derivedRef } from './derive.js';
4
- export { fetchRef, streamRef } from './fetch.js';
5
- export { historyRef } from './history.js';
6
- export { immutableRef, writableRef } from './immutable.js';
7
- export { exceptionRef, modelRef } from './model.js';
8
- export { Props, PropsRef, propsRef } from './prop.js';
9
- export { observedRef } from './observable.js';
10
- export { REF_REGISTRY, constantRef, isRef, variableRef } from './ref.js';
11
- export { ConstantRef, StateRef, VariableRef } from './types.js';
1
+ import { anchorRef, flatRef, orderedRef, rawRef, reactiveRef } from "./anchor.js";
2
+ import { ConstantRef, StateRef, VariableRef } from "./types.js";
3
+ import { derivedRef } from "./derive.js";
4
+ import { fetchRef, streamRef } from "./fetch.js";
5
+ import { historyRef } from "./history.js";
6
+ import { immutableRef, writableRef } from "./immutable.js";
7
+ import { exceptionRef, modelRef } from "./model.js";
8
+ import { Props, PropsRef, propsRef } from "./prop.js";
9
+ import { observedRef } from "./observable.js";
10
+ import { REF_REGISTRY, constantRef, isRef, variableRef } from "./ref.js";
11
+ import { AnchorSettings, BatchHandler, Context, ContextProvider, DerivedRef, EffectHandler, FetchOptions, FetchState, FetchStatus, HistoryOptions, HistoryState, Immutable, ImmutableOutput, ImmutableRef, MicroBatch, MicroLooper, MicroPusher, MicroTask, ModelError, ModelInput, ModelObject, Mutable, MutablePart, MutableRef, PushHandler, State, StateChange, StateException, StateExceptionHandler, StateObserver, StateOptions, StateSubscriber, StateUnsubscribe, TaskHandler, Writable, anchor, derived, effect, exception, fetchState, getContext, history, immutable, isImmutableRef, isMutableRef, isValueRef, microbatch, microloop, micropush, microtask, model, mutable, ordered, setContext, shortId, streamState, subscribe, undoable, writable } from "@anchorlib/core";
12
+ export { type AnchorSettings, type BatchHandler, ConstantRef, type Context, type ContextProvider, DerivedRef, type EffectHandler, type FetchOptions, type FetchState, FetchStatus, type HistoryOptions, type HistoryState, type Immutable, type ImmutableOutput, ImmutableRef, type MicroBatch, type MicroLooper, type MicroPusher, type MicroTask, type ModelError, type ModelInput, type ModelObject, type Mutable, type MutablePart, MutableRef, Props, PropsRef, type PushHandler, REF_REGISTRY, type State, type StateChange, type StateException, type StateExceptionHandler, type StateObserver, type StateOptions, StateRef, type StateSubscriber, type StateUnsubscribe, type TaskHandler, VariableRef, type Writable, anchor, anchorRef, constantRef, derived, derivedRef, effect, exception, exceptionRef, fetchRef, fetchState, flatRef, getContext, history, historyRef, immutable, immutableRef, isImmutableRef, isMutableRef, isRef, isValueRef, microbatch, microloop, micropush, microtask, model, modelRef, mutable, observedRef, ordered, orderedRef, propsRef, rawRef, reactiveRef, setContext, shortId, streamRef, streamState, subscribe, undoable, variableRef, writable, writableRef };
package/dist/index.js CHANGED
@@ -1,14 +1,13 @@
1
- import './reactive.js';
2
- export { DerivedRef, FetchStatus, ImmutableRef, MutableRef, anchor, derived, effect, exception, fetchState, getContext, history, immutable, isImmutableRef, isMutableRef, isValueRef, microbatch, microloop, micropush, microtask, model, mutable, ordered, setContext, shortId, streamState, subscribe, undoable, writable } from '@anchorlib/core';
3
- export * from './anchor.js';
4
- export * from './derive.js';
5
- export * from './fetch.js';
6
- export * from './history.js';
7
- export * from './immutable.js';
8
- export * from './model.js';
9
- export * from './prop.js';
10
- export * from './observable.js';
11
- export * from './ref.js';
12
- export * from './types.js';
13
- //# sourceMappingURL=index.js.map
14
- //# sourceMappingURL=index.js.map
1
+ import { anchorRef, flatRef, orderedRef, rawRef, reactiveRef } from "./anchor.js";
2
+ import { REF_REGISTRY, constantRef, isRef, variableRef } from "./ref.js";
3
+ import { derivedRef } from "./derive.js";
4
+ import { fetchRef, streamRef } from "./fetch.js";
5
+ import { historyRef } from "./history.js";
6
+ import { immutableRef, writableRef } from "./immutable.js";
7
+ import "./reactive.js";
8
+ import { exceptionRef, modelRef } from "./model.js";
9
+ import { propsRef } from "./prop.js";
10
+ import { observedRef } from "./observable.js";
11
+ import { DerivedRef, FetchStatus, ImmutableRef, MutableRef, anchor, derived, effect, exception, fetchState, getContext, history, immutable, isImmutableRef, isMutableRef, isValueRef, microbatch, microloop, micropush, microtask, model, mutable, ordered, setContext, shortId, streamState, subscribe, undoable, writable } from "@anchorlib/core";
12
+
13
+ export { DerivedRef, FetchStatus, ImmutableRef, MutableRef, REF_REGISTRY, anchor, anchorRef, constantRef, derived, derivedRef, effect, exception, exceptionRef, fetchRef, fetchState, flatRef, getContext, history, historyRef, immutable, immutableRef, isImmutableRef, isMutableRef, isRef, isValueRef, microbatch, microloop, micropush, microtask, model, modelRef, mutable, observedRef, ordered, orderedRef, propsRef, rawRef, reactiveRef, setContext, shortId, streamRef, streamState, subscribe, undoable, variableRef, writable, writableRef };
package/dist/model.d.ts CHANGED
@@ -1,4 +1,6 @@
1
- import { LinkableSchema, ModelInput, StateBaseOptions, ModelOutput, ImmutableOutput, ObjLike, StateExceptionMap } from '@anchorlib/core';
1
+ import { ImmutableOutput, LinkableSchema, ModelInput, ModelOutput, ObjLike, StateBaseOptions, StateExceptionMap } from "@anchorlib/core";
2
+
3
+ //#region src/model.d.ts
2
4
 
3
5
  /**
4
6
  * @deprecated Use 'model()' instead.
@@ -24,7 +26,7 @@ declare function modelRef<S extends LinkableSchema, T extends ModelInput<S>>(sch
24
26
  * @returns An immutable model output.
25
27
  */
26
28
  declare function modelRef<S extends LinkableSchema, T extends ModelInput<S>>(schema: S, init: T, options: StateBaseOptions & {
27
- immutable: true;
29
+ immutable: true;
28
30
  }): ImmutableOutput<S>;
29
31
  /**
30
32
  * @deprecated Use 'exception()' instead.
@@ -35,5 +37,5 @@ declare function modelRef<S extends LinkableSchema, T extends ModelInput<S>>(sch
35
37
  * @returns A StateExceptionMap for the provided state.
36
38
  */
37
39
  declare function exceptionRef<T extends ObjLike | Array<unknown>>(state: T): StateExceptionMap<T>;
38
-
39
- export { exceptionRef, modelRef };
40
+ //#endregion
41
+ export { exceptionRef, modelRef };
package/dist/model.js CHANGED
@@ -1,12 +1,20 @@
1
- import { anchor } from '@anchorlib/core';
1
+ import { anchor } from "@anchorlib/core";
2
2
 
3
+ //#region src/model.ts
3
4
  function modelRef(schema, init, options) {
4
- return anchor(init, schema, options);
5
+ return anchor(init, schema, options);
5
6
  }
7
+ /**
8
+ * @deprecated Use 'exception()' instead.
9
+ * Creates a state that maps exceptions for a given state object or array.
10
+ *
11
+ * @template T - The type of the input state, must be an object-like or array type
12
+ * @param state - The input state object or array to create exception mappings for
13
+ * @returns A StateExceptionMap for the provided state.
14
+ */
6
15
  function exceptionRef(state) {
7
- return anchor.catch(state);
16
+ return anchor.catch(state);
8
17
  }
9
18
 
10
- export { exceptionRef, modelRef };
11
- //# sourceMappingURL=model.js.map
12
- //# sourceMappingURL=model.js.map
19
+ //#endregion
20
+ export { exceptionRef, modelRef };
@@ -1,4 +1,6 @@
1
- import { ConstantRef } from './types.js';
1
+ import { ConstantRef } from "./types.js";
2
+
3
+ //#region src/observable.d.ts
2
4
 
3
5
  /**
4
6
  * @deprecated use `effect()` instead.
@@ -11,5 +13,5 @@ import { ConstantRef } from './types.js';
11
13
  * @returns A read-only reference containing the observed value
12
14
  */
13
15
  declare function observedRef<R>(observe: () => R): ConstantRef<R>;
14
-
15
- export { observedRef };
16
+ //#endregion
17
+ export { observedRef };
@@ -1,28 +1,36 @@
1
- import { createObserver, anchor } from '@anchorlib/core';
2
- import { onDestroy } from 'svelte';
3
- import { REF_REGISTRY } from './ref.js';
1
+ import { REF_REGISTRY } from "./ref.js";
2
+ import { anchor, createObserver } from "@anchorlib/core";
3
+ import { onDestroy } from "svelte";
4
4
 
5
+ //#region src/observable.ts
6
+ /**
7
+ * @deprecated use `effect()` instead.
8
+ * Creates a read-only reference that observes a reactive function and updates its value
9
+ * when the observed value changes. The function automatically handles observer lifecycle
10
+ * and cleanup using Svelte's onDestroy hook.
11
+ *
12
+ * @template R - The type of the observed value
13
+ * @param observe - A function that returns the value to be observed
14
+ * @returns A read-only reference containing the observed value
15
+ */
5
16
  function observedRef(observe) {
6
- const observer = createObserver(() => {
7
- update();
8
- });
9
- const valueRef = anchor({ value: observer.run(observe) }, { recursive: false });
10
- const stateRef = {
11
- get value() {
12
- return valueRef.value;
13
- }
14
- };
15
- REF_REGISTRY.set(stateRef, valueRef);
16
- const update = () => {
17
- valueRef.value = observer.run(observe);
18
- };
19
- onDestroy(() => {
20
- observer.destroy();
21
- REF_REGISTRY.delete(stateRef);
22
- });
23
- return stateRef;
17
+ const observer = createObserver(() => {
18
+ update();
19
+ });
20
+ const valueRef = anchor({ value: observer.run(observe) }, { recursive: false });
21
+ const stateRef = { get value() {
22
+ return valueRef.value;
23
+ } };
24
+ REF_REGISTRY.set(stateRef, valueRef);
25
+ const update = () => {
26
+ valueRef.value = observer.run(observe);
27
+ };
28
+ onDestroy(() => {
29
+ observer.destroy();
30
+ REF_REGISTRY.delete(stateRef);
31
+ });
32
+ return stateRef;
24
33
  }
25
34
 
26
- export { observedRef };
27
- //# sourceMappingURL=observable.js.map
28
- //# sourceMappingURL=observable.js.map
35
+ //#endregion
36
+ export { observedRef };
package/dist/prop.d.ts CHANGED
@@ -1,12 +1,11 @@
1
- import { KeyLike, State } from '@anchorlib/core';
2
- import { ConstantRef } from './types.js';
1
+ import { ConstantRef } from "./types.js";
2
+ import { KeyLike, State } from "@anchorlib/core";
3
3
 
4
+ //#region src/prop.d.ts
4
5
  type Props = {
5
- [key: string]: KeyLike | State;
6
- };
7
- type PropsRef<T extends Props> = {
8
- [K in keyof T]: T[K] extends State ? ConstantRef<T[K]> : T[K];
6
+ [key: string]: KeyLike | State;
9
7
  };
8
+ type PropsRef<T extends Props> = { [K in keyof T]: T[K] extends State ? ConstantRef<T[K]> : T[K] };
10
9
  /**
11
10
  * Creates a reactive state object from the provided props.
12
11
  * For each property in the input props:
@@ -18,5 +17,5 @@ type PropsRef<T extends Props> = {
18
17
  * @returns {PropsRef<T>} A new object with State values converted to reactive states
19
18
  */
20
19
  declare function propsRef<T extends Props>(props: T): T;
21
-
22
- export { type Props, type PropsRef, propsRef };
20
+ //#endregion
21
+ export { Props, PropsRef, propsRef };
package/dist/prop.js CHANGED
@@ -1,9 +1,19 @@
1
- import '@anchorlib/core';
1
+ import "@anchorlib/core";
2
2
 
3
+ //#region src/prop.ts
4
+ /**
5
+ * Creates a reactive state object from the provided props.
6
+ * For each property in the input props:
7
+ * - If the value is a State object, it will be converted to a derived state
8
+ * - Otherwise, the value will be kept as is
9
+ * @deprecated
10
+ * @template T - The type of props extending Props
11
+ * @param {T} props - The input props object containing KeyLike or State values
12
+ * @returns {PropsRef<T>} A new object with State values converted to reactive states
13
+ */
3
14
  function propsRef(props) {
4
- return props;
15
+ return props;
5
16
  }
6
17
 
7
- export { propsRef };
8
- //# sourceMappingURL=prop.js.map
9
- //# sourceMappingURL=prop.js.map
18
+ //#endregion
19
+ export { propsRef };
@@ -1,5 +1,6 @@
1
- import { Linkable, KeyLike } from '@anchorlib/core';
1
+ import { KeyLike, Linkable } from "@anchorlib/core";
2
2
 
3
+ //#region src/reactive.d.ts
3
4
  declare const TRACKER_REGISTRY: WeakMap<Linkable, (prop: KeyLike) => void>;
4
-
5
- export { TRACKER_REGISTRY };
5
+ //#endregion
6
+ export { TRACKER_REGISTRY };