@dxos/echo-solid 0.0.0 → 0.8.4-main.1068cf700f

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.
@@ -0,0 +1,209 @@
1
+ // src/useObject.ts
2
+ import { access } from "@solid-primitives/utils";
3
+ import { createEffect, createMemo, createSignal, onCleanup } from "solid-js";
4
+ import { Obj, Ref } from "@dxos/echo";
5
+ import { AtomObj } from "@dxos/echo-atom";
6
+ import { useRegistry } from "@dxos/effect-atom-solid";
7
+ function useObject(objOrRef, property) {
8
+ const registry = useRegistry();
9
+ const resolvedInput = createMemo(() => access(objOrRef));
10
+ const isRef = createMemo(() => Ref.isRef(resolvedInput()));
11
+ const liveObj = createMemo(() => {
12
+ const input = resolvedInput();
13
+ return isRef() ? input?.target : input;
14
+ });
15
+ const callback = (updateOrValue) => {
16
+ const obj = isRef() ? resolvedInput()?.target : liveObj();
17
+ if (!obj) {
18
+ return;
19
+ }
20
+ Obj.change(obj, (o) => {
21
+ if (typeof updateOrValue === "function") {
22
+ const returnValue = updateOrValue(property !== void 0 ? o[property] : o);
23
+ if (returnValue !== void 0) {
24
+ if (property === void 0) {
25
+ throw new Error("Cannot re-assign the entire object");
26
+ }
27
+ o[property] = returnValue;
28
+ }
29
+ } else {
30
+ if (property === void 0) {
31
+ throw new Error("Cannot re-assign the entire object");
32
+ }
33
+ o[property] = updateOrValue;
34
+ }
35
+ });
36
+ };
37
+ if (property !== void 0) {
38
+ useObjectValue(registry, objOrRef);
39
+ return [
40
+ useObjectProperty(registry, liveObj, property),
41
+ callback
42
+ ];
43
+ }
44
+ return [
45
+ useObjectValue(registry, objOrRef),
46
+ callback
47
+ ];
48
+ }
49
+ function useObjectValue(registry, objOrRef) {
50
+ const resolvedInput = createMemo(() => access(objOrRef));
51
+ const initialInput = resolvedInput();
52
+ const initialValue = initialInput ? registry.get(AtomObj.make(initialInput)) : void 0;
53
+ const [value, setValue] = createSignal(initialValue);
54
+ createEffect(() => {
55
+ const input = resolvedInput();
56
+ if (!input) {
57
+ setValue(() => void 0);
58
+ return;
59
+ }
60
+ const atom = AtomObj.make(input);
61
+ const currentValue = registry.get(atom);
62
+ setValue(() => currentValue);
63
+ const unsubscribe = registry.subscribe(atom, () => {
64
+ setValue(() => registry.get(atom));
65
+ }, {
66
+ immediate: true
67
+ });
68
+ onCleanup(unsubscribe);
69
+ });
70
+ return value;
71
+ }
72
+ function useObjectProperty(registry, obj, property) {
73
+ const initialObj = obj();
74
+ const initialValue = initialObj ? registry.get(AtomObj.makeProperty(initialObj, property)) : void 0;
75
+ const [value, setValue] = createSignal(initialValue);
76
+ createEffect(() => {
77
+ const currentObj = obj();
78
+ if (!currentObj) {
79
+ setValue(() => void 0);
80
+ return;
81
+ }
82
+ const atom = AtomObj.makeProperty(currentObj, property);
83
+ const currentValue = registry.get(atom);
84
+ setValue(() => currentValue);
85
+ const unsubscribe = registry.subscribe(atom, () => {
86
+ setValue(() => registry.get(atom));
87
+ }, {
88
+ immediate: true
89
+ });
90
+ onCleanup(unsubscribe);
91
+ });
92
+ return value;
93
+ }
94
+ var useObjects = (refs) => {
95
+ const [version, setVersion] = createSignal(0);
96
+ const resolvedRefs = createMemo(() => access(refs));
97
+ createEffect(() => {
98
+ const currentRefs = resolvedRefs();
99
+ const targetUnsubscribes = /* @__PURE__ */ new Map();
100
+ const triggerUpdate = () => {
101
+ setVersion((v) => v + 1);
102
+ };
103
+ const subscribeToTarget = (ref) => {
104
+ const target = ref.target;
105
+ if (target) {
106
+ const key = ref.dxn.toString();
107
+ if (!targetUnsubscribes.has(key)) {
108
+ targetUnsubscribes.set(key, Obj.subscribe(target, triggerUpdate));
109
+ }
110
+ }
111
+ };
112
+ for (const ref of currentRefs) {
113
+ subscribeToTarget(ref);
114
+ if (!ref.target) {
115
+ void ref.load().then(() => {
116
+ subscribeToTarget(ref);
117
+ triggerUpdate();
118
+ }).catch(() => {
119
+ });
120
+ }
121
+ }
122
+ onCleanup(() => {
123
+ targetUnsubscribes.forEach((u) => u());
124
+ });
125
+ });
126
+ return createMemo(() => {
127
+ version();
128
+ const currentRefs = resolvedRefs();
129
+ const snapshots = [];
130
+ for (const ref of currentRefs) {
131
+ const target = ref.target;
132
+ if (target !== void 0) {
133
+ snapshots.push(target);
134
+ }
135
+ }
136
+ return snapshots;
137
+ });
138
+ };
139
+
140
+ // src/useQuery.ts
141
+ import { createEffect as createEffect2, createMemo as createMemo2, createSignal as createSignal2, onCleanup as onCleanup2 } from "solid-js";
142
+ import { Filter, Query } from "@dxos/echo";
143
+ var EMPTY_ARRAY = [];
144
+ var useQuery = (resource, queryOrFilter) => {
145
+ const query = createMemo2(() => {
146
+ const resolved = typeof queryOrFilter === "function" ? queryOrFilter() : queryOrFilter;
147
+ return Filter.is(resolved) ? Query.select(resolved) : resolved;
148
+ });
149
+ const queryResult = createMemo2(() => {
150
+ const q = query();
151
+ const resolvedResource = typeof resource === "function" ? resource() : resource;
152
+ return resolvedResource?.query(q);
153
+ });
154
+ const [objects, setObjects] = createSignal2(EMPTY_ARRAY);
155
+ createEffect2(() => {
156
+ const result = queryResult();
157
+ if (!result) {
158
+ return;
159
+ }
160
+ const unsubscribe = result.subscribe(() => {
161
+ setObjects(() => result.results);
162
+ }, {
163
+ fire: true
164
+ });
165
+ onCleanup2(unsubscribe);
166
+ });
167
+ return objects;
168
+ };
169
+
170
+ // src/useSchema.ts
171
+ import { createEffect as createEffect3, createMemo as createMemo3, createSignal as createSignal3, onCleanup as onCleanup3 } from "solid-js";
172
+ var useSchema = (db, typename) => {
173
+ const query = createMemo3(() => {
174
+ const resolvedDb = typeof db === "function" ? db() : db;
175
+ const resolvedTypename = typeof typename === "function" ? typename() : typename;
176
+ if (!resolvedTypename || !resolvedDb) {
177
+ return void 0;
178
+ }
179
+ return resolvedDb.schemaRegistry.query({
180
+ typename: resolvedTypename,
181
+ location: [
182
+ "database",
183
+ "runtime"
184
+ ]
185
+ });
186
+ });
187
+ const [schema, setSchema] = createSignal3(void 0);
188
+ createEffect3(() => {
189
+ const q = query();
190
+ if (!q) {
191
+ return;
192
+ }
193
+ const unsubscribe = q.subscribe(() => {
194
+ const results = q.results;
195
+ setSchema(() => results[0]);
196
+ }, {
197
+ fire: true
198
+ });
199
+ onCleanup3(unsubscribe);
200
+ });
201
+ return schema;
202
+ };
203
+ export {
204
+ useObject,
205
+ useObjects,
206
+ useQuery,
207
+ useSchema
208
+ };
209
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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.Entity.Any = Type.Entity.Any>(\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,WAAWC,YAAAA;AAGjB,QAAMC,gBAAgBC,WAAW,MAAMC,OAAON,QAAAA,CAAAA;AAG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AAEA,SAAOL;AACT;",
6
+ "names": ["access", "createEffect", "createMemo", "createSignal", "onCleanup", "Obj", "Ref", "AtomObj", "useRegistry", "useObject", "objOrRef", "property", "registry", "useRegistry", "resolvedInput", "createMemo", "access", "isRef", "Ref", "liveObj", "input", "target", "callback", "updateOrValue", "obj", "Obj", "change", "o", "returnValue", "undefined", "Error", "useObjectValue", "useObjectProperty", "initialInput", "initialValue", "get", "AtomObj", "make", "value", "setValue", "createSignal", "createEffect", "atom", "currentValue", "unsubscribe", "subscribe", "immediate", "onCleanup", "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", "createMemo", "resolved", "Filter", "is", "Query", "select", "queryResult", "q", "resolvedResource", "objects", "setObjects", "createSignal", "createEffect", "result", "unsubscribe", "subscribe", "results", "fire", "onCleanup", "createEffect", "createMemo", "createSignal", "onCleanup", "useSchema", "db", "typename", "query", "createMemo", "resolvedDb", "resolvedTypename", "undefined", "schemaRegistry", "location", "schema", "setSchema", "createSignal", "createEffect", "q", "unsubscribe", "subscribe", "results", "fire", "onCleanup"]
7
+ }
@@ -0,0 +1 @@
1
+ {"inputs":{"src/useObject.ts":{"bytes":28959,"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":5894,"imports":[{"path":"solid-js","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true}],"format":"esm"},"src/useSchema.ts":{"bytes":6018,"imports":[{"path":"solid-js","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":638,"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":22399},"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":4138},"src/index.ts":{"bytesInOutput":0},"src/useQuery.ts":{"bytesInOutput":986},"src/useSchema.ts":{"bytesInOutput":922}},"bytes":6205}}}
@@ -0,0 +1,4 @@
1
+ export * from './useObject';
2
+ export * from './useQuery';
3
+ export * from './useSchema';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,101 @@
1
+ import { type MaybeAccessor } from '@solid-primitives/utils';
2
+ import { type Accessor } from 'solid-js';
3
+ import { Obj, Ref } from '@dxos/echo';
4
+ export interface ObjectUpdateCallback<T> {
5
+ (update: (obj: Obj.Mutable<T>) => void): void;
6
+ (update: (obj: Obj.Mutable<T>) => Obj.Mutable<T>): void;
7
+ }
8
+ export interface ObjectPropUpdateCallback<T> {
9
+ (update: (value: Obj.Mutable<T>) => void): void;
10
+ (update: (value: Obj.Mutable<T>) => Obj.Mutable<T>): void;
11
+ (newValue: T): void;
12
+ }
13
+ /**
14
+ * Helper type to conditionally include undefined in return type only if input includes undefined.
15
+ * Only adds undefined if T includes undefined AND R doesn't already include undefined.
16
+ */
17
+ type ConditionalUndefined<T, R> = [T] extends [Exclude<T, undefined>] ? R : [R] extends [Exclude<R, undefined>] ? R | undefined : R;
18
+ /**
19
+ * Subscribe to a Ref's target object.
20
+ * Automatically dereferences the ref and handles async loading.
21
+ * Returns undefined if the ref hasn't loaded yet.
22
+ *
23
+ * @param ref - The Ref to dereference and subscribe to (can be reactive)
24
+ * @returns A tuple of [accessor, updateCallback]
25
+ */
26
+ export declare function useObject<T>(ref: MaybeAccessor<Ref.Ref<T>>): [Accessor<T | undefined>, ObjectUpdateCallback<T>];
27
+ /**
28
+ * Subscribe to a Ref's target object that may be undefined.
29
+ * Returns undefined if the ref is undefined or hasn't loaded yet.
30
+ *
31
+ * @param ref - The Ref to dereference and subscribe to (can be undefined/reactive)
32
+ * @returns A tuple of [accessor, updateCallback]
33
+ */
34
+ export declare function useObject<T>(ref: MaybeAccessor<Ref.Ref<T> | undefined>): [Accessor<T | undefined>, ObjectUpdateCallback<T>];
35
+ /**
36
+ * Subscribe to an entire Echo object.
37
+ * Returns the current object value accessor and an update callback.
38
+ *
39
+ * @param obj - The Echo object to subscribe to (can be reactive)
40
+ * @returns A tuple of [accessor, updateCallback]
41
+ */
42
+ export declare function useObject<T extends Obj.Unknown>(obj: MaybeAccessor<T>): [Accessor<ConditionalUndefined<T, T>>, ObjectUpdateCallback<T>];
43
+ /**
44
+ * Subscribe to an entire Echo object that may be undefined.
45
+ * Returns undefined if the object is undefined.
46
+ *
47
+ * @param obj - The Echo object to subscribe to (can be undefined/reactive)
48
+ * @returns A tuple of [accessor, updateCallback]
49
+ */
50
+ export declare function useObject<T extends Obj.Unknown>(obj: MaybeAccessor<T | undefined>): [Accessor<ConditionalUndefined<T, T>>, ObjectUpdateCallback<T>];
51
+ /**
52
+ * Subscribe to a specific property of an Echo object.
53
+ * Returns the current property value accessor and an update callback.
54
+ *
55
+ * @param obj - The Echo object to subscribe to (can be reactive)
56
+ * @param property - Property key to subscribe to
57
+ * @returns A tuple of [accessor, updateCallback]
58
+ */
59
+ export declare function useObject<T extends Obj.Unknown, K extends keyof T>(obj: MaybeAccessor<T>, property: K): [Accessor<T[K]>, ObjectPropUpdateCallback<T[K]>];
60
+ /**
61
+ * Subscribe to a specific property of an Echo object that may be undefined.
62
+ * Returns undefined if the object is undefined.
63
+ *
64
+ * @param obj - The Echo object to subscribe to (can be undefined/reactive)
65
+ * @param property - Property key to subscribe to
66
+ * @returns A tuple of [accessor, updateCallback]
67
+ */
68
+ export declare function useObject<T extends Obj.Unknown, K extends keyof T>(obj: MaybeAccessor<T | undefined>, property: K): [Accessor<T[K] | undefined>, ObjectPropUpdateCallback<T[K]>];
69
+ /**
70
+ * Subscribe to a specific property of a Ref's target object.
71
+ * Automatically dereferences the ref and handles async loading.
72
+ * Returns undefined if the ref hasn't loaded yet.
73
+ *
74
+ * @param ref - The Ref to dereference and subscribe to (can be reactive)
75
+ * @param property - Property key to subscribe to
76
+ * @returns A tuple of [accessor, updateCallback]
77
+ */
78
+ export declare function useObject<T, K extends keyof T>(ref: MaybeAccessor<Ref.Ref<T>>, property: K): [Accessor<T[K] | undefined>, ObjectPropUpdateCallback<T[K]>];
79
+ /**
80
+ * Subscribe to a specific property of a Ref's target object that may be undefined.
81
+ * Returns undefined if the ref is undefined or hasn't loaded yet.
82
+ *
83
+ * @param ref - The Ref to dereference and subscribe to (can be undefined/reactive)
84
+ * @param property - Property key to subscribe to
85
+ * @returns A tuple of [accessor, updateCallback]
86
+ */
87
+ export declare function useObject<T, K extends keyof T>(ref: MaybeAccessor<Ref.Ref<T> | undefined>, property: K): [Accessor<T[K] | undefined>, ObjectPropUpdateCallback<T[K]>];
88
+ /**
89
+ * Subscribe to multiple Refs' target objects.
90
+ * Automatically dereferences each ref and handles async loading.
91
+ * Returns an accessor to an array of loaded snapshots (filtering out undefined values).
92
+ *
93
+ * This hook is useful for aggregate computations like counts or filtering
94
+ * across multiple refs without using .target directly.
95
+ *
96
+ * @param refs - Array of Refs to dereference and subscribe to (can be reactive)
97
+ * @returns Accessor to array of loaded target snapshots (excludes unloaded refs)
98
+ */
99
+ export declare const useObjects: <T extends Obj.Unknown>(refs: MaybeAccessor<readonly Ref.Ref<T>[]>) => Accessor<T[]>;
100
+ export {};
101
+ //# sourceMappingURL=useObject.d.ts.map
@@ -0,0 +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,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI,CAAC;IAC9C,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;CACzD;AAED,MAAM,WAAW,wBAAwB,CAAC,CAAC;IACzC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI,CAAC;IAChD,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAC1D,CAAC,QAA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AiJhE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,GAAG,CAAC,OAAO,EAAE,MAAM,aAAa,CAAC,SAAS,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAG,QAAQ,CAAC,CAAC,EAAE,CAmE1G,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=useObject.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useObject.test.d.ts","sourceRoot":"","sources":["../../../src/useObject.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import { type Accessor } from 'solid-js';
2
+ import { type Database, type Entity, Filter, Query } from '@dxos/echo';
3
+ type MaybeAccessor<T> = T | Accessor<T>;
4
+ /**
5
+ * Create a reactive query subscription.
6
+ * Accepts either values or accessors for resource and query/filter.
7
+ *
8
+ * @param resource - The database or queryable resource (can be reactive)
9
+ * @param queryOrFilter - The query or filter to apply (can be reactive)
10
+ * @returns An accessor that returns the current query results
11
+ */
12
+ export declare const useQuery: <T extends Entity.Any = Entity.Any>(resource: MaybeAccessor<Database.Queryable | undefined>, queryOrFilter: MaybeAccessor<Query.Any | Filter.Any>) => Accessor<T[]>;
13
+ export {};
14
+ //# sourceMappingURL=useQuery.d.ts.map
@@ -0,0 +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,EACxD,UAAU,aAAa,CAAC,QAAQ,CAAC,SAAS,GAAG,SAAS,CAAC,EACvD,eAAe,aAAa,CAAC,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,KACnD,QAAQ,CAAC,CAAC,EAAE,CAqCd,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=useQuery.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useQuery.test.d.ts","sourceRoot":"","sources":["../../../src/useQuery.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import { type Accessor } from 'solid-js';
2
+ import { type Database, type Type } from '@dxos/echo';
3
+ type MaybeAccessor<T> = T | Accessor<T>;
4
+ /**
5
+ * Subscribe to and retrieve schema changes from a database's schema registry.
6
+ * Accepts either values or accessors for db and typename.
7
+ *
8
+ * @param db - The database instance (can be reactive)
9
+ * @param typename - The schema typename to query (can be reactive)
10
+ * @returns An accessor that returns the current schema or undefined
11
+ */
12
+ export declare const useSchema: <T extends Type.Entity.Any = Type.Entity.Any>(db?: MaybeAccessor<Database.Database | undefined>, typename?: MaybeAccessor<string | undefined>) => Accessor<T | undefined>;
13
+ export {};
14
+ //# sourceMappingURL=useSchema.d.ts.map
@@ -0,0 +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,MAAM,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,EACnE,KAAK,aAAa,CAAC,QAAQ,CAAC,QAAQ,GAAG,SAAS,CAAC,EACjD,WAAW,aAAa,CAAC,MAAM,GAAG,SAAS,CAAC,KAC3C,QAAQ,CAAC,CAAC,GAAG,SAAS,CAqCxB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=useSchema.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSchema.test.d.ts","sourceRoot":"","sources":["../../../src/useSchema.test.tsx"],"names":[],"mappings":""}