Update and minify Osana
Prior to this commit, Osana was not minified at all. This commit updates Osana so it is minified. Refraining from minification is just asking for longer load times.
This commit is contained in:
parent
9fc1780af6
commit
40e9a564c5
4 changed files with 5 additions and 22587 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1,40 +1,2 @@
|
||||||
/******/ (() => { // webpackBootstrap
|
(()=>{"use strict";self.__osana$config={bare:`${location.origin}/bare/`,prefix:"/service/~osana/",codec:self.__osana$bundle.codecs.none,files:{config:"/osana.config.js",client:"/osana.client.js",bundle:"/osana.bundle.js",worker:"/osana.worker.js"},blacklist:[/^(www\.)?netflix\.com/,/^accounts\.google\.com/]}})();
|
||||||
/******/ "use strict";
|
|
||||||
/******/ // The require scope
|
|
||||||
/******/ var __webpack_require__ = {};
|
|
||||||
/******/
|
|
||||||
/************************************************************************/
|
|
||||||
/******/ /* webpack/runtime/make namespace object */
|
|
||||||
/******/ (() => {
|
|
||||||
/******/ // define __esModule on exports
|
|
||||||
/******/ __webpack_require__.r = (exports) => {
|
|
||||||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
||||||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
||||||
/******/ }
|
|
||||||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
||||||
/******/ };
|
|
||||||
/******/ })();
|
|
||||||
/******/
|
|
||||||
/************************************************************************/
|
|
||||||
var __webpack_exports__ = {};
|
|
||||||
__webpack_require__.r(__webpack_exports__);
|
|
||||||
self.__osana$config = {
|
|
||||||
bare: `${location.origin}/bare/`,
|
|
||||||
prefix: "/service/~osana/",
|
|
||||||
codec: self.__osana$bundle.codecs.none,
|
|
||||||
files: {
|
|
||||||
config: "/osana/osana.config.js",
|
|
||||||
client: "/osana/osana.client.js",
|
|
||||||
bundle: "/osana/osana.bundle.js",
|
|
||||||
worker: "/osana/osana.worker.js"
|
|
||||||
},
|
|
||||||
blacklist: [
|
|
||||||
/^(www\.)?netflix\.com/,
|
|
||||||
/^accounts\.google\.com/,
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/******/ })()
|
|
||||||
;
|
|
||||||
//# sourceMappingURL=osana.config.js.map
|
//# sourceMappingURL=osana.config.js.map
|
||||||
|
|
@ -1,103 +1,2 @@
|
||||||
/******/ (() => { // webpackBootstrap
|
(()=>{"use strict";importScripts("/osana/osana.bundle.js?1"),importScripts("/osana/osana.config.js?1"),self.OsanaServiceWorker=class{constructor(){this.config=self.__osana$config,this.bundle=self.__osana$bundle,this.bareClient=new this.bundle.BareClient(this.config.bare)}fetch(t){return s=this,n=void 0,r=function*(){const s=this.config.codec.decode(new URL(t.request.url).pathname.replace(this.config.prefix,""))+new URL(t.request.url).search;if(!/^https?:\/\//.test(s))return fetch(t.request.url);const n=new URL(s),i=this.bundle.rewrite.headers.request(Object.fromEntries(t.request.headers.entries()),n);if(this.config.blacklist&&this.config.blacklist.some((e=>e.test(n.host))))return new e;const r={method:t.request.method,headers:i};["GET","HEAD"].includes(t.request.method)||(r.body=yield t.request.blob());const o=yield this.bareClient.fetch(n,r);let a=o.rawResponse.status;const c=this.bundle.rewrite.headers.response(o.rawHeaders,n);let l="";return/text\/html/.test(c["Content-Type"])?(l=`<head><script src="${this.config.files.bundle}?1"><\/script><script src="${this.config.files.config}?1"><\/script><script src="${this.config.files.client}?1"><\/script><link rel="icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdjYGBkZAAAAAoAAx9k7/gAAAAASUVORK5CYIIA"><link rel="icon" href="${n.origin}/favicon.ico">`+(301===a&&c.location?`<meta http-equiv="refresh" content="0; url=${this.bundle.rewrite.url(c.location)}">`:"")+"</head>",l+=this.bundle.rewrite.html(yield o.text(),n.origin+n.pathname)):l=/text\/css/.test(c["Content-Type"])||"style"===t.request.destination?this.bundle.rewrite.css(yield o.text(),n.origin+n.pathname):/application\/javascript/.test(c["Content-Type"])||"script"===t.request.destination?this.bundle.rewrite.js(yield o.text()):yield o.arrayBuffer(),new Response(l,{status:o.rawResponse.status,statusText:o.rawResponse.statusText,headers:c})},new((i=void 0)||(i=Promise))((function(e,t){function o(e){try{c(r.next(e))}catch(e){t(e)}}function a(e){try{c(r.throw(e))}catch(e){t(e)}}function c(t){var s;t.done?e(t.value):(s=t.value,s instanceof i?s:new i((function(e){e(s)}))).then(o,a)}c((r=r.apply(s,n||[])).next())}));var s,n,i,r}};class e extends Response{constructor(){super("Forbidden",{status:403,statusText:"Forbidden",headers:{"Content-Type":"text/plain"}})}}})();
|
||||||
/******/ "use strict";
|
|
||||||
/******/ // The require scope
|
|
||||||
/******/ var __webpack_require__ = {};
|
|
||||||
/******/
|
|
||||||
/************************************************************************/
|
|
||||||
/******/ /* webpack/runtime/make namespace object */
|
|
||||||
/******/ (() => {
|
|
||||||
/******/ // define __esModule on exports
|
|
||||||
/******/ __webpack_require__.r = (exports) => {
|
|
||||||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
||||||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
||||||
/******/ }
|
|
||||||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
||||||
/******/ };
|
|
||||||
/******/ })();
|
|
||||||
/******/
|
|
||||||
/************************************************************************/
|
|
||||||
var __webpack_exports__ = {};
|
|
||||||
__webpack_require__.r(__webpack_exports__);
|
|
||||||
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
importScripts(`../osana/osana.bundle.js`);
|
|
||||||
importScripts(`../osana/osana.config.js`);
|
|
||||||
self.OsanaServiceWorker = class OsanaServiceWorker {
|
|
||||||
constructor() {
|
|
||||||
this.config = self.__osana$config;
|
|
||||||
this.bundle = self.__osana$bundle;
|
|
||||||
this.bareClient = new this.bundle.BareClient(this.config.bare);
|
|
||||||
}
|
|
||||||
fetch(event) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const url = this.config.codec.decode(new URL(event.request.url).pathname.replace(this.config.prefix, "")) + new URL(event.request.url).search;
|
|
||||||
if (!/^https?:\/\//.test(url)) {
|
|
||||||
return fetch(event.request.url);
|
|
||||||
}
|
|
||||||
const requestURL = new URL(url);
|
|
||||||
const requestHeaders = this.bundle.rewrite.headers.request(Object.fromEntries(event.request.headers.entries()), requestURL);
|
|
||||||
if (this.config.blacklist && this.config.blacklist.some(regex => regex.test(requestURL.host))) {
|
|
||||||
return new BlackListedResponse();
|
|
||||||
}
|
|
||||||
const bareRequestData = {
|
|
||||||
method: event.request.method,
|
|
||||||
headers: requestHeaders
|
|
||||||
};
|
|
||||||
if (!["GET", "HEAD"].includes(event.request.method))
|
|
||||||
bareRequestData.body = yield event.request.blob();
|
|
||||||
const response = yield this.bareClient.fetch(requestURL, bareRequestData);
|
|
||||||
let responseStatus = response.rawResponse.status;
|
|
||||||
const responseHeaders = this.bundle.rewrite.headers.response(response.rawHeaders, requestURL);
|
|
||||||
let responseData = "";
|
|
||||||
if (/text\/html/.test(responseHeaders["Content-Type"])) {
|
|
||||||
responseData =
|
|
||||||
`<head>` +
|
|
||||||
`<script src="${this.config.files.bundle}?1"></script>` +
|
|
||||||
`<script src="${this.config.files.config}?1"></script>` +
|
|
||||||
`<script src="${this.config.files.client}?1"></script>` +
|
|
||||||
`<link rel="icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdjYGBkZAAAAAoAAx9k7/gAAAAASUVORK5CYIIA">` +
|
|
||||||
`<link rel="icon" href="${requestURL.origin}/favicon.ico">` +
|
|
||||||
`${(responseStatus === 301 && responseHeaders["location"]) ? `<meta http-equiv="refresh" content="0; url=${this.bundle.rewrite.url(responseHeaders["location"])}">` : ""}` +
|
|
||||||
`</head>`;
|
|
||||||
responseData += this.bundle.rewrite.html(yield response.text(), (requestURL.origin + requestURL.pathname));
|
|
||||||
}
|
|
||||||
else if (/text\/css/.test(responseHeaders["Content-Type"]) || event.request.destination === "style") {
|
|
||||||
responseData = this.bundle.rewrite.css(yield response.text(), (requestURL.origin + requestURL.pathname));
|
|
||||||
}
|
|
||||||
else if (/application\/javascript/.test(responseHeaders["Content-Type"]) || event.request.destination === "script") {
|
|
||||||
responseData = this.bundle.rewrite.js(yield response.text());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
responseData = yield response.arrayBuffer();
|
|
||||||
}
|
|
||||||
return new Response(responseData, {
|
|
||||||
status: response.rawResponse.status,
|
|
||||||
statusText: response.rawResponse.statusText,
|
|
||||||
headers: responseHeaders
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
class BlackListedResponse extends Response {
|
|
||||||
constructor() {
|
|
||||||
super("Forbidden", {
|
|
||||||
status: 403,
|
|
||||||
statusText: "Forbidden",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "text/plain"
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/******/ })()
|
|
||||||
;
|
|
||||||
//# sourceMappingURL=osana.worker.js.map
|
//# sourceMappingURL=osana.worker.js.map
|
||||||
Loading…
Add table
Reference in a new issue