@dxos/shell 0.6.5 → 0.6.6-staging.582ce24

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 (28) hide show
  1. package/dist/bundle/shell.mjs +5670 -5564
  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/bundle/style.css +1 -1
  6. package/dist/lib/browser/meta.json +1 -1
  7. package/dist/lib/browser/react.mjs +73 -59
  8. package/dist/lib/browser/react.mjs.map +3 -3
  9. package/dist/types/src/components/AuthCode.d.ts.map +1 -1
  10. package/dist/types/src/components/AuthCode.js +35 -6
  11. package/dist/types/src/components/AuthCode.js.map +1 -1
  12. package/dist/types/src/components/InvitationList/InvitationListItem.d.ts.map +1 -1
  13. package/dist/types/src/components/InvitationList/InvitationListItem.js +5 -4
  14. package/dist/types/src/components/InvitationList/InvitationListItem.js.map +1 -1
  15. package/dist/types/src/composites/Shell/Shell.js +1 -1
  16. package/dist/types/src/composites/Shell/Shell.js.map +1 -1
  17. package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.d.ts.map +1 -1
  18. package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.js +12 -32
  19. package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.js.map +1 -1
  20. package/dist/types/src/panels/SpacePanel/steps/SpaceManager.d.ts.map +1 -1
  21. package/dist/types/src/panels/SpacePanel/steps/SpaceManager.js +9 -8
  22. package/dist/types/src/panels/SpacePanel/steps/SpaceManager.js.map +1 -1
  23. package/package.json +23 -23
  24. package/src/components/AuthCode.tsx +15 -9
  25. package/src/components/InvitationList/InvitationListItem.tsx +6 -3
  26. package/src/composites/Shell/Shell.tsx +1 -1
  27. package/src/panels/IdentityPanel/steps/IdentityActionChooser.tsx +9 -10
  28. package/src/panels/SpacePanel/steps/SpaceManager.tsx +14 -9
@@ -701,20 +701,31 @@ import { focusRing, getSize as getSize7, mx as mx9 } from "@dxos/react-ui-theme"
701
701
  import { hexToEmoji } from "@dxos/util";
702
702
 
703
703
  // packages/sdk/shell/src/components/AuthCode.tsx
704
- import React11 from "react";
704
+ import React11, { useRef as useRef3 } from "react";
705
705
  import { mx as mx8 } from "@dxos/react-ui-theme";
706
706
  var AuthCode = (props) => {
707
707
  const { code, large, classNames } = props;
708
708
  const l = code?.length ?? 0;
709
709
  const left = code?.slice(0, l / 2);
710
710
  const right = code?.slice(l / 2);
711
- const handleCopy = () => {
711
+ const codeRef = useRef3(null);
712
+ const handleClick = () => {
713
+ if (codeRef.current) {
714
+ const selection = window.getSelection();
715
+ selection?.removeAllRanges();
716
+ const range = document.createRange();
717
+ range.selectNodeContents(codeRef.current);
718
+ selection?.addRange(range);
719
+ }
712
720
  void navigator.clipboard.writeText(code ?? "");
713
721
  };
714
722
  return /* @__PURE__ */ React11.createElement("span", {
715
- className: mx8(large ? "text-6xl" : "text-2xl", "font-mono pli-2.5 flex gap-1.5 rounded cursor-pointer", classNames),
716
- onClick: handleCopy
717
- }, /* @__PURE__ */ React11.createElement("span", null, left), /* @__PURE__ */ React11.createElement("span", null, right));
723
+ className: mx8(large ? "text-6xl" : "text-2xl", "font-mono pli-2.5 rounded cursor-pointer", classNames),
724
+ onClick: handleClick,
725
+ ref: codeRef
726
+ }, /* @__PURE__ */ React11.createElement("span", {
727
+ className: "mie-[0.4em]"
728
+ }, left), /* @__PURE__ */ React11.createElement("span", null, right));
718
729
  };
719
730
 
720
731
  // packages/sdk/shell/src/components/InvitationList/InvitationListItem.tsx
@@ -762,17 +773,17 @@ var AvatarStackEffect = ({ animation, status, reverseEffects }) => {
762
773
  };
763
774
  var InvitationListItemImpl = ({ invitation, invitationStatus: propsInvitationStatus, send, onClickRemove, createInvitationUrl, reverseEffects, ...props }) => {
764
775
  const { t } = useTranslation8("os");
765
- const { cancel, status: invitationStatus, invitationCode, authCode, multiUse } = propsInvitationStatus;
776
+ const { cancel, status: invitationStatus, invitationCode, authCode, multiUse, shareable } = propsInvitationStatus;
766
777
  const isCancellable = !([
767
778
  Invitation.State.ERROR,
768
779
  Invitation.State.TIMEOUT,
769
780
  Invitation.State.CANCELLED
770
781
  ].indexOf(invitationStatus) >= 0);
771
- const showShare = multiUse || [
782
+ const showShare = shareable && (multiUse || [
772
783
  Invitation.State.INIT,
773
784
  Invitation.State.CONNECTING,
774
785
  Invitation.State.CONNECTED
775
- ].indexOf(invitationStatus) >= 0;
786
+ ].indexOf(invitationStatus) >= 0);
776
787
  const showAuthCode = invitationStatus === Invitation.State.READY_FOR_AUTHENTICATION;
777
788
  const handleClickRemove = useCallback2(() => onClickRemove?.(invitation), [
778
789
  invitation,
@@ -862,7 +873,9 @@ var InvitationListItemImpl = ({ invitation, invitationStatus: propsInvitationSta
862
873
  className: "pli-2 grow text-neutral-500"
863
874
  }, "Cancelled") : invitationStatus === Invitation.State.SUCCESS ? /* @__PURE__ */ React12.createElement("span", {
864
875
  className: "pli-2 grow truncate"
865
- }, "User joined") : /* @__PURE__ */ React12.createElement("span", {
876
+ }, "User joined") : !shareable ? /* @__PURE__ */ React12.createElement("span", {
877
+ className: "pli-2 grow text-neutral-500"
878
+ }, "Pending Invitation") : /* @__PURE__ */ React12.createElement("span", {
866
879
  className: "grow"
867
880
  }, " "), isCancellable ? /* @__PURE__ */ React12.createElement(Button7, {
868
881
  variant: "ghost",
@@ -1344,7 +1357,7 @@ var useIdentityMachine = (client, options) => {
1344
1357
  };
1345
1358
 
1346
1359
  // packages/sdk/shell/src/panels/IdentityPanel/steps/IdentityActionChooser.tsx
1347
- import React25, { useCallback as useCallback4 } from "react";
1360
+ import React25 from "react";
1348
1361
  import { log as log2 } from "@dxos/log";
1349
1362
  import { useClient as useClient2 } from "@dxos/react-client";
1350
1363
  import { useHaloInvitations, DeviceType as DeviceType2 } from "@dxos/react-client/halo";
@@ -1354,25 +1367,25 @@ var IdentityActionChooser = (props) => {
1354
1367
  const { send } = props;
1355
1368
  const client = useClient2();
1356
1369
  const invitations = useHaloInvitations();
1357
- const onInvitationEvent = useCallback4((invitation) => {
1358
- const invitationCode = InvitationEncoder.encode(invitation);
1359
- if (invitation.state === Invitation2.State.CONNECTING) {
1360
- log2.info(JSON.stringify({
1361
- invitationCode,
1362
- authCode: invitation.authCode
1363
- }), void 0, {
1364
- F: __dxlog_file2,
1365
- L: 24,
1366
- S: void 0,
1367
- C: (f, a) => f(...a)
1368
- });
1369
- }
1370
- }, []);
1371
1370
  const createInvitation = () => {
1372
1371
  invitations.forEach((invitation2) => invitation2.cancel());
1373
1372
  const invitation = client.halo.share();
1374
- if (true) {
1375
- invitation.subscribe(onInvitationEvent);
1373
+ if (client.config.values.runtime?.app?.env?.DX_ENVIRONMENT !== "production") {
1374
+ const subscription = invitation.subscribe((invitation2) => {
1375
+ const invitationCode = InvitationEncoder.encode(invitation2);
1376
+ if (invitation2.state === Invitation2.State.CONNECTING) {
1377
+ log2.info(JSON.stringify({
1378
+ invitationCode,
1379
+ authCode: invitation2.authCode
1380
+ }), void 0, {
1381
+ F: __dxlog_file2,
1382
+ L: 29,
1383
+ S: void 0,
1384
+ C: (f, a) => f(...a)
1385
+ });
1386
+ subscription.unsubscribe();
1387
+ }
1388
+ });
1376
1389
  }
1377
1390
  send?.({
1378
1391
  type: "selectInvitation",
@@ -1410,7 +1423,7 @@ import { useTranslation as useTranslation11 } from "@dxos/react-ui";
1410
1423
  import { hexToEmoji as hexToEmoji2, hexToHue } from "@dxos/util";
1411
1424
 
1412
1425
  // packages/sdk/shell/src/panels/IdentityPanel/useAgentHandlers.ts
1413
- import { useCallback as useCallback5, useEffect as useEffect2, useState as useState6 } from "react";
1426
+ import { useCallback as useCallback4, useEffect as useEffect2, useState as useState6 } from "react";
1414
1427
  import { invariant } from "@dxos/invariant";
1415
1428
  import { log as log4 } from "@dxos/log";
1416
1429
  import { useClient as useClient3, useAgentHostingClient } from "@dxos/react-client";
@@ -1498,7 +1511,7 @@ var useAgentHandlers = ({ invitations, identity }) => {
1498
1511
  useEffect2(() => {
1499
1512
  void updateAgentStatus();
1500
1513
  }, []);
1501
- const handleAgentCreate = useCallback5(async (invitation) => {
1514
+ const handleAgentCreate = useCallback4(async (invitation) => {
1502
1515
  const invitationCode = InvitationEncoder2.encode(invitation);
1503
1516
  if (invitation.state === Invitation3.State.CONNECTING) {
1504
1517
  log4.info(JSON.stringify({
@@ -1995,7 +2008,7 @@ var IdentityPanel = ({ titleId: propsTitleId, createInvitationUrl = (code) => co
1995
2008
  };
1996
2009
 
1997
2010
  // packages/sdk/shell/src/panels/JoinPanel/JoinPanel.tsx
1998
- import React38, { useCallback as useCallback7, useEffect as useEffect5, useMemo as useMemo4 } from "react";
2011
+ import React38, { useCallback as useCallback6, useEffect as useEffect5, useMemo as useMemo4 } from "react";
1999
2012
  import { log as log10 } from "@dxos/log";
2000
2013
  import { useClient as useClient6, useMulticastObservable } from "@dxos/react-client";
2001
2014
  import { useIdentity as useIdentity2 } from "@dxos/react-client/halo";
@@ -2036,7 +2049,7 @@ var JoinHeading = /* @__PURE__ */ forwardRef9(({ mode, titleId, exitActionParent
2036
2049
 
2037
2050
  // packages/sdk/shell/src/panels/JoinPanel/joinMachine.ts
2038
2051
  import { useMachine as useMachine2 } from "@xstate/react";
2039
- import { useCallback as useCallback6 } from "react";
2052
+ import { useCallback as useCallback5 } from "react";
2040
2053
  import { assign as assign2, createMachine as createMachine2 } from "xstate";
2041
2054
  import { log as log7 } from "@dxos/log";
2042
2055
  import { AlreadyJoinedError } from "@dxos/react-client";
@@ -2533,7 +2546,7 @@ var defaultCodeFromUrl = (invitationType, text) => {
2533
2546
  }
2534
2547
  };
2535
2548
  var useJoinMachine = (client, options) => {
2536
- const redeemHaloInvitationCode = useCallback6(({ halo }) => {
2549
+ const redeemHaloInvitationCode = useCallback5(({ halo }) => {
2537
2550
  if (halo.unredeemedCode) {
2538
2551
  try {
2539
2552
  const invitation = InvitationEncoder3.decode(defaultCodeFromUrl("halo", halo.unredeemedCode));
@@ -2558,7 +2571,7 @@ var useJoinMachine = (client, options) => {
2558
2571
  }, [
2559
2572
  client
2560
2573
  ]);
2561
- const redeemSpaceInvitationCode = useCallback6(({ space }) => {
2574
+ const redeemSpaceInvitationCode = useCallback5(({ space }) => {
2562
2575
  if (space.unredeemedCode) {
2563
2576
  try {
2564
2577
  const invitation = InvitationEncoder3.decode(defaultCodeFromUrl("space", space.unredeemedCode));
@@ -2583,7 +2596,7 @@ var useJoinMachine = (client, options) => {
2583
2596
  }, [
2584
2597
  client
2585
2598
  ]);
2586
- const invalidateHaloInvitationCode = useCallback6(({ halo }) => {
2599
+ const invalidateHaloInvitationCode = useCallback5(({ halo }) => {
2587
2600
  if (halo.unredeemedCode) {
2588
2601
  options?.onInvalidateInvitationCode?.(halo.unredeemedCode);
2589
2602
  return {
@@ -2596,7 +2609,7 @@ var useJoinMachine = (client, options) => {
2596
2609
  }, [
2597
2610
  options?.onInvalidateInvitationCode
2598
2611
  ]);
2599
- const invalidateSpaceInvitationCode = useCallback6(({ space }) => {
2612
+ const invalidateSpaceInvitationCode = useCallback5(({ space }) => {
2600
2613
  if (space.unredeemedCode) {
2601
2614
  options?.onInvalidateInvitationCode?.(space.unredeemedCode);
2602
2615
  return {
@@ -3404,7 +3417,7 @@ var JoinPanel = ({ titleId: propsTitleId, mode = "default", initialDisposition =
3404
3417
  }), [
3405
3418
  joinState
3406
3419
  ]);
3407
- const onHaloDone = useCallback7(() => {
3420
+ const onHaloDone = useCallback6(() => {
3408
3421
  propsOnDone?.({
3409
3422
  identityKey: joinState.context.halo.invitation?.identityKey ?? null,
3410
3423
  swarmKey: joinState.context.halo.invitation?.swarmKey ?? null,
@@ -3415,7 +3428,7 @@ var JoinPanel = ({ titleId: propsTitleId, mode = "default", initialDisposition =
3415
3428
  joinState,
3416
3429
  propsOnDone
3417
3430
  ]);
3418
- const onSpaceDone = useCallback7(() => {
3431
+ const onSpaceDone = useCallback6(() => {
3419
3432
  propsOnDone?.({
3420
3433
  identityKey: joinState.context.space.invitation?.identityKey ?? null,
3421
3434
  swarmKey: joinState.context.space.invitation?.swarmKey ?? null,
@@ -3426,7 +3439,7 @@ var JoinPanel = ({ titleId: propsTitleId, mode = "default", initialDisposition =
3426
3439
  joinState,
3427
3440
  propsOnDone
3428
3441
  ]);
3429
- const onConfirmResetStorage = useCallback7(() => client.reset().then(() => {
3442
+ const onConfirmResetStorage = useCallback6(() => client.reset().then(() => {
3430
3443
  joinSend({
3431
3444
  type: "resetIdentity"
3432
3445
  });
@@ -3545,7 +3558,7 @@ var useSpaceMachine = (options) => {
3545
3558
 
3546
3559
  // packages/sdk/shell/src/panels/SpacePanel/steps/SpaceManager.tsx
3547
3560
  import { Placeholder as Placeholder2, UserPlus, UsersThree } from "@phosphor-icons/react";
3548
- import React39, { useCallback as useCallback8, useState as useState12 } from "react";
3561
+ import React39, { useCallback as useCallback7, useState as useState12 } from "react";
3549
3562
  import { log as log12 } from "@dxos/log";
3550
3563
  import { useConfig } from "@dxos/react-client";
3551
3564
  import { useSpaceInvitations as useSpaceInvitations2 } from "@dxos/react-client/echo";
@@ -3554,31 +3567,32 @@ import { ScrollArea, useTranslation as useTranslation23 } from "@dxos/react-ui";
3554
3567
  import { descriptionText as descriptionText11, mx as mx24 } from "@dxos/react-ui-theme";
3555
3568
  var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/shell/src/panels/SpacePanel/steps/SpaceManager.tsx";
3556
3569
  var activeActionKey = "dxos:react-shell/space-manager/active-action";
3570
+ var handleInvitationEvent = (invitation, subscription) => {
3571
+ const invitationCode = InvitationEncoder4.encode(invitation);
3572
+ if (invitation.state === Invitation7.State.CONNECTING) {
3573
+ log12.info(JSON.stringify({
3574
+ invitationCode,
3575
+ authCode: invitation.authCode
3576
+ }), void 0, {
3577
+ F: __dxlog_file11,
3578
+ L: 40,
3579
+ S: void 0,
3580
+ C: (f, a) => f(...a)
3581
+ });
3582
+ subscription.unsubscribe();
3583
+ }
3584
+ };
3557
3585
  var SpaceManager = (props) => {
3558
3586
  const { space, target } = props;
3559
3587
  const { t } = useTranslation23("os");
3560
3588
  const config = useConfig();
3561
3589
  const invitations = useSpaceInvitations2(space?.key);
3562
- const onInvitationEvent = useCallback8((invitation) => {
3563
- const invitationCode = InvitationEncoder4.encode(invitation);
3564
- if (invitation.state === Invitation7.State.CONNECTING) {
3565
- log12.info(JSON.stringify({
3566
- invitationCode,
3567
- authCode: invitation.authCode
3568
- }), void 0, {
3569
- F: __dxlog_file11,
3570
- L: 49,
3571
- S: void 0,
3572
- C: (f, a) => f(...a)
3573
- });
3574
- }
3575
- }, []);
3576
3590
  const inviteActions = {
3577
3591
  inviteOne: {
3578
3592
  label: t("invite one label"),
3579
3593
  description: t("invite one description"),
3580
3594
  icon: UserPlus,
3581
- onClick: useCallback8(() => {
3595
+ onClick: useCallback7(() => {
3582
3596
  const invitation = space.share?.({
3583
3597
  type: Invitation7.Type.INTERACTIVE,
3584
3598
  authMethod: Invitation7.AuthMethod.SHARED_SECRET,
@@ -3586,7 +3600,7 @@ var SpaceManager = (props) => {
3586
3600
  target
3587
3601
  });
3588
3602
  if (invitation && config.values.runtime?.app?.env?.DX_ENVIRONMENT !== "production") {
3589
- invitation.subscribe(onInvitationEvent);
3603
+ const subscription = invitation.subscribe((invitation2) => handleInvitationEvent(invitation2, subscription));
3590
3604
  }
3591
3605
  }, [
3592
3606
  space
@@ -3596,7 +3610,7 @@ var SpaceManager = (props) => {
3596
3610
  label: t("invite many label"),
3597
3611
  description: t("invite many description"),
3598
3612
  icon: UsersThree,
3599
- onClick: useCallback8(() => {
3613
+ onClick: useCallback7(() => {
3600
3614
  const invitation = space.share?.({
3601
3615
  type: Invitation7.Type.DELEGATED,
3602
3616
  authMethod: Invitation7.AuthMethod.KNOWN_PUBLIC_KEY,
@@ -3604,7 +3618,7 @@ var SpaceManager = (props) => {
3604
3618
  target
3605
3619
  });
3606
3620
  if (invitation && config.values.runtime?.app?.env?.DX_ENVIRONMENT !== "production") {
3607
- invitation.subscribe(onInvitationEvent);
3621
+ const subscription = invitation.subscribe((invitation2) => handleInvitationEvent(invitation2, subscription));
3608
3622
  }
3609
3623
  }, [
3610
3624
  space
@@ -3976,7 +3990,7 @@ var Shell = ({ runtime }) => {
3976
3990
  await client.reset();
3977
3991
  return runtime.setAppContext({
3978
3992
  display: ShellDisplay.NONE,
3979
- reload: true
3993
+ reset: true
3980
3994
  });
3981
3995
  },
3982
3996
  onJoinNewIdentity: async () => {
@@ -4357,7 +4371,7 @@ var Fallback = ({ onClose }) => {
4357
4371
  };
4358
4372
 
4359
4373
  // packages/sdk/shell/src/composites/Shell/ShellContext.tsx
4360
- import React48, { createContext as createContext2, useCallback as useCallback9, useContext as useContext2, useEffect as useEffect8, useMemo as useMemo6, useState as useState14 } from "react";
4374
+ import React48, { createContext as createContext2, useCallback as useCallback8, useContext as useContext2, useEffect as useEffect8, useMemo as useMemo6, useState as useState14 } from "react";
4361
4375
  import { useClient as useClient8, ShellDisplay as ShellDisplay3, ShellLayout as ShellLayout4 } from "@dxos/react-client";
4362
4376
  import { useIdentity as useIdentity3 } from "@dxos/react-client/halo";
4363
4377
  import { mx as mx25 } from "@dxos/react-ui-theme";
@@ -4464,7 +4478,7 @@ var ShellProvider = ({ space, deviceInvitationCode, spaceInvitationCode, onJoine
4464
4478
  spaceInvitationCode,
4465
4479
  deviceInvitationCode
4466
4480
  ]);
4467
- const handleKeyDown = useCallback9((event) => {
4481
+ const handleKeyDown = useCallback8((event) => {
4468
4482
  if (!space || !shellRuntime) {
4469
4483
  return;
4470
4484
  }