@manyducks.co/dolla-styled 0.0.1 → 0.0.2
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/bun.lock +4 -7
- package/dist/index.mjs +69 -63
- package/dist/registry.d.ts +21 -0
- package/dist/styled.d.ts +22 -4
- package/package.json +1 -2
- package/dist/sheet.d.ts +0 -9
package/bun.lock
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"configVersion": 1,
|
|
4
4
|
"workspaces": {
|
|
5
5
|
"": {
|
|
6
|
-
"name": "dolla-
|
|
6
|
+
"name": "@manyducks.co/dolla-styled",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"jsdom": "^29.1.1",
|
|
9
9
|
"stylis": "^4.4.0",
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
"@types/node": "^25.8.0",
|
|
15
15
|
"@types/stylis": "^4.2.7",
|
|
16
16
|
"lodash-es": "^4.18.1",
|
|
17
|
-
"nanoid": "^5.1.11",
|
|
18
17
|
"vite": "^8.0.14",
|
|
19
18
|
"vitest": "^4.1.7",
|
|
20
19
|
},
|
|
@@ -57,7 +56,7 @@
|
|
|
57
56
|
|
|
58
57
|
"@jridgewell/sourcemap-codec": ["@jridgewell/sourcemap-codec@1.5.5", "", {}, "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og=="],
|
|
59
58
|
|
|
60
|
-
"@manyducks.co/dolla": ["@manyducks.co/dolla@4.
|
|
59
|
+
"@manyducks.co/dolla": ["@manyducks.co/dolla@4.3.0", "", {}, "sha512-+gc3kzagDIgR1IBIPRln1dl8aVrY5/ByVc3WyRP6zSDnfmbZPSlcjnc8mLYQLhihEV5raVnsl/Z2hDpqvRsBWg=="],
|
|
61
60
|
|
|
62
61
|
"@napi-rs/wasm-runtime": ["@napi-rs/wasm-runtime@1.1.4", "", { "dependencies": { "@tybys/wasm-util": "^0.10.1" }, "peerDependencies": { "@emnapi/core": "^1.7.1", "@emnapi/runtime": "^1.7.1" } }, "sha512-3NQNNgA1YSlJb/kMH1ildASP9HW7/7kYnRI2szWJaofaS1hWmbGI4H+d3+22aGzXXN9IJ+n+GiFVcGipJP18ow=="],
|
|
63
62
|
|
|
@@ -111,7 +110,7 @@
|
|
|
111
110
|
|
|
112
111
|
"@types/lodash-es": ["@types/lodash-es@4.17.12", "", { "dependencies": { "@types/lodash": "*" } }, "sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ=="],
|
|
113
112
|
|
|
114
|
-
"@types/node": ["@types/node@25.
|
|
113
|
+
"@types/node": ["@types/node@25.9.1", "", { "dependencies": { "undici-types": ">=7.24.0 <7.24.7" } }, "sha512-xfrlY7UD5rMJk3ZVJP8BNzS28J36YJg+xp+LPXV1TdWxr8uMH5A860QNxYDGQe/ylDSgjxE52Q9VnO7p75tJxg=="],
|
|
115
114
|
|
|
116
115
|
"@types/stylis": ["@types/stylis@4.2.7", "", {}, "sha512-VgDNokpBoKF+wrdvhAAfS55OMQpL6QRglwTwNC3kIgBrzZxA4WsFj+2eLfEA/uMUDzBcEhYmjSbwQakn/i3ajA=="],
|
|
117
116
|
|
|
@@ -197,7 +196,7 @@
|
|
|
197
196
|
|
|
198
197
|
"mdn-data": ["mdn-data@2.27.1", "", {}, "sha512-9Yubnt3e8A0OKwxYSXyhLymGW4sCufcLG6VdiDdUGVkPhpqLxlvP5vl1983gQjJl3tqbrM731mjaZaP68AgosQ=="],
|
|
199
198
|
|
|
200
|
-
"nanoid": ["nanoid@
|
|
199
|
+
"nanoid": ["nanoid@3.3.12", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-ZB9RH/39qpq5Vu6Y+NmUaFhQR6pp+M2Xt76XBnEwDaGcVAqhlvxrl3B2bKS5D3NH3QR76v3aSrKaF/Kiy7lEtQ=="],
|
|
201
200
|
|
|
202
201
|
"obug": ["obug@2.1.1", "", {}, "sha512-uTqF9MuPraAQ+IsnPf366RG4cP9RtUi7MLO1N3KEc+wb0a6yKpeL0lmk2IB1jY5KHPAlTc6T/JRdC/YqxHNwkQ=="],
|
|
203
202
|
|
|
@@ -272,7 +271,5 @@
|
|
|
272
271
|
"xml-name-validator": ["xml-name-validator@5.0.0", "", {}, "sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg=="],
|
|
273
272
|
|
|
274
273
|
"xmlchars": ["xmlchars@2.2.0", "", {}, "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw=="],
|
|
275
|
-
|
|
276
|
-
"postcss/nanoid": ["nanoid@3.3.12", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-ZB9RH/39qpq5Vu6Y+NmUaFhQR6pp+M2Xt76XBnEwDaGcVAqhlvxrl3B2bKS5D3NH3QR76v3aSrKaF/Kiy7lEtQ=="],
|
|
277
274
|
}
|
|
278
275
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,87 +1,93 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { compile as
|
|
3
|
-
//#region
|
|
4
|
-
var
|
|
5
|
-
let t = "", n = crypto.getRandomValues(new Uint8Array(e |= 0));
|
|
6
|
-
for (; e--;) t += u[n[e] & 63];
|
|
7
|
-
return t;
|
|
8
|
-
}, f = new class {
|
|
1
|
+
import { compose as e, createMarkup as t, onEffect as n, unwrap as r } from "@manyducks.co/dolla";
|
|
2
|
+
import { compile as i, middleware as a, prefixer as o, serialize as s, stringify as c } from "stylis";
|
|
3
|
+
//#region src/registry.ts
|
|
4
|
+
var l = class {
|
|
9
5
|
el;
|
|
10
6
|
sheet;
|
|
11
7
|
cache;
|
|
12
8
|
constructor() {
|
|
13
|
-
this.el = document.createElement("style"), this.el.id = "dolla-
|
|
9
|
+
this.el = document.createElement("style"), this.el.id = "dolla-styled-static", document.head.appendChild(this.el), this.sheet = this.el.sheet, this.cache = /* @__PURE__ */ new Set();
|
|
14
10
|
}
|
|
15
11
|
insert(e, t) {
|
|
16
12
|
if (this.cache.has(e)) return;
|
|
17
|
-
let n =
|
|
18
|
-
{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this.sheet.insertRule(t, this.sheet.cssRules.length);
|
|
22
|
-
} catch {
|
|
23
|
-
console.warn("[Dolla] Failed to inject rule:", t);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
13
|
+
let n = s(i(`.${e}{${t}}`), a([o, c])).split(/(?<=\})\s*(?=[.#@a-zA-Z:\*])/g).map((e) => e.trim()).filter(Boolean);
|
|
14
|
+
for (let e of n) try {
|
|
15
|
+
this.sheet.insertRule(e, this.sheet.cssRules.length);
|
|
16
|
+
} catch {}
|
|
26
17
|
this.cache.add(e);
|
|
27
18
|
}
|
|
28
|
-
}
|
|
29
|
-
|
|
19
|
+
}, u = class {
|
|
20
|
+
sheet = new CSSStyleSheet();
|
|
21
|
+
ruleIndex = 0;
|
|
22
|
+
constructor() {
|
|
23
|
+
document.adoptedStyleSheets = [...document.adoptedStyleSheets, this.sheet];
|
|
24
|
+
}
|
|
25
|
+
createInstanceRule(e) {
|
|
26
|
+
let t = this.ruleIndex++;
|
|
27
|
+
return this.sheet.insertRule(`.${e} {}`, t), this.sheet.cssRules[t].style;
|
|
28
|
+
}
|
|
29
|
+
}, d = class {
|
|
30
|
+
registered = /* @__PURE__ */ new Set();
|
|
31
|
+
register(e, t, n) {
|
|
32
|
+
if (!(this.registered.has(e) || t === "*")) try {
|
|
33
|
+
CSS.registerProperty({
|
|
34
|
+
name: e,
|
|
35
|
+
syntax: t,
|
|
36
|
+
inherits: !1,
|
|
37
|
+
initialValue: n
|
|
38
|
+
}), this.registered.add(e);
|
|
39
|
+
} catch (t) {
|
|
40
|
+
console.warn(`[Dolla] Failed to register @property ${e}:`, t);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}, f = new l(), p = new u(), m = new d();
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/styled.ts
|
|
46
|
+
function h(e) {
|
|
30
47
|
let t = 0;
|
|
31
48
|
for (let n = 0; n < e.length; n++) t = Math.imul(31, t) + e.charCodeAt(n) | 0;
|
|
32
49
|
return "styled-" + Math.abs(t).toString(36);
|
|
33
50
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
51
|
+
var g = 0;
|
|
52
|
+
function _(i, a = {}) {
|
|
53
|
+
let o = {}, s = (a, ...s) => {
|
|
54
|
+
let c = h(a.join("||")), l = "", u = [];
|
|
55
|
+
return a.forEach((e, t) => {
|
|
38
56
|
if (l += e, t < s.length) {
|
|
39
|
-
let e = s[t], n = "*", r =
|
|
40
|
-
if (Array.isArray(e) && ([e, n, r =
|
|
41
|
-
let i =
|
|
42
|
-
l += `var(${i})`, u.push({
|
|
57
|
+
let e = s[t], n = "*", r = null;
|
|
58
|
+
if (Array.isArray(e) && ([e, n, r = null] = e), typeof e == "function") {
|
|
59
|
+
let i = `--${c}-${t}`;
|
|
60
|
+
r === null ? l += `var(${i})` : (l += `var(${i}, ${r})`, n !== "*" && m.register(i, n, r)), u.push({
|
|
43
61
|
varName: i,
|
|
44
|
-
fn: e
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
syntax: n,
|
|
48
|
-
initialValue: r,
|
|
49
|
-
inherits: !1
|
|
50
|
-
}), p.add(i));
|
|
62
|
+
fn: e,
|
|
63
|
+
initialValue: r
|
|
64
|
+
});
|
|
51
65
|
} else l += e;
|
|
52
66
|
}
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
}), f.insert(c, l), (a, s) => {
|
|
68
|
+
let l = [c];
|
|
69
|
+
if (u.length > 0) {
|
|
70
|
+
let e = `styled-inst-${(g++).toString(36)}`;
|
|
71
|
+
l.push(e);
|
|
72
|
+
let t = p.createInstanceRule(e);
|
|
73
|
+
n(s, () => {
|
|
74
|
+
u.forEach(({ varName: e, fn: n, initialValue: r }) => {
|
|
75
|
+
let i = n(a);
|
|
76
|
+
i == null || i === r ? t.removeProperty(e) : t.setProperty(e, i);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return t(typeof i == "string" && a.as || i, {
|
|
63
81
|
...o,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
...c()
|
|
67
|
-
})),
|
|
68
|
-
class: t(() => [o.class && i(o.class), h])
|
|
69
|
-
};
|
|
70
|
-
if (typeof a == "string") return s.name = `Styled(${a.toLowerCase()})`, n(o.as || a, {
|
|
71
|
-
...d,
|
|
72
|
-
ref: (e) => (f.insert(h, l), d.ref?.(e))
|
|
82
|
+
...a,
|
|
83
|
+
class: e(() => [a.class && r(a.class), ...l])
|
|
73
84
|
});
|
|
74
|
-
{
|
|
75
|
-
let t = new e(s, a, d);
|
|
76
|
-
return r(t.context, () => {
|
|
77
|
-
f.insert(h, l);
|
|
78
|
-
}), t;
|
|
79
|
-
}
|
|
80
85
|
};
|
|
81
86
|
};
|
|
87
|
+
return s.with = () => s, s.defaults = (e) => _(i, Object.assign({}, a, e)), s;
|
|
82
88
|
}
|
|
83
|
-
var
|
|
84
|
-
return
|
|
89
|
+
var v = new Proxy(_, { get(e, t) {
|
|
90
|
+
return _(t);
|
|
85
91
|
} });
|
|
86
92
|
//#endregion
|
|
87
|
-
export {
|
|
93
|
+
export { v as styled };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
declare class StaticRegistry {
|
|
2
|
+
el: HTMLStyleElement;
|
|
3
|
+
sheet: CSSStyleSheet;
|
|
4
|
+
cache: Set<string>;
|
|
5
|
+
constructor();
|
|
6
|
+
insert(className: string, rawCss: string): void;
|
|
7
|
+
}
|
|
8
|
+
declare class DynamicRegistry {
|
|
9
|
+
sheet: CSSStyleSheet;
|
|
10
|
+
ruleIndex: number;
|
|
11
|
+
constructor();
|
|
12
|
+
createInstanceRule(instanceClass: string): CSSStyleDeclaration;
|
|
13
|
+
}
|
|
14
|
+
declare class PropertyRegistry {
|
|
15
|
+
registered: Set<string>;
|
|
16
|
+
register(name: string, syntax: string, initialValue: any): void;
|
|
17
|
+
}
|
|
18
|
+
export declare const staticRegistry: StaticRegistry;
|
|
19
|
+
export declare const dynamicRegistry: DynamicRegistry;
|
|
20
|
+
export declare const propertyRegistry: PropertyRegistry;
|
|
21
|
+
export {};
|
package/dist/styled.d.ts
CHANGED
|
@@ -3,10 +3,28 @@ type StyledProps = {
|
|
|
3
3
|
as?: keyof JSX.IntrinsicElements | string;
|
|
4
4
|
};
|
|
5
5
|
type StyledView<Props> = View<Props & StyledProps>;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
type ApplyDefaults<Base, Defaults> = Omit<Base, keyof Defaults> & Partial<Pick<Base, Extract<keyof Base, keyof Defaults>>>;
|
|
7
|
+
type Flatten<T> = {
|
|
8
|
+
[K in keyof T]: T[K];
|
|
9
|
+
} & {};
|
|
10
|
+
interface TypedTemplateFn<Props> {
|
|
11
|
+
(strings: TemplateStringsArray, ...interpolations: any[]): StyledView<Props>;
|
|
12
|
+
/**
|
|
13
|
+
* Provides default props that are passed to all instances unless overridden.
|
|
14
|
+
*/
|
|
15
|
+
defaults<D extends Partial<Props>>(defaultProps: D): (strings: TemplateStringsArray, ...interpolations: any[]) => StyledView<Flatten<ApplyDefaults<Props, D>>>;
|
|
16
|
+
}
|
|
17
|
+
interface TemplateFn<BaseProps = {}> {
|
|
18
|
+
(strings: TemplateStringsArray, ...interpolations: any[]): StyledView<BaseProps>;
|
|
19
|
+
/**
|
|
20
|
+
* Defines additional props the resulting view takes.
|
|
21
|
+
*/
|
|
22
|
+
with<T>(): TypedTemplateFn<BaseProps & T>;
|
|
23
|
+
}
|
|
24
|
+
declare function createBuilder<Tag extends keyof JSX.IntrinsicElements>(tag: Tag, boundDefaults?: Partial<JSX.IntrinsicElements[Tag]>): TemplateFn<JSX.IntrinsicElements[Tag]>;
|
|
25
|
+
declare function createBuilder<Props>(view: View<Props>, boundDefaults?: Partial<Props>): TemplateFn<Props>;
|
|
26
|
+
type Styled = typeof createBuilder & {
|
|
27
|
+
[Tag in keyof JSX.IntrinsicElements]: TemplateFn<JSX.IntrinsicElements[Tag]>;
|
|
10
28
|
};
|
|
11
29
|
declare const _default: Styled;
|
|
12
30
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manyducks.co/dolla-styled",
|
|
3
3
|
"description": "Styled Components for Dolla",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.2",
|
|
5
5
|
"main": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
"@types/node": "^25.8.0",
|
|
27
27
|
"@types/stylis": "^4.2.7",
|
|
28
28
|
"lodash-es": "^4.18.1",
|
|
29
|
-
"nanoid": "^5.1.11",
|
|
30
29
|
"vite": "^8.0.14",
|
|
31
30
|
"vitest": "^4.1.7"
|
|
32
31
|
},
|