@salty-css/react 0.1.0-alpha.9 → 0.1.0-refactor-add-additional-paths-to-config-cache.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 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("@salty-css/core/css/dynamic-styles"),u=require("./clsx-C11secjj.cjs"),g=require("react"),S=async({as:n,scope:r,styles:t,...c})=>{if(n){const a=l=>typeof n=="string"?g.createElement(n,l):n(l);if(!t)return e.jsx(a,{...c});const i=s.getDynamicStylesClassName(t),m=await s.getDynamicStylesCss(t,r||`.${i}`),o={...c,className:u.clsx(i,c.className)};return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:m}),e.jsx(a,{...o})]})}if(!t)return null;const y=await s.getDynamicStylesCss(t,r);return e.jsx("style",{children:y})};Object.defineProperty(exports,"getDynamicStylesClassName",{enumerable:!0,get:()=>s.getDynamicStylesClassName});Object.defineProperty(exports,"getDynamicStylesCss",{enumerable:!0,get:()=>s.getDynamicStylesCss});exports.DynamicStyles=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("@salty-css/core/css/dynamic-styles"),g=require("./clsx-C11secjj.cjs"),d=require("react"),j=t=>async({as:s,scope:y,styles:n,...i})=>{if(s){const l=m=>typeof s=="string"?d.createElement(s,m):s(m);if(!n)return e.jsx(l,{...i});const r=t.getDynamicStylesClassName(n),S=await t.getDynamicStylesCss(n,y||`.${r}`),D={...i,className:g.clsx(r,i.className)};return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:S}),e.jsx(l,{...D})]})}if(!n)return null;const u=await t.getDynamicStylesCss(n,y);return e.jsx("style",{children:u})},o=(t={})=>{const c=a.initializeDynamicStyles(t);return{...c,DynamicStyles:j(c)}},C=o(),f=C.DynamicStyles;Object.defineProperty(exports,"getDynamicStylesClassName",{enumerable:!0,get:()=>a.getDynamicStylesClassName});Object.defineProperty(exports,"getDynamicStylesCss",{enumerable:!0,get:()=>a.getDynamicStylesCss});exports.DynamicStyles=f;exports.initializeDynamicStyles=o;
@@ -1,15 +1,35 @@
1
1
  import { BaseStyles } from '@salty-css/core/types';
2
- import { getDynamicStylesClassName, getDynamicStylesCss } from '@salty-css/core/css/dynamic-styles';
2
+ import { DynamicStylesHelpers, getDynamicStylesClassName, getDynamicStylesCss, InitializeDynamicStylesOptions } from '@salty-css/core/css/dynamic-styles';
3
3
  import { HTMLAttributes } from 'react';
4
- export { getDynamicStylesClassName, getDynamicStylesCss };
4
+ export { getDynamicStylesClassName, getDynamicStylesCss, type InitializeDynamicStylesOptions };
5
5
  type AnyComponent = (...args: any[]) => React.ReactNode;
6
6
  interface DynamicStylesProps extends HTMLAttributes<HTMLElement> {
7
7
  styles?: BaseStyles;
8
8
  scope?: string;
9
9
  as?: string | AnyComponent;
10
10
  }
11
+ declare const createDynamicStylesComponent: (helpers: DynamicStylesHelpers) => ({ as, scope, styles, ...rest }: DynamicStylesProps) => Promise<import("react/jsx-runtime").JSX.Element | null>;
12
+ export interface DynamicStylesBundle extends DynamicStylesHelpers {
13
+ DynamicStyles: ReturnType<typeof createDynamicStylesComponent>;
14
+ }
15
+ /**
16
+ * Bind `DynamicStyles` and its helpers to a specific config / cache location.
17
+ *
18
+ * Use this in production deployments where the build-time `saltygen/` directory is
19
+ * not present at runtime (e.g. an Astro site deployed to Cloudflare). Call once at
20
+ * app startup and re-export the returned `DynamicStyles` component.
21
+ *
22
+ * @example
23
+ * export const { DynamicStyles } = initializeDynamicStyles({
24
+ * configCachePath: 'dist/saltygen/cache/config-cache.json',
25
+ * });
26
+ */
27
+ export declare const initializeDynamicStyles: (options?: InitializeDynamicStylesOptions) => DynamicStylesBundle;
11
28
  /**
12
29
  * Add any dynamic styles to your app with a custom scope.
13
30
  * Note: this works only with server components.
31
+ *
32
+ * For production deployments where the `saltygen/` directory is stripped,
33
+ * call {@link initializeDynamicStyles} instead and re-export its `DynamicStyles`.
14
34
  */
15
35
  export declare const DynamicStyles: ({ as, scope, styles, ...rest }: DynamicStylesProps) => Promise<import("react/jsx-runtime").JSX.Element | null>;
package/dynamic-styles.js CHANGED
@@ -1,24 +1,31 @@
1
- import { jsx as n, jsxs as f, Fragment as p } from "react/jsx-runtime";
2
- import { getDynamicStylesClassName as g, getDynamicStylesCss as o } from "@salty-css/core/css/dynamic-styles";
3
- import { getDynamicStylesClassName as w, getDynamicStylesCss as E } from "@salty-css/core/css/dynamic-styles";
4
- import { c as u } from "./clsx-OuTLNxxd.js";
5
- import { createElement as x } from "react";
6
- const d = async ({ as: e, scope: r, styles: t, ...s }) => {
1
+ import { jsx as s, jsxs as S, Fragment as f } from "react/jsx-runtime";
2
+ import { initializeDynamicStyles as u } from "@salty-css/core/css/dynamic-styles";
3
+ import { getDynamicStylesClassName as F, getDynamicStylesCss as b } from "@salty-css/core/css/dynamic-styles";
4
+ import { c as g } from "./clsx-OuTLNxxd.js";
5
+ import { createElement as p } from "react";
6
+ const C = (t) => async ({ as: e, scope: a, styles: n, ...c }) => {
7
7
  if (e) {
8
- const c = (a) => typeof e == "string" ? x(e, a) : e(a);
9
- if (!t) return /* @__PURE__ */ n(c, { ...s });
10
- const m = g(t), l = await o(t, r || `.${m}`), y = { ...s, className: u(m, s.className) };
11
- return /* @__PURE__ */ f(p, { children: [
12
- /* @__PURE__ */ n("style", { children: l }),
13
- /* @__PURE__ */ n(c, { ...y })
8
+ const m = (l) => typeof e == "string" ? p(e, l) : e(l);
9
+ if (!n) return /* @__PURE__ */ s(m, { ...c });
10
+ const y = t.getDynamicStylesClassName(n), o = await t.getDynamicStylesCss(n, a || `.${y}`), D = { ...c, className: g(y, c.className) };
11
+ return /* @__PURE__ */ S(f, { children: [
12
+ /* @__PURE__ */ s("style", { children: o }),
13
+ /* @__PURE__ */ s(m, { ...D })
14
14
  ] });
15
15
  }
16
- if (!t) return null;
17
- const i = await o(t, r);
18
- return /* @__PURE__ */ n("style", { children: i });
19
- };
16
+ if (!n) return null;
17
+ const r = await t.getDynamicStylesCss(n, a);
18
+ return /* @__PURE__ */ s("style", { children: r });
19
+ }, x = (t = {}) => {
20
+ const i = u(t);
21
+ return {
22
+ ...i,
23
+ DynamicStyles: C(i)
24
+ };
25
+ }, N = x(), w = N.DynamicStyles;
20
26
  export {
21
- d as DynamicStyles,
22
- w as getDynamicStylesClassName,
23
- E as getDynamicStylesCss
27
+ w as DynamicStyles,
28
+ F as getDynamicStylesClassName,
29
+ b as getDynamicStylesCss,
30
+ x as initializeDynamicStyles
24
31
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/react",
3
- "version": "0.1.0-alpha.9",
3
+ "version": "0.1.0-refactor-add-additional-paths-to-config-cache.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -78,7 +78,7 @@
78
78
  }
79
79
  },
80
80
  "dependencies": {
81
- "@salty-css/core": "^0.1.0-alpha.9",
81
+ "@salty-css/core": "^0.1.0-refactor-add-additional-paths-to-config-cache.0",
82
82
  "clsx": ">=2.x",
83
83
  "react": ">=19.x || >=18.3.x"
84
84
  },