pinokiod 8.0.67 → 8.0.68

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": "pinokiod",
3
- "version": "8.0.67",
3
+ "version": "8.0.68",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -186,12 +186,21 @@
186
186
  !event.data || typeof event.data !== "object") return
187
187
  if (event.data.e === "vault-automatic-scan-state" &&
188
188
  window.parent !== window && event.source === window.parent) {
189
+ const firstParentState = parentStateVersion === 0
189
190
  parentStateVersion += 1
190
191
  if (fallbackTimer !== null) {
191
192
  window.clearTimeout(fallbackTimer)
192
193
  fallbackTimer = null
193
194
  }
194
- applySnapshot(event.data.snapshot)
195
+ const snapshot = normalizeSnapshot(event.data.snapshot)
196
+ const result = snapshot.rows.find((item) => item.app === app)
197
+ const currentSignature = status.dataset.resultSignature || ""
198
+ const parentSignature = result ? result.signature : ""
199
+ if (firstParentState && currentSignature && currentSignature !== parentSignature) {
200
+ loadState()
201
+ return
202
+ }
203
+ applySnapshot(snapshot)
195
204
  relaySnapshot()
196
205
  return
197
206
  }
@@ -576,3 +576,61 @@ test("a late parent state is not overwritten by the app badge fallback", async (
576
576
  dom.window.close()
577
577
  parent.window.close()
578
578
  })
579
+
580
+ test("a stale parent replay cannot clear a server-rendered result", async () => {
581
+ const script = await fs.promises.readFile(
582
+ path.join(root, "server", "public", "app-vault-mode.js"), "utf8")
583
+ const signature = "d".repeat(64)
584
+ const parent = new JSDOM("", { url: "http://localhost/" })
585
+ const dom = new JSDOM(`<a id="save-space-tab">
586
+ <span data-app-vault-result-badge></span>
587
+ <span data-app-vault-mode data-app="ComfyUI" data-mode="automatic"
588
+ data-ready="true" data-result-signature="${signature}">
589
+ <span data-app-vault-mode-label>Auto</span>
590
+ </span>
591
+ </a>`, {
592
+ runScripts: "outside-only",
593
+ url: "http://localhost/v/ComfyUI"
594
+ })
595
+ Object.defineProperty(dom.window, "parent", {
596
+ configurable: true,
597
+ value: parent.window
598
+ })
599
+ parent.window.postMessage = () => {}
600
+ const requests = []
601
+ dom.window.fetch = async (url) => {
602
+ requests.push(url)
603
+ return {
604
+ ok: true,
605
+ json: async () => ({
606
+ global_scan_ready: true,
607
+ rows: [{ app: "ComfyUI", state: "result", signature }],
608
+ settings: [{ app: "ComfyUI", mode: "automatic" }]
609
+ })
610
+ }
611
+ }
612
+
613
+ dom.window.eval(script)
614
+ dom.window.dispatchEvent(new dom.window.MessageEvent("message", {
615
+ source: parent.window,
616
+ origin: "http://localhost",
617
+ data: {
618
+ e: "vault-automatic-scan-state",
619
+ snapshot: {
620
+ global_scan_ready: true,
621
+ rows: [],
622
+ settings: []
623
+ }
624
+ }
625
+ }))
626
+
627
+ await waitFor(() => requests.length === 1)
628
+ assert.deepEqual(requests, ["/info/vault/automatic-scans"])
629
+ assert.equal(dom.window.document.querySelector(
630
+ "[data-app-vault-result-badge]").hidden, false)
631
+ assert.equal(dom.window.document.querySelector(
632
+ "[data-app-vault-mode]").dataset.resultSignature, signature)
633
+
634
+ dom.window.close()
635
+ parent.window.close()
636
+ })