@aprovan/patchwork-compiler 0.1.2-dev.99f9769 → 0.1.2-dev.9c336a0
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/dist/index.cjs +35 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +34 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -88,7 +88,7 @@ __export(index_exports, {
|
|
|
88
88
|
});
|
|
89
89
|
module.exports = __toCommonJS(index_exports);
|
|
90
90
|
|
|
91
|
-
// ../../node_modules/.pnpm/tsup@8.5.1_jiti@1.21.7_postcss@8.5.
|
|
91
|
+
// ../../node_modules/.pnpm/tsup@8.5.1_jiti@1.21.7_postcss@8.5.18_tsx@4.23.0_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js
|
|
92
92
|
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
93
93
|
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
94
94
|
|
|
@@ -2577,37 +2577,46 @@ var HttpBackend = class {
|
|
|
2577
2577
|
const res = await fetch(this.url(path), { method: "HEAD" });
|
|
2578
2578
|
return res.ok;
|
|
2579
2579
|
}
|
|
2580
|
-
watch(
|
|
2580
|
+
watch(_path, callback) {
|
|
2581
2581
|
const controller = new AbortController();
|
|
2582
|
-
this.
|
|
2582
|
+
this.startPoll(callback, controller.signal);
|
|
2583
2583
|
return () => controller.abort();
|
|
2584
2584
|
}
|
|
2585
|
-
async
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
if (
|
|
2591
|
-
const
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
const
|
|
2598
|
-
|
|
2599
|
-
for (const line of lines) {
|
|
2600
|
-
if (line.startsWith("data: ")) {
|
|
2601
|
-
try {
|
|
2602
|
-
const event = JSON.parse(line.slice(6));
|
|
2603
|
-
callback(event.type, event.path);
|
|
2604
|
-
} catch {
|
|
2605
|
-
}
|
|
2606
|
-
}
|
|
2585
|
+
async startPoll(callback, signal) {
|
|
2586
|
+
const intervalMs = this.config.pollIntervalMs ?? 7e3;
|
|
2587
|
+
let since = (/* @__PURE__ */ new Date()).toISOString();
|
|
2588
|
+
const poll = async () => {
|
|
2589
|
+
if (signal.aborted) return;
|
|
2590
|
+
if (typeof document !== "undefined" && document.visibilityState !== "visible") return;
|
|
2591
|
+
const pollStart = (/* @__PURE__ */ new Date()).toISOString();
|
|
2592
|
+
try {
|
|
2593
|
+
const res = await fetch(this.url("", { since }), { signal });
|
|
2594
|
+
if (!res.ok) return;
|
|
2595
|
+
const changes = await res.json();
|
|
2596
|
+
since = pollStart;
|
|
2597
|
+
for (const change of changes) {
|
|
2598
|
+
callback("update", change.path);
|
|
2607
2599
|
}
|
|
2600
|
+
} catch {
|
|
2608
2601
|
}
|
|
2609
|
-
}
|
|
2602
|
+
};
|
|
2603
|
+
await poll();
|
|
2604
|
+
if (signal.aborted) return;
|
|
2605
|
+
const timer = setInterval(() => void poll(), intervalMs);
|
|
2606
|
+
const onVisibilityChange = () => {
|
|
2607
|
+
if (typeof document !== "undefined" && document.visibilityState === "visible") {
|
|
2608
|
+
void poll();
|
|
2609
|
+
}
|
|
2610
|
+
};
|
|
2611
|
+
if (typeof document !== "undefined") {
|
|
2612
|
+
document.addEventListener("visibilitychange", onVisibilityChange);
|
|
2610
2613
|
}
|
|
2614
|
+
signal.addEventListener("abort", () => {
|
|
2615
|
+
clearInterval(timer);
|
|
2616
|
+
if (typeof document !== "undefined") {
|
|
2617
|
+
document.removeEventListener("visibilitychange", onVisibilityChange);
|
|
2618
|
+
}
|
|
2619
|
+
});
|
|
2611
2620
|
}
|
|
2612
2621
|
url(path, params) {
|
|
2613
2622
|
const baseUrl = this.config.baseUrl.replace(/\/+$/, "");
|