@depict-ai/react-solid-bridge
Advanced tools
Comparing version 1.0.6 to 1.0.7
/*! For license information please see main.js.LICENSE.txt */ | ||
!function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r(require("react"),require("react-dom"),require("solid-js"));else if("function"==typeof define&&define.amd)define(["react","react-dom","solid-js"],r);else{var t="object"==typeof exports?r(require("react"),require("react-dom"),require("solid-js")):r(e.react,e["react-dom"],e["solid-js"]);for(var n in t)("object"==typeof exports?exports:e)[n]=t[n]}}(this,((e,r,t)=>(()=>{"use strict";var n={251:(e,r,t)=>{var n=t(156),o=Symbol.for("react.element"),i=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),c=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};r.jsx=function(e,r,t){var n,l={},f=null,a=null;for(n in void 0!==t&&(f=""+t),void 0!==r.key&&(f=""+r.key),void 0!==r.ref&&(a=r.ref),r)i.call(r,n)&&!u.hasOwnProperty(n)&&(l[n]=r[n]);if(e&&e.defaultProps)for(n in r=e.defaultProps)void 0===l[n]&&(l[n]=r[n]);return{$$typeof:o,type:e,key:f,ref:a,props:l,_owner:c.current}}},893:(e,r,t)=>{e.exports=t(251)},156:r=>{r.exports=e},111:e=>{e.exports=r},137:e=>{e.exports=t}},o={};function i(e){var r=o[e];if(void 0!==r)return r.exports;var t=o[e]={exports:{}};return n[e](t,t.exports,i),t.exports}i.d=(e,r)=>{for(var t in r)i.o(r,t)&&!i.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},i.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var c={};return(()=>{i.r(c),i.d(c,{ReactToSolidBridge:()=>j,ReactToSolidBridgeProvider:()=>P,convertToReactComponent:()=>E});var e=i(156),r=i(111),t=i(137);function n(e,r,t){const n=document.createElement("template");n.innerHTML=e;let o=n.content.firstChild;return t&&(o=o.firstChild),o}function o(e,r,n,o){if(void 0===n||o||(o=[]),"function"!=typeof r)return u(e,r,o,n);(0,t.createRenderEffect)((t=>u(e,r(),t,n)),o)}function u(e,r,n,o,i){for(t.sharedConfig.context&&!n&&(n=[...e.childNodes]);"function"==typeof n;)n=n();if(r===n)return n;const c=typeof r,s=void 0!==o;if(e=s&&n[0]&&n[0].parentNode||e,"string"===c||"number"===c){if(t.sharedConfig.context)return n;if("number"===c&&(r=r.toString()),s){let t=n[0];t&&3===t.nodeType?t.data=r:t=document.createTextNode(r),n=a(e,n,o,t)}else n=""!==n&&"string"==typeof n?e.firstChild.data=r:e.textContent=r}else if(null==r||"boolean"===c){if(t.sharedConfig.context)return n;n=a(e,n,o)}else{if("function"===c)return(0,t.createRenderEffect)((()=>{let t=r();for(;"function"==typeof t;)t=t();n=u(e,t,n,o)})),()=>n;if(Array.isArray(r)){const c=[],d=n&&Array.isArray(n);if(l(c,r,n,i))return(0,t.createRenderEffect)((()=>n=u(e,c,n,o,!0))),()=>n;if(t.sharedConfig.context){if(!c.length)return n;for(let e=0;e<c.length;e++)if(c[e].parentNode)return n=c}if(0===c.length){if(n=a(e,n,o),s)return n}else d?0===n.length?f(e,c,o):function(e,r,t){let n=t.length,o=r.length,i=n,c=0,u=0,l=r[o-1].nextSibling,f=null;for(;c<o||u<i;)if(r[c]!==t[u]){for(;r[o-1]===t[i-1];)o--,i--;if(o===c){const r=i<n?u?t[u-1].nextSibling:t[i-u]:l;for(;u<i;)e.insertBefore(t[u++],r)}else if(i===u)for(;c<o;)f&&f.has(r[c])||r[c].remove(),c++;else if(r[c]===t[i-1]&&t[u]===r[o-1]){const n=r[--o].nextSibling;e.insertBefore(t[u++],r[c++].nextSibling),e.insertBefore(t[--i],n),r[o]=t[i]}else{if(!f){f=new Map;let e=u;for(;e<i;)f.set(t[e],e++)}const n=f.get(r[c]);if(null!=n)if(u<n&&n<i){let l,a=c,s=1;for(;++a<o&&a<i&&null!=(l=f.get(r[a]))&&l===n+s;)s++;if(s>n-u){const o=r[c];for(;u<n;)e.insertBefore(t[u++],o)}else e.replaceChild(t[u++],r[c++])}else c++;else r[c++].remove()}}else c++,u++}(e,n,c):(n&&a(e),f(e,c));n=c}else if(r instanceof Node){if(t.sharedConfig.context&&r.parentNode)return n=s?[r]:r;if(Array.isArray(n)){if(s)return n=a(e,n,o,r);a(e,n,null,r)}else null!=n&&""!==n&&e.firstChild?e.replaceChild(r,e.firstChild):e.appendChild(r);n=r}}return n}function l(e,r,t,n){let o=!1;for(let i=0,c=r.length;i<c;i++){let c=r[i],u=t&&t[i];if(c instanceof Node)e.push(c);else if(null==c||!0===c||!1===c);else if(Array.isArray(c))o=l(e,c,u)||o;else if("function"==typeof c)if(n){for(;"function"==typeof c;)c=c();o=l(e,Array.isArray(c)?c:[c],Array.isArray(u)?u:[u])||o}else e.push(c),o=!0;else{const r=String(c);u&&3===u.nodeType&&u.data===r?e.push(u):e.push(document.createTextNode(r))}}return o}function f(e,r,t){for(let n=0,o=r.length;n<o;n++)e.insertBefore(r[n],t)}function a(e,r,t,n){if(void 0===t)return e.textContent="";const o=n||document.createTextNode("");if(r.length){let n=!1;for(let i=r.length-1;i>=0;i--){const c=r[i];if(o!==c){const r=c.parentNode===e;n||i?r&&c.remove():r?e.replaceChild(o,c):e.insertBefore(o,t)}else n=!0}}else e.insertBefore(o,t);return[o]}const s=(0,e.createContext)({});function d(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}const p=function(e){var r,n,o=(r=(0,t.createSignal)(e.getChildren()),n=2,function(e){if(Array.isArray(e))return e}(r)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,i=[],c=!0,u=!1;try{for(t=t.call(e);!(c=(n=t.next()).done)&&(i.push(n.value),!r||i.length!==r);c=!0);}catch(e){u=!0,o=e}finally{try{c||null==t.return||t.return()}finally{if(u)throw o}}return i}}(r,n)||function(e,r){if(e){if("string"==typeof e)return d(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?d(e,r):void 0}}(r,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],c=o[1];return(0,t.createEffect)((function(){var r=e.subscribeToChildren(c);(0,t.onCleanup)((function(){r()}))})),(0,t.createComponent)(t.For,{get each(){return i()},children:function(e){return(0,t.createComponent)(e,{})}})},h=n("<div></div>"),y=function(e){var r=e.getChildElement,t=h.cloneNode(!0);return r(t),t},v=function(){var r=(0,e.useMemo)((function(){return function(){var e={current:arguments.length>0&&void 0!==arguments[0]?arguments[0]:null},r={current:[]},t={current:new Map},n=function(n){e.current=n,r.current.forEach((function(e){t.current.set(e,e(n))}))},o=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Function.prototype;return r.current=r.current.concat(e),function(){var n=t.current.get(e);"function"==typeof n&&n();var o=r.current.indexOf(e);r.current=r.current.slice(0,o).concat(r.current.slice(o+1))}};return{_subscribersRef:r,getValue:function(){return e.current},publish:n,subscribe:o}}([])}),[]),t=r.getValue,n=r.publish,o=r.subscribe,i=(0,e.useCallback)((function(e){n(t().concat(e))}),[t,n]),c=(0,e.useCallback)((function(e){var r=t(),o=r.indexOf(e),i=r.slice(0,o).concat(r.slice(o+1));n(i)}),[t,n]);return{addItem:i,getItems:t,removeItem:c,subscribeToItems:o}};var m=i(893);function b(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function g(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?b(Object(t),!0).forEach((function(r){C(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):b(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function C(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function S(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,i=[],c=!0,u=!1;try{for(t=t.call(e);!(c=(n=t.next()).done)&&(i.push(n.value),!r||i.length!==r);c=!0);}catch(e){u=!0,o=e}finally{try{c||null==t.return||t.return()}finally{if(u)throw o}}return i}}(e,r)||function(e,r){if(e){if("string"==typeof e)return O(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?O(e,r):void 0}}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var x={};const j=function(n){var i=n.children,c=n.getSolidComponent,u=n.props,l=n.solidComponent,f=(0,e.useContext)(s),a=f.addSolidChild,d=f.removeSolidChild,h=v(),b=h.addItem,O=h.getItems,j=h.removeItem,w=h.subscribeToItems,E=S((0,e.useState)(),2),P=E[0],T=E[1],A=(0,e.useRef)(),R=(0,e.useRef)();R.current=c;var I=(0,e.useRef)();I.current=l;var _=(0,e.useRef)();_.current=u;var N=(0,e.useRef)(),M=(0,e.useRef)(x);(0,e.useEffect)((function(){var e=function(e){"function"==typeof u[e]?M.current[e]||(M.current=g(g({},M.current),{},C({},e,[function(){var r;return(r=_.current)[e].apply(r,arguments)}]))):M.current[e]?M.current[e][1](u[e]):M.current=g(g({},M.current),{},C({},e,(0,t.createSignal)(u[e])))};for(var r in(null==u?void 0:u.values)||u)e(r);N.current||(N.current=Object.fromEntries(Object.entries(M.current).map((function(e){var r=S(e,2);return[r[0],r[1][0]]}))))}),[u]),(0,e.useEffect)((function(){if(!a)throw new Error("You need to wrap `ReactToSolidBridge` in a `ReactToSolidBridgeProvider` component at the top-level of your React app.");var e=function(){return[y({getChildElement:T}),p({getChildren:O,subscribeToChildren:w})]},r=function(){return function(e){const{useShadow:r}=e,n=document.createTextNode(""),i=e.mount||document.body;function c(){if(t.sharedConfig.context){const[r,n]=(0,t.createSignal)(!1);return queueMicrotask((()=>n(!0))),()=>r()&&e.children}return()=>e.children}if(i instanceof HTMLHeadElement){const[e,r]=(0,t.createSignal)(!1),n=()=>r(!0);(0,t.createRoot)((r=>o(i,(()=>e()?r():c()()),null))),(0,t.onCleanup)((()=>{t.sharedConfig.context?queueMicrotask(n):n()}))}else{const u=function(e,r=!1){return r?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e)}(e.isSVG?"g":"div",e.isSVG),l=r&&u.attachShadow?u.attachShadow({mode:"open"}):u;Object.defineProperty(u,"host",{get:()=>n.parentNode}),o(l,c()),i.appendChild(u),e.ref&&e.ref(u),(0,t.onCleanup)((()=>i.removeChild(u)))}return n}({get children(){if(I.current){var r=new Proxy({get children(){return e()}},{get:function(e,r){return r in N.current?N.current[r]():Reflect.get(e,r)}});return I.current(r)}return R.current({getChildren:e,props:N.current})},mount:A.current})};return a(r),function(){d(r)}}),[a,O,d,w]);var B=(0,e.useMemo)((function(){return{addSolidChild:b,removeSolidChild:j}}),[b,j]);return(0,m.jsx)("div",{ref:A,children:(0,m.jsx)(s.Provider,{value:B,children:i&&P&&(0,r.createPortal)(i,P)})})};var w=["children"];const E=function(r){var t=function(e){var t=e.children,n=function(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)t=i[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)t=i[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}(e,w);return(0,m.jsx)(j,{props:n,solidComponent:r,children:t})};return(0,e.memo)(t)},P=function(r){var n=r.children,i=v(),c=i.addItem,u=i.getItems,l=i.removeItem,f=i.subscribeToItems,a=(0,e.useRef)();(0,e.useEffect)((function(){var e=function(e,r,n){let i;return(0,t.createRoot)((t=>{i=t,r===document?e():o(r,e(),r.firstChild?null:void 0,n)})),()=>{i(),r.textContent=""}}((function(){return p({getChildren:u,subscribeToChildren:f})}),a.current);return function(){e()}}),[u,f]);var d=(0,e.useMemo)((function(){return{addSolidChild:c,removeSolidChild:l}}),[]);return(0,m.jsx)("div",{ref:a,children:(0,m.jsx)(s.Provider,{value:d,children:n})})}})(),c})())); | ||
!function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r(require("react"),require("react-dom"),require("solid-js"));else if("function"==typeof define&&define.amd)define(["react","react-dom","solid-js"],r);else{var t="object"==typeof exports?r(require("react"),require("react-dom"),require("solid-js")):r(e.react,e["react-dom"],e["solid-js"]);for(var n in t)("object"==typeof exports?exports:e)[n]=t[n]}}(this,((e,r,t)=>(()=>{"use strict";var n={251:(e,r,t)=>{var n=t(156),o=Symbol.for("react.element"),i=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),c=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};r.jsx=function(e,r,t){var n,l={},f=null,a=null;for(n in void 0!==t&&(f=""+t),void 0!==r.key&&(f=""+r.key),void 0!==r.ref&&(a=r.ref),r)i.call(r,n)&&!u.hasOwnProperty(n)&&(l[n]=r[n]);if(e&&e.defaultProps)for(n in r=e.defaultProps)void 0===l[n]&&(l[n]=r[n]);return{$$typeof:o,type:e,key:f,ref:a,props:l,_owner:c.current}}},893:(e,r,t)=>{e.exports=t(251)},156:r=>{r.exports=e},111:e=>{e.exports=r},137:e=>{e.exports=t}},o={};function i(e){var r=o[e];if(void 0!==r)return r.exports;var t=o[e]={exports:{}};return n[e](t,t.exports,i),t.exports}i.d=(e,r)=>{for(var t in r)i.o(r,t)&&!i.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},i.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var c={};return(()=>{i.r(c),i.d(c,{ReactToSolidBridge:()=>j,ReactToSolidBridgeProvider:()=>P,convertToReactComponent:()=>E});var e=i(156),r=i(111),t=i(137);function n(e,r,t){const n=document.createElement("template");n.innerHTML=e;let o=n.content.firstChild;return t&&(o=o.firstChild),o}function o(e,r,n,o){if(void 0===n||o||(o=[]),"function"!=typeof r)return u(e,r,o,n);(0,t.createRenderEffect)((t=>u(e,r(),t,n)),o)}function u(e,r,n,o,i){for(t.sharedConfig.context&&!n&&(n=[...e.childNodes]);"function"==typeof n;)n=n();if(r===n)return n;const c=typeof r,s=void 0!==o;if(e=s&&n[0]&&n[0].parentNode||e,"string"===c||"number"===c){if(t.sharedConfig.context)return n;if("number"===c&&(r=r.toString()),s){let t=n[0];t&&3===t.nodeType?t.data=r:t=document.createTextNode(r),n=a(e,n,o,t)}else n=""!==n&&"string"==typeof n?e.firstChild.data=r:e.textContent=r}else if(null==r||"boolean"===c){if(t.sharedConfig.context)return n;n=a(e,n,o)}else{if("function"===c)return(0,t.createRenderEffect)((()=>{let t=r();for(;"function"==typeof t;)t=t();n=u(e,t,n,o)})),()=>n;if(Array.isArray(r)){const c=[],d=n&&Array.isArray(n);if(l(c,r,n,i))return(0,t.createRenderEffect)((()=>n=u(e,c,n,o,!0))),()=>n;if(t.sharedConfig.context){if(!c.length)return n;for(let e=0;e<c.length;e++)if(c[e].parentNode)return n=c}if(0===c.length){if(n=a(e,n,o),s)return n}else d?0===n.length?f(e,c,o):function(e,r,t){let n=t.length,o=r.length,i=n,c=0,u=0,l=r[o-1].nextSibling,f=null;for(;c<o||u<i;)if(r[c]!==t[u]){for(;r[o-1]===t[i-1];)o--,i--;if(o===c){const r=i<n?u?t[u-1].nextSibling:t[i-u]:l;for(;u<i;)e.insertBefore(t[u++],r)}else if(i===u)for(;c<o;)f&&f.has(r[c])||r[c].remove(),c++;else if(r[c]===t[i-1]&&t[u]===r[o-1]){const n=r[--o].nextSibling;e.insertBefore(t[u++],r[c++].nextSibling),e.insertBefore(t[--i],n),r[o]=t[i]}else{if(!f){f=new Map;let e=u;for(;e<i;)f.set(t[e],e++)}const n=f.get(r[c]);if(null!=n)if(u<n&&n<i){let l,a=c,s=1;for(;++a<o&&a<i&&null!=(l=f.get(r[a]))&&l===n+s;)s++;if(s>n-u){const o=r[c];for(;u<n;)e.insertBefore(t[u++],o)}else e.replaceChild(t[u++],r[c++])}else c++;else r[c++].remove()}}else c++,u++}(e,n,c):(n&&a(e),f(e,c));n=c}else if(r instanceof Node){if(t.sharedConfig.context&&r.parentNode)return n=s?[r]:r;if(Array.isArray(n)){if(s)return n=a(e,n,o,r);a(e,n,null,r)}else null!=n&&""!==n&&e.firstChild?e.replaceChild(r,e.firstChild):e.appendChild(r);n=r}}return n}function l(e,r,t,n){let o=!1;for(let i=0,c=r.length;i<c;i++){let c=r[i],u=t&&t[i];if(c instanceof Node)e.push(c);else if(null==c||!0===c||!1===c);else if(Array.isArray(c))o=l(e,c,u)||o;else if("function"==typeof c)if(n){for(;"function"==typeof c;)c=c();o=l(e,Array.isArray(c)?c:[c],Array.isArray(u)?u:[u])||o}else e.push(c),o=!0;else{const r=String(c);u&&3===u.nodeType&&u.data===r?e.push(u):e.push(document.createTextNode(r))}}return o}function f(e,r,t){for(let n=0,o=r.length;n<o;n++)e.insertBefore(r[n],t)}function a(e,r,t,n){if(void 0===t)return e.textContent="";const o=n||document.createTextNode("");if(r.length){let n=!1;for(let i=r.length-1;i>=0;i--){const c=r[i];if(o!==c){const r=c.parentNode===e;n||i?r&&c.remove():r?e.replaceChild(o,c):e.insertBefore(o,t)}else n=!0}}else e.insertBefore(o,t);return[o]}const s=(0,e.createContext)({});function d(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}const p=function(e){var r,n,o=(r=(0,t.createSignal)(e.getChildren()),n=2,function(e){if(Array.isArray(e))return e}(r)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,i=[],c=!0,u=!1;try{for(t=t.call(e);!(c=(n=t.next()).done)&&(i.push(n.value),!r||i.length!==r);c=!0);}catch(e){u=!0,o=e}finally{try{c||null==t.return||t.return()}finally{if(u)throw o}}return i}}(r,n)||function(e,r){if(e){if("string"==typeof e)return d(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?d(e,r):void 0}}(r,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],c=o[1];return(0,t.createEffect)((function(){var r=e.subscribeToChildren(c);(0,t.onCleanup)((function(){r()}))})),(0,t.createComponent)(t.For,{get each(){return i()},children:function(e){return(0,t.createComponent)(e,{})}})},h=n("<div></div>"),y=function(e){var r=e.getChildElement,t=h.cloneNode(!0);return r(t),t},v=function(){var r=(0,e.useMemo)((function(){return function(){var e={current:arguments.length>0&&void 0!==arguments[0]?arguments[0]:null},r={current:[]},t={current:new Map},n=function(n){e.current=n,r.current.forEach((function(e){t.current.set(e,e(n))}))},o=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Function.prototype;return r.current=r.current.concat(e),function(){var n=t.current.get(e);"function"==typeof n&&n();var o=r.current.indexOf(e);r.current=r.current.slice(0,o).concat(r.current.slice(o+1))}};return{_subscribersRef:r,getValue:function(){return e.current},publish:n,subscribe:o}}([])}),[]),t=r.getValue,n=r.publish,o=r.subscribe,i=(0,e.useCallback)((function(e){n(t().concat(e))}),[t,n]),c=(0,e.useCallback)((function(e){var r=t(),o=r.indexOf(e),i=r.slice(0,o).concat(r.slice(o+1));n(i)}),[t,n]);return{addItem:i,getItems:t,removeItem:c,subscribeToItems:o}};var m=i(893);function b(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function g(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?b(Object(t),!0).forEach((function(r){C(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):b(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function C(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function S(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,i=[],c=!0,u=!1;try{for(t=t.call(e);!(c=(n=t.next()).done)&&(i.push(n.value),!r||i.length!==r);c=!0);}catch(e){u=!0,o=e}finally{try{c||null==t.return||t.return()}finally{if(u)throw o}}return i}}(e,r)||function(e,r){if(e){if("string"==typeof e)return O(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?O(e,r):void 0}}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var x={};const j=function(n){var i=n.children,c=n.getSolidComponent,u=n.props,l=n.solidComponent,f=(0,e.useContext)(s),a=f.addSolidChild,d=f.removeSolidChild,h=v(),b=h.addItem,O=h.getItems,j=h.removeItem,w=h.subscribeToItems,E=S((0,e.useState)(),2),P=E[0],T=E[1],A=(0,e.useRef)(),R=(0,e.useRef)();R.current=c;var I=(0,e.useRef)();I.current=l;var _=(0,e.useRef)();_.current=u;var N=(0,e.useRef)(),M=(0,e.useRef)(x);(0,e.useEffect)((function(){var e=function(e){"function"==typeof u[e]?M.current[e]||(M.current=g(g({},M.current),{},C({},e,[function(){var r;return(r=_.current)[e].apply(r,arguments)}]))):M.current[e]?M.current[e][1](u[e]):M.current=g(g({},M.current),{},C({},e,(0,t.createSignal)(u[e])))};for(var r in(null==u?void 0:u.values)||u)e(r);N.current||(N.current=Object.fromEntries(Object.entries(M.current).map((function(e){var r=S(e,2);return[r[0],r[1][0]]}))))}),[u]),(0,e.useEffect)((function(){if(!a)throw new Error("You need to wrap `ReactToSolidBridge` in a `ReactToSolidBridgeProvider` component at the top-level of your React app.");var e=function(){return[y({getChildElement:T}),p({getChildren:O,subscribeToChildren:w})]},r=function(){return function(e){const{useShadow:r}=e,n=document.createTextNode(""),i=e.mount||document.body;function c(){if(t.sharedConfig.context){const[r,n]=(0,t.createSignal)(!1);return queueMicrotask((()=>n(!0))),()=>r()&&e.children}return()=>e.children}if(i instanceof HTMLHeadElement){const[e,r]=(0,t.createSignal)(!1),n=()=>r(!0);(0,t.createRoot)((r=>o(i,(()=>e()?r():c()()),null))),(0,t.onCleanup)((()=>{t.sharedConfig.context?queueMicrotask(n):n()}))}else{const u=function(e,r=!1){return r?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e)}(e.isSVG?"g":"div",e.isSVG),l=r&&u.attachShadow?u.attachShadow({mode:"open"}):u;Object.defineProperty(u,"host",{get:()=>n.parentNode}),o(l,c()),i.appendChild(u),e.ref&&e.ref(u),(0,t.onCleanup)((()=>i.removeChild(u)))}return n}({get children(){if(I.current){var r=new Proxy({get children(){return e()}},{get:function(e,r){return r in N.current?N.current[r]():Reflect.get(e,r)}});return I.current(r)}return R.current({getChildren:e,props:N.current})},mount:A.current})};return a(r),function(){d(r)}}),[a,O,d,w]);var B=(0,e.useMemo)((function(){return{addSolidChild:b,removeSolidChild:j}}),[b,j]);return(0,m.jsx)("div",{ref:A,children:(0,m.jsx)(s.Provider,{value:B,children:i&&P&&(0,r.createPortal)(i,P)})})};var w=["children"];const E=function(r){var t=function(e){var t=e.children,n=function(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)t=i[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)t=i[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}(e,w);return(0,m.jsx)(j,{props:n,solidComponent:r,children:t})};return(0,e.memo)(t)},P=function(r){var n=r.children,i=v(),c=i.addItem,u=i.getItems,l=i.removeItem,f=i.subscribeToItems,a=(0,e.useRef)();(0,e.useEffect)((function(){var e=function(e,r,n){let i;return(0,t.createRoot)((t=>{i=t,r===document?e():o(r,e(),r.firstChild?null:void 0,n)})),()=>{i(),r.textContent=""}}((function(){return p({getChildren:u,subscribeToChildren:f})}),a.current);return function(){e()}}),[u,f]);var d=(0,e.useMemo)((function(){return{addSolidChild:c,removeSolidChild:l}}),[]);return(0,m.jsx)("div",{ref:a,children:(0,m.jsx)(s.Provider,{value:d,children:n})})}})(),c})())); | ||
//# sourceMappingURL=main.js.map |
{ | ||
"name": "@depict-ai/react-solid-bridge", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "files": ["/dist"], |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
92386
58
141