main repo

This commit is contained in:
Basilosaurusrex
2025-11-24 18:09:40 +01:00
parent b636ee5e70
commit f027651f9b
34146 changed files with 4436636 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
/**
* A webpack loader that resolves absolute url() paths relative to their original source file.
* Requires source-maps to do any meaningful work.
*/
export default function resolveUrlLoader(this: any,
/** Css content */
content: string,
/** The source-map */
sourceMap: any): Promise<void>;

View File

@@ -0,0 +1,98 @@
/*
The MIT License (MIT)
Copyright (c) 2016 Ben Holloway
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, /**
* A webpack loader that resolves absolute url() paths relative to their original source file.
* Requires source-maps to do any meaningful work.
*/ "default", {
enumerable: true,
get: function() {
return resolveUrlLoader;
}
});
const _sourcemap = require("next/dist/compiled/source-map");
const _valueprocessor = /*#__PURE__*/ _interop_require_default(require("./lib/value-processor"));
const _joinfunction = require("./lib/join-function");
const _postcss = /*#__PURE__*/ _interop_require_default(require("./lib/postcss"));
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
async function resolveUrlLoader(/** Css content */ content, /** The source-map */ sourceMap) {
const options = Object.assign({
sourceMap: this.sourceMap,
silent: false,
absolute: false,
keepQuery: false,
root: false,
debug: false,
join: _joinfunction.defaultJoin
}, this.getOptions());
let sourceMapConsumer;
if (sourceMap) {
sourceMapConsumer = new _sourcemap.SourceMapConsumer(sourceMap);
}
const callback = this.async();
const { postcss } = await options.postcss();
(0, _postcss.default)(postcss, this.resourcePath, content, {
outputSourceMap: Boolean(options.sourceMap),
transformDeclaration: (0, _valueprocessor.default)(this.resourcePath, options),
inputSourceMap: sourceMap,
sourceMapConsumer: sourceMapConsumer
})// eslint-disable-next-line @typescript-eslint/no-use-before-define
.catch(onFailure)// eslint-disable-next-line @typescript-eslint/no-use-before-define
.then(onSuccess);
function onFailure(error) {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
callback(encodeError("CSS error", error));
}
function onSuccess(reworked) {
if (reworked) {
// complete with source-map
// source-map sources are relative to the file being processed
if (options.sourceMap) {
callback(null, reworked.content, reworked.map);
} else {
callback(null, reworked.content);
}
}
}
function encodeError(label, exception) {
return new Error([
"resolve-url-loader",
": ",
[
label
].concat(typeof exception === "string" && exception || exception instanceof Error && [
exception.message,
exception.stack.split("\n")[1].trim()
] || []).filter(Boolean).join("\n ")
].join(""));
}
}
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/build/webpack/loaders/resolve-url-loader/index.ts"],"names":["resolveUrlLoader","content","sourceMap","options","Object","assign","silent","absolute","keepQuery","root","debug","join","defaultJoin","getOptions","sourceMapConsumer","SourceMapConsumer","callback","async","postcss","process","resourcePath","outputSourceMap","Boolean","transformDeclaration","valueProcessor","inputSourceMap","catch","onFailure","then","onSuccess","error","encodeError","reworked","map","label","exception","Error","concat","message","stack","split","trim","filter"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;AAsBA;;;;+BAMA;;;CAGC,GACD;;;eAA8BA;;;2BARI;uE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AkBI,KAAK,CAACC,KAAK,CAAC,KAAK,CAAC,EAAE,CAACC,IAAI;aAC7C,IACD,EAAE,EAELC,MAAM,CAACpB,SACPX,IAAI,CAAC;SACT,CAACA,IAAI,CAAC;IAEX;AACF"}

View File

@@ -0,0 +1,8 @@
/**
* Prepend file:// protocol to source path string or source-map sources.
*/
export declare function prepend(candidate: any): any;
/**
* Remove file:// protocol from source path string or source-map sources.
*/
export declare function remove(candidate: any): any;

View File

@@ -0,0 +1,70 @@
/*
The MIT License (MIT)
Copyright (c) 2016 Ben Holloway
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/ /**
* Prepend file:// protocol to source path string or source-map sources.
*/ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
prepend: null,
remove: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
prepend: function() {
return prepend;
},
remove: function() {
return remove;
}
});
function prepend(candidate) {
if (typeof candidate === "string") {
return "file://" + candidate;
} else if (candidate && typeof candidate === "object" && Array.isArray(candidate.sources)) {
return Object.assign({}, candidate, {
sources: candidate.sources.map(prepend)
});
} else {
throw new Error("expected string|object");
}
}
function remove(candidate) {
if (typeof candidate === "string") {
return candidate.replace(/^file:\/{2}/, "");
} else if (candidate && typeof candidate === "object" && Array.isArray(candidate.sources)) {
return Object.assign({}, candidate, {
sources: candidate.sources.map(remove)
});
} else {
throw new Error("expected string|object");
}
}
//# sourceMappingURL=file-protocol.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/build/webpack/loaders/resolve-url-loader/lib/file-protocol.ts"],"names":["prepend","remove","candidate","Array","isArray","sources","Object","assign","map","Error","replace"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;AAsBA,GAEA;;CAEC;;;;;;;;;;;;;;;IACeA,OAAO;eAAPA;;IAmBAC,MAAM;eAANA;;;AAnBT,SAASD,QAAQE,SAAc;IACpC,IAAI,OAAOA,cAAc,UAAU;QACjC,OAAO,YAAYA;IACrB,OAAO,IACLA,aACA,OAAOA,cAAc,YACrBC,MAAMC,OAAO,CAACF,UAAUG,OAAO,GAC/B;QACA,OAAOC,OAAOC,MAAM,CAAC,CAAC,GAAGL,WAAW;YAClCG,SAASH,UAAUG,OAAO,CAACG,GAAG,CAACR;QACjC;IACF,OAAO;QACL,MAAM,IAAIS,MAAM;IAClB;AACF;AAKO,SAASR,OAAOC,SAAc;IACnC,IAAI,OAAOA,cAAc,UAAU;QACjC,OAAOA,UAAUQ,OAAO,CAAC,eAAe;IAC1C,OAAO,IACLR,aACA,OAAOA,cAAc,YACrBC,MAAMC,OAAO,CAACF,UAAUG,OAAO,GAC/B;QACA,OAAOC,OAAOC,MAAM,CAAC,CAAC,GAAGL,WAAW;YAClCG,SAASH,UAAUG,OAAO,CAACG,GAAG,CAACP;QACjC;IACF,OAAO;QACL,MAAM,IAAIQ,MAAM;IAClB;AACF"}

View File

@@ -0,0 +1,14 @@
/**
* The default join function iterates over possible base paths until a suitable join is found.
*
* The first base path is used as fallback for the case where none of the base paths can locate the actual file.
*
* @type {function}
*/
export declare const defaultJoin: ((filename: string, options: {
debug?: any | boolean;
root: string;
}) => (uri: string, baseOrIteratorOrAbsent: any) => any) & ("" | {
valueOf: () => string;
toString: () => string;
});

View File

@@ -0,0 +1,186 @@
// TODO: Remove use of `any` type. Fix no-use-before-define violations.
/* eslint-disable @typescript-eslint/no-use-before-define */ /*
The MIT License (MIT)
Copyright (c) 2016 Ben Holloway
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "defaultJoin", {
enumerable: true,
get: function() {
return defaultJoin;
}
});
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const compose = (f, g)=>(...args)=>f(g(...args));
const simpleJoin = compose(_path.default.normalize, _path.default.join);
const defaultJoin = createJoinForPredicate(function predicate(_, uri, base, i, next) {
const absolute = simpleJoin(base, uri);
return _fs.default.existsSync(absolute) ? absolute : next(i === 0 ? absolute : null);
}, "defaultJoin");
function* createIterator(arr) {
for (const i of arr){
yield i;
}
}
/**
* Define a join function by a predicate that tests possible base paths from an iterator.
*
* The `predicate` is of the form:
*
* ```
* function(filename, uri, base, i, next):string|null
* ```
*
* Given the uri and base it should either return:
* - an absolute path success
* - a call to `next(null)` as failure
* - a call to `next(absolute)` where absolute is placeholder and the iterator continues
*
* The value given to `next(...)` is only used if success does not eventually occur.
*
* The `file` value is typically unused but useful if you would like to differentiate behaviour.
*
* You can write a much simpler function than this if you have specific requirements.
*
*/ function createJoinForPredicate(/** predicate A function that tests values */ predicate, /** Optional name for the resulting join function */ name) {
/**
* A factory for a join function with logging.
*/ function join(/** The current file being processed */ filename, /** An options hash */ options) {
const log = createDebugLogger(options.debug);
/**
* Join function proper.
*
* For absolute uri only `uri` will be provided. In this case we substitute any `root` given in options.
*
* Returns Just the uri where base is empty or the uri appended to the base
*/ return function joinProper(/** A uri path, relative or absolute */ uri, /** Optional absolute base path or iterator thereof */ baseOrIteratorOrAbsent) {
const iterator = typeof baseOrIteratorOrAbsent === "undefined" && createIterator([
options.root
]) || typeof baseOrIteratorOrAbsent === "string" && createIterator([
baseOrIteratorOrAbsent
]) || baseOrIteratorOrAbsent;
const result = runIterator([]);
log(createJoinMsg, [
filename,
uri,
result,
result.isFound
]);
return typeof result.absolute === "string" ? result.absolute : uri;
function runIterator(accumulator) {
const nextItem = iterator.next();
var base = !nextItem.done && nextItem.value;
if (typeof base === "string") {
const element = predicate(filename, uri, base, accumulator.length, next);
if (typeof element === "string" && _path.default.isAbsolute(element)) {
return Object.assign(accumulator.concat(base), {
isFound: true,
absolute: element
});
} else if (Array.isArray(element)) {
return element;
} else {
throw new Error("predicate must return an absolute path or the result of calling next()");
}
} else {
return accumulator;
}
function next(fallback) {
return runIterator(Object.assign(accumulator.concat(base), typeof fallback === "string" && {
absolute: fallback
}));
}
}
};
}
function toString() {
return "[Function: " + name + "]";
}
return Object.assign(join, name && {
valueOf: toString,
toString: toString
});
}
/**
* Format a debug message.
* Return Formatted message
*/ function createJoinMsg(/** The file being processed by webpack */ file, /** A uri path, relative or absolute */ uri, /** Absolute base paths up to and including the found one */ bases, /** Indicates the last base was correct */ isFound) {
return [
"resolve-url-loader: " + pathToString(file) + ": " + uri,
//
...bases.map(pathToString).filter(Boolean),
...isFound ? [
"FOUND"
] : [
"NOT FOUND"
]
].join("\n ");
/**
* If given path is within `process.cwd()` then show relative posix path, otherwise show absolute posix path.
*
* Returns A relative or absolute path
*/ function pathToString(/** An absolute path */ absolute) {
if (!absolute) {
return null;
} else {
const relative = _path.default.relative(process.cwd(), absolute).split(_path.default.sep);
return (relative[0] === ".." ? absolute.split(_path.default.sep) : [
"."
].concat(relative).filter(Boolean)).join("/");
}
}
}
exports.createJoinMsg = createJoinMsg;
/**
* A factory for a log function predicated on the given debug parameter.
*
* The logging function created accepts a function that formats a message and parameters that the function utilises.
* Presuming the message function may be expensive we only call it if logging is enabled.
*
* The log messages are de-duplicated based on the parameters, so it is assumed they are simple types that stringify
* well.
*
* Returns A logging function possibly degenerate
*/ function createDebugLogger(/** A boolean or debug function */ debug) {
const log = !!debug && (typeof debug === "function" ? debug : console.log);
const cache = {};
return log ? actuallyLog : noop;
function noop() {}
function actuallyLog(msgFn, params) {
const key = JSON.stringify(params);
if (!cache[key]) {
cache[key] = true;
log(msgFn.apply(null, params));
}
}
}
exports.createDebugLogger = createDebugLogger;
//# sourceMappingURL=join-function.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/build/webpack/loaders/resolve-url-loader/lib/join-function.ts"],"names":["defaultJoin","compose","f","g","args","simpleJoin","path","normalize","join","createJoinForPredicate","predicate","_","uri","base","i","next","absolute","fs","existsSync","createIterator","arr","name","filename","options","log","createDebugLogger","debug","joinProper","baseOrIteratorOrAbsent","iterator","root","result","runIterator","createJoinMsg","isFound","accumulator","nextItem","done","value","element","length","isAbsolute","Object","assign","concat","Array","isArray","Error","fallback","toString","valueOf","file","bases","pathToString","map","filter","Boolean","relative","process","cwd","split","sep","exports","console","cache","actuallyLog","noop","msgFn","params","key","JSON","stringify","apply"],"mappings":"AAAA,uEAAuE;AACvE,0DAA0D,GAC1D;;;;;;;;;;;;;;;;;;;;;;AAsBA;;;;+BAkBaA;;;eAAAA;;;6DAjBI;2DACF;;;;;;AAEf,MAAMC,UACJ,CAACC,GAAQC,IACT,CAAC,GAAGC,OACFF,EAAEC,KAAKC;AAEX,MAAMC,aAAaJ,QAAQK,aAAI,CAACC,SAAS,EAAED,aAAI,CAACE,IAAI;AAS7C,MAAMR,cAAcS,uBAAuB,SAASC,UACzDC,CAAM,EACNC,GAAQ,EACRC,IAAS,EACTC,CAAM,EACNC,IAAS;IAET,MAAMC,WAAWX,WAAWQ,MAAMD;IAClC,OAAOK,WAAE,CAACC,UAAU,CAACF,YAAYA,WAAWD,KAAKD,MAAM,IAAIE,WAAW;AACxE,GACA;AAEA,UAAUG,eAAeC,GAAQ;IAC/B,KAAK,MAAMN,KAAKM,IAAK;QACnB,MAAMN;IACR;AACF;AAEA;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,SAASL,uBACP,2CAA2C,GAC3CC,SAAc,EACd,kDAAkD,GAClDW,IAAY;IAEZ;;GAEC,GACD,SAASb,KACP,qCAAqC,GACrCc,QAAgB,EAChB,oBAAoB,GACpBC,OAAgD;QAEhD,MAAMC,MAAMC,kBAAkBF,QAAQG,KAAK;QAE3C;;;;;;KAMC,GACD,OAAO,SAASC,WACd,qCAAqC,GACrCf,GAAW,EACX,oDAAoD,GACpDgB,sBAA2B;YAE3B,MAAMC,WACJ,AAAC,OAAOD,2BAA2B,eACjCT,eAAe;gBAACI,QAAQO,IAAI;aAAC,KAC9B,OAAOF,2BAA2B,YACjCT,eAAe;gBAACS;aAAuB,KACzCA;YAEF,MAAMG,SAASC,YAAY,EAAE;YAC7BR,IAAIS,eAAe;gBAACX;gBAAUV;gBAAKmB;gBAAQA,OAAOG,OAAO;aAAC;YAE1D,OAAO,OAAOH,OAAOf,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ACP,qBAAqB,GACrBrC,QAAgB;QAEhB,IAAI,CAACA,UAAU;YACb,OAAO;QACT,OAAO;YACL,MAAMyC,WAAWnD,aAAI,CAACmD,QAAQ,CAACC,QAAQC,GAAG,IAAI3C,UAAU4C,KAAK,CAACtD,aAAI,CAACuD,GAAG;YAEtE,OAAO,AACLJ,CAAAA,QAAQ,CAAC,EAAE,KAAK,OACZzC,SAAS4C,KAAK,CAACtD,aAAI,CAACuD,GAAG,IACvB;gBAAC;aAAI,CAACjB,MAAM,CAACa,UAAUF,MAAM,CAACC,QAAO,EACzChD,IAAI,CAAC;QACT;IACF;AACF;AAEAsD,QAAQ7B,aAAa,GAAGA;AAExB;;;;;;;;;;CAUC,GACD,SAASR,kBACP,gCAAgC,GAChCC,KAAoB;IAEpB,MAAMF,MAAM,CAAC,CAACE,SAAU,CAAA,OAAOA,UAAU,aAAaA,QAAQqC,QAAQvC,GAAG,AAAD;IACxE,MAAMwC,QAAa,CAAC;IACpB,OAAOxC,MAAMyC,cAAcC;IAE3B,SAASA,QAAQ;IAEjB,SAASD,YAAYE,KAAU,EAAEC,MAAW;QAC1C,MAAMC,MAAMC,KAAKC,SAAS,CAACH;QAC3B,IAAI,CAACJ,KAAK,CAACK,IAAI,EAAE;YACfL,KAAK,CAACK,IAAI,GAAG;YACb7C,IAAI2C,MAAMK,KAAK,CAAC,MAAMJ;QACxB;IACF;AACF;AAEAN,QAAQrC,iBAAiB,GAAGA"}

View File

@@ -0,0 +1 @@
export default function process(postcss: any, sourceFile: any, sourceContent: any, params: any): any;

View File

@@ -0,0 +1,86 @@
/*
The MIT License (MIT)
Copyright (c) 2016 Ben Holloway
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function() {
return process;
}
});
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
const _fileprotocol = require("./file-protocol");
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const ORPHAN_CR_REGEX = /\r(?!\n)(.|\n)?/g;
function process(postcss, sourceFile, sourceContent, params) {
// #107 libsass emits orphan CR not considered newline, postcss does consider newline (content vs source-map mismatch)
// prepend file protocol to all sources to avoid problems with source map
// eslint-disable-next-line @typescript-eslint/no-use-before-define
return postcss([
postcss.plugin("postcss-resolve-url", postcssPlugin)
]).process(sourceContent, {
from: (0, _fileprotocol.prepend)(sourceFile),
map: params.outputSourceMap && {
prev: !!params.inputSourceMap && (0, _fileprotocol.prepend)(params.inputSourceMap),
inline: false,
annotation: false,
sourcesContent: true
}
}).then((result)=>({
content: result.css,
map: params.outputSourceMap ? (0, _fileprotocol.remove)(result.map.toJSON()) : null
}));
/**
* Plugin for postcss that follows SASS transpilation.
*/ function postcssPlugin() {
return function(styles) {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
styles.walkDecls(eachDeclaration);
};
/**
* Process a declaration from the syntax tree.
* @param declaration
*/ function eachDeclaration(declaration) {
const isValid = declaration.value && declaration.value.indexOf("url") >= 0;
if (isValid) {
// reverse the original source-map to find the original source file before transpilation
const startPosApparent = declaration.source.start, startPosOriginal = params.sourceMapConsumer && params.sourceMapConsumer.originalPositionFor(startPosApparent);
// we require a valid directory for the specified file
const directory = startPosOriginal && startPosOriginal.source && (0, _fileprotocol.remove)(_path.default.dirname(startPosOriginal.source));
if (directory) {
declaration.value = params.transformDeclaration(declaration.value, directory);
} else if (params.sourceMapConsumer) {
throw new Error("source-map information is not available at url() declaration " + (ORPHAN_CR_REGEX.test(sourceContent) ? "(found orphan CR, try removeCR option)" : "(no orphan CR found)"));
}
}
}
}
}
//# sourceMappingURL=postcss.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/build/webpack/loaders/resolve-url-loader/lib/postcss.ts"],"names":["process","ORPHAN_CR_REGEX","postcss","sourceFile","sourceContent","params","plugin","postcssPlugin","from","prepend","map","outputSourceMap","prev","inputSourceMap","inline","annotation","sourcesContent","then","result","content","css","remove","toJSON","styles","walkDecls","eachDeclaration","declaration","isValid","value","indexOf","startPosApparent","source","start","startPosOriginal","sourceMapConsumer","originalPositionFor","directory","path","dirname","transformDeclaration","Error","test"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;AAsBA;;;;+BAOA;;;eAAwBA;;;6DALP;8BACe;;;;;;AAEhC,MAAMC,kBAAkB;AAET,SAASD,QACtBE,OAAY,EACZC,UAAe,EACfC,aAAkB,EAClBC,MAAW;IAEX,sHAAsH;IAEtH,yEAAyE;IACzE,mEAAmE;IACnE,OAAOH,QAAQ;QAACA,QAAQI,MAAM,CAAC,uBAAuBC;KAAe,EAClEP,OAAO,CAACI,eAAe;QACtBI,MAAMC,IAAAA,qBAAO,EAACN;QACdO,KAAKL,OAAOM,eAAe,IAAI;YAC7BC,MAAM,CAAC,CAACP,OAAOQ,cAAc,IAAIJ,IAAAA,qBAAO,EAACJ,OAAOQ,cAAc;YAC9DC,QAAQ;YACRC,YAAY;YACZC,gBAAgB;QAClB;IACF,GACCC,IAAI,CAAC,CAACC,SAAiB,CAAA;YACtBC,SAASD,OAAOE,GAAG;YACnBV,KAAKL,OAAOM,eAAe,GAAGU,IAAAA,oBAAM,EAACH,OAAOR,GAAG,CAACY,MAAM,MAAM;QAC9D,CAAA;IAEF;;GAEC,GACD,SAASf;QACP,OAAO,SAAUgB,MAAW;YAC1B,mEAAmE;YACnEA,OAAOC,SAAS,CAACC;QACnB;QAEA;;;KAGC,GACD,SAASA,gBAAgBC,WAAgB;YACvC,MAAMC,UAAUD,YAAYE,KAAK,IAAIF,YAAYE,KAAK,CAACC,OAAO,CAAC,UAAU;YACzE,IAAIF,SAAS;gBACX,wFAAwF;gBACxF,MAAMG,mBAAmBJ,YAAYK,MAAM,CAACC,KAAK,EAC/CC,mBACE5B,OAAO6B,iBAAiB,IACxB7B,OAAO6B,iBAAiB,CAACC,mBAAmB,CAACL;gBAEjD,sDAAsD;gBACtD,MAAMM,YACJH,oBACAA,iBAAiBF,MAAM,IACvBV,IAAAA,oBAAM,EAACgB,aAAI,CAACC,OAAO,CAACL,iBAAiBF,MAAM;gBAC7C,IAAIK,WAAW;oBACbV,YAAYE,KAAK,GAAGvB,OAAOkC,oBAAoB,CAC7Cb,YAAYE,KAAK,EACjBQ;gBAEJ,OAEK,IAAI/B,OAAO6B,iBAAiB,EAAE;oBACjC,MAAM,IAAIM,MACR,kEACGvC,CAAAA,gBAAgBwC,IAAI,CAACrC,iBAClB,2CACA,sBAAqB;gBAE/B;YACF;QACF;IACF;AACF"}

View File

@@ -0,0 +1,2 @@
declare function valueProcessor(filename: any, options: any): (value: string, candidate: any) => string;
export default valueProcessor;

View File

@@ -0,0 +1,99 @@
/*
The MIT License (MIT)
Copyright (c) 2016 Ben Holloway
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function() {
return _default;
}
});
const _loaderutils2 = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/loader-utils2"));
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function valueProcessor(filename, options) {
const URL_STATEMENT_REGEX = /(url\s*\()\s*(?:(['"])((?:(?!\2).)*)(\2)|([^'"](?:(?!\)).)*[^'"]))\s*(\))/g;
const directory = _path.default.dirname(filename);
const join = options.join(filename, options);
/**
* Process the given CSS declaration value.
*
*/ return function transformValue(/** A declaration value that may or may not contain a url() statement */ value, /** An absolute path that may be the correct base or an Iterator thereof */ candidate) {
// allow multiple url() values in the declaration
// split by url statements and process the content
// additional capture groups are needed to match quotations correctly
// escaped quotations are not considered
return value.split(URL_STATEMENT_REGEX).map((token, i, arr)=>{
// we can get groups as undefined under certain match circumstances
const initialised = token || "";
// the content of the url() statement is either in group 3 or group 5
const mod = i % 7;
if (mod === 3 || mod === 5) {
// detect quoted url and unescape backslashes
const before = arr[i - 1], after = arr[i + 1], isQuoted = before === after && (before === "'" || before === '"'), unescaped = isQuoted ? initialised.replace(/\\{2}/g, "\\") : initialised;
// split into uri and query/hash and then find the absolute path to the uri
const split = unescaped.split(/([?#])/g), uri = split[0], absolute = // eslint-disable-next-line @typescript-eslint/no-use-before-define
testIsRelative(uri) && join(uri, candidate) || // eslint-disable-next-line @typescript-eslint/no-use-before-define
testIsAbsolute(uri) && join(uri), query = options.keepQuery ? split.slice(1).join("") : "";
// use the absolute path in absolute mode or else relative path (or default to initialised)
// #6 - backslashes are not legal in URI
if (!absolute) {
return initialised;
} else if (options.absolute) {
return absolute.replace(/\\/g, "/") + query;
} else {
return _loaderutils2.default.urlToRequest(_path.default.relative(directory, absolute).replace(/\\/g, "/") + query);
}
} else {
return initialised;
}
}).join("");
};
/**
* The loaderUtils.isUrlRequest() doesn't support windows absolute paths on principle. We do not subscribe to that
* dogma so we add path.isAbsolute() check to allow them.
*
* We also eliminate module relative (~) paths.
*
* Returns true for relative uri
*/ function testIsRelative(/** A uri string possibly empty or undefined */ uri) {
return !!uri && _loaderutils2.default.isUrlRequest(uri, false) && !_path.default.isAbsolute(uri) && uri.indexOf("~") !== 0;
}
/**
* The loaderUtils.isUrlRequest() doesn't support windows absolute paths on principle. We do not subscribe to that
* dogma so we add path.isAbsolute() check to allow them.
*
* Returns true for absolute uri
*/ function testIsAbsolute(/** A uri string possibly empty or undefined */ uri) {
return !!uri && typeof options.root === "string" && _loaderutils2.default.isUrlRequest(uri, options.root) && (/^\//.test(uri) || _path.default.isAbsolute(uri));
}
}
const _default = valueProcessor;
//# sourceMappingURL=value-processor.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/build/webpack/loaders/resolve-url-loader/lib/value-processor.ts"],"names":["valueProcessor","filename","options","URL_STATEMENT_REGEX","directory","path","dirname","join","transformValue","value","candidate","split","map","token","i","arr","initialised","mod","before","after","isQuoted","unescaped","replace","uri","absolute","testIsRelative","testIsAbsolute","query","keepQuery","slice","loaderUtils","urlToRequest","relative","isUrlRequest","isAbsolute","indexOf","root","test"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;AAsBA;;;;+BA+GA;;;eAAA;;;qEA7GwB;6DAC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