@next-bricks/visual-builder 1.30.0 → 1.31.1

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 (117) hide show
  1. package/dist/bricks.json +11 -11
  2. package/dist/chunks/{1122.a2e4f62e.js → 1122.1f550956.js} +2 -2
  3. package/dist/chunks/1122.1f550956.js.map +1 -0
  4. package/dist/chunks/{114.63bf1208.js → 114.c25646f6.js} +2 -2
  5. package/dist/chunks/{114.63bf1208.js.map → 114.c25646f6.js.map} +1 -1
  6. package/dist/chunks/{1940.5f0efc53.js → 1940.fa7d69c6.js} +2 -2
  7. package/dist/chunks/{1940.5f0efc53.js.map → 1940.fa7d69c6.js.map} +1 -1
  8. package/dist/chunks/{2252.6c4f85f9.js → 2252.8c147e6c.js} +3 -3
  9. package/dist/chunks/2252.8c147e6c.js.map +1 -0
  10. package/dist/chunks/{2277.06e20216.js → 2277.e16c7cbf.js} +2 -2
  11. package/dist/chunks/{2277.06e20216.js.map → 2277.e16c7cbf.js.map} +1 -1
  12. package/dist/chunks/{2980.56778607.js → 2980.51717b3f.js} +2 -2
  13. package/dist/chunks/{2980.56778607.js.map → 2980.51717b3f.js.map} +1 -1
  14. package/dist/chunks/{3171.fed38379.js → 3171.9c6b399c.js} +2 -2
  15. package/dist/chunks/{3171.fed38379.js.map → 3171.9c6b399c.js.map} +1 -1
  16. package/dist/chunks/{3933.5bb88d4a.js → 3933.374de7c2.js} +2 -2
  17. package/dist/chunks/{3933.5bb88d4a.js.map → 3933.374de7c2.js.map} +1 -1
  18. package/dist/chunks/{4658.6f1f1b37.js → 4658.e9f4df8f.js} +2 -2
  19. package/dist/chunks/{4658.6f1f1b37.js.map → 4658.e9f4df8f.js.map} +1 -1
  20. package/dist/chunks/{4837.df62d8e1.js → 4837.58fb5576.js} +2 -2
  21. package/dist/chunks/{4837.df62d8e1.js.map → 4837.58fb5576.js.map} +1 -1
  22. package/dist/chunks/{5021.be85545d.js → 5021.ec378b1d.js} +2 -2
  23. package/dist/chunks/5021.ec378b1d.js.map +1 -0
  24. package/dist/chunks/{5399.3fbcbf7e.js → 5399.eb4a18e3.js} +2 -2
  25. package/dist/chunks/{5399.3fbcbf7e.js.map → 5399.eb4a18e3.js.map} +1 -1
  26. package/dist/chunks/{5552.cabbd277.js → 5552.c264a000.js} +2 -2
  27. package/dist/chunks/{5552.cabbd277.js.map → 5552.c264a000.js.map} +1 -1
  28. package/dist/chunks/{6314.9d427e15.js → 6314.ed6c5313.js} +2 -2
  29. package/dist/chunks/{6314.9d427e15.js.map → 6314.ed6c5313.js.map} +1 -1
  30. package/dist/chunks/6846.56c301e6.js +3 -0
  31. package/dist/chunks/6846.56c301e6.js.map +1 -0
  32. package/dist/chunks/{7150.ac864502.js → 7150.5a68b243.js} +3 -3
  33. package/dist/chunks/{7150.ac864502.js.map → 7150.5a68b243.js.map} +1 -1
  34. package/dist/chunks/{7218.57b21ecf.js → 7218.417c6054.js} +2 -2
  35. package/dist/chunks/{7218.57b21ecf.js.map → 7218.417c6054.js.map} +1 -1
  36. package/dist/chunks/{7434.99b24ba5.js → 7434.4ddb3aab.js} +2 -2
  37. package/dist/chunks/{7434.99b24ba5.js.map → 7434.4ddb3aab.js.map} +1 -1
  38. package/dist/chunks/{7733.6aaf0acb.js → 7733.4fc7b710.js} +2 -2
  39. package/dist/chunks/{7733.6aaf0acb.js.map → 7733.4fc7b710.js.map} +1 -1
  40. package/dist/chunks/{790.77b44e6b.js → 790.5aa68ffb.js} +2 -2
  41. package/dist/chunks/{790.77b44e6b.js.map → 790.5aa68ffb.js.map} +1 -1
  42. package/dist/chunks/{9027.21af2a5d.js → 9027.e3490283.js} +2 -2
  43. package/dist/chunks/{9027.21af2a5d.js.map → 9027.e3490283.js.map} +1 -1
  44. package/dist/chunks/{9130.51e9c8f2.js → 9130.117ac8b0.js} +3 -3
  45. package/dist/chunks/{9130.51e9c8f2.js.map → 9130.117ac8b0.js.map} +1 -1
  46. package/dist/chunks/{9559.a7cc0fe6.js → 9559.34ed0b2d.js} +2 -2
  47. package/dist/chunks/{9559.a7cc0fe6.js.map → 9559.34ed0b2d.js.map} +1 -1
  48. package/dist/chunks/{chat-conversation.06c03ce2.js → chat-conversation.5600ab79.js} +3 -3
  49. package/dist/chunks/{chat-conversation.06c03ce2.js.map → chat-conversation.5600ab79.js.map} +1 -1
  50. package/dist/chunks/{chat-preview.75a05ac5.js → chat-preview.f7014cdb.js} +3 -3
  51. package/dist/chunks/{chat-preview.75a05ac5.js.map → chat-preview.f7014cdb.js.map} +1 -1
  52. package/dist/chunks/{check-editor-by-name.151786ec.js → check-editor-by-name.7e2f27ec.js} +2 -2
  53. package/dist/chunks/{check-editor-by-name.151786ec.js.map → check-editor-by-name.7e2f27ec.js.map} +1 -1
  54. package/dist/chunks/{contract-select.b4daeecc.js → contract-select.858bf125.js} +3 -3
  55. package/dist/chunks/{contract-select.b4daeecc.js.map → contract-select.858bf125.js.map} +1 -1
  56. package/dist/chunks/{generate-snippets-context-menu.a076f5f7.js → generate-snippets-context-menu.83328abe.js} +2 -2
  57. package/dist/chunks/{generate-snippets-context-menu.a076f5f7.js.map → generate-snippets-context-menu.83328abe.js.map} +1 -1
  58. package/dist/chunks/{get-data-deps.e521c8d2.js → get-data-deps.d2ca1894.js} +2 -2
  59. package/dist/chunks/{get-data-deps.e521c8d2.js.map → get-data-deps.d2ca1894.js.map} +1 -1
  60. package/dist/chunks/{get-dependency-tree.a0216e9a.js → get-dependency-tree.e2a26654.js} +2 -2
  61. package/dist/chunks/{get-dependency-tree.a0216e9a.js.map → get-dependency-tree.e2a26654.js.map} +1 -1
  62. package/dist/chunks/{inject-chat-preview-agent.79f723c0.js → inject-chat-preview-agent.2c1c58bf.js} +2 -2
  63. package/dist/chunks/{inject-chat-preview-agent.79f723c0.js.map → inject-chat-preview-agent.2c1c58bf.js.map} +1 -1
  64. package/dist/chunks/{inject-preview-agent.4cc9a12f.js → inject-preview-agent.84654232.js} +2 -2
  65. package/dist/chunks/{inject-preview-agent.4cc9a12f.js.map → inject-preview-agent.84654232.js.map} +1 -1
  66. package/dist/chunks/main.1896b359.js +2 -0
  67. package/dist/chunks/{main.fed23272.js.map → main.1896b359.js.map} +1 -1
  68. package/dist/chunks/{page-arch-node.50fe50b2.js → page-arch-node.59e3fed0.js} +3 -3
  69. package/dist/chunks/{page-arch-node.50fe50b2.js.map → page-arch-node.59e3fed0.js.map} +1 -1
  70. package/dist/chunks/{parse-path.571d7d62.js → parse-path.b34df33b.js} +2 -2
  71. package/dist/chunks/{parse-path.571d7d62.js.map → parse-path.b34df33b.js.map} +1 -1
  72. package/dist/chunks/{pre-generated-container.d8e62dfd.js → pre-generated-container.d2f83710.js} +2 -2
  73. package/dist/chunks/{pre-generated-container.d8e62dfd.js.map → pre-generated-container.d2f83710.js.map} +1 -1
  74. package/dist/chunks/{pre-generated-preview.78d438ab.js → pre-generated-preview.03d5b930.js} +3 -3
  75. package/dist/chunks/{pre-generated-preview.78d438ab.js.map → pre-generated-preview.03d5b930.js.map} +1 -1
  76. package/dist/chunks/{pre-generated-table-view.a76e65eb.js → pre-generated-table-view.1a7bcbab.js} +2 -2
  77. package/dist/chunks/{pre-generated-table-view.a76e65eb.js.map → pre-generated-table-view.1a7bcbab.js.map} +1 -1
  78. package/dist/chunks/{property-editor.6e901980.js → property-editor.3bc75a4d.js} +2 -2
  79. package/dist/chunks/{property-editor.6e901980.js.map → property-editor.3bc75a4d.js.map} +1 -1
  80. package/dist/chunks/{workbench-action-list.29085ba6.js → workbench-action-list.dbcbbdac.js} +2 -2
  81. package/dist/chunks/{workbench-action-list.29085ba6.js.map → workbench-action-list.dbcbbdac.js.map} +1 -1
  82. package/dist/chunks/{workbench-action.5cd875ea.js → workbench-action.fecc0cc7.js} +3 -3
  83. package/dist/chunks/{workbench-action.5cd875ea.js.map → workbench-action.fecc0cc7.js.map} +1 -1
  84. package/dist/chunks/{workbench-history-action.6927ae60.js → workbench-history-action.a713bacf.js} +3 -3
  85. package/dist/chunks/{workbench-history-action.6927ae60.js.map → workbench-history-action.a713bacf.js.map} +1 -1
  86. package/dist/chunks/{workbench-pane.9634f35a.js → workbench-pane.76c5f450.js} +3 -3
  87. package/dist/chunks/{workbench-pane.9634f35a.js.map → workbench-pane.76c5f450.js.map} +1 -1
  88. package/dist/chunks/{workbench-sidebar.d9bc1d1a.js → workbench-sidebar.9ff63381.js} +2 -2
  89. package/dist/chunks/{workbench-sidebar.d9bc1d1a.js.map → workbench-sidebar.9ff63381.js.map} +1 -1
  90. package/dist/chunks/{workbench-tree.c3469448.js → workbench-tree.7a82e0b6.js} +3 -3
  91. package/dist/chunks/{workbench-tree.c3469448.js.map → workbench-tree.7a82e0b6.js.map} +1 -1
  92. package/dist/index.742c3f79.js +2 -0
  93. package/dist/index.742c3f79.js.map +1 -0
  94. package/dist/manifest.json +74 -74
  95. package/dist/types.json +13 -13
  96. package/package.json +4 -4
  97. package/dist/chunks/1122.a2e4f62e.js.map +0 -1
  98. package/dist/chunks/2252.6c4f85f9.js.map +0 -1
  99. package/dist/chunks/5021.be85545d.js.map +0 -1
  100. package/dist/chunks/6846.9781d710.js +0 -3
  101. package/dist/chunks/6846.9781d710.js.map +0 -1
  102. package/dist/chunks/main.fed23272.js +0 -2
  103. package/dist/index.af5d8796.js +0 -2
  104. package/dist/index.af5d8796.js.map +0 -1
  105. /package/dist/chunks/{2252.6c4f85f9.js.LICENSE.txt → 2252.8c147e6c.js.LICENSE.txt} +0 -0
  106. /package/dist/chunks/{6846.9781d710.js.LICENSE.txt → 6846.56c301e6.js.LICENSE.txt} +0 -0
  107. /package/dist/chunks/{7150.ac864502.js.LICENSE.txt → 7150.5a68b243.js.LICENSE.txt} +0 -0
  108. /package/dist/chunks/{9130.51e9c8f2.js.LICENSE.txt → 9130.117ac8b0.js.LICENSE.txt} +0 -0
  109. /package/dist/chunks/{chat-conversation.06c03ce2.js.LICENSE.txt → chat-conversation.5600ab79.js.LICENSE.txt} +0 -0
  110. /package/dist/chunks/{chat-preview.75a05ac5.js.LICENSE.txt → chat-preview.f7014cdb.js.LICENSE.txt} +0 -0
  111. /package/dist/chunks/{contract-select.b4daeecc.js.LICENSE.txt → contract-select.858bf125.js.LICENSE.txt} +0 -0
  112. /package/dist/chunks/{page-arch-node.50fe50b2.js.LICENSE.txt → page-arch-node.59e3fed0.js.LICENSE.txt} +0 -0
  113. /package/dist/chunks/{pre-generated-preview.78d438ab.js.LICENSE.txt → pre-generated-preview.03d5b930.js.LICENSE.txt} +0 -0
  114. /package/dist/chunks/{workbench-action.5cd875ea.js.LICENSE.txt → workbench-action.fecc0cc7.js.LICENSE.txt} +0 -0
  115. /package/dist/chunks/{workbench-history-action.6927ae60.js.LICENSE.txt → workbench-history-action.a713bacf.js.LICENSE.txt} +0 -0
  116. /package/dist/chunks/{workbench-pane.9634f35a.js.LICENSE.txt → workbench-pane.76c5f450.js.LICENSE.txt} +0 -0
  117. /package/dist/chunks/{workbench-tree.c3469448.js.LICENSE.txt → workbench-tree.7a82e0b6.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
- "use strict";(globalThis.webpackChunk_next_bricks_visual_builder=globalThis.webpackChunk_next_bricks_visual_builder||[]).push([[9027],{6788:(e,t,o)=>{o.d(t,{b:()=>i});var n=o(8896),a=o(2153),r=o(6946);function i(e){const t=function(e){const t=new Set;return(0,a.h)(e,(e=>{switch(e.type){case"Resolvable":case"EventHandler":{var o;const n=null===(o=e.raw)||void 0===o?void 0:o.useProvider;n&&t.add(n)}}})),t}((0,r.lN)(e)),o=[];for(const e of t)e.includes("@")&&o.push(e);return o}customElements.define("visual-builder.collect-used-contracts",(0,n.createProviderClass)(i))},9027:(e,t,o)=>{o.d(t,{A:()=>D,w:()=>N});var n=o(6916),a=o(3465),r=o(6055),i=o(1030),s=o(8317),d=o.n(s);let l;function c(e){e.preventDefault(),e.stopPropagation(),function(e){const t=g(e);t.length>0&&window.parent.postMessage({sender:"previewer",type:"select-brick",iidList:t},l)}(e.composedPath())}function p(e){e.preventDefault(),e.stopPropagation()}const u=(0,i.throttle)((e=>{const t=g(e);t.length>0&&window.parent.postMessage({sender:"previewer",type:"hover-on-brick",iidList:t},l)}),100,{leading:!1});function v(e){e.preventDefault(),e.stopPropagation(),u(e.composedPath())}function h(e){e.preventDefault(),e.stopPropagation(),u(e.composedPath())}function w(e){e.preventDefault(),e.stopPropagation(),window.parent.postMessage({sender:"previewer",type:"hover-on-brick",iidList:[]},l)}function m(e){e.preventDefault(),e.stopPropagation(),function(e,t){const o=g(e);o.length>0&&window.parent.postMessage({sender:"previewer",type:"context-menu-on-brick",iidList:o,position:t},l)}(e.composedPath(),{x:e.clientX,y:e.clientY})}function g(e){const t=[];for(const o of e)o instanceof HTMLElement&&"string"==typeof o.dataset.iid&&t.push(o.dataset.iid);return t}var y=o(6788);function f(e){const t=typeof e;switch(t){case"string":case"boolean":case"number":return{type:t,value:e};case"undefined":return{type:t}}return null===e?{type:"null"}:Array.isArray(e)?{type:"array",length:e.length}:{type:"object"}}let b=!1,S=n.getHistory,I=n.matchPath,E=n.__secret_internals,L=r.flowApi,k=!1;try{var P;const e=window.dll;if(e&&null!==(P=window.BRICK_NEXT_VERSIONS)&&void 0!==P&&null!==(P=P["brick-container"])&&void 0!==P&&P.startsWith("2.")){const{getHistory:t,developHelper:o,collectDebugContract:n}=e("tYg3"),{matchPath:a}=e("A+yw");S=t,I=a,E={...o,getContextValue(e,t){let{tplStateStoreId:n}=t;return o.getContextValue(e,{tplContextId:n})},getAllContextValues(e){let{tplStateStoreId:t}=e;const n=o.getAllContextValues({tplContextId:t});return Object.fromEntries([...n].map((e=>{let[t,o]=e;return[t,o.value]})))},debugDataValue(e,t){let{tplStateStoreId:n}=t;return o.debugDataValue(e,{tplContextId:n})}},L={collectDebugContract:n},k=!0}}catch(e){console.error("Try to use v2 runtime APIs failed:",e)}let x=null,C=null;async function D(e,t){var o,r;if(b)return;b=!0;const s=t=>{window.parent.postMessage({sender:"previewer",...t},e)};let u,g,k,P;s({type:"preview-started"}),l=e;const D=(e,t,o)=>{const n=T(t);s({type:"highlight-brick",highlightType:e,outlines:n,iid:t,alias:o})};let N;t.templateId&&(N=t.settings);const R=()=>{E.updateTemplatePreviewSettings(t.appId,t.templateId,N),S().reload()},O=()=>{E.updateSnippetPreviewSettings(t.appId,JSON.parse(t.snippetData)),S().reload()},_=()=>{E.updateFormPreviewSettings(t.appId,t.formId,t.formData),S().reload()},q=S();window.addEventListener("message",(async o=>{var r,f;let{data:b,origin:I}=o;if(I===e&&b&&"preview-container"===b.sender)if("builder"===b.forwardedFor)switch(b.type){case"hover-on-brick":u=b.iid,g=b.alias,D("hover",b.iid,b.alias);break;case"hover-on-main":D("hover","#main-mount-point","root");break;case"hover-on-context":(e=>{const t=e.map((e=>T(e.iid,e.alias))).flat();s({type:"highlight-context",outlines:t})})(b.highlightNodes);break;case"select-brick":k=b.iid,P=b.alias,D("active",b.iid,b.alias);break;case"hover-on-iframe":(e=>{const t=document.elementFromPoint(e.x,e.y);if("BODY"===(null==t?void 0:t.tagName))window.parent.postMessage({sender:"previewer",type:"hover-on-main",isDirection:!0,position:{x:e.x,y:e.y}},l);else{const o=function(e){const t=[];let o=e;for(;o;)"string"==typeof o.dataset.iid&&t.push(o.dataset.iid),o=o.parentElement;return t}(t);window.parent.postMessage({sender:"previewer",type:"hover-on-brick",iidList:o,isDirection:!0,position:{x:e.x,y:e.y}},l)}})(b.position)}else switch(b.type){case"toggle-inspecting":b.enabled?(window.addEventListener("click",c,!0),window.addEventListener("mousedown",p,!0),window.addEventListener("mouseover",p,!0),window.addEventListener("mouseup",p,!0),window.addEventListener("pointerdown",v,!0),window.addEventListener("pointermove",h,!0),window.addEventListener("pointerup",p,!0),window.addEventListener("pointerleave",w,!0),window.addEventListener("contextmenu",m,!0)):(window.removeEventListener("click",c,!0),window.removeEventListener("mousedown",p,!0),window.removeEventListener("mouseover",p,!0),window.removeEventListener("mouseup",p,!0),window.removeEventListener("pointerdown",v,!0),window.removeEventListener("pointermove",h,!0),window.removeEventListener("pointerup",p,!0),window.removeEventListener("pointerleave",w,!0),window.removeEventListener("contextmenu",m,!0));break;case"refresh":if(null!==(r=b.options)&&void 0!==r&&r.updateStoryboardType){var x;let e;var C,M;"route"===b.options.updateStoryboardType?E.updateStoryboardByRoute(t.appId,b.storyboardPatch):"template"===b.options.updateStoryboardType?E.updateStoryboardByTemplate(t.appId,b.storyboardPatch,b.options.settings):"snippet"===b.options.updateStoryboardType?E.updateStoryboardBySnippet(t.appId,b.storyboardPatch):"form"===b.options.updateStoryboardType&&E.updateFormPreviewSettings(t.appId,t.formId,b.storyboardPatch),"form"!==(null===(x=b.options)||void 0===x?void 0:x.updateStoryboardType)&&(e=await(null===(C=(M=E).getAddedContracts)||void 0===C?void 0:C.call(M,b.storyboardPatch,{appId:t.appId,updateStoryboardType:b.options.updateStoryboardType,formId:t.formId,collectUsedContracts:y.b}))),(0,i.isEmpty)(e)?S().reload():s({type:"contract-update",data:{add:e}});break}E.updateStoryboard(t.appId,b.storyboardPatch),t.templateId?(N=b.settings,R()):t.formId||t.formData?_():null!==(f=b.options)&&void 0!==f&&f.snippetData?(t.snippetData=b.options.snippetData,O()):S().reload();break;case"reload":location.reload();break;case"back":q.goBack();break;case"forward":q.goForward();break;case"capture":(async function(e,t){const o=await d()(document.body,{logging:!1,scale:1,width:window.innerWidth,height:window.innerHeight,foreignObjectRendering:!0}),n=document.createElement("canvas");var a;return function(e,t,o,n){const a=o/n,{width:r,height:i}=e,s=r/i,d=s>=a,l=d?o:n*s,c=d?o/s:n;t.width=l,t.height=c,t.getContext("2d").drawImage(e,0,0,r,i,0,0,l,c),t.toDataURL()}(o,n,e,t),await(a=n,new Promise((function(e,t){a.toBlob((function(o){o?e(o):t()}))})))})(b.maxWidth,b.maxHeight).then((e=>{s({type:"capture-ok",screenshot:e})}),(()=>{s({type:"capture-failed"})}));break;case"inspect-data-value":((e,t)=>{try{const{dataType:o}=t;let n,a,r;if("state"===o&&(n=A(),!n))return void s({type:"inspect-data-value-error",data:{error:{message:"tplStateStoreId not found, unable to preview STATE value"}}});if(e)r="inspect-single-data-value-success",a=E.getContextValue(e,{tplStateStoreId:n});else{r="inspect-all-data-values-success";const e=E.getAllContextValues({tplStateStoreId:n});a=Object.entries(e).map((e=>{let[t,o]=e;return{name:t,value:o}}))}s({type:r,data:{name:e,value:a}})}catch(e){s({type:"inspect-data-value-error",data:{message:e.message}})}})(b.name,b.option);break;case"update-preview-url":{const e=b.previewUrl.startsWith(window.origin)?b.previewUrl.substring(window.origin.length):b.previewUrl,t=(0,n.getBasePath)(),o=e.startsWith(t)?e.substring(t.length-1):e;S().push(o);break}case"update-preview-route":t.routePath=b.routePath,t.routeExact=b.routeExact,B();break;case"debug-data-value":(async(e,o,n)=>{try{o&&L.collectDebugContract([o]);const a=await E.debugDataValue(e,{tplStateStoreId:"state"===n.dataType?A():void 0,routeId:t.routeId});s({type:"debug-data-value-success",data:{debugConf:e,value:a}})}catch(e){s({type:"debug-data-value-error",data:e instanceof a.HttpResponseError?e.responseJson:{message:e.message}})}})(b.debugData,b.contractData,b.options)}})),window.addEventListener("scroll",(()=>{s({type:"scroll",scroll:{x:window.scrollX,y:window.scrollY}})}));let M,H=!0;const V=e=>{s({type:"url-change",url:location.origin+q.createHref(e)}),M=e,B()};function B(){if(t.routePath){const e=!!I(M.pathname,{path:t.routePath,exact:t.routeExact});if(s({type:"route-match-change",match:e}),t.templateId&&!H&&e){const e=document.querySelector("#main-mount-point"),t=new MutationObserver((()=>{1===e.childNodes.length&&"SPAN"===e.firstChild.tagName&&0===e.firstChild.childNodes.length&&(R(),t.disconnect())}));t.observe(e,{childList:!0})}if(t.formId&&!H&&e){const e=document.querySelector("#main-mount-point"),t=new MutationObserver((()=>{1===e.childNodes.length&&"SPAN"===e.firstChild.tagName&&0===e.firstChild.childNodes.length&&(_(),t.disconnect())}));t.observe(e,{childList:!0})}if(t.snippetData&&!H&&e){const e=document.querySelector("#main-mount-point"),t=new MutationObserver((()=>{1===e.childNodes.length&&"SPAN"===e.firstChild.tagName&&0===e.firstChild.childNodes.length&&(O(),t.disconnect())}));t.observe(e,{childList:!0})}H=e}}function j(){var e;const t=document.querySelector("eo-page-view"),o=(null==t||null===(e=t.shadowRoot)||void 0===e?void 0:e.querySelector(".content"))??null;var n;o!==x&&(null===(n=x)||void 0===n||n.removeEventListener("scroll",F),null==o||o.addEventListener("scroll",F),x=o,C=t)}function F(){s({type:"content-scroll",scroll:{x:this.scrollLeft,y:this.scrollTop}})}V(q.location),q.listen(V),t.templateId&&R(),(t.formId||t.formData)&&_(),t.snippetData&&O();const U=()=>{var e;const o=t.routeId,n=E.getLegalRuntimeValue({routeId:o});s({type:"inspect-runtime-data-value",data:{...(0,i.omit)(n,"query"),query:n.query?Object.fromEntries(n.query.entries()):{},path:null===(e=n.match)||void 0===e?void 0:e.params}})};let W;function Y(e){const o=t.templateId?A():void 0;var n,a;(W!==o||e)&&(W=o,null===(n=(a=E).setRealTimeDataInspectRoot)||void 0===n||n.call(a,{tplStateStoreId:o}))}null===(o=(r=E).addRealTimeDataInspectHook)||void 0===o||o.call(r,(e=>{let{changeType:t,tplStateStoreId:o,detail:n}=e;s({type:"real-time-data-inspect-change",changeType:t,tplStateStoreId:o,detail:"update"===t?{name:n.name,annotation:f(n.value)}:{data:Object.fromEntries(Object.entries(n.data).map((e=>{let[t,o]=e;return[t,f(o)]})))}})})),window.addEventListener("route.render",(()=>{Y(!0),U()})),j(),Y(!0),U(),new MutationObserver((0,i.throttle)((()=>{j(),Y(),u&&D("hover",u,g),k&&D("active",k,P)}),100,{leading:!1})).observe(document.body,{subtree:!0,childList:!0})}function T(e,t){if(!e)return[];const o=e.includes("#"),n=function(e,t){return e.map((e=>{var o;const n=null===(o=C)||void 0===o?void 0:o.contains(e),{width:a,height:r,left:i,top:s}=e.getBoundingClientRect();return{width:a,height:r,left:i+window.scrollX+(n?x.scrollLeft:0),top:s+window.scrollY+(n?x.scrollTop:0),alias:t,hasContentScroll:n}}))}(N(e,o),t);return o?n.map((e=>({...e,height:window.innerHeight-e.top}))):n}function N(e,t){const o=[];return function n(a){const r=a.querySelectorAll(t?e:`[data-iid="${e}"]`);if(o.push(...r),!(a===document&&r.length>0))for(const e of a.querySelectorAll("*"))e.shadowRoot&&n(e.shadowRoot)}(document),o}function A(){var e;const t=document.querySelector("#main-mount-point");return null==t||null===(e=t.firstChild)||void 0===e?void 0:e.dataset[k?"tplContextId":"tplStateStoreId"]}}}]);
2
- //# sourceMappingURL=9027.21af2a5d.js.map
1
+ "use strict";(globalThis.webpackChunk_next_bricks_visual_builder=globalThis.webpackChunk_next_bricks_visual_builder||[]).push([[9027],{6788:(e,t,o)=>{o.d(t,{b:()=>i});var n=o(3518),a=o(2153),r=o(6946);function i(e){const t=function(e){const t=new Set;return(0,a.h)(e,(e=>{switch(e.type){case"Resolvable":case"EventHandler":{var o;const n=null===(o=e.raw)||void 0===o?void 0:o.useProvider;n&&t.add(n)}}})),t}((0,r.lN)(e)),o=[];for(const e of t)e.includes("@")&&o.push(e);return o}customElements.define("visual-builder.collect-used-contracts",(0,n.createProviderClass)(i))},9027:(e,t,o)=>{o.d(t,{A:()=>D,w:()=>N});var n=o(1653),a=o(9422),r=o(6055),i=o(1030),s=o(8317),d=o.n(s);let l;function c(e){e.preventDefault(),e.stopPropagation(),function(e){const t=g(e);t.length>0&&window.parent.postMessage({sender:"previewer",type:"select-brick",iidList:t},l)}(e.composedPath())}function p(e){e.preventDefault(),e.stopPropagation()}const u=(0,i.throttle)((e=>{const t=g(e);t.length>0&&window.parent.postMessage({sender:"previewer",type:"hover-on-brick",iidList:t},l)}),100,{leading:!1});function v(e){e.preventDefault(),e.stopPropagation(),u(e.composedPath())}function h(e){e.preventDefault(),e.stopPropagation(),u(e.composedPath())}function w(e){e.preventDefault(),e.stopPropagation(),window.parent.postMessage({sender:"previewer",type:"hover-on-brick",iidList:[]},l)}function m(e){e.preventDefault(),e.stopPropagation(),function(e,t){const o=g(e);o.length>0&&window.parent.postMessage({sender:"previewer",type:"context-menu-on-brick",iidList:o,position:t},l)}(e.composedPath(),{x:e.clientX,y:e.clientY})}function g(e){const t=[];for(const o of e)o instanceof HTMLElement&&"string"==typeof o.dataset.iid&&t.push(o.dataset.iid);return t}var y=o(6788);function f(e){const t=typeof e;switch(t){case"string":case"boolean":case"number":return{type:t,value:e};case"undefined":return{type:t}}return null===e?{type:"null"}:Array.isArray(e)?{type:"array",length:e.length}:{type:"object"}}let b=!1,S=n.getHistory,I=n.matchPath,E=n.__secret_internals,L=r.flowApi,k=!1;try{var P;const e=window.dll;if(e&&null!==(P=window.BRICK_NEXT_VERSIONS)&&void 0!==P&&null!==(P=P["brick-container"])&&void 0!==P&&P.startsWith("2.")){const{getHistory:t,developHelper:o,collectDebugContract:n}=e("tYg3"),{matchPath:a}=e("A+yw");S=t,I=a,E={...o,getContextValue(e,t){let{tplStateStoreId:n}=t;return o.getContextValue(e,{tplContextId:n})},getAllContextValues(e){let{tplStateStoreId:t}=e;const n=o.getAllContextValues({tplContextId:t});return Object.fromEntries([...n].map((e=>{let[t,o]=e;return[t,o.value]})))},debugDataValue(e,t){let{tplStateStoreId:n}=t;return o.debugDataValue(e,{tplContextId:n})}},L={collectDebugContract:n},k=!0}}catch(e){console.error("Try to use v2 runtime APIs failed:",e)}let x=null,C=null;async function D(e,t){var o,r;if(b)return;b=!0;const s=t=>{window.parent.postMessage({sender:"previewer",...t},e)};let u,g,k,P;s({type:"preview-started"}),l=e;const D=(e,t,o)=>{const n=T(t);s({type:"highlight-brick",highlightType:e,outlines:n,iid:t,alias:o})};let N;t.templateId&&(N=t.settings);const R=()=>{E.updateTemplatePreviewSettings(t.appId,t.templateId,N),S().reload()},O=()=>{E.updateSnippetPreviewSettings(t.appId,JSON.parse(t.snippetData)),S().reload()},_=()=>{E.updateFormPreviewSettings(t.appId,t.formId,t.formData),S().reload()},q=S();window.addEventListener("message",(async o=>{var r,f;let{data:b,origin:I}=o;if(I===e&&b&&"preview-container"===b.sender)if("builder"===b.forwardedFor)switch(b.type){case"hover-on-brick":u=b.iid,g=b.alias,D("hover",b.iid,b.alias);break;case"hover-on-main":D("hover","#main-mount-point","root");break;case"hover-on-context":(e=>{const t=e.map((e=>T(e.iid,e.alias))).flat();s({type:"highlight-context",outlines:t})})(b.highlightNodes);break;case"select-brick":k=b.iid,P=b.alias,D("active",b.iid,b.alias);break;case"hover-on-iframe":(e=>{const t=document.elementFromPoint(e.x,e.y);if("BODY"===(null==t?void 0:t.tagName))window.parent.postMessage({sender:"previewer",type:"hover-on-main",isDirection:!0,position:{x:e.x,y:e.y}},l);else{const o=function(e){const t=[];let o=e;for(;o;)"string"==typeof o.dataset.iid&&t.push(o.dataset.iid),o=o.parentElement;return t}(t);window.parent.postMessage({sender:"previewer",type:"hover-on-brick",iidList:o,isDirection:!0,position:{x:e.x,y:e.y}},l)}})(b.position)}else switch(b.type){case"toggle-inspecting":b.enabled?(window.addEventListener("click",c,!0),window.addEventListener("mousedown",p,!0),window.addEventListener("mouseover",p,!0),window.addEventListener("mouseup",p,!0),window.addEventListener("pointerdown",v,!0),window.addEventListener("pointermove",h,!0),window.addEventListener("pointerup",p,!0),window.addEventListener("pointerleave",w,!0),window.addEventListener("contextmenu",m,!0)):(window.removeEventListener("click",c,!0),window.removeEventListener("mousedown",p,!0),window.removeEventListener("mouseover",p,!0),window.removeEventListener("mouseup",p,!0),window.removeEventListener("pointerdown",v,!0),window.removeEventListener("pointermove",h,!0),window.removeEventListener("pointerup",p,!0),window.removeEventListener("pointerleave",w,!0),window.removeEventListener("contextmenu",m,!0));break;case"refresh":if(null!==(r=b.options)&&void 0!==r&&r.updateStoryboardType){var x;let e;var C,M;"route"===b.options.updateStoryboardType?E.updateStoryboardByRoute(t.appId,b.storyboardPatch):"template"===b.options.updateStoryboardType?E.updateStoryboardByTemplate(t.appId,b.storyboardPatch,b.options.settings):"snippet"===b.options.updateStoryboardType?E.updateStoryboardBySnippet(t.appId,b.storyboardPatch):"form"===b.options.updateStoryboardType&&E.updateFormPreviewSettings(t.appId,t.formId,b.storyboardPatch),"form"!==(null===(x=b.options)||void 0===x?void 0:x.updateStoryboardType)&&(e=await(null===(C=(M=E).getAddedContracts)||void 0===C?void 0:C.call(M,b.storyboardPatch,{appId:t.appId,updateStoryboardType:b.options.updateStoryboardType,formId:t.formId,collectUsedContracts:y.b}))),(0,i.isEmpty)(e)?S().reload():s({type:"contract-update",data:{add:e}});break}E.updateStoryboard(t.appId,b.storyboardPatch),t.templateId?(N=b.settings,R()):t.formId||t.formData?_():null!==(f=b.options)&&void 0!==f&&f.snippetData?(t.snippetData=b.options.snippetData,O()):S().reload();break;case"reload":location.reload();break;case"back":q.goBack();break;case"forward":q.goForward();break;case"capture":(async function(e,t){const o=await d()(document.body,{logging:!1,scale:1,width:window.innerWidth,height:window.innerHeight,foreignObjectRendering:!0}),n=document.createElement("canvas");var a;return function(e,t,o,n){const a=o/n,{width:r,height:i}=e,s=r/i,d=s>=a,l=d?o:n*s,c=d?o/s:n;t.width=l,t.height=c,t.getContext("2d").drawImage(e,0,0,r,i,0,0,l,c),t.toDataURL()}(o,n,e,t),await(a=n,new Promise((function(e,t){a.toBlob((function(o){o?e(o):t()}))})))})(b.maxWidth,b.maxHeight).then((e=>{s({type:"capture-ok",screenshot:e})}),(()=>{s({type:"capture-failed"})}));break;case"inspect-data-value":((e,t)=>{try{const{dataType:o}=t;let n,a,r;if("state"===o&&(n=A(),!n))return void s({type:"inspect-data-value-error",data:{error:{message:"tplStateStoreId not found, unable to preview STATE value"}}});if(e)r="inspect-single-data-value-success",a=E.getContextValue(e,{tplStateStoreId:n});else{r="inspect-all-data-values-success";const e=E.getAllContextValues({tplStateStoreId:n});a=Object.entries(e).map((e=>{let[t,o]=e;return{name:t,value:o}}))}s({type:r,data:{name:e,value:a}})}catch(e){s({type:"inspect-data-value-error",data:{message:e.message}})}})(b.name,b.option);break;case"update-preview-url":{const e=b.previewUrl.startsWith(window.origin)?b.previewUrl.substring(window.origin.length):b.previewUrl,t=(0,n.getBasePath)(),o=e.startsWith(t)?e.substring(t.length-1):e;S().push(o);break}case"update-preview-route":t.routePath=b.routePath,t.routeExact=b.routeExact,B();break;case"debug-data-value":(async(e,o,n)=>{try{o&&L.collectDebugContract([o]);const a=await E.debugDataValue(e,{tplStateStoreId:"state"===n.dataType?A():void 0,routeId:t.routeId});s({type:"debug-data-value-success",data:{debugConf:e,value:a}})}catch(e){s({type:"debug-data-value-error",data:e instanceof a.HttpResponseError?e.responseJson:{message:e.message}})}})(b.debugData,b.contractData,b.options)}})),window.addEventListener("scroll",(()=>{s({type:"scroll",scroll:{x:window.scrollX,y:window.scrollY}})}));let M,H=!0;const V=e=>{s({type:"url-change",url:location.origin+q.createHref(e)}),M=e,B()};function B(){if(t.routePath){const e=!!I(M.pathname,{path:t.routePath,exact:t.routeExact});if(s({type:"route-match-change",match:e}),t.templateId&&!H&&e){const e=document.querySelector("#main-mount-point"),t=new MutationObserver((()=>{1===e.childNodes.length&&"SPAN"===e.firstChild.tagName&&0===e.firstChild.childNodes.length&&(R(),t.disconnect())}));t.observe(e,{childList:!0})}if(t.formId&&!H&&e){const e=document.querySelector("#main-mount-point"),t=new MutationObserver((()=>{1===e.childNodes.length&&"SPAN"===e.firstChild.tagName&&0===e.firstChild.childNodes.length&&(_(),t.disconnect())}));t.observe(e,{childList:!0})}if(t.snippetData&&!H&&e){const e=document.querySelector("#main-mount-point"),t=new MutationObserver((()=>{1===e.childNodes.length&&"SPAN"===e.firstChild.tagName&&0===e.firstChild.childNodes.length&&(O(),t.disconnect())}));t.observe(e,{childList:!0})}H=e}}function j(){var e;const t=document.querySelector("eo-page-view"),o=(null==t||null===(e=t.shadowRoot)||void 0===e?void 0:e.querySelector(".content"))??null;var n;o!==x&&(null===(n=x)||void 0===n||n.removeEventListener("scroll",F),null==o||o.addEventListener("scroll",F),x=o,C=t)}function F(){s({type:"content-scroll",scroll:{x:this.scrollLeft,y:this.scrollTop}})}V(q.location),q.listen(V),t.templateId&&R(),(t.formId||t.formData)&&_(),t.snippetData&&O();const U=()=>{var e;const o=t.routeId,n=E.getLegalRuntimeValue({routeId:o});s({type:"inspect-runtime-data-value",data:{...(0,i.omit)(n,"query"),query:n.query?Object.fromEntries(n.query.entries()):{},path:null===(e=n.match)||void 0===e?void 0:e.params}})};let W;function Y(e){const o=t.templateId?A():void 0;var n,a;(W!==o||e)&&(W=o,null===(n=(a=E).setRealTimeDataInspectRoot)||void 0===n||n.call(a,{tplStateStoreId:o}))}null===(o=(r=E).addRealTimeDataInspectHook)||void 0===o||o.call(r,(e=>{let{changeType:t,tplStateStoreId:o,detail:n}=e;s({type:"real-time-data-inspect-change",changeType:t,tplStateStoreId:o,detail:"update"===t?{name:n.name,annotation:f(n.value)}:{data:Object.fromEntries(Object.entries(n.data).map((e=>{let[t,o]=e;return[t,f(o)]})))}})})),window.addEventListener("route.render",(()=>{Y(!0),U()})),j(),Y(!0),U(),new MutationObserver((0,i.throttle)((()=>{j(),Y(),u&&D("hover",u,g),k&&D("active",k,P)}),100,{leading:!1})).observe(document.body,{subtree:!0,childList:!0})}function T(e,t){if(!e)return[];const o=e.includes("#"),n=function(e,t){return e.map((e=>{var o;const n=null===(o=C)||void 0===o?void 0:o.contains(e),{width:a,height:r,left:i,top:s}=e.getBoundingClientRect();return{width:a,height:r,left:i+window.scrollX+(n?x.scrollLeft:0),top:s+window.scrollY+(n?x.scrollTop:0),alias:t,hasContentScroll:n}}))}(N(e,o),t);return o?n.map((e=>({...e,height:window.innerHeight-e.top}))):n}function N(e,t){const o=[];return function n(a){const r=a.querySelectorAll(t?e:`[data-iid="${e}"]`);if(o.push(...r),!(a===document&&r.length>0))for(const e of a.querySelectorAll("*"))e.shadowRoot&&n(e.shadowRoot)}(document),o}function A(){var e;const t=document.querySelector("#main-mount-point");return null==t||null===(e=t.firstChild)||void 0===e?void 0:e.dataset[k?"tplContextId":"tplStateStoreId"]}}}]);
2
+ //# sourceMappingURL=9027.e3490283.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chunks/9027.21af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CA1DmBK,CADAC,EAAgCvO,EAAK8N,GACfnK,GACvC,OAAOmK,EACHlK,EAAS1B,KAAKzE,IAAI,IACbA,EACHoK,OAAQrJ,OAAOsJ,YAAcrK,EAAK2Q,QAEpCxK,CACN,CAEO,SAAS2K,EACdvO,EACA8N,GAEA,MAAMC,EAA0B,GAuBhC,OArBA,SAASS,EAAKC,GACZ,MAAMC,EAAaD,EAAKE,iBACtBb,EAAS9N,EAAM,cAAcA,OAK/B,GAHA+N,EAASpQ,QAAQ+Q,KAGbD,IAAShJ,UAAYiJ,EAAWnQ,OAAS,GAK7C,IAAK,MAAMd,KAAQgR,EAAKE,iBAAiB,KACnClR,EAAK0O,YACPqC,EAAK/Q,EAAK0O,WAGhB,CAEAqC,CAAK/I,UAEEsI,CACT,CAuBA,SAASxE,IAA6C,IAAAqF,EACpD,MAAMrD,EAAiB9F,SAAS+F,cAAc,qBAE9C,OAAQD,SAA0B,QAAZqD,EAAdrD,EAAgBK,kBAAU,IAAAgD,OAAA,EAA3BA,EAA6C7O,QAClDe,EAAO,eAAiB,kBAE5B,C","sources":["webpack:///./src/data-providers/collect-used-contracts.ts","webpack:///./src/data-providers/preview/inspector.ts","webpack:///./src/data-providers/preview/realTimeDataInspect.ts","webpack:///./src/data-providers/preview/connect.ts","webpack:///./src/data-providers/preview/capture.ts","webpack:///./src/data-providers/preview/resizeScreenshot.ts"],"sourcesContent":["import { createProviderClass } from \"@next-core/utils/general\";\nimport {\n type StoryboardNode,\n parseStoryboard,\n traverse,\n} from \"@next-core/storyboard\";\nimport {\n Storyboard,\n UseProviderResolveConf,\n UseProviderEventHandler,\n} from \"@next-core/types\";\n\nfunction collect(nodeOrNodes: StoryboardNode | StoryboardNode[]): Set<string> {\n const collection = new Set<string>();\n\n traverse(nodeOrNodes, (node) => {\n switch (node.type) {\n case \"Resolvable\":\n case \"EventHandler\": {\n const useProvider = (\n node.raw as UseProviderResolveConf | UseProviderEventHandler\n )?.useProvider;\n if (useProvider) {\n collection.add(useProvider);\n }\n }\n }\n });\n\n return collection;\n}\n\nexport function collectUsedContracts(storyboard: Storyboard): string[] {\n const collection = collect(parseStoryboard(storyboard as any));\n\n const contracts = [];\n\n for (const item of collection) {\n if (item.includes(\"@\")) {\n contracts.push(item);\n }\n }\n\n return contracts;\n}\n\ncustomElements.define(\n \"visual-builder.collect-used-contracts\",\n createProviderClass(collectUsedContracts)\n);\n","// istanbul ignore file: working in progress\n// https://github.com/facebook/react/blob/cae635054e17a6f107a39d328649137b83f25972/packages/react-devtools-shared/src/backend/views/Highlighter/index.js\nimport { throttle } from \"lodash\";\nimport type {\n PreviewMessagePreviewerHoverOnBrick,\n PreviewMessagePreviewerSelectBrick,\n PreviewMessagePreviewerContextMenuOnBrick,\n} from \"./interfaces.js\";\n\nexport let previewProxyOrigin: string;\n\nexport function setPreviewFromOrigin(origin: string): void {\n previewProxyOrigin = origin;\n}\n\nexport function startInspecting(): void {\n registerListeners();\n}\n\nexport function stopInspecting(): void {\n unregisterListeners();\n}\n\nfunction registerListeners(): void {\n window.addEventListener(\"click\", onClick, true);\n window.addEventListener(\"mousedown\", onMouseEvent, true);\n window.addEventListener(\"mouseover\", onMouseEvent, true);\n window.addEventListener(\"mouseup\", onMouseEvent, true);\n window.addEventListener(\"pointerdown\", onPointerDown, true);\n window.addEventListener(\"pointermove\", onPointerMove, true);\n window.addEventListener(\"pointerup\", onMouseEvent, true);\n window.addEventListener(\"pointerleave\", onPointerLeave, true);\n window.addEventListener(\"contextmenu\", onContextMenu, true);\n}\n\nfunction unregisterListeners(): void {\n window.removeEventListener(\"click\", onClick, true);\n window.removeEventListener(\"mousedown\", onMouseEvent, true);\n window.removeEventListener(\"mouseover\", onMouseEvent, true);\n window.removeEventListener(\"mouseup\", onMouseEvent, true);\n window.removeEventListener(\"pointerdown\", onPointerDown, true);\n window.removeEventListener(\"pointermove\", onPointerMove, true);\n window.removeEventListener(\"pointerup\", onMouseEvent, true);\n window.removeEventListener(\"pointerleave\", onPointerLeave, true);\n window.removeEventListener(\"contextmenu\", onContextMenu, true);\n}\n\nfunction onClick(event: MouseEvent): void {\n event.preventDefault();\n event.stopPropagation();\n selectBrick(event.composedPath());\n}\n\nfunction onMouseEvent(event: MouseEvent): void {\n event.preventDefault();\n event.stopPropagation();\n}\n\nconst hoverOnBrick = throttle(\n (eventTargets: EventTarget[]) => {\n const iidList = getPossibleBrickTargets(eventTargets);\n\n if (iidList.length > 0) {\n window.parent.postMessage(\n {\n sender: \"previewer\",\n type: \"hover-on-brick\",\n iidList,\n } as PreviewMessagePreviewerHoverOnBrick,\n previewProxyOrigin\n );\n }\n },\n 100,\n { leading: false }\n);\n\nfunction onPointerDown(event: MouseEvent): void {\n event.preventDefault();\n event.stopPropagation();\n hoverOnBrick(event.composedPath());\n}\n\nfunction onPointerMove(event: MouseEvent): void {\n event.preventDefault();\n event.stopPropagation();\n hoverOnBrick(event.composedPath());\n}\n\nfunction onPointerLeave(event: MouseEvent): void {\n event.preventDefault();\n event.stopPropagation();\n window.parent.postMessage(\n {\n sender: \"previewer\",\n type: \"hover-on-brick\",\n iidList: [],\n } as PreviewMessagePreviewerHoverOnBrick,\n previewProxyOrigin\n );\n}\n\nfunction onContextMenu(event: MouseEvent): void {\n event.preventDefault();\n event.stopPropagation();\n contextMenuOnBrick(event.composedPath(), {\n x: event.clientX,\n y: event.clientY,\n });\n}\n\nfunction contextMenuOnBrick(\n eventTargets: EventTarget[],\n position: {\n x: number;\n y: number;\n }\n): void {\n const iidList = getPossibleBrickTargets(eventTargets);\n if (iidList.length > 0) {\n window.parent.postMessage(\n {\n sender: \"previewer\",\n type: \"context-menu-on-brick\",\n iidList,\n position,\n } as PreviewMessagePreviewerContextMenuOnBrick,\n previewProxyOrigin\n );\n }\n}\n\nfunction selectBrick(eventTargets: EventTarget[]): void {\n const iidList = getPossibleBrickTargets(eventTargets);\n if (iidList.length > 0) {\n window.parent.postMessage(\n {\n sender: \"previewer\",\n type: \"select-brick\",\n iidList,\n } as PreviewMessagePreviewerSelectBrick,\n previewProxyOrigin\n );\n }\n}\n\nexport function getPossibleBrickIidList(brick: HTMLElement): string[] {\n const iidList: string[] = [];\n // Traverse from bottom to up, to find bricks current hover on.\n let cursor: HTMLElement | null = brick;\n while (cursor) {\n if (typeof cursor.dataset.iid === \"string\") {\n iidList.push(cursor.dataset.iid);\n }\n cursor = cursor.parentElement;\n }\n return iidList;\n}\n\nexport function getPossibleBrickTargets(eventTargets: EventTarget[]) {\n const targets: string[] = [];\n for (const target of eventTargets) {\n if (\n target instanceof HTMLElement &&\n typeof target.dataset.iid === \"string\"\n ) {\n targets.push(target.dataset.iid);\n }\n }\n return targets;\n}\n","export function getRealTimeDataAnnotation(value: unknown) {\n const type = typeof value;\n switch (type) {\n case \"string\":\n case \"boolean\":\n case \"number\":\n return {\n type,\n value,\n };\n case \"undefined\":\n return { type };\n }\n if (value === null) {\n return { type: \"null\" };\n }\n if (Array.isArray(value)) {\n return { type: \"array\", length: value.length };\n }\n return { type: \"object\" };\n}\n","import {\n getHistory as _getHistory,\n getBasePath,\n matchPath as _matchPath,\n __secret_internals as _internals,\n type NextLocation,\n} from \"@next-core/runtime\";\nimport { HttpResponseError } from \"@next-core/http\";\nimport { flowApi as _flowAPi } from \"@next-core/easyops-runtime\";\nimport type {\n BrickConf,\n Contract,\n CustomTemplate,\n RouteConf,\n} from \"@next-core/types\";\nimport { isEmpty, throttle, omit } from \"lodash\";\nimport type {\n BrickOutline,\n HighLightNode,\n Position,\n PreviewDataOption,\n PreviewMessageFromPreviewer,\n PreviewMessagePreviewContractUpdate,\n PreviewMessagePreviewDataValueError,\n PreviewMessagePreviewDataValueSuccess,\n PreviewMessagePreviewDebugValueSuccess,\n PreviewMessagePreviewDebugValueError,\n PreviewMessagePreviewerCaptureFailed,\n PreviewMessagePreviewerCaptureOk,\n PreviewMessagePreviewerContentScroll,\n PreviewMessagePreviewerHighlightBrick,\n PreviewMessagePreviewerHighlightContext,\n PreviewMessagePreviewerHoverOnMain,\n PreviewMessagePreviewerRealTimeDataInspectChange,\n PreviewMessagePreviewerRouteMatchChange,\n PreviewMessagePreviewerScroll,\n PreviewMessagePreviewerUrlChange,\n PreviewMessageToPreviewer,\n PreviewSettings,\n PreviewStartOptions,\n PreviewDebugData,\n PreviewMessagePreviewInspectRuntimeValue,\n} from \"./interfaces.js\";\nimport { capture } from \"./capture.js\";\nimport {\n previewProxyOrigin,\n getPossibleBrickIidList,\n setPreviewFromOrigin,\n startInspecting,\n stopInspecting,\n} from \"./inspector.js\";\nimport { collectUsedContracts } from \"../collect-used-contracts.js\";\nimport { getRealTimeDataAnnotation } from \"./realTimeDataInspect.js\";\n\nlet connected = false;\n\ninterface DLL {\n (moduleId: \"tYg3\"): {\n getHistory: typeof _getHistory;\n developHelper: typeof _internals;\n collectDebugContract: typeof flowApi.collectDebugContract;\n };\n (moduleId: \"A+yw\"): {\n matchPath: typeof _matchPath;\n };\n}\n\nlet getHistory = _getHistory;\nlet matchPath = _matchPath;\nlet __secret_internals = _internals;\nlet flowApi = _flowAPi;\nlet isV2 = false;\n\n// istanbul ignore next\n// Make v3 bricks compatible with Brick Next v2.\ntry {\n const dll = (window as unknown as { dll?: DLL }).dll;\n if (\n dll &&\n window.BRICK_NEXT_VERSIONS?.[\"brick-container\"]?.startsWith(\"2.\")\n ) {\n const {\n getHistory: getHistoryV2,\n developHelper: developHelperV2,\n collectDebugContract,\n } = dll(\"tYg3\");\n const { matchPath: matchPathV2 } = dll(\"A+yw\");\n getHistory = getHistoryV2;\n matchPath = matchPathV2;\n // The `__secret_internals` of v3 has pretty the same API as\n // `developHelper` of v2, especially those for preview usage.\n __secret_internals = {\n ...developHelperV2,\n getContextValue(name, { tplStateStoreId }) {\n return developHelperV2.getContextValue(name, {\n tplContextId: tplStateStoreId,\n } as any);\n },\n getAllContextValues({ tplStateStoreId }) {\n // V3 returns an object of key-value.\n // While v2 returns a map of ContextItem.\n const v2Map = developHelperV2.getAllContextValues({\n tplContextId: tplStateStoreId,\n } as any) as unknown as Map<string, { value: unknown }>;\n return Object.fromEntries(\n [...v2Map].map(([k, v]) => [k, (v as any).value])\n );\n },\n debugDataValue(data, { tplStateStoreId }) {\n return developHelperV2.debugDataValue(data, {\n tplContextId: tplStateStoreId,\n } as any);\n },\n };\n\n flowApi = {\n collectDebugContract,\n } as any;\n isV2 = true;\n }\n} catch (e) {\n // eslint-disable-next-line no-console\n console.error(\"Try to use v2 runtime APIs failed:\", e);\n}\n\nlet contentScrollElement: Element | null = null;\nlet contentScrollHost: Element | null = null;\n\nexport default async function connect(\n previewFromOrigin: string,\n options: PreviewStartOptions\n) {\n if (connected) {\n return;\n }\n connected = true;\n\n const sendMessage = <T extends PreviewMessageFromPreviewer>(\n message: Omit<T, \"sender\">\n ): void => {\n window.parent.postMessage(\n {\n sender: \"previewer\",\n ...message,\n },\n previewFromOrigin\n );\n };\n\n sendMessage({ type: \"preview-started\" });\n setPreviewFromOrigin(previewFromOrigin);\n\n let hoverIid: string;\n let hoverAlias: string;\n let activeIid: string;\n let activeAlias: string;\n\n const handleHoverOnIframe = (pos: Position): void => {\n const element = document.elementFromPoint(pos.x, pos.y);\n if (element?.tagName === \"BODY\") {\n window.parent.postMessage(\n {\n sender: \"previewer\",\n type: \"hover-on-main\",\n isDirection: true,\n position: {\n x: pos.x,\n y: pos.y,\n },\n } as PreviewMessagePreviewerHoverOnMain,\n previewProxyOrigin\n );\n } else {\n const iidList = getPossibleBrickIidList(element as HTMLElement);\n window.parent.postMessage(\n {\n sender: \"previewer\",\n type: \"hover-on-brick\",\n iidList,\n isDirection: true,\n position: {\n x: pos.x,\n y: pos.y,\n },\n },\n previewProxyOrigin\n );\n }\n };\n\n const sendHighlightBrickOutlines = (\n type: \"hover\" | \"active\",\n iid: string,\n alias: string\n ): void => {\n const outlines = getBrickOutlines(iid);\n sendMessage<PreviewMessagePreviewerHighlightBrick>({\n type: \"highlight-brick\",\n highlightType: type,\n outlines,\n iid: iid,\n alias: alias,\n });\n };\n\n const sendHighlightBricksOutlines = (nodes: HighLightNode[]): void => {\n const outlines = nodes\n .map((node) => getBrickOutlines(node.iid, node.alias))\n .flat();\n sendMessage<PreviewMessagePreviewerHighlightContext>({\n type: \"highlight-context\",\n outlines,\n });\n };\n\n let lastTemplatePreviewSettings: PreviewSettings | undefined;\n if (options.templateId) {\n lastTemplatePreviewSettings = options.settings;\n }\n\n const updateTemplatePreviewSettings = (): void => {\n __secret_internals.updateTemplatePreviewSettings(\n options.appId,\n options.templateId!,\n lastTemplatePreviewSettings\n );\n getHistory().reload();\n };\n\n const updateSnippetPreviewSettings = (): void => {\n __secret_internals.updateSnippetPreviewSettings(\n options.appId,\n JSON.parse(options.snippetData)\n );\n getHistory().reload();\n };\n\n const updateFormPreviewSettings = (): void => {\n (__secret_internals as any).updateFormPreviewSettings(\n options.appId,\n options.formId,\n options.formData\n );\n getHistory().reload();\n };\n\n const handlePreviewData = (name: string, option: PreviewDataOption): void => {\n try {\n const { dataType } = option;\n let tplStateStoreId;\n\n if (dataType === \"state\") {\n tplStateStoreId = getRootTplStateStoreId();\n\n if (!tplStateStoreId) {\n sendMessage<PreviewMessagePreviewDataValueError>({\n type: \"inspect-data-value-error\",\n data: {\n error: {\n message:\n \"tplStateStoreId not found, unable to preview STATE value\",\n },\n },\n });\n\n return;\n }\n }\n\n let value, type: PreviewMessagePreviewDataValueSuccess[\"type\"];\n if (name) {\n type = \"inspect-single-data-value-success\";\n value = __secret_internals.getContextValue(name, {\n tplStateStoreId,\n });\n } else {\n type = \"inspect-all-data-values-success\";\n const data = __secret_internals.getAllContextValues({\n tplStateStoreId,\n });\n value = Object.entries(data).map(([name, value]) => ({ name, value }));\n }\n\n sendMessage<PreviewMessagePreviewDataValueSuccess>({\n type,\n data: {\n name,\n value,\n },\n });\n\n // istanbul ignore next\n } catch (error) {\n sendMessage<PreviewMessagePreviewDataValueError>({\n type: \"inspect-data-value-error\",\n data: {\n message: (error as Error).message,\n },\n });\n }\n };\n\n const debugDataValue = async (\n data: PreviewDebugData,\n contractData: Contract,\n previewOption: PreviewDataOption\n ) => {\n try {\n if (contractData) {\n flowApi.collectDebugContract([contractData]);\n }\n const value = await __secret_internals.debugDataValue(data, {\n tplStateStoreId:\n previewOption.dataType === \"state\"\n ? getRootTplStateStoreId()\n : undefined,\n routeId: options.routeId,\n });\n\n sendMessage<PreviewMessagePreviewDebugValueSuccess>({\n type: \"debug-data-value-success\",\n data: {\n debugConf: data,\n value,\n },\n });\n } catch (error) {\n sendMessage<PreviewMessagePreviewDebugValueError>({\n type: \"debug-data-value-error\",\n data:\n error instanceof HttpResponseError\n ? error.responseJson\n : { message: (error as Error).message },\n });\n }\n };\n\n const history = getHistory();\n\n window.addEventListener(\n \"message\",\n async ({ data, origin }: MessageEvent<PreviewMessageToPreviewer>) => {\n if (\n origin !== previewFromOrigin ||\n !data ||\n data.sender !== \"preview-container\"\n ) {\n return;\n }\n if (data.forwardedFor === \"builder\") {\n switch (data.type) {\n case \"hover-on-brick\":\n hoverIid = data.iid;\n hoverAlias = data.alias;\n sendHighlightBrickOutlines(\"hover\", data.iid, data.alias);\n break;\n case \"hover-on-main\":\n sendHighlightBrickOutlines(\"hover\", \"#main-mount-point\", \"root\");\n break;\n case \"hover-on-context\":\n sendHighlightBricksOutlines(data.highlightNodes);\n break;\n case \"select-brick\":\n activeIid = data.iid;\n activeAlias = data.alias;\n sendHighlightBrickOutlines(\"active\", data.iid, data.alias);\n break;\n case \"hover-on-iframe\":\n handleHoverOnIframe(data.position);\n break;\n }\n } else\n switch (data.type) {\n case \"toggle-inspecting\":\n data.enabled ? startInspecting() : stopInspecting();\n break;\n case \"refresh\":\n if (data.options?.updateStoryboardType) {\n if (data.options.updateStoryboardType === \"route\") {\n __secret_internals.updateStoryboardByRoute(\n options.appId,\n data.storyboardPatch as RouteConf\n );\n } else if (data.options.updateStoryboardType === \"template\") {\n __secret_internals.updateStoryboardByTemplate(\n options.appId,\n data.storyboardPatch as CustomTemplate,\n data.options.settings\n );\n } else if (data.options.updateStoryboardType === \"snippet\") {\n __secret_internals.updateStoryboardBySnippet(\n options.appId,\n data.storyboardPatch as {\n snippetId: string;\n bricks: BrickConf[];\n }\n );\n } else if (data.options.updateStoryboardType === \"form\") {\n (__secret_internals as any).updateFormPreviewSettings(\n options.appId,\n options.formId,\n data.storyboardPatch\n );\n }\n\n let newContracts;\n if (data.options?.updateStoryboardType !== \"form\") {\n newContracts = await (\n __secret_internals as any\n ).getAddedContracts?.(data.storyboardPatch, {\n appId: options.appId,\n updateStoryboardType: data.options.updateStoryboardType,\n formId: options.formId,\n collectUsedContracts,\n });\n }\n\n if (!isEmpty(newContracts)) {\n sendMessage<PreviewMessagePreviewContractUpdate>({\n type: \"contract-update\",\n data: {\n add: newContracts,\n },\n });\n } else {\n getHistory().reload();\n }\n\n break;\n }\n __secret_internals.updateStoryboard(\n options.appId,\n data.storyboardPatch\n );\n if (options.templateId) {\n lastTemplatePreviewSettings = data.settings;\n updateTemplatePreviewSettings();\n } else if (options.formId || options.formData) {\n updateFormPreviewSettings();\n } else if (data.options?.snippetData) {\n options.snippetData = data.options.snippetData;\n updateSnippetPreviewSettings();\n } else {\n getHistory().reload();\n }\n break;\n case \"reload\":\n location.reload();\n break;\n case \"back\":\n history.goBack();\n break;\n case \"forward\":\n history.goForward();\n break;\n case \"capture\":\n capture(data.maxWidth, data.maxHeight).then(\n (screenshot) => {\n sendMessage<PreviewMessagePreviewerCaptureOk>({\n type: \"capture-ok\",\n screenshot,\n });\n },\n () => {\n sendMessage<PreviewMessagePreviewerCaptureFailed>({\n type: \"capture-failed\",\n });\n }\n );\n break;\n case \"inspect-data-value\":\n handlePreviewData(data.name, data.option);\n break;\n case \"update-preview-url\": {\n // Remove origin first.\n const url = data.previewUrl.startsWith(window.origin)\n ? data.previewUrl.substring(window.origin.length)\n : data.previewUrl;\n // Then remove base path.\n const basePath = getBasePath();\n const to = url.startsWith(basePath)\n ? url.substring(basePath.length - 1)\n : url;\n getHistory().push(to);\n break;\n }\n case \"update-preview-route\": {\n options.routePath = data.routePath;\n options.routeExact = data.routeExact;\n syncRouteMatch();\n break;\n }\n case \"debug-data-value\":\n debugDataValue(data.debugData, data.contractData, data.options);\n break;\n /* case \"excute-proxy-method\": {\n const [ref, method, args = []] = data.proxyMethodArgs;\n try {\n const result = document.body.querySelector(ref)[method](...args);\n window.parent.postMessage({\n sender: \"previewer\",\n type: \"excute-proxy-method-success\",\n data: { method: method, res: result },\n });\n } catch (err) {\n window.parent.postMessage({\n sender: \"previewer\",\n type: \"excute-proxy-method-error\",\n data: { method: method, res: err.message },\n });\n }\n break;\n } */\n }\n }\n );\n\n window.addEventListener(\"scroll\", () => {\n sendMessage<PreviewMessagePreviewerScroll>({\n type: \"scroll\",\n scroll: {\n x: window.scrollX,\n y: window.scrollY,\n },\n });\n });\n\n let previewPageMatch = true;\n let currentLocation: NextLocation;\n const sendLocationChange = (loc: NextLocation): void => {\n sendMessage<PreviewMessagePreviewerUrlChange>({\n type: \"url-change\",\n url: location.origin + history.createHref(loc),\n });\n currentLocation = loc;\n syncRouteMatch();\n };\n\n function syncRouteMatch() {\n if (options.routePath) {\n const match = !!matchPath(currentLocation.pathname, {\n path: options.routePath,\n exact: options.routeExact,\n });\n sendMessage<PreviewMessagePreviewerRouteMatchChange>({\n type: \"route-match-change\",\n match,\n });\n\n // Re-update template preview settings once match route again (typically after login).\n if (options.templateId && !previewPageMatch && match) {\n const mainMountPoint = document.querySelector(\"#main-mount-point\")!;\n const placeholderLoadObserver = new MutationObserver(() => {\n // We observe when the placeholder is appeared.\n if (\n mainMountPoint.childNodes.length === 1 &&\n (mainMountPoint.firstChild as HTMLElement).tagName === \"SPAN\" &&\n mainMountPoint.firstChild!.childNodes.length === 0\n ) {\n updateTemplatePreviewSettings();\n placeholderLoadObserver.disconnect();\n }\n });\n placeholderLoadObserver.observe(mainMountPoint, { childList: true });\n }\n if (options.formId && !previewPageMatch && match) {\n const mainMountPoint = document.querySelector(\"#main-mount-point\");\n const placeholderLoadObserver = new MutationObserver(() => {\n // We observe when the placeholder is appeared.\n if (\n mainMountPoint.childNodes.length === 1 &&\n (mainMountPoint.firstChild as HTMLElement).tagName === \"SPAN\" &&\n mainMountPoint.firstChild.childNodes.length === 0\n ) {\n updateFormPreviewSettings();\n placeholderLoadObserver.disconnect();\n }\n });\n placeholderLoadObserver.observe(mainMountPoint, { childList: true });\n }\n if (options.snippetData && !previewPageMatch && match) {\n const mainMountPoint = document.querySelector(\"#main-mount-point\")!;\n const placeholderLoadObserver = new MutationObserver(() => {\n // We observe when the placeholder is appeared.\n if (\n mainMountPoint.childNodes.length === 1 &&\n (mainMountPoint.firstChild as HTMLElement).tagName === \"SPAN\" &&\n mainMountPoint.firstChild!.childNodes.length === 0\n ) {\n updateSnippetPreviewSettings();\n placeholderLoadObserver.disconnect();\n }\n });\n placeholderLoadObserver.observe(mainMountPoint, { childList: true });\n }\n previewPageMatch = match;\n }\n }\n\n sendLocationChange(history.location);\n\n history.listen(sendLocationChange);\n\n if (options.templateId) {\n updateTemplatePreviewSettings();\n }\n\n if (options.formId || options.formData) {\n updateFormPreviewSettings();\n }\n\n if (options.snippetData) {\n updateSnippetPreviewSettings();\n }\n\n function setupContentScroll() {\n const host = document.querySelector(\"eo-page-view\");\n const element = host?.shadowRoot?.querySelector(\".content\") ?? null;\n if (element !== contentScrollElement) {\n contentScrollElement?.removeEventListener(\"scroll\", onContentScroll);\n element?.addEventListener(\"scroll\", onContentScroll);\n contentScrollElement = element;\n contentScrollHost = host;\n }\n }\n\n function onContentScroll(this: Element) {\n sendMessage<PreviewMessagePreviewerContentScroll>({\n type: \"content-scroll\",\n scroll: {\n x: this.scrollLeft,\n y: this.scrollTop,\n },\n });\n }\n\n const setupRuntimeValueInspect = () => {\n const routeId = options.routeId;\n\n const data = __secret_internals.getLegalRuntimeValue({ routeId });\n sendMessage<PreviewMessagePreviewInspectRuntimeValue>({\n type: \"inspect-runtime-data-value\",\n data: {\n ...omit(data, \"query\"),\n query: data.query ? Object.fromEntries(data.query.entries()) : {},\n path: data.match?.params,\n },\n });\n };\n\n __secret_internals.addRealTimeDataInspectHook?.(\n ({ changeType, tplStateStoreId, detail }) => {\n sendMessage<PreviewMessagePreviewerRealTimeDataInspectChange>({\n type: \"real-time-data-inspect-change\",\n changeType,\n tplStateStoreId,\n detail:\n changeType === \"update\"\n ? {\n name: detail.name,\n annotation: getRealTimeDataAnnotation(detail.value),\n }\n : {\n data: Object.fromEntries(\n Object.entries(detail.data).map(([k, v]) => [\n k,\n getRealTimeDataAnnotation(v),\n ])\n ),\n },\n });\n }\n );\n\n let memoizedRootTplStateStoreId: string | undefined;\n\n function setupRealTimeDataInspect(force?: boolean) {\n const tplStateStoreId = options.templateId\n ? getRootTplStateStoreId()\n : undefined;\n if (memoizedRootTplStateStoreId !== tplStateStoreId || force) {\n memoizedRootTplStateStoreId = tplStateStoreId;\n __secret_internals.setRealTimeDataInspectRoot?.({\n tplStateStoreId,\n });\n }\n }\n\n window.addEventListener(\"route.render\", () => {\n setupRealTimeDataInspect(true);\n setupRuntimeValueInspect();\n });\n\n setupContentScroll();\n setupRealTimeDataInspect(true);\n setupRuntimeValueInspect();\n\n const mutationCallback = (): void => {\n setupContentScroll();\n setupRealTimeDataInspect();\n if (hoverIid) {\n sendHighlightBrickOutlines(\"hover\", hoverIid, hoverAlias);\n }\n if (activeIid) {\n sendHighlightBrickOutlines(\"active\", activeIid, activeAlias);\n }\n };\n const mutationObserver = new MutationObserver(\n throttle(mutationCallback, 100, { leading: false })\n );\n mutationObserver.observe(document.body, { subtree: true, childList: true });\n}\n\nfunction getBrickOutlines(iid: string, alias?: string): BrickOutline[] {\n if (!iid) {\n return [];\n }\n const isRoot = iid.includes(\"#\");\n const elements = getElementsIncludingInShadowDOM(iid, isRoot);\n const outlines = getOutlines(elements, alias);\n return isRoot\n ? outlines.map((item) => ({\n ...item,\n height: window.innerHeight - item.top,\n }))\n : outlines;\n}\n\nexport function getElementsIncludingInShadowDOM(\n iid: string,\n isRoot?: boolean\n): HTMLElement[] {\n const elements: HTMLElement[] = [];\n\n function walk(root: Document | ShadowRoot) {\n const candidates = root.querySelectorAll<HTMLElement>(\n isRoot ? iid : `[data-iid=\"${iid}\"]`\n );\n elements.push(...candidates);\n\n // If elements are found in the document, we should stop searching in shadow DOM.\n if (root === document && candidates.length > 0) {\n return;\n }\n\n // These useBrick in v3 bricks will be inside shadow DOM.\n for (const item of root.querySelectorAll(\"*\")) {\n if (item.shadowRoot) {\n walk(item.shadowRoot);\n }\n }\n }\n\n walk(document);\n\n return elements;\n}\n\nfunction getOutlines(elements: HTMLElement[], alias?: string): BrickOutline[] {\n return elements.map((element) => {\n const hasContentScroll = contentScrollHost?.contains(element);\n const { width, height, left, top } = element.getBoundingClientRect();\n return {\n width,\n height,\n left:\n left +\n window.scrollX +\n (hasContentScroll ? contentScrollElement.scrollLeft : 0),\n top:\n top +\n window.scrollY +\n (hasContentScroll ? contentScrollElement.scrollTop : 0),\n alias,\n hasContentScroll,\n };\n });\n}\n\nfunction getRootTplStateStoreId(): string | undefined {\n const mainMountPoint = document.querySelector(\"#main-mount-point\")!;\n\n return (mainMountPoint?.firstChild as HTMLElement)?.dataset[\n isV2 ? \"tplContextId\" : \"tplStateStoreId\"\n ];\n}\n","// istanbul ignore file: nothing logical except calling html2canvas.\nimport html2canvas from \"html2canvas\";\nimport { resizeScreenshot } from \"./resizeScreenshot.js\";\n\nfunction getCanvasBlob(canvas: HTMLCanvasElement): Promise<Blob> {\n return new Promise(function (resolve, reject) {\n canvas.toBlob(function (blob: Blob | null) {\n if (blob) {\n resolve(blob);\n } else {\n reject();\n }\n });\n });\n}\n\nexport async function capture(\n maxWidth: number,\n maxHeight: number\n): Promise<Blob> {\n const sourceCanvas = await html2canvas(document.body, {\n logging: false,\n scale: 1,\n width: window.innerWidth,\n height: window.innerHeight,\n foreignObjectRendering: true,\n });\n const targetCanvas = document.createElement(\"canvas\");\n resizeScreenshot(sourceCanvas, targetCanvas, maxWidth, maxHeight);\n const blob = await getCanvasBlob(targetCanvas);\n return blob;\n}\n","export function resizeScreenshot(\n canvas: HTMLCanvasElement,\n targetCanvas: HTMLCanvasElement,\n maxWidth: number,\n maxHeight: number\n): string {\n const targetRatio = maxWidth / maxHeight;\n const { width, height } = canvas;\n const ratio = width / height;\n const wider = ratio >= targetRatio;\n const finalWidth = wider ? maxWidth : maxHeight * ratio;\n const finalHeight = wider ? maxWidth / ratio : maxHeight;\n targetCanvas.width = finalWidth;\n targetCanvas.height = finalHeight;\n\n const ctx = targetCanvas.getContext(\"2d\")!;\n ctx.drawImage(canvas, 0, 0, width, height, 0, 0, finalWidth, finalHeight);\n return targetCanvas.toDataURL();\n}\n"],"names":["collectUsedContracts","storyboard","collection","nodeOrNodes","Set","traverse","node","type","_node$raw","useProvider","raw","add","collect","parseStoryboard","contracts","item","includes","push","customElements","define","createProviderClass","previewProxyOrigin","onClick","event","preventDefault","stopPropagation","eventTargets","iidList","getPossibleBrickTargets","length","window","parent","postMessage","sender","selectBrick","composedPath","onMouseEvent","hoverOnBrick","throttle","leading","onPointerDown","onPointerMove","onPointerLeave","onContextMenu","position","contextMenuOnBrick","x","clientX","y","clientY","targets","target","HTMLElement","dataset","iid","getRealTimeDataAnnotation","value","Array","isArray","connected","getHistory","_getHistory","matchPath","_matchPath","__secret_internals","_internals","flowApi","_flowAPi","isV2","_window$BRICK_NEXT_VE","dll","BRICK_NEXT_VERSIONS","startsWith","getHistoryV2","developHelper","developHelperV2","collectDebugContract","matchPathV2","getContextValue","name","_ref","tplStateStoreId","tplContextId","getAllContextValues","_ref2","v2Map","Object","fromEntries","map","_ref3","k","v","debugDataValue","data","_ref4","e","console","error","contentScrollElement","contentScrollHost","async","connect","previewFromOrigin","options","_secret_internals$ad","_secret_internals","sendMessage","message","hoverIid","hoverAlias","activeIid","activeAlias","sendHighlightBrickOutlines","alias","outlines","getBrickOutlines","highlightType","lastTemplatePreviewSettings","templateId","settings","updateTemplatePreviewSettings","appId","reload","updateSnippetPreviewSettings","JSON","parse","snippetData","updateFormPreviewSettings","formId","formData","history","addEventListener","_data$options","_data$options3","origin","_ref6","forwardedFor","nodes","flat","sendHighlightBricksOutlines","highlightNodes","pos","element","document","elementFromPoint","tagName","isDirection","brick","cursor","parentElement","getPossibleBrickIidList","handleHoverOnIframe","enabled","removeEventListener","updateStoryboardType","_data$options2","newContracts","_getAddedContracts","_ref7","updateStoryboardByRoute","storyboardPatch","updateStoryboardByTemplate","updateStoryboardBySnippet","getAddedContracts","call","isEmpty","updateStoryboard","location","goBack","goForward","maxWidth","maxHeight","sourceCanvas","html2canvas","body","logging","scale","width","innerWidth","height","innerHeight","foreignObjectRendering","targetCanvas","createElement","canvas","targetRatio","ratio","wider","finalWidth","finalHeight","getContext","drawImage","toDataURL","resizeScreenshot","Promise","resolve","reject","toBlob","blob","capture","then","screenshot","handlePreviewData","option","dataType","getRootTplStateStoreId","entries","_ref5","url","previewUrl","substring","basePath","getBasePath","to","routePath","routeExact","syncRouteMatch","contractData","previewOption","undefined","routeId","debugConf","HttpResponseError","responseJson","debugData","scroll","scrollX","scrollY","currentLocation","previewPageMatch","sendLocationChange","loc","createHref","match","pathname","path","exact","mainMountPoint","querySelector","placeholderLoadObserver","MutationObserver","childNodes","firstChild","disconnect","observe","childList","setupContentScroll","_host$shadowRoot","host","shadowRoot","_contentScrollElement","onContentScroll","this","scrollLeft","scrollTop","listen","setupRuntimeValueInspect","_data$match","getLegalRuntimeValue","omit","query","params","memoizedRootTplStateStoreId","setupRealTimeDataInspect","force","_secret_internals$se","_secret_internals2","setRealTimeDataInspectRoot","addRealTimeDataInspectHook","_ref8","changeType","detail","annotation","_ref9","mutationCallback","subtree","isRoot","elements","_contentScrollHost","hasContentScroll","contains","left","top","getBoundingClientRect","getOutlines","getElementsIncludingInShadowDOM","walk","root","candidates","querySelectorAll","_mainMountPoint$first"],"sourceRoot":""}
1
+ {"version":3,"file":"chunks/9027.e3490283.js","mappings":"yMAgCO,SAASA,EAAqBC,GACnC,MAAMC,EArBR,SAAiBC,GACf,MAAMD,EAAa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AI,IACbA,EACHoK,OAAQrJ,OAAOsJ,YAAcrK,EAAK2Q,QAEpCxK,CACN,CAEO,SAAS2K,EACdvO,EACA8N,GAEA,MAAMC,EAA0B,GAuBhC,OArBA,SAASS,EAAKC,GACZ,MAAMC,EAAaD,EAAKE,iBACtBb,EAAS9N,EAAM,cAAcA,OAK/B,GAHA+N,EAASpQ,QAAQ+Q,KAGbD,IAAShJ,UAAYiJ,EAAWnQ,OAAS,GAK7C,IAAK,MAAMd,KAAQgR,EAAKE,iBAAiB,KACnClR,EAAK0O,YACPqC,EAAK/Q,EAAK0O,WAGhB,CAEAqC,CAAK/I,UAEEsI,CACT,CAuBA,SAASxE,IAA6C,IAAAqF,EACpD,MAAMrD,EAAiB9F,SAAS+F,cAAc,qBAE9C,OAAQD,SAA0B,QAAZqD,EAAdrD,EAAgBK,kBAAU,IAAAgD,OAAA,EAA3BA,EAA6C7O,QAClDe,EAAO,eAAiB,kBAE5B,C","sources":["webpack:///./src/data-providers/collect-used-contracts.ts","webpack:///./src/data-providers/preview/inspector.ts","webpack:///./src/data-providers/preview/realTimeDataInspect.ts","webpack:///./src/data-providers/preview/connect.ts","webpack:///./src/data-providers/preview/capture.ts","webpack:///./src/data-providers/preview/resizeScreenshot.ts"],"sourcesContent":["import { createProviderClass } from \"@next-core/utils/general\";\nimport {\n type StoryboardNode,\n parseStoryboard,\n traverse,\n} from \"@next-core/storyboard\";\nimport {\n Storyboard,\n UseProviderResolveConf,\n UseProviderEventHandler,\n} from \"@next-core/types\";\n\nfunction collect(nodeOrNodes: StoryboardNode | StoryboardNode[]): Set<string> {\n const collection = new Set<string>();\n\n traverse(nodeOrNodes, (node) => {\n switch (node.type) {\n case \"Resolvable\":\n case \"EventHandler\": {\n const useProvider = (\n node.raw as UseProviderResolveConf | UseProviderEventHandler\n )?.useProvider;\n if (useProvider) {\n collection.add(useProvider);\n }\n }\n }\n });\n\n return collection;\n}\n\nexport function collectUsedContracts(storyboard: Storyboard): string[] {\n const collection = collect(parseStoryboard(storyboard as any));\n\n const contracts = [];\n\n for (const item of collection) {\n if (item.includes(\"@\")) {\n contracts.push(item);\n }\n }\n\n return contracts;\n}\n\ncustomElements.define(\n \"visual-builder.collect-used-contracts\",\n createProviderClass(collectUsedContracts)\n);\n","// istanbul ignore file: working in progress\n// https://github.com/facebook/react/blob/cae635054e17a6f107a39d328649137b83f25972/packages/react-devtools-shared/src/backend/views/Highlighter/index.js\nimport { throttle } from \"lodash\";\nimport type {\n PreviewMessagePreviewerHoverOnBrick,\n PreviewMessagePreviewerSelectBrick,\n PreviewMessagePreviewerContextMenuOnBrick,\n} from \"./interfaces.js\";\n\nexport let previewProxyOrigin: string;\n\nexport function setPreviewFromOrigin(origin: string): void {\n previewProxyOrigin = origin;\n}\n\nexport function startInspecting(): void {\n registerListeners();\n}\n\nexport function stopInspecting(): void {\n unregisterListeners();\n}\n\nfunction registerListeners(): void {\n window.addEventListener(\"click\", onClick, true);\n window.addEventListener(\"mousedown\", onMouseEvent, true);\n window.addEventListener(\"mouseover\", onMouseEvent, true);\n window.addEventListener(\"mouseup\", onMouseEvent, true);\n window.addEventListener(\"pointerdown\", onPointerDown, true);\n window.addEventListener(\"pointermove\", onPointerMove, true);\n window.addEventListener(\"pointerup\", onMouseEvent, true);\n window.addEventListener(\"pointerleave\", onPointerLeave, true);\n window.addEventListener(\"contextmenu\", onContextMenu, true);\n}\n\nfunction unregisterListeners(): void {\n window.removeEventListener(\"click\", onClick, true);\n window.removeEventListener(\"mousedown\", onMouseEvent, true);\n window.removeEventListener(\"mouseover\", onMouseEvent, true);\n window.removeEventListener(\"mouseup\", onMouseEvent, true);\n window.removeEventListener(\"pointerdown\", onPointerDown, true);\n window.removeEventListener(\"pointermove\", onPointerMove, true);\n window.removeEventListener(\"pointerup\", onMouseEvent, true);\n window.removeEventListener(\"pointerleave\", onPointerLeave, true);\n window.removeEventListener(\"contextmenu\", onContextMenu, true);\n}\n\nfunction onClick(event: MouseEvent): void {\n event.preventDefault();\n event.stopPropagation();\n selectBrick(event.composedPath());\n}\n\nfunction onMouseEvent(event: MouseEvent): void {\n event.preventDefault();\n event.stopPropagation();\n}\n\nconst hoverOnBrick = throttle(\n (eventTargets: EventTarget[]) => {\n const iidList = getPossibleBrickTargets(eventTargets);\n\n if (iidList.length > 0) {\n window.parent.postMessage(\n {\n sender: \"previewer\",\n type: \"hover-on-brick\",\n iidList,\n } as PreviewMessagePreviewerHoverOnBrick,\n previewProxyOrigin\n );\n }\n },\n 100,\n { leading: false }\n);\n\nfunction onPointerDown(event: MouseEvent): void {\n event.preventDefault();\n event.stopPropagation();\n hoverOnBrick(event.composedPath());\n}\n\nfunction onPointerMove(event: MouseEvent): void {\n event.preventDefault();\n event.stopPropagation();\n hoverOnBrick(event.composedPath());\n}\n\nfunction onPointerLeave(event: MouseEvent): void {\n event.preventDefault();\n event.stopPropagation();\n window.parent.postMessage(\n {\n sender: \"previewer\",\n type: \"hover-on-brick\",\n iidList: [],\n } as PreviewMessagePreviewerHoverOnBrick,\n previewProxyOrigin\n );\n}\n\nfunction onContextMenu(event: MouseEvent): void {\n event.preventDefault();\n event.stopPropagation();\n contextMenuOnBrick(event.composedPath(), {\n x: event.clientX,\n y: event.clientY,\n });\n}\n\nfunction contextMenuOnBrick(\n eventTargets: EventTarget[],\n position: {\n x: number;\n y: number;\n }\n): void {\n const iidList = getPossibleBrickTargets(eventTargets);\n if (iidList.length > 0) {\n window.parent.postMessage(\n {\n sender: \"previewer\",\n type: \"context-menu-on-brick\",\n iidList,\n position,\n } as PreviewMessagePreviewerContextMenuOnBrick,\n previewProxyOrigin\n );\n }\n}\n\nfunction selectBrick(eventTargets: EventTarget[]): void {\n const iidList = getPossibleBrickTargets(eventTargets);\n if (iidList.length > 0) {\n window.parent.postMessage(\n {\n sender: \"previewer\",\n type: \"select-brick\",\n iidList,\n } as PreviewMessagePreviewerSelectBrick,\n previewProxyOrigin\n );\n }\n}\n\nexport function getPossibleBrickIidList(brick: HTMLElement): string[] {\n const iidList: string[] = [];\n // Traverse from bottom to up, to find bricks current hover on.\n let cursor: HTMLElement | null = brick;\n while (cursor) {\n if (typeof cursor.dataset.iid === \"string\") {\n iidList.push(cursor.dataset.iid);\n }\n cursor = cursor.parentElement;\n }\n return iidList;\n}\n\nexport function getPossibleBrickTargets(eventTargets: EventTarget[]) {\n const targets: string[] = [];\n for (const target of eventTargets) {\n if (\n target instanceof HTMLElement &&\n typeof target.dataset.iid === \"string\"\n ) {\n targets.push(target.dataset.iid);\n }\n }\n return targets;\n}\n","export function getRealTimeDataAnnotation(value: unknown) {\n const type = typeof value;\n switch (type) {\n case \"string\":\n case \"boolean\":\n case \"number\":\n return {\n type,\n value,\n };\n case \"undefined\":\n return { type };\n }\n if (value === null) {\n return { type: \"null\" };\n }\n if (Array.isArray(value)) {\n return { type: \"array\", length: value.length };\n }\n return { type: \"object\" };\n}\n","import {\n getHistory as _getHistory,\n getBasePath,\n matchPath as _matchPath,\n __secret_internals as _internals,\n type NextLocation,\n} from \"@next-core/runtime\";\nimport { HttpResponseError } from \"@next-core/http\";\nimport { flowApi as _flowAPi } from \"@next-core/easyops-runtime\";\nimport type {\n BrickConf,\n Contract,\n CustomTemplate,\n RouteConf,\n} from \"@next-core/types\";\nimport { isEmpty, throttle, omit } from \"lodash\";\nimport type {\n BrickOutline,\n HighLightNode,\n Position,\n PreviewDataOption,\n PreviewMessageFromPreviewer,\n PreviewMessagePreviewContractUpdate,\n PreviewMessagePreviewDataValueError,\n PreviewMessagePreviewDataValueSuccess,\n PreviewMessagePreviewDebugValueSuccess,\n PreviewMessagePreviewDebugValueError,\n PreviewMessagePreviewerCaptureFailed,\n PreviewMessagePreviewerCaptureOk,\n PreviewMessagePreviewerContentScroll,\n PreviewMessagePreviewerHighlightBrick,\n PreviewMessagePreviewerHighlightContext,\n PreviewMessagePreviewerHoverOnMain,\n PreviewMessagePreviewerRealTimeDataInspectChange,\n PreviewMessagePreviewerRouteMatchChange,\n PreviewMessagePreviewerScroll,\n PreviewMessagePreviewerUrlChange,\n PreviewMessageToPreviewer,\n PreviewSettings,\n PreviewStartOptions,\n PreviewDebugData,\n PreviewMessagePreviewInspectRuntimeValue,\n} from \"./interfaces.js\";\nimport { capture } from \"./capture.js\";\nimport {\n previewProxyOrigin,\n getPossibleBrickIidList,\n setPreviewFromOrigin,\n startInspecting,\n stopInspecting,\n} from \"./inspector.js\";\nimport { collectUsedContracts } from \"../collect-used-contracts.js\";\nimport { getRealTimeDataAnnotation } from \"./realTimeDataInspect.js\";\n\nlet connected = false;\n\ninterface DLL {\n (moduleId: \"tYg3\"): {\n getHistory: typeof _getHistory;\n developHelper: typeof _internals;\n collectDebugContract: typeof flowApi.collectDebugContract;\n };\n (moduleId: \"A+yw\"): {\n matchPath: typeof _matchPath;\n };\n}\n\nlet getHistory = _getHistory;\nlet matchPath = _matchPath;\nlet __secret_internals = _internals;\nlet flowApi = _flowAPi;\nlet isV2 = false;\n\n// istanbul ignore next\n// Make v3 bricks compatible with Brick Next v2.\ntry {\n const dll = (window as unknown as { dll?: DLL }).dll;\n if (\n dll &&\n window.BRICK_NEXT_VERSIONS?.[\"brick-container\"]?.startsWith(\"2.\")\n ) {\n const {\n getHistory: getHistoryV2,\n developHelper: developHelperV2,\n collectDebugContract,\n } = dll(\"tYg3\");\n const { matchPath: matchPathV2 } = dll(\"A+yw\");\n getHistory = getHistoryV2;\n matchPath = matchPathV2;\n // The `__secret_internals` of v3 has pretty the same API as\n // `developHelper` of v2, especially those for preview usage.\n __secret_internals = {\n ...developHelperV2,\n getContextValue(name, { tplStateStoreId }) {\n return developHelperV2.getContextValue(name, {\n tplContextId: tplStateStoreId,\n } as any);\n },\n getAllContextValues({ tplStateStoreId }) {\n // V3 returns an object of key-value.\n // While v2 returns a map of ContextItem.\n const v2Map = developHelperV2.getAllContextValues({\n tplContextId: tplStateStoreId,\n } as any) as unknown as Map<string, { value: unknown }>;\n return Object.fromEntries(\n [...v2Map].map(([k, v]) => [k, (v as any).value])\n );\n },\n debugDataValue(data, { tplStateStoreId }) {\n return developHelperV2.debugDataValue(data, {\n tplContextId: tplStateStoreId,\n } as any);\n },\n };\n\n flowApi = {\n collectDebugContract,\n } as any;\n isV2 = true;\n }\n} catch (e) {\n // eslint-disable-next-line no-console\n console.error(\"Try to use v2 runtime APIs failed:\", e);\n}\n\nlet contentScrollElement: Element | null = null;\nlet contentScrollHost: Element | null = null;\n\nexport default async function connect(\n previewFromOrigin: string,\n options: PreviewStartOptions\n) {\n if (connected) {\n return;\n }\n connected = true;\n\n const sendMessage = <T extends PreviewMessageFromPreviewer>(\n message: Omit<T, \"sender\">\n ): void => {\n window.parent.postMessage(\n {\n sender: \"previewer\",\n ...message,\n },\n previewFromOrigin\n );\n };\n\n sendMessage({ type: \"preview-started\" });\n setPreviewFromOrigin(previewFromOrigin);\n\n let hoverIid: string;\n let hoverAlias: string;\n let activeIid: string;\n let activeAlias: string;\n\n const handleHoverOnIframe = (pos: Position): void => {\n const element = document.elementFromPoint(pos.x, pos.y);\n if (element?.tagName === \"BODY\") {\n window.parent.postMessage(\n {\n sender: \"previewer\",\n type: \"hover-on-main\",\n isDirection: true,\n position: {\n x: pos.x,\n y: pos.y,\n },\n } as PreviewMessagePreviewerHoverOnMain,\n previewProxyOrigin\n );\n } else {\n const iidList = getPossibleBrickIidList(element as HTMLElement);\n window.parent.postMessage(\n {\n sender: \"previewer\",\n type: \"hover-on-brick\",\n iidList,\n isDirection: true,\n position: {\n x: pos.x,\n y: pos.y,\n },\n },\n previewProxyOrigin\n );\n }\n };\n\n const sendHighlightBrickOutlines = (\n type: \"hover\" | \"active\",\n iid: string,\n alias: string\n ): void => {\n const outlines = getBrickOutlines(iid);\n sendMessage<PreviewMessagePreviewerHighlightBrick>({\n type: \"highlight-brick\",\n highlightType: type,\n outlines,\n iid: iid,\n alias: alias,\n });\n };\n\n const sendHighlightBricksOutlines = (nodes: HighLightNode[]): void => {\n const outlines = nodes\n .map((node) => getBrickOutlines(node.iid, node.alias))\n .flat();\n sendMessage<PreviewMessagePreviewerHighlightContext>({\n type: \"highlight-context\",\n outlines,\n });\n };\n\n let lastTemplatePreviewSettings: PreviewSettings | undefined;\n if (options.templateId) {\n lastTemplatePreviewSettings = options.settings;\n }\n\n const updateTemplatePreviewSettings = (): void => {\n __secret_internals.updateTemplatePreviewSettings(\n options.appId,\n options.templateId!,\n lastTemplatePreviewSettings\n );\n getHistory().reload();\n };\n\n const updateSnippetPreviewSettings = (): void => {\n __secret_internals.updateSnippetPreviewSettings(\n options.appId,\n JSON.parse(options.snippetData)\n );\n getHistory().reload();\n };\n\n const updateFormPreviewSettings = (): void => {\n (__secret_internals as any).updateFormPreviewSettings(\n options.appId,\n options.formId,\n options.formData\n );\n getHistory().reload();\n };\n\n const handlePreviewData = (name: string, option: PreviewDataOption): void => {\n try {\n const { dataType } = option;\n let tplStateStoreId;\n\n if (dataType === \"state\") {\n tplStateStoreId = getRootTplStateStoreId();\n\n if (!tplStateStoreId) {\n sendMessage<PreviewMessagePreviewDataValueError>({\n type: \"inspect-data-value-error\",\n data: {\n error: {\n message:\n \"tplStateStoreId not found, unable to preview STATE value\",\n },\n },\n });\n\n return;\n }\n }\n\n let value, type: PreviewMessagePreviewDataValueSuccess[\"type\"];\n if (name) {\n type = \"inspect-single-data-value-success\";\n value = __secret_internals.getContextValue(name, {\n tplStateStoreId,\n });\n } else {\n type = \"inspect-all-data-values-success\";\n const data = __secret_internals.getAllContextValues({\n tplStateStoreId,\n });\n value = Object.entries(data).map(([name, value]) => ({ name, value }));\n }\n\n sendMessage<PreviewMessagePreviewDataValueSuccess>({\n type,\n data: {\n name,\n value,\n },\n });\n\n // istanbul ignore next\n } catch (error) {\n sendMessage<PreviewMessagePreviewDataValueError>({\n type: \"inspect-data-value-error\",\n data: {\n message: (error as Error).message,\n },\n });\n }\n };\n\n const debugDataValue = async (\n data: PreviewDebugData,\n contractData: Contract,\n previewOption: PreviewDataOption\n ) => {\n try {\n if (contractData) {\n flowApi.collectDebugContract([contractData]);\n }\n const value = await __secret_internals.debugDataValue(data, {\n tplStateStoreId:\n previewOption.dataType === \"state\"\n ? getRootTplStateStoreId()\n : undefined,\n routeId: options.routeId,\n });\n\n sendMessage<PreviewMessagePreviewDebugValueSuccess>({\n type: \"debug-data-value-success\",\n data: {\n debugConf: data,\n value,\n },\n });\n } catch (error) {\n sendMessage<PreviewMessagePreviewDebugValueError>({\n type: \"debug-data-value-error\",\n data:\n error instanceof HttpResponseError\n ? error.responseJson\n : { message: (error as Error).message },\n });\n }\n };\n\n const history = getHistory();\n\n window.addEventListener(\n \"message\",\n async ({ data, origin }: MessageEvent<PreviewMessageToPreviewer>) => {\n if (\n origin !== previewFromOrigin ||\n !data ||\n data.sender !== \"preview-container\"\n ) {\n return;\n }\n if (data.forwardedFor === \"builder\") {\n switch (data.type) {\n case \"hover-on-brick\":\n hoverIid = data.iid;\n hoverAlias = data.alias;\n sendHighlightBrickOutlines(\"hover\", data.iid, data.alias);\n break;\n case \"hover-on-main\":\n sendHighlightBrickOutlines(\"hover\", \"#main-mount-point\", \"root\");\n break;\n case \"hover-on-context\":\n sendHighlightBricksOutlines(data.highlightNodes);\n break;\n case \"select-brick\":\n activeIid = data.iid;\n activeAlias = data.alias;\n sendHighlightBrickOutlines(\"active\", data.iid, data.alias);\n break;\n case \"hover-on-iframe\":\n handleHoverOnIframe(data.position);\n break;\n }\n } else\n switch (data.type) {\n case \"toggle-inspecting\":\n data.enabled ? startInspecting() : stopInspecting();\n break;\n case \"refresh\":\n if (data.options?.updateStoryboardType) {\n if (data.options.updateStoryboardType === \"route\") {\n __secret_internals.updateStoryboardByRoute(\n options.appId,\n data.storyboardPatch as RouteConf\n );\n } else if (data.options.updateStoryboardType === \"template\") {\n __secret_internals.updateStoryboardByTemplate(\n options.appId,\n data.storyboardPatch as CustomTemplate,\n data.options.settings\n );\n } else if (data.options.updateStoryboardType === \"snippet\") {\n __secret_internals.updateStoryboardBySnippet(\n options.appId,\n data.storyboardPatch as {\n snippetId: string;\n bricks: BrickConf[];\n }\n );\n } else if (data.options.updateStoryboardType === \"form\") {\n (__secret_internals as any).updateFormPreviewSettings(\n options.appId,\n options.formId,\n data.storyboardPatch\n );\n }\n\n let newContracts;\n if (data.options?.updateStoryboardType !== \"form\") {\n newContracts = await (\n __secret_internals as any\n ).getAddedContracts?.(data.storyboardPatch, {\n appId: options.appId,\n updateStoryboardType: data.options.updateStoryboardType,\n formId: options.formId,\n collectUsedContracts,\n });\n }\n\n if (!isEmpty(newContracts)) {\n sendMessage<PreviewMessagePreviewContractUpdate>({\n type: \"contract-update\",\n data: {\n add: newContracts,\n },\n });\n } else {\n getHistory().reload();\n }\n\n break;\n }\n __secret_internals.updateStoryboard(\n options.appId,\n data.storyboardPatch\n );\n if (options.templateId) {\n lastTemplatePreviewSettings = data.settings;\n updateTemplatePreviewSettings();\n } else if (options.formId || options.formData) {\n updateFormPreviewSettings();\n } else if (data.options?.snippetData) {\n options.snippetData = data.options.snippetData;\n updateSnippetPreviewSettings();\n } else {\n getHistory().reload();\n }\n break;\n case \"reload\":\n location.reload();\n break;\n case \"back\":\n history.goBack();\n break;\n case \"forward\":\n history.goForward();\n break;\n case \"capture\":\n capture(data.maxWidth, data.maxHeight).then(\n (screenshot) => {\n sendMessage<PreviewMessagePreviewerCaptureOk>({\n type: \"capture-ok\",\n screenshot,\n });\n },\n () => {\n sendMessage<PreviewMessagePreviewerCaptureFailed>({\n type: \"capture-failed\",\n });\n }\n );\n break;\n case \"inspect-data-value\":\n handlePreviewData(data.name, data.option);\n break;\n case \"update-preview-url\": {\n // Remove origin first.\n const url = data.previewUrl.startsWith(window.origin)\n ? data.previewUrl.substring(window.origin.length)\n : data.previewUrl;\n // Then remove base path.\n const basePath = getBasePath();\n const to = url.startsWith(basePath)\n ? url.substring(basePath.length - 1)\n : url;\n getHistory().push(to);\n break;\n }\n case \"update-preview-route\": {\n options.routePath = data.routePath;\n options.routeExact = data.routeExact;\n syncRouteMatch();\n break;\n }\n case \"debug-data-value\":\n debugDataValue(data.debugData, data.contractData, data.options);\n break;\n /* case \"excute-proxy-method\": {\n const [ref, method, args = []] = data.proxyMethodArgs;\n try {\n const result = document.body.querySelector(ref)[method](...args);\n window.parent.postMessage({\n sender: \"previewer\",\n type: \"excute-proxy-method-success\",\n data: { method: method, res: result },\n });\n } catch (err) {\n window.parent.postMessage({\n sender: \"previewer\",\n type: \"excute-proxy-method-error\",\n data: { method: method, res: err.message },\n });\n }\n break;\n } */\n }\n }\n );\n\n window.addEventListener(\"scroll\", () => {\n sendMessage<PreviewMessagePreviewerScroll>({\n type: \"scroll\",\n scroll: {\n x: window.scrollX,\n y: window.scrollY,\n },\n });\n });\n\n let previewPageMatch = true;\n let currentLocation: NextLocation;\n const sendLocationChange = (loc: NextLocation): void => {\n sendMessage<PreviewMessagePreviewerUrlChange>({\n type: \"url-change\",\n url: location.origin + history.createHref(loc),\n });\n currentLocation = loc;\n syncRouteMatch();\n };\n\n function syncRouteMatch() {\n if (options.routePath) {\n const match = !!matchPath(currentLocation.pathname, {\n path: options.routePath,\n exact: options.routeExact,\n });\n sendMessage<PreviewMessagePreviewerRouteMatchChange>({\n type: \"route-match-change\",\n match,\n });\n\n // Re-update template preview settings once match route again (typically after login).\n if (options.templateId && !previewPageMatch && match) {\n const mainMountPoint = document.querySelector(\"#main-mount-point\")!;\n const placeholderLoadObserver = new MutationObserver(() => {\n // We observe when the placeholder is appeared.\n if (\n mainMountPoint.childNodes.length === 1 &&\n (mainMountPoint.firstChild as HTMLElement).tagName === \"SPAN\" &&\n mainMountPoint.firstChild!.childNodes.length === 0\n ) {\n updateTemplatePreviewSettings();\n placeholderLoadObserver.disconnect();\n }\n });\n placeholderLoadObserver.observe(mainMountPoint, { childList: true });\n }\n if (options.formId && !previewPageMatch && match) {\n const mainMountPoint = document.querySelector(\"#main-mount-point\");\n const placeholderLoadObserver = new MutationObserver(() => {\n // We observe when the placeholder is appeared.\n if (\n mainMountPoint.childNodes.length === 1 &&\n (mainMountPoint.firstChild as HTMLElement).tagName === \"SPAN\" &&\n mainMountPoint.firstChild.childNodes.length === 0\n ) {\n updateFormPreviewSettings();\n placeholderLoadObserver.disconnect();\n }\n });\n placeholderLoadObserver.observe(mainMountPoint, { childList: true });\n }\n if (options.snippetData && !previewPageMatch && match) {\n const mainMountPoint = document.querySelector(\"#main-mount-point\")!;\n const placeholderLoadObserver = new MutationObserver(() => {\n // We observe when the placeholder is appeared.\n if (\n mainMountPoint.childNodes.length === 1 &&\n (mainMountPoint.firstChild as HTMLElement).tagName === \"SPAN\" &&\n mainMountPoint.firstChild!.childNodes.length === 0\n ) {\n updateSnippetPreviewSettings();\n placeholderLoadObserver.disconnect();\n }\n });\n placeholderLoadObserver.observe(mainMountPoint, { childList: true });\n }\n previewPageMatch = match;\n }\n }\n\n sendLocationChange(history.location);\n\n history.listen(sendLocationChange);\n\n if (options.templateId) {\n updateTemplatePreviewSettings();\n }\n\n if (options.formId || options.formData) {\n updateFormPreviewSettings();\n }\n\n if (options.snippetData) {\n updateSnippetPreviewSettings();\n }\n\n function setupContentScroll() {\n const host = document.querySelector(\"eo-page-view\");\n const element = host?.shadowRoot?.querySelector(\".content\") ?? null;\n if (element !== contentScrollElement) {\n contentScrollElement?.removeEventListener(\"scroll\", onContentScroll);\n element?.addEventListener(\"scroll\", onContentScroll);\n contentScrollElement = element;\n contentScrollHost = host;\n }\n }\n\n function onContentScroll(this: Element) {\n sendMessage<PreviewMessagePreviewerContentScroll>({\n type: \"content-scroll\",\n scroll: {\n x: this.scrollLeft,\n y: this.scrollTop,\n },\n });\n }\n\n const setupRuntimeValueInspect = () => {\n const routeId = options.routeId;\n\n const data = __secret_internals.getLegalRuntimeValue({ routeId });\n sendMessage<PreviewMessagePreviewInspectRuntimeValue>({\n type: \"inspect-runtime-data-value\",\n data: {\n ...omit(data, \"query\"),\n query: data.query ? Object.fromEntries(data.query.entries()) : {},\n path: data.match?.params,\n },\n });\n };\n\n __secret_internals.addRealTimeDataInspectHook?.(\n ({ changeType, tplStateStoreId, detail }) => {\n sendMessage<PreviewMessagePreviewerRealTimeDataInspectChange>({\n type: \"real-time-data-inspect-change\",\n changeType,\n tplStateStoreId,\n detail:\n changeType === \"update\"\n ? {\n name: detail.name,\n annotation: getRealTimeDataAnnotation(detail.value),\n }\n : {\n data: Object.fromEntries(\n Object.entries(detail.data).map(([k, v]) => [\n k,\n getRealTimeDataAnnotation(v),\n ])\n ),\n },\n });\n }\n );\n\n let memoizedRootTplStateStoreId: string | undefined;\n\n function setupRealTimeDataInspect(force?: boolean) {\n const tplStateStoreId = options.templateId\n ? getRootTplStateStoreId()\n : undefined;\n if (memoizedRootTplStateStoreId !== tplStateStoreId || force) {\n memoizedRootTplStateStoreId = tplStateStoreId;\n __secret_internals.setRealTimeDataInspectRoot?.({\n tplStateStoreId,\n });\n }\n }\n\n window.addEventListener(\"route.render\", () => {\n setupRealTimeDataInspect(true);\n setupRuntimeValueInspect();\n });\n\n setupContentScroll();\n setupRealTimeDataInspect(true);\n setupRuntimeValueInspect();\n\n const mutationCallback = (): void => {\n setupContentScroll();\n setupRealTimeDataInspect();\n if (hoverIid) {\n sendHighlightBrickOutlines(\"hover\", hoverIid, hoverAlias);\n }\n if (activeIid) {\n sendHighlightBrickOutlines(\"active\", activeIid, activeAlias);\n }\n };\n const mutationObserver = new MutationObserver(\n throttle(mutationCallback, 100, { leading: false })\n );\n mutationObserver.observe(document.body, { subtree: true, childList: true });\n}\n\nfunction getBrickOutlines(iid: string, alias?: string): BrickOutline[] {\n if (!iid) {\n return [];\n }\n const isRoot = iid.includes(\"#\");\n const elements = getElementsIncludingInShadowDOM(iid, isRoot);\n const outlines = getOutlines(elements, alias);\n return isRoot\n ? outlines.map((item) => ({\n ...item,\n height: window.innerHeight - item.top,\n }))\n : outlines;\n}\n\nexport function getElementsIncludingInShadowDOM(\n iid: string,\n isRoot?: boolean\n): HTMLElement[] {\n const elements: HTMLElement[] = [];\n\n function walk(root: Document | ShadowRoot) {\n const candidates = root.querySelectorAll<HTMLElement>(\n isRoot ? iid : `[data-iid=\"${iid}\"]`\n );\n elements.push(...candidates);\n\n // If elements are found in the document, we should stop searching in shadow DOM.\n if (root === document && candidates.length > 0) {\n return;\n }\n\n // These useBrick in v3 bricks will be inside shadow DOM.\n for (const item of root.querySelectorAll(\"*\")) {\n if (item.shadowRoot) {\n walk(item.shadowRoot);\n }\n }\n }\n\n walk(document);\n\n return elements;\n}\n\nfunction getOutlines(elements: HTMLElement[], alias?: string): BrickOutline[] {\n return elements.map((element) => {\n const hasContentScroll = contentScrollHost?.contains(element);\n const { width, height, left, top } = element.getBoundingClientRect();\n return {\n width,\n height,\n left:\n left +\n window.scrollX +\n (hasContentScroll ? contentScrollElement.scrollLeft : 0),\n top:\n top +\n window.scrollY +\n (hasContentScroll ? contentScrollElement.scrollTop : 0),\n alias,\n hasContentScroll,\n };\n });\n}\n\nfunction getRootTplStateStoreId(): string | undefined {\n const mainMountPoint = document.querySelector(\"#main-mount-point\")!;\n\n return (mainMountPoint?.firstChild as HTMLElement)?.dataset[\n isV2 ? \"tplContextId\" : \"tplStateStoreId\"\n ];\n}\n","// istanbul ignore file: nothing logical except calling html2canvas.\nimport html2canvas from \"html2canvas\";\nimport { resizeScreenshot } from \"./resizeScreenshot.js\";\n\nfunction getCanvasBlob(canvas: HTMLCanvasElement): Promise<Blob> {\n return new Promise(function (resolve, reject) {\n canvas.toBlob(function (blob: Blob | null) {\n if (blob) {\n resolve(blob);\n } else {\n reject();\n }\n });\n });\n}\n\nexport async function capture(\n maxWidth: number,\n maxHeight: number\n): Promise<Blob> {\n const sourceCanvas = await html2canvas(document.body, {\n logging: false,\n scale: 1,\n width: window.innerWidth,\n height: window.innerHeight,\n foreignObjectRendering: true,\n });\n const targetCanvas = document.createElement(\"canvas\");\n resizeScreenshot(sourceCanvas, targetCanvas, maxWidth, maxHeight);\n const blob = await getCanvasBlob(targetCanvas);\n return blob;\n}\n","export function resizeScreenshot(\n canvas: HTMLCanvasElement,\n targetCanvas: HTMLCanvasElement,\n maxWidth: number,\n maxHeight: number\n): string {\n const targetRatio = maxWidth / maxHeight;\n const { width, height } = canvas;\n const ratio = width / height;\n const wider = ratio >= targetRatio;\n const finalWidth = wider ? maxWidth : maxHeight * ratio;\n const finalHeight = wider ? maxWidth / ratio : maxHeight;\n targetCanvas.width = finalWidth;\n targetCanvas.height = finalHeight;\n\n const ctx = targetCanvas.getContext(\"2d\")!;\n ctx.drawImage(canvas, 0, 0, width, height, 0, 0, finalWidth, finalHeight);\n return targetCanvas.toDataURL();\n}\n"],"names":["collectUsedContracts","storyboard","collection","nodeOrNodes","Set","traverse","node","type","_node$raw","useProvider","raw","add","collect","parseStoryboard","contracts","item","includes","push","customElements","define","createProviderClass","previewProxyOrigin","onClick","event","preventDefault","stopPropagation","eventTargets","iidList","getPossibleBrickTargets","length","window","parent","postMessage","sender","selectBrick","composedPath","onMouseEvent","hoverOnBrick","throttle","leading","onPointerDown","onPointerMove","onPointerLeave","onContextMenu","position","contextMenuOnBrick","x","clientX","y","clientY","targets","target","HTMLElement","dataset","iid","getRealTimeDataAnnotation","value","Array","isArray","connected","getHistory","_getHistory","matchPath","_matchPath","__secret_internals","_internals","flowApi","_flowAPi","isV2","_window$BRICK_NEXT_VE","dll","BRICK_NEXT_VERSIONS","startsWith","getHistoryV2","developHelper","developHelperV2","collectDebugContract","matchPathV2","getContextValue","name","_ref","tplStateStoreId","tplContextId","getAllContextValues","_ref2","v2Map","Object","fromEntries","map","_ref3","k","v","debugDataValue","data","_ref4","e","console","error","contentScrollElement","contentScrollHost","async","connect","previewFromOrigin","options","_secret_internals$ad","_secret_internals","sendMessage","message","hoverIid","hoverAlias","activeIid","activeAlias","sendHighlightBrickOutlines","alias","outlines","getBrickOutlines","highlightType","lastTemplatePreviewSettings","templateId","settings","updateTemplatePreviewSettings","appId","reload","updateSnippetPreviewSettings","JSON","parse","snippetData","updateFormPreviewSettings","formId","formData","history","addEventListener","_data$options","_data$options3","origin","_ref6","forwardedFor","nodes","flat","sendHighlightBricksOutlines","highlightNodes","pos","element","document","elementFromPoint","tagName","isDirection","brick","cursor","parentElement","getPossibleBrickIidList","handleHoverOnIframe","enabled","removeEventListener","updateStoryboardType","_data$options2","newContracts","_getAddedContracts","_ref7","updateStoryboardByRoute","storyboardPatch","updateStoryboardByTemplate","updateStoryboardBySnippet","getAddedContracts","call","isEmpty","updateStoryboard","location","goBack","goForward","maxWidth","maxHeight","sourceCanvas","html2canvas","body","logging","scale","width","innerWidth","height","innerHeight","foreignObjectRendering","targetCanvas","createElement","canvas","targetRatio","ratio","wider","finalWidth","finalHeight","getContext","drawImage","toDataURL","resizeScreenshot","Promise","resolve","reject","toBlob","blob","capture","then","screenshot","handlePreviewData","option","dataType","getRootTplStateStoreId","entries","_ref5","url","previewUrl","substring","basePath","getBasePath","to","routePath","routeExact","syncRouteMatch","contractData","previewOption","undefined","routeId","debugConf","HttpResponseError","responseJson","debugData","scroll","scrollX","scrollY","currentLocation","previewPageMatch","sendLocationChange","loc","createHref","match","pathname","path","exact","mainMountPoint","querySelector","placeholderLoadObserver","MutationObserver","childNodes","firstChild","disconnect","observe","childList","setupContentScroll","_host$shadowRoot","host","shadowRoot","_contentScrollElement","onContentScroll","this","scrollLeft","scrollTop","listen","setupRuntimeValueInspect","_data$match","getLegalRuntimeValue","omit","query","params","memoizedRootTplStateStoreId","setupRealTimeDataInspect","force","_secret_internals$se","_secret_internals2","setRealTimeDataInspectRoot","addRealTimeDataInspectHook","_ref8","changeType","detail","annotation","_ref9","mutationCallback","subtree","isRoot","elements","_contentScrollHost","hasContentScroll","contains","left","top","getBoundingClientRect","getOutlines","getElementsIncludingInShadowDOM","walk","root","candidates","querySelectorAll","_mainMountPoint$first"],"sourceRoot":""}