phoenix_live_view 0.19.3 → 0.19.5
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/assets/js/phoenix_live_view/dom.js +2 -2
- package/assets/js/phoenix_live_view/entry_uploader.js +4 -1
- package/assets/js/phoenix_live_view/live_socket.js +9 -4
- package/assets/js/phoenix_live_view/view.js +2 -1
- package/assets/package.json +1 -1
- package/package.json +1 -1
- package/priv/static/phoenix_live_view.cjs.js +18 -8
- package/priv/static/phoenix_live_view.cjs.js.map +2 -2
- package/priv/static/phoenix_live_view.esm.js +18 -8
- package/priv/static/phoenix_live_view.esm.js.map +2 -2
- package/priv/static/phoenix_live_view.js +18 -8
- package/priv/static/phoenix_live_view.min.js +3 -3
|
@@ -61,7 +61,7 @@ let DOM = {
|
|
|
61
61
|
wantsNewTab(e){
|
|
62
62
|
let wantsNewTab = e.ctrlKey || e.shiftKey || e.metaKey || (e.button && e.button === 1)
|
|
63
63
|
let isDownload = (e.target instanceof HTMLAnchorElement && e.target.hasAttribute("download"))
|
|
64
|
-
let isTargetBlank = e.target.getAttribute("target") === "_blank"
|
|
64
|
+
let isTargetBlank = e.target.hasAttribute("target") && e.target.getAttribute("target").toLowerCase() === "_blank"
|
|
65
65
|
return wantsNewTab || isTargetBlank || isDownload
|
|
66
66
|
},
|
|
67
67
|
|
|
@@ -488,4 +488,4 @@ let DOM = {
|
|
|
488
488
|
}
|
|
489
489
|
}
|
|
490
490
|
|
|
491
|
-
export default DOM
|
|
491
|
+
export default DOM
|
|
@@ -9,12 +9,14 @@ export default class EntryUploader {
|
|
|
9
9
|
this.offset = 0
|
|
10
10
|
this.chunkSize = chunkSize
|
|
11
11
|
this.chunkTimer = null
|
|
12
|
+
this.errored = false
|
|
12
13
|
this.uploadChannel = liveSocket.channel(`lvu:${entry.ref}`, {token: entry.metadata()})
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
error(reason){
|
|
17
|
+
if(this.errored){ return }
|
|
18
|
+
this.errored = true
|
|
16
19
|
clearTimeout(this.chunkTimer)
|
|
17
|
-
this.uploadChannel.leave()
|
|
18
20
|
this.entry.error(reason)
|
|
19
21
|
}
|
|
20
22
|
|
|
@@ -50,5 +52,6 @@ export default class EntryUploader {
|
|
|
50
52
|
this.chunkTimer = setTimeout(() => this.readNextChunk(), this.liveSocket.getLatencySim() || 0)
|
|
51
53
|
}
|
|
52
54
|
})
|
|
55
|
+
.receive("error", ({reason}) => this.error(reason))
|
|
53
56
|
}
|
|
54
57
|
}
|
|
@@ -407,7 +407,7 @@ export default class LiveSocket {
|
|
|
407
407
|
DOM.findPhxSticky(document).forEach(el => newMainEl.appendChild(el))
|
|
408
408
|
this.outgoingMainEl.replaceWith(newMainEl)
|
|
409
409
|
this.outgoingMainEl = null
|
|
410
|
-
callback && requestAnimationFrame(callback)
|
|
410
|
+
callback && requestAnimationFrame(() => callback(linkRef))
|
|
411
411
|
onDone()
|
|
412
412
|
})
|
|
413
413
|
}
|
|
@@ -684,6 +684,7 @@ export default class LiveSocket {
|
|
|
684
684
|
let {type, id, root, scroll} = event.state || {}
|
|
685
685
|
let href = window.location.href
|
|
686
686
|
|
|
687
|
+
DOM.dispatchEvent(window, "phx:navigate", {detail: {href, patch: type === "patch", pop: true}})
|
|
687
688
|
this.requestDOMUpdate(() => {
|
|
688
689
|
if(this.main.isConnected() && (type === "patch" && id === this.main.id)){
|
|
689
690
|
this.main.pushLinkPatch(href, null, () => {
|
|
@@ -761,6 +762,7 @@ export default class LiveSocket {
|
|
|
761
762
|
if(!this.commitPendingLink(linkRef)){ return }
|
|
762
763
|
|
|
763
764
|
Browser.pushState(linkState, {type: "patch", id: this.main.id}, href)
|
|
765
|
+
DOM.dispatchEvent(window, "phx:navigate", {detail: {patch: true, href, pop: false}})
|
|
764
766
|
this.registerNewLocation(window.location)
|
|
765
767
|
}
|
|
766
768
|
|
|
@@ -773,9 +775,12 @@ export default class LiveSocket {
|
|
|
773
775
|
}
|
|
774
776
|
let scroll = window.scrollY
|
|
775
777
|
this.withPageLoading({to: href, kind: "redirect"}, done => {
|
|
776
|
-
this.replaceMain(href, flash, () => {
|
|
777
|
-
|
|
778
|
-
|
|
778
|
+
this.replaceMain(href, flash, (linkRef) => {
|
|
779
|
+
if(linkRef === this.linkRef){
|
|
780
|
+
Browser.pushState(linkState, {type: "redirect", id: this.main.id, scroll: scroll}, href)
|
|
781
|
+
DOM.dispatchEvent(window, "phx:navigate", {detail: {href, patch: false, pop: false}})
|
|
782
|
+
this.registerNewLocation(window.location)
|
|
783
|
+
}
|
|
779
784
|
done()
|
|
780
785
|
})
|
|
781
786
|
})
|
|
@@ -1083,8 +1083,9 @@ export default class View {
|
|
|
1083
1083
|
let linkRef = this.liveSocket.setPendingLink(href)
|
|
1084
1084
|
let refGen = targetEl ? () => this.putRef([targetEl], "click") : null
|
|
1085
1085
|
let fallback = () => this.liveSocket.redirect(window.location.href)
|
|
1086
|
+
let url = href.startsWith("/") ? `${location.protocol}//${location.host}${href}` : href
|
|
1086
1087
|
|
|
1087
|
-
let push = this.pushWithReply(refGen, "live_patch", {url
|
|
1088
|
+
let push = this.pushWithReply(refGen, "live_patch", {url}, resp => {
|
|
1088
1089
|
this.liveSocket.requestDOMUpdate(() => {
|
|
1089
1090
|
if(resp.link_redirect){
|
|
1090
1091
|
this.liveSocket.replaceMain(href, null, callback, linkRef)
|
package/assets/package.json
CHANGED
package/package.json
CHANGED
|
@@ -109,11 +109,15 @@ var EntryUploader = class {
|
|
|
109
109
|
this.offset = 0;
|
|
110
110
|
this.chunkSize = chunkSize;
|
|
111
111
|
this.chunkTimer = null;
|
|
112
|
+
this.errored = false;
|
|
112
113
|
this.uploadChannel = liveSocket.channel(`lvu:${entry.ref}`, { token: entry.metadata() });
|
|
113
114
|
}
|
|
114
115
|
error(reason) {
|
|
116
|
+
if (this.errored) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
this.errored = true;
|
|
115
120
|
clearTimeout(this.chunkTimer);
|
|
116
|
-
this.uploadChannel.leave();
|
|
117
121
|
this.entry.error(reason);
|
|
118
122
|
}
|
|
119
123
|
upload() {
|
|
@@ -145,7 +149,7 @@ var EntryUploader = class {
|
|
|
145
149
|
if (!this.isDone()) {
|
|
146
150
|
this.chunkTimer = setTimeout(() => this.readNextChunk(), this.liveSocket.getLatencySim() || 0);
|
|
147
151
|
}
|
|
148
|
-
});
|
|
152
|
+
}).receive("error", ({ reason }) => this.error(reason));
|
|
149
153
|
}
|
|
150
154
|
};
|
|
151
155
|
|
|
@@ -312,7 +316,7 @@ var DOM = {
|
|
|
312
316
|
wantsNewTab(e) {
|
|
313
317
|
let wantsNewTab = e.ctrlKey || e.shiftKey || e.metaKey || e.button && e.button === 1;
|
|
314
318
|
let isDownload = e.target instanceof HTMLAnchorElement && e.target.hasAttribute("download");
|
|
315
|
-
let isTargetBlank = e.target.getAttribute("target") === "_blank";
|
|
319
|
+
let isTargetBlank = e.target.hasAttribute("target") && e.target.getAttribute("target").toLowerCase() === "_blank";
|
|
316
320
|
return wantsNewTab || isTargetBlank || isDownload;
|
|
317
321
|
},
|
|
318
322
|
isUnloadableFormSubmit(e) {
|
|
@@ -3562,7 +3566,8 @@ var View = class {
|
|
|
3562
3566
|
let linkRef = this.liveSocket.setPendingLink(href);
|
|
3563
3567
|
let refGen = targetEl ? () => this.putRef([targetEl], "click") : null;
|
|
3564
3568
|
let fallback = () => this.liveSocket.redirect(window.location.href);
|
|
3565
|
-
let
|
|
3569
|
+
let url = href.startsWith("/") ? `${location.protocol}//${location.host}${href}` : href;
|
|
3570
|
+
let push = this.pushWithReply(refGen, "live_patch", { url }, (resp) => {
|
|
3566
3571
|
this.liveSocket.requestDOMUpdate(() => {
|
|
3567
3572
|
if (resp.link_redirect) {
|
|
3568
3573
|
this.liveSocket.replaceMain(href, null, callback, linkRef);
|
|
@@ -3932,7 +3937,7 @@ var LiveSocket = class {
|
|
|
3932
3937
|
dom_default.findPhxSticky(document).forEach((el) => newMainEl.appendChild(el));
|
|
3933
3938
|
this.outgoingMainEl.replaceWith(newMainEl);
|
|
3934
3939
|
this.outgoingMainEl = null;
|
|
3935
|
-
callback && requestAnimationFrame(callback);
|
|
3940
|
+
callback && requestAnimationFrame(() => callback(linkRef));
|
|
3936
3941
|
onDone();
|
|
3937
3942
|
});
|
|
3938
3943
|
}
|
|
@@ -4214,6 +4219,7 @@ var LiveSocket = class {
|
|
|
4214
4219
|
}
|
|
4215
4220
|
let { type, id, root, scroll } = event.state || {};
|
|
4216
4221
|
let href = window.location.href;
|
|
4222
|
+
dom_default.dispatchEvent(window, "phx:navigate", { detail: { href, patch: type === "patch", pop: true } });
|
|
4217
4223
|
this.requestDOMUpdate(() => {
|
|
4218
4224
|
if (this.main.isConnected() && (type === "patch" && id === this.main.id)) {
|
|
4219
4225
|
this.main.pushLinkPatch(href, null, () => {
|
|
@@ -4291,6 +4297,7 @@ var LiveSocket = class {
|
|
|
4291
4297
|
return;
|
|
4292
4298
|
}
|
|
4293
4299
|
browser_default.pushState(linkState, { type: "patch", id: this.main.id }, href);
|
|
4300
|
+
dom_default.dispatchEvent(window, "phx:navigate", { detail: { patch: true, href, pop: false } });
|
|
4294
4301
|
this.registerNewLocation(window.location);
|
|
4295
4302
|
}
|
|
4296
4303
|
historyRedirect(href, linkState, flash) {
|
|
@@ -4303,9 +4310,12 @@ var LiveSocket = class {
|
|
|
4303
4310
|
}
|
|
4304
4311
|
let scroll = window.scrollY;
|
|
4305
4312
|
this.withPageLoading({ to: href, kind: "redirect" }, (done) => {
|
|
4306
|
-
this.replaceMain(href, flash, () => {
|
|
4307
|
-
|
|
4308
|
-
|
|
4313
|
+
this.replaceMain(href, flash, (linkRef) => {
|
|
4314
|
+
if (linkRef === this.linkRef) {
|
|
4315
|
+
browser_default.pushState(linkState, { type: "redirect", id: this.main.id, scroll }, href);
|
|
4316
|
+
dom_default.dispatchEvent(window, "phx:navigate", { detail: { href, patch: false, pop: false } });
|
|
4317
|
+
this.registerNewLocation(window.location);
|
|
4318
|
+
}
|
|
4309
4319
|
done();
|
|
4310
4320
|
});
|
|
4311
4321
|
});
|