@dxos/shell 0.5.1-main.d514f85 → 0.5.1-main.ea79cb0

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.
Files changed (33) hide show
  1. package/dist/bundle/shell.mjs +5111 -5084
  2. package/dist/bundle/shell.mjs.map +1 -1
  3. package/dist/bundle/shell.umd.js +55 -55
  4. package/dist/bundle/shell.umd.js.map +1 -1
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/react.mjs +107 -45
  7. package/dist/lib/browser/react.mjs.map +3 -3
  8. package/dist/types/src/composites/Shell/Shell.d.ts +1 -2
  9. package/dist/types/src/composites/Shell/Shell.d.ts.map +1 -1
  10. package/dist/types/src/composites/Shell/Shell.js +24 -4
  11. package/dist/types/src/composites/Shell/Shell.js.map +1 -1
  12. package/dist/types/src/composites/Shell/ShellContext.js +1 -1
  13. package/dist/types/src/composites/Shell/ShellContext.js.map +1 -1
  14. package/dist/types/src/composites/Shell/memory-shell-runtime.d.ts +10 -2
  15. package/dist/types/src/composites/Shell/memory-shell-runtime.d.ts.map +1 -1
  16. package/dist/types/src/composites/Shell/memory-shell-runtime.js +20 -1
  17. package/dist/types/src/composites/Shell/memory-shell-runtime.js.map +1 -1
  18. package/dist/types/src/composites/Shell/run-shell.d.ts.map +1 -1
  19. package/dist/types/src/composites/Shell/run-shell.js +29 -10
  20. package/dist/types/src/composites/Shell/run-shell.js.map +1 -1
  21. package/dist/types/src/panels/JoinPanel/JoinPanel.js +2 -2
  22. package/dist/types/src/panels/JoinPanel/JoinPanel.js.map +1 -1
  23. package/dist/types/src/translations/locales/en-US.d.ts +1 -0
  24. package/dist/types/src/translations/locales/en-US.d.ts.map +1 -1
  25. package/dist/types/src/translations/locales/en-US.js +1 -0
  26. package/dist/types/src/translations/locales/en-US.js.map +1 -1
  27. package/package.json +21 -21
  28. package/src/composites/Shell/Shell.tsx +36 -5
  29. package/src/composites/Shell/ShellContext.tsx +1 -1
  30. package/src/composites/Shell/memory-shell-runtime.ts +36 -2
  31. package/src/composites/Shell/run-shell.tsx +51 -19
  32. package/src/panels/JoinPanel/JoinPanel.tsx +2 -2
  33. package/src/translations/locales/en-US.ts +1 -0
@@ -2983,7 +2983,7 @@ var JoinPanelImpl = (props) => {
2983
2983
  id: "reset storage confirmation"
2984
2984
  }, /* @__PURE__ */ React38.createElement(ConfirmResetComponent, {
2985
2985
  send,
2986
- active: activeView === "reset identity confirmation",
2986
+ active: activeView === "reset storage confirmation",
2987
2987
  onCancel: onCancelResetStorage,
2988
2988
  onConfirm: onConfirmResetStorage
2989
2989
  })), /* @__PURE__ */ React38.createElement(Viewport.View, {
@@ -3150,7 +3150,7 @@ var JoinPanel = ({ titleId: propsTitleId, mode = "default", initialDisposition =
3150
3150
  }):
3151
3151
  return "addition method chooser";
3152
3152
  case joinState.matches("resettingIdentity"):
3153
- return "reset identity confirmation";
3153
+ return "reset storage confirmation";
3154
3154
  case joinState.matches({
3155
3155
  choosingIdentity: "creatingIdentity"
3156
3156
  }):
@@ -3746,8 +3746,8 @@ import React47, { StrictMode } from "react";
3746
3746
  import { createRoot } from "react-dom/client";
3747
3747
  import { DEFAULT_CLIENT_CHANNEL, DEFAULT_SHELL_CHANNEL } from "@dxos/client-protocol";
3748
3748
  import { ShellRuntimeImpl } from "@dxos/client-services";
3749
- import { AgentHostingProvider, Client, ClientContext, ClientServicesProxy, Config, SystemStatus } from "@dxos/react-client";
3750
- import { ThemeProvider, Tooltip as Tooltip7 } from "@dxos/react-ui";
3749
+ import { AgentHostingProvider, Client, ClientContext, ClientServicesProxy, Config, ShellDisplay as ShellDisplay2, SystemStatus } from "@dxos/react-client";
3750
+ import { Button as Button11, Dialog as Dialog3, ThemeProvider, Tooltip as Tooltip7, useTranslation as useTranslation26 } from "@dxos/react-ui";
3751
3751
  import { defaultTx } from "@dxos/react-ui-theme";
3752
3752
  import { createIFramePort } from "@dxos/rpc-tunnel";
3753
3753
 
@@ -3792,17 +3792,37 @@ var StatusDialog = () => {
3792
3792
 
3793
3793
  // packages/sdk/shell/src/composites/Shell/Shell.tsx
3794
3794
  var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/composites/Shell/Shell.tsx";
3795
- var Shell = ({ runtime, origin }) => {
3795
+ var Shell = ({ runtime }) => {
3796
3796
  const [{ layout, invitationCode, spaceKey, target }, setLayout] = useState13({
3797
3797
  layout: runtime.layout,
3798
3798
  invitationCode: runtime.invitationCode,
3799
3799
  spaceKey: runtime.spaceKey,
3800
3800
  target: runtime.target
3801
3801
  });
3802
+ const [{ invitationUrl, deviceInvitationParam, spaceInvitationParam }, setInvitationUrl] = useState13({
3803
+ invitationUrl: runtime.invitationUrl,
3804
+ deviceInvitationParam: runtime.deviceInvitationParam,
3805
+ spaceInvitationParam: runtime.spaceInvitationParam
3806
+ });
3802
3807
  const client = useClient7();
3803
3808
  const space = useSpace2(spaceKey);
3809
+ const createDeviceInvitationUrl = (invitationCode2) => {
3810
+ const baseUrl = new URL(invitationUrl);
3811
+ baseUrl.searchParams.set(deviceInvitationParam, invitationCode2);
3812
+ return baseUrl.toString();
3813
+ };
3814
+ const createSpaceInvitationUrl = (invitationCode2) => {
3815
+ const baseUrl = new URL(invitationUrl);
3816
+ baseUrl.searchParams.set(spaceInvitationParam, invitationCode2);
3817
+ return baseUrl.toString();
3818
+ };
3804
3819
  useEffect7(() => {
3805
- return runtime.layoutUpdate.on((request) => setLayout(request));
3820
+ const unsubscribeLayout = runtime.layoutUpdate.on((request) => setLayout(request));
3821
+ const unsubscribeInvitationUrl = runtime.invitationUrlUpdate.on((request) => setInvitationUrl(request));
3822
+ return () => {
3823
+ unsubscribeLayout();
3824
+ unsubscribeInvitationUrl();
3825
+ };
3806
3826
  }, [
3807
3827
  runtime
3808
3828
  ]);
@@ -3810,7 +3830,7 @@ var Shell = ({ runtime, origin }) => {
3810
3830
  if (layout === ShellLayout.SPACE && !space) {
3811
3831
  log14.warn("No space found for shell space invitations.", void 0, {
3812
3832
  F: __dxlog_file13,
3813
- L: 33,
3833
+ L: 64,
3814
3834
  S: void 0,
3815
3835
  C: (f, a) => f(...a)
3816
3836
  });
@@ -3854,7 +3874,7 @@ var Shell = ({ runtime, origin }) => {
3854
3874
  case ShellLayout.SHARE_IDENTITY:
3855
3875
  case ShellLayout.EDIT_PROFILE:
3856
3876
  return /* @__PURE__ */ React46.createElement(IdentityDialog, {
3857
- createInvitationUrl: (invitationCode2) => `${origin}?deviceInvitationCode=${invitationCode2}`,
3877
+ createInvitationUrl: createDeviceInvitationUrl,
3858
3878
  onResetStorage: async () => {
3859
3879
  runtime.setLayout({
3860
3880
  layout: ShellLayout.STATUS
@@ -3888,7 +3908,7 @@ var Shell = ({ runtime, origin }) => {
3888
3908
  return space ? /* @__PURE__ */ React46.createElement(SpaceDialog, {
3889
3909
  space,
3890
3910
  target,
3891
- createInvitationUrl: (invitationCode2) => `${origin}?spaceInvitationCode=${invitationCode2}`,
3911
+ createInvitationUrl: createSpaceInvitationUrl,
3892
3912
  onDone: async () => {
3893
3913
  await runtime.setAppContext({
3894
3914
  display: ShellDisplay.NONE
@@ -4067,7 +4087,8 @@ var os = {
4067
4087
  "agent message body": "Creating an agent helps keep your devices and peers in-sync. An agent is like any other device, but since it\u2019s always online your changes will sync even when all your physical devices are\xA0asleep.",
4068
4088
  "create agent label": "Start an agent",
4069
4089
  "destroy agent label": "Shut down agent",
4070
- "agent device label": "Your agent"
4090
+ "agent device label": "Your agent",
4091
+ "shell fallback title": "Shell failed to connect"
4071
4092
  };
4072
4093
 
4073
4094
  // packages/sdk/shell/src/translations/index.ts
@@ -4077,39 +4098,62 @@ var osTranslations = {
4077
4098
 
4078
4099
  // packages/sdk/shell/src/composites/Shell/run-shell.tsx
4079
4100
  var runShell = async (config = new Config()) => {
4080
- const services = new ClientServicesProxy(createIFramePort({
4081
- channel: DEFAULT_CLIENT_CHANNEL
4082
- }));
4083
- const client = new Client({
4084
- config,
4085
- services
4086
- });
4087
4101
  const runtime = new ShellRuntimeImpl(createIFramePort({
4088
4102
  channel: DEFAULT_SHELL_CHANNEL
4089
4103
  }));
4090
- await Promise.all([
4091
- runtime.open(),
4092
- client.initialize()
4093
- ]);
4094
- createRoot(document.getElementById("root")).render(/* @__PURE__ */ React47.createElement(StrictMode, null, /* @__PURE__ */ React47.createElement(ThemeProvider, {
4095
- tx: defaultTx,
4096
- resourceExtensions: [
4097
- osTranslations
4098
- ]
4099
- }, /* @__PURE__ */ React47.createElement(ClientContext.Provider, {
4100
- value: {
4101
- client,
4102
- status: SystemStatus.ACTIVE
4103
- }
4104
- }, /* @__PURE__ */ React47.createElement(ClipboardProvider, null, /* @__PURE__ */ React47.createElement(Tooltip7.Provider, null, /* @__PURE__ */ React47.createElement(AgentHostingProvider, null, /* @__PURE__ */ React47.createElement(Shell, {
4105
- runtime,
4106
- origin: location.origin
4107
- }))))))));
4104
+ await runtime.open();
4105
+ try {
4106
+ const services = new ClientServicesProxy(createIFramePort({
4107
+ channel: DEFAULT_CLIENT_CHANNEL
4108
+ }));
4109
+ const client = new Client({
4110
+ config,
4111
+ services
4112
+ });
4113
+ await client.initialize();
4114
+ createRoot(document.getElementById("root")).render(/* @__PURE__ */ React47.createElement(StrictMode, null, /* @__PURE__ */ React47.createElement(ThemeProvider, {
4115
+ tx: defaultTx,
4116
+ resourceExtensions: [
4117
+ osTranslations
4118
+ ]
4119
+ }, /* @__PURE__ */ React47.createElement(ClientContext.Provider, {
4120
+ value: {
4121
+ client,
4122
+ status: SystemStatus.ACTIVE
4123
+ }
4124
+ }, /* @__PURE__ */ React47.createElement(ClipboardProvider, null, /* @__PURE__ */ React47.createElement(Tooltip7.Provider, null, /* @__PURE__ */ React47.createElement(AgentHostingProvider, null, /* @__PURE__ */ React47.createElement(Shell, {
4125
+ runtime
4126
+ }))))))));
4127
+ } catch {
4128
+ createRoot(document.getElementById("root")).render(/* @__PURE__ */ React47.createElement(StrictMode, null, /* @__PURE__ */ React47.createElement(ThemeProvider, {
4129
+ tx: defaultTx,
4130
+ resourceExtensions: [
4131
+ osTranslations
4132
+ ]
4133
+ }, /* @__PURE__ */ React47.createElement(Fallback, {
4134
+ onClose: () => runtime.setAppContext({
4135
+ display: ShellDisplay2.NONE
4136
+ })
4137
+ }))));
4138
+ }
4139
+ };
4140
+ var Fallback = ({ onClose }) => {
4141
+ const { t } = useTranslation26("os");
4142
+ return /* @__PURE__ */ React47.createElement(Dialog3.Root, {
4143
+ modal: true,
4144
+ open: true,
4145
+ onOpenChange: () => onClose?.()
4146
+ }, /* @__PURE__ */ React47.createElement(Dialog3.Overlay, null, /* @__PURE__ */ React47.createElement(Dialog3.Content, null, /* @__PURE__ */ React47.createElement(Dialog3.Title, null, t("shell fallback title")), /* @__PURE__ */ React47.createElement(Dialog3.Close, {
4147
+ asChild: true,
4148
+ onClick: () => onClose?.()
4149
+ }, /* @__PURE__ */ React47.createElement(Button11, {
4150
+ variant: "primary"
4151
+ }, t("close label"))))));
4108
4152
  };
4109
4153
 
4110
4154
  // packages/sdk/shell/src/composites/Shell/ShellContext.tsx
4111
4155
  import React48, { createContext as createContext2, useCallback as useCallback9, useContext as useContext2, useEffect as useEffect8, useMemo as useMemo6, useState as useState14 } from "react";
4112
- import { ShellDisplay as ShellDisplay2, ShellLayout as ShellLayout3, useClient as useClient8 } from "@dxos/react-client";
4156
+ import { ShellDisplay as ShellDisplay3, ShellLayout as ShellLayout3, useClient as useClient8 } from "@dxos/react-client";
4113
4157
  import { useIdentity as useIdentity3 } from "@dxos/react-client/halo";
4114
4158
  import { mx as mx25 } from "@dxos/react-ui-theme";
4115
4159
 
@@ -4117,12 +4161,16 @@ import { mx as mx25 } from "@dxos/react-ui-theme";
4117
4161
  import { Event } from "@dxos/async";
4118
4162
  import { ShellLayout as ShellLayout2 } from "@dxos/react-client";
4119
4163
  var MemoryShellRuntime = class {
4120
- constructor({ layout, invitationCode, spaceKey } = {}) {
4164
+ constructor({ layout, invitationCode, spaceKey, invitationUrl, deviceInvitationParam, spaceInvitationParam } = {}) {
4121
4165
  this.layoutUpdate = new Event();
4166
+ this.invitationUrlUpdate = new Event();
4122
4167
  this.contextUpdate = new Event();
4123
4168
  this._layout = layout ?? ShellLayout2.DEFAULT;
4124
4169
  this._invitationCode = invitationCode;
4125
4170
  this._spaceKey = spaceKey;
4171
+ this._invitationUrl = invitationUrl ?? window.location.origin;
4172
+ this._deviceInvitationParam = deviceInvitationParam ?? "deviceInvitationCode";
4173
+ this._spaceInvitationParam = spaceInvitationParam ?? "spaceInvitationCode";
4126
4174
  }
4127
4175
  get layout() {
4128
4176
  return this._layout;
@@ -4133,12 +4181,27 @@ var MemoryShellRuntime = class {
4133
4181
  get spaceKey() {
4134
4182
  return this._spaceKey;
4135
4183
  }
4184
+ get invitationUrl() {
4185
+ return this._invitationUrl;
4186
+ }
4187
+ get deviceInvitationParam() {
4188
+ return this._deviceInvitationParam;
4189
+ }
4190
+ get spaceInvitationParam() {
4191
+ return this._spaceInvitationParam;
4192
+ }
4136
4193
  setLayout(request) {
4137
4194
  this._layout = request.layout;
4138
4195
  this._invitationCode = request.invitationCode;
4139
4196
  this._spaceKey = request.spaceKey;
4140
4197
  this.layoutUpdate.emit(request);
4141
4198
  }
4199
+ setInvitationUrl(request) {
4200
+ this._invitationUrl = request.invitationUrl;
4201
+ this._deviceInvitationParam = request.deviceInvitationParam;
4202
+ this._spaceInvitationParam = request.spaceInvitationParam;
4203
+ this.invitationUrlUpdate.emit(request);
4204
+ }
4142
4205
  async setAppContext(context) {
4143
4206
  this.contextUpdate.emit(context);
4144
4207
  }
@@ -4152,9 +4215,9 @@ var useShell = () => {
4152
4215
  const setLayout = async (layout, options) => {
4153
4216
  if (runtime) {
4154
4217
  if (layout === ShellLayout3.DEFAULT) {
4155
- setDisplay?.(ShellDisplay2.NONE);
4218
+ setDisplay?.(ShellDisplay3.NONE);
4156
4219
  } else {
4157
- setDisplay?.(ShellDisplay2.FULLSCREEN);
4220
+ setDisplay?.(ShellDisplay3.FULLSCREEN);
4158
4221
  }
4159
4222
  runtime.setLayout({
4160
4223
  layout,
@@ -4170,7 +4233,7 @@ var useShell = () => {
4170
4233
  var ShellProvider = ({ space, deviceInvitationCode, spaceInvitationCode, onJoinedSpace, children }) => {
4171
4234
  const client = useClient8();
4172
4235
  const identity = useIdentity3();
4173
- const [display, setDisplay] = useState14(!identity || spaceInvitationCode || deviceInvitationCode ? ShellDisplay2.FULLSCREEN : ShellDisplay2.NONE);
4236
+ const [display, setDisplay] = useState14(!identity || spaceInvitationCode || deviceInvitationCode ? ShellDisplay3.FULLSCREEN : ShellDisplay3.NONE);
4174
4237
  const shellRuntime = useMemo6(() => {
4175
4238
  if (client.config.get("runtime.app.env.DX_VAULT") !== "false") {
4176
4239
  return;
@@ -4205,13 +4268,13 @@ var ShellProvider = ({ space, deviceInvitationCode, spaceInvitationCode, onJoine
4205
4268
  shellRuntime.setLayout({
4206
4269
  layout: ShellLayout3.SHARE_IDENTITY
4207
4270
  });
4208
- setDisplay(ShellDisplay2.FULLSCREEN);
4271
+ setDisplay(ShellDisplay3.FULLSCREEN);
4209
4272
  } else if (event.key === "." && modifier) {
4210
4273
  shellRuntime.setLayout({
4211
4274
  layout: ShellLayout3.SPACE,
4212
4275
  spaceKey: space.key
4213
4276
  });
4214
- setDisplay(ShellDisplay2.FULLSCREEN);
4277
+ setDisplay(ShellDisplay3.FULLSCREEN);
4215
4278
  }
4216
4279
  }, [
4217
4280
  space,
@@ -4241,10 +4304,9 @@ var ShellProvider = ({ space, deviceInvitationCode, spaceInvitationCode, onJoine
4241
4304
  shellRuntime
4242
4305
  ]);
4243
4306
  return /* @__PURE__ */ React48.createElement(React48.Fragment, null, shellRuntime && /* @__PURE__ */ React48.createElement("div", {
4244
- className: mx25(display === ShellDisplay2.NONE ? "hidden" : "")
4307
+ className: mx25(display === ShellDisplay3.NONE ? "hidden" : "")
4245
4308
  }, /* @__PURE__ */ React48.createElement(Shell, {
4246
- runtime: shellRuntime,
4247
- origin: window.location.origin
4309
+ runtime: shellRuntime
4248
4310
  })), /* @__PURE__ */ React48.createElement(ShellContext.Provider, {
4249
4311
  value: {
4250
4312
  runtime: shellRuntime,