@lionweb/delta-protocol-client 0.7.0-beta.21

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/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ # Changelog
2
+
3
+ ## 0.7.0
4
+
5
+ Initial creation and publication of this package.
6
+
package/README.md ADDED
@@ -0,0 +1,138 @@
1
+ # The `delta-protocol-client` package
2
+
3
+ [![license](https://img.shields.io/badge/License-Apache%202.0-green.svg?style=flat)
4
+ ](./LICENSE)
5
+
6
+ An NPM package that can be added to a Node.js/NPM codebase as follows:
7
+
8
+ ```shell
9
+ $ npm add @lionweb/delta-protocol-client
10
+ ```
11
+
12
+ This package implements client that complies with the LionWeb delta protocol is implemented as the `LionWebClient` class.
13
+ It *does not* take care of the message transport protocol!
14
+ It implements the API specification as found [here](https://github.com/LionWeb-io/specification/blob/main/delta/delta-api.adoc).
15
+
16
+ A LionWeb client manages exactly one “model”, meaning a forest of nodes with root nodes having `Concept`s marked as partitions as their classifiers.
17
+ “To manage” means the following things:
18
+
19
+ 1. Adding to and deleting partitions from the model.
20
+ 2. Taking care that changes (AKA “deltas”) to the model are propagated as commands to a LionWeb delta protocol-compliant repository.
21
+ 3. Taking care that incoming events are applied to the model.
22
+
23
+ **Note** that no conflict resolution is implemented at any level.
24
+ Concretely, this means:
25
+
26
+ * Changes to the model are assumed to be conflict-free with any other changes that may have been concurrently through the connected repository.
27
+ This means, in particular, that any change is assumed to directly lead to an event (coming from the connected repository) that corresponds *exactly* to the change.
28
+ * Any events coming from the connected repository correspond to a change that’s either already made to the model, or can be applied directly and entirely conflict-free to the model.
29
+
30
+ The client connects with the repository through a WebSocket connection.
31
+ The details of this connection are entirely encapsulated in two `LowLevelClient` and `LowLevelServer` classes.
32
+ These are quite generic (through type parameters for payload types, and configured callback functions), and not at all specific to the LionWeb delta protocol, which makes unit testing these classes quite simple.
33
+
34
+
35
+ ## Setting up a client
36
+
37
+ A client can be instantiated as follows:
38
+
39
+ ```typescript
40
+ import { LionWebClient } from "@lionweb/delta-protocol-client"
41
+
42
+ const lionWebClient = await LionWebClient.create({
43
+ <parameter object>
44
+ })
45
+ ```
46
+
47
+ The properties of the `<parameter object>` are as follows:
48
+
49
+ * `clientId`: (required) a string containing the client’s ID, unique within the scope of the repository it connects to.
50
+ It’s also exposed as a field on the client object.
51
+ * `url`: (required) a string containing the URL of the WebSocket exposed by the LionWeb delta protocol-compliant repository.
52
+ (The `wsLocalhostUrl` function may be convenient to use — especially in test contexts.)
53
+ * `languageBases`: (required) an array containing the implementations of `ILanguageBase` for the languages of the model managed by the client.
54
+ * `serializationChunk`: (optional) a `LionWebJsonChunk` that represents the initial state of the model managed by the client.
55
+ If no serialization chunk is provided, the model’s initial state is *empty* — i.e., no roots/partitions.
56
+ * `instantiateDeltaReceiverForwardingTo`: (optional) a function that, given a (so-called) “downstream” delta receiver, returns an “upstream/forwarding” delta receiver that forwards deltas (that result from changes to the managed model) to that downstream delta receiver.
57
+ This mechanism is used to intercept changes (as deltas) to the model for purposes other than turning these directly into commands to the LionWeb repository.
58
+ The “upstream/forwarding” delta receiver has the obligations to (eventually) forward all deltas it receives as commands to the LionWeb repository.
59
+ * `semanticLogger`: (optional) a `SemanticLogger` instance that accepts semantic log items (`ISemanticLogItem`), to be able to provide verbosity on what’s going on.
60
+ (This is predominantly useful for testing.)
61
+ * `lowLevelClientInstantiator`: (optional) a function that instantiates a `LowLevelClient`, given a client ID, an URL, and a `receiveMessageOnClient` function that handles incoming messages.
62
+ This is intended solely for testing purposes, to implement a mock implementation of a LionWeb repository, without needing an actual, working repository implementation, nor even a WebSocket connection.
63
+
64
+ During creation of the client, a WebSocket connection with the LionWeb repository is set up, and if a serialization chunk is given, it gets deserialized as the model.
65
+ After creation of the client, it exposes the following data:
66
+
67
+ * `.clientId`: the client’s ID.
68
+ * `.model`: the managed model, as an array of nodes of `Concept`s that are marked as partition.
69
+ * `.createNode`: a factory function that instantiates a node having the given classifier and ID.
70
+ The client ensures that that node is wired-up with an appropriate delta receiver that intercepts changes and propagates these as commands to the connected LionWeb repository.
71
+ * `.participationId`: defined after establishing a participation – see below.
72
+
73
+ The first thing to do before manipulating the model, is to establish a **participation**, which is done as follows:
74
+
75
+ ```typescript
76
+ await lionWebClient.signOn(<query ID>)
77
+ ```
78
+
79
+ Before a participation has been established, the client can’t send any commands to the LionWeb repository, nor receive any events.
80
+ Provided this call succeeds, the ID of the established participation can be retrieved as `lionWebClient.participationId`.
81
+
82
+ After having established a participation through signing on, the model available through `lionWebClient.model` can be manipulated.
83
+ Adding and deleting partitions is done through the `.addPartition(<partition>)` and `.deletePartition(<partition>)` methods.
84
+ Changes made to the model are propagated to the effective delta receiver – see the explanation of `instantiateDeltaReceiverForwardingTo` above –, and eventually to the LionWeb repository, as commands.
85
+
86
+ When you are finished with a client, you can disconnect it from the repository as follows:
87
+
88
+ ```typescript
89
+ await lionWebClient.disconnect()
90
+ ```
91
+
92
+ After this, the client can’t send any queries nor commands, nor receive any events anymore.
93
+
94
+
95
+ ## Hooking up an undo stack
96
+
97
+ ```typescript
98
+ import { DeltaCompositor, deltaReceiverForwardingTo, IDelta } from "@lionweb/class-core"
99
+ import { LionWebClient } from "@lionweb/delta-protocol-client"
100
+
101
+ const deltas: IDelta[] = []
102
+ let compositorToCreate: DeltaCompositor
103
+ const lionWebClient = await LionWebClient.create({
104
+ // ...other parameters...
105
+ instantiateDeltaReceiverForwardingTo: (commandSender) => {
106
+ compositorToCreate = new DeltaCompositor(deltaReceiverForwardingTo(
107
+ (delta) => {
108
+ deltas.push(delta)
109
+ },
110
+ commandSender
111
+ ))
112
+ return compositorToCreate.upstreamReceiveDelta
113
+ }
114
+ })
115
+ const compositor = compositorToCreate!
116
+ ```
117
+
118
+ Now composites can be opened and closed as follows:
119
+
120
+ ```typescript
121
+ compositor.openComposite()
122
+ // ...change the model...
123
+ compositor.closeComposite()
124
+ ```
125
+
126
+ The model changes emanating from the statements between `compositor.{open|close}Composite()` are emitted as the `parts` commands of a `CompositeCommand`.
127
+
128
+ ***TODO***
129
+
130
+
131
+ ## Development
132
+
133
+ Build this package from source as follows:
134
+
135
+ ```shell
136
+ npm run build
137
+ ```
138
+
@@ -0,0 +1,58 @@
1
+ import { DeltaReceiver, IdMapping, ILanguageBase, INodeBase, NodeBaseFactory } from "@lionweb/class-core";
2
+ import { LionWebId, LionWebJsonChunk } from "@lionweb/json";
3
+ import { Command, Event, QueryMessage, SemanticLogger, SubscribeToPartitionChangesParameters } from "@lionweb/delta-protocol-common";
4
+ import { LowLevelClientInstantiator } from "./low-level-client.js";
5
+ /**
6
+ * Type def. for parameters – required and optional – for instantiating a {@link LionWebClient LionWeb delta protocol client}.
7
+ */
8
+ export type LionWebClientParameters = {
9
+ clientId: LionWebId;
10
+ url: string;
11
+ languageBases: ILanguageBase[];
12
+ lowLevelClientInstantiator: LowLevelClientInstantiator<Event | QueryMessage, Command | QueryMessage>;
13
+ serializationChunk?: LionWebJsonChunk;
14
+ instantiateDeltaReceiverForwardingTo?: (commandSender: DeltaReceiver) => DeltaReceiver;
15
+ semanticLogger?: SemanticLogger;
16
+ };
17
+ /**
18
+ * Implementation of a LionWeb delta protocol client.
19
+ */
20
+ export declare class LionWebClient {
21
+ readonly clientId: LionWebId;
22
+ model: INodeBase[];
23
+ readonly idMapping: IdMapping;
24
+ readonly createNode: NodeBaseFactory;
25
+ private readonly effectiveReceiveDelta;
26
+ private readonly lowLevelClient;
27
+ private _participationId?;
28
+ get participationId(): string | undefined;
29
+ private signedOff;
30
+ private lastReceivedSequenceNumber;
31
+ private constructor();
32
+ private readonly queryResolveById;
33
+ private static readonly nodesByIdFrom;
34
+ static create({ clientId, url, languageBases, instantiateDeltaReceiverForwardingTo, serializationChunk, semanticLogger, lowLevelClientInstantiator }: LionWebClientParameters): Promise<LionWebClient>;
35
+ /**
36
+ * Sets the model held by the client to the given model, discarding the previous one.
37
+ * No commands will be sent because of this action.
38
+ */
39
+ setModel(newModel: INodeBase[]): void;
40
+ disconnect(): Promise<void>;
41
+ /**
42
+ * Makes the query in the sense that the given query request is sent (as a client message),
43
+ * and that the `resolve` callback of the associated `Promise` is stored so the promise can be resolved,
44
+ * so that query call can be `await`ed.
45
+ */
46
+ private readonly makeQuery;
47
+ subscribeToChangingPartitions(queryId: LionWebId, parameters: SubscribeToPartitionChangesParameters): Promise<void>;
48
+ subscribeToPartitionContents(queryId: LionWebId, partition: LionWebId): Promise<LionWebJsonChunk>;
49
+ unsubscribeFromPartitionContents(queryId: LionWebId, partition: LionWebId): Promise<void>;
50
+ signOn(queryId: LionWebId, repositoryId: LionWebId): Promise<void>;
51
+ signOff(queryId: LionWebId): Promise<void>;
52
+ reconnect(queryId: LionWebId, participationId: LionWebId, lastReceivedSequenceNumber: number): Promise<void>;
53
+ private static checkWhetherPartition;
54
+ private checkSignedOn;
55
+ addPartition(partition: INodeBase): void;
56
+ deletePartition(partition: INodeBase): void;
57
+ }
58
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAiBA,OAAO,EAIH,aAAa,EACb,SAAS,EACT,aAAa,EACb,SAAS,EAET,eAAe,EAIlB,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAG3D,OAAO,EAOH,OAAO,EAGP,KAAK,EAIL,YAAY,EAGZ,cAAc,EAMd,qCAAqC,EAIxC,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAkB,0BAA0B,EAAE,MAAM,uBAAuB,CAAA;AAMlF;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG;IAClC,QAAQ,EAAE,SAAS,CAAA;IACnB,GAAG,EAAE,MAAM,CAAA;IACX,aAAa,EAAE,aAAa,EAAE,CAAA;IAC9B,0BAA0B,EAAE,0BAA0B,CAAC,KAAK,GAAG,YAAY,EAAE,OAAO,GAAG,YAAY,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CAAC;IASzF,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAelE,OAAO,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAU1C,SAAS,CAAC,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,0BAA0B,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAelH,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAUpC,OAAO,CAAC,aAAa;IAMrB,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAUxC,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;CAW9C"}
package/dist/client.js ADDED
@@ -0,0 +1,239 @@
1
+ // Copyright 2025 TRUMPF Laser SE and other contributors
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License")
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ //
15
+ // SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
16
+ // SPDX-License-Identifier: Apache-2.0
17
+ import { allNodesFrom, applyDelta, combinedFactoryFor, IdMapping, nodeBaseDeserializer, PartitionAddedDelta, PartitionDeletedDelta, serializeDelta } from "@lionweb/class-core";
18
+ import { Concept } from "@lionweb/core";
19
+ import { byIdMap } from "@lionweb/ts-utils";
20
+ import { ansi, ClientAppliedEvent, ClientDidNotApplyEventFromOwnCommand, ClientHadProblem, ClientReceivedMessage, ClientSentMessage, deltaAsCommand, DeltaOccurredOnClient, eventToDeltaTranslator, isEvent, isQueryResponse, semanticLoggerFunctionFrom } from "@lionweb/delta-protocol-common";
21
+ import { priorityQueueAcceptor } from "./priority-queue.js";
22
+ const { clientWarning } = ansi;
23
+ /**
24
+ * Implementation of a LionWeb delta protocol client.
25
+ */
26
+ export class LionWebClient {
27
+ get participationId() {
28
+ return this._participationId;
29
+ }
30
+ // TODO could also get this from the priority queue (which would need to be adapted for that)
31
+ constructor(clientId, model, idMapping, createNode, effectiveReceiveDelta, lowLevelClient) {
32
+ this.clientId = clientId;
33
+ this.model = model;
34
+ this.idMapping = idMapping;
35
+ this.createNode = createNode;
36
+ this.effectiveReceiveDelta = effectiveReceiveDelta;
37
+ this.lowLevelClient = lowLevelClient;
38
+ this.signedOff = false;
39
+ this.lastReceivedSequenceNumber = -1;
40
+ this.queryResolveById = {};
41
+ // queries, in order of the specification (§ 6.3):
42
+ /**
43
+ * Makes the query in the sense that the given query request is sent (as a client message),
44
+ * and that the `resolve` callback of the associated `Promise` is stored so the promise can be resolved,
45
+ * so that query call can be `await`ed.
46
+ */
47
+ this.makeQuery = (queryRequest) => new Promise((resolveResponse, rejectResponse) => {
48
+ this.queryResolveById[queryRequest.queryId] = resolveResponse;
49
+ this.lowLevelClient.sendMessage(queryRequest)
50
+ .catch(rejectResponse);
51
+ });
52
+ }
53
+ static async create({ clientId, url, languageBases, instantiateDeltaReceiverForwardingTo, serializationChunk, semanticLogger, lowLevelClientInstantiator }) {
54
+ const log = semanticLoggerFunctionFrom(semanticLogger);
55
+ let loading = true;
56
+ let commandNumber = 0;
57
+ const issuedCommandIds = [];
58
+ const commandSender = (delta) => {
59
+ try {
60
+ const serializedDelta = serializeDelta(delta);
61
+ log(new DeltaOccurredOnClient(clientId, serializedDelta));
62
+ if (!loading) {
63
+ const commandId = `cmd-${++commandNumber}`;
64
+ const command = deltaAsCommand(delta, commandId);
65
+ if (command !== undefined) {
66
+ issuedCommandIds.push(commandId); // (register the ID before actually sending the command so that effectively-synchronous tests mimic the actual behavior more reliably)
67
+ lowLevelClient.sendMessage(command);
68
+ log(new ClientSentMessage(clientId, command));
69
+ }
70
+ }
71
+ }
72
+ catch (e) {
73
+ console.error(`error occurred during serialization of delta: ${e.message}`);
74
+ console.dir(delta);
75
+ }
76
+ };
77
+ const effectiveReceiveDelta = instantiateDeltaReceiverForwardingTo === undefined ? commandSender : instantiateDeltaReceiverForwardingTo(commandSender);
78
+ const deserialized = nodeBaseDeserializer(languageBases, effectiveReceiveDelta);
79
+ const model = serializationChunk === undefined ? [] : deserialized(serializationChunk);
80
+ const idMapping = new IdMapping(LionWebClient.nodesByIdFrom(model));
81
+ const eventAsDelta = eventToDeltaTranslator(languageBases, deserialized);
82
+ loading = false;
83
+ const processEvent = (event) => {
84
+ lionWebClient.lastReceivedSequenceNumber = event.sequenceNumber;
85
+ const commandOriginatingFromSelf = event.originCommands.find(({ commandId }) => issuedCommandIds.indexOf(commandId) > -1);
86
+ // Note: we can't remove members from issuedCommandIds because there may be multiple events originating fom a single command.
87
+ if (commandOriginatingFromSelf === undefined) {
88
+ try {
89
+ const delta = eventAsDelta(event, idMapping);
90
+ if (delta !== undefined) {
91
+ try {
92
+ applyDelta(delta);
93
+ log(new ClientAppliedEvent(clientId, event));
94
+ }
95
+ catch (e) {
96
+ log(new ClientHadProblem(clientId, `couldn't apply delta of type ${delta.constructor.name} because of: ${e.message}`));
97
+ }
98
+ }
99
+ }
100
+ catch (eventTranslationError) {
101
+ log(new ClientHadProblem(clientId, `couldn't translate event to a delta because of: ${eventTranslationError.message}\n\tdelta = ${JSON.stringify(event)}`));
102
+ }
103
+ }
104
+ else {
105
+ log(new ClientDidNotApplyEventFromOwnCommand(clientId, commandOriginatingFromSelf.commandId));
106
+ }
107
+ };
108
+ const acceptEvent = priorityQueueAcceptor(({ sequenceNumber }) => sequenceNumber, 0, processEvent);
109
+ const receiveMessageOnClient = (message) => {
110
+ log(new ClientReceivedMessage(clientId, message));
111
+ if (isQueryResponse(message)) {
112
+ const { queryId } = message;
113
+ if (queryId in lionWebClient.queryResolveById) {
114
+ const resolveResponse = lionWebClient.queryResolveById[queryId];
115
+ resolveResponse(message);
116
+ delete lionWebClient.queryResolveById[queryId];
117
+ return; // ~void
118
+ }
119
+ console.log(clientWarning(`client received response for a query with ID="${queryId} without having sent a corresponding request - ignoring`));
120
+ return;
121
+ }
122
+ if (isEvent(message)) {
123
+ acceptEvent(message);
124
+ return;
125
+ }
126
+ };
127
+ const lowLevelClient = await lowLevelClientInstantiator({ url, clientId, receiveMessageOnClient /* no logging parameter */ });
128
+ const lionWebClient = new LionWebClient(clientId, model, idMapping, combinedFactoryFor(languageBases, effectiveReceiveDelta), effectiveReceiveDelta, lowLevelClient); // Note: we need this `lionWebClient` constant non-inlined for write-access to lastReceivedSequenceNumber and queryResolveById.
129
+ return lionWebClient;
130
+ }
131
+ /**
132
+ * Sets the model held by the client to the given model, discarding the previous one.
133
+ * No commands will be sent because of this action.
134
+ */
135
+ setModel(newModel) {
136
+ this.model = newModel;
137
+ this.idMapping.reinitializeWith(LionWebClient.nodesByIdFrom(newModel));
138
+ }
139
+ async disconnect() {
140
+ // TODO abort responses to all queries that the repository hasn't responded to?
141
+ await this.lowLevelClient.disconnect();
142
+ }
143
+ async subscribeToChangingPartitions(queryId, parameters) {
144
+ await this.makeQuery({
145
+ messageKind: "SubscribeToChangingPartitionsRequest",
146
+ queryId,
147
+ ...parameters,
148
+ protocolMessages: []
149
+ });
150
+ }
151
+ async subscribeToPartitionContents(queryId, partition) {
152
+ const response = await this.makeQuery({
153
+ messageKind: "SubscribeToPartitionContentsRequest",
154
+ queryId,
155
+ partition,
156
+ protocolMessages: []
157
+ });
158
+ return response.contents;
159
+ }
160
+ async unsubscribeFromPartitionContents(queryId, partition) {
161
+ await this.makeQuery({
162
+ messageKind: "UnsubscribeFromPartitionContentsRequest",
163
+ queryId,
164
+ partition,
165
+ protocolMessages: []
166
+ });
167
+ }
168
+ async signOn(queryId, repositoryId) {
169
+ if (this.signedOff) {
170
+ return Promise.reject(new Error(`can't sign on after having signed off`));
171
+ }
172
+ const response = await this.makeQuery({
173
+ messageKind: "SignOnRequest",
174
+ queryId,
175
+ repositoryId,
176
+ deltaProtocolVersion: "2025.1",
177
+ clientId: this.clientId,
178
+ protocolMessages: []
179
+ });
180
+ this._participationId = response.participationId;
181
+ }
182
+ async signOff(queryId) {
183
+ await this.makeQuery({
184
+ messageKind: "SignOffRequest",
185
+ queryId,
186
+ protocolMessages: []
187
+ });
188
+ this.signedOff = true;
189
+ this._participationId = undefined;
190
+ }
191
+ async reconnect(queryId, participationId, lastReceivedSequenceNumber) {
192
+ const response = await this.makeQuery({
193
+ messageKind: "ReconnectRequest",
194
+ queryId,
195
+ participationId,
196
+ lastReceivedSequenceNumber,
197
+ protocolMessages: []
198
+ });
199
+ this._participationId = participationId;
200
+ this.lastReceivedSequenceNumber = response.lastReceivedSequenceNumber;
201
+ }
202
+ // commands, in order of the specification (§ 6.5):
203
+ static checkWhetherPartition(node) {
204
+ const { classifier } = node;
205
+ if (!(classifier instanceof Concept)) {
206
+ throw new Error(`node with classifier ${classifier.name} from language ${classifier.language.name} is not an instance of a Concept`);
207
+ }
208
+ if (!classifier.partition) {
209
+ throw new Error(`classifier ${classifier.name} from language ${classifier.language.name} is not a partition`);
210
+ }
211
+ }
212
+ checkSignedOn() {
213
+ if (this._participationId === undefined) {
214
+ throw new Error(`client ${this.clientId} can't send a command without being signed on`);
215
+ }
216
+ }
217
+ addPartition(partition) {
218
+ this.checkSignedOn();
219
+ LionWebClient.checkWhetherPartition(partition);
220
+ if (this.model.indexOf(partition) === -1) {
221
+ this.model.push(partition);
222
+ this.idMapping.updateWith(partition);
223
+ this.effectiveReceiveDelta(new PartitionAddedDelta(partition));
224
+ } // else: ignore; already done
225
+ }
226
+ deletePartition(partition) {
227
+ this.checkSignedOn();
228
+ const index = this.model.indexOf(partition);
229
+ if (index > -1) {
230
+ this.model.splice(index, 1);
231
+ this.effectiveReceiveDelta(new PartitionDeletedDelta(partition));
232
+ }
233
+ else {
234
+ throw new Error(`node with id "${partition.id}" is not a partition in the current model`);
235
+ }
236
+ }
237
+ }
238
+ LionWebClient.nodesByIdFrom = (model) => byIdMap(model.flatMap(allNodesFrom));
239
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,iEAAiE;AACjE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,EAAE;AACF,sEAAsE;AACtE,sCAAsC;AAEtC,OAAO,EACH,YAAY,EACZ,UAAU,EACV,kBAAkB,EAElB,SAAS,EAGT,oBAAoB,EAEpB,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACjB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAE3C,OAAO,EACH,IAAI,EACJ,kBAAkB,EAClB,oCAAoC,EACpC,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EAEjB,cAAc,EACd,qBAAqB,EAErB,sBAAsB,EACtB,OAAO,EACP,eAAe,EAKf,0BAA0B,EAS7B,MAAM,gCAAgC,CAAA;AAEvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAE3D,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI,CAAA;AAiB9B;;GAEG;AACH,MAAM,OAAO,aAAa;IAItB,IAAI,eAAe;QACf,OAAO,IAAI,CAAC,gBAAgB,CAAA;IAChC,CAAC;IAKD,8FAA8F;IAE9F,YACoB,QAAmB,EAC5B,KAAkB,EACT,SAAoB,EACpB,UAA2B,EAC1B,qBAAoC,EACpC,cAAsD;QALvD,aAAQ,GAAR,QAAQ,CAAW;QAC5B,UAAK,GAAL,KAAK,CAAa;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AC,CAAC,EAAE,CAAC;YACvC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YAC1B,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;YACpC,IAAI,CAAC,qBAAqB,CAAC,IAAI,mBAAmB,CAAC,SAAS,CAAC,CAAC,CAAA;QAClE,CAAC,CAAC,6BAA6B;IACnC,CAAC;IAED,eAAe,CAAC,SAAoB;QAChC,IAAI,CAAC,aAAa,EAAE,CAAA;QACpB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QAC3C,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;YACb,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;YAC3B,IAAI,CAAC,qBAAqB,CAAC,IAAI,qBAAqB,CAAC,SAAS,CAAC,CAAC,CAAA;QACpE,CAAC;aAAM,CAAC;YACJ,MAAM,IAAI,KAAK,CAAC,iBAAiB,SAAS,CAAC,EAAE,2CAA2C,CAAC,CAAA;QAC7F,CAAC;IACL,CAAC;;AAjOuB,2BAAa,GAAG,CAAC,KAAkB,EAAE,EAAE,CAC3D,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,AADH,CACG"}
@@ -0,0 +1,6 @@
1
+ export { LionWebClient } from "./client.js";
2
+ export type { LionWebClientParameters } from "./client.js";
3
+ export { noOpLowLevelClientLogger } from "./log-types.js";
4
+ export type { MessageReceivedOnClient, MessageSentToServer, TextualLogItem, LowLevelClientLogItem, LowLevelClientLogger } from "./log-types.js";
5
+ export type { LowLevelClient, LowLevelClientInstantiator, LowLevelClientLoggingParameters, LowLevelClientParameters } from "./low-level-client.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,YAAY,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAE1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA;AACzD,YAAY,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,cAAc,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAE/I,YAAY,EAAE,cAAc,EAAE,0BAA0B,EAAE,+BAA+B,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ // Copyright 2025 TRUMPF Laser SE and other contributors
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License")
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ //
15
+ // SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
16
+ // SPDX-License-Identifier: Apache-2.0
17
+ export { LionWebClient } from "./client.js";
18
+ export { noOpLowLevelClientLogger } from "./log-types.js";
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,iEAAiE;AACjE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,EAAE;AACF,sEAAsE;AACtE,sCAAsC;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAG3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA"}
@@ -0,0 +1,20 @@
1
+ export type MessageReceivedOnClient<TMessageForClient> = {
2
+ receivedOnClient: TMessageForClient;
3
+ };
4
+ export type MessageSentToServer<TMessageForServer> = {
5
+ sentToServer: TMessageForServer;
6
+ };
7
+ export type TextualLogItem = {
8
+ message: string;
9
+ error?: boolean;
10
+ };
11
+ /**
12
+ * Type def. for activity logged by a low-level client.
13
+ */
14
+ export type LowLevelClientLogItem<TMessageForClient, TMessageForServer> = TextualLogItem | MessageReceivedOnClient<TMessageForClient> | MessageSentToServer<TMessageForServer>;
15
+ export type LowLevelClientLogger<TMessageForClient, TMessageForServer> = (logItem: LowLevelClientLogItem<TMessageForClient, TMessageForServer>) => void;
16
+ /**
17
+ * Implementation of {@link LowLevelClientLogger} that does nothing.
18
+ */
19
+ export declare const noOpLowLevelClientLogger: LowLevelClientLogger<unknown, unknown>;
20
+ //# sourceMappingURL=log-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-types.d.ts","sourceRoot":"","sources":["../src/log-types.ts"],"names":[],"mappings":"AAiBA,MAAM,MAAM,uBAAuB,CAAC,iBAAiB,IAAI;IACrD,gBAAgB,EAAE,iBAAiB,CAAA;CACtC,CAAA;AAED,MAAM,MAAM,mBAAmB,CAAC,iBAAiB,IAAI;IACjD,YAAY,EAAE,iBAAiB,CAAA;CAClC,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IACzB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,qBAAqB,CAAC,iBAAiB,EAAE,iBAAiB,IAChE,cAAc,GACd,uBAAuB,CAAC,iBAAiB,CAAC,GAC1C,mBAAmB,CAAC,iBAAiB,CAAC,CAAA;AAG5C,MAAM,MAAM,oBAAoB,CAAC,iBAAiB,EAAE,iBAAiB,IACjE,CAAC,OAAO,EAAE,qBAAqB,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,KAAK,IAAI,CAAA;AAGlF;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAoB,CAAA"}
@@ -0,0 +1,21 @@
1
+ // Copyright 2025 TRUMPF Laser SE and other contributors
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License")
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ //
15
+ // SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
16
+ // SPDX-License-Identifier: Apache-2.0
17
+ /**
18
+ * Implementation of {@link LowLevelClientLogger} that does nothing.
19
+ */
20
+ export const noOpLowLevelClientLogger = (_logItem) => { };
21
+ //# sourceMappingURL=log-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-types.js","sourceRoot":"","sources":["../src/log-types.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,iEAAiE;AACjE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,EAAE;AACF,sEAAsE;AACtE,sCAAsC;AA4BtC;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAA2C,CAAC,QAAQ,EAAE,EAAE,GAAE,CAAC,CAAA"}
@@ -0,0 +1,36 @@
1
+ import { LionWebId } from "@lionweb/json";
2
+ import { TextualLogger } from "@lionweb/delta-protocol-common";
3
+ /**
4
+ * Type def. for a client that's able to send messages.
5
+ */
6
+ export type LowLevelClient<TMessageToServer> = {
7
+ sendMessage: (message: TMessageToServer) => Promise<void>;
8
+ disconnect: () => Promise<void>;
9
+ };
10
+ /**
11
+ * Type def. for parameters *required* for instantiating a {@link LowLevelClient low-level client}.
12
+ */
13
+ export type LowLevelClientParameters<TMessageForClient> = {
14
+ /** The URL of the WebSocket server to connect to. */
15
+ url: string;
16
+ /** An ID for the created client. */
17
+ clientId: LionWebId;
18
+ /** A function that's called with a received message. */
19
+ receiveMessageOnClient: (message: TMessageForClient) => void;
20
+ };
21
+ /**
22
+ * Type def. for optional parameters for a {@link LowLevelClient low-level client} regarding logging.
23
+ */
24
+ export type LowLevelClientLoggingParameters<TMessageForClient, TMessageToServer> = {
25
+ /** An optional {@link TextualLogger textual logger}. */
26
+ textualLogger?: TextualLogger;
27
+ /** An optional message logger. */
28
+ messageLogger?: (message: (TMessageForClient | TMessageToServer)) => void;
29
+ };
30
+ /**
31
+ * Type def. for functions that instantiate a {@link LowLevelClient}.
32
+ *
33
+ * Note that the instantiator implementation is responsible for passing logging parameters.
34
+ */
35
+ export type LowLevelClientInstantiator<TMessageForClient, TMessageToServer> = (lowLevelClientParameters: LowLevelClientParameters<TMessageForClient>) => Promise<LowLevelClient<TMessageToServer>>;
36
+ //# sourceMappingURL=low-level-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"low-level-client.d.ts","sourceRoot":"","sources":["../src/low-level-client.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;AAG9D;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,gBAAgB,IAAI;IAC3C,WAAW,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACzD,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAClC,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,wBAAwB,CAAC,iBAAiB,IAAI;IACtD,qDAAqD;IACrD,GAAG,EAAE,MAAM,CAAA;IACX,oCAAoC;IACpC,QAAQ,EAAE,SAAS,CAAA;IACnB,wDAAwD;IACxD,sBAAsB,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAA;CAE/D,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,+BAA+B,CAAC,iBAAiB,EAAE,gBAAgB,IAAI;IAC/E,wDAAwD;IACxD,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B,kCAAkC;IAClC,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,iBAAiB,GAAG,gBAAgB,CAAC,KAAK,IAAI,CAAA;CAC5E,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,0BAA0B,CAAC,iBAAiB,EAAE,gBAAgB,IACtE,CAAC,wBAAwB,EAAE,wBAAwB,CAAC,iBAAiB,CAAC,KAClE,OAAO,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,CAAA"}
@@ -0,0 +1,18 @@
1
+ // Copyright 2025 TRUMPF Laser SE and other contributors
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License")
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ //
15
+ // SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
16
+ // SPDX-License-Identifier: Apache-2.0
17
+ export {};
18
+ //# sourceMappingURL=low-level-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"low-level-client.js","sourceRoot":"","sources":["../src/low-level-client.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,iEAAiE;AACjE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,EAAE;AACF,sEAAsE;AACtE,sCAAsC"}
@@ -0,0 +1,22 @@
1
+ import { Procedure } from "@lionweb/delta-protocol-common";
2
+ /**
3
+ * @return the index at which `t` should be inserted to keep the array `ts` sorted in the numeric order determined by applying `valueFunc` to its members.
4
+ * In case `t` has the same numeric value as existing members of `ts`, the lowest index having that numeric value is returned.
5
+ * (Exported for testing purposes only!)
6
+ */
7
+ export declare const insertionIndex: <T>(ts: T[], valueFunc: (t: T) => number, tToInsert: T) => number;
8
+ /**
9
+ * Type def. for a function that takes a `t` and either processes it directly if `t` has the next expected priority,
10
+ * or enqueues it for later processing.
11
+ *
12
+ * (Technically, this can be considered to be a modified {@link https://en.wikipedia.org/wiki/Priority_queue *“monotone priority queue”*}.)
13
+ */
14
+ export type PriorityQueueAcceptor<T> = (t: T) => void;
15
+ /**
16
+ * @return a {@link PriorityQueueAcceptor} function that accepts instances of `T`,
17
+ * passing them to the `process` function in (min-max) priority order,
18
+ * as computed by the `priorityFunc`, starting with the `firstPriority`.
19
+ * @throws an {@link Error error} when a `T` is passed with a priority that has already been processed.
20
+ */
21
+ export declare const priorityQueueAcceptor: <T>(priorityFunc: (t: T) => number, firstPriority: number, process: Procedure<T>) => PriorityQueueAcceptor<T>;
22
+ //# sourceMappingURL=priority-queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"priority-queue.d.ts","sourceRoot":"","sources":["../src/priority-queue.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAA;AAG1D;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,EAAE,WAAW,CAAC,KAAG,MAmBtF,CAAA;AAGD;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,CAAA;AAErD;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,CAAC,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,EAAE,eAAe,MAAM,EAAE,SAAS,SAAS,CAAC,CAAC,CAAC,KAAG,qBAAqB,CAAC,CAAC,CAgC9I,CAAA"}