querysub 0.341.0 → 0.342.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
CHANGED
|
@@ -53,6 +53,8 @@ import { parseArgsFactory } from "../misc/rawParams";
|
|
|
53
53
|
|
|
54
54
|
import * as typesafecss from "typesafecss";
|
|
55
55
|
import "../library-components/urlResetGroups";
|
|
56
|
+
import { createLocalSchema } from "./schemaHelpers";
|
|
57
|
+
|
|
56
58
|
|
|
57
59
|
|
|
58
60
|
typesafecss.setMeasureBlock(measureBlock);
|
|
@@ -1069,32 +1071,6 @@ export class Querysub {
|
|
|
1069
1071
|
// like just relying on the automatic checking is better?
|
|
1070
1072
|
}
|
|
1071
1073
|
|
|
1072
|
-
let localSchemaNames = new Set<string>();
|
|
1073
|
-
function createLocalSchema<T>(name: string): () => T;
|
|
1074
|
-
function createLocalSchema<SchemaDef extends Schema2>(name: string, schema: SchemaDef): () => Schema2T<SchemaDef>;
|
|
1075
|
-
function createLocalSchema<T>(name: string, schema2?: Schema2): () => T {
|
|
1076
|
-
if (localSchemaNames.has(name) && !isHotReloading() && !isDynamicallyLoading()) {
|
|
1077
|
-
debugbreak(2);
|
|
1078
|
-
debugger;
|
|
1079
|
-
throw new Error(`Already have local schema with name ${JSON.stringify(name)}`);
|
|
1080
|
-
}
|
|
1081
|
-
if (schema2) {
|
|
1082
|
-
registerSchemaPrefix({
|
|
1083
|
-
schema: schema2,
|
|
1084
|
-
prefixPathStr: getPathStr2(LOCAL_DOMAIN, name),
|
|
1085
|
-
});
|
|
1086
|
-
}
|
|
1087
|
-
localSchemaNames.add(name);
|
|
1088
|
-
let schema = rawSchema<{
|
|
1089
|
-
[LOCAL_DOMAIN]: {
|
|
1090
|
-
[name: string]: T;
|
|
1091
|
-
}
|
|
1092
|
-
}>();
|
|
1093
|
-
// Lazy saves a lot of time on accesses by skipping a few proxy accesses
|
|
1094
|
-
return lazy(() => {
|
|
1095
|
-
return schema()[LOCAL_DOMAIN][name];
|
|
1096
|
-
});
|
|
1097
|
-
}
|
|
1098
1074
|
|
|
1099
1075
|
let nextGlobalIndex = 1000 * 1000 * 1000 * 100;
|
|
1100
1076
|
let nextCallIndex = 1;
|
|
@@ -10,8 +10,9 @@ import { blue, green, magenta, yellow } from "socket-function/src/formatting/log
|
|
|
10
10
|
import { formatTime } from "socket-function/src/formatting/format";
|
|
11
11
|
import { measureBlock, measureWrap } from "socket-function/src/profiling/measure";
|
|
12
12
|
import { debugTime } from "../0-path-value-core/pathValueCore";
|
|
13
|
-
import { t } from "./Querysub";
|
|
14
13
|
import { getProxyPath } from "../2-proxy/pathValueProxy";
|
|
14
|
+
import { createLocalSchema } from "./schemaHelpers";
|
|
15
|
+
import { t } from "../2-proxy/schema2";
|
|
15
16
|
|
|
16
17
|
let commitQueues: Map<string, {
|
|
17
18
|
callSpec: CallSpec;
|
|
@@ -22,7 +23,7 @@ let commitQueues: Map<string, {
|
|
|
22
23
|
resolveOrderedPromise: PromiseObj<void>;
|
|
23
24
|
canBeClobbered: boolean;
|
|
24
25
|
}[]> = new Map();
|
|
25
|
-
let commitQueueCount =
|
|
26
|
+
let commitQueueCount = createLocalSchema("commitQueueCount", {
|
|
26
27
|
count: t.number,
|
|
27
28
|
});
|
|
28
29
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { lazy } from "socket-function/src/caching";
|
|
2
|
+
import { LOCAL_DOMAIN } from "../0-path-value-core/NodePathAuthorities";
|
|
3
|
+
import { registerSchemaPrefix } from "../2-proxy/PathValueProxyWatcher";
|
|
4
|
+
import { rawSchema } from "../2-proxy/pathDatabaseProxyBase";
|
|
5
|
+
import { Schema2, Schema2T } from "../2-proxy/schema2";
|
|
6
|
+
import { isDynamicallyLoading } from "../config";
|
|
7
|
+
import { getPathStr2 } from "../path";
|
|
8
|
+
import { isHotReloading } from "socket-function/hot/HotReloadController";
|
|
9
|
+
import debugbreak from "debugbreak";
|
|
10
|
+
|
|
11
|
+
let localSchemaNames = new Set<string>();
|
|
12
|
+
export function createLocalSchema<T>(name: string): () => T;
|
|
13
|
+
export function createLocalSchema<SchemaDef extends Schema2>(name: string, schema: SchemaDef): () => Schema2T<SchemaDef>;
|
|
14
|
+
export function createLocalSchema<T>(name: string, schema2?: Schema2): () => T {
|
|
15
|
+
if (localSchemaNames.has(name) && !isHotReloading() && !isDynamicallyLoading()) {
|
|
16
|
+
debugbreak(2);
|
|
17
|
+
debugger;
|
|
18
|
+
throw new Error(`Already have local schema with name ${JSON.stringify(name)}`);
|
|
19
|
+
}
|
|
20
|
+
if (schema2) {
|
|
21
|
+
registerSchemaPrefix({
|
|
22
|
+
schema: schema2,
|
|
23
|
+
prefixPathStr: getPathStr2(LOCAL_DOMAIN, name),
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
localSchemaNames.add(name);
|
|
27
|
+
let schema = rawSchema<{
|
|
28
|
+
[LOCAL_DOMAIN]: {
|
|
29
|
+
[name: string]: T;
|
|
30
|
+
}
|
|
31
|
+
}>();
|
|
32
|
+
// Lazy saves a lot of time on accesses by skipping a few proxy accesses
|
|
33
|
+
return lazy(() => {
|
|
34
|
+
return schema()[LOCAL_DOMAIN][name];
|
|
35
|
+
});
|
|
36
|
+
}
|