@hotwired/turbo 7.0.0-rc.1 → 7.0.0-rc.3
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/turbo.es2017-esm.js +185 -96
- package/dist/turbo.es2017-umd.js +185 -95
- package/dist/types/core/drive/form_submission.d.ts +1 -1
- package/dist/types/core/drive/navigator.d.ts +2 -2
- package/dist/types/core/drive/visit.d.ts +1 -1
- package/dist/types/core/frames/frame_controller.d.ts +2 -0
- package/dist/types/core/index.d.ts +3 -1
- package/dist/types/core/native/adapter.d.ts +3 -0
- package/dist/types/core/native/browser_adapter.d.ts +9 -3
- package/dist/types/core/session.d.ts +10 -3
- package/dist/types/core/view.d.ts +1 -0
- package/dist/types/http/fetch_request.d.ts +2 -1
- package/dist/types/tests/functional/drive_disabled_tests.d.ts +7 -0
- package/dist/types/tests/functional/drive_tests.d.ts +7 -0
- package/dist/types/tests/functional/form_submission_tests.d.ts +6 -0
- package/dist/types/tests/functional/frame_navigation_tests.d.ts +6 -0
- package/dist/types/tests/functional/frame_tests.d.ts +4 -0
- package/dist/types/tests/functional/index.d.ts +3 -0
- package/dist/types/tests/functional/navigation_tests.d.ts +9 -0
- package/dist/types/tests/helpers/functional_test_case.d.ts +3 -0
- package/dist/types/tests/helpers/turbo_drive_test_case.d.ts +2 -1
- package/dist/types/tests/unit/deprecated_adapter_support_test.d.ts +3 -0
- package/package.json +2 -2
- package/CHANGELOG.md +0 -3
- package/dist/turbo.es2017-esm.js.map +0 -1
- package/dist/turbo.es2017-umd.js.map +0 -1
- package/dist/turbo.es5-umd.js +0 -4121
- package/dist/turbo.es5-umd.js.map +0 -1
- package/dist/types/core/request_interceptor.d.ts +0 -6
package/dist/turbo.es2017-umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Turbo 7.0.0-rc.
|
|
2
|
+
Turbo 7.0.0-rc.2
|
|
3
3
|
Copyright © 2021 Basecamp, LLC
|
|
4
4
|
*/
|
|
5
5
|
(function (global, factory) {
|
|
@@ -344,8 +344,10 @@ Copyright © 2021 Basecamp, LLC
|
|
|
344
344
|
return await this.receive(response);
|
|
345
345
|
}
|
|
346
346
|
catch (error) {
|
|
347
|
-
|
|
348
|
-
|
|
347
|
+
if (error.name !== 'AbortError') {
|
|
348
|
+
this.delegate.requestErrored(this, error);
|
|
349
|
+
throw error;
|
|
350
|
+
}
|
|
349
351
|
}
|
|
350
352
|
finally {
|
|
351
353
|
this.delegate.requestFinished(this);
|
|
@@ -366,13 +368,15 @@ Copyright © 2021 Basecamp, LLC
|
|
|
366
368
|
return fetchResponse;
|
|
367
369
|
}
|
|
368
370
|
get fetchOptions() {
|
|
371
|
+
var _a;
|
|
369
372
|
return {
|
|
370
373
|
method: FetchMethod[this.method].toUpperCase(),
|
|
371
374
|
credentials: "same-origin",
|
|
372
375
|
headers: this.headers,
|
|
373
376
|
redirect: "follow",
|
|
374
377
|
body: this.body,
|
|
375
|
-
signal: this.abortSignal
|
|
378
|
+
signal: this.abortSignal,
|
|
379
|
+
referrer: (_a = this.delegate.referrer) === null || _a === void 0 ? void 0 : _a.href
|
|
376
380
|
};
|
|
377
381
|
}
|
|
378
382
|
get defaultHeaders() {
|
|
@@ -511,7 +515,8 @@ Copyright © 2021 Basecamp, LLC
|
|
|
511
515
|
}
|
|
512
516
|
get action() {
|
|
513
517
|
var _a;
|
|
514
|
-
|
|
518
|
+
const formElementAction = typeof this.formElement.action === 'string' ? this.formElement.action : null;
|
|
519
|
+
return ((_a = this.submitter) === null || _a === void 0 ? void 0 : _a.getAttribute("formaction")) || this.formElement.getAttribute("action") || formElementAction || "";
|
|
515
520
|
}
|
|
516
521
|
get location() {
|
|
517
522
|
return expandURL(this.action);
|
|
@@ -637,12 +642,7 @@ Copyright © 2021 Basecamp, LLC
|
|
|
637
642
|
return this.getElementForAnchor(anchor) != null;
|
|
638
643
|
}
|
|
639
644
|
getElementForAnchor(anchor) {
|
|
640
|
-
|
|
641
|
-
return this.element.querySelector(`[id='${anchor}'], a[name='${anchor}']`);
|
|
642
|
-
}
|
|
643
|
-
catch (_a) {
|
|
644
|
-
return null;
|
|
645
|
-
}
|
|
645
|
+
return anchor ? this.element.querySelector(`[id='${anchor}'], a[name='${anchor}']`) : null;
|
|
646
646
|
}
|
|
647
647
|
get isConnected() {
|
|
648
648
|
return this.element.isConnected;
|
|
@@ -731,6 +731,9 @@ Copyright © 2021 Basecamp, LLC
|
|
|
731
731
|
scrollToPosition({ x, y }) {
|
|
732
732
|
this.scrollRoot.scrollTo(x, y);
|
|
733
733
|
}
|
|
734
|
+
scrollToTop() {
|
|
735
|
+
this.scrollToPosition({ x: 0, y: 0 });
|
|
736
|
+
}
|
|
734
737
|
get scrollRoot() {
|
|
735
738
|
return window;
|
|
736
739
|
}
|
|
@@ -1299,6 +1302,9 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1299
1302
|
get restorationData() {
|
|
1300
1303
|
return this.history.getRestorationDataForIdentifier(this.restorationIdentifier);
|
|
1301
1304
|
}
|
|
1305
|
+
get silent() {
|
|
1306
|
+
return this.isSamePage;
|
|
1307
|
+
}
|
|
1302
1308
|
start() {
|
|
1303
1309
|
if (this.state == VisitState.initialized) {
|
|
1304
1310
|
this.recordTimingMetric(TimingMetric.visitStart);
|
|
@@ -1322,6 +1328,7 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1322
1328
|
this.state = VisitState.completed;
|
|
1323
1329
|
this.adapter.visitCompleted(this);
|
|
1324
1330
|
this.delegate.visitCompleted(this);
|
|
1331
|
+
this.followRedirect();
|
|
1325
1332
|
}
|
|
1326
1333
|
}
|
|
1327
1334
|
fail() {
|
|
@@ -1434,8 +1441,10 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1434
1441
|
}
|
|
1435
1442
|
followRedirect() {
|
|
1436
1443
|
if (this.redirectedToLocation && !this.followedRedirect) {
|
|
1437
|
-
this.
|
|
1438
|
-
|
|
1444
|
+
this.adapter.visitProposedToLocation(this.redirectedToLocation, {
|
|
1445
|
+
action: 'replace',
|
|
1446
|
+
response: this.response
|
|
1447
|
+
});
|
|
1439
1448
|
this.followedRedirect = true;
|
|
1440
1449
|
}
|
|
1441
1450
|
}
|
|
@@ -1480,10 +1489,10 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1480
1489
|
performScroll() {
|
|
1481
1490
|
if (!this.scrolled) {
|
|
1482
1491
|
if (this.action == "restore") {
|
|
1483
|
-
this.scrollToRestoredPosition() || this.scrollToAnchor() || this.scrollToTop();
|
|
1492
|
+
this.scrollToRestoredPosition() || this.scrollToAnchor() || this.view.scrollToTop();
|
|
1484
1493
|
}
|
|
1485
1494
|
else {
|
|
1486
|
-
this.scrollToAnchor() || this.scrollToTop();
|
|
1495
|
+
this.scrollToAnchor() || this.view.scrollToTop();
|
|
1487
1496
|
}
|
|
1488
1497
|
if (this.isSamePage) {
|
|
1489
1498
|
this.delegate.visitScrolledToSamePageLocation(this.view.lastRenderedLocation, this.location);
|
|
@@ -1505,9 +1514,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1505
1514
|
return true;
|
|
1506
1515
|
}
|
|
1507
1516
|
}
|
|
1508
|
-
scrollToTop() {
|
|
1509
|
-
this.view.scrollToPosition({ x: 0, y: 0 });
|
|
1510
|
-
}
|
|
1511
1517
|
recordTimingMetric(metric) {
|
|
1512
1518
|
this.timingMetrics[metric] = new Date().getTime();
|
|
1513
1519
|
}
|
|
@@ -1581,7 +1587,7 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1581
1587
|
visitRequestStarted(visit) {
|
|
1582
1588
|
this.progressBar.setValue(0);
|
|
1583
1589
|
if (visit.hasCachedSnapshot() || visit.action != "restore") {
|
|
1584
|
-
this.
|
|
1590
|
+
this.showVisitProgressBarAfterDelay();
|
|
1585
1591
|
}
|
|
1586
1592
|
else {
|
|
1587
1593
|
this.showProgressBar();
|
|
@@ -1602,10 +1608,9 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1602
1608
|
}
|
|
1603
1609
|
visitRequestFinished(visit) {
|
|
1604
1610
|
this.progressBar.setValue(1);
|
|
1605
|
-
this.
|
|
1611
|
+
this.hideVisitProgressBar();
|
|
1606
1612
|
}
|
|
1607
1613
|
visitCompleted(visit) {
|
|
1608
|
-
visit.followRedirect();
|
|
1609
1614
|
}
|
|
1610
1615
|
pageInvalidated() {
|
|
1611
1616
|
this.reload();
|
|
@@ -1614,14 +1619,34 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1614
1619
|
}
|
|
1615
1620
|
visitRendered(visit) {
|
|
1616
1621
|
}
|
|
1617
|
-
|
|
1618
|
-
this.
|
|
1622
|
+
formSubmissionStarted(formSubmission) {
|
|
1623
|
+
this.progressBar.setValue(0);
|
|
1624
|
+
this.showFormProgressBarAfterDelay();
|
|
1625
|
+
}
|
|
1626
|
+
formSubmissionFinished(formSubmission) {
|
|
1627
|
+
this.progressBar.setValue(1);
|
|
1628
|
+
this.hideFormProgressBar();
|
|
1629
|
+
}
|
|
1630
|
+
showVisitProgressBarAfterDelay() {
|
|
1631
|
+
this.visitProgressBarTimeout = window.setTimeout(this.showProgressBar, this.session.progressBarDelay);
|
|
1632
|
+
}
|
|
1633
|
+
hideVisitProgressBar() {
|
|
1634
|
+
this.progressBar.hide();
|
|
1635
|
+
if (this.visitProgressBarTimeout != null) {
|
|
1636
|
+
window.clearTimeout(this.visitProgressBarTimeout);
|
|
1637
|
+
delete this.visitProgressBarTimeout;
|
|
1638
|
+
}
|
|
1619
1639
|
}
|
|
1620
|
-
|
|
1640
|
+
showFormProgressBarAfterDelay() {
|
|
1641
|
+
if (this.formProgressBarTimeout == null) {
|
|
1642
|
+
this.formProgressBarTimeout = window.setTimeout(this.showProgressBar, this.session.progressBarDelay);
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
hideFormProgressBar() {
|
|
1621
1646
|
this.progressBar.hide();
|
|
1622
|
-
if (this.
|
|
1623
|
-
window.clearTimeout(this.
|
|
1624
|
-
delete this.
|
|
1647
|
+
if (this.formProgressBarTimeout != null) {
|
|
1648
|
+
window.clearTimeout(this.formProgressBarTimeout);
|
|
1649
|
+
delete this.formProgressBarTimeout;
|
|
1625
1650
|
}
|
|
1626
1651
|
}
|
|
1627
1652
|
reload() {
|
|
@@ -1712,6 +1737,7 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1712
1737
|
linkClickIntercepted(element, url) {
|
|
1713
1738
|
const frame = this.findFrameElement(element);
|
|
1714
1739
|
if (frame) {
|
|
1740
|
+
frame.setAttribute("reloadable", "");
|
|
1715
1741
|
frame.src = url;
|
|
1716
1742
|
}
|
|
1717
1743
|
}
|
|
@@ -1721,6 +1747,7 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1721
1747
|
formSubmissionIntercepted(element, submitter) {
|
|
1722
1748
|
const frame = this.findFrameElement(element);
|
|
1723
1749
|
if (frame) {
|
|
1750
|
+
frame.removeAttribute("reloadable");
|
|
1724
1751
|
frame.delegate.formSubmissionIntercepted(element, submitter);
|
|
1725
1752
|
}
|
|
1726
1753
|
}
|
|
@@ -1827,7 +1854,8 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1827
1854
|
};
|
|
1828
1855
|
this.clickBubbled = (event) => {
|
|
1829
1856
|
if (this.clickEventIsSignificant(event)) {
|
|
1830
|
-
const
|
|
1857
|
+
const target = (event.composedPath && event.composedPath()[0]) || event.target;
|
|
1858
|
+
const link = this.findLinkFromClickTarget(target);
|
|
1831
1859
|
if (link) {
|
|
1832
1860
|
const location = this.getLocationForLink(link);
|
|
1833
1861
|
if (this.delegate.willFollowLinkToLocation(link, location)) {
|
|
@@ -1879,7 +1907,7 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1879
1907
|
this.delegate = delegate;
|
|
1880
1908
|
}
|
|
1881
1909
|
proposeVisit(location, options = {}) {
|
|
1882
|
-
if (this.delegate.
|
|
1910
|
+
if (this.delegate.allowsVisitingLocationWithAction(location, options.action)) {
|
|
1883
1911
|
this.delegate.visitProposedToLocation(location, options);
|
|
1884
1912
|
}
|
|
1885
1913
|
}
|
|
@@ -1918,6 +1946,9 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1918
1946
|
return this.delegate.history;
|
|
1919
1947
|
}
|
|
1920
1948
|
formSubmissionStarted(formSubmission) {
|
|
1949
|
+
if (typeof this.adapter.formSubmissionStarted === 'function') {
|
|
1950
|
+
this.adapter.formSubmissionStarted(formSubmission);
|
|
1951
|
+
}
|
|
1921
1952
|
}
|
|
1922
1953
|
async formSubmissionSucceededWithResponse(formSubmission, fetchResponse) {
|
|
1923
1954
|
if (formSubmission == this.formSubmission) {
|
|
@@ -1936,7 +1967,13 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1936
1967
|
const responseHTML = await fetchResponse.responseHTML;
|
|
1937
1968
|
if (responseHTML) {
|
|
1938
1969
|
const snapshot = PageSnapshot.fromHTMLString(responseHTML);
|
|
1939
|
-
|
|
1970
|
+
if (fetchResponse.serverError) {
|
|
1971
|
+
await this.view.renderError(snapshot);
|
|
1972
|
+
}
|
|
1973
|
+
else {
|
|
1974
|
+
await this.view.renderPage(snapshot);
|
|
1975
|
+
}
|
|
1976
|
+
this.view.scrollToTop();
|
|
1940
1977
|
this.view.clearSnapshotCache();
|
|
1941
1978
|
}
|
|
1942
1979
|
}
|
|
@@ -1944,6 +1981,9 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1944
1981
|
console.error(error);
|
|
1945
1982
|
}
|
|
1946
1983
|
formSubmissionFinished(formSubmission) {
|
|
1984
|
+
if (typeof this.adapter.formSubmissionFinished === 'function') {
|
|
1985
|
+
this.adapter.formSubmissionFinished(formSubmission);
|
|
1986
|
+
}
|
|
1947
1987
|
}
|
|
1948
1988
|
visitStarted(visit) {
|
|
1949
1989
|
this.delegate.visitStarted(visit);
|
|
@@ -1952,8 +1992,12 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1952
1992
|
this.delegate.visitCompleted(visit);
|
|
1953
1993
|
}
|
|
1954
1994
|
locationWithActionIsSamePage(location, action) {
|
|
1955
|
-
|
|
1956
|
-
|
|
1995
|
+
const anchor = getAnchor(location);
|
|
1996
|
+
const currentAnchor = getAnchor(this.view.lastRenderedLocation);
|
|
1997
|
+
const isRestorationToTop = action === 'restore' && typeof anchor === 'undefined';
|
|
1998
|
+
return action !== "replace" &&
|
|
1999
|
+
getRequestURL(location) === getRequestURL(this.view.lastRenderedLocation) &&
|
|
2000
|
+
(isRestorationToTop || (anchor != null && anchor !== currentAnchor));
|
|
1957
2001
|
}
|
|
1958
2002
|
visitScrolledToSamePageLocation(oldURL, newURL) {
|
|
1959
2003
|
this.delegate.visitScrolledToSamePageLocation(oldURL, newURL);
|
|
@@ -2341,6 +2385,7 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2341
2385
|
this.scrollObserver = new ScrollObserver(this);
|
|
2342
2386
|
this.streamObserver = new StreamObserver(this);
|
|
2343
2387
|
this.frameRedirector = new FrameRedirector(document.documentElement);
|
|
2388
|
+
this.drive = true;
|
|
2344
2389
|
this.enabled = true;
|
|
2345
2390
|
this.progressBarDelay = 500;
|
|
2346
2391
|
this.started = false;
|
|
@@ -2414,7 +2459,7 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2414
2459
|
this.history.updateRestorationData({ scrollPosition: position });
|
|
2415
2460
|
}
|
|
2416
2461
|
willFollowLinkToLocation(link, location) {
|
|
2417
|
-
return
|
|
2462
|
+
return this.elementDriveEnabled(link)
|
|
2418
2463
|
&& this.locationIsVisitable(location)
|
|
2419
2464
|
&& this.applicationAllowsFollowingLinkToLocation(link, location);
|
|
2420
2465
|
}
|
|
@@ -2423,21 +2468,20 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2423
2468
|
this.convertLinkWithMethodClickToFormSubmission(link) || this.visit(location.href, { action });
|
|
2424
2469
|
}
|
|
2425
2470
|
convertLinkWithMethodClickToFormSubmission(link) {
|
|
2426
|
-
var _a;
|
|
2427
2471
|
const linkMethod = link.getAttribute("data-turbo-method");
|
|
2428
2472
|
if (linkMethod) {
|
|
2429
2473
|
const form = document.createElement("form");
|
|
2430
2474
|
form.method = linkMethod;
|
|
2431
2475
|
form.action = link.getAttribute("href") || "undefined";
|
|
2432
|
-
|
|
2476
|
+
document.body.appendChild(form);
|
|
2433
2477
|
return dispatch("submit", { cancelable: true, target: form });
|
|
2434
2478
|
}
|
|
2435
2479
|
else {
|
|
2436
2480
|
return false;
|
|
2437
2481
|
}
|
|
2438
2482
|
}
|
|
2439
|
-
|
|
2440
|
-
return this.applicationAllowsVisitingLocation(location);
|
|
2483
|
+
allowsVisitingLocationWithAction(location, action) {
|
|
2484
|
+
return this.locationWithActionIsSamePage(location, action) || this.applicationAllowsVisitingLocation(location);
|
|
2441
2485
|
}
|
|
2442
2486
|
visitProposedToLocation(location, options) {
|
|
2443
2487
|
extendURLWithDeprecatedProperties(location);
|
|
@@ -2445,7 +2489,9 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2445
2489
|
}
|
|
2446
2490
|
visitStarted(visit) {
|
|
2447
2491
|
extendURLWithDeprecatedProperties(visit.location);
|
|
2448
|
-
|
|
2492
|
+
if (!visit.silent) {
|
|
2493
|
+
this.notifyApplicationAfterVisitingLocation(visit.location, visit.action);
|
|
2494
|
+
}
|
|
2449
2495
|
}
|
|
2450
2496
|
visitCompleted(visit) {
|
|
2451
2497
|
this.notifyApplicationAfterPageLoad(visit.getTimingMetrics());
|
|
@@ -2457,7 +2503,7 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2457
2503
|
this.notifyApplicationAfterVisitingSamePageLocation(oldURL, newURL);
|
|
2458
2504
|
}
|
|
2459
2505
|
willSubmitForm(form, submitter) {
|
|
2460
|
-
return
|
|
2506
|
+
return this.elementDriveEnabled(form) && this.elementDriveEnabled(submitter);
|
|
2461
2507
|
}
|
|
2462
2508
|
formSubmitted(form, submitter) {
|
|
2463
2509
|
this.navigator.submitForm(form, submitter);
|
|
@@ -2476,7 +2522,10 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2476
2522
|
this.renderStreamMessage(message);
|
|
2477
2523
|
}
|
|
2478
2524
|
viewWillCacheSnapshot() {
|
|
2479
|
-
|
|
2525
|
+
var _a;
|
|
2526
|
+
if (!((_a = this.navigator.currentVisit) === null || _a === void 0 ? void 0 : _a.silent)) {
|
|
2527
|
+
this.notifyApplicationBeforeCachingSnapshot();
|
|
2528
|
+
}
|
|
2480
2529
|
}
|
|
2481
2530
|
allowsImmediateRender({ element }, resume) {
|
|
2482
2531
|
const event = this.notifyApplicationBeforeRender(element, resume);
|
|
@@ -2489,6 +2538,12 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2489
2538
|
viewInvalidated() {
|
|
2490
2539
|
this.adapter.pageInvalidated();
|
|
2491
2540
|
}
|
|
2541
|
+
frameLoaded(frame) {
|
|
2542
|
+
this.notifyApplicationAfterFrameLoad(frame);
|
|
2543
|
+
}
|
|
2544
|
+
frameRendered(fetchResponse, frame) {
|
|
2545
|
+
this.notifyApplicationAfterFrameRender(fetchResponse, frame);
|
|
2546
|
+
}
|
|
2492
2547
|
applicationAllowsFollowingLinkToLocation(link, location) {
|
|
2493
2548
|
const event = this.notifyApplicationAfterClickingLinkToLocation(link, location);
|
|
2494
2549
|
return !event.defaultPrevented;
|
|
@@ -2521,6 +2576,31 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2521
2576
|
notifyApplicationAfterVisitingSamePageLocation(oldURL, newURL) {
|
|
2522
2577
|
dispatchEvent(new HashChangeEvent("hashchange", { oldURL: oldURL.toString(), newURL: newURL.toString() }));
|
|
2523
2578
|
}
|
|
2579
|
+
notifyApplicationAfterFrameLoad(frame) {
|
|
2580
|
+
return dispatch("turbo:frame-load", { target: frame });
|
|
2581
|
+
}
|
|
2582
|
+
notifyApplicationAfterFrameRender(fetchResponse, frame) {
|
|
2583
|
+
return dispatch("turbo:frame-render", { detail: { fetchResponse }, target: frame, cancelable: true });
|
|
2584
|
+
}
|
|
2585
|
+
elementDriveEnabled(element) {
|
|
2586
|
+
const container = element === null || element === void 0 ? void 0 : element.closest("[data-turbo]");
|
|
2587
|
+
if (this.drive) {
|
|
2588
|
+
if (container) {
|
|
2589
|
+
return container.getAttribute("data-turbo") != "false";
|
|
2590
|
+
}
|
|
2591
|
+
else {
|
|
2592
|
+
return true;
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
else {
|
|
2596
|
+
if (container) {
|
|
2597
|
+
return container.getAttribute("data-turbo") == "true";
|
|
2598
|
+
}
|
|
2599
|
+
else {
|
|
2600
|
+
return false;
|
|
2601
|
+
}
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2524
2604
|
getActionForLink(link) {
|
|
2525
2605
|
const action = link.getAttribute("data-turbo-action");
|
|
2526
2606
|
return isAction(action) ? action : "advance";
|
|
@@ -2532,15 +2612,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2532
2612
|
return this.view.snapshot;
|
|
2533
2613
|
}
|
|
2534
2614
|
}
|
|
2535
|
-
function elementIsNavigable(element) {
|
|
2536
|
-
const container = element === null || element === void 0 ? void 0 : element.closest("[data-turbo]");
|
|
2537
|
-
if (container) {
|
|
2538
|
-
return container.getAttribute("data-turbo") != "false";
|
|
2539
|
-
}
|
|
2540
|
-
else {
|
|
2541
|
-
return true;
|
|
2542
|
-
}
|
|
2543
|
-
}
|
|
2544
2615
|
function extendURLWithDeprecatedProperties(url) {
|
|
2545
2616
|
Object.defineProperties(url, deprecatedLocationPropertyDescriptors);
|
|
2546
2617
|
}
|
|
@@ -2552,6 +2623,49 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2552
2623
|
}
|
|
2553
2624
|
};
|
|
2554
2625
|
|
|
2626
|
+
const session = new Session;
|
|
2627
|
+
const { navigator } = session;
|
|
2628
|
+
function start() {
|
|
2629
|
+
session.start();
|
|
2630
|
+
}
|
|
2631
|
+
function registerAdapter(adapter) {
|
|
2632
|
+
session.registerAdapter(adapter);
|
|
2633
|
+
}
|
|
2634
|
+
function visit(location, options) {
|
|
2635
|
+
session.visit(location, options);
|
|
2636
|
+
}
|
|
2637
|
+
function connectStreamSource(source) {
|
|
2638
|
+
session.connectStreamSource(source);
|
|
2639
|
+
}
|
|
2640
|
+
function disconnectStreamSource(source) {
|
|
2641
|
+
session.disconnectStreamSource(source);
|
|
2642
|
+
}
|
|
2643
|
+
function renderStreamMessage(message) {
|
|
2644
|
+
session.renderStreamMessage(message);
|
|
2645
|
+
}
|
|
2646
|
+
function clearCache() {
|
|
2647
|
+
session.clearCache();
|
|
2648
|
+
}
|
|
2649
|
+
function setProgressBarDelay(delay) {
|
|
2650
|
+
session.setProgressBarDelay(delay);
|
|
2651
|
+
}
|
|
2652
|
+
|
|
2653
|
+
var Turbo = /*#__PURE__*/Object.freeze({
|
|
2654
|
+
__proto__: null,
|
|
2655
|
+
navigator: navigator,
|
|
2656
|
+
session: session,
|
|
2657
|
+
PageRenderer: PageRenderer,
|
|
2658
|
+
PageSnapshot: PageSnapshot,
|
|
2659
|
+
start: start,
|
|
2660
|
+
registerAdapter: registerAdapter,
|
|
2661
|
+
visit: visit,
|
|
2662
|
+
connectStreamSource: connectStreamSource,
|
|
2663
|
+
disconnectStreamSource: disconnectStreamSource,
|
|
2664
|
+
renderStreamMessage: renderStreamMessage,
|
|
2665
|
+
clearCache: clearCache,
|
|
2666
|
+
setProgressBarDelay: setProgressBarDelay
|
|
2667
|
+
});
|
|
2668
|
+
|
|
2555
2669
|
class FrameController {
|
|
2556
2670
|
constructor(element) {
|
|
2557
2671
|
this.resolveVisitPromise = () => { };
|
|
@@ -2567,6 +2681,7 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2567
2681
|
connect() {
|
|
2568
2682
|
if (!this.connected) {
|
|
2569
2683
|
this.connected = true;
|
|
2684
|
+
this.reloadable = false;
|
|
2570
2685
|
if (this.loadingStyle == FrameLoadingStyle.lazy) {
|
|
2571
2686
|
this.appearanceObserver.start();
|
|
2572
2687
|
}
|
|
@@ -2603,7 +2718,7 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2603
2718
|
}
|
|
2604
2719
|
}
|
|
2605
2720
|
async loadSourceURL() {
|
|
2606
|
-
if (!this.settingSourceURL && this.enabled && this.isActive && this.sourceURL != this.currentURL) {
|
|
2721
|
+
if (!this.settingSourceURL && this.enabled && this.isActive && (this.reloadable || this.sourceURL != this.currentURL)) {
|
|
2607
2722
|
const previousURL = this.currentURL;
|
|
2608
2723
|
this.currentURL = this.sourceURL;
|
|
2609
2724
|
if (this.sourceURL) {
|
|
@@ -2612,6 +2727,7 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2612
2727
|
this.appearanceObserver.stop();
|
|
2613
2728
|
await this.element.loaded;
|
|
2614
2729
|
this.hasBeenLoaded = true;
|
|
2730
|
+
session.frameLoaded(this.element);
|
|
2615
2731
|
}
|
|
2616
2732
|
catch (error) {
|
|
2617
2733
|
this.currentURL = previousURL;
|
|
@@ -2633,6 +2749,7 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2633
2749
|
if (this.view.renderPromise)
|
|
2634
2750
|
await this.view.renderPromise;
|
|
2635
2751
|
await this.view.render(renderer);
|
|
2752
|
+
session.frameRendered(fetchResponse, this.element);
|
|
2636
2753
|
}
|
|
2637
2754
|
}
|
|
2638
2755
|
catch (error) {
|
|
@@ -2652,6 +2769,7 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2652
2769
|
}
|
|
2653
2770
|
}
|
|
2654
2771
|
linkClickIntercepted(element, url) {
|
|
2772
|
+
this.reloadable = true;
|
|
2655
2773
|
this.navigateFrame(element, url);
|
|
2656
2774
|
}
|
|
2657
2775
|
shouldInterceptFormSubmission(element, submitter) {
|
|
@@ -2661,6 +2779,7 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2661
2779
|
if (this.formSubmission) {
|
|
2662
2780
|
this.formSubmission.stop();
|
|
2663
2781
|
}
|
|
2782
|
+
this.reloadable = false;
|
|
2664
2783
|
this.formSubmission = new FormSubmission(this, element, submitter);
|
|
2665
2784
|
if (this.formSubmission.fetchRequest.isIdempotent) {
|
|
2666
2785
|
this.navigateFrame(element, this.formSubmission.fetchRequest.url.href);
|
|
@@ -2768,10 +2887,10 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2768
2887
|
return !frameElement.disabled;
|
|
2769
2888
|
}
|
|
2770
2889
|
}
|
|
2771
|
-
if (!
|
|
2890
|
+
if (!session.elementDriveEnabled(element)) {
|
|
2772
2891
|
return false;
|
|
2773
2892
|
}
|
|
2774
|
-
if (submitter && !
|
|
2893
|
+
if (submitter && !session.elementDriveEnabled(submitter)) {
|
|
2775
2894
|
return false;
|
|
2776
2895
|
}
|
|
2777
2896
|
return true;
|
|
@@ -2787,6 +2906,19 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2787
2906
|
return this.element.src;
|
|
2788
2907
|
}
|
|
2789
2908
|
}
|
|
2909
|
+
get reloadable() {
|
|
2910
|
+
const frame = this.findFrameElement(this.element);
|
|
2911
|
+
return frame.hasAttribute("reloadable");
|
|
2912
|
+
}
|
|
2913
|
+
set reloadable(value) {
|
|
2914
|
+
const frame = this.findFrameElement(this.element);
|
|
2915
|
+
if (value) {
|
|
2916
|
+
frame.setAttribute("reloadable", "");
|
|
2917
|
+
}
|
|
2918
|
+
else {
|
|
2919
|
+
frame.removeAttribute("reloadable");
|
|
2920
|
+
}
|
|
2921
|
+
}
|
|
2790
2922
|
set sourceURL(sourceURL) {
|
|
2791
2923
|
this.settingSourceURL = true;
|
|
2792
2924
|
this.element.src = sourceURL !== null && sourceURL !== void 0 ? sourceURL : null;
|
|
@@ -2989,48 +3121,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2989
3121
|
}
|
|
2990
3122
|
})();
|
|
2991
3123
|
|
|
2992
|
-
const session = new Session;
|
|
2993
|
-
const { navigator } = session;
|
|
2994
|
-
function start() {
|
|
2995
|
-
session.start();
|
|
2996
|
-
}
|
|
2997
|
-
function registerAdapter(adapter) {
|
|
2998
|
-
session.registerAdapter(adapter);
|
|
2999
|
-
}
|
|
3000
|
-
function visit(location, options) {
|
|
3001
|
-
session.visit(location, options);
|
|
3002
|
-
}
|
|
3003
|
-
function connectStreamSource(source) {
|
|
3004
|
-
session.connectStreamSource(source);
|
|
3005
|
-
}
|
|
3006
|
-
function disconnectStreamSource(source) {
|
|
3007
|
-
session.disconnectStreamSource(source);
|
|
3008
|
-
}
|
|
3009
|
-
function renderStreamMessage(message) {
|
|
3010
|
-
session.renderStreamMessage(message);
|
|
3011
|
-
}
|
|
3012
|
-
function clearCache() {
|
|
3013
|
-
session.clearCache();
|
|
3014
|
-
}
|
|
3015
|
-
function setProgressBarDelay(delay) {
|
|
3016
|
-
session.setProgressBarDelay(delay);
|
|
3017
|
-
}
|
|
3018
|
-
|
|
3019
|
-
var Turbo = /*#__PURE__*/Object.freeze({
|
|
3020
|
-
__proto__: null,
|
|
3021
|
-
navigator: navigator,
|
|
3022
|
-
PageRenderer: PageRenderer,
|
|
3023
|
-
PageSnapshot: PageSnapshot,
|
|
3024
|
-
start: start,
|
|
3025
|
-
registerAdapter: registerAdapter,
|
|
3026
|
-
visit: visit,
|
|
3027
|
-
connectStreamSource: connectStreamSource,
|
|
3028
|
-
disconnectStreamSource: disconnectStreamSource,
|
|
3029
|
-
renderStreamMessage: renderStreamMessage,
|
|
3030
|
-
clearCache: clearCache,
|
|
3031
|
-
setProgressBarDelay: setProgressBarDelay
|
|
3032
|
-
});
|
|
3033
|
-
|
|
3034
3124
|
window.Turbo = Turbo;
|
|
3035
3125
|
start();
|
|
3036
3126
|
|
|
@@ -3042,6 +3132,7 @@ Copyright © 2021 Basecamp, LLC
|
|
|
3042
3132
|
exports.navigator = navigator;
|
|
3043
3133
|
exports.registerAdapter = registerAdapter;
|
|
3044
3134
|
exports.renderStreamMessage = renderStreamMessage;
|
|
3135
|
+
exports.session = session;
|
|
3045
3136
|
exports.setProgressBarDelay = setProgressBarDelay;
|
|
3046
3137
|
exports.start = start;
|
|
3047
3138
|
exports.visit = visit;
|
|
@@ -3049,4 +3140,3 @@ Copyright © 2021 Basecamp, LLC
|
|
|
3049
3140
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3050
3141
|
|
|
3051
3142
|
})));
|
|
3052
|
-
//# sourceMappingURL=turbo.es2017-umd.js.map
|