@dxos/plugin-explorer 0.8.4-main.ae835ea → 0.8.4-main.bc674ce
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-BFAWRIAJ.mjs +45 -0
- package/dist/lib/browser/ExplorerContainer-BFAWRIAJ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-CRN65FY3.mjs → chunk-AGZAGILW.mjs} +135 -148
- package/dist/lib/{node-esm/chunk-RSZFBKZM.mjs.map → browser/chunk-AGZAGILW.mjs.map} +3 -3
- package/dist/lib/browser/{chunk-2MKBRIUT.mjs → chunk-BZMTFAP3.mjs} +8 -5
- package/dist/lib/browser/chunk-BZMTFAP3.mjs.map +7 -0
- package/dist/lib/browser/chunk-HIFLWHXR.mjs +83 -0
- package/dist/lib/browser/chunk-HIFLWHXR.mjs.map +7 -0
- package/dist/lib/browser/chunk-MGBT2ZFU.mjs +177 -0
- package/dist/lib/browser/chunk-MGBT2ZFU.mjs.map +7 -0
- package/dist/lib/browser/{chunk-UBHZGWZQ.mjs → chunk-YNQF4CPY.mjs} +1 -1
- package/dist/lib/browser/chunk-YNQF4CPY.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +46 -65
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +1 -1
- package/dist/lib/browser/react-surface-RWVHQL3J.mjs +35 -0
- package/dist/lib/browser/react-surface-RWVHQL3J.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -2
- package/dist/lib/node-esm/ExplorerContainer-YQ2KKBVS.mjs +46 -0
- package/dist/lib/node-esm/ExplorerContainer-YQ2KKBVS.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-3OE6TBJI.mjs +84 -0
- package/dist/lib/node-esm/chunk-3OE6TBJI.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-UXZM5VJB.mjs → chunk-DK77RB6M.mjs} +1 -1
- package/dist/lib/node-esm/chunk-DK77RB6M.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-3ODK27PU.mjs → chunk-IPIGIQHX.mjs} +8 -5
- package/dist/lib/node-esm/chunk-IPIGIQHX.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-RSZFBKZM.mjs → chunk-QLMTN2XI.mjs} +135 -148
- package/dist/lib/{browser/chunk-CRN65FY3.mjs.map → node-esm/chunk-QLMTN2XI.mjs.map} +3 -3
- package/dist/lib/node-esm/chunk-YWJBDETV.mjs +179 -0
- package/dist/lib/node-esm/chunk-YWJBDETV.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +46 -65
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/meta.mjs +1 -1
- package/dist/lib/node-esm/react-surface-3REUS7KW.mjs +36 -0
- package/dist/lib/node-esm/react-surface-3REUS7KW.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +1 -2
- package/dist/types/src/ExplorerPlugin.d.ts +2 -1
- package/dist/types/src/ExplorerPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +1 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/components/ExplorerContainer.d.ts +4 -6
- package/dist/types/src/components/ExplorerContainer.d.ts.map +1 -1
- package/dist/types/src/components/Graph/D3ForceGraph.d.ts.map +1 -1
- package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts.map +1 -1
- package/dist/types/src/components/Graph/ForceGraph.stories.d.ts.map +1 -1
- package/dist/types/src/components/Graph/adapter.d.ts +1 -1
- package/dist/types/src/components/Graph/adapter.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.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 +17 -15
- package/dist/types/src/components/Tree/types/tree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/types/types.d.ts +1 -1
- package/dist/types/src/components/Tree/types/types.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useGraphModel.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +17 -10
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/ExplorerAction.d.ts +1 -18
- package/dist/types/src/types/ExplorerAction.d.ts.map +1 -1
- package/dist/types/src/types/Graph.d.ts +21 -24
- package/dist/types/src/types/Graph.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +52 -47
- package/src/ExplorerPlugin.tsx +27 -52
- package/src/capabilities/index.ts +1 -4
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +30 -0
- package/src/components/Chart/Chart.stories.tsx +2 -2
- package/src/components/ExplorerContainer.tsx +7 -9
- package/src/components/Globe/Globe.stories.tsx +2 -2
- package/src/components/Graph/D3ForceGraph.stories.tsx +19 -13
- package/src/components/Graph/D3ForceGraph.tsx +2 -2
- package/src/components/Graph/ForceGraph.stories.tsx +19 -13
- package/src/components/Graph/adapter.ts +14 -8
- package/src/components/Graph/testing.ts +11 -8
- package/src/components/Tree/Tree.stories.tsx +3 -2
- package/src/components/Tree/Tree.tsx +8 -3
- package/src/components/Tree/testing/generator.ts +4 -2
- package/src/components/Tree/types/tree.test.ts +5 -3
- package/src/components/Tree/types/tree.ts +39 -18
- package/src/components/Tree/types/types.ts +1 -1
- package/src/components/index.ts +3 -3
- package/src/hooks/useGraphModel.ts +6 -4
- package/src/meta.ts +2 -2
- package/src/translations.ts +3 -1
- package/src/types/ExplorerAction.ts +11 -19
- package/src/types/Graph.ts +38 -21
- package/dist/lib/browser/ExplorerContainer-L5RVUJRL.mjs +0 -50
- package/dist/lib/browser/ExplorerContainer-L5RVUJRL.mjs.map +0 -7
- package/dist/lib/browser/chunk-2MKBRIUT.mjs.map +0 -7
- package/dist/lib/browser/chunk-6BVXZQPP.mjs +0 -188
- package/dist/lib/browser/chunk-6BVXZQPP.mjs.map +0 -7
- package/dist/lib/browser/chunk-BGNRYZUN.mjs +0 -79
- package/dist/lib/browser/chunk-BGNRYZUN.mjs.map +0 -7
- package/dist/lib/browser/chunk-UBHZGWZQ.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-FX5H52QN.mjs +0 -31
- package/dist/lib/browser/intent-resolver-FX5H52QN.mjs.map +0 -7
- package/dist/lib/browser/react-surface-VS3ZFL2Y.mjs +0 -35
- package/dist/lib/browser/react-surface-VS3ZFL2Y.mjs.map +0 -7
- package/dist/lib/node-esm/ExplorerContainer-BBLPHH7K.mjs +0 -51
- package/dist/lib/node-esm/ExplorerContainer-BBLPHH7K.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3ODK27PU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CRSVAZNA.mjs +0 -190
- package/dist/lib/node-esm/chunk-CRSVAZNA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-TQESRBUJ.mjs +0 -80
- package/dist/lib/node-esm/chunk-TQESRBUJ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UXZM5VJB.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-RGBBXXYM.mjs +0 -32
- package/dist/lib/node-esm/intent-resolver-RGBBXXYM.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-SXPT2T37.mjs +0 -36
- package/dist/lib/node-esm/react-surface-SXPT2T37.mjs.map +0 -7
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/src/capabilities/intent-resolver.ts +0 -21
- package/src/capabilities/react-surface.tsx +0 -27
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// src/hooks/useGraphModel.ts
|
|
2
|
-
import {
|
|
2
|
+
import { RegistryContext } from "@effect-atom/atom-react";
|
|
3
|
+
import { useContext, useEffect, useState } from "react";
|
|
3
4
|
import { SpaceGraphModel } from "@dxos/schema";
|
|
4
5
|
var useGraphModel = (space, filter, options, queue) => {
|
|
6
|
+
const registry = useContext(RegistryContext);
|
|
5
7
|
const [model, setModel] = useState(void 0);
|
|
6
8
|
useEffect(() => {
|
|
7
9
|
if (!space) {
|
|
@@ -10,8 +12,8 @@ var useGraphModel = (space, filter, options, queue) => {
|
|
|
10
12
|
return;
|
|
11
13
|
}
|
|
12
14
|
if (!model || model.queue !== queue) {
|
|
13
|
-
const model2 = new SpaceGraphModel().setFilter(filter).setOptions(options);
|
|
14
|
-
void model2.open(space, queue);
|
|
15
|
+
const model2 = new SpaceGraphModel(registry).setFilter(filter).setOptions(options);
|
|
16
|
+
void model2.open(space.db, queue);
|
|
15
17
|
setModel(model2);
|
|
16
18
|
} else {
|
|
17
19
|
model.setFilter(filter).setOptions(options);
|
|
@@ -20,7 +22,8 @@ var useGraphModel = (space, filter, options, queue) => {
|
|
|
20
22
|
space,
|
|
21
23
|
filter,
|
|
22
24
|
options,
|
|
23
|
-
queue
|
|
25
|
+
queue,
|
|
26
|
+
registry
|
|
24
27
|
]);
|
|
25
28
|
return model;
|
|
26
29
|
};
|
|
@@ -28,4 +31,4 @@ var useGraphModel = (space, filter, options, queue) => {
|
|
|
28
31
|
export {
|
|
29
32
|
useGraphModel
|
|
30
33
|
};
|
|
31
|
-
//# sourceMappingURL=chunk-
|
|
34
|
+
//# sourceMappingURL=chunk-BZMTFAP3.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/useGraphModel.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { RegistryContext } from '@effect-atom/atom-react';\nimport { useContext, useEffect, useState } from 'react';\n\nimport { type Filter, type Queue, type Space } from '@dxos/client/echo';\nimport { SpaceGraphModel, type SpaceGraphModelOptions } from '@dxos/schema';\n\n// TODO(burdon): Factor out.\nexport const useGraphModel = (\n space: Space | undefined,\n filter?: Filter.Any | undefined,\n options?: SpaceGraphModelOptions,\n queue?: Queue,\n): SpaceGraphModel | undefined => {\n const registry = useContext(RegistryContext);\n const [model, setModel] = useState<SpaceGraphModel | undefined>(undefined);\n useEffect(() => {\n if (!space) {\n void model?.close();\n setModel(undefined);\n return;\n }\n\n // TODO(burdon): Does this need to be a dependency?\n if (!model || model.queue !== queue) {\n const model = new SpaceGraphModel(registry).setFilter(filter).setOptions(options);\n void model.open(space.db, queue);\n setModel(model);\n } else {\n model.setFilter(filter).setOptions(options);\n }\n }, [space, filter, options, queue, registry]);\n\n return model;\n};\n"],
|
|
5
|
+
"mappings": ";AAIA,SAASA,uBAAuB;AAChC,SAASC,YAAYC,WAAWC,gBAAgB;AAGhD,SAASC,uBAAoD;AAGtD,IAAMC,gBAAgB,CAC3BC,OACAC,QACAC,SACAC,UAAAA;AAEA,QAAMC,WAAWC,WAAWC,eAAAA;AAC5B,QAAM,CAACC,OAAOC,QAAAA,IAAYC,SAAsCC,MAAAA;AAChEC,YAAU,MAAA;AACR,QAAI,CAACX,OAAO;AACV,WAAKO,OAAOK,MAAAA;AACZJ,eAASE,MAAAA;AACT;IACF;AAGA,QAAI,CAACH,SAASA,MAAMJ,UAAUA,OAAO;AACnC,YAAMI,SAAQ,IAAIM,gBAAgBT,QAAAA,EAAUU,UAAUb,MAAAA,EAAQc,WAAWb,OAAAA;AACzE,WAAKK,OAAMS,KAAKhB,MAAMiB,IAAId,KAAAA;AAC1BK,eAASD,MAAAA;IACX,OAAO;AACLA,YAAMO,UAAUb,MAAAA,EAAQc,WAAWb,OAAAA;IACrC;EACF,GAAG;IAACF;IAAOC;IAAQC;IAASC;IAAOC;GAAS;AAE5C,SAAOG;AACT;",
|
|
6
|
+
"names": ["RegistryContext", "useContext", "useEffect", "useState", "SpaceGraphModel", "useGraphModel", "space", "filter", "options", "queue", "registry", "useContext", "RegistryContext", "model", "setModel", "useState", "undefined", "useEffect", "close", "SpaceGraphModel", "setFilter", "setOptions", "open", "db"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./chunk-J5LGTIGS.mjs";
|
|
4
|
+
|
|
5
|
+
// src/types/ExplorerAction.ts
|
|
6
|
+
var ExplorerAction_exports = {};
|
|
7
|
+
__export(ExplorerAction_exports, {
|
|
8
|
+
GraphProps: () => GraphProps
|
|
9
|
+
});
|
|
10
|
+
import * as Schema from "effect/Schema";
|
|
11
|
+
import { TypeInputOptionsAnnotation } from "@dxos/plugin-space/types";
|
|
12
|
+
var GraphProps = Schema.Struct({
|
|
13
|
+
name: Schema.optional(Schema.String),
|
|
14
|
+
// TODO(wittjosiah): This should be a query input instead.
|
|
15
|
+
typename: Schema.String.pipe(Schema.annotations({
|
|
16
|
+
title: "Select type"
|
|
17
|
+
}), TypeInputOptionsAnnotation.set({
|
|
18
|
+
location: [
|
|
19
|
+
"database",
|
|
20
|
+
"runtime"
|
|
21
|
+
],
|
|
22
|
+
kind: [
|
|
23
|
+
"user"
|
|
24
|
+
],
|
|
25
|
+
registered: [
|
|
26
|
+
"registered"
|
|
27
|
+
]
|
|
28
|
+
}), Schema.optional)
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// src/types/Graph.ts
|
|
32
|
+
var Graph_exports = {};
|
|
33
|
+
__export(Graph_exports, {
|
|
34
|
+
Graph: () => Graph,
|
|
35
|
+
GraphV1: () => GraphV1,
|
|
36
|
+
make: () => make
|
|
37
|
+
});
|
|
38
|
+
import * as Schema2 from "effect/Schema";
|
|
39
|
+
import { Filter, Obj, Query, QueryAST, Ref, Type } from "@dxos/echo";
|
|
40
|
+
import { FormInputAnnotation, LabelAnnotation } from "@dxos/echo/internal";
|
|
41
|
+
import { View, ViewAnnotation } from "@dxos/schema";
|
|
42
|
+
var GraphSchema = Schema2.Struct({
|
|
43
|
+
name: Schema2.optional(Schema2.String),
|
|
44
|
+
view: Type.Ref(View.View).pipe(FormInputAnnotation.set(false)),
|
|
45
|
+
query: Schema2.Struct({
|
|
46
|
+
raw: Schema2.optional(Schema2.String),
|
|
47
|
+
ast: QueryAST.Query
|
|
48
|
+
}).pipe(FormInputAnnotation.set(false))
|
|
49
|
+
}).pipe(Type.object({
|
|
50
|
+
typename: "dxos.org/type/Graph",
|
|
51
|
+
version: "0.2.0"
|
|
52
|
+
}), LabelAnnotation.set([
|
|
53
|
+
"name"
|
|
54
|
+
]), ViewAnnotation.set(true));
|
|
55
|
+
var Graph = GraphSchema;
|
|
56
|
+
var make = ({ name, query = {
|
|
57
|
+
raw: "",
|
|
58
|
+
ast: Query.select(Filter.nothing()).ast
|
|
59
|
+
}, view }) => {
|
|
60
|
+
return Obj.make(Graph, {
|
|
61
|
+
name,
|
|
62
|
+
view: Ref.make(view),
|
|
63
|
+
query
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
var GraphV1 = Schema2.Struct({
|
|
67
|
+
name: Schema2.optional(Schema2.String),
|
|
68
|
+
query: Schema2.Struct({
|
|
69
|
+
raw: Schema2.optional(Schema2.String),
|
|
70
|
+
ast: QueryAST.Query
|
|
71
|
+
})
|
|
72
|
+
}).pipe(Type.object({
|
|
73
|
+
typename: "dxos.org/type/Graph",
|
|
74
|
+
version: "0.1.0"
|
|
75
|
+
}), LabelAnnotation.set([
|
|
76
|
+
"name"
|
|
77
|
+
]));
|
|
78
|
+
|
|
79
|
+
export {
|
|
80
|
+
ExplorerAction_exports,
|
|
81
|
+
Graph_exports
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=chunk-HIFLWHXR.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/types';\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 registered: ['registered'],\n }),\n Schema.optional,\n ),\n});\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Filter, Obj, Query, QueryAST, Ref, Type } from '@dxos/echo';\nimport { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/internal';\nimport { View, ViewAnnotation } from '@dxos/schema';\n\nconst GraphSchema = Schema.Struct({\n name: Schema.optional(Schema.String),\n\n view: Type.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: 'dxos.org/type/Graph',\n version: '0.2.0',\n }),\n LabelAnnotation.set(['name']),\n ViewAnnotation.set(true),\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\n//\n// V1\n//\n\nexport const GraphV1 = Schema.Struct({\n name: Schema.optional(Schema.String),\n query: Schema.Struct({\n raw: Schema.optional(Schema.String),\n ast: QueryAST.Query,\n }),\n}).pipe(\n Type.object({\n typename: 'dxos.org/type/Graph',\n version: '0.1.0',\n }),\n LabelAnnotation.set(['name']),\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,GAC1CC,2BAA2BC,IAAI;IAC7BC,UAAU;MAAC;MAAY;;IACvBC,MAAM;MAAC;;IACPC,YAAY;MAAC;;EACf,CAAA,GACOV,eAAQ;AAEnB,CAAA;;;ACpBA;;;;;;AAIA,YAAYW,aAAY;AAExB,SAASC,QAAQC,KAAKC,OAAOC,UAAUC,KAAKC,YAAY;AACxD,SAASC,qBAAqBC,uBAAuB;AACrD,SAASC,MAAMC,sBAAsB;AAErC,IAAMC,cAAqBC,eAAO;EAChCC,MAAaC,iBAAgBC,cAAM;EAEnCC,MAAMC,KAAKC,IAAIC,KAAKA,IAAI,EAAEC,KAAKC,oBAAoBC,IAAI,KAAA,CAAA;EAEvDC,OAAcX,eAAO;IACnBY,KAAYV,iBAAgBC,cAAM;IAClCU,KAAKC,SAASC;EAChB,CAAA,EAAGP,KAAKC,oBAAoBC,IAAI,KAAA,CAAA;AAClC,CAAA,EAAGF,KACDH,KAAKW,OAAO;EACVC,UAAU;EACVC,SAAS;AACX,CAAA,GACAC,gBAAgBT,IAAI;EAAC;CAAO,GAC5BU,eAAeV,IAAI,IAAA,CAAA;AAGd,IAAMW,QAAyBtB;AAS/B,IAAMuB,OAAO,CAAC,EACnBrB,MACAU,QAAQ;EAAEC,KAAK;EAAIC,KAAKE,MAAMQ,OAAOC,OAAOC,QAAO,CAAA,EAAIZ;AAAI,GAC3DT,KAAI,MACM;AACV,SAAOsB,IAAIJ,KAAKD,OAAO;IAAEpB;IAAMG,MAAME,IAAIgB,KAAKlB,IAAAA;IAAOO;EAAM,CAAA;AAC7D;AAMO,IAAMgB,UAAiB3B,eAAO;EACnCC,MAAaC,iBAAgBC,cAAM;EACnCQ,OAAcX,eAAO;IACnBY,KAAYV,iBAAgBC,cAAM;IAClCU,KAAKC,SAASC;EAChB,CAAA;AACF,CAAA,EAAGP,KACDH,KAAKW,OAAO;EACVC,UAAU;EACVC,SAAS;AACX,CAAA,GACAC,gBAAgBT,IAAI;EAAC;CAAO,CAAA;",
|
|
6
|
+
"names": ["Schema", "TypeInputOptionsAnnotation", "GraphProps", "Struct", "name", "optional", "String", "typename", "pipe", "annotations", "title", "TypeInputOptionsAnnotation", "set", "location", "kind", "registered", "Schema", "Filter", "Obj", "Query", "QueryAST", "Ref", "Type", "FormInputAnnotation", "LabelAnnotation", "View", "ViewAnnotation", "GraphSchema", "Struct", "name", "optional", "String", "view", "Type", "Ref", "View", "pipe", "FormInputAnnotation", "set", "query", "raw", "ast", "QueryAST", "Query", "object", "typename", "version", "LabelAnnotation", "ViewAnnotation", "Graph", "make", "select", "Filter", "nothing", "Obj", "GraphV1"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// src/components/Graph/D3ForceGraph.tsx
|
|
2
|
+
import React, { useCallback, useEffect, useMemo, useRef } from "react";
|
|
3
|
+
import { Obj } from "@dxos/echo";
|
|
4
|
+
import { SelectionModel } from "@dxos/graph";
|
|
5
|
+
import { GraphForceProjector, SVG } from "@dxos/react-ui-graph";
|
|
6
|
+
import { getHashStyles } from "@dxos/ui-theme";
|
|
7
|
+
import "@dxos/react-ui-graph/styles/graph.css";
|
|
8
|
+
var D3ForceGraph = ({ classNames, model, selection: _selection, grid, ...props }) => {
|
|
9
|
+
const context = useRef(null);
|
|
10
|
+
const projector = useMemo(() => {
|
|
11
|
+
if (context.current) {
|
|
12
|
+
return new GraphForceProjector(context.current, {
|
|
13
|
+
attributes: {
|
|
14
|
+
linkForce: (edge) => {
|
|
15
|
+
return edge.data?.object?.active !== false;
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
forces: {
|
|
19
|
+
point: {
|
|
20
|
+
strength: 0.01
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}, [
|
|
26
|
+
context.current
|
|
27
|
+
]);
|
|
28
|
+
const graph = useRef(null);
|
|
29
|
+
const selection = useMemo(() => _selection ?? new SelectionModel(), [
|
|
30
|
+
_selection
|
|
31
|
+
]);
|
|
32
|
+
useEffect(() => selection.subscribe(() => graph.current?.repaint()), [
|
|
33
|
+
selection
|
|
34
|
+
]);
|
|
35
|
+
const handleSelect = useCallback((node) => {
|
|
36
|
+
if (selection.contains(node.id)) {
|
|
37
|
+
selection.remove(node.id);
|
|
38
|
+
} else {
|
|
39
|
+
selection.add(node.id);
|
|
40
|
+
}
|
|
41
|
+
}, [
|
|
42
|
+
selection
|
|
43
|
+
]);
|
|
44
|
+
return /* @__PURE__ */ React.createElement(SVG.Root, {
|
|
45
|
+
ref: context,
|
|
46
|
+
classNames
|
|
47
|
+
}, /* @__PURE__ */ React.createElement(SVG.Markers, null), grid && /* @__PURE__ */ React.createElement(SVG.Grid, {
|
|
48
|
+
axis: true
|
|
49
|
+
}), /* @__PURE__ */ React.createElement(SVG.Zoom, {
|
|
50
|
+
extent: [
|
|
51
|
+
1 / 2,
|
|
52
|
+
2
|
|
53
|
+
]
|
|
54
|
+
}, /* @__PURE__ */ React.createElement(SVG.Graph, {
|
|
55
|
+
...props,
|
|
56
|
+
ref: graph,
|
|
57
|
+
model,
|
|
58
|
+
projector,
|
|
59
|
+
labels: {
|
|
60
|
+
text: (node) => {
|
|
61
|
+
return node.data?.data.label ?? node.id;
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
attributes: {
|
|
65
|
+
node: (node) => {
|
|
66
|
+
const obj = node.data?.data.object;
|
|
67
|
+
return {
|
|
68
|
+
data: {
|
|
69
|
+
color: getHashStyles(obj && Obj.getTypename(obj))?.hue
|
|
70
|
+
},
|
|
71
|
+
classes: {
|
|
72
|
+
"dx-selected": selection.contains(node.id)
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
onSelect: handleSelect
|
|
78
|
+
})));
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// src/components/Graph/ForceGraph.tsx
|
|
82
|
+
import { forceLink, forceManyBody } from "d3";
|
|
83
|
+
import NativeForceGraph from "force-graph";
|
|
84
|
+
import React2, { useEffect as useEffect2, useRef as useRef2, useState } from "react";
|
|
85
|
+
import { useResizeDetector } from "react-resize-detector";
|
|
86
|
+
import { filterObjectsSync } from "@dxos/plugin-search";
|
|
87
|
+
|
|
88
|
+
// src/components/Graph/adapter.ts
|
|
89
|
+
var GraphAdapter = class {
|
|
90
|
+
graph;
|
|
91
|
+
_nodes = [];
|
|
92
|
+
_links = [];
|
|
93
|
+
constructor(graph) {
|
|
94
|
+
this.graph = graph;
|
|
95
|
+
this._nodes = graph.nodes.map((node) => ({
|
|
96
|
+
id: node.id,
|
|
97
|
+
type: node.type,
|
|
98
|
+
data: node.data
|
|
99
|
+
}));
|
|
100
|
+
const nodeIds = new Set(this._nodes.map((node) => node.id));
|
|
101
|
+
this._links = graph.edges.filter((edge) => nodeIds.has(edge.source) && nodeIds.has(edge.target)).map((edge) => ({
|
|
102
|
+
type: edge.type,
|
|
103
|
+
source: edge.source,
|
|
104
|
+
target: edge.target,
|
|
105
|
+
data: edge.data
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
get nodes() {
|
|
109
|
+
return this._nodes;
|
|
110
|
+
}
|
|
111
|
+
get links() {
|
|
112
|
+
return this._links;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// src/components/Graph/ForceGraph.tsx
|
|
117
|
+
var ForceGraph = ({ model, match }) => {
|
|
118
|
+
const { ref, width, height } = useResizeDetector({
|
|
119
|
+
refreshRate: 200
|
|
120
|
+
});
|
|
121
|
+
const rootRef = useRef2(null);
|
|
122
|
+
const forceGraph = useRef2(null);
|
|
123
|
+
const filteredRef = useRef2([]);
|
|
124
|
+
filteredRef.current = filterObjectsSync(model?.objects ?? [], match);
|
|
125
|
+
const [data, setData] = useState();
|
|
126
|
+
useEffect2(() => {
|
|
127
|
+
return model?.subscribe((model2) => {
|
|
128
|
+
setData(new GraphAdapter(model2.graph));
|
|
129
|
+
});
|
|
130
|
+
}, [
|
|
131
|
+
model
|
|
132
|
+
]);
|
|
133
|
+
useEffect2(() => {
|
|
134
|
+
if (rootRef.current) {
|
|
135
|
+
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((link) => link.type);
|
|
136
|
+
}
|
|
137
|
+
return () => {
|
|
138
|
+
forceGraph.current?.pauseAnimation().graphData({
|
|
139
|
+
nodes: [],
|
|
140
|
+
links: []
|
|
141
|
+
});
|
|
142
|
+
forceGraph.current = null;
|
|
143
|
+
};
|
|
144
|
+
}, []);
|
|
145
|
+
useEffect2(() => {
|
|
146
|
+
if (!data || !width || !height || !forceGraph.current) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
forceGraph.current.pauseAnimation().width(width).height(height).onEngineStop(() => {
|
|
150
|
+
handleZoomToFit();
|
|
151
|
+
}).onNodeClick((node) => {
|
|
152
|
+
forceGraph.current?.emitParticle(node);
|
|
153
|
+
}).d3Force("link", forceLink().distance(160).strength(0.5)).d3Force("charge", forceManyBody().strength(-30)).graphData(data).warmupTicks(100).cooldownTime(1e3).resumeAnimation();
|
|
154
|
+
}, [
|
|
155
|
+
data,
|
|
156
|
+
width,
|
|
157
|
+
height,
|
|
158
|
+
forceGraph.current
|
|
159
|
+
]);
|
|
160
|
+
const handleZoomToFit = () => {
|
|
161
|
+
forceGraph.current?.zoomToFit(400, 40);
|
|
162
|
+
};
|
|
163
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
164
|
+
ref,
|
|
165
|
+
className: "relative grow",
|
|
166
|
+
onClick: handleZoomToFit
|
|
167
|
+
}, /* @__PURE__ */ React2.createElement("div", {
|
|
168
|
+
ref: rootRef,
|
|
169
|
+
className: "absolute inset-0"
|
|
170
|
+
}));
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
export {
|
|
174
|
+
D3ForceGraph,
|
|
175
|
+
ForceGraph
|
|
176
|
+
};
|
|
177
|
+
//# sourceMappingURL=chunk-MGBT2ZFU.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/Graph/D3ForceGraph.tsx", "../../../src/components/Graph/ForceGraph.tsx", "../../../src/components/Graph/adapter.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react';\n\nimport { Obj } from '@dxos/echo';\nimport { SelectionModel } from '@dxos/graph';\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport {\n type GraphController,\n GraphForceProjector,\n type GraphLayoutNode,\n type GraphProps,\n SVG,\n type SVGContext,\n} from '@dxos/react-ui-graph';\nimport { type SpaceGraphEdge, type SpaceGraphModel, type SpaceGraphNode } from '@dxos/schema';\nimport { getHashStyles } from '@dxos/ui-theme';\n\nimport '@dxos/react-ui-graph/styles/graph.css';\n\nexport type D3ForceGraphProps = ThemedClassName<\n {\n model?: SpaceGraphModel;\n match?: RegExp;\n selection?: SelectionModel;\n grid?: boolean;\n } & Pick<GraphProps, 'drag'>\n>;\n\nexport const D3ForceGraph = ({ classNames, model, selection: _selection, grid, ...props }: D3ForceGraphProps) => {\n const context = useRef<SVGContext>(null);\n const projector = useMemo<GraphForceProjector | undefined>(() => {\n if (context.current) {\n return new GraphForceProjector(context.current, {\n attributes: {\n linkForce: (edge) => {\n // TODO(burdon): Check type (currently assumes Employee property).\n // Edge shouldn't contribute to force if it's not active.\n return edge.data?.object?.active !== false;\n },\n },\n forces: {\n point: {\n strength: 0.01,\n },\n },\n });\n }\n }, [context.current]);\n\n const graph = useRef<GraphController>(null);\n const selection = useMemo(() => _selection ?? new SelectionModel(), [_selection]);\n useEffect(() => selection.subscribe(() => graph.current?.repaint()), [selection]);\n\n const handleSelect = useCallback<NonNullable<GraphProps['onSelect']>>(\n (node) => {\n if (selection.contains(node.id)) {\n selection.remove(node.id);\n } else {\n selection.add(node.id);\n }\n },\n [selection],\n );\n\n return (\n <SVG.Root ref={context} classNames={classNames}>\n <SVG.Markers />\n {grid && <SVG.Grid axis />}\n <SVG.Zoom extent={[1 / 2, 2]}>\n <SVG.Graph<SpaceGraphNode, SpaceGraphEdge>\n {...props}\n ref={graph}\n model={model}\n projector={projector}\n labels={{\n text: (node) => {\n return node.data?.data.label ?? node.id;\n },\n }}\n attributes={{\n node: (node: GraphLayoutNode<SpaceGraphNode>) => {\n const obj = node.data?.data.object;\n return {\n data: {\n color: getHashStyles(obj && Obj.getTypename(obj))?.hue,\n },\n classes: {\n 'dx-selected': selection.contains(node.id),\n },\n };\n },\n }}\n onSelect={handleSelect}\n />\n </SVG.Zoom>\n </SVG.Root>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { forceLink, forceManyBody } from 'd3';\nimport NativeForceGraph from 'force-graph';\nimport React, { type FC, useEffect, useRef, useState } from 'react';\nimport { useResizeDetector } from 'react-resize-detector';\n\nimport { type SearchResult, filterObjectsSync } from '@dxos/plugin-search';\nimport { type SpaceGraphModel } from '@dxos/schema';\n\nimport { GraphAdapter } from './adapter';\n\nexport type ForceGraphProps = {\n model?: SpaceGraphModel;\n match?: RegExp;\n};\n\nexport const ForceGraph: FC<ForceGraphProps> = ({ model, match }) => {\n const { ref, width, height } = useResizeDetector({ refreshRate: 200 });\n const rootRef = useRef<HTMLDivElement>(null);\n const forceGraph = useRef<NativeForceGraph>(null);\n\n const filteredRef = useRef<SearchResult[]>([]);\n filteredRef.current = filterObjectsSync(model?.objects ?? [], match);\n\n const [data, setData] = useState<GraphAdapter>();\n useEffect(() => {\n return model?.subscribe((model) => {\n setData(new GraphAdapter(model.graph));\n });\n }, [model]);\n\n useEffect(() => {\n if (rootRef.current) {\n // https://github.com/vasturiano/force-graph\n // https://github.com/vasturiano/3d-force-graph\n forceGraph.current = new NativeForceGraph(rootRef.current)\n // https://github.com/vasturiano/force-graph?tab=readme-ov-file#node-styling\n .nodeRelSize(6)\n .nodeLabel((node: any) => (node.type === 'schema' ? node.data.typename : (node.data.label ?? node.id)))\n .nodeAutoColorBy((node: any) => (node.type === 'schema' ? 'schema' : node.data.typename))\n\n // https://github.com/vasturiano/force-graph?tab=readme-ov-file#link-styling\n .linkAutoColorBy((link: any) => link.type);\n }\n\n return () => {\n forceGraph.current?.pauseAnimation().graphData({ nodes: [], links: [] });\n forceGraph.current = null;\n };\n }, []);\n\n useEffect(() => {\n if (!data || !width || !height || !forceGraph.current) {\n return;\n }\n\n // https://github.com/vasturiano/force-graph?tab=readme-ov-file#container-layout\n forceGraph.current\n .pauseAnimation()\n .width(width)\n .height(height)\n .onEngineStop(() => {\n handleZoomToFit();\n })\n .onNodeClick((node: any) => {\n forceGraph.current?.emitParticle(node);\n })\n\n // https://github.com/vasturiano/force-graph?tab=readme-ov-file#force-engine-d3-force-configuration\n // .d3Force('center', forceCenter().strength(0.9))\n .d3Force('link', forceLink().distance(160).strength(0.5))\n .d3Force('charge', forceManyBody().strength(-30))\n\n .graphData(data)\n .warmupTicks(100)\n .cooldownTime(1_000)\n .resumeAnimation();\n }, [data, width, height, forceGraph.current]);\n\n const handleZoomToFit = () => {\n forceGraph.current?.zoomToFit(400, 40);\n };\n\n return (\n <div ref={ref} className='relative grow' onClick={handleZoomToFit}>\n <div ref={rootRef} className='absolute inset-0' />\n </div>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Graph } from '@dxos/graph';\n\nexport type GraphNode = {\n id?: string;\n};\n\nexport type GraphLink = {\n source?: string;\n target?: string;\n};\n\nexport type GraphData = {\n nodes: GraphNode[];\n links: GraphLink[];\n};\n\n/**\n * Map common graph to force-graph format.\n */\nexport class GraphAdapter implements GraphData {\n private readonly _nodes: GraphNode[] = [];\n private readonly _links: GraphLink[] = [];\n\n constructor(private readonly graph: Graph.Any) {\n this._nodes = graph.nodes.map((node: Graph.Node.Any) => ({\n id: node.id,\n type: node.type,\n data: node.data,\n }));\n\n // Build a set of node IDs for efficient lookup.\n const nodeIds = new Set(this._nodes.map((node) => node.id));\n\n // Filter out edges where source or target node doesn't exist.\n this._links = graph.edges\n .filter((edge: Graph.Edge.Any) => nodeIds.has(edge.source) && nodeIds.has(edge.target))\n .map((edge: Graph.Edge.Any) => ({\n type: edge.type,\n source: edge.source,\n target: edge.target,\n data: edge.data,\n }));\n }\n\n get nodes() {\n return this._nodes;\n }\n\n get links() {\n return this._links;\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAIA,OAAOA,SAASC,aAAaC,WAAWC,SAASC,cAAc;AAE/D,SAASC,WAAW;AACpB,SAASC,sBAAsB;AAE/B,SAEEC,qBAGAC,WAEK;AAEP,SAASC,qBAAqB;AAE9B,OAAO;AAWA,IAAMC,eAAe,CAAC,EAAEC,YAAYC,OAAOC,WAAWC,YAAYC,MAAM,GAAGC,MAAAA,MAA0B;AAC1G,QAAMC,UAAUC,OAAmB,IAAA;AACnC,QAAMC,YAAYC,QAAyC,MAAA;AACzD,QAAIH,QAAQI,SAAS;AACnB,aAAO,IAAIC,oBAAoBL,QAAQI,SAA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AAM0B,kBAAkB,MAAA;AACtB5B,eAAWE,SAASqC,UAAU,KAAK,EAAA;EACrC;AAEA,SACE,gBAAAC,OAAA,cAACC,OAAAA;IAAIhD;IAAUiD,WAAU;IAAgBC,SAASf;KAChD,gBAAAY,OAAA,cAACC,OAAAA;IAAIhD,KAAKK;IAAS4C,WAAU;;AAGnC;",
|
|
6
|
+
"names": ["React", "useCallback", "useEffect", "useMemo", "useRef", "Obj", "SelectionModel", "GraphForceProjector", "SVG", "getHashStyles", "D3ForceGraph", "classNames", "model", "selection", "_selection", "grid", "props", "context", "useRef", "projector", "useMemo", "current", "GraphForceProjector", "attributes", "linkForce", "edge", "data", "object", "active", "forces", "point", "strength", "graph", "SelectionModel", "useEffect", "subscribe", "repaint", "handleSelect", "useCallback", "node", "contains", "id", "remove", "add", "SVG", "Root", "ref", "Markers", "Grid", "axis", "Zoom", "extent", "Graph", "labels", "text", "label", "obj", "color", "getHashStyles", "Obj", "getTypename", "hue", "classes", "onSelect", "forceLink", "forceManyBody", "NativeForceGraph", "React", "useEffect", "useRef", "useState", "useResizeDetector", "filterObjectsSync", "GraphAdapter", "_nodes", "_links", "graph", "nodes", "map", "node", "id", "type", "data", "nodeIds", "Set", "edges", "filter", "edge", "has", "source", "target", "links", "ForceGraph", "model", "match", "ref", "width", "height", "useResizeDetector", "refreshRate", "rootRef", "useRef", "forceGraph", "filteredRef", "current", "filterObjectsSync", "objects", "data", "setData", "useState", "useEffect", "subscribe", "GraphAdapter", "graph", "NativeForceGraph", "nodeRelSize", "nodeLabel", "node", "type", "typename", "label", "id", "nodeAutoColorBy", "linkAutoColorBy", "link", "pauseAnimation", "graphData", "nodes", "links", "onEngineStop", "handleZoomToFit", "onNodeClick", "emitParticle", "d3Force", "forceLink", "distance", "strength", "forceManyBody", "warmupTicks", "cooldownTime", "resumeAnimation", "zoomToFit", "React", "div", "className", "onClick"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/meta.ts"],
|
|
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: 'dxos.org/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,aAAaC;;;;EAIbC,MAAM;EACNC,SAAS;EACTC,QAAQ;EACRC,MAAM;IAAC;;EACPC,aAAa;IAAC;;AAChB;",
|
|
6
|
+
"names": ["trim", "meta", "id", "name", "description", "trim", "icon", "iconHue", "source", "tags", "screenshots"]
|
|
7
|
+
}
|
|
@@ -1,50 +1,51 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useGraphModel
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-BZMTFAP3.mjs";
|
|
4
4
|
import {
|
|
5
5
|
Chart,
|
|
6
6
|
ExplorerContainer,
|
|
7
7
|
Globe,
|
|
8
8
|
Tree,
|
|
9
9
|
defaultTreeLayoutSlots
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-AGZAGILW.mjs";
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} from "./chunk-6BVXZQPP.mjs";
|
|
12
|
+
meta
|
|
13
|
+
} from "./chunk-YNQF4CPY.mjs";
|
|
15
14
|
import {
|
|
16
15
|
ExplorerAction_exports,
|
|
17
16
|
Graph_exports
|
|
18
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-HIFLWHXR.mjs";
|
|
19
18
|
import {
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
D3ForceGraph,
|
|
20
|
+
ForceGraph
|
|
21
|
+
} from "./chunk-MGBT2ZFU.mjs";
|
|
22
22
|
import "./chunk-J5LGTIGS.mjs";
|
|
23
23
|
|
|
24
24
|
// src/ExplorerPlugin.tsx
|
|
25
|
-
import
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
25
|
+
import * as Effect from "effect/Effect";
|
|
26
|
+
import { Common, Plugin } from "@dxos/app-framework";
|
|
27
|
+
import { Type as Type2 } from "@dxos/echo";
|
|
28
|
+
import { View } from "@dxos/schema";
|
|
29
29
|
|
|
30
|
-
// src/capabilities/index.ts
|
|
31
|
-
import {
|
|
32
|
-
var
|
|
33
|
-
var ReactSurface = lazy(() => import("./react-surface-VS3ZFL2Y.mjs"));
|
|
30
|
+
// src/capabilities/react-surface/index.ts
|
|
31
|
+
import { Capability } from "@dxos/app-framework";
|
|
32
|
+
var ReactSurface = Capability.lazy("ReactSurface", () => import("./react-surface-RWVHQL3J.mjs"));
|
|
34
33
|
|
|
35
34
|
// src/translations.ts
|
|
35
|
+
import { Type } from "@dxos/echo";
|
|
36
36
|
import { translations as componentsTranslations } from "@dxos/react-ui-components";
|
|
37
37
|
var translations = [
|
|
38
38
|
{
|
|
39
39
|
"en-US": {
|
|
40
|
-
[Graph_exports.Graph
|
|
40
|
+
[Type.getTypename(Graph_exports.Graph)]: {
|
|
41
41
|
"typename label": "Explorer",
|
|
42
42
|
"typename label_zero": "Explorers",
|
|
43
43
|
"typename label_one": "Explorer",
|
|
44
44
|
"typename label_other": "Explorers",
|
|
45
45
|
"object name placeholder": "New explorer",
|
|
46
46
|
"rename object label": "Rename explorer",
|
|
47
|
-
"delete object label": "Delete explorer"
|
|
47
|
+
"delete object label": "Delete explorer",
|
|
48
|
+
"object deleted label": "Explorer deleted"
|
|
48
49
|
},
|
|
49
50
|
[meta.id]: {
|
|
50
51
|
"plugin name": "Explorer",
|
|
@@ -56,54 +57,34 @@ var translations = [
|
|
|
56
57
|
];
|
|
57
58
|
|
|
58
59
|
// src/ExplorerPlugin.tsx
|
|
59
|
-
var ExplorerPlugin =
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
id: `${meta.id}/module/object-form`,
|
|
78
|
-
activatesOn: ClientEvents.SetupSchema,
|
|
79
|
-
activate: () => contributes(SpaceCapabilities.ObjectForm, defineObjectForm({
|
|
80
|
-
objectSchema: Graph_exports.Graph,
|
|
81
|
-
formSchema: ExplorerAction_exports.GraphProps,
|
|
82
|
-
hidden: true,
|
|
83
|
-
getIntent: (props, options) => createIntent(ExplorerAction_exports.CreateGraph, {
|
|
84
|
-
...props,
|
|
85
|
-
space: options.space
|
|
60
|
+
var ExplorerPlugin = Plugin.define(meta).pipe(Common.Plugin.addTranslationsModule({
|
|
61
|
+
translations
|
|
62
|
+
}), Common.Plugin.addMetadataModule({
|
|
63
|
+
metadata: {
|
|
64
|
+
id: Type2.getTypename(Graph_exports.Graph),
|
|
65
|
+
metadata: {
|
|
66
|
+
icon: "ph--graph--regular",
|
|
67
|
+
iconHue: "green",
|
|
68
|
+
inputSchema: ExplorerAction_exports.GraphProps,
|
|
69
|
+
createObject: (props, { db }) => Effect.promise(async () => {
|
|
70
|
+
const { view } = await View.makeFromDatabase({
|
|
71
|
+
db,
|
|
72
|
+
typename: props.typename
|
|
73
|
+
});
|
|
74
|
+
return Graph_exports.make({
|
|
75
|
+
name: props.name,
|
|
76
|
+
view
|
|
77
|
+
});
|
|
86
78
|
})
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
defineModule({
|
|
97
|
-
id: `${meta.id}/module/react-surface`,
|
|
98
|
-
activatesOn: Events.SetupReactSurface,
|
|
99
|
-
activate: ReactSurface
|
|
100
|
-
}),
|
|
101
|
-
defineModule({
|
|
102
|
-
id: `${meta.id}/module/intent-resolver`,
|
|
103
|
-
activatesOn: Events.SetupIntentResolver,
|
|
104
|
-
activate: IntentResolver
|
|
105
|
-
})
|
|
106
|
-
]);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}), Common.Plugin.addSchemaModule({
|
|
82
|
+
schema: [
|
|
83
|
+
Graph_exports.Graph
|
|
84
|
+
]
|
|
85
|
+
}), Common.Plugin.addSurfaceModule({
|
|
86
|
+
activate: ReactSurface
|
|
87
|
+
}), Plugin.make);
|
|
107
88
|
export {
|
|
108
89
|
Chart,
|
|
109
90
|
D3ForceGraph,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/ExplorerPlugin.tsx", "../../../src/capabilities/index.ts", "../../../src/translations.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAIA,
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../../../src/ExplorerPlugin.tsx", "../../../src/capabilities/react-surface/index.ts", "../../../src/translations.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Common, Plugin } from '@dxos/app-framework';\nimport { Type } from '@dxos/echo';\nimport { type CreateObject } from '@dxos/plugin-space/types';\nimport { View } from '@dxos/schema';\n\nimport { ReactSurface } from './capabilities';\nimport { meta } from './meta';\nimport { translations } from './translations';\nimport { ExplorerAction, Graph } from './types';\n\nexport const ExplorerPlugin = Plugin.define(meta).pipe(\n Common.Plugin.addTranslationsModule({ translations }),\n Common.Plugin.addMetadataModule({\n metadata: {\n id: Type.getTypename(Graph.Graph),\n metadata: {\n icon: 'ph--graph--regular',\n iconHue: 'green',\n inputSchema: ExplorerAction.GraphProps,\n createObject: ((props, { db }) =>\n Effect.promise(async () => {\n const { view } = await View.makeFromDatabase({ db, typename: props.typename });\n return Graph.make({ name: props.name, view });\n })) satisfies CreateObject,\n },\n },\n }),\n Common.Plugin.addSchemaModule({ schema: [Graph.Graph] }),\n Common.Plugin.addSurfaceModule({ activate: ReactSurface }),\n Plugin.make,\n);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capability } from '@dxos/app-framework';\n\nexport const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { Type } from '@dxos/echo';\nimport { type Resource } from '@dxos/react-ui';\nimport { translations as componentsTranslations } from '@dxos/react-ui-components';\n\nimport { meta } from './meta';\nimport { Graph } from './types';\n\nexport const translations = [\n {\n 'en-US': {\n [Type.getTypename(Graph.Graph)]: {\n 'typename label': 'Explorer',\n 'typename label_zero': 'Explorers',\n 'typename label_one': 'Explorer',\n 'typename label_other': 'Explorers',\n 'object name placeholder': 'New explorer',\n 'rename object label': 'Rename explorer',\n 'delete object label': 'Delete explorer',\n 'object deleted label': 'Explorer deleted',\n },\n [meta.id]: {\n 'plugin name': 'Explorer',\n 'object title label': 'Title',\n },\n },\n },\n ...componentsTranslations,\n] as const satisfies Resource[];\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,QAAQC,cAAc;AAC/B,SAASC,QAAAA,aAAY;AAErB,SAASC,YAAY;;;ACLrB,SAASC,kBAAkB;AAEpB,IAAMC,eAAeC,WAAWC,KAAK,gBAAgB,MAAM,OAAO,8BAAA,CAAA;;;ACFzE,SAASC,YAAY;AAErB,SAASC,gBAAgBC,8BAA8B;AAKhD,IAAMC,eAAe;EAC1B;IACE,SAAS;MACP,CAACC,KAAKC,YAAYC,cAAMA,KAAK,CAAA,GAAI;QAC/B,kBAAkB;QAClB,uBAAuB;QACvB,sBAAsB;QACtB,wBAAwB;QACxB,2BAA2B;QAC3B,uBAAuB;QACvB,uBAAuB;QACvB,wBAAwB;MAC1B;MACA,CAACC,KAAKC,EAAE,GAAG;QACT,eAAe;QACf,sBAAsB;MACxB;IACF;EACF;KACGC;;;;AFdE,IAAMC,iBAAiBC,OAAOC,OAAOC,IAAAA,EAAMC,KAChDC,OAAOJ,OAAOK,sBAAsB;EAAEC;AAAa,CAAA,GACnDF,OAAOJ,OAAOO,kBAAkB;EAC9BC,UAAU;IACRC,IAAIC,MAAKC,YAAYC,cAAMA,KAAK;IAChCJ,UAAU;MACRK,MAAM;MACNC,SAAS;MACTC,aAAaC,uBAAeC;MAC5BC,cAAe,CAACC,OAAO,EAAEC,GAAE,MAClBC,eAAQ,YAAA;AACb,cAAM,EAAEC,KAAI,IAAK,MAAMC,KAAKC,iBAAiB;UAAEJ;UAAIK,UAAUN,MAAMM;QAAS,CAAA;AAC5E,eAAOb,cAAMc,KAAK;UAAEC,MAAMR,MAAMQ;UAAML;QAAK,CAAA;MAC7C,CAAA;IACJ;EACF;AACF,CAAA,GACAlB,OAAOJ,OAAO4B,gBAAgB;EAAEC,QAAQ;IAACjB,cAAMA;;AAAO,CAAA,GACtDR,OAAOJ,OAAO8B,iBAAiB;EAAEC,UAAUC;AAAa,CAAA,GACxDhC,OAAO0B,IAAI;",
|
|
6
|
+
"names": ["Effect", "Common", "Plugin", "Type", "View", "Capability", "ReactSurface", "Capability", "lazy", "Type", "translations", "componentsTranslations", "translations", "Type", "getTypename", "Graph", "meta", "id", "componentsTranslations", "ExplorerPlugin", "Plugin", "define", "meta", "pipe", "Common", "addTranslationsModule", "translations", "addMetadataModule", "metadata", "id", "Type", "getTypename", "Graph", "icon", "iconHue", "inputSchema", "ExplorerAction", "GraphProps", "createObject", "props", "db", "promise", "view", "View", "makeFromDatabase", "typename", "make", "name", "addSchemaModule", "schema", "addSurfaceModule", "activate", "ReactSurface"]
|
|
7
7
|
}
|