@alignable/bifrost 0.0.14 → 0.0.15
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/chunk-4DL7N7Y5.js +17 -0
- package/dist/chunk-4DL7N7Y5.js.map +1 -0
- package/dist/chunk-ABW2IXO4.js +936 -0
- package/dist/chunk-ABW2IXO4.js.map +1 -0
- package/dist/chunk-AIK6VRNF.js +20 -0
- package/dist/chunk-AIK6VRNF.js.map +1 -0
- package/dist/chunk-CXNEKD7R.js +9 -0
- package/dist/chunk-CXNEKD7R.js.map +1 -0
- package/dist/chunk-EYYCKU6F.js +11 -0
- package/dist/chunk-EYYCKU6F.js.map +1 -0
- package/dist/chunk-LEUA73GT.js +26 -0
- package/dist/chunk-LEUA73GT.js.map +1 -0
- package/dist/chunk-RQ34EW7E.js +13 -0
- package/dist/chunk-RQ34EW7E.js.map +1 -0
- package/dist/index.d.ts +13 -7
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -0
- package/dist/internal-fe09ebc7.d.ts +72 -0
- package/dist/proxy/pages/+config.d.ts +2 -2
- package/dist/proxy/pages/+config.js +17 -12
- package/dist/proxy/pages/+config.js.map +1 -0
- package/dist/proxy/pages/Page.d.ts +3 -2
- package/dist/proxy/pages/Page.js +7 -3
- package/dist/proxy/pages/Page.js.map +1 -0
- package/dist/proxy/pages/onBeforeRender.d.ts +9 -3
- package/dist/proxy/pages/onBeforeRender.js +9 -5
- package/dist/proxy/pages/onBeforeRender.js.map +1 -0
- package/dist/proxy/pages/onRenderClient.d.ts +9 -3
- package/dist/proxy/pages/onRenderClient.js +59 -51
- package/dist/proxy/pages/onRenderClient.js.map +1 -0
- package/dist/proxy/pages/onRenderHtml.d.ts +11 -4
- package/dist/proxy/pages/onRenderHtml.js +54 -39
- package/dist/proxy/pages/onRenderHtml.js.map +1 -0
- package/dist/proxy/pages/restorationVisit/+config.d.ts +2 -2
- package/dist/proxy/pages/restorationVisit/+config.js +19 -14
- package/dist/proxy/pages/restorationVisit/+config.js.map +1 -0
- package/dist/proxy/pages/restorationVisit/onRenderClient.d.ts +9 -3
- package/dist/proxy/pages/restorationVisit/onRenderClient.js +49 -39
- package/dist/proxy/pages/restorationVisit/onRenderClient.js.map +1 -0
- package/dist/proxy/pages/restorationVisit/route.d.ts +3 -2
- package/dist/proxy/pages/restorationVisit/route.js +7 -3
- package/dist/proxy/pages/restorationVisit/route.js.map +1 -0
- package/dist/renderer/+config.d.ts +2 -5
- package/dist/renderer/+config.js +25 -14
- package/dist/renderer/+config.js.map +1 -0
- package/dist/renderer/_error/Page.d.ts +2 -3
- package/dist/renderer/_error/Page.js +11 -12
- package/dist/renderer/_error/Page.js.map +1 -0
- package/dist/renderer/getConfigOrPageContext.d.ts +9 -4
- package/dist/renderer/getConfigOrPageContext.js +7 -6
- package/dist/renderer/getConfigOrPageContext.js.map +1 -0
- package/dist/renderer/onBeforeRoute.d.ts +3 -2
- package/dist/renderer/onBeforeRoute.js +28 -20
- package/dist/renderer/onBeforeRoute.js.map +1 -0
- package/dist/renderer/onRenderClient.d.ts +9 -3
- package/dist/renderer/onRenderClient.js +53 -38
- package/dist/renderer/onRenderClient.js.map +1 -0
- package/dist/renderer/onRenderHtml.d.ts +11 -4
- package/dist/renderer/onRenderHtml.js +43 -23
- package/dist/renderer/onRenderHtml.js.map +1 -0
- package/dist/renderer/usePageContext.d.ts +7 -4
- package/dist/renderer/usePageContext.js +10 -21
- package/dist/renderer/usePageContext.js.map +1 -0
- package/dist/renderer/utils/buildHead.d.ts +9 -4
- package/dist/renderer/utils/buildHead.js +7 -10
- package/dist/renderer/utils/buildHead.js.map +1 -0
- package/dist/renderer/utils/getGlobalObject.d.ts +3 -2
- package/dist/renderer/utils/getGlobalObject.js +7 -8
- package/dist/renderer/utils/getGlobalObject.js.map +1 -0
- package/package.json +5 -4
- package/dist/index.d.ts.map +0 -1
- package/dist/lib/PageShell.d.ts +0 -7
- package/dist/lib/PageShell.d.ts.map +0 -1
- package/dist/lib/PageShell.js +0 -6
- package/dist/lib/getElementAttributes.d.ts +0 -2
- package/dist/lib/getElementAttributes.d.ts.map +0 -1
- package/dist/lib/getElementAttributes.js +0 -7
- package/dist/lib/renderReact.d.ts +0 -3
- package/dist/lib/renderReact.d.ts.map +0 -1
- package/dist/lib/renderReact.js +0 -14
- package/dist/lib/turbolinks/adapter.d.ts +0 -17
- package/dist/lib/turbolinks/adapter.d.ts.map +0 -1
- package/dist/lib/turbolinks/adapter.js +0 -1
- package/dist/lib/turbolinks/browser_adapter.d.ts +0 -28
- package/dist/lib/turbolinks/browser_adapter.d.ts.map +0 -1
- package/dist/lib/turbolinks/browser_adapter.js +0 -68
- package/dist/lib/turbolinks/controller.d.ts +0 -75
- package/dist/lib/turbolinks/controller.d.ts.map +0 -1
- package/dist/lib/turbolinks/controller.js +0 -219
- package/dist/lib/turbolinks/head_details.d.ts +0 -24
- package/dist/lib/turbolinks/head_details.d.ts.map +0 -1
- package/dist/lib/turbolinks/head_details.js +0 -97
- package/dist/lib/turbolinks/index.d.ts +0 -14
- package/dist/lib/turbolinks/index.d.ts.map +0 -1
- package/dist/lib/turbolinks/index.js +0 -55
- package/dist/lib/turbolinks/location.d.ts +0 -23
- package/dist/lib/turbolinks/location.d.ts.map +0 -1
- package/dist/lib/turbolinks/location.js +0 -75
- package/dist/lib/turbolinks/lruCache.d.ts +0 -8
- package/dist/lib/turbolinks/lruCache.d.ts.map +0 -1
- package/dist/lib/turbolinks/lruCache.js +0 -25
- package/dist/lib/turbolinks/mergeHead.d.ts +0 -2
- package/dist/lib/turbolinks/mergeHead.d.ts.map +0 -1
- package/dist/lib/turbolinks/mergeHead.js +0 -120
- package/dist/lib/turbolinks/progress_bar.d.ts +0 -24
- package/dist/lib/turbolinks/progress_bar.d.ts.map +0 -1
- package/dist/lib/turbolinks/progress_bar.js +0 -99
- package/dist/lib/turbolinks/types.d.ts +0 -7
- package/dist/lib/turbolinks/types.d.ts.map +0 -1
- package/dist/lib/turbolinks/types.js +0 -3
- package/dist/lib/turbolinks/util.d.ts +0 -18
- package/dist/lib/turbolinks/util.d.ts.map +0 -1
- package/dist/lib/turbolinks/util.js +0 -125
- package/dist/lib/turbolinks/visit.d.ts +0 -55
- package/dist/lib/turbolinks/visit.d.ts.map +0 -1
- package/dist/lib/turbolinks/visit.js +0 -163
- package/dist/proxy/pages/+config.d.ts.map +0 -1
- package/dist/proxy/pages/Page.d.ts.map +0 -1
- package/dist/proxy/pages/onBeforeRender.d.ts.map +0 -1
- package/dist/proxy/pages/onRenderClient.d.ts.map +0 -1
- package/dist/proxy/pages/onRenderHtml.d.ts.map +0 -1
- package/dist/proxy/pages/restorationVisit/+config.d.ts.map +0 -1
- package/dist/proxy/pages/restorationVisit/onRenderClient.d.ts.map +0 -1
- package/dist/proxy/pages/restorationVisit/route.d.ts.map +0 -1
- package/dist/renderer/+config.d.ts.map +0 -1
- package/dist/renderer/_error/Page.d.ts.map +0 -1
- package/dist/renderer/getConfigOrPageContext.d.ts.map +0 -1
- package/dist/renderer/onBeforeRoute.d.ts.map +0 -1
- package/dist/renderer/onRenderClient.d.ts.map +0 -1
- package/dist/renderer/onRenderHtml.d.ts.map +0 -1
- package/dist/renderer/usePageContext.d.ts.map +0 -1
- package/dist/renderer/utils/buildHead.d.ts.map +0 -1
- package/dist/renderer/utils/getGlobalObject.d.ts.map +0 -1
- package/dist/types/internal.d.ts +0 -64
- package/dist/types/internal.d.ts.map +0 -1
- package/dist/types/internal.js +0 -1
|
@@ -0,0 +1,936 @@
|
|
|
1
|
+
// lib/renderReact.ts
|
|
2
|
+
import { createRoot, hydrateRoot } from "react-dom/client";
|
|
3
|
+
var root;
|
|
4
|
+
function renderReact(page, isHydration) {
|
|
5
|
+
const container = document.getElementById("page-view");
|
|
6
|
+
if (isHydration) {
|
|
7
|
+
root = hydrateRoot(container, page);
|
|
8
|
+
} else {
|
|
9
|
+
if (!root) {
|
|
10
|
+
root = createRoot(container);
|
|
11
|
+
}
|
|
12
|
+
root.render(page);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// lib/turbolinks/util.ts
|
|
17
|
+
function array(values) {
|
|
18
|
+
return Array.prototype.slice.call(values);
|
|
19
|
+
}
|
|
20
|
+
var closest = (() => {
|
|
21
|
+
const html = document.documentElement;
|
|
22
|
+
const match = html.matches || html.webkitMatchesSelector || html.msMatchesSelector || html.mozMatchesSelector;
|
|
23
|
+
const closest2 = html.closest || function(selector) {
|
|
24
|
+
let element = this;
|
|
25
|
+
while (element) {
|
|
26
|
+
if (match.call(element, selector)) {
|
|
27
|
+
return element;
|
|
28
|
+
} else {
|
|
29
|
+
element = element.parentElement;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
return function(element, selector) {
|
|
34
|
+
return closest2.call(element, selector);
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
37
|
+
function defer(callback) {
|
|
38
|
+
setTimeout(callback, 1);
|
|
39
|
+
}
|
|
40
|
+
function dispatch(eventName, { target, cancelable, data } = {}) {
|
|
41
|
+
const event = document.createEvent("Events");
|
|
42
|
+
event.initEvent(eventName, true, cancelable == true);
|
|
43
|
+
event.data = data || {};
|
|
44
|
+
if (event.cancelable && !preventDefaultSupported) {
|
|
45
|
+
const { preventDefault } = event;
|
|
46
|
+
event.preventDefault = function() {
|
|
47
|
+
if (!this.defaultPrevented) {
|
|
48
|
+
Object.defineProperty(this, "defaultPrevented", { get: () => true });
|
|
49
|
+
}
|
|
50
|
+
preventDefault.call(this);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
(target || document).dispatchEvent(event);
|
|
54
|
+
return event;
|
|
55
|
+
}
|
|
56
|
+
var preventDefaultSupported = (() => {
|
|
57
|
+
const event = document.createEvent("Events");
|
|
58
|
+
event.initEvent("test", true, true);
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
return event.defaultPrevented;
|
|
61
|
+
})();
|
|
62
|
+
function unindent(strings, ...values) {
|
|
63
|
+
const lines = trimLeft(interpolate(strings, values)).split("\n");
|
|
64
|
+
const match = lines[0].match(/^\s+/);
|
|
65
|
+
const indent = match ? match[0].length : 0;
|
|
66
|
+
return lines.map((line) => line.slice(indent)).join("\n");
|
|
67
|
+
}
|
|
68
|
+
function trimLeft(string) {
|
|
69
|
+
return string.replace(/^\n/, "");
|
|
70
|
+
}
|
|
71
|
+
function interpolate(strings, values) {
|
|
72
|
+
return strings.reduce((result, string, i) => {
|
|
73
|
+
const value = values[i] == void 0 ? "" : values[i];
|
|
74
|
+
return result + string + value;
|
|
75
|
+
}, "");
|
|
76
|
+
}
|
|
77
|
+
function uuid() {
|
|
78
|
+
return Array.apply(null, { length: 36 }).map((_, i) => {
|
|
79
|
+
if (i == 8 || i == 13 || i == 18 || i == 23) {
|
|
80
|
+
return "-";
|
|
81
|
+
} else if (i == 14) {
|
|
82
|
+
return "4";
|
|
83
|
+
} else if (i == 19) {
|
|
84
|
+
return (Math.floor(Math.random() * 4) + 8).toString(16);
|
|
85
|
+
} else {
|
|
86
|
+
return Math.floor(Math.random() * 15).toString(16);
|
|
87
|
+
}
|
|
88
|
+
}).join("");
|
|
89
|
+
}
|
|
90
|
+
function createScriptElement(element, cb) {
|
|
91
|
+
if (element.getAttribute("data-turbolinks-eval") == "false") {
|
|
92
|
+
return element;
|
|
93
|
+
} else {
|
|
94
|
+
const createdScriptElement = document.createElement("script");
|
|
95
|
+
createdScriptElement.textContent = element.textContent;
|
|
96
|
+
createdScriptElement.async = false;
|
|
97
|
+
copyElementAttributes(createdScriptElement, element);
|
|
98
|
+
if (cb) {
|
|
99
|
+
createdScriptElement.addEventListener("load", cb);
|
|
100
|
+
}
|
|
101
|
+
return createdScriptElement;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function copyElementAttributes(destinationElement, sourceElement) {
|
|
105
|
+
for (const { name, value } of array(sourceElement.attributes)) {
|
|
106
|
+
destinationElement.setAttribute(name, value);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function replaceElementWithElement(fromElement, toElement) {
|
|
110
|
+
const parentElement = fromElement.parentElement;
|
|
111
|
+
if (parentElement) {
|
|
112
|
+
return parentElement.replaceChild(toElement, fromElement);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function activateNewBodyScriptElements(newScriptElements) {
|
|
116
|
+
for (const inertScriptElement of newScriptElements) {
|
|
117
|
+
const activatedScriptElement = createScriptElement(inertScriptElement);
|
|
118
|
+
replaceElementWithElement(inertScriptElement, activatedScriptElement);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function focusFirstAutofocusableElement() {
|
|
122
|
+
const element = document.body.querySelector("[autofocus]");
|
|
123
|
+
if (element && "focus" in element && typeof element.focus === "function") {
|
|
124
|
+
element.focus();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// lib/turbolinks/mergeHead.ts
|
|
129
|
+
var allHeadScriptsEverRun = {};
|
|
130
|
+
var firstLoad = true;
|
|
131
|
+
var lastTrackedScriptSignature;
|
|
132
|
+
async function mergeHead(head, trackScripts, reload) {
|
|
133
|
+
const newHead = categorizeHead(head);
|
|
134
|
+
const oldHead = categorizeHead(document.head);
|
|
135
|
+
if (head.querySelector('meta[name="turbolinks-visit-control"]')?.getAttribute("content") === "reload") {
|
|
136
|
+
reload();
|
|
137
|
+
}
|
|
138
|
+
if (trackScripts) {
|
|
139
|
+
lastTrackedScriptSignature = lastTrackedScriptSignature || trackedElementSignature([...oldHead.scripts, ...oldHead.stylesheets]);
|
|
140
|
+
if (lastTrackedScriptSignature !== trackedElementSignature([...newHead.scripts, ...newHead.stylesheets])) {
|
|
141
|
+
reload();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (firstLoad) {
|
|
145
|
+
for (const element of oldHead.scripts) {
|
|
146
|
+
allHeadScriptsEverRun[element.outerHTML] = {
|
|
147
|
+
tracked: elementIsTracked(element)
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
firstLoad = false;
|
|
151
|
+
}
|
|
152
|
+
copyNewHeadStylesheetElements(newHead.stylesheets, oldHead.stylesheets);
|
|
153
|
+
removeCurrentHeadProvisionalElements(oldHead.provisional);
|
|
154
|
+
copyNewHeadProvisionalElements(newHead.provisional);
|
|
155
|
+
return new Promise((resolve) => {
|
|
156
|
+
copyNewHeadScriptElements(newHead.scripts, resolve);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
function trackedElementSignature(scripts) {
|
|
160
|
+
return scripts.filter(elementIsTracked).map((s) => s.outerHTML).join();
|
|
161
|
+
}
|
|
162
|
+
function copyNewHeadStylesheetElements(next, prev) {
|
|
163
|
+
const existing = prev.map((s) => s.outerHTML);
|
|
164
|
+
for (const element of next) {
|
|
165
|
+
if (!existing.includes(element.outerHTML)) {
|
|
166
|
+
document.head.appendChild(element);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function copyNewHeadScriptElements(next, onScriptsLoaded) {
|
|
171
|
+
let blockingLoaded = [];
|
|
172
|
+
function dispatch2() {
|
|
173
|
+
onScriptsLoaded();
|
|
174
|
+
}
|
|
175
|
+
for (const element of next) {
|
|
176
|
+
const runBefore = element.outerHTML in allHeadScriptsEverRun;
|
|
177
|
+
if (!runBefore) {
|
|
178
|
+
let cb;
|
|
179
|
+
if (!element.defer && element.src) {
|
|
180
|
+
const idx = blockingLoaded.length;
|
|
181
|
+
cb = () => {
|
|
182
|
+
blockingLoaded[idx] = true;
|
|
183
|
+
if (blockingLoaded.every((v) => v)) {
|
|
184
|
+
dispatch2();
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
blockingLoaded.push(false);
|
|
188
|
+
}
|
|
189
|
+
document.head.appendChild(createScriptElement(element, cb));
|
|
190
|
+
allHeadScriptsEverRun[element.outerHTML] = {
|
|
191
|
+
tracked: elementIsTracked(element)
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (blockingLoaded.length === 0) {
|
|
196
|
+
requestAnimationFrame(dispatch2);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function removeCurrentHeadProvisionalElements(prev) {
|
|
200
|
+
for (const element of prev) {
|
|
201
|
+
document.head.removeChild(element);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
function copyNewHeadProvisionalElements(next) {
|
|
205
|
+
for (const element of next) {
|
|
206
|
+
document.head.appendChild(element);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
function elementIsTracked(element) {
|
|
210
|
+
return element.getAttribute("data-turbolinks-track") == "reload";
|
|
211
|
+
}
|
|
212
|
+
function elementIsScript(element) {
|
|
213
|
+
const tagName = element.tagName.toLowerCase();
|
|
214
|
+
return tagName == "script";
|
|
215
|
+
}
|
|
216
|
+
function elementIsStylesheet(element) {
|
|
217
|
+
const tagName = element.tagName.toLowerCase();
|
|
218
|
+
return tagName == "style" || tagName == "link" && element.getAttribute("rel") == "stylesheet";
|
|
219
|
+
}
|
|
220
|
+
function categorizeHead(head) {
|
|
221
|
+
const scripts = [];
|
|
222
|
+
const stylesheets = [];
|
|
223
|
+
const provisional = [];
|
|
224
|
+
for (const element of head.children) {
|
|
225
|
+
if (elementIsScript(element)) {
|
|
226
|
+
scripts.push(element);
|
|
227
|
+
} else if (elementIsStylesheet(element)) {
|
|
228
|
+
stylesheets.push(element);
|
|
229
|
+
} else {
|
|
230
|
+
provisional.push(element);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return { scripts, stylesheets, provisional };
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// lib/turbolinks/lruCache.ts
|
|
237
|
+
var LruCache = class {
|
|
238
|
+
constructor(maxEntries) {
|
|
239
|
+
this.values = /* @__PURE__ */ new Map();
|
|
240
|
+
this.maxEntries = maxEntries;
|
|
241
|
+
}
|
|
242
|
+
get(key) {
|
|
243
|
+
const hasKey = this.values.has(key);
|
|
244
|
+
let entry;
|
|
245
|
+
if (hasKey) {
|
|
246
|
+
entry = this.values.get(key);
|
|
247
|
+
this.values.delete(key);
|
|
248
|
+
this.values.set(key, entry);
|
|
249
|
+
}
|
|
250
|
+
return entry;
|
|
251
|
+
}
|
|
252
|
+
put(key, value) {
|
|
253
|
+
if (this.values.size >= this.maxEntries) {
|
|
254
|
+
const keyToDelete = this.values.keys().next().value;
|
|
255
|
+
this.values.delete(keyToDelete);
|
|
256
|
+
}
|
|
257
|
+
this.values.set(key, value);
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
// lib/turbolinks/progress_bar.ts
|
|
262
|
+
var _ProgressBar = class _ProgressBar {
|
|
263
|
+
constructor() {
|
|
264
|
+
this.stylesheetElement = this.createStylesheetElement();
|
|
265
|
+
this.progressElement = this.createProgressElement();
|
|
266
|
+
this.hiding = false;
|
|
267
|
+
this.value = 0;
|
|
268
|
+
this.visible = false;
|
|
269
|
+
this.trickle = () => {
|
|
270
|
+
this.setValue(this.value + Math.random() / 100);
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
/*ms*/
|
|
274
|
+
static get defaultCSS() {
|
|
275
|
+
return unindent`
|
|
276
|
+
.turbolinks-progress-bar {
|
|
277
|
+
position: fixed;
|
|
278
|
+
display: block;
|
|
279
|
+
top: 0;
|
|
280
|
+
left: 0;
|
|
281
|
+
height: 3px;
|
|
282
|
+
background: #0076ff;
|
|
283
|
+
z-index: 9999;
|
|
284
|
+
transition:
|
|
285
|
+
width ${_ProgressBar.animationDuration}ms ease-out,
|
|
286
|
+
opacity ${_ProgressBar.animationDuration / 2}ms ${_ProgressBar.animationDuration / 2}ms ease-in;
|
|
287
|
+
transform: translate3d(0, 0, 0);
|
|
288
|
+
}
|
|
289
|
+
`;
|
|
290
|
+
}
|
|
291
|
+
show() {
|
|
292
|
+
if (!this.visible) {
|
|
293
|
+
this.visible = true;
|
|
294
|
+
this.installStylesheetElement();
|
|
295
|
+
this.installProgressElement();
|
|
296
|
+
this.startTrickling();
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
hide() {
|
|
300
|
+
if (this.visible && !this.hiding) {
|
|
301
|
+
this.hiding = true;
|
|
302
|
+
this.fadeProgressElement(() => {
|
|
303
|
+
this.uninstallProgressElement();
|
|
304
|
+
this.stopTrickling();
|
|
305
|
+
this.visible = false;
|
|
306
|
+
this.hiding = false;
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
setValue(value) {
|
|
311
|
+
this.value = value;
|
|
312
|
+
this.refresh();
|
|
313
|
+
}
|
|
314
|
+
// Private
|
|
315
|
+
installStylesheetElement() {
|
|
316
|
+
document.head.insertBefore(
|
|
317
|
+
this.stylesheetElement,
|
|
318
|
+
document.head.firstChild
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
installProgressElement() {
|
|
322
|
+
this.progressElement.style.width = "0";
|
|
323
|
+
this.progressElement.style.opacity = "1";
|
|
324
|
+
document.documentElement.insertBefore(this.progressElement, document.body);
|
|
325
|
+
this.refresh();
|
|
326
|
+
}
|
|
327
|
+
fadeProgressElement(callback) {
|
|
328
|
+
this.progressElement.style.opacity = "0";
|
|
329
|
+
setTimeout(callback, _ProgressBar.animationDuration * 1.5);
|
|
330
|
+
}
|
|
331
|
+
uninstallProgressElement() {
|
|
332
|
+
if (this.progressElement.parentNode) {
|
|
333
|
+
document.documentElement.removeChild(this.progressElement);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
startTrickling() {
|
|
337
|
+
if (!this.trickleInterval) {
|
|
338
|
+
this.trickleInterval = window.setInterval(
|
|
339
|
+
this.trickle,
|
|
340
|
+
_ProgressBar.animationDuration
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
stopTrickling() {
|
|
345
|
+
window.clearInterval(this.trickleInterval);
|
|
346
|
+
delete this.trickleInterval;
|
|
347
|
+
}
|
|
348
|
+
refresh() {
|
|
349
|
+
requestAnimationFrame(() => {
|
|
350
|
+
this.progressElement.style.width = `${10 + this.value * 90}%`;
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
createStylesheetElement() {
|
|
354
|
+
const element = document.createElement("style");
|
|
355
|
+
element.type = "text/css";
|
|
356
|
+
element.textContent = _ProgressBar.defaultCSS;
|
|
357
|
+
return element;
|
|
358
|
+
}
|
|
359
|
+
createProgressElement() {
|
|
360
|
+
const element = document.createElement("div");
|
|
361
|
+
element.className = "turbolinks-progress-bar";
|
|
362
|
+
return element;
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
_ProgressBar.animationDuration = 300;
|
|
366
|
+
var ProgressBar = _ProgressBar;
|
|
367
|
+
|
|
368
|
+
// lib/turbolinks/browser_adapter.ts
|
|
369
|
+
var BrowserAdapter = class {
|
|
370
|
+
constructor(controller2) {
|
|
371
|
+
this.progressBar = new ProgressBar();
|
|
372
|
+
this.showProgressBar = () => {
|
|
373
|
+
this.progressBar.show();
|
|
374
|
+
};
|
|
375
|
+
this.controller = controller2;
|
|
376
|
+
}
|
|
377
|
+
visitProposedToLocationWithAction(location, action) {
|
|
378
|
+
this.controller.startVisitToLocationWithAction(
|
|
379
|
+
location,
|
|
380
|
+
action
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
visitStarted(visit) {
|
|
384
|
+
visit.issueRequest();
|
|
385
|
+
visit.changeHistory();
|
|
386
|
+
visit.loadCachedSnapshot();
|
|
387
|
+
}
|
|
388
|
+
visitRequestStarted(visit) {
|
|
389
|
+
this.progressBar.setValue(0);
|
|
390
|
+
if (visit.hasCachedSnapshot() || visit.action != "restore") {
|
|
391
|
+
this.showProgressBarAfterDelay();
|
|
392
|
+
} else {
|
|
393
|
+
this.showProgressBar();
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
visitRequestProgressed(visit) {
|
|
397
|
+
this.progressBar.setValue(visit.progress);
|
|
398
|
+
}
|
|
399
|
+
visitRequestCompleted(visit) {
|
|
400
|
+
visit.loadResponse();
|
|
401
|
+
}
|
|
402
|
+
visitRequestFailedWithStatusCode(visit, statusCode) {
|
|
403
|
+
switch (statusCode) {
|
|
404
|
+
default:
|
|
405
|
+
return visit.loadResponse();
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
visitRequestFinished(visit) {
|
|
409
|
+
this.hideProgressBar();
|
|
410
|
+
}
|
|
411
|
+
visitCompleted(visit) {
|
|
412
|
+
}
|
|
413
|
+
pageInvalidated() {
|
|
414
|
+
this.reload();
|
|
415
|
+
}
|
|
416
|
+
visitFailed(visit) {
|
|
417
|
+
}
|
|
418
|
+
visitRendered(visit) {
|
|
419
|
+
}
|
|
420
|
+
// Private
|
|
421
|
+
showProgressBarAfterDelay() {
|
|
422
|
+
this.progressBarTimeout = window.setTimeout(
|
|
423
|
+
this.showProgressBar,
|
|
424
|
+
this.controller.progressBarDelay
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
hideProgressBar() {
|
|
428
|
+
this.progressBar.hide();
|
|
429
|
+
if (this.progressBarTimeout != null) {
|
|
430
|
+
window.clearTimeout(this.progressBarTimeout);
|
|
431
|
+
delete this.progressBarTimeout;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
reload() {
|
|
435
|
+
window.location.reload();
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
// lib/turbolinks/location.ts
|
|
440
|
+
var Location = class {
|
|
441
|
+
static get currentLocation() {
|
|
442
|
+
return this.wrap(window.location.toString());
|
|
443
|
+
}
|
|
444
|
+
static wrap(locatable) {
|
|
445
|
+
if (typeof locatable == "string") {
|
|
446
|
+
return new this(locatable);
|
|
447
|
+
} else if (locatable != null) {
|
|
448
|
+
return locatable;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
constructor(url) {
|
|
452
|
+
const linkWithAnchor = document.createElement("a");
|
|
453
|
+
linkWithAnchor.href = url;
|
|
454
|
+
this.absoluteURL = linkWithAnchor.href;
|
|
455
|
+
const anchorLength = linkWithAnchor.hash.length;
|
|
456
|
+
if (anchorLength < 2) {
|
|
457
|
+
this.requestURL = this.absoluteURL;
|
|
458
|
+
} else {
|
|
459
|
+
this.requestURL = this.absoluteURL.slice(0, -anchorLength);
|
|
460
|
+
this.anchor = linkWithAnchor.hash.slice(1);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
getOrigin() {
|
|
464
|
+
return this.absoluteURL.split("/", 3).join("/");
|
|
465
|
+
}
|
|
466
|
+
getPath() {
|
|
467
|
+
return (this.requestURL.match(/\/\/[^/]*(\/[^?;]*)/) || [])[1] || "/";
|
|
468
|
+
}
|
|
469
|
+
getPathComponents() {
|
|
470
|
+
return this.getPath().split("/").slice(1);
|
|
471
|
+
}
|
|
472
|
+
getLastPathComponent() {
|
|
473
|
+
return this.getPathComponents().slice(-1)[0];
|
|
474
|
+
}
|
|
475
|
+
getExtension() {
|
|
476
|
+
return (this.getLastPathComponent().match(/\.[^.]*$/) || [])[0] || "";
|
|
477
|
+
}
|
|
478
|
+
isHTML() {
|
|
479
|
+
return this.getExtension().match(/^(?:|\.(?:htm|html|xhtml))$/);
|
|
480
|
+
}
|
|
481
|
+
isPrefixedBy(location) {
|
|
482
|
+
const prefixURL = getPrefixURL(location);
|
|
483
|
+
return this.isEqualTo(location) || stringStartsWith(this.absoluteURL, prefixURL);
|
|
484
|
+
}
|
|
485
|
+
isEqualTo(location) {
|
|
486
|
+
return location && this.absoluteURL === location.absoluteURL;
|
|
487
|
+
}
|
|
488
|
+
toCacheKey() {
|
|
489
|
+
return this.requestURL;
|
|
490
|
+
}
|
|
491
|
+
toJSON() {
|
|
492
|
+
return this.absoluteURL;
|
|
493
|
+
}
|
|
494
|
+
toString() {
|
|
495
|
+
return this.absoluteURL;
|
|
496
|
+
}
|
|
497
|
+
valueOf() {
|
|
498
|
+
return this.absoluteURL;
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
function getPrefixURL(location) {
|
|
502
|
+
return addTrailingSlash(location.getOrigin() + location.getPath());
|
|
503
|
+
}
|
|
504
|
+
function addTrailingSlash(url) {
|
|
505
|
+
return stringEndsWith(url, "/") ? url : url + "/";
|
|
506
|
+
}
|
|
507
|
+
function stringStartsWith(string, prefix) {
|
|
508
|
+
return string.slice(0, prefix.length) === prefix;
|
|
509
|
+
}
|
|
510
|
+
function stringEndsWith(string, suffix) {
|
|
511
|
+
return string.slice(-suffix.length) === suffix;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// lib/turbolinks/types.ts
|
|
515
|
+
function isAction(action) {
|
|
516
|
+
return action == "advance" || action == "replace" || action == "restore";
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// lib/turbolinks/visit.ts
|
|
520
|
+
import { navigate } from "vite-plugin-ssr/client/router";
|
|
521
|
+
var Visit = class {
|
|
522
|
+
constructor(controller2, location, action, restorationIdentifier = uuid()) {
|
|
523
|
+
this.identifier = uuid();
|
|
524
|
+
this.timingMetrics = {};
|
|
525
|
+
this.progress = 0;
|
|
526
|
+
this.snapshotCached = false;
|
|
527
|
+
this.state = "initialized" /* initialized */;
|
|
528
|
+
this.requestInFlight = false;
|
|
529
|
+
this.controller = controller2;
|
|
530
|
+
this.location = location;
|
|
531
|
+
this.action = action;
|
|
532
|
+
this.adapter = controller2.adapter;
|
|
533
|
+
this.restorationIdentifier = restorationIdentifier;
|
|
534
|
+
}
|
|
535
|
+
start() {
|
|
536
|
+
if (this.state == "initialized" /* initialized */) {
|
|
537
|
+
this.recordTimingMetric("visitStart" /* visitStart */);
|
|
538
|
+
this.state = "started" /* started */;
|
|
539
|
+
this.adapter.visitStarted(this);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
cancel() {
|
|
543
|
+
if (this.state == "started" /* started */) {
|
|
544
|
+
this.requestInFlight = false;
|
|
545
|
+
this.cancelRender();
|
|
546
|
+
this.state = "canceled" /* canceled */;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
complete() {
|
|
550
|
+
if (this.state == "started" /* started */) {
|
|
551
|
+
this.recordTimingMetric("visitEnd" /* visitEnd */);
|
|
552
|
+
this.state = "completed" /* completed */;
|
|
553
|
+
this.adapter.visitCompleted(this);
|
|
554
|
+
this.controller.visitCompleted(this);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
fail() {
|
|
558
|
+
if (this.state == "started" /* started */) {
|
|
559
|
+
this.state = "failed" /* failed */;
|
|
560
|
+
this.adapter.visitFailed(this);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
changeHistory() {
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
issueRequest() {
|
|
567
|
+
if (!this.requestInFlight) {
|
|
568
|
+
if (this.shouldIssueRequest()) {
|
|
569
|
+
const url = new URL(
|
|
570
|
+
this.location.toString(),
|
|
571
|
+
this.location.getOrigin()
|
|
572
|
+
);
|
|
573
|
+
navigate(url.pathname + url.hash + url.search, {
|
|
574
|
+
overwriteLastHistoryEntry: this.action === "replace"
|
|
575
|
+
}).catch(console.error);
|
|
576
|
+
this.progress = 0;
|
|
577
|
+
this.requestInFlight = true;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
getCachedSnapshot() {
|
|
582
|
+
const snapshot = this.controller.getCachedSnapshotForLocation(
|
|
583
|
+
this.location
|
|
584
|
+
);
|
|
585
|
+
if (snapshot) {
|
|
586
|
+
if (this.action == "restore") {
|
|
587
|
+
return snapshot;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
hasCachedSnapshot() {
|
|
592
|
+
return this.getCachedSnapshot() != null;
|
|
593
|
+
}
|
|
594
|
+
loadCachedSnapshot() {
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
loadResponse() {
|
|
598
|
+
this.render(async () => {
|
|
599
|
+
if (!this.renderFn)
|
|
600
|
+
throw new Error("Render details not set before rendering");
|
|
601
|
+
this.cacheSnapshot();
|
|
602
|
+
await this.renderFn();
|
|
603
|
+
this.complete();
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
// HTTP request delegate
|
|
607
|
+
/*
|
|
608
|
+
requestStarted() {
|
|
609
|
+
this.recordTimingMetric(TimingMetric.requestStart);
|
|
610
|
+
this.adapter.visitRequestStarted(this);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
requestProgressed(progress: number) {
|
|
614
|
+
this.progress = progress;
|
|
615
|
+
if (this.adapter.visitRequestProgressed) {
|
|
616
|
+
this.adapter.visitRequestProgressed(this);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
requestCompletedWithResponse(
|
|
621
|
+
response: string,
|
|
622
|
+
redirectedToLocation?: Location
|
|
623
|
+
) {
|
|
624
|
+
this.response = response;
|
|
625
|
+
this.redirectedToLocation = redirectedToLocation;
|
|
626
|
+
this.adapter.visitRequestCompleted(this);
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
requestFailedWithStatusCode(statusCode: number, response?: string) {
|
|
630
|
+
this.response = response;
|
|
631
|
+
this.adapter.visitRequestFailedWithStatusCode(this, statusCode);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
requestFinished() {
|
|
635
|
+
this.recordTimingMetric(TimingMetric.requestEnd);
|
|
636
|
+
this.adapter.visitRequestFinished(this);
|
|
637
|
+
}
|
|
638
|
+
*/
|
|
639
|
+
// Instrumentation
|
|
640
|
+
recordTimingMetric(metric) {
|
|
641
|
+
this.timingMetrics[metric] = (/* @__PURE__ */ new Date()).getTime();
|
|
642
|
+
}
|
|
643
|
+
getTimingMetrics() {
|
|
644
|
+
return { ...this.timingMetrics };
|
|
645
|
+
}
|
|
646
|
+
// Private
|
|
647
|
+
shouldIssueRequest() {
|
|
648
|
+
return this.action == "restore" ? !this.hasCachedSnapshot() : true;
|
|
649
|
+
}
|
|
650
|
+
cacheSnapshot() {
|
|
651
|
+
if (!this.snapshotCached) {
|
|
652
|
+
this.controller.cacheSnapshot();
|
|
653
|
+
this.snapshotCached = true;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
render(callback) {
|
|
657
|
+
this.cancelRender();
|
|
658
|
+
this.frame = requestAnimationFrame(() => {
|
|
659
|
+
delete this.frame;
|
|
660
|
+
callback.call(this);
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
cancelRender() {
|
|
664
|
+
if (this.frame) {
|
|
665
|
+
cancelAnimationFrame(this.frame);
|
|
666
|
+
delete this.frame;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
|
|
671
|
+
// lib/turbolinks/controller.ts
|
|
672
|
+
var Controller = class {
|
|
673
|
+
constructor() {
|
|
674
|
+
this.adapter = new BrowserAdapter(this);
|
|
675
|
+
this.cache = new LruCache(10);
|
|
676
|
+
this.enabled = true;
|
|
677
|
+
this.progressBarDelay = 500;
|
|
678
|
+
// This only exists for compatibility with iOS
|
|
679
|
+
this.started = false;
|
|
680
|
+
// Event handlers
|
|
681
|
+
this.clickCaptured = () => {
|
|
682
|
+
document.body.removeEventListener("click", this.clickBubbled, false);
|
|
683
|
+
document.body.addEventListener("click", this.clickBubbled, false);
|
|
684
|
+
};
|
|
685
|
+
this.clickBubbled = (event) => {
|
|
686
|
+
if (this.enabled && this.clickEventIsSignificant(event)) {
|
|
687
|
+
const link = this.getVisitableLinkForTarget(event.target);
|
|
688
|
+
if (link) {
|
|
689
|
+
const location = this.getVisitableLocationForLink(link);
|
|
690
|
+
if (location && this.applicationAllowsFollowingLinkToLocation(link, location)) {
|
|
691
|
+
event.preventDefault();
|
|
692
|
+
event.stopPropagation();
|
|
693
|
+
const action = this.getActionForLink(link);
|
|
694
|
+
this.visit(location, { action });
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
start() {
|
|
701
|
+
if (!this.started) {
|
|
702
|
+
document.body.addEventListener("click", this.clickCaptured, true);
|
|
703
|
+
this.location = Location.currentLocation;
|
|
704
|
+
this.restorationIdentifier = uuid();
|
|
705
|
+
this.lastRenderedLocation = this.location;
|
|
706
|
+
this.started = true;
|
|
707
|
+
this.enabled = true;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
disable() {
|
|
711
|
+
this.enabled = false;
|
|
712
|
+
}
|
|
713
|
+
stop() {
|
|
714
|
+
if (this.started) {
|
|
715
|
+
document.body.removeEventListener("click", this.clickCaptured, true);
|
|
716
|
+
this.started = false;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
clearCache() {
|
|
720
|
+
this.cache = new LruCache(10);
|
|
721
|
+
}
|
|
722
|
+
visit(location, options = {}) {
|
|
723
|
+
location = Location.wrap(location);
|
|
724
|
+
if (this.applicationAllowsVisitingLocation(location)) {
|
|
725
|
+
if (this.locationIsVisitable(location)) {
|
|
726
|
+
const action = options.action || "advance";
|
|
727
|
+
this.adapter.visitProposedToLocationWithAction(location, action);
|
|
728
|
+
} else {
|
|
729
|
+
window.location.href = location.toString();
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
startVisitToLocationWithAction(location, action, restorationIdentifier) {
|
|
734
|
+
this.startVisit(Location.wrap(location), action);
|
|
735
|
+
}
|
|
736
|
+
setProgressBarDelay(delay) {
|
|
737
|
+
this.progressBarDelay = delay;
|
|
738
|
+
}
|
|
739
|
+
// History delegate
|
|
740
|
+
historyPoppedToLocationWithRestorationIdentifier(location, restorationIdentifier) {
|
|
741
|
+
if (this.enabled) {
|
|
742
|
+
this.location = Location.wrap(location);
|
|
743
|
+
this.restorationIdentifier = restorationIdentifier;
|
|
744
|
+
this.startVisit(this.location, "restore");
|
|
745
|
+
} else {
|
|
746
|
+
this.adapter.pageInvalidated();
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
// Snapshot cache
|
|
750
|
+
getCachedSnapshotForLocation(location) {
|
|
751
|
+
return this.cache.get(Location.wrap(location).toCacheKey());
|
|
752
|
+
}
|
|
753
|
+
shouldCacheSnapshot() {
|
|
754
|
+
return document.body.querySelector("#proxied-body") && document.head.querySelector("meta[name='turbolinks-no-cache']")?.getAttribute("content") != "no-cache";
|
|
755
|
+
}
|
|
756
|
+
cacheSnapshot() {
|
|
757
|
+
if (this.shouldCacheSnapshot()) {
|
|
758
|
+
this.notifyApplicationBeforeCachingSnapshot();
|
|
759
|
+
const snapshot = {
|
|
760
|
+
bodyEl: document.body.cloneNode(true),
|
|
761
|
+
headEl: document.head.cloneNode(true),
|
|
762
|
+
pageContext: this.pageContext
|
|
763
|
+
};
|
|
764
|
+
const location = this.lastRenderedLocation || Location.currentLocation;
|
|
765
|
+
defer(() => this.cache.put(location.toCacheKey(), snapshot));
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
// View
|
|
769
|
+
viewInvalidated() {
|
|
770
|
+
this.adapter.pageInvalidated();
|
|
771
|
+
}
|
|
772
|
+
viewWillRender() {
|
|
773
|
+
this.notifyApplicationBeforeRender();
|
|
774
|
+
}
|
|
775
|
+
viewRendered() {
|
|
776
|
+
this.lastRenderedLocation = this.currentVisit.location;
|
|
777
|
+
this.notifyApplicationAfterRender();
|
|
778
|
+
}
|
|
779
|
+
// Application events
|
|
780
|
+
applicationAllowsFollowingLinkToLocation(link, location) {
|
|
781
|
+
const event = this.notifyApplicationAfterClickingLinkToLocation(
|
|
782
|
+
link,
|
|
783
|
+
location
|
|
784
|
+
);
|
|
785
|
+
return !event.defaultPrevented;
|
|
786
|
+
}
|
|
787
|
+
applicationAllowsVisitingLocation(location) {
|
|
788
|
+
const event = this.notifyApplicationBeforeVisitingLocation(location);
|
|
789
|
+
return !event.defaultPrevented;
|
|
790
|
+
}
|
|
791
|
+
notifyApplicationAfterClickingLinkToLocation(link, location) {
|
|
792
|
+
return dispatch("turbolinks:click", {
|
|
793
|
+
target: link,
|
|
794
|
+
data: { url: location.absoluteURL },
|
|
795
|
+
cancelable: true
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
notifyApplicationBeforeVisitingLocation(location) {
|
|
799
|
+
return dispatch("turbolinks:before-visit", {
|
|
800
|
+
data: { url: location.absoluteURL },
|
|
801
|
+
cancelable: true
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
notifyApplicationAfterVisitingLocation(location) {
|
|
805
|
+
return dispatch("turbolinks:visit", {
|
|
806
|
+
data: { url: location.absoluteURL }
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
notifyApplicationBeforeCachingSnapshot() {
|
|
810
|
+
return dispatch("turbolinks:before-cache");
|
|
811
|
+
}
|
|
812
|
+
notifyApplicationBeforeRender() {
|
|
813
|
+
return dispatch("turbolinks:before-render");
|
|
814
|
+
}
|
|
815
|
+
notifyApplicationAfterRender() {
|
|
816
|
+
return dispatch("turbolinks:render");
|
|
817
|
+
}
|
|
818
|
+
notifyApplicationAfterPageLoad(timing = {}) {
|
|
819
|
+
return dispatch("turbolinks:load", {
|
|
820
|
+
data: { url: this.location.absoluteURL, timing }
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
// Private
|
|
824
|
+
startVisit(location, action) {
|
|
825
|
+
if (this.currentVisit) {
|
|
826
|
+
this.currentVisit.cancel();
|
|
827
|
+
}
|
|
828
|
+
this.currentVisit = this.createVisit(location, action);
|
|
829
|
+
this.currentVisit.start();
|
|
830
|
+
this.notifyApplicationAfterVisitingLocation(location);
|
|
831
|
+
}
|
|
832
|
+
createVisit(location, action) {
|
|
833
|
+
const visit = new Visit(this, location, action);
|
|
834
|
+
visit.referrer = this.location;
|
|
835
|
+
if (action === "restore") {
|
|
836
|
+
visit.requestInFlight = true;
|
|
837
|
+
}
|
|
838
|
+
return visit;
|
|
839
|
+
}
|
|
840
|
+
visitCompleted(visit) {
|
|
841
|
+
this.notifyApplicationAfterPageLoad(visit.getTimingMetrics());
|
|
842
|
+
}
|
|
843
|
+
clickEventIsSignificant(event) {
|
|
844
|
+
return !(event.target && event.target.isContentEditable || event.defaultPrevented || event.which > 1 || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey);
|
|
845
|
+
}
|
|
846
|
+
getVisitableLinkForTarget(target) {
|
|
847
|
+
if (target instanceof Element && this.elementIsVisitable(target)) {
|
|
848
|
+
return closest(target, "a[href]:not([target]):not([download])");
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
getVisitableLocationForLink(link) {
|
|
852
|
+
const location = new Location(link.getAttribute("href") || "");
|
|
853
|
+
if (this.locationIsVisitable(location)) {
|
|
854
|
+
return location;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
getActionForLink(link) {
|
|
858
|
+
const action = link.getAttribute("data-turbolinks-action");
|
|
859
|
+
return isAction(action) ? action : "advance";
|
|
860
|
+
}
|
|
861
|
+
elementIsVisitable(element) {
|
|
862
|
+
const container = closest(element, "[data-turbolinks]");
|
|
863
|
+
if (container) {
|
|
864
|
+
return container.getAttribute("data-turbolinks") != "false";
|
|
865
|
+
} else {
|
|
866
|
+
return true;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
locationIsVisitable(location) {
|
|
870
|
+
return location.isPrefixedBy(new Location("/")) && location.isHTML();
|
|
871
|
+
}
|
|
872
|
+
};
|
|
873
|
+
|
|
874
|
+
// lib/turbolinks/index.ts
|
|
875
|
+
var controller = new Controller();
|
|
876
|
+
var Turbolinks = {
|
|
877
|
+
get supported() {
|
|
878
|
+
return true;
|
|
879
|
+
},
|
|
880
|
+
controller,
|
|
881
|
+
visit(location, options) {
|
|
882
|
+
controller.visit(location, options);
|
|
883
|
+
},
|
|
884
|
+
clearCache() {
|
|
885
|
+
controller.clearCache();
|
|
886
|
+
},
|
|
887
|
+
setProgressBarDelay(delay) {
|
|
888
|
+
controller.setProgressBarDelay(delay);
|
|
889
|
+
},
|
|
890
|
+
start() {
|
|
891
|
+
if (window.Turbolinks !== Turbolinks && window.Turbolinks.controller.adapter) {
|
|
892
|
+
window.Turbolinks.controller.adapter.controller = controller;
|
|
893
|
+
controller.adapter = window.Turbolinks.controller.adapter;
|
|
894
|
+
}
|
|
895
|
+
window._disableAutomaticLinkInterception = true;
|
|
896
|
+
window.Turbolinks = Turbolinks;
|
|
897
|
+
controller.start();
|
|
898
|
+
},
|
|
899
|
+
_vpsCachePageContext(pageContext) {
|
|
900
|
+
controller.pageContext = pageContext;
|
|
901
|
+
},
|
|
902
|
+
_vpsOnRenderClient(newHead, trackScripts, renderBody) {
|
|
903
|
+
if (controller.currentVisit) {
|
|
904
|
+
const { currentVisit } = controller;
|
|
905
|
+
currentVisit.renderFn = async () => {
|
|
906
|
+
const scriptsLoaded = mergeHead(
|
|
907
|
+
newHead,
|
|
908
|
+
trackScripts,
|
|
909
|
+
() => controller.viewInvalidated()
|
|
910
|
+
);
|
|
911
|
+
controller.viewWillRender();
|
|
912
|
+
renderBody();
|
|
913
|
+
await scriptsLoaded;
|
|
914
|
+
activateNewBodyScriptElements(
|
|
915
|
+
Array.from(document.body.querySelectorAll("script"))
|
|
916
|
+
);
|
|
917
|
+
focusFirstAutofocusableElement();
|
|
918
|
+
controller.viewRendered();
|
|
919
|
+
controller.adapter.visitRendered(currentVisit);
|
|
920
|
+
};
|
|
921
|
+
controller.adapter.visitRequestCompleted(controller.currentVisit);
|
|
922
|
+
controller.adapter.visitRequestFinished(controller.currentVisit);
|
|
923
|
+
} else {
|
|
924
|
+
console.error(
|
|
925
|
+
"controller.currentVisit should exist when onRenderClient fires"
|
|
926
|
+
);
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
};
|
|
930
|
+
|
|
931
|
+
export {
|
|
932
|
+
renderReact,
|
|
933
|
+
copyElementAttributes,
|
|
934
|
+
Turbolinks
|
|
935
|
+
};
|
|
936
|
+
//# sourceMappingURL=chunk-ABW2IXO4.js.map
|