graphwise-reactodia 0.0.1-TR16 → 0.0.1-TR18
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 +57 -0
- package/dist/cjs/error-code-BdRU0RQ9.js +36 -0
- package/dist/cjs/graphwise-reactodia.cjs.entry.js +270 -65
- package/dist/cjs/graphwise-reactodia.cjs.js +1 -1
- package/dist/cjs/{index-CII9aUQC.js → index-DtzCybH4.js} +16 -0
- package/dist/cjs/index.cjs.js +14 -4
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/graphwise-reactodia/graphwise-reactodia.js +46 -4
- package/dist/collection/components/graphwise-reactodia/menu/graphwise-menu.js +4 -1
- package/dist/collection/components/graphwise-reactodia/models/error/error-cause.js +1 -0
- package/dist/collection/components/graphwise-reactodia/models/error/error-code.js +18 -0
- package/dist/collection/components/graphwise-reactodia/models/error/error-report.js +1 -0
- package/dist/collection/components/graphwise-reactodia/models/event/event-callback.js +1 -0
- package/dist/collection/components/graphwise-reactodia/models/event/event-detail.js +4 -0
- package/dist/collection/components/graphwise-reactodia/models/event/event-type.js +7 -0
- package/dist/collection/components/graphwise-reactodia/reactodia-app.js +53 -19
- package/dist/collection/components/graphwise-reactodia/services/diagram-storage/diagram-storage.service.js +20 -4
- package/dist/collection/components/graphwise-reactodia/services/error/error.service.js +78 -0
- package/dist/collection/components/graphwise-reactodia/services/event/event.service.js +23 -0
- package/dist/collection/index.js +3 -0
- package/dist/collection/pages/graphwise-reactodia/main.js +41 -0
- package/dist/esm/error-code-DHI2bePh.js +34 -0
- package/dist/esm/graphwise-reactodia.entry.js +268 -63
- package/dist/esm/graphwise-reactodia.js +2 -2
- package/dist/esm/{index-Cypw7ydc.js → index-DpCR6zMg.js} +16 -1
- package/dist/esm/index.js +5 -4
- package/dist/esm/loader.js +2 -2
- package/dist/graphwise-reactodia/graphwise-reactodia.esm.js +1 -1
- package/dist/graphwise-reactodia/index.esm.js +1 -1
- package/dist/graphwise-reactodia/p-DHI2bePh.js +1 -0
- package/dist/graphwise-reactodia/p-DpCR6zMg.js +2 -0
- package/dist/graphwise-reactodia/p-abfb5091.entry.js +1 -0
- package/dist/types/components/graphwise-reactodia/graphwise-reactodia.d.ts +9 -0
- package/dist/types/components/graphwise-reactodia/models/error/error-cause.d.ts +10 -0
- package/dist/types/components/graphwise-reactodia/models/error/error-code.d.ts +17 -0
- package/dist/types/components/graphwise-reactodia/models/error/error-report.d.ts +13 -0
- 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 +48 -0
- package/dist/types/components/graphwise-reactodia/models/event/event-type.d.ts +6 -0
- package/dist/types/components/graphwise-reactodia/reactodia-app.d.ts +1 -1
- package/dist/types/components/graphwise-reactodia/services/diagram-storage/diagram-storage.service.d.ts +1 -0
- package/dist/types/components/graphwise-reactodia/services/error/error.service.d.ts +41 -0
- package/dist/types/components/graphwise-reactodia/services/event/event.service.d.ts +16 -0
- package/dist/types/components.d.ts +21 -0
- package/dist/types/index.d.ts +5 -0
- package/package.json +1 -1
- package/dist/graphwise-reactodia/p-20637a6f.entry.js +0 -1
- package/dist/graphwise-reactodia/p-Cypw7ydc.js +0 -2
package/README.md
CHANGED
|
@@ -66,6 +66,63 @@ 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
|
+
## 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:
|
|
75
|
+
|
|
76
|
+
| `type` | `payload` |
|
|
77
|
+
|---------|-----------------|
|
|
78
|
+
| `error` | `ErrorReport` |
|
|
79
|
+
|
|
80
|
+
Checking `type` narrows `payload`:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
element.addEventListener(GRAPHWISE_REACTODIA_EVENT, (event) => {
|
|
84
|
+
const detail = (event as CustomEvent<EventDetail>).detail;
|
|
85
|
+
if (detail.type === EventType.ERROR) {
|
|
86
|
+
const {code, error} = detail.payload; // an ErrorReport
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`EventDetail<T>` is one event, e.g. for a handler of a single type:
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
function onError(detail: EventDetail<EventType.ERROR>): void {
|
|
95
|
+
const {code, error} = detail.payload;
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Error handling
|
|
100
|
+
|
|
101
|
+
The element dispatches an `error` event for every error it reports; the codes below list them.
|
|
102
|
+
|
|
103
|
+
`payload` is an `ErrorReport`:
|
|
104
|
+
|
|
105
|
+
| Field | Description |
|
|
106
|
+
|---------|-----------------------------------------------------------------------------------------|
|
|
107
|
+
| `code` | An `ErrorCode`. The host translates by it. |
|
|
108
|
+
| `error` | Always an `Error`; its `message` is untranslated developer text, meant for the logs. |
|
|
109
|
+
|
|
110
|
+
`ErrorCode`:
|
|
111
|
+
|
|
112
|
+
| Code | Reported when |
|
|
113
|
+
|-------------------------|------------------------------------------------------------|
|
|
114
|
+
| `missing-required-prop` | A required prop is missing. |
|
|
115
|
+
| `data-fetch` | A SPARQL data provider call failed. |
|
|
116
|
+
| `diagram-load` | The startup load, a reload or a repository switch failed. |
|
|
117
|
+
| `diagram-import` | The uploaded file was rejected or its import failed. |
|
|
118
|
+
| `local-diagram-read` | Reading the diagram from local storage failed. |
|
|
119
|
+
| `local-diagram-save` | Saving the diagram in local storage failed. |
|
|
120
|
+
|
|
121
|
+
Failed PNG/SVG exports and printing are not reported.
|
|
122
|
+
|
|
123
|
+
Every failure is reported once: an error is skipped when it, or an error in its `cause` chain, is already reported.
|
|
124
|
+
Aborted requests are not reported.
|
|
125
|
+
|
|
69
126
|
## Editing the fork
|
|
70
127
|
|
|
71
128
|
Reactodia lives in the `reactodia-workspace/` submodule, which is its own git repo (remote:
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Event name for clearing the local store state of the diagram. There is an event listener listening for it, which
|
|
5
|
+
* will clear the local store state, whenever this event is fired.
|
|
6
|
+
*/
|
|
7
|
+
const CLEAR_DIAGRAM_STORAGE_EVENT = 'graphwise-reactodia:clear-diagram-storage';
|
|
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
|
+
})(exports.EventType || (exports.EventType = {}));
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The stable category of a reported error. The host uses it to choose its own message.
|
|
19
|
+
*/
|
|
20
|
+
exports.ErrorCode = void 0;
|
|
21
|
+
(function (ErrorCode) {
|
|
22
|
+
/** A required prop is missing. */
|
|
23
|
+
ErrorCode["MISSING_REQUIRED_PROP"] = "missing-required-prop";
|
|
24
|
+
/** A SPARQL data provider call failed. */
|
|
25
|
+
ErrorCode["DATA_FETCH"] = "data-fetch";
|
|
26
|
+
/** The startup load, a reload or a repository switch failed. */
|
|
27
|
+
ErrorCode["DIAGRAM_LOAD"] = "diagram-load";
|
|
28
|
+
/** The uploaded file was rejected or its import failed. */
|
|
29
|
+
ErrorCode["DIAGRAM_IMPORT"] = "diagram-import";
|
|
30
|
+
/** Reading the diagram from local storage failed. */
|
|
31
|
+
ErrorCode["LOCAL_DIAGRAM_READ"] = "local-diagram-read";
|
|
32
|
+
/** Saving the diagram in local storage failed. */
|
|
33
|
+
ErrorCode["LOCAL_DIAGRAM_SAVE"] = "local-diagram-save";
|
|
34
|
+
})(exports.ErrorCode || (exports.ErrorCode = {}));
|
|
35
|
+
|
|
36
|
+
exports.CLEAR_DIAGRAM_STORAGE_EVENT = CLEAR_DIAGRAM_STORAGE_EVENT;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index
|
|
4
|
-
var
|
|
3
|
+
var index = require('./index-DtzCybH4.js');
|
|
4
|
+
var errorCode = require('./error-code-BdRU0RQ9.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
|
|
|
@@ -6331,6 +6331,57 @@ var DefaultColorVariants = [
|
|
|
6331
6331
|
"danger"
|
|
6332
6332
|
];
|
|
6333
6333
|
//#endregion
|
|
6334
|
+
//#region src/data/decorated/decoratedDataProvider.ts
|
|
6335
|
+
/**
|
|
6336
|
+
* Utility graph data provider to wrap over another provider to modify
|
|
6337
|
+
* how the requests are made or alter the results.
|
|
6338
|
+
*
|
|
6339
|
+
* @category Data
|
|
6340
|
+
*/
|
|
6341
|
+
var DecoratedDataProvider = class {
|
|
6342
|
+
baseProvider;
|
|
6343
|
+
decorator;
|
|
6344
|
+
constructor(options) {
|
|
6345
|
+
this.baseProvider = options.baseProvider;
|
|
6346
|
+
this.decorator = options.decorator;
|
|
6347
|
+
}
|
|
6348
|
+
get factory() {
|
|
6349
|
+
return this.baseProvider.factory;
|
|
6350
|
+
}
|
|
6351
|
+
decorate(method, params) {
|
|
6352
|
+
const bound = this.baseProvider[method].bind(this.baseProvider);
|
|
6353
|
+
const { decorator } = this;
|
|
6354
|
+
return decorator(method, params[0], bound);
|
|
6355
|
+
}
|
|
6356
|
+
knownElementTypes(params) {
|
|
6357
|
+
return this.decorate("knownElementTypes", [params]);
|
|
6358
|
+
}
|
|
6359
|
+
knownLinkTypes(params) {
|
|
6360
|
+
return this.decorate("knownLinkTypes", [params]);
|
|
6361
|
+
}
|
|
6362
|
+
elementTypes(params) {
|
|
6363
|
+
return this.decorate("elementTypes", [params]);
|
|
6364
|
+
}
|
|
6365
|
+
propertyTypes(params) {
|
|
6366
|
+
return this.decorate("propertyTypes", [params]);
|
|
6367
|
+
}
|
|
6368
|
+
linkTypes(params) {
|
|
6369
|
+
return this.decorate("linkTypes", [params]);
|
|
6370
|
+
}
|
|
6371
|
+
elements(params) {
|
|
6372
|
+
return this.decorate("elements", [params]);
|
|
6373
|
+
}
|
|
6374
|
+
links(params) {
|
|
6375
|
+
return this.decorate("links", [params]);
|
|
6376
|
+
}
|
|
6377
|
+
connectedLinkStats(params) {
|
|
6378
|
+
return this.decorate("connectedLinkStats", [params]);
|
|
6379
|
+
}
|
|
6380
|
+
lookup(params) {
|
|
6381
|
+
return this.decorate("lookup", [params]);
|
|
6382
|
+
}
|
|
6383
|
+
};
|
|
6384
|
+
//#endregion
|
|
6334
6385
|
//#region src/data/decorated/emptyDataProvider.ts
|
|
6335
6386
|
/**
|
|
6336
6387
|
* Empty graph data provider, which always return nothing.
|
|
@@ -31333,7 +31384,7 @@ function Service(_serviceClass) {
|
|
|
31333
31384
|
// no implementation needed. We only use the type checking of the parameter
|
|
31334
31385
|
}
|
|
31335
31386
|
|
|
31336
|
-
var __decorate$
|
|
31387
|
+
var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
31337
31388
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
31338
31389
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
31339
31390
|
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;
|
|
@@ -31395,11 +31446,11 @@ let DiagramService = DiagramService_1 = class DiagramService {
|
|
|
31395
31446
|
DiagramService.ID = 'DiagramService';
|
|
31396
31447
|
DiagramService.NOTIFY_DEBOUNCE_MS = 300;
|
|
31397
31448
|
DiagramService.HISTORY_CHANGED_EVENT = 'historyChanged';
|
|
31398
|
-
DiagramService = DiagramService_1 = __decorate$
|
|
31449
|
+
DiagramService = DiagramService_1 = __decorate$5([
|
|
31399
31450
|
Service
|
|
31400
31451
|
], DiagramService);
|
|
31401
31452
|
|
|
31402
|
-
var __decorate$
|
|
31453
|
+
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
31403
31454
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
31404
31455
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
31405
31456
|
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;
|
|
@@ -31414,37 +31465,171 @@ let WindowService = class WindowService {
|
|
|
31414
31465
|
}
|
|
31415
31466
|
};
|
|
31416
31467
|
WindowService.ID = 'WindowService';
|
|
31417
|
-
WindowService = __decorate$
|
|
31468
|
+
WindowService = __decorate$4([
|
|
31418
31469
|
Service
|
|
31419
31470
|
], WindowService);
|
|
31420
31471
|
|
|
31472
|
+
var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
31473
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
31474
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
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
|
+
|
|
31421
31522
|
var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
31422
31523
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
31423
31524
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
31424
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;
|
|
31425
31526
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
31426
31527
|
};
|
|
31528
|
+
var ErrorService_1;
|
|
31529
|
+
/**
|
|
31530
|
+
* Service that collects the failures of the wrapper and the fork, so they can be announced to the host.
|
|
31531
|
+
*/
|
|
31532
|
+
let ErrorService = ErrorService_1 = class ErrorService {
|
|
31533
|
+
constructor() {
|
|
31534
|
+
this.eventService = service(EventService);
|
|
31535
|
+
this.reported = new WeakSet();
|
|
31536
|
+
}
|
|
31537
|
+
/**
|
|
31538
|
+
* Reports a failure to the host, unless it's an abort, or this exact error object is already reported
|
|
31539
|
+
* from another place.
|
|
31540
|
+
*
|
|
31541
|
+
* The same error object may be reported from different places. E.g. a query that fails while a diagram loads is
|
|
31542
|
+
* reported by the data provider decorator as `data-fetch`, and then reaches the `catch` around the load, which
|
|
31543
|
+
* reports it as `diagram-load`. Only the first one is announced.
|
|
31544
|
+
*
|
|
31545
|
+
* The `cause` is checked because the fork wraps whatever fails during a diagram import in a new error:
|
|
31546
|
+
*
|
|
31547
|
+
* ```ts
|
|
31548
|
+
* // reactodia-workspace/src/editor/dataDiagramModel.ts, importLayout
|
|
31549
|
+
* } catch (error) {
|
|
31550
|
+
* throw new Error('Reactodia: failed to import a layout', {cause: error});
|
|
31551
|
+
* }
|
|
31552
|
+
* ```
|
|
31553
|
+
*
|
|
31554
|
+
* We need to check the cause to make sure we don't report the same error/abort more than once.
|
|
31555
|
+
*
|
|
31556
|
+
* @param code The category of the failure.
|
|
31557
|
+
* @param thrown The thrown value.
|
|
31558
|
+
*/
|
|
31559
|
+
report(code, thrown) {
|
|
31560
|
+
const causes = this.causeChain(thrown);
|
|
31561
|
+
if (this.isAbortedOrAlreadyReported(causes)) {
|
|
31562
|
+
return;
|
|
31563
|
+
}
|
|
31564
|
+
causes.forEach((cause) => this.reported.add(cause));
|
|
31565
|
+
this.eventService.emit({ type: errorCode.EventType.ERROR, payload: { code, error: thrown } });
|
|
31566
|
+
}
|
|
31567
|
+
/**
|
|
31568
|
+
* Whether any link of the given cause chain is an abort or is already reported.
|
|
31569
|
+
*/
|
|
31570
|
+
isAbortedOrAlreadyReported(causes) {
|
|
31571
|
+
return causes.some((cause) => cause.name === ErrorService_1.ABORT_ERROR_NAME || this.reported.has(cause));
|
|
31572
|
+
}
|
|
31573
|
+
/**
|
|
31574
|
+
* The thrown value followed by its `cause`, the cause of that, and so on, for as long as they are objects.
|
|
31575
|
+
*/
|
|
31576
|
+
causeChain(thrown) {
|
|
31577
|
+
const causes = [];
|
|
31578
|
+
let current = thrown;
|
|
31579
|
+
while (typeof current === 'object' && current !== null && !causes.includes(current)) {
|
|
31580
|
+
causes.push(current);
|
|
31581
|
+
current = current.cause;
|
|
31582
|
+
}
|
|
31583
|
+
return causes;
|
|
31584
|
+
}
|
|
31585
|
+
};
|
|
31586
|
+
ErrorService.ID = 'ErrorService';
|
|
31587
|
+
ErrorService.ABORT_ERROR_NAME = 'AbortError';
|
|
31588
|
+
ErrorService = ErrorService_1 = __decorate$2([
|
|
31589
|
+
Service
|
|
31590
|
+
], ErrorService);
|
|
31591
|
+
|
|
31592
|
+
var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
31593
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
31594
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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;
|
|
31596
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
31597
|
+
};
|
|
31427
31598
|
var DiagramStorageService_1;
|
|
31428
31599
|
/**
|
|
31429
31600
|
* Service for local store-related diagram operations
|
|
31430
31601
|
*/
|
|
31431
31602
|
let DiagramStorageService = DiagramStorageService_1 = class DiagramStorageService {
|
|
31603
|
+
constructor() {
|
|
31604
|
+
this.errorService = service(ErrorService);
|
|
31605
|
+
}
|
|
31432
31606
|
/**
|
|
31433
31607
|
* Load the persisted diagram from the local store, or `undefined` when nothing is stored (or the stored value
|
|
31434
31608
|
* is unreadable).
|
|
31435
31609
|
*/
|
|
31436
31610
|
load() {
|
|
31437
|
-
|
|
31438
|
-
|
|
31611
|
+
try {
|
|
31612
|
+
const raw = this.storage.getItem(DiagramStorageService_1.STORAGE_KEY);
|
|
31613
|
+
if (!raw) {
|
|
31614
|
+
return undefined;
|
|
31615
|
+
}
|
|
31616
|
+
return JSON.parse(raw);
|
|
31617
|
+
}
|
|
31618
|
+
catch (error) {
|
|
31619
|
+
this.errorService.report(errorCode.ErrorCode.LOCAL_DIAGRAM_READ, error);
|
|
31439
31620
|
return undefined;
|
|
31440
31621
|
}
|
|
31441
|
-
return JSON.parse(raw);
|
|
31442
31622
|
}
|
|
31443
31623
|
/**
|
|
31444
31624
|
* Persists the given diagram serialization.
|
|
31445
31625
|
*/
|
|
31446
31626
|
save(diagram) {
|
|
31447
|
-
|
|
31627
|
+
try {
|
|
31628
|
+
this.storage.setItem(DiagramStorageService_1.STORAGE_KEY, JSON.stringify(diagram));
|
|
31629
|
+
}
|
|
31630
|
+
catch (error) {
|
|
31631
|
+
this.errorService.report(errorCode.ErrorCode.LOCAL_DIAGRAM_SAVE, error);
|
|
31632
|
+
}
|
|
31448
31633
|
}
|
|
31449
31634
|
/**
|
|
31450
31635
|
* Removes the persisted diagram. Used when a new view (a seed) should take precedence over
|
|
@@ -31462,37 +31647,10 @@ let DiagramStorageService = DiagramStorageService_1 = class DiagramStorageServic
|
|
|
31462
31647
|
};
|
|
31463
31648
|
DiagramStorageService.ID = 'DiagramStorageService';
|
|
31464
31649
|
DiagramStorageService.STORAGE_KEY = 'diagram.state';
|
|
31465
|
-
DiagramStorageService = DiagramStorageService_1 = __decorate$
|
|
31650
|
+
DiagramStorageService = DiagramStorageService_1 = __decorate$1([
|
|
31466
31651
|
Service
|
|
31467
31652
|
], DiagramStorageService);
|
|
31468
31653
|
|
|
31469
|
-
var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
31470
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
31471
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
31472
|
-
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;
|
|
31473
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
31474
|
-
};
|
|
31475
|
-
/**
|
|
31476
|
-
* Service for event based operations
|
|
31477
|
-
*/
|
|
31478
|
-
let EventService = class EventService {
|
|
31479
|
-
/**
|
|
31480
|
-
* Subscribes to the host's "clear persisted diagram" command.
|
|
31481
|
-
*
|
|
31482
|
-
* @param onClear Called whenever the event fires.
|
|
31483
|
-
* @returns A {@link Subscription} that, when called, removes the listener.
|
|
31484
|
-
*/
|
|
31485
|
-
subscribeToClearDiagramStorage(onClear) {
|
|
31486
|
-
const target = service(WindowService).getWindow();
|
|
31487
|
-
target.addEventListener(index.CLEAR_DIAGRAM_STORAGE_EVENT, onClear);
|
|
31488
|
-
return () => target.removeEventListener(index.CLEAR_DIAGRAM_STORAGE_EVENT, onClear);
|
|
31489
|
-
}
|
|
31490
|
-
};
|
|
31491
|
-
EventService.ID = 'EventService';
|
|
31492
|
-
EventService = __decorate$1([
|
|
31493
|
-
Service
|
|
31494
|
-
], EventService);
|
|
31495
|
-
|
|
31496
31654
|
/**
|
|
31497
31655
|
* A collection of {@link Subscription}s that can be released together. Components collect the
|
|
31498
31656
|
* subscriptions they open and call {@link unsubscribeAll} on teardown so nothing is left
|
|
@@ -31654,6 +31812,7 @@ function GraphwiseMenu() {
|
|
|
31654
31812
|
const t = useTranslation();
|
|
31655
31813
|
const diagramFileService = service(DiagramFileService);
|
|
31656
31814
|
const diagramService = service(DiagramService);
|
|
31815
|
+
const errorService = service(ErrorService);
|
|
31657
31816
|
const downloadDiagram = () => {
|
|
31658
31817
|
const timestamp = new Date().toISOString().replace(/[-:]|\.\d+Z$/g, '');
|
|
31659
31818
|
diagramFileService.download(model.exportLayout(), `diagram-${timestamp}${DiagramFileService.FILE_EXTENSION}`);
|
|
@@ -31664,7 +31823,7 @@ function GraphwiseMenu() {
|
|
|
31664
31823
|
await diagramService.importDiagram(model, model.dataProvider, diagram);
|
|
31665
31824
|
}
|
|
31666
31825
|
catch (error) {
|
|
31667
|
-
|
|
31826
|
+
errorService.report(errorCode.ErrorCode.DIAGRAM_IMPORT, error);
|
|
31668
31827
|
}
|
|
31669
31828
|
};
|
|
31670
31829
|
return reactExports.createElement(reactExports.Fragment, null, reactExports.createElement(ToolbarActionClearAll, {}), reactExports.createElement(ToolbarActionExport, { kind: 'exportRaster' }), reactExports.createElement(ToolbarActionExport, { kind: 'exportSvg' }), reactExports.createElement(ToolbarActionExport, { kind: 'print' }), reactExports.createElement(ToolbarAction,
|
|
@@ -31702,18 +31861,36 @@ const subscriptions = new SubscriptionList();
|
|
|
31702
31861
|
let diagramStorageSubscription;
|
|
31703
31862
|
const diagramService = service(DiagramService);
|
|
31704
31863
|
const diagramStorageService = service(DiagramStorageService);
|
|
31705
|
-
const eventService = service(EventService);
|
|
31864
|
+
const eventService$1 = service(EventService);
|
|
31865
|
+
const errorService$1 = service(ErrorService);
|
|
31866
|
+
/**
|
|
31867
|
+
* Reports every failed data provider call, unless the call was aborted, and passes the failure on to the caller.
|
|
31868
|
+
*/
|
|
31869
|
+
const reportDataFetchError = async (_method, params, body) => {
|
|
31870
|
+
var _a;
|
|
31871
|
+
try {
|
|
31872
|
+
return await body(params);
|
|
31873
|
+
}
|
|
31874
|
+
catch (error) {
|
|
31875
|
+
if (!((_a = params.signal) === null || _a === void 0 ? void 0 : _a.aborted)) {
|
|
31876
|
+
errorService$1.report(errorCode.ErrorCode.DATA_FETCH, error);
|
|
31877
|
+
}
|
|
31878
|
+
throw error;
|
|
31879
|
+
}
|
|
31880
|
+
};
|
|
31706
31881
|
/**
|
|
31707
31882
|
* Builds a Reactodia {@link SparqlDataProvider} for the given endpoint using the supplied
|
|
31708
31883
|
* query preset. The host owns the query configuration and always passes it in via props.
|
|
31884
|
+
* The provider is decorated, so its failed calls are reported.
|
|
31709
31885
|
*/
|
|
31710
31886
|
function createDataProvider(props) {
|
|
31711
31887
|
const { currentRepository, config, providerSettings } = props;
|
|
31712
|
-
|
|
31888
|
+
const baseProvider = new SparqlDataProvider({
|
|
31713
31889
|
endpointUrl: currentRepository,
|
|
31714
31890
|
queryMethod: 'POST',
|
|
31715
31891
|
queryFunction: config.queryFunction
|
|
31716
31892
|
}, providerSettings);
|
|
31893
|
+
return new DecoratedDataProvider({ baseProvider, decorator: reportDataFetchError });
|
|
31717
31894
|
}
|
|
31718
31895
|
/**
|
|
31719
31896
|
* Places the seed entities on the canvas. Each IRI is added as a placeholder element, and data is then loaded for the
|
|
@@ -31781,7 +31958,7 @@ function subscribeToDiagramChange(model) {
|
|
|
31781
31958
|
* @param model The diagram model whose edits are persisted
|
|
31782
31959
|
*/
|
|
31783
31960
|
function onClearDiagramStorage(model) {
|
|
31784
|
-
subscriptions.add(eventService.subscribeToClearDiagramStorage(() => {
|
|
31961
|
+
subscriptions.add(eventService$1.subscribeToClearDiagramStorage(() => {
|
|
31785
31962
|
// re-subscribe, to avoid any pending debounced saves, which may write over the cleared diagram
|
|
31786
31963
|
subscribeToDiagramChange(model);
|
|
31787
31964
|
diagramStorageService.clear();
|
|
@@ -31808,22 +31985,31 @@ function ReactodiaApp(props) {
|
|
|
31808
31985
|
const dataProvider = createDataProvider(props);
|
|
31809
31986
|
const isReload = props.isReload;
|
|
31810
31987
|
const savedDiagram = diagramStorageService.load();
|
|
31811
|
-
|
|
31812
|
-
|
|
31813
|
-
|
|
31814
|
-
|
|
31815
|
-
|
|
31816
|
-
|
|
31817
|
-
|
|
31818
|
-
|
|
31819
|
-
|
|
31820
|
-
|
|
31821
|
-
|
|
31988
|
+
try {
|
|
31989
|
+
if (isReload) {
|
|
31990
|
+
// Reload the diagram that is currently on the canvas. This may happen when the host changes the provider
|
|
31991
|
+
// settings, or when the user switches the language at runtime, since there is no existing mechanism to
|
|
31992
|
+
// re-translate the UI at runtime (not for the UI labels at least)
|
|
31993
|
+
await diagramService.importDiagram(model, dataProvider, currentDiagram, signal);
|
|
31994
|
+
}
|
|
31995
|
+
else if ((_a = config.seedIris) === null || _a === void 0 ? void 0 : _a.length) {
|
|
31996
|
+
await seedIrisToCanvas(context, dataProvider, config.seedIris, signal);
|
|
31997
|
+
}
|
|
31998
|
+
else if ((_b = config.seedGraph) === null || _b === void 0 ? void 0 : _b.length) {
|
|
31999
|
+
await seedGraphToCanvas(context, dataProvider, config.seedGraph, signal);
|
|
32000
|
+
}
|
|
32001
|
+
else {
|
|
32002
|
+
// Restore the previously saved layout when present, otherwise start empty. Either way this binds the
|
|
32003
|
+
// data provider (savedDiagram is undefined -> empty diagram), so the unified search/lookup works.
|
|
32004
|
+
await diagramService.importDiagram(model, dataProvider, savedDiagram, signal);
|
|
32005
|
+
}
|
|
31822
32006
|
}
|
|
31823
|
-
|
|
31824
|
-
|
|
31825
|
-
|
|
31826
|
-
|
|
32007
|
+
catch (error) {
|
|
32008
|
+
if (!signal.aborted) {
|
|
32009
|
+
errorService$1.report(errorCode.ErrorCode.DIAGRAM_LOAD, error);
|
|
32010
|
+
}
|
|
32011
|
+
// rethrow, so the workspace shows the failure on its loading spinner
|
|
32012
|
+
throw error;
|
|
31827
32013
|
}
|
|
31828
32014
|
}, [language]);
|
|
31829
32015
|
/**
|
|
@@ -31860,7 +32046,7 @@ function mountReactodia(container, props) {
|
|
|
31860
32046
|
/**
|
|
31861
32047
|
* Re-points the diagram at a new SPARQL endpoint by recreating it with a fresh data provider.
|
|
31862
32048
|
* The canvas is reset to empty, matching the initial mount, since the data of another repository
|
|
31863
|
-
* has nothing to do with the current graph.
|
|
32049
|
+
* has nothing to do with the current graph. A failure is reported, not thrown.
|
|
31864
32050
|
*/
|
|
31865
32051
|
async function updateReactodia(props) {
|
|
31866
32052
|
if (!workspaceContext) {
|
|
@@ -31868,7 +32054,12 @@ async function updateReactodia(props) {
|
|
|
31868
32054
|
}
|
|
31869
32055
|
const { model } = workspaceContext;
|
|
31870
32056
|
const dataProvider = createDataProvider(props);
|
|
31871
|
-
|
|
32057
|
+
try {
|
|
32058
|
+
await model.createNewDiagram({ dataProvider });
|
|
32059
|
+
}
|
|
32060
|
+
catch (error) {
|
|
32061
|
+
errorService$1.report(errorCode.ErrorCode.DIAGRAM_LOAD, error);
|
|
32062
|
+
}
|
|
31872
32063
|
}
|
|
31873
32064
|
/**
|
|
31874
32065
|
* Serializes the current diagram so it can be restored after a remount (e.g. when a
|
|
@@ -31887,9 +32078,13 @@ function unmountReactodia(root) {
|
|
|
31887
32078
|
|
|
31888
32079
|
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)}";
|
|
31889
32080
|
|
|
32081
|
+
const errorService = service(ErrorService);
|
|
32082
|
+
const eventService = service(EventService);
|
|
31890
32083
|
const GraphwiseReactodia = class {
|
|
31891
32084
|
constructor(hostRef) {
|
|
31892
|
-
index
|
|
32085
|
+
index.registerInstance(this, hostRef);
|
|
32086
|
+
this.eventEmitter = index.createEvent(this, "graphwiseReactodiaEvent");
|
|
32087
|
+
this.subscriptions = new SubscriptionList();
|
|
31893
32088
|
/**
|
|
31894
32089
|
* UI language code (e.g. `en`, `fr`) for the Reactodia interface. Defaults to English.
|
|
31895
32090
|
*/
|
|
@@ -31917,6 +32112,7 @@ const GraphwiseReactodia = class {
|
|
|
31917
32112
|
this.renderGraph(true);
|
|
31918
32113
|
}
|
|
31919
32114
|
connectedCallback() {
|
|
32115
|
+
this.subscribeToEvents();
|
|
31920
32116
|
this.renderGraph();
|
|
31921
32117
|
}
|
|
31922
32118
|
componentDidLoad() {
|
|
@@ -31924,13 +32120,17 @@ const GraphwiseReactodia = class {
|
|
|
31924
32120
|
this.renderGraph();
|
|
31925
32121
|
}
|
|
31926
32122
|
disconnectedCallback() {
|
|
32123
|
+
this.subscriptions.unsubscribeAll();
|
|
31927
32124
|
if (this.reactRoot) {
|
|
31928
32125
|
unmountReactodia(this.reactRoot);
|
|
31929
32126
|
this.reactRoot = undefined;
|
|
31930
32127
|
}
|
|
31931
32128
|
}
|
|
31932
32129
|
render() {
|
|
31933
|
-
return (index
|
|
32130
|
+
return (index.h(index.Host, { key: '2e8541c791f478484c4bad64ad758df99aba2059' }));
|
|
32131
|
+
}
|
|
32132
|
+
subscribeToEvents() {
|
|
32133
|
+
this.subscriptions.add(eventService.subscribe((detail) => this.eventEmitter.emit(detail)));
|
|
31934
32134
|
}
|
|
31935
32135
|
renderGraph(isReloading) {
|
|
31936
32136
|
var _a;
|
|
@@ -31938,13 +32138,13 @@ const GraphwiseReactodia = class {
|
|
|
31938
32138
|
return;
|
|
31939
32139
|
}
|
|
31940
32140
|
if (!this.currentRepository) {
|
|
31941
|
-
throw
|
|
32141
|
+
throw this.reportMissingPropError('currentRepository is required');
|
|
31942
32142
|
}
|
|
31943
32143
|
if (!((_a = this.config) === null || _a === void 0 ? void 0 : _a.queryFunction)) {
|
|
31944
|
-
throw
|
|
32144
|
+
throw this.reportMissingPropError('config.queryFunction is required');
|
|
31945
32145
|
}
|
|
31946
32146
|
if (!this.providerSettings) {
|
|
31947
|
-
throw
|
|
32147
|
+
throw this.reportMissingPropError('providerSettings is required');
|
|
31948
32148
|
}
|
|
31949
32149
|
if (!this.hostElement) {
|
|
31950
32150
|
return;
|
|
@@ -31964,7 +32164,12 @@ const GraphwiseReactodia = class {
|
|
|
31964
32164
|
this.reactRoot = mountReactodia(this.hostElement, props);
|
|
31965
32165
|
}
|
|
31966
32166
|
}
|
|
31967
|
-
|
|
32167
|
+
reportMissingPropError(message) {
|
|
32168
|
+
const error = new Error(message);
|
|
32169
|
+
errorService.report(errorCode.ErrorCode.MISSING_REQUIRED_PROP, error);
|
|
32170
|
+
return error;
|
|
32171
|
+
}
|
|
32172
|
+
get hostElement() { return index.getElement(this); }
|
|
31968
32173
|
static get watchers() { return {
|
|
31969
32174
|
"currentRepository": ["onCurrentRepositoryChange"],
|
|
31970
32175
|
"language": ["onLanguageOrSettingsChange"],
|
|
@@ -289,6 +289,21 @@ var parsePropertyValue = (propValue, propType, isFormAssociated) => {
|
|
|
289
289
|
return propValue;
|
|
290
290
|
};
|
|
291
291
|
var getElement = (ref) => getHostRef(ref).$hostElement$ ;
|
|
292
|
+
|
|
293
|
+
// src/runtime/event-emitter.ts
|
|
294
|
+
var createEvent = (ref, name, flags) => {
|
|
295
|
+
const elm = getElement(ref);
|
|
296
|
+
return {
|
|
297
|
+
emit: (detail) => {
|
|
298
|
+
return emitEvent(elm, name, {
|
|
299
|
+
bubbles: true,
|
|
300
|
+
composed: true,
|
|
301
|
+
cancelable: true,
|
|
302
|
+
detail
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
};
|
|
292
307
|
var emitEvent = (elm, name, opts) => {
|
|
293
308
|
const ev = plt.ce(name, opts);
|
|
294
309
|
elm.dispatchEvent(ev);
|
|
@@ -1205,6 +1220,7 @@ var setNonce = (nonce) => plt.$nonce$ = nonce;
|
|
|
1205
1220
|
|
|
1206
1221
|
exports.Host = Host;
|
|
1207
1222
|
exports.bootstrapLazy = bootstrapLazy;
|
|
1223
|
+
exports.createEvent = createEvent;
|
|
1208
1224
|
exports.getElement = getElement;
|
|
1209
1225
|
exports.h = h;
|
|
1210
1226
|
exports.promiseResolve = promiseResolve;
|