@lionweb/delta-protocol-repository-ws 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 +6 -0
- package/README.md +24 -0
- package/dist/command-to-event.d.ts +6 -0
- package/dist/command-to-event.d.ts.map +1 -0
- package/dist/command-to-event.js +450 -0
- package/dist/command-to-event.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/repository-impl.d.ts +13 -0
- package/dist/repository-impl.d.ts.map +1 -0
- package/dist/repository-impl.js +119 -0
- package/dist/repository-impl.js.map +1 -0
- package/dist/server.d.ts +23 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +75 -0
- package/dist/server.js.map +1 -0
- package/dist/set.d.ts +5 -0
- package/dist/set.d.ts.map +1 -0
- package/dist/set.js +27 -0
- package/dist/set.js.map +1 -0
- package/package.json +38 -0
- package/src/command-to-event.ts +544 -0
- package/src/index.ts +22 -0
- package/src/repository-impl.ts +151 -0
- package/src/server.ts +104 -0
- package/src/set.ts +28 -0
|
@@ -0,0 +1,119 @@
|
|
|
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 { RepositoryReceivedMessage, semanticLoggerFunctionFrom } from "@lionweb/delta-protocol-common";
|
|
18
|
+
import { createWebSocketServer } from "./server.js";
|
|
19
|
+
import { commandAsEvent } from "./command-to-event.js";
|
|
20
|
+
export class LionWebRepository {
|
|
21
|
+
constructor(lowLevelServer) {
|
|
22
|
+
this.lowLevelServer = lowLevelServer;
|
|
23
|
+
}
|
|
24
|
+
static async create({ port, semanticLogger }) {
|
|
25
|
+
const log = semanticLoggerFunctionFrom(semanticLogger);
|
|
26
|
+
let nextParticipationIdSequenceNumber = 0;
|
|
27
|
+
const receiveMessageOnRepository = (clientMetadata, message) => {
|
|
28
|
+
log(new RepositoryReceivedMessage({ ...clientMetadata }, message));
|
|
29
|
+
const checkedClientMetadata = () => {
|
|
30
|
+
if (clientMetadata.participationId === undefined) {
|
|
31
|
+
throw new Error(`can't process an event if no participation has started`); // TODO instead: log an item, and fall through
|
|
32
|
+
}
|
|
33
|
+
// (now .clientId must be !== undefined too:)
|
|
34
|
+
return clientMetadata;
|
|
35
|
+
};
|
|
36
|
+
switch (message.messageKind) {
|
|
37
|
+
case "SignOnRequest": {
|
|
38
|
+
const { clientId, queryId } = message;
|
|
39
|
+
clientMetadata.participationId = `participation-${String.fromCharCode(97 + (nextParticipationIdSequenceNumber++))}`;
|
|
40
|
+
clientMetadata.clientId = clientId;
|
|
41
|
+
return {
|
|
42
|
+
messageKind: "SignOnResponse",
|
|
43
|
+
queryId,
|
|
44
|
+
participationId: clientMetadata.participationId,
|
|
45
|
+
protocolMessages: []
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
case "SignOffRequest": {
|
|
49
|
+
const { queryId } = message;
|
|
50
|
+
clientMetadata.participationId = undefined;
|
|
51
|
+
return {
|
|
52
|
+
messageKind: "SignOffResponse",
|
|
53
|
+
queryId,
|
|
54
|
+
protocolMessages: []
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
// all commands, in order of the specification (§ 6.5):
|
|
58
|
+
/*
|
|
59
|
+
* **DEV note**: run
|
|
60
|
+
*
|
|
61
|
+
* $ node src/code-reading/command-message-kinds.js
|
|
62
|
+
*
|
|
63
|
+
* inside the build package to generate the following cases.
|
|
64
|
+
*/
|
|
65
|
+
case "AddPartition":
|
|
66
|
+
case "DeletePartition":
|
|
67
|
+
case "ChangeClassifier":
|
|
68
|
+
case "AddProperty":
|
|
69
|
+
case "DeleteProperty":
|
|
70
|
+
case "ChangeProperty":
|
|
71
|
+
case "AddChild":
|
|
72
|
+
case "DeleteChild":
|
|
73
|
+
case "ReplaceChild":
|
|
74
|
+
case "MoveChildFromOtherContainment":
|
|
75
|
+
case "MoveChildFromOtherContainmentInSameParent":
|
|
76
|
+
case "MoveChildInSameContainment":
|
|
77
|
+
case "MoveAndReplaceChildFromOtherContainment":
|
|
78
|
+
case "MoveAndReplaceChildFromOtherContainmentInSameParent":
|
|
79
|
+
case "MoveAndReplaceChildInSameContainment":
|
|
80
|
+
case "AddAnnotation":
|
|
81
|
+
case "DeleteAnnotation":
|
|
82
|
+
case "ReplaceAnnotation":
|
|
83
|
+
case "MoveAnnotationFromOtherParent":
|
|
84
|
+
case "MoveAnnotationInSameParent":
|
|
85
|
+
case "MoveAndReplaceAnnotationFromOtherParent":
|
|
86
|
+
case "MoveAndReplaceAnnotationInSameParent":
|
|
87
|
+
case "AddReference":
|
|
88
|
+
case "DeleteReference":
|
|
89
|
+
case "ChangeReference":
|
|
90
|
+
case "MoveEntryFromOtherReference":
|
|
91
|
+
case "MoveEntryFromOtherReferenceInSameParent":
|
|
92
|
+
case "MoveEntryInSameReference":
|
|
93
|
+
case "MoveAndReplaceEntryFromOtherReference":
|
|
94
|
+
case "MoveAndReplaceEntryFromOtherReferenceInSameParent":
|
|
95
|
+
case "MoveAndReplaceEntryInSameReference":
|
|
96
|
+
case "AddReferenceResolveInfo":
|
|
97
|
+
case "DeleteReferenceResolveInfo":
|
|
98
|
+
case "ChangeReferenceResolveInfo":
|
|
99
|
+
case "AddReferenceTarget":
|
|
100
|
+
case "DeleteReferenceTarget":
|
|
101
|
+
case "ChangeReferenceTarget":
|
|
102
|
+
case "CompositeCommand":
|
|
103
|
+
{
|
|
104
|
+
lowLevelServer.broadcastMessage(commandAsEvent(message, checkedClientMetadata().participationId)); // FIXME not correct: message to broadcast to a particular client holds sequence number for that particular participation
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
default:
|
|
108
|
+
throw new Error(`can't handle message of kind "${message.messageKind}"`); // TODO instead: log an item, and fall through
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const lowLevelServer = createWebSocketServer(port, (_) => ({}), // (leave values undefined – they're set later)
|
|
112
|
+
receiveMessageOnRepository);
|
|
113
|
+
return new LionWebRepository(lowLevelServer);
|
|
114
|
+
}
|
|
115
|
+
async shutdown() {
|
|
116
|
+
await this.lowLevelServer.shutdown();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=repository-impl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository-impl.js","sourceRoot":"","sources":["../src/repository-impl.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,EAIH,yBAAyB,EAEzB,0BAA0B,EAK7B,MAAM,gCAAgC,CAAA;AAGvC,OAAO,EAAE,qBAAqB,EAAkB,MAAM,aAAa,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAatD,MAAM,OAAO,iBAAiB;IAE1B,YAA6B,cAAqC;QAArC,mBAAc,GAAd,cAA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AC,CAAC,CAAA,CAAI,0HAA0H;wBAC1O,OAAO,SAAS,CAAA;oBACpB,CAAC;gBACD;oBACI,MAAM,IAAI,KAAK,CAAC,iCAAiC,OAAO,CAAC,WAAW,GAAG,CAAC,CAAA,CAAG,+CAA+C;YAClI,CAAC;QACL,CAAC,CAAA;QACD,MAAM,cAAc,GAAG,qBAAqB,CACxC,IAAI,EACJ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,+CAA+C;QAC5D,0BAA0B,CAC7B,CAAA;QACD,OAAO,IAAI,iBAAiB,CAAC,cAAc,CAAC,CAAA;IAChD,CAAC;IAED,KAAK,CAAC,QAAQ;QACV,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAA;IACxC,CAAC;CAEJ"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TextualLogger } from "@lionweb/delta-protocol-common";
|
|
2
|
+
import { IncomingMessage } from "http";
|
|
3
|
+
/**
|
|
4
|
+
* Type definition for a low“-level” server that's able to broadcast messages.
|
|
5
|
+
* “Low-level” essentially means “wire protocol”, here.
|
|
6
|
+
*/
|
|
7
|
+
export type LowLevelServer<TBroadcastMessage> = {
|
|
8
|
+
broadcastMessage: (message: TBroadcastMessage) => Promise<void>;
|
|
9
|
+
shutdown: () => Promise<void>;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* @return a WebSocket-driven {@link server}.
|
|
13
|
+
* @param port The port for clients to connect.
|
|
14
|
+
* @param clientMetadataFrom A function that computes metadata for a (just-)connected client from the associated {@link IncomingMessage request object}.
|
|
15
|
+
* @param receiveMessageOnServer A function that's called with the client's metadata and a received message.
|
|
16
|
+
* @param optionalTextualLogger An optional {@link TextualLogger textual logger}.
|
|
17
|
+
*/
|
|
18
|
+
export declare const createWebSocketServer: <TClientMetadata, TMessageForServer, TResponse, TBroadcastMessage>(port: number, clientMetadataFrom: (request: IncomingMessage) => TClientMetadata, receiveMessageOnServer: (clientMetadata: TClientMetadata, message: TMessageForServer) => TResponse, optionalTextualLogger?: TextualLogger) => LowLevelServer<TBroadcastMessage>;
|
|
19
|
+
/**
|
|
20
|
+
* @return the URL for a WebSocket server hosted on `localhost` on the given `port`.
|
|
21
|
+
*/
|
|
22
|
+
export declare const wsLocalhostUrl: (port: number) => string;
|
|
23
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAiBA,OAAO,EACH,aAAa,EAIhB,MAAM,gCAAgC,CAAA;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAA;AAOtC;;;GAGG;AACH,MAAM,MAAM,cAAc,CAAC,iBAAiB,IAAI;IAC5C,gBAAgB,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/D,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAChC,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GAAI,eAAe,EAAE,iBAAiB,EAAE,SAAS,EAAE,iBAAiB,EAClG,MAAM,MAAM,EACZ,oBAAoB,CAAC,OAAO,EAAE,eAAe,KAAK,eAAe,EACjE,wBAAwB,CAAC,cAAc,EAAE,eAAe,EAAE,OAAO,EAAE,iBAAiB,KAAK,SAAS,EAClG,wBAAwB,aAAa,KACtC,cAAc,CAAC,iBAAiB,CA4ClC,CAAA;AAGD;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,WAA6B,CAAA"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
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 { textualLoggerFunctionFrom, tryParseJson, wrappedAsPromise } from "@lionweb/delta-protocol-common";
|
|
18
|
+
import { asMinimalJsonString } from "@lionweb/ts-utils";
|
|
19
|
+
import { WebSocketServer } from "ws";
|
|
20
|
+
import { setMap } from "./set.js";
|
|
21
|
+
/**
|
|
22
|
+
* @return a WebSocket-driven {@link server}.
|
|
23
|
+
* @param port The port for clients to connect.
|
|
24
|
+
* @param clientMetadataFrom A function that computes metadata for a (just-)connected client from the associated {@link IncomingMessage request object}.
|
|
25
|
+
* @param receiveMessageOnServer A function that's called with the client's metadata and a received message.
|
|
26
|
+
* @param optionalTextualLogger An optional {@link TextualLogger textual logger}.
|
|
27
|
+
*/
|
|
28
|
+
export const createWebSocketServer = (port, clientMetadataFrom, receiveMessageOnServer, optionalTextualLogger) => {
|
|
29
|
+
const webSocketServer = new WebSocketServer({ port });
|
|
30
|
+
const log = textualLoggerFunctionFrom(optionalTextualLogger);
|
|
31
|
+
log("WebSocketServer started");
|
|
32
|
+
webSocketServer.on("connection", (webSocket, request) => {
|
|
33
|
+
log(`a client connected`);
|
|
34
|
+
const clientMetadata = clientMetadataFrom(request);
|
|
35
|
+
webSocket.on("message", (messageText) => {
|
|
36
|
+
log(`received a message from client: ${messageText}`);
|
|
37
|
+
const response = receiveMessageOnServer(clientMetadata, tryParseJson(messageText, log));
|
|
38
|
+
if (response !== undefined) {
|
|
39
|
+
const responseText = asMinimalJsonString(response);
|
|
40
|
+
// send back to this client (only):
|
|
41
|
+
webSocket.send(responseText); // TODO handle error
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
// TODO rethink broadcasting: need to make a different message _per client_, based on its metadata (which then should include nextSequenceNumber)
|
|
47
|
+
broadcastMessage: async (message) => {
|
|
48
|
+
const messageText = asMinimalJsonString(message);
|
|
49
|
+
log(`broadcasting message to all clients: ${messageText}`);
|
|
50
|
+
await Promise.all(setMap(webSocketServer.clients, (client) => wrappedAsPromise((callback) => {
|
|
51
|
+
client.send(messageText, callback);
|
|
52
|
+
})));
|
|
53
|
+
},
|
|
54
|
+
shutdown: () => {
|
|
55
|
+
log(`shutting down server`);
|
|
56
|
+
return wrappedAsPromise((callback) => {
|
|
57
|
+
webSocketServer.clients.forEach((webSocket) => {
|
|
58
|
+
webSocket.close();
|
|
59
|
+
process.nextTick(() => {
|
|
60
|
+
const state = webSocket.readyState;
|
|
61
|
+
if (state === webSocket.OPEN || state === webSocket.CLOSING) {
|
|
62
|
+
webSocket.terminate();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
webSocketServer.close(callback);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* @return the URL for a WebSocket server hosted on `localhost` on the given `port`.
|
|
73
|
+
*/
|
|
74
|
+
export const wsLocalhostUrl = (port) => `ws://localhost:${port}`;
|
|
75
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,iEAAiE;AACjE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,o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
|
|
|
1
|
+
{"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../src/set.ts"],"names":[],"mappings":"AAiBA;;GAEG;AACH,eAAO,MAAM,MAAM,GAAI,CAAC,EAAE,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAG,CAAC,EAMjE,CAAA"}
|
package/dist/set.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
* @return an array of the mapped values of the given set.
|
|
19
|
+
*/
|
|
20
|
+
export const setMap = (set, mapFunc) => {
|
|
21
|
+
const rs = [];
|
|
22
|
+
set.forEach((t) => {
|
|
23
|
+
rs.push(mapFunc(t));
|
|
24
|
+
});
|
|
25
|
+
return rs;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=set.js.map
|
package/dist/set.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set.js","sourceRoot":"","sources":["../src/set.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;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAO,GAAW,EAAE,OAAoB,EAAO,EAAE;IACnE,MAAM,EAAE,GAAQ,EAAE,CAAA;IAClB,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QACd,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;IACvB,CAAC,CAAC,CAAA;IACF,OAAO,EAAE,CAAA;AACb,CAAC,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lionweb/delta-protocol-repository-ws",
|
|
3
|
+
"version": "0.7.0-beta.21",
|
|
4
|
+
"description": "Implementation – currently: partial – of a delta protocol repository using the WebSocket protocol, relying on the 'ws' package",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"typings": "dist/index.d.ts",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"license": "Apache-2.0",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/LionWeb-io/lionweb-typescript.git"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/LionWeb-io/lionweb-typescript/issues"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"clean": "npx rimraf dist node_modules",
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"lint": "eslint src",
|
|
21
|
+
"prep:pre-release": "npm run clean && npm install && npm run build",
|
|
22
|
+
"prerelease-alpha": "npm run prep:pre-release",
|
|
23
|
+
"release-alpha": "npm publish --tag alpha",
|
|
24
|
+
"prerelease-beta": "npm run prep:pre-release",
|
|
25
|
+
"release-beta": "npm publish --tag beta",
|
|
26
|
+
"prerelease": "npm run prep:pre-release",
|
|
27
|
+
"release": "npm publish"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@lionweb/delta-protocol-common": "0.7.0-beta.21",
|
|
31
|
+
"@lionweb/json": "0.7.0-beta.21",
|
|
32
|
+
"@lionweb/ts-utils": "0.7.0-beta.21",
|
|
33
|
+
"ws": "8.18.2"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/ws": "8.18.1"
|
|
37
|
+
}
|
|
38
|
+
}
|