@dxos/echo-solid 0.8.4-main.c85a9c8dae → 0.8.4-main.d05539e30a
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/LICENSE +102 -5
- package/dist/lib/neutral/index.mjs +9 -8
- package/dist/lib/neutral/index.mjs.map +3 -3
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/types/src/useObject.d.ts.map +1 -1
- package/dist/types/src/useQuery.d.ts.map +1 -1
- package/dist/types/src/useSchema.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -11
- package/src/useObject.test.tsx +10 -10
- package/src/useObject.ts +6 -5
- package/src/useQuery.test.tsx +1 -1
- package/src/useSchema.test.tsx +2 -2
package/LICENSE
CHANGED
|
@@ -1,8 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
Copyright (c) 2025 DXOS
|
|
1
|
+
# Functional Source License, Version 1.1, ALv2 Future License
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
## Abbreviation
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
FSL-1.1-Apache-2.0
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 DXOS
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
|
@@ -17,20 +17,20 @@ function useObject(objOrRef, property) {
|
|
|
17
17
|
if (!obj) {
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
-
Obj.
|
|
20
|
+
Obj.update(obj, (obj2) => {
|
|
21
21
|
if (typeof updateOrValue === "function") {
|
|
22
|
-
const returnValue = updateOrValue(property !== void 0 ?
|
|
22
|
+
const returnValue = updateOrValue(property !== void 0 ? obj2[property] : obj2);
|
|
23
23
|
if (returnValue !== void 0) {
|
|
24
24
|
if (property === void 0) {
|
|
25
25
|
throw new Error("Cannot re-assign the entire object");
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
obj2[property] = returnValue;
|
|
28
28
|
}
|
|
29
29
|
} else {
|
|
30
30
|
if (property === void 0) {
|
|
31
31
|
throw new Error("Cannot re-assign the entire object");
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
obj2[property] = updateOrValue;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
};
|
|
@@ -40,11 +40,12 @@ function useObject(objOrRef, property) {
|
|
|
40
40
|
useObjectProperty(registry, liveObj, property),
|
|
41
41
|
callback
|
|
42
42
|
];
|
|
43
|
+
} else {
|
|
44
|
+
return [
|
|
45
|
+
useObjectValue(registry, objOrRef),
|
|
46
|
+
callback
|
|
47
|
+
];
|
|
43
48
|
}
|
|
44
|
-
return [
|
|
45
|
-
useObjectValue(registry, objOrRef),
|
|
46
|
-
callback
|
|
47
|
-
];
|
|
48
49
|
}
|
|
49
50
|
function useObjectValue(registry, objOrRef) {
|
|
50
51
|
const resolvedInput = createMemo(() => access(objOrRef));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/useObject.ts", "../../../src/useQuery.ts", "../../../src/useSchema.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type MaybeAccessor, access } from '@solid-primitives/utils';\nimport { type Accessor, createEffect, createMemo, createSignal, onCleanup } from 'solid-js';\n\nimport { Obj, Ref } from '@dxos/echo';\nimport { AtomObj } from '@dxos/echo-atom';\nimport { type Registry, useRegistry } from '@dxos/effect-atom-solid';\n\nexport interface ObjectUpdateCallback<T> {\n (update: (obj: Obj.Mutable<T>) => void): void;\n (update: (obj: Obj.Mutable<T>) => Obj.Mutable<T>): void;\n}\n\nexport interface ObjectPropUpdateCallback<T> {\n (update: (value: Obj.Mutable<T>) => void): void;\n (update: (value: Obj.Mutable<T>) => Obj.Mutable<T>): void;\n (newValue: T): void;\n}\n\n/**\n * Helper type to conditionally include undefined in return type only if input includes undefined.\n * Only adds undefined if T includes undefined AND R doesn't already include undefined.\n */\ntype ConditionalUndefined<T, R> = [T] extends [Exclude<T, undefined>]\n ? R // T doesn't include undefined, return R as-is\n : [R] extends [Exclude<R, undefined>]\n ? R | undefined // T includes undefined but R doesn't, add undefined\n : R; // Both T and R include undefined, return R as-is (no double undefined)\n\n/**\n * Subscribe to a Ref's target object.\n * Automatically dereferences the ref and handles async loading.\n * Returns undefined if the ref hasn't loaded yet.\n *\n * @param ref - The Ref to dereference and subscribe to (can be reactive)\n * @returns A tuple of [accessor, updateCallback]\n */\nexport function useObject<T>(ref: MaybeAccessor<Ref.Ref<T>>): [Accessor<T | undefined>, ObjectUpdateCallback<T>];\n\n/**\n * Subscribe to a Ref's target object that may be undefined.\n * Returns undefined if the ref is undefined or hasn't loaded yet.\n *\n * @param ref - The Ref to dereference and subscribe to (can be undefined/reactive)\n * @returns A tuple of [accessor, updateCallback]\n */\nexport function useObject<T>(\n ref: MaybeAccessor<Ref.Ref<T> | undefined>,\n): [Accessor<T | undefined>, ObjectUpdateCallback<T>];\n\n/**\n * Subscribe to an entire Echo object.\n * Returns the current object value accessor and an update callback.\n *\n * @param obj - The Echo object to subscribe to (can be reactive)\n * @returns A tuple of [accessor, updateCallback]\n */\nexport function useObject<T extends Obj.Unknown>(\n obj: MaybeAccessor<T>,\n): [Accessor<ConditionalUndefined<T, T>>, ObjectUpdateCallback<T>];\n\n/**\n * Subscribe to an entire Echo object that may be undefined.\n * Returns undefined if the object is undefined.\n *\n * @param obj - The Echo object to subscribe to (can be undefined/reactive)\n * @returns A tuple of [accessor, updateCallback]\n */\nexport function useObject<T extends Obj.Unknown>(\n obj: MaybeAccessor<T | undefined>,\n): [Accessor<ConditionalUndefined<T, T>>, ObjectUpdateCallback<T>];\n\n/**\n * Subscribe to a specific property of an Echo object.\n * Returns the current property value accessor and an update callback.\n *\n * @param obj - The Echo object to subscribe to (can be reactive)\n * @param property - Property key to subscribe to\n * @returns A tuple of [accessor, updateCallback]\n */\nexport function useObject<T extends Obj.Unknown, K extends keyof T>(\n obj: MaybeAccessor<T>,\n property: K,\n): [Accessor<T[K]>, ObjectPropUpdateCallback<T[K]>];\n\n/**\n * Subscribe to a specific property of an Echo object that may be undefined.\n * Returns undefined if the object is undefined.\n *\n * @param obj - The Echo object to subscribe to (can be undefined/reactive)\n * @param property - Property key to subscribe to\n * @returns A tuple of [accessor, updateCallback]\n */\nexport function useObject<T extends Obj.Unknown, K extends keyof T>(\n obj: MaybeAccessor<T | undefined>,\n property: K,\n): [Accessor<T[K] | undefined>, ObjectPropUpdateCallback<T[K]>];\n\n/**\n * Subscribe to a specific property of a Ref's target object.\n * Automatically dereferences the ref and handles async loading.\n * Returns undefined if the ref hasn't loaded yet.\n *\n * @param ref - The Ref to dereference and subscribe to (can be reactive)\n * @param property - Property key to subscribe to\n * @returns A tuple of [accessor, updateCallback]\n */\nexport function useObject<T, K extends keyof T>(\n ref: MaybeAccessor<Ref.Ref<T>>,\n property: K,\n): [Accessor<T[K] | undefined>, ObjectPropUpdateCallback<T[K]>];\n\n/**\n * Subscribe to a specific property of a Ref's target object that may be undefined.\n * Returns undefined if the ref is undefined or hasn't loaded yet.\n *\n * @param ref - The Ref to dereference and subscribe to (can be undefined/reactive)\n * @param property - Property key to subscribe to\n * @returns A tuple of [accessor, updateCallback]\n */\nexport function useObject<T, K extends keyof T>(\n ref: MaybeAccessor<Ref.Ref<T> | undefined>,\n property: K,\n): [Accessor<T[K] | undefined>, ObjectPropUpdateCallback<T[K]>];\n\n/**\n * Subscribe to an Echo object or Ref (entire object or specific property).\n * Returns the current value accessor and an update callback.\n *\n * @param objOrRef - The Echo object or Ref to subscribe to (can be reactive)\n * @param property - Optional property key to subscribe to a specific property\n * @returns A tuple of [accessor, updateCallback]\n */\nexport function useObject<T extends Obj.Unknown, K extends keyof T>(\n objOrRef: MaybeAccessor<T | Ref.Ref<T> | undefined>,\n property?: K,\n): [Accessor<any>, ObjectUpdateCallback<T> | ObjectPropUpdateCallback<T[K]>] {\n const registry = useRegistry();\n\n // Memoize the resolved input to track changes.\n const resolvedInput = createMemo(() => access(objOrRef));\n\n // Determine if input is a ref.\n const isRef = createMemo(() => Ref.isRef(resolvedInput()));\n\n // Get the live object for the callback (refs need to dereference).\n const liveObj = createMemo(() => {\n const input = resolvedInput();\n return isRef() ? (input as Ref.Ref<T>)?.target : (input as T | undefined);\n });\n\n // Create a stable callback that handles both object and property updates.\n const callback = (updateOrValue: unknown | ((obj: unknown) => unknown)) => {\n // Get current target for refs (may have loaded since render).\n const obj = isRef() ? (resolvedInput() as Ref.Ref<T>)?.target : liveObj();\n if (!obj) {\n return;\n }\n\n Obj.change(obj, (o: any) => {\n if (typeof updateOrValue === 'function') {\n const returnValue = (updateOrValue as (obj: unknown) => unknown)(property !== undefined ? o[property] : o);\n if (returnValue !== undefined) {\n if (property === undefined) {\n throw new Error('Cannot re-assign the entire object');\n }\n o[property] = returnValue;\n }\n } else {\n if (property === undefined) {\n throw new Error('Cannot re-assign the entire object');\n }\n o[property] = updateOrValue;\n }\n });\n };\n\n if (property !== undefined) {\n // For property subscriptions on refs, we subscribe to trigger re-render on load.\n useObjectValue(registry, objOrRef);\n return [useObjectProperty(registry, liveObj, property), callback as ObjectPropUpdateCallback<T[K]>];\n }\n return [useObjectValue(registry, objOrRef), callback as ObjectUpdateCallback<T>];\n}\n\n/**\n * Internal function for subscribing to an Echo object or Ref.\n * AtomObj.make handles both objects and refs, returning snapshots.\n */\nfunction useObjectValue<T extends Obj.Unknown>(\n registry: Registry.Registry,\n objOrRef: MaybeAccessor<T | Ref.Ref<T> | undefined>,\n): Accessor<T | undefined> {\n // Memoize the resolved input to track changes.\n const resolvedInput = createMemo(() => access(objOrRef));\n\n // Initialize with the current value (if available).\n const initialInput = resolvedInput();\n const initialValue = initialInput ? registry.get(AtomObj.make(initialInput)) : undefined;\n const [value, setValue] = createSignal<T | undefined>(initialValue as T | undefined);\n\n // Subscribe to atom updates.\n createEffect(() => {\n const input = resolvedInput();\n\n if (!input) {\n setValue(() => undefined);\n return;\n }\n\n const atom = AtomObj.make(input);\n const currentValue = registry.get(atom);\n setValue(() => currentValue as unknown as T);\n\n const unsubscribe = registry.subscribe(\n atom,\n () => {\n setValue(() => registry.get(atom) as unknown as T);\n },\n { immediate: true },\n );\n\n onCleanup(unsubscribe);\n });\n\n return value;\n}\n\n/**\n * Internal function for subscribing to a specific property of an Echo object.\n */\nfunction useObjectProperty<T extends Obj.Unknown, K extends keyof T>(\n registry: Registry.Registry,\n obj: Accessor<T | undefined>,\n property: K,\n): Accessor<T[K] | undefined> {\n // Initialize with the current value (if available).\n const initialObj = obj();\n const initialValue = initialObj ? registry.get(AtomObj.makeProperty(initialObj, property)) : undefined;\n const [value, setValue] = createSignal<T[K] | undefined>(initialValue);\n\n // Subscribe to atom updates.\n createEffect(() => {\n const currentObj = obj();\n\n if (!currentObj) {\n setValue(() => undefined);\n return;\n }\n\n const atom = AtomObj.makeProperty(currentObj, property);\n const currentValue = registry.get(atom);\n setValue(() => currentValue);\n\n const unsubscribe = registry.subscribe(\n atom,\n () => {\n setValue(() => registry.get(atom) as T[K]);\n },\n { immediate: true },\n );\n\n onCleanup(unsubscribe);\n });\n\n return value;\n}\n\n/**\n * Subscribe to multiple Refs' target objects.\n * Automatically dereferences each ref and handles async loading.\n * Returns an accessor to an array of loaded snapshots (filtering out undefined values).\n *\n * This hook is useful for aggregate computations like counts or filtering\n * across multiple refs without using .target directly.\n *\n * @param refs - Array of Refs to dereference and subscribe to (can be reactive)\n * @returns Accessor to array of loaded target snapshots (excludes unloaded refs)\n */\nexport const useObjects = <T extends Obj.Unknown>(refs: MaybeAccessor<readonly Ref.Ref<T>[]>): Accessor<T[]> => {\n // Track version to trigger re-renders when any ref or target changes.\n const [version, setVersion] = createSignal(0);\n\n // Memoize the refs array to track changes.\n const resolvedRefs = createMemo(() => access(refs));\n\n // Subscribe to all refs and their targets.\n createEffect(() => {\n const currentRefs = resolvedRefs();\n const targetUnsubscribes = new Map<string, () => void>();\n\n // Function to trigger re-render.\n const triggerUpdate = () => {\n setVersion((v) => v + 1);\n };\n\n // Function to set up subscription for a target.\n const subscribeToTarget = (ref: Ref.Ref<T>) => {\n const target = ref.target;\n if (target) {\n const key = ref.dxn.toString();\n if (!targetUnsubscribes.has(key)) {\n targetUnsubscribes.set(key, Obj.subscribe(target, triggerUpdate));\n }\n }\n };\n\n // Try to load all refs and subscribe to targets.\n for (const ref of currentRefs) {\n // Subscribe to existing target if available.\n subscribeToTarget(ref);\n\n // Trigger async load if not already loaded.\n if (!ref.target) {\n void ref\n .load()\n .then(() => {\n subscribeToTarget(ref);\n triggerUpdate();\n })\n .catch(() => {\n // Ignore load errors.\n });\n }\n }\n\n onCleanup(() => {\n targetUnsubscribes.forEach((u) => u());\n });\n });\n\n // Compute current snapshots by reading each ref's target.\n return createMemo(() => {\n // Depend on version to re-compute when targets change.\n version();\n\n const currentRefs = resolvedRefs();\n const snapshots: T[] = [];\n for (const ref of currentRefs) {\n const target = ref.target;\n if (target !== undefined) {\n snapshots.push(target as T);\n }\n }\n return snapshots;\n });\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Accessor, createEffect, createMemo, createSignal, onCleanup } from 'solid-js';\n\nimport { type Database, type Entity, Filter, Query } from '@dxos/echo';\n\nconst EMPTY_ARRAY: never[] = [];\n\ntype MaybeAccessor<T> = T | Accessor<T>;\n\n/**\n * Create a reactive query subscription.\n * Accepts either values or accessors for resource and query/filter.\n *\n * @param resource - The database or queryable resource (can be reactive)\n * @param queryOrFilter - The query or filter to apply (can be reactive)\n * @returns An accessor that returns the current query results\n */\nexport const useQuery = <T extends Entity.Any = Entity.Any>(\n resource: MaybeAccessor<Database.Queryable | undefined>,\n queryOrFilter: MaybeAccessor<Query.Any | Filter.Any>,\n): Accessor<T[]> => {\n // Derive the normalized query from the input\n const query = createMemo(() => {\n const resolved = typeof queryOrFilter === 'function' ? queryOrFilter() : queryOrFilter;\n return Filter.is(resolved) ? Query.select(resolved) : resolved;\n });\n\n // Derive the query result object reactively\n const queryResult = createMemo(() => {\n const q = query();\n const resolvedResource = typeof resource === 'function' ? resource() : resource;\n return resolvedResource?.query(q);\n });\n\n // Store the current results in a signal\n const [objects, setObjects] = createSignal<T[]>(EMPTY_ARRAY as T[]);\n\n // Subscribe to query result changes\n createEffect(() => {\n const result = queryResult();\n if (!result) {\n // Keep previous value during transitions to prevent flickering\n return;\n }\n\n // Subscribe with immediate fire to get initial results\n const unsubscribe = result.subscribe(\n () => {\n setObjects(() => result.results as T[]);\n },\n { fire: true },\n );\n\n onCleanup(unsubscribe);\n });\n\n return objects;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Accessor, createEffect, createMemo, createSignal, onCleanup } from 'solid-js';\n\nimport { type Database, type Type } from '@dxos/echo';\n\ntype MaybeAccessor<T> = T | Accessor<T>;\n\n/**\n * Subscribe to and retrieve schema changes from a database's schema registry.\n * Accepts either values or accessors for db and typename.\n *\n * @param db - The database instance (can be reactive)\n * @param typename - The schema typename to query (can be reactive)\n * @returns An accessor that returns the current schema or undefined\n */\nexport const useSchema = <T extends Type.AnyEntity = Type.AnyEntity>(\n db?: MaybeAccessor<Database.Database | undefined>,\n typename?: MaybeAccessor<string | undefined>,\n): Accessor<T | undefined> => {\n // Derive the schema query reactively\n const query = createMemo(() => {\n const resolvedDb = typeof db === 'function' ? db() : db;\n const resolvedTypename = typeof typename === 'function' ? typename() : typename;\n if (!resolvedTypename || !resolvedDb) {\n return undefined;\n }\n return resolvedDb.schemaRegistry.query({ typename: resolvedTypename, location: ['database', 'runtime'] });\n });\n\n // Store the current schema in a signal\n const [schema, setSchema] = createSignal<T | undefined>(undefined);\n\n // Subscribe to query changes\n createEffect(() => {\n const q = query();\n if (!q) {\n // Keep previous value during transitions to prevent flickering\n return;\n }\n\n // Subscribe to updates with immediate fire to get initial result and track changes\n // The subscription will automatically start the reactive query\n const unsubscribe = q.subscribe(\n () => {\n // Access results inside the callback to ensure query is running\n const results = q.results;\n setSchema(() => results[0] as T | undefined);\n },\n { fire: true },\n );\n\n onCleanup(unsubscribe);\n });\n\n return schema;\n};\n"],
|
|
5
|
-
"mappings": ";AAIA,SAA6BA,cAAc;AAC3C,SAAwBC,cAAcC,YAAYC,cAAcC,iBAAiB;AAEjF,SAASC,KAAKC,WAAW;AACzB,SAASC,eAAe;AACxB,SAAwBC,mBAAmB;AA+HpC,SAASC,UACdC,UACAC,UAAY;AAEZ,QAAMC,
|
|
6
|
-
"names": ["access", "createEffect", "createMemo", "createSignal", "onCleanup", "Obj", "Ref", "AtomObj", "useRegistry", "useObject", "objOrRef", "property", "registry", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type MaybeAccessor, access } from '@solid-primitives/utils';\nimport { type Accessor, createEffect, createMemo, createSignal, onCleanup } from 'solid-js';\n\nimport { Obj, Ref } from '@dxos/echo';\nimport { AtomObj } from '@dxos/echo-atom';\nimport { type Registry, useRegistry } from '@dxos/effect-atom-solid';\n\nexport interface ObjectUpdateCallback<T> {\n (update: (obj: Obj.Mutable<T>) => void): void;\n (update: (obj: Obj.Mutable<T>) => Obj.Mutable<T>): void;\n}\n\nexport interface ObjectPropUpdateCallback<T> {\n (update: (value: Obj.Mutable<T>) => void): void;\n (update: (value: Obj.Mutable<T>) => Obj.Mutable<T>): void;\n (newValue: T): void;\n}\n\n/**\n * Helper type to conditionally include undefined in return type only if input includes undefined.\n * Only adds undefined if T includes undefined AND R doesn't already include undefined.\n */\ntype ConditionalUndefined<T, R> = [T] extends [Exclude<T, undefined>]\n ? R // T doesn't include undefined, return R as-is\n : [R] extends [Exclude<R, undefined>]\n ? R | undefined // T includes undefined but R doesn't, add undefined\n : R; // Both T and R include undefined, return R as-is (no double undefined)\n\n/**\n * Subscribe to a Ref's target object.\n * Automatically dereferences the ref and handles async loading.\n * Returns undefined if the ref hasn't loaded yet.\n *\n * @param ref - The Ref to dereference and subscribe to (can be reactive)\n * @returns A tuple of [accessor, updateCallback]\n */\nexport function useObject<T>(ref: MaybeAccessor<Ref.Ref<T>>): [Accessor<T | undefined>, ObjectUpdateCallback<T>];\n\n/**\n * Subscribe to a Ref's target object that may be undefined.\n * Returns undefined if the ref is undefined or hasn't loaded yet.\n *\n * @param ref - The Ref to dereference and subscribe to (can be undefined/reactive)\n * @returns A tuple of [accessor, updateCallback]\n */\nexport function useObject<T>(\n ref: MaybeAccessor<Ref.Ref<T> | undefined>,\n): [Accessor<T | undefined>, ObjectUpdateCallback<T>];\n\n/**\n * Subscribe to an entire Echo object.\n * Returns the current object value accessor and an update callback.\n *\n * @param obj - The Echo object to subscribe to (can be reactive)\n * @returns A tuple of [accessor, updateCallback]\n */\nexport function useObject<T extends Obj.Unknown>(\n obj: MaybeAccessor<T>,\n): [Accessor<ConditionalUndefined<T, T>>, ObjectUpdateCallback<T>];\n\n/**\n * Subscribe to an entire Echo object that may be undefined.\n * Returns undefined if the object is undefined.\n *\n * @param obj - The Echo object to subscribe to (can be undefined/reactive)\n * @returns A tuple of [accessor, updateCallback]\n */\nexport function useObject<T extends Obj.Unknown>(\n obj: MaybeAccessor<T | undefined>,\n): [Accessor<ConditionalUndefined<T, T>>, ObjectUpdateCallback<T>];\n\n/**\n * Subscribe to a specific property of an Echo object.\n * Returns the current property value accessor and an update callback.\n *\n * @param obj - The Echo object to subscribe to (can be reactive)\n * @param property - Property key to subscribe to\n * @returns A tuple of [accessor, updateCallback]\n */\nexport function useObject<T extends Obj.Unknown, K extends keyof T>(\n obj: MaybeAccessor<T>,\n property: K,\n): [Accessor<T[K]>, ObjectPropUpdateCallback<T[K]>];\n\n/**\n * Subscribe to a specific property of an Echo object that may be undefined.\n * Returns undefined if the object is undefined.\n *\n * @param obj - The Echo object to subscribe to (can be undefined/reactive)\n * @param property - Property key to subscribe to\n * @returns A tuple of [accessor, updateCallback]\n */\nexport function useObject<T extends Obj.Unknown, K extends keyof T>(\n obj: MaybeAccessor<T | undefined>,\n property: K,\n): [Accessor<T[K] | undefined>, ObjectPropUpdateCallback<T[K]>];\n\n/**\n * Subscribe to a specific property of a Ref's target object.\n * Automatically dereferences the ref and handles async loading.\n * Returns undefined if the ref hasn't loaded yet.\n *\n * @param ref - The Ref to dereference and subscribe to (can be reactive)\n * @param property - Property key to subscribe to\n * @returns A tuple of [accessor, updateCallback]\n */\nexport function useObject<T, K extends keyof T>(\n ref: MaybeAccessor<Ref.Ref<T>>,\n property: K,\n): [Accessor<T[K] | undefined>, ObjectPropUpdateCallback<T[K]>];\n\n/**\n * Subscribe to a specific property of a Ref's target object that may be undefined.\n * Returns undefined if the ref is undefined or hasn't loaded yet.\n *\n * @param ref - The Ref to dereference and subscribe to (can be undefined/reactive)\n * @param property - Property key to subscribe to\n * @returns A tuple of [accessor, updateCallback]\n */\nexport function useObject<T, K extends keyof T>(\n ref: MaybeAccessor<Ref.Ref<T> | undefined>,\n property: K,\n): [Accessor<T[K] | undefined>, ObjectPropUpdateCallback<T[K]>];\n\n/**\n * Subscribe to an Echo object or Ref (entire object or specific property).\n * Returns the current value accessor and an update callback.\n *\n * @param objOrRef - The Echo object or Ref to subscribe to (can be reactive)\n * @param property - Optional property key to subscribe to a specific property\n * @returns A tuple of [accessor, updateCallback]\n */\nexport function useObject<T extends Obj.Unknown, K extends keyof T>(\n objOrRef: MaybeAccessor<T | Ref.Ref<T> | undefined>,\n property?: K,\n): [Accessor<any>, ObjectUpdateCallback<T> | ObjectPropUpdateCallback<T[K]>] {\n const registry = useRegistry();\n\n // Memoize the resolved input to track changes.\n const resolvedInput = createMemo(() => access(objOrRef));\n\n // Determine if input is a ref.\n const isRef = createMemo(() => Ref.isRef(resolvedInput()));\n\n // Get the live object for the callback (refs need to dereference).\n const liveObj = createMemo(() => {\n const input = resolvedInput();\n return isRef() ? (input as Ref.Ref<T>)?.target : (input as T | undefined);\n });\n\n // Create a stable callback that handles both object and property updates.\n const callback = (updateOrValue: unknown | ((obj: unknown) => unknown)) => {\n // Get current target for refs (may have loaded since render).\n const obj = isRef() ? (resolvedInput() as Ref.Ref<T>)?.target : liveObj();\n if (!obj) {\n return;\n }\n\n Obj.update(obj, (obj: any) => {\n if (typeof updateOrValue === 'function') {\n const returnValue = (updateOrValue as (obj: unknown) => unknown)(property !== undefined ? obj[property] : obj);\n if (returnValue !== undefined) {\n if (property === undefined) {\n throw new Error('Cannot re-assign the entire object');\n }\n obj[property] = returnValue;\n }\n } else {\n if (property === undefined) {\n throw new Error('Cannot re-assign the entire object');\n }\n obj[property] = updateOrValue;\n }\n });\n };\n\n if (property !== undefined) {\n // For property subscriptions on refs, we subscribe to trigger re-render on load.\n useObjectValue(registry, objOrRef);\n return [useObjectProperty(registry, liveObj, property), callback as ObjectPropUpdateCallback<T[K]>];\n } else {\n return [useObjectValue(registry, objOrRef), callback as ObjectUpdateCallback<T>];\n }\n}\n\n/**\n * Internal function for subscribing to an Echo object or Ref.\n * AtomObj.make handles both objects and refs, returning snapshots.\n */\nfunction useObjectValue<T extends Obj.Unknown>(\n registry: Registry.Registry,\n objOrRef: MaybeAccessor<T | Ref.Ref<T> | undefined>,\n): Accessor<T | undefined> {\n // Memoize the resolved input to track changes.\n const resolvedInput = createMemo(() => access(objOrRef));\n\n // Initialize with the current value (if available).\n const initialInput = resolvedInput();\n const initialValue = initialInput ? registry.get(AtomObj.make(initialInput)) : undefined;\n const [value, setValue] = createSignal<T | undefined>(initialValue as T | undefined);\n\n // Subscribe to atom updates.\n createEffect(() => {\n const input = resolvedInput();\n\n if (!input) {\n setValue(() => undefined);\n return;\n }\n\n const atom = AtomObj.make(input);\n const currentValue = registry.get(atom);\n setValue(() => currentValue as unknown as T);\n\n const unsubscribe = registry.subscribe(\n atom,\n () => {\n setValue(() => registry.get(atom) as unknown as T);\n },\n { immediate: true },\n );\n\n onCleanup(unsubscribe);\n });\n\n return value;\n}\n\n/**\n * Internal function for subscribing to a specific property of an Echo object.\n */\nfunction useObjectProperty<T extends Obj.Unknown, K extends keyof T>(\n registry: Registry.Registry,\n obj: Accessor<T | undefined>,\n property: K,\n): Accessor<T[K] | undefined> {\n // Initialize with the current value (if available).\n const initialObj = obj();\n const initialValue = initialObj ? registry.get(AtomObj.makeProperty(initialObj, property)) : undefined;\n const [value, setValue] = createSignal<T[K] | undefined>(initialValue);\n\n // Subscribe to atom updates.\n createEffect(() => {\n const currentObj = obj();\n\n if (!currentObj) {\n setValue(() => undefined);\n return;\n }\n\n const atom = AtomObj.makeProperty(currentObj, property);\n const currentValue = registry.get(atom);\n setValue(() => currentValue);\n\n const unsubscribe = registry.subscribe(\n atom,\n () => {\n setValue(() => registry.get(atom) as T[K]);\n },\n { immediate: true },\n );\n\n onCleanup(unsubscribe);\n });\n\n return value;\n}\n\n/**\n * Subscribe to multiple Refs' target objects.\n * Automatically dereferences each ref and handles async loading.\n * Returns an accessor to an array of loaded snapshots (filtering out undefined values).\n *\n * This hook is useful for aggregate computations like counts or filtering\n * across multiple refs without using .target directly.\n *\n * @param refs - Array of Refs to dereference and subscribe to (can be reactive)\n * @returns Accessor to array of loaded target snapshots (excludes unloaded refs)\n */\nexport const useObjects = <T extends Obj.Unknown>(refs: MaybeAccessor<readonly Ref.Ref<T>[]>): Accessor<T[]> => {\n // Track version to trigger re-renders when any ref or target changes.\n const [version, setVersion] = createSignal(0);\n\n // Memoize the refs array to track changes.\n const resolvedRefs = createMemo(() => access(refs));\n\n // Subscribe to all refs and their targets.\n createEffect(() => {\n const currentRefs = resolvedRefs();\n const targetUnsubscribes = new Map<string, () => void>();\n\n // Function to trigger re-render.\n const triggerUpdate = () => {\n setVersion((v) => v + 1);\n };\n\n // Function to set up subscription for a target.\n const subscribeToTarget = (ref: Ref.Ref<T>) => {\n const target = ref.target;\n if (target) {\n const key = ref.dxn.toString();\n if (!targetUnsubscribes.has(key)) {\n targetUnsubscribes.set(key, Obj.subscribe(target, triggerUpdate));\n }\n }\n };\n\n // Try to load all refs and subscribe to targets.\n for (const ref of currentRefs) {\n // Subscribe to existing target if available.\n subscribeToTarget(ref);\n\n // Trigger async load if not already loaded.\n if (!ref.target) {\n void ref\n .load()\n .then(() => {\n subscribeToTarget(ref);\n triggerUpdate();\n })\n .catch(() => {\n // Ignore load errors.\n });\n }\n }\n\n onCleanup(() => {\n targetUnsubscribes.forEach((u) => u());\n });\n });\n\n // Compute current snapshots by reading each ref's target.\n return createMemo(() => {\n // Depend on version to re-compute when targets change.\n version();\n\n const currentRefs = resolvedRefs();\n const snapshots: T[] = [];\n for (const ref of currentRefs) {\n const target = ref.target;\n if (target !== undefined) {\n snapshots.push(target as T);\n }\n }\n return snapshots;\n });\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Accessor, createEffect, createMemo, createSignal, onCleanup } from 'solid-js';\n\nimport { type Database, type Entity, Filter, Query } from '@dxos/echo';\n\nconst EMPTY_ARRAY: never[] = [];\n\ntype MaybeAccessor<T> = T | Accessor<T>;\n\n/**\n * Create a reactive query subscription.\n * Accepts either values or accessors for resource and query/filter.\n *\n * @param resource - The database or queryable resource (can be reactive)\n * @param queryOrFilter - The query or filter to apply (can be reactive)\n * @returns An accessor that returns the current query results\n */\nexport const useQuery = <T extends Entity.Any = Entity.Any>(\n resource: MaybeAccessor<Database.Queryable | undefined>,\n queryOrFilter: MaybeAccessor<Query.Any | Filter.Any>,\n): Accessor<T[]> => {\n // Derive the normalized query from the input\n const query = createMemo(() => {\n const resolved = typeof queryOrFilter === 'function' ? queryOrFilter() : queryOrFilter;\n return Filter.is(resolved) ? Query.select(resolved) : resolved;\n });\n\n // Derive the query result object reactively\n const queryResult = createMemo(() => {\n const q = query();\n const resolvedResource = typeof resource === 'function' ? resource() : resource;\n return resolvedResource?.query(q);\n });\n\n // Store the current results in a signal\n const [objects, setObjects] = createSignal<T[]>(EMPTY_ARRAY as T[]);\n\n // Subscribe to query result changes\n createEffect(() => {\n const result = queryResult();\n if (!result) {\n // Keep previous value during transitions to prevent flickering\n return;\n }\n\n // Subscribe with immediate fire to get initial results\n const unsubscribe = result.subscribe(\n () => {\n setObjects(() => result.results as T[]);\n },\n { fire: true },\n );\n\n onCleanup(unsubscribe);\n });\n\n return objects;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Accessor, createEffect, createMemo, createSignal, onCleanup } from 'solid-js';\n\nimport { type Database, type Type } from '@dxos/echo';\n\ntype MaybeAccessor<T> = T | Accessor<T>;\n\n/**\n * Subscribe to and retrieve schema changes from a database's schema registry.\n * Accepts either values or accessors for db and typename.\n *\n * @param db - The database instance (can be reactive)\n * @param typename - The schema typename to query (can be reactive)\n * @returns An accessor that returns the current schema or undefined\n */\nexport const useSchema = <T extends Type.AnyEntity = Type.AnyEntity>(\n db?: MaybeAccessor<Database.Database | undefined>,\n typename?: MaybeAccessor<string | undefined>,\n): Accessor<T | undefined> => {\n // Derive the schema query reactively\n const query = createMemo(() => {\n const resolvedDb = typeof db === 'function' ? db() : db;\n const resolvedTypename = typeof typename === 'function' ? typename() : typename;\n if (!resolvedTypename || !resolvedDb) {\n return undefined;\n }\n return resolvedDb.schemaRegistry.query({ typename: resolvedTypename, location: ['database', 'runtime'] });\n });\n\n // Store the current schema in a signal\n const [schema, setSchema] = createSignal<T | undefined>(undefined);\n\n // Subscribe to query changes\n createEffect(() => {\n const q = query();\n if (!q) {\n // Keep previous value during transitions to prevent flickering\n return;\n }\n\n // Subscribe to updates with immediate fire to get initial result and track changes\n // The subscription will automatically start the reactive query\n const unsubscribe = q.subscribe(\n () => {\n // Access results inside the callback to ensure query is running\n const results = q.results;\n setSchema(() => results[0] as T | undefined);\n },\n { fire: true },\n );\n\n onCleanup(unsubscribe);\n });\n\n return schema;\n};\n"],
|
|
5
|
+
"mappings": ";AAIA,SAA6BA,cAAc;AAC3C,SAAwBC,cAAcC,YAAY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;AACX,UAAMe,IAAIR,MAAAA;AACV,QAAI,CAACQ,GAAG;AAEN;IACF;AAIA,UAAMC,cAAcD,EAAEE,UACpB,MAAA;AAEE,YAAMC,UAAUH,EAAEG;AAClBJ,gBAAU,MAAMI,QAAQ,CAAA,CAAE;IAC5B,GACA;MAAEC,MAAM;IAAK,CAAA;AAGfhB,IAAAA,WAAUa,WAAAA;EACZ,CAAA;AAEA,SAAOH;AACT;",
|
|
6
|
+
"names": ["access", "createEffect", "createMemo", "createSignal", "onCleanup", "Obj", "Ref", "AtomObj", "useRegistry", "useObject", "objOrRef", "property", "registry", "resolvedInput", "isRef", "liveObj", "input", "target", "callback", "updateOrValue", "obj", "update", "returnValue", "undefined", "Error", "useObjectValue", "useObjectProperty", "initialInput", "initialValue", "get", "make", "value", "setValue", "atom", "currentValue", "unsubscribe", "subscribe", "immediate", "initialObj", "makeProperty", "currentObj", "useObjects", "refs", "version", "setVersion", "resolvedRefs", "currentRefs", "targetUnsubscribes", "Map", "triggerUpdate", "v", "subscribeToTarget", "ref", "key", "dxn", "toString", "has", "set", "load", "then", "catch", "forEach", "u", "snapshots", "push", "createEffect", "createMemo", "createSignal", "onCleanup", "Filter", "Query", "EMPTY_ARRAY", "useQuery", "resource", "queryOrFilter", "query", "resolved", "is", "select", "queryResult", "q", "resolvedResource", "objects", "setObjects", "result", "unsubscribe", "subscribe", "results", "fire", "createEffect", "createMemo", "createSignal", "onCleanup", "useSchema", "db", "typename", "query", "resolvedDb", "resolvedTypename", "undefined", "schemaRegistry", "location", "schema", "setSchema", "q", "unsubscribe", "subscribe", "results", "fire"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/useObject.ts":{"bytes":
|
|
1
|
+
{"inputs":{"src/useObject.ts":{"bytes":28950,"imports":[{"path":"@solid-primitives/utils","kind":"import-statement","external":true},{"path":"solid-js","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-atom","kind":"import-statement","external":true},{"path":"@dxos/effect-atom-solid","kind":"import-statement","external":true}],"format":"esm"},"src/useQuery.ts":{"bytes":5807,"imports":[{"path":"solid-js","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true}],"format":"esm"},"src/useSchema.ts":{"bytes":5930,"imports":[{"path":"solid-js","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":558,"imports":[{"path":"src/useObject.ts","kind":"import-statement","original":"./useObject"},{"path":"src/useQuery.ts","kind":"import-statement","original":"./useQuery"},{"path":"src/useSchema.ts","kind":"import-statement","original":"./useSchema"}],"format":"esm"}},"outputs":{"dist/lib/neutral/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":22198},"dist/lib/neutral/index.mjs":{"imports":[{"path":"@solid-primitives/utils","kind":"import-statement","external":true},{"path":"solid-js","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-atom","kind":"import-statement","external":true},{"path":"@dxos/effect-atom-solid","kind":"import-statement","external":true},{"path":"solid-js","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"solid-js","kind":"import-statement","external":true}],"exports":["useObject","useObjects","useQuery","useSchema"],"entryPoint":"src/index.ts","inputs":{"src/useObject.ts":{"bytesInOutput":4172},"src/index.ts":{"bytesInOutput":0},"src/useQuery.ts":{"bytesInOutput":986},"src/useSchema.ts":{"bytesInOutput":922}},"bytes":6239}}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useObject.d.ts","sourceRoot":"","sources":["../../../src/useObject.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,aAAa,EAAU,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,KAAK,QAAQ,EAAqD,MAAM,UAAU,CAAC;AAE5F,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAItC,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,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,CAAC,EAC1C,QAAQ,EAAE,CAAC,GACV,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,EAAE,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAkJhE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,GAAG,CAAC,OAAO,QAAQ,aAAa,CAAC,SAAS,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAG,QAAQ,CAAC,CAAC,EAAE,CAmE1G,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQuery.d.ts","sourceRoot":"","sources":["../../../src/useQuery.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,QAAQ,EAAqD,MAAM,UAAU,CAAC;AAE5F,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAIvE,KAAK,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;AAExC;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,
|
|
1
|
+
{"version":3,"file":"useQuery.d.ts","sourceRoot":"","sources":["../../../src/useQuery.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,QAAQ,EAAqD,MAAM,UAAU,CAAC;AAE5F,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAIvE,KAAK,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;AAExC;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,YAC9C,aAAa,CAAC,QAAQ,CAAC,SAAS,GAAG,SAAS,CAAC,iBACxC,aAAa,CAAC,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,KACnD,QAAQ,CAAC,CAAC,EAAE,CAqCd,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSchema.d.ts","sourceRoot":"","sources":["../../../src/useSchema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,QAAQ,EAAqD,MAAM,UAAU,CAAC;AAE5F,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAEtD,KAAK,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;AAExC;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"useSchema.d.ts","sourceRoot":"","sources":["../../../src/useSchema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,QAAQ,EAAqD,MAAM,UAAU,CAAC;AAE5F,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAEtD,KAAK,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;AAExC;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,OAC5D,aAAa,CAAC,QAAQ,CAAC,QAAQ,GAAG,SAAS,CAAC,aACtC,aAAa,CAAC,MAAM,GAAG,SAAS,CAAC,KAC3C,QAAQ,CAAC,CAAC,GAAG,SAAS,CAqCxB,CAAC"}
|