@dxos/react-client 0.6.14-main.f49f251 → 0.6.14-staging.0f558a0
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/browser/{chunk-GSDDO2LE.mjs → chunk-U6WOCCWH.mjs} +9 -9
- package/dist/lib/browser/{chunk-GSDDO2LE.mjs.map → chunk-U6WOCCWH.mjs.map} +2 -2
- package/dist/lib/browser/devtools/index.mjs +1 -1
- package/dist/lib/browser/echo/index.mjs +1 -1
- package/dist/lib/browser/halo/index.mjs +1 -1
- package/dist/lib/browser/halo/index.mjs.map +2 -2
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/mesh/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +26 -11
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-WR4BVOQQ.cjs → chunk-BYDG3FH4.cjs} +12 -12
- package/dist/lib/node/{chunk-WR4BVOQQ.cjs.map → chunk-BYDG3FH4.cjs.map} +2 -2
- package/dist/lib/node/devtools/index.cjs +2 -2
- package/dist/lib/node/echo/index.cjs +3 -3
- package/dist/lib/node/halo/index.cjs +5 -5
- package/dist/lib/node/halo/index.cjs.map +2 -2
- package/dist/lib/node/index.cjs +12 -12
- package/dist/lib/node/mesh/index.cjs +2 -2
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +30 -14
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/lib/node-esm/{chunk-LPOLSASZ.mjs → chunk-E5UAY5Z4.mjs} +9 -9
- package/dist/lib/node-esm/{chunk-LPOLSASZ.mjs.map → chunk-E5UAY5Z4.mjs.map} +2 -2
- package/dist/lib/node-esm/devtools/index.mjs +1 -1
- package/dist/lib/node-esm/echo/index.mjs +1 -1
- package/dist/lib/node-esm/halo/index.mjs +1 -1
- package/dist/lib/node-esm/halo/index.mjs.map +2 -2
- package/dist/lib/node-esm/index.mjs +1 -1
- package/dist/lib/node-esm/mesh/index.mjs +1 -1
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +26 -11
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/client/ClientProvider.d.ts +0 -4
- package/dist/types/src/client/ClientProvider.d.ts.map +1 -1
- package/dist/types/src/halo/index.d.ts +1 -1
- package/dist/types/src/halo/index.d.ts.map +1 -1
- package/dist/types/src/testing/withClientProvider.d.ts +8 -3
- package/dist/types/src/testing/withClientProvider.d.ts.map +1 -1
- package/package.json +23 -23
- package/src/client/ClientProvider.tsx +1 -3
- package/src/halo/index.ts +1 -1
- package/src/testing/withClientProvider.tsx +35 -16
- package/tsconfig.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/testing/index.ts", "../../../../src/testing/ClientRepeater.tsx", "../../../../src/testing/withClientProvider.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2020 DXOS.org\n//\n\nexport * from '@dxos/client/testing';\n\nexport * from './ClientRepeater';\nexport * from './withClientProvider';\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { type Schema as S } from '@effect/schema';\nimport React, { useState, type FC, useEffect, useRef } from 'react';\n\nimport { Client, type PublicKey } from '@dxos/client';\nimport { TestBuilder, performInvitation } from '@dxos/client/testing';\nimport { registerSignalsRuntime } from '@dxos/echo-signals/react';\nimport { faker } from '@dxos/random';\n\nimport { type WithClientProviderProps } from './withClientProvider';\nimport { ClientProvider } from '../client';\n\nexport type ClientRepeatedComponentProps = { id: number; count: number; spaceKey?: PublicKey };\n\nexport type ClientRepeaterControlsProps = { clients: Client[] };\n\n// TODO(burdon): Reconcile with ClientProviderProps.\nexport type ClientRepeaterProps<P extends ClientRepeatedComponentProps> = {\n className?: string;\n component: FC<ClientRepeatedComponentProps>;\n controls?: FC<ClientRepeaterControlsProps>;\n count?: number;\n clients?: Client[];\n types?: S.Schema<any>[];\n args?: Omit<P, 'id' | 'count'>;\n} & Pick<WithClientProviderProps, 'createIdentity' | 'createSpace' | 'onSpaceCreated'>;\n\n/**\n * Utility component for Storybook stories which sets up clients for n peers.\n * The `Component` property is rendered n times, once for each peer.\n * @deprecated use `withClientProvider`.\n */\n// TODO(burdon): To discuss: evolve ClientRepeater with optional decorator that uses it.\n// NOTE: This is specifically not a storybook decorator because it broke stories as a decorator.\n// This seems primarily due to the fact that it required top-level await for the clients to initialize.\n// Storybook seemed to handle it alright, but Chromatic had a lot of trouble with it.\n// There was also a question of whether or not calling the story function multiple times was a good idea.\nexport const ClientRepeater = <P extends ClientRepeatedComponentProps>(props: ClientRepeaterProps<P>) => {\n const {\n component: Component,\n controls: Controls,\n count = 1,\n types,\n createIdentity,\n createSpace,\n onSpaceCreated,\n } = props;\n useEffect(() => {\n registerSignalsRuntime();\n }, []);\n\n const [clients, setClients] = useState(props.clients ?? []);\n const [spaceKey, setSpaceKey] = useState<PublicKey>();\n\n const testBuilder = useRef(new TestBuilder());\n useEffect(() => {\n const timeout = setTimeout(async () => {\n const clients = [...Array(count)].map(\n (_) => new Client({ services: testBuilder.current.createLocalClientServices(), types }),\n );\n\n await Promise.all(clients.map((client) => client.initialize()));\n if (createIdentity || createSpace) {\n await Promise.all(clients.map((client) => client.halo.createIdentity()));\n }\n\n if (createSpace) {\n const client = clients[0];\n const space = await client.spaces.create({ name: faker.commerce.productName() });\n setSpaceKey(space.key);\n await onSpaceCreated?.({ client, space });\n await Promise.all(\n clients.slice(1).flatMap((client) => performInvitation({ host: space, guest: client.spaces })),\n );\n }\n\n setClients(clients);\n });\n\n return () => clearTimeout(timeout);\n }, []);\n\n if (clients.length === 0) {\n return null;\n }\n\n return (\n <>\n {Controls && <Controls clients={clients} />}\n {clients.map((client, index) => (\n <ClientProvider key={index} client={client}>\n <Component id={index} count={clients.length} spaceKey={spaceKey} {...{ ...props.args }} />\n </ClientProvider>\n ))}\n </>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type Decorator } from '@storybook/react';\nimport React, { createContext, type PropsWithChildren, useContext, useEffect, useRef, useState } from 'react';\nimport { type FallbackProps, ErrorBoundary as NativeErrorBoundary } from 'react-error-boundary';\n\nimport { Trigger } from '@dxos/async';\nimport { type Client } from '@dxos/client';\nimport { type Space } from '@dxos/client/echo';\nimport { performInvitation, TestBuilder } from '@dxos/client/testing';\nimport { log } from '@dxos/log';\nimport { type MaybePromise } from '@dxos/util';\n\nimport { ClientProvider, type ClientProviderProps } from '../client';\n\ntype InitializeProps = {\n createIdentity?: boolean;\n createSpace?: boolean;\n onSpaceCreated?: (props: { client: Client; space: Space }) => MaybePromise<void>;\n};\n\n/**\n * Initialize client, identity and first space.\n */\nconst initializeClient = async (\n client: Client,\n {\n createIdentity,\n createSpace,\n onSpaceCreated,\n onInitialized,\n }: InitializeProps & Pick<WithClientProviderProps, 'onInitialized'>,\n): Promise<Space | undefined> => {\n if (createIdentity || createSpace) {\n if (!client.halo.identity.get()) {\n await client.halo.createIdentity();\n }\n }\n\n let space: Space | undefined;\n if (createSpace) {\n space = await client.spaces.create({ name: 'Test Space' });\n await onSpaceCreated?.({ client, space });\n }\n\n await onInitialized?.(client);\n return space;\n};\n\nexport type WithClientProviderProps = InitializeProps & ClientProviderProps;\n\n/**\n * Decorator that provides the client context.\n */\nexport const withClientProvider = ({\n createIdentity,\n createSpace,\n onSpaceCreated,\n onInitialized,\n ...props\n}: WithClientProviderProps = {}): Decorator => {\n return (Story) => {\n const handleInitialized = async (client: Client) => {\n await initializeClient(client, { createIdentity, createSpace, onSpaceCreated, onInitialized });\n };\n\n return (\n <ErrorBoundary>\n <ClientProvider onInitialized={handleInitialized} {...props}>\n <Story />\n </ClientProvider>\n </ErrorBoundary>\n );\n };\n};\n\n// TODO(burdon): Implement context per client for context.\n// TODO(burdon): Callback once all invitations have completed.\n// TODO(burdon): Delay/jitter for creation of other clients.\nexport type WithMultiClientProviderProps = InitializeProps & ClientProviderProps & { numClients?: number };\n\nconst MultiClientContext = createContext<{ id: number }>({ id: 0 });\n\nexport const useMultiClient = () => useContext(MultiClientContext);\n\n/**\n * Decorator that creates a scaffold for multiple clients.\n * Orchestrates invitations between a randomly selected host and the remaining clients.\n * NOTE: Should come before withLayout.\n */\nexport const withMultiClientProvider = ({\n numClients = 2,\n createIdentity,\n createSpace,\n onSpaceCreated,\n onInitialized,\n ...props\n}: WithMultiClientProviderProps): Decorator => {\n return (Story) => {\n const builder = useRef(new TestBuilder());\n const hostRef = useRef<Client>();\n const spaceReady = useRef(new Trigger<Space | undefined>());\n\n // Handle invitations.\n // NOTE: The zeroth client isn't necessarily the first to be initialized.\n const handleInitialized = async (client: Client, index: number) => {\n log.info('initialized', { index });\n if (createSpace) {\n if (!hostRef.current) {\n hostRef.current = client;\n const space = await initializeClient(client, { createIdentity, createSpace, onSpaceCreated, onInitialized });\n spaceReady.current.wake(space);\n log.info('inviting', { index });\n } else {\n await initializeClient(client, { createIdentity, onInitialized });\n const space = await spaceReady.current.wait();\n if (space) {\n log.info('joining', { index });\n await Promise.all(performInvitation({ host: space, guest: client.spaces }));\n }\n }\n }\n };\n\n return (\n <ErrorBoundary>\n {Array.from({ length: numClients }).map((_, index) => (\n <MultiClientContext.Provider key={index} value={{ id: index }}>\n <ClientProvider\n services={builder.current.createLocalClientServices()}\n onInitialized={(client) => handleInitialized(client, index)}\n {...props}\n >\n <Story />\n </ClientProvider>\n </MultiClientContext.Provider>\n ))}\n </ErrorBoundary>\n );\n };\n};\n\nconst ErrorBoundary = ({ children }: PropsWithChildren) => {\n const [error, setError] = useState<Error>();\n useEffect(() => {\n const handleError = (event: PromiseRejectionEvent) => {\n setError(event.reason);\n };\n\n window.addEventListener('unhandledrejection', handleError);\n return () => window.removeEventListener('unhandledrejection', handleError);\n }, []);\n\n if (error) {\n return <ErrorFallback error={error} resetErrorBoundary={() => setError(undefined)} />;\n }\n\n return <NativeErrorBoundary FallbackComponent={ErrorFallback}>{children}</NativeErrorBoundary>;\n};\n\nconst ErrorFallback = ({ error }: FallbackProps) => {\n const { name, message, stack } =\n error instanceof Error ? error : { name: 'Error', message: String(error), stack: undefined };\n return (\n <div role='alert' className='flex flex-col p-4 gap-4 overflow-auto'>\n <h1 className='text-xl text-red-500'>{name}</h1>\n <div className='text-lg'>{message}</div>\n {stack && <pre className='whitespace-pre-wrap text-sm text-subdued'>{stack}</pre>}\n </div>\n );\n};\n"],
|
|
5
|
-
"mappings": ";;;;;AAIA,cAAc;;;ACCd,OAAOA,SAASC,UAAmBC,WAAWC,cAAc;AAE5D,SAASC,cAA8B;AACvC,SAASC,aAAaC,yBAAyB;AAC/C,SAASC,8BAA8B;AACvC,SAASC,aAAa;AA8Bf,IAAMC,iBAAiB,CAAyCC,UAAAA;AACrE,QAAM,EACJC,WAAWC,WACXC,UAAUC,UACVC,QAAQ,GACRC,OACAC,gBACAC,aACAC,eAAc,IACZT;AACJU,YAAU,MAAA;AACRC,2BAAAA;EACF,GAAG,CAAA,CAAE;AAEL,QAAM,CAACC,SAASC,UAAAA,IAAcC,SAASd,MAAMY,WAAW,CAAA,CAAE;AAC1D,QAAM,CAACG,UAAUC,WAAAA,IAAeF,SAAAA;AAEhC,QAAMG,cAAcC,OAAO,IAAIC,YAAAA,CAAAA;AAC/BT,YAAU,MAAA;AACR,UAAMU,UAAUC,WAAW,YAAA;AACzB,YAAMT,WAAU;WAAIU,MAAMjB,KAAAA;QAAQkB,IAChC,CAACC,MAAM,IAAIC,OAAO;QAAEC,UAAUT,YAAYU,QAAQC,0BAAyB;QAAItB;MAAM,CAAA,CAAA;AAGvF,YAAMuB,QAAQC,IAAIlB,SAAQW,IAAI,CAACQ,WAAWA,OAAOC,WAAU,CAAA,CAAA;AAC3D,UAAIzB,kBAAkBC,aAAa;AACjC,cAAMqB,QAAQC,IAAIlB,SAAQW,IAAI,CAACQ,WAAWA,OAAOE,KAAK1B,eAAc,CAAA,CAAA;MACtE;AAEA,UAAIC,aAAa;AACf,cAAMuB,SAASnB,SAAQ,CAAA;AACvB,cAAMsB,QAAQ,MAAMH,OAAOI,OAAOC,OAAO;UAAEC,MAAMC,MAAMC,SAASC,YAAW;QAAG,CAAA;AAC9ExB,oBAAYkB,MAAMO,GAAG;AACrB,cAAMhC,iBAAiB;UAAEsB;UAAQG;QAAM,CAAA;AACvC,cAAML,QAAQC,IACZlB,SAAQ8B,MAAM,CAAA,EAAGC,QAAQ,CAACZ,YAAWa,kBAAkB;UAAEC,MAAMX;UAAOY,OAAOf,QAAOI;QAAO,CAAA,CAAA,CAAA;MAE/F;AAEAtB,iBAAWD,QAAAA;IACb,CAAA;AAEA,WAAO,MAAMmC,aAAa3B,OAAAA;EAC5B,GAAG,CAAA,CAAE;AAEL,MAAIR,QAAQoC,WAAW,GAAG;AACxB,WAAO;EACT;AAEA,SACE,sBAAA,cAAA,MAAA,UAAA,MACG5C,YAAY,sBAAA,cAACA,UAAAA;IAASQ;MACtBA,QAAQW,IAAI,CAACQ,QAAQkB,UACpB,sBAAA,cAACC,gBAAAA;IAAeT,KAAKQ;IAAOlB;KAC1B,sBAAA,cAAC7B,WAAAA;IAAUiD,IAAIF;IAAO5C,OAAOO,QAAQoC;IAAQjC;IAA0B,GAAGf,MAAMoD;;AAK1F;;;AC9FA,OAAOC,UAASC,eAAuCC,YAAYC,aAAAA,YAAWC,UAAAA,SAAQC,YAAAA,iBAAgB;AACtG,SAA6BC,iBAAiBC,2BAA2B;AAEzE,SAASC,eAAe;AAGxB,SAASC,qBAAAA,oBAAmBC,eAAAA,oBAAmB;AAC/C,SAASC,WAAW;;
|
|
6
|
-
"names": ["React", "useState", "useEffect", "useRef", "Client", "TestBuilder", "performInvitation", "registerSignalsRuntime", "faker", "ClientRepeater", "props", "component", "Component", "controls", "Controls", "count", "types", "createIdentity", "createSpace", "onSpaceCreated", "useEffect", "registerSignalsRuntime", "clients", "setClients", "useState", "spaceKey", "setSpaceKey", "testBuilder", "useRef", "TestBuilder", "timeout", "setTimeout", "Array", "map", "_", "Client", "services", "current", "createLocalClientServices", "Promise", "all", "client", "initialize", "halo", "space", "spaces", "create", "name", "faker", "commerce", "productName", "key", "slice", "flatMap", "performInvitation", "host", "guest", "clearTimeout", "length", "index", "ClientProvider", "id", "args", "React", "createContext", "useContext", "useEffect", "useRef", "useState", "ErrorBoundary", "NativeErrorBoundary", "Trigger", "performInvitation", "TestBuilder", "log", "initializeClient", "client", "createIdentity", "createSpace", "onSpaceCreated", "onInitialized", "halo", "identity", "get", "space", "spaces", "create", "name", "withClientProvider", "props", "Story", "handleInitialized", "React", "ErrorBoundary", "ClientProvider", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2020 DXOS.org\n//\n\nexport * from '@dxos/client/testing';\n\nexport * from './ClientRepeater';\nexport * from './withClientProvider';\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { type Schema as S } from '@effect/schema';\nimport React, { useState, type FC, useEffect, useRef } from 'react';\n\nimport { Client, type PublicKey } from '@dxos/client';\nimport { TestBuilder, performInvitation } from '@dxos/client/testing';\nimport { registerSignalsRuntime } from '@dxos/echo-signals/react';\nimport { faker } from '@dxos/random';\n\nimport { type WithClientProviderProps } from './withClientProvider';\nimport { ClientProvider } from '../client';\n\nexport type ClientRepeatedComponentProps = { id: number; count: number; spaceKey?: PublicKey };\n\nexport type ClientRepeaterControlsProps = { clients: Client[] };\n\n// TODO(burdon): Reconcile with ClientProviderProps.\nexport type ClientRepeaterProps<P extends ClientRepeatedComponentProps> = {\n className?: string;\n component: FC<ClientRepeatedComponentProps>;\n controls?: FC<ClientRepeaterControlsProps>;\n count?: number;\n clients?: Client[];\n types?: S.Schema<any>[];\n args?: Omit<P, 'id' | 'count'>;\n} & Pick<WithClientProviderProps, 'createIdentity' | 'createSpace' | 'onSpaceCreated'>;\n\n/**\n * Utility component for Storybook stories which sets up clients for n peers.\n * The `Component` property is rendered n times, once for each peer.\n * @deprecated use `withClientProvider`.\n */\n// TODO(burdon): To discuss: evolve ClientRepeater with optional decorator that uses it.\n// NOTE: This is specifically not a storybook decorator because it broke stories as a decorator.\n// This seems primarily due to the fact that it required top-level await for the clients to initialize.\n// Storybook seemed to handle it alright, but Chromatic had a lot of trouble with it.\n// There was also a question of whether or not calling the story function multiple times was a good idea.\nexport const ClientRepeater = <P extends ClientRepeatedComponentProps>(props: ClientRepeaterProps<P>) => {\n const {\n component: Component,\n controls: Controls,\n count = 1,\n types,\n createIdentity,\n createSpace,\n onSpaceCreated,\n } = props;\n useEffect(() => {\n registerSignalsRuntime();\n }, []);\n\n const [clients, setClients] = useState(props.clients ?? []);\n const [spaceKey, setSpaceKey] = useState<PublicKey>();\n\n const testBuilder = useRef(new TestBuilder());\n useEffect(() => {\n const timeout = setTimeout(async () => {\n const clients = [...Array(count)].map(\n (_) => new Client({ services: testBuilder.current.createLocalClientServices(), types }),\n );\n\n await Promise.all(clients.map((client) => client.initialize()));\n if (createIdentity || createSpace) {\n await Promise.all(clients.map((client) => client.halo.createIdentity()));\n }\n\n if (createSpace) {\n const client = clients[0];\n const space = await client.spaces.create({ name: faker.commerce.productName() });\n setSpaceKey(space.key);\n await onSpaceCreated?.({ client, space });\n await Promise.all(\n clients.slice(1).flatMap((client) => performInvitation({ host: space, guest: client.spaces })),\n );\n }\n\n setClients(clients);\n });\n\n return () => clearTimeout(timeout);\n }, []);\n\n if (clients.length === 0) {\n return null;\n }\n\n return (\n <>\n {Controls && <Controls clients={clients} />}\n {clients.map((client, index) => (\n <ClientProvider key={index} client={client}>\n <Component id={index} count={clients.length} spaceKey={spaceKey} {...{ ...props.args }} />\n </ClientProvider>\n ))}\n </>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type Decorator } from '@storybook/react';\nimport React, { createContext, type PropsWithChildren, useContext, useEffect, useRef, useState } from 'react';\nimport { type FallbackProps, ErrorBoundary as NativeErrorBoundary } from 'react-error-boundary';\n\nimport { Trigger } from '@dxos/async';\nimport { type Client } from '@dxos/client';\nimport { type Space } from '@dxos/client/echo';\nimport { performInvitation, TestBuilder } from '@dxos/client/testing';\nimport { raise } from '@dxos/debug';\nimport { log } from '@dxos/log';\nimport { type MaybePromise } from '@dxos/util';\n\nimport { ClientProvider, type ClientProviderProps } from '../client';\n\ntype InitializeProps = {\n createIdentity?: boolean;\n createSpace?: boolean;\n onInitialized?: (client: Client) => MaybePromise<Record<string, any> | void>;\n onSpaceCreated?: (props: { client: Client; space: Space }) => MaybePromise<Record<string, any> | void>;\n};\n\n/**\n * Initialize client, identity and first space.\n */\nconst initializeClient = async (\n client: Client,\n { createIdentity, createSpace, onSpaceCreated, onInitialized }: InitializeProps,\n): Promise<StoryClientProps> => {\n const clientData = await onInitialized?.(client);\n\n if (createIdentity || createSpace) {\n if (!client.halo.identity.get()) {\n await client.halo.createIdentity();\n }\n }\n\n let space: Space | undefined;\n let spaceData: Record<string, any> | void = {};\n if (createSpace) {\n space = await client.spaces.create({ name: 'Test Space' });\n spaceData = await onSpaceCreated?.({ client, space });\n }\n\n return { space, ...clientData, ...spaceData };\n};\n\ntype StoryClientProps<T extends Record<string, any> = Record<string, unknown>> = T & { space?: Space };\n\n// TODO(wittjosiah): Add to multi-client as well.\nconst StoryClientContext = createContext<StoryClientProps | undefined>(undefined);\n\nexport const useStoryClientData = <T extends Record<string, any> = Record<string, unknown>>() => {\n const data = useContext(StoryClientContext) ?? raise(new Error('Missing withClientProvider decorator.'));\n return data as StoryClientProps<T>;\n};\n\nexport type WithClientProviderProps = InitializeProps & Omit<ClientProviderProps, 'onInitialized'>;\n\n/**\n * Decorator that provides the client context.\n */\nexport const withClientProvider = ({\n createIdentity,\n createSpace,\n onSpaceCreated,\n onInitialized,\n ...props\n}: WithClientProviderProps = {}): Decorator => {\n return (Story) => {\n const [data, setData] = useState<StoryClientProps>({});\n\n const handleInitialized = async (client: Client) => {\n setData(await initializeClient(client, { createIdentity, createSpace, onSpaceCreated, onInitialized }));\n };\n\n return (\n <ErrorBoundary>\n <ClientProvider onInitialized={handleInitialized} {...props}>\n <StoryClientContext.Provider value={data}>\n <Story />\n </StoryClientContext.Provider>\n </ClientProvider>\n </ErrorBoundary>\n );\n };\n};\n\n// TODO(burdon): Implement context per client for context.\n// TODO(burdon): Callback once all invitations have completed.\n// TODO(burdon): Delay/jitter for creation of other clients.\nexport type WithMultiClientProviderProps = InitializeProps &\n Omit<ClientProviderProps, 'onInitialized'> & { numClients?: number };\n\nconst MultiClientContext = createContext<{ id: number }>({ id: 0 });\n\nexport const useMultiClient = () => useContext(MultiClientContext);\n\n/**\n * Decorator that creates a scaffold for multiple clients.\n * Orchestrates invitations between a randomly selected host and the remaining clients.\n * NOTE: Should come before withLayout.\n */\nexport const withMultiClientProvider = ({\n numClients = 2,\n createIdentity,\n createSpace,\n onSpaceCreated,\n onInitialized,\n ...props\n}: WithMultiClientProviderProps): Decorator => {\n return (Story) => {\n const builder = useRef(new TestBuilder());\n const hostRef = useRef<Client>();\n const spaceReady = useRef(new Trigger<Space | undefined>());\n\n // Handle invitations.\n // NOTE: The zeroth client isn't necessarily the first to be initialized.\n const handleInitialized = async (client: Client, index: number) => {\n log.info('initialized', { index });\n if (createSpace) {\n if (!hostRef.current) {\n hostRef.current = client;\n const { space } = await initializeClient(client, {\n createIdentity,\n createSpace,\n onSpaceCreated,\n onInitialized,\n });\n spaceReady.current.wake(space);\n log.info('inviting', { index });\n } else {\n await initializeClient(client, { createIdentity, onInitialized });\n const space = await spaceReady.current.wait();\n if (space) {\n log.info('joining', { index });\n await Promise.all(performInvitation({ host: space, guest: client.spaces }));\n }\n }\n }\n };\n\n return (\n <ErrorBoundary>\n {Array.from({ length: numClients }).map((_, index) => (\n <MultiClientContext.Provider key={index} value={{ id: index }}>\n <ClientProvider\n services={builder.current.createLocalClientServices()}\n onInitialized={(client) => handleInitialized(client, index)}\n {...props}\n >\n <Story />\n </ClientProvider>\n </MultiClientContext.Provider>\n ))}\n </ErrorBoundary>\n );\n };\n};\n\nconst ErrorBoundary = ({ children }: PropsWithChildren) => {\n const [error, setError] = useState<Error>();\n useEffect(() => {\n const handleError = (event: PromiseRejectionEvent) => {\n setError(event.reason);\n };\n\n window.addEventListener('unhandledrejection', handleError);\n return () => window.removeEventListener('unhandledrejection', handleError);\n }, []);\n\n if (error) {\n return <ErrorFallback error={error} resetErrorBoundary={() => setError(undefined)} />;\n }\n\n return <NativeErrorBoundary FallbackComponent={ErrorFallback}>{children}</NativeErrorBoundary>;\n};\n\nconst ErrorFallback = ({ error }: FallbackProps) => {\n const { name, message, stack } =\n error instanceof Error ? error : { name: 'Error', message: String(error), stack: undefined };\n return (\n <div role='alert' className='flex flex-col p-4 gap-4 overflow-auto'>\n <h1 className='text-xl text-red-500'>{name}</h1>\n <div className='text-lg'>{message}</div>\n {stack && <pre className='whitespace-pre-wrap text-sm text-subdued'>{stack}</pre>}\n </div>\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;AAIA,cAAc;;;ACCd,OAAOA,SAASC,UAAmBC,WAAWC,cAAc;AAE5D,SAASC,cAA8B;AACvC,SAASC,aAAaC,yBAAyB;AAC/C,SAASC,8BAA8B;AACvC,SAASC,aAAa;AA8Bf,IAAMC,iBAAiB,CAAyCC,UAAAA;AACrE,QAAM,EACJC,WAAWC,WACXC,UAAUC,UACVC,QAAQ,GACRC,OACAC,gBACAC,aACAC,eAAc,IACZT;AACJU,YAAU,MAAA;AACRC,2BAAAA;EACF,GAAG,CAAA,CAAE;AAEL,QAAM,CAACC,SAASC,UAAAA,IAAcC,SAASd,MAAMY,WAAW,CAAA,CAAE;AAC1D,QAAM,CAACG,UAAUC,WAAAA,IAAeF,SAAAA;AAEhC,QAAMG,cAAcC,OAAO,IAAIC,YAAAA,CAAAA;AAC/BT,YAAU,MAAA;AACR,UAAMU,UAAUC,WAAW,YAAA;AACzB,YAAMT,WAAU;WAAIU,MAAMjB,KAAAA;QAAQkB,IAChC,CAACC,MAAM,IAAIC,OAAO;QAAEC,UAAUT,YAAYU,QAAQC,0BAAyB;QAAItB;MAAM,CAAA,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|
+
"names": ["React", "useState", "useEffect", "useRef", "Client", "TestBuilder", "performInvitation", "registerSignalsRuntime", "faker", "ClientRepeater", "props", "component", "Component", "controls", "Controls", "count", "types", "createIdentity", "createSpace", "onSpaceCreated", "useEffect", "registerSignalsRuntime", "clients", "setClients", "useState", "spaceKey", "setSpaceKey", "testBuilder", "useRef", "TestBuilder", "timeout", "setTimeout", "Array", "map", "_", "Client", "services", "current", "createLocalClientServices", "Promise", "all", "client", "initialize", "halo", "space", "spaces", "create", "name", "faker", "commerce", "productName", "key", "slice", "flatMap", "performInvitation", "host", "guest", "clearTimeout", "length", "index", "ClientProvider", "id", "args", "React", "createContext", "useContext", "useEffect", "useRef", "useState", "ErrorBoundary", "NativeErrorBoundary", "Trigger", "performInvitation", "TestBuilder", "raise", "log", "initializeClient", "client", "createIdentity", "createSpace", "onSpaceCreated", "onInitialized", "clientData", "halo", "identity", "get", "space", "spaceData", "spaces", "create", "name", "StoryClientContext", "createContext", "undefined", "useStoryClientData", "data", "useContext", "raise", "Error", "withClientProvider", "props", "Story", "setData", "useState", "handleInitialized", "React", "ErrorBoundary", "ClientProvider", "Provider", "value", "MultiClientContext", "id", "useMultiClient", "withMultiClientProvider", "numClients", "builder", "useRef", "TestBuilder", "hostRef", "spaceReady", "Trigger", "index", "log", "info", "current", "wake", "wait", "Promise", "all", "performInvitation", "host", "guest", "Array", "from", "length", "map", "_", "key", "services", "createLocalClientServices", "children", "error", "setError", "useEffect", "handleError", "event", "reason", "window", "addEventListener", "removeEventListener", "ErrorFallback", "resetErrorBoundary", "NativeErrorBoundary", "FallbackComponent", "message", "stack", "String", "div", "role", "className", "h1", "pre"]
|
|
7
7
|
}
|
|
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_BYDG3FH4_exports = {};
|
|
30
|
+
__export(chunk_BYDG3FH4_exports, {
|
|
31
31
|
AgentHostingContext: () => AgentHostingContext,
|
|
32
32
|
AgentHostingProvider: () => AgentHostingProvider,
|
|
33
33
|
ClientContext: () => ClientContext,
|
|
@@ -40,7 +40,7 @@ __export(chunk_WR4BVOQQ_exports, {
|
|
|
40
40
|
useShellDisplay: () => useShellDisplay,
|
|
41
41
|
useStatus: () => useStatus
|
|
42
42
|
});
|
|
43
|
-
module.exports = __toCommonJS(
|
|
43
|
+
module.exports = __toCommonJS(chunk_BYDG3FH4_exports);
|
|
44
44
|
var import_react = __toESM(require("react"));
|
|
45
45
|
var import_client = require("@dxos/client");
|
|
46
46
|
var import_log = require("@dxos/log");
|
|
@@ -111,14 +111,14 @@ var ClientProvider = /* @__PURE__ */ (0, import_react2.forwardRef)(({ children,
|
|
|
111
111
|
await client3.initialize().catch(setError);
|
|
112
112
|
(0, import_log2.log)("client ready", void 0, {
|
|
113
113
|
F: __dxlog_file,
|
|
114
|
-
L:
|
|
114
|
+
L: 132,
|
|
115
115
|
S: void 0,
|
|
116
116
|
C: (f, a) => f(...a)
|
|
117
117
|
});
|
|
118
118
|
await onInitialized?.(client3);
|
|
119
119
|
(0, import_log2.log)("initialization complete", void 0, {
|
|
120
120
|
F: __dxlog_file,
|
|
121
|
-
L:
|
|
121
|
+
L: 134,
|
|
122
122
|
S: void 0,
|
|
123
123
|
C: (f, a) => f(...a)
|
|
124
124
|
});
|
|
@@ -139,7 +139,7 @@ var ClientProvider = /* @__PURE__ */ (0, import_react2.forwardRef)(({ children,
|
|
|
139
139
|
config
|
|
140
140
|
}, {
|
|
141
141
|
F: __dxlog_file,
|
|
142
|
-
L:
|
|
142
|
+
L: 153,
|
|
143
143
|
S: void 0,
|
|
144
144
|
C: (f, a) => f(...a)
|
|
145
145
|
});
|
|
@@ -148,7 +148,7 @@ var ClientProvider = /* @__PURE__ */ (0, import_react2.forwardRef)(({ children,
|
|
|
148
148
|
services
|
|
149
149
|
}, {
|
|
150
150
|
F: __dxlog_file,
|
|
151
|
-
L:
|
|
151
|
+
L: 155,
|
|
152
152
|
S: void 0,
|
|
153
153
|
C: (f, a) => f(...a)
|
|
154
154
|
});
|
|
@@ -159,7 +159,7 @@ var ClientProvider = /* @__PURE__ */ (0, import_react2.forwardRef)(({ children,
|
|
|
159
159
|
});
|
|
160
160
|
(0, import_log2.log)("created client", void 0, {
|
|
161
161
|
F: __dxlog_file,
|
|
162
|
-
L:
|
|
162
|
+
L: 157,
|
|
163
163
|
S: void 0,
|
|
164
164
|
C: (f, a) => f(...a)
|
|
165
165
|
});
|
|
@@ -169,7 +169,7 @@ var ClientProvider = /* @__PURE__ */ (0, import_react2.forwardRef)(({ children,
|
|
|
169
169
|
return () => {
|
|
170
170
|
(0, import_log2.log)("clean up", void 0, {
|
|
171
171
|
F: __dxlog_file,
|
|
172
|
-
L:
|
|
172
|
+
L: 163,
|
|
173
173
|
S: void 0,
|
|
174
174
|
C: (f, a) => f(...a)
|
|
175
175
|
});
|
|
@@ -177,13 +177,13 @@ var ClientProvider = /* @__PURE__ */ (0, import_react2.forwardRef)(({ children,
|
|
|
177
177
|
void client2?.destroy().then(() => {
|
|
178
178
|
(0, import_log2.log)("destroyed", void 0, {
|
|
179
179
|
F: __dxlog_file,
|
|
180
|
-
L:
|
|
180
|
+
L: 168,
|
|
181
181
|
S: void 0,
|
|
182
182
|
C: (f, a) => f(...a)
|
|
183
183
|
});
|
|
184
184
|
}).catch((err) => import_log2.log.catch(err, void 0, {
|
|
185
185
|
F: __dxlog_file,
|
|
186
|
-
L:
|
|
186
|
+
L: 170,
|
|
187
187
|
S: void 0,
|
|
188
188
|
C: (f, a) => f(...a)
|
|
189
189
|
}));
|
|
@@ -312,4 +312,4 @@ var makeClient = ({ config, halo }) => {
|
|
|
312
312
|
useShellDisplay,
|
|
313
313
|
useStatus
|
|
314
314
|
});
|
|
315
|
-
//# sourceMappingURL=chunk-
|
|
315
|
+
//# sourceMappingURL=chunk-BYDG3FH4.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/client/AgentHostingProvider.tsx", "../../../src/client/ClientProvider.tsx", "../../../src/client/context.ts", "../../../src/banner.ts", "../../../src/client/useClient.ts", "../../../src/client/useClientStatus.ts", "../../../src/client/useConfig.ts", "../../../src/client/useShell.ts", "../../../src/client/useStatus.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { createContext, type PropsWithChildren, useContext, useState } from 'react';\n\nimport { type AgentHostingProviderClient, AgentManagerClient, FakeAgentHostingProvider } from '@dxos/client';\nimport { type Halo } from '@dxos/client/halo';\nimport { type Config } from '@dxos/config';\nimport { log } from '@dxos/log';\n\nimport { useClient } from '../client';\n\nexport type AgentHostingProviderProps = { config: Config; halo: Halo };\n\nexport const AgentHostingContext = createContext<AgentHostingProviderClient | null>(null);\n\n/**\n * Experimental agent hosting provider.\n * @param props\n * @constructor\n * @deprecated\n */\nexport const AgentHostingProvider = (props: PropsWithChildren) => {\n const client = useClient();\n const [agentHostingProviderClient] = useState(makeClient(client));\n return (\n <AgentHostingContext.Provider value={agentHostingProviderClient}> {props.children}</AgentHostingContext.Provider>\n );\n};\n\nexport const useAgentHostingClient = () => {\n return useContext(AgentHostingContext);\n};\n\nconst makeClient = ({ config, halo }: AgentHostingProviderProps) => {\n const agentHostingConfig = config.get('runtime.services.agentHosting');\n if (!agentHostingConfig) {\n log('no agent hosting configured');\n return null;\n }\n\n // TODO(nf): Dynamically discover based on runtime config.\n let agentHostingProviderClient: AgentHostingProviderClient | null = null;\n switch (agentHostingConfig.type) {\n case 'LOCAL_TESTING': {\n log('using FakeAgentHostingProvider');\n return new FakeAgentHostingProvider();\n }\n\n case 'AGENTHOSTING_API': {\n agentHostingProviderClient = new AgentManagerClient(config, halo);\n if (agentHostingProviderClient.init()) {\n return agentHostingProviderClient;\n } else {\n // Not authorized or error initializing.\n return null;\n }\n }\n\n default: {\n log.error('Unknown agent hosting provider type: ' + agentHostingConfig.type);\n return null;\n }\n }\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport React, {\n type FunctionComponent,\n type PropsWithChildren,\n forwardRef,\n useEffect,\n useImperativeHandle,\n useState,\n} from 'react';\n\nimport { Client, type ClientOptions, type ClientServicesProvider, SystemStatus } from '@dxos/client';\nimport { type Config } from '@dxos/config';\nimport { registerSignalsRuntime } from '@dxos/echo-signals/react';\nimport { log } from '@dxos/log';\nimport { useControlledValue } from '@dxos/react-hooks';\nimport { getAsyncProviderValue, type MaybePromise, type Provider } from '@dxos/util';\n\nimport { ClientContext, type ClientContextProps } from './context';\nimport { printBanner } from '../banner';\n\n/**\n * Properties for the ClientProvider.\n */\nexport type ClientProviderProps = Omit<ClientOptions, 'config' | 'services'> &\n Pick<ClientContextProps, 'status'> &\n PropsWithChildren<{\n /**\n * Client object or async provider to enable to caller to do custom initialization.\n *\n * NOTE: For advanced use cases only.\n */\n client?: Client | Provider<Promise<Client>>;\n\n /**\n * Config object or async provider.\n *\n * NOTE: If a `client` is provided then `config` is ignored.\n */\n // TODO(burdon): Reconcile with ClientOptions.\n config?: Config | Provider<Promise<Config>>;\n\n /**\n * Callback to enable the caller to create a custom ClientServicesProvider.\n *\n * NOTE: If a `client` is provided then `services` is ignored.\n */\n // TODO(burdon): Reconcile with ClientOptions.\n services?: ClientServicesProvider | ((config?: Config) => MaybePromise<ClientServicesProvider>);\n\n /**\n * ReactNode to display until the client is available.\n */\n fallback?: FunctionComponent<Partial<ClientContextProps>>;\n\n /**\n * Enable (by default) registration of Preact signals runtime for reactive ECHO objects.\n * @see https://www.npmjs.com/package/@preact/signals-react\n */\n signalsRuntime?: boolean;\n\n /**\n * Skip the DXOS banner.\n */\n noBanner?: boolean;\n\n /**\n * Post initialization hook to enable to caller to do custom initialization.\n *\n * @param Client\n */\n onInitialized?: (client: Client) => MaybePromise<void>;\n }>;\n\n/**\n * Root component that provides the DXOS client instance to child components.\n * To be used with the `useClient` hook.\n */\nexport const ClientProvider = forwardRef<Client | undefined, ClientProviderProps>(\n (\n {\n children,\n config: configProvider,\n client: clientProvider,\n services: servicesProvider,\n status: controlledStatus,\n fallback: Fallback = () => null,\n signalsRuntime = true,\n noBanner,\n onInitialized,\n ...options\n },\n forwardedRef,\n ) => {\n useEffect(() => {\n // TODO(wittjosiah): Ideally this should be imported asynchronously because it is optional.\n // Unfortunately, async import seemed to break signals React instrumentation.\n signalsRuntime && registerSignalsRuntime();\n }, []);\n\n // The client is initialized asynchronously.\n // If an error occurs during initialization, it is caught and the state is set.\n // This allows the error to be thrown in the render method.\n // The assumption is that a client initialization error is fatal to the app.\n // This error will be caught by the nearest error boundary.\n const [error, setError] = useState();\n if (error) {\n throw error;\n }\n\n const [client, setClient] = useState(clientProvider instanceof Client ? clientProvider : undefined);\n\n // Provide external access.\n useImperativeHandle(forwardedRef, () => client, [client]);\n\n // Client status subscription.\n const [status, setStatus] = useControlledValue(controlledStatus);\n useEffect(() => {\n if (!client) {\n return;\n }\n\n const subscription = client.status.subscribe((status) => setStatus(status));\n return () => subscription.unsubscribe();\n }, [client]);\n\n // Create and/or initialize client.\n useEffect(() => {\n const initialize = async (client: Client) => {\n if (!client.initialized) {\n await client.initialize().catch(setError);\n log('client ready');\n await onInitialized?.(client);\n log('initialization complete');\n }\n\n setClient(client);\n\n if (!noBanner) {\n printBanner(client);\n }\n };\n\n let client: Client;\n const t = setTimeout(async () => {\n if (clientProvider) {\n // Asynchronously request client.\n client = await getAsyncProviderValue(clientProvider);\n await initialize(client);\n } else {\n // Asynchronously construct client (config may be undefined).\n const config = await getAsyncProviderValue(configProvider);\n log('resolved config', { config });\n const services = await getAsyncProviderValue(servicesProvider, config);\n log('created services', { services });\n client = new Client({ config, services, ...options });\n log('created client');\n await initialize(client);\n }\n });\n\n return () => {\n log('clean up');\n clearTimeout(t);\n void client\n ?.destroy()\n .then(() => {\n log('destroyed');\n })\n .catch((err) => log.catch(err));\n };\n }, [configProvider, clientProvider, servicesProvider, noBanner]);\n\n if (!client?.initialized || status !== SystemStatus.ACTIVE) {\n return <Fallback client={client} status={status} />;\n }\n\n return <ClientContext.Provider value={{ client, status }}>{children}</ClientContext.Provider>;\n },\n);\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { type Context, createContext } from 'react';\n\nimport { type Client, type SystemStatus } from '@dxos/client';\n\nexport type ClientContextProps = {\n client: Client;\n status?: SystemStatus | null;\n};\n\n/**\n * @internal Use ClientProvider to create or initialize the Client.\n */\nexport const ClientContext: Context<ClientContextProps | undefined> = createContext<ClientContextProps | undefined>(\n undefined,\n);\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport { type Client } from '@dxos/client';\n\n// http://patorjk.com/software/taag/#p=testall&f=Patorjk-HeX&t=DXOS\nconst BANNER = (client: Client) => {\n const commitHash = client.config.get('runtime.app.build.commitHash');\n const hash = commitHash ? ` App Commit ${commitHash} \\n` : '';\n\n return (\n '\\n' +\n '_/\\\\/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\______/\\\\/\\\\/\\\\/\\\\/\\\\_\\n' +\n '_/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\__/\\\\/\\\\_________\\n' +\n '_/\\\\/\\\\____/\\\\/\\\\______/\\\\/\\\\______/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\___\\n' +\n '_/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\__________/\\\\/\\\\_\\n' +\n '_/\\\\/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\/\\\\___\\n' +\n `\\n DXOS Client ${client.version} \\n${hash}`\n );\n};\n\nlet bannerPrinted = false;\n\nexport const printBanner = (client: Client) => {\n if (bannerPrinted) {\n return;\n }\n\n bannerPrinted = true;\n // eslint-disable-next-line no-console\n console.log(`%c${BANNER(client)}`, 'font-family: monospace;');\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { ClientContext } from '../client/context';\n\n/**\n * Hook returning instance of DXOS client.\n * Requires ClientContext to be set via ClientProvider.\n */\nexport const useClient = () => {\n const { client } = useContext(ClientContext) ?? raise(new Error('Missing ClientContext.'));\n return client;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { useEffect, useState } from 'react';\n\nimport { type Client, type SystemStatus } from '@dxos/client';\n\nexport const useClientStatus = (client: Client) => {\n const [status, setStatus] = useState<SystemStatus | null>();\n useEffect(() => {\n if (!client) {\n return;\n }\n\n const subscription = client.status.subscribe((status) => setStatus(status));\n return () => subscription.unsubscribe();\n }, [client, setStatus]);\n\n return status;\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { ClientContext } from './context';\n\n/**\n * Hook returning config object used to initialize the DXOS client instance.\n * Requires ClientContext to be set via ClientProvider.\n */\nexport const useConfig = () => {\n const { client } = useContext(ClientContext) ?? raise(new Error('Missing ClientContext.'));\n return client.config;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { useEffect, useState } from 'react';\n\nimport { type Shell, type ShellDisplay } from '@dxos/client';\n\nimport { useClient } from './useClient';\n\n/**\n * Helper hook to access the shell.\n */\nexport const useShell = (): Shell => {\n const client = useClient();\n return client.shell;\n};\n\n/**\n * Hook to access the shell’s display state.\n */\nexport const useShellDisplay = (): ShellDisplay => {\n const client = useClient();\n const [display, setDisplay] = useState(client.shell.display);\n useEffect(() => client.shell.onDisplayChange(setDisplay), [client]);\n return display;\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { useContext } from 'react';\n\nimport { type SystemStatus } from '@dxos/client';\nimport { raise } from '@dxos/debug';\n\nimport { ClientContext } from './context';\n\nexport const useStatus = (): SystemStatus | null | undefined => {\n const { status } = useContext(ClientContext) ?? raise(new Error('Missing ClientContext.'));\n return status;\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mBAAmF;AAEnF,oBAA8F;AAG9F,iBAAoB;ACLpB,IAAAA,gBAOO;AAEP,IAAAC,iBAAsF;AAEtF,IAAAD,gBAAuC;AACvC,IAAAE,cAAoB;AACpB,yBAAmC;AACnC,kBAAwE;ACdxE,IAAAF,gBAA4C;AEA5C,IAAAA,gBAA2B;AAE3B,mBAAsB;ACFtB,IAAAA,gBAAoC;ACApC,IAAAA,gBAA2B;AAE3B,IAAAG,gBAAsB;ACFtB,IAAAH,gBAAoC;ACApC,IAAAA,gBAA2B;AAG3B,IAAAG,gBAAsB;ANSf,IAAMC,oBAAyDC,6BACpEC,MAAAA;ACVF,IAAMC,SAAS,CAACC,WAAAA;AACd,QAAMC,aAAaD,OAAOE,OAAOC,IAAI,8BAAA;AACrC,QAAMC,OAAOH,aAAa,eAAeA,UAAAA;IAAkB;AAE3D,SACE;;;;;;;eAMkBD,OAAOK,OAAO;EAAMD,IAAAA;AAE1C;AAEA,IAAIE,gBAAgB;AAEb,IAAMC,cAAc,CAACP,WAAAA;AAC1B,MAAIM,eAAe;AACjB;EACF;AAEAA,kBAAgB;AAEhBE,UAAQC,IAAI,KAAKV,OAAOC,MAAAA,CAAAA,IAAW,yBAAA;AACrC;;
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { createContext, type PropsWithChildren, useContext, useState } from 'react';\n\nimport { type AgentHostingProviderClient, AgentManagerClient, FakeAgentHostingProvider } from '@dxos/client';\nimport { type Halo } from '@dxos/client/halo';\nimport { type Config } from '@dxos/config';\nimport { log } from '@dxos/log';\n\nimport { useClient } from '../client';\n\nexport type AgentHostingProviderProps = { config: Config; halo: Halo };\n\nexport const AgentHostingContext = createContext<AgentHostingProviderClient | null>(null);\n\n/**\n * Experimental agent hosting provider.\n * @param props\n * @constructor\n * @deprecated\n */\nexport const AgentHostingProvider = (props: PropsWithChildren) => {\n const client = useClient();\n const [agentHostingProviderClient] = useState(makeClient(client));\n return (\n <AgentHostingContext.Provider value={agentHostingProviderClient}> {props.children}</AgentHostingContext.Provider>\n );\n};\n\nexport const useAgentHostingClient = () => {\n return useContext(AgentHostingContext);\n};\n\nconst makeClient = ({ config, halo }: AgentHostingProviderProps) => {\n const agentHostingConfig = config.get('runtime.services.agentHosting');\n if (!agentHostingConfig) {\n log('no agent hosting configured');\n return null;\n }\n\n // TODO(nf): Dynamically discover based on runtime config.\n let agentHostingProviderClient: AgentHostingProviderClient | null = null;\n switch (agentHostingConfig.type) {\n case 'LOCAL_TESTING': {\n log('using FakeAgentHostingProvider');\n return new FakeAgentHostingProvider();\n }\n\n case 'AGENTHOSTING_API': {\n agentHostingProviderClient = new AgentManagerClient(config, halo);\n if (agentHostingProviderClient.init()) {\n return agentHostingProviderClient;\n } else {\n // Not authorized or error initializing.\n return null;\n }\n }\n\n default: {\n log.error('Unknown agent hosting provider type: ' + agentHostingConfig.type);\n return null;\n }\n }\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport React, {\n forwardRef,\n type FunctionComponent,\n type PropsWithChildren,\n useEffect,\n useImperativeHandle,\n useState,\n} from 'react';\n\nimport { Client, type ClientOptions, type ClientServicesProvider, SystemStatus } from '@dxos/client';\nimport { type Config } from '@dxos/config';\nimport { registerSignalsRuntime } from '@dxos/echo-signals/react';\nimport { log } from '@dxos/log';\nimport { useControlledValue } from '@dxos/react-hooks';\nimport { getAsyncProviderValue, type MaybePromise, type Provider } from '@dxos/util';\n\nimport { ClientContext, type ClientContextProps } from './context';\nimport { printBanner } from '../banner';\n\n/**\n * Properties for the ClientProvider.\n */\nexport type ClientProviderProps = Omit<ClientOptions, 'config' | 'services'> &\n Pick<ClientContextProps, 'status'> &\n PropsWithChildren<{\n /**\n * Client object or async provider to enable to caller to do custom initialization.\n *\n * NOTE: For advanced use cases only.\n */\n client?: Client | Provider<Promise<Client>>;\n\n /**\n * Config object or async provider.\n *\n * NOTE: If a `client` is provided then `config` is ignored.\n */\n // TODO(burdon): Reconcile with ClientOptions.\n config?: Config | Provider<Promise<Config>>;\n\n /**\n * Callback to enable the caller to create a custom ClientServicesProvider.\n *\n * NOTE: If a `client` is provided then `services` is ignored.\n */\n // TODO(burdon): Reconcile with ClientOptions.\n services?: ClientServicesProvider | ((config?: Config) => MaybePromise<ClientServicesProvider>);\n\n /**\n * ReactNode to display until the client is available.\n */\n fallback?: FunctionComponent<Partial<ClientContextProps>>;\n\n /**\n * Enable (by default) registration of Preact signals runtime for reactive ECHO objects.\n * @see https://www.npmjs.com/package/@preact/signals-react\n */\n signalsRuntime?: boolean;\n\n /**\n * Skip the DXOS banner.\n */\n noBanner?: boolean;\n\n /**\n * Post initialization hook to enable to caller to do custom initialization.\n */\n onInitialized?: (client: Client) => MaybePromise<void>;\n }>;\n\n/**\n * Root component that provides the DXOS client instance to child components.\n * To be used with the `useClient` hook.\n */\nexport const ClientProvider = forwardRef<Client | undefined, ClientProviderProps>(\n (\n {\n children,\n config: configProvider,\n client: clientProvider,\n services: servicesProvider,\n status: controlledStatus,\n fallback: Fallback = () => null,\n signalsRuntime = true,\n noBanner,\n onInitialized,\n ...options\n },\n forwardedRef,\n ) => {\n useEffect(() => {\n // TODO(wittjosiah): Ideally this should be imported asynchronously because it is optional.\n // Unfortunately, async import seemed to break signals React instrumentation.\n signalsRuntime && registerSignalsRuntime();\n }, []);\n\n // The client is initialized asynchronously.\n // If an error occurs during initialization, it is caught and the state is set.\n // This allows the error to be thrown in the render method.\n // The assumption is that a client initialization error is fatal to the app.\n // This error will be caught by the nearest error boundary.\n const [error, setError] = useState();\n if (error) {\n throw error;\n }\n\n const [client, setClient] = useState(clientProvider instanceof Client ? clientProvider : undefined);\n\n // Provide external access.\n useImperativeHandle(forwardedRef, () => client, [client]);\n\n // Client status subscription.\n const [status, setStatus] = useControlledValue(controlledStatus);\n useEffect(() => {\n if (!client) {\n return;\n }\n\n const subscription = client.status.subscribe((status) => setStatus(status));\n return () => subscription.unsubscribe();\n }, [client]);\n\n // Create and/or initialize client.\n useEffect(() => {\n const initialize = async (client: Client) => {\n if (!client.initialized) {\n await client.initialize().catch(setError);\n log('client ready');\n await onInitialized?.(client);\n log('initialization complete');\n }\n\n setClient(client);\n\n if (!noBanner) {\n printBanner(client);\n }\n };\n\n let client: Client;\n const t = setTimeout(async () => {\n if (clientProvider) {\n // Asynchronously request client.\n client = await getAsyncProviderValue(clientProvider);\n await initialize(client);\n } else {\n // Asynchronously construct client (config may be undefined).\n const config = await getAsyncProviderValue(configProvider);\n log('resolved config', { config });\n const services = await getAsyncProviderValue(servicesProvider, config);\n log('created services', { services });\n client = new Client({ config, services, ...options });\n log('created client');\n await initialize(client);\n }\n });\n\n return () => {\n log('clean up');\n clearTimeout(t);\n void client\n ?.destroy()\n .then(() => {\n log('destroyed');\n })\n .catch((err) => log.catch(err));\n };\n }, [configProvider, clientProvider, servicesProvider, noBanner]);\n\n if (!client?.initialized || status !== SystemStatus.ACTIVE) {\n return <Fallback client={client} status={status} />;\n }\n\n return <ClientContext.Provider value={{ client, status }}>{children}</ClientContext.Provider>;\n },\n);\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { type Context, createContext } from 'react';\n\nimport { type Client, type SystemStatus } from '@dxos/client';\n\nexport type ClientContextProps = {\n client: Client;\n status?: SystemStatus | null;\n};\n\n/**\n * @internal Use ClientProvider to create or initialize the Client.\n */\nexport const ClientContext: Context<ClientContextProps | undefined> = createContext<ClientContextProps | undefined>(\n undefined,\n);\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport { type Client } from '@dxos/client';\n\n// http://patorjk.com/software/taag/#p=testall&f=Patorjk-HeX&t=DXOS\nconst BANNER = (client: Client) => {\n const commitHash = client.config.get('runtime.app.build.commitHash');\n const hash = commitHash ? ` App Commit ${commitHash} \\n` : '';\n\n return (\n '\\n' +\n '_/\\\\/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\______/\\\\/\\\\/\\\\/\\\\/\\\\_\\n' +\n '_/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\__/\\\\/\\\\_________\\n' +\n '_/\\\\/\\\\____/\\\\/\\\\______/\\\\/\\\\______/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\___\\n' +\n '_/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\__________/\\\\/\\\\_\\n' +\n '_/\\\\/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\____/\\\\/\\\\/\\\\/\\\\/\\\\___\\n' +\n `\\n DXOS Client ${client.version} \\n${hash}`\n );\n};\n\nlet bannerPrinted = false;\n\nexport const printBanner = (client: Client) => {\n if (bannerPrinted) {\n return;\n }\n\n bannerPrinted = true;\n // eslint-disable-next-line no-console\n console.log(`%c${BANNER(client)}`, 'font-family: monospace;');\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { ClientContext } from '../client/context';\n\n/**\n * Hook returning instance of DXOS client.\n * Requires ClientContext to be set via ClientProvider.\n */\nexport const useClient = () => {\n const { client } = useContext(ClientContext) ?? raise(new Error('Missing ClientContext.'));\n return client;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { useEffect, useState } from 'react';\n\nimport { type Client, type SystemStatus } from '@dxos/client';\n\nexport const useClientStatus = (client: Client) => {\n const [status, setStatus] = useState<SystemStatus | null>();\n useEffect(() => {\n if (!client) {\n return;\n }\n\n const subscription = client.status.subscribe((status) => setStatus(status));\n return () => subscription.unsubscribe();\n }, [client, setStatus]);\n\n return status;\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { ClientContext } from './context';\n\n/**\n * Hook returning config object used to initialize the DXOS client instance.\n * Requires ClientContext to be set via ClientProvider.\n */\nexport const useConfig = () => {\n const { client } = useContext(ClientContext) ?? raise(new Error('Missing ClientContext.'));\n return client.config;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { useEffect, useState } from 'react';\n\nimport { type Shell, type ShellDisplay } from '@dxos/client';\n\nimport { useClient } from './useClient';\n\n/**\n * Helper hook to access the shell.\n */\nexport const useShell = (): Shell => {\n const client = useClient();\n return client.shell;\n};\n\n/**\n * Hook to access the shell’s display state.\n */\nexport const useShellDisplay = (): ShellDisplay => {\n const client = useClient();\n const [display, setDisplay] = useState(client.shell.display);\n useEffect(() => client.shell.onDisplayChange(setDisplay), [client]);\n return display;\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { useContext } from 'react';\n\nimport { type SystemStatus } from '@dxos/client';\nimport { raise } from '@dxos/debug';\n\nimport { ClientContext } from './context';\n\nexport const useStatus = (): SystemStatus | null | undefined => {\n const { status } = useContext(ClientContext) ?? raise(new Error('Missing ClientContext.'));\n return status;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mBAAmF;AAEnF,oBAA8F;AAG9F,iBAAoB;ACLpB,IAAAA,gBAOO;AAEP,IAAAC,iBAAsF;AAEtF,IAAAD,gBAAuC;AACvC,IAAAE,cAAoB;AACpB,yBAAmC;AACnC,kBAAwE;ACdxE,IAAAF,gBAA4C;AEA5C,IAAAA,gBAA2B;AAE3B,mBAAsB;ACFtB,IAAAA,gBAAoC;ACApC,IAAAA,gBAA2B;AAE3B,IAAAG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,IAAMkD,sBAAsBtE,iCAAAA,eAAiD,IAAA;AAQ7E,IAAMuE,uBAAuB,CAACC,UAAAA;AACnC,QAAMrE,SAASsD,UAAAA;AACf,QAAM,CAACgB,0BAAAA,QAA8BxC,aAAAA,UAASyC,WAAWvE,MAAAA,CAAAA;AACzD,SACEmD,6BAAAA,QAAA,cAACgB,oBAAoBf,UAAQ;IAACC,OAAOiB;KAA4B,KAAED,MAAMzD,QAAQ;AAErF;AAEO,IAAM4D,wBAAwB,MAAA;AACnC,aAAOjB,aAAAA,YAAWY,mBAAAA;AACpB;AAEA,IAAMI,aAAa,CAAC,EAAErE,QAAQuE,KAAI,MAA6B;AAC7D,QAAMC,qBAAqBxE,OAAOC,IAAI,+BAAA;AACtC,MAAI,CAACuE,oBAAoB;AACvBjE,mBAAAA,KAAI,+BAAA,QAAA;;;;;;AACJ,WAAO;EACT;AAGA,MAAI6D,6BAAgE;AACpE,UAAQI,mBAAmBC,MAAI;IAC7B,KAAK,iBAAiB;AACpBlE,qBAAAA,KAAI,kCAAA,QAAA;;;;;;AACJ,aAAO,IAAImE,uCAAAA;IACb;IAEA,KAAK,oBAAoB;AACvBN,mCAA6B,IAAIO,iCAAmB3E,QAAQuE,IAAAA;AAC5D,UAAIH,2BAA2BQ,KAAI,GAAI;AACrC,eAAOR;MACT,OAAO;AAEL,eAAO;MACT;IACF;IAEA,SAAS;AACP7D,iBAAAA,IAAImB,MAAM,0CAA0C8C,mBAAmBC,MAAI,QAAA;;;;;;AAC3E,aAAO;IACT;EACF;AACF;",
|
|
6
6
|
"names": ["import_react", "import_client", "import_log", "import_debug", "ClientContext", "createContext", "undefined", "BANNER", "client", "commitHash", "config", "get", "hash", "version", "bannerPrinted", "printBanner", "console", "log", "ClientProvider", "forwardRef", "children", "configProvider", "clientProvider", "services", "servicesProvider", "status", "controlledStatus", "fallback", "Fallback", "signalsRuntime", "noBanner", "onInitialized", "options", "forwardedRef", "useEffect", "registerSignalsRuntime", "error", "setError", "useState", "setClient", "Client", "useImperativeHandle", "setStatus", "useControlledValue", "subscription", "subscribe", "unsubscribe", "initialize", "initialized", "catch", "t", "setTimeout", "getAsyncProviderValue", "clearTimeout", "destroy", "then", "err", "SystemStatus", "ACTIVE", "React", "Provider", "value", "useClient", "useContext", "raise", "Error", "useClientStatus", "useConfig", "useShell", "shell", "useShellDisplay", "display", "setDisplay", "onDisplayChange", "useStatus", "AgentHostingContext", "AgentHostingProvider", "props", "agentHostingProviderClient", "makeClient", "useAgentHostingClient", "halo", "agentHostingConfig", "type", "FakeAgentHostingProvider", "AgentManagerClient", "init"]
|
|
7
7
|
}
|
|
@@ -23,13 +23,13 @@ __export(devtools_exports, {
|
|
|
23
23
|
useStream: () => useStream
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(devtools_exports);
|
|
26
|
-
var
|
|
26
|
+
var import_chunk_BYDG3FH4 = require("../chunk-BYDG3FH4.cjs");
|
|
27
27
|
__reExport(devtools_exports, require("@dxos/client/devtools"), module.exports);
|
|
28
28
|
var import_debug = require("@dxos/debug");
|
|
29
29
|
var import_react = require("react");
|
|
30
30
|
var import_log = require("@dxos/log");
|
|
31
31
|
var useDevtools = () => {
|
|
32
|
-
const client = (0,
|
|
32
|
+
const client = (0, import_chunk_BYDG3FH4.useClient)();
|
|
33
33
|
return client.services.services.DevtoolsHost ?? (0, import_debug.raise)(new Error("DevtoolsHost not available."));
|
|
34
34
|
};
|
|
35
35
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/react-client/src/devtools/useStream.ts";
|
|
@@ -29,7 +29,7 @@ __export(echo_exports, {
|
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(echo_exports);
|
|
31
31
|
var import_chunk_FYOAVV65 = require("../chunk-FYOAVV65.cjs");
|
|
32
|
-
var
|
|
32
|
+
var import_chunk_BYDG3FH4 = require("../chunk-BYDG3FH4.cjs");
|
|
33
33
|
__reExport(echo_exports, require("@dxos/client/echo"), module.exports);
|
|
34
34
|
var import_async = require("@dxos/async");
|
|
35
35
|
var import_echo = require("@dxos/client/echo");
|
|
@@ -45,7 +45,7 @@ var import_react_hooks3 = require("@dxos/react-hooks");
|
|
|
45
45
|
var import_react4 = require("react");
|
|
46
46
|
var import_echo4 = require("@dxos/client/echo");
|
|
47
47
|
var useSpace = (spaceKeyLike) => {
|
|
48
|
-
const client = (0,
|
|
48
|
+
const client = (0, import_chunk_BYDG3FH4.useClient)();
|
|
49
49
|
const spaces = (0, import_react_hooks2.useMulticastObservable)(client.spaces);
|
|
50
50
|
const [ready, setReady] = (0, import_react.useState)(false);
|
|
51
51
|
(0, import_react.useEffect)(() => {
|
|
@@ -69,7 +69,7 @@ var useSpace = (spaceKeyLike) => {
|
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
71
|
var useSpaces = ({ all = false } = {}) => {
|
|
72
|
-
const client = (0,
|
|
72
|
+
const client = (0, import_chunk_BYDG3FH4.useClient)();
|
|
73
73
|
const spaces = (0, import_react_hooks2.useMulticastObservable)(client.spaces);
|
|
74
74
|
return spaces.filter((space) => all || space.state.get() === import_echo2.SpaceState.SPACE_READY);
|
|
75
75
|
};
|
|
@@ -31,7 +31,7 @@ __export(halo_exports, {
|
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(halo_exports);
|
|
33
33
|
var import_chunk_FYOAVV65 = require("../chunk-FYOAVV65.cjs");
|
|
34
|
-
var
|
|
34
|
+
var import_chunk_BYDG3FH4 = require("../chunk-BYDG3FH4.cjs");
|
|
35
35
|
var import_halo = require("@dxos/client/halo");
|
|
36
36
|
var import_react_hooks = require("@dxos/react-hooks");
|
|
37
37
|
var import_react_hooks2 = require("@dxos/react-hooks");
|
|
@@ -40,15 +40,15 @@ var import_react_hooks3 = require("@dxos/react-hooks");
|
|
|
40
40
|
var import_react_hooks4 = require("@dxos/react-hooks");
|
|
41
41
|
var import_react2 = require("react");
|
|
42
42
|
var useContacts = () => {
|
|
43
|
-
const client = (0,
|
|
43
|
+
const client = (0, import_chunk_BYDG3FH4.useClient)();
|
|
44
44
|
return (0, import_react_hooks.useMulticastObservable)(client.halo.contacts);
|
|
45
45
|
};
|
|
46
46
|
var useDevices = () => {
|
|
47
|
-
const client = (0,
|
|
47
|
+
const client = (0, import_chunk_BYDG3FH4.useClient)();
|
|
48
48
|
return (0, import_react_hooks2.useMulticastObservable)(client.halo.devices);
|
|
49
49
|
};
|
|
50
50
|
var useHaloInvitations = () => {
|
|
51
|
-
const client = (0,
|
|
51
|
+
const client = (0, import_chunk_BYDG3FH4.useClient)();
|
|
52
52
|
return (0, import_react_hooks3.useMulticastObservable)(client.halo.invitations);
|
|
53
53
|
};
|
|
54
54
|
var useHaloInvitation = (invitationId) => {
|
|
@@ -59,7 +59,7 @@ var useHaloInvitation = (invitationId) => {
|
|
|
59
59
|
return (0, import_chunk_FYOAVV65.useInvitationStatus)(invitation);
|
|
60
60
|
};
|
|
61
61
|
var useIdentity = () => {
|
|
62
|
-
const client = (0,
|
|
62
|
+
const client = (0, import_chunk_BYDG3FH4.useClient)();
|
|
63
63
|
return (0, import_react_hooks4.useMulticastObservable)(client.halo.identity);
|
|
64
64
|
};
|
|
65
65
|
var KeyStore = class {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/halo/index.ts", "../../../../src/halo/useContacts.ts", "../../../../src/halo/useDevices.ts", "../../../../src/halo/useHaloInvitations.ts", "../../../../src/halo/useIdentity.ts", "../../../../src/halo/useKeyStore.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\n// NOTE: Export * fails here.\nexport { type Contact, type Identity, type Halo, Device, DeviceKind, DeviceType } from '@dxos/client/halo';\n\nexport * from './useContacts';\nexport * from './useDevices';\nexport * from './useHaloInvitations';\nexport * from './useIdentity';\nexport * from './useKeyStore';\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport type { Contact } from '@dxos/client/halo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\n\n/**\n * Returns all known Contacts across all Spaces.\n * Contacts are known members of a common Space.\n * Requires ClientContext to be set via ClientProvider.\n */\nexport const useContacts = (): Contact[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.contacts);\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport type { Device } from '@dxos/client/halo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\n\nexport const useDevices = (): Device[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.devices);\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { useMemo } from 'react';\n\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\nimport { useInvitationStatus, type CancellableInvitationObservable } from '../invitations';\n\nexport const useHaloInvitations = (): CancellableInvitationObservable[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.invitations);\n};\n\nexport const useHaloInvitation = (invitationId?: string) => {\n const invitations = useHaloInvitations();\n const invitation = useMemo(\n () => invitations.find((invitation) => invitation.get().invitationId === invitationId),\n [invitations],\n );\n return useInvitationStatus(invitation);\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { type Identity } from '@dxos/client/halo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\n\n/**\n * Hook returning DXOS identity object.\n * Requires ClientContext to be set via ClientProvider.\n */\nexport const useIdentity = (): Identity | null => {\n const client = useClient();\n return useMulticastObservable(client.halo.identity);\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { useMemo, useReducer } from 'react';\n\n// TODO(burdon): Move to settings plugin.\nexport class KeyStore {\n private _keyMap = new Map<string, string>();\n\n constructor(private readonly _defaultKeys: string[] = []) {}\n\n get map() {\n return this._keyMap;\n }\n\n // TODO(burdon): Create subkeys.\n initialize() {\n this._defaultKeys.forEach((key) => {\n const value = localStorage.getItem(key);\n this.setKey(key, value ?? '');\n });\n\n return this;\n }\n\n getKey(key: string) {\n localStorage.getItem(key);\n }\n\n setKey(key: string, value: string) {\n localStorage.setItem(key, '');\n this._keyMap.set(key, value);\n }\n}\n\n/**\n * Settings store.\n * @deprecated Replace with HALO key store when available.\n */\nexport const useKeyStore = (\n defaultKeys: string[] = [],\n): [Map<string, string>, (key: string, value: string) => void] => {\n const [, forceUpdate] = useReducer((x) => x + 1, 0);\n const store = useMemo(() => new KeyStore(defaultKeys).initialize(), [defaultKeys]);\n const setKey = (key: string, value: string) => {\n store.setKey(key, value);\n forceUpdate();\n };\n\n return [store.map, setKey];\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\n// NOTE: Export * fails here.\nexport { type Credential, type Contact, type Identity, type Halo, Device, DeviceKind, DeviceType } from '@dxos/client/halo';\n\nexport * from './useContacts';\nexport * from './useDevices';\nexport * from './useHaloInvitations';\nexport * from './useIdentity';\nexport * from './useKeyStore';\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport type { Contact } from '@dxos/client/halo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\n\n/**\n * Returns all known Contacts across all Spaces.\n * Contacts are known members of a common Space.\n * Requires ClientContext to be set via ClientProvider.\n */\nexport const useContacts = (): Contact[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.contacts);\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport type { Device } from '@dxos/client/halo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\n\nexport const useDevices = (): Device[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.devices);\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { useMemo } from 'react';\n\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\nimport { useInvitationStatus, type CancellableInvitationObservable } from '../invitations';\n\nexport const useHaloInvitations = (): CancellableInvitationObservable[] => {\n const client = useClient();\n return useMulticastObservable(client.halo.invitations);\n};\n\nexport const useHaloInvitation = (invitationId?: string) => {\n const invitations = useHaloInvitations();\n const invitation = useMemo(\n () => invitations.find((invitation) => invitation.get().invitationId === invitationId),\n [invitations],\n );\n return useInvitationStatus(invitation);\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { type Identity } from '@dxos/client/halo';\nimport { useMulticastObservable } from '@dxos/react-hooks';\n\nimport { useClient } from '../client';\n\n/**\n * Hook returning DXOS identity object.\n * Requires ClientContext to be set via ClientProvider.\n */\nexport const useIdentity = (): Identity | null => {\n const client = useClient();\n return useMulticastObservable(client.halo.identity);\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { useMemo, useReducer } from 'react';\n\n// TODO(burdon): Move to settings plugin.\nexport class KeyStore {\n private _keyMap = new Map<string, string>();\n\n constructor(private readonly _defaultKeys: string[] = []) {}\n\n get map() {\n return this._keyMap;\n }\n\n // TODO(burdon): Create subkeys.\n initialize() {\n this._defaultKeys.forEach((key) => {\n const value = localStorage.getItem(key);\n this.setKey(key, value ?? '');\n });\n\n return this;\n }\n\n getKey(key: string) {\n localStorage.getItem(key);\n }\n\n setKey(key: string, value: string) {\n localStorage.setItem(key, '');\n this._keyMap.set(key, value);\n }\n}\n\n/**\n * Settings store.\n * @deprecated Replace with HALO key store when available.\n */\nexport const useKeyStore = (\n defaultKeys: string[] = [],\n): [Map<string, string>, (key: string, value: string) => void] => {\n const [, forceUpdate] = useReducer((x) => x + 1, 0);\n const store = useMemo(() => new KeyStore(defaultKeys).initialize(), [defaultKeys]);\n const setKey = (key: string, value: string) => {\n store.setKey(key, value);\n forceUpdate();\n };\n\n return [store.map, setKey];\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,kBAAwG;ACAxG,yBAAuC;ACAvC,IAAAA,sBAAuC;ACDvC,mBAAwB;AAExB,IAAAA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Ac,CACzBC,cAAwB,CAAA,MAAE;AAE1B,QAAM,CAAA,EAAGC,WAAAA,QAAeC,0BAAW,CAACC,MAAMA,IAAI,GAAG,CAAA;AACjD,QAAMC,YAAQ3B,cAAAA,SAAQ,MAAM,IAAIM,SAASiB,WAAAA,EAAaX,WAAU,GAAI;IAACW;GAAY;AACjF,QAAML,SAAS,CAACJ,KAAaC,UAAAA;AAC3BY,UAAMT,OAAOJ,KAAKC,KAAAA;AAClBS,gBAAAA;EACF;AAEA,SAAO;IAACG,MAAMhB;IAAKO;;AACrB;",
|
|
6
6
|
"names": ["import_react_hooks", "import_react", "useContacts", "client", "useClient", "useMulticastObservable", "halo", "contacts", "useDevices", "devices", "useHaloInvitations", "invitations", "useHaloInvitation", "invitationId", "invitation", "useMemo", "find", "get", "useInvitationStatus", "useIdentity", "identity", "KeyStore", "constructor", "_defaultKeys", "_keyMap", "Map", "map", "initialize", "forEach", "key", "value", "localStorage", "getItem", "setKey", "getKey", "setItem", "set", "useKeyStore", "defaultKeys", "forceUpdate", "useReducer", "x", "store"]
|
|
7
7
|
}
|
package/dist/lib/node/index.cjs
CHANGED
|
@@ -19,21 +19,21 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
19
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
20
|
var node_exports = {};
|
|
21
21
|
__export(node_exports, {
|
|
22
|
-
AgentHostingContext: () =>
|
|
23
|
-
AgentHostingProvider: () =>
|
|
24
|
-
ClientContext: () =>
|
|
25
|
-
ClientProvider: () =>
|
|
26
|
-
useAgentHostingClient: () =>
|
|
27
|
-
useClient: () =>
|
|
28
|
-
useClientStatus: () =>
|
|
29
|
-
useConfig: () =>
|
|
22
|
+
AgentHostingContext: () => import_chunk_BYDG3FH4.AgentHostingContext,
|
|
23
|
+
AgentHostingProvider: () => import_chunk_BYDG3FH4.AgentHostingProvider,
|
|
24
|
+
ClientContext: () => import_chunk_BYDG3FH4.ClientContext,
|
|
25
|
+
ClientProvider: () => import_chunk_BYDG3FH4.ClientProvider,
|
|
26
|
+
useAgentHostingClient: () => import_chunk_BYDG3FH4.useAgentHostingClient,
|
|
27
|
+
useClient: () => import_chunk_BYDG3FH4.useClient,
|
|
28
|
+
useClientStatus: () => import_chunk_BYDG3FH4.useClientStatus,
|
|
29
|
+
useConfig: () => import_chunk_BYDG3FH4.useConfig,
|
|
30
30
|
useMulticastObservable: () => import_react_hooks.useMulticastObservable,
|
|
31
|
-
useShell: () =>
|
|
32
|
-
useShellDisplay: () =>
|
|
33
|
-
useStatus: () =>
|
|
31
|
+
useShell: () => import_chunk_BYDG3FH4.useShell,
|
|
32
|
+
useShellDisplay: () => import_chunk_BYDG3FH4.useShellDisplay,
|
|
33
|
+
useStatus: () => import_chunk_BYDG3FH4.useStatus
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(node_exports);
|
|
36
|
-
var
|
|
36
|
+
var import_chunk_BYDG3FH4 = require("./chunk-BYDG3FH4.cjs");
|
|
37
37
|
__reExport(node_exports, require("@dxos/client"), module.exports);
|
|
38
38
|
var import_react_hooks = require("@dxos/react-hooks");
|
|
39
39
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -22,11 +22,11 @@ __export(mesh_exports, {
|
|
|
22
22
|
useNetworkStatus: () => useNetworkStatus
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(mesh_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_chunk_BYDG3FH4 = require("../chunk-BYDG3FH4.cjs");
|
|
26
26
|
__reExport(mesh_exports, require("@dxos/client/mesh"), module.exports);
|
|
27
27
|
var import_react_hooks = require("@dxos/react-hooks");
|
|
28
28
|
var useNetworkStatus = () => {
|
|
29
|
-
const client = (0,
|
|
29
|
+
const client = (0, import_chunk_BYDG3FH4.useClient)();
|
|
30
30
|
return (0, import_react_hooks.useMulticastObservable)(client.mesh.networkStatus);
|
|
31
31
|
};
|
|
32
32
|
// Annotate the CommonJS export names for ESM import in node:
|