@dxos/halo-react 0.0.0 → 0.11.0
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/index.mjs +124 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/types/src/useIdentity.d.ts.map +1 -1
- package/dist/types/src/useMembers.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -5
- package/src/useIdentity.ts +11 -1
- package/src/useMembers.ts +1 -0
- package/dist/lib/browser/index.mjs +0 -132
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/node-esm/index.mjs +0 -134
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/halo-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "React hooks for the @dxos/halo services.",
|
|
5
5
|
"homepage": "https://github.com/dxos/dxos/tree/main/packages/core/halo/halo-react#readme",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
".": {
|
|
17
17
|
"source": "./src/index.ts",
|
|
18
18
|
"types": "./dist/types/src/index.d.ts",
|
|
19
|
-
"
|
|
20
|
-
"node": "./dist/lib/node-esm/index.mjs"
|
|
19
|
+
"import": "./dist/lib/index.mjs"
|
|
21
20
|
}
|
|
22
21
|
},
|
|
23
22
|
"types": "dist/types/src/index.d.ts",
|
|
@@ -27,8 +26,8 @@
|
|
|
27
26
|
],
|
|
28
27
|
"dependencies": {
|
|
29
28
|
"@effect-atom/atom-react": "^0.5.0",
|
|
30
|
-
"@dxos/halo": "0.
|
|
31
|
-
"@dxos/keys": "0.
|
|
29
|
+
"@dxos/halo": "0.11.0",
|
|
30
|
+
"@dxos/keys": "0.11.0"
|
|
32
31
|
},
|
|
33
32
|
"devDependencies": {
|
|
34
33
|
"react": "~19.2.7",
|
package/src/useIdentity.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Atom, Result, useAtomValue } from '@effect-atom/atom-react';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
6
7
|
import * as Option from 'effect/Option';
|
|
7
8
|
import * as Stream from 'effect/Stream';
|
|
8
9
|
import { useMemo } from 'react';
|
|
@@ -18,7 +19,16 @@ import { useHaloServices } from './HaloProvider';
|
|
|
18
19
|
export const useIdentity = (): Identity.Info | undefined => {
|
|
19
20
|
const services = useHaloServices();
|
|
20
21
|
const atom = useMemo(
|
|
21
|
-
() =>
|
|
22
|
+
() =>
|
|
23
|
+
Atom.make(Identity.identity.pipe(Stream.provideContext(services), Stream.map(Option.getOrUndefined)), {
|
|
24
|
+
// The stream emits the current identity, but only after its first (async) subscription
|
|
25
|
+
// tick — until then the atom would sit at `Result.Initial` and callers would see "no
|
|
26
|
+
// identity" for the first render(s) even when one already exists. Seed it with the
|
|
27
|
+
// service's synchronous snapshot so the current identity is available on the very first
|
|
28
|
+
// render; the stream's value takes over as soon as it arrives (and covers post-mount
|
|
29
|
+
// create/update).
|
|
30
|
+
initialValue: Option.getOrUndefined(Effect.runSync(Identity.getSnapshot.pipe(Effect.provide(services)))),
|
|
31
|
+
}),
|
|
22
32
|
[services],
|
|
23
33
|
);
|
|
24
34
|
return Result.getOrElse(useAtomValue(atom), () => undefined);
|
package/src/useMembers.ts
CHANGED
|
@@ -24,5 +24,6 @@ export const useMembers = (spaceId?: SpaceId): readonly Space.Member[] => {
|
|
|
24
24
|
() => Atom.make((spaceId ? Space.members(spaceId) : Stream.empty).pipe(Stream.provideContext(services))),
|
|
25
25
|
[services, spaceId],
|
|
26
26
|
);
|
|
27
|
+
|
|
27
28
|
return Result.getOrElse(useAtomValue(atom), () => EMPTY);
|
|
28
29
|
};
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
// src/HaloProvider.tsx
|
|
2
|
-
import React, { createContext, useContext } from "react";
|
|
3
|
-
var HaloServicesContext = /* @__PURE__ */ createContext(void 0);
|
|
4
|
-
var HaloProvider = ({ services, children }) => /* @__PURE__ */ React.createElement(HaloServicesContext.Provider, {
|
|
5
|
-
value: services
|
|
6
|
-
}, children);
|
|
7
|
-
var useHaloServices = () => {
|
|
8
|
-
const services = useContext(HaloServicesContext);
|
|
9
|
-
if (!services) {
|
|
10
|
-
throw new Error("Missing HaloProvider.");
|
|
11
|
-
}
|
|
12
|
-
return services;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
// src/useCredentials.ts
|
|
16
|
-
import { Atom, Result, useAtomValue } from "@effect-atom/atom-react";
|
|
17
|
-
import * as Stream from "effect/Stream";
|
|
18
|
-
import { useMemo } from "react";
|
|
19
|
-
import { Identity } from "@dxos/halo";
|
|
20
|
-
var EMPTY = [];
|
|
21
|
-
var useCredentials = () => {
|
|
22
|
-
const services = useHaloServices();
|
|
23
|
-
const atom = useMemo(() => Atom.make(Identity.credentials.pipe(Stream.provideContext(services))), [
|
|
24
|
-
services
|
|
25
|
-
]);
|
|
26
|
-
return Result.getOrElse(useAtomValue(atom), () => EMPTY);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
// src/useDevices.ts
|
|
30
|
-
import { Atom as Atom2, Result as Result2, useAtomValue as useAtomValue2 } from "@effect-atom/atom-react";
|
|
31
|
-
import * as Stream2 from "effect/Stream";
|
|
32
|
-
import { useMemo as useMemo2 } from "react";
|
|
33
|
-
import { Identity as Identity2 } from "@dxos/halo";
|
|
34
|
-
var EMPTY2 = [];
|
|
35
|
-
var useDevices = () => {
|
|
36
|
-
const services = useHaloServices();
|
|
37
|
-
const atom = useMemo2(() => Atom2.make(Identity2.devices.pipe(Stream2.provideContext(services))), [
|
|
38
|
-
services
|
|
39
|
-
]);
|
|
40
|
-
return Result2.getOrElse(useAtomValue2(atom), () => EMPTY2);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// src/useIdentity.ts
|
|
44
|
-
import { Atom as Atom3, Result as Result3, useAtomValue as useAtomValue3 } from "@effect-atom/atom-react";
|
|
45
|
-
import * as Option from "effect/Option";
|
|
46
|
-
import * as Stream3 from "effect/Stream";
|
|
47
|
-
import { useMemo as useMemo3 } from "react";
|
|
48
|
-
import { Identity as Identity3 } from "@dxos/halo";
|
|
49
|
-
var useIdentity = () => {
|
|
50
|
-
const services = useHaloServices();
|
|
51
|
-
const atom = useMemo3(() => Atom3.make(Identity3.identity.pipe(Stream3.provideContext(services), Stream3.map(Option.getOrUndefined))), [
|
|
52
|
-
services
|
|
53
|
-
]);
|
|
54
|
-
return Result3.getOrElse(useAtomValue3(atom), () => void 0);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
// src/useInvitations.ts
|
|
58
|
-
import { Atom as Atom4, Result as Result4, useAtomValue as useAtomValue4 } from "@effect-atom/atom-react";
|
|
59
|
-
import * as Stream4 from "effect/Stream";
|
|
60
|
-
import { useMemo as useMemo4 } from "react";
|
|
61
|
-
import { Identity as Identity4, Space } from "@dxos/halo";
|
|
62
|
-
var EMPTY3 = [];
|
|
63
|
-
var useSpaceInvitations = (spaceId) => {
|
|
64
|
-
const services = useHaloServices();
|
|
65
|
-
const atom = useMemo4(() => Atom4.make((spaceId ? Space.invitations(spaceId) : Stream4.empty).pipe(Stream4.provideContext(services))), [
|
|
66
|
-
services,
|
|
67
|
-
spaceId
|
|
68
|
-
]);
|
|
69
|
-
return Result4.getOrElse(useAtomValue4(atom), () => EMPTY3);
|
|
70
|
-
};
|
|
71
|
-
var useHaloInvitations = () => {
|
|
72
|
-
const services = useHaloServices();
|
|
73
|
-
const atom = useMemo4(() => Atom4.make(Identity4.invitations.pipe(Stream4.provideContext(services))), [
|
|
74
|
-
services
|
|
75
|
-
]);
|
|
76
|
-
return Result4.getOrElse(useAtomValue4(atom), () => EMPTY3);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
// src/useMembers.ts
|
|
80
|
-
import { Atom as Atom5, Result as Result5, useAtomValue as useAtomValue5 } from "@effect-atom/atom-react";
|
|
81
|
-
import * as Stream5 from "effect/Stream";
|
|
82
|
-
import { useMemo as useMemo5 } from "react";
|
|
83
|
-
import { Space as Space2 } from "@dxos/halo";
|
|
84
|
-
var EMPTY4 = [];
|
|
85
|
-
var useMembers = (spaceId) => {
|
|
86
|
-
const services = useHaloServices();
|
|
87
|
-
const atom = useMemo5(() => Atom5.make((spaceId ? Space2.members(spaceId) : Stream5.empty).pipe(Stream5.provideContext(services))), [
|
|
88
|
-
services,
|
|
89
|
-
spaceId
|
|
90
|
-
]);
|
|
91
|
-
return Result5.getOrElse(useAtomValue5(atom), () => EMPTY4);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
// src/useSpaces.ts
|
|
95
|
-
import { Atom as Atom6, Result as Result6, useAtomValue as useAtomValue6 } from "@effect-atom/atom-react";
|
|
96
|
-
import * as Stream6 from "effect/Stream";
|
|
97
|
-
import { useMemo as useMemo6 } from "react";
|
|
98
|
-
import { Space as Space3 } from "@dxos/halo";
|
|
99
|
-
var EMPTY5 = [];
|
|
100
|
-
var useSpaces = ({ all = false } = {}) => {
|
|
101
|
-
const services = useHaloServices();
|
|
102
|
-
const atom = useMemo6(() => Atom6.make(Space3.spaces.pipe(Stream6.provideContext(services))), [
|
|
103
|
-
services
|
|
104
|
-
]);
|
|
105
|
-
const spaces = Result6.getOrElse(useAtomValue6(atom), () => EMPTY5);
|
|
106
|
-
return useMemo6(() => all ? spaces : spaces.filter((space) => space.state === "ready"), [
|
|
107
|
-
spaces,
|
|
108
|
-
all
|
|
109
|
-
]);
|
|
110
|
-
};
|
|
111
|
-
var useSpace = (spaceId) => {
|
|
112
|
-
const spaces = useSpaces({
|
|
113
|
-
all: true
|
|
114
|
-
});
|
|
115
|
-
return useMemo6(() => spaceId ? spaces.find((space) => space.id === spaceId) : void 0, [
|
|
116
|
-
spaces,
|
|
117
|
-
spaceId
|
|
118
|
-
]);
|
|
119
|
-
};
|
|
120
|
-
export {
|
|
121
|
-
HaloProvider,
|
|
122
|
-
useCredentials,
|
|
123
|
-
useDevices,
|
|
124
|
-
useHaloInvitations,
|
|
125
|
-
useHaloServices,
|
|
126
|
-
useIdentity,
|
|
127
|
-
useMembers,
|
|
128
|
-
useSpace,
|
|
129
|
-
useSpaceInvitations,
|
|
130
|
-
useSpaces
|
|
131
|
-
};
|
|
132
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/HaloProvider.tsx", "../../../src/useCredentials.ts", "../../../src/useDevices.ts", "../../../src/useIdentity.ts", "../../../src/useInvitations.ts", "../../../src/useMembers.ts", "../../../src/useSpaces.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\nimport React, { type PropsWithChildren, createContext, useContext } from 'react';\n\nimport { type Identity, type Space } from '@dxos/halo';\n\n/**\n * The HALO services, as the tag union carried in an Effect service {@link Context.Context}.\n */\nexport type HaloServices = Identity.Service | Space.Service;\n\n/**\n * React context carrying the HALO services. Hooks read it, provide it into a service stream, and\n * surface the result through the default {@link Atom} runtime.\n */\nconst HaloServicesContext = createContext<Context.Context<HaloServices> | undefined>(undefined);\n\nexport type HaloProviderProps = PropsWithChildren<{\n /**\n * The HALO services context. Build it from a concrete backing — e.g. the client adapter's\n * `makeIdentityService` / `makeSpaceService` from `@dxos/halo-adapter-client` — and pass it\n * here.\n */\n services: Context.Context<HaloServices>;\n}>;\n\n/**\n * Provides the HALO services to the hook library. Wrap the application (or the subtree that uses\n * the hooks) in this provider. Replaces `ClientProvider` for HALO concerns.\n */\nexport const HaloProvider = ({ services, children }: HaloProviderProps) => (\n <HaloServicesContext.Provider value={services}>{children}</HaloServicesContext.Provider>\n);\n\n/**\n * Returns the HALO services context. Throws if no {@link HaloProvider} is above in the tree.\n */\nexport const useHaloServices = (): Context.Context<HaloServices> => {\n const services = useContext(HaloServicesContext);\n if (!services) {\n throw new Error('Missing HaloProvider.');\n }\n return services;\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { Atom, Result, useAtomValue } from '@effect-atom/atom-react';\nimport * as Stream from 'effect/Stream';\nimport { useMemo } from 'react';\n\nimport { Identity } from '@dxos/halo';\n\nimport { useHaloServices } from './HaloProvider';\n\nconst EMPTY: readonly Identity.Credential[] = [];\n\n/**\n * Returns the local identity's HALO credentials. Reactive: re-renders when credentials are\n * written. Replaces `@dxos/react-client`'s `useCredentials`.\n */\nexport const useCredentials = (): readonly Identity.Credential[] => {\n const services = useHaloServices();\n const atom = useMemo(() => Atom.make(Identity.credentials.pipe(Stream.provideContext(services))), [services]);\n return Result.getOrElse(useAtomValue(atom), () => EMPTY);\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { Atom, Result, useAtomValue } from '@effect-atom/atom-react';\nimport * as Stream from 'effect/Stream';\nimport { useMemo } from 'react';\n\nimport { Identity } from '@dxos/halo';\n\nimport { useHaloServices } from './HaloProvider';\n\nconst EMPTY: readonly Identity.DeviceInfo[] = [];\n\n/**\n * Returns the devices belonging to the local identity. Reactive. Replaces\n * `@dxos/react-client`'s `useDevices`.\n */\nexport const useDevices = (): readonly Identity.DeviceInfo[] => {\n const services = useHaloServices();\n const atom = useMemo(() => Atom.make(Identity.devices.pipe(Stream.provideContext(services))), [services]);\n return Result.getOrElse(useAtomValue(atom), () => EMPTY);\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { Atom, Result, useAtomValue } from '@effect-atom/atom-react';\nimport * as Option from 'effect/Option';\nimport * as Stream from 'effect/Stream';\nimport { useMemo } from 'react';\n\nimport { Identity } from '@dxos/halo';\n\nimport { useHaloServices } from './HaloProvider';\n\n/**\n * Returns the local identity, or `undefined` if none exists. Reactive: re-renders when the\n * identity is created or its profile changes. Replaces `@dxos/react-client`'s `useIdentity`.\n */\nexport const useIdentity = (): Identity.Info | undefined => {\n const services = useHaloServices();\n const atom = useMemo(\n () => Atom.make(Identity.identity.pipe(Stream.provideContext(services), Stream.map(Option.getOrUndefined))),\n [services],\n );\n return Result.getOrElse(useAtomValue(atom), () => undefined);\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { Atom, Result, useAtomValue } from '@effect-atom/atom-react';\nimport * as Stream from 'effect/Stream';\nimport { useMemo } from 'react';\n\nimport { Identity, type Invitation, Space } from '@dxos/halo';\nimport { type SpaceId } from '@dxos/keys';\n\nimport { useHaloServices } from './HaloProvider';\n\nconst EMPTY: readonly Invitation.Flow[] = [];\n\n/**\n * Returns the active (host-created) invitation flows for a space. Reactive. Replaces\n * `@dxos/react-client`'s `useSpaceInvitations`. Drive an individual flow through the\n * `Invitation` verbs (`events` / `authenticate` / `cancel` / `code`).\n */\nexport const useSpaceInvitations = (spaceId?: SpaceId): readonly Invitation.Flow[] => {\n const services = useHaloServices();\n const atom = useMemo(\n () => Atom.make((spaceId ? Space.invitations(spaceId) : Stream.empty).pipe(Stream.provideContext(services))),\n [services, spaceId],\n );\n return Result.getOrElse(useAtomValue(atom), () => EMPTY);\n};\n\n/**\n * Returns the active device-invitation flows for the local identity. Reactive. Replaces\n * `useHaloInvitations`.\n */\nexport const useHaloInvitations = (): readonly Invitation.Flow[] => {\n const services = useHaloServices();\n const atom = useMemo(() => Atom.make(Identity.invitations.pipe(Stream.provideContext(services))), [services]);\n return Result.getOrElse(useAtomValue(atom), () => EMPTY);\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { Atom, Result, useAtomValue } from '@effect-atom/atom-react';\nimport * as Stream from 'effect/Stream';\nimport { useMemo } from 'react';\n\nimport { Space } from '@dxos/halo';\nimport { type SpaceId } from '@dxos/keys';\n\nimport { useHaloServices } from './HaloProvider';\n\nconst EMPTY: readonly Space.Member[] = [];\n\n/**\n * Returns the membership of a space. Reactive: re-renders on join/leave/role/presence changes.\n * Replaces `@dxos/react-client`'s `useMembers` (which took a `PublicKey`; this takes a\n * {@link SpaceId}).\n */\nexport const useMembers = (spaceId?: SpaceId): readonly Space.Member[] => {\n const services = useHaloServices();\n const atom = useMemo(\n () => Atom.make((spaceId ? Space.members(spaceId) : Stream.empty).pipe(Stream.provideContext(services))),\n [services, spaceId],\n );\n return Result.getOrElse(useAtomValue(atom), () => EMPTY);\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { Atom, Result, useAtomValue } from '@effect-atom/atom-react';\nimport * as Stream from 'effect/Stream';\nimport { useMemo } from 'react';\n\nimport { Space } from '@dxos/halo';\nimport { type SpaceId } from '@dxos/keys';\n\nimport { useHaloServices } from './HaloProvider';\n\nconst EMPTY: readonly Space.Info[] = [];\n\nexport type UseSpacesOptions = {\n /** Include spaces that are not yet `ready` (default: only `ready` spaces). */\n all?: boolean;\n};\n\n/**\n * Returns the spaces known to the local identity. By default only `ready` spaces are returned;\n * pass `{ all: true }` for every space. Reactive. Replaces `@dxos/react-client`'s `useSpaces`.\n */\nexport const useSpaces = ({ all = false }: UseSpacesOptions = {}): readonly Space.Info[] => {\n const services = useHaloServices();\n const atom = useMemo(() => Atom.make(Space.spaces.pipe(Stream.provideContext(services))), [services]);\n const spaces = Result.getOrElse(useAtomValue(atom), () => EMPTY);\n return useMemo(() => (all ? spaces : spaces.filter((space) => space.state === 'ready')), [spaces, all]);\n};\n\n/**\n * Resolves a single space by id, or `undefined`. Reactive. Replaces `useSpace`. Unlike the\n * legacy hook this takes a {@link SpaceId} only (no `PublicKey`).\n */\nexport const useSpace = (spaceId?: SpaceId): Space.Info | undefined => {\n const spaces = useSpaces({ all: true });\n return useMemo(() => (spaceId ? spaces.find((space) => space.id === spaceId) : undefined), [spaces, spaceId]);\n};\n"],
|
|
5
|
-
"mappings": ";AAKA,OAAOA,SAAiCC,eAAeC,kBAAkB;AAazE,IAAMC,sBAAsBF,8BAAyDG,MAAAA;A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,eAAOC,KAAYC,uBAAeV,QAAAA,CAAAA,CAAAA,GAC7F;IAACA;IAAUD;GAAQ;AAErB,SAAOY,QAAOC,UAAUC,cAAaX,IAAAA,GAAO,MAAML,MAAAA;AACpD;;;ACvBA,SAASiB,QAAAA,OAAMC,UAAAA,SAAQC,gBAAAA,qBAAoB;AAC3C,YAAYC,aAAY;AACxB,SAASC,WAAAA,gBAAe;AAExB,SAASC,SAAAA,cAAa;AAKtB,IAAMC,SAA+B,CAAA;AAW9B,IAAMC,YAAY,CAAC,EAAEC,MAAM,MAAK,IAAuB,CAAC,MAAC;AAC9D,QAAMC,WAAWC,gBAAAA;AACjB,QAAMC,OAAOC,SAAQ,MAAMC,MAAKC,KAAKC,OAAMC,OAAOC,KAAYC,uBAAeT,QAAAA,CAAAA,CAAAA,GAAa;IAACA;GAAS;AACpG,QAAMO,SAASG,QAAOC,UAAUC,cAAaV,IAAAA,GAAO,MAAML,MAAAA;AAC1D,SAAOM,SAAQ,MAAOJ,MAAMQ,SAASA,OAAOM,OAAO,CAACC,UAAUA,MAAMC,UAAU,OAAA,GAAW;IAACR;IAAQR;GAAI;AACxG;AAMO,IAAMiB,WAAW,CAACC,YAAAA;AACvB,QAAMV,SAAST,UAAU;IAAEC,KAAK;EAAK,CAAA;AACrC,SAAOI,SAAQ,MAAOc,UAAUV,OAAOW,KAAK,CAACJ,UAAUA,MAAMK,OAAOF,OAAAA,IAAWG,QAAY;IAACb;IAAQU;GAAQ;AAC9G;",
|
|
6
|
-
"names": ["React", "createContext", "useContext", "HaloServicesContext", "undefined", "HaloProvider", "services", "children", "Provider", "value", "useHaloServices", "Error", "Atom", "Result", "useAtomValue", "Stream", "useMemo", "Identity", "EMPTY", "useCredentials", "services", "useHaloServices", "atom", "useMemo", "Atom", "make", "Identity", "credentials", "pipe", "provideContext", "Result", "getOrElse", "useAtomValue", "Atom", "Result", "useAtomValue", "Stream", "useMemo", "Identity", "EMPTY", "useDevices", "services", "useHaloServices", "atom", "useMemo", "Atom", "make", "Identity", "devices", "pipe", "provideContext", "Result", "getOrElse", "useAtomValue", "Atom", "Result", "useAtomValue", "Option", "Stream", "useMemo", "Identity", "useIdentity", "services", "useHaloServices", "atom", "useMemo", "Atom", "make", "Identity", "identity", "pipe", "provideContext", "map", "getOrUndefined", "Result", "getOrElse", "useAtomValue", "undefined", "Atom", "Result", "useAtomValue", "Stream", "useMemo", "Identity", "Space", "EMPTY", "useSpaceInvitations", "spaceId", "services", "useHaloServices", "atom", "useMemo", "Atom", "make", "Space", "invitations", "empty", "pipe", "provideContext", "Result", "getOrElse", "useAtomValue", "useHaloInvitations", "Identity", "Atom", "Result", "useAtomValue", "Stream", "useMemo", "Space", "EMPTY", "useMembers", "spaceId", "services", "useHaloServices", "atom", "useMemo", "Atom", "make", "Space", "members", "empty", "pipe", "provideContext", "Result", "getOrElse", "useAtomValue", "Atom", "Result", "useAtomValue", "Stream", "useMemo", "Space", "EMPTY", "useSpaces", "all", "services", "useHaloServices", "atom", "useMemo", "Atom", "make", "Space", "spaces", "pipe", "provideContext", "Result", "getOrElse", "useAtomValue", "filter", "space", "state", "useSpace", "spaceId", "find", "id", "undefined"]
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"inputs":{"src/HaloProvider.tsx":{"bytes":4067,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/useCredentials.ts":{"bytes":2751,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/halo","kind":"import-statement","external":true},{"path":"src/HaloProvider.tsx","kind":"import-statement","original":"./HaloProvider"}],"format":"esm"},"src/useDevices.ts":{"bytes":2624,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/halo","kind":"import-statement","external":true},{"path":"src/HaloProvider.tsx","kind":"import-statement","original":"./HaloProvider"}],"format":"esm"},"src/useIdentity.ts":{"bytes":3007,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/halo","kind":"import-statement","external":true},{"path":"src/HaloProvider.tsx","kind":"import-statement","original":"./HaloProvider"}],"format":"esm"},"src/useInvitations.ts":{"bytes":4621,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/halo","kind":"import-statement","external":true},{"path":"src/HaloProvider.tsx","kind":"import-statement","original":"./HaloProvider"}],"format":"esm"},"src/useMembers.ts":{"bytes":3124,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/halo","kind":"import-statement","external":true},{"path":"src/HaloProvider.tsx","kind":"import-statement","original":"./HaloProvider"}],"format":"esm"},"src/useSpaces.ts":{"bytes":4853,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/halo","kind":"import-statement","external":true},{"path":"src/HaloProvider.tsx","kind":"import-statement","original":"./HaloProvider"}],"format":"esm"},"src/index.ts":{"bytes":972,"imports":[{"path":"src/HaloProvider.tsx","kind":"import-statement","original":"./HaloProvider"},{"path":"src/useCredentials.ts","kind":"import-statement","original":"./useCredentials"},{"path":"src/useDevices.ts","kind":"import-statement","original":"./useDevices"},{"path":"src/useIdentity.ts","kind":"import-statement","original":"./useIdentity"},{"path":"src/useInvitations.ts","kind":"import-statement","original":"./useInvitations"},{"path":"src/useMembers.ts","kind":"import-statement","original":"./useMembers"},{"path":"src/useSpaces.ts","kind":"import-statement","original":"./useSpaces"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":13111},"dist/lib/browser/index.mjs":{"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/halo","kind":"import-statement","external":true},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/halo","kind":"import-statement","external":true},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/halo","kind":"import-statement","external":true},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/halo","kind":"import-statement","external":true},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/halo","kind":"import-statement","external":true},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/halo","kind":"import-statement","external":true}],"exports":["HaloProvider","useCredentials","useDevices","useHaloInvitations","useHaloServices","useIdentity","useMembers","useSpace","useSpaceInvitations","useSpaces"],"entryPoint":"src/index.ts","inputs":{"src/HaloProvider.tsx":{"bytesInOutput":443},"src/index.ts":{"bytesInOutput":0},"src/useCredentials.ts":{"bytesInOutput":450},"src/useDevices.ts":{"bytesInOutput":513},"src/useIdentity.ts":{"bytesInOutput":575},"src/useInvitations.ts":{"bytesInOutput":848},"src/useMembers.ts":{"bytesInOutput":561},"src/useSpaces.ts":{"bytesInOutput":851}},"bytes":4617}}}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
|
|
3
|
-
// src/HaloProvider.tsx
|
|
4
|
-
import React, { createContext, useContext } from "react";
|
|
5
|
-
var HaloServicesContext = /* @__PURE__ */ createContext(void 0);
|
|
6
|
-
var HaloProvider = ({ services, children }) => /* @__PURE__ */ React.createElement(HaloServicesContext.Provider, {
|
|
7
|
-
value: services
|
|
8
|
-
}, children);
|
|
9
|
-
var useHaloServices = () => {
|
|
10
|
-
const services = useContext(HaloServicesContext);
|
|
11
|
-
if (!services) {
|
|
12
|
-
throw new Error("Missing HaloProvider.");
|
|
13
|
-
}
|
|
14
|
-
return services;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// src/useCredentials.ts
|
|
18
|
-
import { Atom, Result, useAtomValue } from "@effect-atom/atom-react";
|
|
19
|
-
import * as Stream from "effect/Stream";
|
|
20
|
-
import { useMemo } from "react";
|
|
21
|
-
import { Identity } from "@dxos/halo";
|
|
22
|
-
var EMPTY = [];
|
|
23
|
-
var useCredentials = () => {
|
|
24
|
-
const services = useHaloServices();
|
|
25
|
-
const atom = useMemo(() => Atom.make(Identity.credentials.pipe(Stream.provideContext(services))), [
|
|
26
|
-
services
|
|
27
|
-
]);
|
|
28
|
-
return Result.getOrElse(useAtomValue(atom), () => EMPTY);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
// src/useDevices.ts
|
|
32
|
-
import { Atom as Atom2, Result as Result2, useAtomValue as useAtomValue2 } from "@effect-atom/atom-react";
|
|
33
|
-
import * as Stream2 from "effect/Stream";
|
|
34
|
-
import { useMemo as useMemo2 } from "react";
|
|
35
|
-
import { Identity as Identity2 } from "@dxos/halo";
|
|
36
|
-
var EMPTY2 = [];
|
|
37
|
-
var useDevices = () => {
|
|
38
|
-
const services = useHaloServices();
|
|
39
|
-
const atom = useMemo2(() => Atom2.make(Identity2.devices.pipe(Stream2.provideContext(services))), [
|
|
40
|
-
services
|
|
41
|
-
]);
|
|
42
|
-
return Result2.getOrElse(useAtomValue2(atom), () => EMPTY2);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// src/useIdentity.ts
|
|
46
|
-
import { Atom as Atom3, Result as Result3, useAtomValue as useAtomValue3 } from "@effect-atom/atom-react";
|
|
47
|
-
import * as Option from "effect/Option";
|
|
48
|
-
import * as Stream3 from "effect/Stream";
|
|
49
|
-
import { useMemo as useMemo3 } from "react";
|
|
50
|
-
import { Identity as Identity3 } from "@dxos/halo";
|
|
51
|
-
var useIdentity = () => {
|
|
52
|
-
const services = useHaloServices();
|
|
53
|
-
const atom = useMemo3(() => Atom3.make(Identity3.identity.pipe(Stream3.provideContext(services), Stream3.map(Option.getOrUndefined))), [
|
|
54
|
-
services
|
|
55
|
-
]);
|
|
56
|
-
return Result3.getOrElse(useAtomValue3(atom), () => void 0);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// src/useInvitations.ts
|
|
60
|
-
import { Atom as Atom4, Result as Result4, useAtomValue as useAtomValue4 } from "@effect-atom/atom-react";
|
|
61
|
-
import * as Stream4 from "effect/Stream";
|
|
62
|
-
import { useMemo as useMemo4 } from "react";
|
|
63
|
-
import { Identity as Identity4, Space } from "@dxos/halo";
|
|
64
|
-
var EMPTY3 = [];
|
|
65
|
-
var useSpaceInvitations = (spaceId) => {
|
|
66
|
-
const services = useHaloServices();
|
|
67
|
-
const atom = useMemo4(() => Atom4.make((spaceId ? Space.invitations(spaceId) : Stream4.empty).pipe(Stream4.provideContext(services))), [
|
|
68
|
-
services,
|
|
69
|
-
spaceId
|
|
70
|
-
]);
|
|
71
|
-
return Result4.getOrElse(useAtomValue4(atom), () => EMPTY3);
|
|
72
|
-
};
|
|
73
|
-
var useHaloInvitations = () => {
|
|
74
|
-
const services = useHaloServices();
|
|
75
|
-
const atom = useMemo4(() => Atom4.make(Identity4.invitations.pipe(Stream4.provideContext(services))), [
|
|
76
|
-
services
|
|
77
|
-
]);
|
|
78
|
-
return Result4.getOrElse(useAtomValue4(atom), () => EMPTY3);
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
// src/useMembers.ts
|
|
82
|
-
import { Atom as Atom5, Result as Result5, useAtomValue as useAtomValue5 } from "@effect-atom/atom-react";
|
|
83
|
-
import * as Stream5 from "effect/Stream";
|
|
84
|
-
import { useMemo as useMemo5 } from "react";
|
|
85
|
-
import { Space as Space2 } from "@dxos/halo";
|
|
86
|
-
var EMPTY4 = [];
|
|
87
|
-
var useMembers = (spaceId) => {
|
|
88
|
-
const services = useHaloServices();
|
|
89
|
-
const atom = useMemo5(() => Atom5.make((spaceId ? Space2.members(spaceId) : Stream5.empty).pipe(Stream5.provideContext(services))), [
|
|
90
|
-
services,
|
|
91
|
-
spaceId
|
|
92
|
-
]);
|
|
93
|
-
return Result5.getOrElse(useAtomValue5(atom), () => EMPTY4);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
// src/useSpaces.ts
|
|
97
|
-
import { Atom as Atom6, Result as Result6, useAtomValue as useAtomValue6 } from "@effect-atom/atom-react";
|
|
98
|
-
import * as Stream6 from "effect/Stream";
|
|
99
|
-
import { useMemo as useMemo6 } from "react";
|
|
100
|
-
import { Space as Space3 } from "@dxos/halo";
|
|
101
|
-
var EMPTY5 = [];
|
|
102
|
-
var useSpaces = ({ all = false } = {}) => {
|
|
103
|
-
const services = useHaloServices();
|
|
104
|
-
const atom = useMemo6(() => Atom6.make(Space3.spaces.pipe(Stream6.provideContext(services))), [
|
|
105
|
-
services
|
|
106
|
-
]);
|
|
107
|
-
const spaces = Result6.getOrElse(useAtomValue6(atom), () => EMPTY5);
|
|
108
|
-
return useMemo6(() => all ? spaces : spaces.filter((space) => space.state === "ready"), [
|
|
109
|
-
spaces,
|
|
110
|
-
all
|
|
111
|
-
]);
|
|
112
|
-
};
|
|
113
|
-
var useSpace = (spaceId) => {
|
|
114
|
-
const spaces = useSpaces({
|
|
115
|
-
all: true
|
|
116
|
-
});
|
|
117
|
-
return useMemo6(() => spaceId ? spaces.find((space) => space.id === spaceId) : void 0, [
|
|
118
|
-
spaces,
|
|
119
|
-
spaceId
|
|
120
|
-
]);
|
|
121
|
-
};
|
|
122
|
-
export {
|
|
123
|
-
HaloProvider,
|
|
124
|
-
useCredentials,
|
|
125
|
-
useDevices,
|
|
126
|
-
useHaloInvitations,
|
|
127
|
-
useHaloServices,
|
|
128
|
-
useIdentity,
|
|
129
|
-
useMembers,
|
|
130
|
-
useSpace,
|
|
131
|
-
useSpaceInvitations,
|
|
132
|
-
useSpaces
|
|
133
|
-
};
|
|
134
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/HaloProvider.tsx", "../../../src/useCredentials.ts", "../../../src/useDevices.ts", "../../../src/useIdentity.ts", "../../../src/useInvitations.ts", "../../../src/useMembers.ts", "../../../src/useSpaces.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\nimport React, { type PropsWithChildren, createContext, useContext } from 'react';\n\nimport { type Identity, type Space } from '@dxos/halo';\n\n/**\n * The HALO services, as the tag union carried in an Effect service {@link Context.Context}.\n */\nexport type HaloServices = Identity.Service | Space.Service;\n\n/**\n * React context carrying the HALO services. Hooks read it, provide it into a service stream, and\n * surface the result through the default {@link Atom} runtime.\n */\nconst HaloServicesContext = createContext<Context.Context<HaloServices> | undefined>(undefined);\n\nexport type HaloProviderProps = PropsWithChildren<{\n /**\n * The HALO services context. Build it from a concrete backing — e.g. the client adapter's\n * `makeIdentityService` / `makeSpaceService` from `@dxos/halo-adapter-client` — and pass it\n * here.\n */\n services: Context.Context<HaloServices>;\n}>;\n\n/**\n * Provides the HALO services to the hook library. Wrap the application (or the subtree that uses\n * the hooks) in this provider. Replaces `ClientProvider` for HALO concerns.\n */\nexport const HaloProvider = ({ services, children }: HaloProviderProps) => (\n <HaloServicesContext.Provider value={services}>{children}</HaloServicesContext.Provider>\n);\n\n/**\n * Returns the HALO services context. Throws if no {@link HaloProvider} is above in the tree.\n */\nexport const useHaloServices = (): Context.Context<HaloServices> => {\n const services = useContext(HaloServicesContext);\n if (!services) {\n throw new Error('Missing HaloProvider.');\n }\n return services;\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { Atom, Result, useAtomValue } from '@effect-atom/atom-react';\nimport * as Stream from 'effect/Stream';\nimport { useMemo } from 'react';\n\nimport { Identity } from '@dxos/halo';\n\nimport { useHaloServices } from './HaloProvider';\n\nconst EMPTY: readonly Identity.Credential[] = [];\n\n/**\n * Returns the local identity's HALO credentials. Reactive: re-renders when credentials are\n * written. Replaces `@dxos/react-client`'s `useCredentials`.\n */\nexport const useCredentials = (): readonly Identity.Credential[] => {\n const services = useHaloServices();\n const atom = useMemo(() => Atom.make(Identity.credentials.pipe(Stream.provideContext(services))), [services]);\n return Result.getOrElse(useAtomValue(atom), () => EMPTY);\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { Atom, Result, useAtomValue } from '@effect-atom/atom-react';\nimport * as Stream from 'effect/Stream';\nimport { useMemo } from 'react';\n\nimport { Identity } from '@dxos/halo';\n\nimport { useHaloServices } from './HaloProvider';\n\nconst EMPTY: readonly Identity.DeviceInfo[] = [];\n\n/**\n * Returns the devices belonging to the local identity. Reactive. Replaces\n * `@dxos/react-client`'s `useDevices`.\n */\nexport const useDevices = (): readonly Identity.DeviceInfo[] => {\n const services = useHaloServices();\n const atom = useMemo(() => Atom.make(Identity.devices.pipe(Stream.provideContext(services))), [services]);\n return Result.getOrElse(useAtomValue(atom), () => EMPTY);\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { Atom, Result, useAtomValue } from '@effect-atom/atom-react';\nimport * as Option from 'effect/Option';\nimport * as Stream from 'effect/Stream';\nimport { useMemo } from 'react';\n\nimport { Identity } from '@dxos/halo';\n\nimport { useHaloServices } from './HaloProvider';\n\n/**\n * Returns the local identity, or `undefined` if none exists. Reactive: re-renders when the\n * identity is created or its profile changes. Replaces `@dxos/react-client`'s `useIdentity`.\n */\nexport const useIdentity = (): Identity.Info | undefined => {\n const services = useHaloServices();\n const atom = useMemo(\n () => Atom.make(Identity.identity.pipe(Stream.provideContext(services), Stream.map(Option.getOrUndefined))),\n [services],\n );\n return Result.getOrElse(useAtomValue(atom), () => undefined);\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { Atom, Result, useAtomValue } from '@effect-atom/atom-react';\nimport * as Stream from 'effect/Stream';\nimport { useMemo } from 'react';\n\nimport { Identity, type Invitation, Space } from '@dxos/halo';\nimport { type SpaceId } from '@dxos/keys';\n\nimport { useHaloServices } from './HaloProvider';\n\nconst EMPTY: readonly Invitation.Flow[] = [];\n\n/**\n * Returns the active (host-created) invitation flows for a space. Reactive. Replaces\n * `@dxos/react-client`'s `useSpaceInvitations`. Drive an individual flow through the\n * `Invitation` verbs (`events` / `authenticate` / `cancel` / `code`).\n */\nexport const useSpaceInvitations = (spaceId?: SpaceId): readonly Invitation.Flow[] => {\n const services = useHaloServices();\n const atom = useMemo(\n () => Atom.make((spaceId ? Space.invitations(spaceId) : Stream.empty).pipe(Stream.provideContext(services))),\n [services, spaceId],\n );\n return Result.getOrElse(useAtomValue(atom), () => EMPTY);\n};\n\n/**\n * Returns the active device-invitation flows for the local identity. Reactive. Replaces\n * `useHaloInvitations`.\n */\nexport const useHaloInvitations = (): readonly Invitation.Flow[] => {\n const services = useHaloServices();\n const atom = useMemo(() => Atom.make(Identity.invitations.pipe(Stream.provideContext(services))), [services]);\n return Result.getOrElse(useAtomValue(atom), () => EMPTY);\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { Atom, Result, useAtomValue } from '@effect-atom/atom-react';\nimport * as Stream from 'effect/Stream';\nimport { useMemo } from 'react';\n\nimport { Space } from '@dxos/halo';\nimport { type SpaceId } from '@dxos/keys';\n\nimport { useHaloServices } from './HaloProvider';\n\nconst EMPTY: readonly Space.Member[] = [];\n\n/**\n * Returns the membership of a space. Reactive: re-renders on join/leave/role/presence changes.\n * Replaces `@dxos/react-client`'s `useMembers` (which took a `PublicKey`; this takes a\n * {@link SpaceId}).\n */\nexport const useMembers = (spaceId?: SpaceId): readonly Space.Member[] => {\n const services = useHaloServices();\n const atom = useMemo(\n () => Atom.make((spaceId ? Space.members(spaceId) : Stream.empty).pipe(Stream.provideContext(services))),\n [services, spaceId],\n );\n return Result.getOrElse(useAtomValue(atom), () => EMPTY);\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { Atom, Result, useAtomValue } from '@effect-atom/atom-react';\nimport * as Stream from 'effect/Stream';\nimport { useMemo } from 'react';\n\nimport { Space } from '@dxos/halo';\nimport { type SpaceId } from '@dxos/keys';\n\nimport { useHaloServices } from './HaloProvider';\n\nconst EMPTY: readonly Space.Info[] = [];\n\nexport type UseSpacesOptions = {\n /** Include spaces that are not yet `ready` (default: only `ready` spaces). */\n all?: boolean;\n};\n\n/**\n * Returns the spaces known to the local identity. By default only `ready` spaces are returned;\n * pass `{ all: true }` for every space. Reactive. Replaces `@dxos/react-client`'s `useSpaces`.\n */\nexport const useSpaces = ({ all = false }: UseSpacesOptions = {}): readonly Space.Info[] => {\n const services = useHaloServices();\n const atom = useMemo(() => Atom.make(Space.spaces.pipe(Stream.provideContext(services))), [services]);\n const spaces = Result.getOrElse(useAtomValue(atom), () => EMPTY);\n return useMemo(() => (all ? spaces : spaces.filter((space) => space.state === 'ready')), [spaces, all]);\n};\n\n/**\n * Resolves a single space by id, or `undefined`. Reactive. Replaces `useSpace`. Unlike the\n * legacy hook this takes a {@link SpaceId} only (no `PublicKey`).\n */\nexport const useSpace = (spaceId?: SpaceId): Space.Info | undefined => {\n const spaces = useSpaces({ all: true });\n return useMemo(() => (spaceId ? spaces.find((space) => space.id === spaceId) : undefined), [spaces, spaceId]);\n};\n"],
|
|
5
|
-
"mappings": ";;;AAKA,OAAOA,SAAiC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,MAAMC,MAAKC,MAAMN,UAAUO,OAAMC,QAAQR,OAAAA,IAAkBS,eAAOC,KAAYC,uBAAeV,QAAAA,CAAAA,CAAAA,GAC7F;IAACA;IAAUD;GAAQ;AAErB,SAAOY,QAAOC,UAAUC,cAAaX,IAAAA,GAAO,MAAML,MAAAA;AACpD;;;ACvBA,SAASiB,QAAAA,OAAMC,UAAAA,SAAQC,gBAAAA,qBAAoB;AAC3C,YAAYC,aAAY;AACxB,SAASC,WAAAA,gBAAe;AAExB,SAASC,SAAAA,cAAa;AAKtB,IAAMC,SAA+B,CAAA;AAW9B,IAAMC,YAAY,CAAC,EAAEC,MAAM,MAAK,IAAuB,CAAC,MAAC;AAC9D,QAAMC,WAAWC,gBAAAA;AACjB,QAAMC,OAAOC,SAAQ,MAAMC,MAAKC,KAAKC,OAAMC,OAAOC,KAAYC,uBAAeT,QAAAA,CAAAA,CAAAA,GAAa;IAACA;GAAS;AACpG,QAAMO,SAASG,QAAOC,UAAUC,cAAaV,IAAAA,GAAO,MAAML,MAAAA;AAC1D,SAAOM,SAAQ,MAAOJ,MAAMQ,SAASA,OAAOM,OAAO,CAACC,UAAUA,MAAMC,UAAU,OAAA,GAAW;IAACR;IAAQR;GAAI;AACxG;AAMO,IAAMiB,WAAW,CAACC,YAAAA;AACvB,QAAMV,SAAST,UAAU;IAAEC,KAAK;EAAK,CAAA;AACrC,SAAOI,SAAQ,MAAOc,UAAUV,OAAOW,KAAK,CAACJ,UAAUA,MAAMK,OAAOF,OAAAA,IAAWG,QAAY;IAACb;IAAQU;GAAQ;AAC9G;",
|
|
6
|
-
"names": ["React", "createContext", "useContext", "HaloServicesContext", "undefined", "HaloProvider", "services", "children", "Provider", "value", "useHaloServices", "Error", "Atom", "Result", "useAtomValue", "Stream", "useMemo", "Identity", "EMPTY", "useCredentials", "services", "useHaloServices", "atom", "useMemo", "Atom", "make", "Identity", "credentials", "pipe", "provideContext", "Result", "getOrElse", "useAtomValue", "Atom", "Result", "useAtomValue", "Stream", "useMemo", "Identity", "EMPTY", "useDevices", "services", "useHaloServices", "atom", "useMemo", "Atom", "make", "Identity", "devices", "pipe", "provideContext", "Result", "getOrElse", "useAtomValue", "Atom", "Result", "useAtomValue", "Option", "Stream", "useMemo", "Identity", "useIdentity", "services", "useHaloServices", "atom", "useMemo", "Atom", "make", "Identity", "identity", "pipe", "provideContext", "map", "getOrUndefined", "Result", "getOrElse", "useAtomValue", "undefined", "Atom", "Result", "useAtomValue", "Stream", "useMemo", "Identity", "Space", "EMPTY", "useSpaceInvitations", "spaceId", "services", "useHaloServices", "atom", "useMemo", "Atom", "make", "Space", "invitations", "empty", "pipe", "provideContext", "Result", "getOrElse", "useAtomValue", "useHaloInvitations", "Identity", "Atom", "Result", "useAtomValue", "Stream", "useMemo", "Space", "EMPTY", "useMembers", "spaceId", "services", "useHaloServices", "atom", "useMemo", "Atom", "make", "Space", "members", "empty", "pipe", "provideContext", "Result", "getOrElse", "useAtomValue", "Atom", "Result", "useAtomValue", "Stream", "useMemo", "Space", "EMPTY", "useSpaces", "all", "services", "useHaloServices", "atom", "useMemo", "Atom", "make", "Space", "spaces", "pipe", "provideContext", "Result", "getOrElse", "useAtomValue", "filter", "space", "state", "useSpace", "spaceId", "find", "id", "undefined"]
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"inputs":{"src/HaloProvider.tsx":{"bytes":4067,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/useCredentials.ts":{"bytes":2751,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/halo","kind":"import-statement","external":true},{"path":"src/HaloProvider.tsx","kind":"import-statement","original":"./HaloProvider"}],"format":"esm"},"src/useDevices.ts":{"bytes":2624,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/halo","kind":"import-statement","external":true},{"path":"src/HaloProvider.tsx","kind":"import-statement","original":"./HaloProvider"}],"format":"esm"},"src/useIdentity.ts":{"bytes":3007,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/halo","kind":"import-statement","external":true},{"path":"src/HaloProvider.tsx","kind":"import-statement","original":"./HaloProvider"}],"format":"esm"},"src/useInvitations.ts":{"bytes":4621,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/halo","kind":"import-statement","external":true},{"path":"src/HaloProvider.tsx","kind":"import-statement","original":"./HaloProvider"}],"format":"esm"},"src/useMembers.ts":{"bytes":3124,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/halo","kind":"import-statement","external":true},{"path":"src/HaloProvider.tsx","kind":"import-statement","original":"./HaloProvider"}],"format":"esm"},"src/useSpaces.ts":{"bytes":4853,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/halo","kind":"import-statement","external":true},{"path":"src/HaloProvider.tsx","kind":"import-statement","original":"./HaloProvider"}],"format":"esm"},"src/index.ts":{"bytes":972,"imports":[{"path":"src/HaloProvider.tsx","kind":"import-statement","original":"./HaloProvider"},{"path":"src/useCredentials.ts","kind":"import-statement","original":"./useCredentials"},{"path":"src/useDevices.ts","kind":"import-statement","original":"./useDevices"},{"path":"src/useIdentity.ts","kind":"import-statement","original":"./useIdentity"},{"path":"src/useInvitations.ts","kind":"import-statement","original":"./useInvitations"},{"path":"src/useMembers.ts","kind":"import-statement","original":"./useMembers"},{"path":"src/useSpaces.ts","kind":"import-statement","original":"./useSpaces"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":13113},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/halo","kind":"import-statement","external":true},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/halo","kind":"import-statement","external":true},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/halo","kind":"import-statement","external":true},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/halo","kind":"import-statement","external":true},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/halo","kind":"import-statement","external":true},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/halo","kind":"import-statement","external":true}],"exports":["HaloProvider","useCredentials","useDevices","useHaloInvitations","useHaloServices","useIdentity","useMembers","useSpace","useSpaceInvitations","useSpaces"],"entryPoint":"src/index.ts","inputs":{"src/HaloProvider.tsx":{"bytesInOutput":443},"src/index.ts":{"bytesInOutput":0},"src/useCredentials.ts":{"bytesInOutput":450},"src/useDevices.ts":{"bytesInOutput":513},"src/useIdentity.ts":{"bytesInOutput":575},"src/useInvitations.ts":{"bytesInOutput":848},"src/useMembers.ts":{"bytesInOutput":561},"src/useSpaces.ts":{"bytesInOutput":851}},"bytes":4710}}}
|