@firsthandjs/styled 0.1.0 → 0.2.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.
- package/dist/css.d.ts +7 -0
- package/dist/css.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +4 -4
package/dist/css.d.ts
CHANGED
|
@@ -54,6 +54,13 @@ export interface Compiled {
|
|
|
54
54
|
* contains a function of its own.
|
|
55
55
|
*/
|
|
56
56
|
export declare function compile(fragment: CssFragment, id: string, values?: boolean): Compiled;
|
|
57
|
+
/**
|
|
58
|
+
* Joins a fragment whose `static` flag has already been checked.
|
|
59
|
+
*
|
|
60
|
+
* Such a fragment has no slots, so `join` would need a resolver that can never
|
|
61
|
+
* run — an arrow no test could reach and no reader could explain.
|
|
62
|
+
*/
|
|
63
|
+
export declare function joinStatic(compiled: Compiled): string;
|
|
57
64
|
/** Joins the compiled chunks, asking for each block slot's text. */
|
|
58
65
|
export declare function join(compiled: Compiled, resolve: (slot: Slot) => string): string;
|
|
59
66
|
/** Resolves one block slot's value, including a nested fragment. */
|
package/dist/css.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../src/css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,yDAAyD;AACzD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC;CACrC;AAID;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,WAAW,CAEpF;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAE/D;AAED,8DAA8D;AAC9D,MAAM,WAAW,IAAI;IACnB,0EAA0E;IAC1E,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I,WAAW,CAE/D;AAED,8DAA8D;AAC9D,MAAM,WAAW,IAAI;IACnB,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;IACjC,oDAAoD;IACpD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC;CAC1D;AAED,MAAM,WAAW,QAAQ;IACvB;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAC5C,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IAChC,yDAAyD;IACzD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AA8BD;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,UAAO,GAAG,QAAQ,CAiDlF;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAErD;AAED,oEAAoE;AACpE,wBAAgB,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,MAAM,GAAG,MAAM,CAMhF;AAED,oEAAoE;AACpE,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAchD"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bind as
|
|
1
|
+
import{bind as F,signal as Y,useContext as _}from"@firsthandjs/core";import{component as D}from"@firsthandjs/dom";import{applyProp as K,insert as Q}from"@firsthandjs/dom/internal";var M=Symbol("firsthand.css");function x(e,...t){return{[M]:!0,strings:[...e],values:t}}function j(e){return typeof e=="object"&&e!==null&&M in e}function H(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n===":")return!0;if(n===";"||n==="{"||n==="}")return!1}return!1}function O(e){return e==null||e===!1||e===!0?"":String(e)}function C(e,t,n=!0){let o=[],s=[],a="",c=()=>{a!==""&&(s.push(a),a="")},g=p=>{for(let[h,w]of p.strings.entries()){if(a+=w,h>=p.values.length)continue;let m=p.values[h];if(j(m)){g(m);continue}if(typeof m!="function"){a+=O(m);continue}let i=o.length,v=n&&H(a)?"value":"block",k={kind:v,property:`--${t}-${String(i)}`,fn:m};o.push(k),v==="value"?a+=`var(${k.property})`:(c(),s.push(k))}};return g(e),c(),{chunks:s,slots:o,static:o.length===0}}function R(e){return e.chunks.join("")}function b(e,t){let n="";for(let o of e.chunks)n+=typeof o=="string"?o:t(o);return n}function $(e){if(j(e)){let t=C(e,"x");if(!t.static)throw new Error("A css`` fragment returned from an interpolation must not contain further functions.");return R(t)}return O(e)}var P=new Map,d=null;function y(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function J(){return d!==null&&d.isConnected||(d=document.createElement("style"),d.setAttribute("data-firsthand-styled",""),document.head.appendChild(d)),d}function T(e,t){let n=P.get(e);if(n!==void 0)return n.count++,!1;let o=document.createTextNode(t);return P.set(e,{node:o,count:1}),J().appendChild(o),!0}function V(e){let t=P.get(e);t!==void 0&&(--t.count>0||(P.delete(e),t.node.remove()))}function L(){P.clear(),d?.remove(),d=null}import{createContext as N,useContext as X}from"@firsthandjs/core";var q=Object.freeze({}),S=N(q,"theme");function z(){return X(S)}function U(e,t){return t==="children"||t==="class"||t.startsWith("$")?!1:t in e||t.startsWith("data-")||t.startsWith("aria-")||t.startsWith("on")||t==="style"||t==="role"}function Z(e,t){let n={};for(let o of Object.keys(e))Object.defineProperty(n,o,{enumerable:!0,get:()=>e[o]});return Object.defineProperty(n,"theme",{enumerable:!0,get:()=>t.value}),n}var ee=0,W=new WeakMap;function G(e,t){let n=typeof e=="string"?e:null,o=n===null?(W.get(e)??0)+1:0,s=`s${y(t.strings.join("|"))}${String(++ee)}`,a=i=>`.${i}`.repeat(o+1),c=C(t,s,n!==null),g=b(c,()=>""),p=`${s}-${y(g)}`,h=c.slots.some(i=>i.kind==="block");h||T(p,`${a(p)}{${g}}`);let m=D(i=>{let v=_(S),k=Z(i,v),f=n===null?null:document.createElement(n),E="",A=f===null?Y(""):null,I=r=>{let l=i.class,u=`${r}${typeof l=="string"&&l!==""?` ${l}`:""}`;u!==E&&(E=u,f===null?A.value=u:f.className=u)};h?F(()=>{let r=b(c,u=>$(u.fn(k))),l=`${s}-${y(r)}`;T(l,`${a(l)}{${r}}`),I(l)}):F(()=>{I(p)});for(let r of c.slots){if(r.kind!=="value")continue;let l=f;F(()=>{let u=r.fn(k),B=u==null||u===!1?"":String(u);l.style.setProperty(r.property,B)})}if(f===null){let r={};for(let l of Object.keys(i))l!=="class"&&Object.defineProperty(r,l,{enumerable:!0,get:()=>i[l]});return Object.defineProperty(r,"class",{enumerable:!0,get:()=>A.value}),e(r)}for(let r of Object.keys(i))U(f,r)&&F(()=>{K(f,r,i[r])});return Q(f,()=>i.children),f},void 0,`firsthand/styled:${s}`,n===null?`Styled(${e.name})`:`Styled(${n})`);return W.set(m,o),m}var te=new Proxy((e=>(t,...n)=>G(e,x(t,...n))),{get:(e,t)=>(n,...o)=>G(t,x(n,...o))});import{bind as ne,onCleanup as oe,useContext as re}from"@firsthandjs/core";import{component as se}from"@firsthandjs/dom";function ie(e,...t){let n=C(x(e,...t),"k",!1);if(!n.static)throw new Error("keyframes`` cannot interpolate functions: an animation has no props.");let o=R(n),s=`k${y(o)}`;return T(s,`@keyframes ${s}{${o}}`),s}function le(e,...t){let n=x(e,...t),o=C(n,"g",!1);return se(()=>{let a=re(S),c=null,g=()=>{c!==null&&(V(c),c=null)};return ne(()=>{let p={theme:a.value},h=b(o,m=>$(m.fn(p))),w=`g${y(h)}`;g(),T(w,h),c=w}),oe(g),null},void 0,`firsthand/styled:global${y(e.join("|"))}`,"GlobalStyle")}export{S as ThemeContext,le as createGlobalStyle,x as css,y as hash,j as isFragment,ie as keyframes,L as resetStyles,te as styled,z as useTheme};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firsthandjs/styled",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "CSS-in-JS for Firsthand: tagged templates, themes, and fine-grained style updates.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"LICENSE"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@firsthandjs/core": "0.
|
|
23
|
-
"@firsthandjs/dom": "0.
|
|
24
|
-
"@firsthandjs/jsx-runtime": "0.
|
|
22
|
+
"@firsthandjs/core": "0.2.0",
|
|
23
|
+
"@firsthandjs/dom": "0.2.0",
|
|
24
|
+
"@firsthandjs/jsx-runtime": "0.2.0"
|
|
25
25
|
},
|
|
26
26
|
"engines": {
|
|
27
27
|
"node": ">=20.11.0"
|