@dxos/plugin-debug 0.6.14-main.2b6a0f3 → 0.6.14-main.f49f251

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  DebugContext
3
- } from "./chunk-6Y463JSP.mjs";
3
+ } from "./chunk-NHHLZV45.mjs";
4
4
  import "./chunk-2HTS7SNO.mjs";
5
5
  import {
6
6
  DebugPanel
@@ -408,4 +408,4 @@ var DebugSpace_default = DebugSpace;
408
408
  export {
409
409
  DebugSpace_default as default
410
410
  };
411
- //# sourceMappingURL=DebugSpace-2G2PBGCC.mjs.map
411
+ //# sourceMappingURL=DebugSpace-I6BNZKI2.mjs.map
@@ -4,6 +4,7 @@ import {
4
4
 
5
5
  // packages/plugins/plugin-debug/src/types.ts
6
6
  import { createContext } from "react";
7
+ import { S } from "@dxos/echo-schema";
7
8
  var DEBUG_ACTION = `${DEBUG_PLUGIN}/action`;
8
9
  var DebugAction;
9
10
  (function(DebugAction2) {
@@ -16,9 +17,15 @@ var DebugContext = createContext({
16
17
  stop: () => {
17
18
  }
18
19
  });
20
+ var DebugSettingsSchema = S.mutable(S.Struct({
21
+ devtools: S.optional(S.Boolean),
22
+ debug: S.optional(S.Boolean),
23
+ wireframe: S.optional(S.Boolean)
24
+ }));
19
25
 
20
26
  export {
21
27
  DebugAction,
22
- DebugContext
28
+ DebugContext,
29
+ DebugSettingsSchema
23
30
  };
24
- //# sourceMappingURL=chunk-6Y463JSP.mjs.map
31
+ //# sourceMappingURL=chunk-NHHLZV45.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/types.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Context, createContext } from 'react';\n\nimport type {\n GraphBuilderProvides,\n IntentResolverProvides,\n SettingsProvides,\n SurfaceProvides,\n TranslationsProvides,\n} from '@dxos/app-framework';\nimport type { TimerCallback, TimerOptions } from '@dxos/async';\nimport { S } from '@dxos/echo-schema';\n\nimport { DEBUG_PLUGIN } from './meta';\n\nconst DEBUG_ACTION = `${DEBUG_PLUGIN}/action`;\nexport enum DebugAction {\n OPEN_DEVTOOLS = `${DEBUG_ACTION}/open-devtools`,\n}\n\nexport type DebugContextType = {\n running: boolean;\n start: (cb: TimerCallback, options: TimerOptions) => void;\n stop: () => void;\n};\n\nexport const DebugContext: Context<DebugContextType> = createContext<DebugContextType>({\n running: false,\n start: () => {},\n stop: () => {},\n});\n\nexport const DebugSettingsSchema = S.mutable(\n S.Struct({\n devtools: S.optional(S.Boolean),\n debug: S.optional(S.Boolean),\n wireframe: S.optional(S.Boolean),\n }),\n);\n\nexport interface DebugSettingsProps extends S.Schema.Type<typeof DebugSettingsSchema> {}\n\nexport type DebugPluginProvides = SurfaceProvides &\n IntentResolverProvides &\n GraphBuilderProvides &\n SettingsProvides<DebugSettingsProps> &\n TranslationsProvides;\n"],
5
+ "mappings": ";;;;;AAIA,SAAuBA,qBAAqB;AAU5C,SAASC,SAAS;AAIlB,IAAMC,eAAe,GAAGC,YAAAA;;UACZC,cAAAA;+CACM,GAAGF,YAAAA,gBAA4B,IAAA;GADrCE,gBAAAA,cAAAA,CAAAA,EAAAA;AAUL,IAAMC,eAA0CC,cAAgC;EACrFC,SAAS;EACTC,OAAO,MAAA;EAAO;EACdC,MAAM,MAAA;EAAO;AACf,CAAA;AAEO,IAAMC,sBAAsBC,EAAEC,QACnCD,EAAEE,OAAO;EACPC,UAAUH,EAAEI,SAASJ,EAAEK,OAAO;EAC9BC,OAAON,EAAEI,SAASJ,EAAEK,OAAO;EAC3BE,WAAWP,EAAEI,SAASJ,EAAEK,OAAO;AACjC,CAAA,CAAA;",
6
+ "names": ["createContext", "S", "DEBUG_ACTION", "DEBUG_PLUGIN", "DebugAction", "DebugContext", "createContext", "running", "start", "stop", "DebugSettingsSchema", "S", "mutable", "Struct", "devtools", "optional", "Boolean", "debug", "wireframe"]
7
+ }
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  DebugAction,
3
- DebugContext
4
- } from "./chunk-6Y463JSP.mjs";
3
+ DebugContext,
4
+ DebugSettingsSchema
5
+ } from "./chunk-NHHLZV45.mjs";
5
6
  import {
6
7
  DEBUG_PLUGIN,
7
8
  meta_default
@@ -9,14 +10,15 @@ import {
9
10
 
10
11
  // packages/plugins/plugin-debug/src/DebugPlugin.tsx
11
12
  import React5, { useEffect as useEffect3, useState as useState3 } from "react";
12
- import { getPlugin, parseGraphPlugin as parseGraphPlugin2, parseIntentPlugin, resolvePlugin } from "@dxos/app-framework";
13
+ import { definePlugin, parseGraphPlugin as parseGraphPlugin2, parseIntentPlugin, parseMetadataResolverPlugin, parseSettingsPlugin, resolvePlugin } from "@dxos/app-framework";
13
14
  import { Timer } from "@dxos/async";
14
15
  import { Devtools } from "@dxos/devtools";
15
- import { LocalStorageStore } from "@dxos/local-storage";
16
- import { createExtension, Graph } from "@dxos/plugin-graph";
16
+ import { invariant } from "@dxos/invariant";
17
+ import { parseClientPlugin } from "@dxos/plugin-client";
18
+ import { createExtension, Graph, toSignal } from "@dxos/plugin-graph";
17
19
  import { SpaceAction } from "@dxos/plugin-space";
18
20
  import { CollectionType } from "@dxos/plugin-space/types";
19
- import { SpaceState, isEchoObject, isSpace } from "@dxos/react-client/echo";
21
+ import { create, getTypename, isEchoObject, isSpace, parseId, SpaceState } from "@dxos/react-client/echo";
20
22
  import { Main } from "@dxos/react-ui";
21
23
  import { baseSurface, bottombarBlockPaddingEnd, fixedInsetFlexLayout, topbarBlockPaddingStart } from "@dxos/react-ui-theme";
22
24
 
@@ -42,9 +44,9 @@ import React2, { useEffect, useState } from "react";
42
44
  import { parseFileManagerPlugin, useResolvePlugin } from "@dxos/app-framework";
43
45
  import { defs, SaveConfig, Storage } from "@dxos/config";
44
46
  import { log } from "@dxos/log";
45
- import { SettingsValue } from "@dxos/plugin-settings";
46
47
  import { useClient } from "@dxos/react-client";
47
48
  import { useTranslation, Button, Toast, Input, useFileDownload, Select } from "@dxos/react-ui";
49
+ import { FormInput } from "@dxos/react-ui-data";
48
50
  import { getSize, mx } from "@dxos/react-ui-theme";
49
51
  import { setDeep } from "@dxos/util";
50
52
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-debug/src/components/DebugSettings.tsx";
@@ -124,28 +126,28 @@ var DebugSettings = ({ settings }) => {
124
126
  });
125
127
  }
126
128
  };
127
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(SettingsValue, {
129
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(FormInput, {
128
130
  label: t("settings show debug panel")
129
131
  }, /* @__PURE__ */ React2.createElement(Input.Switch, {
130
132
  checked: settings.debug,
131
133
  onCheckedChange: (checked) => settings.debug = !!checked
132
- })), /* @__PURE__ */ React2.createElement(SettingsValue, {
134
+ })), /* @__PURE__ */ React2.createElement(FormInput, {
133
135
  label: t("settings show devtools panel")
134
136
  }, /* @__PURE__ */ React2.createElement(Input.Switch, {
135
137
  checked: settings.devtools,
136
138
  onCheckedChange: (checked) => settings.devtools = !!checked
137
- })), /* @__PURE__ */ React2.createElement(SettingsValue, {
139
+ })), /* @__PURE__ */ React2.createElement(FormInput, {
138
140
  label: t("settings wireframe")
139
141
  }, /* @__PURE__ */ React2.createElement(Input.Switch, {
140
142
  checked: settings.wireframe,
141
143
  onCheckedChange: (checked) => settings.wireframe = !!checked
142
- })), /* @__PURE__ */ React2.createElement(SettingsValue, {
144
+ })), /* @__PURE__ */ React2.createElement(FormInput, {
143
145
  label: t("settings download diagnostics")
144
146
  }, /* @__PURE__ */ React2.createElement(Button, {
145
147
  onClick: handleDownload
146
148
  }, /* @__PURE__ */ React2.createElement(DownloadSimple, {
147
149
  className: getSize(5)
148
- }))), /* @__PURE__ */ React2.createElement(SettingsValue, {
150
+ }))), /* @__PURE__ */ React2.createElement(FormInput, {
149
151
  label: t("settings repair")
150
152
  }, /* @__PURE__ */ React2.createElement(Button, {
151
153
  onClick: handleRepair
@@ -154,7 +156,7 @@ var DebugSettings = ({ settings }) => {
154
156
  }))), toast && /* @__PURE__ */ React2.createElement(Toast.Root, null, /* @__PURE__ */ React2.createElement(Toast.Body, null, /* @__PURE__ */ React2.createElement(Toast.Title, null, /* @__PURE__ */ React2.createElement(Gift, {
155
157
  className: mx(getSize(5), "inline mr-1"),
156
158
  weight: "duotone"
157
- }), /* @__PURE__ */ React2.createElement("span", null, toast.title)), toast.description && /* @__PURE__ */ React2.createElement(Toast.Description, null, toast.description))), /* @__PURE__ */ React2.createElement(SettingsValue, {
159
+ }), /* @__PURE__ */ React2.createElement("span", null, toast.title)), toast.description && /* @__PURE__ */ React2.createElement(Toast.Description, null, toast.description))), /* @__PURE__ */ React2.createElement(FormInput, {
158
160
  label: t("settings choose storage adaptor")
159
161
  }, /* @__PURE__ */ React2.createElement(Select.Root, {
160
162
  value: Object.entries(StorageAdapters).find(([name, value]) => value === storageConfig?.runtime?.client?.storage?.dataStore)?.[0],
@@ -319,7 +321,7 @@ var PerformanceIndicator = () => {
319
321
  icon: "ph--chart-bar--regular",
320
322
  size: 4
321
323
  })), visible && /* @__PURE__ */ React3.createElement("div", {
322
- className: mx2("z-20 absolute bottom-[--statusbar-size] right-2 w-[450px] max-h-[600px]", "overflow-x-hidden overflow-y-auto scrollbar-thin", "border-x border-y border-separator")
324
+ className: mx2("z-20 absolute bottom-[--statusbar-size] right-4 w-[450px]", "overflow-x-hidden overflow-y-auto scrollbar-thin", "border-x border-y border-separator")
323
325
  }, /* @__PURE__ */ React3.createElement(StatsPanel, {
324
326
  stats,
325
327
  onRefresh: refreshStats
@@ -386,7 +388,7 @@ var Wireframe = ({ classNames, label, object }) => {
386
388
 
387
389
  // packages/plugins/plugin-debug/src/components/index.ts
388
390
  var DebugGlobal = lazy(() => import("./DebugGlobal-ZTCBF3XR.mjs"));
389
- var DebugSpace = lazy(() => import("./DebugSpace-2G2PBGCC.mjs"));
391
+ var DebugSpace = lazy(() => import("./DebugSpace-I6BNZKI2.mjs"));
390
392
 
391
393
  // packages/plugins/plugin-debug/src/translations.ts
392
394
  var translations_default = [
@@ -420,32 +422,20 @@ var translations_default = [
420
422
  ];
421
423
 
422
424
  // packages/plugins/plugin-debug/src/DebugPlugin.tsx
423
- var SETTINGS_KEY = DEBUG_PLUGIN + "/settings";
424
- var DebugPlugin = () => {
425
- const settings = new LocalStorageStore(DEBUG_PLUGIN, {
425
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-debug/src/DebugPlugin.tsx";
426
+ var DebugPlugin = definePlugin((context) => {
427
+ const settings = create({
426
428
  debug: true,
427
429
  devtools: true
428
430
  });
429
- let intentPlugin;
430
431
  return {
431
432
  meta: meta_default,
432
433
  ready: async (plugins) => {
433
- intentPlugin = resolvePlugin(plugins, parseIntentPlugin);
434
- settings.prop({
435
- key: "debug",
436
- type: LocalStorageStore.bool({
437
- allowUndefined: true
438
- })
439
- }).prop({
440
- key: "devtools",
441
- type: LocalStorageStore.bool({
442
- allowUndefined: true
443
- })
444
- }).prop({
445
- key: "wireframe",
446
- type: LocalStorageStore.bool({
447
- allowUndefined: true
448
- })
434
+ context.init(plugins);
435
+ context.resolvePlugin(parseSettingsPlugin).provides.settingsStore.createStore({
436
+ schema: DebugSettingsSchema,
437
+ prefix: DEBUG_PLUGIN,
438
+ value: settings
449
439
  });
450
440
  const composer = window.composer;
451
441
  composer.changeStorageVersionInMetadata = async (version) => {
@@ -460,10 +450,10 @@ var DebugPlugin = () => {
460
450
  };
461
451
  },
462
452
  unload: async () => {
463
- settings.close();
453
+ context.dispose();
464
454
  },
465
455
  provides: {
466
- settings: settings.values,
456
+ settings,
467
457
  translations: translations_default,
468
458
  context: ({ children }) => {
469
459
  const [timer, setTimer] = useState3();
@@ -486,12 +476,34 @@ var DebugPlugin = () => {
486
476
  },
487
477
  graph: {
488
478
  builder: (plugins) => {
479
+ const clientPlugin = resolvePlugin(plugins, parseClientPlugin);
480
+ const metadataPlugin = resolvePlugin(plugins, parseMetadataResolverPlugin);
489
481
  const graphPlugin = resolvePlugin(plugins, parseGraphPlugin2);
482
+ const resolve = metadataPlugin?.provides.metadata.resolver;
483
+ const client = clientPlugin?.provides.client;
484
+ invariant(resolve, void 0, {
485
+ F: __dxlog_file3,
486
+ L: 108,
487
+ S: void 0,
488
+ A: [
489
+ "resolve",
490
+ ""
491
+ ]
492
+ });
493
+ invariant(client, void 0, {
494
+ F: __dxlog_file3,
495
+ L: 109,
496
+ S: void 0,
497
+ A: [
498
+ "client",
499
+ ""
500
+ ]
501
+ });
490
502
  return [
491
503
  // Devtools node.
492
504
  createExtension({
493
505
  id: "dxos.org/plugin/debug/devtools",
494
- filter: (node) => !!settings.values.devtools && node.id === "root",
506
+ filter: (node) => !!settings.devtools && node.id === "root",
495
507
  connector: () => [
496
508
  {
497
509
  // TODO(zan): Removed `/` because it breaks deck layout reload. Fix?
@@ -513,7 +525,7 @@ var DebugPlugin = () => {
513
525
  // Debug node.
514
526
  createExtension({
515
527
  id: "dxos.org/plugin/debug/debug",
516
- filter: (node) => !!settings.values.debug && node.id === "root",
528
+ filter: (node) => !!settings.debug && node.id === "root",
517
529
  connector: () => [
518
530
  {
519
531
  id: "dxos.org/plugin/debug/debug",
@@ -536,7 +548,7 @@ var DebugPlugin = () => {
536
548
  // Space debug nodes.
537
549
  createExtension({
538
550
  id: "dxos.org/plugin/debug/spaces",
539
- filter: (node) => !!settings.values.debug && isSpace(node.data),
551
+ filter: (node) => !!settings.debug && isSpace(node.data),
540
552
  connector: ({ node }) => {
541
553
  const space = node.data;
542
554
  return [
@@ -558,6 +570,72 @@ var DebugPlugin = () => {
558
570
  }
559
571
  ];
560
572
  }
573
+ }),
574
+ // Create nodes for debug sidebar.
575
+ createExtension({
576
+ id: `${DEBUG_PLUGIN}/debug-for-subject`,
577
+ resolver: ({ id }) => {
578
+ if (!id.endsWith("~debug")) {
579
+ return;
580
+ }
581
+ const type = "orphan-settings-for-subject";
582
+ const icon = "ph--bug--regular";
583
+ const [subjectId] = id.split("~");
584
+ const { spaceId, objectId } = parseId(subjectId);
585
+ const space = client.spaces.get().find((space2) => space2.id === spaceId);
586
+ if (!objectId) {
587
+ const label2 = space ? space.properties.name || [
588
+ "unnamed space label",
589
+ {
590
+ ns: DEBUG_PLUGIN
591
+ }
592
+ ] : [
593
+ "unnamed object settings label",
594
+ {
595
+ ns: DEBUG_PLUGIN
596
+ }
597
+ ];
598
+ return {
599
+ id,
600
+ type,
601
+ data: null,
602
+ properties: {
603
+ icon,
604
+ label: label2,
605
+ showResolvedThreads: false,
606
+ object: null,
607
+ space
608
+ }
609
+ };
610
+ }
611
+ const object = toSignal((onChange) => {
612
+ const timeout = setTimeout(async () => {
613
+ await space?.db.loadObjectById(objectId);
614
+ onChange();
615
+ });
616
+ return () => clearTimeout(timeout);
617
+ }, () => space?.db.getObjectById(objectId), subjectId);
618
+ if (!object || !subjectId) {
619
+ return;
620
+ }
621
+ const meta = resolve(getTypename(object) ?? "");
622
+ const label = meta.label?.(object) || object.name || meta.placeholder || [
623
+ "unnamed object settings label",
624
+ {
625
+ ns: DEBUG_PLUGIN
626
+ }
627
+ ];
628
+ return {
629
+ id,
630
+ type,
631
+ data: null,
632
+ properties: {
633
+ icon,
634
+ label,
635
+ object
636
+ }
637
+ };
638
+ }
561
639
  })
562
640
  ];
563
641
  }
@@ -566,7 +644,7 @@ var DebugPlugin = () => {
566
644
  resolver: async (intent, plugins) => {
567
645
  switch (intent.action) {
568
646
  case DebugAction.OPEN_DEVTOOLS: {
569
- const clientPlugin = getPlugin(plugins, "dxos.org/plugin/client");
647
+ const clientPlugin = context.getPlugin("dxos.org/plugin/client");
570
648
  const client = clientPlugin.provides.client;
571
649
  const vaultUrl = client.config.values?.runtime?.client?.remoteSource ?? "https://halo.dxos.org";
572
650
  let devtoolsUrl = "http://localhost:5174";
@@ -589,7 +667,7 @@ var DebugPlugin = () => {
589
667
  switch (role) {
590
668
  case "settings":
591
669
  return data.plugin === meta_default.id ? /* @__PURE__ */ React5.createElement(DebugSettings, {
592
- settings: settings.values
670
+ settings
593
671
  }) : null;
594
672
  case "status":
595
673
  return /* @__PURE__ */ React5.createElement(DebugStatus, null);
@@ -601,9 +679,9 @@ var DebugPlugin = () => {
601
679
  const primary = data.active ?? data.object;
602
680
  let component;
603
681
  if (role === "main" || role === "article") {
604
- if (primary === "devtools" && settings.values.devtools) {
682
+ if (primary === "devtools" && settings.devtools) {
605
683
  component = /* @__PURE__ */ React5.createElement(Devtools, null);
606
- } else if (!primary || typeof primary !== "object" || !settings.values.debug) {
684
+ } else if (!primary || typeof primary !== "object" || !settings.debug) {
607
685
  component = null;
608
686
  } else if ("space" in primary && isSpace(primary.space)) {
609
687
  component = /* @__PURE__ */ React5.createElement(DebugSpace, {
@@ -616,7 +694,7 @@ var DebugPlugin = () => {
616
694
  if (!(collection instanceof CollectionType)) {
617
695
  return;
618
696
  }
619
- void intentPlugin?.provides.intent.dispatch(objects.map((object) => ({
697
+ void context.resolvePlugin(parseIntentPlugin).provides.intent.dispatch(objects.map((object) => ({
620
698
  action: SpaceAction.ADD_OBJECT,
621
699
  data: {
622
700
  target: collection,
@@ -634,18 +712,18 @@ var DebugPlugin = () => {
634
712
  }
635
713
  }
636
714
  if (!component) {
637
- if (settings.values.wireframe) {
715
+ if (settings.wireframe) {
638
716
  if (role === "main" || role === "article" || role === "section") {
639
717
  const primary2 = data.active ?? data.object;
640
718
  const isCollection = primary2 instanceof CollectionType;
641
719
  if (!isCollection) {
642
720
  return {
643
- disposition: "hoist",
644
721
  node: /* @__PURE__ */ React5.createElement(Wireframe, {
645
722
  label: `${role}:${name}`,
646
723
  object: primary2,
647
724
  classNames: "row-span-2 overflow-hidden"
648
- })
725
+ }),
726
+ disposition: "hoist"
649
727
  };
650
728
  }
651
729
  }
@@ -673,13 +751,12 @@ var DebugPlugin = () => {
673
751
  }
674
752
  }
675
753
  };
676
- };
754
+ });
677
755
 
678
756
  // packages/plugins/plugin-debug/src/index.ts
679
757
  var src_default = DebugPlugin;
680
758
  export {
681
759
  DebugPlugin,
682
- SETTINGS_KEY,
683
760
  src_default as default
684
761
  };
685
762
  //# sourceMappingURL=index.mjs.map