@livon/runtime 0.27.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/THIRD_PARTY_NOTICES.md +28 -0
- package/dist/index.cjs +36 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +2 -0
- package/dist/runtime.cjs +372 -0
- package/dist/runtime.d.ts +13 -0
- package/dist/runtime.js +338 -0
- package/dist/runtime.spec.cjs +280 -0
- package/dist/runtime.spec.d.ts +1 -0
- package/dist/runtime.spec.js +274 -0
- package/dist/testing/mocks/index.cjs +42 -0
- package/dist/testing/mocks/index.d.ts +2 -0
- package/dist/testing/mocks/index.js +2 -0
- package/dist/testing/mocks/runtime.mock.cjs +63 -0
- package/dist/testing/mocks/runtime.mock.d.ts +22 -0
- package/dist/testing/mocks/runtime.mock.js +23 -0
- package/dist/types.cjs +18 -0
- package/dist/types.d.ts +143 -0
- package/dist/types.js +0 -0
- package/package.json +42 -0
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
Third-Party Notices
|
|
2
|
+
|
|
3
|
+
This package includes third-party software. The following licenses apply:
|
|
4
|
+
|
|
5
|
+
------------------------------------------------------------------------------
|
|
6
|
+
msgpackr
|
|
7
|
+
------------------------------------------------------------------------------
|
|
8
|
+
License: MIT
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2020 Kris Zyp
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
runtime: ()=>external_runtime_cjs_namespaceObject.runtime
|
|
28
|
+
});
|
|
29
|
+
const external_runtime_cjs_namespaceObject = require("./runtime.cjs");
|
|
30
|
+
exports.runtime = __webpack_exports__.runtime;
|
|
31
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
32
|
+
"runtime"
|
|
33
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
34
|
+
Object.defineProperty(exports, '__esModule', {
|
|
35
|
+
value: true
|
|
36
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public package entrypoint for `@livon/runtime`.
|
|
3
|
+
*
|
|
4
|
+
* @see https://live-input-vector-output-node.github.io/livon-ts/docs/packages/runtime
|
|
5
|
+
*/
|
|
6
|
+
export { runtime } from './runtime.js';
|
|
7
|
+
export type { RuntimeEventContext, EventStatus, EventError, EventEnvelopeBase, EventEnvelopePayload, EventEnvelopeError, EventEnvelope, EventAck, EmitInputBase, EmitInputPayload, EmitInputError, EmitInput, EmitEvent, EmitReceive, EmitSend, EmitError, RoomSelector, StateGet, StateSet, RuntimeState, RuntimeContext, RuntimeHook, RuntimeModule, RuntimeOnError, RuntimeInput, RuntimeModuleRegister, RuntimeHookRegister, RuntimeOnErrorRegister, RuntimeHookSubscription, RuntimeUnsubscribe, RuntimeRegistry, RuntimeStart, PartialEventEnvelopeBase, PartialEventEnvelopePayload, PartialEventEnvelopeError, PartialEventEnvelopeEmpty, PartialEventEnvelope, } from './types.js';
|
|
8
|
+
export type { RuntimeStart as RuntimeFactory } from './types.js';
|
package/dist/index.js
ADDED
package/dist/runtime.cjs
ADDED
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
runtime: ()=>runtime
|
|
28
|
+
});
|
|
29
|
+
const createHookStore = ()=>({
|
|
30
|
+
onReceive: [],
|
|
31
|
+
onSend: [],
|
|
32
|
+
onError: []
|
|
33
|
+
});
|
|
34
|
+
const createState = ()=>{
|
|
35
|
+
const store = new Map();
|
|
36
|
+
const get = (key)=>store.get(key);
|
|
37
|
+
const set = (key, value)=>{
|
|
38
|
+
store.set(key, value);
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
get,
|
|
42
|
+
set
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
const mergeMetadata = (base, extra)=>{
|
|
46
|
+
if (!base && !extra) return;
|
|
47
|
+
return {
|
|
48
|
+
...base ?? {},
|
|
49
|
+
...extra ?? {}
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
let fallbackEventIdCounter = 0;
|
|
53
|
+
const createEventId = ()=>{
|
|
54
|
+
const cryptoValue = globalThis.crypto;
|
|
55
|
+
if (cryptoValue?.randomUUID) return cryptoValue.randomUUID();
|
|
56
|
+
fallbackEventIdCounter += 1;
|
|
57
|
+
return `evt_${Date.now().toString(36)}_${fallbackEventIdCounter.toString(36)}`;
|
|
58
|
+
};
|
|
59
|
+
const isContextRecord = (value)=>'object' == typeof value && null !== value && !Array.isArray(value);
|
|
60
|
+
const contextRecordFrom = (value)=>{
|
|
61
|
+
if (!value || !isContextRecord(value)) return;
|
|
62
|
+
return value;
|
|
63
|
+
};
|
|
64
|
+
const errorFromUnknown = (error)=>{
|
|
65
|
+
if (error instanceof Error) {
|
|
66
|
+
const context = isContextRecord(error.context) ? error.context : void 0;
|
|
67
|
+
return {
|
|
68
|
+
message: error.message,
|
|
69
|
+
...error.name ? {
|
|
70
|
+
name: error.name
|
|
71
|
+
} : {},
|
|
72
|
+
...error.stack ? {
|
|
73
|
+
stack: error.stack
|
|
74
|
+
} : {},
|
|
75
|
+
...context ? {
|
|
76
|
+
context
|
|
77
|
+
} : {}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
if ('string' == typeof error) return {
|
|
81
|
+
message: error
|
|
82
|
+
};
|
|
83
|
+
if ('object' == typeof error && null !== error) {
|
|
84
|
+
const value = error;
|
|
85
|
+
const message = 'string' == typeof value.message ? value.message : 'Unknown error';
|
|
86
|
+
const name = 'string' == typeof value.name ? value.name : void 0;
|
|
87
|
+
const stack = 'string' == typeof value.stack ? value.stack : void 0;
|
|
88
|
+
const context = isContextRecord(value.context) ? value.context : void 0;
|
|
89
|
+
return {
|
|
90
|
+
message,
|
|
91
|
+
...name ? {
|
|
92
|
+
name
|
|
93
|
+
} : {},
|
|
94
|
+
...stack ? {
|
|
95
|
+
stack
|
|
96
|
+
} : {},
|
|
97
|
+
...context ? {
|
|
98
|
+
context
|
|
99
|
+
} : {}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
message: 'Unknown error'
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
const registerHook = (hooks)=>(hook)=>{
|
|
107
|
+
hooks.push(hook);
|
|
108
|
+
const unsub = ()=>{
|
|
109
|
+
const index = hooks.indexOf(hook);
|
|
110
|
+
if (index >= 0) hooks.splice(index, 1);
|
|
111
|
+
};
|
|
112
|
+
return {
|
|
113
|
+
unsub
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
const registerErrorHook = (hooks)=>(hook)=>{
|
|
117
|
+
hooks.push(hook);
|
|
118
|
+
const unsub = ()=>{
|
|
119
|
+
const index = hooks.indexOf(hook);
|
|
120
|
+
if (index >= 0) hooks.splice(index, 1);
|
|
121
|
+
};
|
|
122
|
+
return {
|
|
123
|
+
unsub
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
const runtime = (inputOrModule, ...rest)=>{
|
|
127
|
+
const input = 'modules' in inputOrModule ? inputOrModule : {
|
|
128
|
+
modules: [
|
|
129
|
+
inputOrModule,
|
|
130
|
+
...rest
|
|
131
|
+
]
|
|
132
|
+
};
|
|
133
|
+
const modules = input.modules;
|
|
134
|
+
const state = createState();
|
|
135
|
+
const hooks = createHookStore();
|
|
136
|
+
const onReceive = registerHook(hooks.onReceive);
|
|
137
|
+
const onSend = registerHook(hooks.onSend);
|
|
138
|
+
const onError = registerErrorHook(hooks.onError);
|
|
139
|
+
const emitErrorHooks = ({ runtimeError, eventEnvelope, runtimeContext })=>{
|
|
140
|
+
hooks.onError.forEach((handler)=>{
|
|
141
|
+
try {
|
|
142
|
+
handler(runtimeError, eventEnvelope, runtimeContext);
|
|
143
|
+
} catch {}
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
const mergeContext = (base, update)=>{
|
|
147
|
+
const left = contextRecordFrom(base);
|
|
148
|
+
const right = contextRecordFrom(update);
|
|
149
|
+
if (!left && !right) return;
|
|
150
|
+
return {
|
|
151
|
+
...left ?? {},
|
|
152
|
+
...right ?? {}
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
const payloadFromEvent = (event)=>event.payload;
|
|
156
|
+
const errorFromEvent = (event)=>event.error;
|
|
157
|
+
const mergeEvent = (base, update)=>{
|
|
158
|
+
if (!update) return base;
|
|
159
|
+
const nextId = update.id ?? base.id;
|
|
160
|
+
const nextEvent = update.event ?? base.event;
|
|
161
|
+
const nextStatus = update.status ?? base.status;
|
|
162
|
+
const nextMetadata = mergeMetadata(base.metadata, update.metadata);
|
|
163
|
+
const nextContext = mergeContext(base.context, update.context);
|
|
164
|
+
const nextPayload = payloadFromEvent(update) ?? payloadFromEvent(base);
|
|
165
|
+
const nextError = errorFromEvent(update) ?? errorFromEvent(base);
|
|
166
|
+
if (void 0 === nextPayload && void 0 === nextError) throw new Error('Event envelope must contain payload or error.');
|
|
167
|
+
const mergedEnvelopeBase = {
|
|
168
|
+
...base,
|
|
169
|
+
id: nextId,
|
|
170
|
+
event: nextEvent,
|
|
171
|
+
status: nextStatus,
|
|
172
|
+
metadata: nextMetadata,
|
|
173
|
+
context: nextContext
|
|
174
|
+
};
|
|
175
|
+
if (void 0 !== nextPayload && void 0 !== nextError) return {
|
|
176
|
+
...mergedEnvelopeBase,
|
|
177
|
+
payload: nextPayload,
|
|
178
|
+
error: nextError
|
|
179
|
+
};
|
|
180
|
+
if (void 0 !== nextPayload) return {
|
|
181
|
+
...mergedEnvelopeBase,
|
|
182
|
+
payload: nextPayload
|
|
183
|
+
};
|
|
184
|
+
const definedError = nextError;
|
|
185
|
+
return {
|
|
186
|
+
...mergedEnvelopeBase,
|
|
187
|
+
error: definedError
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
const buildEnvelope = ({ emitInput, fallbackStatus, roomName })=>{
|
|
191
|
+
const { id: inputId, event, status: inputStatus, metadata: inputMetadata, context, payload, error } = emitInput;
|
|
192
|
+
const roomMeta = roomName ? {
|
|
193
|
+
room: roomName
|
|
194
|
+
} : void 0;
|
|
195
|
+
const metadata = mergeMetadata(roomMeta, inputMetadata);
|
|
196
|
+
const id = inputId ?? createEventId();
|
|
197
|
+
const status = inputStatus ?? fallbackStatus;
|
|
198
|
+
if (void 0 === payload && void 0 === error) throw new Error('Emit input must contain payload or error.');
|
|
199
|
+
const envelopeBase = {
|
|
200
|
+
id,
|
|
201
|
+
event,
|
|
202
|
+
status,
|
|
203
|
+
metadata,
|
|
204
|
+
context
|
|
205
|
+
};
|
|
206
|
+
if (void 0 !== payload && void 0 !== error) return {
|
|
207
|
+
...envelopeBase,
|
|
208
|
+
payload,
|
|
209
|
+
error
|
|
210
|
+
};
|
|
211
|
+
if (void 0 !== payload) return {
|
|
212
|
+
...envelopeBase,
|
|
213
|
+
payload
|
|
214
|
+
};
|
|
215
|
+
const definedError = error;
|
|
216
|
+
return {
|
|
217
|
+
...envelopeBase,
|
|
218
|
+
error: definedError
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
const buildFailedEnvelope = ({ runtimeError, eventEnvelope })=>{
|
|
222
|
+
const normalizedError = errorFromUnknown(runtimeError);
|
|
223
|
+
const nextContext = mergeContext(eventEnvelope.context, normalizedError.context);
|
|
224
|
+
return {
|
|
225
|
+
...eventEnvelope,
|
|
226
|
+
error: normalizedError,
|
|
227
|
+
context: nextContext
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
const invokeHook = (input)=>{
|
|
231
|
+
const hook = input.hookChain[input.hookIndex];
|
|
232
|
+
if (!hook) return Promise.resolve(input.eventEnvelope);
|
|
233
|
+
let nextPromise;
|
|
234
|
+
let nextCalled = false;
|
|
235
|
+
const next = (update)=>{
|
|
236
|
+
nextCalled = true;
|
|
237
|
+
nextPromise = invokeHook({
|
|
238
|
+
hookChain: input.hookChain,
|
|
239
|
+
hookIndex: input.hookIndex + 1,
|
|
240
|
+
eventEnvelope: mergeEvent(input.eventEnvelope, update),
|
|
241
|
+
runtimeContext: input.runtimeContext
|
|
242
|
+
});
|
|
243
|
+
return nextPromise;
|
|
244
|
+
};
|
|
245
|
+
const result = hook(input.eventEnvelope, input.runtimeContext, next);
|
|
246
|
+
if (void 0 === result && nextCalled) return nextPromise ?? Promise.resolve(input.eventEnvelope);
|
|
247
|
+
return Promise.resolve(result).then((value)=>value ?? nextPromise ?? input.eventEnvelope);
|
|
248
|
+
};
|
|
249
|
+
const runReceive = (eventEnvelope, runtimeContext)=>invokeHook({
|
|
250
|
+
hookChain: hooks.onReceive,
|
|
251
|
+
hookIndex: 0,
|
|
252
|
+
eventEnvelope,
|
|
253
|
+
runtimeContext
|
|
254
|
+
});
|
|
255
|
+
const runSend = (eventEnvelope, runtimeContext)=>invokeHook({
|
|
256
|
+
hookChain: hooks.onSend,
|
|
257
|
+
hookIndex: 0,
|
|
258
|
+
eventEnvelope,
|
|
259
|
+
runtimeContext
|
|
260
|
+
});
|
|
261
|
+
const createEmitError = ({ runtimeContext, roomName })=>async (emitInput)=>{
|
|
262
|
+
const envelope = buildEnvelope({
|
|
263
|
+
emitInput,
|
|
264
|
+
fallbackStatus: 'sending',
|
|
265
|
+
roomName
|
|
266
|
+
});
|
|
267
|
+
const fallbackError = envelope.error ?? {
|
|
268
|
+
message: 'Unknown error'
|
|
269
|
+
};
|
|
270
|
+
const failedEnvelope = {
|
|
271
|
+
...envelope,
|
|
272
|
+
error: fallbackError
|
|
273
|
+
};
|
|
274
|
+
emitErrorHooks({
|
|
275
|
+
runtimeError: fallbackError,
|
|
276
|
+
eventEnvelope: failedEnvelope,
|
|
277
|
+
runtimeContext
|
|
278
|
+
});
|
|
279
|
+
return {
|
|
280
|
+
ok: true
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
const createEmitReceive = ({ runtimeContext, roomName })=>async (emitInput)=>{
|
|
284
|
+
const envelope = buildEnvelope({
|
|
285
|
+
emitInput,
|
|
286
|
+
fallbackStatus: 'receiving',
|
|
287
|
+
roomName
|
|
288
|
+
});
|
|
289
|
+
try {
|
|
290
|
+
await runReceive(envelope, runtimeContext);
|
|
291
|
+
return {
|
|
292
|
+
ok: true
|
|
293
|
+
};
|
|
294
|
+
} catch (error) {
|
|
295
|
+
const failedEnvelope = buildFailedEnvelope({
|
|
296
|
+
runtimeError: error,
|
|
297
|
+
eventEnvelope: envelope
|
|
298
|
+
});
|
|
299
|
+
emitErrorHooks({
|
|
300
|
+
runtimeError: error,
|
|
301
|
+
eventEnvelope: failedEnvelope,
|
|
302
|
+
runtimeContext
|
|
303
|
+
});
|
|
304
|
+
return {
|
|
305
|
+
ok: false,
|
|
306
|
+
error: failedEnvelope.error.message
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
const createEmitSend = ({ runtimeContext, roomName })=>async (emitInput)=>{
|
|
311
|
+
const envelope = buildEnvelope({
|
|
312
|
+
emitInput,
|
|
313
|
+
fallbackStatus: 'sending',
|
|
314
|
+
roomName
|
|
315
|
+
});
|
|
316
|
+
try {
|
|
317
|
+
await runSend(envelope, runtimeContext);
|
|
318
|
+
return {
|
|
319
|
+
ok: true
|
|
320
|
+
};
|
|
321
|
+
} catch (error) {
|
|
322
|
+
const failedEnvelope = buildFailedEnvelope({
|
|
323
|
+
runtimeError: error,
|
|
324
|
+
eventEnvelope: envelope
|
|
325
|
+
});
|
|
326
|
+
emitErrorHooks({
|
|
327
|
+
runtimeError: error,
|
|
328
|
+
eventEnvelope: failedEnvelope,
|
|
329
|
+
runtimeContext
|
|
330
|
+
});
|
|
331
|
+
return {
|
|
332
|
+
ok: false,
|
|
333
|
+
error: failedEnvelope.error.message
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
const createEmitEvent = (input)=>async (eventInput)=>createEmitSend(input)(eventInput);
|
|
338
|
+
const createContext = (roomName)=>{
|
|
339
|
+
const runtimeContext = {};
|
|
340
|
+
const createEmitInput = {
|
|
341
|
+
runtimeContext,
|
|
342
|
+
roomName
|
|
343
|
+
};
|
|
344
|
+
runtimeContext.emitReceive = createEmitReceive(createEmitInput);
|
|
345
|
+
runtimeContext.emitSend = createEmitSend(createEmitInput);
|
|
346
|
+
runtimeContext.emitError = createEmitError(createEmitInput);
|
|
347
|
+
runtimeContext.emitEvent = createEmitEvent(createEmitInput);
|
|
348
|
+
runtimeContext.room = (nextRoomName)=>createContext(nextRoomName);
|
|
349
|
+
runtimeContext.state = state;
|
|
350
|
+
return runtimeContext;
|
|
351
|
+
};
|
|
352
|
+
const baseContext = createContext();
|
|
353
|
+
const registry = {
|
|
354
|
+
emitReceive: baseContext.emitReceive,
|
|
355
|
+
emitSend: baseContext.emitSend,
|
|
356
|
+
emitError: baseContext.emitError,
|
|
357
|
+
onReceive,
|
|
358
|
+
onSend,
|
|
359
|
+
onError,
|
|
360
|
+
state
|
|
361
|
+
};
|
|
362
|
+
modules.forEach((mod)=>{
|
|
363
|
+
mod.register(registry);
|
|
364
|
+
});
|
|
365
|
+
};
|
|
366
|
+
exports.runtime = __webpack_exports__.runtime;
|
|
367
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
368
|
+
"runtime"
|
|
369
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
370
|
+
Object.defineProperty(exports, '__esModule', {
|
|
371
|
+
value: true
|
|
372
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RuntimeStart } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* runtime is part of the public LIVON API.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Parameter and return types are defined in the TypeScript signature.
|
|
7
|
+
*
|
|
8
|
+
* @see https://live-input-vector-output-node.github.io/livon-ts/docs/packages/runtime
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const result = runtime(undefined as never);
|
|
12
|
+
*/
|
|
13
|
+
export declare const runtime: RuntimeStart;
|