@antelopejs/dms 0.25.4 → 0.25.5
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v0.25.5
|
|
4
|
+
|
|
5
|
+
[compare changes](https://github.com/AntelopeJS/dms/compare/v0.25.4...v0.25.5)
|
|
6
|
+
|
|
7
|
+
### 🩹 Fixes
|
|
8
|
+
|
|
9
|
+
- **dms:** Reload the site layout again when a navigation cancels the resync's reload ([#1314](https://github.com/AntelopeJS/dms/pull/1314))
|
|
10
|
+
|
|
11
|
+
### 📦 Build
|
|
12
|
+
|
|
13
|
+
- **deps:** Bump tooling-configs to 0.10.15 and run sync ([#1312](https://github.com/AntelopeJS/dms/pull/1312))
|
|
14
|
+
|
|
15
|
+
### ❤️ Contributors
|
|
16
|
+
|
|
17
|
+
- Antony Rizzitelli
|
|
18
|
+
|
|
3
19
|
## v0.25.4
|
|
4
20
|
|
|
5
21
|
[compare changes](https://github.com/AntelopeJS/dms/compare/v0.25.3...v0.25.4)
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { router as inertiaRouter } from "@inertiajs/vue3";
|
|
2
|
+
|
|
3
|
+
/** How long a cancelled reload waits for the page to settle before it starts again anyway. */
|
|
4
|
+
const SETTLE_TIMEOUT_MS = 2_000;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Resolves once the page on screen settles after a visit cancelled a reload:
|
|
8
|
+
* Inertia sets a new page (a visit, a prefetched one or a history step), a
|
|
9
|
+
* visit that was neither cancelled nor interrupted finishes, or
|
|
10
|
+
* `SETTLE_TIMEOUT_MS` pass, so a cancellation that nothing follows cannot
|
|
11
|
+
* hold the resync.
|
|
12
|
+
*/
|
|
13
|
+
function pageSettled(): Promise<void> {
|
|
14
|
+
return new Promise((resolve) => {
|
|
15
|
+
const stops = [
|
|
16
|
+
inertiaRouter.on("navigate", () => settle()),
|
|
17
|
+
inertiaRouter.on("finish", (event) => {
|
|
18
|
+
const { visit } = event.detail;
|
|
19
|
+
if (!visit.cancelled && !visit.interrupted) settle();
|
|
20
|
+
}),
|
|
21
|
+
];
|
|
22
|
+
const timer = setTimeout(() => settle(), SETTLE_TIMEOUT_MS);
|
|
23
|
+
function settle(): void {
|
|
24
|
+
clearTimeout(timer);
|
|
25
|
+
for (const stop of stops) stop();
|
|
26
|
+
resolve();
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A partial reload of the page on screen: the server sends the site layout
|
|
33
|
+
* and the page fresh, and they replace the browser's copies, the layout
|
|
34
|
+
* Inertia carries from page to page included. Resolves `landed` when its
|
|
35
|
+
* answer reached the page, a redirect included. Resolves `cancelled` when a
|
|
36
|
+
* visit cancelled or interrupted it, and `dropped` when another visit or a
|
|
37
|
+
* history step set a page while it ran, which makes Inertia drop its answer:
|
|
38
|
+
* both leave the layout the browser holds. A failure rejects and leaves the
|
|
39
|
+
* page as it is: Inertia would otherwise show the error in its place.
|
|
40
|
+
*/
|
|
41
|
+
function reloadSiteLayoutAndPage(): Promise<
|
|
42
|
+
"landed" | "cancelled" | "dropped"
|
|
43
|
+
> {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
let failure: Error | undefined;
|
|
46
|
+
const pagesSetBy: Array<string | undefined> = [];
|
|
47
|
+
const stopWatching = inertiaRouter.on("navigate", (event) => {
|
|
48
|
+
pagesSetBy.push(event.detail.visitId);
|
|
49
|
+
});
|
|
50
|
+
const reload = (): void =>
|
|
51
|
+
inertiaRouter.reload({
|
|
52
|
+
only: ["shared", "page"],
|
|
53
|
+
onHttpException: (response) => {
|
|
54
|
+
failure = new Error(`Site layout reload failed (${response.status})`);
|
|
55
|
+
return false;
|
|
56
|
+
},
|
|
57
|
+
onNetworkError: (error) => {
|
|
58
|
+
failure = error;
|
|
59
|
+
return false;
|
|
60
|
+
},
|
|
61
|
+
onFinish: (visit) => {
|
|
62
|
+
stopWatching();
|
|
63
|
+
if (failure) reject(failure);
|
|
64
|
+
else if (visit.cancelled || visit.interrupted) resolve("cancelled");
|
|
65
|
+
else if (pagesSetBy.some((visitId) => visitId !== visit.id)) {
|
|
66
|
+
resolve("dropped");
|
|
67
|
+
} else resolve("landed");
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
try {
|
|
71
|
+
reload();
|
|
72
|
+
} catch (error) {
|
|
73
|
+
stopWatching();
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Reloads the site layout and the page on screen until a reload lands: once
|
|
81
|
+
* the page settles after a visit cancelled it, and again at once when
|
|
82
|
+
* another page was set while it ran. Each reload that does not land follows
|
|
83
|
+
* a visit, so this ends once navigation stops.
|
|
84
|
+
*/
|
|
85
|
+
export async function resyncSiteLayout(): Promise<void> {
|
|
86
|
+
inertiaRouter.flushAll();
|
|
87
|
+
for (;;) {
|
|
88
|
+
const outcome = await reloadSiteLayoutAndPage();
|
|
89
|
+
if (outcome === "landed") return;
|
|
90
|
+
if (outcome === "cancelled") await pageSettled();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { router as inertiaRouter } from "@inertiajs/vue3";
|
|
2
1
|
import { layoutUrlWithQuery } from "../../utils/pageQuery";
|
|
2
|
+
import { resyncSiteLayout } from "../../build/utils/siteLayoutResync";
|
|
3
3
|
import { onBeforeMount, toRaw } from "vue";
|
|
4
4
|
import { withoutTrailingSlash } from "ufo";
|
|
5
5
|
|
|
@@ -100,30 +100,6 @@ export function extractRouteParams(
|
|
|
100
100
|
return buildParamBag(paramNames, match.slice(1));
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
/**
|
|
104
|
-
* A partial reload of the page on screen: the server sends the site layout
|
|
105
|
-
* and the page fresh, and they replace the browser's copies, the layout
|
|
106
|
-
* Inertia carries from page to page included. A failure rejects and leaves
|
|
107
|
-
* the page as it is: Inertia would otherwise show the error in its place.
|
|
108
|
-
*/
|
|
109
|
-
function reloadSiteLayoutAndPage(): Promise<void> {
|
|
110
|
-
return new Promise((resolve, reject) => {
|
|
111
|
-
let failure: Error | undefined;
|
|
112
|
-
inertiaRouter.reload({
|
|
113
|
-
only: ["shared", "page"],
|
|
114
|
-
onHttpException: (response) => {
|
|
115
|
-
failure = new Error(`Site layout reload failed (${response.status})`);
|
|
116
|
-
return false;
|
|
117
|
-
},
|
|
118
|
-
onNetworkError: (error) => {
|
|
119
|
-
failure = error;
|
|
120
|
-
return false;
|
|
121
|
-
},
|
|
122
|
-
onFinish: () => (failure ? reject(failure) : resolve()),
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
103
|
interface SiteLayoutResponse {
|
|
128
104
|
siteLayout: SiteLayout;
|
|
129
105
|
siteLayoutTree: SiteLayoutTree;
|
|
@@ -310,13 +286,6 @@ const useSiteLayoutRequests = () => {
|
|
|
310
286
|
await loadingPromise.value;
|
|
311
287
|
};
|
|
312
288
|
|
|
313
|
-
const resync = async (): Promise<void> => {
|
|
314
|
-
inertiaRouter.flushAll();
|
|
315
|
-
const path = window.location.pathname;
|
|
316
|
-
await reloadSiteLayoutAndPage();
|
|
317
|
-
if (window.location.pathname !== path) await reloadSiteLayoutAndPage();
|
|
318
|
-
};
|
|
319
|
-
|
|
320
289
|
const refreshIfStale = async () => {
|
|
321
290
|
const elapsed = Date.now() - lastRefreshTime.value;
|
|
322
291
|
if (elapsed < STALE_THRESHOLD_MS) {
|
|
@@ -338,7 +307,7 @@ const useSiteLayoutRequests = () => {
|
|
|
338
307
|
loadingError,
|
|
339
308
|
loadSiteLayout,
|
|
340
309
|
refresh,
|
|
341
|
-
resync,
|
|
310
|
+
resync: resyncSiteLayout,
|
|
342
311
|
differsFromServer: () => siteLayoutDiffersFromServer(state),
|
|
343
312
|
refreshIfStale,
|
|
344
313
|
clearPageLayoutCaches,
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@antelopejs/core": "~1.24.5",
|
|
82
82
|
"@antelopejs/dms-frontend": ">=0.11.11 <0.12.0",
|
|
83
|
-
"@antelopejs/tooling-configs": ">=0.10.
|
|
83
|
+
"@antelopejs/tooling-configs": ">=0.10.15 <0.11.0",
|
|
84
84
|
"@inertiajs/vue3": "^3.7.0",
|
|
85
85
|
"@nuxt/eslint-config": "^1.17.0",
|
|
86
86
|
"@nuxt/ui": "4.10.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/dms",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.5",
|
|
4
4
|
"description": "AntelopeJS DMS. Plug in your PostgreSQL, MySQL, MariaDB, MongoDB or RethinkDB database and your coding agent builds a back office and analytics dashboard as typed TypeScript. Real-time updates on the data the DMS manages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antelopejs",
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"@antelopejs/mysql": ">=0.2.7 <0.3.0",
|
|
121
121
|
"@antelopejs/postgres": ">=0.4.3 <0.5.0",
|
|
122
122
|
"@antelopejs/rethinkdb": "~1.10.6",
|
|
123
|
-
"@antelopejs/tooling-configs": ">=0.10.
|
|
123
|
+
"@antelopejs/tooling-configs": ">=0.10.15 <0.11.0",
|
|
124
124
|
"@playwright/test": "~1.65.0",
|
|
125
125
|
"@types/archiver": "^6.0.4",
|
|
126
126
|
"@types/chai": "^5.0.0",
|
|
@@ -211,7 +211,7 @@
|
|
|
211
211
|
"optional": true
|
|
212
212
|
}
|
|
213
213
|
},
|
|
214
|
-
"gitHead": "
|
|
214
|
+
"gitHead": "14882bcecbabddf327fda55484ca753409e07aa7",
|
|
215
215
|
"scripts": {
|
|
216
216
|
"build": "pnpm --filter @antelopejs/interface-dms --filter @antelopejs/interface-dms-builder build && rimraf dist && antelopejs-tsc && tsc-alias && tsc -p e2e/tsconfig.types.json",
|
|
217
217
|
"dev": "ajs project run --inspect -w -p playground",
|