update
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
'use strict';
|
||||
module.exports = function generate_pattern(it, $keyword, $ruleType) {
|
||||
var out = ' ';
|
||||
var $lvl = it.level;
|
||||
var $dataLvl = it.dataLevel;
|
||||
var $schema = it.schema[$keyword];
|
||||
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
||||
var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
|
||||
var $breakOnError = !it.opts.allErrors;
|
||||
var $data = 'data' + ($dataLvl || '');
|
||||
var $isData = it.opts.$data && $schema && $schema.$data,
|
||||
$schemaValue;
|
||||
if ($isData) {
|
||||
out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
|
||||
$schemaValue = 'schema' + $lvl;
|
||||
} else {
|
||||
$schemaValue = $schema;
|
||||
}
|
||||
var $regexp = $isData ? '(new RegExp(' + $schemaValue + '))' : it.usePattern($schema);
|
||||
out += 'if ( ';
|
||||
if ($isData) {
|
||||
out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'string\') || ';
|
||||
}
|
||||
out += ' !' + ($regexp) + '.test(' + ($data) + ') ) { ';
|
||||
var $$outStack = $$outStack || [];
|
||||
$$outStack.push(out);
|
||||
out = ''; /* istanbul ignore else */
|
||||
if (it.createErrors !== false) {
|
||||
out += ' { keyword: \'' + ('pattern') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { pattern: ';
|
||||
if ($isData) {
|
||||
out += '' + ($schemaValue);
|
||||
} else {
|
||||
out += '' + (it.util.toQuotedString($schema));
|
||||
}
|
||||
out += ' } ';
|
||||
if (it.opts.messages !== false) {
|
||||
out += ' , message: \'should match pattern "';
|
||||
if ($isData) {
|
||||
out += '\' + ' + ($schemaValue) + ' + \'';
|
||||
} else {
|
||||
out += '' + (it.util.escapeQuotes($schema));
|
||||
}
|
||||
out += '"\' ';
|
||||
}
|
||||
if (it.opts.verbose) {
|
||||
out += ' , schema: ';
|
||||
if ($isData) {
|
||||
out += 'validate.schema' + ($schemaPath);
|
||||
} else {
|
||||
out += '' + (it.util.toQuotedString($schema));
|
||||
}
|
||||
out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
|
||||
}
|
||||
out += ' } ';
|
||||
} else {
|
||||
out += ' {} ';
|
||||
}
|
||||
var __err = out;
|
||||
out = $$outStack.pop();
|
||||
if (!it.compositeRule && $breakOnError) {
|
||||
/* istanbul ignore if */
|
||||
if (it.async) {
|
||||
out += ' throw new ValidationError([' + (__err) + ']); ';
|
||||
} else {
|
||||
out += ' validate.errors = [' + (__err) + ']; return false; ';
|
||||
}
|
||||
} else {
|
||||
out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
|
||||
}
|
||||
out += '} ';
|
||||
if ($breakOnError) {
|
||||
out += ' else { ';
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2012-2018 Aseem Kishore, and [others].
|
||||
|
||||
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.
|
||||
|
||||
[others]: https://github.com/json5/json5/contributors
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"47":0.00111,"53":0.00111,"72":0.00221,"115":0.00774,"127":0.01106,"128":0.00111,"129":0.00111,"131":0.00111,"135":0.05862,"136":0.30304,_:"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 48 49 50 51 52 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 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 116 117 118 119 120 121 122 123 124 125 126 130 132 133 134 137 138 139 140 3.5 3.6"},D:{"49":0.00221,"55":0.00442,"77":0.00111,"95":0.00332,"99":0.00774,"109":0.01548,"116":0.00332,"117":0.00111,"119":0.00111,"120":0.00111,"122":0.00442,"124":0.00111,"126":0.00221,"128":0.00221,"129":0.00111,"130":0.00221,"131":0.00221,"132":0.02654,"133":0.23005,"134":0.2389,"136":0.00221,_:"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 50 51 52 53 54 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 78 79 80 81 83 84 85 86 87 88 89 90 91 92 93 94 96 97 98 100 101 102 103 104 105 106 107 108 110 111 112 113 114 115 118 121 123 125 127 135 137 138"},F:{"36":0.00111,"46":0.00111,"57":0.00442,"58":0.00111,"64":0.00553,"95":0.00221,"116":0.00442,"117":0.0929,_:"9 11 12 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 37 38 39 40 41 42 43 44 45 47 48 49 50 51 52 53 54 55 56 60 62 63 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 96 97 98 99 100 101 102 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:{"12":0.00111,"13":0.00111,"17":0.00111,"84":0.00111,"89":0.00664,"90":0.00221,"92":0.00111,"100":0.00221,"109":0.00111,"111":0.00111,"112":0.00111,"125":0.00221,"127":0.00442,"131":0.00332,"132":0.02544,"133":0.04756,"134":0.10507,_:"14 15 16 18 79 80 81 83 85 86 87 88 91 93 94 95 96 97 98 99 101 102 103 104 105 106 107 108 110 113 114 115 116 117 118 119 120 121 122 123 124 126 128 129 130"},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 15.6 16.1 16.2 16.3 16.4 16.5 17.0 17.1 17.2 17.3 17.4 17.5 17.6 18.0 18.1 18.2 18.4","16.0":0.00111,"16.6":0.00221,"18.3":0.00332},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0.00073,"5.0-5.1":0,"6.0-6.1":0.00218,"7.0-7.1":0.00146,"8.1-8.4":0,"9.0-9.2":0.00109,"9.3":0.00509,"10.0-10.2":0.00036,"10.3":0.00837,"11.0-11.2":0.03856,"11.3-11.4":0.00255,"12.0-12.1":0.00146,"12.2-12.5":0.03601,"13.0-13.1":0.00073,"13.2":0.00109,"13.3":0.00146,"13.4-13.7":0.00509,"14.0-14.4":0.01273,"14.5-14.8":0.01528,"15.0-15.1":0.00837,"15.2-15.3":0.00837,"15.4":0.01019,"15.5":0.01164,"15.6-15.8":0.14332,"16.0":0.02037,"16.1":0.04183,"16.2":0.02183,"16.3":0.03783,"16.4":0.00837,"16.5":0.01564,"16.6-16.7":0.16988,"17.0":0.01019,"17.1":0.01819,"17.2":0.01382,"17.3":0.01928,"17.4":0.03856,"17.5":0.08585,"17.6-17.7":0.24918,"18.0":0.06984,"18.1":0.22844,"18.2":0.10222,"18.3":2.13639,"18.4":0.03165},P:{"4":0.10178,"20":0.01018,"22":0.02036,"23":0.03053,"24":0.24426,"25":0.23409,"26":0.01018,"27":0.13231,_:"21 8.2 10.1 12.0 13.0 14.0 15.0 17.0 18.0 19.0","5.0-5.4":0.03053,"6.2-6.4":0.03053,"7.2-7.4":0.10178,"9.2":0.02036,"11.1-11.2":0.01018,"16.0":0.01018},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":2.12603,_:"10 11 12 11.1 11.5 12.1"},A:{_:"6 7 8 9 10 11 5.5"},S:{"2.5":0.04447,_:"3.0-3.1"},J:{_:"7 10"},N:{_:"10 11"},R:{_:"0"},M:{"0":0.05336},Q:{"14.9":0.00889},O:{"0":0.01779},H:{"0":2.57},L:{"0":89.13276}};
|
||||
@@ -0,0 +1,57 @@
|
||||
// From pdfjs-dist/lib/web/struct_tree_layer_builder.js
|
||||
export const PDF_ROLE_TO_HTML_ROLE = {
|
||||
// Document level structure types
|
||||
Document: null, // There's a "document" role, but it doesn't make sense here.
|
||||
DocumentFragment: null,
|
||||
// Grouping level structure types
|
||||
Part: 'group',
|
||||
Sect: 'group', // XXX: There's a "section" role, but it's abstract.
|
||||
Div: 'group',
|
||||
Aside: 'note',
|
||||
NonStruct: 'none',
|
||||
// Block level structure types
|
||||
P: null,
|
||||
// H<n>,
|
||||
H: 'heading',
|
||||
Title: null,
|
||||
FENote: 'note',
|
||||
// Sub-block level structure type
|
||||
Sub: 'group',
|
||||
// General inline level structure types
|
||||
Lbl: null,
|
||||
Span: null,
|
||||
Em: null,
|
||||
Strong: null,
|
||||
Link: 'link',
|
||||
Annot: 'note',
|
||||
Form: 'form',
|
||||
// Ruby and Warichu structure types
|
||||
Ruby: null,
|
||||
RB: null,
|
||||
RT: null,
|
||||
RP: null,
|
||||
Warichu: null,
|
||||
WT: null,
|
||||
WP: null,
|
||||
// List standard structure types
|
||||
L: 'list',
|
||||
LI: 'listitem',
|
||||
LBody: null,
|
||||
// Table standard structure types
|
||||
Table: 'table',
|
||||
TR: 'row',
|
||||
TH: 'columnheader',
|
||||
TD: 'cell',
|
||||
THead: 'columnheader',
|
||||
TBody: null,
|
||||
TFoot: null,
|
||||
// Standard structure type Caption
|
||||
Caption: null,
|
||||
// Standard structure type Figure
|
||||
Figure: 'figure',
|
||||
// Standard structure type Formula
|
||||
Formula: null,
|
||||
// standard structure type Artifact
|
||||
Artifact: null,
|
||||
};
|
||||
export const HEADING_PATTERN = /^H(\d+)$/;
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"1":"F A B","16":"mC","132":"K D E"},B:{"1":"0 9 C L M G N O P 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"},C:{"1":"0 1 2 3 4 5 6 7 8 9 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 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 oC pC qC rC"},D:{"1":"0 9 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 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","132":"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"},E:{"1":"D E F A B C L M G uC vC wC TC FC GC xC yC zC UC VC HC 0C IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C","16":"sC","132":"J PB K SC tC"},F:{"1":"0 1 2 3 4 5 6 7 8 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 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 l m n o p q r s t u v w x y z","16":"F 4C","132":"B C G N 5C 6C 7C FC kC 8C GC"},G:{"1":"E 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 ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC","16":"SC"},H:{"2":"WD"},I:{"1":"I bD cD","16":"XD YD","132":"LC J ZD aD lC"},J:{"132":"D A"},K:{"1":"H","132":"A B C FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"1":"A B"},O:{"1":"HC"},P:{"1":"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:{"1":"oD"},R:{"1":"pD"},S:{"1":"qD rD"}},B:2,C:"letter-spacing CSS property",D:true};
|
||||
@@ -0,0 +1,28 @@
|
||||
const handler = {
|
||||
scheme: "http",
|
||||
domainHost: true,
|
||||
parse: function (components, options) {
|
||||
//report missing host
|
||||
if (!components.host) {
|
||||
components.error = components.error || "HTTP URIs must have a host.";
|
||||
}
|
||||
return components;
|
||||
},
|
||||
serialize: function (components, options) {
|
||||
const secure = String(components.scheme).toLowerCase() === "https";
|
||||
//normalize the default port
|
||||
if (components.port === (secure ? 443 : 80) || components.port === "") {
|
||||
components.port = undefined;
|
||||
}
|
||||
//normalize the empty path
|
||||
if (!components.path) {
|
||||
components.path = "/";
|
||||
}
|
||||
//NOTE: We do not parse query strings for HTTP URIs
|
||||
//as WWW Form Url Encoded query strings are part of the HTML4+ spec,
|
||||
//and not the HTTP spec.
|
||||
return components;
|
||||
}
|
||||
};
|
||||
export default handler;
|
||||
//# sourceMappingURL=http.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"K D E F A B mC"},B:{"2":"0 9 C L M G N O P 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"},C:{"1":"oC pC","2":"0 1 2 3 4 5 6 7 8 9 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 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 qC rC","194":"PC EC QC RC"},D:{"2":"0 1 2 3 4 5 6 7 8 9 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 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"},E:{"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 ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C"},F:{"2":"0 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 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 l m n o p q r s t u v w x y z 4C 5C 6C 7C FC kC 8C GC"},G:{"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 ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC"},H:{"2":"WD"},I:{"2":"LC J I XD YD ZD aD lC bD cD"},J:{"2":"D A"},K:{"2":"A B C H FC kC GC"},L:{"2":"I"},M:{"2":"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:{"2":"oD"},R:{"2":"pD"},S:{"2":"qD rD"}},B:6,C:"Temporal",D:true};
|
||||
@@ -0,0 +1,64 @@
|
||||
import { Asset } from './Asset'
|
||||
import { useRouterState } from './useRouterState'
|
||||
import { useRouter } from './useRouter'
|
||||
import type { RouterManagedTag } from '@tanstack/router-core'
|
||||
|
||||
export const Scripts = () => {
|
||||
const router = useRouter()
|
||||
|
||||
const assetScripts = useRouterState({
|
||||
select: (state) => {
|
||||
const assetScripts: Array<RouterManagedTag> = []
|
||||
const manifest = router.ssr?.manifest
|
||||
|
||||
if (!manifest) {
|
||||
return []
|
||||
}
|
||||
|
||||
state.matches
|
||||
.map((match) => router.looseRoutesById[match.routeId]!)
|
||||
.forEach((route) =>
|
||||
manifest.routes[route.id]?.assets
|
||||
?.filter((d) => d.tag === 'script')
|
||||
.forEach((asset) => {
|
||||
assetScripts.push({
|
||||
tag: 'script',
|
||||
attrs: asset.attrs,
|
||||
children: asset.children,
|
||||
} as any)
|
||||
}),
|
||||
)
|
||||
|
||||
return assetScripts
|
||||
},
|
||||
structuralSharing: true as any,
|
||||
})
|
||||
|
||||
const { scripts } = useRouterState({
|
||||
select: (state) => ({
|
||||
scripts: (
|
||||
state.matches
|
||||
.map((match) => match.scripts!)
|
||||
.flat(1)
|
||||
.filter(Boolean) as Array<RouterManagedTag>
|
||||
).map(({ children, ...script }) => ({
|
||||
tag: 'script',
|
||||
attrs: {
|
||||
...script,
|
||||
suppressHydrationWarning: true,
|
||||
},
|
||||
children,
|
||||
})),
|
||||
}),
|
||||
})
|
||||
|
||||
const allScripts = [...scripts, ...assetScripts] as Array<RouterManagedTag>
|
||||
|
||||
return (
|
||||
<>
|
||||
{allScripts.map((asset, i) => (
|
||||
<Asset {...asset} key={`tsr-scripts-${asset.tag}-${i}`} />
|
||||
))}
|
||||
</>
|
||||
)
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,88 @@
|
||||
import type { SourceMapInput } from '@jridgewell/trace-mapping';
|
||||
import type { DecodedSourceMap, EncodedSourceMap, Pos, Mapping } from './types';
|
||||
export type { DecodedSourceMap, EncodedSourceMap, Mapping };
|
||||
export declare type Options = {
|
||||
file?: string | null;
|
||||
sourceRoot?: string | null;
|
||||
};
|
||||
/**
|
||||
* Provides the state to generate a sourcemap.
|
||||
*/
|
||||
export declare class GenMapping {
|
||||
private _names;
|
||||
private _sources;
|
||||
private _sourcesContent;
|
||||
private _mappings;
|
||||
private _ignoreList;
|
||||
file: string | null | undefined;
|
||||
sourceRoot: string | null | undefined;
|
||||
constructor({ file, sourceRoot }?: Options);
|
||||
}
|
||||
/**
|
||||
* A low-level API to associate a generated position with an original source position. Line and
|
||||
* column here are 0-based, unlike `addMapping`.
|
||||
*/
|
||||
export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source?: null, sourceLine?: null, sourceColumn?: null, name?: null, content?: null): void;
|
||||
export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source: string, sourceLine: number, sourceColumn: number, name?: null, content?: string | null): void;
|
||||
export declare function addSegment(map: GenMapping, genLine: number, genColumn: number, source: string, sourceLine: number, sourceColumn: number, name: string, content?: string | null): void;
|
||||
/**
|
||||
* A high-level API to associate a generated position with an original source position. Line is
|
||||
* 1-based, but column is 0-based, due to legacy behavior in `source-map` library.
|
||||
*/
|
||||
export declare function addMapping(map: GenMapping, mapping: {
|
||||
generated: Pos;
|
||||
source?: null;
|
||||
original?: null;
|
||||
name?: null;
|
||||
content?: null;
|
||||
}): void;
|
||||
export declare function addMapping(map: GenMapping, mapping: {
|
||||
generated: Pos;
|
||||
source: string;
|
||||
original: Pos;
|
||||
name?: null;
|
||||
content?: string | null;
|
||||
}): void;
|
||||
export declare function addMapping(map: GenMapping, mapping: {
|
||||
generated: Pos;
|
||||
source: string;
|
||||
original: Pos;
|
||||
name: string;
|
||||
content?: string | null;
|
||||
}): void;
|
||||
/**
|
||||
* Same as `addSegment`, but will only add the segment if it generates useful information in the
|
||||
* resulting map. This only works correctly if segments are added **in order**, meaning you should
|
||||
* not add a segment with a lower generated line/column than one that came before.
|
||||
*/
|
||||
export declare const maybeAddSegment: typeof addSegment;
|
||||
/**
|
||||
* Same as `addMapping`, but will only add the mapping if it generates useful information in the
|
||||
* resulting map. This only works correctly if mappings are added **in order**, meaning you should
|
||||
* not add a mapping with a lower generated line/column than one that came before.
|
||||
*/
|
||||
export declare const maybeAddMapping: typeof addMapping;
|
||||
/**
|
||||
* Adds/removes the content of the source file to the source map.
|
||||
*/
|
||||
export declare function setSourceContent(map: GenMapping, source: string, content: string | null): void;
|
||||
export declare function setIgnore(map: GenMapping, source: string, ignore?: boolean): void;
|
||||
/**
|
||||
* Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects
|
||||
* a sourcemap, or to JSON.stringify.
|
||||
*/
|
||||
export declare function toDecodedMap(map: GenMapping): DecodedSourceMap;
|
||||
/**
|
||||
* Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects
|
||||
* a sourcemap, or to JSON.stringify.
|
||||
*/
|
||||
export declare function toEncodedMap(map: GenMapping): EncodedSourceMap;
|
||||
/**
|
||||
* Constructs a new GenMapping, using the already present mappings of the input.
|
||||
*/
|
||||
export declare function fromMap(input: SourceMapInput): GenMapping;
|
||||
/**
|
||||
* Returns an array of high-level mapping objects for every recorded segment, which could then be
|
||||
* passed to the `source-map` library.
|
||||
*/
|
||||
export declare function allMappings(map: GenMapping): Mapping[];
|
||||
@@ -0,0 +1 @@
|
||||
module.exports = require("./data/plugin-bugfixes.json");
|
||||
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* @license React
|
||||
* use-sync-external-store-shim/with-selector.production.js
|
||||
*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
var React = require("react"),
|
||||
shim = require("use-sync-external-store/shim");
|
||||
function is(x, y) {
|
||||
return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
|
||||
}
|
||||
var objectIs = "function" === typeof Object.is ? Object.is : is,
|
||||
useSyncExternalStore = shim.useSyncExternalStore,
|
||||
useRef = React.useRef,
|
||||
useEffect = React.useEffect,
|
||||
useMemo = React.useMemo,
|
||||
useDebugValue = React.useDebugValue;
|
||||
exports.useSyncExternalStoreWithSelector = function (
|
||||
subscribe,
|
||||
getSnapshot,
|
||||
getServerSnapshot,
|
||||
selector,
|
||||
isEqual
|
||||
) {
|
||||
var instRef = useRef(null);
|
||||
if (null === instRef.current) {
|
||||
var inst = { hasValue: !1, value: null };
|
||||
instRef.current = inst;
|
||||
} else inst = instRef.current;
|
||||
instRef = useMemo(
|
||||
function () {
|
||||
function memoizedSelector(nextSnapshot) {
|
||||
if (!hasMemo) {
|
||||
hasMemo = !0;
|
||||
memoizedSnapshot = nextSnapshot;
|
||||
nextSnapshot = selector(nextSnapshot);
|
||||
if (void 0 !== isEqual && inst.hasValue) {
|
||||
var currentSelection = inst.value;
|
||||
if (isEqual(currentSelection, nextSnapshot))
|
||||
return (memoizedSelection = currentSelection);
|
||||
}
|
||||
return (memoizedSelection = nextSnapshot);
|
||||
}
|
||||
currentSelection = memoizedSelection;
|
||||
if (objectIs(memoizedSnapshot, nextSnapshot)) return currentSelection;
|
||||
var nextSelection = selector(nextSnapshot);
|
||||
if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
|
||||
return (memoizedSnapshot = nextSnapshot), currentSelection;
|
||||
memoizedSnapshot = nextSnapshot;
|
||||
return (memoizedSelection = nextSelection);
|
||||
}
|
||||
var hasMemo = !1,
|
||||
memoizedSnapshot,
|
||||
memoizedSelection,
|
||||
maybeGetServerSnapshot =
|
||||
void 0 === getServerSnapshot ? null : getServerSnapshot;
|
||||
return [
|
||||
function () {
|
||||
return memoizedSelector(getSnapshot());
|
||||
},
|
||||
null === maybeGetServerSnapshot
|
||||
? void 0
|
||||
: function () {
|
||||
return memoizedSelector(maybeGetServerSnapshot());
|
||||
}
|
||||
];
|
||||
},
|
||||
[getSnapshot, getServerSnapshot, selector, isEqual]
|
||||
);
|
||||
var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);
|
||||
useEffect(
|
||||
function () {
|
||||
inst.hasValue = !0;
|
||||
inst.value = value;
|
||||
},
|
||||
[value]
|
||||
);
|
||||
useDebugValue(value);
|
||||
return value;
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
export * from "pdfjs-dist";
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "loose-envify",
|
||||
"version": "1.4.0",
|
||||
"description": "Fast (and loose) selective `process.env` replacer using js-tokens instead of an AST",
|
||||
"keywords": [
|
||||
"environment",
|
||||
"variables",
|
||||
"browserify",
|
||||
"browserify-transform",
|
||||
"transform",
|
||||
"source",
|
||||
"configuration"
|
||||
],
|
||||
"homepage": "https://github.com/zertosh/loose-envify",
|
||||
"license": "MIT",
|
||||
"author": "Andres Suarez <zertosh@gmail.com>",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
"loose-envify": "cli.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/zertosh/loose-envify.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/*.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"js-tokens": "^3.0.0 || ^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^13.1.1",
|
||||
"envify": "^3.4.0",
|
||||
"tap": "^8.0.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
'use strict';
|
||||
|
||||
// See http://www.robvanderwoude.com/escapechars.php
|
||||
const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
|
||||
|
||||
function escapeCommand(arg) {
|
||||
// Escape meta chars
|
||||
arg = arg.replace(metaCharsRegExp, '^$1');
|
||||
|
||||
return arg;
|
||||
}
|
||||
|
||||
function escapeArgument(arg, doubleEscapeMetaChars) {
|
||||
// Convert to string
|
||||
arg = `${arg}`;
|
||||
|
||||
// Algorithm below is based on https://qntm.org/cmd
|
||||
// It's slightly altered to disable JS backtracking to avoid hanging on specially crafted input
|
||||
// Please see https://github.com/moxystudio/node-cross-spawn/pull/160 for more information
|
||||
|
||||
// Sequence of backslashes followed by a double quote:
|
||||
// double up all the backslashes and escape the double quote
|
||||
arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
|
||||
|
||||
// Sequence of backslashes followed by the end of the string
|
||||
// (which will become a double quote later):
|
||||
// double up all the backslashes
|
||||
arg = arg.replace(/(?=(\\+?)?)\1$/, '$1$1');
|
||||
|
||||
// All other backslashes occur literally
|
||||
|
||||
// Quote the whole thing:
|
||||
arg = `"${arg}"`;
|
||||
|
||||
// Escape meta chars
|
||||
arg = arg.replace(metaCharsRegExp, '^$1');
|
||||
|
||||
// Double escape meta chars if necessary
|
||||
if (doubleEscapeMetaChars) {
|
||||
arg = arg.replace(metaCharsRegExp, '^$1');
|
||||
}
|
||||
|
||||
return arg;
|
||||
}
|
||||
|
||||
module.exports.command = escapeCommand;
|
||||
module.exports.argument = escapeArgument;
|
||||
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.isKeyword = isKeyword;
|
||||
exports.isReservedWord = isReservedWord;
|
||||
exports.isStrictBindOnlyReservedWord = isStrictBindOnlyReservedWord;
|
||||
exports.isStrictBindReservedWord = isStrictBindReservedWord;
|
||||
exports.isStrictReservedWord = isStrictReservedWord;
|
||||
const reservedWords = {
|
||||
keyword: ["break", "case", "catch", "continue", "debugger", "default", "do", "else", "finally", "for", "function", "if", "return", "switch", "throw", "try", "var", "const", "while", "with", "new", "this", "super", "class", "extends", "export", "import", "null", "true", "false", "in", "instanceof", "typeof", "void", "delete"],
|
||||
strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"],
|
||||
strictBind: ["eval", "arguments"]
|
||||
};
|
||||
const keywords = new Set(reservedWords.keyword);
|
||||
const reservedWordsStrictSet = new Set(reservedWords.strict);
|
||||
const reservedWordsStrictBindSet = new Set(reservedWords.strictBind);
|
||||
function isReservedWord(word, inModule) {
|
||||
return inModule && word === "await" || word === "enum";
|
||||
}
|
||||
function isStrictReservedWord(word, inModule) {
|
||||
return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);
|
||||
}
|
||||
function isStrictBindOnlyReservedWord(word) {
|
||||
return reservedWordsStrictBindSet.has(word);
|
||||
}
|
||||
function isStrictBindReservedWord(word, inModule) {
|
||||
return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word);
|
||||
}
|
||||
function isKeyword(word) {
|
||||
return keywords.has(word);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=keyword.js.map
|
||||
@@ -0,0 +1,150 @@
|
||||
'use strict'
|
||||
|
||||
exports.byteLength = byteLength
|
||||
exports.toByteArray = toByteArray
|
||||
exports.fromByteArray = fromByteArray
|
||||
|
||||
var lookup = []
|
||||
var revLookup = []
|
||||
var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
|
||||
|
||||
var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
||||
for (var i = 0, len = code.length; i < len; ++i) {
|
||||
lookup[i] = code[i]
|
||||
revLookup[code.charCodeAt(i)] = i
|
||||
}
|
||||
|
||||
// Support decoding URL-safe base64 strings, as Node.js does.
|
||||
// See: https://en.wikipedia.org/wiki/Base64#URL_applications
|
||||
revLookup['-'.charCodeAt(0)] = 62
|
||||
revLookup['_'.charCodeAt(0)] = 63
|
||||
|
||||
function getLens (b64) {
|
||||
var len = b64.length
|
||||
|
||||
if (len % 4 > 0) {
|
||||
throw new Error('Invalid string. Length must be a multiple of 4')
|
||||
}
|
||||
|
||||
// Trim off extra bytes after placeholder bytes are found
|
||||
// See: https://github.com/beatgammit/base64-js/issues/42
|
||||
var validLen = b64.indexOf('=')
|
||||
if (validLen === -1) validLen = len
|
||||
|
||||
var placeHoldersLen = validLen === len
|
||||
? 0
|
||||
: 4 - (validLen % 4)
|
||||
|
||||
return [validLen, placeHoldersLen]
|
||||
}
|
||||
|
||||
// base64 is 4/3 + up to two characters of the original data
|
||||
function byteLength (b64) {
|
||||
var lens = getLens(b64)
|
||||
var validLen = lens[0]
|
||||
var placeHoldersLen = lens[1]
|
||||
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
||||
}
|
||||
|
||||
function _byteLength (b64, validLen, placeHoldersLen) {
|
||||
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
||||
}
|
||||
|
||||
function toByteArray (b64) {
|
||||
var tmp
|
||||
var lens = getLens(b64)
|
||||
var validLen = lens[0]
|
||||
var placeHoldersLen = lens[1]
|
||||
|
||||
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
|
||||
|
||||
var curByte = 0
|
||||
|
||||
// if there are placeholders, only get up to the last complete 4 chars
|
||||
var len = placeHoldersLen > 0
|
||||
? validLen - 4
|
||||
: validLen
|
||||
|
||||
var i
|
||||
for (i = 0; i < len; i += 4) {
|
||||
tmp =
|
||||
(revLookup[b64.charCodeAt(i)] << 18) |
|
||||
(revLookup[b64.charCodeAt(i + 1)] << 12) |
|
||||
(revLookup[b64.charCodeAt(i + 2)] << 6) |
|
||||
revLookup[b64.charCodeAt(i + 3)]
|
||||
arr[curByte++] = (tmp >> 16) & 0xFF
|
||||
arr[curByte++] = (tmp >> 8) & 0xFF
|
||||
arr[curByte++] = tmp & 0xFF
|
||||
}
|
||||
|
||||
if (placeHoldersLen === 2) {
|
||||
tmp =
|
||||
(revLookup[b64.charCodeAt(i)] << 2) |
|
||||
(revLookup[b64.charCodeAt(i + 1)] >> 4)
|
||||
arr[curByte++] = tmp & 0xFF
|
||||
}
|
||||
|
||||
if (placeHoldersLen === 1) {
|
||||
tmp =
|
||||
(revLookup[b64.charCodeAt(i)] << 10) |
|
||||
(revLookup[b64.charCodeAt(i + 1)] << 4) |
|
||||
(revLookup[b64.charCodeAt(i + 2)] >> 2)
|
||||
arr[curByte++] = (tmp >> 8) & 0xFF
|
||||
arr[curByte++] = tmp & 0xFF
|
||||
}
|
||||
|
||||
return arr
|
||||
}
|
||||
|
||||
function tripletToBase64 (num) {
|
||||
return lookup[num >> 18 & 0x3F] +
|
||||
lookup[num >> 12 & 0x3F] +
|
||||
lookup[num >> 6 & 0x3F] +
|
||||
lookup[num & 0x3F]
|
||||
}
|
||||
|
||||
function encodeChunk (uint8, start, end) {
|
||||
var tmp
|
||||
var output = []
|
||||
for (var i = start; i < end; i += 3) {
|
||||
tmp =
|
||||
((uint8[i] << 16) & 0xFF0000) +
|
||||
((uint8[i + 1] << 8) & 0xFF00) +
|
||||
(uint8[i + 2] & 0xFF)
|
||||
output.push(tripletToBase64(tmp))
|
||||
}
|
||||
return output.join('')
|
||||
}
|
||||
|
||||
function fromByteArray (uint8) {
|
||||
var tmp
|
||||
var len = uint8.length
|
||||
var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
|
||||
var parts = []
|
||||
var maxChunkLength = 16383 // must be multiple of 3
|
||||
|
||||
// go through the array every three bytes, we'll deal with trailing stuff later
|
||||
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
|
||||
parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
|
||||
}
|
||||
|
||||
// pad the end with zeros, but make sure to not forget the extra bytes
|
||||
if (extraBytes === 1) {
|
||||
tmp = uint8[len - 1]
|
||||
parts.push(
|
||||
lookup[tmp >> 2] +
|
||||
lookup[(tmp << 4) & 0x3F] +
|
||||
'=='
|
||||
)
|
||||
} else if (extraBytes === 2) {
|
||||
tmp = (uint8[len - 2] << 8) + uint8[len - 1]
|
||||
parts.push(
|
||||
lookup[tmp >> 10] +
|
||||
lookup[(tmp >> 4) & 0x3F] +
|
||||
lookup[(tmp << 2) & 0x3F] +
|
||||
'='
|
||||
)
|
||||
}
|
||||
|
||||
return parts.join('')
|
||||
}
|
||||
@@ -0,0 +1,506 @@
|
||||
// TypeScript Version: 3.0
|
||||
|
||||
import { Readable } from 'stream'
|
||||
|
||||
export interface PngConfig {
|
||||
/** Specifies the ZLIB compression level. Defaults to 6. */
|
||||
compressionLevel?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
|
||||
/**
|
||||
* Any bitwise combination of `PNG_FILTER_NONE`, `PNG_FILTER_SUB`,
|
||||
* `PNG_FILTER_UP`, `PNG_FILTER_AVG` and `PNG_FILTER_PATETH`; or one of
|
||||
* `PNG_ALL_FILTERS` or `PNG_NO_FILTERS` (all are properties of the canvas
|
||||
* instance). These specify which filters *may* be used by libpng. During
|
||||
* encoding, libpng will select the best filter from this list of allowed
|
||||
* filters. Defaults to `canvas.PNG_ALL_FILTERS`.
|
||||
*/
|
||||
filters?: number
|
||||
/**
|
||||
* _For creating indexed PNGs._ The palette of colors. Entries should be in
|
||||
* RGBA order.
|
||||
*/
|
||||
palette?: Uint8ClampedArray
|
||||
/**
|
||||
* _For creating indexed PNGs._ The index of the background color. Defaults
|
||||
* to 0.
|
||||
*/
|
||||
backgroundIndex?: number
|
||||
/** pixels per inch */
|
||||
resolution?: number
|
||||
}
|
||||
|
||||
export interface JpegConfig {
|
||||
/** Specifies the quality, between 0 and 1. Defaults to 0.75. */
|
||||
quality?: number
|
||||
/** Enables progressive encoding. Defaults to `false`. */
|
||||
progressive?: boolean
|
||||
/** Enables 2x2 chroma subsampling. Defaults to `true`. */
|
||||
chromaSubsampling?: boolean
|
||||
}
|
||||
|
||||
export interface PdfConfig {
|
||||
title?: string
|
||||
author?: string
|
||||
subject?: string
|
||||
keywords?: string
|
||||
creator?: string
|
||||
creationDate?: Date
|
||||
modDate?: Date
|
||||
}
|
||||
|
||||
export interface NodeCanvasRenderingContext2DSettings {
|
||||
alpha?: boolean
|
||||
pixelFormat?: 'RGBA32' | 'RGB24' | 'A8' | 'RGB16_565' | 'A1' | 'RGB30'
|
||||
}
|
||||
|
||||
export class Canvas {
|
||||
width: number
|
||||
height: number
|
||||
|
||||
/** _Non standard._ The type of the canvas. */
|
||||
readonly type: 'image'|'pdf'|'svg'
|
||||
|
||||
/** _Non standard._ Getter. The stride used by the canvas. */
|
||||
readonly stride: number;
|
||||
|
||||
/** Constant used in PNG encoding methods. */
|
||||
static readonly PNG_NO_FILTERS: number
|
||||
/** Constant used in PNG encoding methods. */
|
||||
static readonly PNG_ALL_FILTERS: number
|
||||
/** Constant used in PNG encoding methods. */
|
||||
static readonly PNG_FILTER_NONE: number
|
||||
/** Constant used in PNG encoding methods. */
|
||||
static readonly PNG_FILTER_SUB: number
|
||||
/** Constant used in PNG encoding methods. */
|
||||
static readonly PNG_FILTER_UP: number
|
||||
/** Constant used in PNG encoding methods. */
|
||||
static readonly PNG_FILTER_AVG: number
|
||||
/** Constant used in PNG encoding methods. */
|
||||
static readonly PNG_FILTER_PAETH: number
|
||||
|
||||
constructor(width: number, height: number, type?: 'image'|'pdf'|'svg')
|
||||
|
||||
getContext(contextId: '2d', contextAttributes?: NodeCanvasRenderingContext2DSettings): CanvasRenderingContext2D
|
||||
|
||||
/**
|
||||
* For image canvases, encodes the canvas as a PNG. For PDF canvases,
|
||||
* encodes the canvas as a PDF. For SVG canvases, encodes the canvas as an
|
||||
* SVG.
|
||||
*/
|
||||
toBuffer(cb: (err: Error|null, result: Buffer) => void): void
|
||||
toBuffer(cb: (err: Error|null, result: Buffer) => void, mimeType: 'image/png', config?: PngConfig): void
|
||||
toBuffer(cb: (err: Error|null, result: Buffer) => void, mimeType: 'image/jpeg', config?: JpegConfig): void
|
||||
|
||||
/**
|
||||
* For image canvases, encodes the canvas as a PNG. For PDF canvases,
|
||||
* encodes the canvas as a PDF. For SVG canvases, encodes the canvas as an
|
||||
* SVG.
|
||||
*/
|
||||
toBuffer(): Buffer
|
||||
toBuffer(mimeType: 'image/png', config?: PngConfig): Buffer
|
||||
toBuffer(mimeType: 'image/jpeg', config?: JpegConfig): Buffer
|
||||
toBuffer(mimeType: 'application/pdf', config?: PdfConfig): Buffer
|
||||
|
||||
/**
|
||||
* Returns the unencoded pixel data, top-to-bottom. On little-endian (most)
|
||||
* systems, the array will be ordered BGRA; on big-endian systems, it will
|
||||
* be ARGB.
|
||||
*/
|
||||
toBuffer(mimeType: 'raw'): Buffer
|
||||
|
||||
createPNGStream(config?: PngConfig): PNGStream
|
||||
createJPEGStream(config?: JpegConfig): JPEGStream
|
||||
createPDFStream(config?: PdfConfig): PDFStream
|
||||
|
||||
/** Defaults to PNG image. */
|
||||
toDataURL(): string
|
||||
toDataURL(mimeType: 'image/png'): string
|
||||
toDataURL(mimeType: 'image/jpeg', quality?: number): string
|
||||
/** _Non-standard._ Defaults to PNG image. */
|
||||
toDataURL(cb: (err: Error|null, result: string) => void): void
|
||||
/** _Non-standard._ */
|
||||
toDataURL(mimeType: 'image/png', cb: (err: Error|null, result: string) => void): void
|
||||
/** _Non-standard._ */
|
||||
toDataURL(mimeType: 'image/jpeg', cb: (err: Error|null, result: string) => void): void
|
||||
/** _Non-standard._ */
|
||||
toDataURL(mimeType: 'image/jpeg', config: JpegConfig, cb: (err: Error|null, result: string) => void): void
|
||||
/** _Non-standard._ */
|
||||
toDataURL(mimeType: 'image/jpeg', quality: number, cb: (err: Error|null, result: string) => void): void
|
||||
}
|
||||
|
||||
export interface TextMetrics {
|
||||
readonly alphabeticBaseline: number;
|
||||
readonly actualBoundingBoxAscent: number;
|
||||
readonly actualBoundingBoxDescent: number;
|
||||
readonly actualBoundingBoxLeft: number;
|
||||
readonly actualBoundingBoxRight: number;
|
||||
readonly emHeightAscent: number;
|
||||
readonly emHeightDescent: number;
|
||||
readonly fontBoundingBoxAscent: number;
|
||||
readonly fontBoundingBoxDescent: number;
|
||||
readonly width: number;
|
||||
}
|
||||
|
||||
export type CanvasFillRule = 'evenodd' | 'nonzero';
|
||||
|
||||
export type GlobalCompositeOperation =
|
||||
| 'clear'
|
||||
| 'copy'
|
||||
| 'destination'
|
||||
| 'source-over'
|
||||
| 'destination-over'
|
||||
| 'source-in'
|
||||
| 'destination-in'
|
||||
| 'source-out'
|
||||
| 'destination-out'
|
||||
| 'source-atop'
|
||||
| 'destination-atop'
|
||||
| 'xor'
|
||||
| 'lighter'
|
||||
| 'normal'
|
||||
| 'multiply'
|
||||
| 'screen'
|
||||
| 'overlay'
|
||||
| 'darken'
|
||||
| 'lighten'
|
||||
| 'color-dodge'
|
||||
| 'color-burn'
|
||||
| 'hard-light'
|
||||
| 'soft-light'
|
||||
| 'difference'
|
||||
| 'exclusion'
|
||||
| 'hue'
|
||||
| 'saturation'
|
||||
| 'color'
|
||||
| 'luminosity'
|
||||
| 'saturate';
|
||||
|
||||
export type CanvasLineCap = 'butt' | 'round' | 'square';
|
||||
|
||||
export type CanvasLineJoin = 'bevel' | 'miter' | 'round';
|
||||
|
||||
export type CanvasTextBaseline = 'alphabetic' | 'bottom' | 'hanging' | 'ideographic' | 'middle' | 'top';
|
||||
|
||||
export type CanvasTextAlign = 'center' | 'end' | 'left' | 'right' | 'start';
|
||||
|
||||
export class CanvasRenderingContext2D {
|
||||
drawImage(image: Canvas|Image, dx: number, dy: number): void
|
||||
drawImage(image: Canvas|Image, dx: number, dy: number, dw: number, dh: number): void
|
||||
drawImage(image: Canvas|Image, sx: number, sy: number, sw: number, sh: number, dx: number, dy: number, dw: number, dh: number): void
|
||||
putImageData(imagedata: ImageData, dx: number, dy: number): void;
|
||||
putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX: number, dirtyY: number, dirtyWidth: number, dirtyHeight: number): void;
|
||||
getImageData(sx: number, sy: number, sw: number, sh: number): ImageData;
|
||||
createImageData(sw: number, sh: number): ImageData;
|
||||
createImageData(imagedata: ImageData): ImageData;
|
||||
/**
|
||||
* For PDF canvases, adds another page. If width and/or height are omitted,
|
||||
* the canvas's initial size is used.
|
||||
*/
|
||||
addPage(width?: number, height?: number): void
|
||||
save(): void;
|
||||
restore(): void;
|
||||
rotate(angle: number): void;
|
||||
translate(x: number, y: number): void;
|
||||
transform(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
||||
getTransform(): DOMMatrix;
|
||||
resetTransform(): void;
|
||||
setTransform(transform?: DOMMatrix): void;
|
||||
setTransform(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
||||
isPointInPath(x: number, y: number, fillRule?: CanvasFillRule): boolean;
|
||||
scale(x: number, y: number): void;
|
||||
clip(fillRule?: CanvasFillRule): void;
|
||||
fill(fillRule?: CanvasFillRule): void;
|
||||
stroke(): void;
|
||||
fillText(text: string, x: number, y: number, maxWidth?: number): void;
|
||||
strokeText(text: string, x: number, y: number, maxWidth?: number): void;
|
||||
fillRect(x: number, y: number, w: number, h: number): void;
|
||||
strokeRect(x: number, y: number, w: number, h: number): void;
|
||||
clearRect(x: number, y: number, w: number, h: number): void;
|
||||
rect(x: number, y: number, w: number, h: number): void;
|
||||
roundRect(x: number, y: number, w: number, h: number, radii?: number | number[]): void;
|
||||
measureText(text: string): TextMetrics;
|
||||
moveTo(x: number, y: number): void;
|
||||
lineTo(x: number, y: number): void;
|
||||
bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void;
|
||||
quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
|
||||
beginPath(): void;
|
||||
closePath(): void;
|
||||
arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void;
|
||||
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void;
|
||||
ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void;
|
||||
setLineDash(segments: number[]): void;
|
||||
getLineDash(): number[];
|
||||
createPattern(image: Canvas|Image, repetition: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat' | '' | null): CanvasPattern
|
||||
createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient;
|
||||
createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient;
|
||||
beginTag(tagName: string, attributes?: string): void;
|
||||
endTag(tagName: string): void;
|
||||
/**
|
||||
* _Non-standard_. Defaults to 'good'. Affects pattern (gradient, image,
|
||||
* etc.) rendering quality.
|
||||
*/
|
||||
patternQuality: 'fast' | 'good' | 'best' | 'nearest' | 'bilinear'
|
||||
imageSmoothingEnabled: boolean;
|
||||
globalCompositeOperation: GlobalCompositeOperation;
|
||||
globalAlpha: number;
|
||||
shadowColor: string;
|
||||
miterLimit: number;
|
||||
lineWidth: number;
|
||||
lineCap: CanvasLineCap;
|
||||
lineJoin: CanvasLineJoin;
|
||||
lineDashOffset: number;
|
||||
shadowOffsetX: number;
|
||||
shadowOffsetY: number;
|
||||
shadowBlur: number;
|
||||
/** _Non-standard_. Sets the antialiasing mode. */
|
||||
antialias: 'default' | 'gray' | 'none' | 'subpixel'
|
||||
/**
|
||||
* Defaults to 'path'. The effect depends on the canvas type:
|
||||
*
|
||||
* * **Standard (image)** `'glyph'` and `'path'` both result in rasterized
|
||||
* text. Glyph mode is faster than path, but may result in lower-quality
|
||||
* text, especially when rotated or translated.
|
||||
*
|
||||
* * **PDF** `'glyph'` will embed text instead of paths into the PDF. This
|
||||
* is faster to encode, faster to open with PDF viewers, yields a smaller
|
||||
* file size and makes the text selectable. The subset of the font needed
|
||||
* to render the glyphs will be embedded in the PDF. This is usually the
|
||||
* mode you want to use with PDF canvases.
|
||||
*
|
||||
* * **SVG** glyph does not cause `<text>` elements to be produced as one
|
||||
* might expect ([cairo bug](https://gitlab.freedesktop.org/cairo/cairo/issues/253)).
|
||||
* Rather, glyph will create a `<defs>` section with a `<symbol>` for each
|
||||
* glyph, then those glyphs be reused via `<use>` elements. `'path'` mode
|
||||
* creates a `<path>` element for each text string. glyph mode is faster
|
||||
* and yields a smaller file size.
|
||||
*
|
||||
* In glyph mode, `ctx.strokeText()` and `ctx.fillText()` behave the same
|
||||
* (aside from using the stroke and fill style, respectively).
|
||||
*/
|
||||
textDrawingMode: 'path' | 'glyph'
|
||||
/**
|
||||
* _Non-standard_. Defaults to 'good'. Like `patternQuality`, but applies to
|
||||
* transformations affecting more than just patterns.
|
||||
*/
|
||||
quality: 'fast' | 'good' | 'best' | 'nearest' | 'bilinear'
|
||||
/** Returns or sets a `DOMMatrix` for the current transformation matrix. */
|
||||
currentTransform: DOMMatrix
|
||||
fillStyle: string | CanvasGradient | CanvasPattern;
|
||||
strokeStyle: string | CanvasGradient | CanvasPattern;
|
||||
font: string;
|
||||
textBaseline: CanvasTextBaseline;
|
||||
textAlign: CanvasTextAlign;
|
||||
canvas: Canvas;
|
||||
direction: 'ltr' | 'rtl';
|
||||
}
|
||||
|
||||
export class CanvasGradient {
|
||||
addColorStop(offset: number, color: string): void;
|
||||
}
|
||||
|
||||
export class CanvasPattern {
|
||||
setTransform(transform?: DOMMatrix): void;
|
||||
}
|
||||
|
||||
// This does not extend HTMLImageElement because there are dozens of inherited
|
||||
// methods and properties that we do not provide.
|
||||
export class Image {
|
||||
/** Track image data */
|
||||
static readonly MODE_IMAGE: number
|
||||
/** Track MIME data */
|
||||
static readonly MODE_MIME: number
|
||||
|
||||
/**
|
||||
* The URL, `data:` URI or local file path of the image to be loaded, or a
|
||||
* Buffer instance containing an encoded image.
|
||||
*/
|
||||
src: string | Buffer
|
||||
/** Retrieves whether the object is fully loaded. */
|
||||
readonly complete: boolean
|
||||
/** Sets or retrieves the height of the image. */
|
||||
height: number
|
||||
/** Sets or retrieves the width of the image. */
|
||||
width: number
|
||||
|
||||
/** The original height of the image resource before sizing. */
|
||||
readonly naturalHeight: number
|
||||
/** The original width of the image resource before sizing. */
|
||||
readonly naturalWidth: number
|
||||
/**
|
||||
* Applies to JPEG images drawn to PDF canvases only. Setting
|
||||
* `img.dataMode = Image.MODE_MIME` or `Image.MODE_MIME|Image.MODE_IMAGE`
|
||||
* enables image MIME data tracking. When MIME data is tracked, PDF canvases
|
||||
* can embed JPEGs directly into the output, rather than re-encoding into
|
||||
* PNG. This can drastically reduce filesize and speed up rendering.
|
||||
*/
|
||||
dataMode: number
|
||||
|
||||
onload: (() => void) | null;
|
||||
onerror: ((err: Error) => void) | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Canvas instance. This function works in both Node.js and Web
|
||||
* browsers, where there is no Canvas constructor.
|
||||
* @param type Optionally specify to create a PDF or SVG canvas. Defaults to an
|
||||
* image canvas.
|
||||
*/
|
||||
export function createCanvas(width: number, height: number, type?: 'pdf'|'svg'): Canvas
|
||||
|
||||
/**
|
||||
* Creates an ImageData instance. This function works in both Node.js and Web
|
||||
* browsers.
|
||||
* @param data An array containing the pixel representation of the image.
|
||||
* @param height If omitted, the height is calculated based on the array's size
|
||||
* and `width`.
|
||||
*/
|
||||
export function createImageData(data: Uint8ClampedArray, width: number, height?: number): ImageData
|
||||
/**
|
||||
* _Non-standard._ Creates an ImageData instance for an alternative pixel
|
||||
* format, such as RGB16_565
|
||||
* @param data An array containing the pixel representation of the image.
|
||||
* @param height If omitted, the height is calculated based on the array's size
|
||||
* and `width`.
|
||||
*/
|
||||
export function createImageData(data: Uint16Array, width: number, height?: number): ImageData
|
||||
/**
|
||||
* Creates an ImageData instance. This function works in both Node.js and Web
|
||||
* browsers.
|
||||
*/
|
||||
export function createImageData(width: number, height: number): ImageData
|
||||
|
||||
/**
|
||||
* Convenience function for loading an image with a Promise interface. This
|
||||
* function works in both Node.js and Web browsers; however, the `src` must be
|
||||
* a string in Web browsers (it can only be a Buffer in Node.js).
|
||||
* @param src URL, `data: ` URI or (Node.js only) a local file path or Buffer
|
||||
* instance.
|
||||
*/
|
||||
export function loadImage(src: string|Buffer, options?: any): Promise<Image>
|
||||
|
||||
/**
|
||||
* Registers a font that is not installed as a system font. This must be used
|
||||
* before creating Canvas instances.
|
||||
* @param path Path to local font file.
|
||||
* @param fontFace Description of the font face, corresponding to CSS properties
|
||||
* used in `@font-face` rules.
|
||||
*/
|
||||
export function registerFont(path: string, fontFace: {family: string, weight?: string, style?: string}): void
|
||||
|
||||
/**
|
||||
* Unloads all fonts
|
||||
*/
|
||||
export function deregisterAllFonts(): void;
|
||||
|
||||
/** This class must not be constructed directly; use `canvas.createPNGStream()`. */
|
||||
export class PNGStream extends Readable {}
|
||||
/** This class must not be constructed directly; use `canvas.createJPEGStream()`. */
|
||||
export class JPEGStream extends Readable {}
|
||||
/** This class must not be constructed directly; use `canvas.createPDFStream()`. */
|
||||
export class PDFStream extends Readable {}
|
||||
|
||||
// TODO: this is wrong. See matrixTransform in lib/DOMMatrix.js
|
||||
type DOMMatrixInit = DOMMatrix | string | number[];
|
||||
|
||||
interface DOMPointInit {
|
||||
w?: number;
|
||||
x?: number;
|
||||
y?: number;
|
||||
z?: number;
|
||||
}
|
||||
|
||||
export class DOMPoint {
|
||||
w: number;
|
||||
x: number;
|
||||
y: number;
|
||||
z: number;
|
||||
matrixTransform(matrix?: DOMMatrixInit): DOMPoint;
|
||||
toJSON(): any;
|
||||
static fromPoint(other?: DOMPointInit): DOMPoint;
|
||||
}
|
||||
|
||||
export class DOMMatrix {
|
||||
constructor(init?: string | number[]);
|
||||
toString(): string;
|
||||
multiply(other?: DOMMatrix): DOMMatrix;
|
||||
multiplySelf(other?: DOMMatrix): DOMMatrix;
|
||||
preMultiplySelf(other?: DOMMatrix): DOMMatrix;
|
||||
translate(tx?: number, ty?: number, tz?: number): DOMMatrix;
|
||||
translateSelf(tx?: number, ty?: number, tz?: number): DOMMatrix;
|
||||
scale(scaleX?: number, scaleY?: number, scaleZ?: number, originX?: number, originY?: number, originZ?: number): DOMMatrix;
|
||||
scale3d(scale?: number, originX?: number, originY?: number, originZ?: number): DOMMatrix;
|
||||
scale3dSelf(scale?: number, originX?: number, originY?: number, originZ?: number): DOMMatrix;
|
||||
scaleSelf(scaleX?: number, scaleY?: number, scaleZ?: number, originX?: number, originY?: number, originZ?: number): DOMMatrix;
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
scaleNonUniform(scaleX?: number, scaleY?: number): DOMMatrix;
|
||||
rotateFromVector(x?: number, y?: number): DOMMatrix;
|
||||
rotateFromVectorSelf(x?: number, y?: number): DOMMatrix;
|
||||
rotate(rotX?: number, rotY?: number, rotZ?: number): DOMMatrix;
|
||||
rotateSelf(rotX?: number, rotY?: number, rotZ?: number): DOMMatrix;
|
||||
rotateAxisAngle(x?: number, y?: number, z?: number, angle?: number): DOMMatrix;
|
||||
rotateAxisAngleSelf(x?: number, y?: number, z?: number, angle?: number): DOMMatrix;
|
||||
skewX(sx?: number): DOMMatrix;
|
||||
skewXSelf(sx?: number): DOMMatrix;
|
||||
skewY(sy?: number): DOMMatrix;
|
||||
skewYSelf(sy?: number): DOMMatrix;
|
||||
flipX(): DOMMatrix;
|
||||
flipY(): DOMMatrix;
|
||||
inverse(): DOMMatrix;
|
||||
invertSelf(): DOMMatrix;
|
||||
setMatrixValue(transformList: string): DOMMatrix;
|
||||
transformPoint(point?: DOMPoint): DOMPoint;
|
||||
toJSON(): any;
|
||||
toFloat32Array(): Float32Array;
|
||||
toFloat64Array(): Float64Array;
|
||||
readonly is2D: boolean;
|
||||
readonly isIdentity: boolean;
|
||||
a: number;
|
||||
b: number;
|
||||
c: number;
|
||||
d: number;
|
||||
e: number;
|
||||
f: number;
|
||||
m11: number;
|
||||
m12: number;
|
||||
m13: number;
|
||||
m14: number;
|
||||
m21: number;
|
||||
m22: number;
|
||||
m23: number;
|
||||
m24: number;
|
||||
m31: number;
|
||||
m32: number;
|
||||
m33: number;
|
||||
m34: number;
|
||||
m41: number;
|
||||
m42: number;
|
||||
m43: number;
|
||||
m44: number;
|
||||
static fromMatrix(other: DOMMatrix): DOMMatrix;
|
||||
static fromFloat32Array(a: Float32Array): DOMMatrix;
|
||||
static fromFloat64Array(a: Float64Array): DOMMatrix;
|
||||
}
|
||||
|
||||
export class ImageData {
|
||||
constructor(sw: number, sh: number);
|
||||
constructor(data: Uint8ClampedArray, sw: number, sh?: number);
|
||||
readonly data: Uint8ClampedArray;
|
||||
readonly height: number;
|
||||
readonly width: number;
|
||||
}
|
||||
|
||||
// Not documented: backends
|
||||
|
||||
/** Library version. */
|
||||
export const version: string
|
||||
/** Cairo version. */
|
||||
export const cairoVersion: string
|
||||
/** jpeglib version, if built with JPEG support. */
|
||||
export const jpegVersion: string | undefined
|
||||
/** giflib version, if built with GIF support. */
|
||||
export const gifVersion: string | undefined
|
||||
/** freetype version. */
|
||||
export const freetypeVersion: string
|
||||
/** rsvg version. */
|
||||
export const rsvgVersion: string | undefined
|
||||
@@ -0,0 +1,292 @@
|
||||
/**
|
||||
* @fileoverview Rule to disallow whitespace that is not a tab or space, whitespace inside strings and comments are allowed
|
||||
* @author Jonathan Kingston
|
||||
* @author Christophe Porteneuve
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const astUtils = require("./utils/ast-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Constants
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const ALL_IRREGULARS =
|
||||
/[\f\v\u0085\ufeff\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u202f\u205f\u3000\u2028\u2029]/u;
|
||||
const IRREGULAR_WHITESPACE =
|
||||
/[\f\v\u0085\ufeff\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u202f\u205f\u3000]+/gmu;
|
||||
const IRREGULAR_LINE_TERMINATORS = /[\u2028\u2029]/gmu;
|
||||
const LINE_BREAK = astUtils.createGlobalLinebreakMatcher();
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "problem",
|
||||
|
||||
defaultOptions: [
|
||||
{
|
||||
skipComments: false,
|
||||
skipJSXText: false,
|
||||
skipRegExps: false,
|
||||
skipStrings: true,
|
||||
skipTemplates: false,
|
||||
},
|
||||
],
|
||||
|
||||
docs: {
|
||||
description: "Disallow irregular whitespace",
|
||||
recommended: true,
|
||||
url: "https://eslint.org/docs/latest/rules/no-irregular-whitespace",
|
||||
},
|
||||
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
skipComments: {
|
||||
type: "boolean",
|
||||
},
|
||||
skipStrings: {
|
||||
type: "boolean",
|
||||
},
|
||||
skipTemplates: {
|
||||
type: "boolean",
|
||||
},
|
||||
skipRegExps: {
|
||||
type: "boolean",
|
||||
},
|
||||
skipJSXText: {
|
||||
type: "boolean",
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
|
||||
messages: {
|
||||
noIrregularWhitespace: "Irregular whitespace not allowed.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const [
|
||||
{
|
||||
skipComments,
|
||||
skipStrings,
|
||||
skipRegExps,
|
||||
skipTemplates,
|
||||
skipJSXText,
|
||||
},
|
||||
] = context.options;
|
||||
|
||||
const sourceCode = context.sourceCode;
|
||||
const commentNodes = sourceCode.getAllComments();
|
||||
|
||||
// Module store of errors that we have found
|
||||
let errors = [];
|
||||
|
||||
/**
|
||||
* Removes errors that occur inside the given node
|
||||
* @param {ASTNode} node to check for matching errors.
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
function removeWhitespaceError(node) {
|
||||
const locStart = node.loc.start;
|
||||
const locEnd = node.loc.end;
|
||||
|
||||
errors = errors.filter(
|
||||
({ loc: { start: errorLocStart } }) =>
|
||||
errorLocStart.line < locStart.line ||
|
||||
(errorLocStart.line === locStart.line &&
|
||||
errorLocStart.column < locStart.column) ||
|
||||
(errorLocStart.line === locEnd.line &&
|
||||
errorLocStart.column >= locEnd.column) ||
|
||||
errorLocStart.line > locEnd.line,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks literal nodes for errors that we are choosing to ignore and calls the relevant methods to remove the errors
|
||||
* @param {ASTNode} node to check for matching errors.
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
function removeInvalidNodeErrorsInLiteral(node) {
|
||||
const shouldCheckStrings =
|
||||
skipStrings && typeof node.value === "string";
|
||||
const shouldCheckRegExps = skipRegExps && Boolean(node.regex);
|
||||
|
||||
if (shouldCheckStrings || shouldCheckRegExps) {
|
||||
// If we have irregular characters remove them from the errors list
|
||||
if (ALL_IRREGULARS.test(node.raw)) {
|
||||
removeWhitespaceError(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks template string literal nodes for errors that we are choosing to ignore and calls the relevant methods to remove the errors
|
||||
* @param {ASTNode} node to check for matching errors.
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
function removeInvalidNodeErrorsInTemplateLiteral(node) {
|
||||
if (typeof node.value.raw === "string") {
|
||||
if (ALL_IRREGULARS.test(node.value.raw)) {
|
||||
removeWhitespaceError(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks comment nodes for errors that we are choosing to ignore and calls the relevant methods to remove the errors
|
||||
* @param {ASTNode} node to check for matching errors.
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
function removeInvalidNodeErrorsInComment(node) {
|
||||
if (ALL_IRREGULARS.test(node.value)) {
|
||||
removeWhitespaceError(node);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks JSX nodes for errors that we are choosing to ignore and calls the relevant methods to remove the errors
|
||||
* @param {ASTNode} node to check for matching errors.
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
function removeInvalidNodeErrorsInJSXText(node) {
|
||||
if (ALL_IRREGULARS.test(node.raw)) {
|
||||
removeWhitespaceError(node);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the program source for irregular whitespace
|
||||
* @param {ASTNode} node The program node
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
function checkForIrregularWhitespace(node) {
|
||||
const sourceLines = sourceCode.lines;
|
||||
|
||||
sourceLines.forEach((sourceLine, lineIndex) => {
|
||||
const lineNumber = lineIndex + 1;
|
||||
let match;
|
||||
|
||||
while (
|
||||
(match = IRREGULAR_WHITESPACE.exec(sourceLine)) !== null
|
||||
) {
|
||||
errors.push({
|
||||
node,
|
||||
messageId: "noIrregularWhitespace",
|
||||
loc: {
|
||||
start: {
|
||||
line: lineNumber,
|
||||
column: match.index,
|
||||
},
|
||||
end: {
|
||||
line: lineNumber,
|
||||
column: match.index + match[0].length,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the program source for irregular line terminators
|
||||
* @param {ASTNode} node The program node
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
function checkForIrregularLineTerminators(node) {
|
||||
const source = sourceCode.getText(),
|
||||
sourceLines = sourceCode.lines,
|
||||
linebreaks = source.match(LINE_BREAK);
|
||||
let lastLineIndex = -1,
|
||||
match;
|
||||
|
||||
while ((match = IRREGULAR_LINE_TERMINATORS.exec(source)) !== null) {
|
||||
const lineIndex =
|
||||
linebreaks.indexOf(match[0], lastLineIndex + 1) || 0;
|
||||
|
||||
errors.push({
|
||||
node,
|
||||
messageId: "noIrregularWhitespace",
|
||||
loc: {
|
||||
start: {
|
||||
line: lineIndex + 1,
|
||||
column: sourceLines[lineIndex].length,
|
||||
},
|
||||
end: {
|
||||
line: lineIndex + 2,
|
||||
column: 0,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
lastLineIndex = lineIndex;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A no-op function to act as placeholder for comment accumulation when the `skipComments` option is `false`.
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
function noop() {}
|
||||
|
||||
const nodes = {};
|
||||
|
||||
if (ALL_IRREGULARS.test(sourceCode.getText())) {
|
||||
nodes.Program = function (node) {
|
||||
/*
|
||||
* As we can easily fire warnings for all white space issues with
|
||||
* all the source its simpler to fire them here.
|
||||
* This means we can check all the application code without having
|
||||
* to worry about issues caused in the parser tokens.
|
||||
* When writing this code also evaluating per node was missing out
|
||||
* connecting tokens in some cases.
|
||||
* We can later filter the errors when they are found to be not an
|
||||
* issue in nodes we don't care about.
|
||||
*/
|
||||
checkForIrregularWhitespace(node);
|
||||
checkForIrregularLineTerminators(node);
|
||||
};
|
||||
|
||||
nodes.Literal = removeInvalidNodeErrorsInLiteral;
|
||||
nodes.TemplateElement = skipTemplates
|
||||
? removeInvalidNodeErrorsInTemplateLiteral
|
||||
: noop;
|
||||
nodes.JSXText = skipJSXText
|
||||
? removeInvalidNodeErrorsInJSXText
|
||||
: noop;
|
||||
nodes["Program:exit"] = function () {
|
||||
if (skipComments) {
|
||||
// First strip errors occurring in comment nodes.
|
||||
commentNodes.forEach(removeInvalidNodeErrorsInComment);
|
||||
}
|
||||
|
||||
// If we have any errors remaining report on them
|
||||
errors.forEach(error => context.report(error));
|
||||
};
|
||||
} else {
|
||||
nodes.Program = noop;
|
||||
}
|
||||
|
||||
return nodes;
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user