@dxos/plugin-debug 0.8.4-main.c1de068 → 0.8.4-main.e098934

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 (64) hide show
  1. package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs +20 -0
  2. package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs.map +7 -0
  3. package/dist/lib/browser/{SpaceGenerator-AG3XGNMV.mjs → SpaceGenerator-SRCIEELZ.mjs} +183 -65
  4. package/dist/lib/browser/SpaceGenerator-SRCIEELZ.mjs.map +7 -0
  5. package/dist/lib/browser/{app-graph-builder-SQXFD2BL.mjs → app-graph-builder-JTIEFOWZ.mjs} +22 -32
  6. package/dist/lib/browser/app-graph-builder-JTIEFOWZ.mjs.map +7 -0
  7. package/dist/lib/browser/index.mjs +7 -4
  8. package/dist/lib/browser/index.mjs.map +3 -3
  9. package/dist/lib/browser/meta.json +1 -1
  10. package/dist/lib/browser/{react-surface-3GD2OWCA.mjs → react-surface-HQPOGG33.mjs} +28 -23
  11. package/dist/lib/browser/react-surface-HQPOGG33.mjs.map +7 -0
  12. package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
  13. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  14. package/dist/types/src/capabilities/index.d.ts +5 -5
  15. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  16. package/dist/types/src/capabilities/react-context.d.ts +2 -2
  17. package/dist/types/src/capabilities/react-surface.d.ts +1 -1
  18. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  19. package/dist/types/src/capabilities/settings.d.ts +1 -1
  20. package/dist/types/src/components/DebugGraph.d.ts +8 -0
  21. package/dist/types/src/components/DebugGraph.d.ts.map +1 -0
  22. package/dist/types/src/components/DebugSettings.d.ts.map +1 -1
  23. package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
  24. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +1 -1
  25. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts +13 -3
  26. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts.map +1 -1
  27. package/dist/types/src/components/SpaceGenerator/draw-util.d.ts.map +1 -1
  28. package/dist/types/src/components/SpaceGenerator/presets.d.ts +4 -1
  29. package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -1
  30. package/dist/types/src/components/Wireframe.d.ts.map +1 -1
  31. package/dist/types/src/components/index.d.ts +2 -1
  32. package/dist/types/src/components/index.d.ts.map +1 -1
  33. package/dist/types/src/translations.d.ts +2 -0
  34. package/dist/types/src/translations.d.ts.map +1 -1
  35. package/dist/types/tsconfig.tsbuildinfo +1 -1
  36. package/package.json +58 -55
  37. package/src/DebugPlugin.tsx +1 -1
  38. package/src/capabilities/app-graph-builder.ts +13 -40
  39. package/src/capabilities/react-surface.tsx +7 -6
  40. package/src/components/DebugGraph.tsx +14 -0
  41. package/src/components/DebugObjectPanel.tsx +1 -1
  42. package/src/components/DebugSettings.tsx +72 -64
  43. package/src/components/SpaceGenerator/ObjectGenerator.tsx +12 -12
  44. package/src/components/SpaceGenerator/SpaceGenerator.stories.tsx +8 -6
  45. package/src/components/SpaceGenerator/SpaceGenerator.tsx +7 -7
  46. package/src/components/SpaceGenerator/draw-util.ts +3 -3
  47. package/src/components/SpaceGenerator/presets.ts +112 -11
  48. package/src/components/Wireframe.tsx +2 -1
  49. package/src/components/index.ts +1 -1
  50. package/src/translations.ts +2 -0
  51. package/dist/lib/browser/DebugApp-ZDL4CPY5.mjs +0 -228
  52. package/dist/lib/browser/DebugApp-ZDL4CPY5.mjs.map +0 -7
  53. package/dist/lib/browser/SpaceGenerator-AG3XGNMV.mjs.map +0 -7
  54. package/dist/lib/browser/app-graph-builder-SQXFD2BL.mjs.map +0 -7
  55. package/dist/lib/browser/react-surface-3GD2OWCA.mjs.map +0 -7
  56. package/dist/types/src/components/DebugApp/DebugApp.d.ts +0 -6
  57. package/dist/types/src/components/DebugApp/DebugApp.d.ts.map +0 -1
  58. package/dist/types/src/components/DebugApp/Tree.d.ts +0 -18
  59. package/dist/types/src/components/DebugApp/Tree.d.ts.map +0 -1
  60. package/dist/types/src/components/DebugApp/index.d.ts +0 -3
  61. package/dist/types/src/components/DebugApp/index.d.ts.map +0 -1
  62. package/src/components/DebugApp/DebugApp.tsx +0 -84
  63. package/src/components/DebugApp/Tree.tsx +0 -103
  64. package/src/components/DebugApp/index.ts +0 -7
@@ -3,17 +3,17 @@
3
3
  //
4
4
 
5
5
  // TODO(burdon): workerize-loader dep.
6
- import { Graph, type Edge, type PlainObject } from '@antv/graphlib';
6
+ import { type Edge, Graph, type PlainObject } from '@antv/graphlib';
7
7
  import {
8
- type Layout,
9
8
  D3ForceLayout,
10
9
  type D3ForceLayoutOptions,
11
10
  GridLayout,
12
11
  type GridLayoutOptions,
12
+ type Layout,
13
13
  RadialLayout,
14
14
  type RadialLayoutOptions,
15
15
  } from '@antv/layout';
16
- import { createBindingId, createShapeId, type Editor, type SerializedStore, type TLRecord } from '@tldraw/tldraw';
16
+ import { type Editor, type SerializedStore, type TLRecord, createBindingId, createShapeId } from '@tldraw/tldraw';
17
17
 
18
18
  import { faker } from '@dxos/random';
19
19
  import { isNotFalsy, range } from '@dxos/util';
@@ -4,10 +4,13 @@
4
4
 
5
5
  import { Schema } from 'effect';
6
6
 
7
+ import { ResearchOn, research } from '@dxos/assistant-testing';
7
8
  import { type ComputeGraphModel, NODE_INPUT } from '@dxos/conductor';
8
- import { DXN, Key, Obj, Ref, Type } from '@dxos/echo';
9
- import { FunctionTrigger, TriggerKind, type TriggerType } from '@dxos/functions';
9
+ import { DXN, Filter, Key, Obj, Query, Ref, Relation, Type } from '@dxos/echo';
10
+ import { FunctionTrigger, type TriggerKind, type TriggerType, serializeFunction } from '@dxos/functions';
10
11
  import { invariant } from '@dxos/invariant';
12
+ import { Mailbox } from '@dxos/plugin-inbox/types';
13
+ import { Markdown } from '@dxos/plugin-markdown/types';
11
14
  import { type Space } from '@dxos/react-client/echo';
12
15
  import {
13
16
  type ComputeShape,
@@ -18,8 +21,8 @@ import {
18
21
  createFunction,
19
22
  createGpt,
20
23
  createQueue,
21
- createSurface,
22
24
  createRandom,
25
+ createSurface,
23
26
  createTemplate,
24
27
  createText,
25
28
  createTrigger,
@@ -31,11 +34,14 @@ import {
31
34
  pointsToRect,
32
35
  rectToPoints,
33
36
  } from '@dxos/react-ui-canvas-editor';
37
+ import { DataType, createView } from '@dxos/schema';
34
38
  import { range } from '@dxos/util';
35
39
 
36
40
  import { type ObjectGenerator } from './ObjectGenerator';
37
41
 
38
42
  export enum PresetName {
43
+ DXOS_TEAM = 'dxos-team',
44
+ ORG_RESEARCH_PROJECT = 'org-research-project',
39
45
  // EMAIL_TABLE = 'email-table',
40
46
  GPT_QUEUE = 'webhook-gpt-queue',
41
47
  CHAT_GPT = 'chat-gpt-text',
@@ -51,6 +57,101 @@ export const generator = () => ({
51
57
  schemas: [CanvasBoardType, FunctionTrigger],
52
58
  types: Object.values(PresetName).map((name) => ({ typename: name })),
53
59
  items: [
60
+ [
61
+ PresetName.DXOS_TEAM,
62
+ async (space, n, cb) => {
63
+ const objects = range(n, () => {
64
+ const org = space.db.add(Obj.make(DataType.Organization, { name: 'DXOS', website: 'https://dxos.org' }));
65
+
66
+ const doc = space.db.add(
67
+ Markdown.makeDocument({
68
+ name: 'DXOS Research',
69
+ content: 'DXOS builds Composer, an open-source AI-powered malleable application.',
70
+ }),
71
+ );
72
+ space.db.add(
73
+ Relation.make(ResearchOn, {
74
+ [Relation.Source]: doc,
75
+ [Relation.Target]: org,
76
+ completedAt: new Date().toISOString(),
77
+ }),
78
+ );
79
+
80
+ space.db.add(
81
+ Obj.make(DataType.Person, { fullName: 'Rich', jobTitle: 'investor', organization: Ref.make(org) }),
82
+ );
83
+ space.db.add(Obj.make(DataType.Person, { fullName: 'Josiah', organization: Ref.make(org) }));
84
+ space.db.add(Obj.make(DataType.Person, { fullName: 'Dima', organization: Ref.make(org) }));
85
+ space.db.add(Obj.make(DataType.Person, { fullName: 'Mykola', organization: Ref.make(org) }));
86
+ space.db.add(Obj.make(DataType.Person, { fullName: 'Will', organization: Ref.make(org) }));
87
+
88
+ return doc;
89
+ });
90
+ cb?.(objects);
91
+ return objects;
92
+ },
93
+ ],
94
+ [
95
+ PresetName.ORG_RESEARCH_PROJECT,
96
+ async (space, n, cb) => {
97
+ const mailbox = await space.db.query(Filter.type(Mailbox.Mailbox)).first();
98
+
99
+ const objects = range(n, () => {
100
+ // TODO(wittjosiah): Move filter to another property.
101
+ const contactsQuery = Query.select(Filter.type(DataType.Person, { jobTitle: 'investor' }));
102
+ const organizationsQuery = contactsQuery.reference('organization');
103
+ const notesQuery = organizationsQuery.targetOf(ResearchOn).source();
104
+
105
+ const researchTrigger = Obj.make(FunctionTrigger, {
106
+ function: Ref.make(serializeFunction(research)),
107
+ spec: {
108
+ kind: 'subscription',
109
+ query: organizationsQuery.ast,
110
+ },
111
+ enabled: true,
112
+ });
113
+ space.db.add(researchTrigger);
114
+
115
+ const mailboxView = createView({
116
+ name: 'Mailbox',
117
+ query: Query.select(
118
+ Filter.type(DataType.Message, { properties: { labels: Filter.contains('investor') } }),
119
+ ).options({
120
+ queues: [mailbox.queue.dxn.toString()],
121
+ }),
122
+ jsonSchema: Type.toJsonSchema(DataType.Message),
123
+ presentation: Obj.make(DataType.Collection, { objects: [] }),
124
+ });
125
+ const contactsView = createView({
126
+ name: 'Contacts',
127
+ query: contactsQuery,
128
+ jsonSchema: Type.toJsonSchema(DataType.Person),
129
+ presentation: Obj.make(DataType.Collection, { objects: [] }),
130
+ });
131
+ const organizationsView = createView({
132
+ name: 'Organizations',
133
+ query: organizationsQuery,
134
+ jsonSchema: Type.toJsonSchema(DataType.Organization),
135
+ presentation: Obj.make(DataType.Collection, { objects: [] }),
136
+ });
137
+ const notesView = createView({
138
+ name: 'Notes',
139
+ query: notesQuery,
140
+ jsonSchema: Type.toJsonSchema(Markdown.Document),
141
+ presentation: Obj.make(DataType.Collection, { objects: [] }),
142
+ });
143
+
144
+ return space.db.add(
145
+ DataType.makeProject({
146
+ name: 'Investor Research',
147
+ collections: [mailboxView, contactsView, organizationsView, notesView].map((view) => Ref.make(view)),
148
+ }),
149
+ );
150
+ });
151
+ cb?.(objects.flat());
152
+ return objects.flat();
153
+ },
154
+ ],
54
155
  [
55
156
  PresetName.GPT_QUEUE,
56
157
  async (space, n, cb) => {
@@ -62,7 +163,7 @@ export const generator = () => ({
62
163
  const gpt = canvasModel.createNode(createGpt(position({ x: 0, y: -14 })));
63
164
  const triggerShape = createTrigger({
64
165
  spaceId: space.id,
65
- triggerKind: TriggerKind.Webhook,
166
+ triggerKind: 'webhook',
66
167
  ...position({ x: -18, y: -2 }),
67
168
  });
68
169
  const trigger = canvasModel.createNode(triggerShape);
@@ -96,8 +197,8 @@ export const generator = () => ({
96
197
  const objects = range(n, () => {
97
198
  const { canvasModel, computeModel } = createQueueSinkPreset(
98
199
  space,
99
- TriggerKind.Subscription,
100
- (triggerSpec) => (triggerSpec.filter = { type: 'dxn:type:dxos.org/type/Chess' }),
200
+ 'subscription',
201
+ (triggerSpec) => (triggerSpec.query = Query.select(Filter.typename('dxos.org/type/Chess')).ast),
101
202
  'type',
102
203
  );
103
204
  return addToSpace(PresetName.OBJECT_CHANGE_QUEUE, space, canvasModel, computeModel);
@@ -113,7 +214,7 @@ export const generator = () => ({
113
214
  const objects = range(n, () => {
114
215
  const { canvasModel, computeModel } = createQueueSinkPreset(
115
216
  space,
116
- TriggerKind.Timer,
217
+ 'timer',
117
218
  (triggerSpec) => (triggerSpec.cron = '*/5 * * * * *'),
118
219
  'result',
119
220
  );
@@ -147,7 +248,7 @@ export const generator = () => ({
147
248
  // canvasModel.builder.call((builder) => {
148
249
  // const triggerShape = createTrigger({
149
250
  // spaceId: space.id,
150
- // triggerKind: TriggerKind.Email,
251
+ // triggerKind: 'email',
151
252
  // ...position({ x: -18, y: -2 }),
152
253
  // });
153
254
  // const trigger = canvasModel.createNode(triggerShape);
@@ -254,7 +355,7 @@ export const generator = () => ({
254
355
  // );
255
356
  // const triggerShape = createTrigger({
256
357
  // spaceId: space.id,
257
- // triggerKind: TriggerKind.Email,
358
+ // triggerKind: 'email',
258
359
  // ...rawPosition({ centerX: -736, centerY: -384, width: 182, height: 192 }),
259
360
  // });
260
361
  // const trigger = canvasModel.createNode(triggerShape);
@@ -358,7 +459,7 @@ export const generator = () => ({
358
459
  canvasModel.builder.call((builder) => {
359
460
  const triggerShape = createTrigger({
360
461
  spaceId: space.id,
361
- triggerKind: TriggerKind.Timer,
462
+ triggerKind: 'timer',
362
463
  ...position({ x: -10, y: -5 }),
363
464
  });
364
465
  const trigger = canvasModel.createNode(triggerShape);
@@ -416,7 +517,7 @@ export const generator = () => ({
416
517
  // canvasModel.builder.call((builder) => {
417
518
  // const triggerShape = createTrigger({
418
519
  // spaceId: space.id,
419
- // triggerKind: TriggerKind.Queue,
520
+ // triggerKind: 'queue',
420
521
  // ...position({ x: -10, y: -5 }),
421
522
  // });
422
523
  // const trigger = canvasModel.createNode(triggerShape);
@@ -22,6 +22,7 @@ export type WireframeProps = ThemedClassName<{
22
22
  export const Wireframe = ({ classNames, label, object }: WireframeProps) => {
23
23
  const attentionAttrs = useAttentionAttributes(fullyQualifiedId(object));
24
24
  const { width, height, ref } = useResizeDetector();
25
+
25
26
  return (
26
27
  <div ref={ref} className={mx('relative grow min-bs-96', classNames)} {...attentionAttrs}>
27
28
  <div className='absolute inset-2 flex flex-col gap-2 overflow-hidden font-mono'>
@@ -30,7 +31,7 @@ export const Wireframe = ({ classNames, label, object }: WireframeProps) => {
30
31
  <div>{`[${width}x${height}]`}</div>
31
32
  </div>
32
33
  {object && (
33
- <SyntaxHighlighter language='json' classNames='flex w-full text-xs opacity-75 rounded'>
34
+ <SyntaxHighlighter language='json' classNames='text-xs opacity-75 rounded'>
34
35
  {JSON.stringify(object, undefined, 2)}
35
36
  </SyntaxHighlighter>
36
37
  )}
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { lazy } from 'react';
6
6
 
7
- export const DebugApp = lazy(() => import('./DebugApp'));
7
+ export const DebugGraph = lazy(() => import('./DebugGraph'));
8
8
  export const DevtoolsOverviewContainer = lazy(() => import('./DevtoolsOverviewContainer'));
9
9
  export const SpaceGenerator = lazy(() => import('./SpaceGenerator'));
10
10
 
@@ -11,12 +11,14 @@ export const translations = [
11
11
  'en-US': {
12
12
  [meta.id]: {
13
13
  'plugin name': 'Debug',
14
+ 'settings title': 'Debug settings',
14
15
  'mutation count': 'Number of mutations',
15
16
  'mutation period': 'Mutation period',
16
17
  'open devtools label': 'Open DevTools',
17
18
  'devtools label': 'DevTools',
18
19
  'devtools overview label': 'DevTools Stats',
19
20
  'debug label': 'Debug',
21
+ 'debug app graph label': 'App Graph',
20
22
  'settings show debug panel': 'Show Debug panel.',
21
23
  'settings show devtools panel': 'Show DevTools panel.',
22
24
  'settings wireframe': 'Show wireframes.',
@@ -1,228 +0,0 @@
1
- // src/components/DebugApp/DebugApp.tsx
2
- import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
3
- import React3, { useEffect, useState as useState2 } from "react";
4
- import { useClient, useConfig } from "@dxos/react-client";
5
- import { ToggleGroup, ToggleGroupItem, Toolbar, Icon, IconButton } from "@dxos/react-ui";
6
-
7
- // src/components/DebugApp/Tree.tsx
8
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
9
- import React, { useState } from "react";
10
- import { SyntaxHighlighter } from "@dxos/react-ui-syntax-highlighter";
11
- import { mx } from "@dxos/react-ui-theme";
12
- import { arrayToBuffer } from "@dxos/util";
13
- var replacer = (key, value) => {
14
- if (typeof value === "object") {
15
- if (value instanceof Uint8Array) {
16
- return arrayToBuffer(value).toString("hex");
17
- }
18
- if (value?.type === "Buffer") {
19
- return Buffer.from(value.data).toString("hex");
20
- }
21
- if (key === "downloaded") {
22
- return void 0;
23
- }
24
- }
25
- return value;
26
- };
27
- var Json = ({ data }) => {
28
- var _effect = _useSignals();
29
- try {
30
- return /* @__PURE__ */ React.createElement(SyntaxHighlighter, {
31
- language: "json"
32
- }, JSON.stringify(data, replacer, 2));
33
- } finally {
34
- _effect.f();
35
- }
36
- };
37
- var Tree = ({ data }) => {
38
- var _effect = _useSignals();
39
- try {
40
- return /* @__PURE__ */ React.createElement("div", {
41
- className: "p-2"
42
- }, /* @__PURE__ */ React.createElement(Node, {
43
- data,
44
- root: true
45
- }));
46
- } finally {
47
- _effect.f();
48
- }
49
- };
50
- var Node = ({ data, root }) => {
51
- var _effect = _useSignals();
52
- try {
53
- if (typeof data !== "object" || data === void 0 || data === null) {
54
- return /* @__PURE__ */ React.createElement(Scalar, {
55
- value: data
56
- });
57
- }
58
- if (Array.isArray(data)) {
59
- return /* @__PURE__ */ React.createElement("div", {
60
- className: "flex flex-col space-y-2"
61
- }, data.map((value, index) => /* @__PURE__ */ React.createElement(KeyValue, {
62
- key: index,
63
- label: String(index),
64
- data: value,
65
- className: "bg-teal-50"
66
- })));
67
- }
68
- return /* @__PURE__ */ React.createElement("div", {
69
- className: "flex flex-col space-y-2"
70
- }, Object.entries(data).map(([key, value]) => /* @__PURE__ */ React.createElement(KeyValue, {
71
- key,
72
- label: key,
73
- data: value,
74
- className: "bg-blue-50"
75
- })));
76
- } finally {
77
- _effect.f();
78
- }
79
- };
80
- var KeyValue = ({ label, data, className }) => {
81
- var _effect = _useSignals();
82
- try {
83
- const [open, setOpen] = useState(true);
84
- if (data === void 0) {
85
- return null;
86
- }
87
- return /* @__PURE__ */ React.createElement("div", {
88
- className: "flex"
89
- }, /* @__PURE__ */ React.createElement(Box, {
90
- className: mx("border-blue-200 text-sm select-none cursor-pointer", className),
91
- onClick: () => setOpen((open2) => !open2)
92
- }, label), open && /* @__PURE__ */ React.createElement(Node, {
93
- data
94
- }));
95
- } finally {
96
- _effect.f();
97
- }
98
- };
99
- var Scalar = ({ value }) => {
100
- var _effect = _useSignals();
101
- try {
102
- return /* @__PURE__ */ React.createElement(Box, {
103
- className: "bg-green-50 border-green-200 rounded-r text-sm font-thin"
104
- }, value === void 0 && "undefined" || value === null && "null" || typeof value === "string" && value || JSON.stringify(value));
105
- } finally {
106
- _effect.f();
107
- }
108
- };
109
- var Box = ({ children, className, ...props }) => {
110
- var _effect = _useSignals();
111
- try {
112
- return /* @__PURE__ */ React.createElement("div", {
113
- className: mx("flex px-2 border border-l-0 font-mono truncate", className),
114
- ...props
115
- }, children);
116
- } finally {
117
- _effect.f();
118
- }
119
- };
120
-
121
- // src/components/Container.tsx
122
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
123
- import React2 from "react";
124
- var Container = ({ toolbar, children }) => {
125
- var _effect = _useSignals2();
126
- try {
127
- return /* @__PURE__ */ React2.createElement("div", {
128
- role: "none",
129
- className: "flex flex-col grow overflow-hidden divide-y divide-separator"
130
- }, toolbar, /* @__PURE__ */ React2.createElement("div", {
131
- className: "flex flex-col grow overflow-auto"
132
- }, children));
133
- } finally {
134
- _effect.f();
135
- }
136
- };
137
-
138
- // src/components/DebugApp/DebugApp.tsx
139
- var DebugApp = ({ graph }) => {
140
- var _effect = _useSignals3();
141
- try {
142
- const [view, setView] = useState2("graph");
143
- const [data, setData] = useState2({});
144
- const client = useClient();
145
- const config = useConfig();
146
- const handleRefresh = async () => {
147
- const data2 = await client.diagnostics({
148
- truncate: true
149
- });
150
- setData(data2);
151
- };
152
- useEffect(() => {
153
- void handleRefresh();
154
- }, []);
155
- const handleResetClient = async (force = false) => {
156
- if (!force && !window.confirm("Reset storage?")) {
157
- return;
158
- }
159
- await client.reset();
160
- window.location.href = window.location.origin;
161
- };
162
- const handleOpenDevtools = () => {
163
- const vaultUrl = config.values?.runtime?.client?.remoteSource;
164
- if (vaultUrl) {
165
- window.open(`https://devtools.dev.dxos.org/?target=${vaultUrl}`);
166
- }
167
- };
168
- return /* @__PURE__ */ React3.createElement(Container, {
169
- toolbar: /* @__PURE__ */ React3.createElement(Toolbar.Root, {
170
- classNames: "p-1"
171
- }, /* @__PURE__ */ React3.createElement(ToggleGroup, {
172
- type: "single",
173
- value: view
174
- }, /* @__PURE__ */ React3.createElement(ToggleGroupItem, {
175
- value: "graph",
176
- onClick: () => setView("graph"),
177
- title: "Plugin graph"
178
- }, /* @__PURE__ */ React3.createElement(Icon, {
179
- icon: "ph--graph--regular",
180
- size: 5
181
- })), /* @__PURE__ */ React3.createElement(ToggleGroupItem, {
182
- value: "diagnostics",
183
- onClick: () => setView("diagnostics"),
184
- title: "Diagnostics"
185
- }, /* @__PURE__ */ React3.createElement(Icon, {
186
- icon: "ph--gauge--regular",
187
- size: 5
188
- })), /* @__PURE__ */ React3.createElement(ToggleGroupItem, {
189
- value: "config",
190
- onClick: () => setView("config"),
191
- title: "Config"
192
- }, /* @__PURE__ */ React3.createElement(Icon, {
193
- icon: "ph--gear--regular",
194
- size: 5
195
- }))), /* @__PURE__ */ React3.createElement(Toolbar.Separator, {
196
- variant: "gap"
197
- }), /* @__PURE__ */ React3.createElement(IconButton, {
198
- icon: "ph--warning--regular",
199
- iconOnly: true,
200
- size: 5,
201
- classNames: "text-red-700",
202
- onClick: (event) => handleResetClient(event.shiftKey),
203
- label: "Reset client"
204
- }), /* @__PURE__ */ React3.createElement(IconButton, {
205
- icon: "ph--toolbox--duotone",
206
- iconOnly: true,
207
- size: 5,
208
- onClick: handleOpenDevtools,
209
- label: "Open Devtools"
210
- }))
211
- }, view === "graph" && /* @__PURE__ */ React3.createElement(Tree, {
212
- data: graph.toJSON()
213
- }), view === "config" && /* @__PURE__ */ React3.createElement(Json, {
214
- data: data.diagnostics?.config
215
- }), view === "diagnostics" && /* @__PURE__ */ React3.createElement(Json, {
216
- data
217
- }));
218
- } finally {
219
- _effect.f();
220
- }
221
- };
222
-
223
- // src/components/DebugApp/index.ts
224
- var DebugApp_default = DebugApp;
225
- export {
226
- DebugApp_default as default
227
- };
228
- //# sourceMappingURL=DebugApp-ZDL4CPY5.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/DebugApp/DebugApp.tsx", "../../../src/components/DebugApp/Tree.tsx", "../../../src/components/Container.tsx", "../../../src/components/DebugApp/index.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { type FC, useEffect, useState } from 'react';\n\nimport { type Graph } from '@dxos/plugin-graph';\nimport { useClient, useConfig } from '@dxos/react-client';\nimport { ToggleGroup, ToggleGroupItem, Toolbar, Icon, IconButton } from '@dxos/react-ui';\n\nimport { Json, Tree } from './Tree';\nimport { Container } from '../Container';\n\nexport const DebugApp: FC<{ graph: Graph }> = ({ graph }) => {\n const [view, setView] = useState<'config' | 'diagnostics' | 'graph'>('graph');\n const [data, setData] = useState<any>({});\n const client = useClient();\n const config = useConfig();\n const handleRefresh = async () => {\n const data = await client.diagnostics({ truncate: true });\n setData(data);\n };\n useEffect(() => {\n void handleRefresh();\n }, []);\n\n const handleResetClient = async (force = false) => {\n if (!force && !window.confirm('Reset storage?')) {\n return;\n }\n\n // TODO(burdon): Throws exception.\n await client.reset();\n window.location.href = window.location.origin;\n };\n\n const handleOpenDevtools = () => {\n const vaultUrl = config.values?.runtime?.client?.remoteSource;\n if (vaultUrl) {\n window.open(`https://devtools.dev.dxos.org/?target=${vaultUrl}`);\n }\n };\n\n return (\n <Container\n toolbar={\n <Toolbar.Root classNames='p-1'>\n <ToggleGroup type='single' value={view}>\n <ToggleGroupItem value={'graph'} onClick={() => setView('graph')} title={'Plugin graph'}>\n <Icon icon='ph--graph--regular' size={5} />\n </ToggleGroupItem>\n <ToggleGroupItem value={'diagnostics'} onClick={() => setView('diagnostics')} title={'Diagnostics'}>\n <Icon icon='ph--gauge--regular' size={5} />\n </ToggleGroupItem>\n <ToggleGroupItem value={'config'} onClick={() => setView('config')} title={'Config'}>\n <Icon icon='ph--gear--regular' size={5} />\n </ToggleGroupItem>\n </ToggleGroup>\n\n <Toolbar.Separator variant='gap' />\n <IconButton\n icon='ph--warning--regular'\n iconOnly\n size={5}\n classNames='text-red-700'\n onClick={(event) => handleResetClient(event.shiftKey)}\n label='Reset client'\n />\n <IconButton\n icon='ph--toolbox--duotone'\n iconOnly\n size={5}\n onClick={handleOpenDevtools}\n label='Open Devtools'\n />\n </Toolbar.Root>\n }\n >\n {view === 'graph' && <Tree data={graph.toJSON()} />}\n {view === 'config' && <Json data={data.diagnostics?.config} />}\n {view === 'diagnostics' && <Json data={data} />}\n </Container>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { type FC, type HTMLAttributes, useState } from 'react';\n\nimport { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';\nimport { mx } from '@dxos/react-ui-theme';\nimport { arrayToBuffer } from '@dxos/util';\n\n// TODO(burdon): Copied form devtools.\n\nexport const replacer = (key: any, value: any) => {\n if (typeof value === 'object') {\n if (value instanceof Uint8Array) {\n return arrayToBuffer(value).toString('hex');\n }\n\n if (value?.type === 'Buffer') {\n return Buffer.from(value.data).toString('hex');\n }\n\n if (key === 'downloaded') {\n return undefined;\n }\n }\n\n return value;\n};\n\nexport const Json: FC<{ data?: object }> = ({ data }) => {\n return <SyntaxHighlighter language='json'>{JSON.stringify(data, replacer, 2)}</SyntaxHighlighter>;\n};\n\nexport const Tree: FC<{ data?: object }> = ({ data }) => {\n return (\n <div className='p-2'>\n <Node data={data} root />\n </div>\n );\n};\n\nexport const Node: FC<{ data?: any; root?: boolean }> = ({ data, root }) => {\n if (typeof data !== 'object' || data === undefined || data === null) {\n return <Scalar value={data} />;\n }\n\n if (Array.isArray(data)) {\n return (\n <div className='flex flex-col space-y-2'>\n {data.map((value, index) => (\n <KeyValue key={index} label={String(index)} data={value} className='bg-teal-50' />\n ))}\n </div>\n );\n }\n\n return (\n <div className='flex flex-col space-y-2'>\n {Object.entries(data).map(([key, value]) => (\n <KeyValue key={key} label={key} data={value} className='bg-blue-50' />\n ))}\n </div>\n );\n};\n\nexport const KeyValue: FC<{ label: string; data?: any; className?: string }> = ({ label, data, className }) => {\n const [open, setOpen] = useState(true);\n if (data === undefined) {\n return null;\n }\n\n return (\n <div className='flex'>\n <Box\n className={mx('border-blue-200 text-sm select-none cursor-pointer', className)}\n onClick={() => setOpen((open) => !open)}\n >\n {label}\n </Box>\n {open && <Node data={data} />}\n </div>\n );\n};\n\nconst Scalar: FC<{ value: any }> = ({ value }) => {\n return (\n <Box className='bg-green-50 border-green-200 rounded-r text-sm font-thin'>\n {(value === undefined && 'undefined') ||\n (value === null && 'null') ||\n (typeof value === 'string' && value) ||\n JSON.stringify(value)}\n </Box>\n );\n};\n\nconst Box: FC<HTMLAttributes<HTMLDivElement>> = ({ children, className, ...props }) => {\n return (\n <div className={mx('flex px-2 border border-l-0 font-mono truncate', className)} {...props}>\n {children}\n </div>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { type PropsWithChildren, type ReactNode } from 'react';\n\n// TODO(burdon): Convert to grid.\nexport const Container = ({ toolbar, children }: PropsWithChildren<{ toolbar: ReactNode }>) => {\n return (\n <div role='none' className='flex flex-col grow overflow-hidden divide-y divide-separator'>\n {toolbar}\n <div className='flex flex-col grow overflow-auto'>{children}</div>\n </div>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { DebugApp } from './DebugApp';\n\nexport default DebugApp;\n"],
5
- "mappings": ";;AAIA,OAAOA,UAAkBC,WAAWC,YAAAA,iBAAgB;AAGpD,SAASC,WAAWC,iBAAiB;AACrC,SAASC,aAAaC,iBAAiBC,SAASC,MAAMC,kBAAkB;;;;ACJxE,OAAOC,SAAuCC,gBAAgB;AAE9D,SAASC,yBAAyB;AAClC,SAASC,UAAU;AACnB,SAASC,qBAAqB;AAIvB,IAAMC,WAAW,CAACC,KAAUC,UAAAA;AACjC,MAAI,OAAOA,UAAU,UAAU;AAC7B,QAAIA,iBAAiBC,YAAY;AAC/B,aAAOC,cAAcF,KAAAA,EAAOG,SAAS,KAAA;IACvC;AAEA,QAAIH,OAAOI,SAAS,UAAU;AA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J,MAAK;QACLK,UAAAA;QACAJ,MAAM;QACNJ,SAAShB;QACT2B,OAAM;;OAKXhD,SAAS,WAAW,gBAAA2B,OAAA,cAACsB,MAAAA;MAAK9C,MAAMJ,MAAMmD,OAAM;QAC5ClD,SAAS,YAAY,gBAAA2B,OAAA,cAACwB,MAAAA;MAAKhD,MAAMA,KAAKO,aAAaH;QACnDP,SAAS,iBAAiB,gBAAA2B,OAAA,cAACwB,MAAAA;MAAKhD;;;;;AAGvC;;;AG7EA,IAAA,mBAAeiD;",
6
- "names": ["React", "useEffect", "useState", "useClient", "useConfig", "ToggleGroup", "ToggleGroupItem", "Toolbar", "Icon", "IconButton", "React", "useState", "SyntaxHighlighter", "mx", "arrayToBuffer", "replacer", "key", "value", "Uint8Array", "arrayToBuffer", "toString", "type", "Buffer", "from", "data", "undefined", "Json", "SyntaxHighlighter", "language", "JSON", "stringify", "Tree", "div", "className", "Node", "root", "Scalar", "Array", "isArray", "map", "index", "KeyValue", "label", "String", "Object", "entries", "open", "setOpen", "useState", "Box", "mx", "onClick", "children", "props", "React", "Container", "toolbar", "children", "React", "div", "role", "className", "DebugApp", "graph", "view", "setView", "useState", "data", "setData", "client", "useClient", "config", "useConfig", "handleRefresh", "diagnostics", "truncate", "useEffect", "handleResetClient", "force", "window", "confirm", "reset", "location", "href", "origin", "handleOpenDevtools", "vaultUrl", "values", "runtime", "remoteSource", "open", "React", "Container", "toolbar", "Toolbar", "Root", "classNames", "ToggleGroup", "type", "value", "ToggleGroupItem", "onClick", "title", "Icon", "icon", "size", "Separator", "variant", "IconButton", "iconOnly", "event", "shiftKey", "label", "Tree", "toJSON", "Json", "DebugApp"]
7
- }