querysub 0.436.0 → 0.438.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/.eslintrc.js +50 -50
- package/bin/deploy.js +0 -0
- package/bin/function.js +0 -0
- package/bin/server.js +0 -0
- package/costsBenefits.txt +115 -115
- package/deploy.ts +2 -2
- package/package.json +1 -1
- package/spec.txt +1192 -1192
- package/src/-a-archives/archives.ts +202 -202
- package/src/-a-archives/archivesBackBlaze.ts +0 -1
- package/src/-a-archives/archivesDisk.ts +454 -454
- package/src/-a-auth/certs.ts +540 -540
- package/src/-a-auth/node-forge-ed25519.d.ts +16 -16
- package/src/-b-authorities/dnsAuthority.ts +138 -138
- package/src/-c-identity/IdentityController.ts +258 -258
- package/src/-d-trust/NetworkTrust2.ts +180 -180
- package/src/-e-certs/EdgeCertController.ts +252 -252
- package/src/-e-certs/certAuthority.ts +201 -201
- package/src/-f-node-discovery/NodeDiscovery.ts +640 -640
- package/src/-g-core-values/NodeCapabilities.ts +200 -200
- package/src/-h-path-value-serialize/stringSerializer.ts +175 -175
- package/src/0-path-value-core/PathValueCommitter.ts +468 -468
- package/src/0-path-value-core/PathValueController.ts +0 -2
- package/src/2-proxy/PathValueProxyWatcher.ts +2542 -2542
- package/src/2-proxy/TransactionDelayer.ts +94 -94
- package/src/2-proxy/pathDatabaseProxyBase.ts +36 -36
- package/src/2-proxy/pathValueProxy.ts +159 -159
- package/src/3-path-functions/PathFunctionRunnerMain.ts +87 -87
- package/src/3-path-functions/pathFunctionLoader.ts +516 -516
- package/src/3-path-functions/tests/rejectTest.ts +76 -76
- package/src/4-deploy/deployCheck.ts +6 -6
- package/src/4-dom/css.tsx +29 -29
- package/src/4-dom/cssTypes.d.ts +211 -211
- package/src/4-dom/qreact.tsx +2799 -2799
- package/src/4-dom/qreactTest.tsx +410 -410
- package/src/4-querysub/permissions.ts +335 -335
- package/src/4-querysub/querysubPrediction.ts +483 -483
- package/src/5-diagnostics/qreactDebug.tsx +377 -346
- package/src/TestController.ts +34 -34
- package/src/bits.ts +104 -104
- package/src/buffers.ts +69 -69
- package/src/diagnostics/ActionsHistory.ts +57 -57
- package/src/diagnostics/listenOnDebugger.ts +71 -71
- package/src/diagnostics/periodic.ts +111 -111
- package/src/diagnostics/trackResources.ts +91 -91
- package/src/diagnostics/watchdog.ts +120 -120
- package/src/errors.ts +133 -133
- package/src/forceProduction.ts +2 -2
- package/src/fs.ts +80 -80
- package/src/functional/diff.ts +857 -857
- package/src/functional/promiseCache.ts +78 -78
- package/src/functional/random.ts +8 -8
- package/src/functional/stats.ts +60 -60
- package/src/heapDumps.ts +665 -665
- package/src/https.ts +1 -1
- package/src/library-components/AspectSizedComponent.tsx +87 -87
- package/src/library-components/ButtonSelector.tsx +64 -64
- package/src/library-components/DropdownCustom.tsx +150 -150
- package/src/library-components/DropdownSelector.tsx +31 -31
- package/src/library-components/InlinePopup.tsx +66 -66
- package/src/misc/color.ts +29 -29
- package/src/misc/hash.ts +83 -83
- package/src/misc/ipPong.js +13 -13
- package/src/misc/networking.ts +1 -1
- package/src/misc/random.ts +44 -44
- package/src/misc.ts +196 -196
- package/src/path.ts +255 -255
- package/src/persistentLocalStore.ts +41 -41
- package/src/promise.ts +14 -14
- package/src/storage/fileSystemPointer.ts +71 -71
- package/src/test/heapProcess.ts +35 -35
- package/src/zip.ts +15 -15
- package/tsconfig.json +26 -26
- package/yarnSpec.txt +56 -56
package/src/misc.ts
CHANGED
|
@@ -1,197 +1,197 @@
|
|
|
1
|
-
import { canHaveChildren } from "socket-function/src/types";
|
|
2
|
-
|
|
3
|
-
// TIMING: About 20MB/s
|
|
4
|
-
export function createRandomText(count: number): string {
|
|
5
|
-
let text = "";
|
|
6
|
-
let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
7
|
-
for (let i = 0; i < count; i++) {
|
|
8
|
-
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
|
9
|
-
}
|
|
10
|
-
return text;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function isEmpty(obj: unknown): boolean {
|
|
14
|
-
if (!obj) return false;
|
|
15
|
-
if (typeof obj !== "object") return false;
|
|
16
|
-
return Object.keys(obj).length === 0;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function isDefined<T>(value: T | undefined | null): value is T {
|
|
20
|
-
return value !== undefined && value !== null;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function ObjectAssign<T extends { [key: string]: unknown }>(obj: T, values: Partial<T>) {
|
|
24
|
-
return Object.assign(obj, values);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function ellipsis(text: string, max: number) {
|
|
28
|
-
if (text.length <= max) return text;
|
|
29
|
-
return text.slice(0, max - 3) + "...";
|
|
30
|
-
}
|
|
31
|
-
export function ellipsisMiddle(text: string, max: number) {
|
|
32
|
-
if (text.length <= max) return text;
|
|
33
|
-
let half = Math.floor((max - 3) / 2);
|
|
34
|
-
return text.slice(0, half) + "..." + text.slice(-half);
|
|
35
|
-
}
|
|
36
|
-
export function ellipsisStart(text: string, max: number) {
|
|
37
|
-
if (text.length <= max) return text;
|
|
38
|
-
return "..." + text.slice(-max + 3);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function joinVNodes(vNodes: preact.ComponentChild[], delimitter: preact.ComponentChild) {
|
|
42
|
-
let output: preact.ComponentChild[] = [];
|
|
43
|
-
for (let i = 0; i < vNodes.length; i++) {
|
|
44
|
-
if (i !== 0) {
|
|
45
|
-
output.push(delimitter);
|
|
46
|
-
}
|
|
47
|
-
output.push(vNodes[i]);
|
|
48
|
-
}
|
|
49
|
-
return output;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function clamp(value: number, min: number, max: number) {
|
|
53
|
-
return Math.max(min, Math.min(max, value));
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function unique<T>(array: T[]): T[] {
|
|
57
|
-
return Array.from(new Set(array));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function mostCommon<T>(array: T[]): T | undefined {
|
|
61
|
-
let counts = new Map<T, number>();
|
|
62
|
-
for (let item of array) {
|
|
63
|
-
counts.set(item, (counts.get(item) || 0) + 1);
|
|
64
|
-
}
|
|
65
|
-
return Array.from(counts.entries()).sort((a, b) => b[1] - a[1])[0]?.[0];
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
export function parsePath(path: string): { dir: string; name: string } {
|
|
70
|
-
path = path.replaceAll("\\", "/");
|
|
71
|
-
let lastSlash = path.lastIndexOf("/");
|
|
72
|
-
if (lastSlash === -1) return { dir: "", name: path };
|
|
73
|
-
return { dir: path.slice(0, lastSlash + 1), name: path.slice(lastSlash + 1) };
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Loses spaces in keys and values
|
|
77
|
-
export function toFileNameKVP(kvp: { [key: string]: string }): string {
|
|
78
|
-
function s(v: string) {
|
|
79
|
-
return v.replaceAll(" ", "_");
|
|
80
|
-
}
|
|
81
|
-
return " " + Object.entries(kvp).map(([key, value]) => `${s(key)}=${s(value)}`).join(" ") + " ";
|
|
82
|
-
}
|
|
83
|
-
export function parseFileNameKVP(fileName: string): { [key: string]: string } {
|
|
84
|
-
let parts = fileName.trim().split(" ");
|
|
85
|
-
let obj: { [key: string]: string } = {};
|
|
86
|
-
for (let part of parts) {
|
|
87
|
-
let [key, value] = part.split("=");
|
|
88
|
-
obj[key] = value || key;
|
|
89
|
-
}
|
|
90
|
-
return obj;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/** Copied object until maxFields is reached. */
|
|
94
|
-
export function partialCopyObject(data: unknown, maxFields: number = 500): unknown {
|
|
95
|
-
try {
|
|
96
|
-
let fieldCount = 0;
|
|
97
|
-
const seen = new WeakSet();
|
|
98
|
-
|
|
99
|
-
function copy(value: unknown): unknown {
|
|
100
|
-
// Handle primitives
|
|
101
|
-
if (!canHaveChildren(value)) {
|
|
102
|
-
return value;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// Check for circular references
|
|
106
|
-
if (seen.has(value as object)) {
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
seen.add(value as object);
|
|
110
|
-
|
|
111
|
-
// Check if we've hit the field limit
|
|
112
|
-
if (fieldCount >= maxFields) {
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (Array.isArray(value)) {
|
|
117
|
-
const result: unknown[] = [];
|
|
118
|
-
for (const item of value) {
|
|
119
|
-
fieldCount++;
|
|
120
|
-
if (fieldCount >= maxFields) break;
|
|
121
|
-
result.push(copy(item));
|
|
122
|
-
}
|
|
123
|
-
seen.delete(value);
|
|
124
|
-
return result;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// Handle plain objects
|
|
128
|
-
const result: Record<string, unknown> = {};
|
|
129
|
-
|
|
130
|
-
// Special case for Error objects - include stack and message
|
|
131
|
-
if (value instanceof Error) {
|
|
132
|
-
fieldCount++;
|
|
133
|
-
if (fieldCount < maxFields) {
|
|
134
|
-
result.message = value.message;
|
|
135
|
-
}
|
|
136
|
-
fieldCount++;
|
|
137
|
-
if (fieldCount < maxFields) {
|
|
138
|
-
result.stack = value.stack;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
for (const key of Object.keys(value as object)) {
|
|
143
|
-
fieldCount++;
|
|
144
|
-
if (fieldCount >= maxFields) break;
|
|
145
|
-
result[key] = copy((value as Record<string, unknown>)[key]);
|
|
146
|
-
}
|
|
147
|
-
seen.delete(value);
|
|
148
|
-
return result;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return copy(data) as any;
|
|
152
|
-
} catch (e: any) {
|
|
153
|
-
return { errorCopying: e.messsage } as any;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export function sum(array: number[]): number {
|
|
158
|
-
return array.reduce((a, b) => a + b, 0);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export function matchFilter(filter: { value: string }, value: string) {
|
|
162
|
-
let filterValue = filter.value.toLowerCase().trim();
|
|
163
|
-
if (!filterValue) return true;
|
|
164
|
-
value = value.toLowerCase().trim();
|
|
165
|
-
return filterValue.split("|").some(part =>
|
|
166
|
-
part.split("&").every(part =>
|
|
167
|
-
value.includes(part.trim())
|
|
168
|
-
)
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
export const applyFilter = matchFilter;
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
export function streamToIteratable<T>(reader: {
|
|
175
|
-
read(): Promise<{ value: T; done: false } | { done: true; value?: T }>;
|
|
176
|
-
}): AsyncIterable<T> {
|
|
177
|
-
return {
|
|
178
|
-
[Symbol.asyncIterator]: async function* () {
|
|
179
|
-
while (true) {
|
|
180
|
-
const { done, value } = await reader.read();
|
|
181
|
-
if (done) {
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
yield value;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
const AsyncFunction = (async () => { }).constructor;
|
|
191
|
-
export function isAsyncFunction(func: unknown): boolean {
|
|
192
|
-
return func instanceof AsyncFunction;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
export function maybeUndefined<T>(value: T): T | undefined {
|
|
196
|
-
return value;
|
|
1
|
+
import { canHaveChildren } from "socket-function/src/types";
|
|
2
|
+
|
|
3
|
+
// TIMING: About 20MB/s
|
|
4
|
+
export function createRandomText(count: number): string {
|
|
5
|
+
let text = "";
|
|
6
|
+
let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
7
|
+
for (let i = 0; i < count; i++) {
|
|
8
|
+
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
|
9
|
+
}
|
|
10
|
+
return text;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function isEmpty(obj: unknown): boolean {
|
|
14
|
+
if (!obj) return false;
|
|
15
|
+
if (typeof obj !== "object") return false;
|
|
16
|
+
return Object.keys(obj).length === 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function isDefined<T>(value: T | undefined | null): value is T {
|
|
20
|
+
return value !== undefined && value !== null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function ObjectAssign<T extends { [key: string]: unknown }>(obj: T, values: Partial<T>) {
|
|
24
|
+
return Object.assign(obj, values);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function ellipsis(text: string, max: number) {
|
|
28
|
+
if (text.length <= max) return text;
|
|
29
|
+
return text.slice(0, max - 3) + "...";
|
|
30
|
+
}
|
|
31
|
+
export function ellipsisMiddle(text: string, max: number) {
|
|
32
|
+
if (text.length <= max) return text;
|
|
33
|
+
let half = Math.floor((max - 3) / 2);
|
|
34
|
+
return text.slice(0, half) + "..." + text.slice(-half);
|
|
35
|
+
}
|
|
36
|
+
export function ellipsisStart(text: string, max: number) {
|
|
37
|
+
if (text.length <= max) return text;
|
|
38
|
+
return "..." + text.slice(-max + 3);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function joinVNodes(vNodes: preact.ComponentChild[], delimitter: preact.ComponentChild) {
|
|
42
|
+
let output: preact.ComponentChild[] = [];
|
|
43
|
+
for (let i = 0; i < vNodes.length; i++) {
|
|
44
|
+
if (i !== 0) {
|
|
45
|
+
output.push(delimitter);
|
|
46
|
+
}
|
|
47
|
+
output.push(vNodes[i]);
|
|
48
|
+
}
|
|
49
|
+
return output;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function clamp(value: number, min: number, max: number) {
|
|
53
|
+
return Math.max(min, Math.min(max, value));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function unique<T>(array: T[]): T[] {
|
|
57
|
+
return Array.from(new Set(array));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function mostCommon<T>(array: T[]): T | undefined {
|
|
61
|
+
let counts = new Map<T, number>();
|
|
62
|
+
for (let item of array) {
|
|
63
|
+
counts.set(item, (counts.get(item) || 0) + 1);
|
|
64
|
+
}
|
|
65
|
+
return Array.from(counts.entries()).sort((a, b) => b[1] - a[1])[0]?.[0];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
export function parsePath(path: string): { dir: string; name: string } {
|
|
70
|
+
path = path.replaceAll("\\", "/");
|
|
71
|
+
let lastSlash = path.lastIndexOf("/");
|
|
72
|
+
if (lastSlash === -1) return { dir: "", name: path };
|
|
73
|
+
return { dir: path.slice(0, lastSlash + 1), name: path.slice(lastSlash + 1) };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Loses spaces in keys and values
|
|
77
|
+
export function toFileNameKVP(kvp: { [key: string]: string }): string {
|
|
78
|
+
function s(v: string) {
|
|
79
|
+
return v.replaceAll(" ", "_");
|
|
80
|
+
}
|
|
81
|
+
return " " + Object.entries(kvp).map(([key, value]) => `${s(key)}=${s(value)}`).join(" ") + " ";
|
|
82
|
+
}
|
|
83
|
+
export function parseFileNameKVP(fileName: string): { [key: string]: string } {
|
|
84
|
+
let parts = fileName.trim().split(" ");
|
|
85
|
+
let obj: { [key: string]: string } = {};
|
|
86
|
+
for (let part of parts) {
|
|
87
|
+
let [key, value] = part.split("=");
|
|
88
|
+
obj[key] = value || key;
|
|
89
|
+
}
|
|
90
|
+
return obj;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Copied object until maxFields is reached. */
|
|
94
|
+
export function partialCopyObject(data: unknown, maxFields: number = 500): unknown {
|
|
95
|
+
try {
|
|
96
|
+
let fieldCount = 0;
|
|
97
|
+
const seen = new WeakSet();
|
|
98
|
+
|
|
99
|
+
function copy(value: unknown): unknown {
|
|
100
|
+
// Handle primitives
|
|
101
|
+
if (!canHaveChildren(value)) {
|
|
102
|
+
return value;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Check for circular references
|
|
106
|
+
if (seen.has(value as object)) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
seen.add(value as object);
|
|
110
|
+
|
|
111
|
+
// Check if we've hit the field limit
|
|
112
|
+
if (fieldCount >= maxFields) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (Array.isArray(value)) {
|
|
117
|
+
const result: unknown[] = [];
|
|
118
|
+
for (const item of value) {
|
|
119
|
+
fieldCount++;
|
|
120
|
+
if (fieldCount >= maxFields) break;
|
|
121
|
+
result.push(copy(item));
|
|
122
|
+
}
|
|
123
|
+
seen.delete(value);
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Handle plain objects
|
|
128
|
+
const result: Record<string, unknown> = {};
|
|
129
|
+
|
|
130
|
+
// Special case for Error objects - include stack and message
|
|
131
|
+
if (value instanceof Error) {
|
|
132
|
+
fieldCount++;
|
|
133
|
+
if (fieldCount < maxFields) {
|
|
134
|
+
result.message = value.message;
|
|
135
|
+
}
|
|
136
|
+
fieldCount++;
|
|
137
|
+
if (fieldCount < maxFields) {
|
|
138
|
+
result.stack = value.stack;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
for (const key of Object.keys(value as object)) {
|
|
143
|
+
fieldCount++;
|
|
144
|
+
if (fieldCount >= maxFields) break;
|
|
145
|
+
result[key] = copy((value as Record<string, unknown>)[key]);
|
|
146
|
+
}
|
|
147
|
+
seen.delete(value);
|
|
148
|
+
return result;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return copy(data) as any;
|
|
152
|
+
} catch (e: any) {
|
|
153
|
+
return { errorCopying: e.messsage } as any;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function sum(array: number[]): number {
|
|
158
|
+
return array.reduce((a, b) => a + b, 0);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function matchFilter(filter: { value: string }, value: string) {
|
|
162
|
+
let filterValue = filter.value.toLowerCase().trim();
|
|
163
|
+
if (!filterValue) return true;
|
|
164
|
+
value = value.toLowerCase().trim();
|
|
165
|
+
return filterValue.split("|").some(part =>
|
|
166
|
+
part.split("&").every(part =>
|
|
167
|
+
value.includes(part.trim())
|
|
168
|
+
)
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
export const applyFilter = matchFilter;
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
export function streamToIteratable<T>(reader: {
|
|
175
|
+
read(): Promise<{ value: T; done: false } | { done: true; value?: T }>;
|
|
176
|
+
}): AsyncIterable<T> {
|
|
177
|
+
return {
|
|
178
|
+
[Symbol.asyncIterator]: async function* () {
|
|
179
|
+
while (true) {
|
|
180
|
+
const { done, value } = await reader.read();
|
|
181
|
+
if (done) {
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
yield value;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const AsyncFunction = (async () => { }).constructor;
|
|
191
|
+
export function isAsyncFunction(func: unknown): boolean {
|
|
192
|
+
return func instanceof AsyncFunction;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export function maybeUndefined<T>(value: T): T | undefined {
|
|
196
|
+
return value;
|
|
197
197
|
}
|