@heybox/hb-sdk 0.9.6-alpha.10 → 0.9.6-alpha.11

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 (35) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +4 -0
  3. package/dist/cli-chunks/{artifact-BaZzEQjq.cjs → artifact-BW6SD1G6.cjs} +3 -3
  4. package/dist/cli-chunks/{build-Ykhw1sz9.cjs → build-B0Id0UTN.cjs} +5 -5
  5. package/dist/cli-chunks/{create-BEjKsD1y.cjs → create-DVu93Ekp.cjs} +1 -1
  6. package/dist/cli-chunks/{dev-DpkBN4ir.cjs → dev-CeSjpEZQ.cjs} +8 -8
  7. package/dist/cli-chunks/{dev-context-B3Y_EcXC.cjs → dev-context-CVc_BsWR.cjs} +2 -2
  8. package/dist/cli-chunks/{doctor-DPELjB83.cjs → doctor-BF9mtkJr.cjs} +1 -1
  9. package/dist/cli-chunks/{games-D2hnnWKY.cjs → games-BKnDCklM.cjs} +1 -1
  10. package/dist/cli-chunks/{index-DCj9vtVv.cjs → index-Cgui_8Rk.cjs} +1 -1
  11. package/dist/cli-chunks/{index-DIgSsTuu.cjs → index-Rp3UMZIO.cjs} +17 -17
  12. package/dist/cli-chunks/{index.esm-t29GC7yg.cjs → index.esm-BK0eVYaM.cjs} +6 -6
  13. package/dist/cli-chunks/{login-C5XmcbRa.cjs → login-DpeDN-mt.cjs} +1 -1
  14. package/dist/cli-chunks/{project-vite-B12EMgRq.cjs → project-vite-Cg3jYqAJ.cjs} +1 -1
  15. package/dist/cli-chunks/{remote-lFAA88Zl.cjs → remote-BQ-9rhTb.cjs} +6 -6
  16. package/dist/cli-chunks/{runtime-permission-env-CYbLBtWo.cjs → runtime-permission-env-BgipCJ0Z.cjs} +3 -3
  17. package/dist/cli-chunks/{skill-AilHsggi.cjs → skill-D7pd4yPq.cjs} +2 -2
  18. package/dist/cli-chunks/{version-KZTUyIiC.cjs → version-DbjRZkb6.cjs} +1 -1
  19. package/dist/cli.cjs +1 -1
  20. package/dist/devtools/browser-dev-host/assets/browser-dev-host-DVlT56iQ.js +100 -0
  21. package/dist/devtools/browser-dev-host/assets/{desktop-app-launch-CPk4dD63.js → desktop-app-launch-BzRxl_MM.js} +1 -1
  22. package/dist/devtools/browser-dev-host/assets/{index-BzOC7Q8l.js → index-DY5ZynQp.js} +3 -3
  23. package/dist/devtools/browser-dev-host/index.html +2 -2
  24. package/dist/index.cjs.js +173 -3
  25. package/dist/index.esm.js +173 -3
  26. package/dist/miniapp-publish.cjs.js +1 -1
  27. package/dist/miniapp-publish.esm.js +1 -1
  28. package/dist/protocol.cjs.js +5 -0
  29. package/dist/protocol.esm.js +5 -0
  30. package/dist/vite.cjs.js +2 -2
  31. package/dist/vite.esm.js +2 -2
  32. package/package.json +5 -5
  33. package/skill/skill.json +4 -4
  34. package/types/index.d.ts +54 -1
  35. package/dist/devtools/browser-dev-host/assets/browser-dev-host-C0_lx52X.js +0 -100
package/dist/index.esm.js CHANGED
@@ -424,6 +424,10 @@ const USER_SHOW_APPRECIATION_METHOD = 'user.showAppreciation';
424
424
  const SHARE_COPY_LINK_METHOD = 'share.copyLink';
425
425
  const SHARE_SHOW_SHARE_MENU_METHOD = 'share.showShareMenu';
426
426
  const SHARE_SCREENSHOT_METHOD = 'share.screenshot';
427
+ /** DOM 长图内部传输方法;业务仍调用 screenshotElement。
428
+ * @internal
429
+ */
430
+ const SHARE_SCREENSHOT_LONG_METHOD = 'share.screenshotLong';
427
431
  const VIEWPORT_SET_DISPLAY_METHOD = 'viewport.setDisplay';
428
432
  const VIEWPORT_GET_WINDOW_INFO_METHOD = 'viewport.getWindowInfo';
429
433
  const VIEWPORT_SET_NAVIGATION_BAR_STYLE_METHOD = 'viewport.setNavigationBarStyle';
@@ -7505,7 +7509,7 @@ function createMessageId() {
7505
7509
  /** 构建时替换为当前发布包的实际版本。 */
7506
7510
  const HB_SDK_VERSION = typeof undefined === 'string'
7507
7511
  ? undefined
7508
- : '0.9.6-alpha.10';
7512
+ : '0.9.6-alpha.11';
7509
7513
 
7510
7514
  const RUNTIME_MODES = new Set(['production', 'preview', 'development', 'unknown']);
7511
7515
  const OPERATING_SYSTEM_NAMES = new Set(['android', 'ios', 'ohos', 'windows', 'macos', 'linux', 'unknown']);
@@ -7552,7 +7556,7 @@ function readRecord$1(value) {
7552
7556
 
7553
7557
  const DEFAULT_TIMEOUT = 10000;
7554
7558
  // 选择器等待、截图延迟、登录和关注确认由 Host 管理,使用长操作生命周期,不设固定总时长。
7555
- const HOST_MANAGED_TIMEOUT_METHODS = new Set([FILES_PICK_FILES_METHOD, FILES_PICK_DIRECTORY_METHOD, FILES_SAVE_FILE_METHOD, SHARE_SCREENSHOT_METHOD, USER_REQUEST_FOLLOW_AUTHOR_METHOD]);
7559
+ const HOST_MANAGED_TIMEOUT_METHODS = new Set([FILES_PICK_FILES_METHOD, FILES_PICK_DIRECTORY_METHOD, FILES_SAVE_FILE_METHOD, SHARE_SCREENSHOT_METHOD, SHARE_SCREENSHOT_LONG_METHOD, USER_REQUEST_FOLLOW_AUTHOR_METHOD]);
7556
7560
  const HANDSHAKE_RETRY_INTERVAL = 250;
7557
7561
  /** 底层 bridge client,负责握手、请求响应、事件分发与超时清理。 */
7558
7562
  class MiniProgramBridgeClient {
@@ -10588,6 +10592,14 @@ function decodeBase64Url(value) {
10588
10592
  return Uint8Array.from(atob(padded), (character) => character.charCodeAt(0));
10589
10593
  }
10590
10594
 
10595
+ let queue = Promise.resolve();
10596
+ /** 同页截图串行执行,避免长图捕获面遮挡另一次截图。 */
10597
+ function serializeScreenshot(capture) {
10598
+ const result = queue.then(capture);
10599
+ queue = result.catch(() => undefined);
10600
+ return result;
10601
+ }
10602
+
10591
10603
  /**
10592
10604
  * 截图并唤起分享。
10593
10605
  *
@@ -10604,13 +10616,169 @@ function decodeBase64Url(value) {
10604
10616
  * @see {@link MiniProgramScreenshotOptions}
10605
10617
  */
10606
10618
  function screenshot(requester, options) {
10619
+ return serializeScreenshot(() => captureScreenshot(requester, options));
10620
+ }
10621
+ /** 已持有截图队列的内部入口。 */
10622
+ function captureScreenshot(requester, options) {
10623
+ warnScreenshotWatermark();
10624
+ return requester.request(SHARE_SCREENSHOT_METHOD, options);
10625
+ }
10626
+ function warnScreenshotWatermark() {
10607
10627
  try {
10608
10628
  console.warn('[hb-sdk] share.screenshot 行为变更提醒:正式版 SDK 0.9.1 及以上默认添加小程序品牌水印;低于 0.9.1(含预发布版本)的 SDK 保持无水印截图。升级前请在目标截图区域底部预留至少 57 个逻辑像素,避免遮挡重要内容;watermarkTheme 的 light 为黑色水印,dark 为白色水印且是默认值,不自动跟随系统主题。系统按键截图不在此能力范围内。');
10609
10629
  }
10610
10630
  catch {
10611
10631
  // 日志输出失败不能阻断截图调用。
10612
10632
  }
10613
- return requester.request(SHARE_SCREENSHOT_METHOD, options);
10633
+ }
10634
+
10635
+ /** 将当前页面的 DOM 边界转换为逻辑像素矩形,再复用原截图分享流程。 */
10636
+ async function screenshotElement(requester, options) {
10637
+ return serializeScreenshot(() => captureElement(requester, options));
10638
+ }
10639
+ async function captureElement(requester, options) {
10640
+ if (!options || typeof options !== 'object' || Array.isArray(options) || 'rect' in options) {
10641
+ throw createSDKError('INVALID_PARAMS', 'share.screenshotElement 必须传入包含 element 的配置,且不能指定 rect');
10642
+ }
10643
+ const { element, ...screenshotOptions } = options;
10644
+ if (typeof window === 'undefined' || typeof document === 'undefined' || typeof Element === 'undefined'
10645
+ || !(element instanceof Element) || element.ownerDocument !== document || !element.isConnected) {
10646
+ throw createSDKError('INVALID_PARAMS', 'share.screenshotElement element 必须是当前页面中已挂载的 DOM 元素');
10647
+ }
10648
+ // DOMRect 已是当前窗口逻辑像素;不叠加滚动偏移,也不乘设备像素比。
10649
+ const { left, top, width, height } = element.getBoundingClientRect();
10650
+ const windowWidth = document.documentElement.clientWidth || window.innerWidth;
10651
+ const windowHeight = document.documentElement.clientHeight || window.innerHeight;
10652
+ const visibility = window.getComputedStyle(element).visibility;
10653
+ if (![left, top, width, height, windowWidth, windowHeight].every(Number.isFinite)
10654
+ || width <= 0 || height <= 0 || windowWidth <= 0 || windowHeight <= 0
10655
+ || element.getClientRects().length === 0 || visibility === 'hidden' || visibility === 'collapse') {
10656
+ throw createSDKError('INVALID_PARAMS', 'share.screenshotElement element 必须具有可见的布局尺寸');
10657
+ }
10658
+ // 原生只支持纵向拼接;横向溢出不能静默退化为可见区域截图。
10659
+ if (width >= windowWidth + 1 || element.scrollWidth > element.clientWidth + 1) {
10660
+ throw createSDKError('INVALID_PARAMS', '暂不支持横向长图:元素宽度不能超过窗口,且不能包含横向溢出内容');
10661
+ }
10662
+ if (height >= windowHeight + 1 || element.scrollHeight > height + 1) {
10663
+ if (width > windowWidth + 1)
10664
+ throw createSDKError('INVALID_PARAMS', '长图宽度不能超过窗口');
10665
+ return screenshotLongElement(requester, options);
10666
+ }
10667
+ // clientWidth/clientHeight 为整数,DOMRect 保留亚像素;仅容忍不足 1 个逻辑像素的边界误差。
10668
+ const tolerance = 1;
10669
+ const right = left + width;
10670
+ const bottom = top + height;
10671
+ if (left <= -tolerance || top <= -tolerance || right >= windowWidth + tolerance || bottom >= windowHeight + tolerance) {
10672
+ throw createSDKError('INVALID_PARAMS', 'share.screenshotElement element 的完整边界必须位于当前可见窗口内');
10673
+ }
10674
+ const clippedLeft = Math.max(0, left);
10675
+ const clippedTop = Math.max(0, top);
10676
+ const clippedWidth = left < 0 || right > windowWidth ? Math.min(windowWidth, right) - clippedLeft : width;
10677
+ const clippedHeight = top < 0 || bottom > windowHeight ? Math.min(windowHeight, bottom) - clippedTop : height;
10678
+ if (clippedWidth <= 0 || clippedHeight <= 0) {
10679
+ throw createSDKError('INVALID_PARAMS', 'share.screenshotElement element 必须与当前可见窗口相交');
10680
+ }
10681
+ return captureScreenshot(requester, { ...screenshotOptions, rect: { left: clippedLeft, top: clippedTop, width: clippedWidth, height: clippedHeight } });
10682
+ }
10683
+ /** 在业务文档准备长图捕获面,再交给宿主原生截图。调用方持有同页截图队列。 */
10684
+ async function screenshotLongElement(requester, { element, ...options }) {
10685
+ if (!element.isConnected)
10686
+ throw createSDKError('INVALID_PARAMS', '截图元素已卸载');
10687
+ const bounds = element.getBoundingClientRect();
10688
+ const height = Math.max(bounds.height, element.scrollHeight + bounds.height - element.clientHeight);
10689
+ if (height > 10000 || bounds.width > 2048 || bounds.width * height > 4000000) {
10690
+ throw createSDKError('INVALID_PARAMS', '长图尺寸超过限制(高度 10000、面积 400 万逻辑像素)');
10691
+ }
10692
+ if (element.matches('iframe,video,object,embed') || element.querySelector('iframe,video,object,embed')) {
10693
+ throw createSDKError('INVALID_PARAMS', '长图暂不支持嵌入网页和视频');
10694
+ }
10695
+ // 在业务自己的文档内复制,DOM 不经过 bridge,也不导出 Canvas 像素。
10696
+ if (!(element instanceof HTMLElement))
10697
+ throw createSDKError('INVALID_PARAMS', '长图需要 HTML 容器元素');
10698
+ const sources = [element, ...element.querySelectorAll('*')];
10699
+ if (sources.some(source => source.shadowRoot || source.localName.includes('-'))) {
10700
+ throw createSDKError('INVALID_PARAMS', '长图暂不支持自定义元素和 Shadow DOM');
10701
+ }
10702
+ const clone = element.cloneNode(true);
10703
+ const copies = [clone, ...clone.querySelectorAll('*')];
10704
+ for (let i = 0; i < sources.length; i++) {
10705
+ const source = sources[i];
10706
+ const copy = copies[i];
10707
+ if (!copy.style)
10708
+ continue;
10709
+ const computed = window.getComputedStyle(source);
10710
+ if (computed.position === 'fixed' || computed.position === 'sticky')
10711
+ throw createSDKError('INVALID_PARAMS', '长图暂不支持固定或吸顶元素');
10712
+ for (let j = 0; j < computed.length; j++) {
10713
+ const name = computed.item(j);
10714
+ copy.style.setProperty(name, computed.getPropertyValue(name), 'important');
10715
+ }
10716
+ copy.style.setProperty('animation', 'none', 'important');
10717
+ copy.style.setProperty('transition', 'none', 'important');
10718
+ if (source instanceof HTMLCanvasElement) {
10719
+ copy.getContext('2d')?.drawImage(source, 0, 0);
10720
+ }
10721
+ if (source instanceof HTMLInputElement)
10722
+ copy.value = source.value;
10723
+ if (source instanceof HTMLTextAreaElement)
10724
+ copy.value = source.value;
10725
+ if (source instanceof HTMLSelectElement)
10726
+ copy.selectedIndex = source.selectedIndex;
10727
+ if (source instanceof HTMLImageElement) {
10728
+ copy.src = source.currentSrc || source.src;
10729
+ copy.removeAttribute('srcset');
10730
+ copy.loading = 'eager';
10731
+ }
10732
+ }
10733
+ if (window.getComputedStyle(element).backgroundColor === 'rgba(0, 0, 0, 0)')
10734
+ clone.style.setProperty('background-color', 'white', 'important');
10735
+ clone.querySelectorAll('script').forEach(script => script.remove());
10736
+ clone.setAttribute('aria-hidden', 'true');
10737
+ clone.inert = true;
10738
+ clone.dataset.hbScreenshotStage = '';
10739
+ for (const [key, value] of Object.entries({ position: 'absolute', left: '0', top: '0', margin: '0', transform: 'none', width: `${bounds.width}px`, height: `${height}px`, 'box-sizing': 'border-box', 'min-width': '0', 'max-width': 'none', 'min-height': '0', 'max-height': 'none', overflow: 'hidden', 'z-index': '2147483647', 'pointer-events': 'none' })) {
10740
+ clone.style.setProperty(key, value, 'important');
10741
+ }
10742
+ const x = window.scrollX;
10743
+ const y = window.scrollY;
10744
+ const documentStyles = [document.documentElement, document.body].map(node => ({ node, style: node.getAttribute('style') }));
10745
+ let timer;
10746
+ try {
10747
+ // 小程序经常锁定 body 的高度与滚动;临时释放裁剪,确保捕获面完整可绘制。
10748
+ for (const { node } of documentStyles) {
10749
+ node.style.setProperty('overflow', 'visible', 'important');
10750
+ node.style.setProperty('min-height', `${height}px`, 'important');
10751
+ node.style.setProperty('scroll-behavior', 'auto', 'important');
10752
+ }
10753
+ document.body.append(clone);
10754
+ window.scrollTo(0, 0);
10755
+ // body 定位上下文可能有偏移,将独立捕获面校正到文档原点。
10756
+ const stageBounds = clone.getBoundingClientRect();
10757
+ clone.style.setProperty('left', `${-stageBounds.left}px`, 'important');
10758
+ clone.style.setProperty('top', `${-stageBounds.top}px`, 'important');
10759
+ await Promise.race([
10760
+ Promise.all([...(clone instanceof HTMLImageElement ? [clone] : []), ...clone.querySelectorAll('img')].map(image => image.decode())),
10761
+ new Promise((_, reject) => { timer = setTimeout(() => reject(createSDKError('REQUEST_TIMEOUT', '长图图片加载超时')), 5000); }),
10762
+ ]);
10763
+ const rendered = clone.getBoundingClientRect();
10764
+ if (Math.abs(rendered.left) >= 1 || Math.abs(rendered.top) >= 1 || Math.abs(rendered.width - bounds.width) >= 1 || Math.abs(rendered.height - height) >= 1) {
10765
+ throw createSDKError('INVALID_PARAMS', '当前页面布局无法容纳长图捕获面');
10766
+ }
10767
+ warnScreenshotWatermark();
10768
+ return await requester.request(SHARE_SCREENSHOT_LONG_METHOD, { ...options, rect: { left: 0, top: 0, width: bounds.width, height } });
10769
+ }
10770
+ finally {
10771
+ clearTimeout(timer);
10772
+ clone.remove();
10773
+ // 在恢复业务的 smooth 滚动样式前立即还原,避免退出截图后继续滚动。
10774
+ window.scrollTo(x, y);
10775
+ for (const { node, style } of documentStyles) {
10776
+ if (style === null)
10777
+ node.removeAttribute('style');
10778
+ else
10779
+ node.setAttribute('style', style);
10780
+ }
10781
+ }
10614
10782
  }
10615
10783
 
10616
10784
  /**
@@ -10641,6 +10809,7 @@ function createShareModule(requester, launchHref) {
10641
10809
  getExtra: () => readMiniProgramShareExtra(launchHref),
10642
10810
  showShareMenu: (options) => showShareMenu(requester, options),
10643
10811
  screenshot: (options) => screenshot(requester, options),
10812
+ screenshotElement: (options) => screenshotElement(requester, options),
10644
10813
  };
10645
10814
  }
10646
10815
 
@@ -12215,6 +12384,7 @@ const share = {
12215
12384
  getExtra: () => getDefaultSDK().share.getExtra(),
12216
12385
  showShareMenu: (options) => getDefaultSDK().share.showShareMenu(options),
12217
12386
  screenshot: (options) => getDefaultSDK().share.screenshot(options),
12387
+ screenshotElement: (options) => getDefaultSDK().share.screenshotElement(options),
12218
12388
  };
12219
12389
  /** 默认 SDK 实例的 Viewport 模块。 */
12220
12390
  const viewport = {
@@ -61,7 +61,7 @@ const MINI_PROGRAM_PERMISSION_CATALOG = [
61
61
  access: 'declaration',
62
62
  risk: 'medium',
63
63
  config: {},
64
- methods: ['share.copyLink', 'share.showShareMenu', 'share.screenshot'],
64
+ methods: ['share.copyLink', 'share.showShareMenu', 'share.screenshot', 'share.screenshotLong'],
65
65
  conditions: ['继续执行分享参数校验和 Host 支持检查。'],
66
66
  },
67
67
  {
@@ -59,7 +59,7 @@ const MINI_PROGRAM_PERMISSION_CATALOG = [
59
59
  access: 'declaration',
60
60
  risk: 'medium',
61
61
  config: {},
62
- methods: ['share.copyLink', 'share.showShareMenu', 'share.screenshot'],
62
+ methods: ['share.copyLink', 'share.showShareMenu', 'share.screenshot', 'share.screenshotLong'],
63
63
  conditions: ['继续执行分享参数校验和 Host 支持检查。'],
64
64
  },
65
65
  {
@@ -47,6 +47,10 @@ const USER_SHOW_APPRECIATION_METHOD = 'user.showAppreciation';
47
47
  const SHARE_COPY_LINK_METHOD = 'share.copyLink';
48
48
  const SHARE_SHOW_SHARE_MENU_METHOD = 'share.showShareMenu';
49
49
  const SHARE_SCREENSHOT_METHOD = 'share.screenshot';
50
+ /** DOM 长图内部传输方法;业务仍调用 screenshotElement。
51
+ * @internal
52
+ */
53
+ const SHARE_SCREENSHOT_LONG_METHOD = 'share.screenshotLong';
50
54
  const VIEWPORT_SET_DISPLAY_METHOD = 'viewport.setDisplay';
51
55
  const VIEWPORT_GET_WINDOW_INFO_METHOD = 'viewport.getWindowInfo';
52
56
  const VIEWPORT_SET_NAVIGATION_BAR_STYLE_METHOD = 'viewport.setNavigationBarStyle';
@@ -200,6 +204,7 @@ const MINI_PROGRAM_PROTOCOL_CAPABILITIES = [
200
204
  requirement: { kind: 'all', permissions: ['share'] },
201
205
  risk: 'medium',
202
206
  },
207
+ { method: SHARE_SCREENSHOT_LONG_METHOD, module: 'share', capability: SHARE_SCREENSHOT_LONG_METHOD, requirement: { kind: 'all', permissions: ['share'] }, risk: 'medium' },
203
208
  {
204
209
  method: VIEWPORT_GET_WINDOW_INFO_METHOD,
205
210
  module: 'viewport',
@@ -45,6 +45,10 @@ const USER_SHOW_APPRECIATION_METHOD = 'user.showAppreciation';
45
45
  const SHARE_COPY_LINK_METHOD = 'share.copyLink';
46
46
  const SHARE_SHOW_SHARE_MENU_METHOD = 'share.showShareMenu';
47
47
  const SHARE_SCREENSHOT_METHOD = 'share.screenshot';
48
+ /** DOM 长图内部传输方法;业务仍调用 screenshotElement。
49
+ * @internal
50
+ */
51
+ const SHARE_SCREENSHOT_LONG_METHOD = 'share.screenshotLong';
48
52
  const VIEWPORT_SET_DISPLAY_METHOD = 'viewport.setDisplay';
49
53
  const VIEWPORT_GET_WINDOW_INFO_METHOD = 'viewport.getWindowInfo';
50
54
  const VIEWPORT_SET_NAVIGATION_BAR_STYLE_METHOD = 'viewport.setNavigationBarStyle';
@@ -198,6 +202,7 @@ const MINI_PROGRAM_PROTOCOL_CAPABILITIES = [
198
202
  requirement: { kind: 'all', permissions: ['share'] },
199
203
  risk: 'medium',
200
204
  },
205
+ { method: SHARE_SCREENSHOT_LONG_METHOD, module: 'share', capability: SHARE_SCREENSHOT_LONG_METHOD, requirement: { kind: 'all', permissions: ['share'] }, risk: 'medium' },
201
206
  {
202
207
  method: VIEWPORT_GET_WINDOW_INFO_METHOD,
203
208
  module: 'viewport',
package/dist/vite.cjs.js CHANGED
@@ -111,7 +111,7 @@ const MINI_PROGRAM_PERMISSION_CATALOG = [
111
111
  access: 'declaration',
112
112
  risk: 'medium',
113
113
  config: {},
114
- methods: ['share.copyLink', 'share.showShareMenu', 'share.screenshot'],
114
+ methods: ['share.copyLink', 'share.showShareMenu', 'share.screenshot', 'share.screenshotLong'],
115
115
  conditions: ['继续执行分享参数校验和 Host 支持检查。'],
116
116
  },
117
117
  {
@@ -10329,7 +10329,7 @@ async function ensureBasicInfoDirectory(rootPath, relative) {
10329
10329
  /** 构建时替换为当前发布包的实际版本。 */
10330
10330
  const HB_SDK_VERSION = typeof undefined === 'string'
10331
10331
  ? undefined
10332
- : '0.9.6-alpha.10';
10332
+ : '0.9.6-alpha.11';
10333
10333
 
10334
10334
  /**
10335
10335
  * network.request 诊断日志的纯脱敏工具。
package/dist/vite.esm.js CHANGED
@@ -108,7 +108,7 @@ const MINI_PROGRAM_PERMISSION_CATALOG = [
108
108
  access: 'declaration',
109
109
  risk: 'medium',
110
110
  config: {},
111
- methods: ['share.copyLink', 'share.showShareMenu', 'share.screenshot'],
111
+ methods: ['share.copyLink', 'share.showShareMenu', 'share.screenshot', 'share.screenshotLong'],
112
112
  conditions: ['继续执行分享参数校验和 Host 支持检查。'],
113
113
  },
114
114
  {
@@ -10326,7 +10326,7 @@ async function ensureBasicInfoDirectory(rootPath, relative) {
10326
10326
  /** 构建时替换为当前发布包的实际版本。 */
10327
10327
  const HB_SDK_VERSION = typeof undefined === 'string'
10328
10328
  ? undefined
10329
- : '0.9.6-alpha.10';
10329
+ : '0.9.6-alpha.11';
10330
10330
 
10331
10331
  /**
10332
10332
  * network.request 诊断日志的纯脱敏工具。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heybox/hb-sdk",
3
- "version": "0.9.6-alpha.10",
3
+ "version": "0.9.6-alpha.11",
4
4
  "sideEffects": [
5
5
  "./src/index.ts",
6
6
  "./src/core/singleton.ts",
@@ -88,7 +88,7 @@
88
88
  "undici": "^7.28.0",
89
89
  "ws": "^8.18.0",
90
90
  "sharp": "^0.34.5",
91
- "@heybox/hb-sdk-protocol": "0.9.6-alpha.10"
91
+ "@heybox/hb-sdk-protocol": "0.9.6-alpha.11"
92
92
  },
93
93
  "peerDependencies": {
94
94
  "vite": ">=5"
@@ -142,11 +142,11 @@
142
142
  "rollup-plugin-dts": "6.4.0",
143
143
  "playwright-core": "1.64.1",
144
144
  "@heybox-domain/heybox-theme": "~0.1.0",
145
- "@heybox/hb-sdk-runtime": "~0.9.6-alpha.10",
146
- "@heybox/hb-api": "~1.28.22",
145
+ "@heybox-domain/heybox-vue3-ui": "~0.1.0",
147
146
  "@heybox/runtime-policy": "~0.2.1",
147
+ "@heybox/hb-sdk-runtime": "~0.9.6-alpha.11",
148
148
  "@heybox/runtime": "~0.2.1",
149
- "@heybox-domain/heybox-vue3-ui": "~0.1.0",
149
+ "@heybox/hb-api": "~1.28.22",
150
150
  "@heybox/runtime-transport-fetch": "~0.2.1"
151
151
  },
152
152
  "publishConfig": {
package/skill/skill.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "hb-sdk",
3
- "skillVersion": "0.9.6-alpha.10+skill.fe3b525ecac8",
3
+ "skillVersion": "0.9.6-alpha.11+skill.fe3b525ecac8",
4
4
  "sdk": {
5
5
  "package": "@heybox/hb-sdk",
6
- "version": "0.9.6-alpha.10",
7
- "compatibility": "0.9.6-alpha.10"
6
+ "version": "0.9.6-alpha.11",
7
+ "compatibility": "0.9.6-alpha.11"
8
8
  },
9
9
  "distribution": {
10
10
  "type": "npm",
11
11
  "package": "@heybox/hb-sdk",
12
- "version": "0.9.6-alpha.10",
12
+ "version": "0.9.6-alpha.11",
13
13
  "path": "skill"
14
14
  },
15
15
  "integrity": "sha256-fe3b525ecac8431e1774ee453864cf9ba58ff6897272e2356ceb17b621c8c427"
package/types/index.d.ts CHANGED
@@ -3393,6 +3393,15 @@ interface MiniProgramScreenshotOptions {
3393
3393
  */
3394
3394
  post?: MiniProgramSharePostOptions | null;
3395
3395
  }
3396
+ /**
3397
+ * DOM 区域截图配置;除用必填的 `element` 替代 `rect` 外,其余配置与原截图接口一致。
3398
+ *
3399
+ * @see {@link MiniProgramShareModule.screenshotElement | share.screenshotElement}
3400
+ */
3401
+ interface MiniProgramScreenshotElementOptions extends Omit<MiniProgramScreenshotOptions, 'rect'> {
3402
+ /** 当前页面中已挂载、有布局尺寸的 DOM 元素;长内容由支持的移动宿主自动生成长图。 */
3403
+ element: Element;
3404
+ }
3396
3405
 
3397
3406
  /** `share.copyLink` 入参;省略后生成不带 `extra` 的通用分享链接。 */
3398
3407
  type CopyLinkPayload = MiniProgramCopyLinkOptions | undefined;
@@ -3729,6 +3738,50 @@ interface MiniProgramShareModule {
3729
3738
  * @hbClient macos none
3730
3739
  */
3731
3740
  screenshot(options?: MiniProgramScreenshotOptions): Promise<ScreenshotResult>;
3741
+ /**
3742
+ * 按 DOM 元素所在的矩形区域截图并唤起分享。
3743
+ *
3744
+ * @param options - 必填配置;用 `element` 替代原截图接口的 `rect`,其余选项保持一致。
3745
+ * @returns 与 {@link MiniProgramShareModule.screenshot | share.screenshot} 相同的不透明结果。
3746
+ * @throws {@link HbMiniProgramSDKError} 配置无效、传入 `rect`、元素不属于当前页面、未挂载、
3747
+ * 无可见布局尺寸、普通截图边界超出窗口或长图尺寸超限时返回 `INVALID_PARAMS`;其余错误由原截图流程透传。
3748
+ *
3749
+ * @remarks
3750
+ * 截图串行执行,轮到本次请求时读取 `element.getBoundingClientRect()`,使用当前窗口逻辑像素,不需要手动
3751
+ * 加滚动偏移或乘设备像素比。DOM 不会通过 bridge 传输;权限、平台支持、延迟、水印、
3752
+ * 相册入口与社区预置均沿用 {@link MiniProgramShareModule.screenshot | share.screenshot}。
3753
+ *
3754
+ * 普通元素仍截取当前窗口矩形;超过窗口高度或具有纵向溢出内容的 HTML 元素自动走原生长图。
3755
+ * 长图需要配套 Runtime 和 iOS / Android Host;旧宿主明确拒绝,不回退为截断图片。仅支持纵向长图,元素超出窗口宽度或自身横向溢出时返回 `INVALID_PARAMS`;长图宽度不得超过窗口,
3756
+ * 高度最多 10000、面积最多 400 万逻辑像素。SDK 临时复制已渲染内容并冻结计算样式,结束后清理。
3757
+ * 嵌入网页、视频、固定/吸顶元素和自定义元素不支持;虚拟列表未渲染的内容不会自动生成,嵌套滚动容器仍保留自身裁剪。
3758
+ * 普通截图的祖先裁剪和遮挡保持实际画面语义。请先完成资源加载,并在操作期间保持内容稳定。
3759
+ * 截图区域底部仍需预留至少 57 个逻辑像素供水印使用。
3760
+ *
3761
+ * @example
3762
+ * ```ts
3763
+ * import hbSDK from '@heybox/hb-sdk'
3764
+ *
3765
+ * const element = document.querySelector('#share-card')
3766
+ * if (element) {
3767
+ * await hbSDK.share.screenshotElement({ element, delay: 100, saveToAlbum: true })
3768
+ * }
3769
+ * ```
3770
+ *
3771
+ * @see {@link MiniProgramScreenshotElementOptions}
3772
+ * @since 0.9.6
3773
+ * @hbPlatform android
3774
+ * @hbPlatform ios
3775
+ * @hbPlatform ohos
3776
+ * @hbPlatform windows
3777
+ * @hbPlatform macos
3778
+ * @hbClient android none
3779
+ * @hbClient ios none
3780
+ * @hbClient ohos none
3781
+ * @hbClient windows none
3782
+ * @hbClient macos none
3783
+ */
3784
+ screenshotElement(options: MiniProgramScreenshotElementOptions): Promise<ScreenshotResult>;
3732
3785
  }
3733
3786
 
3734
3787
  /**
@@ -8028,4 +8081,4 @@ declare const hbSDK: {
8028
8081
  };
8029
8082
 
8030
8083
  export { HbMiniProgramNetworkError, HbMiniProgramSDKError, auth, cloud, companion, hbSDK as default, device, environment, files, gameSaves, getHandshakeState, media, navigation, network, off, on, onHandshakeStateChange, share, storage, ui, user, viewport, workspaceCards };
8031
- export type { ClosePayload, CloseResult, CompanionAttachments, CompanionExitHandler, CompanionNotification, CompanionNotifications, CompanionOutputHandler, CompanionOwnershipLostHandler, CompanionPrepareOptions, CompanionSession, CompanionState, CompanionStateChangeHandler, CompanionStdio, CopyLinkPayload, CopyLinkResult, CreateOptions, DeleteCurrentUserLeaderboardEntryPayload, DeleteCurrentUserLeaderboardEntryResult, DirectoryHandle, DownloadBaseOptions, DownloadOptions, DownloadProgress, FileHandle, FileMode, FileStat, FileSystem, FileSystemEntity, FilesModule, GameSaveFileInfo, GameSaveInfo, GameSavesFileOptions, GameSavesModule, GameSavesSyncOptions, GetCurrentUserLeaderboardEntryPayload, GetCurrentUserLeaderboardEntryResult, GetLeaderboardInfoPayload, GetLeaderboardInfoResult, GetLeaderboardListPayload, GetLeaderboardListResult, GetSteamGameListOptions, GetSteamGameListPayload, GetSteamGameListResult, GetStoragePayload, GetStorageResult, GetUserInfoPayload, GetUserInfoResult, GetWindowInfoPayload, GetWindowInfoResult, HideLoadingPayload, HideLoadingResult, LeaderboardEntry, LeaderboardOrder, ListOptions, LoginOptions, LoginPayload, LoginResult, LoginScope, MediaImageItem, MediaItem, MediaModule, MediaSelectionType, MediaType, MediaVideoItem, MiniProgramAppPageTarget, MiniProgramAuthModule, MiniProgramCloudLeaderboardModule, MiniProgramCloudModule, MiniProgramCloudStorageModule, MiniProgramCompanionModule, MiniProgramCopyLinkOptions, MiniProgramDeviceModule, MiniProgramEnvironmentInfo, MiniProgramEnvironmentModule, MiniProgramEventHandler, MiniProgramGameDetailGameType, MiniProgramGameDetailPage, MiniProgramNavigationBarForegroundStyle, MiniProgramNavigationModule, MiniProgramNetworkHeaders, MiniProgramNetworkModule, MiniProgramNetworkParams, MiniProgramNetworkRequestConfig, MiniProgramNetworkRequestMethod, MiniProgramNetworkResponse, MiniProgramNetworkValidateStatus, MiniProgramSDKHandshakeState, MiniProgramSDKHandshakeStateHandler, MiniProgramSafeArea, MiniProgramScreenshotOptions, MiniProgramScreenshotRect, MiniProgramSetNavigationBarStyleOptions, MiniProgramShareChannel, MiniProgramShareExtraValue, MiniProgramShareModule, MiniProgramSharePostOptions, MiniProgramShowShareMenuOptions, MiniProgramStorageModule, MiniProgramToastStatus, MiniProgramUiModule, MiniProgramUserModule, MiniProgramVibrateIntensity, MiniProgramViewportModule, MiniProgramWindowInfoResult, NetworkRequestPayload, NetworkResponsePayload, OpenAppPageOptions, OpenAppPagePayload, OpenAppPageResult, OpenGameDetailAppPageOptions, OpenGameDetailAppPagePayload, OpenMiniProgramAppPageOptions, OpenMiniProgramAppPagePayload, OpenPostDetailAppPageOptions, OpenPostDetailAppPagePayload, OpenUserDetailAppPageOptions, OpenUserDetailAppPagePayload, PathRoot, PickDirectoryOptions, PickFilesOptions, PickMediaOptions, ReloadPayload, ReloadResult, RemoveOptions, RevokeAuthorizationPayload, RevokeAuthorizationResult, SaveFileOptions, ScreenshotPayload, ScreenshotResult, SetClipboardPayload, SetClipboardResult, SetNavigationBarStylePayload, SetNavigationBarStyleResult, SetStoragePayload, ShowLoadingPayload, ShowLoadingResult, ShowShareMenuPayload, ShowShareMenuResult, ShowToastPayload, ShowToastResult, SteamGameListData, SteamGameListItem, SteamGameListSort, SubmitLeaderboardEntryPayload, SubmitLeaderboardEntryResult, UploadBaseOptions, UploadOptions, UploadProgress, UploadResponse, VibratePayload, VibrateResult, WorkspaceCardsModule };
8084
+ export type { ClosePayload, CloseResult, CompanionAttachments, CompanionExitHandler, CompanionNotification, CompanionNotifications, CompanionOutputHandler, CompanionOwnershipLostHandler, CompanionPrepareOptions, CompanionSession, CompanionState, CompanionStateChangeHandler, CompanionStdio, CopyLinkPayload, CopyLinkResult, CreateOptions, DeleteCurrentUserLeaderboardEntryPayload, DeleteCurrentUserLeaderboardEntryResult, DirectoryHandle, DownloadBaseOptions, DownloadOptions, DownloadProgress, FileHandle, FileMode, FileStat, FileSystem, FileSystemEntity, FilesModule, GameSaveFileInfo, GameSaveInfo, GameSavesFileOptions, GameSavesModule, GameSavesSyncOptions, GetCurrentUserLeaderboardEntryPayload, GetCurrentUserLeaderboardEntryResult, GetLeaderboardInfoPayload, GetLeaderboardInfoResult, GetLeaderboardListPayload, GetLeaderboardListResult, GetSteamGameListOptions, GetSteamGameListPayload, GetSteamGameListResult, GetStoragePayload, GetStorageResult, GetUserInfoPayload, GetUserInfoResult, GetWindowInfoPayload, GetWindowInfoResult, HideLoadingPayload, HideLoadingResult, LeaderboardEntry, LeaderboardOrder, ListOptions, LoginOptions, LoginPayload, LoginResult, LoginScope, MediaImageItem, MediaItem, MediaModule, MediaSelectionType, MediaType, MediaVideoItem, MiniProgramAppPageTarget, MiniProgramAuthModule, MiniProgramCloudLeaderboardModule, MiniProgramCloudModule, MiniProgramCloudStorageModule, MiniProgramCompanionModule, MiniProgramCopyLinkOptions, MiniProgramDeviceModule, MiniProgramEnvironmentInfo, MiniProgramEnvironmentModule, MiniProgramEventHandler, MiniProgramGameDetailGameType, MiniProgramGameDetailPage, MiniProgramNavigationBarForegroundStyle, MiniProgramNavigationModule, MiniProgramNetworkHeaders, MiniProgramNetworkModule, MiniProgramNetworkParams, MiniProgramNetworkRequestConfig, MiniProgramNetworkRequestMethod, MiniProgramNetworkResponse, MiniProgramNetworkValidateStatus, MiniProgramSDKHandshakeState, MiniProgramSDKHandshakeStateHandler, MiniProgramSafeArea, MiniProgramScreenshotElementOptions, MiniProgramScreenshotOptions, MiniProgramScreenshotRect, MiniProgramSetNavigationBarStyleOptions, MiniProgramShareChannel, MiniProgramShareExtraValue, MiniProgramShareModule, MiniProgramSharePostOptions, MiniProgramShowShareMenuOptions, MiniProgramStorageModule, MiniProgramToastStatus, MiniProgramUiModule, MiniProgramUserModule, MiniProgramVibrateIntensity, MiniProgramViewportModule, MiniProgramWindowInfoResult, NetworkRequestPayload, NetworkResponsePayload, OpenAppPageOptions, OpenAppPagePayload, OpenAppPageResult, OpenGameDetailAppPageOptions, OpenGameDetailAppPagePayload, OpenMiniProgramAppPageOptions, OpenMiniProgramAppPagePayload, OpenPostDetailAppPageOptions, OpenPostDetailAppPagePayload, OpenUserDetailAppPageOptions, OpenUserDetailAppPagePayload, PathRoot, PickDirectoryOptions, PickFilesOptions, PickMediaOptions, ReloadPayload, ReloadResult, RemoveOptions, RevokeAuthorizationPayload, RevokeAuthorizationResult, SaveFileOptions, ScreenshotPayload, ScreenshotResult, SetClipboardPayload, SetClipboardResult, SetNavigationBarStylePayload, SetNavigationBarStyleResult, SetStoragePayload, ShowLoadingPayload, ShowLoadingResult, ShowShareMenuPayload, ShowShareMenuResult, ShowToastPayload, ShowToastResult, SteamGameListData, SteamGameListItem, SteamGameListSort, SubmitLeaderboardEntryPayload, SubmitLeaderboardEntryResult, UploadBaseOptions, UploadOptions, UploadProgress, UploadResponse, VibratePayload, VibrateResult, WorkspaceCardsModule };