graphwise-reactodia 0.0.1-TR5 → 0.0.1-TR7

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 (23) hide show
  1. package/dist/cjs/graphwise-reactodia.cjs.entry.js +79 -16
  2. package/dist/cjs/graphwise-reactodia.cjs.js +1 -1
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/collection/components/graphwise-reactodia/graphwise-reactodia.js +32 -24
  5. package/dist/collection/components/graphwise-reactodia/i18n/language-key.js +5 -0
  6. package/dist/collection/components/graphwise-reactodia/i18n/translations.js +3 -1
  7. package/dist/collection/components/graphwise-reactodia/models/reactodia-config.js +1 -0
  8. package/dist/collection/components/graphwise-reactodia/models/reactodia-seed-link.js +1 -0
  9. package/dist/collection/components/graphwise-reactodia/reactodia-app.js +64 -9
  10. package/dist/collection/pages/graphwise-reactodia/main.js +26 -13
  11. package/dist/esm/graphwise-reactodia.entry.js +79 -16
  12. package/dist/esm/graphwise-reactodia.js +1 -1
  13. package/dist/esm/loader.js +1 -1
  14. package/dist/graphwise-reactodia/graphwise-reactodia.esm.js +1 -1
  15. package/dist/graphwise-reactodia/{p-b10c344f.entry.js → p-eb362faa.entry.js} +1 -1
  16. package/dist/types/components/graphwise-reactodia/graphwise-reactodia.d.ts +17 -12
  17. package/dist/types/components/graphwise-reactodia/i18n/language-key.d.ts +4 -0
  18. package/dist/types/components/graphwise-reactodia/i18n/translations.d.ts +5 -342
  19. package/dist/types/components/graphwise-reactodia/models/reactodia-app-props.d.ts +10 -8
  20. package/dist/types/components/graphwise-reactodia/models/reactodia-config.d.ts +29 -0
  21. package/dist/types/components/graphwise-reactodia/models/reactodia-seed-link.d.ts +23 -0
  22. package/dist/types/components.d.ts +33 -29
  23. package/package.json +13 -1
@@ -30631,8 +30631,15 @@ var frTranslation = {
30631
30631
  zoom_control: zoom_control
30632
30632
  };
30633
30633
 
30634
+ var LanguageKey;
30635
+ (function (LanguageKey) {
30636
+ LanguageKey["EN"] = "en";
30637
+ LanguageKey["FR"] = "fr";
30638
+ })(LanguageKey || (LanguageKey = {}));
30639
+
30640
+ // English is provided by default from reactodia so we don't need to include it here, unless we override it
30634
30641
  const TRANSLATIONS = {
30635
- 'fr': frTranslation
30642
+ [LanguageKey.FR]: frTranslation
30636
30643
  };
30637
30644
 
30638
30645
  /**
@@ -30657,28 +30664,77 @@ let workspaceContext = null;
30657
30664
  * query preset. The host owns the query configuration and passes it in via props; when none
30658
30665
  * is provided we fall back to Reactodia's generic {@link OwlRdfsSettings} OWL/RDFS preset.
30659
30666
  */
30660
- function createDataProvider(currentRepository, queryFunction, settings) {
30667
+ function createDataProvider(props) {
30668
+ const { currentRepository, config, providerSettings } = props;
30661
30669
  return new SparqlDataProvider({
30662
30670
  endpointUrl: currentRepository,
30663
30671
  queryMethod: 'POST',
30664
- queryFunction,
30665
- }, settings);
30672
+ queryFunction: config.queryFunction,
30673
+ }, providerSettings);
30674
+ }
30675
+ /**
30676
+ * Places the seed entities on the canvas. Each IRI is added as a placeholder element, and data is then loaded for the
30677
+ * respective nodes using the {@link DataDiagramModel.requestData} method.
30678
+ */
30679
+ async function seedCanvas(context, seed, signal) {
30680
+ const { model, performLayout } = context;
30681
+ for (const iri of seed) {
30682
+ model.createElement(iri);
30683
+ }
30684
+ await model.requestData();
30685
+ await performLayout({ signal });
30686
+ }
30687
+ /**
30688
+ * Places a pre-resolved graph (e.g. a CONSTRUCT query result) on the canvas. The relationships
30689
+ * are computed and not persisted in the repository, so the edges are drawn directly from the
30690
+ * supplied data instead of being fetched. The node IRIs do exist in the repository, so only
30691
+ * their display data is hydrated via {@link DataDiagramModel.requestElementData}.
30692
+ *
30693
+ * Note we use `requestElementData` rather than `requestData`: the latter would also query the
30694
+ * provider for *all* persisted links between the seeded nodes, over-fetching beyond the
30695
+ * CONSTRUCT's selection. Hydrating elements alone keeps the canvas to exactly the supplied
30696
+ * edges, while further expansion continues lazily against the SPARQL provider.
30697
+ */
30698
+ async function seedGraphCanvas(context, links, signal) {
30699
+ const { model, performLayout } = context;
30700
+ const uniqueIris = new Set();
30701
+ links.forEach((link) => {
30702
+ var _a;
30703
+ uniqueIris.add(link.source);
30704
+ uniqueIris.add(link.target);
30705
+ // this is a createOrGet, regardless of the name, so we don't need to worry about duplicates.
30706
+ model.createElement(link.source);
30707
+ model.createElement(link.target);
30708
+ (_a = link.rawPredicates) === null || _a === void 0 ? void 0 : _a.forEach((predicate) => {
30709
+ model.createLinks({
30710
+ linkTypeId: predicate,
30711
+ sourceId: link.source,
30712
+ targetId: link.target,
30713
+ properties: {}
30714
+ });
30715
+ });
30716
+ });
30717
+ // Request data only for elements.
30718
+ // Link data is not available in the DB, since we are displaying construct/describe queries
30719
+ await model.requestElementData(Array.from(uniqueIris));
30720
+ await performLayout({ signal });
30666
30721
  }
30667
30722
  /**
30668
30723
  * The Reactodia workspace React component.
30669
30724
  *
30670
30725
  * Authored with `React.createElement` (no TSX) on purpose, since there are differences in stencil and react
30671
30726
  *
30672
- * The canvas starts empty; the user populates it through the workspace search bar
30673
- * (Reactodia's `DefaultWorkspace` unified search), which is backed by the SPARQL
30674
- * data provider's lookup.
30727
+ * Without a seed the canvas starts empty and the user populates it through the workspace
30728
+ * search bar (Reactodia's `DefaultWorkspace` unified search), backed by the SPARQL data
30729
+ * provider's lookup. With a seed, the seeded nodes are placed on the canvas on startup.
30675
30730
  */
30676
30731
  function ReactodiaApp(props) {
30677
- const { currentRepository, queryFunction, language, initialDiagram, providerSettings } = props;
30732
+ const { language, initialDiagram, config } = props;
30678
30733
  const { onMount } = useLoadedWorkspace(async ({ context, signal }) => {
30734
+ var _a, _b;
30679
30735
  workspaceContext = context;
30680
30736
  const { model } = context;
30681
- const dataProvider = createDataProvider(currentRepository, queryFunction, providerSettings);
30737
+ const dataProvider = createDataProvider(props);
30682
30738
  // A language change remounts this component to rebuild the workspace with the new
30683
30739
  // translation bundle; restoring the exported diagram keeps the user's canvas intact.
30684
30740
  // This is done because there is no existing mechanism to re-translate the UI at runtime (not for the UI labels at least)
@@ -30687,6 +30743,12 @@ function ReactodiaApp(props) {
30687
30743
  }
30688
30744
  else {
30689
30745
  await model.createNewDiagram({ dataProvider, signal });
30746
+ if ((_a = config.seedGraph) === null || _a === void 0 ? void 0 : _a.length) {
30747
+ await seedGraphCanvas(context, config.seedGraph, signal);
30748
+ }
30749
+ else if ((_b = config.seedIris) === null || _b === void 0 ? void 0 : _b.length) {
30750
+ await seedCanvas(context, config.seedIris, signal);
30751
+ }
30690
30752
  }
30691
30753
  }, [language]);
30692
30754
  /**
@@ -30723,7 +30785,7 @@ async function updateReactodia(props) {
30723
30785
  return;
30724
30786
  }
30725
30787
  const { model } = workspaceContext;
30726
- const dataProvider = createDataProvider(props.currentRepository, props.queryFunction, props.providerSettings);
30788
+ const dataProvider = createDataProvider(props);
30727
30789
  await model.createNewDiagram({ dataProvider });
30728
30790
  }
30729
30791
  /**
@@ -30748,7 +30810,7 @@ const GraphwiseReactodia = class {
30748
30810
  /**
30749
30811
  * UI language code (e.g. `en`, `fr`) for the Reactodia interface. Defaults to English.
30750
30812
  */
30751
- this.language = 'en';
30813
+ this.language = LanguageKey.EN;
30752
30814
  }
30753
30815
  onProviderSettingsChange() {
30754
30816
  this.renderGraph();
@@ -30760,7 +30822,7 @@ const GraphwiseReactodia = class {
30760
30822
  const diagram = exportReactodiaLayout();
30761
30823
  this.renderGraph(diagram);
30762
30824
  }
30763
- componentDidLoad() {
30825
+ connectedCallback() {
30764
30826
  this.renderGraph();
30765
30827
  }
30766
30828
  disconnectedCallback() {
@@ -30770,14 +30832,15 @@ const GraphwiseReactodia = class {
30770
30832
  }
30771
30833
  }
30772
30834
  render() {
30773
- return (index.h(index.Host, { key: '3fca0e2163335fc2cb0fc3c57291e4f29234f2c2' }));
30835
+ return (index.h(index.Host, { key: '63c58ee1d28c4866aa66d3dcf4893879de4d09f6' }));
30774
30836
  }
30775
30837
  renderGraph(initialDiagram) {
30838
+ var _a;
30776
30839
  if (!this.currentRepository) {
30777
30840
  throw new Error('currentRepository is required');
30778
30841
  }
30779
- if (!this.queryFunction) {
30780
- throw new Error('queryFunction is required');
30842
+ if (!((_a = this.config) === null || _a === void 0 ? void 0 : _a.queryFunction)) {
30843
+ throw new Error('config.queryFunction is required');
30781
30844
  }
30782
30845
  if (!this.hostElement) {
30783
30846
  return;
@@ -30785,7 +30848,7 @@ const GraphwiseReactodia = class {
30785
30848
  const props = {
30786
30849
  initialDiagram,
30787
30850
  currentRepository: this.currentRepository,
30788
- queryFunction: this.queryFunction,
30851
+ config: this.config,
30789
30852
  language: this.language,
30790
30853
  providerSettings: this.providerSettings,
30791
30854
  };
@@ -19,7 +19,7 @@ var patchBrowser = () => {
19
19
 
20
20
  patchBrowser().then(async (options) => {
21
21
  await appGlobals.globalScripts();
22
- 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);
22
+ return index.bootstrapLazy([["graphwise-reactodia.cjs",[[0,"graphwise-reactodia",{"currentRepository":[1,"current-repository"],"config":[16],"language":[1],"providerSettings":[16,"provider-settings"]},null,{"currentRepository":["onProviderSettingsChange"],"providerSettings":["onProviderSettingsChange"],"language":["onLanguageChange"]}]]]], options);
23
23
  });
24
24
 
25
25
  exports.setNonce = index.setNonce;
@@ -6,7 +6,7 @@ var appGlobals = require('./app-globals-CcJr5lkF.js');
6
6
  const defineCustomElements = async (win, options) => {
7
7
  if (typeof window === 'undefined') return undefined;
8
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);
9
+ return index.bootstrapLazy([["graphwise-reactodia.cjs",[[0,"graphwise-reactodia",{"currentRepository":[1,"current-repository"],"config":[16],"language":[1],"providerSettings":[16,"provider-settings"]},null,{"currentRepository":["onProviderSettingsChange"],"providerSettings":["onProviderSettingsChange"],"language":["onLanguageChange"]}]]]], options);
10
10
  };
11
11
 
12
12
  exports.setNonce = index.setNonce;
@@ -1,12 +1,13 @@
1
1
  import { h, Host } from "@stencil/core";
2
2
  import { exportReactodiaLayout, mountReactodia, unmountReactodia, updateReactodia } from "./reactodia-app";
3
+ import { LanguageKey } from "./i18n/language-key";
3
4
  /**
4
5
  * A web component that renders a graph with the Reactodia workspace.
5
6
  *
6
7
  * 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.
8
+ * the active repository's endpoint via `current-repository` and a `config.queryFunction`
9
+ * that performs the actual HTTP request. Reactodia fetches all node, link and type data
10
+ * lazily through them; the canvas starts empty and the user populates it via the search bar.
10
11
  *
11
12
  * The component is a thin wrapper around Reactodia: query configuration lives outside the
12
13
  * wrapper and is supplied through the `providerSettings` prop.
@@ -16,7 +17,7 @@ export class GraphwiseReactodia {
16
17
  /**
17
18
  * UI language code (e.g. `en`, `fr`) for the Reactodia interface. Defaults to English.
18
19
  */
19
- this.language = 'en';
20
+ this.language = LanguageKey.EN;
20
21
  }
21
22
  onProviderSettingsChange() {
22
23
  this.renderGraph();
@@ -28,7 +29,7 @@ export class GraphwiseReactodia {
28
29
  const diagram = exportReactodiaLayout();
29
30
  this.renderGraph(diagram);
30
31
  }
31
- componentDidLoad() {
32
+ connectedCallback() {
32
33
  this.renderGraph();
33
34
  }
34
35
  disconnectedCallback() {
@@ -38,14 +39,15 @@ export class GraphwiseReactodia {
38
39
  }
39
40
  }
40
41
  render() {
41
- return (h(Host, { key: '3fca0e2163335fc2cb0fc3c57291e4f29234f2c2' }));
42
+ return (h(Host, { key: '63c58ee1d28c4866aa66d3dcf4893879de4d09f6' }));
42
43
  }
43
44
  renderGraph(initialDiagram) {
45
+ var _a;
44
46
  if (!this.currentRepository) {
45
47
  throw new Error('currentRepository is required');
46
48
  }
47
- if (!this.queryFunction) {
48
- throw new Error('queryFunction is required');
49
+ if (!((_a = this.config) === null || _a === void 0 ? void 0 : _a.queryFunction)) {
50
+ throw new Error('config.queryFunction is required');
49
51
  }
50
52
  if (!this.hostElement) {
51
53
  return;
@@ -53,7 +55,7 @@ export class GraphwiseReactodia {
53
55
  const props = {
54
56
  initialDiagram,
55
57
  currentRepository: this.currentRepository,
56
- queryFunction: this.queryFunction,
58
+ config: this.config,
57
59
  language: this.language,
58
60
  providerSettings: this.providerSettings,
59
61
  };
@@ -87,35 +89,35 @@ export class GraphwiseReactodia {
87
89
  "references": {}
88
90
  },
89
91
  "required": false,
90
- "optional": false,
92
+ "optional": true,
91
93
  "docs": {
92
94
  "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."
95
+ "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
96
  },
95
97
  "getter": false,
96
98
  "setter": false,
97
99
  "reflect": false
98
100
  },
99
- "queryFunction": {
101
+ "config": {
100
102
  "type": "unknown",
101
- "attribute": "query-function",
103
+ "attribute": "config",
102
104
  "mutable": false,
103
105
  "complexType": {
104
- "original": "SparqlQueryFunction",
105
- "resolved": "(params: { url: string; body?: string; headers: { [header: string]: string; }; method: string; signal?: AbortSignal; }) => Promise<Response>",
106
+ "original": "ReactodiaConfig",
107
+ "resolved": "ReactodiaConfig",
106
108
  "references": {
107
- "SparqlQueryFunction": {
109
+ "ReactodiaConfig": {
108
110
  "location": "import",
109
- "path": "@reactodia/workspace",
110
- "id": "reactodia-workspace/dist/typings/workspace.d.ts::SparqlQueryFunction"
111
+ "path": "./models/reactodia-config",
112
+ "id": "src/components/graphwise-reactodia/models/reactodia-config.ts::ReactodiaConfig"
111
113
  }
112
114
  }
113
115
  },
114
116
  "required": false,
115
- "optional": false,
117
+ "optional": true,
116
118
  "docs": {
117
119
  "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`."
120
+ "text": "Host-supplied configuration: the SPARQL `queryFunction` transport and an optional `seed`\nset of entities to pre-populate the canvas with. A DOM property (an object, not an\nattribute) passed in from outside the wrapper.\n\nRead once on mount; not watched, as it only sets up the data source and initial canvas."
119
121
  },
120
122
  "getter": false,
121
123
  "setter": false
@@ -125,9 +127,15 @@ export class GraphwiseReactodia {
125
127
  "attribute": "language",
126
128
  "mutable": false,
127
129
  "complexType": {
128
- "original": "string",
129
- "resolved": "string",
130
- "references": {}
130
+ "original": "LanguageKey",
131
+ "resolved": "LanguageKey.EN | LanguageKey.FR",
132
+ "references": {
133
+ "LanguageKey": {
134
+ "location": "import",
135
+ "path": "./i18n/language-key",
136
+ "id": "src/components/graphwise-reactodia/i18n/language-key.ts::LanguageKey"
137
+ }
138
+ }
131
139
  },
132
140
  "required": false,
133
141
  "optional": false,
@@ -138,7 +146,7 @@ export class GraphwiseReactodia {
138
146
  "getter": false,
139
147
  "setter": false,
140
148
  "reflect": false,
141
- "defaultValue": "'en'"
149
+ "defaultValue": "LanguageKey.EN"
142
150
  },
143
151
  "providerSettings": {
144
152
  "type": "unknown",
@@ -0,0 +1,5 @@
1
+ export var LanguageKey;
2
+ (function (LanguageKey) {
3
+ LanguageKey["EN"] = "en";
4
+ LanguageKey["FR"] = "fr";
5
+ })(LanguageKey || (LanguageKey = {}));
@@ -1,4 +1,6 @@
1
1
  import frTranslation from "./fr.reactodia.translation.json";
2
+ import { LanguageKey } from "./language-key";
3
+ // English is provided by default from reactodia so we don't need to include it here, unless we override it
2
4
  export const TRANSLATIONS = {
3
- 'fr': frTranslation
5
+ [LanguageKey.FR]: frTranslation
4
6
  };
@@ -25,28 +25,77 @@ let workspaceContext = null;
25
25
  * query preset. The host owns the query configuration and passes it in via props; when none
26
26
  * is provided we fall back to Reactodia's generic {@link OwlRdfsSettings} OWL/RDFS preset.
27
27
  */
28
- function createDataProvider(currentRepository, queryFunction, settings) {
28
+ function createDataProvider(props) {
29
+ const { currentRepository, config, providerSettings } = props;
29
30
  return new SparqlDataProvider({
30
31
  endpointUrl: currentRepository,
31
32
  queryMethod: 'POST',
32
- queryFunction,
33
- }, settings);
33
+ queryFunction: config.queryFunction,
34
+ }, providerSettings);
35
+ }
36
+ /**
37
+ * Places the seed entities on the canvas. Each IRI is added as a placeholder element, and data is then loaded for the
38
+ * respective nodes using the {@link DataDiagramModel.requestData} method.
39
+ */
40
+ async function seedCanvas(context, seed, signal) {
41
+ const { model, performLayout } = context;
42
+ for (const iri of seed) {
43
+ model.createElement(iri);
44
+ }
45
+ await model.requestData();
46
+ await performLayout({ signal });
47
+ }
48
+ /**
49
+ * Places a pre-resolved graph (e.g. a CONSTRUCT query result) on the canvas. The relationships
50
+ * are computed and not persisted in the repository, so the edges are drawn directly from the
51
+ * supplied data instead of being fetched. The node IRIs do exist in the repository, so only
52
+ * their display data is hydrated via {@link DataDiagramModel.requestElementData}.
53
+ *
54
+ * Note we use `requestElementData` rather than `requestData`: the latter would also query the
55
+ * provider for *all* persisted links between the seeded nodes, over-fetching beyond the
56
+ * CONSTRUCT's selection. Hydrating elements alone keeps the canvas to exactly the supplied
57
+ * edges, while further expansion continues lazily against the SPARQL provider.
58
+ */
59
+ async function seedGraphCanvas(context, links, signal) {
60
+ const { model, performLayout } = context;
61
+ const uniqueIris = new Set();
62
+ links.forEach((link) => {
63
+ var _a;
64
+ uniqueIris.add(link.source);
65
+ uniqueIris.add(link.target);
66
+ // this is a createOrGet, regardless of the name, so we don't need to worry about duplicates.
67
+ model.createElement(link.source);
68
+ model.createElement(link.target);
69
+ (_a = link.rawPredicates) === null || _a === void 0 ? void 0 : _a.forEach((predicate) => {
70
+ model.createLinks({
71
+ linkTypeId: predicate,
72
+ sourceId: link.source,
73
+ targetId: link.target,
74
+ properties: {}
75
+ });
76
+ });
77
+ });
78
+ // Request data only for elements.
79
+ // Link data is not available in the DB, since we are displaying construct/describe queries
80
+ await model.requestElementData(Array.from(uniqueIris));
81
+ await performLayout({ signal });
34
82
  }
35
83
  /**
36
84
  * The Reactodia workspace React component.
37
85
  *
38
86
  * Authored with `React.createElement` (no TSX) on purpose, since there are differences in stencil and react
39
87
  *
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.
88
+ * Without a seed the canvas starts empty and the user populates it through the workspace
89
+ * search bar (Reactodia's `DefaultWorkspace` unified search), backed by the SPARQL data
90
+ * provider's lookup. With a seed, the seeded nodes are placed on the canvas on startup.
43
91
  */
44
92
  function ReactodiaApp(props) {
45
- const { currentRepository, queryFunction, language, initialDiagram, providerSettings } = props;
93
+ const { language, initialDiagram, config } = props;
46
94
  const { onMount } = useLoadedWorkspace(async ({ context, signal }) => {
95
+ var _a, _b;
47
96
  workspaceContext = context;
48
97
  const { model } = context;
49
- const dataProvider = createDataProvider(currentRepository, queryFunction, providerSettings);
98
+ const dataProvider = createDataProvider(props);
50
99
  // A language change remounts this component to rebuild the workspace with the new
51
100
  // translation bundle; restoring the exported diagram keeps the user's canvas intact.
52
101
  // This is done because there is no existing mechanism to re-translate the UI at runtime (not for the UI labels at least)
@@ -55,6 +104,12 @@ function ReactodiaApp(props) {
55
104
  }
56
105
  else {
57
106
  await model.createNewDiagram({ dataProvider, signal });
107
+ if ((_a = config.seedGraph) === null || _a === void 0 ? void 0 : _a.length) {
108
+ await seedGraphCanvas(context, config.seedGraph, signal);
109
+ }
110
+ else if ((_b = config.seedIris) === null || _b === void 0 ? void 0 : _b.length) {
111
+ await seedCanvas(context, config.seedIris, signal);
112
+ }
58
113
  }
59
114
  }, [language]);
60
115
  /**
@@ -91,7 +146,7 @@ export async function updateReactodia(props) {
91
146
  return;
92
147
  }
93
148
  const { model } = workspaceContext;
94
- const dataProvider = createDataProvider(props.currentRepository, props.queryFunction, props.providerSettings);
149
+ const dataProvider = createDataProvider(props);
95
150
  await model.createNewDiagram({ dataProvider });
96
151
  }
97
152
  /**
@@ -1,21 +1,34 @@
1
- const EMPTY_SPARQL_RESULT = {
2
- head: {vars: []},
3
- results: {bindings: []},
4
- };
5
-
6
- function stubQueryFunction() {
7
- return Promise.resolve(
8
- new Response(JSON.stringify(EMPTY_SPARQL_RESULT), {
9
- status: 200,
10
- headers: {'Content-Type': 'application/sparql-results+json'},
11
- })
12
- );
1
+ // Mock all responses as turtle, as we won't be making any SPARQL requests in the dev server.
2
+ async function stubQueryFunction(_params) {
3
+ return (new Response('', {headers: {'Content-Type': 'text/turtle'}}));
13
4
  }
14
5
 
6
+ // IRIs of the entities the host asks to pre-populate the canvas with on startup.
7
+ const SEED_NODES = ['http://example.com/alice', 'http://example.com/bob'];
8
+
9
+ // Pre-resolved edges (e.g. a CONSTRUCT result) the host asks to draw directly on the canvas,
10
+ // without querying the SPARQL endpoint for link data.
11
+ const SEED_GRAPH = [
12
+ {
13
+ source: 'http://example.com/alice',
14
+ target: 'http://example.com/bob',
15
+ predicates: ['knows'],
16
+ rawPredicates: ['http://example.com/knows'],
17
+ },
18
+ ];
19
+
15
20
  const reactodia = document.querySelector('graphwise-reactodia');
16
21
 
17
22
  function setQueryFunction() {
18
- reactodia.queryFunction = stubQueryFunction;
23
+ reactodia.config = {...reactodia.config, queryFunction: stubQueryFunction};
24
+ }
25
+
26
+ function setSeed() {
27
+ reactodia.config = {...reactodia.config, seedIris: SEED_NODES};
28
+ }
29
+
30
+ function setSeedGraph() {
31
+ reactodia.config = {...reactodia.config, seedGraph: SEED_GRAPH};
19
32
  }
20
33
 
21
34
  function setRepository(repository) {