next-yak 9.4.0 → 9.4.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/README.md +57 -288
- package/dist/context/baseContext.cjs +6 -29
- package/dist/context/baseContext.cjs.map +1 -1
- package/dist/context/baseContext.d.cts +4 -2
- package/dist/context/baseContext.d.ts +4 -2
- package/dist/context/baseContext.js +5 -5
- package/dist/context/baseContext.js.map +1 -1
- package/dist/context/index.cjs +33 -41
- package/dist/context/index.cjs.map +1 -1
- package/dist/context/index.d.cts +12 -8
- package/dist/context/index.d.ts +12 -8
- package/dist/context/index.js +10 -13
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.server.cjs +35 -41
- package/dist/context/index.server.cjs.map +1 -1
- package/dist/context/index.server.d.cts +13 -0
- package/dist/context/index.server.d.ts +13 -0
- package/dist/context/index.server.js +12 -14
- package/dist/context/index.server.js.map +1 -1
- package/dist/index.cjs +1 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +52 -46
- package/dist/index.d.ts +52 -46
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +464 -697
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +368 -0
- package/dist/internal.d.ts +368 -0
- package/dist/internal.js +297 -532
- package/dist/internal.js.map +1 -1
- package/dist/isolated-source-eval/index.d.ts +22 -20
- package/dist/isolated-source-eval/index.js +284 -298
- package/dist/isolated-source-eval/index.js.map +1 -1
- package/dist/isolated-source-eval/worker.js +53 -57
- package/dist/isolated-source-eval/worker.js.map +1 -1
- package/dist/jsx-dev-runtime.cjs +1 -1
- package/dist/jsx-dev-runtime.cjs.map +1 -1
- package/dist/jsx-dev-runtime.d.cts +9 -0
- package/dist/jsx-dev-runtime.d.ts +9 -0
- package/dist/jsx-dev-runtime.js +1 -1
- package/dist/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx-runtime.cjs +1 -1
- package/dist/jsx-runtime.cjs.map +1 -1
- package/dist/jsx-runtime.d.cts +25 -24
- package/dist/jsx-runtime.d.ts +25 -24
- package/dist/jsx-runtime.js +1 -1
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/loaders/turbo-loader.cjs +695 -983
- package/dist/loaders/turbo-loader.cjs.map +1 -1
- package/dist/loaders/turbo-loader.d.cts +7 -6
- package/dist/loaders/vite-plugin.d.ts +15 -13
- package/dist/loaders/vite-plugin.js +736 -1060
- package/dist/loaders/vite-plugin.js.map +1 -1
- package/dist/loaders/webpack-loader.cjs +629 -916
- package/dist/loaders/webpack-loader.cjs.map +1 -1
- package/dist/loaders/webpack-loader.d.cts +5 -4
- package/dist/static/chunk-WfQuXRBF.js +1 -0
- package/dist/static/index.cjs +1 -1
- package/dist/static/index.cjs.map +1 -1
- package/dist/static/index.d.cts +6 -7
- package/dist/static/index.d.ts +6 -7
- package/dist/static/index.js +1 -1
- package/dist/static/index.js.map +1 -1
- package/dist/withYak/index.cjs +135 -161
- package/dist/withYak/index.cjs.map +1 -1
- package/dist/withYak/index.d.cts +42 -40
- package/dist/withYak/index.d.ts +42 -40
- package/dist/withYak/index.js +114 -133
- package/dist/withYak/index.js.map +1 -1
- package/loaders/lib/__tests__/debugLogger.test.ts +11 -43
- package/loaders/lib/debugLogger.ts +6 -12
- package/loaders/lib/extractCss.ts +2 -6
- package/loaders/lib/resolveCrossFileSelectors.ts +105 -89
- package/loaders/turbo-evaluator.ts +7 -14
- package/loaders/turbo-loader.ts +5 -22
- package/loaders/vite-plugin.ts +19 -55
- package/loaders/webpack-loader.ts +1 -3
- package/package.json +131 -71
- package/runtime/__tests__/attrs.test.tsx +9 -16
- package/runtime/__tests__/cssLiteral.test.tsx +21 -45
- package/runtime/__tests__/cssProp.test.tsx +8 -17
- package/runtime/__tests__/cssPropTest.tsx +10 -13
- package/runtime/__tests__/styled.test.tsx +4 -13
- package/runtime/__tests__/tsconfig.json +1 -0
- package/runtime/__tests__/typeTest.tsx +7 -15
- package/runtime/atoms.tsx +1 -1
- package/runtime/context/README.md +11 -16
- package/runtime/context/index.server.tsx +2 -9
- package/runtime/cssLiteral.tsx +4 -13
- package/runtime/index.ts +1 -1
- package/runtime/internals/mergeCssProp.ts +1 -3
- package/runtime/jsx-runtime.ts +1 -2
- package/runtime/keyframes.tsx +1 -1
- package/runtime/mocks/cssLiteral.ts +3 -11
- package/runtime/mocks/keyframes.ts +1 -1
- package/runtime/publicStyledApi.ts +3 -13
- package/runtime/styled.tsx +19 -31
- package/withYak/index.ts +11 -19
package/README.md
CHANGED
|
@@ -5,328 +5,97 @@
|
|
|
5
5
|
[](https://www.npmjs.com/package/next-yak)
|
|
6
6
|
[](https://github.com/DigitecGalaxus/next-yak/blob/main/LICENSE)
|
|
7
7
|
|
|
8
|
-
**next-yak** is a CSS-in-JS
|
|
8
|
+
**next-yak** is a build-time CSS-in-JS library powered by a Rust SWC plugin. Write styled-components syntax, get zero-runtime CSS extraction and full React Server Components compatibility.
|
|
9
9
|
|
|
10
|
+
Works with **Next.js** (Webpack & Turbopack), **Vite** (7+, including Vite 8 with OXC), and **Storybook**. Any Vite-based framework works out of the box, including react-router, TanStack Start, and more.
|
|
11
|
+
|
|
12
|
+
> **Production-proven:** next-yak is sponsored and used in production by [Digitec Galaxus](https://www.galaxus.ch), the largest e-commerce platform in Switzerland, across thousands of styled components, delivering measurable improvements in Core Web Vitals.
|
|
10
13
|
|
|
11
14
|
## Features
|
|
12
15
|
|
|
13
|
-
- **
|
|
14
|
-
- **Build-
|
|
15
|
-
- **
|
|
16
|
-
- **
|
|
17
|
-
- **
|
|
16
|
+
- **Multi-Framework**: First-class support for Next.js (Webpack & Turbopack), Vite 7+ (react-router, TanStack Start, ...), and Storybook
|
|
17
|
+
- **Build-Time CSS**: Extracts CSS at compile time with zero runtime overhead
|
|
18
|
+
- **React Server Components**: Works seamlessly with both Server and Client Components
|
|
19
|
+
- **Cross-File Imports**: Import constants, mixins, and selectors from `.yak` files and other modules, works across all bundlers
|
|
20
|
+
- **Standard CSS Syntax**: Write familiar CSS with full nesting, keyframes, and media query support
|
|
21
|
+
- **Integrates with Atomic CSS**: Combines with utility-first frameworks like Tailwind CSS
|
|
22
|
+
- **TypeScript First**: Fully typed props, theme context, and cross-file selectors
|
|
23
|
+
- **Lightweight Runtime**: Minimal footprint, just swaps CSS class names based on props
|
|
24
|
+
- **Minimal Dependencies**: Only 8 dependencies in total (including transitive ones)
|
|
25
|
+
|
|
26
|
+
## Documentation
|
|
27
|
+
|
|
28
|
+
Full documentation, guides, and a live playground are available at **[yak.js.org](https://yak.js.org/)**.
|
|
18
29
|
|
|
19
|
-
[
|
|
20
|
-
)
|
|
30
|
+
- [Getting Started (Next.js)](https://yak.js.org/docs/getting-started)
|
|
31
|
+
- [Vite Setup](https://yak.js.org/docs/vite)
|
|
32
|
+
- [Storybook Setup](https://yak.js.org/docs/storybook)
|
|
33
|
+
- [Migration from styled-components](https://yak.js.org/docs/migration-from-styled-components)
|
|
34
|
+
- [Features](https://yak.js.org/docs/features)
|
|
35
|
+
- [Playground](https://yak.js.org/playground)
|
|
21
36
|
|
|
22
37
|
## Compatibility
|
|
23
38
|
|
|
24
|
-
| next-yak
|
|
25
|
-
|
|
26
|
-
| 9.x
|
|
27
|
-
| 8.x
|
|
28
|
-
| 7.x
|
|
29
|
-
| 6.x
|
|
30
|
-
| 5.x
|
|
31
|
-
| 4.x
|
|
32
|
-
| 3.x
|
|
33
|
-
| 2.x
|
|
39
|
+
| next-yak | Next.js | Vite | react | swc_core |
|
|
40
|
+
| -------- | --------- | --------------- | ----------- | -------- |
|
|
41
|
+
| 9.x | >= 16.1.0 | >= 7.0.0 (9.1+) | 19.x | 56.0.0 |
|
|
42
|
+
| 8.x | >= 16.0.0 | - | 19.x | 45.0.1 |
|
|
43
|
+
| 7.x | >= 15.4.4 | - | 19.x | 38.0.1 |
|
|
44
|
+
| 6.x | >= 15.4.1 | - | 19.x | 27.0.6 |
|
|
45
|
+
| 5.x | >= 15.2.1 | - | 19.x | 16.0.0 |
|
|
46
|
+
| 4.x | >= 15.0.4 | - | 19.x | 5.0.1 |
|
|
47
|
+
| 3.x | 15.x | - | 18.x / 19.x | 3.0.2 |
|
|
48
|
+
| 2.x | 14.x | - | 18.x / 19.x | 0.279.0 |
|
|
34
49
|
|
|
35
50
|
## Installation
|
|
36
51
|
|
|
37
52
|
```bash
|
|
38
|
-
# For Next.js >= 15.2.1
|
|
39
53
|
npm install next-yak
|
|
40
|
-
|
|
41
|
-
# For Next.js 14.x
|
|
42
|
-
npm install next-yak@2
|
|
43
54
|
```
|
|
44
55
|
|
|
45
|
-
##
|
|
46
|
-
|
|
47
|
-
See a live [stackblitz demo](https://stackblitz.com/edit/stackblitz-starters-dfykqy?file=app%2Fpage.tsx) or try our **[stackblitz starter kit](https://stackblitz.com/fork/next-yak-starter?file=app%2Fpage.tsx)**
|
|
48
|
-
|
|
49
|
-
### Locally
|
|
56
|
+
## Quick Start
|
|
50
57
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
2. Add next-yak to your `next.config.mjs`:
|
|
58
|
+
### Next.js
|
|
54
59
|
|
|
55
60
|
```js
|
|
56
|
-
// next.config.
|
|
61
|
+
// next.config.ts
|
|
57
62
|
import { withYak } from "next-yak/withYak";
|
|
58
63
|
|
|
59
|
-
|
|
64
|
+
export default withYak({
|
|
60
65
|
// your next.js config
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export default withYak(nextConfig);
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
3. Ready to go:
|
|
67
|
-
|
|
68
|
-
```jsx
|
|
69
|
-
// pages/index.js
|
|
70
|
-
import { styled } from 'next-yak';
|
|
71
|
-
|
|
72
|
-
const StyledDiv = styled.div`
|
|
73
|
-
color: #333;
|
|
74
|
-
padding: 16px;
|
|
75
|
-
background-color: #f0f0f0;
|
|
76
|
-
`;
|
|
77
|
-
|
|
78
|
-
function HomePage() {
|
|
79
|
-
return <StyledDiv>Hello, next-yak!</StyledDiv>;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export default HomePage;
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
## More Examples
|
|
86
|
-
|
|
87
|
-
### Dynamic Styles
|
|
88
|
-
|
|
89
|
-
Dynamic Styles will only toggle the css class during runtime:
|
|
90
|
-
|
|
91
|
-
```jsx
|
|
92
|
-
import { styled, css } from 'next-yak';
|
|
93
|
-
|
|
94
|
-
const ToggleButton = styled.button`
|
|
95
|
-
${props => props.$active
|
|
96
|
-
? css`background-color: green`
|
|
97
|
-
: css`background-color: lime`
|
|
98
|
-
};
|
|
99
|
-
color: white;
|
|
100
|
-
padding: 10px 20px;
|
|
101
|
-
`;
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
[Dynamic Styles (Video)](https://github.com/DigitecGalaxus/next-yak/assets/4113649/c5f52846-33e4-4058-9c78-efd98197d75f)
|
|
105
|
-
|
|
106
|
-
### Dynamic Properties
|
|
107
|
-
|
|
108
|
-
Dynamic Properties use custom properties ([aka css variables](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties)) under the hood to extract the CSS at built time but modify properties at runtime:
|
|
109
|
-
|
|
110
|
-
```jsx
|
|
111
|
-
import { styled } from 'next-yak';
|
|
112
|
-
|
|
113
|
-
const ProgressBar = styled.div`
|
|
114
|
-
width: ${props => `${props.$percent}%`};
|
|
115
|
-
height: 20px;
|
|
116
|
-
background-color: #3498db;
|
|
117
|
-
transition: width 0.3s ease-in-out;
|
|
118
|
-
`;
|
|
119
|
-
|
|
120
|
-
const ProgressBarContainer = styled.div`
|
|
121
|
-
border: 1px solid #ccc;
|
|
122
|
-
`;
|
|
123
|
-
|
|
124
|
-
const ExampleComponent = () => {
|
|
125
|
-
const progress = 75; // You can dynamically set this value
|
|
126
|
-
|
|
127
|
-
return (
|
|
128
|
-
<ProgressBarContainer>
|
|
129
|
-
<ProgressBar $percent={progress} />
|
|
130
|
-
</ProgressBarContainer>
|
|
131
|
-
);
|
|
132
|
-
};
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
[Dynamic Props (video)](https://github.com/DigitecGalaxus/next-yak/assets/4113649/2fa78f82-382c-465f-b294-2504739ea168)
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
### Targeting Components
|
|
139
|
-
|
|
140
|
-
In next-yak, you can target other components directly using CSS selectors as long as they are **in the same file**:
|
|
141
|
-
|
|
142
|
-
```jsx
|
|
143
|
-
import { styled, keyframes } from 'next-yak';
|
|
144
|
-
|
|
145
|
-
const flip = keyframes`
|
|
146
|
-
from { transform: rotateY(0deg); }
|
|
147
|
-
to { transform: rotateY(360deg); }
|
|
148
|
-
`;
|
|
149
|
-
|
|
150
|
-
const Glow = styled.div`
|
|
151
|
-
/* Add your Glow component styles here */
|
|
152
|
-
`;
|
|
153
|
-
|
|
154
|
-
const Text = styled.span`
|
|
155
|
-
display: inline-block;
|
|
156
|
-
${Glow}:hover & {
|
|
157
|
-
animation: 1.5s ${flip} ease-out;
|
|
158
|
-
}
|
|
159
|
-
`;
|
|
160
|
-
|
|
161
|
-
const ExampleComponent = () => {
|
|
162
|
-
return (
|
|
163
|
-
<Glow>
|
|
164
|
-
<Text>This text will flip on hover.</Text>
|
|
165
|
-
</Glow>
|
|
166
|
-
);
|
|
167
|
-
};
|
|
66
|
+
});
|
|
168
67
|
```
|
|
169
68
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
`next-yak` supports nesting out of the box.
|
|
173
|
-
[For now](https://github.com/css-modules/postcss-modules-local-by-default/pull/64) Next.js 13 supports nesting only with the `postcss-nested` plugin.
|
|
174
|
-
Therefore you have to create a `postcss.config.js` file in your project root:
|
|
69
|
+
### Vite
|
|
175
70
|
|
|
176
71
|
```js
|
|
177
|
-
//
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
[Nesting Example (video)](https://github.com/DigitecGalaxus/next-yak/assets/4113649/33eeeb13-b0cf-499f-a1d3-ba6f51cf4308)
|
|
186
|
-
|
|
187
|
-
## Motivation
|
|
188
|
-
|
|
189
|
-
Most of the existing CSS-in-JS libraries are either slow or have a complex api. This project tries to find a middle ground between speed and api complexity.
|
|
190
|
-
|
|
191
|
-
The goal of this project is to create a proof of concept for a CSS-in-JS library that has the following properties:
|
|
192
|
-
|
|
193
|
-
- fast
|
|
194
|
-
- no runtime
|
|
195
|
-
- can be statically extracted
|
|
196
|
-
- can be optimized by postcss
|
|
197
|
-
- no processing during hydration
|
|
198
|
-
- can make use of [103 early hints](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/103)
|
|
199
|
-
- api
|
|
200
|
-
- ui colocation (mixing css and jsx)
|
|
201
|
-
- familiar `styled.div` api
|
|
202
|
-
- composable `styled(Component)`
|
|
203
|
-
- allows conditional styles
|
|
204
|
-
- allow to use props in styles
|
|
205
|
-
- allow to use a context based theme in styles
|
|
206
|
-
- typescript support
|
|
207
|
-
|
|
208
|
-
Optimizations are done by postcss. This allows to use the full power of postcss and its plugins. It also allows to use the same optimizations for css files and css-in-js.
|
|
209
|
-
|
|
210
|
-
## Performance Gains
|
|
211
|
-
|
|
212
|
-
[](https://raw.githubusercontent.com/DigitecGalaxus/next-yak/main/css-extract.gif)
|
|
213
|
-
|
|
214
|
-
## How it works
|
|
215
|
-
|
|
216
|
-
next-yak converts css-in-js into css modules. This allows to use the full power of postcss and its plugins. It also allows to use the same optimizations for css files and css-in-js.
|
|
217
|
-
|
|
218
|
-
[](https://raw.githubusercontent.com/DigitecGalaxus/next-yak/main/compile-flow.webp)
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
## Atomic CSS
|
|
222
|
-
|
|
223
|
-
`next-yak` ships with atomic css support
|
|
224
|
-
So you can use [tailwind](https://tailwindcss.com/) out of the box without additional configuration.
|
|
225
|
-
|
|
226
|
-
```tsx
|
|
227
|
-
import { styled, atoms } from "next-yak";
|
|
228
|
-
|
|
229
|
-
// Mixing tailwind with custom styles
|
|
230
|
-
const Icon = styled.p`
|
|
231
|
-
${atoms("font-bold")}
|
|
232
|
-
@supports (initial-letter: 2) {
|
|
233
|
-
initial-letter: 2;
|
|
234
|
-
}
|
|
235
|
-
`;
|
|
236
|
-
|
|
237
|
-
// Apply tailwind classes conditionally
|
|
238
|
-
const Button = styled.button`
|
|
239
|
-
${({ $primary }) =>
|
|
240
|
-
$primary
|
|
241
|
-
? atoms(
|
|
242
|
-
'bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded'
|
|
243
|
-
)
|
|
244
|
-
: atoms(
|
|
245
|
-
'bg-transparent hover:bg-blue-500 text-blue-700 font-semibold hover:text-white py-2 px-4 border border-blue-500 hover:border-transparent rounded'
|
|
246
|
-
)}
|
|
247
|
-
`;
|
|
72
|
+
// vite.config.ts
|
|
73
|
+
import { defineConfig } from "vite";
|
|
74
|
+
import react from "@vitejs/plugin-react-swc";
|
|
75
|
+
import { viteYak } from "next-yak/vite";
|
|
76
|
+
|
|
77
|
+
export default defineConfig({
|
|
78
|
+
plugins: [viteYak(), react()],
|
|
79
|
+
});
|
|
248
80
|
```
|
|
249
81
|
|
|
250
|
-
|
|
251
|
-
## Build Time Constants
|
|
252
|
-
|
|
253
|
-
The downside of dynamic properties is that they require inline style attributes.
|
|
254
|
-
While this is not a problem for most cases, we can't use them for media queries.
|
|
255
|
-
|
|
256
|
-
`next-yak` allows you to define build time constants which can be used in your styles:
|
|
82
|
+
### Usage
|
|
257
83
|
|
|
258
84
|
```jsx
|
|
259
|
-
import { styled } from
|
|
260
|
-
import { breakpoints, spacings } from './constants.yak';
|
|
85
|
+
import { styled } from "next-yak";
|
|
261
86
|
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
87
|
+
const Button = styled.button`
|
|
88
|
+
background: #bf4f74;
|
|
89
|
+
color: white;
|
|
90
|
+
padding: 0.5rem 1rem;
|
|
91
|
+
border-radius: 4px;
|
|
267
92
|
`;
|
|
268
93
|
```
|
|
269
94
|
|
|
270
|
-
| Feature | Code | Yak Constant files |
|
|
271
|
-
|:-----------------|:------------------------------------------------|:-----------------------------------------------|
|
|
272
|
-
| File Extension | `.js`, `.jsx`, `.tsx`, etc. | `.yak.js`, `.yak.jsx`, `.yak.tsx`, etc. |
|
|
273
|
-
| Runs at | Runtime (Node or Browser) | Compile time (Bundler) |
|
|
274
|
-
| Side effects | ✅ | 🚫 |
|
|
275
|
-
| Yak Features | All (`styled`, `css`, ...) | 🚫 |
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
[Build time constants (video)](https://github.com/DigitecGalaxus/next-yak/assets/4113649/2c83246c-a03b-4c57-8814-32a7248983ac)
|
|
279
|
-
|
|
280
|
-
## Yak shaving
|
|
281
|
-
|
|
282
|
-
While trying to get next-yak to work properly we stumbled across several bugs.
|
|
283
|
-
Thanks for merging our prs fixes in next.js, webpack, postcss and qwik ❤️
|
|
284
|
-
|
|
285
|
-
<details>
|
|
286
|
-
<summary>PRS</summary>
|
|
287
|
-
|
|
288
|
-
- https://github.com/vercel/next.js/pull/51115
|
|
289
|
-
- https://github.com/vercel/next.js/pull/53796
|
|
290
|
-
- https://github.com/css-modules/postcss-modules-local-by-default/pull/64
|
|
291
|
-
- https://github.com/css-modules/postcss-modules-local-by-default/pull/72
|
|
292
|
-
- https://github.com/vercel/next.js/pull/62644
|
|
293
|
-
- https://github.com/vercel/next.js/pull/62639
|
|
294
|
-
- https://github.com/webpack-contrib/mini-css-extract-plugin/pull/1084
|
|
295
|
-
- https://github.com/vercel/next.js/pull/62733
|
|
296
|
-
- https://github.com/vercel/next.js/pull/64551
|
|
297
|
-
- https://github.com/QwikDev/qwik/pull/8351
|
|
298
|
-
- https://github.com/vercel/next.js/pull/89600
|
|
299
|
-
- https://github.com/vercel/next.js/pull/89901
|
|
300
|
-
|
|
301
|
-
</details>
|
|
302
|
-
|
|
303
|
-
<details>
|
|
304
|
-
<summary>Experiments</summary>
|
|
305
|
-
Incomplete work in progress experiments to test the features and performance of next-yak:
|
|
306
|
-
|
|
307
|
-
- https://next-yak-benchmark.vercel.app/
|
|
308
|
-
- https://yacijs.vercel.app/
|
|
309
|
-
</details>
|
|
310
|
-
|
|
311
|
-
## Acknowledgments
|
|
312
|
-
|
|
313
|
-
Massive kudos to:
|
|
314
|
-
|
|
315
|
-
- @sokra: For guiding us through webpacks module and loader APIs
|
|
316
|
-
- @kdy1: For his support while rewriting our Babel plugin as a blazing fast SWC Rust WASM plugin
|
|
317
|
-
|
|
318
|
-
Special thanks to the contributors and the inspiring projects that influenced next-yak:
|
|
319
|
-
|
|
320
|
-
- Styled-Components 💅: For pioneering the styled syntax and redefining styling in the React ecosystem.
|
|
321
|
-
- Linaria: For its innovative approach to zero-runtime CSS in JS and efficient styling solutions.
|
|
322
|
-
- Emotion: For pushing the boundaries of CSS-in-JS and providing a high-performance styling experience.
|
|
323
|
-
- Vanilla Extract: For its focus on type-safe, zero-runtime CSS and contributing to the evolution of styling techniques.
|
|
324
|
-
- Tailwind CSS: For its exceptional atomic CSS approach, enabling efficient and customizable styling solutions.
|
|
325
|
-
|
|
326
95
|
## License
|
|
327
96
|
|
|
328
|
-
**next-yak** is licensed under the [MIT License](
|
|
97
|
+
**next-yak** is licensed under the [MIT License](https://github.com/DigitecGalaxus/next-yak/blob/main/LICENSE).
|
|
329
98
|
|
|
330
|
-
|
|
99
|
+
## Contributing
|
|
331
100
|
|
|
332
|
-
|
|
101
|
+
Contributions are welcome! The [contributing guide](https://github.com/DigitecGalaxus/next-yak/blob/main/CONTRIBUTION.md) helps you get started.
|
|
@@ -1,33 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
var baseContext_exports = {};
|
|
22
|
-
__export(baseContext_exports, {
|
|
23
|
-
getYakThemeContext: () => getYakThemeContext
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(baseContext_exports);
|
|
3
|
+
//#region runtime/context/baseContext.tsx
|
|
26
4
|
function getYakThemeContext() {
|
|
27
|
-
|
|
5
|
+
return {};
|
|
28
6
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
});
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
exports.getYakThemeContext = getYakThemeContext;
|
|
33
10
|
//# sourceMappingURL=baseContext.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../runtime/context/baseContext.tsx"],"sourcesContent":["import type { YakTheme } from \"next-yak\";\n\nexport function getYakThemeContext() {\n return {} as YakTheme | undefined;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"baseContext.cjs","names":[],"sources":["../../runtime/context/baseContext.tsx"],"sourcesContent":["import type { YakTheme } from \"next-yak\";\n\nexport function getYakThemeContext() {\n return {} as YakTheme | undefined;\n}\n"],"mappings":";;;AAEA,SAAgB,qBAAqB;AACnC,QAAO,EAAE"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { YakTheme } from
|
|
1
|
+
import { YakTheme } from "next-yak";
|
|
2
2
|
|
|
3
|
+
//#region runtime/context/baseContext.d.ts
|
|
3
4
|
declare function getYakThemeContext(): YakTheme | undefined;
|
|
4
|
-
|
|
5
|
+
//#endregion
|
|
5
6
|
export { getYakThemeContext };
|
|
7
|
+
//# sourceMappingURL=baseContext.d.cts.map
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { YakTheme } from
|
|
1
|
+
import { YakTheme } from "next-yak";
|
|
2
2
|
|
|
3
|
+
//#region runtime/context/baseContext.d.ts
|
|
3
4
|
declare function getYakThemeContext(): YakTheme | undefined;
|
|
4
|
-
|
|
5
|
+
//#endregion
|
|
5
6
|
export { getYakThemeContext };
|
|
7
|
+
//# sourceMappingURL=baseContext.d.ts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
//#region runtime/context/baseContext.tsx
|
|
2
2
|
function getYakThemeContext() {
|
|
3
|
-
|
|
3
|
+
return {};
|
|
4
4
|
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
7
|
+
export { getYakThemeContext };
|
|
8
8
|
//# sourceMappingURL=baseContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../runtime/context/baseContext.tsx"],"sourcesContent":["import type { YakTheme } from \"next-yak\";\n\nexport function getYakThemeContext() {\n return {} as YakTheme | undefined;\n}\n"],"mappings":";
|
|
1
|
+
{"version":3,"file":"baseContext.js","names":[],"sources":["../../runtime/context/baseContext.tsx"],"sourcesContent":["import type { YakTheme } from \"next-yak\";\n\nexport function getYakThemeContext() {\n return {} as YakTheme | undefined;\n}\n"],"mappings":";AAEA,SAAgB,qBAAqB;AACnC,QAAO,EAAE"}
|
package/dist/context/index.cjs
CHANGED
|
@@ -1,53 +1,45 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
"use client";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
//#region \0rolldown/runtime.js
|
|
3
5
|
var __create = Object.create;
|
|
4
6
|
var __defProp = Object.defineProperty;
|
|
5
7
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
8
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
9
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
10
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
11
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
14
|
+
key = keys[i];
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
__defProp(to, key, {
|
|
17
|
+
get: ((k) => from[k]).bind(null, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
20
24
|
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: true
|
|
28
|
+
}) : target, mod));
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var useTheme = () => {
|
|
41
|
-
const context = (0, import_react.use)(YakContext);
|
|
42
|
-
return context instanceof Promise ? (0, import_react.use)(context) : context;
|
|
30
|
+
//#endregion
|
|
31
|
+
let react = require("react");
|
|
32
|
+
react = __toESM(react);
|
|
33
|
+
|
|
34
|
+
//#region runtime/context/index.tsx
|
|
35
|
+
const YakContext = (0, react.createContext)({});
|
|
36
|
+
const useTheme = () => {
|
|
37
|
+
const context = (0, react.use)(YakContext);
|
|
38
|
+
return context instanceof Promise ? (0, react.use)(context) : context;
|
|
43
39
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
0 && (module.exports = {
|
|
50
|
-
YakThemeProvider,
|
|
51
|
-
useTheme
|
|
52
|
-
});
|
|
40
|
+
const YakThemeProvider = ({ children, theme = {} }) => /* @__PURE__ */ react.default.createElement(YakContext.Provider, { value: theme }, children);
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
exports.YakThemeProvider = YakThemeProvider;
|
|
44
|
+
exports.useTheme = useTheme;
|
|
53
45
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../runtime/context/index.tsx"],"sourcesContent":["\"use client\";\n//\n// This file is the client component (browser & ssr) version of index.server.tsx\n//\nimport React, { ReactNode, createContext, use } from \"react\";\n\nexport interface YakTheme {}\n\n/**\n * The yak theme context\n * @see https://github.com/DigitecGalaxus/next-yak/blob/main/packages/next-yak/runtime/context/README.md\n */\nconst YakContext = createContext<YakTheme>({});\n\n/**\n * Returns the current yak theme context\n *\n * @see https://github.com/DigitecGalaxus/next-yak/blob/main/packages/next-yak/runtime/context/README.md\n */\nexport const useTheme = (): YakTheme => {\n const context = use(YakContext);\n return context instanceof Promise ? use(context) : context;\n};\n\n/**\n * Yak theme context provider\n *\n * @see https://github.com/DigitecGalaxus/next-yak/blob/main/packages/next-yak/runtime/context/README.md\n */\nexport const YakThemeProvider = ({\n children,\n theme = {},\n}: {\n children: ReactNode;\n theme?: YakTheme;\n}) => <YakContext.Provider value={theme}>{children}</YakContext.Provider>;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../runtime/context/index.tsx"],"sourcesContent":["\"use client\";\n//\n// This file is the client component (browser & ssr) version of index.server.tsx\n//\nimport React, { ReactNode, createContext, use } from \"react\";\n\nexport interface YakTheme {}\n\n/**\n * The yak theme context\n * @see https://github.com/DigitecGalaxus/next-yak/blob/main/packages/next-yak/runtime/context/README.md\n */\nconst YakContext = createContext<YakTheme>({});\n\n/**\n * Returns the current yak theme context\n *\n * @see https://github.com/DigitecGalaxus/next-yak/blob/main/packages/next-yak/runtime/context/README.md\n */\nexport const useTheme = (): YakTheme => {\n const context = use(YakContext);\n return context instanceof Promise ? use(context) : context;\n};\n\n/**\n * Yak theme context provider\n *\n * @see https://github.com/DigitecGalaxus/next-yak/blob/main/packages/next-yak/runtime/context/README.md\n */\nexport const YakThemeProvider = ({\n children,\n theme = {},\n}: {\n children: ReactNode;\n theme?: YakTheme;\n}) => <YakContext.Provider value={theme}>{children}</YakContext.Provider>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,MAAM,sCAAqC,EAAE,CAAC;AAO9C,MAAa,iBAA2B;CACtC,MAAM,yBAAc,WAAW;AAC/B,QAAO,mBAAmB,yBAAc,QAAQ,GAAG;;AAQrD,MAAa,oBAAoB,EAC/B,UACA,QAAQ,EAAE,OAIN,4CAAC,WAAW,UAAZ,EAAqB,OAAO,OAAuC,EAA/B,SAA+B"}
|
package/dist/context/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React, { ReactNode } from
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
}
|
|
3
|
+
//#region runtime/context/index.d.ts
|
|
4
|
+
interface YakTheme {}
|
|
5
5
|
/**
|
|
6
6
|
* Returns the current yak theme context
|
|
7
7
|
*
|
|
@@ -13,9 +13,13 @@ declare const useTheme: () => YakTheme;
|
|
|
13
13
|
*
|
|
14
14
|
* @see https://github.com/DigitecGalaxus/next-yak/blob/main/packages/next-yak/runtime/context/README.md
|
|
15
15
|
*/
|
|
16
|
-
declare const YakThemeProvider: ({
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
declare const YakThemeProvider: ({
|
|
17
|
+
children,
|
|
18
|
+
theme
|
|
19
|
+
}: {
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
theme?: YakTheme;
|
|
19
22
|
}) => React.JSX.Element;
|
|
20
|
-
|
|
21
|
-
export {
|
|
23
|
+
//#endregion
|
|
24
|
+
export { YakTheme, YakThemeProvider, useTheme };
|
|
25
|
+
//# sourceMappingURL=index.d.cts.map
|
package/dist/context/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React, { ReactNode } from
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
}
|
|
3
|
+
//#region runtime/context/index.d.ts
|
|
4
|
+
interface YakTheme {}
|
|
5
5
|
/**
|
|
6
6
|
* Returns the current yak theme context
|
|
7
7
|
*
|
|
@@ -13,9 +13,13 @@ declare const useTheme: () => YakTheme;
|
|
|
13
13
|
*
|
|
14
14
|
* @see https://github.com/DigitecGalaxus/next-yak/blob/main/packages/next-yak/runtime/context/README.md
|
|
15
15
|
*/
|
|
16
|
-
declare const YakThemeProvider: ({
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
declare const YakThemeProvider: ({
|
|
17
|
+
children,
|
|
18
|
+
theme
|
|
19
|
+
}: {
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
theme?: YakTheme;
|
|
19
22
|
}) => React.JSX.Element;
|
|
20
|
-
|
|
21
|
-
export {
|
|
23
|
+
//#endregion
|
|
24
|
+
export { YakTheme, YakThemeProvider, useTheme };
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|