@data-client/vue 0.0.1

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 (72) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +315 -0
  3. package/data_client_logo_and_text.svg +64 -0
  4. package/dist/index.js +290 -0
  5. package/dist/index.umd.min.js +1 -0
  6. package/dist/package.json +1 -0
  7. package/lib/components/DataProvider.d.ts +11 -0
  8. package/lib/components/DataProvider.d.ts.map +1 -0
  9. package/lib/components/DataProvider.js +18 -0
  10. package/lib/consumers/index.d.ts +5 -0
  11. package/lib/consumers/index.d.ts.map +1 -0
  12. package/lib/consumers/index.js +5 -0
  13. package/lib/consumers/useInjects.d.ts +5 -0
  14. package/lib/consumers/useInjects.d.ts.map +1 -0
  15. package/lib/consumers/useInjects.js +8 -0
  16. package/lib/consumers/useQuery.d.ts +12 -0
  17. package/lib/consumers/useQuery.d.ts.map +1 -0
  18. package/lib/consumers/useQuery.js +29 -0
  19. package/lib/consumers/useSubscription.d.ts +8 -0
  20. package/lib/consumers/useSubscription.d.ts.map +1 -0
  21. package/lib/consumers/useSubscription.js +31 -0
  22. package/lib/consumers/useSuspense.d.ts +5 -0
  23. package/lib/consumers/useSuspense.d.ts.map +1 -0
  24. package/lib/consumers/useSuspense.js +29 -0
  25. package/lib/context.d.ts +10 -0
  26. package/lib/context.d.ts.map +1 -0
  27. package/lib/context.js +28 -0
  28. package/lib/index.d.ts +6 -0
  29. package/lib/index.d.ts.map +1 -0
  30. package/lib/index.js +8 -0
  31. package/lib/managers/index.d.ts +2 -0
  32. package/lib/managers/index.d.ts.map +1 -0
  33. package/lib/managers/index.js +2 -0
  34. package/lib/providers/getDefaultManagers.d.ts +14 -0
  35. package/lib/providers/getDefaultManagers.d.ts.map +1 -0
  36. package/lib/providers/getDefaultManagers.js +51 -0
  37. package/lib/providers/index.d.ts +3 -0
  38. package/lib/providers/index.d.ts.map +1 -0
  39. package/lib/providers/index.js +3 -0
  40. package/lib/providers/provideDataClient.d.ts +21 -0
  41. package/lib/providers/provideDataClient.d.ts.map +1 -0
  42. package/lib/providers/provideDataClient.js +94 -0
  43. package/package.json +143 -0
  44. package/src/__tests__/index.test.ts +10 -0
  45. package/src/__tests__/useQuery.web.ts +207 -0
  46. package/src/__tests__/useSubscription.web.ts +151 -0
  47. package/src/__tests__/useSuspense.web.ts +159 -0
  48. package/src/components/DataProvider.ts +26 -0
  49. package/src/consumers/index.ts +7 -0
  50. package/src/consumers/useInjects.ts +12 -0
  51. package/src/consumers/useQuery.ts +43 -0
  52. package/src/consumers/useSubscription.ts +44 -0
  53. package/src/consumers/useSuspense.ts +91 -0
  54. package/src/context.ts +42 -0
  55. package/src/index.ts +48 -0
  56. package/src/managers/index.ts +8 -0
  57. package/src/providers/getDefaultManagers.ts +80 -0
  58. package/src/providers/index.ts +2 -0
  59. package/src/providers/provideDataClient.ts +126 -0
  60. package/ts3.4/components/DataProvider.d.ts +11 -0
  61. package/ts3.4/consumers/index.d.ts +5 -0
  62. package/ts3.4/consumers/useInjects.d.ts +5 -0
  63. package/ts3.4/consumers/useQuery.d.ts +12 -0
  64. package/ts3.4/consumers/useSubscription.d.ts +12 -0
  65. package/ts3.4/consumers/useSuspense.d.ts +11 -0
  66. package/ts3.4/context.d.ts +10 -0
  67. package/ts3.4/index.d.ts +6 -0
  68. package/ts3.4/managers/index.d.ts +2 -0
  69. package/ts3.4/providers/getDefaultManagers.d.ts +14 -0
  70. package/ts3.4/providers/index.d.ts +3 -0
  71. package/ts3.4/providers/provideDataClient.d.ts +21 -0
  72. package/typescript.svg +8 -0
@@ -0,0 +1,91 @@
1
+ import { ExpiryStatus } from '@data-client/core';
2
+ import type {
3
+ EndpointInterface,
4
+ Denormalize,
5
+ Schema,
6
+ FetchFunction,
7
+ DenormalizeNullable,
8
+ ResolveType,
9
+ } from '@data-client/core';
10
+ import {
11
+ computed,
12
+ watch,
13
+ readonly,
14
+ type DeepReadonly,
15
+ type ComputedRef,
16
+ } from 'vue';
17
+
18
+ import { injectController, injectState } from '../context.js';
19
+
20
+ export default function useSuspense<
21
+ E extends EndpointInterface<
22
+ FetchFunction,
23
+ Schema | undefined,
24
+ undefined | false
25
+ >,
26
+ >(
27
+ endpoint: E,
28
+ ...args: readonly [...Parameters<E>]
29
+ ): Promise<
30
+ DeepReadonly<
31
+ ComputedRef<
32
+ E['schema'] extends undefined | null ? ResolveType<E>
33
+ : Denormalize<E['schema']>
34
+ >
35
+ >
36
+ >;
37
+
38
+ export default function useSuspense<
39
+ E extends EndpointInterface<
40
+ FetchFunction,
41
+ Schema | undefined,
42
+ undefined | false
43
+ >,
44
+ >(
45
+ endpoint: E,
46
+ ...args: readonly [...Parameters<E>] | readonly [null]
47
+ ): Promise<
48
+ DeepReadonly<
49
+ ComputedRef<
50
+ E['schema'] extends undefined | null ? ResolveType<E> | undefined
51
+ : DenormalizeNullable<E['schema']>
52
+ >
53
+ >
54
+ >;
55
+
56
+ export default async function useSuspense(
57
+ endpoint: any,
58
+ ...args: any[]
59
+ ): Promise<any> {
60
+ const stateRef = injectState();
61
+ const controller = injectController();
62
+
63
+ const key = args[0] !== null ? endpoint.key(...args) : '';
64
+ const responseMeta = computed(() =>
65
+ controller.getResponseMeta(endpoint, ...args, stateRef.value),
66
+ );
67
+
68
+ // If invalid or expired, perform fetch and await it to integrate with Vue Suspense
69
+ const isInvalid =
70
+ responseMeta.value.expiryStatus === ExpiryStatus.Invalid ||
71
+ Date.now() > responseMeta.value.expiresAt;
72
+ if (key && isInvalid) {
73
+ await controller.fetch(endpoint, ...(args as any));
74
+ }
75
+
76
+ const error = controller.getError(endpoint, ...args, stateRef.value);
77
+ if (error) throw error;
78
+
79
+ // Maintain GC refcounts on data mount/changes
80
+ watch(
81
+ () => responseMeta.value.data,
82
+ (_newVal, _oldVal, onCleanup) => {
83
+ const decrement = responseMeta.value.countRef();
84
+ onCleanup(() => decrement());
85
+ },
86
+ { immediate: true },
87
+ );
88
+
89
+ // Return readonly computed ref - Vue automatically unwraps in templates and reactive contexts
90
+ return readonly(computed(() => responseMeta.value.data));
91
+ }
package/src/context.ts ADDED
@@ -0,0 +1,42 @@
1
+ import { initialState, Controller } from '@data-client/core';
2
+ import type { State } from '@data-client/core';
3
+ import { inject, type InjectionKey, shallowRef, type ShallowRef } from 'vue';
4
+
5
+ export const StateKey: InjectionKey<ShallowRef<State<unknown>>> = Symbol(
6
+ 'DataClientState',
7
+ ) as any;
8
+ export const ControllerKey: InjectionKey<Controller> = Symbol(
9
+ 'DataClientController',
10
+ ) as any;
11
+
12
+ /** Fallback state ref used when no provider is found. */
13
+ export const FallbackStateRef: ShallowRef<State<unknown>> =
14
+ shallowRef(initialState);
15
+
16
+ export function injectController(): Controller {
17
+ const ctrl = inject(ControllerKey, null);
18
+ if (!ctrl) {
19
+ if (process.env.NODE_ENV !== 'production') {
20
+ console.error(
21
+ 'It appears you are trying to use Reactive Data Client (Vue) without a provider.\n' +
22
+ 'Follow instructions: https://dataclient.io/docs/getting-started/installation#add-provider-at-top-level-component',
23
+ );
24
+ }
25
+ return new Controller();
26
+ }
27
+ return ctrl;
28
+ }
29
+
30
+ export function injectState(): ShallowRef<State<unknown>> {
31
+ const state = inject(StateKey, null);
32
+ if (!state) {
33
+ if (process.env.NODE_ENV !== 'production') {
34
+ console.error(
35
+ 'It appears you are trying to use Reactive Data Client (Vue) without a provider.\n' +
36
+ 'Follow instructions: https://dataclient.io/docs/getting-started/installation#add-provider-at-top-level-component',
37
+ );
38
+ }
39
+ return FallbackStateRef;
40
+ }
41
+ return state;
42
+ }
package/src/index.ts ADDED
@@ -0,0 +1,48 @@
1
+ // Vue Data Client - Coming Soon
2
+ // This package will provide Vue 3 composables for @data-client/core
3
+
4
+ export { Controller, ExpiryStatus, actionTypes } from '@data-client/core';
5
+ export type {
6
+ EndpointExtraOptions,
7
+ FetchFunction,
8
+ ResolveType,
9
+ EndpointInterface,
10
+ EntityInterface,
11
+ Queryable,
12
+ SchemaArgs,
13
+ Schema,
14
+ SchemaClass,
15
+ DenormalizeNullable,
16
+ Denormalize,
17
+ Normalize,
18
+ NormalizeNullable,
19
+ FetchAction,
20
+ InvalidateAction,
21
+ UnsubscribeAction,
22
+ SubscribeAction,
23
+ ResetAction,
24
+ SetAction,
25
+ SetResponseAction,
26
+ ActionTypes,
27
+ NetworkError,
28
+ UnknownError,
29
+ ErrorTypes,
30
+ AbstractInstanceType,
31
+ UpdateFunction,
32
+ State,
33
+ PK,
34
+ Dispatch,
35
+ Middleware,
36
+ MiddlewareAPI,
37
+ Manager,
38
+ GCInterface,
39
+ GCOptions,
40
+ CreateCountRef,
41
+ // used in Controller generic
42
+ DataClientDispatch,
43
+ GenericDispatch,
44
+ } from '@data-client/core';
45
+
46
+ export * from './consumers/index.js';
47
+ export * from './providers/index.js';
48
+ export * from './managers/index.js';
@@ -0,0 +1,8 @@
1
+ export {
2
+ PollingSubscription,
3
+ DevToolsManager,
4
+ SubscriptionManager,
5
+ DefaultConnectionListener,
6
+ LogoutManager,
7
+ NetworkManager,
8
+ } from '@data-client/core';
@@ -0,0 +1,80 @@
1
+ import type { DevToolsConfig, Manager } from '@data-client/core';
2
+ import {
3
+ NetworkManager,
4
+ SubscriptionManager,
5
+ PollingSubscription,
6
+ DevToolsManager,
7
+ } from '@data-client/core';
8
+
9
+ /* istanbul ignore next */
10
+ /** Returns the default Managers used by DataProvider. */
11
+ let getDefaultManagers: (options?: GetManagersOptions) => Manager[] = (
12
+ options = {},
13
+ ) => {
14
+ const { networkManager, subscriptionManager = PollingSubscription } = options;
15
+ if (subscriptionManager === null) {
16
+ return [constructManager(NetworkManager, networkManager ?? ({} as any))];
17
+ }
18
+ return [
19
+ constructManager(NetworkManager, networkManager ?? ({} as any)),
20
+ constructManager(SubscriptionManager, subscriptionManager),
21
+ ];
22
+ };
23
+ /* istanbul ignore else */
24
+ if (process.env.NODE_ENV !== 'production') {
25
+ getDefaultManagers = (options: GetManagersOptions = {}): Manager[] => {
26
+ const {
27
+ devToolsManager,
28
+ networkManager,
29
+ subscriptionManager = PollingSubscription,
30
+ } = options;
31
+ if (networkManager === null) {
32
+ console.error('Disabling NetworkManager is not allowed.');
33
+ // fall back to default options
34
+ }
35
+ const nm = constructManager(NetworkManager, networkManager ?? ({} as any));
36
+ const managers: Manager[] = [nm];
37
+ if (subscriptionManager !== null) {
38
+ managers.push(constructManager(SubscriptionManager, subscriptionManager));
39
+ }
40
+ if (devToolsManager !== null) {
41
+ let dtm: DevToolsManager;
42
+ if (devToolsManager instanceof DevToolsManager) {
43
+ dtm = devToolsManager;
44
+ } else {
45
+ dtm = new DevToolsManager(
46
+ devToolsManager as any,
47
+ nm.skipLogging.bind(nm),
48
+ );
49
+ }
50
+ managers.unshift(dtm);
51
+ }
52
+ return managers;
53
+ };
54
+ }
55
+ export { getDefaultManagers };
56
+
57
+ function constructManager<M extends { new (...args: any): Manager }>(
58
+ Mgr: M,
59
+ optionOrInstance: InstanceType<M> | ConstructorArgs<M>,
60
+ ): InstanceType<M> {
61
+ if (optionOrInstance instanceof Mgr) {
62
+ return optionOrInstance as InstanceType<M>;
63
+ }
64
+ return new Mgr(optionOrInstance as any) as InstanceType<M>;
65
+ }
66
+
67
+ export type GetManagersOptions = {
68
+ devToolsManager?: DevToolsManager | DevToolsConfig | null;
69
+ networkManager?:
70
+ | NetworkManager
71
+ | ConstructorArgs<typeof NetworkManager>
72
+ | null;
73
+ subscriptionManager?:
74
+ | SubscriptionManager
75
+ | ConstructorArgs<typeof SubscriptionManager>
76
+ | null;
77
+ };
78
+
79
+ export type ConstructorArgs<T extends { new (...args: any): any }> =
80
+ T extends new (options: infer O) => any ? O : never;
@@ -0,0 +1,2 @@
1
+ export { getDefaultManagers } from './getDefaultManagers.js';
2
+ export { provideDataClient } from '../providers/provideDataClient.js';
@@ -0,0 +1,126 @@
1
+ import {
2
+ initialState as defaultState,
3
+ Controller as DataController,
4
+ applyManager,
5
+ initManager,
6
+ createReducer,
7
+ } from '@data-client/core';
8
+ import type { State, Manager, GCInterface } from '@data-client/core';
9
+ import {
10
+ onMounted,
11
+ onUnmounted,
12
+ provide,
13
+ shallowRef,
14
+ type ShallowRef,
15
+ } from 'vue';
16
+
17
+ import { ControllerKey, StateKey } from '../context.js';
18
+ import { getDefaultManagers } from './getDefaultManagers.js';
19
+
20
+ export interface ProvideOptions {
21
+ managers?: Manager[];
22
+ initialState?: State<unknown>;
23
+ Controller?: typeof DataController;
24
+ gcPolicy?: GCInterface;
25
+ }
26
+
27
+ export interface ProvidedDataClient {
28
+ controller: InstanceType<typeof DataController>;
29
+ /** Optimistic overlay state ref provided to consumers */
30
+ stateRef: ShallowRef<State<unknown>>;
31
+ }
32
+
33
+ /**
34
+ * Provide/inject setup for @data-client/vue. Call inside setup() of your root component.
35
+ * Mirrors React DataProvider but as a composable.
36
+ */
37
+ export function provideDataClient(
38
+ options: ProvideOptions = {},
39
+ ): ProvidedDataClient {
40
+ const { Controller = DataController, gcPolicy } = options;
41
+
42
+ // stable singletons for this provider scope
43
+ const controller = new Controller({ gcPolicy });
44
+ const managers = options.managers ?? getDefaultManagers();
45
+ const baseInitial = options.initialState ?? (defaultState as State<unknown>);
46
+
47
+ // init managers (run on mount/unmount)
48
+ const mgrEffect = initManager(managers, controller, baseInitial);
49
+
50
+ // build middlewares and bind to controller
51
+ const middlewares = applyManager(managers, controller);
52
+
53
+ // reducer and state management
54
+ const reducer = createReducer(controller);
55
+
56
+ // base state (no optimistic overlay) exposed to controller.getState via middleware API
57
+ const baseStateRef = shallowRef<State<unknown>>(baseInitial);
58
+ // optimistic/effective state provided to consumers
59
+ const stateRef = shallowRef<State<unknown>>(computeOptimistic(baseInitial));
60
+
61
+ type Dispatch = (action: any) => Promise<void>;
62
+
63
+ let resolveNext: (() => void) | null = null;
64
+ const waitForCommit = () =>
65
+ new Promise<void>(resolve => {
66
+ resolveNext = resolve;
67
+ });
68
+
69
+ const realDispatch: Dispatch = async action => {
70
+ const nextBase = reducer(baseStateRef.value, action);
71
+ baseStateRef.value = nextBase;
72
+ stateRef.value = computeOptimistic(nextBase);
73
+ if (resolveNext) {
74
+ const r = resolveNext;
75
+ resolveNext = null;
76
+ r();
77
+ }
78
+ };
79
+
80
+ const getState = () => baseStateRef.value;
81
+
82
+ // compose middlewares similar to redux
83
+ const chain = middlewares.map(mw =>
84
+ mw({
85
+ getState,
86
+ dispatch: (a: any) => outerDispatch(a),
87
+ } as any),
88
+ );
89
+ const compose = (fns: ((arg: any) => any)[]) => (initial: any) =>
90
+ fns.reduceRight((v, f) => f(v), initial);
91
+ const outerDispatch = compose(chain)(async (action: any) => {
92
+ const promise = waitForCommit();
93
+ await realDispatch(action);
94
+ return promise;
95
+ });
96
+
97
+ // wire controller
98
+ controller.bindMiddleware({
99
+ getState,
100
+ dispatch: (a: any) => outerDispatch(a),
101
+ } as any);
102
+
103
+ // provide to children
104
+ provide(StateKey, stateRef);
105
+ provide(ControllerKey, controller as any);
106
+
107
+ // run managers after mount and cleanup on unmount
108
+ let cleanup: void | (() => void);
109
+ onMounted(() => {
110
+ cleanup = mgrEffect();
111
+ });
112
+ onUnmounted(() => {
113
+ if (cleanup) cleanup();
114
+ });
115
+
116
+ return { controller: controller as any, stateRef };
117
+
118
+ function computeOptimistic(state: State<unknown>): State<unknown> {
119
+ // mirror React’s optimistic overlay
120
+ // reduce over pending optimistic actions to derive the effective state
121
+ // reducer is stable from closure
122
+ return state.optimistic.reduce(reducer as any, state);
123
+ }
124
+ }
125
+
126
+ export default provideDataClient;
@@ -0,0 +1,11 @@
1
+ import { Controller as DataController } from '@data-client/core';
2
+ import { State, Manager, GCInterface } from '@data-client/core';
3
+ export interface ProviderProps {
4
+ managers?: Manager[];
5
+ initialState?: State<unknown>;
6
+ Controller?: typeof DataController;
7
+ gcPolicy?: GCInterface;
8
+ }
9
+ declare const _default: import("vue").DefineComponent<ProviderProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ProviderProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ export default _default;
11
+ //# sourceMappingURL=DataProvider.d.ts.map
@@ -0,0 +1,5 @@
1
+ export { default as useSuspense } from './useSuspense.js';
2
+ export { default as useSubscription } from './useSubscription.js';
3
+ export { default as useQuery } from './useQuery.js';
4
+ export { injectController as useController, injectState as useStateRef, } from '../context.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,5 @@
1
+ import { State } from '@data-client/core';
2
+ import { ShallowRef } from 'vue';
3
+ export declare function useController(): import("@data-client/core").Controller<import("@data-client/core").DataClientDispatch>;
4
+ export declare function useStateRef(): ShallowRef<State<unknown>>;
5
+ //# sourceMappingURL=useInjects.d.ts.map
@@ -0,0 +1,12 @@
1
+ import { DenormalizeNullable, NI, Queryable, SchemaArgs } from '@data-client/core';
2
+ import { ComputedRef } from 'vue';
3
+ /**
4
+ * Query the store (non-suspense).
5
+ *
6
+ * Returns a readonly computed ref of the query result. The value is undefined when
7
+ * the result is not found or invalid.
8
+ * Mirrors React's useQuery semantics using Vue reactivity.
9
+ * @see https://dataclient.io/docs/api/useQuery
10
+ */
11
+ export default function useQuery<S extends Queryable>(schema: S, ...args: NI<SchemaArgs<S>>): ComputedRef<DenormalizeNullable<S> | undefined>;
12
+ //# sourceMappingURL=useQuery.d.ts.map
@@ -0,0 +1,12 @@
1
+ import { EndpointInterface, Schema, FetchFunction } from '@data-client/core';
2
+ /**
3
+ * Keeps a resource fresh by subscribing to updates.
4
+ * Mirrors React hook API. Pass `null` as first arg to unsubscribe.
5
+ * @see https://dataclient.io/docs/api/useSubscription
6
+ */
7
+ export default function useSubscription<E extends EndpointInterface<FetchFunction, Schema | undefined, undefined | false>>(endpoint: E, ...args: readonly [
8
+ ...Parameters<E>
9
+ ] | readonly [
10
+ null
11
+ ]): void;
12
+ //# sourceMappingURL=useSubscription.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { EndpointInterface, Denormalize, Schema, FetchFunction, DenormalizeNullable, ResolveType } from '@data-client/core';
2
+ import { DeepReadonly, ComputedRef } from 'vue';
3
+ export default function useSuspense<E extends EndpointInterface<FetchFunction, Schema | undefined, undefined | false>>(endpoint: E, ...args: readonly [
4
+ ...Parameters<E>
5
+ ]): Promise<DeepReadonly<ComputedRef<E['schema'] extends undefined | null ? ResolveType<E> : Denormalize<E['schema']>>>>;
6
+ export default function useSuspense<E extends EndpointInterface<FetchFunction, Schema | undefined, undefined | false>>(endpoint: E, ...args: readonly [
7
+ ...Parameters<E>
8
+ ] | readonly [
9
+ null
10
+ ]): Promise<DeepReadonly<ComputedRef<E['schema'] extends undefined | null ? ResolveType<E> | undefined : DenormalizeNullable<E['schema']>>>>;
11
+ //# sourceMappingURL=useSuspense.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { Controller } from '@data-client/core';
2
+ import { State } from '@data-client/core';
3
+ import { InjectionKey, ShallowRef } from 'vue';
4
+ export declare const StateKey: InjectionKey<ShallowRef<State<unknown>>>;
5
+ export declare const ControllerKey: InjectionKey<Controller>;
6
+ /** Fallback state ref used when no provider is found. */
7
+ export declare const FallbackStateRef: ShallowRef<State<unknown>>;
8
+ export declare function injectController(): Controller;
9
+ export declare function injectState(): ShallowRef<State<unknown>>;
10
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1,6 @@
1
+ export { Controller, ExpiryStatus, actionTypes } from '@data-client/core';
2
+ export { EndpointExtraOptions, FetchFunction, ResolveType, EndpointInterface, EntityInterface, Queryable, SchemaArgs, Schema, SchemaClass, DenormalizeNullable, Denormalize, Normalize, NormalizeNullable, FetchAction, InvalidateAction, UnsubscribeAction, SubscribeAction, ResetAction, SetAction, SetResponseAction, ActionTypes, NetworkError, UnknownError, ErrorTypes, AbstractInstanceType, UpdateFunction, State, PK, Dispatch, Middleware, MiddlewareAPI, Manager, GCInterface, GCOptions, CreateCountRef, DataClientDispatch, GenericDispatch, } from '@data-client/core';
3
+ export * from './consumers/index.js';
4
+ export * from './providers/index.js';
5
+ export * from './managers/index.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { PollingSubscription, DevToolsManager, SubscriptionManager, DefaultConnectionListener, LogoutManager, NetworkManager, } from '@data-client/core';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { DevToolsConfig, Manager } from '@data-client/core';
2
+ import { NetworkManager, SubscriptionManager, DevToolsManager } from '@data-client/core';
3
+ /** Returns the default Managers used by DataProvider. */
4
+ declare let getDefaultManagers: (options?: GetManagersOptions) => Manager[];
5
+ export { getDefaultManagers };
6
+ export type GetManagersOptions = {
7
+ devToolsManager?: DevToolsManager | DevToolsConfig | null;
8
+ networkManager?: NetworkManager | ConstructorArgs<typeof NetworkManager> | null;
9
+ subscriptionManager?: SubscriptionManager | ConstructorArgs<typeof SubscriptionManager> | null;
10
+ };
11
+ export type ConstructorArgs<T extends {
12
+ new (...args: any): any;
13
+ }> = T extends new (options: infer O) => any ? O : never;
14
+ //# sourceMappingURL=getDefaultManagers.d.ts.map
@@ -0,0 +1,3 @@
1
+ export { getDefaultManagers } from './getDefaultManagers.js';
2
+ export { provideDataClient } from '../providers/provideDataClient.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,21 @@
1
+ import { Controller as DataController } from '@data-client/core';
2
+ import { State, Manager, GCInterface } from '@data-client/core';
3
+ import { ShallowRef } from 'vue';
4
+ export interface ProvideOptions {
5
+ managers?: Manager[];
6
+ initialState?: State<unknown>;
7
+ Controller?: typeof DataController;
8
+ gcPolicy?: GCInterface;
9
+ }
10
+ export interface ProvidedDataClient {
11
+ controller: InstanceType<typeof DataController>;
12
+ /** Optimistic overlay state ref provided to consumers */
13
+ stateRef: ShallowRef<State<unknown>>;
14
+ }
15
+ /**
16
+ * Provide/inject setup for @data-client/vue. Call inside setup() of your root component.
17
+ * Mirrors React DataProvider but as a composable.
18
+ */
19
+ export declare function provideDataClient(options?: ProvideOptions): ProvidedDataClient;
20
+ export default provideDataClient;
21
+ //# sourceMappingURL=provideDataClient.d.ts.map
package/typescript.svg ADDED
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="21px" height="21px" viewBox="0 0 256 256" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid">
3
+ <g>
4
+ <polygon fill="#007ACC" transform="translate(128.000000, 128.000000) scale(1, -1) translate(-128.000000, -128.000000) " points="0 128 0 0 128 0 256 0 256 128 256 256 128 256 0 256"></polygon>
5
+ <path d="M146.658132,223.436863 L146.739401,212.953054 L130.079084,212.953054 L113.418767,212.953054 L113.418767,165.613371 L113.418767,118.273689 L101.63464,118.273689 L89.8505126,118.273689 L89.8505126,165.613371 L89.8505126,212.953054 L73.1901951,212.953054 L56.5298776,212.953054 L56.5298776,223.233689 C56.5298776,228.922577 56.6517824,233.676863 56.8143221,233.798768 C56.9362269,233.961308 77.2130522,234.042577 101.797179,234.001943 L146.536227,233.880038 L146.658132,223.436863 Z" fill="#FFFFFF" transform="translate(101.634640, 176.142993) rotate(-180.000000) translate(-101.634640, -176.142993) "></path>
6
+ <path d="M206.566631,234.272145 C213.068219,232.646748 218.025679,229.761668 222.57679,225.048018 C224.933616,222.528653 228.428219,217.936907 228.712663,216.839764 C228.793933,216.514684 217.659965,209.037859 210.914568,204.852462 C210.670758,204.689922 209.69552,205.74643 208.598377,207.371827 C205.306949,212.166748 201.852981,214.239129 196.570441,214.604843 C188.809171,215.133097 183.811076,211.069605 183.851711,204.283573 C183.851711,202.292462 184.136155,201.114049 184.948854,199.488653 C186.65552,195.953414 189.825044,193.840399 199.7806,189.533097 C218.106949,181.649922 225.949489,176.448653 230.825679,169.053097 C236.270758,160.804208 237.489806,147.638494 233.792028,137.845478 C229.728536,127.199129 219.651076,119.966113 205.469489,117.568653 C201.080917,116.796589 190.678377,116.918494 185.964727,117.771827 C175.684092,119.600399 165.931711,124.679764 159.917743,131.343891 C157.560917,133.944526 152.969171,140.730557 153.253616,141.218176 C153.37552,141.380716 154.432028,142.030875 155.610441,142.721668 C156.748219,143.371827 161.05552,145.850557 165.119012,148.207383 L172.473933,152.474049 L174.01806,150.198494 C176.171711,146.907065 180.885362,142.396589 183.729806,140.893097 C191.897425,136.585795 203.112663,137.195319 208.639012,142.15278 C210.995838,144.30643 211.971076,146.541351 211.971076,149.83278 C211.971076,152.799129 211.605362,154.099446 210.061235,156.334367 C208.070123,159.178811 204.006631,161.576272 192.466314,166.574367 C179.259965,172.263256 173.571076,175.798494 168.369806,181.406113 C165.362822,184.656907 162.518377,189.858176 161.339965,194.206113 C160.364727,197.822621 160.120917,206.884208 160.892981,210.541351 C163.61552,223.300716 173.245996,232.199764 187.143139,234.841034 C191.653616,235.694367 202.137425,235.369287 206.566631,234.272145 Z" fill="#FFFFFF" transform="translate(194.578507, 176.190240) scale(1, -1) translate(-194.578507, -176.190240) "></path>
7
+ </g>
8
+ </svg>