graphwise-reactodia 0.0.1-TR17 → 0.0.1-TR19
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/README.md +31 -8
- package/dist/cjs/{error-code-NpXlqCEN.js → error-code-BjU_V9e8.js} +9 -0
- package/dist/cjs/graphwise-reactodia.cjs.entry.js +80 -56
- package/dist/cjs/index.cjs.js +8 -4
- package/dist/collection/components/graphwise-reactodia/graphwise-reactodia.js +14 -12
- package/dist/collection/components/graphwise-reactodia/models/error/error-report.js +1 -4
- package/dist/collection/components/graphwise-reactodia/models/event/event-detail.js +4 -0
- package/dist/collection/components/graphwise-reactodia/models/event/event-type.js +8 -0
- package/dist/collection/components/graphwise-reactodia/reactodia-app.js +17 -2
- package/dist/collection/components/graphwise-reactodia/services/error/error.service.js +5 -16
- package/dist/collection/components/graphwise-reactodia/services/event/event.service.js +23 -0
- package/dist/collection/index.js +2 -1
- package/dist/collection/pages/graphwise-reactodia/main.js +14 -2
- package/dist/esm/{error-code-7lGYbTwb.js → error-code-HfC639tc.js} +10 -1
- package/dist/esm/graphwise-reactodia.entry.js +80 -56
- package/dist/esm/index.js +4 -4
- package/dist/graphwise-reactodia/graphwise-reactodia.esm.js +1 -1
- package/dist/graphwise-reactodia/index.esm.js +1 -1
- package/dist/graphwise-reactodia/p-HfC639tc.js +1 -0
- package/dist/graphwise-reactodia/p-bf7f09d2.entry.js +1 -0
- package/dist/types/components/graphwise-reactodia/graphwise-reactodia.d.ts +4 -4
- package/dist/types/components/graphwise-reactodia/models/error/error-report.d.ts +0 -4
- package/dist/types/components/graphwise-reactodia/models/event/event-callback.d.ts +5 -0
- package/dist/types/components/graphwise-reactodia/models/event/event-detail.d.ts +55 -0
- package/dist/types/components/graphwise-reactodia/models/event/event-type.d.ts +7 -0
- package/dist/types/components/graphwise-reactodia/services/error/error.service.d.ts +1 -10
- package/dist/types/components/graphwise-reactodia/services/event/event.service.d.ts +16 -0
- package/dist/types/components.d.ts +5 -5
- package/dist/types/index.d.ts +3 -1
- package/package.json +1 -1
- package/dist/graphwise-reactodia/p-7lGYbTwb.js +0 -1
- package/dist/graphwise-reactodia/p-ec30185a.entry.js +0 -1
- package/dist/types/components/graphwise-reactodia/models/error/error-callback.d.ts +0 -5
- /package/dist/collection/components/graphwise-reactodia/models/{error/error-callback.js → event/event-callback.js} +0 -0
package/README.md
CHANGED
|
@@ -66,19 +66,42 @@ persisted in the DB, so they can't be fetched lazily and must be supplied by the
|
|
|
66
66
|
|
|
67
67
|
When both are supplied `seedGraph` takes precedence over `seedIris`.
|
|
68
68
|
|
|
69
|
-
##
|
|
69
|
+
## Events
|
|
70
|
+
|
|
71
|
+
The element sends every event to the host through one DOM event, `graphwiseReactodiaEvent`. The event
|
|
72
|
+
only informs the host and it bubbles. Its name is exported as `GRAPHWISE_REACTODIA_EVENT`.
|
|
73
|
+
|
|
74
|
+
`detail` is an `EventDetail`: `{type, payload}`. `type` is an `EventType`; `payload` depends on it:
|
|
70
75
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
`
|
|
76
|
+
| `type` | `payload` | Dispatched when |
|
|
77
|
+
|---------------|---------------|-------------------------------------|
|
|
78
|
+
| `error` | `ErrorReport` | An error is reported. |
|
|
79
|
+
| `text-search` | none | The user searches entities by text. |
|
|
74
80
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
81
|
+
Checking `type` narrows `payload`:
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
element.addEventListener(GRAPHWISE_REACTODIA_EVENT, (event) => {
|
|
85
|
+
const detail = (event as CustomEvent<EventDetail>).detail;
|
|
86
|
+
if (detail.type === EventType.ERROR) {
|
|
87
|
+
const {code, error} = detail.payload; // an ErrorReport
|
|
88
|
+
}
|
|
78
89
|
});
|
|
79
90
|
```
|
|
80
91
|
|
|
81
|
-
`
|
|
92
|
+
`EventDetail<T>` is one event, e.g. for a handler of a single type:
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
function onError(detail: EventDetail<EventType.ERROR>): void {
|
|
96
|
+
const {code, error} = detail.payload;
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Error handling
|
|
101
|
+
|
|
102
|
+
The element dispatches an `error` event for every error it reports; the codes below list them.
|
|
103
|
+
|
|
104
|
+
`payload` is an `ErrorReport`:
|
|
82
105
|
|
|
83
106
|
| Field | Description |
|
|
84
107
|
|---------|-----------------------------------------------------------------------------------------|
|
|
@@ -6,6 +6,15 @@
|
|
|
6
6
|
*/
|
|
7
7
|
const CLEAR_DIAGRAM_STORAGE_EVENT = 'graphwise-reactodia:clear-diagram-storage';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* The kind of event the wrapper announces to the host. It selects the payload of an {@link EventDetail}.
|
|
11
|
+
*/
|
|
12
|
+
exports.EventType = void 0;
|
|
13
|
+
(function (EventType) {
|
|
14
|
+
EventType["ERROR"] = "error";
|
|
15
|
+
EventType["TEXT_SEARCH"] = "text-search";
|
|
16
|
+
})(exports.EventType || (exports.EventType = {}));
|
|
17
|
+
|
|
9
18
|
/**
|
|
10
19
|
* The stable category of a reported error. The host uses it to choose its own message.
|
|
11
20
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var index = require('./index-DtzCybH4.js');
|
|
4
|
-
var errorCode = require('./error-code-
|
|
4
|
+
var errorCode = require('./error-code-BjU_V9e8.js');
|
|
5
5
|
|
|
6
6
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
7
7
|
|
|
@@ -31475,12 +31475,63 @@ var __decorate$3 = (undefined && undefined.__decorate) || function (decorators,
|
|
|
31475
31475
|
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;
|
|
31476
31476
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
31477
31477
|
};
|
|
31478
|
+
/**
|
|
31479
|
+
* Service for event based operations
|
|
31480
|
+
*/
|
|
31481
|
+
let EventService = class EventService {
|
|
31482
|
+
/**
|
|
31483
|
+
* Announces an event to the host.
|
|
31484
|
+
*
|
|
31485
|
+
* @param detail The event detail.
|
|
31486
|
+
*/
|
|
31487
|
+
emit(detail) {
|
|
31488
|
+
var _a;
|
|
31489
|
+
(_a = this.callback) === null || _a === void 0 ? void 0 : _a.call(this, detail);
|
|
31490
|
+
}
|
|
31491
|
+
/**
|
|
31492
|
+
* Subscribes to the emitted events, replacing the previous subscriber.
|
|
31493
|
+
*
|
|
31494
|
+
* @param callback Called with every emitted event.
|
|
31495
|
+
* @returns A {@link Subscription} that, when called, removes the callback, unless it has already been replaced.
|
|
31496
|
+
*/
|
|
31497
|
+
subscribe(callback) {
|
|
31498
|
+
this.callback = callback;
|
|
31499
|
+
return () => {
|
|
31500
|
+
if (this.callback === callback) {
|
|
31501
|
+
this.callback = undefined;
|
|
31502
|
+
}
|
|
31503
|
+
};
|
|
31504
|
+
}
|
|
31505
|
+
/**
|
|
31506
|
+
* Subscribes to the host's "clear persisted diagram" command.
|
|
31507
|
+
*
|
|
31508
|
+
* @param onClear Called whenever the event fires.
|
|
31509
|
+
* @returns A {@link Subscription} that, when called, removes the listener.
|
|
31510
|
+
*/
|
|
31511
|
+
subscribeToClearDiagramStorage(onClear) {
|
|
31512
|
+
const target = service(WindowService).getWindow();
|
|
31513
|
+
target.addEventListener(errorCode.CLEAR_DIAGRAM_STORAGE_EVENT, onClear);
|
|
31514
|
+
return () => target.removeEventListener(errorCode.CLEAR_DIAGRAM_STORAGE_EVENT, onClear);
|
|
31515
|
+
}
|
|
31516
|
+
};
|
|
31517
|
+
EventService.ID = 'EventService';
|
|
31518
|
+
EventService = __decorate$3([
|
|
31519
|
+
Service
|
|
31520
|
+
], EventService);
|
|
31521
|
+
|
|
31522
|
+
var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
31523
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
31524
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
31525
|
+
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;
|
|
31526
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
31527
|
+
};
|
|
31478
31528
|
var ErrorService_1;
|
|
31479
31529
|
/**
|
|
31480
31530
|
* Service that collects the failures of the wrapper and the fork, so they can be announced to the host.
|
|
31481
31531
|
*/
|
|
31482
31532
|
let ErrorService = ErrorService_1 = class ErrorService {
|
|
31483
31533
|
constructor() {
|
|
31534
|
+
this.eventService = service(EventService);
|
|
31484
31535
|
this.reported = new WeakSet();
|
|
31485
31536
|
}
|
|
31486
31537
|
/**
|
|
@@ -31506,27 +31557,12 @@ let ErrorService = ErrorService_1 = class ErrorService {
|
|
|
31506
31557
|
* @param thrown The thrown value.
|
|
31507
31558
|
*/
|
|
31508
31559
|
report(code, thrown) {
|
|
31509
|
-
var _a;
|
|
31510
31560
|
const causes = this.causeChain(thrown);
|
|
31511
31561
|
if (this.isAbortedOrAlreadyReported(causes)) {
|
|
31512
31562
|
return;
|
|
31513
31563
|
}
|
|
31514
31564
|
causes.forEach((cause) => this.reported.add(cause));
|
|
31515
|
-
|
|
31516
|
-
}
|
|
31517
|
-
/**
|
|
31518
|
-
* Subscribes to the reported errors, replacing the previous subscriber.
|
|
31519
|
-
*
|
|
31520
|
-
* @param callback Called with every reported error.
|
|
31521
|
-
* @returns A {@link Subscription} that, when called, removes the callback, unless it has already been replaced.
|
|
31522
|
-
*/
|
|
31523
|
-
subscribe(callback) {
|
|
31524
|
-
this.callback = callback;
|
|
31525
|
-
return () => {
|
|
31526
|
-
if (this.callback === callback) {
|
|
31527
|
-
this.callback = undefined;
|
|
31528
|
-
}
|
|
31529
|
-
};
|
|
31565
|
+
this.eventService.emit({ type: errorCode.EventType.ERROR, payload: { code, error: thrown } });
|
|
31530
31566
|
}
|
|
31531
31567
|
/**
|
|
31532
31568
|
* Whether any link of the given cause chain is an abort or is already reported.
|
|
@@ -31549,11 +31585,11 @@ let ErrorService = ErrorService_1 = class ErrorService {
|
|
|
31549
31585
|
};
|
|
31550
31586
|
ErrorService.ID = 'ErrorService';
|
|
31551
31587
|
ErrorService.ABORT_ERROR_NAME = 'AbortError';
|
|
31552
|
-
ErrorService = ErrorService_1 = __decorate$
|
|
31588
|
+
ErrorService = ErrorService_1 = __decorate$2([
|
|
31553
31589
|
Service
|
|
31554
31590
|
], ErrorService);
|
|
31555
31591
|
|
|
31556
|
-
var __decorate$
|
|
31592
|
+
var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
31557
31593
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
31558
31594
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
31559
31595
|
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;
|
|
@@ -31611,37 +31647,10 @@ let DiagramStorageService = DiagramStorageService_1 = class DiagramStorageServic
|
|
|
31611
31647
|
};
|
|
31612
31648
|
DiagramStorageService.ID = 'DiagramStorageService';
|
|
31613
31649
|
DiagramStorageService.STORAGE_KEY = 'diagram.state';
|
|
31614
|
-
DiagramStorageService = DiagramStorageService_1 = __decorate$
|
|
31650
|
+
DiagramStorageService = DiagramStorageService_1 = __decorate$1([
|
|
31615
31651
|
Service
|
|
31616
31652
|
], DiagramStorageService);
|
|
31617
31653
|
|
|
31618
|
-
var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
31619
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
31620
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
31621
|
-
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;
|
|
31622
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
31623
|
-
};
|
|
31624
|
-
/**
|
|
31625
|
-
* Service for event based operations
|
|
31626
|
-
*/
|
|
31627
|
-
let EventService = class EventService {
|
|
31628
|
-
/**
|
|
31629
|
-
* Subscribes to the host's "clear persisted diagram" command.
|
|
31630
|
-
*
|
|
31631
|
-
* @param onClear Called whenever the event fires.
|
|
31632
|
-
* @returns A {@link Subscription} that, when called, removes the listener.
|
|
31633
|
-
*/
|
|
31634
|
-
subscribeToClearDiagramStorage(onClear) {
|
|
31635
|
-
const target = service(WindowService).getWindow();
|
|
31636
|
-
target.addEventListener(errorCode.CLEAR_DIAGRAM_STORAGE_EVENT, onClear);
|
|
31637
|
-
return () => target.removeEventListener(errorCode.CLEAR_DIAGRAM_STORAGE_EVENT, onClear);
|
|
31638
|
-
}
|
|
31639
|
-
};
|
|
31640
|
-
EventService.ID = 'EventService';
|
|
31641
|
-
EventService = __decorate$1([
|
|
31642
|
-
Service
|
|
31643
|
-
], EventService);
|
|
31644
|
-
|
|
31645
31654
|
/**
|
|
31646
31655
|
* A collection of {@link Subscription}s that can be released together. Components collect the
|
|
31647
31656
|
* subscriptions they open and call {@link unsubscribeAll} on teardown so nothing is left
|
|
@@ -31852,8 +31861,16 @@ const subscriptions = new SubscriptionList();
|
|
|
31852
31861
|
let diagramStorageSubscription;
|
|
31853
31862
|
const diagramService = service(DiagramService);
|
|
31854
31863
|
const diagramStorageService = service(DiagramStorageService);
|
|
31855
|
-
const eventService = service(EventService);
|
|
31864
|
+
const eventService$1 = service(EventService);
|
|
31856
31865
|
const errorService$1 = service(ErrorService);
|
|
31866
|
+
/**
|
|
31867
|
+
* Emits a {@link EventType.TEXT_SEARCH} event for each text lookup.
|
|
31868
|
+
*/
|
|
31869
|
+
function emitTextSearch(method, params) {
|
|
31870
|
+
if (method === 'lookup' && params.text) {
|
|
31871
|
+
eventService$1.emit({ type: errorCode.EventType.TEXT_SEARCH });
|
|
31872
|
+
}
|
|
31873
|
+
}
|
|
31857
31874
|
/**
|
|
31858
31875
|
* Reports every failed data provider call, unless the call was aborted, and passes the failure on to the caller.
|
|
31859
31876
|
*/
|
|
@@ -31872,7 +31889,7 @@ const reportDataFetchError = async (_method, params, body) => {
|
|
|
31872
31889
|
/**
|
|
31873
31890
|
* Builds a Reactodia {@link SparqlDataProvider} for the given endpoint using the supplied
|
|
31874
31891
|
* query preset. The host owns the query configuration and always passes it in via props.
|
|
31875
|
-
* The provider is decorated, so its failed calls are reported.
|
|
31892
|
+
* The provider is decorated, so its failed calls are reported and its text lookups emit an event.
|
|
31876
31893
|
*/
|
|
31877
31894
|
function createDataProvider(props) {
|
|
31878
31895
|
const { currentRepository, config, providerSettings } = props;
|
|
@@ -31881,7 +31898,13 @@ function createDataProvider(props) {
|
|
|
31881
31898
|
queryMethod: 'POST',
|
|
31882
31899
|
queryFunction: config.queryFunction
|
|
31883
31900
|
}, providerSettings);
|
|
31884
|
-
return new DecoratedDataProvider({
|
|
31901
|
+
return new DecoratedDataProvider({
|
|
31902
|
+
baseProvider,
|
|
31903
|
+
decorator: (method, params, body) => {
|
|
31904
|
+
emitTextSearch(method, params);
|
|
31905
|
+
return reportDataFetchError(method, params, body);
|
|
31906
|
+
}
|
|
31907
|
+
});
|
|
31885
31908
|
}
|
|
31886
31909
|
/**
|
|
31887
31910
|
* Places the seed entities on the canvas. Each IRI is added as a placeholder element, and data is then loaded for the
|
|
@@ -31949,7 +31972,7 @@ function subscribeToDiagramChange(model) {
|
|
|
31949
31972
|
* @param model The diagram model whose edits are persisted
|
|
31950
31973
|
*/
|
|
31951
31974
|
function onClearDiagramStorage(model) {
|
|
31952
|
-
subscriptions.add(eventService.subscribeToClearDiagramStorage(() => {
|
|
31975
|
+
subscriptions.add(eventService$1.subscribeToClearDiagramStorage(() => {
|
|
31953
31976
|
// re-subscribe, to avoid any pending debounced saves, which may write over the cleared diagram
|
|
31954
31977
|
subscribeToDiagramChange(model);
|
|
31955
31978
|
diagramStorageService.clear();
|
|
@@ -32070,10 +32093,11 @@ function unmountReactodia(root) {
|
|
|
32070
32093
|
const graphwiseReactodiaCss = "graphwise-reactodia{--_graphwise-reactodia-type-color-01:var(--graphwise-reactodia-type-color-01);--_graphwise-reactodia-type-color-02:var(--graphwise-reactodia-type-color-02);--_graphwise-reactodia-type-color-03:var(--graphwise-reactodia-type-color-03);--_graphwise-reactodia-type-color-04:var(--graphwise-reactodia-type-color-04);--_graphwise-reactodia-type-color-05:var(--graphwise-reactodia-type-color-05);--_graphwise-reactodia-type-color-06:var(--graphwise-reactodia-type-color-06);--_graphwise-reactodia-type-color-07:var(--graphwise-reactodia-type-color-07);--_graphwise-reactodia-type-color-08:var(--graphwise-reactodia-type-color-08);--_graphwise-reactodia-type-color-09:var(--graphwise-reactodia-type-color-09);--_graphwise-reactodia-type-color-10:var(--graphwise-reactodia-type-color-10);--_graphwise-reactodia-type-color-11:var(--graphwise-reactodia-type-color-11);--_graphwise-reactodia-type-color-12:var(--graphwise-reactodia-type-color-12);--_graphwise-reactodia-type-color-13:var(--graphwise-reactodia-type-color-13);--_graphwise-reactodia-type-color-14:var(--graphwise-reactodia-type-color-14);--_graphwise-reactodia-type-color-15:var(--graphwise-reactodia-type-color-15);--_graphwise-reactodia-type-color-16:var(--graphwise-reactodia-type-color-16);--_graphwise-reactodia-type-color-17:var(--graphwise-reactodia-type-color-17);--_graphwise-reactodia-type-color-18:var(--graphwise-reactodia-type-color-18);--_graphwise-reactodia-type-color-19:var(--graphwise-reactodia-type-color-19);--_graphwise-reactodia-type-color-20:var(--graphwise-reactodia-type-color-20);--_graphwise-reactodia-type-color-contrast:var(--graphwise-reactodia-type-color-contrast, #fff)}graphwise-reactodia{display:block;width:100%;height:100%}graphwise-reactodia .reactodia-container{position:relative;width:100%;height:100%}graphwise-reactodia .reactodia-selection-action__link{display:none}graphwise-reactodia .reactodia-standard-element__thumbnail:not(:has(img)){background:var(--reactodia-element-style-color);border-radius:50%;color:var(--_graphwise-reactodia-type-color-contrast)}";
|
|
32071
32094
|
|
|
32072
32095
|
const errorService = service(ErrorService);
|
|
32096
|
+
const eventService = service(EventService);
|
|
32073
32097
|
const GraphwiseReactodia = class {
|
|
32074
32098
|
constructor(hostRef) {
|
|
32075
32099
|
index.registerInstance(this, hostRef);
|
|
32076
|
-
this.
|
|
32100
|
+
this.eventEmitter = index.createEvent(this, "graphwiseReactodiaEvent");
|
|
32077
32101
|
this.subscriptions = new SubscriptionList();
|
|
32078
32102
|
/**
|
|
32079
32103
|
* UI language code (e.g. `en`, `fr`) for the Reactodia interface. Defaults to English.
|
|
@@ -32102,7 +32126,7 @@ const GraphwiseReactodia = class {
|
|
|
32102
32126
|
this.renderGraph(true);
|
|
32103
32127
|
}
|
|
32104
32128
|
connectedCallback() {
|
|
32105
|
-
this.
|
|
32129
|
+
this.subscribeToEvents();
|
|
32106
32130
|
this.renderGraph();
|
|
32107
32131
|
}
|
|
32108
32132
|
componentDidLoad() {
|
|
@@ -32117,10 +32141,10 @@ const GraphwiseReactodia = class {
|
|
|
32117
32141
|
}
|
|
32118
32142
|
}
|
|
32119
32143
|
render() {
|
|
32120
|
-
return (index.h(index.Host, { key: '
|
|
32144
|
+
return (index.h(index.Host, { key: '2e8541c791f478484c4bad64ad758df99aba2059' }));
|
|
32121
32145
|
}
|
|
32122
|
-
|
|
32123
|
-
this.subscriptions.add(
|
|
32146
|
+
subscribeToEvents() {
|
|
32147
|
+
this.subscriptions.add(eventService.subscribe((detail) => this.eventEmitter.emit(detail)));
|
|
32124
32148
|
}
|
|
32125
32149
|
renderGraph(isReloading) {
|
|
32126
32150
|
var _a;
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var errorCode = require('./error-code-
|
|
3
|
+
var errorCode = require('./error-code-BjU_V9e8.js');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Name of the DOM event the `graphwise-reactodia` element dispatches for every
|
|
6
|
+
* Name of the DOM event the `graphwise-reactodia` element dispatches for every event.
|
|
7
7
|
*/
|
|
8
|
-
const
|
|
8
|
+
const GRAPHWISE_REACTODIA_EVENT = 'graphwiseReactodiaEvent';
|
|
9
9
|
|
|
10
10
|
exports.CLEAR_DIAGRAM_STORAGE_EVENT = errorCode.CLEAR_DIAGRAM_STORAGE_EVENT;
|
|
11
11
|
Object.defineProperty(exports, "ErrorCode", {
|
|
12
12
|
enumerable: true,
|
|
13
13
|
get: function () { return errorCode.ErrorCode; }
|
|
14
14
|
});
|
|
15
|
-
exports
|
|
15
|
+
Object.defineProperty(exports, "EventType", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return errorCode.EventType; }
|
|
18
|
+
});
|
|
19
|
+
exports.GRAPHWISE_REACTODIA_EVENT = GRAPHWISE_REACTODIA_EVENT;
|
|
@@ -5,8 +5,10 @@ import { ErrorCode } from "./models/error/error-code";
|
|
|
5
5
|
import { SubscriptionList } from "./models/subscription-list";
|
|
6
6
|
import { service } from "./providers/service/service-inject";
|
|
7
7
|
import { ErrorService } from "./services/error/error.service";
|
|
8
|
+
import { EventService } from "./services/event/event.service";
|
|
8
9
|
import { resetColors } from "./styles/type-style.resolver";
|
|
9
10
|
const errorService = service(ErrorService);
|
|
11
|
+
const eventService = service(EventService);
|
|
10
12
|
/**
|
|
11
13
|
* A web component that renders a graph with the Reactodia workspace.
|
|
12
14
|
*
|
|
@@ -48,7 +50,7 @@ export class GraphwiseReactodia {
|
|
|
48
50
|
this.renderGraph(true);
|
|
49
51
|
}
|
|
50
52
|
connectedCallback() {
|
|
51
|
-
this.
|
|
53
|
+
this.subscribeToEvents();
|
|
52
54
|
this.renderGraph();
|
|
53
55
|
}
|
|
54
56
|
componentDidLoad() {
|
|
@@ -63,10 +65,10 @@ export class GraphwiseReactodia {
|
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
67
|
render() {
|
|
66
|
-
return (h(Host, { key: '
|
|
68
|
+
return (h(Host, { key: '2e8541c791f478484c4bad64ad758df99aba2059' }));
|
|
67
69
|
}
|
|
68
|
-
|
|
69
|
-
this.subscriptions.add(
|
|
70
|
+
subscribeToEvents() {
|
|
71
|
+
this.subscriptions.add(eventService.subscribe((detail) => this.eventEmitter.emit(detail)));
|
|
70
72
|
}
|
|
71
73
|
renderGraph(isReloading) {
|
|
72
74
|
var _a;
|
|
@@ -234,23 +236,23 @@ export class GraphwiseReactodia {
|
|
|
234
236
|
}
|
|
235
237
|
static get events() {
|
|
236
238
|
return [{
|
|
237
|
-
"method": "
|
|
238
|
-
"name": "
|
|
239
|
+
"method": "eventEmitter",
|
|
240
|
+
"name": "graphwiseReactodiaEvent",
|
|
239
241
|
"bubbles": true,
|
|
240
242
|
"cancelable": true,
|
|
241
243
|
"composed": true,
|
|
242
244
|
"docs": {
|
|
243
245
|
"tags": [],
|
|
244
|
-
"text": "Fires
|
|
246
|
+
"text": "Fires for every event to the host, differentiated by `detail.type`."
|
|
245
247
|
},
|
|
246
248
|
"complexType": {
|
|
247
|
-
"original": "
|
|
248
|
-
"resolved": "ErrorReport",
|
|
249
|
+
"original": "EventDetail",
|
|
250
|
+
"resolved": "{ type: EventType.ERROR; payload: ErrorReport; } | { type: EventType.TEXT_SEARCH; payload?: undefined; }",
|
|
249
251
|
"references": {
|
|
250
|
-
"
|
|
252
|
+
"EventDetail": {
|
|
251
253
|
"location": "import",
|
|
252
|
-
"path": "./models/
|
|
253
|
-
"id": "src/components/graphwise-reactodia/models/
|
|
254
|
+
"path": "./models/event/event-detail",
|
|
255
|
+
"id": "src/components/graphwise-reactodia/models/event/event-detail.ts::EventDetail"
|
|
254
256
|
}
|
|
255
257
|
}
|
|
256
258
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The kind of event the wrapper announces to the host. It selects the payload of an {@link EventDetail}.
|
|
3
|
+
*/
|
|
4
|
+
export var EventType;
|
|
5
|
+
(function (EventType) {
|
|
6
|
+
EventType["ERROR"] = "error";
|
|
7
|
+
EventType["TEXT_SEARCH"] = "text-search";
|
|
8
|
+
})(EventType || (EventType = {}));
|
|
@@ -9,6 +9,7 @@ import { DiagramStorageService } from "./services/diagram-storage/diagram-storag
|
|
|
9
9
|
import { EventService } from "./services/event/event.service";
|
|
10
10
|
import { ErrorService } from "./services/error/error.service";
|
|
11
11
|
import { ErrorCode } from "./models/error/error-code";
|
|
12
|
+
import { EventType } from "./models/event/event-type";
|
|
12
13
|
import { SubscriptionList } from "./models/subscription-list";
|
|
13
14
|
import { resolveTypeStyle } from "./styles/type-style.resolver";
|
|
14
15
|
import { GraphwiseMenu } from "./menu/graphwise-menu";
|
|
@@ -40,6 +41,14 @@ const diagramService = service(DiagramService);
|
|
|
40
41
|
const diagramStorageService = service(DiagramStorageService);
|
|
41
42
|
const eventService = service(EventService);
|
|
42
43
|
const errorService = service(ErrorService);
|
|
44
|
+
/**
|
|
45
|
+
* Emits a {@link EventType.TEXT_SEARCH} event for each text lookup.
|
|
46
|
+
*/
|
|
47
|
+
function emitTextSearch(method, params) {
|
|
48
|
+
if (method === 'lookup' && params.text) {
|
|
49
|
+
eventService.emit({ type: EventType.TEXT_SEARCH });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
43
52
|
/**
|
|
44
53
|
* Reports every failed data provider call, unless the call was aborted, and passes the failure on to the caller.
|
|
45
54
|
*/
|
|
@@ -58,7 +67,7 @@ const reportDataFetchError = async (_method, params, body) => {
|
|
|
58
67
|
/**
|
|
59
68
|
* Builds a Reactodia {@link SparqlDataProvider} for the given endpoint using the supplied
|
|
60
69
|
* query preset. The host owns the query configuration and always passes it in via props.
|
|
61
|
-
* The provider is decorated, so its failed calls are reported.
|
|
70
|
+
* The provider is decorated, so its failed calls are reported and its text lookups emit an event.
|
|
62
71
|
*/
|
|
63
72
|
function createDataProvider(props) {
|
|
64
73
|
const { currentRepository, config, providerSettings } = props;
|
|
@@ -67,7 +76,13 @@ function createDataProvider(props) {
|
|
|
67
76
|
queryMethod: 'POST',
|
|
68
77
|
queryFunction: config.queryFunction
|
|
69
78
|
}, providerSettings);
|
|
70
|
-
return new DecoratedDataProvider({
|
|
79
|
+
return new DecoratedDataProvider({
|
|
80
|
+
baseProvider,
|
|
81
|
+
decorator: (method, params, body) => {
|
|
82
|
+
emitTextSearch(method, params);
|
|
83
|
+
return reportDataFetchError(method, params, body);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
71
86
|
}
|
|
72
87
|
/**
|
|
73
88
|
* Places the seed entities on the canvas. Each IRI is added as a placeholder element, and data is then loaded for the
|
|
@@ -10,11 +10,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
10
10
|
};
|
|
11
11
|
var ErrorService_1;
|
|
12
12
|
import { Service } from "../../providers/service/service";
|
|
13
|
+
import { service } from "../../providers/service/service-inject";
|
|
14
|
+
import { EventType } from "../../models/event/event-type";
|
|
15
|
+
import { EventService } from "../event/event.service";
|
|
13
16
|
/**
|
|
14
17
|
* Service that collects the failures of the wrapper and the fork, so they can be announced to the host.
|
|
15
18
|
*/
|
|
16
19
|
let ErrorService = ErrorService_1 = class ErrorService {
|
|
17
20
|
constructor() {
|
|
21
|
+
this.eventService = service(EventService);
|
|
18
22
|
this.reported = new WeakSet();
|
|
19
23
|
}
|
|
20
24
|
/**
|
|
@@ -40,27 +44,12 @@ let ErrorService = ErrorService_1 = class ErrorService {
|
|
|
40
44
|
* @param thrown The thrown value.
|
|
41
45
|
*/
|
|
42
46
|
report(code, thrown) {
|
|
43
|
-
var _a;
|
|
44
47
|
const causes = this.causeChain(thrown);
|
|
45
48
|
if (this.isAbortedOrAlreadyReported(causes)) {
|
|
46
49
|
return;
|
|
47
50
|
}
|
|
48
51
|
causes.forEach((cause) => this.reported.add(cause));
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Subscribes to the reported errors, replacing the previous subscriber.
|
|
53
|
-
*
|
|
54
|
-
* @param callback Called with every reported error.
|
|
55
|
-
* @returns A {@link Subscription} that, when called, removes the callback, unless it has already been replaced.
|
|
56
|
-
*/
|
|
57
|
-
subscribe(callback) {
|
|
58
|
-
this.callback = callback;
|
|
59
|
-
return () => {
|
|
60
|
-
if (this.callback === callback) {
|
|
61
|
-
this.callback = undefined;
|
|
62
|
-
}
|
|
63
|
-
};
|
|
52
|
+
this.eventService.emit({ type: EventType.ERROR, payload: { code, error: thrown } });
|
|
64
53
|
}
|
|
65
54
|
/**
|
|
66
55
|
* Whether any link of the given cause chain is an abort or is already reported.
|
|
@@ -16,6 +16,29 @@ import { WindowService } from "../window/window.service";
|
|
|
16
16
|
* Service for event based operations
|
|
17
17
|
*/
|
|
18
18
|
let EventService = class EventService {
|
|
19
|
+
/**
|
|
20
|
+
* Announces an event to the host.
|
|
21
|
+
*
|
|
22
|
+
* @param detail The event detail.
|
|
23
|
+
*/
|
|
24
|
+
emit(detail) {
|
|
25
|
+
var _a;
|
|
26
|
+
(_a = this.callback) === null || _a === void 0 ? void 0 : _a.call(this, detail);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Subscribes to the emitted events, replacing the previous subscriber.
|
|
30
|
+
*
|
|
31
|
+
* @param callback Called with every emitted event.
|
|
32
|
+
* @returns A {@link Subscription} that, when called, removes the callback, unless it has already been replaced.
|
|
33
|
+
*/
|
|
34
|
+
subscribe(callback) {
|
|
35
|
+
this.callback = callback;
|
|
36
|
+
return () => {
|
|
37
|
+
if (this.callback === callback) {
|
|
38
|
+
this.callback = undefined;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
19
42
|
/**
|
|
20
43
|
* Subscribes to the host's "clear persisted diagram" command.
|
|
21
44
|
*
|
package/dist/collection/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { CLEAR_DIAGRAM_STORAGE_EVENT } from './components/graphwise-reactodia/models/clear-diagram-storage-event';
|
|
2
|
-
export {
|
|
2
|
+
export { GRAPHWISE_REACTODIA_EVENT } from './components/graphwise-reactodia/models/event/event-detail';
|
|
3
|
+
export { EventType } from './components/graphwise-reactodia/models/event/event-type';
|
|
3
4
|
export { ErrorCode } from './components/graphwise-reactodia/models/error/error-code';
|
|
@@ -42,8 +42,20 @@ function hangingQueryFunction(params) {
|
|
|
42
42
|
const reportedErrors = [];
|
|
43
43
|
window.reportedErrors = reportedErrors;
|
|
44
44
|
// The listener is on the document, since the tests replace the element.
|
|
45
|
-
document.addEventListener('
|
|
46
|
-
|
|
45
|
+
document.addEventListener('graphwiseReactodiaEvent', (event) => {
|
|
46
|
+
if (event.detail.type !== 'error') {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const {code, error} = event.detail.payload;
|
|
50
|
+
reportedErrors.push({code, message: error.message});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// The text search events are counted.
|
|
54
|
+
window.textSearches = 0;
|
|
55
|
+
document.addEventListener('graphwiseReactodiaEvent', (event) => {
|
|
56
|
+
if (event.detail.type === 'text-search') {
|
|
57
|
+
window.textSearches++;
|
|
58
|
+
}
|
|
47
59
|
});
|
|
48
60
|
|
|
49
61
|
const SEED_NODES = ['http://example.com/alice', 'http://example.com/bob'];
|
|
@@ -4,6 +4,15 @@
|
|
|
4
4
|
*/
|
|
5
5
|
const CLEAR_DIAGRAM_STORAGE_EVENT = 'graphwise-reactodia:clear-diagram-storage';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* The kind of event the wrapper announces to the host. It selects the payload of an {@link EventDetail}.
|
|
9
|
+
*/
|
|
10
|
+
var EventType;
|
|
11
|
+
(function (EventType) {
|
|
12
|
+
EventType["ERROR"] = "error";
|
|
13
|
+
EventType["TEXT_SEARCH"] = "text-search";
|
|
14
|
+
})(EventType || (EventType = {}));
|
|
15
|
+
|
|
7
16
|
/**
|
|
8
17
|
* The stable category of a reported error. The host uses it to choose its own message.
|
|
9
18
|
*/
|
|
@@ -23,4 +32,4 @@ var ErrorCode;
|
|
|
23
32
|
ErrorCode["LOCAL_DIAGRAM_SAVE"] = "local-diagram-save";
|
|
24
33
|
})(ErrorCode || (ErrorCode = {}));
|
|
25
34
|
|
|
26
|
-
export { CLEAR_DIAGRAM_STORAGE_EVENT as C,
|
|
35
|
+
export { CLEAR_DIAGRAM_STORAGE_EVENT as C, EventType as E, ErrorCode as a };
|