@dxos/plugin-graph 0.6.14-staging.9e90729 → 0.6.14-staging.c117501

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.
@@ -0,0 +1,11 @@
1
+ // packages/plugins/plugin-graph/src/meta.ts
2
+ var GRAPH_PLUGIN = "dxos.org/plugin/graph";
3
+ var meta_default = {
4
+ id: GRAPH_PLUGIN
5
+ };
6
+
7
+ export {
8
+ GRAPH_PLUGIN,
9
+ meta_default
10
+ };
11
+ //# sourceMappingURL=chunk-SYPRW7IK.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/meta.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const GRAPH_PLUGIN = 'dxos.org/plugin/graph';\n\nexport default {\n id: GRAPH_PLUGIN,\n} satisfies PluginMeta;\n"],
5
+ "mappings": ";AAMO,IAAMA,eAAe;AAE5B,IAAA,eAAe;EACbC,IAAID;AACN;",
6
+ "names": ["GRAPH_PLUGIN", "id"]
7
+ }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  meta_default
3
- } from "./chunk-4OVHWC4C.mjs";
3
+ } from "./chunk-SYPRW7IK.mjs";
4
4
 
5
5
  // packages/plugins/plugin-graph/src/GraphPlugin.tsx
6
6
  import React from "react";
@@ -16,10 +16,19 @@ var useGraph = () => useContext(GraphContext) ?? raise(new Error("Missing GraphC
16
16
  // packages/plugins/plugin-graph/src/GraphPlugin.tsx
17
17
  var GraphPlugin = () => {
18
18
  const builder = new GraphBuilder();
19
+ let unsubscribe;
19
20
  return {
20
21
  meta: meta_default,
21
22
  ready: async (plugins) => {
22
23
  filterPlugins(plugins, parseGraphBuilderPlugin).forEach((plugin) => builder.addExtension(plugin.provides.graph.builder(plugins)));
24
+ await builder.initialize();
25
+ const composer = window.composer;
26
+ if (typeof composer === "object") {
27
+ composer.graph = builder.graph;
28
+ }
29
+ },
30
+ unload: async () => {
31
+ unsubscribe?.();
23
32
  },
24
33
  provides: {
25
34
  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';\n\nimport { GraphContext } from './GraphContext';\nimport meta from './meta';\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 = new GraphBuilder();\n\n return {\n meta,\n ready: async (plugins) => {\n filterPlugins(plugins, parseGraphBuilderPlugin).forEach((plugin) =>\n builder.addExtension(plugin.provides.graph.builder(plugins)),\n );\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;;;ADGjF,IAAMC,cAAc,MAAA;AACzB,QAAMC,UAAU,IAAIC,aAAAA;AAEpB,SAAO;IACLC;IACAC,OAAO,OAAOC,YAAAA;AACZC,oBAAcD,SAASE,uBAAAA,EAAyBC,QAAQ,CAACC,WACvDR,QAAQS,aAAaD,OAAOE,SAASC,MAAMX,QAAQI,OAAAA,CAAAA,CAAAA;IAEvD;IACAM,UAAU;MACRC,OAAOX,QAAQW;;MAEfC,SAAS,CAACC,YAAYb,QAAQY,QAAQC,OAAAA;MACtCC,SAAS,CAAC,EAAEC,SAAQ,MAClB,sBAAA,cAACC,aAAaC,UAAQ;QAACC,OAAO;UAAEP,OAAOX,QAAQW;QAAM;SAAII,QAAAA;IAE7D;EACF;AACF;;;AE5BA,cAAc;AAFd,IAAA,cAAeI;",
6
- "names": ["React", "filterPlugins", "parseGraphBuilderPlugin", "GraphBuilder", "createContext", "useContext", "raise", "GraphContext", "createContext", "useGraph", "useContext", "raise", "Error", "GraphPlugin", "builder", "GraphBuilder", "meta", "ready", "plugins", "filterPlugins", "parseGraphBuilderPlugin", "forEach", "plugin", "addExtension", "provides", "graph", "explore", "options", "context", "children", "GraphContext", "Provider", "value", "GraphPlugin"]
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';\nimport { type UnsubscribeCallback } from '@dxos/async';\n\nimport { GraphContext } from './GraphContext';\nimport meta from './meta';\n\n// const 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 const builder = new GraphBuilder();\n let unsubscribe: UnsubscribeCallback | undefined;\n\n return {\n meta,\n ready: async (plugins) => {\n filterPlugins(plugins, parseGraphBuilderPlugin).forEach((plugin) =>\n builder.addExtension(plugin.provides.graph.builder(plugins)),\n );\n\n await builder.initialize();\n\n // TODO(wittjosiah): This needs better cache invalidation before it can be enabled always.\n // At present it's too easy to get into a state where there are partial/broken nodes in the graph.\n // unsubscribe = effect(\n // debounce(() => {\n // localStorage.setItem(`${GRAPH_PLUGIN}/graph`, builder.graph.pickle());\n // }, 1000),\n // );\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 unsubscribe?.();\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;;;ADMjF,IAAMC,cAAc,MAAA;AAEzB,QAAMC,UAAU,IAAIC,aAAAA;AACpB,MAAIC;AAEJ,SAAO;IACLC;IACAC,OAAO,OAAOC,YAAAA;AACZC,oBAAcD,SAASE,uBAAAA,EAAyBC,QAAQ,CAACC,WACvDT,QAAQU,aAAaD,OAAOE,SAASC,MAAMZ,QAAQK,OAAAA,CAAAA,CAAAA;AAGrD,YAAML,QAAQa,WAAU;AAWxB,YAAMC,WAAYC,OAAeD;AACjC,UAAI,OAAOA,aAAa,UAAU;AAChCA,iBAASF,QAAQZ,QAAQY;MAC3B;IACF;IACAI,QAAQ,YAAA;AACNd,oBAAAA;IACF;IACAS,UAAU;MACRC,OAAOZ,QAAQY;;MAEfK,SAAS,CAACC,YAAYlB,QAAQiB,QAAQC,OAAAA;MACtCC,SAAS,CAAC,EAAEC,SAAQ,MAClB,sBAAA,cAACC,aAAaC,UAAQ;QAACC,OAAO;UAAEX,OAAOZ,QAAQY;QAAM;SAAIQ,QAAAA;IAE7D;EACF;AACF;;;AEpDA,cAAc;AAFd,IAAA,cAAeI;",
6
+ "names": ["React", "filterPlugins", "parseGraphBuilderPlugin", "GraphBuilder", "createContext", "useContext", "raise", "GraphContext", "createContext", "useGraph", "useContext", "raise", "Error", "GraphPlugin", "builder", "GraphBuilder", "unsubscribe", "meta", "ready", "plugins", "filterPlugins", "parseGraphBuilderPlugin", "forEach", "plugin", "addExtension", "provides", "graph", "initialize", "composer", "window", "unload", "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":692,"imports":[],"format":"esm"},"packages/plugins/plugin-graph/src/GraphPlugin.tsx":{"bytes":4155,"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":3164},"packages/plugins/plugin-graph/dist/lib/browser/index.mjs":{"imports":[{"path":"packages/plugins/plugin-graph/dist/lib/browser/chunk-4OVHWC4C.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":753},"packages/plugins/plugin-graph/src/GraphContext.ts":{"bytesInOutput":219},"packages/plugins/plugin-graph/src/index.ts":{"bytesInOutput":64}},"bytes":1415},"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-4OVHWC4C.mjs","kind":"import-statement"}],"exports":["default"],"entryPoint":"packages/plugins/plugin-graph/src/meta.ts","inputs":{},"bytes":127},"packages/plugins/plugin-graph/dist/lib/browser/chunk-4OVHWC4C.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":324},"packages/plugins/plugin-graph/dist/lib/browser/chunk-4OVHWC4C.mjs":{"imports":[],"exports":["meta_default"],"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytesInOutput":54}},"bytes":171}}}
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":6749,"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":4297},"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":992},"packages/plugins/plugin-graph/src/GraphContext.ts":{"bytesInOutput":219},"packages/plugins/plugin-graph/src/index.ts":{"bytesInOutput":64}},"bytes":1654},"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}}}
@@ -1,7 +1,9 @@
1
1
  import {
2
+ GRAPH_PLUGIN,
2
3
  meta_default
3
- } from "./chunk-4OVHWC4C.mjs";
4
+ } from "./chunk-SYPRW7IK.mjs";
4
5
  export {
6
+ GRAPH_PLUGIN,
5
7
  meta_default as default
6
8
  };
7
9
  //# sourceMappingURL=meta.mjs.map
@@ -16,16 +16,19 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var chunk_JMUG24QZ_exports = {};
20
- __export(chunk_JMUG24QZ_exports, {
19
+ var chunk_PIWXSWR4_exports = {};
20
+ __export(chunk_PIWXSWR4_exports, {
21
+ GRAPH_PLUGIN: () => GRAPH_PLUGIN,
21
22
  meta_default: () => meta_default
22
23
  });
23
- module.exports = __toCommonJS(chunk_JMUG24QZ_exports);
24
+ module.exports = __toCommonJS(chunk_PIWXSWR4_exports);
25
+ var GRAPH_PLUGIN = "dxos.org/plugin/graph";
24
26
  var meta_default = {
25
- id: "dxos.org/plugin/graph"
27
+ id: GRAPH_PLUGIN
26
28
  };
27
29
  // Annotate the CommonJS export names for ESM import in node:
28
30
  0 && (module.exports = {
31
+ GRAPH_PLUGIN,
29
32
  meta_default
30
33
  });
31
- //# sourceMappingURL=chunk-JMUG24QZ.cjs.map
34
+ //# sourceMappingURL=chunk-PIWXSWR4.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/meta.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const GRAPH_PLUGIN = 'dxos.org/plugin/graph';\n\nexport default {\n id: GRAPH_PLUGIN,\n} satisfies PluginMeta;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAMO,IAAMA,eAAe;AAE5B,IAAA,eAAe;EACbC,IAAID;AACN;",
6
+ "names": ["GRAPH_PLUGIN", "id"]
7
+ }
@@ -35,7 +35,7 @@ __export(node_exports, {
35
35
  useGraph: () => useGraph
36
36
  });
37
37
  module.exports = __toCommonJS(node_exports);
38
- var import_chunk_JMUG24QZ = require("./chunk-JMUG24QZ.cjs");
38
+ var import_chunk_PIWXSWR4 = require("./chunk-PIWXSWR4.cjs");
39
39
  var import_react = __toESM(require("react"));
40
40
  var import_app_framework = require("@dxos/app-framework");
41
41
  var import_app_graph = require("@dxos/app-graph");
@@ -46,10 +46,19 @@ 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
47
  var GraphPlugin = () => {
48
48
  const builder = new import_app_graph.GraphBuilder();
49
+ let unsubscribe;
49
50
  return {
50
- meta: import_chunk_JMUG24QZ.meta_default,
51
+ meta: import_chunk_PIWXSWR4.meta_default,
51
52
  ready: async (plugins) => {
52
53
  (0, import_app_framework.filterPlugins)(plugins, import_app_framework.parseGraphBuilderPlugin).forEach((plugin) => builder.addExtension(plugin.provides.graph.builder(plugins)));
54
+ await builder.initialize();
55
+ const composer = window.composer;
56
+ if (typeof composer === "object") {
57
+ composer.graph = builder.graph;
58
+ }
59
+ },
60
+ unload: async () => {
61
+ unsubscribe?.();
53
62
  },
54
63
  provides: {
55
64
  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';\n\nimport { GraphContext } from './GraphContext';\nimport meta from './meta';\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 = new GraphBuilder();\n\n return {\n meta,\n ready: async (plugins) => {\n filterPlugins(plugins, parseGraphBuilderPlugin).forEach((plugin) =>\n builder.addExtension(plugin.provides.graph.builder(plugins)),\n );\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;ADGjF,IAAMC,cAAc,MAAA;AACzB,QAAMC,UAAU,IAAIC,8BAAAA;AAEpB,SAAO;IACLC,MAAAA;IACAC,OAAO,OAAOC,YAAAA;AACZC,8CAAcD,SAASE,4CAAAA,EAAyBC,QAAQ,CAACC,WACvDR,QAAQS,aAAaD,OAAOE,SAASC,MAAMX,QAAQI,OAAAA,CAAAA,CAAAA;IAEvD;IACAM,UAAU;MACRC,OAAOX,QAAQW;;MAEfC,SAAS,CAACC,YAAYb,QAAQY,QAAQC,OAAAA;MACtCC,SAAS,CAAC,EAAEC,SAAQ,MAClB,6BAAAC,QAAA,cAACvB,aAAawB,UAAQ;QAACC,OAAO;UAAEP,OAAOX,QAAQW;QAAM;SAAII,QAAAA;IAE7D;EACF;AACF;AE9BA,IAAA,cAAehB;",
6
- "names": ["import_react", "GraphContext", "createContext", "useGraph", "useContext", "raise", "Error", "GraphPlugin", "builder", "GraphBuilder", "meta", "ready", "plugins", "filterPlugins", "parseGraphBuilderPlugin", "forEach", "plugin", "addExtension", "provides", "graph", "explore", "options", "context", "children", "React", "Provider", "value"]
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';\nimport { type UnsubscribeCallback } from '@dxos/async';\n\nimport { GraphContext } from './GraphContext';\nimport meta from './meta';\n\n// const 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 const builder = new GraphBuilder();\n let unsubscribe: UnsubscribeCallback | undefined;\n\n return {\n meta,\n ready: async (plugins) => {\n filterPlugins(plugins, parseGraphBuilderPlugin).forEach((plugin) =>\n builder.addExtension(plugin.provides.graph.builder(plugins)),\n );\n\n await builder.initialize();\n\n // TODO(wittjosiah): This needs better cache invalidation before it can be enabled always.\n // At present it's too easy to get into a state where there are partial/broken nodes in the graph.\n // unsubscribe = effect(\n // debounce(() => {\n // localStorage.setItem(`${GRAPH_PLUGIN}/graph`, builder.graph.pickle());\n // }, 1000),\n // );\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 unsubscribe?.();\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;ADMjF,IAAMC,cAAc,MAAA;AAEzB,QAAMC,UAAU,IAAIC,8BAAAA;AACpB,MAAIC;AAEJ,SAAO;IACLC,MAAAA;IACAC,OAAO,OAAOC,YAAAA;AACZC,8CAAcD,SAASE,4CAAAA,EAAyBC,QAAQ,CAACC,WACvDT,QAAQU,aAAaD,OAAOE,SAASC,MAAMZ,QAAQK,OAAAA,CAAAA,CAAAA;AAGrD,YAAML,QAAQa,WAAU;AAWxB,YAAMC,WAAYC,OAAeD;AACjC,UAAI,OAAOA,aAAa,UAAU;AAChCA,iBAASF,QAAQZ,QAAQY;MAC3B;IACF;IACAI,QAAQ,YAAA;AACNd,oBAAAA;IACF;IACAS,UAAU;MACRC,OAAOZ,QAAQY;;MAEfK,SAAS,CAACC,YAAYlB,QAAQiB,QAAQC,OAAAA;MACtCC,SAAS,CAAC,EAAEC,SAAQ,MAClB,6BAAAC,QAAA,cAAC5B,aAAa6B,UAAQ;QAACC,OAAO;UAAEX,OAAOZ,QAAQY;QAAM;SAAIQ,QAAAA;IAE7D;EACF;AACF;AEtDA,IAAA,cAAerB;",
6
+ "names": ["import_react", "GraphContext", "createContext", "useGraph", "useContext", "raise", "Error", "GraphPlugin", "builder", "GraphBuilder", "unsubscribe", "meta", "ready", "plugins", "filterPlugins", "parseGraphBuilderPlugin", "forEach", "plugin", "addExtension", "provides", "graph", "initialize", "composer", "window", "unload", "explore", "options", "context", "children", "React", "Provider", "value"]
7
7
  }
@@ -18,8 +18,13 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var meta_exports = {};
20
20
  __export(meta_exports, {
21
- default: () => import_chunk_JMUG24QZ.meta_default
21
+ GRAPH_PLUGIN: () => import_chunk_PIWXSWR4.GRAPH_PLUGIN,
22
+ default: () => import_chunk_PIWXSWR4.meta_default
22
23
  });
23
24
  module.exports = __toCommonJS(meta_exports);
24
- var import_chunk_JMUG24QZ = require("./chunk-JMUG24QZ.cjs");
25
+ var import_chunk_PIWXSWR4 = require("./chunk-PIWXSWR4.cjs");
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ GRAPH_PLUGIN
29
+ });
25
30
  //# sourceMappingURL=meta.cjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["meta.cjs"],
4
- "sourcesContent": ["import {\n meta_default\n} from \"./chunk-JMUG24QZ.cjs\";\nexport {\n meta_default as default\n};\n//# sourceMappingURL=meta.cjs.map\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAEO;",
4
+ "sourcesContent": ["import {\n GRAPH_PLUGIN,\n meta_default\n} from \"./chunk-PIWXSWR4.cjs\";\nexport {\n GRAPH_PLUGIN,\n meta_default as default\n};\n//# sourceMappingURL=meta.cjs.map\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAGO;",
6
6
  "names": []
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":692,"imports":[],"format":"esm"},"packages/plugins/plugin-graph/src/GraphPlugin.tsx":{"bytes":4155,"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":3164},"packages/plugins/plugin-graph/dist/lib/node/index.cjs":{"imports":[{"path":"packages/plugins/plugin-graph/dist/lib/node/chunk-JMUG24QZ.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":753},"packages/plugins/plugin-graph/src/GraphContext.ts":{"bytesInOutput":219},"packages/plugins/plugin-graph/src/index.ts":{"bytesInOutput":64}},"bytes":1415},"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-JMUG24QZ.cjs","kind":"import-statement"}],"exports":["default"],"entryPoint":"packages/plugins/plugin-graph/src/meta.ts","inputs":{},"bytes":127},"packages/plugins/plugin-graph/dist/lib/node/chunk-JMUG24QZ.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":324},"packages/plugins/plugin-graph/dist/lib/node/chunk-JMUG24QZ.cjs":{"imports":[],"exports":["meta_default"],"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytesInOutput":54}},"bytes":171}}}
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":6749,"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":4297},"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":992},"packages/plugins/plugin-graph/src/GraphContext.ts":{"bytesInOutput":219},"packages/plugins/plugin-graph/src/index.ts":{"bytesInOutput":64}},"bytes":1654},"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,11 +1,13 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
 
3
3
  // packages/plugins/plugin-graph/src/meta.ts
4
+ var GRAPH_PLUGIN = "dxos.org/plugin/graph";
4
5
  var meta_default = {
5
- id: "dxos.org/plugin/graph"
6
+ id: GRAPH_PLUGIN
6
7
  };
7
8
 
8
9
  export {
10
+ GRAPH_PLUGIN,
9
11
  meta_default
10
12
  };
11
- //# sourceMappingURL=chunk-NGPG3UU5.mjs.map
13
+ //# sourceMappingURL=chunk-H3EEX7DI.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/meta.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const GRAPH_PLUGIN = 'dxos.org/plugin/graph';\n\nexport default {\n id: GRAPH_PLUGIN,\n} satisfies PluginMeta;\n"],
5
+ "mappings": ";;;AAMO,IAAMA,eAAe;AAE5B,IAAA,eAAe;EACbC,IAAID;AACN;",
6
+ "names": ["GRAPH_PLUGIN", "id"]
7
+ }
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
  import {
3
3
  meta_default
4
- } from "./chunk-NGPG3UU5.mjs";
4
+ } from "./chunk-H3EEX7DI.mjs";
5
5
 
6
6
  // packages/plugins/plugin-graph/src/GraphPlugin.tsx
7
7
  import React from "react";
@@ -17,10 +17,19 @@ var useGraph = () => useContext(GraphContext) ?? raise(new Error("Missing GraphC
17
17
  // packages/plugins/plugin-graph/src/GraphPlugin.tsx
18
18
  var GraphPlugin = () => {
19
19
  const builder = new GraphBuilder();
20
+ let unsubscribe;
20
21
  return {
21
22
  meta: meta_default,
22
23
  ready: async (plugins) => {
23
24
  filterPlugins(plugins, parseGraphBuilderPlugin).forEach((plugin) => builder.addExtension(plugin.provides.graph.builder(plugins)));
25
+ await builder.initialize();
26
+ const composer = window.composer;
27
+ if (typeof composer === "object") {
28
+ composer.graph = builder.graph;
29
+ }
30
+ },
31
+ unload: async () => {
32
+ unsubscribe?.();
24
33
  },
25
34
  provides: {
26
35
  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';\n\nimport { GraphContext } from './GraphContext';\nimport meta from './meta';\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 = new GraphBuilder();\n\n return {\n meta,\n ready: async (plugins) => {\n filterPlugins(plugins, parseGraphBuilderPlugin).forEach((plugin) =>\n builder.addExtension(plugin.provides.graph.builder(plugins)),\n );\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;;;ADGjF,IAAMC,cAAc,MAAA;AACzB,QAAMC,UAAU,IAAIC,aAAAA;AAEpB,SAAO;IACLC;IACAC,OAAO,OAAOC,YAAAA;AACZC,oBAAcD,SAASE,uBAAAA,EAAyBC,QAAQ,CAACC,WACvDR,QAAQS,aAAaD,OAAOE,SAASC,MAAMX,QAAQI,OAAAA,CAAAA,CAAAA;IAEvD;IACAM,UAAU;MACRC,OAAOX,QAAQW;;MAEfC,SAAS,CAACC,YAAYb,QAAQY,QAAQC,OAAAA;MACtCC,SAAS,CAAC,EAAEC,SAAQ,MAClB,sBAAA,cAACC,aAAaC,UAAQ;QAACC,OAAO;UAAEP,OAAOX,QAAQW;QAAM;SAAII,QAAAA;IAE7D;EACF;AACF;;;AE5BA,cAAc;AAFd,IAAA,cAAeI;",
6
- "names": ["React", "filterPlugins", "parseGraphBuilderPlugin", "GraphBuilder", "createContext", "useContext", "raise", "GraphContext", "createContext", "useGraph", "useContext", "raise", "Error", "GraphPlugin", "builder", "GraphBuilder", "meta", "ready", "plugins", "filterPlugins", "parseGraphBuilderPlugin", "forEach", "plugin", "addExtension", "provides", "graph", "explore", "options", "context", "children", "GraphContext", "Provider", "value", "GraphPlugin"]
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';\nimport { type UnsubscribeCallback } from '@dxos/async';\n\nimport { GraphContext } from './GraphContext';\nimport meta from './meta';\n\n// const 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 const builder = new GraphBuilder();\n let unsubscribe: UnsubscribeCallback | undefined;\n\n return {\n meta,\n ready: async (plugins) => {\n filterPlugins(plugins, parseGraphBuilderPlugin).forEach((plugin) =>\n builder.addExtension(plugin.provides.graph.builder(plugins)),\n );\n\n await builder.initialize();\n\n // TODO(wittjosiah): This needs better cache invalidation before it can be enabled always.\n // At present it's too easy to get into a state where there are partial/broken nodes in the graph.\n // unsubscribe = effect(\n // debounce(() => {\n // localStorage.setItem(`${GRAPH_PLUGIN}/graph`, builder.graph.pickle());\n // }, 1000),\n // );\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 unsubscribe?.();\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;;;ADMjF,IAAMC,cAAc,MAAA;AAEzB,QAAMC,UAAU,IAAIC,aAAAA;AACpB,MAAIC;AAEJ,SAAO;IACLC;IACAC,OAAO,OAAOC,YAAAA;AACZC,oBAAcD,SAASE,uBAAAA,EAAyBC,QAAQ,CAACC,WACvDT,QAAQU,aAAaD,OAAOE,SAASC,MAAMZ,QAAQK,OAAAA,CAAAA,CAAAA;AAGrD,YAAML,QAAQa,WAAU;AAWxB,YAAMC,WAAYC,OAAeD;AACjC,UAAI,OAAOA,aAAa,UAAU;AAChCA,iBAASF,QAAQZ,QAAQY;MAC3B;IACF;IACAI,QAAQ,YAAA;AACNd,oBAAAA;IACF;IACAS,UAAU;MACRC,OAAOZ,QAAQY;;MAEfK,SAAS,CAACC,YAAYlB,QAAQiB,QAAQC,OAAAA;MACtCC,SAAS,CAAC,EAAEC,SAAQ,MAClB,sBAAA,cAACC,aAAaC,UAAQ;QAACC,OAAO;UAAEX,OAAOZ,QAAQY;QAAM;SAAIQ,QAAAA;IAE7D;EACF;AACF;;;AEpDA,cAAc;AAFd,IAAA,cAAeI;",
6
+ "names": ["React", "filterPlugins", "parseGraphBuilderPlugin", "GraphBuilder", "createContext", "useContext", "raise", "GraphContext", "createContext", "useGraph", "useContext", "raise", "Error", "GraphPlugin", "builder", "GraphBuilder", "unsubscribe", "meta", "ready", "plugins", "filterPlugins", "parseGraphBuilderPlugin", "forEach", "plugin", "addExtension", "provides", "graph", "initialize", "composer", "window", "unload", "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":692,"imports":[],"format":"esm"},"packages/plugins/plugin-graph/src/GraphPlugin.tsx":{"bytes":4155,"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":3165},"packages/plugins/plugin-graph/dist/lib/node-esm/index.mjs":{"imports":[{"path":"packages/plugins/plugin-graph/dist/lib/node-esm/chunk-NGPG3UU5.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":753},"packages/plugins/plugin-graph/src/GraphContext.ts":{"bytesInOutput":219},"packages/plugins/plugin-graph/src/index.ts":{"bytesInOutput":64}},"bytes":1507},"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-NGPG3UU5.mjs","kind":"import-statement"}],"exports":["default"],"entryPoint":"packages/plugins/plugin-graph/src/meta.ts","inputs":{},"bytes":219},"packages/plugins/plugin-graph/dist/lib/node-esm/chunk-NGPG3UU5.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":326},"packages/plugins/plugin-graph/dist/lib/node-esm/chunk-NGPG3UU5.mjs":{"imports":[],"exports":["meta_default"],"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytesInOutput":54}},"bytes":264}}}
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":6749,"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":4298},"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":992},"packages/plugins/plugin-graph/src/GraphContext.ts":{"bytesInOutput":219},"packages/plugins/plugin-graph/src/index.ts":{"bytesInOutput":64}},"bytes":1746},"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,8 +1,10 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
  import {
3
+ GRAPH_PLUGIN,
3
4
  meta_default
4
- } from "./chunk-NGPG3UU5.mjs";
5
+ } from "./chunk-H3EEX7DI.mjs";
5
6
  export {
7
+ GRAPH_PLUGIN,
6
8
  meta_default as default
7
9
  };
8
10
  //# sourceMappingURL=meta.mjs.map
@@ -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;AAMxH;;;;GAIG;AACH,eAAO,MAAM,WAAW,QAAO,gBAAgB,CAAC,aAAa,CAmB5D,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;AASxH;;;;GAIG;AACH,eAAO,MAAM,WAAW,QAAO,gBAAgB,CAAC,aAAa,CAwC5D,CAAC"}
@@ -1,3 +1,4 @@
1
+ export declare const GRAPH_PLUGIN = "dxos.org/plugin/graph";
1
2
  declare const _default: {
2
3
  id: string;
3
4
  };
@@ -1 +1 @@
1
- {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/meta.ts"],"names":[],"mappings":";;;AAMA,wBAEuB"}
1
+ {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/meta.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,YAAY,0BAA0B,CAAC;;;;AAEpD,wBAEuB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-graph",
3
- "version": "0.6.14-staging.9e90729",
3
+ "version": "0.6.14-staging.c117501",
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",
@@ -32,9 +32,11 @@
32
32
  "src"
33
33
  ],
34
34
  "dependencies": {
35
- "@dxos/app-framework": "0.6.14-staging.9e90729",
36
- "@dxos/app-graph": "0.6.14-staging.9e90729",
37
- "@dxos/debug": "0.6.14-staging.9e90729"
35
+ "@preact/signals-core": "^1.6.0",
36
+ "@dxos/app-framework": "0.6.14-staging.c117501",
37
+ "@dxos/async": "0.6.14-staging.c117501",
38
+ "@dxos/app-graph": "0.6.14-staging.c117501",
39
+ "@dxos/debug": "0.6.14-staging.c117501"
38
40
  },
39
41
  "devDependencies": {
40
42
  "@types/react": "~18.2.0",
@@ -42,8 +44,8 @@
42
44
  "react": "~18.2.0",
43
45
  "react-dom": "~18.2.0",
44
46
  "vite": "5.4.7",
45
- "@dxos/react-client": "0.6.14-staging.9e90729",
46
- "@dxos/storybook-utils": "0.6.14-staging.9e90729"
47
+ "@dxos/react-client": "0.6.14-staging.c117501",
48
+ "@dxos/storybook-utils": "0.6.14-staging.c117501"
47
49
  },
48
50
  "peerDependencies": {
49
51
  "react": "~18.2.0",
@@ -6,17 +6,22 @@ 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';
9
10
 
10
11
  import { GraphContext } from './GraphContext';
11
12
  import meta from './meta';
12
13
 
14
+ // const KEY = `${GRAPH_PLUGIN}/graph`;
15
+
13
16
  /**
14
17
  * Manages the state of the graph for the application.
15
18
  * Enables other plugins to register node builders to add nodes to the graph.
16
19
  * This includes actions and annotation each other's nodes.
17
20
  */
18
21
  export const GraphPlugin = (): PluginDefinition<GraphProvides> => {
22
+ // const builder = GraphBuilder.from(localStorage.getItem(KEY) ?? undefined);
19
23
  const builder = new GraphBuilder();
24
+ let unsubscribe: UnsubscribeCallback | undefined;
20
25
 
21
26
  return {
22
27
  meta,
@@ -24,6 +29,25 @@ export const GraphPlugin = (): PluginDefinition<GraphProvides> => {
24
29
  filterPlugins(plugins, parseGraphBuilderPlugin).forEach((plugin) =>
25
30
  builder.addExtension(plugin.provides.graph.builder(plugins)),
26
31
  );
32
+
33
+ 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
+ // );
42
+
43
+ // Expose the graph to the window for debugging.
44
+ const composer = (window as any).composer;
45
+ if (typeof composer === 'object') {
46
+ composer.graph = builder.graph;
47
+ }
48
+ },
49
+ unload: async () => {
50
+ unsubscribe?.();
27
51
  },
28
52
  provides: {
29
53
  graph: builder.graph,
package/src/meta.ts CHANGED
@@ -4,6 +4,8 @@
4
4
 
5
5
  import { type PluginMeta } from '@dxos/app-framework';
6
6
 
7
+ export const GRAPH_PLUGIN = 'dxos.org/plugin/graph';
8
+
7
9
  export default {
8
- id: 'dxos.org/plugin/graph',
10
+ id: GRAPH_PLUGIN,
9
11
  } satisfies PluginMeta;
@@ -1,9 +0,0 @@
1
- // packages/plugins/plugin-graph/src/meta.ts
2
- var meta_default = {
3
- id: "dxos.org/plugin/graph"
4
- };
5
-
6
- export {
7
- meta_default
8
- };
9
- //# sourceMappingURL=chunk-4OVHWC4C.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/meta.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport default {\n id: 'dxos.org/plugin/graph',\n} satisfies PluginMeta;\n"],
5
- "mappings": ";AAMA,IAAA,eAAe;EACbA,IAAI;AACN;",
6
- "names": ["id"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/meta.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport default {\n id: 'dxos.org/plugin/graph',\n} satisfies PluginMeta;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAMA,IAAA,eAAe;EACbA,IAAI;AACN;",
6
- "names": ["id"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/meta.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport default {\n id: 'dxos.org/plugin/graph',\n} satisfies PluginMeta;\n"],
5
- "mappings": ";;;AAMA,IAAA,eAAe;EACbA,IAAI;AACN;",
6
- "names": ["id"]
7
- }