@dxos/plugin-explorer 0.8.4-main.28f8d3d → 0.8.4-main.406dc2a
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/ExplorerContainer-6SHZJ6AK.mjs +50 -0
- package/dist/lib/browser/ExplorerContainer-6SHZJ6AK.mjs.map +7 -0
- package/dist/lib/browser/{chunk-UL5EDJPE.mjs → chunk-2DGFNLRO.mjs} +2 -4
- package/dist/lib/browser/chunk-2DGFNLRO.mjs.map +7 -0
- package/dist/lib/browser/chunk-BZ65T5M3.mjs +79 -0
- package/dist/lib/browser/chunk-BZ65T5M3.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/{chunk-LGK64HLU.mjs → chunk-MOM5KCKC.mjs} +258 -6
- package/dist/lib/browser/{chunk-LGK64HLU.mjs.map → chunk-MOM5KCKC.mjs.map} +3 -3
- package/dist/lib/browser/{chunk-L4U4MPSZ.mjs → chunk-NXGP6NTP.mjs} +28 -15
- package/dist/lib/browser/chunk-NXGP6NTP.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +23 -17
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/intent-resolver-K57C3LIX.mjs +31 -0
- package/dist/lib/browser/intent-resolver-K57C3LIX.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +2 -3
- package/dist/lib/browser/react-surface-OPBND5W3.mjs +35 -0
- package/dist/lib/browser/react-surface-OPBND5W3.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +7 -6
- package/dist/lib/node-esm/{ExplorerContainer-AMYAVLO4.mjs → ExplorerContainer-FRTDXZI5.mjs} +19 -6
- package/dist/lib/node-esm/ExplorerContainer-FRTDXZI5.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-MCOXQ3ML.mjs → chunk-6JACZE7E.mjs} +28 -15
- package/dist/lib/node-esm/chunk-6JACZE7E.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ES6AOMCY.mjs +80 -0
- package/dist/lib/node-esm/chunk-ES6AOMCY.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-PIAXA43R.mjs → chunk-PX6LHR2N.mjs} +2 -4
- package/dist/lib/node-esm/chunk-PX6LHR2N.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-W4ZNCGOD.mjs → chunk-ZCV4U7LT.mjs} +258 -6
- package/dist/lib/node-esm/{chunk-W4ZNCGOD.mjs.map → chunk-ZCV4U7LT.mjs.map} +3 -3
- package/dist/lib/node-esm/index.mjs +23 -17
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/intent-resolver-BLPPTTEY.mjs +32 -0
- package/dist/lib/node-esm/intent-resolver-BLPPTTEY.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/meta.mjs +2 -3
- package/dist/lib/node-esm/react-surface-HCKQSHKJ.mjs +36 -0
- package/dist/lib/node-esm/react-surface-HCKQSHKJ.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +7 -6
- package/dist/types/src/ExplorerPlugin.d.ts +1 -1
- package/dist/types/src/ExplorerPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +2 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +2 -2
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/Chart/Chart.stories.d.ts +8 -4
- package/dist/types/src/components/Chart/Chart.stories.d.ts.map +1 -1
- package/dist/types/src/components/ExplorerContainer.d.ts +2 -2
- package/dist/types/src/components/ExplorerContainer.d.ts.map +1 -1
- package/dist/types/src/components/Globe/Globe.stories.d.ts +8 -4
- package/dist/types/src/components/Globe/Globe.stories.d.ts.map +1 -1
- package/dist/types/src/components/Graph/D3ForceGraph.d.ts +2 -2
- package/dist/types/src/components/Graph/D3ForceGraph.d.ts.map +1 -1
- package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts +13 -4
- package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts.map +1 -1
- package/dist/types/src/components/Graph/ForceGraph.stories.d.ts +13 -4
- package/dist/types/src/components/Graph/ForceGraph.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tree/Tree.stories.d.ts +13 -16
- package/dist/types/src/components/Tree/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tree/types/tree.d.ts +1 -1
- package/dist/types/src/components/Tree/types/tree.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/meta.d.ts +0 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +14 -2
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/ExplorerAction.d.ts +23 -0
- package/dist/types/src/types/ExplorerAction.d.ts.map +1 -0
- package/dist/types/src/types/Graph.d.ts +33 -0
- package/dist/types/src/types/Graph.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +37 -36
- package/src/ExplorerPlugin.tsx +47 -46
- package/src/capabilities/intent-resolver.ts +10 -8
- package/src/capabilities/react-surface.tsx +9 -5
- package/src/components/Chart/Chart.stories.tsx +7 -6
- package/src/components/ExplorerContainer.tsx +22 -5
- package/src/components/Globe/Globe.stories.tsx +11 -10
- package/src/components/Graph/D3ForceGraph.stories.tsx +28 -16
- package/src/components/Graph/D3ForceGraph.tsx +4 -4
- package/src/components/Graph/ForceGraph.stories.tsx +28 -16
- package/src/components/Graph/ForceGraph.tsx +3 -3
- package/src/components/Tree/Tree.stories.tsx +27 -21
- package/src/components/Tree/Tree.tsx +2 -2
- package/src/components/Tree/types/tree.ts +1 -1
- package/src/meta.ts +1 -3
- package/src/translations.ts +4 -2
- package/src/types/ExplorerAction.ts +29 -0
- package/src/types/Graph.ts +45 -0
- package/src/types/index.ts +2 -2
- package/dist/lib/browser/ExplorerContainer-5QHLD2B2.mjs +0 -37
- package/dist/lib/browser/ExplorerContainer-5QHLD2B2.mjs.map +0 -7
- package/dist/lib/browser/chunk-CZZ3DDR7.mjs +0 -38
- package/dist/lib/browser/chunk-CZZ3DDR7.mjs.map +0 -7
- package/dist/lib/browser/chunk-L4U4MPSZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-UL5EDJPE.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-7MVEYNX7.mjs +0 -24
- package/dist/lib/browser/intent-resolver-7MVEYNX7.mjs.map +0 -7
- package/dist/lib/browser/react-surface-FABRDFTF.mjs +0 -31
- package/dist/lib/browser/react-surface-FABRDFTF.mjs.map +0 -7
- package/dist/lib/node-esm/ExplorerContainer-AMYAVLO4.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4GWDNZ4Z.mjs +0 -39
- package/dist/lib/node-esm/chunk-4GWDNZ4Z.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MCOXQ3ML.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-PIAXA43R.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-NL3SR2XF.mjs +0 -25
- package/dist/lib/node-esm/intent-resolver-NL3SR2XF.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-EYCZUAAI.mjs +0 -32
- package/dist/lib/node-esm/react-surface-EYCZUAAI.mjs.map +0 -7
- package/dist/types/src/types/schema.d.ts +0 -12
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/dist/types/src/types/types.d.ts +0 -18
- package/dist/types/src/types/types.d.ts.map +0 -1
- package/src/types/schema.ts +0 -16
- package/src/types/types.ts +0 -22
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useGraphModel
|
|
3
|
+
} from "./chunk-2MKBRIUT.mjs";
|
|
4
|
+
import {
|
|
5
|
+
D3ForceGraph
|
|
6
|
+
} from "./chunk-NXGP6NTP.mjs";
|
|
7
|
+
import "./chunk-J5LGTIGS.mjs";
|
|
8
|
+
|
|
9
|
+
// src/components/ExplorerContainer.tsx
|
|
10
|
+
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
11
|
+
import React, { useCallback, useMemo, useState } from "react";
|
|
12
|
+
import { QueryBuilder } from "@dxos/echo-query";
|
|
13
|
+
import { useGlobalSearch } from "@dxos/plugin-search";
|
|
14
|
+
import { getSpace } from "@dxos/react-client/echo";
|
|
15
|
+
import { Toolbar } from "@dxos/react-ui";
|
|
16
|
+
import { QueryEditor } from "@dxos/react-ui-components";
|
|
17
|
+
import { StackItem } from "@dxos/react-ui-stack";
|
|
18
|
+
var ExplorerContainer = ({ role, view }) => {
|
|
19
|
+
var _effect = _useSignals();
|
|
20
|
+
try {
|
|
21
|
+
const space = getSpace(view);
|
|
22
|
+
const [filter, setFilter] = useState();
|
|
23
|
+
const model = useGraphModel(space, filter);
|
|
24
|
+
const { match } = useGlobalSearch();
|
|
25
|
+
const builder = useMemo(() => new QueryBuilder(), []);
|
|
26
|
+
const handleChange = useCallback((value) => {
|
|
27
|
+
setFilter(builder.build(value));
|
|
28
|
+
}, []);
|
|
29
|
+
const showToolbar = role === "article";
|
|
30
|
+
if (!space || !model) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return /* @__PURE__ */ React.createElement(StackItem.Content, {
|
|
34
|
+
toolbar: showToolbar
|
|
35
|
+
}, showToolbar && /* @__PURE__ */ React.createElement(Toolbar.Root, null, /* @__PURE__ */ React.createElement(QueryEditor, {
|
|
36
|
+
db: space.db,
|
|
37
|
+
onChange: handleChange
|
|
38
|
+
})), /* @__PURE__ */ React.createElement(D3ForceGraph, {
|
|
39
|
+
model,
|
|
40
|
+
match
|
|
41
|
+
}));
|
|
42
|
+
} finally {
|
|
43
|
+
_effect.f();
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
var ExplorerContainer_default = ExplorerContainer;
|
|
47
|
+
export {
|
|
48
|
+
ExplorerContainer_default as default
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=ExplorerContainer-6SHZJ6AK.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/ExplorerContainer.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { useCallback, useMemo, useState } from 'react';\n\nimport { type Filter } from '@dxos/echo';\nimport { QueryBuilder } from '@dxos/echo-query';\nimport { useGlobalSearch } from '@dxos/plugin-search';\nimport { getSpace } from '@dxos/react-client/echo';\nimport { Toolbar } from '@dxos/react-ui';\nimport { QueryEditor, type QueryEditorProps } from '@dxos/react-ui-components';\nimport { StackItem } from '@dxos/react-ui-stack';\nimport { type DataType } from '@dxos/schema';\n\nimport { useGraphModel } from '../hooks';\n\nimport { D3ForceGraph } from './Graph';\n\ntype ExplorerContainerProps = {\n role: string;\n view: DataType.View;\n};\n\nconst ExplorerContainer = ({ role, view }: ExplorerContainerProps) => {\n const space = getSpace(view);\n const [filter, setFilter] = useState<Filter.Any>();\n const model = useGraphModel(space, filter);\n const { match } = useGlobalSearch();\n\n const builder = useMemo(() => new QueryBuilder(), []);\n const handleChange = useCallback<NonNullable<QueryEditorProps['onChange']>>((value) => {\n setFilter(builder.build(value));\n }, []);\n\n const showToolbar = role === 'article';\n\n if (!space || !model) {\n return null;\n }\n\n return (\n <StackItem.Content toolbar={showToolbar}>\n {showToolbar && (\n <Toolbar.Root>\n <QueryEditor db={space.db} onChange={handleChange} />\n </Toolbar.Root>\n )}\n <D3ForceGraph model={model} match={match} />\n </StackItem.Content>\n );\n};\n\nexport default ExplorerContainer;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;AAIA,OAAOA,SAASC,aAAaC,SAASC,gBAAgB;AAGtD,SAASC,oBAAoB;AAC7B,SAASC,uBAAuB;AAChC,SAASC,gBAAgB;AACzB,SAASC,eAAe;AACxB,SAASC,mBAA0C;AACnD,SAASC,iBAAiB;AAY1B,IAAMC,oBAAoB,CAAC,EAAEC,MAAMC,KAAI,MAA0B;;;AAC/D,UAAMC,QAAQC,SAASF,IAAAA;AACvB,UAAM,CAACG,QAAQC,SAAAA,IAAaC,SAAAA;AAC5B,UAAMC,QAAQC,cAAcN,OAAOE,MAAAA;AACnC,UAAM,EAAEK,MAAK,IAAKC,gBAAAA;AAElB,UAAMC,UAAUC,QAAQ,MAAM,IAAIC,aAAAA,GAAgB,CAAA,CAAE;AACpD,UAAMC,eAAeC,YAAuD,CAACC,UAAAA;AAC3EX,gBAAUM,QAAQM,MAAMD,KAAAA,CAAAA;IAC1B,GAAG,CAAA,CAAE;AAEL,UAAME,cAAclB,SAAS;AAE7B,QAAI,CAACE,SAAS,CAACK,OAAO;AACpB,aAAO;IACT;AAEA,WACE,sBAAA,cAACY,UAAUC,SAAO;MAACC,SAASH;OACzBA,eACC,sBAAA,cAACI,QAAQC,MAAI,MACX,sBAAA,cAACC,aAAAA;MAAYC,IAAIvB,MAAMuB;MAAIC,UAAUZ;SAGzC,sBAAA,cAACa,cAAAA;MAAapB;MAAcE;;;;;AAGlC;AAEA,IAAA,4BAAeV;",
|
|
6
|
+
"names": ["React", "useCallback", "useMemo", "useState", "QueryBuilder", "useGlobalSearch", "getSpace", "Toolbar", "QueryEditor", "StackItem", "ExplorerContainer", "role", "view", "space", "getSpace", "filter", "setFilter", "useState", "model", "useGraphModel", "match", "useGlobalSearch", "builder", "useMemo", "QueryBuilder", "handleChange", "useCallback", "value", "build", "showToolbar", "StackItem", "Content", "toolbar", "Toolbar", "Root", "QueryEditor", "db", "onChange", "D3ForceGraph"]
|
|
7
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// src/meta.ts
|
|
2
|
-
var EXPLORER_PLUGIN = "dxos.org/plugin/explorer";
|
|
3
2
|
var meta = {
|
|
4
|
-
id:
|
|
3
|
+
id: "dxos.org/plugin/explorer",
|
|
5
4
|
name: "Explorer",
|
|
6
5
|
description: "Install this plugin to view a hypergraph of all objects inside of your Space.",
|
|
7
6
|
icon: "ph--graph--regular",
|
|
@@ -15,7 +14,6 @@ var meta = {
|
|
|
15
14
|
};
|
|
16
15
|
|
|
17
16
|
export {
|
|
18
|
-
EXPLORER_PLUGIN,
|
|
19
17
|
meta
|
|
20
18
|
};
|
|
21
|
-
//# sourceMappingURL=chunk-
|
|
19
|
+
//# sourceMappingURL=chunk-2DGFNLRO.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/meta.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const meta: PluginMeta = {\n id: 'dxos.org/plugin/explorer',\n name: 'Explorer',\n description: 'Install this plugin to view a hypergraph of all objects inside of your Space.',\n icon: 'ph--graph--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-explorer',\n tags: ['labs'],\n screenshots: ['https://dxos.network/plugin-details-explorer-dark.png'],\n};\n"],
|
|
5
|
+
"mappings": ";AAMO,IAAMA,OAAmB;EAC9BC,IAAI;EACJC,MAAM;EACNC,aAAa;EACbC,MAAM;EACNC,QAAQ;EACRC,MAAM;IAAC;;EACPC,aAAa;IAAC;;AAChB;",
|
|
6
|
+
"names": ["meta", "id", "name", "description", "icon", "source", "tags", "screenshots"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
meta
|
|
3
|
+
} from "./chunk-2DGFNLRO.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__export
|
|
6
|
+
} from "./chunk-J5LGTIGS.mjs";
|
|
7
|
+
|
|
8
|
+
// src/types/ExplorerAction.ts
|
|
9
|
+
var ExplorerAction_exports = {};
|
|
10
|
+
__export(ExplorerAction_exports, {
|
|
11
|
+
CreateGraph: () => CreateGraph,
|
|
12
|
+
GraphProps: () => GraphProps
|
|
13
|
+
});
|
|
14
|
+
import * as Schema from "effect/Schema";
|
|
15
|
+
import { SpaceSchema } from "@dxos/react-client/echo";
|
|
16
|
+
import { DataType, TypenameAnnotationId } from "@dxos/schema";
|
|
17
|
+
var EXPLORER_ACTION = `${meta.id}/action`;
|
|
18
|
+
var GraphProps = Schema.Struct({
|
|
19
|
+
name: Schema.optional(Schema.String),
|
|
20
|
+
typename: Schema.String.annotations({
|
|
21
|
+
[TypenameAnnotationId]: [
|
|
22
|
+
"used-static",
|
|
23
|
+
"dynamic"
|
|
24
|
+
],
|
|
25
|
+
title: "Select graph record type"
|
|
26
|
+
})
|
|
27
|
+
});
|
|
28
|
+
var CreateGraph = class extends Schema.TaggedClass()(`${EXPLORER_ACTION}/create-graph`, {
|
|
29
|
+
input: Schema.Struct({
|
|
30
|
+
space: SpaceSchema
|
|
31
|
+
}).pipe(Schema.extend(GraphProps)),
|
|
32
|
+
output: Schema.Struct({
|
|
33
|
+
object: DataType.View
|
|
34
|
+
})
|
|
35
|
+
}) {
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// src/types/Graph.ts
|
|
39
|
+
var Graph_exports = {};
|
|
40
|
+
__export(Graph_exports, {
|
|
41
|
+
Graph: () => Graph,
|
|
42
|
+
make: () => make,
|
|
43
|
+
makeView: () => makeView
|
|
44
|
+
});
|
|
45
|
+
import * as Schema2 from "effect/Schema";
|
|
46
|
+
import { Filter, Obj, Query, QueryAST, Type } from "@dxos/echo";
|
|
47
|
+
import { LabelAnnotation, ViewAnnotation } from "@dxos/echo/internal";
|
|
48
|
+
import { createViewFromSpace } from "@dxos/schema";
|
|
49
|
+
var Graph = Schema2.Struct({
|
|
50
|
+
name: Schema2.optional(Schema2.String),
|
|
51
|
+
query: Schema2.Struct({
|
|
52
|
+
raw: Schema2.optional(Schema2.String),
|
|
53
|
+
ast: QueryAST.Query
|
|
54
|
+
}).pipe(Schema2.mutable)
|
|
55
|
+
}).pipe(Type.Obj({
|
|
56
|
+
typename: "dxos.org/type/Graph",
|
|
57
|
+
version: "0.1.0"
|
|
58
|
+
}), LabelAnnotation.set([
|
|
59
|
+
"name"
|
|
60
|
+
]), ViewAnnotation.set(true));
|
|
61
|
+
var make = (props = {
|
|
62
|
+
query: {
|
|
63
|
+
raw: "",
|
|
64
|
+
ast: Query.select(Filter.nothing()).ast
|
|
65
|
+
}
|
|
66
|
+
}) => Obj.make(Graph, props);
|
|
67
|
+
var makeView = async ({ presentation, ...props }) => {
|
|
68
|
+
const graph = make(presentation);
|
|
69
|
+
return createViewFromSpace({
|
|
70
|
+
...props,
|
|
71
|
+
presentation: graph
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export {
|
|
76
|
+
ExplorerAction_exports,
|
|
77
|
+
Graph_exports
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=chunk-BZ65T5M3.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/types/ExplorerAction.ts", "../../../src/types/Graph.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { SpaceSchema } from '@dxos/react-client/echo';\nimport { DataType, TypenameAnnotationId } from '@dxos/schema';\n\nimport { meta } from '../meta';\n\nconst EXPLORER_ACTION = `${meta.id}/action`;\n\nexport const GraphProps = Schema.Struct({\n name: Schema.optional(Schema.String),\n typename: Schema.String.annotations({\n [TypenameAnnotationId]: ['used-static', 'dynamic'],\n title: 'Select graph record type',\n }),\n});\n\nexport class CreateGraph extends Schema.TaggedClass<CreateGraph>()(`${EXPLORER_ACTION}/create-graph`, {\n input: Schema.Struct({\n space: SpaceSchema,\n }).pipe(Schema.extend(GraphProps)),\n output: Schema.Struct({\n object: DataType.View,\n }),\n}) {}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Filter, Obj, Query, QueryAST, Type } from '@dxos/echo';\nimport { LabelAnnotation, ViewAnnotation } from '@dxos/echo/internal';\nimport { type CreateViewFromSpaceProps, createViewFromSpace } from '@dxos/schema';\n\nexport const Graph = Schema.Struct({\n name: Schema.optional(Schema.String),\n query: Schema.Struct({\n raw: Schema.optional(Schema.String),\n ast: QueryAST.Query,\n }).pipe(Schema.mutable),\n}).pipe(\n Type.Obj({\n typename: 'dxos.org/type/Graph',\n version: '0.1.0',\n }),\n LabelAnnotation.set(['name']),\n ViewAnnotation.set(true),\n);\n\nexport type Graph = Schema.Schema.Type<typeof Graph>;\n\n/**\n * Make a graph object.\n */\nexport const make = (\n props: Obj.MakeProps<typeof Graph> = { query: { raw: '', ast: Query.select(Filter.nothing()).ast } },\n) => Obj.make(Graph, props);\n\ntype MakeViewProps = Omit<CreateViewFromSpaceProps, 'presentation'> & {\n presentation?: Omit<Obj.MakeProps<typeof Graph>, 'name'>;\n};\n\n/**\n * Make a graph as a view of a data set.\n */\nexport const makeView = async ({ presentation, ...props }: MakeViewProps) => {\n const graph = make(presentation);\n return createViewFromSpace({ ...props, presentation: graph });\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAAA;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,mBAAmB;AAC5B,SAASC,UAAUC,4BAA4B;AAI/C,IAAMC,kBAAkB,GAAGC,KAAKC,EAAE;AAE3B,IAAMC,aAAoBC,cAAO;EACtCC,MAAaC,gBAAgBC,aAAM;EACnCC,UAAiBD,cAAOE,YAAY;IAClC,CAACC,oBAAAA,GAAuB;MAAC;MAAe;;IACxCC,OAAO;EACT,CAAA;AACF,CAAA;AAEO,IAAMC,cAAN,cAAiCC,mBAAW,EAAgB,GAAGb,eAAAA,iBAAgC;EACpGc,OAAcV,cAAO;IACnBW,OAAOC;EACT,CAAA,EAAGC,KAAYC,cAAOf,UAAAA,CAAAA;EACtBgB,QAAef,cAAO;IACpBgB,QAAQC,SAASC;EACnB,CAAA;AACF,CAAA,EAAA;AAAI;;;AC5BJ;;;;;;AAIA,YAAYC,aAAY;AAExB,SAASC,QAAQC,KAAKC,OAAOC,UAAUC,YAAY;AACnD,SAASC,iBAAiBC,sBAAsB;AAChD,SAAwCC,2BAA2B;AAE5D,IAAMC,QAAeC,eAAO;EACjCC,MAAaC,iBAAgBC,cAAM;EACnCC,OAAcJ,eAAO;IACnBK,KAAYH,iBAAgBC,cAAM;IAClCG,KAAKC,SAASC;EAChB,CAAA,EAAGC,KAAYC,eAAO;AACxB,CAAA,EAAGD,KACDE,KAAKC,IAAI;EACPC,UAAU;EACVC,SAAS;AACX,CAAA,GACAC,gBAAgBC,IAAI;EAAC;CAAO,GAC5BC,eAAeD,IAAI,IAAA,CAAA;AAQd,IAAME,OAAO,CAClBC,QAAqC;EAAEf,OAAO;IAAEC,KAAK;IAAIC,KAAKE,MAAMY,OAAOC,OAAOC,QAAO,CAAA,EAAIhB;EAAI;AAAE,MAChGM,IAAIM,KAAKnB,OAAOoB,KAAAA;AASd,IAAMI,WAAW,OAAO,EAAEC,cAAc,GAAGL,MAAAA,MAAsB;AACtE,QAAMM,QAAQP,KAAKM,YAAAA;AACnB,SAAOE,oBAAoB;IAAE,GAAGP;IAAOK,cAAcC;EAAM,CAAA;AAC7D;",
|
|
6
|
+
"names": ["Schema", "SpaceSchema", "DataType", "TypenameAnnotationId", "EXPLORER_ACTION", "meta", "id", "GraphProps", "Struct", "name", "optional", "String", "typename", "annotations", "TypenameAnnotationId", "title", "CreateGraph", "TaggedClass", "input", "space", "SpaceSchema", "pipe", "extend", "output", "object", "DataType", "View", "Schema", "Filter", "Obj", "Query", "QueryAST", "Type", "LabelAnnotation", "ViewAnnotation", "createViewFromSpace", "Graph", "Struct", "name", "optional", "String", "query", "raw", "ast", "QueryAST", "Query", "pipe", "mutable", "Type", "Obj", "typename", "version", "LabelAnnotation", "set", "ViewAnnotation", "make", "props", "select", "Filter", "nothing", "makeView", "presentation", "graph", "createViewFromSpace"]
|
|
7
|
+
}
|
|
@@ -10973,9 +10973,23 @@ var TidyTree = (s, data, options) => {
|
|
|
10973
10973
|
var TidyTree_default = TidyTree;
|
|
10974
10974
|
|
|
10975
10975
|
// src/components/Tree/types/tree.ts
|
|
10976
|
-
import
|
|
10976
|
+
import * as Schema from "effect/Schema";
|
|
10977
10977
|
import { Key, Obj, Type } from "@dxos/echo";
|
|
10978
10978
|
import { invariant } from "@dxos/invariant";
|
|
10979
|
+
function _define_property(obj, key, value) {
|
|
10980
|
+
if (key in obj) {
|
|
10981
|
+
Object.defineProperty(obj, key, {
|
|
10982
|
+
value,
|
|
10983
|
+
enumerable: true,
|
|
10984
|
+
configurable: true,
|
|
10985
|
+
writable: true
|
|
10986
|
+
});
|
|
10987
|
+
} else {
|
|
10988
|
+
obj[key] = value;
|
|
10989
|
+
}
|
|
10990
|
+
return obj;
|
|
10991
|
+
}
|
|
10992
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-explorer/src/components/Tree/types/tree.ts";
|
|
10979
10993
|
var TreeNodeType = Schema.Struct({
|
|
10980
10994
|
id: Key.ObjectId,
|
|
10981
10995
|
children: Schema.mutable(Schema.Array(Key.ObjectId)),
|
|
@@ -10995,6 +11009,244 @@ var TreeType = Schema.Struct({
|
|
|
10995
11009
|
typename: "dxos.org/type/Tree",
|
|
10996
11010
|
version: "0.1.0"
|
|
10997
11011
|
}));
|
|
11012
|
+
var Tree = class _Tree {
|
|
11013
|
+
get tree() {
|
|
11014
|
+
return this._tree;
|
|
11015
|
+
}
|
|
11016
|
+
// TODO(burdon): Make reactive.
|
|
11017
|
+
get size() {
|
|
11018
|
+
return Object.keys(this._tree.nodes).length;
|
|
11019
|
+
}
|
|
11020
|
+
get root() {
|
|
11021
|
+
return this.getNode(this._tree.root);
|
|
11022
|
+
}
|
|
11023
|
+
//
|
|
11024
|
+
// Traversal
|
|
11025
|
+
//
|
|
11026
|
+
/**
|
|
11027
|
+
* Recursively traverse the tree until the callback returns a value.
|
|
11028
|
+
*/
|
|
11029
|
+
tranverse(callback, root = this._tree.root, depth = 0) {
|
|
11030
|
+
const node = this._tree.nodes[root];
|
|
11031
|
+
const result = callback(node, depth);
|
|
11032
|
+
if (result !== void 0) {
|
|
11033
|
+
return result;
|
|
11034
|
+
}
|
|
11035
|
+
for (const childId of node.children) {
|
|
11036
|
+
const result2 = this.tranverse(callback, childId, depth + 1);
|
|
11037
|
+
if (result2 !== void 0) {
|
|
11038
|
+
return result2;
|
|
11039
|
+
}
|
|
11040
|
+
}
|
|
11041
|
+
}
|
|
11042
|
+
getNode(id) {
|
|
11043
|
+
const node = this._tree.nodes[id];
|
|
11044
|
+
invariant(node, void 0, {
|
|
11045
|
+
F: __dxlog_file,
|
|
11046
|
+
L: 98,
|
|
11047
|
+
S: this,
|
|
11048
|
+
A: [
|
|
11049
|
+
"node",
|
|
11050
|
+
""
|
|
11051
|
+
]
|
|
11052
|
+
});
|
|
11053
|
+
return node;
|
|
11054
|
+
}
|
|
11055
|
+
/**
|
|
11056
|
+
* Get the children of a node.
|
|
11057
|
+
*/
|
|
11058
|
+
getChildNodes(node) {
|
|
11059
|
+
return node.children.map((id) => this.getNode(id));
|
|
11060
|
+
}
|
|
11061
|
+
/**
|
|
11062
|
+
* Get the parent of a node.
|
|
11063
|
+
*/
|
|
11064
|
+
getParent(node) {
|
|
11065
|
+
const parent = this.tranverse((n) => {
|
|
11066
|
+
if (n.children.includes(node.id)) {
|
|
11067
|
+
return n;
|
|
11068
|
+
}
|
|
11069
|
+
});
|
|
11070
|
+
return parent ?? null;
|
|
11071
|
+
}
|
|
11072
|
+
/**
|
|
11073
|
+
* Get the next node in the tree.
|
|
11074
|
+
*/
|
|
11075
|
+
getNext(node, hierarchical = true) {
|
|
11076
|
+
if (hierarchical && node.children.length) {
|
|
11077
|
+
return this.getChildNodes(node)[0];
|
|
11078
|
+
} else {
|
|
11079
|
+
const parent = this.getParent(node);
|
|
11080
|
+
if (parent) {
|
|
11081
|
+
const idx = this.getChildNodes(parent).findIndex(({ id }) => id === node.id);
|
|
11082
|
+
if (idx < parent.children.length - 1) {
|
|
11083
|
+
return this.getNode(parent.children[idx + 1]);
|
|
11084
|
+
} else {
|
|
11085
|
+
return this.getNext(parent, false);
|
|
11086
|
+
}
|
|
11087
|
+
}
|
|
11088
|
+
}
|
|
11089
|
+
}
|
|
11090
|
+
/**
|
|
11091
|
+
* Get the previous node in the tree.
|
|
11092
|
+
*/
|
|
11093
|
+
getPrevious(node, hierarchical = true) {
|
|
11094
|
+
const parent = this.getParent(node);
|
|
11095
|
+
const idx = this.getChildNodes(parent).findIndex(({ id }) => id === node.id);
|
|
11096
|
+
if (idx === 0) {
|
|
11097
|
+
if (hierarchical) {
|
|
11098
|
+
return parent;
|
|
11099
|
+
}
|
|
11100
|
+
} else {
|
|
11101
|
+
const previous = this.getNode(parent.children[idx - 1]);
|
|
11102
|
+
if (hierarchical && previous.children.length) {
|
|
11103
|
+
return this.getLastDescendent(previous);
|
|
11104
|
+
}
|
|
11105
|
+
return previous;
|
|
11106
|
+
}
|
|
11107
|
+
}
|
|
11108
|
+
/**
|
|
11109
|
+
* Get the last descendent of a node.
|
|
11110
|
+
*/
|
|
11111
|
+
getLastDescendent(node) {
|
|
11112
|
+
const children = this.getChildNodes(node);
|
|
11113
|
+
const last = children.length ? children[children.length - 1] : void 0;
|
|
11114
|
+
if (last) {
|
|
11115
|
+
return this.getLastDescendent(last);
|
|
11116
|
+
}
|
|
11117
|
+
return node;
|
|
11118
|
+
}
|
|
11119
|
+
//
|
|
11120
|
+
// Mutations
|
|
11121
|
+
//
|
|
11122
|
+
/**
|
|
11123
|
+
* Clear tree.
|
|
11124
|
+
*/
|
|
11125
|
+
clear() {
|
|
11126
|
+
const root = this._tree.nodes[this._tree.root];
|
|
11127
|
+
root.children.length = 0;
|
|
11128
|
+
this._tree.nodes = {
|
|
11129
|
+
[root.id]: root
|
|
11130
|
+
};
|
|
11131
|
+
}
|
|
11132
|
+
/**
|
|
11133
|
+
* Add node.
|
|
11134
|
+
*/
|
|
11135
|
+
addNode(parent, node, index) {
|
|
11136
|
+
if (!node) {
|
|
11137
|
+
const id = Key.ObjectId.random();
|
|
11138
|
+
node = {
|
|
11139
|
+
id,
|
|
11140
|
+
children: [],
|
|
11141
|
+
data: {
|
|
11142
|
+
text: ""
|
|
11143
|
+
}
|
|
11144
|
+
};
|
|
11145
|
+
}
|
|
11146
|
+
this._tree.nodes[node.id] = node;
|
|
11147
|
+
parent.children.splice(index ?? parent.children.length, 0, node.id);
|
|
11148
|
+
return node;
|
|
11149
|
+
}
|
|
11150
|
+
/**
|
|
11151
|
+
* Delete node.
|
|
11152
|
+
*/
|
|
11153
|
+
deleteNode(parent, id) {
|
|
11154
|
+
const node = this._tree.nodes[id];
|
|
11155
|
+
if (!node) {
|
|
11156
|
+
return void 0;
|
|
11157
|
+
}
|
|
11158
|
+
delete this._tree.nodes[node.id];
|
|
11159
|
+
const idx = parent.children.findIndex((child) => child === id);
|
|
11160
|
+
if (idx !== -1) {
|
|
11161
|
+
parent.children.splice(idx, 1);
|
|
11162
|
+
}
|
|
11163
|
+
return node;
|
|
11164
|
+
}
|
|
11165
|
+
/**
|
|
11166
|
+
* Move child node.
|
|
11167
|
+
*/
|
|
11168
|
+
moveNode(node, from, to) {
|
|
11169
|
+
invariant(from >= 0 && from < node.children.length, void 0, {
|
|
11170
|
+
F: __dxlog_file,
|
|
11171
|
+
L: 228,
|
|
11172
|
+
S: this,
|
|
11173
|
+
A: [
|
|
11174
|
+
"from >= 0 && from < node.children.length",
|
|
11175
|
+
""
|
|
11176
|
+
]
|
|
11177
|
+
});
|
|
11178
|
+
invariant(to >= 0 && to < node.children.length, void 0, {
|
|
11179
|
+
F: __dxlog_file,
|
|
11180
|
+
L: 229,
|
|
11181
|
+
S: this,
|
|
11182
|
+
A: [
|
|
11183
|
+
"to >= 0 && to < node.children.length",
|
|
11184
|
+
""
|
|
11185
|
+
]
|
|
11186
|
+
});
|
|
11187
|
+
if (from === to) {
|
|
11188
|
+
return null;
|
|
11189
|
+
}
|
|
11190
|
+
const child = node.children[from];
|
|
11191
|
+
node.children.splice(from, 1);
|
|
11192
|
+
node.children.splice(to, 0, child);
|
|
11193
|
+
return this.getNode(child);
|
|
11194
|
+
}
|
|
11195
|
+
/**
|
|
11196
|
+
* Indent node.
|
|
11197
|
+
*/
|
|
11198
|
+
indentNode(node) {
|
|
11199
|
+
const parent = this.getParent(node);
|
|
11200
|
+
if (!parent) {
|
|
11201
|
+
return;
|
|
11202
|
+
}
|
|
11203
|
+
const idx = parent.children.findIndex((child) => child === node.id);
|
|
11204
|
+
if (idx < 1 || idx >= parent.children.length) {
|
|
11205
|
+
return;
|
|
11206
|
+
}
|
|
11207
|
+
const previous = this.getNode(parent.children[idx - 1]);
|
|
11208
|
+
parent.children.splice(idx, 1);
|
|
11209
|
+
previous.children.push(node.id);
|
|
11210
|
+
}
|
|
11211
|
+
/**
|
|
11212
|
+
* Unindent node.
|
|
11213
|
+
*/
|
|
11214
|
+
unindentNode(node) {
|
|
11215
|
+
const parent = this.getParent(node);
|
|
11216
|
+
if (!parent) {
|
|
11217
|
+
return;
|
|
11218
|
+
}
|
|
11219
|
+
const ancestor = this.getParent(parent);
|
|
11220
|
+
if (!ancestor) {
|
|
11221
|
+
return;
|
|
11222
|
+
}
|
|
11223
|
+
const nodeIdx = parent.children.findIndex((id) => id === node.id);
|
|
11224
|
+
const [_, ...rest] = parent.children.splice(nodeIdx, parent.children.length - nodeIdx);
|
|
11225
|
+
parent.children.splice(nodeIdx, parent.children.length - nodeIdx);
|
|
11226
|
+
const parentIdx = this.getChildNodes(ancestor).findIndex((n) => n.id === parent.id);
|
|
11227
|
+
ancestor.children.splice(parentIdx + 1, 0, node.id);
|
|
11228
|
+
node.children.push(...rest);
|
|
11229
|
+
}
|
|
11230
|
+
constructor(tree3) {
|
|
11231
|
+
_define_property(this, "_tree", void 0);
|
|
11232
|
+
this._tree = tree3 ?? _Tree.create();
|
|
11233
|
+
}
|
|
11234
|
+
};
|
|
11235
|
+
_define_property(Tree, "create", () => {
|
|
11236
|
+
const id = Key.ObjectId.random();
|
|
11237
|
+
return Obj.make(TreeType, {
|
|
11238
|
+
root: id,
|
|
11239
|
+
nodes: {
|
|
11240
|
+
[id]: {
|
|
11241
|
+
id,
|
|
11242
|
+
children: [],
|
|
11243
|
+
data: {
|
|
11244
|
+
text: ""
|
|
11245
|
+
}
|
|
11246
|
+
}
|
|
11247
|
+
}
|
|
11248
|
+
});
|
|
11249
|
+
});
|
|
10998
11250
|
|
|
10999
11251
|
// src/components/Tree/types/types.ts
|
|
11000
11252
|
var mapGraphToTreeData = (model, maxDepth = 8) => {
|
|
@@ -11022,7 +11274,7 @@ var renderers = /* @__PURE__ */ new Map([
|
|
|
11022
11274
|
HierarchicalEdgeBundling_default
|
|
11023
11275
|
]
|
|
11024
11276
|
]);
|
|
11025
|
-
var
|
|
11277
|
+
var Tree2 = ({ space, selected, variant = "tidy", onNodeClick }) => {
|
|
11026
11278
|
var _effect = _useSignals3();
|
|
11027
11279
|
try {
|
|
11028
11280
|
const [model] = useAsyncState(async () => space ? new SpaceGraphModel().open(space) : void 0, [
|
|
@@ -11040,7 +11292,7 @@ var Tree = ({ space, selected, variant = "tidy", onNodeClick }) => {
|
|
|
11040
11292
|
]);
|
|
11041
11293
|
const context = useRef(null);
|
|
11042
11294
|
useEffect3(() => {
|
|
11043
|
-
if (context.current) {
|
|
11295
|
+
if (context.current?.size) {
|
|
11044
11296
|
const { width, height } = context.current.size;
|
|
11045
11297
|
const size = Math.min(width, height);
|
|
11046
11298
|
const radius = size * 0.4;
|
|
@@ -11077,13 +11329,13 @@ var Tree = ({ space, selected, variant = "tidy", onNodeClick }) => {
|
|
|
11077
11329
|
|
|
11078
11330
|
// src/components/index.ts
|
|
11079
11331
|
import { lazy } from "react";
|
|
11080
|
-
var ExplorerContainer = lazy(() => import("./ExplorerContainer-
|
|
11332
|
+
var ExplorerContainer = lazy(() => import("./ExplorerContainer-6SHZJ6AK.mjs"));
|
|
11081
11333
|
|
|
11082
11334
|
export {
|
|
11083
11335
|
Chart,
|
|
11084
11336
|
Globe,
|
|
11085
11337
|
defaultTreeLayoutSlots,
|
|
11086
|
-
Tree,
|
|
11338
|
+
Tree2 as Tree,
|
|
11087
11339
|
ExplorerContainer
|
|
11088
11340
|
};
|
|
11089
|
-
//# sourceMappingURL=chunk-
|
|
11341
|
+
//# sourceMappingURL=chunk-MOM5KCKC.mjs.map
|