next-yak 9.8.0 → 9.10.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.
Files changed (70) hide show
  1. package/dist/context/baseContext.cjs +0 -1
  2. package/dist/context/baseContext.cjs.map +1 -1
  3. package/dist/context/baseContext.d.cts +0 -1
  4. package/dist/context/baseContext.d.ts +0 -1
  5. package/dist/context/index.cjs +1 -1
  6. package/dist/context/index.cjs.map +1 -1
  7. package/dist/context/index.d.cts +1 -5
  8. package/dist/context/index.d.ts +1 -5
  9. package/dist/context/index.server.cjs +1 -1
  10. package/dist/context/index.server.cjs.map +1 -1
  11. package/dist/context/index.server.d.cts +1 -4
  12. package/dist/context/index.server.d.ts +1 -4
  13. package/dist/cross-file-resolver/index.d.ts +199 -0
  14. package/dist/cross-file-resolver/index.js +535 -0
  15. package/dist/cross-file-resolver/index.js.map +1 -0
  16. package/dist/index.cjs +1 -1
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +3 -7
  19. package/dist/index.d.ts +3 -7
  20. package/dist/index.js +1 -1
  21. package/dist/index.js.map +1 -1
  22. package/dist/internal.cjs +14 -7
  23. package/dist/internal.cjs.map +1 -1
  24. package/dist/internal.d.cts +12 -9
  25. package/dist/internal.d.ts +12 -9
  26. package/dist/internal.js +13 -6
  27. package/dist/internal.js.map +1 -1
  28. package/dist/isolated-source-eval/index.d.ts +1 -1
  29. package/dist/isolated-source-eval/index.js +5 -3
  30. package/dist/isolated-source-eval/index.js.map +1 -1
  31. package/dist/isolated-source-eval/worker.js +1 -1
  32. package/dist/isolated-source-eval/worker.js.map +1 -1
  33. package/dist/jsx-dev-runtime.cjs +1 -1
  34. package/dist/jsx-dev-runtime.cjs.map +1 -1
  35. package/dist/jsx-dev-runtime.d.cts +0 -1
  36. package/dist/jsx-dev-runtime.d.ts +0 -1
  37. package/dist/jsx-runtime.cjs +1 -1
  38. package/dist/jsx-runtime.cjs.map +1 -1
  39. package/dist/jsx-runtime.d.cts +2 -1
  40. package/dist/jsx-runtime.d.ts +2 -1
  41. package/dist/loaders/turbo-loader.cjs +61 -19
  42. package/dist/loaders/turbo-loader.cjs.map +1 -1
  43. package/dist/loaders/turbo-loader.d.cts +0 -1
  44. package/dist/loaders/vite-plugin.d.ts +99 -8
  45. package/dist/loaders/vite-plugin.js +114 -51
  46. package/dist/loaders/vite-plugin.js.map +1 -1
  47. package/dist/loaders/webpack-loader.cjs +97 -87
  48. package/dist/loaders/webpack-loader.cjs.map +1 -1
  49. package/dist/loaders/webpack-loader.d.cts +0 -1
  50. package/dist/rsbuild/index.d.ts +0 -1
  51. package/dist/rsbuild/index.js.map +1 -1
  52. package/dist/withYak/index.cjs +22 -19
  53. package/dist/withYak/index.cjs.map +1 -1
  54. package/dist/withYak/index.d.cts +6 -4
  55. package/dist/withYak/index.d.ts +6 -4
  56. package/dist/withYak/index.js +21 -18
  57. package/dist/withYak/index.js.map +1 -1
  58. package/loaders/lib/resolveCrossFileSelectors.ts +6 -204
  59. package/loaders/turbo-evaluator.ts +1 -1
  60. package/loaders/turbo-loader.ts +29 -11
  61. package/loaders/vite-plugin.ts +24 -342
  62. package/loaders/webpack-loader.ts +2 -2
  63. package/package.json +28 -17
  64. package/runtime/__tests__/cssProp.test.tsx +79 -25
  65. package/runtime/internals/mergeCssProp.ts +31 -16
  66. package/runtime/mocks/cssLiteral.ts +1 -1
  67. package/withYak/index.ts +8 -99
  68. package/loaders/lib/__tests__/debugLogger.test.ts +0 -113
  69. package/loaders/lib/debugLogger.ts +0 -116
  70. package/loaders/lib/extractCss.ts +0 -35
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
2
  //#region runtime/context/baseContext.tsx
4
3
  function getYakThemeContext() {
5
4
  return {};
@@ -1 +1 @@
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;CACnC,OAAO,CAAC;AACV"}
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;CACnC,OAAO,CAAC;AACV"}
@@ -1,5 +1,4 @@
1
1
  import { YakTheme } from "next-yak";
2
-
3
2
  //#region runtime/context/baseContext.d.ts
4
3
  declare function getYakThemeContext(): YakTheme | undefined;
5
4
  //#endregion
@@ -1,5 +1,4 @@
1
1
  import { YakTheme } from "next-yak";
2
-
3
2
  //#region runtime/context/baseContext.d.ts
4
3
  declare function getYakThemeContext(): YakTheme | undefined;
5
4
  //#endregion
@@ -22,7 +22,7 @@ var __copyProps = (to, from, except, desc) => {
22
22
  }
23
23
  return to;
24
24
  };
25
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
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
26
  value: mod,
27
27
  enumerable: true
28
28
  }) : target, mod));
@@ -1 +1 @@
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,CAAC,CAAC;AAO7C,MAAa,iBAA2B;CACtC,MAAM,yBAAc,UAAU;CAC9B,OAAO,mBAAmB,yBAAc,OAAO,IAAI;AACrD;AAOA,MAAa,oBAAoB,EAC/B,UACA,QAAQ,CAAC,QAIL,4CAAC,WAAW,UAAZ,EAAqB,OAAO,MAAsC,GAA9B,QAA8B"}
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/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,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"}
@@ -1,5 +1,4 @@
1
1
  import React, { ReactNode } from "react";
2
-
3
2
  //#region runtime/context/index.d.ts
4
3
  interface YakTheme {}
5
4
  /**
@@ -13,10 +12,7 @@ declare const useTheme: () => YakTheme;
13
12
  *
14
13
  * @see https://github.com/DigitecGalaxus/next-yak/blob/main/packages/next-yak/runtime/context/README.md
15
14
  */
16
- declare const YakThemeProvider: ({
17
- children,
18
- theme
19
- }: {
15
+ declare const YakThemeProvider: ({ children, theme }: {
20
16
  children: ReactNode;
21
17
  theme?: YakTheme;
22
18
  }) => React.JSX.Element;
@@ -1,5 +1,4 @@
1
1
  import React, { ReactNode } from "react";
2
-
3
2
  //#region runtime/context/index.d.ts
4
3
  interface YakTheme {}
5
4
  /**
@@ -13,10 +12,7 @@ declare const useTheme: () => YakTheme;
13
12
  *
14
13
  * @see https://github.com/DigitecGalaxus/next-yak/blob/main/packages/next-yak/runtime/context/README.md
15
14
  */
16
- declare const YakThemeProvider: ({
17
- children,
18
- theme
19
- }: {
15
+ declare const YakThemeProvider: ({ children, theme }: {
20
16
  children: ReactNode;
21
17
  theme?: YakTheme;
22
18
  }) => React.JSX.Element;
@@ -20,7 +20,7 @@ var __copyProps = (to, from, except, desc) => {
20
20
  }
21
21
  return to;
22
22
  };
23
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
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
24
  value: mod,
25
25
  enumerable: true
26
26
  }) : target, mod));
@@ -1 +1 @@
1
- {"version":3,"file":"index.server.cjs","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 \"next-yak/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,4FAA+C,CAAC;AACtD,MAAa,iBAAuC;CAClD,MAAM,QAAkD,cAAc;CACtE,OAAO,iBAAiB,yBAAc,KAAK,IAAI;AACjD;AACA,MAAa,oBAAoB,EAAE,eAAwC;CACzE,OAAO,4CAACA,2CAAD,EAAwB,OAAO,cAAc,EAAqC,GAAjC,QAAiC;AAC3F"}
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 \"next-yak/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,iDAAmB,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"}
@@ -1,11 +1,8 @@
1
1
  import React, { ReactNode } from "react";
2
2
  import { YakTheme } from "./index.js";
3
-
4
3
  //#region runtime/context/index.server.d.ts
5
4
  declare const useTheme: () => YakTheme | undefined;
6
- declare const YakThemeProvider: ({
7
- children
8
- }: {
5
+ declare const YakThemeProvider: ({ children }: {
9
6
  children: ReactNode;
10
7
  }) => React.JSX.Element;
11
8
  //#endregion
@@ -1,11 +1,8 @@
1
1
  import React, { ReactNode } from "react";
2
2
  import { YakTheme } from "./index.js";
3
-
4
3
  //#region runtime/context/index.server.d.ts
5
4
  declare const useTheme: () => YakTheme | undefined;
6
- declare const YakThemeProvider: ({
7
- children
8
- }: {
5
+ declare const YakThemeProvider: ({ children }: {
9
6
  children: ReactNode;
10
7
  }) => React.JSX.Element;
11
8
  //#endregion
@@ -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