@dxos/plugin-graph 0.6.14-staging.54a8bab → 0.6.14-staging.7b35391

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.
@@ -1,14 +1,11 @@
1
1
  import {
2
- GRAPH_PLUGIN,
3
2
  meta_default
4
3
  } from "./chunk-SYPRW7IK.mjs";
5
4
 
6
5
  // packages/plugins/plugin-graph/src/GraphPlugin.tsx
7
- import { effect } from "@preact/signals-core";
8
6
  import React from "react";
9
7
  import { filterPlugins, parseGraphBuilderPlugin } from "@dxos/app-framework";
10
8
  import { GraphBuilder } from "@dxos/app-graph";
11
- import { debounce } from "@dxos/async";
12
9
 
13
10
  // packages/plugins/plugin-graph/src/GraphContext.ts
14
11
  import { createContext, useContext } from "react";
@@ -17,18 +14,14 @@ var GraphContext = createContext(null);
17
14
  var useGraph = () => useContext(GraphContext) ?? raise(new Error("Missing GraphContext"));
18
15
 
19
16
  // packages/plugins/plugin-graph/src/GraphPlugin.tsx
20
- var KEY = `${GRAPH_PLUGIN}/graph`;
21
17
  var GraphPlugin = () => {
22
- const builder = GraphBuilder.from(localStorage.getItem(KEY) ?? void 0);
18
+ const builder = new GraphBuilder();
23
19
  let unsubscribe;
24
20
  return {
25
21
  meta: meta_default,
26
22
  ready: async (plugins) => {
27
23
  filterPlugins(plugins, parseGraphBuilderPlugin).forEach((plugin) => builder.addExtension(plugin.provides.graph.builder(plugins)));
28
24
  await builder.initialize();
29
- unsubscribe = effect(debounce(() => {
30
- localStorage.setItem(`${GRAPH_PLUGIN}/graph`, builder.graph.pickle());
31
- }, 1e3));
32
25
  const composer = window.composer;
33
26
  if (typeof composer === "object") {
34
27
  composer.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 { effect } from '@preact/signals-core';\nimport React from 'react';\n\nimport { filterPlugins, type GraphProvides, type PluginDefinition, parseGraphBuilderPlugin } from '@dxos/app-framework';\nimport { GraphBuilder } from '@dxos/app-graph';\nimport { debounce, type UnsubscribeCallback } from '@dxos/async';\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 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 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,SAASA,cAAc;AACvB,OAAOC,WAAW;AAElB,SAASC,eAA0DC,+BAA+B;AAClG,SAASC,oBAAoB;AAC7B,SAASC,gBAA0C;;;ACJnD,SAAuBC,eAAeC,kBAAkB;AAGxD,SAASC,aAAa;AAIf,IAAMC,eAA6CC,cAAmC,IAAA;AAEtF,IAAMC,WAAW,MAAoBC,WAAWH,YAAAA,KAAiBI,MAAM,IAAIC,MAAM,sBAAA,CAAA;;;ADAxF,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;AACZC,oBAAcD,SAASE,uBAAAA,EAAyBC,QAAQ,CAACC,WACvDb,QAAQc,aAAaD,OAAOE,SAASC,MAAMhB,QAAQS,OAAAA,CAAAA,CAAAA;AAGrD,YAAMT,QAAQiB,WAAU;AAExBX,oBAAcY,OACZC,SAAS,MAAA;AACPhB,qBAAaiB,QAAQ,GAAGtB,YAAAA,UAAsBE,QAAQgB,MAAMK,OAAM,CAAA;MACpE,GAAG,GAAA,CAAA;AAIL,YAAMC,WAAYC,OAAeD;AACjC,UAAI,OAAOA,aAAa,UAAU;AAChCA,iBAASN,QAAQhB,QAAQgB;MAC3B;IACF;IACAQ,QAAQ,YAAA;AACNlB,oBAAAA;IACF;IACAS,UAAU;MACRC,OAAOhB,QAAQgB;;MAEfS,SAAS,CAACC,YAAY1B,QAAQyB,QAAQC,OAAAA;MACtCC,SAAS,CAAC,EAAEC,SAAQ,MAClB,sBAAA,cAACC,aAAaC,UAAQ;QAACC,OAAO;UAAEf,OAAOhB,QAAQgB;QAAM;SAAIY,QAAAA;IAE7D;EACF;AACF;;;AElDA,cAAc;AAFd,IAAA,cAAeI;",
6
- "names": ["effect", "React", "filterPlugins", "parseGraphBuilderPlugin", "GraphBuilder", "debounce", "createContext", "useContext", "raise", "GraphContext", "createContext", "useGraph", "useContext", "raise", "Error", "KEY", "GRAPH_PLUGIN", "GraphPlugin", "builder", "GraphBuilder", "from", "localStorage", "getItem", "undefined", "unsubscribe", "meta", "ready", "plugins", "filterPlugins", "parseGraphBuilderPlugin", "forEach", "plugin", "addExtension", "provides", "graph", "initialize", "effect", "debounce", "setItem", "pickle", "composer", "window", "unload", "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":854,"imports":[],"format":"esm"},"packages/plugins/plugin-graph/src/GraphPlugin.tsx":{"bytes":6628,"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"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":"@dxos/async","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":4461},"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":"@preact/signals-core","kind":"import-statement","external":true},{"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":"@dxos/async","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":1289},"packages/plugins/plugin-graph/src/GraphContext.ts":{"bytesInOutput":219},"packages/plugins/plugin-graph/src/index.ts":{"bytesInOutput":64}},"bytes":1967},"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
+ {"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}}}
@@ -36,28 +36,22 @@ __export(node_exports, {
36
36
  });
37
37
  module.exports = __toCommonJS(node_exports);
38
38
  var import_chunk_PIWXSWR4 = require("./chunk-PIWXSWR4.cjs");
39
- var import_signals_core = require("@preact/signals-core");
40
39
  var import_react = __toESM(require("react"));
41
40
  var import_app_framework = require("@dxos/app-framework");
42
41
  var import_app_graph = require("@dxos/app-graph");
43
- var import_async = require("@dxos/async");
44
42
  var import_react2 = require("react");
45
43
  var import_debug = require("@dxos/debug");
46
44
  __reExport(node_exports, require("@dxos/app-graph"), module.exports);
47
45
  var GraphContext = (0, import_react2.createContext)(null);
48
46
  var useGraph = () => (0, import_react2.useContext)(GraphContext) ?? (0, import_debug.raise)(new Error("Missing GraphContext"));
49
- var KEY = `${import_chunk_PIWXSWR4.GRAPH_PLUGIN}/graph`;
50
47
  var GraphPlugin = () => {
51
- const builder = import_app_graph.GraphBuilder.from(localStorage.getItem(KEY) ?? void 0);
48
+ const builder = new import_app_graph.GraphBuilder();
52
49
  let unsubscribe;
53
50
  return {
54
51
  meta: import_chunk_PIWXSWR4.meta_default,
55
52
  ready: async (plugins) => {
56
53
  (0, import_app_framework.filterPlugins)(plugins, import_app_framework.parseGraphBuilderPlugin).forEach((plugin) => builder.addExtension(plugin.provides.graph.builder(plugins)));
57
54
  await builder.initialize();
58
- unsubscribe = (0, import_signals_core.effect)((0, import_async.debounce)(() => {
59
- localStorage.setItem(`${import_chunk_PIWXSWR4.GRAPH_PLUGIN}/graph`, builder.graph.pickle());
60
- }, 1e3));
61
55
  const composer = window.composer;
62
56
  if (typeof composer === "object") {
63
57
  composer.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 { effect } from '@preact/signals-core';\nimport React from 'react';\n\nimport { filterPlugins, type GraphProvides, type PluginDefinition, parseGraphBuilderPlugin } from '@dxos/app-framework';\nimport { GraphBuilder } from '@dxos/app-graph';\nimport { debounce, type UnsubscribeCallback } from '@dxos/async';\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 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 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,0BAAuB;AACvB,mBAAkB;AAElB,2BAAkG;AAClG,uBAA6B;AAC7B,mBAAmD;ACJnD,IAAAA,gBAAwD;AAGxD,mBAAsB;ACAtB,yBAAc;ADIP,IAAMC,mBAA6CC,6BAAmC,IAAA;AAEtF,IAAMC,WAAW,UAAoBC,0BAAWH,YAAAA,SAAiBI,oBAAM,IAAIC,MAAM,sBAAA,CAAA;ADAxF,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;AACZC,8CAAcD,SAASE,4CAAAA,EAAyBC,QAAQ,CAACC,WACvDb,QAAQc,aAAaD,OAAOE,SAASC,MAAMhB,QAAQS,OAAAA,CAAAA,CAAAA;AAGrD,YAAMT,QAAQiB,WAAU;AAExBX,wBAAcY,gCACZC,uBAAS,MAAA;AACPhB,qBAAaiB,QAAQ,GAAGtB,kCAAAA,UAAsBE,QAAQgB,MAAMK,OAAM,CAAA;MACpE,GAAG,GAAA,CAAA;AAIL,YAAMC,WAAYC,OAAeD;AACjC,UAAI,OAAOA,aAAa,UAAU;AAChCA,iBAASN,QAAQhB,QAAQgB;MAC3B;IACF;IACAQ,QAAQ,YAAA;AACNlB,oBAAAA;IACF;IACAS,UAAU;MACRC,OAAOhB,QAAQgB;;MAEfS,SAAS,CAACC,YAAY1B,QAAQyB,QAAQC,OAAAA;MACtCC,SAAS,CAAC,EAAEC,SAAQ,MAClB,6BAAAC,QAAA,cAACtC,aAAauC,UAAQ;QAACC,OAAO;UAAEf,OAAOhB,QAAQgB;QAAM;SAAIY,QAAAA;IAE7D;EACF;AACF;AEpDA,IAAA,cAAe7B;",
6
- "names": ["import_react", "GraphContext", "createContext", "useGraph", "useContext", "raise", "Error", "KEY", "GRAPH_PLUGIN", "GraphPlugin", "builder", "GraphBuilder", "from", "localStorage", "getItem", "undefined", "unsubscribe", "meta", "ready", "plugins", "filterPlugins", "parseGraphBuilderPlugin", "forEach", "plugin", "addExtension", "provides", "graph", "initialize", "effect", "debounce", "setItem", "pickle", "composer", "window", "unload", "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
  }
@@ -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":6628,"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"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":"@dxos/async","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":4461},"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":"@preact/signals-core","kind":"import-statement","external":true},{"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":"@dxos/async","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":1289},"packages/plugins/plugin-graph/src/GraphContext.ts":{"bytesInOutput":219},"packages/plugins/plugin-graph/src/index.ts":{"bytesInOutput":64}},"bytes":1967},"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
+ {"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,15 +1,12 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
  import {
3
- GRAPH_PLUGIN,
4
3
  meta_default
5
4
  } from "./chunk-H3EEX7DI.mjs";
6
5
 
7
6
  // packages/plugins/plugin-graph/src/GraphPlugin.tsx
8
- import { effect } from "@preact/signals-core";
9
7
  import React from "react";
10
8
  import { filterPlugins, parseGraphBuilderPlugin } from "@dxos/app-framework";
11
9
  import { GraphBuilder } from "@dxos/app-graph";
12
- import { debounce } from "@dxos/async";
13
10
 
14
11
  // packages/plugins/plugin-graph/src/GraphContext.ts
15
12
  import { createContext, useContext } from "react";
@@ -18,18 +15,14 @@ var GraphContext = createContext(null);
18
15
  var useGraph = () => useContext(GraphContext) ?? raise(new Error("Missing GraphContext"));
19
16
 
20
17
  // packages/plugins/plugin-graph/src/GraphPlugin.tsx
21
- var KEY = `${GRAPH_PLUGIN}/graph`;
22
18
  var GraphPlugin = () => {
23
- const builder = GraphBuilder.from(localStorage.getItem(KEY) ?? void 0);
19
+ const builder = new GraphBuilder();
24
20
  let unsubscribe;
25
21
  return {
26
22
  meta: meta_default,
27
23
  ready: async (plugins) => {
28
24
  filterPlugins(plugins, parseGraphBuilderPlugin).forEach((plugin) => builder.addExtension(plugin.provides.graph.builder(plugins)));
29
25
  await builder.initialize();
30
- unsubscribe = effect(debounce(() => {
31
- localStorage.setItem(`${GRAPH_PLUGIN}/graph`, builder.graph.pickle());
32
- }, 1e3));
33
26
  const composer = window.composer;
34
27
  if (typeof composer === "object") {
35
28
  composer.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 { effect } from '@preact/signals-core';\nimport React from 'react';\n\nimport { filterPlugins, type GraphProvides, type PluginDefinition, parseGraphBuilderPlugin } from '@dxos/app-framework';\nimport { GraphBuilder } from '@dxos/app-graph';\nimport { debounce, type UnsubscribeCallback } from '@dxos/async';\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 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 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,SAASA,cAAc;AACvB,OAAOC,WAAW;AAElB,SAASC,eAA0DC,+BAA+B;AAClG,SAASC,oBAAoB;AAC7B,SAASC,gBAA0C;;;ACJnD,SAAuBC,eAAeC,kBAAkB;AAGxD,SAASC,aAAa;AAIf,IAAMC,eAA6CC,cAAmC,IAAA;AAEtF,IAAMC,WAAW,MAAoBC,WAAWH,YAAAA,KAAiBI,MAAM,IAAIC,MAAM,sBAAA,CAAA;;;ADAxF,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;AACZC,oBAAcD,SAASE,uBAAAA,EAAyBC,QAAQ,CAACC,WACvDb,QAAQc,aAAaD,OAAOE,SAASC,MAAMhB,QAAQS,OAAAA,CAAAA,CAAAA;AAGrD,YAAMT,QAAQiB,WAAU;AAExBX,oBAAcY,OACZC,SAAS,MAAA;AACPhB,qBAAaiB,QAAQ,GAAGtB,YAAAA,UAAsBE,QAAQgB,MAAMK,OAAM,CAAA;MACpE,GAAG,GAAA,CAAA;AAIL,YAAMC,WAAYC,OAAeD;AACjC,UAAI,OAAOA,aAAa,UAAU;AAChCA,iBAASN,QAAQhB,QAAQgB;MAC3B;IACF;IACAQ,QAAQ,YAAA;AACNlB,oBAAAA;IACF;IACAS,UAAU;MACRC,OAAOhB,QAAQgB;;MAEfS,SAAS,CAACC,YAAY1B,QAAQyB,QAAQC,OAAAA;MACtCC,SAAS,CAAC,EAAEC,SAAQ,MAClB,sBAAA,cAACC,aAAaC,UAAQ;QAACC,OAAO;UAAEf,OAAOhB,QAAQgB;QAAM;SAAIY,QAAAA;IAE7D;EACF;AACF;;;AElDA,cAAc;AAFd,IAAA,cAAeI;",
6
- "names": ["effect", "React", "filterPlugins", "parseGraphBuilderPlugin", "GraphBuilder", "debounce", "createContext", "useContext", "raise", "GraphContext", "createContext", "useGraph", "useContext", "raise", "Error", "KEY", "GRAPH_PLUGIN", "GraphPlugin", "builder", "GraphBuilder", "from", "localStorage", "getItem", "undefined", "unsubscribe", "meta", "ready", "plugins", "filterPlugins", "parseGraphBuilderPlugin", "forEach", "plugin", "addExtension", "provides", "graph", "initialize", "effect", "debounce", "setItem", "pickle", "composer", "window", "unload", "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":854,"imports":[],"format":"esm"},"packages/plugins/plugin-graph/src/GraphPlugin.tsx":{"bytes":6628,"imports":[{"path":"@preact/signals-core","kind":"import-statement","external":true},{"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":"@dxos/async","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":4462},"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":"@preact/signals-core","kind":"import-statement","external":true},{"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":"@dxos/async","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":1289},"packages/plugins/plugin-graph/src/GraphContext.ts":{"bytesInOutput":219},"packages/plugins/plugin-graph/src/index.ts":{"bytesInOutput":64}},"bytes":2059},"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
+ {"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 +1 @@
1
- {"version":3,"file":"GraphPlugin.d.ts","sourceRoot":"","sources":["../../../src/GraphPlugin.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAiB,KAAK,aAAa,EAAE,KAAK,gBAAgB,EAA2B,MAAM,qBAAqB,CAAC;AASxH;;;;GAIG;AACH,eAAO,MAAM,WAAW,QAAO,gBAAgB,CAAC,aAAa,CAqC5D,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-graph",
3
- "version": "0.6.14-staging.54a8bab",
3
+ "version": "0.6.14-staging.7b35391",
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.6.14-staging.54a8bab",
37
- "@dxos/app-graph": "0.6.14-staging.54a8bab",
38
- "@dxos/async": "0.6.14-staging.54a8bab",
39
- "@dxos/debug": "0.6.14-staging.54a8bab"
36
+ "@dxos/app-graph": "0.6.14-staging.7b35391",
37
+ "@dxos/debug": "0.6.14-staging.7b35391",
38
+ "@dxos/async": "0.6.14-staging.7b35391",
39
+ "@dxos/app-framework": "0.6.14-staging.7b35391"
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.6.14-staging.54a8bab",
48
- "@dxos/storybook-utils": "0.6.14-staging.54a8bab"
47
+ "@dxos/storybook-utils": "0.6.14-staging.7b35391",
48
+ "@dxos/react-client": "0.6.14-staging.7b35391"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "react": "~18.2.0",
@@ -2,17 +2,16 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { effect } from '@preact/signals-core';
6
5
  import React from 'react';
7
6
 
8
7
  import { filterPlugins, type GraphProvides, type PluginDefinition, parseGraphBuilderPlugin } from '@dxos/app-framework';
9
8
  import { GraphBuilder } from '@dxos/app-graph';
10
- import { debounce, type UnsubscribeCallback } from '@dxos/async';
9
+ import { type UnsubscribeCallback } from '@dxos/async';
11
10
 
12
11
  import { GraphContext } from './GraphContext';
13
- import meta, { GRAPH_PLUGIN } from './meta';
12
+ import meta from './meta';
14
13
 
15
- const KEY = `${GRAPH_PLUGIN}/graph`;
14
+ // const KEY = `${GRAPH_PLUGIN}/graph`;
16
15
 
17
16
  /**
18
17
  * Manages the state of the graph for the application.
@@ -20,7 +19,8 @@ const KEY = `${GRAPH_PLUGIN}/graph`;
20
19
  * This includes actions and annotation each other's nodes.
21
20
  */
22
21
  export const GraphPlugin = (): PluginDefinition<GraphProvides> => {
23
- const builder = GraphBuilder.from(localStorage.getItem(KEY) ?? undefined);
22
+ // const builder = GraphBuilder.from(localStorage.getItem(KEY) ?? undefined);
23
+ const builder = new GraphBuilder();
24
24
  let unsubscribe: UnsubscribeCallback | undefined;
25
25
 
26
26
  return {
@@ -32,11 +32,13 @@ export const GraphPlugin = (): PluginDefinition<GraphProvides> => {
32
32
 
33
33
  await builder.initialize();
34
34
 
35
- unsubscribe = effect(
36
- debounce(() => {
37
- localStorage.setItem(`${GRAPH_PLUGIN}/graph`, builder.graph.pickle());
38
- }, 1000),
39
- );
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
+ // );
40
42
 
41
43
  // Expose the graph to the window for debugging.
42
44
  const composer = (window as any).composer;