@dxos/echo-react 0.9.1-main.c7dcc2e112 → 0.9.1-staging.ee54ba693a
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/dist/lib/neutral/index.mjs.map +2 -2
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/types/src/useObject.d.ts +12 -1
- package/dist/types/src/useObject.d.ts.map +1 -1
- package/dist/types/src/useType.d.ts +1 -1
- package/dist/types/src/useType.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/src/useObject.ts +12 -1
- package/src/useType.ts +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/useQuery.ts", "../../../src/useType.ts", "../../../src/useObject.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport { useMemo, useSyncExternalStore } from 'react';\n\nimport { type Database, type Entity, Filter, Query } from '@dxos/echo';\n\nconst EMPTY_ARRAY: never[] = [];\n\nconst noop = () => {};\n\ninterface UseQueryFn {\n <Q extends Query.Any, O extends Entity.Entity<Query.Type<Q>> = Entity.Entity<Query.Type<Q>>>(\n resource: Database.Queryable | undefined,\n query: Q,\n ): O[];\n\n <F extends Filter.Any, O extends Entity.Entity<Filter.Type<F>> = Entity.Entity<Filter.Type<F>>>(\n resource: Database.Queryable | undefined,\n filter: F,\n ): O[];\n}\n\n/**\n * Create subscription.\n *\n * @param queryOrFilter - The query or filter to apply. Query is memoized based on the AST. No need to call useMemo.\n */\nexport const useQuery: UseQueryFn = (\n resource: Database.Queryable | undefined,\n queryOrFilter: Query.Any | Filter.Any,\n): Entity.Any[] => {\n const query = Filter.is(queryOrFilter) ? Query.select(queryOrFilter) : queryOrFilter;\n\n const { getObjects, subscribe } = useMemo(() => {\n let queryResult = undefined;\n if (resource) {\n queryResult = resource.query(query);\n }\n\n let subscribed = false;\n return {\n getObjects: () => (subscribed && queryResult ? queryResult.results : EMPTY_ARRAY),\n subscribe: (cb: () => void) => {\n subscribed = true;\n const unsubscribe = queryResult?.subscribe(cb) ?? noop;\n return () => {\n unsubscribe?.();\n subscribed = false;\n };\n },\n };\n }, [resource, JSON.stringify(query.ast)]);\n\n // https://beta.reactjs.org/reference/react/useSyncExternalStore\n // NOTE: This hook will resubscribe whenever the callback passed to the first argument changes; make sure it is stable.\n const objects = useSyncExternalStore<Entity.Any[]>(subscribe, getObjects);\n return objects;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useMemo, useSyncExternalStore } from 'react';\n\nimport { DXN, EID, URI, type Database, Filter, Query, Scope, Type } from '@dxos/echo';\n\n/**\n * Subscribe to and retrieve a type by its URI from a space: a static schema's typename DXN, or a\n * persisted (database) schema's `echo:` EID (what `Type.getURI` / `getTypeURIFromQuery` produce).\n *\n * Fans across the owning space db (persisted custom types) and the shared\n * registry (static/runtime plugin types). Persisted types live only in the db,\n * so a registry-only lookup misses them.\n *\n * DXN matching is version-agnostic: `dxn:com.example/Foo` matches `dxn:com.example/Foo:0.1.0`.\n * This lets callers pass a bare typename DXN (no version) from e.g. a `ReferenceAnnotation`.\n */\nexport const useType = <T extends Type.AnyEntity = Type.AnyEntity>(\n db?: Database.Database,\n typeUri?: URI.URI,\n): T | undefined => {\n const { subscribe, getType } = useMemo(() => {\n if (!typeUri || !db) {\n return {\n subscribe: () => () => {},\n getType: (): T | undefined => undefined,\n };\n }\n\n const searchEid = EID.isEID(typeUri) ? EID.tryParse(typeUri) : undefined;\n const searchDxn = DXN.isDXN(typeUri) ? DXN.tryMake(typeUri) : undefined;\n\n const queryResult = db.query(Query.select(Filter.type(Type.Type)).from(Scope.space(), Scope.registry()));\n let subscribed = false;\n const find = (): T | undefined => {\n if (!subscribed) {\n return undefined;\n }\n return queryResult.results.find((type) => {\n const uri = Type.getURI(type);\n if (uri === typeUri) {\n return true;\n }\n // EID matching is space-agnostic: echo:/<id> matches echo://<space>/<id>.\n if (searchEid && EID.isEID(uri)) {\n const typeEid = EID.tryParse(uri);\n return typeEid != null && EID.getEntityId(typeEid) === EID.getEntityId(searchEid);\n }\n // DXN matching is version-agnostic so callers may pass an unversioned DXN.\n if (searchDxn && DXN.isDXN(uri)) {\n const typeDxn = DXN.tryMake(uri);\n return typeDxn != null && DXN.getName(typeDxn) === DXN.getName(searchDxn);\n }\n return false;\n }) as T | undefined;\n };\n\n return {\n subscribe: (onStoreChange: () => void) => {\n subscribed = true;\n const unsubscribe = queryResult.subscribe(onStoreChange);\n return () => {\n unsubscribe();\n subscribed = false;\n };\n },\n getType: find,\n };\n }, [typeUri, db]);\n\n return useSyncExternalStore(subscribe, getType);\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useAtomValue } from '@effect-atom/atom-react';\nimport * as Atom from '@effect-atom/atom/Atom';\nimport { useCallback, useMemo } from 'react';\n\nimport { Obj, Ref } from '@dxos/echo';\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\nexport const useObject: {\n /**\n * Hook to subscribe to a Ref's target object.\n * Automatically dereferences the ref and handles async loading.\n * Returns a snapshot (undefined if the ref hasn't loaded yet).\n *\n * @param ref - The Ref to dereference and subscribe to\n * @returns The current target snapshot (or undefined if not loaded) and update callback\n */\n <T extends Obj.Unknown>(ref: Ref.Ref<T>): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];\n\n /**\n * Hook to subscribe to a Ref's target object that may be undefined.\n * Returns a snapshot (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)\n * @returns The current target snapshot (or undefined) and update callback\n */\n <T extends Obj.Unknown>(ref: Ref.Ref<T> | undefined): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];\n\n /**\n * Hook to subscribe to an entire Echo object.\n * Returns a snapshot of the current object value and automatically re-renders when the object changes.\n *\n * @param obj - The Echo object to subscribe to (objects only, not relations)\n * @returns The current object snapshot and update callback\n */\n <T extends Obj.Unknown>(obj: T): [Obj.Snapshot<T>, ObjectUpdateCallback<T>];\n\n /**\n * Hook to subscribe to an entire Echo object that may be undefined.\n * Returns a snapshot (undefined if the object is undefined).\n *\n * @param obj - The Echo object to subscribe to (can be undefined, objects only)\n * @returns The current object snapshot (or undefined) and update callback\n */\n <T extends Obj.Unknown>(obj: T | undefined): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];\n\n /**\n * Hook to subscribe to an Echo object or Ref.\n * Handles both cases - if passed a Ref, dereferences it and subscribes to the target.\n * Returns a snapshot (undefined if ref hasn't loaded).\n *\n * @param objOrRef - The Echo object or Ref to subscribe to\n * @returns The current object snapshot (or undefined) and update callback\n */\n <T extends Obj.Unknown>(objOrRef: T | Ref.Ref<T>): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];\n\n /**\n * Hook to subscribe to a specific property of an Echo object.\n * Returns the current property value and automatically re-renders when the property changes.\n *\n * @param obj - The Echo object to subscribe to (objects only, not relations)\n * @param property - Property key to subscribe to\n * @returns The current property value and update callback\n */\n <T extends Obj.Unknown, K extends keyof T>(obj: T, property: K): [T[K], ObjectPropUpdateCallback<T[K]>];\n\n /**\n * Hook to 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, objects only)\n * @param property - Property key to subscribe to\n * @returns The current property value (or undefined) and update callback\n */\n <T extends Obj.Unknown, K extends keyof T>(\n obj: T | undefined,\n property: K,\n ): [T[K] | undefined, ObjectPropUpdateCallback<T[K]>];\n\n /**\n * Hook to 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\n * @param property - Property key to subscribe to\n * @returns The current property value (or undefined if not loaded) and update callback\n */\n <T, K extends keyof T>(ref: Ref.Ref<T>, property: K): [T[K] | undefined, ObjectPropUpdateCallback<T[K]>];\n\n /**\n * Hook to 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)\n * @param property - Property key to subscribe to\n * @returns The current property value (or undefined) and update callback\n */\n <T, K extends keyof T>(ref: Ref.Ref<T> | undefined, property: K): [T[K] | undefined, ObjectPropUpdateCallback<T[K]>];\n} = (<T extends Obj.Unknown, K extends keyof T>(objOrRef: T | Ref.Ref<T> | undefined, property?: K): any => {\n // Get the live object for the callback (refs need to dereference).\n const isRef = Ref.isRef(objOrRef);\n const liveObj = isRef ? (objOrRef as Ref.Ref<T>)?.target : (objOrRef as T | undefined);\n\n const callback: ObjectPropUpdateCallback<unknown> = useCallback(\n (updateOrValue: unknown | ((obj: unknown) => unknown)) => {\n // Get current target for refs (may have loaded since render).\n const obj = isRef ? (objOrRef as Ref.Ref<T>)?.target : liveObj;\n if (obj === undefined) {\n return;\n }\n Obj.update(obj, (obj: any) => {\n if (typeof updateOrValue === 'function') {\n const returnValue = updateOrValue(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 [objOrRef, property, isRef, liveObj],\n );\n\n if (property !== undefined) {\n // For refs, subscribe to load event only (not full mutation tracking).\n // Property-level updates are handled by useObjectProperty once the ref loads.\n useRefLoad(objOrRef);\n return [useObjectProperty(liveObj, property as any), callback];\n } else {\n return [useObjectValue(objOrRef), callback];\n }\n}) as any;\n\n/**\n * Internal hook for subscribing to an Echo object or Ref.\n */\nconst useObjectValue = <T extends Obj.Unknown>(objOrRef: T | Ref.Ref<T> | undefined): Obj.Snapshot<T> | undefined => {\n const atom = useMemo(() => {\n if (objOrRef == null) {\n return Atom.make<Obj.Snapshot<T> | undefined>(() => undefined);\n }\n if (Ref.isRef(objOrRef)) {\n return Obj.atom(objOrRef);\n }\n return Obj.atom(objOrRef);\n }, [objOrRef]);\n return useAtomValue(atom) as Obj.Snapshot<T> | undefined;\n};\n\n/**\n * Internal hook for subscribing to ref resolution only (load-once).\n * Triggers a re-render when the ref target first becomes available,\n * without subscribing to subsequent target mutations.\n * For non-refs, this is a no-op.\n */\nconst useRefLoad = <T extends Obj.Unknown>(objOrRef: T | Ref.Ref<T> | undefined): void => {\n const atom = useMemo(() => {\n if (objOrRef == null || !Ref.isRef(objOrRef)) {\n return Atom.make<T | undefined>(() => undefined);\n }\n return objOrRef.atom;\n }, [objOrRef]);\n useAtomValue(atom);\n};\n\n/**\n * Internal hook for subscribing to a specific property of an Echo object.\n */\nconst useObjectProperty = <T extends Obj.Unknown, K extends keyof T>(\n obj: T | undefined,\n property: K,\n): T[K] | undefined => {\n const atom = useMemo(() => {\n if (obj == null) {\n return Atom.make<T[K] | undefined>(() => undefined);\n }\n return Obj.atomProperty(obj, property);\n }, [obj, property]);\n return useAtomValue(atom);\n};\n\n/**\n * Hook to subscribe to multiple Refs' target objects.\n * Automatically dereferences each ref and handles async loading.\n * Returns 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\n * @returns Array of loaded target snapshots (excludes unloaded refs)\n */\nexport const useObjects = <T extends Obj.Unknown>(refs: readonly Ref.Ref<T>[]): Obj.Snapshot<T>[] => {\n const atom = useMemo(\n () =>\n Atom.make((get) => {\n const results: Obj.Snapshot<T>[] = [];\n for (const ref of refs) {\n const value = get(Obj.atom(ref));\n if (value !== undefined) {\n results.push(value as Obj.Snapshot<T>);\n }\n }\n return results;\n }),\n [refs],\n );\n return useAtomValue(atom);\n};\n"],
|
|
5
|
-
"mappings": ";AAIA,SAASA,SAASC,4BAA4B;AAE9C,SAAqCC,QAAQC,aAAa;AAE1D,IAAMC,cAAuB,CAAA;AAE7B,IAAMC,OAAO,MAAA;AAAO;AAmBb,IAAMC,WAAuB,CAClCC,UACAC,kBAAAA;AAEA,QAAMC,QAAQP,OAAOQ,GAAGF,aAAAA,IAAiBL,MAAMQ,OAAOH,aAAAA,IAAiBA;AAEvE,QAAM,EAAEI,YAAYC,UAAS,IAAKb,QAAQ,MAAA;AACxC,QAAIc,cAAcC;AAClB,QAAIR,UAAU;AACZO,oBAAcP,SAASE,MAAMA,KAAAA;IAC/B;AAEA,QAAIO,aAAa;AACjB,WAAO;MACLJ,YAAY,MAAOI,cAAcF,cAAcA,YAAYG,UAAUb;MACrES,WAAW,CAACK,OAAAA;AACVF,qBAAa;AACb,cAAMG,cAAcL,aAAaD,UAAUK,EAAAA,KAAOb;AAClD,eAAO,MAAA;AACLc,wBAAAA;AACAH,uBAAa;QACf;MACF;IACF;EACF,GAAG;IAACT;IAAUa,KAAKC,UAAUZ,MAAMa,GAAG;GAAE;AAIxC,QAAMC,UAAUtB,qBAAmCY,WAAWD,UAAAA;AAC9D,SAAOW;AACT;;;ACvDA,SAASC,WAAAA,UAASC,wBAAAA,6BAA4B;AAE9C,
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport { useMemo, useSyncExternalStore } from 'react';\n\nimport { type Database, type Entity, Filter, Query } from '@dxos/echo';\n\nconst EMPTY_ARRAY: never[] = [];\n\nconst noop = () => {};\n\ninterface UseQueryFn {\n <Q extends Query.Any, O extends Entity.Entity<Query.Type<Q>> = Entity.Entity<Query.Type<Q>>>(\n resource: Database.Queryable | undefined,\n query: Q,\n ): O[];\n\n <F extends Filter.Any, O extends Entity.Entity<Filter.Type<F>> = Entity.Entity<Filter.Type<F>>>(\n resource: Database.Queryable | undefined,\n filter: F,\n ): O[];\n}\n\n/**\n * Create subscription.\n *\n * @param queryOrFilter - The query or filter to apply. Query is memoized based on the AST. No need to call useMemo.\n */\nexport const useQuery: UseQueryFn = (\n resource: Database.Queryable | undefined,\n queryOrFilter: Query.Any | Filter.Any,\n): Entity.Any[] => {\n const query = Filter.is(queryOrFilter) ? Query.select(queryOrFilter) : queryOrFilter;\n\n const { getObjects, subscribe } = useMemo(() => {\n let queryResult = undefined;\n if (resource) {\n queryResult = resource.query(query);\n }\n\n let subscribed = false;\n return {\n getObjects: () => (subscribed && queryResult ? queryResult.results : EMPTY_ARRAY),\n subscribe: (cb: () => void) => {\n subscribed = true;\n const unsubscribe = queryResult?.subscribe(cb) ?? noop;\n return () => {\n unsubscribe?.();\n subscribed = false;\n };\n },\n };\n }, [resource, JSON.stringify(query.ast)]);\n\n // https://beta.reactjs.org/reference/react/useSyncExternalStore\n // NOTE: This hook will resubscribe whenever the callback passed to the first argument changes; make sure it is stable.\n const objects = useSyncExternalStore<Entity.Any[]>(subscribe, getObjects);\n return objects;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useMemo, useSyncExternalStore } from 'react';\n\nimport { type Database, DXN, EID, Filter, Query, Scope, Type, URI } from '@dxos/echo';\n\n/**\n * Subscribe to and retrieve a type by its URI from a space: a static schema's typename DXN, or a\n * persisted (database) schema's `echo:` EID (what `Type.getURI` / `getTypeURIFromQuery` produce).\n *\n * Fans across the owning space db (persisted custom types) and the shared\n * registry (static/runtime plugin types). Persisted types live only in the db,\n * so a registry-only lookup misses them.\n *\n * DXN matching is version-agnostic: `dxn:com.example/Foo` matches `dxn:com.example/Foo:0.1.0`.\n * This lets callers pass a bare typename DXN (no version) from e.g. a `ReferenceAnnotation`.\n */\nexport const useType = <T extends Type.AnyEntity = Type.AnyEntity>(\n db?: Database.Database,\n typeUri?: URI.URI,\n): T | undefined => {\n const { subscribe, getType } = useMemo(() => {\n if (!typeUri || !db) {\n return {\n subscribe: () => () => {},\n getType: (): T | undefined => undefined,\n };\n }\n\n const searchEid = EID.isEID(typeUri) ? EID.tryParse(typeUri) : undefined;\n const searchDxn = DXN.isDXN(typeUri) ? DXN.tryMake(typeUri) : undefined;\n\n const queryResult = db.query(Query.select(Filter.type(Type.Type)).from(Scope.space(), Scope.registry()));\n let subscribed = false;\n const find = (): T | undefined => {\n if (!subscribed) {\n return undefined;\n }\n return queryResult.results.find((type) => {\n const uri = Type.getURI(type);\n if (uri === typeUri) {\n return true;\n }\n // EID matching is space-agnostic: echo:/<id> matches echo://<space>/<id>.\n if (searchEid && EID.isEID(uri)) {\n const typeEid = EID.tryParse(uri);\n return typeEid != null && EID.getEntityId(typeEid) === EID.getEntityId(searchEid);\n }\n // DXN matching is version-agnostic so callers may pass an unversioned DXN.\n if (searchDxn && DXN.isDXN(uri)) {\n const typeDxn = DXN.tryMake(uri);\n return typeDxn != null && DXN.getName(typeDxn) === DXN.getName(searchDxn);\n }\n return false;\n }) as T | undefined;\n };\n\n return {\n subscribe: (onStoreChange: () => void) => {\n subscribed = true;\n const unsubscribe = queryResult.subscribe(onStoreChange);\n return () => {\n unsubscribe();\n subscribed = false;\n };\n },\n getType: find,\n };\n }, [typeUri, db]);\n\n return useSyncExternalStore(subscribe, getType);\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useAtomValue } from '@effect-atom/atom-react';\nimport * as Atom from '@effect-atom/atom/Atom';\nimport { useCallback, useMemo } from 'react';\n\nimport { Obj, Ref } from '@dxos/echo';\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\nexport const useObject: {\n /**\n * Hook to subscribe to a Ref's target object.\n * Automatically dereferences the ref and handles async loading.\n * Returns a snapshot (undefined if the ref hasn't loaded yet).\n * Re-renders the component when the ref resolves or the target object changes.\n *\n * @param ref - The Ref to dereference and subscribe to\n * @returns The current target snapshot (or undefined if not loaded) and update callback\n *\n * @idiom org.dxos.echo-react.useObjectReactive\n * applies: Reading a ref's target (or a specific property) inside a React component — establishes a reactive subscription so the component re-renders when the ref resolves or the value changes\n * instead-of: `ref.target` — synchronous and not reactive; returns `undefined` when the target isn't loaded yet and never triggers a re-render when it becomes available\n * uses: {@link useObject}\n * related: org.dxos.echo.objAtomReactive, org.dxos.echo.refLoad\n */\n <T extends Obj.Unknown>(ref: Ref.Ref<T>): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];\n\n /**\n * Hook to subscribe to a Ref's target object that may be undefined.\n * Returns a snapshot (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)\n * @returns The current target snapshot (or undefined) and update callback\n */\n <T extends Obj.Unknown>(ref: Ref.Ref<T> | undefined): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];\n\n /**\n * Hook to subscribe to an entire Echo object.\n * Returns a snapshot of the current object value and automatically re-renders when the object changes.\n *\n * @param obj - The Echo object to subscribe to (objects only, not relations)\n * @returns The current object snapshot and update callback\n */\n <T extends Obj.Unknown>(obj: T): [Obj.Snapshot<T>, ObjectUpdateCallback<T>];\n\n /**\n * Hook to subscribe to an entire Echo object that may be undefined.\n * Returns a snapshot (undefined if the object is undefined).\n *\n * @param obj - The Echo object to subscribe to (can be undefined, objects only)\n * @returns The current object snapshot (or undefined) and update callback\n */\n <T extends Obj.Unknown>(obj: T | undefined): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];\n\n /**\n * Hook to subscribe to an Echo object or Ref.\n * Handles both cases - if passed a Ref, dereferences it and subscribes to the target.\n * Returns a snapshot (undefined if ref hasn't loaded).\n *\n * @param objOrRef - The Echo object or Ref to subscribe to\n * @returns The current object snapshot (or undefined) and update callback\n */\n <T extends Obj.Unknown>(objOrRef: T | Ref.Ref<T> | undefined): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];\n\n /**\n * Hook to subscribe to a specific property of an Echo object.\n * Returns the current property value and automatically re-renders when the property changes.\n *\n * @param obj - The Echo object to subscribe to (objects only, not relations)\n * @param property - Property key to subscribe to\n * @returns The current property value and update callback\n */\n <T extends Obj.Unknown, K extends keyof T>(obj: T, property: K): [T[K], ObjectPropUpdateCallback<T[K]>];\n\n /**\n * Hook to 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, objects only)\n * @param property - Property key to subscribe to\n * @returns The current property value (or undefined) and update callback\n */\n <T extends Obj.Unknown, K extends keyof T>(\n obj: T | undefined,\n property: K,\n ): [T[K] | undefined, ObjectPropUpdateCallback<T[K]>];\n\n /**\n * Hook to 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\n * @param property - Property key to subscribe to\n * @returns The current property value (or undefined if not loaded) and update callback\n */\n <T, K extends keyof T>(ref: Ref.Ref<T>, property: K): [T[K] | undefined, ObjectPropUpdateCallback<T[K]>];\n\n /**\n * Hook to 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)\n * @param property - Property key to subscribe to\n * @returns The current property value (or undefined) and update callback\n */\n <T, K extends keyof T>(ref: Ref.Ref<T> | undefined, property: K): [T[K] | undefined, ObjectPropUpdateCallback<T[K]>];\n} = (<T extends Obj.Unknown, K extends keyof T>(objOrRef: T | Ref.Ref<T> | undefined, property?: K): any => {\n // Get the live object for the callback (refs need to dereference).\n const isRef = Ref.isRef(objOrRef);\n const liveObj = isRef ? (objOrRef as Ref.Ref<T>)?.target : (objOrRef as T | undefined);\n\n const callback: ObjectPropUpdateCallback<unknown> = useCallback(\n (updateOrValue: unknown | ((obj: unknown) => unknown)) => {\n // Get current target for refs (may have loaded since render).\n const obj = isRef ? (objOrRef as Ref.Ref<T>)?.target : liveObj;\n if (obj === undefined) {\n return;\n }\n Obj.update(obj, (obj: any) => {\n if (typeof updateOrValue === 'function') {\n const returnValue = updateOrValue(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 [objOrRef, property, isRef, liveObj],\n );\n\n if (property !== undefined) {\n // For refs, subscribe to load event only (not full mutation tracking).\n // Property-level updates are handled by useObjectProperty once the ref loads.\n useRefLoad(objOrRef);\n return [useObjectProperty(liveObj, property as any), callback];\n } else {\n return [useObjectValue(objOrRef), callback];\n }\n}) as any;\n\n/**\n * Internal hook for subscribing to an Echo object or Ref.\n */\nconst useObjectValue = <T extends Obj.Unknown>(objOrRef: T | Ref.Ref<T> | undefined): Obj.Snapshot<T> | undefined => {\n const atom = useMemo(() => {\n if (objOrRef == null) {\n return Atom.make<Obj.Snapshot<T> | undefined>(() => undefined);\n }\n if (Ref.isRef(objOrRef)) {\n return Obj.atom(objOrRef);\n }\n return Obj.atom(objOrRef);\n }, [objOrRef]);\n return useAtomValue(atom) as Obj.Snapshot<T> | undefined;\n};\n\n/**\n * Internal hook for subscribing to ref resolution only (load-once).\n * Triggers a re-render when the ref target first becomes available,\n * without subscribing to subsequent target mutations.\n * For non-refs, this is a no-op.\n */\nconst useRefLoad = <T extends Obj.Unknown>(objOrRef: T | Ref.Ref<T> | undefined): void => {\n const atom = useMemo(() => {\n if (objOrRef == null || !Ref.isRef(objOrRef)) {\n return Atom.make<T | undefined>(() => undefined);\n }\n return objOrRef.atom;\n }, [objOrRef]);\n useAtomValue(atom);\n};\n\n/**\n * Internal hook for subscribing to a specific property of an Echo object.\n */\nconst useObjectProperty = <T extends Obj.Unknown, K extends keyof T>(\n obj: T | undefined,\n property: K,\n): T[K] | undefined => {\n const atom = useMemo(() => {\n if (obj == null) {\n return Atom.make<T[K] | undefined>(() => undefined);\n }\n return Obj.atomProperty(obj, property);\n }, [obj, property]);\n return useAtomValue(atom);\n};\n\n/**\n * Hook to subscribe to multiple Refs' target objects.\n * Automatically dereferences each ref and handles async loading.\n * Returns 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 * @deprecated Subscribes the component to the whole list, re-rendering on any element's change. Prefer pushing\n * the subscription down — derive the aggregate in an atom (reading each `Obj.atom(ref)`) and read it where it is\n * needed, or subscribe to the individual ref/property closest to the consumer — to keep subscriptions granular.\n *\n * @param refs - Array of Refs to dereference and subscribe to\n * @returns Array of loaded target snapshots (excludes unloaded refs)\n */\nexport const useObjects = <T extends Obj.Unknown>(refs: readonly Ref.Ref<T>[]): Obj.Snapshot<T>[] => {\n const atom = useMemo(\n () =>\n Atom.make((get) => {\n const results: Obj.Snapshot<T>[] = [];\n for (const ref of refs) {\n const value = get(Obj.atom(ref));\n if (value !== undefined) {\n results.push(value as Obj.Snapshot<T>);\n }\n }\n return results;\n }),\n [refs],\n );\n return useAtomValue(atom);\n};\n"],
|
|
5
|
+
"mappings": ";AAIA,SAASA,SAASC,4BAA4B;AAE9C,SAAqCC,QAAQC,aAAa;AAE1D,IAAMC,cAAuB,CAAA;AAE7B,IAAMC,OAAO,MAAA;AAAO;AAmBb,IAAMC,WAAuB,CAClCC,UACAC,kBAAAA;AAEA,QAAMC,QAAQP,OAAOQ,GAAGF,aAAAA,IAAiBL,MAAMQ,OAAOH,aAAAA,IAAiBA;AAEvE,QAAM,EAAEI,YAAYC,UAAS,IAAKb,QAAQ,MAAA;AACxC,QAAIc,cAAcC;AAClB,QAAIR,UAAU;AACZO,oBAAcP,SAASE,MAAMA,KAAAA;IAC/B;AAEA,QAAIO,aAAa;AACjB,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A;AACT,UAAMC,UAA6B,CAAA;AACnC,eAAWC,OAAOH,MAAM;AACtB,YAAMI,QAAQH,IAAIvB,IAAIkB,KAAKO,GAAAA,CAAAA;AAC3B,UAAIC,UAAUf,QAAW;AACvBa,gBAAQG,KAAKD,KAAAA;MACf;IACF;AACA,WAAOF;EACT,CAAA,GACF;IAACF;GAAK;AAER,SAAO1B,aAAasB,IAAAA;AACtB;",
|
|
6
6
|
"names": ["useMemo", "useSyncExternalStore", "Filter", "Query", "EMPTY_ARRAY", "noop", "useQuery", "resource", "queryOrFilter", "query", "is", "select", "getObjects", "subscribe", "queryResult", "undefined", "subscribed", "results", "cb", "unsubscribe", "JSON", "stringify", "ast", "objects", "useMemo", "useSyncExternalStore", "DXN", "EID", "Filter", "Query", "Scope", "Type", "useType", "db", "typeUri", "subscribe", "getType", "undefined", "searchEid", "isEID", "tryParse", "searchDxn", "isDXN", "tryMake", "queryResult", "query", "select", "type", "from", "space", "registry", "subscribed", "find", "results", "uri", "getURI", "typeEid", "getEntityId", "typeDxn", "getName", "onStoreChange", "unsubscribe", "useAtomValue", "Atom", "useCallback", "useMemo", "Obj", "Ref", "useObject", "objOrRef", "property", "isRef", "liveObj", "target", "callback", "updateOrValue", "obj", "undefined", "update", "returnValue", "Error", "useRefLoad", "useObjectProperty", "useObjectValue", "atom", "make", "atomProperty", "useObjects", "refs", "get", "results", "ref", "value", "push"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/useQuery.ts":{"bytes":5393,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true}],"format":"esm"},"src/useType.ts":{"bytes":8807,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true}],"format":"esm"},"src/useObject.ts":{"bytes":
|
|
1
|
+
{"inputs":{"src/useQuery.ts":{"bytes":5393,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true}],"format":"esm"},"src/useType.ts":{"bytes":8807,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true}],"format":"esm"},"src/useObject.ts":{"bytes":21031,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"@effect-atom/atom/Atom","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":552,"imports":[{"path":"src/useQuery.ts","kind":"import-statement","original":"./useQuery"},{"path":"src/useType.ts","kind":"import-statement","original":"./useType"},{"path":"src/useObject.ts","kind":"import-statement","original":"./useObject"}],"format":"esm"}},"outputs":{"dist/lib/neutral/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":19633},"dist/lib/neutral/index.mjs":{"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"@effect-atom/atom/Atom","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true}],"exports":["useObject","useObjects","useQuery","useType"],"entryPoint":"src/index.ts","inputs":{"src/useQuery.ts":{"bytesInOutput":921},"src/index.ts":{"bytesInOutput":0},"src/useType.ts":{"bytesInOutput":1686},"src/useObject.ts":{"bytesInOutput":2437}},"bytes":5199}}}
|
|
@@ -13,9 +13,16 @@ export declare const useObject: {
|
|
|
13
13
|
* Hook to subscribe to a Ref's target object.
|
|
14
14
|
* Automatically dereferences the ref and handles async loading.
|
|
15
15
|
* Returns a snapshot (undefined if the ref hasn't loaded yet).
|
|
16
|
+
* Re-renders the component when the ref resolves or the target object changes.
|
|
16
17
|
*
|
|
17
18
|
* @param ref - The Ref to dereference and subscribe to
|
|
18
19
|
* @returns The current target snapshot (or undefined if not loaded) and update callback
|
|
20
|
+
*
|
|
21
|
+
* @idiom org.dxos.echo-react.useObjectReactive
|
|
22
|
+
* applies: Reading a ref's target (or a specific property) inside a React component — establishes a reactive subscription so the component re-renders when the ref resolves or the value changes
|
|
23
|
+
* instead-of: `ref.target` — synchronous and not reactive; returns `undefined` when the target isn't loaded yet and never triggers a re-render when it becomes available
|
|
24
|
+
* uses: {@link useObject}
|
|
25
|
+
* related: org.dxos.echo.objAtomReactive, org.dxos.echo.refLoad
|
|
19
26
|
*/
|
|
20
27
|
<T extends Obj.Unknown>(ref: Ref.Ref<T>): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];
|
|
21
28
|
/**
|
|
@@ -50,7 +57,7 @@ export declare const useObject: {
|
|
|
50
57
|
* @param objOrRef - The Echo object or Ref to subscribe to
|
|
51
58
|
* @returns The current object snapshot (or undefined) and update callback
|
|
52
59
|
*/
|
|
53
|
-
<T extends Obj.Unknown>(objOrRef: T | Ref.Ref<T>): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];
|
|
60
|
+
<T extends Obj.Unknown>(objOrRef: T | Ref.Ref<T> | undefined): [Obj.Snapshot<T> | undefined, ObjectUpdateCallback<T>];
|
|
54
61
|
/**
|
|
55
62
|
* Hook to subscribe to a specific property of an Echo object.
|
|
56
63
|
* Returns the current property value and automatically re-renders when the property changes.
|
|
@@ -97,6 +104,10 @@ export declare const useObject: {
|
|
|
97
104
|
* This hook is useful for aggregate computations like counts or filtering
|
|
98
105
|
* across multiple refs without using .target directly.
|
|
99
106
|
*
|
|
107
|
+
* @deprecated Subscribes the component to the whole list, re-rendering on any element's change. Prefer pushing
|
|
108
|
+
* the subscription down — derive the aggregate in an atom (reading each `Obj.atom(ref)`) and read it where it is
|
|
109
|
+
* needed, or subscribe to the individual ref/property closest to the consumer — to keep subscriptions granular.
|
|
110
|
+
*
|
|
100
111
|
* @param refs - Array of Refs to dereference and subscribe to
|
|
101
112
|
* @returns Array of loaded target snapshots (excludes unloaded refs)
|
|
102
113
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useObject.d.ts","sourceRoot":"","sources":["../../../src/useObject.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,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,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,SAAS,EAAE;IACtB
|
|
1
|
+
{"version":3,"file":"useObject.d.ts","sourceRoot":"","sources":["../../../src/useObject.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,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,CA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AAE,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAyC9G,CAAC;AAkDV;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,GAAG,CAAC,OAAO,QAAQ,SAAS,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAgB9F,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Database, Type, URI } from '@dxos/echo';
|
|
2
2
|
/**
|
|
3
3
|
* Subscribe to and retrieve a type by its URI from a space: a static schema's typename DXN, or a
|
|
4
4
|
* persisted (database) schema's `echo:` EID (what `Type.getURI` / `getTypeURIFromQuery` produce).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useType.d.ts","sourceRoot":"","sources":["../../../src/useType.ts"],"names":[],"mappings":"AAMA,OAAO,
|
|
1
|
+
{"version":3,"file":"useType.d.ts","sourceRoot":"","sources":["../../../src/useType.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,QAAQ,EAAkC,IAAI,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,OAAO,GAAI,CAAC,SAAS,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,OAC1D,QAAQ,CAAC,QAAQ,YACZ,GAAG,CAAC,GAAG,KAChB,CAAC,GAAG,SAmDN,CAAC"}
|