@knighted/css 1.0.0-rc.0 → 1.0.0-rc.10

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 (51) hide show
  1. package/bin/generate-types.js +31 -0
  2. package/dist/cjs/css.cjs +107 -25
  3. package/dist/cjs/css.d.cts +10 -6
  4. package/dist/cjs/generateTypes.cjs +636 -0
  5. package/dist/cjs/generateTypes.d.cts +104 -0
  6. package/dist/cjs/loader.cjs +128 -56
  7. package/dist/cjs/loader.d.cts +5 -0
  8. package/dist/cjs/loaderInternals.cjs +108 -0
  9. package/dist/cjs/loaderInternals.d.cts +23 -0
  10. package/dist/cjs/moduleGraph.cjs +431 -0
  11. package/dist/cjs/moduleGraph.d.cts +15 -0
  12. package/dist/cjs/moduleInfo.cjs +62 -0
  13. package/dist/cjs/moduleInfo.d.cts +10 -0
  14. package/dist/cjs/sassInternals.cjs +135 -0
  15. package/dist/cjs/sassInternals.d.cts +25 -0
  16. package/dist/cjs/stableNamespace.cjs +12 -0
  17. package/dist/cjs/stableNamespace.d.cts +3 -0
  18. package/dist/cjs/stableSelectors.cjs +44 -0
  19. package/dist/cjs/stableSelectors.d.cts +13 -0
  20. package/dist/cjs/stableSelectorsLiteral.cjs +104 -0
  21. package/dist/cjs/stableSelectorsLiteral.d.cts +19 -0
  22. package/dist/cjs/types.cjs +2 -0
  23. package/dist/cjs/types.d.cts +4 -0
  24. package/dist/css.d.ts +10 -6
  25. package/dist/css.js +107 -26
  26. package/dist/generateTypes.d.ts +104 -0
  27. package/dist/generateTypes.js +628 -0
  28. package/dist/loader.d.ts +5 -0
  29. package/dist/loader.js +127 -55
  30. package/dist/loaderInternals.d.ts +23 -0
  31. package/dist/loaderInternals.js +96 -0
  32. package/dist/moduleGraph.d.ts +15 -0
  33. package/dist/moduleGraph.js +425 -0
  34. package/dist/moduleInfo.d.ts +10 -0
  35. package/dist/moduleInfo.js +55 -0
  36. package/dist/sassInternals.d.ts +25 -0
  37. package/dist/sassInternals.js +124 -0
  38. package/dist/stableNamespace.d.ts +3 -0
  39. package/dist/stableNamespace.js +8 -0
  40. package/dist/stableSelectors.d.ts +13 -0
  41. package/dist/stableSelectors.js +36 -0
  42. package/dist/stableSelectorsLiteral.d.ts +19 -0
  43. package/dist/stableSelectorsLiteral.js +98 -0
  44. package/dist/types.d.ts +4 -0
  45. package/dist/types.js +1 -0
  46. package/loader-queries.d.ts +61 -0
  47. package/package.json +58 -8
  48. package/stable/_index.scss +57 -0
  49. package/stable/stable.css +15 -0
  50. package/types-stub/index.d.ts +5 -0
  51. package/types.d.ts +4 -0
@@ -0,0 +1,104 @@
1
+ import { createRequire } from 'node:module';
2
+ import { moduleType } from 'node-module-type';
3
+ import { getTsconfig } from 'get-tsconfig';
4
+ import { type MatchPath } from 'tsconfig-paths';
5
+ import { cssWithMeta } from './css.cjs';
6
+ import { type SelectorTypeVariant } from './loaderInternals.cjs';
7
+ interface ManifestEntry {
8
+ file: string;
9
+ hash: string;
10
+ }
11
+ type Manifest = Record<string, ManifestEntry>;
12
+ interface ImportMatch {
13
+ specifier: string;
14
+ importer: string;
15
+ }
16
+ interface DeclarationRecord {
17
+ specifier: string;
18
+ filePath: string;
19
+ }
20
+ interface TsconfigResolutionContext {
21
+ absoluteBaseUrl?: string;
22
+ matchPath?: MatchPath;
23
+ }
24
+ type CssWithMetaFn = typeof cssWithMeta;
25
+ export interface GenerateTypesResult {
26
+ written: number;
27
+ removed: number;
28
+ declarations: DeclarationRecord[];
29
+ warnings: string[];
30
+ outDir: string;
31
+ typesIndexPath: string;
32
+ }
33
+ export interface GenerateTypesOptions {
34
+ rootDir?: string;
35
+ include?: string[];
36
+ outDir?: string;
37
+ typesRoot?: string;
38
+ stableNamespace?: string;
39
+ }
40
+ type ModuleTypeDetector = () => ReturnType<typeof moduleType>;
41
+ declare function resolvePackageRoot(): string;
42
+ export declare function generateTypes(options?: GenerateTypesOptions): Promise<GenerateTypesResult>;
43
+ declare function normalizeIncludeOptions(include: string[] | undefined, rootDir: string): string[];
44
+ declare function collectCandidateFiles(entries: string[]): Promise<string[]>;
45
+ declare function findSpecifierImports(filePath: string): Promise<ImportMatch[]>;
46
+ declare function stripInlineLoader(specifier: string): string;
47
+ declare function splitResourceAndQuery(specifier: string): {
48
+ resource: string;
49
+ query: string;
50
+ };
51
+ declare function resolveImportPath(resourceSpecifier: string, importerPath: string, rootDir: string, tsconfig?: TsconfigResolutionContext): Promise<string | undefined>;
52
+ declare function buildDeclarationFileName(specifier: string): string;
53
+ declare function formatModuleDeclaration(specifier: string, variant: SelectorTypeVariant, selectors: Map<string, string>): string;
54
+ declare function formatSelectorType(selectors: Map<string, string>): string;
55
+ declare function writeTypesIndex(indexPath: string, manifest: Manifest, outDir: string): Promise<void>;
56
+ declare function relativeToRoot(filePath: string, rootDir: string): string;
57
+ declare function resolveWithTsconfigPaths(specifier: string, tsconfig?: TsconfigResolutionContext): Promise<string | undefined>;
58
+ declare function loadTsconfigResolutionContext(rootDir: string, loader?: typeof getTsconfig): TsconfigResolutionContext | undefined;
59
+ declare function normalizeTsconfigPaths(paths: Record<string, string[] | string> | undefined): Record<string, string[]> | undefined;
60
+ declare function isNonRelativeSpecifier(specifier: string): boolean;
61
+ declare function createProjectPeerResolver(rootDir: string): (name: string) => Promise<any>;
62
+ declare function getProjectRequire(rootDir: string): ReturnType<typeof createRequire>;
63
+ export declare function runGenerateTypesCli(argv?: string[]): Promise<void>;
64
+ export interface ParsedCliArgs {
65
+ rootDir: string;
66
+ include?: string[];
67
+ outDir?: string;
68
+ typesRoot?: string;
69
+ stableNamespace?: string;
70
+ help?: boolean;
71
+ }
72
+ declare function parseCliArgs(argv: string[]): ParsedCliArgs;
73
+ declare function printHelp(): void;
74
+ declare function reportCliResult(result: GenerateTypesResult): void;
75
+ declare function setCssWithMetaImplementation(impl?: CssWithMetaFn): void;
76
+ declare function setModuleTypeDetector(detector?: ModuleTypeDetector): void;
77
+ declare function setImportMetaUrlProvider(provider?: () => string | undefined): void;
78
+ export declare const __generateTypesInternals: {
79
+ writeTypesIndex: typeof writeTypesIndex;
80
+ stripInlineLoader: typeof stripInlineLoader;
81
+ splitResourceAndQuery: typeof splitResourceAndQuery;
82
+ findSpecifierImports: typeof findSpecifierImports;
83
+ resolveImportPath: typeof resolveImportPath;
84
+ resolvePackageRoot: typeof resolvePackageRoot;
85
+ buildDeclarationFileName: typeof buildDeclarationFileName;
86
+ formatModuleDeclaration: typeof formatModuleDeclaration;
87
+ formatSelectorType: typeof formatSelectorType;
88
+ relativeToRoot: typeof relativeToRoot;
89
+ collectCandidateFiles: typeof collectCandidateFiles;
90
+ normalizeIncludeOptions: typeof normalizeIncludeOptions;
91
+ normalizeTsconfigPaths: typeof normalizeTsconfigPaths;
92
+ setCssWithMetaImplementation: typeof setCssWithMetaImplementation;
93
+ setModuleTypeDetector: typeof setModuleTypeDetector;
94
+ setImportMetaUrlProvider: typeof setImportMetaUrlProvider;
95
+ isNonRelativeSpecifier: typeof isNonRelativeSpecifier;
96
+ createProjectPeerResolver: typeof createProjectPeerResolver;
97
+ getProjectRequire: typeof getProjectRequire;
98
+ loadTsconfigResolutionContext: typeof loadTsconfigResolutionContext;
99
+ resolveWithTsconfigPaths: typeof resolveWithTsconfigPaths;
100
+ parseCliArgs: typeof parseCliArgs;
101
+ printHelp: typeof printHelp;
102
+ reportCliResult: typeof reportCliResult;
103
+ };
104
+ export {};
@@ -2,32 +2,106 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.pitch = void 0;
4
4
  const css_js_1 = require("./css.cjs");
5
+ const moduleInfo_js_1 = require("./moduleInfo.cjs");
6
+ const loaderInternals_js_1 = require("./loaderInternals.cjs");
7
+ const stableSelectorsLiteral_js_1 = require("./stableSelectorsLiteral.cjs");
8
+ const stableNamespace_js_1 = require("./stableNamespace.cjs");
5
9
  const DEFAULT_EXPORT_NAME = 'knightedCss';
6
- const COMBINED_QUERY_FLAG = 'combined';
7
10
  const loader = async function loader(source) {
8
- const cssOptions = resolveCssOptions(this);
11
+ const { cssOptions, vanillaOptions, stableNamespace: optionNamespace, } = resolveLoaderOptions(this);
12
+ const resolvedNamespace = (0, stableNamespace_js_1.resolveStableNamespace)(optionNamespace);
13
+ const typesRequested = (0, loaderInternals_js_1.hasQueryFlag)(this.resourceQuery, loaderInternals_js_1.TYPES_QUERY_FLAG);
9
14
  const css = await extractCss(this, cssOptions);
10
- const injection = buildInjection(css);
11
- const input = toSourceString(source);
15
+ const stableSelectorsLiteral = typesRequested
16
+ ? (0, stableSelectorsLiteral_js_1.buildStableSelectorsLiteral)({
17
+ css,
18
+ namespace: resolvedNamespace,
19
+ resourcePath: this.resourcePath,
20
+ emitWarning: message => emitKnightedWarning(this, message),
21
+ })
22
+ : undefined;
23
+ const injection = buildInjection(css, {
24
+ stableSelectorsLiteral: stableSelectorsLiteral?.literal,
25
+ });
12
26
  const isStyleModule = this.resourcePath.endsWith('.css.ts');
13
- return isStyleModule ? `${injection}export default {};\n` : `${input}${injection}`;
27
+ if (isStyleModule) {
28
+ const { source: compiledSource } = await (0, css_js_1.compileVanillaModule)(this.resourcePath, cssOptions.cwd ?? this.rootContext ?? process.cwd(), cssOptions.peerResolver);
29
+ const vanillaSource = maybeTransformVanillaModule(compiledSource, vanillaOptions);
30
+ return `${vanillaSource}${injection}`;
31
+ }
32
+ const input = toSourceString(source);
33
+ return `${input}${injection}`;
14
34
  };
35
+ function transformVanillaModuleToEsm(source) {
36
+ const exportBlock = /__export\([^,]+,\s*{([\s\S]*?)}\);/m.exec(source);
37
+ if (!exportBlock) {
38
+ return source;
39
+ }
40
+ const names = exportBlock[1]
41
+ .split(',')
42
+ .map(part => part.trim())
43
+ .filter(Boolean)
44
+ .map(entry => entry.split(':')[0]?.trim())
45
+ .filter(Boolean);
46
+ let transformed = source.replace(/module\.exports\s*=\s*__toCommonJS\([^;]+;\n?/m, '');
47
+ transformed = transformed.replace(/0 && \(module\.exports = {[^}]+}\);?\n?/m, '');
48
+ if (names.length > 0) {
49
+ transformed = `${transformed}\nexport { ${names.join(', ')} };\n`;
50
+ }
51
+ return transformed;
52
+ }
53
+ function maybeTransformVanillaModule(source, options) {
54
+ if (!options?.transformToEsm) {
55
+ return source;
56
+ }
57
+ return transformVanillaModuleToEsm(source);
58
+ }
15
59
  const pitch = function pitch() {
16
- if (!hasCombinedQuery(this.resourceQuery)) {
60
+ if (!(0, loaderInternals_js_1.hasCombinedQuery)(this.resourceQuery)) {
17
61
  return;
18
62
  }
19
63
  const request = buildProxyRequest(this);
20
- const cssOptions = resolveCssOptions(this);
21
- return extractCss(this, cssOptions).then(css => createCombinedModule(request, css));
64
+ const { cssOptions, stableNamespace: optionNamespace } = resolveLoaderOptions(this);
65
+ const typesRequested = (0, loaderInternals_js_1.hasQueryFlag)(this.resourceQuery, loaderInternals_js_1.TYPES_QUERY_FLAG);
66
+ const resolvedNamespace = (0, stableNamespace_js_1.resolveStableNamespace)(optionNamespace);
67
+ const skipSyntheticDefault = (0, loaderInternals_js_1.hasNamedOnlyQueryFlag)(this.resourceQuery);
68
+ const defaultSignalPromise = skipSyntheticDefault
69
+ ? Promise.resolve('unknown')
70
+ : (0, moduleInfo_js_1.detectModuleDefaultExport)(this.resourcePath);
71
+ return Promise.all([extractCss(this, cssOptions), defaultSignalPromise]).then(([css, defaultSignal]) => {
72
+ const emitDefault = (0, loaderInternals_js_1.shouldEmitCombinedDefault)({
73
+ request,
74
+ skipSyntheticDefault,
75
+ detection: defaultSignal,
76
+ });
77
+ const stableSelectorsLiteral = typesRequested
78
+ ? (0, stableSelectorsLiteral_js_1.buildStableSelectorsLiteral)({
79
+ css,
80
+ namespace: resolvedNamespace,
81
+ resourcePath: this.resourcePath,
82
+ emitWarning: message => emitKnightedWarning(this, message),
83
+ })
84
+ : undefined;
85
+ return createCombinedModule(request, css, {
86
+ emitDefault,
87
+ stableSelectorsLiteral: stableSelectorsLiteral?.literal,
88
+ });
89
+ });
22
90
  };
23
91
  exports.pitch = pitch;
24
92
  loader.pitch = exports.pitch;
25
93
  exports.default = loader;
26
- function resolveCssOptions(ctx) {
94
+ function resolveLoaderOptions(ctx) {
27
95
  const rawOptions = (typeof ctx.getOptions === 'function' ? ctx.getOptions() : {});
96
+ const { vanilla, stableNamespace, ...rest } = rawOptions;
97
+ const cssOptions = {
98
+ ...rest,
99
+ cwd: rest.cwd ?? ctx.rootContext ?? process.cwd(),
100
+ };
28
101
  return {
29
- ...rawOptions,
30
- cwd: rawOptions.cwd ?? ctx.rootContext ?? process.cwd(),
102
+ cssOptions,
103
+ vanillaOptions: vanilla,
104
+ stableNamespace,
31
105
  };
32
106
  }
33
107
  async function extractCss(ctx, options) {
@@ -41,22 +115,20 @@ async function extractCss(ctx, options) {
41
115
  function toSourceString(source) {
42
116
  return typeof source === 'string' ? source : source.toString('utf8');
43
117
  }
44
- function buildInjection(css) {
45
- return `\n\nexport const ${DEFAULT_EXPORT_NAME} = ${JSON.stringify(css)};\n`;
46
- }
47
- function hasCombinedQuery(query) {
48
- if (!query)
49
- return false;
50
- const trimmed = query.startsWith('?') ? query.slice(1) : query;
51
- if (!trimmed)
52
- return false;
53
- return trimmed
54
- .split('&')
55
- .filter(Boolean)
56
- .some(part => isQueryFlag(part, COMBINED_QUERY_FLAG));
118
+ function buildInjection(css, extras) {
119
+ const lines = [`\n\nexport const ${DEFAULT_EXPORT_NAME} = ${JSON.stringify(css)};\n`];
120
+ if (extras?.stableSelectorsLiteral) {
121
+ lines.push(extras.stableSelectorsLiteral);
122
+ }
123
+ return lines.join('');
57
124
  }
58
125
  function buildProxyRequest(ctx) {
59
- const sanitizedQuery = buildSanitizedQuery(ctx.resourceQuery);
126
+ const sanitizedQuery = (0, loaderInternals_js_1.buildSanitizedQuery)(ctx.resourceQuery);
127
+ const rawRequest = getRawRequest(ctx);
128
+ if (rawRequest) {
129
+ const stripped = stripResourceQuery(rawRequest);
130
+ return `${stripped}${sanitizedQuery}`;
131
+ }
60
132
  const request = `${ctx.resourcePath}${sanitizedQuery}`;
61
133
  const context = ctx.context ?? ctx.rootContext ?? process.cwd();
62
134
  if (ctx.utils && typeof ctx.utils.contextify === 'function') {
@@ -64,40 +136,40 @@ function buildProxyRequest(ctx) {
64
136
  }
65
137
  return request;
66
138
  }
67
- function buildSanitizedQuery(query) {
68
- if (!query)
69
- return '';
70
- const entries = splitQuery(query).filter(part => {
71
- return !isQueryFlag(part, COMBINED_QUERY_FLAG) && !isQueryFlag(part, 'knighted-css');
72
- });
73
- return entries.length > 0 ? `?${entries.join('&')}` : '';
74
- }
75
- function splitQuery(query) {
76
- const trimmed = query.startsWith('?') ? query.slice(1) : query;
77
- if (!trimmed)
78
- return [];
79
- return trimmed.split('&').filter(Boolean);
80
- }
81
- function isQueryFlag(entry, flag) {
82
- const [rawKey] = entry.split('=');
83
- try {
84
- return decodeURIComponent(rawKey) === flag;
85
- }
86
- catch {
87
- return rawKey === flag;
139
+ function getRawRequest(ctx) {
140
+ const mod = ctx._module;
141
+ const request = mod?.rawRequest;
142
+ if (typeof request === 'string' && request.length > 0) {
143
+ return request;
88
144
  }
145
+ return undefined;
146
+ }
147
+ function stripResourceQuery(request) {
148
+ const idx = request.indexOf('?');
149
+ return idx >= 0 ? request.slice(0, idx) : request;
89
150
  }
90
- function createCombinedModule(request, css) {
151
+ function createCombinedModule(request, css, options) {
152
+ const shouldEmitDefault = options?.emitDefault ?? (0, loaderInternals_js_1.shouldForwardDefaultExport)(request);
91
153
  const requestLiteral = JSON.stringify(request);
92
- const defaultExport = `const __knightedDefault =
93
- typeof __knightedModule.default !== 'undefined'
94
- ? __knightedModule.default
95
- : __knightedModule;`;
96
- return [
154
+ const lines = [
97
155
  `import * as __knightedModule from ${requestLiteral};`,
98
156
  `export * from ${requestLiteral};`,
99
- defaultExport,
100
- 'export default __knightedDefault;',
101
- buildInjection(css),
102
- ].join('\n');
157
+ ];
158
+ if (shouldEmitDefault) {
159
+ lines.push(`const __knightedDefault =
160
+ typeof __knightedModule.default !== 'undefined'
161
+ ? __knightedModule.default
162
+ : __knightedModule;`, 'export default __knightedDefault;');
163
+ }
164
+ lines.push(buildInjection(css, { stableSelectorsLiteral: options?.stableSelectorsLiteral }));
165
+ return lines.join('\n');
166
+ }
167
+ function emitKnightedWarning(ctx, message) {
168
+ const formatted = `\x1b[33m@knighted/css warning\x1b[0m ${message}`;
169
+ if (typeof ctx.emitWarning === 'function') {
170
+ ctx.emitWarning(new Error(formatted));
171
+ return;
172
+ }
173
+ // eslint-disable-next-line no-console
174
+ console.warn(formatted);
103
175
  }
@@ -3,7 +3,12 @@ import { type CssOptions } from './css.cjs';
3
3
  export type KnightedCssCombinedModule<TModule> = TModule & {
4
4
  knightedCss: string;
5
5
  };
6
+ export interface KnightedCssVanillaOptions {
7
+ transformToEsm?: boolean;
8
+ }
6
9
  export interface KnightedCssLoaderOptions extends CssOptions {
10
+ vanilla?: KnightedCssVanillaOptions;
11
+ stableNamespace?: string;
7
12
  }
8
13
  declare const loader: LoaderDefinitionFunction<KnightedCssLoaderOptions>;
9
14
  export declare const pitch: PitchLoaderDefinitionFunction<KnightedCssLoaderOptions>;
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.__loaderInternals = exports.NAMED_ONLY_QUERY_FLAGS = exports.TYPES_QUERY_FLAG = exports.COMBINED_QUERY_FLAG = void 0;
4
+ exports.splitQuery = splitQuery;
5
+ exports.isQueryFlag = isQueryFlag;
6
+ exports.buildSanitizedQuery = buildSanitizedQuery;
7
+ exports.hasQueryFlag = hasQueryFlag;
8
+ exports.shouldForwardDefaultExport = shouldForwardDefaultExport;
9
+ exports.hasCombinedQuery = hasCombinedQuery;
10
+ exports.hasNamedOnlyQueryFlag = hasNamedOnlyQueryFlag;
11
+ exports.determineSelectorVariant = determineSelectorVariant;
12
+ exports.shouldEmitCombinedDefault = shouldEmitCombinedDefault;
13
+ exports.COMBINED_QUERY_FLAG = 'combined';
14
+ exports.TYPES_QUERY_FLAG = 'types';
15
+ exports.NAMED_ONLY_QUERY_FLAGS = ['named-only', 'no-default'];
16
+ function splitQuery(query) {
17
+ const trimmed = query.startsWith('?') ? query.slice(1) : query;
18
+ if (!trimmed)
19
+ return [];
20
+ return trimmed.split('&').filter(Boolean);
21
+ }
22
+ function isQueryFlag(entry, flag) {
23
+ const [rawKey] = entry.split('=');
24
+ try {
25
+ return decodeURIComponent(rawKey) === flag;
26
+ }
27
+ catch {
28
+ return rawKey === flag;
29
+ }
30
+ }
31
+ function buildSanitizedQuery(query) {
32
+ if (!query)
33
+ return '';
34
+ const entries = splitQuery(query).filter(part => {
35
+ if (isQueryFlag(part, exports.COMBINED_QUERY_FLAG)) {
36
+ return false;
37
+ }
38
+ if (isQueryFlag(part, 'knighted-css')) {
39
+ return false;
40
+ }
41
+ if (isQueryFlag(part, exports.TYPES_QUERY_FLAG)) {
42
+ return false;
43
+ }
44
+ if (exports.NAMED_ONLY_QUERY_FLAGS.some(flag => isQueryFlag(part, flag))) {
45
+ return false;
46
+ }
47
+ return true;
48
+ });
49
+ return entries.length > 0 ? `?${entries.join('&')}` : '';
50
+ }
51
+ function hasQueryFlag(query, flag) {
52
+ if (!query)
53
+ return false;
54
+ const entries = splitQuery(query);
55
+ if (entries.length === 0)
56
+ return false;
57
+ return entries.some(part => isQueryFlag(part, flag));
58
+ }
59
+ function safeDecode(value) {
60
+ try {
61
+ return decodeURIComponent(value);
62
+ }
63
+ catch {
64
+ return value;
65
+ }
66
+ }
67
+ function shouldForwardDefaultExport(request) {
68
+ const [pathPart] = request.split('?');
69
+ if (!pathPart)
70
+ return true;
71
+ const lower = pathPart.toLowerCase();
72
+ if (lower.endsWith('.css.ts') || lower.endsWith('.css.js')) {
73
+ return false;
74
+ }
75
+ return true;
76
+ }
77
+ function hasCombinedQuery(query) {
78
+ return hasQueryFlag(query, exports.COMBINED_QUERY_FLAG);
79
+ }
80
+ function hasNamedOnlyQueryFlag(query) {
81
+ return exports.NAMED_ONLY_QUERY_FLAGS.some(flag => hasQueryFlag(query, flag));
82
+ }
83
+ function determineSelectorVariant(query) {
84
+ if (hasCombinedQuery(query)) {
85
+ return hasNamedOnlyQueryFlag(query) ? 'combinedWithoutDefault' : 'combined';
86
+ }
87
+ return 'types';
88
+ }
89
+ function shouldEmitCombinedDefault(options) {
90
+ if (options.skipSyntheticDefault) {
91
+ return false;
92
+ }
93
+ if (!shouldForwardDefaultExport(options.request)) {
94
+ return false;
95
+ }
96
+ if (options.detection === 'has-default') {
97
+ return true;
98
+ }
99
+ if (options.detection === 'no-default') {
100
+ return false;
101
+ }
102
+ return true;
103
+ }
104
+ exports.__loaderInternals = {
105
+ buildSanitizedQuery,
106
+ shouldEmitCombinedDefault,
107
+ determineSelectorVariant,
108
+ };
@@ -0,0 +1,23 @@
1
+ import type { ModuleDefaultSignal } from './moduleInfo.cjs';
2
+ export declare const COMBINED_QUERY_FLAG = "combined";
3
+ export declare const TYPES_QUERY_FLAG = "types";
4
+ export declare const NAMED_ONLY_QUERY_FLAGS: readonly ["named-only", "no-default"];
5
+ export type SelectorTypeVariant = 'types' | 'combined' | 'combinedWithoutDefault';
6
+ export declare function splitQuery(query: string): string[];
7
+ export declare function isQueryFlag(entry: string, flag: string): boolean;
8
+ export declare function buildSanitizedQuery(query?: string | null): string;
9
+ export declare function hasQueryFlag(query: string | null | undefined, flag: string): boolean;
10
+ export declare function shouldForwardDefaultExport(request: string): boolean;
11
+ export declare function hasCombinedQuery(query?: string | null): boolean;
12
+ export declare function hasNamedOnlyQueryFlag(query?: string | null): boolean;
13
+ export declare function determineSelectorVariant(query?: string | null): SelectorTypeVariant;
14
+ export declare function shouldEmitCombinedDefault(options: {
15
+ detection: ModuleDefaultSignal;
16
+ request: string;
17
+ skipSyntheticDefault: boolean;
18
+ }): boolean;
19
+ export declare const __loaderInternals: {
20
+ buildSanitizedQuery: typeof buildSanitizedQuery;
21
+ shouldEmitCombinedDefault: typeof shouldEmitCombinedDefault;
22
+ determineSelectorVariant: typeof determineSelectorVariant;
23
+ };