@anchorlib/svelte 1.0.0-beta.14 → 1.0.0-beta.15

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/anchor.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Linkable, LinkableSchema, StateOptions, ModelInput, ModelOutput, Immutable, ModelArray } from '@anchorlib/core';
2
2
 
3
3
  /**
4
+ * @deprecated Use 'mutable()' instead.
4
5
  * Creates a reactive state that can be used to manage state with Anchor.
5
6
  * This overload is used when no schema is provided, or when using a LinkableSchema with StateOptions.
6
7
  *
@@ -12,6 +13,7 @@ import { Linkable, LinkableSchema, StateOptions, ModelInput, ModelOutput, Immuta
12
13
  */
13
14
  declare function anchorRef<T extends Linkable, S extends LinkableSchema = LinkableSchema>(init: T, options?: StateOptions<S>): T;
14
15
  /**
16
+ * @deprecated Use 'mutable()' instead.
15
17
  * Creates a reactive state with a defined schema for validation and type inference.
16
18
  *
17
19
  * @template S - The schema type, extending LinkableSchema
@@ -23,6 +25,7 @@ declare function anchorRef<T extends Linkable, S extends LinkableSchema = Linkab
23
25
  */
24
26
  declare function anchorRef<S extends LinkableSchema, T extends ModelInput<S>>(init: T, schema?: S, options?: StateOptions): ModelOutput<S>;
25
27
  /**
28
+ * @deprecated Use 'mutable()' instead.
26
29
  * Creates an immutable reactive state with a defined schema.
27
30
  *
28
31
  * @template S - The schema type, extending LinkableSchema
@@ -36,11 +39,13 @@ declare function anchorRef<S extends LinkableSchema, T extends ModelInput<S>>(in
36
39
  immutable: true;
37
40
  }): Immutable<ModelOutput<S>>;
38
41
  /**
42
+ * @deprecated Use 'mutable()' instead.
39
43
  * Reactive state alias for anchorRef.
40
44
  * @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>>}}
41
45
  */
42
46
  declare const reactiveRef: typeof anchorRef;
43
47
  /**
48
+ * @deprecated Use 'ordered()' instead.
44
49
  * Creates a reactive state that maintains a sorted array state based on a comparison function.
45
50
  *
46
51
  * @template T - The type of elements in the array
@@ -52,6 +57,7 @@ declare const reactiveRef: typeof anchorRef;
52
57
  */
53
58
  declare function orderedRef<T extends unknown[], S extends ModelArray = ModelArray>(init: T, compare: (a: T[number], b: T[number]) => number, options?: StateOptions<S>): T;
54
59
  /**
60
+ * @deprecated Use 'flat()' instead.
55
61
  * Creates a reactive state that maintains a flat array state.
56
62
  *
57
63
  * @template T - The type of elements in the array
@@ -62,6 +68,7 @@ declare function orderedRef<T extends unknown[], S extends ModelArray = ModelArr
62
68
  */
63
69
  declare function flatRef<T extends unknown[], S extends ModelArray = ModelArray>(init: T, options?: StateOptions<S>): T;
64
70
  /**
71
+ * @deprecated Use 'raw()' instead.
65
72
  * Creates a reactive state that mutates the underlying object.
66
73
  *
67
74
  * Unless you set the global options to `cloned: true`, you don't want to use this.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/anchor.ts"],"names":[],"mappings":";;AAoEO,SAAS,SAAA,CACd,IAAA,EACA,aAAA,EACA,OAAA,EACgD;AAChD,EAAA,OAAO,MAAA,CAAyB,IAAA,EAAuB,aAAA,EAAoB,OAAO,CAAA;AACpF;AAMO,MAAM,WAAA,GAAc;AAYpB,SAAS,UAAA,CACd,IAAA,EACA,OAAA,EACA,OAAA,EACG;AACH,EAAA,OAAO,MAAA,CAAO,OAAA,CAAQ,IAAA,EAAM,OAAA,EAAS,OAAO,CAAA;AAC9C;AAWO,SAAS,OAAA,CAAgE,MAAS,OAAA,EAA8B;AACrH,EAAA,OAAO,MAAA,CAAO,IAAA,CAAK,IAAA,EAAM,OAAO,CAAA;AAClC;AAaO,SAAS,MAAA,CACd,MACA,OAAA,EACG;AACH,EAAA,OAAO,MAAA,CAAO,GAAA,CAAI,IAAA,EAAM,OAAO,CAAA;AACjC","file":"anchor.js","sourcesContent":["import {\n anchor,\n type Immutable,\n type Linkable,\n type LinkableSchema,\n type ModelArray,\n type ModelInput,\n type ModelOutput,\n type StateOptions,\n} from '@anchorlib/core';\n\n/**\n * Creates a reactive state that can be used to manage state with Anchor.\n * This overload is used when no schema is provided, or when using a LinkableSchema with StateOptions.\n *\n * @template T - The type of the initial value\n * @template S - The schema type, extending LinkableSchema\n * @param init - The initial value for the state\n * @param options - Optional state options for the state\n * @returns A reactive state containing the initial value\n */\nexport function anchorRef<T extends Linkable, S extends LinkableSchema = LinkableSchema>(\n init: T,\n options?: StateOptions<S>\n): T;\n\n/**\n * Creates a reactive state with a defined schema for validation and type inference.\n *\n * @template S - The schema type, extending LinkableSchema\n * @template T - The type of the initial value, must extend ModelInput of the schema\n * @param init - The initial value for the state\n * @param schema - The schema to validate and type the state\n * @param options - Optional state options for the state\n * @returns A reactive state containing the output model based on the schema\n */\nexport function anchorRef<S extends LinkableSchema, T extends ModelInput<S>>(\n init: T,\n schema?: S,\n options?: StateOptions\n): ModelOutput<S>;\n\n/**\n * Creates an immutable reactive state with a defined schema.\n *\n * @template S - The schema type, extending LinkableSchema\n * @template T - The type of the initial value, must extend ModelInput of the schema\n * @param init - The initial value for the state\n * @param schema - The schema to validate and type the state\n * @param options - State options with immutable flag set to true\n * @returns A reactive state containing an immutable output model based on the schema\n */\nexport function anchorRef<S extends LinkableSchema, T extends ModelInput<S>>(\n init: T,\n schema?: S,\n options?: StateOptions & { immutable: true }\n): Immutable<ModelOutput<S>>;\n\n/**\n * Creates a reactive state for state management with optional schema validation.\n *\n * @template T - The type of the initial value\n * @template S - The schema type or options\n * @param init - The initial value for the state\n * @param schemaOptions - Either a schema or state options\n * @param options - Additional state options when schema is provided\n * @returns A reactive state containing the managed state\n */\nexport function anchorRef<T extends Linkable, S extends LinkableSchema = LinkableSchema>(\n init: T,\n schemaOptions?: S | StateOptions,\n options?: StateOptions\n): T | ModelOutput<S> | Immutable<ModelOutput<S>> {\n return anchor<S, ModelInput<S>>(init as ModelInput<S>, schemaOptions as S, options);\n}\n\n/**\n * Reactive state alias for anchorRef.\n * @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>>}}\n */\nexport const reactiveRef = anchorRef;\n\n/**\n * Creates a reactive state that maintains a sorted array state based on a comparison function.\n *\n * @template T - The type of elements in the array\n * @template S - The schema type for array elements, extending ModelArray\n * @param init - The initial array value for the state\n * @param compare - A function that defines the sort order of elements\n * @param options - Optional state options for the state\n * @returns A reactive state containing the sorted array\n */\nexport function orderedRef<T extends unknown[], S extends ModelArray = ModelArray>(\n init: T,\n compare: (a: T[number], b: T[number]) => number,\n options?: StateOptions<S>\n): T {\n return anchor.ordered(init, compare, options);\n}\n\n/**\n * Creates a reactive state that maintains a flat array state.\n *\n * @template T - The type of elements in the array\n * @template S - The schema type for array elements, extending ModelArray\n * @param init - The initial array value for the state\n * @param options - Optional state options for the state\n * @returns A reactive state containing the flat array\n */\nexport function flatRef<T extends unknown[], S extends ModelArray = ModelArray>(init: T, options?: StateOptions<S>): T {\n return anchor.flat(init, options);\n}\n\n/**\n * Creates a reactive state that mutates the underlying object.\n *\n * Unless you set the global options to `cloned: true`, you don't want to use this.\n *\n * @template T - The type of the initial value\n * @template S - The schema type, extending LinkableSchema\n * @param init - The initial value for the state\n * @param options - Optional state options for the state\n * @returns A reactive state containing the raw value\n */\nexport function rawRef<T extends Linkable, S extends LinkableSchema = LinkableSchema>(\n init: T,\n options?: StateOptions<S>\n): T {\n return anchor.raw(init, options);\n}\n"]}
1
+ {"version":3,"sources":["../src/anchor.ts"],"names":[],"mappings":";;AAwEO,SAAS,SAAA,CACd,IAAA,EACA,aAAA,EACA,OAAA,EACgD;AAChD,EAAA,OAAO,MAAA,CAAyB,IAAA,EAAuB,aAAA,EAAoB,OAAO,CAAA;AACpF;AAOO,MAAM,WAAA,GAAc;AAapB,SAAS,UAAA,CACd,IAAA,EACA,OAAA,EACA,OAAA,EACG;AACH,EAAA,OAAO,MAAA,CAAO,OAAA,CAAQ,IAAA,EAAM,OAAA,EAAS,OAAO,CAAA;AAC9C;AAYO,SAAS,OAAA,CAAgE,MAAS,OAAA,EAA8B;AACrH,EAAA,OAAO,MAAA,CAAO,IAAA,CAAK,IAAA,EAAM,OAAO,CAAA;AAClC;AAcO,SAAS,MAAA,CACd,MACA,OAAA,EACG;AACH,EAAA,OAAO,MAAA,CAAO,GAAA,CAAI,IAAA,EAAM,OAAO,CAAA;AACjC","file":"anchor.js","sourcesContent":["import {\n anchor,\n type Immutable,\n type Linkable,\n type LinkableSchema,\n type ModelArray,\n type ModelInput,\n type ModelOutput,\n type StateOptions,\n} from '@anchorlib/core';\n\n/**\n * @deprecated Use 'mutable()' instead.\n * Creates a reactive state that can be used to manage state with Anchor.\n * This overload is used when no schema is provided, or when using a LinkableSchema with StateOptions.\n *\n * @template T - The type of the initial value\n * @template S - The schema type, extending LinkableSchema\n * @param init - The initial value for the state\n * @param options - Optional state options for the state\n * @returns A reactive state containing the initial value\n */\nexport function anchorRef<T extends Linkable, S extends LinkableSchema = LinkableSchema>(\n init: T,\n options?: StateOptions<S>\n): T;\n\n/**\n * @deprecated Use 'mutable()' instead.\n * Creates a reactive state with a defined schema for validation and type inference.\n *\n * @template S - The schema type, extending LinkableSchema\n * @template T - The type of the initial value, must extend ModelInput of the schema\n * @param init - The initial value for the state\n * @param schema - The schema to validate and type the state\n * @param options - Optional state options for the state\n * @returns A reactive state containing the output model based on the schema\n */\nexport function anchorRef<S extends LinkableSchema, T extends ModelInput<S>>(\n init: T,\n schema?: S,\n options?: StateOptions\n): ModelOutput<S>;\n\n/**\n * @deprecated Use 'mutable()' instead.\n * Creates an immutable reactive state with a defined schema.\n *\n * @template S - The schema type, extending LinkableSchema\n * @template T - The type of the initial value, must extend ModelInput of the schema\n * @param init - The initial value for the state\n * @param schema - The schema to validate and type the state\n * @param options - State options with immutable flag set to true\n * @returns A reactive state containing an immutable output model based on the schema\n */\nexport function anchorRef<S extends LinkableSchema, T extends ModelInput<S>>(\n init: T,\n schema?: S,\n options?: StateOptions & { immutable: true }\n): Immutable<ModelOutput<S>>;\n\n/**\n * @deprecated Use 'mutable()' instead.\n * Creates a reactive state for state management with optional schema validation.\n *\n * @template T - The type of the initial value\n * @template S - The schema type or options\n * @param init - The initial value for the state\n * @param schemaOptions - Either a schema or state options\n * @param options - Additional state options when schema is provided\n * @returns A reactive state containing the managed state\n */\nexport function anchorRef<T extends Linkable, S extends LinkableSchema = LinkableSchema>(\n init: T,\n schemaOptions?: S | StateOptions,\n options?: StateOptions\n): T | ModelOutput<S> | Immutable<ModelOutput<S>> {\n return anchor<S, ModelInput<S>>(init as ModelInput<S>, schemaOptions as S, options);\n}\n\n/**\n * @deprecated Use 'mutable()' instead.\n * Reactive state alias for anchorRef.\n * @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>>}}\n */\nexport const reactiveRef = anchorRef;\n\n/**\n * @deprecated Use 'ordered()' instead.\n * Creates a reactive state that maintains a sorted array state based on a comparison function.\n *\n * @template T - The type of elements in the array\n * @template S - The schema type for array elements, extending ModelArray\n * @param init - The initial array value for the state\n * @param compare - A function that defines the sort order of elements\n * @param options - Optional state options for the state\n * @returns A reactive state containing the sorted array\n */\nexport function orderedRef<T extends unknown[], S extends ModelArray = ModelArray>(\n init: T,\n compare: (a: T[number], b: T[number]) => number,\n options?: StateOptions<S>\n): T {\n return anchor.ordered(init, compare, options);\n}\n\n/**\n * @deprecated Use 'flat()' instead.\n * Creates a reactive state that maintains a flat array state.\n *\n * @template T - The type of elements in the array\n * @template S - The schema type for array elements, extending ModelArray\n * @param init - The initial array value for the state\n * @param options - Optional state options for the state\n * @returns A reactive state containing the flat array\n */\nexport function flatRef<T extends unknown[], S extends ModelArray = ModelArray>(init: T, options?: StateOptions<S>): T {\n return anchor.flat(init, options);\n}\n\n/**\n * @deprecated Use 'raw()' instead.\n * Creates a reactive state that mutates the underlying object.\n *\n * Unless you set the global options to `cloned: true`, you don't want to use this.\n *\n * @template T - The type of the initial value\n * @template S - The schema type, extending LinkableSchema\n * @param init - The initial value for the state\n * @param options - Optional state options for the state\n * @returns A reactive state containing the raw value\n */\nexport function rawRef<T extends Linkable, S extends LinkableSchema = LinkableSchema>(\n init: T,\n options?: StateOptions<S>\n): T {\n return anchor.raw(init, options);\n}"]}
@@ -0,0 +1 @@
1
+ export * from '@anchorlib/core';
@@ -0,0 +1,3 @@
1
+ export * from '@anchorlib/core';
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]}
package/dist/derive.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { ConstantRef } from './types.js';
2
2
 
3
3
  /**
4
+ * @deprecated Use `derived()` instead.
4
5
  * Creates a derived state from a source state with an optional transformation.
5
6
  *
6
7
  * @template T - The type of the input state
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/derive.ts"],"names":[],"mappings":";;;;AAcO,SAAS,UAAA,CAAiB,OAAU,MAAA,EAA2C;AACpF,EAAA,MAAM,WAAW,MAAA,CAAO,IAAI,EAAE,SAAA,EAAW,OAAO,CAAA;AAChD,EAAA,MAAM,QAAA,GAAW;AAAA,IACf,IAAI,KAAA,GAAQ;AACV,MAAA,OAAO,QAAA,CAAS,KAAA;AAAA,IAClB;AAAA,GACF;AACA,EAAA,YAAA,CAAa,GAAA,CAAI,UAAU,QAAQ,CAAA;AAEnC,EAAA,MAAM,WAAA,GAAc,SAAA,CAAU,KAAA,EAAO,CAAC,OAAA,KAAY;AAChD,IAAA,QAAA,CAAS,KAAA,GAAQ,OAAO,OAAO,CAAA;AAAA,EACjC,CAAC,CAAA;AAED,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAA,CAAO,QAAQ,QAAQ,CAAA;AACvB,IAAA,WAAA,EAAY;AACZ,IAAA,YAAA,CAAa,OAAO,QAAQ,CAAA;AAAA,EAC9B,CAAC,CAAA;AAED,EAAA,OAAO,QAAA;AACT","file":"derive.js","sourcesContent":["import { anchor, subscribe } from '@anchorlib/core';\nimport type { ConstantRef, StateRef } from './types.js';\nimport { onDestroy } from 'svelte';\nimport { REF_REGISTRY } from './ref.js';\n\n/**\n * Creates a derived state from a source state with an optional transformation.\n *\n * @template T - The type of the input state\n * @template R - The type of the transformed output\n * @param state - The source state\n * @param derive - A function that transforms the current state value\n * @returns A read-only reference containing the derived state value\n */\nexport function derivedRef<T, R>(state: T, derive: (current: T) => R): ConstantRef<R> {\n const valueRef = anchor({}, { recursive: false }) as StateRef<R>;\n const stateRef = {\n get value() {\n return valueRef.value;\n },\n };\n REF_REGISTRY.set(stateRef, valueRef);\n\n const unsubscribe = subscribe(state, (current) => {\n valueRef.value = derive(current);\n });\n\n onDestroy(() => {\n anchor.destroy(valueRef);\n unsubscribe();\n REF_REGISTRY.delete(stateRef);\n });\n\n return stateRef as ConstantRef<R>;\n}\n"]}
1
+ {"version":3,"sources":["../src/derive.ts"],"names":[],"mappings":";;;;AAeO,SAAS,UAAA,CAAiB,OAAU,MAAA,EAA2C;AACpF,EAAA,MAAM,WAAW,MAAA,CAAO,IAAI,EAAE,SAAA,EAAW,OAAO,CAAA;AAChD,EAAA,MAAM,QAAA,GAAW;AAAA,IACf,IAAI,KAAA,GAAQ;AACV,MAAA,OAAO,QAAA,CAAS,KAAA;AAAA,IAClB;AAAA,GACF;AACA,EAAA,YAAA,CAAa,GAAA,CAAI,UAAU,QAAQ,CAAA;AAEnC,EAAA,MAAM,WAAA,GAAc,SAAA,CAAU,KAAA,EAAO,CAAC,OAAA,KAAY;AAChD,IAAA,QAAA,CAAS,KAAA,GAAQ,OAAO,OAAO,CAAA;AAAA,EACjC,CAAC,CAAA;AAED,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAA,CAAO,QAAQ,QAAQ,CAAA;AACvB,IAAA,WAAA,EAAY;AACZ,IAAA,YAAA,CAAa,OAAO,QAAQ,CAAA;AAAA,EAC9B,CAAC,CAAA;AAED,EAAA,OAAO,QAAA;AACT","file":"derive.js","sourcesContent":["import { anchor, subscribe } from '@anchorlib/core';\nimport type { ConstantRef, StateRef } from './types.js';\nimport { onDestroy } from 'svelte';\nimport { REF_REGISTRY } from './ref.js';\n\n/**\n * @deprecated Use `derived()` instead.\n * Creates a derived state from a source state with an optional transformation.\n *\n * @template T - The type of the input state\n * @template R - The type of the transformed output\n * @param state - The source state\n * @param derive - A function that transforms the current state value\n * @returns A read-only reference containing the derived state value\n */\nexport function derivedRef<T, R>(state: T, derive: (current: T) => R): ConstantRef<R> {\n const valueRef = anchor({}, { recursive: false }) as StateRef<R>;\n const stateRef = {\n get value() {\n return valueRef.value;\n },\n };\n REF_REGISTRY.set(stateRef, valueRef);\n\n const unsubscribe = subscribe(state, (current) => {\n valueRef.value = derive(current);\n });\n\n onDestroy(() => {\n anchor.destroy(valueRef);\n unsubscribe();\n REF_REGISTRY.delete(stateRef);\n });\n\n return stateRef as ConstantRef<R>;\n}"]}
package/dist/fetch.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { FetchOptions, FetchState, StreamOptions } from '@anchorlib/core';
2
2
 
3
3
  /**
4
+ * @deprecated Use 'fetchState()' or 'asyncState()' instead.
4
5
  * Creates a reactive state that manages the state of a fetch request.
5
6
  * This overload is for GET or DELETE requests, which typically do not have a request body.
6
7
  *
@@ -13,6 +14,7 @@ declare function fetchRef<R>(init: R, options: FetchOptions & {
13
14
  method: 'GET' | 'DELETE';
14
15
  }): FetchState<R>;
15
16
  /**
17
+ * @deprecated Use 'fetchState()' or 'asyncState()' instead.
16
18
  * Creates a readable Svelte store that manages the state of a fetch request.
17
19
  * This overload is for POST, PUT, or PATCH requests, which typically include a request body.
18
20
  *
@@ -27,6 +29,7 @@ declare function fetchRef<R, P>(init: R, options: FetchOptions & {
27
29
  body: P;
28
30
  }): FetchState<R>;
29
31
  /**
32
+ * @deprecated Use 'streamState()' instead.
30
33
  * Creates a reactive state that manages the state of a streaming request.
31
34
  * This overload is for GET or DELETE requests, which typically do not have a request body.
32
35
  *
@@ -39,6 +42,7 @@ declare function streamRef<R>(init: R, options: StreamOptions<R> & {
39
42
  method: 'GET' | 'DELETE';
40
43
  }): FetchState<R>;
41
44
  /**
45
+ * @deprecated Use 'streamState()' instead.
42
46
  * Creates a reactive state that manages the state of a streaming request.
43
47
  * This overload is for POST, PUT, or PATCH requests, which typically include a request body.
44
48
  *
package/dist/fetch.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/fetch.ts"],"names":[],"mappings":";;AA4BO,SAAS,QAAA,CAAY,MAAS,OAAA,EAAsC;AACzE,EAAA,OAAO,UAAA,CAAW,MAAM,OAAO,CAAA;AACjC;AA4BO,SAAS,SAAA,CAAa,MAAS,OAAA,EAA0C;AAC9E,EAAA,OAAO,WAAA,CAAY,MAAM,OAAO,CAAA;AAClC","file":"fetch.js","sourcesContent":["import { type FetchOptions, fetchState, type FetchState, type StreamOptions, streamState } from '@anchorlib/core';\n\n/**\n * Creates a reactive state that manages the state of a fetch request.\n * This overload is for GET or DELETE requests, which typically do not have a request body.\n *\n * @template R The type of the data expected in the response.\n * @param init The initial value for the fetch state.\n * @param options The options for the fetch request, including the URL and method.\n * @returns A `FetchState` object representing the state of the request.\n */\nexport function fetchRef<R>(init: R, options: FetchOptions & { method: 'GET' | 'DELETE' }): FetchState<R>;\n\n/**\n * Creates a readable Svelte store that manages the state of a fetch request.\n * This overload is for POST, PUT, or PATCH requests, which typically include a request body.\n *\n * @template R The type of the data expected in the response.\n * @template P The type of the request body.\n * @param init The initial value for the fetch state.\n * @param options The options for the fetch request, including the URL, method, and body.\n * @returns A `FetchState` object representing the state of the request.\n */\nexport function fetchRef<R, P>(\n init: R,\n options: FetchOptions & { method: 'POST' | 'PUT' | 'PATCH'; body: P }\n): FetchState<R>;\n\nexport function fetchRef<R>(init: R, options: FetchOptions): FetchState<R> {\n return fetchState(init, options);\n}\n\n/**\n * Creates a reactive state that manages the state of a streaming request.\n * This overload is for GET or DELETE requests, which typically do not have a request body.\n *\n * @template R The type of the data expected in the response.\n * @param init The initial value for the fetch state.\n * @param options The options for the stream request, including the URL and method.\n * @returns A `FetchState` object representing the state of the request.\n */\nexport function streamRef<R>(init: R, options: StreamOptions<R> & { method: 'GET' | 'DELETE' }): FetchState<R>;\n\n/**\n * Creates a reactive state that manages the state of a streaming request.\n * This overload is for POST, PUT, or PATCH requests, which typically include a request body.\n *\n * @template R The type of the data expected in the response.\n * @template P The type of the request body.\n * @param init The initial value for the fetch state.\n * @param options The options for the stream request, including the URL, method, and body.\n * @returns A `FetchState` object representing the state of the request.\n */\nexport function streamRef<R, P>(\n init: R,\n options: StreamOptions<R> & { method: 'POST' | 'PUT' | 'PATCH'; body: P }\n): FetchState<R>;\n\nexport function streamRef<R>(init: R, options: StreamOptions<R>): FetchState<R> {\n return streamState(init, options);\n}\n"]}
1
+ {"version":3,"sources":["../src/fetch.ts"],"names":[],"mappings":";;AA8BO,SAAS,QAAA,CAAY,MAAS,OAAA,EAAsC;AACzE,EAAA,OAAO,UAAA,CAAW,MAAM,OAAO,CAAA;AACjC;AA8BO,SAAS,SAAA,CAAa,MAAS,OAAA,EAA0C;AAC9E,EAAA,OAAO,WAAA,CAAY,MAAM,OAAO,CAAA;AAClC","file":"fetch.js","sourcesContent":["import { type FetchOptions, fetchState, type FetchState, type StreamOptions, streamState } from '@anchorlib/core';\n\n/**\n * @deprecated Use 'fetchState()' or 'asyncState()' instead.\n * Creates a reactive state that manages the state of a fetch request.\n * This overload is for GET or DELETE requests, which typically do not have a request body.\n *\n * @template R The type of the data expected in the response.\n * @param init The initial value for the fetch state.\n * @param options The options for the fetch request, including the URL and method.\n * @returns A `FetchState` object representing the state of the request.\n */\nexport function fetchRef<R>(init: R, options: FetchOptions & { method: 'GET' | 'DELETE' }): FetchState<R>;\n\n/**\n * @deprecated Use 'fetchState()' or 'asyncState()' instead.\n * Creates a readable Svelte store that manages the state of a fetch request.\n * This overload is for POST, PUT, or PATCH requests, which typically include a request body.\n *\n * @template R The type of the data expected in the response.\n * @template P The type of the request body.\n * @param init The initial value for the fetch state.\n * @param options The options for the fetch request, including the URL, method, and body.\n * @returns A `FetchState` object representing the state of the request.\n */\nexport function fetchRef<R, P>(\n init: R,\n options: FetchOptions & { method: 'POST' | 'PUT' | 'PATCH'; body: P }\n): FetchState<R>;\n\nexport function fetchRef<R>(init: R, options: FetchOptions): FetchState<R> {\n return fetchState(init, options);\n}\n\n/**\n * @deprecated Use 'streamState()' instead.\n * Creates a reactive state that manages the state of a streaming request.\n * This overload is for GET or DELETE requests, which typically do not have a request body.\n *\n * @template R The type of the data expected in the response.\n * @param init The initial value for the fetch state.\n * @param options The options for the stream request, including the URL and method.\n * @returns A `FetchState` object representing the state of the request.\n */\nexport function streamRef<R>(init: R, options: StreamOptions<R> & { method: 'GET' | 'DELETE' }): FetchState<R>;\n\n/**\n * @deprecated Use 'streamState()' instead.\n * Creates a reactive state that manages the state of a streaming request.\n * This overload is for POST, PUT, or PATCH requests, which typically include a request body.\n *\n * @template R The type of the data expected in the response.\n * @template P The type of the request body.\n * @param init The initial value for the fetch state.\n * @param options The options for the stream request, including the URL, method, and body.\n * @returns A `FetchState` object representing the state of the request.\n */\nexport function streamRef<R, P>(\n init: R,\n options: StreamOptions<R> & { method: 'POST' | 'PUT' | 'PATCH'; body: P }\n): FetchState<R>;\n\nexport function streamRef<R>(init: R, options: StreamOptions<R>): FetchState<R> {\n return streamState(init, options);\n}"]}
package/dist/history.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { State, HistoryOptions, HistoryState } from '@anchorlib/core';
2
2
 
3
3
  /**
4
+ * @deprecated Use 'history()' instead.
4
5
  * Creates a reactive state that reflects the history state of a given Anchor state.
5
6
  * @param state The initial Anchor state.
6
7
  * @param options Optional history options.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/history.ts"],"names":[],"mappings":";;AASO,SAAS,UAAA,CAA4B,OAAU,OAAA,EAAwC;AAC5F,EAAA,OAAO,OAAA,CAAQ,OAAO,OAAO,CAAA;AAC/B","file":"history.js","sourcesContent":["import type { HistoryOptions, HistoryState, State } from '@anchorlib/core';\nimport { history } from '@anchorlib/core';\n\n/**\n * Creates a reactive state that reflects the history state of a given Anchor state.\n * @param state The initial Anchor state.\n * @param options Optional history options.\n * @returns A `HistoryState` object representing the state of the history.\n */\nexport function historyRef<T extends State>(state: T, options?: HistoryOptions): HistoryState {\n return history(state, options);\n}\n"]}
1
+ {"version":3,"sources":["../src/history.ts"],"names":[],"mappings":";;AAUO,SAAS,UAAA,CAA4B,OAAU,OAAA,EAAwC;AAC5F,EAAA,OAAO,OAAA,CAAQ,OAAO,OAAO,CAAA;AAC/B","file":"history.js","sourcesContent":["import type { HistoryOptions, HistoryState, State } from '@anchorlib/core';\nimport { history } from '@anchorlib/core';\n\n/**\n * @deprecated Use 'history()' instead.\n * Creates a reactive state that reflects the history state of a given Anchor state.\n * @param state The initial Anchor state.\n * @param options Optional history options.\n * @returns A `HistoryState` object representing the state of the history.\n */\nexport function historyRef<T extends State>(state: T, options?: HistoryOptions): HistoryState {\n return history(state, options);\n}"]}
@@ -1,6 +1,7 @@
1
1
  import { State, LinkableSchema, StateOptions, Immutable, ModelInput, StateBaseOptions, ImmutableOutput, Mutable, MutationKey, MutablePart } from '@anchorlib/core';
2
2
 
3
3
  /**
4
+ * @deprecated Use 'immutable()' instead.
4
5
  * Creates an immutable state from a state object.
5
6
  *
6
7
  * @template T The type of the state object.
@@ -11,6 +12,7 @@ import { State, LinkableSchema, StateOptions, Immutable, ModelInput, StateBaseOp
11
12
  */
12
13
  declare function immutableRef<T extends State, S extends LinkableSchema = LinkableSchema>(init: T, options?: StateOptions<S>): Immutable<T>;
13
14
  /**
15
+ * @deprecated Use 'immutable()' instead.
14
16
  * Creates an immutable state from a model input and a schema.
15
17
  *
16
18
  * @template S The type of the linkable schema.
@@ -22,6 +24,7 @@ declare function immutableRef<T extends State, S extends LinkableSchema = Linkab
22
24
  */
23
25
  declare function immutableRef<S extends LinkableSchema, T extends ModelInput<S>>(init: T, schema: S, options?: StateBaseOptions): ImmutableOutput<S>;
24
26
  /**
27
+ * @deprecated Use 'writable()' instead.
25
28
  * Creates a writable state from a state object.
26
29
  *
27
30
  * @template T The type of the state object.
@@ -30,6 +33,7 @@ declare function immutableRef<S extends LinkableSchema, T extends ModelInput<S>>
30
33
  */
31
34
  declare function writableRef<T extends State>(state: T): Mutable<T>;
32
35
  /**
36
+ * @deprecated Use 'writable()' instead.
33
37
  * Creates a writable state from a state object and a list of contracts.
34
38
  *
35
39
  * @template T The type of the state object.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/immutable.ts"],"names":[],"mappings":";;AA6CO,SAAS,YAAA,CACd,IAAA,EACA,aAAA,EACA,OAAA,EACc;AACd,EAAA,OAAO,MAAA,CAAO,SAAA,CAAU,IAAA,EAAe,aAAA,EAAwB,OAAO,CAAA;AACxE;AAuBO,SAAS,WAAA,CAAyD,OAAU,SAAA,EAAkB;AACnG,EAAA,OAAO,MAAA,CAAO,QAAA,CAAS,KAAA,EAAO,SAAS,CAAA;AACzC","file":"immutable.js","sourcesContent":["import {\n anchor,\n type Immutable,\n type ImmutableOutput,\n type LinkableSchema,\n type ModelInput,\n type Mutable,\n type MutablePart,\n type MutationKey,\n type State,\n type StateBaseOptions,\n type StateOptions,\n} from '@anchorlib/core';\n\n/**\n * Creates an immutable state from a state object.\n *\n * @template T The type of the state object.\n * @template S The type of the linkable schema.\n * @param init The initial state object.\n * @param options Optional state options.\n * @returns An immutable state.\n */\nexport function immutableRef<T extends State, S extends LinkableSchema = LinkableSchema>(\n init: T,\n options?: StateOptions<S>\n): Immutable<T>;\n\n/**\n * Creates an immutable state from a model input and a schema.\n *\n * @template S The type of the linkable schema.\n * @template T The type of the model input.\n * @param init The initial model input.\n * @param schema The linkable schema.\n * @param options Optional base state options.\n * @returns An immutable state.\n */\nexport function immutableRef<S extends LinkableSchema, T extends ModelInput<S>>(\n init: T,\n schema: S,\n options?: StateBaseOptions\n): ImmutableOutput<S>;\n\n/** Implementation of `immutableRef` overloads. */\nexport function immutableRef<T extends State, S extends LinkableSchema = LinkableSchema>(\n init: T,\n schemaOptions?: S | StateOptions,\n options?: StateOptions<S>\n): Immutable<T> {\n return anchor.immutable(init as never, schemaOptions as never, options);\n}\n\n/**\n * Creates a writable state from a state object.\n *\n * @template T The type of the state object.\n * @param state The initial state object.\n * @returns A mutable state.\n */\nexport function writableRef<T extends State>(state: T): Mutable<T>;\n\n/**\n * Creates a writable state from a state object and a list of contracts.\n *\n * @template T The type of the state object.\n * @template K The type of the mutation keys.\n * @param state The initial state object.\n * @param contracts A list of mutation keys.\n * @returns A mutable part of the state.\n */\nexport function writableRef<T extends State, K extends MutationKey<T>[]>(state: T, contracts: K): MutablePart<T, K>;\n\n/** Implementation of `writableRef` overloads. */\nexport function writableRef<T extends State, K extends MutationKey<T>[]>(state: T, contracts?: K): T {\n return anchor.writable(state, contracts) as T;\n}\n"]}
1
+ {"version":3,"sources":["../src/immutable.ts"],"names":[],"mappings":";;AA+CO,SAAS,YAAA,CACd,IAAA,EACA,aAAA,EACA,OAAA,EACc;AACd,EAAA,OAAO,MAAA,CAAO,SAAA,CAAU,IAAA,EAAe,aAAA,EAAwB,OAAO,CAAA;AACxE;AAyBO,SAAS,WAAA,CAAyD,OAAU,SAAA,EAAkB;AACnG,EAAA,OAAO,MAAA,CAAO,QAAA,CAAS,KAAA,EAAO,SAAS,CAAA;AACzC","file":"immutable.js","sourcesContent":["import {\n anchor,\n type Immutable,\n type ImmutableOutput,\n type LinkableSchema,\n type ModelInput,\n type Mutable,\n type MutablePart,\n type MutationKey,\n type State,\n type StateBaseOptions,\n type StateOptions,\n} from '@anchorlib/core';\n\n/**\n * @deprecated Use 'immutable()' instead.\n * Creates an immutable state from a state object.\n *\n * @template T The type of the state object.\n * @template S The type of the linkable schema.\n * @param init The initial state object.\n * @param options Optional state options.\n * @returns An immutable state.\n */\nexport function immutableRef<T extends State, S extends LinkableSchema = LinkableSchema>(\n init: T,\n options?: StateOptions<S>\n): Immutable<T>;\n\n/**\n * @deprecated Use 'immutable()' instead.\n * Creates an immutable state from a model input and a schema.\n *\n * @template S The type of the linkable schema.\n * @template T The type of the model input.\n * @param init The initial model input.\n * @param schema The linkable schema.\n * @param options Optional base state options.\n * @returns An immutable state.\n */\nexport function immutableRef<S extends LinkableSchema, T extends ModelInput<S>>(\n init: T,\n schema: S,\n options?: StateBaseOptions\n): ImmutableOutput<S>;\n\n/** Implementation of `immutableRef` overloads. */\nexport function immutableRef<T extends State, S extends LinkableSchema = LinkableSchema>(\n init: T,\n schemaOptions?: S | StateOptions,\n options?: StateOptions<S>\n): Immutable<T> {\n return anchor.immutable(init as never, schemaOptions as never, options);\n}\n\n/**\n * @deprecated Use 'writable()' instead.\n * Creates a writable state from a state object.\n *\n * @template T The type of the state object.\n * @param state The initial state object.\n * @returns A mutable state.\n */\nexport function writableRef<T extends State>(state: T): Mutable<T>;\n\n/**\n * @deprecated Use 'writable()' instead.\n * Creates a writable state from a state object and a list of contracts.\n *\n * @template T The type of the state object.\n * @template K The type of the mutation keys.\n * @param state The initial state object.\n * @param contracts A list of mutation keys.\n * @returns A mutable part of the state.\n */\nexport function writableRef<T extends State, K extends MutationKey<T>[]>(state: T, contracts: K): MutablePart<T, K>;\n\n/** Implementation of `writableRef` overloads. */\nexport function writableRef<T extends State, K extends MutationKey<T>[]>(state: T, contracts?: K): T {\n return anchor.writable(state, contracts) as T;\n}"]}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
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';
1
2
  export { anchorRef, flatRef, orderedRef, rawRef, reactiveRef } from './anchor.js';
2
3
  export { derivedRef } from './derive.js';
3
4
  export { fetchRef, streamRef } from './fetch.js';
@@ -8,4 +9,3 @@ export { Props, PropsRef, propsRef } from './prop.js';
8
9
  export { observedRef } from './observable.js';
9
10
  export { REF_REGISTRY, constantRef, isRef, variableRef } from './ref.js';
10
11
  export { ConstantRef, StateRef, VariableRef } from './types.js';
11
- import '@anchorlib/core';
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
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';
2
3
  export * from './anchor.js';
3
4
  export * from './derive.js';
4
5
  export * from './fetch.js';
package/dist/model.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { LinkableSchema, ModelInput, StateBaseOptions, ModelOutput, ImmutableOutput, ObjLike, StateExceptionMap } from '@anchorlib/core';
2
2
 
3
3
  /**
4
+ * @deprecated Use 'model()' instead.
4
5
  * Creates a model with mutable state.
5
6
  *
6
7
  * @template S - The linkable schema type
@@ -12,6 +13,7 @@ import { LinkableSchema, ModelInput, StateBaseOptions, ModelOutput, ImmutableOut
12
13
  */
13
14
  declare function modelRef<S extends LinkableSchema, T extends ModelInput<S>>(schema: S, init: T, options?: StateBaseOptions): ModelOutput<S>;
14
15
  /**
16
+ * @deprecated Use 'model()' instead.
15
17
  * Creates a model with immutable state.
16
18
  *
17
19
  * @template S - The linkable schema type
@@ -25,6 +27,7 @@ declare function modelRef<S extends LinkableSchema, T extends ModelInput<S>>(sch
25
27
  immutable: true;
26
28
  }): ImmutableOutput<S>;
27
29
  /**
30
+ * @deprecated Use 'exception()' instead.
28
31
  * Creates a state that maps exceptions for a given state object or array.
29
32
  *
30
33
  * @template T - The type of the input state, must be an object-like or array type
package/dist/model.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/model.ts"],"names":[],"mappings":";;AA2CO,SAAS,QAAA,CACd,MAAA,EACA,IAAA,EACA,OAAA,EACA;AACA,EAAA,OAAO,MAAA,CAAO,IAAA,EAAM,MAAA,EAAQ,OAAO,CAAA;AACrC;AASO,SAAS,aAAiD,KAAA,EAAgC;AAC/F,EAAA,OAAO,MAAA,CAAO,MAAM,KAAK,CAAA;AAC3B","file":"model.js","sourcesContent":["import {\n anchor,\n type ImmutableOutput,\n type LinkableSchema,\n type ModelInput,\n type ModelOutput,\n type ObjLike,\n type StateBaseOptions,\n type StateExceptionMap,\n} from '@anchorlib/core';\n\n/**\n * Creates a model with mutable state.\n *\n * @template S - The linkable schema type\n * @template T - The model input type that extends the schema\n * @param schema - The schema to use for the model\n * @param init - The initial value for the model\n * @param options - Optional state configuration\n * @returns A model output.\n */\nexport function modelRef<S extends LinkableSchema, T extends ModelInput<S>>(\n schema: S,\n init: T,\n options?: StateBaseOptions\n): ModelOutput<S>;\n\n/**\n * Creates a model with immutable state.\n *\n * @template S - The linkable schema type\n * @template T - The model input type that extends the schema\n * @param schema - The schema to use for the model\n * @param init - The initial value for the model\n * @param options - State configuration with immutable flag set to true\n * @returns An immutable model output.\n */\nexport function modelRef<S extends LinkableSchema, T extends ModelInput<S>>(\n schema: S,\n init: T,\n options: StateBaseOptions & { immutable: true }\n): ImmutableOutput<S>;\n\nexport function modelRef<S extends LinkableSchema, T extends ModelInput<S>>(\n schema: S,\n init: T,\n options?: StateBaseOptions\n) {\n return anchor(init, schema, options);\n}\n\n/**\n * Creates a state that maps exceptions for a given state object or array.\n *\n * @template T - The type of the input state, must be an object-like or array type\n * @param state - The input state object or array to create exception mappings for\n * @returns A StateExceptionMap for the provided state.\n */\nexport function exceptionRef<T extends ObjLike | Array<unknown>>(state: T): StateExceptionMap<T> {\n return anchor.catch(state);\n}\n"]}
1
+ {"version":3,"sources":["../src/model.ts"],"names":[],"mappings":";;AA6CO,SAAS,QAAA,CACd,MAAA,EACA,IAAA,EACA,OAAA,EACA;AACA,EAAA,OAAO,MAAA,CAAO,IAAA,EAAM,MAAA,EAAQ,OAAO,CAAA;AACrC;AAUO,SAAS,aAAiD,KAAA,EAAgC;AAC/F,EAAA,OAAO,MAAA,CAAO,MAAM,KAAK,CAAA;AAC3B","file":"model.js","sourcesContent":["import {\n anchor,\n type ImmutableOutput,\n type LinkableSchema,\n type ModelInput,\n type ModelOutput,\n type ObjLike,\n type StateBaseOptions,\n type StateExceptionMap,\n} from '@anchorlib/core';\n\n/**\n * @deprecated Use 'model()' instead.\n * Creates a model with mutable state.\n *\n * @template S - The linkable schema type\n * @template T - The model input type that extends the schema\n * @param schema - The schema to use for the model\n * @param init - The initial value for the model\n * @param options - Optional state configuration\n * @returns A model output.\n */\nexport function modelRef<S extends LinkableSchema, T extends ModelInput<S>>(\n schema: S,\n init: T,\n options?: StateBaseOptions\n): ModelOutput<S>;\n\n/**\n * @deprecated Use 'model()' instead.\n * Creates a model with immutable state.\n *\n * @template S - The linkable schema type\n * @template T - The model input type that extends the schema\n * @param schema - The schema to use for the model\n * @param init - The initial value for the model\n * @param options - State configuration with immutable flag set to true\n * @returns An immutable model output.\n */\nexport function modelRef<S extends LinkableSchema, T extends ModelInput<S>>(\n schema: S,\n init: T,\n options: StateBaseOptions & { immutable: true }\n): ImmutableOutput<S>;\n\nexport function modelRef<S extends LinkableSchema, T extends ModelInput<S>>(\n schema: S,\n init: T,\n options?: StateBaseOptions\n) {\n return anchor(init, schema, options);\n}\n\n/**\n * @deprecated Use 'exception()' instead.\n * Creates a state that maps exceptions for a given state object or array.\n *\n * @template T - The type of the input state, must be an object-like or array type\n * @param state - The input state object or array to create exception mappings for\n * @returns A StateExceptionMap for the provided state.\n */\nexport function exceptionRef<T extends ObjLike | Array<unknown>>(state: T): StateExceptionMap<T> {\n return anchor.catch(state);\n}"]}
@@ -1,6 +1,7 @@
1
1
  import { ConstantRef } from './types.js';
2
2
 
3
3
  /**
4
+ * @deprecated use `effect()` instead.
4
5
  * Creates a read-only reference that observes a reactive function and updates its value
5
6
  * when the observed value changes. The function automatically handles observer lifecycle
6
7
  * and cleanup using Svelte's onDestroy hook.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/observable.ts"],"names":[],"mappings":";;;;AAcO,SAAS,YAAe,OAAA,EAAkC;AAC/D,EAAA,MAAM,QAAA,GAAW,eAAe,MAAM;AACpC,IAAA,MAAA,EAAO;AAAA,EACT,CAAC,CAAA;AAED,EAAA,MAAM,QAAA,GAAW,MAAA,CAAO,EAAE,KAAA,EAAO,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA,EAAE,EAAG,EAAE,SAAA,EAAW,KAAA,EAAO,CAAA;AAC9E,EAAA,MAAM,QAAA,GAAW;AAAA,IACf,IAAI,KAAA,GAAQ;AACV,MAAA,OAAO,QAAA,CAAS,KAAA;AAAA,IAClB;AAAA,GACF;AAEA,EAAA,YAAA,CAAa,GAAA,CAAI,UAAU,QAAQ,CAAA;AAEnC,EAAA,MAAM,SAAS,MAAM;AACnB,IAAA,QAAA,CAAS,KAAA,GAAQ,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA;AAAA,EACvC,CAAA;AAEA,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,QAAA,CAAS,OAAA,EAAQ;AACjB,IAAA,YAAA,CAAa,OAAO,QAAQ,CAAA;AAAA,EAC9B,CAAC,CAAA;AAED,EAAA,OAAO,QAAA;AACT","file":"observable.js","sourcesContent":["import { anchor, createObserver } from '@anchorlib/core';\nimport type { ConstantRef, StateRef } from './types.js';\nimport { onDestroy } from 'svelte';\nimport { REF_REGISTRY } from './ref.js';\n\n/**\n * Creates a read-only reference that observes a reactive function and updates its value\n * when the observed value changes. The function automatically handles observer lifecycle\n * and cleanup using Svelte's onDestroy hook.\n *\n * @template R - The type of the observed value\n * @param observe - A function that returns the value to be observed\n * @returns A read-only reference containing the observed value\n */\nexport function observedRef<R>(observe: () => R): ConstantRef<R> {\n const observer = createObserver(() => {\n update();\n });\n\n const valueRef = anchor({ value: observer.run(observe) }, { recursive: false }) as StateRef<R>;\n const stateRef = {\n get value() {\n return valueRef.value;\n },\n } as ConstantRef<R>;\n\n REF_REGISTRY.set(stateRef, valueRef);\n\n const update = () => {\n valueRef.value = observer.run(observe);\n };\n\n onDestroy(() => {\n observer.destroy();\n REF_REGISTRY.delete(stateRef);\n });\n\n return stateRef;\n}\n"]}
1
+ {"version":3,"sources":["../src/observable.ts"],"names":[],"mappings":";;;;AAeO,SAAS,YAAe,OAAA,EAAkC;AAC/D,EAAA,MAAM,QAAA,GAAW,eAAe,MAAM;AACpC,IAAA,MAAA,EAAO;AAAA,EACT,CAAC,CAAA;AAED,EAAA,MAAM,QAAA,GAAW,MAAA,CAAO,EAAE,KAAA,EAAO,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA,EAAE,EAAG,EAAE,SAAA,EAAW,KAAA,EAAO,CAAA;AAC9E,EAAA,MAAM,QAAA,GAAW;AAAA,IACf,IAAI,KAAA,GAAQ;AACV,MAAA,OAAO,QAAA,CAAS,KAAA;AAAA,IAClB;AAAA,GACF;AAEA,EAAA,YAAA,CAAa,GAAA,CAAI,UAAU,QAAQ,CAAA;AAEnC,EAAA,MAAM,SAAS,MAAM;AACnB,IAAA,QAAA,CAAS,KAAA,GAAQ,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA;AAAA,EACvC,CAAA;AAEA,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,QAAA,CAAS,OAAA,EAAQ;AACjB,IAAA,YAAA,CAAa,OAAO,QAAQ,CAAA;AAAA,EAC9B,CAAC,CAAA;AAED,EAAA,OAAO,QAAA;AACT","file":"observable.js","sourcesContent":["import { anchor, createObserver } from '@anchorlib/core';\nimport type { ConstantRef, StateRef } from './types.js';\nimport { onDestroy } from 'svelte';\nimport { REF_REGISTRY } from './ref.js';\n\n/**\n * @deprecated use `effect()` instead.\n * Creates a read-only reference that observes a reactive function and updates its value\n * when the observed value changes. The function automatically handles observer lifecycle\n * and cleanup using Svelte's onDestroy hook.\n *\n * @template R - The type of the observed value\n * @param observe - A function that returns the value to be observed\n * @returns A read-only reference containing the observed value\n */\nexport function observedRef<R>(observe: () => R): ConstantRef<R> {\n const observer = createObserver(() => {\n update();\n });\n\n const valueRef = anchor({ value: observer.run(observe) }, { recursive: false }) as StateRef<R>;\n const stateRef = {\n get value() {\n return valueRef.value;\n },\n } as ConstantRef<R>;\n\n REF_REGISTRY.set(stateRef, valueRef);\n\n const update = () => {\n valueRef.value = observer.run(observe);\n };\n\n onDestroy(() => {\n observer.destroy();\n REF_REGISTRY.delete(stateRef);\n });\n\n return stateRef;\n}"]}
package/dist/reactive.js CHANGED
@@ -1,4 +1,5 @@
1
- import { setTracker, createObserver } from '@anchorlib/core';
1
+ import { setTracker, createObserver, setCleanUpHandler, onGlobalCleanup } from '@anchorlib/core';
2
+ import { onDestroy } from 'svelte';
2
3
  import { createSubscriber } from 'svelte/reactivity';
3
4
 
4
5
  const TRACKER_REGISTRY = /* @__PURE__ */ new WeakMap();
@@ -7,11 +8,16 @@ if (!bindingInitialized && typeof window !== "undefined") {
7
8
  bindingInitialized = true;
8
9
  setTracker((init, observers, key) => {
9
10
  if (!TRACKER_REGISTRY.has(init)) {
10
- let track = void 0;
11
+ let track;
11
12
  const subscribe = createSubscriber((update) => {
12
- const observer = createObserver(() => {
13
- update();
14
- });
13
+ const observer = createObserver(
14
+ () => {
15
+ observer.reset();
16
+ update();
17
+ },
18
+ void 0,
19
+ true
20
+ );
15
21
  track = observer.assign(init, observers);
16
22
  return () => {
17
23
  observer.destroy();
@@ -26,6 +32,13 @@ if (!bindingInitialized && typeof window !== "undefined") {
26
32
  }
27
33
  TRACKER_REGISTRY.get(init)?.(key);
28
34
  });
35
+ setCleanUpHandler((handler) => {
36
+ try {
37
+ return onDestroy(handler);
38
+ } catch (_error) {
39
+ return onGlobalCleanup(handler);
40
+ }
41
+ });
29
42
  }
30
43
 
31
44
  export { TRACKER_REGISTRY };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/reactive.ts"],"names":[],"mappings":";;;AAGO,MAAM,gBAAA,uBAAuB,OAAA;AAEpC,IAAI,kBAAA,GAAqB,KAAA;AAEzB,IAAI,CAAC,kBAAA,IAAsB,OAAO,MAAA,KAAW,WAAA,EAAa;AACxD,EAAA,kBAAA,GAAqB,IAAA;AAWrB,EAAA,UAAA,CAAW,CAAC,IAAA,EAAM,SAAA,EAAW,GAAA,KAAQ;AAEnC,IAAA,IAAI,CAAC,gBAAA,CAAiB,GAAA,CAAI,IAAI,CAAA,EAAG;AAC/B,MAAA,IAAI,KAAA,GAA+C,MAAA;AAGnD,MAAA,MAAM,SAAA,GAAY,gBAAA,CAAiB,CAAC,MAAA,KAAW;AAE7C,QAAA,MAAM,QAAA,GAAW,eAAe,MAAM;AACpC,UAAA,MAAA,EAAO;AAAA,QACT,CAAC,CAAA;AAGD,QAAA,KAAA,GAAQ,QAAA,CAAS,MAAA,CAAO,IAAA,EAAM,SAAS,CAAA;AAGvC,QAAA,OAAO,MAAM;AACX,UAAA,QAAA,CAAS,OAAA,EAAQ;AACjB,UAAA,gBAAA,CAAiB,OAAO,IAAI,CAAA;AAAA,QAC9B,CAAA;AAAA,MACF,CAAC,CAAA;AAGD,MAAA,MAAM,MAAA,GAAS,CAAC,IAAA,KAAkB;AAEhC,QAAA,SAAA,EAAU;AAEV,QAAA,KAAA,GAAQ,IAAI,CAAA;AAAA,MACd,CAAA;AAGA,MAAA,gBAAA,CAAiB,GAAA,CAAI,MAAM,MAAM,CAAA;AAAA,IACnC;AAGA,IAAA,gBAAA,CAAiB,GAAA,CAAI,IAAI,CAAA,GAAI,GAAG,CAAA;AAAA,EAClC,CAAC,CAAA;AACH","file":"reactive.js","sourcesContent":["import { createObserver, type KeyLike, type Linkable, setTracker } from '@anchorlib/core';\nimport { createSubscriber } from 'svelte/reactivity';\n\nexport const TRACKER_REGISTRY = new WeakMap<Linkable, (prop: KeyLike) => void>();\n\nlet bindingInitialized = false;\n\nif (!bindingInitialized && typeof window !== 'undefined') {\n bindingInitialized = true;\n\n /**\n * Sets up a tracker function that integrates Anchor's reactivity system with Svelte's reactivity.\n * This tracker is responsible for creating observers that watch for changes in reactive objects\n * and properly subscribing/unsubscribing to Svelte's reactivity system.\n *\n * @param init - The initial linkable object to track\n * @param observers - The observers collection to use for tracking\n * @param key - The specific key/property to track on the object\n */\n setTracker((init, observers, key) => {\n // Only initialize the tracking setup once per object\n if (!TRACKER_REGISTRY.has(init)) {\n let track: ((prop: KeyLike) => void) | undefined = undefined;\n\n // Create a Svelte subscriber that manages the lifecycle of our observer\n const subscribe = createSubscriber((update) => {\n // Create an Anchor observer that will trigger the Svelte update when changes occur\n const observer = createObserver(() => {\n update();\n });\n\n // Assign the observer to track changes on the init object and its observers\n track = observer.assign(init, observers);\n\n // Return cleanup function to destroy observer and remove from registry\n return () => {\n observer.destroy();\n TRACKER_REGISTRY.delete(init);\n };\n });\n\n // Function to assign tracking to a specific key/property\n const assign = (prop: KeyLike) => {\n // Activate the subscription\n subscribe();\n // Track the specific property\n track?.(prop);\n };\n\n // Store the assign function in the registry for this object\n TRACKER_REGISTRY.set(init, assign);\n }\n\n // Execute the tracking function for the specific key\n TRACKER_REGISTRY.get(init)?.(key);\n });\n}\n"]}
1
+ {"version":3,"sources":["../src/reactive.ts"],"names":[],"mappings":";;;;AAWO,MAAM,gBAAA,uBAAuB,OAAA;AAEpC,IAAI,kBAAA,GAAqB,KAAA;AAEzB,IAAI,CAAC,kBAAA,IAAsB,OAAO,MAAA,KAAW,WAAA,EAAa;AACxD,EAAA,kBAAA,GAAqB,IAAA;AAWrB,EAAA,UAAA,CAAW,CAAC,IAAA,EAAM,SAAA,EAAW,GAAA,KAAQ;AAEnC,IAAA,IAAI,CAAC,gBAAA,CAAiB,GAAA,CAAI,IAAI,CAAA,EAAG;AAC/B,MAAA,IAAI,KAAA;AAGJ,MAAA,MAAM,SAAA,GAAY,gBAAA,CAAiB,CAAC,MAAA,KAAW;AAE7C,QAAA,MAAM,QAAA,GAAW,cAAA;AAAA,UACf,MAAM;AACJ,YAAA,QAAA,CAAS,KAAA,EAAM;AACf,YAAA,MAAA,EAAO;AAAA,UACT,CAAA;AAAA,UACA,MAAA;AAAA,UACA;AAAA,SACF;AAGA,QAAA,KAAA,GAAQ,QAAA,CAAS,MAAA,CAAO,IAAA,EAAM,SAAS,CAAA;AAGvC,QAAA,OAAO,MAAM;AACX,UAAA,QAAA,CAAS,OAAA,EAAQ;AACjB,UAAA,gBAAA,CAAiB,OAAO,IAAI,CAAA;AAAA,QAC9B,CAAA;AAAA,MACF,CAAC,CAAA;AAGD,MAAA,MAAM,MAAA,GAAS,CAAC,IAAA,KAAkB;AAEhC,QAAA,SAAA,EAAU;AAEV,QAAA,KAAA,GAAQ,IAAI,CAAA;AAAA,MACd,CAAA;AAGA,MAAA,gBAAA,CAAiB,GAAA,CAAI,MAAM,MAAM,CAAA;AAAA,IACnC;AAGA,IAAA,gBAAA,CAAiB,GAAA,CAAI,IAAI,CAAA,GAAI,GAAG,CAAA;AAAA,EAClC,CAAC,CAAA;AAED,EAAA,iBAAA,CAAkB,CAAC,OAAA,KAAY;AAC7B,IAAA,IAAI;AACF,MAAA,OAAO,UAAU,OAAO,CAAA;AAAA,IAC1B,SAAS,MAAA,EAAQ;AACf,MAAA,OAAO,gBAAgB,OAAO,CAAA;AAAA,IAChC;AAAA,EACF,CAAC,CAAA;AACH","file":"reactive.js","sourcesContent":["import {\n createObserver,\n type KeyLike,\n type Linkable,\n onGlobalCleanup,\n setCleanUpHandler,\n setTracker,\n} from '@anchorlib/core';\nimport { onDestroy } from 'svelte';\nimport { createSubscriber } from 'svelte/reactivity';\n\nexport const TRACKER_REGISTRY = new WeakMap<Linkable, (prop: KeyLike) => void>();\n\nlet bindingInitialized = false;\n\nif (!bindingInitialized && typeof window !== 'undefined') {\n bindingInitialized = true;\n\n /**\n * Sets up a tracker function that integrates Anchor's reactivity system with Svelte's reactivity.\n * This tracker is responsible for creating observers that watch for changes in reactive objects\n * and properly subscribing/unsubscribing to Svelte's reactivity system.\n *\n * @param init - The initial linkable object to track\n * @param observers - The observers collection to use for tracking\n * @param key - The specific key/property to track on the object\n */\n setTracker((init, observers, key) => {\n // Only initialize the tracking setup once per object\n if (!TRACKER_REGISTRY.has(init)) {\n let track: ((prop: KeyLike) => void) | undefined;\n\n // Create a Svelte subscriber that manages the lifecycle of our observer\n const subscribe = createSubscriber((update) => {\n // Create an Anchor observer that will trigger the Svelte update when changes occur\n const observer = createObserver(\n () => {\n observer.reset();\n update();\n },\n undefined,\n true\n );\n\n // Assign the observer to track changes on the init object and its observers\n track = observer.assign(init, observers);\n\n // Return cleanup function to destroy observer and remove from registry\n return () => {\n observer.destroy();\n TRACKER_REGISTRY.delete(init);\n };\n });\n\n // Function to assign tracking to a specific key/property\n const assign = (prop: KeyLike) => {\n // Activate the subscription\n subscribe();\n // Track the specific property\n track?.(prop);\n };\n\n // Store the assign function in the registry for this object\n TRACKER_REGISTRY.set(init, assign);\n }\n\n // Execute the tracking function for the specific key\n TRACKER_REGISTRY.get(init)?.(key);\n });\n\n setCleanUpHandler((handler) => {\n try {\n return onDestroy(handler);\n } catch (_error) {\n return onGlobalCleanup(handler);\n }\n });\n}\n"]}
package/dist/ref.d.ts CHANGED
@@ -2,6 +2,7 @@ import { ConstantRef, StateRef, VariableRef } from './types.js';
2
2
 
3
3
  declare const REF_REGISTRY: WeakMap<ConstantRef<unknown>, StateRef<unknown>>;
4
4
  /**
5
+ * @deprecated Use 'mutable()' instead.
5
6
  * Creates a readable reference that can be subscribed to for reactive updates.
6
7
  * This function initializes a reactive reference with a given initial value and provides
7
8
  * mechanisms for subscribing to changes and publishing updates to subscribers.
@@ -12,6 +13,7 @@ declare const REF_REGISTRY: WeakMap<ConstantRef<unknown>, StateRef<unknown>>;
12
13
  */
13
14
  declare function variableRef<T>(init: T): VariableRef<T>;
14
15
  /**
16
+ * @deprecated Use 'mutable()' instead.
15
17
  * Creates a constant (read-only) reference that can be subscribed to for reactive updates.
16
18
  * This function initializes a reactive reference with a given initial value that cannot be modified
17
19
  * after creation.
@@ -23,6 +25,7 @@ declare function variableRef<T>(init: T): VariableRef<T>;
23
25
  */
24
26
  declare function variableRef<T>(init: T, constant: true): ConstantRef<T>;
25
27
  /**
28
+ * @deprecated Use 'immutable()' instead.
26
29
  * Creates a constant (read-only) reference that can be subscribed to for reactive updates.
27
30
  * This function initializes a reactive reference with a given initial value that cannot be modified
28
31
  * after creation. It's useful for values that should remain constant throughout the component lifecycle
@@ -34,6 +37,7 @@ declare function variableRef<T>(init: T, constant: true): ConstantRef<T>;
34
37
  */
35
38
  declare function constantRef<T>(init: T): ConstantRef<T>;
36
39
  /**
40
+ * @deprecated Use 'isValueRef()' instead.
37
41
  * Checks if a given value is a writable reference.
38
42
  * This function uses the REF_REGISTRY to determine if the provided value
39
43
  * is a registered writable reference.
package/dist/ref.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ref.ts"],"names":[],"mappings":";;;AAIO,MAAM,YAAA,uBAAmB,OAAA;AAmCzB,SAAS,WAAA,CAAe,MAAS,QAAA,EAAoB;AAC1D,EAAA,MAAM,QAAA,GAAW,OAAO,EAAE,KAAA,EAAO,MAAK,EAAG,EAAE,SAAA,EAAW,IAAA,EAAM,CAAA;AAE5D,EAAA,MAAM,GAAA,GAAM,CAAC,KAAA,KAAa;AAExB,IAAA,IAAI,QAAA,KAAa,IAAA,IAAQ,KAAA,KAAU,QAAA,CAAS,KAAA,EAAO;AAEnD,IAAA,QAAA,CAAS,KAAA,GAAQ,KAAA;AAAA,EACnB,CAAA;AAEA,EAAA,SAAA,CAAU,MAAM;AAEd,IAAA,YAAA,CAAa,OAAO,QAAgC,CAAA;AAGpD,IAAA,MAAA,CAAO,QAAQ,QAAQ,CAAA;AAAA,EACzB,CAAC,CAAA;AAED,EAAA,MAAM,QAAA,GAAW;AAAA,IACf,IAAI,KAAA,GAAQ;AACV,MAAA,OAAO,QAAA,CAAS,KAAA;AAAA,IAClB,CAAA;AAAA,IACA,IAAI,MAAM,KAAA,EAAU;AAClB,MAAA,GAAA,CAAI,KAAK,CAAA;AAAA,IACX;AAAA,GACF;AAEA,EAAA,YAAA,CAAa,GAAA,CAAI,UAAkC,QAAQ,CAAA;AAE3D,EAAA,OAAO,QAAA;AACT;AAYO,SAAS,YAAe,IAAA,EAAyB;AACtD,EAAA,OAAO,WAAA,CAAY,MAAM,IAAI,CAAA;AAC/B;AAWO,SAAS,MAAS,GAAA,EAAqC;AAC5D,EAAA,OAAO,YAAA,CAAa,IAAI,GAA2B,CAAA;AACrD","file":"ref.js","sourcesContent":["import type { ConstantRef, StateRef, VariableRef } from './types.js';\nimport { anchor } from '@anchorlib/core';\nimport { onDestroy } from 'svelte';\n\nexport const REF_REGISTRY = new WeakMap<ConstantRef<unknown>, StateRef<unknown>>();\n\n/**\n * Creates a readable reference that can be subscribed to for reactive updates.\n * This function initializes a reactive reference with a given initial value and provides\n * mechanisms for subscribing to changes and publishing updates to subscribers.\n *\n * @template T The type of the value being referenced\n * @param init - The initial value for the reference\n * @returns A readable reference object with subscribe and publish capabilities\n */\nexport function variableRef<T>(init: T): VariableRef<T>;\n\n/**\n * Creates a constant (read-only) reference that can be subscribed to for reactive updates.\n * This function initializes a reactive reference with a given initial value that cannot be modified\n * after creation.\n *\n * @template T The type of the value being referenced\n * @param init - The initial value for the reference\n * @param constant - If true, the reference will be read-only and cannot be updated.\n * @returns A constant reference object with subscribe capability but no write access\n */\nexport function variableRef<T>(init: T, constant: true): ConstantRef<T>;\n\n/**\n * Creates a readable reference that can be subscribed to for reactive updates.\n * This function initializes a reactive reference with a given initial value and provides\n * mechanisms for subscribing to changes and publishing updates to subscribers.\n *\n * @template T The type of the value being referenced\n * @param init - The initial value for the reference\n * @param constant - If true, the reference will be read-only and cannot be updated.\n * @returns A readable reference object with subscribe and publish capabilities\n */\nexport function variableRef<T>(init: T, constant?: boolean) {\n const valueRef = anchor({ value: init }, { recursive: true });\n\n const set = (value: T) => {\n // Ignore if the value is the same.\n if (constant === true || value === valueRef.value) return;\n\n valueRef.value = value;\n };\n\n onDestroy(() => {\n // Remove the ref from the registry.\n REF_REGISTRY.delete(stateRef as ConstantRef<unknown>);\n\n // Destroy the ref state.\n anchor.destroy(valueRef);\n });\n\n const stateRef = {\n get value() {\n return valueRef.value;\n },\n set value(value: T) {\n set(value);\n },\n } as never;\n\n REF_REGISTRY.set(stateRef as ConstantRef<unknown>, valueRef);\n\n return stateRef as ConstantRef<T>;\n}\n\n/**\n * Creates a constant (read-only) reference that can be subscribed to for reactive updates.\n * This function initializes a reactive reference with a given initial value that cannot be modified\n * after creation. It's useful for values that should remain constant throughout the component lifecycle\n * but still need to be reactively tracked.\n *\n * @template T The type of the value being referenced\n * @param init - The initial value for the constant reference\n * @returns A constant reference object with subscribe capability but no write access\n */\nexport function constantRef<T>(init: T): ConstantRef<T> {\n return variableRef(init, true);\n}\n\n/**\n * Checks if a given value is a writable reference.\n * This function uses the REF_REGISTRY to determine if the provided value\n * is a registered writable reference.\n *\n * @template T The type of the value that the reference holds\n * @param ref - The value to check\n * @returns True if the value is a writable reference, false otherwise\n */\nexport function isRef<T>(ref: unknown): ref is VariableRef<T> {\n return REF_REGISTRY.has(ref as VariableRef<unknown>);\n}\n"]}
1
+ {"version":3,"sources":["../src/ref.ts"],"names":[],"mappings":";;;AAIO,MAAM,YAAA,uBAAmB,OAAA;AAsCzB,SAAS,WAAA,CAAe,MAAS,QAAA,EAAoB;AAC1D,EAAA,MAAM,QAAA,GAAW,OAAO,EAAE,KAAA,EAAO,MAAK,EAAG,EAAE,SAAA,EAAW,IAAA,EAAM,CAAA;AAE5D,EAAA,MAAM,GAAA,GAAM,CAAC,KAAA,KAAa;AAExB,IAAA,IAAI,QAAA,KAAa,IAAA,IAAQ,KAAA,KAAU,QAAA,CAAS,KAAA,EAAO;AAEnD,IAAA,QAAA,CAAS,KAAA,GAAQ,KAAA;AAAA,EACnB,CAAA;AAEA,EAAA,SAAA,CAAU,MAAM;AAEd,IAAA,YAAA,CAAa,OAAO,QAAgC,CAAA;AAGpD,IAAA,MAAA,CAAO,QAAQ,QAAQ,CAAA;AAAA,EACzB,CAAC,CAAA;AAED,EAAA,MAAM,QAAA,GAAW;AAAA,IACf,IAAI,KAAA,GAAQ;AACV,MAAA,OAAO,QAAA,CAAS,KAAA;AAAA,IAClB,CAAA;AAAA,IACA,IAAI,MAAM,KAAA,EAAU;AAClB,MAAA,GAAA,CAAI,KAAK,CAAA;AAAA,IACX;AAAA,GACF;AAEA,EAAA,YAAA,CAAa,GAAA,CAAI,UAAkC,QAAQ,CAAA;AAE3D,EAAA,OAAO,QAAA;AACT;AAaO,SAAS,YAAe,IAAA,EAAyB;AACtD,EAAA,OAAO,WAAA,CAAY,MAAM,IAAI,CAAA;AAC/B;AAYO,SAAS,MAAS,GAAA,EAAqC;AAC5D,EAAA,OAAO,YAAA,CAAa,IAAI,GAA2B,CAAA;AACrD","file":"ref.js","sourcesContent":["import type { ConstantRef, StateRef, VariableRef } from './types.js';\nimport { anchor } from '@anchorlib/core';\nimport { onDestroy } from 'svelte';\n\nexport const REF_REGISTRY = new WeakMap<ConstantRef<unknown>, StateRef<unknown>>();\n\n/**\n * @deprecated Use 'mutable()' instead.\n * Creates a readable reference that can be subscribed to for reactive updates.\n * This function initializes a reactive reference with a given initial value and provides\n * mechanisms for subscribing to changes and publishing updates to subscribers.\n *\n * @template T The type of the value being referenced\n * @param init - The initial value for the reference\n * @returns A readable reference object with subscribe and publish capabilities\n */\nexport function variableRef<T>(init: T): VariableRef<T>;\n\n/**\n * @deprecated Use 'mutable()' instead.\n * Creates a constant (read-only) reference that can be subscribed to for reactive updates.\n * This function initializes a reactive reference with a given initial value that cannot be modified\n * after creation.\n *\n * @template T The type of the value being referenced\n * @param init - The initial value for the reference\n * @param constant - If true, the reference will be read-only and cannot be updated.\n * @returns A constant reference object with subscribe capability but no write access\n */\nexport function variableRef<T>(init: T, constant: true): ConstantRef<T>;\n\n/**\n * @deprecated Use 'mutable()' instead.\n * Creates a readable reference that can be subscribed to for reactive updates.\n * This function initializes a reactive reference with a given initial value and provides\n * mechanisms for subscribing to changes and publishing updates to subscribers.\n *\n * @template T The type of the value being referenced\n * @param init - The initial value for the reference\n * @param constant - If true, the reference will be read-only and cannot be updated.\n * @returns A readable reference object with subscribe and publish capabilities\n */\nexport function variableRef<T>(init: T, constant?: boolean) {\n const valueRef = anchor({ value: init }, { recursive: true });\n\n const set = (value: T) => {\n // Ignore if the value is the same.\n if (constant === true || value === valueRef.value) return;\n\n valueRef.value = value;\n };\n\n onDestroy(() => {\n // Remove the ref from the registry.\n REF_REGISTRY.delete(stateRef as ConstantRef<unknown>);\n\n // Destroy the ref state.\n anchor.destroy(valueRef);\n });\n\n const stateRef = {\n get value() {\n return valueRef.value;\n },\n set value(value: T) {\n set(value);\n },\n } as never;\n\n REF_REGISTRY.set(stateRef as ConstantRef<unknown>, valueRef);\n\n return stateRef as ConstantRef<T>;\n}\n\n/**\n * @deprecated Use 'immutable()' instead.\n * Creates a constant (read-only) reference that can be subscribed to for reactive updates.\n * This function initializes a reactive reference with a given initial value that cannot be modified\n * after creation. It's useful for values that should remain constant throughout the component lifecycle\n * but still need to be reactively tracked.\n *\n * @template T The type of the value being referenced\n * @param init - The initial value for the constant reference\n * @returns A constant reference object with subscribe capability but no write access\n */\nexport function constantRef<T>(init: T): ConstantRef<T> {\n return variableRef(init, true);\n}\n\n/**\n * @deprecated Use 'isValueRef()' instead.\n * Checks if a given value is a writable reference.\n * This function uses the REF_REGISTRY to determine if the provided value\n * is a registered writable reference.\n *\n * @template T The type of the value that the reference holds\n * @param ref - The value to check\n * @returns True if the value is a writable reference, false otherwise\n */\nexport function isRef<T>(ref: unknown): ref is VariableRef<T> {\n return REF_REGISTRY.has(ref as VariableRef<unknown>);\n}"]}
@@ -1,3 +1,4 @@
1
+ export * from '@anchorlib/storage';
1
2
  export { kvRef } from './kv.js';
2
3
  export { persistentRef } from './persistent.js';
3
4
  export { sessionRef } from './session.js';
@@ -1,3 +1,5 @@
1
+ import '../reactive.js';
2
+ export * from '@anchorlib/storage';
1
3
  export * from './kv.js';
2
4
  export * from './persistent.js';
3
5
  export * from './session.js';
@@ -1,6 +1,7 @@
1
1
  import { Storable, KVState } from '@anchorlib/storage/db';
2
2
 
3
3
  /**
4
+ * @deprecated Use `kv()` instead.
4
5
  * Creates a reactive key-value store state.
5
6
  *
6
7
  * This function initializes a key-value store with the given name and initial value,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/storage/kv.ts"],"names":[],"mappings":";;;AAcO,SAAS,KAAA,CAA0B,MAAc,IAAA,EAAqB;AAC3E,EAAA,MAAM,KAAA,GAAQ,EAAA,CAAG,IAAA,EAAM,IAAI,CAAA;AAE3B,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,EAAA,CAAG,MAAM,KAAK,CAAA;AAAA,EAChB,CAAC,CAAA;AAED,EAAA,OAAO,KAAA;AACT","file":"kv.js","sourcesContent":["import { kv, type KVState, type Storable } from '@anchorlib/storage/db';\nimport { onDestroy } from 'svelte';\n\n/**\n * Creates a reactive key-value store state.\n *\n * This function initializes a key-value store with the given name and initial value,\n * and automatically cleans up the store subscription when the component is destroyed.\n *\n * @template T - The type of the stored value, must extend Storable\n * @param name - The unique identifier for the key-value store\n * @param init - The initial value for the store\n * @returns A reactive key-value store state.\n */\nexport function kvRef<T extends Storable>(name: string, init: T): KVState<T> {\n const state = kv(name, init);\n\n onDestroy(() => {\n kv.leave(state);\n });\n\n return state;\n}\n"]}
1
+ {"version":3,"sources":["../../src/storage/kv.ts"],"names":[],"mappings":";;;AAeO,SAAS,KAAA,CAA0B,MAAc,IAAA,EAAqB;AAC3E,EAAA,MAAM,KAAA,GAAQ,EAAA,CAAG,IAAA,EAAM,IAAI,CAAA;AAE3B,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,EAAA,CAAG,MAAM,KAAK,CAAA;AAAA,EAChB,CAAC,CAAA;AAED,EAAA,OAAO,KAAA;AACT","file":"kv.js","sourcesContent":["import { kv, type KVState, type Storable } from '@anchorlib/storage/db';\nimport { onDestroy } from 'svelte';\n\n/**\n * @deprecated Use `kv()` instead.\n * Creates a reactive key-value store state.\n *\n * This function initializes a key-value store with the given name and initial value,\n * and automatically cleans up the store subscription when the component is destroyed.\n *\n * @template T - The type of the stored value, must extend Storable\n * @param name - The unique identifier for the key-value store\n * @param init - The initial value for the store\n * @returns A reactive key-value store state.\n */\nexport function kvRef<T extends Storable>(name: string, init: T): KVState<T> {\n const state = kv(name, init);\n\n onDestroy(() => {\n kv.leave(state);\n });\n\n return state;\n}"]}
@@ -1,6 +1,7 @@
1
1
  import { ObjLike, LinkableSchema, StateOptions } from '@anchorlib/core';
2
2
 
3
3
  /**
4
+ * @deprecated Use `persistent()` instead.
4
5
  * Creates a persistent reactive state using the provided name, initial value, and options.
5
6
  * The persistentRef is tied to the browser's local storage, meaning its value will persist
6
7
  * across page reloads and browser sessions until explicitly cleared.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/storage/persistent.ts"],"names":[],"mappings":";;;AAgBO,SAAS,aAAA,CACd,IAAA,EACA,IAAA,EACA,OAAA,EACG;AACH,EAAA,MAAM,KAAA,GAAQ,UAAA,CAAW,IAAA,EAAM,IAAA,EAAM,OAAO,CAAA;AAE5C,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,UAAA,CAAW,MAAM,KAAK,CAAA;AAAA,EACxB,CAAC,CAAA;AAED,EAAA,OAAO,KAAA;AACT","file":"persistent.js","sourcesContent":["import type { LinkableSchema, ObjLike, StateOptions } from '@anchorlib/core';\nimport { persistent } from '@anchorlib/storage';\nimport { onDestroy } from 'svelte';\n\n/**\n * Creates a persistent reactive state using the provided name, initial value, and options.\n * The persistentRef is tied to the browser's local storage, meaning its value will persist\n * across page reloads and browser sessions until explicitly cleared.\n *\n * @template T - The type of the initial value, must extend object-like structure.\n * @template S - The schema type for linkable validation, defaults to LinkableSchema.\n * @param name - A unique string identifier for the local storage key.\n * @param init - The initial value to be stored in local storage.\n * @param options - Optional configuration for state behavior and validation schema.\n * @returns A reactive state that provides reactive access and modification capabilities.\n */\nexport function persistentRef<T extends ObjLike, S extends LinkableSchema = LinkableSchema>(\n name: string,\n init: T,\n options?: StateOptions<S>\n): T {\n const state = persistent(name, init, options);\n\n onDestroy(() => {\n persistent.leave(state);\n });\n\n return state;\n}\n"]}
1
+ {"version":3,"sources":["../../src/storage/persistent.ts"],"names":[],"mappings":";;;AAiBO,SAAS,aAAA,CACd,IAAA,EACA,IAAA,EACA,OAAA,EACG;AACH,EAAA,MAAM,KAAA,GAAQ,UAAA,CAAW,IAAA,EAAM,IAAA,EAAM,OAAO,CAAA;AAE5C,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,UAAA,CAAW,MAAM,KAAK,CAAA;AAAA,EACxB,CAAC,CAAA;AAED,EAAA,OAAO,KAAA;AACT","file":"persistent.js","sourcesContent":["import type { LinkableSchema, ObjLike, StateOptions } from '@anchorlib/core';\nimport { persistent } from '@anchorlib/storage';\nimport { onDestroy } from 'svelte';\n\n/**\n * @deprecated Use `persistent()` instead.\n * Creates a persistent reactive state using the provided name, initial value, and options.\n * The persistentRef is tied to the browser's local storage, meaning its value will persist\n * across page reloads and browser sessions until explicitly cleared.\n *\n * @template T - The type of the initial value, must extend object-like structure.\n * @template S - The schema type for linkable validation, defaults to LinkableSchema.\n * @param name - A unique string identifier for the local storage key.\n * @param init - The initial value to be stored in local storage.\n * @param options - Optional configuration for state behavior and validation schema.\n * @returns A reactive state that provides reactive access and modification capabilities.\n */\nexport function persistentRef<T extends ObjLike, S extends LinkableSchema = LinkableSchema>(\n name: string,\n init: T,\n options?: StateOptions<S>\n): T {\n const state = persistent(name, init, options);\n\n onDestroy(() => {\n persistent.leave(state);\n });\n\n return state;\n}"]}
@@ -1,6 +1,7 @@
1
1
  import { ObjLike, LinkableSchema, StateOptions } from '@anchorlib/core';
2
2
 
3
3
  /**
4
+ * @deprecated Use `session()` instead.
4
5
  * Creates a session-scoped reactive state using the provided name, initial value, and options.
5
6
  * The sessionRef is tied to the browser's session storage, meaning its value will persist
6
7
  * across page reloads but not after the session ends (e.g., tab/window closed).
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/storage/session.ts"],"names":[],"mappings":";;;AAgBO,SAAS,UAAA,CACd,IAAA,EACA,IAAA,EACA,OAAA,EACG;AACH,EAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,IAAA,EAAM,IAAA,EAAM,OAAO,CAAA;AAEzC,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,OAAA,CAAQ,MAAM,KAAK,CAAA;AAAA,EACrB,CAAC,CAAA;AAED,EAAA,OAAO,KAAA;AACT","file":"session.js","sourcesContent":["import type { LinkableSchema, ObjLike, StateOptions } from '@anchorlib/core';\nimport { session } from '@anchorlib/storage';\nimport { onDestroy } from 'svelte';\n\n/**\n * Creates a session-scoped reactive state using the provided name, initial value, and options.\n * The sessionRef is tied to the browser's session storage, meaning its value will persist\n * across page reloads but not after the session ends (e.g., tab/window closed).\n *\n * @template T - The type of the initial value, must extend object-like structure.\n * @template S - The schema type for linkable validation, defaults to LinkableSchema.\n * @param name - A unique string identifier for the session storage key.\n * @param init - The initial value to be stored in session storage.\n * @param options - Optional configuration for state behavior and validation schema.\n * @returns A reactive state that provides reactive access and modification capabilities.\n */\nexport function sessionRef<T extends ObjLike, S extends LinkableSchema = LinkableSchema>(\n name: string,\n init: T,\n options?: StateOptions<S>\n): T {\n const state = session(name, init, options);\n\n onDestroy(() => {\n session.leave(state);\n });\n\n return state;\n}\n"]}
1
+ {"version":3,"sources":["../../src/storage/session.ts"],"names":[],"mappings":";;;AAiBO,SAAS,UAAA,CACd,IAAA,EACA,IAAA,EACA,OAAA,EACG;AACH,EAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,IAAA,EAAM,IAAA,EAAM,OAAO,CAAA;AAEzC,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,OAAA,CAAQ,MAAM,KAAK,CAAA;AAAA,EACrB,CAAC,CAAA;AAED,EAAA,OAAO,KAAA;AACT","file":"session.js","sourcesContent":["import type { LinkableSchema, ObjLike, StateOptions } from '@anchorlib/core';\nimport { session } from '@anchorlib/storage';\nimport { onDestroy } from 'svelte';\n\n/**\n * @deprecated Use `session()` instead.\n * Creates a session-scoped reactive state using the provided name, initial value, and options.\n * The sessionRef is tied to the browser's session storage, meaning its value will persist\n * across page reloads but not after the session ends (e.g., tab/window closed).\n *\n * @template T - The type of the initial value, must extend object-like structure.\n * @template S - The schema type for linkable validation, defaults to LinkableSchema.\n * @param name - A unique string identifier for the session storage key.\n * @param init - The initial value to be stored in session storage.\n * @param options - Optional configuration for state behavior and validation schema.\n * @returns A reactive state that provides reactive access and modification capabilities.\n */\nexport function sessionRef<T extends ObjLike, S extends LinkableSchema = LinkableSchema>(\n name: string,\n init: T,\n options?: StateOptions<S>\n): T {\n const state = session(name, init, options);\n\n onDestroy(() => {\n session.leave(state);\n });\n\n return state;\n}"]}
@@ -1,7 +1,13 @@
1
1
  import { ReactiveTable, Rec, InferRec, Row } from '@anchorlib/storage/db';
2
2
  import { TableRef } from './types.js';
3
3
 
4
+ /**
5
+ * @deprecated Use `createTable()` instead.
6
+ */
4
7
  declare function createTableRef<T extends ReactiveTable<Rec>>(table: T): TableRef<InferRec<T>>;
8
+ /**
9
+ * @deprecated Use `createTable()` instead.
10
+ */
5
11
  declare function createTableRef<T extends Rec, R extends Row<T> = Row<T>>(name: string, version?: number, indexes?: (keyof R)[], remIndexes?: (keyof R)[], dbName?: string): TableRef<T, R>;
6
12
 
7
13
  export { createTableRef };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/storage/table.ts"],"names":[],"mappings":";;;AAmBO,SAAS,eACd,SAAA,EACA,OAAA,GAAU,GACV,OAAA,EACA,UAAA,EACA,SAAS,SAAA,EACO;AAChB,EAAA,IAAI,OAAO,cAAc,QAAA,EAAU;AACjC,IAAA,SAAA,GAAY,WAAA,CAAkB,SAAA,EAAW,OAAA,EAAS,OAAA,EAAS,YAAY,MAAM,CAAA;AAAA,EAC/E;AAEA,EAAA,MAAM,QAAA,GAAW,SAAA;AAEjB,EAAA,OAAO;AAAA,IACL,IAAI,EAAA,EAAY;AACd,MAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,GAAA,CAAI,EAAE,CAAA;AAE7B,MAAA,SAAA,CAAU,MAAM;AACd,QAAA,QAAA,CAAS,MAAM,EAAE,CAAA;AAAA,MACnB,CAAC,CAAA;AAED,MAAA,OAAO,KAAA;AAAA,IACT,CAAA;AAAA,IACA,IAAI,OAAA,EAAY;AACd,MAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA;AAElC,MAAA,SAAA,CAAU,MAAM;AACd,QAAA,QAAA,CAAS,KAAA,CAAM,KAAA,CAAM,IAAA,CAAK,EAAE,CAAA;AAAA,MAC9B,CAAC,CAAA;AAED,MAAA,OAAO,KAAA;AAAA,IACT,CAAA;AAAA,IACA,IAAA,CAAK,MAAA,EAAoC,KAAA,EAAgB,SAAA,EAAgC;AACvF,MAAA,OAAO,QAAA,CAAS,IAAA,CAAK,MAAA,EAAQ,KAAA,EAAO,SAAS,CAAA;AAAA,IAC/C,CAAA;AAAA,IACA,WAAA,CAAY,IAAA,EAAe,MAAA,EAAoC,KAAA,EAAgB,SAAA,EAAgC;AAC7G,MAAA,OAAO,QAAA,CAAS,WAAA,CAAY,IAAA,EAAM,MAAA,EAAQ,OAAO,SAAS,CAAA;AAAA,IAC5D,CAAA;AAAA,IACA,OAAO,EAAA,EAAY;AACjB,MAAA,OAAO,QAAA,CAAS,OAAO,EAAE,CAAA;AAAA,IAC3B,CAAA;AAAA,IACA,KAAK,KAAA,EAAY;AACf,MAAA,QAAA,CAAS,KAAK,KAAK,CAAA;AACnB,MAAA,OAAO,IAAA;AAAA,IACT,CAAA;AAAA,IACA,KAAA,GAAQ;AACN,MAAA,OAAO,QAAA;AAAA,IACT;AAAA,GACF;AACF","file":"table.js","sourcesContent":["import {\n createTable,\n type FilterFn,\n type InferRec,\n type ReactiveTable,\n type Rec,\n type Row,\n} from '@anchorlib/storage/db';\nimport { onDestroy } from 'svelte';\nimport type { TableRef } from './types.js';\n\nexport function createTableRef<T extends ReactiveTable<Rec>>(table: T): TableRef<InferRec<T>>;\nexport function createTableRef<T extends Rec, R extends Row<T> = Row<T>>(\n name: string,\n version?: number,\n indexes?: (keyof R)[],\n remIndexes?: (keyof R)[],\n dbName?: string\n): TableRef<T, R>;\nexport function createTableRef<T extends Rec, R extends Row<T> = Row<T>>(\n tableName: string | ReactiveTable<T>,\n version = 1,\n indexes?: (keyof R)[],\n remIndexes?: (keyof R)[],\n dbName = tableName as string\n): TableRef<T, R> {\n if (typeof tableName === 'string') {\n tableName = createTable<T, R>(tableName, version, indexes, remIndexes, dbName);\n }\n\n const tableRef = tableName as ReactiveTable<T, R>;\n\n return {\n get(id: string) {\n const state = tableRef.get(id);\n\n onDestroy(() => {\n tableRef.leave(id);\n });\n\n return state;\n },\n add(payload: T) {\n const state = tableRef.add(payload);\n\n onDestroy(() => {\n tableRef.leave(state.data.id);\n });\n\n return state;\n },\n list(filter?: IDBKeyRange | FilterFn<R>, limit?: number, direction?: IDBCursorDirection) {\n return tableRef.list(filter, limit, direction);\n },\n listByIndex(name: keyof R, filter?: IDBKeyRange | FilterFn<R>, limit?: number, direction?: IDBCursorDirection) {\n return tableRef.listByIndex(name, filter, limit, direction);\n },\n remove(id: string) {\n return tableRef.remove(id);\n },\n seed(seeds: R[]) {\n tableRef.seed(seeds);\n return this;\n },\n table() {\n return tableRef;\n },\n };\n}\n"]}
1
+ {"version":3,"sources":["../../src/storage/table.ts"],"names":[],"mappings":";;;AA4BO,SAAS,eACd,SAAA,EACA,OAAA,GAAU,GACV,OAAA,EACA,UAAA,EACA,SAAS,SAAA,EACO;AAChB,EAAA,IAAI,OAAO,cAAc,QAAA,EAAU;AACjC,IAAA,SAAA,GAAY,WAAA,CAAkB,SAAA,EAAW,OAAA,EAAS,OAAA,EAAS,YAAY,MAAM,CAAA;AAAA,EAC/E;AAEA,EAAA,MAAM,QAAA,GAAW,SAAA;AAEjB,EAAA,OAAO;AAAA,IACL,IAAI,EAAA,EAAY;AACd,MAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,GAAA,CAAI,EAAE,CAAA;AAE7B,MAAA,SAAA,CAAU,MAAM;AACd,QAAA,QAAA,CAAS,MAAM,EAAE,CAAA;AAAA,MACnB,CAAC,CAAA;AAED,MAAA,OAAO,KAAA;AAAA,IACT,CAAA;AAAA,IACA,IAAI,OAAA,EAAY;AACd,MAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA;AAElC,MAAA,SAAA,CAAU,MAAM;AACd,QAAA,QAAA,CAAS,KAAA,CAAM,KAAA,CAAM,IAAA,CAAK,EAAE,CAAA;AAAA,MAC9B,CAAC,CAAA;AAED,MAAA,OAAO,KAAA;AAAA,IACT,CAAA;AAAA,IACA,IAAA,CAAK,MAAA,EAAoC,KAAA,EAAgB,SAAA,EAAgC;AACvF,MAAA,OAAO,QAAA,CAAS,IAAA,CAAK,MAAA,EAAQ,KAAA,EAAO,SAAS,CAAA;AAAA,IAC/C,CAAA;AAAA,IACA,WAAA,CAAY,IAAA,EAAe,MAAA,EAAoC,KAAA,EAAgB,SAAA,EAAgC;AAC7G,MAAA,OAAO,QAAA,CAAS,WAAA,CAAY,IAAA,EAAM,MAAA,EAAQ,OAAO,SAAS,CAAA;AAAA,IAC5D,CAAA;AAAA,IACA,OAAO,EAAA,EAAY;AACjB,MAAA,OAAO,QAAA,CAAS,OAAO,EAAE,CAAA;AAAA,IAC3B,CAAA;AAAA,IACA,KAAK,KAAA,EAAY;AACf,MAAA,QAAA,CAAS,KAAK,KAAK,CAAA;AACnB,MAAA,OAAO,IAAA;AAAA,IACT,CAAA;AAAA,IACA,KAAA,GAAQ;AACN,MAAA,OAAO,QAAA;AAAA,IACT;AAAA,GACF;AACF","file":"table.js","sourcesContent":["import {\n createTable,\n type FilterFn,\n type InferRec,\n type ReactiveTable,\n type Rec,\n type Row,\n} from '@anchorlib/storage/db';\nimport { onDestroy } from 'svelte';\nimport type { TableRef } from './types.js';\n\n/**\n * @deprecated Use `createTable()` instead.\n */\nexport function createTableRef<T extends ReactiveTable<Rec>>(table: T): TableRef<InferRec<T>>;\n/**\n * @deprecated Use `createTable()` instead.\n */\nexport function createTableRef<T extends Rec, R extends Row<T> = Row<T>>(\n name: string,\n version?: number,\n indexes?: (keyof R)[],\n remIndexes?: (keyof R)[],\n dbName?: string\n): TableRef<T, R>;\n/**\n * @deprecated Use `createTable()` instead.\n */\nexport function createTableRef<T extends Rec, R extends Row<T> = Row<T>>(\n tableName: string | ReactiveTable<T>,\n version = 1,\n indexes?: (keyof R)[],\n remIndexes?: (keyof R)[],\n dbName = tableName as string\n): TableRef<T, R> {\n if (typeof tableName === 'string') {\n tableName = createTable<T, R>(tableName, version, indexes, remIndexes, dbName);\n }\n\n const tableRef = tableName as ReactiveTable<T, R>;\n\n return {\n get(id: string) {\n const state = tableRef.get(id);\n\n onDestroy(() => {\n tableRef.leave(id);\n });\n\n return state;\n },\n add(payload: T) {\n const state = tableRef.add(payload);\n\n onDestroy(() => {\n tableRef.leave(state.data.id);\n });\n\n return state;\n },\n list(filter?: IDBKeyRange | FilterFn<R>, limit?: number, direction?: IDBCursorDirection) {\n return tableRef.list(filter, limit, direction);\n },\n listByIndex(name: keyof R, filter?: IDBKeyRange | FilterFn<R>, limit?: number, direction?: IDBCursorDirection) {\n return tableRef.listByIndex(name, filter, limit, direction);\n },\n remove(id: string) {\n return tableRef.remove(id);\n },\n seed(seeds: R[]) {\n tableRef.seed(seeds);\n return this;\n },\n table() {\n return tableRef;\n },\n };\n}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anchorlib/svelte",
3
- "version": "1.0.0-beta.14",
3
+ "version": "1.0.0-beta.15",
4
4
  "description": "Svelte bindings for Anchor reactive state management",
5
5
  "keywords": [
6
6
  "state",
@@ -34,6 +34,11 @@
34
34
  "svelte": "./dist/reactive.js",
35
35
  "import": "./dist/reactive.js"
36
36
  },
37
+ "./core": {
38
+ "types": "./dist/core/index.d.ts",
39
+ "svelte": "./dist/core/index.js",
40
+ "import": "./dist/core/index.js"
41
+ },
37
42
  "./storage": {
38
43
  "types": "./dist/storage/index.d.ts",
39
44
  "svelte": "./dist/storage/index.js",
@@ -50,8 +55,8 @@
50
55
  "access": "public"
51
56
  },
52
57
  "dependencies": {
53
- "@anchorlib/core": "^1.0.0-beta.14",
54
- "@anchorlib/storage": "^1.0.0-beta.14"
58
+ "@anchorlib/core": "^1.0.0-beta.15",
59
+ "@anchorlib/storage": "^1.0.0-beta.15"
55
60
  },
56
61
  "devDependencies": {
57
62
  "@biomejs/biome": "2.3.3",