@devvit/runtime-lite 0.11.0-next-2024-08-15-375bb2dbc.0 → 0.11.0-next-2024-08-15-52281a666.0
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@devvit/runtime-lite",
|
3
|
-
"version": "0.11.0-next-2024-08-15-
|
3
|
+
"version": "0.11.0-next-2024-08-15-52281a666.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-08-15-
|
47
|
-
"@devvit/protos": "0.11.0-next-2024-08-15-
|
48
|
-
"@devvit/repo-tools": "0.11.0-next-2024-08-15-
|
49
|
-
"@devvit/shared-types": "0.11.0-next-2024-08-15-
|
50
|
-
"@devvit/tsconfig": "0.11.0-next-2024-08-15-
|
46
|
+
"@devvit/eslint-config": "0.11.0-next-2024-08-15-52281a666.0",
|
47
|
+
"@devvit/protos": "0.11.0-next-2024-08-15-52281a666.0",
|
48
|
+
"@devvit/repo-tools": "0.11.0-next-2024-08-15-52281a666.0",
|
49
|
+
"@devvit/shared-types": "0.11.0-next-2024-08-15-52281a666.0",
|
50
|
+
"@devvit/tsconfig": "0.11.0-next-2024-08-15-52281a666.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",
|
@@ -81,5 +81,5 @@
|
|
81
81
|
}
|
82
82
|
},
|
83
83
|
"source": "./src/index.ts",
|
84
|
-
"gitHead": "
|
84
|
+
"gitHead": "31cdc89f75eedb562c20a1b2915f332c580870a5"
|
85
85
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"UnsandboxedRuntimeLite.d.ts","sourceRoot":"","sources":["../../src/runt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
@@ -16,7 +16,6 @@ import { inspect } from '@devvit/shared-types/inspect.js';
|
|
16
16
|
import { QueueConsole } from '../console/QueueConsole.js';
|
17
17
|
import { ActorResponse } from '../types/Commands.js';
|
18
18
|
import { getDependencyMetadata } from '../utils/metadata.js';
|
19
|
-
import { callBinary, extractMessageTypes } from '../utils/methodSerializers.js';
|
20
19
|
import { box } from './RuntimeLite.js';
|
21
20
|
export class UnsandboxedRuntimeLite {
|
22
21
|
/**
|
@@ -76,7 +75,15 @@ export class UnsandboxedRuntimeLite {
|
|
76
75
|
return circuitBreaker;
|
77
76
|
}
|
78
77
|
},
|
79
|
-
provides: () => {
|
78
|
+
provides: (definition) => {
|
79
|
+
// capture the (de)serializers for messages as they're added to the provide map
|
80
|
+
Object.values(definition.methods).forEach((method) => {
|
81
|
+
__classPrivateFieldGet(this, _UnsandboxedRuntimeLite_methodMsgMap, "f")[method.name] = {
|
82
|
+
req: method.requestType,
|
83
|
+
res: method.responseType,
|
84
|
+
};
|
85
|
+
});
|
86
|
+
},
|
80
87
|
}));
|
81
88
|
modules = { '@devvit/protos': protos, ...modules };
|
82
89
|
__classPrivateFieldSet(this, _UnsandboxedRuntimeLite_exceptionHandler, exceptionHandler, "f");
|
@@ -124,12 +131,17 @@ export class UnsandboxedRuntimeLite {
|
|
124
131
|
if (!module?.exports?.default)
|
125
132
|
throw Error('bundle missing default export');
|
126
133
|
__classPrivateFieldSet(this, _UnsandboxedRuntimeLite_actor, new module.exports.default(config), "f");
|
127
|
-
__classPrivateFieldSet(this, _UnsandboxedRuntimeLite_methodMsgMap, extractMessageTypes(protos, bundle.provides), "f");
|
128
134
|
});
|
129
135
|
}
|
130
136
|
async callBinary(method, args, meta) {
|
131
|
-
return __classPrivateFieldGet(this, _UnsandboxedRuntimeLite_instances, "m", _UnsandboxedRuntimeLite_runWithExceptionHandler).call(this, () => {
|
132
|
-
|
137
|
+
return __classPrivateFieldGet(this, _UnsandboxedRuntimeLite_instances, "m", _UnsandboxedRuntimeLite_runWithExceptionHandler).call(this, async () => {
|
138
|
+
const { req, res } = __classPrivateFieldGet(this, _UnsandboxedRuntimeLite_methodMsgMap, "f")[method];
|
139
|
+
const argsObj = req.decode(args);
|
140
|
+
const response = await this.call(method, argsObj, meta, false);
|
141
|
+
if (response.value) {
|
142
|
+
response.value = res.encode(res.fromJSON(response.value)).finish();
|
143
|
+
}
|
144
|
+
return response;
|
133
145
|
});
|
134
146
|
}
|
135
147
|
async call(method, args, meta, binary) {
|
@@ -1,25 +0,0 @@
|
|
1
|
-
import type { Definition, MessageType, Metadata, SerializableServiceDefinition } from '@devvit/protos';
|
2
|
-
import type { CallResponse, RuntimeLite } from '../runtime/RuntimeLite.js';
|
3
|
-
/**
|
4
|
-
* Cached method message types to manage serialization when dealing with binary messages (for mobile)
|
5
|
-
*/
|
6
|
-
export type MethodMessageMap = {
|
7
|
-
[key: string]: MethodMessages;
|
8
|
-
};
|
9
|
-
type MethodMessages = {
|
10
|
-
req: MessageType;
|
11
|
-
res: MessageType;
|
12
|
-
};
|
13
|
-
/**
|
14
|
-
* Cache the Request and Response message classes to use when handling binary messages
|
15
|
-
* @param provides From `LinkedBundle.provides`
|
16
|
-
*/
|
17
|
-
export declare function extractMessageTypes(protos: {
|
18
|
-
[proto: string]: Definition;
|
19
|
-
}, provides: SerializableServiceDefinition[]): MethodMessageMap;
|
20
|
-
/**
|
21
|
-
* Common function to decode a binary request and encode a response to binary
|
22
|
-
*/
|
23
|
-
export declare function callBinary({ req, res }: MethodMessages, call: RuntimeLite['call'], method: string, args: Uint8Array, meta: Metadata): Promise<CallResponse>;
|
24
|
-
export {};
|
25
|
-
//# sourceMappingURL=methodSerializers.d.ts.map
|
@@ -1 +0,0 @@
|
|
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,32 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Cache the Request and Response message classes to use when handling binary messages
|
3
|
-
* @param provides From `LinkedBundle.provides`
|
4
|
-
*/
|
5
|
-
export function extractMessageTypes(protos, provides) {
|
6
|
-
return provides.reduce((provideMap, provide) => {
|
7
|
-
return {
|
8
|
-
...provideMap,
|
9
|
-
...Object.entries(protos[provide.name + 'Definition'].methods).reduce((methods, [_, m]) => {
|
10
|
-
const method = m;
|
11
|
-
return {
|
12
|
-
...methods,
|
13
|
-
[method.name]: {
|
14
|
-
req: method.requestType,
|
15
|
-
res: method.responseType,
|
16
|
-
},
|
17
|
-
};
|
18
|
-
}, {}),
|
19
|
-
};
|
20
|
-
}, {});
|
21
|
-
}
|
22
|
-
/**
|
23
|
-
* Common function to decode a binary request and encode a response to binary
|
24
|
-
*/
|
25
|
-
export async function callBinary({ req, res }, call, method, args, meta) {
|
26
|
-
const argsObj = req.decode(args);
|
27
|
-
const response = await call(method, argsObj, meta, false);
|
28
|
-
if (response.value) {
|
29
|
-
response.value = res.encode(res.fromJSON(response.value)).finish();
|
30
|
-
}
|
31
|
-
return response;
|
32
|
-
}
|