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
@@ -30629,8 +30629,15 @@ var frTranslation = {
30629
30629
  zoom_control: zoom_control
30630
30630
  };
30631
30631
 
30632
+ var LanguageKey;
30633
+ (function (LanguageKey) {
30634
+ LanguageKey["EN"] = "en";
30635
+ LanguageKey["FR"] = "fr";
30636
+ })(LanguageKey || (LanguageKey = {}));
30637
+
30638
+ // English is provided by default from reactodia so we don't need to include it here, unless we override it
30632
30639
  const TRANSLATIONS = {
30633
- 'fr': frTranslation
30640
+ [LanguageKey.FR]: frTranslation
30634
30641
  };
30635
30642
 
30636
30643
  /**
@@ -30655,28 +30662,77 @@ let workspaceContext = null;
30655
30662
  * query preset. The host owns the query configuration and passes it in via props; when none
30656
30663
  * is provided we fall back to Reactodia's generic {@link OwlRdfsSettings} OWL/RDFS preset.
30657
30664
  */
30658
- function createDataProvider(currentRepository, queryFunction, settings) {
30665
+ function createDataProvider(props) {
30666
+ const { currentRepository, config, providerSettings } = props;
30659
30667
  return new SparqlDataProvider({
30660
30668
  endpointUrl: currentRepository,
30661
30669
  queryMethod: 'POST',
30662
- queryFunction,
30663
- }, settings);
30670
+ queryFunction: config.queryFunction,
30671
+ }, providerSettings);
30672
+ }
30673
+ /**
30674
+ * Places the seed entities on the canvas. Each IRI is added as a placeholder element, and data is then loaded for the
30675
+ * respective nodes using the {@link DataDiagramModel.requestData} method.
30676
+ */
30677
+ async function seedCanvas(context, seed, signal) {
30678
+ const { model, performLayout } = context;
30679
+ for (const iri of seed) {
30680
+ model.createElement(iri);
30681
+ }
30682
+ await model.requestData();
30683
+ await performLayout({ signal });
30684
+ }
30685
+ /**
30686
+ * Places a pre-resolved graph (e.g. a CONSTRUCT query result) on the canvas. The relationships
30687
+ * are computed and not persisted in the repository, so the edges are drawn directly from the
30688
+ * supplied data instead of being fetched. The node IRIs do exist in the repository, so only
30689
+ * their display data is hydrated via {@link DataDiagramModel.requestElementData}.
30690
+ *
30691
+ * Note we use `requestElementData` rather than `requestData`: the latter would also query the
30692
+ * provider for *all* persisted links between the seeded nodes, over-fetching beyond the
30693
+ * CONSTRUCT's selection. Hydrating elements alone keeps the canvas to exactly the supplied
30694
+ * edges, while further expansion continues lazily against the SPARQL provider.
30695
+ */
30696
+ async function seedGraphCanvas(context, links, signal) {
30697
+ const { model, performLayout } = context;
30698
+ const uniqueIris = new Set();
30699
+ links.forEach((link) => {
30700
+ var _a;
30701
+ uniqueIris.add(link.source);
30702
+ uniqueIris.add(link.target);
30703
+ // this is a createOrGet, regardless of the name, so we don't need to worry about duplicates.
30704
+ model.createElement(link.source);
30705
+ model.createElement(link.target);
30706
+ (_a = link.rawPredicates) === null || _a === void 0 ? void 0 : _a.forEach((predicate) => {
30707
+ model.createLinks({
30708
+ linkTypeId: predicate,
30709
+ sourceId: link.source,
30710
+ targetId: link.target,
30711
+ properties: {}
30712
+ });
30713
+ });
30714
+ });
30715
+ // Request data only for elements.
30716
+ // Link data is not available in the DB, since we are displaying construct/describe queries
30717
+ await model.requestElementData(Array.from(uniqueIris));
30718
+ await performLayout({ signal });
30664
30719
  }
30665
30720
  /**
30666
30721
  * The Reactodia workspace React component.
30667
30722
  *
30668
30723
  * Authored with `React.createElement` (no TSX) on purpose, since there are differences in stencil and react
30669
30724
  *
30670
- * The canvas starts empty; the user populates it through the workspace search bar
30671
- * (Reactodia's `DefaultWorkspace` unified search), which is backed by the SPARQL
30672
- * data provider's lookup.
30725
+ * Without a seed the canvas starts empty and the user populates it through the workspace
30726
+ * search bar (Reactodia's `DefaultWorkspace` unified search), backed by the SPARQL data
30727
+ * provider's lookup. With a seed, the seeded nodes are placed on the canvas on startup.
30673
30728
  */
30674
30729
  function ReactodiaApp(props) {
30675
- const { currentRepository, queryFunction, language, initialDiagram, providerSettings } = props;
30730
+ const { language, initialDiagram, config } = props;
30676
30731
  const { onMount } = useLoadedWorkspace(async ({ context, signal }) => {
30732
+ var _a, _b;
30677
30733
  workspaceContext = context;
30678
30734
  const { model } = context;
30679
- const dataProvider = createDataProvider(currentRepository, queryFunction, providerSettings);
30735
+ const dataProvider = createDataProvider(props);
30680
30736
  // A language change remounts this component to rebuild the workspace with the new
30681
30737
  // translation bundle; restoring the exported diagram keeps the user's canvas intact.
30682
30738
  // This is done because there is no existing mechanism to re-translate the UI at runtime (not for the UI labels at least)
@@ -30685,6 +30741,12 @@ function ReactodiaApp(props) {
30685
30741
  }
30686
30742
  else {
30687
30743
  await model.createNewDiagram({ dataProvider, signal });
30744
+ if ((_a = config.seedGraph) === null || _a === void 0 ? void 0 : _a.length) {
30745
+ await seedGraphCanvas(context, config.seedGraph, signal);
30746
+ }
30747
+ else if ((_b = config.seedIris) === null || _b === void 0 ? void 0 : _b.length) {
30748
+ await seedCanvas(context, config.seedIris, signal);
30749
+ }
30688
30750
  }
30689
30751
  }, [language]);
30690
30752
  /**
@@ -30721,7 +30783,7 @@ async function updateReactodia(props) {
30721
30783
  return;
30722
30784
  }
30723
30785
  const { model } = workspaceContext;
30724
- const dataProvider = createDataProvider(props.currentRepository, props.queryFunction, props.providerSettings);
30786
+ const dataProvider = createDataProvider(props);
30725
30787
  await model.createNewDiagram({ dataProvider });
30726
30788
  }
30727
30789
  /**
@@ -30746,7 +30808,7 @@ const GraphwiseReactodia = class {
30746
30808
  /**
30747
30809
  * UI language code (e.g. `en`, `fr`) for the Reactodia interface. Defaults to English.
30748
30810
  */
30749
- this.language = 'en';
30811
+ this.language = LanguageKey.EN;
30750
30812
  }
30751
30813
  onProviderSettingsChange() {
30752
30814
  this.renderGraph();
@@ -30758,7 +30820,7 @@ const GraphwiseReactodia = class {
30758
30820
  const diagram = exportReactodiaLayout();
30759
30821
  this.renderGraph(diagram);
30760
30822
  }
30761
- componentDidLoad() {
30823
+ connectedCallback() {
30762
30824
  this.renderGraph();
30763
30825
  }
30764
30826
  disconnectedCallback() {
@@ -30768,14 +30830,15 @@ const GraphwiseReactodia = class {
30768
30830
  }
30769
30831
  }
30770
30832
  render() {
30771
- return (h(Host, { key: '3fca0e2163335fc2cb0fc3c57291e4f29234f2c2' }));
30833
+ return (h(Host, { key: '63c58ee1d28c4866aa66d3dcf4893879de4d09f6' }));
30772
30834
  }
30773
30835
  renderGraph(initialDiagram) {
30836
+ var _a;
30774
30837
  if (!this.currentRepository) {
30775
30838
  throw new Error('currentRepository is required');
30776
30839
  }
30777
- if (!this.queryFunction) {
30778
- throw new Error('queryFunction is required');
30840
+ if (!((_a = this.config) === null || _a === void 0 ? void 0 : _a.queryFunction)) {
30841
+ throw new Error('config.queryFunction is required');
30779
30842
  }
30780
30843
  if (!this.hostElement) {
30781
30844
  return;
@@ -30783,7 +30846,7 @@ const GraphwiseReactodia = class {
30783
30846
  const props = {
30784
30847
  initialDiagram,
30785
30848
  currentRepository: this.currentRepository,
30786
- queryFunction: this.queryFunction,
30849
+ config: this.config,
30787
30850
  language: this.language,
30788
30851
  providerSettings: this.providerSettings,
30789
30852
  };
@@ -17,5 +17,5 @@ var patchBrowser = () => {
17
17
 
18
18
  patchBrowser().then(async (options) => {
19
19
  await globalScripts();
20
- return bootstrapLazy([["graphwise-reactodia",[[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);
20
+ return bootstrapLazy([["graphwise-reactodia",[[0,"graphwise-reactodia",{"currentRepository":[1,"current-repository"],"config":[16],"language":[1],"providerSettings":[16,"provider-settings"]},null,{"currentRepository":["onProviderSettingsChange"],"providerSettings":["onProviderSettingsChange"],"language":["onLanguageChange"]}]]]], options);
21
21
  });
@@ -5,7 +5,7 @@ import { g as globalScripts } from './app-globals-CalY52z6.js';
5
5
  const defineCustomElements = async (win, options) => {
6
6
  if (typeof window === 'undefined') return undefined;
7
7
  await globalScripts();
8
- return bootstrapLazy([["graphwise-reactodia",[[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);
8
+ return bootstrapLazy([["graphwise-reactodia",[[0,"graphwise-reactodia",{"currentRepository":[1,"current-repository"],"config":[16],"language":[1],"providerSettings":[16,"provider-settings"]},null,{"currentRepository":["onProviderSettingsChange"],"providerSettings":["onProviderSettingsChange"],"language":["onLanguageChange"]}]]]], options);
9
9
  };
10
10
 
11
11
  export { defineCustomElements };
@@ -1 +1 @@
1
- import{p as r,b as e}from"./p-Cypw7ydc.js";export{s as setNonce}from"./p-Cypw7ydc.js";import{g as t}from"./p-CalY52z6.js";(()=>{const e=import.meta.url,t={};return""!==e&&(t.resourcesUrl=new URL(".",e).href),r(t)})().then((async r=>(await t(),e([["p-b10c344f",[[0,"graphwise-reactodia",{currentRepository:[1,"current-repository"],queryFunction:[16,"query-function"],language:[1],providerSettings:[16,"provider-settings"]},null,{currentRepository:["onProviderSettingsChange"],providerSettings:["onProviderSettingsChange"],language:["onLanguageChange"]}]]]],r))));
1
+ import{p as e,b as r}from"./p-Cypw7ydc.js";export{s as setNonce}from"./p-Cypw7ydc.js";import{g as t}from"./p-CalY52z6.js";(()=>{const r=import.meta.url,t={};return""!==r&&(t.resourcesUrl=new URL(".",r).href),e(t)})().then((async e=>(await t(),r([["p-eb362faa",[[0,"graphwise-reactodia",{currentRepository:[1,"current-repository"],config:[16],language:[1],providerSettings:[16,"provider-settings"]},null,{currentRepository:["onProviderSettingsChange"],providerSettings:["onProviderSettingsChange"],language:["onLanguageChange"]}]]]],e))));