myagent-ai 1.23.27 → 1.23.28
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/agents/main_agent.py +8 -8
- package/core/tool_dispatcher.py +19 -0
- package/core/web_control.py +6 -1
- package/data/novnc/lib/base64.js +6 -5
- package/data/novnc/lib/decoders/copyrect.js +11 -9
- package/data/novnc/lib/decoders/hextile.js +34 -30
- package/data/novnc/lib/decoders/jpeg.js +110 -136
- package/data/novnc/lib/decoders/raw.js +39 -31
- package/data/novnc/lib/decoders/rre.js +11 -9
- package/data/novnc/lib/decoders/tight.js +21 -82
- package/data/novnc/lib/decoders/tightpng.js +22 -26
- package/data/novnc/lib/decoders/zrle.js +14 -18
- package/data/novnc/lib/deflator.js +14 -17
- package/data/novnc/lib/{crypto/des.js → des.js} +15 -88
- package/data/novnc/lib/display.js +24 -31
- package/data/novnc/lib/encodings.js +2 -2
- package/data/novnc/lib/inflator.js +14 -17
- package/data/novnc/lib/input/domkeytable.js +3 -2
- package/data/novnc/lib/input/fixedkeys.js +3 -2
- package/data/novnc/lib/input/gesturehandler.js +11 -9
- package/data/novnc/lib/input/keyboard.js +26 -38
- package/data/novnc/lib/input/keysym.js +3 -2
- package/data/novnc/lib/input/keysymdef.js +3 -2
- package/data/novnc/lib/input/util.js +5 -5
- package/data/novnc/lib/input/vkeys.js +3 -2
- package/data/novnc/lib/input/xtscancodes.js +3 -2
- package/data/novnc/lib/ra2.js +666 -196
- package/data/novnc/lib/rfb.js +439 -340
- package/data/novnc/lib/util/browser.js +11 -8
- package/data/novnc/lib/util/cursor.js +12 -16
- package/data/novnc/lib/util/element.js +0 -0
- package/data/novnc/lib/util/events.js +0 -0
- package/data/novnc/lib/util/eventtarget.js +11 -9
- package/data/novnc/lib/util/int.js +0 -0
- package/data/novnc/lib/util/logging.js +9 -4
- package/data/novnc/lib/util/md5.js +77 -0
- package/data/novnc/lib/util/strings.js +0 -0
- package/data/novnc/lib/vendor/pako/lib/utils/common.js +6 -3
- package/data/novnc/lib/vendor/pako/lib/zlib/adler32.js +0 -0
- package/data/novnc/lib/vendor/pako/lib/zlib/constants.js +3 -2
- package/data/novnc/lib/vendor/pako/lib/zlib/crc32.js +0 -0
- package/data/novnc/lib/vendor/pako/lib/zlib/deflate.js +59 -25
- package/data/novnc/lib/vendor/pako/lib/zlib/gzheader.js +0 -0
- package/data/novnc/lib/vendor/pako/lib/zlib/inffast.js +2 -0
- package/data/novnc/lib/vendor/pako/lib/zlib/inflate.js +42 -18
- package/data/novnc/lib/vendor/pako/lib/zlib/inftrees.js +5 -3
- package/data/novnc/lib/vendor/pako/lib/zlib/messages.js +3 -2
- package/data/novnc/lib/vendor/pako/lib/zlib/trees.js +10 -3
- package/data/novnc/lib/vendor/pako/lib/zlib/zstream.js +0 -0
- package/data/novnc/lib/websock.js +96 -107
- package/package.json +1 -1
- package/web/api_server.py +11 -20
- package/data/novnc/lib/crypto/aes.js +0 -481
- package/data/novnc/lib/crypto/bigint.js +0 -41
- package/data/novnc/lib/crypto/crypto.js +0 -109
- package/data/novnc/lib/crypto/dh.js +0 -81
- package/data/novnc/lib/crypto/md5.js +0 -97
- package/data/novnc/lib/crypto/rsa.js +0 -312
package/agents/main_agent.py
CHANGED
|
@@ -47,12 +47,12 @@ class MainAgent(BaseAgent):
|
|
|
47
47
|
<output>
|
|
48
48
|
<mainsubject>当前对话的6字以内标题(每轮都需输出,系统会每3轮自动更新会话名称)</mainsubject>
|
|
49
49
|
<usersays_correct>通过修正识别错误、调整标点,结合上下文,将用户语音转写文本"usersays"修正为更准确的文本,但尽量少改动。如"usersays"为空,则此处为空。</usersays_correct>
|
|
50
|
-
<response><reply>展示给用户的文本,格式上尽量使用md
|
|
51
|
-
<tool><beforecalltext>展示给用户的简单工具调用信息。格式:先使用"
|
|
50
|
+
<response><reply>展示给用户的文本,格式上尽量使用md格式,直观形象展示,甚至可以包括超链接、表格等。内容上,针对用户问题,直接回应问题;针对任务,开始的时候,告诉用户,为完成任务,准备如何开展工作;执行过程中,根据工具调用结果,简单展示任务进展;任务完成后的详细最终总结。注意:这是给用户展示信息的最重要标签,尽量不要跟上次回复重复,执行过程展示内容尽量简洁,执行总结可以丰富一点。</reply><toolstocal>
|
|
51
|
+
<tool><beforecalltext>展示给用户的简单工具调用信息。格式:先使用"接下来、下一步、接着、现在、然后、最后、等下"等连接词➕调用"工具名"。</beforecalltext><toolname>工具名,用于后台解析器解析调用工具</toolname><parms>调用工具的JSON格式参数对象,如格式: {"query": "搜索关键词", "num": 5}</parms><timeout>预估调用超时时限(秒),工具调用超时会立即回调大语言模型,方便调整工具使用</timeout></tool>
|
|
52
52
|
</toolstocal>
|
|
53
53
|
</response>
|
|
54
|
-
<task_plan>若"context"包含非空"task_plan",则更新它:若任务条数已超8,则精简为3条,若主题发生明显变化,重新设计任务列表。若"context"包含空"task_plan",则先评估任务复杂度,针对单次查询、简单问答、格式转换、单文件修改、简单计算等简单任务,若预计操作步骤不超过2步,则此处输出为空,不创建任务列表;针对多文件修改、需要调研+实现+测试、涉及多个模块联动等复杂任务,如预计超过2步操作,则以Markdown列表格式制定新任务列表。格式:每项用 "- [ ] 任务描述" 或 "- [x] 已完成任务"
|
|
55
|
-
<remember><type>填global或session,其中"global"
|
|
54
|
+
<task_plan>若"context"包含非空"task_plan",则更新它:若任务条数已超8,则精简为3条,若主题发生明显变化,重新设计任务列表。若"context"包含空"task_plan",则先评估任务复杂度,针对单次查询、简单问答、格式转换、单文件修改、简单计算等简单任务,若预计操作步骤不超过2步,则此处输出为空,不创建任务列表;针对多文件修改、需要调研+实现+测试、涉及多个模块联动等复杂任务,如预计超过2步操作,则以Markdown列表格式制定新任务列表。格式:每项用 "- [ ] 任务描述" 或 "- [x] 已完成任务",含完成状态标记,排序按已完成在前。</task_plan>
|
|
55
|
+
<remember><type>填global或session,其中"global"为跨会话全局记忆,主要记忆用户个人信息和偏好,"session"为仅当前会话,临时的一些信息。</type><content>仅从最新用户输入,包括"userprint"或"usersays_correct"或工具调用结果,中提炼值得记忆的信息(如用户偏好、重要结论、错误经验、用户个人信息、对话要点、用户诉求、ai回复等)。因为对话默认不自动保存聊天记录,而是从记忆库搜索最相关的最新内容到"automemory"供决策,所以此次必须有所记忆,才能为后续多轮对话提供持续记忆基础。</content></remember>
|
|
56
56
|
<recall>下一轮需要主动召回的记忆描述。填写需要从记忆库中检索的关键字或描述。如果不填写则为空。如果需要更多记忆支持当前任务,填写相关关键词(可包含时间参考,如"2025年1月的项目"),系统将在下一轮搜索top5相关记忆并通过"recall_memory"注入上下文。如需即时搜索记忆,使用命令: myagent-ai memory --keyword 关键词</recall>
|
|
57
57
|
<knowledge>从本轮对话或工具执行结果中提炼值得长期保存到知识库的专业知识、事实、经验法则、技术要点等,将被持久化存储,未来可通过 "get_knowledge"检索复用。如果本轮无需保存的知识,则为空。格式要求:简洁明确,每条知识一行,用换行分隔。</knowledge>
|
|
58
58
|
<get_knowledge>下一轮执行时需要从知识库搜索获得的知识,填写检索关键词或描述。如context中已包含充足的knowledge内容,则为空。如需更多专业知识支撑,则填写相关搜索词。</get_knowledge>
|
|
@@ -173,12 +173,12 @@ class MainAgent(BaseAgent):
|
|
|
173
173
|
<output>
|
|
174
174
|
<mainsubject>当前对话的6字以内标题(每轮都需输出,系统会每3轮自动更新会话名称)</mainsubject>
|
|
175
175
|
<usersays_correct>通过修正识别错误、调整标点,结合上下文,将用户语音转写文本"usersays"修正为更准确的文本,但尽量少改动。如"usersays"为空,则此处为空。</usersays_correct>
|
|
176
|
-
<response><reply>展示给用户的文本,格式上尽量使用md
|
|
177
|
-
<tool><beforecalltext>展示给用户的简单工具调用信息。格式:先使用"
|
|
176
|
+
<response><reply>展示给用户的文本,格式上尽量使用md格式,直观形象展示,甚至可以包括超链接、表格等。内容上,针对用户问题,直接回应问题;针对任务,开始的时候,告诉用户,为完成任务,准备如何开展工作;执行过程中,根据工具调用结果,简单展示任务进展;任务完成后的详细最终总结。注意:这是给用户展示信息的最重要标签,尽量不要跟上次回复重复,执行过程展示内容尽量简洁,执行总结可以丰富一点。</reply><toolstocal>
|
|
177
|
+
<tool><beforecalltext>展示给用户的简单工具调用信息。格式:先使用"接下来、下一步、接着、现在、然后、最后、等下"等连接词➕调用"工具名"。</beforecalltext><toolname>工具名,用于后台解析器解析调用工具</toolname><parms>调用工具的JSON格式参数对象,如格式: {"query": "搜索关键词", "num": 5}</parms><timeout>预估调用超时时限(秒),工具调用超时会立即回调大语言模型,方便调整工具使用</timeout></tool>
|
|
178
178
|
</toolstocal>
|
|
179
179
|
</response>
|
|
180
|
-
<task_plan>若"context"包含非空"task_plan",则更新它:若任务条数已超8,则精简为3条,若主题发生明显变化,重新设计任务列表。若"context"包含空"task_plan",则先评估任务复杂度,针对单次查询、简单问答、格式转换、单文件修改、简单计算等简单任务,若预计操作步骤不超过2步,则此处输出为空,不创建任务列表;针对多文件修改、需要调研+实现+测试、涉及多个模块联动等复杂任务,如预计超过2步操作,则以Markdown列表格式制定新任务列表。格式:每项用 "- [ ] 任务描述" 或 "- [x] 已完成任务"
|
|
181
|
-
<remember><type>填global或session,其中"global"
|
|
180
|
+
<task_plan>若"context"包含非空"task_plan",则更新它:若任务条数已超8,则精简为3条,若主题发生明显变化,重新设计任务列表。若"context"包含空"task_plan",则先评估任务复杂度,针对单次查询、简单问答、格式转换、单文件修改、简单计算等简单任务,若预计操作步骤不超过2步,则此处输出为空,不创建任务列表;针对多文件修改、需要调研+实现+测试、涉及多个模块联动等复杂任务,如预计超过2步操作,则以Markdown列表格式制定新任务列表。格式:每项用 "- [ ] 任务描述" 或 "- [x] 已完成任务",含完成状态标记,排序按已完成在前。</task_plan>
|
|
181
|
+
<remember><type>填global或session,其中"global"为跨会话全局记忆,主要记忆用户个人信息和偏好,"session"为仅当前会话,临时的一些信息。</type><content>仅从最新用户输入,包括"userprint"或"usersays_correct"或工具调用结果,中提炼值得记忆的信息(如用户偏好、重要结论、错误经验、用户个人信息、对话要点、用户诉求、ai回复等)。因为对话默认不自动保存聊天记录,而是从记忆库搜索最相关的最新内容到"automemory"供决策,所以此次必须有所记忆,才能为后续多轮对话提供持续记忆基础。</content></remember>
|
|
182
182
|
<recall>下一轮需要主动召回的记忆描述。填写需要从记忆库中检索的关键字或描述。如果不填写则为空。如果需要更多记忆支持当前任务,填写相关关键词(可包含时间参考,如"2025年1月的项目"),系统将在下一轮搜索top5相关记忆并通过"recall_memory"注入上下文。如需即时搜索记忆,使用命令: myagent-ai memory --keyword 关键词</recall>
|
|
183
183
|
<knowledge>从本轮对话或工具执行结果中提炼值得长期保存到知识库的专业知识、事实、经验法则、技术要点等,将被持久化存储,未来可通过 "get_knowledge"检索复用。如果本轮无需保存的知识,则为空。格式要求:简洁明确,每条知识一行,用换行分隔。</knowledge>
|
|
184
184
|
<get_knowledge>下一轮执行时需要从知识库搜索获得的知识,填写检索关键词或描述。如context中已包含充足的knowledge内容,则为空。如需更多专业知识支撑,则填写相关搜索词。</get_knowledge>
|
package/core/tool_dispatcher.py
CHANGED
|
@@ -284,7 +284,15 @@ class ToolDispatcher:
|
|
|
284
284
|
fskill = FileSendSkill()
|
|
285
285
|
fpath = params.get("file_path", "")
|
|
286
286
|
fdesc = params.get("description", "")
|
|
287
|
+
if not fpath:
|
|
288
|
+
logger.warning(f"[{task_id}] file_send: 缺少 file_path 参数")
|
|
289
|
+
return {"success": False, "error": "缺少 file_path 参数,请提供要发送的文件路径"}
|
|
290
|
+
logger.info(f"[{task_id}] file_send: 发送文件 {fpath}")
|
|
287
291
|
fresult = await fskill.execute(fpath, fdesc, stream_callback=stream_callback)
|
|
292
|
+
if not fresult.get("success"):
|
|
293
|
+
logger.warning(f"[{task_id}] file_send: 发送失败 - {fresult.get('error', '')}")
|
|
294
|
+
else:
|
|
295
|
+
logger.info(f"[{task_id}] file_send: 发送成功 {fresult.get('file_id', '')} → {fresult.get('name', '')}")
|
|
288
296
|
result = {"success": True, "output": json.dumps(fresult, ensure_ascii=False, indent=2), "data": fresult}
|
|
289
297
|
if sent_files is not None and fresult.get("success") and fresult.get("file_id"):
|
|
290
298
|
sent_files.append({
|
|
@@ -295,6 +303,7 @@ class ToolDispatcher:
|
|
|
295
303
|
})
|
|
296
304
|
return result
|
|
297
305
|
except Exception as e:
|
|
306
|
+
logger.error(f"[{task_id}] file_send: 异常 - {e}", exc_info=True)
|
|
298
307
|
return {"success": False, "error": f"文件发送失败: {e}"}
|
|
299
308
|
|
|
300
309
|
async def _exec_media(
|
|
@@ -310,6 +319,10 @@ class ToolDispatcher:
|
|
|
310
319
|
embed_title = params.get("title", "")
|
|
311
320
|
fallback_link = None
|
|
312
321
|
|
|
322
|
+
if not media_url and not media_file:
|
|
323
|
+
logger.warning(f"[{task_id}] {tool_name}: 缺少 url 和 file_path 参数")
|
|
324
|
+
return {"success": False, "error": f"请提供在线链接(url)或本地文件路径(file_path)"}
|
|
325
|
+
|
|
313
326
|
if media_url:
|
|
314
327
|
url_lower = media_url.lower()
|
|
315
328
|
# YouTube
|
|
@@ -378,6 +391,7 @@ class ToolDispatcher:
|
|
|
378
391
|
sent_files.append(_media_meta)
|
|
379
392
|
|
|
380
393
|
if embed_url and stream_callback:
|
|
394
|
+
logger.info(f"[{task_id}] {tool_name}: 嵌入播放器 {embed_title} → {embed_url[:80]}")
|
|
381
395
|
await self._emit_sse("v2_media", {
|
|
382
396
|
"media_type": media_type,
|
|
383
397
|
"embed_url": embed_url,
|
|
@@ -386,6 +400,11 @@ class ToolDispatcher:
|
|
|
386
400
|
}, stream_callback)
|
|
387
401
|
return {"success": True, "output": f"已嵌入{embed_title}播放器: {media_url}"}
|
|
388
402
|
|
|
403
|
+
elif embed_url and not stream_callback:
|
|
404
|
+
# [v1.23.26] stream_callback 缺失时仍返回成功(非 Web 环境降级)
|
|
405
|
+
logger.warning(f"[{task_id}] {tool_name}: stream_callback 缺失,无法发送播放器到前端")
|
|
406
|
+
return {"success": True, "output": f"已生成{embed_title}播放器(非 Web 环境无法显示): {embed_url}"}
|
|
407
|
+
|
|
389
408
|
elif fallback_link and stream_callback:
|
|
390
409
|
await self._emit_sse("v2_media", {
|
|
391
410
|
"media_type": media_type,
|
package/core/web_control.py
CHANGED
|
@@ -531,6 +531,11 @@ class WebControlManager:
|
|
|
531
531
|
|
|
532
532
|
import aiohttp
|
|
533
533
|
|
|
534
|
+
# [v1.23.26] 兼容不同 aiohttp 版本的 redirect 参数
|
|
535
|
+
# aiohttp >= 3.0 使用 follow_redirects, < 3.0 使用 allow_redirects
|
|
536
|
+
_aio_ver = tuple(int(x) for x in aiohttp.__version__.split('.')[:2])
|
|
537
|
+
_redirect_kw = 'follow_redirects' if _aio_ver >= (3, 0) else 'allow_redirects'
|
|
538
|
+
|
|
534
539
|
headers = {
|
|
535
540
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
|
536
541
|
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8',
|
|
@@ -559,7 +564,7 @@ class WebControlManager:
|
|
|
559
564
|
async with http_session.get(
|
|
560
565
|
url,
|
|
561
566
|
headers=headers,
|
|
562
|
-
|
|
567
|
+
**{_redirect_kw: True},
|
|
563
568
|
timeout=aiohttp.ClientTimeout(total=20),
|
|
564
569
|
ssl=False,
|
|
565
570
|
) as resp:
|
package/data/novnc/lib/base64.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports["default"] = void 0;
|
|
8
8
|
var Log = _interopRequireWildcard(require("./util/logging.js"));
|
|
9
|
-
function _getRequireWildcardCache(
|
|
10
|
-
function _interopRequireWildcard(
|
|
9
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
10
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
11
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
12
12
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
13
13
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
14
14
|
// From: http://hg.mozilla.org/mozilla-central/raw-file/ec10630b1a54/js/src/devtools/jint/sunspider/string-base64.js
|
|
15
|
-
var _default =
|
|
15
|
+
var _default = {
|
|
16
16
|
/* Convert data (an array of integers) to a Base64 string. */
|
|
17
17
|
toBase64Table: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split(''),
|
|
18
18
|
base64Pad: '=',
|
|
@@ -97,4 +97,5 @@ var _default = exports["default"] = {
|
|
|
97
97
|
return result;
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
|
-
/* End of Base64 namespace */
|
|
100
|
+
/* End of Base64 namespace */
|
|
101
|
+
exports["default"] = _default;
|
|
@@ -4,12 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
function _typeof(
|
|
8
|
-
function _classCallCheck(
|
|
9
|
-
function _defineProperties(
|
|
10
|
-
function _createClass(
|
|
11
|
-
function _toPropertyKey(
|
|
12
|
-
function _toPrimitive(
|
|
7
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
8
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
10
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
12
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
13
13
|
/*
|
|
14
14
|
* noVNC: HTML5 VNC client
|
|
15
15
|
* Copyright (C) 2019 The noVNC Authors
|
|
@@ -18,11 +18,11 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
18
18
|
* See README.md for usage and integration instructions.
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
|
-
var CopyRectDecoder =
|
|
21
|
+
var CopyRectDecoder = /*#__PURE__*/function () {
|
|
22
22
|
function CopyRectDecoder() {
|
|
23
23
|
_classCallCheck(this, CopyRectDecoder);
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
_createClass(CopyRectDecoder, [{
|
|
26
26
|
key: "decodeRect",
|
|
27
27
|
value: function decodeRect(x, y, width, height, sock, display, depth) {
|
|
28
28
|
if (sock.rQwait("COPYRECT", 4)) {
|
|
@@ -37,4 +37,6 @@ var CopyRectDecoder = exports["default"] = /*#__PURE__*/function () {
|
|
|
37
37
|
return true;
|
|
38
38
|
}
|
|
39
39
|
}]);
|
|
40
|
-
|
|
40
|
+
return CopyRectDecoder;
|
|
41
|
+
}();
|
|
42
|
+
exports["default"] = CopyRectDecoder;
|
|
@@ -5,29 +5,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
7
|
var Log = _interopRequireWildcard(require("../util/logging.js"));
|
|
8
|
-
function _getRequireWildcardCache(
|
|
9
|
-
function _interopRequireWildcard(
|
|
10
|
-
function _typeof(
|
|
11
|
-
function _classCallCheck(
|
|
12
|
-
function _defineProperties(
|
|
13
|
-
function _createClass(
|
|
14
|
-
function _toPropertyKey(
|
|
15
|
-
function _toPrimitive(
|
|
16
|
-
|
|
17
|
-
* Copyright (C) 2019 The noVNC Authors
|
|
18
|
-
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
19
|
-
*
|
|
20
|
-
* See README.md for usage and integration instructions.
|
|
21
|
-
*
|
|
22
|
-
*/
|
|
23
|
-
var HextileDecoder = exports["default"] = /*#__PURE__*/function () {
|
|
8
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
9
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
10
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
11
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
13
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
14
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
15
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
16
|
+
var HextileDecoder = /*#__PURE__*/function () {
|
|
24
17
|
function HextileDecoder() {
|
|
25
18
|
_classCallCheck(this, HextileDecoder);
|
|
26
19
|
this._tiles = 0;
|
|
27
20
|
this._lastsubencoding = 0;
|
|
28
21
|
this._tileBuffer = new Uint8Array(16 * 16 * 4);
|
|
29
22
|
}
|
|
30
|
-
|
|
23
|
+
_createClass(HextileDecoder, [{
|
|
31
24
|
key: "decodeRect",
|
|
32
25
|
value: function decodeRect(x, y, width, height, sock, display, depth) {
|
|
33
26
|
if (this._tiles === 0) {
|
|
@@ -41,7 +34,9 @@ var HextileDecoder = exports["default"] = /*#__PURE__*/function () {
|
|
|
41
34
|
if (sock.rQwait("HEXTILE", bytes)) {
|
|
42
35
|
return false;
|
|
43
36
|
}
|
|
44
|
-
var
|
|
37
|
+
var rQ = sock.rQ;
|
|
38
|
+
var rQi = sock.rQi;
|
|
39
|
+
var subencoding = rQ[rQi]; // Peek
|
|
45
40
|
if (subencoding > 30) {
|
|
46
41
|
// Raw
|
|
47
42
|
throw new Error("Illegal hextile subencoding (subencoding: " + subencoding + ")");
|
|
@@ -74,7 +69,7 @@ var HextileDecoder = exports["default"] = /*#__PURE__*/function () {
|
|
|
74
69
|
if (sock.rQwait("HEXTILE", bytes)) {
|
|
75
70
|
return false;
|
|
76
71
|
}
|
|
77
|
-
var subrects =
|
|
72
|
+
var subrects = rQ[rQi + bytes - 1]; // Peek
|
|
78
73
|
if (subencoding & 0x10) {
|
|
79
74
|
// SubrectsColoured
|
|
80
75
|
bytes += subrects * (4 + 2);
|
|
@@ -88,7 +83,7 @@ var HextileDecoder = exports["default"] = /*#__PURE__*/function () {
|
|
|
88
83
|
}
|
|
89
84
|
|
|
90
85
|
// We know the encoding and have a whole tile
|
|
91
|
-
|
|
86
|
+
rQi++;
|
|
92
87
|
if (subencoding === 0) {
|
|
93
88
|
if (this._lastsubencoding & 0x01) {
|
|
94
89
|
// Weird: ignore blanks are RAW
|
|
@@ -99,37 +94,43 @@ var HextileDecoder = exports["default"] = /*#__PURE__*/function () {
|
|
|
99
94
|
} else if (subencoding & 0x01) {
|
|
100
95
|
// Raw
|
|
101
96
|
var pixels = tw * th;
|
|
102
|
-
var data = sock.rQshiftBytes(pixels * 4, false);
|
|
103
97
|
// Max sure the image is fully opaque
|
|
104
98
|
for (var i = 0; i < pixels; i++) {
|
|
105
|
-
|
|
99
|
+
rQ[rQi + i * 4 + 3] = 255;
|
|
106
100
|
}
|
|
107
|
-
display.blitImage(tx, ty, tw, th,
|
|
101
|
+
display.blitImage(tx, ty, tw, th, rQ, rQi);
|
|
102
|
+
rQi += bytes - 1;
|
|
108
103
|
} else {
|
|
109
104
|
if (subencoding & 0x02) {
|
|
110
105
|
// Background
|
|
111
|
-
this._background =
|
|
106
|
+
this._background = [rQ[rQi], rQ[rQi + 1], rQ[rQi + 2], rQ[rQi + 3]];
|
|
107
|
+
rQi += 4;
|
|
112
108
|
}
|
|
113
109
|
if (subencoding & 0x04) {
|
|
114
110
|
// Foreground
|
|
115
|
-
this._foreground =
|
|
111
|
+
this._foreground = [rQ[rQi], rQ[rQi + 1], rQ[rQi + 2], rQ[rQi + 3]];
|
|
112
|
+
rQi += 4;
|
|
116
113
|
}
|
|
117
114
|
this._startTile(tx, ty, tw, th, this._background);
|
|
118
115
|
if (subencoding & 0x08) {
|
|
119
116
|
// AnySubrects
|
|
120
|
-
var _subrects =
|
|
117
|
+
var _subrects = rQ[rQi];
|
|
118
|
+
rQi++;
|
|
121
119
|
for (var s = 0; s < _subrects; s++) {
|
|
122
120
|
var color = void 0;
|
|
123
121
|
if (subencoding & 0x10) {
|
|
124
122
|
// SubrectsColoured
|
|
125
|
-
color =
|
|
123
|
+
color = [rQ[rQi], rQ[rQi + 1], rQ[rQi + 2], rQ[rQi + 3]];
|
|
124
|
+
rQi += 4;
|
|
126
125
|
} else {
|
|
127
126
|
color = this._foreground;
|
|
128
127
|
}
|
|
129
|
-
var xy =
|
|
128
|
+
var xy = rQ[rQi];
|
|
129
|
+
rQi++;
|
|
130
130
|
var sx = xy >> 4;
|
|
131
131
|
var sy = xy & 0x0f;
|
|
132
|
-
var wh =
|
|
132
|
+
var wh = rQ[rQi];
|
|
133
|
+
rQi++;
|
|
133
134
|
var sw = (wh >> 4) + 1;
|
|
134
135
|
var sh = (wh & 0x0f) + 1;
|
|
135
136
|
this._subTile(sx, sy, sw, sh, color);
|
|
@@ -137,6 +138,7 @@ var HextileDecoder = exports["default"] = /*#__PURE__*/function () {
|
|
|
137
138
|
}
|
|
138
139
|
this._finishTile(display);
|
|
139
140
|
}
|
|
141
|
+
sock.rQi = rQi;
|
|
140
142
|
this._lastsubencoding = subencoding;
|
|
141
143
|
this._tiles--;
|
|
142
144
|
}
|
|
@@ -192,4 +194,6 @@ var HextileDecoder = exports["default"] = /*#__PURE__*/function () {
|
|
|
192
194
|
display.blitImage(this._tileX, this._tileY, this._tileW, this._tileH, this._tileBuffer, 0);
|
|
193
195
|
}
|
|
194
196
|
}]);
|
|
195
|
-
|
|
197
|
+
return HextileDecoder;
|
|
198
|
+
}();
|
|
199
|
+
exports["default"] = HextileDecoder;
|