effcss 2.2.0 → 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,75 +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 _prefix: string;
9
- protected _counter: number;
10
- protected _keys: Set<string>;
11
- protected _configs: Map<TStyleSheetConfig, string>;
12
- constructor(params: {
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 _collector: IStyleCollector;
41
- protected _resolver: IStyleResolver;
42
- protected _initcls: string;
43
- protected _mainConfig: {
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>]>) => Record<string, string>;
69
- toString(): string;
70
- }
71
- /**
72
- * Basic class for manipulating stylesheets
73
- */
74
- export declare function createPseudoDispatcher(params?: IPseudoDispatcherParams): PseudoDispatcher;
75
- export {};
@@ -1,2 +0,0 @@
1
- declare const _default: import("vite").UserConfig;
2
- export default _default;
@@ -1 +0,0 @@
1
- import{PROVIDER_TAG_NAME as e}from"../constants.js";const s=(s,i)=>{var o,u;return void 0===s&&(s=window.document),void 0===i&&(i=(null===(o=window.__EFFCSS_PARAMS__)||void 0===o?void 0:o.name)||e),null===(u=null==s?void 0:s.getElementsByTagName(i))||void 0===u?void 0:u[0]},i=(e,i,o=s())=>o.use(e,i),o=(e,i=s())=>null==i?void 0:i.usePublic(e),u=(e,i=s())=>null==i?void 0:i.usePrivate(e),r=(e,i=s())=>i.resolve(e),t=(e,i=s())=>null==i?void 0:i.get(e),l=(e,i=s())=>null==i?void 0:i.getMany(e),n=(e,i=s())=>{var o;return[...(null===(o=t(e,i))||void 0===o?void 0:o.cssRules)||[]].map((e=>e.cssText)).join("")},v=(e,i=s())=>[...l(e,i)||[]].reduce(((e,s)=>e+[...(null==s?void 0:s.cssRules)||[]].map((e=>e.cssText)).join("")),""),d=(e,i=s())=>{var o;return function e(s){return s?s.length+[...s].reduce(((s,i)=>s+e(null==i?void 0:i.cssRules)),0):0}(null===(o=t(e,i))||void 0===o?void 0:o.cssRules)},c=(e,i=s())=>e.reduce(((e,s)=>e+d(s,i)),0);class a{constructor(e){this.use=(...e)=>this._provider.use(...e),this.usePublic=e=>this._provider.usePublic(e),this.usePrivate=e=>this._provider.usePrivate(e),this.resolve=e=>this._provider.resolve(e);const{root:i,tag:o}=e||{};this._provider=s(i,o)}}function h(e){return new a(e)}export{h as createDispatcher,l as getManyStyleSheets,s as getProvider,t as getStyleSheet,c as measureMany,d as measureOne,r as resolveStyleSheet,v as stringifyMany,n as stringifyOne,u as usePrivateStyleSheets,o 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(" "),n=(t,e)=>Object.defineProperties({[t]:e},{k:{value:t},v:{value:e}}),o=(...t)=>"--"+t.join("-"),r=(...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=>o=>{let r=o||"";e(r)&&(r=i(r));const c=t+(s?"__"+s:"");return r=c+(r?" "+(null==r?void 0:r.split(" ").map((t=>c+"_"+t.split("-").join("_"))).join(" ")):""),n("class",r)},varName:o,kfName:r}:{selector:({b:t,e:e,m:s,mv:i})=>`[data-${t}${e?"-"+e:""}${s?'~="'+(s||"")+(i?"-"+i:"")+'"':""}]`,attr:t=>s=>o=>{const r=`data-${t}${s?"-"+s:""}`;let c=o||"";return e(c)&&(c=i(c)),n(r,c)},varName:o,kfName:r}};class i{constructor(t){this._counter=0,this._keys=new Set,this._configs=new Map,this.use=(t,e)=>{const s=this._configs.get(t);if(s)return s;const i=e||this._prefix+this._counter.toString(36);return this._keys.add(i),this._configs.set(t,i),this._counter++,i},this.mutate=(t,e)=>Object.assign(this.getConfigs()[t],e),this.getKey=t=>this._configs.get(t),this.getKeys=()=>[...this._keys],this.getConfigs=()=>Object.fromEntries(this._configs.entries().map((([t,e])=>[e,t]))),this._prefix=(null==t?void 0:t.prefix)||"eff",t.initContent&&Object.entries(t.initContent).forEach((([t,e])=>this.use(e,t))),t.hydrate&&(this._counter=0)}}function n(t){return new i(t)}class o{get collector(){return this._collector}constructor(e){this._mainConfig={c:{}},this.use=(t,e)=>{let s=this._collector.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._resolver.attr(t||this._collector.getKey(this._mainConfig));const{prefix:i,mode:o,initcls:r=t}=e||{};this._initcls=r,this._resolver=s({mode:o}),this._collector=n({prefix:i}),this.use(this._mainConfig)}toString(){const t=this._collector.getConfigs(),e=this._collector.getKey(this._mainConfig);return e&&delete t[e],`<script class="${this._initcls}" type="application/json">${JSON.stringify(t)}<\/script>`}}function r(t){return new o(t)}export{n as createCollector,r as createPseudoDispatcher,s as createResolver};