-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.html
More file actions
247 lines (217 loc) · 8.53 KB
/
index.html
File metadata and controls
247 lines (217 loc) · 8.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>RuntimeFS</title>
<style>
* {
font-family: monospace;
}
body {
cursor: default;
}
hr {
border: 1px solid white;
}
html {
background-color: black;
color: white;
}
.supportCheck,
#encryptionSection {
display: none;
}
button {
border: solid #ceface 1.5px;
border-radius: 5px;
padding: 4px;
cursor: pointer;
transition: background-color 200ms;
background-color: #15e264;
}
button:disabled {
cursor: not-allowed;
}
h1,
h2 {
color: #d7b7f2;
}
fieldset {
border: solid 1px #83ceec;
border-radius: 15px;
margin-bottom: 1em;
}
input[type=text] {
width: 175px;
}
input[type=checkbox] {
cursor: pointer;
}
button:hover {
background-color: #14af50;
}
button:active {
background-color: #098438;
}
input,
textarea {
transition: background-color 400ms, filter 800ms;
background-color: #3a5774;
border: solid #959595 1.5px;
border-radius: 5px;
color: white;
}
input:placeholder-shown,
textarea:placeholder-shown {
background-color: #262e36;
}
input:focus,
textarea:focus {
background-color: #5d5ba3;
box-shadow: 0 0 8px white;
}
input::placeholder,
textarea::placeholder {
color: #b8b8b8;
}
</style>
<script>
const handleFatalError = (error, source, lineno, colno) => {
const actualError = error || {};
const message = actualError.message || String(error || "Unknown error");
let errorMessage = `An error occurred: ${message}`;
// Safari uses error.line/error.column
const finalLine = lineno || actualError.line;
const finalCol = colno || actualError.column;
if (source || finalLine || finalCol) {
const fileName = source ? source.split("/").pop() || source : "unknown";
errorMessage += `\nSource: ${fileName}:${finalLine || "?"}:${finalCol || "?"}`;
}
if (globalThis.engine && globalThis.engine.destroyedError) {
errorMessage += `\nDetails: ${globalThis.engine.destroyedError}`;
}
if (actualError.stack) {
errorMessage += `\n\nStack trace:\n${actualError.stack}`;
} else if (typeof error === "object" && error !== null) {
try {
const json = JSON.stringify(error);
if (json !== "{}") errorMessage += `\nObject state: ${json}`;
} catch {
errorMessage += "\n(Object state hidden: circular reference)";
}
}
alert(errorMessage);
try {
if (typeof setUiBusy === "function") setUiBusy(false);
if (typeof logProgress === "function") logProgress("", true);
const syncInfo = document.getElementById("syncInfo");
if (syncInfo) syncInfo.textContent = "";
} catch (err) { }
};
window.onerror = (message, source, lineno, colno, error) => {
handleFatalError(error || message, source, lineno, colno);
};
window.onunhandledrejection = (e) => {
if (e.reason instanceof Error && e.reason.name === "NotSupportedError") {
console.warn("Caught and ignored a FileSystemObserver NotSupportedError. This is expected in some browsers.");
return;
}
handleFatalError(e.reason);
};
</script>
<script src="main.min.js" defer></script>
</head>
<body>
<h1>RuntimeFS</h1>
<fieldset>
<legend>
<h2>Manage Folders</h2>
</legend>
<label for="folderName">Folder Name:</label>
<input type="text" id="folderName" placeholder="Enter a name...">
<button onclick="uploadFolder()">Upload Folder</button>
<button onclick="syncFiles()" class="supportCheck">Sync</button>
<span id="syncInfo" class="supportCheck"></span>
<input type="file" id="folderUploadFallbackInput" webkitdirectory directory style="display: none">
<hr>
<label for="openFolderName">Folder to Open:</label>
<input type="text" id="openFolderName" placeholder="Enter folder name...">
<label for="fileName" placeholder="File name...">File:</label>
<input type="text" id="fileName" placeholder="index.html (optional)">
<button onclick="openFile()">Open</button>
<button onclick="openFileInPlace()">In-Place Open</button>
<button onclick="syncAndOpenFile()" class="supportCheck">Sync and Open</button>
</fieldset>
<fieldset>
<legend>
<h2>Data Management</h2>
</legend>
<div style="display: flex; gap: 20px; align-items: flex-start">
<div>
<strong>Existing Folders:</strong>
<ul id="folderList"></ul>
</div>
<div>
<strong>Delete Folder:</strong><br>
<input type="text" id="deleteFolderName" placeholder="Enter folder name...">
<button onclick="deleteFolder()">Delete</button>
</div>
<div></div>
<div>
<strong>Import / Export:</strong><br>
<button onclick="importData()">Import Data...</button>
<hr>
<button onclick="exportData()">Export Data...</button>
<div id="progress"></div>
</div>
<div>
<input type="checkbox" id="c1"><label for="c1">Cookies</label><br>
<input type="checkbox" id="c2" checked><label for="c2">localStorage</label><br>
<input type="checkbox" id="c3" checked><label for="c3">IndexedDB</label><br>
<input type="checkbox" id="c4" checked><label for="c4">RuntimeFS</label><br>
<input type="checkbox" id="c5" checked><label for="c5">OPFS</label><br>
<input type="checkbox" id="c6"><label for="c6">Cache Storage</label><br>
<input type="checkbox" id="c7"><label for="c7">Session Storage</label><br>
</div>
</div>
</fieldset>
<fieldset>
<legend>
<h2>Advanced</h2>
</legend>
<h3>Regex Replacement</h3>
Spaces required; disabled for files over 10MiB. File name matching uses regex.
<br>
Replace | with || and $ with $$ to only match the first instance.
Replace regexHere or plain text with <code>{{SCRIPT}}</code> to inject a script into the HTML.
<ul>
<li><code>* | regexHere -> replacement</code></li>
<li><code>file\.js $ plain text -> replacement</code></li>
<li><code>index\.html $ {{SCRIPT}} -> alert(1)</code></li>
</ul>
<textarea id="regex" rows="5" cols="40" placeholder="Enter rules here..."></textarea>
<hr>
<h3>Custom Headers</h3>
To use regex without replacing * with .* and escaping ., replace -> with -->.
<ul>
<li><code># Override the default headers for network requests.</code></li>
<li><code>* -> Cross-Origin-Embedder-Policy: require-corp</code></li>
<li><code>index\.(html|js) --> Cross-Origin-Opener-Policy: same-origin</code></li>
<li><code>*.html -> Content-Security-Policy: default-src 'self'; worker-src 'self' blob:;</code></li>
</ul>
<textarea id="headers" rows="5" cols="40" placeholder="Enter headers here..."></textarea>
<div id="encryptionSection">
<hr>
<h3>Encrypt Folders</h3>
You can encrypt a folder into a bunch of files.
<br><br>
<label for="encryptFolderName">Folder Name:</label>
<input type="text" id="encryptFolderName" placeholder="Enter a name...">
<br>
<button onclick="uploadAndEncryptWithPassword()">Password Encrypt Folder (in-browser)</button>
</div>
</fieldset>
</body>
</html>