graphwise-reactodia 0.0.1-TR7 → 0.0.1-TR9

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 +32 -0
  2. package/dist/cjs/graphwise-reactodia.cjs.entry.js +309 -41
  3. package/dist/cjs/index.cjs.js +7 -0
  4. package/dist/collection/components/graphwise-reactodia/graphwise-reactodia.js +10 -10
  5. package/dist/collection/components/graphwise-reactodia/models/clear-diagram-storage-event.js +5 -0
  6. package/dist/collection/components/graphwise-reactodia/models/subscription-list.js +35 -0
  7. package/dist/collection/components/graphwise-reactodia/models/triple.js +1 -0
  8. package/dist/collection/components/graphwise-reactodia/providers/service/service-inject.js +15 -0
  9. package/dist/collection/components/graphwise-reactodia/providers/service/service.js +19 -0
  10. package/dist/collection/components/graphwise-reactodia/providers/service/service.provider.js +20 -0
  11. package/dist/collection/components/graphwise-reactodia/reactodia-app.js +61 -28
  12. package/dist/collection/components/graphwise-reactodia/services/diagram/diagram.service.js +54 -0
  13. package/dist/collection/components/graphwise-reactodia/services/diagram-storage/diagram-storage.service.js +55 -0
  14. package/dist/collection/components/graphwise-reactodia/services/event/event.service.js +35 -0
  15. package/dist/collection/components/graphwise-reactodia/services/window/window.service.js +24 -0
  16. package/dist/collection/components/graphwise-reactodia/testing/storage.mock.js +35 -0
  17. package/dist/collection/index.js +1 -1
  18. package/dist/collection/pages/graphwise-reactodia/main.js +17 -7
  19. package/dist/esm/graphwise-reactodia.entry.js +306 -38
  20. package/dist/esm/index.js +6 -0
  21. package/dist/graphwise-reactodia/graphwise-reactodia.esm.js +1 -1
  22. package/dist/graphwise-reactodia/index.esm.js +1 -0
  23. package/dist/graphwise-reactodia/p-5b907998.entry.js +1 -0
  24. package/dist/types/components/graphwise-reactodia/i18n/translations.d.ts +2 -6
  25. package/dist/types/components/graphwise-reactodia/models/clear-diagram-storage-event.d.ts +5 -0
  26. package/dist/types/components/graphwise-reactodia/models/reactodia-app-props.d.ts +6 -7
  27. package/dist/types/components/graphwise-reactodia/models/reactodia-config.d.ts +8 -6
  28. package/dist/types/components/graphwise-reactodia/models/subscription-list.d.ts +26 -0
  29. package/dist/types/components/graphwise-reactodia/models/subscription.d.ts +4 -0
  30. package/dist/types/components/graphwise-reactodia/models/{reactodia-seed-link.d.ts → triple.d.ts} +2 -6
  31. package/dist/types/components/graphwise-reactodia/providers/service/service-inject.d.ts +13 -0
  32. package/dist/types/components/graphwise-reactodia/providers/service/service.d.ts +28 -0
  33. package/dist/types/components/graphwise-reactodia/providers/service/service.provider.d.ts +16 -0
  34. package/dist/types/components/graphwise-reactodia/services/diagram/diagram.service.d.ts +26 -0
  35. package/dist/types/components/graphwise-reactodia/services/diagram-storage/diagram-storage.service.d.ts +26 -0
  36. package/dist/types/components/graphwise-reactodia/services/event/event.service.d.ts +14 -0
  37. package/dist/types/components/graphwise-reactodia/services/window/window.service.d.ts +7 -0
  38. package/dist/types/components/graphwise-reactodia/testing/storage.mock.d.ts +18 -0
  39. package/dist/types/index.d.ts +1 -1
  40. package/package.json +9 -3
  41. package/dist/graphwise-reactodia/p-eb362faa.entry.js +0 -1
  42. /package/dist/collection/components/graphwise-reactodia/models/{reactodia-seed-link.js → subscription.js} +0 -0
@@ -1,4 +1,5 @@
1
1
  import { r as registerInstance, h, H as Host, g as getElement } from './index-Cypw7ydc.js';
2
+ import { CLEAR_DIAGRAM_STORAGE_EVENT } from './index.js';
2
3
 
3
4
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
5
 
@@ -18577,11 +18578,15 @@ function addWatermark(svg, viewBox, watermarkSvg) {
18577
18578
  image.setAttribute("opacity", "0.3");
18578
18579
  svg.insertBefore(image, svg.firstChild);
18579
18580
  }
18581
+ function stripPseudoElements(selectorText) {
18582
+ if (!selectorText.includes("::")) return selectorText;
18583
+ return selectorText.split(",").map((selector) => selector.replace(/::[a-zA-Z-]+/g, "").trim()).filter(Boolean).join(", ");
18584
+ }
18580
18585
  function collectAppliedCssFromDocument(targetSubtree) {
18581
18586
  const appliedRules = [];
18582
18587
  enumerateStylesheets((rule) => {
18583
- const selectorWithoutPseudo = rule.selectorText.replace(/::[a-zA-Z-]+$/, "");
18584
- if (targetSubtree.querySelector(selectorWithoutPseudo)) appliedRules.push(rule);
18588
+ const selector = stripPseudoElements(rule.selectorText);
18589
+ if (selector && targetSubtree.querySelector(selector)) appliedRules.push(rule);
18585
18590
  });
18586
18591
  return appliedRules;
18587
18592
  }
@@ -30640,6 +30645,241 @@ const TRANSLATIONS = {
30640
30645
  [LanguageKey.FR]: frTranslation
30641
30646
  };
30642
30647
 
30648
+ /**
30649
+ * Provider for all {@link Service} instances. Services are singletons: there is only one
30650
+ * instance of each service, created on demand and cached here so every consumer shares it.
30651
+ */
30652
+ class ServiceProvider {
30653
+ /**
30654
+ * Returns the instance of the given service type, creating and caching it on first request.
30655
+ *
30656
+ * @param type The service type to retrieve.
30657
+ * @returns The shared instance of the service.
30658
+ * @template T The type of the service to retrieve.
30659
+ */
30660
+ static get(type) {
30661
+ if (!ServiceProvider.SERVICE_INSTANCES.has(type.ID)) {
30662
+ ServiceProvider.SERVICE_INSTANCES.set(type.ID, new type());
30663
+ }
30664
+ return ServiceProvider.SERVICE_INSTANCES.get(type.ID);
30665
+ }
30666
+ }
30667
+ ServiceProvider.SERVICE_INSTANCES = new Map();
30668
+
30669
+ /**
30670
+ * Injects the singleton instance of the given service class from the {@link ServiceProvider}.
30671
+ *
30672
+ * @param serviceClass The class of the service to inject.
30673
+ * @returns The shared instance of the specified service class.
30674
+ * @template T The type of the service to inject.
30675
+ * @example
30676
+ * ```typescript
30677
+ * const diagramStateService = service(DiagramStateService);
30678
+ * ```
30679
+ */
30680
+ function service(serviceClass) {
30681
+ return ServiceProvider.get(serviceClass);
30682
+ }
30683
+
30684
+ /**
30685
+ * Decorator for a service class.
30686
+ * It receives the class and simply type checks it with the {@link Service} interface.
30687
+ * Works as a contract, which enforces the service class to have a static ID member.
30688
+ * We can't simply implement the interface, since this will enforce the ID to be an instance member, which is not what we want.
30689
+ *
30690
+ * @param _serviceClass The decorated service class, checked for its ID and discarded.
30691
+ * @template T The type of the service instance.
30692
+ * @example
30693
+ * ```TypeScript
30694
+ * @Service
30695
+ * export class WindowService {
30696
+ * static readonly ID = 'WindowService';
30697
+ * }
30698
+ * ```
30699
+ */
30700
+ function Service(_serviceClass) {
30701
+ // no implementation needed. We only use the type checking of the parameter
30702
+ }
30703
+
30704
+ var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
30705
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
30706
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
30707
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
30708
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
30709
+ };
30710
+ var DiagramService_1;
30711
+ /**
30712
+ * Service for diagram related operations and subscriptions
30713
+ */
30714
+ let DiagramService = DiagramService_1 = class DiagramService {
30715
+ /**
30716
+ * Subscribes to diagram changes. On every debounced change the current layout is
30717
+ * exported and passed to the callback.
30718
+ * Debounce time for the callback trigger is needed, because certain events (like moving a node) can trigger
30719
+ * multiple `historyChanged` events in a short time.
30720
+ *
30721
+ * @param model The diagram model to observe.
30722
+ * @param onChangeCallback Called with the exported layout when the diagram changes.
30723
+ * @returns A {@link Subscription} that, when called, removes the listener and drops any
30724
+ * pending notification.
30725
+ */
30726
+ subscribeToDiagramChange(model, onChangeCallback) {
30727
+ let notifyTimer;
30728
+ const onHistoryChange = () => {
30729
+ if (notifyTimer) {
30730
+ clearTimeout(notifyTimer);
30731
+ }
30732
+ notifyTimer = setTimeout(() => {
30733
+ notifyTimer = undefined;
30734
+ onChangeCallback(model.exportLayout());
30735
+ }, DiagramService_1.NOTIFY_DEBOUNCE_MS);
30736
+ };
30737
+ model.history.events.on(DiagramService_1.HISTORY_CHANGED_EVENT, onHistoryChange);
30738
+ return () => {
30739
+ model.history.events.off(DiagramService_1.HISTORY_CHANGED_EVENT, onHistoryChange);
30740
+ if (notifyTimer) {
30741
+ clearTimeout(notifyTimer);
30742
+ }
30743
+ };
30744
+ }
30745
+ };
30746
+ DiagramService.ID = 'DiagramService';
30747
+ DiagramService.NOTIFY_DEBOUNCE_MS = 300;
30748
+ DiagramService.HISTORY_CHANGED_EVENT = 'historyChanged';
30749
+ DiagramService = DiagramService_1 = __decorate$3([
30750
+ Service
30751
+ ], DiagramService);
30752
+
30753
+ var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
30754
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
30755
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
30756
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
30757
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
30758
+ };
30759
+ /**
30760
+ * Service that provides access to browser window-related functionality.
30761
+ */
30762
+ let WindowService = class WindowService {
30763
+ getWindow() {
30764
+ return window;
30765
+ }
30766
+ };
30767
+ WindowService.ID = 'WindowService';
30768
+ WindowService = __decorate$2([
30769
+ Service
30770
+ ], WindowService);
30771
+
30772
+ var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
30773
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
30774
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
30775
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
30776
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
30777
+ };
30778
+ var DiagramStorageService_1;
30779
+ /**
30780
+ * Service for local store-related diagram operations
30781
+ */
30782
+ let DiagramStorageService = DiagramStorageService_1 = class DiagramStorageService {
30783
+ /**
30784
+ * Load the persisted diagram from the local store, or `undefined` when nothing is stored (or the stored value
30785
+ * is unreadable).
30786
+ */
30787
+ load() {
30788
+ const raw = this.storage.getItem(DiagramStorageService_1.STORAGE_KEY);
30789
+ if (!raw) {
30790
+ return undefined;
30791
+ }
30792
+ return JSON.parse(raw);
30793
+ }
30794
+ /**
30795
+ * Persists the given diagram serialization.
30796
+ */
30797
+ save(diagram) {
30798
+ this.storage.setItem(DiagramStorageService_1.STORAGE_KEY, JSON.stringify(diagram));
30799
+ }
30800
+ /**
30801
+ * Removes the persisted diagram. Used when a new view (a seed) should take precedence over
30802
+ * previously saved edits.
30803
+ */
30804
+ clear() {
30805
+ this.storage.removeItem(DiagramStorageService_1.STORAGE_KEY);
30806
+ }
30807
+ /**
30808
+ * Local storage getter
30809
+ */
30810
+ get storage() {
30811
+ return service(WindowService).getWindow().localStorage;
30812
+ }
30813
+ };
30814
+ DiagramStorageService.ID = 'DiagramStorageService';
30815
+ DiagramStorageService.STORAGE_KEY = 'diagram.state';
30816
+ DiagramStorageService = DiagramStorageService_1 = __decorate$1([
30817
+ Service
30818
+ ], DiagramStorageService);
30819
+
30820
+ var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
30821
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
30822
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
30823
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
30824
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
30825
+ };
30826
+ /**
30827
+ * Service for event based operations
30828
+ */
30829
+ let EventService = class EventService {
30830
+ /**
30831
+ * Subscribes to the host's "clear persisted diagram" command.
30832
+ *
30833
+ * @param onClear Called whenever the event fires.
30834
+ * @returns A {@link Subscription} that, when called, removes the listener.
30835
+ */
30836
+ subscribeToClearDiagramStorage(onClear) {
30837
+ const target = service(WindowService).getWindow();
30838
+ target.addEventListener(CLEAR_DIAGRAM_STORAGE_EVENT, onClear);
30839
+ return () => target.removeEventListener(CLEAR_DIAGRAM_STORAGE_EVENT, onClear);
30840
+ }
30841
+ };
30842
+ EventService.ID = 'EventService';
30843
+ EventService = __decorate([
30844
+ Service
30845
+ ], EventService);
30846
+
30847
+ /**
30848
+ * A collection of {@link Subscription}s that can be released together. Components collect the
30849
+ * subscriptions they open and call {@link unsubscribeAll} on teardown so nothing is left
30850
+ * listening.
30851
+ */
30852
+ class SubscriptionList {
30853
+ constructor(subscriptions = []) {
30854
+ this.items = subscriptions;
30855
+ }
30856
+ /**
30857
+ * Adds a subscription to the list.
30858
+ */
30859
+ add(subscription) {
30860
+ this.items.push(subscription);
30861
+ }
30862
+ /**
30863
+ * Adds multiple subscriptions to the list.
30864
+ */
30865
+ addAll(subscriptions) {
30866
+ this.items.push(...subscriptions);
30867
+ }
30868
+ /**
30869
+ * Removes a subscription from the list without unsubscribing it.
30870
+ */
30871
+ remove(subscription) {
30872
+ this.items = this.items.filter((sub) => sub !== subscription);
30873
+ }
30874
+ /**
30875
+ * Calls every subscription (unsubscribing it) and clears the list.
30876
+ */
30877
+ unsubscribeAll() {
30878
+ this.items.forEach((subscription) => subscription());
30879
+ this.items = [];
30880
+ }
30881
+ }
30882
+
30643
30883
  /**
30644
30884
  * Reactodia ships English as its built-in default bundle, so English needs no override.
30645
30885
  * Other languages are layered on top as partial bundles; unknown codes fall back to English.
@@ -30657,6 +30897,12 @@ function translationsForLanguage(language) {
30657
30897
  * runs outside React and therefore cannot call the `useWorkspace` hook.
30658
30898
  */
30659
30899
  let workspaceContext = null;
30900
+ /**
30901
+ * Active listeners that persist diagram edits to local storage. Populated when the workspace
30902
+ * mounts and released in {@link unmountReactodia}, so persistence follows the same lifecycle as
30903
+ * the React root.
30904
+ */
30905
+ const subscriptions = new SubscriptionList();
30660
30906
  /**
30661
30907
  * Builds a Reactodia {@link SparqlDataProvider} for the given endpoint using the supplied
30662
30908
  * query preset. The host owns the query configuration and passes it in via props; when none
@@ -30667,15 +30913,16 @@ function createDataProvider(props) {
30667
30913
  return new SparqlDataProvider({
30668
30914
  endpointUrl: currentRepository,
30669
30915
  queryMethod: 'POST',
30670
- queryFunction: config.queryFunction,
30916
+ queryFunction: config.queryFunction
30671
30917
  }, providerSettings);
30672
30918
  }
30673
30919
  /**
30674
30920
  * Places the seed entities on the canvas. Each IRI is added as a placeholder element, and data is then loaded for the
30675
30921
  * respective nodes using the {@link DataDiagramModel.requestData} method.
30676
30922
  */
30677
- async function seedCanvas(context, seed, signal) {
30923
+ async function seedIrisToCanvas(context, dataProvider, seed, signal) {
30678
30924
  const { model, performLayout } = context;
30925
+ await model.createNewDiagram({ dataProvider, signal });
30679
30926
  for (const iri of seed) {
30680
30927
  model.createElement(iri);
30681
30928
  }
@@ -30683,18 +30930,13 @@ async function seedCanvas(context, seed, signal) {
30683
30930
  await performLayout({ signal });
30684
30931
  }
30685
30932
  /**
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.
30933
+ * Places a pre-resolved graph (e.g. a CONSTRUCT query result) on the canvas. The difference between this and
30934
+ * {@link seedIrisToCanvas} is that this method does not request link data from the SPARQL endpoint, since describe/construct
30935
+ * queries are not persisted in the DB. Here we expect provided links and query for element data only
30695
30936
  */
30696
- async function seedGraphCanvas(context, links, signal) {
30937
+ async function seedGraphToCanvas(context, dataProvider, links, signal) {
30697
30938
  const { model, performLayout } = context;
30939
+ await model.createNewDiagram({ dataProvider, signal });
30698
30940
  const uniqueIris = new Set();
30699
30941
  links.forEach((link) => {
30700
30942
  var _a;
@@ -30712,11 +30954,30 @@ async function seedGraphCanvas(context, links, signal) {
30712
30954
  });
30713
30955
  });
30714
30956
  });
30715
- // Request data only for elements.
30716
- // Link data is not available in the DB, since we are displaying construct/describe queries
30717
30957
  await model.requestElementData(Array.from(uniqueIris));
30718
30958
  await performLayout({ signal });
30719
30959
  }
30960
+ /**
30961
+ * Subscribes to the model's changes so diagram edits are persisted to local storage. The
30962
+ * subscription is tracked in {@link subscriptions} so it is released together with the React
30963
+ * root in {@link unmountReactodia}.
30964
+ */
30965
+ function onDiagramChange(model) {
30966
+ const storage = service(DiagramStorageService);
30967
+ const diagramService = service(DiagramService);
30968
+ subscriptions.add(diagramService.subscribeToDiagramChange(model, (diagram) => storage.save(diagram)));
30969
+ }
30970
+ /**
30971
+ * Subscribes to the host's "clear persisted diagram" command so the saved layout is dropped on
30972
+ * request (e.g. before a fresh seed should take precedence over previously saved edits). The
30973
+ * subscription is tracked in {@link subscriptions} so it is released together with the React
30974
+ * root in {@link unmountReactodia}.
30975
+ */
30976
+ function onClearDiagramStorage() {
30977
+ const storage = service(DiagramStorageService);
30978
+ const eventService = service(EventService);
30979
+ subscriptions.add(eventService.subscribeToClearDiagramStorage(() => storage.clear()));
30980
+ }
30720
30981
  /**
30721
30982
  * The Reactodia workspace React component.
30722
30983
  *
@@ -30727,26 +30988,32 @@ async function seedGraphCanvas(context, links, signal) {
30727
30988
  * provider's lookup. With a seed, the seeded nodes are placed on the canvas on startup.
30728
30989
  */
30729
30990
  function ReactodiaApp(props) {
30730
- const { language, initialDiagram, config } = props;
30991
+ const { language, config } = props;
30992
+ const currentDiagram = props.isReload ? exportReactodiaLayout() : undefined;
30731
30993
  const { onMount } = useLoadedWorkspace(async ({ context, signal }) => {
30732
30994
  var _a, _b;
30733
30995
  workspaceContext = context;
30734
30996
  const { model } = context;
30997
+ onDiagramChange(model);
30998
+ onClearDiagramStorage();
30735
30999
  const dataProvider = createDataProvider(props);
30736
- // A language change remounts this component to rebuild the workspace with the new
30737
- // translation bundle; restoring the exported diagram keeps the user's canvas intact.
30738
- // This is done because there is no existing mechanism to re-translate the UI at runtime (not for the UI labels at least)
30739
- if (initialDiagram) {
30740
- await model.importLayout({ dataProvider, diagram: initialDiagram, signal });
31000
+ const isReload = props.isReload;
31001
+ const savedDiagram = service(DiagramStorageService).load();
31002
+ if (isReload) {
31003
+ // Simply reload without using the current state. This may happen when the user switches the language at runtime.
31004
+ // since there is no existing mechanism to re-translate the UI at runtime (not for the UI labels at least)
31005
+ await model.importLayout({ dataProvider, diagram: currentDiagram, signal });
31006
+ }
31007
+ else if ((_a = config.seedIris) === null || _a === void 0 ? void 0 : _a.length) {
31008
+ await seedIrisToCanvas(context, dataProvider, config.seedIris, signal);
31009
+ }
31010
+ else if ((_b = config.seedGraph) === null || _b === void 0 ? void 0 : _b.length) {
31011
+ await seedGraphToCanvas(context, dataProvider, config.seedGraph, signal);
30741
31012
  }
30742
31013
  else {
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
- }
31014
+ // Restore the previously saved layout when present, otherwise start empty. Either way this binds the
31015
+ // data provider (savedDiagram is undefined -> empty diagram), so the unified search/lookup works.
31016
+ await model.importLayout({ dataProvider, diagram: savedDiagram, signal });
30750
31017
  }
30751
31018
  }, [language]);
30752
31019
  /**
@@ -30797,6 +31064,7 @@ function exportReactodiaLayout() {
30797
31064
  * Unmounts the Reactodia application.
30798
31065
  */
30799
31066
  function unmountReactodia(root) {
31067
+ subscriptions.unsubscribeAll();
30800
31068
  root.unmount();
30801
31069
  }
30802
31070
 
@@ -30815,13 +31083,13 @@ const GraphwiseReactodia = class {
30815
31083
  }
30816
31084
  onLanguageChange() {
30817
31085
  // The translations are evaluated by the workspace at construction, so the only way
30818
- // to re-translate the UI is to re-create the graph. We carry the
30819
- // current diagram across the remount so switching languages does not wipe the canvas.
30820
- const diagram = exportReactodiaLayout();
30821
- this.renderGraph(diagram);
31086
+ // to re-translate the UI is to re-create the graph.
31087
+ this.renderGraph(true);
30822
31088
  }
30823
31089
  connectedCallback() {
30824
- this.renderGraph();
31090
+ if (this.config) {
31091
+ this.renderGraph();
31092
+ }
30825
31093
  }
30826
31094
  disconnectedCallback() {
30827
31095
  if (this.reactRoot) {
@@ -30830,9 +31098,9 @@ const GraphwiseReactodia = class {
30830
31098
  }
30831
31099
  }
30832
31100
  render() {
30833
- return (h(Host, { key: '63c58ee1d28c4866aa66d3dcf4893879de4d09f6' }));
31101
+ return (h(Host, { key: 'b33d3709a5d7b1fdde8d528d036d9dbc962d6c76' }));
30834
31102
  }
30835
- renderGraph(initialDiagram) {
31103
+ renderGraph(isReloading) {
30836
31104
  var _a;
30837
31105
  if (!this.currentRepository) {
30838
31106
  throw new Error('currentRepository is required');
@@ -30844,13 +31112,13 @@ const GraphwiseReactodia = class {
30844
31112
  return;
30845
31113
  }
30846
31114
  const props = {
30847
- initialDiagram,
31115
+ isReload: isReloading,
30848
31116
  currentRepository: this.currentRepository,
30849
31117
  config: this.config,
30850
31118
  language: this.language,
30851
31119
  providerSettings: this.providerSettings,
30852
31120
  };
30853
- if (this.reactRoot && !initialDiagram) {
31121
+ if (this.reactRoot && !isReloading) {
30854
31122
  void updateReactodia(props);
30855
31123
  }
30856
31124
  else {
package/dist/esm/index.js CHANGED
@@ -1 +1,7 @@
1
+ /**
2
+ * Event name for clearing the local store state of the diagram. There is an event listener listening for it, which
3
+ * will clear the local store state, whenever this event is fired.
4
+ */
5
+ const CLEAR_DIAGRAM_STORAGE_EVENT = 'graphwise-reactodia:clear-diagram-storage';
1
6
 
7
+ export { CLEAR_DIAGRAM_STORAGE_EVENT };
@@ -1 +1 @@
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))));
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-5b907998",[[0,"graphwise-reactodia",{currentRepository:[1,"current-repository"],config:[16],language:[1],providerSettings:[16,"provider-settings"]},null,{currentRepository:["onProviderSettingsChange"],providerSettings:["onProviderSettingsChange"],language:["onLanguageChange"]}]]]],r))));
@@ -0,0 +1 @@
1
+ const a="graphwise-reactodia:clear-diagram-storage";export{a as CLEAR_DIAGRAM_STORAGE_EVENT}