next-yak 9.8.0 → 9.9.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/dist/cross-file-resolver/index.d.ts +198 -0
- package/dist/cross-file-resolver/index.js +533 -0
- package/dist/cross-file-resolver/index.js.map +1 -0
- package/dist/internal.cjs +7 -1
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.js +7 -1
- package/dist/internal.js.map +1 -1
- package/dist/isolated-source-eval/index.d.ts +1 -1
- package/dist/isolated-source-eval/index.js +2 -2
- package/dist/isolated-source-eval/index.js.map +1 -1
- package/dist/isolated-source-eval/worker.js +1 -1
- package/dist/isolated-source-eval/worker.js.map +1 -1
- package/dist/loaders/turbo-loader.cjs +39 -8
- package/dist/loaders/turbo-loader.cjs.map +1 -1
- package/dist/loaders/vite-plugin.d.ts +104 -8
- package/dist/loaders/vite-plugin.js +102 -43
- package/dist/loaders/vite-plugin.js.map +1 -1
- package/dist/loaders/webpack-loader.cjs +87 -80
- package/dist/loaders/webpack-loader.cjs.map +1 -1
- package/dist/withYak/index.cjs +21 -18
- package/dist/withYak/index.cjs.map +1 -1
- package/dist/withYak/index.d.cts +6 -4
- package/dist/withYak/index.d.ts +6 -4
- package/dist/withYak/index.js +21 -18
- package/dist/withYak/index.js.map +1 -1
- package/loaders/lib/resolveCrossFileSelectors.ts +6 -204
- package/loaders/turbo-evaluator.ts +1 -1
- package/loaders/turbo-loader.ts +10 -5
- package/loaders/vite-plugin.ts +24 -342
- package/loaders/webpack-loader.ts +2 -2
- package/package.json +16 -4
- package/runtime/__tests__/cssProp.test.tsx +33 -1
- package/runtime/internals/mergeCssProp.ts +14 -2
- package/withYak/index.ts +8 -99
- package/loaders/lib/__tests__/debugLogger.test.ts +0 -113
- package/loaders/lib/debugLogger.ts +0 -116
- package/loaders/lib/extractCss.ts +0 -35
|
@@ -0,0 +1,198 @@
|
|
|
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`. */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
|
+
declare function resolveCrossFileConstant(context: ResolveContext, filePath: string, css: string): Promise<{
|
|
121
|
+
resolved: string;
|
|
122
|
+
dependencies: string[];
|
|
123
|
+
}>;
|
|
124
|
+
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
|
+
declare class CauseError extends Error {
|
|
167
|
+
circular?: boolean;
|
|
168
|
+
constructor(message: string, options?: {
|
|
169
|
+
cause?: unknown;
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
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
|
+
declare class UnsupportedExportError extends ResolveError {}
|
|
180
|
+
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`, re-exports with a `from`, `export *`, and `export default`.
|
|
191
|
+
* Anything else becomes an `unsupported` entry with its source location, or is skipped.
|
|
192
|
+
*
|
|
193
|
+
* Throws if the source doesn't parse.
|
|
194
|
+
*/
|
|
195
|
+
declare function parseExports(sourceContents: string): Promise<ModuleExports>;
|
|
196
|
+
//#endregion
|
|
197
|
+
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 };
|
|
198
|
+
//# sourceMappingURL=index.d.ts.map
|