wu-framework 2.1.1 → 2.1.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.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
function e(){return"undefined"==typeof window?null:window.wu||window.parent?.wu||window.top?.wu||null}function n(n=5e3){return new Promise((t,r)=>{const o=e();if(o)return t(o);const i=Date.now(),a=()=>{c(),t(e())};window.addEventListener("wu:ready",a),window.addEventListener("wu:app:ready",a);const u=setInterval(()=>{const o=e();if(o)return c(),void t(o);Date.now()-i>n&&(c(),r(new Error(`Wu Framework not found after ${n}ms`)))},200);function c(){clearInterval(u),window.removeEventListener("wu:ready",a),window.removeEventListener("wu:app:ready",a)}})}let t=!1;async function r(n,r,o={}){const i=e();if(!i)return;const a=await import("@builder.io/qwik");if(function(){if(t)return;t=!0;const e=document.addEventListener;document.addEventListener=function(n,t,r){if((!0===r||r&&r.capture)&&"function"==typeof t){const o=function(e){const n=e.composedPath();if(n.length&&n[0]!==e.target&&n[0]instanceof Element){const r=n[0],o=new Proxy(e,{get(e,n){if("target"===n)return r;const t=Reflect.get(e,n);return"function"==typeof t?t.bind(e):t}});return t.call(this,o)}return t.call(this,e)};return e.call(this,n,o,r)}return e.call(this,n,t,r)}}(),!document.__wu_qwikloader){document.__wu_qwikloader=!0;try{const{QWIK_LOADER:e}=await import("@builder.io/qwik/loader"),n=document.createElement("script");n.textContent=e,document.head.appendChild(n)}catch(e){console.warn("[WuQwik] qwikloader not available:",e.message)}}i.define(n,{async mount(e){e.innerHTML="";try{const n=a.jsx(r,o.props||{});await a.render(e,n)}catch(n){console.error("[WuQwik] render error:",n),e.innerHTML='<pre style="color:#f66;padding:1rem">'+n.message+"</pre>"}},unmount(e){e.innerHTML=""}})}const o={register:r,getWuInstance:e,waitForWu:n};export{o as default,e as getWuInstance,r as register,n as waitForWu,o as wuQwik};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/adapters/qwik/index.js"],"sourcesContent":["/**\n * WU-FRAMEWORK QWIK ADAPTER\n *\n * Integrates Qwik components (component$) into Wu Framework's\n * microfrontend orchestration via @builder.io/qwik render API.\n *\n * Shadow DOM compatibility:\n * Qwik uses QRL-based event delegation — the qwikloader script\n * attaches capture-phase listeners on `document` to intercept events\n * and resolve QRL attributes (on:click, on:input, etc.) on elements.\n *\n * Inside Shadow DOM, event.target is retargeted to the shadow host,\n * so qwikloader can't find QRL attributes on the actual elements.\n * We fix this by wrapping qwikloader's document listeners with a\n * Proxy that returns event.composedPath()[0] as the real target.\n *\n * See: https://github.com/QwikDev/qwik-evolution/issues/283\n */\n\nlet _patched = false;\n\n/**\n * Patches document.addEventListener so capture-phase handlers (used by\n * qwikloader) receive the real event target from inside Shadow DOM via\n * composedPath()[0], instead of the retargeted shadow host.\n *\n * Only activates when there's actual Shadow DOM retargeting — events\n * in the light DOM pass through with zero overhead (no Proxy created).\n */\nfunction patchDocumentListenersForShadowDOM() {\n if (_patched) return;\n _patched = true;\n\n const origAdd = document.addEventListener;\n\n document.addEventListener = function (type, handler, options) {\n const isCapture = options === true || (options && options.capture);\n\n if (isCapture && typeof handler === 'function') {\n const wrapped = function (event) {\n const path = event.composedPath();\n // Only proxy when Shadow DOM retargeting occurred\n if (path.length && path[0] !== event.target && path[0] instanceof Element) {\n const realTarget = path[0];\n const proxy = new Proxy(event, {\n get(obj, prop) {\n if (prop === 'target') return realTarget;\n const val = Reflect.get(obj, prop);\n return typeof val === 'function' ? val.bind(obj) : val;\n }\n });\n return handler.call(this, proxy);\n }\n return handler.call(this, event);\n };\n return origAdd.call(this, type, wrapped, options);\n }\n\n return origAdd.call(this, type, handler, options);\n };\n}\n\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/adapters/qwik/index.js"],"sourcesContent":["/**\n * WU-FRAMEWORK QWIK ADAPTER\n *\n * Integrates Qwik components (component$) into Wu Framework's\n * microfrontend orchestration via @builder.io/qwik render API.\n *\n * Shadow DOM compatibility:\n * Qwik uses QRL-based event delegation — the qwikloader script\n * attaches capture-phase listeners on `document` to intercept events\n * and resolve QRL attributes (on:click, on:input, etc.) on elements.\n *\n * Inside Shadow DOM, event.target is retargeted to the shadow host,\n * so qwikloader can't find QRL attributes on the actual elements.\n * We fix this by wrapping qwikloader's document listeners with a\n * Proxy that returns event.composedPath()[0] as the real target.\n *\n * See: https://github.com/QwikDev/qwik-evolution/issues/283\n */\n\nfunction getWuInstance() {\n if (typeof window === 'undefined') return null;\n return window.wu || window.parent?.wu || window.top?.wu || null;\n}\n\nfunction waitForWu(timeout = 5000) {\n return new Promise((resolve, reject) => {\n const wu = getWuInstance();\n if (wu) return resolve(wu);\n\n const startTime = Date.now();\n\n const handleWuReady = () => {\n cleanup();\n resolve(getWuInstance());\n };\n\n window.addEventListener('wu:ready', handleWuReady);\n window.addEventListener('wu:app:ready', handleWuReady);\n\n const checkInterval = setInterval(() => {\n const wu = getWuInstance();\n if (wu) { cleanup(); resolve(wu); return; }\n if (Date.now() - startTime > timeout) {\n cleanup();\n reject(new Error(`Wu Framework not found after ${timeout}ms`));\n }\n }, 200);\n\n function cleanup() {\n clearInterval(checkInterval);\n window.removeEventListener('wu:ready', handleWuReady);\n window.removeEventListener('wu:app:ready', handleWuReady);\n }\n });\n}\n\nlet _patched = false;\n\n/**\n * Patches document.addEventListener so capture-phase handlers (used by\n * qwikloader) receive the real event target from inside Shadow DOM via\n * composedPath()[0], instead of the retargeted shadow host.\n *\n * Only activates when there's actual Shadow DOM retargeting — events\n * in the light DOM pass through with zero overhead (no Proxy created).\n */\nfunction patchDocumentListenersForShadowDOM() {\n if (_patched) return;\n _patched = true;\n\n const origAdd = document.addEventListener;\n\n document.addEventListener = function (type, handler, options) {\n const isCapture = options === true || (options && options.capture);\n\n if (isCapture && typeof handler === 'function') {\n const wrapped = function (event) {\n const path = event.composedPath();\n // Only proxy when Shadow DOM retargeting occurred\n if (path.length && path[0] !== event.target && path[0] instanceof Element) {\n const realTarget = path[0];\n const proxy = new Proxy(event, {\n get(obj, prop) {\n if (prop === 'target') return realTarget;\n const val = Reflect.get(obj, prop);\n return typeof val === 'function' ? val.bind(obj) : val;\n }\n });\n return handler.call(this, proxy);\n }\n return handler.call(this, event);\n };\n return origAdd.call(this, type, wrapped, options);\n }\n\n return origAdd.call(this, type, handler, options);\n };\n}\n\nasync function register(appName, Component, options = {}) {\n const wu = getWuInstance();\n if (!wu) return;\n\n const qwik = await import('@builder.io/qwik');\n\n // Patch document listeners BEFORE injecting qwikloader so its\n // capture-phase handlers are wrapped with Shadow DOM awareness.\n // Must stay active permanently — qwikloader registers event types\n // lazily as new on: attributes appear in the DOM.\n patchDocumentListenersForShadowDOM();\n\n // Inject qwikloader once per document (event delegation for QRLs)\n if (!document.__wu_qwikloader) {\n document.__wu_qwikloader = true;\n try {\n const { QWIK_LOADER } = await import('@builder.io/qwik/loader');\n const s = document.createElement('script');\n s.textContent = QWIK_LOADER;\n document.head.appendChild(s);\n } catch (e) {\n console.warn('[WuQwik] qwikloader not available:', e.message);\n }\n }\n\n wu.define(appName, {\n async mount(container) {\n container.innerHTML = '';\n try {\n const vnode = qwik.jsx(Component, options.props || {});\n await qwik.render(container, vnode);\n } catch (e) {\n console.error('[WuQwik] render error:', e);\n container.innerHTML = '<pre style=\"color:#f66;padding:1rem\">' + e.message + '</pre>';\n }\n },\n unmount(container) {\n container.innerHTML = '';\n }\n });\n}\n\nexport const wuQwik = {\n register,\n getWuInstance,\n waitForWu\n};\n\nexport { register, getWuInstance, waitForWu };\nexport default wuQwik;\n"],"names":["getWuInstance","window","wu","parent","top","waitForWu","timeout","Promise","resolve","reject","startTime","Date","now","handleWuReady","cleanup","addEventListener","checkInterval","setInterval","Error","clearInterval","removeEventListener","_patched","async","register","appName","Component","options","qwik","import","origAdd","document","type","handler","capture","wrapped","event","path","composedPath","length","target","Element","realTarget","proxy","Proxy","get","obj","prop","val","Reflect","bind","call","this","patchDocumentListenersForShadowDOM","__wu_qwikloader","QWIK_LOADER","s","createElement","textContent","head","appendChild","e","console","warn","message","define","mount","container","innerHTML","vnode","jsx","props","render","error","unmount","wuQwik"],"mappings":"AAmBA,SAASA,IACP,MAAsB,oBAAXC,OAA+B,KACnCA,OAAOC,IAAMD,OAAOE,QAAQD,IAAMD,OAAOG,KAAKF,IAAM,IAC7D,CAEA,SAASG,EAAUC,EAAU,KAC3B,OAAO,IAAIC,QAAQ,CAACC,EAASC,KAC3B,MAAMP,EAAKF,IACX,GAAIE,EAAI,OAAOM,EAAQN,GAEvB,MAAMQ,EAAYC,KAAKC,MAEjBC,EAAgB,KACpBC,IACAN,EAAQR,MAGVC,OAAOc,iBAAiB,WAAYF,GACpCZ,OAAOc,iBAAiB,eAAgBF,GAExC,MAAMG,EAAgBC,YAAY,KAChC,MAAMf,EAAKF,IACX,GAAIE,EAA8B,OAAxBY,SAAWN,EAAQN,GACzBS,KAAKC,MAAQF,EAAYJ,IAC3BQ,IACAL,EAAO,IAAIS,MAAM,gCAAgCZ,UAElD,KAEH,SAASQ,IACPK,cAAcH,GACdf,OAAOmB,oBAAoB,WAAYP,GACvCZ,OAAOmB,oBAAoB,eAAgBP,EAC7C,GAEJ,CAEA,IAAIQ,GAAW,EA2CfC,eAAeC,EAASC,EAASC,EAAWC,EAAU,CAAA,GACpD,MAAMxB,EAAKF,IACX,IAAKE,EAAI,OAET,MAAMyB,QAAaC,OAAO,oBAS1B,GA9CF,WACE,GAAIP,EAAU,OACdA,GAAW,EAEX,MAAMQ,EAAUC,SAASf,iBAEzBe,SAASf,iBAAmB,SAAUgB,EAAMC,EAASN,GAGnD,KAF8B,IAAZA,GAAqBA,GAAWA,EAAQO,UAEtB,mBAAZD,EAAwB,CAC9C,MAAME,EAAU,SAAUC,GACxB,MAAMC,EAAOD,EAAME,eAEnB,GAAID,EAAKE,QAAUF,EAAK,KAAOD,EAAMI,QAAUH,EAAK,aAAcI,QAAS,CACzE,MAAMC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