effcss 2.2.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,77 +0,0 @@
1
- import { TCreateResolver, IStyleCollector, TStyleSheetConfig, TProviderInitContent, TStyleMode, IStyleDispatcher, IStyleResolver } from '../types';
2
- /**
3
- * Create BEM resolver
4
- * @param params - BEM resolver params
5
- */
6
- export declare const createResolver: TCreateResolver;
7
- declare class Collector implements IStyleCollector {
8
- protected _p: string;
9
- protected _c: number;
10
- protected _k: Set<string>;
11
- protected _: Map<TStyleSheetConfig, string>;
12
- constructor({ prefix, initContent, hydrate }?: {
13
- prefix?: string;
14
- initContent?: TProviderInitContent;
15
- hydrate?: boolean;
16
- });
17
- use: (config: TStyleSheetConfig, key?: string) => string;
18
- mutate: (key: string, nextConfig: TStyleSheetConfig) => TStyleSheetConfig;
19
- getKey: (config: TStyleSheetConfig) => string | undefined;
20
- getKeys: () => string[];
21
- getConfigs: () => {
22
- [k: string]: TStyleSheetConfig;
23
- };
24
- }
25
- /**
26
- * Create stylesheet config collector
27
- * @param params - collector params
28
- */
29
- export declare function createCollector(params: {
30
- prefix?: string;
31
- initContent?: TProviderInitContent;
32
- hydrate?: boolean;
33
- }): Collector;
34
- interface IPseudoDispatcherParams {
35
- mode?: TStyleMode;
36
- prefix?: string;
37
- initcls?: string;
38
- }
39
- declare class PseudoDispatcher implements IStyleDispatcher {
40
- protected _c: IStyleCollector;
41
- protected _r: IStyleResolver;
42
- protected _i: string;
43
- protected _m: {
44
- c: {};
45
- };
46
- get collector(): IStyleCollector;
47
- constructor(params?: IPseudoDispatcherParams);
48
- /**
49
- * Use stylesheet config
50
- * @param config - stylesheet config
51
- * @returns BEM resolver
52
- */
53
- use: IStyleDispatcher['use'];
54
- /**
55
- * Use public stylesheet configs
56
- * @param configs - stylesheet configs
57
- */
58
- usePublic: IStyleDispatcher['usePublic'];
59
- /**
60
- * Use private stylesheet configs
61
- * @param configs - stylesheet configs
62
- */
63
- usePrivate: IStyleDispatcher['usePrivate'];
64
- /**
65
- * Resolve styles
66
- * @param key - stylesheet key
67
- */
68
- resolve: (key?: string) => <E extends string>(e?: E) => <M extends Record<string, Record<string, string | number | (boolean | undefined) | null>>>(m?: string | Partial<M[NoInfer<E>]>) => {
69
- [x: string]: string;
70
- };
71
- toString(): string;
72
- }
73
- /**
74
- * Basic class for manipulating stylesheets
75
- */
76
- export declare function createPseudoDispatcher(params?: IPseudoDispatcherParams): PseudoDispatcher;
77
- export {};
@@ -1 +0,0 @@
1
- import{PROVIDER_TAG_NAME as e}from"../constants.js";const s=(s,i)=>{var u,o;return void 0===s&&(s=window.document),void 0===i&&(i=null===(u=window.__EFFCSS_PARAMS__)||void 0===u?void 0:u.name),null===(o=null==s?void 0:s.getElementsByTagName(i||e))||void 0===o?void 0:o[0]},i=(e,i,u=s())=>u.use(e,i),u=(e,i=s())=>null==i?void 0:i.usePublic(e),o=(e,i=s())=>null==i?void 0:i.usePrivate(e),t=(e,i=s())=>i.resolve(e),l=(e,i=s())=>null==i?void 0:i.get(e),n=(e,i=s())=>null==i?void 0:i.getMany(e),r=(e,i=s())=>{var u;return[...(null===(u=l(e,i))||void 0===u?void 0:u.cssRules)||[]].map((e=>e.cssText)).join("")},v=(e,i=s())=>[...n(e,i)||[]].reduce(((e,s)=>e+[...(null==s?void 0:s.cssRules)||[]].map((e=>e.cssText)).join("")),""),d=(e,i=s())=>{var u;return function e(s){return s?s.length+[...s].reduce(((s,i)=>s+e(null==i?void 0:i.cssRules)),0):0}(null===(u=l(e,i))||void 0===u?void 0:u.cssRules)},c=(e,i=s())=>e.reduce(((e,s)=>e+d(s,i)),0);class a{constructor(e){this.use=(...e)=>this._p.use(...e),this.usePublic=e=>this._p.usePublic(e),this.usePrivate=e=>this._p.usePrivate(e),this.resolve=e=>this._p.resolve(e);const{root:i,tag:u}=e||{};this._p=s(i,u)}}function h(e){return new a(e)}export{h as createDispatcher,n as getManyStyleSheets,s as getProvider,l as getStyleSheet,c as measureMany,d as measureOne,t as resolveStyleSheet,v as stringifyMany,r as stringifyOne,o as usePrivateStyleSheets,u as usePublicStyleSheets,i as useStyleSheet};
@@ -1 +0,0 @@
1
- import{STYLES_SCRIPT_CLS as t}from"../constants.js";const e=t=>"object"==typeof t,s=t=>{const{mode:s}=t||{},i=t=>Object.entries(t).reduce(((t,[e,s])=>(void 0!==s&&t.push(e+(s?"-"+s:"")),t)),[]).join(" "),r=(t,e)=>Object.defineProperties({[t]:e},{k:{value:t},v:{value:e}}),n=(...t)=>"--"+t.join("-"),c=(...t)=>t.join("-");return"c"===s?{selector:({b:t,e:e,m:s,mv:i})=>`.${t}${(e?"__"+e:"")+(s?"_"+s:"")+(s&&i?"_"+i:"")}`,attr:t=>s=>n=>{let c=n||"";e(c)&&(c=i(c));const o=t+(s?"__"+s:"");return c=o+(c?" "+(null==c?void 0:c.split(" ").map((t=>o+"_"+t.split("-").join("_"))).join(" ")):""),r("class",c)},varName:n,kfName:c}:{selector:({b:t,e:e,m:s,mv:i})=>`[data-${t}${e?"-"+e:""}${s?'~="'+(s||"")+(i?"-"+i:"")+'"':""}]`,attr:t=>s=>n=>{const c=`data-${t}${s?"-"+s:""}`;let o=n||"";return e(o)&&(o=i(o)),r(c,o)},varName:n,kfName:c}};class i{constructor({prefix:t,initContent:e,hydrate:s}={}){this._c=0,this._k=new Set,this._=new Map,this.use=(t,e)=>{const s=this._.get(t);if(s)return s;const i=e||this._p+this._c.toString(36);return this._k.add(i),this._.set(t,i),this._c++,i},this.mutate=(t,e)=>Object.assign(this.getConfigs()[t],e),this.getKey=t=>this._.get(t),this.getKeys=()=>[...this._k],this.getConfigs=()=>Object.fromEntries(this._.entries().map((([t,e])=>[e,t]))),this._p=t||"eff",e&&Object.entries(e).forEach((([t,e])=>this.use(e,t))),s&&(this._c=0)}}function r(t){return new i(t)}class n{get collector(){return this._c}constructor(e){this._m={c:{}},this.use=(t,e)=>{let s=this._c.use(t,e);return this.resolve(s)},this.usePublic=t=>Object.fromEntries(Object.entries(t).map((([t,e])=>[t,this.use(e,t)]))),this.usePrivate=t=>t.map((t=>this.use(t))),this.resolve=t=>this._r.attr(t||this._c.getKey(this._m));const{prefix:i,mode:n,initcls:c=t}=e||{};this._i=c,this._r=s({mode:n}),this._c=r({prefix:i}),this.use(this._m)}toString(){const t=this._c.getConfigs(),e=this._c.getKey(this._m);return e&&delete t[e],`<script class="${this._i}" type="application/json">${JSON.stringify(t)}<\/script>`}}function c(t){return new n(t)}export{r as createCollector,c as createPseudoDispatcher,s as createResolver};