querysub 0.706.0 → 0.708.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "querysub",
3
- "version": "0.706.0",
3
+ "version": "0.708.0",
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",
@@ -25,9 +25,9 @@
25
25
  "mcp2": "yarn typenode ./src/diagnostics/debugger/mcp-server.ts",
26
26
  "mc2": "yarn typenode ./src/diagnostics/debugger/mcp-server.ts --cwd D:/repos/qs-cyoa/",
27
27
  "autofix": "yarn typenode ./src/diagnostics/logs/errorTickets/autoFixerEntry.ts",
28
- "thin": "yarn typenode ./src/archiveapps/snapshotThinningEntry.ts",
29
- "thin-watch": "yarn typenode ./src/archiveapps/snapshotThinningEntry.ts --watch",
30
- "thin-dry": "yarn typenode ./src/archiveapps/snapshotThinningEntry.ts --dry-run",
28
+ "thin": "yarn typenode ./src/archiveapps/snapshotThinningEntry.ts --nobreak --public",
29
+ "thin-watch": "yarn typenode ./src/archiveapps/snapshotThinningEntry.ts --nobreak --public --watch",
30
+ "thin-dry": "yarn typenode ./src/archiveapps/snapshotThinningEntry.ts --nobreak --public --dry-run",
31
31
  "parameters-timeline": "yarn typenode ./src/deployManager/parametersTimelineMain.ts",
32
32
  "setup-machine": "yarn typenode ./src/deployManager/setupMachineMain.ts",
33
33
  "stop-machine": "yarn typenode ./src/deployManager/stopMachineMain.ts",
@@ -0,0 +1,60 @@
1
+ import { isNode } from "typesafecss";
2
+ import { t } from "../2-proxy/schema2";
3
+ import { Querysub } from "../4-querysub/Querysub";
4
+
5
+ const localStorageParamState = Querysub.createLocalSchema("localStorageParams", {
6
+ values: t.lookup(t.string),
7
+ });
8
+
9
+ let allParams: LocalStorageParamStr[] = [];
10
+
11
+ export class LocalStorageParamStr {
12
+ public lastSetValue = "";
13
+ constructor(public readonly storageKey: string, private defaultValue: string = "") {
14
+ allParams.push(this);
15
+ this.forceUpdate();
16
+ }
17
+
18
+ public forceUpdate() {
19
+ if (isNode()) return;
20
+ let stored = localStorage.getItem(this.storageKey) || "";
21
+ Querysub.localCommit(() => {
22
+ localStorageParamState().values[this.storageKey] = stored;
23
+ });
24
+ }
25
+
26
+ public get() {
27
+ if (isNode()) return "";
28
+ if (Querysub.isInWatcher()) {
29
+ return localStorageParamState().values[this.storageKey];
30
+ }
31
+ return Querysub.localRead(() => localStorageParamState().values[this.storageKey]);
32
+ }
33
+
34
+ public set(value: string) {
35
+ this.lastSetValue = value;
36
+ if (isNode()) return;
37
+ if (value === "") {
38
+ localStorage.removeItem(this.storageKey);
39
+ } else {
40
+ localStorage.setItem(this.storageKey, value);
41
+ }
42
+ this.forceUpdate();
43
+ }
44
+
45
+ public get value() {
46
+ return this.get() || this.defaultValue;
47
+ }
48
+ public set value(value: string) {
49
+ this.set(value);
50
+ }
51
+ }
52
+
53
+ if (!isNode()) {
54
+ window.addEventListener("storage", e => {
55
+ for (let param of allParams) {
56
+ if (e.key !== param.storageKey) continue;
57
+ param.forceUpdate();
58
+ }
59
+ });
60
+ }