socket-function 0.62.0 → 0.64.0
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 +1 -4
- package/require/RequireController.ts +13 -3
- package/src/misc.ts +7 -0
package/package.json
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "socket-function",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.64.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"note1": "note on node-forge fork, see https://github.com/digitalbazaar/forge/issues/744 for details",
|
|
7
6
|
"dependencies": {
|
|
8
7
|
"@types/pako": "^2.0.3",
|
|
9
8
|
"@types/ws": "^8.5.3",
|
|
10
9
|
"cbor-x": "^1.6.0",
|
|
11
10
|
"mobx": "^6.6.2",
|
|
12
|
-
"node-forge": "https://github.com/sliftist/forge#name",
|
|
13
11
|
"pako": "^2.1.0",
|
|
14
12
|
"preact": "10.24.3",
|
|
15
13
|
"typenode": "^5.7.0",
|
|
@@ -22,7 +20,6 @@
|
|
|
22
20
|
},
|
|
23
21
|
"devDependencies": {
|
|
24
22
|
"@types/cookie": "^0.5.1",
|
|
25
|
-
"@types/node-forge": "^1.3.1",
|
|
26
23
|
"debugbreak": "^0.6.5",
|
|
27
24
|
"pegjs": "^0.10.0",
|
|
28
25
|
"typedev": "^0.1.3"
|
|
@@ -110,8 +110,8 @@ const resolvedHTMLFile = isNodeTrue() && (
|
|
|
110
110
|
.replace(`<script src="./require.js"></script>`, `<script>${jsFile}</script>`)
|
|
111
111
|
);
|
|
112
112
|
|
|
113
|
-
let beforeEntryText: string[] = [];
|
|
114
|
-
function injectHTMLBeforeStartup(text: string) {
|
|
113
|
+
let beforeEntryText: (string | (() => Promise<string>))[] = [];
|
|
114
|
+
function injectHTMLBeforeStartup(text: string | (() => Promise<string>)) {
|
|
115
115
|
beforeEntryText.push(text);
|
|
116
116
|
}
|
|
117
117
|
|
|
@@ -133,7 +133,15 @@ class RequireControllerBase {
|
|
|
133
133
|
let { requireCalls } = config || {};
|
|
134
134
|
let result = resolvedHTMLFile;
|
|
135
135
|
if (beforeEntryText.length > 0) {
|
|
136
|
-
|
|
136
|
+
let resolved: string[] = [];
|
|
137
|
+
for (let text of beforeEntryText) {
|
|
138
|
+
if (typeof text === "string") {
|
|
139
|
+
resolved.push(text);
|
|
140
|
+
} else {
|
|
141
|
+
resolved.push(await text());
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
result = result.replace(BEFORE_ENTRY_TEMPLATE, resolved.join("\n"));
|
|
137
145
|
}
|
|
138
146
|
if (requireCalls) {
|
|
139
147
|
async function requireAll(calls: string[]) {
|
|
@@ -150,6 +158,8 @@ class RequireControllerBase {
|
|
|
150
158
|
}
|
|
151
159
|
}
|
|
152
160
|
result = result.replace(ENTRY_TEMPLATE, `<script>\n(${requireAll.toString()})(${JSON.stringify(requireCalls)});\n</script>`);
|
|
161
|
+
} else {
|
|
162
|
+
result = result.replace(ENTRY_TEMPLATE, "");
|
|
153
163
|
}
|
|
154
164
|
return setHTTPResultHeaders(Buffer.from(result), { "Content-Type": "text/html" });
|
|
155
165
|
}
|
package/src/misc.ts
CHANGED
|
@@ -377,6 +377,13 @@ export function compare(lhs: unknown, rhs: unknown): number {
|
|
|
377
377
|
if (lhs as any < (rhs as any)) return -1;
|
|
378
378
|
return 1;
|
|
379
379
|
}
|
|
380
|
+
export function compareArray(lhs: unknown[], rhs: unknown[]): number {
|
|
381
|
+
for (let i = 0; i < Math.min(lhs.length, rhs.length); i++) {
|
|
382
|
+
let comparison = compare(lhs[i], rhs[i]);
|
|
383
|
+
if (comparison !== 0) return comparison;
|
|
384
|
+
}
|
|
385
|
+
return lhs.length - rhs.length;
|
|
386
|
+
}
|
|
380
387
|
|
|
381
388
|
export function insertIntoSortedList<T>(list: T[], map: (val: T) => string | number, element: T) {
|
|
382
389
|
let searchValue = map(element);
|