We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ae4c229 commit 1e08450Copy full SHA for 1e08450
packages/chrome/src/Browser.tsx
@@ -20,30 +20,6 @@ import type { ScramjetDownload } from "@mercuryworkshop/scramjet";
20
21
export let browser: Browser;
22
23
-export const config = createState({
24
- theme: {
25
- frame_bg: [231, 238, 245],
26
- toolbar_bg: [211, 218, 255],
27
- toolbar_button_fg: [65, 72, 76],
28
- toolbar_fg: [65, 72, 76],
29
-
30
- inactive_tab_bg: [40, 40, 40],
31
- inactive_tab_fg: [95, 92, 96],
32
- active_tab_fg: [65, 72, 76],
33
34
- button_bg: [231, 238, 0],
35
36
- ntp_bg: [231, 238, 0],
37
- ntp_fg: [232, 234, 237],
38
- ntp_link_fg: [138, 180, 248],
39
40
- omnibox_bg: [221, 228, 235],
41
- omnibox_fg: [227, 227, 227],
42
43
- bookmark_fg: [199, 199, 199],
44
- },
45
-});
46
47
export type SerializedBrowser = {
48
tabs: SerializedTab[];
49
globalhistory: SerializedHistoryState[];
packages/chrome/src/History.ts
@@ -80,11 +80,18 @@ export class History {
80
return this.states[this.index];
81
}
82
83
- push(url: URL, state: any = null, navigate: boolean = true): HistoryState {
+ push(
84
+ url: URL,
85
+ state: any = null,
86
+ navigate: boolean = true,
87
+ virtual: boolean = false
88
+ ): HistoryState {
89
if (this.index + 1 < this.states.length)
90
// "fork" history tree, creating a new timeline
91
this.states.splice(this.index, this.states.length - this.index);
92
const hstate = new HistoryState({ url, state });
93
+ if (virtual) hstate.virtual = true;
94
+
95
if (url.href != "puter://newtab") browser.globalhistory.push(hstate);
96
this.states.push(hstate);
97
this.index++;
@@ -130,8 +137,10 @@ export class History {
130
137
let newstate = this.states[this.index];
131
138
132
139
if (newstate.virtual) {
133
- sendFrame(this.tab, "history_go", {
134
- delta,
140
+ sendFrame(this.tab, "popstate", {
141
+ state: newstate.state,
142
+ url: newstate.url.href,
143
+ title: newstate.title || "",
135
144
});
136
145
} else if (navigate) {
146
this.justTriggeredNavigation = true;
packages/chrome/src/IsolatedFrame.tsx
@@ -819,4 +819,20 @@ const chromemethods: ChromeboundMethods = {
819
tab.history.push(new URL(url), undefined, false);
820
821
},
822
823
+ history_go: async (tab, { delta }) => {
824
+ if (tab) {
825
+ tab.history.go(delta);
826
+ }
827
+ },
828
+ history_pushState: async (tab, { url, title }) => {
829
830
+ tab.history.push(new URL(url), title, true);
831
832
833
+ history_replaceState: async (tab, { url, title }) => {
834
835
+ tab.history.replace(new URL(url), title);
836
837
838
};
packages/chrome/src/pages/NewTabPage.tsx
@@ -113,7 +113,7 @@ NewTabPage.style = css`
113
114
.inputcontainer {
115
flex: 1;
116
- max-width: 40em;
+ max-width: 60em;
117
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1);
118
background: var(--bg20);
119
border-radius: var(--radius);
packages/inject/src/index.ts
@@ -7,12 +7,16 @@ import { sendChrome } from "./ipc";
7
export const client = self[SCRAMJETCLIENT];
8
export const chromeframe = top!;
9
10
+const history_replaceState = History.prototype.replaceState;
11
12
export const methods: FrameboundMethods = {
13
async navigate({ url }) {
14
window.location.href = url;
15
- async history_go({ delta }) {
- client.natives.call("History.prototype.go", history, delta);
16
+ async popstate({ url, state, title }) {
17
+ history_replaceState.call(history, state, title, url);
18
+ const popStateEvent = new PopStateEvent("popstate", { state });
19
+ window.dispatchEvent(popStateEvent);
@@ -114,7 +118,7 @@ function setupHistoryEmulation() {
sendChrome("history_pushState", {
state: ctx.args[0],
120
title: ctx.args[1],
- url: ctx.args[2],
121
+ url: new URL(ctx.args[2], client.url).href,
122
123
124
ctx.return(undefined);
@@ -126,7 +130,7 @@ function setupHistoryEmulation() {
126
sendChrome("history_replaceState", {
127
128
129
packages/inject/src/types.d.ts
@@ -57,5 +57,11 @@ export type Framebound = {
57
url: string;
58
59
];
60
- history_go: [{ delta: number }, void];
+ popstate: [
61
+ {
62
+ state: any;
63
+ url: string;
64
+ title: string;
65
66
+ ];
67
0 commit comments