@dxos/plugin-client 0.6.8-main.046e6cf
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/LICENSE +8 -0
- package/README.md +15 -0
- package/dist/lib/browser/chunk-3GFJ7SEI.mjs +21 -0
- package/dist/lib/browser/chunk-3GFJ7SEI.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +224 -0
- package/dist/lib/browser/index.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -0
- package/dist/lib/browser/meta.mjs +11 -0
- package/dist/lib/browser/meta.mjs.map +7 -0
- package/dist/lib/node/chunk-2E5ZNH3H.cjs +45 -0
- package/dist/lib/node/chunk-2E5ZNH3H.cjs.map +7 -0
- package/dist/lib/node/index.cjs +248 -0
- package/dist/lib/node/index.cjs.map +7 -0
- package/dist/lib/node/meta.cjs +32 -0
- package/dist/lib/node/meta.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -0
- package/dist/types/src/ClientPlugin.d.ts +30 -0
- package/dist/types/src/ClientPlugin.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +4 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +13 -0
- package/dist/types/src/meta.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +9 -0
- package/dist/types/src/translations.d.ts.map +1 -0
- package/package.json +65 -0
- package/src/ClientPlugin.tsx +238 -0
- package/src/index.ts +9 -0
- package/src/meta.ts +18 -0
- package/src/translations.ts +15 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
Copyright (c) 2022 DXOS
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
5
|
+
|
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @dxos/plugin-client
|
|
2
|
+
|
|
3
|
+
Surface plugin for DXOS Client.
|
|
4
|
+
|
|
5
|
+
## DXOS Resources
|
|
6
|
+
|
|
7
|
+
- [Website](https://dxos.org)
|
|
8
|
+
- [Developer Documentation](https://docs.dxos.org)
|
|
9
|
+
- Talk to us on [Discord](https://dxos.org/discord)
|
|
10
|
+
|
|
11
|
+
## Contributions
|
|
12
|
+
|
|
13
|
+
Your ideas, issues, and code are most welcome. Please take a look at our [community code of conduct](https://github.com/dxos/dxos/blob/main/CODE_OF_CONDUCT.md), the [issue guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-issues), and the [PR contribution guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-prs).
|
|
14
|
+
|
|
15
|
+
License: [MIT](./LICENSE) Copyright 2023 © DXOS
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// packages/plugins/plugin-client/src/meta.ts
|
|
2
|
+
var CLIENT_PLUGIN = "dxos.org/plugin/client";
|
|
3
|
+
var meta_default = {
|
|
4
|
+
id: CLIENT_PLUGIN,
|
|
5
|
+
name: "Client"
|
|
6
|
+
};
|
|
7
|
+
var CLIENT_ACTION = `${CLIENT_PLUGIN}/action`;
|
|
8
|
+
var ClientAction;
|
|
9
|
+
(function(ClientAction2) {
|
|
10
|
+
ClientAction2[ClientAction2["OPEN_SHELL"] = `${CLIENT_ACTION}/SHELL`] = "OPEN_SHELL";
|
|
11
|
+
ClientAction2[ClientAction2["CREATE_IDENTITY"] = `${CLIENT_ACTION}/CREATE_IDENTITY`] = "CREATE_IDENTITY";
|
|
12
|
+
ClientAction2[ClientAction2["JOIN_IDENTITY"] = `${CLIENT_ACTION}/JOIN_IDENTITY`] = "JOIN_IDENTITY";
|
|
13
|
+
ClientAction2[ClientAction2["SHARE_IDENTITY"] = `${CLIENT_ACTION}/SHARE_IDENTITY`] = "SHARE_IDENTITY";
|
|
14
|
+
})(ClientAction || (ClientAction = {}));
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
CLIENT_PLUGIN,
|
|
18
|
+
meta_default,
|
|
19
|
+
ClientAction
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=chunk-3GFJ7SEI.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/meta.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nexport const CLIENT_PLUGIN = 'dxos.org/plugin/client';\n\nexport default {\n id: CLIENT_PLUGIN,\n name: 'Client',\n};\n\nconst CLIENT_ACTION = `${CLIENT_PLUGIN}/action`;\nexport enum ClientAction {\n OPEN_SHELL = `${CLIENT_ACTION}/SHELL`,\n CREATE_IDENTITY = `${CLIENT_ACTION}/CREATE_IDENTITY`,\n JOIN_IDENTITY = `${CLIENT_ACTION}/JOIN_IDENTITY`,\n SHARE_IDENTITY = `${CLIENT_ACTION}/SHARE_IDENTITY`,\n}\n"],
|
|
5
|
+
"mappings": ";AAIO,IAAMA,gBAAgB;AAE7B,IAAA,eAAe;EACbC,IAAID;EACJE,MAAM;AACR;AAEA,IAAMC,gBAAgB,GAAGH,aAAAA;;UACbI,eAAAA;8CACG,GAAGD,aAAAA,QAAqB,IAAA;mDACnB,GAAGA,aAAAA,kBAA+B,IAAA;iDACpC,GAAGA,aAAAA,gBAA6B,IAAA;kDAC/B,GAAGA,aAAAA,iBAA8B,IAAA;GAJxCC,iBAAAA,eAAAA,CAAAA,EAAAA;",
|
|
6
|
+
"names": ["CLIENT_PLUGIN", "id", "name", "CLIENT_ACTION", "ClientAction"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CLIENT_PLUGIN,
|
|
3
|
+
ClientAction,
|
|
4
|
+
meta_default
|
|
5
|
+
} from "./chunk-3GFJ7SEI.mjs";
|
|
6
|
+
|
|
7
|
+
// packages/plugins/plugin-client/src/ClientPlugin.tsx
|
|
8
|
+
import { AddressBook } from "@phosphor-icons/react";
|
|
9
|
+
import React, { useEffect, useState } from "react";
|
|
10
|
+
import { filterPlugins, parseIntentPlugin, resolvePlugin } from "@dxos/app-framework";
|
|
11
|
+
import { Config, Defaults, Envs, Local, Storage } from "@dxos/config";
|
|
12
|
+
import { registerSignalRuntime } from "@dxos/echo-signals/react";
|
|
13
|
+
import { log } from "@dxos/log";
|
|
14
|
+
import { createExtension } from "@dxos/plugin-graph";
|
|
15
|
+
import { Client, ClientContext } from "@dxos/react-client";
|
|
16
|
+
|
|
17
|
+
// packages/plugins/plugin-client/src/translations.ts
|
|
18
|
+
var translations_default = [
|
|
19
|
+
{
|
|
20
|
+
"en-US": {
|
|
21
|
+
[CLIENT_PLUGIN]: {
|
|
22
|
+
"open shell label": "Open HALO"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
// packages/plugins/plugin-client/src/ClientPlugin.tsx
|
|
29
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-client/src/ClientPlugin.tsx";
|
|
30
|
+
var parseClientPlugin = (plugin) => (plugin?.provides).client instanceof Client ? plugin : void 0;
|
|
31
|
+
var parseSchemaPlugin = (plugin) => Array.isArray(plugin?.provides.echo?.schema) ? plugin : void 0;
|
|
32
|
+
var ClientPlugin = ({ appKey, onClientInitialized, onReady, ...options }) => {
|
|
33
|
+
registerSignalRuntime();
|
|
34
|
+
let client;
|
|
35
|
+
let error = null;
|
|
36
|
+
return {
|
|
37
|
+
meta: meta_default,
|
|
38
|
+
initialize: async () => {
|
|
39
|
+
const config = new Config(await Storage(), Envs(), Local(), Defaults());
|
|
40
|
+
client = new Client({
|
|
41
|
+
config,
|
|
42
|
+
...options
|
|
43
|
+
});
|
|
44
|
+
try {
|
|
45
|
+
await client.initialize();
|
|
46
|
+
await onClientInitialized?.(client);
|
|
47
|
+
client.reloaded.on(() => {
|
|
48
|
+
client.halo.identity.subscribe(async (identity) => {
|
|
49
|
+
if (identity) {
|
|
50
|
+
window.location.href = window.location.origin;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
} catch (err) {
|
|
55
|
+
error = err;
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
client,
|
|
59
|
+
context: ({ children }) => {
|
|
60
|
+
const [status, setStatus] = useState(null);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (!client) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const subscription = client.status.subscribe((status2) => setStatus(status2));
|
|
66
|
+
return () => subscription.unsubscribe();
|
|
67
|
+
}, [
|
|
68
|
+
client,
|
|
69
|
+
setStatus
|
|
70
|
+
]);
|
|
71
|
+
return /* @__PURE__ */ React.createElement(ClientContext.Provider, {
|
|
72
|
+
value: {
|
|
73
|
+
client,
|
|
74
|
+
status
|
|
75
|
+
}
|
|
76
|
+
}, children);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
ready: async (plugins) => {
|
|
81
|
+
if (error) {
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
await onReady?.(client, plugins);
|
|
85
|
+
filterPlugins(plugins, parseSchemaPlugin).forEach((plugin) => {
|
|
86
|
+
log("ready", {
|
|
87
|
+
id: plugin.meta.id
|
|
88
|
+
}, {
|
|
89
|
+
F: __dxlog_file,
|
|
90
|
+
L: 125,
|
|
91
|
+
S: void 0,
|
|
92
|
+
C: (f, a) => f(...a)
|
|
93
|
+
});
|
|
94
|
+
client.addTypes(plugin.provides.echo.schema);
|
|
95
|
+
});
|
|
96
|
+
},
|
|
97
|
+
unload: async () => {
|
|
98
|
+
await client.destroy();
|
|
99
|
+
},
|
|
100
|
+
provides: {
|
|
101
|
+
translations: translations_default,
|
|
102
|
+
graph: {
|
|
103
|
+
builder: (plugins) => {
|
|
104
|
+
const intentPlugin = resolvePlugin(plugins, parseIntentPlugin);
|
|
105
|
+
const id = `${CLIENT_PLUGIN}/open-shell`;
|
|
106
|
+
return createExtension({
|
|
107
|
+
id: CLIENT_PLUGIN,
|
|
108
|
+
filter: (node) => node.id === "root",
|
|
109
|
+
actions: () => [
|
|
110
|
+
{
|
|
111
|
+
id,
|
|
112
|
+
data: async () => {
|
|
113
|
+
await intentPlugin?.provides.intent.dispatch([
|
|
114
|
+
{
|
|
115
|
+
plugin: CLIENT_PLUGIN,
|
|
116
|
+
action: ClientAction.OPEN_SHELL
|
|
117
|
+
}
|
|
118
|
+
]);
|
|
119
|
+
},
|
|
120
|
+
properties: {
|
|
121
|
+
label: [
|
|
122
|
+
"open shell label",
|
|
123
|
+
{
|
|
124
|
+
ns: CLIENT_PLUGIN
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
icon: (props) => /* @__PURE__ */ React.createElement(AddressBook, props),
|
|
128
|
+
iconSymbol: "ph--address-book--regular",
|
|
129
|
+
keyBinding: {
|
|
130
|
+
macos: "meta+shift+.",
|
|
131
|
+
// TODO(wittjosiah): Test on windows to see if it behaves the same as linux.
|
|
132
|
+
windows: "alt+shift+.",
|
|
133
|
+
linux: "alt+shift+>"
|
|
134
|
+
},
|
|
135
|
+
testId: "clientPlugin.openShell"
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
]
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
intent: {
|
|
143
|
+
resolver: async (intent) => {
|
|
144
|
+
switch (intent.action) {
|
|
145
|
+
case ClientAction.OPEN_SHELL:
|
|
146
|
+
await client.shell.open(intent.data?.layout);
|
|
147
|
+
return {
|
|
148
|
+
data: true
|
|
149
|
+
};
|
|
150
|
+
case ClientAction.CREATE_IDENTITY: {
|
|
151
|
+
const data = await client.halo.createIdentity();
|
|
152
|
+
return {
|
|
153
|
+
data,
|
|
154
|
+
intents: [
|
|
155
|
+
[
|
|
156
|
+
{
|
|
157
|
+
// NOTE: This action is hardcoded to avoid circular dependency with observability plugin.
|
|
158
|
+
action: "dxos.org/plugin/observability/send-event",
|
|
159
|
+
data: {
|
|
160
|
+
name: "identity.created"
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
]
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
case ClientAction.JOIN_IDENTITY: {
|
|
168
|
+
const data = await client.shell.joinIdentity({
|
|
169
|
+
invitationCode: intent.data?.invitationCode
|
|
170
|
+
});
|
|
171
|
+
return {
|
|
172
|
+
data,
|
|
173
|
+
intents: [
|
|
174
|
+
[
|
|
175
|
+
{
|
|
176
|
+
// NOTE: This action is hardcoded to avoid circular dependency with observability plugin.
|
|
177
|
+
action: "dxos.org/plugin/observability/send-event",
|
|
178
|
+
data: {
|
|
179
|
+
name: "identity.joined"
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
]
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
case ClientAction.SHARE_IDENTITY: {
|
|
187
|
+
const data = await client.shell.shareIdentity();
|
|
188
|
+
return {
|
|
189
|
+
data,
|
|
190
|
+
intents: [
|
|
191
|
+
[
|
|
192
|
+
{
|
|
193
|
+
// NOTE: This action is hardcoded to avoid circular dependency with observability plugin.
|
|
194
|
+
action: "dxos.org/plugin/observability/send-event",
|
|
195
|
+
data: {
|
|
196
|
+
name: "identity.shared",
|
|
197
|
+
properties: {
|
|
198
|
+
deviceKey: data.device?.deviceKey.truncate(),
|
|
199
|
+
deviceKind: data.device?.kind,
|
|
200
|
+
error: data.error?.message,
|
|
201
|
+
canceled: data.cancelled
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
]
|
|
206
|
+
]
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
// packages/plugins/plugin-client/src/index.ts
|
|
217
|
+
var src_default = ClientPlugin;
|
|
218
|
+
export {
|
|
219
|
+
ClientPlugin,
|
|
220
|
+
src_default as default,
|
|
221
|
+
parseClientPlugin,
|
|
222
|
+
parseSchemaPlugin
|
|
223
|
+
};
|
|
224
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/ClientPlugin.tsx", "../../../src/translations.ts", "../../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { AddressBook, type IconProps } from '@phosphor-icons/react';\nimport React, { useEffect, useState } from 'react';\n\nimport {\n filterPlugins,\n parseIntentPlugin,\n resolvePlugin,\n type GraphBuilderProvides,\n type IntentResolverProvides,\n type Plugin,\n type PluginDefinition,\n type TranslationsProvides,\n} from '@dxos/app-framework';\nimport { Config, Defaults, Envs, Local, Storage } from '@dxos/config';\nimport { type S } from '@dxos/echo-schema';\nimport { registerSignalRuntime } from '@dxos/echo-signals/react';\nimport { log } from '@dxos/log';\nimport { createExtension, type Node } from '@dxos/plugin-graph';\nimport { Client, ClientContext, type ClientOptions, type SystemStatus } from '@dxos/react-client';\n\nimport meta, { CLIENT_PLUGIN, ClientAction } from './meta';\nimport translations from './translations';\n\nexport type ClientPluginOptions = ClientOptions & {\n /**\n * Used to track app-specific state in spaces.\n */\n appKey: 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\nexport type ClientPluginProvides = IntentResolverProvides &\n GraphBuilderProvides &\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\nexport type SchemaProvides = {\n echo: {\n schema: S.Schema<any>[];\n };\n};\n\nexport const parseSchemaPlugin = (plugin?: Plugin) =>\n Array.isArray((plugin?.provides as any).echo?.schema) ? (plugin as Plugin<SchemaProvides>) : undefined;\n\nexport const ClientPlugin = ({\n appKey,\n onClientInitialized,\n onReady,\n ...options\n}: ClientPluginOptions): PluginDefinition<\n Omit<ClientPluginProvides, 'client'>,\n Pick<ClientPluginProvides, 'client'>\n> => {\n registerSignalRuntime();\n\n let client: Client;\n let error: unknown = null;\n\n return {\n meta,\n initialize: async () => {\n const config = new Config(await Storage(), Envs(), Local(), Defaults());\n client = new Client({ config, ...options });\n\n try {\n await client.initialize();\n await onClientInitialized?.(client);\n\n // TODO(wittjosiah): Remove. This is a hack to get the app to boot with the new identity after a reset.\n client.reloaded.on(() => {\n client.halo.identity.subscribe(async (identity) => {\n if (identity) {\n window.location.href = window.location.origin;\n }\n });\n });\n } catch (err) {\n error = err;\n }\n\n return {\n client,\n context: ({ children }) => {\n const [status, setStatus] = useState<SystemStatus | null>(null);\n useEffect(() => {\n if (!client) {\n return;\n }\n\n const subscription = client.status.subscribe((status) => setStatus(status));\n return () => subscription.unsubscribe();\n }, [client, setStatus]);\n\n return <ClientContext.Provider value={{ client, status }}>{children}</ClientContext.Provider>;\n },\n };\n },\n ready: async (plugins) => {\n if (error) {\n throw error;\n }\n\n await onReady?.(client, plugins);\n\n filterPlugins(plugins, parseSchemaPlugin).forEach((plugin) => {\n log('ready', { id: plugin.meta.id });\n client.addTypes(plugin.provides.echo.schema);\n });\n },\n unload: async () => {\n await client.destroy();\n },\n provides: {\n translations,\n graph: {\n builder: (plugins) => {\n const intentPlugin = resolvePlugin(plugins, parseIntentPlugin);\n const id = `${CLIENT_PLUGIN}/open-shell`;\n\n return createExtension({\n id: CLIENT_PLUGIN,\n filter: (node): node is Node<null> => node.id === 'root',\n actions: () => [\n {\n id,\n data: async () => {\n await intentPlugin?.provides.intent.dispatch([\n { plugin: CLIENT_PLUGIN, action: ClientAction.OPEN_SHELL },\n ]);\n },\n properties: {\n label: ['open shell label', { ns: CLIENT_PLUGIN }],\n icon: (props: IconProps) => <AddressBook {...props} />,\n iconSymbol: 'ph--address-book--regular',\n keyBinding: {\n macos: 'meta+shift+.',\n // TODO(wittjosiah): Test on windows to see if it behaves the same as linux.\n windows: 'alt+shift+.',\n linux: 'alt+shift+>',\n },\n testId: 'clientPlugin.openShell',\n },\n },\n ],\n });\n },\n },\n intent: {\n resolver: async (intent) => {\n switch (intent.action) {\n case ClientAction.OPEN_SHELL:\n await client.shell.open(intent.data?.layout);\n return { data: true };\n\n case ClientAction.CREATE_IDENTITY: {\n const data = await client.halo.createIdentity();\n return {\n data,\n intents: [\n [\n {\n // NOTE: This action is hardcoded to avoid circular dependency with observability plugin.\n action: 'dxos.org/plugin/observability/send-event',\n data: {\n name: 'identity.created',\n },\n },\n ],\n ],\n };\n }\n\n case ClientAction.JOIN_IDENTITY: {\n const data = await client.shell.joinIdentity({ invitationCode: intent.data?.invitationCode });\n return {\n data,\n intents: [\n [\n {\n // NOTE: This action is hardcoded to avoid circular dependency with observability plugin.\n action: 'dxos.org/plugin/observability/send-event',\n data: {\n name: 'identity.joined',\n },\n },\n ],\n ],\n };\n }\n\n case ClientAction.SHARE_IDENTITY: {\n const data = await client.shell.shareIdentity();\n return {\n data,\n intents: [\n [\n {\n // NOTE: This action is hardcoded to avoid circular dependency with observability plugin.\n action: 'dxos.org/plugin/observability/send-event',\n data: {\n name: 'identity.shared',\n properties: {\n deviceKey: data.device?.deviceKey.truncate(),\n deviceKind: data.device?.kind,\n error: data.error?.message,\n canceled: data.cancelled,\n },\n },\n },\n ],\n ],\n };\n }\n }\n },\n },\n },\n };\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { CLIENT_PLUGIN } from './meta';\n\nexport default [\n {\n 'en-US': {\n [CLIENT_PLUGIN]: {\n 'open shell label': 'Open HALO',\n },\n },\n },\n];\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { ClientPlugin } from './ClientPlugin';\n\nexport default ClientPlugin;\n\nexport * from './ClientPlugin';\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["AddressBook", "React", "useEffect", "useState", "filterPlugins", "parseIntentPlugin", "resolvePlugin", "Config", "Defaults", "Envs", "Local", "Storage", "registerSignalRuntime", "log", "createExtension", "Client", "ClientContext", "CLIENT_PLUGIN", "parseClientPlugin", "plugin", "provides", "client", "Client", "undefined", "parseSchemaPlugin", "Array", "isArray", "echo", "schema", "ClientPlugin", "appKey", "onClientInitialized", "onReady", "options", "registerSignalRuntime", "error", "meta", "initialize", "config", "Config", "Storage", "Envs", "Local", "Defaults", "reloaded", "on", "halo", "identity", "subscribe", "window", "location", "href", "origin", "err", "context", "children", "status", "setStatus", "useState", "useEffect", "subscription", "unsubscribe", "ClientContext", "Provider", "value", "ready", "plugins", "filterPlugins", "forEach", "log", "id", "addTypes", "unload", "destroy", "translations", "graph", "builder", "intentPlugin", "resolvePlugin", "parseIntentPlugin", "CLIENT_PLUGIN", "createExtension", "filter", "node", "actions", "data", "intent", "dispatch", "action", "ClientAction", "OPEN_SHELL", "properties", "label", "ns", "icon", "props", "AddressBook", "iconSymbol", "keyBinding", "macos", "windows", "linux", "testId", "resolver", "shell", "open", "layout", "CREATE_IDENTITY", "createIdentity", "intents", "name", "JOIN_IDENTITY", "joinIdentity", "invitationCode", "SHARE_IDENTITY", "shareIdentity", "deviceKey", "device", "truncate", "deviceKind", "kind", "message", "canceled", "cancelled", "ClientPlugin"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"packages/plugins/plugin-client/src/meta.ts":{"bytes":2078,"imports":[],"format":"esm"},"packages/plugins/plugin-client/src/translations.ts":{"bytes":1043,"imports":[{"path":"packages/plugins/plugin-client/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/plugin-client/src/ClientPlugin.tsx":{"bytes":26553,"imports":[{"path":"@phosphor-icons/react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/config","kind":"import-statement","external":true},{"path":"@dxos/echo-signals/react","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/plugin-graph","kind":"import-statement","external":true},{"path":"@dxos/react-client","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-client/src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"packages/plugins/plugin-client/src/translations.ts","kind":"import-statement","original":"./translations"}],"format":"esm"},"packages/plugins/plugin-client/src/index.ts":{"bytes":782,"imports":[{"path":"packages/plugins/plugin-client/src/ClientPlugin.tsx","kind":"import-statement","original":"./ClientPlugin"},{"path":"packages/plugins/plugin-client/src/ClientPlugin.tsx","kind":"import-statement","original":"./ClientPlugin"}],"format":"esm"}},"outputs":{"packages/plugins/plugin-client/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":12922},"packages/plugins/plugin-client/dist/lib/browser/index.mjs":{"imports":[{"path":"packages/plugins/plugin-client/dist/lib/browser/chunk-3GFJ7SEI.mjs","kind":"import-statement"},{"path":"@phosphor-icons/react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/config","kind":"import-statement","external":true},{"path":"@dxos/echo-signals/react","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/plugin-graph","kind":"import-statement","external":true},{"path":"@dxos/react-client","kind":"import-statement","external":true}],"exports":["ClientPlugin","default","parseClientPlugin","parseSchemaPlugin"],"entryPoint":"packages/plugins/plugin-client/src/index.ts","inputs":{"packages/plugins/plugin-client/src/ClientPlugin.tsx":{"bytesInOutput":6587},"packages/plugins/plugin-client/src/translations.ts":{"bytesInOutput":134},"packages/plugins/plugin-client/src/index.ts":{"bytesInOutput":32}},"bytes":7186},"packages/plugins/plugin-client/dist/lib/browser/meta.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/plugins/plugin-client/dist/lib/browser/meta.mjs":{"imports":[{"path":"packages/plugins/plugin-client/dist/lib/browser/chunk-3GFJ7SEI.mjs","kind":"import-statement"}],"exports":["CLIENT_PLUGIN","ClientAction","default"],"entryPoint":"packages/plugins/plugin-client/src/meta.ts","inputs":{},"bytes":193},"packages/plugins/plugin-client/dist/lib/browser/chunk-3GFJ7SEI.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":888},"packages/plugins/plugin-client/dist/lib/browser/chunk-3GFJ7SEI.mjs":{"imports":[],"exports":["CLIENT_PLUGIN","ClientAction","meta_default"],"inputs":{"packages/plugins/plugin-client/src/meta.ts":{"bytesInOutput":644}},"bytes":795}}}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var chunk_2E5ZNH3H_exports = {};
|
|
20
|
+
__export(chunk_2E5ZNH3H_exports, {
|
|
21
|
+
CLIENT_PLUGIN: () => CLIENT_PLUGIN,
|
|
22
|
+
ClientAction: () => ClientAction,
|
|
23
|
+
meta_default: () => meta_default
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(chunk_2E5ZNH3H_exports);
|
|
26
|
+
var CLIENT_PLUGIN = "dxos.org/plugin/client";
|
|
27
|
+
var meta_default = {
|
|
28
|
+
id: CLIENT_PLUGIN,
|
|
29
|
+
name: "Client"
|
|
30
|
+
};
|
|
31
|
+
var CLIENT_ACTION = `${CLIENT_PLUGIN}/action`;
|
|
32
|
+
var ClientAction;
|
|
33
|
+
(function(ClientAction2) {
|
|
34
|
+
ClientAction2[ClientAction2["OPEN_SHELL"] = `${CLIENT_ACTION}/SHELL`] = "OPEN_SHELL";
|
|
35
|
+
ClientAction2[ClientAction2["CREATE_IDENTITY"] = `${CLIENT_ACTION}/CREATE_IDENTITY`] = "CREATE_IDENTITY";
|
|
36
|
+
ClientAction2[ClientAction2["JOIN_IDENTITY"] = `${CLIENT_ACTION}/JOIN_IDENTITY`] = "JOIN_IDENTITY";
|
|
37
|
+
ClientAction2[ClientAction2["SHARE_IDENTITY"] = `${CLIENT_ACTION}/SHARE_IDENTITY`] = "SHARE_IDENTITY";
|
|
38
|
+
})(ClientAction || (ClientAction = {}));
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
CLIENT_PLUGIN,
|
|
42
|
+
ClientAction,
|
|
43
|
+
meta_default
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=chunk-2E5ZNH3H.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/meta.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nexport const CLIENT_PLUGIN = 'dxos.org/plugin/client';\n\nexport default {\n id: CLIENT_PLUGIN,\n name: 'Client',\n};\n\nconst CLIENT_ACTION = `${CLIENT_PLUGIN}/action`;\nexport enum ClientAction {\n OPEN_SHELL = `${CLIENT_ACTION}/SHELL`,\n CREATE_IDENTITY = `${CLIENT_ACTION}/CREATE_IDENTITY`,\n JOIN_IDENTITY = `${CLIENT_ACTION}/JOIN_IDENTITY`,\n SHARE_IDENTITY = `${CLIENT_ACTION}/SHARE_IDENTITY`,\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAIO,IAAMA,gBAAgB;AAE7B,IAAA,eAAe;EACbC,IAAID;EACJE,MAAM;AACR;AAEA,IAAMC,gBAAgB,GAAGH,aAAAA;;UACbI,eAAAA;8CACG,GAAGD,aAAAA,QAAqB,IAAA;mDACnB,GAAGA,aAAAA,kBAA+B,IAAA;iDACpC,GAAGA,aAAAA,gBAA6B,IAAA;kDAC/B,GAAGA,aAAAA,iBAA8B,IAAA;GAJxCC,iBAAAA,eAAAA,CAAAA,EAAAA;",
|
|
6
|
+
"names": ["CLIENT_PLUGIN", "id", "name", "CLIENT_ACTION", "ClientAction"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var node_exports = {};
|
|
30
|
+
__export(node_exports, {
|
|
31
|
+
ClientPlugin: () => ClientPlugin,
|
|
32
|
+
default: () => src_default,
|
|
33
|
+
parseClientPlugin: () => parseClientPlugin,
|
|
34
|
+
parseSchemaPlugin: () => parseSchemaPlugin
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(node_exports);
|
|
37
|
+
var import_chunk_2E5ZNH3H = require("./chunk-2E5ZNH3H.cjs");
|
|
38
|
+
var import_react = require("@phosphor-icons/react");
|
|
39
|
+
var import_react2 = __toESM(require("react"));
|
|
40
|
+
var import_app_framework = require("@dxos/app-framework");
|
|
41
|
+
var import_config = require("@dxos/config");
|
|
42
|
+
var import_react3 = require("@dxos/echo-signals/react");
|
|
43
|
+
var import_log = require("@dxos/log");
|
|
44
|
+
var import_plugin_graph = require("@dxos/plugin-graph");
|
|
45
|
+
var import_react_client = require("@dxos/react-client");
|
|
46
|
+
var translations_default = [
|
|
47
|
+
{
|
|
48
|
+
"en-US": {
|
|
49
|
+
[import_chunk_2E5ZNH3H.CLIENT_PLUGIN]: {
|
|
50
|
+
"open shell label": "Open HALO"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
];
|
|
55
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-client/src/ClientPlugin.tsx";
|
|
56
|
+
var parseClientPlugin = (plugin) => (plugin?.provides).client instanceof import_react_client.Client ? plugin : void 0;
|
|
57
|
+
var parseSchemaPlugin = (plugin) => Array.isArray(plugin?.provides.echo?.schema) ? plugin : void 0;
|
|
58
|
+
var ClientPlugin = ({ appKey, onClientInitialized, onReady, ...options }) => {
|
|
59
|
+
(0, import_react3.registerSignalRuntime)();
|
|
60
|
+
let client;
|
|
61
|
+
let error = null;
|
|
62
|
+
return {
|
|
63
|
+
meta: import_chunk_2E5ZNH3H.meta_default,
|
|
64
|
+
initialize: async () => {
|
|
65
|
+
const config = new import_config.Config(await (0, import_config.Storage)(), (0, import_config.Envs)(), (0, import_config.Local)(), (0, import_config.Defaults)());
|
|
66
|
+
client = new import_react_client.Client({
|
|
67
|
+
config,
|
|
68
|
+
...options
|
|
69
|
+
});
|
|
70
|
+
try {
|
|
71
|
+
await client.initialize();
|
|
72
|
+
await onClientInitialized?.(client);
|
|
73
|
+
client.reloaded.on(() => {
|
|
74
|
+
client.halo.identity.subscribe(async (identity) => {
|
|
75
|
+
if (identity) {
|
|
76
|
+
window.location.href = window.location.origin;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
} catch (err) {
|
|
81
|
+
error = err;
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
client,
|
|
85
|
+
context: ({ children }) => {
|
|
86
|
+
const [status, setStatus] = (0, import_react2.useState)(null);
|
|
87
|
+
(0, import_react2.useEffect)(() => {
|
|
88
|
+
if (!client) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const subscription = client.status.subscribe((status2) => setStatus(status2));
|
|
92
|
+
return () => subscription.unsubscribe();
|
|
93
|
+
}, [
|
|
94
|
+
client,
|
|
95
|
+
setStatus
|
|
96
|
+
]);
|
|
97
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_react_client.ClientContext.Provider, {
|
|
98
|
+
value: {
|
|
99
|
+
client,
|
|
100
|
+
status
|
|
101
|
+
}
|
|
102
|
+
}, children);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
},
|
|
106
|
+
ready: async (plugins) => {
|
|
107
|
+
if (error) {
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
await onReady?.(client, plugins);
|
|
111
|
+
(0, import_app_framework.filterPlugins)(plugins, parseSchemaPlugin).forEach((plugin) => {
|
|
112
|
+
(0, import_log.log)("ready", {
|
|
113
|
+
id: plugin.meta.id
|
|
114
|
+
}, {
|
|
115
|
+
F: __dxlog_file,
|
|
116
|
+
L: 125,
|
|
117
|
+
S: void 0,
|
|
118
|
+
C: (f, a) => f(...a)
|
|
119
|
+
});
|
|
120
|
+
client.addTypes(plugin.provides.echo.schema);
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
unload: async () => {
|
|
124
|
+
await client.destroy();
|
|
125
|
+
},
|
|
126
|
+
provides: {
|
|
127
|
+
translations: translations_default,
|
|
128
|
+
graph: {
|
|
129
|
+
builder: (plugins) => {
|
|
130
|
+
const intentPlugin = (0, import_app_framework.resolvePlugin)(plugins, import_app_framework.parseIntentPlugin);
|
|
131
|
+
const id = `${import_chunk_2E5ZNH3H.CLIENT_PLUGIN}/open-shell`;
|
|
132
|
+
return (0, import_plugin_graph.createExtension)({
|
|
133
|
+
id: import_chunk_2E5ZNH3H.CLIENT_PLUGIN,
|
|
134
|
+
filter: (node) => node.id === "root",
|
|
135
|
+
actions: () => [
|
|
136
|
+
{
|
|
137
|
+
id,
|
|
138
|
+
data: async () => {
|
|
139
|
+
await intentPlugin?.provides.intent.dispatch([
|
|
140
|
+
{
|
|
141
|
+
plugin: import_chunk_2E5ZNH3H.CLIENT_PLUGIN,
|
|
142
|
+
action: import_chunk_2E5ZNH3H.ClientAction.OPEN_SHELL
|
|
143
|
+
}
|
|
144
|
+
]);
|
|
145
|
+
},
|
|
146
|
+
properties: {
|
|
147
|
+
label: [
|
|
148
|
+
"open shell label",
|
|
149
|
+
{
|
|
150
|
+
ns: import_chunk_2E5ZNH3H.CLIENT_PLUGIN
|
|
151
|
+
}
|
|
152
|
+
],
|
|
153
|
+
icon: (props) => /* @__PURE__ */ import_react2.default.createElement(import_react.AddressBook, props),
|
|
154
|
+
iconSymbol: "ph--address-book--regular",
|
|
155
|
+
keyBinding: {
|
|
156
|
+
macos: "meta+shift+.",
|
|
157
|
+
// TODO(wittjosiah): Test on windows to see if it behaves the same as linux.
|
|
158
|
+
windows: "alt+shift+.",
|
|
159
|
+
linux: "alt+shift+>"
|
|
160
|
+
},
|
|
161
|
+
testId: "clientPlugin.openShell"
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
]
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
intent: {
|
|
169
|
+
resolver: async (intent) => {
|
|
170
|
+
switch (intent.action) {
|
|
171
|
+
case import_chunk_2E5ZNH3H.ClientAction.OPEN_SHELL:
|
|
172
|
+
await client.shell.open(intent.data?.layout);
|
|
173
|
+
return {
|
|
174
|
+
data: true
|
|
175
|
+
};
|
|
176
|
+
case import_chunk_2E5ZNH3H.ClientAction.CREATE_IDENTITY: {
|
|
177
|
+
const data = await client.halo.createIdentity();
|
|
178
|
+
return {
|
|
179
|
+
data,
|
|
180
|
+
intents: [
|
|
181
|
+
[
|
|
182
|
+
{
|
|
183
|
+
// NOTE: This action is hardcoded to avoid circular dependency with observability plugin.
|
|
184
|
+
action: "dxos.org/plugin/observability/send-event",
|
|
185
|
+
data: {
|
|
186
|
+
name: "identity.created"
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
]
|
|
190
|
+
]
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
case import_chunk_2E5ZNH3H.ClientAction.JOIN_IDENTITY: {
|
|
194
|
+
const data = await client.shell.joinIdentity({
|
|
195
|
+
invitationCode: intent.data?.invitationCode
|
|
196
|
+
});
|
|
197
|
+
return {
|
|
198
|
+
data,
|
|
199
|
+
intents: [
|
|
200
|
+
[
|
|
201
|
+
{
|
|
202
|
+
// NOTE: This action is hardcoded to avoid circular dependency with observability plugin.
|
|
203
|
+
action: "dxos.org/plugin/observability/send-event",
|
|
204
|
+
data: {
|
|
205
|
+
name: "identity.joined"
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
]
|
|
209
|
+
]
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
case import_chunk_2E5ZNH3H.ClientAction.SHARE_IDENTITY: {
|
|
213
|
+
const data = await client.shell.shareIdentity();
|
|
214
|
+
return {
|
|
215
|
+
data,
|
|
216
|
+
intents: [
|
|
217
|
+
[
|
|
218
|
+
{
|
|
219
|
+
// NOTE: This action is hardcoded to avoid circular dependency with observability plugin.
|
|
220
|
+
action: "dxos.org/plugin/observability/send-event",
|
|
221
|
+
data: {
|
|
222
|
+
name: "identity.shared",
|
|
223
|
+
properties: {
|
|
224
|
+
deviceKey: data.device?.deviceKey.truncate(),
|
|
225
|
+
deviceKind: data.device?.kind,
|
|
226
|
+
error: data.error?.message,
|
|
227
|
+
canceled: data.cancelled
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
]
|
|
232
|
+
]
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
var src_default = ClientPlugin;
|
|
242
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
243
|
+
0 && (module.exports = {
|
|
244
|
+
ClientPlugin,
|
|
245
|
+
parseClientPlugin,
|
|
246
|
+
parseSchemaPlugin
|
|
247
|
+
});
|
|
248
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/ClientPlugin.tsx", "../../../src/translations.ts", "../../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { AddressBook, type IconProps } from '@phosphor-icons/react';\nimport React, { useEffect, useState } from 'react';\n\nimport {\n filterPlugins,\n parseIntentPlugin,\n resolvePlugin,\n type GraphBuilderProvides,\n type IntentResolverProvides,\n type Plugin,\n type PluginDefinition,\n type TranslationsProvides,\n} from '@dxos/app-framework';\nimport { Config, Defaults, Envs, Local, Storage } from '@dxos/config';\nimport { type S } from '@dxos/echo-schema';\nimport { registerSignalRuntime } from '@dxos/echo-signals/react';\nimport { log } from '@dxos/log';\nimport { createExtension, type Node } from '@dxos/plugin-graph';\nimport { Client, ClientContext, type ClientOptions, type SystemStatus } from '@dxos/react-client';\n\nimport meta, { CLIENT_PLUGIN, ClientAction } from './meta';\nimport translations from './translations';\n\nexport type ClientPluginOptions = ClientOptions & {\n /**\n * Used to track app-specific state in spaces.\n */\n appKey: 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\nexport type ClientPluginProvides = IntentResolverProvides &\n GraphBuilderProvides &\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\nexport type SchemaProvides = {\n echo: {\n schema: S.Schema<any>[];\n };\n};\n\nexport const parseSchemaPlugin = (plugin?: Plugin) =>\n Array.isArray((plugin?.provides as any).echo?.schema) ? (plugin as Plugin<SchemaProvides>) : undefined;\n\nexport const ClientPlugin = ({\n appKey,\n onClientInitialized,\n onReady,\n ...options\n}: ClientPluginOptions): PluginDefinition<\n Omit<ClientPluginProvides, 'client'>,\n Pick<ClientPluginProvides, 'client'>\n> => {\n registerSignalRuntime();\n\n let client: Client;\n let error: unknown = null;\n\n return {\n meta,\n initialize: async () => {\n const config = new Config(await Storage(), Envs(), Local(), Defaults());\n client = new Client({ config, ...options });\n\n try {\n await client.initialize();\n await onClientInitialized?.(client);\n\n // TODO(wittjosiah): Remove. This is a hack to get the app to boot with the new identity after a reset.\n client.reloaded.on(() => {\n client.halo.identity.subscribe(async (identity) => {\n if (identity) {\n window.location.href = window.location.origin;\n }\n });\n });\n } catch (err) {\n error = err;\n }\n\n return {\n client,\n context: ({ children }) => {\n const [status, setStatus] = useState<SystemStatus | null>(null);\n useEffect(() => {\n if (!client) {\n return;\n }\n\n const subscription = client.status.subscribe((status) => setStatus(status));\n return () => subscription.unsubscribe();\n }, [client, setStatus]);\n\n return <ClientContext.Provider value={{ client, status }}>{children}</ClientContext.Provider>;\n },\n };\n },\n ready: async (plugins) => {\n if (error) {\n throw error;\n }\n\n await onReady?.(client, plugins);\n\n filterPlugins(plugins, parseSchemaPlugin).forEach((plugin) => {\n log('ready', { id: plugin.meta.id });\n client.addTypes(plugin.provides.echo.schema);\n });\n },\n unload: async () => {\n await client.destroy();\n },\n provides: {\n translations,\n graph: {\n builder: (plugins) => {\n const intentPlugin = resolvePlugin(plugins, parseIntentPlugin);\n const id = `${CLIENT_PLUGIN}/open-shell`;\n\n return createExtension({\n id: CLIENT_PLUGIN,\n filter: (node): node is Node<null> => node.id === 'root',\n actions: () => [\n {\n id,\n data: async () => {\n await intentPlugin?.provides.intent.dispatch([\n { plugin: CLIENT_PLUGIN, action: ClientAction.OPEN_SHELL },\n ]);\n },\n properties: {\n label: ['open shell label', { ns: CLIENT_PLUGIN }],\n icon: (props: IconProps) => <AddressBook {...props} />,\n iconSymbol: 'ph--address-book--regular',\n keyBinding: {\n macos: 'meta+shift+.',\n // TODO(wittjosiah): Test on windows to see if it behaves the same as linux.\n windows: 'alt+shift+.',\n linux: 'alt+shift+>',\n },\n testId: 'clientPlugin.openShell',\n },\n },\n ],\n });\n },\n },\n intent: {\n resolver: async (intent) => {\n switch (intent.action) {\n case ClientAction.OPEN_SHELL:\n await client.shell.open(intent.data?.layout);\n return { data: true };\n\n case ClientAction.CREATE_IDENTITY: {\n const data = await client.halo.createIdentity();\n return {\n data,\n intents: [\n [\n {\n // NOTE: This action is hardcoded to avoid circular dependency with observability plugin.\n action: 'dxos.org/plugin/observability/send-event',\n data: {\n name: 'identity.created',\n },\n },\n ],\n ],\n };\n }\n\n case ClientAction.JOIN_IDENTITY: {\n const data = await client.shell.joinIdentity({ invitationCode: intent.data?.invitationCode });\n return {\n data,\n intents: [\n [\n {\n // NOTE: This action is hardcoded to avoid circular dependency with observability plugin.\n action: 'dxos.org/plugin/observability/send-event',\n data: {\n name: 'identity.joined',\n },\n },\n ],\n ],\n };\n }\n\n case ClientAction.SHARE_IDENTITY: {\n const data = await client.shell.shareIdentity();\n return {\n data,\n intents: [\n [\n {\n // NOTE: This action is hardcoded to avoid circular dependency with observability plugin.\n action: 'dxos.org/plugin/observability/send-event',\n data: {\n name: 'identity.shared',\n properties: {\n deviceKey: data.device?.deviceKey.truncate(),\n deviceKind: data.device?.kind,\n error: data.error?.message,\n canceled: data.cancelled,\n },\n },\n },\n ],\n ],\n };\n }\n }\n },\n },\n },\n };\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { CLIENT_PLUGIN } from './meta';\n\nexport default [\n {\n 'en-US': {\n [CLIENT_PLUGIN]: {\n 'open shell label': 'Open HALO',\n },\n },\n },\n];\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { ClientPlugin } from './ClientPlugin';\n\nexport default ClientPlugin;\n\nexport * from './ClientPlugin';\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["import_react", "CLIENT_PLUGIN", "parseClientPlugin", "plugin", "provides", "client", "Client", "undefined", "parseSchemaPlugin", "Array", "isArray", "echo", "schema", "ClientPlugin", "appKey", "onClientInitialized", "onReady", "options", "registerSignalRuntime", "error", "meta", "initialize", "config", "Config", "Storage", "Envs", "Local", "Defaults", "reloaded", "on", "halo", "identity", "subscribe", "window", "location", "href", "origin", "err", "context", "children", "status", "setStatus", "useState", "useEffect", "subscription", "unsubscribe", "React", "ClientContext", "Provider", "value", "ready", "plugins", "filterPlugins", "forEach", "log", "id", "addTypes", "unload", "destroy", "translations", "graph", "builder", "intentPlugin", "resolvePlugin", "parseIntentPlugin", "createExtension", "filter", "node", "actions", "data", "intent", "dispatch", "action", "ClientAction", "OPEN_SHELL", "properties", "label", "ns", "icon", "props", "AddressBook", "iconSymbol", "keyBinding", "macos", "windows", "linux", "testId", "resolver", "shell", "open", "layout", "CREATE_IDENTITY", "createIdentity", "intents", "name", "JOIN_IDENTITY", "joinIdentity", "invitationCode", "SHARE_IDENTITY", "shareIdentity", "deviceKey", "device", "truncate", "deviceKind", "kind", "message", "canceled", "cancelled"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var meta_exports = {};
|
|
20
|
+
__export(meta_exports, {
|
|
21
|
+
CLIENT_PLUGIN: () => import_chunk_2E5ZNH3H.CLIENT_PLUGIN,
|
|
22
|
+
ClientAction: () => import_chunk_2E5ZNH3H.ClientAction,
|
|
23
|
+
default: () => import_chunk_2E5ZNH3H.meta_default
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(meta_exports);
|
|
26
|
+
var import_chunk_2E5ZNH3H = require("./chunk-2E5ZNH3H.cjs");
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
CLIENT_PLUGIN,
|
|
30
|
+
ClientAction
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=meta.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["meta.cjs"],
|
|
4
|
+
"sourcesContent": ["import {\n CLIENT_PLUGIN,\n ClientAction,\n meta_default\n} from \"./chunk-2E5ZNH3H.cjs\";\nexport {\n CLIENT_PLUGIN,\n ClientAction,\n meta_default as default\n};\n//# sourceMappingURL=meta.cjs.map\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAIO;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"packages/plugins/plugin-client/src/meta.ts":{"bytes":2078,"imports":[],"format":"esm"},"packages/plugins/plugin-client/src/translations.ts":{"bytes":1043,"imports":[{"path":"packages/plugins/plugin-client/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/plugin-client/src/ClientPlugin.tsx":{"bytes":26553,"imports":[{"path":"@phosphor-icons/react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/config","kind":"import-statement","external":true},{"path":"@dxos/echo-signals/react","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/plugin-graph","kind":"import-statement","external":true},{"path":"@dxos/react-client","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-client/src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"packages/plugins/plugin-client/src/translations.ts","kind":"import-statement","original":"./translations"}],"format":"esm"},"packages/plugins/plugin-client/src/index.ts":{"bytes":782,"imports":[{"path":"packages/plugins/plugin-client/src/ClientPlugin.tsx","kind":"import-statement","original":"./ClientPlugin"},{"path":"packages/plugins/plugin-client/src/ClientPlugin.tsx","kind":"import-statement","original":"./ClientPlugin"}],"format":"esm"}},"outputs":{"packages/plugins/plugin-client/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":12922},"packages/plugins/plugin-client/dist/lib/node/index.cjs":{"imports":[{"path":"packages/plugins/plugin-client/dist/lib/node/chunk-2E5ZNH3H.cjs","kind":"import-statement"},{"path":"@phosphor-icons/react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/config","kind":"import-statement","external":true},{"path":"@dxos/echo-signals/react","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/plugin-graph","kind":"import-statement","external":true},{"path":"@dxos/react-client","kind":"import-statement","external":true}],"exports":["ClientPlugin","default","parseClientPlugin","parseSchemaPlugin"],"entryPoint":"packages/plugins/plugin-client/src/index.ts","inputs":{"packages/plugins/plugin-client/src/ClientPlugin.tsx":{"bytesInOutput":6587},"packages/plugins/plugin-client/src/translations.ts":{"bytesInOutput":134},"packages/plugins/plugin-client/src/index.ts":{"bytesInOutput":32}},"bytes":7186},"packages/plugins/plugin-client/dist/lib/node/meta.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/plugins/plugin-client/dist/lib/node/meta.cjs":{"imports":[{"path":"packages/plugins/plugin-client/dist/lib/node/chunk-2E5ZNH3H.cjs","kind":"import-statement"}],"exports":["CLIENT_PLUGIN","ClientAction","default"],"entryPoint":"packages/plugins/plugin-client/src/meta.ts","inputs":{},"bytes":193},"packages/plugins/plugin-client/dist/lib/node/chunk-2E5ZNH3H.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":888},"packages/plugins/plugin-client/dist/lib/node/chunk-2E5ZNH3H.cjs":{"imports":[],"exports":["CLIENT_PLUGIN","ClientAction","meta_default"],"inputs":{"packages/plugins/plugin-client/src/meta.ts":{"bytesInOutput":644}},"bytes":795}}}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type GraphBuilderProvides, type IntentResolverProvides, type Plugin, type PluginDefinition, type TranslationsProvides } from '@dxos/app-framework';
|
|
2
|
+
import { type S } from '@dxos/echo-schema';
|
|
3
|
+
import { Client, type ClientOptions } from '@dxos/react-client';
|
|
4
|
+
export type ClientPluginOptions = ClientOptions & {
|
|
5
|
+
/**
|
|
6
|
+
* Used to track app-specific state in spaces.
|
|
7
|
+
*/
|
|
8
|
+
appKey: string;
|
|
9
|
+
/**
|
|
10
|
+
* Run after the client has been initialized.
|
|
11
|
+
*/
|
|
12
|
+
onClientInitialized?: (client: Client) => Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Run after the identity has been successfully initialized.
|
|
15
|
+
* Run with client during plugin ready phase.
|
|
16
|
+
*/
|
|
17
|
+
onReady?: (client: Client, plugins: Plugin[]) => Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
export type ClientPluginProvides = IntentResolverProvides & GraphBuilderProvides & TranslationsProvides & {
|
|
20
|
+
client: Client;
|
|
21
|
+
};
|
|
22
|
+
export declare const parseClientPlugin: (plugin?: Plugin) => Plugin<ClientPluginProvides> | undefined;
|
|
23
|
+
export type SchemaProvides = {
|
|
24
|
+
echo: {
|
|
25
|
+
schema: S.Schema<any>[];
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export declare const parseSchemaPlugin: (plugin?: Plugin) => Plugin<SchemaProvides> | undefined;
|
|
29
|
+
export declare const ClientPlugin: ({ appKey, onClientInitialized, onReady, ...options }: ClientPluginOptions) => PluginDefinition<Omit<ClientPluginProvides, "client">, Pick<ClientPluginProvides, "client">>;
|
|
30
|
+
//# sourceMappingURL=ClientPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientPlugin.d.ts","sourceRoot":"","sources":["../../../src/ClientPlugin.tsx"],"names":[],"mappings":"AAOA,OAAO,EAIL,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,MAAM,EACX,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EAC1B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAI3C,OAAO,EAAE,MAAM,EAAiB,KAAK,aAAa,EAAqB,MAAM,oBAAoB,CAAC;AAKlG,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG;IAChD;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,mBAAmB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAExD;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAChE,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,sBAAsB,GACvD,oBAAoB,GACpB,oBAAoB,GAAG;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEJ,eAAO,MAAM,iBAAiB,YAAa,MAAM,6CAC0D,CAAC;AAE5G,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE;QACJ,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;KACzB,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,iBAAiB,YAAa,MAAM,uCACuD,CAAC;AAEzG,eAAO,MAAM,YAAY,yDAKtB,mBAAmB,KAAG,gBAAgB,CACvC,IAAI,CAAC,oBAAoB,EAAE,QAAQ,CAAC,EACpC,IAAI,CAAC,oBAAoB,EAAE,QAAQ,CAAC,CAuKrC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,eAAe,YAAY,CAAC;AAE5B,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const CLIENT_PLUGIN = "dxos.org/plugin/client";
|
|
2
|
+
declare const _default: {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
7
|
+
export declare enum ClientAction {
|
|
8
|
+
OPEN_SHELL = "dxos.org/plugin/client/action/SHELL",
|
|
9
|
+
CREATE_IDENTITY = "dxos.org/plugin/client/action/CREATE_IDENTITY",
|
|
10
|
+
JOIN_IDENTITY = "dxos.org/plugin/client/action/JOIN_IDENTITY",
|
|
11
|
+
SHARE_IDENTITY = "dxos.org/plugin/client/action/SHARE_IDENTITY"
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=meta.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/meta.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa,2BAA2B,CAAC;;;;;AAEtD,wBAGE;AAGF,oBAAY,YAAY;IACtB,UAAU,wCAA2B;IACrC,eAAe,kDAAqC;IACpD,aAAa,gDAAmC;IAChD,cAAc,iDAAoC;CACnD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":";;;;;;;AAMA,wBAQE"}
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dxos/plugin-client",
|
|
3
|
+
"version": "0.6.8-main.046e6cf",
|
|
4
|
+
"description": "DXOS Surface plugin for DXOS Client",
|
|
5
|
+
"homepage": "https://dxos.org",
|
|
6
|
+
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"author": "DXOS.org",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"browser": "./dist/lib/browser/index.mjs",
|
|
12
|
+
"node": {
|
|
13
|
+
"default": "./dist/lib/node/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"types": "./dist/types/src/index.d.ts"
|
|
16
|
+
},
|
|
17
|
+
"./meta": {
|
|
18
|
+
"browser": "./dist/lib/browser/meta.mjs",
|
|
19
|
+
"node": {
|
|
20
|
+
"default": "./dist/lib/node/meta.cjs"
|
|
21
|
+
},
|
|
22
|
+
"types": "./dist/types/src/meta.d.ts"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"types": "dist/types/src/index.d.ts",
|
|
26
|
+
"typesVersions": {
|
|
27
|
+
"*": {
|
|
28
|
+
"meta": [
|
|
29
|
+
"dist/types/src/meta.d.ts"
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"src"
|
|
36
|
+
],
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@phosphor-icons/react": "^2.1.5",
|
|
39
|
+
"@dxos/app-framework": "0.6.8-main.046e6cf",
|
|
40
|
+
"@dxos/echo-signals": "0.6.8-main.046e6cf",
|
|
41
|
+
"@dxos/invariant": "0.6.8-main.046e6cf",
|
|
42
|
+
"@dxos/echo-schema": "0.6.8-main.046e6cf",
|
|
43
|
+
"@dxos/plugin-graph": "0.6.8-main.046e6cf",
|
|
44
|
+
"@dxos/local-storage": "0.6.8-main.046e6cf",
|
|
45
|
+
"@dxos/log": "0.6.8-main.046e6cf",
|
|
46
|
+
"@dxos/react-ui": "0.6.8-main.046e6cf",
|
|
47
|
+
"@dxos/react-client": "0.6.8-main.046e6cf",
|
|
48
|
+
"@dxos/config": "0.6.8-main.046e6cf"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/react": "~18.2.0",
|
|
52
|
+
"@types/react-dom": "~18.2.0",
|
|
53
|
+
"react": "~18.2.0",
|
|
54
|
+
"react-dom": "~18.2.0",
|
|
55
|
+
"vite": "^5.3.4",
|
|
56
|
+
"@dxos/storybook-utils": "0.6.8-main.046e6cf"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"react": "^18.0.0",
|
|
60
|
+
"react-dom": "^18.0.0"
|
|
61
|
+
},
|
|
62
|
+
"publishConfig": {
|
|
63
|
+
"access": "public"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { AddressBook, type IconProps } from '@phosphor-icons/react';
|
|
6
|
+
import React, { useEffect, useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
filterPlugins,
|
|
10
|
+
parseIntentPlugin,
|
|
11
|
+
resolvePlugin,
|
|
12
|
+
type GraphBuilderProvides,
|
|
13
|
+
type IntentResolverProvides,
|
|
14
|
+
type Plugin,
|
|
15
|
+
type PluginDefinition,
|
|
16
|
+
type TranslationsProvides,
|
|
17
|
+
} from '@dxos/app-framework';
|
|
18
|
+
import { Config, Defaults, Envs, Local, Storage } from '@dxos/config';
|
|
19
|
+
import { type S } from '@dxos/echo-schema';
|
|
20
|
+
import { registerSignalRuntime } from '@dxos/echo-signals/react';
|
|
21
|
+
import { log } from '@dxos/log';
|
|
22
|
+
import { createExtension, type Node } from '@dxos/plugin-graph';
|
|
23
|
+
import { Client, ClientContext, type ClientOptions, type SystemStatus } from '@dxos/react-client';
|
|
24
|
+
|
|
25
|
+
import meta, { CLIENT_PLUGIN, ClientAction } from './meta';
|
|
26
|
+
import translations from './translations';
|
|
27
|
+
|
|
28
|
+
export type ClientPluginOptions = ClientOptions & {
|
|
29
|
+
/**
|
|
30
|
+
* Used to track app-specific state in spaces.
|
|
31
|
+
*/
|
|
32
|
+
appKey: string;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Run after the client has been initialized.
|
|
36
|
+
*/
|
|
37
|
+
onClientInitialized?: (client: Client) => Promise<void>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Run after the identity has been successfully initialized.
|
|
41
|
+
* Run with client during plugin ready phase.
|
|
42
|
+
*/
|
|
43
|
+
onReady?: (client: Client, plugins: Plugin[]) => Promise<void>;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type ClientPluginProvides = IntentResolverProvides &
|
|
47
|
+
GraphBuilderProvides &
|
|
48
|
+
TranslationsProvides & {
|
|
49
|
+
client: Client;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const parseClientPlugin = (plugin?: Plugin) =>
|
|
53
|
+
(plugin?.provides as any).client instanceof Client ? (plugin as Plugin<ClientPluginProvides>) : undefined;
|
|
54
|
+
|
|
55
|
+
export type SchemaProvides = {
|
|
56
|
+
echo: {
|
|
57
|
+
schema: S.Schema<any>[];
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const parseSchemaPlugin = (plugin?: Plugin) =>
|
|
62
|
+
Array.isArray((plugin?.provides as any).echo?.schema) ? (plugin as Plugin<SchemaProvides>) : undefined;
|
|
63
|
+
|
|
64
|
+
export const ClientPlugin = ({
|
|
65
|
+
appKey,
|
|
66
|
+
onClientInitialized,
|
|
67
|
+
onReady,
|
|
68
|
+
...options
|
|
69
|
+
}: ClientPluginOptions): PluginDefinition<
|
|
70
|
+
Omit<ClientPluginProvides, 'client'>,
|
|
71
|
+
Pick<ClientPluginProvides, 'client'>
|
|
72
|
+
> => {
|
|
73
|
+
registerSignalRuntime();
|
|
74
|
+
|
|
75
|
+
let client: Client;
|
|
76
|
+
let error: unknown = null;
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
meta,
|
|
80
|
+
initialize: async () => {
|
|
81
|
+
const config = new Config(await Storage(), Envs(), Local(), Defaults());
|
|
82
|
+
client = new Client({ config, ...options });
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
await client.initialize();
|
|
86
|
+
await onClientInitialized?.(client);
|
|
87
|
+
|
|
88
|
+
// TODO(wittjosiah): Remove. This is a hack to get the app to boot with the new identity after a reset.
|
|
89
|
+
client.reloaded.on(() => {
|
|
90
|
+
client.halo.identity.subscribe(async (identity) => {
|
|
91
|
+
if (identity) {
|
|
92
|
+
window.location.href = window.location.origin;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
} catch (err) {
|
|
97
|
+
error = err;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
client,
|
|
102
|
+
context: ({ children }) => {
|
|
103
|
+
const [status, setStatus] = useState<SystemStatus | null>(null);
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
if (!client) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const subscription = client.status.subscribe((status) => setStatus(status));
|
|
110
|
+
return () => subscription.unsubscribe();
|
|
111
|
+
}, [client, setStatus]);
|
|
112
|
+
|
|
113
|
+
return <ClientContext.Provider value={{ client, status }}>{children}</ClientContext.Provider>;
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
},
|
|
117
|
+
ready: async (plugins) => {
|
|
118
|
+
if (error) {
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
await onReady?.(client, plugins);
|
|
123
|
+
|
|
124
|
+
filterPlugins(plugins, parseSchemaPlugin).forEach((plugin) => {
|
|
125
|
+
log('ready', { id: plugin.meta.id });
|
|
126
|
+
client.addTypes(plugin.provides.echo.schema);
|
|
127
|
+
});
|
|
128
|
+
},
|
|
129
|
+
unload: async () => {
|
|
130
|
+
await client.destroy();
|
|
131
|
+
},
|
|
132
|
+
provides: {
|
|
133
|
+
translations,
|
|
134
|
+
graph: {
|
|
135
|
+
builder: (plugins) => {
|
|
136
|
+
const intentPlugin = resolvePlugin(plugins, parseIntentPlugin);
|
|
137
|
+
const id = `${CLIENT_PLUGIN}/open-shell`;
|
|
138
|
+
|
|
139
|
+
return createExtension({
|
|
140
|
+
id: CLIENT_PLUGIN,
|
|
141
|
+
filter: (node): node is Node<null> => node.id === 'root',
|
|
142
|
+
actions: () => [
|
|
143
|
+
{
|
|
144
|
+
id,
|
|
145
|
+
data: async () => {
|
|
146
|
+
await intentPlugin?.provides.intent.dispatch([
|
|
147
|
+
{ plugin: CLIENT_PLUGIN, action: ClientAction.OPEN_SHELL },
|
|
148
|
+
]);
|
|
149
|
+
},
|
|
150
|
+
properties: {
|
|
151
|
+
label: ['open shell label', { ns: CLIENT_PLUGIN }],
|
|
152
|
+
icon: (props: IconProps) => <AddressBook {...props} />,
|
|
153
|
+
iconSymbol: 'ph--address-book--regular',
|
|
154
|
+
keyBinding: {
|
|
155
|
+
macos: 'meta+shift+.',
|
|
156
|
+
// TODO(wittjosiah): Test on windows to see if it behaves the same as linux.
|
|
157
|
+
windows: 'alt+shift+.',
|
|
158
|
+
linux: 'alt+shift+>',
|
|
159
|
+
},
|
|
160
|
+
testId: 'clientPlugin.openShell',
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
});
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
intent: {
|
|
168
|
+
resolver: async (intent) => {
|
|
169
|
+
switch (intent.action) {
|
|
170
|
+
case ClientAction.OPEN_SHELL:
|
|
171
|
+
await client.shell.open(intent.data?.layout);
|
|
172
|
+
return { data: true };
|
|
173
|
+
|
|
174
|
+
case ClientAction.CREATE_IDENTITY: {
|
|
175
|
+
const data = await client.halo.createIdentity();
|
|
176
|
+
return {
|
|
177
|
+
data,
|
|
178
|
+
intents: [
|
|
179
|
+
[
|
|
180
|
+
{
|
|
181
|
+
// NOTE: This action is hardcoded to avoid circular dependency with observability plugin.
|
|
182
|
+
action: 'dxos.org/plugin/observability/send-event',
|
|
183
|
+
data: {
|
|
184
|
+
name: 'identity.created',
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
],
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
case ClientAction.JOIN_IDENTITY: {
|
|
193
|
+
const data = await client.shell.joinIdentity({ invitationCode: intent.data?.invitationCode });
|
|
194
|
+
return {
|
|
195
|
+
data,
|
|
196
|
+
intents: [
|
|
197
|
+
[
|
|
198
|
+
{
|
|
199
|
+
// NOTE: This action is hardcoded to avoid circular dependency with observability plugin.
|
|
200
|
+
action: 'dxos.org/plugin/observability/send-event',
|
|
201
|
+
data: {
|
|
202
|
+
name: 'identity.joined',
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
],
|
|
206
|
+
],
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
case ClientAction.SHARE_IDENTITY: {
|
|
211
|
+
const data = await client.shell.shareIdentity();
|
|
212
|
+
return {
|
|
213
|
+
data,
|
|
214
|
+
intents: [
|
|
215
|
+
[
|
|
216
|
+
{
|
|
217
|
+
// NOTE: This action is hardcoded to avoid circular dependency with observability plugin.
|
|
218
|
+
action: 'dxos.org/plugin/observability/send-event',
|
|
219
|
+
data: {
|
|
220
|
+
name: 'identity.shared',
|
|
221
|
+
properties: {
|
|
222
|
+
deviceKey: data.device?.deviceKey.truncate(),
|
|
223
|
+
deviceKind: data.device?.kind,
|
|
224
|
+
error: data.error?.message,
|
|
225
|
+
canceled: data.cancelled,
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
],
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
};
|
package/src/index.ts
ADDED
package/src/meta.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
export const CLIENT_PLUGIN = 'dxos.org/plugin/client';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
id: CLIENT_PLUGIN,
|
|
9
|
+
name: 'Client',
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const CLIENT_ACTION = `${CLIENT_PLUGIN}/action`;
|
|
13
|
+
export enum ClientAction {
|
|
14
|
+
OPEN_SHELL = `${CLIENT_ACTION}/SHELL`,
|
|
15
|
+
CREATE_IDENTITY = `${CLIENT_ACTION}/CREATE_IDENTITY`,
|
|
16
|
+
JOIN_IDENTITY = `${CLIENT_ACTION}/JOIN_IDENTITY`,
|
|
17
|
+
SHARE_IDENTITY = `${CLIENT_ACTION}/SHARE_IDENTITY`,
|
|
18
|
+
}
|