@devvit/runtime-lite 0.11.0-next-2024-07-29-e3757fb74.0 → 0.11.0-next-2024-07-29-74c4bb837.0
Sign up to get free protection for your applications and to get access to all the features.
- package/browser-lite.worker.js +15 -17
- package/browser-lite.worker.js.map +3 -3
- package/mobile-lite.js +2 -2
- package/package.json +9 -9
- package/runtime/SandboxedRuntimeLite.d.ts +2 -2
- package/runtime/SandboxedRuntimeLite.d.ts.map +1 -1
- package/runtime/SandboxedRuntimeLite.js +8 -15
- package/runtime/UnsandboxedRuntimeLite.d.ts.map +1 -1
- package/runtime/UnsandboxedRuntimeLite.js +3 -3
- package/utils/methodSerializers.d.ts +4 -2
- package/utils/methodSerializers.d.ts.map +1 -1
- package/utils/methodSerializers.js +2 -4
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@devvit/runtime-lite",
|
3
|
-
"version": "0.11.0-next-2024-07-29-
|
3
|
+
"version": "0.11.0-next-2024-07-29-74c4bb837.0",
|
4
4
|
"license": "BSD-3-Clause",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -43,11 +43,11 @@
|
|
43
43
|
},
|
44
44
|
"devDependencies": {
|
45
45
|
"@ampproject/filesize": "4.3.0",
|
46
|
-
"@devvit/eslint-config": "0.11.0-next-2024-07-29-
|
47
|
-
"@devvit/protos": "0.11.0-next-2024-07-29-
|
48
|
-
"@devvit/repo-tools": "0.11.0-next-2024-07-29-
|
49
|
-
"@devvit/shared-types": "0.11.0-next-2024-07-29-
|
50
|
-
"@devvit/tsconfig": "0.11.0-next-2024-07-29-
|
46
|
+
"@devvit/eslint-config": "0.11.0-next-2024-07-29-74c4bb837.0",
|
47
|
+
"@devvit/protos": "0.11.0-next-2024-07-29-74c4bb837.0",
|
48
|
+
"@devvit/repo-tools": "0.11.0-next-2024-07-29-74c4bb837.0",
|
49
|
+
"@devvit/shared-types": "0.11.0-next-2024-07-29-74c4bb837.0",
|
50
|
+
"@devvit/tsconfig": "0.11.0-next-2024-07-29-74c4bb837.0",
|
51
51
|
"@jitl/quickjs-singlefile-browser-release-sync": "0.29.0",
|
52
52
|
"base64-js": "1.5.1",
|
53
53
|
"chokidar-cli": "3.0.0",
|
@@ -64,8 +64,8 @@
|
|
64
64
|
},
|
65
65
|
"filesize": {
|
66
66
|
"dist/browser-lite.worker.js": {
|
67
|
-
"gzip": "
|
68
|
-
"none": "
|
67
|
+
"gzip": "890 KB",
|
68
|
+
"none": "3970 KB"
|
69
69
|
},
|
70
70
|
"dist/assets/corejs.js": {
|
71
71
|
"gzip": "33 KB",
|
@@ -81,5 +81,5 @@
|
|
81
81
|
}
|
82
82
|
},
|
83
83
|
"source": "./src/index.ts",
|
84
|
-
"gitHead": "
|
84
|
+
"gitHead": "68efa1e336dee06ac482d1932fbb0c97c34ce058"
|
85
85
|
}
|
@@ -16,8 +16,8 @@ export declare class SandboxedRuntimeLite implements RuntimeLite {
|
|
16
16
|
setPluginList(plugins: string[]): void;
|
17
17
|
setLocalMetadata(meta: Metadata): void;
|
18
18
|
loadBundle(bundle: LinkedBundle): void;
|
19
|
-
|
20
|
-
|
19
|
+
call(method: string, args: unknown, meta: Metadata): Promise<CallResponse>;
|
20
|
+
callBinary(): never;
|
21
21
|
onPluginResponse(id: number, result: CallResponse): void;
|
22
22
|
quit(): void;
|
23
23
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SandboxedRuntimeLite.d.ts","sourceRoot":"","sources":["../../src/runtime/SandboxedRuntimeLite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;
|
1
|
+
{"version":3,"file":"SandboxedRuntimeLite.d.ts","sourceRoot":"","sources":["../../src/runtime/SandboxedRuntimeLite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAqB7D,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAK7E,qBAAa,oBAAqB,YAAW,WAAW;;IAatD;;;;OAIG;gBACS,OAAO,GAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;KAAO;IAOlD,gBAAgB,IAAI,IAAI;IAIxB,YAAY,IAAI,SAAS;IAInB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAsC3B,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAKtC,gBAAgB,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;IAItC,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAsDhC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC;IAmEhF,UAAU,IAAI,KAAK;IAInB,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI;IAmBxD,IAAI,IAAI,IAAI;CA0Ib"}
|
@@ -9,7 +9,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
11
11
|
};
|
12
|
-
var _SandboxedRuntimeLite_instances, _SandboxedRuntimeLite_runtime, _SandboxedRuntimeLite_vm, _SandboxedRuntimeLite_importObjectPtr, _SandboxedRuntimeLite_actor, _SandboxedRuntimeLite_aborted, _SandboxedRuntimeLite_console, _SandboxedRuntimeLite_modules, _SandboxedRuntimeLite_pluginCallId, _SandboxedRuntimeLite_pluginReturnHandlers, _SandboxedRuntimeLite_localMetadata, _SandboxedRuntimeLite_dependencyMetadata,
|
12
|
+
var _SandboxedRuntimeLite_instances, _SandboxedRuntimeLite_runtime, _SandboxedRuntimeLite_vm, _SandboxedRuntimeLite_importObjectPtr, _SandboxedRuntimeLite_actor, _SandboxedRuntimeLite_aborted, _SandboxedRuntimeLite_console, _SandboxedRuntimeLite_modules, _SandboxedRuntimeLite_pluginCallId, _SandboxedRuntimeLite_pluginReturnHandlers, _SandboxedRuntimeLite_localMetadata, _SandboxedRuntimeLite_dependencyMetadata, _SandboxedRuntimeLite_importObject, _SandboxedRuntimeLite_evalGlobal, _SandboxedRuntimeLite_eval, _SandboxedRuntimeLite_initConsole, _SandboxedRuntimeLite_initImporter, _SandboxedRuntimeLite_initCircuitBreaker, _SandboxedRuntimeLite_initPluginProxy, _SandboxedRuntimeLite_initRequire, _SandboxedRuntimeLite_initFetch, _SandboxedRuntimeLite_logErr;
|
13
|
+
import { CircuitBreak, isCircuitBreaker } from '@devvit/shared-types/CircuitBreaker.js';
|
13
14
|
import { inspect } from '@devvit/shared-types/inspect.js';
|
14
15
|
import releaseSync from '@jitl/quickjs-singlefile-browser-release-sync';
|
15
16
|
import { newQuickJSWASMModuleFromVariant, Scope } from 'quickjs-emscripten-core';
|
@@ -17,11 +18,9 @@ import corejs from '../../dist/assets/corejs.js?raw';
|
|
17
18
|
import intlPolyfill from '../../dist/assets/intl-polyfill.js?raw';
|
18
19
|
import protos from '../../dist/assets/protos.js?raw';
|
19
20
|
import { QueueConsole } from '../console/QueueConsole.js';
|
20
|
-
import { CircuitBreak, isCircuitBreaker } from '@devvit/shared-types/CircuitBreaker.js';
|
21
21
|
import { ActorResponse } from '../types/Commands.js';
|
22
|
-
import { box } from './RuntimeLite.js';
|
23
22
|
import { getDependencyMetadata } from '../utils/metadata.js';
|
24
|
-
import {
|
23
|
+
import { box } from './RuntimeLite.js';
|
25
24
|
const wasmModule = newQuickJSWASMModuleFromVariant(releaseSync);
|
26
25
|
export class SandboxedRuntimeLite {
|
27
26
|
/**
|
@@ -42,7 +41,6 @@ export class SandboxedRuntimeLite {
|
|
42
41
|
_SandboxedRuntimeLite_pluginReturnHandlers.set(this, {});
|
43
42
|
_SandboxedRuntimeLite_localMetadata.set(this, {});
|
44
43
|
_SandboxedRuntimeLite_dependencyMetadata.set(this, {});
|
45
|
-
_SandboxedRuntimeLite_methodMsgMap.set(this, {});
|
46
44
|
_SandboxedRuntimeLite_importObject.set(this, (vm, obj) => {
|
47
45
|
return vm
|
48
46
|
.newString(typeof obj === 'string' ? obj : JSON.stringify(obj))
|
@@ -181,7 +179,6 @@ export class SandboxedRuntimeLite {
|
|
181
179
|
}
|
182
180
|
loadBundle(bundle) {
|
183
181
|
__classPrivateFieldSet(this, _SandboxedRuntimeLite_dependencyMetadata, getDependencyMetadata(bundle), "f");
|
184
|
-
__classPrivateFieldSet(this, _SandboxedRuntimeLite_methodMsgMap, extractMessageTypes(bundle.provides), "f");
|
185
182
|
__classPrivateFieldGet(this, _SandboxedRuntimeLite_console, "f").logs = [];
|
186
183
|
const vm = __classPrivateFieldGet(this, _SandboxedRuntimeLite_vm, "f");
|
187
184
|
// to-do: type.
|
@@ -227,14 +224,7 @@ export class SandboxedRuntimeLite {
|
|
227
224
|
throw err;
|
228
225
|
}
|
229
226
|
}
|
230
|
-
async
|
231
|
-
return await callBinary(__classPrivateFieldGet(this, _SandboxedRuntimeLite_methodMsgMap, "f")[method], this.call.bind(this), method, args, meta);
|
232
|
-
}
|
233
|
-
async call(method, args, meta, binary) {
|
234
|
-
if (binary) {
|
235
|
-
// temporary solution until the binary flag can be dropped
|
236
|
-
return await this.callBinary(method, args, meta);
|
237
|
-
}
|
227
|
+
async call(method, args, meta) {
|
238
228
|
return Scope.withScopeAsync(async (scope) => {
|
239
229
|
const vm = scope.manage(__classPrivateFieldGet(this, _SandboxedRuntimeLite_runtime, "f").newContext());
|
240
230
|
const actor = __classPrivateFieldGet(this, _SandboxedRuntimeLite_actor, "f");
|
@@ -300,6 +290,9 @@ export class SandboxedRuntimeLite {
|
|
300
290
|
return { error: undefined, success: true, value: response };
|
301
291
|
});
|
302
292
|
}
|
293
|
+
callBinary() {
|
294
|
+
throw new Error('binary calls are unsupported');
|
295
|
+
}
|
303
296
|
onPluginResponse(id, result) {
|
304
297
|
const handler = __classPrivateFieldGet(this, _SandboxedRuntimeLite_pluginReturnHandlers, "f")[id];
|
305
298
|
if (handler && handler.alive) {
|
@@ -328,7 +321,7 @@ export class SandboxedRuntimeLite {
|
|
328
321
|
globalThis.close();
|
329
322
|
}
|
330
323
|
}
|
331
|
-
_SandboxedRuntimeLite_runtime = new WeakMap(), _SandboxedRuntimeLite_vm = new WeakMap(), _SandboxedRuntimeLite_importObjectPtr = new WeakMap(), _SandboxedRuntimeLite_actor = new WeakMap(), _SandboxedRuntimeLite_aborted = new WeakMap(), _SandboxedRuntimeLite_console = new WeakMap(), _SandboxedRuntimeLite_modules = new WeakMap(), _SandboxedRuntimeLite_pluginCallId = new WeakMap(), _SandboxedRuntimeLite_pluginReturnHandlers = new WeakMap(), _SandboxedRuntimeLite_localMetadata = new WeakMap(), _SandboxedRuntimeLite_dependencyMetadata = new WeakMap(),
|
324
|
+
_SandboxedRuntimeLite_runtime = new WeakMap(), _SandboxedRuntimeLite_vm = new WeakMap(), _SandboxedRuntimeLite_importObjectPtr = new WeakMap(), _SandboxedRuntimeLite_actor = new WeakMap(), _SandboxedRuntimeLite_aborted = new WeakMap(), _SandboxedRuntimeLite_console = new WeakMap(), _SandboxedRuntimeLite_modules = new WeakMap(), _SandboxedRuntimeLite_pluginCallId = new WeakMap(), _SandboxedRuntimeLite_pluginReturnHandlers = new WeakMap(), _SandboxedRuntimeLite_localMetadata = new WeakMap(), _SandboxedRuntimeLite_dependencyMetadata = new WeakMap(), _SandboxedRuntimeLite_importObject = new WeakMap(), _SandboxedRuntimeLite_initConsole = new WeakMap(), _SandboxedRuntimeLite_initImporter = new WeakMap(), _SandboxedRuntimeLite_initCircuitBreaker = new WeakMap(), _SandboxedRuntimeLite_initPluginProxy = new WeakMap(), _SandboxedRuntimeLite_initRequire = new WeakMap(), _SandboxedRuntimeLite_initFetch = new WeakMap(), _SandboxedRuntimeLite_instances = new WeakSet(), _SandboxedRuntimeLite_evalGlobal = function _SandboxedRuntimeLite_evalGlobal(vm, ...args) {
|
332
325
|
for (const code of args) {
|
333
326
|
vm.unwrapResult(vm.evalCode(code, undefined, { type: 'global' })).dispose();
|
334
327
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"UnsandboxedRuntimeLite.d.ts","sourceRoot":"","sources":["../../src/runtime/UnsandboxedRuntimeLite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;
|
1
|
+
{"version":3,"file":"UnsandboxedRuntimeLite.d.ts","sourceRoot":"","sources":["../../src/runtime/UnsandboxedRuntimeLite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAazE,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAe7E,qBAAa,sBAAuB,YAAW,WAAW;;IAUxD;;;OAGG;gBACS,OAAO,GAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAA;KAAO;IAenD,gBAAgB,IAAI,IAAI;IAIxB,YAAY,IAAI,SAAS;IAInB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAItC,gBAAgB,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;IAItC,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IA2BhC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC;IAInF,IAAI,CACR,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,GAAG,UAAU,EAC1B,IAAI,EAAE,QAAQ,EACd,MAAM,CAAC,EAAE,OAAO,GACf,OAAO,CAAC,YAAY,CAAC;IA6BxB,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI;IAUxD,IAAI,IAAI,IAAI;CA2Eb"}
|
@@ -11,13 +11,13 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
11
11
|
};
|
12
12
|
var _UnsandboxedRuntimeLite_instances, _UnsandboxedRuntimeLite_actor, _UnsandboxedRuntimeLite_aborted, _UnsandboxedRuntimeLite_methodMsgMap, _UnsandboxedRuntimeLite_plugins, _UnsandboxedRuntimeLite_pluginCallId, _UnsandboxedRuntimeLite_pluginReturnHandlers, _UnsandboxedRuntimeLite_localMetadata, _UnsandboxedRuntimeLite_dependencyMetadata, _UnsandboxedRuntimeLite_config, _UnsandboxedRuntimeLite_logErr, _UnsandboxedRuntimeLite_setupGlobalDevvit;
|
13
13
|
import * as protos from '@devvit/protos';
|
14
|
+
import { CircuitBreak, isCircuitBreaker } from '@devvit/shared-types/CircuitBreaker.js';
|
14
15
|
import { inspect } from '@devvit/shared-types/inspect.js';
|
15
16
|
import { QueueConsole } from '../console/QueueConsole.js';
|
16
|
-
import { CircuitBreak, isCircuitBreaker } from '@devvit/shared-types/CircuitBreaker.js';
|
17
17
|
import { ActorResponse } from '../types/Commands.js';
|
18
|
-
import { box } from './RuntimeLite.js';
|
19
18
|
import { getDependencyMetadata } from '../utils/metadata.js';
|
20
19
|
import { callBinary, extractMessageTypes } from '../utils/methodSerializers.js';
|
20
|
+
import { box } from './RuntimeLite.js';
|
21
21
|
export class UnsandboxedRuntimeLite {
|
22
22
|
/**
|
23
23
|
* @arg modules Environment dependencies available via `require(id)` to
|
@@ -122,7 +122,7 @@ export class UnsandboxedRuntimeLite {
|
|
122
122
|
if (!module?.exports?.default)
|
123
123
|
throw Error('bundle missing default export');
|
124
124
|
__classPrivateFieldSet(this, _UnsandboxedRuntimeLite_actor, new module.exports.default(config), "f");
|
125
|
-
__classPrivateFieldSet(this, _UnsandboxedRuntimeLite_methodMsgMap, extractMessageTypes(bundle.provides), "f");
|
125
|
+
__classPrivateFieldSet(this, _UnsandboxedRuntimeLite_methodMsgMap, extractMessageTypes(protos, bundle.provides), "f");
|
126
126
|
}
|
127
127
|
catch (err) {
|
128
128
|
__classPrivateFieldGet(this, _UnsandboxedRuntimeLite_instances, "m", _UnsandboxedRuntimeLite_logErr).call(this, err);
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { MessageType, Metadata, SerializableServiceDefinition } from '@devvit/protos';
|
1
|
+
import type { Definition, MessageType, Metadata, SerializableServiceDefinition } from '@devvit/protos';
|
2
2
|
import type { CallResponse, RuntimeLite } from '../runtime/RuntimeLite.js';
|
3
3
|
/**
|
4
4
|
* Cached method message types to manage serialization when dealing with binary messages (for mobile)
|
@@ -14,7 +14,9 @@ type MethodMessages = {
|
|
14
14
|
* Cache the Request and Response message classes to use when handling binary messages
|
15
15
|
* @param provides From `LinkedBundle.provides`
|
16
16
|
*/
|
17
|
-
export declare function extractMessageTypes(
|
17
|
+
export declare function extractMessageTypes(protos: {
|
18
|
+
[proto: string]: Definition;
|
19
|
+
}, provides: SerializableServiceDefinition[]): MethodMessageMap;
|
18
20
|
/**
|
19
21
|
* Common function to decode a binary request and encode a response to binary
|
20
22
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"methodSerializers.d.ts","sourceRoot":"","sources":["../../src/utils/methodSerializers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
1
|
+
{"version":3,"file":"methodSerializers.d.ts","sourceRoot":"","sources":["../../src/utils/methodSerializers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,QAAQ,EAER,6BAA6B,EAC9B,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE3E;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAA;CAAE,CAAC;AACjE,KAAK,cAAc,GAAG;IAAE,GAAG,EAAE,WAAW,CAAC;IAAC,GAAG,EAAE,WAAW,CAAA;CAAE,CAAC;AAE7D;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,EACvC,QAAQ,EAAE,6BAA6B,EAAE,GACxC,gBAAgB,CAmBlB;AAED;;GAEG;AACH,wBAAsB,UAAU,CAC9B,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,cAAc,EAC5B,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,EACzB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,YAAY,CAAC,CAOvB"}
|
@@ -1,14 +1,12 @@
|
|
1
|
-
import * as protos from '@devvit/protos';
|
2
1
|
/**
|
3
2
|
* Cache the Request and Response message classes to use when handling binary messages
|
4
3
|
* @param provides From `LinkedBundle.provides`
|
5
4
|
*/
|
6
|
-
export function extractMessageTypes(provides) {
|
5
|
+
export function extractMessageTypes(protos, provides) {
|
7
6
|
return provides.reduce((provideMap, provide) => {
|
8
|
-
const protoDefLookup = protos;
|
9
7
|
return {
|
10
8
|
...provideMap,
|
11
|
-
...Object.entries(
|
9
|
+
...Object.entries(protos[provide.name + 'Definition'].methods).reduce((methods, [_, m]) => {
|
12
10
|
const method = m;
|
13
11
|
return {
|
14
12
|
...methods,
|