From 355e87dd216ca97ff3ff3486bf83e01803592e7d Mon Sep 17 00:00:00 2001 From: Jason <59297610+caracal-js@users.noreply.github.com> Date: Wed, 23 Feb 2022 15:04:25 -0500 Subject: [PATCH] Almost done! --- client/dom/style.js | 19 ++++++++++ example/index.js | 8 ++++- example/load.html | 2 +- example/static/index.css | 73 ++++++++++++++++++++++++++++++++++++++ example/static/index.html | 28 +++++++++------ example/static/uv.png | Bin 0 -> 20873 bytes lib/uv.bundle.js | 58 +++++++++++++++++++++++++++--- lib/uv.config.js | 9 +++++ lib/uv.handler.js | 41 +++++++++++++++------ lib/uv.sw.js | 14 ++++---- rewrite/index.js | 1 + rewrite/rewrite.html.js | 37 ++++++++++++++++--- tomp/tomp.js | 10 ++++++ 13 files changed, 262 insertions(+), 38 deletions(-) create mode 100644 example/static/index.css create mode 100644 example/static/uv.png create mode 100644 lib/uv.config.js create mode 100644 tomp/tomp.js diff --git a/client/dom/style.js b/client/dom/style.js index 77e476d..8ef0474 100644 --- a/client/dom/style.js +++ b/client/dom/style.js @@ -10,6 +10,7 @@ class StyleApi extends EventEmitter { this.cssStyleProto = this.CSSStyleDeclaration.prototype || {}; this.getPropertyValue = this.cssStyleProto.getPropertyValue || null; this.setProperty = this.cssStyleProto.setProperty || null; + this.cssText - ctx.nativeMethods.getOwnPropertyDescriptors(this.cssStyleProto, 'cssText'); this.urlProps = ['background', 'backgroundImage', 'borderImage', 'borderImageSource', 'listStyle', 'listStyleImage', 'cursor']; this.dashedUrlProps = ['background', 'background-image', 'border-image', 'border-image-source', 'list-style', 'list-style-image', 'cursor']; this.propToDashed = { @@ -45,6 +46,24 @@ class StyleApi extends EventEmitter { return event.target.call(event.that, event.data.property, event.data.value); }); }; + overrideCssText() { + this.ctx.overrideDescriptor(this.cssStyleProto, 'cssText', { + get: (target, that) => { + const event = new HookEvent({ value: target.call(that) }, target, that); + this.emit('getCssText', event); + + if (event.intercepted) return event.returnValue; + return event.data.value; + }, + set: (target, that, [ val ]) => { + const event = new HookEvent({ value: val }, target, that); + this.emit('setCssText', event); + + if (event.intercepted) return event.returnValue; + return event.target.call(event.that, event.data.value); + }, + }); + }; }; export default StyleApi; \ No newline at end of file diff --git a/example/index.js b/example/index.js index 6ed10fc..118565c 100644 --- a/example/index.js +++ b/example/index.js @@ -36,6 +36,12 @@ server.on('request', (req, res) => { return true; }; + if (req.url.startsWith('/uv.config.js')) { + res.writeHead(200, { "Content-Type": "application/javascript" }); + createUVFileStream('uv.config.js').pipe(res); + return true; + }; + if (req.url.startsWith(config.prefix)) { res.writeHead(200, { "Content-Type": "text/html" }); createReadStream(path.join(__dirname, './load.html')).pipe(res); @@ -49,7 +55,7 @@ server.on('upgrade', (req, socket, head) => { if (!bare.route_upgrade(req, socket, head)) socket.end(); }); -server.listen(3030); +server.listen(443); function createUVFileStream(file) { return createReadStream( diff --git a/example/load.html b/example/load.html index 10e363f..3f63e21 100644 --- a/example/load.html +++ b/example/load.html @@ -5,7 +5,7 @@ - - + +
-