voodoojs 0.6.0 → 0.6.1
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 +32 -8
- package/dist/index.js +32 -8
- package/dist/voodoo.full.js +32 -8
- package/dist/voodoo.full.min.js +35 -35
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -7732,6 +7732,32 @@ function buildUrl(location2) {
|
|
|
7732
7732
|
const base = settings2.base === "/" ? "" : settings2.base.replace(/\/$/, "");
|
|
7733
7733
|
return `${base}${suffix}` || "/";
|
|
7734
7734
|
}
|
|
7735
|
+
var historyRefused = false;
|
|
7736
|
+
var writingHash = false;
|
|
7737
|
+
function writeUrl(state2, url2, replace) {
|
|
7738
|
+
if (!historyRefused) {
|
|
7739
|
+
try {
|
|
7740
|
+
if (replace) window.history.replaceState(state2, "", url2);
|
|
7741
|
+
else window.history.pushState(state2, "", url2);
|
|
7742
|
+
return;
|
|
7743
|
+
} catch (error) {
|
|
7744
|
+
if (!(error instanceof Error) || error.name !== "SecurityError") throw error;
|
|
7745
|
+
historyRefused = true;
|
|
7746
|
+
}
|
|
7747
|
+
}
|
|
7748
|
+
if (settings2.mode !== "hash") return;
|
|
7749
|
+
const hash = url2.slice(url2.indexOf("#"));
|
|
7750
|
+
if (window.location.hash === hash) return;
|
|
7751
|
+
writingHash = true;
|
|
7752
|
+
try {
|
|
7753
|
+
if (replace) window.location.replace(url2);
|
|
7754
|
+
else window.location.hash = hash;
|
|
7755
|
+
} finally {
|
|
7756
|
+
setTimeout(() => {
|
|
7757
|
+
writingHash = false;
|
|
7758
|
+
}, 0);
|
|
7759
|
+
}
|
|
7760
|
+
}
|
|
7735
7761
|
function compileRoute(pattern, record) {
|
|
7736
7762
|
const clean = pattern === "*" ? "*" : normalizePath(pattern);
|
|
7737
7763
|
const raw = clean === "*" ? ["*"] : clean.split("/").filter(Boolean);
|
|
@@ -7918,8 +7944,7 @@ async function navigate(target2, options = {}) {
|
|
|
7918
7944
|
const key = uid("rota");
|
|
7919
7945
|
const historyState = { ...options.state ?? {}, [HISTORY_KEY]: key };
|
|
7920
7946
|
const url2 = buildUrl(destination);
|
|
7921
|
-
|
|
7922
|
-
else window.history.pushState(historyState, "", url2);
|
|
7947
|
+
writeUrl(historyState, url2, options.replace === true);
|
|
7923
7948
|
currentKey = key;
|
|
7924
7949
|
applyLocation(destination);
|
|
7925
7950
|
if (options.scroll !== false) scheduleScroll(destination, from, null);
|
|
@@ -7932,17 +7957,14 @@ async function navigate(target2, options = {}) {
|
|
|
7932
7957
|
return true;
|
|
7933
7958
|
}
|
|
7934
7959
|
async function onHistoryChange(event) {
|
|
7960
|
+
if (writingHash) return;
|
|
7935
7961
|
const { path, query: query2, hash } = readLocation();
|
|
7936
7962
|
const destination = locationFor(path, query2, hash);
|
|
7937
7963
|
const from = snapshot();
|
|
7938
7964
|
if (destination.fullPath === from.fullPath) return;
|
|
7939
7965
|
const verdict = await runGuards(destination, from);
|
|
7940
7966
|
if (verdict === false) {
|
|
7941
|
-
|
|
7942
|
-
{ [HISTORY_KEY]: currentKey },
|
|
7943
|
-
"",
|
|
7944
|
-
buildUrl(from)
|
|
7945
|
-
);
|
|
7967
|
+
writeUrl({ [HISTORY_KEY]: currentKey }, buildUrl(from), true);
|
|
7946
7968
|
devtoolsBus.emit("navigation", {
|
|
7947
7969
|
from: from.fullPath,
|
|
7948
7970
|
to: destination.fullPath,
|
|
@@ -7985,6 +8007,8 @@ function stopRouter() {
|
|
|
7985
8007
|
window.removeEventListener("popstate", historyListener);
|
|
7986
8008
|
window.removeEventListener("hashchange", historyListener);
|
|
7987
8009
|
window.removeEventListener("beforeunload", saveScroll);
|
|
8010
|
+
historyRefused = false;
|
|
8011
|
+
writingHash = false;
|
|
7988
8012
|
}
|
|
7989
8013
|
async function enterInitialRoute() {
|
|
7990
8014
|
if (typeof window === "undefined") return;
|
|
@@ -8005,7 +8029,7 @@ async function enterInitialRoute() {
|
|
|
8005
8029
|
break;
|
|
8006
8030
|
}
|
|
8007
8031
|
currentKey = uid("rota");
|
|
8008
|
-
|
|
8032
|
+
writeUrl({ [HISTORY_KEY]: currentKey }, buildUrl(destination), true);
|
|
8009
8033
|
applyLocation(destination);
|
|
8010
8034
|
if (destination.hash) scheduleScroll(destination, from, null);
|
|
8011
8035
|
settings2.afterEach?.(snapshot(), from);
|
package/dist/index.js
CHANGED
|
@@ -128,6 +128,32 @@ function buildUrl(location) {
|
|
|
128
128
|
const base = settings.base === "/" ? "" : settings.base.replace(/\/$/, "");
|
|
129
129
|
return `${base}${suffix}` || "/";
|
|
130
130
|
}
|
|
131
|
+
var historyRefused = false;
|
|
132
|
+
var writingHash = false;
|
|
133
|
+
function writeUrl(state2, url2, replace) {
|
|
134
|
+
if (!historyRefused) {
|
|
135
|
+
try {
|
|
136
|
+
if (replace) window.history.replaceState(state2, "", url2);
|
|
137
|
+
else window.history.pushState(state2, "", url2);
|
|
138
|
+
return;
|
|
139
|
+
} catch (error) {
|
|
140
|
+
if (!(error instanceof Error) || error.name !== "SecurityError") throw error;
|
|
141
|
+
historyRefused = true;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (settings.mode !== "hash") return;
|
|
145
|
+
const hash = url2.slice(url2.indexOf("#"));
|
|
146
|
+
if (window.location.hash === hash) return;
|
|
147
|
+
writingHash = true;
|
|
148
|
+
try {
|
|
149
|
+
if (replace) window.location.replace(url2);
|
|
150
|
+
else window.location.hash = hash;
|
|
151
|
+
} finally {
|
|
152
|
+
setTimeout(() => {
|
|
153
|
+
writingHash = false;
|
|
154
|
+
}, 0);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
131
157
|
function compileRoute(pattern, record) {
|
|
132
158
|
const clean = pattern === "*" ? "*" : normalizePath(pattern);
|
|
133
159
|
const raw = clean === "*" ? ["*"] : clean.split("/").filter(Boolean);
|
|
@@ -314,8 +340,7 @@ async function navigate(target, options = {}) {
|
|
|
314
340
|
const key = uid("rota");
|
|
315
341
|
const historyState = { ...options.state ?? {}, [HISTORY_KEY]: key };
|
|
316
342
|
const url2 = buildUrl(destination);
|
|
317
|
-
|
|
318
|
-
else window.history.pushState(historyState, "", url2);
|
|
343
|
+
writeUrl(historyState, url2, options.replace === true);
|
|
319
344
|
currentKey = key;
|
|
320
345
|
applyLocation(destination);
|
|
321
346
|
if (options.scroll !== false) scheduleScroll(destination, from, null);
|
|
@@ -328,17 +353,14 @@ async function navigate(target, options = {}) {
|
|
|
328
353
|
return true;
|
|
329
354
|
}
|
|
330
355
|
async function onHistoryChange(event) {
|
|
356
|
+
if (writingHash) return;
|
|
331
357
|
const { path, query: query2, hash } = readLocation();
|
|
332
358
|
const destination = locationFor(path, query2, hash);
|
|
333
359
|
const from = snapshot();
|
|
334
360
|
if (destination.fullPath === from.fullPath) return;
|
|
335
361
|
const verdict = await runGuards(destination, from);
|
|
336
362
|
if (verdict === false) {
|
|
337
|
-
|
|
338
|
-
{ [HISTORY_KEY]: currentKey },
|
|
339
|
-
"",
|
|
340
|
-
buildUrl(from)
|
|
341
|
-
);
|
|
363
|
+
writeUrl({ [HISTORY_KEY]: currentKey }, buildUrl(from), true);
|
|
342
364
|
devtoolsBus.emit("navigation", {
|
|
343
365
|
from: from.fullPath,
|
|
344
366
|
to: destination.fullPath,
|
|
@@ -381,6 +403,8 @@ function stopRouter() {
|
|
|
381
403
|
window.removeEventListener("popstate", historyListener);
|
|
382
404
|
window.removeEventListener("hashchange", historyListener);
|
|
383
405
|
window.removeEventListener("beforeunload", saveScroll);
|
|
406
|
+
historyRefused = false;
|
|
407
|
+
writingHash = false;
|
|
384
408
|
}
|
|
385
409
|
async function enterInitialRoute() {
|
|
386
410
|
if (typeof window === "undefined") return;
|
|
@@ -401,7 +425,7 @@ async function enterInitialRoute() {
|
|
|
401
425
|
break;
|
|
402
426
|
}
|
|
403
427
|
currentKey = uid("rota");
|
|
404
|
-
|
|
428
|
+
writeUrl({ [HISTORY_KEY]: currentKey }, buildUrl(destination), true);
|
|
405
429
|
applyLocation(destination);
|
|
406
430
|
if (destination.hash) scheduleScroll(destination, from, null);
|
|
407
431
|
settings.afterEach?.(snapshot(), from);
|
package/dist/voodoo.full.js
CHANGED
|
@@ -7855,6 +7855,32 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
|
|
|
7855
7855
|
const base = settings2.base === "/" ? "" : settings2.base.replace(/\/$/, "");
|
|
7856
7856
|
return `${base}${suffix}` || "/";
|
|
7857
7857
|
}
|
|
7858
|
+
var historyRefused = false;
|
|
7859
|
+
var writingHash = false;
|
|
7860
|
+
function writeUrl(state2, url2, replace) {
|
|
7861
|
+
if (!historyRefused) {
|
|
7862
|
+
try {
|
|
7863
|
+
if (replace) window.history.replaceState(state2, "", url2);
|
|
7864
|
+
else window.history.pushState(state2, "", url2);
|
|
7865
|
+
return;
|
|
7866
|
+
} catch (error) {
|
|
7867
|
+
if (!(error instanceof Error) || error.name !== "SecurityError") throw error;
|
|
7868
|
+
historyRefused = true;
|
|
7869
|
+
}
|
|
7870
|
+
}
|
|
7871
|
+
if (settings2.mode !== "hash") return;
|
|
7872
|
+
const hash = url2.slice(url2.indexOf("#"));
|
|
7873
|
+
if (window.location.hash === hash) return;
|
|
7874
|
+
writingHash = true;
|
|
7875
|
+
try {
|
|
7876
|
+
if (replace) window.location.replace(url2);
|
|
7877
|
+
else window.location.hash = hash;
|
|
7878
|
+
} finally {
|
|
7879
|
+
setTimeout(() => {
|
|
7880
|
+
writingHash = false;
|
|
7881
|
+
}, 0);
|
|
7882
|
+
}
|
|
7883
|
+
}
|
|
7858
7884
|
function compileRoute(pattern, record) {
|
|
7859
7885
|
const clean = pattern === "*" ? "*" : normalizePath(pattern);
|
|
7860
7886
|
const raw = clean === "*" ? ["*"] : clean.split("/").filter(Boolean);
|
|
@@ -8045,8 +8071,7 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
|
|
|
8045
8071
|
const key = uid("rota");
|
|
8046
8072
|
const historyState = { ...(_a2 = options.state) != null ? _a2 : {}, [HISTORY_KEY]: key };
|
|
8047
8073
|
const url2 = buildUrl(destination);
|
|
8048
|
-
|
|
8049
|
-
else window.history.pushState(historyState, "", url2);
|
|
8074
|
+
writeUrl(historyState, url2, options.replace === true);
|
|
8050
8075
|
currentKey = key;
|
|
8051
8076
|
applyLocation(destination);
|
|
8052
8077
|
if (options.scroll !== false) scheduleScroll(destination, from, null);
|
|
@@ -8060,17 +8085,14 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
|
|
|
8060
8085
|
}
|
|
8061
8086
|
async function onHistoryChange(event) {
|
|
8062
8087
|
var _a2, _b;
|
|
8088
|
+
if (writingHash) return;
|
|
8063
8089
|
const { path, query: query2, hash } = readLocation();
|
|
8064
8090
|
const destination = locationFor(path, query2, hash);
|
|
8065
8091
|
const from = snapshot();
|
|
8066
8092
|
if (destination.fullPath === from.fullPath) return;
|
|
8067
8093
|
const verdict = await runGuards(destination, from);
|
|
8068
8094
|
if (verdict === false) {
|
|
8069
|
-
|
|
8070
|
-
{ [HISTORY_KEY]: currentKey },
|
|
8071
|
-
"",
|
|
8072
|
-
buildUrl(from)
|
|
8073
|
-
);
|
|
8095
|
+
writeUrl({ [HISTORY_KEY]: currentKey }, buildUrl(from), true);
|
|
8074
8096
|
devtoolsBus.emit("navigation", {
|
|
8075
8097
|
from: from.fullPath,
|
|
8076
8098
|
to: destination.fullPath,
|
|
@@ -8113,6 +8135,8 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
|
|
|
8113
8135
|
window.removeEventListener("popstate", historyListener);
|
|
8114
8136
|
window.removeEventListener("hashchange", historyListener);
|
|
8115
8137
|
window.removeEventListener("beforeunload", saveScroll);
|
|
8138
|
+
historyRefused = false;
|
|
8139
|
+
writingHash = false;
|
|
8116
8140
|
}
|
|
8117
8141
|
async function enterInitialRoute() {
|
|
8118
8142
|
var _a2;
|
|
@@ -8134,7 +8158,7 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
|
|
|
8134
8158
|
break;
|
|
8135
8159
|
}
|
|
8136
8160
|
currentKey = uid("rota");
|
|
8137
|
-
|
|
8161
|
+
writeUrl({ [HISTORY_KEY]: currentKey }, buildUrl(destination), true);
|
|
8138
8162
|
applyLocation(destination);
|
|
8139
8163
|
if (destination.hash) scheduleScroll(destination, from, null);
|
|
8140
8164
|
(_a2 = settings2.afterEach) == null ? void 0 : _a2.call(settings2, snapshot(), from);
|