@tailwindcss/node 0.0.0-insiders.25ec6a3 → 0.0.0-insiders.2666194

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