@knighted/css 1.0.0-rc.1 → 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.
- package/bin/generate-types.js +31 -0
- package/dist/cjs/css.cjs +100 -22
- package/dist/cjs/css.d.cts +5 -6
- package/dist/cjs/generateTypes.cjs +636 -0
- package/dist/cjs/generateTypes.d.cts +104 -0
- package/dist/cjs/loader.cjs +65 -55
- package/dist/cjs/loader.d.cts +1 -0
- package/dist/cjs/loaderInternals.cjs +108 -0
- package/dist/cjs/loaderInternals.d.cts +23 -0
- package/dist/cjs/moduleGraph.cjs +431 -0
- package/dist/cjs/moduleGraph.d.cts +15 -0
- package/dist/cjs/moduleInfo.cjs +62 -0
- package/dist/cjs/moduleInfo.d.cts +10 -0
- package/dist/cjs/sassInternals.cjs +135 -0
- package/dist/cjs/sassInternals.d.cts +25 -0
- package/dist/cjs/stableNamespace.cjs +12 -0
- package/dist/cjs/stableNamespace.d.cts +3 -0
- package/dist/cjs/stableSelectors.cjs +44 -0
- package/dist/cjs/stableSelectors.d.cts +13 -0
- package/dist/cjs/stableSelectorsLiteral.cjs +104 -0
- package/dist/cjs/stableSelectorsLiteral.d.cts +19 -0
- package/dist/cjs/types.cjs +2 -0
- package/dist/cjs/types.d.cts +4 -0
- package/dist/css.d.ts +5 -6
- package/dist/css.js +101 -23
- package/dist/generateTypes.d.ts +104 -0
- package/dist/generateTypes.js +628 -0
- package/dist/loader.d.ts +1 -0
- package/dist/loader.js +63 -53
- package/dist/loaderInternals.d.ts +23 -0
- package/dist/loaderInternals.js +96 -0
- package/dist/moduleGraph.d.ts +15 -0
- package/dist/moduleGraph.js +425 -0
- package/dist/moduleInfo.d.ts +10 -0
- package/dist/moduleInfo.js +55 -0
- package/dist/sassInternals.d.ts +25 -0
- package/dist/sassInternals.js +124 -0
- package/dist/stableNamespace.d.ts +3 -0
- package/dist/stableNamespace.js +8 -0
- package/dist/stableSelectors.d.ts +13 -0
- package/dist/stableSelectors.js +36 -0
- package/dist/stableSelectorsLiteral.d.ts +19 -0
- package/dist/stableSelectorsLiteral.js +98 -0
- package/dist/types.d.ts +4 -0
- package/dist/types.js +1 -0
- package/loader-queries.d.ts +61 -0
- package/package.json +58 -8
- package/stable/_index.scss +57 -0
- package/stable/stable.css +15 -0
- package/types-stub/index.d.ts +5 -0
- 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 {};
|
package/dist/cjs/loader.cjs
CHANGED
|
@@ -2,12 +2,27 @@
|
|
|
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, vanillaOptions } = resolveLoaderOptions(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
|
|
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
|
+
});
|
|
11
26
|
const isStyleModule = this.resourcePath.endsWith('.css.ts');
|
|
12
27
|
if (isStyleModule) {
|
|
13
28
|
const { source: compiledSource } = await (0, css_js_1.compileVanillaModule)(this.resourcePath, cssOptions.cwd ?? this.rootContext ?? process.cwd(), cssOptions.peerResolver);
|
|
@@ -42,19 +57,43 @@ function maybeTransformVanillaModule(source, options) {
|
|
|
42
57
|
return transformVanillaModuleToEsm(source);
|
|
43
58
|
}
|
|
44
59
|
const pitch = function pitch() {
|
|
45
|
-
if (!hasCombinedQuery(this.resourceQuery)) {
|
|
60
|
+
if (!(0, loaderInternals_js_1.hasCombinedQuery)(this.resourceQuery)) {
|
|
46
61
|
return;
|
|
47
62
|
}
|
|
48
63
|
const request = buildProxyRequest(this);
|
|
49
|
-
const { cssOptions } = resolveLoaderOptions(this);
|
|
50
|
-
|
|
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
|
+
});
|
|
51
90
|
};
|
|
52
91
|
exports.pitch = pitch;
|
|
53
92
|
loader.pitch = exports.pitch;
|
|
54
93
|
exports.default = loader;
|
|
55
94
|
function resolveLoaderOptions(ctx) {
|
|
56
95
|
const rawOptions = (typeof ctx.getOptions === 'function' ? ctx.getOptions() : {});
|
|
57
|
-
const { vanilla, ...rest } = rawOptions;
|
|
96
|
+
const { vanilla, stableNamespace, ...rest } = rawOptions;
|
|
58
97
|
const cssOptions = {
|
|
59
98
|
...rest,
|
|
60
99
|
cwd: rest.cwd ?? ctx.rootContext ?? process.cwd(),
|
|
@@ -62,6 +101,7 @@ function resolveLoaderOptions(ctx) {
|
|
|
62
101
|
return {
|
|
63
102
|
cssOptions,
|
|
64
103
|
vanillaOptions: vanilla,
|
|
104
|
+
stableNamespace,
|
|
65
105
|
};
|
|
66
106
|
}
|
|
67
107
|
async function extractCss(ctx, options) {
|
|
@@ -75,22 +115,15 @@ async function extractCss(ctx, options) {
|
|
|
75
115
|
function toSourceString(source) {
|
|
76
116
|
return typeof source === 'string' ? source : source.toString('utf8');
|
|
77
117
|
}
|
|
78
|
-
function buildInjection(css) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const trimmed = query.startsWith('?') ? query.slice(1) : query;
|
|
85
|
-
if (!trimmed)
|
|
86
|
-
return false;
|
|
87
|
-
return trimmed
|
|
88
|
-
.split('&')
|
|
89
|
-
.filter(Boolean)
|
|
90
|
-
.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('');
|
|
91
124
|
}
|
|
92
125
|
function buildProxyRequest(ctx) {
|
|
93
|
-
const sanitizedQuery = buildSanitizedQuery(ctx.resourceQuery);
|
|
126
|
+
const sanitizedQuery = (0, loaderInternals_js_1.buildSanitizedQuery)(ctx.resourceQuery);
|
|
94
127
|
const rawRequest = getRawRequest(ctx);
|
|
95
128
|
if (rawRequest) {
|
|
96
129
|
const stripped = stripResourceQuery(rawRequest);
|
|
@@ -115,51 +148,28 @@ function stripResourceQuery(request) {
|
|
|
115
148
|
const idx = request.indexOf('?');
|
|
116
149
|
return idx >= 0 ? request.slice(0, idx) : request;
|
|
117
150
|
}
|
|
118
|
-
function
|
|
119
|
-
|
|
120
|
-
return '';
|
|
121
|
-
const entries = splitQuery(query).filter(part => {
|
|
122
|
-
return !isQueryFlag(part, COMBINED_QUERY_FLAG) && !isQueryFlag(part, 'knighted-css');
|
|
123
|
-
});
|
|
124
|
-
return entries.length > 0 ? `?${entries.join('&')}` : '';
|
|
125
|
-
}
|
|
126
|
-
function splitQuery(query) {
|
|
127
|
-
const trimmed = query.startsWith('?') ? query.slice(1) : query;
|
|
128
|
-
if (!trimmed)
|
|
129
|
-
return [];
|
|
130
|
-
return trimmed.split('&').filter(Boolean);
|
|
131
|
-
}
|
|
132
|
-
function isQueryFlag(entry, flag) {
|
|
133
|
-
const [rawKey] = entry.split('=');
|
|
134
|
-
try {
|
|
135
|
-
return decodeURIComponent(rawKey) === flag;
|
|
136
|
-
}
|
|
137
|
-
catch {
|
|
138
|
-
return rawKey === flag;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
function createCombinedModule(request, css) {
|
|
151
|
+
function createCombinedModule(request, css, options) {
|
|
152
|
+
const shouldEmitDefault = options?.emitDefault ?? (0, loaderInternals_js_1.shouldForwardDefaultExport)(request);
|
|
142
153
|
const requestLiteral = JSON.stringify(request);
|
|
143
154
|
const lines = [
|
|
144
155
|
`import * as __knightedModule from ${requestLiteral};`,
|
|
145
156
|
`export * from ${requestLiteral};`,
|
|
146
157
|
];
|
|
147
|
-
if (
|
|
158
|
+
if (shouldEmitDefault) {
|
|
148
159
|
lines.push(`const __knightedDefault =
|
|
149
160
|
typeof __knightedModule.default !== 'undefined'
|
|
150
161
|
? __knightedModule.default
|
|
151
162
|
: __knightedModule;`, 'export default __knightedDefault;');
|
|
152
163
|
}
|
|
153
|
-
lines.push(buildInjection(css));
|
|
164
|
+
lines.push(buildInjection(css, { stableSelectorsLiteral: options?.stableSelectorsLiteral }));
|
|
154
165
|
return lines.join('\n');
|
|
155
166
|
}
|
|
156
|
-
function
|
|
157
|
-
const
|
|
158
|
-
if (
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (lower.endsWith('.css.ts') || lower.endsWith('.css.js')) {
|
|
162
|
-
return false;
|
|
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;
|
|
163
172
|
}
|
|
164
|
-
|
|
173
|
+
// eslint-disable-next-line no-console
|
|
174
|
+
console.warn(formatted);
|
|
165
175
|
}
|
package/dist/cjs/loader.d.cts
CHANGED
|
@@ -8,6 +8,7 @@ export interface KnightedCssVanillaOptions {
|
|
|
8
8
|
}
|
|
9
9
|
export interface KnightedCssLoaderOptions extends CssOptions {
|
|
10
10
|
vanilla?: KnightedCssVanillaOptions;
|
|
11
|
+
stableNamespace?: string;
|
|
11
12
|
}
|
|
12
13
|
declare const loader: LoaderDefinitionFunction<KnightedCssLoaderOptions>;
|
|
13
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
|
+
};
|