@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.
Files changed (210) hide show
  1. package/dist/routes/git.d.ts.map +1 -1
  2. package/dist/routes/git.js +58 -0
  3. package/dist/routes/git.js.map +1 -1
  4. package/dist/routes/preview.d.ts.map +1 -1
  5. package/dist/routes/preview.js +39 -0
  6. package/dist/routes/preview.js.map +1 -1
  7. package/dist/security/sandbox-manager.d.ts +1 -0
  8. package/dist/security/sandbox-manager.d.ts.map +1 -1
  9. package/dist/security/sandbox-manager.js +11 -0
  10. package/dist/security/sandbox-manager.js.map +1 -1
  11. package/dist/services/git.d.ts +11 -0
  12. package/dist/services/git.d.ts.map +1 -1
  13. package/dist/services/git.js +37 -0
  14. package/dist/services/git.js.map +1 -1
  15. package/dist/services/live-view-manager.d.ts +20 -0
  16. package/dist/services/live-view-manager.d.ts.map +1 -0
  17. package/dist/services/live-view-manager.js +114 -0
  18. package/dist/services/live-view-manager.js.map +1 -0
  19. package/dist/services/preview.d.ts +16 -1
  20. package/dist/services/preview.d.ts.map +1 -1
  21. package/dist/services/preview.js +112 -2
  22. package/dist/services/preview.js.map +1 -1
  23. package/dist/surfaces/browser.d.ts +12 -0
  24. package/dist/surfaces/browser.d.ts.map +1 -1
  25. package/dist/surfaces/browser.js +31 -1
  26. package/dist/surfaces/browser.js.map +1 -1
  27. package/dist/tools/preview-tools.d.ts.map +1 -1
  28. package/dist/tools/preview-tools.js.map +1 -1
  29. package/package.json +1 -1
  30. package/web-dist/assets/{_basePickBy-BjvMP2af.js → _basePickBy-B2KkoWFz.js} +1 -1
  31. package/web-dist/assets/{_baseUniq-CQbQ6NgV.js → _baseUniq-DFNflT4F.js} +1 -1
  32. package/web-dist/assets/{arc-D3KRIJWu.js → arc-C7JI0CHt.js} +1 -1
  33. package/web-dist/assets/{architectureDiagram-2XIMDMQ5-DM3fcOkr.js → architectureDiagram-2XIMDMQ5-bI95Cgh9.js} +1 -1
  34. package/web-dist/assets/{blockDiagram-WCTKOSBZ-B-9Vjl98.js → blockDiagram-WCTKOSBZ-DgfGN-sd.js} +1 -1
  35. package/web-dist/assets/{c4Diagram-IC4MRINW-CTu2yYlj.js → c4Diagram-IC4MRINW-xM9CGMLf.js} +1 -1
  36. package/web-dist/assets/channel-otEtLTdD.js +1 -0
  37. package/web-dist/assets/{chunk-4BX2VUAB-ZDQu0uWO.js → chunk-4BX2VUAB-C66ZLhus.js} +1 -1
  38. package/web-dist/assets/{chunk-55IACEB6-YtzMmlzY.js → chunk-55IACEB6-ByPuHMYM.js} +1 -1
  39. package/web-dist/assets/{chunk-FMBD7UC4-BsIyXbSx.js → chunk-FMBD7UC4-CMH4hMhI.js} +1 -1
  40. package/web-dist/assets/{chunk-JSJVCQXG-CfudXyS3.js → chunk-JSJVCQXG-BJLuo8dM.js} +1 -1
  41. package/web-dist/assets/{chunk-KX2RTZJC-B-fQrx3o.js → chunk-KX2RTZJC-CU0ZE2mJ.js} +1 -1
  42. package/web-dist/assets/{chunk-NQ4KR5QH-DzmNoENv.js → chunk-NQ4KR5QH-CD4JSx3E.js} +1 -1
  43. package/web-dist/assets/{chunk-QZHKN3VN-DtkgvjXx.js → chunk-QZHKN3VN-BhZcwDDX.js} +1 -1
  44. package/web-dist/assets/{chunk-WL4C6EOR-BCxmVwuX.js → chunk-WL4C6EOR-CScYiORQ.js} +1 -1
  45. package/web-dist/assets/classDiagram-VBA2DB6C-D3uA1Ef5.js +1 -0
  46. package/web-dist/assets/classDiagram-v2-RAHNMMFH-D3uA1Ef5.js +1 -0
  47. package/web-dist/assets/clone-CAAX5MRw.js +1 -0
  48. package/web-dist/assets/{cose-bilkent-S5V4N54A-Ixga3b-M.js → cose-bilkent-S5V4N54A-DTphha5A.js} +1 -1
  49. package/web-dist/assets/{dagre-KLK3FWXG-CXoAVVKA.js → dagre-KLK3FWXG-Dm5HIzgU.js} +1 -1
  50. package/web-dist/assets/{diagram-E7M64L7V-CcBLNXz0.js → diagram-E7M64L7V-BafxXR5t.js} +1 -1
  51. package/web-dist/assets/{diagram-IFDJBPK2-6gwd3HNI.js → diagram-IFDJBPK2-DDMAYAl_.js} +1 -1
  52. package/web-dist/assets/{diagram-P4PSJMXO-CAXp9Quj.js → diagram-P4PSJMXO-DHvyv48k.js} +1 -1
  53. package/web-dist/assets/{erDiagram-INFDFZHY-C6p1MF8r.js → erDiagram-INFDFZHY-B_xrbbBo.js} +1 -1
  54. package/web-dist/assets/{flowDiagram-PKNHOUZH-B2M24TQ4.js → flowDiagram-PKNHOUZH-CRcTFuaU.js} +1 -1
  55. package/web-dist/assets/{ganttDiagram-A5KZAMGK-CmKwfSN8.js → ganttDiagram-A5KZAMGK-CeIGrgW3.js} +1 -1
  56. package/web-dist/assets/{gitGraphDiagram-K3NZZRJ6-f6_FZnF_.js → gitGraphDiagram-K3NZZRJ6-B8p3GzsB.js} +1 -1
  57. package/web-dist/assets/{graph-X0lqls-x.js → graph-DgPXX2YH.js} +1 -1
  58. package/web-dist/assets/{index-DnSc9BPB.js → index-Dyq1wR8W.js} +307 -307
  59. package/web-dist/assets/{infoDiagram-LFFYTUFH-59VZJVF5.js → infoDiagram-LFFYTUFH-C1EleBwJ.js} +1 -1
  60. package/web-dist/assets/{ishikawaDiagram-PHBUUO56-BEy0oxW6.js → ishikawaDiagram-PHBUUO56-CY7B0Af8.js} +1 -1
  61. package/web-dist/assets/{journeyDiagram-4ABVD52K-BDulB1lR.js → journeyDiagram-4ABVD52K-BEbad9lw.js} +1 -1
  62. package/web-dist/assets/{kanban-definition-K7BYSVSG-Cx1576bJ.js → kanban-definition-K7BYSVSG-PmiPROs_.js} +1 -1
  63. package/web-dist/assets/{layout-C7p8zLip.js → layout-u4nQqZo9.js} +1 -1
  64. package/web-dist/assets/{linear-C7lgV0KB.js → linear-CYNrNanw.js} +1 -1
  65. package/web-dist/assets/{mindmap-definition-YRQLILUH-B0aaRwFC.js → mindmap-definition-YRQLILUH-Ch-jh05Z.js} +1 -1
  66. package/web-dist/assets/{pieDiagram-SKSYHLDU-BrlmIbXe.js → pieDiagram-SKSYHLDU-ypmvYTXD.js} +1 -1
  67. package/web-dist/assets/{quadrantDiagram-337W2JSQ-BwXx6zzR.js → quadrantDiagram-337W2JSQ-Butg8Ecg.js} +1 -1
  68. package/web-dist/assets/{requirementDiagram-Z7DCOOCP-kUdwkQkY.js → requirementDiagram-Z7DCOOCP-nj6Myt9w.js} +1 -1
  69. package/web-dist/assets/{sankeyDiagram-WA2Y5GQK-Dkpg3nlZ.js → sankeyDiagram-WA2Y5GQK-DPAF8v8e.js} +1 -1
  70. package/web-dist/assets/{sequenceDiagram-2WXFIKYE-CyZv4rLL.js → sequenceDiagram-2WXFIKYE-DVyGYemI.js} +1 -1
  71. package/web-dist/assets/{stateDiagram-RAJIS63D-CZbnLN4N.js → stateDiagram-RAJIS63D-CstalmXc.js} +1 -1
  72. package/web-dist/assets/stateDiagram-v2-FVOUBMTO-DidQo5W_.js +1 -0
  73. package/web-dist/assets/{timeline-definition-YZTLITO2-BSFBZK4o.js → timeline-definition-YZTLITO2-D0D_Mp_k.js} +1 -1
  74. package/web-dist/assets/{treemap-KZPCXAKY-Bhm8QcdX.js → treemap-KZPCXAKY-C9RoKRs9.js} +1 -1
  75. package/web-dist/assets/{vennDiagram-LZ73GAT5-CamPCKoy.js → vennDiagram-LZ73GAT5-r2eoeYH9.js} +1 -1
  76. package/web-dist/assets/{xychartDiagram-JWTSCODW-BgY7GIM5.js → xychartDiagram-JWTSCODW-CdE4gaJ1.js} +1 -1
  77. package/web-dist/index.html +1 -1
  78. package/web-dist/noVNC/LICENSE.txt +62 -0
  79. package/web-dist/noVNC/app/error-handler.js +79 -0
  80. package/web-dist/noVNC/app/images/alt.svg +92 -0
  81. package/web-dist/noVNC/app/images/clipboard.svg +106 -0
  82. package/web-dist/noVNC/app/images/connect.svg +96 -0
  83. package/web-dist/noVNC/app/images/ctrl.svg +96 -0
  84. package/web-dist/noVNC/app/images/ctrlaltdel.svg +100 -0
  85. package/web-dist/noVNC/app/images/disconnect.svg +94 -0
  86. package/web-dist/noVNC/app/images/drag.svg +76 -0
  87. package/web-dist/noVNC/app/images/error.svg +81 -0
  88. package/web-dist/noVNC/app/images/esc.svg +92 -0
  89. package/web-dist/noVNC/app/images/expander.svg +69 -0
  90. package/web-dist/noVNC/app/images/fullscreen.svg +93 -0
  91. package/web-dist/noVNC/app/images/handle.svg +82 -0
  92. package/web-dist/noVNC/app/images/handle_bg.svg +172 -0
  93. package/web-dist/noVNC/app/images/icons/Makefile +42 -0
  94. package/web-dist/noVNC/app/images/icons/novnc-icon-sm.svg +163 -0
  95. package/web-dist/noVNC/app/images/icons/novnc-icon.svg +163 -0
  96. package/web-dist/noVNC/app/images/icons/novnc-ios-120.png +0 -0
  97. package/web-dist/noVNC/app/images/icons/novnc-ios-152.png +0 -0
  98. package/web-dist/noVNC/app/images/icons/novnc-ios-167.png +0 -0
  99. package/web-dist/noVNC/app/images/icons/novnc-ios-180.png +0 -0
  100. package/web-dist/noVNC/app/images/icons/novnc-ios-40.png +0 -0
  101. package/web-dist/noVNC/app/images/icons/novnc-ios-58.png +0 -0
  102. package/web-dist/noVNC/app/images/icons/novnc-ios-60.png +0 -0
  103. package/web-dist/noVNC/app/images/icons/novnc-ios-80.png +0 -0
  104. package/web-dist/noVNC/app/images/icons/novnc-ios-87.png +0 -0
  105. package/web-dist/noVNC/app/images/icons/novnc-ios-icon.svg +183 -0
  106. package/web-dist/noVNC/app/images/icons/novnc.ico +0 -0
  107. package/web-dist/noVNC/app/images/info.svg +81 -0
  108. package/web-dist/noVNC/app/images/keyboard.svg +88 -0
  109. package/web-dist/noVNC/app/images/power.svg +87 -0
  110. package/web-dist/noVNC/app/images/settings.svg +76 -0
  111. package/web-dist/noVNC/app/images/tab.svg +86 -0
  112. package/web-dist/noVNC/app/images/toggleextrakeys.svg +90 -0
  113. package/web-dist/noVNC/app/images/warning.svg +81 -0
  114. package/web-dist/noVNC/app/images/windows.svg +65 -0
  115. package/web-dist/noVNC/app/locale/README +1 -0
  116. package/web-dist/noVNC/app/locale/cs.json +71 -0
  117. package/web-dist/noVNC/app/locale/de.json +74 -0
  118. package/web-dist/noVNC/app/locale/el.json +100 -0
  119. package/web-dist/noVNC/app/locale/es.json +68 -0
  120. package/web-dist/noVNC/app/locale/fr.json +82 -0
  121. package/web-dist/noVNC/app/locale/hu.json +80 -0
  122. package/web-dist/noVNC/app/locale/it.json +68 -0
  123. package/web-dist/noVNC/app/locale/ja.json +81 -0
  124. package/web-dist/noVNC/app/locale/ko.json +70 -0
  125. package/web-dist/noVNC/app/locale/nl.json +95 -0
  126. package/web-dist/noVNC/app/locale/pl.json +80 -0
  127. package/web-dist/noVNC/app/locale/pt_BR.json +72 -0
  128. package/web-dist/noVNC/app/locale/ru.json +72 -0
  129. package/web-dist/noVNC/app/locale/sv.json +83 -0
  130. package/web-dist/noVNC/app/locale/tr.json +69 -0
  131. package/web-dist/noVNC/app/locale/uk.json +81 -0
  132. package/web-dist/noVNC/app/locale/zh_CN.json +93 -0
  133. package/web-dist/noVNC/app/locale/zh_TW.json +69 -0
  134. package/web-dist/noVNC/app/localization.js +206 -0
  135. package/web-dist/noVNC/app/sounds/CREDITS +4 -0
  136. package/web-dist/noVNC/app/sounds/bell.mp3 +0 -0
  137. package/web-dist/noVNC/app/sounds/bell.oga +0 -0
  138. package/web-dist/noVNC/app/styles/Orbitron700.ttf +0 -0
  139. package/web-dist/noVNC/app/styles/Orbitron700.woff +0 -0
  140. package/web-dist/noVNC/app/styles/base.css +927 -0
  141. package/web-dist/noVNC/app/styles/constants.css +30 -0
  142. package/web-dist/noVNC/app/styles/input.css +628 -0
  143. package/web-dist/noVNC/app/ui.js +1873 -0
  144. package/web-dist/noVNC/app/wakelock.js +199 -0
  145. package/web-dist/noVNC/app/webutil.js +250 -0
  146. package/web-dist/noVNC/core/base64.js +104 -0
  147. package/web-dist/noVNC/core/clipboard.js +72 -0
  148. package/web-dist/noVNC/core/crypto/aes.js +178 -0
  149. package/web-dist/noVNC/core/crypto/bigint.js +34 -0
  150. package/web-dist/noVNC/core/crypto/crypto.js +90 -0
  151. package/web-dist/noVNC/core/crypto/des.js +330 -0
  152. package/web-dist/noVNC/core/crypto/dh.js +55 -0
  153. package/web-dist/noVNC/core/crypto/md5.js +82 -0
  154. package/web-dist/noVNC/core/crypto/rsa.js +132 -0
  155. package/web-dist/noVNC/core/decoders/copyrect.js +27 -0
  156. package/web-dist/noVNC/core/decoders/h264.js +321 -0
  157. package/web-dist/noVNC/core/decoders/hextile.js +181 -0
  158. package/web-dist/noVNC/core/decoders/jpeg.js +161 -0
  159. package/web-dist/noVNC/core/decoders/raw.js +59 -0
  160. package/web-dist/noVNC/core/decoders/rre.js +44 -0
  161. package/web-dist/noVNC/core/decoders/tight.js +393 -0
  162. package/web-dist/noVNC/core/decoders/tightpng.js +27 -0
  163. package/web-dist/noVNC/core/decoders/zlib.js +51 -0
  164. package/web-dist/noVNC/core/decoders/zrle.js +185 -0
  165. package/web-dist/noVNC/core/deflator.js +84 -0
  166. package/web-dist/noVNC/core/display.js +578 -0
  167. package/web-dist/noVNC/core/encodings.js +54 -0
  168. package/web-dist/noVNC/core/inflator.js +65 -0
  169. package/web-dist/noVNC/core/input/domkeytable.js +311 -0
  170. package/web-dist/noVNC/core/input/fixedkeys.js +129 -0
  171. package/web-dist/noVNC/core/input/gesturehandler.js +567 -0
  172. package/web-dist/noVNC/core/input/keyboard.js +294 -0
  173. package/web-dist/noVNC/core/input/keysym.js +616 -0
  174. package/web-dist/noVNC/core/input/keysymdef.js +688 -0
  175. package/web-dist/noVNC/core/input/util.js +191 -0
  176. package/web-dist/noVNC/core/input/vkeys.js +116 -0
  177. package/web-dist/noVNC/core/input/xtscancodes.js +173 -0
  178. package/web-dist/noVNC/core/ra2.js +312 -0
  179. package/web-dist/noVNC/core/rfb.js +3426 -0
  180. package/web-dist/noVNC/core/util/browser.js +266 -0
  181. package/web-dist/noVNC/core/util/cursor.js +249 -0
  182. package/web-dist/noVNC/core/util/element.js +32 -0
  183. package/web-dist/noVNC/core/util/events.js +138 -0
  184. package/web-dist/noVNC/core/util/eventtarget.js +35 -0
  185. package/web-dist/noVNC/core/util/int.js +15 -0
  186. package/web-dist/noVNC/core/util/logging.js +56 -0
  187. package/web-dist/noVNC/core/util/strings.js +28 -0
  188. package/web-dist/noVNC/core/websock.js +369 -0
  189. package/web-dist/noVNC/defaults.json +1 -0
  190. package/web-dist/noVNC/mandatory.json +1 -0
  191. package/web-dist/noVNC/vendor/pako/LICENSE +21 -0
  192. package/web-dist/noVNC/vendor/pako/README.md +6 -0
  193. package/web-dist/noVNC/vendor/pako/lib/utils/common.js +45 -0
  194. package/web-dist/noVNC/vendor/pako/lib/zlib/adler32.js +27 -0
  195. package/web-dist/noVNC/vendor/pako/lib/zlib/constants.js +47 -0
  196. package/web-dist/noVNC/vendor/pako/lib/zlib/crc32.js +36 -0
  197. package/web-dist/noVNC/vendor/pako/lib/zlib/deflate.js +1846 -0
  198. package/web-dist/noVNC/vendor/pako/lib/zlib/gzheader.js +35 -0
  199. package/web-dist/noVNC/vendor/pako/lib/zlib/inffast.js +324 -0
  200. package/web-dist/noVNC/vendor/pako/lib/zlib/inflate.js +1527 -0
  201. package/web-dist/noVNC/vendor/pako/lib/zlib/inftrees.js +322 -0
  202. package/web-dist/noVNC/vendor/pako/lib/zlib/messages.js +11 -0
  203. package/web-dist/noVNC/vendor/pako/lib/zlib/trees.js +1195 -0
  204. package/web-dist/noVNC/vendor/pako/lib/zlib/zstream.js +24 -0
  205. package/web-dist/noVNC/vnc_lite.html +180 -0
  206. package/web-dist/assets/channel-r3VxZeIf.js +0 -1
  207. package/web-dist/assets/classDiagram-VBA2DB6C-BRBktPwb.js +0 -1
  208. package/web-dist/assets/classDiagram-v2-RAHNMMFH-BRBktPwb.js +0 -1
  209. package/web-dist/assets/clone-rt9RfsvE.js +0 -1
  210. 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
+ }