@emailmaker/emailmaker 1.1.31 → 1.1.36

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 (41) hide show
  1. package/{emailmaker-core.25e2342b.js → emailmaker-core.4a2946bd.js} +1 -1
  2. package/emailmaker-esm.js +17 -6
  3. package/emailmaker.d.ts +9 -2
  4. package/emailmaker.js +176 -12
  5. package/iframe/js/amp.DieSnBUu.js +1 -0
  6. package/iframe/js/iframe-eblock.js +1 -1
  7. package/iframe/js/iframe.js +1 -1
  8. package/iframe/js/rules.CNqvmp_P.js +1 -1
  9. package/package.json +1 -1
  10. package/singlepage_headless_plugin.html +1 -1
  11. package/static/core/{76f5295d.js → 369b60a1.js} +1 -1
  12. package/static/core/{13ca3f502.js → 539179022.js} +1 -1
  13. package/static/core/548145dc.js +3 -0
  14. package/static/core/{4686eabe.js → 61af40b8.js} +3 -3
  15. package/static/core/{cc38c423.js → 6d27d0a8.js} +2 -2
  16. package/static/core/77441b5e.js +51 -0
  17. package/static/core/{25d26369.js → 7865066d.js} +2 -2
  18. package/static/core/8f709c0d.js +1 -0
  19. package/static/core/{ca58f6cf.js → a73f6ffb.js} +1 -1
  20. package/static/core/{bfefb58d.js → af40ecaa.js} +2 -2
  21. package/static/core/{d06bc0bd.js → b6d3de9a.js} +50 -50
  22. package/static/core/{91634ef3.js → ba40f70e.js} +1 -1
  23. package/static/core/bc0b6b3f.js +78 -0
  24. package/static/core/{df4b4fe2.js → d856ee32.js} +2 -2
  25. package/static/core/{1da27b3c.js → e5d13a1c.js} +1 -1
  26. package/static/core/{558afaa1.js → ef4e808c.js} +1 -1
  27. package/static/core/{e37f6763.js → f47646dc.js} +2 -2
  28. package/static/core/{e4ba0190.js → fc5712ae.js} +1 -1
  29. package/static/esm/533d7587.js +1 -0
  30. package/two_step_headless_plugin.html +1 -1
  31. package/vite/index.cjs +109 -18
  32. package/vite/index.js +109 -18
  33. package/webpack/index.cjs +108 -11
  34. package/webpack/index.js +108 -11
  35. package/iframe/js/amp.BLBsfH3J.js +0 -1
  36. package/static/core/3c291097.js +0 -78
  37. package/static/core/62c48605.js +0 -3
  38. package/static/core/8a188b85.js +0 -51
  39. package/static/core/8aba252b.js +0 -1
  40. /package/iframe/{iframe-eblock.25e2342b.html → iframe-eblock.4a2946bd.html} +0 -0
  41. /package/iframe/{iframe.25e2342b.html → iframe.4a2946bd.html} +0 -0
@@ -1 +1 @@
1
- __emailmaker__.define(`static/core/e4ba0190.js`,[`require`,`exports`,`module`,`static/core/354bf8a9.js`,`static/core/25d26369.js`,`react`,`react-dom`,`react/jsx-runtime`,`antd`,`react-dom/client`,`@ant-design/icons`,`@ant-design/cssinjs`],function(e,t,n){let r=e("./354bf8a9.js"),i=e("./25d26369.js"),a=e("react");a=r.l(a,1),e("react-dom");let o=e("react/jsx-runtime"),s=e("antd");e("react-dom/client"),e("@ant-design/icons"),e("@ant-design/cssinjs");var c=({size:e=24,color:t=`currentColor`,...n})=>a.createElement(`svg`,{viewBox:`0 0 24 24`,width:e,height:e,stroke:t,strokeWidth:`2`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,...n},a.createElement(`path`,{d:`m14 10 7-7m0 0h-6m6 0v6m-11 5-7 7m0 0h6m-6 0v-6`}));c.displayName=`Expand01`;var l={root:`root`,controls:`controls`,segmentedControl:`segmentedControl`,sizeRow:`sizeRow`,sizeRowLabel:`sizeRowLabel`,sizeInputNumber:`sizeInputNumber`,sizeSuffix:`sizeSuffix`,colorGrid:`colorGrid`,colorCell:`colorCell`,colorCellLabel:`colorCellLabel`,colorPickerFull:`colorPickerFull`,bgExtras:`bgExtras`,bgWarning:`bgWarning`,previewSection:`previewSection`,previewTitle:`previewTitle`,previewWrap:`previewWrap`,scanLine:`scanLine`,scanLineBarcode:`scanLineBarcode`,previewWrapBarcode:`previewWrapBarcode`,previewCanvas:`previewCanvas`,previewCanvasBarcode:`previewCanvasBarcode`,actions:`actions`};t.default=({customRequest:t,state:n,setState:r})=>{let{t:u}=i.v(),{options:d}=i.S(),f=d?.config?.iconStrokeWidth??1.75,p=(0,a.useRef)(null),{mode:m,rawText:h,foregroundHex:g,backgroundHex:_,transparentBackground:v,qrSidePx:y,barcodeBarHeightPx:b}=n,x=(0,a.useCallback)(e=>r(t=>Object.assign(Object.assign({},t),{mode:e})),[r]),S=(0,a.useCallback)(e=>r(t=>Object.assign(Object.assign({},t),{rawText:e})),[r]),C=(0,a.useCallback)(e=>r(t=>Object.assign(Object.assign({},t),{foregroundHex:e})),[r]),w=(0,a.useCallback)(e=>r(t=>Object.assign(Object.assign({},t),{backgroundHex:e})),[r]),T=(0,a.useCallback)(e=>r(t=>Object.assign(Object.assign({},t),{transparentBackground:e})),[r]),E=(0,a.useCallback)(e=>r(t=>Object.assign(Object.assign({},t),{qrSidePx:e})),[r]),D=(0,a.useCallback)(e=>r(t=>Object.assign(Object.assign({},t),{barcodeBarHeightPx:e})),[r]),[O,k]=(0,a.useState)(h),[A,j]=(0,a.useState)(null),[M,N]=(0,a.useState)(!1),P=(0,a.useMemo)(()=>i.u.debounce(e=>k(e),300),[]);(0,a.useEffect)(()=>(P(h),()=>{P.cancel()}),[h,P]);let F=v?`#00000000`:_,I=(0,a.useCallback)(async(t,n)=>{let r=(await Promise.resolve().then(()=>e("./ca58f6cf.js")).then(function(e){return e.b})).default,i=n.trim(),a=Math.min(280,Math.max(80,y));if(!i){t.width=a,t.height=a;let e=t.getContext(`2d`);e&&e.clearRect(0,0,t.width,t.height);return}t.width=a,t.height=a,await r.toCanvas(t,i,{width:a,margin:2,color:{dark:g,light:F}})},[g,F,y]),L=(0,a.useCallback)(async(t,n)=>{let r=(await Promise.resolve().then(()=>e("./91634ef3.js")).then(function(e){return e.J})).default,i=n.trim(),a=v?`rgba(0,0,0,0)`:_,o=Math.min(72,Math.max(24,b)),s=Math.max(1,Math.round(o/42)),c=Math.max(4,Math.round(.07*o)),l=Math.max(10,Math.round(.15*o));if(!i){t.width=Math.round(4*o),t.height=Math.round(1.65*o);let e=t.getContext(`2d`);e&&e.clearRect(0,0,t.width,t.height);return}t.width=Math.round(4.2*o),t.height=Math.round(1.65*o),r(t,i,{format:`CODE128`,displayValue:!0,background:a,lineColor:g,margin:c,width:s,height:o,fontSize:l})},[g,_,v,b]);(0,a.useEffect)(()=>{let e=p.current;if(!e)return;let t=!1;return(async()=>{try{m===`qr`?await I(e,O):await L(e,O),t||j(null)}catch(n){let r=n instanceof Error?n.message:String(n);if(!t){j(m===`barcode`?u(`Barcode generation failed`):r);let t=e.getContext(`2d`);t&&t.clearRect(0,0,e.width,e.height)}}})(),()=>{t=!0}},[m,O,L,I,u]);let R=(0,a.useCallback)(async()=>{P.flush();let t=h.trim();if(!t)throw Error(u(`Enter text or URL to preview`));let n=typeof window>`u`?2:Math.min(3,Math.max(2,window.devicePixelRatio||2));if(m===`qr`){let r=Math.round(Math.min(600,Math.max(80,y))*n),i=document.createElement(`canvas`);i.width=r,i.height=r,await(await Promise.resolve().then(()=>e("./ca58f6cf.js")).then(function(e){return e.b})).default.toCanvas(i,t,{width:r,margin:2,color:{dark:g,light:F}});let a=await new Promise(e=>i.toBlob(e,`image/png`));if(!a)throw Error(`PNG export failed`);return a}let r=(await Promise.resolve().then(()=>e("./91634ef3.js")).then(function(e){return e.J})).default,i=document.createElement(`canvas`),a=v?`rgba(0,0,0,0)`:_,o=Math.min(130,Math.max(24,b)),s=Math.max(6,Math.round(.1*o)),c=Math.max(2,Math.round(o/36)),l=Math.max(12,Math.round(.16*o));r(i,t,{format:`CODE128`,displayValue:!0,background:a,lineColor:g,margin:Math.round(s*n),width:Math.round(c*n),height:Math.round(o*n),fontSize:Math.round(l*n)});let d=await new Promise(e=>i.toBlob(e,`image/png`));if(!d)throw Error(`PNG export failed`);return d},[m,h,g,F,_,v,y,b,P,u]),z=(0,a.useCallback)(async()=>{if(!M&&h.trim()){N(!0);try{let e;try{e=await R()}catch(e){j(e instanceof Error?e.message:String(e));return}let n=new File([e],`${m===`qr`?`qr-code`:`barcode`}-${Date.now()}.png`,{type:`image/png`,lastModified:Date.now()});await Promise.resolve(t({file:n}))}finally{N(!1)}}},[t,R,m,h,M]),B=!!h.trim()&&!A;return(0,o.jsx)(`div`,{className:l.root,children:(0,o.jsxs)(`div`,{className:l.controls,children:[(0,o.jsx)(s.Segmented,{block:!0,className:l.segmentedControl,value:m,onChange:e=>{x(e),j(null)},options:[{label:u(`QR code`),value:`qr`},{label:u(`Barcode`),value:`barcode`}]}),A&&(0,o.jsx)(s.Alert,{type:`error`,title:u(`Validation error`),description:A,showIcon:!0,closable:!0,onClose:()=>j(null)}),(0,o.jsx)(s.Input.TextArea,{value:h,onChange:e=>{S(e.target.value),j(null)},placeholder:u(`Text or URL`),rows:3,spellCheck:!1,autoComplete:`off`}),(0,o.jsxs)(`div`,{className:l.sizeRow,children:[(0,o.jsx)(s.Typography.Text,{type:`secondary`,className:l.sizeRowLabel,children:u(m===`qr`?`QR image size px`:`Barcode bar height px`)}),(0,o.jsx)(s.InputNumber,m===`qr`?{className:l.sizeInputNumber,min:80,max:600,step:8,value:y,onChange:e=>E(typeof e!=`number`||Number.isNaN(e)?200:e),prefix:(0,o.jsx)(c,{size:18,strokeWidth:f}),suffix:(0,o.jsx)(`span`,{className:l.sizeSuffix,children:`px`}),"aria-label":u(`QR image size px`)}:{className:l.sizeInputNumber,min:24,max:130,step:4,value:b,onChange:e=>D(typeof e!=`number`||Number.isNaN(e)?60:e),prefix:(0,o.jsx)(c,{size:18,strokeWidth:f}),suffix:(0,o.jsx)(`span`,{className:l.sizeSuffix,children:`px`}),"aria-label":u(`Barcode bar height px`)})]}),(0,o.jsxs)(`div`,{className:l.colorGrid,children:[(0,o.jsxs)(`div`,{className:l.colorCell,children:[(0,o.jsx)(s.Typography.Text,{type:`secondary`,className:l.colorCellLabel,children:u(`Code color`,`Code color`)}),(0,o.jsx)(s.ColorPicker,{className:l.colorPickerFull,value:g,format:`hex`,disabledAlpha:!0,showText:!0,onChange:(e,t)=>{C(typeof e==`string`?e:e?.toHexString?e.toHexString():t)}})]}),(0,o.jsxs)(`div`,{className:l.colorCell,children:[(0,o.jsx)(s.Typography.Text,{type:`secondary`,className:l.colorCellLabel,children:u(`Background color`,`Background color`)}),(0,o.jsx)(s.ColorPicker,{className:l.colorPickerFull,value:_,format:`hex`,disabledAlpha:!0,showText:!0,disabled:v,onChange:(e,t)=>{w(typeof e==`string`?e:e?.toHexString?e.toHexString():t)}})]}),(0,o.jsxs)(`div`,{className:l.bgExtras,children:[(0,o.jsx)(s.Checkbox,{checked:v,onChange:e=>T(e.target.checked),children:u(`Transparent background`,`Transparent background`)}),v&&(0,o.jsx)(s.Alert,{type:`warning`,showIcon:!0,title:u(`QR transparent background hint`),className:l.bgWarning})]})]}),(0,o.jsxs)(`div`,{className:l.previewSection,children:[(0,o.jsx)(s.Typography.Text,{className:l.previewTitle,children:u(`Preview`,`Preview`)}),(0,o.jsxs)(`div`,{className:[l.previewWrap,m===`barcode`&&l.previewWrapBarcode].filter(Boolean).join(` `),children:[(0,o.jsx)(`div`,{className:[l.scanLine,m===`barcode`&&l.scanLineBarcode].filter(Boolean).join(` `)}),(0,o.jsx)(`canvas`,{ref:p,className:[l.previewCanvas,m===`barcode`&&l.previewCanvasBarcode].filter(Boolean).join(` `),"aria-label":u(`Preview`)})]})]}),(0,o.jsx)(`div`,{className:l.actions,children:(0,o.jsx)(s.Button,{type:`primary`,onClick:()=>{z()},loading:M,disabled:!B,children:u(`Add to My files`)})})]})})}});
1
+ __emailmaker__.define(`static/core/fc5712ae.js`,[`require`,`exports`,`module`,`static/core/354bf8a9.js`,`static/core/7865066d.js`,`react`,`react-dom`,`react/jsx-runtime`,`antd`,`react-dom/client`,`@ant-design/icons`,`@ant-design/cssinjs`],function(e,t,n){let r=e("./354bf8a9.js"),i=e("./7865066d.js"),a=e("react");a=r.l(a,1),e("react-dom");let o=e("react/jsx-runtime"),s=e("antd");e("react-dom/client"),e("@ant-design/icons"),e("@ant-design/cssinjs");var c=({size:e=24,color:t=`currentColor`,...n})=>a.createElement(`svg`,{viewBox:`0 0 24 24`,width:e,height:e,stroke:t,strokeWidth:`2`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,...n},a.createElement(`path`,{d:`m14 10 7-7m0 0h-6m6 0v6m-11 5-7 7m0 0h6m-6 0v-6`}));c.displayName=`Expand01`;var l={root:`root`,controls:`controls`,segmentedControl:`segmentedControl`,sizeRow:`sizeRow`,sizeRowLabel:`sizeRowLabel`,sizeInputNumber:`sizeInputNumber`,sizeSuffix:`sizeSuffix`,colorGrid:`colorGrid`,colorCell:`colorCell`,colorCellLabel:`colorCellLabel`,colorPickerFull:`colorPickerFull`,bgExtras:`bgExtras`,bgWarning:`bgWarning`,previewSection:`previewSection`,previewTitle:`previewTitle`,previewWrap:`previewWrap`,scanLine:`scanLine`,scanLineBarcode:`scanLineBarcode`,previewWrapBarcode:`previewWrapBarcode`,previewCanvas:`previewCanvas`,previewCanvasBarcode:`previewCanvasBarcode`,actions:`actions`};t.default=({customRequest:t,state:n,setState:r})=>{let{t:u}=i.v(),{options:d}=i.S(),f=d?.config?.iconStrokeWidth??1.75,p=(0,a.useRef)(null),{mode:m,rawText:h,foregroundHex:g,backgroundHex:_,transparentBackground:v,qrSidePx:y,barcodeBarHeightPx:b}=n,x=(0,a.useCallback)(e=>r(t=>Object.assign(Object.assign({},t),{mode:e})),[r]),S=(0,a.useCallback)(e=>r(t=>Object.assign(Object.assign({},t),{rawText:e})),[r]),C=(0,a.useCallback)(e=>r(t=>Object.assign(Object.assign({},t),{foregroundHex:e})),[r]),w=(0,a.useCallback)(e=>r(t=>Object.assign(Object.assign({},t),{backgroundHex:e})),[r]),T=(0,a.useCallback)(e=>r(t=>Object.assign(Object.assign({},t),{transparentBackground:e})),[r]),E=(0,a.useCallback)(e=>r(t=>Object.assign(Object.assign({},t),{qrSidePx:e})),[r]),D=(0,a.useCallback)(e=>r(t=>Object.assign(Object.assign({},t),{barcodeBarHeightPx:e})),[r]),[O,k]=(0,a.useState)(h),[A,j]=(0,a.useState)(null),[M,N]=(0,a.useState)(!1),P=(0,a.useMemo)(()=>i.u.debounce(e=>k(e),300),[]);(0,a.useEffect)(()=>(P(h),()=>{P.cancel()}),[h,P]);let F=v?`#00000000`:_,I=(0,a.useCallback)(async(t,n)=>{let r=(await Promise.resolve().then(()=>e("./a73f6ffb.js")).then(function(e){return e.b})).default,i=n.trim(),a=Math.min(280,Math.max(80,y));if(!i){t.width=a,t.height=a;let e=t.getContext(`2d`);e&&e.clearRect(0,0,t.width,t.height);return}t.width=a,t.height=a,await r.toCanvas(t,i,{width:a,margin:2,color:{dark:g,light:F}})},[g,F,y]),L=(0,a.useCallback)(async(t,n)=>{let r=(await Promise.resolve().then(()=>e("./ba40f70e.js")).then(function(e){return e.J})).default,i=n.trim(),a=v?`rgba(0,0,0,0)`:_,o=Math.min(72,Math.max(24,b)),s=Math.max(1,Math.round(o/42)),c=Math.max(4,Math.round(.07*o)),l=Math.max(10,Math.round(.15*o));if(!i){t.width=Math.round(4*o),t.height=Math.round(1.65*o);let e=t.getContext(`2d`);e&&e.clearRect(0,0,t.width,t.height);return}t.width=Math.round(4.2*o),t.height=Math.round(1.65*o),r(t,i,{format:`CODE128`,displayValue:!0,background:a,lineColor:g,margin:c,width:s,height:o,fontSize:l})},[g,_,v,b]);(0,a.useEffect)(()=>{let e=p.current;if(!e)return;let t=!1;return(async()=>{try{m===`qr`?await I(e,O):await L(e,O),t||j(null)}catch(n){let r=n instanceof Error?n.message:String(n);if(!t){j(m===`barcode`?u(`Barcode generation failed`):r);let t=e.getContext(`2d`);t&&t.clearRect(0,0,e.width,e.height)}}})(),()=>{t=!0}},[m,O,L,I,u]);let R=(0,a.useCallback)(async()=>{P.flush();let t=h.trim();if(!t)throw Error(u(`Enter text or URL to preview`));let n=typeof window>`u`?2:Math.min(3,Math.max(2,window.devicePixelRatio||2));if(m===`qr`){let r=Math.round(Math.min(600,Math.max(80,y))*n),i=document.createElement(`canvas`);i.width=r,i.height=r,await(await Promise.resolve().then(()=>e("./a73f6ffb.js")).then(function(e){return e.b})).default.toCanvas(i,t,{width:r,margin:2,color:{dark:g,light:F}});let a=await new Promise(e=>i.toBlob(e,`image/png`));if(!a)throw Error(`PNG export failed`);return a}let r=(await Promise.resolve().then(()=>e("./ba40f70e.js")).then(function(e){return e.J})).default,i=document.createElement(`canvas`),a=v?`rgba(0,0,0,0)`:_,o=Math.min(130,Math.max(24,b)),s=Math.max(6,Math.round(.1*o)),c=Math.max(2,Math.round(o/36)),l=Math.max(12,Math.round(.16*o));r(i,t,{format:`CODE128`,displayValue:!0,background:a,lineColor:g,margin:Math.round(s*n),width:Math.round(c*n),height:Math.round(o*n),fontSize:Math.round(l*n)});let d=await new Promise(e=>i.toBlob(e,`image/png`));if(!d)throw Error(`PNG export failed`);return d},[m,h,g,F,_,v,y,b,P,u]),z=(0,a.useCallback)(async()=>{if(!M&&h.trim()){N(!0);try{let e;try{e=await R()}catch(e){j(e instanceof Error?e.message:String(e));return}let n=new File([e],`${m===`qr`?`qr-code`:`barcode`}-${Date.now()}.png`,{type:`image/png`,lastModified:Date.now()});await Promise.resolve(t({file:n}))}finally{N(!1)}}},[t,R,m,h,M]),B=!!h.trim()&&!A;return(0,o.jsx)(`div`,{className:l.root,children:(0,o.jsxs)(`div`,{className:l.controls,children:[(0,o.jsx)(s.Segmented,{block:!0,className:l.segmentedControl,value:m,onChange:e=>{x(e),j(null)},options:[{label:u(`QR code`),value:`qr`},{label:u(`Barcode`),value:`barcode`}]}),A&&(0,o.jsx)(s.Alert,{type:`error`,title:u(`Validation error`),description:A,showIcon:!0,closable:!0,onClose:()=>j(null)}),(0,o.jsx)(s.Input.TextArea,{value:h,onChange:e=>{S(e.target.value),j(null)},placeholder:u(`Text or URL`),rows:3,spellCheck:!1,autoComplete:`off`}),(0,o.jsxs)(`div`,{className:l.sizeRow,children:[(0,o.jsx)(s.Typography.Text,{type:`secondary`,className:l.sizeRowLabel,children:u(m===`qr`?`QR image size px`:`Barcode bar height px`)}),(0,o.jsx)(s.InputNumber,m===`qr`?{className:l.sizeInputNumber,min:80,max:600,step:8,value:y,onChange:e=>E(typeof e!=`number`||Number.isNaN(e)?200:e),prefix:(0,o.jsx)(c,{size:18,strokeWidth:f}),suffix:(0,o.jsx)(`span`,{className:l.sizeSuffix,children:`px`}),"aria-label":u(`QR image size px`)}:{className:l.sizeInputNumber,min:24,max:130,step:4,value:b,onChange:e=>D(typeof e!=`number`||Number.isNaN(e)?60:e),prefix:(0,o.jsx)(c,{size:18,strokeWidth:f}),suffix:(0,o.jsx)(`span`,{className:l.sizeSuffix,children:`px`}),"aria-label":u(`Barcode bar height px`)})]}),(0,o.jsxs)(`div`,{className:l.colorGrid,children:[(0,o.jsxs)(`div`,{className:l.colorCell,children:[(0,o.jsx)(s.Typography.Text,{type:`secondary`,className:l.colorCellLabel,children:u(`Code color`,`Code color`)}),(0,o.jsx)(s.ColorPicker,{className:l.colorPickerFull,value:g,format:`hex`,disabledAlpha:!0,showText:!0,onChange:(e,t)=>{C(typeof e==`string`?e:e?.toHexString?e.toHexString():t)}})]}),(0,o.jsxs)(`div`,{className:l.colorCell,children:[(0,o.jsx)(s.Typography.Text,{type:`secondary`,className:l.colorCellLabel,children:u(`Background color`,`Background color`)}),(0,o.jsx)(s.ColorPicker,{className:l.colorPickerFull,value:_,format:`hex`,disabledAlpha:!0,showText:!0,disabled:v,onChange:(e,t)=>{w(typeof e==`string`?e:e?.toHexString?e.toHexString():t)}})]}),(0,o.jsxs)(`div`,{className:l.bgExtras,children:[(0,o.jsx)(s.Checkbox,{checked:v,onChange:e=>T(e.target.checked),children:u(`Transparent background`,`Transparent background`)}),v&&(0,o.jsx)(s.Alert,{type:`warning`,showIcon:!0,title:u(`QR transparent background hint`),className:l.bgWarning})]})]}),(0,o.jsxs)(`div`,{className:l.previewSection,children:[(0,o.jsx)(s.Typography.Text,{className:l.previewTitle,children:u(`Preview`,`Preview`)}),(0,o.jsxs)(`div`,{className:[l.previewWrap,m===`barcode`&&l.previewWrapBarcode].filter(Boolean).join(` `),children:[(0,o.jsx)(`div`,{className:[l.scanLine,m===`barcode`&&l.scanLineBarcode].filter(Boolean).join(` `)}),(0,o.jsx)(`canvas`,{ref:p,className:[l.previewCanvas,m===`barcode`&&l.previewCanvasBarcode].filter(Boolean).join(` `),"aria-label":u(`Preview`)})]})]}),(0,o.jsx)(`div`,{className:l.actions,children:(0,o.jsx)(s.Button,{type:`primary`,onClick:()=>{z()},loading:M,disabled:!B,children:u(`Add to My files`)})})]})})}});
@@ -0,0 +1 @@
1
+ function e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)r!==`__proto__`&&(e[r]=n[r])}return e}var t={read:function(e){return e[0]===`"`&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function n(t,r){function i(n,i,a){if(!(typeof document>`u`)){a=e({},r,a),typeof a.expires==`number`&&(a.expires=new Date(Date.now()+a.expires*864e5)),a.expires&&=a.expires.toUTCString(),n=encodeURIComponent(n).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var o=``;for(var s in a)a[s]&&(o+=`; `+s,a[s]!==!0&&(o+=`=`+a[s].split(`;`)[0]));return document.cookie=n+`=`+t.write(i,n)+o}}function a(e){if(!(typeof document>`u`||arguments.length&&!e)){for(var n=document.cookie?document.cookie.split(`; `):[],r={},i=0;i<n.length;i++){var a=n[i].split(`=`),o=a.slice(1).join(`=`);try{var s=decodeURIComponent(a[0]);if(s in r||(r[s]=t.read(o,s)),e===s)break}catch{}}return e?r[e]:r}}return Object.create({set:i,get:a,remove:function(t,n){i(t,``,e({},n,{expires:-1}))},withAttributes:function(t){return n(this.converter,e({},this.attributes,t))},withConverter:function(t){return n(e({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(r)},converter:{value:Object.freeze(t)}})}var r=n(t,{path:`/`});export{r as t};
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
5
  <title>Two-step flow: design → subject/preheader (headless)</title>
6
- <script id="plugin-script" type="text/javascript" src="emailmaker.js?25e2342b"></script>
6
+ <script id="plugin-script" type="text/javascript" src="emailmaker.js?4a2946bd"></script>
7
7
  <style>
8
8
  body {
9
9
  margin: 0;
package/vite/index.cjs CHANGED
@@ -31,6 +31,7 @@ fs = __toESM(fs);
31
31
  let os = require("os");
32
32
  os = __toESM(os);
33
33
  let fs_promises = require("fs/promises");
34
+ let module$1 = require("module");
34
35
  //#region src/vite/mime-types.ts
35
36
  /**
36
37
  * Нам не нужен огромный универсальный справочник MIME:
@@ -104,6 +105,11 @@ async function copyFolder(src, dest, filter) {
104
105
  * (`/product` -> `/product/`, resolved against the host `document.baseURI`).
105
106
  * - With `publicPath`: `http://host:3032` + `/product` -> `http://host:3032/product/`.
106
107
  */
108
+ function normalizeHostBundlerPublicPath(publicPath) {
109
+ const value = String(publicPath ?? "").trim();
110
+ if (!value || value === "auto" || value === "automatic") return "";
111
+ return value;
112
+ }
107
113
  function joinHostPublicPath(publicPath, outputFolder, defaultOutputFolder) {
108
114
  const folder = outputFolder != null && outputFolder !== "" ? String(outputFolder) : defaultOutputFolder;
109
115
  const base = String(publicPath || "").replace(/\/+$/, "");
@@ -146,12 +152,29 @@ function createInitFragment$1(environmentVariable, publicPath, startupPrefetchMo
146
152
  `if (!window.${environmentVariable}.startupPrefetchMode) window.${environmentVariable}.startupPrefetchMode = "${startupPrefetchMode}";`
147
153
  ].join(" ");
148
154
  }
155
+ function moduleSourceContainsFacadeSentinel(source) {
156
+ return typeof source === "string" && source.includes("@shared-runtime:init-complete");
157
+ }
158
+ /**
159
+ * True when host bootstrap was already prepended (avoid double injection).
160
+ *
161
+ * Must match the host-plugin assignment shape from `createInitFragment` /
162
+ * `createNormalizedPublicPathAssignment`, NOT a bare `window.__ns__.publicPath`
163
+ * substring — publish diagnostics embed that substring inside string literals and
164
+ * would otherwise false-positive and block all host injection.
165
+ */
166
+ function moduleSourceHasHostPublicPathBootstrap(source, environmentVariable) {
167
+ if (typeof source !== "string" || !source) return false;
168
+ return source.includes(`if (!window.${environmentVariable}.publicPath) window.${environmentVariable}.publicPath =`);
169
+ }
149
170
  //#endregion
150
171
  //#region src/shared/hostPackageEntryMatch.ts
151
172
  /**
152
173
  * Match main product entry modules for host bootstrap injection (Vite + Webpack).
153
174
  * Uses suffix matching so absolute node_modules ids ending with `{packagePath}/{appName}-esm.js`
154
175
  * match the same way as Webpack `renderModuleContent` (endsWith), not exact relative paths.
176
+ * When path matching fails (alias, wrapper re-export), falls back to publish facade sentinel
177
+ * in module source (`@shared-runtime:init-complete`).
155
178
  */
156
179
  function normalizeHostModulePath(value) {
157
180
  return String(value || "").replace(/#.*$/s, "").replace(/\?.*$/s, "").replace(/\\/g, "/");
@@ -173,6 +196,60 @@ function shouldMatchProductPackageEntry(moduleId, packagePath, appName, optimize
173
196
  }
174
197
  return false;
175
198
  }
199
+ function shouldPatchProductEntry(options) {
200
+ const { moduleId, source, packagePath, appName, optimizedDepFileName, environmentVariable } = options;
201
+ if (environmentVariable && moduleSourceHasHostPublicPathBootstrap(source, environmentVariable)) return false;
202
+ if (shouldMatchProductPackageEntry(moduleId, packagePath, appName, optimizedDepFileName)) return true;
203
+ return moduleSourceContainsFacadeSentinel(source);
204
+ }
205
+ //#endregion
206
+ //#region src/shared/resolvePublishedPackage.ts
207
+ /**
208
+ * Resolve the on-disk root of the published main package (handles pnpm hoisting / symlinks).
209
+ * Prefers `modulesPath/<packagePath>` under `cwd` when `package.json` exists there.
210
+ */
211
+ function resolvePublishedPackageRoot(packagePath, modulesPath = "node_modules", cwd = process.cwd()) {
212
+ const modulesRoot = path.default.isAbsolute(modulesPath) ? modulesPath : path.default.join(cwd, modulesPath);
213
+ const localRoot = path.default.join(modulesRoot, ...packagePath.split("/"));
214
+ const localPackageJson = path.default.join(localRoot, "package.json");
215
+ if (fs.default.existsSync(localPackageJson)) return localRoot;
216
+ try {
217
+ const packageJsonPath = (0, module$1.createRequire)(path.default.join(cwd, "package.json")).resolve(`${packagePath}/package.json`);
218
+ return path.default.dirname(packageJsonPath);
219
+ } catch {
220
+ return localRoot;
221
+ }
222
+ }
223
+ var PublishedPackageNotFoundError = class extends Error {
224
+ constructor(packagePath, resolvedPath) {
225
+ super(`[host-plugin] Published package "${packagePath}" was not found at "${resolvedPath}". Install the product npm package or set \`modulesPath\` to the directory that contains it.`);
226
+ this.packagePath = packagePath;
227
+ this.resolvedPath = resolvedPath;
228
+ this.name = "PublishedPackageNotFoundError";
229
+ }
230
+ };
231
+ function assertPublishedPackageExists(packageRoot, packagePath) {
232
+ if (!fs.default.existsSync(packageRoot) || !fs.default.statSync(packageRoot).isDirectory()) throw new PublishedPackageNotFoundError(packagePath, packageRoot);
233
+ }
234
+ /**
235
+ * After copying static assets, verify at least one core chunk is present.
236
+ */
237
+ function assertCoreChunkCopied(outputDir, appName) {
238
+ if (!fs.default.existsSync(outputDir)) throw new Error(`[host-plugin] Output folder "${outputDir}" is missing after copy. Expected "${appName}-core.*.js" under the configured outputFolder.`);
239
+ if (!findCoreChunk(outputDir, new RegExp(`^${appName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}-core\\.[^/\\\\]+\\.js$`))) throw new Error(`[host-plugin] No "${appName}-core.*.js" found under "${outputDir}" after copy. The published package may be incomplete or IGNORED_PATTERNS filtered the core chunk.`);
240
+ }
241
+ function findCoreChunk(dir, corePattern) {
242
+ const entries = fs.default.readdirSync(dir, { withFileTypes: true });
243
+ for (const entry of entries) {
244
+ const fullPath = path.default.join(dir, entry.name);
245
+ if (entry.isDirectory()) {
246
+ if (findCoreChunk(fullPath, corePattern)) return true;
247
+ continue;
248
+ }
249
+ if (corePattern.test(entry.name)) return true;
250
+ }
251
+ return false;
252
+ }
176
253
  //#endregion
177
254
  //#region src/shared/branding.ts
178
255
  /**
@@ -439,8 +516,15 @@ function createBootstrapPrefix(publicPath, startupPrefetchMode) {
439
516
  function prependBootstrap(code, publicPath, startupPrefetchMode) {
440
517
  return `${createBootstrapPrefix(publicPath, startupPrefetchMode)}${code}`;
441
518
  }
442
- function shouldPatchPackageEntry(id, optimizedFileName) {
443
- return shouldMatchProductPackageEntry(id, BUNDLER_DEFAULT_PACKAGE_NAME, BUNDLER_DEFAULT_APP_NAME, optimizedFileName || getFlattenedOptimizedDepFileName());
519
+ function shouldPatchPackageEntry(id, code, optimizedFileName) {
520
+ return shouldPatchProductEntry({
521
+ moduleId: id,
522
+ source: code,
523
+ packagePath: BUNDLER_DEFAULT_PACKAGE_NAME,
524
+ appName: BUNDLER_DEFAULT_APP_NAME,
525
+ optimizedDepFileName: optimizedFileName || getFlattenedOptimizedDepFileName(),
526
+ environmentVariable: ENVIRONMENT_VARIABLE
527
+ });
444
528
  }
445
529
  function getFlattenedOptimizedDepFileName() {
446
530
  return `${BUNDLER_DEFAULT_PACKAGE_NAME.replace(/[\\/]/g, "_")}.js`;
@@ -457,18 +541,21 @@ function readOptimizedDepFileName(depsMetadataPath) {
457
541
  }
458
542
  }
459
543
  var ViteServePlugin = (options) => {
460
- const rootPath = process.cwd();
461
544
  const mountSeg = outputFolderFsSegment(options.outputFolder, BUNDLER_DEFAULT_APP_NAME);
462
- const destPath = path.default.normalize(path.default.join(rootPath, mountSeg));
463
- const packageRoot = path.default.join(options.modulesPath || DEFAULT_MODULES_PATH, BUNDLER_DEFAULT_PACKAGE_NAME);
464
- const publicPath = joinHostPublicPath(options.publicPath, options.outputFolder, DEFAULT_OUTPUT_FOLDER);
545
+ const publicPath = joinHostPublicPath(normalizeHostBundlerPublicPath(options.publicPath), options.outputFolder, DEFAULT_OUTPUT_FOLDER);
465
546
  const startupPrefetchMode = options.startupPrefetchMode || DEFAULT_STARTUP_PREFETCH_MODE;
547
+ let projectRoot = process.cwd();
548
+ let destPath = path.default.normalize(path.default.join(projectRoot, mountSeg));
549
+ let packageRoot = resolvePublishedPackageRoot(BUNDLER_DEFAULT_PACKAGE_NAME, options.modulesPath || DEFAULT_MODULES_PATH, projectRoot);
466
550
  let optimizedFacadeFile = getFlattenedOptimizedDepFileName();
467
551
  return {
468
552
  name: `${PLUGIN_NAME}-serve`,
469
553
  enforce: "pre",
470
554
  apply: "serve",
471
555
  configResolved(config) {
556
+ projectRoot = config.root;
557
+ destPath = path.default.normalize(path.default.join(projectRoot, mountSeg));
558
+ packageRoot = resolvePublishedPackageRoot(BUNDLER_DEFAULT_PACKAGE_NAME, options.modulesPath || DEFAULT_MODULES_PATH, projectRoot);
472
559
  optimizedFacadeFile = readOptimizedDepFileName(path.default.join(config.cacheDir, "deps", "_metadata.json"));
473
560
  /**
474
561
  * Эвристика: предупредить integrator'а если main package был обновлён
@@ -496,7 +583,7 @@ var ViteServePlugin = (options) => {
496
583
  });
497
584
  },
498
585
  transform(code, id) {
499
- if (!shouldPatchPackageEntry(id, optimizedFacadeFile)) return code;
586
+ if (!shouldPatchPackageEntry(id, code, optimizedFacadeFile)) return code;
500
587
  return prependBootstrap(code, publicPath, startupPrefetchMode);
501
588
  },
502
589
  configureServer: (server) => {
@@ -571,7 +658,7 @@ var ViteServePlugin = (options) => {
571
658
  return;
572
659
  }
573
660
  }
574
- if (shouldMatchProductPackageEntry(pathname, "@emailmaker/emailmaker", "emailmaker", optimizedFacadeFile)) {
661
+ if (shouldPatchPackageEntry(pathname, void 0, optimizedFacadeFile)) {
575
662
  const optimizedFilePath = path.default.join(server.config.cacheDir, "deps", optimizedFacadeFile);
576
663
  if (fs.default.existsSync(optimizedFilePath) && fs.default.statSync(optimizedFilePath).isFile()) {
577
664
  const content = await fs.default.promises.readFile(optimizedFilePath, "utf-8");
@@ -580,7 +667,7 @@ var ViteServePlugin = (options) => {
580
667
  return;
581
668
  }
582
669
  }
583
- const absReqPath = path.default.normalize(path.default.join(rootPath, ...pathname.split("/").filter(Boolean)));
670
+ const absReqPath = path.default.normalize(path.default.join(projectRoot, ...pathname.split("/").filter(Boolean)));
584
671
  const normDest = path.default.normalize(destPath);
585
672
  if (absReqPath === normDest || absReqPath.startsWith(normDest + path.default.sep)) {
586
673
  const rel = path.default.relative(normDest, absReqPath);
@@ -588,7 +675,7 @@ var ViteServePlugin = (options) => {
588
675
  next();
589
676
  return;
590
677
  }
591
- const sourcePath = path.default.join(options.modulesPath || DEFAULT_MODULES_PATH, BUNDLER_DEFAULT_PACKAGE_NAME, rel);
678
+ const sourcePath = path.default.join(packageRoot, rel);
592
679
  if (!IGNORED_PATTERNS.some((pattern) => pattern.test(sourcePath)) && fs.default.existsSync(sourcePath)) {
593
680
  await sendContentByFilePath(sourcePath);
594
681
  return;
@@ -604,16 +691,15 @@ var ViteServePlugin = (options) => {
604
691
  };
605
692
  };
606
693
  var ViteBuildPlugin = (options) => {
607
- const sourcePath = path.default.join(options.modulesPath || DEFAULT_MODULES_PATH, BUNDLER_DEFAULT_PACKAGE_NAME);
608
694
  let resolvedConfig;
609
- const normalizedPublicPath = joinHostPublicPath(options.publicPath, options.outputFolder, DEFAULT_OUTPUT_FOLDER);
695
+ const normalizedPublicPath = joinHostPublicPath(normalizeHostBundlerPublicPath(options.publicPath), options.outputFolder, DEFAULT_OUTPUT_FOLDER);
610
696
  const startupPrefetchMode = options.startupPrefetchMode || DEFAULT_STARTUP_PREFETCH_MODE;
611
697
  return {
612
698
  name: `${PLUGIN_NAME}-build`,
613
699
  enforce: "pre",
614
700
  apply: "build",
615
701
  transform(code, id) {
616
- if (!shouldPatchPackageEntry(id)) return code;
702
+ if (!shouldPatchPackageEntry(id, code)) return code;
617
703
  return prependBootstrap(code, normalizedPublicPath, startupPrefetchMode);
618
704
  },
619
705
  configResolved(config) {
@@ -621,13 +707,18 @@ var ViteBuildPlugin = (options) => {
621
707
  },
622
708
  async closeBundle() {
623
709
  if (!resolvedConfig) return;
624
- const outDir = path.default.join(resolvedConfig.root, resolvedConfig.build.outDir);
710
+ const projectRoot = resolvedConfig.root;
711
+ const packageRoot = resolvePublishedPackageRoot(BUNDLER_DEFAULT_PACKAGE_NAME, options.modulesPath || DEFAULT_MODULES_PATH, projectRoot);
712
+ const outDir = path.default.join(projectRoot, resolvedConfig.build.outDir);
625
713
  const outSeg = outputFolderFsSegment(options.outputFolder, BUNDLER_DEFAULT_APP_NAME);
626
714
  const destPath = path.default.join(outDir, outSeg);
627
- if (!fs.default.existsSync(sourcePath)) return;
628
- if ((await fs.default.promises.stat(sourcePath)).isDirectory()) await copyFolder(sourcePath, destPath, (sp) => {
629
- return !IGNORED_PATTERNS.some((pattern) => pattern.test(sp));
630
- });
715
+ assertPublishedPackageExists(packageRoot, BUNDLER_DEFAULT_PACKAGE_NAME);
716
+ if ((await fs.default.promises.stat(packageRoot)).isDirectory()) {
717
+ await copyFolder(packageRoot, destPath, (sp) => {
718
+ return !IGNORED_PATTERNS.some((pattern) => pattern.test(sp));
719
+ });
720
+ assertCoreChunkCopied(destPath, BUNDLER_DEFAULT_APP_NAME);
721
+ }
631
722
  }
632
723
  };
633
724
  };
package/vite/index.js CHANGED
@@ -2,6 +2,7 @@ import path from "path";
2
2
  import fs from "fs";
3
3
  import os from "os";
4
4
  import { copyFile, mkdir, readdir, stat } from "fs/promises";
5
+ import { createRequire } from "module";
5
6
  //#region src/vite/mime-types.ts
6
7
  /**
7
8
  * Нам не нужен огромный универсальный справочник MIME:
@@ -75,6 +76,11 @@ async function copyFolder(src, dest, filter) {
75
76
  * (`/product` -> `/product/`, resolved against the host `document.baseURI`).
76
77
  * - With `publicPath`: `http://host:3032` + `/product` -> `http://host:3032/product/`.
77
78
  */
79
+ function normalizeHostBundlerPublicPath(publicPath) {
80
+ const value = String(publicPath ?? "").trim();
81
+ if (!value || value === "auto" || value === "automatic") return "";
82
+ return value;
83
+ }
78
84
  function joinHostPublicPath(publicPath, outputFolder, defaultOutputFolder) {
79
85
  const folder = outputFolder != null && outputFolder !== "" ? String(outputFolder) : defaultOutputFolder;
80
86
  const base = String(publicPath || "").replace(/\/+$/, "");
@@ -117,12 +123,29 @@ function createInitFragment$1(environmentVariable, publicPath, startupPrefetchMo
117
123
  `if (!window.${environmentVariable}.startupPrefetchMode) window.${environmentVariable}.startupPrefetchMode = "${startupPrefetchMode}";`
118
124
  ].join(" ");
119
125
  }
126
+ function moduleSourceContainsFacadeSentinel(source) {
127
+ return typeof source === "string" && source.includes("@shared-runtime:init-complete");
128
+ }
129
+ /**
130
+ * True when host bootstrap was already prepended (avoid double injection).
131
+ *
132
+ * Must match the host-plugin assignment shape from `createInitFragment` /
133
+ * `createNormalizedPublicPathAssignment`, NOT a bare `window.__ns__.publicPath`
134
+ * substring — publish diagnostics embed that substring inside string literals and
135
+ * would otherwise false-positive and block all host injection.
136
+ */
137
+ function moduleSourceHasHostPublicPathBootstrap(source, environmentVariable) {
138
+ if (typeof source !== "string" || !source) return false;
139
+ return source.includes(`if (!window.${environmentVariable}.publicPath) window.${environmentVariable}.publicPath =`);
140
+ }
120
141
  //#endregion
121
142
  //#region src/shared/hostPackageEntryMatch.ts
122
143
  /**
123
144
  * Match main product entry modules for host bootstrap injection (Vite + Webpack).
124
145
  * Uses suffix matching so absolute node_modules ids ending with `{packagePath}/{appName}-esm.js`
125
146
  * match the same way as Webpack `renderModuleContent` (endsWith), not exact relative paths.
147
+ * When path matching fails (alias, wrapper re-export), falls back to publish facade sentinel
148
+ * in module source (`@shared-runtime:init-complete`).
126
149
  */
127
150
  function normalizeHostModulePath(value) {
128
151
  return String(value || "").replace(/#.*$/s, "").replace(/\?.*$/s, "").replace(/\\/g, "/");
@@ -144,6 +167,60 @@ function shouldMatchProductPackageEntry(moduleId, packagePath, appName, optimize
144
167
  }
145
168
  return false;
146
169
  }
170
+ function shouldPatchProductEntry(options) {
171
+ const { moduleId, source, packagePath, appName, optimizedDepFileName, environmentVariable } = options;
172
+ if (environmentVariable && moduleSourceHasHostPublicPathBootstrap(source, environmentVariable)) return false;
173
+ if (shouldMatchProductPackageEntry(moduleId, packagePath, appName, optimizedDepFileName)) return true;
174
+ return moduleSourceContainsFacadeSentinel(source);
175
+ }
176
+ //#endregion
177
+ //#region src/shared/resolvePublishedPackage.ts
178
+ /**
179
+ * Resolve the on-disk root of the published main package (handles pnpm hoisting / symlinks).
180
+ * Prefers `modulesPath/<packagePath>` under `cwd` when `package.json` exists there.
181
+ */
182
+ function resolvePublishedPackageRoot(packagePath, modulesPath = "node_modules", cwd = process.cwd()) {
183
+ const modulesRoot = path.isAbsolute(modulesPath) ? modulesPath : path.join(cwd, modulesPath);
184
+ const localRoot = path.join(modulesRoot, ...packagePath.split("/"));
185
+ const localPackageJson = path.join(localRoot, "package.json");
186
+ if (fs.existsSync(localPackageJson)) return localRoot;
187
+ try {
188
+ const packageJsonPath = createRequire(path.join(cwd, "package.json")).resolve(`${packagePath}/package.json`);
189
+ return path.dirname(packageJsonPath);
190
+ } catch {
191
+ return localRoot;
192
+ }
193
+ }
194
+ var PublishedPackageNotFoundError = class extends Error {
195
+ constructor(packagePath, resolvedPath) {
196
+ super(`[host-plugin] Published package "${packagePath}" was not found at "${resolvedPath}". Install the product npm package or set \`modulesPath\` to the directory that contains it.`);
197
+ this.packagePath = packagePath;
198
+ this.resolvedPath = resolvedPath;
199
+ this.name = "PublishedPackageNotFoundError";
200
+ }
201
+ };
202
+ function assertPublishedPackageExists(packageRoot, packagePath) {
203
+ if (!fs.existsSync(packageRoot) || !fs.statSync(packageRoot).isDirectory()) throw new PublishedPackageNotFoundError(packagePath, packageRoot);
204
+ }
205
+ /**
206
+ * After copying static assets, verify at least one core chunk is present.
207
+ */
208
+ function assertCoreChunkCopied(outputDir, appName) {
209
+ if (!fs.existsSync(outputDir)) throw new Error(`[host-plugin] Output folder "${outputDir}" is missing after copy. Expected "${appName}-core.*.js" under the configured outputFolder.`);
210
+ if (!findCoreChunk(outputDir, new RegExp(`^${appName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}-core\\.[^/\\\\]+\\.js$`))) throw new Error(`[host-plugin] No "${appName}-core.*.js" found under "${outputDir}" after copy. The published package may be incomplete or IGNORED_PATTERNS filtered the core chunk.`);
211
+ }
212
+ function findCoreChunk(dir, corePattern) {
213
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
214
+ for (const entry of entries) {
215
+ const fullPath = path.join(dir, entry.name);
216
+ if (entry.isDirectory()) {
217
+ if (findCoreChunk(fullPath, corePattern)) return true;
218
+ continue;
219
+ }
220
+ if (corePattern.test(entry.name)) return true;
221
+ }
222
+ return false;
223
+ }
147
224
  //#endregion
148
225
  //#region src/shared/branding.ts
149
226
  /**
@@ -410,8 +487,15 @@ function createBootstrapPrefix(publicPath, startupPrefetchMode) {
410
487
  function prependBootstrap(code, publicPath, startupPrefetchMode) {
411
488
  return `${createBootstrapPrefix(publicPath, startupPrefetchMode)}${code}`;
412
489
  }
413
- function shouldPatchPackageEntry(id, optimizedFileName) {
414
- return shouldMatchProductPackageEntry(id, BUNDLER_DEFAULT_PACKAGE_NAME, BUNDLER_DEFAULT_APP_NAME, optimizedFileName || getFlattenedOptimizedDepFileName());
490
+ function shouldPatchPackageEntry(id, code, optimizedFileName) {
491
+ return shouldPatchProductEntry({
492
+ moduleId: id,
493
+ source: code,
494
+ packagePath: BUNDLER_DEFAULT_PACKAGE_NAME,
495
+ appName: BUNDLER_DEFAULT_APP_NAME,
496
+ optimizedDepFileName: optimizedFileName || getFlattenedOptimizedDepFileName(),
497
+ environmentVariable: ENVIRONMENT_VARIABLE
498
+ });
415
499
  }
416
500
  function getFlattenedOptimizedDepFileName() {
417
501
  return `${BUNDLER_DEFAULT_PACKAGE_NAME.replace(/[\\/]/g, "_")}.js`;
@@ -428,18 +512,21 @@ function readOptimizedDepFileName(depsMetadataPath) {
428
512
  }
429
513
  }
430
514
  var ViteServePlugin = (options) => {
431
- const rootPath = process.cwd();
432
515
  const mountSeg = outputFolderFsSegment(options.outputFolder, BUNDLER_DEFAULT_APP_NAME);
433
- const destPath = path.normalize(path.join(rootPath, mountSeg));
434
- const packageRoot = path.join(options.modulesPath || DEFAULT_MODULES_PATH, BUNDLER_DEFAULT_PACKAGE_NAME);
435
- const publicPath = joinHostPublicPath(options.publicPath, options.outputFolder, DEFAULT_OUTPUT_FOLDER);
516
+ const publicPath = joinHostPublicPath(normalizeHostBundlerPublicPath(options.publicPath), options.outputFolder, DEFAULT_OUTPUT_FOLDER);
436
517
  const startupPrefetchMode = options.startupPrefetchMode || DEFAULT_STARTUP_PREFETCH_MODE;
518
+ let projectRoot = process.cwd();
519
+ let destPath = path.normalize(path.join(projectRoot, mountSeg));
520
+ let packageRoot = resolvePublishedPackageRoot(BUNDLER_DEFAULT_PACKAGE_NAME, options.modulesPath || DEFAULT_MODULES_PATH, projectRoot);
437
521
  let optimizedFacadeFile = getFlattenedOptimizedDepFileName();
438
522
  return {
439
523
  name: `${PLUGIN_NAME}-serve`,
440
524
  enforce: "pre",
441
525
  apply: "serve",
442
526
  configResolved(config) {
527
+ projectRoot = config.root;
528
+ destPath = path.normalize(path.join(projectRoot, mountSeg));
529
+ packageRoot = resolvePublishedPackageRoot(BUNDLER_DEFAULT_PACKAGE_NAME, options.modulesPath || DEFAULT_MODULES_PATH, projectRoot);
443
530
  optimizedFacadeFile = readOptimizedDepFileName(path.join(config.cacheDir, "deps", "_metadata.json"));
444
531
  /**
445
532
  * Эвристика: предупредить integrator'а если main package был обновлён
@@ -467,7 +554,7 @@ var ViteServePlugin = (options) => {
467
554
  });
468
555
  },
469
556
  transform(code, id) {
470
- if (!shouldPatchPackageEntry(id, optimizedFacadeFile)) return code;
557
+ if (!shouldPatchPackageEntry(id, code, optimizedFacadeFile)) return code;
471
558
  return prependBootstrap(code, publicPath, startupPrefetchMode);
472
559
  },
473
560
  configureServer: (server) => {
@@ -542,7 +629,7 @@ var ViteServePlugin = (options) => {
542
629
  return;
543
630
  }
544
631
  }
545
- if (shouldMatchProductPackageEntry(pathname, "@emailmaker/emailmaker", "emailmaker", optimizedFacadeFile)) {
632
+ if (shouldPatchPackageEntry(pathname, void 0, optimizedFacadeFile)) {
546
633
  const optimizedFilePath = path.join(server.config.cacheDir, "deps", optimizedFacadeFile);
547
634
  if (fs.existsSync(optimizedFilePath) && fs.statSync(optimizedFilePath).isFile()) {
548
635
  const content = await fs.promises.readFile(optimizedFilePath, "utf-8");
@@ -551,7 +638,7 @@ var ViteServePlugin = (options) => {
551
638
  return;
552
639
  }
553
640
  }
554
- const absReqPath = path.normalize(path.join(rootPath, ...pathname.split("/").filter(Boolean)));
641
+ const absReqPath = path.normalize(path.join(projectRoot, ...pathname.split("/").filter(Boolean)));
555
642
  const normDest = path.normalize(destPath);
556
643
  if (absReqPath === normDest || absReqPath.startsWith(normDest + path.sep)) {
557
644
  const rel = path.relative(normDest, absReqPath);
@@ -559,7 +646,7 @@ var ViteServePlugin = (options) => {
559
646
  next();
560
647
  return;
561
648
  }
562
- const sourcePath = path.join(options.modulesPath || DEFAULT_MODULES_PATH, BUNDLER_DEFAULT_PACKAGE_NAME, rel);
649
+ const sourcePath = path.join(packageRoot, rel);
563
650
  if (!IGNORED_PATTERNS.some((pattern) => pattern.test(sourcePath)) && fs.existsSync(sourcePath)) {
564
651
  await sendContentByFilePath(sourcePath);
565
652
  return;
@@ -575,16 +662,15 @@ var ViteServePlugin = (options) => {
575
662
  };
576
663
  };
577
664
  var ViteBuildPlugin = (options) => {
578
- const sourcePath = path.join(options.modulesPath || DEFAULT_MODULES_PATH, BUNDLER_DEFAULT_PACKAGE_NAME);
579
665
  let resolvedConfig;
580
- const normalizedPublicPath = joinHostPublicPath(options.publicPath, options.outputFolder, DEFAULT_OUTPUT_FOLDER);
666
+ const normalizedPublicPath = joinHostPublicPath(normalizeHostBundlerPublicPath(options.publicPath), options.outputFolder, DEFAULT_OUTPUT_FOLDER);
581
667
  const startupPrefetchMode = options.startupPrefetchMode || DEFAULT_STARTUP_PREFETCH_MODE;
582
668
  return {
583
669
  name: `${PLUGIN_NAME}-build`,
584
670
  enforce: "pre",
585
671
  apply: "build",
586
672
  transform(code, id) {
587
- if (!shouldPatchPackageEntry(id)) return code;
673
+ if (!shouldPatchPackageEntry(id, code)) return code;
588
674
  return prependBootstrap(code, normalizedPublicPath, startupPrefetchMode);
589
675
  },
590
676
  configResolved(config) {
@@ -592,13 +678,18 @@ var ViteBuildPlugin = (options) => {
592
678
  },
593
679
  async closeBundle() {
594
680
  if (!resolvedConfig) return;
595
- const outDir = path.join(resolvedConfig.root, resolvedConfig.build.outDir);
681
+ const projectRoot = resolvedConfig.root;
682
+ const packageRoot = resolvePublishedPackageRoot(BUNDLER_DEFAULT_PACKAGE_NAME, options.modulesPath || DEFAULT_MODULES_PATH, projectRoot);
683
+ const outDir = path.join(projectRoot, resolvedConfig.build.outDir);
596
684
  const outSeg = outputFolderFsSegment(options.outputFolder, BUNDLER_DEFAULT_APP_NAME);
597
685
  const destPath = path.join(outDir, outSeg);
598
- if (!fs.existsSync(sourcePath)) return;
599
- if ((await fs.promises.stat(sourcePath)).isDirectory()) await copyFolder(sourcePath, destPath, (sp) => {
600
- return !IGNORED_PATTERNS.some((pattern) => pattern.test(sp));
601
- });
686
+ assertPublishedPackageExists(packageRoot, BUNDLER_DEFAULT_PACKAGE_NAME);
687
+ if ((await fs.promises.stat(packageRoot)).isDirectory()) {
688
+ await copyFolder(packageRoot, destPath, (sp) => {
689
+ return !IGNORED_PATTERNS.some((pattern) => pattern.test(sp));
690
+ });
691
+ assertCoreChunkCopied(destPath, BUNDLER_DEFAULT_APP_NAME);
692
+ }
602
693
  }
603
694
  };
604
695
  };