@dxos/plugin-debug 0.7.4 → 0.7.5-labs.401163d
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.
- package/dist/lib/browser/{DebugApp-HCHR6GKO.mjs → DebugApp-LQHFFK3Y.mjs} +4 -2
- package/dist/lib/browser/{DebugApp-HCHR6GKO.mjs.map → DebugApp-LQHFFK3Y.mjs.map} +3 -3
- package/dist/lib/browser/{DebugSpace-DHKEAMIC.mjs → DebugSpace-4JHYA7FG.mjs} +7 -6
- package/dist/lib/browser/DebugSpace-4JHYA7FG.mjs.map +7 -0
- package/dist/lib/browser/SpaceGenerator-KYSK77VG.mjs +1100 -0
- package/dist/lib/browser/SpaceGenerator-KYSK77VG.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-DCMGZAT3.mjs +181 -0
- package/dist/lib/browser/app-graph-builder-DCMGZAT3.mjs.map +7 -0
- package/dist/lib/browser/chunk-EF3UVAVI.mjs +21 -0
- package/dist/lib/browser/chunk-EF3UVAVI.mjs.map +7 -0
- package/dist/lib/browser/{chunk-LZEK532R.mjs → chunk-P7GHHMDB.mjs} +1 -11
- package/dist/lib/browser/chunk-P7GHHMDB.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +60 -737
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-6GVTLM4O.mjs +484 -0
- package/dist/lib/browser/react-surface-6GVTLM4O.mjs.map +7 -0
- package/dist/lib/browser/settings-OIMSBZUC.mjs +25 -0
- package/dist/lib/browser/settings-OIMSBZUC.mjs.map +7 -0
- package/dist/types/src/DebugPlugin.d.ts +1 -2
- package/dist/types/src/DebugPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +181 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +180 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +4 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings.d.ts +4 -0
- package/dist/types/src/capabilities/settings.d.ts.map +1 -0
- package/dist/types/src/components/DebugObjectPanel.d.ts.map +1 -1
- package/dist/types/src/components/DebugSettings.d.ts.map +1 -1
- package/dist/types/src/components/DebugSpace/DebugSpace.stories.d.ts.map +1 -1
- package/dist/types/src/components/DebugSpace/ObjectCreator.stories.d.ts.map +1 -1
- package/dist/types/src/components/DebugStatus.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts +2 -2
- package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/draw-util.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/presets.d.ts +21 -0
- package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -0
- package/dist/types/src/components/Wireframe.d.ts +2 -1
- package/dist/types/src/components/Wireframe.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +0 -6
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +49 -51
- package/src/DebugPlugin.tsx +55 -381
- package/src/capabilities/app-graph-builder.ts +175 -0
- package/src/capabilities/index.ts +9 -0
- package/src/capabilities/react-surface.tsx +130 -0
- package/src/capabilities/settings.ts +18 -0
- package/src/components/DebugApp/DebugApp.tsx +1 -1
- package/src/components/DebugObjectPanel.tsx +17 -5
- package/src/components/DebugSettings.tsx +11 -13
- package/src/components/DebugSpace/DebugSpace.stories.tsx +4 -3
- package/src/components/DebugSpace/DebugSpace.tsx +1 -1
- package/src/components/DebugSpace/ObjectCreator.stories.tsx +4 -3
- package/src/components/DebugStatus.tsx +17 -27
- package/src/components/SpaceGenerator/ObjectGenerator.tsx +45 -18
- package/src/components/SpaceGenerator/SpaceGenerator.tsx +11 -8
- package/src/components/SpaceGenerator/draw-util.ts +7 -6
- package/src/components/SpaceGenerator/presets.ts +493 -0
- package/src/components/Wireframe.tsx +2 -2
- package/src/index.ts +1 -4
- package/src/meta.ts +4 -2
- package/src/types.ts +0 -22
- package/dist/lib/browser/DebugSpace-DHKEAMIC.mjs.map +0 -7
- package/dist/lib/browser/SpaceGenerator-BQ3645OS.mjs +0 -273
- package/dist/lib/browser/SpaceGenerator-BQ3645OS.mjs.map +0 -7
- package/dist/lib/browser/chunk-CAENAAHY.mjs +0 -18
- package/dist/lib/browser/chunk-CAENAAHY.mjs.map +0 -7
- package/dist/lib/browser/chunk-LZEK532R.mjs.map +0 -7
- package/dist/lib/browser/meta.mjs +0 -9
- package/dist/lib/browser/meta.mjs.map +0 -7
- package/dist/types/src/components/DebugSurface.d.ts +0 -9
- package/dist/types/src/components/DebugSurface.d.ts.map +0 -1
- package/src/components/DebugSurface.tsx +0 -55
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type ComputeGraphModel, EmailTriggerOutput, NODE_INPUT } from '@dxos/conductor';
|
|
6
|
+
import { AST, ObjectId, S, toJsonSchema } from '@dxos/echo-schema';
|
|
7
|
+
import { FunctionTrigger, TriggerKind, type TriggerType } from '@dxos/functions/types';
|
|
8
|
+
import { invariant } from '@dxos/invariant';
|
|
9
|
+
import { DXN, SpaceId } from '@dxos/keys';
|
|
10
|
+
import { create, makeRef } from '@dxos/live-object';
|
|
11
|
+
import { Filter, type Space } from '@dxos/react-client/echo';
|
|
12
|
+
import {
|
|
13
|
+
type ComputeShape,
|
|
14
|
+
createAppend,
|
|
15
|
+
createChat,
|
|
16
|
+
createComputeGraph,
|
|
17
|
+
createConstant,
|
|
18
|
+
createFunction,
|
|
19
|
+
createGpt,
|
|
20
|
+
createQueue,
|
|
21
|
+
createSurface,
|
|
22
|
+
createRandom,
|
|
23
|
+
createTemplate,
|
|
24
|
+
createText,
|
|
25
|
+
createTrigger,
|
|
26
|
+
} from '@dxos/react-ui-canvas-compute';
|
|
27
|
+
import {
|
|
28
|
+
CanvasBoardType,
|
|
29
|
+
CanvasGraphModel,
|
|
30
|
+
pointMultiply,
|
|
31
|
+
pointsToRect,
|
|
32
|
+
rectToPoints,
|
|
33
|
+
} from '@dxos/react-ui-canvas-editor';
|
|
34
|
+
import { TableType } from '@dxos/react-ui-table';
|
|
35
|
+
import { range } from '@dxos/util';
|
|
36
|
+
|
|
37
|
+
import { type ObjectGenerator } from './ObjectGenerator';
|
|
38
|
+
|
|
39
|
+
export enum PresetName {
|
|
40
|
+
EMAIL_TABLE = 'email-table',
|
|
41
|
+
GPT_QUEUE = 'webhook-gpt-queue',
|
|
42
|
+
CHAT_GPT = 'chat-gpt-text',
|
|
43
|
+
EMAIL_WITH_SUMMARY = 'email-gptSummary-table',
|
|
44
|
+
OBJECT_CHANGE_QUEUE = 'objectChange-queue',
|
|
45
|
+
FOREX_FUNCTION_CALL = 'forex-function-call',
|
|
46
|
+
TIMER_TICK_QUEUE = 'timerTick-queue',
|
|
47
|
+
DISCORD_MESSAGES = 'discord-messages',
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const presets = {
|
|
51
|
+
schemas: [CanvasBoardType, FunctionTrigger],
|
|
52
|
+
types: Object.values(PresetName).map((name) => ({ typename: name })),
|
|
53
|
+
items: [
|
|
54
|
+
[
|
|
55
|
+
PresetName.GPT_QUEUE,
|
|
56
|
+
async (space, n, cb) => {
|
|
57
|
+
const objects = range(n, () => {
|
|
58
|
+
const canvasModel = CanvasGraphModel.create<ComputeShape>();
|
|
59
|
+
|
|
60
|
+
let functionTrigger: FunctionTrigger | undefined;
|
|
61
|
+
canvasModel.builder.call((builder) => {
|
|
62
|
+
const gpt = canvasModel.createNode(createGpt(position({ x: 0, y: -14 })));
|
|
63
|
+
const triggerShape = createTrigger({ triggerKind: TriggerKind.Webhook, ...position({ x: -18, y: -2 }) });
|
|
64
|
+
const trigger = canvasModel.createNode(triggerShape);
|
|
65
|
+
const text = canvasModel.createNode(createText(position({ x: 19, y: 3, width: 10, height: 10 })));
|
|
66
|
+
const { queueId } = setupQueue(canvasModel);
|
|
67
|
+
const append = canvasModel.createNode(createAppend(position({ x: 10, y: 6 })));
|
|
68
|
+
|
|
69
|
+
builder
|
|
70
|
+
.createEdge({ source: trigger.id, target: gpt.id, input: 'prompt', output: 'bodyText' })
|
|
71
|
+
.createEdge({ source: gpt.id, target: text.id, output: 'text' })
|
|
72
|
+
.createEdge({ source: queueId.id, target: append.id, input: 'id' })
|
|
73
|
+
.createEdge({ source: gpt.id, target: append.id, output: 'messages', input: 'items' });
|
|
74
|
+
|
|
75
|
+
functionTrigger = triggerShape.functionTrigger!.target!;
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const computeModel = createComputeGraph(canvasModel);
|
|
79
|
+
|
|
80
|
+
attachTrigger(functionTrigger, computeModel);
|
|
81
|
+
|
|
82
|
+
return addToSpace(PresetName.GPT_QUEUE, space, canvasModel, computeModel);
|
|
83
|
+
});
|
|
84
|
+
cb?.(objects);
|
|
85
|
+
return objects;
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
|
|
89
|
+
[
|
|
90
|
+
PresetName.OBJECT_CHANGE_QUEUE,
|
|
91
|
+
async (space, n, cb) => {
|
|
92
|
+
const objects = range(n, () => {
|
|
93
|
+
const { canvasModel, computeModel } = createQueueSinkPreset(
|
|
94
|
+
TriggerKind.Subscription,
|
|
95
|
+
(triggerSpec) => (triggerSpec.filter = { type: 'dxn:type:dxos.org/type/Chess' }),
|
|
96
|
+
'type',
|
|
97
|
+
);
|
|
98
|
+
return addToSpace(PresetName.OBJECT_CHANGE_QUEUE, space, canvasModel, computeModel);
|
|
99
|
+
});
|
|
100
|
+
cb?.(objects);
|
|
101
|
+
return objects;
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
|
|
105
|
+
[
|
|
106
|
+
PresetName.TIMER_TICK_QUEUE,
|
|
107
|
+
async (space, n, cb) => {
|
|
108
|
+
const objects = range(n, () => {
|
|
109
|
+
const { canvasModel, computeModel } = createQueueSinkPreset(
|
|
110
|
+
TriggerKind.Timer,
|
|
111
|
+
(triggerSpec) => (triggerSpec.cron = '*/5 * * * * *'),
|
|
112
|
+
'result',
|
|
113
|
+
);
|
|
114
|
+
return addToSpace(PresetName.TIMER_TICK_QUEUE, space, canvasModel, computeModel);
|
|
115
|
+
});
|
|
116
|
+
cb?.(objects);
|
|
117
|
+
return objects;
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
|
|
121
|
+
[
|
|
122
|
+
PresetName.EMAIL_TABLE,
|
|
123
|
+
async (space, n, cb) => {
|
|
124
|
+
const objects = range(n, () => {
|
|
125
|
+
const canvasModel = CanvasGraphModel.create<ComputeShape>();
|
|
126
|
+
|
|
127
|
+
const results = space.db.query(Filter.schema(TableType)).runSync();
|
|
128
|
+
const emailTable = results.find((r) => r.object?.view?.target?.query?.type?.endsWith('Email'));
|
|
129
|
+
invariant(emailTable, 'Email table not found.');
|
|
130
|
+
|
|
131
|
+
const template = canvasModel.createNode(
|
|
132
|
+
createTemplate({
|
|
133
|
+
valueType: 'object',
|
|
134
|
+
...rawPosition({ centerX: -80, centerY: -64, width: 320, height: 320 }),
|
|
135
|
+
}),
|
|
136
|
+
);
|
|
137
|
+
const templateContent = ['{'];
|
|
138
|
+
|
|
139
|
+
let functionTrigger: FunctionTrigger | undefined;
|
|
140
|
+
canvasModel.builder.call((builder) => {
|
|
141
|
+
const triggerShape = createTrigger({ triggerKind: TriggerKind.Email, ...position({ x: -18, y: -2 }) });
|
|
142
|
+
const trigger = canvasModel.createNode(triggerShape);
|
|
143
|
+
|
|
144
|
+
const tableId = canvasModel.createNode(
|
|
145
|
+
createConstant({
|
|
146
|
+
value: DXN.fromLocalObjectId(emailTable.id).toString(),
|
|
147
|
+
...position({ x: -18, y: 5, width: 8, height: 6 }),
|
|
148
|
+
}),
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
const appendToTable = canvasModel.createNode(createAppend(position({ x: 10, y: 6 })));
|
|
152
|
+
|
|
153
|
+
const properties = AST.getPropertySignatures(EmailTriggerOutput.ast);
|
|
154
|
+
for (let i = 0; i < properties.length; i++) {
|
|
155
|
+
const propName = properties[i].name.toString();
|
|
156
|
+
builder.createEdge({ source: trigger.id, target: template.id, input: propName, output: propName });
|
|
157
|
+
templateContent.push(` "${propName}": "{{${propName}}}"` + (i === properties.length - 1 ? '' : ','));
|
|
158
|
+
}
|
|
159
|
+
templateContent.push('}');
|
|
160
|
+
|
|
161
|
+
builder
|
|
162
|
+
.createEdge({ source: tableId.id, target: appendToTable.id, input: 'id' })
|
|
163
|
+
.createEdge({ source: template.id, target: appendToTable.id, input: 'items' });
|
|
164
|
+
|
|
165
|
+
functionTrigger = triggerShape.functionTrigger!.target!;
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
const computeModel = createComputeGraph(canvasModel);
|
|
169
|
+
|
|
170
|
+
const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
|
|
171
|
+
invariant(templateComputeNode, 'Template compute node was not created.');
|
|
172
|
+
templateComputeNode.value = templateContent.join('\n');
|
|
173
|
+
templateComputeNode.inputSchema = toJsonSchema(EmailTriggerOutput);
|
|
174
|
+
|
|
175
|
+
attachTrigger(functionTrigger, computeModel);
|
|
176
|
+
|
|
177
|
+
return addToSpace(PresetName.EMAIL_TABLE, space, canvasModel, computeModel);
|
|
178
|
+
});
|
|
179
|
+
cb?.(objects);
|
|
180
|
+
return objects;
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
|
|
184
|
+
[
|
|
185
|
+
PresetName.CHAT_GPT,
|
|
186
|
+
async (space, n, cb) => {
|
|
187
|
+
const objects = range(n, () => {
|
|
188
|
+
const canvasModel = CanvasGraphModel.create<ComputeShape>();
|
|
189
|
+
|
|
190
|
+
canvasModel.builder.call((builder) => {
|
|
191
|
+
const gpt = canvasModel.createNode(createGpt(position({ x: 0, y: -14 })));
|
|
192
|
+
const chat = canvasModel.createNode(createChat(position({ x: -18, y: -2 })));
|
|
193
|
+
const text = canvasModel.createNode(createText(position({ x: 19, y: 3, width: 10, height: 10 })));
|
|
194
|
+
const { queueId } = setupQueue(canvasModel);
|
|
195
|
+
|
|
196
|
+
const append = canvasModel.createNode(createAppend(position({ x: 10, y: 6 })));
|
|
197
|
+
|
|
198
|
+
builder
|
|
199
|
+
.createEdge({ source: chat.id, target: gpt.id, input: 'prompt' })
|
|
200
|
+
.createEdge({ source: gpt.id, target: text.id, output: 'text' })
|
|
201
|
+
.createEdge({ source: queueId.id, target: append.id, input: 'id' })
|
|
202
|
+
.createEdge({ source: gpt.id, target: append.id, output: 'messages', input: 'items' });
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
const computeModel = createComputeGraph(canvasModel);
|
|
206
|
+
|
|
207
|
+
return addToSpace(PresetName.CHAT_GPT, space, canvasModel, computeModel);
|
|
208
|
+
});
|
|
209
|
+
cb?.(objects);
|
|
210
|
+
return objects;
|
|
211
|
+
},
|
|
212
|
+
],
|
|
213
|
+
|
|
214
|
+
[
|
|
215
|
+
PresetName.EMAIL_WITH_SUMMARY,
|
|
216
|
+
async (space, n, cb) => {
|
|
217
|
+
const objects = range(n, () => {
|
|
218
|
+
const canvasModel = CanvasGraphModel.create<ComputeShape>();
|
|
219
|
+
|
|
220
|
+
const results = space.db.query(Filter.schema(TableType)).runSync();
|
|
221
|
+
const emailTable = results.find((r) => r.object?.view?.target?.query?.type?.endsWith('Email'));
|
|
222
|
+
invariant(emailTable, 'Email table not found.');
|
|
223
|
+
|
|
224
|
+
const template = canvasModel.createNode(
|
|
225
|
+
createTemplate({
|
|
226
|
+
valueType: 'object',
|
|
227
|
+
...rawPosition({ centerX: 192, centerY: -176, width: 320, height: 320 }),
|
|
228
|
+
}),
|
|
229
|
+
);
|
|
230
|
+
const templateContent = ['{'];
|
|
231
|
+
|
|
232
|
+
let functionTrigger: FunctionTrigger | undefined;
|
|
233
|
+
canvasModel.builder.call((builder) => {
|
|
234
|
+
const gpt = canvasModel.createNode(
|
|
235
|
+
createGpt(rawPosition({ centerX: -400, centerY: -112, width: 256, height: 202 })),
|
|
236
|
+
);
|
|
237
|
+
const systemPrompt = canvasModel.createNode(
|
|
238
|
+
createConstant({
|
|
239
|
+
value: "use one word to describe content category. don't write anything else",
|
|
240
|
+
...rawPosition({ centerX: -800, centerY: -160, width: 192, height: 128 }),
|
|
241
|
+
}),
|
|
242
|
+
);
|
|
243
|
+
const triggerShape = createTrigger({
|
|
244
|
+
triggerKind: TriggerKind.Email,
|
|
245
|
+
...rawPosition({ centerX: -736, centerY: -384, width: 182, height: 192 }),
|
|
246
|
+
});
|
|
247
|
+
const trigger = canvasModel.createNode(triggerShape);
|
|
248
|
+
|
|
249
|
+
const { queueId } = setupQueue(canvasModel, {
|
|
250
|
+
idPosition: { centerX: -720, centerY: 224, width: 192, height: 256 },
|
|
251
|
+
queuePosition: { centerX: -144, centerY: 416, width: 320, height: 448 },
|
|
252
|
+
});
|
|
253
|
+
const appendToQueue = canvasModel.createNode(
|
|
254
|
+
createAppend(rawPosition({ centerX: -80, centerY: 96, width: 122, height: 128 })),
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
const tableId = canvasModel.createNode(
|
|
258
|
+
createConstant({
|
|
259
|
+
value: DXN.fromLocalObjectId(emailTable.id).toString(),
|
|
260
|
+
...rawPosition({ centerX: -112, centerY: -544, width: 192, height: 256 }),
|
|
261
|
+
}),
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
const appendToTable = canvasModel.createNode(
|
|
265
|
+
createAppend(rawPosition({ centerX: 560, centerY: -416, width: 128, height: 122 })),
|
|
266
|
+
);
|
|
267
|
+
|
|
268
|
+
templateContent.push(' "category": "{{text}}",');
|
|
269
|
+
builder.createEdge({ source: gpt.id, target: template.id, input: 'text', output: 'text' });
|
|
270
|
+
|
|
271
|
+
const properties = AST.getPropertySignatures(EmailTriggerOutput.ast);
|
|
272
|
+
for (let i = 0; i < properties.length; i++) {
|
|
273
|
+
const propName = properties[i].name.toString();
|
|
274
|
+
builder.createEdge({ source: trigger.id, target: template.id, input: propName, output: propName });
|
|
275
|
+
templateContent.push(` "${propName}": "{{${propName}}}"` + (i === properties.length - 1 ? '' : ','));
|
|
276
|
+
}
|
|
277
|
+
templateContent.push('}');
|
|
278
|
+
|
|
279
|
+
builder
|
|
280
|
+
.createEdge({ source: tableId.id, target: appendToTable.id, input: 'id' })
|
|
281
|
+
.createEdge({ source: queueId.id, target: appendToQueue.id, input: 'id' })
|
|
282
|
+
.createEdge({ source: gpt.id, target: appendToQueue.id, output: 'messages', input: 'items' })
|
|
283
|
+
.createEdge({ source: systemPrompt.id, target: gpt.id, input: 'systemPrompt' })
|
|
284
|
+
.createEdge({ source: trigger.id, target: gpt.id, input: 'prompt', output: 'body' })
|
|
285
|
+
.createEdge({ source: template.id, target: appendToTable.id, input: 'items' });
|
|
286
|
+
|
|
287
|
+
functionTrigger = triggerShape.functionTrigger!.target!;
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
const computeModel = createComputeGraph(canvasModel);
|
|
291
|
+
|
|
292
|
+
const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
|
|
293
|
+
invariant(templateComputeNode, 'Template compute node was not created.');
|
|
294
|
+
templateComputeNode.value = templateContent.join('\n');
|
|
295
|
+
const extendedSchema = S.extend(EmailTriggerOutput, S.Struct({ text: S.String }));
|
|
296
|
+
templateComputeNode.inputSchema = toJsonSchema(extendedSchema);
|
|
297
|
+
|
|
298
|
+
attachTrigger(functionTrigger, computeModel);
|
|
299
|
+
|
|
300
|
+
return addToSpace(PresetName.EMAIL_WITH_SUMMARY, space, canvasModel, computeModel);
|
|
301
|
+
});
|
|
302
|
+
cb?.(objects);
|
|
303
|
+
return objects;
|
|
304
|
+
},
|
|
305
|
+
],
|
|
306
|
+
[
|
|
307
|
+
PresetName.FOREX_FUNCTION_CALL,
|
|
308
|
+
async (space, n, cb) => {
|
|
309
|
+
const objects = range(n, () => {
|
|
310
|
+
const canvasModel = CanvasGraphModel.create<ComputeShape>();
|
|
311
|
+
|
|
312
|
+
canvasModel.builder.call((builder) => {
|
|
313
|
+
const sourceCurrency = canvasModel.createNode(
|
|
314
|
+
createConstant({ value: 'USD', ...position({ x: -10, y: -5 }) }),
|
|
315
|
+
);
|
|
316
|
+
const targetCurrency = canvasModel.createNode(
|
|
317
|
+
createConstant({ value: 'EUR', ...position({ x: -10, y: 5 }) }),
|
|
318
|
+
);
|
|
319
|
+
const converter = canvasModel.createNode(createFunction(position({ x: 0, y: 0 })));
|
|
320
|
+
const view = canvasModel.createNode(createSurface(position({ x: 12, y: 0 })));
|
|
321
|
+
|
|
322
|
+
builder
|
|
323
|
+
.createEdge({ source: sourceCurrency.id, target: converter.id, input: 'from' })
|
|
324
|
+
.createEdge({ source: targetCurrency.id, target: converter.id, input: 'to' })
|
|
325
|
+
.createEdge({ source: converter.id, target: view.id, output: 'rate' });
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
const computeModel = createComputeGraph(canvasModel);
|
|
329
|
+
|
|
330
|
+
return addToSpace(PresetName.FOREX_FUNCTION_CALL, space, canvasModel, computeModel);
|
|
331
|
+
});
|
|
332
|
+
cb?.(objects);
|
|
333
|
+
return objects;
|
|
334
|
+
},
|
|
335
|
+
],
|
|
336
|
+
[
|
|
337
|
+
PresetName.DISCORD_MESSAGES,
|
|
338
|
+
async (space, n, cb) => {
|
|
339
|
+
const objects = range(n, () => {
|
|
340
|
+
const canvasModel = CanvasGraphModel.create<ComputeShape>();
|
|
341
|
+
|
|
342
|
+
let functionTrigger: FunctionTrigger | undefined;
|
|
343
|
+
canvasModel.builder.call((builder) => {
|
|
344
|
+
const triggerShape = createTrigger({ triggerKind: TriggerKind.Timer, ...position({ x: -10, y: -5 }) });
|
|
345
|
+
const trigger = canvasModel.createNode(triggerShape);
|
|
346
|
+
// DXOS dev-null channel.
|
|
347
|
+
const channelId = canvasModel.createNode(
|
|
348
|
+
createConstant({ value: '1088569858767212554', ...position({ x: -10, y: 0 }) }),
|
|
349
|
+
);
|
|
350
|
+
const queueId = canvasModel.createNode(
|
|
351
|
+
createConstant({
|
|
352
|
+
value: new DXN(DXN.kind.QUEUE, ['data', SpaceId.random(), ObjectId.random()]).toString(),
|
|
353
|
+
...position({ x: -10, y: 5 }),
|
|
354
|
+
}),
|
|
355
|
+
);
|
|
356
|
+
const converter = canvasModel.createNode(createFunction(position({ x: 0, y: 0 })));
|
|
357
|
+
const view = canvasModel.createNode(createText(position({ x: 12, y: 0 })));
|
|
358
|
+
const queue = canvasModel.createNode(createQueue(position({ x: 0, y: 12 })));
|
|
359
|
+
|
|
360
|
+
builder
|
|
361
|
+
.createEdge({ source: trigger.id, target: converter.id, input: 'tick' })
|
|
362
|
+
.createEdge({ source: channelId.id, target: converter.id, input: 'channelId' })
|
|
363
|
+
.createEdge({ source: queueId.id, target: converter.id, input: 'queueId' })
|
|
364
|
+
.createEdge({ source: converter.id, target: view.id, output: 'newMessages' })
|
|
365
|
+
.createEdge({ source: queueId.id, target: queue.id, input: 'input' });
|
|
366
|
+
|
|
367
|
+
functionTrigger = triggerShape.functionTrigger!.target!;
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
const computeModel = createComputeGraph(canvasModel);
|
|
371
|
+
attachTrigger(functionTrigger, computeModel);
|
|
372
|
+
|
|
373
|
+
return addToSpace(PresetName.DISCORD_MESSAGES, space, canvasModel, computeModel);
|
|
374
|
+
});
|
|
375
|
+
cb?.(objects);
|
|
376
|
+
return objects;
|
|
377
|
+
},
|
|
378
|
+
],
|
|
379
|
+
] as [PresetName, ObjectGenerator<any>][],
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
const createQueueSinkPreset = <SpecType extends TriggerKind>(
|
|
383
|
+
triggerKind: SpecType,
|
|
384
|
+
initSpec: (spec: Extract<TriggerType, { type: SpecType }>) => void,
|
|
385
|
+
triggerOutputName: string,
|
|
386
|
+
) => {
|
|
387
|
+
const canvasModel = CanvasGraphModel.create<ComputeShape>();
|
|
388
|
+
|
|
389
|
+
const template = canvasModel.createNode(
|
|
390
|
+
createTemplate({
|
|
391
|
+
valueType: 'object',
|
|
392
|
+
...rawPosition({ centerX: -64, centerY: -79, width: 320, height: 320 }),
|
|
393
|
+
}),
|
|
394
|
+
);
|
|
395
|
+
|
|
396
|
+
let functionTrigger: FunctionTrigger | undefined;
|
|
397
|
+
canvasModel.builder.call((builder) => {
|
|
398
|
+
const triggerShape = createTrigger({
|
|
399
|
+
triggerKind,
|
|
400
|
+
...rawPosition({ centerX: -578, centerY: -187, height: 320, width: 320 }),
|
|
401
|
+
});
|
|
402
|
+
const trigger = canvasModel.createNode(triggerShape);
|
|
403
|
+
const { queueId } = setupQueue(canvasModel, {
|
|
404
|
+
queuePosition: { centerX: -80, centerY: 378, width: 320, height: 448 },
|
|
405
|
+
});
|
|
406
|
+
const append = canvasModel.createNode(
|
|
407
|
+
createAppend(rawPosition({ centerX: 320, centerY: 192, width: 128, height: 122 })),
|
|
408
|
+
);
|
|
409
|
+
const random = canvasModel.createNode(
|
|
410
|
+
createRandom(rawPosition({ centerX: -509, centerY: -30, width: 64, height: 64 })),
|
|
411
|
+
);
|
|
412
|
+
|
|
413
|
+
builder
|
|
414
|
+
.createEdge({ source: queueId.id, target: append.id, input: 'id' })
|
|
415
|
+
.createEdge({ source: template.id, target: append.id, input: 'items' })
|
|
416
|
+
.createEdge({ source: trigger.id, target: template.id, output: triggerOutputName, input: 'type' })
|
|
417
|
+
.createEdge({
|
|
418
|
+
source: random.id,
|
|
419
|
+
target: template.id,
|
|
420
|
+
input: 'changeId',
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
functionTrigger = triggerShape.functionTrigger!.target!;
|
|
424
|
+
const triggerSpec = functionTrigger.spec;
|
|
425
|
+
invariant(triggerSpec && triggerSpec.type === triggerKind, 'No trigger spec.');
|
|
426
|
+
initSpec(triggerSpec as any);
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
const computeModel = createComputeGraph(canvasModel);
|
|
430
|
+
|
|
431
|
+
const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
|
|
432
|
+
invariant(templateComputeNode, 'Template compute node was not created.');
|
|
433
|
+
templateComputeNode.value = ['{', ' "@type": "{{type}}",', ' "id": "@{{changeId}}"', '}'].join('\n');
|
|
434
|
+
templateComputeNode.inputSchema = toJsonSchema(S.Struct({ type: S.String, changeId: S.String }));
|
|
435
|
+
|
|
436
|
+
attachTrigger(functionTrigger, computeModel);
|
|
437
|
+
|
|
438
|
+
return { canvasModel, computeModel };
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
const addToSpace = (name: string, space: Space, canvas: CanvasGraphModel, compute: ComputeGraphModel) => {
|
|
442
|
+
return space.db.add(
|
|
443
|
+
create(CanvasBoardType, {
|
|
444
|
+
name,
|
|
445
|
+
computeGraph: makeRef(compute.root),
|
|
446
|
+
layout: canvas.graph,
|
|
447
|
+
}),
|
|
448
|
+
);
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
const setupQueue = (
|
|
452
|
+
canvasModel: CanvasGraphModel,
|
|
453
|
+
args?: { idPosition?: RawPositionInput; queuePosition?: RawPositionInput },
|
|
454
|
+
) => {
|
|
455
|
+
const queueId = canvasModel.createNode(
|
|
456
|
+
createConstant({
|
|
457
|
+
value: new DXN(DXN.kind.QUEUE, ['data', SpaceId.random(), ObjectId.random()]).toString(),
|
|
458
|
+
...(args?.idPosition ? rawPosition(args.idPosition) : position({ x: -18, y: 5, width: 8, height: 6 })),
|
|
459
|
+
}),
|
|
460
|
+
);
|
|
461
|
+
const queue = canvasModel.createNode(
|
|
462
|
+
createQueue(
|
|
463
|
+
args?.queuePosition ? rawPosition(args.queuePosition) : position({ x: -3, y: 3, width: 14, height: 10 }),
|
|
464
|
+
),
|
|
465
|
+
);
|
|
466
|
+
canvasModel.createEdge({ source: queueId.id, target: queue.id });
|
|
467
|
+
return { queue, queueId };
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
const attachTrigger = (functionTrigger: FunctionTrigger | undefined, computeModel: ComputeGraphModel) => {
|
|
471
|
+
invariant(functionTrigger);
|
|
472
|
+
functionTrigger.function = DXN.fromLocalObjectId(computeModel.root.id).toString();
|
|
473
|
+
functionTrigger.meta ??= {};
|
|
474
|
+
const inputNode = computeModel.nodes.find((node) => node.type === NODE_INPUT)!;
|
|
475
|
+
functionTrigger.meta.computeNodeId = inputNode.id;
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
type RawPositionInput = { centerX: number; centerY: number; width: number; height: number };
|
|
479
|
+
|
|
480
|
+
const rawPosition = (args: RawPositionInput) => {
|
|
481
|
+
return { center: { x: args.centerX, y: args.centerY }, size: { width: args.width, height: args.height } };
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
const position = (rect: { x: number; y: number; width?: number; height?: number }) => {
|
|
485
|
+
const snap = 32;
|
|
486
|
+
const [center, size] = rectToPoints({ width: 0, height: 0, ...rect });
|
|
487
|
+
const { x, y, width, height } = pointsToRect([pointMultiply(center, snap), pointMultiply(size, snap)]);
|
|
488
|
+
if (width && height) {
|
|
489
|
+
return { center: { x, y }, size: width && height ? { width, height } : undefined };
|
|
490
|
+
} else {
|
|
491
|
+
return { center: { x, y } };
|
|
492
|
+
}
|
|
493
|
+
};
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { useResizeDetector } from 'react-resize-detector';
|
|
7
7
|
|
|
8
|
-
import { fullyQualifiedId } from '@dxos/react-client/echo';
|
|
8
|
+
import { fullyQualifiedId, type ReactiveEchoObject } from '@dxos/react-client/echo';
|
|
9
9
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
10
10
|
import { useAttendableAttributes } from '@dxos/react-ui-attention';
|
|
11
11
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
@@ -14,7 +14,7 @@ import { mx } from '@dxos/react-ui-theme';
|
|
|
14
14
|
// TODO(burdon): Create generic container with wireframe mode.
|
|
15
15
|
export type WireframeProps = ThemedClassName<{
|
|
16
16
|
label?: string;
|
|
17
|
-
object
|
|
17
|
+
object: ReactiveEchoObject<any>;
|
|
18
18
|
}>;
|
|
19
19
|
|
|
20
20
|
// TODO(burdon): Make focusable and attendable with input.
|
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -6,11 +6,13 @@ import { type PluginMeta } from '@dxos/app-framework';
|
|
|
6
6
|
|
|
7
7
|
export const DEBUG_PLUGIN = 'dxos.org/plugin/debug';
|
|
8
8
|
|
|
9
|
-
export
|
|
9
|
+
export const meta = {
|
|
10
10
|
id: DEBUG_PLUGIN,
|
|
11
11
|
name: 'Debug',
|
|
12
|
-
description:
|
|
12
|
+
description:
|
|
13
|
+
'The debug plugin is useful for troubleshooting inside of Composer. You can also use the Debug plugin to create test data inside of sheets or tables or explore pre-built automations. Non-technical users will likely not spend much time here, but this plugin is invaluable for developers and technical users.',
|
|
13
14
|
icon: 'ph--bug--regular',
|
|
14
15
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-debug',
|
|
15
16
|
tags: ['experimental'],
|
|
17
|
+
screenshots: ['https://dxos.network/plugin-details-debug-dark.png'],
|
|
16
18
|
} satisfies PluginMeta;
|
package/src/types.ts
CHANGED
|
@@ -4,23 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { type Context, createContext } from 'react';
|
|
6
6
|
|
|
7
|
-
import type {
|
|
8
|
-
GraphBuilderProvides,
|
|
9
|
-
IntentResolverProvides,
|
|
10
|
-
SettingsProvides,
|
|
11
|
-
SurfaceProvides,
|
|
12
|
-
TranslationsProvides,
|
|
13
|
-
} from '@dxos/app-framework';
|
|
14
7
|
import type { TimerCallback, TimerOptions } from '@dxos/async';
|
|
15
8
|
import { S } from '@dxos/echo-schema';
|
|
16
|
-
import { type PanelProvides } from '@dxos/plugin-deck/types';
|
|
17
|
-
|
|
18
|
-
import { DEBUG_PLUGIN } from './meta';
|
|
19
|
-
|
|
20
|
-
const DEBUG_ACTION = `${DEBUG_PLUGIN}/action`;
|
|
21
|
-
export enum DebugAction {
|
|
22
|
-
OPEN_DEVTOOLS = `${DEBUG_ACTION}/open-devtools`,
|
|
23
|
-
}
|
|
24
9
|
|
|
25
10
|
export type DebugContextType = {
|
|
26
11
|
running: boolean;
|
|
@@ -43,10 +28,3 @@ export const DebugSettingsSchema = S.mutable(
|
|
|
43
28
|
);
|
|
44
29
|
|
|
45
30
|
export interface DebugSettingsProps extends S.Schema.Type<typeof DebugSettingsSchema> {}
|
|
46
|
-
|
|
47
|
-
export type DebugPluginProvides = SurfaceProvides &
|
|
48
|
-
IntentResolverProvides &
|
|
49
|
-
GraphBuilderProvides &
|
|
50
|
-
SettingsProvides<DebugSettingsProps> &
|
|
51
|
-
TranslationsProvides &
|
|
52
|
-
PanelProvides;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/DebugSpace/DebugSpace.tsx", "../../../src/components/DebugSpace/ObjectCreator.tsx", "../../../src/components/DebugSpace/index.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { type FC, useContext, useMemo, useState } from 'react';\n\nimport { createSpaceObjectGenerator } from '@dxos/echo-generator';\nimport { type ReactiveObject } from '@dxos/live-object';\nimport { DocumentType } from '@dxos/plugin-markdown/types';\nimport { Invitation } from '@dxos/protocols/proto/dxos/client/services';\nimport { faker } from '@dxos/random';\nimport { useClient } from '@dxos/react-client';\nimport { Filter, type Space, useSpaceInvitation } from '@dxos/react-client/echo';\nimport { InvitationEncoder } from '@dxos/react-client/invitations';\nimport { useAsyncEffect } from '@dxos/react-hooks';\nimport { Icon, IconButton, Input, type IconProps, type TextInputProps, Toolbar, useFileDownload } from '@dxos/react-ui';\nimport { safeParseInt } from '@dxos/util';\n\nimport { ObjectCreator } from './ObjectCreator';\nimport { DebugContext } from '../../types';\nimport { Container } from '../Container';\n\nconst DEFAULT_COUNT = 100;\nconst DEFAULT_PERIOD = 500;\nconst DEFAULT_JITTER = 50;\n\nconst useRefresh = (): [any, () => void] => {\n const [update, setUpdate] = useState({});\n return [update, () => setUpdate({})];\n};\n\nconst CustomInput = ({ icon, ...props }: Pick<IconProps, 'icon'> & TextInputProps) => {\n return (\n <div role='none' className='relative'>\n <Input.Root>\n <Input.TextInput classNames='w-[100px] text-right pie-[22px]' size={5} {...props} />\n </Input.Root>\n <Icon icon={icon} size={3} classNames='absolute inline-end-1 block-start-1 mt-[6px]' />\n </div>\n );\n};\n\nexport const DebugSpace: FC<{\n space: Space;\n onAddObjects?: (objects: ReactiveObject<any>[]) => void;\n}> = ({ space, onAddObjects }) => {\n const { connect } = useSpaceInvitation(space?.key);\n const client = useClient();\n const [data, setData] = useState<any>({});\n\n const [update, handleUpdate] = useRefresh();\n useAsyncEffect(\n async (isMounted) => {\n const data = await client.diagnostics({ truncate: true });\n if (isMounted()) {\n setData(\n data?.diagnostics?.spaces?.find(({ key }: any) => {\n return space.key.toHex().startsWith(key);\n }),\n );\n }\n },\n [space, update],\n );\n\n const download = useFileDownload();\n const handleDownload = async () => {\n download(\n new Blob([JSON.stringify(data, undefined, 2)], { type: 'text/plain' }),\n `${new Date().toISOString().replace(/\\W/g, '-')}.json`,\n );\n };\n\n const [mutationCount, setMutationCount] = useState(String(DEFAULT_COUNT));\n const [mutationInterval, setMutationInterval] = useState(String(DEFAULT_PERIOD));\n const [mutationJitter, setMutationJitter] = useState(String(DEFAULT_JITTER));\n\n const generator = useMemo(() => createSpaceObjectGenerator(space), [space]);\n\n // TODO(burdon): Note: this is shared across all spaces!\n const { running, start, stop } = useContext(DebugContext);\n const handleToggleRunning = () => {\n if (running) {\n stop();\n handleUpdate();\n } else {\n start(\n async () => {\n const { objects } = await space.db.query(Filter.schema(DocumentType)).run();\n if (objects.length) {\n const object = faker.helpers.arrayElement(objects);\n await generator.mutateObject(object, { count: 10, mutationSize: 10, maxContentLength: 1000 });\n }\n },\n {\n count: safeParseInt(mutationCount) ?? 0,\n interval: safeParseInt(mutationInterval) ?? 0,\n jitter: safeParseInt(mutationJitter) ?? 0,\n },\n );\n }\n };\n\n const handleCreateInvitation = () => {\n const invitation = space.share({\n type: Invitation.Type.INTERACTIVE,\n authMethod: Invitation.AuthMethod.NONE,\n multiUse: true,\n });\n\n // TODO(burdon): Refactor.\n // TODO(burdon): Unsubscribe?\n connect(invitation);\n const code = InvitationEncoder.encode(invitation.get());\n new URL(window.origin).searchParams.set('spaceInvitationCode', code);\n const url = `${window.origin}?spaceInvitationCode=${code}`;\n void navigator.clipboard.writeText(url);\n };\n\n const handleCreateEpoch = async () => {\n await space.internal.createEpoch();\n handleUpdate();\n };\n\n return (\n <Container\n toolbar={\n <Toolbar.Root classNames='p-1'>\n <CustomInput\n icon='ph--flag--regular'\n autoComplete='off'\n placeholder='Count'\n value={mutationCount}\n onChange={({ target: { value } }) => setMutationCount(value)}\n />\n <CustomInput\n icon='ph--timer--regular'\n autoComplete='off'\n placeholder='Interval'\n value={mutationInterval}\n onChange={({ target: { value } }) => setMutationInterval(value)}\n />\n <CustomInput\n icon='ph--plus-minus--regular'\n autoComplete='off'\n placeholder='Jitter'\n value={mutationJitter}\n onChange={({ target: { value } }) => setMutationJitter(value)}\n />\n\n <IconButton\n icon={running ? 'ph--pause-circle--regular' : 'ph--play-circle--regular'}\n iconOnly\n label='Start/stop'\n size={5}\n onClick={handleToggleRunning}\n />\n <IconButton icon='ph--arrow-clockwise--regular' iconOnly label='Refresh' size={5} onClick={handleUpdate} />\n <IconButton icon='ph--download-simple--regular' iconOnly label='Download' size={5} onClick={handleDownload} />\n\n <Toolbar.Expander />\n <IconButton\n icon='ph--flag-pennant--regular'\n iconOnly\n label='Create epoch'\n size={5}\n onClick={handleCreateEpoch}\n />\n <IconButton\n icon='ph--user-circle-plus--regular'\n iconOnly\n iconClassNames='text-blue-500'\n label='Create Invitation'\n size={5}\n onClick={handleCreateInvitation}\n />\n </Toolbar.Root>\n }\n >\n <ObjectCreator space={space} onAddObjects={onAddObjects} />\n </Container>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { useMemo, useState } from 'react';\n\nimport { type MutationsProviderParams, TestSchemaType, createSpaceObjectGenerator } from '@dxos/echo-generator';\nimport { type ReactiveEchoObject, type ReactiveObject, type Space } from '@dxos/react-client/echo';\nimport { IconButton, Toolbar } from '@dxos/react-ui';\nimport { createColumnBuilder, type TableColumnDef, Table } from '@dxos/react-ui-table/deprecated';\n\nconst BATCH_SIZE = 10;\n\nexport type CreateObjectsParams = {\n schema: string;\n enabled: boolean;\n objects: number;\n mutations: Pick<MutationsProviderParams, 'count' | 'mutationSize' | 'maxContentLength'>;\n};\n\nexport type ObjectCreatorProps = {\n space: Space;\n onAddObjects?: (objects: ReactiveObject<any>[]) => void;\n};\n\nexport const ObjectCreator = ({ space, onAddObjects }: ObjectCreatorProps) => {\n const generator = useMemo(() => createSpaceObjectGenerator(space), [space]);\n\n const [objects, setObjects] = useState<CreateObjectsParams[]>(\n Object.values(TestSchemaType).map((schema) => ({\n schema,\n enabled: true,\n objects: 10,\n mutations: {\n count: 10,\n mutationSize: 10,\n maxContentLength: 1000,\n },\n })),\n );\n\n const handleCreate = async () => {\n for (const params of objects) {\n if (!params.enabled) {\n continue;\n }\n\n let objectsCreated = 0;\n while (objectsCreated < params.objects) {\n const objects = (await generator.createObjects({\n [params.schema]: Math.min(BATCH_SIZE, params.objects - objectsCreated),\n })) as ReactiveEchoObject<any>[];\n\n await generator.mutateObjects(objects, params.mutations);\n objectsCreated += objects.length;\n onAddObjects?.(objects);\n }\n }\n\n await space.db.flush();\n };\n\n const handleUpdate = (row: CreateObjectsParams, key: string, value: any) => {\n const newObjects = [...objects];\n Object.assign(newObjects.find((object) => object.schema === row.schema)!, { [key]: value });\n setObjects(newObjects);\n };\n\n const { helper, builder } = createColumnBuilder<CreateObjectsParams>();\n const columns: TableColumnDef<CreateObjectsParams>[] = [\n helper.accessor('enabled', builder.switch({ label: 'Live', onUpdate: handleUpdate })),\n helper.accessor('schema', builder.string({ label: 'Schema', classNames: 'font-mono' })),\n helper.accessor('objects', builder.number({ label: 'Objects', onUpdate: handleUpdate })),\n helper.accessor((obj) => obj.mutations.count, {\n id: 'mutations',\n ...builder.number({ label: 'Mutations', onUpdate: handleUpdate }),\n }),\n helper.accessor((obj) => obj.mutations.mutationSize, {\n id: 'mutationSize',\n ...builder.number({ label: 'Mut. Size', onUpdate: handleUpdate }),\n }),\n helper.accessor((obj) => obj.mutations.maxContentLength, {\n id: 'mutationMaxContentLength',\n ...builder.number({ label: 'Length', onUpdate: handleUpdate }),\n }),\n ];\n\n return (\n <>\n <Table.Root>\n <Table.Viewport>\n <Table.Main<CreateObjectsParams> columns={columns} data={objects} />\n </Table.Viewport>\n </Table.Root>\n <Toolbar.Root classNames='p-1'>\n <IconButton icon='ph--plus--regular' label='Create' onClick={handleCreate} />\n </Toolbar.Root>\n </>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { DebugSpace } from './DebugSpace';\n\nexport default DebugSpace;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;AAIA,OAAOA,UAAkBC,YAAYC,WAAAA,UAASC,YAAAA,iBAAgB;AAE9D,SAASC,8BAAAA,mCAAkC;AAE3C,SAASC,oBAAoB;AAC7B,SAASC,kBAAkB;AAC3B,SAASC,aAAa;AACtB,SAASC,iBAAiB;AAC1B,SAASC,QAAoBC,0BAA0B;AACvD,SAASC,yBAAyB;AAClC,SAASC,sBAAsB;AAC/B,SAASC,MAAMC,cAAAA,aAAYC,OAA4CC,WAAAA,UAASC,uBAA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M;MACNwG,SAASrC;;KAKf,gBAAA3E,OAAA,cAACmH,eAAAA;IAAcxG;IAAcC;;AAGnC;;;AEhLA,IAAA,qBAAewG;",
|
|
6
|
-
"names": ["React", "useContext", "useMemo", "useState", "createSpaceObjectGenerator", "DocumentType", "Invitation", "faker", "useClient", "Filter", "useSpaceInvitation", "InvitationEncoder", "useAsyncEffect", "Icon", "IconButton", "Input", "Toolbar", "useFileDownload", "safeParseInt", "React", "useMemo", "useState", "TestSchemaType", "createSpaceObjectGenerator", "IconButton", "Toolbar", "createColumnBuilder", "Table", "BATCH_SIZE", "ObjectCreator", "space", "onAddObjects", "generator", "useMemo", "createSpaceObjectGenerator", "objects", "setObjects", "useState", "Object", "values", "TestSchemaType", "map", "schema", "enabled", "mutations", "count", "mutationSize", "maxContentLength", "handleCreate", "params", "objectsCreated", "createObjects", "Math", "min", "mutateObjects", "length", "db", "flush", "handleUpdate", "row", "key", "value", "newObjects", "assign", "find", "object", "helper", "builder", "createColumnBuilder", "columns", "accessor", "switch", "label", "onUpdate", "string", "classNames", "number", "obj", "id", "Table", "Root", "Viewport", "Main", "data", "Toolbar", "IconButton", "icon", "onClick", "DEFAULT_COUNT", "DEFAULT_PERIOD", "DEFAULT_JITTER", "useRefresh", "update", "setUpdate", "useState", "CustomInput", "icon", "props", "React", "div", "role", "className", "Input", "Root", "TextInput", "classNames", "size", "Icon", "DebugSpace", "space", "onAddObjects", "connect", "useSpaceInvitation", "key", "client", "useClient", "data", "setData", "handleUpdate", "useAsyncEffect", "isMounted", "diagnostics", "truncate", "spaces", "find", "toHex", "startsWith", "download", "useFileDownload", "handleDownload", "Blob", "JSON", "stringify", "undefined", "type", "Date", "toISOString", "replace", "mutationCount", "setMutationCount", "String", "mutationInterval", "setMutationInterval", "mutationJitter", "setMutationJitter", "generator", "useMemo", "createSpaceObjectGenerator", "running", "start", "stop", "useContext", "DebugContext", "handleToggleRunning", "objects", "db", "query", "Filter", "schema", "DocumentType", "run", "length", "object", "faker", "helpers", "arrayElement", "mutateObject", "count", "mutationSize", "maxContentLength", "safeParseInt", "interval", "jitter", "handleCreateInvitation", "invitation", "share", "Invitation", "Type", "INTERACTIVE", "authMethod", "AuthMethod", "NONE", "multiUse", "code", "InvitationEncoder", "encode", "get", "URL", "window", "origin", "searchParams", "set", "url", "navigator", "clipboard", "writeText", "handleCreateEpoch", "internal", "createEpoch", "Container", "toolbar", "Toolbar", "autoComplete", "placeholder", "value", "onChange", "target", "IconButton", "iconOnly", "label", "onClick", "Expander", "iconClassNames", "ObjectCreator", "DebugSpace"]
|
|
7
|
-
}
|