socket-function 0.12.14 → 0.12.16
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "socket-function",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.16",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"note1": "note on node-forge fork, see https://github.com/digitalbazaar/forge/issues/744 for details",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"node-forge": "https://github.com/sliftist/forge#name",
|
|
14
14
|
"pako": "^2.1.0",
|
|
15
15
|
"preact": "^10.10.6",
|
|
16
|
-
"typenode": "^5.4.
|
|
16
|
+
"typenode": "^5.4.1",
|
|
17
17
|
"ws": "^8.8.0"
|
|
18
18
|
},
|
|
19
19
|
"optionalDependencies": {
|
|
@@ -53,6 +53,7 @@ export interface SerializedModule {
|
|
|
53
53
|
// request => resolvedPath
|
|
54
54
|
[request: string]: string;
|
|
55
55
|
};
|
|
56
|
+
asyncRequests: { [request: string]: true };
|
|
56
57
|
// NOTE: IF !allowclient && !serveronly, it might just mean we didn't add allowclient
|
|
57
58
|
// to the module yet. BUT, if serveronly, then we know for sure we don't want it client.
|
|
58
59
|
// So the messages and behavior will be different.
|
|
@@ -201,6 +202,7 @@ class RequireControllerBase {
|
|
|
201
202
|
seqNum: module.requireControllerSeqNum,
|
|
202
203
|
size: module.size,
|
|
203
204
|
version: module.version,
|
|
205
|
+
asyncRequests: module.asyncRequires,
|
|
204
206
|
};
|
|
205
207
|
let moduleObj = modules[module.filename];
|
|
206
208
|
if (moduleObj.allowclient) {
|
|
@@ -218,11 +220,16 @@ class RequireControllerBase {
|
|
|
218
220
|
// - And now it increases the size by much less, as we ignore any subtree which are entirely
|
|
219
221
|
// not allowed on the client.
|
|
220
222
|
for (let request in module.requires) {
|
|
223
|
+
|
|
221
224
|
let requireResolvedPath = module.requires[request];
|
|
222
225
|
let requiredModule = require.cache[requireResolvedPath];
|
|
223
226
|
|
|
224
227
|
if (requiredModule) {
|
|
225
|
-
|
|
228
|
+
// Only include synchronous modules. BUT, DO include the requests, so when/if the request is made
|
|
229
|
+
// it can be resolved correctly.
|
|
230
|
+
if (!module.asyncRequires[request]) {
|
|
231
|
+
addModule(requiredModule);
|
|
232
|
+
}
|
|
226
233
|
moduleObj.requests[request] = requiredModule.filename;
|
|
227
234
|
} else {
|
|
228
235
|
moduleObj.requests[request] = "";
|
|
@@ -266,6 +273,7 @@ class RequireControllerBase {
|
|
|
266
273
|
path: "",
|
|
267
274
|
paths: [],
|
|
268
275
|
requires: {},
|
|
276
|
+
asyncRequires: {},
|
|
269
277
|
allowclient: true,
|
|
270
278
|
moduleContents: `console.warn(${JSON.stringify(error)})`,
|
|
271
279
|
};
|
package/require/require.js
CHANGED
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
// request => resolvedPath
|
|
75
75
|
[request: string]: string;
|
|
76
76
|
};
|
|
77
|
+
asyncRequests: { [request: string]: true };
|
|
77
78
|
// NOTE: IF !allowclient && !serveronly, it might just mean we didn't add allowclient
|
|
78
79
|
// to the module yet. BUT, if serveronly, then we know for sure we don't want it client.
|
|
79
80
|
// So the messages and behavior will be different.
|
|
@@ -255,6 +256,9 @@
|
|
|
255
256
|
if (typeof asyncIsFine !== "boolean") {
|
|
256
257
|
asyncIsFine = false;
|
|
257
258
|
}
|
|
259
|
+
if (request in serializedModule.asyncRequests) {
|
|
260
|
+
asyncIsFine = true;
|
|
261
|
+
}
|
|
258
262
|
if (request in builtInModuleExports) {
|
|
259
263
|
return builtInModuleExports[request];
|
|
260
264
|
}
|
|
@@ -292,8 +296,8 @@
|
|
|
292
296
|
"color: red", "color: unset",
|
|
293
297
|
"color: red", "color: unset",
|
|
294
298
|
);
|
|
299
|
+
debugger;
|
|
295
300
|
}
|
|
296
|
-
debugger;
|
|
297
301
|
return rootRequire(resolvedPath);
|
|
298
302
|
}
|
|
299
303
|
|
|
@@ -427,7 +431,10 @@
|
|
|
427
431
|
|
|
428
432
|
// Import children, as the children may be allowed clientside, and may have side-effects!
|
|
429
433
|
if (!source) {
|
|
430
|
-
let requests = Object.keys(serializedModule.requests)
|
|
434
|
+
let requests = Object.keys(serializedModule.requests)
|
|
435
|
+
.filter(x => x !== "NOTALLOWEDCLIENTSIDE")
|
|
436
|
+
.filter(x => !(x in serializedModule.asyncRequests))
|
|
437
|
+
;
|
|
431
438
|
source = requests.map(id => `require(${JSON.stringify(id)});\n`).join("");
|
|
432
439
|
}
|
|
433
440
|
|