@webflow/emotion-utils
Advanced tools
| import React from 'react'; | ||
| import { Options } from '@emotion/cache'; | ||
| declare const EmotionCacheShadowDomProvider: React.FC<{ | ||
| options?: Options; | ||
| children: React.ReactNode; | ||
| }>; | ||
| export { EmotionCacheShadowDomProvider }; |
+6
-0
| # @webflow/emotion-utils | ||
| ## 0.0.3 | ||
| ### Patch Changes | ||
| - Update type declarations | ||
| ## 0.0.2 | ||
@@ -4,0 +10,0 @@ |
+65
-1
@@ -1,1 +0,65 @@ | ||
| 'use strict';var r=require('react'),f=require('@emotion/cache'),react=require('@emotion/react');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var r__default=/*#__PURE__*/_interopDefault(r);var f__default=/*#__PURE__*/_interopDefault(f);var u=({children:c,options:n})=>{let e=r.useRef(null),[o,a]=r.useState(null);return r.useEffect(()=>{if(e.current){let t=e.current.getRootNode(),i=t instanceof ShadowRoot?t:document.head,s=f__default.default({key:"webflow",container:i,speedy:false,...n});a(s);}},[]),o?r__default.default.createElement(react.CacheProvider,{value:o},c):r__default.default.createElement("div",{ref:e})};exports.EmotionCacheShadowDomProvider=u; | ||
| "use strict"; | ||
| var __create = Object.create; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __getProtoOf = Object.getPrototypeOf; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __export = (target, all) => { | ||
| for (var name in all) | ||
| __defProp(target, name, { get: all[name], enumerable: true }); | ||
| }; | ||
| var __copyProps = (to, from, except, desc) => { | ||
| if (from && typeof from === "object" || typeof from === "function") { | ||
| for (let key of __getOwnPropNames(from)) | ||
| if (!__hasOwnProp.call(to, key) && key !== except) | ||
| __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
| } | ||
| return to; | ||
| }; | ||
| var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
| // If the importer is in node compatibility mode or this is not an ESM | ||
| // file that has been converted to a CommonJS file using a Babel- | ||
| // compatible transform (i.e. "__esModule" has not been set), then set | ||
| // "default" to the CommonJS "module.exports" for node compatibility. | ||
| isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
| mod | ||
| )); | ||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
| // src/index.ts | ||
| var src_exports = {}; | ||
| __export(src_exports, { | ||
| EmotionCacheShadowDomProvider: () => EmotionCacheShadowDomProvider | ||
| }); | ||
| module.exports = __toCommonJS(src_exports); | ||
| // src/EmotionCacheShadowDomProvider.tsx | ||
| var import_react = __toESM(require("react"), 1); | ||
| var import_cache = __toESM(require("@emotion/cache"), 1); | ||
| var import_react2 = require("@emotion/react"); | ||
| var EmotionCacheShadowDomProvider = ({ children, options }) => { | ||
| const ref = (0, import_react.useRef)(null); | ||
| const [cache, setCache] = (0, import_react.useState)(null); | ||
| (0, import_react.useEffect)(() => { | ||
| if (ref.current) { | ||
| const root = ref.current.getRootNode(); | ||
| const container = root instanceof ShadowRoot ? root : document.head; | ||
| const emotionCache = (0, import_cache.default)({ | ||
| key: "webflow", | ||
| container, | ||
| speedy: false, | ||
| ...options | ||
| }); | ||
| setCache(emotionCache); | ||
| } | ||
| }, []); | ||
| if (!cache) { | ||
| return /* @__PURE__ */ import_react.default.createElement("div", { ref }); | ||
| } | ||
| return /* @__PURE__ */ import_react.default.createElement(import_react2.CacheProvider, { value: cache }, children); | ||
| }; | ||
| // Annotate the CommonJS export names for ESM import in node: | ||
| 0 && (module.exports = { | ||
| EmotionCacheShadowDomProvider | ||
| }); |
+28
-1
@@ -1,1 +0,28 @@ | ||
| import r,{useRef,useState,useEffect}from'react';import f from'@emotion/cache';import {CacheProvider}from'@emotion/react';var u=({children:c,options:n})=>{let e=useRef(null),[o,a]=useState(null);return useEffect(()=>{if(e.current){let t=e.current.getRootNode(),i=t instanceof ShadowRoot?t:document.head,s=f({key:"webflow",container:i,speedy:false,...n});a(s);}},[]),o?r.createElement(CacheProvider,{value:o},c):r.createElement("div",{ref:e})};export{u as EmotionCacheShadowDomProvider}; | ||
| // src/EmotionCacheShadowDomProvider.tsx | ||
| import React, { useEffect, useRef, useState } from "react"; | ||
| import createCache from "@emotion/cache"; | ||
| import { CacheProvider } from "@emotion/react"; | ||
| var EmotionCacheShadowDomProvider = ({ children, options }) => { | ||
| const ref = useRef(null); | ||
| const [cache, setCache] = useState(null); | ||
| useEffect(() => { | ||
| if (ref.current) { | ||
| const root = ref.current.getRootNode(); | ||
| const container = root instanceof ShadowRoot ? root : document.head; | ||
| const emotionCache = createCache({ | ||
| key: "webflow", | ||
| container, | ||
| speedy: false, | ||
| ...options | ||
| }); | ||
| setCache(emotionCache); | ||
| } | ||
| }, []); | ||
| if (!cache) { | ||
| return /* @__PURE__ */ React.createElement("div", { ref }); | ||
| } | ||
| return /* @__PURE__ */ React.createElement(CacheProvider, { value: cache }, children); | ||
| }; | ||
| export { | ||
| EmotionCacheShadowDomProvider | ||
| }; |
+22
-1
| { | ||
| "name": "@webflow/emotion-utils", | ||
| "version": "0.0.2", | ||
| "version": "0.0.3", | ||
| "type": "module", | ||
@@ -28,2 +28,8 @@ "license": "MIT", | ||
| ], | ||
| "scripts": { | ||
| "build": "rm -fr ./dist; tsup", | ||
| "lint": "eslint .", | ||
| "test": "jest tests --ci", | ||
| "test:local": "jest tests" | ||
| }, | ||
| "dependencies": {}, | ||
@@ -35,3 +41,18 @@ "peerDependencies": { | ||
| "react-dom": ">=18 <=19" | ||
| }, | ||
| "devDependencies": { | ||
| "@testing-library/react": "^14.0.0", | ||
| "@testing-library/jest-dom": "^6.0.0", | ||
| "@types/jest": "^29.2.3", | ||
| "@types/react": ">=18 <=19", | ||
| "@types/react-dom": ">=18 <=19", | ||
| "eslint-config-custom": "*", | ||
| "jest": "^29.3.1", | ||
| "jest-environment-jsdom": "^29.3.1", | ||
| "ts-jest": "^29.0.3", | ||
| "ts-node": "^10.9.1", | ||
| "tsconfig": "*", | ||
| "tsup": "^8.4.0", | ||
| "typescript": "^4.9.3" | ||
| } | ||
| } |
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
8981
56.79%8
14.29%98
Infinity%2
-50%0
-100%13
Infinity%