@yak/react 0.0.0-stage → 10.0.0-rc.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/LICENSE +21 -0
- package/README.md +102 -2
- package/dist/context/baseContext.cjs +9 -0
- package/dist/context/baseContext.cjs.map +1 -0
- package/dist/context/baseContext.d.cts +6 -0
- package/dist/context/baseContext.d.ts +6 -0
- package/dist/context/baseContext.js +8 -0
- package/dist/context/baseContext.js.map +1 -0
- package/dist/context/index.cjs +45 -0
- package/dist/context/index.cjs.map +1 -0
- package/dist/context/index.d.cts +21 -0
- package/dist/context/index.d.ts +21 -0
- package/dist/context/index.js +15 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/index.server.cjs +47 -0
- package/dist/context/index.server.cjs.map +1 -0
- package/dist/context/index.server.d.cts +10 -0
- package/dist/context/index.server.d.ts +10 -0
- package/dist/context/index.server.js +17 -0
- package/dist/context/index.server.js.map +1 -0
- package/dist/cross-file-resolver/index.d.ts +199 -0
- package/dist/cross-file-resolver/index.js +535 -0
- package/dist/cross-file-resolver/index.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +320 -0
- package/dist/index.d.ts +320 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/internal.cjs +544 -0
- package/dist/internal.cjs.map +1 -0
- package/dist/internal.d.cts +452 -0
- package/dist/internal.d.ts +452 -0
- package/dist/internal.js +363 -0
- package/dist/internal.js.map +1 -0
- package/dist/isolated-source-eval/index.d.ts +30 -0
- package/dist/isolated-source-eval/index.js +317 -0
- package/dist/isolated-source-eval/index.js.map +1 -0
- package/dist/isolated-source-eval/worker.js +59 -0
- package/dist/isolated-source-eval/worker.js.map +1 -0
- package/dist/jsx-dev-runtime.cjs +2 -0
- package/dist/jsx-dev-runtime.cjs.map +1 -0
- package/dist/jsx-dev-runtime.d.cts +7 -0
- package/dist/jsx-dev-runtime.d.ts +7 -0
- package/dist/jsx-dev-runtime.js +2 -0
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx-runtime.cjs +2 -0
- package/dist/jsx-runtime.cjs.map +1 -0
- package/dist/jsx-runtime.d.cts +38 -0
- package/dist/jsx-runtime.d.ts +38 -0
- package/dist/jsx-runtime.js +2 -0
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/loaders/turbo-loader.cjs +803 -0
- package/dist/loaders/turbo-loader.cjs.map +1 -0
- package/dist/loaders/turbo-loader.d.cts +15 -0
- package/dist/loaders/vite-plugin.d.ts +111 -0
- package/dist/loaders/vite-plugin.js +878 -0
- package/dist/loaders/vite-plugin.js.map +1 -0
- package/dist/loaders/webpack-loader.cjs +697 -0
- package/dist/loaders/webpack-loader.cjs.map +1 -0
- package/dist/loaders/webpack-loader.d.cts +12 -0
- package/dist/rsbuild/index.d.ts +29 -0
- package/dist/rsbuild/index.js +52 -0
- package/dist/rsbuild/index.js.map +1 -0
- package/dist/static/chunk-DK3Fl9T5.js +1 -0
- package/dist/static/index.cjs +2 -0
- package/dist/static/index.cjs.map +1 -0
- package/dist/static/index.d.cts +28 -0
- package/dist/static/index.d.ts +28 -0
- package/dist/static/index.js +2 -0
- package/dist/static/index.js.map +1 -0
- package/dist/withYak/index.cjs +208 -0
- package/dist/withYak/index.cjs.map +1 -0
- package/dist/withYak/index.d.cts +121 -0
- package/dist/withYak/index.d.ts +121 -0
- package/dist/withYak/index.js +177 -0
- package/dist/withYak/index.js.map +1 -0
- package/loaders/lib/resolveCrossFileSelectors.ts +162 -0
- package/loaders/turbo-evaluator.ts +134 -0
- package/loaders/turbo-loader.ts +180 -0
- package/loaders/vite-plugin.ts +28 -0
- package/loaders/webpack-loader.ts +44 -0
- package/package.json +214 -3
- package/rsbuild/index.ts +92 -0
- package/runtime/__tests__/atoms.test.tsx +48 -0
- package/runtime/__tests__/attrs.test.tsx +490 -0
- package/runtime/__tests__/cssLiteral.test.tsx +503 -0
- package/runtime/__tests__/cssProp.test.tsx +392 -0
- package/runtime/__tests__/cssPropTest.tsx +227 -0
- package/runtime/__tests__/foldedJsxParity.test.tsx +117 -0
- package/runtime/__tests__/styled.test.tsx +653 -0
- package/runtime/__tests__/tsconfig.json +18 -0
- package/runtime/__tests__/typeTest.tsx +374 -0
- package/runtime/atoms.tsx +36 -0
- package/runtime/context/README.md +84 -0
- package/runtime/context/baseContext.tsx +5 -0
- package/runtime/context/index.server.tsx +22 -0
- package/runtime/context/index.tsx +36 -0
- package/runtime/cssLiteral.tsx +214 -0
- package/runtime/globalStyle.tsx +54 -0
- package/runtime/index.ts +37 -0
- package/runtime/internal.ts +42 -0
- package/runtime/internals/mergeClassNames.ts +23 -0
- package/runtime/internals/mergeCssProp.ts +69 -0
- package/runtime/internals/propMarkers.ts +20 -0
- package/runtime/internals/unitPostFix.ts +34 -0
- package/runtime/jsx-dev-runtime.ts +6 -0
- package/runtime/jsx-runtime.ts +48 -0
- package/runtime/keyframes.tsx +30 -0
- package/runtime/mocks/cssLiteral.ts +74 -0
- package/runtime/mocks/globalStyle.ts +14 -0
- package/runtime/mocks/keyframes.ts +29 -0
- package/runtime/mocks/styled.ts +8 -0
- package/runtime/publicStyledApi.ts +159 -0
- package/runtime/styled.tsx +372 -0
- package/runtime/styledDom.tsx +139 -0
- package/withYak/allow-global-css.ts +94 -0
- package/withYak/index.ts +282 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Jan Nicklas
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,103 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @yak/react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@yak/react)
|
|
6
|
+
[](https://github.com/DigitecGalaxus/next-yak/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
**@yak/react** 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
|
+
|
|
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:** @yak/react 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.
|
|
13
|
+
|
|
14
|
+
## Features
|
|
15
|
+
|
|
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/)**.
|
|
29
|
+
|
|
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)
|
|
36
|
+
|
|
37
|
+
## Compatibility
|
|
38
|
+
|
|
39
|
+
Versions before 10.x are on npm as [`next-yak`](https://www.npmjs.com/package/next-yak).
|
|
40
|
+
|
|
41
|
+
| Version | Next.js | Vite | react | swc_core |
|
|
42
|
+
| ------- | --------- | --------------- | ----------- | -------- |
|
|
43
|
+
| 9.x | >= 16.1.0 | >= 7.0.0 (9.1+) | 19.x | 56.0.0 |
|
|
44
|
+
| 8.x | >= 16.0.0 | - | 19.x | 45.0.1 |
|
|
45
|
+
| 7.x | >= 15.4.4 | - | 19.x | 38.0.1 |
|
|
46
|
+
| 6.x | >= 15.4.1 | - | 19.x | 27.0.6 |
|
|
47
|
+
| 5.x | >= 15.2.1 | - | 19.x | 16.0.0 |
|
|
48
|
+
| 4.x | >= 15.0.4 | - | 19.x | 5.0.1 |
|
|
49
|
+
| 3.x | 15.x | - | 18.x / 19.x | 3.0.2 |
|
|
50
|
+
| 2.x | 14.x | - | 18.x / 19.x | 0.279.0 |
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm install @yak/react
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Quick Start
|
|
59
|
+
|
|
60
|
+
### Next.js
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
// next.config.ts
|
|
64
|
+
import { withYak } from "@yak/react/withYak";
|
|
65
|
+
|
|
66
|
+
export default withYak({
|
|
67
|
+
// your next.js config
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Vite
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
// vite.config.ts
|
|
75
|
+
import { defineConfig } from "vite";
|
|
76
|
+
import react from "@vitejs/plugin-react-swc";
|
|
77
|
+
import { viteYak } from "@yak/react/vite";
|
|
78
|
+
|
|
79
|
+
export default defineConfig({
|
|
80
|
+
plugins: [viteYak(), react()],
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Usage
|
|
85
|
+
|
|
86
|
+
```jsx
|
|
87
|
+
import { styled } from "@yak/react";
|
|
88
|
+
|
|
89
|
+
const Button = styled.button`
|
|
90
|
+
background: #bf4f74;
|
|
91
|
+
color: white;
|
|
92
|
+
padding: 0.5rem 1rem;
|
|
93
|
+
border-radius: 4px;
|
|
94
|
+
`;
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
**@yak/react** is licensed under the [MIT License](https://github.com/DigitecGalaxus/next-yak/blob/main/LICENSE).
|
|
100
|
+
|
|
101
|
+
## Contributing
|
|
102
|
+
|
|
103
|
+
Contributions are welcome! The [contributing guide](https://github.com/DigitecGalaxus/next-yak/blob/main/CONTRIBUTION.md) helps you get started.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
//#region runtime/context/baseContext.tsx
|
|
3
|
+
function getYakThemeContext() {
|
|
4
|
+
return {};
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
exports.getYakThemeContext = getYakThemeContext;
|
|
9
|
+
//# sourceMappingURL=baseContext.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseContext.cjs","names":[],"sources":["../../runtime/context/baseContext.tsx"],"sourcesContent":["import type { YakTheme } from \"@yak/react\";\n\nexport function getYakThemeContext() {\n return {} as YakTheme | undefined;\n}\n"],"mappings":";;AAEA,SAAgB,qBAAqB;CACnC,OAAO,CAAC;AACV"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseContext.js","names":[],"sources":["../../runtime/context/baseContext.tsx"],"sourcesContent":["import type { YakTheme } from \"@yak/react\";\n\nexport function getYakThemeContext() {\n return {} as YakTheme | undefined;\n}\n"],"mappings":";AAEA,SAAgB,qBAAqB;CACnC,OAAO,CAAC;AACV"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
//#region \0rolldown/runtime.js
|
|
5
|
+
var __create = Object.create;
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
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;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: true
|
|
28
|
+
}) : target, mod));
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
let react = require("react");
|
|
32
|
+
react = __toESM(react, 1);
|
|
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;
|
|
39
|
+
};
|
|
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;
|
|
45
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["createContext","use"],"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/yak-react/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/yak-react/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/yak-react/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,iBAAaA,qBAAwB,CAAC,CAAC;AAO7C,MAAa,iBAA2B;CACtC,MAAM,cAAUC,WAAI,UAAU;CAC9B,OAAO,mBAAmB,cAAUA,WAAI,OAAO,IAAI;AACrD;AAOA,MAAa,oBAAoB,EAC/B,UACA,QAAQ,CAAC,QAIL,4CAAC,WAAW,UAAZ,EAAqB,OAAO,MAAsC,GAA9B,QAA8B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
//#region runtime/context/index.d.ts
|
|
3
|
+
interface YakTheme {}
|
|
4
|
+
/**
|
|
5
|
+
* Returns the current yak theme context
|
|
6
|
+
*
|
|
7
|
+
* @see https://github.com/DigitecGalaxus/next-yak/blob/main/packages/yak-react/runtime/context/README.md
|
|
8
|
+
*/
|
|
9
|
+
declare const useTheme: () => YakTheme;
|
|
10
|
+
/**
|
|
11
|
+
* Yak theme context provider
|
|
12
|
+
*
|
|
13
|
+
* @see https://github.com/DigitecGalaxus/next-yak/blob/main/packages/yak-react/runtime/context/README.md
|
|
14
|
+
*/
|
|
15
|
+
declare const YakThemeProvider: ({ children, theme }: {
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
theme?: YakTheme;
|
|
18
|
+
}) => React.JSX.Element;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { YakTheme, YakThemeProvider, useTheme };
|
|
21
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
//#region runtime/context/index.d.ts
|
|
3
|
+
interface YakTheme {}
|
|
4
|
+
/**
|
|
5
|
+
* Returns the current yak theme context
|
|
6
|
+
*
|
|
7
|
+
* @see https://github.com/DigitecGalaxus/next-yak/blob/main/packages/yak-react/runtime/context/README.md
|
|
8
|
+
*/
|
|
9
|
+
declare const useTheme: () => YakTheme;
|
|
10
|
+
/**
|
|
11
|
+
* Yak theme context provider
|
|
12
|
+
*
|
|
13
|
+
* @see https://github.com/DigitecGalaxus/next-yak/blob/main/packages/yak-react/runtime/context/README.md
|
|
14
|
+
*/
|
|
15
|
+
declare const YakThemeProvider: ({ children, theme }: {
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
theme?: YakTheme;
|
|
18
|
+
}) => React.JSX.Element;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { YakTheme, YakThemeProvider, useTheme };
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, { createContext, use } from "react";
|
|
4
|
+
|
|
5
|
+
//#region runtime/context/index.tsx
|
|
6
|
+
const YakContext = createContext({});
|
|
7
|
+
const useTheme = () => {
|
|
8
|
+
const context = use(YakContext);
|
|
9
|
+
return context instanceof Promise ? use(context) : context;
|
|
10
|
+
};
|
|
11
|
+
const YakThemeProvider = ({ children, theme = {} }) => /* @__PURE__ */ React.createElement(YakContext.Provider, { value: theme }, children);
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { YakThemeProvider, useTheme };
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","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/yak-react/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/yak-react/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/yak-react/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,aAAa,cAAwB,CAAC,CAAC;AAO7C,MAAa,iBAA2B;CACtC,MAAM,UAAU,IAAI,UAAU;CAC9B,OAAO,mBAAmB,UAAU,IAAI,OAAO,IAAI;AACrD;AAOA,MAAa,oBAAoB,EAC/B,UACA,QAAQ,CAAC,QAIL,oCAAC,WAAW,UAAZ,EAAqB,OAAO,MAAsC,GAA9B,QAA8B"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: ((k) => from[k]).bind(null, key),
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
26
|
+
}) : target, mod));
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
let react = require("react");
|
|
30
|
+
react = __toESM(react, 1);
|
|
31
|
+
let runtime_context_index_js = require("./index.js");
|
|
32
|
+
let _yak_react_context_baseContext = require("@yak/react/context/baseContext");
|
|
33
|
+
|
|
34
|
+
//#region runtime/context/index.server.tsx
|
|
35
|
+
const getYakContext = (0, react.cache)(() => (0, _yak_react_context_baseContext.getYakThemeContext)());
|
|
36
|
+
const useTheme = () => {
|
|
37
|
+
const theme = getYakContext();
|
|
38
|
+
return theme instanceof Promise ? (0, react.use)(theme) : theme;
|
|
39
|
+
};
|
|
40
|
+
const YakThemeProvider = ({ children }) => {
|
|
41
|
+
return /* @__PURE__ */ react.default.createElement(runtime_context_index_js.YakThemeProvider, { theme: getYakContext() }, children);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
exports.YakThemeProvider = YakThemeProvider;
|
|
46
|
+
exports.useTheme = useTheme;
|
|
47
|
+
//# sourceMappingURL=index.server.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.server.cjs","names":["cache","getYakThemeContext","use","YakThemeClientProvider"],"sources":["../../runtime/context/index.server.tsx"],"sourcesContent":["//\n// This file is the react-server component version of index.tsx\n//\n\n// @ts-ignore - in the current @types/react \"cache\" is not typed\nimport React, { ReactNode, cache, use } from \"react\";\nimport { YakTheme, YakThemeProvider as YakThemeClientProvider } from \"./index.js\";\n\n// the following import might be changed by\n// the user config in withYak to point to their own\n// context\nimport { getYakThemeContext } from \"@yak/react/context/baseContext\";\n\n/** Request based RSC YAK Context */\nconst getYakContext = cache(() => getYakThemeContext());\nexport const useTheme = (): YakTheme | undefined => {\n const theme: YakTheme | undefined | Promise<YakTheme> = getYakContext();\n return theme instanceof Promise ? use(theme) : theme;\n};\nexport const YakThemeProvider = ({ children }: { children: ReactNode }) => {\n return <YakThemeClientProvider theme={getYakContext()}>{children}</YakThemeClientProvider>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAM,oBAAgBA,uBAAYC,mDAAmB,CAAC;AACtD,MAAa,iBAAuC;CAClD,MAAM,QAAkD,cAAc;CACtE,OAAO,iBAAiB,cAAUC,WAAI,KAAK,IAAI;AACjD;AACA,MAAa,oBAAoB,EAAE,eAAwC;CACzE,OAAO,4CAACC,2CAAD,EAAwB,OAAO,cAAc,EAAqC,GAAjC,QAAiC;AAC3F"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import { YakTheme } from "./index.js";
|
|
3
|
+
//#region runtime/context/index.server.d.ts
|
|
4
|
+
declare const useTheme: () => YakTheme | undefined;
|
|
5
|
+
declare const YakThemeProvider: ({ children }: {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}) => React.JSX.Element;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { YakThemeProvider, useTheme };
|
|
10
|
+
//# sourceMappingURL=index.server.d.cts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
import { YakTheme } from "./index.js";
|
|
3
|
+
//#region runtime/context/index.server.d.ts
|
|
4
|
+
declare const useTheme: () => YakTheme | undefined;
|
|
5
|
+
declare const YakThemeProvider: ({ children }: {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}) => React.JSX.Element;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { YakThemeProvider, useTheme };
|
|
10
|
+
//# sourceMappingURL=index.server.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { cache, use } from "react";
|
|
2
|
+
import { YakThemeProvider as YakThemeProvider$1 } from "./index.js";
|
|
3
|
+
import { getYakThemeContext } from "@yak/react/context/baseContext";
|
|
4
|
+
|
|
5
|
+
//#region runtime/context/index.server.tsx
|
|
6
|
+
const getYakContext = cache(() => getYakThemeContext());
|
|
7
|
+
const useTheme = () => {
|
|
8
|
+
const theme = getYakContext();
|
|
9
|
+
return theme instanceof Promise ? use(theme) : theme;
|
|
10
|
+
};
|
|
11
|
+
const YakThemeProvider = ({ children }) => {
|
|
12
|
+
return /* @__PURE__ */ React.createElement(YakThemeProvider$1, { theme: getYakContext() }, children);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { YakThemeProvider, useTheme };
|
|
17
|
+
//# sourceMappingURL=index.server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.server.js","names":["YakThemeClientProvider"],"sources":["../../runtime/context/index.server.tsx"],"sourcesContent":["//\n// This file is the react-server component version of index.tsx\n//\n\n// @ts-ignore - in the current @types/react \"cache\" is not typed\nimport React, { ReactNode, cache, use } from \"react\";\nimport { YakTheme, YakThemeProvider as YakThemeClientProvider } from \"./index.js\";\n\n// the following import might be changed by\n// the user config in withYak to point to their own\n// context\nimport { getYakThemeContext } from \"@yak/react/context/baseContext\";\n\n/** Request based RSC YAK Context */\nconst getYakContext = cache(() => getYakThemeContext());\nexport const useTheme = (): YakTheme | undefined => {\n const theme: YakTheme | undefined | Promise<YakTheme> = getYakContext();\n return theme instanceof Promise ? use(theme) : theme;\n};\nexport const YakThemeProvider = ({ children }: { children: ReactNode }) => {\n return <YakThemeClientProvider theme={getYakContext()}>{children}</YakThemeClientProvider>;\n};\n"],"mappings":";;;;;AAcA,MAAM,gBAAgB,YAAY,mBAAmB,CAAC;AACtD,MAAa,iBAAuC;CAClD,MAAM,QAAkD,cAAc;CACtE,OAAO,iBAAiB,UAAU,IAAI,KAAK,IAAI;AACjD;AACA,MAAa,oBAAoB,EAAE,eAAwC;CACzE,OAAO,oCAACA,oBAAD,EAAwB,OAAO,cAAc,EAAqC,GAAjC,QAAiC;AAC3F"}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
//#region ../yak-internals/cross-file-resolver/types.d.ts
|
|
2
|
+
interface Cache<STORED> {
|
|
3
|
+
set(key: string, data: STORED): void;
|
|
4
|
+
get(key: string): STORED | undefined;
|
|
5
|
+
addDependency?(key: string, filePath: string): void;
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region ../yak-internals/cross-file-resolver/parseModule.d.ts
|
|
9
|
+
declare function parseModule(context: ParseContext, modulePath: string): Promise<ParsedModule>;
|
|
10
|
+
declare function uncachedParseModule(context: ParseContext, modulePath: string): Promise<ParsedModule>;
|
|
11
|
+
type ParseContext = {
|
|
12
|
+
cache?: {
|
|
13
|
+
parse?: Cache<ParsedModule>;
|
|
14
|
+
};
|
|
15
|
+
transpilationMode?: "Css" | "CssModule";
|
|
16
|
+
evaluateYakModule?: (modulePath: string) => Promise<Record<string, unknown>> | Record<string, unknown>;
|
|
17
|
+
extractExports: (modulePath: string) => Promise<ModuleExports> | ModuleExports;
|
|
18
|
+
getTransformed: (modulePath: string) => Promise<{
|
|
19
|
+
code: string;
|
|
20
|
+
map?: string;
|
|
21
|
+
}> | {
|
|
22
|
+
code: string;
|
|
23
|
+
map?: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
type ModuleExports = {
|
|
27
|
+
importYak: boolean;
|
|
28
|
+
named: Record<string, ModuleExport>;
|
|
29
|
+
all: string[];
|
|
30
|
+
};
|
|
31
|
+
type ConstantExport = {
|
|
32
|
+
type: "constant";
|
|
33
|
+
value: string | number;
|
|
34
|
+
};
|
|
35
|
+
type RecordExport = {
|
|
36
|
+
type: "record";
|
|
37
|
+
value: Record<string, ModuleExport>;
|
|
38
|
+
};
|
|
39
|
+
type UnsupportedExport = {
|
|
40
|
+
type: "unsupported";
|
|
41
|
+
hint?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Source location of the offending expression. Populated by the parser
|
|
44
|
+
* when it has access to source text; left undefined for runtime-evaluated
|
|
45
|
+
* yak modules. The error formatter is responsible for any rendering.
|
|
46
|
+
*/
|
|
47
|
+
source?: UnsupportedExportSource;
|
|
48
|
+
};
|
|
49
|
+
type UnsupportedExportSource = {
|
|
50
|
+
/** 1-based line number, 0-based column — same convention as Babel `loc`. */
|
|
51
|
+
start: {
|
|
52
|
+
line: number;
|
|
53
|
+
column: number;
|
|
54
|
+
};
|
|
55
|
+
end: {
|
|
56
|
+
line: number;
|
|
57
|
+
column: number;
|
|
58
|
+
};
|
|
59
|
+
/** The text of `start.line` from the original source — kept so the
|
|
60
|
+
* error formatter can render a snippet without re-reading the file. */
|
|
61
|
+
lineText: string;
|
|
62
|
+
};
|
|
63
|
+
type ReExport = {
|
|
64
|
+
type: "re-export";
|
|
65
|
+
name: string;
|
|
66
|
+
from: string;
|
|
67
|
+
};
|
|
68
|
+
type NamespaceReExport = {
|
|
69
|
+
type: "namespace-re-export";
|
|
70
|
+
from: string;
|
|
71
|
+
};
|
|
72
|
+
type TagTemplateExport = {
|
|
73
|
+
type: "tag-template";
|
|
74
|
+
};
|
|
75
|
+
type ModuleExport = ConstantExport | TagTemplateExport | RecordExport | UnsupportedExport | ReExport | NamespaceReExport;
|
|
76
|
+
type ParsedModule = {
|
|
77
|
+
path: string;
|
|
78
|
+
exports: ModuleExports;
|
|
79
|
+
} & ({
|
|
80
|
+
type: "regular";
|
|
81
|
+
js?: {
|
|
82
|
+
code: string;
|
|
83
|
+
map?: string;
|
|
84
|
+
};
|
|
85
|
+
styledComponents?: Record<string, StyledComponent>;
|
|
86
|
+
mixins?: Record<string, Mixin>;
|
|
87
|
+
} | {
|
|
88
|
+
type: "yak";
|
|
89
|
+
});
|
|
90
|
+
type StyledComponent = {
|
|
91
|
+
type: "styled-component";
|
|
92
|
+
value: string;
|
|
93
|
+
nameParts: string[];
|
|
94
|
+
};
|
|
95
|
+
type Mixin = {
|
|
96
|
+
type: "mixin";
|
|
97
|
+
value: string;
|
|
98
|
+
nameParts: string[];
|
|
99
|
+
};
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region ../yak-internals/cross-file-resolver/resolveCrossFileConstant.d.ts
|
|
102
|
+
/**
|
|
103
|
+
* Resolves cross-file selectors in css files
|
|
104
|
+
*
|
|
105
|
+
* e.g.:
|
|
106
|
+
* theme.ts:
|
|
107
|
+
* ```ts
|
|
108
|
+
* export const colors = {
|
|
109
|
+
* primary: "#ff0000",
|
|
110
|
+
* secondary: "#00ff00",
|
|
111
|
+
* };
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* styles.ts:
|
|
115
|
+
* ```ts
|
|
116
|
+
* import { colors } from "./theme";
|
|
117
|
+
* export const button = css`
|
|
118
|
+
* background-color: ${colors.primary};
|
|
119
|
+
* `;
|
|
120
|
+
*/
|
|
121
|
+
declare function resolveCrossFileConstant(context: ResolveContext, filePath: string, css: string): Promise<{
|
|
122
|
+
resolved: string;
|
|
123
|
+
dependencies: string[];
|
|
124
|
+
}>;
|
|
125
|
+
declare function uncachedResolveCrossFileConstant(context: ResolveContext, filePath: string, css: string): Promise<{
|
|
126
|
+
resolved: string;
|
|
127
|
+
dependencies: string[];
|
|
128
|
+
}>;
|
|
129
|
+
type ResolveContext = {
|
|
130
|
+
parse: (modulePath: string) => Promise<ParsedModule> | ParsedModule;
|
|
131
|
+
cache?: {
|
|
132
|
+
resolve?: Cache<Promise<{
|
|
133
|
+
resolved: ResolvedModule;
|
|
134
|
+
dependencies: string[];
|
|
135
|
+
}>>;
|
|
136
|
+
resolveCrossFileConstant?: Cache<Promise<{
|
|
137
|
+
resolved: string;
|
|
138
|
+
dependencies: string[];
|
|
139
|
+
}>>;
|
|
140
|
+
};
|
|
141
|
+
exportAllLimit?: number;
|
|
142
|
+
resolve: (specifier: string, importer: string) => Promise<string> | string;
|
|
143
|
+
};
|
|
144
|
+
type ExtendedRecordExport = {
|
|
145
|
+
type: "record";
|
|
146
|
+
value: Record<string, ResolvedExport>;
|
|
147
|
+
};
|
|
148
|
+
type ResolvedMixin = {
|
|
149
|
+
type: "mixin";
|
|
150
|
+
value: string;
|
|
151
|
+
};
|
|
152
|
+
type ResolvedStyledComponent = {
|
|
153
|
+
type: "styled-component";
|
|
154
|
+
className: string;
|
|
155
|
+
};
|
|
156
|
+
type ResolvedExport = Exclude<ModuleExport, RecordExport> | ExtendedRecordExport | ResolvedStyledComponent | ResolvedMixin;
|
|
157
|
+
type ResolvedExports = {
|
|
158
|
+
named: Record<string, ResolvedExport>;
|
|
159
|
+
all: string[];
|
|
160
|
+
};
|
|
161
|
+
type ResolvedModule = {
|
|
162
|
+
path: string;
|
|
163
|
+
exports: ResolvedExports;
|
|
164
|
+
};
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region ../yak-internals/cross-file-resolver/Errors.d.ts
|
|
167
|
+
declare class CauseError extends Error {
|
|
168
|
+
circular?: boolean;
|
|
169
|
+
constructor(message: string, options?: {
|
|
170
|
+
cause?: unknown;
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
declare class ResolveError extends CauseError {}
|
|
174
|
+
/**
|
|
175
|
+
* Thrown for `unsupported` exports. Subclassed so the surrounding
|
|
176
|
+
* `resolveModuleExport` catch can recognise that the error already
|
|
177
|
+
* carries its own "Unable to resolve … in module …" wrapper and
|
|
178
|
+
* doesn't need another one stacked on top.
|
|
179
|
+
*/
|
|
180
|
+
declare class UnsupportedExportError extends ResolveError {}
|
|
181
|
+
declare class CircularDependencyError extends CauseError {
|
|
182
|
+
constructor(message: string, options?: {
|
|
183
|
+
cause?: unknown;
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region ../yak-internals/loaders/lib/parseExports.d.ts
|
|
188
|
+
/**
|
|
189
|
+
* Extracts a module's exports for the cross-file resolver by parsing with babel. Nothing is executed.
|
|
190
|
+
*
|
|
191
|
+
* Handles `export const`, re-exports with a `from`, `export *`, and `export default`.
|
|
192
|
+
* Anything else becomes an `unsupported` entry with its source location, or is skipped.
|
|
193
|
+
*
|
|
194
|
+
* Throws if the source doesn't parse.
|
|
195
|
+
*/
|
|
196
|
+
declare function parseExports(sourceContents: string): Promise<ModuleExports>;
|
|
197
|
+
//#endregion
|
|
198
|
+
export { CauseError, CircularDependencyError, type Mixin, type ModuleExport, type ModuleExports, type ParseContext, type ParsedModule, type ResolveContext, ResolveError, type ResolvedExport, type ResolvedExports, type ResolvedModule, type StyledComponent, UnsupportedExportError, type UnsupportedExportSource, parseExports, parseModule, resolveCrossFileConstant, uncachedParseModule, uncachedResolveCrossFileConstant };
|
|
199
|
+
//# sourceMappingURL=index.d.ts.map
|