@dxos/plugin-graph 0.8.3 → 0.8.4-main.28f8d3d

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-graph",
3
- "version": "0.8.3",
3
+ "version": "0.8.4-main.28f8d3d",
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",
@@ -10,6 +10,7 @@
10
10
  "type": "module",
11
11
  "exports": {
12
12
  ".": {
13
+ "source": "./src/index.ts",
13
14
  "types": "./dist/types/src/index.d.ts",
14
15
  "browser": "./dist/lib/browser/index.mjs",
15
16
  "node": "./dist/lib/node-esm/index.mjs"
@@ -25,26 +26,26 @@
25
26
  ],
26
27
  "dependencies": {
27
28
  "@preact-signals/safe-react": "^0.9.0",
28
- "@dxos/app-framework": "0.8.3",
29
- "@dxos/app-graph": "0.8.3",
30
- "@dxos/async": "0.8.3",
31
- "@dxos/debug": "0.8.3"
29
+ "@dxos/app-framework": "0.8.4-main.28f8d3d",
30
+ "@dxos/app-graph": "0.8.4-main.28f8d3d",
31
+ "@dxos/async": "0.8.4-main.28f8d3d",
32
+ "@dxos/debug": "0.8.4-main.28f8d3d"
32
33
  },
33
34
  "devDependencies": {
34
- "@effect-rx/rx-react": "^0.34.1",
35
- "@effect/platform": "0.80.12",
35
+ "@effect-rx/rx-react": "0.38.0",
36
+ "@effect/platform": "0.90.2",
36
37
  "@types/react": "~18.2.0",
37
38
  "@types/react-dom": "~18.2.0",
38
- "effect": "^3.13.3",
39
+ "effect": "3.17.7",
39
40
  "react": "~18.2.0",
40
41
  "react-dom": "~18.2.0",
41
42
  "vite": "5.4.7",
42
- "@dxos/storybook-utils": "0.8.3",
43
- "@dxos/react-client": "0.8.3"
43
+ "@dxos/react-client": "0.8.4-main.28f8d3d",
44
+ "@dxos/storybook-utils": "0.8.4-main.28f8d3d"
44
45
  },
45
46
  "peerDependencies": {
46
47
  "@effect-rx/rx-react": "^0.34.1",
47
- "@effect/platform": "0.80.12",
48
+ "@effect/platform": "^0.80.12",
48
49
  "effect": "^3.13.3",
49
50
  "react": "~18.2.0",
50
51
  "react-dom": "~18.2.0"
@@ -2,7 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { defineModule, lazy, Events, definePlugin } from '@dxos/app-framework';
5
+ import { Events, defineModule, definePlugin, lazy } from '@dxos/app-framework';
6
6
 
7
7
  import { meta } from './meta';
8
8
 
package/src/graph.ts CHANGED
@@ -4,8 +4,8 @@
4
4
 
5
5
  import { Record } from 'effect';
6
6
 
7
- import { Capabilities, contributes, type PluginContext } from '@dxos/app-framework';
8
- import { flattenExtensions, GraphBuilder, type ExpandableGraph, ROOT_ID } from '@dxos/app-graph';
7
+ import { Capabilities, type PluginContext, contributes } from '@dxos/app-framework';
8
+ import { type ExpandableGraph, GraphBuilder, ROOT_ID, flattenExtensions } from '@dxos/app-graph';
9
9
 
10
10
  // TODO(wittjosiah): Remove or restore graph caching.
11
11
  // import { GRAPH_PLUGIN } from './meta';
@@ -5,7 +5,7 @@
5
5
  import { useRxValue } from '@effect-rx/rx-react';
6
6
  import { Option } from 'effect';
7
7
 
8
- import { type ReadableGraph, type Node, type Relation } from '@dxos/app-graph';
8
+ import { type Node, type ReadableGraph, type Relation } from '@dxos/app-graph';
9
9
 
10
10
  /**
11
11
  * React hook to get a node from the graph.
@@ -1,56 +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 graph_Q4KLVTNI_exports = {};
20
- __export(graph_Q4KLVTNI_exports, {
21
- default: () => graph_default
22
- });
23
- module.exports = __toCommonJS(graph_Q4KLVTNI_exports);
24
- var import_effect = require("effect");
25
- var import_app_framework = require("@dxos/app-framework");
26
- var import_app_graph = require("@dxos/app-graph");
27
- var graph_default = async (context) => {
28
- const registry = context.getCapability(import_app_framework.Capabilities.RxRegistry);
29
- const builder = import_app_graph.GraphBuilder.from(
30
- /* localStorage.getItem(KEY) ?? */
31
- void 0,
32
- registry
33
- );
34
- const unsubscribe = registry.subscribe(context.capabilities(import_app_framework.Capabilities.AppGraphBuilder), (extensions) => {
35
- const next = (0, import_app_graph.flattenExtensions)(extensions);
36
- const current = import_effect.Record.values(registry.get(builder.extensions));
37
- const removed = current.filter(({ id }) => !next.some(({ id: nextId }) => nextId === id));
38
- removed.forEach((extension) => builder.removeExtension(extension.id));
39
- next.forEach((extension) => builder.addExtension(extension));
40
- }, {
41
- immediate: true
42
- });
43
- void builder.graph.expand(import_app_graph.ROOT_ID);
44
- setupDevtools(builder.graph);
45
- return (0, import_app_framework.contributes)(import_app_framework.Capabilities.AppGraph, {
46
- graph: builder.graph,
47
- explore: builder.explore
48
- }, () => {
49
- unsubscribe();
50
- });
51
- };
52
- var setupDevtools = (graph) => {
53
- globalThis.composer ??= {};
54
- globalThis.composer.graph = graph;
55
- };
56
- //# sourceMappingURL=graph-Q4KLVTNI.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/graph.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Record } from 'effect';\n\nimport { Capabilities, contributes, type PluginContext } from '@dxos/app-framework';\nimport { flattenExtensions, GraphBuilder, type ExpandableGraph, ROOT_ID } from '@dxos/app-graph';\n\n// TODO(wittjosiah): Remove or restore graph caching.\n// import { GRAPH_PLUGIN } from './meta';\n\n// const KEY = `${GRAPH_PLUGIN}/app-graph`;\n\nexport default async (context: PluginContext) => {\n const registry = context.getCapability(Capabilities.RxRegistry);\n const builder = GraphBuilder.from(/* localStorage.getItem(KEY) ?? */ undefined, registry);\n // const interval = setInterval(() => {\n // localStorage.setItem(KEY, builder.graph.pickle());\n // }, 5_000);\n\n const unsubscribe = registry.subscribe(\n context.capabilities(Capabilities.AppGraphBuilder),\n (extensions) => {\n const next = flattenExtensions(extensions);\n const current = Record.values(registry.get(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 { immediate: true },\n );\n\n // await builder.initialize();\n void builder.graph.expand(ROOT_ID);\n\n setupDevtools(builder.graph);\n\n return contributes(Capabilities.AppGraph, { graph: builder.graph, explore: builder.explore }, () => {\n // clearInterval(interval);\n unsubscribe();\n });\n};\n\n// Expose the graph to the window for debugging.\nconst setupDevtools = (graph: ExpandableGraph) => {\n (globalThis as any).composer ??= {};\n (globalThis as any).composer.graph = graph;\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAIA,oBAAuB;AAEvB,2BAA8D;AAC9D,uBAA+E;AAO/E,IAAA,gBAAe,OAAOA,YAAAA;AACpB,QAAMC,WAAWD,QAAQE,cAAcC,kCAAaC,UAAU;AAC9D,QAAMC,UAAUC,8BAAaC;;IAAwCC;IAAWP;EAAAA;AAKhF,QAAMQ,cAAcR,SAASS,UAC3BV,QAAQW,aAAaR,kCAAaS,eAAe,GACjD,CAACC,eAAAA;AACC,UAAMC,WAAOC,oCAAkBF,UAAAA;AAC/B,UAAMG,UAAUC,qBAAOC,OAAOjB,SAASkB,IAAId,QAAQQ,UAAU,CAAA;AAC7D,UAAMO,UAAUJ,QAAQK,OAAO,CAAC,EAAEC,GAAE,MAAO,CAACR,KAAKS,KAAK,CAAC,EAAED,IAAIE,OAAM,MAAOA,WAAWF,EAAAA,CAAAA;AACrFF,YAAQK,QAAQ,CAACC,cAAcrB,QAAQsB,gBAAgBD,UAAUJ,EAAE,CAAA;AACnER,SAAKW,QAAQ,CAACC,cAAcrB,QAAQuB,aAAaF,SAAAA,CAAAA;EACnD,GACA;IAAEG,WAAW;EAAK,CAAA;AAIpB,OAAKxB,QAAQyB,MAAMC,OAAOC,wBAAAA;AAE1BC,gBAAc5B,QAAQyB,KAAK;AAE3B,aAAOI,kCAAY/B,kCAAagC,UAAU;IAAEL,OAAOzB,QAAQyB;IAAOM,SAAS/B,QAAQ+B;EAAQ,GAAG,MAAA;AAE5F3B,gBAAAA;EACF,CAAA;AACF;AAGA,IAAMwB,gBAAgB,CAACH,UAAAA;AACpBO,aAAmBC,aAAa,CAAC;AACjCD,aAAmBC,SAASR,QAAQA;AACvC;",
6
- "names": ["context", "registry", "getCapability", "Capabilities", "RxRegistry", "builder", "GraphBuilder", "from", "undefined", "unsubscribe", "subscribe", "capabilities", "AppGraphBuilder", "extensions", "next", "flattenExtensions", "current", "Record", "values", "get", "removed", "filter", "id", "some", "nextId", "forEach", "extension", "removeExtension", "addExtension", "immediate", "graph", "expand", "ROOT_ID", "setupDevtools", "contributes", "AppGraph", "explore", "globalThis", "composer"]
7
- }
@@ -1,82 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var node_exports = {};
31
- __export(node_exports, {
32
- GRAPH_PLUGIN: () => GRAPH_PLUGIN,
33
- GraphPlugin: () => GraphPlugin,
34
- meta: () => meta,
35
- useActions: () => useActions,
36
- useConnections: () => useConnections,
37
- useNode: () => useNode
38
- });
39
- module.exports = __toCommonJS(node_exports);
40
- __reExport(node_exports, require("@dxos/app-graph"), module.exports);
41
- var import_app_framework = require("@dxos/app-framework");
42
- var import_rx_react = require("@effect-rx/rx-react");
43
- var import_effect = require("effect");
44
- var GRAPH_PLUGIN = "dxos.org/plugin/graph";
45
- var meta = {
46
- id: GRAPH_PLUGIN,
47
- name: "Graph"
48
- };
49
- var GraphPlugin = () => (0, import_app_framework.definePlugin)(meta, [
50
- (0, import_app_framework.defineModule)({
51
- id: `${meta.id}/module/graph`,
52
- activatesOn: import_app_framework.Events.Startup,
53
- activatesBefore: [
54
- import_app_framework.Events.SetupAppGraph,
55
- import_app_framework.Events.SetupMetadata
56
- ],
57
- activatesAfter: [
58
- import_app_framework.Events.AppGraphReady
59
- ],
60
- activate: (0, import_app_framework.lazy)(() => import("./graph-Q4KLVTNI.cjs"))
61
- })
62
- ]);
63
- var useNode = (graph, id) => {
64
- return import_effect.Option.getOrElse((0, import_rx_react.useRxValue)(graph.node(id ?? "")), () => void 0);
65
- };
66
- var useConnections = (graph, id, relation) => {
67
- return (0, import_rx_react.useRxValue)(graph.connections(id ?? "", relation));
68
- };
69
- var useActions = (graph, id) => {
70
- return (0, import_rx_react.useRxValue)(graph.actions(id ?? ""));
71
- };
72
- // Annotate the CommonJS export names for ESM import in node:
73
- 0 && (module.exports = {
74
- GRAPH_PLUGIN,
75
- GraphPlugin,
76
- meta,
77
- useActions,
78
- useConnections,
79
- useNode,
80
- ...require("@dxos/app-graph")
81
- });
82
- //# sourceMappingURL=index.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/index.ts", "../../../src/GraphPlugin.ts", "../../../src/meta.ts", "../../../src/hooks/useNode.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nexport * from '@dxos/app-graph';\n\nexport * from './GraphPlugin';\nexport * from './hooks';\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", "//\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: PluginMeta = {\n id: GRAPH_PLUGIN,\n name: 'Graph',\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { useRxValue } from '@effect-rx/rx-react';\nimport { Option } from 'effect';\n\nimport { type ReadableGraph, type Node, type Relation } from '@dxos/app-graph';\n\n/**\n * React hook to get a node from the graph.\n *\n * @param graph Graph to find the node in.\n * @param id Id of the node to find.\n * @param timeout Optional timeout in milliseconds to wait for the node to be found.\n * @returns Node if found, undefined otherwise.\n */\n// TODO(wittjosiah): Factor out to @dxos/app-graph/react.\nexport const useNode = <T = any>(graph: ReadableGraph, id?: string): Node<T> | undefined => {\n return Option.getOrElse(useRxValue(graph.node(id ?? '')), () => undefined);\n};\n\nexport const useConnections = (graph: ReadableGraph, id?: string, relation?: Relation): Node[] => {\n return useRxValue(graph.connections(id ?? '', relation));\n};\n\nexport const useActions = (graph: ReadableGraph, id?: string): Node[] => {\n return useRxValue(graph.actions(id ?? ''));\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,yBAAc;ACAd,2BAAyD;AEAzD,sBAA2B;AAC3B,oBAAuB;ADChB,IAAMA,eAAe;AAErB,IAAMC,OAAmB;EAC9BC,IAAIF;EACJG,MAAM;AACR;ADEO,IAAMC,cAAc,UACzBC,mCAAaJ,MAAM;MACjBK,mCAAa;IACXJ,IAAI,GAAGD,KAAKC,EAAE;IACdK,aAAaC,4BAAOC;IACpBC,iBAAiB;MAACF,4BAAOG;MAAeH,4BAAOI;;IAC/CC,gBAAgB;MAACL,4BAAOM;;IACxBC,cAAUC,2BAAK,MAAM,OAAO,sBAAA,CAAA;EAC9B,CAAA;CACD;AEJI,IAAMC,UAAU,CAAUC,OAAsBhB,OAAAA;AACrD,SAAOiB,qBAAOC,cAAUC,4BAAWH,MAAMI,KAAKpB,MAAM,EAAA,CAAA,GAAM,MAAMqB,MAAAA;AAClE;AAEO,IAAMC,iBAAiB,CAACN,OAAsBhB,IAAauB,aAAAA;AAChE,aAAOJ,4BAAWH,MAAMQ,YAAYxB,MAAM,IAAIuB,QAAAA,CAAAA;AAChD;AAEO,IAAME,aAAa,CAACT,OAAsBhB,OAAAA;AAC/C,aAAOmB,4BAAWH,MAAMU,QAAQ1B,MAAM,EAAA,CAAA;AACxC;",
6
- "names": ["GRAPH_PLUGIN", "meta", "id", "name", "GraphPlugin", "definePlugin", "defineModule", "activatesOn", "Events", "Startup", "activatesBefore", "SetupAppGraph", "SetupMetadata", "activatesAfter", "AppGraphReady", "activate", "lazy", "useNode", "graph", "Option", "getOrElse", "useRxValue", "node", "undefined", "useConnections", "relation", "connections", "useActions", "actions"]
7
- }
@@ -1 +0,0 @@
1
- {"inputs":{"packages/plugins/plugin-graph/src/meta.ts":{"bytes":914,"imports":[],"format":"esm"},"packages/plugins/plugin-graph/src/graph.ts":{"bytes":6317,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-graph","kind":"import-statement","external":true}],"format":"esm"},"packages/plugins/plugin-graph/src/GraphPlugin.ts":{"bytes":2750,"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/hooks/useNode.ts":{"bytes":3137,"imports":[{"path":"@effect-rx/rx-react","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"packages/plugins/plugin-graph/src/hooks/index.ts":{"bytes":474,"imports":[{"path":"packages/plugins/plugin-graph/src/hooks/useNode.ts","kind":"import-statement","original":"./useNode"}],"format":"esm"},"packages/plugins/plugin-graph/src/index.ts":{"bytes":746,"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/hooks/index.ts","kind":"import-statement","original":"./hooks"},{"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":3458},"packages/plugins/plugin-graph/dist/lib/node/index.cjs":{"imports":[{"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-Q4KLVTNI.cjs","kind":"dynamic-import"},{"path":"@effect-rx/rx-react","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true}],"exports":["GRAPH_PLUGIN","GraphPlugin","meta","useActions","useConnections","useNode"],"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},"packages/plugins/plugin-graph/src/meta.ts":{"bytesInOutput":96},"packages/plugins/plugin-graph/src/hooks/useNode.ts":{"bytesInOutput":386},"packages/plugins/plugin-graph/src/hooks/index.ts":{"bytesInOutput":0}},"bytes":1313},"packages/plugins/plugin-graph/dist/lib/node/graph-Q4KLVTNI.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3328},"packages/plugins/plugin-graph/dist/lib/node/graph-Q4KLVTNI.cjs":{"imports":[{"path":"effect","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":1200}},"bytes":1329}}}