@dxos/app-framework 0.3.10-main.dcfebef → 0.3.10-main.e948ee0

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.
@@ -54,9 +54,13 @@ var LayoutAction;
54
54
  LayoutAction2[LayoutAction2["CLOSE_DIALOG"] = `${LAYOUT_ACTION}/close-dialog`] = "CLOSE_DIALOG";
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
+ 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";
57
62
  LayoutAction2[LayoutAction2["OPEN_SETTINGS"] = `${LAYOUT_ACTION}/open-settings`] = "OPEN_SETTINGS";
58
63
  LayoutAction2[LayoutAction2["OPEN_SHORTCUTS"] = `${LAYOUT_ACTION}/open-shortcuts`] = "OPEN_SHORTCUTS";
59
- LayoutAction2[LayoutAction2["ACTIVATE"] = `${LAYOUT_ACTION}/activate`] = "ACTIVATE";
60
64
  })(LayoutAction || (LayoutAction = {}));
61
65
 
62
66
  // packages/sdk/app-framework/src/plugins/common/metadata.ts
@@ -80,10 +84,98 @@ var parseTranslationsPlugin = (plugin) => {
80
84
  return success ? plugin : void 0;
81
85
  };
82
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
+
83
175
  // packages/sdk/app-framework/src/plugins/components/SettingsDialog.tsx
84
- import React4, { useState } from "react";
85
- import { Button, DensityProvider, Dialog, List, ListItem, useTranslation } from "@dxos/react-ui";
86
- 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";
87
179
 
88
180
  // packages/sdk/app-framework/src/plugins/PluginHost/plugin.ts
89
181
  var pluginMeta = (meta) => meta;
@@ -119,7 +211,7 @@ var PluginProvider = PluginContext.Provider;
119
211
 
120
212
  // packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx
121
213
  import { shallow } from "deepsignal/react";
122
- import React, { useEffect } from "react";
214
+ import React2, { useEffect } from "react";
123
215
  import { LocalStorageStore } from "@dxos/local-storage";
124
216
  import { log } from "@dxos/log";
125
217
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx";
@@ -152,7 +244,7 @@ var PluginHost = ({ order, plugins: definitions, core = [], defaults = [], fallb
152
244
  },
153
245
  provides: {
154
246
  plugins: state.values,
155
- context: ({ children }) => /* @__PURE__ */ React.createElement(PluginProvider, {
247
+ context: ({ children }) => /* @__PURE__ */ React2.createElement(PluginProvider, {
156
248
  value: state.values
157
249
  }, children),
158
250
  root: () => {
@@ -210,10 +302,10 @@ var PluginHost = ({ order, plugins: definitions, core = [], defaults = [], fallb
210
302
  };
211
303
  }, []);
212
304
  if (!state.values.ready) {
213
- return /* @__PURE__ */ React.createElement(React.Fragment, null, fallback);
305
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, fallback);
214
306
  }
215
307
  const ComposedContext = composeContext(state.values.plugins);
216
- return /* @__PURE__ */ React.createElement(ComposedContext, null, rootComponents(state.values.plugins));
308
+ return /* @__PURE__ */ React2.createElement(ComposedContext, null, rootComponents(state.values.plugins));
217
309
  }
218
310
  }
219
311
  };
@@ -232,7 +324,7 @@ var rootComponents = (plugins) => {
232
324
  return plugins.map((plugin) => {
233
325
  const Component2 = plugin.provides.root;
234
326
  if (Component2) {
235
- return /* @__PURE__ */ React.createElement(Component2, {
327
+ return /* @__PURE__ */ React2.createElement(Component2, {
236
328
  key: plugin.meta.id
237
329
  });
238
330
  } else {
@@ -246,14 +338,14 @@ var composeContext = (plugins) => {
246
338
  var compose = (contexts) => {
247
339
  return [
248
340
  ...contexts
249
- ].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)));
250
342
  };
251
343
 
252
344
  // packages/sdk/app-framework/src/plugins/SurfacePlugin/helpers.ts
253
345
  var isObject = (data) => !!data && typeof data === "object";
254
346
 
255
347
  // packages/sdk/app-framework/src/plugins/SurfacePlugin/ErrorBoundary.tsx
256
- import React2, { Component } from "react";
348
+ import React3, { Component } from "react";
257
349
  var ErrorBoundary = class extends Component {
258
350
  constructor(props) {
259
351
  super(props);
@@ -273,7 +365,7 @@ var ErrorBoundary = class extends Component {
273
365
  }
274
366
  render() {
275
367
  if (this.state.error) {
276
- return /* @__PURE__ */ React2.createElement(this.props.fallback, {
368
+ return /* @__PURE__ */ React3.createElement(this.props.fallback, {
277
369
  error: this.state.error,
278
370
  reset: this.resetError
279
371
  });
@@ -288,7 +380,7 @@ var ErrorBoundary = class extends Component {
288
380
  };
289
381
 
290
382
  // packages/sdk/app-framework/src/plugins/SurfacePlugin/Surface.tsx
291
- import React3, { forwardRef, Fragment, isValidElement } from "react";
383
+ import React4, { forwardRef, Fragment, isValidElement } from "react";
292
384
  import { createContext as createContext2, useContext as useContext2 } from "react";
293
385
  var Surface = /* @__PURE__ */ forwardRef(({ role, name = role, fallback, ...rest }, forwardedRef) => {
294
386
  const props = {
@@ -299,13 +391,13 @@ var Surface = /* @__PURE__ */ forwardRef(({ role, name = role, fallback, ...rest
299
391
  };
300
392
  const context = useContext2(SurfaceContext);
301
393
  const data = props.data ?? (name && context?.surfaces?.[name]?.data || {});
302
- 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, {
303
395
  data,
304
396
  fallback
305
- }, /* @__PURE__ */ React3.createElement(SurfaceResolver, {
397
+ }, /* @__PURE__ */ React4.createElement(SurfaceResolver, {
306
398
  ...props,
307
399
  ref: forwardedRef
308
- })) : /* @__PURE__ */ React3.createElement(SurfaceResolver, {
400
+ })) : /* @__PURE__ */ React4.createElement(SurfaceResolver, {
309
401
  ...props,
310
402
  ref: forwardedRef
311
403
  }));
@@ -322,9 +414,9 @@ var SurfaceResolver = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
322
414
  ...props.surfaces
323
415
  }
324
416
  };
325
- return /* @__PURE__ */ React3.createElement(SurfaceContext.Provider, {
417
+ return /* @__PURE__ */ React4.createElement(SurfaceContext.Provider, {
326
418
  value: currentContext
327
- }, 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);
328
420
  });
329
421
  var resolveNodes = (components, props, context, forwardedRef) => {
330
422
  const data = {
@@ -359,7 +451,7 @@ var resolveNodes = (components, props, context, forwardedRef) => {
359
451
  return 1;
360
452
  }
361
453
  return 0;
362
- }).map(([key, result]) => /* @__PURE__ */ React3.createElement(Fragment, {
454
+ }).map(([key, result]) => /* @__PURE__ */ React4.createElement(Fragment, {
363
455
  key
364
456
  }, result.node));
365
457
  return props.limit ? nodes.slice(0, props.limit) : nodes;
@@ -367,7 +459,7 @@ var resolveNodes = (components, props, context, forwardedRef) => {
367
459
 
368
460
  // packages/sdk/app-framework/src/plugins/components/SettingsDialog.tsx
369
461
  var SettingsDialogContent = () => {
370
- const { t } = useTranslation("os");
462
+ const { t } = useTranslation2("os");
371
463
  const [plugin, setPlugin] = useState("dxos.org/plugin/registry");
372
464
  const { plugins, enabled } = usePlugins();
373
465
  const core = [
@@ -377,52 +469,51 @@ var SettingsDialogContent = () => {
377
469
  "dxos.org/plugin/registry"
378
470
  ];
379
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);
380
- return /* @__PURE__ */ React4.createElement(DensityProvider, {
381
- density: "fine"
382
- }, /* @__PURE__ */ React4.createElement(Dialog.Content, {
472
+ return /* @__PURE__ */ React5.createElement(Dialog2.Content, {
383
473
  classNames: [
384
- "h-[90%] md:max-is-[40rem] overflow-hidden"
474
+ "h-full md:max-is-[40rem] overflow-hidden"
385
475
  ]
386
- }, /* @__PURE__ */ React4.createElement(Dialog.Title, null, t("settings dialog title", {
476
+ }, /* @__PURE__ */ React5.createElement(Dialog2.Title, null, t("settings dialog title", {
387
477
  ns: "os"
388
- })), /* @__PURE__ */ React4.createElement("div", {
478
+ })), /* @__PURE__ */ React5.createElement("div", {
389
479
  className: "flex grow mlb-4 overflow-hidden"
390
- }, /* @__PURE__ */ React4.createElement("div", {
391
- className: mx("flex flex-col w-[200px] space-y-4 pr-4 border-r overflow-y-auto", groupBorder)
392
- }, /* @__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, {
393
483
  title: "Options",
394
484
  plugins: core.map((id) => plugins.find((p) => p.meta.id === id).meta),
395
485
  selected: plugin,
396
486
  onSelect: (plugin2) => setPlugin(plugin2)
397
- }), /* @__PURE__ */ React4.createElement(PluginList, {
487
+ }), /* @__PURE__ */ React5.createElement(PluginList, {
398
488
  title: "Plugins",
399
489
  plugins: filteredPlugins,
400
490
  selected: plugin,
401
491
  onSelect: (plugin2) => setPlugin(plugin2)
402
- })), /* @__PURE__ */ React4.createElement("div", {
403
- className: mx("flex flex-col w-full md:px-4 divide-y overflow-y-auto", groupBorder)
404
- }, /* @__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, {
405
495
  role: "settings",
406
496
  data: {
407
497
  plugin
408
498
  }
409
- }))), /* @__PURE__ */ React4.createElement(Dialog.Close, {
499
+ }))), /* @__PURE__ */ React5.createElement(Dialog2.Close, {
410
500
  asChild: true
411
- }, /* @__PURE__ */ React4.createElement(Button, {
501
+ }, /* @__PURE__ */ React5.createElement(Button2, {
412
502
  variant: "primary",
413
- classNames: "mbs-2"
503
+ classNames: "mbs-2",
504
+ autoFocus: true
414
505
  }, t("done label", {
415
506
  ns: "os"
416
- })))));
507
+ }))));
417
508
  };
418
509
  var PluginList = ({ title, plugins, selected, onSelect }) => {
419
- return /* @__PURE__ */ React4.createElement("div", {
510
+ return /* @__PURE__ */ React5.createElement("div", {
420
511
  role: "none"
421
- }, /* @__PURE__ */ React4.createElement("h2", {
512
+ }, /* @__PURE__ */ React5.createElement("h2", {
422
513
  className: "my-1 px-2 text-sm text-neutral-500"
423
- }, title), /* @__PURE__ */ React4.createElement(List, {
514
+ }, title), /* @__PURE__ */ React5.createElement(List, {
424
515
  selectable: true
425
- }, plugins.map((plugin) => /* @__PURE__ */ React4.createElement(ListItem.Root, {
516
+ }, plugins.map((plugin) => /* @__PURE__ */ React5.createElement(ListItem.Root, {
426
517
  key: plugin.id,
427
518
  onClick: () => onSelect(plugin.id),
428
519
  selected: plugin.id === selected,
@@ -431,7 +522,7 @@ var PluginList = ({ title, plugins, selected, onSelect }) => {
431
522
  plugin.id === selected && ghostSelected,
432
523
  ghostHover
433
524
  ]
434
- }, /* @__PURE__ */ React4.createElement(ListItem.Heading, {
525
+ }, /* @__PURE__ */ React5.createElement(ListItem.Heading, {
435
526
  classNames: [
436
527
  "flex w-full items-center cursor-pointer"
437
528
  ]
@@ -439,69 +530,27 @@ var PluginList = ({ title, plugins, selected, onSelect }) => {
439
530
  };
440
531
 
441
532
  // packages/sdk/app-framework/src/plugins/components/SettingsValue.tsx
442
- import React5 from "react";
533
+ import React6 from "react";
443
534
  import { Input } from "@dxos/react-ui";
444
535
  var SettingsValue = ({ label, description, children }) => {
445
- return /* @__PURE__ */ React5.createElement("div", {
536
+ return /* @__PURE__ */ React6.createElement("div", {
446
537
  role: "none",
447
538
  className: "flex w-full gap-4 py-1"
448
- }, /* @__PURE__ */ React5.createElement(Input.Root, null, /* @__PURE__ */ React5.createElement("div", {
539
+ }, /* @__PURE__ */ React6.createElement(Input.Root, null, /* @__PURE__ */ React6.createElement("div", {
449
540
  role: "none",
450
541
  className: "flex flex-col w-full"
451
- }, /* @__PURE__ */ React5.createElement(Input.Label, {
542
+ }, /* @__PURE__ */ React6.createElement(Input.Label, {
452
543
  classNames: "flex min-h-[40px] items-center"
453
- }, label), description && /* @__PURE__ */ React5.createElement(Input.DescriptionAndValidation, {
544
+ }, label), description && /* @__PURE__ */ React6.createElement(Input.DescriptionAndValidation, {
454
545
  classNames: "mbs-0.5"
455
- }, /* @__PURE__ */ React5.createElement(Input.Description, null, description))), /* @__PURE__ */ React5.createElement("div", {
546
+ }, /* @__PURE__ */ React6.createElement(Input.Description, null, description))), /* @__PURE__ */ React6.createElement("div", {
456
547
  role: "none"
457
- }, /* @__PURE__ */ React5.createElement("div", {
548
+ }, /* @__PURE__ */ React6.createElement("div", {
458
549
  role: "none",
459
550
  className: "flex min-h-[40px] items-center"
460
551
  }, children))));
461
552
  };
462
553
 
463
- // packages/sdk/app-framework/src/plugins/components/ShortcutsDialog.tsx
464
- import React6 from "react";
465
- import { Keyboard, keySymbols } from "@dxos/keyboard";
466
- import { Button as Button2, Dialog as Dialog2, DensityProvider as DensityProvider2, useTranslation as useTranslation2 } from "@dxos/react-ui";
467
- import { mx as mx2 } from "@dxos/react-ui-theme";
468
- var ShortcutsDialogContent = () => {
469
- const { t } = useTranslation2("os");
470
- const bindings = Keyboard.singleton.getBindings();
471
- const getLabel = (label) => Array.isArray(label) ? t(...label) : label;
472
- return /* @__PURE__ */ React6.createElement(DensityProvider2, {
473
- density: "fine"
474
- }, /* @__PURE__ */ React6.createElement(Dialog2.Content, {
475
- classNames: [
476
- "md:max-is-[30rem] overflow-hidden"
477
- ]
478
- }, /* @__PURE__ */ React6.createElement(Dialog2.Title, null, t("shortcuts dialog title", {
479
- ns: "os"
480
- })), /* @__PURE__ */ React6.createElement("table", {
481
- className: "table-fixed border-collapse my-4"
482
- }, /* @__PURE__ */ React6.createElement("tbody", null, bindings.map((binding, i) => /* @__PURE__ */ React6.createElement("tr", {
483
- key: i
484
- }, /* @__PURE__ */ React6.createElement("td", {
485
- className: "p-1 w-[120px]"
486
- }, /* @__PURE__ */ React6.createElement("div", {
487
- className: "flex gap-1"
488
- }, keySymbols(binding.binding).map((c, i2) => /* @__PURE__ */ React6.createElement("span", {
489
- key: i2,
490
- className: mx2("inline-flex w-[24px] h-[24px] justify-center items-center text-xs", "rounded border border-neutral-300 dark:border-neutral-600 bg-neutral-50 dark:bg-neutral-850")
491
- }, c)))), /* @__PURE__ */ React6.createElement("td", {
492
- className: "p-1"
493
- }, /* @__PURE__ */ React6.createElement("span", {
494
- className: "grow truncate"
495
- }, getLabel(binding.data))))))), /* @__PURE__ */ React6.createElement(Dialog2.Close, {
496
- asChild: true
497
- }, /* @__PURE__ */ React6.createElement(Button2, {
498
- variant: "primary",
499
- classNames: "mbs-2"
500
- }, t("close label", {
501
- ns: "os"
502
- })))));
503
- };
504
-
505
554
  // packages/sdk/app-framework/src/App.tsx
506
555
  import React7 from "react";
507
556
  import { invariant } from "@dxos/invariant";
@@ -548,6 +597,7 @@ var createApp = ({ order, plugins, core = order.map(({ id }) => id), ...params }
548
597
  return () => /* @__PURE__ */ React7.createElement(Context, null, /* @__PURE__ */ React7.createElement(Root, null));
549
598
  };
550
599
  export {
600
+ CommandsDialogContent,
551
601
  ErrorBoundary,
552
602
  IntentProvider,
553
603
  Layout,
@@ -560,7 +610,6 @@ export {
560
610
  ResourceLanguage,
561
611
  SettingsDialogContent,
562
612
  SettingsValue,
563
- ShortcutsDialogContent,
564
613
  Surface,
565
614
  SurfaceProvider,
566
615
  createApp,