graphwise-reactodia 0.0.1-TR1

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.
Files changed (42) hide show
  1. package/README.md +2 -0
  2. package/dist/cjs/app-globals-CcJr5lkF.js +23 -0
  3. package/dist/cjs/graphwise-reactodia.cjs.entry.js +45058 -0
  4. package/dist/cjs/graphwise-reactodia.cjs.js +25 -0
  5. package/dist/cjs/index-CII9aUQC.js +1212 -0
  6. package/dist/cjs/index.cjs.js +2 -0
  7. package/dist/cjs/loader.cjs.js +13 -0
  8. package/dist/collection/collection-manifest.json +13 -0
  9. package/dist/collection/components/graphwise-reactodia/graphwise-reactodia.css +10 -0
  10. package/dist/collection/components/graphwise-reactodia/graphwise-reactodia.js +182 -0
  11. package/dist/collection/components/graphwise-reactodia/i18n/translations.js +4 -0
  12. package/dist/collection/components/graphwise-reactodia/models/reactodia-app-props.js +1 -0
  13. package/dist/collection/components/graphwise-reactodia/reactodia-app.js +109 -0
  14. package/dist/collection/index.js +1 -0
  15. package/dist/collection/polyfill/polyfill-node.js +17 -0
  16. package/dist/esm/app-globals-CalY52z6.js +21 -0
  17. package/dist/esm/graphwise-reactodia.entry.js +45056 -0
  18. package/dist/esm/graphwise-reactodia.js +21 -0
  19. package/dist/esm/index-Cypw7ydc.js +1204 -0
  20. package/dist/esm/index.js +1 -0
  21. package/dist/esm/loader.js +11 -0
  22. package/dist/graphwise-reactodia/graphwise-reactodia.esm.js +1 -0
  23. package/dist/graphwise-reactodia/index.esm.js +0 -0
  24. package/dist/graphwise-reactodia/p-CalY52z6.js +1 -0
  25. package/dist/graphwise-reactodia/p-Cypw7ydc.js +2 -0
  26. package/dist/graphwise-reactodia/p-bafd6be5.entry.js +1 -0
  27. package/dist/index.cjs.js +1 -0
  28. package/dist/index.js +1 -0
  29. package/dist/types/components/graphwise-reactodia/graphwise-reactodia.d.ts +44 -0
  30. package/dist/types/components/graphwise-reactodia/i18n/translations.d.ts +343 -0
  31. package/dist/types/components/graphwise-reactodia/models/reactodia-app-props.d.ts +34 -0
  32. package/dist/types/components/graphwise-reactodia/reactodia-app.d.ts +21 -0
  33. package/dist/types/components.d.ts +109 -0
  34. package/dist/types/index.d.ts +1 -0
  35. package/dist/types/polyfill/polyfill-node.d.ts +9 -0
  36. package/dist/types/stencil-public-runtime.d.ts +1702 -0
  37. package/loader/cdn.js +1 -0
  38. package/loader/index.cjs.js +1 -0
  39. package/loader/index.d.ts +24 -0
  40. package/loader/index.es2017.js +1 -0
  41. package/loader/index.js +2 -0
  42. package/package.json +30 -0
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ var index = require('./index-CII9aUQC.js');
4
+ var appGlobals = require('./app-globals-CcJr5lkF.js');
5
+
6
+ const defineCustomElements = async (win, options) => {
7
+ if (typeof window === 'undefined') return undefined;
8
+ await appGlobals.globalScripts();
9
+ return index.bootstrapLazy([["graphwise-reactodia.cjs",[[0,"graphwise-reactodia",{"currentRepository":[1,"current-repository"],"queryFunction":[16,"query-function"],"language":[1],"providerSettings":[16,"provider-settings"]},null,{"currentRepository":["onProviderSettingsChange"],"providerSettings":["onProviderSettingsChange"],"language":["onLanguageChange"]}]]]], options);
10
+ };
11
+
12
+ exports.setNonce = index.setNonce;
13
+ exports.defineCustomElements = defineCustomElements;
@@ -0,0 +1,13 @@
1
+ {
2
+ "entries": [
3
+ "components/graphwise-reactodia/graphwise-reactodia.js"
4
+ ],
5
+ "compiler": {
6
+ "name": "@stencil/core",
7
+ "version": "4.35.1",
8
+ "typescriptVersion": "5.5.4"
9
+ },
10
+ "collections": [],
11
+ "bundles": [],
12
+ "global": "polyfill/polyfill-node.js"
13
+ }
@@ -0,0 +1,10 @@
1
+ graphwise-reactodia {
2
+ display: block;
3
+ width: 100%;
4
+ height: 75vh;
5
+ }
6
+ graphwise-reactodia .reactodia-container {
7
+ position: relative;
8
+ width: 100%;
9
+ height: 100%;
10
+ }
@@ -0,0 +1,182 @@
1
+ import { h, Host } from "@stencil/core";
2
+ import { exportReactodiaLayout, mountReactodia, unmountReactodia, updateReactodia } from "./reactodia-app";
3
+ /**
4
+ * A web component that renders a graph with the Reactodia workspace.
5
+ *
6
+ * The component is backed by a SPARQL endpoint but is endpoint-agnostic: the host passes
7
+ * the active repository's endpoint via `current-repository` and a `queryFunction` that
8
+ * performs the actual HTTP request. Reactodia fetches all node, link and type data lazily
9
+ * through them; the canvas starts empty and the user populates it via the search bar.
10
+ *
11
+ * The component is a thin wrapper around Reactodia: query configuration lives outside the
12
+ * wrapper and is supplied through the `providerSettings` prop.
13
+ */
14
+ export class GraphwiseReactodia {
15
+ constructor() {
16
+ /**
17
+ * UI language code (e.g. `en`, `fr`) for the Reactodia interface. Defaults to English.
18
+ */
19
+ this.language = 'en';
20
+ }
21
+ onProviderSettingsChange() {
22
+ this.renderGraph();
23
+ }
24
+ onLanguageChange() {
25
+ // The translations are evaluated by the workspace at construction, so the only way
26
+ // to re-translate the UI is to re-create the graph. We carry the
27
+ // current diagram across the remount so switching languages does not wipe the canvas.
28
+ const diagram = exportReactodiaLayout();
29
+ this.renderGraph(diagram);
30
+ }
31
+ componentDidLoad() {
32
+ this.renderGraph();
33
+ }
34
+ disconnectedCallback() {
35
+ if (this.reactRoot) {
36
+ unmountReactodia(this.reactRoot);
37
+ this.reactRoot = undefined;
38
+ }
39
+ }
40
+ render() {
41
+ return (h(Host, { key: '3fca0e2163335fc2cb0fc3c57291e4f29234f2c2' }));
42
+ }
43
+ renderGraph(initialDiagram) {
44
+ if (!this.currentRepository) {
45
+ throw new Error('currentRepository is required');
46
+ }
47
+ if (!this.queryFunction) {
48
+ throw new Error('queryFunction is required');
49
+ }
50
+ if (!this.hostElement) {
51
+ return;
52
+ }
53
+ const props = {
54
+ initialDiagram,
55
+ currentRepository: this.currentRepository,
56
+ queryFunction: this.queryFunction,
57
+ language: this.language,
58
+ providerSettings: this.providerSettings,
59
+ };
60
+ if (this.reactRoot && !initialDiagram) {
61
+ void updateReactodia(props);
62
+ }
63
+ else {
64
+ this.reactRoot = mountReactodia(this.hostElement, props);
65
+ }
66
+ }
67
+ static get is() { return "graphwise-reactodia"; }
68
+ static get originalStyleUrls() {
69
+ return {
70
+ "$": ["graphwise-reactodia.scss"]
71
+ };
72
+ }
73
+ static get styleUrls() {
74
+ return {
75
+ "$": ["graphwise-reactodia.css"]
76
+ };
77
+ }
78
+ static get properties() {
79
+ return {
80
+ "currentRepository": {
81
+ "type": "string",
82
+ "attribute": "current-repository",
83
+ "mutable": false,
84
+ "complexType": {
85
+ "original": "string",
86
+ "resolved": "string",
87
+ "references": {}
88
+ },
89
+ "required": false,
90
+ "optional": false,
91
+ "docs": {
92
+ "tags": [],
93
+ "text": "The active repository id. Appended to {@link queryFunction} as the request `url`;\nchanging it re-points the graph at the new repository (and resets the canvas),\nwhich is how runtime repository changes are handled."
94
+ },
95
+ "getter": false,
96
+ "setter": false,
97
+ "reflect": false
98
+ },
99
+ "queryFunction": {
100
+ "type": "unknown",
101
+ "attribute": "query-function",
102
+ "mutable": false,
103
+ "complexType": {
104
+ "original": "SparqlQueryFunction",
105
+ "resolved": "(params: { url: string; body?: string; headers: { [header: string]: string; }; method: string; signal?: AbortSignal; }) => Promise<Response>",
106
+ "references": {
107
+ "SparqlQueryFunction": {
108
+ "location": "import",
109
+ "path": "@reactodia/workspace",
110
+ "id": "node_modules::SparqlQueryFunction"
111
+ }
112
+ }
113
+ },
114
+ "required": false,
115
+ "optional": false,
116
+ "docs": {
117
+ "tags": [],
118
+ "text": "HTTP transport for the SPARQL requests. Set by the host so requests go through the host's HTTP layer (auth,\ninterceptors) instead of a built-in `fetch`."
119
+ },
120
+ "getter": false,
121
+ "setter": false
122
+ },
123
+ "language": {
124
+ "type": "string",
125
+ "attribute": "language",
126
+ "mutable": false,
127
+ "complexType": {
128
+ "original": "string",
129
+ "resolved": "string",
130
+ "references": {}
131
+ },
132
+ "required": false,
133
+ "optional": false,
134
+ "docs": {
135
+ "tags": [],
136
+ "text": "UI language code (e.g. `en`, `fr`) for the Reactodia interface. Defaults to English."
137
+ },
138
+ "getter": false,
139
+ "setter": false,
140
+ "reflect": false,
141
+ "defaultValue": "'en'"
142
+ },
143
+ "providerSettings": {
144
+ "type": "unknown",
145
+ "attribute": "provider-settings",
146
+ "mutable": false,
147
+ "complexType": {
148
+ "original": "SparqlDataProviderSettings",
149
+ "resolved": "SparqlDataProviderSettings",
150
+ "references": {
151
+ "SparqlDataProviderSettings": {
152
+ "location": "import",
153
+ "path": "@reactodia/workspace",
154
+ "id": "node_modules::SparqlDataProviderSettings"
155
+ }
156
+ }
157
+ },
158
+ "required": false,
159
+ "optional": true,
160
+ "docs": {
161
+ "tags": [],
162
+ "text": "Query preset for the SPARQL data provider, owned and configured by the host. A DOM\nproperty (an object, not an attribute) passed in from outside the wrapper. When omitted,\nthe data provider falls back to Reactodia's generic OWL/RDFS preset. Changing it rebuilds\nthe data provider and resets the canvas."
163
+ },
164
+ "getter": false,
165
+ "setter": false
166
+ }
167
+ };
168
+ }
169
+ static get elementRef() { return "hostElement"; }
170
+ static get watchers() {
171
+ return [{
172
+ "propName": "currentRepository",
173
+ "methodName": "onProviderSettingsChange"
174
+ }, {
175
+ "propName": "providerSettings",
176
+ "methodName": "onProviderSettingsChange"
177
+ }, {
178
+ "propName": "language",
179
+ "methodName": "onLanguageChange"
180
+ }];
181
+ }
182
+ }
@@ -0,0 +1,4 @@
1
+ import frTranslation from "./fr.reactodia.translation.json";
2
+ export const TRANSLATIONS = {
3
+ 'fr': frTranslation
4
+ };
@@ -0,0 +1,109 @@
1
+ import { createElement } from "react";
2
+ import { createRoot } from "react-dom/client";
3
+ import { DefaultWorkspace, SparqlDataProvider, useLoadedWorkspace, Workspace, } from "@reactodia/workspace";
4
+ import { blockingDefaultLayout } from "@reactodia/workspace/layout-sync";
5
+ import { TRANSLATIONS } from "./i18n/translations";
6
+ /**
7
+ * Reactodia ships English as its built-in default bundle, so English needs no override.
8
+ * Other languages are layered on top as partial bundles; unknown codes fall back to English.
9
+ *
10
+ * Reactodia never re-reads the translations, so the component must be remounted
11
+ * to switch the UI language (handled in `graphwise-reactodia.tsx`).
12
+ */
13
+ function translationsForLanguage(language) {
14
+ const translation = TRANSLATIONS[language];
15
+ return translation ? [translation] : [];
16
+ }
17
+ /**
18
+ * The workspace context captured from the Workspace `ref` once it mounts.
19
+ * Used to drive the diagram imperatively from {@link updateReactodia}, which
20
+ * runs outside React and therefore cannot call the `useWorkspace` hook.
21
+ */
22
+ let workspaceContext = null;
23
+ /**
24
+ * Builds a Reactodia {@link SparqlDataProvider} for the given endpoint using the supplied
25
+ * query preset. The host owns the query configuration and passes it in via props; when none
26
+ * is provided we fall back to Reactodia's generic {@link OwlRdfsSettings} OWL/RDFS preset.
27
+ */
28
+ function createDataProvider(currentRepository, queryFunction, settings) {
29
+ return new SparqlDataProvider({
30
+ endpointUrl: currentRepository,
31
+ queryMethod: 'POST',
32
+ queryFunction,
33
+ }, settings);
34
+ }
35
+ /**
36
+ * The Reactodia workspace React component.
37
+ *
38
+ * Authored with `React.createElement` (no TSX) on purpose, since there are differences in stencil and react
39
+ *
40
+ * The canvas starts empty; the user populates it through the workspace search bar
41
+ * (Reactodia's `DefaultWorkspace` unified search), which is backed by the SPARQL
42
+ * data provider's lookup.
43
+ */
44
+ function ReactodiaApp(props) {
45
+ const { currentRepository, queryFunction, language, initialDiagram, providerSettings } = props;
46
+ const { onMount } = useLoadedWorkspace(async ({ context, signal }) => {
47
+ workspaceContext = context;
48
+ const { model } = context;
49
+ const dataProvider = createDataProvider(currentRepository, queryFunction, providerSettings);
50
+ // A language change remounts this component to rebuild the workspace with the new
51
+ // translation bundle; restoring the exported diagram keeps the user's canvas intact.
52
+ // This is done because there is no existing mechanism to re-translate the UI at runtime (not for the UI labels at least)
53
+ if (initialDiagram) {
54
+ await model.importLayout({ dataProvider, diagram: initialDiagram, signal });
55
+ }
56
+ else {
57
+ await model.createNewDiagram({ dataProvider, signal });
58
+ }
59
+ }, [language]);
60
+ /**
61
+ * From the documentation
62
+ *
63
+ * return (
64
+ * <Reactodia.Workspace ref={onMount}
65
+ * defaultLayout={defaultLayout}>
66
+ * <Reactodia.DefaultWorkspace />
67
+ * </Reactodia.Workspace>
68
+ * );
69
+ */
70
+ return createElement(Workspace, {
71
+ ref: onMount,
72
+ defaultLayout: blockingDefaultLayout,
73
+ defaultLanguage: language,
74
+ translations: translationsForLanguage(language)
75
+ }, createElement(DefaultWorkspace, {}));
76
+ }
77
+ /**
78
+ * Mounts the Reactodia application into the given container and returns the React root.
79
+ */
80
+ export function mountReactodia(container, props) {
81
+ const root = createRoot(container);
82
+ root.render(createElement(ReactodiaApp, props));
83
+ return root;
84
+ }
85
+ /**
86
+ * Re-points the diagram at a new SPARQL endpoint or query preset by recreating it with a
87
+ * fresh data provider. The canvas is reset to empty, matching the initial mount.
88
+ */
89
+ export async function updateReactodia(props) {
90
+ if (!workspaceContext) {
91
+ return;
92
+ }
93
+ const { model } = workspaceContext;
94
+ const dataProvider = createDataProvider(props.currentRepository, props.queryFunction, props.providerSettings);
95
+ await model.createNewDiagram({ dataProvider });
96
+ }
97
+ /**
98
+ * Serializes the current diagram so it can be restored after a remount (e.g. when a
99
+ * language change rebuilds the workspace). Returns `undefined` if nothing is mounted yet.
100
+ */
101
+ export function exportReactodiaLayout() {
102
+ return workspaceContext === null || workspaceContext === void 0 ? void 0 : workspaceContext.model.exportLayout();
103
+ }
104
+ /**
105
+ * Unmounts the Reactodia application.
106
+ */
107
+ export function unmountReactodia(root) {
108
+ root.unmount();
109
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Stencil global script, executed once before any component bundle loads.
3
+ *
4
+ * Reactodia's transitive dependencies (n3 / readable-stream) reference the Node.js
5
+ * `process` global at module-evaluation time (e.g. `util.debuglog` reads
6
+ * `process.env.NODE_DEBUG`). That global does not exist in the browser, so we provide
7
+ * a minimal shim here to keep those modules from crashing
8
+ */
9
+ export default function polyfillNode() {
10
+ const globalScope = globalThis;
11
+ if (!globalScope.process) {
12
+ globalScope.process = { env: { NODE_ENV: 'production' } };
13
+ }
14
+ else if (!globalScope.process.env) {
15
+ globalScope.process.env = { NODE_ENV: 'production' };
16
+ }
17
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Stencil global script, executed once before any component bundle loads.
3
+ *
4
+ * Reactodia's transitive dependencies (n3 / readable-stream) reference the Node.js
5
+ * `process` global at module-evaluation time (e.g. `util.debuglog` reads
6
+ * `process.env.NODE_DEBUG`). That global does not exist in the browser, so we provide
7
+ * a minimal shim here to keep those modules from crashing
8
+ */
9
+ function polyfillNode() {
10
+ const globalScope = globalThis;
11
+ if (!globalScope.process) {
12
+ globalScope.process = { env: { NODE_ENV: 'production' } };
13
+ }
14
+ else if (!globalScope.process.env) {
15
+ globalScope.process.env = { NODE_ENV: 'production' };
16
+ }
17
+ }
18
+
19
+ const globalScripts = polyfillNode;
20
+
21
+ export { globalScripts as g };