@next-bricks/visual-builder 1.5.1 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bricks.json +1 -1
- package/dist/chunks/{1876.f201fa37.js → 1876.3eb6dfd2.js} +3 -3
- package/dist/chunks/{1876.f201fa37.js.map → 1876.3eb6dfd2.js.map} +1 -1
- package/dist/chunks/3322.461a0488.js +2 -0
- package/dist/chunks/3322.461a0488.js.map +1 -0
- package/dist/chunks/{4724.c751ae2d.js → 4724.977bdfa3.js} +2 -2
- package/dist/chunks/{4724.c751ae2d.js.map → 4724.977bdfa3.js.map} +1 -1
- package/dist/chunks/592.8e4d9195.js +3 -0
- package/dist/chunks/592.8e4d9195.js.map +1 -0
- package/dist/chunks/{9784.4c1d3d90.js → 9784.7644184b.js} +3 -3
- package/dist/chunks/{9784.4c1d3d90.js.map → 9784.7644184b.js.map} +1 -1
- package/dist/chunks/{main.2f29f594.js → main.99296b2a.js} +2 -2
- package/dist/chunks/{main.2f29f594.js.map → main.99296b2a.js.map} +1 -1
- package/dist/chunks/{workbench-action-list.fdf58701.js → workbench-action-list.38fd8840.js} +2 -2
- package/dist/chunks/{workbench-action-list.fdf58701.js.map → workbench-action-list.38fd8840.js.map} +1 -1
- package/dist/chunks/{workbench-history-action.74149de5.js → workbench-history-action.61562660.js} +3 -3
- package/dist/chunks/{workbench-history-action.74149de5.js.map → workbench-history-action.61562660.js.map} +1 -1
- package/dist/{index.2da40318.js → index.426b8719.js} +2 -2
- package/dist/{index.2da40318.js.map → index.426b8719.js.map} +1 -1
- package/package.json +3 -3
- package/dist/chunks/3322.690ec4f9.js +0 -2
- package/dist/chunks/3322.690ec4f9.js.map +0 -1
- package/dist/chunks/592.dc063ee7.js +0 -3
- package/dist/chunks/592.dc063ee7.js.map +0 -1
- /package/dist/chunks/{1876.f201fa37.js.LICENSE.txt → 1876.3eb6dfd2.js.LICENSE.txt} +0 -0
- /package/dist/chunks/{592.dc063ee7.js.LICENSE.txt → 592.8e4d9195.js.LICENSE.txt} +0 -0
- /package/dist/chunks/{9784.4c1d3d90.js.LICENSE.txt → 9784.7644184b.js.LICENSE.txt} +0 -0
- /package/dist/chunks/{workbench-history-action.74149de5.js.LICENSE.txt → workbench-history-action.61562660.js.LICENSE.txt} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_next_bricks_visual_builder=self.webpackChunk_next_bricks_visual_builder||[]).push([[4724],{8172:(e,t,n)=>{n.d(t,{e:()=>i});var r=n(4516),a=n(9384),o=n(2700);function i(e){var t=function(e){var t=new Set;return(0,a.c)(e,(e=>{switch(e.type){case"Resolvable":case"EventHandler":var n,r=null===(n=e.raw)||void 0===n?void 0:n.useProvider;r&&t.add(r)}})),t}((0,o.MF)(e)),n=[];for(var r of t)r.includes("@")&&n.push(r);return n}customElements.define("visual-builder.collect-used-contracts",(0,r.createProviderClass)(i))},4724:(e,t,n)=>{n.d(t,{c:()=>R});var r,a=n(8944),o=n(4412),i=n(5268),s=n(9604),d=n(5440),l=n.n(d);function p(){return(p=(0,a.c)((function*(e,t){var n,r=yield l()(document.body,{logging:!1,scale:1,width:window.innerWidth,height:window.innerHeight,foreignObjectRendering:!0}),a=document.createElement("canvas");return function(e,t,n,r){var a=n/r,{width:o,height:i}=e,s=o/i,d=s>=a,l=d?n:r*s,p=d?n/s:r;t.width=l,t.height=p,t.getContext("2d").drawImage(e,0,0,o,i,0,0,l,p),t.toDataURL()}(r,a,e,t),yield(n=a,new Promise((function(e,t){n.toBlob((function(n){n?e(n):t()}))})))}))).apply(this,arguments)}function c(e){var t;e.preventDefault(),e.stopPropagation(),(t=y(e.composedPath())).length>0&&window.parent.postMessage({sender:"previewer",type:"select-brick",iidList:t},r)}function u(e){e.preventDefault(),e.stopPropagation()}var v=(0,s.throttle)((e=>{var t=y(e);t.length>0&&window.parent.postMessage({sender:"previewer",type:"hover-on-brick",iidList:t},r)}),100,{leading:!1});function h(e){e.preventDefault(),e.stopPropagation(),v(e.composedPath())}function w(e){e.preventDefault(),e.stopPropagation(),v(e.composedPath())}function m(e){e.preventDefault(),e.stopPropagation(),window.parent.postMessage({sender:"previewer",type:"hover-on-brick",iidList:[]},r)}function g(e){var t,n,a;e.preventDefault(),e.stopPropagation(),t=e.composedPath(),n={x:e.clientX,y:e.clientY},(a=y(t)).length>0&&window.parent.postMessage({sender:"previewer",type:"context-menu-on-brick",iidList:a,position:n},r)}function y(e){var t=[];for(var n of e)n instanceof HTMLElement&&"string"==typeof n.dataset.iid&&t.push(n.dataset.iid);return t}var f=n(8172);function b(e){var 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"}}var S=!1,E=i.getHistory,L=i.matchPath,k=i.__secret_internals,I=!1;try{var x,P=window.dll;if(P&&null!==(x=window.BRICK_NEXT_VERSIONS)&&void 0!==x&&null!==(x=x["brick-container"])&&void 0!==x&&x.startsWith("2.")){var{getHistory:C,developHelper:T}=P("tYg3"),{matchPath:D}=P("A+yw");E=C,L=D,k=(0,o.c)((0,o.c)({},T),{},{getContextValue(e,t){var{tplStateStoreId:n}=t;return T.getContextValue(e,{tplContextId:n})},getAllContextValues(e){var{tplStateStoreId:t}=e,n=T.getAllContextValues({tplContextId:t});return Object.fromEntries([...n].map((e=>{var[t,n]=e;return[t,n.value]})))}}),I=!0}}catch(e){console.error("Try to use v2 runtime APIs failed:",e)}var A=null,N=null;function R(e,t){return _.apply(this,arguments)}function _(){return _=(0,a.c)((function*(e,t){var n,d;if(!S){S=!0;var l,v,y,I,x=t=>{window.parent.postMessage((0,o.c)({sender:"previewer"},t),e)};x({type:"preview-started"}),r=e;var P,C=(e,t,n)=>{var r=M(t);x({type:"highlight-brick",highlightType:e,outlines:r,iid:t,alias:n})};t.templateId&&(P=t.settings);var T=()=>{k.updateTemplatePreviewSettings(t.appId,t.templateId,P),E().reload()},D=()=>{k.updateSnippetPreviewSettings(t.appId,JSON.parse(t.snippetData)),E().reload()},R=E();window.addEventListener("message",function(){var n=(0,a.c)((function*(n){var a,o,d,{data:b,origin:S}=n;if(S===e&&b&&"preview-container"===b.sender)if("builder"===b.forwardedFor)switch(b.type){case"hover-on-brick":l=b.iid,v=b.alias,C("hover",b.iid,b.alias);break;case"hover-on-main":C("hover","#main-mount-point","root");break;case"hover-on-context":d=b.highlightNodes.map((e=>M(e.iid,e.alias))).flat(),x({type:"highlight-context",outlines:d});break;case"select-brick":y=b.iid,I=b.alias,C("active",b.iid,b.alias);break;case"hover-on-iframe":(e=>{var 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}},r);else{var n=function(e){for(var t=[],n=e;n;)"string"==typeof n.dataset.iid&&t.push(n.dataset.iid),n=n.parentElement;return t}(t);window.parent.postMessage({sender:"previewer",type:"hover-on-brick",iidList:n,isDirection:!0,position:{x:e.x,y:e.y}},r)}})(b.position)}else switch(b.type){case"toggle-inspecting":b.enabled?(window.addEventListener("click",c,!0),window.addEventListener("mousedown",u,!0),window.addEventListener("mouseover",u,!0),window.addEventListener("mouseup",u,!0),window.addEventListener("pointerdown",h,!0),window.addEventListener("pointermove",w,!0),window.addEventListener("pointerup",u,!0),window.addEventListener("pointerleave",m,!0),window.addEventListener("contextmenu",g,!0)):(window.removeEventListener("click",c,!0),window.removeEventListener("mousedown",u,!0),window.removeEventListener("mouseover",u,!0),window.removeEventListener("mouseup",u,!0),window.removeEventListener("pointerdown",h,!0),window.removeEventListener("pointermove",w,!0),window.removeEventListener("pointerup",u,!0),window.removeEventListener("pointerleave",m,!0),window.removeEventListener("contextmenu",g,!0));break;case"refresh":if(null!==(a=b.options)&&void 0!==a&&a.updateStoryboardType){var L,A;"route"===b.options.updateStoryboardType?k.updateStoryboardByRoute(t.appId,b.storyboardPatch):"template"===b.options.updateStoryboardType?k.updateStoryboardByTemplate(t.appId,b.storyboardPatch,b.options.settings):"snippet"===b.options.updateStoryboardType&&k.updateStoryboardBySnippet(t.appId,b.storyboardPatch);var N=yield null===(L=(A=k).getAddedContracts)||void 0===L?void 0:L.call(A,b.storyboardPatch,{appId:t.appId,updateStoryboardType:b.options.updateStoryboardType,formId:t.formId,collectUsedContracts:f.e});(0,s.isEmpty)(N)?E().reload():x({type:"contract-update",data:{add:N}});break}k.updateStoryboard(t.appId,b.storyboardPatch),t.templateId?(P=b.settings,T()):null!==(o=b.options)&&void 0!==o&&o.snippetData?(t.snippetData=b.options.snippetData,D()):E().reload();break;case"reload":location.reload();break;case"back":R.goBack();break;case"forward":R.goForward();break;case"capture":(function(e,t){return p.apply(this,arguments)})(b.maxWidth,b.maxHeight).then((e=>{x({type:"capture-ok",screenshot:e})}),(()=>{x({type:"capture-failed"})}));break;case"inspect-data-value":((e,t)=>{try{var n,r,a,{dataType:o}=t;if("state"===o&&!(n=O()))return void x({type:"inspect-data-value-error",data:{error:{message:"tplStateStoreId not found, unable to preview STATE value"}}});if(e)a="inspect-single-data-value-success",r=k.getContextValue(e,{tplStateStoreId:n});else{a="inspect-all-data-values-success";var i=k.getAllContextValues({tplStateStoreId:n});r=Object.entries(i).map((e=>{var[t,n]=e;return{name:t,value:n}}))}x({type:a,data:{name:e,value:r}})}catch(e){x({type:"inspect-data-value-error",data:{message:e.message}})}})(b.name,b.option);break;case"update-preview-url":var _=b.previewUrl.startsWith(window.origin)?b.previewUrl.substring(window.origin.length):b.previewUrl,H=(0,i.getBasePath)(),B=_.startsWith(H)?_.substring(H.length-1):_;E().push(B);break;case"update-preview-route":t.routePath=b.routePath,t.routeExact=b.routeExact,V()}}));return function(e){return n.apply(this,arguments)}}()),window.addEventListener("scroll",(()=>{x({type:"scroll",scroll:{x:window.scrollX,y:window.scrollY}})}));var _,H,B=!0,q=e=>{x({type:"url-change",url:location.origin+R.createHref(e)}),_=e,V()};q(R.location),R.listen(q),t.templateId&&T(),t.snippetData&&D(),null===(n=(d=k).addRealTimeDataInspectHook)||void 0===n||n.call(d,(e=>{var{changeType:t,tplStateStoreId:n,detail:r}=e;x({type:"real-time-data-inspect-change",changeType:t,tplStateStoreId:n,detail:"update"===t?{name:r.name,annotation:b(r.value)}:{data:Object.fromEntries(Object.entries(r.data).map((e=>{var[t,n]=e;return[t,b(n)]})))}})})),window.addEventListener("route.render",(()=>{W(!0)})),j(),W(!0),new MutationObserver((0,s.throttle)((()=>{j(),W(),l&&C("hover",l,v),y&&C("active",y,I)}),100,{leading:!1})).observe(document.body,{subtree:!0,childList:!0})}function V(){if(t.routePath){var e=!!L(_.pathname,{path:t.routePath,exact:t.routeExact});if(x({type:"route-match-change",match:e}),t.templateId&&!B&&e){var n=document.querySelector("#main-mount-point"),r=new MutationObserver((()=>{1===n.childNodes.length&&"SPAN"===n.firstChild.tagName&&0===n.firstChild.childNodes.length&&(T(),r.disconnect())}));r.observe(n,{childList:!0})}if(t.snippetData&&!B&&e){var a=document.querySelector("#main-mount-point"),o=new MutationObserver((()=>{1===a.childNodes.length&&"SPAN"===a.firstChild.tagName&&0===a.firstChild.childNodes.length&&(D(),o.disconnect())}));o.observe(a,{childList:!0})}B=e}}function j(){var e,t,n,r=document.querySelector("eo-page-view"),a=null!==(e=null==r||null===(t=r.shadowRoot)||void 0===t?void 0:t.querySelector(".content"))&&void 0!==e?e:null;a!==A&&(null===(n=A)||void 0===n||n.removeEventListener("scroll",U),null==a||a.addEventListener("scroll",U),A=a,N=r)}function U(){x({type:"content-scroll",scroll:{x:this.scrollLeft,y:this.scrollTop}})}function W(e){var n,r,a=t.templateId?O():void 0;(H!==a||e)&&(H=a,null===(n=(r=k).setRealTimeDataInspectRoot)||void 0===n||n.call(r,{tplStateStoreId:a}))}})),_.apply(this,arguments)}function M(e,t){if(!e)return[];var n=e.includes("#"),r=function(e,t){var n=[];return function r(a){var o=a.querySelectorAll(t?e:'[data-iid="'.concat(e,'"]'));if(n.push(...o),!(a===document&&o.length>0))for(var i of a.querySelectorAll("*"))i.shadowRoot&&r(i.shadowRoot)}(document),n}(e,n),a=function(e,t){return e.map((e=>{var n,r=null===(n=N)||void 0===n?void 0:n.contains(e),{width:a,height:o,left:i,top:s}=e.getBoundingClientRect();return{width:a,height:o,left:i+window.scrollX+(r?A.scrollLeft:0),top:s+window.scrollY+(r?A.scrollTop:0),alias:t,hasContentScroll:r}}))}(r,t);return n?a.map((e=>(0,o.c)((0,o.c)({},e),{},{height:window.innerHeight-e.top}))):a}function O(){var e,t=document.querySelector("#main-mount-point");return null==t||null===(e=t.firstChild)||void 0===e?void 0:e.dataset[I?"tplContextId":"tplStateStoreId"]}}}]);
|
|
2
|
-
//# sourceMappingURL=4724.
|
|
1
|
+
"use strict";(self.webpackChunk_next_bricks_visual_builder=self.webpackChunk_next_bricks_visual_builder||[]).push([[4724],{8172:(e,t,n)=>{n.d(t,{e:()=>i});var r=n(4516),a=n(9384),o=n(2700);function i(e){var t=function(e){var t=new Set;return(0,a.c)(e,(e=>{switch(e.type){case"Resolvable":case"EventHandler":var n,r=null===(n=e.raw)||void 0===n?void 0:n.useProvider;r&&t.add(r)}})),t}((0,o.MF)(e)),n=[];for(var r of t)r.includes("@")&&n.push(r);return n}customElements.define("visual-builder.collect-used-contracts",(0,r.createProviderClass)(i))},4724:(e,t,n)=>{n.d(t,{c:()=>R});var r,a=n(8944),o=n(4412),i=n(6960),s=n(9604),d=n(5440),l=n.n(d);function p(){return(p=(0,a.c)((function*(e,t){var n,r=yield l()(document.body,{logging:!1,scale:1,width:window.innerWidth,height:window.innerHeight,foreignObjectRendering:!0}),a=document.createElement("canvas");return function(e,t,n,r){var a=n/r,{width:o,height:i}=e,s=o/i,d=s>=a,l=d?n:r*s,p=d?n/s:r;t.width=l,t.height=p,t.getContext("2d").drawImage(e,0,0,o,i,0,0,l,p),t.toDataURL()}(r,a,e,t),yield(n=a,new Promise((function(e,t){n.toBlob((function(n){n?e(n):t()}))})))}))).apply(this,arguments)}function c(e){var t;e.preventDefault(),e.stopPropagation(),(t=y(e.composedPath())).length>0&&window.parent.postMessage({sender:"previewer",type:"select-brick",iidList:t},r)}function u(e){e.preventDefault(),e.stopPropagation()}var v=(0,s.throttle)((e=>{var t=y(e);t.length>0&&window.parent.postMessage({sender:"previewer",type:"hover-on-brick",iidList:t},r)}),100,{leading:!1});function h(e){e.preventDefault(),e.stopPropagation(),v(e.composedPath())}function w(e){e.preventDefault(),e.stopPropagation(),v(e.composedPath())}function m(e){e.preventDefault(),e.stopPropagation(),window.parent.postMessage({sender:"previewer",type:"hover-on-brick",iidList:[]},r)}function g(e){var t,n,a;e.preventDefault(),e.stopPropagation(),t=e.composedPath(),n={x:e.clientX,y:e.clientY},(a=y(t)).length>0&&window.parent.postMessage({sender:"previewer",type:"context-menu-on-brick",iidList:a,position:n},r)}function y(e){var t=[];for(var n of e)n instanceof HTMLElement&&"string"==typeof n.dataset.iid&&t.push(n.dataset.iid);return t}var f=n(8172);function b(e){var 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"}}var S=!1,E=i.getHistory,L=i.matchPath,k=i.__secret_internals,I=!1;try{var x,P=window.dll;if(P&&null!==(x=window.BRICK_NEXT_VERSIONS)&&void 0!==x&&null!==(x=x["brick-container"])&&void 0!==x&&x.startsWith("2.")){var{getHistory:C,developHelper:T}=P("tYg3"),{matchPath:D}=P("A+yw");E=C,L=D,k=(0,o.c)((0,o.c)({},T),{},{getContextValue(e,t){var{tplStateStoreId:n}=t;return T.getContextValue(e,{tplContextId:n})},getAllContextValues(e){var{tplStateStoreId:t}=e,n=T.getAllContextValues({tplContextId:t});return Object.fromEntries([...n].map((e=>{var[t,n]=e;return[t,n.value]})))}}),I=!0}}catch(e){console.error("Try to use v2 runtime APIs failed:",e)}var A=null,N=null;function R(e,t){return _.apply(this,arguments)}function _(){return _=(0,a.c)((function*(e,t){var n,d;if(!S){S=!0;var l,v,y,I,x=t=>{window.parent.postMessage((0,o.c)({sender:"previewer"},t),e)};x({type:"preview-started"}),r=e;var P,C=(e,t,n)=>{var r=M(t);x({type:"highlight-brick",highlightType:e,outlines:r,iid:t,alias:n})};t.templateId&&(P=t.settings);var T=()=>{k.updateTemplatePreviewSettings(t.appId,t.templateId,P),E().reload()},D=()=>{k.updateSnippetPreviewSettings(t.appId,JSON.parse(t.snippetData)),E().reload()},R=E();window.addEventListener("message",function(){var n=(0,a.c)((function*(n){var a,o,d,{data:b,origin:S}=n;if(S===e&&b&&"preview-container"===b.sender)if("builder"===b.forwardedFor)switch(b.type){case"hover-on-brick":l=b.iid,v=b.alias,C("hover",b.iid,b.alias);break;case"hover-on-main":C("hover","#main-mount-point","root");break;case"hover-on-context":d=b.highlightNodes.map((e=>M(e.iid,e.alias))).flat(),x({type:"highlight-context",outlines:d});break;case"select-brick":y=b.iid,I=b.alias,C("active",b.iid,b.alias);break;case"hover-on-iframe":(e=>{var 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}},r);else{var n=function(e){for(var t=[],n=e;n;)"string"==typeof n.dataset.iid&&t.push(n.dataset.iid),n=n.parentElement;return t}(t);window.parent.postMessage({sender:"previewer",type:"hover-on-brick",iidList:n,isDirection:!0,position:{x:e.x,y:e.y}},r)}})(b.position)}else switch(b.type){case"toggle-inspecting":b.enabled?(window.addEventListener("click",c,!0),window.addEventListener("mousedown",u,!0),window.addEventListener("mouseover",u,!0),window.addEventListener("mouseup",u,!0),window.addEventListener("pointerdown",h,!0),window.addEventListener("pointermove",w,!0),window.addEventListener("pointerup",u,!0),window.addEventListener("pointerleave",m,!0),window.addEventListener("contextmenu",g,!0)):(window.removeEventListener("click",c,!0),window.removeEventListener("mousedown",u,!0),window.removeEventListener("mouseover",u,!0),window.removeEventListener("mouseup",u,!0),window.removeEventListener("pointerdown",h,!0),window.removeEventListener("pointermove",w,!0),window.removeEventListener("pointerup",u,!0),window.removeEventListener("pointerleave",m,!0),window.removeEventListener("contextmenu",g,!0));break;case"refresh":if(null!==(a=b.options)&&void 0!==a&&a.updateStoryboardType){var L,A;"route"===b.options.updateStoryboardType?k.updateStoryboardByRoute(t.appId,b.storyboardPatch):"template"===b.options.updateStoryboardType?k.updateStoryboardByTemplate(t.appId,b.storyboardPatch,b.options.settings):"snippet"===b.options.updateStoryboardType&&k.updateStoryboardBySnippet(t.appId,b.storyboardPatch);var N=yield null===(L=(A=k).getAddedContracts)||void 0===L?void 0:L.call(A,b.storyboardPatch,{appId:t.appId,updateStoryboardType:b.options.updateStoryboardType,formId:t.formId,collectUsedContracts:f.e});(0,s.isEmpty)(N)?E().reload():x({type:"contract-update",data:{add:N}});break}k.updateStoryboard(t.appId,b.storyboardPatch),t.templateId?(P=b.settings,T()):null!==(o=b.options)&&void 0!==o&&o.snippetData?(t.snippetData=b.options.snippetData,D()):E().reload();break;case"reload":location.reload();break;case"back":R.goBack();break;case"forward":R.goForward();break;case"capture":(function(e,t){return p.apply(this,arguments)})(b.maxWidth,b.maxHeight).then((e=>{x({type:"capture-ok",screenshot:e})}),(()=>{x({type:"capture-failed"})}));break;case"inspect-data-value":((e,t)=>{try{var n,r,a,{dataType:o}=t;if("state"===o&&!(n=O()))return void x({type:"inspect-data-value-error",data:{error:{message:"tplStateStoreId not found, unable to preview STATE value"}}});if(e)a="inspect-single-data-value-success",r=k.getContextValue(e,{tplStateStoreId:n});else{a="inspect-all-data-values-success";var i=k.getAllContextValues({tplStateStoreId:n});r=Object.entries(i).map((e=>{var[t,n]=e;return{name:t,value:n}}))}x({type:a,data:{name:e,value:r}})}catch(e){x({type:"inspect-data-value-error",data:{message:e.message}})}})(b.name,b.option);break;case"update-preview-url":var _=b.previewUrl.startsWith(window.origin)?b.previewUrl.substring(window.origin.length):b.previewUrl,H=(0,i.getBasePath)(),B=_.startsWith(H)?_.substring(H.length-1):_;E().push(B);break;case"update-preview-route":t.routePath=b.routePath,t.routeExact=b.routeExact,V()}}));return function(e){return n.apply(this,arguments)}}()),window.addEventListener("scroll",(()=>{x({type:"scroll",scroll:{x:window.scrollX,y:window.scrollY}})}));var _,H,B=!0,q=e=>{x({type:"url-change",url:location.origin+R.createHref(e)}),_=e,V()};q(R.location),R.listen(q),t.templateId&&T(),t.snippetData&&D(),null===(n=(d=k).addRealTimeDataInspectHook)||void 0===n||n.call(d,(e=>{var{changeType:t,tplStateStoreId:n,detail:r}=e;x({type:"real-time-data-inspect-change",changeType:t,tplStateStoreId:n,detail:"update"===t?{name:r.name,annotation:b(r.value)}:{data:Object.fromEntries(Object.entries(r.data).map((e=>{var[t,n]=e;return[t,b(n)]})))}})})),window.addEventListener("route.render",(()=>{W(!0)})),j(),W(!0),new MutationObserver((0,s.throttle)((()=>{j(),W(),l&&C("hover",l,v),y&&C("active",y,I)}),100,{leading:!1})).observe(document.body,{subtree:!0,childList:!0})}function V(){if(t.routePath){var e=!!L(_.pathname,{path:t.routePath,exact:t.routeExact});if(x({type:"route-match-change",match:e}),t.templateId&&!B&&e){var n=document.querySelector("#main-mount-point"),r=new MutationObserver((()=>{1===n.childNodes.length&&"SPAN"===n.firstChild.tagName&&0===n.firstChild.childNodes.length&&(T(),r.disconnect())}));r.observe(n,{childList:!0})}if(t.snippetData&&!B&&e){var a=document.querySelector("#main-mount-point"),o=new MutationObserver((()=>{1===a.childNodes.length&&"SPAN"===a.firstChild.tagName&&0===a.firstChild.childNodes.length&&(D(),o.disconnect())}));o.observe(a,{childList:!0})}B=e}}function j(){var e,t,n,r=document.querySelector("eo-page-view"),a=null!==(e=null==r||null===(t=r.shadowRoot)||void 0===t?void 0:t.querySelector(".content"))&&void 0!==e?e:null;a!==A&&(null===(n=A)||void 0===n||n.removeEventListener("scroll",U),null==a||a.addEventListener("scroll",U),A=a,N=r)}function U(){x({type:"content-scroll",scroll:{x:this.scrollLeft,y:this.scrollTop}})}function W(e){var n,r,a=t.templateId?O():void 0;(H!==a||e)&&(H=a,null===(n=(r=k).setRealTimeDataInspectRoot)||void 0===n||n.call(r,{tplStateStoreId:a}))}})),_.apply(this,arguments)}function M(e,t){if(!e)return[];var n=e.includes("#"),r=function(e,t){var n=[];return function r(a){var o=a.querySelectorAll(t?e:'[data-iid="'.concat(e,'"]'));if(n.push(...o),!(a===document&&o.length>0))for(var i of a.querySelectorAll("*"))i.shadowRoot&&r(i.shadowRoot)}(document),n}(e,n),a=function(e,t){return e.map((e=>{var n,r=null===(n=N)||void 0===n?void 0:n.contains(e),{width:a,height:o,left:i,top:s}=e.getBoundingClientRect();return{width:a,height:o,left:i+window.scrollX+(r?A.scrollLeft:0),top:s+window.scrollY+(r?A.scrollTop:0),alias:t,hasContentScroll:r}}))}(r,t);return n?a.map((e=>(0,o.c)((0,o.c)({},e),{},{height:window.innerHeight-e.top}))):a}function O(){var e,t=document.querySelector("#main-mount-point");return null==t||null===(e=t.firstChild)||void 0===e?void 0:e.dataset[I?"tplContextId":"tplStateStoreId"]}}}]);
|
|
2
|
+
//# sourceMappingURL=4724.977bdfa3.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunks/4724.c751ae2d.js","mappings":"6LAgCO,SAASA,EAAqBC,GACnC,IAAMC,EArBR,SAAiBC,GACf,IAAMD,EAAa,IAAIE,IAgBvB,OAdAC,EAAAA,EAAAA,GAASF,GAAcG,IACrB,OAAQA,EAAKC,MACX,IAAK,aACL,IAAK,eAAgB,IAAAC,EACbC,EACI,QADOD,EACfF,EAAKI,WAAG,IAAAF,OAAA,EADUA,EAEjBC,YACCA,GACFP,EAAWS,IAAIF,GAGrB,IAGKP,CACT,CAGqBU,EAAQC,EAAAA,EAAAA,IAAgBZ,IAErCa,EAAY,GAElB,IAAK,IAAMC,KAAQb,EACba,EAAKC,SAAS,MAChBF,EAAUG,KAAKF,GAInB,OAAOD,CACT,CAEAI,eAAeC,OACb,yCACAC,EAAAA,EAAAA,qBAAoBp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AASyD,IAA6C,IAAA2E,EAC9CnC,EAAiBpN,SAASqN,cAAc,qBAE9C,OAAQD,SAA0B,QAAZmC,EAAdnC,EAAgBI,kBAAU,IAAA+B,OAAA,EAA3BA,EAA6C/L,QAClDa,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/capture.ts","webpack:///./src/data-providers/preview/resizeScreenshot.ts","webpack:///./src/data-providers/preview/realTimeDataInspect.ts","webpack:///./src/data-providers/preview/connect.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","// 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","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 type { BrickConf, CustomTemplate, RouteConf } from \"@next-core/types\";\nimport { isEmpty, throttle } from \"lodash\";\nimport type {\n BrickOutline,\n HighLightNode,\n Position,\n PreviewDataOption,\n PreviewMessageFromPreviewer,\n PreviewMessagePreviewContractUpdate,\n PreviewMessagePreviewDataValueError,\n PreviewMessagePreviewDataValueSuccess,\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} 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 };\n (moduleId: \"A+yw\"): {\n matchPath: typeof _matchPath;\n };\n}\n\nlet getHistory = _getHistory;\nlet matchPath = _matchPath;\nlet __secret_internals = _internals;\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 { getHistory: getHistoryV2, developHelper: developHelperV2 } =\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 };\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.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 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.updateFormPreviewSettings(\n options.appId,\n options.formId,\n data.storyboardPatch as FormDataProperties\n );\n } */\n\n const 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 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 \"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 __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 });\n\n setupContentScroll();\n setupRealTimeDataInspect(true);\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\nfunction 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"],"names":["collectUsedContracts","storyboard","collection","nodeOrNodes","Set","traverse","node","type","_node$raw","useProvider","raw","add","collect","parseStoryboard","contracts","item","includes","push","customElements","define","createProviderClass","previewProxyOrigin","_capture","_asyncToGenerator","maxWidth","maxHeight","canvas","sourceCanvas","html2canvas","document","body","logging","scale","width","window","innerWidth","height","innerHeight","foreignObjectRendering","targetCanvas","createElement","targetRatio","ratio","wider","finalWidth","finalHeight","getContext","drawImage","toDataURL","resizeScreenshot","Promise","resolve","reject","toBlob","blob","apply","arguments","onClick","event","iidList","preventDefault","stopPropagation","getPossibleBrickTargets","composedPath","length","parent","postMessage","sender","onMouseEvent","hoverOnBrick","throttle","eventTargets","leading","onPointerDown","onPointerMove","onPointerLeave","onContextMenu","position","x","clientX","y","clientY","targets","target","HTMLElement","dataset","iid","getRealTimeDataAnnotation","value","Array","isArray","connected","getHistory","_getHistory","matchPath","_matchPath","__secret_internals","_internals","isV2","_window$BRICK_NEXT_VE","dll","BRICK_NEXT_VERSIONS","startsWith","getHistoryV2","developHelper","developHelperV2","matchPathV2","_objectSpread","getContextValue","name","_ref","tplStateStoreId","tplContextId","getAllContextValues","_ref2","v2Map","Object","fromEntries","map","_ref3","k","v","e","console","error","contentScrollElement","contentScrollHost","connect","_x","_x2","_connect","previewFromOrigin","options","_secret_internals$ad","_secret_internals","hoverIid","hoverAlias","activeIid","activeAlias","sendMessage","message","lastTemplatePreviewSettings","sendHighlightBrickOutlines","alias","outlines","getBrickOutlines","highlightType","templateId","settings","updateTemplatePreviewSettings","appId","reload","updateSnippetPreviewSettings","JSON","parse","snippetData","history","addEventListener","_ref6","_ref5","_data$options","_data$options2","data","origin","forwardedFor","highlightNodes","flat","pos","element","elementFromPoint","tagName","isDirection","brick","cursor","parentElement","getPossibleBrickIidList","handleHoverOnIframe","enabled","removeEventListener","updateStoryboardType","_getAddedContracts","_ref7","updateStoryboardByRoute","storyboardPatch","updateStoryboardByTemplate","updateStoryboardBySnippet","newContracts","getAddedContracts","call","formId","isEmpty","updateStoryboard","location","goBack","goForward","capture","then","screenshot","handlePreviewData","option","dataType","getRootTplStateStoreId","entries","_ref4","url","previewUrl","substring","basePath","getBasePath","to","routePath","routeExact","syncRouteMatch","_x3","scroll","scrollX","scrollY","currentLocation","memoizedRootTplStateStoreId","previewPageMatch","sendLocationChange","loc","createHref","listen","addRealTimeDataInspectHook","_ref8","changeType","detail","annotation","_ref9","setupRealTimeDataInspect","setupContentScroll","MutationObserver","mutationCallback","observe","subtree","childList","match","pathname","path","exact","mainMountPoint","querySelector","placeholderLoadObserver","childNodes","firstChild","disconnect","_host$shadowRoot$quer","_host$shadowRoot","_contentScrollElement","host","shadowRoot","onContentScroll","this","scrollLeft","scrollTop","force","_secret_internals$se","_secret_internals2","undefined","setRealTimeDataInspectRoot","isRoot","elements","walk","root","candidates","querySelectorAll","concat","getElementsIncludingInShadowDOM","_contentScrollHost","hasContentScroll","contains","left","top","getBoundingClientRect","getOutlines","_mainMountPoint$first"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"chunks/4724.977bdfa3.js","mappings":"6LAgCO,SAASA,EAAqBC,GACnC,IAAMC,EArBR,SAAiBC,GACf,IAAMD,EAAa,IAAIE,IAgBvB,OAdAC,EAAAA,EAAAA,GAASF,GAAcG,IACrB,OAAQA,EAAKC,MACX,IAAK,aACL,IAAK,eAAgB,IAAAC,EACbC,EACI,QADOD,EACfF,EAAKI,WAAG,IAAAF,OAAA,EADUA,EAEjBC,YACCA,GACFP,EAAWS,IAAIF,GAGrB,IAGKP,CACT,CAGqBU,EAAQC,EAAAA,EAAAA,IAAgBZ,IAErCa,EAAY,GAElB,IAAK,IAAMC,KAAQb,EACba,EAAKC,SAAS,MAChBF,EAAUG,KAAKF,GAInB,OAAOD,CACT,CAEAI,eAAeC,OACb,yCACAC,EAAAA,EAAAA,qBAAoBpB,G,sCCvCXqB,E,2DCsBV,SAAAC,IAAA,OAAAA,GAAAC,EAAAA,EAAAA,IAfM,UACLC,EACAC,GAEA,IA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AAgBI,kBAAU,IAAA+B,OAAA,EAA3BA,EAA6C/L,QAClDa,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/capture.ts","webpack:///./src/data-providers/preview/resizeScreenshot.ts","webpack:///./src/data-providers/preview/realTimeDataInspect.ts","webpack:///./src/data-providers/preview/connect.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","// 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","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 type { BrickConf, CustomTemplate, RouteConf } from \"@next-core/types\";\nimport { isEmpty, throttle } from \"lodash\";\nimport type {\n BrickOutline,\n HighLightNode,\n Position,\n PreviewDataOption,\n PreviewMessageFromPreviewer,\n PreviewMessagePreviewContractUpdate,\n PreviewMessagePreviewDataValueError,\n PreviewMessagePreviewDataValueSuccess,\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} 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 };\n (moduleId: \"A+yw\"): {\n matchPath: typeof _matchPath;\n };\n}\n\nlet getHistory = _getHistory;\nlet matchPath = _matchPath;\nlet __secret_internals = _internals;\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 { getHistory: getHistoryV2, developHelper: developHelperV2 } =\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 };\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.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 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.updateFormPreviewSettings(\n options.appId,\n options.formId,\n data.storyboardPatch as FormDataProperties\n );\n } */\n\n const 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 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 \"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 __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 });\n\n setupContentScroll();\n setupRealTimeDataInspect(true);\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\nfunction 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"],"names":["collectUsedContracts","storyboard","collection","nodeOrNodes","Set","traverse","node","type","_node$raw","useProvider","raw","add","collect","parseStoryboard","contracts","item","includes","push","customElements","define","createProviderClass","previewProxyOrigin","_capture","_asyncToGenerator","maxWidth","maxHeight","canvas","sourceCanvas","html2canvas","document","body","logging","scale","width","window","innerWidth","height","innerHeight","foreignObjectRendering","targetCanvas","createElement","targetRatio","ratio","wider","finalWidth","finalHeight","getContext","drawImage","toDataURL","resizeScreenshot","Promise","resolve","reject","toBlob","blob","apply","arguments","onClick","event","iidList","preventDefault","stopPropagation","getPossibleBrickTargets","composedPath","length","parent","postMessage","sender","onMouseEvent","hoverOnBrick","throttle","eventTargets","leading","onPointerDown","onPointerMove","onPointerLeave","onContextMenu","position","x","clientX","y","clientY","targets","target","HTMLElement","dataset","iid","getRealTimeDataAnnotation","value","Array","isArray","connected","getHistory","_getHistory","matchPath","_matchPath","__secret_internals","_internals","isV2","_window$BRICK_NEXT_VE","dll","BRICK_NEXT_VERSIONS","startsWith","getHistoryV2","developHelper","developHelperV2","matchPathV2","_objectSpread","getContextValue","name","_ref","tplStateStoreId","tplContextId","getAllContextValues","_ref2","v2Map","Object","fromEntries","map","_ref3","k","v","e","console","error","contentScrollElement","contentScrollHost","connect","_x","_x2","_connect","previewFromOrigin","options","_secret_internals$ad","_secret_internals","hoverIid","hoverAlias","activeIid","activeAlias","sendMessage","message","lastTemplatePreviewSettings","sendHighlightBrickOutlines","alias","outlines","getBrickOutlines","highlightType","templateId","settings","updateTemplatePreviewSettings","appId","reload","updateSnippetPreviewSettings","JSON","parse","snippetData","history","addEventListener","_ref6","_ref5","_data$options","_data$options2","data","origin","forwardedFor","highlightNodes","flat","pos","element","elementFromPoint","tagName","isDirection","brick","cursor","parentElement","getPossibleBrickIidList","handleHoverOnIframe","enabled","removeEventListener","updateStoryboardType","_getAddedContracts","_ref7","updateStoryboardByRoute","storyboardPatch","updateStoryboardByTemplate","updateStoryboardBySnippet","newContracts","getAddedContracts","call","formId","isEmpty","updateStoryboard","location","goBack","goForward","capture","then","screenshot","handlePreviewData","option","dataType","getRootTplStateStoreId","entries","_ref4","url","previewUrl","substring","basePath","getBasePath","to","routePath","routeExact","syncRouteMatch","_x3","scroll","scrollX","scrollY","currentLocation","memoizedRootTplStateStoreId","previewPageMatch","sendLocationChange","loc","createHref","listen","addRealTimeDataInspectHook","_ref8","changeType","detail","annotation","_ref9","setupRealTimeDataInspect","setupContentScroll","MutationObserver","mutationCallback","observe","subtree","childList","match","pathname","path","exact","mainMountPoint","querySelector","placeholderLoadObserver","childNodes","firstChild","disconnect","_host$shadowRoot$quer","_host$shadowRoot","_contentScrollElement","host","shadowRoot","onContentScroll","this","scrollLeft","scrollTop","force","_secret_internals$se","_secret_internals2","undefined","setRealTimeDataInspectRoot","isRoot","elements","walk","root","candidates","querySelectorAll","concat","getElementsIncludingInShadowDOM","_contentScrollHost","hasContentScroll","contains","left","top","getBoundingClientRect","getOutlines","_mainMountPoint$first"],"sourceRoot":""}
|