@shgysk8zer0/polyfills 0.0.5 → 0.0.6
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 +18 -5
- package/README.md +71 -27
- package/all.min.js +8 -8
- package/all.min.js.map +1 -1
- package/element.js +0 -1
- package/globalThis.js +8 -8
- package/package.json +5 -3
- package/rollup.config.js +2 -4
- /package/{dialog.js → legacy/dialog.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -6,17 +6,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## [v0.0.6] - 2023-05-15
|
|
10
10
|
|
|
11
11
|
### Added
|
|
12
|
-
-
|
|
12
|
+
- `main` & `module` to `package.json`
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
### Changed
|
|
15
|
+
- Update README (again)
|
|
16
|
+
- Update `rollup-plugin-terser` to `@rollup/plugin-terser`
|
|
17
|
+
- Fix order of releases in CHANGELOG
|
|
15
18
|
|
|
16
|
-
###
|
|
17
|
-
-
|
|
19
|
+
### Removed
|
|
20
|
+
- Remove polyfill for `<dialog>` from default bundle (moved to `legacy/`)
|
|
18
21
|
|
|
19
22
|
## [v0.0.5] - 2023-05-08
|
|
20
23
|
|
|
21
24
|
### Changed
|
|
22
25
|
- Update README with instructions
|
|
26
|
+
|
|
27
|
+
## [v0.0.4] - 2023-05-07
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
- Add missing `deprefixer.js` script
|
|
31
|
+
|
|
32
|
+
### [v0.0.3] - 2023-05-07
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
- Bundle `all.js` -> `all.min.js` on pack/pubilsh
|
package/README.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
# polyfills
|
|
2
|
-
|
|
1
|
+
# [@shgysk8zer0/polyfills](https://www.npmjs.com/package/@shgysk8zer0/rollup-import)
|
|
2
|
+
|
|
3
|
+
@shgysk8zer0/polyfills is a collection of JavaScript polyfills designed to provide
|
|
4
|
+
modern functionality in older browsers. This library provides a range of polyfills
|
|
5
|
+
for features including `AbortSignal`, `CookieStore`, `Sanitizer`, and many more.
|
|
3
6
|
|
|
4
7
|
[](https://github.com/shgysk8zer0/polyfills/actions/workflows/codeql-analysis.yml)
|
|
5
8
|

|
|
@@ -27,51 +30,92 @@ A set of JavaScript polyfills
|
|
|
27
30
|
- [Contributing](./.github/CONTRIBUTING.md)
|
|
28
31
|
<!-- - [Security Policy](./.github/SECURITY.md) -->
|
|
29
32
|
|
|
30
|
-
## Installation
|
|
31
|
-
This may be used via [unpkg.com](https://unpkg.com/browse/@shgysk8zer0/polyfills/),
|
|
32
|
-
as an [npm package](https://www.npmjs.com/package/@shgysk8zer0/polyfills), or
|
|
33
|
-
as a submodule.
|
|
33
|
+
## Installation
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
You can access @shgysk8zer0/polyfills in several ways:
|
|
36
36
|
|
|
37
|
-
###
|
|
37
|
+
### CDN
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
You can use a CDN to access the library. Add the following script tag to your
|
|
40
|
+
HTML file to load the latest version:
|
|
40
41
|
|
|
41
42
|
```html
|
|
42
|
-
<script src="https://unpkg.com/@shgysk8zer0/polyfills/all.min.js"
|
|
43
|
+
<script src="https://unpkg.com/@shgysk8zer0/polyfills/all.min.js"></script>
|
|
43
44
|
```
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
#### With version and SRI
|
|
46
47
|
|
|
47
48
|
```html
|
|
48
|
-
<script src="https://unpkg.com/@shgysk8zer0/polyfills@0.0.
|
|
49
|
+
<script src="https://unpkg.com/@shgysk8zer0/polyfills@0.0.6/all.min.js" referrerpolicy="no-referrer" crossorigin="anonymous" integrity="sha384-xoY6kDRPTvbDfGdGA3S6Ercudev5mWGBWZIErLB38f7TeN6hV7zof6WBpzMdx/z0" fetchpriority="high" defer=""></script>
|
|
49
50
|
```
|
|
50
51
|
|
|
51
|
-
###
|
|
52
|
+
### NPM
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
You can install the library as an NPM package and use it in your project. Use
|
|
55
|
+
the following command to install the library:
|
|
54
56
|
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
+
```bash
|
|
58
|
+
npm install @shgysk8zer0/polyfills
|
|
57
59
|
```
|
|
58
60
|
|
|
59
|
-
###
|
|
61
|
+
### Git Submodule
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
You can add the library as a Git submodule to your project. Use the following
|
|
64
|
+
command to add the library as a submodule:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
git submodule add https://github.com/shgysk8zer0/polyfills.git [:path/to/destination]
|
|
65
68
|
```
|
|
66
69
|
|
|
67
|
-
##
|
|
70
|
+
## Usage
|
|
68
71
|
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
To use the polyfills in your project, simply import them using ES6 modules:
|
|
73
|
+
|
|
74
|
+
```javascript
|
|
75
|
+
import '@shgysk8zer0/polyfills';
|
|
76
|
+
// Or
|
|
77
|
+
import 'https://unpkg.com/@shgysk8zer0/polyfills/all.js';
|
|
71
78
|
```
|
|
72
79
|
|
|
73
|
-
|
|
80
|
+
This will load all the polyfills in the library.
|
|
74
81
|
|
|
75
|
-
|
|
76
|
-
|
|
82
|
+
If you only need certain polyfills, you can import them individually:
|
|
83
|
+
|
|
84
|
+
```javascript
|
|
85
|
+
import '@shgysk8zer0/polyfills/sanitizer.js';
|
|
86
|
+
import '@shgysk8zer0/polyfills/trustedTypes.js';
|
|
87
|
+
import '@shgysk8zer0/polyfills/elementInternals.js';
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Import Map
|
|
91
|
+
|
|
92
|
+
You can avoid installing altogether while keeping the familiar syntax by using
|
|
93
|
+
an [import map](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap).
|
|
94
|
+
If you use Rollup, see [`@shgysk8zer0/rollup-import`](https://www.npmjs.com/package/@shgysk8zer0/rollup-import).
|
|
95
|
+
for more details.
|
|
96
|
+
|
|
97
|
+
```html
|
|
98
|
+
<script type="importmap">
|
|
99
|
+
{
|
|
100
|
+
"imports": {
|
|
101
|
+
"@shgysk8zer0/polyfills": "https://unpkg.com/@shgysk8zer0/polyfills@0.0.6/all.min.js",
|
|
102
|
+
"@shgysk8zer0/polyfills/": "https://unpkg.com/@shgysk8zer0/polyfills@0.0.6/",
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
</script>
|
|
77
106
|
```
|
|
107
|
+
|
|
108
|
+
## Contributing
|
|
109
|
+
|
|
110
|
+
If you would like to contribute to the library, please follow these steps:
|
|
111
|
+
|
|
112
|
+
1. Fork the repository.
|
|
113
|
+
2. Create a branch for your changes.
|
|
114
|
+
3. Make your changes.
|
|
115
|
+
4. Submit a pull request.
|
|
116
|
+
|
|
117
|
+
Please make sure that your changes are thoroughly tested and that they follow the same coding style as the rest of the library.
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
@shgysk8zer0/polyfills is licensed under the MIT license. See the [LICENSE](https://github.com/shgysk8zer0/polyfills/blob/master/LICENSE) file for more details.
|
package/all.min.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
!function(){"use strict";var e;!("crypto"in window)&&"msCrypto"in window&&(globalThis.crypto=globalThis.msCrypto),"Notification"in window||(globalThis.Notification=globalThis.notifications||globalThis.webkitNotifications||globalThis.oNotifications||globalThis.msNotifications||!1),"doNotTrack"in navigator||(navigator.doNotTrack=globalThis.doNotTrack||navigator.msDoNotTrack||"unspecified"),"indexedDB"in window||(globalThis.indexedDB=globalThis.indexedDB||globalThis.mozIndexedDB||globalThis.webkitIndexedDB||globalThis.msIndexedDB||!1),"hidden"in document||(document.hidden=document.webkitHidden||document.msHidden||document.mozHidden||!1),"visibilityState"in document||(document.visibilityState=document.webkitVisibilityState||document.msVisibilityState||document.mozVisibilityState||"visible"),"fullscreenElement"in document||(document.fullscreenElement=document.mozFullScreenElement||document.webkitFullscreenElement||!1),"requestAnimationFrame"in window||(globalThis.requestAnimationFrame=globalThis.mozRequestAnimationFrame||globalThis.webkitRequestAnimationFrame||globalThis.msRequestAnimationFrame||!1),"exitFullscreen"in Document.prototype||(Document.prototype.exitFullscreen=document.mozCancelFullScreen||document.webkitCancelFullScreen||document.msCancelFullScreen||!1),"requestFullscreen"in HTMLElement.prototype||(HTMLElement.prototype.requestFullscreen=HTMLElement.prototype.requestFullScreen||HTMLElement.prototype.mozRequestFullScreen||HTMLElement.prototype.webkitRequestFullScreen||!1),"fullscreen"in Document.prototype||Object.defineProperty(Document.prototype,"fullscreen",{get:()=>document.fullscreenElement instanceof Element}),"Symbol"in globalThis&&(void 0===Symbol.toStringTag&&(Symbol.toStringTag=Symbol("Symbol.toStringTag")),void 0===Symbol.iterator&&(Symbol.iterator=Symbol("Symbol.iterator"))),function(){const e=[Array,String,globalThis.Int8Array,globalThis.Uint8Array,globalThis.Uint8ClampedArray,globalThis.Int16Array,globalThis.Uint16Array,globalThis.Int32Array,globalThis.Uint32Array,globalThis.Float32Array,globalThis.Float64Array,globalThis.BigInt64Array,globalThis.BigUint64Array];if(Array.prototype.flat instanceof Function||(Array.prototype.flat=function(e=1){const t=[];e=Math.min(Number.MAX_SAFE_INTEGER,Math.max(0,e));const n=(e,o)=>{Array.isArray(e)&&o>=0?e.forEach((e=>n(e,o-1))):t.push(e)};return n(this,Number.isNaN(e)?0:e),t}),Array.prototype.flatMap instanceof Function||(Array.prototype.flatMap=function(e,t){return this.map(e,t).flat(1)}),Array.prototype.findLast instanceof Function||(Array.prototype.findLast=function(e,t){let n;return this.forEach(((o,r,i)=>{e.call(t,o,r,i)&&(n=o)}),t),n}),Array.prototype.findLastIndex instanceof Function||(Array.prototype.findLastIndex=function(e,t){let n=-1;return this.forEach(((o,r,i)=>{e.call(t,o,r,i)&&(n=r)}),t),n}),!(Array.prototype.at instanceof Function)){const t=function(e){if((e=Math.trunc(e)||0)<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]};for(const n of e)void 0!==n&&Object.defineProperty(n.prototype,"at",{value:t,writable:!0,enumerable:!1,configurable:!0})}Array.prototype.group instanceof Function||(Array.prototype.group=function(e,t=globalThis){return this.reduce(((n,o,r,i)=>{const a=e.call(t,o,r,i);return n.hasOwnProperty(a)?n[a].push(o):n[a]=[o],n}),{})}),Array.prototype.groupBy=function(...e){return console.warn("`goupBy` is deprecated. Please use `group` instead."),this.group(...e)},!(Array.prototype.groupToMap instanceof Function)&&Map.prototype.emplace instanceof Function&&(Array.prototype.groupToMap=function(e,t=globalThis){return this.reduce(((n,o,r,i)=>(n.emplace(e.call(t,o,r,i),{insert:()=>[o],update:e=>(e.push(o),e)}),n)),new Map)}),Map.prototype.emplace instanceof Function&&(Array.prototype.groupByToMap=function(...e){return console.warn("`goupByToMap` is deprecated. Please use `groupToMap` instead."),this.groupToMap(...e)}),Array.fromAsync instanceof Function||(Array.fromAsync=async function(e,t,n=globalThis){let o=[];for await(const t of e)o.push(await t);return Array.from(o,t,n)}),Array.prototype.equals instanceof Function||(Array.prototype.equals=function(e){return this===e||!!Array.isArray(e)&&(this.length===e.length&&this.every(((t,n)=>{const o=e[n];return Array.isArray(t)?Array.isArray(o)&&t.equals(o):Object.is(t,o)})))}),Array.prototype.uniqueBy instanceof Function||(Array.prototype.uniqueBy=function(e){if(void 0===e)return[...new Set(this)];if("string"==typeof e){const t=[];return this.filter((n=>{const o=n[e];return!t.includes(o)&&(t.push(o),!0)}))}if(e instanceof Function){const t=[];return this.filter(((...n)=>{try{const o=e.apply(this,n);return"string"==typeof o&&(!t.includes(o)&&(t.push(o),!0))}catch(e){return!1}}))}throw new TypeError("Not a valid argument for uniqueBy")}),Array.prototype.toReversed instanceof Function||(Array.prototype.toReversed=function(){return[...this].reverse()}),Array.prototype.toSorted instanceof Function||(Array.prototype.toSorted=function(e){return[...this].sort(e)}),Array.prototype.toSpliced instanceof Function||(Array.prototype.toSpliced=function(e,t,...n){const o=[...this];return o.splice(e,t,...n),o}),Array.prototype.with instanceof Function||(Array.prototype.with=function(e,t){const n=[...this];return n[e]=t,n})}(),function(){"undefined"==typeof globalThis&&("undefined"!=typeof self?Object.defineProperty(self,"globalThis",{enumerable:!1,writable:!0,configurable:!0,value:self}):"undefined"!=typeof window?Object.defineProperty(Window.prototype,"globalThis",{enumerable:!1,writable:!0,configurable:!0,value:window}):"undefined"!=typeof global?Object.defineProperty(global,"globalThis",{enumerable:!1,writable:!0,configurable:!0,value:global}):Object.defineProperty(this,"globalThis",{enumerable:!1,writable:!0,configurable:!0,value:this}))}(),function(){if(!(Function.prototype.once instanceof Function)){const e=new WeakMap;Function.prototype.once=function(t){const n=this;return function(...o){if(e.has(n))return e.get(n);if("AsyncFunction"===n.constructor.name){const r=n.apply(t||n,o).catch((t=>{throw e.delete(n),t}));return e.set(n,r),r}if(n instanceof Function){const r=n.apply(t||n,o);return e.set(n,r),r}}}}}(),Number.range instanceof Function||(Number.range=function(e,t,n=1){return console.warn("`Number.range()` is deprecated. Use `Iterator.range()` instead."),globalThis.Iterator.range(e,t,{step:n})}),function(){"Iterator"in globalThis||(globalThis.Iterator={prototype:Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))});const e=globalThis.Iterator;e.range instanceof Function||(e.range=function*(t,n,o){if("number"==typeof o||"bigint"==typeof o)for(const r of e.range(t,n,{step:o}))yield r;else if("object"!=typeof o||Object.is(o,null))for(const o of e.range(t,n,{}))yield o;else{const{step:e=("number"==typeof t?t<n?1:-1:t<n?1n:-1n),inclusive:r=!1}=o;if("number"!=typeof t&&"bigint"!=typeof t)throw new TypeError("Start must be a number");if(Number.isNaN(t))throw new RangeError("Invalid start");if("number"!=typeof n&&"bigint"!=typeof n)throw new TypeError("End must be a number");if(Number.isNaN(n))throw new RangeError("Invalid end");if("number"!=typeof e&&"bigint"!=typeof e)throw new TypeError("Step must be a number");if(Number.isNaN(e))throw new RangeError("Invalid step");if(0===e)throw new RangeError("Step must not be 0");if(e<0&&t<n||e>0&&t>n)return;if(r)if(e>0)for(let o=t;o<=n;o+=e)yield o;else for(let o=t;o>=n;o+=e)yield o;else if(e>0)for(let o=t;o<n;o+=e)yield o;else for(let o=t;o>n;o+=e)yield o}}),e.prototype[Symbol.toStringTag]||(e.prototype[Symbol.toStringTag]="Iterator"),e.prototype.take instanceof Function||(e.prototype.take=function*(e){let t=0;for(const n of this){if(++t>e)break;yield n}}),e.prototype.drop instanceof Function||(e.prototype.drop=function*(e){let t=0;for(const n of this)t++>=e&&(yield n)}),e.prototype.toArray instanceof Function||(e.prototype.toArray=function(){return Array.from(this)}),e.prototype.forEach instanceof Function||(e.prototype.forEach=function(e){for(const t of this)e(t)}),e.prototype.map instanceof Function||(e.prototype.map=function*(e){for(const t of this)yield e(t)}),e.prototype.reduce instanceof Function||(e.prototype.reduce=function(e,t){let n=void 0===t?this.next().value:t;for(const t of this)n=e(n,t);return n}),e.prototype.filter instanceof Function||(e.prototype.filter=function*(e){for(const t of this)e(t)&&(yield t)}),e.prototype.some instanceof Function||(e.prototype.some=function(e){let t=!1;for(const n of this)if(e(n)){t=!0;break}return t}),e.prototype.every instanceof Function||(e.prototype.every=function(e){let t=!0;for(const n of this)if(!e(n)){t=!1;break}return t}),e.prototype.find instanceof Function||(e.prototype.find=function(e){for(const t of this)if(e(t))return t}),e.prototype.indexed instanceof Function||(e.prototype.indexed=function*(){let e=0;for(const t of this)yield[e++,t]})}(),Number.hasOwnProperty("isSafeInteger")||(Number.MAX_SAFE_INTEGER=2**53-1,Number.MIN_SAFE_INTEGER=-Number.MAX_SAFE_INTEGER,Number.isSafeInteger=e=>e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER),Number.hasOwnProperty("EPSILON")||(Number.EPSILON=2**-52),Math.hasOwnProperty("sign")||(Math.sign=e=>(e>0)-(e<0)||+e),Math.hasOwnProperty("trunc")||(Math.trunc=e=>{const t=e-e%1;return 0===t&&(e<0||0===e&&1/e!=1/0)?-0:t}),Math.hasOwnProperty("expm1")||(Math.expm1=e=>Math.exp(e)-1),Math.hasOwnProperty("hypot")||(Math.hypot=(...e)=>Math.sqrt(e.reduce(((e,t)=>e+t**2),0))),Math.hasOwnProperty("cbrt")||(Math.cbrt=e=>e**(1/3)),Math.hasOwnProperty("log10")||(Math.log10=e=>Math.log(e)*Math.LOG10E),Math.hasOwnProperty("log2")||(Math.log2=e=>Math.log(e)*Math.LOG2E),Math.hasOwnProperty("log1p")||(Math.log1p=e=>Math.log(1+e)),Math.hasOwnProperty("fround")||(Math.fround=(e=new Float32Array(1),function(t){return e[0]=t,e[0]})),Math.clamp instanceof Function||(Math.clamp=function(e,t,n){return Math.min(Math.max(e,t),n)}),Math.constrain instanceof Function||(Math.constrain=Math.clamp),function(){if(!("isSecureContext"in globalThis)){const e=["localhost","127.0.0.1"],t="https:",n=[t,"file:","wss:"],o=(e=globalThis.document)=>[...e.scripts].every((({src:n})=>{if(0===n.length)return!0;{const{protocol:o,hostname:r}=new URL(n,e.baseURI);return o===t||r===location.hostname}}));Object.defineProperty(globalThis,"isSecureContext",{enumerable:!0,configurable:!0,get:function(){return!(!n.includes(location.protocol)&&!e.includes(location.hostname))&&o()}})}}();const t=new WeakMap;function n(e){return e instanceof Function&&"AsyncFunction"===e.constructor.name}function o(e){return"object"==typeof e&&!Object.is(e,null)&&!Array.isArray(e)}function r(e){switch(typeof e){case"undefined":return"Undefined";case"function":return"prototype"in e?r(e.prototype):"constructor"in e?e.constructor.name:"Function";case"object":return Object.is(e,null)?"Null":"constructor"in e?e.constructor.name:Symbol.toStringTag in e?e[Symbol.toStringTag]:"prototype"in e?r(e.prototype):(console.log(e),"Unknown Object");case"string":return"String";case"number":return Number.isNaN(e)?"NaN":"Number";case"bigint":return"BigInt";case"boolean":return"Boolean";case"symbol":return"Symbol";default:return"Unknown"}}function i(e,o){return e.once instanceof Function?e.once(o):function(...r){if(t.has(e))return t.get(e);if(n(e)){const n=e.apply(o||this,r).catch((n=>{throw t.delete(e),n}));return t.set(e,n),n}if(e instanceof Function){const n=e.apply(o||this,r);return t.set(e,n),n}}}
|
|
1
|
+
!function(){"use strict";var e;!("crypto"in window)&&"msCrypto"in window&&(globalThis.crypto=globalThis.msCrypto),"Notification"in window||(globalThis.Notification=globalThis.notifications||globalThis.webkitNotifications||globalThis.oNotifications||globalThis.msNotifications||!1),"doNotTrack"in navigator||(navigator.doNotTrack=globalThis.doNotTrack||navigator.msDoNotTrack||"unspecified"),"indexedDB"in window||(globalThis.indexedDB=globalThis.indexedDB||globalThis.mozIndexedDB||globalThis.webkitIndexedDB||globalThis.msIndexedDB||!1),"hidden"in document||(document.hidden=document.webkitHidden||document.msHidden||document.mozHidden||!1),"visibilityState"in document||(document.visibilityState=document.webkitVisibilityState||document.msVisibilityState||document.mozVisibilityState||"visible"),"fullscreenElement"in document||(document.fullscreenElement=document.mozFullScreenElement||document.webkitFullscreenElement||!1),"requestAnimationFrame"in window||(globalThis.requestAnimationFrame=globalThis.mozRequestAnimationFrame||globalThis.webkitRequestAnimationFrame||globalThis.msRequestAnimationFrame||!1),"exitFullscreen"in Document.prototype||(Document.prototype.exitFullscreen=document.mozCancelFullScreen||document.webkitCancelFullScreen||document.msCancelFullScreen||!1),"requestFullscreen"in HTMLElement.prototype||(HTMLElement.prototype.requestFullscreen=HTMLElement.prototype.requestFullScreen||HTMLElement.prototype.mozRequestFullScreen||HTMLElement.prototype.webkitRequestFullScreen||!1),"fullscreen"in Document.prototype||Object.defineProperty(Document.prototype,"fullscreen",{get:()=>document.fullscreenElement instanceof Element}),"Symbol"in globalThis&&(void 0===Symbol.toStringTag&&(Symbol.toStringTag=Symbol("Symbol.toStringTag")),void 0===Symbol.iterator&&(Symbol.iterator=Symbol("Symbol.iterator"))),function(){const e=[Array,String,globalThis.Int8Array,globalThis.Uint8Array,globalThis.Uint8ClampedArray,globalThis.Int16Array,globalThis.Uint16Array,globalThis.Int32Array,globalThis.Uint32Array,globalThis.Float32Array,globalThis.Float64Array,globalThis.BigInt64Array,globalThis.BigUint64Array];if(Array.prototype.flat instanceof Function||(Array.prototype.flat=function(e=1){const t=[];e=Math.min(Number.MAX_SAFE_INTEGER,Math.max(0,e));const n=(e,o)=>{Array.isArray(e)&&o>=0?e.forEach((e=>n(e,o-1))):t.push(e)};return n(this,Number.isNaN(e)?0:e),t}),Array.prototype.flatMap instanceof Function||(Array.prototype.flatMap=function(e,t){return this.map(e,t).flat(1)}),Array.prototype.findLast instanceof Function||(Array.prototype.findLast=function(e,t){let n;return this.forEach(((o,r,i)=>{e.call(t,o,r,i)&&(n=o)}),t),n}),Array.prototype.findLastIndex instanceof Function||(Array.prototype.findLastIndex=function(e,t){let n=-1;return this.forEach(((o,r,i)=>{e.call(t,o,r,i)&&(n=r)}),t),n}),!(Array.prototype.at instanceof Function)){const t=function(e){if((e=Math.trunc(e)||0)<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]};for(const n of e)void 0!==n&&Object.defineProperty(n.prototype,"at",{value:t,writable:!0,enumerable:!1,configurable:!0})}Array.prototype.group instanceof Function||(Array.prototype.group=function(e,t=globalThis){return this.reduce(((n,o,r,i)=>{const a=e.call(t,o,r,i);return n.hasOwnProperty(a)?n[a].push(o):n[a]=[o],n}),{})}),Array.prototype.groupBy=function(...e){return console.warn("`goupBy` is deprecated. Please use `group` instead."),this.group(...e)},!(Array.prototype.groupToMap instanceof Function)&&Map.prototype.emplace instanceof Function&&(Array.prototype.groupToMap=function(e,t=globalThis){return this.reduce(((n,o,r,i)=>(n.emplace(e.call(t,o,r,i),{insert:()=>[o],update:e=>(e.push(o),e)}),n)),new Map)}),Map.prototype.emplace instanceof Function&&(Array.prototype.groupByToMap=function(...e){return console.warn("`goupByToMap` is deprecated. Please use `groupToMap` instead."),this.groupToMap(...e)}),Array.fromAsync instanceof Function||(Array.fromAsync=async function(e,t,n=globalThis){let o=[];for await(const t of e)o.push(await t);return Array.from(o,t,n)}),Array.prototype.equals instanceof Function||(Array.prototype.equals=function(e){return this===e||!!Array.isArray(e)&&(this.length===e.length&&this.every(((t,n)=>{const o=e[n];return Array.isArray(t)?Array.isArray(o)&&t.equals(o):Object.is(t,o)})))}),Array.prototype.uniqueBy instanceof Function||(Array.prototype.uniqueBy=function(e){if(void 0===e)return[...new Set(this)];if("string"==typeof e){const t=[];return this.filter((n=>{const o=n[e];return!t.includes(o)&&(t.push(o),!0)}))}if(e instanceof Function){const t=[];return this.filter(((...n)=>{try{const o=e.apply(this,n);return"string"==typeof o&&(!t.includes(o)&&(t.push(o),!0))}catch(e){return!1}}))}throw new TypeError("Not a valid argument for uniqueBy")}),Array.prototype.toReversed instanceof Function||(Array.prototype.toReversed=function(){return[...this].reverse()}),Array.prototype.toSorted instanceof Function||(Array.prototype.toSorted=function(e){return[...this].sort(e)}),Array.prototype.toSpliced instanceof Function||(Array.prototype.toSpliced=function(e,t,...n){const o=[...this];return o.splice(e,t,...n),o}),Array.prototype.with instanceof Function||(Array.prototype.with=function(e,t){const n=[...this];return n[e]=t,n})}(),function(){"undefined"==typeof globalThis&&("undefined"!=typeof window?Object.defineProperty(Window.prototype,"globalThis",{enumerable:!1,writable:!0,configurable:!0,value:window}):"undefined"!=typeof global?Object.defineProperty(global,"globalThis",{enumerable:!1,writable:!0,configurable:!0,value:global}):"undefined"!=typeof self?Object.defineProperty(self,"globalThis",{enumerable:!1,writable:!0,configurable:!0,value:self}):Object.defineProperty(this,"globalThis",{enumerable:!1,writable:!0,configurable:!0,value:this}))}(),function(){if(!(Function.prototype.once instanceof Function)){const e=new WeakMap;Function.prototype.once=function(t){const n=this;return function(...o){if(e.has(n))return e.get(n);if("AsyncFunction"===n.constructor.name){const r=n.apply(t||n,o).catch((t=>{throw e.delete(n),t}));return e.set(n,r),r}if(n instanceof Function){const r=n.apply(t||n,o);return e.set(n,r),r}}}}}(),Number.range instanceof Function||(Number.range=function(e,t,n=1){return console.warn("`Number.range()` is deprecated. Use `Iterator.range()` instead."),globalThis.Iterator.range(e,t,{step:n})}),function(){"Iterator"in globalThis||(globalThis.Iterator={prototype:Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))});const e=globalThis.Iterator;e.range instanceof Function||(e.range=function*(t,n,o){if("number"==typeof o||"bigint"==typeof o)for(const r of e.range(t,n,{step:o}))yield r;else if("object"!=typeof o||Object.is(o,null))for(const o of e.range(t,n,{}))yield o;else{const{step:e=("number"==typeof t?t<n?1:-1:t<n?1n:-1n),inclusive:r=!1}=o;if("number"!=typeof t&&"bigint"!=typeof t)throw new TypeError("Start must be a number");if(Number.isNaN(t))throw new RangeError("Invalid start");if("number"!=typeof n&&"bigint"!=typeof n)throw new TypeError("End must be a number");if(Number.isNaN(n))throw new RangeError("Invalid end");if("number"!=typeof e&&"bigint"!=typeof e)throw new TypeError("Step must be a number");if(Number.isNaN(e))throw new RangeError("Invalid step");if(0===e)throw new RangeError("Step must not be 0");if(e<0&&t<n||e>0&&t>n)return;if(r)if(e>0)for(let o=t;o<=n;o+=e)yield o;else for(let o=t;o>=n;o+=e)yield o;else if(e>0)for(let o=t;o<n;o+=e)yield o;else for(let o=t;o>n;o+=e)yield o}}),e.prototype[Symbol.toStringTag]||(e.prototype[Symbol.toStringTag]="Iterator"),e.prototype.take instanceof Function||(e.prototype.take=function*(e){let t=0;for(const n of this){if(++t>e)break;yield n}}),e.prototype.drop instanceof Function||(e.prototype.drop=function*(e){let t=0;for(const n of this)t++>=e&&(yield n)}),e.prototype.toArray instanceof Function||(e.prototype.toArray=function(){return Array.from(this)}),e.prototype.forEach instanceof Function||(e.prototype.forEach=function(e){for(const t of this)e(t)}),e.prototype.map instanceof Function||(e.prototype.map=function*(e){for(const t of this)yield e(t)}),e.prototype.reduce instanceof Function||(e.prototype.reduce=function(e,t){let n=void 0===t?this.next().value:t;for(const t of this)n=e(n,t);return n}),e.prototype.filter instanceof Function||(e.prototype.filter=function*(e){for(const t of this)e(t)&&(yield t)}),e.prototype.some instanceof Function||(e.prototype.some=function(e){let t=!1;for(const n of this)if(e(n)){t=!0;break}return t}),e.prototype.every instanceof Function||(e.prototype.every=function(e){let t=!0;for(const n of this)if(!e(n)){t=!1;break}return t}),e.prototype.find instanceof Function||(e.prototype.find=function(e){for(const t of this)if(e(t))return t}),e.prototype.indexed instanceof Function||(e.prototype.indexed=function*(){let e=0;for(const t of this)yield[e++,t]})}(),Number.hasOwnProperty("isSafeInteger")||(Number.MAX_SAFE_INTEGER=2**53-1,Number.MIN_SAFE_INTEGER=-Number.MAX_SAFE_INTEGER,Number.isSafeInteger=e=>e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER),Number.hasOwnProperty("EPSILON")||(Number.EPSILON=2**-52),Math.hasOwnProperty("sign")||(Math.sign=e=>(e>0)-(e<0)||+e),Math.hasOwnProperty("trunc")||(Math.trunc=e=>{const t=e-e%1;return 0===t&&(e<0||0===e&&1/e!=1/0)?-0:t}),Math.hasOwnProperty("expm1")||(Math.expm1=e=>Math.exp(e)-1),Math.hasOwnProperty("hypot")||(Math.hypot=(...e)=>Math.sqrt(e.reduce(((e,t)=>e+t**2),0))),Math.hasOwnProperty("cbrt")||(Math.cbrt=e=>e**(1/3)),Math.hasOwnProperty("log10")||(Math.log10=e=>Math.log(e)*Math.LOG10E),Math.hasOwnProperty("log2")||(Math.log2=e=>Math.log(e)*Math.LOG2E),Math.hasOwnProperty("log1p")||(Math.log1p=e=>Math.log(1+e)),Math.hasOwnProperty("fround")||(Math.fround=(e=new Float32Array(1),function(t){return e[0]=t,e[0]})),Math.clamp instanceof Function||(Math.clamp=function(e,t,n){return Math.min(Math.max(e,t),n)}),Math.constrain instanceof Function||(Math.constrain=Math.clamp),function(){if(!("isSecureContext"in globalThis)){const e=["localhost","127.0.0.1"],t="https:",n=[t,"file:","wss:"],o=(e=globalThis.document)=>[...e.scripts].every((({src:n})=>{if(0===n.length)return!0;{const{protocol:o,hostname:r}=new URL(n,e.baseURI);return o===t||r===location.hostname}}));Object.defineProperty(globalThis,"isSecureContext",{enumerable:!0,configurable:!0,get:function(){return!(!n.includes(location.protocol)&&!e.includes(location.hostname))&&o()}})}}();const t=new WeakMap;function n(e){return e instanceof Function&&"AsyncFunction"===e.constructor.name}function o(e){return"object"==typeof e&&!Object.is(e,null)&&!Array.isArray(e)}function r(e){switch(typeof e){case"undefined":return"Undefined";case"function":return"prototype"in e?r(e.prototype):"constructor"in e?e.constructor.name:"Function";case"object":return Object.is(e,null)?"Null":"constructor"in e?e.constructor.name:Symbol.toStringTag in e?e[Symbol.toStringTag]:"prototype"in e?r(e.prototype):(console.log(e),"Unknown Object");case"string":return"String";case"number":return Number.isNaN(e)?"NaN":"Number";case"bigint":return"BigInt";case"boolean":return"Boolean";case"symbol":return"Symbol";default:return"Unknown"}}function i(e,o){return e.once instanceof Function?e.once(o):function(...r){if(t.has(e))return t.get(e);if(n(e)){const n=e.apply(o||this,r).catch((n=>{throw t.delete(e),n}));return t.set(e,n),n}if(e instanceof Function){const n=e.apply(o||this,r);return t.set(e,n),n}}}
|
|
2
2
|
/**
|
|
3
3
|
* @copyright 2023 Chris Zuber <admin@kernvalley.us>
|
|
4
4
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Lock
|
|
5
5
|
*/const a=new WeakMap;class s{constructor(e,t="exclusive"){if(!["exclusive","shared"].includes(t))throw new TypeError(`'${t}' (value of 'mode' member of LockOptions) is not a valid value for enumeration LockMode.`);if("string"!=typeof e&&(e=e.toString()),e.startsWith("-"))throw new DOMException("Names starting with `-` are reserved");a.set(this,{name:e,mode:t})}get name(){return a.get(this).name}get mode(){return a.get(this).mode}}
|
|
6
6
|
/**
|
|
7
7
|
* @copyright 2023 Chris Zuber <admin@kernvalley.us>
|
|
8
|
-
*/const l=new Map,c=Symbol("lock-key"),u="locks"in navigator&&navigator.locks.request instanceof Function;const p=async function(){return await new Promise((e=>{"locks"in navigator&&navigator.locks.request instanceof Function?navigator.locks.query().then((()=>e(!0))).catch((()=>e(!1))):e(!1)}))}();async function d(e,t=null){return new Promise(((o,r)=>{var i;n(i=e)||i instanceof Promise?e.call(globalThis,t).then(o,r):queueMicrotask((()=>{try{const n=e.call(globalThis,t);o(n)}catch(e){r(e)}}))}))}async function h(e){l.has(e)&&await l.get(e).promise.catch(console.error)}function f(e,t,n){const{resolve:o,reject:r,promise:i}=function(){if(Promise.withResolvers instanceof Function)return Promise.withResolvers();{const e={};return e.promise=new Promise(((t,n)=>{e.resolve=t,e.reject=n})),e}}(),a=new AbortController,c=new s(e,t),u=function({name:e,mode:t}){switch(t){case"exclusive":return y().some((t=>t.name===e));case"shared":return y().some((t=>t.name===e&&"exclusive"===t.mode))}}(c);return l.set(c,{resolve:o,reject:r,promise:i,callback:n,pending:u,controller:a}),c}function m(e){return e instanceof s&&l.has(e)&&l.get(e).pending}function y(e){return"string"==typeof e?[...l.keys()].filter((t=>t.name===e)):[...l.keys()]}function g(e){return y(e).filter((e=>!m(e)))}function b(e){return y(e).filter((e=>m(e)))}async function w(e){switch(e.mode){case"exclusive":await Promise.allSettled(y().filter((t=>t.name===e.name&&t!==e)).map(h));break;case"shared":await Promise.allSettled(y().filter((t=>t.name===e.name&&"exclusive"===t.mode&&t!==e)).map(h))}}function T(e){if(l.has(e))return l.get(e).controller.signal}async function v(e){if(l.has(e)){const{resolve:t,reject:n,promise:o,callback:r,pending:i,controller:a}=l.get(e);return i&&function(e,t=!0){l.has(e)&&l.set(e,{...l.get(e),pending:t})}(e,!1),d(r,e).then(t,n).finally((()=>{l.delete(e),requestIdleCallback((()=>a.abort()))})),o}}class E{constructor(e){if(e!==c)throw new TypeError("Invalid constructor")}static async request(e,...t){let n,o={};t[0]instanceof Function?n=t[0]:t[1]instanceof Function&&([o,n]=t),"string"!=typeof e&&(e=e.toString());const{mode:r="exclusive",ifAvailable:i=!1,steal:a=!1,signal:s}=o;if(a&&i)throw new DOMException("LockManager.request: `steal` and `ifAvailable` cannot be used together");if(e.startsWith("-"))throw new DOMException("LockManager.request: Names starting with `-` are reserved");if(!["exclusive","shared"].includes(r))throw new TypeError(`LockManager.request: '${r}' (value of 'mode' member of LockOptions) is not a valid value for enumeration LockMode.`);if(s instanceof AbortSignal&&s.aborted)throw s.reason;if("shared"===r&&a)throw new DOMException("LockManager.request: `steal` is only supported for exclusive lock requests");const c=g(e),u=b(e),p=[...c,...u].some((t=>t.name===e));a&&p&&function(e){[...l.entries()].filter((([t])=>t.name===e)).forEach((([e,{reject:t,controller:n}])=>{requestIdleCallback((()=>{n.abort(),l.delete(e)})),t(new DOMException("The lock request is aborted"))}))}(e);const h=f(e,r,n);switch(s instanceof AbortSignal&&s.addEventListener("abort",(()=>{if(l.has(h)){const{reject:e,controller:t}=l.get(h);l.delete(h),e(new DOMException("The lock request is aborted")),t.abort()}}),{once:!0,signal:T(h)}),r){case"exclusive":if(!i||0===c.length&&0===u.length)return await w(h),await v(h);{const e=l.get(h).controller;return l.delete(h),await d(n,null).then((t=>(requestIdleCallback((()=>e.abort())),t)))}case"shared":if(i){if([...c,...u].some((e=>"exclusive"===e.mode))){const e=l.get(h).controller;return l.delete(h),await d(n,null).then((t=>(requestIdleCallback((()=>e.abort())),t)))}return await w(h),await v(h)}return await w(h),await v(h);default:throw new TypeError(`LockManager.request: '${r}' (value of 'mode' member of LockOptions) is not a valid value for enumeration LockMode.`)}}static async query(){return{held:g().map((({name:e,mode:t})=>({name:e,mode:t,clientId:null}))),pending:b().map((({name:e,mode:t})=>({name:e,mode:t,clientId:null})))}}}function S(e,t="error"){if(e instanceof Error){const{message:n,name:o,fileName:r,lineNumber:i,columnNumber:a}=e;return new ErrorEvent(t,{error:e,message:`${o}: ${n}`,filename:r,lineno:i,colno:a})}throw new TypeError("`errorToEvent()` only accepts Errors")}let M=!1;new Promise((async e=>{if(u)if(await p)e(!1);else try{navigator.locks.request=E.request,navigator.locks.query=E.query,M=!0,e(!0)}catch(t){globalThis.dispatchEvent(S(t)),e(!1)}else try{navigator.locks=E,M=!0,e(!0)}catch(t){globalThis.dispatchEvent(S(t)),e(!1)}})),navigator.canShare instanceof Function||(navigator.canShare=function({title:e,text:t,url:n,files:o}={}){return navigator.share instanceof Function&&(!Array.isArray(o)||0===o.length)&&(!![e,t,n].every((e=>void 0===e))||[e,t,n].some((e=>"string"==typeof e&&0!==e.length)))}),navigator.setAppBadge instanceof Function||(navigator.setAppBadge=async e=>{if(!Number.isInteger(e))throw new TypeError("Failed to execute 'setAppBadge' on 'Navigator': Value is not of type 'unsigned long long'");if(e<0)throw new TypeError("Failed to execute 'setAppBadge' on 'Navigator': Value is outside the 'unsigned long long' value range.");0===e?document.title.startsWith("(")&&(document.title=document.title.replace(/^\((\d{1,2}\+?)\)\s/,"")):e<100?(await navigator.clearAppBadge(),document.title=`(${e}) ${document.title}`):(await navigator.clearAppBadge(),document.title=`(99+) ${document.title}`)}),navigator.clearAppBadge instanceof Function||(navigator.clearAppBadge=()=>navigator.setAppBadge(0)),Navigator.prototype.hasOwnProperty("pdfViewerEnabled")||Object.defineProperty(navigator,"pdfViewerEnabled",{enumerable:!0,configurable:!1,writable:!1,value:!1}),Navigator.prototype.getInstalledRelatedApps instanceof Function||(Navigator.prototype.getInstalledRelatedApps=async()=>[]),Navigator.prototype.getGamepads instanceof Function||(Navigator.prototype.getGamepads=()=>[]),"hardwareConcurrency"in Navigator.prototype||Object.defineProperty(Navigator.prototype,"hardwareConcurrency",{get:()=>1}),"connection"in Navigator.prototype?"type"in navigator.connection||(navigator.connection.type="unknown"):Object.defineProperty(Navigator.prototype,"connection",{get:()=>Object.create(EventTarget.prototype,{type:{value:"unknown"},effectiveType:{value:"4g"},rtt:{value:NaN},downlink:{value:NaN},downlinkMax:{value:1/0},saveData:{value:!1},onchange:{value:null,writable:!0},ontypechange:{value:null,writable:!0}})}),"doNotTrack"in Navigator.prototype||Object.defineProperty(Navigator.prototype,"doNotTrack",{get:()=>"unspecified"}),"globalPrivacyControl"in Navigator.prototype||Object.defineProperty(Navigator.prototype,"globalPrivacyControl",{get:()=>!1}),function(){if(!(globalThis.requestIdleCallback instanceof Function)){const e=e=>Number.isSafeInteger(e)&&e>0;globalThis.requestIdleCallback=function(t,{timeout:n}={}){const o=performance.now(),r=()=>e(n)?Math.max(0,n-(performance.now()-o)):Math.max(0,600-(performance.now()-o));return setTimeout((()=>t({didTimeout:!!e(n)&&0===r(),timeRemaining:r})),1)}}globalThis.cancelIdleCallback instanceof Function||(globalThis.cancelIdleCallback=e=>clearTimeout(e)),globalThis.requestAnimationFrame instanceof Function||(globalThis.requestAnimationFrame=e=>setTimeout((()=>e(performance.now())),1e3/60)),globalThis.cancelAnimationFrame instanceof Function||(globalThis.cancelAnimationFrame=e=>clearTimeout(e)),globalThis.queueMicrotask instanceof Function||(globalThis.queueMicrotask=e=>Promise.resolve().then(e).catch((e=>setTimeout((()=>{throw e})))))}(),function(){if(!("AbortSignal"in globalThis)){const e={signal:Symbol("signal"),aborted:Symbol("aborted"),reason:Symbol("reason"),onabort:Symbol("onabort")};globalThis.AbortError=class extends Error{},globalThis.AbortSignal=class t extends EventTarget{constructor(){super(),Object.defineProperties(this,{[e.aborted]:{enumerable:!1,writable:!0,configurable:!1,value:!1},[e.reason]:{enumerable:!1,writable:!0,configurable:!1,value:void 0},[e.onabort]:{enumerable:!1,writable:!0,configurable:!1,value:null}}),this.addEventListener("abort",(e=>{this.onabort instanceof Function&&this.onabort.call(this,e)}))}get aborted(){return this[e.aborted]}get onabort(){return this[e.onabort]}set onabort(t){this[e.onabort]=t instanceof Function?t:null}get reason(){return this[e.reason]}throwIfAborted(){if(this.aborted)throw this.reason}static abort(n=new DOMException("Operation aborted")){const o=new t;return o[e.aborted]=!0,o[e.reason]=n,o}},globalThis.AbortController=class{constructor(){this[e.signal]=new AbortSignal}get signal(){return this[e.signal]}abort(t=new DOMException("Operation aborted")){const n=this.signal;n.aborted||(n[e.aborted]=!0,n[e.reason]=t,n.dispatchEvent(new Event("abort")))}}}if(!("reason"in AbortSignal.prototype)){const e=new WeakMap,t=AbortController.prototype.abort;if(AbortSignal.abort instanceof Function){const t=AbortSignal.abort;AbortSignal.abort=function(n=new DOMException("Operation aborted")){const o=t();return e.set(o,n),o}}else AbortSignal.abort=function(e=new DOMException("Operation aborted")){const t=new AbortController;return t.abort(e),t.reason};Object.defineProperty(AbortSignal.prototype,"reason",{enumerable:!0,configurable:!0,get:function(){return e.has(this)?e.get(this):void 0}}),AbortController.prototype.abort=function(n=new DOMException("Operation aborted")){e.set(this.signal,n),t.call(this)}}AbortSignal.prototype.throwIfAborted instanceof Function||(AbortSignal.prototype.throwIfAborted=function(){if(this.aborted)throw this.reason}),AbortSignal.timeout instanceof Function||(AbortSignal.timeout=function(e){if(void 0===e)throw new TypeError("At least one 1 argument required but only 0 passed");if(Number.isFinite(e)){if(e<0)throw new TypeError("Argument 1 is out of range for unsigned long long.");{const t=new AbortController;return setTimeout((()=>t.abort(new DOMException("The operation timed out."))),e),t.signal}}throw new TypeError("Argument 1 is not a finite value, so it is out of range for unsigned long long.")}),AbortSignal.any instanceof Function||(AbortSignal.any=function(e){if(!Array.isArray(e))throw new TypeError("Expected an array of signals");const t=new AbortController;for(const n of e){if(!(n instanceof AbortSignal)){const e=new TypeError("`signal` is not an `AbortSignal`");throw t.abort(e),e}if(n.aborted){t.abort(n.reason||new DOMException("Operation aborted."));break}n.addEventListener("abort",(({target:e})=>{t.abort(e.reason||new DOMException("Operation aborted."))}),{signal:t.signal})}return t.signal})}(),globalThis.hasOwnProperty("AggregateError")||(globalThis.AggregateError=class extends Error{constructor(e,t){void 0===t?(super(e),this.errors=[]):(super(t),this.errors=e)}}),globalThis.reportError instanceof Function||(globalThis.reportError=function(e){globalThis.dispatchEvent(S(e))}),function(){if("MediaQueryListEvent"in globalThis||(globalThis.MediaQueryListEvent=class extends Event{constructor(e,{media:t,matches:n}={}){super(e),Object.defineProperties(this,{media:{enumerable:!0,configurable:!1,writable:!1,value:t},matches:{enumerable:!0,configurable:!1,writable:!1,value:n}})}}),"MediaQueryList"in globalThis&&!(globalThis.MediaQueryList.prototype.addEventListener instanceof Function)){const e=new WeakMap,t=function(){const{media:e,matches:t}=this;this.dispatchEvent(new MediaQueryListEvent("change",{media:e,matches:t}))},n=function(n){return e.has(n)||(e.set(n,new EventTarget),n.addListener(t.bind(n))),e.get(n)};globalThis.MediaQueryList.prototype.addEventListener=function(e,t,o){n(this).addEventListener(e,t,o)},globalThis.MediaQueryList.prototype.removeEventListener=function(e,t,o){n(this).removeEventListener(e,t,o)},globalThis.MediaQueryList.prototype.dispatchEvent=function(e){n(this).dispatchEvent(e)}}}(),"Promise"in globalThis&&(Promise.prototype.finally instanceof Function||(Promise.prototype.finally=function(e){return this.then((async t=>(await e(),t)),(async t=>(await e(),t)))}),Promise.allSettled instanceof Function||(Promise.allSettled=function(e){return Promise.all(Array.from(e).map((function(e){return new Promise((function(t){e instanceof Promise||(e=Promise.resolve(e)),e.then((function(e){t({status:"fulfilled",value:e})})).catch((function(e){t({status:"rejected",reason:e})}))}))})))}),Promise.any instanceof Function||(Promise.any=e=>new Promise(((t,n)=>{let o=[];e.forEach((r=>{r.then(t).catch((t=>{o.push(t),o.length===e.length&&n(new globalThis.AggregateError(o,"No Promise in Promise.any was resolved"))}))}))}))),Promise.race instanceof Function||(Promise.race=e=>new Promise(((t,n)=>{e.forEach((e=>e.then(t,n)))}))),Promise.try instanceof Function||(Promise.try=e=>new Promise((t=>t(e())))),Promise.withResolvers instanceof Function||(Promise.withResolvers=function(){const e={};return e.promise=new Promise(((t,n)=>{e.resolve=t,e.reject=n})),e}))
|
|
8
|
+
*/const l=new Map,c=Symbol("lock-key"),u="locks"in navigator&&navigator.locks.request instanceof Function;const p=async function(){return await new Promise((e=>{"locks"in navigator&&navigator.locks.request instanceof Function?navigator.locks.query().then((()=>e(!0))).catch((()=>e(!1))):e(!1)}))}();async function d(e,t=null){return new Promise(((o,r)=>{var i;n(i=e)||i instanceof Promise?e.call(globalThis,t).then(o,r):queueMicrotask((()=>{try{const n=e.call(globalThis,t);o(n)}catch(e){r(e)}}))}))}async function f(e){l.has(e)&&await l.get(e).promise.catch(console.error)}function h(e,t,n){const{resolve:o,reject:r,promise:i}=function(){if(Promise.withResolvers instanceof Function)return Promise.withResolvers();{const e={};return e.promise=new Promise(((t,n)=>{e.resolve=t,e.reject=n})),e}}(),a=new AbortController,c=new s(e,t),u=function({name:e,mode:t}){switch(t){case"exclusive":return y().some((t=>t.name===e));case"shared":return y().some((t=>t.name===e&&"exclusive"===t.mode))}}(c);return l.set(c,{resolve:o,reject:r,promise:i,callback:n,pending:u,controller:a}),c}function m(e){return e instanceof s&&l.has(e)&&l.get(e).pending}function y(e){return"string"==typeof e?[...l.keys()].filter((t=>t.name===e)):[...l.keys()]}function g(e){return y(e).filter((e=>!m(e)))}function b(e){return y(e).filter((e=>m(e)))}async function w(e){switch(e.mode){case"exclusive":await Promise.allSettled(y().filter((t=>t.name===e.name&&t!==e)).map(f));break;case"shared":await Promise.allSettled(y().filter((t=>t.name===e.name&&"exclusive"===t.mode&&t!==e)).map(f))}}function T(e){if(l.has(e))return l.get(e).controller.signal}async function v(e){if(l.has(e)){const{resolve:t,reject:n,promise:o,callback:r,pending:i,controller:a}=l.get(e);return i&&function(e,t=!0){l.has(e)&&l.set(e,{...l.get(e),pending:t})}(e,!1),d(r,e).then(t,n).finally((()=>{l.delete(e),requestIdleCallback((()=>a.abort()))})),o}}class E{constructor(e){if(e!==c)throw new TypeError("Invalid constructor")}static async request(e,...t){let n,o={};t[0]instanceof Function?n=t[0]:t[1]instanceof Function&&([o,n]=t),"string"!=typeof e&&(e=e.toString());const{mode:r="exclusive",ifAvailable:i=!1,steal:a=!1,signal:s}=o;if(a&&i)throw new DOMException("LockManager.request: `steal` and `ifAvailable` cannot be used together");if(e.startsWith("-"))throw new DOMException("LockManager.request: Names starting with `-` are reserved");if(!["exclusive","shared"].includes(r))throw new TypeError(`LockManager.request: '${r}' (value of 'mode' member of LockOptions) is not a valid value for enumeration LockMode.`);if(s instanceof AbortSignal&&s.aborted)throw s.reason;if("shared"===r&&a)throw new DOMException("LockManager.request: `steal` is only supported for exclusive lock requests");const c=g(e),u=b(e),p=[...c,...u].some((t=>t.name===e));a&&p&&function(e){[...l.entries()].filter((([t])=>t.name===e)).forEach((([e,{reject:t,controller:n}])=>{requestIdleCallback((()=>{n.abort(),l.delete(e)})),t(new DOMException("The lock request is aborted"))}))}(e);const f=h(e,r,n);switch(s instanceof AbortSignal&&s.addEventListener("abort",(()=>{if(l.has(f)){const{reject:e,controller:t}=l.get(f);l.delete(f),e(new DOMException("The lock request is aborted")),t.abort()}}),{once:!0,signal:T(f)}),r){case"exclusive":if(!i||0===c.length&&0===u.length)return await w(f),await v(f);{const e=l.get(f).controller;return l.delete(f),await d(n,null).then((t=>(requestIdleCallback((()=>e.abort())),t)))}case"shared":if(i){if([...c,...u].some((e=>"exclusive"===e.mode))){const e=l.get(f).controller;return l.delete(f),await d(n,null).then((t=>(requestIdleCallback((()=>e.abort())),t)))}return await w(f),await v(f)}return await w(f),await v(f);default:throw new TypeError(`LockManager.request: '${r}' (value of 'mode' member of LockOptions) is not a valid value for enumeration LockMode.`)}}static async query(){return{held:g().map((({name:e,mode:t})=>({name:e,mode:t,clientId:null}))),pending:b().map((({name:e,mode:t})=>({name:e,mode:t,clientId:null})))}}}function S(e,t="error"){if(e instanceof Error){const{message:n,name:o,fileName:r,lineNumber:i,columnNumber:a}=e;return new ErrorEvent(t,{error:e,message:`${o}: ${n}`,filename:r,lineno:i,colno:a})}throw new TypeError("`errorToEvent()` only accepts Errors")}let M=!1;new Promise((async e=>{if(u)if(await p)e(!1);else try{navigator.locks.request=E.request,navigator.locks.query=E.query,M=!0,e(!0)}catch(t){globalThis.dispatchEvent(S(t)),e(!1)}else try{navigator.locks=E,M=!0,e(!0)}catch(t){globalThis.dispatchEvent(S(t)),e(!1)}})),navigator.canShare instanceof Function||(navigator.canShare=function({title:e,text:t,url:n,files:o}={}){return navigator.share instanceof Function&&(!Array.isArray(o)||0===o.length)&&(!![e,t,n].every((e=>void 0===e))||[e,t,n].some((e=>"string"==typeof e&&0!==e.length)))}),navigator.setAppBadge instanceof Function||(navigator.setAppBadge=async e=>{if(!Number.isInteger(e))throw new TypeError("Failed to execute 'setAppBadge' on 'Navigator': Value is not of type 'unsigned long long'");if(e<0)throw new TypeError("Failed to execute 'setAppBadge' on 'Navigator': Value is outside the 'unsigned long long' value range.");0===e?document.title.startsWith("(")&&(document.title=document.title.replace(/^\((\d{1,2}\+?)\)\s/,"")):e<100?(await navigator.clearAppBadge(),document.title=`(${e}) ${document.title}`):(await navigator.clearAppBadge(),document.title=`(99+) ${document.title}`)}),navigator.clearAppBadge instanceof Function||(navigator.clearAppBadge=()=>navigator.setAppBadge(0)),Navigator.prototype.hasOwnProperty("pdfViewerEnabled")||Object.defineProperty(navigator,"pdfViewerEnabled",{enumerable:!0,configurable:!1,writable:!1,value:!1}),Navigator.prototype.getInstalledRelatedApps instanceof Function||(Navigator.prototype.getInstalledRelatedApps=async()=>[]),Navigator.prototype.getGamepads instanceof Function||(Navigator.prototype.getGamepads=()=>[]),"hardwareConcurrency"in Navigator.prototype||Object.defineProperty(Navigator.prototype,"hardwareConcurrency",{get:()=>1}),"connection"in Navigator.prototype?"type"in navigator.connection||(navigator.connection.type="unknown"):Object.defineProperty(Navigator.prototype,"connection",{get:()=>Object.create(EventTarget.prototype,{type:{value:"unknown"},effectiveType:{value:"4g"},rtt:{value:NaN},downlink:{value:NaN},downlinkMax:{value:1/0},saveData:{value:!1},onchange:{value:null,writable:!0},ontypechange:{value:null,writable:!0}})}),"doNotTrack"in Navigator.prototype||Object.defineProperty(Navigator.prototype,"doNotTrack",{get:()=>"unspecified"}),"globalPrivacyControl"in Navigator.prototype||Object.defineProperty(Navigator.prototype,"globalPrivacyControl",{get:()=>!1}),function(){if(!(globalThis.requestIdleCallback instanceof Function)){const e=e=>Number.isSafeInteger(e)&&e>0;globalThis.requestIdleCallback=function(t,{timeout:n}={}){const o=performance.now(),r=()=>e(n)?Math.max(0,n-(performance.now()-o)):Math.max(0,600-(performance.now()-o));return setTimeout((()=>t({didTimeout:!!e(n)&&0===r(),timeRemaining:r})),1)}}globalThis.cancelIdleCallback instanceof Function||(globalThis.cancelIdleCallback=e=>clearTimeout(e)),globalThis.requestAnimationFrame instanceof Function||(globalThis.requestAnimationFrame=e=>setTimeout((()=>e(performance.now())),1e3/60)),globalThis.cancelAnimationFrame instanceof Function||(globalThis.cancelAnimationFrame=e=>clearTimeout(e)),globalThis.queueMicrotask instanceof Function||(globalThis.queueMicrotask=e=>Promise.resolve().then(e).catch((e=>setTimeout((()=>{throw e})))))}(),function(){if(!("AbortSignal"in globalThis)){const e={signal:Symbol("signal"),aborted:Symbol("aborted"),reason:Symbol("reason"),onabort:Symbol("onabort")};globalThis.AbortError=class extends Error{},globalThis.AbortSignal=class t extends EventTarget{constructor(){super(),Object.defineProperties(this,{[e.aborted]:{enumerable:!1,writable:!0,configurable:!1,value:!1},[e.reason]:{enumerable:!1,writable:!0,configurable:!1,value:void 0},[e.onabort]:{enumerable:!1,writable:!0,configurable:!1,value:null}}),this.addEventListener("abort",(e=>{this.onabort instanceof Function&&this.onabort.call(this,e)}))}get aborted(){return this[e.aborted]}get onabort(){return this[e.onabort]}set onabort(t){this[e.onabort]=t instanceof Function?t:null}get reason(){return this[e.reason]}throwIfAborted(){if(this.aborted)throw this.reason}static abort(n=new DOMException("Operation aborted")){const o=new t;return o[e.aborted]=!0,o[e.reason]=n,o}},globalThis.AbortController=class{constructor(){this[e.signal]=new AbortSignal}get signal(){return this[e.signal]}abort(t=new DOMException("Operation aborted")){const n=this.signal;n.aborted||(n[e.aborted]=!0,n[e.reason]=t,n.dispatchEvent(new Event("abort")))}}}if(!("reason"in AbortSignal.prototype)){const e=new WeakMap,t=AbortController.prototype.abort;if(AbortSignal.abort instanceof Function){const t=AbortSignal.abort;AbortSignal.abort=function(n=new DOMException("Operation aborted")){const o=t();return e.set(o,n),o}}else AbortSignal.abort=function(e=new DOMException("Operation aborted")){const t=new AbortController;return t.abort(e),t.reason};Object.defineProperty(AbortSignal.prototype,"reason",{enumerable:!0,configurable:!0,get:function(){return e.has(this)?e.get(this):void 0}}),AbortController.prototype.abort=function(n=new DOMException("Operation aborted")){e.set(this.signal,n),t.call(this)}}AbortSignal.prototype.throwIfAborted instanceof Function||(AbortSignal.prototype.throwIfAborted=function(){if(this.aborted)throw this.reason}),AbortSignal.timeout instanceof Function||(AbortSignal.timeout=function(e){if(void 0===e)throw new TypeError("At least one 1 argument required but only 0 passed");if(Number.isFinite(e)){if(e<0)throw new TypeError("Argument 1 is out of range for unsigned long long.");{const t=new AbortController;return setTimeout((()=>t.abort(new DOMException("The operation timed out."))),e),t.signal}}throw new TypeError("Argument 1 is not a finite value, so it is out of range for unsigned long long.")}),AbortSignal.any instanceof Function||(AbortSignal.any=function(e){if(!Array.isArray(e))throw new TypeError("Expected an array of signals");const t=new AbortController;for(const n of e){if(!(n instanceof AbortSignal)){const e=new TypeError("`signal` is not an `AbortSignal`");throw t.abort(e),e}if(n.aborted){t.abort(n.reason||new DOMException("Operation aborted."));break}n.addEventListener("abort",(({target:e})=>{t.abort(e.reason||new DOMException("Operation aborted."))}),{signal:t.signal})}return t.signal})}(),globalThis.hasOwnProperty("AggregateError")||(globalThis.AggregateError=class extends Error{constructor(e,t){void 0===t?(super(e),this.errors=[]):(super(t),this.errors=e)}}),globalThis.reportError instanceof Function||(globalThis.reportError=function(e){globalThis.dispatchEvent(S(e))}),function(){if("MediaQueryListEvent"in globalThis||(globalThis.MediaQueryListEvent=class extends Event{constructor(e,{media:t,matches:n}={}){super(e),Object.defineProperties(this,{media:{enumerable:!0,configurable:!1,writable:!1,value:t},matches:{enumerable:!0,configurable:!1,writable:!1,value:n}})}}),"MediaQueryList"in globalThis&&!(globalThis.MediaQueryList.prototype.addEventListener instanceof Function)){const e=new WeakMap,t=function(){const{media:e,matches:t}=this;this.dispatchEvent(new MediaQueryListEvent("change",{media:e,matches:t}))},n=function(n){return e.has(n)||(e.set(n,new EventTarget),n.addListener(t.bind(n))),e.get(n)};globalThis.MediaQueryList.prototype.addEventListener=function(e,t,o){n(this).addEventListener(e,t,o)},globalThis.MediaQueryList.prototype.removeEventListener=function(e,t,o){n(this).removeEventListener(e,t,o)},globalThis.MediaQueryList.prototype.dispatchEvent=function(e){n(this).dispatchEvent(e)}}}(),"Promise"in globalThis&&(Promise.prototype.finally instanceof Function||(Promise.prototype.finally=function(e){return this.then((async t=>(await e(),t)),(async t=>(await e(),t)))}),Promise.allSettled instanceof Function||(Promise.allSettled=function(e){return Promise.all(Array.from(e).map((function(e){return new Promise((function(t){e instanceof Promise||(e=Promise.resolve(e)),e.then((function(e){t({status:"fulfilled",value:e})})).catch((function(e){t({status:"rejected",reason:e})}))}))})))}),Promise.any instanceof Function||(Promise.any=e=>new Promise(((t,n)=>{let o=[];e.forEach((r=>{r.then(t).catch((t=>{o.push(t),o.length===e.length&&n(new globalThis.AggregateError(o,"No Promise in Promise.any was resolved"))}))}))}))),Promise.race instanceof Function||(Promise.race=e=>new Promise(((t,n)=>{e.forEach((e=>e.then(t,n)))}))),Promise.try instanceof Function||(Promise.try=e=>new Promise((t=>t(e())))),Promise.withResolvers instanceof Function||(Promise.withResolvers=function(){const e={};return e.promise=new Promise(((t,n)=>{e.resolve=t,e.reject=n})),e}))
|
|
9
9
|
/**
|
|
10
10
|
* @copyright 2023 Chris Zuber <admin@kernvalley.us>
|
|
11
11
|
*/;class A{get encoding(){return"utf-8"}encode(e){return new Uint8Array(e.split("").flatMap((e=>{const t=e.charCodeAt(0);if(t<128)return[t];return[194+Math.floor((t-128)/64),t%64+128]})))}encodeInto(e,t){if(t instanceof Uint8Array){const n=this.encode(e),o=Math.min(t.length,n.length);return n.length>t.length?t.set(n.slice(0,o)):t.set(n),{read:o,written:o}}throw new TypeError("TextEncoder.encodeInto: Argument 2 does not implement interface Uint8Array.")}}
|
|
@@ -20,18 +20,18 @@
|
|
|
20
20
|
* cookie properties, such as expires, etc.
|
|
21
21
|
*
|
|
22
22
|
* @TODO verify spec compliance as best as is possible
|
|
23
|
-
*/;const
|
|
23
|
+
*/;const P="cookieStore"in globalThis,k={constructor:Symbol("constructor")};function L(){return 0===document.cookie.length?[]:document.cookie.split(";").map((e=>{const[t,n=null]=e.split("=");return{name:decodeURIComponent(t.trim()),value:"string"==typeof n?decodeURIComponent(n.trim()):null,path:void 0,expires:void 0,domain:void 0,sameSite:void 0,secure:void 0}}))}function O({name:e=null,value:t=null}={}){return"string"==typeof e&&(e=decodeURIComponent(e)),"string"==typeof t&&(t=decodeURIComponent(t)),"string"==typeof e&&"string"==typeof t?L().filter((n=>n.name===e&&n.value===t)):"string"==typeof e?L().filter((t=>t.name===e)):"string"==typeof t?L().filter((e=>e.value===t)):L()}function x({name:e,value:t,expires:n=null,maxAge:o=null,path:r="/",sameSite:i="strict",domain:a=null,secure:s=!1,httpOnly:l=!1}){if(Number.isInteger(o))x({name:e,value:t,expires:Date.now()+o,path:r,sameSite:i,domain:a,secure:s,httpOnly:l});else{let o=`${encodeURIComponent(e)}=`;t&&(o+=encodeURIComponent(t)),Number.isInteger(n)?o+=`;expires=${new Date(n).toUTCString()}`:n instanceof Date&&(o+=`;expires=${n.toUTCString()}`),"string"==typeof r&&(o+=`;path=${r}`),"string"==typeof a&&(o+=`;domain=${a}`),"string"==typeof i&&(o+=`;sameSite=${i}`),!0===s&&(o+=";secure"),!0===l&&(o+=";httponly"),document.cookie=o}}class C extends EventTarget{constructor(e){if(e!==k.constructor)throw new DOMException("Invalid constructor");super(),Object.defineProperty(this,k.onchange,{enumerable:!1,configurable:!1,writable:!0,value:null})}get onchange(){return this[k.onchange]}set onchange(e){this[k.onchange]instanceof Function&&this.removeEventListener("change",this[k.onchange]),e instanceof Function&&this.addEventListener("change",e)}async get(e){const t=await this.getAll(e);return Array.isArray(t)&&0!==t.length?t[0]:null}async getAll(e){return O("string"==typeof e?{name:e}:e)}async set(...e){if(1===e.length&&"string"==typeof e[0].name){const t=function({name:e,value:t=null,domain:n=null,path:o="/",expires:r=null,maxAge:i=null,sameSite:a="strict",secure:s=!1,httpOnly:l=!1}){return{name:e,value:t,domain:n,path:o,expires:r,maxAge:i,sameSite:a,secure:s,httpOnly:l}}(e[0]);x(t);const n=new Event("change");n.changed=[t],n.deleted=[],this.dispatchEvent(n)}else{if(2!==e.length)throw new Error("Invalid arguments");this.set({name:e[0],value:e[1]})}}async delete(e={}){if("string"==typeof e)this.delete({name:e});else{if("string"!=typeof e.name)throw new TypeError("Failed to execute 'delete' on 'CookieStore': required member name is undefined.");{const t=await this.getAll(e);if(0!==t.length){const n=new Event("change");n.changed=[],n.deleted=new Array(t.length),t.forEach(((t,o)=>{t.path=e.path||"/",t.domain=e.domain||null,t.secure=e.secure||null,delete t.value,t.sameSite=e.sameSite||"strict",n.deleted[o]=t,x({...t,value:null,expires:1})})),this.dispatchEvent(n)}}}}}const I=new C(k.constructor);
|
|
24
24
|
/**
|
|
25
25
|
* @copyright 2023 Chris Zuber <admin@kernvalley.us>
|
|
26
26
|
*/
|
|
27
|
-
function D(){return"trustedTypes"in globalThis&&trustedTypes instanceof EventTarget&&trustedTypes.createPolicy instanceof Function}!
|
|
27
|
+
function D(){return"trustedTypes"in globalThis&&trustedTypes instanceof EventTarget&&trustedTypes.createPolicy instanceof Function}!P&&(globalThis.cookieStore=I),globalThis.hasOwnProperty("Animation")&&!Animation.prototype.hasOwnProperty("finished")&&Object.defineProperty(Animation.prototype,"finished",{get:function(){return new Promise(((e,t)=>{"finished"===this.playState?e(this):(this.addEventListener("finish",(()=>e(this)),{once:!0}),this.addEventListener("error",(e=>t(e)),{once:!0}))}))}}),globalThis.hasOwnProperty("Animation")&&!Animation.prototype.hasOwnProperty("ready")&&Object.defineProperty(Animation.prototype,"ready",{get:function(){return new Promise(((e,t)=>{this.pending?(this.addEventListener("ready",(()=>e(this)),{once:!0}),this.addEventListener("error",(e=>t(e)),{once:!0})):e(this)}))}});
|
|
28
28
|
/**
|
|
29
29
|
* @copyright 2023 Chris Zuber <admin@kernvalley.us>
|
|
30
30
|
*/
|
|
31
|
-
const H=Object.keys(Object.getOwnPropertyDescriptors(HTMLElement.prototype)).filter((e=>e.startsWith("on"))),R=["action","cite","formaction","href","ping","src"],
|
|
31
|
+
const H=Object.keys(Object.getOwnPropertyDescriptors(HTMLElement.prototype)).filter((e=>e.startsWith("on"))),R=["action","cite","formaction","href","ping","src"],j=i((async function(){const{ok:e,headers:t}=await fetch(location.href,{method:"HEAD"});if(e&&t.has("Content-Security-Policy")){const e=t.get("Content-Security-Policy").trim().split(";").filter((e=>0!==e.length));return Object.fromEntries(e.map((e=>{const[t,...n]=e.trim().split(" ").filter((e=>0!==e.length));return[t,n]})))}}));function z(){const e=document.head.querySelector('meta[http-equiv="Content-Security-Policy"][content]');if(e instanceof HTMLMetaElement){const t=e.content.trim().split(";").filter((e=>0!==e.length));return Object.fromEntries(t.map((e=>{const[t,...n]=e.trim().split(" ").filter((e=>0!==e.length));return[t,n]})))}return{}}
|
|
32
32
|
/**
|
|
33
33
|
* @copyright 2023 Chris Zuber <admin@kernvalley.us>
|
|
34
|
-
*/const
|
|
34
|
+
*/const U="1"===document.documentElement.dataset.fetchTrustCsp;function q({"trusted-types":e=null}={}){if(Array.isArray(e)){const t=new Set(e),n=t.has("'allow-duplicates'"),o=t.has("'none'");return n&&t.delete("'allow-duplicates'"),o&&t.clear(),t.add("empty#html"),t.add("empty#script"),{policies:t,allowDuplicates:n,hasNone:o}}return{}}const{allowDuplicates:_,allowedPolicies:$}=function(){const e=q(z());if("object"==typeof e&&e.policies instanceof Set){const{policies:t,allowDuplicates:n}=e;return{allowDuplicates:n,allowedPolicies:t}}{const e=(()=>{const e=q(z());return"object"==typeof e&&"allowDuplicates"in e?e.allowDuplicates:"1"===document.documentElement.dataset.allowTrustDuplicates})(),t=(()=>{if(document.documentElement.dataset.hasOwnProperty("trustedPolicies"))return new Set(["empty#html","empty#script",...document.documentElement.dataset.trustedPolicies.split(" ")]);{const{policies:e}=q(z());return e instanceof Set?e:new Set(["empty#html","empty#script"])}})();return t.has("'none'")&&t.clear(),t.add("empty#html"),t.add("empty#script"),{allowDuplicates:e,allowedPolicies:t}}}();D();const V={trustedValue:Symbol("[[Data]]"),trustedKey:Symbol("trusted-key"),emptyHTML:Symbol("policy-empty#html"),emptyScript:Symbol("policy-empty#script"),policy:Symbol.for("trust-policy"),defaultPolicy:Symbol("default-policy"),trustedTypesCSP:Symbol("trusted-types-csp")};Symbol.hasOwnProperty("toStringTag")||(Symbol.toStringTag=Symbol("Symbol.toStringTag"));const B=[];function W(e){return null!==function(e){return B.find((t=>t.name===e))||null}(e)}function G(e,t){return function(){throw new TypeError(`Failed to execute '${t}' on 'TrustedTypePolicy': Policy ${e.name}'s TrustedTypePolicyOptions did not specify a '${t}' member.`)}}class K{constructor(e,{key:t,policy:n}){if(t!==V.trustedKey)throw new TypeError("Invalid constructor");Object.defineProperties(this,{[V.trustedValue]:{enumerable:!1,configurable:!1,writable:!1,value:e.toString()},[V.policy]:{enumerable:!1,configurable:!1,writable:!1,value:n.name}}),Object.freeze(this)}toString(){return this.valueOf()}toJSON(){return this.valueOf()}valueOf(){return this[V.trustedValue]}}class Q extends K{[Symbol.toStringTag](){return"TrustedHTML"}}class X extends K{[Symbol.toStringTag](){return"TrustedScript"}}class J extends K{[Symbol.toStringTag](){return"TrustedScriptURL"}}class Y{constructor(e,{createHTML:t,createScript:n,createScriptURL:o}={},{key:r}){if(r!==V.trustedKey)throw new TypeError("Invalid constructor");Object.defineProperties(this,{name:{enumerable:!0,configurable:!1,writable:!1,value:e.toString()},createHTML:{enumerable:!0,configurable:!1,writable:!1,value:t instanceof Function?(e,...n)=>new Q(t(e.toString(),...n),{key:V.trustedKey,policy:this}):G(this,"createHTML")},createScript:{enumerable:!0,configurable:!1,writable:!1,value:n instanceof Function?(e,...t)=>new X(n(e.toString(),...t),{key:V.trustedKey,policy:this}):G(this,"createScript")},createScriptURL:{enumerable:!0,configurable:!1,writable:!1,value:o instanceof Function?(e,...t)=>new J(o(e.toString(),...t),{key:V.trustedKey,policy:this}):G(this,"createScriptURL")}})}}class Z extends EventTarget{constructor(e){if(super(),e!==V.trustedKey)throw new TypeError("Invalid constructor");U&&async function(){const{policies:e,allowDuplicates:t=!1,hasNone:n=!1}=await j().then(q);return e instanceof Set?{policies:e,allowDuplicates:t,hasNone:n}:{}}().then((({policies:e,allowDuplicates:t=!1,hasNone:n=!1})=>{void 0!==e&&Object.defineProperty(Z,V.trustedTypesCSP,{value:{policies:e,allowDuplicates:t,hasNone:n},enumberable:!1,writable:!1,configurable:!1})})).catch((e=>console.error(e))),Object.defineProperties(this,{[V.defaultPolicy]:{enumerable:!1,configurable:!1,writable:!0,value:null},[V.emptyHTML]:{enumerable:!1,configurable:!1,writable:!1,value:this.createPolicy("empty#html",{createHTML:()=>""})},[V.emptyScript]:{enumerable:!1,configurable:!1,writable:!1,value:this.createPolicy("empty#script",{createScript:()=>""})}})}isHTML(e){return e instanceof globalThis.TrustedHTML}isScript(e){return e instanceof globalThis.TrustedScript}isScriptURL(e){return e instanceof globalThis.TrustedScriptURL}createPolicy(e,{createHTML:t,createScript:n,createScriptURL:o}={}){const r=new Y(e,{createHTML:t,createScript:n,createScriptURL:o},{key:V.trustedKey});if(!e.toString().match(/^[-#a-zA-Z0-9=_/@.%]+$/g))throw new TypeError(`Failed to execute 'createPolicy' on 'TrustedTypePolicyFactory': Policy: "${e}" contains invalid characters.`);if(Z.hasOwnProperty(V.trustedTypesCSP)){const{policies:t,allowDuplicates:n,hasNone:o}=Z[V.trustedTypesCSP];if(o&&"empty#html"!==e&&"empty#script"!==e)throw new TypeError(`Failed to execute 'createPolicy' on 'TrustedTypePolicyFactory': Policy: "${e}" disallowed.`);if(!t.has(e))throw new TypeError(`Failed to execute 'createPolicy' on 'TrustedTypePolicyFactory': Policy: "${e}" disallowed.`);if(!n&&W(e))throw new TypeError(`Failed to execute 'createPolicy' on 'TrustedTypePolicyFactory': Policy: "${e}" already exists.`)}else{if($.size>2&&!$.has(e))throw new TypeError(`Failed to execute 'createPolicy' on 'TrustedTypePolicyFactory': Policy: "${e}" disallowed.`);if(!_&&W(e))throw new TypeError(`Failed to execute 'createPolicy' on 'TrustedTypePolicyFactory': Policy: "${e}" already exists.`)}return"default"===r.name&&(this[V.defaultPolicy]=r),B.push(r),r}getAttributeType(e,t,n){if(e=e.toLowerCase(),t=t.toLowerCase(),"string"==typeof elementNS&&0!==n.length)return H.includes(t)?"TrustedScript":null;if(H.includes(t))return"TrustedScript";switch(e){case"script":return"src"===t?"TrustedScriptURL":null;case"iframe":return"srcdoc"===t?"TrustedHTML":"src"===t?"TrustedScriptURL":null;default:return null}}getPropertyType(e,t){if(e=e.toLowerCase(),H.includes(t.toLowerCase()))return"TrustedScript";switch(e){case"embed":case"iframe":return"src"===t?"TrustedScriptURL":null;case"script":return"src"===t?"TrustedScriptURL":["text","innerText","textContent","innerHTML"].includes(t)?"TrustedScript":["outerHTML"].includes(t)?"TrustedHTML":null;default:return["innerHTML","outerHTML"].includes(t)?"TrustedHTML":null}}get emptyHTML(){return this[V.emptyHTML].createHTML("")}get emptyScript(){return this[V.emptyScript].createScript("")}get defaultPolicy(){return this[V.defaultPolicy]}get _isPolyfill_(){return!0}static get allowDuplicates(){return _}}const ee=new Z(V.trustedKey);!function(){if("TrustedTypePolicyFactory"in globalThis||(globalThis.TrustedTypePolicyFactory=Z),"TrustedTypePolicy"in globalThis||(globalThis.TrustedTypePolicy=Y),"TrustedType"in globalThis||(globalThis.TrustedType=K),"TrustedHTML"in globalThis||(globalThis.TrustedHTML=Q),"TrustedScript"in globalThis||(globalThis.TrustedScript=X),"TrustedScriptURL"in globalThis||(globalThis.TrustedScriptURL=J),"trustedTypes"in globalThis)try{globalThis.trustedTypes.createPolicy("empty#html",{createHTML:()=>""}),globalThis.trustedTypes.createPolicy("empty#script",{createScript:()=>""})}catch(e){console.error(e)}else globalThis.trustedTypes=ee}();
|
|
35
35
|
/**
|
|
36
36
|
* @copyright 2023 Chris Zuber <admin@kernvalley.us>
|
|
37
37
|
* @see https://wicg.github.io/sanitizer-api/#default-configuration-dictionary
|
|
@@ -40,11 +40,11 @@ const te=JSON.parse('{\n "allowCustomElements": false,\n "allowUnknownMarkup":
|
|
|
40
40
|
/**
|
|
41
41
|
* @copyright 2022-2023 Chris Zuber <admin@kernvalley.us>
|
|
42
42
|
*/
|
|
43
|
-
const se=new WeakMap;class le{constructor({allowElements:e,allowAttributes:t,blockElements:n,dropAttributes:o,dropElements:r,allowComments:i=te.allowComments,allowCustomElements:a=te.allowCustomElements,allowUnknownMarkup:s=te.allowUnknownMarkup}=le.getDefaultConfiguration()){se.set(this,{allowElements:e,allowComments:i,allowAttributes:t,allowCustomElements:a,blockElements:n,dropAttributes:o,dropElements:r,allowUnknownMarkup:s})}getConfiguration(){return se.get(this)}sanitize(e){return ie(e,{config:this.getConfiguration()})}sanitizeFor(e,t){return function(e,t,{config:n=te}={}){const o=document.createElement(e),r=document.createElement("template");return r.innerHTML=re(t),o.append(ie(r.content,{config:n})),o}(e,t,{config:this.getConfiguration()})}static getDefaultConfiguration(){return te}}const{setHTML:ce,polyfill:ue}=function(e,t){return{setHTML:function(t,n,{sanitizer:o=new e}={}){const r=o.sanitizeFor("div",n);t.replaceChildren(...r.children)},polyfill:function(){let n=!1;if("Sanitizer"in globalThis){if(globalThis.Sanitizer.getDefaultConfiguration instanceof Function||(globalThis.Sanitizer.getDefaultConfiguration=function(){return t},n=!0),!(globalThis.Sanitizer.prototype.getConfiguration instanceof Function)){const e=new WeakMap,t=globalThis.Sanitizer;globalThis.Sanitizer=class extends t{constructor({allowAttributes:n,allowComments:o,allowElements:r,allowCustomElements:i,blockElements:a,dropAttributes:s,dropElements:l,allowUnknownMarkup:c}=t.getDefaultConfiguration()){super({allowAttributes:n,allowComments:o,allowElements:r,allowCustomElements:i,blockElements:a,dropAttributes:s,dropElements:l,allowUnknownMarkup:c}),e.set(this,{allowAttributes:n,allowComments:o,allowElements:r,allowCustomElements:i,blockElements:a,dropAttributes:s,dropElements:l,allowUnknownMarkup:c})}getConfiguration(){return e.get(this)}},n=!0}globalThis.Sanitizer.prototype.sanitize instanceof Function||(globalThis.Sanitizer.prototype.sanitize=function(e){if(e instanceof Node){if([Node.DOCUMENT_NODE,Node.DOCUMENT_FRAGMENT_NODE].includes(e.nodeType))return ie(e,{config:this.getConfiguration()});throw new TypeError("Expected a Document or DocumentFragment in `Sanitizer.sanitize()`.")}throw new TypeError("`Sanitizer.sanitize()` expects a `Node`")},n=!0),!(globalThis.Sanitizer.prototype.sanitizeFor instanceof Function)&&Element.prototype.setHTML instanceof Function?(globalThis.Sanitizer.prototype.sanitizeFor=function(e,t){const n=document.createElement(e);return n.setHTML(t,{sanitizer:this}),n},n=!0):globalThis.Sanitizer.prototype.sanitizeFor instanceof Function||(globalThis.Sanitizer.prototype.sanitizeFor=function(e,t){const n=document.createElement(e),o=document.createElement("template");return o.innerHTML=re(t),n.append(this.sanitize(o.content)),n},n=!0),Element.prototype.setHTML instanceof Function||(Element.prototype.setHTML=function(e,{sanitizer:t=new globalThis.Sanitizer}={}){const n=t.sanitizeFor("div",e);this.replaceChildren(...n.children)},n=!0)}else globalThis.Sanitizer=e,n=!0;return n}}}(le,te);ue(),document.createElement("dialog")instanceof HTMLUnknownElement&&!HTMLUnknownElement.prototype.hasOwnProperty("open")&&(HTMLUnknownElement.prototype.show=function(){this.open=!0},HTMLUnknownElement.prototype.close=function(e=null){if(this.open=!1,"DIALOG"===this.tagName){const t=new CustomEvent("close");"string"==typeof e&&(t.returnValue=!0,this.returnValue=e),this.dispatchEvent(t),delete this.returnValue}},Object.defineProperty(HTMLUnknownElement.prototype,"open",{set:function(e){if("DETAILS"===this.tagName)this.dispatchEvent(new CustomEvent("toggle")),this.toggleAttribute("open",e);else if("DIALOG"===this.tagName&&(this.toggleAttribute("open",e),!e)){this.classList.remove("modal");const e=this.nextElementSibling;e instanceof HTMLElement&&e.matches(".backdrop")&&e.remove()}},get:function(){return this.hasAttribute("open")}})),document.createElement("dialog").showModal instanceof Function||(HTMLUnknownElement.prototype.showModal=function(){const e=new AbortController,t=e.signal;document.addEventListener("keydown",(function({key:e}){"Escape"===e&&this.close()}),{passive:!0,signal:t}),this.addEventListener("close",(()=>e.abort()),{once:!0,signal:t}),this.open=!0,this.classList.add("modal");const n=document.createElement("div");n.classList.add("backdrop"),this.after(n)});const pe={ariaAtomic:"aria-atomic",ariaAutoComplete:"aria-autocomplete",ariaBusy:"aria-busy",ariaChecked:"aria-checked",ariaColCount:"aria-colcount",ariaColIndex:"aria-colindex",ariaColIndexText:"aria-colindextext",ariaColSpan:"aria-colspan",ariaCurrent:"aria-current",ariaDisabled:"aria-disabled",ariaExpanded:"aria-expanded",ariaHasPopup:"aria-haspopup",ariaHidden:"aria-hidden",ariaInvalid:"aria-invalid",ariaKeyShortcuts:"aria-keyshortcuts",ariaLabel:"aria-label",ariaLevel:"aria-level",ariaLive:"aria-live",ariaModal:"aria-modal",ariaMultiLine:"aria-multiline",ariaMultiSelectable:"aria-multiselectable",ariaOrientation:"aria-orientation",ariaPlaceholder:"aria-placeholder",ariaPosInSet:"aria-posinset",ariaPressed:"aria-pressed",ariaReadOnly:"aria-readonly",ariaRelevant:"aria-relevant",ariaRequired:"aria-required",ariaRoleDescription:"aria-roledescription",ariaRowCount:"aria-rowcount",ariaRowIndex:"aria-rowindex",ariaRowIndexText:"aria-rowindextext",ariaRowSpan:"aria-rowspan",ariaSelected:"aria-selected",ariaSetSize:"aria-setsize",ariaSort:"aria-sort",ariaValueMax:"aria-valuemax",ariaValueMin:"aria-valuemin",ariaValueNow:"aria-valuenow",ariaValueText:"aria-valuetext",role:"role"};if(HTMLScriptElement.supports instanceof Function||(HTMLScriptElement.supports=function(e){switch(e.toLowerCase()){case"classic":return!0;case"module":return"noModule"in HTMLScriptElement.prototype;default:return!1}}),!Element.prototype.hasOwnProperty(pe.role)){const e=!0,t=!0,n=Object.fromEntries(Object.entries(pe).map((([n,o])=>[n,{get:function(){return this.getAttribute(o)},set:function(e){"string"==typeof e?this.setAttribute(o,e):this.removeAttribute(o)},enumerable:e,configurable:t}])));Object.defineProperties(Element.prototype,n)}if(!HTMLElement.prototype.hasOwnProperty("inert")){const e=new WeakMap,t=n=>{e.has(n)&&(n.tabIndex=e.get(n)),n.hasChildNodes()&&[...n.children].forEach(t)},n=t=>{-1!==t.tabIndex&&(e.set(t,t.tabIndex),t.tabIndex=-1),t.hasChildNodes()&&[...t.children].forEach(n)};Object.defineProperty(HTMLElement.prototype,"inert",{get:function(){return this.hasAttribute("inert")},set:function(e){e?(this.setAttribute("aria-hidden","true"),this.setAttribute("inert",""),n(this)):(this.removeAttribute("aria-hidden"),this.removeAttribute("inert"),t(this))},enumerable:!0,configurable:!0})}if(HTMLImageElement.prototype.hasOwnProperty("complete")||Object.defineProperty(HTMLImageElement.prototype,"complete",{get:function(){return""===this.src||this.naturalHeight>0}}),HTMLImageElement.prototype.decode instanceof Function||(HTMLImageElement.prototype.decode=function(){return this.complete?Promise.resolve():new Promise(((e,t)=>{const n=()=>{this.removeEventListener("error",o),this.removeEventListener("load",n),e()},o=e=>{this.removeEventListener("error",o),this.removeEventListener("load",n),t(e)};this.addEventListener("load",n),this.addEventListener("error",o)}))}),!(Element.prototype.setHTML instanceof Function)&&"Sanitizer"in globalThis&&globalThis.Sanitizer.sanitizeFor instanceof Function&&(Element.prototype.setHTML=function(e,{sanitizer:t=new globalThis.Sanitizer}={}){if(!("Sanitizer"in globalThis&&t instanceof globalThis.Sanitizer||void 0!==t&&t.sanitizeFor instanceof Function))throw new TypeError("`sanitizer` is not a valid Sanitizer");{const n=t.sanitizeFor(this.tagName.toLowerCase(),e);this.replaceChildren(...n.children)}}),!HTMLTemplateElement.prototype.hasOwnProperty("shadowRootMode")){Object.defineProperty(HTMLTemplateElement.prototype,"shadowRootMode",{get:function(){return this.getAttribute("shadowrootmode")},set:function(e){this.setAttribute("shadowrootmode",e)},enumerable:!0,configurable:!0});const e=(t=document)=>{t.querySelectorAll("template[shadowrootmode]").forEach((t=>{const n=t.parentElement.attachShadow({mode:t.shadowRootMode});n.append(t.content),t.remove(),e(n)}))};"loading"===document.readyState?document.addEventListener("readystatechange",(()=>e(document)),{once:!0}):e(document)}Set.prototype.intersection instanceof Function||(Set.prototype.intersection=function(e){return e instanceof Set||(e=new Set(e)),new Set([...this].filter((t=>e.has(t))))}),Set.prototype.difference instanceof Function||(Set.prototype.difference=function(e){return e instanceof Set||(e=new Set(e)),new Set([...this].filter((t=>!e.has(t))))}),Set.prototype.union instanceof Function||(Set.prototype.union=function(e){return new Set([...this,...e])}),Set.prototype.isSubsetOf instanceof Function||(Set.prototype.isSubsetOf=function(e){return e instanceof Set||(e=new Set(e)),[...this].every((t=>e.has(t)))}),Set.prototype.isSupersetOf instanceof Function||(Set.prototype.isSupersetOf=function(e){return e instanceof Set||(e=new Set(e)),e.isSubsetOf(this)}),Set.prototype.symmetricDifference instanceof Function||(Set.prototype.symmetricDifference=function(e){return e instanceof Set||(e=new Set(e)),new Set([...this.difference(e),...e.difference(this)])}),Set.prototype.isDisjointFrom instanceof Function||(Set.prototype.isDisjointFrom=function(e){return e instanceof Set||(e=new Set(e)),new Set([...this,...e]).size===this.size+e.size}),Map.prototype.emplace instanceof Function||(Map.prototype.emplace=function(e,{insert:t,update:n}={}){const o=this.has(e);if(o&&n instanceof Function){const t=this.get(e),o=n.call(this,t,e,this);return o!==t&&this.set(e,o),o}if(o)return this.get(e);if(t instanceof Function){const n=t.call(this,e,this);return this.set(e,n),n}throw new Error("Key is not found and no `insert()` given")}),WeakMap.prototype.emplace instanceof Function||(WeakMap.prototype.emplace=function(e,{insert:t,update:n}={}){const o=this.has(e);if(o&&n instanceof Function){const t=this.get(e),o=n.call(this,t,e,this);return o!==t&&this.set(e,t),o}if(o)return this.get(e);if(t instanceof Function){const n=t.call(this,e,this);return this.set(e,n),n}throw new Error("Key is not found and no `insert()` given")}),function(){if("screen"in globalThis&&!(globalThis.getScreenDetails instanceof Function)){class e extends EventTarget{get availHeight(){return screen.availHeight}get availLeft(){return screen.availLeft}get availTop(){return screen.availTop}get availWidth(){return screen.availWidth}get colorDepth(){return screen.colorDepth}get devicePixelRatio(){return globalThis.devicePixelRatio||1}get height(){return screen.height}get isExtended(){return screen.isExtended}get isInternal(){return!0}get isPrimary(){return!0}get label(){return"Unknown"}get orientation(){return screen.orientation}get pixelDepth(){return screen.pixelDepth}get top(){return screen.top}get width(){return screen.width}}class t extends EventTarget{get currentScreen(){return new e}get screens(){return[this.currentScreen]}}Object.defineProperty(Screen.prototype,"isExtended",{enumerable:!0,configurable:!0,get:()=>!1}),globalThis.getScreenDetails=async()=>new t}}();
|
|
43
|
+
const se=new WeakMap;class le{constructor({allowElements:e,allowAttributes:t,blockElements:n,dropAttributes:o,dropElements:r,allowComments:i=te.allowComments,allowCustomElements:a=te.allowCustomElements,allowUnknownMarkup:s=te.allowUnknownMarkup}=le.getDefaultConfiguration()){se.set(this,{allowElements:e,allowComments:i,allowAttributes:t,allowCustomElements:a,blockElements:n,dropAttributes:o,dropElements:r,allowUnknownMarkup:s})}getConfiguration(){return se.get(this)}sanitize(e){return ie(e,{config:this.getConfiguration()})}sanitizeFor(e,t){return function(e,t,{config:n=te}={}){const o=document.createElement(e),r=document.createElement("template");return r.innerHTML=re(t),o.append(ie(r.content,{config:n})),o}(e,t,{config:this.getConfiguration()})}static getDefaultConfiguration(){return te}}const{setHTML:ce,polyfill:ue}=function(e,t){return{setHTML:function(t,n,{sanitizer:o=new e}={}){const r=o.sanitizeFor("div",n);t.replaceChildren(...r.children)},polyfill:function(){let n=!1;if("Sanitizer"in globalThis){if(globalThis.Sanitizer.getDefaultConfiguration instanceof Function||(globalThis.Sanitizer.getDefaultConfiguration=function(){return t},n=!0),!(globalThis.Sanitizer.prototype.getConfiguration instanceof Function)){const e=new WeakMap,t=globalThis.Sanitizer;globalThis.Sanitizer=class extends t{constructor({allowAttributes:n,allowComments:o,allowElements:r,allowCustomElements:i,blockElements:a,dropAttributes:s,dropElements:l,allowUnknownMarkup:c}=t.getDefaultConfiguration()){super({allowAttributes:n,allowComments:o,allowElements:r,allowCustomElements:i,blockElements:a,dropAttributes:s,dropElements:l,allowUnknownMarkup:c}),e.set(this,{allowAttributes:n,allowComments:o,allowElements:r,allowCustomElements:i,blockElements:a,dropAttributes:s,dropElements:l,allowUnknownMarkup:c})}getConfiguration(){return e.get(this)}},n=!0}globalThis.Sanitizer.prototype.sanitize instanceof Function||(globalThis.Sanitizer.prototype.sanitize=function(e){if(e instanceof Node){if([Node.DOCUMENT_NODE,Node.DOCUMENT_FRAGMENT_NODE].includes(e.nodeType))return ie(e,{config:this.getConfiguration()});throw new TypeError("Expected a Document or DocumentFragment in `Sanitizer.sanitize()`.")}throw new TypeError("`Sanitizer.sanitize()` expects a `Node`")},n=!0),!(globalThis.Sanitizer.prototype.sanitizeFor instanceof Function)&&Element.prototype.setHTML instanceof Function?(globalThis.Sanitizer.prototype.sanitizeFor=function(e,t){const n=document.createElement(e);return n.setHTML(t,{sanitizer:this}),n},n=!0):globalThis.Sanitizer.prototype.sanitizeFor instanceof Function||(globalThis.Sanitizer.prototype.sanitizeFor=function(e,t){const n=document.createElement(e),o=document.createElement("template");return o.innerHTML=re(t),n.append(this.sanitize(o.content)),n},n=!0),Element.prototype.setHTML instanceof Function||(Element.prototype.setHTML=function(e,{sanitizer:t=new globalThis.Sanitizer}={}){const n=t.sanitizeFor("div",e);this.replaceChildren(...n.children)},n=!0)}else globalThis.Sanitizer=e,n=!0;return n}}}(le,te);ue();const pe={ariaAtomic:"aria-atomic",ariaAutoComplete:"aria-autocomplete",ariaBusy:"aria-busy",ariaChecked:"aria-checked",ariaColCount:"aria-colcount",ariaColIndex:"aria-colindex",ariaColIndexText:"aria-colindextext",ariaColSpan:"aria-colspan",ariaCurrent:"aria-current",ariaDisabled:"aria-disabled",ariaExpanded:"aria-expanded",ariaHasPopup:"aria-haspopup",ariaHidden:"aria-hidden",ariaInvalid:"aria-invalid",ariaKeyShortcuts:"aria-keyshortcuts",ariaLabel:"aria-label",ariaLevel:"aria-level",ariaLive:"aria-live",ariaModal:"aria-modal",ariaMultiLine:"aria-multiline",ariaMultiSelectable:"aria-multiselectable",ariaOrientation:"aria-orientation",ariaPlaceholder:"aria-placeholder",ariaPosInSet:"aria-posinset",ariaPressed:"aria-pressed",ariaReadOnly:"aria-readonly",ariaRelevant:"aria-relevant",ariaRequired:"aria-required",ariaRoleDescription:"aria-roledescription",ariaRowCount:"aria-rowcount",ariaRowIndex:"aria-rowindex",ariaRowIndexText:"aria-rowindextext",ariaRowSpan:"aria-rowspan",ariaSelected:"aria-selected",ariaSetSize:"aria-setsize",ariaSort:"aria-sort",ariaValueMax:"aria-valuemax",ariaValueMin:"aria-valuemin",ariaValueNow:"aria-valuenow",ariaValueText:"aria-valuetext",role:"role"};if(HTMLScriptElement.supports instanceof Function||(HTMLScriptElement.supports=function(e){switch(e.toLowerCase()){case"classic":return!0;case"module":return"noModule"in HTMLScriptElement.prototype;default:return!1}}),!Element.prototype.hasOwnProperty(pe.role)){const e=!0,t=!0,n=Object.fromEntries(Object.entries(pe).map((([n,o])=>[n,{get:function(){return this.getAttribute(o)},set:function(e){"string"==typeof e?this.setAttribute(o,e):this.removeAttribute(o)},enumerable:e,configurable:t}])));Object.defineProperties(Element.prototype,n)}if(!HTMLElement.prototype.hasOwnProperty("inert")){const e=new WeakMap,t=n=>{e.has(n)&&(n.tabIndex=e.get(n)),n.hasChildNodes()&&[...n.children].forEach(t)},n=t=>{-1!==t.tabIndex&&(e.set(t,t.tabIndex),t.tabIndex=-1),t.hasChildNodes()&&[...t.children].forEach(n)};Object.defineProperty(HTMLElement.prototype,"inert",{get:function(){return this.hasAttribute("inert")},set:function(e){e?(this.setAttribute("aria-hidden","true"),this.setAttribute("inert",""),n(this)):(this.removeAttribute("aria-hidden"),this.removeAttribute("inert"),t(this))},enumerable:!0,configurable:!0})}if(HTMLImageElement.prototype.hasOwnProperty("complete")||Object.defineProperty(HTMLImageElement.prototype,"complete",{get:function(){return""===this.src||this.naturalHeight>0}}),HTMLImageElement.prototype.decode instanceof Function||(HTMLImageElement.prototype.decode=function(){return this.complete?Promise.resolve():new Promise(((e,t)=>{const n=()=>{this.removeEventListener("error",o),this.removeEventListener("load",n),e()},o=e=>{this.removeEventListener("error",o),this.removeEventListener("load",n),t(e)};this.addEventListener("load",n),this.addEventListener("error",o)}))}),!(Element.prototype.setHTML instanceof Function)&&"Sanitizer"in globalThis&&globalThis.Sanitizer.sanitizeFor instanceof Function&&(Element.prototype.setHTML=function(e,{sanitizer:t=new globalThis.Sanitizer}={}){if(!("Sanitizer"in globalThis&&t instanceof globalThis.Sanitizer||void 0!==t&&t.sanitizeFor instanceof Function))throw new TypeError("`sanitizer` is not a valid Sanitizer");{const n=t.sanitizeFor(this.tagName.toLowerCase(),e);this.replaceChildren(...n.children)}}),!HTMLTemplateElement.prototype.hasOwnProperty("shadowRootMode")){Object.defineProperty(HTMLTemplateElement.prototype,"shadowRootMode",{get:function(){return this.getAttribute("shadowrootmode")},set:function(e){this.setAttribute("shadowrootmode",e)},enumerable:!0,configurable:!0});const e=(t=document)=>{t.querySelectorAll("template[shadowrootmode]").forEach((t=>{const n=t.parentElement.attachShadow({mode:t.shadowRootMode});n.append(t.content),t.remove(),e(n)}))};"loading"===document.readyState?document.addEventListener("readystatechange",(()=>e(document)),{once:!0}):e(document)}Set.prototype.intersection instanceof Function||(Set.prototype.intersection=function(e){return e instanceof Set||(e=new Set(e)),new Set([...this].filter((t=>e.has(t))))}),Set.prototype.difference instanceof Function||(Set.prototype.difference=function(e){return e instanceof Set||(e=new Set(e)),new Set([...this].filter((t=>!e.has(t))))}),Set.prototype.union instanceof Function||(Set.prototype.union=function(e){return new Set([...this,...e])}),Set.prototype.isSubsetOf instanceof Function||(Set.prototype.isSubsetOf=function(e){return e instanceof Set||(e=new Set(e)),[...this].every((t=>e.has(t)))}),Set.prototype.isSupersetOf instanceof Function||(Set.prototype.isSupersetOf=function(e){return e instanceof Set||(e=new Set(e)),e.isSubsetOf(this)}),Set.prototype.symmetricDifference instanceof Function||(Set.prototype.symmetricDifference=function(e){return e instanceof Set||(e=new Set(e)),new Set([...this.difference(e),...e.difference(this)])}),Set.prototype.isDisjointFrom instanceof Function||(Set.prototype.isDisjointFrom=function(e){return e instanceof Set||(e=new Set(e)),new Set([...this,...e]).size===this.size+e.size}),Map.prototype.emplace instanceof Function||(Map.prototype.emplace=function(e,{insert:t,update:n}={}){const o=this.has(e);if(o&&n instanceof Function){const t=this.get(e),o=n.call(this,t,e,this);return o!==t&&this.set(e,o),o}if(o)return this.get(e);if(t instanceof Function){const n=t.call(this,e,this);return this.set(e,n),n}throw new Error("Key is not found and no `insert()` given")}),WeakMap.prototype.emplace instanceof Function||(WeakMap.prototype.emplace=function(e,{insert:t,update:n}={}){const o=this.has(e);if(o&&n instanceof Function){const t=this.get(e),o=n.call(this,t,e,this);return o!==t&&this.set(e,t),o}if(o)return this.get(e);if(t instanceof Function){const n=t.call(this,e,this);return this.set(e,n),n}throw new Error("Key is not found and no `insert()` given")}),function(){if("screen"in globalThis&&!(globalThis.getScreenDetails instanceof Function)){class e extends EventTarget{get availHeight(){return screen.availHeight}get availLeft(){return screen.availLeft}get availTop(){return screen.availTop}get availWidth(){return screen.availWidth}get colorDepth(){return screen.colorDepth}get devicePixelRatio(){return globalThis.devicePixelRatio||1}get height(){return screen.height}get isExtended(){return screen.isExtended}get isInternal(){return!0}get isPrimary(){return!0}get label(){return"Unknown"}get orientation(){return screen.orientation}get pixelDepth(){return screen.pixelDepth}get top(){return screen.top}get width(){return screen.width}}class t extends EventTarget{get currentScreen(){return new e}get screens(){return[this.currentScreen]}}Object.defineProperty(Screen.prototype,"isExtended",{enumerable:!0,configurable:!0,get:()=>!1}),globalThis.getScreenDetails=async()=>new t}}();
|
|
44
44
|
/**
|
|
45
45
|
* @copyright 2023 Chris Zuber <admin@kernvalley.us>
|
|
46
46
|
*/
|
|
47
|
-
const de="user-blocking",
|
|
47
|
+
const de="user-blocking",fe="user-visible",he="background";async function me(e,{delay:t=0,signal:n}={}){return new Promise(((o,r)=>{if(n instanceof AbortSignal&&n.aborted)r(n.reason);else{const i=new AbortController,a=setTimeout((()=>{o(e()),i.abort()}),t);n instanceof AbortSignal&&n.addEventListener("abort",(({target:e})=>{r(e.reason),clearTimeout(a)}),{once:!0,signal:i.signal})}}))}class ye{async postTask(e,{priority:t=fe,delay:n,signal:o}={}){return new Promise(((r,i)=>{if(o instanceof AbortSignal&&o.aborted)i(o.reason);else switch(t){case de:"number"==typeof n&&!Number.isNaN(n)&&n>0?me(e,{delay:n,signal:o}).then(r,i):r((async()=>await e())());break;case fe:if("number"==typeof n&&!Number.isNaN(n)&&n>0)me((()=>requestAnimationFrame((async()=>{try{const t=await e();r(t)}catch(e){i(e)}}))),{delay:n,signal:o}).catch(i);else{const t=new AbortController,n=requestAnimationFrame((async()=>{try{const t=await e();r(t)}catch(e){i(e)}finally{t.abort()}}));o instanceof AbortSignal&&o.addEventListener("abort",(({target:e})=>{cancelAnimationFrame(n),i(e.reason)}),{once:!0,signal:t.signal})}break;case he:if("number"==typeof n&&!Number.isNaN(n)&&n>0)me((()=>requestIdleCallback((async()=>{try{const t=await e();r(t)}catch(e){i(e)}}))),{delay:n,signal:o}).catch(i);else{const t=new AbortController,n=requestIdleCallback((async()=>{try{const t=await e();r(t)}catch(e){i(e)}finally{t.abort()}}));o instanceof AbortSignal&&o.addEventListener("abort",(({target:e})=>{cancelIdleCallback(n),i(e.reason)}),{once:!0,signal:t.signal})}break;default:throw new TypeError(`Scheduler.postTask: '${t}' (value of 'priority' member of SchedulerPostTaskOptions) is not a valid value for enumeration TaskPriority.`)}}))}}"scheduler"in globalThis||(globalThis.scheduler=new ye)
|
|
48
48
|
/**
|
|
49
49
|
* @copyright 2023 Chris Zuber <admin@kernvalley.us>
|
|
50
50
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals
|