mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 06:50:01 -04:00
commit
This commit is contained in:
parent
555ae496a5
commit
b448c5505b
20 changed files with 104 additions and 71 deletions
|
@ -4,8 +4,16 @@ import { hasAttrib } from "domutils";
|
|||
import render from "dom-serializer";
|
||||
import { encodeUrl } from "./url";
|
||||
import { rewriteCss } from "./css";
|
||||
// import { rewriteJs } from "./js";
|
||||
import { isScramjetFile } from "..";
|
||||
import { rewriteJs } from "./js";
|
||||
|
||||
export function isScramjetFile(src: string) {
|
||||
let bool = false;
|
||||
["codecs", "client", "shared", "worker", "config"].forEach((file) => {
|
||||
if (src === self.__scramjet$config[file]) bool = true;
|
||||
});
|
||||
|
||||
return bool;
|
||||
}
|
||||
|
||||
export function rewriteHtml(html: string, origin?: URL) {
|
||||
const handler = new DomHandler((err, dom) => dom);
|
||||
|
@ -50,7 +58,7 @@ function traverseParsedHtml(node, origin?: URL) {
|
|||
if (hasAttrib(node, "style")) node.attribs.style = rewriteCss(node.attribs.style, origin);
|
||||
|
||||
if (node.name === "style" && node.children[0] !== undefined) node.children[0].data = rewriteCss(node.children[0].data, origin);
|
||||
// if (node.name === "script" && /(application|text)\/javascript|importmap|undefined/.test(node.attribs.type) && node.children[0] !== undefined) node.children[0].data = rewriteJs(node.children[0].data, origin);
|
||||
if (node.name === "script" && /(application|text)\/javascript|importmap|undefined/.test(node.attribs.type) && node.children[0] !== undefined) node.children[0].data = rewriteJs(node.children[0].data, origin);
|
||||
if (node.name === "meta" && hasAttrib(node, "http-equiv")) {
|
||||
if (node.attribs["http-equiv"] === "content-security-policy") {
|
||||
node = {};
|
||||
|
@ -66,7 +74,6 @@ function traverseParsedHtml(node, origin?: URL) {
|
|||
["codecs", "config", "shared", "client"].forEach((script) => {
|
||||
scramjetScripts.push(new Element("script", {
|
||||
src: self.__scramjet$config[script],
|
||||
type: "module",
|
||||
"data-scramjet": ""
|
||||
}));
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue