@tailwindcss/node 0.0.0-insiders.f8b9aa9 → 0.0.0-insiders.f945c3d

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 CHANGED
@@ -27,14 +27,10 @@ For full documentation, visit [tailwindcss.com](https://tailwindcss.com).
27
27
 
28
28
  ## Community
29
29
 
30
- For help, discussion about best practices, or any other conversation that would benefit from being searchable:
30
+ For help, discussion about best practices, or feature ideas:
31
31
 
32
32
  [Discuss Tailwind CSS on GitHub](https://github.com/tailwindcss/tailwindcss/discussions)
33
33
 
34
- For chatting with others using the framework:
35
-
36
- [Join the Tailwind CSS Discord Server](https://discord.gg/7NF8GNe)
37
-
38
34
  ## Contributing
39
35
 
40
36
  If you're interested in contributing to Tailwind CSS, please read our [contributing docs](https://github.com/tailwindcss/tailwindcss/blob/next/.github/CONTRIBUTING.md) **before submitting a pull request**.
@@ -1 +1 @@
1
- import{isBuiltin as i}from"node:module";var o=async(a,e,u)=>{let r=await u(a,e);if(r.url===import.meta.url||i(r.url)||!e.parentURL)return r;let t=new URL(e.parentURL).searchParams.get("id");if(t===null)return r;let l=new URL(r.url);return l.searchParams.set("id",t),{...r,url:`${l}`}};export{o as resolve};
1
+ import{isBuiltin as i}from"module";var o=async(a,e,u)=>{let r=await u(a,e);if(r.url===import.meta.url||i(r.url)||!e.parentURL)return r;let t=new URL(e.parentURL).searchParams.get("id");if(t===null)return r;let l=new URL(r.url);return l.searchParams.set("id",t),{...r,url:`${l}`}};export{o as resolve};
package/dist/index.d.mts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { Candidate, Variant } from './candidate';
2
2
  import { compileAstNodes } from './compile';
3
- import { ClassEntry, VariantEntry } from './intellisense';
3
+ import { ClassEntry, VariantEntry, CanonicalizeOptions } from './intellisense';
4
4
  import { Theme } from './theme';
5
5
  import { Utilities } from './utilities';
6
6
  import { Variants } from './variants';
7
+ import * as tailwindcss from 'tailwindcss';
7
8
  import { Polyfills, Features } from 'tailwindcss';
8
9
  export { Features, Polyfills } from 'tailwindcss';
9
10
 
@@ -14,6 +15,10 @@ declare namespace env {
14
15
  export { env_DEBUG as DEBUG };
15
16
  }
16
17
 
18
+ declare const enum CompileAstFlags {
19
+ None = 0,
20
+ RespectImportant = 1
21
+ }
17
22
  type DesignSystem = {
18
23
  theme: Theme;
19
24
  utilities: Utilities;
@@ -25,48 +30,141 @@ type DesignSystem = {
25
30
  getVariants(): VariantEntry[];
26
31
  parseCandidate(candidate: string): Readonly<Candidate>[];
27
32
  parseVariant(variant: string): Readonly<Variant> | null;
28
- compileAstNodes(candidate: Candidate): ReturnType<typeof compileAstNodes>;
33
+ compileAstNodes(candidate: Candidate, flags?: CompileAstFlags): ReturnType<typeof compileAstNodes>;
34
+ printCandidate(candidate: Candidate): string;
35
+ printVariant(variant: Variant): string;
29
36
  getVariantOrder(): Map<Variant, number>;
30
37
  resolveThemeValue(path: string, forceInline?: boolean): string | undefined;
31
38
  trackUsedVariables(raw: string): void;
39
+ canonicalizeCandidates(candidates: string[], options?: CanonicalizeOptions): string[];
32
40
  candidatesToCss(classes: string[]): (string | null)[];
33
41
  };
34
42
 
43
+ /**
44
+ * The source code for one or more nodes in the AST
45
+ *
46
+ * This generally corresponds to a stylesheet
47
+ */
48
+ interface Source {
49
+ /**
50
+ * The path to the file that contains the referenced source code
51
+ *
52
+ * If this references the *output* source code, this is `null`.
53
+ */
54
+ file: string | null;
55
+ /**
56
+ * The referenced source code
57
+ */
58
+ code: string;
59
+ }
60
+ /**
61
+ * The file and offsets within it that this node covers
62
+ *
63
+ * This can represent either:
64
+ * - A location in the original CSS which caused this node to be created
65
+ * - A location in the output CSS where this node resides
66
+ */
67
+ type SourceLocation = [source: Source, start: number, end: number];
68
+
69
+ /**
70
+ * Line offset tables are the key to generating our source maps. They allow us
71
+ * to store indexes with our AST nodes and later convert them into positions as
72
+ * when given the source that the indexes refer to.
73
+ */
74
+ /**
75
+ * A position in source code
76
+ *
77
+ * https://tc39.es/ecma426/#sec-position-record-type
78
+ */
79
+ interface Position {
80
+ /** The line number, one-based */
81
+ line: number;
82
+ /** The column/character number, one-based */
83
+ column: number;
84
+ }
85
+
86
+ interface OriginalPosition extends Position {
87
+ source: DecodedSource;
88
+ }
89
+ /**
90
+ * A "decoded" sourcemap
91
+ *
92
+ * @see https://tc39.es/ecma426/#decoded-source-map-record
93
+ */
94
+ interface DecodedSourceMap {
95
+ file: string | null;
96
+ sources: DecodedSource[];
97
+ mappings: DecodedMapping[];
98
+ }
99
+ /**
100
+ * A "decoded" source
101
+ *
102
+ * @see https://tc39.es/ecma426/#decoded-source-record
103
+ */
104
+ interface DecodedSource {
105
+ url: string | null;
106
+ content: string | null;
107
+ ignore: boolean;
108
+ }
109
+ /**
110
+ * A "decoded" mapping
111
+ *
112
+ * @see https://tc39.es/ecma426/#decoded-mapping-record
113
+ */
114
+ interface DecodedMapping {
115
+ originalPosition: OriginalPosition | null;
116
+ generatedPosition: Position;
117
+ name: string | null;
118
+ }
119
+
35
120
  type StyleRule = {
36
121
  kind: 'rule';
37
122
  selector: string;
38
123
  nodes: AstNode[];
124
+ src?: SourceLocation;
125
+ dst?: SourceLocation;
39
126
  };
40
127
  type AtRule = {
41
128
  kind: 'at-rule';
42
129
  name: string;
43
130
  params: string;
44
131
  nodes: AstNode[];
132
+ src?: SourceLocation;
133
+ dst?: SourceLocation;
45
134
  };
46
135
  type Declaration = {
47
136
  kind: 'declaration';
48
137
  property: string;
49
138
  value: string | undefined;
50
139
  important: boolean;
140
+ src?: SourceLocation;
141
+ dst?: SourceLocation;
51
142
  };
52
143
  type Comment = {
53
144
  kind: 'comment';
54
145
  value: string;
146
+ src?: SourceLocation;
147
+ dst?: SourceLocation;
55
148
  };
56
149
  type Context = {
57
150
  kind: 'context';
58
151
  context: Record<string, string | boolean>;
59
152
  nodes: AstNode[];
153
+ src?: undefined;
154
+ dst?: undefined;
60
155
  };
61
156
  type AtRoot = {
62
157
  kind: 'at-root';
63
158
  nodes: AstNode[];
159
+ src?: undefined;
160
+ dst?: undefined;
64
161
  };
65
162
  type AstNode = StyleRule | AtRule | Declaration | Comment | Context | AtRoot;
66
163
 
67
164
  type Resolver = (id: string, base: string) => Promise<string | false | undefined>;
68
165
  interface CompileOptions {
69
166
  base: string;
167
+ from?: string;
70
168
  onDependency: (path: string) => void;
71
169
  shouldRewriteUrls?: boolean;
72
170
  polyfills?: Polyfills;
@@ -98,11 +196,13 @@ declare function compile(css: string, options: CompileOptions): Promise<{
98
196
  } | null;
99
197
  features: Features;
100
198
  build(candidates: string[]): string;
199
+ buildSourceMap(): tailwindcss.DecodedSourceMap;
101
200
  }>;
102
201
  declare function __unstable__loadDesignSystem(css: string, { base }: {
103
202
  base: string;
104
203
  }): Promise<DesignSystem>;
105
204
  declare function loadModule(id: string, base: string, onDependency: (path: string) => void, customJsResolver?: Resolver): Promise<{
205
+ path: string;
106
206
  base: string;
107
207
  module: any;
108
208
  }>;
@@ -121,9 +221,32 @@ declare class Instrumentation implements Disposable {
121
221
 
122
222
  declare function normalizePath(originalPath: string): string;
123
223
 
124
- declare function optimize(input: string, { file, minify }?: {
224
+ interface OptimizeOptions {
225
+ /**
226
+ * The file being transformed
227
+ */
125
228
  file?: string;
229
+ /**
230
+ * Enabled minified output
231
+ */
126
232
  minify?: boolean;
127
- }): string;
233
+ /**
234
+ * The output source map before optimization
235
+ *
236
+ * If omitted a resulting source map will not be available
237
+ */
238
+ map?: string;
239
+ }
240
+ interface TransformResult {
241
+ code: string;
242
+ map: string | undefined;
243
+ }
244
+ declare function optimize(input: string, { file, minify, map }?: OptimizeOptions): TransformResult;
245
+
246
+ interface SourceMap {
247
+ readonly raw: string;
248
+ readonly inline: string;
249
+ }
250
+ declare function toSourceMap(map: DecodedSourceMap | string): SourceMap;
128
251
 
129
- export { type CompileOptions, Instrumentation, type Resolver, __unstable__loadDesignSystem, compile, compileAst, env, loadModule, normalizePath, optimize };
252
+ export { type CompileOptions, type DecodedSource, type DecodedSourceMap, Instrumentation, type OptimizeOptions, type Resolver, type SourceMap, type TransformResult, __unstable__loadDesignSystem, compile, compileAst, env, loadModule, normalizePath, optimize, toSourceMap };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { Candidate, Variant } from './candidate';
2
2
  import { compileAstNodes } from './compile';
3
- import { ClassEntry, VariantEntry } from './intellisense';
3
+ import { ClassEntry, VariantEntry, CanonicalizeOptions } from './intellisense';
4
4
  import { Theme } from './theme';
5
5
  import { Utilities } from './utilities';
6
6
  import { Variants } from './variants';
7
+ import * as tailwindcss from 'tailwindcss';
7
8
  import { Polyfills, Features } from 'tailwindcss';
8
9
  export { Features, Polyfills } from 'tailwindcss';
9
10
 
@@ -14,6 +15,10 @@ declare namespace env {
14
15
  export { env_DEBUG as DEBUG };
15
16
  }
16
17
 
18
+ declare const enum CompileAstFlags {
19
+ None = 0,
20
+ RespectImportant = 1
21
+ }
17
22
  type DesignSystem = {
18
23
  theme: Theme;
19
24
  utilities: Utilities;
@@ -25,48 +30,141 @@ type DesignSystem = {
25
30
  getVariants(): VariantEntry[];
26
31
  parseCandidate(candidate: string): Readonly<Candidate>[];
27
32
  parseVariant(variant: string): Readonly<Variant> | null;
28
- compileAstNodes(candidate: Candidate): ReturnType<typeof compileAstNodes>;
33
+ compileAstNodes(candidate: Candidate, flags?: CompileAstFlags): ReturnType<typeof compileAstNodes>;
34
+ printCandidate(candidate: Candidate): string;
35
+ printVariant(variant: Variant): string;
29
36
  getVariantOrder(): Map<Variant, number>;
30
37
  resolveThemeValue(path: string, forceInline?: boolean): string | undefined;
31
38
  trackUsedVariables(raw: string): void;
39
+ canonicalizeCandidates(candidates: string[], options?: CanonicalizeOptions): string[];
32
40
  candidatesToCss(classes: string[]): (string | null)[];
33
41
  };
34
42
 
43
+ /**
44
+ * The source code for one or more nodes in the AST
45
+ *
46
+ * This generally corresponds to a stylesheet
47
+ */
48
+ interface Source {
49
+ /**
50
+ * The path to the file that contains the referenced source code
51
+ *
52
+ * If this references the *output* source code, this is `null`.
53
+ */
54
+ file: string | null;
55
+ /**
56
+ * The referenced source code
57
+ */
58
+ code: string;
59
+ }
60
+ /**
61
+ * The file and offsets within it that this node covers
62
+ *
63
+ * This can represent either:
64
+ * - A location in the original CSS which caused this node to be created
65
+ * - A location in the output CSS where this node resides
66
+ */
67
+ type SourceLocation = [source: Source, start: number, end: number];
68
+
69
+ /**
70
+ * Line offset tables are the key to generating our source maps. They allow us
71
+ * to store indexes with our AST nodes and later convert them into positions as
72
+ * when given the source that the indexes refer to.
73
+ */
74
+ /**
75
+ * A position in source code
76
+ *
77
+ * https://tc39.es/ecma426/#sec-position-record-type
78
+ */
79
+ interface Position {
80
+ /** The line number, one-based */
81
+ line: number;
82
+ /** The column/character number, one-based */
83
+ column: number;
84
+ }
85
+
86
+ interface OriginalPosition extends Position {
87
+ source: DecodedSource;
88
+ }
89
+ /**
90
+ * A "decoded" sourcemap
91
+ *
92
+ * @see https://tc39.es/ecma426/#decoded-source-map-record
93
+ */
94
+ interface DecodedSourceMap {
95
+ file: string | null;
96
+ sources: DecodedSource[];
97
+ mappings: DecodedMapping[];
98
+ }
99
+ /**
100
+ * A "decoded" source
101
+ *
102
+ * @see https://tc39.es/ecma426/#decoded-source-record
103
+ */
104
+ interface DecodedSource {
105
+ url: string | null;
106
+ content: string | null;
107
+ ignore: boolean;
108
+ }
109
+ /**
110
+ * A "decoded" mapping
111
+ *
112
+ * @see https://tc39.es/ecma426/#decoded-mapping-record
113
+ */
114
+ interface DecodedMapping {
115
+ originalPosition: OriginalPosition | null;
116
+ generatedPosition: Position;
117
+ name: string | null;
118
+ }
119
+
35
120
  type StyleRule = {
36
121
  kind: 'rule';
37
122
  selector: string;
38
123
  nodes: AstNode[];
124
+ src?: SourceLocation;
125
+ dst?: SourceLocation;
39
126
  };
40
127
  type AtRule = {
41
128
  kind: 'at-rule';
42
129
  name: string;
43
130
  params: string;
44
131
  nodes: AstNode[];
132
+ src?: SourceLocation;
133
+ dst?: SourceLocation;
45
134
  };
46
135
  type Declaration = {
47
136
  kind: 'declaration';
48
137
  property: string;
49
138
  value: string | undefined;
50
139
  important: boolean;
140
+ src?: SourceLocation;
141
+ dst?: SourceLocation;
51
142
  };
52
143
  type Comment = {
53
144
  kind: 'comment';
54
145
  value: string;
146
+ src?: SourceLocation;
147
+ dst?: SourceLocation;
55
148
  };
56
149
  type Context = {
57
150
  kind: 'context';
58
151
  context: Record<string, string | boolean>;
59
152
  nodes: AstNode[];
153
+ src?: undefined;
154
+ dst?: undefined;
60
155
  };
61
156
  type AtRoot = {
62
157
  kind: 'at-root';
63
158
  nodes: AstNode[];
159
+ src?: undefined;
160
+ dst?: undefined;
64
161
  };
65
162
  type AstNode = StyleRule | AtRule | Declaration | Comment | Context | AtRoot;
66
163
 
67
164
  type Resolver = (id: string, base: string) => Promise<string | false | undefined>;
68
165
  interface CompileOptions {
69
166
  base: string;
167
+ from?: string;
70
168
  onDependency: (path: string) => void;
71
169
  shouldRewriteUrls?: boolean;
72
170
  polyfills?: Polyfills;
@@ -98,11 +196,13 @@ declare function compile(css: string, options: CompileOptions): Promise<{
98
196
  } | null;
99
197
  features: Features;
100
198
  build(candidates: string[]): string;
199
+ buildSourceMap(): tailwindcss.DecodedSourceMap;
101
200
  }>;
102
201
  declare function __unstable__loadDesignSystem(css: string, { base }: {
103
202
  base: string;
104
203
  }): Promise<DesignSystem>;
105
204
  declare function loadModule(id: string, base: string, onDependency: (path: string) => void, customJsResolver?: Resolver): Promise<{
205
+ path: string;
106
206
  base: string;
107
207
  module: any;
108
208
  }>;
@@ -121,9 +221,32 @@ declare class Instrumentation implements Disposable {
121
221
 
122
222
  declare function normalizePath(originalPath: string): string;
123
223
 
124
- declare function optimize(input: string, { file, minify }?: {
224
+ interface OptimizeOptions {
225
+ /**
226
+ * The file being transformed
227
+ */
125
228
  file?: string;
229
+ /**
230
+ * Enabled minified output
231
+ */
126
232
  minify?: boolean;
127
- }): string;
233
+ /**
234
+ * The output source map before optimization
235
+ *
236
+ * If omitted a resulting source map will not be available
237
+ */
238
+ map?: string;
239
+ }
240
+ interface TransformResult {
241
+ code: string;
242
+ map: string | undefined;
243
+ }
244
+ declare function optimize(input: string, { file, minify, map }?: OptimizeOptions): TransformResult;
245
+
246
+ interface SourceMap {
247
+ readonly raw: string;
248
+ readonly inline: string;
249
+ }
250
+ declare function toSourceMap(map: DecodedSourceMap | string): SourceMap;
128
251
 
129
- export { type CompileOptions, Instrumentation, type Resolver, __unstable__loadDesignSystem, compile, compileAst, env, loadModule, normalizePath, optimize };
252
+ export { type CompileOptions, type DecodedSource, type DecodedSourceMap, Instrumentation, type OptimizeOptions, type Resolver, type SourceMap, type TransformResult, __unstable__loadDesignSystem, compile, compileAst, env, loadModule, normalizePath, optimize, toSourceMap };