@dcl/ecs 1.0.0-20220511175240.commit-459bc31 → 1.0.0-20220525093820.commit-c20b8cd
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/dist/components/definitions/AudioSource.proto +16 -0
- package/dist/components/definitions/AudioStream.proto +13 -0
- package/dist/components/definitions/ConeShape.proto +15 -0
- package/dist/components/definitions/CylinderShape.proto +15 -0
- package/dist/components/definitions/PlaneShape.proto +14 -0
- package/dist/components/definitions/SphereShape.proto +13 -0
- package/dist/components/generated/AudioSource.d.ts +5 -0
- package/dist/components/generated/AudioSource.d.ts.map +1 -0
- package/dist/components/generated/AudioSource.js +17 -0
- package/dist/components/generated/AudioSource.js.map +1 -0
- package/dist/components/generated/AudioStream.d.ts +5 -0
- package/dist/components/generated/AudioStream.d.ts.map +1 -0
- package/dist/components/generated/AudioStream.js +17 -0
- package/dist/components/generated/AudioStream.js.map +1 -0
- package/dist/components/generated/ConeShape.d.ts +5 -0
- package/dist/components/generated/ConeShape.d.ts.map +1 -0
- package/dist/components/generated/ConeShape.js +17 -0
- package/dist/components/generated/ConeShape.js.map +1 -0
- package/dist/components/generated/CylinderShape.d.ts +5 -0
- package/dist/components/generated/CylinderShape.d.ts.map +1 -0
- package/dist/components/generated/CylinderShape.js +17 -0
- package/dist/components/generated/CylinderShape.js.map +1 -0
- package/dist/components/generated/PlaneShape.d.ts +5 -0
- package/dist/components/generated/PlaneShape.d.ts.map +1 -0
- package/dist/components/generated/PlaneShape.js +17 -0
- package/dist/components/generated/PlaneShape.js.map +1 -0
- package/dist/components/generated/SphereShape.d.ts +5 -0
- package/dist/components/generated/SphereShape.d.ts.map +1 -0
- package/dist/components/generated/SphereShape.js +17 -0
- package/dist/components/generated/SphereShape.js.map +1 -0
- package/dist/components/generated/index.d.ts +8 -2
- package/dist/components/generated/index.d.ts.map +1 -1
- package/dist/components/generated/index.js +13 -1
- package/dist/components/generated/index.js.map +1 -1
- package/dist/components/generated/pb/AudioSource.d.ts +15 -0
- package/dist/components/generated/pb/AudioSource.d.ts.map +1 -0
- package/dist/components/generated/pb/AudioSource.js +95 -0
- package/dist/components/generated/pb/AudioSource.js.map +1 -0
- package/dist/components/generated/pb/AudioStream.d.ts +12 -0
- package/dist/components/generated/pb/AudioStream.d.ts.map +1 -0
- package/dist/components/generated/pb/AudioStream.js +70 -0
- package/dist/components/generated/pb/AudioStream.js.map +1 -0
- package/dist/components/generated/pb/ConeShape.d.ts +14 -0
- package/dist/components/generated/pb/ConeShape.d.ts.map +1 -0
- package/dist/components/generated/pb/ConeShape.js +88 -0
- package/dist/components/generated/pb/ConeShape.js.map +1 -0
- package/dist/components/generated/pb/CylinderShape.d.ts +14 -0
- package/dist/components/generated/pb/CylinderShape.d.ts.map +1 -0
- package/dist/components/generated/pb/CylinderShape.js +88 -0
- package/dist/components/generated/pb/CylinderShape.js.map +1 -0
- package/dist/components/generated/pb/PlaneShape.d.ts +13 -0
- package/dist/components/generated/pb/PlaneShape.d.ts.map +1 -0
- package/dist/components/generated/pb/PlaneShape.js +91 -0
- package/dist/components/generated/pb/PlaneShape.js.map +1 -0
- package/dist/components/generated/pb/SphereShape.d.ts +12 -0
- package/dist/components/generated/pb/SphereShape.d.ts.map +1 -0
- package/dist/components/generated/pb/SphereShape.js +70 -0
- package/dist/components/generated/pb/SphereShape.js.map +1 -0
- package/dist/components/index.d.ts +8 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/legacy/index.d.ts +8 -2
- package/dist/components/legacy/index.d.ts.map +1 -1
- package/dist/components/legacy/index.js.map +1 -1
- package/dist/ecs.api.json +2 -216
- package/dist/engine/index.d.ts +2 -20
- package/dist/engine/index.d.ts.map +1 -1
- package/dist/engine/index.js +2 -5
- package/dist/engine/index.js.map +1 -1
- package/dist/engine/types.d.ts +18 -0
- package/dist/engine/types.d.ts.map +1 -1
- package/dist/engine/utils.d.ts.map +1 -1
- package/dist/engine/utils.js.map +1 -1
- package/dist/serialization/ByteBuffer/index.d.ts +12 -4
- package/dist/serialization/ByteBuffer/index.d.ts.map +1 -1
- package/dist/serialization/ByteBuffer/index.js +20 -6
- package/dist/serialization/ByteBuffer/index.js.map +1 -1
- package/dist/serialization/crdt/componentOperation.d.ts +3 -3
- package/dist/serialization/crdt/componentOperation.d.ts.map +1 -1
- package/dist/serialization/crdt/componentOperation.js +4 -4
- package/dist/serialization/crdt/componentOperation.js.map +1 -1
- package/dist/systems/crdt/index.d.ts +2 -7
- package/dist/systems/crdt/index.d.ts.map +1 -1
- package/dist/systems/crdt/index.js +116 -82
- package/dist/systems/crdt/index.js.map +1 -1
- package/dist/systems/crdt/transport.d.ts +8 -1
- package/dist/systems/crdt/transport.d.ts.map +1 -1
- package/dist/systems/crdt/transport.js +22 -4
- package/dist/systems/crdt/transport.js.map +1 -1
- package/dist/systems/crdt/types.d.ts +11 -0
- package/dist/systems/crdt/types.d.ts.map +1 -0
- package/dist/systems/crdt/types.js +3 -0
- package/dist/systems/crdt/types.js.map +1 -0
- package/dist/systems/crdt/utils.d.ts +2 -4
- package/dist/systems/crdt/utils.d.ts.map +1 -1
- package/dist/systems/crdt/utils.js +10 -9
- package/dist/systems/crdt/utils.js.map +1 -1
- package/package.json +2 -2
|
@@ -11,111 +11,145 @@ const componentOperation_1 = require("../../serialization/crdt/componentOperatio
|
|
|
11
11
|
const wireMessage_1 = __importDefault(require("../../serialization/wireMessage"));
|
|
12
12
|
const transport_1 = require("./transport");
|
|
13
13
|
const utils_1 = __importDefault(require("./utils"));
|
|
14
|
-
/**
|
|
15
|
-
* TODO:
|
|
16
|
-
* What about when we remove the SyncComponent ? Should we notify all the clients? How ?
|
|
17
|
-
* Where do we create the transport and process the received messages?
|
|
18
|
-
*/
|
|
19
14
|
function crdtSceneSystem(engine) {
|
|
15
|
+
// CRDT Client
|
|
20
16
|
const crdtClient = (0, crdt_1.crdtProtocol)();
|
|
21
|
-
|
|
17
|
+
// Messages that we received at transport.onMessage waiting to be processed
|
|
18
|
+
const receivedMessages = [];
|
|
19
|
+
// Messages already processed by the engine but that we need to broadcast to other transports.
|
|
20
|
+
const transportMessages = [];
|
|
21
|
+
// Map of entities already processed at least once
|
|
22
22
|
const crdtEntities = new Map();
|
|
23
|
-
const
|
|
24
|
-
transport.onmessage = parseChunkMessage;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
const transports = (0, transport_1.getTransports)();
|
|
24
|
+
transports.forEach((transport) => (transport.onmessage = parseChunkMessage(transport.type)));
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @param transportType tranport id to identiy messages
|
|
28
|
+
* @returns a function to process received messages
|
|
29
|
+
*/
|
|
30
|
+
function parseChunkMessage(transportType) {
|
|
31
|
+
/**
|
|
32
|
+
* Receives a chunk of binary messages and stores all the valid
|
|
33
|
+
* Component Operation Messages at messages queue
|
|
34
|
+
* @param chunkMessage A chunk of binary messages
|
|
35
|
+
*/
|
|
36
|
+
return function parseChunkMessage(chunkMessage) {
|
|
37
|
+
if (!chunkMessage.data?.length)
|
|
38
|
+
return;
|
|
39
|
+
const buffer = (0, ByteBuffer_1.createByteBuffer)({
|
|
40
|
+
reading: { buffer: chunkMessage.data, currentOffset: 0 }
|
|
38
41
|
});
|
|
39
|
-
|
|
42
|
+
while (wireMessage_1.default.validate(buffer)) {
|
|
43
|
+
const offset = buffer.currentReadOffset();
|
|
44
|
+
const message = componentOperation_1.PutComponentOperation.read(buffer);
|
|
45
|
+
const { entity, componentId, data, timestamp } = message;
|
|
46
|
+
receivedMessages.push({
|
|
47
|
+
entity,
|
|
48
|
+
componentId,
|
|
49
|
+
data,
|
|
50
|
+
timestamp,
|
|
51
|
+
transportType,
|
|
52
|
+
messageBuffer: buffer
|
|
53
|
+
.buffer()
|
|
54
|
+
.subarray(offset, buffer.currentReadOffset())
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
};
|
|
40
58
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Return and clear the messaes queue
|
|
61
|
+
* @returns messages recieved by the transport to process on the next tick
|
|
62
|
+
*/
|
|
63
|
+
function getMessages(value) {
|
|
64
|
+
const messagesToProcess = Array.from(value);
|
|
65
|
+
value.length = 0;
|
|
44
66
|
return messagesToProcess;
|
|
45
67
|
}
|
|
46
68
|
/**
|
|
47
|
-
* This
|
|
69
|
+
* This fn will be called on every tick.
|
|
70
|
+
* Process all the messages queue received by the transport
|
|
48
71
|
*/
|
|
49
|
-
function
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
72
|
+
function receiveMessages() {
|
|
73
|
+
const messagesToProcess = getMessages(receivedMessages);
|
|
74
|
+
for (const transport of transports) {
|
|
75
|
+
const buffer = (0, ByteBuffer_1.createByteBuffer)();
|
|
76
|
+
for (const message of messagesToProcess) {
|
|
77
|
+
const { data, timestamp, componentId, entity } = message;
|
|
78
|
+
const crdtMessage = {
|
|
79
|
+
key: utils_1.default.getKey(entity, componentId),
|
|
80
|
+
data: data,
|
|
81
|
+
timestamp: timestamp
|
|
82
|
+
};
|
|
83
|
+
const component = engine.getComponent(componentId);
|
|
84
|
+
const currentMessage = crdtClient.processMessage(crdtMessage);
|
|
85
|
+
// CRDT outdated message. Resend this message through the wire
|
|
86
|
+
// TODO: perf transactor
|
|
87
|
+
if (crdtMessage !== currentMessage) {
|
|
88
|
+
// CRDT outdated message. Resend this message through the wire
|
|
89
|
+
componentOperation_1.PutComponentOperation.write(entity, currentMessage.timestamp, component, buffer);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
const opts = { reading: { buffer: message.data, currentOffset: 0 } };
|
|
93
|
+
const bb = (0, ByteBuffer_1.createByteBuffer)(opts);
|
|
94
|
+
// Update engine component
|
|
95
|
+
component.upsertFromBinary(message.entity, bb);
|
|
96
|
+
component.clearDirty();
|
|
97
|
+
// Add message to transport queue to be processed by others transports
|
|
98
|
+
transportMessages.push(message);
|
|
99
|
+
}
|
|
60
100
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
reading: {
|
|
64
|
-
buffer: message.data,
|
|
65
|
-
currentOffset: 0
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
component.upsertFromBinary(entity, bb);
|
|
69
|
-
component.clearDirty();
|
|
101
|
+
if (buffer.size()) {
|
|
102
|
+
transport.send(buffer.toBinary());
|
|
70
103
|
}
|
|
71
104
|
}
|
|
72
|
-
if (buffer.size()) {
|
|
73
|
-
transport.send(buffer.toBinary());
|
|
74
|
-
}
|
|
75
105
|
}
|
|
76
|
-
|
|
106
|
+
/**
|
|
107
|
+
* Iterates the dirty map and generates crdt messages to be send
|
|
108
|
+
* @param dirtyMap a map of { entities: [componentId] }
|
|
109
|
+
*/
|
|
110
|
+
function createMessages(dirtyMap) {
|
|
111
|
+
// CRDT Messages will be the merge between the recieved transport messages and the new crdt messages
|
|
112
|
+
const crdtMessages = getMessages(transportMessages);
|
|
77
113
|
const buffer = (0, ByteBuffer_1.createByteBuffer)();
|
|
78
114
|
for (const [entity, componentsId] of dirtyMap) {
|
|
79
|
-
if (entity_utils_1.default.isStaticEntity(entity) && !crdtEntities.has(entity)) {
|
|
80
|
-
crdtEntities.set(entity, true);
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
crdtEntities.set(entity, true);
|
|
84
115
|
for (const componentId of componentsId) {
|
|
85
116
|
const component = engine.getComponent(componentId);
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
|
|
117
|
+
const event = crdtClient.createEvent(utils_1.default.getKey(entity, componentId), component.toBinary(entity).toBinary());
|
|
118
|
+
const offset = buffer.currentWriteOffset();
|
|
119
|
+
// There is no need to create messages for the static entities the first time they are created
|
|
120
|
+
// They are part of the scene loading. Send only updates.
|
|
121
|
+
if (!entity_utils_1.default.isStaticEntity(entity) || crdtEntities.has(entity)) {
|
|
122
|
+
componentOperation_1.PutComponentOperation.write(entity, event.timestamp, component, buffer);
|
|
123
|
+
crdtMessages.push({
|
|
124
|
+
componentId,
|
|
125
|
+
entity,
|
|
126
|
+
timestamp: event.timestamp,
|
|
127
|
+
messageBuffer: buffer
|
|
128
|
+
.buffer()
|
|
129
|
+
.subarray(offset, buffer.currentWriteOffset())
|
|
130
|
+
});
|
|
131
|
+
}
|
|
89
132
|
}
|
|
133
|
+
crdtEntities.set(entity, true);
|
|
90
134
|
}
|
|
91
|
-
|
|
92
|
-
|
|
135
|
+
// Send messages to transports
|
|
136
|
+
const transportBuffer = (0, ByteBuffer_1.createByteBuffer)();
|
|
137
|
+
for (const transport of transports) {
|
|
138
|
+
transportBuffer.resetBuffer();
|
|
139
|
+
for (const message of crdtMessages) {
|
|
140
|
+
if (transport.filter(message)) {
|
|
141
|
+
transportBuffer.writeBuffer(message.messageBuffer, false);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (transportBuffer.size()) {
|
|
145
|
+
transport.send(transportBuffer.toBinary());
|
|
146
|
+
}
|
|
93
147
|
}
|
|
94
148
|
}
|
|
95
149
|
return {
|
|
96
|
-
|
|
97
|
-
|
|
150
|
+
createMessages,
|
|
151
|
+
receiveMessages
|
|
98
152
|
};
|
|
99
153
|
}
|
|
100
154
|
exports.crdtSceneSystem = crdtSceneSystem;
|
|
101
|
-
// const { Sync } = engine.baseComponents
|
|
102
|
-
// for (const [entity] of engine.groupOf(Dirty)) {
|
|
103
|
-
// const components = engine.getEntityComponents(entity)
|
|
104
|
-
// for (const p of )
|
|
105
|
-
// }
|
|
106
|
-
// for (const [entity] of engine.mutableGroupOf(Sync)) {
|
|
107
|
-
// for (const component of engine.getEntityComponents(entity)) {
|
|
108
|
-
// // If its a new entity, we should send all the components.
|
|
109
|
-
// // Otherwise, we send only the updates (dirty)
|
|
110
|
-
// if (!crdtEntities.has(entity) || component.isDirty(entity)) {
|
|
111
|
-
// const event = crdtClient.createEvent(
|
|
112
|
-
// getKey(entity, component._id),
|
|
113
|
-
// component.toBinary(entity)
|
|
114
|
-
// )
|
|
115
|
-
// void crdtClient.sendMessage(event)
|
|
116
|
-
// return
|
|
117
|
-
// }
|
|
118
|
-
// }
|
|
119
|
-
// crdtEntities.add(entity)
|
|
120
|
-
// }
|
|
121
155
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/systems/crdt/index.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/systems/crdt/index.ts"],"names":[],"mappings":";;;;;;AAAA,oCAAgE;AAIhE,6EAAmD;AACnD,+DAAiE;AACjE,oFAA8F;AAC9F,kFAAyD;AACzD,2CAA2C;AAE3C,oDAA+B;AAE/B,SAAgB,eAAe,CAAC,MAAiB;IAC/C,cAAc;IACd,MAAM,UAAU,GAAG,IAAA,mBAAY,GAAc,CAAA;IAC7C,2EAA2E;IAC3E,MAAM,gBAAgB,GAAqB,EAAE,CAAA;IAC7C,8FAA8F;IAC9F,MAAM,iBAAiB,GAAuB,EAAE,CAAA;IAChD,kDAAkD;IAClD,MAAM,YAAY,GAAG,IAAI,GAAG,EAAmB,CAAA;IAE/C,MAAM,UAAU,GAAG,IAAA,yBAAa,GAAE,CAAA;IAClC,UAAU,CAAC,OAAO,CAChB,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,SAAS,GAAG,iBAAiB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CACzE,CAAA;IAED;;;;OAIG;IACH,SAAS,iBAAiB,CAAC,aAAqB;QAC9C;;;;WAIG;QACH,OAAO,SAAS,iBA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AC,CAAA;iBAC1D;aACF;YACD,IAAI,eAAe,CAAC,IAAI,EAAE,EAAE;gBAC1B,SAAS,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,CAAA;aAC3C;SACF;IACH,CAAC;IAED,OAAO;QACL,cAAc;QACd,eAAe;KAChB,CAAA;AACH,CAAC;AA7JD,0CA6JC"}
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { TransportMessage } from './types';
|
|
2
|
+
export declare type Transport = {
|
|
3
|
+
type: string;
|
|
4
|
+
send(message: Uint8Array): void;
|
|
5
|
+
onmessage?(message: MessageEvent<Uint8Array>): void;
|
|
6
|
+
filter(message: TransportMessage): boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare function getTransports(): Transport[];
|
|
2
9
|
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/systems/crdt/transport.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/systems/crdt/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE1C,oBAAY,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAA;IAC/B,SAAS,CAAC,CAAC,OAAO,EAAE,YAAY,CAAC,UAAU,CAAC,GAAG,IAAI,CAAA;IACnD,MAAM,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAA;CAC3C,CAAA;AAuBD,wBAAgB,aAAa,gBAE5B"}
|
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
function
|
|
5
|
-
|
|
3
|
+
exports.getTransports = void 0;
|
|
4
|
+
function networkTransport() {
|
|
5
|
+
// const rpc = new RpcTransport()
|
|
6
|
+
const rpc = {
|
|
7
|
+
send: () => { }
|
|
8
|
+
};
|
|
9
|
+
const type = 'network-transport';
|
|
10
|
+
return {
|
|
11
|
+
...rpc,
|
|
12
|
+
type,
|
|
13
|
+
filter(message) {
|
|
14
|
+
// Echo message, ignore them
|
|
15
|
+
if (message.transportType === type) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
return !!message; // validComponents.includes(componentId)
|
|
19
|
+
}
|
|
20
|
+
};
|
|
6
21
|
}
|
|
7
|
-
|
|
22
|
+
function getTransports() {
|
|
23
|
+
return [networkTransport()];
|
|
24
|
+
}
|
|
25
|
+
exports.getTransports = getTransports;
|
|
8
26
|
//# sourceMappingURL=transport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../src/systems/crdt/transport.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../src/systems/crdt/transport.ts"],"names":[],"mappings":";;;AASA,SAAS,gBAAgB;IACvB,iCAAiC;IACjC,MAAM,GAAG,GAAG;QACV,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;KACf,CAAA;IAED,MAAM,IAAI,GAAG,mBAAmB,CAAA;IAChC,OAAO;QACL,GAAG,GAAG;QACN,IAAI;QACJ,MAAM,CAAC,OAAyB;YAC9B,4BAA4B;YAC5B,IAAI,OAAO,CAAC,aAAa,KAAK,IAAI,EAAE;gBAClC,OAAO,KAAK,CAAA;aACb;YAED,OAAO,CAAC,CAAC,OAAO,CAAA,CAAC,wCAAwC;QAC3D,CAAC;KACF,CAAA;AACH,CAAC;AAED,SAAgB,aAAa;IAC3B,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAA;AAC7B,CAAC;AAFD,sCAEC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Entity } from '../../engine/entity';
|
|
2
|
+
export declare type ReceiveMessage = {
|
|
3
|
+
entity: Entity;
|
|
4
|
+
componentId: number;
|
|
5
|
+
timestamp: number;
|
|
6
|
+
transportType?: string;
|
|
7
|
+
data: Uint8Array;
|
|
8
|
+
messageBuffer: Uint8Array;
|
|
9
|
+
};
|
|
10
|
+
export declare type TransportMessage = Omit<ReceiveMessage, 'data'>;
|
|
11
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/systems/crdt/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAE5C,oBAAY,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,IAAI,EAAE,UAAU,CAAA;IAChB,aAAa,EAAE,UAAU,CAAA;CAC1B,CAAA;AAED,oBAAY,gBAAgB,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/systems/crdt/types.ts"],"names":[],"mappings":""}
|
|
@@ -2,12 +2,10 @@ import { ComponentDefinition } from '../../engine/component';
|
|
|
2
2
|
import { Entity } from '../../engine/entity';
|
|
3
3
|
export declare namespace CrdtUtils {
|
|
4
4
|
type ComponentID = ComponentDefinition['_id'];
|
|
5
|
-
function parseKey(key: string): [Entity, ComponentID];
|
|
6
5
|
function getKey(entity: Entity, componentId: ComponentID): string;
|
|
7
6
|
enum SynchronizedEntityType {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
RENDERER = 2
|
|
7
|
+
NETWORKED = 0,
|
|
8
|
+
RENDERER = 1
|
|
11
9
|
}
|
|
12
10
|
}
|
|
13
11
|
export default CrdtUtils;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/systems/crdt/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/systems/crdt/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAE5C,yBAAiB,SAAS,CAAC;IACzB,KAAY,WAAW,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAA;IAWpD,SAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,GAAG,MAAM,CAEvE;IAED,KAAY,sBAAsB;QAEhC,SAAS,IAAA;QAET,QAAQ,IAAA;KACT;CACF;AAED,eAAe,SAAS,CAAA"}
|
|
@@ -3,23 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CrdtUtils = void 0;
|
|
4
4
|
var CrdtUtils;
|
|
5
5
|
(function (CrdtUtils) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
// TODO: use this again
|
|
7
|
+
// export function parseKey(key: string): [Entity, ComponentID] {
|
|
8
|
+
// const [entity, componentId] = key.split('.').map(Number) as [
|
|
9
|
+
// Entity,
|
|
10
|
+
// ComponentID
|
|
11
|
+
// ]
|
|
12
|
+
// return [entity, componentId]
|
|
13
|
+
// }
|
|
11
14
|
function getKey(entity, componentId) {
|
|
12
15
|
return `${entity}.${componentId}`;
|
|
13
16
|
}
|
|
14
17
|
CrdtUtils.getKey = getKey;
|
|
15
18
|
let SynchronizedEntityType;
|
|
16
19
|
(function (SynchronizedEntityType) {
|
|
17
|
-
// synchronizes all entities without filter. used for renderers
|
|
18
|
-
SynchronizedEntityType[SynchronizedEntityType["ALL"] = 0] = "ALL";
|
|
19
20
|
// synchronizes entities with the NetworkSynchronized component only, used for networked games
|
|
20
|
-
SynchronizedEntityType[SynchronizedEntityType["NETWORKED"] =
|
|
21
|
+
SynchronizedEntityType[SynchronizedEntityType["NETWORKED"] = 0] = "NETWORKED";
|
|
21
22
|
// synchronizes entities needed by the renderer
|
|
22
|
-
SynchronizedEntityType[SynchronizedEntityType["RENDERER"] =
|
|
23
|
+
SynchronizedEntityType[SynchronizedEntityType["RENDERER"] = 1] = "RENDERER";
|
|
23
24
|
})(SynchronizedEntityType = CrdtUtils.SynchronizedEntityType || (CrdtUtils.SynchronizedEntityType = {}));
|
|
24
25
|
})(CrdtUtils = exports.CrdtUtils || (exports.CrdtUtils = {}));
|
|
25
26
|
exports.default = CrdtUtils;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/systems/crdt/utils.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/systems/crdt/utils.ts"],"names":[],"mappings":";;;AAGA,IAAiB,SAAS,CAsBzB;AAtBD,WAAiB,SAAS;IAGxB,uBAAuB;IACvB,iEAAiE;IACjE,kEAAkE;IAClE,cAAc;IACd,kBAAkB;IAClB,MAAM;IACN,iCAAiC;IACjC,IAAI;IAEJ,SAAgB,MAAM,CAAC,MAAc,EAAE,WAAwB;QAC7D,OAAO,GAAG,MAAM,IAAI,WAAW,EAAE,CAAA;IACnC,CAAC;IAFe,gBAAM,SAErB,CAAA;IAED,IAAY,sBAKX;IALD,WAAY,sBAAsB;QAChC,8FAA8F;QAC9F,6EAAS,CAAA;QACT,+CAA+C;QAC/C,2EAAQ,CAAA;IACV,CAAC,EALW,sBAAsB,GAAtB,gCAAsB,KAAtB,gCAAsB,QAKjC;AACH,CAAC,EAtBgB,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAsBzB;AAED,kBAAe,SAAS,CAAA;AAExB,mEAAmE;AACnE,8CAA8C;AAC9C,iCAAiC;AACjC,4DAA4D;AAC5D,2FAA2F;AAC3F,2CAA2C;AAE3C,oCAAoC;AACpC,gDAAgD;AAChD,+HAA+H;AAC/H,uBAAuB;AACvB,MAAM;AACN,KAAK;AAEL,sDAAsD;AACtD,WAAW;AACX,IAAI;AAEJ,8BAA8B;AAC9B,2CAA2C;AAE3C,2CAA2C;AAC3C,gDAAgD;AAChD,MAAM;AAEN,sBAAsB;AACtB,0BAA0B;AAC1B,MAAM;AAEN,4BAA4B;AAC5B,IAAI;AAEJ,2BAA2B;AAC3B,4CAA4C;AAC5C,IAAI"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcl/ecs",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-20220525093820.commit-c20b8cd",
|
|
4
4
|
"description": "Decentraland ECS",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"files": [
|
|
42
42
|
"dist"
|
|
43
43
|
],
|
|
44
|
-
"commit": "
|
|
44
|
+
"commit": "c20b8cd2582224d6bc67d3b7ca86f3c00e2e9952"
|
|
45
45
|
}
|