@dxos/plugin-debug 0.7.5-main.ff8607b → 0.7.5-staging.2ff1350

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 (71) hide show
  1. package/dist/lib/browser/{DebugSpace-4JHYA7FG.mjs → DebugSpace-BTMTVZ6C.mjs} +2 -2
  2. package/dist/lib/browser/SpaceGenerator-BPZGOSH4.mjs +1238 -0
  3. package/dist/lib/browser/SpaceGenerator-BPZGOSH4.mjs.map +7 -0
  4. package/dist/lib/browser/app-graph-builder-BZFZ6UG6.mjs +533 -0
  5. package/dist/lib/browser/app-graph-builder-BZFZ6UG6.mjs.map +7 -0
  6. package/dist/lib/browser/chunk-UASI2CRI.mjs +72 -0
  7. package/dist/lib/browser/chunk-UASI2CRI.mjs.map +7 -0
  8. package/dist/lib/browser/index.mjs +44 -8
  9. package/dist/lib/browser/index.mjs.map +3 -3
  10. package/dist/lib/browser/meta.json +1 -1
  11. package/dist/lib/browser/react-context-TCD3MNIT.mjs +16 -0
  12. package/dist/lib/browser/react-context-TCD3MNIT.mjs.map +7 -0
  13. package/dist/lib/browser/{react-surface-VEEFOGIM.mjs → react-surface-W6QLG4YJ.mjs} +210 -40
  14. package/dist/lib/browser/react-surface-W6QLG4YJ.mjs.map +7 -0
  15. package/dist/lib/browser/{settings-OIMSBZUC.mjs → settings-INPXR64L.mjs} +5 -6
  16. package/dist/lib/browser/{settings-OIMSBZUC.mjs.map → settings-INPXR64L.mjs.map} +3 -3
  17. package/dist/types/src/DebugPlugin.d.ts.map +1 -1
  18. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  19. package/dist/types/src/capabilities/index.d.ts +5 -0
  20. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  21. package/dist/types/src/capabilities/react-context.d.ts +8 -0
  22. package/dist/types/src/capabilities/react-context.d.ts.map +1 -0
  23. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  24. package/dist/types/src/capabilities/settings.d.ts.map +1 -1
  25. package/dist/types/src/components/Container.d.ts +2 -2
  26. package/dist/types/src/components/Container.d.ts.map +1 -1
  27. package/dist/types/src/components/DebugObjectPanel.d.ts +1 -2
  28. package/dist/types/src/components/DebugObjectPanel.d.ts.map +1 -1
  29. package/dist/types/src/components/DebugSettings.d.ts +1 -2
  30. package/dist/types/src/components/DebugSettings.d.ts.map +1 -1
  31. package/dist/types/src/components/DebugSpace/ObjectCreator.d.ts +1 -2
  32. package/dist/types/src/components/DebugSpace/ObjectCreator.d.ts.map +1 -1
  33. package/dist/types/src/components/DebugStatus.d.ts +1 -2
  34. package/dist/types/src/components/DebugStatus.d.ts.map +1 -1
  35. package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
  36. package/dist/types/src/components/SpaceGenerator/SchemaTable.d.ts +1 -2
  37. package/dist/types/src/components/SpaceGenerator/SchemaTable.d.ts.map +1 -1
  38. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts +1 -2
  39. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +1 -1
  40. package/dist/types/src/components/SpaceGenerator/presets.d.ts +22 -0
  41. package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -0
  42. package/dist/types/src/components/Wireframe.d.ts +1 -2
  43. package/dist/types/src/components/Wireframe.d.ts.map +1 -1
  44. package/dist/types/src/components/index.d.ts +1 -1
  45. package/dist/types/src/components/index.d.ts.map +1 -1
  46. package/dist/types/src/translations.d.ts +28 -0
  47. package/dist/types/src/translations.d.ts.map +1 -1
  48. package/dist/types/src/types.d.ts +44 -1
  49. package/dist/types/src/types.d.ts.map +1 -1
  50. package/package.json +50 -44
  51. package/src/DebugPlugin.tsx +12 -4
  52. package/src/capabilities/app-graph-builder.ts +292 -89
  53. package/src/capabilities/index.ts +1 -0
  54. package/src/capabilities/react-context.tsx +16 -0
  55. package/src/capabilities/react-surface.tsx +204 -27
  56. package/src/capabilities/settings.ts +0 -1
  57. package/src/components/DebugObjectPanel.tsx +17 -5
  58. package/src/components/DebugSettings.tsx +0 -3
  59. package/src/components/SpaceGenerator/ObjectGenerator.tsx +31 -4
  60. package/src/components/SpaceGenerator/SpaceGenerator.tsx +75 -6
  61. package/src/components/SpaceGenerator/presets.ts +563 -0
  62. package/src/translations.ts +28 -0
  63. package/src/types.ts +52 -1
  64. package/dist/lib/browser/SpaceGenerator-NJCG57CU.mjs +0 -279
  65. package/dist/lib/browser/SpaceGenerator-NJCG57CU.mjs.map +0 -7
  66. package/dist/lib/browser/app-graph-builder-66ZVNTDI.mjs +0 -182
  67. package/dist/lib/browser/app-graph-builder-66ZVNTDI.mjs.map +0 -7
  68. package/dist/lib/browser/chunk-P7GHHMDB.mjs +0 -21
  69. package/dist/lib/browser/chunk-P7GHHMDB.mjs.map +0 -7
  70. package/dist/lib/browser/react-surface-VEEFOGIM.mjs.map +0 -7
  71. /package/dist/lib/browser/{DebugSpace-4JHYA7FG.mjs.map → DebugSpace-BTMTVZ6C.mjs.map} +0 -0
@@ -1,279 +0,0 @@
1
- // packages/plugins/plugin-debug/src/components/SpaceGenerator/SpaceGenerator.tsx
2
- import React2, { useCallback, useMemo, useState } from "react";
3
- import { DocumentType as DocumentType2 } from "@dxos/plugin-markdown/types";
4
- import { SheetType as SheetType2 } from "@dxos/plugin-sheet/types";
5
- import { DiagramType as DiagramType2 } from "@dxos/plugin-sketch/types";
6
- import { useClient } from "@dxos/react-client";
7
- import { getTypename } from "@dxos/react-client/echo";
8
- import { IconButton as IconButton2, Input, Toolbar, useAsyncEffect } from "@dxos/react-ui";
9
- import { SyntaxHighlighter } from "@dxos/react-ui-syntax-highlighter";
10
- import { Testing } from "@dxos/schema/testing";
11
- import { jsonKeyReplacer, sortKeys } from "@dxos/util";
12
-
13
- // packages/plugins/plugin-debug/src/components/SpaceGenerator/ObjectGenerator.tsx
14
- import { addressToA1Notation } from "@dxos/compute";
15
- import { create, makeRef } from "@dxos/live-object";
16
- import { DocumentType } from "@dxos/plugin-markdown/types";
17
- import { createSheet } from "@dxos/plugin-sheet/types";
18
- import { SheetType } from "@dxos/plugin-sheet/types";
19
- import { CanvasType, DiagramType } from "@dxos/plugin-sketch/types";
20
- import { faker } from "@dxos/random";
21
- import { Filter } from "@dxos/react-client/echo";
22
- import { TableType } from "@dxos/react-ui-table";
23
- import { createView, TextType } from "@dxos/schema";
24
- import { createAsyncGenerator } from "@dxos/schema/testing";
25
- import { range } from "@dxos/util";
26
- var generator = faker;
27
- var staticGenerators = /* @__PURE__ */ new Map([
28
- [
29
- DocumentType.typename,
30
- async (space, n, cb) => {
31
- const objects = range(n).map(() => {
32
- const obj = space.db.add(create(DocumentType, {
33
- name: faker.commerce.productName(),
34
- content: makeRef(create(TextType, {
35
- content: faker.lorem.sentences(5)
36
- })),
37
- threads: []
38
- }));
39
- return obj;
40
- });
41
- cb?.(objects);
42
- return objects;
43
- }
44
- ],
45
- [
46
- DiagramType.typename,
47
- async (space, n, cb) => {
48
- const objects = range(n).map(() => {
49
- const obj = space.db.add(create(DiagramType, {
50
- name: faker.commerce.productName(),
51
- canvas: makeRef(create(CanvasType, {
52
- content: {}
53
- }))
54
- }));
55
- return obj;
56
- });
57
- cb?.(objects);
58
- return objects;
59
- }
60
- ],
61
- // TODO(burdon): Create unit tests.
62
- [
63
- SheetType.typename,
64
- async (space, n, cb) => {
65
- const objects = range(n).map(() => {
66
- const cells = {};
67
- const year = (/* @__PURE__ */ new Date()).getFullYear();
68
- const cols = 4;
69
- const rows = 16;
70
- for (let col = 1; col <= cols; col++) {
71
- for (let row = 1; row <= rows; row++) {
72
- const cell = addressToA1Notation({
73
- col,
74
- row
75
- });
76
- if (row === 1) {
77
- cells[cell] = {
78
- value: `${year} Q${col}`
79
- };
80
- } else if (row === rows) {
81
- const from = addressToA1Notation({
82
- col,
83
- row: 2
84
- });
85
- const to = addressToA1Notation({
86
- col,
87
- row: rows - 1
88
- });
89
- cells[cell] = {
90
- value: `=SUM(${from}:${to})`
91
- };
92
- } else if (row > 2 && row < rows - 1) {
93
- cells[cell] = {
94
- value: Math.floor(Math.random() * 1e4)
95
- };
96
- }
97
- }
98
- }
99
- return space.db.add(createSheet({
100
- name: faker.commerce.productName(),
101
- cells
102
- }));
103
- });
104
- cb?.(objects);
105
- return objects;
106
- }
107
- ]
108
- ]);
109
- var createGenerator = (type) => {
110
- return async (space, n, cb) => {
111
- const schema = await space.db.schemaRegistry.query({
112
- typename: type.typename
113
- }).firstOrUndefined() ?? (await space.db.schemaRegistry.register([
114
- type
115
- ]))[0];
116
- const generate = createAsyncGenerator(generator, schema.getSchemaSnapshot(), {
117
- db: space.db
118
- });
119
- const objects = await generate.createObjects(n);
120
- const { objects: tables } = await space.db.query(Filter.schema(TableType)).run();
121
- const table = tables.find((table2) => table2.view?.target?.query?.type === type.typename);
122
- if (!table) {
123
- const name = type.typename.split("/").pop() ?? type.typename;
124
- const view = createView({
125
- name,
126
- typename: type.typename,
127
- jsonSchema: schema.jsonSchema
128
- });
129
- const table2 = space.db.add(create(TableType, {
130
- name,
131
- view: makeRef(view)
132
- }));
133
- cb?.([
134
- table2
135
- ]);
136
- }
137
- return objects;
138
- };
139
- };
140
-
141
- // packages/plugins/plugin-debug/src/components/SpaceGenerator/SchemaTable.tsx
142
- import React from "react";
143
- import { IconButton } from "@dxos/react-ui";
144
- var SchemaTable = ({ types, objects = {}, label, onClick }) => {
145
- return /* @__PURE__ */ React.createElement("div", {
146
- className: "grid grid-cols-[1fr_80px_40px] gap-1 overflow-hidden"
147
- }, /* @__PURE__ */ React.createElement("div", {
148
- className: "grid grid-cols-subgrid col-span-3"
149
- }, /* @__PURE__ */ React.createElement("div", {
150
- className: "px-2 text-sm text-primary-500"
151
- }, label), /* @__PURE__ */ React.createElement("div", {
152
- className: "px-2 text-xs text-subdued text-right"
153
- }, "count")), types.map((type) => /* @__PURE__ */ React.createElement("div", {
154
- key: type.typename,
155
- className: "grid grid-cols-subgrid col-span-3 items-center"
156
- }, /* @__PURE__ */ React.createElement("div", {
157
- className: "px-2 text-sm font-mono text-green-500"
158
- }, type.typename), /* @__PURE__ */ React.createElement("div", {
159
- className: "px-2 text-right font-mono"
160
- }, objects[type.typename] ?? 0), /* @__PURE__ */ React.createElement(IconButton, {
161
- variant: "ghost",
162
- icon: "ph--plus--regular",
163
- iconOnly: true,
164
- label: "Create data",
165
- onClick: () => onClick(type.typename)
166
- }))));
167
- };
168
-
169
- // packages/plugins/plugin-debug/src/components/SpaceGenerator/SpaceGenerator.tsx
170
- var SpaceGenerator = ({ space, onCreateObjects }) => {
171
- const client = useClient();
172
- const staticTypes = [
173
- DocumentType2,
174
- DiagramType2,
175
- SheetType2
176
- ];
177
- const mutableTypes = [
178
- Testing.OrgType,
179
- Testing.ProjectType,
180
- Testing.ContactType
181
- ];
182
- const [count, setCount] = useState(1);
183
- const [info, setInfo] = useState({});
184
- const typeMap = useMemo(() => {
185
- client.addTypes(staticTypes);
186
- const mutableGenerators = new Map(mutableTypes.map((type) => [
187
- type.typename,
188
- createGenerator(type)
189
- ]));
190
- return new Map([
191
- ...staticGenerators,
192
- ...mutableGenerators
193
- ]);
194
- }, [
195
- client,
196
- mutableTypes
197
- ]);
198
- const updateInfo = async () => {
199
- const echoSchema = await space.db.schemaRegistry.query().run();
200
- const staticSchema = space.db.graph.schemaRegistry.schemas;
201
- const { objects } = await space.db.query().run();
202
- const objectMap = sortKeys(objects.reduce((map, obj) => {
203
- const type = getTypename(obj);
204
- if (type) {
205
- const count2 = map[type] ?? 0;
206
- map[type] = count2 + 1;
207
- }
208
- return map;
209
- }, {}));
210
- setInfo({
211
- schema: {
212
- static: staticSchema.length,
213
- mutable: echoSchema.length
214
- },
215
- objects: objectMap
216
- });
217
- };
218
- useAsyncEffect(updateInfo, [
219
- space
220
- ]);
221
- const handleCreateData = useCallback(async (typename) => {
222
- const constructor = typeMap.get(typename);
223
- if (constructor) {
224
- await constructor(space, count, onCreateObjects);
225
- await updateInfo();
226
- }
227
- }, [
228
- typeMap,
229
- count
230
- ]);
231
- return /* @__PURE__ */ React2.createElement("div", {
232
- role: "none",
233
- className: "flex flex-col divide-y divide-separator"
234
- }, /* @__PURE__ */ React2.createElement(Toolbar.Root, {
235
- classNames: "p-1"
236
- }, /* @__PURE__ */ React2.createElement(IconButton2, {
237
- icon: "ph--arrow-clockwise--regular",
238
- iconOnly: true,
239
- label: "Refresh",
240
- onClick: updateInfo
241
- }), /* @__PURE__ */ React2.createElement(Toolbar.Separator, {
242
- variant: "gap"
243
- }), /* @__PURE__ */ React2.createElement("div", {
244
- className: "flex"
245
- }, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.TextInput, {
246
- type: "number",
247
- min: 1,
248
- max: 100,
249
- placeholder: "Count",
250
- classNames: "w-[80px]",
251
- value: count,
252
- onChange: (ev) => setCount(parseInt(ev.target.value))
253
- })))), /* @__PURE__ */ React2.createElement(SchemaTable, {
254
- types: staticTypes,
255
- objects: info.objects,
256
- label: "Static Types",
257
- onClick: handleCreateData
258
- }), /* @__PURE__ */ React2.createElement(SchemaTable, {
259
- types: mutableTypes,
260
- objects: info.objects,
261
- label: "Mutable Types",
262
- onClick: handleCreateData
263
- }), /* @__PURE__ */ React2.createElement(SyntaxHighlighter, {
264
- classNames: "flex text-xs",
265
- language: "json"
266
- }, JSON.stringify({
267
- space,
268
- ...info
269
- }, jsonKeyReplacer({
270
- truncate: true
271
- }), 2)));
272
- };
273
-
274
- // packages/plugins/plugin-debug/src/components/SpaceGenerator/index.ts
275
- var SpaceGenerator_default = SpaceGenerator;
276
- export {
277
- SpaceGenerator_default as default
278
- };
279
- //# sourceMappingURL=SpaceGenerator-NJCG57CU.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/SpaceGenerator/SpaceGenerator.tsx", "../../../src/components/SpaceGenerator/ObjectGenerator.tsx", "../../../src/components/SpaceGenerator/SchemaTable.tsx", "../../../src/components/SpaceGenerator/index.ts"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback, useMemo, useState } from 'react';\n\nimport { type ReactiveObject } from '@dxos/live-object';\nimport { DocumentType } from '@dxos/plugin-markdown/types';\nimport { SheetType } from '@dxos/plugin-sheet/types';\nimport { DiagramType } from '@dxos/plugin-sketch/types';\nimport { useClient } from '@dxos/react-client';\nimport { getTypename, type Space } from '@dxos/react-client/echo';\nimport { IconButton, Input, Toolbar, useAsyncEffect } from '@dxos/react-ui';\nimport { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';\nimport { Testing } from '@dxos/schema/testing';\nimport { jsonKeyReplacer, sortKeys } from '@dxos/util';\n\nimport { type ObjectGenerator, createGenerator, staticGenerators } from './ObjectGenerator';\nimport { SchemaTable } from './SchemaTable';\n\nexport type SpaceGeneratorProps = {\n space: Space;\n onCreateObjects?: (objects: ReactiveObject<any>[]) => void;\n};\n\nexport const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps) => {\n const client = useClient();\n const staticTypes = [DocumentType, DiagramType, SheetType]; // TODO(burdon): Make extensible.\n const mutableTypes = [Testing.OrgType, Testing.ProjectType, Testing.ContactType];\n const [count, setCount] = useState(1);\n const [info, setInfo] = useState<any>({});\n\n // Create type generators.\n const typeMap = useMemo(() => {\n client.addTypes(staticTypes);\n const mutableGenerators = new Map<string, ObjectGenerator<any>>(\n mutableTypes.map((type) => [type.typename, createGenerator(type)]),\n );\n\n return new Map([...staticGenerators, ...mutableGenerators]);\n }, [client, mutableTypes]);\n\n // Query space to get info.\n const updateInfo = async () => {\n // Create schema map.\n const echoSchema = await space.db.schemaRegistry.query().run();\n const staticSchema = space.db.graph.schemaRegistry.schemas;\n\n // Create object map.\n const { objects } = await space.db.query().run();\n const objectMap = sortKeys(\n objects.reduce<Record<string, number>>((map, obj) => {\n const type = getTypename(obj);\n if (type) {\n const count = map[type] ?? 0;\n map[type] = count + 1;\n }\n return map;\n }, {}),\n );\n\n setInfo({\n schema: {\n static: staticSchema.length,\n mutable: echoSchema.length,\n },\n objects: objectMap,\n });\n };\n\n useAsyncEffect(updateInfo, [space]);\n\n const handleCreateData = useCallback(\n async (typename: string) => {\n const constructor = typeMap.get(typename);\n if (constructor) {\n // TODO(burdon): Input to specify number of objects.\n await constructor(space, count, onCreateObjects);\n await updateInfo();\n }\n },\n [typeMap, count],\n );\n\n return (\n <div role='none' className='flex flex-col divide-y divide-separator'>\n <Toolbar.Root classNames='p-1'>\n <IconButton icon='ph--arrow-clockwise--regular' iconOnly label='Refresh' onClick={updateInfo} />\n <Toolbar.Separator variant='gap' />\n <div className='flex'>\n <Input.Root>\n <Input.TextInput\n type='number'\n min={1}\n max={100}\n placeholder={'Count'}\n classNames='w-[80px]'\n value={count}\n onChange={(ev) => setCount(parseInt(ev.target.value))}\n />\n </Input.Root>\n </div>\n </Toolbar.Root>\n\n <SchemaTable types={staticTypes} objects={info.objects} label='Static Types' onClick={handleCreateData} />\n <SchemaTable types={mutableTypes} objects={info.objects} label='Mutable Types' onClick={handleCreateData} />\n\n <SyntaxHighlighter classNames='flex text-xs' language='json'>\n {JSON.stringify({ space, ...info }, jsonKeyReplacer({ truncate: true }), 2)}\n </SyntaxHighlighter>\n </div>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { addressToA1Notation } from '@dxos/compute';\nimport { type BaseObject, type TypedObject } from '@dxos/echo-schema';\nimport { create, makeRef, type ReactiveObject } from '@dxos/live-object';\nimport { DocumentType } from '@dxos/plugin-markdown/types';\nimport { createSheet } from '@dxos/plugin-sheet/types';\nimport { SheetType, type CellValue } from '@dxos/plugin-sheet/types';\nimport { CanvasType, DiagramType } from '@dxos/plugin-sketch/types';\nimport { faker } from '@dxos/random';\nimport { Filter, type Space } from '@dxos/react-client/echo';\nimport { TableType } from '@dxos/react-ui-table';\nimport { createView, TextType } from '@dxos/schema';\nimport { createAsyncGenerator, type ValueGenerator } from '@dxos/schema/testing';\nimport { range } from '@dxos/util';\n\nconst generator: ValueGenerator = faker as any;\n\n// TODO(burdon): Add objects to collections.\n// TODO(burdon): Create docs.\n// TODO(burdon): Create sketches.\n// TODO(burdon): Create sheets.\n// TODO(burdon): Create comments.\n// TODO(burdon): Reuse in testbench-app.\n// TODO(burdon): Mutator running in background (factor out): from echo-generator.\n\nexport type ObjectGenerator<T extends BaseObject> = (\n space: Space,\n n: number,\n cb?: (objects: ReactiveObject<any>[]) => void,\n) => Promise<ReactiveObject<T>[]>;\n\nexport const staticGenerators = new Map<string, ObjectGenerator<any>>([\n [\n DocumentType.typename,\n async (space, n, cb) => {\n const objects = range(n).map(() => {\n const obj = space.db.add(\n create(DocumentType, {\n name: faker.commerce.productName(),\n content: makeRef(create(TextType, { content: faker.lorem.sentences(5) })),\n threads: [],\n }),\n );\n\n return obj;\n });\n\n cb?.(objects);\n return objects;\n },\n ],\n [\n DiagramType.typename,\n async (space, n, cb) => {\n const objects = range(n).map(() => {\n // TODO(burdon): Generate diagram.\n const obj = space.db.add(\n create(DiagramType, {\n name: faker.commerce.productName(),\n canvas: makeRef(create(CanvasType, { content: {} })),\n }),\n );\n\n return obj;\n });\n\n cb?.(objects);\n return objects;\n },\n ],\n // TODO(burdon): Create unit tests.\n [\n SheetType.typename,\n async (space, n, cb) => {\n const objects = range(n).map(() => {\n const cells: Record<string, CellValue> = {};\n const year = new Date().getFullYear();\n const cols = 4;\n const rows = 16;\n for (let col = 1; col <= cols; col++) {\n for (let row = 1; row <= rows; row++) {\n const cell = addressToA1Notation({ col, row });\n if (row === 1) {\n cells[cell] = { value: `${year} Q${col}` };\n } else if (row === rows) {\n const from = addressToA1Notation({ col, row: 2 });\n const to = addressToA1Notation({ col, row: rows - 1 });\n cells[cell] = { value: `=SUM(${from}:${to})` };\n } else if (row > 2 && row < rows - 1) {\n cells[cell] = { value: Math.floor(Math.random() * 10_000) };\n }\n }\n }\n\n // TODO(burdon): Set width.\n // TODO(burdon): Set formatting for columns.\n return space.db.add(\n createSheet({\n name: faker.commerce.productName(),\n cells,\n }),\n );\n });\n\n cb?.(objects);\n return objects;\n },\n ],\n]);\n\nexport const createGenerator = <T extends BaseObject>(type: TypedObject<T>): ObjectGenerator<T> => {\n return async (\n space: Space,\n n: number,\n cb?: (objects: ReactiveObject<any>[]) => void,\n ): Promise<ReactiveObject<T>[]> => {\n // Find or create mutable schema.\n const schema =\n (await space.db.schemaRegistry.query({ typename: type.typename }).firstOrUndefined()) ??\n (await space.db.schemaRegistry.register([type]))[0];\n\n // Create objects.\n const generate = createAsyncGenerator(generator, schema.getSchemaSnapshot(), { db: space.db });\n const objects = await generate.createObjects(n);\n\n // Find or create table and view.\n const { objects: tables } = await space.db.query(Filter.schema(TableType)).run();\n const table = tables.find((table) => table.view?.target?.query?.type === type.typename);\n if (!table) {\n const name = type.typename.split('/').pop() ?? type.typename;\n const view = createView({ name, typename: type.typename, jsonSchema: schema.jsonSchema });\n const table = space.db.add(create(TableType, { name, view: makeRef(view) }));\n cb?.([table]);\n }\n\n return objects;\n };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { IconButton } from '@dxos/react-ui';\n\nexport type SchemaTableProps = {\n types: any[];\n objects?: Record<string, number | undefined>;\n label: string;\n onClick: (typename: string) => void;\n};\n\nexport const SchemaTable = ({ types, objects = {}, label, onClick }: SchemaTableProps) => {\n return (\n <div className='grid grid-cols-[1fr_80px_40px] gap-1 overflow-hidden'>\n <div className='grid grid-cols-subgrid col-span-3'>\n <div className='px-2 text-sm text-primary-500'>{label}</div>\n <div className='px-2 text-xs text-subdued text-right'>count</div>\n </div>\n {types.map((type) => (\n <div key={type.typename} className='grid grid-cols-subgrid col-span-3 items-center'>\n <div className='px-2 text-sm font-mono text-green-500'>{type.typename}</div>\n <div className='px-2 text-right font-mono'>{objects[type.typename] ?? 0}</div>\n <IconButton\n variant='ghost'\n icon='ph--plus--regular'\n iconOnly\n label='Create data'\n onClick={() => onClick(type.typename)}\n />\n </div>\n ))}\n </div>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\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ASyB,OAAM;IAAeC,SAASf;MACtF,gBAAAI,OAAA,cAACwB,aAAAA;IAAYC,OAAOrE;IAAc6B,SAASrB,KAAKqB;IAASyB,OAAM;IAAgBC,SAASf;MAExF,gBAAAI,OAAA,cAAC0B,mBAAAA;IAAkBpB,YAAW;IAAeqB,UAAS;KACnDC,KAAKC,UAAU;IAAEjF;IAAO,GAAGgB;EAAK,GAAGkE,gBAAgB;IAAEC,UAAU;EAAK,CAAA,GAAI,CAAA,CAAA,CAAA;AAIjF;;;AG1GA,IAAA,yBAAeC;",
6
- "names": ["React", "useCallback", "useMemo", "useState", "DocumentType", "SheetType", "DiagramType", "useClient", "getTypename", "IconButton", "Input", "Toolbar", "useAsyncEffect", "SyntaxHighlighter", "Testing", "jsonKeyReplacer", "sortKeys", "addressToA1Notation", "create", "makeRef", "DocumentType", "createSheet", "SheetType", "CanvasType", "DiagramType", "faker", "Filter", "TableType", "createView", "TextType", "createAsyncGenerator", "range", "generator", "faker", "staticGenerators", "Map", "DocumentType", "typename", "space", "n", "cb", "objects", "range", "map", "obj", "db", "add", "create", "name", "commerce", "productName", "content", "makeRef", "TextType", "lorem", "sentences", "threads", "DiagramType", "canvas", "CanvasType", "SheetType", "cells", "year", "Date", "getFullYear", "cols", "rows", "col", "row", "cell", "addressToA1Notation", "value", "from", "to", "Math", "floor", "random", "createSheet", "createGenerator", "type", "schema", "schemaRegistry", "query", "firstOrUndefined", "register", "generate", "createAsyncGenerator", "getSchemaSnapshot", "createObjects", "tables", "Filter", "TableType", "run", "table", "find", "view", "target", "split", "pop", "createView", "jsonSchema", "React", "IconButton", "SchemaTable", "types", "objects", "label", "onClick", "div", "className", "map", "type", "key", "typename", "IconButton", "variant", "icon", "iconOnly", "SpaceGenerator", "space", "onCreateObjects", "client", "useClient", "staticTypes", "DocumentType", "DiagramType", "SheetType", "mutableTypes", "Testing", "OrgType", "ProjectType", "ContactType", "count", "setCount", "useState", "info", "setInfo", "typeMap", "useMemo", "addTypes", "mutableGenerators", "Map", "map", "type", "typename", "createGenerator", "staticGenerators", "updateInfo", "echoSchema", "db", "schemaRegistry", "query", "run", "staticSchema", "graph", "schemas", "objects", "objectMap", "sortKeys", "reduce", "obj", "getTypename", "schema", "static", "length", "mutable", "useAsyncEffect", "handleCreateData", "useCallback", "constructor", "get", "React", "div", "role", "className", "Toolbar", "Root", "classNames", "IconButton", "icon", "iconOnly", "label", "onClick", "Separator", "variant", "Input", "TextInput", "min", "max", "placeholder", "value", "onChange", "ev", "parseInt", "target", "SchemaTable", "types", "SyntaxHighlighter", "language", "JSON", "stringify", "jsonKeyReplacer", "truncate", "SpaceGenerator"]
7
- }
@@ -1,182 +0,0 @@
1
- import {
2
- DEBUG_PLUGIN
3
- } from "./chunk-EF3UVAVI.mjs";
4
-
5
- // packages/plugins/plugin-debug/src/capabilities/app-graph-builder.ts
6
- import { contributes, Capabilities } from "@dxos/app-framework";
7
- import { ClientCapabilities } from "@dxos/plugin-client";
8
- import { createExtension, toSignal } from "@dxos/plugin-graph";
9
- import { memoizeQuery } from "@dxos/plugin-space";
10
- import { CollectionType } from "@dxos/plugin-space/types";
11
- import { getTypename, parseId, SpaceState } from "@dxos/react-client/echo";
12
- import { isSpace } from "@dxos/react-client/echo";
13
- var app_graph_builder_default = (context) => {
14
- const resolve = (typename) => context.requestCapabilities(Capabilities.Metadata).find(({ id }) => id === typename)?.metadata ?? {};
15
- return contributes(Capabilities.AppGraphBuilder, [
16
- // Devtools node.
17
- createExtension({
18
- id: "dxos.org/plugin/debug/devtools",
19
- filter: (node) => {
20
- const settings = context.requestCapabilities(Capabilities.SettingsStore)[0]?.getStore(DEBUG_PLUGIN)?.value;
21
- return !!settings?.devtools && node.id === "root";
22
- },
23
- connector: () => [
24
- {
25
- // TODO(zan): Removed `/` because it breaks deck layout reload. Fix?
26
- id: "dxos.org.plugin.debug.devtools",
27
- data: "devtools",
28
- type: "dxos.org/plugin/debug/devtools",
29
- properties: {
30
- label: [
31
- "devtools label",
32
- {
33
- ns: DEBUG_PLUGIN
34
- }
35
- ],
36
- disposition: "navigation",
37
- icon: "ph--hammer--regular"
38
- }
39
- }
40
- ]
41
- }),
42
- // Debug node.
43
- createExtension({
44
- id: "dxos.org/plugin/debug/debug",
45
- filter: (node) => {
46
- const settings = context.requestCapabilities(Capabilities.SettingsStore)[0]?.getStore(DEBUG_PLUGIN)?.value;
47
- return !!settings?.debug && node.id === "root";
48
- },
49
- connector: () => {
50
- const [graph] = context.requestCapabilities(Capabilities.AppGraph);
51
- if (!graph) {
52
- return;
53
- }
54
- return [
55
- {
56
- id: "dxos.org/plugin/debug/debug",
57
- type: "dxos.org/plugin/debug/debug",
58
- data: {
59
- graph
60
- },
61
- properties: {
62
- label: [
63
- "debug label",
64
- {
65
- ns: DEBUG_PLUGIN
66
- }
67
- ],
68
- disposition: "navigation",
69
- icon: "ph--bug--regular"
70
- }
71
- }
72
- ];
73
- }
74
- }),
75
- // Space debug nodes.
76
- createExtension({
77
- id: "dxos.org/plugin/debug/spaces",
78
- filter: (node) => {
79
- const settings = context.requestCapabilities(Capabilities.SettingsStore)[0]?.getStore(DEBUG_PLUGIN)?.value;
80
- return !!settings?.debug && isSpace(node.data);
81
- },
82
- connector: ({ node }) => {
83
- const space = node.data;
84
- const state = toSignal((onChange) => space.state.subscribe(() => onChange()).unsubscribe, () => space.state.get(), space.id);
85
- if (state !== SpaceState.SPACE_READY) {
86
- return;
87
- }
88
- const collection = space.properties[CollectionType.typename]?.target;
89
- if (!collection) {
90
- return;
91
- }
92
- return [
93
- {
94
- id: `${space.id}-debug`,
95
- type: "dxos.org/plugin/debug/space",
96
- data: {
97
- space,
98
- type: "dxos.org/plugin/debug/space"
99
- },
100
- properties: {
101
- label: [
102
- "debug label",
103
- {
104
- ns: DEBUG_PLUGIN
105
- }
106
- ],
107
- icon: "ph--bug--regular"
108
- }
109
- }
110
- ];
111
- }
112
- }),
113
- // Create nodes for debug sidebar.
114
- createExtension({
115
- id: `${DEBUG_PLUGIN}/debug-for-subject`,
116
- resolver: ({ id }) => {
117
- if (!id.endsWith("~debug")) {
118
- return;
119
- }
120
- const type = "orphan-settings-for-subject";
121
- const icon = "ph--bug--regular";
122
- const client = context.requestCapability(ClientCapabilities.Client);
123
- const [subjectId] = id.split("~");
124
- const { spaceId, objectId } = parseId(subjectId);
125
- const spaces = toSignal((onChange) => client.spaces.subscribe(() => onChange()).unsubscribe, () => client.spaces.get());
126
- const space = spaces?.find((space2) => space2.state.get() === SpaceState.SPACE_READY && space2.id === spaceId);
127
- if (!objectId) {
128
- const label2 = space ? space.properties.name || [
129
- "unnamed space label",
130
- {
131
- ns: DEBUG_PLUGIN
132
- }
133
- ] : [
134
- "unnamed object settings label",
135
- {
136
- ns: DEBUG_PLUGIN
137
- }
138
- ];
139
- return {
140
- id,
141
- type,
142
- data: null,
143
- properties: {
144
- icon,
145
- label: label2,
146
- showResolvedThreads: false,
147
- object: null,
148
- space
149
- }
150
- };
151
- }
152
- const [object] = memoizeQuery(space, {
153
- id: objectId
154
- });
155
- if (!object || !subjectId) {
156
- return;
157
- }
158
- const meta = resolve(getTypename(object) ?? "");
159
- const label = meta.label?.(object) || object.name || meta.placeholder || [
160
- "unnamed object settings label",
161
- {
162
- ns: DEBUG_PLUGIN
163
- }
164
- ];
165
- return {
166
- id,
167
- type,
168
- data: null,
169
- properties: {
170
- icon,
171
- label,
172
- object
173
- }
174
- };
175
- }
176
- })
177
- ]);
178
- };
179
- export {
180
- app_graph_builder_default as default
181
- };
182
- //# sourceMappingURL=app-graph-builder-66ZVNTDI.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/app-graph-builder.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { contributes, Capabilities, type PluginsContext } from '@dxos/app-framework';\nimport { ClientCapabilities } from '@dxos/plugin-client';\nimport { createExtension, toSignal, type Node } from '@dxos/plugin-graph';\nimport { memoizeQuery } from '@dxos/plugin-space';\nimport { CollectionType } from '@dxos/plugin-space/types';\nimport { getTypename, parseId, SpaceState } from '@dxos/react-client/echo';\nimport { isSpace, type Space } from '@dxos/react-client/echo';\n\nimport { DEBUG_PLUGIN } from '../meta';\nimport { type DebugSettingsProps } from '../types';\n\nexport default (context: PluginsContext) => {\n const resolve = (typename: string) =>\n context.requestCapabilities(Capabilities.Metadata).find(({ id }) => id === typename)?.metadata ?? {};\n\n return contributes(Capabilities.AppGraphBuilder, [\n // Devtools node.\n createExtension({\n id: 'dxos.org/plugin/debug/devtools',\n filter: (node): node is Node<null> => {\n const settings = context\n .requestCapabilities(Capabilities.SettingsStore)[0]\n ?.getStore<DebugSettingsProps>(DEBUG_PLUGIN)?.value;\n return !!settings?.devtools && node.id === 'root';\n },\n connector: () => [\n {\n // TODO(zan): Removed `/` because it breaks deck layout reload. Fix?\n id: 'dxos.org.plugin.debug.devtools',\n data: 'devtools',\n type: 'dxos.org/plugin/debug/devtools',\n properties: {\n label: ['devtools label', { ns: DEBUG_PLUGIN }],\n disposition: 'navigation',\n icon: 'ph--hammer--regular',\n },\n },\n ],\n }),\n\n // Debug node.\n createExtension({\n id: 'dxos.org/plugin/debug/debug',\n filter: (node): node is Node<null> => {\n const settings = context\n .requestCapabilities(Capabilities.SettingsStore)[0]\n ?.getStore<DebugSettingsProps>(DEBUG_PLUGIN)?.value;\n return !!settings?.debug && node.id === 'root';\n },\n connector: () => {\n const [graph] = context.requestCapabilities(Capabilities.AppGraph);\n if (!graph) {\n return;\n }\n\n return [\n {\n id: 'dxos.org/plugin/debug/debug',\n type: 'dxos.org/plugin/debug/debug',\n data: { graph },\n properties: {\n label: ['debug label', { ns: DEBUG_PLUGIN }],\n disposition: 'navigation',\n icon: 'ph--bug--regular',\n },\n },\n ];\n },\n }),\n\n // Space debug nodes.\n createExtension({\n id: 'dxos.org/plugin/debug/spaces',\n filter: (node): node is Node<Space> => {\n const settings = context\n .requestCapabilities(Capabilities.SettingsStore)[0]\n ?.getStore<DebugSettingsProps>(DEBUG_PLUGIN)?.value;\n return !!settings?.debug && isSpace(node.data);\n },\n connector: ({ node }) => {\n const space = node.data;\n const state = toSignal(\n (onChange) => space.state.subscribe(() => onChange()).unsubscribe,\n () => space.state.get(),\n space.id,\n );\n if (state !== SpaceState.SPACE_READY) {\n return;\n }\n\n // Not adding the debug node until the root collection is available aligns the behaviour of this\n // extension with that of the space plugin adding objects. This ensures that the debug node is added at\n // the same time as objects and prevents order from changing as the nodes are added.\n const collection = space.properties[CollectionType.typename]?.target as CollectionType | undefined;\n if (!collection) {\n return;\n }\n\n return [\n {\n id: `${space.id}-debug`, // TODO(burdon): Change to slashes consistently.\n type: 'dxos.org/plugin/debug/space',\n data: { space, type: 'dxos.org/plugin/debug/space' },\n properties: {\n label: ['debug label', { ns: DEBUG_PLUGIN }],\n icon: 'ph--bug--regular',\n },\n },\n ];\n },\n }),\n\n // Create nodes for debug sidebar.\n createExtension({\n id: `${DEBUG_PLUGIN}/debug-for-subject`,\n resolver: ({ id }) => {\n // TODO(Zan): Find util (or make one).\n if (!id.endsWith('~debug')) {\n return;\n }\n\n const type = 'orphan-settings-for-subject';\n const icon = 'ph--bug--regular';\n\n const client = context.requestCapability(ClientCapabilities.Client);\n const [subjectId] = id.split('~');\n const { spaceId, objectId } = parseId(subjectId);\n const spaces = toSignal(\n (onChange) => client.spaces.subscribe(() => onChange()).unsubscribe,\n () => client.spaces.get(),\n );\n const space = spaces?.find((space) => space.state.get() === SpaceState.SPACE_READY && space.id === spaceId);\n if (!objectId) {\n // TODO(burdon): Ref SPACE_PLUGIN ns.\n const label = space\n ? space.properties.name || ['unnamed space label', { ns: DEBUG_PLUGIN }]\n : ['unnamed object settings label', { ns: DEBUG_PLUGIN }];\n\n // TODO(wittjosiah): Support comments for arbitrary subjects.\n // This is to ensure that the comments panel is not stuck on an old object.\n return {\n id,\n type,\n data: null,\n properties: {\n icon,\n label,\n showResolvedThreads: false,\n object: null,\n space,\n },\n };\n }\n\n const [object] = memoizeQuery(space, { id: objectId });\n if (!object || !subjectId) {\n return;\n }\n\n const meta = resolve(getTypename(object) ?? '');\n const label = meta.label?.(object) ||\n object.name ||\n meta.placeholder || ['unnamed object settings label', { ns: DEBUG_PLUGIN }];\n\n return {\n id,\n type,\n data: null,\n properties: {\n icon,\n label,\n object,\n },\n };\n },\n }),\n ]);\n};\n"],
5
- "mappings": ";;;;;AAIA,SAASA,aAAaC,oBAAyC;AAC/D,SAASC,0BAA0B;AACnC,SAASC,iBAAiBC,gBAA2B;AACrD,SAASC,oBAAoB;AAC7B,SAASC,sBAAsB;AAC/B,SAASC,aAAaC,SAASC,kBAAkB;AACjD,SAASC,eAA2B;AAKpC,IAAA,4BAAe,CAACC,YAAAA;AACd,QAAMC,UAAU,CAACC,aACfF,QAAQG,oBAAoBC,aAAaC,QAAQ,EAAEC,KAAK,CAAC,EAAEC,GAAE,MAAOA,OAAOL,QAAAA,GAAWM,YAAY,CAAC;AAErG,SAAOC,YAAYL,aAAaM,iBAAiB;;IAE/CC,gBAAgB;MACdJ,IAAI;MACJK,QAAQ,CAACC,SAAAA;AACP,cAAMC,WAAWd,QACdG,oBAAoBC,aAAaW,aAAa,EAAE,CAAA,GAC/CC,SAA6BC,YAAAA,GAAeC;AAChD,eAAO,CAAC,CAACJ,UAAUK,YAAYN,KAAKN,OAAO;MAC7C;MACAa,WAAW,MAAM;QACf;;UAEEb,IAAI;UACJc,MAAM;UACNC,MAAM;UACNC,YAAY;YACVC,OAAO;cAAC;cAAkB;gBAAEC,IAAIR;cAAa;;YAC7CS,aAAa;YACbC,MAAM;UACR;QACF;;IAEJ,CAAA;;IAGAhB,gBAAgB;MACdJ,IAAI;MACJK,QAAQ,CAACC,SAAAA;AACP,cAAMC,WAAWd,QACdG,oBAAoBC,aAAaW,aAAa,EAAE,CAAA,GAC/CC,SAA6BC,YAAAA,GAAeC;AAChD,eAAO,CAAC,CAACJ,UAAUc,SAASf,KAAKN,OAAO;MAC1C;MACAa,WAAW,MAAA;AACT,cAAM,CAACS,KAAAA,I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AAS9C,QAAQ+C,kBAAkBC,mBAAmBC,MAAM;AAClE,cAAM,CAACC,SAAAA,IAAa3C,GAAG4C,MAAM,GAAA;AAC7B,cAAM,EAAEC,SAASC,SAAQ,IAAKC,QAAQJ,SAAAA;AACtC,cAAMK,SAASrB,SACb,CAACC,aAAaW,OAAOS,OAAOnB,UAAU,MAAMD,SAAAA,CAAAA,EAAYE,aACxD,MAAMS,OAAOS,OAAOjB,IAAG,CAAA;AAEzB,cAAMN,QAAQuB,QAAQjD,KAAK,CAAC0B,WAAUA,OAAMC,MAAMK,IAAG,MAAOC,WAAWC,eAAeR,OAAMzB,OAAO6C,OAAAA;AACnG,YAAI,CAACC,UAAU;AAEb,gBAAM7B,SAAQQ,QACVA,MAAMT,WAAWiC,QAAQ;YAAC;YAAuB;cAAE/B,IAAIR;YAAa;cACpE;YAAC;YAAiC;cAAEQ,IAAIR;YAAa;;AAIzD,iBAAO;YACLV;YACAe;YACAD,MAAM;YACNE,YAAY;cACVI;cACAH,OAAAA;cACAiC,qBAAqB;cACrBC,QAAQ;cACR1B;YACF;UACF;QACF;AAEA,cAAM,CAAC0B,MAAAA,IAAUC,aAAa3B,OAAO;UAAEzB,IAAI8C;QAAS,CAAA;AACpD,YAAI,CAACK,UAAU,CAACR,WAAW;AACzB;QACF;AAEA,cAAMU,OAAO3D,QAAQ4D,YAAYH,MAAAA,KAAW,EAAA;AAC5C,cAAMlC,QAAQoC,KAAKpC,QAAQkC,MAAAA,KACzBA,OAAOF,QACPI,KAAKE,eAAe;UAAC;UAAiC;YAAErC,IAAIR;UAAa;;AAE3E,eAAO;UACLV;UACAe;UACAD,MAAM;UACNE,YAAY;YACVI;YACAH;YACAkC;UACF;QACF;MACF;IACF,CAAA;GACD;AACH;",
6
- "names": ["contributes", "Capabilities", "ClientCapabilities", "createExtension", "toSignal", "memoizeQuery", "CollectionType", "getTypename", "parseId", "SpaceState", "isSpace", "context", "resolve", "typename", "requestCapabilities", "Capabilities", "Metadata", "find", "id", "metadata", "contributes", "AppGraphBuilder", "createExtension", "filter", "node", "settings", "SettingsStore", "getStore", "DEBUG_PLUGIN", "value", "devtools", "connector", "data", "type", "properties", "label", "ns", "disposition", "icon", "debug", "graph", "AppGraph", "isSpace", "space", "state", "toSignal", "onChange", "subscribe", "unsubscribe", "get", "SpaceState", "SPACE_READY", "collection", "CollectionType", "target", "resolver", "endsWith", "client", "requestCapability", "ClientCapabilities", "Client", "subjectId", "split", "spaceId", "objectId", "parseId", "spaces", "name", "showResolvedThreads", "object", "memoizeQuery", "meta", "getTypename", "placeholder"]
7
- }
@@ -1,21 +0,0 @@
1
- // packages/plugins/plugin-debug/src/types.ts
2
- import { createContext } from "react";
3
- import { S } from "@dxos/echo-schema";
4
- var DebugContext = createContext({
5
- running: false,
6
- start: () => {
7
- },
8
- stop: () => {
9
- }
10
- });
11
- var DebugSettingsSchema = S.mutable(S.Struct({
12
- devtools: S.optional(S.Boolean),
13
- debug: S.optional(S.Boolean),
14
- wireframe: S.optional(S.Boolean)
15
- }));
16
-
17
- export {
18
- DebugContext,
19
- DebugSettingsSchema
20
- };
21
- //# sourceMappingURL=chunk-P7GHHMDB.mjs.map
@@ -1,7 +0,0 @@
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 { TimerCallback, TimerOptions } from '@dxos/async';\nimport { S } from '@dxos/echo-schema';\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"],
5
- "mappings": ";AAIA,SAAuBA,qBAAqB;AAG5C,SAASC,SAAS;AAQX,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", "DebugContext", "createContext", "running", "start", "stop", "DebugSettingsSchema", "S", "mutable", "Struct", "devtools", "optional", "Boolean", "debug", "wireframe"]
7
- }