@dxos/app-framework 0.3.10-main.ec4f2f4 → 0.3.10-main.f460bb8

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.
@@ -55,6 +55,12 @@ var LayoutAction;
55
55
  LayoutAction2[LayoutAction2["OPEN_POPOVER"] = `${LAYOUT_ACTION}/open-popover`] = "OPEN_POPOVER";
56
56
  LayoutAction2[LayoutAction2["CLOSE_POPOVER"] = `${LAYOUT_ACTION}/close-popover`] = "CLOSE_POPOVER";
57
57
  LayoutAction2[LayoutAction2["ACTIVATE"] = `${LAYOUT_ACTION}/activate`] = "ACTIVATE";
58
+ LayoutAction2[LayoutAction2[
59
+ // TODO(burdon): Move to new plugin.
60
+ "OPEN_COMMANDS"
61
+ ] = `${LAYOUT_ACTION}/open-commands`] = "OPEN_COMMANDS";
62
+ LayoutAction2[LayoutAction2["OPEN_SETTINGS"] = `${LAYOUT_ACTION}/open-settings`] = "OPEN_SETTINGS";
63
+ LayoutAction2[LayoutAction2["OPEN_SHORTCUTS"] = `${LAYOUT_ACTION}/open-shortcuts`] = "OPEN_SHORTCUTS";
58
64
  })(LayoutAction || (LayoutAction = {}));
59
65
 
60
66
  // packages/sdk/app-framework/src/plugins/common/metadata.ts
@@ -78,10 +84,98 @@ var parseTranslationsPlugin = (plugin) => {
78
84
  return success ? plugin : void 0;
79
85
  };
80
86
 
87
+ // packages/sdk/app-framework/src/plugins/components/CommandsDialog.tsx
88
+ import { DotOutline } from "@phosphor-icons/react";
89
+ import React, { useMemo, useRef } from "react";
90
+ import { Keyboard, keySymbols } from "@dxos/keyboard";
91
+ import { Button, Dialog, useTranslation } from "@dxos/react-ui";
92
+ import { SearchList } from "@dxos/react-ui-searchlist";
93
+ import { descriptionText, getSize, mx } from "@dxos/react-ui-theme";
94
+ var CommandsDialogContent = ({ graph }) => {
95
+ const { t } = useTranslation("os");
96
+ const toString = (label) => Array.isArray(label) ? t(...label) : label;
97
+ const actions = useMemo(() => {
98
+ const current = Keyboard.singleton.getCurrentContext();
99
+ const actionMap = /* @__PURE__ */ new Set();
100
+ const actions2 = [];
101
+ graph?.traverse({
102
+ visitor: (node, path) => {
103
+ if (current.startsWith(path.join("/"))) {
104
+ node.actions.forEach((action) => {
105
+ if (!actionMap.has(action.id)) {
106
+ actionMap.add(action.id);
107
+ actions2.push(action);
108
+ }
109
+ });
110
+ }
111
+ }
112
+ });
113
+ actions2.sort(({ label: a }, { label: b }) => {
114
+ return toString(a)?.toLowerCase().localeCompare(toString(b)?.toLowerCase());
115
+ });
116
+ return actions2;
117
+ }, [
118
+ graph
119
+ ]);
120
+ const buttonRef = useRef(null);
121
+ return /* @__PURE__ */ React.createElement(Dialog.Content, {
122
+ classNames: [
123
+ "md:max-is-[30rem] overflow-hidden"
124
+ ]
125
+ }, /* @__PURE__ */ React.createElement(Dialog.Title, null, t("commands dialog title", {
126
+ ns: "os"
127
+ })), /* @__PURE__ */ React.createElement(SearchList.Root, {
128
+ label: t("commandlist input placeholder"),
129
+ classNames: "flex flex-col grow overflow-hidden my-2"
130
+ }, /* @__PURE__ */ React.createElement(SearchList.Input, {
131
+ placeholder: t("commandlist input placeholder"),
132
+ classNames: mx("px-1 my-2")
133
+ }), /* @__PURE__ */ React.createElement(SearchList.Content, {
134
+ classNames: [
135
+ "max-bs-[30rem] overflow-auto"
136
+ ]
137
+ }, actions?.map((action) => {
138
+ const label = toString(action.label);
139
+ const Icon = action.icon ?? DotOutline;
140
+ return /* @__PURE__ */ React.createElement(SearchList.Item, {
141
+ value: label,
142
+ key: action.id,
143
+ onSelect: () => {
144
+ if (action.properties.disabled) {
145
+ return;
146
+ }
147
+ buttonRef.current?.click();
148
+ setTimeout(() => {
149
+ void action.invoke();
150
+ });
151
+ },
152
+ classNames: "flex items-center gap-2",
153
+ disabled: action.properties.disabled,
154
+ ...action.properties?.testId && {
155
+ "data-testid": action.properties.testId
156
+ }
157
+ }, /* @__PURE__ */ React.createElement(Icon, {
158
+ className: mx(getSize(4), "shrink-0", !action.icon && "invisible")
159
+ }), /* @__PURE__ */ React.createElement("span", {
160
+ className: "grow truncate"
161
+ }, label), action.keyBinding && /* @__PURE__ */ React.createElement("span", {
162
+ className: mx("shrink-0", descriptionText)
163
+ }, keySymbols(action.keyBinding).join("")));
164
+ }))), /* @__PURE__ */ React.createElement(Dialog.Close, {
165
+ asChild: true
166
+ }, /* @__PURE__ */ React.createElement(Button, {
167
+ ref: buttonRef,
168
+ variant: "primary",
169
+ classNames: "mbs-2"
170
+ }, t("close label", {
171
+ ns: "os"
172
+ }))));
173
+ };
174
+
81
175
  // packages/sdk/app-framework/src/plugins/components/SettingsDialog.tsx
82
- import React4, { useState } from "react";
83
- import { Button, DensityProvider, Dialog, List, ListItem, useTranslation } from "@dxos/react-ui";
84
- import { ghostHover, ghostSelected, groupBorder, mx } from "@dxos/react-ui-theme";
176
+ import React5, { useState } from "react";
177
+ import { Button as Button2, Dialog as Dialog2, List, ListItem, useTranslation as useTranslation2 } from "@dxos/react-ui";
178
+ import { ghostHover, ghostSelected, groupBorder, mx as mx2 } from "@dxos/react-ui-theme";
85
179
 
86
180
  // packages/sdk/app-framework/src/plugins/PluginHost/plugin.ts
87
181
  var pluginMeta = (meta) => meta;
@@ -117,7 +211,7 @@ var PluginProvider = PluginContext.Provider;
117
211
 
118
212
  // packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx
119
213
  import { shallow } from "deepsignal/react";
120
- import React, { useEffect } from "react";
214
+ import React2, { useEffect } from "react";
121
215
  import { LocalStorageStore } from "@dxos/local-storage";
122
216
  import { log } from "@dxos/log";
123
217
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx";
@@ -150,7 +244,7 @@ var PluginHost = ({ order, plugins: definitions, core = [], defaults = [], fallb
150
244
  },
151
245
  provides: {
152
246
  plugins: state.values,
153
- context: ({ children }) => /* @__PURE__ */ React.createElement(PluginProvider, {
247
+ context: ({ children }) => /* @__PURE__ */ React2.createElement(PluginProvider, {
154
248
  value: state.values
155
249
  }, children),
156
250
  root: () => {
@@ -208,10 +302,10 @@ var PluginHost = ({ order, plugins: definitions, core = [], defaults = [], fallb
208
302
  };
209
303
  }, []);
210
304
  if (!state.values.ready) {
211
- return /* @__PURE__ */ React.createElement(React.Fragment, null, fallback);
305
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, fallback);
212
306
  }
213
307
  const ComposedContext = composeContext(state.values.plugins);
214
- return /* @__PURE__ */ React.createElement(ComposedContext, null, rootComponents(state.values.plugins));
308
+ return /* @__PURE__ */ React2.createElement(ComposedContext, null, rootComponents(state.values.plugins));
215
309
  }
216
310
  }
217
311
  };
@@ -230,7 +324,7 @@ var rootComponents = (plugins) => {
230
324
  return plugins.map((plugin) => {
231
325
  const Component2 = plugin.provides.root;
232
326
  if (Component2) {
233
- return /* @__PURE__ */ React.createElement(Component2, {
327
+ return /* @__PURE__ */ React2.createElement(Component2, {
234
328
  key: plugin.meta.id
235
329
  });
236
330
  } else {
@@ -244,14 +338,14 @@ var composeContext = (plugins) => {
244
338
  var compose = (contexts) => {
245
339
  return [
246
340
  ...contexts
247
- ].reduce((Acc, Next) => ({ children }) => /* @__PURE__ */ React.createElement(Acc, null, /* @__PURE__ */ React.createElement(Next, null, children)));
341
+ ].reduce((Acc, Next) => ({ children }) => /* @__PURE__ */ React2.createElement(Acc, null, /* @__PURE__ */ React2.createElement(Next, null, children)));
248
342
  };
249
343
 
250
344
  // packages/sdk/app-framework/src/plugins/SurfacePlugin/helpers.ts
251
345
  var isObject = (data) => !!data && typeof data === "object";
252
346
 
253
347
  // packages/sdk/app-framework/src/plugins/SurfacePlugin/ErrorBoundary.tsx
254
- import React2, { Component } from "react";
348
+ import React3, { Component } from "react";
255
349
  var ErrorBoundary = class extends Component {
256
350
  constructor(props) {
257
351
  super(props);
@@ -271,7 +365,7 @@ var ErrorBoundary = class extends Component {
271
365
  }
272
366
  render() {
273
367
  if (this.state.error) {
274
- return /* @__PURE__ */ React2.createElement(this.props.fallback, {
368
+ return /* @__PURE__ */ React3.createElement(this.props.fallback, {
275
369
  error: this.state.error,
276
370
  reset: this.resetError
277
371
  });
@@ -286,7 +380,7 @@ var ErrorBoundary = class extends Component {
286
380
  };
287
381
 
288
382
  // packages/sdk/app-framework/src/plugins/SurfacePlugin/Surface.tsx
289
- import React3, { forwardRef, Fragment, isValidElement } from "react";
383
+ import React4, { forwardRef, Fragment, isValidElement } from "react";
290
384
  import { createContext as createContext2, useContext as useContext2 } from "react";
291
385
  var Surface = /* @__PURE__ */ forwardRef(({ role, name = role, fallback, ...rest }, forwardedRef) => {
292
386
  const props = {
@@ -297,13 +391,13 @@ var Surface = /* @__PURE__ */ forwardRef(({ role, name = role, fallback, ...rest
297
391
  };
298
392
  const context = useContext2(SurfaceContext);
299
393
  const data = props.data ?? (name && context?.surfaces?.[name]?.data || {});
300
- return /* @__PURE__ */ React3.createElement(React3.Fragment, null, fallback ? /* @__PURE__ */ React3.createElement(ErrorBoundary, {
394
+ return /* @__PURE__ */ React4.createElement(React4.Fragment, null, fallback ? /* @__PURE__ */ React4.createElement(ErrorBoundary, {
301
395
  data,
302
396
  fallback
303
- }, /* @__PURE__ */ React3.createElement(SurfaceResolver, {
397
+ }, /* @__PURE__ */ React4.createElement(SurfaceResolver, {
304
398
  ...props,
305
399
  ref: forwardedRef
306
- })) : /* @__PURE__ */ React3.createElement(SurfaceResolver, {
400
+ })) : /* @__PURE__ */ React4.createElement(SurfaceResolver, {
307
401
  ...props,
308
402
  ref: forwardedRef
309
403
  }));
@@ -320,9 +414,9 @@ var SurfaceResolver = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
320
414
  ...props.surfaces
321
415
  }
322
416
  };
323
- return /* @__PURE__ */ React3.createElement(SurfaceContext.Provider, {
417
+ return /* @__PURE__ */ React4.createElement(SurfaceContext.Provider, {
324
418
  value: currentContext
325
- }, nodes.length > 0 ? nodes : props.contentFallback ? /* @__PURE__ */ React3.createElement(props.contentFallback, null) : null);
419
+ }, nodes.length > 0 ? nodes : props.contentFallback ? /* @__PURE__ */ React4.createElement(props.contentFallback, null) : null);
326
420
  });
327
421
  var resolveNodes = (components, props, context, forwardedRef) => {
328
422
  const data = {
@@ -357,7 +451,7 @@ var resolveNodes = (components, props, context, forwardedRef) => {
357
451
  return 1;
358
452
  }
359
453
  return 0;
360
- }).map(([key, result]) => /* @__PURE__ */ React3.createElement(Fragment, {
454
+ }).map(([key, result]) => /* @__PURE__ */ React4.createElement(Fragment, {
361
455
  key
362
456
  }, result.node));
363
457
  return props.limit ? nodes.slice(0, props.limit) : nodes;
@@ -365,8 +459,8 @@ var resolveNodes = (components, props, context, forwardedRef) => {
365
459
 
366
460
  // packages/sdk/app-framework/src/plugins/components/SettingsDialog.tsx
367
461
  var SettingsDialogContent = () => {
462
+ const { t } = useTranslation2("os");
368
463
  const [plugin, setPlugin] = useState("dxos.org/plugin/registry");
369
- const { t } = useTranslation("os");
370
464
  const { plugins, enabled } = usePlugins();
371
465
  const core = [
372
466
  "dxos.org/plugin/layout",
@@ -375,52 +469,51 @@ var SettingsDialogContent = () => {
375
469
  "dxos.org/plugin/registry"
376
470
  ];
377
471
  const filteredPlugins = enabled.map((id) => plugins.find((plugin2) => plugin2.meta.id === id)).filter((plugin2) => plugin2?.provides?.settings).map((plugin2) => plugin2.meta).sort(({ name: a }, { name: b }) => a?.localeCompare(b ?? "") ?? 0);
378
- return /* @__PURE__ */ React4.createElement(DensityProvider, {
379
- density: "fine"
380
- }, /* @__PURE__ */ React4.createElement(Dialog.Content, {
472
+ return /* @__PURE__ */ React5.createElement(Dialog2.Content, {
381
473
  classNames: [
382
- "h-[90%] md:max-is-[40rem] overflow-hidden"
474
+ "h-full md:max-is-[40rem] overflow-hidden"
383
475
  ]
384
- }, /* @__PURE__ */ React4.createElement(Dialog.Title, null, t("settings dialog title", {
476
+ }, /* @__PURE__ */ React5.createElement(Dialog2.Title, null, t("settings dialog title", {
385
477
  ns: "os"
386
- })), /* @__PURE__ */ React4.createElement("div", {
478
+ })), /* @__PURE__ */ React5.createElement("div", {
387
479
  className: "flex grow mlb-4 overflow-hidden"
388
- }, /* @__PURE__ */ React4.createElement("div", {
389
- className: mx("flex flex-col w-[200px] space-y-4 pr-4 border-r overflow-y-auto", groupBorder)
390
- }, /* @__PURE__ */ React4.createElement(PluginList, {
480
+ }, /* @__PURE__ */ React5.createElement("div", {
481
+ className: mx2("flex flex-col w-[200px] space-y-4 pr-4 border-r overflow-y-auto", groupBorder)
482
+ }, /* @__PURE__ */ React5.createElement(PluginList, {
391
483
  title: "Options",
392
484
  plugins: core.map((id) => plugins.find((p) => p.meta.id === id).meta),
393
485
  selected: plugin,
394
486
  onSelect: (plugin2) => setPlugin(plugin2)
395
- }), /* @__PURE__ */ React4.createElement(PluginList, {
487
+ }), /* @__PURE__ */ React5.createElement(PluginList, {
396
488
  title: "Plugins",
397
489
  plugins: filteredPlugins,
398
490
  selected: plugin,
399
491
  onSelect: (plugin2) => setPlugin(plugin2)
400
- })), /* @__PURE__ */ React4.createElement("div", {
401
- className: mx("flex flex-col w-full md:px-4 divide-y overflow-y-auto", groupBorder)
402
- }, /* @__PURE__ */ React4.createElement(Surface, {
492
+ })), /* @__PURE__ */ React5.createElement("div", {
493
+ className: mx2("flex flex-col w-full md:px-4 divide-y overflow-y-auto", groupBorder)
494
+ }, /* @__PURE__ */ React5.createElement(Surface, {
403
495
  role: "settings",
404
496
  data: {
405
497
  plugin
406
498
  }
407
- }))), /* @__PURE__ */ React4.createElement(Dialog.Close, {
499
+ }))), /* @__PURE__ */ React5.createElement(Dialog2.Close, {
408
500
  asChild: true
409
- }, /* @__PURE__ */ React4.createElement(Button, {
501
+ }, /* @__PURE__ */ React5.createElement(Button2, {
410
502
  variant: "primary",
411
- classNames: "mbs-2"
503
+ classNames: "mbs-2",
504
+ autoFocus: true
412
505
  }, t("done label", {
413
506
  ns: "os"
414
- })))));
507
+ }))));
415
508
  };
416
509
  var PluginList = ({ title, plugins, selected, onSelect }) => {
417
- return /* @__PURE__ */ React4.createElement("div", {
510
+ return /* @__PURE__ */ React5.createElement("div", {
418
511
  role: "none"
419
- }, /* @__PURE__ */ React4.createElement("h2", {
512
+ }, /* @__PURE__ */ React5.createElement("h2", {
420
513
  className: "my-1 px-2 text-sm text-neutral-500"
421
- }, title), /* @__PURE__ */ React4.createElement(List, {
514
+ }, title), /* @__PURE__ */ React5.createElement(List, {
422
515
  selectable: true
423
- }, plugins.map((plugin) => /* @__PURE__ */ React4.createElement(ListItem.Root, {
516
+ }, plugins.map((plugin) => /* @__PURE__ */ React5.createElement(ListItem.Root, {
424
517
  key: plugin.id,
425
518
  onClick: () => onSelect(plugin.id),
426
519
  selected: plugin.id === selected,
@@ -429,7 +522,7 @@ var PluginList = ({ title, plugins, selected, onSelect }) => {
429
522
  plugin.id === selected && ghostSelected,
430
523
  ghostHover
431
524
  ]
432
- }, /* @__PURE__ */ React4.createElement(ListItem.Heading, {
525
+ }, /* @__PURE__ */ React5.createElement(ListItem.Heading, {
433
526
  classNames: [
434
527
  "flex w-full items-center cursor-pointer"
435
528
  ]
@@ -437,29 +530,29 @@ var PluginList = ({ title, plugins, selected, onSelect }) => {
437
530
  };
438
531
 
439
532
  // packages/sdk/app-framework/src/plugins/components/SettingsValue.tsx
440
- import React5 from "react";
533
+ import React6 from "react";
441
534
  import { Input } from "@dxos/react-ui";
442
535
  var SettingsValue = ({ label, description, children }) => {
443
- return /* @__PURE__ */ React5.createElement("div", {
536
+ return /* @__PURE__ */ React6.createElement("div", {
444
537
  role: "none",
445
538
  className: "flex w-full gap-4 py-1"
446
- }, /* @__PURE__ */ React5.createElement(Input.Root, null, /* @__PURE__ */ React5.createElement("div", {
539
+ }, /* @__PURE__ */ React6.createElement(Input.Root, null, /* @__PURE__ */ React6.createElement("div", {
447
540
  role: "none",
448
541
  className: "flex flex-col w-full"
449
- }, /* @__PURE__ */ React5.createElement(Input.Label, {
542
+ }, /* @__PURE__ */ React6.createElement(Input.Label, {
450
543
  classNames: "flex min-h-[40px] items-center"
451
- }, label), description && /* @__PURE__ */ React5.createElement(Input.DescriptionAndValidation, {
544
+ }, label), description && /* @__PURE__ */ React6.createElement(Input.DescriptionAndValidation, {
452
545
  classNames: "mbs-0.5"
453
- }, /* @__PURE__ */ React5.createElement(Input.Description, null, description))), /* @__PURE__ */ React5.createElement("div", {
546
+ }, /* @__PURE__ */ React6.createElement(Input.Description, null, description))), /* @__PURE__ */ React6.createElement("div", {
454
547
  role: "none"
455
- }, /* @__PURE__ */ React5.createElement("div", {
548
+ }, /* @__PURE__ */ React6.createElement("div", {
456
549
  role: "none",
457
550
  className: "flex min-h-[40px] items-center"
458
551
  }, children))));
459
552
  };
460
553
 
461
554
  // packages/sdk/app-framework/src/App.tsx
462
- import React6 from "react";
555
+ import React7 from "react";
463
556
  import { invariant } from "@dxos/invariant";
464
557
  var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/App.tsx";
465
558
  var createApp = ({ order, plugins, core = order.map(({ id }) => id), ...params }) => {
@@ -501,9 +594,10 @@ var createApp = ({ order, plugins, core = order.map(({ id }) => id), ...params }
501
594
  });
502
595
  const Context = host.provides.context;
503
596
  const Root = host.provides.root;
504
- return () => /* @__PURE__ */ React6.createElement(Context, null, /* @__PURE__ */ React6.createElement(Root, null));
597
+ return () => /* @__PURE__ */ React7.createElement(Context, null, /* @__PURE__ */ React7.createElement(Root, null));
505
598
  };
506
599
  export {
600
+ CommandsDialogContent,
507
601
  ErrorBoundary,
508
602
  IntentProvider,
509
603
  Layout,