drab 6.5.1 → 7.0.0
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/dist/announcer/index.d.ts +2 -0
- package/dist/base/index.d.ts +101 -1536
- package/dist/base/index.js +87 -76
- package/dist/contextmenu/index.d.ts +1045 -3
- package/dist/contextmenu/index.js +15 -15
- package/dist/define.d.ts +11 -1
- package/dist/define.js +11 -5
- package/dist/dialog/index.d.ts +1047 -6
- package/dist/dialog/index.js +22 -22
- package/dist/editor/index.d.ts +1047 -12
- package/dist/editor/index.js +36 -36
- package/dist/fullscreen/index.d.ts +1045 -7
- package/dist/fullscreen/index.js +8 -8
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -3
- package/dist/intersect/index.d.ts +1059 -16
- package/dist/intersect/index.js +26 -33
- package/dist/prefetch/index.d.ts +706 -25
- package/dist/prefetch/index.js +25 -44
- package/dist/share/index.d.ts +1413 -11
- package/dist/share/index.js +50 -18
- package/dist/tablesort/index.d.ts +1390 -5
- package/dist/tablesort/index.js +5 -5
- package/dist/tabs/index.d.ts +702 -4
- package/dist/tabs/index.js +3 -3
- package/dist/types/index.d.ts +29 -0
- package/dist/wakelock/index.d.ts +1390 -6
- package/dist/wakelock/index.js +16 -16
- package/package.json +5 -24
- package/dist/base/define.js +0 -3
- package/dist/copy/define.d.ts +0 -1
- package/dist/copy/define.js +0 -3
- package/dist/copy/index.d.ts +0 -30
- package/dist/copy/index.js +0 -39
- package/dist/youtube/define.d.ts +0 -1
- package/dist/youtube/define.js +0 -3
- package/dist/youtube/index.d.ts +0 -31
- package/dist/youtube/index.js +0 -56
- /package/dist/{base/define.d.ts → types/index.js} +0 -0
package/dist/wakelock/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { Announce, Content, Lifecycle, Trigger, } from "../base/index.js";
|
2
2
|
/**
|
3
3
|
* `WakeLock` uses the
|
4
4
|
* [WakeLock API](https://developer.mozilla.org/en-US/docs/Web/API/Screen_Wake_Lock_API)
|
@@ -7,7 +7,6 @@ import { Base } from "../base/index.js";
|
|
7
7
|
* that needs to stay on, or you are displaying a QR code.
|
8
8
|
*
|
9
9
|
* - Use `content` and `swap` elements to adjust the UI based on the current state.
|
10
|
-
* - `request` and `release` methods are provided to set the WakeLock with JavaScript.
|
11
10
|
* - `trigger` is disabled if not supported.
|
12
11
|
* - WakeLock is released when the element is removed from the DOM.
|
13
12
|
*
|
@@ -24,8 +23,8 @@ import { Base } from "../base/index.js";
|
|
24
23
|
* WakeLock can be toggled with a `trigger`, or will be requested if the element has
|
25
24
|
* a `locked` attribute when connected.
|
26
25
|
*/
|
27
|
-
export class WakeLock extends
|
28
|
-
wakeLock = null;
|
26
|
+
export class WakeLock extends Lifecycle(Trigger(Content(Announce()))) {
|
27
|
+
#wakeLock = null;
|
29
28
|
constructor() {
|
30
29
|
super();
|
31
30
|
}
|
@@ -34,7 +33,8 @@ export class WakeLock extends Base {
|
|
34
33
|
return "wakeLock" in navigator;
|
35
34
|
}
|
36
35
|
/**
|
37
|
-
* the `auto-lock` attribute controls whether an active WakeLock should be restored when navigating back to
|
36
|
+
* the `auto-lock` attribute controls whether an active WakeLock should be restored when navigating back to
|
37
|
+
* the page.
|
38
38
|
*/
|
39
39
|
get #autoLock() {
|
40
40
|
return this.hasAttribute("auto-lock");
|
@@ -42,42 +42,42 @@ export class WakeLock extends Base {
|
|
42
42
|
/** Requests WakeLock on the current page. */
|
43
43
|
async request() {
|
44
44
|
if (this.#wakeLockSupported() && document.visibilityState === "visible") {
|
45
|
-
this
|
45
|
+
this.#wakeLock = await navigator.wakeLock.request("screen");
|
46
46
|
this.setAttribute("locked", "");
|
47
47
|
this.announce("screen wake lock activated");
|
48
|
-
this.
|
49
|
-
this
|
48
|
+
this.swap(false);
|
49
|
+
this.#wakeLock.addEventListener("release", () => {
|
50
50
|
this.removeAttribute("locked");
|
51
51
|
this.announce("screen wake lock deactivated");
|
52
|
-
this.
|
52
|
+
this.swap(false);
|
53
53
|
if (!this.#autoLock) {
|
54
54
|
// set to null is required, used to determine if screen should be
|
55
55
|
// locked again, see visibilitychange listener
|
56
|
-
this
|
56
|
+
this.#wakeLock = null;
|
57
57
|
}
|
58
58
|
});
|
59
59
|
}
|
60
60
|
}
|
61
61
|
/** Releases the WakeLock, sets `this.wakeLock` to null. */
|
62
62
|
async release() {
|
63
|
-
await this
|
64
|
-
this
|
63
|
+
await this.#wakeLock?.release();
|
64
|
+
this.#wakeLock = null;
|
65
65
|
}
|
66
66
|
mount() {
|
67
67
|
// lock on mount if the `locked` attribute is present
|
68
68
|
if (this.hasAttribute("locked")) {
|
69
69
|
this.request();
|
70
70
|
}
|
71
|
-
this.
|
71
|
+
this.listener(() => {
|
72
72
|
// toggle
|
73
|
-
if (this
|
73
|
+
if (this.#wakeLock) {
|
74
74
|
this.release();
|
75
75
|
}
|
76
76
|
else {
|
77
77
|
this.request();
|
78
78
|
}
|
79
79
|
});
|
80
|
-
for (const trigger of this.
|
80
|
+
for (const trigger of this.triggers()) {
|
81
81
|
if (!this.#wakeLockSupported() && "disabled" in trigger) {
|
82
82
|
// disable `trigger` if not supported
|
83
83
|
trigger.disabled = true;
|
@@ -88,7 +88,7 @@ export class WakeLock extends Base {
|
|
88
88
|
// When the tab is not visible, the wakeLock is automatically released.
|
89
89
|
// This requests it back if it exists, if it is `null`, that
|
90
90
|
// means it was removed. In which case, it shouldn't be requested again.
|
91
|
-
if (this
|
91
|
+
if (this.#wakeLock) {
|
92
92
|
this.request();
|
93
93
|
}
|
94
94
|
}, document);
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "drab",
|
3
3
|
"description": "Interactivity for You",
|
4
|
-
"version": "
|
4
|
+
"version": "7.0.0",
|
5
5
|
"homepage": "https://drab.robino.dev",
|
6
6
|
"license": "MIT",
|
7
7
|
"author": {
|
@@ -12,7 +12,6 @@
|
|
12
12
|
"web components",
|
13
13
|
"custom elements",
|
14
14
|
"contextmenu",
|
15
|
-
"copy",
|
16
15
|
"dialog",
|
17
16
|
"editor",
|
18
17
|
"fullscreen",
|
@@ -21,8 +20,7 @@
|
|
21
20
|
"share",
|
22
21
|
"tablesort",
|
23
22
|
"tabs",
|
24
|
-
"wakelock"
|
25
|
-
"youtube"
|
23
|
+
"wakelock"
|
26
24
|
],
|
27
25
|
"repository": {
|
28
26
|
"type": "git",
|
@@ -55,10 +53,6 @@
|
|
55
53
|
"types": "./dist/base/index.d.ts",
|
56
54
|
"default": "./dist/base/index.js"
|
57
55
|
},
|
58
|
-
"./base/define": {
|
59
|
-
"types": "./dist/base/define.d.ts",
|
60
|
-
"default": "./dist/base/define.js"
|
61
|
-
},
|
62
56
|
"./breakpoint": {
|
63
57
|
"types": "./dist/breakpoint/index.d.ts",
|
64
58
|
"default": "./dist/breakpoint/index.js"
|
@@ -75,14 +69,6 @@
|
|
75
69
|
"types": "./dist/contextmenu/define.d.ts",
|
76
70
|
"default": "./dist/contextmenu/define.js"
|
77
71
|
},
|
78
|
-
"./copy": {
|
79
|
-
"types": "./dist/copy/index.d.ts",
|
80
|
-
"default": "./dist/copy/index.js"
|
81
|
-
},
|
82
|
-
"./copy/define": {
|
83
|
-
"types": "./dist/copy/define.d.ts",
|
84
|
-
"default": "./dist/copy/define.js"
|
85
|
-
},
|
86
72
|
"./dialog": {
|
87
73
|
"types": "./dist/dialog/index.d.ts",
|
88
74
|
"default": "./dist/dialog/index.js"
|
@@ -147,6 +133,9 @@
|
|
147
133
|
"types": "./dist/tabs/define.d.ts",
|
148
134
|
"default": "./dist/tabs/define.js"
|
149
135
|
},
|
136
|
+
"./types": {
|
137
|
+
"types": "./dist/types/index.d.ts"
|
138
|
+
},
|
150
139
|
"./wakelock": {
|
151
140
|
"types": "./dist/wakelock/index.d.ts",
|
152
141
|
"default": "./dist/wakelock/index.js"
|
@@ -154,14 +143,6 @@
|
|
154
143
|
"./wakelock/define": {
|
155
144
|
"types": "./dist/wakelock/define.d.ts",
|
156
145
|
"default": "./dist/wakelock/define.js"
|
157
|
-
},
|
158
|
-
"./youtube": {
|
159
|
-
"types": "./dist/youtube/index.d.ts",
|
160
|
-
"default": "./dist/youtube/index.js"
|
161
|
-
},
|
162
|
-
"./youtube/define": {
|
163
|
-
"types": "./dist/youtube/define.d.ts",
|
164
|
-
"default": "./dist/youtube/define.js"
|
165
146
|
}
|
166
147
|
},
|
167
148
|
"files": [
|
package/dist/base/define.js
DELETED
package/dist/copy/define.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
package/dist/copy/define.js
DELETED
package/dist/copy/index.d.ts
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
import { Base, type BaseAttributes } from "../base/index.js";
|
2
|
-
export type CopyAttributes = BaseAttributes & {
|
3
|
-
value: string;
|
4
|
-
};
|
5
|
-
/**
|
6
|
-
* Uses the
|
7
|
-
* [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText)
|
8
|
-
* to copy text.
|
9
|
-
*
|
10
|
-
* ### Attributes
|
11
|
-
*
|
12
|
-
* `value`
|
13
|
-
*
|
14
|
-
* Text to copy.
|
15
|
-
*/
|
16
|
-
export declare class Copy extends Base {
|
17
|
-
constructor();
|
18
|
-
/**
|
19
|
-
* The value to copy.
|
20
|
-
*
|
21
|
-
* @default ""
|
22
|
-
*/
|
23
|
-
get value(): string;
|
24
|
-
set value(value: string);
|
25
|
-
/**
|
26
|
-
* @param value The `value` to copy
|
27
|
-
*/
|
28
|
-
copy(value?: string): Promise<void>;
|
29
|
-
mount(): void;
|
30
|
-
}
|
package/dist/copy/index.js
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
import { Base } from "../base/index.js";
|
2
|
-
/**
|
3
|
-
* Uses the
|
4
|
-
* [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText)
|
5
|
-
* to copy text.
|
6
|
-
*
|
7
|
-
* ### Attributes
|
8
|
-
*
|
9
|
-
* `value`
|
10
|
-
*
|
11
|
-
* Text to copy.
|
12
|
-
*/
|
13
|
-
export class Copy extends Base {
|
14
|
-
constructor() {
|
15
|
-
super();
|
16
|
-
}
|
17
|
-
/**
|
18
|
-
* The value to copy.
|
19
|
-
*
|
20
|
-
* @default ""
|
21
|
-
*/
|
22
|
-
get value() {
|
23
|
-
return this.getAttribute("value") ?? "";
|
24
|
-
}
|
25
|
-
set value(value) {
|
26
|
-
this.setAttribute("value", value);
|
27
|
-
}
|
28
|
-
/**
|
29
|
-
* @param value The `value` to copy
|
30
|
-
*/
|
31
|
-
copy(value = this.value) {
|
32
|
-
this.announce("copied text to clipboard");
|
33
|
-
this.swapContent();
|
34
|
-
return navigator.clipboard.writeText(value);
|
35
|
-
}
|
36
|
-
mount() {
|
37
|
-
this.triggerListener(() => this.copy());
|
38
|
-
}
|
39
|
-
}
|
package/dist/youtube/define.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
package/dist/youtube/define.js
DELETED
package/dist/youtube/index.d.ts
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
import { Base, type BaseAttributes } from "../base/index.js";
|
2
|
-
export type YouTubeAttributes = BaseAttributes & {
|
3
|
-
autoplay?: boolean;
|
4
|
-
start?: number;
|
5
|
-
uid: string;
|
6
|
-
};
|
7
|
-
/**
|
8
|
-
* Embeds a YouTube video iframe into a website with the video uid, using www.youtube-nocookie.com.
|
9
|
-
*/
|
10
|
-
export declare class YouTube extends Base {
|
11
|
-
static observedAttributes: readonly ["autoplay", "start", "uid"];
|
12
|
-
constructor();
|
13
|
-
/** The `HTMLIFrameElement` within the element. */
|
14
|
-
get iframe(): HTMLIFrameElement;
|
15
|
-
/** Whether the video should start playing when loaded. */
|
16
|
-
get autoplay(): boolean;
|
17
|
-
set autoplay(value: boolean);
|
18
|
-
/** The start time of the video (seconds). */
|
19
|
-
get start(): string;
|
20
|
-
set start(value: string);
|
21
|
-
/**
|
22
|
-
* The video's YouTube uid, found within the url of the video.
|
23
|
-
*
|
24
|
-
* For example if the video url is https://youtu.be/gouiY85kD2o,
|
25
|
-
* the `uid` is `"gouiY85kD2o"`.
|
26
|
-
*/
|
27
|
-
get uid(): string;
|
28
|
-
set uid(v: string);
|
29
|
-
mount(): void;
|
30
|
-
attributeChangedCallback(): void;
|
31
|
-
}
|
package/dist/youtube/index.js
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
import { Base } from "../base/index.js";
|
2
|
-
/**
|
3
|
-
* Embeds a YouTube video iframe into a website with the video uid, using www.youtube-nocookie.com.
|
4
|
-
*/
|
5
|
-
export class YouTube extends Base {
|
6
|
-
static observedAttributes = ["autoplay", "start", "uid"];
|
7
|
-
constructor() {
|
8
|
-
super();
|
9
|
-
}
|
10
|
-
/** The `HTMLIFrameElement` within the element. */
|
11
|
-
get iframe() {
|
12
|
-
return this.getContent(HTMLIFrameElement);
|
13
|
-
}
|
14
|
-
/** Whether the video should start playing when loaded. */
|
15
|
-
get autoplay() {
|
16
|
-
return this.hasAttribute("autoplay");
|
17
|
-
}
|
18
|
-
set autoplay(value) {
|
19
|
-
if (value)
|
20
|
-
this.setAttribute("autoplay", "");
|
21
|
-
else
|
22
|
-
this.removeAttribute("autoplay");
|
23
|
-
}
|
24
|
-
/** The start time of the video (seconds). */
|
25
|
-
get start() {
|
26
|
-
return this.getAttribute("start") ?? "0";
|
27
|
-
}
|
28
|
-
set start(value) {
|
29
|
-
this.setAttribute("start", value);
|
30
|
-
}
|
31
|
-
/**
|
32
|
-
* The video's YouTube uid, found within the url of the video.
|
33
|
-
*
|
34
|
-
* For example if the video url is https://youtu.be/gouiY85kD2o,
|
35
|
-
* the `uid` is `"gouiY85kD2o"`.
|
36
|
-
*/
|
37
|
-
get uid() {
|
38
|
-
const uid = this.getAttribute("uid");
|
39
|
-
if (!uid)
|
40
|
-
throw new Error("YouTube: missing `uid` attribute.");
|
41
|
-
return uid;
|
42
|
-
}
|
43
|
-
set uid(v) {
|
44
|
-
this.setAttribute("uid", v);
|
45
|
-
}
|
46
|
-
mount() {
|
47
|
-
this.iframe.allowFullscreen = true;
|
48
|
-
this.iframe.allow =
|
49
|
-
"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture";
|
50
|
-
}
|
51
|
-
attributeChangedCallback() {
|
52
|
-
queueMicrotask(() => {
|
53
|
-
this.iframe.src = `https://www.youtube-nocookie.com/embed/${this.uid}?start=${this.start}${this.autoplay ? "&autoplay=1" : ""}`;
|
54
|
-
});
|
55
|
-
}
|
56
|
-
}
|
File without changes
|