@heybox/hb-sdk 0.9.9-alpha.11 → 0.9.9-alpha.12

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 (30) hide show
  1. package/dist/cli-chunks/{build-D_2l0CIV.cjs → build-B3VyxfKr.cjs} +4 -4
  2. package/dist/cli-chunks/{create-0QH1Tn92.cjs → create-39LGd3Va.cjs} +1 -1
  3. package/dist/cli-chunks/{dev-CS5VPiB1.cjs → dev-B3gKz4BL.cjs} +16731 -15662
  4. package/dist/cli-chunks/{doctor-B33mYzm-.cjs → doctor-BE6I4-rx.cjs} +1 -1
  5. package/dist/cli-chunks/{game-binding-guide-DMDuw1Pj.cjs → game-binding-guide-DDa7jfSf.cjs} +2 -2
  6. package/dist/cli-chunks/{game-bindings-CQWdvXfM.cjs → game-bindings-Btsa9s9U.cjs} +3 -3
  7. package/dist/cli-chunks/{games-deIaD0qu.cjs → games-Dgs1h1U5.cjs} +1 -1
  8. package/dist/cli-chunks/{index-C91c2NGN.cjs → index-BGtIgSyr.cjs} +1 -1
  9. package/dist/cli-chunks/{index-DpfxAeSH.cjs → index-DdaTdCPN.cjs} +449 -21
  10. package/dist/cli-chunks/{index.esm-B2WXn2A4.cjs → index.esm-_pGbNbXF.cjs} +10 -10
  11. package/dist/cli-chunks/{login-D7XGHQFo.cjs → login-Bal-XkCR.cjs} +1 -1
  12. package/dist/cli-chunks/{project-vite-B7sylnO7.cjs → project-vite-BBF1D8Bo.cjs} +1 -1
  13. package/dist/cli-chunks/{remote-Crnu4l7X.cjs → remote-pyeuWkyG.cjs} +23 -4
  14. package/dist/cli-chunks/{runtime-permission-env-Cj9STUWz.cjs → runtime-permission-env-E7_Ozj6z.cjs} +2 -2
  15. package/dist/cli-chunks/{skill-BDswKf84.cjs → skill-DQze9VfS.cjs} +2 -2
  16. package/dist/cli-chunks/{version-Dl0HQVTu.cjs → version-CgVSWQYR.cjs} +1 -1
  17. package/dist/cli.cjs +1 -1
  18. package/dist/devtools/browser-dev-host/assets/{browser-dev-host-Be8jnz2C.js → browser-dev-host-CRF7uMBi.js} +1 -1
  19. package/dist/devtools/browser-dev-host/assets/{desktop-app-launch-z3rWAJJc.js → desktop-app-launch-CRCVNdl9.js} +1 -1
  20. package/dist/devtools/browser-dev-host/assets/index-870cPYsT.css +1 -0
  21. package/dist/devtools/browser-dev-host/assets/{index-CvUCSIVI.js → index-CdokjhK8.js} +9 -9
  22. package/dist/devtools/browser-dev-host/assets/pc-onboarding-example-BS3sevnG.webp +0 -0
  23. package/dist/devtools/browser-dev-host/index.html +3 -3
  24. package/dist/index.cjs.js +1 -1
  25. package/dist/index.esm.js +1 -1
  26. package/dist/vite.cjs.js +1 -1
  27. package/dist/vite.esm.js +1 -1
  28. package/package.json +5 -4
  29. package/skill/skill.json +4 -4
  30. package/dist/devtools/browser-dev-host/assets/index-DQgWBZbX.css +0 -1
@@ -1,7 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var dev = require('./dev-CS5VPiB1.cjs');
4
- require('./index-DpfxAeSH.cjs');
3
+ var dev = require('./dev-B3gKz4BL.cjs');
4
+ require('node:crypto');
5
+ require('./index-DdaTdCPN.cjs');
5
6
  require('node:module');
6
7
  require('readline');
7
8
  require('os');
@@ -11,7 +12,6 @@ require('events');
11
12
  require('stream');
12
13
  require('buffer');
13
14
  require('util');
14
- require('node:crypto');
15
15
  require('node:path');
16
16
  require('path');
17
17
  require('fs');
@@ -23,25 +23,25 @@ require('node:child_process');
23
23
  require('node:util');
24
24
  require('node:readline/promises');
25
25
  require('node:timers/promises');
26
+ require('crypto');
27
+ require('./version-CgVSWQYR.cjs');
26
28
  require('node:os');
27
- require('./remote-Crnu4l7X.cjs');
29
+ require('./remote-pyeuWkyG.cjs');
28
30
  require('./index.esm-CenYK5Bl.cjs');
29
- require('./runtime-permission-env-Cj9STUWz.cjs');
30
- require('./version-Dl0HQVTu.cjs');
31
+ require('./runtime-permission-env-E7_Ozj6z.cjs');
31
32
  require('./bindings-B9HSKhmy.cjs');
32
33
  require('node:url');
33
34
  require('./_commonjs-dynamic-modules-DUamuDzp.cjs');
34
35
  require('inspector');
35
36
  require('node:async_hooks');
36
37
  require('sharp');
37
- require('./game-binding-guide-DMDuw1Pj.cjs');
38
- require('./games-deIaD0qu.cjs');
38
+ require('./game-binding-guide-DDa7jfSf.cjs');
39
+ require('./games-Dgs1h1U5.cjs');
39
40
  require('node:net');
40
41
  require('node:dns/promises');
41
42
  require('node:http');
42
43
  require('node:events');
43
44
  require('undici');
44
- require('crypto');
45
45
  require('./browser-RAy8e8cV.cjs');
46
46
  require('node:process');
47
47
  require('node:buffer');
@@ -51,7 +51,7 @@ require('net');
51
51
  require('tls');
52
52
  require('url');
53
53
  require('zlib');
54
- require('./project-vite-B7sylnO7.cjs');
54
+ require('./project-vite-BBF1D8Bo.cjs');
55
55
 
56
56
  /**
57
57
  * @packageDocumentation
@@ -3,7 +3,7 @@
3
3
  var promises = require('node:readline/promises');
4
4
  var node_crypto = require('node:crypto');
5
5
  var node_http = require('node:http');
6
- var index = require('./index-DpfxAeSH.cjs');
6
+ var index = require('./index-DdaTdCPN.cjs');
7
7
  var browser = require('./browser-RAy8e8cV.cjs');
8
8
  require('node:module');
9
9
  require('readline');
@@ -4,7 +4,7 @@ var fs = require('node:fs/promises');
4
4
  var node_module = require('node:module');
5
5
  var path = require('node:path');
6
6
  var node_url = require('node:url');
7
- var index = require('./index-DpfxAeSH.cjs');
7
+ var index = require('./index-DdaTdCPN.cjs');
8
8
 
9
9
  async function loadProjectVite(projectRoot) {
10
10
  const projectRequire = node_module.createRequire(path.join(projectRoot, 'package.json'));
@@ -1,15 +1,15 @@
1
1
  'use strict';
2
2
 
3
3
  var index_esm = require('./index.esm-CenYK5Bl.cjs');
4
- var runtimePermissionEnv = require('./runtime-permission-env-Cj9STUWz.cjs');
4
+ var runtimePermissionEnv = require('./runtime-permission-env-E7_Ozj6z.cjs');
5
5
  var node_crypto = require('node:crypto');
6
6
  var fs = require('node:fs/promises');
7
7
  var path = require('node:path');
8
8
  var fs$1 = require('node:fs');
9
9
  var sharp = require('sharp');
10
- var gameBindingGuide = require('./game-binding-guide-DMDuw1Pj.cjs');
10
+ var gameBindingGuide = require('./game-binding-guide-DDa7jfSf.cjs');
11
11
  var promises = require('node:readline/promises');
12
- var index = require('./index-DpfxAeSH.cjs');
12
+ var index = require('./index-DdaTdCPN.cjs');
13
13
  var childProcess = require('node:child_process');
14
14
  require('node:zlib');
15
15
 
@@ -522,6 +522,23 @@ function isTruthyEnvFlag(value) {
522
522
  const PC_ADAPTATION_GUIDE_URL = 'https://docs.xiaoheihe.cn/hb_sdk/guide/pc-adaptation';
523
523
  const PC_CLIENT_DOWNLOAD_URL = 'https://www.xiaoheihe.cn';
524
524
  const PC_ONBOARDING_PATH = '/__hb_sdk__/pc-onboarding';
525
+ const PC_ONBOARDING_EVENT_PATH = `${PC_ONBOARDING_PATH}/event`;
526
+ const PC_ONBOARDING_ACTIONS = ['exposure', 'guide', 'download', 'close', 'later'];
527
+ function parsePcOnboardingEvent(input) {
528
+ if (!input || typeof input !== 'object' || Array.isArray(input))
529
+ return;
530
+ const value = input;
531
+ const uuid = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
532
+ if (Object.keys(value).some((key) => !['eventId', 'dialogId', 'source', 'action'].includes(key)) ||
533
+ typeof value.eventId !== 'string' ||
534
+ !uuid.test(value.eventId) ||
535
+ typeof value.dialogId !== 'string' ||
536
+ !uuid.test(value.dialogId) ||
537
+ !['automatic', 'manual'].includes(String(value.source)) ||
538
+ !PC_ONBOARDING_ACTIONS.includes(value.action))
539
+ return;
540
+ return value;
541
+ }
525
542
  /** 平台声明只代表适配承诺,不能据此认定已完成客户端验收。 */
526
543
  function getPcAdaptationSuggestion(platforms) {
527
544
  return platforms.includes('windows') || platforms.includes('macos')
@@ -1001,7 +1018,7 @@ function createDefaultCosClient(uploadToken, COS) {
1001
1018
  };
1002
1019
  }
1003
1020
  async function loadCosConstructor() {
1004
- const cosModule = await Promise.resolve().then(function () { return require('./index-C91c2NGN.cjs'); }).then(function (n) { return n.index; });
1021
+ const cosModule = await Promise.resolve().then(function () { return require('./index-BGtIgSyr.cjs'); }).then(function (n) { return n.index; });
1005
1022
  return cosModule.default;
1006
1023
  }
1007
1024
  function formatSize(bytes) {
@@ -2643,6 +2660,7 @@ var remote = /*#__PURE__*/Object.freeze({
2643
2660
  runRemoteCommand: runRemoteCommand
2644
2661
  });
2645
2662
 
2663
+ exports.PC_ONBOARDING_EVENT_PATH = PC_ONBOARDING_EVENT_PATH;
2646
2664
  exports.PC_ONBOARDING_PATH = PC_ONBOARDING_PATH;
2647
2665
  exports.computeMiniappArtifactReceipt = computeMiniappArtifactReceipt;
2648
2666
  exports.createBrowserDevPermissionState = createBrowserDevPermissionState;
@@ -2652,6 +2670,7 @@ exports.detectPackageManager = detectPackageManager;
2652
2670
  exports.getBoundMiniProgram = getBoundMiniProgram;
2653
2671
  exports.getPcAdaptationSuggestion = getPcAdaptationSuggestion;
2654
2672
  exports.migrateBasicInfo = migrateBasicInfo;
2673
+ exports.parsePcOnboardingEvent = parsePcOnboardingEvent;
2655
2674
  exports.readRemoteMiniProgramPreview = readRemoteMiniProgramPreview;
2656
2675
  exports.remote = remote;
2657
2676
  exports.resolveBrowserFakeContext = resolveBrowserFakeContext;
@@ -2,11 +2,11 @@
2
2
 
3
3
  var fs = require('node:fs');
4
4
  var path = require('node:path');
5
- var version = require('./version-Dl0HQVTu.cjs');
5
+ var version = require('./version-CgVSWQYR.cjs');
6
6
  var bindings = require('./bindings-B9HSKhmy.cjs');
7
7
  var fs$1 = require('node:fs/promises');
8
8
  var index_esm = require('./index.esm-CenYK5Bl.cjs');
9
- var index = require('./index-DpfxAeSH.cjs');
9
+ var index = require('./index-DdaTdCPN.cjs');
10
10
  var node_crypto = require('node:crypto');
11
11
  require('node:zlib');
12
12
  require('node:module');
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var version = require('./version-Dl0HQVTu.cjs');
3
+ var version = require('./version-CgVSWQYR.cjs');
4
4
  var fs = require('node:fs/promises');
5
5
  var path = require('node:path');
6
6
  var childProcess = require('node:child_process');
7
- var index = require('./index-DpfxAeSH.cjs');
7
+ var index = require('./index-DdaTdCPN.cjs');
8
8
  require('node:module');
9
9
  require('readline');
10
10
  require('os');
@@ -3,6 +3,6 @@
3
3
  /** 构建时替换为当前发布包的实际版本。 */
4
4
  const HB_SDK_VERSION = typeof undefined === 'string'
5
5
  ? undefined
6
- : '0.9.9-alpha.11';
6
+ : '0.9.9-alpha.12';
7
7
 
8
8
  exports.HB_SDK_VERSION = HB_SDK_VERSION;
package/dist/cli.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./cli-chunks/index-DpfxAeSH.cjs');
3
+ var index = require('./cli-chunks/index-DdaTdCPN.cjs');
4
4
  require('node:module');
5
5
  require('readline');
6
6
  require('os');
@@ -1,4 +1,4 @@
1
- import{m as Im,H as Hc,a_ as bm,bA as ym,a3 as Nm,bh as wm,bi as Dm,n as wt,bK as ee,ba as cl,l as ul,aM as Sm,e as Fc,aR as Om,aD as Mm,k as Cm,aN as Rm,bE as mn,aY as Vn,aX as io,aZ as ki,b2 as dl,b4 as Lm,f as Wi,v as Pm,ap as $i,Z as Jo,aQ as vm,j as so,at as ao,h as km,be as ll,aI as xm,G as Um,b0 as fl,U as Bm,z as Hm,aF as Fm,y as zm,bb as jm,bC as hl,bB as ml,b6 as Vm,g as oo,aH as Gm,b as Er,c as Ym}from"./desktop-app-launch-z3rWAJJc.js";function Qm(){return{targetId:"ui-preview-target",ownerId:"ui-preview-owner",adapterId:"browser-dev-host",kind:"browser",capabilities:{storage:!0,presentation:!0,sandboxList:!0,sandboxRead:!0},state:"attached",currentInstanceId:"ui-preview-instance",cdpTargetId:"ui-preview-browser-target",metadata:{displayName:"UI 预览(模拟)",browser:"Chrome",os:"macOS"},updatedAt:Date.now(),stale:!1}}function qm(){return[{key:"network",label:"网络请求",state:"approved",facts:{platformApproval:!0,temporary:!1,effective:!0,online:"enabled"}},{key:"companion",label:"桌面辅助应用",state:"temporary",facts:{platformApproval:!1,temporary:!0,effective:!0,online:"disabled"},releaseDifference:"发布前需要获得平台批准。"},{key:"network.useOfficialDomain",label:"官方域名",state:"unavailable",facts:{platformApproval:!1,temporary:!1,effective:!1,online:"disabled"},reason:"不支持本地临时授权,获得平台批准后才能使用。"}]}const Ti={device:'[data-preview-target="device"]',screen:'[data-preview-target="screen"]',app:"#device iframe",workbench:'[data-testid="workbench-root"]'},zc=15e3,Wm=32*1024*1024,jc="data-hb-preview-capture-device",wa="data-hb-preview-capture-ancestor",Vc="data-hb-preview-capture-surface",Gc=64,$m=1024;function Km(e={}){const t=e.document??globalThis.document,r=t.defaultView,n=e.leaseMs??zc;if(!Number.isFinite(n)||n<=0||n>zc)throw tt("INVALID_CAPTURE_LEASE","截图租约无效");let i;function s(d,l,h){d.attributes.push({element:l,name:h,previous:l.getAttribute(h)}),l.setAttribute(h,d.token)}function a(d){const l=i;if(!l||l.token!==d)return!1;const h=c(l),f=!!l.style?.isConnected;i=void 0,clearTimeout(l.timer),l.removeAbort?.(),l.removeResize?.(),l.observer?.disconnect(),l.style?.remove(),l.bounds?.remove();for(const{element:p,name:g,previous:b}of l.attributes)p.getAttribute(g)===d&&(b===null?p.removeAttribute(g):p.setAttribute(g,b));return l.overlay.remove(),f&&(r.scrollX!==l.scroll.x||r.scrollY!==l.scroll.y)&&r.scrollTo(l.scroll.x,l.scroll.y),h}function c(d){const{viewport:l,target:h,rect:f}=d;if(!h?.isConnected||!f||Date.now()>=d.expiresAt||r.innerWidth!==l.width||r.innerHeight!==l.height||r.devicePixelRatio!==l.devicePixelRatio)return!1;const p=h.getBoundingClientRect();return["left","top","width","height"].every(g=>Math.abs(p[g]-f[g])<.01)}async function u(d,l){if(l?.throwIfAborted(),!Number.isFinite(d.deadlineAt)||Date.now()>=d.deadlineAt)throw tt("PREVIEW_TIMEOUT","截图操作已超时");if(d.scope==="workbench"||!Object.hasOwn(Ti,d.scope))throw tt("INVALID_CAPTURE_SCOPE","设备像素截图仅支持 device、screen 或 app");if(!d.operationId||d.operationId.length>128)throw tt("INVALID_OPERATION","截图操作标识无效");if(!d.previewImage.startsWith("data:image/png;base64,")||d.previewImage.length>Wm)throw tt("INVALID_CAPTURE_IMAGE","共享窗口冻结图无效或过大");if(i)throw tt("PREVIEW_BUSY","已有设备截图正在执行");const h=t.querySelectorAll(Ti.device);if(h.length!==1)throw tt("DEVICE_NOT_UNIQUE","设备画面不唯一或尚未创建");const f=h[0],p=d.scope==="device"?f:t.querySelector(Ti[d.scope]);if(!p||p!==f&&!f.contains(p))throw tt("CAPTURE_TARGET_UNAVAILABLE","截图内容尚未创建");const g=f.getBoundingClientRect();if(!(g.width>0&&g.height>0))throw tt("CAPTURE_TARGET_UNAVAILABLE","设备画面当前不可见");const b=t.createElement("img");b.alt="",b.setAttribute("aria-hidden","true"),b.setAttribute("data-hb-preview-capture-freeze",""),b.style.cssText=`position:fixed;left:0;top:0;width:${r.innerWidth}px;height:${r.innerHeight}px;max-width:none;max-height:none;margin:0;border:0;padding:0;z-index:2147483647;pointer-events:auto;user-select:none;`,b.addEventListener("wheel",Y=>Y.preventDefault(),{passive:!1}),b.addEventListener("touchmove",Y=>Y.preventDefault(),{passive:!1});const y=Math.min(Date.now()+n,d.deadlineAt),N={operationId:d.operationId,token:r.crypto.randomUUID(),overlay:b,attributes:[],scroll:{x:r.scrollX,y:r.scrollY},viewport:{width:r.innerWidth,height:r.innerHeight,devicePixelRatio:r.devicePixelRatio},expiresAt:y};i=N,N.timer=setTimeout(()=>a(N.token),Math.max(0,y-Date.now()));const C=()=>a(N.token);l?.addEventListener("abort",C,{once:!0}),N.removeAbort=()=>l?.removeEventListener("abort",C);const I=()=>{const{viewport:Y}=N;(r.innerWidth!==Y.width||r.innerHeight!==Y.height||r.devicePixelRatio!==Y.devicePixelRatio)&&a(N.token)};r.addEventListener("resize",I),N.removeResize=()=>r.removeEventListener("resize",I);const U=()=>{if(l?.throwIfAborted(),i!==N||Date.now()>=y)throw tt("CAPTURE_EXPIRED","截图布局租约已结束,请重新截图")};try{b.src=d.previewImage,await b.decode(),U();const Y=N.token,R=`[${jc}="${Y}"]`,P=r.getComputedStyle(f),M=new r.DOMMatrixReadOnly(P.transform==="none"?void 0:P.transform),V=Math.atan2(M.b,M.a),z=f.querySelector(".desktop-window__surface"),te=z?z.offsetWidth:Number.parseFloat(P.width),x=z?z.offsetHeight:Number.parseFloat(P.height),Q=P.backgroundColor,j=r.getComputedStyle(t.body).backgroundColor,H=ye=>!ye||ye==="transparent"||ye==="rgba(0, 0, 0, 0)",F=H(Q)?H(j)?"#fff":j:Q;if(!(te>0&&x>0))throw tt("CAPTURE_TARGET_UNAVAILABLE","设备布局尺寸无效");U(),t.body.append(b),s(N,f,jc),z&&s(N,z,Vc);for(let ye=f.parentElement;ye;ye=ye.parentElement)s(N,ye,wa);const v=t.createElement("style");N.style=v;const L=`
1
+ import{m as Im,H as Hc,a_ as bm,bA as ym,a3 as Nm,bh as wm,bi as Dm,n as wt,bK as ee,ba as cl,l as ul,aM as Sm,e as Fc,aR as Om,aD as Mm,k as Cm,aN as Rm,bE as mn,aY as Vn,aX as io,aZ as ki,b2 as dl,b4 as Lm,f as Wi,v as Pm,ap as $i,Z as Jo,aQ as vm,j as so,at as ao,h as km,be as ll,aI as xm,G as Um,b0 as fl,U as Bm,z as Hm,aF as Fm,y as zm,bb as jm,bC as hl,bB as ml,b6 as Vm,g as oo,aH as Gm,b as Er,c as Ym}from"./desktop-app-launch-CRCVNdl9.js";function Qm(){return{targetId:"ui-preview-target",ownerId:"ui-preview-owner",adapterId:"browser-dev-host",kind:"browser",capabilities:{storage:!0,presentation:!0,sandboxList:!0,sandboxRead:!0},state:"attached",currentInstanceId:"ui-preview-instance",cdpTargetId:"ui-preview-browser-target",metadata:{displayName:"UI 预览(模拟)",browser:"Chrome",os:"macOS"},updatedAt:Date.now(),stale:!1}}function qm(){return[{key:"network",label:"网络请求",state:"approved",facts:{platformApproval:!0,temporary:!1,effective:!0,online:"enabled"}},{key:"companion",label:"桌面辅助应用",state:"temporary",facts:{platformApproval:!1,temporary:!0,effective:!0,online:"disabled"},releaseDifference:"发布前需要获得平台批准。"},{key:"network.useOfficialDomain",label:"官方域名",state:"unavailable",facts:{platformApproval:!1,temporary:!1,effective:!1,online:"disabled"},reason:"不支持本地临时授权,获得平台批准后才能使用。"}]}const Ti={device:'[data-preview-target="device"]',screen:'[data-preview-target="screen"]',app:"#device iframe",workbench:'[data-testid="workbench-root"]'},zc=15e3,Wm=32*1024*1024,jc="data-hb-preview-capture-device",wa="data-hb-preview-capture-ancestor",Vc="data-hb-preview-capture-surface",Gc=64,$m=1024;function Km(e={}){const t=e.document??globalThis.document,r=t.defaultView,n=e.leaseMs??zc;if(!Number.isFinite(n)||n<=0||n>zc)throw tt("INVALID_CAPTURE_LEASE","截图租约无效");let i;function s(d,l,h){d.attributes.push({element:l,name:h,previous:l.getAttribute(h)}),l.setAttribute(h,d.token)}function a(d){const l=i;if(!l||l.token!==d)return!1;const h=c(l),f=!!l.style?.isConnected;i=void 0,clearTimeout(l.timer),l.removeAbort?.(),l.removeResize?.(),l.observer?.disconnect(),l.style?.remove(),l.bounds?.remove();for(const{element:p,name:g,previous:b}of l.attributes)p.getAttribute(g)===d&&(b===null?p.removeAttribute(g):p.setAttribute(g,b));return l.overlay.remove(),f&&(r.scrollX!==l.scroll.x||r.scrollY!==l.scroll.y)&&r.scrollTo(l.scroll.x,l.scroll.y),h}function c(d){const{viewport:l,target:h,rect:f}=d;if(!h?.isConnected||!f||Date.now()>=d.expiresAt||r.innerWidth!==l.width||r.innerHeight!==l.height||r.devicePixelRatio!==l.devicePixelRatio)return!1;const p=h.getBoundingClientRect();return["left","top","width","height"].every(g=>Math.abs(p[g]-f[g])<.01)}async function u(d,l){if(l?.throwIfAborted(),!Number.isFinite(d.deadlineAt)||Date.now()>=d.deadlineAt)throw tt("PREVIEW_TIMEOUT","截图操作已超时");if(d.scope==="workbench"||!Object.hasOwn(Ti,d.scope))throw tt("INVALID_CAPTURE_SCOPE","设备像素截图仅支持 device、screen 或 app");if(!d.operationId||d.operationId.length>128)throw tt("INVALID_OPERATION","截图操作标识无效");if(!d.previewImage.startsWith("data:image/png;base64,")||d.previewImage.length>Wm)throw tt("INVALID_CAPTURE_IMAGE","共享窗口冻结图无效或过大");if(i)throw tt("PREVIEW_BUSY","已有设备截图正在执行");const h=t.querySelectorAll(Ti.device);if(h.length!==1)throw tt("DEVICE_NOT_UNIQUE","设备画面不唯一或尚未创建");const f=h[0],p=d.scope==="device"?f:t.querySelector(Ti[d.scope]);if(!p||p!==f&&!f.contains(p))throw tt("CAPTURE_TARGET_UNAVAILABLE","截图内容尚未创建");const g=f.getBoundingClientRect();if(!(g.width>0&&g.height>0))throw tt("CAPTURE_TARGET_UNAVAILABLE","设备画面当前不可见");const b=t.createElement("img");b.alt="",b.setAttribute("aria-hidden","true"),b.setAttribute("data-hb-preview-capture-freeze",""),b.style.cssText=`position:fixed;left:0;top:0;width:${r.innerWidth}px;height:${r.innerHeight}px;max-width:none;max-height:none;margin:0;border:0;padding:0;z-index:2147483647;pointer-events:auto;user-select:none;`,b.addEventListener("wheel",Y=>Y.preventDefault(),{passive:!1}),b.addEventListener("touchmove",Y=>Y.preventDefault(),{passive:!1});const y=Math.min(Date.now()+n,d.deadlineAt),N={operationId:d.operationId,token:r.crypto.randomUUID(),overlay:b,attributes:[],scroll:{x:r.scrollX,y:r.scrollY},viewport:{width:r.innerWidth,height:r.innerHeight,devicePixelRatio:r.devicePixelRatio},expiresAt:y};i=N,N.timer=setTimeout(()=>a(N.token),Math.max(0,y-Date.now()));const C=()=>a(N.token);l?.addEventListener("abort",C,{once:!0}),N.removeAbort=()=>l?.removeEventListener("abort",C);const I=()=>{const{viewport:Y}=N;(r.innerWidth!==Y.width||r.innerHeight!==Y.height||r.devicePixelRatio!==Y.devicePixelRatio)&&a(N.token)};r.addEventListener("resize",I),N.removeResize=()=>r.removeEventListener("resize",I);const U=()=>{if(l?.throwIfAborted(),i!==N||Date.now()>=y)throw tt("CAPTURE_EXPIRED","截图布局租约已结束,请重新截图")};try{b.src=d.previewImage,await b.decode(),U();const Y=N.token,R=`[${jc}="${Y}"]`,P=r.getComputedStyle(f),M=new r.DOMMatrixReadOnly(P.transform==="none"?void 0:P.transform),V=Math.atan2(M.b,M.a),z=f.querySelector(".desktop-window__surface"),te=z?z.offsetWidth:Number.parseFloat(P.width),x=z?z.offsetHeight:Number.parseFloat(P.height),Q=P.backgroundColor,j=r.getComputedStyle(t.body).backgroundColor,H=ye=>!ye||ye==="transparent"||ye==="rgba(0, 0, 0, 0)",F=H(Q)?H(j)?"#fff":j:Q;if(!(te>0&&x>0))throw tt("CAPTURE_TARGET_UNAVAILABLE","设备布局尺寸无效");U(),t.body.append(b),s(N,f,jc),z&&s(N,z,Vc);for(let ye=f.parentElement;ye;ye=ye.parentElement)s(N,ye,wa);const v=t.createElement("style");N.style=v;const L=`
2
2
  [${wa}="${Y}"] {overflow:visible!important;scrollbar-width:none!important;}
3
3
  [${wa}="${Y}"]::-webkit-scrollbar {display:none!important;}
4
4
  [${Vc}="${Y}"] {transform:none!important;transition:none!important;}