styletron-react-lite
Version:
A lightweight styletron binding for React.
16 lines (13 loc) • 3.67 kB
JavaScript
import t,{createContext as n,useContext as e}from"react";import{Server as r,Client as o}from"styletron-engine-atomic";import{driver as i}from"styletron-standard";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */var u=function(t,n){return(u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)};var c=function(){return(c=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t}).apply(this,arguments)},a="Invariant Violation",s=Object.setPrototypeOf,f=void 0===s?function(t,n){return t.__proto__=n,t}:s,l=function(t){function n(e){void 0===e&&(e=a);var r=t.call(this,"number"==typeof e?a+": "+e+" (see https://github.com/apollographql/invariant-packages)":e)||this;return r.framesToPop=1,r.name=a,f(r,n.prototype),r}return function(t,n){function e(){this.constructor=t}u(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}(n,t),n}(Error);function p(t,n){if(!t)throw new l}function y(t){return function(){return console[t].apply(console,arguments)}}!function(t){t.warn=y("warn"),t.error=y("error")}(p||(p={}));var v,g={env:{}};if("object"==typeof process)g=process;else try{Function("stub","process = stub")(g)}catch(t){}function h(){return v||(v=n({})),v}function d(n){var e=h();return t.createElement(e.Consumer,null,(function(t){return p(t&&t.engine),n.children(t.engine)}))}function m(n){var e=h();return t.createElement(e.Consumer,null,(function(r){return void 0===r&&(r={}),r&&r.engine!==n.engine&&(r=Object.assign({},r,{engine:n.engine})),p(r.engine),t.createElement(e.Provider,{value:r},n.children)}))}var _="_styletron_hydrate_",b="._styletron_hydrate_",w={styleTagQuerySelector:"._styletron_hydrate_"},O=function(){function t(t){var n=this;void 0===t&&(t=w),this.options=t,this.getHydratableElements=function(){return document.querySelectorAll(n.options.styleTagQuerySelector)},this.options=t}return t.prototype.get=function(){return"undefined"==typeof window?new r:new o({hydrate:this.getHydratableElements()})},t.prototype.getClient=function(){return new o({hydrate:this.getHydratableElements()})},t.prototype.getServer=function(){return new r},t}();function E(t){return new O(t)}var j=E();function P(){return j.getClient()}function S(){return j.getServer()}function C(){var t=h(),n=e(t).engine;return p(n),n}function H(){var t=C();return function(n){return i(n,t)}}var T=function(n){return function(e){var r=C();return t.createElement(n,c({},e,{styletron:r}))}};export{_ as DEFAULT_STYLETRON_HYDRATE_CLASS_NAME,b as DEFAULT_STYLETRON_HYDRATE_QUERY_SELECTOR,O as StyletronAtomicEngineProvider,d as StyletronConsumer,m as StyletronProvider,E as getAtomicProvider,P as getStyletronClient,S as getStyletronServer,C as useStyletron,H as useStyletronDriver,T as withStyletron};