@opentiny/next-sdk 0.2.9 → 0.2.10

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.
@@ -27073,27 +27073,27 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
27073
27073
  }
27074
27074
  /**
27075
27075
  * 合并菜单项配置。
27076
- * - sessionId:使用默认菜单 + 用户配置(可定制每一项的 show/text/icon 等)
27077
- * - sessionId:不渲染任何下拉菜单,仅保留点击浮标打开对话框的能力
27076
+ * - 用户明确传入 menuItems:直接使用用户配置,不受 sessionId 限制;未传 icon 时自动补充默认图标
27077
+ * - sessionId 且未传 menuItems:使用默认菜单
27078
+ * - 无 sessionId 且未传 menuItems:不渲染任何下拉菜单,仅保留点击浮标打开对话框的能力
27078
27079
  */
27079
27080
  mergeMenuItems(userMenuItems) {
27081
+ const defaultIcons = {
27082
+ "qr-code": qrCode,
27083
+ "ai-chat": chat,
27084
+ "remote-url": link,
27085
+ "remote-control": scan
27086
+ };
27087
+ if (userMenuItems) {
27088
+ return userMenuItems.map((item) => ({
27089
+ ...item,
27090
+ icon: item.icon ?? defaultIcons[item.action]
27091
+ }));
27092
+ }
27080
27093
  if (!this.options.sessionId) {
27081
27094
  return [];
27082
27095
  }
27083
- if (!userMenuItems) {
27084
- return getDefaultMenuItems(this.options);
27085
- }
27086
- return getDefaultMenuItems(this.options).map((defaultItem) => {
27087
- const userItem = userMenuItems.find((item) => item.action === defaultItem.action);
27088
- if (userItem) {
27089
- return {
27090
- ...defaultItem,
27091
- ...userItem,
27092
- show: userItem.show !== void 0 ? userItem.show : defaultItem.show
27093
- };
27094
- }
27095
- return defaultItem;
27096
- });
27096
+ return getDefaultMenuItems(this.options);
27097
27097
  }
27098
27098
  init() {
27099
27099
  this.createFloatingBlock();
@@ -27124,7 +27124,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
27124
27124
  <div class="tiny-remoter-dropdown-item__content">
27125
27125
  <div title="${item.tip}">${item.text}</div>
27126
27126
  <div class="tiny-remoter-dropdown-item__desc-wrapper">
27127
- <div class="tiny-remoter-dropdown-item__desc ${item.active ? "tiny-remoter-dropdown-item__desc--active" : ""} ${item.know ? "tiny-remoter-dropdown-item__desc--know" : ""}">${item.desc}</div>
27127
+ <div class="tiny-remoter-dropdown-item__desc ${item.active ? "tiny-remoter-dropdown-item__desc--active" : ""} ${item.know ? "tiny-remoter-dropdown-item__desc--know" : ""}">${item.desc ?? ""}</div>
27128
27128
  <div>
27129
27129
  ${item.showCopyIcon ? `
27130
27130
  <div class="tiny-remoter-copy-icon" id="${item.action}" data-action="${item.action}">
@@ -27232,12 +27232,20 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
27232
27232
  this.closeDropdown();
27233
27233
  }
27234
27234
  copyRemoteControl() {
27235
- if (!this.options.sessionId) return;
27236
- this.copyToClipboard(this.options.sessionId.slice(-6));
27235
+ const menuItem = this.menuItems.find((item) => item.action === "remote-control");
27236
+ const codeToCopy = menuItem?.desc || menuItem?.text || (this.options.sessionId ? this.options.sessionId.slice(-6) : "");
27237
+ if (codeToCopy) {
27238
+ this.copyToClipboard(codeToCopy);
27239
+ }
27237
27240
  }
27238
27241
  copyRemoteURL() {
27239
- if (!this.options.sessionId) return;
27240
- this.copyToClipboard(this.options.remoteUrl + this.sessionPrefix + this.options.sessionId);
27242
+ const menuItem = this.menuItems.find((item) => item.action === "remote-url");
27243
+ const sessionUrl = this.options.sessionId ? this.options.remoteUrl + this.sessionPrefix + this.options.sessionId : "";
27244
+ const customDesc = menuItem?.desc && menuItem.desc !== this.options.remoteUrl ? menuItem.desc : void 0;
27245
+ const urlToCopy = customDesc || sessionUrl || menuItem?.text || "";
27246
+ if (urlToCopy) {
27247
+ this.copyToClipboard(urlToCopy);
27248
+ }
27241
27249
  }
27242
27250
  // 实现复制到剪贴板功能
27243
27251
  async copyToClipboard(text2) {
@@ -50022,7 +50030,13 @@ Thought: 用户想要获取今天的日期,我需要调用日期相关的工
50022
50030
  try {
50023
50031
  let transport;
50024
50032
  if ("type" in serverConfig && serverConfig.type.toLocaleLowerCase() === "streamablehttp") {
50025
- transport = new StreamableHTTPClientTransport(new URL(serverConfig.url));
50033
+ const configWithHeaders = serverConfig;
50034
+ const requestInit = configWithHeaders.headers ? { headers: configWithHeaders.headers } : void 0;
50035
+ transport = new StreamableHTTPClientTransport(new URL(configWithHeaders.url), { requestInit });
50036
+ } else if ("type" in serverConfig && serverConfig.type === "sse") {
50037
+ const configWithHeaders = serverConfig;
50038
+ const requestInit = configWithHeaders.headers ? { headers: configWithHeaders.headers } : void 0;
50039
+ transport = new SSEClientTransport(new URL(configWithHeaders.url), { requestInit });
50026
50040
  } else if ("type" in serverConfig && serverConfig.type === "extension") {
50027
50041
  transport = new ExtensionClientTransport(serverConfig.sessionId);
50028
50042
  } else if ("transport" in serverConfig) {