@hotwired/turbo 7.0.0-rc.2 → 7.0.0
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 +71 -32
- package/dist/turbo.es2017-esm.js.map +1 -1
- package/dist/turbo.es2017-umd.js +71 -32
- package/dist/turbo.es2017-umd.js.map +1 -1
- package/dist/turbo.es5-umd.js +167 -422
- package/dist/turbo.es5-umd.js.map +1 -1
- package/dist/types/core/native/browser_adapter.d.ts +6 -3
- package/dist/types/http/fetch_request.d.ts +3 -1
- package/dist/types/tests/functional/form_submission_tests.d.ts +8 -1
- package/dist/types/tests/functional/frame_navigation_tests.d.ts +1 -0
- package/dist/types/tests/functional/frame_tests.d.ts +8 -1
- package/dist/types/tests/functional/rendering_tests.d.ts +1 -0
- package/dist/types/tests/functional/visit_tests.d.ts +1 -0
- package/package.json +2 -2
package/dist/turbo.es5-umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Turbo 7.0.0-
|
|
2
|
+
Turbo 7.0.0-beta.7
|
|
3
3
|
Copyright © 2021 Basecamp, LLC
|
|
4
4
|
*/
|
|
5
5
|
(function (global, factory) {
|
|
@@ -195,11 +195,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
195
195
|
FrameElement.prototype.disconnectedCallback = function () {
|
|
196
196
|
this.delegate.disconnect();
|
|
197
197
|
};
|
|
198
|
-
FrameElement.prototype.reload = function () {
|
|
199
|
-
var src = this.src;
|
|
200
|
-
this.src = null;
|
|
201
|
-
this.src = src;
|
|
202
|
-
};
|
|
203
198
|
FrameElement.prototype.attributeChangedCallback = function (name) {
|
|
204
199
|
if (name == "loading") {
|
|
205
200
|
this.delegate.loadingStyleChanged();
|
|
@@ -313,6 +308,9 @@ Copyright © 2021 Basecamp, LLC
|
|
|
313
308
|
else if (anchorMatch = url.href.match(/#(.*)$/)) {
|
|
314
309
|
return anchorMatch[1];
|
|
315
310
|
}
|
|
311
|
+
else {
|
|
312
|
+
return "";
|
|
313
|
+
}
|
|
316
314
|
}
|
|
317
315
|
function getExtension(url) {
|
|
318
316
|
return (getLastPathComponent(url).match(/\.[^.]*$/) || [])[0] || "";
|
|
@@ -324,14 +322,14 @@ Copyright © 2021 Basecamp, LLC
|
|
|
324
322
|
var prefix = getPrefix(url);
|
|
325
323
|
return baseURL.href === expandURL(prefix).href || baseURL.href.startsWith(prefix);
|
|
326
324
|
}
|
|
327
|
-
function getRequestURL(url) {
|
|
328
|
-
var anchor = getAnchor(url);
|
|
329
|
-
return anchor != null
|
|
330
|
-
? url.href.slice(0, -(anchor.length + 1))
|
|
331
|
-
: url.href;
|
|
332
|
-
}
|
|
333
325
|
function toCacheKey(url) {
|
|
334
|
-
|
|
326
|
+
var anchorLength = url.hash.length;
|
|
327
|
+
if (anchorLength < 2) {
|
|
328
|
+
return url.href;
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
return url.href.slice(0, -anchorLength);
|
|
332
|
+
}
|
|
335
333
|
}
|
|
336
334
|
function urlsAreEqual(left, right) {
|
|
337
335
|
return expandURL(left).href == expandURL(right).href;
|
|
@@ -514,7 +512,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
514
512
|
function FetchRequest(delegate, method, location, body) {
|
|
515
513
|
if (body === void 0) { body = new URLSearchParams; }
|
|
516
514
|
this.abortController = new AbortController;
|
|
517
|
-
this.resolveRequestPromise = function (value) { };
|
|
518
515
|
this.delegate = delegate;
|
|
519
516
|
this.method = method;
|
|
520
517
|
this.headers = this.defaultHeaders;
|
|
@@ -559,29 +556,24 @@ Copyright © 2021 Basecamp, LLC
|
|
|
559
556
|
case 0:
|
|
560
557
|
fetchOptions = this.fetchOptions;
|
|
561
558
|
(_b = (_a = this.delegate).prepareHeadersForRequest) === null || _b === void 0 ? void 0 : _b.call(_a, this.headers, this);
|
|
562
|
-
|
|
559
|
+
dispatch("turbo:before-fetch-request", { detail: { fetchOptions: fetchOptions } });
|
|
560
|
+
_c.label = 1;
|
|
563
561
|
case 1:
|
|
564
|
-
_c.
|
|
565
|
-
_c.label = 2;
|
|
566
|
-
case 2:
|
|
567
|
-
_c.trys.push([2, 5, 6, 7]);
|
|
562
|
+
_c.trys.push([1, 4, 5, 6]);
|
|
568
563
|
this.delegate.requestStarted(this);
|
|
569
564
|
return [4, fetch(this.url.href, fetchOptions)];
|
|
570
|
-
case
|
|
565
|
+
case 2:
|
|
571
566
|
response = _c.sent();
|
|
572
567
|
return [4, this.receive(response)];
|
|
573
|
-
case
|
|
574
|
-
case
|
|
568
|
+
case 3: return [2, _c.sent()];
|
|
569
|
+
case 4:
|
|
575
570
|
error_1 = _c.sent();
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
}
|
|
580
|
-
return [3, 7];
|
|
581
|
-
case 6:
|
|
571
|
+
this.delegate.requestErrored(this, error_1);
|
|
572
|
+
throw error_1;
|
|
573
|
+
case 5:
|
|
582
574
|
this.delegate.requestFinished(this);
|
|
583
575
|
return [7];
|
|
584
|
-
case
|
|
576
|
+
case 6: return [2];
|
|
585
577
|
}
|
|
586
578
|
});
|
|
587
579
|
});
|
|
@@ -607,15 +599,13 @@ Copyright © 2021 Basecamp, LLC
|
|
|
607
599
|
};
|
|
608
600
|
Object.defineProperty(FetchRequest.prototype, "fetchOptions", {
|
|
609
601
|
get: function () {
|
|
610
|
-
var _a;
|
|
611
602
|
return {
|
|
612
603
|
method: FetchMethod[this.method].toUpperCase(),
|
|
613
604
|
credentials: "same-origin",
|
|
614
605
|
headers: this.headers,
|
|
615
606
|
redirect: "follow",
|
|
616
607
|
body: this.body,
|
|
617
|
-
signal: this.abortSignal
|
|
618
|
-
referrer: (_a = this.delegate.referrer) === null || _a === void 0 ? void 0 : _a.href
|
|
608
|
+
signal: this.abortSignal
|
|
619
609
|
};
|
|
620
610
|
},
|
|
621
611
|
enumerable: false,
|
|
@@ -644,25 +634,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
644
634
|
enumerable: false,
|
|
645
635
|
configurable: true
|
|
646
636
|
});
|
|
647
|
-
FetchRequest.prototype.allowRequestToBeIntercepted = function (fetchOptions) {
|
|
648
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
649
|
-
var requestInterception, event;
|
|
650
|
-
var _this = this;
|
|
651
|
-
return __generator(this, function (_a) {
|
|
652
|
-
switch (_a.label) {
|
|
653
|
-
case 0:
|
|
654
|
-
requestInterception = new Promise(function (resolve) { return _this.resolveRequestPromise = resolve; });
|
|
655
|
-
event = dispatch("turbo:before-fetch-request", { cancelable: true, detail: { fetchOptions: fetchOptions, url: this.url.href, resume: this.resolveRequestPromise } });
|
|
656
|
-
if (!event.defaultPrevented) return [3, 2];
|
|
657
|
-
return [4, requestInterception];
|
|
658
|
-
case 1:
|
|
659
|
-
_a.sent();
|
|
660
|
-
_a.label = 2;
|
|
661
|
-
case 2: return [2];
|
|
662
|
-
}
|
|
663
|
-
});
|
|
664
|
-
});
|
|
665
|
-
};
|
|
666
637
|
return FetchRequest;
|
|
667
638
|
}());
|
|
668
639
|
function mergeFormDataEntries(url, entries) {
|
|
@@ -826,8 +797,7 @@ Copyright © 2021 Basecamp, LLC
|
|
|
826
797
|
Object.defineProperty(FormSubmission.prototype, "action", {
|
|
827
798
|
get: function () {
|
|
828
799
|
var _a;
|
|
829
|
-
|
|
830
|
-
return ((_a = this.submitter) === null || _a === void 0 ? void 0 : _a.getAttribute("formaction")) || this.formElement.getAttribute("action") || formElementAction || "";
|
|
800
|
+
return ((_a = this.submitter) === null || _a === void 0 ? void 0 : _a.getAttribute("formaction")) || this.formElement.action;
|
|
831
801
|
},
|
|
832
802
|
enumerable: false,
|
|
833
803
|
configurable: true
|
|
@@ -988,7 +958,12 @@ Copyright © 2021 Basecamp, LLC
|
|
|
988
958
|
return this.getElementForAnchor(anchor) != null;
|
|
989
959
|
};
|
|
990
960
|
Snapshot.prototype.getElementForAnchor = function (anchor) {
|
|
991
|
-
|
|
961
|
+
try {
|
|
962
|
+
return this.element.querySelector("[id='" + anchor + "'], a[name='" + anchor + "']");
|
|
963
|
+
}
|
|
964
|
+
catch (_a) {
|
|
965
|
+
return null;
|
|
966
|
+
}
|
|
992
967
|
};
|
|
993
968
|
Object.defineProperty(Snapshot.prototype, "isConnected", {
|
|
994
969
|
get: function () {
|
|
@@ -1067,8 +1042,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1067
1042
|
|
|
1068
1043
|
var View = (function () {
|
|
1069
1044
|
function View(delegate, element) {
|
|
1070
|
-
this.resolveRenderPromise = function (value) { };
|
|
1071
|
-
this.resolveInterceptionPromise = function (value) { };
|
|
1072
1045
|
this.delegate = delegate;
|
|
1073
1046
|
this.element = element;
|
|
1074
1047
|
}
|
|
@@ -1076,37 +1049,18 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1076
1049
|
var element = this.snapshot.getElementForAnchor(anchor);
|
|
1077
1050
|
if (element) {
|
|
1078
1051
|
this.scrollToElement(element);
|
|
1079
|
-
this.focusElement(element);
|
|
1080
1052
|
}
|
|
1081
1053
|
else {
|
|
1082
1054
|
this.scrollToPosition({ x: 0, y: 0 });
|
|
1083
1055
|
}
|
|
1084
1056
|
};
|
|
1085
|
-
View.prototype.scrollToAnchorFromLocation = function (location) {
|
|
1086
|
-
this.scrollToAnchor(getAnchor(location));
|
|
1087
|
-
};
|
|
1088
1057
|
View.prototype.scrollToElement = function (element) {
|
|
1089
1058
|
element.scrollIntoView();
|
|
1090
1059
|
};
|
|
1091
|
-
View.prototype.focusElement = function (element) {
|
|
1092
|
-
if (element instanceof HTMLElement) {
|
|
1093
|
-
if (element.hasAttribute("tabindex")) {
|
|
1094
|
-
element.focus();
|
|
1095
|
-
}
|
|
1096
|
-
else {
|
|
1097
|
-
element.setAttribute("tabindex", "-1");
|
|
1098
|
-
element.focus();
|
|
1099
|
-
element.removeAttribute("tabindex");
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
|
-
};
|
|
1103
1060
|
View.prototype.scrollToPosition = function (_a) {
|
|
1104
1061
|
var x = _a.x, y = _a.y;
|
|
1105
1062
|
this.scrollRoot.scrollTo(x, y);
|
|
1106
1063
|
};
|
|
1107
|
-
View.prototype.scrollToTop = function () {
|
|
1108
|
-
this.scrollToPosition({ x: 0, y: 0 });
|
|
1109
|
-
};
|
|
1110
1064
|
Object.defineProperty(View.prototype, "scrollRoot", {
|
|
1111
1065
|
get: function () {
|
|
1112
1066
|
return window;
|
|
@@ -1116,42 +1070,35 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1116
1070
|
});
|
|
1117
1071
|
View.prototype.render = function (renderer) {
|
|
1118
1072
|
return __awaiter(this, void 0, void 0, function () {
|
|
1119
|
-
var isPreview, shouldRender, snapshot
|
|
1120
|
-
var _this = this;
|
|
1073
|
+
var isPreview, shouldRender, snapshot;
|
|
1121
1074
|
return __generator(this, function (_a) {
|
|
1122
1075
|
switch (_a.label) {
|
|
1123
1076
|
case 0:
|
|
1077
|
+
if (this.renderer) {
|
|
1078
|
+
throw new Error("rendering is already in progress");
|
|
1079
|
+
}
|
|
1124
1080
|
isPreview = renderer.isPreview, shouldRender = renderer.shouldRender, snapshot = renderer.newSnapshot;
|
|
1125
|
-
if (!shouldRender) return [3,
|
|
1081
|
+
if (!shouldRender) return [3, 5];
|
|
1126
1082
|
_a.label = 1;
|
|
1127
1083
|
case 1:
|
|
1128
|
-
_a.trys.push([1, ,
|
|
1129
|
-
this.renderPromise = new Promise(function (resolve) { return _this.resolveRenderPromise = resolve; });
|
|
1084
|
+
_a.trys.push([1, , 3, 4]);
|
|
1130
1085
|
this.renderer = renderer;
|
|
1131
1086
|
this.prepareToRenderSnapshot(renderer);
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
if (!!immediateRender) return [3, 3];
|
|
1135
|
-
return [4, renderInterception];
|
|
1087
|
+
this.delegate.viewWillRenderSnapshot(snapshot, isPreview);
|
|
1088
|
+
return [4, this.renderSnapshot(renderer)];
|
|
1136
1089
|
case 2:
|
|
1137
|
-
_a.sent();
|
|
1138
|
-
_a.label = 3;
|
|
1139
|
-
case 3: return [4, this.renderSnapshot(renderer)];
|
|
1140
|
-
case 4:
|
|
1141
1090
|
_a.sent();
|
|
1142
1091
|
this.delegate.viewRenderedSnapshot(snapshot, isPreview);
|
|
1143
1092
|
this.finishRenderingSnapshot(renderer);
|
|
1144
|
-
return [3,
|
|
1145
|
-
case
|
|
1093
|
+
return [3, 4];
|
|
1094
|
+
case 3:
|
|
1146
1095
|
delete this.renderer;
|
|
1147
|
-
this.resolveRenderPromise(undefined);
|
|
1148
|
-
delete this.renderPromise;
|
|
1149
1096
|
return [7];
|
|
1150
|
-
case
|
|
1151
|
-
case
|
|
1097
|
+
case 4: return [3, 6];
|
|
1098
|
+
case 5:
|
|
1152
1099
|
this.invalidate();
|
|
1153
|
-
_a.label =
|
|
1154
|
-
case
|
|
1100
|
+
_a.label = 6;
|
|
1101
|
+
case 6: return [2];
|
|
1155
1102
|
}
|
|
1156
1103
|
});
|
|
1157
1104
|
});
|
|
@@ -1223,7 +1170,8 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1223
1170
|
if (_this.delegate.shouldInterceptLinkClick(event.target, event.detail.url)) {
|
|
1224
1171
|
_this.clickEvent.preventDefault();
|
|
1225
1172
|
event.preventDefault();
|
|
1226
|
-
_this.
|
|
1173
|
+
_this.convertLinkWithMethodClickToFormSubmission(event.target) ||
|
|
1174
|
+
_this.delegate.linkClickIntercepted(event.target, event.detail.url);
|
|
1227
1175
|
}
|
|
1228
1176
|
}
|
|
1229
1177
|
delete _this.clickEvent;
|
|
@@ -1244,6 +1192,20 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1244
1192
|
document.removeEventListener("turbo:click", this.linkClicked);
|
|
1245
1193
|
document.removeEventListener("turbo:before-visit", this.willVisit);
|
|
1246
1194
|
};
|
|
1195
|
+
LinkInterceptor.prototype.convertLinkWithMethodClickToFormSubmission = function (link) {
|
|
1196
|
+
var _a;
|
|
1197
|
+
var linkMethod = link.getAttribute("data-turbo-method") || link.getAttribute("data-method");
|
|
1198
|
+
if (linkMethod) {
|
|
1199
|
+
var form = document.createElement("form");
|
|
1200
|
+
form.method = linkMethod;
|
|
1201
|
+
form.action = link.getAttribute("href") || "undefined";
|
|
1202
|
+
(_a = link.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(form, link);
|
|
1203
|
+
return dispatch("submit", { target: form });
|
|
1204
|
+
}
|
|
1205
|
+
else {
|
|
1206
|
+
return false;
|
|
1207
|
+
}
|
|
1208
|
+
};
|
|
1247
1209
|
LinkInterceptor.prototype.respondsToEventTarget = function (target) {
|
|
1248
1210
|
var element = target instanceof Element
|
|
1249
1211
|
? target
|
|
@@ -1339,9 +1301,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1339
1301
|
}
|
|
1340
1302
|
else {
|
|
1341
1303
|
var createdScriptElement = document.createElement("script");
|
|
1342
|
-
if (this.cspNonce) {
|
|
1343
|
-
createdScriptElement.nonce = this.cspNonce;
|
|
1344
|
-
}
|
|
1345
1304
|
createdScriptElement.textContent = element.textContent;
|
|
1346
1305
|
createdScriptElement.async = false;
|
|
1347
1306
|
copyElementAttributes(createdScriptElement, element);
|
|
@@ -1385,14 +1344,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1385
1344
|
enumerable: false,
|
|
1386
1345
|
configurable: true
|
|
1387
1346
|
});
|
|
1388
|
-
Object.defineProperty(Renderer.prototype, "cspNonce", {
|
|
1389
|
-
get: function () {
|
|
1390
|
-
var _a;
|
|
1391
|
-
return (_a = document.head.querySelector('meta[name="csp-nonce"]')) === null || _a === void 0 ? void 0 : _a.getAttribute("content");
|
|
1392
|
-
},
|
|
1393
|
-
enumerable: false,
|
|
1394
|
-
configurable: true
|
|
1395
|
-
});
|
|
1396
1347
|
return Renderer;
|
|
1397
1348
|
}());
|
|
1398
1349
|
function copyElementAttributes(destinationElement, sourceElement) {
|
|
@@ -1443,10 +1394,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1443
1394
|
case 2:
|
|
1444
1395
|
_a.sent();
|
|
1445
1396
|
this.focusFirstAutofocusableElement();
|
|
1446
|
-
return [4, nextAnimationFrame()];
|
|
1447
|
-
case 3:
|
|
1448
|
-
_a.sent();
|
|
1449
|
-
this.activateScriptElements();
|
|
1450
1397
|
return [2];
|
|
1451
1398
|
}
|
|
1452
1399
|
});
|
|
@@ -1475,30 +1422,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1475
1422
|
}
|
|
1476
1423
|
return false;
|
|
1477
1424
|
};
|
|
1478
|
-
FrameRenderer.prototype.activateScriptElements = function () {
|
|
1479
|
-
var e_1, _a;
|
|
1480
|
-
try {
|
|
1481
|
-
for (var _b = __values(this.newScriptElements), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1482
|
-
var inertScriptElement = _c.value;
|
|
1483
|
-
var activatedScriptElement = this.createScriptElement(inertScriptElement);
|
|
1484
|
-
inertScriptElement.replaceWith(activatedScriptElement);
|
|
1485
|
-
}
|
|
1486
|
-
}
|
|
1487
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1488
|
-
finally {
|
|
1489
|
-
try {
|
|
1490
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1491
|
-
}
|
|
1492
|
-
finally { if (e_1) throw e_1.error; }
|
|
1493
|
-
}
|
|
1494
|
-
};
|
|
1495
|
-
Object.defineProperty(FrameRenderer.prototype, "newScriptElements", {
|
|
1496
|
-
get: function () {
|
|
1497
|
-
return this.currentElement.querySelectorAll("script");
|
|
1498
|
-
},
|
|
1499
|
-
enumerable: false,
|
|
1500
|
-
configurable: true
|
|
1501
|
-
});
|
|
1502
1425
|
return FrameRenderer;
|
|
1503
1426
|
}(Renderer));
|
|
1504
1427
|
function readScrollLogicalPosition(value, defaultValue) {
|
|
@@ -1607,9 +1530,7 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1607
1530
|
__extends(HeadSnapshot, _super);
|
|
1608
1531
|
function HeadSnapshot() {
|
|
1609
1532
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
1610
|
-
_this.detailsByOuterHTML = _this.children
|
|
1611
|
-
.filter(function (element) { return !elementIsNoscript(element); })
|
|
1612
|
-
.reduce(function (result, element) {
|
|
1533
|
+
_this.detailsByOuterHTML = _this.children.reduce(function (result, element) {
|
|
1613
1534
|
var _a;
|
|
1614
1535
|
var outerHTML = element.outerHTML;
|
|
1615
1536
|
var details = outerHTML in result
|
|
@@ -1702,10 +1623,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1702
1623
|
var tagName = element.tagName.toLowerCase();
|
|
1703
1624
|
return tagName == "script";
|
|
1704
1625
|
}
|
|
1705
|
-
function elementIsNoscript(element) {
|
|
1706
|
-
var tagName = element.tagName.toLowerCase();
|
|
1707
|
-
return tagName == "noscript";
|
|
1708
|
-
}
|
|
1709
1626
|
function elementIsStylesheet(element) {
|
|
1710
1627
|
var tagName = element.tagName.toLowerCase();
|
|
1711
1628
|
return tagName == "style" || (tagName == "link" && element.getAttribute("rel") == "stylesheet");
|
|
@@ -1830,7 +1747,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1830
1747
|
this.referrer = referrer;
|
|
1831
1748
|
this.snapshotHTML = snapshotHTML;
|
|
1832
1749
|
this.response = response;
|
|
1833
|
-
this.isSamePage = this.delegate.locationWithActionIsSamePage(this.location, this.action);
|
|
1834
1750
|
}
|
|
1835
1751
|
Object.defineProperty(Visit.prototype, "adapter", {
|
|
1836
1752
|
get: function () {
|
|
@@ -1860,13 +1776,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1860
1776
|
enumerable: false,
|
|
1861
1777
|
configurable: true
|
|
1862
1778
|
});
|
|
1863
|
-
Object.defineProperty(Visit.prototype, "silent", {
|
|
1864
|
-
get: function () {
|
|
1865
|
-
return this.isSamePage;
|
|
1866
|
-
},
|
|
1867
|
-
enumerable: false,
|
|
1868
|
-
configurable: true
|
|
1869
|
-
});
|
|
1870
1779
|
Visit.prototype.start = function () {
|
|
1871
1780
|
if (this.state == VisitState.initialized) {
|
|
1872
1781
|
this.recordTimingMetric(TimingMetric.visitStart);
|
|
@@ -1890,7 +1799,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1890
1799
|
this.state = VisitState.completed;
|
|
1891
1800
|
this.adapter.visitCompleted(this);
|
|
1892
1801
|
this.delegate.visitCompleted(this);
|
|
1893
|
-
this.followRedirect();
|
|
1894
1802
|
}
|
|
1895
1803
|
};
|
|
1896
1804
|
Visit.prototype.fail = function () {
|
|
@@ -1954,26 +1862,20 @@ Copyright © 2021 Basecamp, LLC
|
|
|
1954
1862
|
switch (_a.label) {
|
|
1955
1863
|
case 0:
|
|
1956
1864
|
this.cacheSnapshot();
|
|
1957
|
-
if (!
|
|
1958
|
-
return [4, this.view.renderPromise];
|
|
1959
|
-
case 1:
|
|
1960
|
-
_a.sent();
|
|
1961
|
-
_a.label = 2;
|
|
1962
|
-
case 2:
|
|
1963
|
-
if (!(isSuccessful(statusCode_1) && responseHTML_1 != null)) return [3, 4];
|
|
1865
|
+
if (!(isSuccessful(statusCode_1) && responseHTML_1 != null)) return [3, 2];
|
|
1964
1866
|
return [4, this.view.renderPage(PageSnapshot.fromHTMLString(responseHTML_1))];
|
|
1965
|
-
case
|
|
1867
|
+
case 1:
|
|
1966
1868
|
_a.sent();
|
|
1967
1869
|
this.adapter.visitRendered(this);
|
|
1968
1870
|
this.complete();
|
|
1969
|
-
return [3,
|
|
1970
|
-
case
|
|
1971
|
-
case
|
|
1871
|
+
return [3, 4];
|
|
1872
|
+
case 2: return [4, this.view.renderError(PageSnapshot.fromHTMLString(responseHTML_1))];
|
|
1873
|
+
case 3:
|
|
1972
1874
|
_a.sent();
|
|
1973
1875
|
this.adapter.visitRendered(this);
|
|
1974
1876
|
this.fail();
|
|
1975
|
-
_a.label =
|
|
1976
|
-
case
|
|
1877
|
+
_a.label = 4;
|
|
1878
|
+
case 4: return [2];
|
|
1977
1879
|
}
|
|
1978
1880
|
});
|
|
1979
1881
|
}); });
|
|
@@ -2005,24 +1907,14 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2005
1907
|
switch (_a.label) {
|
|
2006
1908
|
case 0:
|
|
2007
1909
|
this.cacheSnapshot();
|
|
2008
|
-
|
|
2009
|
-
this.adapter.visitRendered(this);
|
|
2010
|
-
return [3, 5];
|
|
1910
|
+
return [4, this.view.renderPage(snapshot, isPreview_1)];
|
|
2011
1911
|
case 1:
|
|
2012
|
-
if (!this.view.renderPromise) return [3, 3];
|
|
2013
|
-
return [4, this.view.renderPromise];
|
|
2014
|
-
case 2:
|
|
2015
|
-
_a.sent();
|
|
2016
|
-
_a.label = 3;
|
|
2017
|
-
case 3: return [4, this.view.renderPage(snapshot, isPreview_1)];
|
|
2018
|
-
case 4:
|
|
2019
1912
|
_a.sent();
|
|
2020
1913
|
this.adapter.visitRendered(this);
|
|
2021
1914
|
if (!isPreview_1) {
|
|
2022
1915
|
this.complete();
|
|
2023
1916
|
}
|
|
2024
|
-
|
|
2025
|
-
case 5: return [2];
|
|
1917
|
+
return [2];
|
|
2026
1918
|
}
|
|
2027
1919
|
});
|
|
2028
1920
|
}); });
|
|
@@ -2030,25 +1922,11 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2030
1922
|
};
|
|
2031
1923
|
Visit.prototype.followRedirect = function () {
|
|
2032
1924
|
if (this.redirectedToLocation && !this.followedRedirect) {
|
|
2033
|
-
this.
|
|
2034
|
-
|
|
2035
|
-
response: this.response
|
|
2036
|
-
});
|
|
1925
|
+
this.location = this.redirectedToLocation;
|
|
1926
|
+
this.history.replace(this.redirectedToLocation, this.restorationIdentifier);
|
|
2037
1927
|
this.followedRedirect = true;
|
|
2038
1928
|
}
|
|
2039
1929
|
};
|
|
2040
|
-
Visit.prototype.goToSamePageAnchor = function () {
|
|
2041
|
-
var _this = this;
|
|
2042
|
-
if (this.isSamePage) {
|
|
2043
|
-
this.render(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2044
|
-
return __generator(this, function (_a) {
|
|
2045
|
-
this.cacheSnapshot();
|
|
2046
|
-
this.adapter.visitRendered(this);
|
|
2047
|
-
return [2];
|
|
2048
|
-
});
|
|
2049
|
-
}); });
|
|
2050
|
-
}
|
|
2051
|
-
};
|
|
2052
1930
|
Visit.prototype.requestStarted = function () {
|
|
2053
1931
|
this.startRequest();
|
|
2054
1932
|
};
|
|
@@ -2102,13 +1980,10 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2102
1980
|
Visit.prototype.performScroll = function () {
|
|
2103
1981
|
if (!this.scrolled) {
|
|
2104
1982
|
if (this.action == "restore") {
|
|
2105
|
-
this.scrollToRestoredPosition() || this.
|
|
1983
|
+
this.scrollToRestoredPosition() || this.scrollToTop();
|
|
2106
1984
|
}
|
|
2107
1985
|
else {
|
|
2108
|
-
this.scrollToAnchor() || this.
|
|
2109
|
-
}
|
|
2110
|
-
if (this.isSamePage) {
|
|
2111
|
-
this.delegate.visitScrolledToSamePageLocation(this.view.lastRenderedLocation, this.location);
|
|
1986
|
+
this.scrollToAnchor() || this.scrollToTop();
|
|
2112
1987
|
}
|
|
2113
1988
|
this.scrolled = true;
|
|
2114
1989
|
}
|
|
@@ -2121,12 +1996,14 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2121
1996
|
}
|
|
2122
1997
|
};
|
|
2123
1998
|
Visit.prototype.scrollToAnchor = function () {
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
this.view.scrollToAnchor(anchor);
|
|
1999
|
+
if (getAnchor(this.location)) {
|
|
2000
|
+
this.view.scrollToAnchor(getAnchor(this.location));
|
|
2127
2001
|
return true;
|
|
2128
2002
|
}
|
|
2129
2003
|
};
|
|
2004
|
+
Visit.prototype.scrollToTop = function () {
|
|
2005
|
+
this.view.scrollToPosition({ x: 0, y: 0 });
|
|
2006
|
+
};
|
|
2130
2007
|
Visit.prototype.recordTimingMetric = function (metric) {
|
|
2131
2008
|
this.timingMetrics[metric] = new Date().getTime();
|
|
2132
2009
|
};
|
|
@@ -2144,15 +2021,9 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2144
2021
|
return typeof this.response == "object";
|
|
2145
2022
|
};
|
|
2146
2023
|
Visit.prototype.shouldIssueRequest = function () {
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
else if (this.action == "restore") {
|
|
2151
|
-
return !this.hasCachedSnapshot();
|
|
2152
|
-
}
|
|
2153
|
-
else {
|
|
2154
|
-
return true;
|
|
2155
|
-
}
|
|
2024
|
+
return this.action == "restore"
|
|
2025
|
+
? !this.hasCachedSnapshot()
|
|
2026
|
+
: true;
|
|
2156
2027
|
};
|
|
2157
2028
|
Visit.prototype.cacheSnapshot = function () {
|
|
2158
2029
|
if (!this.snapshotCached) {
|
|
@@ -2172,9 +2043,7 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2172
2043
|
})];
|
|
2173
2044
|
case 1:
|
|
2174
2045
|
_a.sent();
|
|
2175
|
-
|
|
2176
|
-
case 2:
|
|
2177
|
-
_a.sent();
|
|
2046
|
+
callback();
|
|
2178
2047
|
delete this.frame;
|
|
2179
2048
|
this.performScroll();
|
|
2180
2049
|
return [2];
|
|
@@ -2209,7 +2078,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2209
2078
|
BrowserAdapter.prototype.visitStarted = function (visit) {
|
|
2210
2079
|
visit.issueRequest();
|
|
2211
2080
|
visit.changeHistory();
|
|
2212
|
-
visit.goToSamePageAnchor();
|
|
2213
2081
|
visit.loadCachedSnapshot();
|
|
2214
2082
|
};
|
|
2215
2083
|
BrowserAdapter.prototype.visitRequestStarted = function (visit) {
|
|
@@ -2239,6 +2107,7 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2239
2107
|
this.hideProgressBar();
|
|
2240
2108
|
};
|
|
2241
2109
|
BrowserAdapter.prototype.visitCompleted = function (visit) {
|
|
2110
|
+
visit.followRedirect();
|
|
2242
2111
|
};
|
|
2243
2112
|
BrowserAdapter.prototype.pageInvalidated = function () {
|
|
2244
2113
|
this.reload();
|
|
@@ -2247,14 +2116,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2247
2116
|
};
|
|
2248
2117
|
BrowserAdapter.prototype.visitRendered = function (visit) {
|
|
2249
2118
|
};
|
|
2250
|
-
BrowserAdapter.prototype.formSubmissionStarted = function (formSubmission) {
|
|
2251
|
-
this.progressBar.setValue(0);
|
|
2252
|
-
this.showProgressBarAfterDelay();
|
|
2253
|
-
};
|
|
2254
|
-
BrowserAdapter.prototype.formSubmissionFinished = function (formSubmission) {
|
|
2255
|
-
this.progressBar.setValue(1);
|
|
2256
|
-
this.hideProgressBar();
|
|
2257
|
-
};
|
|
2258
2119
|
BrowserAdapter.prototype.showProgressBarAfterDelay = function () {
|
|
2259
2120
|
this.progressBarTimeout = window.setTimeout(this.showProgressBar, this.session.progressBarDelay);
|
|
2260
2121
|
};
|
|
@@ -2499,8 +2360,7 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2499
2360
|
};
|
|
2500
2361
|
this.clickBubbled = function (event) {
|
|
2501
2362
|
if (_this.clickEventIsSignificant(event)) {
|
|
2502
|
-
var
|
|
2503
|
-
var link = _this.findLinkFromClickTarget(target);
|
|
2363
|
+
var link = _this.findLinkFromClickTarget(event.target);
|
|
2504
2364
|
if (link) {
|
|
2505
2365
|
var location_1 = _this.getLocationForLink(link);
|
|
2506
2366
|
if (_this.delegate.willFollowLinkToLocation(link, location_1)) {
|
|
@@ -2554,7 +2414,7 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2554
2414
|
}
|
|
2555
2415
|
Navigator.prototype.proposeVisit = function (location, options) {
|
|
2556
2416
|
if (options === void 0) { options = {}; }
|
|
2557
|
-
if (this.delegate.
|
|
2417
|
+
if (this.delegate.allowsVisitingLocation(location)) {
|
|
2558
2418
|
this.delegate.visitProposedToLocation(location, options);
|
|
2559
2419
|
}
|
|
2560
2420
|
};
|
|
@@ -2606,9 +2466,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2606
2466
|
configurable: true
|
|
2607
2467
|
});
|
|
2608
2468
|
Navigator.prototype.formSubmissionStarted = function (formSubmission) {
|
|
2609
|
-
if (typeof this.adapter.formSubmissionStarted === 'function') {
|
|
2610
|
-
this.adapter.formSubmissionStarted(formSubmission);
|
|
2611
|
-
}
|
|
2612
2469
|
};
|
|
2613
2470
|
Navigator.prototype.formSubmissionSucceededWithResponse = function (formSubmission, fetchResponse) {
|
|
2614
2471
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -2642,22 +2499,14 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2642
2499
|
case 0: return [4, fetchResponse.responseHTML];
|
|
2643
2500
|
case 1:
|
|
2644
2501
|
responseHTML = _a.sent();
|
|
2645
|
-
if (!responseHTML) return [3,
|
|
2502
|
+
if (!responseHTML) return [3, 3];
|
|
2646
2503
|
snapshot = PageSnapshot.fromHTMLString(responseHTML);
|
|
2647
|
-
|
|
2648
|
-
return [4, this.view.renderError(snapshot)];
|
|
2504
|
+
return [4, this.view.renderPage(snapshot)];
|
|
2649
2505
|
case 2:
|
|
2650
2506
|
_a.sent();
|
|
2651
|
-
return [3, 5];
|
|
2652
|
-
case 3: return [4, this.view.renderPage(snapshot)];
|
|
2653
|
-
case 4:
|
|
2654
|
-
_a.sent();
|
|
2655
|
-
_a.label = 5;
|
|
2656
|
-
case 5:
|
|
2657
|
-
this.view.scrollToTop();
|
|
2658
2507
|
this.view.clearSnapshotCache();
|
|
2659
|
-
_a.label =
|
|
2660
|
-
case
|
|
2508
|
+
_a.label = 3;
|
|
2509
|
+
case 3: return [2];
|
|
2661
2510
|
}
|
|
2662
2511
|
});
|
|
2663
2512
|
});
|
|
@@ -2666,9 +2515,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2666
2515
|
console.error(error);
|
|
2667
2516
|
};
|
|
2668
2517
|
Navigator.prototype.formSubmissionFinished = function (formSubmission) {
|
|
2669
|
-
if (typeof this.adapter.formSubmissionFinished === 'function') {
|
|
2670
|
-
this.adapter.formSubmissionFinished(formSubmission);
|
|
2671
|
-
}
|
|
2672
2518
|
};
|
|
2673
2519
|
Navigator.prototype.visitStarted = function (visit) {
|
|
2674
2520
|
this.delegate.visitStarted(visit);
|
|
@@ -2676,17 +2522,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
2676
2522
|
Navigator.prototype.visitCompleted = function (visit) {
|
|
2677
2523
|
this.delegate.visitCompleted(visit);
|
|
2678
2524
|
};
|
|
2679
|
-
Navigator.prototype.locationWithActionIsSamePage = function (location, action) {
|
|
2680
|
-
var anchor = getAnchor(location);
|
|
2681
|
-
var currentAnchor = getAnchor(this.view.lastRenderedLocation);
|
|
2682
|
-
var isRestorationToTop = action === 'restore' && typeof anchor === 'undefined';
|
|
2683
|
-
return action !== "replace" &&
|
|
2684
|
-
getRequestURL(location) === getRequestURL(this.view.lastRenderedLocation) &&
|
|
2685
|
-
(isRestorationToTop || (anchor != null && anchor !== currentAnchor));
|
|
2686
|
-
};
|
|
2687
|
-
Navigator.prototype.visitScrolledToSamePageLocation = function (oldURL, newURL) {
|
|
2688
|
-
this.delegate.visitScrolledToSamePageLocation(oldURL, newURL);
|
|
2689
|
-
};
|
|
2690
2525
|
Object.defineProperty(Navigator.prototype, "location", {
|
|
2691
2526
|
get: function () {
|
|
2692
2527
|
return this.history.location;
|
|
@@ -3132,7 +2967,7 @@ Copyright © 2021 Basecamp, LLC
|
|
|
3132
2967
|
});
|
|
3133
2968
|
Object.defineProperty(PageRenderer.prototype, "newBodyScriptElements", {
|
|
3134
2969
|
get: function () {
|
|
3135
|
-
return this.newElement.querySelectorAll("script");
|
|
2970
|
+
return __spread(this.newElement.querySelectorAll("script"));
|
|
3136
2971
|
},
|
|
3137
2972
|
enumerable: false,
|
|
3138
2973
|
configurable: true
|
|
@@ -3212,7 +3047,7 @@ Copyright © 2021 Basecamp, LLC
|
|
|
3212
3047
|
};
|
|
3213
3048
|
PageView.prototype.renderError = function (snapshot) {
|
|
3214
3049
|
var renderer = new ErrorRenderer(this.snapshot, snapshot, false);
|
|
3215
|
-
|
|
3050
|
+
this.render(renderer);
|
|
3216
3051
|
};
|
|
3217
3052
|
PageView.prototype.clearSnapshotCache = function () {
|
|
3218
3053
|
this.snapshotCache.clear();
|
|
@@ -3269,7 +3104,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
3269
3104
|
this.scrollObserver = new ScrollObserver(this);
|
|
3270
3105
|
this.streamObserver = new StreamObserver(this);
|
|
3271
3106
|
this.frameRedirector = new FrameRedirector(document.documentElement);
|
|
3272
|
-
this.drive = true;
|
|
3273
3107
|
this.enabled = true;
|
|
3274
3108
|
this.progressBarDelay = 500;
|
|
3275
3109
|
this.started = false;
|
|
@@ -3340,9 +3174,9 @@ Copyright © 2021 Basecamp, LLC
|
|
|
3340
3174
|
enumerable: false,
|
|
3341
3175
|
configurable: true
|
|
3342
3176
|
});
|
|
3343
|
-
Session.prototype.historyPoppedToLocationWithRestorationIdentifier = function (location
|
|
3177
|
+
Session.prototype.historyPoppedToLocationWithRestorationIdentifier = function (location) {
|
|
3344
3178
|
if (this.enabled) {
|
|
3345
|
-
this.navigator.
|
|
3179
|
+
this.navigator.proposeVisit(location, { action: "restore", historyChanged: true });
|
|
3346
3180
|
}
|
|
3347
3181
|
else {
|
|
3348
3182
|
this.adapter.pageInvalidated();
|
|
@@ -3352,29 +3186,16 @@ Copyright © 2021 Basecamp, LLC
|
|
|
3352
3186
|
this.history.updateRestorationData({ scrollPosition: position });
|
|
3353
3187
|
};
|
|
3354
3188
|
Session.prototype.willFollowLinkToLocation = function (link, location) {
|
|
3355
|
-
return
|
|
3189
|
+
return elementIsNavigable(link)
|
|
3356
3190
|
&& this.locationIsVisitable(location)
|
|
3357
3191
|
&& this.applicationAllowsFollowingLinkToLocation(link, location);
|
|
3358
3192
|
};
|
|
3359
3193
|
Session.prototype.followedLinkToLocation = function (link, location) {
|
|
3360
3194
|
var action = this.getActionForLink(link);
|
|
3361
|
-
this.
|
|
3362
|
-
};
|
|
3363
|
-
Session.prototype.convertLinkWithMethodClickToFormSubmission = function (link) {
|
|
3364
|
-
var linkMethod = link.getAttribute("data-turbo-method");
|
|
3365
|
-
if (linkMethod) {
|
|
3366
|
-
var form = document.createElement("form");
|
|
3367
|
-
form.method = linkMethod;
|
|
3368
|
-
form.action = link.getAttribute("href") || "undefined";
|
|
3369
|
-
document.body.appendChild(form);
|
|
3370
|
-
return dispatch("submit", { cancelable: true, target: form });
|
|
3371
|
-
}
|
|
3372
|
-
else {
|
|
3373
|
-
return false;
|
|
3374
|
-
}
|
|
3195
|
+
this.visit(location.href, { action: action });
|
|
3375
3196
|
};
|
|
3376
|
-
Session.prototype.
|
|
3377
|
-
return this.
|
|
3197
|
+
Session.prototype.allowsVisitingLocation = function (location) {
|
|
3198
|
+
return this.applicationAllowsVisitingLocation(location);
|
|
3378
3199
|
};
|
|
3379
3200
|
Session.prototype.visitProposedToLocation = function (location, options) {
|
|
3380
3201
|
extendURLWithDeprecatedProperties(location);
|
|
@@ -3382,21 +3203,13 @@ Copyright © 2021 Basecamp, LLC
|
|
|
3382
3203
|
};
|
|
3383
3204
|
Session.prototype.visitStarted = function (visit) {
|
|
3384
3205
|
extendURLWithDeprecatedProperties(visit.location);
|
|
3385
|
-
|
|
3386
|
-
this.notifyApplicationAfterVisitingLocation(visit.location, visit.action);
|
|
3387
|
-
}
|
|
3206
|
+
this.notifyApplicationAfterVisitingLocation(visit.location);
|
|
3388
3207
|
};
|
|
3389
3208
|
Session.prototype.visitCompleted = function (visit) {
|
|
3390
3209
|
this.notifyApplicationAfterPageLoad(visit.getTimingMetrics());
|
|
3391
3210
|
};
|
|
3392
|
-
Session.prototype.locationWithActionIsSamePage = function (location, action) {
|
|
3393
|
-
return this.navigator.locationWithActionIsSamePage(location, action);
|
|
3394
|
-
};
|
|
3395
|
-
Session.prototype.visitScrolledToSamePageLocation = function (oldURL, newURL) {
|
|
3396
|
-
this.notifyApplicationAfterVisitingSamePageLocation(oldURL, newURL);
|
|
3397
|
-
};
|
|
3398
3211
|
Session.prototype.willSubmitForm = function (form, submitter) {
|
|
3399
|
-
return
|
|
3212
|
+
return elementIsNavigable(form) && elementIsNavigable(submitter);
|
|
3400
3213
|
};
|
|
3401
3214
|
Session.prototype.formSubmitted = function (form, submitter) {
|
|
3402
3215
|
this.navigator.submitForm(form, submitter);
|
|
@@ -3415,15 +3228,11 @@ Copyright © 2021 Basecamp, LLC
|
|
|
3415
3228
|
this.renderStreamMessage(message);
|
|
3416
3229
|
};
|
|
3417
3230
|
Session.prototype.viewWillCacheSnapshot = function () {
|
|
3418
|
-
|
|
3419
|
-
if (!((_a = this.navigator.currentVisit) === null || _a === void 0 ? void 0 : _a.silent)) {
|
|
3420
|
-
this.notifyApplicationBeforeCachingSnapshot();
|
|
3421
|
-
}
|
|
3231
|
+
this.notifyApplicationBeforeCachingSnapshot();
|
|
3422
3232
|
};
|
|
3423
|
-
Session.prototype.
|
|
3233
|
+
Session.prototype.viewWillRenderSnapshot = function (_a, isPreview) {
|
|
3424
3234
|
var element = _a.element;
|
|
3425
|
-
|
|
3426
|
-
return !event.defaultPrevented;
|
|
3235
|
+
this.notifyApplicationBeforeRender(element);
|
|
3427
3236
|
};
|
|
3428
3237
|
Session.prototype.viewRenderedSnapshot = function (snapshot, isPreview) {
|
|
3429
3238
|
this.view.lastRenderedLocation = this.history.location;
|
|
@@ -3432,12 +3241,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
3432
3241
|
Session.prototype.viewInvalidated = function () {
|
|
3433
3242
|
this.adapter.pageInvalidated();
|
|
3434
3243
|
};
|
|
3435
|
-
Session.prototype.frameLoaded = function (frame) {
|
|
3436
|
-
this.notifyApplicationAfterFrameLoad(frame);
|
|
3437
|
-
};
|
|
3438
|
-
Session.prototype.frameRendered = function (fetchResponse, frame) {
|
|
3439
|
-
this.notifyApplicationAfterFrameRender(fetchResponse, frame);
|
|
3440
|
-
};
|
|
3441
3244
|
Session.prototype.applicationAllowsFollowingLinkToLocation = function (link, location) {
|
|
3442
3245
|
var event = this.notifyApplicationAfterClickingLinkToLocation(link, location);
|
|
3443
3246
|
return !event.defaultPrevented;
|
|
@@ -3452,14 +3255,14 @@ Copyright © 2021 Basecamp, LLC
|
|
|
3452
3255
|
Session.prototype.notifyApplicationBeforeVisitingLocation = function (location) {
|
|
3453
3256
|
return dispatch("turbo:before-visit", { detail: { url: location.href }, cancelable: true });
|
|
3454
3257
|
};
|
|
3455
|
-
Session.prototype.notifyApplicationAfterVisitingLocation = function (location
|
|
3456
|
-
return dispatch("turbo:visit", { detail: { url: location.href
|
|
3258
|
+
Session.prototype.notifyApplicationAfterVisitingLocation = function (location) {
|
|
3259
|
+
return dispatch("turbo:visit", { detail: { url: location.href } });
|
|
3457
3260
|
};
|
|
3458
3261
|
Session.prototype.notifyApplicationBeforeCachingSnapshot = function () {
|
|
3459
3262
|
return dispatch("turbo:before-cache");
|
|
3460
3263
|
};
|
|
3461
|
-
Session.prototype.notifyApplicationBeforeRender = function (newBody
|
|
3462
|
-
return dispatch("turbo:before-render", { detail: { newBody: newBody
|
|
3264
|
+
Session.prototype.notifyApplicationBeforeRender = function (newBody) {
|
|
3265
|
+
return dispatch("turbo:before-render", { detail: { newBody: newBody } });
|
|
3463
3266
|
};
|
|
3464
3267
|
Session.prototype.notifyApplicationAfterRender = function () {
|
|
3465
3268
|
return dispatch("turbo:render");
|
|
@@ -3468,34 +3271,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
3468
3271
|
if (timing === void 0) { timing = {}; }
|
|
3469
3272
|
return dispatch("turbo:load", { detail: { url: this.location.href, timing: timing } });
|
|
3470
3273
|
};
|
|
3471
|
-
Session.prototype.notifyApplicationAfterVisitingSamePageLocation = function (oldURL, newURL) {
|
|
3472
|
-
dispatchEvent(new HashChangeEvent("hashchange", { oldURL: oldURL.toString(), newURL: newURL.toString() }));
|
|
3473
|
-
};
|
|
3474
|
-
Session.prototype.notifyApplicationAfterFrameLoad = function (frame) {
|
|
3475
|
-
return dispatch("turbo:frame-load", { target: frame });
|
|
3476
|
-
};
|
|
3477
|
-
Session.prototype.notifyApplicationAfterFrameRender = function (fetchResponse, frame) {
|
|
3478
|
-
return dispatch("turbo:frame-render", { detail: { fetchResponse: fetchResponse }, target: frame, cancelable: true });
|
|
3479
|
-
};
|
|
3480
|
-
Session.prototype.elementDriveEnabled = function (element) {
|
|
3481
|
-
var container = element === null || element === void 0 ? void 0 : element.closest("[data-turbo]");
|
|
3482
|
-
if (this.drive) {
|
|
3483
|
-
if (container) {
|
|
3484
|
-
return container.getAttribute("data-turbo") != "false";
|
|
3485
|
-
}
|
|
3486
|
-
else {
|
|
3487
|
-
return true;
|
|
3488
|
-
}
|
|
3489
|
-
}
|
|
3490
|
-
else {
|
|
3491
|
-
if (container) {
|
|
3492
|
-
return container.getAttribute("data-turbo") == "true";
|
|
3493
|
-
}
|
|
3494
|
-
else {
|
|
3495
|
-
return false;
|
|
3496
|
-
}
|
|
3497
|
-
}
|
|
3498
|
-
};
|
|
3499
3274
|
Session.prototype.getActionForLink = function (link) {
|
|
3500
3275
|
var action = link.getAttribute("data-turbo-action");
|
|
3501
3276
|
return isAction(action) ? action : "advance";
|
|
@@ -3512,6 +3287,15 @@ Copyright © 2021 Basecamp, LLC
|
|
|
3512
3287
|
});
|
|
3513
3288
|
return Session;
|
|
3514
3289
|
}());
|
|
3290
|
+
function elementIsNavigable(element) {
|
|
3291
|
+
var container = element === null || element === void 0 ? void 0 : element.closest("[data-turbo]");
|
|
3292
|
+
if (container) {
|
|
3293
|
+
return container.getAttribute("data-turbo") != "false";
|
|
3294
|
+
}
|
|
3295
|
+
else {
|
|
3296
|
+
return true;
|
|
3297
|
+
}
|
|
3298
|
+
}
|
|
3515
3299
|
function extendURLWithDeprecatedProperties(url) {
|
|
3516
3300
|
Object.defineProperties(url, deprecatedLocationPropertyDescriptors);
|
|
3517
3301
|
}
|
|
@@ -3523,49 +3307,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
3523
3307
|
}
|
|
3524
3308
|
};
|
|
3525
3309
|
|
|
3526
|
-
var session = new Session;
|
|
3527
|
-
var navigator = session.navigator;
|
|
3528
|
-
function start() {
|
|
3529
|
-
session.start();
|
|
3530
|
-
}
|
|
3531
|
-
function registerAdapter(adapter) {
|
|
3532
|
-
session.registerAdapter(adapter);
|
|
3533
|
-
}
|
|
3534
|
-
function visit(location, options) {
|
|
3535
|
-
session.visit(location, options);
|
|
3536
|
-
}
|
|
3537
|
-
function connectStreamSource(source) {
|
|
3538
|
-
session.connectStreamSource(source);
|
|
3539
|
-
}
|
|
3540
|
-
function disconnectStreamSource(source) {
|
|
3541
|
-
session.disconnectStreamSource(source);
|
|
3542
|
-
}
|
|
3543
|
-
function renderStreamMessage(message) {
|
|
3544
|
-
session.renderStreamMessage(message);
|
|
3545
|
-
}
|
|
3546
|
-
function clearCache() {
|
|
3547
|
-
session.clearCache();
|
|
3548
|
-
}
|
|
3549
|
-
function setProgressBarDelay(delay) {
|
|
3550
|
-
session.setProgressBarDelay(delay);
|
|
3551
|
-
}
|
|
3552
|
-
|
|
3553
|
-
var Turbo = /*#__PURE__*/Object.freeze({
|
|
3554
|
-
__proto__: null,
|
|
3555
|
-
navigator: navigator,
|
|
3556
|
-
session: session,
|
|
3557
|
-
PageRenderer: PageRenderer,
|
|
3558
|
-
PageSnapshot: PageSnapshot,
|
|
3559
|
-
start: start,
|
|
3560
|
-
registerAdapter: registerAdapter,
|
|
3561
|
-
visit: visit,
|
|
3562
|
-
connectStreamSource: connectStreamSource,
|
|
3563
|
-
disconnectStreamSource: disconnectStreamSource,
|
|
3564
|
-
renderStreamMessage: renderStreamMessage,
|
|
3565
|
-
clearCache: clearCache,
|
|
3566
|
-
setProgressBarDelay: setProgressBarDelay
|
|
3567
|
-
});
|
|
3568
|
-
|
|
3569
3310
|
var FrameController = (function () {
|
|
3570
3311
|
function FrameController(element) {
|
|
3571
3312
|
this.resolveVisitPromise = function () { };
|
|
@@ -3581,7 +3322,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
3581
3322
|
FrameController.prototype.connect = function () {
|
|
3582
3323
|
if (!this.connected) {
|
|
3583
3324
|
this.connected = true;
|
|
3584
|
-
this.reloadable = false;
|
|
3585
3325
|
if (this.loadingStyle == FrameLoadingStyle.lazy) {
|
|
3586
3326
|
this.appearanceObserver.start();
|
|
3587
3327
|
}
|
|
@@ -3623,7 +3363,7 @@ Copyright © 2021 Basecamp, LLC
|
|
|
3623
3363
|
return __generator(this, function (_a) {
|
|
3624
3364
|
switch (_a.label) {
|
|
3625
3365
|
case 0:
|
|
3626
|
-
if (!(!this.settingSourceURL && this.enabled && this.isActive &&
|
|
3366
|
+
if (!(!this.settingSourceURL && this.enabled && this.isActive && this.sourceURL != this.currentURL)) return [3, 4];
|
|
3627
3367
|
previousURL = this.currentURL;
|
|
3628
3368
|
this.currentURL = this.sourceURL;
|
|
3629
3369
|
if (!this.sourceURL) return [3, 4];
|
|
@@ -3636,7 +3376,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
3636
3376
|
case 2:
|
|
3637
3377
|
_a.sent();
|
|
3638
3378
|
this.hasBeenLoaded = true;
|
|
3639
|
-
session.frameLoaded(this.element);
|
|
3640
3379
|
return [3, 4];
|
|
3641
3380
|
case 3:
|
|
3642
3381
|
error_1 = _a.sent();
|
|
@@ -3658,34 +3397,28 @@ Copyright © 2021 Basecamp, LLC
|
|
|
3658
3397
|
}
|
|
3659
3398
|
_b.label = 1;
|
|
3660
3399
|
case 1:
|
|
3661
|
-
_b.trys.push([1,
|
|
3400
|
+
_b.trys.push([1, 6, , 7]);
|
|
3662
3401
|
return [4, fetchResponse.responseHTML];
|
|
3663
3402
|
case 2:
|
|
3664
3403
|
html = _b.sent();
|
|
3665
|
-
if (!html) return [3,
|
|
3404
|
+
if (!html) return [3, 5];
|
|
3666
3405
|
body = parseHTMLDocument(html).body;
|
|
3667
3406
|
_a = Snapshot.bind;
|
|
3668
3407
|
return [4, this.extractForeignFrameElement(body)];
|
|
3669
3408
|
case 3:
|
|
3670
3409
|
snapshot = new (_a.apply(Snapshot, [void 0, _b.sent()]))();
|
|
3671
3410
|
renderer = new FrameRenderer(this.view.snapshot, snapshot, false);
|
|
3672
|
-
|
|
3673
|
-
return [4, this.view.renderPromise];
|
|
3411
|
+
return [4, this.view.render(renderer)];
|
|
3674
3412
|
case 4:
|
|
3675
3413
|
_b.sent();
|
|
3676
3414
|
_b.label = 5;
|
|
3677
|
-
case 5: return [
|
|
3415
|
+
case 5: return [3, 7];
|
|
3678
3416
|
case 6:
|
|
3679
|
-
_b.sent();
|
|
3680
|
-
session.frameRendered(fetchResponse, this.element);
|
|
3681
|
-
_b.label = 7;
|
|
3682
|
-
case 7: return [3, 9];
|
|
3683
|
-
case 8:
|
|
3684
3417
|
error_2 = _b.sent();
|
|
3685
3418
|
console.error(error_2);
|
|
3686
3419
|
this.view.invalidate();
|
|
3687
|
-
return [3,
|
|
3688
|
-
case
|
|
3420
|
+
return [3, 7];
|
|
3421
|
+
case 7: return [2];
|
|
3689
3422
|
}
|
|
3690
3423
|
});
|
|
3691
3424
|
});
|
|
@@ -3694,15 +3427,9 @@ Copyright © 2021 Basecamp, LLC
|
|
|
3694
3427
|
this.loadSourceURL();
|
|
3695
3428
|
};
|
|
3696
3429
|
FrameController.prototype.shouldInterceptLinkClick = function (element, url) {
|
|
3697
|
-
|
|
3698
|
-
return false;
|
|
3699
|
-
}
|
|
3700
|
-
else {
|
|
3701
|
-
return this.shouldInterceptNavigation(element);
|
|
3702
|
-
}
|
|
3430
|
+
return this.shouldInterceptNavigation(element);
|
|
3703
3431
|
};
|
|
3704
3432
|
FrameController.prototype.linkClickIntercepted = function (element, url) {
|
|
3705
|
-
this.reloadable = true;
|
|
3706
3433
|
this.navigateFrame(element, url);
|
|
3707
3434
|
};
|
|
3708
3435
|
FrameController.prototype.shouldInterceptFormSubmission = function (element, submitter) {
|
|
@@ -3712,7 +3439,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
3712
3439
|
if (this.formSubmission) {
|
|
3713
3440
|
this.formSubmission.stop();
|
|
3714
3441
|
}
|
|
3715
|
-
this.reloadable = false;
|
|
3716
3442
|
this.formSubmission = new FormSubmission(this, element, submitter);
|
|
3717
3443
|
if (this.formSubmission.fetchRequest.isIdempotent) {
|
|
3718
3444
|
this.navigateFrame(element, this.formSubmission.fetchRequest.url.href);
|
|
@@ -3774,8 +3500,7 @@ Copyright © 2021 Basecamp, LLC
|
|
|
3774
3500
|
var frame = this.findFrameElement(formSubmission.formElement);
|
|
3775
3501
|
frame.removeAttribute("busy");
|
|
3776
3502
|
};
|
|
3777
|
-
FrameController.prototype.
|
|
3778
|
-
return true;
|
|
3503
|
+
FrameController.prototype.viewWillRenderSnapshot = function (snapshot, isPreview) {
|
|
3779
3504
|
};
|
|
3780
3505
|
FrameController.prototype.viewRenderedSnapshot = function (snapshot, isPreview) {
|
|
3781
3506
|
};
|
|
@@ -3848,10 +3573,10 @@ Copyright © 2021 Basecamp, LLC
|
|
|
3848
3573
|
return !frameElement_1.disabled;
|
|
3849
3574
|
}
|
|
3850
3575
|
}
|
|
3851
|
-
if (!
|
|
3576
|
+
if (!elementIsNavigable(element)) {
|
|
3852
3577
|
return false;
|
|
3853
3578
|
}
|
|
3854
|
-
if (submitter && !
|
|
3579
|
+
if (submitter && !elementIsNavigable(submitter)) {
|
|
3855
3580
|
return false;
|
|
3856
3581
|
}
|
|
3857
3582
|
return true;
|
|
@@ -3885,23 +3610,6 @@ Copyright © 2021 Basecamp, LLC
|
|
|
3885
3610
|
enumerable: false,
|
|
3886
3611
|
configurable: true
|
|
3887
3612
|
});
|
|
3888
|
-
Object.defineProperty(FrameController.prototype, "reloadable", {
|
|
3889
|
-
get: function () {
|
|
3890
|
-
var frame = this.findFrameElement(this.element);
|
|
3891
|
-
return frame.hasAttribute("reloadable");
|
|
3892
|
-
},
|
|
3893
|
-
set: function (value) {
|
|
3894
|
-
var frame = this.findFrameElement(this.element);
|
|
3895
|
-
if (value) {
|
|
3896
|
-
frame.setAttribute("reloadable", "");
|
|
3897
|
-
}
|
|
3898
|
-
else {
|
|
3899
|
-
frame.removeAttribute("reloadable");
|
|
3900
|
-
}
|
|
3901
|
-
},
|
|
3902
|
-
enumerable: false,
|
|
3903
|
-
configurable: true
|
|
3904
|
-
});
|
|
3905
3613
|
Object.defineProperty(FrameController.prototype, "loadingStyle", {
|
|
3906
3614
|
get: function () {
|
|
3907
3615
|
return this.element.loading;
|
|
@@ -4181,24 +3889,61 @@ Copyright © 2021 Basecamp, LLC
|
|
|
4181
3889
|
return;
|
|
4182
3890
|
while (element = element.parentElement) {
|
|
4183
3891
|
if (element == document.body) {
|
|
4184
|
-
return console.warn(unindent(templateObject_1$1 || (templateObject_1$1 = __makeTemplateObject(["\n You are loading Turbo from a <script> element inside the <body> element. This is probably not what you meant to do!\n\n Load your application\u2019s JavaScript bundle inside the <head> element instead. <script> elements in <body> are evaluated with each page change.\n\n For more information, see: https://turbo.
|
|
3892
|
+
return console.warn(unindent(templateObject_1$1 || (templateObject_1$1 = __makeTemplateObject(["\n You are loading Turbo from a <script> element inside the <body> element. This is probably not what you meant to do!\n\n Load your application\u2019s JavaScript bundle inside the <head> element instead. <script> elements in <body> are evaluated with each page change.\n\n For more information, see: https://turbo.hotwire.dev/handbook/building#working-with-script-elements\n\n \u2014\u2014\n Suppress this warning by adding a \"data-turbo-suppress-warning\" attribute to: %s\n "], ["\n You are loading Turbo from a <script> element inside the <body> element. This is probably not what you meant to do!\n\n Load your application\u2019s JavaScript bundle inside the <head> element instead. <script> elements in <body> are evaluated with each page change.\n\n For more information, see: https://turbo.hotwire.dev/handbook/building#working-with-script-elements\n\n \u2014\u2014\n Suppress this warning by adding a \"data-turbo-suppress-warning\" attribute to: %s\n "]))), element.outerHTML);
|
|
4185
3893
|
}
|
|
4186
3894
|
}
|
|
4187
3895
|
})();
|
|
4188
3896
|
var templateObject_1$1;
|
|
4189
3897
|
|
|
3898
|
+
var session = new Session;
|
|
3899
|
+
var navigator = session.navigator;
|
|
3900
|
+
function start() {
|
|
3901
|
+
session.start();
|
|
3902
|
+
}
|
|
3903
|
+
function registerAdapter(adapter) {
|
|
3904
|
+
session.registerAdapter(adapter);
|
|
3905
|
+
}
|
|
3906
|
+
function visit(location, options) {
|
|
3907
|
+
session.visit(location, options);
|
|
3908
|
+
}
|
|
3909
|
+
function connectStreamSource(source) {
|
|
3910
|
+
session.connectStreamSource(source);
|
|
3911
|
+
}
|
|
3912
|
+
function disconnectStreamSource(source) {
|
|
3913
|
+
session.disconnectStreamSource(source);
|
|
3914
|
+
}
|
|
3915
|
+
function renderStreamMessage(message) {
|
|
3916
|
+
session.renderStreamMessage(message);
|
|
3917
|
+
}
|
|
3918
|
+
function clearCache() {
|
|
3919
|
+
session.clearCache();
|
|
3920
|
+
}
|
|
3921
|
+
function setProgressBarDelay(delay) {
|
|
3922
|
+
session.setProgressBarDelay(delay);
|
|
3923
|
+
}
|
|
3924
|
+
|
|
3925
|
+
var Turbo = /*#__PURE__*/Object.freeze({
|
|
3926
|
+
__proto__: null,
|
|
3927
|
+
navigator: navigator,
|
|
3928
|
+
start: start,
|
|
3929
|
+
registerAdapter: registerAdapter,
|
|
3930
|
+
visit: visit,
|
|
3931
|
+
connectStreamSource: connectStreamSource,
|
|
3932
|
+
disconnectStreamSource: disconnectStreamSource,
|
|
3933
|
+
renderStreamMessage: renderStreamMessage,
|
|
3934
|
+
clearCache: clearCache,
|
|
3935
|
+
setProgressBarDelay: setProgressBarDelay
|
|
3936
|
+
});
|
|
3937
|
+
|
|
4190
3938
|
window.Turbo = Turbo;
|
|
4191
3939
|
start();
|
|
4192
3940
|
|
|
4193
|
-
exports.PageRenderer = PageRenderer;
|
|
4194
|
-
exports.PageSnapshot = PageSnapshot;
|
|
4195
3941
|
exports.clearCache = clearCache;
|
|
4196
3942
|
exports.connectStreamSource = connectStreamSource;
|
|
4197
3943
|
exports.disconnectStreamSource = disconnectStreamSource;
|
|
4198
3944
|
exports.navigator = navigator;
|
|
4199
3945
|
exports.registerAdapter = registerAdapter;
|
|
4200
3946
|
exports.renderStreamMessage = renderStreamMessage;
|
|
4201
|
-
exports.session = session;
|
|
4202
3947
|
exports.setProgressBarDelay = setProgressBarDelay;
|
|
4203
3948
|
exports.start = start;
|
|
4204
3949
|
exports.visit = visit;
|