@shgysk8zer0/polyfills 0.0.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/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/README.md +2 -0
- package/abort.js +194 -0
- package/all.js +30 -0
- package/animation.js +33 -0
- package/aom.js +43 -0
- package/appBadge.js +27 -0
- package/array.js +258 -0
- package/assets/CookieStore.js +230 -0
- package/assets/Lock.js +31 -0
- package/assets/LockManager.js +278 -0
- package/assets/Sanitizer.js +59 -0
- package/assets/SanitizerConfig.js +348 -0
- package/assets/SanitizerConfigBase.js +18 -0
- package/assets/SanitizerConfigEdge.js +335 -0
- package/assets/SanitizerConfigW3C.js +766 -0
- package/assets/Scheduler.js +124 -0
- package/assets/TextDecoder.js +83 -0
- package/assets/TextEncoder.js +41 -0
- package/assets/TrustedTypes.js +595 -0
- package/assets/attributes.js +15 -0
- package/assets/csp.js +29 -0
- package/assets/error.js +8 -0
- package/assets/sanitizerUtils.js +270 -0
- package/assets/trust.js +190 -0
- package/assets/utility.js +101 -0
- package/cookieStore.js +2 -0
- package/crypto.js +8 -0
- package/dialog.js +63 -0
- package/element.js +171 -0
- package/elementInternals.js +616 -0
- package/errors.js +21 -0
- package/function.js +31 -0
- package/globalThis.js +36 -0
- package/iterator.js +197 -0
- package/legacy/array.js +15 -0
- package/legacy/element.js +140 -0
- package/legacy/map.js +168 -0
- package/legacy/object.js +42 -0
- package/legacy.js +9 -0
- package/locks.js +33 -0
- package/map.js +32 -0
- package/match-media.js +58 -0
- package/math.js +69 -0
- package/navigator.js +55 -0
- package/number.js +14 -0
- package/package.json +52 -0
- package/performance.js +36 -0
- package/promise.js +70 -0
- package/sanitizer.js +3 -0
- package/scheduler.js +5 -0
- package/secure-context.js +31 -0
- package/set.js +73 -0
- package/share.js +17 -0
- package/symbols.js +9 -0
- package/textEncoder.js +16 -0
- package/trustedTypes.js +3 -0
- package/weakMap.js +28 -0
- package/window.js +85 -0
package/math.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
if (! Number.hasOwnProperty('isSafeInteger')) {
|
|
5
|
+
Number.MAX_SAFE_INTEGER = 2**53 -1;
|
|
6
|
+
Number.MIN_SAFE_INTEGER = -Number.MAX_SAFE_INTEGER;
|
|
7
|
+
Number.isSafeInteger = num => num <= Number.MAX_SAFE_INTEGER && num >= Number.MIN_SAFE_INTEGER;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (! Number.hasOwnProperty('EPSILON')) {
|
|
11
|
+
Number.EPSILON = 2**-52;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (! Math.hasOwnProperty('sign')) {
|
|
15
|
+
Math.sign = x => ((x > 0) - (x < 0)) || +x;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (! Math.hasOwnProperty('trunc')) {
|
|
19
|
+
Math.trunc = x => {
|
|
20
|
+
const n = x - x%1;
|
|
21
|
+
return n===0 && (x<0 || (x===0 && (1/x !== 1/0))) ? -0 : n;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (! Math.hasOwnProperty('expm1')) {
|
|
26
|
+
Math.expm1 = x => Math.exp(x) - 1;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (! Math.hasOwnProperty('hypot')) {
|
|
30
|
+
Math.hypot = (...nums) => Math.sqrt(nums.reduce((sum, num) => sum + num**2, 0));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (! Math.hasOwnProperty('cbrt')) {
|
|
34
|
+
Math.cbrt = x => x**(1/3);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (! Math.hasOwnProperty('log10')) {
|
|
38
|
+
Math.log10 = x => Math.log(x) * Math.LOG10E;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (! Math.hasOwnProperty('log2')) {
|
|
42
|
+
Math.log2 = x => Math.log(x) * Math.LOG2E;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (! Math.hasOwnProperty('log1p')) {
|
|
46
|
+
Math.log1p = x => Math.log(1 + x);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (! Math.hasOwnProperty('fround')) {
|
|
50
|
+
Math.fround = (function (array) {
|
|
51
|
+
return function(x) {
|
|
52
|
+
return array[0] = x, array[0];
|
|
53
|
+
};
|
|
54
|
+
})(new Float32Array(1));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (! (Math.clamp instanceof Function)) {
|
|
58
|
+
Math.clamp = function(value, min, max) {
|
|
59
|
+
return Math.min(Math.max(value, min), max);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/*
|
|
64
|
+
* Question of if it will be `Math.clamp` or `Math.constrain`
|
|
65
|
+
*/
|
|
66
|
+
if (! (Math.constrain instanceof Function)) {
|
|
67
|
+
Math.constrain = Math.clamp;
|
|
68
|
+
}
|
|
69
|
+
})();
|
package/navigator.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import './locks.js';
|
|
2
|
+
import './share.js';
|
|
3
|
+
import './appBadge.js';
|
|
4
|
+
|
|
5
|
+
if (! Navigator.prototype.hasOwnProperty('pdfViewerEnabled')) {
|
|
6
|
+
Object.defineProperty(navigator, 'pdfViewerEnabled', {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: false,
|
|
9
|
+
writable: false,
|
|
10
|
+
value: false,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (! (Navigator.prototype.getInstalledRelatedApps instanceof Function)) {
|
|
15
|
+
Navigator.prototype.getInstalledRelatedApps = async () => [];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (! (Navigator.prototype.getGamepads instanceof Function)) {
|
|
19
|
+
Navigator.prototype.getGamepads = () => [];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (! ('hardwareConcurrency' in Navigator.prototype)) {
|
|
23
|
+
Object.defineProperty(Navigator.prototype, 'hardwareConcurrency', {
|
|
24
|
+
get: () => 1,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (! ('connection' in Navigator.prototype)) {
|
|
29
|
+
Object.defineProperty(Navigator.prototype, 'connection', {
|
|
30
|
+
get: () => Object.create(EventTarget.prototype, {
|
|
31
|
+
type: { value: 'unknown' },
|
|
32
|
+
effectiveType: { value: '4g' },
|
|
33
|
+
rtt: { value: NaN },
|
|
34
|
+
downlink: { value: NaN },
|
|
35
|
+
downlinkMax: { value: Infinity },
|
|
36
|
+
saveData: { value: false },
|
|
37
|
+
onchange: { value: null, writable: true },
|
|
38
|
+
ontypechange: { value: null, writable: true },
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
} else if (! ('type' in navigator.connection)) {
|
|
42
|
+
navigator.connection.type = 'unknown';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (! ('doNotTrack' in Navigator.prototype)) {
|
|
46
|
+
Object.defineProperty(Navigator.prototype, 'doNotTrack', {
|
|
47
|
+
get: () => 'unspecified',
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (! ('globalPrivacyControl' in Navigator.prototype)) {
|
|
52
|
+
Object.defineProperty(Navigator.prototype, 'globalPrivacyControl', {
|
|
53
|
+
get: () => false,
|
|
54
|
+
});
|
|
55
|
+
}
|
package/number.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
if (! (Number.range instanceof Function)) {
|
|
5
|
+
/**
|
|
6
|
+
* @see https://github.com/tc39/proposal-Number.range
|
|
7
|
+
* @deprecated - changed to `Iterator.range`
|
|
8
|
+
*/
|
|
9
|
+
Number.range = function range(start, end, step = 1) {
|
|
10
|
+
console.warn('`Number.range()` is deprecated. Use `Iterator.range()` instead.');
|
|
11
|
+
return globalThis.Iterator.range(start, end, { step });
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
})();
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@shgysk8zer0/polyfills",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "A collection of JavaScript polyfills",
|
|
6
|
+
"config": {
|
|
7
|
+
"serve": {
|
|
8
|
+
"domain": "localhost",
|
|
9
|
+
"path": "./",
|
|
10
|
+
"port": 8080
|
|
11
|
+
},
|
|
12
|
+
"dir": {
|
|
13
|
+
"css": "css/ components/",
|
|
14
|
+
"js": "js/ components/",
|
|
15
|
+
"img": "img/",
|
|
16
|
+
"html": "components/"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"test": "npm run lint:js && npm run lint:html",
|
|
21
|
+
"preversion": "npm test",
|
|
22
|
+
"start": "http-server ${npm_package_config_serve_path} -c-1 --port ${npm_package_config_serve_port} --gzip true --brotli true -a ${npm_package_config_serve_domain} -o /test/",
|
|
23
|
+
"fix": "npm run fix:js",
|
|
24
|
+
"fix:js": "eslint . --fix",
|
|
25
|
+
"lint:js": "eslint .",
|
|
26
|
+
"lint:html": "htmlhint \"**/*.html\"",
|
|
27
|
+
"create:lock": "npm i --package-lock-only --ignore-scripts",
|
|
28
|
+
"version:bump": "npm run version:bump:patch",
|
|
29
|
+
"version:bump:patch": "npm version --no-git-tag-version patch",
|
|
30
|
+
"version:bump:minor": "npm version --no-git-tag-version minor",
|
|
31
|
+
"version:bump:major": "npm version --no-git-tag-version major"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/shgysk8zer0/polyfills.git"
|
|
36
|
+
},
|
|
37
|
+
"keywords": [
|
|
38
|
+
"polyfills",
|
|
39
|
+
"shims"
|
|
40
|
+
],
|
|
41
|
+
"author": "Chris Zuber <shgysk8zer0@gmail.com>",
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/shgysk8zer0/polyfills/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://github.com/shgysk8zer0/polyfills#readme",
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"eslint": "^8.40.0",
|
|
49
|
+
"htmlhint": "^1.1.4",
|
|
50
|
+
"http-server": "^14.1.1"
|
|
51
|
+
}
|
|
52
|
+
}
|
package/performance.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
if (! (globalThis.requestIdleCallback instanceof Function)) {
|
|
5
|
+
const isValidTimeout = timeout => Number.isSafeInteger(timeout) && timeout > 0;
|
|
6
|
+
|
|
7
|
+
globalThis.requestIdleCallback = function(callback, { timeout } = {}) {
|
|
8
|
+
const start = performance.now();
|
|
9
|
+
const timeRemaining = () => isValidTimeout(timeout)
|
|
10
|
+
? Math.max(0, timeout - (performance.now() - start))
|
|
11
|
+
: Math.max(0, 600 - (performance.now() - start));
|
|
12
|
+
|
|
13
|
+
return setTimeout(() => callback({
|
|
14
|
+
didTimeout: isValidTimeout(timeout) ? timeRemaining() === 0 : false,
|
|
15
|
+
timeRemaining,
|
|
16
|
+
}), 1);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (! (globalThis.cancelIdleCallback instanceof Function)) {
|
|
21
|
+
globalThis.cancelIdleCallback = id => clearTimeout(id);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (! (globalThis.requestAnimationFrame instanceof Function)) {
|
|
25
|
+
globalThis.requestAnimationFrame = callback => setTimeout(() => callback(performance.now()), 1000 / 60);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (! (globalThis.cancelAnimationFrame instanceof Function)) {
|
|
29
|
+
globalThis.cancelAnimationFrame = id => clearTimeout(id);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (! (globalThis.queueMicrotask instanceof Function)) {
|
|
33
|
+
globalThis.queueMicrotask = cb => Promise.resolve().then(cb)
|
|
34
|
+
.catch(e => setTimeout(() => { throw e; }));
|
|
35
|
+
}
|
|
36
|
+
})();
|
package/promise.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
if ('Promise' in globalThis) {
|
|
2
|
+
if (! (Promise.prototype.finally instanceof Function)) {
|
|
3
|
+
Promise.prototype.finally = function(callback) {
|
|
4
|
+
return this.then(async val => {
|
|
5
|
+
await callback();
|
|
6
|
+
return val;
|
|
7
|
+
}, async val => {
|
|
8
|
+
await callback();
|
|
9
|
+
return val;
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (! (Promise.allSettled instanceof Function)) {
|
|
15
|
+
Promise.allSettled = function(promises) {
|
|
16
|
+
return Promise.all(Array.from(promises).map(function(call) {
|
|
17
|
+
return new Promise(function(resolve) {
|
|
18
|
+
if (! (call instanceof Promise)) {
|
|
19
|
+
call = Promise.resolve(call);
|
|
20
|
+
}
|
|
21
|
+
call.then(function(value) {
|
|
22
|
+
resolve({ status: 'fulfilled', value: value });
|
|
23
|
+
}).catch(function(reason) {
|
|
24
|
+
resolve({ status: 'rejected', reason: reason });
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}));
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (! (Promise.any instanceof Function)) {
|
|
32
|
+
Promise.any = (promises) => new Promise((resolve, reject) => {
|
|
33
|
+
let errors = [];
|
|
34
|
+
|
|
35
|
+
promises.forEach(promise => {
|
|
36
|
+
promise.then(resolve).catch(e => {
|
|
37
|
+
errors.push(e);
|
|
38
|
+
if (errors.length === promises.length) {
|
|
39
|
+
reject(new globalThis.AggregateError(errors, 'No Promise in Promise.any was resolved'));
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (! (Promise.race instanceof Function)) {
|
|
47
|
+
Promise.race = (promises) => new Promise((resolve, reject) => {
|
|
48
|
+
promises.forEach(promise => promise.then(resolve, reject));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (! (Promise.try instanceof Function)) {
|
|
53
|
+
/**
|
|
54
|
+
* @see https://github.com/tc39/proposal-promise-try
|
|
55
|
+
*/
|
|
56
|
+
Promise.try = callback => new Promise(resolve => resolve(callback()));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (! (Promise.withResolvers instanceof Function)) {
|
|
60
|
+
Promise.withResolvers = function() {
|
|
61
|
+
const def = {};
|
|
62
|
+
def.promise = new Promise((resolve, reject) => {
|
|
63
|
+
def.resolve = resolve;
|
|
64
|
+
def.reject = reject;
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
return def;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
package/sanitizer.js
ADDED
package/scheduler.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
if (! ('isSecureContext' in globalThis)) {
|
|
5
|
+
const hostnames = ['localhost', '127.0.0.1'];
|
|
6
|
+
const HTTPS = 'https:';
|
|
7
|
+
const protocols = [HTTPS, 'file:', 'wss:'];
|
|
8
|
+
const hasSecureScripts = (document = globalThis.document) => {
|
|
9
|
+
return [...document.scripts].every(({ src }) => {
|
|
10
|
+
if (src.length === 0) {
|
|
11
|
+
return true;
|
|
12
|
+
} else {
|
|
13
|
+
const { protocol, hostname } = new URL(src, document.baseURI);
|
|
14
|
+
return protocol === HTTPS || hostname === location.hostname;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
Object.defineProperty(globalThis, 'isSecureContext', {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
configurable: true,
|
|
22
|
+
get: function isSecureContext() {
|
|
23
|
+
if (protocols.includes(location.protocol) || hostnames.includes(location.hostname)) {
|
|
24
|
+
return hasSecureScripts();
|
|
25
|
+
} else {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
})();
|
package/set.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://github.com/tc39/proposal-set-methods
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
if (! (Set.prototype.intersection instanceof Function)) {
|
|
9
|
+
Set.prototype.intersection = function intersection(iterable) {
|
|
10
|
+
if (! (iterable instanceof Set)) {
|
|
11
|
+
iterable = new Set(iterable);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return new Set([...this].filter(item => iterable.has(item)));
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (! (Set.prototype.difference instanceof Function)) {
|
|
19
|
+
Set.prototype.difference = function difference(iterable) {
|
|
20
|
+
if (! (iterable instanceof Set)) {
|
|
21
|
+
iterable = new Set(iterable);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return new Set([...this].filter(item => ! iterable.has(item)));
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (! (Set.prototype.union instanceof Function)) {
|
|
29
|
+
Set.prototype.union = function union(iterable) {
|
|
30
|
+
return new Set([...this, ...iterable]);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (! (Set.prototype.isSubsetOf instanceof Function)) {
|
|
35
|
+
Set.prototype.isSubsetOf = function isSubsetOf(iterable) {
|
|
36
|
+
if (! (iterable instanceof Set)) {
|
|
37
|
+
iterable = new Set(iterable);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return [...this].every(item => iterable.has(item));
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (! (Set.prototype.isSupersetOf instanceof Function)) {
|
|
45
|
+
Set.prototype.isSupersetOf = function isSupersetOf(iterable) {
|
|
46
|
+
if (! (iterable instanceof Set)) {
|
|
47
|
+
iterable = new Set(iterable);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return iterable.isSubsetOf(this);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (! (Set.prototype.symmetricDifference instanceof Function)) {
|
|
55
|
+
Set.prototype.symmetricDifference = function symmetricDifference(iterable) {
|
|
56
|
+
if (! (iterable instanceof Set)) {
|
|
57
|
+
iterable = new Set(iterable);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return new Set([...this.difference(iterable), ...iterable.difference(this)]);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (! (Set.prototype.isDisjointFrom instanceof Function)) {
|
|
65
|
+
Set.prototype.isDisjointFrom = function isDisjointFrom(iterable) {
|
|
66
|
+
if (! (iterable instanceof Set)) {
|
|
67
|
+
iterable = new Set(iterable);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return new Set([...this, ...iterable]).size === this.size + iterable.size;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
})();
|
package/share.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
if (! (navigator.canShare instanceof Function)) {
|
|
5
|
+
navigator.canShare = function({ title, text, url, files } = {}) {
|
|
6
|
+
if (! (navigator.share instanceof Function)) {
|
|
7
|
+
return false;
|
|
8
|
+
} else if (Array.isArray(files) && files.length !== 0) {
|
|
9
|
+
return false;
|
|
10
|
+
} else if ([title, text, url].every(arg => typeof arg === 'undefined')) {
|
|
11
|
+
return true;
|
|
12
|
+
} else {
|
|
13
|
+
return [title, text, url].some(arg => typeof arg === 'string' && arg.length !== 0);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
})();
|
package/symbols.js
ADDED
package/textEncoder.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TextEncoder } from './assets/TextEncoder.js';
|
|
2
|
+
import { TextDecoder } from './assets/TextDecoder.js';
|
|
3
|
+
|
|
4
|
+
if (! ('TextEncoder' in globalThis)) {
|
|
5
|
+
globalThis.TextEncoder = TextEncoder;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (! ('TextDecoder' in globalThis)) {
|
|
9
|
+
globalThis.TextDecoder = TextDecoder;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (! (globalThis.TextEncoder.prototype.encodeInto instanceof Function)) {
|
|
13
|
+
globalThis.TextEncoder.prototype.encodeInto = function(...args) {
|
|
14
|
+
return TextEncoder.prototype.encodeInto.apply(this, args);
|
|
15
|
+
};
|
|
16
|
+
}
|
package/trustedTypes.js
ADDED
package/weakMap.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
if (! (WeakMap.prototype.emplace instanceof Function)) {
|
|
5
|
+
WeakMap.prototype.emplace = function emplace(key, { insert, update } = {}) {
|
|
6
|
+
const has = this.has(key);
|
|
7
|
+
|
|
8
|
+
if (has && update instanceof Function) {
|
|
9
|
+
const existing = this.get(key);
|
|
10
|
+
const value = update.call(this, existing, key, this);
|
|
11
|
+
|
|
12
|
+
if (value !== existing) {
|
|
13
|
+
this.set(key, existing);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return value;
|
|
17
|
+
} else if (has) {
|
|
18
|
+
return this.get(key);
|
|
19
|
+
} else if (insert instanceof Function) {
|
|
20
|
+
const value = insert.call(this, key, this);
|
|
21
|
+
this.set(key, value);
|
|
22
|
+
return value;
|
|
23
|
+
} else {
|
|
24
|
+
throw new Error('Key is not found and no `insert()` given');
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
})();
|
package/window.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
if ('screen' in globalThis && ! (globalThis.getScreenDetails instanceof Function)) {
|
|
5
|
+
class ScreenDetailed extends EventTarget {
|
|
6
|
+
get availHeight() {
|
|
7
|
+
return screen.availHeight;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
get availLeft() {
|
|
11
|
+
return screen.availLeft;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
get availTop() {
|
|
15
|
+
return screen.availTop;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
get availWidth() {
|
|
19
|
+
return screen.availWidth;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
get colorDepth() {
|
|
23
|
+
return screen.colorDepth;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get devicePixelRatio() {
|
|
27
|
+
return globalThis.devicePixelRatio || 1;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get height() {
|
|
31
|
+
return screen.height;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get isExtended() {
|
|
35
|
+
return screen.isExtended;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get isInternal() {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
get isPrimary() {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
get label() {
|
|
47
|
+
return 'Unknown';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
get orientation() {
|
|
51
|
+
return screen.orientation;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
get pixelDepth() {
|
|
55
|
+
return screen.pixelDepth;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
get top() {
|
|
59
|
+
return screen.top;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
get width() {
|
|
63
|
+
return screen.width;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
class ScreenDetails extends EventTarget {
|
|
68
|
+
get currentScreen() {
|
|
69
|
+
return new ScreenDetailed();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
get screens() {
|
|
73
|
+
return [this.currentScreen];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
Object.defineProperty(Screen.prototype, 'isExtended', {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
configurable: true,
|
|
80
|
+
get: () => false,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
globalThis.getScreenDetails = async () => new ScreenDetails();
|
|
84
|
+
}
|
|
85
|
+
})();
|