@dxos/plugin-client 0.7.5-main.9d26e3a → 0.7.5-main.e9bb01b
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-52IJQ35F.mjs → chunk-E3OUNOEL.mjs} +4 -6
- package/dist/lib/browser/chunk-E3OUNOEL.mjs.map +7 -0
- package/dist/lib/browser/chunk-MSK3TLIH.mjs +17 -0
- package/dist/lib/browser/chunk-MSK3TLIH.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-PDSHZE3P.mjs +162 -0
- package/dist/lib/browser/chunk-PDSHZE3P.mjs.map +7 -0
- package/dist/lib/browser/chunk-RGMLBYIF.mjs +18 -0
- package/dist/lib/browser/chunk-RGMLBYIF.mjs.map +7 -0
- package/dist/lib/browser/client-BEJK55IM.mjs +41 -0
- package/dist/lib/browser/client-BEJK55IM.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +75 -369
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-XNZZLRBY.mjs +159 -0
- package/dist/lib/browser/intent-resolver-XNZZLRBY.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-context-PHX2CVI7.mjs +24 -0
- package/dist/lib/browser/react-context-PHX2CVI7.mjs.map +7 -0
- package/dist/lib/browser/react-surface-K5NKVCIB.mjs +41 -0
- package/dist/lib/browser/react-surface-K5NKVCIB.mjs.map +7 -0
- package/dist/lib/browser/schema-AL34NY2M.mjs +33 -0
- package/dist/lib/browser/schema-AL34NY2M.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/{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/chunk-VUJ3ZPK3.cjs +190 -0
- package/dist/lib/node/chunk-VUJ3ZPK3.cjs.map +7 -0
- package/dist/lib/node/chunk-XPC4JOPP.cjs +37 -0
- package/dist/lib/node/chunk-XPC4JOPP.cjs.map +7 -0
- package/dist/lib/node/{meta.cjs → chunk-ZI7AV5RP.cjs} +14 -8
- package/dist/lib/node/chunk-ZI7AV5RP.cjs.map +7 -0
- package/dist/lib/node/client-AHIW24VM.cjs +55 -0
- package/dist/lib/node/client-AHIW24VM.cjs.map +7 -0
- package/dist/lib/node/index.cjs +72 -358
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/intent-resolver-UZEK4ODS.cjs +167 -0
- package/dist/lib/node/intent-resolver-UZEK4ODS.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/react-context-WMOFXPT4.cjs +48 -0
- package/dist/lib/node/react-context-WMOFXPT4.cjs.map +7 -0
- package/dist/lib/node/react-surface-YQ2PKXNV.cjs +62 -0
- package/dist/lib/node/react-surface-YQ2PKXNV.cjs.map +7 -0
- package/dist/lib/node/schema-HW4W3QYU.cjs +49 -0
- package/dist/lib/node/schema-HW4W3QYU.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-TI4GNGMM.mjs → chunk-74T33KTB.mjs} +4 -6
- package/dist/lib/node-esm/chunk-74T33KTB.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-B73LKPGU.mjs +18 -0
- package/dist/lib/node-esm/chunk-B73LKPGU.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-QR72BXJK.mjs +19 -0
- package/dist/lib/node-esm/chunk-QR72BXJK.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-WS4CKCUR.mjs +163 -0
- package/dist/lib/node-esm/chunk-WS4CKCUR.mjs.map +7 -0
- package/dist/lib/node-esm/client-FY7IDNRL.mjs +42 -0
- package/dist/lib/node-esm/client-FY7IDNRL.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +75 -369
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-DLCCRSFV.mjs +160 -0
- package/dist/lib/node-esm/intent-resolver-DLCCRSFV.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-context-EEGDXBWA.mjs +25 -0
- package/dist/lib/node-esm/react-context-EEGDXBWA.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-H34XQPWC.mjs +42 -0
- package/dist/lib/node-esm/react-surface-H34XQPWC.mjs.map +7 -0
- package/dist/lib/node-esm/schema-74LVJ3EU.mjs +34 -0
- package/dist/lib/node-esm/schema-74LVJ3EU.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 +194 -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/capabilities/schema.d.ts +4 -0
- package/dist/types/src/capabilities/schema.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 +17 -23
- package/src/ClientPlugin.ts +64 -0
- package/src/capabilities/app-graph-builder.ts +39 -0
- package/src/capabilities/capabilities.ts +16 -0
- package/src/capabilities/client.ts +42 -0
- package/src/capabilities/index.ts +14 -0
- package/src/capabilities/intent-resolver.ts +130 -0
- package/src/capabilities/react-context.tsx +20 -0
- package/src/capabilities/react-surface.tsx +44 -0
- package/src/capabilities/schema.ts +36 -0
- package/src/components/IdentityDialog.tsx +3 -3
- package/src/components/JoinDialog.tsx +1 -1
- 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
|
@@ -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
|
-
};
|