querysub 0.2.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/.dependency-cruiser.js +304 -0
- package/.eslintrc.js +51 -0
- package/.github/copilot-instructions.md +1 -0
- package/.vscode/settings.json +25 -0
- package/bin/deploy.js +4 -0
- package/bin/function.js +4 -0
- package/bin/server.js +4 -0
- package/costsBenefits.txt +112 -0
- package/deploy.ts +3 -0
- package/inject.ts +1 -0
- package/package.json +60 -0
- package/prompts.txt +54 -0
- package/spec.txt +820 -0
- package/src/-a-archives/archiveCache.ts +913 -0
- package/src/-a-archives/archives.ts +148 -0
- package/src/-a-archives/archivesBackBlaze.ts +792 -0
- package/src/-a-archives/archivesDisk.ts +418 -0
- package/src/-a-archives/copyLocalToBackblaze.ts +24 -0
- package/src/-a-auth/certs.ts +517 -0
- package/src/-a-auth/der.ts +122 -0
- package/src/-a-auth/ed25519.ts +1015 -0
- package/src/-a-auth/node-forge-ed25519.d.ts +17 -0
- package/src/-b-authorities/dnsAuthority.ts +203 -0
- package/src/-b-authorities/emailAuthority.ts +57 -0
- package/src/-c-identity/IdentityController.ts +200 -0
- package/src/-d-trust/NetworkTrust2.ts +150 -0
- package/src/-e-certs/EdgeCertController.ts +288 -0
- package/src/-e-certs/certAuthority.ts +192 -0
- package/src/-f-node-discovery/NodeDiscovery.ts +543 -0
- package/src/-g-core-values/NodeCapabilities.ts +134 -0
- package/src/-g-core-values/oneTimeForward.ts +91 -0
- package/src/-h-path-value-serialize/PathValueSerializer.ts +769 -0
- package/src/-h-path-value-serialize/stringSerializer.ts +176 -0
- package/src/0-path-value-core/LoggingClient.tsx +24 -0
- package/src/0-path-value-core/NodePathAuthorities.ts +978 -0
- package/src/0-path-value-core/PathController.ts +1 -0
- package/src/0-path-value-core/PathValueCommitter.ts +565 -0
- package/src/0-path-value-core/PathValueController.ts +231 -0
- package/src/0-path-value-core/archiveLocks/ArchiveLocks.ts +154 -0
- package/src/0-path-value-core/archiveLocks/ArchiveLocks2.ts +820 -0
- package/src/0-path-value-core/archiveLocks/archiveSnapshots.ts +180 -0
- package/src/0-path-value-core/debugLogs.ts +90 -0
- package/src/0-path-value-core/pathValueArchives.ts +483 -0
- package/src/0-path-value-core/pathValueCore.ts +2217 -0
- package/src/1-path-client/RemoteWatcher.ts +558 -0
- package/src/1-path-client/pathValueClientWatcher.ts +702 -0
- package/src/2-proxy/PathValueProxyWatcher.ts +1857 -0
- package/src/2-proxy/archiveMoveHarness.ts +376 -0
- package/src/2-proxy/garbageCollection.ts +753 -0
- package/src/2-proxy/pathDatabaseProxyBase.ts +37 -0
- package/src/2-proxy/pathValueProxy.ts +139 -0
- package/src/2-proxy/schema2.ts +518 -0
- package/src/3-path-functions/PathFunctionHelpers.ts +129 -0
- package/src/3-path-functions/PathFunctionRunner.ts +619 -0
- package/src/3-path-functions/PathFunctionRunnerMain.ts +67 -0
- package/src/3-path-functions/deployBlock.ts +10 -0
- package/src/3-path-functions/deployCheck.ts +7 -0
- package/src/3-path-functions/deployMain.ts +160 -0
- package/src/3-path-functions/pathFunctionLoader.ts +282 -0
- package/src/3-path-functions/syncSchema.ts +475 -0
- package/src/3-path-functions/tests/functionsTest.ts +135 -0
- package/src/3-path-functions/tests/rejectTest.ts +77 -0
- package/src/4-dom/css.tsx +29 -0
- package/src/4-dom/cssTypes.d.ts +212 -0
- package/src/4-dom/qreact.tsx +2322 -0
- package/src/4-dom/qreactTest.tsx +417 -0
- package/src/4-querysub/Querysub.ts +877 -0
- package/src/4-querysub/QuerysubController.ts +620 -0
- package/src/4-querysub/copyEvent.ts +0 -0
- package/src/4-querysub/permissions.ts +289 -0
- package/src/4-querysub/permissionsShared.ts +1 -0
- package/src/4-querysub/querysubPrediction.ts +525 -0
- package/src/5-diagnostics/FullscreenModal.tsx +67 -0
- package/src/5-diagnostics/GenericFormat.tsx +165 -0
- package/src/5-diagnostics/Modal.tsx +79 -0
- package/src/5-diagnostics/Table.tsx +183 -0
- package/src/5-diagnostics/TimeGrouper.tsx +114 -0
- package/src/5-diagnostics/diskValueAudit.ts +216 -0
- package/src/5-diagnostics/memoryValueAudit.ts +442 -0
- package/src/5-diagnostics/nodeMetadata.ts +135 -0
- package/src/5-diagnostics/qreactDebug.tsx +309 -0
- package/src/5-diagnostics/shared.ts +26 -0
- package/src/5-diagnostics/synchronousLagTracking.ts +47 -0
- package/src/TestController.ts +35 -0
- package/src/allowclient.flag +0 -0
- package/src/bits.ts +86 -0
- package/src/buffers.ts +69 -0
- package/src/config.ts +53 -0
- package/src/config2.ts +48 -0
- package/src/diagnostics/ActionsHistory.ts +56 -0
- package/src/diagnostics/NodeViewer.tsx +503 -0
- package/src/diagnostics/SizeLimiter.ts +62 -0
- package/src/diagnostics/TimeDebug.tsx +18 -0
- package/src/diagnostics/benchmark.ts +139 -0
- package/src/diagnostics/errorLogs/ErrorLogController.ts +515 -0
- package/src/diagnostics/errorLogs/ErrorLogCore.ts +274 -0
- package/src/diagnostics/errorLogs/LogClassifiers.tsx +302 -0
- package/src/diagnostics/errorLogs/LogFilterUI.tsx +84 -0
- package/src/diagnostics/errorLogs/LogNotify.tsx +101 -0
- package/src/diagnostics/errorLogs/LogTimeSelector.tsx +724 -0
- package/src/diagnostics/errorLogs/LogViewer.tsx +757 -0
- package/src/diagnostics/errorLogs/hookErrors.ts +60 -0
- package/src/diagnostics/errorLogs/logFiltering.tsx +149 -0
- package/src/diagnostics/heapTag.ts +13 -0
- package/src/diagnostics/listenOnDebugger.ts +77 -0
- package/src/diagnostics/logs/DiskLoggerPage.tsx +572 -0
- package/src/diagnostics/logs/ObjectDisplay.tsx +165 -0
- package/src/diagnostics/logs/ansiFormat.ts +108 -0
- package/src/diagnostics/logs/diskLogGlobalContext.ts +38 -0
- package/src/diagnostics/logs/diskLogger.ts +305 -0
- package/src/diagnostics/logs/diskShimConsoleLogs.ts +32 -0
- package/src/diagnostics/logs/injectFileLocationToConsole.ts +50 -0
- package/src/diagnostics/logs/logGitHashes.ts +30 -0
- package/src/diagnostics/managementPages.tsx +289 -0
- package/src/diagnostics/periodic.ts +89 -0
- package/src/diagnostics/runSaturationTest.ts +416 -0
- package/src/diagnostics/satSchema.ts +64 -0
- package/src/diagnostics/trackResources.ts +82 -0
- package/src/diagnostics/watchdog.ts +55 -0
- package/src/errors.ts +132 -0
- package/src/forceProduction.ts +3 -0
- package/src/fs.ts +72 -0
- package/src/heapDumps.ts +666 -0
- package/src/https.ts +2 -0
- package/src/inject.ts +1 -0
- package/src/library-components/ATag.tsx +84 -0
- package/src/library-components/Button.tsx +344 -0
- package/src/library-components/ButtonSelector.tsx +64 -0
- package/src/library-components/DropdownCustom.tsx +151 -0
- package/src/library-components/DropdownSelector.tsx +32 -0
- package/src/library-components/Input.tsx +334 -0
- package/src/library-components/InputLabel.tsx +198 -0
- package/src/library-components/InputPicker.tsx +125 -0
- package/src/library-components/LazyComponent.tsx +62 -0
- package/src/library-components/MeasureHeightCSS.tsx +48 -0
- package/src/library-components/MeasuredDiv.tsx +47 -0
- package/src/library-components/ShowMore.tsx +51 -0
- package/src/library-components/SyncedController.ts +171 -0
- package/src/library-components/TimeRangeSelector.tsx +407 -0
- package/src/library-components/URLParam.ts +263 -0
- package/src/library-components/colors.tsx +14 -0
- package/src/library-components/drag.ts +114 -0
- package/src/library-components/icons.tsx +692 -0
- package/src/library-components/niceStringify.ts +50 -0
- package/src/library-components/renderToString.ts +52 -0
- package/src/misc/PromiseRace.ts +101 -0
- package/src/misc/color.ts +30 -0
- package/src/misc/getParentProcessId.cs +53 -0
- package/src/misc/getParentProcessId.ts +53 -0
- package/src/misc/hash.ts +83 -0
- package/src/misc/ipPong.js +13 -0
- package/src/misc/networking.ts +2 -0
- package/src/misc/random.ts +45 -0
- package/src/misc.ts +19 -0
- package/src/noserverhotreload.flag +0 -0
- package/src/path.ts +226 -0
- package/src/persistentLocalStore.ts +37 -0
- package/src/promise.ts +15 -0
- package/src/server.ts +73 -0
- package/src/src.d.ts +1 -0
- package/src/test/heapProcess.ts +36 -0
- package/src/test/mongoSatTest.tsx +55 -0
- package/src/test/satTest.ts +193 -0
- package/src/test/test.tsx +552 -0
- package/src/zip.ts +92 -0
- package/src/zipThreaded.ts +106 -0
- package/src/zipThreadedWorker.js +19 -0
- package/tsconfig.json +27 -0
- package/yarnSpec.txt +56 -0
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
import { disableMeasurements, measureBlock, measureCode, measureFnc } from "socket-function/src/profiling/measure";
|
|
2
|
+
disableMeasurements();
|
|
3
|
+
|
|
4
|
+
import preact from "preact";
|
|
5
|
+
import { isNode, list, timeInHour } from "socket-function/src/misc";
|
|
6
|
+
import { ClientWatcher, clientWatcher } from "../1-path-client/pathValueClientWatcher";
|
|
7
|
+
import { isDeploy } from "../3-path-functions/deployCheck";
|
|
8
|
+
import { logErrors } from "../errors";
|
|
9
|
+
import { watchFilesAndTriggerHotReloading } from "socket-function/hot/HotReloadController";
|
|
10
|
+
import { qreact } from "./qreact";
|
|
11
|
+
import { Querysub } from "../4-querysub/QuerysubController";
|
|
12
|
+
import { PermissionsCheck } from "../4-querysub/permissions";
|
|
13
|
+
import { PathValueProxyWatcher, proxyWatcher } from "../2-proxy/PathValueProxyWatcher";
|
|
14
|
+
import { setFlag } from "socket-function/require/compileFlags";
|
|
15
|
+
import { rawSchema } from "../2-proxy/pathDatabaseProxyBase";
|
|
16
|
+
import { LOCAL_DOMAIN } from "../0-path-value-core/PathController";
|
|
17
|
+
import { batchFunction, delay } from "socket-function/src/batching";
|
|
18
|
+
import { formatTime } from "socket-function/src/formatting/format";
|
|
19
|
+
import { pathValueAuthority2 } from "../0-path-value-core/NodePathAuthorities";
|
|
20
|
+
import { schema } from "../3-path-functions/tests/rejectTest";
|
|
21
|
+
import { pathValueSerializer } from "../-h-path-value-serialize/PathValueSerializer";
|
|
22
|
+
import { getPathFromStr } from "../path";
|
|
23
|
+
import { PromiseObj } from "../promise";
|
|
24
|
+
import { css } from "./css";
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
async function main() {
|
|
29
|
+
if (!isNode()) return;
|
|
30
|
+
if (isDeploy()) return;
|
|
31
|
+
if (module.hotreload) return;
|
|
32
|
+
const edgePort = 15060;
|
|
33
|
+
PermissionsCheck.DEBUG = true;
|
|
34
|
+
ClientWatcher.DEBUG_READS = true;
|
|
35
|
+
ClientWatcher.DEBUG_WRITES = true;
|
|
36
|
+
//debugCoreMode();
|
|
37
|
+
|
|
38
|
+
//SocketFunction.silent = false;
|
|
39
|
+
Error.stackTraceLimit = 20;
|
|
40
|
+
|
|
41
|
+
await Querysub.hostServer({
|
|
42
|
+
trustedDomains: ["querysub.com"],
|
|
43
|
+
port: edgePort,
|
|
44
|
+
rootPath: __dirname + "/../../",
|
|
45
|
+
clientsideEntryPoint: "./src/4-dom/qreactTest.tsx",
|
|
46
|
+
hotReload: true,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
class Nested extends qreact.Component<{
|
|
51
|
+
value: unknown;
|
|
52
|
+
}> {
|
|
53
|
+
render() {
|
|
54
|
+
return (
|
|
55
|
+
<>
|
|
56
|
+
value = {this.props.value}, {this.props.value}
|
|
57
|
+
<div>
|
|
58
|
+
{String(this.props.value)}
|
|
59
|
+
</div>
|
|
60
|
+
</>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
class DynamicComponent extends qreact.Component<{
|
|
66
|
+
propValue: unknown;
|
|
67
|
+
}> {
|
|
68
|
+
state = {
|
|
69
|
+
value: "state",
|
|
70
|
+
noRoot: false,
|
|
71
|
+
children: {} as {
|
|
72
|
+
[num: number | string]: {
|
|
73
|
+
value: string;
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
nextChild: 0,
|
|
77
|
+
};
|
|
78
|
+
render() {
|
|
79
|
+
let base = <>
|
|
80
|
+
<div>Prop value {this.props.propValue}</div>
|
|
81
|
+
<div>State value <input value={this.state.value} onChange={e => this.state.value = e.currentTarget.value} /> = {this.state.value}</div>
|
|
82
|
+
<div>
|
|
83
|
+
No div root <input type="checkbox" checked={this.state.noRoot} onChange={e => this.state.noRoot = e.currentTarget.checked} />
|
|
84
|
+
</div>
|
|
85
|
+
<div>
|
|
86
|
+
<div>Children</div>
|
|
87
|
+
<button onClick={() => {
|
|
88
|
+
let nextChild = this.state.nextChild++;
|
|
89
|
+
this.state.children[nextChild] = { value: "prop" + nextChild, };
|
|
90
|
+
}}>
|
|
91
|
+
Add child
|
|
92
|
+
</button>
|
|
93
|
+
{Object.entries(this.state.children).map(([key, obj]) =>
|
|
94
|
+
<div class={css.marginLeft(10).hsla(200, 75, 75, 0.2)}>
|
|
95
|
+
<button onClick={() => delete this.state.children[key]}>Remove child</button>
|
|
96
|
+
<div>
|
|
97
|
+
Child prop: <input value={obj.value} onChange={e => obj.value = e.currentTarget.value} />
|
|
98
|
+
</div>
|
|
99
|
+
<DynamicComponent propValue={obj.value} />
|
|
100
|
+
</div>
|
|
101
|
+
)}
|
|
102
|
+
</div>
|
|
103
|
+
</>;
|
|
104
|
+
if (!this.state.noRoot) {
|
|
105
|
+
base = <div class={css.pad(10).hsla(160, 75, 75, 0.5)}>{base}</div>;
|
|
106
|
+
}
|
|
107
|
+
return base;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
class ValueRender extends qreact.Component<{
|
|
112
|
+
x: { value: number };
|
|
113
|
+
}> {
|
|
114
|
+
render() {
|
|
115
|
+
return (
|
|
116
|
+
<div>
|
|
117
|
+
x = {this.props.x.value}
|
|
118
|
+
<button onClick={() => this.props.x.value++}>Test</button>
|
|
119
|
+
<input type="number" value={this.props.x.value} onInput={e => this.props.x.value = e.currentTarget.valueAsNumber} />
|
|
120
|
+
</div>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
class Intermediate extends qreact.Component<{
|
|
126
|
+
x: { value: number };
|
|
127
|
+
}> {
|
|
128
|
+
render() {
|
|
129
|
+
return (
|
|
130
|
+
<ValueRender x={this.props.x} />
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
class CircleComponent extends qreact.Component {
|
|
136
|
+
render() {
|
|
137
|
+
return (
|
|
138
|
+
<circle cx={200} cy={50} r={50} fill="red" />
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
class Test extends qreact.Component {
|
|
144
|
+
state = {
|
|
145
|
+
valueValue: { value: 0 },
|
|
146
|
+
};
|
|
147
|
+
render() {
|
|
148
|
+
return (
|
|
149
|
+
<div>
|
|
150
|
+
<button onClick={() => this.state.valueValue.value++}>Increment</button>
|
|
151
|
+
<div>Value = {this.state.valueValue.value}</div>
|
|
152
|
+
<Intermediate x={{ value: this.state.valueValue.value }} />
|
|
153
|
+
|
|
154
|
+
<svg>
|
|
155
|
+
<circle cx={100} cy={100} r={50} fill="red" />
|
|
156
|
+
<CircleComponent />
|
|
157
|
+
</svg>
|
|
158
|
+
</div>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
class Benchmark1 extends qreact.Component<{
|
|
164
|
+
count: number;
|
|
165
|
+
}> {
|
|
166
|
+
render() {
|
|
167
|
+
return (
|
|
168
|
+
<div>
|
|
169
|
+
{list(this.props.count).map(i => <div>{i}</div>)}
|
|
170
|
+
</div>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
class Benchmark2 extends qreact.Component<{
|
|
175
|
+
count: number;
|
|
176
|
+
}> {
|
|
177
|
+
render() {
|
|
178
|
+
return (
|
|
179
|
+
list(this.props.count).map(i => <div>{i}</div>)
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
class SmallNested extends qreact.Component<{
|
|
186
|
+
obj: { value: number };
|
|
187
|
+
}> {
|
|
188
|
+
render() {
|
|
189
|
+
return (
|
|
190
|
+
<div />
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
class Benchmark3 extends qreact.Component<{
|
|
195
|
+
count: number;
|
|
196
|
+
}> {
|
|
197
|
+
render() {
|
|
198
|
+
return (
|
|
199
|
+
list(this.props.count).map(i => <SmallNested obj={{ value: i }} />)
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
class SmallNested2 extends qreact.Component<{
|
|
205
|
+
obj: { value: number };
|
|
206
|
+
}> {
|
|
207
|
+
render() {
|
|
208
|
+
return (
|
|
209
|
+
<div class={css.flex.gap(10).wrap} onClick={() => this.props.obj.value++}>
|
|
210
|
+
{this.props.obj.value}
|
|
211
|
+
<img src="/widgets/HTML5Video/video-thumbnail.jpg" />
|
|
212
|
+
</div>
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
class Benchmark3p5 extends qreact.Component<{
|
|
217
|
+
count: number;
|
|
218
|
+
}> {
|
|
219
|
+
render() {
|
|
220
|
+
return (
|
|
221
|
+
list(this.props.count).map(i => <SmallNested2 obj={{ value: i }} />)
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
class Benchmark4 extends qreact.Component<{
|
|
227
|
+
count: number;
|
|
228
|
+
}> {
|
|
229
|
+
render() {
|
|
230
|
+
return (
|
|
231
|
+
<div class={css.flex.wrap}>
|
|
232
|
+
{list(this.props.count).map(i =>
|
|
233
|
+
<img src="/widgets/HTML5Video/video-thumbnail.jpg" />
|
|
234
|
+
)}
|
|
235
|
+
</div>
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
async function browserMain() {
|
|
243
|
+
if (isNode()) return;
|
|
244
|
+
watchFilesAndTriggerHotReloading();
|
|
245
|
+
|
|
246
|
+
// NOTE: Annoying, but qreact can't emulate the special minified keys preact uses
|
|
247
|
+
qreact.createElement = preact.createElement as any;
|
|
248
|
+
qreact.Fragment = preact.Fragment as any;
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
//ClientWatcher.DEBUG_READS = true;
|
|
252
|
+
//ClientWatcher.DEBUG_READS_EXPANDED = true;
|
|
253
|
+
//ClientWatcher.DEBUG_WRITES = true;
|
|
254
|
+
//ClientWatcher.DEBUG_WRITES_EXPANDED = true;
|
|
255
|
+
//Querysub.DEBUG_CALLS = true;
|
|
256
|
+
//PathValueProxyWatcher.TRACE = true;
|
|
257
|
+
//ClientWatcher.DEBUG_TRIGGERS = "light";
|
|
258
|
+
//ClientWatcher.DEBUG_TRIGGERS = "heavy";
|
|
259
|
+
//qreact.debug();
|
|
260
|
+
|
|
261
|
+
//preact.render(<Test />, document.getElementById("main")!);
|
|
262
|
+
//qreact.render(<DynamicComponent propValue={1} />, document.getElementById("main")!);
|
|
263
|
+
//qreact.render(<SyncedTest propValue={1} />, document.getElementById("main")!);
|
|
264
|
+
|
|
265
|
+
//*
|
|
266
|
+
await new Promise(resolve => setTimeout(resolve, 0));
|
|
267
|
+
await pathValueAuthority2.waitUntilRoutingIsReady();
|
|
268
|
+
|
|
269
|
+
let benchmarkComponents = [
|
|
270
|
+
// ONLY run with devtools closed AND disableMeasurements (at the top of the file)! Otherwise the timings will be wrong.
|
|
271
|
+
// qreact is 3X slower
|
|
272
|
+
() => <Benchmark1 count={10000} />,
|
|
273
|
+
// qreact is 3X slower
|
|
274
|
+
() => <Benchmark2 count={10000} />,
|
|
275
|
+
// qreact is 30X slower
|
|
276
|
+
() => <Benchmark3 count={1000} />,
|
|
277
|
+
// qreact is 10X slower
|
|
278
|
+
() => <Benchmark3p5 count={1000} />,
|
|
279
|
+
// qreact is 1.5X slower
|
|
280
|
+
() => <Benchmark4 count={1000} />,
|
|
281
|
+
];
|
|
282
|
+
|
|
283
|
+
await measureCode(async function renderTest() {
|
|
284
|
+
const main = document.getElementById("main")!;
|
|
285
|
+
async function reset() {
|
|
286
|
+
main.replaceChildren();
|
|
287
|
+
await delay(0);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
for (let componentFactory of benchmarkComponents) {
|
|
291
|
+
let component = componentFactory();
|
|
292
|
+
let name = (component.type as any).name;
|
|
293
|
+
|
|
294
|
+
await reset();
|
|
295
|
+
let time = Date.now();
|
|
296
|
+
preact.render(component, main);
|
|
297
|
+
time = Date.now() - time;
|
|
298
|
+
preact.render(<div />, main);
|
|
299
|
+
console.log(`preact|${name} took ${formatTime(time)}`);
|
|
300
|
+
|
|
301
|
+
await reset();
|
|
302
|
+
time = Date.now();
|
|
303
|
+
await measureBlock(async () => {
|
|
304
|
+
qreact.render(component, main);
|
|
305
|
+
await clientWatcher.waitForTriggerFinished();
|
|
306
|
+
qreact.render(<div />, main);
|
|
307
|
+
await clientWatcher.waitForTriggerFinished();
|
|
308
|
+
}, "qreact|" + name);
|
|
309
|
+
time = Date.now() - time;
|
|
310
|
+
console.log(`qreact|${name} took ${formatTime(time)}`);
|
|
311
|
+
|
|
312
|
+
qreact.render(<div>done</div>, main);
|
|
313
|
+
}
|
|
314
|
+
}, { minTimeToLog: 0, thresholdInTable: 0 });
|
|
315
|
+
//*/
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
logErrors(main());
|
|
319
|
+
logErrors(browserMain());
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
let { data, functions } = Querysub.createSchema<{
|
|
323
|
+
values: {
|
|
324
|
+
[key: string]: string;
|
|
325
|
+
};
|
|
326
|
+
}>()({
|
|
327
|
+
domainName: "querysub.com",
|
|
328
|
+
functions: {
|
|
329
|
+
setValue(key: string, value: string) {
|
|
330
|
+
data().values[key] = value;
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
module,
|
|
334
|
+
moduleId: "qreactTest",
|
|
335
|
+
functionMetadata: {},
|
|
336
|
+
permissions: {
|
|
337
|
+
PERMISSIONS: () => true
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
class SyncTest extends qreact.Component {
|
|
342
|
+
render() {
|
|
343
|
+
return (
|
|
344
|
+
<div>
|
|
345
|
+
<div>Regular <input value={data().values["a"]} onChange={e => functions.setValue("a", e.currentTarget.value)} /></div>
|
|
346
|
+
<div>Hot <input value={data().values["b"]} onInput={e => functions.setValue("b", e.currentTarget.value)} /></div>
|
|
347
|
+
<div>
|
|
348
|
+
Trigger sources {Array.from(Querysub.getTriggerReason()?.pathSources || []).map(x =>
|
|
349
|
+
<div>
|
|
350
|
+
{getPathFromStr(x.path).join(".")}
|
|
351
|
+
{x.source && <div class={css.marginLeft(10)}>{x.source}</div>}
|
|
352
|
+
</div>
|
|
353
|
+
)}
|
|
354
|
+
</div>
|
|
355
|
+
</div>
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/*
|
|
361
|
+
async function browserMain2() {
|
|
362
|
+
if (isNode()) return;
|
|
363
|
+
|
|
364
|
+
watchFilesAndTriggerHotReloading();
|
|
365
|
+
|
|
366
|
+
Querysub.DEBUG_CALLS = true;
|
|
367
|
+
ClientWatcher.DEBUG_TRIGGERS = "heavy";
|
|
368
|
+
qreact.debug();
|
|
369
|
+
|
|
370
|
+
qreact.render(preact.createElement(SyncTest, {}), document.getElementById("main")!);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
async function main2() {
|
|
374
|
+
if (!isNode()) return;
|
|
375
|
+
if (isDeploy()) return;
|
|
376
|
+
if (module.hotreload) return;
|
|
377
|
+
const edgePort = 15060;
|
|
378
|
+
PermissionsCheck.DEBUG = true;
|
|
379
|
+
ClientWatcher.DEBUG_READS = true;
|
|
380
|
+
ClientWatcher.DEBUG_WRITES = true;
|
|
381
|
+
|
|
382
|
+
//SocketFunction.silent = false;
|
|
383
|
+
Error.stackTraceLimit = 20;
|
|
384
|
+
|
|
385
|
+
await Querysub.hostServer({
|
|
386
|
+
trustedDomains: ["querysub.com"],
|
|
387
|
+
port: edgePort,
|
|
388
|
+
rootPath: __dirname + "/../../",
|
|
389
|
+
clientsideEntryPoint: "./src/4-dom/qreactTest.tsx",
|
|
390
|
+
hotReload: true,
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
module.hotreload = isNode() && process.argv[1].includes("PathFunctionRunnerMain.ts");
|
|
395
|
+
module.noserverhotreload = false;
|
|
396
|
+
|
|
397
|
+
logErrors(main2());
|
|
398
|
+
logErrors(browserMain2());
|
|
399
|
+
*/
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
// async function main3() {
|
|
403
|
+
// let test = await proxyWatcher.dryRun({
|
|
404
|
+
// canWrite: true,
|
|
405
|
+
// watchFunction() {
|
|
406
|
+
// schema()["querysub.com"].rejectTest.value = 2;
|
|
407
|
+
// },
|
|
408
|
+
// });
|
|
409
|
+
// let buffer = await pathValueSerializer.serialize(test!);
|
|
410
|
+
// let test2 = await pathValueSerializer.deserialize(buffer);
|
|
411
|
+
// debugger;
|
|
412
|
+
// }
|
|
413
|
+
|
|
414
|
+
// main3().catch(e => console.error(e)).finally(() => process.exit());
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
// yarn test typenode ./src/4-dom/qreactTest.tsx
|