@dxos/plugin-explorer 0.8.4-main.422d1c7879 → 0.8.4-main.4f23b4e393
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/neutral/ExplorerContainer-BOXGUSRG.mjs +41 -0
- package/dist/lib/neutral/ExplorerContainer-BOXGUSRG.mjs.map +7 -0
- package/dist/lib/neutral/ExplorerPlugin.mjs +26 -0
- package/dist/lib/neutral/ExplorerPlugin.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +11 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/{browser/types/index.mjs → neutral/chunk-7SPMPHRS.mjs} +10 -8
- package/dist/lib/neutral/chunk-7SPMPHRS.mjs.map +7 -0
- package/dist/lib/{browser/chunk-LSUP47BZ.mjs → neutral/chunk-HPIS2WXY.mjs} +1 -1
- package/dist/lib/{browser/chunk-LSUP47BZ.mjs.map → neutral/chunk-HPIS2WXY.mjs.map} +2 -2
- package/dist/lib/{browser → neutral/components}/index.mjs +140 -240
- package/dist/lib/{node-esm → neutral/components}/index.mjs.map +4 -4
- package/dist/lib/neutral/containers/index.mjs +9 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/create-object-F6TKVAGV.mjs +39 -0
- package/dist/lib/neutral/create-object-F6TKVAGV.mjs.map +7 -0
- package/dist/lib/neutral/hooks/index.mjs +45 -0
- package/dist/lib/neutral/hooks/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +14 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/{browser → neutral}/meta.mjs +1 -1
- package/dist/lib/neutral/plugin.mjs +12 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-U3JEY7V7.mjs +26 -0
- package/dist/lib/neutral/react-surface-U3JEY7V7.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +33 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +10 -0
- package/dist/types/data/cities.d.ts +4 -4
- package/dist/types/data/cities.d.ts.map +1 -1
- package/dist/types/data/countries-110m.d.ts +19 -22
- package/dist/types/data/countries-110m.d.ts.map +1 -1
- package/dist/types/src/ExplorerPlugin.d.ts +1 -0
- package/dist/types/src/ExplorerPlugin.d.ts.map +1 -1
- package/dist/types/src/ExplorerPlugin.test.d.ts +2 -0
- package/dist/types/src/ExplorerPlugin.test.d.ts.map +1 -0
- package/dist/types/src/capabilities/create-object.d.ts +11 -0
- package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +6 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/Chart/Chart.d.ts.map +1 -1
- package/dist/types/src/components/Chart/Chart.stories.d.ts +4 -1
- package/dist/types/src/components/Chart/Chart.stories.d.ts.map +1 -1
- package/dist/types/src/components/Globe/Globe.d.ts.map +1 -1
- package/dist/types/src/components/Globe/Globe.stories.d.ts +5 -2
- package/dist/types/src/components/Globe/Globe.stories.d.ts.map +1 -1
- package/dist/types/src/components/Graph/CanvasForceGraph.d.ts +13 -0
- package/dist/types/src/components/Graph/CanvasForceGraph.d.ts.map +1 -0
- package/dist/types/src/components/Graph/{D3ForceGraph.stories.d.ts → CanvasForceGraph.stories.d.ts} +3 -3
- package/dist/types/src/components/Graph/CanvasForceGraph.stories.d.ts.map +1 -0
- package/dist/types/src/components/Graph/ForceGraph.d.ts +12 -5
- package/dist/types/src/components/Graph/ForceGraph.d.ts.map +1 -1
- package/dist/types/src/components/Graph/ForceGraph.stories.d.ts +3 -1
- package/dist/types/src/components/Graph/ForceGraph.stories.d.ts.map +1 -1
- package/dist/types/src/components/Graph/{adapter.d.ts → graph-adapter.d.ts} +1 -1
- package/dist/types/src/components/Graph/graph-adapter.d.ts.map +1 -0
- package/dist/types/src/components/Graph/index.d.ts +1 -1
- package/dist/types/src/components/Graph/index.d.ts.map +1 -1
- package/dist/types/src/components/Graph/testing.d.ts.map +1 -1
- package/dist/types/src/components/Tree/Tree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/Tree.stories.d.ts +5 -1
- package/dist/types/src/components/Tree/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tree/layout/HierarchicalEdgeBundling.d.ts.map +1 -1
- package/dist/types/src/components/Tree/layout/RadialTree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/layout/TidyTree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/testing/generator.d.ts.map +1 -1
- package/dist/types/src/components/Tree/types/tree.d.ts +6 -6
- package/dist/types/src/components/Tree/types/tree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/types/types.d.ts.map +1 -1
- package/dist/types/src/components/plot.d.ts.map +1 -1
- package/dist/types/src/containers/ExplorerContainer/ExplorerContainer.d.ts +1 -1
- package/dist/types/src/containers/ExplorerContainer/ExplorerContainer.d.ts.map +1 -1
- package/dist/types/src/hooks/useGraphModel.d.ts +2 -2
- package/dist/types/src/hooks/useGraphModel.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/plugin.d.ts +3 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +17 -17
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Graph.d.ts +3 -4
- package/dist/types/src/types/Graph.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +94 -51
- package/src/ExplorerPlugin.test.ts +26 -0
- package/src/ExplorerPlugin.tsx +6 -35
- package/src/capabilities/create-object.ts +36 -0
- package/src/capabilities/index.ts +1 -0
- package/src/components/Chart/Chart.stories.tsx +14 -20
- package/src/components/Globe/Globe.stories.tsx +17 -19
- package/src/components/Graph/CanvasForceGraph.stories.tsx +83 -0
- package/src/components/Graph/CanvasForceGraph.tsx +124 -0
- package/src/components/Graph/ForceGraph.stories.tsx +68 -36
- package/src/components/Graph/ForceGraph.tsx +104 -85
- package/src/components/Graph/index.ts +1 -1
- package/src/components/Tree/Tree.stories.tsx +40 -35
- package/src/components/Tree/testing/generator.ts +1 -1
- package/src/components/Tree/types/tree.test.ts +1 -1
- package/src/components/Tree/types/tree.ts +9 -9
- package/src/containers/ExplorerContainer/ExplorerContainer.tsx +10 -13
- package/src/hooks/useGraphModel.ts +10 -6
- package/src/index.ts +1 -4
- package/src/plugin.ts +9 -0
- package/src/translations.ts +1 -1
- package/src/types/ExplorerAction.ts +1 -1
- package/src/types/Graph.ts +2 -3
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/types/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-EN3JZNEY.mjs +0 -26
- package/dist/lib/node-esm/chunk-EN3JZNEY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
- package/dist/lib/node-esm/index.mjs +0 -11375
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/meta.mjs +0 -9
- package/dist/lib/node-esm/types/index.mjs +0 -71
- package/dist/lib/node-esm/types/index.mjs.map +0 -7
- package/dist/types/src/components/Graph/D3ForceGraph.d.ts +0 -15
- package/dist/types/src/components/Graph/D3ForceGraph.d.ts.map +0 -1
- package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts.map +0 -1
- package/dist/types/src/components/Graph/adapter.d.ts.map +0 -1
- package/src/components/Graph/D3ForceGraph.stories.tsx +0 -83
- package/src/components/Graph/D3ForceGraph.tsx +0 -108
- /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs +0 -0
- /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs.map +0 -0
- /package/dist/lib/{browser/meta.mjs.map → neutral/index.mjs.map} +0 -0
- /package/dist/lib/{node-esm → neutral}/meta.mjs.map +0 -0
- /package/dist/lib/{node-esm/chunk-HSLMI22Q.mjs.map → neutral/types/index.mjs.map} +0 -0
- /package/src/components/Graph/{adapter.ts → graph-adapter.ts} +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import "./chunk-J5LGTIGS.mjs";
|
|
2
|
+
|
|
3
|
+
// src/containers/ExplorerContainer/ExplorerContainer.tsx
|
|
4
|
+
import React, { useCallback, useMemo, useState } from "react";
|
|
5
|
+
import { Obj } from "@dxos/echo";
|
|
6
|
+
import { QueryBuilder } from "@dxos/echo-query";
|
|
7
|
+
import { useObject } from "@dxos/react-client/echo";
|
|
8
|
+
import { Panel, Toolbar } from "@dxos/react-ui";
|
|
9
|
+
import { QueryEditor } from "@dxos/react-ui-components";
|
|
10
|
+
import { ForceGraph } from "#components";
|
|
11
|
+
import { useGraphModel } from "#hooks";
|
|
12
|
+
var ExplorerContainer = ({ role, subject, attendableId: _attendableId }) => {
|
|
13
|
+
const [view] = useObject(subject);
|
|
14
|
+
const db = view && Obj.getDatabase(view);
|
|
15
|
+
const [filter, setFilter] = useState();
|
|
16
|
+
const model = useGraphModel(db, filter);
|
|
17
|
+
const builder = useMemo(() => new QueryBuilder(), []);
|
|
18
|
+
const handleChange = useCallback((value) => {
|
|
19
|
+
setFilter(builder.build(value).filter);
|
|
20
|
+
}, []);
|
|
21
|
+
const showToolbar = role === "article";
|
|
22
|
+
if (!db || !model) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return /* @__PURE__ */ React.createElement(Panel.Root, {
|
|
26
|
+
role
|
|
27
|
+
}, showToolbar && /* @__PURE__ */ React.createElement(Panel.Toolbar, {
|
|
28
|
+
asChild: true
|
|
29
|
+
}, /* @__PURE__ */ React.createElement(Toolbar.Root, null, /* @__PURE__ */ React.createElement(QueryEditor, {
|
|
30
|
+
db,
|
|
31
|
+
onChange: handleChange
|
|
32
|
+
}))), /* @__PURE__ */ React.createElement(Panel.Content, {
|
|
33
|
+
asChild: true
|
|
34
|
+
}, /* @__PURE__ */ React.createElement(ForceGraph, {
|
|
35
|
+
model
|
|
36
|
+
})));
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
ExplorerContainer as default
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=ExplorerContainer-BOXGUSRG.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/containers/ExplorerContainer/ExplorerContainer.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { useCallback, useMemo, useState } from 'react';\n\nimport { type AppSurface } from '@dxos/app-toolkit/ui';\nimport { type Filter, Obj, type View } from '@dxos/echo';\nimport { QueryBuilder } from '@dxos/echo-query';\nimport { useObject } from '@dxos/react-client/echo';\nimport { Panel, Toolbar } from '@dxos/react-ui';\nimport { QueryEditor, type QueryEditorProps } from '@dxos/react-ui-components';\n\nimport { ForceGraph } from '#components';\nimport { useGraphModel } from '#hooks';\n\nexport type ExplorerContainerProps = AppSurface.ObjectArticleProps<View.View>;\n\nexport const ExplorerContainer = ({ role, subject, attendableId: _attendableId }: ExplorerContainerProps) => {\n const [view] = useObject(subject);\n const db = view && Obj.getDatabase(view);\n const [filter, setFilter] = useState<Filter.Any>();\n const model = useGraphModel(db, filter);\n\n const builder = useMemo(() => new QueryBuilder(), []);\n const handleChange = useCallback<NonNullable<QueryEditorProps['onChange']>>((value) => {\n setFilter(builder.build(value).filter);\n }, []);\n\n const showToolbar = role === 'article';\n\n if (!db || !model) {\n return null;\n }\n\n return (\n <Panel.Root role={role}>\n {showToolbar && (\n <Panel.Toolbar asChild>\n <Toolbar.Root>\n <QueryEditor db={db} onChange={handleChange} />\n </Toolbar.Root>\n </Panel.Toolbar>\n )}\n <Panel.Content asChild>\n <ForceGraph model={model} />\n </Panel.Content>\n </Panel.Root>\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;AAIA,OAAOA,SAASC,aAAaC,SAASC,gBAAgB;AAGtD,SAAsBC,WAAsB;AAC5C,SAASC,oBAAoB;AAC7B,SAASC,iBAAiB;AAC1B,SAASC,OAAOC,eAAe;AAC/B,SAASC,mBAA0C;AAEnD,SAASC,kBAAkB;AAC3B,SAASC,qBAAqB;AAIvB,IAAMC,oBAAoB,CAAC,EAAEC,MAAMC,SAASC,cAAcC,cAAa,MAA0B;AACtG,QAAM,CAACC,IAAAA,IAAQX,UAAUQ,OAAAA;AACzB,QAAMI,KAAKD,QAAQb,IAAIe,YAAYF,IAAAA;AACnC,QAAM,CAACG,QAAQC,SAAAA,IAAalB,SAAAA;AAC5B,QAAMmB,QAAQX,cAAcO,IAAIE,MAAAA;AAEhC,QAAMG,UAAUrB,QAAQ,MAAM,IAAIG,aAAAA,GAAgB,CAAA,CAAE;AACpD,QAAMmB,eAAevB,YAAuD,CAACwB,UAAAA;AAC3EJ,cAAUE,QAAQG,MAAMD,KAAAA,EAAOL,MAAM;EACvC,GAAG,CAAA,CAAE;AAEL,QAAMO,cAAcd,SAAS;AAE7B,MAAI,CAACK,MAAM,CAACI,OAAO;AACjB,WAAO;EACT;AAEA,SACE,sBAAA,cAACf,MAAMqB,MAAI;IAACf;KACTc,eACC,sBAAA,cAACpB,MAAMC,SAAO;IAACqB,SAAAA;KACb,sBAAA,cAACrB,QAAQoB,MAAI,MACX,sBAAA,cAACnB,aAAAA;IAAYS;IAAQY,UAAUN;QAIrC,sBAAA,cAACjB,MAAMwB,SAAO;IAACF,SAAAA;KACb,sBAAA,cAACnB,YAAAA;IAAWY;;AAIpB;",
|
|
6
|
+
"names": ["React", "useCallback", "useMemo", "useState", "Obj", "QueryBuilder", "useObject", "Panel", "Toolbar", "QueryEditor", "ForceGraph", "useGraphModel", "ExplorerContainer", "role", "subject", "attendableId", "_attendableId", "view", "db", "getDatabase", "filter", "setFilter", "model", "builder", "handleChange", "value", "build", "showToolbar", "Root", "asChild", "onChange", "Content"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import "./chunk-J5LGTIGS.mjs";
|
|
2
|
+
|
|
3
|
+
// src/ExplorerPlugin.tsx
|
|
4
|
+
import { Plugin } from "@dxos/app-framework";
|
|
5
|
+
import { AppPlugin } from "@dxos/app-toolkit";
|
|
6
|
+
import { CreateObject, ReactSurface } from "#capabilities";
|
|
7
|
+
import { meta } from "#meta";
|
|
8
|
+
import { translations } from "#translations";
|
|
9
|
+
import { Graph } from "#types";
|
|
10
|
+
var ExplorerPlugin = Plugin.define(meta).pipe(AppPlugin.addCreateObjectModule({
|
|
11
|
+
activate: CreateObject
|
|
12
|
+
}), AppPlugin.addSchemaModule({
|
|
13
|
+
schema: [
|
|
14
|
+
Graph.Graph
|
|
15
|
+
]
|
|
16
|
+
}), AppPlugin.addSurfaceModule({
|
|
17
|
+
activate: ReactSurface
|
|
18
|
+
}), AppPlugin.addTranslationsModule({
|
|
19
|
+
translations
|
|
20
|
+
}), Plugin.make);
|
|
21
|
+
var ExplorerPlugin_default = ExplorerPlugin;
|
|
22
|
+
export {
|
|
23
|
+
ExplorerPlugin,
|
|
24
|
+
ExplorerPlugin_default as default
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=ExplorerPlugin.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/ExplorerPlugin.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Plugin } from '@dxos/app-framework';\nimport { AppPlugin } from '@dxos/app-toolkit';\n\nimport { CreateObject, ReactSurface } from '#capabilities';\nimport { meta } from '#meta';\nimport { translations } from '#translations';\nimport { Graph } from '#types';\n\nexport const ExplorerPlugin = Plugin.define(meta).pipe(\n AppPlugin.addCreateObjectModule({ activate: CreateObject }),\n AppPlugin.addSchemaModule({ schema: [Graph.Graph] }),\n AppPlugin.addSurfaceModule({ activate: ReactSurface }),\n AppPlugin.addTranslationsModule({ translations }),\n Plugin.make,\n);\n\nexport default ExplorerPlugin;\n"],
|
|
5
|
+
"mappings": ";;;AAIA,SAASA,cAAc;AACvB,SAASC,iBAAiB;AAE1B,SAASC,cAAcC,oBAAoB;AAC3C,SAASC,YAAY;AACrB,SAASC,oBAAoB;AAC7B,SAASC,aAAa;AAEf,IAAMC,iBAAiBP,OAAOQ,OAAOJ,IAAAA,EAAMK,KAChDR,UAAUS,sBAAsB;EAAEC,UAAUT;AAAa,CAAA,GACzDD,UAAUW,gBAAgB;EAAEC,QAAQ;IAACP,MAAMA;;AAAO,CAAA,GAClDL,UAAUa,iBAAiB;EAAEH,UAAUR;AAAa,CAAA,GACpDF,UAAUc,sBAAsB;EAAEV;AAAa,CAAA,GAC/CL,OAAOgB,IAAI;AAGb,IAAA,yBAAeT;",
|
|
6
|
+
"names": ["Plugin", "AppPlugin", "CreateObject", "ReactSurface", "meta", "translations", "Graph", "ExplorerPlugin", "define", "pipe", "addCreateObjectModule", "activate", "addSchemaModule", "schema", "addSurfaceModule", "addTranslationsModule", "make"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "../chunk-J5LGTIGS.mjs";
|
|
2
|
+
|
|
3
|
+
// src/capabilities/index.ts
|
|
4
|
+
import { Capability } from "@dxos/app-framework";
|
|
5
|
+
var CreateObject = Capability.lazy("CreateObject", () => import("../create-object-F6TKVAGV.mjs"));
|
|
6
|
+
var ReactSurface = Capability.lazy("ReactSurface", () => import("../react-surface-U3JEY7V7.mjs"));
|
|
7
|
+
export {
|
|
8
|
+
CreateObject,
|
|
9
|
+
ReactSurface
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/capabilities/index.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capability } from '@dxos/app-framework';\n\nexport const CreateObject = Capability.lazy('CreateObject', () => import('./create-object'));\nexport const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));\n"],
|
|
5
|
+
"mappings": ";;;AAIA,SAASA,kBAAkB;AAEpB,IAAMC,eAAeD,WAAWE,KAAK,gBAAgB,MAAM,OAAO,+BAAA,CAAA;AAClE,IAAMC,eAAeH,WAAWE,KAAK,gBAAgB,MAAM,OAAO,+BAAA,CAAA;",
|
|
6
|
+
"names": ["Capability", "CreateObject", "lazy", "ReactSurface"]
|
|
7
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export
|
|
3
|
-
} from "
|
|
3
|
+
} from "./chunk-J5LGTIGS.mjs";
|
|
4
4
|
|
|
5
5
|
// src/types/ExplorerAction.ts
|
|
6
6
|
var ExplorerAction_exports = {};
|
|
@@ -8,7 +8,7 @@ __export(ExplorerAction_exports, {
|
|
|
8
8
|
GraphProps: () => GraphProps
|
|
9
9
|
});
|
|
10
10
|
import * as Schema from "effect/Schema";
|
|
11
|
-
import { TypeInputOptionsAnnotation } from "@dxos/plugin-space
|
|
11
|
+
import { TypeInputOptionsAnnotation } from "@dxos/plugin-space";
|
|
12
12
|
var GraphProps = Schema.Struct({
|
|
13
13
|
name: Schema.optional(Schema.String),
|
|
14
14
|
// TODO(wittjosiah): This should be a query input instead.
|
|
@@ -32,8 +32,7 @@ __export(Graph_exports, {
|
|
|
32
32
|
make: () => make
|
|
33
33
|
});
|
|
34
34
|
import * as Schema2 from "effect/Schema";
|
|
35
|
-
import { Annotation, Filter, Obj, Query, QueryAST, Ref, Type } from "@dxos/echo";
|
|
36
|
-
import { View } from "@dxos/echo";
|
|
35
|
+
import { Annotation, Filter, Obj, Query, QueryAST, Ref, Type, View } from "@dxos/echo";
|
|
37
36
|
import { FormInputAnnotation, LabelAnnotation } from "@dxos/echo/internal";
|
|
38
37
|
import { ViewAnnotation } from "@dxos/schema";
|
|
39
38
|
var GraphSchema = Schema2.Struct({
|
|
@@ -48,7 +47,9 @@ var GraphSchema = Schema2.Struct({
|
|
|
48
47
|
version: "0.1.0"
|
|
49
48
|
}), LabelAnnotation.set([
|
|
50
49
|
"name"
|
|
51
|
-
]), ViewAnnotation.set(
|
|
50
|
+
]), ViewAnnotation.set([
|
|
51
|
+
"view"
|
|
52
|
+
]), Annotation.IconAnnotation.set({
|
|
52
53
|
icon: "ph--graph--regular",
|
|
53
54
|
hue: "green"
|
|
54
55
|
}));
|
|
@@ -63,8 +64,9 @@ var make = ({ name, query = {
|
|
|
63
64
|
query
|
|
64
65
|
});
|
|
65
66
|
};
|
|
67
|
+
|
|
66
68
|
export {
|
|
67
|
-
ExplorerAction_exports
|
|
68
|
-
Graph_exports
|
|
69
|
+
ExplorerAction_exports,
|
|
70
|
+
Graph_exports
|
|
69
71
|
};
|
|
70
|
-
//# sourceMappingURL=
|
|
72
|
+
//# sourceMappingURL=chunk-7SPMPHRS.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 { TypeInputOptionsAnnotation } from '@dxos/plugin-space';\n\nexport const GraphProps = Schema.Struct({\n name: Schema.optional(Schema.String),\n // TODO(wittjosiah): This should be a query input instead.\n typename: Schema.String.pipe(\n Schema.annotations({ title: 'Select type' }),\n TypeInputOptionsAnnotation.set({\n location: ['database', 'runtime'],\n kind: ['user'],\n }),\n Schema.optional,\n ),\n});\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Annotation, Filter, Obj, Query, QueryAST, Ref, Type, View } from '@dxos/echo';\nimport { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/internal';\nimport { ViewAnnotation } from '@dxos/schema';\n\nconst GraphSchema = Schema.Struct({\n name: Schema.optional(Schema.String),\n\n view: Ref.Ref(View.View).pipe(FormInputAnnotation.set(false)),\n\n query: Schema.Struct({\n raw: Schema.optional(Schema.String),\n ast: QueryAST.Query,\n }).pipe(FormInputAnnotation.set(false)),\n}).pipe(\n Type.object({\n typename: 'org.dxos.type.graph',\n version: '0.1.0',\n }),\n LabelAnnotation.set(['name']),\n ViewAnnotation.set(['view']),\n Annotation.IconAnnotation.set({\n icon: 'ph--graph--regular',\n hue: 'green',\n }),\n);\nexport interface Graph extends Schema.Schema.Type<typeof GraphSchema> {}\nexport const Graph: Type.Obj<Graph> = GraphSchema as any;\n\ntype MakeProps = Omit<Partial<Obj.MakeProps<typeof Graph>>, 'view'> & {\n view: View.View;\n};\n\n/**\n * Make a graph as a view of a data set.\n */\nexport const make = ({\n name,\n query = { raw: '', ast: Query.select(Filter.nothing()).ast },\n view,\n}: MakeProps): Graph => {\n return Obj.make(Graph, { name, view: Ref.make(view), query });\n};\n"],
|
|
5
|
+
"mappings": ";;;;;AAAA;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,kCAAkC;AAEpC,IAAMC,aAAoBC,cAAO;EACtCC,MAAaC,gBAAgBC,aAAM;;EAEnCC,UAAiBD,cAAOE,KACfC,mBAAY;IAAEC,OAAO;EAAc,CAAA,GAC1CT,2BAA2BU,IAAI;IAC7BC,UAAU;MAAC;MAAY;;IACvBC,MAAM;MAAC;;EACT,CAAA,GACOR,eAAQ;AAEnB,CAAA;;;ACnBA;;;;;AAIA,YAAYS,aAAY;AAExB,SAASC,YAAYC,QAAQC,KAAKC,OAAOC,UAAUC,KAAKC,MAAMC,YAAY;AAC1E,SAASC,qBAAqBC,uBAAuB;AACrD,SAASC,sBAAsB;AAE/B,IAAMC,cAAqBC,eAAO;EAChCC,MAAaC,iBAAgBC,cAAM;EAEnCC,MAAMX,IAAIA,IAAIE,KAAKA,IAAI,EAAEU,KAAKT,oBAAoBU,IAAI,KAAA,CAAA;EAEtDC,OAAcP,eAAO;IACnBQ,KAAYN,iBAAgBC,cAAM;IAClCM,KAAKjB,SAASD;EAChB,CAAA,EAAGc,KAAKT,oBAAoBU,IAAI,KAAA,CAAA;AAClC,CAAA,EAAGD,KACDX,KAAKgB,OAAO;EACVC,UAAU;EACVC,SAAS;AACX,CAAA,GACAf,gBAAgBS,IAAI;EAAC;CAAO,GAC5BR,eAAeQ,IAAI;EAAC;CAAO,GAC3BlB,WAAWyB,eAAeP,IAAI;EAC5BQ,MAAM;EACNC,KAAK;AACP,CAAA,CAAA;AAGK,IAAMC,QAAyBjB;AAS/B,IAAMkB,OAAO,CAAC,EACnBhB,MACAM,QAAQ;EAAEC,KAAK;EAAIC,KAAKlB,MAAM2B,OAAO7B,OAAO8B,QAAO,CAAA,EAAIV;AAAI,GAC3DL,KAAI,MACM;AACV,SAAOd,IAAI2B,KAAKD,OAAO;IAAEf;IAAMG,MAAMX,IAAIwB,KAAKb,IAAAA;IAAOG;EAAM,CAAA;AAC7D;",
|
|
6
|
+
"names": ["Schema", "TypeInputOptionsAnnotation", "GraphProps", "Struct", "name", "optional", "String", "typename", "pipe", "annotations", "title", "set", "location", "kind", "Schema", "Annotation", "Filter", "Obj", "Query", "QueryAST", "Ref", "Type", "View", "FormInputAnnotation", "LabelAnnotation", "ViewAnnotation", "GraphSchema", "Struct", "name", "optional", "String", "view", "pipe", "set", "query", "raw", "ast", "object", "typename", "version", "IconAnnotation", "icon", "hue", "Graph", "make", "select", "nothing"]
|
|
7
|
+
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/meta.ts"],
|
|
4
4
|
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Plugin } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const meta: Plugin.Meta = {\n id: 'org.dxos.plugin.explorer',\n name: 'Explorer',\n description: trim`\n Interactive hypergraph visualization that reveals relationships between objects in your workspace.\n Navigate complex data structures and discover connections through a dynamic network view.\n `,\n icon: 'ph--graph--regular',\n iconHue: 'green',\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": ";AAKA,SAASA,YAAY;AAEd,IAAMC,OAAoB;EAC/BC,IAAI;EACJC,MAAM;EACNC,
|
|
6
|
-
"names": ["trim", "meta", "id", "name", "description", "
|
|
5
|
+
"mappings": ";AAKA,SAASA,YAAY;AAEd,IAAMC,OAAoB;EAC/BC,IAAI;EACJC,MAAM;EACNC,aAAaJ;;;;EAIbK,MAAM;EACNC,SAAS;EACTC,QAAQ;EACRC,MAAM;IAAC;;EACPC,aAAa;IAAC;;AAChB;",
|
|
6
|
+
"names": ["trim", "meta", "id", "name", "description", "icon", "iconHue", "source", "tags", "screenshots"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
meta
|
|
3
|
-
} from "./chunk-LSUP47BZ.mjs";
|
|
4
|
-
import "./chunk-J5LGTIGS.mjs";
|
|
1
|
+
import "../chunk-J5LGTIGS.mjs";
|
|
5
2
|
|
|
6
3
|
// src/components/Chart/Chart.tsx
|
|
7
4
|
import * as Plot from "@observablehq/plot";
|
|
@@ -10825,102 +10822,14 @@ var Globe = ({ items = [], accessor, projection = "orthographic", options = defa
|
|
|
10825
10822
|
});
|
|
10826
10823
|
};
|
|
10827
10824
|
|
|
10828
|
-
// src/components/Graph/
|
|
10829
|
-
import { Atom, useAtomValue } from "@effect-atom/atom-react";
|
|
10830
|
-
import React3, { useCallback, useEffect as useEffect3, useMemo, useRef } from "react";
|
|
10831
|
-
import { Obj } from "@dxos/echo";
|
|
10832
|
-
import { SelectionModel } from "@dxos/graph";
|
|
10833
|
-
import { GraphForceProjector, SVG } from "@dxos/react-ui-graph";
|
|
10834
|
-
import { composable, composableProps, getHashStyles } from "@dxos/ui-theme";
|
|
10835
|
-
import "@dxos/react-ui-graph/styles/graph.css";
|
|
10836
|
-
var EMPTY_ATOM = Atom.make({
|
|
10837
|
-
nodes: [],
|
|
10838
|
-
edges: []
|
|
10839
|
-
});
|
|
10840
|
-
var D3ForceGraph = composable(({ model, selection: _selection, grid, drag, ...props }, forwardedRef) => {
|
|
10841
|
-
useAtomValue(model?.graphAtom ?? EMPTY_ATOM);
|
|
10842
|
-
const svgRef = useRef(null);
|
|
10843
|
-
const projector = useMemo(() => {
|
|
10844
|
-
if (svgRef.current) {
|
|
10845
|
-
return new GraphForceProjector(svgRef.current, {
|
|
10846
|
-
attributes: {
|
|
10847
|
-
linkForce: (edge) => {
|
|
10848
|
-
return edge.data?.object?.active !== false;
|
|
10849
|
-
}
|
|
10850
|
-
},
|
|
10851
|
-
forces: {
|
|
10852
|
-
point: {
|
|
10853
|
-
strength: 0.01
|
|
10854
|
-
}
|
|
10855
|
-
}
|
|
10856
|
-
});
|
|
10857
|
-
}
|
|
10858
|
-
}, []);
|
|
10859
|
-
const graph = useRef(null);
|
|
10860
|
-
const selection = useMemo(() => _selection ?? new SelectionModel(), [
|
|
10861
|
-
_selection
|
|
10862
|
-
]);
|
|
10863
|
-
useEffect3(() => selection.subscribe(() => graph.current?.repaint()), [
|
|
10864
|
-
selection
|
|
10865
|
-
]);
|
|
10866
|
-
const handleSelect = useCallback((node) => {
|
|
10867
|
-
if (selection.contains(node.id)) {
|
|
10868
|
-
selection.remove(node.id);
|
|
10869
|
-
} else {
|
|
10870
|
-
selection.add(node.id);
|
|
10871
|
-
}
|
|
10872
|
-
}, [
|
|
10873
|
-
selection
|
|
10874
|
-
]);
|
|
10875
|
-
return /* @__PURE__ */ React3.createElement("div", {
|
|
10876
|
-
...composableProps(props, {
|
|
10877
|
-
classNames: "dx-container"
|
|
10878
|
-
}),
|
|
10879
|
-
ref: forwardedRef
|
|
10880
|
-
}, /* @__PURE__ */ React3.createElement(SVG.Root, {
|
|
10881
|
-
ref: svgRef
|
|
10882
|
-
}, /* @__PURE__ */ React3.createElement(SVG.Markers, null), grid && /* @__PURE__ */ React3.createElement(SVG.Grid, {
|
|
10883
|
-
axis: true
|
|
10884
|
-
}), /* @__PURE__ */ React3.createElement(SVG.Zoom, {
|
|
10885
|
-
extent: [
|
|
10886
|
-
1 / 2,
|
|
10887
|
-
2
|
|
10888
|
-
]
|
|
10889
|
-
}, /* @__PURE__ */ React3.createElement(SVG.Graph, {
|
|
10890
|
-
drag,
|
|
10891
|
-
ref: graph,
|
|
10892
|
-
model,
|
|
10893
|
-
projector,
|
|
10894
|
-
labels: {
|
|
10895
|
-
text: (node) => {
|
|
10896
|
-
return node.data?.data.label ?? node.id;
|
|
10897
|
-
}
|
|
10898
|
-
},
|
|
10899
|
-
attributes: {
|
|
10900
|
-
node: (node) => {
|
|
10901
|
-
const obj = node.data?.data.object;
|
|
10902
|
-
return {
|
|
10903
|
-
data: {
|
|
10904
|
-
color: getHashStyles(obj && Obj.getTypename(obj))?.hue
|
|
10905
|
-
},
|
|
10906
|
-
classes: {
|
|
10907
|
-
"dx-selected": selection.contains(node.id)
|
|
10908
|
-
}
|
|
10909
|
-
};
|
|
10910
|
-
}
|
|
10911
|
-
},
|
|
10912
|
-
onSelect: handleSelect
|
|
10913
|
-
}))));
|
|
10914
|
-
});
|
|
10915
|
-
|
|
10916
|
-
// src/components/Graph/ForceGraph.tsx
|
|
10825
|
+
// src/components/Graph/CanvasForceGraph.tsx
|
|
10917
10826
|
import { forceLink, forceManyBody } from "d3";
|
|
10918
10827
|
import NativeForceGraph from "force-graph";
|
|
10919
|
-
import
|
|
10828
|
+
import React3, { useCallback, useEffect as useEffect3, useRef, useState } from "react";
|
|
10920
10829
|
import { useResizeDetector as useResizeDetector3 } from "react-resize-detector";
|
|
10921
|
-
import {
|
|
10830
|
+
import { composable, composableProps } from "@dxos/ui-theme";
|
|
10922
10831
|
|
|
10923
|
-
// src/components/Graph/adapter.ts
|
|
10832
|
+
// src/components/Graph/graph-adapter.ts
|
|
10924
10833
|
var GraphAdapter = class {
|
|
10925
10834
|
graph;
|
|
10926
10835
|
_nodes = [];
|
|
@@ -10948,24 +10857,27 @@ var GraphAdapter = class {
|
|
|
10948
10857
|
}
|
|
10949
10858
|
};
|
|
10950
10859
|
|
|
10951
|
-
// src/components/Graph/
|
|
10952
|
-
var
|
|
10953
|
-
const { ref, width, height } = useResizeDetector3({
|
|
10860
|
+
// src/components/Graph/CanvasForceGraph.tsx
|
|
10861
|
+
var CanvasForceGraph = composable(({ model, match, onClick, ...props }, forwardedRef) => {
|
|
10862
|
+
const { ref: resizeRef, width, height } = useResizeDetector3({
|
|
10954
10863
|
refreshRate: 200
|
|
10955
10864
|
});
|
|
10956
|
-
const
|
|
10957
|
-
|
|
10958
|
-
|
|
10959
|
-
|
|
10865
|
+
const setRef = useCallback((node) => {
|
|
10866
|
+
resizeRef(node);
|
|
10867
|
+
assignRef(forwardedRef, node);
|
|
10868
|
+
}, [
|
|
10869
|
+
resizeRef,
|
|
10870
|
+
forwardedRef
|
|
10871
|
+
]);
|
|
10872
|
+
const rootRef = useRef(null);
|
|
10873
|
+
const forceGraph = useRef(null);
|
|
10960
10874
|
const [data, setData] = useState();
|
|
10961
|
-
|
|
10962
|
-
return model?.subscribe((model2) =>
|
|
10963
|
-
setData(new GraphAdapter(model2.graph));
|
|
10964
|
-
});
|
|
10875
|
+
useEffect3(() => {
|
|
10876
|
+
return model?.subscribe((model2) => setData(new GraphAdapter(model2.graph)));
|
|
10965
10877
|
}, [
|
|
10966
10878
|
model
|
|
10967
10879
|
]);
|
|
10968
|
-
|
|
10880
|
+
useEffect3(() => {
|
|
10969
10881
|
if (rootRef.current) {
|
|
10970
10882
|
forceGraph.current = new NativeForceGraph(rootRef.current).nodeRelSize(6).nodeLabel((node) => node.type === "schema" ? node.data.typename : node.data.label ?? node.id).nodeAutoColorBy((node) => node.type === "schema" ? "schema" : node.data.typename).linkAutoColorBy((link2) => link2.type);
|
|
10971
10883
|
}
|
|
@@ -10977,37 +10889,142 @@ var ForceGraph = ({ model, match }) => {
|
|
|
10977
10889
|
forceGraph.current = null;
|
|
10978
10890
|
};
|
|
10979
10891
|
}, []);
|
|
10980
|
-
|
|
10892
|
+
useEffect3(() => {
|
|
10981
10893
|
if (!data || !width || !height || !forceGraph.current) {
|
|
10982
10894
|
return;
|
|
10983
10895
|
}
|
|
10984
|
-
forceGraph.current.pauseAnimation().width(width).height(height).onEngineStop(() => {
|
|
10985
|
-
handleZoomToFit();
|
|
10986
|
-
}).onNodeClick((node) => {
|
|
10896
|
+
forceGraph.current.pauseAnimation().width(width).height(height).onEngineStop(() => handleZoomToFit()).onNodeClick((node) => {
|
|
10987
10897
|
forceGraph.current?.emitParticle(node);
|
|
10988
10898
|
}).d3Force("link", forceLink().distance(160).strength(0.5)).d3Force("charge", forceManyBody().strength(-30)).graphData(data).warmupTicks(100).cooldownTime(1e3).resumeAnimation();
|
|
10989
10899
|
}, [
|
|
10990
10900
|
data,
|
|
10991
10901
|
width,
|
|
10992
|
-
height
|
|
10993
|
-
forceGraph.current
|
|
10902
|
+
height
|
|
10994
10903
|
]);
|
|
10995
10904
|
const handleZoomToFit = () => {
|
|
10996
10905
|
forceGraph.current?.zoomToFit(400, 40);
|
|
10997
10906
|
};
|
|
10998
|
-
|
|
10999
|
-
|
|
11000
|
-
|
|
11001
|
-
|
|
11002
|
-
|
|
10907
|
+
const handleClick = useCallback((event) => {
|
|
10908
|
+
onClick?.(event);
|
|
10909
|
+
if (!event.defaultPrevented) {
|
|
10910
|
+
handleZoomToFit();
|
|
10911
|
+
}
|
|
10912
|
+
}, [
|
|
10913
|
+
onClick
|
|
10914
|
+
]);
|
|
10915
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
10916
|
+
...composableProps(props, {
|
|
10917
|
+
classNames: "relative grow"
|
|
10918
|
+
}),
|
|
10919
|
+
onClick: handleClick,
|
|
10920
|
+
ref: setRef
|
|
10921
|
+
}, /* @__PURE__ */ React3.createElement("div", {
|
|
11003
10922
|
ref: rootRef,
|
|
11004
10923
|
className: "absolute inset-0"
|
|
11005
10924
|
}));
|
|
10925
|
+
});
|
|
10926
|
+
var assignRef = (ref, value) => {
|
|
10927
|
+
if (typeof ref === "function") {
|
|
10928
|
+
ref(value);
|
|
10929
|
+
} else if (ref) {
|
|
10930
|
+
ref.current = value;
|
|
10931
|
+
}
|
|
11006
10932
|
};
|
|
11007
10933
|
|
|
10934
|
+
// src/components/Graph/ForceGraph.tsx
|
|
10935
|
+
import { Atom, useAtomValue } from "@effect-atom/atom-react";
|
|
10936
|
+
import React4, { useCallback as useCallback2, useEffect as useEffect4, useMemo, useRef as useRef2, useState as useState2 } from "react";
|
|
10937
|
+
import { Obj } from "@dxos/echo";
|
|
10938
|
+
import { SelectionModel } from "@dxos/graph";
|
|
10939
|
+
import { GraphForceProjector, SVG } from "@dxos/react-ui-graph";
|
|
10940
|
+
import { composable as composable2, composableProps as composableProps2, getHashStyles } from "@dxos/ui-theme";
|
|
10941
|
+
import "@dxos/react-ui-graph/styles/graph.css";
|
|
10942
|
+
var EMPTY_ATOM = Atom.make({
|
|
10943
|
+
nodes: [],
|
|
10944
|
+
edges: []
|
|
10945
|
+
});
|
|
10946
|
+
var ForceGraph = composable2(({ model, selection: selectionProp, grid, drag, onInspect, ...props }, forwardedRef) => {
|
|
10947
|
+
useAtomValue(model?.graphAtom ?? EMPTY_ATOM);
|
|
10948
|
+
const graph = useRef2(null);
|
|
10949
|
+
const selection = useMemo(() => selectionProp ?? new SelectionModel(), [
|
|
10950
|
+
selectionProp
|
|
10951
|
+
]);
|
|
10952
|
+
useEffect4(() => {
|
|
10953
|
+
const unsubscribe = selection.subscribe(() => graph.current?.repaint());
|
|
10954
|
+
return unsubscribe;
|
|
10955
|
+
}, [
|
|
10956
|
+
selection
|
|
10957
|
+
]);
|
|
10958
|
+
const svgRef = useRef2(null);
|
|
10959
|
+
const [projector, setProjector] = useState2();
|
|
10960
|
+
useEffect4(() => {
|
|
10961
|
+
if (svgRef.current) {
|
|
10962
|
+
setProjector(new GraphForceProjector(svgRef.current, {
|
|
10963
|
+
attributes: {
|
|
10964
|
+
// TODO(burdon): Check type (currently assumes Employee property).
|
|
10965
|
+
// Edge shouldn't contribute to force if it's not active.
|
|
10966
|
+
linkForce: (edge) => edge.data?.object?.active !== false
|
|
10967
|
+
},
|
|
10968
|
+
forces: {
|
|
10969
|
+
point: {
|
|
10970
|
+
strength: 0.01
|
|
10971
|
+
}
|
|
10972
|
+
}
|
|
10973
|
+
}));
|
|
10974
|
+
}
|
|
10975
|
+
}, []);
|
|
10976
|
+
const handleSelect = useCallback2((node) => {
|
|
10977
|
+
if (selection.contains(node.id)) {
|
|
10978
|
+
selection.remove(node.id);
|
|
10979
|
+
} else {
|
|
10980
|
+
selection.add(node.id);
|
|
10981
|
+
}
|
|
10982
|
+
}, [
|
|
10983
|
+
selection
|
|
10984
|
+
]);
|
|
10985
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
10986
|
+
...composableProps2(props, {
|
|
10987
|
+
classNames: "dx-container"
|
|
10988
|
+
}),
|
|
10989
|
+
ref: forwardedRef
|
|
10990
|
+
}, /* @__PURE__ */ React4.createElement(SVG.Root, {
|
|
10991
|
+
ref: svgRef
|
|
10992
|
+
}, /* @__PURE__ */ React4.createElement(SVG.Markers, null), grid && /* @__PURE__ */ React4.createElement(SVG.Grid, {
|
|
10993
|
+
axis: true
|
|
10994
|
+
}), /* @__PURE__ */ React4.createElement(SVG.Zoom, {
|
|
10995
|
+
extent: [
|
|
10996
|
+
1 / 2,
|
|
10997
|
+
2
|
|
10998
|
+
]
|
|
10999
|
+
}, /* @__PURE__ */ React4.createElement(SVG.Graph, {
|
|
11000
|
+
drag,
|
|
11001
|
+
ref: graph,
|
|
11002
|
+
model,
|
|
11003
|
+
projector,
|
|
11004
|
+
labels: {
|
|
11005
|
+
text: (node) => node.data?.data.label ?? node.id
|
|
11006
|
+
},
|
|
11007
|
+
attributes: {
|
|
11008
|
+
node: (node) => {
|
|
11009
|
+
const obj = node.data?.data.object;
|
|
11010
|
+
return {
|
|
11011
|
+
data: {
|
|
11012
|
+
color: getHashStyles(obj && Obj.getTypename(obj))?.hue
|
|
11013
|
+
},
|
|
11014
|
+
classes: {
|
|
11015
|
+
"dx-selected": selection.contains(node.id)
|
|
11016
|
+
}
|
|
11017
|
+
};
|
|
11018
|
+
}
|
|
11019
|
+
},
|
|
11020
|
+
onSelect: handleSelect,
|
|
11021
|
+
onInspect
|
|
11022
|
+
}))));
|
|
11023
|
+
});
|
|
11024
|
+
|
|
11008
11025
|
// src/components/Tree/Tree.tsx
|
|
11009
11026
|
import { RegistryContext } from "@effect-atom/atom-react";
|
|
11010
|
-
import React5, { useContext, useEffect as useEffect5, useRef as useRef3, useState as
|
|
11027
|
+
import React5, { useContext, useEffect as useEffect5, useRef as useRef3, useState as useState3 } from "react";
|
|
11011
11028
|
import { useAsyncState } from "@dxos/react-ui";
|
|
11012
11029
|
import { SVG as SVG2 } from "@dxos/react-ui-graph";
|
|
11013
11030
|
import { SpaceGraphModel } from "@dxos/schema";
|
|
@@ -11203,7 +11220,7 @@ var Tree = ({ space, selected, variant = "tidy", onNodeClick }) => {
|
|
|
11203
11220
|
selected,
|
|
11204
11221
|
registry
|
|
11205
11222
|
]);
|
|
11206
|
-
const [tree3, setTree] =
|
|
11223
|
+
const [tree3, setTree] = useState3();
|
|
11207
11224
|
useEffect5(() => {
|
|
11208
11225
|
return model?.subscribe(() => {
|
|
11209
11226
|
const tree4 = mapGraphToTreeData(model);
|
|
@@ -11246,129 +11263,12 @@ var Tree = ({ space, selected, variant = "tidy", onNodeClick }) => {
|
|
|
11246
11263
|
ref: context
|
|
11247
11264
|
}));
|
|
11248
11265
|
};
|
|
11249
|
-
|
|
11250
|
-
// src/hooks/useGraphModel.ts
|
|
11251
|
-
import { useEffect as useEffect6, useState as useState3 } from "react";
|
|
11252
|
-
import { Capabilities } from "@dxos/app-framework";
|
|
11253
|
-
import { useCapability } from "@dxos/app-framework/ui";
|
|
11254
|
-
import { SpaceGraphModel as SpaceGraphModel2 } from "@dxos/schema";
|
|
11255
|
-
var useGraphModel = (space, filter, options, queue) => {
|
|
11256
|
-
const registry = useCapability(Capabilities.AtomRegistry);
|
|
11257
|
-
const [model, setModel] = useState3(void 0);
|
|
11258
|
-
useEffect6(() => {
|
|
11259
|
-
if (!space) {
|
|
11260
|
-
setModel(void 0);
|
|
11261
|
-
return;
|
|
11262
|
-
}
|
|
11263
|
-
const newModel = new SpaceGraphModel2(registry);
|
|
11264
|
-
void newModel.open(space.db, queue);
|
|
11265
|
-
setModel(newModel);
|
|
11266
|
-
return () => {
|
|
11267
|
-
setModel(void 0);
|
|
11268
|
-
void newModel.close();
|
|
11269
|
-
};
|
|
11270
|
-
}, [
|
|
11271
|
-
space,
|
|
11272
|
-
registry,
|
|
11273
|
-
queue
|
|
11274
|
-
]);
|
|
11275
|
-
useEffect6(() => {
|
|
11276
|
-
model?.setFilter(filter).setOptions(options);
|
|
11277
|
-
}, [
|
|
11278
|
-
model,
|
|
11279
|
-
filter,
|
|
11280
|
-
options
|
|
11281
|
-
]);
|
|
11282
|
-
return model;
|
|
11283
|
-
};
|
|
11284
|
-
|
|
11285
|
-
// src/ExplorerPlugin.tsx
|
|
11286
|
-
import * as Effect from "effect/Effect";
|
|
11287
|
-
import * as Option from "effect/Option";
|
|
11288
|
-
import { Plugin } from "@dxos/app-framework";
|
|
11289
|
-
import { AppPlugin } from "@dxos/app-toolkit";
|
|
11290
|
-
import { Annotation, Type as Type3 } from "@dxos/echo";
|
|
11291
|
-
import { Operation } from "@dxos/operation";
|
|
11292
|
-
import { SpaceOperation } from "@dxos/plugin-space/operations";
|
|
11293
|
-
import { ViewModel } from "@dxos/schema";
|
|
11294
|
-
import { ReactSurface } from "#capabilities";
|
|
11295
|
-
import { meta as meta3 } from "#meta";
|
|
11296
|
-
import { ExplorerAction, Graph as Graph2 } from "#types";
|
|
11297
|
-
|
|
11298
|
-
// src/translations.ts
|
|
11299
|
-
import { Type as Type2 } from "@dxos/echo";
|
|
11300
|
-
import { translations as componentsTranslations } from "@dxos/react-ui-components";
|
|
11301
|
-
import { meta as meta2 } from "#meta";
|
|
11302
|
-
import { Graph } from "#types";
|
|
11303
|
-
var translations = [
|
|
11304
|
-
{
|
|
11305
|
-
"en-US": {
|
|
11306
|
-
[Type2.getTypename(Graph.Graph)]: {
|
|
11307
|
-
"typename.label": "Explorer",
|
|
11308
|
-
"typename.label_zero": "Explorers",
|
|
11309
|
-
"typename.label_one": "Explorer",
|
|
11310
|
-
"typename.label_other": "Explorers",
|
|
11311
|
-
"object-name.placeholder": "New explorer",
|
|
11312
|
-
"add-object.label": "Add explorer",
|
|
11313
|
-
"rename-object.label": "Rename explorer",
|
|
11314
|
-
"delete-object.label": "Delete explorer",
|
|
11315
|
-
"object-deleted.label": "Explorer deleted"
|
|
11316
|
-
},
|
|
11317
|
-
[meta2.id]: {
|
|
11318
|
-
"plugin.name": "Explorer",
|
|
11319
|
-
"object-title.label": "Title"
|
|
11320
|
-
}
|
|
11321
|
-
}
|
|
11322
|
-
},
|
|
11323
|
-
...componentsTranslations
|
|
11324
|
-
];
|
|
11325
|
-
|
|
11326
|
-
// src/ExplorerPlugin.tsx
|
|
11327
|
-
var ExplorerPlugin = Plugin.define(meta3).pipe(AppPlugin.addMetadataModule({
|
|
11328
|
-
metadata: {
|
|
11329
|
-
id: Type3.getTypename(Graph2.Graph),
|
|
11330
|
-
metadata: {
|
|
11331
|
-
icon: Annotation.IconAnnotation.get(Graph2.Graph).pipe(Option.getOrThrow).icon,
|
|
11332
|
-
iconHue: Annotation.IconAnnotation.get(Graph2.Graph).pipe(Option.getOrThrow).hue ?? "white",
|
|
11333
|
-
inputSchema: ExplorerAction.GraphProps,
|
|
11334
|
-
createObject: (props, options) => Effect.gen(function* () {
|
|
11335
|
-
const object = yield* Effect.promise(async () => {
|
|
11336
|
-
const { view } = await ViewModel.makeFromDatabase({
|
|
11337
|
-
db: options.db,
|
|
11338
|
-
typename: props.typename
|
|
11339
|
-
});
|
|
11340
|
-
return Graph2.make({
|
|
11341
|
-
name: props.name,
|
|
11342
|
-
view
|
|
11343
|
-
});
|
|
11344
|
-
});
|
|
11345
|
-
return yield* Operation.invoke(SpaceOperation.AddObject, {
|
|
11346
|
-
object,
|
|
11347
|
-
target: options.target,
|
|
11348
|
-
hidden: true,
|
|
11349
|
-
targetNodeId: options.targetNodeId
|
|
11350
|
-
});
|
|
11351
|
-
})
|
|
11352
|
-
}
|
|
11353
|
-
}
|
|
11354
|
-
}), AppPlugin.addSchemaModule({
|
|
11355
|
-
schema: [
|
|
11356
|
-
Graph2.Graph
|
|
11357
|
-
]
|
|
11358
|
-
}), AppPlugin.addSurfaceModule({
|
|
11359
|
-
activate: ReactSurface
|
|
11360
|
-
}), AppPlugin.addTranslationsModule({
|
|
11361
|
-
translations
|
|
11362
|
-
}), Plugin.make);
|
|
11363
11266
|
export {
|
|
11267
|
+
CanvasForceGraph,
|
|
11364
11268
|
Chart,
|
|
11365
|
-
D3ForceGraph,
|
|
11366
|
-
ExplorerPlugin,
|
|
11367
11269
|
ForceGraph,
|
|
11368
11270
|
Globe,
|
|
11369
11271
|
Tree,
|
|
11370
|
-
defaultTreeLayoutSlots
|
|
11371
|
-
meta,
|
|
11372
|
-
useGraphModel
|
|
11272
|
+
defaultTreeLayoutSlots
|
|
11373
11273
|
};
|
|
11374
11274
|
//# sourceMappingURL=index.mjs.map
|