@yak/react 0.0.0-stage → 10.0.0-rc.1

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.
Files changed (91) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +114 -2
  3. package/dist/context/baseContext.d.ts +5 -0
  4. package/dist/context/baseContext.js +8 -0
  5. package/dist/context/baseContext.js.map +1 -0
  6. package/dist/context/index.d.ts +20 -0
  7. package/dist/context/index.js +15 -0
  8. package/dist/context/index.js.map +1 -0
  9. package/dist/context/index.server.d.ts +9 -0
  10. package/dist/context/index.server.js +17 -0
  11. package/dist/context/index.server.js.map +1 -0
  12. package/dist/cross-file-resolver/index.d.ts +199 -0
  13. package/dist/cross-file-resolver/index.js +569 -0
  14. package/dist/cross-file-resolver/index.js.map +1 -0
  15. package/dist/index.d.ts +320 -0
  16. package/dist/index.js +2 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/internal.d.ts +452 -0
  19. package/dist/internal.js +363 -0
  20. package/dist/internal.js.map +1 -0
  21. package/dist/isolated-source-eval/index.d.ts +30 -0
  22. package/dist/isolated-source-eval/index.js +317 -0
  23. package/dist/isolated-source-eval/index.js.map +1 -0
  24. package/dist/isolated-source-eval/worker.js +59 -0
  25. package/dist/isolated-source-eval/worker.js.map +1 -0
  26. package/dist/jsx-dev-runtime.d.ts +7 -0
  27. package/dist/jsx-dev-runtime.js +2 -0
  28. package/dist/jsx-dev-runtime.js.map +1 -0
  29. package/dist/jsx-runtime.d.ts +38 -0
  30. package/dist/jsx-runtime.js +2 -0
  31. package/dist/jsx-runtime.js.map +1 -0
  32. package/dist/loaders/turbo-loader.d.ts +15 -0
  33. package/dist/loaders/turbo-loader.js +816 -0
  34. package/dist/loaders/turbo-loader.js.map +1 -0
  35. package/dist/loaders/vite-plugin.d.ts +103 -0
  36. package/dist/loaders/vite-plugin.js +885 -0
  37. package/dist/loaders/vite-plugin.js.map +1 -0
  38. package/dist/loaders/webpack-loader.d.ts +12 -0
  39. package/dist/loaders/webpack-loader.js +710 -0
  40. package/dist/loaders/webpack-loader.js.map +1 -0
  41. package/dist/rsbuild/index.d.ts +29 -0
  42. package/dist/rsbuild/index.js +51 -0
  43. package/dist/rsbuild/index.js.map +1 -0
  44. package/dist/static/chunk-DK3Fl9T5.js +1 -0
  45. package/dist/static/index.d.ts +28 -0
  46. package/dist/static/index.js +2 -0
  47. package/dist/static/index.js.map +1 -0
  48. package/dist/withYak/index.d.ts +112 -0
  49. package/dist/withYak/index.js +171 -0
  50. package/dist/withYak/index.js.map +1 -0
  51. package/loaders/lib/resolveCrossFileSelectors.ts +161 -0
  52. package/loaders/turbo-evaluator.ts +134 -0
  53. package/loaders/turbo-loader.ts +184 -0
  54. package/loaders/vite-plugin.ts +28 -0
  55. package/loaders/webpack-loader.ts +41 -0
  56. package/package.json +155 -3
  57. package/rsbuild/index.ts +91 -0
  58. package/runtime/__tests__/atoms.test.tsx +48 -0
  59. package/runtime/__tests__/attrs.test.tsx +490 -0
  60. package/runtime/__tests__/cssLiteral.test.tsx +503 -0
  61. package/runtime/__tests__/cssProp.test.tsx +392 -0
  62. package/runtime/__tests__/cssPropTest.tsx +227 -0
  63. package/runtime/__tests__/foldedJsxParity.test.tsx +117 -0
  64. package/runtime/__tests__/styled.test.tsx +653 -0
  65. package/runtime/__tests__/tsconfig.json +18 -0
  66. package/runtime/__tests__/typeTest.tsx +374 -0
  67. package/runtime/atoms.tsx +36 -0
  68. package/runtime/context/README.md +84 -0
  69. package/runtime/context/baseContext.tsx +5 -0
  70. package/runtime/context/index.server.tsx +22 -0
  71. package/runtime/context/index.tsx +36 -0
  72. package/runtime/cssLiteral.tsx +214 -0
  73. package/runtime/globalStyle.tsx +54 -0
  74. package/runtime/index.ts +37 -0
  75. package/runtime/internal.ts +42 -0
  76. package/runtime/internals/mergeClassNames.ts +23 -0
  77. package/runtime/internals/mergeCssProp.ts +69 -0
  78. package/runtime/internals/propMarkers.ts +20 -0
  79. package/runtime/internals/unitPostFix.ts +34 -0
  80. package/runtime/jsx-dev-runtime.ts +6 -0
  81. package/runtime/jsx-runtime.ts +48 -0
  82. package/runtime/keyframes.tsx +30 -0
  83. package/runtime/mocks/cssLiteral.ts +74 -0
  84. package/runtime/mocks/globalStyle.ts +14 -0
  85. package/runtime/mocks/keyframes.ts +29 -0
  86. package/runtime/mocks/styled.ts +8 -0
  87. package/runtime/publicStyledApi.ts +159 -0
  88. package/runtime/styled.tsx +372 -0
  89. package/runtime/styledDom.tsx +139 -0
  90. package/withYak/allow-global-css.ts +94 -0
  91. package/withYak/index.ts +268 -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,115 @@
1
- # Temporary Holding Version
1
+ # @yak/react
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ ![A yak Riding on a rusty SWC Rocket](https://github.com/user-attachments/assets/72494b1c-db1a-4ff7-bd6f-2ed3535fb126)
4
+
5
+ [![npm version](https://badge.fury.io/js/@yak%2Freact.svg)](https://www.npmjs.com/package/@yak/react)
6
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](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
+ | 10.x | >= 16.4.0 | >= 7.0.0 | 19.x | 79.0.0 |
44
+ | 9.x | >= 16.1.0 | >= 7.0.0 (9.1+) | 19.x | 56.0.0 |
45
+ | 8.x | >= 16.0.0 | - | 19.x | 45.0.1 |
46
+ | 7.x | >= 15.4.4 | - | 19.x | 38.0.1 |
47
+ | 6.x | >= 15.4.1 | - | 19.x | 27.0.6 |
48
+ | 5.x | >= 15.2.1 | - | 19.x | 16.0.0 |
49
+ | 4.x | >= 15.0.4 | - | 19.x | 5.0.1 |
50
+ | 3.x | 15.x | - | 18.x / 19.x | 3.0.2 |
51
+ | 2.x | 14.x | - | 18.x / 19.x | 0.279.0 |
52
+
53
+ ## Installation
54
+
55
+ ```bash
56
+ npm install @yak/react
57
+ ```
58
+
59
+ ## Quick Start
60
+
61
+ ### Next.js
62
+
63
+ ```js
64
+ // next.config.ts
65
+ import { withYak } from "@yak/react/withYak";
66
+
67
+ export default withYak({
68
+ // your next.js config
69
+ });
70
+ ```
71
+
72
+ ### Vite
73
+
74
+ ```js
75
+ // vite.config.ts
76
+ import { defineConfig } from "vite";
77
+ import react from "@vitejs/plugin-react-swc";
78
+ import { viteYak } from "@yak/react/vite";
79
+
80
+ export default defineConfig({
81
+ plugins: [viteYak(), react()],
82
+ });
83
+ ```
84
+
85
+ ### Usage
86
+
87
+ ```jsx
88
+ import { styled } from "@yak/react";
89
+
90
+ const Button = styled.button`
91
+ background: #bf4f74;
92
+ color: white;
93
+ padding: 0.5rem 1rem;
94
+ border-radius: 4px;
95
+ `;
96
+ ```
97
+
98
+ ### Jest
99
+
100
+ `@yak/react` is ESM only. With `next/jest`, add it to `transpilePackages` in your Next.js config, so that Jest can load it:
101
+
102
+ ```js
103
+ // next.config.mjs
104
+ const nextConfig = {
105
+ transpilePackages: ["@yak/react"],
106
+ };
107
+ ```
108
+
109
+ ## License
110
+
111
+ **@yak/react** is licensed under the [MIT License](https://github.com/DigitecGalaxus/next-yak/blob/main/LICENSE).
112
+
113
+ ## Contributing
114
+
115
+ Contributions are welcome! The [contributing guide](https://github.com/DigitecGalaxus/next-yak/blob/main/CONTRIBUTION.md) helps you get started.
@@ -0,0 +1,5 @@
1
+ import { YakTheme } from "@yak/react";
2
+ //#region runtime/context/baseContext.d.ts
3
+ export declare function getYakThemeContext(): YakTheme | undefined;
4
+ //#endregion
5
+ //# sourceMappingURL=baseContext.d.ts.map
@@ -0,0 +1,8 @@
1
+ //#region runtime/context/baseContext.tsx
2
+ function getYakThemeContext() {
3
+ return {};
4
+ }
5
+
6
+ //#endregion
7
+ export { getYakThemeContext };
8
+ //# sourceMappingURL=baseContext.js.map
@@ -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,20 @@
1
+ import React, { ReactNode } from "react";
2
+ //#region runtime/context/index.d.ts
3
+ export 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
+ export 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
+ export declare const YakThemeProvider: ({ children, theme }: {
16
+ children: ReactNode;
17
+ theme?: YakTheme;
18
+ }) => React.JSX.Element;
19
+ //#endregion
20
+ //# 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,9 @@
1
+ import React, { ReactNode } from "react";
2
+ import { YakTheme } from "./index.js";
3
+ //#region runtime/context/index.server.d.ts
4
+ export declare const useTheme: () => YakTheme | undefined;
5
+ export declare const YakThemeProvider: ({ children }: {
6
+ children: ReactNode;
7
+ }) => React.JSX.Element;
8
+ //#endregion
9
+ //# 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
+ export declare function parseModule(context: ParseContext, modulePath: string): Promise<ParsedModule>;
10
+ export declare function uncachedParseModule(context: ParseContext, modulePath: string): Promise<ParsedModule>;
11
+ type ParseContext = {
12
+ cache?: {
13
+ parse?: Cache<ParsedModule>;
14
+ };
15
+ evaluateYakModule?: (modulePath: string) => Promise<Record<string, unknown>> | Record<string, unknown>;
16
+ extractExports: (modulePath: string) => Promise<ModuleExports> | ModuleExports;
17
+ getTransformed: (modulePath: string) => Promise<{
18
+ code: string;
19
+ map?: string;
20
+ }> | {
21
+ code: string;
22
+ map?: string;
23
+ };
24
+ };
25
+ type ModuleExports = {
26
+ importYak: boolean;
27
+ named: Record<string, ModuleExport>;
28
+ all: string[];
29
+ };
30
+ type ConstantExport = {
31
+ type: "constant";
32
+ value: string | number;
33
+ };
34
+ type RecordExport = {
35
+ type: "record";
36
+ value: Record<string, ModuleExport>;
37
+ };
38
+ type UnsupportedExport = {
39
+ type: "unsupported";
40
+ hint?: string;
41
+ /**
42
+ * Source location of the offending expression. Populated by the parser
43
+ * when it has access to source text; left undefined for runtime-evaluated
44
+ * yak modules. The error formatter is responsible for any rendering.
45
+ */
46
+ source?: UnsupportedExportSource;
47
+ };
48
+ type UnsupportedExportSource = {
49
+ /** 1-based line number, 0-based column — same convention as Babel `loc`. */
50
+ start: {
51
+ line: number;
52
+ column: number;
53
+ };
54
+ end: {
55
+ line: number;
56
+ column: number;
57
+ };
58
+ /** The text of `start.line` from the original source — kept so the
59
+ * error formatter can render a snippet without re-reading the file. */
60
+ lineText: string;
61
+ };
62
+ type ReExport = {
63
+ type: "re-export";
64
+ name: string;
65
+ from: string;
66
+ };
67
+ type NamespaceReExport = {
68
+ type: "namespace-re-export";
69
+ from: string;
70
+ };
71
+ type TagTemplateExport = {
72
+ type: "tag-template";
73
+ };
74
+ type ModuleExport = ConstantExport | TagTemplateExport | RecordExport | UnsupportedExport | ReExport | NamespaceReExport;
75
+ type ParsedModule = {
76
+ path: string;
77
+ exports: ModuleExports;
78
+ } & ({
79
+ type: "regular";
80
+ js?: {
81
+ code: string;
82
+ map?: string;
83
+ };
84
+ styledComponents?: Record<string, StyledComponent>;
85
+ mixins?: Record<string, Mixin>;
86
+ } | {
87
+ type: "yak";
88
+ });
89
+ type StyledComponent = {
90
+ type: "styled-component";
91
+ value: string;
92
+ nameParts: string[];
93
+ };
94
+ type Mixin = {
95
+ type: "mixin";
96
+ value: string;
97
+ nameParts: string[];
98
+ };
99
+ //#endregion
100
+ //#region ../yak-internals/cross-file-resolver/resolveCrossFileConstant.d.ts
101
+ /**
102
+ * Resolves cross-file selectors in css files
103
+ *
104
+ * e.g.:
105
+ * theme.ts:
106
+ * ```ts
107
+ * export const colors = {
108
+ * primary: "#ff0000",
109
+ * secondary: "#00ff00",
110
+ * };
111
+ * ```
112
+ *
113
+ * styles.ts:
114
+ * ```ts
115
+ * import { colors } from "./theme";
116
+ * export const button = css`
117
+ * background-color: ${colors.primary};
118
+ * `;
119
+ */
120
+ export declare function resolveCrossFileConstant(context: ResolveContext, filePath: string, css: string): Promise<{
121
+ resolved: string;
122
+ dependencies: string[];
123
+ }>;
124
+ export declare function uncachedResolveCrossFileConstant(context: ResolveContext, filePath: string, css: string): Promise<{
125
+ resolved: string;
126
+ dependencies: string[];
127
+ }>;
128
+ type ResolveContext = {
129
+ parse: (modulePath: string) => Promise<ParsedModule> | ParsedModule;
130
+ cache?: {
131
+ resolve?: Cache<Promise<{
132
+ resolved: ResolvedModule;
133
+ dependencies: string[];
134
+ }>>;
135
+ resolveCrossFileConstant?: Cache<Promise<{
136
+ resolved: string;
137
+ dependencies: string[];
138
+ }>>;
139
+ };
140
+ exportAllLimit?: number;
141
+ resolve: (specifier: string, importer: string) => Promise<string> | string;
142
+ };
143
+ type ExtendedRecordExport = {
144
+ type: "record";
145
+ value: Record<string, ResolvedExport>;
146
+ };
147
+ type ResolvedMixin = {
148
+ type: "mixin";
149
+ value: string;
150
+ };
151
+ type ResolvedStyledComponent = {
152
+ type: "styled-component";
153
+ className: string;
154
+ };
155
+ type ResolvedExport = Exclude<ModuleExport, RecordExport> | ExtendedRecordExport | ResolvedStyledComponent | ResolvedMixin;
156
+ type ResolvedExports = {
157
+ named: Record<string, ResolvedExport>;
158
+ all: string[];
159
+ };
160
+ type ResolvedModule = {
161
+ path: string;
162
+ exports: ResolvedExports;
163
+ };
164
+ //#endregion
165
+ //#region ../yak-internals/cross-file-resolver/Errors.d.ts
166
+ export declare class CauseError extends Error {
167
+ circular?: boolean;
168
+ constructor(message: string, options?: {
169
+ cause?: unknown;
170
+ });
171
+ }
172
+ export declare class ResolveError extends CauseError {}
173
+ /**
174
+ * Thrown for `unsupported` exports. Subclassed so the surrounding
175
+ * `resolveModuleExport` catch can recognise that the error already
176
+ * carries its own "Unable to resolve … in module …" wrapper and
177
+ * doesn't need another one stacked on top.
178
+ */
179
+ export declare class UnsupportedExportError extends ResolveError {}
180
+ export declare class CircularDependencyError extends CauseError {
181
+ constructor(message: string, options?: {
182
+ cause?: unknown;
183
+ });
184
+ }
185
+ //#endregion
186
+ //#region ../yak-internals/loaders/lib/parseExports.d.ts
187
+ /**
188
+ * Extracts a module's exports for the cross-file resolver by parsing with babel. Nothing is executed.
189
+ *
190
+ * Handles `export const`, export lists (`export { x }`), re-exports with a `from`,
191
+ * `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
+ export declare function parseExports(sourceContents: string): Promise<ModuleExports>;
197
+ //#endregion
198
+ export type { Mixin, ModuleExport, ModuleExports, ParseContext, ParsedModule, ResolveContext, ResolvedExport, ResolvedExports, ResolvedModule, StyledComponent, UnsupportedExportSource };
199
+ //# sourceMappingURL=index.d.ts.map