Skip to content

Commit

Permalink
Bump build
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismccord committed Dec 2, 2024
1 parent 0e49760 commit 34ab2ae
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 33 deletions.
46 changes: 38 additions & 8 deletions priv/static/phoenix_live_view.cjs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions priv/static/phoenix_live_view.cjs.js.map

Large diffs are not rendered by default.

46 changes: 38 additions & 8 deletions priv/static/phoenix_live_view.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions priv/static/phoenix_live_view.esm.js.map

Large diffs are not rendered by default.

46 changes: 38 additions & 8 deletions priv/static/phoenix_live_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ var LiveView = (() => {
var PHX_LV_DEBUG = "phx:live-socket:debug";
var PHX_LV_PROFILE = "phx:live-socket:profiling";
var PHX_LV_LATENCY_SIM = "phx:live-socket:latency-sim";
var PHX_LV_HISTORY_POSITION = "phx:nav-history-position";
var PHX_PROGRESS = "progress";
var PHX_MOUNTED = "mounted";
var PHX_RELOAD_STATUS = "__phoenix_reload_status__";
Expand Down Expand Up @@ -3585,6 +3586,9 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
if (this.root === this) {
this.formsForRecovery = this.getFormsForRecovery();
}
if (this.isMain() && window.history.state === null) {
this.liveSocket.replaceRootHistory();
}
if (liveview_version !== this.liveSocket.version()) {
console.error(`LiveView asset version mismatch. JavaScript version ${this.liveSocket.version()} vs. server ${liveview_version}. To avoid issues, please ensure that your assets use the same version as the server.`);
}
Expand Down Expand Up @@ -4744,6 +4748,7 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
opts.dom || {}
);
this.transitions = new TransitionSet();
this.currentHistoryPosition = parseInt(this.sessionStorage.getItem(PHX_LV_HISTORY_POSITION)) || 0;
window.addEventListener("pagehide", (_e) => {
this.unloaded = true;
});
Expand All @@ -4755,7 +4760,7 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
}
// public
version() {
return "1.0.0-rc.7";
return "1.0.0-rc.8";
}
isProfileEnabled() {
return this.sessionStorage.getItem(PHX_LV_PROFILE) === "true";
Expand Down Expand Up @@ -5263,9 +5268,13 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
if (!this.registerNewLocation(window.location)) {
return;
}
let { type, id, root, scroll } = event.state || {};
let { type, backType, id, root, scroll, position } = event.state || {};
let href = window.location.href;
dom_default.dispatchEvent(window, "phx:navigate", { detail: { href, patch: type === "patch", pop: true } });
let isForward = position > this.currentHistoryPosition;
type = isForward ? type : backType || type;
this.currentHistoryPosition = position || 0;
this.sessionStorage.setItem(PHX_LV_HISTORY_POSITION, this.currentHistoryPosition.toString());
dom_default.dispatchEvent(window, "phx:navigate", { detail: { href, patch: type === "patch", pop: true, direction: isForward ? "forward" : "backward" } });
this.requestDOMUpdate(() => {
if (this.main.isConnected() && (type === "patch" && id === this.main.id)) {
this.main.pushLinkPatch(event, href, null, () => {
Expand Down Expand Up @@ -5342,8 +5351,15 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
if (!this.commitPendingLink(linkRef)) {
return;
}
browser_default.pushState(linkState, { type: "patch", id: this.main.id }, href);
dom_default.dispatchEvent(window, "phx:navigate", { detail: { patch: true, href, pop: false } });
this.currentHistoryPosition++;
this.sessionStorage.setItem(PHX_LV_HISTORY_POSITION, this.currentHistoryPosition.toString());
browser_default.updateCurrentState((state) => __spreadProps(__spreadValues({}, state), { backType: "patch" }));
browser_default.pushState(linkState, {
type: "patch",
id: this.main.id,
position: this.currentHistoryPosition
}, href);
dom_default.dispatchEvent(window, "phx:navigate", { detail: { patch: true, href, pop: false, direction: "forward" } });
this.registerNewLocation(window.location);
}
historyRedirect(e, href, linkState, flash, targetEl) {
Expand All @@ -5361,16 +5377,30 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
this.withPageLoading({ to: href, kind: "redirect" }, (done) => {
this.replaceMain(href, flash, (linkRef) => {
if (linkRef === this.linkRef) {
browser_default.pushState(linkState, { type: "redirect", id: this.main.id, scroll }, href);
dom_default.dispatchEvent(window, "phx:navigate", { detail: { href, patch: false, pop: false } });
this.currentHistoryPosition++;
this.sessionStorage.setItem(PHX_LV_HISTORY_POSITION, this.currentHistoryPosition.toString());
browser_default.updateCurrentState((state) => __spreadProps(__spreadValues({}, state), { backType: "redirect" }));
browser_default.pushState(linkState, {
type: "redirect",
id: this.main.id,
scroll,
position: this.currentHistoryPosition
}, href);
dom_default.dispatchEvent(window, "phx:navigate", { detail: { href, patch: false, pop: false, direction: "forward" } });
this.registerNewLocation(window.location);
}
done();
});
});
}
replaceRootHistory() {
browser_default.pushState("replace", { root: true, type: "patch", id: this.main.id });
browser_default.pushState("replace", {
root: true,
type: "patch",
id: this.main.id,
position: this.currentHistoryPosition
// Preserve current position
});
}
registerNewLocation(newLocation) {
let { pathname, search } = this.currentLocation;
Expand Down
Loading

0 comments on commit 34ab2ae

Please sign in to comment.