Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-habitat

Package Overview
Dependencies
Maintainers
3
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-habitat - npm Package Compare versions

Comparing version 0.5.0-beta to 0.5.0-beta2

21

dist/react-habitat.js

@@ -230,2 +230,4 @@ (function webpackUniversalModuleDefinition(root, factory) {

* @param {null|function} cb - The callback
* @param {object} context - The context of the callback
* @param {...object} args - Arguments to apply
* @private

@@ -245,6 +247,6 @@ */

* Apply a container to nodes and populate components
* @param {array} container The container
* @param {array} nodes The elements to parse
* @param {string} componentSelector The component selector
* @param {function} [cb=null] - Optional callback
* @param {array} container - The container
* @param {array} nodes - The elements to parse
* @param {string} componentSelector - The component selector
* @param {function} [cb=null] - Optional callback
* @private

@@ -271,3 +273,3 @@ */

var componentName = ele.getAttribute(componentSelector);
resolveQueue.push(container.resolve(componentName).then(function (component) {
resolveQueue.push(container.resolve(componentName).then(function (registration) {
// This is an expensive operation so only do on non prod builds

@@ -280,2 +282,11 @@ if (true) {

// Handle any esModule's with default exports
// This helps developers out with writing cleaner container code otherwise
// they will need to wrap `import()`'s in Promises that return the default.. yuk
// https://github.com/webpack/webpack.js.org/pull/213
var component = registration;
if (registration.__esModule && registration.default) {
component = registration.default;
}
// Inject the component

@@ -282,0 +293,0 @@ factory.inject(component, _Habitat2.default.parseProps(ele), _Habitat2.default.create(ele, id));

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("React"),require("ReactDOM")):"function"==typeof define&&define.amd?define(["React","ReactDOM"],t):"object"==typeof exports?exports.ReactHabitat=t(require("React"),require("ReactDOM")):e.ReactHabitat=t(e.React,e.ReactDOM)}(this,function(e,t){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(2),a=r(o),i=n(3),u=r(i),l=n(5);t.default={Bootstrapper:a.default,Container:u.default,createBootstrapper:l.createBootstrapper},e.exports=t.default},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;t.length>n;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){},i=a,u=a,l="http://tinyurl.com/jxryd3s",c=function(){function e(){r(this,e)}return o(e,null,[{key:"warn",value:function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];var a=u("WARNING: "+e+" "+t+" "+l+"#"+e.toLowerCase(),r);i("warn",a)}},{key:"error",value:function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];var a=u("ERROR: "+e+" "+t+" "+l+"#"+e.toLowerCase(),r);i("error",a)}}]),e}();t.default=c,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if("function"==typeof e){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];e.call.apply(e,[t].concat(r))}}function i(e,t,n){for(var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=e.domFactory(),i=e.id(),u=[],l=function(r){var a=t[r];if(c.default.hasHabitat(a))return"continue";var l=a.getAttribute(n);u.push(e.resolve(l).then(function(e){o.inject(e,c.default.parseProps(a),c.default.create(a,i))}).catch(function(e){f.default.error("RHW01",'Cannot resolve component "'+l+'" for element.',e,a)}))},s=0;t.length>s;++s){l(s)}Promise.all(u.map(function(e){return e.catch(function(e){return e})})).then(function(){a(r)}).catch(function(e){throw e})}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;t.length>n;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(4),c=r(l),s=n(1),f=r(s),d="data-component",p=function(){function e(){if(o(this,e),!window||!window&&!window.document)throw Error("React Habitat requires a window but cannot see one :(");this.componentSelector=d,this._container=null,this._observer=null,this._isWatching=!1}return u(e,[{key:"setContainer",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return null!==this._container?void f.default.error("RHW02","A container is already set. Please call dispose() before assigning a new one."):(this._container=e,void this.update(null,function(){a(n,t)}))}},{key:"update",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!this._container)return void a(n);var r=e||window.document.body.querySelectorAll("["+this.componentSelector+"]");if("function"==typeof this.shouldUpdate&&this.shouldUpdate(r)===!1)return void a(n,this);var o=this._isWatching;o&&this.stopWatcher(),"function"==typeof this.willUpdate&&this.willUpdate(r),i(this._container,r,this.componentSelector,function(){o&&t.startWatcher(),"function"==typeof t.didUpdate&&t.didUpdate(r),a(n,t)})}},{key:"startWatcher",value:function(){return"undefined"==typeof MutationObserver?void f.default.error("RHE09","MutationObserver not available."):(this._observer||(this._observer=new MutationObserver(this._handleDomMutation.bind(this))),this._observer.observe(window.document.body,{childList:!0,attributes:!0,subtree:!0,attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,attributeFilter:[this.componentSelector]}),void(this._isWatching=!0))}},{key:"stopWatcher",value:function(){this._observer&&this._observer.disconnect&&this._observer.disconnect(),this._isWatching=!1}},{key:"_handleDomMutation",value:function(e){if(void 0!==e){var t=e.filter(function(e){return e.addedNodes.length});t.length&&this.update()}else this.update()}},{key:"dispose",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.stopWatcher();for(var t=this._container.domFactory(),n=window.document.body.querySelectorAll('[data-habitat="'+this._container.id()+'"]'),r=0;n.length>r;++r)t.dispose(n[r]),c.default.destroy(n[r]);this._container=null,this._observer=null,this._isWatching=!1,a(e,this)}}]),e}();t.default=p,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;t.length>n;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u=n(6),l=r(u),c=function(){var e=0;return function(){return e+=1,"C"+e}}(),s=function(e){return!!e&&("object"===(void 0===e?"undefined":i(e))||"function"==typeof e)&&"function"==typeof e.then},f=function(){function e(){o(this,e),this._components={},this._id=c()}return a(e,[{key:"id",value:function(){return this._id}},{key:"register",value:function(e,t){if("string"!=typeof e)throw Error("Unexpected component key. Expects a string.",e);this._components[e]=t}},{key:"registerAll",value:function(e){if("object"!==(void 0===e?"undefined":i(e)))throw Error("Unexpected components type. Expects type object",e);Object.assign(this._components,e)}},{key:"resolve",value:function(e){var t=this._components[e];return t?s(t)?t:Promise.resolve(t):Promise.reject(Error("Not Registered"))}},{key:"domFactory",value:function(){return l.default}}]),e}();t.default=f,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e){var t=e.currentStyle||window.getComputedStyle(e,"");return t.display}function i(e){return e[1].toUpperCase()}function u(e,t){return t.replace(e,"").replace(/-([a-z])/g,i)}Object.defineProperty(t,"__esModule",{value:!0});var l=function(){function e(e,t){for(var n=0;t.length>n;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(1),s=r(c),f="habitatHostElement",d="data-habitat",p="data-has-habitat",h="data-prop-",y="data-props",v="data-n-prop-",b="data-r-prop-",m=!1,w=function(){function e(){o(this,e)}return l(e,null,[{key:"parseProps",value:function(e){for(var t={proxy:e},n=0;e.attributes.length>n;n++){var r=e.attributes[n];if(0===r.name.indexOf(h)){var o=u(h,r.name),a=r.value||"";"string"==typeof a&&"false"===a.toLowerCase()&&(a=!1),"string"==typeof a&&"true"===a.toLowerCase()&&(a=!0),"string"==typeof a&&a.length>=2&&("{"===a[0]&&"}"===a[a.length-1]||"["===a[0]&&"]"===a[a.length-1])&&(a=JSON.parse(a)),"string"==typeof a&&"null"===a.toLowerCase()&&(a=null),t[o]=a}else if(r.name===y)Object.assign(t,JSON.parse(r.value));else if(0===r.name.indexOf("data-n-prop-")){var i=u(v,r.name);t[i]=parseFloat(r.value)}else if(window&&0===r.name.indexOf(b)){var l=u(b,r.name);t[l]=window[r.value]}}return t}},{key:"create",value:function(e,t){if(window.document.body===e||null===e||void 0===e)return s.default.warn("RHW04","Cannot open a habitat for element.",e),null;var n="span";"block"===a(e)&&(n="div");var r=window.document.createElement(n),o=e.getAttribute("data-habitat-class")||null,i=!1;if(null!==e.getAttribute("data-habitat-no-replace")&&(i="true"===e.getAttribute("data-habitat-no-replace").toLocaleLowerCase()),r.setAttribute(d,t),o&&(r.className=""+o),e.parentNode.insertBefore(r,e.nextSibling),"INPUT"!==e.tagName){if(!i){var u=e.parentNode.removeChild(e);try{r[f]=u}catch(e){m&&(s.default.warn("RHW06","Arbitrary properties are disabled. The container may not dispose correctly.",e),m=!0)}}}else e.setAttribute(p,"true"),"hidden"!==e.getAttribute("type")&&e.setAttribute("style","display: none;");return r}},{key:"hasHabitat",value:function(e){return null!==e.getAttribute(p)}},{key:"destroy",value:function(e){try{void 0!==e[f]&&e.parentNode.insertBefore(e[f],e)}finally{e.parentNode.removeChild(e)}}}]),e}();t.default=w,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function u(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return new p(e,t)}Object.defineProperty(t,"__esModule",{value:!0}),t._Mixin=void 0;var l=function(){function e(e,t){for(var n=0;t.length>n;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();t.createBootstrapper=u;var c=n(2),s=r(c),f=n(3),d=r(f),p=t._Mixin=function(e){function t(e,n){o(this,t);var r=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));if(!e.container)return console.warn('"Container" property was not supplied'),a(r);e.componentSelector&&(r.componentSelector=e.componentSelector),"boolean"==typeof e.enableWatcher&&(r.enableWatcher=e.enableWatcher);for(var i=new d.default,u=0;e.container.length>u;u++)i.register(e.container[u].register,e.container[u].for);return r._shouldUpdateProxy=e.shouldUpdate||null,r._willUpdateProxy=e.willUpdate||null,r._didUpdateProxy=e.didUpdate||null,r.setContainer(i,n),r}return i(t,e),l(t,[{key:"shouldUpdate",value:function(e){this._shouldUpdateProxy&&this._shouldUpdateProxy(e)}},{key:"willUpdate",value:function(){this._willUpdateProxy&&this._willUpdateProxy()}},{key:"didUpdate",value:function(){this._didUpdateProxy&&this._didUpdateProxy()}}]),t}(s.default)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;t.length>n;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=n(7),u=r(i),l=n(8),c=r(l),s=n(1),f=r(s),d=function(){function e(){o(this,e)}return a(e,null,[{key:"inject",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments[2];n?c.default.render(u.default.createElement(e,t||{}),n):f.default.warn("RHW07","Target element is null or undefined.")}},{key:"dispose",value:function(e){e&&c.default.unmountComponentAtNode(e)}}]),e}();t.default=d,e.exports=t.default},function(t,n){t.exports=e},function(e,n){e.exports=t}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("React"),require("ReactDOM")):"function"==typeof define&&define.amd?define(["React","ReactDOM"],t):"object"==typeof exports?exports.ReactHabitat=t(require("React"),require("ReactDOM")):e.ReactHabitat=t(e.React,e.ReactDOM)}(this,function(e,t){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(2),a=r(o),i=n(3),u=r(i),l=n(5);t.default={Bootstrapper:a.default,Container:u.default,createBootstrapper:l.createBootstrapper},e.exports=t.default},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;t.length>n;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(){},i=a,u=a,l="http://tinyurl.com/jxryd3s",c=function(){function e(){r(this,e)}return o(e,null,[{key:"warn",value:function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];var a=u("WARNING: "+e+" "+t+" "+l+"#"+e.toLowerCase(),r);i("warn",a)}},{key:"error",value:function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];var a=u("ERROR: "+e+" "+t+" "+l+"#"+e.toLowerCase(),r);i("error",a)}}]),e}();t.default=c,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if("function"==typeof e){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];e.call.apply(e,[t].concat(r))}}function i(e,t,n){for(var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=e.domFactory(),i=e.id(),u=[],l=function(r){var a=t[r];if(c.default.hasHabitat(a))return"continue";var l=a.getAttribute(n);u.push(e.resolve(l).then(function(e){var t=e;e.__esModule&&e.default&&(t=e.default),o.inject(t,c.default.parseProps(a),c.default.create(a,i))}).catch(function(e){f.default.error("RHW01",'Cannot resolve component "'+l+'" for element.',e,a)}))},s=0;t.length>s;++s){l(s)}Promise.all(u.map(function(e){return e.catch(function(e){return e})})).then(function(){a(r)}).catch(function(e){throw e})}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;t.length>n;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(4),c=r(l),s=n(1),f=r(s),d="data-component",p=function(){function e(){if(o(this,e),!window||!window&&!window.document)throw Error("React Habitat requires a window but cannot see one :(");this.componentSelector=d,this._container=null,this._observer=null,this._isWatching=!1}return u(e,[{key:"setContainer",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return null!==this._container?void f.default.error("RHW02","A container is already set. Please call dispose() before assigning a new one."):(this._container=e,void this.update(null,function(){a(n,t)}))}},{key:"update",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!this._container)return void a(n);var r=e||window.document.body.querySelectorAll("["+this.componentSelector+"]");if("function"==typeof this.shouldUpdate&&this.shouldUpdate(r)===!1)return void a(n,this);var o=this._isWatching;o&&this.stopWatcher(),"function"==typeof this.willUpdate&&this.willUpdate(r),i(this._container,r,this.componentSelector,function(){o&&t.startWatcher(),"function"==typeof t.didUpdate&&t.didUpdate(r),a(n,t)})}},{key:"startWatcher",value:function(){return"undefined"==typeof MutationObserver?void f.default.error("RHE09","MutationObserver not available."):(this._observer||(this._observer=new MutationObserver(this._handleDomMutation.bind(this))),this._observer.observe(window.document.body,{childList:!0,attributes:!0,subtree:!0,attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,attributeFilter:[this.componentSelector]}),void(this._isWatching=!0))}},{key:"stopWatcher",value:function(){this._observer&&this._observer.disconnect&&this._observer.disconnect(),this._isWatching=!1}},{key:"_handleDomMutation",value:function(e){if(void 0!==e){var t=e.filter(function(e){return e.addedNodes.length});t.length&&this.update()}else this.update()}},{key:"dispose",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.stopWatcher();for(var t=this._container.domFactory(),n=window.document.body.querySelectorAll('[data-habitat="'+this._container.id()+'"]'),r=0;n.length>r;++r)t.dispose(n[r]),c.default.destroy(n[r]);this._container=null,this._observer=null,this._isWatching=!1,a(e,this)}}]),e}();t.default=p,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;t.length>n;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u=n(6),l=r(u),c=function(){var e=0;return function(){return e+=1,"C"+e}}(),s=function(e){return!!e&&("object"===(void 0===e?"undefined":i(e))||"function"==typeof e)&&"function"==typeof e.then},f=function(){function e(){o(this,e),this._components={},this._id=c()}return a(e,[{key:"id",value:function(){return this._id}},{key:"register",value:function(e,t){if("string"!=typeof e)throw Error("Unexpected component key. Expects a string.",e);this._components[e]=t}},{key:"registerAll",value:function(e){if("object"!==(void 0===e?"undefined":i(e)))throw Error("Unexpected components type. Expects type object",e);Object.assign(this._components,e)}},{key:"resolve",value:function(e){var t=this._components[e];return t?s(t)?t:Promise.resolve(t):Promise.reject(Error("Not Registered"))}},{key:"domFactory",value:function(){return l.default}}]),e}();t.default=f,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e){var t=e.currentStyle||window.getComputedStyle(e,"");return t.display}function i(e){return e[1].toUpperCase()}function u(e,t){return t.replace(e,"").replace(/-([a-z])/g,i)}Object.defineProperty(t,"__esModule",{value:!0});var l=function(){function e(e,t){for(var n=0;t.length>n;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(1),s=r(c),f="habitatHostElement",d="data-habitat",p="data-has-habitat",h="data-prop-",y="data-props",v="data-n-prop-",b="data-r-prop-",m=!1,_=function(){function e(){o(this,e)}return l(e,null,[{key:"parseProps",value:function(e){for(var t={proxy:e},n=0;e.attributes.length>n;n++){var r=e.attributes[n];if(0===r.name.indexOf(h)){var o=u(h,r.name),a=r.value||"";"string"==typeof a&&"false"===a.toLowerCase()&&(a=!1),"string"==typeof a&&"true"===a.toLowerCase()&&(a=!0),"string"==typeof a&&a.length>=2&&("{"===a[0]&&"}"===a[a.length-1]||"["===a[0]&&"]"===a[a.length-1])&&(a=JSON.parse(a)),"string"==typeof a&&"null"===a.toLowerCase()&&(a=null),t[o]=a}else if(r.name===y)Object.assign(t,JSON.parse(r.value));else if(0===r.name.indexOf("data-n-prop-")){var i=u(v,r.name);t[i]=parseFloat(r.value)}else if(window&&0===r.name.indexOf(b)){var l=u(b,r.name);t[l]=window[r.value]}}return t}},{key:"create",value:function(e,t){if(window.document.body===e||null===e||void 0===e)return s.default.warn("RHW04","Cannot open a habitat for element.",e),null;var n="span";"block"===a(e)&&(n="div");var r=window.document.createElement(n),o=e.getAttribute("data-habitat-class")||null,i=!1;if(null!==e.getAttribute("data-habitat-no-replace")&&(i="true"===e.getAttribute("data-habitat-no-replace").toLocaleLowerCase()),r.setAttribute(d,t),o&&(r.className=""+o),e.parentNode.insertBefore(r,e.nextSibling),"INPUT"!==e.tagName){if(!i){var u=e.parentNode.removeChild(e);try{r[f]=u}catch(e){m&&(s.default.warn("RHW06","Arbitrary properties are disabled. The container may not dispose correctly.",e),m=!0)}}}else e.setAttribute(p,"true"),"hidden"!==e.getAttribute("type")&&e.setAttribute("style","display: none;");return r}},{key:"hasHabitat",value:function(e){return null!==e.getAttribute(p)}},{key:"destroy",value:function(e){try{void 0!==e[f]&&e.parentNode.insertBefore(e[f],e)}finally{e.parentNode.removeChild(e)}}}]),e}();t.default=_,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function u(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return new p(e,t)}Object.defineProperty(t,"__esModule",{value:!0}),t._Mixin=void 0;var l=function(){function e(e,t){for(var n=0;t.length>n;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();t.createBootstrapper=u;var c=n(2),s=r(c),f=n(3),d=r(f),p=t._Mixin=function(e){function t(e,n){o(this,t);var r=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));if(!e.container)return console.warn('"Container" property was not supplied'),a(r);e.componentSelector&&(r.componentSelector=e.componentSelector),"boolean"==typeof e.enableWatcher&&(r.enableWatcher=e.enableWatcher);for(var i=new d.default,u=0;e.container.length>u;u++)i.register(e.container[u].register,e.container[u].for);return r._shouldUpdateProxy=e.shouldUpdate||null,r._willUpdateProxy=e.willUpdate||null,r._didUpdateProxy=e.didUpdate||null,r.setContainer(i,n),r}return i(t,e),l(t,[{key:"shouldUpdate",value:function(e){this._shouldUpdateProxy&&this._shouldUpdateProxy(e)}},{key:"willUpdate",value:function(){this._willUpdateProxy&&this._willUpdateProxy()}},{key:"didUpdate",value:function(){this._didUpdateProxy&&this._didUpdateProxy()}}]),t}(s.default)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;t.length>n;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=n(7),u=r(i),l=n(8),c=r(l),s=n(1),f=r(s),d=function(){function e(){o(this,e)}return a(e,null,[{key:"inject",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments[2];n?c.default.render(u.default.createElement(e,t||{}),n):f.default.warn("RHW07","Target element is null or undefined.")}},{key:"dispose",value:function(e){e&&c.default.unmountComponentAtNode(e)}}]),e}();t.default=d,e.exports=t.default},function(t,n){t.exports=e},function(e,n){e.exports=t}])});

@@ -32,2 +32,4 @@ 'use strict';

* @param {null|function} cb - The callback
* @param {object} context - The context of the callback
* @param {...object} args - Arguments to apply
* @private

@@ -47,6 +49,6 @@ */

* Apply a container to nodes and populate components
* @param {array} container The container
* @param {array} nodes The elements to parse
* @param {string} componentSelector The component selector
* @param {function} [cb=null] - Optional callback
* @param {array} container - The container
* @param {array} nodes - The elements to parse
* @param {string} componentSelector - The component selector
* @param {function} [cb=null] - Optional callback
* @private

@@ -73,3 +75,3 @@ */

var componentName = ele.getAttribute(componentSelector);
resolveQueue.push(container.resolve(componentName).then(function (component) {
resolveQueue.push(container.resolve(componentName).then(function (registration) {
// This is an expensive operation so only do on non prod builds

@@ -82,2 +84,11 @@ if (process.env.NODE_ENV !== 'production') {

// Handle any esModule's with default exports
// This helps developers out with writing cleaner container code otherwise
// they will need to wrap `import()`'s in Promises that return the default.. yuk
// https://github.com/webpack/webpack.js.org/pull/213
var component = registration;
if (registration.__esModule && registration.default) {
component = registration.default;
}
// Inject the component

@@ -84,0 +95,0 @@ factory.inject(component, _Habitat2.default.parseProps(ele), _Habitat2.default.create(ele, id));

{
"name": "react-habitat",
"version": "0.5.0-beta",
"version": "0.5.0-beta2",
"description": "A React DOM Bootstrapper designed to harmonise a hybrid application",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -624,5 +624,5 @@ ![Deloitte Digital](https://raw.githubusercontent.com/DeloitteDigital/DDBreakpoints/master/docs/deloittedigital-logo-white.png)

```javascript
container.register('AsynReactComponent', new Promise(function(resolve, reject) {
require.ensure(['./components/MyComponent'], function(MyComponent) {
resolve(MyComponent);
container.register('AsynReactComponent', new Promise(function(resolve) {
require.ensure(['./components/MyComponent'], function() {
resolve(require('./components/MyComponent'));
});

@@ -629,0 +629,0 @@ }));

@@ -623,5 +623,5 @@ ![Deloitte Digital](https://raw.githubusercontent.com/DeloitteDigital/DDBreakpoints/master/docs/deloittedigital-logo-white.png)

```javascript
container.register('AsynReactComponent', new Promise((resolve, reject) => {
require.ensure(['./components/MyComponent'], (MyComponent) => {
resolve(MyComponent);
container.register('AsynReactComponent', new Promise((resolve) => {
require.ensure(['./components/MyComponent'], () => {
resolve(require('./components/MyComponent'));
});

@@ -628,0 +628,0 @@ }));

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc