@hotwired/turbo 7.2.0-rc.2 → 7.2.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 +20 -35
- package/dist/turbo.es2017-umd.js +20 -35
- package/dist/types/core/drive/navigator.d.ts +4 -4
- package/dist/types/core/drive/visit.d.ts +1 -4
- package/dist/types/core/index.d.ts +2 -2
- package/dist/types/core/native/adapter.d.ts +1 -1
- package/dist/types/core/native/browser_adapter.d.ts +1 -1
- package/dist/types/core/session.d.ts +6 -6
- package/dist/types/core/types.d.ts +0 -4
- package/dist/types/http/fetch_request.d.ts +3 -2
- package/dist/types/tests/unit/deprecated_adapter_support_test.d.ts +1 -1
- package/dist/types/tests/unit/export_tests.d.ts +5 -0
- package/dist/types/tests/unit/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/turbo.es2017-esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Turbo 7.2.0-rc.
|
|
2
|
+
Turbo 7.2.0-rc.3
|
|
3
3
|
Copyright © 2022 Basecamp, LLC
|
|
4
4
|
*/
|
|
5
5
|
(function () {
|
|
@@ -1625,7 +1625,6 @@ const defaultOptions = {
|
|
|
1625
1625
|
updateHistory: true,
|
|
1626
1626
|
shouldCacheSnapshot: true,
|
|
1627
1627
|
acceptsStreamResponse: false,
|
|
1628
|
-
initiator: document.documentElement,
|
|
1629
1628
|
};
|
|
1630
1629
|
var SystemStatusCode;
|
|
1631
1630
|
(function (SystemStatusCode) {
|
|
@@ -1635,6 +1634,7 @@ var SystemStatusCode;
|
|
|
1635
1634
|
})(SystemStatusCode || (SystemStatusCode = {}));
|
|
1636
1635
|
class Visit {
|
|
1637
1636
|
constructor(delegate, location, restorationIdentifier, options = {}) {
|
|
1637
|
+
this.identifier = uuid();
|
|
1638
1638
|
this.timingMetrics = {};
|
|
1639
1639
|
this.followedRedirect = false;
|
|
1640
1640
|
this.historyChanged = false;
|
|
@@ -1646,8 +1646,7 @@ class Visit {
|
|
|
1646
1646
|
this.delegate = delegate;
|
|
1647
1647
|
this.location = location;
|
|
1648
1648
|
this.restorationIdentifier = restorationIdentifier || uuid();
|
|
1649
|
-
|
|
1650
|
-
const { action, historyChanged, referrer, snapshotHTML, response, visitCachedSnapshot, willRender, updateHistory, shouldCacheSnapshot, acceptsStreamResponse, initiator, } = Object.assign(Object.assign({}, defaultOptions), options);
|
|
1649
|
+
const { action, historyChanged, referrer, snapshotHTML, response, visitCachedSnapshot, willRender, updateHistory, shouldCacheSnapshot, acceptsStreamResponse, } = Object.assign(Object.assign({}, defaultOptions), options);
|
|
1651
1650
|
this.action = action;
|
|
1652
1651
|
this.historyChanged = historyChanged;
|
|
1653
1652
|
this.referrer = referrer;
|
|
@@ -1660,7 +1659,6 @@ class Visit {
|
|
|
1660
1659
|
this.scrolled = !willRender;
|
|
1661
1660
|
this.shouldCacheSnapshot = shouldCacheSnapshot;
|
|
1662
1661
|
this.acceptsStreamResponse = acceptsStreamResponse;
|
|
1663
|
-
this.initiator = initiator;
|
|
1664
1662
|
}
|
|
1665
1663
|
get adapter() {
|
|
1666
1664
|
return this.delegate.adapter;
|
|
@@ -1692,7 +1690,6 @@ class Visit {
|
|
|
1692
1690
|
}
|
|
1693
1691
|
this.cancelRender();
|
|
1694
1692
|
this.state = VisitState.canceled;
|
|
1695
|
-
this.resolvingFunctions.reject();
|
|
1696
1693
|
}
|
|
1697
1694
|
}
|
|
1698
1695
|
complete() {
|
|
@@ -1704,14 +1701,12 @@ class Visit {
|
|
|
1704
1701
|
this.adapter.visitCompleted(this);
|
|
1705
1702
|
this.delegate.visitCompleted(this);
|
|
1706
1703
|
}
|
|
1707
|
-
this.resolvingFunctions.resolve();
|
|
1708
1704
|
}
|
|
1709
1705
|
}
|
|
1710
1706
|
fail() {
|
|
1711
1707
|
if (this.state == VisitState.started) {
|
|
1712
1708
|
this.state = VisitState.failed;
|
|
1713
1709
|
this.adapter.visitFailed(this);
|
|
1714
|
-
this.resolvingFunctions.reject();
|
|
1715
1710
|
}
|
|
1716
1711
|
}
|
|
1717
1712
|
changeHistory() {
|
|
@@ -1728,7 +1723,7 @@ class Visit {
|
|
|
1728
1723
|
this.simulateRequest();
|
|
1729
1724
|
}
|
|
1730
1725
|
else if (this.shouldIssueRequest() && !this.request) {
|
|
1731
|
-
this.request = new FetchRequest(this, FetchMethod.get, this.location
|
|
1726
|
+
this.request = new FetchRequest(this, FetchMethod.get, this.location);
|
|
1732
1727
|
this.request.perform();
|
|
1733
1728
|
}
|
|
1734
1729
|
}
|
|
@@ -1974,7 +1969,7 @@ class BrowserAdapter {
|
|
|
1974
1969
|
this.session = session;
|
|
1975
1970
|
}
|
|
1976
1971
|
visitProposedToLocation(location, options) {
|
|
1977
|
-
|
|
1972
|
+
this.navigator.startVisit(location, (options === null || options === void 0 ? void 0 : options.restorationIdentifier) || uuid(), options);
|
|
1978
1973
|
}
|
|
1979
1974
|
visitStarted(visit) {
|
|
1980
1975
|
this.location = visit.location;
|
|
@@ -2233,25 +2228,20 @@ class Navigator {
|
|
|
2233
2228
|
this.delegate = delegate;
|
|
2234
2229
|
}
|
|
2235
2230
|
proposeVisit(location, options = {}) {
|
|
2236
|
-
if (this.delegate.
|
|
2231
|
+
if (this.delegate.allowsVisitingLocationWithAction(location, options.action)) {
|
|
2237
2232
|
if (locationIsVisitable(location, this.view.snapshot.rootLocation)) {
|
|
2238
|
-
|
|
2233
|
+
this.delegate.visitProposedToLocation(location, options);
|
|
2239
2234
|
}
|
|
2240
2235
|
else {
|
|
2241
2236
|
window.location.href = location.toString();
|
|
2242
|
-
return Promise.resolve();
|
|
2243
2237
|
}
|
|
2244
2238
|
}
|
|
2245
|
-
else {
|
|
2246
|
-
return Promise.reject();
|
|
2247
|
-
}
|
|
2248
2239
|
}
|
|
2249
2240
|
startVisit(locatable, restorationIdentifier, options = {}) {
|
|
2250
2241
|
this.lastVisit = this.currentVisit;
|
|
2251
2242
|
this.stop();
|
|
2252
2243
|
this.currentVisit = new Visit(this, expandURL(locatable), restorationIdentifier, Object.assign({ referrer: this.location }, options));
|
|
2253
2244
|
this.currentVisit.start();
|
|
2254
|
-
return this.currentVisit.promise;
|
|
2255
2245
|
}
|
|
2256
2246
|
submitForm(form, submitter) {
|
|
2257
2247
|
this.stop();
|
|
@@ -2872,10 +2862,10 @@ class Session {
|
|
|
2872
2862
|
const frameElement = options.frame ? document.getElementById(options.frame) : null;
|
|
2873
2863
|
if (frameElement instanceof FrameElement) {
|
|
2874
2864
|
frameElement.src = location.toString();
|
|
2875
|
-
|
|
2865
|
+
frameElement.loaded;
|
|
2876
2866
|
}
|
|
2877
2867
|
else {
|
|
2878
|
-
|
|
2868
|
+
this.navigator.proposeVisit(expandURL(location), options);
|
|
2879
2869
|
}
|
|
2880
2870
|
}
|
|
2881
2871
|
connectStreamSource(source) {
|
|
@@ -2930,15 +2920,14 @@ class Session {
|
|
|
2930
2920
|
followedLinkToLocation(link, location) {
|
|
2931
2921
|
const action = this.getActionForLink(link);
|
|
2932
2922
|
const acceptsStreamResponse = link.hasAttribute("data-turbo-stream");
|
|
2933
|
-
this.visit(location.href, { action, acceptsStreamResponse
|
|
2923
|
+
this.visit(location.href, { action, acceptsStreamResponse });
|
|
2934
2924
|
}
|
|
2935
|
-
|
|
2936
|
-
return
|
|
2937
|
-
this.applicationAllowsVisitingLocation(location, options));
|
|
2925
|
+
allowsVisitingLocationWithAction(location, action) {
|
|
2926
|
+
return this.locationWithActionIsSamePage(location, action) || this.applicationAllowsVisitingLocation(location);
|
|
2938
2927
|
}
|
|
2939
2928
|
visitProposedToLocation(location, options) {
|
|
2940
2929
|
extendURLWithDeprecatedProperties(location);
|
|
2941
|
-
|
|
2930
|
+
this.adapter.visitProposedToLocation(location, options);
|
|
2942
2931
|
}
|
|
2943
2932
|
visitStarted(visit) {
|
|
2944
2933
|
if (!visit.acceptsStreamResponse) {
|
|
@@ -2946,7 +2935,7 @@ class Session {
|
|
|
2946
2935
|
}
|
|
2947
2936
|
extendURLWithDeprecatedProperties(visit.location);
|
|
2948
2937
|
if (!visit.silent) {
|
|
2949
|
-
this.notifyApplicationAfterVisitingLocation(visit.location, visit.action
|
|
2938
|
+
this.notifyApplicationAfterVisitingLocation(visit.location, visit.action);
|
|
2950
2939
|
}
|
|
2951
2940
|
}
|
|
2952
2941
|
visitCompleted(visit) {
|
|
@@ -3014,8 +3003,8 @@ class Session {
|
|
|
3014
3003
|
const event = this.notifyApplicationAfterClickingLinkToLocation(link, location, ev);
|
|
3015
3004
|
return !event.defaultPrevented;
|
|
3016
3005
|
}
|
|
3017
|
-
applicationAllowsVisitingLocation(location
|
|
3018
|
-
const event = this.notifyApplicationBeforeVisitingLocation(location
|
|
3006
|
+
applicationAllowsVisitingLocation(location) {
|
|
3007
|
+
const event = this.notifyApplicationBeforeVisitingLocation(location);
|
|
3019
3008
|
return !event.defaultPrevented;
|
|
3020
3009
|
}
|
|
3021
3010
|
notifyApplicationAfterClickingLinkToLocation(link, location, event) {
|
|
@@ -3025,18 +3014,14 @@ class Session {
|
|
|
3025
3014
|
cancelable: true,
|
|
3026
3015
|
});
|
|
3027
3016
|
}
|
|
3028
|
-
notifyApplicationBeforeVisitingLocation(location
|
|
3017
|
+
notifyApplicationBeforeVisitingLocation(location) {
|
|
3029
3018
|
return dispatch("turbo:before-visit", {
|
|
3030
|
-
target: element,
|
|
3031
3019
|
detail: { url: location.href },
|
|
3032
3020
|
cancelable: true,
|
|
3033
3021
|
});
|
|
3034
3022
|
}
|
|
3035
|
-
notifyApplicationAfterVisitingLocation(location, action
|
|
3036
|
-
return dispatch("turbo:visit", {
|
|
3037
|
-
target: element,
|
|
3038
|
-
detail: { url: location.href, action },
|
|
3039
|
-
});
|
|
3023
|
+
notifyApplicationAfterVisitingLocation(location, action) {
|
|
3024
|
+
return dispatch("turbo:visit", { detail: { url: location.href, action } });
|
|
3040
3025
|
}
|
|
3041
3026
|
notifyApplicationBeforeCachingSnapshot() {
|
|
3042
3027
|
return dispatch("turbo:before-cache");
|
|
@@ -3181,7 +3166,7 @@ function registerAdapter(adapter) {
|
|
|
3181
3166
|
session.registerAdapter(adapter);
|
|
3182
3167
|
}
|
|
3183
3168
|
function visit(location, options) {
|
|
3184
|
-
|
|
3169
|
+
session.visit(location, options);
|
|
3185
3170
|
}
|
|
3186
3171
|
function connectStreamSource(source) {
|
|
3187
3172
|
session.connectStreamSource(source);
|
package/dist/turbo.es2017-umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Turbo 7.2.0-rc.
|
|
2
|
+
Turbo 7.2.0-rc.3
|
|
3
3
|
Copyright © 2022 Basecamp, LLC
|
|
4
4
|
*/
|
|
5
5
|
(function (global, factory) {
|
|
@@ -1631,7 +1631,6 @@ Copyright © 2022 Basecamp, LLC
|
|
|
1631
1631
|
updateHistory: true,
|
|
1632
1632
|
shouldCacheSnapshot: true,
|
|
1633
1633
|
acceptsStreamResponse: false,
|
|
1634
|
-
initiator: document.documentElement,
|
|
1635
1634
|
};
|
|
1636
1635
|
var SystemStatusCode;
|
|
1637
1636
|
(function (SystemStatusCode) {
|
|
@@ -1641,6 +1640,7 @@ Copyright © 2022 Basecamp, LLC
|
|
|
1641
1640
|
})(SystemStatusCode || (SystemStatusCode = {}));
|
|
1642
1641
|
class Visit {
|
|
1643
1642
|
constructor(delegate, location, restorationIdentifier, options = {}) {
|
|
1643
|
+
this.identifier = uuid();
|
|
1644
1644
|
this.timingMetrics = {};
|
|
1645
1645
|
this.followedRedirect = false;
|
|
1646
1646
|
this.historyChanged = false;
|
|
@@ -1652,8 +1652,7 @@ Copyright © 2022 Basecamp, LLC
|
|
|
1652
1652
|
this.delegate = delegate;
|
|
1653
1653
|
this.location = location;
|
|
1654
1654
|
this.restorationIdentifier = restorationIdentifier || uuid();
|
|
1655
|
-
|
|
1656
|
-
const { action, historyChanged, referrer, snapshotHTML, response, visitCachedSnapshot, willRender, updateHistory, shouldCacheSnapshot, acceptsStreamResponse, initiator, } = Object.assign(Object.assign({}, defaultOptions), options);
|
|
1655
|
+
const { action, historyChanged, referrer, snapshotHTML, response, visitCachedSnapshot, willRender, updateHistory, shouldCacheSnapshot, acceptsStreamResponse, } = Object.assign(Object.assign({}, defaultOptions), options);
|
|
1657
1656
|
this.action = action;
|
|
1658
1657
|
this.historyChanged = historyChanged;
|
|
1659
1658
|
this.referrer = referrer;
|
|
@@ -1666,7 +1665,6 @@ Copyright © 2022 Basecamp, LLC
|
|
|
1666
1665
|
this.scrolled = !willRender;
|
|
1667
1666
|
this.shouldCacheSnapshot = shouldCacheSnapshot;
|
|
1668
1667
|
this.acceptsStreamResponse = acceptsStreamResponse;
|
|
1669
|
-
this.initiator = initiator;
|
|
1670
1668
|
}
|
|
1671
1669
|
get adapter() {
|
|
1672
1670
|
return this.delegate.adapter;
|
|
@@ -1698,7 +1696,6 @@ Copyright © 2022 Basecamp, LLC
|
|
|
1698
1696
|
}
|
|
1699
1697
|
this.cancelRender();
|
|
1700
1698
|
this.state = VisitState.canceled;
|
|
1701
|
-
this.resolvingFunctions.reject();
|
|
1702
1699
|
}
|
|
1703
1700
|
}
|
|
1704
1701
|
complete() {
|
|
@@ -1710,14 +1707,12 @@ Copyright © 2022 Basecamp, LLC
|
|
|
1710
1707
|
this.adapter.visitCompleted(this);
|
|
1711
1708
|
this.delegate.visitCompleted(this);
|
|
1712
1709
|
}
|
|
1713
|
-
this.resolvingFunctions.resolve();
|
|
1714
1710
|
}
|
|
1715
1711
|
}
|
|
1716
1712
|
fail() {
|
|
1717
1713
|
if (this.state == VisitState.started) {
|
|
1718
1714
|
this.state = VisitState.failed;
|
|
1719
1715
|
this.adapter.visitFailed(this);
|
|
1720
|
-
this.resolvingFunctions.reject();
|
|
1721
1716
|
}
|
|
1722
1717
|
}
|
|
1723
1718
|
changeHistory() {
|
|
@@ -1734,7 +1729,7 @@ Copyright © 2022 Basecamp, LLC
|
|
|
1734
1729
|
this.simulateRequest();
|
|
1735
1730
|
}
|
|
1736
1731
|
else if (this.shouldIssueRequest() && !this.request) {
|
|
1737
|
-
this.request = new FetchRequest(this, FetchMethod.get, this.location
|
|
1732
|
+
this.request = new FetchRequest(this, FetchMethod.get, this.location);
|
|
1738
1733
|
this.request.perform();
|
|
1739
1734
|
}
|
|
1740
1735
|
}
|
|
@@ -1980,7 +1975,7 @@ Copyright © 2022 Basecamp, LLC
|
|
|
1980
1975
|
this.session = session;
|
|
1981
1976
|
}
|
|
1982
1977
|
visitProposedToLocation(location, options) {
|
|
1983
|
-
|
|
1978
|
+
this.navigator.startVisit(location, (options === null || options === void 0 ? void 0 : options.restorationIdentifier) || uuid(), options);
|
|
1984
1979
|
}
|
|
1985
1980
|
visitStarted(visit) {
|
|
1986
1981
|
this.location = visit.location;
|
|
@@ -2239,25 +2234,20 @@ Copyright © 2022 Basecamp, LLC
|
|
|
2239
2234
|
this.delegate = delegate;
|
|
2240
2235
|
}
|
|
2241
2236
|
proposeVisit(location, options = {}) {
|
|
2242
|
-
if (this.delegate.
|
|
2237
|
+
if (this.delegate.allowsVisitingLocationWithAction(location, options.action)) {
|
|
2243
2238
|
if (locationIsVisitable(location, this.view.snapshot.rootLocation)) {
|
|
2244
|
-
|
|
2239
|
+
this.delegate.visitProposedToLocation(location, options);
|
|
2245
2240
|
}
|
|
2246
2241
|
else {
|
|
2247
2242
|
window.location.href = location.toString();
|
|
2248
|
-
return Promise.resolve();
|
|
2249
2243
|
}
|
|
2250
2244
|
}
|
|
2251
|
-
else {
|
|
2252
|
-
return Promise.reject();
|
|
2253
|
-
}
|
|
2254
2245
|
}
|
|
2255
2246
|
startVisit(locatable, restorationIdentifier, options = {}) {
|
|
2256
2247
|
this.lastVisit = this.currentVisit;
|
|
2257
2248
|
this.stop();
|
|
2258
2249
|
this.currentVisit = new Visit(this, expandURL(locatable), restorationIdentifier, Object.assign({ referrer: this.location }, options));
|
|
2259
2250
|
this.currentVisit.start();
|
|
2260
|
-
return this.currentVisit.promise;
|
|
2261
2251
|
}
|
|
2262
2252
|
submitForm(form, submitter) {
|
|
2263
2253
|
this.stop();
|
|
@@ -2878,10 +2868,10 @@ Copyright © 2022 Basecamp, LLC
|
|
|
2878
2868
|
const frameElement = options.frame ? document.getElementById(options.frame) : null;
|
|
2879
2869
|
if (frameElement instanceof FrameElement) {
|
|
2880
2870
|
frameElement.src = location.toString();
|
|
2881
|
-
|
|
2871
|
+
frameElement.loaded;
|
|
2882
2872
|
}
|
|
2883
2873
|
else {
|
|
2884
|
-
|
|
2874
|
+
this.navigator.proposeVisit(expandURL(location), options);
|
|
2885
2875
|
}
|
|
2886
2876
|
}
|
|
2887
2877
|
connectStreamSource(source) {
|
|
@@ -2936,15 +2926,14 @@ Copyright © 2022 Basecamp, LLC
|
|
|
2936
2926
|
followedLinkToLocation(link, location) {
|
|
2937
2927
|
const action = this.getActionForLink(link);
|
|
2938
2928
|
const acceptsStreamResponse = link.hasAttribute("data-turbo-stream");
|
|
2939
|
-
this.visit(location.href, { action, acceptsStreamResponse
|
|
2929
|
+
this.visit(location.href, { action, acceptsStreamResponse });
|
|
2940
2930
|
}
|
|
2941
|
-
|
|
2942
|
-
return
|
|
2943
|
-
this.applicationAllowsVisitingLocation(location, options));
|
|
2931
|
+
allowsVisitingLocationWithAction(location, action) {
|
|
2932
|
+
return this.locationWithActionIsSamePage(location, action) || this.applicationAllowsVisitingLocation(location);
|
|
2944
2933
|
}
|
|
2945
2934
|
visitProposedToLocation(location, options) {
|
|
2946
2935
|
extendURLWithDeprecatedProperties(location);
|
|
2947
|
-
|
|
2936
|
+
this.adapter.visitProposedToLocation(location, options);
|
|
2948
2937
|
}
|
|
2949
2938
|
visitStarted(visit) {
|
|
2950
2939
|
if (!visit.acceptsStreamResponse) {
|
|
@@ -2952,7 +2941,7 @@ Copyright © 2022 Basecamp, LLC
|
|
|
2952
2941
|
}
|
|
2953
2942
|
extendURLWithDeprecatedProperties(visit.location);
|
|
2954
2943
|
if (!visit.silent) {
|
|
2955
|
-
this.notifyApplicationAfterVisitingLocation(visit.location, visit.action
|
|
2944
|
+
this.notifyApplicationAfterVisitingLocation(visit.location, visit.action);
|
|
2956
2945
|
}
|
|
2957
2946
|
}
|
|
2958
2947
|
visitCompleted(visit) {
|
|
@@ -3020,8 +3009,8 @@ Copyright © 2022 Basecamp, LLC
|
|
|
3020
3009
|
const event = this.notifyApplicationAfterClickingLinkToLocation(link, location, ev);
|
|
3021
3010
|
return !event.defaultPrevented;
|
|
3022
3011
|
}
|
|
3023
|
-
applicationAllowsVisitingLocation(location
|
|
3024
|
-
const event = this.notifyApplicationBeforeVisitingLocation(location
|
|
3012
|
+
applicationAllowsVisitingLocation(location) {
|
|
3013
|
+
const event = this.notifyApplicationBeforeVisitingLocation(location);
|
|
3025
3014
|
return !event.defaultPrevented;
|
|
3026
3015
|
}
|
|
3027
3016
|
notifyApplicationAfterClickingLinkToLocation(link, location, event) {
|
|
@@ -3031,18 +3020,14 @@ Copyright © 2022 Basecamp, LLC
|
|
|
3031
3020
|
cancelable: true,
|
|
3032
3021
|
});
|
|
3033
3022
|
}
|
|
3034
|
-
notifyApplicationBeforeVisitingLocation(location
|
|
3023
|
+
notifyApplicationBeforeVisitingLocation(location) {
|
|
3035
3024
|
return dispatch("turbo:before-visit", {
|
|
3036
|
-
target: element,
|
|
3037
3025
|
detail: { url: location.href },
|
|
3038
3026
|
cancelable: true,
|
|
3039
3027
|
});
|
|
3040
3028
|
}
|
|
3041
|
-
notifyApplicationAfterVisitingLocation(location, action
|
|
3042
|
-
return dispatch("turbo:visit", {
|
|
3043
|
-
target: element,
|
|
3044
|
-
detail: { url: location.href, action },
|
|
3045
|
-
});
|
|
3029
|
+
notifyApplicationAfterVisitingLocation(location, action) {
|
|
3030
|
+
return dispatch("turbo:visit", { detail: { url: location.href, action } });
|
|
3046
3031
|
}
|
|
3047
3032
|
notifyApplicationBeforeCachingSnapshot() {
|
|
3048
3033
|
return dispatch("turbo:before-cache");
|
|
@@ -3187,7 +3172,7 @@ Copyright © 2022 Basecamp, LLC
|
|
|
3187
3172
|
session.registerAdapter(adapter);
|
|
3188
3173
|
}
|
|
3189
3174
|
function visit(location, options) {
|
|
3190
|
-
|
|
3175
|
+
session.visit(location, options);
|
|
3191
3176
|
}
|
|
3192
3177
|
function connectStreamSource(source) {
|
|
3193
3178
|
session.connectStreamSource(source);
|
|
@@ -4,8 +4,8 @@ import { FormSubmission } from "./form_submission";
|
|
|
4
4
|
import { Locatable } from "../url";
|
|
5
5
|
import { Visit, VisitDelegate, VisitOptions } from "./visit";
|
|
6
6
|
export declare type NavigatorDelegate = VisitDelegate & {
|
|
7
|
-
|
|
8
|
-
visitProposedToLocation(location: URL, options: Partial<VisitOptions>):
|
|
7
|
+
allowsVisitingLocationWithAction(location: URL, action?: Action): boolean;
|
|
8
|
+
visitProposedToLocation(location: URL, options: Partial<VisitOptions>): void;
|
|
9
9
|
notifyApplicationAfterVisitingSamePageLocation(oldURL: URL, newURL: URL): void;
|
|
10
10
|
};
|
|
11
11
|
export declare class Navigator {
|
|
@@ -14,8 +14,8 @@ export declare class Navigator {
|
|
|
14
14
|
currentVisit?: Visit;
|
|
15
15
|
lastVisit?: Visit;
|
|
16
16
|
constructor(delegate: NavigatorDelegate);
|
|
17
|
-
proposeVisit(location: URL, options?: Partial<VisitOptions>):
|
|
18
|
-
startVisit(locatable: Locatable, restorationIdentifier: string, options?: Partial<VisitOptions>):
|
|
17
|
+
proposeVisit(location: URL, options?: Partial<VisitOptions>): void;
|
|
18
|
+
startVisit(locatable: Locatable, restorationIdentifier: string, options?: Partial<VisitOptions>): void;
|
|
19
19
|
submitForm(form: HTMLFormElement, submitter?: HTMLElement): void;
|
|
20
20
|
stop(): void;
|
|
21
21
|
get adapter(): import("../native/adapter").Adapter;
|
|
@@ -44,7 +44,6 @@ export declare type VisitOptions = {
|
|
|
44
44
|
shouldCacheSnapshot: boolean;
|
|
45
45
|
frame?: string;
|
|
46
46
|
acceptsStreamResponse: boolean;
|
|
47
|
-
initiator: Element;
|
|
48
47
|
};
|
|
49
48
|
export declare type VisitResponse = {
|
|
50
49
|
statusCode: number;
|
|
@@ -58,6 +57,7 @@ export declare enum SystemStatusCode {
|
|
|
58
57
|
}
|
|
59
58
|
export declare class Visit implements FetchRequestDelegate {
|
|
60
59
|
readonly delegate: VisitDelegate;
|
|
60
|
+
readonly identifier: string;
|
|
61
61
|
readonly restorationIdentifier: string;
|
|
62
62
|
readonly action: Action;
|
|
63
63
|
readonly referrer?: URL;
|
|
@@ -65,9 +65,6 @@ export declare class Visit implements FetchRequestDelegate {
|
|
|
65
65
|
readonly visitCachedSnapshot: (snapshot: Snapshot) => void;
|
|
66
66
|
readonly willRender: boolean;
|
|
67
67
|
readonly updateHistory: boolean;
|
|
68
|
-
readonly promise: Promise<void>;
|
|
69
|
-
readonly initiator: Element;
|
|
70
|
-
private resolvingFunctions;
|
|
71
68
|
followedRedirect: boolean;
|
|
72
69
|
frame?: number;
|
|
73
70
|
historyChanged: boolean;
|
|
@@ -12,13 +12,13 @@ declare const session: Session;
|
|
|
12
12
|
declare const cache: Cache;
|
|
13
13
|
declare const navigator: import("./drive/navigator").Navigator;
|
|
14
14
|
export { navigator, session, cache, PageRenderer, PageSnapshot, FrameRenderer };
|
|
15
|
-
export { TurboBeforeCacheEvent, TurboBeforeRenderEvent, TurboBeforeVisitEvent, TurboClickEvent, TurboFrameLoadEvent, TurboFrameRenderEvent, TurboLoadEvent, TurboRenderEvent, TurboVisitEvent, } from "./session";
|
|
15
|
+
export { TurboBeforeCacheEvent, TurboBeforeRenderEvent, TurboBeforeVisitEvent, TurboClickEvent, TurboBeforeFrameRenderEvent, TurboFrameLoadEvent, TurboFrameRenderEvent, TurboLoadEvent, TurboRenderEvent, TurboVisitEvent, } from "./session";
|
|
16
16
|
export { TurboSubmitStartEvent, TurboSubmitEndEvent } from "./drive/form_submission";
|
|
17
17
|
export { TurboFrameMissingEvent } from "./frames/frame_controller";
|
|
18
18
|
export { StreamActions, TurboStreamAction, TurboStreamActions } from "./streams/stream_actions";
|
|
19
19
|
export declare function start(): void;
|
|
20
20
|
export declare function registerAdapter(adapter: Adapter): void;
|
|
21
|
-
export declare function visit(location: Locatable, options?: Partial<VisitOptions>):
|
|
21
|
+
export declare function visit(location: Locatable, options?: Partial<VisitOptions>): void;
|
|
22
22
|
export declare function connectStreamSource(source: StreamSource): void;
|
|
23
23
|
export declare function disconnectStreamSource(source: StreamSource): void;
|
|
24
24
|
export declare function renderStreamMessage(message: StreamMessage | string): void;
|
|
@@ -2,7 +2,7 @@ import { Visit, VisitOptions } from "../drive/visit";
|
|
|
2
2
|
import { FormSubmission } from "../drive/form_submission";
|
|
3
3
|
import { ReloadReason } from "./browser_adapter";
|
|
4
4
|
export interface Adapter {
|
|
5
|
-
visitProposedToLocation(location: URL, options?: Partial<VisitOptions>):
|
|
5
|
+
visitProposedToLocation(location: URL, options?: Partial<VisitOptions>): void;
|
|
6
6
|
visitStarted(visit: Visit): void;
|
|
7
7
|
visitCompleted(visit: Visit): void;
|
|
8
8
|
visitFailed(visit: Visit): void;
|
|
@@ -17,7 +17,7 @@ export declare class BrowserAdapter implements Adapter {
|
|
|
17
17
|
formProgressBarTimeout?: number;
|
|
18
18
|
location?: URL;
|
|
19
19
|
constructor(session: Session);
|
|
20
|
-
visitProposedToLocation(location: URL, options?: Partial<VisitOptions>):
|
|
20
|
+
visitProposedToLocation(location: URL, options?: Partial<VisitOptions>): void;
|
|
21
21
|
visitStarted(visit: Visit): void;
|
|
22
22
|
visitRequestStarted(visit: Visit): void;
|
|
23
23
|
visitRequestCompleted(visit: Visit): void;
|
|
@@ -74,7 +74,7 @@ export declare class Session implements FormSubmitObserverDelegate, HistoryDeleg
|
|
|
74
74
|
disable(): void;
|
|
75
75
|
stop(): void;
|
|
76
76
|
registerAdapter(adapter: Adapter): void;
|
|
77
|
-
visit(location: Locatable, options?: Partial<VisitOptions>):
|
|
77
|
+
visit(location: Locatable, options?: Partial<VisitOptions>): void;
|
|
78
78
|
connectStreamSource(source: StreamSource): void;
|
|
79
79
|
disconnectStreamSource(source: StreamSource): void;
|
|
80
80
|
renderStreamMessage(message: StreamMessage | string): void;
|
|
@@ -89,8 +89,8 @@ export declare class Session implements FormSubmitObserverDelegate, HistoryDeleg
|
|
|
89
89
|
submittedFormLinkToLocation(): void;
|
|
90
90
|
willFollowLinkToLocation(link: Element, location: URL, event: MouseEvent): boolean;
|
|
91
91
|
followedLinkToLocation(link: Element, location: URL): void;
|
|
92
|
-
|
|
93
|
-
visitProposedToLocation(location: URL, options: Partial<VisitOptions>):
|
|
92
|
+
allowsVisitingLocationWithAction(location: URL, action?: Action): boolean;
|
|
93
|
+
visitProposedToLocation(location: URL, options: Partial<VisitOptions>): void;
|
|
94
94
|
visitStarted(visit: Visit): void;
|
|
95
95
|
visitCompleted(visit: Visit): void;
|
|
96
96
|
locationWithActionIsSamePage(location: URL, action?: Action): boolean;
|
|
@@ -109,15 +109,15 @@ export declare class Session implements FormSubmitObserverDelegate, HistoryDeleg
|
|
|
109
109
|
frameLoaded(frame: FrameElement): void;
|
|
110
110
|
frameRendered(fetchResponse: FetchResponse, frame: FrameElement): void;
|
|
111
111
|
applicationAllowsFollowingLinkToLocation(link: Element, location: URL, ev: MouseEvent): boolean;
|
|
112
|
-
applicationAllowsVisitingLocation(location: URL
|
|
112
|
+
applicationAllowsVisitingLocation(location: URL): boolean;
|
|
113
113
|
notifyApplicationAfterClickingLinkToLocation(link: Element, location: URL, event: MouseEvent): CustomEvent<{
|
|
114
114
|
url: string;
|
|
115
115
|
originalEvent: MouseEvent;
|
|
116
116
|
}>;
|
|
117
|
-
notifyApplicationBeforeVisitingLocation(location: URL
|
|
117
|
+
notifyApplicationBeforeVisitingLocation(location: URL): CustomEvent<{
|
|
118
118
|
url: string;
|
|
119
119
|
}>;
|
|
120
|
-
notifyApplicationAfterVisitingLocation(location: URL, action: Action
|
|
120
|
+
notifyApplicationAfterVisitingLocation(location: URL, action: Action): CustomEvent<{
|
|
121
121
|
url: string;
|
|
122
122
|
action: Action;
|
|
123
123
|
}>;
|
|
@@ -8,7 +8,3 @@ export declare type StreamSource = {
|
|
|
8
8
|
addEventListener(type: "message", listener: (event: MessageEvent) => void, options?: boolean | AddEventListenerOptions): void;
|
|
9
9
|
removeEventListener(type: "message", listener: (event: MessageEvent) => void, options?: boolean | EventListenerOptions): void;
|
|
10
10
|
};
|
|
11
|
-
export declare type ResolvingFunctions<T = unknown> = {
|
|
12
|
-
resolve(value: T | PromiseLike<T>): void;
|
|
13
|
-
reject(reason?: any): void;
|
|
14
|
-
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FetchResponse } from "./fetch_response";
|
|
2
|
+
import { FrameElement } from "../elements/frame_element";
|
|
2
3
|
export declare type TurboBeforeFetchRequestEvent = CustomEvent<{
|
|
3
4
|
fetchOptions: RequestInit;
|
|
4
5
|
url: URL;
|
|
@@ -44,10 +45,10 @@ export declare class FetchRequest {
|
|
|
44
45
|
readonly headers: FetchRequestHeaders;
|
|
45
46
|
readonly url: URL;
|
|
46
47
|
readonly body?: FetchRequestBody;
|
|
47
|
-
readonly target?:
|
|
48
|
+
readonly target?: FrameElement | HTMLFormElement | null;
|
|
48
49
|
readonly abortController: AbortController;
|
|
49
50
|
private resolveRequestPromise;
|
|
50
|
-
constructor(delegate: FetchRequestDelegate, method: FetchMethod, location: URL, body?: FetchRequestBody, target?:
|
|
51
|
+
constructor(delegate: FetchRequestDelegate, method: FetchMethod, location: URL, body?: FetchRequestBody, target?: FrameElement | HTMLFormElement | null);
|
|
51
52
|
get location(): URL;
|
|
52
53
|
get params(): URLSearchParams;
|
|
53
54
|
get entries(): [string, FormDataEntryValue][];
|
|
@@ -9,7 +9,7 @@ export declare class DeprecatedAdapterSupportTest extends DOMTestCase implements
|
|
|
9
9
|
teardown(): Promise<void>;
|
|
10
10
|
"test visit proposal location includes deprecated absoluteURL property"(): Promise<void>;
|
|
11
11
|
"test visit start location includes deprecated absoluteURL property"(): Promise<void>;
|
|
12
|
-
visitProposedToLocation(location: URL, _options?: Partial<VisitOptions>):
|
|
12
|
+
visitProposedToLocation(location: URL, _options?: Partial<VisitOptions>): void;
|
|
13
13
|
visitStarted(visit: Visit): void;
|
|
14
14
|
visitCompleted(_visit: Visit): void;
|
|
15
15
|
visitFailed(_visit: Visit): void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DOMTestCase } from "../helpers/dom_test_case";
|
|
2
|
+
export { PageRenderer, PageSnapshot, FrameRenderer, FrameElement, StreamActions, StreamElement, StreamSourceElement, TurboBeforeCacheEvent, TurboBeforeFetchRequestEvent, TurboBeforeFetchResponseEvent, TurboBeforeFrameRenderEvent, TurboBeforeRenderEvent, TurboBeforeStreamRenderEvent, TurboBeforeVisitEvent, TurboClickEvent, TurboFetchRequestErrorEvent, TurboFrameLoadEvent, TurboFrameMissingEvent, TurboFrameRenderEvent, TurboLoadEvent, TurboRenderEvent, TurboStreamAction, TurboStreamActions, TurboSubmitEndEvent, TurboSubmitStartEvent, TurboVisitEvent, } from "../../index";
|
|
3
|
+
export declare class ExportTests extends DOMTestCase {
|
|
4
|
+
"test Turbo interface"(): Promise<void>;
|
|
5
|
+
}
|
package/package.json
CHANGED