@dxos/plugin-deck 0.7.4 → 0.7.5-labs.071a3e2

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 (173) hide show
  1. package/dist/lib/browser/app-graph-builder-CI6ZFMNL.mjs +147 -0
  2. package/dist/lib/browser/app-graph-builder-CI6ZFMNL.mjs.map +7 -0
  3. package/dist/lib/browser/check-app-scheme-S3EYUPMF.mjs +33 -0
  4. package/dist/lib/browser/check-app-scheme-S3EYUPMF.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-BTDY6SES.mjs +1119 -0
  6. package/dist/lib/browser/chunk-BTDY6SES.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-FZOBKOA2.mjs +24 -0
  8. package/dist/lib/browser/chunk-FZOBKOA2.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-M2L53AIH.mjs +126 -0
  10. package/dist/lib/browser/chunk-M2L53AIH.mjs.map +7 -0
  11. package/dist/lib/browser/{chunk-GVOGPULO.mjs → chunk-N7TEPFVR.mjs} +5 -4
  12. package/dist/lib/browser/chunk-N7TEPFVR.mjs.map +7 -0
  13. package/dist/lib/browser/chunk-YQ2GWTDU.mjs +17 -0
  14. package/dist/lib/browser/chunk-YQ2GWTDU.mjs.map +7 -0
  15. package/dist/lib/browser/index.mjs +100 -1807
  16. package/dist/lib/browser/index.mjs.map +4 -4
  17. package/dist/lib/browser/intent-resolver-CSXFDKTC.mjs +494 -0
  18. package/dist/lib/browser/intent-resolver-CSXFDKTC.mjs.map +7 -0
  19. package/dist/lib/browser/meta.json +1 -1
  20. package/dist/lib/browser/react-root-HIHLRMCW.mjs +46 -0
  21. package/dist/lib/browser/react-root-HIHLRMCW.mjs.map +7 -0
  22. package/dist/lib/browser/react-surface-4QVWKQYY.mjs +38 -0
  23. package/dist/lib/browser/react-surface-4QVWKQYY.mjs.map +7 -0
  24. package/dist/lib/browser/settings-WACNLCPB.mjs +28 -0
  25. package/dist/lib/browser/settings-WACNLCPB.mjs.map +7 -0
  26. package/dist/lib/browser/state-VPOYUKK6.mjs +117 -0
  27. package/dist/lib/browser/state-VPOYUKK6.mjs.map +7 -0
  28. package/dist/lib/browser/tools-5LDJNU56.mjs +51 -0
  29. package/dist/lib/browser/tools-5LDJNU56.mjs.map +7 -0
  30. package/dist/lib/browser/types.mjs +20 -3
  31. package/dist/lib/browser/url-handler-HLF42IHP.mjs +70 -0
  32. package/dist/lib/browser/url-handler-HLF42IHP.mjs.map +7 -0
  33. package/dist/types/src/DeckPlugin.d.ts +1 -14
  34. package/dist/types/src/DeckPlugin.d.ts.map +1 -1
  35. package/dist/types/src/capabilities/app-graph-builder.d.ts +181 -0
  36. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
  37. package/dist/types/src/capabilities/capabilities.d.ts +142 -0
  38. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
  39. package/dist/types/src/capabilities/check-app-scheme.d.ts +4 -0
  40. package/dist/types/src/capabilities/check-app-scheme.d.ts.map +1 -0
  41. package/dist/types/src/capabilities/index.d.ts +190 -0
  42. package/dist/types/src/capabilities/index.d.ts.map +1 -0
  43. package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
  44. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
  45. package/dist/types/src/capabilities/react-root.d.ts +7 -0
  46. package/dist/types/src/capabilities/react-root.d.ts.map +1 -0
  47. package/dist/types/src/capabilities/react-surface.d.ts +4 -0
  48. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  49. package/dist/types/src/capabilities/set-active.d.ts +9 -0
  50. package/dist/types/src/capabilities/set-active.d.ts.map +1 -0
  51. package/dist/types/src/capabilities/settings.d.ts +4 -0
  52. package/dist/types/src/capabilities/settings.d.ts.map +1 -0
  53. package/dist/types/src/capabilities/state.d.ts +76 -0
  54. package/dist/types/src/capabilities/state.d.ts.map +1 -0
  55. package/dist/types/src/capabilities/tools.d.ts +10 -0
  56. package/dist/types/src/capabilities/tools.d.ts.map +1 -0
  57. package/dist/types/src/capabilities/url-handler.d.ts +4 -0
  58. package/dist/types/src/capabilities/url-handler.d.ts.map +1 -0
  59. package/dist/types/src/components/DeckLayout/ActiveNode.d.ts.map +1 -1
  60. package/dist/types/src/components/DeckLayout/Banner.d.ts +6 -0
  61. package/dist/types/src/components/DeckLayout/Banner.d.ts.map +1 -0
  62. package/dist/types/src/components/DeckLayout/ComplementarySidebar.d.ts.map +1 -1
  63. package/dist/types/src/components/DeckLayout/ContentEmpty.d.ts.map +1 -1
  64. package/dist/types/src/components/DeckLayout/DeckLayout.d.ts +1 -4
  65. package/dist/types/src/components/DeckLayout/DeckLayout.d.ts.map +1 -1
  66. package/dist/types/src/components/DeckLayout/Fullscreen.d.ts.map +1 -1
  67. package/dist/types/src/components/DeckLayout/NodePlankHeading.d.ts +3 -3
  68. package/dist/types/src/components/DeckLayout/NodePlankHeading.d.ts.map +1 -1
  69. package/dist/types/src/components/DeckLayout/Plank.d.ts +8 -6
  70. package/dist/types/src/components/DeckLayout/Plank.d.ts.map +1 -1
  71. package/dist/types/src/components/DeckLayout/PlankControls.d.ts +2 -2
  72. package/dist/types/src/components/DeckLayout/PlankControls.d.ts.map +1 -1
  73. package/dist/types/src/components/DeckLayout/PlankError.d.ts +4 -3
  74. package/dist/types/src/components/DeckLayout/PlankError.d.ts.map +1 -1
  75. package/dist/types/src/components/DeckLayout/Sidebar.d.ts +1 -5
  76. package/dist/types/src/components/DeckLayout/Sidebar.d.ts.map +1 -1
  77. package/dist/types/src/components/DeckLayout/SidebarButton.d.ts +8 -0
  78. package/dist/types/src/components/DeckLayout/SidebarButton.d.ts.map +1 -0
  79. package/dist/types/src/components/DeckLayout/StatusBar.d.ts.map +1 -1
  80. package/dist/types/src/components/DeckLayout/Toast.d.ts +2 -2
  81. package/dist/types/src/components/DeckLayout/Toast.d.ts.map +1 -1
  82. package/dist/types/src/components/DeckLayout/Topbar.d.ts +3 -0
  83. package/dist/types/src/components/DeckLayout/Topbar.d.ts.map +1 -0
  84. package/dist/types/src/components/fragments.d.ts +4 -0
  85. package/dist/types/src/components/fragments.d.ts.map +1 -0
  86. package/dist/types/src/components/index.d.ts +0 -2
  87. package/dist/types/src/components/index.d.ts.map +1 -1
  88. package/dist/types/src/events.d.ts +4 -0
  89. package/dist/types/src/events.d.ts.map +1 -0
  90. package/dist/types/src/hooks/useMainSize.d.ts +2 -2
  91. package/dist/types/src/index.d.ts +3 -2
  92. package/dist/types/src/index.d.ts.map +1 -1
  93. package/dist/types/src/layout.d.ts +5 -19
  94. package/dist/types/src/layout.d.ts.map +1 -1
  95. package/dist/types/src/meta.d.ts +4 -4
  96. package/dist/types/src/meta.d.ts.map +1 -1
  97. package/dist/types/src/translations.d.ts +7 -2
  98. package/dist/types/src/translations.d.ts.map +1 -1
  99. package/dist/types/src/types.d.ts +130 -17
  100. package/dist/types/src/types.d.ts.map +1 -1
  101. package/dist/types/src/util/index.d.ts +3 -2
  102. package/dist/types/src/util/index.d.ts.map +1 -1
  103. package/dist/types/src/util/layoutAppliesTopbar.d.ts +2 -0
  104. package/dist/types/src/util/layoutAppliesTopbar.d.ts.map +1 -0
  105. package/dist/types/src/util/useBreakpoints.d.ts +2 -0
  106. package/dist/types/src/util/useBreakpoints.d.ts.map +1 -0
  107. package/dist/types/src/util/useHoistStatusbar.d.ts +2 -0
  108. package/dist/types/src/util/useHoistStatusbar.d.ts.map +1 -0
  109. package/dist/types/tsconfig.tsbuildinfo +1 -0
  110. package/package.json +32 -36
  111. package/src/DeckPlugin.ts +83 -0
  112. package/src/capabilities/app-graph-builder.ts +109 -0
  113. package/src/capabilities/capabilities.ts +18 -0
  114. package/src/capabilities/check-app-scheme.ts +44 -0
  115. package/src/capabilities/index.ts +17 -0
  116. package/src/capabilities/intent-resolver.ts +350 -0
  117. package/src/capabilities/react-root.tsx +48 -0
  118. package/src/capabilities/react-surface.tsx +31 -0
  119. package/src/capabilities/set-active.ts +43 -0
  120. package/src/capabilities/settings.ts +21 -0
  121. package/src/capabilities/state.ts +102 -0
  122. package/src/capabilities/tools.ts +61 -0
  123. package/src/capabilities/url-handler.ts +63 -0
  124. package/src/components/DeckLayout/ActiveNode.tsx +3 -4
  125. package/src/components/DeckLayout/Banner.tsx +37 -0
  126. package/src/components/DeckLayout/ComplementarySidebar.tsx +130 -56
  127. package/src/components/DeckLayout/ContentEmpty.tsx +9 -4
  128. package/src/components/DeckLayout/DeckLayout.tsx +116 -83
  129. package/src/components/DeckLayout/Fullscreen.tsx +3 -4
  130. package/src/components/DeckLayout/NodePlankHeading.tsx +66 -93
  131. package/src/components/DeckLayout/Plank.tsx +36 -43
  132. package/src/components/DeckLayout/PlankControls.tsx +12 -13
  133. package/src/components/DeckLayout/PlankError.tsx +6 -5
  134. package/src/components/DeckLayout/Sidebar.tsx +19 -26
  135. package/src/components/DeckLayout/SidebarButton.tsx +68 -0
  136. package/src/components/DeckLayout/StatusBar.tsx +6 -12
  137. package/src/components/DeckLayout/Toast.tsx +21 -8
  138. package/src/components/DeckLayout/Topbar.tsx +11 -0
  139. package/src/components/LayoutSettings.tsx +8 -8
  140. package/src/components/fragments.ts +14 -0
  141. package/src/components/index.ts +0 -2
  142. package/src/events.ts +11 -0
  143. package/src/hooks/useMainSize.ts +3 -3
  144. package/src/index.ts +3 -4
  145. package/src/layout.ts +43 -212
  146. package/src/meta.ts +3 -2
  147. package/src/translations.ts +11 -6
  148. package/src/types.ts +110 -34
  149. package/src/util/index.ts +3 -2
  150. package/src/util/layoutAppliesTopbar.ts +7 -0
  151. package/src/util/useBreakpoints.ts +11 -0
  152. package/src/util/useHoistStatusbar.ts +24 -0
  153. package/dist/lib/browser/chunk-GVOGPULO.mjs.map +0 -7
  154. package/dist/lib/browser/chunk-NIRHDTX4.mjs +0 -17
  155. package/dist/lib/browser/chunk-NIRHDTX4.mjs.map +0 -7
  156. package/dist/lib/browser/meta.mjs +0 -9
  157. package/dist/lib/browser/meta.mjs.map +0 -7
  158. package/dist/types/src/components/DeckContext.d.ts +0 -8
  159. package/dist/types/src/components/DeckContext.d.ts.map +0 -1
  160. package/dist/types/src/components/LayoutContext.d.ts +0 -5
  161. package/dist/types/src/components/LayoutContext.d.ts.map +0 -1
  162. package/dist/types/src/layout.test.d.ts +0 -2
  163. package/dist/types/src/layout.test.d.ts.map +0 -1
  164. package/dist/types/src/util/check-app-scheme.d.ts +0 -2
  165. package/dist/types/src/util/check-app-scheme.d.ts.map +0 -1
  166. package/dist/types/src/util/layout-parts.d.ts +0 -7
  167. package/dist/types/src/util/layout-parts.d.ts.map +0 -1
  168. package/src/DeckPlugin.tsx +0 -657
  169. package/src/components/DeckContext.ts +0 -14
  170. package/src/components/LayoutContext.ts +0 -12
  171. package/src/layout.test.ts +0 -380
  172. package/src/util/check-app-scheme.ts +0 -21
  173. package/src/util/layout-parts.ts +0 -12
@@ -1,1179 +1,51 @@
1
1
  import {
2
- DECK_PLUGIN,
3
- meta_default
4
- } from "./chunk-GVOGPULO.mjs";
2
+ AppGraphBuilder,
3
+ CheckAppScheme,
4
+ DeckSettings,
5
+ DeckState,
6
+ LayoutIntentResolver,
7
+ ReactRoot,
8
+ ReactSurface,
9
+ Tools,
10
+ UrlHandler
11
+ } from "./chunk-FZOBKOA2.mjs";
12
+ import {
13
+ DeckCapabilities
14
+ } from "./chunk-YQ2GWTDU.mjs";
5
15
  import {
6
- NewPlankPositions,
7
- OverscrollOptions,
8
- parsePanelPlugin
9
- } from "./chunk-NIRHDTX4.mjs";
16
+ DECK_PLUGIN,
17
+ meta
18
+ } from "./chunk-N7TEPFVR.mjs";
10
19
 
11
- // packages/plugins/plugin-deck/src/DeckPlugin.tsx
12
- import { batch } from "@preact/signals-core";
20
+ // packages/plugins/plugin-deck/src/events.ts
21
+ import { Events } from "@dxos/app-framework";
22
+ var DeckEvents;
23
+ (function(DeckEvents2) {
24
+ DeckEvents2.StateReady = Events.createStateEvent(`${DECK_PLUGIN}/state-ready`);
25
+ })(DeckEvents || (DeckEvents = {}));
26
+
27
+ // packages/plugins/plugin-deck/src/DeckPlugin.ts
13
28
  import { setAutoFreeze } from "immer";
14
- import React16 from "react";
15
- import { filterPlugins, IntentAction, isLayoutAdjustment, isLayoutMode, isLayoutParts, LayoutAction as LayoutAction3, NavigationAction as NavigationAction3, openIds as openIds2, parseGraphPlugin, parseIntentPlugin, resolvePlugin, SLUG_PATH_SEPARATOR as SLUG_PATH_SEPARATOR4, Toast as ToastSchema } from "@dxos/app-framework";
16
- import { getTypename } from "@dxos/echo-schema";
17
- import { scheduledEffect } from "@dxos/echo-signals/core";
18
- import { create, isReactiveObject } from "@dxos/live-object";
19
- import { LocalStorageStore } from "@dxos/local-storage";
20
- import { log } from "@dxos/log";
21
- import { parseAttentionPlugin } from "@dxos/plugin-attention";
22
- import { createExtension } from "@dxos/plugin-graph";
23
- import { ObservabilityAction } from "@dxos/plugin-observability/meta";
24
- import { fullyQualifiedId } from "@dxos/react-client/echo";
29
+ import { allOf, Capabilities, contributes, defineModule, definePlugin, Events as Events2, oneOf } from "@dxos/app-framework";
25
30
  import { translations as stackTranslations } from "@dxos/react-ui-stack";
26
31
 
27
- // packages/plugins/plugin-deck/src/components/DeckLayout/constants.ts
28
- var NAV_ID = "NavTree";
29
- var SURFACE_PREFIX = "surface:";
30
-
31
- // packages/plugins/plugin-deck/src/components/DeckLayout/DeckLayout.tsx
32
- import { Sidebar as MenuIcon } from "@phosphor-icons/react";
33
- import { untracked } from "@preact/signals-core";
34
- import React14, { useCallback as useCallback2, useEffect as useEffect5, useMemo as useMemo5, useRef as useRef2, Fragment as Fragment2 } from "react";
35
- import { Surface as Surface9, firstIdInPart, usePlugin } from "@dxos/app-framework";
36
- import { AlertDialog, Button as Button3, Dialog as NaturalDialog, Main as Main3, Popover as Popover2, useOnTransition, useTranslation as useTranslation5 } from "@dxos/react-ui";
37
- import { Stack, StackContext as StackContext2, DEFAULT_HORIZONTAL_SIZE } from "@dxos/react-ui-stack";
38
- import { getSize, mainPaddingTransitions as mainPaddingTransitions2 } from "@dxos/react-ui-theme";
39
-
40
- // packages/plugins/plugin-deck/src/components/DeckLayout/ActiveNode.tsx
41
- import React from "react";
42
- import { Surface } from "@dxos/app-framework";
43
- import { useGraph } from "@dxos/plugin-graph";
44
- import { useAttended } from "@dxos/react-ui-attention";
45
-
46
- // packages/plugins/plugin-deck/src/hooks/useNode.ts
47
- import { useEffect, useState } from "react";
48
- var useNode = (graph, id, timeout) => {
49
- const [nodeState, setNodeState] = useState(id ? graph.findNode(id, false) : void 0);
50
- useEffect(() => {
51
- if (!id && nodeState) {
52
- setNodeState(void 0);
53
- }
54
- if (nodeState?.id === id || !id) {
55
- return;
56
- }
57
- const frame = requestAnimationFrame(async () => {
58
- try {
59
- const node = await graph.waitForNode(id, timeout);
60
- if (node) {
61
- setNodeState(node);
62
- }
63
- } catch {
64
- }
65
- });
66
- return () => cancelAnimationFrame(frame);
67
- }, [
68
- graph,
69
- id,
70
- timeout,
71
- nodeState?.id
72
- ]);
73
- return nodeState;
74
- };
75
-
76
- // packages/plugins/plugin-deck/src/hooks/useNodeActionExpander.ts
77
- import { useEffect as useEffect2 } from "react";
78
- import { ACTION_GROUP_TYPE, ACTION_TYPE, getGraph } from "@dxos/plugin-graph";
79
- var expandNodeActions = async (node) => {
80
- const graph = getGraph(node);
81
- await graph.expand(node, "outbound", ACTION_GROUP_TYPE);
82
- await graph.expand(node, "outbound", ACTION_TYPE);
83
- };
84
- var useNodeActionExpander = (node) => {
85
- useEffect2(() => {
86
- if (node) {
87
- const frame = requestAnimationFrame(() => {
88
- void expandNodeActions(node);
89
- });
90
- return () => cancelAnimationFrame(frame);
91
- }
92
- }, [
93
- node
94
- ]);
95
- };
96
-
97
- // packages/plugins/plugin-deck/src/hooks/useMainSize.ts
98
- import { useMainContext } from "@dxos/react-ui";
99
- var useMainSize = () => {
100
- const { navigationSidebarOpen, complementarySidebarOpen } = useMainContext("DeckPluginPlank");
101
- return {
102
- "data-sidebar-inline-start-state": navigationSidebarOpen ? "open" : "closed",
103
- "data-sidebar-inline-end-state": complementarySidebarOpen ? "open" : "closed"
104
- };
105
- };
106
-
107
- // packages/plugins/plugin-deck/src/components/DeckLayout/ActiveNode.tsx
108
- var ActiveNode = () => {
109
- const [id] = useAttended();
110
- const { graph } = useGraph();
111
- const activeNode = useNode(graph, id);
112
- useNodeActionExpander(activeNode);
113
- return /* @__PURE__ */ React.createElement("div", {
114
- role: "none",
115
- className: "sr-only"
116
- }, /* @__PURE__ */ React.createElement(Surface, {
117
- role: "document-title",
118
- data: {
119
- activeNode
120
- },
121
- limit: 1
122
- }));
123
- };
124
-
125
- // packages/plugins/plugin-deck/src/components/DeckLayout/ComplementarySidebar.tsx
126
- import React6, { useMemo as useMemo2 } from "react";
127
- import { NavigationAction as NavigationAction2, SLUG_PATH_SEPARATOR as SLUG_PATH_SEPARATOR2, Surface as Surface3, useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
128
- import { useGraph as useGraph3 } from "@dxos/plugin-graph";
129
- import { Main, ScrollArea } from "@dxos/react-ui";
130
- import { useAttended as useAttended2 } from "@dxos/react-ui-attention";
131
- import { railGridHorizontal, StackContext } from "@dxos/react-ui-stack";
132
- import { mx as mx2 } from "@dxos/react-ui-theme";
133
-
134
- // packages/plugins/plugin-deck/src/components/DeckLayout/NodePlankHeading.tsx
135
- import React3, { Fragment, memo, useEffect as useEffect3, useMemo } from "react";
136
- import { LayoutAction, NavigationAction, SLUG_PATH_SEPARATOR, Surface as Surface2, useIntentDispatcher } from "@dxos/app-framework";
137
- import { useGraph as useGraph2 } from "@dxos/plugin-graph";
138
- import { Icon as Icon2, Popover, toLocalizedString, useMediaQuery, useTranslation as useTranslation2, IconButton } from "@dxos/react-ui";
139
- import { StackItem } from "@dxos/react-ui-stack";
140
- import { TextTooltip } from "@dxos/react-ui-text-tooltip";
141
-
142
- // packages/plugins/plugin-deck/src/components/DeckLayout/PlankControls.tsx
143
- import React2, { forwardRef } from "react";
144
- import { Button, ButtonGroup, Icon, Tooltip, useTranslation } from "@dxos/react-ui";
145
- var PlankControl = ({ icon, label, ...props }) => {
146
- return /* @__PURE__ */ React2.createElement(Tooltip.Root, null, /* @__PURE__ */ React2.createElement(Tooltip.Trigger, {
147
- asChild: true
148
- }, /* @__PURE__ */ React2.createElement(Button, {
149
- variant: "ghost",
150
- ...props
151
- }, /* @__PURE__ */ React2.createElement("span", {
152
- className: "sr-only"
153
- }, label), /* @__PURE__ */ React2.createElement(Icon, {
154
- icon,
155
- size: 4
156
- }))), /* @__PURE__ */ React2.createElement(Tooltip.Portal, null, /* @__PURE__ */ React2.createElement(Tooltip.Content, {
157
- side: "bottom",
158
- classNames: "z-[70]"
159
- }, label)));
160
- };
161
- var PlankControls = /* @__PURE__ */ forwardRef(({ onClick, variant = "default", capabilities: can, isSolo, pin, close = false, children, ...props }, forwardedRef) => {
162
- const { t } = useTranslation(DECK_PLUGIN);
163
- const buttonClassNames = variant === "hide-disabled" ? "disabled:hidden !pli-2 !plb-3" : "!pli-2 !plb-3";
164
- return /* @__PURE__ */ React2.createElement(ButtonGroup, {
165
- ...props,
166
- ref: forwardedRef
167
- }, pin && !isSolo && [
168
- "both",
169
- "start"
170
- ].includes(pin) && /* @__PURE__ */ React2.createElement(PlankControl, {
171
- label: t("pin start label"),
172
- variant: "ghost",
173
- classNames: buttonClassNames,
174
- onClick: () => onClick?.("pin-start"),
175
- icon: "ph--caret-line-left--regular"
176
- }), can.solo && /* @__PURE__ */ React2.createElement(PlankControl, {
177
- label: isSolo ? t("show deck plank label") : t("show solo plank label"),
178
- classNames: buttonClassNames,
179
- onClick: () => onClick?.("solo"),
180
- icon: isSolo ? "ph--arrow-u-down-left--regular" : "ph--arrows-out--regular"
181
- }), !isSolo && can.solo && /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(PlankControl, {
182
- label: t("increment start label"),
183
- disabled: !can.incrementStart,
184
- classNames: buttonClassNames,
185
- onClick: () => onClick?.("increment-start"),
186
- icon: "ph--caret-left--regular"
187
- }), /* @__PURE__ */ React2.createElement(PlankControl, {
188
- label: t("increment end label"),
189
- disabled: !can.incrementEnd,
190
- classNames: buttonClassNames,
191
- onClick: () => onClick?.("increment-end"),
192
- icon: "ph--caret-right--regular"
193
- })), pin && !isSolo && [
194
- "both",
195
- "end"
196
- ].includes(pin) && /* @__PURE__ */ React2.createElement(PlankControl, {
197
- label: t("pin end label"),
198
- classNames: buttonClassNames,
199
- onClick: () => onClick?.("pin-end"),
200
- icon: "ph--caret-line-right--regular"
201
- }), close && !isSolo && /* @__PURE__ */ React2.createElement(PlankControl, {
202
- label: t(`${typeof close === "string" ? "minify" : "close"} label`),
203
- classNames: buttonClassNames,
204
- onClick: () => onClick?.("close"),
205
- "data-testid": "plankHeading.close",
206
- icon: close === "minify-start" ? "ph--caret-line-left--regular" : close === "minify-end" ? "ph--caret-line-right--regular" : "ph--x--regular"
207
- }), children);
208
- });
209
-
210
- // packages/plugins/plugin-deck/src/components/LayoutContext.ts
211
- import { createContext, useContext } from "react";
212
- import { raise } from "@dxos/debug";
213
- var LayoutContext = createContext(null);
214
- var useLayout = () => useContext(LayoutContext) ?? raise(new Error("Missing LayoutContext"));
215
-
216
- // packages/plugins/plugin-deck/src/components/DeckLayout/NodePlankHeading.tsx
217
- var NodePlankHeading = /* @__PURE__ */ memo(({ coordinate, node, canIncrementStart, canIncrementEnd, popoverAnchorId, pending, actions = [] }) => {
218
- const layoutContext = useLayout();
219
- const { t } = useTranslation2(DECK_PLUGIN);
220
- const { graph } = useGraph2();
221
- const icon = node?.properties?.icon ?? "ph--placeholder--regular";
222
- const label = pending ? t("pending heading") : toLocalizedString(node?.properties?.label ?? [
223
- "plank heading fallback label",
224
- {
225
- ns: DECK_PLUGIN
226
- }
227
- ], t);
228
- const dispatch = useIntentDispatcher();
229
- const ActionRoot = node && popoverAnchorId === `dxos.org/ui/${DECK_PLUGIN}/${node.id}` ? Popover.Anchor : Fragment;
230
- const [isNotMobile] = useMediaQuery("md");
231
- useEffect3(() => {
232
- const frame = requestAnimationFrame(() => {
233
- node && graph.actions(node);
234
- });
235
- return () => cancelAnimationFrame(frame);
236
- }, [
237
- node
238
- ]);
239
- const layoutPart = coordinate.part;
240
- const attendableId = coordinate.entryId.split(SLUG_PATH_SEPARATOR).at(0);
241
- const capabilities = useMemo(() => ({
242
- solo: (layoutPart === "solo" || layoutPart === "main") && isNotMobile,
243
- incrementStart: canIncrementStart,
244
- incrementEnd: canIncrementEnd
245
- }), [
246
- isNotMobile,
247
- layoutPart,
248
- canIncrementStart,
249
- canIncrementEnd
250
- ]);
251
- return /* @__PURE__ */ React3.createElement(StackItem.Heading, {
252
- classNames: "pie-1 border-be border-separator"
253
- }, /* @__PURE__ */ React3.createElement(ActionRoot, null, node ? /* @__PURE__ */ React3.createElement(StackItem.Sigil, {
254
- icon,
255
- related: layoutPart === "complementary",
256
- attendableId,
257
- triggerLabel: t("actions menu label"),
258
- actions: [
259
- actions,
260
- graph.actions(node)
261
- ].filter((a) => a.length > 0),
262
- onAction: (action) => typeof action.data === "function" && action.data?.({
263
- node: action,
264
- caller: DECK_PLUGIN
265
- })
266
- }, /* @__PURE__ */ React3.createElement(Surface2, {
267
- role: "menu-footer",
268
- data: {
269
- object: node.data
270
- }
271
- })) : /* @__PURE__ */ React3.createElement(StackItem.SigilButton, null, /* @__PURE__ */ React3.createElement("span", {
272
- className: "sr-only"
273
- }, label), /* @__PURE__ */ React3.createElement(Icon2, {
274
- icon,
275
- size: 5
276
- }))), /* @__PURE__ */ React3.createElement(TextTooltip, {
277
- text: label,
278
- onlyWhenTruncating: true
279
- }, /* @__PURE__ */ React3.createElement(StackItem.HeadingLabel, {
280
- attendableId,
281
- related: layoutPart === "complementary",
282
- ...pending && {
283
- classNames: "text-description"
284
- }
285
- }, label)), node && layoutPart !== "complementary" && // TODO(Zan): What are we doing with layout coordinate here?
286
- /* @__PURE__ */ React3.createElement(Surface2, {
287
- role: "navbar-end",
288
- direction: "inline-reverse",
289
- data: {
290
- object: node.data
291
- }
292
- }), /* @__PURE__ */ React3.createElement(PlankControls, {
293
- capabilities,
294
- isSolo: layoutPart === "solo",
295
- classNames: "mx-1",
296
- onClick: (eventType) => {
297
- if (!layoutPart) {
298
- return;
299
- }
300
- if (eventType === "solo") {
301
- return dispatch([
302
- {
303
- action: NavigationAction.ADJUST,
304
- data: {
305
- type: eventType,
306
- layoutCoordinate: {
307
- part: "main",
308
- entryId: coordinate.entryId
309
- }
310
- }
311
- }
312
- ]);
313
- } else if (eventType === "close") {
314
- if (layoutPart === "complementary") {
315
- return dispatch({
316
- action: LayoutAction.SET_LAYOUT,
317
- data: {
318
- element: "complementary",
319
- state: false
320
- }
321
- });
322
- } else {
323
- return dispatch({
324
- action: NavigationAction.CLOSE,
325
- data: {
326
- activeParts: {
327
- [layoutPart]: [
328
- coordinate.entryId
329
- ]
330
- }
331
- }
332
- });
333
- }
334
- } else {
335
- return dispatch({
336
- action: NavigationAction.ADJUST,
337
- data: {
338
- type: eventType,
339
- layoutCoordinate: coordinate
340
- }
341
- });
342
- }
343
- },
344
- close: layoutPart === "complementary" ? "minify-end" : true
345
- }, layoutPart !== "complementary" && /* @__PURE__ */ React3.createElement(IconButton, {
346
- iconOnly: true,
347
- onClick: () => layoutContext.complementarySidebarOpen = !layoutContext.complementarySidebarOpen,
348
- variant: "ghost",
349
- label: t("open complementary sidebar label"),
350
- classNames: "!pli-2 !plb-3 [&>svg]:-scale-x-100",
351
- icon: "ph--sidebar-simple--regular",
352
- size: 4,
353
- tooltipZIndex: "70"
354
- })));
355
- });
356
-
357
- // packages/plugins/plugin-deck/src/components/DeckLayout/PlankError.tsx
358
- import React5, { useEffect as useEffect4, useState as useState2 } from "react";
359
- import { useTranslation as useTranslation3 } from "@dxos/react-ui";
360
- import { descriptionText, mx } from "@dxos/react-ui-theme";
361
-
362
- // packages/plugins/plugin-deck/src/components/DeckLayout/PlankLoading.tsx
363
- import React4 from "react";
364
- var PlankLoading = () => {
365
- return /* @__PURE__ */ React4.createElement("div", {
366
- role: "none",
367
- className: "grid place-items-center attention-surface"
368
- });
369
- };
370
-
371
- // packages/plugins/plugin-deck/src/components/DeckLayout/PlankError.tsx
372
- var PlankContentError = ({ error }) => {
373
- const { t } = useTranslation3(DECK_PLUGIN);
374
- const errorString = error?.toString() ?? "";
375
- return /* @__PURE__ */ React5.createElement("div", {
376
- role: "none",
377
- className: "overflow-auto p-8 attention-surface grid place-items-center"
378
- }, /* @__PURE__ */ React5.createElement("p", {
379
- role: "alert",
380
- className: mx(descriptionText, "break-words border border-dashed border-separator rounded-lg p-8", errorString.length < 256 && "text-lg")
381
- }, error ? errorString : t("error fallback message")));
382
- };
383
- var PlankError = ({ layoutCoordinate, node, error }) => {
384
- const [timedOut, setTimedOut] = useState2(false);
385
- useEffect4(() => {
386
- setTimeout(() => setTimedOut(true), 5e3);
387
- }, []);
388
- return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(NodePlankHeading, {
389
- coordinate: layoutCoordinate,
390
- node,
391
- pending: !timedOut
392
- }), timedOut ? /* @__PURE__ */ React5.createElement(PlankContentError, {
393
- error
394
- }) : /* @__PURE__ */ React5.createElement(PlankLoading, null));
395
- };
396
-
397
- // packages/plugins/plugin-deck/src/components/DeckLayout/ComplementarySidebar.tsx
398
- var ComplementarySidebar = ({ panels, current }) => {
399
- const { popoverAnchorId } = useLayout();
400
- const attended = useAttended2();
401
- const panel = (panels.find((p) => p.id === current) ?? panels[0])?.id;
402
- const id = attended[0] ? `${attended[0]}${SLUG_PATH_SEPARATOR2}${panel}` : void 0;
403
- const { graph } = useGraph3();
404
- const node = useNode(graph, id);
405
- const dispatch = useIntentDispatcher2();
406
- useNodeActionExpander(node);
407
- const actions = useMemo2(() => panels.map(({ id: id2, label, icon }) => ({
408
- id: `complementary-${id2}`,
409
- data: () => {
410
- void dispatch({
411
- action: NavigationAction2.OPEN,
412
- data: {
413
- activeParts: {
414
- complementary: id2
415
- }
416
- }
417
- });
418
- },
419
- properties: {
420
- label,
421
- icon,
422
- menuItemType: "toggle",
423
- isChecked: panel === id2
424
- }
425
- })), [
426
- panel
427
- ]);
428
- const coordinate = useMemo2(() => ({
429
- entryId: id ?? "unknown",
430
- part: "complementary"
431
- }), [
432
- id
433
- ]);
434
- return /* @__PURE__ */ React6.createElement(Main.ComplementarySidebar, null, /* @__PURE__ */ React6.createElement(StackContext.Provider, {
435
- value: {
436
- size: "contain",
437
- orientation: "horizontal",
438
- separators: false,
439
- rail: true
440
- }
441
- }, /* @__PURE__ */ React6.createElement("div", {
442
- role: "none",
443
- className: mx2(railGridHorizontal, "grid grid-cols-[100%] bs-full")
444
- }, /* @__PURE__ */ React6.createElement(NodePlankHeading, {
445
- coordinate,
446
- node,
447
- popoverAnchorId,
448
- actions
449
- }), /* @__PURE__ */ React6.createElement(ScrollArea.Root, null, /* @__PURE__ */ React6.createElement(ScrollArea.Viewport, null, node && /* @__PURE__ */ React6.createElement(Surface3, {
450
- key: id,
451
- role: `complementary--${panel}`,
452
- limit: 1,
453
- data: {
454
- id,
455
- subject: node.properties.object ?? node.properties.space,
456
- popoverAnchorId
457
- },
458
- fallback: PlankContentError,
459
- placeholder: /* @__PURE__ */ React6.createElement(PlankLoading, null)
460
- }), /* @__PURE__ */ React6.createElement(ScrollArea.Scrollbar, {
461
- orientation: "vertical"
462
- }, /* @__PURE__ */ React6.createElement(ScrollArea.Thumb, null)))))));
463
- };
464
-
465
- // packages/plugins/plugin-deck/src/components/DeckLayout/ContentEmpty.tsx
466
- import React7 from "react";
467
- import { Surface as Surface4 } from "@dxos/app-framework";
468
- var ContentEmpty = () => {
469
- return /* @__PURE__ */ React7.createElement("div", {
470
- role: "none",
471
- className: "min-bs-screen is-dvw sm:is-full flex items-center justify-center p-8",
472
- "data-testid": "layoutPlugin.firstRunMessage"
473
- }, /* @__PURE__ */ React7.createElement("div", {
474
- role: "none",
475
- className: "grid place-items-center grid-rows-[min-content_min-content]"
476
- }, /* @__PURE__ */ React7.createElement(Surface4, {
477
- role: "keyshortcuts"
478
- })));
479
- };
480
-
481
- // packages/plugins/plugin-deck/src/components/DeckLayout/Fullscreen.tsx
482
- import React9 from "react";
483
- import { Surface as Surface5 } from "@dxos/app-framework";
484
- import { useGraph as useGraph4 } from "@dxos/plugin-graph";
485
- import { fixedInsetFlexLayout } from "@dxos/react-ui-theme";
486
-
487
- // packages/plugins/plugin-deck/src/components/DeckLayout/Fallback.tsx
488
- import React8 from "react";
489
- import { useTranslation as useTranslation4 } from "@dxos/react-ui";
490
- import { errorText, mx as mx3 } from "@dxos/react-ui-theme";
491
- var Fallback = () => {
492
- const { t } = useTranslation4(DECK_PLUGIN);
493
- return /* @__PURE__ */ React8.createElement("div", {
494
- role: "none",
495
- className: "min-bs-screen is-full flex items-center justify-center p-8"
496
- }, /* @__PURE__ */ React8.createElement("p", {
497
- role: "alert",
498
- className: mx3(errorText, "border border-error-400/50 rounded-lg flex items-center justify-center p-8 font-normal text-lg")
499
- }, t("plugin error message")));
500
- };
501
-
502
- // packages/plugins/plugin-deck/src/components/DeckLayout/Fullscreen.tsx
503
- var Fullscreen = ({ id }) => {
504
- const { graph } = useGraph4();
505
- const fullScreenNode = useNode(graph, id);
506
- return /* @__PURE__ */ React9.createElement("div", {
507
- role: "none",
508
- className: fixedInsetFlexLayout
509
- }, /* @__PURE__ */ React9.createElement(Surface5, {
510
- role: "main",
511
- limit: 1,
512
- fallback: Fallback,
513
- data: {
514
- active: fullScreenNode?.data,
515
- component: id?.startsWith(SURFACE_PREFIX) ? id.slice(SURFACE_PREFIX.length) : void 0
516
- }
517
- }));
518
- };
519
-
520
- // packages/plugins/plugin-deck/src/components/DeckLayout/Plank.tsx
521
- import React10, { memo as memo2, useCallback, useLayoutEffect, useMemo as useMemo3, useRef } from "react";
522
- import { Surface as Surface6, useIntentDispatcher as useIntentDispatcher3, indexInPart, partLength, LayoutAction as LayoutAction2 } from "@dxos/app-framework";
523
- import { debounce } from "@dxos/async";
524
- import { useGraph as useGraph5 } from "@dxos/plugin-graph";
525
- import { useAttendableAttributes } from "@dxos/react-ui-attention";
526
- import { StackItem as StackItem2, railGridHorizontal as railGridHorizontal2 } from "@dxos/react-ui-stack";
527
- import { mainIntrinsicSize, mx as mx4 } from "@dxos/react-ui-theme";
528
-
529
- // packages/plugins/plugin-deck/src/components/DeckContext.ts
530
- import { createContext as createContext2, useContext as useContext2 } from "react";
531
- import { raise as raise2 } from "@dxos/debug";
532
- var DeckContext = createContext2(null);
533
- var useDeckContext = () => useContext2(DeckContext) ?? raise2(new Error("Missing DeckContext"));
534
-
535
- // packages/plugins/plugin-deck/src/components/DeckLayout/Plank.tsx
536
- var UNKNOWN_ID = "unknown_id";
537
- var Plank = /* @__PURE__ */ memo2(({ entry, layoutParts, part, layoutMode, order }) => {
538
- const dispatch = useIntentDispatcher3();
539
- const coordinate = useMemo3(() => ({
540
- part,
541
- entryId: entry?.id ?? UNKNOWN_ID
542
- }), [
543
- entry?.id,
544
- part
545
- ]);
546
- const { popoverAnchorId, scrollIntoView } = useLayout();
547
- const { plankSizing } = useDeckContext();
548
- const { graph } = useGraph5();
549
- const node = useNode(graph, entry?.id);
550
- const rootElement = useRef(null);
551
- const canResize = layoutMode === "deck";
552
- const Root = part === "solo" ? "article" : StackItem2.Root;
553
- const attendableAttrs = useAttendableAttributes(coordinate.entryId);
554
- const index = indexInPart(layoutParts, coordinate);
555
- const length = partLength(layoutParts, part);
556
- const canIncrementStart = part === "main" && index !== void 0 && index > 0 && length !== void 0 && length > 1;
557
- const canIncrementEnd = part === "main" && index !== void 0 && index < length - 1 && length !== void 0;
558
- const size = plankSizing?.[coordinate.entryId];
559
- const setSize = useCallback(debounce((nextSize) => {
560
- return dispatch({
561
- action: DeckAction.UPDATE_PLANK_SIZE,
562
- data: {
563
- id: coordinate.entryId,
564
- size: nextSize
565
- }
566
- });
567
- }, 200), [
568
- dispatch,
569
- coordinate.entryId
570
- ]);
571
- const handleKeyDown = useCallback((event) => {
572
- if (event.target === event.currentTarget && event.key === "Escape") {
573
- rootElement.current?.closest("main")?.focus();
574
- }
575
- }, []);
576
- useLayoutEffect(() => {
577
- if (scrollIntoView === coordinate.entryId) {
578
- const focusable = rootElement.current?.querySelector("button") || rootElement.current;
579
- focusable?.focus({
580
- preventScroll: true
581
- });
582
- layoutMode === "deck" && focusable?.scrollIntoView({
583
- behavior: "smooth",
584
- inline: "center"
585
- });
586
- void dispatch({
587
- action: LayoutAction2.SCROLL_INTO_VIEW,
588
- data: {
589
- id: void 0
590
- }
591
- });
592
- }
593
- }, [
594
- coordinate.entryId,
595
- scrollIntoView,
596
- layoutMode
597
- ]);
598
- const isSolo = layoutMode === "solo" && part === "solo";
599
- const isAttendable = isSolo || layoutMode === "deck" && part === "main";
600
- const sizeAttrs = useMainSize();
601
- const data = useMemo3(() => node && {
602
- ...entry?.path ? {
603
- subject: node.data,
604
- path: entry.path
605
- } : {
606
- object: node.data
607
- },
608
- coordinate,
609
- popoverAnchorId
610
- }, [
611
- node,
612
- node?.data,
613
- entry?.path,
614
- coordinate,
615
- popoverAnchorId
616
- ]);
617
- const placeholder = useMemo3(() => /* @__PURE__ */ React10.createElement(PlankLoading, null), []);
618
- const className = mx4("attention-surface relative", isSolo && mainIntrinsicSize, isSolo && railGridHorizontal2, isSolo ? "grid absolute inset-0" : "!border-separator border-li");
619
- return /* @__PURE__ */ React10.createElement(Root, {
620
- ref: rootElement,
621
- "data-testid": "deck.plank",
622
- tabIndex: 0,
623
- ...part === "solo" ? {
624
- ...sizeAttrs,
625
- className
626
- } : {
627
- item: {
628
- id: entry?.id ?? "never"
629
- },
630
- size,
631
- onSizeChange: setSize,
632
- classNames: className,
633
- order,
634
- role: "article"
635
- },
636
- ...isAttendable ? attendableAttrs : {},
637
- onKeyDown: handleKeyDown
638
- }, node ? /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement(NodePlankHeading, {
639
- coordinate,
640
- node,
641
- canIncrementStart,
642
- canIncrementEnd,
643
- popoverAnchorId
644
- }), /* @__PURE__ */ React10.createElement(Surface6, {
645
- key: node.id,
646
- role: "article",
647
- data,
648
- limit: 1,
649
- fallback: PlankContentError,
650
- placeholder
651
- })) : /* @__PURE__ */ React10.createElement(PlankError, {
652
- layoutCoordinate: coordinate
653
- }), canResize && /* @__PURE__ */ React10.createElement(StackItem2.ResizeHandle, null));
654
- });
655
-
656
- // packages/plugins/plugin-deck/src/components/DeckLayout/Sidebar.tsx
657
- import React11, { useMemo as useMemo4 } from "react";
658
- import { openIds, Surface as Surface7 } from "@dxos/app-framework";
659
- import { Main as Main2 } from "@dxos/react-ui";
660
- var Sidebar = ({ layoutParts }) => {
661
- const { layoutMode, popoverAnchorId } = useLayout();
662
- const activeIds = useMemo4(() => {
663
- if (layoutMode === "solo") {
664
- return Array.from(new Set(layoutParts?.solo?.map((e) => e.id) ?? []));
665
- } else if (layoutMode === "deck") {
666
- return Array.from(new Set(layoutParts?.main?.map((e) => e.id) ?? []));
667
- }
668
- return Array.from(new Set(openIds(layoutParts)));
669
- }, [
670
- layoutParts,
671
- layoutMode
672
- ]);
673
- const navigationData = useMemo4(() => ({
674
- popoverAnchorId,
675
- activeIds
676
- }), [
677
- popoverAnchorId,
678
- activeIds
679
- ]);
680
- return /* @__PURE__ */ React11.createElement(Main2.NavigationSidebar, null, /* @__PURE__ */ React11.createElement(Surface7, {
681
- role: "navigation",
682
- data: {
683
- ...navigationData
684
- },
685
- limit: 1
686
- }));
687
- };
688
-
689
- // packages/plugins/plugin-deck/src/components/DeckLayout/StatusBar.tsx
690
- import React12 from "react";
691
- import { Surface as Surface8 } from "@dxos/app-framework";
692
- import { mainPadding, mainPaddingTransitions, mx as mx5 } from "@dxos/react-ui-theme";
693
- var StatusBar = ({ showHints }) => {
694
- const sizeAttrs = useMainSize();
695
- return /* @__PURE__ */ React12.createElement("div", {
696
- role: "none",
697
- ...sizeAttrs,
698
- className: mx5("fixed flex justify-between block-end-0 inset-inline-0 items-center border-bs border-separator z-[2]", mainPadding, mainPaddingTransitions)
699
- }, /* @__PURE__ */ React12.createElement("div", {
700
- role: "none"
701
- }, showHints && /* @__PURE__ */ React12.createElement(Surface8, {
702
- role: "hints",
703
- limit: 1
704
- })), /* @__PURE__ */ React12.createElement(Surface8, {
705
- role: "status-bar",
706
- limit: 1
707
- }));
708
- };
709
-
710
- // packages/plugins/plugin-deck/src/components/DeckLayout/Toast.tsx
711
- import React13 from "react";
712
- import { Button as Button2, Icon as Icon3, Toast as NaturalToast } from "@dxos/react-ui";
713
- var Toast = ({ id, title, description, icon, duration, actionLabel, actionAlt, closeLabel, onAction, onOpenChange }) => {
714
- return /* @__PURE__ */ React13.createElement(NaturalToast.Root, {
715
- "data-testid": id,
716
- defaultOpen: true,
717
- duration,
718
- onOpenChange
719
- }, /* @__PURE__ */ React13.createElement(NaturalToast.Body, null, /* @__PURE__ */ React13.createElement(NaturalToast.Title, {
720
- classNames: "items-center"
721
- }, icon && /* @__PURE__ */ React13.createElement(Icon3, {
722
- icon,
723
- size: 5,
724
- classNames: "inline mr-1"
725
- }), /* @__PURE__ */ React13.createElement("span", null, title)), description && /* @__PURE__ */ React13.createElement(NaturalToast.Description, null, description)), /* @__PURE__ */ React13.createElement(NaturalToast.Actions, null, onAction && actionAlt && actionLabel && /* @__PURE__ */ React13.createElement(NaturalToast.Action, {
726
- altText: actionAlt,
727
- asChild: true
728
- }, /* @__PURE__ */ React13.createElement(Button2, {
729
- "data-testid": "toast.action",
730
- variant: "primary",
731
- onClick: () => onAction?.()
732
- }, actionLabel)), closeLabel && /* @__PURE__ */ React13.createElement(NaturalToast.Close, {
733
- asChild: true
734
- }, /* @__PURE__ */ React13.createElement(Button2, {
735
- "data-testid": "toast.close"
736
- }, closeLabel))));
737
- };
738
-
739
- // packages/plugins/plugin-deck/src/util/check-app-scheme.ts
740
- var checkAppScheme = (url) => {
741
- const iframe = document.createElement("iframe");
742
- iframe.style.display = "none";
743
- document.body.appendChild(iframe);
744
- iframe.src = url + window.location.pathname.replace(/^\/+/, "") + window.location.search;
745
- const timer = setTimeout(() => {
746
- document.body.removeChild(iframe);
747
- }, 3e3);
748
- window.addEventListener("pagehide", (event) => {
749
- clearTimeout(timer);
750
- document.body.removeChild(iframe);
751
- });
752
- };
753
-
754
- // packages/plugins/plugin-deck/src/util/layout-parts.ts
755
- var getEffectivePart = (partName, layoutMode) => layoutMode === "solo" && partName === "main" ? "solo" : partName;
756
-
757
- // packages/plugins/plugin-deck/src/util/overscroll.ts
758
- var calculateOverscroll = (planksCount) => {
759
- if (!planksCount) {
760
- return {
761
- paddingInlineStart: 0,
762
- paddingInlineEnd: 0
763
- };
764
- }
765
- if (planksCount === 1) {
766
- const overscrollPadding = "max(0px, calc(((100dvw - var(--dx-main-sidebarWidth) - var(--dx-main-complementaryWidth) - (var(--dx-main-contentFirstWidth) + 1px)) / 2)))";
767
- return {
768
- paddingInlineStart: overscrollPadding,
769
- paddingInlineEnd: overscrollPadding
770
- };
771
- } else {
772
- return {
773
- paddingInlineStart: "max(0px, calc(((100dvw - (var(--dx-main-contentFirstWidth) + 1px)) / 2) - var(--dx-main-sidebarWidth)))",
774
- paddingInlineEnd: "max(0px, calc(((100dvw - (var(--dx-main-contentLastWidth) + 1px)) / 2) - var(--dx-main-complementaryWidth)))"
775
- };
776
- }
777
- };
778
-
779
- // packages/plugins/plugin-deck/src/components/DeckLayout/DeckLayout.tsx
780
- var PlankSeparator = ({ index }) => index > 0 ? /* @__PURE__ */ React14.createElement("span", {
781
- role: "separator",
782
- className: "row-span-2 bg-deck is-4",
783
- style: {
784
- gridColumn: index * 2
785
- }
786
- }) : null;
787
- var DeckLayout = ({ layoutParts, toasts, overscroll, showHints, panels, onDismissToast }) => {
788
- const context = useLayout();
789
- const { layoutMode, sidebarOpen, complementarySidebarOpen, dialogOpen, dialogContent, dialogBlockAlign, dialogType, popoverOpen, popoverContent, popoverAnchorId } = context;
790
- const { t } = useTranslation5(DECK_PLUGIN);
791
- const { plankSizing } = useDeckContext();
792
- const attentionPlugin = usePlugin("dxos.org/plugin/attention");
793
- const fullScreenSlug = useMemo5(() => firstIdInPart(layoutParts, "fullScreen"), [
794
- layoutParts
795
- ]);
796
- const scrollLeftRef = useRef2();
797
- const deckRef = useRef2(null);
798
- const isSoloModeLoaded = layoutMode === "solo" && Boolean(layoutParts.solo?.[0]);
799
- useEffect5(() => {
800
- const attended = untracked(() => attentionPlugin?.provides.attention.attended ?? []);
801
- const firstId = isSoloModeLoaded ? firstIdInPart(layoutParts, "solo") : firstIdInPart(layoutParts, "main");
802
- if (attended.length === 0 && firstId) {
803
- document.querySelector(`article[data-attendable-id="${firstId}"] button`)?.focus();
804
- }
805
- }, []);
806
- const handleResize = useCallback2(() => {
807
- scrollLeftRef.current = null;
808
- }, []);
809
- useEffect5(() => {
810
- window.addEventListener("resize", handleResize);
811
- return () => window.removeEventListener("resize", handleResize);
812
- }, [
813
- handleResize
814
- ]);
815
- const restoreScroll = useCallback2(() => {
816
- if (deckRef.current && scrollLeftRef.current != null) {
817
- deckRef.current.scrollLeft = scrollLeftRef.current;
818
- }
819
- }, []);
820
- useOnTransition(layoutMode, (mode) => mode !== "deck", "deck", restoreScroll);
821
- const handleScroll = useCallback2((event) => {
822
- if (layoutMode === "deck" && event.currentTarget === event.target) {
823
- scrollLeftRef.current = event.target.scrollLeft;
824
- }
825
- }, [
826
- layoutMode
827
- ]);
828
- const isEmpty = (layoutParts.main?.length ?? 0) === 0 && (layoutParts.solo?.length ?? 0) === 0;
829
- const padding = useMemo5(() => {
830
- if (layoutMode === "deck" && overscroll === "centering") {
831
- return calculateOverscroll(layoutParts.main?.length ?? 0);
832
- }
833
- return {};
834
- }, [
835
- layoutMode,
836
- overscroll,
837
- layoutParts.main
838
- ]);
839
- const Dialog = dialogType === "alert" ? AlertDialog : NaturalDialog;
840
- return /* @__PURE__ */ React14.createElement(Popover2.Root, {
841
- modal: true,
842
- open: !!(popoverAnchorId && popoverOpen),
843
- onOpenChange: (nextOpen) => {
844
- if (nextOpen && popoverAnchorId) {
845
- context.popoverOpen = true;
846
- } else {
847
- context.popoverOpen = false;
848
- context.popoverAnchorId = void 0;
849
- }
850
- }
851
- }, /* @__PURE__ */ React14.createElement(ActiveNode, null), layoutMode === "fullscreen" && /* @__PURE__ */ React14.createElement(Fullscreen, {
852
- id: fullScreenSlug
853
- }), layoutMode !== "fullscreen" && /* @__PURE__ */ React14.createElement(Main3.Root, {
854
- navigationSidebarOpen: context.sidebarOpen,
855
- onNavigationSidebarOpenChange: (next) => context.sidebarOpen = next,
856
- complementarySidebarOpen: context.complementarySidebarOpen,
857
- onComplementarySidebarOpenChange: (next) => context.complementarySidebarOpen = next
858
- }, /* @__PURE__ */ React14.createElement(Main3.Notch, {
859
- classNames: "z-[21]"
860
- }, /* @__PURE__ */ React14.createElement(Surface9, {
861
- role: "notch-start"
862
- }), /* @__PURE__ */ React14.createElement(Button3, {
863
- onClick: () => context.sidebarOpen = !context.sidebarOpen,
864
- variant: "ghost",
865
- classNames: "p-1"
866
- }, /* @__PURE__ */ React14.createElement("span", {
867
- className: "sr-only"
868
- }, t("open navigation sidebar label")), /* @__PURE__ */ React14.createElement(MenuIcon, {
869
- weight: "light",
870
- className: getSize(5)
871
- })), /* @__PURE__ */ React14.createElement(Surface9, {
872
- role: "notch-end"
873
- })), /* @__PURE__ */ React14.createElement(Sidebar, {
874
- layoutParts
875
- }), /* @__PURE__ */ React14.createElement(ComplementarySidebar, {
876
- panels,
877
- current: layoutParts.complementary?.[0].id
878
- }), /* @__PURE__ */ React14.createElement(Main3.Overlay, null), isEmpty && /* @__PURE__ */ React14.createElement(Main3.Content, {
879
- handlesFocus: true
880
- }, /* @__PURE__ */ React14.createElement(ContentEmpty, null)), !isEmpty && /* @__PURE__ */ React14.createElement(Main3.Content, {
881
- bounce: true,
882
- classNames: "grid block-end-[--statusbar-size]",
883
- handlesFocus: true,
884
- style: {
885
- "--dx-main-sidebarWidth": sidebarOpen ? "var(--nav-sidebar-size)" : "0px",
886
- "--dx-main-complementaryWidth": complementarySidebarOpen ? "var(--complementary-sidebar-size)" : "0px",
887
- "--dx-main-contentFirstWidth": `${plankSizing[layoutParts.main?.[0]?.id ?? "never"] ?? DEFAULT_HORIZONTAL_SIZE}rem`,
888
- "--dx-main-contentLastWidth": `${plankSizing[layoutParts.main?.[(layoutParts.main?.length ?? 1) - 1]?.id ?? "never"] ?? DEFAULT_HORIZONTAL_SIZE}rem`
889
- }
890
- }, /* @__PURE__ */ React14.createElement("div", {
891
- role: "none",
892
- className: !isSoloModeLoaded ? "relative bg-deck overflow-hidden" : "sr-only",
893
- ...isSoloModeLoaded && {
894
- inert: ""
895
- }
896
- }, /* @__PURE__ */ React14.createElement(Stack, {
897
- separators: false,
898
- orientation: "horizontal",
899
- size: "contain",
900
- classNames: [
901
- "absolute inset-block-0 -inset-inline-px",
902
- mainPaddingTransitions2
903
- ],
904
- onScroll: handleScroll,
905
- itemsCount: 2 * (layoutParts.main?.length ?? 0) - 1,
906
- style: padding,
907
- ref: deckRef
908
- }, layoutParts.main?.map((layoutEntry, index) => /* @__PURE__ */ React14.createElement(Fragment2, {
909
- key: layoutEntry.id
910
- }, /* @__PURE__ */ React14.createElement(PlankSeparator, {
911
- index
912
- }), /* @__PURE__ */ React14.createElement(Plank, {
913
- entry: layoutEntry,
914
- layoutParts,
915
- part: "main",
916
- layoutMode,
917
- order: index * 2 + 1
918
- }))))), /* @__PURE__ */ React14.createElement("div", {
919
- role: "none",
920
- className: isSoloModeLoaded ? "relative bg-deck overflow-hidden" : "sr-only",
921
- ...!isSoloModeLoaded && {
922
- inert: ""
923
- }
924
- }, /* @__PURE__ */ React14.createElement(StackContext2.Provider, {
925
- value: {
926
- size: "contain",
927
- orientation: "horizontal",
928
- separators: false,
929
- rail: true
930
- }
931
- }, /* @__PURE__ */ React14.createElement(Plank, {
932
- entry: layoutParts.solo?.[0],
933
- layoutParts,
934
- part: "solo",
935
- layoutMode
936
- })))), /* @__PURE__ */ React14.createElement(StatusBar, {
937
- showHints
938
- })), /* @__PURE__ */ React14.createElement(Popover2.Portal, null, /* @__PURE__ */ React14.createElement(Popover2.Content, {
939
- classNames: "z-[60]",
940
- onEscapeKeyDown: () => {
941
- context.popoverOpen = false;
942
- context.popoverAnchorId = void 0;
943
- }
944
- }, /* @__PURE__ */ React14.createElement(Popover2.Viewport, null, /* @__PURE__ */ React14.createElement(Surface9, {
945
- role: "popover",
946
- data: popoverContent
947
- })), /* @__PURE__ */ React14.createElement(Popover2.Arrow, null))), /* @__PURE__ */ React14.createElement(Dialog.Root, {
948
- open: dialogOpen,
949
- onOpenChange: (nextOpen) => context.dialogOpen = nextOpen
950
- }, /* @__PURE__ */ React14.createElement(Dialog.Overlay, {
951
- blockAlign: dialogBlockAlign
952
- }, /* @__PURE__ */ React14.createElement(Surface9, {
953
- role: "dialog",
954
- data: dialogContent
955
- }))), toasts?.map((toast) => /* @__PURE__ */ React14.createElement(Toast, {
956
- ...toast,
957
- key: toast.id,
958
- onOpenChange: (open) => {
959
- if (!open) {
960
- onDismissToast(toast.id);
961
- }
962
- return open;
963
- }
964
- })));
965
- };
966
-
967
- // packages/plugins/plugin-deck/src/components/LayoutSettings.tsx
968
- import React15 from "react";
969
- import { Input, Select, useTranslation as useTranslation6 } from "@dxos/react-ui";
970
- import { DeprecatedFormInput } from "@dxos/react-ui-form";
971
- var isSocket = !!globalThis.__args;
972
- var LayoutSettings = ({ settings }) => {
973
- const { t } = useTranslation6(DECK_PLUGIN);
974
- return /* @__PURE__ */ React15.createElement(React15.Fragment, null, /* @__PURE__ */ React15.createElement(DeprecatedFormInput, {
975
- label: t("select new plank positioning label")
976
- }, /* @__PURE__ */ React15.createElement(Select.Root, {
977
- value: settings.newPlankPositioning ?? "start",
978
- onValueChange: (value) => settings.newPlankPositioning = value
979
- }, /* @__PURE__ */ React15.createElement(Select.TriggerButton, {
980
- placeholder: t("select new plank positioning placeholder")
981
- }), /* @__PURE__ */ React15.createElement(Select.Portal, null, /* @__PURE__ */ React15.createElement(Select.Content, null, /* @__PURE__ */ React15.createElement(Select.Viewport, null, NewPlankPositions.map((position) => /* @__PURE__ */ React15.createElement(Select.Option, {
982
- key: position,
983
- value: position
984
- }, t(`settings new plank position ${position} label`)))))))), /* @__PURE__ */ React15.createElement(DeprecatedFormInput, {
985
- label: t("settings overscroll label")
986
- }, /* @__PURE__ */ React15.createElement(Select.Root, {
987
- value: settings.overscroll ?? "none",
988
- onValueChange: (value) => settings.overscroll = value
989
- }, /* @__PURE__ */ React15.createElement(Select.TriggerButton, {
990
- placeholder: t("select overscroll placeholder")
991
- }), /* @__PURE__ */ React15.createElement(Select.Portal, null, /* @__PURE__ */ React15.createElement(Select.Content, null, /* @__PURE__ */ React15.createElement(Select.Viewport, null, OverscrollOptions.map((option) => /* @__PURE__ */ React15.createElement(Select.Option, {
992
- key: option,
993
- value: option
994
- }, t(`settings overscroll ${option} label`)))))))), /* @__PURE__ */ React15.createElement(DeprecatedFormInput, {
995
- label: t("settings show hints label")
996
- }, /* @__PURE__ */ React15.createElement(Input.Switch, {
997
- checked: settings.showHints,
998
- onCheckedChange: (checked) => settings.showHints = checked
999
- })), !isSocket && /* @__PURE__ */ React15.createElement(DeprecatedFormInput, {
1000
- label: t("settings native redirect label")
1001
- }, /* @__PURE__ */ React15.createElement(Input.Switch, {
1002
- checked: settings.enableNativeRedirect,
1003
- onCheckedChange: (checked) => settings.enableNativeRedirect = checked
1004
- })), /* @__PURE__ */ React15.createElement(DeprecatedFormInput, {
1005
- label: t("settings custom slots")
1006
- }, /* @__PURE__ */ React15.createElement(Input.Switch, {
1007
- checked: settings.customSlots,
1008
- onCheckedChange: (checked) => settings.customSlots = checked
1009
- })), /* @__PURE__ */ React15.createElement(DeprecatedFormInput, {
1010
- label: t("settings flat deck")
1011
- }, /* @__PURE__ */ React15.createElement(Input.Switch, {
1012
- checked: settings.flatDeck,
1013
- onCheckedChange: (checked) => settings.flatDeck = checked
1014
- })));
1015
- };
1016
-
1017
- // packages/plugins/plugin-deck/src/layout.ts
1018
- import { produce } from "immer";
1019
- import { SLUG_ENTRY_SEPARATOR, SLUG_KEY_VALUE_SEPARATOR, SLUG_LIST_SEPARATOR, SLUG_PATH_SEPARATOR as SLUG_PATH_SEPARATOR3 } from "@dxos/app-framework";
1020
- var partsThatSupportIncrement = [
1021
- "main"
1022
- ];
1023
- var openEntry = (layout, part, entry, options) => {
1024
- return produce(layout, (draft) => {
1025
- const layoutPart = draft[part];
1026
- if (!layoutPart) {
1027
- draft[part] = [
1028
- entry
1029
- ];
1030
- return;
1031
- }
1032
- if (part === "main") {
1033
- if (layoutPart.find((e) => e.id === entry.id)) {
1034
- return;
1035
- }
1036
- const plankPositioning = options?.positioning ?? "start";
1037
- const pivotId = options?.pivotId;
1038
- if (pivotId) {
1039
- const pivotIndex = layoutPart.findIndex((e) => e.id === pivotId);
1040
- if (pivotIndex !== -1) {
1041
- if (plankPositioning === "start") {
1042
- layoutPart.splice(pivotIndex, 0, entry);
1043
- } else {
1044
- layoutPart.splice(pivotIndex + 1, 0, entry);
1045
- }
1046
- return;
1047
- }
1048
- }
1049
- if (plankPositioning === "start") {
1050
- layoutPart.unshift(entry);
1051
- } else {
1052
- layoutPart.push(entry);
1053
- }
1054
- } else {
1055
- draft[part] = [
1056
- entry
1057
- ];
1058
- }
1059
- });
1060
- };
1061
- var closeEntry = (layout, layoutCoordinate) => {
1062
- return produce(layout, (draft) => {
1063
- const { part, entryId: slugId } = layoutCoordinate;
1064
- const layoutPart = draft[part];
1065
- if (!layoutPart) {
1066
- return;
1067
- }
1068
- const index = layoutPart.findIndex((entry) => entry.id === slugId);
1069
- if (index === -1) {
1070
- return;
1071
- }
1072
- if (layoutPart.length === 1) {
1073
- delete draft[part];
1074
- } else {
1075
- layoutPart.splice(index, 1);
1076
- }
1077
- });
1078
- };
1079
- var incrementPlank = (layout, adjustment) => {
1080
- return produce(layout, (draft) => {
1081
- const { layoutCoordinate, type } = adjustment;
1082
- const { part, entryId } = layoutCoordinate;
1083
- if (partsThatSupportIncrement.includes(part) === false) {
1084
- return;
1085
- }
1086
- const layoutPart = draft[part];
1087
- if (!layoutPart) {
1088
- return;
1089
- }
1090
- const index = layoutPart.findIndex((entry) => entry.id === entryId);
1091
- if (index === -1 || type === "increment-start" && index === 0 || type === "increment-end" && index === layoutPart.length - 1) {
1092
- return;
1093
- }
1094
- if (type === "increment-start") {
1095
- [layoutPart[index - 1], layoutPart[index]] = [
1096
- layoutPart[index],
1097
- layoutPart[index - 1]
1098
- ];
1099
- } else if (type === "increment-end") {
1100
- [layoutPart[index], layoutPart[index + 1]] = [
1101
- layoutPart[index + 1],
1102
- layoutPart[index]
1103
- ];
1104
- }
1105
- });
1106
- };
1107
- var removePart = (layout, part) => {
1108
- return produce(layout, (draft) => {
1109
- delete draft[part];
1110
- });
1111
- };
1112
- var mergeLayoutParts = (...layoutParts) => {
1113
- return layoutParts.reduce((merged, current) => produce(merged, (draft) => {
1114
- Object.entries(current).forEach(([part, entries]) => {
1115
- const typedPart = part;
1116
- if (!draft[typedPart]) {
1117
- draft[typedPart] = [];
1118
- }
1119
- const partEntries = draft[typedPart];
1120
- entries.forEach((entry) => {
1121
- const existingIndex = partEntries.findIndex((e) => e.id === entry.id);
1122
- if (existingIndex !== -1) {
1123
- partEntries[existingIndex] = entry;
1124
- } else {
1125
- partEntries.push(entry);
1126
- }
1127
- });
1128
- });
1129
- }), {});
1130
- };
1131
- var parseLayoutEntry = (itemString) => {
1132
- const [id, path] = itemString.split(SLUG_PATH_SEPARATOR3);
1133
- const entry = {
1134
- id
1135
- };
1136
- if (path) {
1137
- entry.path = path;
1138
- }
1139
- return entry;
1140
- };
1141
- var uriToSoloPart = (uri) => {
1142
- const parts = uri.split("/");
1143
- const slug = parts[parts.length - 1];
1144
- if (slug.length > 0) {
1145
- return {
1146
- solo: [
1147
- parseLayoutEntry(slug)
1148
- ]
1149
- };
1150
- }
1151
- return void 0;
1152
- };
1153
- var soloPartToUri = (layout) => {
1154
- const soloPart = layout?.solo;
1155
- if (!soloPart || soloPart.length === 0) {
1156
- return "";
1157
- }
1158
- const entry = soloPart[0];
1159
- return `${entry.id}${entry.path ? SLUG_PATH_SEPARATOR3 + entry.path : ""}`;
1160
- };
1161
-
1162
32
  // packages/plugins/plugin-deck/src/translations.ts
1163
33
  var translations_default = [
1164
34
  {
1165
35
  "en-US": {
1166
36
  [DECK_PLUGIN]: {
37
+ "plugin name": "Deck",
1167
38
  "main header label": "Main header",
1168
- "open navigation sidebar label": "Open navigation sidebar",
1169
- "open complementary sidebar label": "Open sidebar",
39
+ "open navigation sidebar label": "Open sidebar",
40
+ "collapse navigation sidebar label": "Minimize sidebar",
41
+ "open complementary sidebar label": "Open context sidebar",
42
+ "close complementary sidebar label": "Minimize context sidebar",
1170
43
  "plugin error message": "Content failed to render.",
1171
44
  "content fallback message": "Unsupported",
1172
45
  "content fallback description": "No plugin had a response for the address you navigated\xA0to. Double-check the URL, and ensure you\u2019ve enabled a plugin that supports the\xA0object.",
1173
46
  "toggle fullscreen label": "Toggle fullscreen",
1174
47
  "settings show hints label": "Show hints",
1175
48
  "settings native redirect label": "Enable native url redirect (experimental)",
1176
- "settings custom slots": "Theme option (experimental)",
1177
49
  "settings new plank position start label": "Start",
1178
50
  "settings new plank position end label": "End",
1179
51
  "select new plank positioning placeholder": "Select new plank positioning",
@@ -1185,7 +57,7 @@ var translations_default = [
1185
57
  "error fallback message": "Unable to open this item",
1186
58
  "plank heading fallback label": "Untitled",
1187
59
  "actions menu label": "Options",
1188
- "settings deck label": "Disable Deck",
60
+ "settings deck label": "Disable deck",
1189
61
  "reload required message": "Reload required.",
1190
62
  "pending heading": "Loading\u2026",
1191
63
  "insert plank label": "Open",
@@ -1198,664 +70,85 @@ var translations_default = [
1198
70
  "show solo plank label": "Maximize",
1199
71
  "close label": "Close",
1200
72
  "minify label": "Minify",
1201
- "settings overscroll label": "Plank Overscrolling",
73
+ "settings overscroll label": "Plank overscrolling",
1202
74
  "select overscroll placeholder": "Select plank overscrolling behavior",
1203
75
  "settings overscroll centering label": "Centering",
1204
76
  "settings overscroll none label": "None",
1205
- "settings flat deck": "Flatten deck appearance"
77
+ "settings enable ide-style statusbar label": "IDE-style statusbar",
78
+ "close current label": "Close current plank",
79
+ "close others label": "Close other planks",
80
+ "close all label": "Close all planks"
1206
81
  }
1207
82
  }
1208
83
  }
1209
84
  ];
1210
85
 
1211
- // packages/plugins/plugin-deck/src/DeckPlugin.tsx
1212
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-deck/src/DeckPlugin.tsx";
1213
- var isSocket2 = !!globalThis.__args;
1214
- var appScheme = "composer://";
86
+ // packages/plugins/plugin-deck/src/DeckPlugin.ts
1215
87
  setAutoFreeze(false);
1216
- var DECK_ACTION = "dxos.org/plugin/deck";
1217
- var DeckAction;
1218
- (function(DeckAction2) {
1219
- DeckAction2[DeckAction2["UPDATE_PLANK_SIZE"] = `${DECK_ACTION}/update-plank-size`] = "UPDATE_PLANK_SIZE";
1220
- })(DeckAction || (DeckAction = {}));
1221
- var DeckPlugin = ({ observability } = {}) => {
1222
- let graphPlugin;
1223
- let intentPlugin;
1224
- let attentionPlugin;
1225
- const unsubscriptionCallbacks = [];
1226
- let currentUndoId;
1227
- let handleNavigation;
1228
- const panels = [];
1229
- const settings = new LocalStorageStore("dxos.org/settings/layout", {
1230
- showHints: false,
1231
- customSlots: false,
1232
- flatDeck: false,
1233
- enableNativeRedirect: false,
1234
- disableDeck: false,
1235
- newPlankPositioning: "start",
1236
- overscroll: "centering"
1237
- });
1238
- const layout = new LocalStorageStore("dxos.org/settings/layout", {
1239
- layoutMode: "solo",
1240
- sidebarOpen: true,
1241
- complementarySidebarOpen: false,
1242
- dialogContent: null,
1243
- dialogOpen: false,
1244
- dialogBlockAlign: void 0,
1245
- dialogType: void 0,
1246
- popoverContent: null,
1247
- popoverAnchorId: void 0,
1248
- popoverOpen: false,
1249
- toasts: []
1250
- });
1251
- const deck = new LocalStorageStore("dxos.org/settings/deck", {
1252
- plankSizing: {}
1253
- });
1254
- const location = new LocalStorageStore("dxos.org/state/layout", {
1255
- active: {
1256
- sidebar: [
1257
- {
1258
- id: NAV_ID
1259
- }
1260
- ]
1261
- },
1262
- closed: []
1263
- });
1264
- const layoutModeHistory = create({
1265
- values: []
1266
- });
1267
- const handleSetLayout = ({ element, state, component, subject, anchorId, dialogBlockAlign, dialogType }) => {
1268
- switch (element) {
1269
- case "sidebar": {
1270
- layout.values.sidebarOpen = state ?? !layout.values.sidebarOpen;
1271
- return {
1272
- data: true
1273
- };
1274
- }
1275
- case "complementary": {
1276
- layout.values.complementarySidebarOpen = !!state;
1277
- return {
1278
- data: true
1279
- };
1280
- }
1281
- case "dialog": {
1282
- layout.values.dialogOpen = state ?? Boolean(component);
1283
- layout.values.dialogContent = component ? {
1284
- component,
1285
- subject
1286
- } : null;
1287
- layout.values.dialogBlockAlign = dialogBlockAlign ?? "center";
1288
- layout.values.dialogType = dialogType;
1289
- return {
1290
- data: true
1291
- };
1292
- }
1293
- case "popover": {
1294
- layout.values.popoverOpen = state ?? Boolean(component);
1295
- layout.values.popoverContent = component ? {
1296
- component,
1297
- subject
1298
- } : null;
1299
- layout.values.popoverAnchorId = anchorId;
1300
- return {
1301
- data: true
1302
- };
1303
- }
1304
- case "toast": {
1305
- if (ToastSchema.safeParse(subject).success) {
1306
- layout.values.toasts = [
1307
- ...layout.values.toasts,
1308
- subject
1309
- ];
1310
- return {
1311
- data: true
1312
- };
1313
- }
1314
- }
1315
- }
1316
- };
1317
- const handleSetLocation = (next) => {
1318
- const part = layout.values.layoutMode === "solo" ? "solo" : "main";
1319
- const ids = openIds2(next, [
1320
- part
1321
- ]);
1322
- if (attentionPlugin) {
1323
- const attended = attentionPlugin.provides.attention.attended;
1324
- const [attendedId] = Array.from(attended);
1325
- const isAttendedAvailable = !!attendedId && ids.includes(attendedId);
1326
- if (!isAttendedAvailable) {
1327
- const currentIds = location.values.active[part]?.map(({ id }) => id) ?? [];
1328
- const attendedIndex = currentIds.indexOf(attendedId);
1329
- const index = attendedIndex === -1 ? 0 : attendedIndex >= ids.length ? ids.length - 1 : attendedIndex;
1330
- const nextAttended = next[part]?.[index].id;
1331
- void intentPlugin?.provides.intent.dispatch({
1332
- action: LayoutAction3.SCROLL_INTO_VIEW,
1333
- data: {
1334
- id: nextAttended
1335
- }
1336
- });
1337
- }
1338
- }
1339
- const current = openIds2(location.values.active, [
1340
- part
1341
- ]);
1342
- const removed = current.filter((id) => !ids.includes(id));
1343
- const closed = Array.from(/* @__PURE__ */ new Set([
1344
- ...location.values.closed.filter((id) => !ids.includes(id)),
1345
- ...removed
1346
- ]));
1347
- location.values.closed = closed;
1348
- location.values.active = next;
1349
- };
1350
- return {
1351
- meta: meta_default,
1352
- ready: async (plugins) => {
1353
- intentPlugin = resolvePlugin(plugins, parseIntentPlugin);
1354
- graphPlugin = resolvePlugin(plugins, parseGraphPlugin);
1355
- attentionPlugin = resolvePlugin(plugins, parseAttentionPlugin);
1356
- layout.prop({
1357
- key: "layoutMode",
1358
- type: LocalStorageStore.enum()
1359
- }).prop({
1360
- key: "sidebarOpen",
1361
- type: LocalStorageStore.bool()
1362
- }).prop({
1363
- key: "complementarySidebarOpen",
1364
- type: LocalStorageStore.bool()
1365
- });
1366
- deck.prop({
1367
- key: "plankSizing",
1368
- type: LocalStorageStore.json()
1369
- });
1370
- location.prop({
1371
- key: "active",
1372
- type: LocalStorageStore.json()
1373
- }).prop({
1374
- key: "closed",
1375
- type: LocalStorageStore.json()
1376
- });
1377
- panels.push(...filterPlugins(plugins, parsePanelPlugin).flatMap((plugin) => plugin.provides.complementary.panels));
1378
- settings.prop({
1379
- key: "showHints",
1380
- type: LocalStorageStore.bool()
1381
- }).prop({
1382
- key: "customSlots",
1383
- type: LocalStorageStore.bool()
1384
- }).prop({
1385
- key: "flatDeck",
1386
- type: LocalStorageStore.bool()
1387
- }).prop({
1388
- key: "enableNativeRedirect",
1389
- type: LocalStorageStore.bool()
1390
- }).prop({
1391
- key: "disableDeck",
1392
- type: LocalStorageStore.bool()
1393
- }).prop({
1394
- key: "newPlankPositioning",
1395
- type: LocalStorageStore.enum()
1396
- }).prop({
1397
- key: "overscroll",
1398
- type: LocalStorageStore.enum()
1399
- });
1400
- if (!isSocket2 && settings.values.enableNativeRedirect) {
1401
- checkAppScheme(appScheme);
1402
- }
1403
- handleNavigation = async () => {
1404
- const pathname = window.location.pathname;
1405
- if (pathname === "/reset") {
1406
- handleSetLocation({
1407
- sidebar: [
1408
- {
1409
- id: NAV_ID
1410
- }
1411
- ]
1412
- });
1413
- location.values.closed = [];
1414
- layout.values.layoutMode = "solo";
1415
- window.location.pathname = "/";
1416
- return;
1417
- }
1418
- const startingLayout = removePart(location.values.active, "solo");
1419
- const layoutFromUri = uriToSoloPart(pathname);
1420
- if (!layoutFromUri) {
1421
- handleSetLocation(startingLayout);
1422
- layout.values.layoutMode = "deck";
1423
- return;
1424
- }
1425
- handleSetLocation(mergeLayoutParts(layoutFromUri, startingLayout));
1426
- layout.values.layoutMode = "solo";
1427
- };
1428
- await handleNavigation();
1429
- window.addEventListener("popstate", handleNavigation);
1430
- unsubscriptionCallbacks.push(scheduledEffect(() => ({
1431
- selectedPath: soloPartToUri(location.values.active)
1432
- }), ({ selectedPath }) => {
1433
- history.pushState(null, "", `/${selectedPath}${window.location.search}`);
1434
- }));
1435
- layoutModeHistory.values.push(`${layout.values.layoutMode}`);
1436
- },
1437
- unload: async () => {
1438
- layout.close();
1439
- location.close();
1440
- unsubscriptionCallbacks.forEach((unsubscribe) => unsubscribe?.());
1441
- window.removeEventListener("popstate", handleNavigation);
1442
- },
1443
- provides: {
1444
- settings: settings.values,
1445
- layout: layout.values,
1446
- location: location.values,
1447
- translations: [
1448
- ...translations_default,
1449
- ...stackTranslations
1450
- ],
1451
- graph: {
1452
- builder: () => {
1453
- return createExtension({
1454
- id: DECK_PLUGIN,
1455
- // NOTE(Zan): This is currently disabled.
1456
- // TODO(Zan): Fullscreen needs to know the active node and provide that to the layout part.
1457
- filter: (node) => false,
1458
- actions: () => [
1459
- {
1460
- id: `${LayoutAction3.SET_LAYOUT_MODE}/fullscreen`,
1461
- data: async () => {
1462
- await intentPlugin?.provides.intent.dispatch({
1463
- plugin: DECK_PLUGIN,
1464
- action: LayoutAction3.SET_LAYOUT_MODE,
1465
- data: {
1466
- layoutMode: "fullscreen"
1467
- }
1468
- });
1469
- },
1470
- properties: {
1471
- label: [
1472
- "toggle fullscreen label",
1473
- {
1474
- ns: DECK_PLUGIN
1475
- }
1476
- ],
1477
- icon: "ph--arrows-out--regular",
1478
- keyBinding: {
1479
- macos: "ctrl+meta+f",
1480
- windows: "shift+ctrl+f"
1481
- }
1482
- }
1483
- }
1484
- ]
1485
- });
1486
- }
1487
- },
1488
- context: (props) => /* @__PURE__ */ React16.createElement(LayoutContext.Provider, {
1489
- value: layout.values
1490
- }, /* @__PURE__ */ React16.createElement(DeckContext.Provider, {
1491
- value: deck.values
1492
- }, props.children)),
1493
- root: () => {
1494
- return /* @__PURE__ */ React16.createElement(DeckLayout, {
1495
- layoutParts: location.values.active,
1496
- showHints: settings.values.showHints,
1497
- overscroll: settings.values.overscroll,
1498
- toasts: layout.values.toasts,
1499
- panels,
1500
- onDismissToast: (id) => {
1501
- const index = layout.values.toasts.findIndex((toast) => toast.id === id);
1502
- if (index !== -1) {
1503
- setTimeout(() => {
1504
- if (layout.values.toasts[index].id === currentUndoId) {
1505
- currentUndoId = void 0;
1506
- }
1507
- layout.values.toasts.splice(index, 1);
1508
- }, 1e3);
1509
- }
1510
- }
1511
- });
1512
- },
1513
- surface: {
1514
- component: ({ data, role }) => {
1515
- switch (role) {
1516
- case "settings":
1517
- return data.plugin === meta_default.id ? /* @__PURE__ */ React16.createElement(LayoutSettings, {
1518
- settings: settings.values
1519
- }) : null;
1520
- }
1521
- return null;
1522
- }
1523
- },
1524
- intent: {
1525
- resolver: (intent) => {
1526
- switch (intent.action) {
1527
- case LayoutAction3.SET_LAYOUT: {
1528
- return intent.data && handleSetLayout(intent.data);
1529
- }
1530
- case LayoutAction3.SET_LAYOUT_MODE: {
1531
- const setMode = (mode) => {
1532
- const main = openIds2(location.values.active, [
1533
- "main"
1534
- ]);
1535
- const solo = openIds2(location.values.active, [
1536
- "solo"
1537
- ]);
1538
- const current = layout.values.layoutMode === "solo" ? solo : main;
1539
- const next = mode === "solo" ? solo : [
1540
- ...main,
1541
- ...solo
1542
- ];
1543
- const removed = current.filter((id) => !next.includes(id));
1544
- const closed = Array.from(/* @__PURE__ */ new Set([
1545
- ...location.values.closed.filter((id) => !next.includes(id)),
1546
- ...removed
1547
- ]));
1548
- location.values.closed = closed;
1549
- layout.values.layoutMode = mode;
1550
- };
1551
- return batch(() => {
1552
- if (!intent.data) {
1553
- return;
1554
- }
1555
- if (intent.data?.revert) {
1556
- setMode(layoutModeHistory.values.pop() ?? "solo");
1557
- return {
1558
- data: true
1559
- };
1560
- }
1561
- if (isLayoutMode(intent?.data?.layoutMode)) {
1562
- layoutModeHistory.values.push(layout.values.layoutMode);
1563
- setMode(intent.data.layoutMode);
1564
- } else {
1565
- log.warn("Invalid layout mode", intent?.data?.layoutMode, {
1566
- F: __dxlog_file,
1567
- L: 412,
1568
- S: void 0,
1569
- C: (f, a) => f(...a)
1570
- });
1571
- }
1572
- return {
1573
- data: true
1574
- };
1575
- });
1576
- }
1577
- case LayoutAction3.SCROLL_INTO_VIEW: {
1578
- layout.values.scrollIntoView = intent.data?.id ?? void 0;
1579
- return {
1580
- data: true
1581
- };
1582
- }
1583
- case DeckAction.UPDATE_PLANK_SIZE: {
1584
- const { id, size } = intent.data;
1585
- deck.values.plankSizing[id] = size;
1586
- return {
1587
- data: true
1588
- };
1589
- }
1590
- case IntentAction.SHOW_UNDO: {
1591
- if (currentUndoId) {
1592
- layout.values.toasts = layout.values.toasts.filter((toast) => toast.id !== currentUndoId);
1593
- }
1594
- currentUndoId = `${IntentAction.SHOW_UNDO}-${Date.now()}`;
1595
- const title = (
1596
- // TODO(wittjosiah): How to handle chains better?
1597
- intent.data?.results?.[0]?.result?.undoable?.message ?? translations_default[0]["en-US"]["dxos.org/plugin/deck"]["undo available label"]
1598
- );
1599
- layout.values.toasts = [
1600
- ...layout.values.toasts,
1601
- {
1602
- id: currentUndoId,
1603
- title,
1604
- duration: 1e4,
1605
- actionLabel: translations_default[0]["en-US"]["dxos.org/plugin/deck"]["undo action label"],
1606
- actionAlt: translations_default[0]["en-US"]["dxos.org/plugin/deck"]["undo action alt"],
1607
- closeLabel: translations_default[0]["en-US"]["dxos.org/plugin/deck"]["undo close label"],
1608
- onAction: () => intentPlugin?.provides.intent.undo?.()
1609
- }
1610
- ];
1611
- return {
1612
- data: true
1613
- };
1614
- }
1615
- case NavigationAction3.OPEN: {
1616
- const previouslyOpenIds = new Set(openIds2(location.values.active));
1617
- const layoutMode = layout.values.layoutMode;
1618
- batch(() => {
1619
- if (!intent.data || !intent.data?.activeParts) {
1620
- return;
1621
- }
1622
- const processLayoutEntry = (partName, entryString, currentLayout) => {
1623
- const toggle = false;
1624
- const [id, path] = entryString.split(SLUG_PATH_SEPARATOR4);
1625
- const layoutEntry = {
1626
- id,
1627
- ...path ? {
1628
- path
1629
- } : {}
1630
- };
1631
- const effectivePart = getEffectivePart(partName, layoutMode);
1632
- if (toggle && layoutMode === "deck" && effectivePart === "main" && currentLayout[effectivePart]?.some((entry) => entry.id === id) && !intent.data?.noToggle) {
1633
- return closeEntry(currentLayout, {
1634
- part: effectivePart,
1635
- entryId: id
1636
- });
1637
- } else {
1638
- return openEntry(currentLayout, effectivePart, layoutEntry, {
1639
- positioning: settings.values.newPlankPositioning
1640
- });
1641
- }
1642
- };
1643
- let newLayout = location.values.active;
1644
- Object.entries(intent.data.activeParts).forEach(([partName, layoutEntries]) => {
1645
- if (Array.isArray(layoutEntries)) {
1646
- layoutEntries.forEach((activePartEntry) => {
1647
- newLayout = processLayoutEntry(partName, activePartEntry, newLayout);
1648
- });
1649
- } else if (typeof layoutEntries === "string") {
1650
- newLayout = processLayoutEntry(partName, layoutEntries, newLayout);
1651
- }
1652
- });
1653
- handleSetLocation(newLayout);
1654
- });
1655
- const ids = openIds2(location.values.active);
1656
- const newlyOpen = ids.filter((i) => !previouslyOpenIds.has(i));
1657
- return {
1658
- data: {
1659
- ids
1660
- },
1661
- intents: [
1662
- newlyOpen.length > 0 ? [
1663
- {
1664
- action: LayoutAction3.SCROLL_INTO_VIEW,
1665
- data: {
1666
- id: newlyOpen[0]
1667
- }
1668
- }
1669
- ] : [],
1670
- intent.data?.object ? [
1671
- {
1672
- action: NavigationAction3.EXPOSE,
1673
- data: {
1674
- id: fullyQualifiedId(intent.data.object)
1675
- }
1676
- }
1677
- ] : [],
1678
- observability ? newlyOpen.map((id) => {
1679
- const active = graphPlugin?.provides.graph.findNode(id)?.data;
1680
- const typename = isReactiveObject(active) ? getTypename(active) : void 0;
1681
- return {
1682
- action: ObservabilityAction.SEND_EVENT,
1683
- data: {
1684
- name: "navigation.activate",
1685
- properties: {
1686
- id,
1687
- typename
1688
- }
1689
- }
1690
- };
1691
- }) : []
1692
- ]
1693
- };
1694
- }
1695
- case NavigationAction3.ADD_TO_ACTIVE: {
1696
- const data = intent.data;
1697
- const layoutEntry = {
1698
- id: data.id
1699
- };
1700
- const effectivePart = getEffectivePart(data.part, layout.values.layoutMode);
1701
- handleSetLocation(openEntry(location.values.active, effectivePart, layoutEntry, {
1702
- positioning: data.positioning ?? settings.values.newPlankPositioning,
1703
- pivotId: data.pivotId
1704
- }));
1705
- const intents = [];
1706
- if (data.scrollIntoView && layout.values.layoutMode === "deck") {
1707
- intents.push([
1708
- {
1709
- action: LayoutAction3.SCROLL_INTO_VIEW,
1710
- data: {
1711
- id: data.id
1712
- }
1713
- }
1714
- ]);
1715
- }
1716
- return {
1717
- data: true,
1718
- intents
1719
- };
1720
- }
1721
- case NavigationAction3.CLOSE: {
1722
- return batch(() => {
1723
- if (!intent.data) {
1724
- return;
1725
- }
1726
- let newLayout = location.values.active;
1727
- const layoutMode = layout.values.layoutMode;
1728
- const intentParts = intent.data.activeParts;
1729
- Object.keys(intentParts).forEach((partName) => {
1730
- const effectivePart = getEffectivePart(partName, layoutMode);
1731
- const ids = intentParts[partName];
1732
- if (Array.isArray(ids)) {
1733
- ids.forEach((id) => {
1734
- newLayout = closeEntry(newLayout, {
1735
- part: effectivePart,
1736
- entryId: id
1737
- });
1738
- });
1739
- } else {
1740
- newLayout = closeEntry(newLayout, {
1741
- part: effectivePart,
1742
- entryId: ids
1743
- });
1744
- }
1745
- });
1746
- handleSetLocation(newLayout);
1747
- return {
1748
- data: true
1749
- };
1750
- });
1751
- }
1752
- // TODO(wittjosiah): Factor out.
1753
- case NavigationAction3.SET: {
1754
- return batch(() => {
1755
- if (isLayoutParts(intent.data?.activeParts)) {
1756
- handleSetLocation(intent.data.activeParts);
1757
- }
1758
- return {
1759
- data: true
1760
- };
1761
- });
1762
- }
1763
- case NavigationAction3.ADJUST: {
1764
- return batch(() => {
1765
- if (isLayoutAdjustment(intent.data)) {
1766
- const adjustment = intent.data;
1767
- if (adjustment.type === "increment-end" || adjustment.type === "increment-start") {
1768
- handleSetLocation(incrementPlank(location.values.active, {
1769
- type: adjustment.type,
1770
- layoutCoordinate: adjustment.layoutCoordinate
1771
- }));
1772
- }
1773
- if (adjustment.type === "solo") {
1774
- const entryId = adjustment.layoutCoordinate.entryId;
1775
- if (layout.values.layoutMode !== "solo") {
1776
- return {
1777
- data: true,
1778
- intents: [
1779
- // NOTE: The order of these is important.
1780
- [
1781
- {
1782
- action: NavigationAction3.OPEN,
1783
- data: {
1784
- activeParts: {
1785
- solo: [
1786
- entryId
1787
- ]
1788
- }
1789
- }
1790
- },
1791
- {
1792
- action: LayoutAction3.SET_LAYOUT_MODE,
1793
- data: {
1794
- layoutMode: "solo"
1795
- }
1796
- }
1797
- ]
1798
- ]
1799
- };
1800
- } else {
1801
- return {
1802
- data: true,
1803
- intents: [
1804
- // NOTE: The order of these is important.
1805
- [
1806
- {
1807
- action: LayoutAction3.SET_LAYOUT_MODE,
1808
- data: {
1809
- layoutMode: "deck"
1810
- }
1811
- },
1812
- {
1813
- action: NavigationAction3.CLOSE,
1814
- data: {
1815
- activeParts: {
1816
- solo: [
1817
- entryId
1818
- ]
1819
- }
1820
- }
1821
- },
1822
- {
1823
- action: NavigationAction3.OPEN,
1824
- data: {
1825
- noToggle: true,
1826
- activeParts: {
1827
- main: [
1828
- entryId
1829
- ]
1830
- }
1831
- }
1832
- },
1833
- {
1834
- action: LayoutAction3.SCROLL_INTO_VIEW,
1835
- data: {
1836
- id: entryId
1837
- }
1838
- }
1839
- ]
1840
- ]
1841
- };
1842
- }
1843
- }
1844
- }
1845
- });
1846
- }
1847
- }
1848
- }
1849
- }
1850
- }
1851
- };
1852
- };
1853
-
1854
- // packages/plugins/plugin-deck/src/index.ts
1855
- var src_default = DeckPlugin;
88
+ var DeckPlugin = () => definePlugin(meta, [
89
+ defineModule({
90
+ id: `${meta.id}/module/check-app-scheme`,
91
+ activatesOn: Events2.SettingsReady,
92
+ activate: CheckAppScheme
93
+ }),
94
+ defineModule({
95
+ id: `${meta.id}/module/settings`,
96
+ activatesOn: Events2.SetupSettings,
97
+ activate: DeckSettings
98
+ }),
99
+ defineModule({
100
+ id: `${meta.id}/module/layout`,
101
+ activatesOn: oneOf(Events2.Startup, Events2.SetupAppGraph),
102
+ activatesAfter: [
103
+ Events2.LayoutReady,
104
+ DeckEvents.StateReady
105
+ ],
106
+ activate: DeckState
107
+ }),
108
+ defineModule({
109
+ id: `${meta.id}/module/translations`,
110
+ activatesOn: Events2.SetupTranslations,
111
+ activate: () => contributes(Capabilities.Translations, [
112
+ ...translations_default,
113
+ ...stackTranslations
114
+ ])
115
+ }),
116
+ defineModule({
117
+ id: `${meta.id}/module/react-root`,
118
+ activatesOn: Events2.Startup,
119
+ activate: ReactRoot
120
+ }),
121
+ defineModule({
122
+ id: `${meta.id}/module/react-surface`,
123
+ activatesOn: Events2.SetupSurfaces,
124
+ activate: ReactSurface
125
+ }),
126
+ defineModule({
127
+ id: `${meta.id}/module/layout-intent-resolver`,
128
+ activatesOn: Events2.SetupIntents,
129
+ activate: LayoutIntentResolver
130
+ }),
131
+ defineModule({
132
+ id: `${meta.id}/module/app-graph-builder`,
133
+ activatesOn: Events2.SetupAppGraph,
134
+ activate: AppGraphBuilder
135
+ }),
136
+ defineModule({
137
+ id: `${meta.id}/module/tools`,
138
+ activatesOn: Events2.Startup,
139
+ activate: Tools
140
+ }),
141
+ defineModule({
142
+ id: `${meta.id}/module/url`,
143
+ activatesOn: allOf(Events2.DispatcherReady, DeckEvents.StateReady),
144
+ activate: UrlHandler
145
+ })
146
+ ]);
1856
147
  export {
1857
- DeckAction,
148
+ DECK_PLUGIN,
149
+ DeckCapabilities,
150
+ DeckEvents,
1858
151
  DeckPlugin,
1859
- src_default as default
152
+ meta
1860
153
  };
1861
154
  //# sourceMappingURL=index.mjs.map