@knighted/css 1.0.0-rc.8 → 1.0.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.
@@ -0,0 +1,426 @@
1
+ import path from 'node:path';
2
+ import { builtinModules } from 'node:module';
3
+ import { existsSync, promises as fs, statSync } from 'node:fs';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { parseSync, Visitor } from 'oxc-parser';
6
+ import { ResolverFactory, } from 'oxc-resolver';
7
+ import { createMatchPath } from 'tsconfig-paths';
8
+ import { getTsconfig } from 'get-tsconfig';
9
+ const SCRIPT_EXTENSIONS = ['.ts', '.tsx', '.mts', '.cts', '.js', '.jsx', '.mjs', '.cjs'];
10
+ const BUILTIN_SPECIFIERS = new Set([
11
+ ...builtinModules,
12
+ ...builtinModules.map(mod => `node:${mod}`),
13
+ ]);
14
+ const tsconfigResultCache = new Map();
15
+ const tsconfigFsCache = new Map();
16
+ export async function collectStyleImports(entryPath, options) {
17
+ const { cwd, styleExtensions, filter, resolver, graphOptions } = options;
18
+ const normalizedStyles = normalizeExtensions(styleExtensions);
19
+ const scriptExtensions = normalizeExtensions([
20
+ ...SCRIPT_EXTENSIONS,
21
+ ...(graphOptions?.extensions ?? []),
22
+ ]);
23
+ const resolutionExtensions = dedupeExtensions([
24
+ ...scriptExtensions,
25
+ ...normalizedStyles,
26
+ ]);
27
+ const tsconfigMatcher = createTsconfigMatcher(graphOptions?.tsConfig, cwd, resolutionExtensions);
28
+ const seenScripts = new Set();
29
+ const seenStyles = new Set();
30
+ const styleOrder = [];
31
+ const resolutionCache = new Map();
32
+ const resolverFactory = createResolverFactory(cwd, resolutionExtensions, scriptExtensions, graphOptions);
33
+ async function walk(filePath) {
34
+ const absolutePath = path.resolve(filePath);
35
+ if (seenScripts.has(absolutePath)) {
36
+ return;
37
+ }
38
+ seenScripts.add(absolutePath);
39
+ const source = await readSourceFile(absolutePath);
40
+ if (!source) {
41
+ return;
42
+ }
43
+ const specifiers = extractModuleSpecifiers(source, absolutePath);
44
+ for (const specifier of specifiers) {
45
+ if (!specifier || isBuiltinSpecifier(specifier)) {
46
+ continue;
47
+ }
48
+ const resolved = await resolveImport(specifier, absolutePath);
49
+ if (!resolved) {
50
+ continue;
51
+ }
52
+ const normalized = path.resolve(resolved);
53
+ if (!filter(normalized)) {
54
+ continue;
55
+ }
56
+ if (isStyleExtension(normalized, normalizedStyles)) {
57
+ if (!seenStyles.has(normalized)) {
58
+ seenStyles.add(normalized);
59
+ styleOrder.push(normalized);
60
+ }
61
+ continue;
62
+ }
63
+ if (isScriptExtension(normalized, scriptExtensions)) {
64
+ await walk(normalized);
65
+ }
66
+ }
67
+ }
68
+ async function resolveImport(specifier, importer) {
69
+ const cacheKey = `${importer}::${specifier}`;
70
+ if (resolutionCache.has(cacheKey)) {
71
+ return resolutionCache.get(cacheKey);
72
+ }
73
+ let resolved;
74
+ if (resolver) {
75
+ resolved = normalizeResolverResult(await resolver(specifier, { cwd, from: importer }), cwd);
76
+ }
77
+ if (!resolved && tsconfigMatcher) {
78
+ resolved = tsconfigMatcher(specifier);
79
+ }
80
+ if (!resolved) {
81
+ resolved = resolveWithFactory(resolverFactory, specifier, importer, resolutionExtensions);
82
+ }
83
+ resolutionCache.set(cacheKey, resolved);
84
+ return resolved;
85
+ }
86
+ await walk(entryPath);
87
+ return styleOrder;
88
+ }
89
+ function normalizeExtensions(extensions) {
90
+ const result = new Set();
91
+ for (const ext of extensions) {
92
+ if (!ext)
93
+ continue;
94
+ const normalized = ext.startsWith('.') ? ext.toLowerCase() : `.${ext.toLowerCase()}`;
95
+ result.add(normalized);
96
+ }
97
+ return Array.from(result);
98
+ }
99
+ function dedupeExtensions(extensions) {
100
+ const result = new Set();
101
+ for (const ext of extensions) {
102
+ result.add(ext);
103
+ }
104
+ return Array.from(result);
105
+ }
106
+ function isBuiltinSpecifier(specifier) {
107
+ if (BUILTIN_SPECIFIERS.has(specifier)) {
108
+ return true;
109
+ }
110
+ if (specifier.startsWith('node:')) {
111
+ return true;
112
+ }
113
+ return false;
114
+ }
115
+ function isStyleExtension(filePath, extensions) {
116
+ const lower = filePath.toLowerCase();
117
+ return extensions.some(ext => lower.endsWith(ext));
118
+ }
119
+ function isScriptExtension(filePath, extensions) {
120
+ const ext = path.extname(filePath).toLowerCase();
121
+ return extensions.includes(ext);
122
+ }
123
+ async function readSourceFile(filePath) {
124
+ try {
125
+ return await fs.readFile(filePath, 'utf8');
126
+ }
127
+ catch {
128
+ return undefined;
129
+ }
130
+ }
131
+ function extractModuleSpecifiers(sourceText, filePath) {
132
+ let program;
133
+ try {
134
+ ;
135
+ ({ program } = parseSync(filePath, sourceText, { sourceType: 'unambiguous' }));
136
+ }
137
+ catch {
138
+ return [];
139
+ }
140
+ const specifiers = [];
141
+ const addSpecifier = (raw) => {
142
+ if (!raw) {
143
+ return;
144
+ }
145
+ const normalized = normalizeSpecifier(raw);
146
+ if (normalized) {
147
+ specifiers.push(normalized);
148
+ }
149
+ };
150
+ const visitor = new Visitor({
151
+ ImportDeclaration(node) {
152
+ addSpecifier(node.source?.value);
153
+ },
154
+ ExportNamedDeclaration(node) {
155
+ if (node.source) {
156
+ addSpecifier(node.source.value);
157
+ }
158
+ },
159
+ ExportAllDeclaration(node) {
160
+ addSpecifier(node.source?.value);
161
+ },
162
+ TSImportEqualsDeclaration(node) {
163
+ const specifier = extractImportEqualsSpecifier(node);
164
+ if (specifier) {
165
+ addSpecifier(specifier);
166
+ }
167
+ },
168
+ ImportExpression(node) {
169
+ const specifier = getStringFromExpression(node.source);
170
+ if (specifier) {
171
+ addSpecifier(specifier);
172
+ }
173
+ },
174
+ CallExpression(node) {
175
+ if (!isRequireLikeCallee(node.callee)) {
176
+ return;
177
+ }
178
+ const specifier = getStringFromArgument(node.arguments[0]);
179
+ if (specifier) {
180
+ addSpecifier(specifier);
181
+ }
182
+ },
183
+ });
184
+ visitor.visit(program);
185
+ return specifiers;
186
+ }
187
+ function normalizeSpecifier(raw) {
188
+ if (!raw)
189
+ return '';
190
+ const trimmed = raw.trim();
191
+ if (!trimmed || trimmed.startsWith('\0')) {
192
+ return '';
193
+ }
194
+ const querySearchOffset = trimmed.startsWith('#') ? 1 : 0;
195
+ const remainder = trimmed.slice(querySearchOffset);
196
+ const queryMatchIndex = remainder.search(/[?#]/);
197
+ const queryIndex = queryMatchIndex === -1 ? -1 : querySearchOffset + queryMatchIndex;
198
+ const withoutQuery = queryIndex === -1 ? trimmed : trimmed.slice(0, queryIndex);
199
+ if (!withoutQuery) {
200
+ return '';
201
+ }
202
+ if (/^[a-z][\w+.-]*:/i.test(withoutQuery) && !withoutQuery.startsWith('file:')) {
203
+ return '';
204
+ }
205
+ return withoutQuery;
206
+ }
207
+ function extractImportEqualsSpecifier(node) {
208
+ if (node.moduleReference.type === 'TSExternalModuleReference') {
209
+ return node.moduleReference.expression.value;
210
+ }
211
+ return undefined;
212
+ }
213
+ function getStringFromArgument(argument) {
214
+ if (!argument || argument.type === 'SpreadElement') {
215
+ return undefined;
216
+ }
217
+ return getStringFromExpression(argument);
218
+ }
219
+ function getStringFromExpression(expression) {
220
+ if (!expression) {
221
+ return undefined;
222
+ }
223
+ if (expression.type === 'Literal') {
224
+ const literalValue = expression.value;
225
+ return typeof literalValue === 'string' ? literalValue : undefined;
226
+ }
227
+ if (expression.type === 'TemplateLiteral' && expression.expressions.length === 0) {
228
+ const [first] = expression.quasis;
229
+ return first?.value.cooked ?? first?.value.raw ?? undefined;
230
+ }
231
+ return undefined;
232
+ }
233
+ function isRequireLikeCallee(expression) {
234
+ const target = unwrapExpression(expression);
235
+ if (target.type === 'Identifier') {
236
+ return target.name === 'require';
237
+ }
238
+ if (target.type === 'MemberExpression') {
239
+ const object = target.object;
240
+ if (object.type === 'Identifier') {
241
+ return object.name === 'require';
242
+ }
243
+ }
244
+ return false;
245
+ }
246
+ function unwrapExpression(expression) {
247
+ if (expression.type === 'ChainExpression') {
248
+ const inner = expression.expression;
249
+ if (inner.type === 'CallExpression') {
250
+ return unwrapExpression(inner.callee);
251
+ }
252
+ return unwrapExpression(inner);
253
+ }
254
+ if (expression.type === 'TSNonNullExpression') {
255
+ return unwrapExpression(expression.expression);
256
+ }
257
+ return expression;
258
+ }
259
+ function normalizeResolverResult(result, cwd) {
260
+ if (!result) {
261
+ return undefined;
262
+ }
263
+ if (result.startsWith('file://')) {
264
+ try {
265
+ return fileURLToPath(new URL(result));
266
+ }
267
+ catch {
268
+ return undefined;
269
+ }
270
+ }
271
+ return path.isAbsolute(result) ? result : path.resolve(cwd, result);
272
+ }
273
+ function resolveWithFactory(factory, specifier, importer, extensions) {
274
+ if (specifier.startsWith('file://')) {
275
+ try {
276
+ return findExistingFile(fileURLToPath(new URL(specifier)), extensions);
277
+ }
278
+ catch {
279
+ return undefined;
280
+ }
281
+ }
282
+ if (/^[a-z][\w+.-]*:/i.test(specifier)) {
283
+ return undefined;
284
+ }
285
+ try {
286
+ const result = factory.resolveFileSync(importer, specifier);
287
+ return result?.path;
288
+ }
289
+ catch {
290
+ return undefined;
291
+ }
292
+ }
293
+ function createResolverFactory(cwd, extensions, scriptExtensions, graphOptions) {
294
+ const options = {
295
+ extensions,
296
+ conditionNames: graphOptions?.conditions,
297
+ };
298
+ const extensionAlias = buildExtensionAlias(scriptExtensions);
299
+ if (extensionAlias) {
300
+ options.extensionAlias = extensionAlias;
301
+ }
302
+ const tsconfigOption = resolveResolverTsconfig(graphOptions?.tsConfig, cwd);
303
+ options.tsconfig = tsconfigOption ?? 'auto';
304
+ return new ResolverFactory(options);
305
+ }
306
+ function buildExtensionAlias(scriptExtensions) {
307
+ const alias = {};
308
+ const jsTargets = dedupeExtensions(scriptExtensions.filter(ext => ['.js', '.ts', '.tsx', '.mjs', '.cjs', '.mts', '.cts'].includes(ext)));
309
+ if (jsTargets.length > 0) {
310
+ for (const key of ['.js', '.mjs', '.cjs']) {
311
+ alias[key] = jsTargets;
312
+ }
313
+ }
314
+ const jsxTargets = dedupeExtensions(scriptExtensions.filter(ext => ext === '.jsx' || ext === '.tsx'));
315
+ if (jsxTargets.length > 0) {
316
+ alias['.jsx'] = jsxTargets;
317
+ }
318
+ return Object.keys(alias).length > 0 ? alias : undefined;
319
+ }
320
+ function resolveResolverTsconfig(input, cwd) {
321
+ if (!input || typeof input !== 'string') {
322
+ return undefined;
323
+ }
324
+ const resolved = resolveTsconfigPath(input, cwd);
325
+ if (!resolved) {
326
+ return undefined;
327
+ }
328
+ return { configFile: resolved };
329
+ }
330
+ function createTsconfigMatcher(input, cwd, extensions) {
331
+ const config = loadTsconfigPaths(input, cwd);
332
+ if (!config) {
333
+ return undefined;
334
+ }
335
+ const matchPath = createMatchPath(config.absoluteBaseUrl, config.paths);
336
+ return (specifier) => {
337
+ const matched = matchPath(specifier, undefined, undefined, extensions);
338
+ if (!matched) {
339
+ return undefined;
340
+ }
341
+ return findExistingFile(matched, extensions) ?? matched;
342
+ };
343
+ }
344
+ function loadTsconfigPaths(input, cwd) {
345
+ if (!input) {
346
+ return undefined;
347
+ }
348
+ if (typeof input === 'string') {
349
+ const target = path.isAbsolute(input) ? input : path.resolve(cwd, input);
350
+ const cached = tsconfigResultCache.get(target);
351
+ if (cached !== undefined) {
352
+ return cached ?? undefined;
353
+ }
354
+ const result = getTsconfig(target, undefined, tsconfigFsCache);
355
+ if (!result) {
356
+ tsconfigResultCache.set(target, null);
357
+ return undefined;
358
+ }
359
+ const normalized = normalizeTsconfigCompilerOptions(result.config.compilerOptions, path.dirname(result.path));
360
+ tsconfigResultCache.set(target, normalized ?? null);
361
+ return normalized;
362
+ }
363
+ const compilerOptions = input.compilerOptions;
364
+ return normalizeTsconfigCompilerOptions(compilerOptions, cwd);
365
+ }
366
+ function normalizeTsconfigCompilerOptions(compilerOptions, configDir) {
367
+ if (!compilerOptions?.baseUrl || !compilerOptions.paths) {
368
+ return undefined;
369
+ }
370
+ const normalizedPaths = {};
371
+ for (const [pattern, replacements] of Object.entries(compilerOptions.paths)) {
372
+ if (!replacements || replacements.length === 0) {
373
+ continue;
374
+ }
375
+ normalizedPaths[pattern] = Array.isArray(replacements)
376
+ ? [...replacements]
377
+ : [replacements];
378
+ }
379
+ if (Object.keys(normalizedPaths).length === 0) {
380
+ return undefined;
381
+ }
382
+ const absoluteBaseUrl = path.isAbsolute(compilerOptions.baseUrl)
383
+ ? compilerOptions.baseUrl
384
+ : path.resolve(configDir, compilerOptions.baseUrl);
385
+ return { absoluteBaseUrl, paths: normalizedPaths };
386
+ }
387
+ function resolveTsconfigPath(tsconfigPath, cwd) {
388
+ const absolute = path.isAbsolute(tsconfigPath)
389
+ ? tsconfigPath
390
+ : path.resolve(cwd, tsconfigPath);
391
+ if (!existsSync(absolute)) {
392
+ return undefined;
393
+ }
394
+ const stats = statSync(absolute);
395
+ if (stats.isDirectory()) {
396
+ const candidate = path.join(absolute, 'tsconfig.json');
397
+ return existsSync(candidate) ? candidate : undefined;
398
+ }
399
+ return absolute;
400
+ }
401
+ function findExistingFile(candidate, extensions) {
402
+ const candidateHasExt = hasExtension(candidate);
403
+ if (candidateHasExt && existsSync(candidate)) {
404
+ return candidate;
405
+ }
406
+ if (!candidateHasExt) {
407
+ for (const ext of extensions) {
408
+ const withExt = `${candidate}${ext}`;
409
+ if (existsSync(withExt)) {
410
+ return withExt;
411
+ }
412
+ }
413
+ }
414
+ if (existsSync(candidate) && statSync(candidate).isDirectory()) {
415
+ for (const ext of extensions) {
416
+ const indexPath = path.join(candidate, `index${ext}`);
417
+ if (existsSync(indexPath)) {
418
+ return indexPath;
419
+ }
420
+ }
421
+ }
422
+ return undefined;
423
+ }
424
+ function hasExtension(filePath) {
425
+ return Boolean(path.extname(filePath));
426
+ }
@@ -1,6 +1,5 @@
1
- export type CssResolver = (specifier: string, ctx: {
2
- cwd: string;
3
- }) => string | Promise<string | undefined>;
1
+ import type { CssResolver } from './types.js';
2
+ export type { CssResolver } from './types.js';
4
3
  export declare function createSassImporter({ cwd, resolver, }: {
5
4
  cwd: string;
6
5
  resolver?: CssResolver;
@@ -13,7 +12,7 @@ export declare function createSassImporter({ cwd, resolver, }: {
13
12
  syntax: "scss" | "indented";
14
13
  }>;
15
14
  } | undefined;
16
- export declare function resolveAliasSpecifier(specifier: string, resolver: CssResolver, cwd: string): Promise<string | undefined>;
15
+ export declare function resolveAliasSpecifier(specifier: string, resolver: CssResolver, cwd: string, from?: string): Promise<string | undefined>;
17
16
  export declare function shouldNormalizeSpecifier(specifier: string): boolean;
18
17
  export declare function ensureSassPath(filePath: string): string | undefined;
19
18
  export declare function resolveRelativeSpecifier(specifier: string, containingUrl?: URL | null): string | undefined;
@@ -13,8 +13,11 @@ export function createSassImporter({ cwd, resolver, }) {
13
13
  console.error('[knighted-css:sass] containing url:', context.containingUrl.href);
14
14
  }
15
15
  }
16
+ const containingPath = context?.containingUrl
17
+ ? fileURLToPath(context.containingUrl)
18
+ : undefined;
16
19
  if (shouldNormalizeSpecifier(url)) {
17
- const resolvedPath = await resolveAliasSpecifier(url, resolver, cwd);
20
+ const resolvedPath = await resolveAliasSpecifier(url, resolver, cwd, containingPath);
18
21
  if (!resolvedPath) {
19
22
  if (debug) {
20
23
  console.error('[knighted-css:sass] resolver returned no result for', url);
@@ -50,8 +53,8 @@ export function createSassImporter({ cwd, resolver, }) {
50
53
  },
51
54
  };
52
55
  }
53
- export async function resolveAliasSpecifier(specifier, resolver, cwd) {
54
- const resolved = await resolver(specifier, { cwd });
56
+ export async function resolveAliasSpecifier(specifier, resolver, cwd, from) {
57
+ const resolved = await resolver(specifier, { cwd, from });
55
58
  if (!resolved) {
56
59
  return undefined;
57
60
  }
@@ -5,9 +5,24 @@ export interface StableClassNameOptions extends StableSelectorOptions {
5
5
  token?: string;
6
6
  join?: (values: string[]) => string;
7
7
  }
8
+ export interface MergeStableClassSingleInput extends StableSelectorOptions {
9
+ hashed: string | string[];
10
+ selector?: string;
11
+ token: string;
12
+ join?: (values: string[]) => string;
13
+ }
14
+ export interface MergeStableClassBatchInput<Hashed extends Record<string, string | string[]>, Selectors extends Record<string, string> | undefined = Record<string, string>> extends StableSelectorOptions {
15
+ hashed: Hashed;
16
+ selectors?: Selectors;
17
+ join?: (values: string[]) => string;
18
+ }
8
19
  export declare function stableToken(token: string, options?: StableSelectorOptions): string;
9
20
  export declare function stableClass(token: string, options?: StableSelectorOptions): string;
10
21
  export declare function stableSelector(token: string, options?: StableSelectorOptions): string;
11
22
  export declare function createStableClassFactory(options?: StableSelectorOptions): (token: string) => string;
12
23
  export declare function stableClassName<T extends Record<string, string>>(styles: T, key: keyof T | string, options?: StableClassNameOptions): string;
13
24
  export declare const stableClassFromModule: typeof stableClassName;
25
+ export declare function mergeStableClass(input: MergeStableClassSingleInput): string;
26
+ export declare function mergeStableClass<Hashed extends Record<string, string | string[]>>(input: MergeStableClassBatchInput<Hashed>): {
27
+ [Key in keyof Hashed]: string;
28
+ };
@@ -1,5 +1,6 @@
1
1
  const DEFAULT_NAMESPACE = 'knighted';
2
2
  const defaultJoin = (values) => values.filter(Boolean).join(' ');
3
+ const toArray = (value) => Array.isArray(value) ? value : [value];
3
4
  const normalizeToken = (token) => {
4
5
  const sanitized = token
5
6
  .trim()
@@ -34,3 +35,30 @@ export function stableClassName(styles, key, options) {
34
35
  return join([hashed, stable]);
35
36
  }
36
37
  export const stableClassFromModule = stableClassName;
38
+ export function mergeStableClass(input) {
39
+ if ('token' in input) {
40
+ return mergeSingle(input);
41
+ }
42
+ return mergeBatch(input);
43
+ }
44
+ function mergeSingle(input) {
45
+ const join = input.join ?? defaultJoin;
46
+ const hashed = toArray(input.hashed);
47
+ const stable = input.selector?.trim().length
48
+ ? input.selector
49
+ : stableClass(input.token, { namespace: input.namespace });
50
+ return join([...hashed, stable]);
51
+ }
52
+ function mergeBatch(input) {
53
+ const join = input.join ?? defaultJoin;
54
+ const output = {};
55
+ for (const key of Object.keys(input.hashed)) {
56
+ const hashedValue = input.hashed[key];
57
+ const selector = input.selectors?.[String(key)];
58
+ const stable = selector?.trim().length
59
+ ? selector
60
+ : stableClass(String(key), { namespace: input.namespace });
61
+ output[key] = join([...toArray(hashedValue), stable]);
62
+ }
63
+ return output;
64
+ }
@@ -2,11 +2,13 @@ export interface StableSelectorsLiteralResult {
2
2
  literal: string;
3
3
  selectorMap: Map<string, string>;
4
4
  }
5
+ type StableSelectorsLiteralTarget = 'ts' | 'js';
5
6
  export declare function buildStableSelectorsLiteral(options: {
6
7
  css: string;
7
8
  namespace: string;
8
9
  resourcePath: string;
9
10
  emitWarning: (message: string) => void;
11
+ target?: StableSelectorsLiteralTarget;
10
12
  }): StableSelectorsLiteralResult;
11
13
  export declare function collectStableSelectors(css: string, namespace: string, filename?: string): Map<string, string>;
12
14
  declare function collectStableSelectorsByRegex(css: string, namespace: string): Map<string, string>;
@@ -1,20 +1,23 @@
1
1
  import { transform as lightningTransform } from 'lightningcss';
2
2
  import { escapeRegex, serializeSelector } from './helpers.js';
3
3
  export function buildStableSelectorsLiteral(options) {
4
+ const target = options.target ?? 'ts';
4
5
  const trimmedNamespace = options.namespace.trim();
5
6
  if (!trimmedNamespace) {
6
7
  options.emitWarning(`stableSelectors requested for ${options.resourcePath} but "stableNamespace" resolved to an empty value.`);
7
- return {
8
- literal: 'export const stableSelectors = {} as const;\n',
9
- selectorMap: new Map(),
10
- };
8
+ return finalizeLiteral(new Map(), target);
11
9
  }
12
10
  const selectorMap = collectStableSelectors(options.css, trimmedNamespace, options.resourcePath);
13
11
  if (selectorMap.size === 0) {
14
12
  options.emitWarning(`stableSelectors requested for ${options.resourcePath} but no selectors matched namespace "${trimmedNamespace}".`);
15
13
  }
14
+ return finalizeLiteral(selectorMap, target);
15
+ }
16
+ function finalizeLiteral(selectorMap, target) {
17
+ const formatted = formatStableSelectorMap(selectorMap);
18
+ const suffix = target === 'ts' ? ' as const' : '';
16
19
  return {
17
- literal: `export const stableSelectors = ${formatStableSelectorMap(selectorMap)} as const;\n`,
20
+ literal: `export const stableSelectors = ${formatted}${suffix};\n`,
18
21
  selectorMap,
19
22
  };
20
23
  }
@@ -0,0 +1,4 @@
1
+ export type CssResolver = (specifier: string, ctx: {
2
+ cwd: string;
3
+ from?: string;
4
+ }) => string | Promise<string | undefined>;
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -19,7 +19,12 @@ declare module '*?knighted-css&types' {
19
19
  * TypeScript cannot infer the underlying module automatically, so consumers can
20
20
  * import the default export and narrow it with `KnightedCssCombinedModule<typeof import('./file')>`.
21
21
  */
22
- type KnightedCssCombinedModule<TModule> = TModule & { knightedCss: string }
22
+ type KnightedCssCombinedExtras = Readonly<Record<string, unknown>>
23
+
24
+ type KnightedCssCombinedModule<
25
+ TModule,
26
+ TExtras extends KnightedCssCombinedExtras = Record<never, never>,
27
+ > = TModule & TExtras & { knightedCss: string }
23
28
 
24
29
  declare module '*?knighted-css&combined' {
25
30
  const combined: KnightedCssCombinedModule<Record<string, unknown>>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knighted/css",
3
- "version": "1.0.0-rc.8",
3
+ "version": "1.0.0",
4
4
  "description": "A build-time utility that traverses JavaScript/TypeScript module dependency graphs to extract, compile, and optimize all imported CSS into a single, in-memory string.",
5
5
  "type": "module",
6
6
  "main": "./dist/css.js",
@@ -10,6 +10,9 @@
10
10
  "loader": [
11
11
  "./dist/loader.d.ts"
12
12
  ],
13
+ "loader-helpers": [
14
+ "./dist/loader-helpers.d.ts"
15
+ ],
13
16
  "loader-queries": [
14
17
  "./loader-queries.d.ts"
15
18
  ],
@@ -32,6 +35,11 @@
32
35
  "import": "./dist/loader.js",
33
36
  "require": "./dist/cjs/loader.cjs"
34
37
  },
38
+ "./loader-helpers": {
39
+ "types": "./dist/loader-helpers.d.ts",
40
+ "import": "./dist/loader-helpers.js",
41
+ "require": "./dist/cjs/loader-helpers.cjs"
42
+ },
35
43
  "./loader-queries": {
36
44
  "types": "./loader-queries.d.ts",
37
45
  "default": "./loader-queries.d.ts"
@@ -76,15 +84,13 @@
76
84
  "prepack": "npm run build"
77
85
  },
78
86
  "dependencies": {
79
- "dependency-tree": "^11.2.0",
80
87
  "es-module-lexer": "^2.0.0",
81
88
  "lightningcss": "^1.30.2",
82
- "node-module-type": "^1.0.1"
83
- },
84
- "overrides": {
85
- "module-lookup-amd": {
86
- "glob": "^9.0.0"
87
- }
89
+ "node-module-type": "^1.0.1",
90
+ "get-tsconfig": "^4.13.0",
91
+ "oxc-parser": "^0.104.0",
92
+ "oxc-resolver": "^11.16.0",
93
+ "tsconfig-paths": "^4.2.0"
88
94
  },
89
95
  "peerDependencies": {
90
96
  "@vanilla-extract/integration": "^8.0.0",