@unpackjs/core 1.5.4 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/openChrome.applescript +94 -0
- package/compiled/chokidar/index.d.ts +327 -0
- package/compiled/chokidar/index.js +1773 -0
- package/compiled/chokidar/license +21 -0
- package/compiled/chokidar/package.json +1 -0
- package/compiled/commander/index.d.ts +971 -0
- package/compiled/commander/index.js +2190 -0
- package/compiled/commander/license +22 -0
- package/compiled/commander/package.json +1 -0
- package/compiled/css-loader/api.js +85 -0
- package/compiled/css-loader/getUrl.js +26 -0
- package/compiled/css-loader/index.d.ts +1 -0
- package/compiled/css-loader/index.js +8004 -0
- package/compiled/css-loader/license +20 -0
- package/compiled/css-loader/noSourceMaps.js +5 -0
- package/compiled/css-loader/package.json +1 -0
- package/compiled/css-loader/sourceMaps.js +16 -0
- package/compiled/fast-glob/index.d.ts +237 -0
- package/compiled/fast-glob/index.js +5726 -0
- package/compiled/fast-glob/license +21 -0
- package/compiled/fast-glob/package.json +1 -0
- package/compiled/less-loader/index.d.ts +1 -0
- package/compiled/less-loader/index.js +340 -0
- package/compiled/less-loader/license +20 -0
- package/compiled/less-loader/package.json +1 -0
- package/compiled/line-diff/index.d.ts +1 -0
- package/compiled/line-diff/index.js +160 -0
- package/compiled/line-diff/license +21 -0
- package/compiled/line-diff/package.json +1 -0
- package/compiled/log-update/index.d.ts +1 -0
- package/compiled/log-update/index.js +1970 -0
- package/compiled/log-update/package.json +1 -0
- package/compiled/portfinder/index.d.ts +64 -0
- package/compiled/portfinder/index.js +3401 -0
- package/compiled/portfinder/license +22 -0
- package/compiled/portfinder/package.json +1 -0
- package/compiled/postcss-loader/index.d.ts +1 -0
- package/compiled/postcss-loader/index.js +94945 -0
- package/compiled/postcss-loader/license +20 -0
- package/compiled/postcss-loader/package.json +1 -0
- package/compiled/sass-loader/index.d.ts +961 -0
- package/compiled/sass-loader/index.js +5610 -0
- package/compiled/sass-loader/index1.js +65 -0
- package/compiled/sass-loader/license +20 -0
- package/compiled/sass-loader/package.json +1 -0
- package/compiled/sass-loader/sass.node.js +12 -0
- package/compiled/semver/index.d.ts +1 -0
- package/compiled/semver/index.js +1940 -0
- package/compiled/semver/license +15 -0
- package/compiled/semver/package.json +1 -0
- package/compiled/style-loader/index.d.ts +1 -0
- package/compiled/style-loader/index.js +370 -0
- package/compiled/style-loader/license +20 -0
- package/compiled/style-loader/package.json +1 -0
- package/compiled/style-loader/runtime/injectStylesIntoLinkTag.js +29 -0
- package/compiled/style-loader/runtime/injectStylesIntoStyleTag.js +84 -0
- package/compiled/style-loader/runtime/insertBySelector.js +34 -0
- package/compiled/style-loader/runtime/insertStyleElement.js +10 -0
- package/compiled/style-loader/runtime/isEqualLocals.js +28 -0
- package/compiled/style-loader/runtime/isOldIE.js +17 -0
- package/compiled/style-loader/runtime/setAttributesWithAttributes.js +13 -0
- package/compiled/style-loader/runtime/setAttributesWithAttributesAndNonce.js +9 -0
- package/compiled/style-loader/runtime/setAttributesWithoutAttributes.js +10 -0
- package/compiled/style-loader/runtime/singletonStyleDomAPI.js +86 -0
- package/compiled/style-loader/runtime/styleDomAPI.js +61 -0
- package/compiled/style-loader/runtime/styleTagTransform.js +14 -0
- package/compiled/webpack-bundle-analyzer/index.d.ts +1 -0
- package/compiled/webpack-bundle-analyzer/index.js +13276 -0
- package/compiled/webpack-bundle-analyzer/license +20 -0
- package/compiled/webpack-bundle-analyzer/package.json +1 -0
- package/compiled/webpack-bundle-analyzer/public/viewer.js +16 -0
- package/compiled/webpack-bundle-analyzer/public/viewer.js.LICENSE.txt +10 -0
- package/compiled/webpack-merge/index.d.ts +31 -0
- package/compiled/webpack-merge/index.js +1200 -0
- package/compiled/webpack-merge/license +20 -0
- package/compiled/webpack-merge/package.json +1 -0
- package/dist/bundleRequire.cjs +200 -0
- package/dist/bundleRequire.d.ts +5 -0
- package/dist/bundleRequire.d.ts.map +1 -0
- package/dist/bundleRequire.js +173 -0
- package/dist/bundler-config/chunkSplit.cjs +151 -0
- package/dist/bundler-config/chunkSplit.d.ts +6 -0
- package/dist/bundler-config/chunkSplit.d.ts.map +1 -0
- package/dist/bundler-config/chunkSplit.js +127 -0
- package/dist/bundler-config/css.cjs +168 -0
- package/dist/bundler-config/css.d.ts +6 -0
- package/dist/bundler-config/css.d.ts.map +1 -0
- package/dist/bundler-config/css.js +158 -0
- package/dist/bundler-config/experimentCss.cjs +167 -0
- package/dist/bundler-config/experimentCss.d.ts +6 -0
- package/dist/bundler-config/experimentCss.d.ts.map +1 -0
- package/dist/bundler-config/experimentCss.js +157 -0
- package/dist/bundler-config/helper.cjs +81 -0
- package/dist/bundler-config/helper.d.ts +8 -0
- package/dist/bundler-config/helper.d.ts.map +1 -0
- package/dist/bundler-config/helper.js +56 -0
- package/dist/bundler-config/index.cjs +206 -0
- package/dist/bundler-config/index.d.ts +3 -0
- package/dist/bundler-config/index.d.ts.map +1 -0
- package/dist/bundler-config/index.js +190 -0
- package/dist/colors.cjs +60 -0
- package/dist/colors.d.ts +6 -0
- package/dist/colors.d.ts.map +1 -0
- package/dist/colors.js +40 -0
- package/dist/{config/index.cjs → config.cjs} +26 -20
- package/dist/{config/index.d.ts → config.d.ts} +4 -3
- package/dist/config.d.ts.map +1 -0
- package/dist/{config/index.js → config.js} +19 -21
- package/dist/constants.cjs +86 -0
- package/dist/constants.d.ts +25 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +61 -0
- package/dist/createService.cjs +65 -0
- package/dist/createService.d.ts +8 -0
- package/dist/createService.d.ts.map +1 -0
- package/dist/createService.js +41 -0
- package/dist/index.cjs +27 -48
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -51
- package/dist/lightningcss/cache.cjs +36 -0
- package/dist/lightningcss/cache.d.ts +2 -0
- package/dist/lightningcss/cache.d.ts.map +1 -0
- package/dist/lightningcss/cache.js +22 -0
- package/dist/lightningcss/index.cjs +21 -0
- package/dist/lightningcss/index.d.ts +2 -0
- package/dist/lightningcss/index.d.ts.map +1 -0
- package/dist/lightningcss/index.js +10 -0
- package/dist/lightningcss/loader.cjs +56 -0
- package/dist/lightningcss/loader.d.ts +5 -0
- package/dist/lightningcss/loader.d.ts.map +1 -0
- package/dist/lightningcss/loader.js +36 -0
- package/dist/lightningcss/minimizer.cjs +114 -0
- package/dist/lightningcss/minimizer.d.ts +11 -0
- package/dist/lightningcss/minimizer.d.ts.map +1 -0
- package/dist/lightningcss/minimizer.js +90 -0
- package/dist/logger.cjs +103 -0
- package/dist/logger.d.ts +3 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +79 -0
- package/dist/openBrowser.cjs +85 -0
- package/dist/openBrowser.d.ts +2 -0
- package/dist/openBrowser.d.ts.map +1 -0
- package/dist/openBrowser.js +61 -0
- package/dist/plugin-progress/rspack.cjs +74 -0
- package/dist/plugin-progress/rspack.d.ts +9 -0
- package/dist/plugin-progress/rspack.d.ts.map +1 -0
- package/dist/plugin-progress/rspack.js +50 -0
- package/dist/plugin-progress/webpack.cjs +84 -0
- package/dist/plugin-progress/webpack.d.ts +9 -0
- package/dist/plugin-progress/webpack.d.ts.map +1 -0
- package/dist/plugin-progress/webpack.js +60 -0
- package/dist/plugin.cjs +33 -0
- package/dist/plugin.d.ts +3 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +19 -0
- package/dist/progressBar.cjs +70 -0
- package/dist/progressBar.d.ts +14 -0
- package/dist/progressBar.d.ts.map +1 -0
- package/dist/progressBar.js +46 -0
- package/dist/reporter.cjs +133 -0
- package/dist/reporter.d.ts +8 -0
- package/dist/reporter.d.ts.map +1 -0
- package/dist/reporter.js +109 -0
- package/dist/run/build.cjs +77 -0
- package/dist/run/build.d.ts +3 -0
- package/dist/run/build.d.ts.map +1 -0
- package/dist/run/build.js +53 -0
- package/dist/run/dev.cjs +107 -0
- package/dist/run/dev.d.ts +3 -0
- package/dist/run/dev.d.ts.map +1 -0
- package/dist/run/dev.js +83 -0
- package/dist/run/index.cjs +23 -0
- package/dist/run/index.d.ts +3 -0
- package/dist/run/index.d.ts.map +1 -0
- package/dist/run/index.js +11 -0
- package/dist/thread-loader/WorkerError.cjs +41 -0
- package/dist/thread-loader/WorkerError.js +31 -0
- package/dist/thread-loader/WorkerPool.cjs +407 -0
- package/dist/thread-loader/WorkerPool.js +387 -0
- package/dist/thread-loader/index.cjs +100 -0
- package/dist/thread-loader/index.js +85 -0
- package/dist/thread-loader/readBuffer.cjs +55 -0
- package/dist/thread-loader/readBuffer.js +45 -0
- package/dist/thread-loader/serializer.cjs +46 -0
- package/dist/thread-loader/serializer.js +31 -0
- package/dist/thread-loader/utils.cjs +84 -0
- package/dist/thread-loader/utils.js +60 -0
- package/dist/thread-loader/worker.cjs +377 -0
- package/dist/thread-loader/worker.js +382 -0
- package/dist/thread-loader/workerPools.cjs +57 -0
- package/dist/thread-loader/workerPools.js +33 -0
- package/dist/typed-css-modules/index.cjs +21 -0
- package/dist/typed-css-modules/index.d.ts +2 -0
- package/dist/typed-css-modules/index.d.ts.map +1 -0
- package/dist/typed-css-modules/index.js +10 -0
- package/dist/typed-css-modules/loader.cjs +195 -0
- package/dist/typed-css-modules/loader.d.ts +10 -0
- package/dist/typed-css-modules/loader.d.ts.map +1 -0
- package/dist/typed-css-modules/loader.js +170 -0
- package/dist/typed-css-modules/plugin.cjs +96 -0
- package/dist/typed-css-modules/plugin.d.ts +16 -0
- package/dist/typed-css-modules/plugin.d.ts.map +1 -0
- package/dist/typed-css-modules/plugin.js +72 -0
- package/dist/typed-css-modules/utils.cjs +45 -0
- package/dist/typed-css-modules/utils.d.ts +6 -0
- package/dist/typed-css-modules/utils.d.ts.map +1 -0
- package/dist/typed-css-modules/utils.js +31 -0
- package/dist/types/chunkSplit.cjs +15 -0
- package/dist/types/chunkSplit.d.ts +35 -0
- package/dist/types/chunkSplit.d.ts.map +1 -0
- package/dist/types/chunkSplit.js +9 -0
- package/dist/types/config.cjs +15 -0
- package/dist/types/config.d.ts +176 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +9 -0
- package/dist/types/index.cjs +29 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +14 -0
- package/dist/types/lightningcss.cjs +15 -0
- package/dist/types/lightningcss.d.ts +11 -0
- package/dist/types/lightningcss.d.ts.map +1 -0
- package/dist/types/lightningcss.js +9 -0
- package/dist/types/logger.cjs +35 -0
- package/dist/types/logger.d.ts +16 -0
- package/dist/types/logger.d.ts.map +1 -0
- package/dist/types/logger.js +21 -0
- package/dist/types/plugin.cjs +15 -0
- package/dist/types/plugin.d.ts +18 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/plugin.js +9 -0
- package/dist/utils.cjs +293 -0
- package/dist/utils.d.ts +39 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +242 -0
- package/package.json +95 -6
- package/dist/config/index.d.ts.map +0 -1
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var loader_exports = {};
|
|
29
|
+
__export(loader_exports, {
|
|
30
|
+
default: () => loader_default,
|
|
31
|
+
isInNodeModules: () => isInNodeModules,
|
|
32
|
+
wrapQuotes: () => wrapQuotes
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(loader_exports);
|
|
35
|
+
var import_node_fs = __toESM(require("node:fs"));
|
|
36
|
+
var import_node_path = __toESM(require("node:path"));
|
|
37
|
+
var import_constants = require("../constants.cjs");
|
|
38
|
+
var import_utils = require("./utils.cjs");
|
|
39
|
+
const LineDiff = require("../../compiled/line-diff/index.js");
|
|
40
|
+
const isInNodeModules = (path2) => import_constants.NODE_MODULES_REGEX.test(path2);
|
|
41
|
+
const getNoDeclarationFileError = ({ filename }) => new Error(
|
|
42
|
+
`Generated type declaration does not exist. Run Unpack and commit the type declaration for '${filename}'`
|
|
43
|
+
);
|
|
44
|
+
const getTypeMismatchError = ({
|
|
45
|
+
filename,
|
|
46
|
+
expected,
|
|
47
|
+
actual
|
|
48
|
+
}) => {
|
|
49
|
+
const diff = new LineDiff(enforceLFLineSeparators(actual), expected).toString();
|
|
50
|
+
return new Error(
|
|
51
|
+
`Generated type declaration file is outdated. Run Unpack and commit the updated type declaration for '${filename}'
|
|
52
|
+
|
|
53
|
+
${diff}`
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
function wrapQuotes(key) {
|
|
57
|
+
const isValidIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key);
|
|
58
|
+
if (isValidIdentifier) {
|
|
59
|
+
return key;
|
|
60
|
+
}
|
|
61
|
+
return `'${key}'`;
|
|
62
|
+
}
|
|
63
|
+
const cssModuleToNamedExports = (cssModuleKeys) => {
|
|
64
|
+
return cssModuleKeys.sort().map((key) => `export const ${key}: string;`).join("\n");
|
|
65
|
+
};
|
|
66
|
+
const cssModuleToInterface = (cssModulesKeys) => {
|
|
67
|
+
const interfaceFields = cssModulesKeys.sort().map((key) => ` ${wrapQuotes(key)}: string;`).join("\n");
|
|
68
|
+
return `interface CssExports {
|
|
69
|
+
${interfaceFields}
|
|
70
|
+
}`;
|
|
71
|
+
};
|
|
72
|
+
const filenameToTypingsFilename = (filename) => {
|
|
73
|
+
const dirName = import_node_path.default.dirname(filename);
|
|
74
|
+
const baseName = import_node_path.default.basename(filename);
|
|
75
|
+
return import_node_path.default.join(dirName, `${baseName}.d.ts`);
|
|
76
|
+
};
|
|
77
|
+
const enforceLFLineSeparators = (text) => {
|
|
78
|
+
if (text) {
|
|
79
|
+
return text.replace(/\r\n/g, "\n");
|
|
80
|
+
}
|
|
81
|
+
return text;
|
|
82
|
+
};
|
|
83
|
+
const compareText = (contentA, contentB) => {
|
|
84
|
+
return enforceLFLineSeparators(contentA) === enforceLFLineSeparators(contentB);
|
|
85
|
+
};
|
|
86
|
+
const validModes = ["emit", "verify"];
|
|
87
|
+
const isFileNotFound = (err) => err && err.code === "ENOENT";
|
|
88
|
+
const makeDoneHandlers = (callback, content, rest) => ({
|
|
89
|
+
failed: (e) => callback(e),
|
|
90
|
+
success: () => callback(null, content, ...rest)
|
|
91
|
+
});
|
|
92
|
+
const makeFileHandlers = (filename) => ({
|
|
93
|
+
read: (handler) => import_node_fs.default.readFile(filename, { encoding: "utf-8" }, handler),
|
|
94
|
+
write: (content, handler) => import_node_fs.default.writeFile(filename, content, { encoding: "utf-8" }, handler)
|
|
95
|
+
});
|
|
96
|
+
const extractLocalExports = (content) => {
|
|
97
|
+
let localExports = content.split("exports.locals")[1];
|
|
98
|
+
if (!localExports) {
|
|
99
|
+
localExports = content.split("___CSS_LOADER_EXPORT___.locals")[1];
|
|
100
|
+
}
|
|
101
|
+
return localExports;
|
|
102
|
+
};
|
|
103
|
+
const getCSSModulesKeys = (content, namedExport) => {
|
|
104
|
+
const keys = /* @__PURE__ */ new Set();
|
|
105
|
+
if (namedExport) {
|
|
106
|
+
const exportsRegex = /export\s+var\s+(\w+)\s*=/g;
|
|
107
|
+
let match2 = exportsRegex.exec(content);
|
|
108
|
+
while (match2 !== null) {
|
|
109
|
+
keys.add(match2[1]);
|
|
110
|
+
match2 = exportsRegex.exec(content);
|
|
111
|
+
}
|
|
112
|
+
return Array.from(keys);
|
|
113
|
+
}
|
|
114
|
+
const localExports = extractLocalExports(content);
|
|
115
|
+
const keyRegex = /"([^\\"]+)":/g;
|
|
116
|
+
let match = keyRegex.exec(localExports);
|
|
117
|
+
while (match !== null) {
|
|
118
|
+
keys.add(match[1]);
|
|
119
|
+
match = keyRegex.exec(localExports);
|
|
120
|
+
}
|
|
121
|
+
return Array.from(keys);
|
|
122
|
+
};
|
|
123
|
+
function codegen(keys, namedExport) {
|
|
124
|
+
const bannerMessage = "// Generated automatically, do not edit";
|
|
125
|
+
if (namedExport) {
|
|
126
|
+
return `${bannerMessage}
|
|
127
|
+
${cssModuleToNamedExports(keys)}
|
|
128
|
+
`;
|
|
129
|
+
}
|
|
130
|
+
const cssModuleExport = "declare const cssExports: CssExports;\nexport default cssExports;\n";
|
|
131
|
+
return `${bannerMessage}
|
|
132
|
+
${cssModuleToInterface(keys)}
|
|
133
|
+
${cssModuleExport}`;
|
|
134
|
+
}
|
|
135
|
+
function loader_default(content, ...rest) {
|
|
136
|
+
const { failed, success } = makeDoneHandlers(this.async(), content, rest);
|
|
137
|
+
const { resourcePath } = this;
|
|
138
|
+
const { mode = "emit", modules } = this.getOptions() || {};
|
|
139
|
+
if (!validModes.includes(mode)) {
|
|
140
|
+
failed(new Error(`Invalid mode option: ${mode}`));
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (!(0, import_utils.isCSSModules)({ resourcePath, modules }) || isInNodeModules(resourcePath)) {
|
|
144
|
+
success();
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const cssModuleInterfaceFilename = filenameToTypingsFilename(resourcePath);
|
|
148
|
+
const { read, write } = makeFileHandlers(cssModuleInterfaceFilename);
|
|
149
|
+
const namedExport = import_constants.CSS_NAMED_EXPORT;
|
|
150
|
+
const cssModulesKeys = getCSSModulesKeys(content, namedExport);
|
|
151
|
+
const cssModulesCode = codegen(cssModulesKeys, namedExport);
|
|
152
|
+
if (mode === "verify") {
|
|
153
|
+
read((err, fileContents) => {
|
|
154
|
+
if (isFileNotFound(err)) {
|
|
155
|
+
return failed(
|
|
156
|
+
getNoDeclarationFileError({
|
|
157
|
+
filename: cssModuleInterfaceFilename
|
|
158
|
+
})
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
if (err) {
|
|
162
|
+
return failed(err);
|
|
163
|
+
}
|
|
164
|
+
if (!compareText(cssModulesCode, fileContents)) {
|
|
165
|
+
return failed(
|
|
166
|
+
getTypeMismatchError({
|
|
167
|
+
filename: cssModuleInterfaceFilename,
|
|
168
|
+
expected: cssModulesCode,
|
|
169
|
+
actual: fileContents
|
|
170
|
+
})
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
return success();
|
|
174
|
+
});
|
|
175
|
+
} else {
|
|
176
|
+
read((_, fileContents) => {
|
|
177
|
+
if (!compareText(cssModulesCode, fileContents)) {
|
|
178
|
+
write(cssModulesCode, (err) => {
|
|
179
|
+
if (err) {
|
|
180
|
+
failed(err);
|
|
181
|
+
} else {
|
|
182
|
+
success();
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
} else {
|
|
186
|
+
success();
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
192
|
+
0 && (module.exports = {
|
|
193
|
+
isInNodeModules,
|
|
194
|
+
wrapQuotes
|
|
195
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type * as Rspack from '@rspack/core';
|
|
2
|
+
import type { UnpackConfig } from '../types/index';
|
|
3
|
+
export type CssLoaderModules = UnpackConfig['css']['modules'];
|
|
4
|
+
export declare const isInNodeModules: (path: string) => boolean;
|
|
5
|
+
export declare function wrapQuotes(key: string): string;
|
|
6
|
+
export default function (this: Rspack.LoaderContext<{
|
|
7
|
+
mode: string;
|
|
8
|
+
modules: CssLoaderModules;
|
|
9
|
+
}>, content: string, ...rest: any[]): void;
|
|
10
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/typed-css-modules/loader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,MAAM,cAAc,CAAA;AAG3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAGnD,MAAM,MAAM,gBAAgB,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAA;AAC7D,eAAO,MAAM,eAAe,SAAU,MAAM,YAAkC,CAAA;AAuB9E,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQ9C;AAmGD,MAAM,CAAC,OAAO,WACZ,IAAI,EAAE,MAAM,CAAC,aAAa,CAAC;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,gBAAgB,CAAA;CAC1B,CAAC,EACF,OAAO,EAAE,MAAM,EACf,GAAG,IAAI,EAAE,GAAG,EAAE,GACb,IAAI,CAgEN"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
var require = createRequire(import.meta['url']);
|
|
3
|
+
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
var getFilename = () => fileURLToPath(import.meta.url);
|
|
7
|
+
var getDirname = () => path.dirname(getFilename());
|
|
8
|
+
var __dirname = /* @__PURE__ */ getDirname();
|
|
9
|
+
var __filename = /* @__PURE__ */ getFilename();
|
|
10
|
+
import fs from "node:fs";
|
|
11
|
+
import path2 from "node:path";
|
|
12
|
+
const LineDiff = require("../../compiled/line-diff/index.js");
|
|
13
|
+
import { CSS_NAMED_EXPORT, NODE_MODULES_REGEX } from "../constants.js";
|
|
14
|
+
import { isCSSModules } from "./utils.js";
|
|
15
|
+
const isInNodeModules = (path3) => NODE_MODULES_REGEX.test(path3);
|
|
16
|
+
const getNoDeclarationFileError = ({ filename }) => new Error(
|
|
17
|
+
`Generated type declaration does not exist. Run Unpack and commit the type declaration for '${filename}'`
|
|
18
|
+
);
|
|
19
|
+
const getTypeMismatchError = ({
|
|
20
|
+
filename,
|
|
21
|
+
expected,
|
|
22
|
+
actual
|
|
23
|
+
}) => {
|
|
24
|
+
const diff = new LineDiff(enforceLFLineSeparators(actual), expected).toString();
|
|
25
|
+
return new Error(
|
|
26
|
+
`Generated type declaration file is outdated. Run Unpack and commit the updated type declaration for '${filename}'
|
|
27
|
+
|
|
28
|
+
${diff}`
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
function wrapQuotes(key) {
|
|
32
|
+
const isValidIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key);
|
|
33
|
+
if (isValidIdentifier) {
|
|
34
|
+
return key;
|
|
35
|
+
}
|
|
36
|
+
return `'${key}'`;
|
|
37
|
+
}
|
|
38
|
+
const cssModuleToNamedExports = (cssModuleKeys) => {
|
|
39
|
+
return cssModuleKeys.sort().map((key) => `export const ${key}: string;`).join("\n");
|
|
40
|
+
};
|
|
41
|
+
const cssModuleToInterface = (cssModulesKeys) => {
|
|
42
|
+
const interfaceFields = cssModulesKeys.sort().map((key) => ` ${wrapQuotes(key)}: string;`).join("\n");
|
|
43
|
+
return `interface CssExports {
|
|
44
|
+
${interfaceFields}
|
|
45
|
+
}`;
|
|
46
|
+
};
|
|
47
|
+
const filenameToTypingsFilename = (filename) => {
|
|
48
|
+
const dirName = path2.dirname(filename);
|
|
49
|
+
const baseName = path2.basename(filename);
|
|
50
|
+
return path2.join(dirName, `${baseName}.d.ts`);
|
|
51
|
+
};
|
|
52
|
+
const enforceLFLineSeparators = (text) => {
|
|
53
|
+
if (text) {
|
|
54
|
+
return text.replace(/\r\n/g, "\n");
|
|
55
|
+
}
|
|
56
|
+
return text;
|
|
57
|
+
};
|
|
58
|
+
const compareText = (contentA, contentB) => {
|
|
59
|
+
return enforceLFLineSeparators(contentA) === enforceLFLineSeparators(contentB);
|
|
60
|
+
};
|
|
61
|
+
const validModes = ["emit", "verify"];
|
|
62
|
+
const isFileNotFound = (err) => err && err.code === "ENOENT";
|
|
63
|
+
const makeDoneHandlers = (callback, content, rest) => ({
|
|
64
|
+
failed: (e) => callback(e),
|
|
65
|
+
success: () => callback(null, content, ...rest)
|
|
66
|
+
});
|
|
67
|
+
const makeFileHandlers = (filename) => ({
|
|
68
|
+
read: (handler) => fs.readFile(filename, { encoding: "utf-8" }, handler),
|
|
69
|
+
write: (content, handler) => fs.writeFile(filename, content, { encoding: "utf-8" }, handler)
|
|
70
|
+
});
|
|
71
|
+
const extractLocalExports = (content) => {
|
|
72
|
+
let localExports = content.split("exports.locals")[1];
|
|
73
|
+
if (!localExports) {
|
|
74
|
+
localExports = content.split("___CSS_LOADER_EXPORT___.locals")[1];
|
|
75
|
+
}
|
|
76
|
+
return localExports;
|
|
77
|
+
};
|
|
78
|
+
const getCSSModulesKeys = (content, namedExport) => {
|
|
79
|
+
const keys = /* @__PURE__ */ new Set();
|
|
80
|
+
if (namedExport) {
|
|
81
|
+
const exportsRegex = /export\s+var\s+(\w+)\s*=/g;
|
|
82
|
+
let match2 = exportsRegex.exec(content);
|
|
83
|
+
while (match2 !== null) {
|
|
84
|
+
keys.add(match2[1]);
|
|
85
|
+
match2 = exportsRegex.exec(content);
|
|
86
|
+
}
|
|
87
|
+
return Array.from(keys);
|
|
88
|
+
}
|
|
89
|
+
const localExports = extractLocalExports(content);
|
|
90
|
+
const keyRegex = /"([^\\"]+)":/g;
|
|
91
|
+
let match = keyRegex.exec(localExports);
|
|
92
|
+
while (match !== null) {
|
|
93
|
+
keys.add(match[1]);
|
|
94
|
+
match = keyRegex.exec(localExports);
|
|
95
|
+
}
|
|
96
|
+
return Array.from(keys);
|
|
97
|
+
};
|
|
98
|
+
function codegen(keys, namedExport) {
|
|
99
|
+
const bannerMessage = "// Generated automatically, do not edit";
|
|
100
|
+
if (namedExport) {
|
|
101
|
+
return `${bannerMessage}
|
|
102
|
+
${cssModuleToNamedExports(keys)}
|
|
103
|
+
`;
|
|
104
|
+
}
|
|
105
|
+
const cssModuleExport = "declare const cssExports: CssExports;\nexport default cssExports;\n";
|
|
106
|
+
return `${bannerMessage}
|
|
107
|
+
${cssModuleToInterface(keys)}
|
|
108
|
+
${cssModuleExport}`;
|
|
109
|
+
}
|
|
110
|
+
function loader_default(content, ...rest) {
|
|
111
|
+
const { failed, success } = makeDoneHandlers(this.async(), content, rest);
|
|
112
|
+
const { resourcePath } = this;
|
|
113
|
+
const { mode = "emit", modules } = this.getOptions() || {};
|
|
114
|
+
if (!validModes.includes(mode)) {
|
|
115
|
+
failed(new Error(`Invalid mode option: ${mode}`));
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (!isCSSModules({ resourcePath, modules }) || isInNodeModules(resourcePath)) {
|
|
119
|
+
success();
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const cssModuleInterfaceFilename = filenameToTypingsFilename(resourcePath);
|
|
123
|
+
const { read, write } = makeFileHandlers(cssModuleInterfaceFilename);
|
|
124
|
+
const namedExport = CSS_NAMED_EXPORT;
|
|
125
|
+
const cssModulesKeys = getCSSModulesKeys(content, namedExport);
|
|
126
|
+
const cssModulesCode = codegen(cssModulesKeys, namedExport);
|
|
127
|
+
if (mode === "verify") {
|
|
128
|
+
read((err, fileContents) => {
|
|
129
|
+
if (isFileNotFound(err)) {
|
|
130
|
+
return failed(
|
|
131
|
+
getNoDeclarationFileError({
|
|
132
|
+
filename: cssModuleInterfaceFilename
|
|
133
|
+
})
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
if (err) {
|
|
137
|
+
return failed(err);
|
|
138
|
+
}
|
|
139
|
+
if (!compareText(cssModulesCode, fileContents)) {
|
|
140
|
+
return failed(
|
|
141
|
+
getTypeMismatchError({
|
|
142
|
+
filename: cssModuleInterfaceFilename,
|
|
143
|
+
expected: cssModulesCode,
|
|
144
|
+
actual: fileContents
|
|
145
|
+
})
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
return success();
|
|
149
|
+
});
|
|
150
|
+
} else {
|
|
151
|
+
read((_, fileContents) => {
|
|
152
|
+
if (!compareText(cssModulesCode, fileContents)) {
|
|
153
|
+
write(cssModulesCode, (err) => {
|
|
154
|
+
if (err) {
|
|
155
|
+
failed(err);
|
|
156
|
+
} else {
|
|
157
|
+
success();
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
} else {
|
|
161
|
+
success();
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
export {
|
|
167
|
+
loader_default as default,
|
|
168
|
+
isInNodeModules,
|
|
169
|
+
wrapQuotes
|
|
170
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var plugin_exports = {};
|
|
29
|
+
__export(plugin_exports, {
|
|
30
|
+
PluginTypedCssModules: () => PluginTypedCssModules
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(plugin_exports);
|
|
33
|
+
var import_node_fs = __toESM(require("node:fs"));
|
|
34
|
+
var import_constants = require("../constants.cjs");
|
|
35
|
+
var import_logger = require("../logger.cjs");
|
|
36
|
+
var import_typed_css_modules = __toESM(require("typed-css-modules"));
|
|
37
|
+
var import_utils = require("./utils.cjs");
|
|
38
|
+
const glob = require("../../compiled/fast-glob/index.js");
|
|
39
|
+
const statPromise = import_node_fs.default.promises.stat;
|
|
40
|
+
async function writeFile(dtsCreator, cssFile) {
|
|
41
|
+
const content = await dtsCreator.create(cssFile, void 0, true);
|
|
42
|
+
await content.writeFile((definition) => {
|
|
43
|
+
return `// Generated automatically, do not edit
|
|
44
|
+
${definition}`;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
async function generateTypingIfNecessary(dtsCreator, cssFile) {
|
|
48
|
+
let typingStat;
|
|
49
|
+
try {
|
|
50
|
+
typingStat = await statPromise(`${cssFile}.d.ts`);
|
|
51
|
+
} catch (_) {
|
|
52
|
+
return writeFile(dtsCreator, cssFile);
|
|
53
|
+
}
|
|
54
|
+
const cssFileStat = await statPromise(cssFile);
|
|
55
|
+
if (cssFileStat.mtime.getTime() > typingStat.mtime.getTime()) {
|
|
56
|
+
return writeFile(dtsCreator, cssFile);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const PLUGIN_NAME = "PluginTypedCssModules";
|
|
60
|
+
class PluginTypedCssModules {
|
|
61
|
+
constructor(options) {
|
|
62
|
+
this.useIncremental = false;
|
|
63
|
+
this.globPattern = "src/**/*.{css,less,scss}";
|
|
64
|
+
this.userOptions = options;
|
|
65
|
+
this.dtsCreator = new import_typed_css_modules.default({
|
|
66
|
+
camelCase: true,
|
|
67
|
+
namedExports: import_constants.CSS_NAMED_EXPORT
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
apply(compiler) {
|
|
71
|
+
compiler.hooks.run.tapPromise(PLUGIN_NAME, async () => {
|
|
72
|
+
await this.generateCssTypings(this.useIncremental);
|
|
73
|
+
});
|
|
74
|
+
compiler.hooks.watchRun.tapPromise(PLUGIN_NAME, async () => {
|
|
75
|
+
try {
|
|
76
|
+
await this.generateCssTypings(this.useIncremental);
|
|
77
|
+
} catch (err) {
|
|
78
|
+
import_logger.logger.error(err.toString());
|
|
79
|
+
} finally {
|
|
80
|
+
this.useIncremental = true;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
async generateCssTypings(incremental) {
|
|
85
|
+
const files = await glob(this.globPattern);
|
|
86
|
+
const cssModulesFiles = files.filter((file) => {
|
|
87
|
+
return (0, import_utils.isCSSModules)({ resourcePath: file, modules: this.userOptions?.modules });
|
|
88
|
+
});
|
|
89
|
+
const doTask = incremental ? generateTypingIfNecessary : writeFile;
|
|
90
|
+
return Promise.all(cssModulesFiles.map((file) => doTask(this.dtsCreator, file)));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
94
|
+
0 && (module.exports = {
|
|
95
|
+
PluginTypedCssModules
|
|
96
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { UnpackConfig } from '../types/index';
|
|
2
|
+
import type { Compiler } from 'webpack';
|
|
3
|
+
type PluginTypedCssModulesOptions = {
|
|
4
|
+
modules?: UnpackConfig['css']['modules'];
|
|
5
|
+
};
|
|
6
|
+
export declare class PluginTypedCssModules {
|
|
7
|
+
private dtsCreator;
|
|
8
|
+
private useIncremental;
|
|
9
|
+
private globPattern;
|
|
10
|
+
userOptions: PluginTypedCssModulesOptions;
|
|
11
|
+
constructor(options: PluginTypedCssModulesOptions);
|
|
12
|
+
apply(compiler: Compiler): void;
|
|
13
|
+
private generateCssTypings;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/typed-css-modules/plugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAEnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AA2BvC,KAAK,4BAA4B,GAAG;IAClC,OAAO,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAA;CACzC,CAAA;AAED,qBAAa,qBAAqB;IAChC,OAAO,CAAC,UAAU,CAAY;IAC9B,OAAO,CAAC,cAAc,CAAQ;IAC9B,OAAO,CAAC,WAAW,CAA6B;IAChD,WAAW,EAAE,4BAA4B,CAAA;gBAE7B,OAAO,EAAE,4BAA4B;IAQjD,KAAK,CAAC,QAAQ,EAAE,QAAQ;YAmBV,kBAAkB;CAQjC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
var require = createRequire(import.meta['url']);
|
|
3
|
+
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
var getFilename = () => fileURLToPath(import.meta.url);
|
|
7
|
+
var getDirname = () => path.dirname(getFilename());
|
|
8
|
+
var __dirname = /* @__PURE__ */ getDirname();
|
|
9
|
+
var __filename = /* @__PURE__ */ getFilename();
|
|
10
|
+
import fs from "node:fs";
|
|
11
|
+
const glob = require("../../compiled/fast-glob/index.js");
|
|
12
|
+
import { CSS_NAMED_EXPORT } from "../constants.js";
|
|
13
|
+
import { logger } from "../logger.js";
|
|
14
|
+
import DtsCreator from "typed-css-modules";
|
|
15
|
+
import { isCSSModules } from "./utils.js";
|
|
16
|
+
const statPromise = fs.promises.stat;
|
|
17
|
+
async function writeFile(dtsCreator, cssFile) {
|
|
18
|
+
const content = await dtsCreator.create(cssFile, void 0, true);
|
|
19
|
+
await content.writeFile((definition) => {
|
|
20
|
+
return `// Generated automatically, do not edit
|
|
21
|
+
${definition}`;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
async function generateTypingIfNecessary(dtsCreator, cssFile) {
|
|
25
|
+
let typingStat;
|
|
26
|
+
try {
|
|
27
|
+
typingStat = await statPromise(`${cssFile}.d.ts`);
|
|
28
|
+
} catch (_) {
|
|
29
|
+
return writeFile(dtsCreator, cssFile);
|
|
30
|
+
}
|
|
31
|
+
const cssFileStat = await statPromise(cssFile);
|
|
32
|
+
if (cssFileStat.mtime.getTime() > typingStat.mtime.getTime()) {
|
|
33
|
+
return writeFile(dtsCreator, cssFile);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const PLUGIN_NAME = "PluginTypedCssModules";
|
|
37
|
+
class PluginTypedCssModules {
|
|
38
|
+
constructor(options) {
|
|
39
|
+
this.useIncremental = false;
|
|
40
|
+
this.globPattern = "src/**/*.{css,less,scss}";
|
|
41
|
+
this.userOptions = options;
|
|
42
|
+
this.dtsCreator = new DtsCreator({
|
|
43
|
+
camelCase: true,
|
|
44
|
+
namedExports: CSS_NAMED_EXPORT
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
apply(compiler) {
|
|
48
|
+
compiler.hooks.run.tapPromise(PLUGIN_NAME, async () => {
|
|
49
|
+
await this.generateCssTypings(this.useIncremental);
|
|
50
|
+
});
|
|
51
|
+
compiler.hooks.watchRun.tapPromise(PLUGIN_NAME, async () => {
|
|
52
|
+
try {
|
|
53
|
+
await this.generateCssTypings(this.useIncremental);
|
|
54
|
+
} catch (err) {
|
|
55
|
+
logger.error(err.toString());
|
|
56
|
+
} finally {
|
|
57
|
+
this.useIncremental = true;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
async generateCssTypings(incremental) {
|
|
62
|
+
const files = await glob(this.globPattern);
|
|
63
|
+
const cssModulesFiles = files.filter((file) => {
|
|
64
|
+
return isCSSModules({ resourcePath: file, modules: this.userOptions?.modules });
|
|
65
|
+
});
|
|
66
|
+
const doTask = incremental ? generateTypingIfNecessary : writeFile;
|
|
67
|
+
return Promise.all(cssModulesFiles.map((file) => doTask(this.dtsCreator, file)));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export {
|
|
71
|
+
PluginTypedCssModules
|
|
72
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var utils_exports = {};
|
|
19
|
+
__export(utils_exports, {
|
|
20
|
+
isCSSModules: () => isCSSModules
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(utils_exports);
|
|
23
|
+
var import_constants = require("../constants.cjs");
|
|
24
|
+
var import_utils = require("../utils.cjs");
|
|
25
|
+
const isCSSModules = ({
|
|
26
|
+
resourcePath,
|
|
27
|
+
modules
|
|
28
|
+
}) => {
|
|
29
|
+
if (modules === false)
|
|
30
|
+
return false;
|
|
31
|
+
if (!(0, import_utils.isPlainObject)(modules))
|
|
32
|
+
modules = {};
|
|
33
|
+
const auto = modules.auto;
|
|
34
|
+
if (auto === false)
|
|
35
|
+
return false;
|
|
36
|
+
if ((0, import_utils.isRegExp)(auto))
|
|
37
|
+
return auto.test(resourcePath);
|
|
38
|
+
if ((0, import_utils.isFunction)(auto))
|
|
39
|
+
return auto(resourcePath);
|
|
40
|
+
return import_constants.CSS_MODULES_REGEX.test(resourcePath);
|
|
41
|
+
};
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
isCSSModules
|
|
45
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/typed-css-modules/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAGnD,eAAO,MAAM,YAAY,+BAGtB;IACD,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAA;CACxC,KAAG,OAQH,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
var require = createRequire(import.meta['url']);
|
|
3
|
+
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
var getFilename = () => fileURLToPath(import.meta.url);
|
|
7
|
+
var getDirname = () => path.dirname(getFilename());
|
|
8
|
+
var __dirname = /* @__PURE__ */ getDirname();
|
|
9
|
+
var __filename = /* @__PURE__ */ getFilename();
|
|
10
|
+
import { CSS_MODULES_REGEX } from "../constants.js";
|
|
11
|
+
import { isFunction, isPlainObject, isRegExp } from "../utils.js";
|
|
12
|
+
const isCSSModules = ({
|
|
13
|
+
resourcePath,
|
|
14
|
+
modules
|
|
15
|
+
}) => {
|
|
16
|
+
if (modules === false)
|
|
17
|
+
return false;
|
|
18
|
+
if (!isPlainObject(modules))
|
|
19
|
+
modules = {};
|
|
20
|
+
const auto = modules.auto;
|
|
21
|
+
if (auto === false)
|
|
22
|
+
return false;
|
|
23
|
+
if (isRegExp(auto))
|
|
24
|
+
return auto.test(resourcePath);
|
|
25
|
+
if (isFunction(auto))
|
|
26
|
+
return auto(resourcePath);
|
|
27
|
+
return CSS_MODULES_REGEX.test(resourcePath);
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
isCSSModules
|
|
31
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var chunkSplit_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(chunkSplit_exports);
|