1 | "use strict";
|
2 |
|
3 | var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
4 | if (kind === "m") throw new TypeError("Private method is not writable");
|
5 | if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
6 | if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
7 | return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
8 | };
|
9 | var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
10 | if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
11 | if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
12 | return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
13 | };
|
14 | var _a, _b, _c;
|
15 | var _WorkerLocationPolyfill_url;
|
16 |
|
17 | class WorkerLocationPolyfill {
|
18 | constructor(href) {
|
19 | _WorkerLocationPolyfill_url.set(this, void 0);
|
20 | __classPrivateFieldSet(this, _WorkerLocationPolyfill_url, new URL(href), "f");
|
21 | }
|
22 | get hash() { return ''; }
|
23 | get host() { return __classPrivateFieldGet(this, _WorkerLocationPolyfill_url, "f").host; }
|
24 | get hostname() { return __classPrivateFieldGet(this, _WorkerLocationPolyfill_url, "f").hostname; }
|
25 | get href() { return __classPrivateFieldGet(this, _WorkerLocationPolyfill_url, "f").href; }
|
26 | get origin() { return __classPrivateFieldGet(this, _WorkerLocationPolyfill_url, "f").origin; }
|
27 | get pathname() { return '/'; }
|
28 | get port() { return __classPrivateFieldGet(this, _WorkerLocationPolyfill_url, "f").port; }
|
29 | get protocol() { return __classPrivateFieldGet(this, _WorkerLocationPolyfill_url, "f").protocol; }
|
30 | get search() { return ''; }
|
31 | toString() { return this.href; }
|
32 | }
|
33 | _WorkerLocationPolyfill_url = new WeakMap();
|
34 | function defineProperty(url, writable = false) {
|
35 | Object.defineProperty(self, 'location', {
|
36 | configurable: false,
|
37 | enumerable: true,
|
38 | writable,
|
39 | value: new WorkerLocationPolyfill(url),
|
40 | });
|
41 | }
|
42 | function polyfillLocation(event) {
|
43 |
|
44 | const _event = event;
|
45 | defineProperty(_event.request.url, true);
|
46 | }
|
47 | if (!('location' in self)) {
|
48 | const envLoc = (_a = (self.WORKER_LOCATION)) !== null && _a !== void 0 ? _a : ((_c = (_b = self.process) === null || _b === void 0 ? void 0 : _b.env) === null || _c === void 0 ? void 0 : _c.WORKER_LOCATION);
|
49 | if (envLoc) {
|
50 | defineProperty(envLoc);
|
51 | }
|
52 | else {
|
53 | self.addEventListener('fetch', polyfillLocation);
|
54 | }
|
55 | }
|
56 |
|
\ | No newline at end of file |