@dxos/plugin-deck 0.8.2-main.f11618f → 0.8.2-main.fbd8ed0

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 (132) hide show
  1. package/dist/lib/browser/{app-graph-builder-VYZ4IWI3.mjs → app-graph-builder-R7COZ4A6.mjs} +16 -15
  2. package/dist/lib/browser/app-graph-builder-R7COZ4A6.mjs.map +7 -0
  3. package/dist/lib/browser/{check-app-scheme-O7JPE4TM.mjs → check-app-scheme-7AXGR6UT.mjs} +2 -2
  4. package/dist/lib/browser/check-app-scheme-7AXGR6UT.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-3O2UZVBA.mjs +121 -0
  6. package/dist/lib/browser/chunk-3O2UZVBA.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-JAYQ5BTF.mjs +157 -0
  8. package/dist/lib/browser/chunk-JAYQ5BTF.mjs.map +7 -0
  9. package/dist/lib/browser/{chunk-RDFJGGGX.mjs → chunk-KIGMELV2.mjs} +186 -201
  10. package/dist/lib/browser/chunk-KIGMELV2.mjs.map +7 -0
  11. package/dist/lib/browser/{state-Z6UY2Z3M.mjs → chunk-OF5RIATN.mjs} +6 -4
  12. package/dist/lib/browser/chunk-OF5RIATN.mjs.map +7 -0
  13. package/dist/lib/browser/chunk-TRFYUEBA.mjs +145 -0
  14. package/dist/lib/browser/chunk-TRFYUEBA.mjs.map +7 -0
  15. package/dist/lib/browser/index.mjs +4 -5
  16. package/dist/lib/browser/index.mjs.map +1 -1
  17. package/dist/lib/browser/{intent-resolver-JKWXWUV6.mjs → intent-resolver-MAKOS57L.mjs} +78 -62
  18. package/dist/lib/browser/intent-resolver-MAKOS57L.mjs.map +7 -0
  19. package/dist/lib/browser/meta.json +1 -1
  20. package/dist/lib/browser/{react-root-S6ZAKNZA.mjs → react-root-DGQVIHXP.mjs} +6 -6
  21. package/dist/lib/browser/{react-surface-I7WZBOGM.mjs → react-surface-PXBXIOPU.mjs} +6 -6
  22. package/dist/lib/browser/{settings-6NU7CF2B.mjs → settings-UBWJF7J7.mjs} +4 -4
  23. package/dist/lib/browser/{settings-6NU7CF2B.mjs.map → settings-UBWJF7J7.mjs.map} +3 -3
  24. package/dist/lib/browser/state-4WFB4SDO.mjs +10 -0
  25. package/dist/lib/browser/state-4WFB4SDO.mjs.map +7 -0
  26. package/dist/lib/browser/{tools-VDVQTJMD.mjs → tools-IVPIPTVA.mjs} +7 -7
  27. package/dist/lib/browser/tools-IVPIPTVA.mjs.map +7 -0
  28. package/dist/lib/browser/types.mjs +1 -1
  29. package/dist/lib/browser/{url-handler-3CARFXQK.mjs → url-handler-JSYGSVSB.mjs} +4 -4
  30. package/dist/lib/browser/url-handler-JSYGSVSB.mjs.map +7 -0
  31. package/dist/types/src/capabilities/app-graph-builder.d.ts +2 -179
  32. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  33. package/dist/types/src/capabilities/check-app-scheme.d.ts +2 -2
  34. package/dist/types/src/capabilities/check-app-scheme.d.ts.map +1 -1
  35. package/dist/types/src/capabilities/index.d.ts +5 -180
  36. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  37. package/dist/types/src/capabilities/intent-resolver.d.ts +2 -2
  38. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  39. package/dist/types/src/capabilities/state.d.ts +2 -2
  40. package/dist/types/src/capabilities/state.d.ts.map +1 -1
  41. package/dist/types/src/capabilities/tools.d.ts.map +1 -1
  42. package/dist/types/src/capabilities/url-handler.d.ts +2 -2
  43. package/dist/types/src/capabilities/url-handler.d.ts.map +1 -1
  44. package/dist/types/src/components/DeckLayout/Banner.d.ts.map +1 -1
  45. package/dist/types/src/components/DeckLayout/ContentEmpty.d.ts.map +1 -1
  46. package/dist/types/src/components/DeckLayout/DeckLayout.d.ts.map +1 -1
  47. package/dist/types/src/components/DeckLayout/Popover.d.ts.map +1 -1
  48. package/dist/types/src/components/DeckLayout/StatusBar.d.ts.map +1 -1
  49. package/dist/types/src/components/DeckLayout/Toast.d.ts.map +1 -1
  50. package/dist/types/src/components/DeckSettings/DeckSettings.d.ts.map +1 -1
  51. package/dist/types/src/components/Plank/Plank.d.ts +18 -5
  52. package/dist/types/src/components/Plank/Plank.d.ts.map +1 -1
  53. package/dist/types/src/components/Plank/Plank.stories.d.ts +3 -3
  54. package/dist/types/src/components/Plank/Plank.stories.d.ts.map +1 -1
  55. package/dist/types/src/components/Plank/PlankControls.d.ts +1 -0
  56. package/dist/types/src/components/Plank/PlankControls.d.ts.map +1 -1
  57. package/dist/types/src/components/Plank/PlankError.d.ts.map +1 -1
  58. package/dist/types/src/components/Plank/PlankHeading.d.ts.map +1 -1
  59. package/dist/types/src/components/Sidebar/ComplementarySidebar.d.ts.map +1 -1
  60. package/dist/types/src/components/Sidebar/Sidebar.d.ts.map +1 -1
  61. package/dist/types/src/components/Sidebar/SidebarButton.d.ts +2 -1
  62. package/dist/types/src/components/Sidebar/SidebarButton.d.ts.map +1 -1
  63. package/dist/types/src/hooks/index.d.ts +5 -1
  64. package/dist/types/src/hooks/index.d.ts.map +1 -1
  65. package/dist/types/src/hooks/useBreakpoints.d.ts.map +1 -0
  66. package/dist/types/src/hooks/useCompanions.d.ts.map +1 -0
  67. package/dist/types/src/hooks/useDeckCompanions.d.ts +13 -0
  68. package/dist/types/src/hooks/useDeckCompanions.d.ts.map +1 -0
  69. package/dist/types/src/hooks/useHoistStatusbar.d.ts.map +1 -0
  70. package/dist/types/src/hooks/useNodeActionExpander.d.ts.map +1 -1
  71. package/dist/types/src/index.d.ts +1 -1
  72. package/dist/types/src/index.d.ts.map +1 -1
  73. package/dist/types/src/layout.d.ts.map +1 -1
  74. package/dist/types/src/types.d.ts +104 -104
  75. package/dist/types/src/types.d.ts.map +1 -1
  76. package/dist/types/src/util/index.d.ts +1 -4
  77. package/dist/types/src/util/index.d.ts.map +1 -1
  78. package/dist/types/src/util/layoutAppliesTopbar.d.ts.map +1 -1
  79. package/dist/types/src/util/overscroll.d.ts.map +1 -1
  80. package/dist/types/src/util/set-active.d.ts.map +1 -1
  81. package/dist/types/tsconfig.tsbuildinfo +1 -1
  82. package/package.json +35 -29
  83. package/src/capabilities/app-graph-builder.ts +120 -92
  84. package/src/capabilities/check-app-scheme.ts +3 -5
  85. package/src/capabilities/index.ts +1 -0
  86. package/src/capabilities/intent-resolver.ts +94 -76
  87. package/src/capabilities/settings.ts +2 -2
  88. package/src/capabilities/state.ts +4 -2
  89. package/src/capabilities/tools.ts +4 -3
  90. package/src/capabilities/url-handler.ts +4 -4
  91. package/src/components/DeckLayout/ContentEmpty.tsx +3 -2
  92. package/src/components/DeckLayout/DeckLayout.tsx +12 -10
  93. package/src/components/Plank/Plank.stories.tsx +20 -8
  94. package/src/components/Plank/Plank.tsx +100 -67
  95. package/src/components/Plank/PlankControls.tsx +15 -25
  96. package/src/components/Plank/PlankHeading.tsx +19 -9
  97. package/src/components/Sidebar/ComplementarySidebar.tsx +4 -35
  98. package/src/components/Sidebar/Sidebar.tsx +2 -1
  99. package/src/components/Sidebar/SidebarButton.tsx +30 -7
  100. package/src/components/fragments.ts +1 -1
  101. package/src/hooks/index.ts +5 -1
  102. package/src/{util → hooks}/useCompanions.ts +3 -3
  103. package/src/hooks/useDeckCompanions.ts +33 -0
  104. package/src/hooks/useNodeActionExpander.ts +3 -8
  105. package/src/index.ts +1 -1
  106. package/src/types.ts +72 -71
  107. package/src/util/index.ts +1 -4
  108. package/dist/lib/browser/app-graph-builder-VYZ4IWI3.mjs.map +0 -7
  109. package/dist/lib/browser/check-app-scheme-O7JPE4TM.mjs.map +0 -7
  110. package/dist/lib/browser/chunk-6HJZL3WT.mjs +0 -118
  111. package/dist/lib/browser/chunk-6HJZL3WT.mjs.map +0 -7
  112. package/dist/lib/browser/chunk-FLOVGNYB.mjs +0 -81
  113. package/dist/lib/browser/chunk-FLOVGNYB.mjs.map +0 -7
  114. package/dist/lib/browser/chunk-RBJ6DLAC.mjs +0 -24
  115. package/dist/lib/browser/chunk-RBJ6DLAC.mjs.map +0 -7
  116. package/dist/lib/browser/chunk-RDFJGGGX.mjs.map +0 -7
  117. package/dist/lib/browser/chunk-ZMJMCN7O.mjs +0 -157
  118. package/dist/lib/browser/chunk-ZMJMCN7O.mjs.map +0 -7
  119. package/dist/lib/browser/intent-resolver-JKWXWUV6.mjs.map +0 -7
  120. package/dist/lib/browser/state-Z6UY2Z3M.mjs.map +0 -7
  121. package/dist/lib/browser/tools-VDVQTJMD.mjs.map +0 -7
  122. package/dist/lib/browser/url-handler-3CARFXQK.mjs.map +0 -7
  123. package/dist/types/src/util/useBreakpoints.d.ts.map +0 -1
  124. package/dist/types/src/util/useCompanions.d.ts.map +0 -1
  125. package/dist/types/src/util/useHoistStatusbar.d.ts.map +0 -1
  126. /package/dist/lib/browser/{react-root-S6ZAKNZA.mjs.map → react-root-DGQVIHXP.mjs.map} +0 -0
  127. /package/dist/lib/browser/{react-surface-I7WZBOGM.mjs.map → react-surface-PXBXIOPU.mjs.map} +0 -0
  128. /package/dist/types/src/{util → hooks}/useBreakpoints.d.ts +0 -0
  129. /package/dist/types/src/{util → hooks}/useCompanions.d.ts +0 -0
  130. /package/dist/types/src/{util → hooks}/useHoistStatusbar.d.ts +0 -0
  131. /package/src/{util → hooks}/useBreakpoints.ts +0 -0
  132. /package/src/{util → hooks}/useHoistStatusbar.ts +0 -0
@@ -2,12 +2,14 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import React from 'react';
5
+ import React, { useCallback } from 'react';
6
6
 
7
- import { useCapability } from '@dxos/app-framework';
7
+ import { createIntent, LayoutAction, useCapability, useIntentDispatcher } from '@dxos/app-framework';
8
8
  import { IconButton, type IconButtonProps, type ThemedClassName, useTranslation } from '@dxos/react-ui';
9
9
 
10
10
  import { DeckCapabilities } from '../../capabilities';
11
+ import { useDeckCompanions } from '../../hooks';
12
+ import { getCompanionId } from '../../hooks/useDeckCompanions';
11
13
  import { DECK_PLUGIN } from '../../meta';
12
14
 
13
15
  export const ToggleSidebarButton = ({
@@ -47,16 +49,37 @@ export const CloseSidebarButton = () => {
47
49
  );
48
50
  };
49
51
 
50
- export const ToggleComplementarySidebarButton = ({ inR0, classNames }: ThemedClassName<{ inR0?: boolean }>) => {
52
+ export const ToggleComplementarySidebarButton = ({
53
+ inR0,
54
+ classNames,
55
+ current,
56
+ }: ThemedClassName<{ inR0?: boolean; current?: string }>) => {
57
+ const { dispatchPromise: dispatch } = useIntentDispatcher();
51
58
  const layoutContext = useCapability(DeckCapabilities.MutableDeckState);
52
59
  const { t } = useTranslation(DECK_PLUGIN);
60
+
61
+ const companions = useDeckCompanions();
62
+ const handleClick = useCallback(async () => {
63
+ layoutContext.complementarySidebarState =
64
+ layoutContext.complementarySidebarState === 'expanded' ? 'collapsed' : 'expanded';
65
+ const firstCompanion = companions[0];
66
+ if (layoutContext.complementarySidebarState === 'expanded' && !current && firstCompanion) {
67
+ await dispatch(
68
+ createIntent(LayoutAction.UpdateComplementary, {
69
+ part: 'complementary',
70
+ subject: getCompanionId(firstCompanion.id),
71
+ }),
72
+ );
73
+ }
74
+ }, [layoutContext, current, companions, dispatch]);
75
+
76
+ // TODO(thure): This should have a tooltip but is suppressed because focus is getting set on this twice when the app
77
+ // first mounts, causing even `suppressNextTooltip` not to have the intended effect.
53
78
  return (
54
79
  <IconButton
80
+ noTooltip
55
81
  iconOnly
56
- onClick={() =>
57
- (layoutContext.complementarySidebarState =
58
- layoutContext.complementarySidebarState === 'expanded' ? 'collapsed' : 'expanded')
59
- }
82
+ onClick={handleClick}
60
83
  variant='ghost'
61
84
  label={t('open complementary sidebar label')}
62
85
  classNames={['[&>svg]:-scale-x-100', classNames]}
@@ -7,7 +7,7 @@ import { mx } from '@dxos/react-ui-theme';
7
7
  export const soloInlinePadding =
8
8
  'pis-[calc(env(safe-area-inset-left)+.25rem)] pie-[calc(env(safe-area-inset-left)+.25rem)]';
9
9
 
10
- const sidebarToggleStyles = 'bs-[--rail-item] is-[--rail-item] absolute block-end-2 z-[1] !bg-deck lg:hidden';
10
+ const sidebarToggleStyles = 'bs-[--rail-item] is-[--rail-item] absolute block-end-2 z-[1] !bg-deckSurface lg:hidden';
11
11
 
12
12
  export const fixedSidebarToggleStyles = mx(sidebarToggleStyles, 'inline-start-2');
13
13
 
@@ -2,5 +2,9 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- export * from './useNodeActionExpander';
5
+ export * from './useBreakpoints';
6
+ export * from './useCompanions';
7
+ export * from './useDeckCompanions';
8
+ export * from './useHoistStatusbar';
6
9
  export * from './useMainSize';
10
+ export * from './useNodeActionExpander';
@@ -5,14 +5,14 @@
5
5
  import { useMemo } from 'react';
6
6
 
7
7
  import { useAppGraph } from '@dxos/app-framework';
8
- import { useNode } from '@dxos/plugin-graph';
8
+ import { useConnections } from '@dxos/plugin-graph';
9
9
  import { byPosition } from '@dxos/util';
10
10
 
11
11
  import { PLANK_COMPANION_TYPE } from '../types';
12
12
 
13
13
  export const useCompanions = (id?: string) => {
14
14
  const { graph } = useAppGraph();
15
- const node = useNode(graph, id);
16
- const companions = node ? graph.nodes(node, { type: PLANK_COMPANION_TYPE }) : [];
15
+ const nodes = useConnections(graph, id);
16
+ const companions = nodes.filter((node) => node.type === PLANK_COMPANION_TYPE);
17
17
  return useMemo(() => companions.toSorted((a, b) => byPosition(a.properties, b.properties)), [companions]);
18
18
  };
@@ -0,0 +1,33 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type Label, useAppGraph } from '@dxos/app-framework';
6
+ import { ROOT_ID, useConnections, type Node } from '@dxos/plugin-graph';
7
+ import { byPosition, type Position } from '@dxos/util';
8
+
9
+ import { ATTENDABLE_PATH_SEPARATOR, DECK_COMPANION_TYPE } from '../types';
10
+
11
+ export const getCompanionId = (id: string) => {
12
+ const [_, companionId] = id.split(ATTENDABLE_PATH_SEPARATOR);
13
+ return companionId ?? 'never';
14
+ };
15
+
16
+ export type DeckCompanion = Node<
17
+ any,
18
+ {
19
+ label: Label;
20
+ icon: string;
21
+ // TODO(burdon): Scroll area should be controlled by surface.
22
+ /** If true, the panel will not be wrapped in a scroll area. */
23
+ fixed?: boolean;
24
+ position?: Position;
25
+ }
26
+ >;
27
+
28
+ export const useDeckCompanions = (): DeckCompanion[] => {
29
+ const { graph } = useAppGraph();
30
+ const connections = useConnections(graph, ROOT_ID);
31
+ const companions = connections.filter((node) => node.type === DECK_COMPANION_TYPE) as DeckCompanion[];
32
+ return companions.toSorted((a, b) => byPosition(a.properties, b.properties));
33
+ };
@@ -4,19 +4,14 @@
4
4
 
5
5
  import { useEffect } from 'react';
6
6
 
7
- import { ACTION_GROUP_TYPE, ACTION_TYPE, getGraph, type Node } from '@dxos/plugin-graph';
8
-
9
- const expandNodeActions = async (node: Node) => {
10
- const graph = getGraph(node);
11
- await graph.expand(node, 'outbound', ACTION_GROUP_TYPE);
12
- await graph.expand(node, 'outbound', ACTION_TYPE);
13
- };
7
+ import { getGraph, type Node } from '@dxos/plugin-graph';
14
8
 
15
9
  export const useNodeActionExpander = (node?: Node) => {
16
10
  useEffect(() => {
17
11
  if (node) {
18
12
  const frame = requestAnimationFrame(() => {
19
- void expandNodeActions(node);
13
+ const graph = getGraph(node);
14
+ graph.expand(node.id);
20
15
  });
21
16
  return () => cancelAnimationFrame(frame);
22
17
  }
package/src/index.ts CHANGED
@@ -6,4 +6,4 @@ export { DeckCapabilities } from './capabilities';
6
6
  export { DeckEvents } from './events';
7
7
  export * from './DeckPlugin';
8
8
  export * from './meta';
9
- export { useCompanions } from './util';
9
+ export { useCompanions } from './hooks';
package/src/types.ts CHANGED
@@ -2,8 +2,9 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
+ import { Schema } from 'effect';
6
+
5
7
  import { LayoutAction } from '@dxos/app-framework';
6
- import { S } from '@dxos/echo-schema';
7
8
  import { type DeepReadonly } from '@dxos/util';
8
9
 
9
10
  import { DECK_PLUGIN } from './meta';
@@ -23,33 +24,33 @@ export type Overscroll = (typeof OverscrollOptions)[number];
23
24
  export type Part = 'solo' | 'deck' | 'complementary';
24
25
  export type ResolvedPart = Part | 'solo-primary' | 'solo-companion';
25
26
 
26
- export const DeckSettingsSchema = S.Struct({
27
- showHints: S.optional(S.Boolean),
28
- enableDeck: S.optional(S.Boolean),
29
- enableNativeRedirect: S.optional(S.Boolean),
30
- enableStatusbar: S.optional(S.Boolean),
31
- newPlankPositioning: S.optional(S.Literal(...NewPlankPositions)),
32
- overscroll: S.optional(S.Literal(...OverscrollOptions)),
33
- }).pipe(S.mutable);
34
- export type DeckSettingsProps = S.Schema.Type<typeof DeckSettingsSchema>;
27
+ export const DeckSettingsSchema = Schema.Struct({
28
+ showHints: Schema.optional(Schema.Boolean),
29
+ enableDeck: Schema.optional(Schema.Boolean),
30
+ enableStatusbar: Schema.optional(Schema.Boolean),
31
+ enableNativeRedirect: Schema.optional(Schema.Boolean),
32
+ newPlankPositioning: Schema.optional(Schema.Literal(...NewPlankPositions)),
33
+ overscroll: Schema.optional(Schema.Literal(...OverscrollOptions)),
34
+ }).pipe(Schema.mutable);
35
+ export type DeckSettingsProps = Schema.Schema.Type<typeof DeckSettingsSchema>;
35
36
 
36
- export const PlankSizing = S.Record({ key: S.String, value: S.Number });
37
- export type PlankSizing = S.Schema.Type<typeof PlankSizing>;
37
+ export const PlankSizing = Schema.Record({ key: Schema.String, value: Schema.Number });
38
+ export type PlankSizing = Schema.Schema.Type<typeof PlankSizing>;
38
39
 
39
40
  // State of an individual deck.
40
- export const DeckState = S.Struct({
41
+ export const DeckState = Schema.Struct({
41
42
  /** If false, the deck has not yet left solo mode and new planks should be soloed. */
42
- initialized: S.Boolean,
43
- active: S.mutable(S.Array(S.String)),
43
+ initialized: Schema.Boolean,
44
+ active: Schema.mutable(Schema.Array(Schema.String)),
44
45
  // TODO(wittjosiah): Piping into both mutable and optional caused invalid typescript output.
45
- activeCompanions: S.optional(S.mutable(S.Record({ key: S.String, value: S.String }))),
46
- inactive: S.mutable(S.Array(S.String)),
47
- solo: S.optional(S.String),
48
- fullscreen: S.Boolean,
49
- plankSizing: S.mutable(PlankSizing),
50
- companionFrameSizing: S.mutable(PlankSizing),
46
+ activeCompanions: Schema.optional(Schema.mutable(Schema.Record({ key: Schema.String, value: Schema.String }))),
47
+ inactive: Schema.mutable(Schema.Array(Schema.String)),
48
+ solo: Schema.optional(Schema.String),
49
+ fullscreen: Schema.Boolean,
50
+ plankSizing: Schema.mutable(PlankSizing),
51
+ companionFrameSizing: Schema.mutable(PlankSizing),
51
52
  });
52
- export type DeckState = S.Schema.Type<typeof DeckState>;
53
+ export type DeckState = Schema.Schema.Type<typeof DeckState>;
53
54
 
54
55
  export const defaultDeck: DeckState = {
55
56
  initialized: false,
@@ -62,9 +63,9 @@ export const defaultDeck: DeckState = {
62
63
  companionFrameSizing: {},
63
64
  };
64
65
 
65
- const LayoutMode = S.Literal('deck', 'solo', 'solo--fullscreen');
66
- export type LayoutMode = S.Schema.Type<typeof LayoutMode>;
67
- export const isLayoutMode = (value: any): value is LayoutMode => S.is(LayoutMode)(value);
66
+ const LayoutMode = Schema.Literal('deck', 'solo', 'solo--fullscreen');
67
+ export type LayoutMode = Schema.Schema.Type<typeof LayoutMode>;
68
+ export const isLayoutMode = (value: any): value is LayoutMode => Schema.is(LayoutMode)(value);
68
69
 
69
70
  export const getMode = (deck: DeckState | DeepReadonly<DeckState>): LayoutMode => {
70
71
  if (deck.solo) {
@@ -75,73 +76,73 @@ export const getMode = (deck: DeckState | DeepReadonly<DeckState>): LayoutMode =
75
76
  };
76
77
 
77
78
  // State of the deck plugin.
78
- export const DeckPluginState = S.Struct({
79
- sidebarState: S.Literal('closed', 'collapsed', 'expanded'),
80
- complementarySidebarState: S.Literal('closed', 'collapsed', 'expanded'),
81
- complementarySidebarPanel: S.optional(S.String),
82
-
83
- dialogOpen: S.Boolean,
84
- dialogBlockAlign: S.optional(S.Literal('start', 'center', 'end')),
85
- dialogType: S.optional(S.Literal('default', 'alert')),
79
+ export const DeckPluginState = Schema.Struct({
80
+ sidebarState: Schema.Literal('closed', 'collapsed', 'expanded'),
81
+ complementarySidebarState: Schema.Literal('closed', 'collapsed', 'expanded'),
82
+ complementarySidebarPanel: Schema.optional(Schema.String),
83
+
84
+ dialogOpen: Schema.Boolean,
85
+ dialogBlockAlign: Schema.optional(Schema.Literal('start', 'center', 'end')),
86
+ dialogType: Schema.optional(Schema.Literal('default', 'alert')),
86
87
  /** Data to be passed to the dialog Surface. */
87
- dialogContent: S.optional(S.Any),
88
+ dialogContent: Schema.optional(Schema.Any),
88
89
 
89
- popoverOpen: S.Boolean,
90
- popoverSide: S.optional(S.Literal('top', 'right', 'bottom', 'left')),
91
- popoverAnchor: S.optional(S.Any),
92
- popoverAnchorId: S.optional(S.String),
90
+ popoverOpen: Schema.Boolean,
91
+ popoverSide: Schema.optional(Schema.Literal('top', 'right', 'bottom', 'left')),
92
+ popoverAnchor: Schema.optional(Schema.Any),
93
+ popoverAnchorId: Schema.optional(Schema.String),
93
94
  /** Data to be passed to the popover Surface. */
94
- popoverContent: S.optional(S.Any),
95
+ popoverContent: Schema.optional(Schema.Any),
95
96
 
96
- toasts: S.mutable(S.Array(LayoutAction.Toast)),
97
- currentUndoId: S.optional(S.String),
97
+ toasts: Schema.mutable(Schema.Array(LayoutAction.Toast)),
98
+ currentUndoId: Schema.optional(Schema.String),
98
99
 
99
- activeDeck: S.String,
100
- previousDeck: S.String,
101
- decks: S.mutable(S.Record({ key: S.String, value: S.mutable(DeckState) })),
102
- previousMode: S.mutable(S.Record({ key: S.String, value: LayoutMode })),
103
- deck: S.mutable(DeckState),
100
+ activeDeck: Schema.String,
101
+ previousDeck: Schema.String,
102
+ decks: Schema.mutable(Schema.Record({ key: Schema.String, value: Schema.mutable(DeckState) })),
103
+ previousMode: Schema.mutable(Schema.Record({ key: Schema.String, value: LayoutMode })),
104
+ deck: Schema.mutable(DeckState),
104
105
 
105
106
  /** The identifier of a component to scroll into view when it is mounted. */
106
- scrollIntoView: S.optional(S.String),
107
- }).pipe(S.mutable);
107
+ scrollIntoView: Schema.optional(Schema.String),
108
+ }).pipe(Schema.mutable);
108
109
 
109
- export type DeckPluginState = S.Schema.Type<typeof DeckPluginState>;
110
+ export type DeckPluginState = Schema.Schema.Type<typeof DeckPluginState>;
110
111
 
111
112
  export const DECK_ACTION = `${DECK_PLUGIN}/action`;
112
113
 
113
114
  export namespace DeckAction {
114
- const PartAdjustmentSchema = S.Union(
115
- S.Literal('close').annotations({ description: 'Close the plank.' }),
116
- S.Literal('companion').annotations({ description: 'Open the companion plank.' }),
117
- S.Literal('solo').annotations({ description: 'Solo the plank.' }),
118
- S.Literal('solo--fullscreen').annotations({ description: 'Fullscreen the plank.' }),
119
- S.Literal('increment-start').annotations({ description: 'Move the plank towards the start of the deck.' }),
120
- S.Literal('increment-end').annotations({ description: 'Move the plank towards the end of the deck.' }),
115
+ const PartAdjustmentSchema = Schema.Union(
116
+ Schema.Literal('close').annotations({ description: 'Close the plank.' }),
117
+ Schema.Literal('companion').annotations({ description: 'Open the companion plank.' }),
118
+ Schema.Literal('solo').annotations({ description: 'Solo the plank.' }),
119
+ Schema.Literal('solo--fullscreen').annotations({ description: 'Fullscreen the plank.' }),
120
+ Schema.Literal('increment-start').annotations({ description: 'Move the plank towards the start of the deck.' }),
121
+ Schema.Literal('increment-end').annotations({ description: 'Move the plank towards the end of the deck.' }),
121
122
  );
122
- export type PartAdjustment = S.Schema.Type<typeof PartAdjustmentSchema>;
123
- export const Adjustment = S.mutable(S.Struct({ id: S.String, type: PartAdjustmentSchema }));
124
- export type Adjustment = S.Schema.Type<typeof Adjustment>;
123
+ export type PartAdjustment = Schema.Schema.Type<typeof PartAdjustmentSchema>;
124
+ export const Adjustment = Schema.mutable(Schema.Struct({ id: Schema.String, type: PartAdjustmentSchema }));
125
+ export type Adjustment = Schema.Schema.Type<typeof Adjustment>;
125
126
 
126
127
  // An atomic transaction to apply to the deck, describing which element to move to which location.
127
- export class Adjust extends S.TaggedClass<Adjust>()(`${DECK_ACTION}/adjust`, {
128
+ export class Adjust extends Schema.TaggedClass<Adjust>()(`${DECK_ACTION}/adjust`, {
128
129
  input: Adjustment,
129
- output: S.Void,
130
+ output: Schema.Void,
130
131
  }) {}
131
132
 
132
- export class UpdatePlankSize extends S.TaggedClass<UpdatePlankSize>()(`${DECK_ACTION}/update-plank-size`, {
133
- input: S.Struct({
134
- id: S.String,
135
- size: S.Number,
133
+ export class UpdatePlankSize extends Schema.TaggedClass<UpdatePlankSize>()(`${DECK_ACTION}/update-plank-size`, {
134
+ input: Schema.Struct({
135
+ id: Schema.String,
136
+ size: Schema.Number,
136
137
  }),
137
- output: S.Void,
138
+ output: Schema.Void,
138
139
  }) {}
139
140
 
140
- export class ChangeCompanion extends S.TaggedClass<ChangeCompanion>()(`${DECK_ACTION}/change-companion`, {
141
- input: S.Struct({
142
- primary: S.String,
143
- companion: S.Union(S.String, S.Null),
141
+ export class ChangeCompanion extends Schema.TaggedClass<ChangeCompanion>()(`${DECK_ACTION}/change-companion`, {
142
+ input: Schema.Struct({
143
+ primary: Schema.String,
144
+ companion: Schema.Union(Schema.String, Schema.Null),
144
145
  }),
145
- output: S.Void,
146
+ output: Schema.Void,
146
147
  }) {}
147
148
  }
package/src/util/index.ts CHANGED
@@ -2,9 +2,6 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
+ export * from './layoutAppliesTopbar';
5
6
  export * from './overscroll';
6
7
  export * from './set-active';
7
- export * from './useBreakpoints';
8
- export * from './layoutAppliesTopbar';
9
- export * from './useHoistStatusbar';
10
- export * from './useCompanions';
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/app-graph-builder.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capabilities, contributes, createIntent, LayoutAction, type PluginsContext } from '@dxos/app-framework';\nimport { AttentionCapabilities } from '@dxos/plugin-attention';\nimport { createExtension, type Node, ROOT_ID } from '@dxos/plugin-graph';\n\nimport { DeckCapabilities } from './capabilities';\nimport { DECK_PLUGIN } from '../meta';\n\nexport default (context: PluginsContext) =>\n contributes(\n Capabilities.AppGraphBuilder,\n createExtension({\n id: DECK_PLUGIN,\n filter: (node): node is Node<null> => node.id === ROOT_ID,\n actions: () => {\n const state = context.requestCapability(DeckCapabilities.MutableDeckState);\n\n // NOTE(Zan): This is currently disabled.\n // TODO(Zan): Fullscreen needs to know the active node and provide that to the layout part.\n const _fullscreen = {\n id: `${LayoutAction.UpdateLayout._tag}/fullscreen`,\n data: async () => {\n const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);\n await dispatch(createIntent(LayoutAction.SetLayoutMode, { part: 'mode', options: { mode: 'fullscreen' } }));\n },\n properties: {\n label: ['toggle fullscreen label', { ns: DECK_PLUGIN }],\n icon: 'ph--arrows-out--regular',\n keyBinding: {\n macos: 'ctrl+meta+f',\n windows: 'shift+ctrl+f',\n },\n },\n };\n\n const closeCurrent = {\n id: `${LayoutAction.Close._tag}/current`,\n data: async () => {\n const attention = context.requestCapability(AttentionCapabilities.Attention);\n const attended = attention.current.at(-1);\n if (attended) {\n const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);\n await dispatch(\n createIntent(LayoutAction.Close, { part: 'main', subject: [attended], options: { state: false } }),\n );\n }\n },\n properties: {\n label: ['close current label', { ns: DECK_PLUGIN }],\n icon: 'ph--x--regular',\n },\n };\n\n const closeOthers = {\n id: `${LayoutAction.Close._tag}/others`,\n data: async () => {\n const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);\n const attention = context.requestCapability(AttentionCapabilities.Attention);\n const attended = attention.current.at(-1);\n const ids = state.deck.active.filter((id) => id !== attended) ?? [];\n await dispatch(createIntent(LayoutAction.Close, { part: 'main', subject: ids, options: { state: false } }));\n },\n properties: {\n label: ['close others label', { ns: DECK_PLUGIN }],\n icon: 'ph--x-square--regular',\n },\n };\n\n const closeAll = {\n id: `${LayoutAction.Close._tag}/all`,\n data: async () => {\n const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);\n await dispatch(\n createIntent(LayoutAction.Close, {\n part: 'main',\n subject: state.deck.active,\n options: { state: false },\n }),\n );\n },\n properties: {\n label: ['close all label', { ns: DECK_PLUGIN }],\n icon: 'ph--x-circle--regular',\n },\n };\n\n const toggleSidebar = {\n id: `${LayoutAction.UpdateSidebar._tag}/nav`,\n data: async () => {\n state.sidebarState = state.sidebarState === 'expanded' ? 'collapsed' : 'expanded';\n },\n properties: {\n label: [\n state.sidebarState === 'expanded' ? 'collapse navigation sidebar label' : 'open navigation sidebar label',\n { ns: DECK_PLUGIN },\n ],\n icon: 'ph--sidebar--regular',\n keyBinding: {\n macos: 'meta+b',\n },\n disposition: 'pin-end',\n position: 'hoist',\n l0Breakpoint: 'lg',\n },\n };\n\n return !state.deck.solo ? [closeCurrent, closeOthers, closeAll, toggleSidebar] : [toggleSidebar];\n },\n }),\n );\n"],
5
- "mappings": "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",
6
- "names": ["Capabilities", "contributes", "createIntent", "LayoutAction", "AttentionCapabilities", "createExtension", "ROOT_ID", "context", "contributes", "Capabilities", "AppGraphBuilder", "createExtension", "id", "DECK_PLUGIN", "filter", "node", "ROOT_ID", "actions", "state", "requestCapability", "DeckCapabilities", "MutableDeckState", "_fullscreen", "LayoutAction", "UpdateLayout", "_tag", "data", "dispatchPromise", "dispatch", "IntentDispatcher", "createIntent", "SetLayoutMode", "part", "options", "mode", "properties", "label", "ns", "icon", "keyBinding", "macos", "windows", "closeCurrent", "Close", "attention", "AttentionCapabilities", "Attention", "attended", "current", "at", "subject", "closeOthers", "ids", "deck", "active", "closeAll", "toggleSidebar", "UpdateSidebar", "sidebarState", "disposition", "position", "l0Breakpoint", "solo"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/check-app-scheme.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capabilities, contributes, type PluginsContext } from '@dxos/app-framework';\n\nimport { DECK_PLUGIN } from '../meta';\nimport { type DeckSettingsProps } from '../types';\n\nconst isSocket = !!(globalThis as any).__args;\n\n// TODO(mjamesderocher): Can we get this directly from Socket?\nconst appScheme = 'composer://';\n\n// TODO(mjamesderocher): Factor out as part of NavigationPlugin.\nconst checkAppScheme = (url: string) => {\n const iframe = document.createElement('iframe');\n iframe.style.display = 'none';\n document.body.appendChild(iframe);\n\n iframe.src = url + window.location.pathname.replace(/^\\/+/, '') + window.location.search;\n\n const timer = setTimeout(() => {\n document.body.removeChild(iframe);\n }, 3000);\n\n window.addEventListener('pagehide', (event) => {\n clearTimeout(timer);\n document.body.removeChild(iframe);\n });\n};\n\nexport default async (context: PluginsContext) => {\n const settings = context\n .requestCapability(Capabilities.SettingsStore)\n .getStore<DeckSettingsProps>(DECK_PLUGIN)?.value;\n if (!isSocket && settings?.enableNativeRedirect) {\n checkAppScheme(appScheme);\n }\n\n return contributes(Capabilities.Null, null);\n};\n"],
5
- "mappings": ";;;;;AAIA,SAASA,cAAcC,mBAAwC;AAK/D,IAAMC,WAAW,CAAC,CAAEC,WAAmBC;AAGvC,IAAMC,YAAY;AAGlB,IAAMC,iBAAiB,CAACC,QAAAA;AACtB,QAAMC,SAASC,SAASC,cAAc,QAAA;AACtCF,SAAOG,MAAMC,UAAU;AACvBH,WAASI,KAAKC,YAAYN,MAAAA;AAE1BA,SAAOO,MAAMR,MAAMS,OAAOC,SAASC,SAASC,QAAQ,QAAQ,EAAA,IAAMH,OAAOC,SAASG;AAElF,QAAMC,QAAQC,WAAW,MAAA;AACvBb,aAASI,KAAKU,YAAYf,MAAAA;EAC5B,GAAG,GAAA;AAEHQ,SAAOQ,iBAAiB,YAAY,CAACC,UAAAA;AACnCC,iBAAaL,KAAAA;AACbZ,aAASI,KAAKU,YAAYf,MAAAA;EAC5B,CAAA;AACF;AAEA,IAAA,2BAAe,OAAOmB,YAAAA;AACpB,QAAMC,WAAWD,QACdE,kBAAkBC,aAAaC,aAAa,EAC5CC,SAA4BC,WAAAA,GAAcC;AAC7C,MAAI,CAAChC,YAAY0B,UAAUO,sBAAsB;AAC/C7B,mBAAeD,SAAAA;EACjB;AAEA,SAAO+B,YAAYN,aAAaO,MAAM,IAAA;AACxC;",
6
- "names": ["Capabilities", "contributes", "isSocket", "globalThis", "__args", "appScheme", "checkAppScheme", "url", "iframe", "document", "createElement", "style", "display", "body", "appendChild", "src", "window", "location", "pathname", "replace", "search", "timer", "setTimeout", "removeChild", "addEventListener", "event", "clearTimeout", "context", "settings", "requestCapability", "Capabilities", "SettingsStore", "getStore", "DECK_PLUGIN", "value", "enableNativeRedirect", "contributes", "Null"]
7
- }
@@ -1,118 +0,0 @@
1
- import {
2
- PLANK_COMPANION_TYPE
3
- } from "./chunk-ZMJMCN7O.mjs";
4
- import {
5
- DECK_PLUGIN
6
- } from "./chunk-NSATFAEE.mjs";
7
-
8
- // packages/plugins/plugin-deck/src/util/set-active.ts
9
- import { batch } from "@preact/signals-core";
10
- var setActive = ({ next, state, attention }) => {
11
- return batch(() => {
12
- const active = state.deck.solo ? [
13
- state.deck.solo
14
- ] : state.deck.active;
15
- const removed = active.filter((id) => !next.includes(id));
16
- const closed = Array.from(/* @__PURE__ */ new Set([
17
- ...state.deck.inactive.filter((id) => !next.includes(id)),
18
- ...removed
19
- ]));
20
- state.deck.inactive = closed;
21
- if (state.deck.solo || !state.deck.initialized) {
22
- state.deck.solo = next[0];
23
- } else {
24
- state.deck.active = next;
25
- }
26
- if (state.deck.fullscreen && !state.deck.solo) {
27
- state.deck.fullscreen = false;
28
- }
29
- if (attention) {
30
- const attended = attention.current;
31
- const [attendedId] = Array.from(attended);
32
- const isAttendedAvailable = !!attendedId && next.includes(attendedId);
33
- if (!isAttendedAvailable) {
34
- const attendedIndex = active.indexOf(attendedId);
35
- const index = attendedIndex === -1 ? 0 : attendedIndex >= next.length ? next.length - 1 : attendedIndex;
36
- return next[index];
37
- }
38
- }
39
- });
40
- };
41
-
42
- // packages/plugins/plugin-deck/src/util/useCompanions.ts
43
- import { useMemo } from "react";
44
- import { useAppGraph } from "@dxos/app-framework";
45
- import { useNode } from "@dxos/plugin-graph";
46
- import { byPosition } from "@dxos/util";
47
- var useCompanions = (id) => {
48
- const { graph } = useAppGraph();
49
- const node = useNode(graph, id);
50
- const companions = node ? graph.nodes(node, {
51
- type: PLANK_COMPANION_TYPE
52
- }) : [];
53
- return useMemo(() => companions.toSorted((a, b) => byPosition(a.properties, b.properties)), [
54
- companions
55
- ]);
56
- };
57
-
58
- // packages/plugins/plugin-deck/src/util/overscroll.ts
59
- var calculateOverscroll = (planksCount) => {
60
- if (!planksCount) {
61
- return {
62
- paddingInlineStart: 0,
63
- paddingInlineEnd: 0
64
- };
65
- }
66
- if (planksCount === 1) {
67
- const overscrollPadding = "max(0px, calc(((100dvw - var(--dx-main-sidebarWidth) - var(--dx-main-complementaryWidth) - (var(--dx-main-contentFirstWidth) + 1px)) / 2)))";
68
- return {
69
- paddingInlineStart: overscrollPadding,
70
- paddingInlineEnd: overscrollPadding
71
- };
72
- } else {
73
- return {
74
- paddingInlineStart: "max(0px, calc(((100dvw - (var(--dx-main-contentFirstWidth) + 1px)) / 2) - var(--dx-main-sidebarWidth)))",
75
- paddingInlineEnd: "max(0px, calc(((100dvw - (var(--dx-main-contentLastWidth) + 1px)) / 2) - var(--dx-main-complementaryWidth)))"
76
- };
77
- }
78
- };
79
-
80
- // packages/plugins/plugin-deck/src/util/useBreakpoints.ts
81
- import { useMediaQuery } from "@dxos/react-ui";
82
- var useBreakpoints = () => {
83
- const [isNotMobile] = useMediaQuery("md");
84
- const [isDesktop] = useMediaQuery("lg");
85
- return isDesktop ? "desktop" : isNotMobile ? "tablet" : "mobile";
86
- };
87
-
88
- // packages/plugins/plugin-deck/src/util/layoutAppliesTopbar.ts
89
- var layoutAppliesTopbar = (breakpoint, layoutMode) => {
90
- return document.body.getAttribute("data-platform") === "win" && breakpoint === "desktop" && layoutMode !== "solo--fullscreen";
91
- };
92
-
93
- // packages/plugins/plugin-deck/src/util/useHoistStatusbar.ts
94
- import { useMemo as useMemo2 } from "react";
95
- import { Capabilities, useCapability } from "@dxos/app-framework";
96
- import { useThemeContext } from "@dxos/react-ui";
97
- var useHoistStatusbar = (breakpoint, layoutMode) => {
98
- const enableStatusbar = useCapability(Capabilities.SettingsStore).getStore(DECK_PLUGIN).value.enableStatusbar;
99
- const { safeAreaPadding } = useThemeContext();
100
- return useMemo2(() => {
101
- return breakpoint === "desktop" && layoutMode !== "solo--fullscreen" && !!enableStatusbar && safeAreaPadding?.bottom === 0;
102
- }, [
103
- enableStatusbar,
104
- breakpoint,
105
- safeAreaPadding?.bottom,
106
- layoutMode
107
- ]);
108
- };
109
-
110
- export {
111
- calculateOverscroll,
112
- setActive,
113
- useBreakpoints,
114
- layoutAppliesTopbar,
115
- useHoistStatusbar,
116
- useCompanions
117
- };
118
- //# sourceMappingURL=chunk-6HJZL3WT.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/util/set-active.ts", "../../../src/util/useCompanions.ts", "../../../src/util/overscroll.ts", "../../../src/util/useBreakpoints.ts", "../../../src/util/layoutAppliesTopbar.ts", "../../../src/util/useHoistStatusbar.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { batch } from '@preact/signals-core';\n\nimport { type AttentionManager } from '@dxos/plugin-attention';\n\nimport { type DeckPluginState } from '../types';\n\nexport type SetActiveOptions = {\n next: string[];\n state: DeckPluginState;\n attention?: AttentionManager;\n};\n\nexport const setActive = ({ next, state, attention }: SetActiveOptions) => {\n return batch(() => {\n const active = state.deck.solo ? [state.deck.solo] : state.deck.active;\n const removed = active.filter((id) => !next.includes(id));\n const closed = Array.from(new Set([...state.deck.inactive.filter((id) => !next.includes(id)), ...removed]));\n\n state.deck.inactive = closed;\n\n if (state.deck.solo || !state.deck.initialized) {\n state.deck.solo = next[0];\n } else {\n state.deck.active = next;\n }\n\n if (state.deck.fullscreen && !state.deck.solo) {\n state.deck.fullscreen = false;\n }\n\n if (attention) {\n const attended = attention.current;\n const [attendedId] = Array.from(attended);\n const isAttendedAvailable = !!attendedId && next.includes(attendedId);\n if (!isAttendedAvailable) {\n const attendedIndex = active.indexOf(attendedId);\n // If outside of bounds, focus on the first/last plank, otherwise focus on the new plank in the same position.\n const index = attendedIndex === -1 ? 0 : attendedIndex >= next.length ? next.length - 1 : attendedIndex;\n return next[index];\n }\n }\n });\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useMemo } from 'react';\n\nimport { useAppGraph } from '@dxos/app-framework';\nimport { useNode } from '@dxos/plugin-graph';\nimport { byPosition } from '@dxos/util';\n\nimport { PLANK_COMPANION_TYPE } from '../types';\n\nexport const useCompanions = (id?: string) => {\n const { graph } = useAppGraph();\n const node = useNode(graph, id);\n const companions = node ? graph.nodes(node, { type: PLANK_COMPANION_TYPE }) : [];\n return useMemo(() => companions.toSorted((a, b) => byPosition(a.properties, b.properties)), [companions]);\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport type { CSSProperties } from 'react';\n\n/**\n * ┌────────────────────────────────────────────────────────────────────────────────────────────────────┐\n * | Overscroll Padding Calculation for Centering Planks on Screen. │\n * ├────────────────────────────────────────────────────────────────────────────────────────────────────┤\n * │ NOTE(Zan): I found the way you calculate the overscroll padding to center a plank on the screen │\n * │ at the edges of the scroll context a bit confusing, so I've diagrammed it here. │\n * │ │\n * │ Multiple Planks: │\n * │ ─────────────── │\n * | Use the following overscroll padding calculation centering the boundary planks on the SCREEN. │\n * │ │\n * │ Left Padding: Right Padding: │\n * │ ┌───┬────┬──────────────────┬──────┐ ┌──────┬──────────────────┬────┬───┐ │\n * │ │ │████│ Ideal │ │ │ │ Ideal │████│ │ │\n * │ │ S │█PL█│ first │ │ │ │ last │█PR█│ C │ │\n * │ │ │████│ plank │ │ │ │ plank │████│ │ │\n * │ └───┴────┴──────────────────┴──────┘ └──────┴──────────────────┴────┴───┘ │\n * │ <--------- screen width -----------> <---------- screen width ----------> │\n * │ │\n * │ PL = ((screen width - Plank Width) / 2) - S │\n * │ PR = ((screen width - Plank Width) / 2) - C │\n * │ │\n * │ S = Sidebar width C = Complementary sidebar width │\n * │ PL = Padding Left PR = Padding Right │\n * │ │\n * │ Single Plank: │\n * │ ───────────── │\n * │ For a single plank we use the following overscroll padding calculation to center the plank in │\n * │ the content area: │\n * │ │\n * │ ┌───┬───────────────────────┬───┬───────────────────────┬───┐ │\n * │ │ │███████████████████████│ │███████████████████████│ │ │\n * │ │ S │█████ Left Padding ████│ P │████ Right Padding ████│ C │ │\n * │ │ │███████████████████████│ │███████████████████████│ │ │\n * │ └───┴───────────────────────┴───┴───────────────────────┴───┘ │\n * │ <------------------------ screen width ---------------------> │\n * │ │\n * │ Left/Right Padding Width = (screen width - S - P - C) / 2 │\n * │ │\n * │ S = Sidebar width (may be 0) │\n * │ P = Plank width (centered) │\n * │ C = Complementary sidebar width (may be 0) │\n * └────────────────────────────────────────────────────────────────────────────────────────────────────┘\n */\nexport const calculateOverscroll = (\n planksCount: number,\n): Pick<CSSProperties, 'paddingInlineStart' | 'paddingInlineEnd'> | undefined => {\n if (!planksCount) {\n return { paddingInlineStart: 0, paddingInlineEnd: 0 };\n }\n if (planksCount === 1) {\n const overscrollPadding =\n 'max(0px, calc(((100dvw - var(--dx-main-sidebarWidth) - var(--dx-main-complementaryWidth) - (var(--dx-main-contentFirstWidth) + 1px)) / 2)))';\n return { paddingInlineStart: overscrollPadding, paddingInlineEnd: overscrollPadding };\n } else {\n return {\n paddingInlineStart:\n 'max(0px, calc(((100dvw - (var(--dx-main-contentFirstWidth) + 1px)) / 2) - var(--dx-main-sidebarWidth)))',\n paddingInlineEnd:\n 'max(0px, calc(((100dvw - (var(--dx-main-contentLastWidth) + 1px)) / 2) - var(--dx-main-complementaryWidth)))',\n };\n }\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useMediaQuery } from '@dxos/react-ui';\n\nexport const useBreakpoints = () => {\n const [isNotMobile] = useMediaQuery('md');\n const [isDesktop] = useMediaQuery('lg');\n return isDesktop ? 'desktop' : isNotMobile ? 'tablet' : 'mobile';\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type LayoutMode } from '../types';\n\nexport const layoutAppliesTopbar = (breakpoint: string, layoutMode?: LayoutMode) => {\n return (\n document.body.getAttribute('data-platform') === 'win' &&\n breakpoint === 'desktop' &&\n layoutMode !== 'solo--fullscreen'\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useMemo } from 'react';\n\nimport { Capabilities, useCapability } from '@dxos/app-framework';\nimport { useThemeContext } from '@dxos/react-ui';\n\nimport { DECK_PLUGIN } from '../meta';\nimport type { DeckSettingsProps, LayoutMode } from '../types';\n\nexport const useHoistStatusbar = (breakpoint: string, layoutMode?: LayoutMode): boolean => {\n const enableStatusbar = useCapability(Capabilities.SettingsStore).getStore<DeckSettingsProps>(DECK_PLUGIN)!.value\n .enableStatusbar;\n const { safeAreaPadding } = useThemeContext();\n return useMemo(() => {\n return (\n breakpoint === 'desktop' &&\n layoutMode !== 'solo--fullscreen' &&\n !!enableStatusbar &&\n safeAreaPadding?.bottom === 0\n );\n }, [enableStatusbar, breakpoint, safeAreaPadding?.bottom, layoutMode]);\n};\n"],
5
- "mappings": "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",
6
- "names": ["batch", "setActive", "next", "state", "attention", "batch", "active", "deck", "solo", "removed", "filter", "id", "includes", "closed", "Array", "from", "Set", "inactive", "initialized", "fullscreen", "attended", "current", "attendedId", "isAttendedAvailable", "attendedIndex", "indexOf", "index", "length", "useMemo", "useAppGraph", "useNode", "byPosition", "useCompanions", "id", "graph", "useAppGraph", "node", "useNode", "companions", "nodes", "type", "PLANK_COMPANION_TYPE", "useMemo", "toSorted", "a", "b", "byPosition", "properties", "calculateOverscroll", "planksCount", "paddingInlineStart", "paddingInlineEnd", "overscrollPadding", "useMediaQuery", "useBreakpoints", "isNotMobile", "useMediaQuery", "isDesktop", "layoutAppliesTopbar", "breakpoint", "layoutMode", "document", "body", "getAttribute", "useMemo", "Capabilities", "useCapability", "useThemeContext", "useHoistStatusbar", "breakpoint", "layoutMode", "enableStatusbar", "useCapability", "Capabilities", "SettingsStore", "getStore", "DECK_PLUGIN", "value", "safeAreaPadding", "useThemeContext", "useMemo", "bottom"]
7
- }