Comparing version 0.100.0 to 0.101.0
@@ -1,72 +0,2 @@ | ||
import { createEvent, createStore } from 'effector'; | ||
import { h, node, spec, } from 'forest'; | ||
import { serialize, compile, stringify } from 'stylis'; | ||
import { domElements } from './elements'; | ||
const addStyle = createEvent(); | ||
const $styles = createStore({ map: new Map() }); | ||
export function StyledRoot() { | ||
const text = $styles.map(({ map }) => [...map.values()].join(' ')); | ||
h('style', { text }); | ||
} | ||
$styles.on(addStyle, (state, { id, styles }) => { | ||
if (state.map.has(id)) | ||
return state; | ||
state.map.set(id, make(id, styles)); | ||
return { map: state.map }; | ||
}); | ||
function make(id, styles) { | ||
return serialize(compile(`.es-${id} { ${styles} }`), stringify); | ||
} | ||
const idCount = () => { | ||
let id = 9005000; | ||
return () => (++id).toString(36); | ||
}; | ||
const styledId = idCount(); | ||
function join(strings, interps) { | ||
const result = [strings[0]]; | ||
interps.forEach((part, index) => { | ||
if (typeof part === 'function') { | ||
if (typeof part.STYLED_ID === 'string') { | ||
result.push(`.es-${part.STYLED_ID}`); | ||
} | ||
else { | ||
throw new TypeError('Passed not an effector styled component'); | ||
} | ||
} | ||
else { | ||
result.push(String(part)); | ||
} | ||
result.push(strings[index + 1]); | ||
}); | ||
return result.join(''); | ||
} | ||
const fabric = (tag) => (content, ...interpolations) => { | ||
const id = styledId(); | ||
const styles = join(content, interpolations); | ||
const Component = (config) => { | ||
addStyle({ id, styles }); | ||
h(tag, () => { | ||
node((reference) => { | ||
reference.classList.add(`es-${id}`); | ||
}); | ||
if (config) { | ||
if (typeof config === 'function') { | ||
config(); | ||
} | ||
else { | ||
spec(config); | ||
if (typeof config.fn === 'function') { | ||
config.fn(); | ||
} | ||
} | ||
} | ||
}); | ||
}; | ||
Component.STYLED_ID = id; | ||
return Component; | ||
}; | ||
domElements.forEach((element) => { | ||
fabric[element] = fabric(element); | ||
}); | ||
export const styled = fabric; | ||
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=3)}([function(e,t){e.exports=require("forest")},function(e,t){e.exports=require("stylis")},function(e,t){e.exports=require("effector")},function(e,t,r){"use strict";r.r(t),r.d(t,"StyledRoot",(function(){return u})),r.d(t,"styled",(function(){return p}));var n=r(2),o=r(0),i=r(1);const a=Object(n.createEvent)(),s=Object(n.createStore)({map:new Map});function u(){const e=s.map(({map:e})=>[...e.values()].join(" "));Object(o.h)("style",{text:e})}s.on(a,(e,{id:t,styles:r})=>e.map.has(t)?e:(e.map.set(t,function(e,t){return Object(i.serialize)(Object(i.compile)(`.es-${e} { ${t} }`),i.stringify)}(t,r)),{map:e.map}));const c=(()=>{let e=9005e3;return()=>(++e).toString(36)})();const l=e=>(t,...r)=>{const n=c(),i=function(e,t){const r=[e[0]];return t.forEach((t,n)=>{if("function"==typeof t){if("string"!=typeof t.STYLED_ID)throw new TypeError("Passed not an effector styled component");r.push(".es-"+t.STYLED_ID)}else r.push(String(t));r.push(e[n+1])}),r.join("")}(t,r),s=t=>{a({id:n,styles:i}),Object(o.h)(e,()=>{Object(o.node)(e=>{e.classList.add("es-"+n)}),t&&("function"==typeof t?t():(Object(o.spec)(t),"function"==typeof t.fn&&t.fn()))})};return s.STYLED_ID=n,s};["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","marquee","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"].forEach(e=>{l[e]=l(e)});const p=l}]); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "foliage", | ||
"version": "0.100.0", | ||
"version": "0.101.0", | ||
"description": "Styled Components for forest", | ||
@@ -12,3 +12,3 @@ "main": "dist/index.js", | ||
"lint": "eslint ./", | ||
"build": "tsc --build tsconfig.json", | ||
"build": "webpack", | ||
"format": "prettier --write \"./src/**/**.{ts,tsx,js,jsx,json}\"", | ||
@@ -21,10 +21,11 @@ "start": "parcel example/index.html --no-cache", | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"files": ["dist"], | ||
"keywords": [ | ||
"styled", | ||
"components", | ||
"dom", | ||
"effector", | ||
"components", | ||
"dom" | ||
"foliage", | ||
"forest", | ||
"style", | ||
"styled" | ||
], | ||
@@ -40,2 +41,5 @@ "author": "Sergey Sova <mail@sergeysova.com> (https://sergeysova.com/)", | ||
"@atomix/eslint-config": "^8.0.0", | ||
"@babel/core": "^7.10.2", | ||
"@babel/preset-env": "^7.10.2", | ||
"@babel/preset-typescript": "^7.10.1", | ||
"@commitlint/cli": "^8.3.5", | ||
@@ -65,4 +69,8 @@ "@commitlint/config-conventional": "^8.3.4", | ||
"sharec-sova-config": "^0.1.0", | ||
"terser-webpack-plugin": "^3.0.2", | ||
"ts-loader": "^7.0.5", | ||
"typescript": "^3.8.3", | ||
"typescript-styled-plugin": "^0.15.0" | ||
"typescript-styled-plugin": "^0.15.0", | ||
"webpack": "^4.43.0", | ||
"webpack-cli": "^3.3.11" | ||
}, | ||
@@ -69,0 +77,0 @@ "sharec": { |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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 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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
20725
1
34
6
49
4