@dxos/plugin-client 0.7.5-main.9d26e3a → 0.7.5-main.9d2a38b
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/app-graph-builder-6LOTDB4T.mjs +44 -0
- package/dist/lib/browser/app-graph-builder-6LOTDB4T.mjs.map +7 -0
- package/dist/lib/browser/chunk-6IF6PREG.mjs +158 -0
- package/dist/lib/browser/chunk-6IF6PREG.mjs.map +7 -0
- package/dist/lib/browser/{chunk-52IJQ35F.mjs → chunk-E3OUNOEL.mjs} +4 -6
- package/dist/lib/browser/chunk-E3OUNOEL.mjs.map +7 -0
- package/dist/lib/browser/{chunk-X4QUPYC6.mjs → chunk-NHIL4T3L.mjs} +3 -3
- package/dist/lib/browser/chunk-NHIL4T3L.mjs.map +7 -0
- package/dist/lib/browser/chunk-R4Q6H7RD.mjs +18 -0
- package/dist/lib/browser/chunk-R4Q6H7RD.mjs.map +7 -0
- package/dist/lib/browser/chunk-SVBQRT7I.mjs +17 -0
- package/dist/lib/browser/chunk-SVBQRT7I.mjs.map +7 -0
- package/dist/lib/browser/client-25GYH6TN.mjs +45 -0
- package/dist/lib/browser/client-25GYH6TN.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +69 -369
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-IWWLWOZD.mjs +132 -0
- package/dist/lib/browser/intent-resolver-IWWLWOZD.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-context-M3RT6SSG.mjs +24 -0
- package/dist/lib/browser/react-context-M3RT6SSG.mjs.map +7 -0
- package/dist/lib/browser/react-surface-XXONPG5T.mjs +41 -0
- package/dist/lib/browser/react-surface-XXONPG5T.mjs.map +7 -0
- package/dist/lib/browser/types.mjs +4 -6
- package/dist/lib/node/app-graph-builder-JCND3P6G.cjs +58 -0
- package/dist/lib/node/app-graph-builder-JCND3P6G.cjs.map +7 -0
- package/dist/lib/node/{meta.cjs → chunk-3OB25QN2.cjs} +14 -8
- package/dist/lib/node/chunk-3OB25QN2.cjs.map +7 -0
- package/dist/lib/node/chunk-IXVWJCYB.cjs +37 -0
- package/dist/lib/node/chunk-IXVWJCYB.cjs.map +7 -0
- package/dist/lib/node/chunk-N3U7KVO3.cjs +186 -0
- package/dist/lib/node/chunk-N3U7KVO3.cjs.map +7 -0
- package/dist/lib/node/{chunk-NFO3ADQC.cjs → chunk-NVYWMDF3.cjs} +8 -11
- package/dist/lib/node/chunk-NVYWMDF3.cjs.map +7 -0
- package/dist/lib/node/{chunk-RUA5KXVW.cjs → chunk-OIFPM5ZW.cjs} +7 -7
- package/dist/lib/node/chunk-OIFPM5ZW.cjs.map +7 -0
- package/dist/lib/node/client-52L4TUYU.cjs +59 -0
- package/dist/lib/node/client-52L4TUYU.cjs.map +7 -0
- package/dist/lib/node/index.cjs +66 -358
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/intent-resolver-H3Y64MIP.cjs +140 -0
- package/dist/lib/node/intent-resolver-H3Y64MIP.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/react-context-B2DNULH4.cjs +48 -0
- package/dist/lib/node/react-context-B2DNULH4.cjs.map +7 -0
- package/dist/lib/node/react-surface-7USN5NOO.cjs +62 -0
- package/dist/lib/node/react-surface-7USN5NOO.cjs.map +7 -0
- package/dist/lib/node/types.cjs +4 -6
- package/dist/lib/node/types.cjs.map +2 -2
- package/dist/lib/node-esm/app-graph-builder-ZLGKFBLY.mjs +45 -0
- package/dist/lib/node-esm/app-graph-builder-ZLGKFBLY.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-73M5MK5Q.mjs +19 -0
- package/dist/lib/node-esm/chunk-73M5MK5Q.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-TI4GNGMM.mjs → chunk-74T33KTB.mjs} +4 -6
- package/dist/lib/node-esm/chunk-74T33KTB.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-EHGD3UJH.mjs +159 -0
- package/dist/lib/node-esm/chunk-EHGD3UJH.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-GMGRQ5Q7.mjs → chunk-HO7WDE7C.mjs} +3 -3
- package/dist/lib/node-esm/chunk-HO7WDE7C.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-OBGRL3DF.mjs +18 -0
- package/dist/lib/node-esm/chunk-OBGRL3DF.mjs.map +7 -0
- package/dist/lib/node-esm/client-K52NWOUN.mjs +46 -0
- package/dist/lib/node-esm/client-K52NWOUN.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +69 -369
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-JCKD6R6L.mjs +133 -0
- package/dist/lib/node-esm/intent-resolver-JCKD6R6L.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-context-IGEHJQK5.mjs +25 -0
- package/dist/lib/node-esm/react-context-IGEHJQK5.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-CXLBCMPN.mjs +42 -0
- package/dist/lib/node-esm/react-surface-CXLBCMPN.mjs.map +7 -0
- package/dist/lib/node-esm/types.mjs +4 -6
- package/dist/types/src/ClientPlugin.d.ts +2 -3
- package/dist/types/src/ClientPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +181 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/capabilities.d.ts +8 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
- package/dist/types/src/capabilities/client.d.ts +9 -0
- package/dist/types/src/capabilities/client.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +193 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts +8 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-context.d.ts +8 -0
- package/dist/types/src/capabilities/react-context.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +7 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/events.d.ts +7 -0
- package/dist/types/src/events.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +5 -17
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -22
- package/src/ClientPlugin.ts +59 -0
- package/src/capabilities/app-graph-builder.ts +39 -0
- package/src/capabilities/capabilities.ts +15 -0
- package/src/capabilities/client.ts +48 -0
- package/src/capabilities/index.ts +13 -0
- package/src/capabilities/intent-resolver.ts +101 -0
- package/src/capabilities/react-context.tsx +20 -0
- package/src/capabilities/react-surface.tsx +44 -0
- package/src/events.ts +14 -0
- package/src/index.ts +4 -4
- package/src/meta.ts +1 -1
- package/src/types.ts +5 -31
- package/dist/lib/browser/chunk-52IJQ35F.mjs.map +0 -7
- package/dist/lib/browser/chunk-X4QUPYC6.mjs.map +0 -7
- package/dist/lib/browser/meta.mjs +0 -9
- package/dist/lib/browser/meta.mjs.map +0 -7
- package/dist/lib/node/chunk-NFO3ADQC.cjs.map +0 -7
- package/dist/lib/node/chunk-RUA5KXVW.cjs.map +0 -7
- package/dist/lib/node/meta.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-GMGRQ5Q7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-TI4GNGMM.mjs.map +0 -7
- package/dist/lib/node-esm/meta.mjs +0 -10
- package/dist/lib/node-esm/meta.mjs.map +0 -7
- package/src/ClientPlugin.tsx +0 -227
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Capabilities,
|
|
7
|
+
contributes,
|
|
8
|
+
createIntent,
|
|
9
|
+
createResolver,
|
|
10
|
+
LayoutAction,
|
|
11
|
+
type PluginsContext,
|
|
12
|
+
} from '@dxos/app-framework';
|
|
13
|
+
import { invariant } from '@dxos/invariant';
|
|
14
|
+
import { ObservabilityAction } from '@dxos/plugin-observability/types';
|
|
15
|
+
import { type JoinPanelProps } from '@dxos/shell/react';
|
|
16
|
+
|
|
17
|
+
import { ClientCapabilities } from './capabilities';
|
|
18
|
+
import { IDENTITY_DIALOG, JOIN_DIALOG, RECOVER_CODE_DIALOG } from '../components';
|
|
19
|
+
import { ClientEvents } from '../events';
|
|
20
|
+
import { ClientAction, type ClientPluginOptions } from '../types';
|
|
21
|
+
|
|
22
|
+
type IntentResolverOptions = Pick<ClientPluginOptions, 'onReset'> & {
|
|
23
|
+
context: PluginsContext;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default ({ context, onReset }: IntentResolverOptions) =>
|
|
27
|
+
contributes(Capabilities.IntentResolver, [
|
|
28
|
+
createResolver(ClientAction.CreateIdentity, async () => {
|
|
29
|
+
const manager = context.requestCapability(Capabilities.PluginManager);
|
|
30
|
+
const client = context.requestCapability(ClientCapabilities.Client);
|
|
31
|
+
const data = await client.halo.createIdentity();
|
|
32
|
+
await manager.activate(ClientEvents.IdentityCreated);
|
|
33
|
+
return { data, intents: [createIntent(ObservabilityAction.SendEvent, { name: 'identity.create' })] };
|
|
34
|
+
}),
|
|
35
|
+
createResolver(ClientAction.JoinIdentity, async (data) => {
|
|
36
|
+
return {
|
|
37
|
+
intents: [
|
|
38
|
+
createIntent(LayoutAction.SetLayout, {
|
|
39
|
+
element: 'dialog',
|
|
40
|
+
component: JOIN_DIALOG,
|
|
41
|
+
dialogBlockAlign: 'start',
|
|
42
|
+
subject: {
|
|
43
|
+
initialInvitationCode: data.invitationCode,
|
|
44
|
+
initialDisposition: 'accept-halo-invitation',
|
|
45
|
+
} satisfies Partial<JoinPanelProps>,
|
|
46
|
+
}),
|
|
47
|
+
],
|
|
48
|
+
};
|
|
49
|
+
}),
|
|
50
|
+
createResolver(ClientAction.ShareIdentity, async () => {
|
|
51
|
+
return {
|
|
52
|
+
intents: [
|
|
53
|
+
createIntent(LayoutAction.SetLayout, {
|
|
54
|
+
element: 'dialog',
|
|
55
|
+
component: IDENTITY_DIALOG,
|
|
56
|
+
dialogBlockAlign: 'start',
|
|
57
|
+
}),
|
|
58
|
+
createIntent(ObservabilityAction.SendEvent, { name: 'identity.share' }),
|
|
59
|
+
],
|
|
60
|
+
};
|
|
61
|
+
}),
|
|
62
|
+
createResolver(ClientAction.RecoverIdentity, async () => {
|
|
63
|
+
return {
|
|
64
|
+
intents: [
|
|
65
|
+
createIntent(LayoutAction.SetLayout, {
|
|
66
|
+
element: 'dialog',
|
|
67
|
+
component: JOIN_DIALOG,
|
|
68
|
+
dialogBlockAlign: 'start',
|
|
69
|
+
subject: { initialDisposition: 'recover-identity' } satisfies Partial<JoinPanelProps>,
|
|
70
|
+
}),
|
|
71
|
+
],
|
|
72
|
+
};
|
|
73
|
+
}),
|
|
74
|
+
createResolver(ClientAction.ResetStorage, async (data) => {
|
|
75
|
+
await onReset?.({ target: data.target });
|
|
76
|
+
return {};
|
|
77
|
+
}),
|
|
78
|
+
createResolver(ClientAction.CreateAgent, async () => {
|
|
79
|
+
const client = context.requestCapability(ClientCapabilities.Client);
|
|
80
|
+
invariant(client.services.services.EdgeAgentService, 'Missing EdgeAgentService');
|
|
81
|
+
await client.services.services.EdgeAgentService.createAgent(null as any, { timeout: 10_000 });
|
|
82
|
+
}),
|
|
83
|
+
createResolver(ClientAction.CreateRecoveryCode, async () => {
|
|
84
|
+
const client = context.requestCapability(ClientCapabilities.Client);
|
|
85
|
+
invariant(client.services.services.IdentityService, 'IdentityService not available');
|
|
86
|
+
// TODO(wittjosiah): This needs a proper api. Rename property.
|
|
87
|
+
const { seedphrase } = await client.services.services.IdentityService.createRecoveryPhrase();
|
|
88
|
+
return {
|
|
89
|
+
intents: [
|
|
90
|
+
createIntent(LayoutAction.SetLayout, {
|
|
91
|
+
element: 'dialog',
|
|
92
|
+
dialogBlockAlign: 'start',
|
|
93
|
+
dialogType: 'alert',
|
|
94
|
+
state: true,
|
|
95
|
+
component: RECOVER_CODE_DIALOG,
|
|
96
|
+
subject: { code: seedphrase },
|
|
97
|
+
}),
|
|
98
|
+
],
|
|
99
|
+
};
|
|
100
|
+
}),
|
|
101
|
+
]);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, contributes, useCapability } from '@dxos/app-framework';
|
|
8
|
+
import { ClientProvider } from '@dxos/react-client';
|
|
9
|
+
|
|
10
|
+
import { ClientCapabilities } from './capabilities';
|
|
11
|
+
import { CLIENT_PLUGIN } from '../meta';
|
|
12
|
+
|
|
13
|
+
export default () =>
|
|
14
|
+
contributes(Capabilities.ReactContext, {
|
|
15
|
+
id: CLIENT_PLUGIN,
|
|
16
|
+
context: ({ children }) => {
|
|
17
|
+
const client = useCapability(ClientCapabilities.Client);
|
|
18
|
+
return <ClientProvider client={client}>{children}</ClientProvider>;
|
|
19
|
+
},
|
|
20
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { createSurface, Capabilities, contributes } from '@dxos/app-framework';
|
|
8
|
+
import { type IdentityPanelProps, type JoinPanelProps } from '@dxos/shell/react';
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
IDENTITY_DIALOG,
|
|
12
|
+
IdentityDialog,
|
|
13
|
+
JOIN_DIALOG,
|
|
14
|
+
JoinDialog,
|
|
15
|
+
RECOVER_CODE_DIALOG,
|
|
16
|
+
RecoveryCodeDialog,
|
|
17
|
+
type RecoveryCodeDialogProps,
|
|
18
|
+
} from '../components';
|
|
19
|
+
|
|
20
|
+
type ReactSurfaceOptions = {
|
|
21
|
+
createInvitationUrl: (invitationCode: string) => string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default ({ createInvitationUrl }: ReactSurfaceOptions) =>
|
|
25
|
+
contributes(Capabilities.ReactSurface, [
|
|
26
|
+
createSurface({
|
|
27
|
+
id: IDENTITY_DIALOG,
|
|
28
|
+
role: 'dialog',
|
|
29
|
+
filter: (data): data is { subject: IdentityPanelProps } => data.component === IDENTITY_DIALOG,
|
|
30
|
+
component: ({ data }) => <IdentityDialog {...data.subject} createInvitationUrl={createInvitationUrl} />,
|
|
31
|
+
}),
|
|
32
|
+
createSurface({
|
|
33
|
+
id: JOIN_DIALOG,
|
|
34
|
+
role: 'dialog',
|
|
35
|
+
filter: (data): data is { subject: JoinPanelProps } => data.component === JOIN_DIALOG,
|
|
36
|
+
component: ({ data }) => <JoinDialog {...data.subject} />,
|
|
37
|
+
}),
|
|
38
|
+
createSurface({
|
|
39
|
+
id: RECOVER_CODE_DIALOG,
|
|
40
|
+
role: 'dialog',
|
|
41
|
+
filter: (data): data is { subject: RecoveryCodeDialogProps } => data.component === RECOVER_CODE_DIALOG,
|
|
42
|
+
component: ({ data }) => <RecoveryCodeDialog {...data.subject} />,
|
|
43
|
+
}),
|
|
44
|
+
]);
|
package/src/events.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { defineEvent } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
import { CLIENT_PLUGIN } from './meta';
|
|
8
|
+
|
|
9
|
+
export namespace ClientEvents {
|
|
10
|
+
export const SetupClient = defineEvent(`${CLIENT_PLUGIN}/event/setup-client`);
|
|
11
|
+
export const ClientReady = defineEvent(`${CLIENT_PLUGIN}/event/client-ready`);
|
|
12
|
+
export const IdentityCreated = defineEvent(`${CLIENT_PLUGIN}/event/identity-created`);
|
|
13
|
+
export const SpacesReady = defineEvent(`${CLIENT_PLUGIN}/event/spaces-ready`);
|
|
14
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { ClientPlugin } from './ClientPlugin';
|
|
6
|
-
|
|
7
|
-
export default ClientPlugin;
|
|
8
|
-
|
|
9
5
|
export * from './ClientPlugin';
|
|
6
|
+
export * from './meta';
|
|
7
|
+
|
|
8
|
+
export { ClientCapabilities } from './capabilities';
|
|
9
|
+
export { ClientEvents } from './events';
|
package/src/meta.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -2,15 +2,10 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
type GraphBuilderProvides,
|
|
7
|
-
type IntentResolverProvides,
|
|
8
|
-
type Plugin,
|
|
9
|
-
type SurfaceProvides,
|
|
10
|
-
type TranslationsProvides,
|
|
11
|
-
} from '@dxos/app-framework';
|
|
5
|
+
import { type PluginsContext } from '@dxos/app-framework';
|
|
12
6
|
import { S } from '@dxos/echo-schema';
|
|
13
|
-
import { Client, PublicKey, type ClientOptions } from '@dxos/react-client';
|
|
7
|
+
import { type Client, PublicKey, type ClientOptions } from '@dxos/react-client';
|
|
8
|
+
import { type MaybePromise } from '@dxos/util';
|
|
14
9
|
|
|
15
10
|
import { CLIENT_PLUGIN } from './meta';
|
|
16
11
|
|
|
@@ -72,11 +67,6 @@ export namespace ClientAction {
|
|
|
72
67
|
}
|
|
73
68
|
|
|
74
69
|
export type ClientPluginOptions = ClientOptions & {
|
|
75
|
-
/**
|
|
76
|
-
* Used to track app-specific state in spaces.
|
|
77
|
-
*/
|
|
78
|
-
appKey: string;
|
|
79
|
-
|
|
80
70
|
/**
|
|
81
71
|
* Base URL for the invitation link.
|
|
82
72
|
*/
|
|
@@ -90,26 +80,10 @@ export type ClientPluginOptions = ClientOptions & {
|
|
|
90
80
|
/**
|
|
91
81
|
* Run after the client has been initialized.
|
|
92
82
|
*/
|
|
93
|
-
onClientInitialized?: (client: Client) =>
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Run after the identity has been successfully initialized.
|
|
97
|
-
* Run with client during plugin ready phase.
|
|
98
|
-
*/
|
|
99
|
-
onReady?: (client: Client, plugins: Plugin[]) => Promise<void>;
|
|
83
|
+
onClientInitialized?: (context: PluginsContext, client: Client) => MaybePromise<void>;
|
|
100
84
|
|
|
101
85
|
/**
|
|
102
86
|
* Called when the client is reset.
|
|
103
87
|
*/
|
|
104
|
-
onReset?: (params: { target?: string }) =>
|
|
88
|
+
onReset?: (params: { target?: string }) => MaybePromise<void>;
|
|
105
89
|
};
|
|
106
|
-
|
|
107
|
-
export type ClientPluginProvides = IntentResolverProvides &
|
|
108
|
-
GraphBuilderProvides &
|
|
109
|
-
SurfaceProvides &
|
|
110
|
-
TranslationsProvides & {
|
|
111
|
-
client: Client;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
export const parseClientPlugin = (plugin?: Plugin) =>
|
|
115
|
-
(plugin?.provides as any).client instanceof Client ? (plugin as Plugin<ClientPluginProvides>) : undefined;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport {\n type GraphBuilderProvides,\n type IntentResolverProvides,\n type Plugin,\n type SurfaceProvides,\n type TranslationsProvides,\n} from '@dxos/app-framework';\nimport { S } from '@dxos/echo-schema';\nimport { Client, PublicKey, type ClientOptions } from '@dxos/react-client';\n\nimport { CLIENT_PLUGIN } from './meta';\n\n// TODO(wittjosiah): Factor out. Generate?\nconst IdentitySchema = S.Struct({\n identityKey: S.instanceOf(PublicKey),\n spaceKey: S.optional(S.instanceOf(PublicKey)),\n profile: S.optional(\n S.Struct({\n displayName: S.optional(S.String),\n avatarCid: S.optional(S.String),\n data: S.optional(S.Record({ key: S.String, value: S.Any })),\n }),\n ),\n});\n\nconst CLIENT_ACTION = `${CLIENT_PLUGIN}/action`;\nexport namespace ClientAction {\n export class CreateIdentity extends S.TaggedClass<CreateIdentity>()(`${CLIENT_ACTION}/create-identity`, {\n input: S.Struct({\n displayName: S.optional(S.String),\n }),\n output: IdentitySchema,\n }) {}\n\n export class JoinIdentity extends S.TaggedClass<JoinIdentity>()(`${CLIENT_ACTION}/join-identity`, {\n input: S.Struct({\n invitationCode: S.String,\n }),\n output: S.Void,\n }) {}\n\n export class ShareIdentity extends S.TaggedClass<ShareIdentity>()(`${CLIENT_ACTION}/share-identity`, {\n input: S.Void,\n output: S.Void,\n }) {}\n\n export class RecoverIdentity extends S.TaggedClass<RecoverIdentity>()(`${CLIENT_ACTION}/recover-identity`, {\n input: S.Void,\n output: S.Void,\n }) {}\n\n export class ResetStorage extends S.TaggedClass<ResetStorage>()(`${CLIENT_ACTION}/reset-storage`, {\n input: S.Struct({\n target: S.optional(S.String),\n }),\n output: S.Void,\n }) {}\n\n export class CreateAgent extends S.TaggedClass<CreateAgent>()(`${CLIENT_ACTION}/create-agent`, {\n input: S.Void,\n output: S.Void,\n }) {}\n\n export class CreateRecoveryCode extends S.TaggedClass<CreateRecoveryCode>()(`${CLIENT_ACTION}/create-recovery-code`, {\n input: S.Void,\n output: S.Void,\n }) {}\n}\n\nexport type ClientPluginOptions = ClientOptions & {\n /**\n * Used to track app-specific state in spaces.\n */\n appKey: string;\n\n /**\n * Base URL for the invitation link.\n */\n invitationUrl?: string;\n\n /**\n * Query parameter for the invitation code.\n */\n invitationParam?: string;\n\n /**\n * Run after the client has been initialized.\n */\n onClientInitialized?: (client: Client) => Promise<void>;\n\n /**\n * Run after the identity has been successfully initialized.\n * Run with client during plugin ready phase.\n */\n onReady?: (client: Client, plugins: Plugin[]) => Promise<void>;\n\n /**\n * Called when the client is reset.\n */\n onReset?: (params: { target?: string }) => Promise<void>;\n};\n\nexport type ClientPluginProvides = IntentResolverProvides &\n GraphBuilderProvides &\n SurfaceProvides &\n TranslationsProvides & {\n client: Client;\n };\n\nexport const parseClientPlugin = (plugin?: Plugin) =>\n (plugin?.provides as any).client instanceof Client ? (plugin as Plugin<ClientPluginProvides>) : undefined;\n"],
|
|
5
|
-
"mappings": ";;;;;AAWA,SAASA,SAAS;AAClB,SAASC,QAAQC,iBAAqC;AAKtD,IAAMC,iBAAiBC,EAAEC,OAAO;EAC9BC,aAAaF,EAAEG,WAAWC,SAAAA;EAC1BC,UAAUL,EAAEM,SAASN,EAAEG,WAAWC,SAAAA,CAAAA;EAClCG,SAASP,EAAEM,SACTN,EAAEC,OAAO;IACPO,aAAaR,EAAEM,SAASN,EAAES,MAAM;IAChCC,WAAWV,EAAEM,SAASN,EAAES,MAAM;IAC9BE,MAAMX,EAAEM,SAASN,EAAEY,OAAO;MAAEC,KAAKb,EAAES;MAAQK,OAAOd,EAAEe;IAAI,CAAA,CAAA;EAC1D,CAAA,CAAA;AAEJ,CAAA;AAEA,IAAMC,gBAAgB,GAAGC,aAAAA;;UACRC,eAAAA;EACR,MAAMC,uBAAuBnB,EAAEoB,YAAW,EAAmB,GAAGJ,aAAAA,oBAAiC;IACtGK,OAAOrB,EAAEC,OAAO;MACdO,aAAaR,EAAEM,SAASN,EAAES,MAAM;IAClC,CAAA;IACAa,QAAQvB;EACV,CAAA,EAAA;EAAI;gBALSoB,iBAAAA;EAON,MAAMI,qBAAqBvB,EAAEoB,YAAW,EAAiB,GAAGJ,aAAAA,kBAA+B;IAChGK,OAAOrB,EAAEC,OAAO;MACduB,gBAAgBxB,EAAES;IACpB,CAAA;IACAa,QAAQtB,EAAEyB;EACZ,CAAA,EAAA;EAAI;gBALSF,eAAAA;EAON,MAAMG,sBAAsB1B,EAAEoB,YAAW,EAAkB,GAAGJ,aAAAA,mBAAgC;IACnGK,OAAOrB,EAAEyB;IACTH,QAAQtB,EAAEyB;EACZ,CAAA,EAAA;EAAI;gBAHSC,gBAAAA;EAKN,MAAMC,wBAAwB3B,EAAEoB,YAAW,EAAoB,GAAGJ,aAAAA,qBAAkC;IACzGK,OAAOrB,EAAEyB;IACTH,QAAQtB,EAAEyB;EACZ,CAAA,EAAA;EAAI;gBAHSE,kBAAAA;EAKN,MAAMC,qBAAqB5B,EAAEoB,YAAW,EAAiB,GAAGJ,aAAAA,kBAA+B;IAChGK,OAAOrB,EAAEC,OAAO;MACd4B,QAAQ7B,EAAEM,SAASN,EAAES,MAAM;IAC7B,CAAA;IACAa,QAAQtB,EAAEyB;EACZ,CAAA,EAAA;EAAI;gBALSG,eAAAA;EAON,MAAME,oBAAoB9B,EAAEoB,YAAW,EAAgB,GAAGJ,aAAAA,iBAA8B;IAC7FK,OAAOrB,EAAEyB;IACTH,QAAQtB,EAAEyB;EACZ,CAAA,EAAA;EAAI;gBAHSK,cAAAA;EAKN,MAAMC,2BAA2B/B,EAAEoB,YAAW,EAAuB,GAAGJ,aAAAA,yBAAsC;IACnHK,OAAOrB,EAAEyB;IACTH,QAAQtB,EAAEyB;EACZ,CAAA,EAAA;EAAI;gBAHSM,qBAAAA;AAIf,GAzCiBb,iBAAAA,eAAAA,CAAAA,EAAAA;AAmFV,IAAMc,oBAAoB,CAACC,YAC/BA,QAAQC,UAAiBC,kBAAkBC,SAAUH,SAA0CI;",
|
|
6
|
-
"names": ["S", "Client", "PublicKey", "IdentitySchema", "S", "Struct", "identityKey", "instanceOf", "PublicKey", "spaceKey", "optional", "profile", "displayName", "String", "avatarCid", "data", "Record", "key", "value", "Any", "CLIENT_ACTION", "CLIENT_PLUGIN", "ClientAction", "CreateIdentity", "TaggedClass", "input", "output", "JoinIdentity", "invitationCode", "Void", "ShareIdentity", "RecoverIdentity", "ResetStorage", "target", "CreateAgent", "CreateRecoveryCode", "parseClientPlugin", "plugin", "provides", "client", "Client", "undefined"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const CLIENT_PLUGIN = 'dxos.org/plugin/client';\n\nexport default {\n id: CLIENT_PLUGIN,\n name: 'Client',\n} satisfies PluginMeta;\n"],
|
|
5
|
-
"mappings": ";AAMO,IAAMA,gBAAgB;AAE7B,IAAA,eAAe;EACbC,IAAID;EACJE,MAAM;AACR;",
|
|
6
|
-
"names": ["CLIENT_PLUGIN", "id", "name"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport {\n type GraphBuilderProvides,\n type IntentResolverProvides,\n type Plugin,\n type SurfaceProvides,\n type TranslationsProvides,\n} from '@dxos/app-framework';\nimport { S } from '@dxos/echo-schema';\nimport { Client, PublicKey, type ClientOptions } from '@dxos/react-client';\n\nimport { CLIENT_PLUGIN } from './meta';\n\n// TODO(wittjosiah): Factor out. Generate?\nconst IdentitySchema = S.Struct({\n identityKey: S.instanceOf(PublicKey),\n spaceKey: S.optional(S.instanceOf(PublicKey)),\n profile: S.optional(\n S.Struct({\n displayName: S.optional(S.String),\n avatarCid: S.optional(S.String),\n data: S.optional(S.Record({ key: S.String, value: S.Any })),\n }),\n ),\n});\n\nconst CLIENT_ACTION = `${CLIENT_PLUGIN}/action`;\nexport namespace ClientAction {\n export class CreateIdentity extends S.TaggedClass<CreateIdentity>()(`${CLIENT_ACTION}/create-identity`, {\n input: S.Struct({\n displayName: S.optional(S.String),\n }),\n output: IdentitySchema,\n }) {}\n\n export class JoinIdentity extends S.TaggedClass<JoinIdentity>()(`${CLIENT_ACTION}/join-identity`, {\n input: S.Struct({\n invitationCode: S.String,\n }),\n output: S.Void,\n }) {}\n\n export class ShareIdentity extends S.TaggedClass<ShareIdentity>()(`${CLIENT_ACTION}/share-identity`, {\n input: S.Void,\n output: S.Void,\n }) {}\n\n export class RecoverIdentity extends S.TaggedClass<RecoverIdentity>()(`${CLIENT_ACTION}/recover-identity`, {\n input: S.Void,\n output: S.Void,\n }) {}\n\n export class ResetStorage extends S.TaggedClass<ResetStorage>()(`${CLIENT_ACTION}/reset-storage`, {\n input: S.Struct({\n target: S.optional(S.String),\n }),\n output: S.Void,\n }) {}\n\n export class CreateAgent extends S.TaggedClass<CreateAgent>()(`${CLIENT_ACTION}/create-agent`, {\n input: S.Void,\n output: S.Void,\n }) {}\n\n export class CreateRecoveryCode extends S.TaggedClass<CreateRecoveryCode>()(`${CLIENT_ACTION}/create-recovery-code`, {\n input: S.Void,\n output: S.Void,\n }) {}\n}\n\nexport type ClientPluginOptions = ClientOptions & {\n /**\n * Used to track app-specific state in spaces.\n */\n appKey: string;\n\n /**\n * Base URL for the invitation link.\n */\n invitationUrl?: string;\n\n /**\n * Query parameter for the invitation code.\n */\n invitationParam?: string;\n\n /**\n * Run after the client has been initialized.\n */\n onClientInitialized?: (client: Client) => Promise<void>;\n\n /**\n * Run after the identity has been successfully initialized.\n * Run with client during plugin ready phase.\n */\n onReady?: (client: Client, plugins: Plugin[]) => Promise<void>;\n\n /**\n * Called when the client is reset.\n */\n onReset?: (params: { target?: string }) => Promise<void>;\n};\n\nexport type ClientPluginProvides = IntentResolverProvides &\n GraphBuilderProvides &\n SurfaceProvides &\n TranslationsProvides & {\n client: Client;\n };\n\nexport const parseClientPlugin = (plugin?: Plugin) =>\n (plugin?.provides as any).client instanceof Client ? (plugin as Plugin<ClientPluginProvides>) : undefined;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAWA,yBAAkB;AAClB,0BAAsD;AAKtD,IAAMA,iBAAiBC,qBAAEC,OAAO;EAC9BC,aAAaF,qBAAEG,WAAWC,6BAAAA;EAC1BC,UAAUL,qBAAEM,SAASN,qBAAEG,WAAWC,6BAAAA,CAAAA;EAClCG,SAASP,qBAAEM,SACTN,qBAAEC,OAAO;IACPO,aAAaR,qBAAEM,SAASN,qBAAES,MAAM;IAChCC,WAAWV,qBAAEM,SAASN,qBAAES,MAAM;IAC9BE,MAAMX,qBAAEM,SAASN,qBAAEY,OAAO;MAAEC,KAAKb,qBAAES;MAAQK,OAAOd,qBAAEe;IAAI,CAAA,CAAA;EAC1D,CAAA,CAAA;AAEJ,CAAA;AAEA,IAAMC,gBAAgB,GAAGC,mCAAAA;;UACRC,eAAAA;EACR,MAAMC,uBAAuBnB,qBAAEoB,YAAW,EAAmB,GAAGJ,aAAAA,oBAAiC;IACtGK,OAAOrB,qBAAEC,OAAO;MACdO,aAAaR,qBAAEM,SAASN,qBAAES,MAAM;IAClC,CAAA;IACAa,QAAQvB;EACV,CAAA,EAAA;EAAI;gBALSoB,iBAAAA;EAON,MAAMI,qBAAqBvB,qBAAEoB,YAAW,EAAiB,GAAGJ,aAAAA,kBAA+B;IAChGK,OAAOrB,qBAAEC,OAAO;MACduB,gBAAgBxB,qBAAES;IACpB,CAAA;IACAa,QAAQtB,qBAAEyB;EACZ,CAAA,EAAA;EAAI;gBALSF,eAAAA;EAON,MAAMG,sBAAsB1B,qBAAEoB,YAAW,EAAkB,GAAGJ,aAAAA,mBAAgC;IACnGK,OAAOrB,qBAAEyB;IACTH,QAAQtB,qBAAEyB;EACZ,CAAA,EAAA;EAAI;gBAHSC,gBAAAA;EAKN,MAAMC,wBAAwB3B,qBAAEoB,YAAW,EAAoB,GAAGJ,aAAAA,qBAAkC;IACzGK,OAAOrB,qBAAEyB;IACTH,QAAQtB,qBAAEyB;EACZ,CAAA,EAAA;EAAI;gBAHSE,kBAAAA;EAKN,MAAMC,qBAAqB5B,qBAAEoB,YAAW,EAAiB,GAAGJ,aAAAA,kBAA+B;IAChGK,OAAOrB,qBAAEC,OAAO;MACd4B,QAAQ7B,qBAAEM,SAASN,qBAAES,MAAM;IAC7B,CAAA;IACAa,QAAQtB,qBAAEyB;EACZ,CAAA,EAAA;EAAI;gBALSG,eAAAA;EAON,MAAME,oBAAoB9B,qBAAEoB,YAAW,EAAgB,GAAGJ,aAAAA,iBAA8B;IAC7FK,OAAOrB,qBAAEyB;IACTH,QAAQtB,qBAAEyB;EACZ,CAAA,EAAA;EAAI;gBAHSK,cAAAA;EAKN,MAAMC,2BAA2B/B,qBAAEoB,YAAW,EAAuB,GAAGJ,aAAAA,yBAAsC;IACnHK,OAAOrB,qBAAEyB;IACTH,QAAQtB,qBAAEyB;EACZ,CAAA,EAAA;EAAI;gBAHSM,qBAAAA;AAIf,GAzCiBb,iBAAAA,eAAAA,CAAAA,EAAAA;AAmFV,IAAMc,oBAAoB,CAACC,YAC/BA,QAAQC,UAAiBC,kBAAkBC,6BAAUH,SAA0CI;",
|
|
6
|
-
"names": ["IdentitySchema", "S", "Struct", "identityKey", "instanceOf", "PublicKey", "spaceKey", "optional", "profile", "displayName", "String", "avatarCid", "data", "Record", "key", "value", "Any", "CLIENT_ACTION", "CLIENT_PLUGIN", "ClientAction", "CreateIdentity", "TaggedClass", "input", "output", "JoinIdentity", "invitationCode", "Void", "ShareIdentity", "RecoverIdentity", "ResetStorage", "target", "CreateAgent", "CreateRecoveryCode", "parseClientPlugin", "plugin", "provides", "client", "Client", "undefined"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const CLIENT_PLUGIN = 'dxos.org/plugin/client';\n\nexport default {\n id: CLIENT_PLUGIN,\n name: 'Client',\n} satisfies PluginMeta;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAMO,IAAMA,gBAAgB;AAE7B,IAAA,eAAe;EACbC,IAAID;EACJE,MAAM;AACR;",
|
|
6
|
-
"names": ["CLIENT_PLUGIN", "id", "name"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["meta.cjs"],
|
|
4
|
-
"sourcesContent": ["import {\n CLIENT_PLUGIN,\n meta_default\n} from \"./chunk-RUA5KXVW.cjs\";\nexport {\n CLIENT_PLUGIN,\n meta_default as default\n};\n//# sourceMappingURL=meta.cjs.map\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAGO;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const CLIENT_PLUGIN = 'dxos.org/plugin/client';\n\nexport default {\n id: CLIENT_PLUGIN,\n name: 'Client',\n} satisfies PluginMeta;\n"],
|
|
5
|
-
"mappings": ";;;AAMO,IAAMA,gBAAgB;AAE7B,IAAA,eAAe;EACbC,IAAID;EACJE,MAAM;AACR;",
|
|
6
|
-
"names": ["CLIENT_PLUGIN", "id", "name"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport {\n type GraphBuilderProvides,\n type IntentResolverProvides,\n type Plugin,\n type SurfaceProvides,\n type TranslationsProvides,\n} from '@dxos/app-framework';\nimport { S } from '@dxos/echo-schema';\nimport { Client, PublicKey, type ClientOptions } from '@dxos/react-client';\n\nimport { CLIENT_PLUGIN } from './meta';\n\n// TODO(wittjosiah): Factor out. Generate?\nconst IdentitySchema = S.Struct({\n identityKey: S.instanceOf(PublicKey),\n spaceKey: S.optional(S.instanceOf(PublicKey)),\n profile: S.optional(\n S.Struct({\n displayName: S.optional(S.String),\n avatarCid: S.optional(S.String),\n data: S.optional(S.Record({ key: S.String, value: S.Any })),\n }),\n ),\n});\n\nconst CLIENT_ACTION = `${CLIENT_PLUGIN}/action`;\nexport namespace ClientAction {\n export class CreateIdentity extends S.TaggedClass<CreateIdentity>()(`${CLIENT_ACTION}/create-identity`, {\n input: S.Struct({\n displayName: S.optional(S.String),\n }),\n output: IdentitySchema,\n }) {}\n\n export class JoinIdentity extends S.TaggedClass<JoinIdentity>()(`${CLIENT_ACTION}/join-identity`, {\n input: S.Struct({\n invitationCode: S.String,\n }),\n output: S.Void,\n }) {}\n\n export class ShareIdentity extends S.TaggedClass<ShareIdentity>()(`${CLIENT_ACTION}/share-identity`, {\n input: S.Void,\n output: S.Void,\n }) {}\n\n export class RecoverIdentity extends S.TaggedClass<RecoverIdentity>()(`${CLIENT_ACTION}/recover-identity`, {\n input: S.Void,\n output: S.Void,\n }) {}\n\n export class ResetStorage extends S.TaggedClass<ResetStorage>()(`${CLIENT_ACTION}/reset-storage`, {\n input: S.Struct({\n target: S.optional(S.String),\n }),\n output: S.Void,\n }) {}\n\n export class CreateAgent extends S.TaggedClass<CreateAgent>()(`${CLIENT_ACTION}/create-agent`, {\n input: S.Void,\n output: S.Void,\n }) {}\n\n export class CreateRecoveryCode extends S.TaggedClass<CreateRecoveryCode>()(`${CLIENT_ACTION}/create-recovery-code`, {\n input: S.Void,\n output: S.Void,\n }) {}\n}\n\nexport type ClientPluginOptions = ClientOptions & {\n /**\n * Used to track app-specific state in spaces.\n */\n appKey: string;\n\n /**\n * Base URL for the invitation link.\n */\n invitationUrl?: string;\n\n /**\n * Query parameter for the invitation code.\n */\n invitationParam?: string;\n\n /**\n * Run after the client has been initialized.\n */\n onClientInitialized?: (client: Client) => Promise<void>;\n\n /**\n * Run after the identity has been successfully initialized.\n * Run with client during plugin ready phase.\n */\n onReady?: (client: Client, plugins: Plugin[]) => Promise<void>;\n\n /**\n * Called when the client is reset.\n */\n onReset?: (params: { target?: string }) => Promise<void>;\n};\n\nexport type ClientPluginProvides = IntentResolverProvides &\n GraphBuilderProvides &\n SurfaceProvides &\n TranslationsProvides & {\n client: Client;\n };\n\nexport const parseClientPlugin = (plugin?: Plugin) =>\n (plugin?.provides as any).client instanceof Client ? (plugin as Plugin<ClientPluginProvides>) : undefined;\n"],
|
|
5
|
-
"mappings": ";;;;;;AAWA,SAASA,SAAS;AAClB,SAASC,QAAQC,iBAAqC;AAKtD,IAAMC,iBAAiBC,EAAEC,OAAO;EAC9BC,aAAaF,EAAEG,WAAWC,SAAAA;EAC1BC,UAAUL,EAAEM,SAASN,EAAEG,WAAWC,SAAAA,CAAAA;EAClCG,SAASP,EAAEM,SACTN,EAAEC,OAAO;IACPO,aAAaR,EAAEM,SAASN,EAAES,MAAM;IAChCC,WAAWV,EAAEM,SAASN,EAAES,MAAM;IAC9BE,MAAMX,EAAEM,SAASN,EAAEY,OAAO;MAAEC,KAAKb,EAAES;MAAQK,OAAOd,EAAEe;IAAI,CAAA,CAAA;EAC1D,CAAA,CAAA;AAEJ,CAAA;AAEA,IAAMC,gBAAgB,GAAGC,aAAAA;;UACRC,eAAAA;EACR,MAAMC,uBAAuBnB,EAAEoB,YAAW,EAAmB,GAAGJ,aAAAA,oBAAiC;IACtGK,OAAOrB,EAAEC,OAAO;MACdO,aAAaR,EAAEM,SAASN,EAAES,MAAM;IAClC,CAAA;IACAa,QAAQvB;EACV,CAAA,EAAA;EAAI;gBALSoB,iBAAAA;EAON,MAAMI,qBAAqBvB,EAAEoB,YAAW,EAAiB,GAAGJ,aAAAA,kBAA+B;IAChGK,OAAOrB,EAAEC,OAAO;MACduB,gBAAgBxB,EAAES;IACpB,CAAA;IACAa,QAAQtB,EAAEyB;EACZ,CAAA,EAAA;EAAI;gBALSF,eAAAA;EAON,MAAMG,sBAAsB1B,EAAEoB,YAAW,EAAkB,GAAGJ,aAAAA,mBAAgC;IACnGK,OAAOrB,EAAEyB;IACTH,QAAQtB,EAAEyB;EACZ,CAAA,EAAA;EAAI;gBAHSC,gBAAAA;EAKN,MAAMC,wBAAwB3B,EAAEoB,YAAW,EAAoB,GAAGJ,aAAAA,qBAAkC;IACzGK,OAAOrB,EAAEyB;IACTH,QAAQtB,EAAEyB;EACZ,CAAA,EAAA;EAAI;gBAHSE,kBAAAA;EAKN,MAAMC,qBAAqB5B,EAAEoB,YAAW,EAAiB,GAAGJ,aAAAA,kBAA+B;IAChGK,OAAOrB,EAAEC,OAAO;MACd4B,QAAQ7B,EAAEM,SAASN,EAAES,MAAM;IAC7B,CAAA;IACAa,QAAQtB,EAAEyB;EACZ,CAAA,EAAA;EAAI;gBALSG,eAAAA;EAON,MAAME,oBAAoB9B,EAAEoB,YAAW,EAAgB,GAAGJ,aAAAA,iBAA8B;IAC7FK,OAAOrB,EAAEyB;IACTH,QAAQtB,EAAEyB;EACZ,CAAA,EAAA;EAAI;gBAHSK,cAAAA;EAKN,MAAMC,2BAA2B/B,EAAEoB,YAAW,EAAuB,GAAGJ,aAAAA,yBAAsC;IACnHK,OAAOrB,EAAEyB;IACTH,QAAQtB,EAAEyB;EACZ,CAAA,EAAA;EAAI;gBAHSM,qBAAAA;AAIf,GAzCiBb,iBAAAA,eAAAA,CAAAA,EAAAA;AAmFV,IAAMc,oBAAoB,CAACC,YAC/BA,QAAQC,UAAiBC,kBAAkBC,SAAUH,SAA0CI;",
|
|
6
|
-
"names": ["S", "Client", "PublicKey", "IdentitySchema", "S", "Struct", "identityKey", "instanceOf", "PublicKey", "spaceKey", "optional", "profile", "displayName", "String", "avatarCid", "data", "Record", "key", "value", "Any", "CLIENT_ACTION", "CLIENT_PLUGIN", "ClientAction", "CreateIdentity", "TaggedClass", "input", "output", "JoinIdentity", "invitationCode", "Void", "ShareIdentity", "RecoverIdentity", "ResetStorage", "target", "CreateAgent", "CreateRecoveryCode", "parseClientPlugin", "plugin", "provides", "client", "Client", "undefined"]
|
|
7
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
CLIENT_PLUGIN,
|
|
4
|
-
meta_default
|
|
5
|
-
} from "./chunk-GMGRQ5Q7.mjs";
|
|
6
|
-
export {
|
|
7
|
-
CLIENT_PLUGIN,
|
|
8
|
-
meta_default as default
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=meta.mjs.map
|
package/src/ClientPlugin.tsx
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
LayoutAction,
|
|
9
|
-
parseIntentPlugin,
|
|
10
|
-
resolvePlugin,
|
|
11
|
-
type PluginDefinition,
|
|
12
|
-
createSurface,
|
|
13
|
-
createIntent,
|
|
14
|
-
createResolver,
|
|
15
|
-
} from '@dxos/app-framework';
|
|
16
|
-
import { Config, Defaults, Envs, Local, Storage } from '@dxos/config';
|
|
17
|
-
import { registerSignalsRuntime } from '@dxos/echo-signals/react';
|
|
18
|
-
import { invariant } from '@dxos/invariant';
|
|
19
|
-
import { createExtension, type Node } from '@dxos/plugin-graph';
|
|
20
|
-
import { ObservabilityAction } from '@dxos/plugin-observability/types';
|
|
21
|
-
import { Client, ClientProvider } from '@dxos/react-client';
|
|
22
|
-
import { type IdentityPanelProps, type JoinPanelProps } from '@dxos/shell/react';
|
|
23
|
-
|
|
24
|
-
import {
|
|
25
|
-
IDENTITY_DIALOG,
|
|
26
|
-
IdentityDialog,
|
|
27
|
-
JOIN_DIALOG,
|
|
28
|
-
JoinDialog,
|
|
29
|
-
RECOVER_CODE_DIALOG,
|
|
30
|
-
RecoveryCodeDialog,
|
|
31
|
-
type RecoveryCodeDialogProps,
|
|
32
|
-
} from './components';
|
|
33
|
-
import meta, { CLIENT_PLUGIN } from './meta';
|
|
34
|
-
import translations from './translations';
|
|
35
|
-
import { ClientAction, type ClientPluginOptions, type ClientPluginProvides } from './types';
|
|
36
|
-
|
|
37
|
-
export const ClientPlugin = ({
|
|
38
|
-
appKey,
|
|
39
|
-
invitationUrl = window.location.origin,
|
|
40
|
-
invitationParam = 'deviceInvitationCode',
|
|
41
|
-
onClientInitialized,
|
|
42
|
-
onReady,
|
|
43
|
-
onReset,
|
|
44
|
-
...options
|
|
45
|
-
}: ClientPluginOptions): PluginDefinition<
|
|
46
|
-
Omit<ClientPluginProvides, 'client'>,
|
|
47
|
-
Pick<ClientPluginProvides, 'client'>
|
|
48
|
-
> => {
|
|
49
|
-
registerSignalsRuntime();
|
|
50
|
-
|
|
51
|
-
let client: Client;
|
|
52
|
-
let error: unknown = null;
|
|
53
|
-
|
|
54
|
-
const createDeviceInvitationUrl = (invitationCode: string) => {
|
|
55
|
-
const baseUrl = new URL(invitationUrl);
|
|
56
|
-
baseUrl.searchParams.set(invitationParam, invitationCode);
|
|
57
|
-
return baseUrl.toString();
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
meta,
|
|
62
|
-
initialize: async () => {
|
|
63
|
-
const config = new Config(await Storage(), Envs(), Local(), Defaults());
|
|
64
|
-
client = new Client({ config, ...options });
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
await client.initialize();
|
|
68
|
-
await onClientInitialized?.(client);
|
|
69
|
-
|
|
70
|
-
// TODO(wittjosiah): Remove. This is a hack to get the app to boot with the new identity after a reset.
|
|
71
|
-
client.reloaded.on(() => {
|
|
72
|
-
client.halo.identity.subscribe(async (identity) => {
|
|
73
|
-
if (identity) {
|
|
74
|
-
window.location.href = window.location.origin;
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
} catch (err) {
|
|
79
|
-
error = err;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return {
|
|
83
|
-
client,
|
|
84
|
-
context: ({ children }) => <ClientProvider client={client}>{children}</ClientProvider>,
|
|
85
|
-
};
|
|
86
|
-
},
|
|
87
|
-
ready: async ({ plugins }) => {
|
|
88
|
-
if (error) {
|
|
89
|
-
throw error;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
await onReady?.(client, plugins);
|
|
93
|
-
},
|
|
94
|
-
unload: async () => {
|
|
95
|
-
await client.destroy();
|
|
96
|
-
},
|
|
97
|
-
provides: {
|
|
98
|
-
translations,
|
|
99
|
-
surface: {
|
|
100
|
-
definitions: () => [
|
|
101
|
-
createSurface({
|
|
102
|
-
id: IDENTITY_DIALOG,
|
|
103
|
-
role: 'dialog',
|
|
104
|
-
filter: (data): data is { subject: IdentityPanelProps } => data.component === IDENTITY_DIALOG,
|
|
105
|
-
component: ({ data }) => (
|
|
106
|
-
<IdentityDialog {...data.subject} createInvitationUrl={createDeviceInvitationUrl} />
|
|
107
|
-
),
|
|
108
|
-
}),
|
|
109
|
-
createSurface({
|
|
110
|
-
id: JOIN_DIALOG,
|
|
111
|
-
role: 'dialog',
|
|
112
|
-
filter: (data): data is { subject: JoinPanelProps } => data.component === JOIN_DIALOG,
|
|
113
|
-
component: ({ data }) => <JoinDialog {...data.subject} />,
|
|
114
|
-
}),
|
|
115
|
-
createSurface({
|
|
116
|
-
id: RECOVER_CODE_DIALOG,
|
|
117
|
-
role: 'dialog',
|
|
118
|
-
filter: (data): data is { subject: RecoveryCodeDialogProps } => data.component === RECOVER_CODE_DIALOG,
|
|
119
|
-
component: ({ data }) => <RecoveryCodeDialog {...data.subject} />,
|
|
120
|
-
}),
|
|
121
|
-
],
|
|
122
|
-
},
|
|
123
|
-
graph: {
|
|
124
|
-
builder: (plugins) => {
|
|
125
|
-
const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatchPromise;
|
|
126
|
-
const id = `${CLIENT_PLUGIN}/open-shell`;
|
|
127
|
-
|
|
128
|
-
return createExtension({
|
|
129
|
-
id: CLIENT_PLUGIN,
|
|
130
|
-
filter: (node): node is Node<null> => node.id === 'root',
|
|
131
|
-
actions: () => [
|
|
132
|
-
{
|
|
133
|
-
id,
|
|
134
|
-
data: async () => {
|
|
135
|
-
await dispatch?.(createIntent(ClientAction.ShareIdentity));
|
|
136
|
-
},
|
|
137
|
-
properties: {
|
|
138
|
-
label: ['open shell label', { ns: CLIENT_PLUGIN }],
|
|
139
|
-
icon: 'ph--address-book--regular',
|
|
140
|
-
keyBinding: {
|
|
141
|
-
macos: 'meta+shift+.',
|
|
142
|
-
// TODO(wittjosiah): Test on windows to see if it behaves the same as linux.
|
|
143
|
-
windows: 'alt+shift+.',
|
|
144
|
-
linux: 'alt+shift+>',
|
|
145
|
-
},
|
|
146
|
-
testId: 'clientPlugin.openShell',
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
],
|
|
150
|
-
});
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
intent: {
|
|
154
|
-
resolvers: () => [
|
|
155
|
-
createResolver(ClientAction.CreateIdentity, async () => {
|
|
156
|
-
const data = await client.halo.createIdentity();
|
|
157
|
-
return { data, intents: [createIntent(ObservabilityAction.SendEvent, { name: 'identity.create' })] };
|
|
158
|
-
}),
|
|
159
|
-
createResolver(ClientAction.JoinIdentity, async (data) => {
|
|
160
|
-
return {
|
|
161
|
-
intents: [
|
|
162
|
-
createIntent(LayoutAction.SetLayout, {
|
|
163
|
-
element: 'dialog',
|
|
164
|
-
component: JOIN_DIALOG,
|
|
165
|
-
dialogBlockAlign: 'start',
|
|
166
|
-
subject: {
|
|
167
|
-
initialInvitationCode: data.invitationCode,
|
|
168
|
-
initialDisposition: 'accept-halo-invitation',
|
|
169
|
-
} satisfies Partial<JoinPanelProps>,
|
|
170
|
-
}),
|
|
171
|
-
],
|
|
172
|
-
};
|
|
173
|
-
}),
|
|
174
|
-
createResolver(ClientAction.ShareIdentity, async () => {
|
|
175
|
-
return {
|
|
176
|
-
intents: [
|
|
177
|
-
createIntent(LayoutAction.SetLayout, {
|
|
178
|
-
element: 'dialog',
|
|
179
|
-
component: IDENTITY_DIALOG,
|
|
180
|
-
dialogBlockAlign: 'start',
|
|
181
|
-
}),
|
|
182
|
-
createIntent(ObservabilityAction.SendEvent, { name: 'identity.share' }),
|
|
183
|
-
],
|
|
184
|
-
};
|
|
185
|
-
}),
|
|
186
|
-
createResolver(ClientAction.RecoverIdentity, async () => {
|
|
187
|
-
return {
|
|
188
|
-
intents: [
|
|
189
|
-
createIntent(LayoutAction.SetLayout, {
|
|
190
|
-
element: 'dialog',
|
|
191
|
-
component: JOIN_DIALOG,
|
|
192
|
-
dialogBlockAlign: 'start',
|
|
193
|
-
subject: { initialDisposition: 'recover-identity' } satisfies Partial<JoinPanelProps>,
|
|
194
|
-
}),
|
|
195
|
-
],
|
|
196
|
-
};
|
|
197
|
-
}),
|
|
198
|
-
createResolver(ClientAction.ResetStorage, async (data) => {
|
|
199
|
-
await onReset?.({ target: data.target });
|
|
200
|
-
return {};
|
|
201
|
-
}),
|
|
202
|
-
createResolver(ClientAction.CreateAgent, async () => {
|
|
203
|
-
invariant(client.services.services.EdgeAgentService, 'Missing EdgeAgentService');
|
|
204
|
-
await client.services.services.EdgeAgentService.createAgent(null as any, { timeout: 10_000 });
|
|
205
|
-
}),
|
|
206
|
-
createResolver(ClientAction.CreateRecoveryCode, async () => {
|
|
207
|
-
invariant(client.services.services.IdentityService, 'IdentityService not available');
|
|
208
|
-
// TODO(wittjosiah): This needs a proper api. Rename property.
|
|
209
|
-
const { seedphrase } = await client.services.services.IdentityService.createRecoveryPhrase();
|
|
210
|
-
return {
|
|
211
|
-
intents: [
|
|
212
|
-
createIntent(LayoutAction.SetLayout, {
|
|
213
|
-
element: 'dialog',
|
|
214
|
-
dialogBlockAlign: 'start',
|
|
215
|
-
dialogType: 'alert',
|
|
216
|
-
state: true,
|
|
217
|
-
component: RECOVER_CODE_DIALOG,
|
|
218
|
-
subject: { code: seedphrase },
|
|
219
|
-
}),
|
|
220
|
-
],
|
|
221
|
-
};
|
|
222
|
-
}),
|
|
223
|
-
],
|
|
224
|
-
},
|
|
225
|
-
},
|
|
226
|
-
};
|
|
227
|
-
};
|