cross-state 0.53.3 → 0.54.0

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 (236) hide show
  1. package/dist/chunk-CUT6urMc.cjs +30 -0
  2. package/dist/diff-BQ8bB3Wk.d.cts +22 -0
  3. package/dist/diff-gZezL04N.d.ts +22 -0
  4. package/dist/extendedJson-BZkQBXEv.js +29 -0
  5. package/dist/extendedJson-BZkQBXEv.js.map +1 -0
  6. package/dist/extendedJson-Dn2F7Edo.cjs +53 -0
  7. package/dist/extendedJson-Dn2F7Edo.cjs.map +1 -0
  8. package/dist/hash-BV06P7va.js +19 -0
  9. package/dist/hash-BV06P7va.js.map +1 -0
  10. package/dist/hash-CJPl7SRj.cjs +30 -0
  11. package/dist/hash-CJPl7SRj.cjs.map +1 -0
  12. package/dist/index.cjs +49 -0
  13. package/dist/index.cjs.map +1 -0
  14. package/dist/index.d.cts +59 -0
  15. package/dist/index.d.ts +59 -0
  16. package/dist/index.js +20 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/mutative/index.cjs +3 -0
  19. package/dist/mutative/index.d.cts +3 -0
  20. package/dist/mutative/index.d.ts +3 -0
  21. package/dist/mutative/index.js +3 -0
  22. package/dist/mutative/register.cjs +10 -0
  23. package/dist/mutative/register.cjs.map +1 -0
  24. package/dist/mutative/register.d.cts +11 -0
  25. package/dist/mutative/register.d.ts +9 -0
  26. package/dist/mutative/register.js +10 -0
  27. package/dist/mutative/register.js.map +1 -0
  28. package/dist/mutativeMethods-6QzygG3W.d.cts +13 -0
  29. package/dist/mutativeMethods-Br3xN2Iq.d.ts +13 -0
  30. package/dist/mutativeMethods-CZKeRIDL.js +27 -0
  31. package/dist/mutativeMethods-CZKeRIDL.js.map +1 -0
  32. package/dist/mutativeMethods-CgXk_bMt.cjs +33 -0
  33. package/dist/mutativeMethods-CgXk_bMt.cjs.map +1 -0
  34. package/dist/patchMethods-C3L7Kh8T.d.cts +48 -0
  35. package/dist/patchMethods-D5YJwcpn.cjs +264 -0
  36. package/dist/patchMethods-D5YJwcpn.cjs.map +1 -0
  37. package/dist/patchMethods-DRPfkhAe.js +241 -0
  38. package/dist/patchMethods-DRPfkhAe.js.map +1 -0
  39. package/dist/patchMethods-Dxad6HF6.d.ts +48 -0
  40. package/dist/patches/index.cjs +5 -0
  41. package/dist/patches/index.d.cts +4 -0
  42. package/dist/patches/index.d.ts +4 -0
  43. package/dist/patches/index.js +5 -0
  44. package/dist/patches/register.cjs +11 -0
  45. package/dist/patches/register.cjs.map +1 -0
  46. package/dist/patches/register.d.cts +12 -0
  47. package/dist/patches/register.d.ts +10 -0
  48. package/dist/patches/register.js +11 -0
  49. package/dist/patches/register.js.map +1 -0
  50. package/dist/persist/register.cjs +13 -0
  51. package/dist/persist/register.cjs.map +1 -0
  52. package/dist/persist/register.d.cts +15 -0
  53. package/dist/persist/register.d.ts +13 -0
  54. package/dist/persist/register.js +13 -0
  55. package/dist/persist/register.js.map +1 -0
  56. package/dist/persist-BluRVcW6.js +258 -0
  57. package/dist/persist-BluRVcW6.js.map +1 -0
  58. package/dist/persist-CPjpg6D0.d.ts +61 -0
  59. package/dist/persist-CztClydq.cjs +263 -0
  60. package/dist/persist-CztClydq.cjs.map +1 -0
  61. package/dist/persist-D7MAsyyW.d.cts +61 -0
  62. package/dist/propAccess-ByqBjC19.cjs +173 -0
  63. package/dist/propAccess-ByqBjC19.cjs.map +1 -0
  64. package/dist/propAccess-DGchzVfy.js +113 -0
  65. package/dist/propAccess-DGchzVfy.js.map +1 -0
  66. package/dist/react/index.cjs +610 -0
  67. package/dist/react/index.cjs.map +1 -0
  68. package/dist/react/index.d.cts +305 -0
  69. package/dist/react/index.d.ts +305 -0
  70. package/dist/react/index.js +590 -0
  71. package/dist/react/index.js.map +1 -0
  72. package/dist/react/register.cjs +16 -0
  73. package/dist/react/register.cjs.map +1 -0
  74. package/dist/react/register.d.cts +16 -0
  75. package/dist/react/register.d.ts +14 -0
  76. package/dist/react/register.js +16 -0
  77. package/dist/react/register.js.map +1 -0
  78. package/dist/scope-DI1OFHcr.d.ts +167 -0
  79. package/dist/scope-DO5vpLPV.d.cts +167 -0
  80. package/dist/scope-DU5dFP1T.js +322 -0
  81. package/dist/scope-DU5dFP1T.js.map +1 -0
  82. package/dist/scope-DvqvkIHB.cjs +369 -0
  83. package/dist/scope-DvqvkIHB.cjs.map +1 -0
  84. package/dist/store-BEsiS8y7.d.cts +242 -0
  85. package/dist/store-BWMWEUpu.cjs +819 -0
  86. package/dist/store-BWMWEUpu.cjs.map +1 -0
  87. package/dist/store-DKaeE840.d.ts +242 -0
  88. package/dist/store-Dr8gM3lq.js +730 -0
  89. package/dist/store-Dr8gM3lq.js.map +1 -0
  90. package/dist/storeMethods-AIJSwxHz.js +315 -0
  91. package/dist/storeMethods-AIJSwxHz.js.map +1 -0
  92. package/dist/storeMethods-BQwU2Uia.d.cts +107 -0
  93. package/dist/storeMethods-C4luym7C.d.ts +107 -0
  94. package/dist/storeMethods-DVVsmUg1.cjs +375 -0
  95. package/dist/storeMethods-DVVsmUg1.cjs.map +1 -0
  96. package/package.json +92 -135
  97. package/dist/cjs/hash.cjs +0 -30
  98. package/dist/cjs/hash.cjs.map +0 -1
  99. package/dist/cjs/index.cjs +0 -56
  100. package/dist/cjs/index.cjs.map +0 -1
  101. package/dist/cjs/index2.cjs +0 -300
  102. package/dist/cjs/index2.cjs.map +0 -1
  103. package/dist/cjs/mutative/index.cjs +0 -10
  104. package/dist/cjs/mutative/index.cjs.map +0 -1
  105. package/dist/cjs/mutative/register.cjs +0 -8
  106. package/dist/cjs/mutative/register.cjs.map +0 -1
  107. package/dist/cjs/mutativeMethods.cjs +0 -29
  108. package/dist/cjs/mutativeMethods.cjs.map +0 -1
  109. package/dist/cjs/patches/index.cjs +0 -10
  110. package/dist/cjs/patches/index.cjs.map +0 -1
  111. package/dist/cjs/patches/register.cjs +0 -8
  112. package/dist/cjs/patches/register.cjs.map +0 -1
  113. package/dist/cjs/persist/register.cjs +0 -11
  114. package/dist/cjs/persist/register.cjs.map +0 -1
  115. package/dist/cjs/persist.cjs +0 -302
  116. package/dist/cjs/persist.cjs.map +0 -1
  117. package/dist/cjs/propAccess.cjs +0 -162
  118. package/dist/cjs/propAccess.cjs.map +0 -1
  119. package/dist/cjs/react/index.cjs +0 -628
  120. package/dist/cjs/react/index.cjs.map +0 -1
  121. package/dist/cjs/react/register.cjs +0 -13
  122. package/dist/cjs/react/register.cjs.map +0 -1
  123. package/dist/cjs/scope.cjs +0 -400
  124. package/dist/cjs/scope.cjs.map +0 -1
  125. package/dist/cjs/store.cjs +0 -829
  126. package/dist/cjs/store.cjs.map +0 -1
  127. package/dist/cjs/storeMethods.cjs +0 -856
  128. package/dist/cjs/storeMethods.cjs.map +0 -1
  129. package/dist/cjs/urlStore.cjs +0 -120
  130. package/dist/cjs/urlStore.cjs.map +0 -1
  131. package/dist/es/hash.mjs +0 -27
  132. package/dist/es/hash.mjs.map +0 -1
  133. package/dist/es/index.mjs +0 -20
  134. package/dist/es/index.mjs.map +0 -1
  135. package/dist/es/index2.mjs +0 -291
  136. package/dist/es/index2.mjs.map +0 -1
  137. package/dist/es/mutative/index.mjs +0 -2
  138. package/dist/es/mutative/index.mjs.map +0 -1
  139. package/dist/es/mutative/register.mjs +0 -6
  140. package/dist/es/mutative/register.mjs.map +0 -1
  141. package/dist/es/mutativeMethods.mjs +0 -27
  142. package/dist/es/mutativeMethods.mjs.map +0 -1
  143. package/dist/es/patches/index.mjs +0 -2
  144. package/dist/es/patches/index.mjs.map +0 -1
  145. package/dist/es/patches/register.mjs +0 -6
  146. package/dist/es/patches/register.mjs.map +0 -1
  147. package/dist/es/persist/register.mjs +0 -9
  148. package/dist/es/persist/register.mjs.map +0 -1
  149. package/dist/es/persist.mjs +0 -300
  150. package/dist/es/persist.mjs.map +0 -1
  151. package/dist/es/propAccess.mjs +0 -151
  152. package/dist/es/propAccess.mjs.map +0 -1
  153. package/dist/es/react/index.mjs +0 -611
  154. package/dist/es/react/index.mjs.map +0 -1
  155. package/dist/es/react/register.mjs +0 -11
  156. package/dist/es/react/register.mjs.map +0 -1
  157. package/dist/es/scope.mjs +0 -391
  158. package/dist/es/scope.mjs.map +0 -1
  159. package/dist/es/store.mjs +0 -812
  160. package/dist/es/store.mjs.map +0 -1
  161. package/dist/es/storeMethods.mjs +0 -845
  162. package/dist/es/storeMethods.mjs.map +0 -1
  163. package/dist/es/urlStore.mjs +0 -116
  164. package/dist/es/urlStore.mjs.map +0 -1
  165. package/dist/types/core/cache.d.ts +0 -119
  166. package/dist/types/core/commonTypes.d.ts +0 -76
  167. package/dist/types/core/index.d.ts +0 -6
  168. package/dist/types/core/resourceGroup.d.ts +0 -16
  169. package/dist/types/core/scope.d.ts +0 -5
  170. package/dist/types/core/store.d.ts +0 -86
  171. package/dist/types/core/urlStore.d.ts +0 -21
  172. package/dist/types/index.d.ts +0 -14
  173. package/dist/types/lib/applyPatches.d.ts +0 -2
  174. package/dist/types/lib/autobind.d.ts +0 -1
  175. package/dist/types/lib/cacheState.d.ts +0 -20
  176. package/dist/types/lib/calcDuration.d.ts +0 -2
  177. package/dist/types/lib/calculatedValue.d.ts +0 -9
  178. package/dist/types/lib/castArray.d.ts +0 -1
  179. package/dist/types/lib/clone.d.ts +0 -1
  180. package/dist/types/lib/constrain.d.ts +0 -1
  181. package/dist/types/lib/debounce.d.ts +0 -12
  182. package/dist/types/lib/deferred.d.ts +0 -5
  183. package/dist/types/lib/diff.d.ts +0 -17
  184. package/dist/types/lib/disposable.d.ts +0 -3
  185. package/dist/types/lib/equals.d.ts +0 -3
  186. package/dist/types/lib/extendedJson.d.ts +0 -5
  187. package/dist/types/lib/forwardError.d.ts +0 -1
  188. package/dist/types/lib/hash.d.ts +0 -5
  189. package/dist/types/lib/helpers.d.ts +0 -2
  190. package/dist/types/lib/instanceCache.d.ts +0 -18
  191. package/dist/types/lib/isPromise.d.ts +0 -1
  192. package/dist/types/lib/makeSelector.d.ts +0 -2
  193. package/dist/types/lib/maybePromise.d.ts +0 -1
  194. package/dist/types/lib/path.d.ts +0 -41
  195. package/dist/types/lib/promiseChain.d.ts +0 -5
  196. package/dist/types/lib/promiseWithCancel.d.ts +0 -8
  197. package/dist/types/lib/promiseWithState.d.ts +0 -9
  198. package/dist/types/lib/propAccess.d.ts +0 -7
  199. package/dist/types/lib/queue.d.ts +0 -11
  200. package/dist/types/lib/standardMethods.d.ts +0 -20
  201. package/dist/types/lib/throttle.d.ts +0 -2
  202. package/dist/types/lib/trackingProxy.d.ts +0 -2
  203. package/dist/types/lib/trie.d.ts +0 -11
  204. package/dist/types/lib/typeHelpers.d.ts +0 -12
  205. package/dist/types/lib/unwrapPromise.d.ts +0 -1
  206. package/dist/types/lib/updateHelpers.d.ts +0 -1
  207. package/dist/types/lib/wildcardMatch.d.ts +0 -3
  208. package/dist/types/mutative/index.d.ts +0 -1
  209. package/dist/types/mutative/mutativeMethods.d.ts +0 -11
  210. package/dist/types/mutative/register.d.ts +0 -7
  211. package/dist/types/patches/index.d.ts +0 -1
  212. package/dist/types/patches/patchMethods.d.ts +0 -44
  213. package/dist/types/patches/register.d.ts +0 -7
  214. package/dist/types/persist/index.d.ts +0 -3
  215. package/dist/types/persist/persist.d.ts +0 -40
  216. package/dist/types/persist/persistPathHelpers.d.ts +0 -6
  217. package/dist/types/persist/persistStorage.d.ts +0 -17
  218. package/dist/types/persist/register.d.ts +0 -9
  219. package/dist/types/react/cacheMethods.d.ts +0 -5
  220. package/dist/types/react/form/customInput.d.ts +0 -6
  221. package/dist/types/react/form/form.d.ts +0 -98
  222. package/dist/types/react/form/formField.d.ts +0 -68
  223. package/dist/types/react/form/formForEach.d.ts +0 -19
  224. package/dist/types/react/form/index.d.ts +0 -3
  225. package/dist/types/react/form/useFormAutosave.d.ts +0 -9
  226. package/dist/types/react/index.d.ts +0 -11
  227. package/dist/types/react/loadingBoundary.d.ts +0 -21
  228. package/dist/types/react/register.d.ts +0 -15
  229. package/dist/types/react/scope.d.ts +0 -24
  230. package/dist/types/react/scopeMethods.d.ts +0 -20
  231. package/dist/types/react/storeMethods.d.ts +0 -15
  232. package/dist/types/react/useCache.d.ts +0 -34
  233. package/dist/types/react/useDecoupledState.d.ts +0 -7
  234. package/dist/types/react/useProp.d.ts +0 -8
  235. package/dist/types/react/useStore.d.ts +0 -16
  236. package/dist/types/react/useUrlParamScope.d.ts +0 -4
@@ -1,68 +0,0 @@
1
- import { type PathAsString, type Value } from '../../lib/path';
2
- import { type Component, type ComponentPropsWithoutRef, type ReactNode } from 'react';
3
- import { type Field, type Form, type FormContext, type FormInstance } from './form';
4
- export interface FormFieldComponentProps<TValue, TPath> {
5
- name: TPath;
6
- value: TValue;
7
- onChange: (event: {
8
- target: {
9
- value: TValue;
10
- };
11
- } | TValue | undefined, ...args: any[]) => void;
12
- onBlur: (...args: any[]) => void;
13
- }
14
- export type FormFieldInfos<TDraft, TOriginal, TPath extends string> = Field<TDraft, TOriginal, TPath> & {
15
- hasTriggeredValidations: boolean;
16
- };
17
- type NativeInputType = 'input' | 'select' | 'textarea';
18
- type PartialComponentType<P> = (new (props: P, context?: any) => Component<P, any>) | ((props: P, context?: any) => ReactNode);
19
- export type FormFieldComponent = NativeInputType | PartialComponentType<any>;
20
- type FieldValue<T extends FormFieldComponent> = ComponentPropsWithoutRef<T>['value'];
21
- type FieldChangeValue<T extends FormFieldComponent> = ComponentPropsWithoutRef<T> extends {
22
- onChange?: (update: infer U) => void;
23
- } ? U extends {
24
- target: {
25
- value: infer V;
26
- };
27
- } ? V : U : never;
28
- type MakeOptional<T, Keys extends string> = Omit<T, Keys> & Partial<Pick<T, Keys & keyof T>>;
29
- export type FormFieldProps<TPath, TDraft> = {
30
- name: TPath & PathAsString<TDraft>;
31
- commitOnBlur?: boolean;
32
- commitDebounce?: number;
33
- };
34
- export type FormFieldPropsWithRender<TDraft, TOriginal, TPath extends string> = FormFieldProps<TPath, TDraft> & NoInfer<{
35
- component?: undefined;
36
- render: (props: FormFieldComponentProps<Value<TDraft, TPath>, TPath>, info: FormFieldInfos<TDraft, TOriginal, TPath>, form: FormContext<TDraft, TOriginal>) => ReactNode;
37
- inputFilter?: undefined;
38
- defaultValue?: undefined;
39
- serialize?: undefined;
40
- deserialize?: undefined;
41
- onChange?: undefined;
42
- onBlur?: undefined;
43
- }>;
44
- type Serialize<TDraft, TOriginal, TPath, TComponent extends FormFieldComponent> = (value: Value<TDraft, TPath>, formState: FormInstance<TDraft, TOriginal>) => FieldValue<TComponent>;
45
- type Deserialize<TDraft, TOriginal, TPath, TComponent extends FormFieldComponent> = (value: FieldChangeValue<TComponent>, formState: FormInstance<TDraft, TOriginal>) => Value<TDraft, TPath>;
46
- export type FormFieldPropsWithComponent<TDraft, TOriginal, TPath extends string, TComponent extends FormFieldComponent> = FormFieldProps<TPath, TDraft> & {
47
- component?: TComponent;
48
- render?: undefined;
49
- } & NoInfer<{
50
- inputFilter?: (value: FieldChangeValue<TComponent>) => boolean;
51
- } & MakeOptional<Omit<ComponentPropsWithoutRef<TComponent>, 'id' | 'name' | 'value' | 'defaultValue'>, 'onChange' | 'onBlur'> & (Value<TDraft, TPath> extends Exclude<FieldValue<TComponent>, undefined> ? {
52
- defaultValue?: FieldValue<TComponent>;
53
- serialize?: Serialize<TDraft, TOriginal, TPath, TComponent>;
54
- } : Value<TDraft, TPath> extends FieldValue<TComponent> ? {
55
- defaultValue: FieldValue<TComponent>;
56
- serialize?: Serialize<TDraft, TOriginal, TPath, TComponent>;
57
- } | {
58
- defaultValue?: FieldValue<TComponent>;
59
- serialize: Serialize<TDraft, TOriginal, TPath, TComponent>;
60
- } : {
61
- serialize: Serialize<TDraft, TOriginal, TPath, TComponent>;
62
- }) & (FieldChangeValue<TComponent> extends Value<TDraft, TPath> ? {
63
- deserialize?: Deserialize<TDraft, TOriginal, TPath, TComponent>;
64
- } : {
65
- deserialize: Deserialize<TDraft, TOriginal, TPath, TComponent>;
66
- })>;
67
- export declare function FormField<TDraft, TOriginal, TPath extends string, TComponent extends FormFieldComponent>(this: Form<TDraft, any>, { name, component, commitOnBlur, commitDebounce, render, inputFilter, defaultValue, serialize, deserialize, onChange, onBlur, ...restProps }: FormFieldPropsWithRender<TDraft, TOriginal, TPath> | FormFieldPropsWithComponent<TDraft, TOriginal, TPath, TComponent>): JSX.Element | null;
68
- export {};
@@ -1,19 +0,0 @@
1
- import { type GetKeys, type Join, type PathAsString, type Value } from '../../lib/path';
2
- import { type ReactNode } from 'react';
3
- import { type FieldHelperMethods, type Form } from './form';
4
- export type ElementName<TDraft, TPath extends string> = keyof {
5
- [Path in TPath as Join<Path, GetKeys<NonNullable<Value<TDraft, Path>>> & (string | number)>]: 1;
6
- };
7
- export interface FormForEachProps<TDraft, TPath extends string> {
8
- name: TPath & PathAsString<TDraft>;
9
- renderElement?: (props: {
10
- name: ElementName<TDraft, TPath>;
11
- key: `${GetKeys<NonNullable<Value<TDraft, TPath>>> & (string | number)}`;
12
- index: number;
13
- remove: () => void;
14
- }) => ReactNode;
15
- children?: (props: {
16
- setValue: (value: Value<TDraft, TPath> | ((value: Value<TDraft, TPath>) => Value<TDraft, TPath>)) => void;
17
- } & FieldHelperMethods<TDraft, TPath>) => ReactNode;
18
- }
19
- export declare function FormForEach<TDraft, TPath extends string>(this: Form<TDraft, any>, { name, renderElement, children }: FormForEachProps<TDraft, TPath>): JSX.Element;
@@ -1,3 +0,0 @@
1
- export { CustomInput, type CustomInputProps } from './customInput';
2
- export { Form, createForm, type Field, type FormContext, type FormDerivedState, type FormInstance, type FormOptions, type FormState, type Transform, type Validation, type Validations, } from './form';
3
- export { type FormFieldComponent, type FormFieldProps } from './formField';
@@ -1,9 +0,0 @@
1
- import type { Duration } from '../../core';
2
- import type { MaybePromise } from '../../lib/maybePromise';
3
- import type { FormContext } from './form';
4
- export interface FormAutosaveOptions<TDraft, TOriginal> {
5
- save: (draft: TDraft, form: FormContext<TDraft, TOriginal>) => MaybePromise<void>;
6
- debounce?: Duration;
7
- resetAfterSave?: boolean;
8
- }
9
- export declare function useFormAutosave<TDraft, TOriginal extends TDraft>(form: FormContext<TDraft, TOriginal>): void;
@@ -1,11 +0,0 @@
1
- export { cacheMethods } from './cacheMethods';
2
- export * from './form';
3
- export { LoadingBoundary, useLoadingBoundary, type LoadingBoundaryEntry, type LoadingBoundaryProps, } from './loadingBoundary';
4
- export { ScopeProvider, useScope, type ScopeProps } from './scope';
5
- export { scopeMethods } from './scopeMethods';
6
- export { storeMethods } from './storeMethods';
7
- export { useCache, type UseCacheArray, type UseCacheValue } from './useCache';
8
- export { useDecoupledState, type UseDecoupledStateOptions } from './useDecoupledState';
9
- export { useProp } from './useProp';
10
- export { useStore, type UseStoreOptions } from './useStore';
11
- export { useUrlParamScope } from './useUrlParamScope';
@@ -1,21 +0,0 @@
1
- import { type ReactNode } from 'react';
2
- export interface LoadingBoundaryEntry {
3
- label?: ReactNode;
4
- }
5
- export interface LoadingBoundaryProps {
6
- /**
7
- * Fallback node to render when there are loading components within the boundary.
8
- */
9
- fallback?: ReactNode | ((entries: LoadingBoundaryEntry[]) => ReactNode);
10
- /**
11
- * Child node to render when there are no loading components within the boundary.
12
- */
13
- children?: ReactNode;
14
- /**
15
- * Add a loading state from outside the boundary. Useful for when you want to
16
- * show a loading state for a component that is not a child of the boundary.
17
- */
18
- isLoading?: boolean;
19
- }
20
- export declare function LoadingBoundary({ fallback, children, isLoading: isLoadingExternal, }: LoadingBoundaryProps): JSX.Element;
21
- export declare function useLoadingBoundary(isLoading: boolean | undefined, label?: ReactNode): void;
@@ -1,15 +0,0 @@
1
- import { cacheMethods } from '../react/cacheMethods';
2
- import { scopeMethods } from '../react/scopeMethods';
3
- import { storeMethods } from './storeMethods';
4
- type StoreMethods = typeof storeMethods;
5
- type CacheMethods = typeof cacheMethods;
6
- type ScopeMethods = typeof scopeMethods;
7
- declare module '../core' {
8
- interface Store<T> extends StoreMethods {
9
- }
10
- interface Cache<T> extends CacheMethods {
11
- }
12
- interface Scope<T> extends ScopeMethods {
13
- }
14
- }
15
- export {};
@@ -1,24 +0,0 @@
1
- import type { Scope, Selector, Update } from '../core';
2
- import { type Store } from '../core/store';
3
- import type { Constrain } from '../lib/constrain';
4
- import type { Path, Value } from '../lib/path';
5
- import { type Context, type ReactNode } from 'react';
6
- import { type UseStoreOptions } from './useStore';
7
- export type ScopeProps<T> = {
8
- scope: Scope<T>;
9
- store?: Store<T>;
10
- children?: ReactNode;
11
- };
12
- declare module '../core' {
13
- interface Scope<T> {
14
- context?: Context<Store<T>>;
15
- }
16
- }
17
- export declare function ScopeProvider<T>({ scope, store: inputStore, children, }: ScopeProps<T>): JSX.Element;
18
- export declare function useScope<T>(scope: Scope<T>): Store<T>;
19
- export declare function useScopeStore<T, S>(scope: Scope<T>, selector: Selector<T, S>, option?: UseStoreOptions<S>): S;
20
- export declare function useScopeStore<T, const P>(scope: Scope<T>, selector: Constrain<P, Path<T>>, option?: UseStoreOptions<Value<T, P>>): Value<T, P>;
21
- export declare function useScopeStore<T>(scope: Scope<T>, option?: UseStoreOptions<T>): T;
22
- export declare function useScopeProp<T, S>(scope: Scope<T>, selector: Selector<T, S>, updater: (value: S) => Update<T>, options?: UseStoreOptions<S>): [value: S, setValue: Store<S>['set']];
23
- export declare function useScopeProp<T, const P>(scope: Scope<T>, selector: Constrain<P, Path<T>>, options?: UseStoreOptions<Value<T, P>>): [value: Value<T, P>, setValue: Store<Value<T, P>>['set']];
24
- export declare function useScopeProp<T>(scope: Scope<T>, options?: UseStoreOptions<T>): [value: T, setValue: Store<T>['set']];
@@ -1,20 +0,0 @@
1
- import type { Scope, Selector, Store, Update } from '../core';
2
- import type { Constrain } from '../lib/constrain';
3
- import type { Path, Value } from '../lib/path';
4
- import { type ScopeProps } from '../react/scope';
5
- import type { UseStoreOptions } from '../react/useStore';
6
- declare function boundUseScope<T>(this: Scope<T>): Store<T>;
7
- declare function boundUseScopeStore<T, S>(this: Scope<T>, selector: Selector<T, S>, option?: UseStoreOptions<S>): S;
8
- declare function boundUseScopeStore<T, const P>(this: Scope<T>, selector: Constrain<P, Path<T>>, option?: UseStoreOptions<Value<T, P>>): Value<T, P>;
9
- declare function boundUseScopeStore<T>(this: Scope<T>, option?: UseStoreOptions<T>): T;
10
- declare function boundUseScopeProp<T, S>(this: Scope<T>, selector: Selector<T, S>, updater: (value: S) => Update<T>, options?: UseStoreOptions<S>): [value: S, setValue: Store<S>['set']];
11
- declare function boundUseScopeProp<T, const P>(this: Scope<T>, selector: Constrain<P, Path<T>>, options?: UseStoreOptions<Value<T, P>>): [value: Value<T, P>, setValue: Store<Value<T, P>>['set']];
12
- declare function boundUseScopeProp<T>(this: Scope<T>, options?: UseStoreOptions<T>): [value: T, setValue: Store<T>['set']];
13
- declare function Provider<T>(this: Scope<T>, props: Omit<ScopeProps<T>, 'scope'>): JSX.Element;
14
- export declare const scopeMethods: {
15
- useScope: typeof boundUseScope;
16
- useStore: typeof boundUseScopeStore;
17
- useProp: typeof boundUseScopeProp;
18
- Provider: typeof Provider;
19
- };
20
- export {};
@@ -1,15 +0,0 @@
1
- import type { Selector, Store, Update } from '../core';
2
- import type { Constrain } from '../lib/constrain';
3
- import type { Path, Value } from '../lib/path';
4
- import { type UseStoreOptions } from '../react/useStore';
5
- declare function boundUseStore<T, S>(this: Store<T>, selector: Selector<T, S>, option?: UseStoreOptions<S>): S;
6
- declare function boundUseStore<T, const P>(this: Store<T>, selector: Constrain<P, Path<T>>, option?: UseStoreOptions<Value<T, P>>): Value<T, P>;
7
- declare function boundUseStore<T>(this: Store<T>, option?: UseStoreOptions<T>): T;
8
- declare function boundUseProp<T, S>(this: Store<T>, selector: Selector<T, S>, updater: (value: S) => Update<T>, options?: UseStoreOptions<S>): [value: S, setValue: Store<S>['set']];
9
- declare function boundUseProp<T, const P>(this: Store<T>, selector: Constrain<P, Path<T>>, options?: UseStoreOptions<Value<T, P>>): [value: Value<T, P>, setValue: Store<Value<T, P>>['set']];
10
- declare function boundUseProp<T>(this: Store<T>, options?: UseStoreOptions<T>): [value: T, setValue: Store<T>['set']];
11
- export declare const storeMethods: {
12
- useStore: typeof boundUseStore;
13
- useProp: typeof boundUseProp;
14
- };
15
- export {};
@@ -1,34 +0,0 @@
1
- import type { Cache } from '../core';
2
- import type { CacheState } from '../lib/cacheState';
3
- import { type UseStoreOptions } from './useStore';
4
- export type UseCacheArray<T> = [
5
- value: T | undefined,
6
- error: unknown | undefined,
7
- isUpdating: boolean,
8
- isStale: boolean
9
- ];
10
- export type UseCacheValue<T> = UseCacheArray<T> & CacheState<T>;
11
- export interface UseCacheOptions<T> extends UseStoreOptions<UseCacheArray<T> & CacheState<T>> {
12
- /**
13
- * If true, will always return undefined as value and no fetch will be triggered.
14
- * @default false
15
- */
16
- disabled?: boolean;
17
- /**
18
- * If true, the cache will be invalidated when the component mounts.
19
- * @default false
20
- */
21
- updateOnMount?: boolean;
22
- /**
23
- * If true, `useCache` will throw a promise when the cache is pending. This can be used with React Suspense.
24
- * @see https://react.dev/reference/react/Suspense
25
- * @default false
26
- */
27
- suspense?: boolean;
28
- /**
29
- * If true, `useCache` will register its loading state with the nearest `LoadingBoundary`.
30
- * @default false
31
- */
32
- loadingBoundary?: boolean;
33
- }
34
- export declare function useCache<T>(cache: Cache<T, any>, { passive, disabled, updateOnMount, withViewTransition, suspense, loadingBoundary, ...options }?: UseCacheOptions<T>): UseCacheValue<T>;
@@ -1,7 +0,0 @@
1
- import { type Duration } from '../core';
2
- export interface UseDecoupledStateOptions<T> {
3
- debounce?: Duration;
4
- throttle?: Duration;
5
- onCommit?: (value: T) => void;
6
- }
7
- export declare function useDecoupledState<T>(value: T, onChange: (value: T) => void, options?: UseDecoupledStateOptions<T>): [state: T, setState: (value: T) => void];
@@ -1,8 +0,0 @@
1
- import { type Selector, type Update } from '../core/commonTypes';
2
- import type { Store } from '../core/store';
3
- import type { Constrain } from '../lib/constrain';
4
- import { type Path, type Value } from '../lib/path';
5
- import { type UseStoreOptions } from './useStore';
6
- export declare function useProp<T, S>(store: Store<T>, selector: Selector<T, S>, updater: (value: S) => Update<T>, options?: UseStoreOptions<S>): [value: S, setValue: Store<S>['set']];
7
- export declare function useProp<T, const P>(store: Store<T>, selector: Constrain<P, Path<T>>, options?: UseStoreOptions<Value<T, P>>): [value: Value<T, P>, setValue: Store<Value<T, P>>['set']];
8
- export declare function useProp<T>(store: Store<T>, options?: UseStoreOptions<T>): [value: T, setValue: Store<T>['set']];
@@ -1,16 +0,0 @@
1
- import type { Selector, SubscribeOptions } from '../core/commonTypes';
2
- import type { Store } from '../core/store';
3
- import type { Constrain } from '../lib/constrain';
4
- import { type Path, type Value } from '../lib/path';
5
- export interface UseStoreOptions<S> extends Omit<SubscribeOptions, 'runNow' | 'passive'> {
6
- /**
7
- * If true, the cache content can be consumed but no fetch will be triggered.
8
- * @default false
9
- */
10
- passive?: boolean;
11
- disableTrackingProxy?: boolean;
12
- withViewTransition?: boolean | ((value: S) => unknown);
13
- }
14
- export declare function useStore<T, S>(store: Store<T>, selector: Selector<T, S>, option?: UseStoreOptions<S>): S;
15
- export declare function useStore<T, const P>(store: Store<T>, selector: Constrain<P, Path<T>>, option?: UseStoreOptions<Value<T, P>>): Value<T, P>;
16
- export declare function useStore<T>(store: Store<T>, option?: UseStoreOptions<T>): T;
@@ -1,4 +0,0 @@
1
- export declare function useUrlParamScope({ key, type, }: {
2
- key: string | string[];
3
- type?: 'search' | 'hash';
4
- }): void;