@kehto/paja 0.16.1 → 0.16.2
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/README.md +3 -1
- package/dist/browser-host.js +59 -0
- package/dist/browser-host.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -308,7 +308,9 @@ Paja's developer-runtime policy accepts arbitrary `http:` and `https:` resource
|
|
|
308
308
|
URLs so a normal remote image does not look broken merely because its origin was
|
|
309
309
|
not pre-granted. Paja resolves those URLs with browser `fetch`, omits credentials
|
|
310
310
|
and referrer data, caps responses at 10 MiB, and classifies MIME from returned
|
|
311
|
-
bytes.
|
|
311
|
+
bytes. Its byte classifier recognizes checksum-valid Game Boy ROM headers as
|
|
312
|
+
`application/vnd.nintendo.gb-rom`; it never trusts a server-supplied media type.
|
|
313
|
+
Browser network and CORS rules still apply: an unreadable response is the
|
|
312
314
|
canonical `network-error`, while any CORS-readable response is returned as NAP
|
|
313
315
|
bytes.
|
|
314
316
|
|
package/dist/browser-host.js
CHANGED
|
@@ -16869,6 +16869,56 @@ var PAJA_RESOURCE_MAX_URLS = 100;
|
|
|
16869
16869
|
var PAJA_RESOURCE_MAX_SERVERS = 8;
|
|
16870
16870
|
var UTF8_DECODER = new TextDecoder("utf-8", { fatal: true });
|
|
16871
16871
|
var BLOSSOM_RESOURCE_PATTERN = /^blossom:sha256:([0-9a-f]{64})$/i;
|
|
16872
|
+
var GAME_BOY_NINTENDO_LOGO = [
|
|
16873
|
+
206,
|
|
16874
|
+
237,
|
|
16875
|
+
102,
|
|
16876
|
+
102,
|
|
16877
|
+
204,
|
|
16878
|
+
13,
|
|
16879
|
+
0,
|
|
16880
|
+
11,
|
|
16881
|
+
3,
|
|
16882
|
+
115,
|
|
16883
|
+
0,
|
|
16884
|
+
131,
|
|
16885
|
+
0,
|
|
16886
|
+
12,
|
|
16887
|
+
0,
|
|
16888
|
+
13,
|
|
16889
|
+
0,
|
|
16890
|
+
8,
|
|
16891
|
+
17,
|
|
16892
|
+
31,
|
|
16893
|
+
136,
|
|
16894
|
+
137,
|
|
16895
|
+
0,
|
|
16896
|
+
14,
|
|
16897
|
+
220,
|
|
16898
|
+
204,
|
|
16899
|
+
110,
|
|
16900
|
+
230,
|
|
16901
|
+
221,
|
|
16902
|
+
221,
|
|
16903
|
+
217,
|
|
16904
|
+
153,
|
|
16905
|
+
187,
|
|
16906
|
+
187,
|
|
16907
|
+
103,
|
|
16908
|
+
99,
|
|
16909
|
+
110,
|
|
16910
|
+
14,
|
|
16911
|
+
236,
|
|
16912
|
+
204,
|
|
16913
|
+
221,
|
|
16914
|
+
220,
|
|
16915
|
+
153,
|
|
16916
|
+
159,
|
|
16917
|
+
187,
|
|
16918
|
+
185,
|
|
16919
|
+
51,
|
|
16920
|
+
62
|
|
16921
|
+
];
|
|
16872
16922
|
function createPajaResourceFetch(options = {}) {
|
|
16873
16923
|
return async (value, init) => {
|
|
16874
16924
|
if (init.signal.aborted) throw new DOMException("Resource request cancelled", "AbortError");
|
|
@@ -17127,8 +17177,17 @@ function sniffSafeResourceMime(bytes) {
|
|
|
17127
17177
|
if (ascii(bytes, 4, 8) === "ftyp") return "video/mp4";
|
|
17128
17178
|
if (ascii(bytes, 0, 4) === "wOFF") return "font/woff";
|
|
17129
17179
|
if (ascii(bytes, 0, 4) === "wOF2") return "font/woff2";
|
|
17180
|
+
if (isGameBoyRom(bytes)) return "application/vnd.nintendo.gb-rom";
|
|
17130
17181
|
return sniffSafeTextMime(bytes);
|
|
17131
17182
|
}
|
|
17183
|
+
function isGameBoyRom(bytes) {
|
|
17184
|
+
if (bytes.byteLength < 336 || !startsWith(bytes, GAME_BOY_NINTENDO_LOGO, 260)) return false;
|
|
17185
|
+
let checksum = 0;
|
|
17186
|
+
for (let index = 308; index <= 332; index += 1) {
|
|
17187
|
+
checksum = checksum - (bytes[index] ?? 0) - 1 & 255;
|
|
17188
|
+
}
|
|
17189
|
+
return checksum === bytes[333];
|
|
17190
|
+
}
|
|
17132
17191
|
function sniffSafeTextMime(bytes) {
|
|
17133
17192
|
let text;
|
|
17134
17193
|
try {
|