@anchorlib/svelte 1.0.0-beta.11 → 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.
Files changed (57) hide show
  1. package/dist/anchor.d.ts +84 -0
  2. package/dist/anchor.js +19 -0
  3. package/dist/anchor.js.map +1 -0
  4. package/dist/core/index.d.ts +1 -0
  5. package/dist/core/index.js +3 -0
  6. package/dist/core/index.js.map +1 -0
  7. package/dist/derive.d.ts +15 -0
  8. package/dist/derive.js +26 -0
  9. package/dist/derive.js.map +1 -0
  10. package/dist/fetch.d.ts +60 -0
  11. package/dist/fetch.js +12 -0
  12. package/dist/fetch.js.map +1 -0
  13. package/dist/history.d.ts +12 -0
  14. package/dist/history.js +9 -0
  15. package/dist/history.js.map +1 -0
  16. package/dist/immutable.d.ts +47 -0
  17. package/dist/immutable.js +12 -0
  18. package/dist/immutable.js.map +1 -0
  19. package/dist/index.d.ts +11 -305
  20. package/dist/index.js +12 -138
  21. package/dist/index.js.map +1 -1
  22. package/dist/model.d.ts +39 -0
  23. package/dist/model.js +12 -0
  24. package/dist/model.js.map +1 -0
  25. package/dist/observable.d.ts +15 -0
  26. package/dist/observable.js +28 -0
  27. package/dist/observable.js.map +1 -0
  28. package/dist/prop.d.ts +22 -0
  29. package/dist/prop.js +9 -0
  30. package/dist/prop.js.map +1 -0
  31. package/dist/reactive.js +20 -8
  32. package/dist/reactive.js.map +1 -1
  33. package/dist/ref.d.ts +51 -0
  34. package/dist/ref.js +35 -0
  35. package/dist/ref.js.map +1 -0
  36. package/dist/storage/index.d.ts +8 -60
  37. package/dist/storage/index.js +7 -66
  38. package/dist/storage/index.js.map +1 -1
  39. package/dist/storage/kv.d.ts +17 -0
  40. package/dist/storage/kv.js +14 -0
  41. package/dist/storage/kv.js.map +1 -0
  42. package/dist/storage/persistent.d.ts +18 -0
  43. package/dist/storage/persistent.js +14 -0
  44. package/dist/storage/persistent.js.map +1 -0
  45. package/dist/storage/session.d.ts +18 -0
  46. package/dist/storage/session.js +14 -0
  47. package/dist/storage/session.js.map +1 -0
  48. package/dist/storage/table.d.ts +13 -0
  49. package/dist/storage/table.js +45 -0
  50. package/dist/storage/table.js.map +1 -0
  51. package/dist/storage/types.d.ts +15 -0
  52. package/dist/storage/types.js +3 -0
  53. package/dist/storage/types.js.map +1 -0
  54. package/dist/types.d.ts +11 -0
  55. package/dist/types.js +3 -0
  56. package/dist/types.js.map +1 -0
  57. package/package.json +22 -21
@@ -0,0 +1,84 @@
1
+ import { Linkable, LinkableSchema, StateOptions, ModelInput, ModelOutput, Immutable, ModelArray } from '@anchorlib/core';
2
+
3
+ /**
4
+ * @deprecated Use 'mutable()' instead.
5
+ * Creates a reactive state that can be used to manage state with Anchor.
6
+ * This overload is used when no schema is provided, or when using a LinkableSchema with StateOptions.
7
+ *
8
+ * @template T - The type of the initial value
9
+ * @template S - The schema type, extending LinkableSchema
10
+ * @param init - The initial value for the state
11
+ * @param options - Optional state options for the state
12
+ * @returns A reactive state containing the initial value
13
+ */
14
+ declare function anchorRef<T extends Linkable, S extends LinkableSchema = LinkableSchema>(init: T, options?: StateOptions<S>): T;
15
+ /**
16
+ * @deprecated Use 'mutable()' instead.
17
+ * Creates a reactive state with a defined schema for validation and type inference.
18
+ *
19
+ * @template S - The schema type, extending LinkableSchema
20
+ * @template T - The type of the initial value, must extend ModelInput of the schema
21
+ * @param init - The initial value for the state
22
+ * @param schema - The schema to validate and type the state
23
+ * @param options - Optional state options for the state
24
+ * @returns A reactive state containing the output model based on the schema
25
+ */
26
+ declare function anchorRef<S extends LinkableSchema, T extends ModelInput<S>>(init: T, schema?: S, options?: StateOptions): ModelOutput<S>;
27
+ /**
28
+ * @deprecated Use 'mutable()' instead.
29
+ * Creates an immutable reactive state with a defined schema.
30
+ *
31
+ * @template S - The schema type, extending LinkableSchema
32
+ * @template T - The type of the initial value, must extend ModelInput of the schema
33
+ * @param init - The initial value for the state
34
+ * @param schema - The schema to validate and type the state
35
+ * @param options - State options with immutable flag set to true
36
+ * @returns A reactive state containing an immutable output model based on the schema
37
+ */
38
+ declare function anchorRef<S extends LinkableSchema, T extends ModelInput<S>>(init: T, schema?: S, options?: StateOptions & {
39
+ immutable: true;
40
+ }): Immutable<ModelOutput<S>>;
41
+ /**
42
+ * @deprecated Use 'mutable()' instead.
43
+ * Reactive state alias for anchorRef.
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>>}}
45
+ */
46
+ declare const reactiveRef: typeof anchorRef;
47
+ /**
48
+ * @deprecated Use 'ordered()' instead.
49
+ * Creates a reactive state that maintains a sorted array state based on a comparison function.
50
+ *
51
+ * @template T - The type of elements in the array
52
+ * @template S - The schema type for array elements, extending ModelArray
53
+ * @param init - The initial array value for the state
54
+ * @param compare - A function that defines the sort order of elements
55
+ * @param options - Optional state options for the state
56
+ * @returns A reactive state containing the sorted array
57
+ */
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;
59
+ /**
60
+ * @deprecated Use 'flat()' instead.
61
+ * Creates a reactive state that maintains a flat array state.
62
+ *
63
+ * @template T - The type of elements in the array
64
+ * @template S - The schema type for array elements, extending ModelArray
65
+ * @param init - The initial array value for the state
66
+ * @param options - Optional state options for the state
67
+ * @returns A reactive state containing the flat array
68
+ */
69
+ declare function flatRef<T extends unknown[], S extends ModelArray = ModelArray>(init: T, options?: StateOptions<S>): T;
70
+ /**
71
+ * @deprecated Use 'raw()' instead.
72
+ * Creates a reactive state that mutates the underlying object.
73
+ *
74
+ * Unless you set the global options to `cloned: true`, you don't want to use this.
75
+ *
76
+ * @template T - The type of the initial value
77
+ * @template S - The schema type, extending LinkableSchema
78
+ * @param init - The initial value for the state
79
+ * @param options - Optional state options for the state
80
+ * @returns A reactive state containing the raw value
81
+ */
82
+ declare function rawRef<T extends Linkable, S extends LinkableSchema = LinkableSchema>(init: T, options?: StateOptions<S>): T;
83
+
84
+ export { anchorRef, flatRef, orderedRef, rawRef, reactiveRef };
package/dist/anchor.js ADDED
@@ -0,0 +1,19 @@
1
+ import { anchor } from '@anchorlib/core';
2
+
3
+ function anchorRef(init, schemaOptions, options) {
4
+ return anchor(init, schemaOptions, options);
5
+ }
6
+ const reactiveRef = anchorRef;
7
+ function orderedRef(init, compare, options) {
8
+ return anchor.ordered(init, compare, options);
9
+ }
10
+ function flatRef(init, options) {
11
+ return anchor.flat(init, options);
12
+ }
13
+ function rawRef(init, options) {
14
+ return anchor.raw(init, options);
15
+ }
16
+
17
+ export { anchorRef, flatRef, orderedRef, rawRef, reactiveRef };
18
+ //# sourceMappingURL=anchor.js.map
19
+ //# sourceMappingURL=anchor.js.map
@@ -0,0 +1 @@
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":[]}
@@ -0,0 +1,15 @@
1
+ import { ConstantRef } from './types.js';
2
+
3
+ /**
4
+ * @deprecated Use `derived()` instead.
5
+ * Creates a derived state from a source state with an optional transformation.
6
+ *
7
+ * @template T - The type of the input state
8
+ * @template R - The type of the transformed output
9
+ * @param state - The source state
10
+ * @param derive - A function that transforms the current state value
11
+ * @returns A read-only reference containing the derived state value
12
+ */
13
+ declare function derivedRef<T, R>(state: T, derive: (current: T) => R): ConstantRef<R>;
14
+
15
+ export { derivedRef };
package/dist/derive.js ADDED
@@ -0,0 +1,26 @@
1
+ import { anchor, subscribe } from '@anchorlib/core';
2
+ import { onDestroy } from 'svelte';
3
+ import { REF_REGISTRY } from './ref.js';
4
+
5
+ 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;
22
+ }
23
+
24
+ export { derivedRef };
25
+ //# sourceMappingURL=derive.js.map
26
+ //# sourceMappingURL=derive.js.map
@@ -0,0 +1 @@
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}"]}
@@ -0,0 +1,60 @@
1
+ import { FetchOptions, FetchState, StreamOptions } from '@anchorlib/core';
2
+
3
+ /**
4
+ * @deprecated Use 'fetchState()' or 'asyncState()' instead.
5
+ * Creates a reactive state that manages the state of a fetch request.
6
+ * This overload is for GET or DELETE requests, which typically do not have a request body.
7
+ *
8
+ * @template R The type of the data expected in the response.
9
+ * @param init The initial value for the fetch state.
10
+ * @param options The options for the fetch request, including the URL and method.
11
+ * @returns A `FetchState` object representing the state of the request.
12
+ */
13
+ declare function fetchRef<R>(init: R, options: FetchOptions & {
14
+ method: 'GET' | 'DELETE';
15
+ }): FetchState<R>;
16
+ /**
17
+ * @deprecated Use 'fetchState()' or 'asyncState()' instead.
18
+ * Creates a readable Svelte store that manages the state of a fetch request.
19
+ * This overload is for POST, PUT, or PATCH requests, which typically include a request body.
20
+ *
21
+ * @template R The type of the data expected in the response.
22
+ * @template P The type of the request body.
23
+ * @param init The initial value for the fetch state.
24
+ * @param options The options for the fetch request, including the URL, method, and body.
25
+ * @returns A `FetchState` object representing the state of the request.
26
+ */
27
+ declare function fetchRef<R, P>(init: R, options: FetchOptions & {
28
+ method: 'POST' | 'PUT' | 'PATCH';
29
+ body: P;
30
+ }): FetchState<R>;
31
+ /**
32
+ * @deprecated Use 'streamState()' instead.
33
+ * Creates a reactive state that manages the state of a streaming request.
34
+ * This overload is for GET or DELETE requests, which typically do not have a request body.
35
+ *
36
+ * @template R The type of the data expected in the response.
37
+ * @param init The initial value for the fetch state.
38
+ * @param options The options for the stream request, including the URL and method.
39
+ * @returns A `FetchState` object representing the state of the request.
40
+ */
41
+ declare function streamRef<R>(init: R, options: StreamOptions<R> & {
42
+ method: 'GET' | 'DELETE';
43
+ }): FetchState<R>;
44
+ /**
45
+ * @deprecated Use 'streamState()' instead.
46
+ * Creates a reactive state that manages the state of a streaming request.
47
+ * This overload is for POST, PUT, or PATCH requests, which typically include a request body.
48
+ *
49
+ * @template R The type of the data expected in the response.
50
+ * @template P The type of the request body.
51
+ * @param init The initial value for the fetch state.
52
+ * @param options The options for the stream request, including the URL, method, and body.
53
+ * @returns A `FetchState` object representing the state of the request.
54
+ */
55
+ declare function streamRef<R, P>(init: R, options: StreamOptions<R> & {
56
+ method: 'POST' | 'PUT' | 'PATCH';
57
+ body: P;
58
+ }): FetchState<R>;
59
+
60
+ export { fetchRef, streamRef };
package/dist/fetch.js ADDED
@@ -0,0 +1,12 @@
1
+ import { fetchState, streamState } from '@anchorlib/core';
2
+
3
+ function fetchRef(init, options) {
4
+ return fetchState(init, options);
5
+ }
6
+ function streamRef(init, options) {
7
+ return streamState(init, options);
8
+ }
9
+
10
+ export { fetchRef, streamRef };
11
+ //# sourceMappingURL=fetch.js.map
12
+ //# sourceMappingURL=fetch.js.map
@@ -0,0 +1 @@
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}"]}
@@ -0,0 +1,12 @@
1
+ import { State, HistoryOptions, HistoryState } from '@anchorlib/core';
2
+
3
+ /**
4
+ * @deprecated Use 'history()' instead.
5
+ * Creates a reactive state that reflects the history state of a given Anchor state.
6
+ * @param state The initial Anchor state.
7
+ * @param options Optional history options.
8
+ * @returns A `HistoryState` object representing the state of the history.
9
+ */
10
+ declare function historyRef<T extends State>(state: T, options?: HistoryOptions): HistoryState;
11
+
12
+ export { historyRef };
@@ -0,0 +1,9 @@
1
+ import { history } from '@anchorlib/core';
2
+
3
+ function historyRef(state, options) {
4
+ return history(state, options);
5
+ }
6
+
7
+ export { historyRef };
8
+ //# sourceMappingURL=history.js.map
9
+ //# sourceMappingURL=history.js.map
@@ -0,0 +1 @@
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}"]}
@@ -0,0 +1,47 @@
1
+ import { State, LinkableSchema, StateOptions, Immutable, ModelInput, StateBaseOptions, ImmutableOutput, Mutable, MutationKey, MutablePart } from '@anchorlib/core';
2
+
3
+ /**
4
+ * @deprecated Use 'immutable()' instead.
5
+ * Creates an immutable state from a state object.
6
+ *
7
+ * @template T The type of the state object.
8
+ * @template S The type of the linkable schema.
9
+ * @param init The initial state object.
10
+ * @param options Optional state options.
11
+ * @returns An immutable state.
12
+ */
13
+ declare function immutableRef<T extends State, S extends LinkableSchema = LinkableSchema>(init: T, options?: StateOptions<S>): Immutable<T>;
14
+ /**
15
+ * @deprecated Use 'immutable()' instead.
16
+ * Creates an immutable state from a model input and a schema.
17
+ *
18
+ * @template S The type of the linkable schema.
19
+ * @template T The type of the model input.
20
+ * @param init The initial model input.
21
+ * @param schema The linkable schema.
22
+ * @param options Optional base state options.
23
+ * @returns An immutable state.
24
+ */
25
+ declare function immutableRef<S extends LinkableSchema, T extends ModelInput<S>>(init: T, schema: S, options?: StateBaseOptions): ImmutableOutput<S>;
26
+ /**
27
+ * @deprecated Use 'writable()' instead.
28
+ * Creates a writable state from a state object.
29
+ *
30
+ * @template T The type of the state object.
31
+ * @param state The initial state object.
32
+ * @returns A mutable state.
33
+ */
34
+ declare function writableRef<T extends State>(state: T): Mutable<T>;
35
+ /**
36
+ * @deprecated Use 'writable()' instead.
37
+ * Creates a writable state from a state object and a list of contracts.
38
+ *
39
+ * @template T The type of the state object.
40
+ * @template K The type of the mutation keys.
41
+ * @param state The initial state object.
42
+ * @param contracts A list of mutation keys.
43
+ * @returns A mutable part of the state.
44
+ */
45
+ declare function writableRef<T extends State, K extends MutationKey<T>[]>(state: T, contracts: K): MutablePart<T, K>;
46
+
47
+ export { immutableRef, writableRef };
@@ -0,0 +1,12 @@
1
+ import { anchor } from '@anchorlib/core';
2
+
3
+ function immutableRef(init, schemaOptions, options) {
4
+ return anchor.immutable(init, schemaOptions, options);
5
+ }
6
+ function writableRef(state, contracts) {
7
+ return anchor.writable(state, contracts);
8
+ }
9
+
10
+ export { immutableRef, writableRef };
11
+ //# sourceMappingURL=immutable.js.map
12
+ //# sourceMappingURL=immutable.js.map
@@ -0,0 +1 @@
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}"]}