@manyducks.co/dolla-styled 0.0.1 → 0.0.3

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 CHANGED
@@ -3,7 +3,7 @@
3
3
  "configVersion": 1,
4
4
  "workspaces": {
5
5
  "": {
6
- "name": "dolla-lucide",
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.0.0", "", {}, "sha512-zRj544aYIudS6vbf5om92YkcfvRy5NhwZceKLt5ZI+aoN4wnpBMSPviC/ms8+8SfUy2/mjHTw0MO0QwcnFbx6w=="],
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.8.0", "", { "dependencies": { "undici-types": ">=7.24.0 <7.24.7" } }, "sha512-TCFSk8IZh+iLX1xtksoBVtdmgL+1IX0fC9BeU4QqFSuNdN/K+HUlhqOzEmSYYpZUVsLYcPqc9KX+60iDuninSQ=="],
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@5.1.11", "", { "bin": { "nanoid": "bin/nanoid.js" } }, "sha512-v+KEsUv2ps74PaSKv0gHTxTCgMXOIfBEbaqa6w6ISIGC7ZsvHN4N9oJ8d4cmf0n5oTzQz2SLmThbQWhjd/8eKg=="],
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,94 @@
1
- import { ViewNode as e, compose as t, createMarkup as n, onMount as r, unwrap as i } from "@manyducks.co/dolla";
2
- import { compile as a, middleware as o, prefixer as s, serialize as c, stringify as l } from "stylis";
3
- //#region node_modules/nanoid/url-alphabet/index.js
4
- var u = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", d = (e = 21) => {
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-styles", document.head.appendChild(this.el), this.sheet = this.el.sheet, this.cache = /* @__PURE__ */ new Set();
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 = c(a(`.${e}{${t}}`), o([s, l]));
18
- {
19
- let e = n.split(/(?<=\})\s*(?=[.#@a-zA-Z:\*])/g).map((e) => e.trim()).filter(Boolean);
20
- for (let t of e) try {
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
- }(), p = /* @__PURE__ */ new Set();
29
- function m(e) {
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
- function h(a) {
35
- return (o, ...s) => {
36
- let c = d(), l = "", u = [];
37
- o.forEach((e, t) => {
38
- if (l += e, t < s.length) {
39
- let e = s[t], n = "*", r = "initial";
40
- if (Array.isArray(e) && ([e, n, r = "initial"] = e), typeof e == "function") {
41
- let i = `--styled-${c}-${t}`;
42
- l += `var(${i})`, u.push({
51
+ var g = 0;
52
+ function _(i, a = {}) {
53
+ let { __name: o, ...s } = a, c = (a, ...c) => {
54
+ let l = h(a.join("||")), u = "", d = [];
55
+ return a.forEach((e, t) => {
56
+ if (u += e, t < c.length) {
57
+ let e = c[t], n = "*", r = null;
58
+ if (Array.isArray(e) && ([e, n, r = null] = e), typeof e == "function") {
59
+ let i = `--${l}-${t}`;
60
+ r === null ? u += `var(${i})` : (u += `var(${i}, ${r})`, n !== "*" && m.register(i, n, r)), d.push({
43
61
  varName: i,
44
- fn: e
45
- }), n !== "*" && !p.has(i) && (CSS.registerProperty({
46
- name: i,
47
- syntax: n,
48
- initialValue: r,
49
- inherits: !1
50
- }), p.add(i));
51
- } else l += e;
62
+ fn: e,
63
+ initialValue: r
64
+ });
65
+ } else u += e;
52
66
  }
53
- });
54
- let h = m(l);
55
- return (o, s) => {
56
- let c = t(() => {
57
- let e = {};
58
- return u.forEach(({ varName: t, fn: n }) => {
59
- let r = n(o);
60
- r != null && (e[t] = r);
61
- }), e;
62
- }), d = {
63
- ...o,
64
- style: t(() => ({
65
- ...i(o.style),
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))
73
- });
74
- {
75
- let t = new e(s, a, d);
76
- return r(t.context, () => {
77
- f.insert(h, l);
78
- }), t;
67
+ }), f.insert(l, u), (a, c) => {
68
+ o && (c.name = o);
69
+ let u = [l];
70
+ if (d.length > 0) {
71
+ let e = `styled-inst-${(g++).toString(36)}`;
72
+ u.push(e);
73
+ let t = p.createInstanceRule(e);
74
+ n(c, () => {
75
+ d.forEach(({ varName: e, fn: n, initialValue: r }) => {
76
+ let i = n(a);
77
+ i == null || i === r ? t.removeProperty(e) : t.setProperty(e, i);
78
+ });
79
+ });
79
80
  }
81
+ return t(typeof i == "string" && a.as || i, {
82
+ ...s,
83
+ ...a,
84
+ class: e(() => [a.class && r(a.class), ...u])
85
+ });
80
86
  };
81
87
  };
88
+ return c.with = () => c, c.named = (e) => _(i, Object.assign({}, a, { __name: e })), c.defaults = (e) => _(i, Object.assign({}, a, e)), c;
82
89
  }
83
- var g = new Proxy(h, { get(e, t) {
84
- return typeof t == "string" ? h(t) : e[t];
90
+ var v = new Proxy(_, { get(e, t) {
91
+ return _(t);
85
92
  } });
86
93
  //#endregion
87
- export { g as styled };
94
+ 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,40 @@ type StyledProps = {
3
3
  as?: keyof JSX.IntrinsicElements | string;
4
4
  };
5
5
  type StyledView<Props> = View<Props & StyledProps>;
6
- declare function styled<Tag extends keyof JSX.IntrinsicElements>(tag: Tag): (...args: any[]) => StyledView<JSX.IntrinsicElements[Tag]>;
7
- declare function styled<Props>(view: View<Props>): (...args: any[]) => StyledView<Props>;
8
- type Styled = typeof styled & {
9
- [Tag in keyof JSX.IntrinsicElements]: <Props = {}>(...args: any[]) => StyledView<JSX.IntrinsicElements[Tag] & Props>;
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 a name for the underlying view.
14
+ */
15
+ named(name: string): TypedTemplateFn<Props>;
16
+ /**
17
+ * Provides default props that are passed to all instances unless overridden.
18
+ */
19
+ defaults<D extends Partial<Props>>(defaultProps: D): (strings: TemplateStringsArray, ...interpolations: any[]) => StyledView<Flatten<ApplyDefaults<Props, D>>>;
20
+ }
21
+ interface TemplateFn<BaseProps = {}> {
22
+ (strings: TemplateStringsArray, ...interpolations: any[]): StyledView<BaseProps>;
23
+ /**
24
+ * Provides a name for the underlying view.
25
+ */
26
+ named(name: string): TemplateFn<BaseProps>;
27
+ /**
28
+ * Defines additional props the resulting view takes.
29
+ */
30
+ with<T>(): TypedTemplateFn<BaseProps & T>;
31
+ /**
32
+ * Provides default props that are passed to all instances unless overridden.
33
+ */
34
+ defaults<D extends Partial<BaseProps>>(defaultProps: D): (strings: TemplateStringsArray, ...interpolations: any[]) => StyledView<Flatten<ApplyDefaults<BaseProps, D>>>;
35
+ }
36
+ declare function createBuilder<Tag extends keyof JSX.IntrinsicElements>(tag: Tag, boundDefaults?: Partial<JSX.IntrinsicElements[Tag]>): TemplateFn<JSX.IntrinsicElements[Tag]>;
37
+ declare function createBuilder<Props>(view: View<Props>, boundDefaults?: Partial<Props>): TemplateFn<Props>;
38
+ type Styled = typeof createBuilder & {
39
+ [Tag in keyof JSX.IntrinsicElements]: TemplateFn<JSX.IntrinsicElements[Tag]>;
10
40
  };
11
41
  declare const _default: Styled;
12
42
  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.1",
4
+ "version": "0.0.3",
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
  },
package/dist/sheet.d.ts DELETED
@@ -1,9 +0,0 @@
1
- declare class Stylesheet {
2
- el: HTMLStyleElement;
3
- sheet: CSSStyleSheet;
4
- cache: Set<string>;
5
- constructor();
6
- insert(className: string, rawCss: string): void;
7
- }
8
- export declare const sheet: Stylesheet;
9
- export {};