This commit is contained in:
2025-05-09 05:30:08 +02:00
parent 7bb10e7df4
commit 73367bad9e
5322 changed files with 1266973 additions and 313 deletions

View File

@@ -0,0 +1 @@
{"version":3,"names":["warnings","Set","deprecationWarning","oldName","newName","prefix","has","add","internal","trace","captureShortStackTrace","console","warn","skip","length","stackTraceLimit","prepareStackTrace","Error","stackTrace","err","stack","shortStackTrace","slice","test","getFileName","map","frame","join"],"sources":["../../src/utils/deprecationWarning.ts"],"sourcesContent":["const warnings = new Set();\n\nexport default function deprecationWarning(\n oldName: string,\n newName: string,\n prefix: string = \"\",\n) {\n if (warnings.has(oldName)) return;\n warnings.add(oldName);\n\n const { internal, trace } = captureShortStackTrace(1, 2);\n if (internal) {\n // If usage comes from an internal package, there is no point in warning because\n // 1. The new version of the package will already use the new API\n // 2. When the deprecation will become an error (in a future major version), users\n // will have to update every package anyway.\n return;\n }\n console.warn(\n `${prefix}\\`${oldName}\\` has been deprecated, please migrate to \\`${newName}\\`\\n${trace}`,\n );\n}\n\nfunction captureShortStackTrace(skip: number, length: number) {\n const { stackTraceLimit, prepareStackTrace } = Error;\n let stackTrace: NodeJS.CallSite[];\n // We add 1 to also take into account this function.\n Error.stackTraceLimit = 1 + skip + length;\n Error.prepareStackTrace = function (err, stack) {\n stackTrace = stack;\n };\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n new Error().stack;\n Error.stackTraceLimit = stackTraceLimit;\n Error.prepareStackTrace = prepareStackTrace;\n\n if (!stackTrace) return { internal: false, trace: \"\" };\n\n const shortStackTrace = stackTrace.slice(1 + skip, 1 + skip + length);\n return {\n internal: /[\\\\/]@babel[\\\\/]/.test(shortStackTrace[1].getFileName()),\n trace: shortStackTrace.map(frame => ` at ${frame}`).join(\"\\n\"),\n };\n}\n"],"mappings":";;;;;;AAAA,MAAMA,QAAQ,GAAG,IAAIC,GAAG,CAAC,CAAC;AAEX,SAASC,kBAAkBA,CACxCC,OAAe,EACfC,OAAe,EACfC,MAAc,GAAG,EAAE,EACnB;EACA,IAAIL,QAAQ,CAACM,GAAG,CAACH,OAAO,CAAC,EAAE;EAC3BH,QAAQ,CAACO,GAAG,CAACJ,OAAO,CAAC;EAErB,MAAM;IAAEK,QAAQ;IAAEC;EAAM,CAAC,GAAGC,sBAAsB,CAAC,CAAC,EAAE,CAAC,CAAC;EACxD,IAAIF,QAAQ,EAAE;IAKZ;EACF;EACAG,OAAO,CAACC,IAAI,CACV,GAAGP,MAAM,KAAKF,OAAO,+CAA+CC,OAAO,OAAOK,KAAK,EACzF,CAAC;AACH;AAEA,SAASC,sBAAsBA,CAACG,IAAY,EAAEC,MAAc,EAAE;EAC5D,MAAM;IAAEC,eAAe;IAAEC;EAAkB,CAAC,GAAGC,KAAK;EACpD,IAAIC,UAA6B;EAEjCD,KAAK,CAACF,eAAe,GAAG,CAAC,GAAGF,IAAI,GAAGC,MAAM;EACzCG,KAAK,CAACD,iBAAiB,GAAG,UAAUG,GAAG,EAAEC,KAAK,EAAE;IAC9CF,UAAU,GAAGE,KAAK;EACpB,CAAC;EAED,IAAIH,KAAK,CAAC,CAAC,CAACG,KAAK;EACjBH,KAAK,CAACF,eAAe,GAAGA,eAAe;EACvCE,KAAK,CAACD,iBAAiB,GAAGA,iBAAiB;EAE3C,IAAI,CAACE,UAAU,EAAE,OAAO;IAAEV,QAAQ,EAAE,KAAK;IAAEC,KAAK,EAAE;EAAG,CAAC;EAEtD,MAAMY,eAAe,GAAGH,UAAU,CAACI,KAAK,CAAC,CAAC,GAAGT,IAAI,EAAE,CAAC,GAAGA,IAAI,GAAGC,MAAM,CAAC;EACrE,OAAO;IACLN,QAAQ,EAAE,kBAAkB,CAACe,IAAI,CAACF,eAAe,CAAC,CAAC,CAAC,CAACG,WAAW,CAAC,CAAC,CAAC;IACnEf,KAAK,EAAEY,eAAe,CAACI,GAAG,CAACC,KAAK,IAAI,UAAUA,KAAK,EAAE,CAAC,CAACC,IAAI,CAAC,IAAI;EAClE,CAAC;AACH","ignoreList":[]}

View File

@@ -0,0 +1,171 @@
/**
* @fileoverview Rule to check for implicit global variables, functions and classes.
* @author Joshua Peek
*/
"use strict";
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../shared/types').Rule} */
module.exports = {
meta: {
type: "suggestion",
defaultOptions: [
{
lexicalBindings: false,
},
],
docs: {
description: "Disallow declarations in the global scope",
recommended: false,
url: "https://eslint.org/docs/latest/rules/no-implicit-globals",
},
schema: [
{
type: "object",
properties: {
lexicalBindings: {
type: "boolean",
},
},
additionalProperties: false,
},
],
messages: {
globalNonLexicalBinding:
"Unexpected {{kind}} declaration in the global scope, wrap in an IIFE for a local variable, assign as global property for a global variable.",
globalLexicalBinding:
"Unexpected {{kind}} declaration in the global scope, wrap in a block or in an IIFE.",
globalVariableLeak:
"Global variable leak, declare the variable if it is intended to be local.",
assignmentToReadonlyGlobal:
"Unexpected assignment to read-only global variable.",
redeclarationOfReadonlyGlobal:
"Unexpected redeclaration of read-only global variable.",
},
},
create(context) {
const [{ lexicalBindings: checkLexicalBindings }] = context.options;
const sourceCode = context.sourceCode;
/**
* Reports the node.
* @param {ASTNode} node Node to report.
* @param {string} messageId Id of the message to report.
* @param {string|undefined} kind Declaration kind, can be 'var', 'const', 'let', function or class.
* @returns {void}
*/
function report(node, messageId, kind) {
context.report({
node,
messageId,
data: {
kind,
},
});
}
return {
Program(node) {
const scope = sourceCode.getScope(node);
scope.variables.forEach(variable => {
// Only ESLint global variables have the `writable` key.
const isReadonlyEslintGlobalVariable =
variable.writeable === false;
const isWritableEslintGlobalVariable =
variable.writeable === true;
if (isWritableEslintGlobalVariable) {
// Everything is allowed with writable ESLint global variables.
return;
}
// Variables exported by "exported" block comments
if (variable.eslintExported) {
return;
}
variable.defs.forEach(def => {
const defNode = def.node;
if (
def.type === "FunctionName" ||
(def.type === "Variable" &&
def.parent.kind === "var")
) {
if (isReadonlyEslintGlobalVariable) {
report(
defNode,
"redeclarationOfReadonlyGlobal",
);
} else {
report(
defNode,
"globalNonLexicalBinding",
def.type === "FunctionName"
? "function"
: `'${def.parent.kind}'`,
);
}
}
if (checkLexicalBindings) {
if (
def.type === "ClassName" ||
(def.type === "Variable" &&
(def.parent.kind === "let" ||
def.parent.kind === "const"))
) {
if (isReadonlyEslintGlobalVariable) {
report(
defNode,
"redeclarationOfReadonlyGlobal",
);
} else {
report(
defNode,
"globalLexicalBinding",
def.type === "ClassName"
? "class"
: `'${def.parent.kind}'`,
);
}
}
}
});
});
// Undeclared assigned variables.
scope.implicit.variables.forEach(variable => {
const scopeVariable = scope.set.get(variable.name);
let messageId;
if (scopeVariable) {
// ESLint global variable
if (scopeVariable.writeable) {
return;
}
messageId = "assignmentToReadonlyGlobal";
} else {
// Reference to an unknown variable, possible global leak.
messageId = "globalVariableLeak";
}
// def.node is an AssignmentExpression, ForInStatement or ForOfStatement.
variable.defs.forEach(def => {
report(def.node, messageId);
});
});
},
};
},
};

View File

@@ -0,0 +1,5 @@
'use strict';
throw new Error(
'react-dom/client is not supported in React Server Components.'
);

View File

@@ -0,0 +1,15 @@
# Installation
> `npm install --save @types/react`
# Summary
This package contains type definitions for react (https://react.dev/).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react.
### Additional Details
* Last updated: Wed, 02 Apr 2025 07:33:00 GMT
* Dependencies: [csstype](https://npmjs.com/package/csstype)
# Credits
These definitions were written by [Asana](https://asana.com), [AssureSign](http://www.assuresign.com), [Microsoft](https://microsoft.com), [John Reilly](https://github.com/johnnyreilly), [Benoit Benezech](https://github.com/bbenezech), [Patricio Zavolinsky](https://github.com/pzavolinsky), [Eric Anderson](https://github.com/ericanderson), [Dovydas Navickas](https://github.com/DovydasNavickas), [Josh Rutherford](https://github.com/theruther4d), [Guilherme Hübner](https://github.com/guilhermehubner), [Ferdy Budhidharma](https://github.com/ferdaber), [Johann Rakotoharisoa](https://github.com/jrakotoharisoa), [Olivier Pascal](https://github.com/pascaloliv), [Martin Hochel](https://github.com/hotell), [Frank Li](https://github.com/franklixuefei), [Jessica Franco](https://github.com/Jessidhia), [Saransh Kataria](https://github.com/saranshkataria), [Kanitkorn Sujautra](https://github.com/lukyth), [Sebastian Silbermann](https://github.com/eps1lon), [Kyle Scully](https://github.com/zieka), [Cong Zhang](https://github.com/dancerphil), [Dimitri Mitropoulos](https://github.com/dimitropoulos), [JongChan Choi](https://github.com/disjukr), [Victor Magalhães](https://github.com/vhfmag), [Priyanshu Rav](https://github.com/priyanshurav), [Dmitry Semigradsky](https://github.com/Semigradsky), and [Matt Pocock](https://github.com/mattpocock).

View File

@@ -0,0 +1 @@
module.exports={A:{A:{"2":"K D E F A B mC"},B:{"1":"IB JB KB LB MB NB OB I","2":"C L M G N O P","194":"0 9 AB BB CB DB EB FB GB HB","962":"Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z"},C:{"1":"9 AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC","2":"nC","516":"0 b c d e f g h i j k l m n o p q r s t u v w x y z","772":"1 2 3 4 5 6 7 8 LC J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a qC rC"},D:{"1":"IB JB KB LB MB NB OB I PC EC QC RC","2":"1 2 3 4 5 6 7 8 J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB","194":"BB CB DB EB FB GB HB","962":"0 9 gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB"},E:{"1":"JC bC cC dC eC fC 2C KC gC hC iC jC 3C","2":"J PB K D E F A B C L M G sC SC tC uC vC wC TC FC GC xC yC zC UC VC HC 0C IC WC XC YC","772":"ZC aC 1C"},F:{"1":"0 w x y z","2":"1 2 3 4 5 6 7 8 F B C G N O P QB RB SB 4C 5C 6C 7C FC kC 8C GC","194":"l m n o p q r s t u v","962":"TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k"},G:{"1":"JC bC cC dC eC fC VD KC gC hC iC jC","2":"E SC 9C lC AD BD CD DD ED FD GD HD ID JD KD LD MD ND OD PD QD RD SD UC VC HC TD IC WC XC YC","772":"ZC aC UD"},H:{"2":"WD"},I:{"1":"I","2":"LC J XD YD ZD aD lC bD cD"},J:{"2":"D A"},K:{"2":"A B C H FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"2":"A B"},O:{"2":"HC"},P:{"2":"1 2 3 4 5 6 7 8 J dD eD fD gD hD TC iD jD kD lD mD IC JC KC nD"},Q:{"194":"oD"},R:{"2":"pD"},S:{"2":"qD","516":"rD"}},B:2,C:"CSS font-size-adjust",D:true};

View File

@@ -0,0 +1,108 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const DescriptionFileUtils = require("./DescriptionFileUtils");
const getInnerRequest = require("./getInnerRequest");
/** @typedef {import("./Resolver")} Resolver */
/** @typedef {import("./Resolver").JsonPrimitive} JsonPrimitive */
/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */
/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */
module.exports = class AliasFieldPlugin {
/**
* @param {string | ResolveStepHook} source source
* @param {string | Array<string>} field field
* @param {string | ResolveStepHook} target target
*/
constructor(source, field, target) {
this.source = source;
this.field = field;
this.target = target;
}
/**
* @param {Resolver} resolver the resolver
* @returns {void}
*/
apply(resolver) {
const target = resolver.ensureHook(this.target);
resolver
.getHook(this.source)
.tapAsync("AliasFieldPlugin", (request, resolveContext, callback) => {
if (!request.descriptionFileData) return callback();
const innerRequest = getInnerRequest(resolver, request);
if (!innerRequest) return callback();
const fieldData = DescriptionFileUtils.getField(
request.descriptionFileData,
this.field
);
if (fieldData === null || typeof fieldData !== "object") {
if (resolveContext.log)
resolveContext.log(
"Field '" +
this.field +
"' doesn't contain a valid alias configuration"
);
return callback();
}
/** @type {JsonPrimitive | undefined} */
const data = Object.prototype.hasOwnProperty.call(
fieldData,
innerRequest
)
? /** @type {{[Key in string]: JsonPrimitive}} */ (fieldData)[
innerRequest
]
: innerRequest.startsWith("./")
? /** @type {{[Key in string]: JsonPrimitive}} */ (fieldData)[
innerRequest.slice(2)
]
: undefined;
if (data === innerRequest) return callback();
if (data === undefined) return callback();
if (data === false) {
/** @type {ResolveRequest} */
const ignoreObj = {
...request,
path: false
};
if (typeof resolveContext.yield === "function") {
resolveContext.yield(ignoreObj);
return callback(null, null);
}
return callback(null, ignoreObj);
}
/** @type {ResolveRequest} */
const obj = {
...request,
path: /** @type {string} */ (request.descriptionFileRoot),
request: /** @type {string} */ (data),
fullySpecified: false
};
resolver.doResolve(
target,
obj,
"aliased from description file " +
request.descriptionFilePath +
" with mapping '" +
innerRequest +
"' to '" +
/** @type {string} */ (data) +
"'",
resolveContext,
(err, result) => {
if (err) return callback(err);
// Don't allow other aliasing or raw request
if (result === undefined) return callback(null, null);
callback(null, result);
}
);
});
}
};

View File

@@ -0,0 +1 @@
module.exports={C:{_:"2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 3.5 3.6"},D:{"133":0.21936,"134":6.57708,_:"4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 135 136 137 138"},F:{_:"9 11 12 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 60 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 9.5-9.6 10.0-10.1 10.5 10.6 11.1 11.5 11.6 12.1"},B:{_:"12 13 14 15 16 17 18 79 80 81 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134"},E:{_:"0 4 5 6 7 8 9 10 11 12 13 14 15 3.1 3.2 5.1 6.1 7.1 9.1 10.1 11.1 12.1 13.1 14.1 15.1 15.2-15.3 15.4 15.5 16.0 16.1 16.2 16.4 16.5 17.0 17.2 17.3 17.4 17.5 18.0 18.1 18.2 18.4","15.6":0.43871,"16.3":1.31614,"16.6":1.9742,"17.1":6.79644,"17.6":6.79644,"18.3":6.13837},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0.01267,"5.0-5.1":0,"6.0-6.1":0.03802,"7.0-7.1":0.02535,"8.1-8.4":0,"9.0-9.2":0.01901,"9.3":0.08871,"10.0-10.2":0.00634,"10.3":0.14575,"11.0-11.2":0.6717,"11.3-11.4":0.04436,"12.0-12.1":0.02535,"12.2-12.5":0.62734,"13.0-13.1":0.01267,"13.2":0.01901,"13.3":0.02535,"13.4-13.7":0.08871,"14.0-14.4":0.22179,"14.5-14.8":0.26614,"15.0-15.1":0.14575,"15.2-15.3":0.14575,"15.4":0.17743,"15.5":0.20278,"15.6-15.8":2.49668,"16.0":0.35486,"16.1":0.72873,"16.2":0.38021,"16.3":0.65902,"16.4":0.14575,"16.5":0.27248,"16.6-16.7":2.95927,"17.0":0.17743,"17.1":0.31684,"17.2":0.2408,"17.3":0.33585,"17.4":0.6717,"17.5":1.49547,"17.6-17.7":4.34068,"18.0":1.21666,"18.1":3.97948,"18.2":1.78063,"18.3":37.21578,"18.4":0.5513},P:{_:"4 20 21 22 23 24 25 26 27 5.0-5.4 6.2-6.4 7.2-7.4 8.2 9.2 10.1 11.1-11.2 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0"},I:{"0":0,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0,"4.4":0,"4.4.3-4.4.4":0},K:{"0":0,_:"10 11 12 11.1 11.5 12.1"},A:{_:"6 7 8 9 10 11 5.5"},S:{_:"2.5 3.0-3.1"},J:{_:"7 10"},N:{_:"10 11"},R:{_:"0"},M:{_:"0"},Q:{_:"14.9"},O:{_:"0"},H:{"0":0},L:{"0":0.67242}};

View File

@@ -0,0 +1 @@
module.exports={C:{"56":0.04643,"78":0.1269,"82":0.00929,"91":0.0031,"102":0.01857,"103":0.0031,"115":0.14547,"122":0.0031,"127":0.0031,"128":0.08047,"129":0.00619,"131":0.00619,"133":0.00619,"134":0.01238,"135":0.42402,"136":5.47815,_:"2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 79 80 81 83 84 85 86 87 88 89 90 92 93 94 95 96 97 98 99 100 101 104 105 106 107 108 109 110 111 112 113 114 116 117 118 119 120 121 123 124 125 126 130 132 137 138 139 140 3.5 3.6"},D:{"39":0.0031,"40":0.0031,"41":0.0031,"46":0.0031,"47":0.0031,"48":0.0031,"49":0.0031,"51":0.0031,"53":0.0031,"54":0.0031,"56":0.0031,"57":1.34323,"59":0.0031,"70":0.0031,"73":0.0031,"79":0.01857,"80":0.0031,"81":0.0031,"83":0.0031,"84":0.0031,"85":0.01238,"86":0.00619,"87":0.02167,"88":0.02786,"89":0.0031,"100":0.0031,"103":0.00929,"105":0.0031,"108":0.00619,"109":0.27546,"110":0.00929,"111":0.00619,"113":0.01238,"114":0.00619,"115":0.04643,"116":0.07738,"117":0.01548,"118":0.0031,"119":0.0031,"120":0.01548,"121":0.0031,"122":0.01548,"123":0.01238,"124":0.08666,"125":0.03095,"126":0.12071,"127":0.02476,"128":0.0619,"129":0.01548,"130":0.01857,"131":0.17951,"132":0.14547,"133":3.36736,"134":7.44038,"135":0.00619,"136":0.00929,_:"4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 42 43 44 45 50 52 55 58 60 61 62 63 64 65 66 67 68 69 71 72 74 75 76 77 78 90 91 92 93 94 95 96 97 98 99 101 102 104 106 107 112 137 138"},F:{"46":0.00619,"87":0.00619,"95":0.15166,"102":0.0031,"116":0.35283,"117":0.75828,_:"9 11 12 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 47 48 49 50 51 52 53 54 55 56 57 58 60 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 88 89 90 91 92 93 94 96 97 98 99 100 101 103 104 105 106 107 108 109 110 111 112 113 114 115 9.5-9.6 10.0-10.1 10.5 10.6 11.1 11.5 11.6 12.1"},B:{"86":0.0031,"90":0.0031,"92":0.00619,"98":0.0031,"100":0.0031,"103":0.0031,"109":0.00619,"112":0.0031,"120":0.0031,"122":0.0031,"124":0.0031,"125":0.0031,"126":0.0031,"128":0.00619,"129":0.0031,"130":0.03405,"131":0.02476,"132":0.10214,"133":1.21324,"134":3.16,_:"12 13 14 15 16 17 18 79 80 81 83 84 85 87 88 89 91 93 94 95 96 97 99 101 102 104 105 106 107 108 110 111 113 114 115 116 117 118 119 121 123 127"},E:{"14":0.00619,"15":0.0031,_:"0 4 5 6 7 8 9 10 11 12 13 3.1 3.2 5.1 6.1 7.1 9.1 10.1 11.1","12.1":0.0031,"13.1":0.03405,"14.1":0.02167,"15.1":0.0031,"15.2-15.3":0.0031,"15.4":0.0031,"15.5":0.01548,"15.6":0.17642,"16.0":0.13309,"16.1":0.02786,"16.2":0.13309,"16.3":0.02167,"16.4":0.00619,"16.5":0.00929,"16.6":0.1888,"17.0":0.00619,"17.1":0.09285,"17.2":0.02167,"17.3":0.01238,"17.4":0.16713,"17.5":0.065,"17.6":0.22594,"18.0":0.11452,"18.1":0.15785,"18.2":0.05571,"18.3":1.27514,"18.4":0.01238},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0.0026,"5.0-5.1":0,"6.0-6.1":0.0078,"7.0-7.1":0.0052,"8.1-8.4":0,"9.0-9.2":0.0039,"9.3":0.0182,"10.0-10.2":0.0013,"10.3":0.0299,"11.0-11.2":0.13782,"11.3-11.4":0.0091,"12.0-12.1":0.0052,"12.2-12.5":0.12872,"13.0-13.1":0.0026,"13.2":0.0039,"13.3":0.0052,"13.4-13.7":0.0182,"14.0-14.4":0.04551,"14.5-14.8":0.05461,"15.0-15.1":0.0299,"15.2-15.3":0.0299,"15.4":0.03641,"15.5":0.04161,"15.6-15.8":0.51228,"16.0":0.07281,"16.1":0.14952,"16.2":0.07801,"16.3":0.13522,"16.4":0.0299,"16.5":0.05591,"16.6-16.7":0.6072,"17.0":0.03641,"17.1":0.06501,"17.2":0.04941,"17.3":0.06891,"17.4":0.13782,"17.5":0.30685,"17.6-17.7":0.89064,"18.0":0.24964,"18.1":0.81653,"18.2":0.36536,"18.3":7.63614,"18.4":0.11312},P:{"4":0.01029,"21":0.02059,"22":0.01029,"23":0.02059,"24":0.03088,"25":0.03088,"26":0.04118,"27":1.85295,_:"20 5.0-5.4 6.2-6.4 8.2 9.2 10.1 11.1-11.2 12.0 13.0 16.0","7.2-7.4":0.12353,"14.0":0.04118,"15.0":0.02059,"17.0":0.02059,"18.0":0.01029,"19.0":0.01029},I:{"0":0.16537,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0.00005,"4.4":0,"4.4.3-4.4.4":0.00018},K:{"0":0.10358,_:"10 11 12 11.1 11.5 12.1"},A:{"11":0.0031,_:"6 7 8 9 10 5.5"},S:{_:"2.5 3.0-3.1"},J:{_:"7 10"},N:{_:"10 11"},R:{_:"0"},M:{"0":0.64907},Q:{_:"14.9"},O:{"0":0.09667},H:{"0":0},L:{"0":54.21501}};

View File

@@ -0,0 +1,54 @@
{{# def.definitions }}
{{# def.errors }}
{{# def.setupKeyword }}
{{# def.setupNextLevel }}
{{
var $currentBaseId = $it.baseId
, $prevValid = 'prevValid' + $lvl
, $passingSchemas = 'passingSchemas' + $lvl;
}}
var {{=$errs}} = errors
, {{=$prevValid}} = false
, {{=$valid}} = false
, {{=$passingSchemas}} = null;
{{# def.setCompositeRule }}
{{~ $schema:$sch:$i }}
{{? {{# def.nonEmptySchema:$sch }} }}
{{
$it.schema = $sch;
$it.schemaPath = $schemaPath + '[' + $i + ']';
$it.errSchemaPath = $errSchemaPath + '/' + $i;
}}
{{# def.insertSubschemaCode }}
{{??}}
var {{=$nextValid}} = true;
{{?}}
{{? $i }}
if ({{=$nextValid}} && {{=$prevValid}}) {
{{=$valid}} = false;
{{=$passingSchemas}} = [{{=$passingSchemas}}, {{=$i}}];
} else {
{{ $closingBraces += '}'; }}
{{?}}
if ({{=$nextValid}}) {
{{=$valid}} = {{=$prevValid}} = true;
{{=$passingSchemas}} = {{=$i}};
}
{{~}}
{{# def.resetCompositeRule }}
{{= $closingBraces }}
if (!{{=$valid}}) {
{{# def.extraError:'oneOf' }}
} else {
{{# def.resetErrors }}
{{? it.opts.allErrors }} } {{?}}

View File

@@ -0,0 +1,366 @@
/**
* @fileoverview A rule to ensure blank lines within blocks.
* @author Mathias Schreck <https://github.com/lo1tuma>
* @deprecated in ESLint v8.53.0
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const astUtils = require("./utils/ast-utils");
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../shared/types').Rule} */
module.exports = {
meta: {
deprecated: {
message: "Formatting rules are being moved out of ESLint core.",
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
deprecatedSince: "8.53.0",
availableUntil: "10.0.0",
replacedBy: [
{
message:
"ESLint Stylistic now maintains deprecated stylistic core rules.",
url: "https://eslint.style/guide/migration",
plugin: {
name: "@stylistic/eslint-plugin-js",
url: "https://eslint.style/packages/js",
},
rule: {
name: "padded-blocks",
url: "https://eslint.style/rules/js/padded-blocks",
},
},
],
},
type: "layout",
docs: {
description: "Require or disallow padding within blocks",
recommended: false,
url: "https://eslint.org/docs/latest/rules/padded-blocks",
},
fixable: "whitespace",
schema: [
{
oneOf: [
{
enum: ["always", "never"],
},
{
type: "object",
properties: {
blocks: {
enum: ["always", "never"],
},
switches: {
enum: ["always", "never"],
},
classes: {
enum: ["always", "never"],
},
},
additionalProperties: false,
minProperties: 1,
},
],
},
{
type: "object",
properties: {
allowSingleLineBlocks: {
type: "boolean",
},
},
additionalProperties: false,
},
],
messages: {
alwaysPadBlock: "Block must be padded by blank lines.",
neverPadBlock: "Block must not be padded by blank lines.",
},
},
create(context) {
const options = {};
const typeOptions = context.options[0] || "always";
const exceptOptions = context.options[1] || {};
if (typeof typeOptions === "string") {
const shouldHavePadding = typeOptions === "always";
options.blocks = shouldHavePadding;
options.switches = shouldHavePadding;
options.classes = shouldHavePadding;
} else {
if (Object.hasOwn(typeOptions, "blocks")) {
options.blocks = typeOptions.blocks === "always";
}
if (Object.hasOwn(typeOptions, "switches")) {
options.switches = typeOptions.switches === "always";
}
if (Object.hasOwn(typeOptions, "classes")) {
options.classes = typeOptions.classes === "always";
}
}
if (Object.hasOwn(exceptOptions, "allowSingleLineBlocks")) {
options.allowSingleLineBlocks =
exceptOptions.allowSingleLineBlocks === true;
}
const sourceCode = context.sourceCode;
/**
* Gets the open brace token from a given node.
* @param {ASTNode} node A BlockStatement or SwitchStatement node from which to get the open brace.
* @returns {Token} The token of the open brace.
*/
function getOpenBrace(node) {
if (node.type === "SwitchStatement") {
return sourceCode.getTokenBefore(node.cases[0]);
}
if (node.type === "StaticBlock") {
return sourceCode.getFirstToken(node, { skip: 1 }); // skip the `static` token
}
// `BlockStatement` or `ClassBody`
return sourceCode.getFirstToken(node);
}
/**
* Checks if the given parameter is a comment node
* @param {ASTNode|Token} node An AST node or token
* @returns {boolean} True if node is a comment
*/
function isComment(node) {
return node.type === "Line" || node.type === "Block";
}
/**
* Checks if there is padding between two tokens
* @param {Token} first The first token
* @param {Token} second The second token
* @returns {boolean} True if there is at least a line between the tokens
*/
function isPaddingBetweenTokens(first, second) {
return second.loc.start.line - first.loc.end.line >= 2;
}
/**
* Checks if the given token has a blank line after it.
* @param {Token} token The token to check.
* @returns {boolean} Whether or not the token is followed by a blank line.
*/
function getFirstBlockToken(token) {
let prev,
first = token;
do {
prev = first;
first = sourceCode.getTokenAfter(first, {
includeComments: true,
});
} while (
isComment(first) &&
first.loc.start.line === prev.loc.end.line
);
return first;
}
/**
* Checks if the given token is preceded by a blank line.
* @param {Token} token The token to check
* @returns {boolean} Whether or not the token is preceded by a blank line
*/
function getLastBlockToken(token) {
let last = token,
next;
do {
next = last;
last = sourceCode.getTokenBefore(last, {
includeComments: true,
});
} while (
isComment(last) &&
last.loc.end.line === next.loc.start.line
);
return last;
}
/**
* Checks if a node should be padded, according to the rule config.
* @param {ASTNode} node The AST node to check.
* @throws {Error} (Unreachable)
* @returns {boolean} True if the node should be padded, false otherwise.
*/
function requirePaddingFor(node) {
switch (node.type) {
case "BlockStatement":
case "StaticBlock":
return options.blocks;
case "SwitchStatement":
return options.switches;
case "ClassBody":
return options.classes;
/* c8 ignore next */
default:
throw new Error("unreachable");
}
}
/**
* Checks the given BlockStatement node to be padded if the block is not empty.
* @param {ASTNode} node The AST node of a BlockStatement.
* @returns {void} undefined.
*/
function checkPadding(node) {
const openBrace = getOpenBrace(node),
firstBlockToken = getFirstBlockToken(openBrace),
tokenBeforeFirst = sourceCode.getTokenBefore(firstBlockToken, {
includeComments: true,
}),
closeBrace = sourceCode.getLastToken(node),
lastBlockToken = getLastBlockToken(closeBrace),
tokenAfterLast = sourceCode.getTokenAfter(lastBlockToken, {
includeComments: true,
}),
blockHasTopPadding = isPaddingBetweenTokens(
tokenBeforeFirst,
firstBlockToken,
),
blockHasBottomPadding = isPaddingBetweenTokens(
lastBlockToken,
tokenAfterLast,
);
if (
options.allowSingleLineBlocks &&
astUtils.isTokenOnSameLine(tokenBeforeFirst, tokenAfterLast)
) {
return;
}
if (requirePaddingFor(node)) {
if (!blockHasTopPadding) {
context.report({
node,
loc: {
start: tokenBeforeFirst.loc.start,
end: firstBlockToken.loc.start,
},
fix(fixer) {
return fixer.insertTextAfter(
tokenBeforeFirst,
"\n",
);
},
messageId: "alwaysPadBlock",
});
}
if (!blockHasBottomPadding) {
context.report({
node,
loc: {
end: tokenAfterLast.loc.start,
start: lastBlockToken.loc.end,
},
fix(fixer) {
return fixer.insertTextBefore(tokenAfterLast, "\n");
},
messageId: "alwaysPadBlock",
});
}
} else {
if (blockHasTopPadding) {
context.report({
node,
loc: {
start: tokenBeforeFirst.loc.start,
end: firstBlockToken.loc.start,
},
fix(fixer) {
return fixer.replaceTextRange(
[
tokenBeforeFirst.range[1],
firstBlockToken.range[0] -
firstBlockToken.loc.start.column,
],
"\n",
);
},
messageId: "neverPadBlock",
});
}
if (blockHasBottomPadding) {
context.report({
node,
loc: {
end: tokenAfterLast.loc.start,
start: lastBlockToken.loc.end,
},
messageId: "neverPadBlock",
fix(fixer) {
return fixer.replaceTextRange(
[
lastBlockToken.range[1],
tokenAfterLast.range[0] -
tokenAfterLast.loc.start.column,
],
"\n",
);
},
});
}
}
}
const rule = {};
if (Object.hasOwn(options, "switches")) {
rule.SwitchStatement = function (node) {
if (node.cases.length === 0) {
return;
}
checkPadding(node);
};
}
if (Object.hasOwn(options, "blocks")) {
rule.BlockStatement = function (node) {
if (node.body.length === 0) {
return;
}
checkPadding(node);
};
rule.StaticBlock = rule.BlockStatement;
}
if (Object.hasOwn(options, "classes")) {
rule.ClassBody = function (node) {
if (node.body.length === 0) {
return;
}
checkPadding(node);
};
}
return rule;
},
};

View File

@@ -0,0 +1 @@
module.exports={A:{A:{"2":"K D E F A B mC"},B:{"1":"0 9 Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I","2":"C L M G N O P","194":"Q H R S T U V W X"},C:{"1":"0 9 r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC","2":"1 2 3 4 5 6 7 8 nC LC J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k qC rC","322":"l m n o p q"},D:{"1":"0 9 Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC","2":"1 2 3 4 5 6 7 8 J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B","194":"9B AC BC CC DC Q H R S T U V W X"},E:{"1":"ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C","2":"J PB K D E F A B C L M G sC SC tC uC vC wC TC FC GC xC yC zC UC VC HC 0C IC WC XC YC"},F:{"1":"0 BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z","2":"1 2 3 4 5 6 7 8 F B C G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB 4C 5C 6C 7C FC kC 8C GC","194":"xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC"},G:{"1":"ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC","2":"E SC 9C lC AD BD CD DD ED FD GD HD ID JD KD LD MD ND OD PD QD RD SD UC VC HC TD IC WC XC YC"},H:{"2":"WD"},I:{"1":"I","2":"LC J XD YD ZD aD lC bD cD"},J:{"2":"D A"},K:{"1":"H","2":"A B C FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"2":"A B"},O:{"1":"HC"},P:{"1":"1 2 3 4 5 6 7 8 mD IC JC KC nD","2":"J dD eD fD gD hD TC iD jD kD lD"},Q:{"2":"oD"},R:{"1":"pD"},S:{"2":"qD rD"}},B:7,C:"Import maps",D:true};

View File

@@ -0,0 +1,21 @@
export type TextContent = import("./api").TextContent;
/** @typedef {import("./api").TextContent} TextContent */
export class XfaText {
/**
* Walk an XFA tree and create an array of text nodes that is compatible
* with a regular PDFs TextContent. Currently, only TextItem.str is supported,
* all other fields and styles haven't been implemented.
*
* @param {Object} xfa - An XFA fake DOM object.
*
* @returns {TextContent}
*/
static textContent(xfa: Object): TextContent;
/**
* @param {string} name - DOM node name. (lower case)
*
* @returns {boolean} true if the DOM node should have a corresponding text
* node.
*/
static shouldBuildText(name: string): boolean;
}

View File

@@ -0,0 +1,143 @@
import invariant from 'tiny-invariant';
import warning from 'warning';
/**
* Checks if we're running in a browser environment.
*/
export const isBrowser = typeof window !== 'undefined';
/**
* Checks whether we're running from a local file system.
*/
export const isLocalFileSystem = isBrowser && window.location.protocol === 'file:';
/**
* Checks whether a variable is defined.
*
* @param {*} variable Variable to check
*/
export function isDefined(variable) {
return typeof variable !== 'undefined';
}
/**
* Checks whether a variable is defined and not null.
*
* @param {*} variable Variable to check
*/
export function isProvided(variable) {
return isDefined(variable) && variable !== null;
}
/**
* Checks whether a variable provided is a string.
*
* @param {*} variable Variable to check
*/
export function isString(variable) {
return typeof variable === 'string';
}
/**
* Checks whether a variable provided is an ArrayBuffer.
*
* @param {*} variable Variable to check
*/
export function isArrayBuffer(variable) {
return variable instanceof ArrayBuffer;
}
/**
* Checks whether a variable provided is a Blob.
*
* @param {*} variable Variable to check
*/
export function isBlob(variable) {
invariant(isBrowser, 'isBlob can only be used in a browser environment');
return variable instanceof Blob;
}
/**
* Checks whether a variable provided is a data URI.
*
* @param {*} variable String to check
*/
export function isDataURI(variable) {
return isString(variable) && /^data:/.test(variable);
}
export function dataURItoByteString(dataURI) {
invariant(isDataURI(dataURI), 'Invalid data URI.');
const [headersString = '', dataString = ''] = dataURI.split(',');
const headers = headersString.split(';');
if (headers.indexOf('base64') !== -1) {
return atob(dataString);
}
return unescape(dataString);
}
export function getDevicePixelRatio() {
return (isBrowser && window.devicePixelRatio) || 1;
}
const allowFileAccessFromFilesTip = 'On Chromium based browsers, you can use --allow-file-access-from-files flag for debugging purposes.';
export function displayCORSWarning() {
warning(!isLocalFileSystem, `Loading PDF as base64 strings/URLs may not work on protocols other than HTTP/HTTPS. ${allowFileAccessFromFilesTip}`);
}
export function displayWorkerWarning() {
warning(!isLocalFileSystem, `Loading PDF.js worker may not work on protocols other than HTTP/HTTPS. ${allowFileAccessFromFilesTip}`);
}
export function cancelRunningTask(runningTask) {
if (runningTask === null || runningTask === void 0 ? void 0 : runningTask.cancel)
runningTask.cancel();
}
export function makePageCallback(page, scale) {
Object.defineProperty(page, 'width', {
get() {
return this.view[2] * scale;
},
configurable: true,
});
Object.defineProperty(page, 'height', {
get() {
return this.view[3] * scale;
},
configurable: true,
});
Object.defineProperty(page, 'originalWidth', {
get() {
return this.view[2];
},
configurable: true,
});
Object.defineProperty(page, 'originalHeight', {
get() {
return this.view[3];
},
configurable: true,
});
return page;
}
export function isCancelException(error) {
return error.name === 'RenderingCancelledException';
}
export function loadFromFile(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => {
if (!reader.result) {
return reject(new Error('Error while reading a file.'));
}
resolve(reader.result);
};
reader.onerror = (event) => {
if (!event.target) {
return reject(new Error('Error while reading a file.'));
}
const { error } = event.target;
if (!error) {
return reject(new Error('Error while reading a file.'));
}
switch (error.code) {
case error.NOT_FOUND_ERR:
return reject(new Error('Error while reading a file: File not found.'));
case error.SECURITY_ERR:
return reject(new Error('Error while reading a file: Security error.'));
case error.ABORT_ERR:
return reject(new Error('Error while reading a file: Aborted.'));
default:
return reject(new Error('Error while reading a file.'));
}
};
reader.readAsArrayBuffer(file);
});
}

View File

@@ -0,0 +1,444 @@
/* -*- Mode: js; js-indent-level: 2; -*- */
/*
* Copyright 2011 Mozilla Foundation and contributors
* Licensed under the New BSD license. See LICENSE or:
* http://opensource.org/licenses/BSD-3-Clause
*/
var base64VLQ = require('./base64-vlq');
var util = require('./util');
var ArraySet = require('./array-set').ArraySet;
var MappingList = require('./mapping-list').MappingList;
/**
* An instance of the SourceMapGenerator represents a source map which is
* being built incrementally. You may pass an object with the following
* properties:
*
* - file: The filename of the generated source.
* - sourceRoot: A root for all relative URLs in this source map.
*/
function SourceMapGenerator(aArgs) {
if (!aArgs) {
aArgs = {};
}
this._file = util.getArg(aArgs, 'file', null);
this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
this._ignoreInvalidMapping = util.getArg(aArgs, 'ignoreInvalidMapping', false);
this._sources = new ArraySet();
this._names = new ArraySet();
this._mappings = new MappingList();
this._sourcesContents = null;
}
SourceMapGenerator.prototype._version = 3;
/**
* Creates a new SourceMapGenerator based on a SourceMapConsumer
*
* @param aSourceMapConsumer The SourceMap.
*/
SourceMapGenerator.fromSourceMap =
function SourceMapGenerator_fromSourceMap(aSourceMapConsumer, generatorOps) {
var sourceRoot = aSourceMapConsumer.sourceRoot;
var generator = new SourceMapGenerator(Object.assign(generatorOps || {}, {
file: aSourceMapConsumer.file,
sourceRoot: sourceRoot
}));
aSourceMapConsumer.eachMapping(function (mapping) {
var newMapping = {
generated: {
line: mapping.generatedLine,
column: mapping.generatedColumn
}
};
if (mapping.source != null) {
newMapping.source = mapping.source;
if (sourceRoot != null) {
newMapping.source = util.relative(sourceRoot, newMapping.source);
}
newMapping.original = {
line: mapping.originalLine,
column: mapping.originalColumn
};
if (mapping.name != null) {
newMapping.name = mapping.name;
}
}
generator.addMapping(newMapping);
});
aSourceMapConsumer.sources.forEach(function (sourceFile) {
var sourceRelative = sourceFile;
if (sourceRoot !== null) {
sourceRelative = util.relative(sourceRoot, sourceFile);
}
if (!generator._sources.has(sourceRelative)) {
generator._sources.add(sourceRelative);
}
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
if (content != null) {
generator.setSourceContent(sourceFile, content);
}
});
return generator;
};
/**
* Add a single mapping from original source line and column to the generated
* source's line and column for this source map being created. The mapping
* object should have the following properties:
*
* - generated: An object with the generated line and column positions.
* - original: An object with the original line and column positions.
* - source: The original source file (relative to the sourceRoot).
* - name: An optional original token name for this mapping.
*/
SourceMapGenerator.prototype.addMapping =
function SourceMapGenerator_addMapping(aArgs) {
var generated = util.getArg(aArgs, 'generated');
var original = util.getArg(aArgs, 'original', null);
var source = util.getArg(aArgs, 'source', null);
var name = util.getArg(aArgs, 'name', null);
if (!this._skipValidation) {
if (this._validateMapping(generated, original, source, name) === false) {
return;
}
}
if (source != null) {
source = String(source);
if (!this._sources.has(source)) {
this._sources.add(source);
}
}
if (name != null) {
name = String(name);
if (!this._names.has(name)) {
this._names.add(name);
}
}
this._mappings.add({
generatedLine: generated.line,
generatedColumn: generated.column,
originalLine: original != null && original.line,
originalColumn: original != null && original.column,
source: source,
name: name
});
};
/**
* Set the source content for a source file.
*/
SourceMapGenerator.prototype.setSourceContent =
function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
var source = aSourceFile;
if (this._sourceRoot != null) {
source = util.relative(this._sourceRoot, source);
}
if (aSourceContent != null) {
// Add the source content to the _sourcesContents map.
// Create a new _sourcesContents map if the property is null.
if (!this._sourcesContents) {
this._sourcesContents = Object.create(null);
}
this._sourcesContents[util.toSetString(source)] = aSourceContent;
} else if (this._sourcesContents) {
// Remove the source file from the _sourcesContents map.
// If the _sourcesContents map is empty, set the property to null.
delete this._sourcesContents[util.toSetString(source)];
if (Object.keys(this._sourcesContents).length === 0) {
this._sourcesContents = null;
}
}
};
/**
* Applies the mappings of a sub-source-map for a specific source file to the
* source map being generated. Each mapping to the supplied source file is
* rewritten using the supplied source map. Note: The resolution for the
* resulting mappings is the minimium of this map and the supplied map.
*
* @param aSourceMapConsumer The source map to be applied.
* @param aSourceFile Optional. The filename of the source file.
* If omitted, SourceMapConsumer's file property will be used.
* @param aSourceMapPath Optional. The dirname of the path to the source map
* to be applied. If relative, it is relative to the SourceMapConsumer.
* This parameter is needed when the two source maps aren't in the same
* directory, and the source map to be applied contains relative source
* paths. If so, those relative source paths need to be rewritten
* relative to the SourceMapGenerator.
*/
SourceMapGenerator.prototype.applySourceMap =
function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
var sourceFile = aSourceFile;
// If aSourceFile is omitted, we will use the file property of the SourceMap
if (aSourceFile == null) {
if (aSourceMapConsumer.file == null) {
throw new Error(
'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
'or the source map\'s "file" property. Both were omitted.'
);
}
sourceFile = aSourceMapConsumer.file;
}
var sourceRoot = this._sourceRoot;
// Make "sourceFile" relative if an absolute Url is passed.
if (sourceRoot != null) {
sourceFile = util.relative(sourceRoot, sourceFile);
}
// Applying the SourceMap can add and remove items from the sources and
// the names array.
var newSources = new ArraySet();
var newNames = new ArraySet();
// Find mappings for the "sourceFile"
this._mappings.unsortedForEach(function (mapping) {
if (mapping.source === sourceFile && mapping.originalLine != null) {
// Check if it can be mapped by the source map, then update the mapping.
var original = aSourceMapConsumer.originalPositionFor({
line: mapping.originalLine,
column: mapping.originalColumn
});
if (original.source != null) {
// Copy mapping
mapping.source = original.source;
if (aSourceMapPath != null) {
mapping.source = util.join(aSourceMapPath, mapping.source)
}
if (sourceRoot != null) {
mapping.source = util.relative(sourceRoot, mapping.source);
}
mapping.originalLine = original.line;
mapping.originalColumn = original.column;
if (original.name != null) {
mapping.name = original.name;
}
}
}
var source = mapping.source;
if (source != null && !newSources.has(source)) {
newSources.add(source);
}
var name = mapping.name;
if (name != null && !newNames.has(name)) {
newNames.add(name);
}
}, this);
this._sources = newSources;
this._names = newNames;
// Copy sourcesContents of applied map.
aSourceMapConsumer.sources.forEach(function (sourceFile) {
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
if (content != null) {
if (aSourceMapPath != null) {
sourceFile = util.join(aSourceMapPath, sourceFile);
}
if (sourceRoot != null) {
sourceFile = util.relative(sourceRoot, sourceFile);
}
this.setSourceContent(sourceFile, content);
}
}, this);
};
/**
* A mapping can have one of the three levels of data:
*
* 1. Just the generated position.
* 2. The Generated position, original position, and original source.
* 3. Generated and original position, original source, as well as a name
* token.
*
* To maintain consistency, we validate that any new mapping being added falls
* in to one of these categories.
*/
SourceMapGenerator.prototype._validateMapping =
function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
aName) {
// When aOriginal is truthy but has empty values for .line and .column,
// it is most likely a programmer error. In this case we throw a very
// specific error message to try to guide them the right way.
// For example: https://github.com/Polymer/polymer-bundler/pull/519
if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
var message = 'original.line and original.column are not numbers -- you probably meant to omit ' +
'the original mapping entirely and only map the generated position. If so, pass ' +
'null for the original mapping instead of an object with empty or null values.'
if (this._ignoreInvalidMapping) {
if (typeof console !== 'undefined' && console.warn) {
console.warn(message);
}
return false;
} else {
throw new Error(message);
}
}
if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
&& aGenerated.line > 0 && aGenerated.column >= 0
&& !aOriginal && !aSource && !aName) {
// Case 1.
return;
}
else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
&& aOriginal && 'line' in aOriginal && 'column' in aOriginal
&& aGenerated.line > 0 && aGenerated.column >= 0
&& aOriginal.line > 0 && aOriginal.column >= 0
&& aSource) {
// Cases 2 and 3.
return;
}
else {
var message = 'Invalid mapping: ' + JSON.stringify({
generated: aGenerated,
source: aSource,
original: aOriginal,
name: aName
});
if (this._ignoreInvalidMapping) {
if (typeof console !== 'undefined' && console.warn) {
console.warn(message);
}
return false;
} else {
throw new Error(message)
}
}
};
/**
* Serialize the accumulated mappings in to the stream of base 64 VLQs
* specified by the source map format.
*/
SourceMapGenerator.prototype._serializeMappings =
function SourceMapGenerator_serializeMappings() {
var previousGeneratedColumn = 0;
var previousGeneratedLine = 1;
var previousOriginalColumn = 0;
var previousOriginalLine = 0;
var previousName = 0;
var previousSource = 0;
var result = '';
var next;
var mapping;
var nameIdx;
var sourceIdx;
var mappings = this._mappings.toArray();
for (var i = 0, len = mappings.length; i < len; i++) {
mapping = mappings[i];
next = ''
if (mapping.generatedLine !== previousGeneratedLine) {
previousGeneratedColumn = 0;
while (mapping.generatedLine !== previousGeneratedLine) {
next += ';';
previousGeneratedLine++;
}
}
else {
if (i > 0) {
if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
continue;
}
next += ',';
}
}
next += base64VLQ.encode(mapping.generatedColumn
- previousGeneratedColumn);
previousGeneratedColumn = mapping.generatedColumn;
if (mapping.source != null) {
sourceIdx = this._sources.indexOf(mapping.source);
next += base64VLQ.encode(sourceIdx - previousSource);
previousSource = sourceIdx;
// lines are stored 0-based in SourceMap spec version 3
next += base64VLQ.encode(mapping.originalLine - 1
- previousOriginalLine);
previousOriginalLine = mapping.originalLine - 1;
next += base64VLQ.encode(mapping.originalColumn
- previousOriginalColumn);
previousOriginalColumn = mapping.originalColumn;
if (mapping.name != null) {
nameIdx = this._names.indexOf(mapping.name);
next += base64VLQ.encode(nameIdx - previousName);
previousName = nameIdx;
}
}
result += next;
}
return result;
};
SourceMapGenerator.prototype._generateSourcesContent =
function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
return aSources.map(function (source) {
if (!this._sourcesContents) {
return null;
}
if (aSourceRoot != null) {
source = util.relative(aSourceRoot, source);
}
var key = util.toSetString(source);
return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
? this._sourcesContents[key]
: null;
}, this);
};
/**
* Externalize the source map.
*/
SourceMapGenerator.prototype.toJSON =
function SourceMapGenerator_toJSON() {
var map = {
version: this._version,
sources: this._sources.toArray(),
names: this._names.toArray(),
mappings: this._serializeMappings()
};
if (this._file != null) {
map.file = this._file;
}
if (this._sourceRoot != null) {
map.sourceRoot = this._sourceRoot;
}
if (this._sourcesContents) {
map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
}
return map;
};
/**
* Render the source map being generated to a string.
*/
SourceMapGenerator.prototype.toString =
function SourceMapGenerator_toString() {
return JSON.stringify(this.toJSON());
};
exports.SourceMapGenerator = SourceMapGenerator;

View File

@@ -0,0 +1,19 @@
Copyright 2022 Justin Ridgewell <jridgewell@google.com>
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.

View File

@@ -0,0 +1 @@
module.exports={A:{A:{"2":"K D E F A B mC"},B:{"1":"0 9 Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I","2":"C L M G N O P"},C:{"1":"CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC","2":"1 2 3 4 5 6 7 8 nC LC J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B qC rC","132":"0 9 AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB"},D:{"1":"0 9 CC DC Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC","2":"1 2 3 4 5 6 7 8 J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B","66":"AC BC"},E:{"1":"ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C","2":"J PB K D E F A B C L sC SC tC uC vC wC TC FC GC","322":"M G xC yC zC UC","580":"VC HC 0C IC WC XC YC"},F:{"1":"0 zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z","2":"1 2 3 4 5 6 7 8 F B C G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB 4C 5C 6C 7C FC kC 8C GC","66":"xB yB"},G:{"1":"ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC","2":"E SC 9C lC AD BD CD DD ED FD GD HD ID JD KD LD MD ND OD","322":"PD QD RD SD UC","580":"VC HC TD IC WC XC YC"},H:{"2":"WD"},I:{"1":"I","2":"LC J XD YD ZD aD lC bD cD"},J:{"2":"D A"},K:{"1":"H","2":"A B C FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"2":"A B"},O:{"1":"HC"},P:{"1":"1 2 3 4 5 6 7 8 jD kD lD mD IC JC KC nD","2":"J dD eD fD gD hD TC iD"},Q:{"1":"oD"},R:{"1":"pD"},S:{"2":"qD","132":"rD"}},B:1,C:"Lazy loading via attribute for images & iframes",D:true};

View File

@@ -0,0 +1 @@
module.exports={C:{"67":0.06903,"68":0.07593,"72":0.09664,"75":0.42799,"77":0.01381,"78":0.10355,"82":0.06213,"107":0.0069,"115":0.34515,"117":0.0069,"125":0.26922,"128":0.26231,"131":0.0069,"133":0.0069,"134":0.04832,"135":0.62817,"136":2.09161,_:"2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 69 70 71 73 74 76 79 80 81 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 108 109 110 111 112 113 114 116 118 119 120 121 122 123 124 126 127 129 130 132 137 138 139 140 3.5 3.6"},D:{"49":0.0069,"50":0.0069,"57":0.0069,"65":0.01381,"70":0.02761,"71":0.07593,"72":0.01381,"74":0.02071,"76":0.12425,"78":0.0069,"79":0.47631,"80":0.04832,"81":0.49702,"83":0.0069,"84":0.02071,"85":1.1528,"86":0.06903,"87":1.23564,"89":0.0069,"91":5.2877,"97":0.0069,"98":0.04832,"99":0.01381,"102":0.49011,"103":1.42202,"105":0.01381,"106":0.50392,"107":0.41418,"108":0.93881,"109":1.57388,"110":0.65579,"111":0.52463,"112":0.52463,"116":0.2209,"117":0.0069,"118":0.0069,"119":0.0069,"120":0.02761,"122":0.0069,"123":0.0069,"124":0.71101,"126":0.09664,"127":0.02071,"128":0.17258,"129":0.11045,"130":0.05522,"131":0.51773,"132":1.42892,"133":7.62782,"134":12.45992,"135":0.03452,_:"4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 51 52 53 54 55 56 58 59 60 61 62 63 64 66 67 68 69 73 75 77 88 90 92 93 94 95 96 100 101 104 113 114 115 121 125 136 137 138"},F:{"65":0.08974,"94":0.2209,"96":0.0069,"102":0.0069,"114":0.0069,"116":0.06213,"117":5.2877,_:"9 11 12 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 60 62 63 64 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 95 97 98 99 100 101 103 104 105 106 107 108 109 110 111 112 113 115 9.5-9.6 10.0-10.1 10.5 10.6 11.1 11.5 11.6 12.1"},B:{"18":0.08284,"86":0.0069,"99":0.0069,"106":0.0069,"108":0.38657,"109":0.02761,"110":0.0069,"111":0.0069,"128":0.0069,"131":0.01381,"132":0.07593,"133":1.85,"134":5.01158,_:"12 13 14 15 16 17 79 80 81 83 84 85 87 88 89 90 91 92 93 94 95 96 97 98 100 101 102 103 104 105 107 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 129 130"},E:{"14":0.0069,_:"0 4 5 6 7 8 9 10 11 12 13 15 3.1 3.2 5.1 6.1 7.1 9.1 10.1 11.1 15.2-15.3 15.4 18.4","12.1":0.02071,"13.1":0.0069,"14.1":0.04832,"15.1":0.0069,"15.5":0.0069,"15.6":0.6834,"16.0":0.01381,"16.1":0.15187,"16.2":0.0069,"16.3":0.08974,"16.4":0.0069,"16.5":0.20709,"16.6":0.33134,"17.0":0.0069,"17.1":0.35205,"17.2":0.26922,"17.3":0.24161,"17.4":0.2278,"17.5":0.33825,"17.6":0.33134,"18.0":0.07593,"18.1":0.25541,"18.2":0.06903,"18.3":4.93565},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0.00367,"5.0-5.1":0,"6.0-6.1":0.011,"7.0-7.1":0.00733,"8.1-8.4":0,"9.0-9.2":0.0055,"9.3":0.02566,"10.0-10.2":0.00183,"10.3":0.04216,"11.0-11.2":0.19431,"11.3-11.4":0.01283,"12.0-12.1":0.00733,"12.2-12.5":0.18148,"13.0-13.1":0.00367,"13.2":0.0055,"13.3":0.00733,"13.4-13.7":0.02566,"14.0-14.4":0.06416,"14.5-14.8":0.07699,"15.0-15.1":0.04216,"15.2-15.3":0.04216,"15.4":0.05133,"15.5":0.05866,"15.6-15.8":0.72225,"16.0":0.10265,"16.1":0.21081,"16.2":0.10999,"16.3":0.19064,"16.4":0.04216,"16.5":0.07882,"16.6-16.7":0.85606,"17.0":0.05133,"17.1":0.09166,"17.2":0.06966,"17.3":0.09716,"17.4":0.19431,"17.5":0.43261,"17.6-17.7":1.25568,"18.0":0.35196,"18.1":1.1512,"18.2":0.51511,"18.3":10.76588,"18.4":0.15948},P:{"27":0.70457,_:"4 20 21 22 23 24 25 26 5.0-5.4 6.2-6.4 7.2-7.4 8.2 9.2 10.1 11.1-11.2 12.0 13.0 14.0 15.0 16.0 17.0 18.0","19.0":0.01084},I:{"0":0.0309,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0.00001,"4.4":0,"4.4.3-4.4.4":0.00003},K:{"0":0.05575,_:"10 11 12 11.1 11.5 12.1"},A:{"11":0.11045,_:"6 7 8 9 10 5.5"},S:{_:"2.5 3.0-3.1"},J:{_:"7 10"},N:{_:"10 11"},R:{_:"0"},M:{"0":0.43048},Q:{_:"14.9"},O:{_:"0"},H:{"0":0},L:{"0":11.84738}};

View File

@@ -0,0 +1,46 @@
/* tslint:disable */
/* eslint-disable */
/* auto-generated by NAPI-RS */
export interface ChangedContent {
/** File path to the changed file */
file?: string
/** Contents of the changed file */
content?: string
/** File extension */
extension: string
}
export interface GlobEntry {
/** Base path of the glob */
base: string
/** Glob pattern */
pattern: string
}
export interface SourceEntry {
/** Base path of the glob */
base: string
/** Glob pattern */
pattern: string
/** Negated flag */
negated: boolean
}
export interface ScannerOptions {
/** Glob sources */
sources?: Array<SourceEntry>
}
export interface CandidateWithPosition {
/** The candidate string */
candidate: string
/** The position of the candidate inside the content file */
position: number
}
export declare class Scanner {
constructor(opts: ScannerOptions)
scan(): Array<string>
scanFiles(input: Array<ChangedContent>): Array<string>
getCandidatesWithPositions(input: ChangedContent): Array<CandidateWithPosition>
get files(): Array<string>
get globs(): Array<GlobEntry>
get normalizedSources(): Array<GlobEntry>
}

View File

@@ -0,0 +1,32 @@
import type { SourceMapSegment, ReverseSegment } from './sourcemap-segment';
export type MemoState = {
lastKey: number;
lastNeedle: number;
lastIndex: number;
};
export declare let found: boolean;
/**
* A binary search implementation that returns the index if a match is found.
* If no match is found, then the left-index (the index associated with the item that comes just
* before the desired index) is returned. To maintain proper sort order, a splice would happen at
* the next index:
*
* ```js
* const array = [1, 3];
* const needle = 2;
* const index = binarySearch(array, needle, (item, needle) => item - needle);
*
* assert.equal(index, 0);
* array.splice(index + 1, 0, needle);
* assert.deepEqual(array, [1, 2, 3]);
* ```
*/
export declare function binarySearch(haystack: SourceMapSegment[] | ReverseSegment[], needle: number, low: number, high: number): number;
export declare function upperBound(haystack: SourceMapSegment[] | ReverseSegment[], needle: number, index: number): number;
export declare function lowerBound(haystack: SourceMapSegment[] | ReverseSegment[], needle: number, index: number): number;
export declare function memoizedState(): MemoState;
/**
* This overly complicated beast is just to record the last tested line/column and the resulting
* index, allowing us to skip a few tests if mappings are monotonically increasing.
*/
export declare function memoizedBinarySearch(haystack: SourceMapSegment[] | ReverseSegment[], needle: number, state: MemoState, key: number): number;

View File

@@ -0,0 +1,16 @@
export class AppOptions {
static eventBus: any;
static "__#66@#opts": Map<any, any>;
static get(name: any): any;
static getAll(kind?: null, defaultOnly?: boolean): any;
static set(name: any, value: any): void;
static setAll(options: any, prefs?: boolean): void;
}
export namespace OptionKind {
let BROWSER: number;
let VIEWER: number;
let API: number;
let WORKER: number;
let EVENT_DISPATCH: number;
let PREFERENCE: number;
}

View File

@@ -0,0 +1,469 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.buildPresetChain = buildPresetChain;
exports.buildPresetChainWalker = void 0;
exports.buildRootChain = buildRootChain;
function _path() {
const data = require("path");
_path = function () {
return data;
};
return data;
}
function _debug() {
const data = require("debug");
_debug = function () {
return data;
};
return data;
}
var _options = require("./validation/options.js");
var _patternToRegex = require("./pattern-to-regex.js");
var _printer = require("./printer.js");
var _rewriteStackTrace = require("../errors/rewrite-stack-trace.js");
var _configError = require("../errors/config-error.js");
var _index = require("./files/index.js");
var _caching = require("./caching.js");
var _configDescriptors = require("./config-descriptors.js");
const debug = _debug()("babel:config:config-chain");
function* buildPresetChain(arg, context) {
const chain = yield* buildPresetChainWalker(arg, context);
if (!chain) return null;
return {
plugins: dedupDescriptors(chain.plugins),
presets: dedupDescriptors(chain.presets),
options: chain.options.map(o => normalizeOptions(o)),
files: new Set()
};
}
const buildPresetChainWalker = exports.buildPresetChainWalker = makeChainWalker({
root: preset => loadPresetDescriptors(preset),
env: (preset, envName) => loadPresetEnvDescriptors(preset)(envName),
overrides: (preset, index) => loadPresetOverridesDescriptors(preset)(index),
overridesEnv: (preset, index, envName) => loadPresetOverridesEnvDescriptors(preset)(index)(envName),
createLogger: () => () => {}
});
const loadPresetDescriptors = (0, _caching.makeWeakCacheSync)(preset => buildRootDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors));
const loadPresetEnvDescriptors = (0, _caching.makeWeakCacheSync)(preset => (0, _caching.makeStrongCacheSync)(envName => buildEnvDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors, envName)));
const loadPresetOverridesDescriptors = (0, _caching.makeWeakCacheSync)(preset => (0, _caching.makeStrongCacheSync)(index => buildOverrideDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors, index)));
const loadPresetOverridesEnvDescriptors = (0, _caching.makeWeakCacheSync)(preset => (0, _caching.makeStrongCacheSync)(index => (0, _caching.makeStrongCacheSync)(envName => buildOverrideEnvDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors, index, envName))));
function* buildRootChain(opts, context) {
let configReport, babelRcReport;
const programmaticLogger = new _printer.ConfigPrinter();
const programmaticChain = yield* loadProgrammaticChain({
options: opts,
dirname: context.cwd
}, context, undefined, programmaticLogger);
if (!programmaticChain) return null;
const programmaticReport = yield* programmaticLogger.output();
let configFile;
if (typeof opts.configFile === "string") {
configFile = yield* (0, _index.loadConfig)(opts.configFile, context.cwd, context.envName, context.caller);
} else if (opts.configFile !== false) {
configFile = yield* (0, _index.findRootConfig)(context.root, context.envName, context.caller);
}
let {
babelrc,
babelrcRoots
} = opts;
let babelrcRootsDirectory = context.cwd;
const configFileChain = emptyChain();
const configFileLogger = new _printer.ConfigPrinter();
if (configFile) {
const validatedFile = validateConfigFile(configFile);
const result = yield* loadFileChain(validatedFile, context, undefined, configFileLogger);
if (!result) return null;
configReport = yield* configFileLogger.output();
if (babelrc === undefined) {
babelrc = validatedFile.options.babelrc;
}
if (babelrcRoots === undefined) {
babelrcRootsDirectory = validatedFile.dirname;
babelrcRoots = validatedFile.options.babelrcRoots;
}
mergeChain(configFileChain, result);
}
let ignoreFile, babelrcFile;
let isIgnored = false;
const fileChain = emptyChain();
if ((babelrc === true || babelrc === undefined) && typeof context.filename === "string") {
const pkgData = yield* (0, _index.findPackageData)(context.filename);
if (pkgData && babelrcLoadEnabled(context, pkgData, babelrcRoots, babelrcRootsDirectory)) {
({
ignore: ignoreFile,
config: babelrcFile
} = yield* (0, _index.findRelativeConfig)(pkgData, context.envName, context.caller));
if (ignoreFile) {
fileChain.files.add(ignoreFile.filepath);
}
if (ignoreFile && shouldIgnore(context, ignoreFile.ignore, null, ignoreFile.dirname)) {
isIgnored = true;
}
if (babelrcFile && !isIgnored) {
const validatedFile = validateBabelrcFile(babelrcFile);
const babelrcLogger = new _printer.ConfigPrinter();
const result = yield* loadFileChain(validatedFile, context, undefined, babelrcLogger);
if (!result) {
isIgnored = true;
} else {
babelRcReport = yield* babelrcLogger.output();
mergeChain(fileChain, result);
}
}
if (babelrcFile && isIgnored) {
fileChain.files.add(babelrcFile.filepath);
}
}
}
if (context.showConfig) {
console.log(`Babel configs on "${context.filename}" (ascending priority):\n` + [configReport, babelRcReport, programmaticReport].filter(x => !!x).join("\n\n") + "\n-----End Babel configs-----");
}
const chain = mergeChain(mergeChain(mergeChain(emptyChain(), configFileChain), fileChain), programmaticChain);
return {
plugins: isIgnored ? [] : dedupDescriptors(chain.plugins),
presets: isIgnored ? [] : dedupDescriptors(chain.presets),
options: isIgnored ? [] : chain.options.map(o => normalizeOptions(o)),
fileHandling: isIgnored ? "ignored" : "transpile",
ignore: ignoreFile || undefined,
babelrc: babelrcFile || undefined,
config: configFile || undefined,
files: chain.files
};
}
function babelrcLoadEnabled(context, pkgData, babelrcRoots, babelrcRootsDirectory) {
if (typeof babelrcRoots === "boolean") return babelrcRoots;
const absoluteRoot = context.root;
if (babelrcRoots === undefined) {
return pkgData.directories.includes(absoluteRoot);
}
let babelrcPatterns = babelrcRoots;
if (!Array.isArray(babelrcPatterns)) {
babelrcPatterns = [babelrcPatterns];
}
babelrcPatterns = babelrcPatterns.map(pat => {
return typeof pat === "string" ? _path().resolve(babelrcRootsDirectory, pat) : pat;
});
if (babelrcPatterns.length === 1 && babelrcPatterns[0] === absoluteRoot) {
return pkgData.directories.includes(absoluteRoot);
}
return babelrcPatterns.some(pat => {
if (typeof pat === "string") {
pat = (0, _patternToRegex.default)(pat, babelrcRootsDirectory);
}
return pkgData.directories.some(directory => {
return matchPattern(pat, babelrcRootsDirectory, directory, context);
});
});
}
const validateConfigFile = (0, _caching.makeWeakCacheSync)(file => ({
filepath: file.filepath,
dirname: file.dirname,
options: (0, _options.validate)("configfile", file.options, file.filepath)
}));
const validateBabelrcFile = (0, _caching.makeWeakCacheSync)(file => ({
filepath: file.filepath,
dirname: file.dirname,
options: (0, _options.validate)("babelrcfile", file.options, file.filepath)
}));
const validateExtendFile = (0, _caching.makeWeakCacheSync)(file => ({
filepath: file.filepath,
dirname: file.dirname,
options: (0, _options.validate)("extendsfile", file.options, file.filepath)
}));
const loadProgrammaticChain = makeChainWalker({
root: input => buildRootDescriptors(input, "base", _configDescriptors.createCachedDescriptors),
env: (input, envName) => buildEnvDescriptors(input, "base", _configDescriptors.createCachedDescriptors, envName),
overrides: (input, index) => buildOverrideDescriptors(input, "base", _configDescriptors.createCachedDescriptors, index),
overridesEnv: (input, index, envName) => buildOverrideEnvDescriptors(input, "base", _configDescriptors.createCachedDescriptors, index, envName),
createLogger: (input, context, baseLogger) => buildProgrammaticLogger(input, context, baseLogger)
});
const loadFileChainWalker = makeChainWalker({
root: file => loadFileDescriptors(file),
env: (file, envName) => loadFileEnvDescriptors(file)(envName),
overrides: (file, index) => loadFileOverridesDescriptors(file)(index),
overridesEnv: (file, index, envName) => loadFileOverridesEnvDescriptors(file)(index)(envName),
createLogger: (file, context, baseLogger) => buildFileLogger(file.filepath, context, baseLogger)
});
function* loadFileChain(input, context, files, baseLogger) {
const chain = yield* loadFileChainWalker(input, context, files, baseLogger);
chain == null || chain.files.add(input.filepath);
return chain;
}
const loadFileDescriptors = (0, _caching.makeWeakCacheSync)(file => buildRootDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors));
const loadFileEnvDescriptors = (0, _caching.makeWeakCacheSync)(file => (0, _caching.makeStrongCacheSync)(envName => buildEnvDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors, envName)));
const loadFileOverridesDescriptors = (0, _caching.makeWeakCacheSync)(file => (0, _caching.makeStrongCacheSync)(index => buildOverrideDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors, index)));
const loadFileOverridesEnvDescriptors = (0, _caching.makeWeakCacheSync)(file => (0, _caching.makeStrongCacheSync)(index => (0, _caching.makeStrongCacheSync)(envName => buildOverrideEnvDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors, index, envName))));
function buildFileLogger(filepath, context, baseLogger) {
if (!baseLogger) {
return () => {};
}
return baseLogger.configure(context.showConfig, _printer.ChainFormatter.Config, {
filepath
});
}
function buildRootDescriptors({
dirname,
options
}, alias, descriptors) {
return descriptors(dirname, options, alias);
}
function buildProgrammaticLogger(_, context, baseLogger) {
var _context$caller;
if (!baseLogger) {
return () => {};
}
return baseLogger.configure(context.showConfig, _printer.ChainFormatter.Programmatic, {
callerName: (_context$caller = context.caller) == null ? void 0 : _context$caller.name
});
}
function buildEnvDescriptors({
dirname,
options
}, alias, descriptors, envName) {
var _options$env;
const opts = (_options$env = options.env) == null ? void 0 : _options$env[envName];
return opts ? descriptors(dirname, opts, `${alias}.env["${envName}"]`) : null;
}
function buildOverrideDescriptors({
dirname,
options
}, alias, descriptors, index) {
var _options$overrides;
const opts = (_options$overrides = options.overrides) == null ? void 0 : _options$overrides[index];
if (!opts) throw new Error("Assertion failure - missing override");
return descriptors(dirname, opts, `${alias}.overrides[${index}]`);
}
function buildOverrideEnvDescriptors({
dirname,
options
}, alias, descriptors, index, envName) {
var _options$overrides2, _override$env;
const override = (_options$overrides2 = options.overrides) == null ? void 0 : _options$overrides2[index];
if (!override) throw new Error("Assertion failure - missing override");
const opts = (_override$env = override.env) == null ? void 0 : _override$env[envName];
return opts ? descriptors(dirname, opts, `${alias}.overrides[${index}].env["${envName}"]`) : null;
}
function makeChainWalker({
root,
env,
overrides,
overridesEnv,
createLogger
}) {
return function* chainWalker(input, context, files = new Set(), baseLogger) {
const {
dirname
} = input;
const flattenedConfigs = [];
const rootOpts = root(input);
if (configIsApplicable(rootOpts, dirname, context, input.filepath)) {
flattenedConfigs.push({
config: rootOpts,
envName: undefined,
index: undefined
});
const envOpts = env(input, context.envName);
if (envOpts && configIsApplicable(envOpts, dirname, context, input.filepath)) {
flattenedConfigs.push({
config: envOpts,
envName: context.envName,
index: undefined
});
}
(rootOpts.options.overrides || []).forEach((_, index) => {
const overrideOps = overrides(input, index);
if (configIsApplicable(overrideOps, dirname, context, input.filepath)) {
flattenedConfigs.push({
config: overrideOps,
index,
envName: undefined
});
const overrideEnvOpts = overridesEnv(input, index, context.envName);
if (overrideEnvOpts && configIsApplicable(overrideEnvOpts, dirname, context, input.filepath)) {
flattenedConfigs.push({
config: overrideEnvOpts,
index,
envName: context.envName
});
}
}
});
}
if (flattenedConfigs.some(({
config: {
options: {
ignore,
only
}
}
}) => shouldIgnore(context, ignore, only, dirname))) {
return null;
}
const chain = emptyChain();
const logger = createLogger(input, context, baseLogger);
for (const {
config,
index,
envName
} of flattenedConfigs) {
if (!(yield* mergeExtendsChain(chain, config.options, dirname, context, files, baseLogger))) {
return null;
}
logger(config, index, envName);
yield* mergeChainOpts(chain, config);
}
return chain;
};
}
function* mergeExtendsChain(chain, opts, dirname, context, files, baseLogger) {
if (opts.extends === undefined) return true;
const file = yield* (0, _index.loadConfig)(opts.extends, dirname, context.envName, context.caller);
if (files.has(file)) {
throw new Error(`Configuration cycle detected loading ${file.filepath}.\n` + `File already loaded following the config chain:\n` + Array.from(files, file => ` - ${file.filepath}`).join("\n"));
}
files.add(file);
const fileChain = yield* loadFileChain(validateExtendFile(file), context, files, baseLogger);
files.delete(file);
if (!fileChain) return false;
mergeChain(chain, fileChain);
return true;
}
function mergeChain(target, source) {
target.options.push(...source.options);
target.plugins.push(...source.plugins);
target.presets.push(...source.presets);
for (const file of source.files) {
target.files.add(file);
}
return target;
}
function* mergeChainOpts(target, {
options,
plugins,
presets
}) {
target.options.push(options);
target.plugins.push(...(yield* plugins()));
target.presets.push(...(yield* presets()));
return target;
}
function emptyChain() {
return {
options: [],
presets: [],
plugins: [],
files: new Set()
};
}
function normalizeOptions(opts) {
const options = Object.assign({}, opts);
delete options.extends;
delete options.env;
delete options.overrides;
delete options.plugins;
delete options.presets;
delete options.passPerPreset;
delete options.ignore;
delete options.only;
delete options.test;
delete options.include;
delete options.exclude;
if (hasOwnProperty.call(options, "sourceMap")) {
options.sourceMaps = options.sourceMap;
delete options.sourceMap;
}
return options;
}
function dedupDescriptors(items) {
const map = new Map();
const descriptors = [];
for (const item of items) {
if (typeof item.value === "function") {
const fnKey = item.value;
let nameMap = map.get(fnKey);
if (!nameMap) {
nameMap = new Map();
map.set(fnKey, nameMap);
}
let desc = nameMap.get(item.name);
if (!desc) {
desc = {
value: item
};
descriptors.push(desc);
if (!item.ownPass) nameMap.set(item.name, desc);
} else {
desc.value = item;
}
} else {
descriptors.push({
value: item
});
}
}
return descriptors.reduce((acc, desc) => {
acc.push(desc.value);
return acc;
}, []);
}
function configIsApplicable({
options
}, dirname, context, configName) {
return (options.test === undefined || configFieldIsApplicable(context, options.test, dirname, configName)) && (options.include === undefined || configFieldIsApplicable(context, options.include, dirname, configName)) && (options.exclude === undefined || !configFieldIsApplicable(context, options.exclude, dirname, configName));
}
function configFieldIsApplicable(context, test, dirname, configName) {
const patterns = Array.isArray(test) ? test : [test];
return matchesPatterns(context, patterns, dirname, configName);
}
function ignoreListReplacer(_key, value) {
if (value instanceof RegExp) {
return String(value);
}
return value;
}
function shouldIgnore(context, ignore, only, dirname) {
if (ignore && matchesPatterns(context, ignore, dirname)) {
var _context$filename;
const message = `No config is applied to "${(_context$filename = context.filename) != null ? _context$filename : "(unknown)"}" because it matches one of \`ignore: ${JSON.stringify(ignore, ignoreListReplacer)}\` from "${dirname}"`;
debug(message);
if (context.showConfig) {
console.log(message);
}
return true;
}
if (only && !matchesPatterns(context, only, dirname)) {
var _context$filename2;
const message = `No config is applied to "${(_context$filename2 = context.filename) != null ? _context$filename2 : "(unknown)"}" because it fails to match one of \`only: ${JSON.stringify(only, ignoreListReplacer)}\` from "${dirname}"`;
debug(message);
if (context.showConfig) {
console.log(message);
}
return true;
}
return false;
}
function matchesPatterns(context, patterns, dirname, configName) {
return patterns.some(pattern => matchPattern(pattern, dirname, context.filename, context, configName));
}
function matchPattern(pattern, dirname, pathToTest, context, configName) {
if (typeof pattern === "function") {
return !!(0, _rewriteStackTrace.endHiddenCallStack)(pattern)(pathToTest, {
dirname,
envName: context.envName,
caller: context.caller
});
}
if (typeof pathToTest !== "string") {
throw new _configError.default(`Configuration contains string/RegExp pattern, but no filename was passed to Babel`, configName);
}
if (typeof pattern === "string") {
pattern = (0, _patternToRegex.default)(pattern, dirname);
}
return pattern.test(pathToTest);
}
0 && 0;
//# sourceMappingURL=config-chain.js.map