@jait/gateway 0.1.255 → 0.1.257
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/routes/git.d.ts.map +1 -1
- package/dist/routes/git.js +58 -0
- package/dist/routes/git.js.map +1 -1
- package/dist/routes/preview.d.ts.map +1 -1
- package/dist/routes/preview.js +39 -0
- package/dist/routes/preview.js.map +1 -1
- package/dist/security/sandbox-manager.d.ts +1 -0
- package/dist/security/sandbox-manager.d.ts.map +1 -1
- package/dist/security/sandbox-manager.js +11 -0
- package/dist/security/sandbox-manager.js.map +1 -1
- package/dist/services/git.d.ts +11 -0
- package/dist/services/git.d.ts.map +1 -1
- package/dist/services/git.js +37 -0
- package/dist/services/git.js.map +1 -1
- package/dist/services/live-view-manager.d.ts +20 -0
- package/dist/services/live-view-manager.d.ts.map +1 -0
- package/dist/services/live-view-manager.js +114 -0
- package/dist/services/live-view-manager.js.map +1 -0
- package/dist/services/preview.d.ts +16 -1
- package/dist/services/preview.d.ts.map +1 -1
- package/dist/services/preview.js +112 -2
- package/dist/services/preview.js.map +1 -1
- package/dist/surfaces/browser.d.ts +12 -0
- package/dist/surfaces/browser.d.ts.map +1 -1
- package/dist/surfaces/browser.js +31 -1
- package/dist/surfaces/browser.js.map +1 -1
- package/dist/tools/preview-tools.d.ts.map +1 -1
- package/dist/tools/preview-tools.js.map +1 -1
- package/package.json +1 -1
- package/web-dist/assets/{_basePickBy-BjvMP2af.js → _basePickBy-B2KkoWFz.js} +1 -1
- package/web-dist/assets/{_baseUniq-CQbQ6NgV.js → _baseUniq-DFNflT4F.js} +1 -1
- package/web-dist/assets/{arc-D3KRIJWu.js → arc-C7JI0CHt.js} +1 -1
- package/web-dist/assets/{architectureDiagram-2XIMDMQ5-DM3fcOkr.js → architectureDiagram-2XIMDMQ5-bI95Cgh9.js} +1 -1
- package/web-dist/assets/{blockDiagram-WCTKOSBZ-B-9Vjl98.js → blockDiagram-WCTKOSBZ-DgfGN-sd.js} +1 -1
- package/web-dist/assets/{c4Diagram-IC4MRINW-CTu2yYlj.js → c4Diagram-IC4MRINW-xM9CGMLf.js} +1 -1
- package/web-dist/assets/channel-otEtLTdD.js +1 -0
- package/web-dist/assets/{chunk-4BX2VUAB-ZDQu0uWO.js → chunk-4BX2VUAB-C66ZLhus.js} +1 -1
- package/web-dist/assets/{chunk-55IACEB6-YtzMmlzY.js → chunk-55IACEB6-ByPuHMYM.js} +1 -1
- package/web-dist/assets/{chunk-FMBD7UC4-BsIyXbSx.js → chunk-FMBD7UC4-CMH4hMhI.js} +1 -1
- package/web-dist/assets/{chunk-JSJVCQXG-CfudXyS3.js → chunk-JSJVCQXG-BJLuo8dM.js} +1 -1
- package/web-dist/assets/{chunk-KX2RTZJC-B-fQrx3o.js → chunk-KX2RTZJC-CU0ZE2mJ.js} +1 -1
- package/web-dist/assets/{chunk-NQ4KR5QH-DzmNoENv.js → chunk-NQ4KR5QH-CD4JSx3E.js} +1 -1
- package/web-dist/assets/{chunk-QZHKN3VN-DtkgvjXx.js → chunk-QZHKN3VN-BhZcwDDX.js} +1 -1
- package/web-dist/assets/{chunk-WL4C6EOR-BCxmVwuX.js → chunk-WL4C6EOR-CScYiORQ.js} +1 -1
- package/web-dist/assets/classDiagram-VBA2DB6C-D3uA1Ef5.js +1 -0
- package/web-dist/assets/classDiagram-v2-RAHNMMFH-D3uA1Ef5.js +1 -0
- package/web-dist/assets/clone-CAAX5MRw.js +1 -0
- package/web-dist/assets/{cose-bilkent-S5V4N54A-Ixga3b-M.js → cose-bilkent-S5V4N54A-DTphha5A.js} +1 -1
- package/web-dist/assets/{dagre-KLK3FWXG-CXoAVVKA.js → dagre-KLK3FWXG-Dm5HIzgU.js} +1 -1
- package/web-dist/assets/{diagram-E7M64L7V-CcBLNXz0.js → diagram-E7M64L7V-BafxXR5t.js} +1 -1
- package/web-dist/assets/{diagram-IFDJBPK2-6gwd3HNI.js → diagram-IFDJBPK2-DDMAYAl_.js} +1 -1
- package/web-dist/assets/{diagram-P4PSJMXO-CAXp9Quj.js → diagram-P4PSJMXO-DHvyv48k.js} +1 -1
- package/web-dist/assets/{erDiagram-INFDFZHY-C6p1MF8r.js → erDiagram-INFDFZHY-B_xrbbBo.js} +1 -1
- package/web-dist/assets/{flowDiagram-PKNHOUZH-B2M24TQ4.js → flowDiagram-PKNHOUZH-CRcTFuaU.js} +1 -1
- package/web-dist/assets/{ganttDiagram-A5KZAMGK-CmKwfSN8.js → ganttDiagram-A5KZAMGK-CeIGrgW3.js} +1 -1
- package/web-dist/assets/{gitGraphDiagram-K3NZZRJ6-f6_FZnF_.js → gitGraphDiagram-K3NZZRJ6-B8p3GzsB.js} +1 -1
- package/web-dist/assets/{graph-X0lqls-x.js → graph-DgPXX2YH.js} +1 -1
- package/web-dist/assets/{index-DnSc9BPB.js → index-Dyq1wR8W.js} +307 -307
- package/web-dist/assets/{infoDiagram-LFFYTUFH-59VZJVF5.js → infoDiagram-LFFYTUFH-C1EleBwJ.js} +1 -1
- package/web-dist/assets/{ishikawaDiagram-PHBUUO56-BEy0oxW6.js → ishikawaDiagram-PHBUUO56-CY7B0Af8.js} +1 -1
- package/web-dist/assets/{journeyDiagram-4ABVD52K-BDulB1lR.js → journeyDiagram-4ABVD52K-BEbad9lw.js} +1 -1
- package/web-dist/assets/{kanban-definition-K7BYSVSG-Cx1576bJ.js → kanban-definition-K7BYSVSG-PmiPROs_.js} +1 -1
- package/web-dist/assets/{layout-C7p8zLip.js → layout-u4nQqZo9.js} +1 -1
- package/web-dist/assets/{linear-C7lgV0KB.js → linear-CYNrNanw.js} +1 -1
- package/web-dist/assets/{mindmap-definition-YRQLILUH-B0aaRwFC.js → mindmap-definition-YRQLILUH-Ch-jh05Z.js} +1 -1
- package/web-dist/assets/{pieDiagram-SKSYHLDU-BrlmIbXe.js → pieDiagram-SKSYHLDU-ypmvYTXD.js} +1 -1
- package/web-dist/assets/{quadrantDiagram-337W2JSQ-BwXx6zzR.js → quadrantDiagram-337W2JSQ-Butg8Ecg.js} +1 -1
- package/web-dist/assets/{requirementDiagram-Z7DCOOCP-kUdwkQkY.js → requirementDiagram-Z7DCOOCP-nj6Myt9w.js} +1 -1
- package/web-dist/assets/{sankeyDiagram-WA2Y5GQK-Dkpg3nlZ.js → sankeyDiagram-WA2Y5GQK-DPAF8v8e.js} +1 -1
- package/web-dist/assets/{sequenceDiagram-2WXFIKYE-CyZv4rLL.js → sequenceDiagram-2WXFIKYE-DVyGYemI.js} +1 -1
- package/web-dist/assets/{stateDiagram-RAJIS63D-CZbnLN4N.js → stateDiagram-RAJIS63D-CstalmXc.js} +1 -1
- package/web-dist/assets/stateDiagram-v2-FVOUBMTO-DidQo5W_.js +1 -0
- package/web-dist/assets/{timeline-definition-YZTLITO2-BSFBZK4o.js → timeline-definition-YZTLITO2-D0D_Mp_k.js} +1 -1
- package/web-dist/assets/{treemap-KZPCXAKY-Bhm8QcdX.js → treemap-KZPCXAKY-C9RoKRs9.js} +1 -1
- package/web-dist/assets/{vennDiagram-LZ73GAT5-CamPCKoy.js → vennDiagram-LZ73GAT5-r2eoeYH9.js} +1 -1
- package/web-dist/assets/{xychartDiagram-JWTSCODW-BgY7GIM5.js → xychartDiagram-JWTSCODW-CdE4gaJ1.js} +1 -1
- package/web-dist/index.html +1 -1
- package/web-dist/noVNC/LICENSE.txt +62 -0
- package/web-dist/noVNC/app/error-handler.js +79 -0
- package/web-dist/noVNC/app/images/alt.svg +92 -0
- package/web-dist/noVNC/app/images/clipboard.svg +106 -0
- package/web-dist/noVNC/app/images/connect.svg +96 -0
- package/web-dist/noVNC/app/images/ctrl.svg +96 -0
- package/web-dist/noVNC/app/images/ctrlaltdel.svg +100 -0
- package/web-dist/noVNC/app/images/disconnect.svg +94 -0
- package/web-dist/noVNC/app/images/drag.svg +76 -0
- package/web-dist/noVNC/app/images/error.svg +81 -0
- package/web-dist/noVNC/app/images/esc.svg +92 -0
- package/web-dist/noVNC/app/images/expander.svg +69 -0
- package/web-dist/noVNC/app/images/fullscreen.svg +93 -0
- package/web-dist/noVNC/app/images/handle.svg +82 -0
- package/web-dist/noVNC/app/images/handle_bg.svg +172 -0
- package/web-dist/noVNC/app/images/icons/Makefile +42 -0
- package/web-dist/noVNC/app/images/icons/novnc-icon-sm.svg +163 -0
- package/web-dist/noVNC/app/images/icons/novnc-icon.svg +163 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-120.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-152.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-167.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-180.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-40.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-58.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-60.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-80.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-87.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-icon.svg +183 -0
- package/web-dist/noVNC/app/images/icons/novnc.ico +0 -0
- package/web-dist/noVNC/app/images/info.svg +81 -0
- package/web-dist/noVNC/app/images/keyboard.svg +88 -0
- package/web-dist/noVNC/app/images/power.svg +87 -0
- package/web-dist/noVNC/app/images/settings.svg +76 -0
- package/web-dist/noVNC/app/images/tab.svg +86 -0
- package/web-dist/noVNC/app/images/toggleextrakeys.svg +90 -0
- package/web-dist/noVNC/app/images/warning.svg +81 -0
- package/web-dist/noVNC/app/images/windows.svg +65 -0
- package/web-dist/noVNC/app/locale/README +1 -0
- package/web-dist/noVNC/app/locale/cs.json +71 -0
- package/web-dist/noVNC/app/locale/de.json +74 -0
- package/web-dist/noVNC/app/locale/el.json +100 -0
- package/web-dist/noVNC/app/locale/es.json +68 -0
- package/web-dist/noVNC/app/locale/fr.json +82 -0
- package/web-dist/noVNC/app/locale/hu.json +80 -0
- package/web-dist/noVNC/app/locale/it.json +68 -0
- package/web-dist/noVNC/app/locale/ja.json +81 -0
- package/web-dist/noVNC/app/locale/ko.json +70 -0
- package/web-dist/noVNC/app/locale/nl.json +95 -0
- package/web-dist/noVNC/app/locale/pl.json +80 -0
- package/web-dist/noVNC/app/locale/pt_BR.json +72 -0
- package/web-dist/noVNC/app/locale/ru.json +72 -0
- package/web-dist/noVNC/app/locale/sv.json +83 -0
- package/web-dist/noVNC/app/locale/tr.json +69 -0
- package/web-dist/noVNC/app/locale/uk.json +81 -0
- package/web-dist/noVNC/app/locale/zh_CN.json +93 -0
- package/web-dist/noVNC/app/locale/zh_TW.json +69 -0
- package/web-dist/noVNC/app/localization.js +206 -0
- package/web-dist/noVNC/app/sounds/CREDITS +4 -0
- package/web-dist/noVNC/app/sounds/bell.mp3 +0 -0
- package/web-dist/noVNC/app/sounds/bell.oga +0 -0
- package/web-dist/noVNC/app/styles/Orbitron700.ttf +0 -0
- package/web-dist/noVNC/app/styles/Orbitron700.woff +0 -0
- package/web-dist/noVNC/app/styles/base.css +927 -0
- package/web-dist/noVNC/app/styles/constants.css +30 -0
- package/web-dist/noVNC/app/styles/input.css +628 -0
- package/web-dist/noVNC/app/ui.js +1873 -0
- package/web-dist/noVNC/app/wakelock.js +199 -0
- package/web-dist/noVNC/app/webutil.js +250 -0
- package/web-dist/noVNC/core/base64.js +104 -0
- package/web-dist/noVNC/core/clipboard.js +72 -0
- package/web-dist/noVNC/core/crypto/aes.js +178 -0
- package/web-dist/noVNC/core/crypto/bigint.js +34 -0
- package/web-dist/noVNC/core/crypto/crypto.js +90 -0
- package/web-dist/noVNC/core/crypto/des.js +330 -0
- package/web-dist/noVNC/core/crypto/dh.js +55 -0
- package/web-dist/noVNC/core/crypto/md5.js +82 -0
- package/web-dist/noVNC/core/crypto/rsa.js +132 -0
- package/web-dist/noVNC/core/decoders/copyrect.js +27 -0
- package/web-dist/noVNC/core/decoders/h264.js +321 -0
- package/web-dist/noVNC/core/decoders/hextile.js +181 -0
- package/web-dist/noVNC/core/decoders/jpeg.js +161 -0
- package/web-dist/noVNC/core/decoders/raw.js +59 -0
- package/web-dist/noVNC/core/decoders/rre.js +44 -0
- package/web-dist/noVNC/core/decoders/tight.js +393 -0
- package/web-dist/noVNC/core/decoders/tightpng.js +27 -0
- package/web-dist/noVNC/core/decoders/zlib.js +51 -0
- package/web-dist/noVNC/core/decoders/zrle.js +185 -0
- package/web-dist/noVNC/core/deflator.js +84 -0
- package/web-dist/noVNC/core/display.js +578 -0
- package/web-dist/noVNC/core/encodings.js +54 -0
- package/web-dist/noVNC/core/inflator.js +65 -0
- package/web-dist/noVNC/core/input/domkeytable.js +311 -0
- package/web-dist/noVNC/core/input/fixedkeys.js +129 -0
- package/web-dist/noVNC/core/input/gesturehandler.js +567 -0
- package/web-dist/noVNC/core/input/keyboard.js +294 -0
- package/web-dist/noVNC/core/input/keysym.js +616 -0
- package/web-dist/noVNC/core/input/keysymdef.js +688 -0
- package/web-dist/noVNC/core/input/util.js +191 -0
- package/web-dist/noVNC/core/input/vkeys.js +116 -0
- package/web-dist/noVNC/core/input/xtscancodes.js +173 -0
- package/web-dist/noVNC/core/ra2.js +312 -0
- package/web-dist/noVNC/core/rfb.js +3426 -0
- package/web-dist/noVNC/core/util/browser.js +266 -0
- package/web-dist/noVNC/core/util/cursor.js +249 -0
- package/web-dist/noVNC/core/util/element.js +32 -0
- package/web-dist/noVNC/core/util/events.js +138 -0
- package/web-dist/noVNC/core/util/eventtarget.js +35 -0
- package/web-dist/noVNC/core/util/int.js +15 -0
- package/web-dist/noVNC/core/util/logging.js +56 -0
- package/web-dist/noVNC/core/util/strings.js +28 -0
- package/web-dist/noVNC/core/websock.js +369 -0
- package/web-dist/noVNC/defaults.json +1 -0
- package/web-dist/noVNC/mandatory.json +1 -0
- package/web-dist/noVNC/vendor/pako/LICENSE +21 -0
- package/web-dist/noVNC/vendor/pako/README.md +6 -0
- package/web-dist/noVNC/vendor/pako/lib/utils/common.js +45 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/adler32.js +27 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/constants.js +47 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/crc32.js +36 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/deflate.js +1846 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/gzheader.js +35 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/inffast.js +324 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/inflate.js +1527 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/inftrees.js +322 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/messages.js +11 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/trees.js +1195 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/zstream.js +24 -0
- package/web-dist/noVNC/vnc_lite.html +180 -0
- package/web-dist/assets/channel-r3VxZeIf.js +0 -1
- package/web-dist/assets/classDiagram-VBA2DB6C-BRBktPwb.js +0 -1
- package/web-dist/assets/classDiagram-v2-RAHNMMFH-BRBktPwb.js +0 -1
- package/web-dist/assets/clone-rt9RfsvE.js +0 -1
- package/web-dist/assets/stateDiagram-v2-FVOUBMTO-C28Nk4KM.js +0 -1
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* noVNC: HTML5 VNC client
|
|
3
|
+
* Copyright (C) 2025 The noVNC authors
|
|
4
|
+
* Licensed under MPL 2.0 or any later version (see LICENSE.txt)
|
|
5
|
+
*
|
|
6
|
+
* Wrapper around the `navigator.wakeLock` api that handles reacquiring the
|
|
7
|
+
* lock on visiblility changes.
|
|
8
|
+
*
|
|
9
|
+
* The `acquire` and `release` methods may be called any number of times. The
|
|
10
|
+
* most recent call dictates the desired end-state (if `acquire` was most
|
|
11
|
+
* recently called, then we will try to acquire and hold the wake lock).
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import * as Log from '../core/util/logging.js';
|
|
15
|
+
|
|
16
|
+
const _STATES = {
|
|
17
|
+
/* No wake lock.
|
|
18
|
+
*
|
|
19
|
+
* Can transition to:
|
|
20
|
+
* - AWAITING_VISIBLE: `acquire` called when document is hidden.
|
|
21
|
+
* - ACQUIRING: `acquire` called.
|
|
22
|
+
* - ERROR: `acquired` called when the api is not available.
|
|
23
|
+
*/
|
|
24
|
+
RELEASED: 'released',
|
|
25
|
+
/* Wake lock requested, waiting for browser.
|
|
26
|
+
*
|
|
27
|
+
* Can transition to:
|
|
28
|
+
* - ACQUIRED: success
|
|
29
|
+
* - ACQUIRING_WANT_RELEASE: `release` called while waiting
|
|
30
|
+
* - ERROR
|
|
31
|
+
*/
|
|
32
|
+
ACQUIRING: 'acquiring',
|
|
33
|
+
/* Wake lock requested, release called, still waiting for browser.
|
|
34
|
+
*
|
|
35
|
+
* Can transition to:
|
|
36
|
+
* - ACQUIRING: `acquire` called (but promise has not resolved yet)
|
|
37
|
+
* - RELEASED: success
|
|
38
|
+
*/
|
|
39
|
+
ACQUIRING_WANT_RELEASE: 'releasing',
|
|
40
|
+
/* Wake lock held.
|
|
41
|
+
*
|
|
42
|
+
* Can transition to:
|
|
43
|
+
* - AWAITING_VISIBLE: wakelock lost due to visibility change
|
|
44
|
+
* - RELEASED: success
|
|
45
|
+
*/
|
|
46
|
+
ACQUIRED: 'acquired',
|
|
47
|
+
/* Caller wants wakelock, but we can not get it due to visibility.
|
|
48
|
+
*
|
|
49
|
+
* Can transition to:
|
|
50
|
+
* - ACQUIRING: document is now visible, attempting to get wakelock.
|
|
51
|
+
* - RELEASED: when release is called.
|
|
52
|
+
*/
|
|
53
|
+
AWAITING_VISIBLE: 'awaiting_visible',
|
|
54
|
+
/* An error has occurred.
|
|
55
|
+
*
|
|
56
|
+
* Can transition to:
|
|
57
|
+
* - RELEASED: will happen immediately.
|
|
58
|
+
*/
|
|
59
|
+
ERROR: 'error',
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
class TestOnlyWakeLockManagerStateChangeEvent extends Event {
|
|
63
|
+
constructor(oldState, newState) {
|
|
64
|
+
super("testOnlyStateChange");
|
|
65
|
+
this.oldState = oldState;
|
|
66
|
+
this.newState = newState;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default class WakeLockManager extends EventTarget {
|
|
71
|
+
constructor() {
|
|
72
|
+
super();
|
|
73
|
+
|
|
74
|
+
this._state = _STATES.RELEASED;
|
|
75
|
+
this._wakelock = null;
|
|
76
|
+
|
|
77
|
+
this._eventHandlers = {
|
|
78
|
+
wakelockAcquired: this._wakelockAcquired.bind(this),
|
|
79
|
+
wakelockReleased: this._wakelockReleased.bind(this),
|
|
80
|
+
documentVisibilityChange: this._documentVisibilityChange.bind(this),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
acquire() {
|
|
85
|
+
switch (this._state) {
|
|
86
|
+
case _STATES.ACQUIRING_WANT_RELEASE:
|
|
87
|
+
// We are currently waiting to acquire the wakelock. While
|
|
88
|
+
// waiting, `release()` was called. By transitioning back to
|
|
89
|
+
// ACQUIRING, we will keep the lock after we receive it.
|
|
90
|
+
this._transitionTo(_STATES.ACQUIRING);
|
|
91
|
+
break;
|
|
92
|
+
case _STATES.AWAITING_VISIBLE:
|
|
93
|
+
case _STATES.ACQUIRING:
|
|
94
|
+
case _STATES.ACQUIRED:
|
|
95
|
+
break;
|
|
96
|
+
case _STATES.ERROR:
|
|
97
|
+
case _STATES.RELEASED:
|
|
98
|
+
if (document.hidden) {
|
|
99
|
+
// We can not acquire the wakelock while the document is
|
|
100
|
+
// hidden (eg, not the active tab). Wait until it is
|
|
101
|
+
// visible, then acquire the wakelock.
|
|
102
|
+
this._awaitVisible();
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
this._acquireWakelockNow();
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
release() {
|
|
111
|
+
switch (this._state) {
|
|
112
|
+
case _STATES.ERROR:
|
|
113
|
+
case _STATES.RELEASED:
|
|
114
|
+
case _STATES.ACQUIRING_WANT_RELEASE:
|
|
115
|
+
break;
|
|
116
|
+
case _STATES.ACQUIRING:
|
|
117
|
+
// We are have requested (but not yet received) the wakelock.
|
|
118
|
+
// Give it up as soon as we acquire it.
|
|
119
|
+
this._transitionTo(_STATES.ACQUIRING_WANT_RELEASE);
|
|
120
|
+
break;
|
|
121
|
+
case _STATES.ACQUIRED:
|
|
122
|
+
// We remove the event listener first, as we don't want to be
|
|
123
|
+
// notified about this release (it is expected).
|
|
124
|
+
this._wakelock.removeEventListener("release", this._eventHandlers.wakelockReleased);
|
|
125
|
+
this._wakelock.release();
|
|
126
|
+
this._wakelock = null;
|
|
127
|
+
this._transitionTo(_STATES.RELEASED);
|
|
128
|
+
break;
|
|
129
|
+
case _STATES.AWAITING_VISIBLE:
|
|
130
|
+
// We don't currently have the lock, but are waiting for the
|
|
131
|
+
// document to become visible. By removing the event listener,
|
|
132
|
+
// we will not attempt to get the wakelock in the future.
|
|
133
|
+
document.removeEventListener("visibilitychange", this._eventHandlers.documentVisibilityChange);
|
|
134
|
+
this._transitionTo(_STATES.RELEASED);
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
_transitionTo(newState) {
|
|
140
|
+
let oldState = this._state;
|
|
141
|
+
Log.Debug(`WakelockManager transitioning ${oldState} -> ${newState}`);
|
|
142
|
+
this._state = newState;
|
|
143
|
+
this.dispatchEvent(new TestOnlyWakeLockManagerStateChangeEvent(oldState, newState));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
_awaitVisible() {
|
|
147
|
+
document.addEventListener("visibilitychange", this._eventHandlers.documentVisibilityChange);
|
|
148
|
+
this._transitionTo(_STATES.AWAITING_VISIBLE);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
_acquireWakelockNow() {
|
|
152
|
+
if (!("wakeLock" in navigator)) {
|
|
153
|
+
Log.Warn("Unable to request wakeLock, Browser does not have wakeLock api");
|
|
154
|
+
this._transitionTo(_STATES.ERROR);
|
|
155
|
+
this._transitionTo(_STATES.RELEASED);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
navigator.wakeLock.request("screen")
|
|
159
|
+
.then(this._eventHandlers.wakelockAcquired)
|
|
160
|
+
.catch((err) => {
|
|
161
|
+
Log.Warn("Error occurred while acquiring wakelock: " + err);
|
|
162
|
+
this._transitionTo(_STATES.ERROR);
|
|
163
|
+
this._transitionTo(_STATES.RELEASED);
|
|
164
|
+
});
|
|
165
|
+
this._transitionTo(_STATES.ACQUIRING);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
_wakelockAcquired(wakelock) {
|
|
170
|
+
if (this._state === _STATES.ACQUIRING_WANT_RELEASE) {
|
|
171
|
+
// We were requested to release the wakelock while we were trying to
|
|
172
|
+
// acquire it. Now that we have acquired it, immediately release it.
|
|
173
|
+
wakelock.release();
|
|
174
|
+
this._transitionTo(_STATES.RELEASED);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
this._wakelock = wakelock;
|
|
178
|
+
this._wakelock.addEventListener("release", this._eventHandlers.wakelockReleased);
|
|
179
|
+
this._transitionTo(_STATES.ACQUIRED);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
_wakelockReleased(event) {
|
|
183
|
+
this._wakelock = null;
|
|
184
|
+
if (document.visibilityState === "visible") {
|
|
185
|
+
Log.Warn("Lost wakelock, but document is still visible. Not reacquiring");
|
|
186
|
+
this._transitionTo(_STATES.RELEASED);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
this._awaitVisible();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
_documentVisibilityChange(event) {
|
|
193
|
+
if (document.visibilityState !== "visible") {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
document.removeEventListener("visibilitychange", this._eventHandlers.documentVisibilityChange);
|
|
197
|
+
this._acquireWakelockNow();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* noVNC: HTML5 VNC client
|
|
3
|
+
* Copyright (C) 2019 The noVNC authors
|
|
4
|
+
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
5
|
+
*
|
|
6
|
+
* See README.md for usage and integration instructions.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import * as Log from '../core/util/logging.js';
|
|
10
|
+
|
|
11
|
+
// init log level reading the logging HTTP param
|
|
12
|
+
export function initLogging(level) {
|
|
13
|
+
"use strict";
|
|
14
|
+
if (typeof level !== "undefined") {
|
|
15
|
+
Log.initLogging(level);
|
|
16
|
+
} else {
|
|
17
|
+
const param = document.location.href.match(/logging=([A-Za-z0-9._-]*)/);
|
|
18
|
+
Log.initLogging(param || undefined);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Read a query string variable
|
|
23
|
+
// A URL with a query parameter can look like this (But will most probably get logged on the http server):
|
|
24
|
+
// https://www.example.com?myqueryparam=myvalue
|
|
25
|
+
//
|
|
26
|
+
// For privacy (Using a hastag #, the parameters will not be sent to the server)
|
|
27
|
+
// the url can be requested in the following way:
|
|
28
|
+
// https://www.example.com#myqueryparam=myvalue&password=secretvalue
|
|
29
|
+
//
|
|
30
|
+
// Even mixing public and non public parameters will work:
|
|
31
|
+
// https://www.example.com?nonsecretparam=example.com#password=secretvalue
|
|
32
|
+
export function getQueryVar(name, defVal) {
|
|
33
|
+
"use strict";
|
|
34
|
+
const re = new RegExp('.*[?&]' + name + '=([^&#]*)'),
|
|
35
|
+
match = document.location.href.match(re);
|
|
36
|
+
if (typeof defVal === 'undefined') { defVal = null; }
|
|
37
|
+
|
|
38
|
+
if (match) {
|
|
39
|
+
return decodeURIComponent(match[1]);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return defVal;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Read a hash fragment variable
|
|
46
|
+
export function getHashVar(name, defVal) {
|
|
47
|
+
"use strict";
|
|
48
|
+
const re = new RegExp('.*[&#]' + name + '=([^&]*)'),
|
|
49
|
+
match = document.location.hash.match(re);
|
|
50
|
+
if (typeof defVal === 'undefined') { defVal = null; }
|
|
51
|
+
|
|
52
|
+
if (match) {
|
|
53
|
+
return decodeURIComponent(match[1]);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return defVal;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Read a variable from the fragment or the query string
|
|
60
|
+
// Fragment takes precedence
|
|
61
|
+
export function getConfigVar(name, defVal) {
|
|
62
|
+
"use strict";
|
|
63
|
+
const val = getHashVar(name);
|
|
64
|
+
|
|
65
|
+
if (val === null) {
|
|
66
|
+
return getQueryVar(name, defVal);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return val;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/*
|
|
73
|
+
* Cookie handling. Dervied from: http://www.quirksmode.org/js/cookies.html
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
// No days means only for this browser session
|
|
77
|
+
export function createCookie(name, value, days) {
|
|
78
|
+
"use strict";
|
|
79
|
+
let date, expires;
|
|
80
|
+
if (days) {
|
|
81
|
+
date = new Date();
|
|
82
|
+
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
|
83
|
+
expires = "; expires=" + date.toGMTString();
|
|
84
|
+
} else {
|
|
85
|
+
expires = "";
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
let secure;
|
|
89
|
+
if (document.location.protocol === "https:") {
|
|
90
|
+
secure = "; secure";
|
|
91
|
+
} else {
|
|
92
|
+
secure = "";
|
|
93
|
+
}
|
|
94
|
+
document.cookie = name + "=" + value + expires + "; path=/" + secure;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function readCookie(name, defaultValue) {
|
|
98
|
+
"use strict";
|
|
99
|
+
const nameEQ = name + "=";
|
|
100
|
+
const ca = document.cookie.split(';');
|
|
101
|
+
|
|
102
|
+
for (let i = 0; i < ca.length; i += 1) {
|
|
103
|
+
let c = ca[i];
|
|
104
|
+
while (c.charAt(0) === ' ') {
|
|
105
|
+
c = c.substring(1, c.length);
|
|
106
|
+
}
|
|
107
|
+
if (c.indexOf(nameEQ) === 0) {
|
|
108
|
+
return c.substring(nameEQ.length, c.length);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return (typeof defaultValue !== 'undefined') ? defaultValue : null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function eraseCookie(name) {
|
|
116
|
+
"use strict";
|
|
117
|
+
createCookie(name, "", -1);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/*
|
|
121
|
+
* Setting handling.
|
|
122
|
+
*/
|
|
123
|
+
|
|
124
|
+
let settings = {};
|
|
125
|
+
|
|
126
|
+
export function initSettings() {
|
|
127
|
+
if (!window.chrome || !window.chrome.storage) {
|
|
128
|
+
settings = {};
|
|
129
|
+
return Promise.resolve();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return new Promise(resolve => window.chrome.storage.sync.get(resolve))
|
|
133
|
+
.then((cfg) => { settings = cfg; });
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Update the settings cache, but do not write to permanent storage
|
|
137
|
+
export function setSetting(name, value) {
|
|
138
|
+
settings[name] = value;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// No days means only for this browser session
|
|
142
|
+
export function writeSetting(name, value) {
|
|
143
|
+
"use strict";
|
|
144
|
+
if (settings[name] === value) return;
|
|
145
|
+
settings[name] = value;
|
|
146
|
+
if (window.chrome && window.chrome.storage) {
|
|
147
|
+
window.chrome.storage.sync.set(settings);
|
|
148
|
+
} else {
|
|
149
|
+
localStorageSet(name, value);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export function readSetting(name, defaultValue) {
|
|
154
|
+
"use strict";
|
|
155
|
+
let value;
|
|
156
|
+
if ((name in settings) || (window.chrome && window.chrome.storage)) {
|
|
157
|
+
value = settings[name];
|
|
158
|
+
} else {
|
|
159
|
+
value = localStorageGet(name);
|
|
160
|
+
settings[name] = value;
|
|
161
|
+
}
|
|
162
|
+
if (typeof value === "undefined") {
|
|
163
|
+
value = null;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (value === null && typeof defaultValue !== "undefined") {
|
|
167
|
+
return defaultValue;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return value;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export function eraseSetting(name) {
|
|
174
|
+
"use strict";
|
|
175
|
+
// Deleting here means that next time the setting is read when using local
|
|
176
|
+
// storage, it will be pulled from local storage again.
|
|
177
|
+
// If the setting in local storage is changed (e.g. in another tab)
|
|
178
|
+
// between this delete and the next read, it could lead to an unexpected
|
|
179
|
+
// value change.
|
|
180
|
+
delete settings[name];
|
|
181
|
+
if (window.chrome && window.chrome.storage) {
|
|
182
|
+
window.chrome.storage.sync.remove(name);
|
|
183
|
+
} else {
|
|
184
|
+
localStorageRemove(name);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
let loggedMsgs = [];
|
|
189
|
+
function logOnce(msg, level = "warn") {
|
|
190
|
+
if (!loggedMsgs.includes(msg)) {
|
|
191
|
+
switch (level) {
|
|
192
|
+
case "error":
|
|
193
|
+
Log.Error(msg);
|
|
194
|
+
break;
|
|
195
|
+
case "warn":
|
|
196
|
+
Log.Warn(msg);
|
|
197
|
+
break;
|
|
198
|
+
case "debug":
|
|
199
|
+
Log.Debug(msg);
|
|
200
|
+
break;
|
|
201
|
+
default:
|
|
202
|
+
Log.Info(msg);
|
|
203
|
+
}
|
|
204
|
+
loggedMsgs.push(msg);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
let cookiesMsg = "Couldn't access noVNC settings, are cookies disabled?";
|
|
209
|
+
|
|
210
|
+
function localStorageGet(name) {
|
|
211
|
+
let r;
|
|
212
|
+
try {
|
|
213
|
+
r = localStorage.getItem(name);
|
|
214
|
+
} catch (e) {
|
|
215
|
+
if (e instanceof DOMException) {
|
|
216
|
+
logOnce(cookiesMsg);
|
|
217
|
+
logOnce("'localStorage.getItem(" + name + ")' failed: " + e,
|
|
218
|
+
"debug");
|
|
219
|
+
} else {
|
|
220
|
+
throw e;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return r;
|
|
224
|
+
}
|
|
225
|
+
function localStorageSet(name, value) {
|
|
226
|
+
try {
|
|
227
|
+
localStorage.setItem(name, value);
|
|
228
|
+
} catch (e) {
|
|
229
|
+
if (e instanceof DOMException) {
|
|
230
|
+
logOnce(cookiesMsg);
|
|
231
|
+
logOnce("'localStorage.setItem(" + name + "," + value +
|
|
232
|
+
")' failed: " + e, "debug");
|
|
233
|
+
} else {
|
|
234
|
+
throw e;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function localStorageRemove(name) {
|
|
239
|
+
try {
|
|
240
|
+
localStorage.removeItem(name);
|
|
241
|
+
} catch (e) {
|
|
242
|
+
if (e instanceof DOMException) {
|
|
243
|
+
logOnce(cookiesMsg);
|
|
244
|
+
logOnce("'localStorage.removeItem(" + name + ")' failed: " + e,
|
|
245
|
+
"debug");
|
|
246
|
+
} else {
|
|
247
|
+
throw e;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
4
|
+
|
|
5
|
+
// From: http://hg.mozilla.org/mozilla-central/raw-file/ec10630b1a54/js/src/devtools/jint/sunspider/string-base64.js
|
|
6
|
+
|
|
7
|
+
import * as Log from './util/logging.js';
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
/* Convert data (an array of integers) to a Base64 string. */
|
|
11
|
+
toBase64Table: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split(''),
|
|
12
|
+
base64Pad: '=',
|
|
13
|
+
|
|
14
|
+
encode(data) {
|
|
15
|
+
"use strict";
|
|
16
|
+
let result = '';
|
|
17
|
+
const length = data.length;
|
|
18
|
+
const lengthpad = (length % 3);
|
|
19
|
+
// Convert every three bytes to 4 ascii characters.
|
|
20
|
+
|
|
21
|
+
for (let i = 0; i < (length - 2); i += 3) {
|
|
22
|
+
result += this.toBase64Table[data[i] >> 2];
|
|
23
|
+
result += this.toBase64Table[((data[i] & 0x03) << 4) + (data[i + 1] >> 4)];
|
|
24
|
+
result += this.toBase64Table[((data[i + 1] & 0x0f) << 2) + (data[i + 2] >> 6)];
|
|
25
|
+
result += this.toBase64Table[data[i + 2] & 0x3f];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Convert the remaining 1 or 2 bytes, pad out to 4 characters.
|
|
29
|
+
const j = length - lengthpad;
|
|
30
|
+
if (lengthpad === 2) {
|
|
31
|
+
result += this.toBase64Table[data[j] >> 2];
|
|
32
|
+
result += this.toBase64Table[((data[j] & 0x03) << 4) + (data[j + 1] >> 4)];
|
|
33
|
+
result += this.toBase64Table[(data[j + 1] & 0x0f) << 2];
|
|
34
|
+
result += this.toBase64Table[64];
|
|
35
|
+
} else if (lengthpad === 1) {
|
|
36
|
+
result += this.toBase64Table[data[j] >> 2];
|
|
37
|
+
result += this.toBase64Table[(data[j] & 0x03) << 4];
|
|
38
|
+
result += this.toBase64Table[64];
|
|
39
|
+
result += this.toBase64Table[64];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return result;
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
/* Convert Base64 data to a string */
|
|
46
|
+
/* eslint-disable comma-spacing */
|
|
47
|
+
toBinaryTable: [
|
|
48
|
+
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
|
49
|
+
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
|
50
|
+
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, -1,-1,-1,63,
|
|
51
|
+
52,53,54,55, 56,57,58,59, 60,61,-1,-1, -1, 0,-1,-1,
|
|
52
|
+
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11,12,13,14,
|
|
53
|
+
15,16,17,18, 19,20,21,22, 23,24,25,-1, -1,-1,-1,-1,
|
|
54
|
+
-1,26,27,28, 29,30,31,32, 33,34,35,36, 37,38,39,40,
|
|
55
|
+
41,42,43,44, 45,46,47,48, 49,50,51,-1, -1,-1,-1,-1
|
|
56
|
+
],
|
|
57
|
+
/* eslint-enable comma-spacing */
|
|
58
|
+
|
|
59
|
+
decode(data, offset = 0) {
|
|
60
|
+
let dataLength = data.indexOf('=') - offset;
|
|
61
|
+
if (dataLength < 0) { dataLength = data.length - offset; }
|
|
62
|
+
|
|
63
|
+
/* Every four characters is 3 resulting numbers */
|
|
64
|
+
const resultLength = (dataLength >> 2) * 3 + Math.floor((dataLength % 4) / 1.5);
|
|
65
|
+
const result = new Array(resultLength);
|
|
66
|
+
|
|
67
|
+
// Convert one by one.
|
|
68
|
+
|
|
69
|
+
let leftbits = 0; // number of bits decoded, but yet to be appended
|
|
70
|
+
let leftdata = 0; // bits decoded, but yet to be appended
|
|
71
|
+
for (let idx = 0, i = offset; i < data.length; i++) {
|
|
72
|
+
const c = this.toBinaryTable[data.charCodeAt(i) & 0x7f];
|
|
73
|
+
const padding = (data.charAt(i) === this.base64Pad);
|
|
74
|
+
// Skip illegal characters and whitespace
|
|
75
|
+
if (c === -1) {
|
|
76
|
+
Log.Error("Illegal character code " + data.charCodeAt(i) + " at position " + i);
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Collect data into leftdata, update bitcount
|
|
81
|
+
leftdata = (leftdata << 6) | c;
|
|
82
|
+
leftbits += 6;
|
|
83
|
+
|
|
84
|
+
// If we have 8 or more bits, append 8 bits to the result
|
|
85
|
+
if (leftbits >= 8) {
|
|
86
|
+
leftbits -= 8;
|
|
87
|
+
// Append if not padding.
|
|
88
|
+
if (!padding) {
|
|
89
|
+
result[idx++] = (leftdata >> leftbits) & 0xff;
|
|
90
|
+
}
|
|
91
|
+
leftdata &= (1 << leftbits) - 1;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// If there are any bits left, the base64 string was corrupted
|
|
96
|
+
if (leftbits) {
|
|
97
|
+
const err = new Error('Corrupted base64 string');
|
|
98
|
+
err.name = 'Base64-Error';
|
|
99
|
+
throw err;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
}; /* End of Base64 namespace */
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* noVNC: HTML5 VNC client
|
|
3
|
+
* Copyright (c) 2025 The noVNC authors
|
|
4
|
+
* Licensed under MPL 2.0 or any later version (see LICENSE.txt)
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import * as Log from './util/logging.js';
|
|
8
|
+
import { browserAsyncClipboardSupport } from './util/browser.js';
|
|
9
|
+
|
|
10
|
+
export default class AsyncClipboard {
|
|
11
|
+
constructor(target) {
|
|
12
|
+
this._target = target || null;
|
|
13
|
+
|
|
14
|
+
this._isAvailable = null;
|
|
15
|
+
|
|
16
|
+
this._eventHandlers = {
|
|
17
|
+
'focus': this._handleFocus.bind(this),
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// ===== EVENT HANDLERS =====
|
|
21
|
+
|
|
22
|
+
this.onpaste = () => {};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// ===== PRIVATE METHODS =====
|
|
26
|
+
|
|
27
|
+
async _ensureAvailable() {
|
|
28
|
+
if (this._isAvailable !== null) return this._isAvailable;
|
|
29
|
+
try {
|
|
30
|
+
const status = await browserAsyncClipboardSupport();
|
|
31
|
+
this._isAvailable = (status === 'available');
|
|
32
|
+
} catch {
|
|
33
|
+
this._isAvailable = false;
|
|
34
|
+
}
|
|
35
|
+
return this._isAvailable;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async _handleFocus(event) {
|
|
39
|
+
if (!(await this._ensureAvailable())) return;
|
|
40
|
+
try {
|
|
41
|
+
const text = await navigator.clipboard.readText();
|
|
42
|
+
this.onpaste(text);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
Log.Error("Clipboard read failed: ", error);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ===== PUBLIC METHODS =====
|
|
49
|
+
|
|
50
|
+
writeClipboard(text) {
|
|
51
|
+
// Can lazily check cached availability
|
|
52
|
+
if (!this._isAvailable) return false;
|
|
53
|
+
navigator.clipboard.writeText(text)
|
|
54
|
+
.catch(error => Log.Error("Clipboard write failed: ", error));
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
grab() {
|
|
59
|
+
if (!this._target) return;
|
|
60
|
+
this._ensureAvailable()
|
|
61
|
+
.then((isAvailable) => {
|
|
62
|
+
if (isAvailable) {
|
|
63
|
+
this._target.addEventListener('focus', this._eventHandlers.focus);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
ungrab() {
|
|
69
|
+
if (!this._target) return;
|
|
70
|
+
this._target.removeEventListener('focus', this._eventHandlers.focus);
|
|
71
|
+
}
|
|
72
|
+
}
|