graphwise-reactodia 0.0.1-TR2 → 0.0.1-TR20
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/COPYING +674 -0
- package/COPYING.LESSER +165 -0
- package/NOTICE +41 -0
- package/README.md +225 -1
- package/dist/cjs/graphwise-reactodia.cjs.entry.js +28519 -41232
- package/dist/cjs/graphwise-reactodia.cjs.js +2 -2
- package/dist/cjs/{index-CII9aUQC.js → index-DtzCybH4.js} +16 -0
- package/dist/cjs/index.cjs.js +29 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/node-action-DkJ5ct17.js +96 -0
- package/dist/collection/components/graphwise-reactodia/graphwise-reactodia.css +57 -1
- package/dist/collection/components/graphwise-reactodia/graphwise-reactodia.js +135 -40
- package/dist/collection/components/graphwise-reactodia/i18n/language-key.js +5 -0
- package/dist/collection/components/graphwise-reactodia/i18n/translations.js +6 -1
- package/dist/collection/components/graphwise-reactodia/menu/export-diagram-action.js +19 -0
- package/dist/collection/components/graphwise-reactodia/menu/graphwise-menu.js +24 -0
- package/dist/collection/components/graphwise-reactodia/menu/import-diagram-action.js +31 -0
- package/dist/collection/components/graphwise-reactodia/models/clear-diagram-storage-event.js +5 -0
- package/dist/collection/components/graphwise-reactodia/models/error/error-cause.js +1 -0
- package/dist/collection/components/graphwise-reactodia/models/error/error-code.js +20 -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 +8 -0
- package/dist/collection/components/graphwise-reactodia/models/reactodia-config.js +1 -0
- package/dist/collection/components/graphwise-reactodia/models/sparql/sparql-query-function.js +1 -0
- package/dist/collection/components/graphwise-reactodia/models/sparql/sparql-query-params.js +1 -0
- package/dist/collection/components/graphwise-reactodia/models/subscription-list.js +35 -0
- package/dist/collection/components/graphwise-reactodia/models/subscription.js +1 -0
- package/dist/collection/components/graphwise-reactodia/models/triple.js +1 -0
- package/dist/collection/components/graphwise-reactodia/models/ui/menu-config.js +1 -0
- package/dist/collection/components/graphwise-reactodia/models/ui/menu-item.js +18 -0
- package/dist/collection/components/graphwise-reactodia/models/ui/node-action.js +22 -0
- package/dist/collection/components/graphwise-reactodia/models/ui/resolved-toolbar-position.js +1 -0
- package/dist/collection/components/graphwise-reactodia/models/ui/resolved-ui-config.js +1 -0
- package/dist/collection/components/graphwise-reactodia/models/ui/toolbar-dock.js +14 -0
- package/dist/collection/components/graphwise-reactodia/models/ui/toolbar-position.js +1 -0
- package/dist/collection/components/graphwise-reactodia/models/ui/ui-config.js +1 -0
- package/dist/collection/components/graphwise-reactodia/node-action/node-actions.js +22 -0
- package/dist/collection/components/graphwise-reactodia/providers/service/service-inject.js +15 -0
- package/dist/collection/components/graphwise-reactodia/providers/service/service.js +19 -0
- package/dist/collection/components/graphwise-reactodia/providers/service/service.provider.js +20 -0
- package/dist/collection/components/graphwise-reactodia/reactodia-app.js +188 -26
- package/dist/collection/components/graphwise-reactodia/services/diagram/diagram.service.js +71 -0
- package/dist/collection/components/graphwise-reactodia/services/diagram-file/diagram-file.service.js +68 -0
- package/dist/collection/components/graphwise-reactodia/services/diagram-storage/diagram-storage.service.js +71 -0
- package/dist/collection/components/graphwise-reactodia/services/error/error.service.js +78 -0
- package/dist/collection/components/graphwise-reactodia/services/event/event.service.js +58 -0
- package/dist/collection/components/graphwise-reactodia/services/window/window.service.js +24 -0
- package/dist/collection/components/graphwise-reactodia/styles/type-style.resolver.js +52 -0
- package/dist/collection/components/graphwise-reactodia/testing/storage.mock.js +35 -0
- package/dist/collection/components/graphwise-reactodia/ui-config/default-ui-config.js +30 -0
- package/dist/collection/components/graphwise-reactodia/ui-config/ui-config-mapper.js +51 -0
- package/dist/collection/components/graphwise-reactodia/utils/object-util.js +30 -0
- package/dist/collection/index.js +7 -1
- package/dist/collection/pages/graphwise-reactodia/main.js +157 -0
- package/dist/collection/pages/graphwise-reactodia/owl-rdfs-settings.js +195 -0
- package/dist/esm/graphwise-reactodia.entry.js +28519 -41232
- package/dist/esm/graphwise-reactodia.js +3 -3
- package/dist/esm/{index-Cypw7ydc.js → index-DpCR6zMg.js} +16 -1
- package/dist/esm/index.js +7 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/node-action-fwJ3Zupw.js +94 -0
- package/dist/graphwise-reactodia/graphwise-reactodia.esm.js +1 -1
- package/dist/graphwise-reactodia/index.esm.js +1 -0
- package/dist/graphwise-reactodia/p-DpCR6zMg.js +2 -0
- package/dist/graphwise-reactodia/p-c3d8a69a.entry.js +1 -0
- package/dist/graphwise-reactodia/p-fwJ3Zupw.js +1 -0
- package/dist/types/components/graphwise-reactodia/graphwise-reactodia.d.ts +44 -16
- package/dist/types/components/graphwise-reactodia/i18n/language-key.d.ts +4 -0
- package/dist/types/components/graphwise-reactodia/i18n/translations.d.ts +2 -343
- package/dist/types/components/graphwise-reactodia/menu/export-diagram-action.d.ts +4 -0
- package/dist/types/components/graphwise-reactodia/menu/graphwise-menu.d.ts +6 -0
- package/dist/types/components/graphwise-reactodia/menu/import-diagram-action.d.ts +4 -0
- package/dist/types/components/graphwise-reactodia/models/clear-diagram-storage-event.d.ts +5 -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 +19 -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 +55 -0
- package/dist/types/components/graphwise-reactodia/models/event/event-type.d.ts +7 -0
- package/dist/types/components/graphwise-reactodia/models/reactodia-app-props.d.ts +20 -15
- package/dist/types/components/graphwise-reactodia/models/reactodia-config.d.ts +36 -0
- package/dist/types/components/graphwise-reactodia/models/sparql/sparql-query-function.d.ts +6 -0
- package/dist/types/components/graphwise-reactodia/models/sparql/sparql-query-params.d.ts +12 -0
- package/dist/types/components/graphwise-reactodia/models/subscription-list.d.ts +26 -0
- package/dist/types/components/graphwise-reactodia/models/subscription.d.ts +4 -0
- package/dist/types/components/graphwise-reactodia/models/triple.d.ts +19 -0
- package/dist/types/components/graphwise-reactodia/models/ui/menu-config.d.ts +8 -0
- package/dist/types/components/graphwise-reactodia/models/ui/menu-item.d.ts +17 -0
- package/dist/types/components/graphwise-reactodia/models/ui/node-action.d.ts +21 -0
- package/dist/types/components/graphwise-reactodia/models/ui/resolved-toolbar-position.d.ts +8 -0
- package/dist/types/components/graphwise-reactodia/models/ui/resolved-ui-config.d.ts +12 -0
- package/dist/types/components/graphwise-reactodia/models/ui/toolbar-dock.d.ts +13 -0
- package/dist/types/components/graphwise-reactodia/models/ui/toolbar-position.d.ts +11 -0
- package/dist/types/components/graphwise-reactodia/models/ui/ui-config.d.ts +17 -0
- package/dist/types/components/graphwise-reactodia/node-action/node-actions.d.ts +6 -0
- package/dist/types/components/graphwise-reactodia/providers/service/service-inject.d.ts +13 -0
- package/dist/types/components/graphwise-reactodia/providers/service/service.d.ts +28 -0
- package/dist/types/components/graphwise-reactodia/providers/service/service.provider.d.ts +16 -0
- package/dist/types/components/graphwise-reactodia/reactodia-app.d.ts +3 -2
- package/dist/types/components/graphwise-reactodia/services/diagram/diagram.service.d.ts +36 -0
- package/dist/types/components/graphwise-reactodia/services/diagram-file/diagram-file.service.d.ts +24 -0
- package/dist/types/components/graphwise-reactodia/services/diagram-storage/diagram-storage.service.d.ts +27 -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 +30 -0
- package/dist/types/components/graphwise-reactodia/services/window/window.service.d.ts +7 -0
- package/dist/types/components/graphwise-reactodia/styles/type-style.resolver.d.ts +11 -0
- package/dist/types/components/graphwise-reactodia/testing/storage.mock.d.ts +18 -0
- package/dist/types/components/graphwise-reactodia/ui-config/default-ui-config.d.ts +5 -0
- package/dist/types/components/graphwise-reactodia/ui-config/ui-config-mapper.d.ts +14 -0
- package/dist/types/components/graphwise-reactodia/utils/object-util.d.ts +15 -0
- package/dist/types/components.d.ts +60 -27
- package/dist/types/index.d.ts +15 -1
- package/package.json +39 -10
- package/dist/graphwise-reactodia/p-Cypw7ydc.js +0 -2
- package/dist/graphwise-reactodia/p-bafd6be5.entry.js +0 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { SparqlQueryFunction } from './sparql/sparql-query-function';
|
|
2
|
+
import { Triple } from './triple';
|
|
3
|
+
import { UiConfig } from './ui/ui-config';
|
|
4
|
+
/**
|
|
5
|
+
* Host-supplied configuration read once when the workspace mounts (not reactive).
|
|
6
|
+
*
|
|
7
|
+
* Groups the inputs the host wires up before the graph is created: the SPARQL transport
|
|
8
|
+
* and the optional set of entities to pre-populate the canvas with. Passed to the
|
|
9
|
+
* `graphwise-reactodia` component as a single DOM property (an object, not an attribute).
|
|
10
|
+
*/
|
|
11
|
+
export interface ReactodiaConfig {
|
|
12
|
+
/**
|
|
13
|
+
* HTTP transport for the SPARQL requests. Set by the host so requests go through the host's
|
|
14
|
+
* HTTP layer (auth, interceptors) instead of a built-in `fetch`.
|
|
15
|
+
*/
|
|
16
|
+
queryFunction: SparqlQueryFunction;
|
|
17
|
+
/**
|
|
18
|
+
* IRIs of the elements(nodes) to place on the canvas on startup. When provided, each IRI is added
|
|
19
|
+
* as an element and its data (labels, types, properties) and links are resolved from the
|
|
20
|
+
* SPARQL provider, then the workspace lays them out. Note that when using this seed method reactodia will request data
|
|
21
|
+
* from the connected sparql endpoint for both elements and links, so if the resources are not in the DB, then this approach will not work.
|
|
22
|
+
* (e.g. in the case of a construct query)
|
|
23
|
+
*/
|
|
24
|
+
seedIris?: string[];
|
|
25
|
+
/**
|
|
26
|
+
* Pre-resolved triples (source, rawPredicate, target) to place on the canvas on startup. Date for the links is provided
|
|
27
|
+
* here, so reactodia will not request data for them. Data for nodes will be requested based on the IRIs of the source
|
|
28
|
+
* and target of the links. This is useful for visualizing the result of a CONSTRUCT query, whose relationships are
|
|
29
|
+
* computed and not persisted in the repository
|
|
30
|
+
*/
|
|
31
|
+
seedGraph?: Triple[];
|
|
32
|
+
/**
|
|
33
|
+
* A partial UI configuration, merged over the default UI configuration. JSON-serializable.
|
|
34
|
+
*/
|
|
35
|
+
ui?: UiConfig;
|
|
36
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SparqlQueryParams } from './sparql-query-params';
|
|
2
|
+
/**
|
|
3
|
+
* HTTP transport for the SPARQL requests. The data provider passes it to the fork, so the compiler checks it against
|
|
4
|
+
* the fork's `SparqlQueryFunction`.
|
|
5
|
+
*/
|
|
6
|
+
export type SparqlQueryFunction = (params: SparqlQueryParams) => Promise<Response>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Subscription } from './subscription';
|
|
2
|
+
/**
|
|
3
|
+
* A collection of {@link Subscription}s that can be released together. Components collect the
|
|
4
|
+
* subscriptions they open and call {@link unsubscribeAll} on teardown so nothing is left
|
|
5
|
+
* listening.
|
|
6
|
+
*/
|
|
7
|
+
export declare class SubscriptionList {
|
|
8
|
+
private items;
|
|
9
|
+
constructor(subscriptions?: Subscription[]);
|
|
10
|
+
/**
|
|
11
|
+
* Adds a subscription to the list.
|
|
12
|
+
*/
|
|
13
|
+
add(subscription: Subscription): void;
|
|
14
|
+
/**
|
|
15
|
+
* Adds multiple subscriptions to the list.
|
|
16
|
+
*/
|
|
17
|
+
addAll(subscriptions: Subscription[]): void;
|
|
18
|
+
/**
|
|
19
|
+
* Removes a subscription from the list without unsubscribing it.
|
|
20
|
+
*/
|
|
21
|
+
remove(subscription: Subscription): void;
|
|
22
|
+
/**
|
|
23
|
+
* Calls every subscription (unsubscribing it) and clears the list.
|
|
24
|
+
*/
|
|
25
|
+
unsubscribeAll(): void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A pre-resolved edge to place on the canvas on startup, mirroring GraphDB's
|
|
3
|
+
* `rest/explore-graph` link shape. Used to visualize the result of a CONSTRUCT query, whose
|
|
4
|
+
* relationships are computed and therefore not persisted in the repository, so they cannot be
|
|
5
|
+
* fetched lazily through the SPARQL provider and must be supplied directly.
|
|
6
|
+
*
|
|
7
|
+
* The host adapts its source data into this neutral shape (e.g. the workbench maps the
|
|
8
|
+
* `rest/explore-graph/graph` response onto {@link rawPredicates}).
|
|
9
|
+
*/
|
|
10
|
+
export interface Triple {
|
|
11
|
+
/** Source element IRI. */
|
|
12
|
+
source: string;
|
|
13
|
+
/** Target element IRI. */
|
|
14
|
+
target: string;
|
|
15
|
+
/**
|
|
16
|
+
* Full (absolute) predicate IRIs.
|
|
17
|
+
*/
|
|
18
|
+
rawPredicates: string[];
|
|
19
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An entry of the workspace main menu.
|
|
3
|
+
*/
|
|
4
|
+
export declare enum MenuItem {
|
|
5
|
+
/** Removes all nodes from the diagram. */
|
|
6
|
+
CLEAR_ALL = "clear-all",
|
|
7
|
+
/** Exports the diagram as a PNG image. */
|
|
8
|
+
EXPORT_PNG = "export-png",
|
|
9
|
+
/** Exports the diagram as an SVG image. */
|
|
10
|
+
EXPORT_SVG = "export-svg",
|
|
11
|
+
/** Prints the diagram. */
|
|
12
|
+
PRINT = "print",
|
|
13
|
+
/** Exports the diagram as a JSON file. */
|
|
14
|
+
EXPORT_JSON = "export-json",
|
|
15
|
+
/** Imports a diagram from a JSON file. */
|
|
16
|
+
IMPORT_JSON = "import-json"
|
|
17
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A button shown around a selected node that acts on it.
|
|
3
|
+
*/
|
|
4
|
+
export declare enum NodeAction {
|
|
5
|
+
/** Groups or ungroups the selected nodes. */
|
|
6
|
+
GROUP = "group",
|
|
7
|
+
/** Removes the node from the diagram. */
|
|
8
|
+
REMOVE = "remove",
|
|
9
|
+
/** Expands or collapses the node to show its properties. */
|
|
10
|
+
EXPAND = "expand",
|
|
11
|
+
/** Opens the node IRI. */
|
|
12
|
+
OPEN_LINK = "open-link",
|
|
13
|
+
/** Opens the menu to navigate to connected nodes. */
|
|
14
|
+
CONNECTIONS = "connections",
|
|
15
|
+
/** Searches for nodes connected to this one. */
|
|
16
|
+
ADD_TO_FILTER = "add-to-filter",
|
|
17
|
+
/** Adds an annotation to the node. */
|
|
18
|
+
ANNOTATE = "annotate",
|
|
19
|
+
/** Draws a new link from the node; for an entity, only in authoring mode. */
|
|
20
|
+
ESTABLISH_LINK = "establish-link"
|
|
21
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MenuConfig } from './menu-config';
|
|
2
|
+
import { NodeAction } from './node-action';
|
|
3
|
+
import { ResolvedToolbarPosition } from './resolved-toolbar-position';
|
|
4
|
+
/**
|
|
5
|
+
* The host's UI configuration merged over the default, with every field set.
|
|
6
|
+
*/
|
|
7
|
+
export interface ResolvedUiConfig {
|
|
8
|
+
mainToolbar: ResolvedToolbarPosition;
|
|
9
|
+
actionsToolbar: ResolvedToolbarPosition;
|
|
10
|
+
menu: Required<MenuConfig>;
|
|
11
|
+
nodeActions: NodeAction[];
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ToolbarDock } from './toolbar-dock';
|
|
2
|
+
/**
|
|
3
|
+
* Where a toolbar is placed on the canvas.
|
|
4
|
+
*/
|
|
5
|
+
export interface ToolbarPosition {
|
|
6
|
+
dock?: ToolbarDock;
|
|
7
|
+
/** Horizontal offset from the dock, in pixels. */
|
|
8
|
+
offsetX?: number;
|
|
9
|
+
/** Vertical offset from the dock, in pixels. */
|
|
10
|
+
offsetY?: number;
|
|
11
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MenuConfig } from './menu-config';
|
|
2
|
+
import { NodeAction } from './node-action';
|
|
3
|
+
import { ToolbarPosition } from './toolbar-position';
|
|
4
|
+
/**
|
|
5
|
+
* The UI configuration a host passes. It is partial and merged over the default UI configuration: objects are merged
|
|
6
|
+
* key by key, lists replace the default whole.
|
|
7
|
+
*/
|
|
8
|
+
export interface UiConfig {
|
|
9
|
+
/** The toolbar with the menu and the search. */
|
|
10
|
+
mainToolbar?: ToolbarPosition;
|
|
11
|
+
/** The toolbar with undo, redo and layout. */
|
|
12
|
+
actionsToolbar?: ToolbarPosition;
|
|
13
|
+
/** The main menu in the main toolbar. */
|
|
14
|
+
menu?: MenuConfig;
|
|
15
|
+
/** The actions shown around a selected node. */
|
|
16
|
+
nodeActions?: NodeAction[];
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Service } from './service';
|
|
2
|
+
/**
|
|
3
|
+
* Injects the singleton instance of the given service class from the {@link ServiceProvider}.
|
|
4
|
+
*
|
|
5
|
+
* @param serviceClass The class of the service to inject.
|
|
6
|
+
* @returns The shared instance of the specified service class.
|
|
7
|
+
* @template T The type of the service to inject.
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const diagramStateService = service(DiagramStateService);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare function service<T>(serviceClass: Service<T>): T;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for injectable services by the service provider. Each service needs to have a static unique ID, which
|
|
3
|
+
* is used by the {@link ServiceProvider} to cache and retrieve the singleton instance of the service. Unique IDs ensure
|
|
4
|
+
* correct working of the service provider, when the services are minified
|
|
5
|
+
*
|
|
6
|
+
* @template T the type of the service
|
|
7
|
+
*/
|
|
8
|
+
export interface Service<T> {
|
|
9
|
+
readonly ID: string;
|
|
10
|
+
new (): T;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Decorator for a service class.
|
|
14
|
+
* It receives the class and simply type checks it with the {@link Service} interface.
|
|
15
|
+
* Works as a contract, which enforces the service class to have a static ID member.
|
|
16
|
+
* We can't simply implement the interface, since this will enforce the ID to be an instance member, which is not what we want.
|
|
17
|
+
*
|
|
18
|
+
* @param _serviceClass The decorated service class, checked for its ID and discarded.
|
|
19
|
+
* @template T The type of the service instance.
|
|
20
|
+
* @example
|
|
21
|
+
* ```TypeScript
|
|
22
|
+
* @Service
|
|
23
|
+
* export class WindowService {
|
|
24
|
+
* static readonly ID = 'WindowService';
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function Service<T>(_serviceClass: Service<T>): void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Service } from './service';
|
|
2
|
+
/**
|
|
3
|
+
* Provider for all {@link Service} instances. Services are singletons: there is only one
|
|
4
|
+
* instance of each service, created on demand and cached here so every consumer shares it.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ServiceProvider {
|
|
7
|
+
private static readonly SERVICE_INSTANCES;
|
|
8
|
+
/**
|
|
9
|
+
* Returns the instance of the given service type, creating and caching it on first request.
|
|
10
|
+
*
|
|
11
|
+
* @param serviceClass The service type to retrieve.
|
|
12
|
+
* @returns The shared instance of the service.
|
|
13
|
+
* @template T The type of the service to retrieve.
|
|
14
|
+
*/
|
|
15
|
+
static get<T>(serviceClass: Service<T>): T;
|
|
16
|
+
}
|
|
@@ -6,8 +6,9 @@ import { ReactodiaAppProps } from './models/reactodia-app-props';
|
|
|
6
6
|
*/
|
|
7
7
|
export declare function mountReactodia(container: HTMLElement, props: ReactodiaAppProps): Root;
|
|
8
8
|
/**
|
|
9
|
-
* Re-points the diagram at a new SPARQL endpoint
|
|
10
|
-
*
|
|
9
|
+
* Re-points the diagram at a new SPARQL endpoint by recreating it with a fresh data provider.
|
|
10
|
+
* The canvas is reset to empty, matching the initial mount, since the data of another repository
|
|
11
|
+
* has nothing to do with the current graph. A failure is reported, not thrown.
|
|
11
12
|
*/
|
|
12
13
|
export declare function updateReactodia(props: ReactodiaAppProps): Promise<void>;
|
|
13
14
|
/**
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { DataDiagramModel, DataProvider, SerializedDiagram } from '@reactodia/workspace';
|
|
2
|
+
import { Subscription } from '../../models/subscription';
|
|
3
|
+
/**
|
|
4
|
+
* Callback invoked with the current diagram layout whenever it changes.
|
|
5
|
+
*/
|
|
6
|
+
export type DiagramChangeCallback = (diagram: SerializedDiagram) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Service for diagram related operations and subscriptions
|
|
9
|
+
*/
|
|
10
|
+
export declare class DiagramService {
|
|
11
|
+
static readonly ID = "DiagramService";
|
|
12
|
+
private static readonly NOTIFY_DEBOUNCE_MS;
|
|
13
|
+
private static readonly HISTORY_CHANGED_EVENT;
|
|
14
|
+
/**
|
|
15
|
+
* Replaces the diagram content with the given serialization. Element data is requested from the data provider and
|
|
16
|
+
* the links between the imported elements are validated against it.
|
|
17
|
+
*
|
|
18
|
+
* @param model The diagram model to import into.
|
|
19
|
+
* @param dataProvider The data provider to bind to the diagram.
|
|
20
|
+
* @param diagram The serialization to import. When `undefined`, the diagram is cleared.
|
|
21
|
+
* @param signal Optional signal to abort the import.
|
|
22
|
+
*/
|
|
23
|
+
importDiagram(model: DataDiagramModel, dataProvider: DataProvider, diagram: SerializedDiagram | undefined, signal?: AbortSignal): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Subscribes to diagram changes. On every debounced change the current layout is
|
|
26
|
+
* exported and passed to the callback.
|
|
27
|
+
* Debounce time for the callback trigger is needed, because certain events (like moving a node) can trigger
|
|
28
|
+
* multiple `historyChanged` events in a short time.
|
|
29
|
+
*
|
|
30
|
+
* @param model The diagram model to observe.
|
|
31
|
+
* @param onChangeCallback Called with the exported layout when the diagram changes.
|
|
32
|
+
* @returns A {@link Subscription} that, when called, removes the listener and drops any
|
|
33
|
+
* pending notification.
|
|
34
|
+
*/
|
|
35
|
+
subscribeToDiagramChange(model: DataDiagramModel, onChangeCallback: DiagramChangeCallback): Subscription;
|
|
36
|
+
}
|
package/dist/types/components/graphwise-reactodia/services/diagram-file/diagram-file.service.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { SerializedDiagram } from '@reactodia/workspace';
|
|
2
|
+
/**
|
|
3
|
+
* Service for downloading and uploading the diagram as a file. The file content is the same
|
|
4
|
+
* {@link SerializedDiagram} that is persisted to the local store.
|
|
5
|
+
*/
|
|
6
|
+
export declare class DiagramFileService {
|
|
7
|
+
static readonly ID = "DiagramFileService";
|
|
8
|
+
static readonly FILE_EXTENSION = ".json";
|
|
9
|
+
private static readonly MIME_TYPE;
|
|
10
|
+
/**
|
|
11
|
+
* Downloads the given diagram serialization as a file with the given name.
|
|
12
|
+
*/
|
|
13
|
+
download(diagram: SerializedDiagram, fileName: string): void;
|
|
14
|
+
/**
|
|
15
|
+
* Reads a diagram serialization from the given file.
|
|
16
|
+
*
|
|
17
|
+
* @throws Error when the file is not valid JSON or is not a serialized diagram.
|
|
18
|
+
*/
|
|
19
|
+
read(file: File): Promise<SerializedDiagram>;
|
|
20
|
+
/**
|
|
21
|
+
* Checks if the provided value is a serialized diagram
|
|
22
|
+
*/
|
|
23
|
+
private isSerializedDiagram;
|
|
24
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { SerializedDiagram } from '@reactodia/workspace';
|
|
2
|
+
/**
|
|
3
|
+
* Service for local store-related diagram operations
|
|
4
|
+
*/
|
|
5
|
+
export declare class DiagramStorageService {
|
|
6
|
+
static readonly ID = "DiagramStorageService";
|
|
7
|
+
private static readonly STORAGE_KEY;
|
|
8
|
+
private readonly errorService;
|
|
9
|
+
/**
|
|
10
|
+
* Load the persisted diagram from the local store, or `undefined` when nothing is stored (or the stored value
|
|
11
|
+
* is unreadable).
|
|
12
|
+
*/
|
|
13
|
+
load(): SerializedDiagram | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Persists the given diagram serialization.
|
|
16
|
+
*/
|
|
17
|
+
save(diagram: SerializedDiagram): void;
|
|
18
|
+
/**
|
|
19
|
+
* Removes the persisted diagram. Used when a new view (a seed) should take precedence over
|
|
20
|
+
* previously saved edits.
|
|
21
|
+
*/
|
|
22
|
+
clear(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Local storage getter
|
|
25
|
+
*/
|
|
26
|
+
private get storage();
|
|
27
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ErrorCode } from '../../models/error/error-code';
|
|
2
|
+
/**
|
|
3
|
+
* Service that collects the failures of the wrapper and the fork, so they can be announced to the host.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ErrorService {
|
|
6
|
+
static readonly ID = "ErrorService";
|
|
7
|
+
private static readonly ABORT_ERROR_NAME;
|
|
8
|
+
private readonly eventService;
|
|
9
|
+
private readonly reported;
|
|
10
|
+
/**
|
|
11
|
+
* Reports a failure to the host, unless it's an abort, or this exact error object is already reported
|
|
12
|
+
* from another place.
|
|
13
|
+
*
|
|
14
|
+
* The same error object may be reported from different places. E.g. a query that fails while a diagram loads is
|
|
15
|
+
* reported by the data provider decorator as `data-fetch`, and then reaches the `catch` around the load, which
|
|
16
|
+
* reports it as `diagram-load`. Only the first one is announced.
|
|
17
|
+
*
|
|
18
|
+
* The `cause` is checked because the fork wraps whatever fails during a diagram import in a new error:
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* // reactodia-workspace/src/editor/dataDiagramModel.ts, importLayout
|
|
22
|
+
* } catch (error) {
|
|
23
|
+
* throw new Error('Reactodia: failed to import a layout', {cause: error});
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* We need to check the cause to make sure we don't report the same error/abort more than once.
|
|
28
|
+
*
|
|
29
|
+
* @param code The category of the failure.
|
|
30
|
+
* @param thrown The thrown value.
|
|
31
|
+
*/
|
|
32
|
+
report(code: ErrorCode, thrown: unknown): void;
|
|
33
|
+
/**
|
|
34
|
+
* Whether any link of the given cause chain is an abort or is already reported.
|
|
35
|
+
*/
|
|
36
|
+
private isAbortedOrAlreadyReported;
|
|
37
|
+
/**
|
|
38
|
+
* The thrown value followed by its `cause`, the cause of that, and so on, for as long as they are objects.
|
|
39
|
+
*/
|
|
40
|
+
private causeChain;
|
|
41
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Subscription } from '../../models/subscription';
|
|
2
|
+
import { EventCallback } from '../../models/event/event-callback';
|
|
3
|
+
import { EventDetail } from '../../models/event/event-detail';
|
|
4
|
+
/**
|
|
5
|
+
* Service for event based operations
|
|
6
|
+
*/
|
|
7
|
+
export declare class EventService {
|
|
8
|
+
static readonly ID = "EventService";
|
|
9
|
+
private callback?;
|
|
10
|
+
/**
|
|
11
|
+
* Announces an event to the host.
|
|
12
|
+
*
|
|
13
|
+
* @param detail The event detail.
|
|
14
|
+
*/
|
|
15
|
+
emit(detail: EventDetail): void;
|
|
16
|
+
/**
|
|
17
|
+
* Subscribes to the emitted events, replacing the previous subscriber.
|
|
18
|
+
*
|
|
19
|
+
* @param callback Called with every emitted event.
|
|
20
|
+
* @returns A {@link Subscription} that, when called, removes the callback, unless it has already been replaced.
|
|
21
|
+
*/
|
|
22
|
+
subscribe(callback: EventCallback): Subscription;
|
|
23
|
+
/**
|
|
24
|
+
* Subscribes to the host's "clear persisted diagram" command.
|
|
25
|
+
*
|
|
26
|
+
* @param onClear Called whenever the event fires.
|
|
27
|
+
* @returns A {@link Subscription} that, when called, removes the listener.
|
|
28
|
+
*/
|
|
29
|
+
subscribeToClearDiagramStorage(onClear: () => void): Subscription;
|
|
30
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TypeStyleResolver } from '@reactodia/workspace';
|
|
2
|
+
/**
|
|
3
|
+
* Colors an element by its type: each type takes the next color from the palette, which wraps
|
|
4
|
+
* around once it runs out
|
|
5
|
+
*
|
|
6
|
+
* Returns `undefined` for elements without a type (placeholders and other non-entity elements) and
|
|
7
|
+
* when the host does not define the palette, leaving Reactodia to fall back to its own hash-based
|
|
8
|
+
* colors.
|
|
9
|
+
*/
|
|
10
|
+
export declare const resolveTypeStyle: TypeStyleResolver;
|
|
11
|
+
export declare const resetColors: () => void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal in-memory {@link Storage}, so services that read `localStorage` can be exercised
|
|
3
|
+
* without a real browser store and asserted against directly. Shared across test suites.
|
|
4
|
+
*/
|
|
5
|
+
export declare class StorageMock implements Storage {
|
|
6
|
+
private readonly store;
|
|
7
|
+
get length(): number;
|
|
8
|
+
clear(): void;
|
|
9
|
+
getItem(key: string): string | null;
|
|
10
|
+
key(index: number): string | null;
|
|
11
|
+
removeItem(key: string): void;
|
|
12
|
+
setItem(key: string, value: string): void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Creates a fresh {@link StorageMock}. Suites install the returned instance as the global
|
|
16
|
+
* `localStorage` themselves.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createStorageMock(): StorageMock;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DefaultWorkspaceProps } from '@reactodia/workspace';
|
|
2
|
+
import { UiConfig } from '../models/ui/ui-config';
|
|
3
|
+
/**
|
|
4
|
+
* The `DefaultWorkspace` props the UI configuration sets.
|
|
5
|
+
*/
|
|
6
|
+
export type UiConfigProps = Pick<DefaultWorkspaceProps, 'menu' | 'mainToolbar' | 'actionsToolbar' | 'halo'>;
|
|
7
|
+
/**
|
|
8
|
+
* Merges the host's UI configuration over the default and maps the result to `DefaultWorkspace` props. A `null` or
|
|
9
|
+
* missing field keeps the default; objects merge key by key and lists replace the default whole. Unknown values are
|
|
10
|
+
* reported and left out; a repeated list entry is kept once.
|
|
11
|
+
*
|
|
12
|
+
* @param ui The host's UI configuration.
|
|
13
|
+
*/
|
|
14
|
+
export declare function toWorkspaceProps(ui: UiConfig | undefined): UiConfigProps;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Merges an object with default values. Ported from the GraphDB Workbench `ObjectUtil.mergeWithDefaults`.
|
|
3
|
+
*
|
|
4
|
+
* For each property in `defaults`, if the value in `object` is `null` or `undefined`, the default value is used instead.
|
|
5
|
+
* Nested objects are merged recursively. Arrays and other non-plain values are treated as single values and are not
|
|
6
|
+
* merged.
|
|
7
|
+
*
|
|
8
|
+
* The returned object is a new object and does not share references with the inputs. The inputs must be
|
|
9
|
+
* structured-cloneable.
|
|
10
|
+
*
|
|
11
|
+
* @param object Source object whose values take precedence over defaults.
|
|
12
|
+
* @param defaults Default values applied when properties are missing or null.
|
|
13
|
+
* @returns A new object containing the merged result.
|
|
14
|
+
*/
|
|
15
|
+
export declare function mergeWithDefaults<T extends object>(object: object, defaults: T): T;
|