querysub 0.347.0 → 0.348.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.347.0",
3
+ "version": "0.348.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",
@@ -40,12 +40,14 @@ export const getHTTPSKeyCert = cache(async (domain: string): Promise<{ key: stri
40
40
  console.log(magenta(`Renewing domain ${domain} (renew target is ${formatDateTime(renewDate)}).`));
41
41
  keyCert = undefined;
42
42
  }
43
- let timeUntilRenew = renewDate - Date.now();
44
- setTimeout(() => {
45
- console.log(magenta(`Clearing getHTTPSKeyCert to try to renew ${domain} (renew target is ${formatDateTime(renewDate)}).`));
46
- getHTTPSKeyCert.clear(domain);
47
- void getHTTPSKeyCert(domain);
48
- }, Math.min(Math.floor(timeUntilRenew * 1.1), 2 ** 30));
43
+ if (keyCert) {
44
+ let timeUntilRenew = renewDate - Date.now();
45
+ setTimeout(() => {
46
+ console.log(magenta(`Clearing getHTTPSKeyCert to try to renew ${domain} (renew target is ${formatDateTime(renewDate)}).`));
47
+ getHTTPSKeyCert.clear(domain);
48
+ void getHTTPSKeyCert(domain);
49
+ }, Math.min(Math.floor(timeUntilRenew * 1.1), 2 ** 30));
50
+ }
49
51
  } else {
50
52
  console.log(magenta(`No cert found for domain ${domain}, generating shortly.`));
51
53
  }
@@ -230,6 +230,9 @@ export interface WatcherOptions<Result> {
230
230
  /** Only to be used for logging. Is VERY useful in certain circumstances */
231
231
  predictMetadata?: FunctionMetadata;
232
232
 
233
+ /** AKA, isAllSynced is always true. Useful for cases when we want to show partially loaded values. */
234
+ commitAllRuns?: boolean;
235
+
233
236
  // NOTE: The reason there isn't throttle support here is very frequently when you want to throttle one component rendering, it's because you have many components. So you actually want to throttle many components and have them throttle in conjunction with each other, which results in the logic becoming complicated.
234
237
  // - But maybe we should support the single throttle case anyways?
235
238
  }
@@ -2047,7 +2050,12 @@ export class PathValueProxyWatcher {
2047
2050
  return watcher;
2048
2051
  }
2049
2052
 
2050
- public isAllSynced() {
2053
+ public isAllSynced(config?: {
2054
+ ignoreAlwaysCommitAllRunsFlag?: boolean;
2055
+ }) {
2056
+ if (!config?.ignoreAlwaysCommitAllRunsFlag && this.runningWatcher?.options.commitAllRuns) {
2057
+ return true;
2058
+ }
2051
2059
  return !this.getTriggeredWatcherMaybeUndefined()?.hasAnyUnsyncedAccesses();
2052
2060
  }
2053
2061
  /** @deprecated try not to call getTriggeredWatcherMaybeUndefined, and instead try to call Querysub helper
@@ -141,6 +141,11 @@ export interface QComponentStatic {
141
141
  * */
142
142
  multiRendersPerPaint?: boolean;
143
143
 
144
+ /** If true, we will commit render calls even if there are pending syncs (as in, we render in progress).
145
+ * INHERITS, in the same way multiRendersPerPaint does.
146
+ */
147
+ renderInProgress?: boolean;
148
+
144
149
  /** If true, logs time it takes for component to load synced data (if at all), and the paths that were unloaded. */
145
150
  logLoadTime?: boolean;
146
151
  }
@@ -652,6 +657,15 @@ class QRenderClass {
652
657
  }
653
658
  }
654
659
 
660
+ let commitAllRuns = statics.renderInProgress;
661
+ {
662
+ let ancestor = config.parent;
663
+ while (ancestor && commitAllRuns === undefined) {
664
+ commitAllRuns = (ancestor.config.vNode.type as QComponentStatic).renderInProgress;
665
+ ancestor = ancestor.config.parent;
666
+ }
667
+ }
668
+
655
669
  let comparePrevVNode: VirtualDOM | undefined;
656
670
  let lastPropsJSONCopy: { [key: string]: string } | undefined;
657
671
  // Watch render. In it's own watcher so it can write with locks (because most code will only read/write from
@@ -660,6 +674,7 @@ class QRenderClass {
660
674
  debugName: getDebugName("render"),
661
675
  canWrite: true,
662
676
  logSyncTimings: statics.logLoadTime,
677
+ commitAllRuns: commitAllRuns,
663
678
  runOncePerPaint: !multiRendersPerPaint && `${this.debugName}|${self.id}` || undefined,
664
679
  watchFunction() {
665
680
 
@@ -401,8 +401,10 @@ export class Querysub {
401
401
  public static anyUnsynced() {
402
402
  return !Querysub.allSynced();
403
403
  }
404
- public static allSynced() {
405
- return proxyWatcher.isAllSynced();
404
+ public static allSynced(config?: {
405
+ ignoreAlwaysCommitAllRunsFlag?: boolean;
406
+ }) {
407
+ return proxyWatcher.isAllSynced(config);
406
408
  }
407
409
  public static fullySynced = Querysub.allSynced;
408
410
  public static isFullySynced = Querysub.allSynced;