@dxos/plugin-graph 0.7.1 → 0.7.2-staging.6d26b2a
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/index.mjs +9 -3
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +8 -3
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +9 -3
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/GraphPlugin.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/GraphPlugin.tsx +10 -15
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
GRAPH_PLUGIN,
|
|
2
3
|
meta_default
|
|
3
4
|
} from "./chunk-SYPRW7IK.mjs";
|
|
4
5
|
|
|
@@ -14,21 +15,26 @@ var GraphContext = createContext(null);
|
|
|
14
15
|
var useGraph = () => useContext(GraphContext) ?? raise(new Error("Missing GraphContext"));
|
|
15
16
|
|
|
16
17
|
// packages/plugins/plugin-graph/src/GraphPlugin.tsx
|
|
18
|
+
var KEY = `${GRAPH_PLUGIN}/graph`;
|
|
17
19
|
var GraphPlugin = () => {
|
|
18
|
-
const builder =
|
|
19
|
-
let
|
|
20
|
+
const builder = GraphBuilder.from(localStorage.getItem(KEY) ?? void 0);
|
|
21
|
+
let interval;
|
|
20
22
|
return {
|
|
21
23
|
meta: meta_default,
|
|
22
24
|
ready: async (plugins) => {
|
|
25
|
+
interval = setInterval(() => {
|
|
26
|
+
localStorage.setItem(`${GRAPH_PLUGIN}/graph`, builder.graph.pickle());
|
|
27
|
+
}, 5e3);
|
|
23
28
|
filterPlugins(plugins, parseGraphBuilderPlugin).forEach((plugin) => builder.addExtension(plugin.provides.graph.builder(plugins)));
|
|
24
29
|
await builder.initialize();
|
|
30
|
+
await builder.graph.expand(builder.graph.root);
|
|
25
31
|
const composer = window.composer;
|
|
26
32
|
if (typeof composer === "object") {
|
|
27
33
|
composer.graph = builder.graph;
|
|
28
34
|
}
|
|
29
35
|
},
|
|
30
36
|
unload: async () => {
|
|
31
|
-
|
|
37
|
+
clearInterval(interval);
|
|
32
38
|
},
|
|
33
39
|
provides: {
|
|
34
40
|
graph: builder.graph,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/GraphPlugin.tsx", "../../../src/GraphContext.ts", "../../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { filterPlugins, type GraphProvides, type PluginDefinition, parseGraphBuilderPlugin } from '@dxos/app-framework';\nimport { GraphBuilder } from '@dxos/app-graph';\
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["React", "filterPlugins", "parseGraphBuilderPlugin", "GraphBuilder", "createContext", "useContext", "raise", "GraphContext", "createContext", "useGraph", "useContext", "raise", "Error", "GraphPlugin", "builder", "GraphBuilder", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { filterPlugins, type GraphProvides, type PluginDefinition, parseGraphBuilderPlugin } from '@dxos/app-framework';\nimport { GraphBuilder } from '@dxos/app-graph';\n\nimport { GraphContext } from './GraphContext';\nimport meta, { GRAPH_PLUGIN } from './meta';\n\nconst KEY = `${GRAPH_PLUGIN}/graph`;\n\n/**\n * Manages the state of the graph for the application.\n * Enables other plugins to register node builders to add nodes to the graph.\n * This includes actions and annotation each other's nodes.\n */\nexport const GraphPlugin = (): PluginDefinition<GraphProvides> => {\n const builder = GraphBuilder.from(localStorage.getItem(KEY) ?? undefined);\n let interval: NodeJS.Timeout | undefined;\n\n return {\n meta,\n ready: async (plugins) => {\n interval = setInterval(() => {\n localStorage.setItem(`${GRAPH_PLUGIN}/graph`, builder.graph.pickle());\n }, 5_000);\n\n filterPlugins(plugins, parseGraphBuilderPlugin).forEach((plugin) =>\n builder.addExtension(plugin.provides.graph.builder(plugins)),\n );\n\n await builder.initialize();\n await builder.graph.expand(builder.graph.root);\n\n // Expose the graph to the window for debugging.\n const composer = (window as any).composer;\n if (typeof composer === 'object') {\n composer.graph = builder.graph;\n }\n },\n unload: async () => {\n clearInterval(interval);\n },\n provides: {\n graph: builder.graph,\n // TODO(wittjosiah): This is janky.\n explore: (options) => builder.explore(options),\n context: ({ children }) => (\n <GraphContext.Provider value={{ graph: builder.graph }}>{children}</GraphContext.Provider>\n ),\n },\n };\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// TODO(wittjosiah): State can be a GraphNode.\nimport { type Context, createContext, useContext } from 'react';\n\nimport { type Graph } from '@dxos/app-graph';\nimport { raise } from '@dxos/debug';\n\nexport type GraphContext = { graph: Graph };\n\nexport const GraphContext: Context<GraphContext | null> = createContext<GraphContext | null>(null);\n\nexport const useGraph = (): GraphContext => useContext(GraphContext) ?? raise(new Error('Missing GraphContext'));\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { GraphPlugin } from './GraphPlugin';\n\nexport default GraphPlugin;\n\nexport * from '@dxos/app-graph';\n\nexport * from './GraphContext';\nexport * from './GraphPlugin';\n"],
|
|
5
|
+
"mappings": ";;;;;;AAIA,OAAOA,WAAW;AAElB,SAASC,eAA0DC,+BAA+B;AAClG,SAASC,oBAAoB;;;ACF7B,SAAuBC,eAAeC,kBAAkB;AAGxD,SAASC,aAAa;AAIf,IAAMC,eAA6CC,cAAmC,IAAA;AAEtF,IAAMC,WAAW,MAAoBC,WAAWH,YAAAA,KAAiBI,MAAM,IAAIC,MAAM,sBAAA,CAAA;;;ADFxF,IAAMC,MAAM,GAAGC,YAAAA;AAOR,IAAMC,cAAc,MAAA;AACzB,QAAMC,UAAUC,aAAaC,KAAKC,aAAaC,QAAQP,GAAAA,KAAQQ,MAAAA;AAC/D,MAAIC;AAEJ,SAAO;IACLC;IACAC,OAAO,OAAOC,YAAAA;AACZH,iBAAWI,YAAY,MAAA;AACrBP,qBAAaQ,QAAQ,GAAGb,YAAAA,UAAsBE,QAAQY,MAAMC,OAAM,CAAA;MACpE,GAAG,GAAA;AAEHC,oBAAcL,SAASM,uBAAAA,EAAyBC,QAAQ,CAACC,WACvDjB,QAAQkB,aAAaD,OAAOE,SAASP,MAAMZ,QAAQS,OAAAA,CAAAA,CAAAA;AAGrD,YAAMT,QAAQoB,WAAU;AACxB,YAAMpB,QAAQY,MAAMS,OAAOrB,QAAQY,MAAMU,IAAI;AAG7C,YAAMC,WAAYC,OAAeD;AACjC,UAAI,OAAOA,aAAa,UAAU;AAChCA,iBAASX,QAAQZ,QAAQY;MAC3B;IACF;IACAa,QAAQ,YAAA;AACNC,oBAAcpB,QAAAA;IAChB;IACAa,UAAU;MACRP,OAAOZ,QAAQY;;MAEfe,SAAS,CAACC,YAAY5B,QAAQ2B,QAAQC,OAAAA;MACtCC,SAAS,CAAC,EAAEC,SAAQ,MAClB,sBAAA,cAACC,aAAaC,UAAQ;QAACC,OAAO;UAAErB,OAAOZ,QAAQY;QAAM;SAAIkB,QAAAA;IAE7D;EACF;AACF;;;AE/CA,cAAc;AAFd,IAAA,cAAeI;",
|
|
6
|
+
"names": ["React", "filterPlugins", "parseGraphBuilderPlugin", "GraphBuilder", "createContext", "useContext", "raise", "GraphContext", "createContext", "useGraph", "useContext", "raise", "Error", "KEY", "GRAPH_PLUGIN", "GraphPlugin", "builder", "GraphBuilder", "from", "localStorage", "getItem", "undefined", "interval", "meta", "ready", "plugins", "setInterval", "setItem", "graph", "pickle", "filterPlugins", "parseGraphBuilderPlugin", "forEach", "plugin", "addExtension", "provides", "initialize", "expand", "root", "composer", "window", "unload", "clearInterval", "explore", "options", "context", "children", "GraphContext", "Provider", "value", "GraphPlugin"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/plugins/plugin-graph/src/GraphContext.ts":{"bytes":1674,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true}],"format":"esm"},"packages/plugins/plugin-graph/src/meta.ts":{"bytes":854,"imports":[],"format":"esm"},"packages/plugins/plugin-graph/src/GraphPlugin.tsx":{"bytes":
|
|
1
|
+
{"inputs":{"packages/plugins/plugin-graph/src/GraphContext.ts":{"bytes":1674,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true}],"format":"esm"},"packages/plugins/plugin-graph/src/meta.ts":{"bytes":854,"imports":[],"format":"esm"},"packages/plugins/plugin-graph/src/GraphPlugin.tsx":{"bytes":6523,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/GraphContext.ts","kind":"import-statement","original":"./GraphContext"},{"path":"packages/plugins/plugin-graph/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/plugin-graph/src/index.ts":{"bytes":978,"imports":[{"path":"packages/plugins/plugin-graph/src/GraphPlugin.tsx","kind":"import-statement","original":"./GraphPlugin"},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/GraphContext.ts","kind":"import-statement","original":"./GraphContext"},{"path":"packages/plugins/plugin-graph/src/GraphPlugin.tsx","kind":"import-statement","original":"./GraphPlugin"}],"format":"esm"}},"outputs":{"packages/plugins/plugin-graph/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":4377},"packages/plugins/plugin-graph/dist/lib/browser/index.mjs":{"imports":[{"path":"packages/plugins/plugin-graph/dist/lib/browser/chunk-SYPRW7IK.mjs","kind":"import-statement"},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true}],"exports":["GraphContext","GraphPlugin","default","useGraph"],"entryPoint":"packages/plugins/plugin-graph/src/index.ts","inputs":{"packages/plugins/plugin-graph/src/GraphPlugin.tsx":{"bytesInOutput":1253},"packages/plugins/plugin-graph/src/GraphContext.ts":{"bytesInOutput":219},"packages/plugins/plugin-graph/src/index.ts":{"bytesInOutput":64}},"bytes":1931},"packages/plugins/plugin-graph/dist/lib/browser/meta.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/plugins/plugin-graph/dist/lib/browser/meta.mjs":{"imports":[{"path":"packages/plugins/plugin-graph/dist/lib/browser/chunk-SYPRW7IK.mjs","kind":"import-statement"}],"exports":["GRAPH_PLUGIN","default"],"entryPoint":"packages/plugins/plugin-graph/src/meta.ts","inputs":{},"bytes":159},"packages/plugins/plugin-graph/dist/lib/browser/chunk-SYPRW7IK.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":403},"packages/plugins/plugin-graph/dist/lib/browser/chunk-SYPRW7IK.mjs":{"imports":[],"exports":["GRAPH_PLUGIN","meta_default"],"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytesInOutput":87}},"bytes":220}}}
|
package/dist/lib/node/index.cjs
CHANGED
|
@@ -44,21 +44,26 @@ var import_debug = require("@dxos/debug");
|
|
|
44
44
|
__reExport(node_exports, require("@dxos/app-graph"), module.exports);
|
|
45
45
|
var GraphContext = (0, import_react2.createContext)(null);
|
|
46
46
|
var useGraph = () => (0, import_react2.useContext)(GraphContext) ?? (0, import_debug.raise)(new Error("Missing GraphContext"));
|
|
47
|
+
var KEY = `${import_chunk_PIWXSWR4.GRAPH_PLUGIN}/graph`;
|
|
47
48
|
var GraphPlugin = () => {
|
|
48
|
-
const builder =
|
|
49
|
-
let
|
|
49
|
+
const builder = import_app_graph.GraphBuilder.from(localStorage.getItem(KEY) ?? void 0);
|
|
50
|
+
let interval;
|
|
50
51
|
return {
|
|
51
52
|
meta: import_chunk_PIWXSWR4.meta_default,
|
|
52
53
|
ready: async (plugins) => {
|
|
54
|
+
interval = setInterval(() => {
|
|
55
|
+
localStorage.setItem(`${import_chunk_PIWXSWR4.GRAPH_PLUGIN}/graph`, builder.graph.pickle());
|
|
56
|
+
}, 5e3);
|
|
53
57
|
(0, import_app_framework.filterPlugins)(plugins, import_app_framework.parseGraphBuilderPlugin).forEach((plugin) => builder.addExtension(plugin.provides.graph.builder(plugins)));
|
|
54
58
|
await builder.initialize();
|
|
59
|
+
await builder.graph.expand(builder.graph.root);
|
|
55
60
|
const composer = window.composer;
|
|
56
61
|
if (typeof composer === "object") {
|
|
57
62
|
composer.graph = builder.graph;
|
|
58
63
|
}
|
|
59
64
|
},
|
|
60
65
|
unload: async () => {
|
|
61
|
-
|
|
66
|
+
clearInterval(interval);
|
|
62
67
|
},
|
|
63
68
|
provides: {
|
|
64
69
|
graph: builder.graph,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/GraphPlugin.tsx", "../../../src/GraphContext.ts", "../../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { filterPlugins, type GraphProvides, type PluginDefinition, parseGraphBuilderPlugin } from '@dxos/app-framework';\nimport { GraphBuilder } from '@dxos/app-graph';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mBAAkB;AAElB,2BAAkG;AAClG,uBAA6B;ACF7B,IAAAA,gBAAwD;AAGxD,mBAAsB;ACAtB,yBAAc;ADIP,IAAMC,mBAA6CC,6BAAmC,IAAA;AAEtF,IAAMC,WAAW,UAAoBC,0BAAWH,YAAAA,SAAiBI,oBAAM,IAAIC,MAAM,sBAAA,CAAA;
|
|
6
|
-
"names": ["import_react", "GraphContext", "createContext", "useGraph", "useContext", "raise", "Error", "GraphPlugin", "builder", "GraphBuilder", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { filterPlugins, type GraphProvides, type PluginDefinition, parseGraphBuilderPlugin } from '@dxos/app-framework';\nimport { GraphBuilder } from '@dxos/app-graph';\n\nimport { GraphContext } from './GraphContext';\nimport meta, { GRAPH_PLUGIN } from './meta';\n\nconst KEY = `${GRAPH_PLUGIN}/graph`;\n\n/**\n * Manages the state of the graph for the application.\n * Enables other plugins to register node builders to add nodes to the graph.\n * This includes actions and annotation each other's nodes.\n */\nexport const GraphPlugin = (): PluginDefinition<GraphProvides> => {\n const builder = GraphBuilder.from(localStorage.getItem(KEY) ?? undefined);\n let interval: NodeJS.Timeout | undefined;\n\n return {\n meta,\n ready: async (plugins) => {\n interval = setInterval(() => {\n localStorage.setItem(`${GRAPH_PLUGIN}/graph`, builder.graph.pickle());\n }, 5_000);\n\n filterPlugins(plugins, parseGraphBuilderPlugin).forEach((plugin) =>\n builder.addExtension(plugin.provides.graph.builder(plugins)),\n );\n\n await builder.initialize();\n await builder.graph.expand(builder.graph.root);\n\n // Expose the graph to the window for debugging.\n const composer = (window as any).composer;\n if (typeof composer === 'object') {\n composer.graph = builder.graph;\n }\n },\n unload: async () => {\n clearInterval(interval);\n },\n provides: {\n graph: builder.graph,\n // TODO(wittjosiah): This is janky.\n explore: (options) => builder.explore(options),\n context: ({ children }) => (\n <GraphContext.Provider value={{ graph: builder.graph }}>{children}</GraphContext.Provider>\n ),\n },\n };\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// TODO(wittjosiah): State can be a GraphNode.\nimport { type Context, createContext, useContext } from 'react';\n\nimport { type Graph } from '@dxos/app-graph';\nimport { raise } from '@dxos/debug';\n\nexport type GraphContext = { graph: Graph };\n\nexport const GraphContext: Context<GraphContext | null> = createContext<GraphContext | null>(null);\n\nexport const useGraph = (): GraphContext => useContext(GraphContext) ?? raise(new Error('Missing GraphContext'));\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { GraphPlugin } from './GraphPlugin';\n\nexport default GraphPlugin;\n\nexport * from '@dxos/app-graph';\n\nexport * from './GraphContext';\nexport * from './GraphPlugin';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mBAAkB;AAElB,2BAAkG;AAClG,uBAA6B;ACF7B,IAAAA,gBAAwD;AAGxD,mBAAsB;ACAtB,yBAAc;ADIP,IAAMC,mBAA6CC,6BAAmC,IAAA;AAEtF,IAAMC,WAAW,UAAoBC,0BAAWH,YAAAA,SAAiBI,oBAAM,IAAIC,MAAM,sBAAA,CAAA;ADFxF,IAAMC,MAAM,GAAGC,kCAAAA;AAOR,IAAMC,cAAc,MAAA;AACzB,QAAMC,UAAUC,8BAAaC,KAAKC,aAAaC,QAAQP,GAAAA,KAAQQ,MAAAA;AAC/D,MAAIC;AAEJ,SAAO;IACLC,MAAAA;IACAC,OAAO,OAAOC,YAAAA;AACZH,iBAAWI,YAAY,MAAA;AACrBP,qBAAaQ,QAAQ,GAAGb,kCAAAA,UAAsBE,QAAQY,MAAMC,OAAM,CAAA;MACpE,GAAG,GAAA;AAEHC,8CAAcL,SAASM,4CAAAA,EAAyBC,QAAQ,CAACC,WACvDjB,QAAQkB,aAAaD,OAAOE,SAASP,MAAMZ,QAAQS,OAAAA,CAAAA,CAAAA;AAGrD,YAAMT,QAAQoB,WAAU;AACxB,YAAMpB,QAAQY,MAAMS,OAAOrB,QAAQY,MAAMU,IAAI;AAG7C,YAAMC,WAAYC,OAAeD;AACjC,UAAI,OAAOA,aAAa,UAAU;AAChCA,iBAASX,QAAQZ,QAAQY;MAC3B;IACF;IACAa,QAAQ,YAAA;AACNC,oBAAcpB,QAAAA;IAChB;IACAa,UAAU;MACRP,OAAOZ,QAAQY;;MAEfe,SAAS,CAACC,YAAY5B,QAAQ2B,QAAQC,OAAAA;MACtCC,SAAS,CAAC,EAAEC,SAAQ,MAClB,6BAAAC,QAAA,cAACxC,aAAayC,UAAQ;QAACC,OAAO;UAAErB,OAAOZ,QAAQY;QAAM;SAAIkB,QAAAA;IAE7D;EACF;AACF;AEjDA,IAAA,cAAe/B;",
|
|
6
|
+
"names": ["import_react", "GraphContext", "createContext", "useGraph", "useContext", "raise", "Error", "KEY", "GRAPH_PLUGIN", "GraphPlugin", "builder", "GraphBuilder", "from", "localStorage", "getItem", "undefined", "interval", "meta", "ready", "plugins", "setInterval", "setItem", "graph", "pickle", "filterPlugins", "parseGraphBuilderPlugin", "forEach", "plugin", "addExtension", "provides", "initialize", "expand", "root", "composer", "window", "unload", "clearInterval", "explore", "options", "context", "children", "React", "Provider", "value"]
|
|
7
7
|
}
|
package/dist/lib/node/meta.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/plugins/plugin-graph/src/GraphContext.ts":{"bytes":1674,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true}],"format":"esm"},"packages/plugins/plugin-graph/src/meta.ts":{"bytes":854,"imports":[],"format":"esm"},"packages/plugins/plugin-graph/src/GraphPlugin.tsx":{"bytes":
|
|
1
|
+
{"inputs":{"packages/plugins/plugin-graph/src/GraphContext.ts":{"bytes":1674,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true}],"format":"esm"},"packages/plugins/plugin-graph/src/meta.ts":{"bytes":854,"imports":[],"format":"esm"},"packages/plugins/plugin-graph/src/GraphPlugin.tsx":{"bytes":6523,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/GraphContext.ts","kind":"import-statement","original":"./GraphContext"},{"path":"packages/plugins/plugin-graph/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/plugin-graph/src/index.ts":{"bytes":978,"imports":[{"path":"packages/plugins/plugin-graph/src/GraphPlugin.tsx","kind":"import-statement","original":"./GraphPlugin"},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/GraphContext.ts","kind":"import-statement","original":"./GraphContext"},{"path":"packages/plugins/plugin-graph/src/GraphPlugin.tsx","kind":"import-statement","original":"./GraphPlugin"}],"format":"esm"}},"outputs":{"packages/plugins/plugin-graph/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":4377},"packages/plugins/plugin-graph/dist/lib/node/index.cjs":{"imports":[{"path":"packages/plugins/plugin-graph/dist/lib/node/chunk-PIWXSWR4.cjs","kind":"import-statement"},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true}],"exports":["GraphContext","GraphPlugin","default","useGraph"],"entryPoint":"packages/plugins/plugin-graph/src/index.ts","inputs":{"packages/plugins/plugin-graph/src/GraphPlugin.tsx":{"bytesInOutput":1253},"packages/plugins/plugin-graph/src/GraphContext.ts":{"bytesInOutput":219},"packages/plugins/plugin-graph/src/index.ts":{"bytesInOutput":64}},"bytes":1931},"packages/plugins/plugin-graph/dist/lib/node/meta.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/plugins/plugin-graph/dist/lib/node/meta.cjs":{"imports":[{"path":"packages/plugins/plugin-graph/dist/lib/node/chunk-PIWXSWR4.cjs","kind":"import-statement"}],"exports":["GRAPH_PLUGIN","default"],"entryPoint":"packages/plugins/plugin-graph/src/meta.ts","inputs":{},"bytes":159},"packages/plugins/plugin-graph/dist/lib/node/chunk-PIWXSWR4.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":403},"packages/plugins/plugin-graph/dist/lib/node/chunk-PIWXSWR4.cjs":{"imports":[],"exports":["GRAPH_PLUGIN","meta_default"],"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytesInOutput":87}},"bytes":220}}}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
+
GRAPH_PLUGIN,
|
|
3
4
|
meta_default
|
|
4
5
|
} from "./chunk-H3EEX7DI.mjs";
|
|
5
6
|
|
|
@@ -15,21 +16,26 @@ var GraphContext = createContext(null);
|
|
|
15
16
|
var useGraph = () => useContext(GraphContext) ?? raise(new Error("Missing GraphContext"));
|
|
16
17
|
|
|
17
18
|
// packages/plugins/plugin-graph/src/GraphPlugin.tsx
|
|
19
|
+
var KEY = `${GRAPH_PLUGIN}/graph`;
|
|
18
20
|
var GraphPlugin = () => {
|
|
19
|
-
const builder =
|
|
20
|
-
let
|
|
21
|
+
const builder = GraphBuilder.from(localStorage.getItem(KEY) ?? void 0);
|
|
22
|
+
let interval;
|
|
21
23
|
return {
|
|
22
24
|
meta: meta_default,
|
|
23
25
|
ready: async (plugins) => {
|
|
26
|
+
interval = setInterval(() => {
|
|
27
|
+
localStorage.setItem(`${GRAPH_PLUGIN}/graph`, builder.graph.pickle());
|
|
28
|
+
}, 5e3);
|
|
24
29
|
filterPlugins(plugins, parseGraphBuilderPlugin).forEach((plugin) => builder.addExtension(plugin.provides.graph.builder(plugins)));
|
|
25
30
|
await builder.initialize();
|
|
31
|
+
await builder.graph.expand(builder.graph.root);
|
|
26
32
|
const composer = window.composer;
|
|
27
33
|
if (typeof composer === "object") {
|
|
28
34
|
composer.graph = builder.graph;
|
|
29
35
|
}
|
|
30
36
|
},
|
|
31
37
|
unload: async () => {
|
|
32
|
-
|
|
38
|
+
clearInterval(interval);
|
|
33
39
|
},
|
|
34
40
|
provides: {
|
|
35
41
|
graph: builder.graph,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/GraphPlugin.tsx", "../../../src/GraphContext.ts", "../../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { filterPlugins, type GraphProvides, type PluginDefinition, parseGraphBuilderPlugin } from '@dxos/app-framework';\nimport { GraphBuilder } from '@dxos/app-graph';\
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["React", "filterPlugins", "parseGraphBuilderPlugin", "GraphBuilder", "createContext", "useContext", "raise", "GraphContext", "createContext", "useGraph", "useContext", "raise", "Error", "GraphPlugin", "builder", "GraphBuilder", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { filterPlugins, type GraphProvides, type PluginDefinition, parseGraphBuilderPlugin } from '@dxos/app-framework';\nimport { GraphBuilder } from '@dxos/app-graph';\n\nimport { GraphContext } from './GraphContext';\nimport meta, { GRAPH_PLUGIN } from './meta';\n\nconst KEY = `${GRAPH_PLUGIN}/graph`;\n\n/**\n * Manages the state of the graph for the application.\n * Enables other plugins to register node builders to add nodes to the graph.\n * This includes actions and annotation each other's nodes.\n */\nexport const GraphPlugin = (): PluginDefinition<GraphProvides> => {\n const builder = GraphBuilder.from(localStorage.getItem(KEY) ?? undefined);\n let interval: NodeJS.Timeout | undefined;\n\n return {\n meta,\n ready: async (plugins) => {\n interval = setInterval(() => {\n localStorage.setItem(`${GRAPH_PLUGIN}/graph`, builder.graph.pickle());\n }, 5_000);\n\n filterPlugins(plugins, parseGraphBuilderPlugin).forEach((plugin) =>\n builder.addExtension(plugin.provides.graph.builder(plugins)),\n );\n\n await builder.initialize();\n await builder.graph.expand(builder.graph.root);\n\n // Expose the graph to the window for debugging.\n const composer = (window as any).composer;\n if (typeof composer === 'object') {\n composer.graph = builder.graph;\n }\n },\n unload: async () => {\n clearInterval(interval);\n },\n provides: {\n graph: builder.graph,\n // TODO(wittjosiah): This is janky.\n explore: (options) => builder.explore(options),\n context: ({ children }) => (\n <GraphContext.Provider value={{ graph: builder.graph }}>{children}</GraphContext.Provider>\n ),\n },\n };\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\n// TODO(wittjosiah): State can be a GraphNode.\nimport { type Context, createContext, useContext } from 'react';\n\nimport { type Graph } from '@dxos/app-graph';\nimport { raise } from '@dxos/debug';\n\nexport type GraphContext = { graph: Graph };\n\nexport const GraphContext: Context<GraphContext | null> = createContext<GraphContext | null>(null);\n\nexport const useGraph = (): GraphContext => useContext(GraphContext) ?? raise(new Error('Missing GraphContext'));\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { GraphPlugin } from './GraphPlugin';\n\nexport default GraphPlugin;\n\nexport * from '@dxos/app-graph';\n\nexport * from './GraphContext';\nexport * from './GraphPlugin';\n"],
|
|
5
|
+
"mappings": ";;;;;;;AAIA,OAAOA,WAAW;AAElB,SAASC,eAA0DC,+BAA+B;AAClG,SAASC,oBAAoB;;;ACF7B,SAAuBC,eAAeC,kBAAkB;AAGxD,SAASC,aAAa;AAIf,IAAMC,eAA6CC,cAAmC,IAAA;AAEtF,IAAMC,WAAW,MAAoBC,WAAWH,YAAAA,KAAiBI,MAAM,IAAIC,MAAM,sBAAA,CAAA;;;ADFxF,IAAMC,MAAM,GAAGC,YAAAA;AAOR,IAAMC,cAAc,MAAA;AACzB,QAAMC,UAAUC,aAAaC,KAAKC,aAAaC,QAAQP,GAAAA,KAAQQ,MAAAA;AAC/D,MAAIC;AAEJ,SAAO;IACLC;IACAC,OAAO,OAAOC,YAAAA;AACZH,iBAAWI,YAAY,MAAA;AACrBP,qBAAaQ,QAAQ,GAAGb,YAAAA,UAAsBE,QAAQY,MAAMC,OAAM,CAAA;MACpE,GAAG,GAAA;AAEHC,oBAAcL,SAASM,uBAAAA,EAAyBC,QAAQ,CAACC,WACvDjB,QAAQkB,aAAaD,OAAOE,SAASP,MAAMZ,QAAQS,OAAAA,CAAAA,CAAAA;AAGrD,YAAMT,QAAQoB,WAAU;AACxB,YAAMpB,QAAQY,MAAMS,OAAOrB,QAAQY,MAAMU,IAAI;AAG7C,YAAMC,WAAYC,OAAeD;AACjC,UAAI,OAAOA,aAAa,UAAU;AAChCA,iBAASX,QAAQZ,QAAQY;MAC3B;IACF;IACAa,QAAQ,YAAA;AACNC,oBAAcpB,QAAAA;IAChB;IACAa,UAAU;MACRP,OAAOZ,QAAQY;;MAEfe,SAAS,CAACC,YAAY5B,QAAQ2B,QAAQC,OAAAA;MACtCC,SAAS,CAAC,EAAEC,SAAQ,MAClB,sBAAA,cAACC,aAAaC,UAAQ;QAACC,OAAO;UAAErB,OAAOZ,QAAQY;QAAM;SAAIkB,QAAAA;IAE7D;EACF;AACF;;;AE/CA,cAAc;AAFd,IAAA,cAAeI;",
|
|
6
|
+
"names": ["React", "filterPlugins", "parseGraphBuilderPlugin", "GraphBuilder", "createContext", "useContext", "raise", "GraphContext", "createContext", "useGraph", "useContext", "raise", "Error", "KEY", "GRAPH_PLUGIN", "GraphPlugin", "builder", "GraphBuilder", "from", "localStorage", "getItem", "undefined", "interval", "meta", "ready", "plugins", "setInterval", "setItem", "graph", "pickle", "filterPlugins", "parseGraphBuilderPlugin", "forEach", "plugin", "addExtension", "provides", "initialize", "expand", "root", "composer", "window", "unload", "clearInterval", "explore", "options", "context", "children", "GraphContext", "Provider", "value", "GraphPlugin"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/plugins/plugin-graph/src/GraphContext.ts":{"bytes":1674,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true}],"format":"esm"},"packages/plugins/plugin-graph/src/meta.ts":{"bytes":854,"imports":[],"format":"esm"},"packages/plugins/plugin-graph/src/GraphPlugin.tsx":{"bytes":
|
|
1
|
+
{"inputs":{"packages/plugins/plugin-graph/src/GraphContext.ts":{"bytes":1674,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true}],"format":"esm"},"packages/plugins/plugin-graph/src/meta.ts":{"bytes":854,"imports":[],"format":"esm"},"packages/plugins/plugin-graph/src/GraphPlugin.tsx":{"bytes":6523,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/GraphContext.ts","kind":"import-statement","original":"./GraphContext"},{"path":"packages/plugins/plugin-graph/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/plugin-graph/src/index.ts":{"bytes":978,"imports":[{"path":"packages/plugins/plugin-graph/src/GraphPlugin.tsx","kind":"import-statement","original":"./GraphPlugin"},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/GraphContext.ts","kind":"import-statement","original":"./GraphContext"},{"path":"packages/plugins/plugin-graph/src/GraphPlugin.tsx","kind":"import-statement","original":"./GraphPlugin"}],"format":"esm"}},"outputs":{"packages/plugins/plugin-graph/dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":4378},"packages/plugins/plugin-graph/dist/lib/node-esm/index.mjs":{"imports":[{"path":"packages/plugins/plugin-graph/dist/lib/node-esm/chunk-H3EEX7DI.mjs","kind":"import-statement"},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true}],"exports":["GraphContext","GraphPlugin","default","useGraph"],"entryPoint":"packages/plugins/plugin-graph/src/index.ts","inputs":{"packages/plugins/plugin-graph/src/GraphPlugin.tsx":{"bytesInOutput":1253},"packages/plugins/plugin-graph/src/GraphContext.ts":{"bytesInOutput":219},"packages/plugins/plugin-graph/src/index.ts":{"bytesInOutput":64}},"bytes":2023},"packages/plugins/plugin-graph/dist/lib/node-esm/meta.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/plugins/plugin-graph/dist/lib/node-esm/meta.mjs":{"imports":[{"path":"packages/plugins/plugin-graph/dist/lib/node-esm/chunk-H3EEX7DI.mjs","kind":"import-statement"}],"exports":["GRAPH_PLUGIN","default"],"entryPoint":"packages/plugins/plugin-graph/src/meta.ts","inputs":{},"bytes":251},"packages/plugins/plugin-graph/dist/lib/node-esm/chunk-H3EEX7DI.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":405},"packages/plugins/plugin-graph/dist/lib/node-esm/chunk-H3EEX7DI.mjs":{"imports":[],"exports":["GRAPH_PLUGIN","meta_default"],"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytesInOutput":87}},"bytes":313}}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphPlugin.d.ts","sourceRoot":"","sources":["../../../src/GraphPlugin.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAiB,KAAK,aAAa,EAAE,KAAK,gBAAgB,EAA2B,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"GraphPlugin.d.ts","sourceRoot":"","sources":["../../../src/GraphPlugin.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAiB,KAAK,aAAa,EAAE,KAAK,gBAAgB,EAA2B,MAAM,qBAAqB,CAAC;AAQxH;;;;GAIG;AACH,eAAO,MAAM,WAAW,QAAO,gBAAgB,CAAC,aAAa,CAoC5D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-graph",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2-staging.6d26b2a",
|
|
4
4
|
"description": "DXOS Surface plugin for constructing knowledge graphs",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@preact/signals-core": "^1.6.0",
|
|
36
|
-
"@dxos/app-framework": "0.7.
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/async": "0.7.
|
|
39
|
-
"@dxos/
|
|
36
|
+
"@dxos/app-framework": "0.7.2-staging.6d26b2a",
|
|
37
|
+
"@dxos/app-graph": "0.7.2-staging.6d26b2a",
|
|
38
|
+
"@dxos/async": "0.7.2-staging.6d26b2a",
|
|
39
|
+
"@dxos/debug": "0.7.2-staging.6d26b2a"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/react": "~18.2.0",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"react": "~18.2.0",
|
|
45
45
|
"react-dom": "~18.2.0",
|
|
46
46
|
"vite": "5.4.7",
|
|
47
|
-
"@dxos/react-client": "0.7.
|
|
48
|
-
"@dxos/storybook-utils": "0.7.
|
|
47
|
+
"@dxos/react-client": "0.7.2-staging.6d26b2a",
|
|
48
|
+
"@dxos/storybook-utils": "0.7.2-staging.6d26b2a"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"react": "~18.2.0",
|
package/src/GraphPlugin.tsx
CHANGED
|
@@ -6,12 +6,11 @@ import React from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { filterPlugins, type GraphProvides, type PluginDefinition, parseGraphBuilderPlugin } from '@dxos/app-framework';
|
|
8
8
|
import { GraphBuilder } from '@dxos/app-graph';
|
|
9
|
-
import { type UnsubscribeCallback } from '@dxos/async';
|
|
10
9
|
|
|
11
10
|
import { GraphContext } from './GraphContext';
|
|
12
|
-
import meta from './meta';
|
|
11
|
+
import meta, { GRAPH_PLUGIN } from './meta';
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
const KEY = `${GRAPH_PLUGIN}/graph`;
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* Manages the state of the graph for the application.
|
|
@@ -19,26 +18,22 @@ import meta from './meta';
|
|
|
19
18
|
* This includes actions and annotation each other's nodes.
|
|
20
19
|
*/
|
|
21
20
|
export const GraphPlugin = (): PluginDefinition<GraphProvides> => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
let unsubscribe: UnsubscribeCallback | undefined;
|
|
21
|
+
const builder = GraphBuilder.from(localStorage.getItem(KEY) ?? undefined);
|
|
22
|
+
let interval: NodeJS.Timeout | undefined;
|
|
25
23
|
|
|
26
24
|
return {
|
|
27
25
|
meta,
|
|
28
26
|
ready: async (plugins) => {
|
|
27
|
+
interval = setInterval(() => {
|
|
28
|
+
localStorage.setItem(`${GRAPH_PLUGIN}/graph`, builder.graph.pickle());
|
|
29
|
+
}, 5_000);
|
|
30
|
+
|
|
29
31
|
filterPlugins(plugins, parseGraphBuilderPlugin).forEach((plugin) =>
|
|
30
32
|
builder.addExtension(plugin.provides.graph.builder(plugins)),
|
|
31
33
|
);
|
|
32
34
|
|
|
33
35
|
await builder.initialize();
|
|
34
|
-
|
|
35
|
-
// TODO(wittjosiah): This needs better cache invalidation before it can be enabled always.
|
|
36
|
-
// At present it's too easy to get into a state where there are partial/broken nodes in the graph.
|
|
37
|
-
// unsubscribe = effect(
|
|
38
|
-
// debounce(() => {
|
|
39
|
-
// localStorage.setItem(`${GRAPH_PLUGIN}/graph`, builder.graph.pickle());
|
|
40
|
-
// }, 1000),
|
|
41
|
-
// );
|
|
36
|
+
await builder.graph.expand(builder.graph.root);
|
|
42
37
|
|
|
43
38
|
// Expose the graph to the window for debugging.
|
|
44
39
|
const composer = (window as any).composer;
|
|
@@ -47,7 +42,7 @@ export const GraphPlugin = (): PluginDefinition<GraphProvides> => {
|
|
|
47
42
|
}
|
|
48
43
|
},
|
|
49
44
|
unload: async () => {
|
|
50
|
-
|
|
45
|
+
clearInterval(interval);
|
|
51
46
|
},
|
|
52
47
|
provides: {
|
|
53
48
|
graph: builder.graph,
|