@dxos/plugin-graph 0.7.5-main.9d26e3a → 0.7.5-main.b19bfc8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{chunk-SYPRW7IK.mjs → chunk-7LNMG3EB.mjs} +3 -3
- package/dist/lib/browser/chunk-7LNMG3EB.mjs.map +7 -0
- package/dist/lib/browser/graph-U2AHH24Q.mjs +42 -0
- package/dist/lib/browser/graph-U2AHH24Q.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +21 -52
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/{chunk-PIWXSWR4.cjs → chunk-KHIPMH35.cjs} +7 -7
- package/dist/lib/node/chunk-KHIPMH35.cjs.map +7 -0
- package/dist/lib/node/graph-AOAAITHV.cjs +58 -0
- package/dist/lib/node/graph-AOAAITHV.cjs.map +7 -0
- package/dist/lib/node/index.cjs +20 -47
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/{chunk-H3EEX7DI.mjs → chunk-IHM26RSC.mjs} +3 -3
- package/dist/lib/node-esm/chunk-IHM26RSC.mjs.map +7 -0
- package/dist/lib/node-esm/graph-VC422POI.mjs +43 -0
- package/dist/lib/node-esm/graph-VC422POI.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +21 -52
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/GraphPlugin.d.ts +1 -2
- package/dist/types/src/GraphPlugin.d.ts.map +1 -1
- package/dist/types/src/graph.d.ts +8 -0
- package/dist/types/src/graph.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -17
- package/src/GraphPlugin.ts +23 -0
- package/src/graph.ts +49 -0
- package/src/index.ts +1 -5
- package/src/meta.ts +1 -1
- package/dist/lib/browser/chunk-SYPRW7IK.mjs.map +0 -7
- package/dist/lib/browser/meta.mjs +0 -9
- package/dist/lib/browser/meta.mjs.map +0 -7
- package/dist/lib/node/chunk-PIWXSWR4.cjs.map +0 -7
- package/dist/lib/node/meta.cjs +0 -30
- package/dist/lib/node/meta.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-H3EEX7DI.mjs.map +0 -7
- package/dist/lib/node-esm/meta.mjs +0 -10
- package/dist/lib/node-esm/meta.mjs.map +0 -7
- package/dist/types/src/GraphContext.d.ts +0 -8
- package/dist/types/src/GraphContext.d.ts.map +0 -1
- package/src/GraphContext.ts +0 -15
- package/src/GraphPlugin.tsx +0 -56
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// packages/plugins/plugin-graph/src/meta.ts
|
|
2
2
|
var GRAPH_PLUGIN = "dxos.org/plugin/graph";
|
|
3
|
-
var
|
|
3
|
+
var meta = {
|
|
4
4
|
id: GRAPH_PLUGIN
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
export {
|
|
8
8
|
GRAPH_PLUGIN,
|
|
9
|
-
|
|
9
|
+
meta
|
|
10
10
|
};
|
|
11
|
-
//# sourceMappingURL=chunk-
|
|
11
|
+
//# sourceMappingURL=chunk-7LNMG3EB.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 const meta = {\n id: GRAPH_PLUGIN,\n} satisfies PluginMeta;\n"],
|
|
5
|
+
"mappings": ";AAMO,IAAMA,eAAe;AAErB,IAAMC,OAAO;EAClBC,IAAIF;AACN;",
|
|
6
|
+
"names": ["GRAPH_PLUGIN", "meta", "id"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GRAPH_PLUGIN
|
|
3
|
+
} from "./chunk-7LNMG3EB.mjs";
|
|
4
|
+
|
|
5
|
+
// packages/plugins/plugin-graph/src/graph.ts
|
|
6
|
+
import { batch, effect, untracked } from "@preact/signals-core";
|
|
7
|
+
import { Capabilities, contributes } from "@dxos/app-framework";
|
|
8
|
+
import { flattenExtensions, GraphBuilder } from "@dxos/app-graph";
|
|
9
|
+
var KEY = `${GRAPH_PLUGIN}/app-graph`;
|
|
10
|
+
var graph_default = async (context) => {
|
|
11
|
+
const builder = GraphBuilder.from(localStorage.getItem(KEY) ?? void 0);
|
|
12
|
+
const interval = setInterval(() => {
|
|
13
|
+
localStorage.setItem(KEY, builder.graph.pickle());
|
|
14
|
+
}, 5e3);
|
|
15
|
+
const unsubscribe = effect(() => {
|
|
16
|
+
batch(() => {
|
|
17
|
+
const next = flattenExtensions(context.requestCapabilities(Capabilities.AppGraphBuilder));
|
|
18
|
+
const current = untracked(() => builder.extensions);
|
|
19
|
+
const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));
|
|
20
|
+
removed.forEach((extension) => builder.removeExtension(extension.id));
|
|
21
|
+
next.forEach((extension) => builder.addExtension(extension));
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
await builder.initialize();
|
|
25
|
+
await builder.graph.expand(builder.graph.root);
|
|
26
|
+
setupDevtools(builder.graph);
|
|
27
|
+
return contributes(Capabilities.AppGraph, {
|
|
28
|
+
graph: builder.graph,
|
|
29
|
+
explore: (options) => builder.explore(options)
|
|
30
|
+
}, () => {
|
|
31
|
+
clearInterval(interval);
|
|
32
|
+
unsubscribe();
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
var setupDevtools = (graph) => {
|
|
36
|
+
globalThis.composer ??= {};
|
|
37
|
+
globalThis.composer.graph = graph;
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
graph_default as default
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=graph-U2AHH24Q.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/graph.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { batch, effect, untracked } from '@preact/signals-core';\n\nimport { Capabilities, contributes, type PluginsContext } from '@dxos/app-framework';\nimport { flattenExtensions, type Graph, GraphBuilder } from '@dxos/app-graph';\n\nimport { GRAPH_PLUGIN } from './meta';\n\nconst KEY = `${GRAPH_PLUGIN}/app-graph`;\n\nexport default async (context: PluginsContext) => {\n const builder = GraphBuilder.from(localStorage.getItem(KEY) ?? undefined);\n const interval = setInterval(() => {\n localStorage.setItem(KEY, builder.graph.pickle());\n }, 5_000);\n\n const unsubscribe = effect(() => {\n batch(() => {\n const next = flattenExtensions(context.requestCapabilities(Capabilities.AppGraphBuilder));\n const current = untracked(() => builder.extensions);\n const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));\n removed.forEach((extension) => builder.removeExtension(extension.id));\n next.forEach((extension) => builder.addExtension(extension));\n });\n });\n\n await builder.initialize();\n await builder.graph.expand(builder.graph.root);\n\n setupDevtools(builder.graph);\n\n return contributes(\n Capabilities.AppGraph,\n { graph: builder.graph, explore: (options) => builder.explore(options) },\n () => {\n clearInterval(interval);\n unsubscribe();\n },\n );\n};\n\n// Expose the graph to the window for debugging.\nconst setupDevtools = (graph: Graph) => {\n (globalThis as any).composer ??= {};\n (globalThis as any).composer.graph = graph;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;AAIA,SAASA,OAAOC,QAAQC,iBAAiB;AAEzC,SAASC,cAAcC,mBAAwC;AAC/D,SAASC,mBAA+BC,oBAAoB;AAI5D,IAAMC,MAAM,GAAGC,YAAAA;AAEf,IAAA,gBAAe,OAAOC,YAAAA;AACpB,QAAMC,UAAUC,aAAaC,KAAKC,aAAaC,QAAQP,GAAAA,KAAQQ,MAAAA;AAC/D,QAAMC,WAAWC,YAAY,MAAA;AAC3BJ,iBAAaK,QAAQX,KAAKG,QAAQS,MAAMC,OAAM,CAAA;EAChD,GAAG,GAAA;AAEH,QAAMC,cAAcC,OAAO,MAAA;AACzBC,UAAM,MAAA;AACJ,YAAMC,OAAOC,kBAAkBhB,QAAQiB,oBAAoBC,aAAaC,eAAe,CAAA;AACvF,YAAMC,UAAUC,UAAU,MAAMpB,QAAQqB,UAAU;AAClD,YAAMC,UAAUH,QAAQI,OAAO,CAAC,EAAEC,GAAE,MAAO,CAACV,KAAKW,KAAK,CAAC,EAAED,IAAIE,OAAM,MAAOA,WAAWF,EAAAA,CAAAA;AACrFF,cAAQK,QAAQ,CAACC,cAAc5B,QAAQ6B,gBAAgBD,UAAUJ,EAAE,CAAA;AACnEV,WAAKa,QAAQ,CAACC,cAAc5B,QAAQ8B,aAAaF,SAAAA,CAAAA;IACnD,CAAA;EACF,CAAA;AAEA,QAAM5B,QAAQ+B,WAAU;AACxB,QAAM/B,QAAQS,MAAMuB,OAAOhC,QAAQS,MAAMwB,IAAI;AAE7CC,gBAAclC,QAAQS,KAAK;AAE3B,SAAO0B,YACLlB,aAAamB,UACb;IAAE3B,OAAOT,QAAQS;IAAO4B,SAAS,CAACC,YAAYtC,QAAQqC,QAAQC,OAAAA;EAAS,GACvE,MAAA;AACEC,kBAAcjC,QAAAA;AACdK,gBAAAA;EACF,CAAA;AAEJ;AAGA,IAAMuB,gBAAgB,CAACzB,UAAAA;AACpB+B,aAAmBC,aAAa,CAAC;AACjCD,aAAmBC,SAAShC,QAAQA;AACvC;",
|
|
6
|
+
"names": ["batch", "effect", "untracked", "Capabilities", "contributes", "flattenExtensions", "GraphBuilder", "KEY", "GRAPH_PLUGIN", "context", "builder", "GraphBuilder", "from", "localStorage", "getItem", "undefined", "interval", "setInterval", "setItem", "graph", "pickle", "unsubscribe", "effect", "batch", "next", "flattenExtensions", "requestCapabilities", "Capabilities", "AppGraphBuilder", "current", "untracked", "extensions", "removed", "filter", "id", "some", "nextId", "forEach", "extension", "removeExtension", "addExtension", "initialize", "expand", "root", "setupDevtools", "contributes", "AppGraph", "explore", "options", "clearInterval", "globalThis", "composer"]
|
|
7
|
+
}
|
|
@@ -1,61 +1,30 @@
|
|
|
1
1
|
import {
|
|
2
2
|
GRAPH_PLUGIN,
|
|
3
|
-
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
|
|
6
|
-
// packages/plugins/plugin-graph/src/GraphPlugin.tsx
|
|
7
|
-
import React from "react";
|
|
8
|
-
import { filterPlugins, parseGraphBuilderPlugin } from "@dxos/app-framework";
|
|
9
|
-
import { GraphBuilder } from "@dxos/app-graph";
|
|
10
|
-
|
|
11
|
-
// packages/plugins/plugin-graph/src/GraphContext.ts
|
|
12
|
-
import { createContext, useContext } from "react";
|
|
13
|
-
import { raise } from "@dxos/debug";
|
|
14
|
-
var GraphContext = createContext(null);
|
|
15
|
-
var useGraph = () => useContext(GraphContext) ?? raise(new Error("Missing GraphContext"));
|
|
16
|
-
|
|
17
|
-
// packages/plugins/plugin-graph/src/GraphPlugin.tsx
|
|
18
|
-
var KEY = `${GRAPH_PLUGIN}/app-graph`;
|
|
19
|
-
var GraphPlugin = () => {
|
|
20
|
-
const builder = GraphBuilder.from(localStorage.getItem(KEY) ?? void 0);
|
|
21
|
-
let interval;
|
|
22
|
-
return {
|
|
23
|
-
meta: meta_default,
|
|
24
|
-
ready: async ({ plugins }) => {
|
|
25
|
-
interval = setInterval(() => {
|
|
26
|
-
localStorage.setItem(KEY, builder.graph.pickle());
|
|
27
|
-
}, 5e3);
|
|
28
|
-
filterPlugins(plugins, parseGraphBuilderPlugin).forEach((plugin) => builder.addExtension(plugin.provides.graph.builder(plugins)));
|
|
29
|
-
await builder.initialize();
|
|
30
|
-
await builder.graph.expand(builder.graph.root);
|
|
31
|
-
const composer = window.composer;
|
|
32
|
-
if (typeof composer === "object") {
|
|
33
|
-
composer.graph = builder.graph;
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
unload: async () => {
|
|
37
|
-
clearInterval(interval);
|
|
38
|
-
},
|
|
39
|
-
provides: {
|
|
40
|
-
graph: builder.graph,
|
|
41
|
-
// TODO(wittjosiah): This is janky to expose this function in this way.
|
|
42
|
-
explore: (options) => builder.explore(options),
|
|
43
|
-
context: ({ children }) => /* @__PURE__ */ React.createElement(GraphContext.Provider, {
|
|
44
|
-
value: {
|
|
45
|
-
graph: builder.graph
|
|
46
|
-
}
|
|
47
|
-
}, children)
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
};
|
|
3
|
+
meta
|
|
4
|
+
} from "./chunk-7LNMG3EB.mjs";
|
|
51
5
|
|
|
52
6
|
// packages/plugins/plugin-graph/src/index.ts
|
|
53
7
|
export * from "@dxos/app-graph";
|
|
54
|
-
|
|
8
|
+
|
|
9
|
+
// packages/plugins/plugin-graph/src/GraphPlugin.ts
|
|
10
|
+
import { defineModule, lazy, Events, definePlugin } from "@dxos/app-framework";
|
|
11
|
+
var GraphPlugin = () => definePlugin(meta, [
|
|
12
|
+
defineModule({
|
|
13
|
+
id: `${meta.id}/module/graph`,
|
|
14
|
+
activatesOn: Events.Startup,
|
|
15
|
+
activatesBefore: [
|
|
16
|
+
Events.SetupAppGraph,
|
|
17
|
+
Events.SetupMetadata
|
|
18
|
+
],
|
|
19
|
+
activatesAfter: [
|
|
20
|
+
Events.AppGraphReady
|
|
21
|
+
],
|
|
22
|
+
activate: lazy(() => import("./graph-U2AHH24Q.mjs"))
|
|
23
|
+
})
|
|
24
|
+
]);
|
|
55
25
|
export {
|
|
56
|
-
|
|
26
|
+
GRAPH_PLUGIN,
|
|
57
27
|
GraphPlugin,
|
|
58
|
-
|
|
59
|
-
useGraph
|
|
28
|
+
meta
|
|
60
29
|
};
|
|
61
30
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\
|
|
5
|
-
"mappings": ";;;;;;AAIA,
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../../../src/index.ts", "../../../src/GraphPlugin.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nexport * from '@dxos/app-graph';\n\nexport * from './GraphPlugin';\nexport * from './meta';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { defineModule, lazy, Events, definePlugin } from '@dxos/app-framework';\n\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 = () =>\n definePlugin(meta, [\n defineModule({\n id: `${meta.id}/module/graph`,\n activatesOn: Events.Startup,\n activatesBefore: [Events.SetupAppGraph, Events.SetupMetadata],\n activatesAfter: [Events.AppGraphReady],\n activate: lazy(() => import('./graph')),\n }),\n ]);\n"],
|
|
5
|
+
"mappings": ";;;;;;AAIA,cAAc;;;ACAd,SAASA,cAAcC,MAAMC,QAAQC,oBAAoB;AASlD,IAAMC,cAAc,MACzBC,aAAaC,MAAM;EACjBC,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOC;IACpBC,iBAAiB;MAACF,OAAOG;MAAeH,OAAOI;;IAC/CC,gBAAgB;MAACL,OAAOM;;IACxBC,UAAUC,KAAK,MAAM,OAAO,sBAAA,CAAA;EAC9B,CAAA;CACD;",
|
|
6
|
+
"names": ["defineModule", "lazy", "Events", "definePlugin", "GraphPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "Events", "Startup", "activatesBefore", "SetupAppGraph", "SetupMetadata", "activatesAfter", "AppGraphReady", "activate", "lazy"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/plugins/plugin-graph/src/
|
|
1
|
+
{"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytes":891,"imports":[],"format":"esm"},"packages/plugins/plugin-graph/src/graph.ts":{"bytes":6242,"imports":[{"path":"@preact/signals-core","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/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/plugin-graph/src/GraphPlugin.ts":{"bytes":2810,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"packages/plugins/plugin-graph/src/graph.ts","kind":"dynamic-import","original":"./graph"}],"format":"esm"},"packages/plugins/plugin-graph/src/index.ts":{"bytes":697,"imports":[{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/GraphPlugin.ts","kind":"import-statement","original":"./GraphPlugin"},{"path":"packages/plugins/plugin-graph/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"}},"outputs":{"packages/plugins/plugin-graph/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1499},"packages/plugins/plugin-graph/dist/lib/browser/index.mjs":{"imports":[{"path":"packages/plugins/plugin-graph/dist/lib/browser/chunk-7LNMG3EB.mjs","kind":"import-statement"},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/dist/lib/browser/graph-U2AHH24Q.mjs","kind":"dynamic-import"}],"exports":["GRAPH_PLUGIN","GraphPlugin","meta"],"entryPoint":"packages/plugins/plugin-graph/src/index.ts","inputs":{"packages/plugins/plugin-graph/src/index.ts":{"bytesInOutput":33},"packages/plugins/plugin-graph/src/GraphPlugin.ts":{"bytesInOutput":417}},"bytes":698},"packages/plugins/plugin-graph/dist/lib/browser/graph-U2AHH24Q.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3429},"packages/plugins/plugin-graph/dist/lib/browser/graph-U2AHH24Q.mjs":{"imports":[{"path":"packages/plugins/plugin-graph/dist/lib/browser/chunk-7LNMG3EB.mjs","kind":"import-statement"},{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"packages/plugins/plugin-graph/src/graph.ts","inputs":{"packages/plugins/plugin-graph/src/graph.ts":{"bytesInOutput":1331}},"bytes":1516},"packages/plugins/plugin-graph/dist/lib/browser/chunk-7LNMG3EB.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":418},"packages/plugins/plugin-graph/dist/lib/browser/chunk-7LNMG3EB.mjs":{"imports":[],"exports":["GRAPH_PLUGIN","meta"],"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytesInOutput":79}},"bytes":204}}}
|
|
@@ -16,19 +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
|
|
20
|
-
__export(
|
|
19
|
+
var chunk_KHIPMH35_exports = {};
|
|
20
|
+
__export(chunk_KHIPMH35_exports, {
|
|
21
21
|
GRAPH_PLUGIN: () => GRAPH_PLUGIN,
|
|
22
|
-
|
|
22
|
+
meta: () => meta
|
|
23
23
|
});
|
|
24
|
-
module.exports = __toCommonJS(
|
|
24
|
+
module.exports = __toCommonJS(chunk_KHIPMH35_exports);
|
|
25
25
|
var GRAPH_PLUGIN = "dxos.org/plugin/graph";
|
|
26
|
-
var
|
|
26
|
+
var meta = {
|
|
27
27
|
id: GRAPH_PLUGIN
|
|
28
28
|
};
|
|
29
29
|
// Annotate the CommonJS export names for ESM import in node:
|
|
30
30
|
0 && (module.exports = {
|
|
31
31
|
GRAPH_PLUGIN,
|
|
32
|
-
|
|
32
|
+
meta
|
|
33
33
|
});
|
|
34
|
-
//# sourceMappingURL=chunk-
|
|
34
|
+
//# sourceMappingURL=chunk-KHIPMH35.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 const meta = {\n id: GRAPH_PLUGIN,\n} satisfies PluginMeta;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAMO,IAAMA,eAAe;AAErB,IAAMC,OAAO;EAClBC,IAAIF;AACN;",
|
|
6
|
+
"names": ["GRAPH_PLUGIN", "meta", "id"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var graph_AOAAITHV_exports = {};
|
|
20
|
+
__export(graph_AOAAITHV_exports, {
|
|
21
|
+
default: () => graph_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(graph_AOAAITHV_exports);
|
|
24
|
+
var import_chunk_KHIPMH35 = require("./chunk-KHIPMH35.cjs");
|
|
25
|
+
var import_signals_core = require("@preact/signals-core");
|
|
26
|
+
var import_app_framework = require("@dxos/app-framework");
|
|
27
|
+
var import_app_graph = require("@dxos/app-graph");
|
|
28
|
+
var KEY = `${import_chunk_KHIPMH35.GRAPH_PLUGIN}/app-graph`;
|
|
29
|
+
var graph_default = async (context) => {
|
|
30
|
+
const builder = import_app_graph.GraphBuilder.from(localStorage.getItem(KEY) ?? void 0);
|
|
31
|
+
const interval = setInterval(() => {
|
|
32
|
+
localStorage.setItem(KEY, builder.graph.pickle());
|
|
33
|
+
}, 5e3);
|
|
34
|
+
const unsubscribe = (0, import_signals_core.effect)(() => {
|
|
35
|
+
(0, import_signals_core.batch)(() => {
|
|
36
|
+
const next = (0, import_app_graph.flattenExtensions)(context.requestCapabilities(import_app_framework.Capabilities.AppGraphBuilder));
|
|
37
|
+
const current = (0, import_signals_core.untracked)(() => builder.extensions);
|
|
38
|
+
const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));
|
|
39
|
+
removed.forEach((extension) => builder.removeExtension(extension.id));
|
|
40
|
+
next.forEach((extension) => builder.addExtension(extension));
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
await builder.initialize();
|
|
44
|
+
await builder.graph.expand(builder.graph.root);
|
|
45
|
+
setupDevtools(builder.graph);
|
|
46
|
+
return (0, import_app_framework.contributes)(import_app_framework.Capabilities.AppGraph, {
|
|
47
|
+
graph: builder.graph,
|
|
48
|
+
explore: (options) => builder.explore(options)
|
|
49
|
+
}, () => {
|
|
50
|
+
clearInterval(interval);
|
|
51
|
+
unsubscribe();
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
var setupDevtools = (graph) => {
|
|
55
|
+
globalThis.composer ??= {};
|
|
56
|
+
globalThis.composer.graph = graph;
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=graph-AOAAITHV.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/graph.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { batch, effect, untracked } from '@preact/signals-core';\n\nimport { Capabilities, contributes, type PluginsContext } from '@dxos/app-framework';\nimport { flattenExtensions, type Graph, GraphBuilder } from '@dxos/app-graph';\n\nimport { GRAPH_PLUGIN } from './meta';\n\nconst KEY = `${GRAPH_PLUGIN}/app-graph`;\n\nexport default async (context: PluginsContext) => {\n const builder = GraphBuilder.from(localStorage.getItem(KEY) ?? undefined);\n const interval = setInterval(() => {\n localStorage.setItem(KEY, builder.graph.pickle());\n }, 5_000);\n\n const unsubscribe = effect(() => {\n batch(() => {\n const next = flattenExtensions(context.requestCapabilities(Capabilities.AppGraphBuilder));\n const current = untracked(() => builder.extensions);\n const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));\n removed.forEach((extension) => builder.removeExtension(extension.id));\n next.forEach((extension) => builder.addExtension(extension));\n });\n });\n\n await builder.initialize();\n await builder.graph.expand(builder.graph.root);\n\n setupDevtools(builder.graph);\n\n return contributes(\n Capabilities.AppGraph,\n { graph: builder.graph, explore: (options) => builder.explore(options) },\n () => {\n clearInterval(interval);\n unsubscribe();\n },\n );\n};\n\n// Expose the graph to the window for debugging.\nconst setupDevtools = (graph: Graph) => {\n (globalThis as any).composer ??= {};\n (globalThis as any).composer.graph = graph;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAIA,0BAAyC;AAEzC,2BAA+D;AAC/D,uBAA4D;AAI5D,IAAMA,MAAM,GAAGC,kCAAAA;AAEf,IAAA,gBAAe,OAAOC,YAAAA;AACpB,QAAMC,UAAUC,8BAAaC,KAAKC,aAAaC,QAAQP,GAAAA,KAAQQ,MAAAA;AAC/D,QAAMC,WAAWC,YAAY,MAAA;AAC3BJ,iBAAaK,QAAQX,KAAKG,QAAQS,MAAMC,OAAM,CAAA;EAChD,GAAG,GAAA;AAEH,QAAMC,kBAAcC,4BAAO,MAAA;AACzBC,mCAAM,MAAA;AACJ,YAAMC,WAAOC,oCAAkBhB,QAAQiB,oBAAoBC,kCAAaC,eAAe,CAAA;AACvF,YAAMC,cAAUC,+BAAU,MAAMpB,QAAQqB,UAAU;AAClD,YAAMC,UAAUH,QAAQI,OAAO,CAAC,EAAEC,GAAE,MAAO,CAACV,KAAKW,KAAK,CAAC,EAAED,IAAIE,OAAM,MAAOA,WAAWF,EAAAA,CAAAA;AACrFF,cAAQK,QAAQ,CAACC,cAAc5B,QAAQ6B,gBAAgBD,UAAUJ,EAAE,CAAA;AACnEV,WAAKa,QAAQ,CAACC,cAAc5B,QAAQ8B,aAAaF,SAAAA,CAAAA;IACnD,CAAA;EACF,CAAA;AAEA,QAAM5B,QAAQ+B,WAAU;AACxB,QAAM/B,QAAQS,MAAMuB,OAAOhC,QAAQS,MAAMwB,IAAI;AAE7CC,gBAAclC,QAAQS,KAAK;AAE3B,aAAO0B,kCACLlB,kCAAamB,UACb;IAAE3B,OAAOT,QAAQS;IAAO4B,SAAS,CAACC,YAAYtC,QAAQqC,QAAQC,OAAAA;EAAS,GACvE,MAAA;AACEC,kBAAcjC,QAAAA;AACdK,gBAAAA;EACF,CAAA;AAEJ;AAGA,IAAMuB,gBAAgB,CAACzB,UAAAA;AACpB+B,aAAmBC,aAAa,CAAC;AACjCD,aAAmBC,SAAShC,QAAQA;AACvC;",
|
|
6
|
+
"names": ["KEY", "GRAPH_PLUGIN", "context", "builder", "GraphBuilder", "from", "localStorage", "getItem", "undefined", "interval", "setInterval", "setItem", "graph", "pickle", "unsubscribe", "effect", "batch", "next", "flattenExtensions", "requestCapabilities", "Capabilities", "AppGraphBuilder", "current", "untracked", "extensions", "removed", "filter", "id", "some", "nextId", "forEach", "extension", "removeExtension", "addExtension", "initialize", "expand", "root", "setupDevtools", "contributes", "AppGraph", "explore", "options", "clearInterval", "globalThis", "composer"]
|
|
7
|
+
}
|
package/dist/lib/node/index.cjs
CHANGED
|
@@ -29,60 +29,33 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
30
|
var node_exports = {};
|
|
31
31
|
__export(node_exports, {
|
|
32
|
-
|
|
32
|
+
GRAPH_PLUGIN: () => import_chunk_KHIPMH35.GRAPH_PLUGIN,
|
|
33
33
|
GraphPlugin: () => GraphPlugin,
|
|
34
|
-
|
|
35
|
-
useGraph: () => useGraph
|
|
34
|
+
meta: () => import_chunk_KHIPMH35.meta
|
|
36
35
|
});
|
|
37
36
|
module.exports = __toCommonJS(node_exports);
|
|
38
|
-
var
|
|
39
|
-
var import_react = __toESM(require("react"));
|
|
40
|
-
var import_app_framework = require("@dxos/app-framework");
|
|
41
|
-
var import_app_graph = require("@dxos/app-graph");
|
|
42
|
-
var import_react2 = require("react");
|
|
43
|
-
var import_debug = require("@dxos/debug");
|
|
37
|
+
var import_chunk_KHIPMH35 = require("./chunk-KHIPMH35.cjs");
|
|
44
38
|
__reExport(node_exports, require("@dxos/app-graph"), module.exports);
|
|
45
|
-
var
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const composer = window.composer;
|
|
61
|
-
if (typeof composer === "object") {
|
|
62
|
-
composer.graph = builder.graph;
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
unload: async () => {
|
|
66
|
-
clearInterval(interval);
|
|
67
|
-
},
|
|
68
|
-
provides: {
|
|
69
|
-
graph: builder.graph,
|
|
70
|
-
// TODO(wittjosiah): This is janky to expose this function in this way.
|
|
71
|
-
explore: (options) => builder.explore(options),
|
|
72
|
-
context: ({ children }) => /* @__PURE__ */ import_react.default.createElement(GraphContext.Provider, {
|
|
73
|
-
value: {
|
|
74
|
-
graph: builder.graph
|
|
75
|
-
}
|
|
76
|
-
}, children)
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
var src_default = GraphPlugin;
|
|
39
|
+
var import_app_framework = require("@dxos/app-framework");
|
|
40
|
+
var GraphPlugin = () => (0, import_app_framework.definePlugin)(import_chunk_KHIPMH35.meta, [
|
|
41
|
+
(0, import_app_framework.defineModule)({
|
|
42
|
+
id: `${import_chunk_KHIPMH35.meta.id}/module/graph`,
|
|
43
|
+
activatesOn: import_app_framework.Events.Startup,
|
|
44
|
+
activatesBefore: [
|
|
45
|
+
import_app_framework.Events.SetupAppGraph,
|
|
46
|
+
import_app_framework.Events.SetupMetadata
|
|
47
|
+
],
|
|
48
|
+
activatesAfter: [
|
|
49
|
+
import_app_framework.Events.AppGraphReady
|
|
50
|
+
],
|
|
51
|
+
activate: (0, import_app_framework.lazy)(() => import("./graph-AOAAITHV.cjs"))
|
|
52
|
+
})
|
|
53
|
+
]);
|
|
81
54
|
// Annotate the CommonJS export names for ESM import in node:
|
|
82
55
|
0 && (module.exports = {
|
|
83
|
-
|
|
56
|
+
GRAPH_PLUGIN,
|
|
84
57
|
GraphPlugin,
|
|
85
|
-
|
|
58
|
+
meta,
|
|
86
59
|
...require("@dxos/app-graph")
|
|
87
60
|
});
|
|
88
61
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../../../src/index.ts", "../../../src/GraphPlugin.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nexport * from '@dxos/app-graph';\n\nexport * from './GraphPlugin';\nexport * from './meta';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { defineModule, lazy, Events, definePlugin } from '@dxos/app-framework';\n\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 = () =>\n definePlugin(meta, [\n defineModule({\n id: `${meta.id}/module/graph`,\n activatesOn: Events.Startup,\n activatesBefore: [Events.SetupAppGraph, Events.SetupMetadata],\n activatesAfter: [Events.AppGraphReady],\n activate: lazy(() => import('./graph')),\n }),\n ]);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,yBAAc;ACAd,2BAAyD;AASlD,IAAMA,cAAc,UACzBC,mCAAaC,4BAAM;MACjBC,mCAAa;IACXC,IAAI,GAAGF,2BAAKE,EAAE;IACdC,aAAaC,4BAAOC;IACpBC,iBAAiB;MAACF,4BAAOG;MAAeH,4BAAOI;;IAC/CC,gBAAgB;MAACL,4BAAOM;;IACxBC,cAAUC,2BAAK,MAAM,OAAO,sBAAA,CAAA;EAC9B,CAAA;CACD;",
|
|
6
|
+
"names": ["GraphPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "Events", "Startup", "activatesBefore", "SetupAppGraph", "SetupMetadata", "activatesAfter", "AppGraphReady", "activate", "lazy"]
|
|
7
7
|
}
|
package/dist/lib/node/meta.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/plugins/plugin-graph/src/
|
|
1
|
+
{"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytes":891,"imports":[],"format":"esm"},"packages/plugins/plugin-graph/src/graph.ts":{"bytes":6242,"imports":[{"path":"@preact/signals-core","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/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/plugin-graph/src/GraphPlugin.ts":{"bytes":2810,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"packages/plugins/plugin-graph/src/graph.ts","kind":"dynamic-import","original":"./graph"}],"format":"esm"},"packages/plugins/plugin-graph/src/index.ts":{"bytes":697,"imports":[{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/GraphPlugin.ts","kind":"import-statement","original":"./GraphPlugin"},{"path":"packages/plugins/plugin-graph/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"}},"outputs":{"packages/plugins/plugin-graph/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1499},"packages/plugins/plugin-graph/dist/lib/node/index.cjs":{"imports":[{"path":"packages/plugins/plugin-graph/dist/lib/node/chunk-KHIPMH35.cjs","kind":"import-statement"},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/dist/lib/node/graph-AOAAITHV.cjs","kind":"dynamic-import"}],"exports":["GRAPH_PLUGIN","GraphPlugin","meta"],"entryPoint":"packages/plugins/plugin-graph/src/index.ts","inputs":{"packages/plugins/plugin-graph/src/index.ts":{"bytesInOutput":33},"packages/plugins/plugin-graph/src/GraphPlugin.ts":{"bytesInOutput":417}},"bytes":698},"packages/plugins/plugin-graph/dist/lib/node/graph-AOAAITHV.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3429},"packages/plugins/plugin-graph/dist/lib/node/graph-AOAAITHV.cjs":{"imports":[{"path":"packages/plugins/plugin-graph/dist/lib/node/chunk-KHIPMH35.cjs","kind":"import-statement"},{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"packages/plugins/plugin-graph/src/graph.ts","inputs":{"packages/plugins/plugin-graph/src/graph.ts":{"bytesInOutput":1331}},"bytes":1516},"packages/plugins/plugin-graph/dist/lib/node/chunk-KHIPMH35.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":418},"packages/plugins/plugin-graph/dist/lib/node/chunk-KHIPMH35.cjs":{"imports":[],"exports":["GRAPH_PLUGIN","meta"],"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytesInOutput":79}},"bytes":204}}}
|
|
@@ -2,12 +2,12 @@ import { createRequire } from 'node:module';const require = createRequire(import
|
|
|
2
2
|
|
|
3
3
|
// packages/plugins/plugin-graph/src/meta.ts
|
|
4
4
|
var GRAPH_PLUGIN = "dxos.org/plugin/graph";
|
|
5
|
-
var
|
|
5
|
+
var meta = {
|
|
6
6
|
id: GRAPH_PLUGIN
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export {
|
|
10
10
|
GRAPH_PLUGIN,
|
|
11
|
-
|
|
11
|
+
meta
|
|
12
12
|
};
|
|
13
|
-
//# sourceMappingURL=chunk-
|
|
13
|
+
//# sourceMappingURL=chunk-IHM26RSC.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 const meta = {\n id: GRAPH_PLUGIN,\n} satisfies PluginMeta;\n"],
|
|
5
|
+
"mappings": ";;;AAMO,IAAMA,eAAe;AAErB,IAAMC,OAAO;EAClBC,IAAIF;AACN;",
|
|
6
|
+
"names": ["GRAPH_PLUGIN", "meta", "id"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
GRAPH_PLUGIN
|
|
4
|
+
} from "./chunk-IHM26RSC.mjs";
|
|
5
|
+
|
|
6
|
+
// packages/plugins/plugin-graph/src/graph.ts
|
|
7
|
+
import { batch, effect, untracked } from "@preact/signals-core";
|
|
8
|
+
import { Capabilities, contributes } from "@dxos/app-framework";
|
|
9
|
+
import { flattenExtensions, GraphBuilder } from "@dxos/app-graph";
|
|
10
|
+
var KEY = `${GRAPH_PLUGIN}/app-graph`;
|
|
11
|
+
var graph_default = async (context) => {
|
|
12
|
+
const builder = GraphBuilder.from(localStorage.getItem(KEY) ?? void 0);
|
|
13
|
+
const interval = setInterval(() => {
|
|
14
|
+
localStorage.setItem(KEY, builder.graph.pickle());
|
|
15
|
+
}, 5e3);
|
|
16
|
+
const unsubscribe = effect(() => {
|
|
17
|
+
batch(() => {
|
|
18
|
+
const next = flattenExtensions(context.requestCapabilities(Capabilities.AppGraphBuilder));
|
|
19
|
+
const current = untracked(() => builder.extensions);
|
|
20
|
+
const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));
|
|
21
|
+
removed.forEach((extension) => builder.removeExtension(extension.id));
|
|
22
|
+
next.forEach((extension) => builder.addExtension(extension));
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
await builder.initialize();
|
|
26
|
+
await builder.graph.expand(builder.graph.root);
|
|
27
|
+
setupDevtools(builder.graph);
|
|
28
|
+
return contributes(Capabilities.AppGraph, {
|
|
29
|
+
graph: builder.graph,
|
|
30
|
+
explore: (options) => builder.explore(options)
|
|
31
|
+
}, () => {
|
|
32
|
+
clearInterval(interval);
|
|
33
|
+
unsubscribe();
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
var setupDevtools = (graph) => {
|
|
37
|
+
globalThis.composer ??= {};
|
|
38
|
+
globalThis.composer.graph = graph;
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
graph_default as default
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=graph-VC422POI.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/graph.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { batch, effect, untracked } from '@preact/signals-core';\n\nimport { Capabilities, contributes, type PluginsContext } from '@dxos/app-framework';\nimport { flattenExtensions, type Graph, GraphBuilder } from '@dxos/app-graph';\n\nimport { GRAPH_PLUGIN } from './meta';\n\nconst KEY = `${GRAPH_PLUGIN}/app-graph`;\n\nexport default async (context: PluginsContext) => {\n const builder = GraphBuilder.from(localStorage.getItem(KEY) ?? undefined);\n const interval = setInterval(() => {\n localStorage.setItem(KEY, builder.graph.pickle());\n }, 5_000);\n\n const unsubscribe = effect(() => {\n batch(() => {\n const next = flattenExtensions(context.requestCapabilities(Capabilities.AppGraphBuilder));\n const current = untracked(() => builder.extensions);\n const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));\n removed.forEach((extension) => builder.removeExtension(extension.id));\n next.forEach((extension) => builder.addExtension(extension));\n });\n });\n\n await builder.initialize();\n await builder.graph.expand(builder.graph.root);\n\n setupDevtools(builder.graph);\n\n return contributes(\n Capabilities.AppGraph,\n { graph: builder.graph, explore: (options) => builder.explore(options) },\n () => {\n clearInterval(interval);\n unsubscribe();\n },\n );\n};\n\n// Expose the graph to the window for debugging.\nconst setupDevtools = (graph: Graph) => {\n (globalThis as any).composer ??= {};\n (globalThis as any).composer.graph = graph;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;AAIA,SAASA,OAAOC,QAAQC,iBAAiB;AAEzC,SAASC,cAAcC,mBAAwC;AAC/D,SAASC,mBAA+BC,oBAAoB;AAI5D,IAAMC,MAAM,GAAGC,YAAAA;AAEf,IAAA,gBAAe,OAAOC,YAAAA;AACpB,QAAMC,UAAUC,aAAaC,KAAKC,aAAaC,QAAQP,GAAAA,KAAQQ,MAAAA;AAC/D,QAAMC,WAAWC,YAAY,MAAA;AAC3BJ,iBAAaK,QAAQX,KAAKG,QAAQS,MAAMC,OAAM,CAAA;EAChD,GAAG,GAAA;AAEH,QAAMC,cAAcC,OAAO,MAAA;AACzBC,UAAM,MAAA;AACJ,YAAMC,OAAOC,kBAAkBhB,QAAQiB,oBAAoBC,aAAaC,eAAe,CAAA;AACvF,YAAMC,UAAUC,UAAU,MAAMpB,QAAQqB,UAAU;AAClD,YAAMC,UAAUH,QAAQI,OAAO,CAAC,EAAEC,GAAE,MAAO,CAACV,KAAKW,KAAK,CAAC,EAAED,IAAIE,OAAM,MAAOA,WAAWF,EAAAA,CAAAA;AACrFF,cAAQK,QAAQ,CAACC,cAAc5B,QAAQ6B,gBAAgBD,UAAUJ,EAAE,CAAA;AACnEV,WAAKa,QAAQ,CAACC,cAAc5B,QAAQ8B,aAAaF,SAAAA,CAAAA;IACnD,CAAA;EACF,CAAA;AAEA,QAAM5B,QAAQ+B,WAAU;AACxB,QAAM/B,QAAQS,MAAMuB,OAAOhC,QAAQS,MAAMwB,IAAI;AAE7CC,gBAAclC,QAAQS,KAAK;AAE3B,SAAO0B,YACLlB,aAAamB,UACb;IAAE3B,OAAOT,QAAQS;IAAO4B,SAAS,CAACC,YAAYtC,QAAQqC,QAAQC,OAAAA;EAAS,GACvE,MAAA;AACEC,kBAAcjC,QAAAA;AACdK,gBAAAA;EACF,CAAA;AAEJ;AAGA,IAAMuB,gBAAgB,CAACzB,UAAAA;AACpB+B,aAAmBC,aAAa,CAAC;AACjCD,aAAmBC,SAAShC,QAAQA;AACvC;",
|
|
6
|
+
"names": ["batch", "effect", "untracked", "Capabilities", "contributes", "flattenExtensions", "GraphBuilder", "KEY", "GRAPH_PLUGIN", "context", "builder", "GraphBuilder", "from", "localStorage", "getItem", "undefined", "interval", "setInterval", "setItem", "graph", "pickle", "unsubscribe", "effect", "batch", "next", "flattenExtensions", "requestCapabilities", "Capabilities", "AppGraphBuilder", "current", "untracked", "extensions", "removed", "filter", "id", "some", "nextId", "forEach", "extension", "removeExtension", "addExtension", "initialize", "expand", "root", "setupDevtools", "contributes", "AppGraph", "explore", "options", "clearInterval", "globalThis", "composer"]
|
|
7
|
+
}
|
|
@@ -1,62 +1,31 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
GRAPH_PLUGIN,
|
|
4
|
-
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
|
|
7
|
-
// packages/plugins/plugin-graph/src/GraphPlugin.tsx
|
|
8
|
-
import React from "react";
|
|
9
|
-
import { filterPlugins, parseGraphBuilderPlugin } from "@dxos/app-framework";
|
|
10
|
-
import { GraphBuilder } from "@dxos/app-graph";
|
|
11
|
-
|
|
12
|
-
// packages/plugins/plugin-graph/src/GraphContext.ts
|
|
13
|
-
import { createContext, useContext } from "react";
|
|
14
|
-
import { raise } from "@dxos/debug";
|
|
15
|
-
var GraphContext = createContext(null);
|
|
16
|
-
var useGraph = () => useContext(GraphContext) ?? raise(new Error("Missing GraphContext"));
|
|
17
|
-
|
|
18
|
-
// packages/plugins/plugin-graph/src/GraphPlugin.tsx
|
|
19
|
-
var KEY = `${GRAPH_PLUGIN}/app-graph`;
|
|
20
|
-
var GraphPlugin = () => {
|
|
21
|
-
const builder = GraphBuilder.from(localStorage.getItem(KEY) ?? void 0);
|
|
22
|
-
let interval;
|
|
23
|
-
return {
|
|
24
|
-
meta: meta_default,
|
|
25
|
-
ready: async ({ plugins }) => {
|
|
26
|
-
interval = setInterval(() => {
|
|
27
|
-
localStorage.setItem(KEY, builder.graph.pickle());
|
|
28
|
-
}, 5e3);
|
|
29
|
-
filterPlugins(plugins, parseGraphBuilderPlugin).forEach((plugin) => builder.addExtension(plugin.provides.graph.builder(plugins)));
|
|
30
|
-
await builder.initialize();
|
|
31
|
-
await builder.graph.expand(builder.graph.root);
|
|
32
|
-
const composer = window.composer;
|
|
33
|
-
if (typeof composer === "object") {
|
|
34
|
-
composer.graph = builder.graph;
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
unload: async () => {
|
|
38
|
-
clearInterval(interval);
|
|
39
|
-
},
|
|
40
|
-
provides: {
|
|
41
|
-
graph: builder.graph,
|
|
42
|
-
// TODO(wittjosiah): This is janky to expose this function in this way.
|
|
43
|
-
explore: (options) => builder.explore(options),
|
|
44
|
-
context: ({ children }) => /* @__PURE__ */ React.createElement(GraphContext.Provider, {
|
|
45
|
-
value: {
|
|
46
|
-
graph: builder.graph
|
|
47
|
-
}
|
|
48
|
-
}, children)
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
};
|
|
4
|
+
meta
|
|
5
|
+
} from "./chunk-IHM26RSC.mjs";
|
|
52
6
|
|
|
53
7
|
// packages/plugins/plugin-graph/src/index.ts
|
|
54
8
|
export * from "@dxos/app-graph";
|
|
55
|
-
|
|
9
|
+
|
|
10
|
+
// packages/plugins/plugin-graph/src/GraphPlugin.ts
|
|
11
|
+
import { defineModule, lazy, Events, definePlugin } from "@dxos/app-framework";
|
|
12
|
+
var GraphPlugin = () => definePlugin(meta, [
|
|
13
|
+
defineModule({
|
|
14
|
+
id: `${meta.id}/module/graph`,
|
|
15
|
+
activatesOn: Events.Startup,
|
|
16
|
+
activatesBefore: [
|
|
17
|
+
Events.SetupAppGraph,
|
|
18
|
+
Events.SetupMetadata
|
|
19
|
+
],
|
|
20
|
+
activatesAfter: [
|
|
21
|
+
Events.AppGraphReady
|
|
22
|
+
],
|
|
23
|
+
activate: lazy(() => import("./graph-VC422POI.mjs"))
|
|
24
|
+
})
|
|
25
|
+
]);
|
|
56
26
|
export {
|
|
57
|
-
|
|
27
|
+
GRAPH_PLUGIN,
|
|
58
28
|
GraphPlugin,
|
|
59
|
-
|
|
60
|
-
useGraph
|
|
29
|
+
meta
|
|
61
30
|
};
|
|
62
31
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\
|
|
5
|
-
"mappings": ";;;;;;;AAIA,
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../../../src/index.ts", "../../../src/GraphPlugin.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nexport * from '@dxos/app-graph';\n\nexport * from './GraphPlugin';\nexport * from './meta';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { defineModule, lazy, Events, definePlugin } from '@dxos/app-framework';\n\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 = () =>\n definePlugin(meta, [\n defineModule({\n id: `${meta.id}/module/graph`,\n activatesOn: Events.Startup,\n activatesBefore: [Events.SetupAppGraph, Events.SetupMetadata],\n activatesAfter: [Events.AppGraphReady],\n activate: lazy(() => import('./graph')),\n }),\n ]);\n"],
|
|
5
|
+
"mappings": ";;;;;;;AAIA,cAAc;;;ACAd,SAASA,cAAcC,MAAMC,QAAQC,oBAAoB;AASlD,IAAMC,cAAc,MACzBC,aAAaC,MAAM;EACjBC,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOC;IACpBC,iBAAiB;MAACF,OAAOG;MAAeH,OAAOI;;IAC/CC,gBAAgB;MAACL,OAAOM;;IACxBC,UAAUC,KAAK,MAAM,OAAO,sBAAA,CAAA;EAC9B,CAAA;CACD;",
|
|
6
|
+
"names": ["defineModule", "lazy", "Events", "definePlugin", "GraphPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "Events", "Startup", "activatesBefore", "SetupAppGraph", "SetupMetadata", "activatesAfter", "AppGraphReady", "activate", "lazy"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/plugins/plugin-graph/src/
|
|
1
|
+
{"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytes":891,"imports":[],"format":"esm"},"packages/plugins/plugin-graph/src/graph.ts":{"bytes":6242,"imports":[{"path":"@preact/signals-core","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/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/plugin-graph/src/GraphPlugin.ts":{"bytes":2810,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"packages/plugins/plugin-graph/src/graph.ts","kind":"dynamic-import","original":"./graph"}],"format":"esm"},"packages/plugins/plugin-graph/src/index.ts":{"bytes":697,"imports":[{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/src/GraphPlugin.ts","kind":"import-statement","original":"./GraphPlugin"},{"path":"packages/plugins/plugin-graph/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"}},"outputs":{"packages/plugins/plugin-graph/dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1500},"packages/plugins/plugin-graph/dist/lib/node-esm/index.mjs":{"imports":[{"path":"packages/plugins/plugin-graph/dist/lib/node-esm/chunk-IHM26RSC.mjs","kind":"import-statement"},{"path":"@dxos/app-graph","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-graph/dist/lib/node-esm/graph-VC422POI.mjs","kind":"dynamic-import"}],"exports":["GRAPH_PLUGIN","GraphPlugin","meta"],"entryPoint":"packages/plugins/plugin-graph/src/index.ts","inputs":{"packages/plugins/plugin-graph/src/index.ts":{"bytesInOutput":33},"packages/plugins/plugin-graph/src/GraphPlugin.ts":{"bytesInOutput":417}},"bytes":790},"packages/plugins/plugin-graph/dist/lib/node-esm/graph-VC422POI.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3430},"packages/plugins/plugin-graph/dist/lib/node-esm/graph-VC422POI.mjs":{"imports":[{"path":"packages/plugins/plugin-graph/dist/lib/node-esm/chunk-IHM26RSC.mjs","kind":"import-statement"},{"path":"@preact/signals-core","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"packages/plugins/plugin-graph/src/graph.ts","inputs":{"packages/plugins/plugin-graph/src/graph.ts":{"bytesInOutput":1331}},"bytes":1608},"packages/plugins/plugin-graph/dist/lib/node-esm/chunk-IHM26RSC.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":420},"packages/plugins/plugin-graph/dist/lib/node-esm/chunk-IHM26RSC.mjs":{"imports":[],"exports":["GRAPH_PLUGIN","meta"],"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytesInOutput":79}},"bytes":297}}}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { type GraphProvides, type PluginDefinition } from '@dxos/app-framework';
|
|
2
1
|
/**
|
|
3
2
|
* Manages the state of the graph for the application.
|
|
4
3
|
* Enables other plugins to register node builders to add nodes to the graph.
|
|
5
4
|
* This includes actions and annotation each other's nodes.
|
|
6
5
|
*/
|
|
7
|
-
export declare const GraphPlugin: () =>
|
|
6
|
+
export declare const GraphPlugin: () => import("@dxos/app-framework").Plugin;
|
|
8
7
|
//# sourceMappingURL=GraphPlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphPlugin.d.ts","sourceRoot":"","sources":["../../../src/GraphPlugin.
|
|
1
|
+
{"version":3,"file":"GraphPlugin.d.ts","sourceRoot":"","sources":["../../../src/GraphPlugin.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,eAAO,MAAM,WAAW,4CASpB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type PluginsContext } from '@dxos/app-framework';
|
|
2
|
+
import { type Graph } from '@dxos/app-graph';
|
|
3
|
+
declare const _default: (context: PluginsContext) => Promise<import("@dxos/app-framework").Capability<{
|
|
4
|
+
graph: Graph;
|
|
5
|
+
explore: (options: import("@dxos/app-graph").GraphBuilderTraverseOptions) => Promise<void>;
|
|
6
|
+
}>>;
|
|
7
|
+
export default _default;
|
|
8
|
+
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../../src/graph.ts"],"names":[],"mappings":"AAMA,OAAO,EAA6B,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAqB,KAAK,KAAK,EAAgB,MAAM,iBAAiB,CAAC;kCAM/C,cAAc;;;;AAA7C,wBA6BE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,iBAAiB,CAAC;AAEhC,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC"}
|
package/dist/types/src/meta.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/meta.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,YAAY,0BAA0B,CAAC
|
|
1
|
+
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/meta.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,YAAY,0BAA0B,CAAC;AAEpD,eAAO,MAAM,IAAI;;CAEK,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"5.7.
|
|
1
|
+
{"version":"5.7.3"}
|
package/package.json
CHANGED
|
@@ -1,31 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-graph",
|
|
3
|
-
"version": "0.7.5-main.
|
|
3
|
+
"version": "0.7.5-main.b19bfc8",
|
|
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",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"author": "DXOS.org",
|
|
9
9
|
"sideEffects": true,
|
|
10
|
+
"type": "module",
|
|
10
11
|
"exports": {
|
|
11
12
|
".": {
|
|
12
13
|
"types": "./dist/types/src/index.d.ts",
|
|
13
14
|
"browser": "./dist/lib/browser/index.mjs",
|
|
14
15
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
15
|
-
},
|
|
16
|
-
"./meta": {
|
|
17
|
-
"types": "./dist/types/src/meta.d.ts",
|
|
18
|
-
"browser": "./dist/lib/browser/meta.mjs",
|
|
19
|
-
"node": "./dist/lib/node-esm/meta.mjs"
|
|
20
16
|
}
|
|
21
17
|
},
|
|
22
18
|
"types": "dist/types/src/index.d.ts",
|
|
23
19
|
"typesVersions": {
|
|
24
|
-
"*": {
|
|
25
|
-
"meta": [
|
|
26
|
-
"dist/types/src/meta.d.ts"
|
|
27
|
-
]
|
|
28
|
-
}
|
|
20
|
+
"*": {}
|
|
29
21
|
},
|
|
30
22
|
"files": [
|
|
31
23
|
"dist",
|
|
@@ -33,10 +25,10 @@
|
|
|
33
25
|
],
|
|
34
26
|
"dependencies": {
|
|
35
27
|
"@preact/signals-core": "^1.6.0",
|
|
36
|
-
"@dxos/app-
|
|
37
|
-
"@dxos/app-
|
|
38
|
-
"@dxos/async": "0.7.5-main.
|
|
39
|
-
"@dxos/debug": "0.7.5-main.
|
|
28
|
+
"@dxos/app-graph": "0.7.5-main.b19bfc8",
|
|
29
|
+
"@dxos/app-framework": "0.7.5-main.b19bfc8",
|
|
30
|
+
"@dxos/async": "0.7.5-main.b19bfc8",
|
|
31
|
+
"@dxos/debug": "0.7.5-main.b19bfc8"
|
|
40
32
|
},
|
|
41
33
|
"devDependencies": {
|
|
42
34
|
"@types/react": "~18.2.0",
|
|
@@ -44,8 +36,8 @@
|
|
|
44
36
|
"react": "~18.2.0",
|
|
45
37
|
"react-dom": "~18.2.0",
|
|
46
38
|
"vite": "5.4.7",
|
|
47
|
-
"@dxos/react-client": "0.7.5-main.
|
|
48
|
-
"@dxos/storybook-utils": "0.7.5-main.
|
|
39
|
+
"@dxos/react-client": "0.7.5-main.b19bfc8",
|
|
40
|
+
"@dxos/storybook-utils": "0.7.5-main.b19bfc8"
|
|
49
41
|
},
|
|
50
42
|
"peerDependencies": {
|
|
51
43
|
"react": "~18.2.0",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { defineModule, lazy, Events, definePlugin } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
import { meta } from './meta';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Manages the state of the graph for the application.
|
|
11
|
+
* Enables other plugins to register node builders to add nodes to the graph.
|
|
12
|
+
* This includes actions and annotation each other's nodes.
|
|
13
|
+
*/
|
|
14
|
+
export const GraphPlugin = () =>
|
|
15
|
+
definePlugin(meta, [
|
|
16
|
+
defineModule({
|
|
17
|
+
id: `${meta.id}/module/graph`,
|
|
18
|
+
activatesOn: Events.Startup,
|
|
19
|
+
activatesBefore: [Events.SetupAppGraph, Events.SetupMetadata],
|
|
20
|
+
activatesAfter: [Events.AppGraphReady],
|
|
21
|
+
activate: lazy(() => import('./graph')),
|
|
22
|
+
}),
|
|
23
|
+
]);
|
package/src/graph.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { batch, effect, untracked } from '@preact/signals-core';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, contributes, type PluginsContext } from '@dxos/app-framework';
|
|
8
|
+
import { flattenExtensions, type Graph, GraphBuilder } from '@dxos/app-graph';
|
|
9
|
+
|
|
10
|
+
import { GRAPH_PLUGIN } from './meta';
|
|
11
|
+
|
|
12
|
+
const KEY = `${GRAPH_PLUGIN}/app-graph`;
|
|
13
|
+
|
|
14
|
+
export default async (context: PluginsContext) => {
|
|
15
|
+
const builder = GraphBuilder.from(localStorage.getItem(KEY) ?? undefined);
|
|
16
|
+
const interval = setInterval(() => {
|
|
17
|
+
localStorage.setItem(KEY, builder.graph.pickle());
|
|
18
|
+
}, 5_000);
|
|
19
|
+
|
|
20
|
+
const unsubscribe = effect(() => {
|
|
21
|
+
batch(() => {
|
|
22
|
+
const next = flattenExtensions(context.requestCapabilities(Capabilities.AppGraphBuilder));
|
|
23
|
+
const current = untracked(() => builder.extensions);
|
|
24
|
+
const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));
|
|
25
|
+
removed.forEach((extension) => builder.removeExtension(extension.id));
|
|
26
|
+
next.forEach((extension) => builder.addExtension(extension));
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
await builder.initialize();
|
|
31
|
+
await builder.graph.expand(builder.graph.root);
|
|
32
|
+
|
|
33
|
+
setupDevtools(builder.graph);
|
|
34
|
+
|
|
35
|
+
return contributes(
|
|
36
|
+
Capabilities.AppGraph,
|
|
37
|
+
{ graph: builder.graph, explore: (options) => builder.explore(options) },
|
|
38
|
+
() => {
|
|
39
|
+
clearInterval(interval);
|
|
40
|
+
unsubscribe();
|
|
41
|
+
},
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// Expose the graph to the window for debugging.
|
|
46
|
+
const setupDevtools = (graph: Graph) => {
|
|
47
|
+
(globalThis as any).composer ??= {};
|
|
48
|
+
(globalThis as any).composer.graph = graph;
|
|
49
|
+
};
|
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -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 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 +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 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
|
-
}
|
package/dist/lib/node/meta.cjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var meta_exports = {};
|
|
20
|
-
__export(meta_exports, {
|
|
21
|
-
GRAPH_PLUGIN: () => import_chunk_PIWXSWR4.GRAPH_PLUGIN,
|
|
22
|
-
default: () => import_chunk_PIWXSWR4.meta_default
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(meta_exports);
|
|
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
|
-
});
|
|
30
|
-
//# sourceMappingURL=meta.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["meta.cjs"],
|
|
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
|
-
"names": []
|
|
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 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,10 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
GRAPH_PLUGIN,
|
|
4
|
-
meta_default
|
|
5
|
-
} from "./chunk-H3EEX7DI.mjs";
|
|
6
|
-
export {
|
|
7
|
-
GRAPH_PLUGIN,
|
|
8
|
-
meta_default as default
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=meta.mjs.map
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type Context } from 'react';
|
|
2
|
-
import { type Graph } from '@dxos/app-graph';
|
|
3
|
-
export type GraphContext = {
|
|
4
|
-
graph: Graph;
|
|
5
|
-
};
|
|
6
|
-
export declare const GraphContext: Context<GraphContext | null>;
|
|
7
|
-
export declare const useGraph: () => GraphContext;
|
|
8
|
-
//# sourceMappingURL=GraphContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GraphContext.d.ts","sourceRoot":"","sources":["../../../src/GraphContext.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,OAAO,EAA6B,MAAM,OAAO,CAAC;AAEhE,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAG7C,MAAM,MAAM,YAAY,GAAG;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAE5C,eAAO,MAAM,YAAY,EAAE,OAAO,CAAC,YAAY,GAAG,IAAI,CAA4C,CAAC;AAEnG,eAAO,MAAM,QAAQ,QAAO,YAAoF,CAAC"}
|
package/src/GraphContext.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
// TODO(wittjosiah): State can be a GraphNode.
|
|
6
|
-
import { type Context, createContext, useContext } from 'react';
|
|
7
|
-
|
|
8
|
-
import { type Graph } from '@dxos/app-graph';
|
|
9
|
-
import { raise } from '@dxos/debug';
|
|
10
|
-
|
|
11
|
-
export type GraphContext = { graph: Graph };
|
|
12
|
-
|
|
13
|
-
export const GraphContext: Context<GraphContext | null> = createContext<GraphContext | null>(null);
|
|
14
|
-
|
|
15
|
-
export const useGraph = (): GraphContext => useContext(GraphContext) ?? raise(new Error('Missing GraphContext'));
|
package/src/GraphPlugin.tsx
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
|
|
7
|
-
import { filterPlugins, type GraphProvides, type PluginDefinition, parseGraphBuilderPlugin } from '@dxos/app-framework';
|
|
8
|
-
import { GraphBuilder } from '@dxos/app-graph';
|
|
9
|
-
|
|
10
|
-
import { GraphContext } from './GraphContext';
|
|
11
|
-
import meta, { GRAPH_PLUGIN } from './meta';
|
|
12
|
-
|
|
13
|
-
const KEY = `${GRAPH_PLUGIN}/app-graph`;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Manages the state of the graph for the application.
|
|
17
|
-
* Enables other plugins to register node builders to add nodes to the graph.
|
|
18
|
-
* This includes actions and annotation each other's nodes.
|
|
19
|
-
*/
|
|
20
|
-
export const GraphPlugin = (): PluginDefinition<GraphProvides> => {
|
|
21
|
-
const builder = GraphBuilder.from(localStorage.getItem(KEY) ?? undefined);
|
|
22
|
-
let interval: NodeJS.Timeout | undefined;
|
|
23
|
-
|
|
24
|
-
return {
|
|
25
|
-
meta,
|
|
26
|
-
ready: async ({ plugins }) => {
|
|
27
|
-
interval = setInterval(() => {
|
|
28
|
-
localStorage.setItem(KEY, builder.graph.pickle());
|
|
29
|
-
}, 5_000);
|
|
30
|
-
|
|
31
|
-
filterPlugins(plugins, parseGraphBuilderPlugin).forEach((plugin) =>
|
|
32
|
-
builder.addExtension(plugin.provides.graph.builder(plugins)),
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
await builder.initialize();
|
|
36
|
-
await builder.graph.expand(builder.graph.root);
|
|
37
|
-
|
|
38
|
-
// Expose the graph to the window for debugging.
|
|
39
|
-
const composer = (window as any).composer;
|
|
40
|
-
if (typeof composer === 'object') {
|
|
41
|
-
composer.graph = builder.graph;
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
unload: async () => {
|
|
45
|
-
clearInterval(interval);
|
|
46
|
-
},
|
|
47
|
-
provides: {
|
|
48
|
-
graph: builder.graph,
|
|
49
|
-
// TODO(wittjosiah): This is janky to expose this function in this way.
|
|
50
|
-
explore: (options) => builder.explore(options),
|
|
51
|
-
context: ({ children }) => (
|
|
52
|
-
<GraphContext.Provider value={{ graph: builder.graph }}>{children}</GraphContext.Provider>
|
|
53
|
-
),
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
};
|