@casual-simulation/aux-runtime 3.2.7-alpha.6226622763
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/LICENSE.txt +21 -0
- package/README.md +82 -0
- package/index.d.ts +26 -0
- package/index.js +26 -0
- package/index.js.map +1 -0
- package/package.json +79 -0
- package/runtime/AuxCompiler.d.ts +258 -0
- package/runtime/AuxCompiler.js +722 -0
- package/runtime/AuxCompiler.js.map +1 -0
- package/runtime/AuxDevice.d.ts +28 -0
- package/runtime/AuxDevice.js +2 -0
- package/runtime/AuxDevice.js.map +1 -0
- package/runtime/AuxGlobalContext.d.ts +572 -0
- package/runtime/AuxGlobalContext.js +606 -0
- package/runtime/AuxGlobalContext.js.map +1 -0
- package/runtime/AuxLibrary.d.ts +2566 -0
- package/runtime/AuxLibrary.js +10210 -0
- package/runtime/AuxLibrary.js.map +1 -0
- package/runtime/AuxLibraryDefinitions.def +12288 -0
- package/runtime/AuxPartitionRealtimeEditModeProvider.d.ts +9 -0
- package/runtime/AuxPartitionRealtimeEditModeProvider.js +21 -0
- package/runtime/AuxPartitionRealtimeEditModeProvider.js.map +1 -0
- package/runtime/AuxRealtimeEditModeProvider.d.ts +35 -0
- package/runtime/AuxRealtimeEditModeProvider.js +34 -0
- package/runtime/AuxRealtimeEditModeProvider.js.map +1 -0
- package/runtime/AuxResults.d.ts +77 -0
- package/runtime/AuxResults.js +6 -0
- package/runtime/AuxResults.js.map +1 -0
- package/runtime/AuxRuntime.d.ts +252 -0
- package/runtime/AuxRuntime.js +2688 -0
- package/runtime/AuxRuntime.js.map +1 -0
- package/runtime/AuxRuntimeDynamicImports.d.ts +14 -0
- package/runtime/AuxRuntimeDynamicImports.js +24 -0
- package/runtime/AuxRuntimeDynamicImports.js.map +1 -0
- package/runtime/AuxVersion.d.ts +39 -0
- package/runtime/AuxVersion.js +2 -0
- package/runtime/AuxVersion.js.map +1 -0
- package/runtime/CasualOSError.d.ts +37 -0
- package/runtime/CasualOSError.js +25 -0
- package/runtime/CasualOSError.js.map +1 -0
- package/runtime/CompiledBot.d.ts +107 -0
- package/runtime/CompiledBot.js +44 -0
- package/runtime/CompiledBot.js.map +1 -0
- package/runtime/PerformanceNowPolyfill.d.ts +1 -0
- package/runtime/PerformanceNowPolyfill.js +8 -0
- package/runtime/PerformanceNowPolyfill.js.map +1 -0
- package/runtime/RecordsEvents.d.ts +1025 -0
- package/runtime/RecordsEvents.js +449 -0
- package/runtime/RecordsEvents.js.map +1 -0
- package/runtime/RuntimeBot.d.ts +177 -0
- package/runtime/RuntimeBot.js +732 -0
- package/runtime/RuntimeBot.js.map +1 -0
- package/runtime/RuntimeEvents.d.ts +126 -0
- package/runtime/RuntimeEvents.js +29 -0
- package/runtime/RuntimeEvents.js.map +1 -0
- package/runtime/RuntimeStateVersion.d.ts +23 -0
- package/runtime/RuntimeStateVersion.js +22 -0
- package/runtime/RuntimeStateVersion.js.map +1 -0
- package/runtime/Transpiler.d.ts +174 -0
- package/runtime/Transpiler.js +611 -0
- package/runtime/Transpiler.js.map +1 -0
- package/runtime/Utils.d.ts +44 -0
- package/runtime/Utils.js +253 -0
- package/runtime/Utils.js.map +1 -0
- package/runtime/index.d.ts +13 -0
- package/runtime/index.js +13 -0
- package/runtime/index.js.map +1 -0
- package/runtime/test/TestScriptBotFactory.d.ts +16 -0
- package/runtime/test/TestScriptBotFactory.js +107 -0
- package/runtime/test/TestScriptBotFactory.js.map +1 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { RealtimeEditMode } from './RuntimeBot';
|
|
2
|
+
import { AuxPartitionRealtimeStrategy } from '@casual-simulation/aux-common/partitions/AuxPartition';
|
|
3
|
+
import '@casual-simulation/aux-common/BlobPolyfill';
|
|
4
|
+
export declare function realtimeStrategyToRealtimeEditMode(strategy: AuxPartitionRealtimeStrategy): RealtimeEditMode;
|
|
5
|
+
/**
|
|
6
|
+
* Embeds the given base64 string into a PDF document that references CasualOS.
|
|
7
|
+
* @param str The base64 string to embed.
|
|
8
|
+
*/
|
|
9
|
+
export declare function embedBase64InPdf(str: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Gets the Base64 data that was embedded in the given PDF document by embedBase64InPdf().
|
|
12
|
+
*/
|
|
13
|
+
export declare function getEmbeddedBase64FromPdf(pdf: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Formats the given token and service (bundle ID) into a string that can be used as an auth token for records requests.
|
|
16
|
+
*/
|
|
17
|
+
export declare function formatAuthToken(token: string, service: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Parses the given auth token into a token and service (bundle ID) pair.
|
|
20
|
+
* The returned token is the token that was returned from the auth API and the service is the bundle ID of the app that requested it.
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseAuthToken(token: string): [string, string];
|
|
23
|
+
/**
|
|
24
|
+
* Constructs a Uint8Array from the given hexadecimal formatted string.
|
|
25
|
+
* @param hex The hexadecimal string.
|
|
26
|
+
*/
|
|
27
|
+
export declare function fromHexString(hex: string): Uint8Array;
|
|
28
|
+
/**
|
|
29
|
+
* Constructs a hexidecimal formatted string from the given array of bytes.
|
|
30
|
+
* @param bytes The bytes that should be hex formatted.
|
|
31
|
+
*/
|
|
32
|
+
export declare function toHexString(bytes: Uint8Array): string;
|
|
33
|
+
/**
|
|
34
|
+
* Determines if the given value represents a promise.
|
|
35
|
+
* @param value The value to check.
|
|
36
|
+
*/
|
|
37
|
+
export declare function isPromise<T>(value: unknown): value is Promise<T>;
|
|
38
|
+
export declare const RUNTIME_PROMISE: unique symbol;
|
|
39
|
+
export interface RuntimePromise<T> extends Promise<T> {
|
|
40
|
+
[RUNTIME_PROMISE]: true;
|
|
41
|
+
}
|
|
42
|
+
export declare function isRuntimePromise<T>(value: unknown): value is RuntimePromise<T>;
|
|
43
|
+
export declare function markAsRuntimePromise<T>(promise: Promise<T>): RuntimePromise<T>;
|
|
44
|
+
//# sourceMappingURL=Utils.d.ts.map
|
package/runtime/Utils.js
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { RealtimeEditMode } from './RuntimeBot';
|
|
2
|
+
import '@casual-simulation/aux-common/BlobPolyfill';
|
|
3
|
+
export function realtimeStrategyToRealtimeEditMode(strategy) {
|
|
4
|
+
return strategy === 'immediate'
|
|
5
|
+
? RealtimeEditMode.Immediate
|
|
6
|
+
: RealtimeEditMode.Delayed;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Embeds the given base64 string into a PDF document that references CasualOS.
|
|
10
|
+
* @param str The base64 string to embed.
|
|
11
|
+
*/
|
|
12
|
+
export function embedBase64InPdf(str) {
|
|
13
|
+
return `%PDF-1.3
|
|
14
|
+
%����
|
|
15
|
+
|
|
16
|
+
1 0 obj
|
|
17
|
+
<<
|
|
18
|
+
/Type /Catalog
|
|
19
|
+
/Outlines 2 0 R
|
|
20
|
+
/Pages 3 0 R
|
|
21
|
+
>>
|
|
22
|
+
endobj
|
|
23
|
+
|
|
24
|
+
2 0 obj
|
|
25
|
+
<<
|
|
26
|
+
/Type /Outlines
|
|
27
|
+
/Count 0
|
|
28
|
+
>>
|
|
29
|
+
endobj
|
|
30
|
+
|
|
31
|
+
3 0 obj
|
|
32
|
+
<<
|
|
33
|
+
/Type /Pages
|
|
34
|
+
/Count 1
|
|
35
|
+
/Kids [ 4 0 R ]
|
|
36
|
+
>>
|
|
37
|
+
endobj
|
|
38
|
+
|
|
39
|
+
4 0 obj
|
|
40
|
+
<<
|
|
41
|
+
/Type /Page
|
|
42
|
+
/Parent 3 0 R
|
|
43
|
+
/Resources <<
|
|
44
|
+
/Font <<
|
|
45
|
+
/F1 9 0 R
|
|
46
|
+
>>
|
|
47
|
+
/ProcSet 8 0 R
|
|
48
|
+
>>
|
|
49
|
+
/MediaBox [0 0 512 512]
|
|
50
|
+
/Annots [ 25 0 R ]
|
|
51
|
+
/Contents 5 0 R
|
|
52
|
+
>>
|
|
53
|
+
endobj
|
|
54
|
+
|
|
55
|
+
5 0 obj
|
|
56
|
+
<< /Length 1074 >>
|
|
57
|
+
stream
|
|
58
|
+
BT
|
|
59
|
+
/F1 28 Tf
|
|
60
|
+
183 412 Td
|
|
61
|
+
( CasualOS ) Tj
|
|
62
|
+
ET
|
|
63
|
+
BT
|
|
64
|
+
/F1 16 Tf
|
|
65
|
+
150 256 Td
|
|
66
|
+
( Open) Tj
|
|
67
|
+
ET
|
|
68
|
+
BT
|
|
69
|
+
0 0 1 rg
|
|
70
|
+
0 0 1 RG
|
|
71
|
+
/F1 16 Tf
|
|
72
|
+
193.25 256 Td
|
|
73
|
+
( https://casualos.com ) Tj
|
|
74
|
+
ET
|
|
75
|
+
endstream
|
|
76
|
+
endobj
|
|
77
|
+
|
|
78
|
+
8 0 obj
|
|
79
|
+
[/PDF /Text]
|
|
80
|
+
endobj
|
|
81
|
+
|
|
82
|
+
9 0 obj
|
|
83
|
+
<<
|
|
84
|
+
/Type /Font
|
|
85
|
+
/Subtype /Type1
|
|
86
|
+
/Name /F1
|
|
87
|
+
/BaseFont /Helvetica
|
|
88
|
+
/Encoding /WinAnsiEncoding
|
|
89
|
+
>>
|
|
90
|
+
endobj
|
|
91
|
+
|
|
92
|
+
10 0 obj
|
|
93
|
+
<<
|
|
94
|
+
/Creator (Casual Simulation)
|
|
95
|
+
/Producer (CasualOS)
|
|
96
|
+
/CreationDate (D:20210720000000)
|
|
97
|
+
>>
|
|
98
|
+
endobj
|
|
99
|
+
|
|
100
|
+
25 0 obj % object ID 26 which is referenced by the OBJR in Object 11
|
|
101
|
+
<<
|
|
102
|
+
/Type /Annot
|
|
103
|
+
/Subtype /Link
|
|
104
|
+
/Border [0 0 0] %a colorless border
|
|
105
|
+
/Rect [193.25 245 350 276] %the boundaries defining target area where link annotation is active
|
|
106
|
+
/A <</S /URI /URI (https://casualos.com)>> % The action that the link should perform (Go to casualos.com)
|
|
107
|
+
>>
|
|
108
|
+
endobj
|
|
109
|
+
|
|
110
|
+
9999909 0 obj
|
|
111
|
+
(${str})
|
|
112
|
+
endobj
|
|
113
|
+
|
|
114
|
+
xref
|
|
115
|
+
0 11
|
|
116
|
+
0000000000 65535 f
|
|
117
|
+
0000000019 00000 n
|
|
118
|
+
0000000093 00000 n
|
|
119
|
+
0000000147 00000 n
|
|
120
|
+
0000000222 00000 n
|
|
121
|
+
0000000390 00000 n
|
|
122
|
+
0000001522 00000 n
|
|
123
|
+
0000001690 00000 n
|
|
124
|
+
0000002423 00000 n
|
|
125
|
+
0000002456 00000 n
|
|
126
|
+
0000002574 00000 n
|
|
127
|
+
|
|
128
|
+
trailer
|
|
129
|
+
<<
|
|
130
|
+
/Size 11
|
|
131
|
+
/Root 1 0 R
|
|
132
|
+
/Info 10 0 R
|
|
133
|
+
>>
|
|
134
|
+
|
|
135
|
+
startxref
|
|
136
|
+
2714
|
|
137
|
+
%%EOF
|
|
138
|
+
`;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Gets the Base64 data that was embedded in the given PDF document by embedBase64InPdf().
|
|
142
|
+
*/
|
|
143
|
+
export function getEmbeddedBase64FromPdf(pdf) {
|
|
144
|
+
const objStart = pdf.lastIndexOf('9999909 0 obj');
|
|
145
|
+
if (objStart < 0) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
const pdfFromObj = pdf.slice(objStart);
|
|
149
|
+
const objEnd = pdfFromObj.indexOf('endobj');
|
|
150
|
+
if (objEnd < 0) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
const obj = pdfFromObj.slice(0, objEnd);
|
|
154
|
+
const openParenthesis = obj.indexOf('(');
|
|
155
|
+
const closeParenthesis = obj.indexOf(')');
|
|
156
|
+
if (openParenthesis < 0 || closeParenthesis < 0) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
const base64 = obj.slice(openParenthesis + 1, closeParenthesis);
|
|
160
|
+
return base64;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Formats the given token and service (bundle ID) into a string that can be used as an auth token for records requests.
|
|
164
|
+
*/
|
|
165
|
+
export function formatAuthToken(token, service) {
|
|
166
|
+
return `${token}.${service}`;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Parses the given auth token into a token and service (bundle ID) pair.
|
|
170
|
+
* The returned token is the token that was returned from the auth API and the service is the bundle ID of the app that requested it.
|
|
171
|
+
*/
|
|
172
|
+
export function parseAuthToken(token) {
|
|
173
|
+
const dotIndex = token.indexOf('.');
|
|
174
|
+
if (dotIndex < 0) {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
const tokenWithoutService = token.slice(0, dotIndex);
|
|
178
|
+
const service = token.slice(dotIndex + 1);
|
|
179
|
+
return [tokenWithoutService, service];
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Constructs a Uint8Array from the given hexadecimal formatted string.
|
|
183
|
+
* @param hex The hexadecimal string.
|
|
184
|
+
*/
|
|
185
|
+
export function fromHexString(hex) {
|
|
186
|
+
const numBytes = hex.length / 2;
|
|
187
|
+
const a = new Uint8Array(numBytes);
|
|
188
|
+
hex = hex.toLowerCase();
|
|
189
|
+
for (let i = 0; i < a.length; i++) {
|
|
190
|
+
let char = i * 2;
|
|
191
|
+
let char1 = hex.charCodeAt(char);
|
|
192
|
+
let char2 = hex.charCodeAt(char + 1);
|
|
193
|
+
let val = fromHexCode(char1) * 16 + fromHexCode(char2);
|
|
194
|
+
a[i] = val;
|
|
195
|
+
}
|
|
196
|
+
return a;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Constructs a hexidecimal formatted string from the given array of bytes.
|
|
200
|
+
* @param bytes The bytes that should be hex formatted.
|
|
201
|
+
*/
|
|
202
|
+
export function toHexString(bytes) {
|
|
203
|
+
let str = '';
|
|
204
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
205
|
+
let byte = bytes[i];
|
|
206
|
+
let temp = byte.toString(16);
|
|
207
|
+
if (temp.length < 2) {
|
|
208
|
+
str += '0' + temp;
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
str += temp;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return str;
|
|
215
|
+
}
|
|
216
|
+
const _0CharCode = '0'.charCodeAt(0);
|
|
217
|
+
const _9CharCode = '9'.charCodeAt(0);
|
|
218
|
+
const aCharCode = 'a'.charCodeAt(0);
|
|
219
|
+
const fCharCode = 'f'.charCodeAt(0);
|
|
220
|
+
function fromHexCode(code) {
|
|
221
|
+
if (code >= _0CharCode && code <= _9CharCode) {
|
|
222
|
+
return code - _0CharCode;
|
|
223
|
+
}
|
|
224
|
+
else if (code >= aCharCode && code <= fCharCode) {
|
|
225
|
+
return code - aCharCode + 10;
|
|
226
|
+
}
|
|
227
|
+
throw new Error('Invalid hex code: ' + code);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Determines if the given value represents a promise.
|
|
231
|
+
* @param value The value to check.
|
|
232
|
+
*/
|
|
233
|
+
export function isPromise(value) {
|
|
234
|
+
return (typeof value === 'object' &&
|
|
235
|
+
value !== null &&
|
|
236
|
+
value instanceof Promise &&
|
|
237
|
+
typeof value.then === 'function' &&
|
|
238
|
+
typeof value.catch === 'function');
|
|
239
|
+
}
|
|
240
|
+
export const RUNTIME_PROMISE = Symbol('RUNTIME_PROMISE');
|
|
241
|
+
export function isRuntimePromise(value) {
|
|
242
|
+
return isPromise(value) && RUNTIME_PROMISE in value;
|
|
243
|
+
}
|
|
244
|
+
export function markAsRuntimePromise(promise) {
|
|
245
|
+
Object.defineProperty(promise, RUNTIME_PROMISE, {
|
|
246
|
+
value: true,
|
|
247
|
+
configurable: false,
|
|
248
|
+
enumerable: false,
|
|
249
|
+
writable: false,
|
|
250
|
+
});
|
|
251
|
+
return promise;
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=Utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["Utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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AI;QACd,KAAK,YAAY,OAAO;QACxB,OAAQ,KAAa,CAAC,IAAI,KAAK,UAAU;QACzC,OAAQ,KAAa,CAAC,KAAK,KAAK,UAAU,CAC7C,CAAC;AACN,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAMzD,MAAM,UAAU,gBAAgB,CAC5B,KAAc;IAEd,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,eAAe,IAAI,KAAK,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,oBAAoB,CAChC,OAAmB;IAEnB,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,eAAe,EAAE;QAC5C,KAAK,EAAE,IAAI;QACX,YAAY,EAAE,KAAK;QACnB,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,KAAK;KAClB,CAAC,CAAC;IAEH,OAAO,OAA4B,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './AuxResults';
|
|
2
|
+
export * from './AuxRuntime';
|
|
3
|
+
export * from './Transpiler';
|
|
4
|
+
export * from './AuxDevice';
|
|
5
|
+
export * from './AuxVersion';
|
|
6
|
+
export * from './RuntimeStateVersion';
|
|
7
|
+
export * from './AuxRealtimeEditModeProvider';
|
|
8
|
+
export * from './Utils';
|
|
9
|
+
export * from './CompiledBot';
|
|
10
|
+
export * from './RuntimeEvents';
|
|
11
|
+
export * from './RecordsEvents';
|
|
12
|
+
export * from './AuxPartitionRealtimeEditModeProvider';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
package/runtime/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './AuxResults';
|
|
2
|
+
export * from './AuxRuntime';
|
|
3
|
+
export * from './Transpiler';
|
|
4
|
+
export * from './AuxDevice';
|
|
5
|
+
export * from './AuxVersion';
|
|
6
|
+
export * from './RuntimeStateVersion';
|
|
7
|
+
export * from './AuxRealtimeEditModeProvider';
|
|
8
|
+
export * from './Utils';
|
|
9
|
+
export * from './CompiledBot';
|
|
10
|
+
export * from './RuntimeEvents';
|
|
11
|
+
export * from './RecordsEvents';
|
|
12
|
+
export * from './AuxPartitionRealtimeEditModeProvider';
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wCAAwC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BotTags, BotSpace, Bot, BotSignatures, RuntimeBot } from '@casual-simulation/aux-common/bots';
|
|
2
|
+
import { RuntimeBotInterface, RuntimeBotFactory, RealtimeEditMode } from '../RuntimeBot';
|
|
3
|
+
export declare class TestScriptBotFactory implements RuntimeBotFactory {
|
|
4
|
+
createRuntimeBot(bot: Bot): RuntimeBot;
|
|
5
|
+
destroyScriptBot(): RealtimeEditMode;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Creates a dummy script bot.
|
|
9
|
+
* That is, a bot which uses the given values directly and does not marshall changes back to a runtime.
|
|
10
|
+
* @param id The ID of the bot.
|
|
11
|
+
* @param tags The tags the bot should have.
|
|
12
|
+
* @param space The space of the bot.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createDummyRuntimeBot(id: string, tags?: BotTags, space?: BotSpace, signatures?: BotSignatures): RuntimeBot;
|
|
15
|
+
export declare const testScriptBotInterface: RuntimeBotInterface;
|
|
16
|
+
//# sourceMappingURL=TestScriptBotFactory.d.ts.map
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { TAG_MASK_SPACE_PRIORITIES, hasValue, } from '@casual-simulation/aux-common/bots';
|
|
2
|
+
import { createRuntimeBot, RealtimeEditMode, } from '../RuntimeBot';
|
|
3
|
+
import { createCompiledBot } from '../CompiledBot';
|
|
4
|
+
import { pickBy } from 'lodash';
|
|
5
|
+
import { applyTagEdit, isTagEdit } from '@casual-simulation/aux-common/bots';
|
|
6
|
+
export class TestScriptBotFactory {
|
|
7
|
+
createRuntimeBot(bot) {
|
|
8
|
+
return createDummyRuntimeBot(bot.id, bot.tags, bot.space);
|
|
9
|
+
}
|
|
10
|
+
destroyScriptBot() {
|
|
11
|
+
return RealtimeEditMode.Immediate;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Creates a dummy script bot.
|
|
16
|
+
* That is, a bot which uses the given values directly and does not marshall changes back to a runtime.
|
|
17
|
+
* @param id The ID of the bot.
|
|
18
|
+
* @param tags The tags the bot should have.
|
|
19
|
+
* @param space The space of the bot.
|
|
20
|
+
*/
|
|
21
|
+
export function createDummyRuntimeBot(id, tags = {}, space, signatures) {
|
|
22
|
+
let functions = pickBy(tags, (t) => typeof t === 'function');
|
|
23
|
+
const precalc = createCompiledBot(id, tags, undefined, space, functions, signatures);
|
|
24
|
+
return createRuntimeBot(precalc, testScriptBotInterface);
|
|
25
|
+
}
|
|
26
|
+
export const testScriptBotInterface = {
|
|
27
|
+
updateTag(bot, tag, newValue) {
|
|
28
|
+
if (isTagEdit(newValue)) {
|
|
29
|
+
bot.values[tag] = bot.tags[tag] = applyTagEdit(bot.tags[tag], newValue);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
if (hasValue(newValue)) {
|
|
33
|
+
bot.tags[tag] = newValue;
|
|
34
|
+
bot.values[tag] = newValue;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
delete bot.tags[tag];
|
|
38
|
+
delete bot.values[tag];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
mode: RealtimeEditMode.Immediate,
|
|
43
|
+
changedValue: newValue,
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
getValue(bot, tag) {
|
|
47
|
+
return bot.values[tag];
|
|
48
|
+
},
|
|
49
|
+
getRawValue(bot, tag) {
|
|
50
|
+
return bot.tags[tag];
|
|
51
|
+
},
|
|
52
|
+
getListener(bot, tag) {
|
|
53
|
+
return bot.listeners[tag];
|
|
54
|
+
},
|
|
55
|
+
getSignature(bot, signature) {
|
|
56
|
+
if (bot.signatures) {
|
|
57
|
+
return bot.signatures[signature];
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
notifyChange() { },
|
|
64
|
+
notifyActionEnqueued(action) { },
|
|
65
|
+
getTagMask(bot, tag) {
|
|
66
|
+
if (!bot.masks) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
for (let space of TAG_MASK_SPACE_PRIORITIES) {
|
|
70
|
+
if (!bot.masks[space]) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (tag in bot.masks[space]) {
|
|
74
|
+
return bot.masks[space][tag];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
},
|
|
79
|
+
updateTagMask(bot, tag, spaces, value) {
|
|
80
|
+
if (!bot.masks) {
|
|
81
|
+
bot.masks = {};
|
|
82
|
+
}
|
|
83
|
+
for (let space of spaces) {
|
|
84
|
+
if (!bot.masks[space]) {
|
|
85
|
+
bot.masks[space] = {};
|
|
86
|
+
}
|
|
87
|
+
if (isTagEdit(value)) {
|
|
88
|
+
bot.masks[space][tag] = applyTagEdit(bot.masks[space][tag], value);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
bot.masks[space][tag] = value;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
mode: RealtimeEditMode.Immediate,
|
|
96
|
+
changedValue: value,
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
getTagLink(bot, tag) {
|
|
100
|
+
return null;
|
|
101
|
+
},
|
|
102
|
+
currentVersion: {
|
|
103
|
+
localSites: {},
|
|
104
|
+
vector: {},
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
//# sourceMappingURL=TestScriptBotFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TestScriptBotFactory.js","sourceRoot":"","sources":["TestScriptBotFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAOH,yBAAyB,EAEzB,QAAQ,GAEX,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACH,gBAAgB,EAGhB,gBAAgB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAe,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAG7E,MAAM,OAAO,oBAAoB;IAC7B,gBAAgB,CAAC,GAAQ;QACrB,OAAO,qBAAqB,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;IAC9D,CAAC;IAED,gBAAgB;QACZ,OAAO,gBAAgB,CAAC,SAAS,CAAC;IACtC,CAAC;CACJ;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACjC,EAAU,EACV,OAAgB,EAAE,EAClB,KAAgB,EAChB,UAA0B;IAE1B,IAAI,SAAS,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,CAAM,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,UAAU,CAAC,CAAC;IAClE,MAAM,OAAO,GAAG,iBAAiB,CAC7B,EAAE,EACF,IAAI,EACJ,SAAS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