@visulima/rollup-plugin-css 1.0.0-alpha.45 → 1.0.0-alpha.46
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/CHANGELOG.md +16 -0
- package/dist/index.d.ts +16 -40
- package/dist/index.js +1 -1
- package/dist/loaders/less/index.d.ts +13 -36
- package/dist/loaders/less/index.js +1 -1
- package/dist/loaders/lightningcss.d.ts +13 -13
- package/dist/loaders/lightningcss.js +3 -3
- package/dist/loaders/postcss/index.d.ts +13 -27
- package/dist/loaders/postcss/index.js +6 -6
- package/dist/loaders/sass/index.d.ts +14 -4
- package/dist/loaders/sass/index.js +6 -6
- package/dist/loaders/sourcemap.d.ts +13 -24
- package/dist/loaders/sourcemap.js +1 -1
- package/dist/loaders/stylus/index.d.ts +14 -7
- package/dist/loaders/stylus/index.js +2 -2
- package/dist/loaders/tailwindcss-oxide.d.ts +13 -5
- package/dist/loaders/tailwindcss-oxide.js +1 -1
- package/dist/minifiers/cssnano.d.ts +13 -30
- package/dist/minifiers/cssnano.js +1 -1
- package/dist/minifiers/lightningcss.d.ts +13 -29
- package/dist/minifiers/lightningcss.js +2 -2
- package/dist/packem_shared/concat-CWFnPzjp.js +3 -0
- package/dist/packem_shared/{cssModulesTypesPlugin-CjGroK2y.js → cssModulesTypesPlugin-Bf3f6dn3.js} +2 -2
- package/dist/packem_shared/generate-js-exports-DKOz4w8t.js +23 -0
- package/dist/packem_shared/{getMap-TR-0DXUr.js → getMap-Dlan_u0E.js} +1 -1
- package/dist/packem_shared/hasModuleSpecifier-DKQ_-lwa.js +1 -0
- package/dist/packem_shared/inferModeOption-CJYqAvV-.js +1 -0
- package/dist/packem_shared/loadModule-B0QEI5Uu.js +1 -0
- package/dist/packem_shared/resolve-CEc8oUE8.js +1 -0
- package/dist/packem_shared/rollupCssPlugin-DFW2gy2m.js +3 -0
- package/dist/packem_shared/sourcemap-LKvHG-1m.js +3 -0
- package/dist/packem_shared/types.d-C-ij3n7X.d.ts +194 -0
- package/dist/utils/index.d.ts +63 -9
- package/dist/utils/index.js +1 -1
- package/package.json +21 -21
- package/dist/css-modules-types.d.ts +0 -38
- package/dist/css-plugin.d.ts +0 -44
- package/dist/loaders/less/importer.d.ts +0 -2
- package/dist/loaders/less/types.d.ts +0 -24
- package/dist/loaders/loader-manager.d.ts +0 -78
- package/dist/loaders/postcss/constants.d.ts +0 -20
- package/dist/loaders/postcss/icss/index.d.ts +0 -8
- package/dist/loaders/postcss/icss/load.d.ts +0 -5
- package/dist/loaders/postcss/icss/resolve.d.ts +0 -6
- package/dist/loaders/postcss/import/apply-conditions.d.ts +0 -10
- package/dist/loaders/postcss/import/apply-raws.d.ts +0 -3
- package/dist/loaders/postcss/import/apply-styles.d.ts +0 -10
- package/dist/loaders/postcss/import/constants.d.ts +0 -12
- package/dist/loaders/postcss/import/import-resolve.d.ts +0 -3
- package/dist/loaders/postcss/import/index.d.ts +0 -12
- package/dist/loaders/postcss/import/parser/parse-at-import.d.ts +0 -9
- package/dist/loaders/postcss/import/parser/parse-styles.d.ts +0 -6
- package/dist/loaders/postcss/import/parser/parse-stylesheet.d.ts +0 -10
- package/dist/loaders/postcss/import/types.d.ts +0 -95
- package/dist/loaders/postcss/import/utils/base64-encoded-import.d.ts +0 -3
- package/dist/loaders/postcss/import/utils/data-url.d.ts +0 -2
- package/dist/loaders/postcss/import/utils/format-import-prelude.d.ts +0 -2
- package/dist/loaders/postcss/import/utils/load-content.d.ts +0 -2
- package/dist/loaders/postcss/import/utils/process-content.d.ts +0 -4
- package/dist/loaders/postcss/import/utils/statement.d.ts +0 -6
- package/dist/loaders/postcss/load-config.d.ts +0 -6
- package/dist/loaders/postcss/modules/generate.d.ts +0 -11
- package/dist/loaders/postcss/modules/index.d.ts +0 -35
- package/dist/loaders/postcss/noop.d.ts +0 -22
- package/dist/loaders/postcss/url/generate.d.ts +0 -2
- package/dist/loaders/postcss/url/index.d.ts +0 -46
- package/dist/loaders/postcss/url/inline.d.ts +0 -20
- package/dist/loaders/postcss/url/url-resolve.d.ts +0 -12
- package/dist/loaders/postcss/url/utils.d.ts +0 -4
- package/dist/loaders/sass/modern/importer.d.ts +0 -3
- package/dist/loaders/sass/types.d.ts +0 -20
- package/dist/loaders/sass/utils/get-sass-compiler.d.ts +0 -8
- package/dist/loaders/sass/utils/get-sass-options.d.ts +0 -7
- package/dist/loaders/sass/utils/normalize-source-map.d.ts +0 -3
- package/dist/loaders/sass/utils/resolve-syntax.d.ts +0 -2
- package/dist/loaders/sass/utils/sass-error-factory.d.ts +0 -15
- package/dist/loaders/stylus/types.d.ts +0 -87
- package/dist/loaders/types.d.ts +0 -102
- package/dist/loaders/utils/ensure-auto-modules.d.ts +0 -39
- package/dist/loaders/utils/match-file.d.ts +0 -32
- package/dist/minifiers/types.d.ts +0 -64
- package/dist/packem_shared/concat-WcWAYbOc.js +0 -3
- package/dist/packem_shared/generate-js-exports-BhS4eLrN.js +0 -23
- package/dist/packem_shared/hasModuleSpecifier-DIZeev_W.js +0 -1
- package/dist/packem_shared/inferModeOption-9h3Eq6JH.js +0 -1
- package/dist/packem_shared/loadModule-D20jQQNu.js +0 -1
- package/dist/packem_shared/resolve-anj9ucIq.js +0 -1
- package/dist/packem_shared/rollupCssPlugin-BxRedPmA.js +0 -3
- package/dist/packem_shared/sourcemap-CB6ochh0.js +0 -3
- package/dist/types.d.ts +0 -224
- package/dist/utils/array-fmt.d.ts +0 -18
- package/dist/utils/concat.d.ts +0 -34
- package/dist/utils/generate-js-exports.d.ts +0 -78
- package/dist/utils/load-module.d.ts +0 -3
- package/dist/utils/options.d.ts +0 -155
- package/dist/utils/resolve.d.ts +0 -35
- package/dist/utils/safe-id.d.ts +0 -23
- package/dist/utils/sourcemap.d.ts +0 -42
- package/dist/utils/url.d.ts +0 -8
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { PluginCreator } from "postcss";
|
|
2
|
-
import type { UrlResolve } from "./url-resolve.d.ts";
|
|
3
|
-
declare const plugin: PluginCreator<UrlOptions>;
|
|
4
|
-
/** URL handler options */
|
|
5
|
-
export interface UrlOptions {
|
|
6
|
-
/**
|
|
7
|
-
* Aliases for URL paths.
|
|
8
|
-
* Overrides the global `alias` option.
|
|
9
|
-
* - ex.: `{"foo":"bar"}`
|
|
10
|
-
*/
|
|
11
|
-
alias?: Record<string, string>;
|
|
12
|
-
/**
|
|
13
|
-
* Directory path for outputted CSS assets,
|
|
14
|
-
* which is not included into resulting URL
|
|
15
|
-
* @default "."
|
|
16
|
-
*/
|
|
17
|
-
assetDir?: string | ((original: string, resolved: string, file: string) => string);
|
|
18
|
-
/**
|
|
19
|
-
* Enable/disable name generation with hash for outputted CSS assets
|
|
20
|
-
* or provide your own placeholder with the following blocks:
|
|
21
|
-
* - `[extname]`: The file extension of the asset including a leading dot, e.g. `.png`.
|
|
22
|
-
* - `[ext]`: The file extension without a leading dot, e.g. `png`.
|
|
23
|
-
* - `[hash(:<num>)]`: A hash based on the name and content of the asset (with optional length).
|
|
24
|
-
* - `[name]`: The file name of the asset excluding any extension.
|
|
25
|
-
*
|
|
26
|
-
* Forward slashes / can be used to place files in sub-directories.
|
|
27
|
-
* @default "assets/[name]-[hash][extname]" ("assets/[name][extname]" if false)
|
|
28
|
-
*/
|
|
29
|
-
hash?: boolean | string;
|
|
30
|
-
/**
|
|
31
|
-
* Inline files instead of copying
|
|
32
|
-
* @default true for `inject` mode, otherwise false
|
|
33
|
-
*/
|
|
34
|
-
inline?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Public Path for URLs in CSS files
|
|
37
|
-
* @default "./"
|
|
38
|
-
*/
|
|
39
|
-
publicPath?: string | ((original: string, resolved: string, file: string) => string);
|
|
40
|
-
/**
|
|
41
|
-
* Provide custom resolver for URLs
|
|
42
|
-
* in place of the default one
|
|
43
|
-
*/
|
|
44
|
-
resolve?: UrlResolve;
|
|
45
|
-
}
|
|
46
|
-
export default plugin;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts a file to a data URI for inline embedding in CSS.
|
|
3
|
-
*
|
|
4
|
-
* Creates a data URI that can be used directly in CSS
|
|
5
|
-
* without requiring a separate file request. All files are encoded
|
|
6
|
-
* using base64 for consistent behavior.
|
|
7
|
-
* @param file File path used to determine MIME type
|
|
8
|
-
* @param source File content as Uint8Array to be encoded
|
|
9
|
-
* @returns Data URI string optimized for CSS usage
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* inlineFile("image.png", pngBuffer)
|
|
13
|
-
* // Returns: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
|
|
14
|
-
*
|
|
15
|
-
* inlineFile("icon.svg", svgBuffer)
|
|
16
|
-
* // Returns: "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDov..."
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
declare const inline: (file: string, source: Uint8Array) => string;
|
|
20
|
-
export default inline;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/** File resolved by URL resolver */
|
|
2
|
-
export interface UrlFile {
|
|
3
|
-
/** Absolute path to file */
|
|
4
|
-
from: string;
|
|
5
|
-
/** File source */
|
|
6
|
-
source: Uint8Array;
|
|
7
|
-
/** Original query extracted from the input path */
|
|
8
|
-
urlQuery?: string;
|
|
9
|
-
}
|
|
10
|
-
/** URL resolver */
|
|
11
|
-
export type UrlResolve = (inputUrl: string, baseDirectories: string[]) => Promise<UrlFile>;
|
|
12
|
-
export declare const urlResolve: UrlResolve;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Declaration } from "postcss";
|
|
2
|
-
import type { Node, ParsedValue } from "postcss-value-parser";
|
|
3
|
-
export declare const isDeclWithUrl: (decl: Declaration) => boolean;
|
|
4
|
-
export declare const walkUrls: (parsed: ParsedValue, callback: (url: string, node?: Node) => void) => void;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Modified copy of https://github.com/webpack-contrib/sass-loader
|
|
3
|
-
*
|
|
4
|
-
* MIT License
|
|
5
|
-
*
|
|
6
|
-
* Copyright JS Foundation and other contributors
|
|
7
|
-
*/
|
|
8
|
-
import type { Environment } from "@visulima/packem-share/types";
|
|
9
|
-
import type { StringOptions as SassStringOptions } from "sass";
|
|
10
|
-
import type { StringOptions as SassEmbeddedStringOptions } from "sass-embedded";
|
|
11
|
-
export type SassLoaderContext = {
|
|
12
|
-
environment: Environment;
|
|
13
|
-
resourcePath: string;
|
|
14
|
-
rootContext: string;
|
|
15
|
-
};
|
|
16
|
-
export type SassLoaderOptions = {
|
|
17
|
-
additionalData: string | ((content: string | Buffer, loaderContext: SassLoaderContext) => Promise<string>) | ((content: string | Buffer, loaderContext: SassLoaderContext) => string);
|
|
18
|
-
implementation?: "sass-embedded" | "sass";
|
|
19
|
-
warnRuleAsWarning?: boolean;
|
|
20
|
-
} & (Omit<SassEmbeddedStringOptions<"sync">, "charset" | "indentedSyntax"> | Omit<SassStringOptions<"sync">, "charset" | "indentedSyntax">);
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type * as sass from "sass";
|
|
2
|
-
import type * as sassEmbedded from "sass-embedded";
|
|
3
|
-
declare const getSassCompiler: (implementation: "sass-embedded" | "sass" | undefined) => Promise<((sassOptions: sass.StringOptions<"sync"> & {
|
|
4
|
-
data: string;
|
|
5
|
-
}) => sass.CompileResult) | ((sassOptions: sassEmbedded.StringOptions<"sync"> & {
|
|
6
|
-
data: string;
|
|
7
|
-
}) => sassEmbedded.CompileResult)>;
|
|
8
|
-
export default getSassCompiler;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { RollupLogger } from "@visulima/packem-share/utils";
|
|
2
|
-
import type { SassLoaderContext, SassLoaderOptions } from "../types.d.ts";
|
|
3
|
-
/**
|
|
4
|
-
* Derives the sass options from the loader context and normalizes its values with sane defaults.
|
|
5
|
-
*/
|
|
6
|
-
declare const getSassOptions: (loaderContext: SassLoaderContext, logger: RollupLogger, options: SassLoaderOptions, content: string, useSourceMap: boolean) => Promise<SassLoaderOptions>;
|
|
7
|
-
export default getSassOptions;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
type SassError = Error & {
|
|
2
|
-
column?: number;
|
|
3
|
-
id: string;
|
|
4
|
-
line?: number;
|
|
5
|
-
};
|
|
6
|
-
declare const errorFactory: (error: Error & {
|
|
7
|
-
formatted?: string;
|
|
8
|
-
span?: {
|
|
9
|
-
start: {
|
|
10
|
-
column: number;
|
|
11
|
-
line: number;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
}, file: string) => SassError;
|
|
15
|
-
export default errorFactory;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import type { Environment } from "@visulima/packem-share/types";
|
|
2
|
-
import type { RenderOptions } from "stylus";
|
|
3
|
-
/**
|
|
4
|
-
* Minimal context passed to `additionalData` functions.
|
|
5
|
-
*/
|
|
6
|
-
export type StylusLoaderContext = {
|
|
7
|
-
environment: Environment;
|
|
8
|
-
resourcePath: string;
|
|
9
|
-
rootContext: string;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Stylus plugin: either a function that receives the renderer,
|
|
13
|
-
* or a module id (string) that resolves to a plugin factory.
|
|
14
|
-
*/
|
|
15
|
-
export type StylusPlugin = string | ((renderer: unknown) => void);
|
|
16
|
-
/**
|
|
17
|
-
* Definition entry: `[name, value]` or `[name, value, raw]`.
|
|
18
|
-
*/
|
|
19
|
-
export type StylusDefinition = [string, unknown] | [string, unknown, boolean];
|
|
20
|
-
/**
|
|
21
|
-
* Configuration options for the Stylus loader.
|
|
22
|
-
*
|
|
23
|
-
* Extends the standard Stylus RenderOptions with loader-specific functionality.
|
|
24
|
-
* These options are passed to the Stylus compiler during processing.
|
|
25
|
-
* @example
|
|
26
|
-
* ```typescript
|
|
27
|
-
* const stylusOptions: StylusLoaderOptions = {
|
|
28
|
-
* paths: ['./styles', './node_modules'],
|
|
29
|
-
* define: { 'primary-color': '#007acc' },
|
|
30
|
-
* import: ['nib'],
|
|
31
|
-
* use: ['nib'],
|
|
32
|
-
* compress: true,
|
|
33
|
-
* };
|
|
34
|
-
* ```
|
|
35
|
-
* @see {@link https://stylus-lang.com/docs/js.html} Stylus.js API Documentation
|
|
36
|
-
*/
|
|
37
|
-
export type StylusLoaderOptions = {
|
|
38
|
-
/**
|
|
39
|
-
* Prepends or appends Stylus code to the entry file before compilation.
|
|
40
|
-
* Useful for injecting shared variables, mixins, or plugin imports.
|
|
41
|
-
*/
|
|
42
|
-
additionalData?: string | ((content: string, loaderContext: StylusLoaderContext) => Promise<string> | string);
|
|
43
|
-
/**
|
|
44
|
-
* Disable stylus internal cache.
|
|
45
|
-
*/
|
|
46
|
-
disableCache?: boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Hoist `@import`/`@charset` at-rules to the top of the file
|
|
49
|
-
* (maps to stylus `hoist atrules`).
|
|
50
|
-
*/
|
|
51
|
-
hoistAtrules?: boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Custom stylus implementation. Either a module id to import,
|
|
54
|
-
* or a pre-imported Stylus function.
|
|
55
|
-
*/
|
|
56
|
-
implementation?: string | ((code: string, options?: unknown) => unknown);
|
|
57
|
-
/**
|
|
58
|
-
* Files to pre-import before compiling. Equivalent to calling
|
|
59
|
-
* `.import()` on the renderer for each entry.
|
|
60
|
-
*/
|
|
61
|
-
import?: string[];
|
|
62
|
-
/**
|
|
63
|
-
* Additional include paths. Equivalent to calling `.include()`
|
|
64
|
-
* on the renderer for each entry.
|
|
65
|
-
*/
|
|
66
|
-
include?: string[];
|
|
67
|
-
/**
|
|
68
|
-
* Include regular CSS on `@import` (maps to stylus `include css`).
|
|
69
|
-
*/
|
|
70
|
-
includeCSS?: boolean;
|
|
71
|
-
/**
|
|
72
|
-
* Emit comments in the generated CSS indicating the corresponding
|
|
73
|
-
* stylus line (maps to stylus `linenos`).
|
|
74
|
-
*/
|
|
75
|
-
lineNumbers?: boolean;
|
|
76
|
-
/**
|
|
77
|
-
* Pre-define variables/functions on the renderer.
|
|
78
|
-
* Accepts either a plain object keyed by name or a list of
|
|
79
|
-
* `[name, value]` / `[name, value, raw]` tuples.
|
|
80
|
-
*/
|
|
81
|
-
define?: Record<string, unknown> | StylusDefinition[];
|
|
82
|
-
/**
|
|
83
|
-
* Stylus plugins to apply via `.use()`.
|
|
84
|
-
* Strings are resolved and required relative to the current working directory.
|
|
85
|
-
*/
|
|
86
|
-
use?: StylusPlugin[];
|
|
87
|
-
} & RenderOptions;
|
package/dist/loaders/types.d.ts
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import type { Environment } from "@visulima/packem-share/types";
|
|
2
|
-
import type { RollupLogger } from "@visulima/packem-share/utils";
|
|
3
|
-
import type { CustomPluginOptions, PluginContext } from "rollup";
|
|
4
|
-
import type { RawSourceMap } from "source-map-js";
|
|
5
|
-
import type { InternalStyleOptions } from "../types.d.ts";
|
|
6
|
-
export interface Extracted {
|
|
7
|
-
/** CSS */
|
|
8
|
-
css: string;
|
|
9
|
-
/** Source file path */
|
|
10
|
-
id: string;
|
|
11
|
-
/** Sourcemap */
|
|
12
|
-
map?: string;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* @param T type of loader's options
|
|
16
|
-
*/
|
|
17
|
-
export interface Loader<T = Record<string, unknown>> {
|
|
18
|
-
/** Skip testing, always process the file */
|
|
19
|
-
alwaysProcess?: boolean;
|
|
20
|
-
/** Name */
|
|
21
|
-
name: string;
|
|
22
|
-
/** Function for processing */
|
|
23
|
-
process: (this: LoaderContext<T>, payload: Payload) => Payload | Promise<Payload>;
|
|
24
|
-
/**
|
|
25
|
-
* Test to control if file should be processed.
|
|
26
|
-
* Also used for plugin's supported files test.
|
|
27
|
-
*/
|
|
28
|
-
test?: RegExp | ((file: string) => boolean);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* @param T type of loader's options
|
|
32
|
-
*/
|
|
33
|
-
export interface LoaderContext<T = Record<string, unknown>> {
|
|
34
|
-
readonly alias?: Record<string, string>;
|
|
35
|
-
/** Assets to emit */
|
|
36
|
-
readonly assets: Map<string, Uint8Array>;
|
|
37
|
-
/** @see {@link InternalStyleOptions.autoModules} */
|
|
38
|
-
readonly autoModules: InternalStyleOptions["autoModules"];
|
|
39
|
-
/** Browser targets */
|
|
40
|
-
readonly browserTargets: string[];
|
|
41
|
-
readonly cwd?: string;
|
|
42
|
-
readonly debug?: boolean;
|
|
43
|
-
/** Files to watch */
|
|
44
|
-
readonly deps: Set<string>;
|
|
45
|
-
/** @see {@link InternalStyleOptions.dts} */
|
|
46
|
-
readonly dts: InternalStyleOptions["dts"];
|
|
47
|
-
/** @see {@link InternalStyleOptions.emit} */
|
|
48
|
-
readonly emit: InternalStyleOptions["emit"];
|
|
49
|
-
readonly environment: Environment;
|
|
50
|
-
/** @see {@link InternalStyleOptions.extensions} */
|
|
51
|
-
readonly extensions: InternalStyleOptions["extensions"];
|
|
52
|
-
/** @see {@link InternalStyleOptions.extract} */
|
|
53
|
-
readonly extract: InternalStyleOptions["extract"];
|
|
54
|
-
/** Resource path */
|
|
55
|
-
readonly id: string;
|
|
56
|
-
/** @see {@link InternalStyleOptions.inject} */
|
|
57
|
-
readonly inject: InternalStyleOptions["inject"];
|
|
58
|
-
/** @see {@link InternalStyleOptions.inline} */
|
|
59
|
-
readonly inline: InternalStyleOptions["inline"];
|
|
60
|
-
/** Rollup-compatible logger for plugin messages */
|
|
61
|
-
readonly logger: RollupLogger;
|
|
62
|
-
/** @see {@link InternalStyleOptions.namedExports} */
|
|
63
|
-
readonly namedExports: InternalStyleOptions["namedExports"];
|
|
64
|
-
/**
|
|
65
|
-
* Type-safe configuration options passed to the loader instance
|
|
66
|
-
* @default {}
|
|
67
|
-
*/
|
|
68
|
-
readonly options: T;
|
|
69
|
-
/** [Plugin's context](https://rollupjs.org/guide/en#plugin-context) */
|
|
70
|
-
readonly plugin: PluginContext;
|
|
71
|
-
readonly sourceDir?: string;
|
|
72
|
-
/** @see {@link InternalStyleOptions.sourceMap} */
|
|
73
|
-
readonly sourceMap: false | (SourceMapOptions & {
|
|
74
|
-
inline: boolean;
|
|
75
|
-
});
|
|
76
|
-
readonly useSourcemap: boolean;
|
|
77
|
-
}
|
|
78
|
-
export interface Payload {
|
|
79
|
-
/** File content */
|
|
80
|
-
code: string;
|
|
81
|
-
dts?: string;
|
|
82
|
-
/** Extracted data */
|
|
83
|
-
extracted?: Extracted;
|
|
84
|
-
/** Sourcemap */
|
|
85
|
-
map?: string;
|
|
86
|
-
/** Additional metadata exposed to other Rollup plugins */
|
|
87
|
-
meta?: CustomPluginOptions;
|
|
88
|
-
}
|
|
89
|
-
export type PostCSSMeta = {
|
|
90
|
-
icssDependencies: string[];
|
|
91
|
-
moduleContents: string;
|
|
92
|
-
types: string;
|
|
93
|
-
};
|
|
94
|
-
export interface SourceMapOptions {
|
|
95
|
-
/**
|
|
96
|
-
* Include sources content
|
|
97
|
-
* @default true
|
|
98
|
-
*/
|
|
99
|
-
content?: boolean;
|
|
100
|
-
/** Function for transforming resulting sourcemap */
|
|
101
|
-
transform?: (map: RawSourceMap, name?: string) => void;
|
|
102
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { AutoModules } from "../../types.d.ts";
|
|
2
|
-
/**
|
|
3
|
-
* Determines if CSS modules should be enabled for a given file.
|
|
4
|
-
*
|
|
5
|
-
* This function checks various conditions to decide whether CSS modules
|
|
6
|
-
* processing should be applied to a file:
|
|
7
|
-
*
|
|
8
|
-
* 1. If AutoModules is undefined, defaults to true (enable modules)
|
|
9
|
-
* 2. If AutoModules is a function, calls it with the file ID
|
|
10
|
-
* 3. If AutoModules is a RegExp, tests it against the file ID
|
|
11
|
-
* 4. If AutoModules is true, uses the default module file pattern
|
|
12
|
-
* 5. If AutoModules is false, modules are disabled
|
|
13
|
-
*
|
|
14
|
-
* The default pattern matches files with `.module.` in their name,
|
|
15
|
-
* following the convention used by Vite and other build tools.
|
|
16
|
-
* @param am AutoModules configuration (function, RegExp, boolean, or undefined)
|
|
17
|
-
* @param id File identifier/path to test
|
|
18
|
-
* @returns True if CSS modules should be enabled for this file
|
|
19
|
-
* @example
|
|
20
|
-
* ```typescript
|
|
21
|
-
* // Function-based detection
|
|
22
|
-
* ensureAutoModules((id) => id.includes('.module.'), 'styles.module.css') // true
|
|
23
|
-
*
|
|
24
|
-
* // RegExp-based detection
|
|
25
|
-
* ensureAutoModules(/\.module\./, 'styles.module.css') // true
|
|
26
|
-
*
|
|
27
|
-
* // Boolean enable with default pattern
|
|
28
|
-
* ensureAutoModules(true, 'styles.module.css') // true
|
|
29
|
-
* ensureAutoModules(true, 'styles.css') // false
|
|
30
|
-
*
|
|
31
|
-
* // Boolean disable
|
|
32
|
-
* ensureAutoModules(false, 'styles.module.css') // false
|
|
33
|
-
*
|
|
34
|
-
* // Undefined defaults to true with pattern check
|
|
35
|
-
* ensureAutoModules(undefined, 'styles.module.css') // true
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
declare const ensureAutoModules: (am: AutoModules | undefined, id: string) => boolean;
|
|
39
|
-
export default ensureAutoModules;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { Loader } from "../types.d.ts";
|
|
2
|
-
/**
|
|
3
|
-
* Tests whether a file matches a loader's test condition.
|
|
4
|
-
*
|
|
5
|
-
* This function handles different types of test conditions that can be
|
|
6
|
-
* specified in a loader configuration:
|
|
7
|
-
*
|
|
8
|
-
* 1. **Function**: Calls the function with the file path
|
|
9
|
-
* 2. **RegExp**: Uses the RegExp's test method
|
|
10
|
-
* 3. **undefined/null**: Returns false (no match)
|
|
11
|
-
* @param file File path to test against the condition
|
|
12
|
-
* @param condition The test condition from a loader (function, RegExp, or undefined)
|
|
13
|
-
* @returns True if the file matches the condition, false otherwise
|
|
14
|
-
* @throws Error if the condition type is invalid/unsupported
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* // Function-based matching
|
|
18
|
-
* matchFile('styles.css', (file) => file.endsWith('.css')) // true
|
|
19
|
-
*
|
|
20
|
-
* // RegExp-based matching
|
|
21
|
-
* matchFile('styles.sass', /\.(sass|scss)$/i) // false
|
|
22
|
-
* matchFile('styles.scss', /\.(sass|scss)$/i) // true
|
|
23
|
-
*
|
|
24
|
-
* // No condition (undefined)
|
|
25
|
-
* matchFile('any-file.txt', undefined) // false
|
|
26
|
-
*
|
|
27
|
-
* // Invalid condition throws error
|
|
28
|
-
* matchFile('file.css', { invalid: 'condition' }) // throws Error
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
declare const matchFile: (file: string, condition: Loader["test"]) => boolean;
|
|
32
|
-
export default matchFile;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { RollupLogger } from "@visulima/packem-share/utils";
|
|
2
|
-
import type { LoaderContext } from "../loaders/types.d.ts";
|
|
3
|
-
import type { ExtractedData } from "../types.d.ts";
|
|
4
|
-
/**
|
|
5
|
-
* Context object provided to minifier handlers during CSS minification.
|
|
6
|
-
*
|
|
7
|
-
* Contains build-time information and utilities needed for proper minification:
|
|
8
|
-
* - Browser compatibility targets for optimization decisions
|
|
9
|
-
* - Logging system for reporting minification issues
|
|
10
|
-
*/
|
|
11
|
-
type MinifierContext = {
|
|
12
|
-
/** Browser targets for compatibility-aware minification */
|
|
13
|
-
readonly browserTargets: string[];
|
|
14
|
-
/**
|
|
15
|
-
* Rollup-compatible logger for reporting minification issues.
|
|
16
|
-
* Provides consistent logging across all plugin operations.
|
|
17
|
-
*/
|
|
18
|
-
readonly logger: RollupLogger;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Interface for CSS minification plugins.
|
|
22
|
-
*
|
|
23
|
-
* Minifiers are responsible for optimizing CSS content while preserving
|
|
24
|
-
* functionality and maintaining source maps when available. They receive
|
|
25
|
-
* extracted CSS data and return optimized versions.
|
|
26
|
-
* @template Options Configuration options type for the minifier
|
|
27
|
-
* @example
|
|
28
|
-
* ```typescript
|
|
29
|
-
* const myMinifier: Minifier<MyOptions> = {
|
|
30
|
-
* name: 'my-minifier',
|
|
31
|
-
* async handler(data, sourceMap, options) {
|
|
32
|
-
* // Minify CSS content
|
|
33
|
-
* const minified = await minifyCss(data.css, options);
|
|
34
|
-
*
|
|
35
|
-
* // Report any warnings
|
|
36
|
-
* if (minified.warnings.length > 0) {
|
|
37
|
-
* this.logger.warn({ message: `Minification warnings: ${minified.warnings.join(', ')}` });
|
|
38
|
-
* }
|
|
39
|
-
*
|
|
40
|
-
* return {
|
|
41
|
-
* ...data,
|
|
42
|
-
* css: minified.css,
|
|
43
|
-
* map: minified.map
|
|
44
|
-
* };
|
|
45
|
-
* }
|
|
46
|
-
* };
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
export interface Minifier<Options = Record<string, any>> {
|
|
50
|
-
/**
|
|
51
|
-
* Minification handler function.
|
|
52
|
-
*
|
|
53
|
-
* Processes CSS content and returns optimized version with updated source maps.
|
|
54
|
-
* The handler is called with minifier context containing browser targets and warning utilities.
|
|
55
|
-
* @param data Extracted CSS data to minify
|
|
56
|
-
* @param sourceMap Source map configuration from loader context
|
|
57
|
-
* @param options Minifier-specific configuration options
|
|
58
|
-
* @returns Promise resolving to minified CSS data
|
|
59
|
-
*/
|
|
60
|
-
handler: (this: MinifierContext, data: ExtractedData, sourceMap: LoaderContext["sourceMap"], options: Options) => Promise<ExtractedData>;
|
|
61
|
-
/** Unique name identifier for the minifier */
|
|
62
|
-
name: string;
|
|
63
|
-
}
|
|
64
|
-
export {};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
var l=Object.defineProperty;var u=(o,n)=>l(o,"name",{value:n,configurable:!0});import{SourceMapGenerator as p}from"source-map-js";import{m as f}from"./sourcemap-CB6ochh0.js";var g=Object.defineProperty,d=u((o,n)=>g(o,"name",{value:n,configurable:!0}),"u");const j=d(async o=>{const n=new p({file:""}),a=[];let c=0;for await(const{css:s,map:m}of o){a.push(s);const i=f(m),t=i.toObject();if(t){const r=i.toConsumer();if(r&&(r.eachMapping(e=>{n.addMapping({generated:{column:e.generatedColumn,line:c+e.generatedLine},name:e.name,original:{column:e.originalColumn,line:e.originalLine},source:e.source})}),t.sourcesContent))for(const e of t.sources)n.setSourceContent(e,r.sourceContentFor(e,!0))}c+=s.split(`
|
|
2
|
-
`).length}return{css:a.join(`
|
|
3
|
-
`),map:n}},"concat");export{j as default};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
var G=Object.defineProperty;var C=(r,s)=>G(r,"name",{value:s,configurable:!0});import{relative as V,basename as P}from"@visulima/path";import R from"./safeId-BN5akJYJ.js";var W=Object.defineProperty,w=C((r,s)=>W(r,"name",{value:s,configurable:!0}),"j");const d="css",F=new Set(["abstract","arguments","await","boolean","break","byte","case","catch","char","class","const","continue",d,"debugger","default","delete","do","double","else","enum","eval","export","extends","false","final","finally","float","for","function","goto","if","implements","import","in","instanceof","int","interface","let","long","native","new","null","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","true","try","typeof","var","void","volatile","while","with","yield"]),D=w(r=>{const s=r.replaceAll(/[^\w$]/g,"_");return F.has(s)?`_${s}`:s},"getClassNameIdentifier"),H=w(({css:r,cssVariableName:s,cwd:l,dts:y,dtsOutput:m,id:j,logger:c,modulesExports:e,modulesVariableName:b,namedExports:$,supportModules:g})=>{const o=[`var ${s} = ${JSON.stringify(r)};`];if($&&Object.keys(e).length>0){const u=typeof $=="function"?$:D;for(const[h,a]of Object.entries(e)){const t=u(h);if(h!==t&&c){const v=l?V(l,j):j;c.warn({message:`Exported \`${h}\` as \`${t}\` in ${v}`})}const n=JSON.stringify(a);o.push(`var ${t} = ${n};`),y&&m.push(`declare const ${t}: ${n};`)}}Object.keys(e).length>0&&o.push(`var ${b} = ${JSON.stringify(e)};`);const p=`
|
|
2
|
-
export default ${g?b:s};
|
|
3
|
-
`;return o.push(p),y&&(m.push(`declare const ${s}: string;`),g&&m.push(`
|
|
4
|
-
interface ModulesExports {
|
|
5
|
-
${Object.keys(e).map(u=>` '${u}': string;`).join(`
|
|
6
|
-
`)}
|
|
7
|
-
}
|
|
8
|
-
`,`declare const ${b}: ModulesExports;`),m.push(p)),{code:o.join(`
|
|
9
|
-
`),moduleSideEffects:!1,types:y?m.join(`
|
|
10
|
-
`):void 0}},"generateInlineExports"),T=w(({css:r,cwd:s,dts:l=!1,emit:y=!1,extract:m=!1,icssDependencies:j=[],id:c,inject:e,inline:b=!1,logger:$,map:g,modulesExports:o,namedExports:p,supportModules:u})=>{const h=w(i=>R(i,P(c)),"saferId"),a=h("modules"),t=[`var ${d} = ${JSON.stringify(r)};`],n=[],v=[d];if(p){l&&n.push(`declare const ${d}: string;`);const i=typeof p=="function"?p:D;for(const[x,O]of Object.entries(o)){const f=i(x);if(x!==f&&$){const S=s?V(s,c):c;$.warn({message:`Exported \`${x}\` as \`${f}\` in ${S}`})}const E=JSON.stringify(O);t.push(`var ${f} = ${E};`),l&&n.push(`declare const ${f}: ${E};`),v.push(f)}}if(b)return H({css:r,cssVariableName:d,cwd:s,dts:l,dtsOutput:n,id:c,logger:$,modulesExports:o,modulesVariableName:a,namedExports:p,supportModules:u});if(e)if(typeof e=="function")t.push(e(d,c,t),`var ${a} = ${JSON.stringify(o)};`);else{const{treeshakeable:i,...x}=typeof e=="object"?e:{},O=h("injector"),f=`${O}(${d},${JSON.stringify(x)});`,E=typeof e=="object"&&e.package?e.package:"@visulima/css-style-inject",S=typeof e=="object"&&e.method?e.method:"cssStyleInject";if(t.unshift(`import { ${S} as ${O} } from "${E}";`),i||t.push(`var ${a} = ${JSON.stringify(o)};`,f),i){t.push("var injected = false;");const B=`if (!injected) { injected = true; ${f} }`;if(o.inject)throw new Error("`inject` keyword is reserved when using `inject.treeshakeable` option");let k="";for(const[_,z]of Object.entries(o)){const A=JSON.stringify(_),q=JSON.stringify(z);k+=`get ${A}() { ${B} return ${q}; },
|
|
11
|
-
`}k+=`inject: function inject() { ${B} },`,t.push(`var ${a} = {${k}};`)}}!e&&Object.keys(o).length>0&&t.push(`var ${a} = ${JSON.stringify(o)};`);const J=`
|
|
12
|
-
export default ${u?a:d};
|
|
13
|
-
`;if(t.push(J),l&&(u&&n.push(`
|
|
14
|
-
interface ModulesExports {
|
|
15
|
-
${Object.keys(o).map(i=>` '${i}': string;`).join(`
|
|
16
|
-
`)}
|
|
17
|
-
}
|
|
18
|
-
`,typeof e=="object"&&e.treeshakeable?"interface ModulesExports {inject:()=>void}":"",`declare const ${a}: ModulesExports;`),n.push(J)),p){const i=`export {
|
|
19
|
-
${v.filter(Boolean).join(`,
|
|
20
|
-
`)}
|
|
21
|
-
};`;t.push(i),l&&n.push(i)}const N=t.filter(Boolean).join(`
|
|
22
|
-
`),M=n.length>0?n.filter(Boolean).join(`
|
|
23
|
-
`):void 0;if(y)return{code:r,map:g,meta:{icssDependencies:j,moduleContents:N,types:void 0},moduleSideEffects:!0};let I;return m&&(I={css:r,id:c,map:g}),{code:N,extracted:I,map:g,meta:{icssDependencies:j,moduleContents:N,types:M},moduleSideEffects:u||typeof e=="object"&&e.treeshakeable?!1:"no-treeshake",types:M}},"generateJsExports");export{T as g};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var s=Object.defineProperty;var o=(e,r)=>s(e,"name",{value:r,configurable:!0});import{parse as t,normalize as i,isAbsolute as n}from"@visulima/path";import{isRelative as f}from"@visulima/path/utils";var m=Object.defineProperty,a=o((e,r)=>m(e,"name",{value:r,configurable:!0}),"e");const c=a(e=>/^~[\d@A-Z]/i.test(e),"hasModuleSpecifier"),b=a(e=>{const{base:r,dir:l}=t(e);return l?`${i(l)}/_${r}`:`_${r}`},"getUrlOfPartial"),v=a(e=>c(e)?i(e.slice(1)):n(e)||f(e)?i(e):`./${i(e)}`,"normalizeUrl");export{b as getUrlOfPartial,c as hasModuleSpecifier,v as normalizeUrl};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var f=Object.defineProperty;var l=(n,r)=>f(n,"name",{value:r,configurable:!0});import p from"./arrayFmt-Dek5cB7m.js";import d from"./loadModule-D20jQQNu.js";var y=Object.defineProperty,o=l((n,r)=>y(n,"name",{value:r,configurable:!0}),"o");const u=["inject","extract","emit","inline"],S=p(u),P=o(n=>{const r=Array.isArray(n)?n:[n];if(r[0]&&!u.includes(r[0]))throw new Error(`Incorrect mode provided, allowed modes are ${S}`);const t=r[0]??"inject";let e=!1,i=!1;return t==="extract"&&(e=r[1]??!0),t==="inject"&&(i=r[1]??!0),{emit:t==="emit",extract:e,inject:i,inline:t==="inline"}},"inferModeOption"),O=o((n,r)=>typeof n=="boolean"?n&&{}:typeof n=="object"?n:r,"inferOption"),j=o(n=>{const r=Array.isArray(n)?n:[n];return r[0]?{content:!0,...r[1],inline:r[0]==="inline"}:!1},"inferSourceMapOption"),b=o((n,r)=>{const t=O(n,{});return r&&typeof t=="object"&&!t.alias&&(t.alias=r),t},"inferHandlerOption"),a=o(async(n,r,t,e)=>{if(typeof n!="string")return n;const i=await d(n,t,e);if(!i)throw new Error(`Unable to load PostCSS ${r} \`${n}\``);return i},"ensurePCSSOption"),h=o(async(n,r,t)=>{if(n===void 0)return[];if(n.length===0)return[];const e=[];for await(const i of n.filter(Boolean)){if(!Array.isArray(i)){e.push(await a(i,"plugin",r,t));continue}const[s,c]=i;c?e.push((await a(s,"plugin",r,t))(c)):e.push(await a(s,"plugin",r,t))}return e},"ensurePCSSPlugins");export{a as ensurePCSSOption,h as ensurePCSSPlugins,b as inferHandlerOption,P as inferModeOption,O as inferOption,j as inferSourceMapOption};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var d=Object.defineProperty;var n=(e,t)=>d(e,"name",{value:t,configurable:!0});import{createRequire as c}from"node:module";import{interopDefault as m,loadModule as f}from"mlly";import{resolve as p}from"./resolve-anj9ucIq.js";var g=Object.defineProperty,u=n((e,t)=>g(e,"name",{value:t,configurable:!0}),"a");const o={},R=[".js",".mjs",".cjs",".json"],y=u(async(e,t)=>{try{return t(e)}catch(r){const s=r;if(s.code==="ERR_REQUIRE_ESM")return m(await f(e));throw s}},"loadModuleFromPath"),E=u(async(e,t,r)=>{if(o[e])return o[e];if(o[e]===null)return;const s={baseDirs:[t],caller:"Module loader",extensions:R,symlinks:!1},i=c(import.meta.url);try{const a=p([e,`./${e}`],s);if(a.startsWith("data:")){r.warn({message:`Skipping data URL module: ${e}`,module:e,plugin:"css"}),o[e]=null;return}o[e]=await y(a,i)}catch(a){r.warn({message:`Failed to resolve or load module: ${a instanceof Error?a.message:String(a)}`,module:e,plugin:"css"}),o[e]=null;return}const l=o[e];return l?.default??l},"loadModule");export{E as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var a=Object.defineProperty;var i=(o,e)=>a(o,"name",{value:e,configurable:!0});import{fileURLToPath as m}from"node:url";import{dirname as f}from"@visulima/path";import{ResolverFactory as x}from"oxc-resolver";import d from"./arrayFmt-Dek5cB7m.js";var u=Object.defineProperty,v=i((o,e)=>u(o,"name",{value:e,configurable:!0}),"l");const b=f(m(import.meta.url)),k=v((o,e)=>{const s={baseDirs:[b],caller:"Resolver",extensions:[".mjs",".js",".cjs",".json"],symlinks:!0,...e},c=new x({extensions:s.extensions,symlinks:s.symlinks});for(const n of s.baseDirs)for(const t of o)try{const{error:r,path:l}=c.sync(n,t);if(l)return l;r&&console.debug(r,{context:[{basedir:n,caller:e.caller,extensions:e.extensions,id:t}]})}catch(r){console.debug(r.message,{context:[{basedir:n,caller:e.caller,error:r,extensions:e.extensions,id:t}]})}throw new Error(`${s.caller} could not resolve ${d(o)}`)},"resolve");export{k as resolve};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
var Y=Object.defineProperty;var N=(e,s)=>Y(e,"name",{value:s,configurable:!0});import{createFilter as ee}from"@rollup/pluginutils";import{createRollupLogger as se}from"@visulima/packem-share/utils";import{dirname as L,normalize as M,isAbsolute as te,relative as U,resolve as oe,parse as T,join as _,basename as V}from"@visulima/path";import{isRelative as ie}from"@visulima/path/utils";import re from"p-queue";import ne from"./concat-WcWAYbOc.js";import{inferSourceMapOption as ae,inferModeOption as ce,inferHandlerOption as W,inferOption as G,ensurePCSSOption as R,ensurePCSSPlugins as le}from"./inferModeOption-9h3Eq6JH.js";import{m as q}from"./sourcemap-CB6ochh0.js";var de=Object.defineProperty,ue=N((e,s)=>de(e,"name",{value:s,configurable:!0}),"r");const J=ue((e,s)=>{if(!s)return!1;if(typeof s=="function")return s(e);if(typeof s.test=="function")return s.test(e);throw new Error("Invalid condition type")},"matchFile");var pe=Object.defineProperty,fe=N((e,s)=>pe(e,"name",{value:s,configurable:!0}),"a");const me=4,ge=process.env.UV_THREADPOOL_SIZE?Number.parseInt(process.env.UV_THREADPOOL_SIZE,10):me;class he{static{N(this,"g")}static{fe(this,"LoaderManager")}test;loaders=new Map;options;workQueue;logger;constructor({extensions:s,loaders:c,logger:y,options:O}){this.test=S=>s.some(f=>S.toLowerCase().endsWith(f)),c.length>0&&this.add(...c),this.options=O,this.logger=y}add(...s){for(const c of s)this.loaders.has(c.name)||this.loaders.set(c.name,c)}isSupported(s){if(this.test(s))return!0;for(const[,c]of this.loaders)if(J(s,c.test))return!0;return!1}async process(s,c){this.workQueue||(this.workQueue=new re({concurrency:ge-1}));for await(const[y,O]of this.loaders){const S={...c,options:this.options[y]??{}};if(O.alwaysProcess||J(S.id,O.test)){this.logger.debug({message:`Processing ${y} loader for ${S.id}`,plugin:"css"});try{const f=await this.workQueue.add(O.process.bind(S,s));f&&(s={...f,extracted:f.extracted??s.extracted,meta:f.meta??s.meta},this.logger.debug({message:`Completed ${y} loader for ${S.id}`,outputSize:f.code?.length||0,plugin:"css"}))}catch(f){throw this.logger.error({file:S.id,loader:y,message:`Error in ${y} loader for ${S.id}: ${f instanceof Error?f.message:String(f)}`,plugin:"css"}),f}}}return s}}var xe=Object.defineProperty,z=N((e,s)=>xe(e,"name",{value:s,configurable:!0}),"b");const ye=z(async(e,s)=>e.sort((c,y)=>s.indexOf(c.name)-s.indexOf(y.name)),"sortByNameOrder"),Fe=z(async(e,s,c,y,O,S,f,Z,K)=>{const C={...K,...e.alias},B=ee(e.include,e.exclude),E=ae(e.sourceMap),i={...ce(e.mode),autoModules:e.autoModules??!1,dts:e.dts,extensions:e.extensions,namedExports:e.namedExports};let a,I,H=!1;if(e.loaders)for(const r of e.loaders)r.name==="postcss"&&(H=!0);else e.loaders=[];H&&(i.postcss={...e.postcss,config:G(e.postcss?.config,{}),import:W(e.postcss?.import,C),modules:G(e.postcss?.modules,void 0),to:e.postcss?.to,url:W(e.postcss?.url,C)});let b=[];const F=z((r,d)=>{const g=[];for(const o of Object.keys(r)){const u=new Set;let h=[o];do{const $=[];for(const m of h){if(u.has(m))continue;if(I.isSupported(m)){B(m)&&$.push(m);continue}u.add(m);const P=d(m);P&&$.push(...P.importedIds)}h=$}while(h.some($=>!I.isSupported($)));g.push(...h)}return g},"traverseImportedModules");return{augmentChunkHash(r){if(b.length===0)return;const d=F(r.modules,this.getModuleInfo),g=b.filter(o=>d.includes(o.id)).sort((o,u)=>d.lastIndexOf(o.id)-d.lastIndexOf(u.id)).map(o=>`${V(o.id)}:${o.css}`);if(g.length!==0)return g.join(":")},async buildStart(){b=[],a=se(this,"css"),H&&i.postcss&&(e.postcss?.parser&&(i.postcss.parser=await R(e.postcss.parser,"parser",c,a)),e.postcss?.syntax&&(i.postcss.syntax=await R(e.postcss.syntax,"syntax",c,a)),e.postcss?.stringifier&&(i.postcss.stringifier=await R(e.postcss.stringifier,"stringifier",c,a)),e.postcss?.plugins&&(i.postcss.plugins=await le(e.postcss.plugins,c,a))),I=new he({extensions:i.extensions,loaders:await ye(e.loaders||[],["sourcemap","stylus","less","sass","postcss"]),logger:a,options:{...e,...i,alias:C}}),a.info({extract:typeof i.extract=="string"?i.extract:"individual",loaders:e.loaders?.map(r=>r.name)||[],message:"CSS plugin initialized",minify:!!(Z&&e.minifier),namedExports:!!i.namedExports,plugin:"css",sourceMap:!!S}),typeof i.inject=="object"&&i.inject.treeshakeable&&(i.namedExports=!1,a.info({message:"Disabling named exports due to `inject.treeshakeable` option",plugin:"css"}))},async generateBundle(r,d){if(b.length===0||!(r.dir||r.file))return;const g=Object.values(d),o=r.dir??L(r.file),u=g.filter(n=>n.type==="chunk"),h=u.filter(n=>!n.facadeModuleId),$=r.preserveModules?u:u.filter(n=>n.isEntry||n.isDynamicEntry),m=[],P=z(async(n,l)=>{const t=typeof i.extract=="string"?M(i.extract).replace(/^\.[/\\]/,""):M(`${n}.css`);te(t)&&this.error(["Extraction path must be relative to the output directory,",`which is ${U(c,o)}`].join(`
|
|
2
|
-
`)),ie(t)&&this.error(["Extraction path must be nested inside output directory,",`which is ${U(c,o)}`].join(`
|
|
3
|
-
`));const w=b.filter(x=>l.includes(x.id)).sort((x,v)=>l.lastIndexOf(x.id)-l.lastIndexOf(v.id)),D=await ne(w);return{css:D.css,map:q(D.map.toString()).relative(L(oe(o,t))).toString(),name:t}},"getExtractedData"),A=z(n=>{if(r.file)return T(r.file).name;if(r.preserveModules){const{dir:l,name:t}=T(n.fileName);return l?_(l,t):t}return n.name},"getName"),k=[];if(typeof i.extract=="string"){a.debug({message:`Extracting to ${i.extract}`,prefix:"css"});const n=[];for(const t of h){const w=F(t.modules,this.getModuleInfo);k.push(...w),n.push(...w)}for(const t of $)n.push(...F(t.modules,this.getModuleInfo).filter(w=>!k.includes(w)));const l=A(u[0]);m.push([l,n])}else{a.debug({message:"Extracting to individual files",prefix:"css"});for(const n of h){const l=F(n.modules,this.getModuleInfo);if(l.length===0)continue;k.push(...l);const t=A(n);m.push([t,l])}for(const n of $){const l=F(n.modules,this.getModuleInfo).filter(w=>!k.includes(w));if(l.length===0)continue;const t=A(n);m.push([t,l])}}for await(const[n,l]of m){const t=await P(n,l);if(typeof e.onExtract=="function"&&!e.onExtract(t))continue;if(Z&&e.minifier){a.info({message:`Minifying ${t.name} with ${e.minifier.name}`,prefix:"css"});const{css:x,map:v}=await e.minifier.handler.bind({browserTargets:s,logger:a})(t,E,e[e.minifier.name]??{});t.css=x,t.map=v}const w={fileName:t.name,name:t.name,names:[t.name],originalFileName:t.name,originalFileNames:[t.name],source:t.css,type:"asset"},D=this.emitFile(w);if(a.info({chunkIds:l.length,hasSourceMap:!!(t.map&&E),message:`Emitted CSS file: ${t.name}`,plugin:"css",size:t.css.length}),t.map&&E){const x=this.getFileName(D);let v="assert";typeof r.assetFileNames=="string"?v=M(L(r.assetFileNames)):typeof r.assetFileNames=="function"&&(v=M(L(r.assetFileNames(w))));const j=q(t.map).modify(p=>(p.file=V(x),p)).modifySources(p=>{if(p==="<no source>"||v.length<=1)return p;p=`../${p}`;for(const Q of v)Q==="/"&&(p=`../${p}`);return p});if(E.inline)j.modify(p=>E.transform?.(p,M(_(o,x)))),d[x].source+=j.toCommentData(),a.debug({message:`Generated inline source map for ${x}`,plugin:"css"});else{const p=`${x}.map`;j.modify(X=>E.transform?.(X,M(_(o,p)))),this.emitFile({fileName:p,source:j.toString(),type:"asset"});const{base:Q}=T(p);d[x].source+=j.toCommentFile(Q),a.debug({message:`Generated external source map: ${p}`,plugin:"css"})}}}m.length>0&&a.info({filesEmitted:m.length,message:"CSS processing complete",plugin:"css",totalExtracted:b.length,totalSize:m.reduce((n,[,l])=>n+l.length,0)})},name:"rollup-plugin-css",async transform(r,d){if(!B(d)||!I.isSupported(d))return;if(r.replaceAll(/\s/g,"")===""){a.debug({message:`Skipping empty file: ${d}`,plugin:"css"});return}a.info({message:`Processing CSS file: ${d}`,plugin:"css",size:r.length}),typeof e.onImport=="function"&&e.onImport(r,d);const g={alias:C,assets:new Map,autoModules:i.autoModules,browserTargets:s,cwd:c,debug:f,deps:new Set,dts:i.dts,emit:i.emit,environment:O,extensions:i.extensions,extract:i.extract,id:d,inject:i.inject,inline:i.inline,logger:a,namedExports:i.namedExports,options:{},plugin:this,sourceDir:y,sourceMap:E,useSourcemap:S},o=await I.process({code:r},g);a.info({assets:g.assets.size,dependencies:g.deps.size,hasExtracted:!!o.extracted,message:`Processed ${d}`,outputSize:o.code.length,plugin:"css"});for(const u of g.deps)this.addWatchFile(u);for(const[u,h]of g.assets)this.emitFile({fileName:u,source:h,type:"asset"}),a.debug({message:`Emitted asset: ${u}`,plugin:"css",size:h.length});if(o.extracted){const{id:u}=o.extracted;b=b.filter(h=>h.id!==u),b.push(o.extracted),a.debug({cssSize:o.extracted.css.length,hasSourceMap:!!o.extracted.map,message:`Extracted CSS from ${u}`,plugin:"css"})}return{code:o.code,map:E&&o.map?o.map:{mappings:""},meta:{styles:o.meta},moduleSideEffects:o.extracted?!0:void 0}}}},"cssPlugin");export{Fe as default};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
var m=Object.defineProperty;var a=(e,s)=>m(e,"name",{value:s,configurable:!0});import{isAccessibleSync as u,readFileSync as h}from"@visulima/fs";import{resolve as n,isAbsolute as f,relative as l,normalize as d,dirname as S}from"@visulima/path";import{SourceMapConsumer as g}from"source-map-js";const w=/\[hash(?::(\d+))?\]/,x=/(?<!^|[/\\])(\.[^\s.]+)/,y=/data:[^\n\r;]+(?:;charset=[^\n\r;]+)?;base64,([\d+/A-Za-z]+={0,2})/;var M=Object.defineProperty,t=a((e,s)=>M(e,"name",{value:s,configurable:!0}),"i");const p=/(?:\n|\r\n)?\/\*[#*@]+\s*sourceMappingURL\s*=\s*(\S+)\s*\*+\//g,c=/(?:\n|\r\n)?\/\/[#@]+\s*sourceMappingURL\s*=\s*(\S+)\s*/g;class b{static{a(this,"S")}static{t(this,"MapModifier")}map;constructor(s){if(typeof s=="string")try{this.map=JSON.parse(s)}catch{}else this.map=s}modify(s){return this.map?(s(this.map),this):this}modifySources(s){return this.map?(this.map.sources&&(this.map.sources=this.map.sources.map(r=>s(r))),this):this}resolve(s=process.cwd()){return this.modifySources(r=>r==="<no source>"?r:n(s,r))}relative(s=process.cwd()){return this.modifySources(r=>r==="<no source>"?r:f(r)?l(s,r):d(r))}toObject(){return this.map}toString(){return this.map?JSON.stringify(this.map):this.map}toConsumer(){return this.map?new g(this.map):this.map}toCommentData(){const s=this.toString();return s?`
|
|
2
|
-
/*# sourceMappingURL=data:application/json;base64,${Buffer.from(s).toString("base64")} */`:""}toCommentFile(s){return this.map?`
|
|
3
|
-
/*# sourceMappingURL=${s} */`:""}}const O=t(async(e,s)=>{const[,r]=p.exec(e)??c.exec(e)??[];if(!r)return;const[,i]=y.exec(r)??[];if(i)return Buffer.from(i,"base64").toString();if(!s)throw new Error("Extracted map detected, but no ID is provided");const o=n(S(s),r);if(u(o))return h(o)},"getMap"),U=t(e=>e.replaceAll(p,"").replaceAll(c,""),"stripMap"),_=t(e=>new b(e),"mm");export{y as D,x as F,w as H,O as g,_ as m,U as s};
|