sdfsdfs
This commit is contained in:
1
node_modules/.bin/miller-rabin
generated
vendored
Symbolic link
1
node_modules/.bin/miller-rabin
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../miller-rabin/bin/miller-rabin
|
1
node_modules/.bin/sha.js
generated
vendored
Symbolic link
1
node_modules/.bin/sha.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../sha.js/bin.js
|
1
node_modules/.bin/shadow-cljs
generated
vendored
Symbolic link
1
node_modules/.bin/shadow-cljs
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../shadow-cljs/cli/runner.js
|
1
node_modules/.bin/which
generated
vendored
Symbolic link
1
node_modules/.bin/which
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../which/bin/which
|
1208
node_modules/.package-lock.json
generated
vendored
Normal file
1208
node_modules/.package-lock.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1053
node_modules/@pixi/colord/README.md
generated
vendored
Normal file
1053
node_modules/@pixi/colord/README.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
103
node_modules/@pixi/colord/colord.d.ts
generated
vendored
Normal file
103
node_modules/@pixi/colord/colord.d.ts
generated
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
import { AnyColor, RgbaColor, HslaColor, HsvaColor } from "./types";
|
||||
export declare class Colord {
|
||||
private readonly parsed;
|
||||
readonly rgba: RgbaColor;
|
||||
constructor(input: AnyColor);
|
||||
/**
|
||||
* Returns a boolean indicating whether or not an input has been parsed successfully.
|
||||
* Note: If parsing is unsuccessful, Colord defaults to black (does not throws an error).
|
||||
*/
|
||||
isValid(): boolean;
|
||||
/**
|
||||
* Returns the brightness of a color (from 0 to 1).
|
||||
* The calculation logic is modified from WCAG.
|
||||
* https://www.w3.org/TR/AERT/#color-contrast
|
||||
*/
|
||||
brightness(): number;
|
||||
/**
|
||||
* Same as calling `brightness() < 0.5`.
|
||||
*/
|
||||
isDark(): boolean;
|
||||
/**
|
||||
* Same as calling `brightness() >= 0.5`.
|
||||
* */
|
||||
isLight(): boolean;
|
||||
/**
|
||||
* Returns the hexadecimal representation of a color.
|
||||
* When the alpha channel value of the color is less than 1,
|
||||
* it outputs #rrggbbaa format instead of #rrggbb.
|
||||
*/
|
||||
toHex(): string;
|
||||
/**
|
||||
* Converts a color to RGB color space and returns an object.
|
||||
* Always includes an alpha value from 0 to 1.
|
||||
*/
|
||||
toRgb(): RgbaColor;
|
||||
/**
|
||||
* Converts a color to RGB color space and returns a string representation.
|
||||
* Outputs an alpha value only if it is less than 1.
|
||||
*/
|
||||
toRgbString(): string;
|
||||
/**
|
||||
* Converts a color to HSL color space and returns an object.
|
||||
* Always includes an alpha value from 0 to 1.
|
||||
*/
|
||||
toHsl(): HslaColor;
|
||||
/**
|
||||
* Converts a color to HSL color space and returns a string representation.
|
||||
* Always includes an alpha value from 0 to 1.
|
||||
*/
|
||||
toHslString(): string;
|
||||
/**
|
||||
* Converts a color to HSV color space and returns an object.
|
||||
* Always includes an alpha value from 0 to 1.
|
||||
*/
|
||||
toHsv(): HsvaColor;
|
||||
/**
|
||||
* Creates a new instance containing an inverted (opposite) version of the color.
|
||||
*/
|
||||
invert(): Colord;
|
||||
/**
|
||||
* Increases the HSL saturation of a color by the given amount.
|
||||
*/
|
||||
saturate(amount?: number): Colord;
|
||||
/**
|
||||
* Decreases the HSL saturation of a color by the given amount.
|
||||
*/
|
||||
desaturate(amount?: number): Colord;
|
||||
/**
|
||||
* Makes a gray color with the same lightness as a source color.
|
||||
*/
|
||||
grayscale(): Colord;
|
||||
/**
|
||||
* Increases the HSL lightness of a color by the given amount.
|
||||
*/
|
||||
lighten(amount?: number): Colord;
|
||||
/**
|
||||
* Increases the HSL lightness of a color by the given amount.
|
||||
*/
|
||||
darken(amount?: number): Colord;
|
||||
/**
|
||||
* Changes the HSL hue of a color by the given amount.
|
||||
*/
|
||||
rotate(amount?: number): Colord;
|
||||
/**
|
||||
* Allows to get or change an alpha channel value.
|
||||
*/
|
||||
alpha(): number;
|
||||
alpha(value: number): Colord;
|
||||
/**
|
||||
* Allows to get or change a hue value.
|
||||
*/
|
||||
hue(): number;
|
||||
hue(value: number): Colord;
|
||||
/**
|
||||
* Determines whether two values are the same color.
|
||||
*/
|
||||
isEqual(color: AnyColor | Colord): boolean;
|
||||
}
|
||||
/**
|
||||
* Parses the given input color and creates a new `Colord` instance.
|
||||
* See accepted input formats: https://github.com/omgovich/colord#color-parsing
|
||||
*/
|
||||
export declare const colord: (input: AnyColor | Colord) => Colord;
|
10
node_modules/@pixi/colord/constants.d.ts
generated
vendored
Normal file
10
node_modules/@pixi/colord/constants.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* We used to work with 2 digits after the decimal point, but it wasn't accurate enough,
|
||||
* so the library produced colors that were perceived differently.
|
||||
*/
|
||||
export declare const ALPHA_PRECISION = 3;
|
||||
/**
|
||||
* Valid CSS <angle> units.
|
||||
* https://developer.mozilla.org/en-US/docs/Web/CSS/angle
|
||||
*/
|
||||
export declare const ANGLE_UNITS: Record<string, number>;
|
4
node_modules/@pixi/colord/extend.d.ts
generated
vendored
Normal file
4
node_modules/@pixi/colord/extend.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import { Colord } from "./colord";
|
||||
import { Parsers } from "./types";
|
||||
export declare type Plugin = (ColordClass: typeof Colord, parsers: Parsers) => void;
|
||||
export declare const extend: (plugins: Plugin[]) => void;
|
20
node_modules/@pixi/colord/helpers.d.ts
generated
vendored
Normal file
20
node_modules/@pixi/colord/helpers.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
export declare const isPresent: (value: unknown) => boolean;
|
||||
export declare const round: (number: number, digits?: number, base?: number) => number;
|
||||
export declare const floor: (number: number, digits?: number, base?: number) => number;
|
||||
/**
|
||||
* Clamps a value between an upper and lower bound.
|
||||
* We use ternary operators because it makes the minified code
|
||||
* is 2 times shorter then `Math.min(Math.max(a,b),c)`
|
||||
* NaN is clamped to the lower bound
|
||||
*/
|
||||
export declare const clamp: (number: number, min?: number, max?: number) => number;
|
||||
/**
|
||||
* Processes and clamps a degree (angle) value properly.
|
||||
* Any `NaN` or `Infinity` will be converted to `0`.
|
||||
* Examples: -1 => 359, 361 => 1
|
||||
*/
|
||||
export declare const clampHue: (degrees: number) => number;
|
||||
/**
|
||||
* Converts a hue value to degrees from 0 to 360 inclusive.
|
||||
*/
|
||||
export declare const parseHue: (value: string, unit?: string) => number;
|
5
node_modules/@pixi/colord/index.d.ts
generated
vendored
Normal file
5
node_modules/@pixi/colord/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export { colord, Colord } from "./colord";
|
||||
export { extend, Plugin } from "./extend";
|
||||
export { getFormat } from "./parse";
|
||||
export { random } from "./random";
|
||||
export { HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, LabColor, LabaColor, LchColor, LchaColor, RgbColor, RgbaColor, XyzColor, XyzaColor, AnyColor, } from "./types";
|
1
node_modules/@pixi/colord/index.js
generated
vendored
Normal file
1
node_modules/@pixi/colord/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/@pixi/colord/index.mjs
generated
vendored
Normal file
1
node_modules/@pixi/colord/index.mjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
254
node_modules/@pixi/colord/package.json
generated
vendored
Normal file
254
node_modules/@pixi/colord/package.json
generated
vendored
Normal file
@@ -0,0 +1,254 @@
|
||||
{
|
||||
"name": "@pixi/colord",
|
||||
"version": "2.9.6",
|
||||
"description": "👑 A tiny yet powerful tool for high-performance color manipulations and conversions",
|
||||
"keywords": [
|
||||
"color",
|
||||
"parser",
|
||||
"convert",
|
||||
"tiny",
|
||||
"hex",
|
||||
"rgb",
|
||||
"hsl",
|
||||
"hsv",
|
||||
"hwb",
|
||||
"lab",
|
||||
"lch",
|
||||
"xyz",
|
||||
"css",
|
||||
"color-names",
|
||||
"a11y",
|
||||
"cmyk",
|
||||
"mix",
|
||||
"minify",
|
||||
"harmonies"
|
||||
],
|
||||
"repository": "omgovich/colord",
|
||||
"author": "Vlad Shilov <omgovich@ya.ru>",
|
||||
"license": "MIT",
|
||||
"sideEffects": false,
|
||||
"main": "./index.js",
|
||||
"module": "./index.mjs",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./index.mjs"
|
||||
},
|
||||
"require": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./index.js"
|
||||
}
|
||||
},
|
||||
"./plugins/a11y": {
|
||||
"import": {
|
||||
"types": "./plugins/a11y.d.ts",
|
||||
"default": "./plugins/a11y.mjs"
|
||||
},
|
||||
"require": {
|
||||
"types": "./plugins/a11y.d.ts",
|
||||
"default": "./plugins/a11y.js"
|
||||
}
|
||||
},
|
||||
"./plugins/cmyk": {
|
||||
"import": {
|
||||
"types": "./plugins/cmyk.d.ts",
|
||||
"default": "./plugins/cmyk.mjs"
|
||||
},
|
||||
"require": {
|
||||
"types": "./plugins/cmyk.d.ts",
|
||||
"default": "./plugins/cmyk.js"
|
||||
}
|
||||
},
|
||||
"./plugins/harmonies": {
|
||||
"import": {
|
||||
"types": "./plugins/harmonies.d.ts",
|
||||
"default": "./plugins/harmonies.mjs"
|
||||
},
|
||||
"require": {
|
||||
"types": "./plugins/harmonies.d.ts",
|
||||
"default": "./plugins/harmonies.js"
|
||||
}
|
||||
},
|
||||
"./plugins/hwb": {
|
||||
"import": {
|
||||
"types": "./plugins/hwb.d.ts",
|
||||
"default": "./plugins/hwb.mjs"
|
||||
},
|
||||
"require": {
|
||||
"types": "./plugins/hwb.d.ts",
|
||||
"default": "./plugins/hwb.js"
|
||||
}
|
||||
},
|
||||
"./plugins/lab": {
|
||||
"import": {
|
||||
"types": "./plugins/lab.d.ts",
|
||||
"default": "./plugins/lab.mjs"
|
||||
},
|
||||
"require": {
|
||||
"types": "./plugins/lab.d.ts",
|
||||
"default": "./plugins/lab.js"
|
||||
}
|
||||
},
|
||||
"./plugins/lch": {
|
||||
"import": {
|
||||
"types": "./plugins/lch.d.ts",
|
||||
"default": "./plugins/lch.mjs"
|
||||
},
|
||||
"require": {
|
||||
"types": "./plugins/lch.d.ts",
|
||||
"default": "./plugins/lch.js"
|
||||
}
|
||||
},
|
||||
"./plugins/minify": {
|
||||
"import": {
|
||||
"types": "./plugins/minify.d.ts",
|
||||
"default": "./plugins/minify.mjs"
|
||||
},
|
||||
"require": {
|
||||
"types": "./plugins/minify.d.ts",
|
||||
"default": "./plugins/minify.js"
|
||||
}
|
||||
},
|
||||
"./plugins/mix": {
|
||||
"import": {
|
||||
"types": "./plugins/mix.d.ts",
|
||||
"default": "./plugins/mix.mjs"
|
||||
},
|
||||
"require": {
|
||||
"types": "./plugins/mix.d.ts",
|
||||
"default": "./plugins/mix.js"
|
||||
}
|
||||
},
|
||||
"./plugins/names": {
|
||||
"import": {
|
||||
"types": "./plugins/names.d.ts",
|
||||
"default": "./plugins/names.mjs"
|
||||
},
|
||||
"require": {
|
||||
"types": "./plugins/names.d.ts",
|
||||
"default": "./plugins/names.js"
|
||||
}
|
||||
},
|
||||
"./plugins/xyz": {
|
||||
"import": {
|
||||
"types": "./plugins/xyz.d.ts",
|
||||
"default": "./plugins/xyz.mjs"
|
||||
},
|
||||
"require": {
|
||||
"types": "./plugins/xyz.d.ts",
|
||||
"default": "./plugins/xyz.js"
|
||||
}
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"files": [
|
||||
"*.{js,mjs,ts,map}",
|
||||
"plugins/*.{js,mjs,ts,map}"
|
||||
],
|
||||
"types": "index.d.ts",
|
||||
"scripts": {
|
||||
"lint": "eslint src/**/*.ts",
|
||||
"size": "npm run build && size-limit",
|
||||
"check-types": "tsc --noEmit true",
|
||||
"test": "jest tests --coverage",
|
||||
"benchmark": "tsc --outDir bench --skipLibCheck --esModuleInterop ./tests/benchmark.ts && node ./bench/tests/benchmark.js && rm -rf ./bench",
|
||||
"build": "rollup --config",
|
||||
"release": "npm run build && cp *.json dist && cp *.md dist && npm publish dist",
|
||||
"check-release": "npm run release -- --dry-run"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@size-limit/preset-small-lib": "^4.10.1",
|
||||
"@types/jest": "^26.0.22",
|
||||
"@typescript-eslint/eslint-plugin": "^4.19.0",
|
||||
"@typescript-eslint/parser": "^4.19.0",
|
||||
"ac-colors": "^1.4.2",
|
||||
"benny": "^3.6.15",
|
||||
"chroma-js": "^2.1.1",
|
||||
"color": "^3.1.3",
|
||||
"eslint": "^7.14.0",
|
||||
"eslint-config-prettier": "^6.15.0",
|
||||
"eslint-plugin-prettier": "^3.1.4",
|
||||
"glob": "^7.1.6",
|
||||
"jest": "^26.6.3",
|
||||
"prettier": "^2.2.0",
|
||||
"rollup": "^2.43.1",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"rollup-plugin-typescript2": "^0.30.0",
|
||||
"size-limit": "^4.10.1",
|
||||
"tinycolor2": "^1.4.2",
|
||||
"ts-jest": "^26.5.4",
|
||||
"ts-node": "^9.1.1",
|
||||
"tslib": "^2.6.2",
|
||||
"typescript": "^4.2.3"
|
||||
},
|
||||
"jest": {
|
||||
"verbose": true,
|
||||
"transform": {
|
||||
"^.+\\.ts$": "ts-jest"
|
||||
}
|
||||
},
|
||||
"eslintConfig": {
|
||||
"plugins": [
|
||||
"prettier"
|
||||
],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:prettier/recommended",
|
||||
"prettier/@typescript-eslint"
|
||||
]
|
||||
},
|
||||
"prettier": {
|
||||
"printWidth": 100
|
||||
},
|
||||
"size-limit": [
|
||||
{
|
||||
"path": "dist/index.mjs",
|
||||
"import": "{ colord }",
|
||||
"limit": "2 KB"
|
||||
},
|
||||
{
|
||||
"path": "dist/plugins/a11y.mjs",
|
||||
"limit": "0.5 KB"
|
||||
},
|
||||
{
|
||||
"path": "dist/plugins/cmyk.mjs",
|
||||
"limit": "1 KB"
|
||||
},
|
||||
{
|
||||
"path": "dist/plugins/harmonies.mjs",
|
||||
"limit": "0.5 KB"
|
||||
},
|
||||
{
|
||||
"path": "dist/plugins/hwb.mjs",
|
||||
"limit": "1 KB"
|
||||
},
|
||||
{
|
||||
"path": "dist/plugins/lab.mjs",
|
||||
"limit": "1.5 KB"
|
||||
},
|
||||
{
|
||||
"path": "dist/plugins/lch.mjs",
|
||||
"limit": "1.5 KB"
|
||||
},
|
||||
{
|
||||
"path": "dist/plugins/minify.mjs",
|
||||
"limit": "0.6 KB"
|
||||
},
|
||||
{
|
||||
"path": "dist/plugins/mix.mjs",
|
||||
"limit": "1 KB"
|
||||
},
|
||||
{
|
||||
"path": "dist/plugins/names.mjs",
|
||||
"limit": "1.5 KB"
|
||||
},
|
||||
{
|
||||
"path": "dist/plugins/xyz.mjs",
|
||||
"limit": "1 KB"
|
||||
}
|
||||
]
|
||||
}
|
8
node_modules/@pixi/colord/parse.d.ts
generated
vendored
Normal file
8
node_modules/@pixi/colord/parse.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { Parsers, ParseResult, Input, Format } from "./types";
|
||||
export declare const parsers: Parsers;
|
||||
/** Tries to convert an incoming value into RGBA color by going through all color model parsers */
|
||||
export declare const parse: (input: Input) => ParseResult | [null, undefined];
|
||||
/**
|
||||
* Returns a color model name for the input passed to the function.
|
||||
*/
|
||||
export declare const getFormat: (input: Input) => Format | undefined;
|
38
node_modules/@pixi/colord/plugins/a11y.d.ts
generated
vendored
Normal file
38
node_modules/@pixi/colord/plugins/a11y.d.ts
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
import { AnyColor } from "../types";
|
||||
import { Plugin } from "../extend";
|
||||
interface ReadabilityOptions {
|
||||
level?: "AA" | "AAA";
|
||||
size?: "normal" | "large";
|
||||
}
|
||||
declare module "../colord" {
|
||||
interface Colord {
|
||||
/**
|
||||
* Returns the relative luminance of a color,
|
||||
* normalized to 0 for darkest black and 1 for lightest white.
|
||||
* https://www.w3.org/TR/WCAG20/#relativeluminancedef
|
||||
* https://developer.mozilla.org/en-US/docs/Web/Accessibility/Understanding_Colors_and_Luminance
|
||||
*/
|
||||
luminance(): number;
|
||||
/**
|
||||
* Calculates a contrast ratio for a color pair.
|
||||
* This luminance difference is expressed as a ratio ranging
|
||||
* from 1 (e.g. white on white) to 21 (e.g., black on a white).
|
||||
* WCAG requires a ratio of at least 4.5 for normal text and 3 for large text.
|
||||
* https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html
|
||||
* https://webaim.org/articles/contrast/
|
||||
*/
|
||||
contrast(color2?: AnyColor | Colord): number;
|
||||
/**
|
||||
* Checks that a background and text color pair conforms to WCAG 2.0 requirements.
|
||||
* https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html
|
||||
*/
|
||||
isReadable(color2?: AnyColor | Colord, options?: ReadabilityOptions): boolean;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A plugin adding accessibility and color contrast utilities.
|
||||
* Follows Web Content Accessibility Guidelines 2.0.
|
||||
* https://www.w3.org/TR/WCAG20/
|
||||
*/
|
||||
declare const a11yPlugin: Plugin;
|
||||
export default a11yPlugin;
|
1
node_modules/@pixi/colord/plugins/a11y.js
generated
vendored
Normal file
1
node_modules/@pixi/colord/plugins/a11y.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var o=function(o){var t=o/255;return t<.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},t=function(t){return.2126*o(t.r)+.7152*o(t.g)+.0722*o(t.b)};module.exports=function(o){o.prototype.luminance=function(){return o=t(this.rgba),void 0===(r=2)&&(r=0),void 0===n&&(n=Math.pow(10,r)),Math.round(n*o)/n+0;var o,r,n},o.prototype.contrast=function(r){void 0===r&&(r="#FFF");var n,i,a,e,v,u,d,c=r instanceof o?r:new o(r);return e=this.rgba,v=c.toRgb(),u=t(e),d=t(v),n=u>d?(u+.05)/(d+.05):(d+.05)/(u+.05),void 0===(i=2)&&(i=0),void 0===a&&(a=Math.pow(10,i)),Math.floor(a*n)/a+0},o.prototype.isReadable=function(o,t){return void 0===o&&(o="#FFF"),void 0===t&&(t={}),this.contrast(o)>=(e=void 0===(a=(r=t).size)?"normal":a,"AAA"===(i=void 0===(n=r.level)?"AA":n)&&"normal"===e?7:"AA"===i&&"large"===e?3:4.5);var r,n,i,a,e}};
|
1
node_modules/@pixi/colord/plugins/a11y.mjs
generated
vendored
Normal file
1
node_modules/@pixi/colord/plugins/a11y.mjs
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var o=function(o){var t=o/255;return t<.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},t=function(t){return.2126*o(t.r)+.7152*o(t.g)+.0722*o(t.b)};export default function(o){o.prototype.luminance=function(){return o=t(this.rgba),void 0===(r=2)&&(r=0),void 0===n&&(n=Math.pow(10,r)),Math.round(n*o)/n+0;var o,r,n},o.prototype.contrast=function(r){void 0===r&&(r="#FFF");var n,a,i,e,v,u,d,c=r instanceof o?r:new o(r);return e=this.rgba,v=c.toRgb(),u=t(e),d=t(v),n=u>d?(u+.05)/(d+.05):(d+.05)/(u+.05),void 0===(a=2)&&(a=0),void 0===i&&(i=Math.pow(10,a)),Math.floor(i*n)/i+0},o.prototype.isReadable=function(o,t){return void 0===o&&(o="#FFF"),void 0===t&&(t={}),this.contrast(o)>=(e=void 0===(i=(r=t).size)?"normal":i,"AAA"===(a=void 0===(n=r.level)?"AA":n)&&"normal"===e?7:"AA"===a&&"large"===e?3:4.5);var r,n,a,i,e}}
|
24
node_modules/@pixi/colord/plugins/cmyk.d.ts
generated
vendored
Normal file
24
node_modules/@pixi/colord/plugins/cmyk.d.ts
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import { CmykaColor } from "../types";
|
||||
import { Plugin } from "../extend";
|
||||
declare module "../colord" {
|
||||
interface Colord {
|
||||
/**
|
||||
* Converts a color to CMYK color space and returns an object.
|
||||
* https://drafts.csswg.org/css-color/#cmyk-colors
|
||||
* https://lea.verou.me/2009/03/cmyk-colors-in-css-useful-or-useless/
|
||||
*/
|
||||
toCmyk(): CmykaColor;
|
||||
/**
|
||||
* Converts a color to CMYK color space and returns a string.
|
||||
* https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/device-cmyk()
|
||||
*/
|
||||
toCmykString(): string;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A plugin adding support for CMYK color space.
|
||||
* https://lea.verou.me/2009/03/cmyk-colors-in-css-useful-or-useless/
|
||||
* https://en.wikipedia.org/wiki/CMYK_color_model
|
||||
*/
|
||||
declare const cmykPlugin: Plugin;
|
||||
export default cmykPlugin;
|
1
node_modules/@pixi/colord/plugins/cmyk.js
generated
vendored
Normal file
1
node_modules/@pixi/colord/plugins/cmyk.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var r=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},n=function(r,n,t){return void 0===n&&(n=0),void 0===t&&(t=Math.pow(10,n)),Math.round(t*r)/t+0},t=function(r,n,t){return void 0===n&&(n=0),void 0===t&&(t=1),r>t?t:r>n?r:n},u=function(r){return{c:t(r.c,0,100),m:t(r.m,0,100),y:t(r.y,0,100),k:t(r.k,0,100),a:t(r.a)}},e=function(r){return{c:n(r.c,2),m:n(r.m,2),y:n(r.y,2),k:n(r.k,2),a:n(r.a,3)}};function c(r){return{r:n(255*(1-r.c/100)*(1-r.k/100)),g:n(255*(1-r.m/100)*(1-r.k/100)),b:n(255*(1-r.y/100)*(1-r.k/100)),a:r.a}}function o(r){var t=1-Math.max(r.r/255,r.g/255,r.b/255),u=(1-r.r/255-t)/(1-t),e=(1-r.g/255-t)/(1-t),c=(1-r.b/255-t)/(1-t);return{c:isNaN(u)?0:n(100*u),m:isNaN(e)?0:n(100*e),y:isNaN(c)?0:n(100*c),k:n(100*t),a:r.a}}function i(n){var t=n.c,e=n.m,o=n.y,i=n.k,m=n.a,a=void 0===m?1:m;return r(t)&&r(e)&&r(o)&&r(i)?c(u({c:Number(t),m:Number(e),y:Number(o),k:Number(i),a:Number(a)})):null}var m=/^device-cmyk\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,a=function(r){var n=m.exec(r);return n?c(u({c:Number(n[1])*(n[2]?1:100),m:Number(n[3])*(n[4]?1:100),y:Number(n[5])*(n[6]?1:100),k:Number(n[7])*(n[8]?1:100),a:void 0===n[9]?1:Number(n[9])/(n[10]?100:1)})):null};module.exports=function(r,n){r.prototype.toCmyk=function(){return e(o(this.rgba))},r.prototype.toCmykString=function(){return r=e(o(this.rgba)),n=r.c,t=r.m,u=r.y,c=r.k,(i=r.a)<1?"device-cmyk("+n+"% "+t+"% "+u+"% "+c+"% / "+i+")":"device-cmyk("+n+"% "+t+"% "+u+"% "+c+"%)";var r,n,t,u,c,i},n.object.push([i,"cmyk"]),n.string.push([a,"cmyk"])};
|
1
node_modules/@pixi/colord/plugins/cmyk.mjs
generated
vendored
Normal file
1
node_modules/@pixi/colord/plugins/cmyk.mjs
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var r=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},n=function(r,n,t){return void 0===n&&(n=0),void 0===t&&(t=Math.pow(10,n)),Math.round(t*r)/t+0},t=function(r,n,t){return void 0===n&&(n=0),void 0===t&&(t=1),r>t?t:r>n?r:n},u=function(r){return{c:t(r.c,0,100),m:t(r.m,0,100),y:t(r.y,0,100),k:t(r.k,0,100),a:t(r.a)}},e=function(r){return{c:n(r.c,2),m:n(r.m,2),y:n(r.y,2),k:n(r.k,2),a:n(r.a,3)}};function c(r){return{r:n(255*(1-r.c/100)*(1-r.k/100)),g:n(255*(1-r.m/100)*(1-r.k/100)),b:n(255*(1-r.y/100)*(1-r.k/100)),a:r.a}}function i(r){var t=1-Math.max(r.r/255,r.g/255,r.b/255),u=(1-r.r/255-t)/(1-t),e=(1-r.g/255-t)/(1-t),c=(1-r.b/255-t)/(1-t);return{c:isNaN(u)?0:n(100*u),m:isNaN(e)?0:n(100*e),y:isNaN(c)?0:n(100*c),k:n(100*t),a:r.a}}function o(n){var t=n.c,e=n.m,i=n.y,o=n.k,m=n.a,a=void 0===m?1:m;return r(t)&&r(e)&&r(i)&&r(o)?c(u({c:Number(t),m:Number(e),y:Number(i),k:Number(o),a:Number(a)})):null}var m=/^device-cmyk\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,a=function(r){var n=m.exec(r);return n?c(u({c:Number(n[1])*(n[2]?1:100),m:Number(n[3])*(n[4]?1:100),y:Number(n[5])*(n[6]?1:100),k:Number(n[7])*(n[8]?1:100),a:void 0===n[9]?1:Number(n[9])/(n[10]?100:1)})):null};export default function(r,n){r.prototype.toCmyk=function(){return e(i(this.rgba))},r.prototype.toCmykString=function(){return r=e(i(this.rgba)),n=r.c,t=r.m,u=r.y,c=r.k,(o=r.a)<1?"device-cmyk("+n+"% "+t+"% "+u+"% "+c+"% / "+o+")":"device-cmyk("+n+"% "+t+"% "+u+"% "+c+"%)";var r,n,t,u,c,o},n.object.push([o,"cmyk"]),n.string.push([a,"cmyk"])}
|
16
node_modules/@pixi/colord/plugins/harmonies.d.ts
generated
vendored
Normal file
16
node_modules/@pixi/colord/plugins/harmonies.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import { Plugin } from "../extend";
|
||||
export declare type HarmonyType = "analogous" | "complementary" | "double-split-complementary" | "rectangle" | "split-complementary" | "tetradic" | "triadic";
|
||||
declare module "../colord" {
|
||||
interface Colord {
|
||||
/**
|
||||
* Returns an array of harmony colors as `Colord` instances.
|
||||
*/
|
||||
harmonies(type?: HarmonyType): Colord[];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A plugin adding functionality to generate harmony colors.
|
||||
* https://en.wikipedia.org/wiki/Harmony_(color)
|
||||
*/
|
||||
declare const harmoniesPlugin: Plugin;
|
||||
export default harmoniesPlugin;
|
1
node_modules/@pixi/colord/plugins/harmonies.js
generated
vendored
Normal file
1
node_modules/@pixi/colord/plugins/harmonies.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports=function(t){var e={analogous:[-30,0,30],complementary:[0,180],"double-split-complementary":[-30,0,30,150,210],rectangle:[0,60,180,240],tetradic:[0,90,180,270],triadic:[0,120,240],"split-complementary":[0,150,210]};t.prototype.harmonies=function(t){var o=this;return void 0===t&&(t="complementary"),e[t].map(function(t){return o.rotate(t)})}};
|
1
node_modules/@pixi/colord/plugins/harmonies.mjs
generated
vendored
Normal file
1
node_modules/@pixi/colord/plugins/harmonies.mjs
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export default function(t){var e={analogous:[-30,0,30],complementary:[0,180],"double-split-complementary":[-30,0,30,150,210],rectangle:[0,60,180,240],tetradic:[0,90,180,270],triadic:[0,120,240],"split-complementary":[0,150,210]};t.prototype.harmonies=function(t){var r=this;return void 0===t&&(t="complementary"),e[t].map(function(t){return r.rotate(t)})}}
|
23
node_modules/@pixi/colord/plugins/hwb.d.ts
generated
vendored
Normal file
23
node_modules/@pixi/colord/plugins/hwb.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { HwbaColor } from "../types";
|
||||
import { Plugin } from "../extend";
|
||||
declare module "../colord" {
|
||||
interface Colord {
|
||||
/**
|
||||
* Converts a color to HWB (Hue-Whiteness-Blackness) color space and returns an object.
|
||||
* https://en.wikipedia.org/wiki/HWB_color_model
|
||||
*/
|
||||
toHwb(): HwbaColor;
|
||||
/**
|
||||
* Converts a color to HWB (Hue-Whiteness-Blackness) color space and returns a string.
|
||||
* https://www.w3.org/TR/css-color-4/#the-hwb-notation
|
||||
*/
|
||||
toHwbString(): string;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A plugin adding support for HWB (Hue-Whiteness-Blackness) color model.
|
||||
* https://en.wikipedia.org/wiki/HWB_color_model
|
||||
* https://www.w3.org/TR/css-color-4/#the-hwb-notation
|
||||
*/
|
||||
declare const hwbPlugin: Plugin;
|
||||
export default hwbPlugin;
|
1
node_modules/@pixi/colord/plugins/hwb.js
generated
vendored
Normal file
1
node_modules/@pixi/colord/plugins/hwb.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var r={grad:.9,turn:360,rad:360/(2*Math.PI)},n=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},t=function(r,n,t){return void 0===n&&(n=0),void 0===t&&(t=Math.pow(10,n)),Math.round(t*r)/t+0},u=function(r,n,t){return void 0===n&&(n=0),void 0===t&&(t=1),r>t?t:r>n?r:n},a=function(r){return{h:(n=r.h,(n=isFinite(n)?n%360:0)>0?n:n+360),w:u(r.w,0,100),b:u(r.b,0,100),a:u(r.a)};var n},e=function(r){return{h:t(r.h),w:t(r.w),b:t(r.b),a:t(r.a,3)}},o=function(r){return{h:function(r){var n=r.r,t=r.g,u=r.b,a=r.a,e=Math.max(n,t,u),o=e-Math.min(n,t,u),b=o?e===n?(t-u)/o:e===t?2+(u-n)/o:4+(n-t)/o:0;return{h:60*(b<0?b+6:b),s:e?o/e*100:0,v:e/255*100,a:a}}(r).h,w:Math.min(r.r,r.g,r.b)/255*100,b:100-Math.max(r.r,r.g,r.b)/255*100,a:r.a}},b=function(r){return function(r){var n=r.h,t=r.s,u=r.v,a=r.a;n=n/360*6,t/=100,u/=100;var e=Math.floor(n),o=u*(1-t),b=u*(1-(n-e)*t),i=u*(1-(1-n+e)*t),h=e%6;return{r:255*[u,b,o,o,i,u][h],g:255*[i,u,u,b,o,o][h],b:255*[o,o,i,u,u,b][h],a:a}}({h:r.h,s:100===r.b?0:100-r.w/(100-r.b)*100,v:100-r.b,a:r.a})},i=function(r){var t=r.h,u=r.w,e=r.b,o=r.a,i=void 0===o?1:o;if(!n(t)||!n(u)||!n(e))return null;var h=a({h:Number(t),w:Number(u),b:Number(e),a:Number(i)});return b(h)},h=/^hwb\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,d=function(n){var t=h.exec(n);if(!t)return null;var u,e,o=a({h:(u=t[1],e=t[2],void 0===e&&(e="deg"),Number(u)*(r[e]||1)),w:Number(t[3]),b:Number(t[4]),a:void 0===t[5]?1:Number(t[5])/(t[6]?100:1)});return b(o)};module.exports=function(r,n){r.prototype.toHwb=function(){return e(o(this.rgba))},r.prototype.toHwbString=function(){return r=e(o(this.rgba)),n=r.h,t=r.w,u=r.b,(a=r.a)<1?"hwb("+n+" "+t+"% "+u+"% / "+a+")":"hwb("+n+" "+t+"% "+u+"%)";var r,n,t,u,a},n.string.push([d,"hwb"]),n.object.push([i,"hwb"])};
|
1
node_modules/@pixi/colord/plugins/hwb.mjs
generated
vendored
Normal file
1
node_modules/@pixi/colord/plugins/hwb.mjs
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var r={grad:.9,turn:360,rad:360/(2*Math.PI)},t=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},n=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=Math.pow(10,t)),Math.round(n*r)/n+0},u=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),r>n?n:r>t?r:t},a=function(r){return{h:(t=r.h,(t=isFinite(t)?t%360:0)>0?t:t+360),w:u(r.w,0,100),b:u(r.b,0,100),a:u(r.a)};var t},e=function(r){return{h:n(r.h),w:n(r.w),b:n(r.b),a:n(r.a,3)}},b=function(r){return{h:function(r){var t=r.r,n=r.g,u=r.b,a=r.a,e=Math.max(t,n,u),b=e-Math.min(t,n,u),o=b?e===t?(n-u)/b:e===n?2+(u-t)/b:4+(t-n)/b:0;return{h:60*(o<0?o+6:o),s:e?b/e*100:0,v:e/255*100,a:a}}(r).h,w:Math.min(r.r,r.g,r.b)/255*100,b:100-Math.max(r.r,r.g,r.b)/255*100,a:r.a}},o=function(r){return function(r){var t=r.h,n=r.s,u=r.v,a=r.a;t=t/360*6,n/=100,u/=100;var e=Math.floor(t),b=u*(1-n),o=u*(1-(t-e)*n),i=u*(1-(1-t+e)*n),h=e%6;return{r:255*[u,o,b,b,i,u][h],g:255*[i,u,u,o,b,b][h],b:255*[b,b,i,u,u,o][h],a:a}}({h:r.h,s:100===r.b?0:100-r.w/(100-r.b)*100,v:100-r.b,a:r.a})},i=function(r){var n=r.h,u=r.w,e=r.b,b=r.a,i=void 0===b?1:b;if(!t(n)||!t(u)||!t(e))return null;var h=a({h:Number(n),w:Number(u),b:Number(e),a:Number(i)});return o(h)},h=/^hwb\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,d=function(t){var n=h.exec(t);if(!n)return null;var u,e,b=a({h:(u=n[1],e=n[2],void 0===e&&(e="deg"),Number(u)*(r[e]||1)),w:Number(n[3]),b:Number(n[4]),a:void 0===n[5]?1:Number(n[5])/(n[6]?100:1)});return o(b)};export default function(r,t){r.prototype.toHwb=function(){return e(b(this.rgba))},r.prototype.toHwbString=function(){return r=e(b(this.rgba)),t=r.h,n=r.w,u=r.b,(a=r.a)<1?"hwb("+t+" "+n+"% "+u+"% / "+a+")":"hwb("+t+" "+n+"% "+u+"%)";var r,t,n,u,a},t.string.push([d,"hwb"]),t.object.push([i,"hwb"])}
|
23
node_modules/@pixi/colord/plugins/lab.d.ts
generated
vendored
Normal file
23
node_modules/@pixi/colord/plugins/lab.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { LabaColor, AnyColor } from "../types";
|
||||
import { Plugin } from "../extend";
|
||||
declare module "../colord" {
|
||||
interface Colord {
|
||||
/**
|
||||
* Converts a color to CIELAB color space and returns an object.
|
||||
* The object always includes `alpha` value [0, 1].
|
||||
*/
|
||||
toLab(): LabaColor;
|
||||
/**
|
||||
* Calculates the perceived color difference for two colors according to
|
||||
* [Delta E2000](https://en.wikipedia.org/wiki/Color_difference#CIEDE2000).
|
||||
* Returns a value in [0, 1] range.
|
||||
*/
|
||||
delta(color?: AnyColor | Colord): number;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A plugin adding support for CIELAB color space.
|
||||
* https://en.wikipedia.org/wiki/CIELAB_color_space
|
||||
*/
|
||||
declare const labPlugin: Plugin;
|
||||
export default labPlugin;
|
1
node_modules/@pixi/colord/plugins/lab.js
generated
vendored
Normal file
1
node_modules/@pixi/colord/plugins/lab.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var a=function(a){return"string"==typeof a?a.length>0:"number"==typeof a},t=function(a,t,o){return void 0===t&&(t=0),void 0===o&&(o=Math.pow(10,t)),Math.round(o*a)/o+0},o=function(a,t,o){return void 0===t&&(t=0),void 0===o&&(o=1),a>o?o:a>t?a:t},r=function(a){var t=a/255;return t<.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},h=function(a){return 255*(a>.0031308?1.055*Math.pow(a,1/2.4)-.055:12.92*a)},n=96.422,p=100,M=82.521,u=function(a){var t,r,n={x:.9555766*(t=a).x+-.0230393*t.y+.0631636*t.z,y:-.0282895*t.x+1.0099416*t.y+.0210077*t.z,z:.0122982*t.x+-.020483*t.y+1.3299098*t.z};return r={r:h(.032404542*n.x-.015371385*n.y-.004985314*n.z),g:h(-.00969266*n.x+.018760108*n.y+41556e-8*n.z),b:h(556434e-9*n.x-.002040259*n.y+.010572252*n.z),a:a.a},{r:o(r.r,0,255),g:o(r.g,0,255),b:o(r.b,0,255),a:o(r.a)}},e=function(a){var t=r(a.r),h=r(a.g),u=r(a.b);return function(a){return{x:o(a.x,0,n),y:o(a.y,0,p),z:o(a.z,0,M),a:o(a.a)}}(function(a){return{x:1.0478112*a.x+.0228866*a.y+-.050127*a.z,y:.0295424*a.x+.9904844*a.y+-.0170491*a.z,z:-.0092345*a.x+.0150436*a.y+.7521316*a.z,a:a.a}}({x:100*(.4124564*t+.3575761*h+.1804375*u),y:100*(.2126729*t+.7151522*h+.072175*u),z:100*(.0193339*t+.119192*h+.9503041*u),a:a.a}))},w=216/24389,b=24389/27,i=function(t){var r=t.l,h=t.a,n=t.b,p=t.alpha,M=void 0===p?1:p;if(!a(r)||!a(h)||!a(n))return null;var u=function(a){return{l:o(a.l,0,400),a:a.a,b:a.b,alpha:o(a.alpha)}}({l:Number(r),a:Number(h),b:Number(n),alpha:Number(M)});return l(u)},l=function(a){var t=(a.l+16)/116,o=a.a/500+t,r=t-a.b/200;return u({x:(Math.pow(o,3)>w?Math.pow(o,3):(116*o-16)/b)*n,y:(a.l>8?Math.pow((a.l+16)/116,3):a.l/b)*p,z:(Math.pow(r,3)>w?Math.pow(r,3):(116*r-16)/b)*M,a:a.alpha})};module.exports=function(a,r){a.prototype.toLab=function(){return o=e(this.rgba),h=o.y/p,u=o.z/M,r=(r=o.x/n)>w?Math.cbrt(r):(b*r+16)/116,a={l:116*(h=h>w?Math.cbrt(h):(b*h+16)/116)-16,a:500*(r-h),b:200*(h-(u=u>w?Math.cbrt(u):(b*u+16)/116)),alpha:o.a},{l:t(a.l,2),a:t(a.a,2),b:t(a.b,2),alpha:t(a.alpha,3)};var a,o,r,h,u},a.prototype.delta=function(r){void 0===r&&(r="#FFF");var h=r instanceof a?r:new a(r),n=function(a,t){var o=a.l,r=a.a,h=a.b,n=t.l,p=t.a,M=t.b,u=180/Math.PI,e=Math.PI/180,w=Math.pow(Math.pow(r,2)+Math.pow(h,2),.5),b=Math.pow(Math.pow(p,2)+Math.pow(M,2),.5),i=(o+n)/2,l=Math.pow((w+b)/2,7),c=.5*(1-Math.pow(l/(l+Math.pow(25,7)),.5)),f=r*(1+c),y=p*(1+c),v=Math.pow(Math.pow(f,2)+Math.pow(h,2),.5),x=Math.pow(Math.pow(y,2)+Math.pow(M,2),.5),z=(v+x)/2,s=0===f&&0===h?0:Math.atan2(h,f)*u,d=0===y&&0===M?0:Math.atan2(M,y)*u;s<0&&(s+=360),d<0&&(d+=360);var g=d-s,m=Math.abs(d-s);m>180&&d<=s?g+=360:m>180&&d>s&&(g-=360);var N=s+d;m<=180?N/=2:N=(s+d<360?N+360:N-360)/2;var F=1-.17*Math.cos(e*(N-30))+.24*Math.cos(2*e*N)+.32*Math.cos(e*(3*N+6))-.2*Math.cos(e*(4*N-63)),L=n-o,I=x-v,P=2*Math.sin(e*g/2)*Math.pow(v*x,.5),j=1+.015*Math.pow(i-50,2)/Math.pow(20+Math.pow(i-50,2),.5),k=1+.045*z,q=1+.015*z*F,A=30*Math.exp(-1*Math.pow((N-275)/25,2)),B=-2*Math.pow(l/(l+Math.pow(25,7)),.5)*Math.sin(2*e*A);return Math.pow(Math.pow(L/1/j,2)+Math.pow(I/1/k,2)+Math.pow(P/1/q,2)+B*I*P/(1*k*1*q),.5)}(this.toLab(),h.toLab())/100;return o(t(n,3))},r.object.push([i,"lab"])};
|
1
node_modules/@pixi/colord/plugins/lab.mjs
generated
vendored
Normal file
1
node_modules/@pixi/colord/plugins/lab.mjs
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var a=function(a){return"string"==typeof a?a.length>0:"number"==typeof a},t=function(a,t,o){return void 0===t&&(t=0),void 0===o&&(o=Math.pow(10,t)),Math.round(o*a)/o+0},o=function(a,t,o){return void 0===t&&(t=0),void 0===o&&(o=1),a>o?o:a>t?a:t},r=function(a){var t=a/255;return t<.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},h=function(a){return 255*(a>.0031308?1.055*Math.pow(a,1/2.4)-.055:12.92*a)},n=96.422,p=100,M=82.521,u=function(a){var t,r,n={x:.9555766*(t=a).x+-.0230393*t.y+.0631636*t.z,y:-.0282895*t.x+1.0099416*t.y+.0210077*t.z,z:.0122982*t.x+-.020483*t.y+1.3299098*t.z};return r={r:h(.032404542*n.x-.015371385*n.y-.004985314*n.z),g:h(-.00969266*n.x+.018760108*n.y+41556e-8*n.z),b:h(556434e-9*n.x-.002040259*n.y+.010572252*n.z),a:a.a},{r:o(r.r,0,255),g:o(r.g,0,255),b:o(r.b,0,255),a:o(r.a)}},e=function(a){var t=r(a.r),h=r(a.g),u=r(a.b);return function(a){return{x:o(a.x,0,n),y:o(a.y,0,p),z:o(a.z,0,M),a:o(a.a)}}(function(a){return{x:1.0478112*a.x+.0228866*a.y+-.050127*a.z,y:.0295424*a.x+.9904844*a.y+-.0170491*a.z,z:-.0092345*a.x+.0150436*a.y+.7521316*a.z,a:a.a}}({x:100*(.4124564*t+.3575761*h+.1804375*u),y:100*(.2126729*t+.7151522*h+.072175*u),z:100*(.0193339*t+.119192*h+.9503041*u),a:a.a}))},w=216/24389,b=24389/27,i=function(t){var r=t.l,h=t.a,n=t.b,p=t.alpha,M=void 0===p?1:p;if(!a(r)||!a(h)||!a(n))return null;var u=function(a){return{l:o(a.l,0,400),a:a.a,b:a.b,alpha:o(a.alpha)}}({l:Number(r),a:Number(h),b:Number(n),alpha:Number(M)});return l(u)},l=function(a){var t=(a.l+16)/116,o=a.a/500+t,r=t-a.b/200;return u({x:(Math.pow(o,3)>w?Math.pow(o,3):(116*o-16)/b)*n,y:(a.l>8?Math.pow((a.l+16)/116,3):a.l/b)*p,z:(Math.pow(r,3)>w?Math.pow(r,3):(116*r-16)/b)*M,a:a.alpha})};export default function(a,r){a.prototype.toLab=function(){return o=e(this.rgba),h=o.y/p,u=o.z/M,r=(r=o.x/n)>w?Math.cbrt(r):(b*r+16)/116,a={l:116*(h=h>w?Math.cbrt(h):(b*h+16)/116)-16,a:500*(r-h),b:200*(h-(u=u>w?Math.cbrt(u):(b*u+16)/116)),alpha:o.a},{l:t(a.l,2),a:t(a.a,2),b:t(a.b,2),alpha:t(a.alpha,3)};var a,o,r,h,u},a.prototype.delta=function(r){void 0===r&&(r="#FFF");var h=r instanceof a?r:new a(r),n=function(a,t){var o=a.l,r=a.a,h=a.b,n=t.l,p=t.a,M=t.b,u=180/Math.PI,e=Math.PI/180,w=Math.pow(Math.pow(r,2)+Math.pow(h,2),.5),b=Math.pow(Math.pow(p,2)+Math.pow(M,2),.5),i=(o+n)/2,l=Math.pow((w+b)/2,7),c=.5*(1-Math.pow(l/(l+Math.pow(25,7)),.5)),f=r*(1+c),y=p*(1+c),v=Math.pow(Math.pow(f,2)+Math.pow(h,2),.5),x=Math.pow(Math.pow(y,2)+Math.pow(M,2),.5),z=(v+x)/2,s=0===f&&0===h?0:Math.atan2(h,f)*u,d=0===y&&0===M?0:Math.atan2(M,y)*u;s<0&&(s+=360),d<0&&(d+=360);var g=d-s,m=Math.abs(d-s);m>180&&d<=s?g+=360:m>180&&d>s&&(g-=360);var N=s+d;m<=180?N/=2:N=(s+d<360?N+360:N-360)/2;var F=1-.17*Math.cos(e*(N-30))+.24*Math.cos(2*e*N)+.32*Math.cos(e*(3*N+6))-.2*Math.cos(e*(4*N-63)),L=n-o,I=x-v,P=2*Math.sin(e*g/2)*Math.pow(v*x,.5),j=1+.015*Math.pow(i-50,2)/Math.pow(20+Math.pow(i-50,2),.5),k=1+.045*z,q=1+.015*z*F,A=30*Math.exp(-1*Math.pow((N-275)/25,2)),B=-2*Math.pow(l/(l+Math.pow(25,7)),.5)*Math.sin(2*e*A);return Math.pow(Math.pow(L/1/j,2)+Math.pow(I/1/k,2)+Math.pow(P/1/q,2)+B*I*P/(1*k*1*q),.5)}(this.toLab(),h.toLab())/100;return o(t(n,3))},r.object.push([i,"lab"])}
|
24
node_modules/@pixi/colord/plugins/lch.d.ts
generated
vendored
Normal file
24
node_modules/@pixi/colord/plugins/lch.d.ts
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import { LchaColor } from "../types";
|
||||
import { Plugin } from "../extend";
|
||||
declare module "../colord" {
|
||||
interface Colord {
|
||||
/**
|
||||
* Converts a color to CIELCH (Lightness-Chroma-Hue) color space and returns an object.
|
||||
* https://lea.verou.me/2020/04/lch-colors-in-css-what-why-and-how/
|
||||
* https://en.wikipedia.org/wiki/CIELAB_color_space#Cylindrical_model
|
||||
*/
|
||||
toLch(): LchaColor;
|
||||
/**
|
||||
* Converts a color to CIELCH (Lightness-Chroma-Hue) color space and returns a string.
|
||||
* https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/lch()
|
||||
*/
|
||||
toLchString(): string;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A plugin adding support for CIELCH color space.
|
||||
* https://lea.verou.me/2020/04/lch-colors-in-css-what-why-and-how/
|
||||
* https://en.wikipedia.org/wiki/CIELAB_color_space#Cylindrical_model
|
||||
*/
|
||||
declare const lchPlugin: Plugin;
|
||||
export default lchPlugin;
|
1
node_modules/@pixi/colord/plugins/lch.js
generated
vendored
Normal file
1
node_modules/@pixi/colord/plugins/lch.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var r={grad:.9,turn:360,rad:360/(2*Math.PI)},t=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},a=function(r,t,a){return void 0===t&&(t=0),void 0===a&&(a=Math.pow(10,t)),Math.round(a*r)/a+0},n=function(r,t,a){return void 0===t&&(t=0),void 0===a&&(a=1),r>a?a:r>t?r:t},u=function(r){var t=r/255;return t<.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},h=function(r){return 255*(r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r)},o=96.422,e=100,c=82.521,i=function(r){var t,a,u={x:.9555766*(t=r).x+-.0230393*t.y+.0631636*t.z,y:-.0282895*t.x+1.0099416*t.y+.0210077*t.z,z:.0122982*t.x+-.020483*t.y+1.3299098*t.z};return a={r:h(.032404542*u.x-.015371385*u.y-.004985314*u.z),g:h(-.00969266*u.x+.018760108*u.y+41556e-8*u.z),b:h(556434e-9*u.x-.002040259*u.y+.010572252*u.z),a:r.a},{r:n(a.r,0,255),g:n(a.g,0,255),b:n(a.b,0,255),a:n(a.a)}},l=function(r){var t=u(r.r),a=u(r.g),h=u(r.b);return function(r){return{x:n(r.x,0,o),y:n(r.y,0,e),z:n(r.z,0,c),a:n(r.a)}}(function(r){return{x:1.0478112*r.x+.0228866*r.y+-.050127*r.z,y:.0295424*r.x+.9904844*r.y+-.0170491*r.z,z:-.0092345*r.x+.0150436*r.y+.7521316*r.z,a:r.a}}({x:100*(.4124564*t+.3575761*a+.1804375*h),y:100*(.2126729*t+.7151522*a+.072175*h),z:100*(.0193339*t+.119192*a+.9503041*h),a:r.a}))},b=216/24389,d=24389/27,f=function(r){return{l:n(r.l,0,100),c:r.c,h:(t=r.h,(t=isFinite(t)?t%360:0)>0?t:t+360),a:r.a};var t},p=function(r){return{l:a(r.l,2),c:a(r.c,2),h:a(r.h,2),a:a(r.a,3)}},v=function(r){var a=r.l,n=r.c,u=r.h,h=r.a,o=void 0===h?1:h;if(!t(a)||!t(n)||!t(u))return null;var e=f({l:Number(a),c:Number(n),h:Number(u),a:Number(o)});return M(e)},y=function(r){var t=function(r){var t=l(r),a=t.x/o,n=t.y/e,u=t.z/c;return a=a>b?Math.cbrt(a):(d*a+16)/116,{l:116*(n=n>b?Math.cbrt(n):(d*n+16)/116)-16,a:500*(a-n),b:200*(n-(u=u>b?Math.cbrt(u):(d*u+16)/116)),alpha:t.a}}(r),n=a(t.a,3),u=a(t.b,3),h=Math.atan2(u,n)/Math.PI*180;return{l:t.l,c:Math.sqrt(n*n+u*u),h:h<0?h+360:h,a:t.alpha}},M=function(r){return t={l:r.l,a:r.c*Math.cos(r.h*Math.PI/180),b:r.c*Math.sin(r.h*Math.PI/180),alpha:r.a},n=t.a/500+(a=(t.l+16)/116),u=a-t.b/200,i({x:(Math.pow(n,3)>b?Math.pow(n,3):(116*n-16)/d)*o,y:(t.l>8?Math.pow((t.l+16)/116,3):t.l/d)*e,z:(Math.pow(u,3)>b?Math.pow(u,3):(116*u-16)/d)*c,a:t.alpha});var t,a,n,u},x=/^lch\(\s*([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)\s+([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,s=function(t){var a=x.exec(t);if(!a)return null;var n,u,h=f({l:Number(a[1]),c:Number(a[2]),h:(n=a[3],u=a[4],void 0===u&&(u="deg"),Number(n)*(r[u]||1)),a:void 0===a[5]?1:Number(a[5])/(a[6]?100:1)});return M(h)};module.exports=function(r,t){r.prototype.toLch=function(){return p(y(this.rgba))},r.prototype.toLchString=function(){return r=p(y(this.rgba)),t=r.l,a=r.c,n=r.h,(u=r.a)<1?"lch("+t+"% "+a+" "+n+" / "+u+")":"lch("+t+"% "+a+" "+n+")";var r,t,a,n,u},t.string.push([s,"lch"]),t.object.push([v,"lch"])};
|
1
node_modules/@pixi/colord/plugins/lch.mjs
generated
vendored
Normal file
1
node_modules/@pixi/colord/plugins/lch.mjs
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var r={grad:.9,turn:360,rad:360/(2*Math.PI)},t=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},a=function(r,t,a){return void 0===t&&(t=0),void 0===a&&(a=Math.pow(10,t)),Math.round(a*r)/a+0},n=function(r,t,a){return void 0===t&&(t=0),void 0===a&&(a=1),r>a?a:r>t?r:t},u=function(r){var t=r/255;return t<.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},h=function(r){return 255*(r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r)},o=96.422,e=100,c=82.521,i=function(r){var t,a,u={x:.9555766*(t=r).x+-.0230393*t.y+.0631636*t.z,y:-.0282895*t.x+1.0099416*t.y+.0210077*t.z,z:.0122982*t.x+-.020483*t.y+1.3299098*t.z};return a={r:h(.032404542*u.x-.015371385*u.y-.004985314*u.z),g:h(-.00969266*u.x+.018760108*u.y+41556e-8*u.z),b:h(556434e-9*u.x-.002040259*u.y+.010572252*u.z),a:r.a},{r:n(a.r,0,255),g:n(a.g,0,255),b:n(a.b,0,255),a:n(a.a)}},l=function(r){var t=u(r.r),a=u(r.g),h=u(r.b);return function(r){return{x:n(r.x,0,o),y:n(r.y,0,e),z:n(r.z,0,c),a:n(r.a)}}(function(r){return{x:1.0478112*r.x+.0228866*r.y+-.050127*r.z,y:.0295424*r.x+.9904844*r.y+-.0170491*r.z,z:-.0092345*r.x+.0150436*r.y+.7521316*r.z,a:r.a}}({x:100*(.4124564*t+.3575761*a+.1804375*h),y:100*(.2126729*t+.7151522*a+.072175*h),z:100*(.0193339*t+.119192*a+.9503041*h),a:r.a}))},f=216/24389,b=24389/27,d=function(r){return{l:n(r.l,0,100),c:r.c,h:(t=r.h,(t=isFinite(t)?t%360:0)>0?t:t+360),a:r.a};var t},p=function(r){return{l:a(r.l,2),c:a(r.c,2),h:a(r.h,2),a:a(r.a,3)}},v=function(r){var a=r.l,n=r.c,u=r.h,h=r.a,o=void 0===h?1:h;if(!t(a)||!t(n)||!t(u))return null;var e=d({l:Number(a),c:Number(n),h:Number(u),a:Number(o)});return M(e)},y=function(r){var t=function(r){var t=l(r),a=t.x/o,n=t.y/e,u=t.z/c;return a=a>f?Math.cbrt(a):(b*a+16)/116,{l:116*(n=n>f?Math.cbrt(n):(b*n+16)/116)-16,a:500*(a-n),b:200*(n-(u=u>f?Math.cbrt(u):(b*u+16)/116)),alpha:t.a}}(r),n=a(t.a,3),u=a(t.b,3),h=Math.atan2(u,n)/Math.PI*180;return{l:t.l,c:Math.sqrt(n*n+u*u),h:h<0?h+360:h,a:t.alpha}},M=function(r){return t={l:r.l,a:r.c*Math.cos(r.h*Math.PI/180),b:r.c*Math.sin(r.h*Math.PI/180),alpha:r.a},n=t.a/500+(a=(t.l+16)/116),u=a-t.b/200,i({x:(Math.pow(n,3)>f?Math.pow(n,3):(116*n-16)/b)*o,y:(t.l>8?Math.pow((t.l+16)/116,3):t.l/b)*e,z:(Math.pow(u,3)>f?Math.pow(u,3):(116*u-16)/b)*c,a:t.alpha});var t,a,n,u},x=/^lch\(\s*([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)\s+([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,s=function(t){var a=x.exec(t);if(!a)return null;var n,u,h=d({l:Number(a[1]),c:Number(a[2]),h:(n=a[3],u=a[4],void 0===u&&(u="deg"),Number(n)*(r[u]||1)),a:void 0===a[5]?1:Number(a[5])/(a[6]?100:1)});return M(h)};export default function(r,t){r.prototype.toLch=function(){return p(y(this.rgba))},r.prototype.toLchString=function(){return r=p(y(this.rgba)),t=r.l,a=r.c,n=r.h,(u=r.a)<1?"lch("+t+"% "+a+" "+n+" / "+u+")":"lch("+t+"% "+a+" "+n+")";var r,t,a,n,u},t.string.push([s,"lch"]),t.object.push([v,"lch"])}
|
20
node_modules/@pixi/colord/plugins/minify.d.ts
generated
vendored
Normal file
20
node_modules/@pixi/colord/plugins/minify.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Plugin } from "../extend";
|
||||
interface MinificationOptions {
|
||||
hex?: boolean;
|
||||
alphaHex?: boolean;
|
||||
rgb?: boolean;
|
||||
hsl?: boolean;
|
||||
name?: boolean;
|
||||
transparent?: boolean;
|
||||
}
|
||||
declare module "../colord" {
|
||||
interface Colord {
|
||||
/** Returns the shortest string representation of the color */
|
||||
minify(options?: MinificationOptions): string;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A plugin adding a color minification utilities.
|
||||
*/
|
||||
declare const minifyPlugin: Plugin;
|
||||
export default minifyPlugin;
|
1
node_modules/@pixi/colord/plugins/minify.js
generated
vendored
Normal file
1
node_modules/@pixi/colord/plugins/minify.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports=function(t){var r=function(t){var r,n,e,i=t.toHex(),a=t.alpha(),h=i.split(""),s=h[1],o=h[2],u=h[3],l=h[4],p=h[5],f=h[6],g=h[7],v=h[8];if(a>0&&a<1&&(r=parseInt(g+v,16)/255,void 0===(n=2)&&(n=0),void 0===e&&(e=Math.pow(10,n)),Math.round(e*r)/e+0!==a))return null;if(s===o&&u===l&&p===f){if(1===a)return"#"+s+u+p;if(g===v)return"#"+s+u+p+g}return i},n=function(t){return t>0&&t<1?t.toString().replace("0.","."):t};t.prototype.minify=function(t){void 0===t&&(t={});var e=this.toRgb(),i=n(e.r),a=n(e.g),h=n(e.b),s=this.toHsl(),o=n(s.h),u=n(s.s),l=n(s.l),p=n(this.alpha()),f=Object.assign({hex:!0,rgb:!0,hsl:!0},t),g=[];if(f.hex&&(1===p||f.alphaHex)){var v=r(this);v&&g.push(v)}if(f.rgb&&g.push(1===p?"rgb("+i+","+a+","+h+")":"rgba("+i+","+a+","+h+","+p+")"),f.hsl&&g.push(1===p?"hsl("+o+","+u+"%,"+l+"%)":"hsla("+o+","+u+"%,"+l+"%,"+p+")"),f.transparent&&0===i&&0===a&&0===h&&0===p)g.push("transparent");else if(1===p&&f.name&&"function"==typeof this.toName){var c=this.toName();c&&g.push(c)}return function(t){for(var r=t[0],n=1;n<t.length;n++)t[n].length<r.length&&(r=t[n]);return r}(g)}};
|
1
node_modules/@pixi/colord/plugins/minify.mjs
generated
vendored
Normal file
1
node_modules/@pixi/colord/plugins/minify.mjs
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export default function(t){var r=function(t){var r,n,e,a=t.toHex(),i=t.alpha(),h=a.split(""),s=h[1],o=h[2],u=h[3],l=h[4],p=h[5],f=h[6],g=h[7],v=h[8];if(i>0&&i<1&&(r=parseInt(g+v,16)/255,void 0===(n=2)&&(n=0),void 0===e&&(e=Math.pow(10,n)),Math.round(e*r)/e+0!==i))return null;if(s===o&&u===l&&p===f){if(1===i)return"#"+s+u+p;if(g===v)return"#"+s+u+p+g}return a},n=function(t){return t>0&&t<1?t.toString().replace("0.","."):t};t.prototype.minify=function(t){void 0===t&&(t={});var e=this.toRgb(),a=n(e.r),i=n(e.g),h=n(e.b),s=this.toHsl(),o=n(s.h),u=n(s.s),l=n(s.l),p=n(this.alpha()),f=Object.assign({hex:!0,rgb:!0,hsl:!0},t),g=[];if(f.hex&&(1===p||f.alphaHex)){var v=r(this);v&&g.push(v)}if(f.rgb&&g.push(1===p?"rgb("+a+","+i+","+h+")":"rgba("+a+","+i+","+h+","+p+")"),f.hsl&&g.push(1===p?"hsl("+o+","+u+"%,"+l+"%)":"hsla("+o+","+u+"%,"+l+"%,"+p+")"),f.transparent&&0===a&&0===i&&0===h&&0===p)g.push("transparent");else if(1===p&&f.name&&"function"==typeof this.toName){var c=this.toName();c&&g.push(c)}return function(t){for(var r=t[0],n=1;n<t.length;n++)t[n].length<r.length&&(r=t[n]);return r}(g)}}
|
27
node_modules/@pixi/colord/plugins/mix.d.ts
generated
vendored
Normal file
27
node_modules/@pixi/colord/plugins/mix.d.ts
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import { AnyColor } from "../types";
|
||||
import { Plugin } from "../extend";
|
||||
declare module "../colord" {
|
||||
interface Colord {
|
||||
/**
|
||||
* Produces a mixture of two colors through CIE LAB color space and returns a new Colord instance.
|
||||
*/
|
||||
mix(color2: AnyColor | Colord, ratio?: number): Colord;
|
||||
/**
|
||||
* Generates a tints palette based on original color.
|
||||
*/
|
||||
tints(count?: number): Colord[];
|
||||
/**
|
||||
* Generates a shades palette based on original color.
|
||||
*/
|
||||
shades(count?: number): Colord[];
|
||||
/**
|
||||
* Generates a tones palette based on original color.
|
||||
*/
|
||||
tones(count?: number): Colord[];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A plugin adding a color mixing utilities.
|
||||
*/
|
||||
declare const mixPlugin: Plugin;
|
||||
export default mixPlugin;
|
1
node_modules/@pixi/colord/plugins/mix.js
generated
vendored
Normal file
1
node_modules/@pixi/colord/plugins/mix.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var t=function(t,a,n){return void 0===a&&(a=0),void 0===n&&(n=1),t>n?n:t>a?t:a},a=function(t){var a=t/255;return a<.04045?a/12.92:Math.pow((a+.055)/1.055,2.4)},n=function(t){return 255*(t>.0031308?1.055*Math.pow(t,1/2.4)-.055:12.92*t)},r=96.422,o=100,u=82.521,e=function(a){var r,o,u={x:.9555766*(r=a).x+-.0230393*r.y+.0631636*r.z,y:-.0282895*r.x+1.0099416*r.y+.0210077*r.z,z:.0122982*r.x+-.020483*r.y+1.3299098*r.z};return o={r:n(.032404542*u.x-.015371385*u.y-.004985314*u.z),g:n(-.00969266*u.x+.018760108*u.y+41556e-8*u.z),b:n(556434e-9*u.x-.002040259*u.y+.010572252*u.z),a:a.a},{r:t(o.r,0,255),g:t(o.g,0,255),b:t(o.b,0,255),a:t(o.a)}},i=function(n){var e=a(n.r),i=a(n.g),p=a(n.b);return function(a){return{x:t(a.x,0,r),y:t(a.y,0,o),z:t(a.z,0,u),a:t(a.a)}}(function(t){return{x:1.0478112*t.x+.0228866*t.y+-.050127*t.z,y:.0295424*t.x+.9904844*t.y+-.0170491*t.z,z:-.0092345*t.x+.0150436*t.y+.7521316*t.z,a:t.a}}({x:100*(.4124564*e+.3575761*i+.1804375*p),y:100*(.2126729*e+.7151522*i+.072175*p),z:100*(.0193339*e+.119192*i+.9503041*p),a:n.a}))},p=216/24389,h=24389/27,f=function(t){var a=i(t),n=a.x/r,e=a.y/o,f=a.z/u;return n=n>p?Math.cbrt(n):(h*n+16)/116,{l:116*(e=e>p?Math.cbrt(e):(h*e+16)/116)-16,a:500*(n-e),b:200*(e-(f=f>p?Math.cbrt(f):(h*f+16)/116)),alpha:a.a}},c=function(a,n,i){var c,y=f(a),x=f(n);return function(t){var a=(t.l+16)/116,n=t.a/500+a,i=a-t.b/200;return e({x:(Math.pow(n,3)>p?Math.pow(n,3):(116*n-16)/h)*r,y:(t.l>8?Math.pow((t.l+16)/116,3):t.l/h)*o,z:(Math.pow(i,3)>p?Math.pow(i,3):(116*i-16)/h)*u,a:t.alpha})}({l:t((c={l:y.l*(1-i)+x.l*i,a:y.a*(1-i)+x.a*i,b:y.b*(1-i)+x.b*i,alpha:y.alpha*(1-i)+x.alpha*i}).l,0,400),a:c.a,b:c.b,alpha:t(c.alpha)})};module.exports=function(t){function a(t,a,n){void 0===n&&(n=5);for(var r=[],o=1/(n-1),u=0;u<=n-1;u++)r.push(t.mix(a,o*u));return r}t.prototype.mix=function(a,n){void 0===n&&(n=.5);var r=a instanceof t?a:new t(a),o=c(this.toRgb(),r.toRgb(),n);return new t(o)},t.prototype.tints=function(t){return a(this,"#fff",t)},t.prototype.shades=function(t){return a(this,"#000",t)},t.prototype.tones=function(t){return a(this,"#808080",t)}};
|
1
node_modules/@pixi/colord/plugins/mix.mjs
generated
vendored
Normal file
1
node_modules/@pixi/colord/plugins/mix.mjs
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var t=function(t,a,n){return void 0===a&&(a=0),void 0===n&&(n=1),t>n?n:t>a?t:a},a=function(t){var a=t/255;return a<.04045?a/12.92:Math.pow((a+.055)/1.055,2.4)},n=function(t){return 255*(t>.0031308?1.055*Math.pow(t,1/2.4)-.055:12.92*t)},r=96.422,o=100,u=82.521,e=function(a){var r,o,u={x:.9555766*(r=a).x+-.0230393*r.y+.0631636*r.z,y:-.0282895*r.x+1.0099416*r.y+.0210077*r.z,z:.0122982*r.x+-.020483*r.y+1.3299098*r.z};return o={r:n(.032404542*u.x-.015371385*u.y-.004985314*u.z),g:n(-.00969266*u.x+.018760108*u.y+41556e-8*u.z),b:n(556434e-9*u.x-.002040259*u.y+.010572252*u.z),a:a.a},{r:t(o.r,0,255),g:t(o.g,0,255),b:t(o.b,0,255),a:t(o.a)}},i=function(n){var e=a(n.r),i=a(n.g),p=a(n.b);return function(a){return{x:t(a.x,0,r),y:t(a.y,0,o),z:t(a.z,0,u),a:t(a.a)}}(function(t){return{x:1.0478112*t.x+.0228866*t.y+-.050127*t.z,y:.0295424*t.x+.9904844*t.y+-.0170491*t.z,z:-.0092345*t.x+.0150436*t.y+.7521316*t.z,a:t.a}}({x:100*(.4124564*e+.3575761*i+.1804375*p),y:100*(.2126729*e+.7151522*i+.072175*p),z:100*(.0193339*e+.119192*i+.9503041*p),a:n.a}))},p=216/24389,h=24389/27,f=function(t){var a=i(t),n=a.x/r,e=a.y/o,f=a.z/u;return n=n>p?Math.cbrt(n):(h*n+16)/116,{l:116*(e=e>p?Math.cbrt(e):(h*e+16)/116)-16,a:500*(n-e),b:200*(e-(f=f>p?Math.cbrt(f):(h*f+16)/116)),alpha:a.a}},c=function(a,n,i){var c,y=f(a),x=f(n);return function(t){var a=(t.l+16)/116,n=t.a/500+a,i=a-t.b/200;return e({x:(Math.pow(n,3)>p?Math.pow(n,3):(116*n-16)/h)*r,y:(t.l>8?Math.pow((t.l+16)/116,3):t.l/h)*o,z:(Math.pow(i,3)>p?Math.pow(i,3):(116*i-16)/h)*u,a:t.alpha})}({l:t((c={l:y.l*(1-i)+x.l*i,a:y.a*(1-i)+x.a*i,b:y.b*(1-i)+x.b*i,alpha:y.alpha*(1-i)+x.alpha*i}).l,0,400),a:c.a,b:c.b,alpha:t(c.alpha)})};export default function(t){function a(t,a,n){void 0===n&&(n=5);for(var r=[],o=1/(n-1),u=0;u<=n-1;u++)r.push(t.mix(a,o*u));return r}t.prototype.mix=function(a,n){void 0===n&&(n=.5);var r=a instanceof t?a:new t(a),o=c(this.toRgb(),r.toRgb(),n);return new t(o)},t.prototype.tints=function(t){return a(this,"#fff",t)},t.prototype.shades=function(t){return a(this,"#000",t)},t.prototype.tones=function(t){return a(this,"#808080",t)}}
|
19
node_modules/@pixi/colord/plugins/names.d.ts
generated
vendored
Normal file
19
node_modules/@pixi/colord/plugins/names.d.ts
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import { Plugin } from "../extend";
|
||||
interface ConvertOptions {
|
||||
closest?: boolean;
|
||||
}
|
||||
declare module "../colord" {
|
||||
interface Colord {
|
||||
/** Finds CSS color keyword that matches with the color value */
|
||||
toName(options?: ConvertOptions): string | undefined;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Plugin to work with named colors.
|
||||
* Adds a parser to read CSS color names and `toName` method.
|
||||
* See https://www.w3.org/TR/css-color-4/#named-colors
|
||||
* Supports 'transparent' string as defined in
|
||||
* https://drafts.csswg.org/css-color/#transparent-color
|
||||
*/
|
||||
declare const namesPlugin: Plugin;
|
||||
export default namesPlugin;
|
1
node_modules/@pixi/colord/plugins/names.js
generated
vendored
Normal file
1
node_modules/@pixi/colord/plugins/names.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports=function(e,f){var a={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},r={};for(var d in a)r[a[d]]=d;var l={};e.prototype.toName=function(f){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var d,i,o=r[this.toHex()];if(o)return o;if(null==f?void 0:f.closest){var n=this.toRgb(),t=1/0,b="black";if(!l.length)for(var c in a)l[c]=new e(a[c]).toRgb();for(var g in a){var u=(d=n,i=l[g],Math.pow(d.r-i.r,2)+Math.pow(d.g-i.g,2)+Math.pow(d.b-i.b,2));u<t&&(t=u,b=g)}return b}};f.string.push([function(f){var r=f.toLowerCase(),d="transparent"===r?"#0000":a[r];return d?new e(d).toRgb():null},"name"])};
|
1
node_modules/@pixi/colord/plugins/names.mjs
generated
vendored
Normal file
1
node_modules/@pixi/colord/plugins/names.mjs
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export default function(e,f){var a={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},r={};for(var d in a)r[a[d]]=d;var l={};e.prototype.toName=function(f){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var d,i,n=r[this.toHex()];if(n)return n;if(null==f?void 0:f.closest){var o=this.toRgb(),t=1/0,b="black";if(!l.length)for(var c in a)l[c]=new e(a[c]).toRgb();for(var g in a){var u=(d=o,i=l[g],Math.pow(d.r-i.r,2)+Math.pow(d.g-i.g,2)+Math.pow(d.b-i.b,2));u<t&&(t=u,b=g)}return b}};f.string.push([function(f){var r=f.toLowerCase(),d="transparent"===r?"#0000":a[r];return d?new e(d).toRgb():null},"name"])}
|
14
node_modules/@pixi/colord/plugins/xyz.d.ts
generated
vendored
Normal file
14
node_modules/@pixi/colord/plugins/xyz.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import { XyzaColor } from "../types";
|
||||
import { Plugin } from "../extend";
|
||||
declare module "../colord" {
|
||||
interface Colord {
|
||||
toXyz(): XyzaColor;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A plugin adding support for CIE XYZ colorspace.
|
||||
* Wikipedia: https://en.wikipedia.org/wiki/CIE_1931_color_space
|
||||
* Helpful article: https://www.sttmedia.com/colormodel-xyz
|
||||
*/
|
||||
declare const xyzPlugin: Plugin;
|
||||
export default xyzPlugin;
|
1
node_modules/@pixi/colord/plugins/xyz.js
generated
vendored
Normal file
1
node_modules/@pixi/colord/plugins/xyz.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var r=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},n=function(r,n,t){return void 0===n&&(n=0),void 0===t&&(t=Math.pow(10,n)),Math.round(t*r)/t+0},t=function(r,n,t){return void 0===n&&(n=0),void 0===t&&(t=1),r>t?t:r>n?r:n},u=function(r){var n=r/255;return n<.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)},o=function(r){return 255*(r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r)},a=96.422,e=100,y=82.521,x=function(r){return{x:t(r.x,0,a),y:t(r.y,0,e),z:t(r.z,0,y),a:t(r.a)}},z=function(n){var t=n.x,u=n.y,o=n.z,a=n.a,e=void 0===a?1:a;if(!r(t)||!r(u)||!r(o))return null;var y=x({x:Number(t),y:Number(u),z:Number(o),a:Number(e)});return i(y)},i=function(r){var n,u,a={x:.9555766*(n=r).x+-.0230393*n.y+.0631636*n.z,y:-.0282895*n.x+1.0099416*n.y+.0210077*n.z,z:.0122982*n.x+-.020483*n.y+1.3299098*n.z};return u={r:o(.032404542*a.x-.015371385*a.y-.004985314*a.z),g:o(-.00969266*a.x+.018760108*a.y+41556e-8*a.z),b:o(556434e-9*a.x-.002040259*a.y+.010572252*a.z),a:r.a},{r:t(u.r,0,255),g:t(u.g,0,255),b:t(u.b,0,255),a:t(u.a)}};module.exports=function(r,t){r.prototype.toXyz=function(){return function(r){return{x:n(r.x,2),y:n(r.y,2),z:n(r.z,2),a:n(r.a,3)}}((t=u((r=this.rgba).r),o=u(r.g),a=u(r.b),x({x:1.0478112*(e={x:100*(.4124564*t+.3575761*o+.1804375*a),y:100*(.2126729*t+.7151522*o+.072175*a),z:100*(.0193339*t+.119192*o+.9503041*a),a:r.a}).x+.0228866*e.y+-.050127*e.z,y:.0295424*e.x+.9904844*e.y+-.0170491*e.z,z:-.0092345*e.x+.0150436*e.y+.7521316*e.z,a:e.a})));var r,t,o,a,e},t.object.push([z,"xyz"])};
|
1
node_modules/@pixi/colord/plugins/xyz.mjs
generated
vendored
Normal file
1
node_modules/@pixi/colord/plugins/xyz.mjs
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var r=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},n=function(r,n,t){return void 0===n&&(n=0),void 0===t&&(t=Math.pow(10,n)),Math.round(t*r)/t+0},t=function(r,n,t){return void 0===n&&(n=0),void 0===t&&(t=1),r>t?t:r>n?r:n},u=function(r){var n=r/255;return n<.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)},o=function(r){return 255*(r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r)},a=96.422,e=100,y=82.521,x=function(r){return{x:t(r.x,0,a),y:t(r.y,0,e),z:t(r.z,0,y),a:t(r.a)}},z=function(n){var t=n.x,u=n.y,o=n.z,a=n.a,e=void 0===a?1:a;if(!r(t)||!r(u)||!r(o))return null;var y=x({x:Number(t),y:Number(u),z:Number(o),a:Number(e)});return i(y)},i=function(r){var n,u,a={x:.9555766*(n=r).x+-.0230393*n.y+.0631636*n.z,y:-.0282895*n.x+1.0099416*n.y+.0210077*n.z,z:.0122982*n.x+-.020483*n.y+1.3299098*n.z};return u={r:o(.032404542*a.x-.015371385*a.y-.004985314*a.z),g:o(-.00969266*a.x+.018760108*a.y+41556e-8*a.z),b:o(556434e-9*a.x-.002040259*a.y+.010572252*a.z),a:r.a},{r:t(u.r,0,255),g:t(u.g,0,255),b:t(u.b,0,255),a:t(u.a)}};export default function(r,t){r.prototype.toXyz=function(){return function(r){return{x:n(r.x,2),y:n(r.y,2),z:n(r.z,2),a:n(r.a,3)}}((t=u((r=this.rgba).r),o=u(r.g),a=u(r.b),x({x:1.0478112*(e={x:100*(.4124564*t+.3575761*o+.1804375*a),y:100*(.2126729*t+.7151522*o+.072175*a),z:100*(.0193339*t+.119192*o+.9503041*a),a:r.a}).x+.0228866*e.y+-.050127*e.z,y:.0295424*e.x+.9904844*e.y+-.0170491*e.z,z:-.0092345*e.x+.0150436*e.y+.7521316*e.z,a:e.a})));var r,t,o,a,e},t.object.push([z,"xyz"])}
|
2
node_modules/@pixi/colord/random.d.ts
generated
vendored
Normal file
2
node_modules/@pixi/colord/random.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Colord } from "./colord";
|
||||
export declare const random: () => Colord;
|
67
node_modules/@pixi/colord/types.d.ts
generated
vendored
Normal file
67
node_modules/@pixi/colord/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
export declare type RgbColor = {
|
||||
r: number;
|
||||
g: number;
|
||||
b: number;
|
||||
};
|
||||
export declare type HslColor = {
|
||||
h: number;
|
||||
s: number;
|
||||
l: number;
|
||||
};
|
||||
export declare type HsvColor = {
|
||||
h: number;
|
||||
s: number;
|
||||
v: number;
|
||||
};
|
||||
export declare type HwbColor = {
|
||||
h: number;
|
||||
w: number;
|
||||
b: number;
|
||||
};
|
||||
export interface XyzColor {
|
||||
x: number;
|
||||
y: number;
|
||||
z: number;
|
||||
}
|
||||
export interface LabColor {
|
||||
l: number;
|
||||
a: number;
|
||||
b: number;
|
||||
}
|
||||
export interface LchColor {
|
||||
l: number;
|
||||
c: number;
|
||||
h: number;
|
||||
}
|
||||
export interface CmykColor {
|
||||
c: number;
|
||||
m: number;
|
||||
y: number;
|
||||
k: number;
|
||||
}
|
||||
declare type WithAlpha<O> = O & {
|
||||
a: number;
|
||||
};
|
||||
export declare type RgbaColor = WithAlpha<RgbColor>;
|
||||
export declare type HslaColor = WithAlpha<HslColor>;
|
||||
export declare type HsvaColor = WithAlpha<HsvColor>;
|
||||
export declare type HwbaColor = WithAlpha<HwbColor>;
|
||||
export declare type XyzaColor = WithAlpha<XyzColor>;
|
||||
export declare type LabaColor = LabColor & {
|
||||
alpha: number;
|
||||
};
|
||||
export declare type LchaColor = WithAlpha<LchColor>;
|
||||
export declare type CmykaColor = WithAlpha<CmykColor>;
|
||||
export declare type ObjectColor = RgbColor | RgbaColor | HslColor | HslaColor | HsvColor | HsvaColor | HwbColor | HwbaColor | XyzColor | XyzaColor | LabColor | LabaColor | LchColor | LchaColor | CmykColor | CmykaColor;
|
||||
export declare type AnyColor = string | ObjectColor;
|
||||
export declare type InputObject = Record<string, unknown>;
|
||||
export declare type Format = "name" | "hex" | "rgb" | "hsl" | "hsv" | "hwb" | "xyz" | "lab" | "lch" | "cmyk";
|
||||
export declare type Input = string | InputObject;
|
||||
export declare type ParseResult = [RgbaColor, Format];
|
||||
export declare type ParseFunction<I extends Input> = (input: I) => RgbaColor | null;
|
||||
export declare type Parser<I extends Input> = [ParseFunction<I>, Format];
|
||||
export declare type Parsers = {
|
||||
string: Array<Parser<string>>;
|
||||
object: Array<Parser<InputObject>>;
|
||||
};
|
||||
export {};
|
21
node_modules/@types/css-font-loading-module/LICENSE
generated
vendored
Normal file
21
node_modules/@types/css-font-loading-module/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
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
|
15
node_modules/@types/css-font-loading-module/README.md
generated
vendored
Normal file
15
node_modules/@types/css-font-loading-module/README.md
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
# Installation
|
||||
> `npm install --save @types/css-font-loading-module`
|
||||
|
||||
# Summary
|
||||
This package contains type definitions for css-font-loading-module (https://drafts.csswg.org/css-font-loading/).
|
||||
|
||||
# Details
|
||||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/css-font-loading-module.
|
||||
|
||||
### Additional Details
|
||||
* Last updated: Mon, 20 Nov 2023 23:36:24 GMT
|
||||
* Dependencies: none
|
||||
|
||||
# Credits
|
||||
These definitions were written by [slikts](https://github.com/slikts).
|
110
node_modules/@types/css-font-loading-module/index.d.ts
generated
vendored
Normal file
110
node_modules/@types/css-font-loading-module/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
export type FontFaceLoadStatus = "unloaded" | "loading" | "loaded" | "error";
|
||||
export type FontFaceSetLoadStatus = "loading" | "loaded";
|
||||
export type BinaryData = ArrayBuffer | ArrayBufferView;
|
||||
|
||||
export interface FontFaceSetLoadEventInit extends EventInit {
|
||||
fontfaces?: FontFace[] | undefined;
|
||||
}
|
||||
|
||||
export interface FontFaceSetCallbackMap {
|
||||
loading: (this: FontFaceSet, event: FontFaceSetLoadEvent) => any;
|
||||
loadingdone: (this: FontFaceSet, event: FontFaceSetLoadEvent) => any;
|
||||
loadingerror: (this: FontFaceSet, event: FontFaceSetLoadEvent) => any;
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface FontFaceDescriptors {
|
||||
display?: FontDisplay | undefined;
|
||||
featureSettings?: string | undefined;
|
||||
stretch?: string | undefined;
|
||||
style?: string | undefined;
|
||||
unicodeRange?: string | undefined;
|
||||
variant?: string | undefined;
|
||||
weight?: string | undefined;
|
||||
}
|
||||
|
||||
interface FontFace {
|
||||
load(): Promise<FontFace>;
|
||||
|
||||
family: string;
|
||||
style: string;
|
||||
weight: string;
|
||||
stretch: string;
|
||||
unicodeRange: string;
|
||||
variant: string;
|
||||
featureSettings: string;
|
||||
variationSettings: string;
|
||||
display: FontDisplay;
|
||||
readonly status: FontFaceLoadStatus;
|
||||
readonly loaded: Promise<FontFace>;
|
||||
}
|
||||
|
||||
interface FontFaceSet extends Set<FontFace>, EventTarget {
|
||||
// events for when loading state changes
|
||||
onloading: ((this: FontFaceSet, event: Event) => any) | null;
|
||||
onloadingdone: ((this: FontFaceSet, event: Event) => any) | null;
|
||||
onloadingerror: ((this: FontFaceSet, event: Event) => any) | null;
|
||||
|
||||
// EventTarget
|
||||
addEventListener<K extends keyof FontFaceSetCallbackMap>(
|
||||
type: K,
|
||||
listener: FontFaceSetCallbackMap[K],
|
||||
options?: boolean | AddEventListenerOptions,
|
||||
): void;
|
||||
addEventListener(
|
||||
type: string,
|
||||
listener: EventListenerOrEventListenerObject,
|
||||
options?: boolean | AddEventListenerOptions,
|
||||
): void;
|
||||
removeEventListener<K extends keyof FontFaceSetCallbackMap>(
|
||||
type: K,
|
||||
listener: FontFaceSetCallbackMap[K],
|
||||
options?: boolean | EventListenerOptions,
|
||||
): void;
|
||||
removeEventListener(
|
||||
type: string,
|
||||
listener: EventListenerOrEventListenerObject,
|
||||
options?: boolean | EventListenerOptions,
|
||||
): void;
|
||||
|
||||
// check and start loads if appropriate
|
||||
// and fulfill promise when all loads complete
|
||||
load(font: string, text?: string): Promise<FontFace[]>;
|
||||
// return whether all fonts in the fontlist are loaded
|
||||
// (does not initiate load if not available)
|
||||
check(font: string, text?: string): boolean;
|
||||
|
||||
forEach(callbackfn: (value: FontFace, key: FontFace, parent: FontFaceSet) => void, thisArg?: any): void;
|
||||
|
||||
// async notification that font loading and layout operations are done
|
||||
readonly ready: Promise<FontFaceSet>;
|
||||
|
||||
// loading state, "loading" while one or more fonts loading, "loaded" otherwise
|
||||
readonly status: FontFaceSetLoadStatus;
|
||||
}
|
||||
|
||||
var FontFace: {
|
||||
prototype: FontFace;
|
||||
new(family: string, source: string | BinaryData, descriptors?: FontFaceDescriptors): FontFace;
|
||||
};
|
||||
|
||||
interface FontFaceSetLoadEvent extends Event {
|
||||
readonly fontfaces: readonly FontFace[];
|
||||
}
|
||||
|
||||
var FontFaceSetLoadEvent: {
|
||||
prototype: FontFaceSetLoadEvent;
|
||||
new(type: string, eventInitDict?: FontFaceSetLoadEventInit): FontFaceSetLoadEvent;
|
||||
};
|
||||
|
||||
interface Document {
|
||||
fonts: FontFaceSet;
|
||||
}
|
||||
|
||||
interface WorkerGlobalScope {
|
||||
fonts: FontFaceSet;
|
||||
}
|
||||
}
|
||||
|
||||
type FontFaceSetCopy = FontFaceSet;
|
||||
export { FontFaceSetCopy as FontFaceSet };
|
25
node_modules/@types/css-font-loading-module/package.json
generated
vendored
Normal file
25
node_modules/@types/css-font-loading-module/package.json
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "@types/css-font-loading-module",
|
||||
"version": "0.0.12",
|
||||
"description": "TypeScript definitions for css-font-loading-module",
|
||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/css-font-loading-module",
|
||||
"license": "MIT",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "slikts",
|
||||
"githubUsername": "slikts",
|
||||
"url": "https://github.com/slikts"
|
||||
}
|
||||
],
|
||||
"main": "",
|
||||
"types": "index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||
"directory": "types/css-font-loading-module"
|
||||
},
|
||||
"scripts": {},
|
||||
"dependencies": {},
|
||||
"typesPublisherContentHash": "1846725ec18e12269102f83c365daae5fea943dfb3908d071ee47379f3cc6637",
|
||||
"typeScriptVersion": "5.0"
|
||||
}
|
21
node_modules/@types/earcut/LICENSE
generated
vendored
Normal file
21
node_modules/@types/earcut/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
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
|
15
node_modules/@types/earcut/README.md
generated
vendored
Normal file
15
node_modules/@types/earcut/README.md
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
# Installation
|
||||
> `npm install --save @types/earcut`
|
||||
|
||||
# Summary
|
||||
This package contains type definitions for earcut (https://github.com/mapbox/earcut#readme).
|
||||
|
||||
# Details
|
||||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/earcut.
|
||||
|
||||
### Additional Details
|
||||
* Last updated: Mon, 06 Nov 2023 22:41:05 GMT
|
||||
* Dependencies: none
|
||||
|
||||
# Credits
|
||||
These definitions were written by [Adrian Leonhard](https://github.com/NaridaL).
|
48
node_modules/@types/earcut/index.d.ts
generated
vendored
Normal file
48
node_modules/@types/earcut/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
interface EarcutStatic {
|
||||
/**
|
||||
* Triangulate an outline.
|
||||
*
|
||||
* @param vertices A flat array of vertice coordinates like [x0,y0, x1,y1, x2,y2, ...].
|
||||
* @param holes An array of hole indices if any (e.g. [5, 8] for a 12-vertice input would mean one hole with vertices 5–7 and another with 8–11).
|
||||
* @param dimensions The number of coordinates per vertice in the input array (2 by default).
|
||||
* @return A flat array with each group of three numbers indexing a triangle in the `vertices` array.
|
||||
* @example earcut([10,0, 0,50, 60,60, 70,10]); // returns [1,0,3, 3,2,1]
|
||||
* @example with a hole: earcut([0,0, 100,0, 100,100, 0,100, 20,20, 80,20, 80,80, 20,80], [4]); // [3,0,4, 5,4,0, 3,4,7, 5,0,1, 2,3,7, 6,5,1, 2,7,6, 6,1,2]
|
||||
* @example with 3d coords: earcut([10,0,1, 0,50,2, 60,60,3, 70,10,4], null, 3); // [1,0,3, 3,2,1]
|
||||
*/
|
||||
(vertices: ArrayLike<number>, holes?: ArrayLike<number>, dimensions?: number): number[];
|
||||
|
||||
/**
|
||||
* Transforms multi-dimensional array (e.g. GeoJSON Polygon) into the format expected by earcut.
|
||||
* @example Transforming GeoJSON data.
|
||||
* const data = earcut.flatten(geojson.geometry.coordinates);
|
||||
* const triangles = earcut(data.vertices, data.holes, data.dimensions);
|
||||
* @example Transforming simple triangle with hole:
|
||||
* const data = earcut.flatten([[[0, 0], [100, 0], [0, 100]], [[10, 10], [0, 10], [10, 0]]]);
|
||||
* const triangles = earcut(data.vertices, data.holes, data.dimensions);
|
||||
* @param data Arrays of rings, with the first being the outline and the rest holes. A ring is an array points, each point being an array of numbers.
|
||||
*/
|
||||
flatten(data: ArrayLike<ArrayLike<ArrayLike<number>>>): { vertices: number[]; holes: number[]; dimensions: number };
|
||||
|
||||
/**
|
||||
* Returns the relative difference between the total area of triangles and the area of the input polygon. 0 means the triangulation is fully correct.
|
||||
* @param vertices same as earcut
|
||||
* @param holes same as earcut
|
||||
* @param dimensions same as earcut
|
||||
* @param triangles see return value of earcut
|
||||
* @example
|
||||
* const triangles = earcut(vertices, holes, dimensions);
|
||||
* const deviation = earcut.deviation(vertices, holes, dimensions, triangles);
|
||||
*/
|
||||
deviation(
|
||||
vertices: ArrayLike<number>,
|
||||
holes: ArrayLike<number> | undefined,
|
||||
dimensions: number,
|
||||
triangles: ArrayLike<number>,
|
||||
): number;
|
||||
|
||||
default: EarcutStatic;
|
||||
}
|
||||
declare const exports: EarcutStatic;
|
||||
export = exports;
|
||||
export as namespace earcut;
|
25
node_modules/@types/earcut/package.json
generated
vendored
Normal file
25
node_modules/@types/earcut/package.json
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "@types/earcut",
|
||||
"version": "2.1.4",
|
||||
"description": "TypeScript definitions for earcut",
|
||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/earcut",
|
||||
"license": "MIT",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Adrian Leonhard",
|
||||
"githubUsername": "NaridaL",
|
||||
"url": "https://github.com/NaridaL"
|
||||
}
|
||||
],
|
||||
"main": "",
|
||||
"types": "index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||
"directory": "types/earcut"
|
||||
},
|
||||
"scripts": {},
|
||||
"dependencies": {},
|
||||
"typesPublisherContentHash": "f18d2ca8b1c48564f6a04700333034eedffa8ee069836cdd3fa2e3652e78a5f7",
|
||||
"typeScriptVersion": "4.5"
|
||||
}
|
26
node_modules/@webgpu/types/LICENSE
generated
vendored
Normal file
26
node_modules/@webgpu/types/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
Copyright 2022 WebGPU Developers
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
132
node_modules/@webgpu/types/README.md
generated
vendored
Normal file
132
node_modules/@webgpu/types/README.md
generated
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
# Typescript Type Definitions for WebGPU
|
||||
|
||||
This package defines Typescript types (`.d.ts`) for the upcoming [WebGPU standard](https://github.com/gpuweb/gpuweb/wiki/Implementation-Status).
|
||||
|
||||
Use this package to augment the ambient [`"dom"`](https://www.typescriptlang.org/docs/handbook/compiler-options.html#compiler-options) type definitions with the new definitions for WebGPU.
|
||||
|
||||
## API style docs
|
||||
|
||||
This repo also generates typedoc docs here: https://gpuweb.github.io/types
|
||||
|
||||
## What are declaration files?
|
||||
|
||||
See the [TypeScript handbook](http://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html).
|
||||
|
||||
|
||||
## How can I use them?
|
||||
|
||||
### Install
|
||||
|
||||
- npm: `npm install --save-dev @webgpu/types`
|
||||
- yarn: `yarn add --dev @webgpu/types`
|
||||
- pnpm: `pnpm add -D @webgpu/types`
|
||||
|
||||
If you are on TypeScript < 5.1, you will also need to install `@types/dom-webcodecs`
|
||||
as a sibling dependency. The version you need depends on the TypeScript version;
|
||||
see the [tests](tests/) for examples.
|
||||
|
||||
### Configure
|
||||
|
||||
Since this package is outside DefinitelyTyped, the dependency won't be picked up automatically.
|
||||
There are several ways to add a additional TypeScript type definition dependencies to your TypeScript project:
|
||||
|
||||
#### TypeScript `tsc` and `tsc`-based bundlers
|
||||
|
||||
In `tsconfig.json`:
|
||||
|
||||
```js
|
||||
{
|
||||
// ...
|
||||
"compilerOptions": {
|
||||
// ...
|
||||
"types": ["@webgpu/types"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Or you can use `typeRoots`:
|
||||
|
||||
```js
|
||||
{
|
||||
// ...
|
||||
"compilerOptions": {
|
||||
// ...
|
||||
"typeRoots": ["./node_modules/@webgpu/types", "./node_modules/@types"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Inline in TypeScript
|
||||
|
||||
This may work better if your toolchain doesn't read `tsconfig.json`.
|
||||
|
||||
```ts
|
||||
/// <reference types="@webgpu/types" />
|
||||
```
|
||||
|
||||
#### Webpack
|
||||
|
||||
If you use Webpack and the options above aren't sufficient (this has not been verified),
|
||||
you may need the following in `webpack.config.js`:
|
||||
|
||||
```js
|
||||
"types": ["@webgpu/types"]
|
||||
```
|
||||
|
||||
#### Others?
|
||||
|
||||
Please contribute a PR to add instructions for other setups or improve existing instructions. :)
|
||||
|
||||
|
||||
## How to update these types
|
||||
|
||||
- Make sure the submodule is checked out: `git submodule update --init`
|
||||
- Pull `gpuweb` changes: `pushd gpuweb && git checkout main && git pull && popd`
|
||||
- Install dependencies: `npm ci`
|
||||
- Bug workaround: paste the `copies.bs` contents in place of its include in `index.bs` (generator doesn't support includes).
|
||||
- Generate `generated/index.d.ts`: `npm run generate`
|
||||
- Open a diff between `generated/index.d.ts` and `dist/index.d.ts`.
|
||||
The generated file is tracked by Git so you can see what has changed.
|
||||
Update the latter according to changes from the former.
|
||||
Note the `generated/` and `dist/` files are not the same.
|
||||
See below for intentional differences.
|
||||
- Format the result: `npm run format`
|
||||
|
||||
### Intentional differences between generator output and final result
|
||||
|
||||
Most or all of these should be fixed in the generator over time.
|
||||
|
||||
- `Array` changed to `Iterable` for WebIDL `sequence`s in argument positions.
|
||||
- `any` changed to `object` for WebIDL `object`.
|
||||
- `| SharedArrayBuffer` added for `[AllowShared] BufferSource`.
|
||||
|
||||
The following differences are TODO: should be changed in the final result.
|
||||
|
||||
- Deprecated items should be removed.
|
||||
|
||||
The following differences will remain.
|
||||
|
||||
- `onuncapturederror` strongly typed.
|
||||
- `getContext` definitions.
|
||||
- `GPUExtent3DStrict` and `GPUOrigin2DStrict`.
|
||||
|
||||
### Publish a new npm package version
|
||||
|
||||
(only for people who have npm publish access)
|
||||
|
||||
* One line cmd to copy-n-paste (for ssh git user, and you'd better know what you are doing, if it failed at certain steps, you might need to clean up git tags before trying again)
|
||||
- `git checkout main && git pull git@github.com:gpuweb/types.git main && git submodule update --init && npm version patch && git push git@github.com:gpuweb/types.git main --tags && npm publish`
|
||||
* Separate steps (better for publishing for the first time)
|
||||
* Make sure you are in the upstream repo, not your forked one. And make sure you are synced to latest commit intended for publish
|
||||
- `git checkout main`
|
||||
- `git pull https://github.com/gpuweb/types.git main`
|
||||
- (If you are using HTTPS regularly. You can use remote names like `origin`, just make sure you are referring to the right repo)
|
||||
- `git submodule update --init`
|
||||
* Create the version tag and commit, and push
|
||||
- `npm version patch`
|
||||
- `git push https://github.com/gpuweb/types.git main --tags`
|
||||
* publish the package
|
||||
- `npm publish --otp=<code>`
|
||||
- Replace `<code>` with the one-time password from your authenticator, since two-factors authentication is required to publish.
|
||||
- If you are doing for the first time, you will do `npm adduser` first and it will guide you through adding the npm account.
|
||||
|
3187
node_modules/@webgpu/types/dist/index.d.ts
generated
vendored
Normal file
3187
node_modules/@webgpu/types/dist/index.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
23
node_modules/@webgpu/types/package.json
generated
vendored
Normal file
23
node_modules/@webgpu/types/package.json
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "@webgpu/types",
|
||||
"repository": "gpuweb/types",
|
||||
"homepage": "https://github.com/gpuweb/types",
|
||||
"bugs": "https://github.com/gpuweb/types/issues",
|
||||
"version": "0.1.46",
|
||||
"main": "",
|
||||
"types": "dist/index.d.ts",
|
||||
"license": "BSD-3-Clause",
|
||||
"files": [
|
||||
"dist/**/*"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "for t in tests/*/ ; do (cd \"$t\" && npm i && npm test); done",
|
||||
"build-docs": "cd tsdoc-src && npm ci && npm run build",
|
||||
"generate": "bikeshed-to-ts --in ./gpuweb/spec/index.bs --out ./generated/index.d.ts --forceGlobal --nominal && prettier -w generated/index.d.ts",
|
||||
"format": "prettier -w dist/index.d.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bikeshed-to-ts": "github:toji/bikeshed-to-ts",
|
||||
"prettier": "^2.2.1"
|
||||
}
|
||||
}
|
459
node_modules/@xmldom/xmldom/CHANGELOG.md
generated
vendored
Normal file
459
node_modules/@xmldom/xmldom/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,459 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [0.8.10](https://github.com/xmldom/xmldom/compare/0.8.9...0.8.10)
|
||||
|
||||
### Fixed
|
||||
|
||||
- dom: prevent iteration over deleted items [`#514`](https://github.com/xmldom/xmldom/pull/514)/ [`#499`](https://github.com/xmldom/xmldom/issues/499)
|
||||
|
||||
Thank you, [@qtow](https://github.com/qtow), for your contributions
|
||||
|
||||
|
||||
## [0.8.9](https://github.com/xmldom/xmldom/compare/0.8.8...0.8.9)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Set nodeName property in ProcessingInstruction [`#509`](https://github.com/xmldom/xmldom/pull/509) / [`#505`](https://github.com/xmldom/xmldom/issues/505)
|
||||
|
||||
Thank you, [@cjbarth](https://github.com/cjbarth), for your contributions
|
||||
|
||||
|
||||
## [0.8.8](https://github.com/xmldom/xmldom/compare/0.8.7...0.8.8)
|
||||
|
||||
### Fixed
|
||||
|
||||
- extend list of HTML entities [`#489`](https://github.com/xmldom/xmldom/pull/489)
|
||||
|
||||
Thank you, [@zorkow](https://github.com/zorkow), for your contributions
|
||||
|
||||
## [0.8.7](https://github.com/xmldom/xmldom/compare/0.8.6...0.8.7)
|
||||
|
||||
### Fixed
|
||||
|
||||
- properly parse closing where the last attribute has no value [`#485`](https://github.com/xmldom/xmldom/pull/485) / [`#486`](https://github.com/xmldom/xmldom/issues/486)
|
||||
|
||||
Thank you, [@bulandent](https://github.com/bulandent), for your contributions
|
||||
|
||||
|
||||
## [0.7.10](https://github.com/xmldom/xmldom/compare/0.7.9...0.7.10)
|
||||
|
||||
### Fixed
|
||||
|
||||
- properly parse closing where the last attribute has no value [`#485`](https://github.com/xmldom/xmldom/pull/485) / [`#486`](https://github.com/xmldom/xmldom/issues/486)
|
||||
|
||||
Thank you, [@bulandent](https://github.com/bulandent), for your contributions
|
||||
|
||||
|
||||
## [0.8.6](https://github.com/xmldom/xmldom/compare/0.8.5...0.8.6)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Properly check nodes before replacement [`#457`](https://github.com/xmldom/xmldom/pull/457) / [`#455`](https://github.com/xmldom/xmldom/issues/455) / [`#456`](https://github.com/xmldom/xmldom/issues/456)
|
||||
|
||||
Thank you, [@edemaine](https://github.com/edemaine), [@pedro-l9](https://github.com/pedro-l9), for your contributions
|
||||
|
||||
|
||||
## [0.8.5](https://github.com/xmldom/xmldom/compare/0.8.4...0.8.5)
|
||||
|
||||
### Fixed
|
||||
|
||||
- fix: Restore ES5 compatibility [`#452`](https://github.com/xmldom/xmldom/pull/452) / [`#453`](https://github.com/xmldom/xmldom/issues/453)
|
||||
|
||||
Thank you, [@fengxinming](https://github.com/fengxinming), for your contributions
|
||||
|
||||
|
||||
## [0.8.4](https://github.com/xmldom/xmldom/compare/0.8.3...0.8.4)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Security: Prevent inserting DOM nodes when they are not well-formed [`CVE-2022-39353`](https://github.com/xmldom/xmldom/security/advisories/GHSA-crh6-fp67-6883)
|
||||
In case such a DOM would be created, the part that is not well-formed will be transformed into text nodes, in which xml specific characters like `<` and `>` are encoded accordingly.
|
||||
In the upcoming version 0.9.0 those text nodes will no longer be added and an error will be thrown instead.
|
||||
This change can break your code, if you relied on this behavior, e.g. multiple root elements in the past. We consider it more important to align with the specs that we want to be aligned with, considering the potential security issues that might derive from people not being aware of the difference in behavior.
|
||||
Related Spec: <https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity>
|
||||
|
||||
Thank you, [@frumioj](https://github.com/frumioj), [@cjbarth](https://github.com/cjbarth), [@markgollnick](https://github.com/markgollnick) for your contributions
|
||||
|
||||
|
||||
## [0.8.3](https://github.com/xmldom/xmldom/compare/0.8.3...0.8.2)
|
||||
|
||||
### Fixed
|
||||
- Avoid iterating over prototype properties [`#437`](https://github.com/xmldom/xmldom/pull/437) / [`#436`](https://github.com/xmldom/xmldom/issues/436)
|
||||
|
||||
Thank you, [@Supraja9726](https://github.com/Supraja9726) for your contributions
|
||||
|
||||
|
||||
## [0.8.2](https://github.com/xmldom/xmldom/compare/0.8.1...0.8.2)
|
||||
|
||||
### Fixed
|
||||
- fix(dom): Serialize `>` as specified (#395) [`#58`](https://github.com/xmldom/xmldom/issues/58)
|
||||
|
||||
### Other
|
||||
- docs: Add `nodeType` values to public interface description [`#396`](https://github.com/xmldom/xmldom/pull/396)
|
||||
- test: Add executable examples for node and typescript [`#317`](https://github.com/xmldom/xmldom/pull/317)
|
||||
- fix(dom): Serialize `>` as specified [`#395`](https://github.com/xmldom/xmldom/pull/395)
|
||||
- chore: Add minimal `Object.assign` ponyfill [`#379`](https://github.com/xmldom/xmldom/pull/379)
|
||||
- docs: Refine release documentation [`#378`](https://github.com/xmldom/xmldom/pull/378)
|
||||
- chore: update various dev dependencies
|
||||
|
||||
Thank you [@niklasl](https://github.com/niklasl), [@cburatto](https://github.com/cburatto), [@SheetJSDev](https://github.com/SheetJSDev), [@pyrsmk](https://github.com/pyrsmk) for your contributions
|
||||
|
||||
## [0.8.1](https://github.com/xmldom/xmldom/compare/0.8.0...0.8.1)
|
||||
|
||||
### Fixes
|
||||
- Only use own properties in entityMap [`#374`](https://github.com/xmldom/xmldom/pull/374)
|
||||
|
||||
### Docs
|
||||
- Add security policy [`#365`](https://github.com/xmldom/xmldom/pull/365)
|
||||
- changelog: Correct contributor name and link [`#366`](https://github.com/xmldom/xmldom/pull/366)
|
||||
- Describe release/publish steps [`#358`](https://github.com/xmldom/xmldom/pull/358), [`#376`](https://github.com/xmldom/xmldom/pull/376)
|
||||
- Add snyk package health badge [`#360`](https://github.com/xmldom/xmldom/pull/360)
|
||||
|
||||
|
||||
## [0.8.0](https://github.com/xmldom/xmldom/compare/0.7.5...0.8.0)
|
||||
|
||||
### Fixed
|
||||
- Normalize all line endings according to XML specs [1.0](https://w3.org/TR/xml/#sec-line-ends) and [1.1](https://www.w3.org/TR/xml11/#sec-line-ends) \
|
||||
BREAKING CHANGE: Certain combination of line break characters are normalized to a single `\n` before parsing takes place and will no longer be preserved.
|
||||
- [`#303`](https://github.com/xmldom/xmldom/issues/303) / [`#307`](https://github.com/xmldom/xmldom/pull/307)
|
||||
- [`#49`](https://github.com/xmldom/xmldom/issues/49), [`#97`](https://github.com/xmldom/xmldom/issues/97), [`#324`](https://github.com/xmldom/xmldom/issues/324) / [`#314`](https://github.com/xmldom/xmldom/pull/314)
|
||||
- XMLSerializer: Preserve whitespace character references [`#284`](https://github.com/xmldom/xmldom/issues/284) / [`#310`](https://github.com/xmldom/xmldom/pull/310) \
|
||||
BREAKING CHANGE: If you relied on the not spec compliant preservation of literal `\t`, `\n` or `\r` in **attribute values**.
|
||||
To preserve those you will have to create XML that instead contains the correct numerical (or hexadecimal) equivalent (e.g. `	`, `
`, `
`).
|
||||
- Drop deprecated exports `DOMImplementation` and `XMLSerializer` from `lib/dom-parser.js` [#53](https://github.com/xmldom/xmldom/issues/53) / [`#309`](https://github.com/xmldom/xmldom/pull/309)
|
||||
BREAKING CHANGE: Use the one provided by the main package export.
|
||||
- dom: Remove all links as part of `removeChild` [`#343`](https://github.com/xmldom/xmldom/issues/343) / [`#355`](https://github.com/xmldom/xmldom/pull/355)
|
||||
|
||||
### Chore
|
||||
- ci: Restore latest tested node version to 16.x [`#325`](https://github.com/xmldom/xmldom/pull/325)
|
||||
- ci: Split test and lint steps into jobs [`#111`](https://github.com/xmldom/xmldom/issues/111) / [`#304`](https://github.com/xmldom/xmldom/pull/304)
|
||||
- Pinned and updated devDependencies
|
||||
|
||||
Thank you [@marrus-sh](https://github.com/marrus-sh), [@victorandree](https://github.com/victorandree), [@mdierolf](https://github.com/mdierolf), [@tsabbay](https://github.com/tsabbay), [@fatihpense](https://github.com/fatihpense) for your contributions
|
||||
|
||||
## 0.7.5
|
||||
|
||||
[Commits](https://github.com/xmldom/xmldom/compare/0.7.4...0.7.5)
|
||||
|
||||
### Fixes:
|
||||
|
||||
- Preserve default namespace when serializing [`#319`](https://github.com/xmldom/xmldom/issues/319) / [`#321`](https://github.com/xmldom/xmldom/pull/321)
|
||||
Thank you, [@lupestro](https://github.com/lupestro)
|
||||
|
||||
## 0.7.4
|
||||
|
||||
[Commits](https://github.com/xmldom/xmldom/compare/0.7.3...0.7.4)
|
||||
|
||||
### Fixes:
|
||||
|
||||
- Restore ability to parse `__prototype__` attributes [`#315`](https://github.com/xmldom/xmldom/pull/315)
|
||||
Thank you, [@dsimpsonOMF](https://github.com/dsimpsonOMF)
|
||||
|
||||
## 0.7.3
|
||||
|
||||
[Commits](https://github.com/xmldom/xmldom/compare/0.7.2...0.7.3)
|
||||
|
||||
### Fixes:
|
||||
|
||||
- Add doctype when parsing from string [`#277`](https://github.com/xmldom/xmldom/issues/277) / [`#301`](https://github.com/xmldom/xmldom/pull/301)
|
||||
- Correct typo in error message [`#294`](https://github.com/xmldom/xmldom/pull/294)
|
||||
Thank you, [@rrthomas](https://github.com/rrthomas)
|
||||
|
||||
### Refactor:
|
||||
|
||||
- Improve exports & require statements, new main package entry [`#233`](https://github.com/xmldom/xmldom/pull/233)
|
||||
|
||||
### Docs:
|
||||
|
||||
- Fix Stryker badge [`#298`](https://github.com/xmldom/xmldom/pull/298)
|
||||
- Fix link to help-wanted issues [`#299`](https://github.com/xmldom/xmldom/pull/299)
|
||||
|
||||
### Chore:
|
||||
|
||||
- Execute stryker:dry-run on branches [`#302`](https://github.com/xmldom/xmldom/pull/302)
|
||||
- Fix stryker config [`#300`](https://github.com/xmldom/xmldom/pull/300)
|
||||
- Split test and lint scripts [`#297`](https://github.com/xmldom/xmldom/pull/297)
|
||||
- Switch to stryker dashboard owned by org [`#292`](https://github.com/xmldom/xmldom/pull/292)
|
||||
|
||||
## 0.7.2
|
||||
|
||||
[Commits](https://github.com/xmldom/xmldom/compare/0.7.1...0.7.2)
|
||||
|
||||
### Fixes:
|
||||
|
||||
- Types: Add index.d.ts to packaged files [`#288`](https://github.com/xmldom/xmldom/pull/288)
|
||||
Thank you, [@forty](https://github.com/forty)
|
||||
|
||||
## 0.7.1
|
||||
|
||||
[Commits](https://github.com/xmldom/xmldom/compare/0.7.0...0.7.1)
|
||||
|
||||
### Fixes:
|
||||
|
||||
- Types: Copy types from DefinitelyTyped [`#283`](https://github.com/xmldom/xmldom/pull/283)
|
||||
Thank you, [@kachkaev](https://github.com/kachkaev)
|
||||
|
||||
### Chore:
|
||||
- package.json: remove author, maintainers, etc. [`#279`](https://github.com/xmldom/xmldom/pull/279)
|
||||
|
||||
## 0.7.0
|
||||
|
||||
[Commits](https://github.com/xmldom/xmldom/compare/0.6.0...0.7.0)
|
||||
|
||||
Due to [`#271`](https://github.com/xmldom/xmldom/issue/271) this version was published as
|
||||
- unscoped `xmldom` package to github (git tags [`0.7.0`](https://github.com/xmldom/xmldom/tree/0.7.0) and [`0.7.0+unscoped`](https://github.com/xmldom/xmldom/tree/0.7.0%2Bunscoped))
|
||||
- scoped `@xmldom/xmldom` package to npm (git tag `0.7.0+scoped`)
|
||||
For more details look at [`#278`](https://github.com/xmldom/xmldom/pull/278#issuecomment-902172483)
|
||||
|
||||
### Fixes:
|
||||
|
||||
- Security: Misinterpretation of malicious XML input [`CVE-2021-32796`](https://github.com/xmldom/xmldom/security/advisories/GHSA-5fg8-2547-mr8q)
|
||||
- Implement `Document.getElementsByClassName` as specified [`#213`](https://github.com/xmldom/xmldom/pull/213), thank you, [@ChALkeR](https://github.com/ChALkeR)
|
||||
- Inherit namespace prefix from parent when required [`#268`](https://github.com/xmldom/xmldom/pull/268)
|
||||
- Handle whitespace in closing tags [`#267`](https://github.com/xmldom/xmldom/pull/267)
|
||||
- Update `DOMImplementation` according to recent specs [`#210`](https://github.com/xmldom/xmldom/pull/210)
|
||||
BREAKING CHANGE: Only if you "passed features to be marked as available as a constructor arguments" and expected it to "magically work".
|
||||
- No longer serializes any namespaces with an empty URI [`#244`](https://github.com/xmldom/xmldom/pull/244)
|
||||
(related to [`#168`](https://github.com/xmldom/xmldom/pull/168) released in 0.6.0)
|
||||
BREAKING CHANGE: Only if you rely on ["unsetting" a namespace prefix](https://github.com/xmldom/xmldom/pull/168#issuecomment-886984994) by setting it to an empty string
|
||||
- Set `localName` as part of `Document.createElement` [`#229`](https://github.com/xmldom/xmldom/pull/229), thank you, [@rrthomas](https://github.com/rrthomas)
|
||||
|
||||
### CI
|
||||
|
||||
- We are now additionally running tests against node v16
|
||||
- Stryker tests on the master branch now run against node v14
|
||||
|
||||
### Docs
|
||||
|
||||
- Describe relations with and between specs: [`#211`](https://github.com/xmldom/xmldom/pull/211), [`#247`](https://github.com/xmldom/xmldom/pull/247)
|
||||
|
||||
## 0.6.0
|
||||
|
||||
[Commits](https://github.com/xmldom/xmldom/compare/0.5.0...0.6.0)
|
||||
|
||||
### Fixes
|
||||
|
||||
- Stop serializing empty namespace values like `xmlns:ds=""` [`#168`](https://github.com/xmldom/xmldom/pull/168)
|
||||
BREAKING CHANGE: If your code expected empty namespaces attributes to be serialized.
|
||||
Thank you, [@pdecat](https://github.com/pdecat) and [@FranckDepoortere](https://github.com/FranckDepoortere)
|
||||
- Escape `<` to `<` when serializing attribute values [`#198`](https://github.com/xmldom/xmldom/issues/198) / [`#199`](https://github.com/xmldom/xmldom/pull/199)
|
||||
|
||||
## 0.5.0
|
||||
|
||||
[Commits](https://github.com/xmldom/xmldom/compare/0.4.0...0.5.0)
|
||||
|
||||
### Fixes
|
||||
- Avoid misinterpretation of malicious XML input - [`GHSA-h6q6-9hqw-rwfv`](https://github.com/xmldom/xmldom/security/advisories/GHSA-h6q6-9hqw-rwfv) (CVE-2021-21366)
|
||||
- Improve error reporting; throw on duplicate attribute\
|
||||
BREAKING CHANGE: It is currently not clear how to consistently deal with duplicate attributes, so it's also safer for our users to fail when detecting them.
|
||||
It's possible to configure the `DOMParser.errorHandler` before parsing, to handle those errors differently.
|
||||
|
||||
To accomplish this and also be able to verify it in tests I needed to
|
||||
- create a new `Error` type `ParseError` and export it
|
||||
- Throw `ParseError` from `errorHandler.fatalError` and prevent those from being caught in `XMLReader`.
|
||||
- export `DOMHandler` constructor as `__DOMHandler`
|
||||
- Preserve quotes in DOCTYPE declaration
|
||||
Since the only purpose of parsing the DOCTYPE is to be able to restore it when serializing, we decided that it would be best to leave the parsed `publicId` and `systemId` as is, including any quotes.
|
||||
BREAKING CHANGE: If somebody relies on the actual unquoted values of those ids, they will need to take care of either single or double quotes and the right escaping.
|
||||
(Without this change this would not have been possible because the SAX parser already dropped the information about the quotes that have been used in the source.)
|
||||
|
||||
https://www.w3.org/TR/2006/REC-xml11-20060816/#dtd
|
||||
https://www.w3.org/TR/2006/REC-xml11-20060816/#IDAX1KS (External Entity Declaration)
|
||||
|
||||
- Fix breaking preprocessors' directives when parsing attributes [`#171`](https://github.com/xmldom/xmldom/pull/171)
|
||||
- fix(dom): Escape `]]>` when serializing CharData [`#181`](https://github.com/xmldom/xmldom/pull/181)
|
||||
- Switch to (only) MIT license (drop problematic LGPL license option) [`#178`](https://github.com/xmldom/xmldom/pull/178)
|
||||
- Export DOMException; remove custom assertions; etc. [`#174`](https://github.com/xmldom/xmldom/pull/174)
|
||||
|
||||
### Docs
|
||||
- Update MDN links in `readme.md` [`#188`](https://github.com/xmldom/xmldom/pull/188)
|
||||
|
||||
## 0.4.0
|
||||
|
||||
[Commits](https://github.com/xmldom/xmldom/compare/0.3.0...0.4.0)
|
||||
|
||||
### Fixes
|
||||
- **BREAKING** Restore ` ` behavior from v0.1.27 [`#67`](https://github.com/xmldom/xmldom/pull/67)
|
||||
- **BREAKING** Typecheck source param before parsing [`#113`](https://github.com/xmldom/xmldom/pull/113)
|
||||
- Include documents in package files list [`#156`](https://github.com/xmldom/xmldom/pull/156)
|
||||
- Preserve doctype with sysid [`#144`](https://github.com/xmldom/xmldom/pull/144)
|
||||
- Remove ES6 syntax from getElementsByClassName [`#91`](https://github.com/xmldom/xmldom/pull/91)
|
||||
- Revert "Add lowercase of åäö in entityMap" due to duplicate entries [`#84`](https://github.com/xmldom/xmldom/pull/84)
|
||||
- fix: Convert all line separators to LF [`#66`](https://github.com/xmldom/xmldom/pull/66)
|
||||
|
||||
### Docs
|
||||
- Update CHANGELOG.md through version 0.3.0 [`#63`](https://github.com/xmldom/xmldom/pull/63)
|
||||
- Update badges [`#78`](https://github.com/xmldom/xmldom/pull/78)
|
||||
- Add .editorconfig file [`#104`](https://github.com/xmldom/xmldom/pull/104)
|
||||
- Add note about import [`#79`](https://github.com/xmldom/xmldom/pull/79)
|
||||
- Modernize & improve the example in readme.md [`#81`](https://github.com/xmldom/xmldom/pull/81)
|
||||
|
||||
### CI
|
||||
- Add Stryker Mutator [`#70`](https://github.com/xmldom/xmldom/pull/70)
|
||||
- Add Stryker action to update dashboard [`#77`](https://github.com/xmldom/xmldom/pull/77)
|
||||
- Add Node GitHub action workflow [`#64`](https://github.com/xmldom/xmldom/pull/64)
|
||||
- add & enable eslint [`#106`](https://github.com/xmldom/xmldom/pull/106)
|
||||
- Use eslint-plugin-es5 to enforce ES5 syntax [`#107`](https://github.com/xmldom/xmldom/pull/107)
|
||||
- Recover `vows` tests, drop `proof` tests [`#59`](https://github.com/xmldom/xmldom/pull/59)
|
||||
- Add jest tessuite and first tests [`#114`](https://github.com/xmldom/xmldom/pull/114)
|
||||
- Add jest testsuite with `xmltest` cases [`#112`](https://github.com/xmldom/xmldom/pull/112)
|
||||
- Configure Renovate [`#108`](https://github.com/xmldom/xmldom/pull/108)
|
||||
- Test European HTML entities [`#86`](https://github.com/xmldom/xmldom/pull/86)
|
||||
- Updated devDependencies
|
||||
|
||||
### Other
|
||||
- Remove files that are not of any use [`#131`](https://github.com/xmldom/xmldom/pull/131), [`#65`](https://github.com/xmldom/xmldom/pull/65), [`#33`](https://github.com/xmldom/xmldom/pull/33)
|
||||
|
||||
## 0.3.0
|
||||
|
||||
[Commits](https://github.com/xmldom/xmldom/compare/0.2.1...0.3.0)
|
||||
|
||||
- **BREAKING** Node >=10.x is now required.
|
||||
- **BREAKING** Remove `component.json` (deprecated package manager https://github.com/componentjs/guide)
|
||||
- **BREAKING** Move existing sources into `lib` subdirectory.
|
||||
- **POSSIBLY BREAKING** Introduce `files` entry in `package.json` and remove use of `.npmignore`.
|
||||
- [Add `Document.getElementsByClassName`](https://github.com/xmldom/xmldom/issues/24).
|
||||
- [Add `Node` to the list of exports](https://github.com/xmldom/xmldom/pull/27)
|
||||
- [Add lowercase of åäö in `entityMap`](https://github.com/xmldom/xmldom/pull/23).
|
||||
- Move CHANGELOG to markdown file.
|
||||
- Move LICENSE to markdown file.
|
||||
|
||||
## 0.2.1
|
||||
|
||||
[Commits](https://github.com/xmldom/xmldom/compare/0.2.0...0.2.1)
|
||||
|
||||
- Correct `homepage`, `repository` and `bugs` URLs in `package.json`.
|
||||
|
||||
## 0.2.0
|
||||
|
||||
[Commits](https://github.com/xmldom/xmldom/compare/v0.1.27...0.2.0)
|
||||
|
||||
- Includes all **BREAKING** changes introduced in [`xmldom-alpha@v0.1.28`](#0128) by the original authors.
|
||||
- **POSSIBLY BREAKING** [remove the `Object.create` check from the `_extends` method of `dom.js` that added a `__proto__` property](https://github.com/xmldom/xmldom/commit/0be2ae910a8a22c9ec2cac042e04de4c04317d2a#diff-7d1c5d97786fdf9af5446a241d0b6d56L19-L22) ().
|
||||
- **POSSIBLY BREAKING** [remove code that added a `__proto__` property](https://github.com/xmldom/xmldom/commit/366159a76a181ce9a0d83f5dc48205686cfaf9cc)
|
||||
- formatting/corrections in `package.json`
|
||||
|
||||
## 0.1.31
|
||||
|
||||
[Commits](https://github.com/xmldom/xmldom/compare/v0.1.27...v0.1.31)
|
||||
|
||||
The patch versions (`v0.1.29` - `v0.1.31`) that have been released on the [v0.1.x branch](https://github.com/xmldom/xmldom/tree/0.1.x), to reflect the changed maintainers, **are branched off from [`v0.1.27`](#0127) so they don't include the breaking changes introduced in [`xmldom-alpha@v0.1.28`](#0128)**:
|
||||
|
||||
## Maintainer changes
|
||||
|
||||
After the last commit to the original repository <https://github.com/jindw/xmldom> on the 9th of May 2017, the first commit to <https://github.com/xmldom/xmldom> is from the 19th of December 2019. [The fork has been announced in the original repository on the 2nd of March 2020.](https://github.com/jindw/xmldom/issues/259)
|
||||
|
||||
The versions listed below have been published to one or both of the following packages:
|
||||
- <https://www.npmjs.com/package/xmldom-alpha>
|
||||
- <https://www.npmjs.com/package/xmldom>
|
||||
|
||||
It is currently not planned to continue publishing the `xmldom-alpha` package.
|
||||
|
||||
The new maintainers did not invest time to understand changes that led to the last `xmldom` version [`0.1.27`](#0127) published by the original maintainer, but consider it the basis for their work.
|
||||
A timeline of all the changes that happened from that version until `0.3.0` is available in <https://github.com/xmldom/xmldom/issues/62>. Any related questions should be asked there.
|
||||
|
||||
## 0.1.28
|
||||
|
||||
[Commits](https://github.com/xmldom/xmldom/compare/v0.1.27...xmldom-alpha@v0.1.28)
|
||||
|
||||
Published by @jindw on the 9th of May 2017 as
|
||||
- `xmldom-alpha@0.1.28`
|
||||
|
||||
- **BREAKING** includes [regression regarding ` ` (issue #57)](https://github.com/xmldom/xmldom/issues/57)
|
||||
- [Fix `license` field in `package.json`](https://github.com/jindw/xmldom/pull/178)
|
||||
- [Conditional converting of HTML entities](https://github.com/jindw/xmldom/pull/80)
|
||||
- Fix `dom.js` serialization issue for missing document element ([example that failed on `toString()` before this change](https://github.com/xmldom/xmldom/blob/a58dcf7a265522e80ce520fe3be0cddb1b976f6f/test/parse/unclosedcomment.js#L10-L11))
|
||||
- Add new module `entities.js`
|
||||
|
||||
## 0.1.27
|
||||
|
||||
Published by @jindw on the 28th of Nov 2016 as
|
||||
- `xmldom@0.1.27`
|
||||
- `xmldom-alpha@0.1.27`
|
||||
|
||||
- Various bug fixes.
|
||||
|
||||
## 0.1.26
|
||||
|
||||
Published on the 18th of Nov 2016
|
||||
as `xmldom@0.1.26`
|
||||
|
||||
- Details unknown
|
||||
|
||||
## 0.1.25
|
||||
|
||||
Published on the 18th of Nov 2016 as
|
||||
- `xmldom@0.1.25`
|
||||
|
||||
- Details unknown
|
||||
|
||||
## 0.1.24
|
||||
|
||||
Published on the 27th of November 2016 as
|
||||
- `xmldom@0.1.24`
|
||||
- `xmldom-alpha@0.1.24`
|
||||
|
||||
- Added node filter.
|
||||
|
||||
## 0.1.23
|
||||
|
||||
Published on the 5th of May 2016 as
|
||||
- `xmldom-alpha@0.1.23`
|
||||
|
||||
- Add namespace support for nest node serialize.
|
||||
- Various other bug fixes.
|
||||
|
||||
## 0.1.22
|
||||
|
||||
- Merge XMLNS serialization.
|
||||
- Remove \r from source string.
|
||||
- Print namespaces for child elements.
|
||||
- Switch references to nodeType to use named constants.
|
||||
- Add nodelist toString support.
|
||||
|
||||
## 0.1.21
|
||||
|
||||
- Fix serialize bug.
|
||||
|
||||
## 0.1.20
|
||||
|
||||
- Optimize invalid XML support.
|
||||
- Add toString sorter for attributes output.
|
||||
- Add html self closed node button.
|
||||
- Add `*` NS support for getElementsByTagNameNS.
|
||||
- Convert attribute's value to string in setAttributeNS.
|
||||
- Add support for HTML entities for HTML docs only.
|
||||
- Fix TypeError when Document is created with DocumentType.
|
||||
|
||||
## 0.1.19
|
||||
|
||||
- Fix [infinite loop on unclosed comment (jindw/xmldom#68)](https://github.com/jindw/xmldom/issues/68)
|
||||
- Add error report for unclosed tag.
|
||||
- Various other fixes.
|
||||
|
||||
## 0.1.18
|
||||
|
||||
- Add default `ns` support.
|
||||
- parseFromString now renders entirely plain text documents as textNode.
|
||||
- Enable option to ignore white space on parsing.
|
||||
|
||||
## 0.1.17
|
||||
|
||||
**Details missing for this and potential earlier version**
|
||||
|
||||
## 0.1.16
|
||||
|
||||
- Correctly handle multibyte Unicode greater than two byts. #57. #56.
|
||||
- Initial unit testing and test coverage. #53. #46. #19.
|
||||
- Create Bower `component.json` #52.
|
||||
|
||||
## 0.1.8
|
||||
|
||||
- Add: some test case from node-o3-xml(excludes xpath support)
|
||||
- Fix: remove existed attribute before setting (bug introduced in v0.1.5)
|
||||
- Fix: index direct access for childNodes and any NodeList collection(not w3c standard)
|
||||
- Fix: remove last child bug
|
8
node_modules/@xmldom/xmldom/LICENSE
generated
vendored
Normal file
8
node_modules/@xmldom/xmldom/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
Copyright 2019 - present Christopher J. Brody and other contributors, as listed in: https://github.com/xmldom/xmldom/graphs/contributors
|
||||
Copyright 2012 - 2017 @jindw <jindw@xidea.org> and other contributors, as listed in: https://github.com/jindw/xmldom/graphs/contributors
|
||||
|
||||
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.
|
50
node_modules/@xmldom/xmldom/SECURITY.md
generated
vendored
Normal file
50
node_modules/@xmldom/xmldom/SECURITY.md
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
# Security Policy
|
||||
|
||||
The most up-to-date version of this document can be found at <https://github.com/xmldom/xmldom/security/policy>.
|
||||
|
||||
## Supported Versions
|
||||
|
||||
This repository contains the code for the libraries `xmldom` and `@xmldom/xmldom` on npm.
|
||||
|
||||
As long as we didn't publish v1, we aim to maintain the last two minor versions with security fixes. If it is possible we provide security fixes as path versions.
|
||||
If you think there is a good reason to also patch an earlier version let us know in a github issue or the release discussion once the fix has been provided.
|
||||
The maintainers will consider it and if we agree and have/find the required resources, a patch for that version will be provided.
|
||||
|
||||
Please notice that [we are no longer able to publish the (unscoped) `xmldom` package](https://github.com/xmldom/xmldom/issues/271),
|
||||
and that all existing versions of `xmldom` are affected by at least one security vulnerability and should be considered deprecated.
|
||||
You can still report issues regarding `xmldom` as described below.
|
||||
|
||||
If you need help with migrating from `xmldom` to `@xmldom/xmldom`, file a github issue or PR in the affected repository and mention @karfau.
|
||||
|
||||
## Reporting vulnerabilities
|
||||
|
||||
Please email reports about any security related issues you find to `security@xmldom.org`, which will forward it to the list of maintainers.
|
||||
The maintainers will try to respond within 7 calendar days. (If nobody peplies after 7 days, please us send a reminder!)
|
||||
As part of you communication please make sure to always hit "Reply all", so all maintainers are kept in the loop.
|
||||
|
||||
In addition, please include the following information along with your report:
|
||||
|
||||
- Your name and affiliation (if any).
|
||||
- A description of the technical details of the vulnerabilities. It is very important to let us know how we can reproduce your findings.
|
||||
- An explanation who can exploit this vulnerability, and what they gain when doing so -- write an attack scenario. This will help us evaluate your report quickly, especially if the issue is complex.
|
||||
- Whether this vulnerability public or known to third parties. If it is, please provide details.
|
||||
|
||||
If you believe that an existing (public) issue is security-related, please send an email to `security@xmldom.org`.
|
||||
The email should include the issue URL and a short description of why it should be handled according to this security policy.
|
||||
|
||||
Once an issue is reported, the maintainers use the following disclosure process:
|
||||
|
||||
- When a report is received, we confirm the issue, determine its severity and the affected versions.
|
||||
- If we know of specific third-party services or software based on xmldom that require mitigation before publication, those projects will be notified.
|
||||
- A [github security advisory](https://docs.github.com/en/code-security/security-advisories/about-github-security-advisories) is [created](https://docs.github.com/en/code-security/security-advisories/creating-a-security-advisory) (but not published) which details the problem and steps for mitigation.
|
||||
- If the reporter provides a github account and agrees to it, we (add that github account as a collaborator on the advisuory)[https://docs.github.com/en/code-security/security-advisories/adding-a-collaborator-to-a-security-advisory].
|
||||
- The vulnerability is fixed in a [private fork](https://docs.github.com/en/code-security/security-advisories/collaborating-in-a-temporary-private-fork-to-resolve-a-security-vulnerability) and potential workarounds are identified.
|
||||
- The maintainers audit the existing code to find any potential similar problems.
|
||||
- The release for the current minor version and the [security advisory are published](https://docs.github.com/en/code-security/security-advisories/publishing-a-security-advisory).
|
||||
- The release(s) for previous minor version(s) are published.
|
||||
|
||||
We credit reporters for identifying security issues, if they confirm that they want to.
|
||||
|
||||
## Known vulnerabilities
|
||||
|
||||
See https://github.com/xmldom/xmldom/security/advisories?state=published
|
43
node_modules/@xmldom/xmldom/index.d.ts
generated
vendored
Normal file
43
node_modules/@xmldom/xmldom/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
/// <reference lib="dom" />
|
||||
|
||||
declare module "@xmldom/xmldom" {
|
||||
var DOMParser: DOMParserStatic;
|
||||
var XMLSerializer: XMLSerializerStatic;
|
||||
var DOMImplementation: DOMImplementationStatic;
|
||||
|
||||
interface DOMImplementationStatic {
|
||||
new(): DOMImplementation;
|
||||
}
|
||||
|
||||
interface DOMParserStatic {
|
||||
new (): DOMParser;
|
||||
new (options: Options): DOMParser;
|
||||
}
|
||||
|
||||
interface XMLSerializerStatic {
|
||||
new (): XMLSerializer;
|
||||
}
|
||||
|
||||
interface DOMParser {
|
||||
parseFromString(xmlsource: string, mimeType?: string): Document;
|
||||
}
|
||||
|
||||
interface XMLSerializer {
|
||||
serializeToString(node: Node): string;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
locator?: any;
|
||||
errorHandler?: ErrorHandlerFunction | ErrorHandlerObject | undefined;
|
||||
}
|
||||
|
||||
interface ErrorHandlerFunction {
|
||||
(level: string, msg: any): any;
|
||||
}
|
||||
|
||||
interface ErrorHandlerObject {
|
||||
warning?: ((msg: any) => any) | undefined;
|
||||
error?: ((msg: any) => any) | undefined;
|
||||
fatalError?: ((msg: any) => any) | undefined;
|
||||
}
|
||||
}
|
2
node_modules/@xmldom/xmldom/lib/.eslintrc.yml
generated
vendored
Normal file
2
node_modules/@xmldom/xmldom/lib/.eslintrc.yml
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
extends:
|
||||
- 'plugin:es5/no-es2015'
|
203
node_modules/@xmldom/xmldom/lib/conventions.js
generated
vendored
Normal file
203
node_modules/@xmldom/xmldom/lib/conventions.js
generated
vendored
Normal file
@@ -0,0 +1,203 @@
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Ponyfill for `Array.prototype.find` which is only available in ES6 runtimes.
|
||||
*
|
||||
* Works with anything that has a `length` property and index access properties, including NodeList.
|
||||
*
|
||||
* @template {unknown} T
|
||||
* @param {Array<T> | ({length:number, [number]: T})} list
|
||||
* @param {function (item: T, index: number, list:Array<T> | ({length:number, [number]: T})):boolean} predicate
|
||||
* @param {Partial<Pick<ArrayConstructor['prototype'], 'find'>>?} ac `Array.prototype` by default,
|
||||
* allows injecting a custom implementation in tests
|
||||
* @returns {T | undefined}
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
|
||||
* @see https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.find
|
||||
*/
|
||||
function find(list, predicate, ac) {
|
||||
if (ac === undefined) {
|
||||
ac = Array.prototype;
|
||||
}
|
||||
if (list && typeof ac.find === 'function') {
|
||||
return ac.find.call(list, predicate);
|
||||
}
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
if (Object.prototype.hasOwnProperty.call(list, i)) {
|
||||
var item = list[i];
|
||||
if (predicate.call(undefined, item, i, list)) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* "Shallow freezes" an object to render it immutable.
|
||||
* Uses `Object.freeze` if available,
|
||||
* otherwise the immutability is only in the type.
|
||||
*
|
||||
* Is used to create "enum like" objects.
|
||||
*
|
||||
* @template T
|
||||
* @param {T} object the object to freeze
|
||||
* @param {Pick<ObjectConstructor, 'freeze'> = Object} oc `Object` by default,
|
||||
* allows to inject custom object constructor for tests
|
||||
* @returns {Readonly<T>}
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze
|
||||
*/
|
||||
function freeze(object, oc) {
|
||||
if (oc === undefined) {
|
||||
oc = Object
|
||||
}
|
||||
return oc && typeof oc.freeze === 'function' ? oc.freeze(object) : object
|
||||
}
|
||||
|
||||
/**
|
||||
* Since we can not rely on `Object.assign` we provide a simplified version
|
||||
* that is sufficient for our needs.
|
||||
*
|
||||
* @param {Object} target
|
||||
* @param {Object | null | undefined} source
|
||||
*
|
||||
* @returns {Object} target
|
||||
* @throws TypeError if target is not an object
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
|
||||
* @see https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.assign
|
||||
*/
|
||||
function assign(target, source) {
|
||||
if (target === null || typeof target !== 'object') {
|
||||
throw new TypeError('target is not an object')
|
||||
}
|
||||
for (var key in source) {
|
||||
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
||||
target[key] = source[key]
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
|
||||
/**
|
||||
* All mime types that are allowed as input to `DOMParser.parseFromString`
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02 MDN
|
||||
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype WHATWG HTML Spec
|
||||
* @see DOMParser.prototype.parseFromString
|
||||
*/
|
||||
var MIME_TYPE = freeze({
|
||||
/**
|
||||
* `text/html`, the only mime type that triggers treating an XML document as HTML.
|
||||
*
|
||||
* @see DOMParser.SupportedType.isHTML
|
||||
* @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration
|
||||
* @see https://en.wikipedia.org/wiki/HTML Wikipedia
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
|
||||
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring WHATWG HTML Spec
|
||||
*/
|
||||
HTML: 'text/html',
|
||||
|
||||
/**
|
||||
* Helper method to check a mime type if it indicates an HTML document
|
||||
*
|
||||
* @param {string} [value]
|
||||
* @returns {boolean}
|
||||
*
|
||||
* @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration
|
||||
* @see https://en.wikipedia.org/wiki/HTML Wikipedia
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
|
||||
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring */
|
||||
isHTML: function (value) {
|
||||
return value === MIME_TYPE.HTML
|
||||
},
|
||||
|
||||
/**
|
||||
* `application/xml`, the standard mime type for XML documents.
|
||||
*
|
||||
* @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType registration
|
||||
* @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303
|
||||
* @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
|
||||
*/
|
||||
XML_APPLICATION: 'application/xml',
|
||||
|
||||
/**
|
||||
* `text/html`, an alias for `application/xml`.
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc7303#section-9.2 RFC 7303
|
||||
* @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration
|
||||
* @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
|
||||
*/
|
||||
XML_TEXT: 'text/xml',
|
||||
|
||||
/**
|
||||
* `application/xhtml+xml`, indicates an XML document that has the default HTML namespace,
|
||||
* but is parsed as an XML document.
|
||||
*
|
||||
* @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType registration
|
||||
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec
|
||||
* @see https://en.wikipedia.org/wiki/XHTML Wikipedia
|
||||
*/
|
||||
XML_XHTML_APPLICATION: 'application/xhtml+xml',
|
||||
|
||||
/**
|
||||
* `image/svg+xml`,
|
||||
*
|
||||
* @see https://www.iana.org/assignments/media-types/image/svg+xml IANA MimeType registration
|
||||
* @see https://www.w3.org/TR/SVG11/ W3C SVG 1.1
|
||||
* @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia
|
||||
*/
|
||||
XML_SVG_IMAGE: 'image/svg+xml',
|
||||
})
|
||||
|
||||
/**
|
||||
* Namespaces that are used in this code base.
|
||||
*
|
||||
* @see http://www.w3.org/TR/REC-xml-names
|
||||
*/
|
||||
var NAMESPACE = freeze({
|
||||
/**
|
||||
* The XHTML namespace.
|
||||
*
|
||||
* @see http://www.w3.org/1999/xhtml
|
||||
*/
|
||||
HTML: 'http://www.w3.org/1999/xhtml',
|
||||
|
||||
/**
|
||||
* Checks if `uri` equals `NAMESPACE.HTML`.
|
||||
*
|
||||
* @param {string} [uri]
|
||||
*
|
||||
* @see NAMESPACE.HTML
|
||||
*/
|
||||
isHTML: function (uri) {
|
||||
return uri === NAMESPACE.HTML
|
||||
},
|
||||
|
||||
/**
|
||||
* The SVG namespace.
|
||||
*
|
||||
* @see http://www.w3.org/2000/svg
|
||||
*/
|
||||
SVG: 'http://www.w3.org/2000/svg',
|
||||
|
||||
/**
|
||||
* The `xml:` namespace.
|
||||
*
|
||||
* @see http://www.w3.org/XML/1998/namespace
|
||||
*/
|
||||
XML: 'http://www.w3.org/XML/1998/namespace',
|
||||
|
||||
/**
|
||||
* The `xmlns:` namespace
|
||||
*
|
||||
* @see https://www.w3.org/2000/xmlns/
|
||||
*/
|
||||
XMLNS: 'http://www.w3.org/2000/xmlns/',
|
||||
})
|
||||
|
||||
exports.assign = assign;
|
||||
exports.find = find;
|
||||
exports.freeze = freeze;
|
||||
exports.MIME_TYPE = MIME_TYPE;
|
||||
exports.NAMESPACE = NAMESPACE;
|
322
node_modules/@xmldom/xmldom/lib/dom-parser.js
generated
vendored
Normal file
322
node_modules/@xmldom/xmldom/lib/dom-parser.js
generated
vendored
Normal file
@@ -0,0 +1,322 @@
|
||||
var conventions = require("./conventions");
|
||||
var dom = require('./dom')
|
||||
var entities = require('./entities');
|
||||
var sax = require('./sax');
|
||||
|
||||
var DOMImplementation = dom.DOMImplementation;
|
||||
|
||||
var NAMESPACE = conventions.NAMESPACE;
|
||||
|
||||
var ParseError = sax.ParseError;
|
||||
var XMLReader = sax.XMLReader;
|
||||
|
||||
/**
|
||||
* Normalizes line ending according to https://www.w3.org/TR/xml11/#sec-line-ends:
|
||||
*
|
||||
* > XML parsed entities are often stored in computer files which,
|
||||
* > for editing convenience, are organized into lines.
|
||||
* > These lines are typically separated by some combination
|
||||
* > of the characters CARRIAGE RETURN (#xD) and LINE FEED (#xA).
|
||||
* >
|
||||
* > To simplify the tasks of applications, the XML processor must behave
|
||||
* > as if it normalized all line breaks in external parsed entities (including the document entity)
|
||||
* > on input, before parsing, by translating all of the following to a single #xA character:
|
||||
* >
|
||||
* > 1. the two-character sequence #xD #xA
|
||||
* > 2. the two-character sequence #xD #x85
|
||||
* > 3. the single character #x85
|
||||
* > 4. the single character #x2028
|
||||
* > 5. any #xD character that is not immediately followed by #xA or #x85.
|
||||
*
|
||||
* @param {string} input
|
||||
* @returns {string}
|
||||
*/
|
||||
function normalizeLineEndings(input) {
|
||||
return input
|
||||
.replace(/\r[\n\u0085]/g, '\n')
|
||||
.replace(/[\r\u0085\u2028]/g, '\n')
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef Locator
|
||||
* @property {number} [columnNumber]
|
||||
* @property {number} [lineNumber]
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef DOMParserOptions
|
||||
* @property {DOMHandler} [domBuilder]
|
||||
* @property {Function} [errorHandler]
|
||||
* @property {(string) => string} [normalizeLineEndings] used to replace line endings before parsing
|
||||
* defaults to `normalizeLineEndings`
|
||||
* @property {Locator} [locator]
|
||||
* @property {Record<string, string>} [xmlns]
|
||||
*
|
||||
* @see normalizeLineEndings
|
||||
*/
|
||||
|
||||
/**
|
||||
* The DOMParser interface provides the ability to parse XML or HTML source code
|
||||
* from a string into a DOM `Document`.
|
||||
*
|
||||
* _xmldom is different from the spec in that it allows an `options` parameter,
|
||||
* to override the default behavior._
|
||||
*
|
||||
* @param {DOMParserOptions} [options]
|
||||
* @constructor
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
|
||||
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization
|
||||
*/
|
||||
function DOMParser(options){
|
||||
this.options = options ||{locator:{}};
|
||||
}
|
||||
|
||||
DOMParser.prototype.parseFromString = function(source,mimeType){
|
||||
var options = this.options;
|
||||
var sax = new XMLReader();
|
||||
var domBuilder = options.domBuilder || new DOMHandler();//contentHandler and LexicalHandler
|
||||
var errorHandler = options.errorHandler;
|
||||
var locator = options.locator;
|
||||
var defaultNSMap = options.xmlns||{};
|
||||
var isHTML = /\/x?html?$/.test(mimeType);//mimeType.toLowerCase().indexOf('html') > -1;
|
||||
var entityMap = isHTML ? entities.HTML_ENTITIES : entities.XML_ENTITIES;
|
||||
if(locator){
|
||||
domBuilder.setDocumentLocator(locator)
|
||||
}
|
||||
|
||||
sax.errorHandler = buildErrorHandler(errorHandler,domBuilder,locator);
|
||||
sax.domBuilder = options.domBuilder || domBuilder;
|
||||
if(isHTML){
|
||||
defaultNSMap[''] = NAMESPACE.HTML;
|
||||
}
|
||||
defaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML;
|
||||
var normalize = options.normalizeLineEndings || normalizeLineEndings;
|
||||
if (source && typeof source === 'string') {
|
||||
sax.parse(
|
||||
normalize(source),
|
||||
defaultNSMap,
|
||||
entityMap
|
||||
)
|
||||
} else {
|
||||
sax.errorHandler.error('invalid doc source')
|
||||
}
|
||||
return domBuilder.doc;
|
||||
}
|
||||
function buildErrorHandler(errorImpl,domBuilder,locator){
|
||||
if(!errorImpl){
|
||||
if(domBuilder instanceof DOMHandler){
|
||||
return domBuilder;
|
||||
}
|
||||
errorImpl = domBuilder ;
|
||||
}
|
||||
var errorHandler = {}
|
||||
var isCallback = errorImpl instanceof Function;
|
||||
locator = locator||{}
|
||||
function build(key){
|
||||
var fn = errorImpl[key];
|
||||
if(!fn && isCallback){
|
||||
fn = errorImpl.length == 2?function(msg){errorImpl(key,msg)}:errorImpl;
|
||||
}
|
||||
errorHandler[key] = fn && function(msg){
|
||||
fn('[xmldom '+key+']\t'+msg+_locator(locator));
|
||||
}||function(){};
|
||||
}
|
||||
build('warning');
|
||||
build('error');
|
||||
build('fatalError');
|
||||
return errorHandler;
|
||||
}
|
||||
|
||||
//console.log('#\n\n\n\n\n\n\n####')
|
||||
/**
|
||||
* +ContentHandler+ErrorHandler
|
||||
* +LexicalHandler+EntityResolver2
|
||||
* -DeclHandler-DTDHandler
|
||||
*
|
||||
* DefaultHandler:EntityResolver, DTDHandler, ContentHandler, ErrorHandler
|
||||
* DefaultHandler2:DefaultHandler,LexicalHandler, DeclHandler, EntityResolver2
|
||||
* @link http://www.saxproject.org/apidoc/org/xml/sax/helpers/DefaultHandler.html
|
||||
*/
|
||||
function DOMHandler() {
|
||||
this.cdata = false;
|
||||
}
|
||||
function position(locator,node){
|
||||
node.lineNumber = locator.lineNumber;
|
||||
node.columnNumber = locator.columnNumber;
|
||||
}
|
||||
/**
|
||||
* @see org.xml.sax.ContentHandler#startDocument
|
||||
* @link http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html
|
||||
*/
|
||||
DOMHandler.prototype = {
|
||||
startDocument : function() {
|
||||
this.doc = new DOMImplementation().createDocument(null, null, null);
|
||||
if (this.locator) {
|
||||
this.doc.documentURI = this.locator.systemId;
|
||||
}
|
||||
},
|
||||
startElement:function(namespaceURI, localName, qName, attrs) {
|
||||
var doc = this.doc;
|
||||
var el = doc.createElementNS(namespaceURI, qName||localName);
|
||||
var len = attrs.length;
|
||||
appendElement(this, el);
|
||||
this.currentElement = el;
|
||||
|
||||
this.locator && position(this.locator,el)
|
||||
for (var i = 0 ; i < len; i++) {
|
||||
var namespaceURI = attrs.getURI(i);
|
||||
var value = attrs.getValue(i);
|
||||
var qName = attrs.getQName(i);
|
||||
var attr = doc.createAttributeNS(namespaceURI, qName);
|
||||
this.locator &&position(attrs.getLocator(i),attr);
|
||||
attr.value = attr.nodeValue = value;
|
||||
el.setAttributeNode(attr)
|
||||
}
|
||||
},
|
||||
endElement:function(namespaceURI, localName, qName) {
|
||||
var current = this.currentElement
|
||||
var tagName = current.tagName;
|
||||
this.currentElement = current.parentNode;
|
||||
},
|
||||
startPrefixMapping:function(prefix, uri) {
|
||||
},
|
||||
endPrefixMapping:function(prefix) {
|
||||
},
|
||||
processingInstruction:function(target, data) {
|
||||
var ins = this.doc.createProcessingInstruction(target, data);
|
||||
this.locator && position(this.locator,ins)
|
||||
appendElement(this, ins);
|
||||
},
|
||||
ignorableWhitespace:function(ch, start, length) {
|
||||
},
|
||||
characters:function(chars, start, length) {
|
||||
chars = _toString.apply(this,arguments)
|
||||
//console.log(chars)
|
||||
if(chars){
|
||||
if (this.cdata) {
|
||||
var charNode = this.doc.createCDATASection(chars);
|
||||
} else {
|
||||
var charNode = this.doc.createTextNode(chars);
|
||||
}
|
||||
if(this.currentElement){
|
||||
this.currentElement.appendChild(charNode);
|
||||
}else if(/^\s*$/.test(chars)){
|
||||
this.doc.appendChild(charNode);
|
||||
//process xml
|
||||
}
|
||||
this.locator && position(this.locator,charNode)
|
||||
}
|
||||
},
|
||||
skippedEntity:function(name) {
|
||||
},
|
||||
endDocument:function() {
|
||||
this.doc.normalize();
|
||||
},
|
||||
setDocumentLocator:function (locator) {
|
||||
if(this.locator = locator){// && !('lineNumber' in locator)){
|
||||
locator.lineNumber = 0;
|
||||
}
|
||||
},
|
||||
//LexicalHandler
|
||||
comment:function(chars, start, length) {
|
||||
chars = _toString.apply(this,arguments)
|
||||
var comm = this.doc.createComment(chars);
|
||||
this.locator && position(this.locator,comm)
|
||||
appendElement(this, comm);
|
||||
},
|
||||
|
||||
startCDATA:function() {
|
||||
//used in characters() methods
|
||||
this.cdata = true;
|
||||
},
|
||||
endCDATA:function() {
|
||||
this.cdata = false;
|
||||
},
|
||||
|
||||
startDTD:function(name, publicId, systemId) {
|
||||
var impl = this.doc.implementation;
|
||||
if (impl && impl.createDocumentType) {
|
||||
var dt = impl.createDocumentType(name, publicId, systemId);
|
||||
this.locator && position(this.locator,dt)
|
||||
appendElement(this, dt);
|
||||
this.doc.doctype = dt;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @see org.xml.sax.ErrorHandler
|
||||
* @link http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html
|
||||
*/
|
||||
warning:function(error) {
|
||||
console.warn('[xmldom warning]\t'+error,_locator(this.locator));
|
||||
},
|
||||
error:function(error) {
|
||||
console.error('[xmldom error]\t'+error,_locator(this.locator));
|
||||
},
|
||||
fatalError:function(error) {
|
||||
throw new ParseError(error, this.locator);
|
||||
}
|
||||
}
|
||||
function _locator(l){
|
||||
if(l){
|
||||
return '\n@'+(l.systemId ||'')+'#[line:'+l.lineNumber+',col:'+l.columnNumber+']'
|
||||
}
|
||||
}
|
||||
function _toString(chars,start,length){
|
||||
if(typeof chars == 'string'){
|
||||
return chars.substr(start,length)
|
||||
}else{//java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)")
|
||||
if(chars.length >= start+length || start){
|
||||
return new java.lang.String(chars,start,length)+'';
|
||||
}
|
||||
return chars;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html
|
||||
* used method of org.xml.sax.ext.LexicalHandler:
|
||||
* #comment(chars, start, length)
|
||||
* #startCDATA()
|
||||
* #endCDATA()
|
||||
* #startDTD(name, publicId, systemId)
|
||||
*
|
||||
*
|
||||
* IGNORED method of org.xml.sax.ext.LexicalHandler:
|
||||
* #endDTD()
|
||||
* #startEntity(name)
|
||||
* #endEntity(name)
|
||||
*
|
||||
*
|
||||
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html
|
||||
* IGNORED method of org.xml.sax.ext.DeclHandler
|
||||
* #attributeDecl(eName, aName, type, mode, value)
|
||||
* #elementDecl(name, model)
|
||||
* #externalEntityDecl(name, publicId, systemId)
|
||||
* #internalEntityDecl(name, value)
|
||||
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html
|
||||
* IGNORED method of org.xml.sax.EntityResolver2
|
||||
* #resolveEntity(String name,String publicId,String baseURI,String systemId)
|
||||
* #resolveEntity(publicId, systemId)
|
||||
* #getExternalSubset(name, baseURI)
|
||||
* @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html
|
||||
* IGNORED method of org.xml.sax.DTDHandler
|
||||
* #notationDecl(name, publicId, systemId) {};
|
||||
* #unparsedEntityDecl(name, publicId, systemId, notationName) {};
|
||||
*/
|
||||
"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(key){
|
||||
DOMHandler.prototype[key] = function(){return null}
|
||||
})
|
||||
|
||||
/* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */
|
||||
function appendElement (hander,node) {
|
||||
if (!hander.currentElement) {
|
||||
hander.doc.appendChild(node);
|
||||
} else {
|
||||
hander.currentElement.appendChild(node);
|
||||
}
|
||||
}//appendChild and setAttributeNS are preformance key
|
||||
|
||||
exports.__DOMHandler = DOMHandler;
|
||||
exports.normalizeLineEndings = normalizeLineEndings;
|
||||
exports.DOMParser = DOMParser;
|
1840
node_modules/@xmldom/xmldom/lib/dom.js
generated
vendored
Normal file
1840
node_modules/@xmldom/xmldom/lib/dom.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2166
node_modules/@xmldom/xmldom/lib/entities.js
generated
vendored
Normal file
2166
node_modules/@xmldom/xmldom/lib/entities.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
4
node_modules/@xmldom/xmldom/lib/index.js
generated
vendored
Normal file
4
node_modules/@xmldom/xmldom/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
var dom = require('./dom')
|
||||
exports.DOMImplementation = dom.DOMImplementation
|
||||
exports.XMLSerializer = dom.XMLSerializer
|
||||
exports.DOMParser = require('./dom-parser').DOMParser
|
662
node_modules/@xmldom/xmldom/lib/sax.js
generated
vendored
Normal file
662
node_modules/@xmldom/xmldom/lib/sax.js
generated
vendored
Normal file
@@ -0,0 +1,662 @@
|
||||
var NAMESPACE = require("./conventions").NAMESPACE;
|
||||
|
||||
//[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
|
||||
//[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
|
||||
//[5] Name ::= NameStartChar (NameChar)*
|
||||
var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]///\u10000-\uEFFFF
|
||||
var nameChar = new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");
|
||||
var tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\:'+nameStartChar.source+nameChar.source+'*)?$');
|
||||
//var tagNamePattern = /^[a-zA-Z_][\w\-\.]*(?:\:[a-zA-Z_][\w\-\.]*)?$/
|
||||
//var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',')
|
||||
|
||||
//S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
|
||||
//S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
|
||||
var S_TAG = 0;//tag name offerring
|
||||
var S_ATTR = 1;//attr name offerring
|
||||
var S_ATTR_SPACE=2;//attr name end and space offer
|
||||
var S_EQ = 3;//=space?
|
||||
var S_ATTR_NOQUOT_VALUE = 4;//attr value(no quot value only)
|
||||
var S_ATTR_END = 5;//attr value end and no space(quot end)
|
||||
var S_TAG_SPACE = 6;//(attr value end || tag end ) && (space offer)
|
||||
var S_TAG_CLOSE = 7;//closed el<el />
|
||||
|
||||
/**
|
||||
* Creates an error that will not be caught by XMLReader aka the SAX parser.
|
||||
*
|
||||
* @param {string} message
|
||||
* @param {any?} locator Optional, can provide details about the location in the source
|
||||
* @constructor
|
||||
*/
|
||||
function ParseError(message, locator) {
|
||||
this.message = message
|
||||
this.locator = locator
|
||||
if(Error.captureStackTrace) Error.captureStackTrace(this, ParseError);
|
||||
}
|
||||
ParseError.prototype = new Error();
|
||||
ParseError.prototype.name = ParseError.name
|
||||
|
||||
function XMLReader(){
|
||||
|
||||
}
|
||||
|
||||
XMLReader.prototype = {
|
||||
parse:function(source,defaultNSMap,entityMap){
|
||||
var domBuilder = this.domBuilder;
|
||||
domBuilder.startDocument();
|
||||
_copy(defaultNSMap ,defaultNSMap = {})
|
||||
parse(source,defaultNSMap,entityMap,
|
||||
domBuilder,this.errorHandler);
|
||||
domBuilder.endDocument();
|
||||
}
|
||||
}
|
||||
function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
|
||||
function fixedFromCharCode(code) {
|
||||
// String.prototype.fromCharCode does not supports
|
||||
// > 2 bytes unicode chars directly
|
||||
if (code > 0xffff) {
|
||||
code -= 0x10000;
|
||||
var surrogate1 = 0xd800 + (code >> 10)
|
||||
, surrogate2 = 0xdc00 + (code & 0x3ff);
|
||||
|
||||
return String.fromCharCode(surrogate1, surrogate2);
|
||||
} else {
|
||||
return String.fromCharCode(code);
|
||||
}
|
||||
}
|
||||
function entityReplacer(a){
|
||||
var k = a.slice(1,-1);
|
||||
if (Object.hasOwnProperty.call(entityMap, k)) {
|
||||
return entityMap[k];
|
||||
}else if(k.charAt(0) === '#'){
|
||||
return fixedFromCharCode(parseInt(k.substr(1).replace('x','0x')))
|
||||
}else{
|
||||
errorHandler.error('entity not found:'+a);
|
||||
return a;
|
||||
}
|
||||
}
|
||||
function appendText(end){//has some bugs
|
||||
if(end>start){
|
||||
var xt = source.substring(start,end).replace(/&#?\w+;/g,entityReplacer);
|
||||
locator&&position(start);
|
||||
domBuilder.characters(xt,0,end-start);
|
||||
start = end
|
||||
}
|
||||
}
|
||||
function position(p,m){
|
||||
while(p>=lineEnd && (m = linePattern.exec(source))){
|
||||
lineStart = m.index;
|
||||
lineEnd = lineStart + m[0].length;
|
||||
locator.lineNumber++;
|
||||
//console.log('line++:',locator,startPos,endPos)
|
||||
}
|
||||
locator.columnNumber = p-lineStart+1;
|
||||
}
|
||||
var lineStart = 0;
|
||||
var lineEnd = 0;
|
||||
var linePattern = /.*(?:\r\n?|\n)|.*$/g
|
||||
var locator = domBuilder.locator;
|
||||
|
||||
var parseStack = [{currentNSMap:defaultNSMapCopy}]
|
||||
var closeMap = {};
|
||||
var start = 0;
|
||||
while(true){
|
||||
try{
|
||||
var tagStart = source.indexOf('<',start);
|
||||
if(tagStart<0){
|
||||
if(!source.substr(start).match(/^\s*$/)){
|
||||
var doc = domBuilder.doc;
|
||||
var text = doc.createTextNode(source.substr(start));
|
||||
doc.appendChild(text);
|
||||
domBuilder.currentElement = text;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(tagStart>start){
|
||||
appendText(tagStart);
|
||||
}
|
||||
switch(source.charAt(tagStart+1)){
|
||||
case '/':
|
||||
var end = source.indexOf('>',tagStart+3);
|
||||
var tagName = source.substring(tagStart + 2, end).replace(/[ \t\n\r]+$/g, '');
|
||||
var config = parseStack.pop();
|
||||
if(end<0){
|
||||
|
||||
tagName = source.substring(tagStart+2).replace(/[\s<].*/,'');
|
||||
errorHandler.error("end tag name: "+tagName+' is not complete:'+config.tagName);
|
||||
end = tagStart+1+tagName.length;
|
||||
}else if(tagName.match(/\s</)){
|
||||
tagName = tagName.replace(/[\s<].*/,'');
|
||||
errorHandler.error("end tag name: "+tagName+' maybe not complete');
|
||||
end = tagStart+1+tagName.length;
|
||||
}
|
||||
var localNSMap = config.localNSMap;
|
||||
var endMatch = config.tagName == tagName;
|
||||
var endIgnoreCaseMach = endMatch || config.tagName&&config.tagName.toLowerCase() == tagName.toLowerCase()
|
||||
if(endIgnoreCaseMach){
|
||||
domBuilder.endElement(config.uri,config.localName,tagName);
|
||||
if(localNSMap){
|
||||
for (var prefix in localNSMap) {
|
||||
if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {
|
||||
domBuilder.endPrefixMapping(prefix);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!endMatch){
|
||||
errorHandler.fatalError("end tag name: "+tagName+' is not match the current start tagName:'+config.tagName ); // No known test case
|
||||
}
|
||||
}else{
|
||||
parseStack.push(config)
|
||||
}
|
||||
|
||||
end++;
|
||||
break;
|
||||
// end elment
|
||||
case '?':// <?...?>
|
||||
locator&&position(tagStart);
|
||||
end = parseInstruction(source,tagStart,domBuilder);
|
||||
break;
|
||||
case '!':// <!doctype,<![CDATA,<!--
|
||||
locator&&position(tagStart);
|
||||
end = parseDCC(source,tagStart,domBuilder,errorHandler);
|
||||
break;
|
||||
default:
|
||||
locator&&position(tagStart);
|
||||
var el = new ElementAttributes();
|
||||
var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
|
||||
//elStartEnd
|
||||
var end = parseElementStartPart(source,tagStart,el,currentNSMap,entityReplacer,errorHandler);
|
||||
var len = el.length;
|
||||
|
||||
|
||||
if(!el.closed && fixSelfClosed(source,end,el.tagName,closeMap)){
|
||||
el.closed = true;
|
||||
if(!entityMap.nbsp){
|
||||
errorHandler.warning('unclosed xml attribute');
|
||||
}
|
||||
}
|
||||
if(locator && len){
|
||||
var locator2 = copyLocator(locator,{});
|
||||
//try{//attribute position fixed
|
||||
for(var i = 0;i<len;i++){
|
||||
var a = el[i];
|
||||
position(a.offset);
|
||||
a.locator = copyLocator(locator,{});
|
||||
}
|
||||
domBuilder.locator = locator2
|
||||
if(appendElement(el,domBuilder,currentNSMap)){
|
||||
parseStack.push(el)
|
||||
}
|
||||
domBuilder.locator = locator;
|
||||
}else{
|
||||
if(appendElement(el,domBuilder,currentNSMap)){
|
||||
parseStack.push(el)
|
||||
}
|
||||
}
|
||||
|
||||
if (NAMESPACE.isHTML(el.uri) && !el.closed) {
|
||||
end = parseHtmlSpecialContent(source,end,el.tagName,entityReplacer,domBuilder)
|
||||
} else {
|
||||
end++;
|
||||
}
|
||||
}
|
||||
}catch(e){
|
||||
if (e instanceof ParseError) {
|
||||
throw e;
|
||||
}
|
||||
errorHandler.error('element parse error: '+e)
|
||||
end = -1;
|
||||
}
|
||||
if(end>start){
|
||||
start = end;
|
||||
}else{
|
||||
//TODO: 这里有可能sax回退,有位置错误风险
|
||||
appendText(Math.max(tagStart,start)+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
function copyLocator(f,t){
|
||||
t.lineNumber = f.lineNumber;
|
||||
t.columnNumber = f.columnNumber;
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #appendElement(source,elStartEnd,el,selfClosed,entityReplacer,domBuilder,parseStack);
|
||||
* @return end of the elementStartPart(end of elementEndPart for selfClosed el)
|
||||
*/
|
||||
function parseElementStartPart(source,start,el,currentNSMap,entityReplacer,errorHandler){
|
||||
|
||||
/**
|
||||
* @param {string} qname
|
||||
* @param {string} value
|
||||
* @param {number} startIndex
|
||||
*/
|
||||
function addAttribute(qname, value, startIndex) {
|
||||
if (el.attributeNames.hasOwnProperty(qname)) {
|
||||
errorHandler.fatalError('Attribute ' + qname + ' redefined')
|
||||
}
|
||||
el.addValue(
|
||||
qname,
|
||||
// @see https://www.w3.org/TR/xml/#AVNormalize
|
||||
// since the xmldom sax parser does not "interpret" DTD the following is not implemented:
|
||||
// - recursive replacement of (DTD) entity references
|
||||
// - trimming and collapsing multiple spaces into a single one for attributes that are not of type CDATA
|
||||
value.replace(/[\t\n\r]/g, ' ').replace(/&#?\w+;/g, entityReplacer),
|
||||
startIndex
|
||||
)
|
||||
}
|
||||
var attrName;
|
||||
var value;
|
||||
var p = ++start;
|
||||
var s = S_TAG;//status
|
||||
while(true){
|
||||
var c = source.charAt(p);
|
||||
switch(c){
|
||||
case '=':
|
||||
if(s === S_ATTR){//attrName
|
||||
attrName = source.slice(start,p);
|
||||
s = S_EQ;
|
||||
}else if(s === S_ATTR_SPACE){
|
||||
s = S_EQ;
|
||||
}else{
|
||||
//fatalError: equal must after attrName or space after attrName
|
||||
throw new Error('attribute equal must after attrName'); // No known test case
|
||||
}
|
||||
break;
|
||||
case '\'':
|
||||
case '"':
|
||||
if(s === S_EQ || s === S_ATTR //|| s == S_ATTR_SPACE
|
||||
){//equal
|
||||
if(s === S_ATTR){
|
||||
errorHandler.warning('attribute value must after "="')
|
||||
attrName = source.slice(start,p)
|
||||
}
|
||||
start = p+1;
|
||||
p = source.indexOf(c,start)
|
||||
if(p>0){
|
||||
value = source.slice(start, p);
|
||||
addAttribute(attrName, value, start-1);
|
||||
s = S_ATTR_END;
|
||||
}else{
|
||||
//fatalError: no end quot match
|
||||
throw new Error('attribute value no end \''+c+'\' match');
|
||||
}
|
||||
}else if(s == S_ATTR_NOQUOT_VALUE){
|
||||
value = source.slice(start, p);
|
||||
addAttribute(attrName, value, start);
|
||||
errorHandler.warning('attribute "'+attrName+'" missed start quot('+c+')!!');
|
||||
start = p+1;
|
||||
s = S_ATTR_END
|
||||
}else{
|
||||
//fatalError: no equal before
|
||||
throw new Error('attribute value must after "="'); // No known test case
|
||||
}
|
||||
break;
|
||||
case '/':
|
||||
switch(s){
|
||||
case S_TAG:
|
||||
el.setTagName(source.slice(start,p));
|
||||
case S_ATTR_END:
|
||||
case S_TAG_SPACE:
|
||||
case S_TAG_CLOSE:
|
||||
s =S_TAG_CLOSE;
|
||||
el.closed = true;
|
||||
case S_ATTR_NOQUOT_VALUE:
|
||||
case S_ATTR:
|
||||
break;
|
||||
case S_ATTR_SPACE:
|
||||
el.closed = true;
|
||||
break;
|
||||
//case S_EQ:
|
||||
default:
|
||||
throw new Error("attribute invalid close char('/')") // No known test case
|
||||
}
|
||||
break;
|
||||
case ''://end document
|
||||
errorHandler.error('unexpected end of input');
|
||||
if(s == S_TAG){
|
||||
el.setTagName(source.slice(start,p));
|
||||
}
|
||||
return p;
|
||||
case '>':
|
||||
switch(s){
|
||||
case S_TAG:
|
||||
el.setTagName(source.slice(start,p));
|
||||
case S_ATTR_END:
|
||||
case S_TAG_SPACE:
|
||||
case S_TAG_CLOSE:
|
||||
break;//normal
|
||||
case S_ATTR_NOQUOT_VALUE://Compatible state
|
||||
case S_ATTR:
|
||||
value = source.slice(start,p);
|
||||
if(value.slice(-1) === '/'){
|
||||
el.closed = true;
|
||||
value = value.slice(0,-1)
|
||||
}
|
||||
case S_ATTR_SPACE:
|
||||
if(s === S_ATTR_SPACE){
|
||||
value = attrName;
|
||||
}
|
||||
if(s == S_ATTR_NOQUOT_VALUE){
|
||||
errorHandler.warning('attribute "'+value+'" missed quot(")!');
|
||||
addAttribute(attrName, value, start)
|
||||
}else{
|
||||
if(!NAMESPACE.isHTML(currentNSMap['']) || !value.match(/^(?:disabled|checked|selected)$/i)){
|
||||
errorHandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!')
|
||||
}
|
||||
addAttribute(value, value, start)
|
||||
}
|
||||
break;
|
||||
case S_EQ:
|
||||
throw new Error('attribute value missed!!');
|
||||
}
|
||||
// console.log(tagName,tagNamePattern,tagNamePattern.test(tagName))
|
||||
return p;
|
||||
/*xml space '\x20' | #x9 | #xD | #xA; */
|
||||
case '\u0080':
|
||||
c = ' ';
|
||||
default:
|
||||
if(c<= ' '){//space
|
||||
switch(s){
|
||||
case S_TAG:
|
||||
el.setTagName(source.slice(start,p));//tagName
|
||||
s = S_TAG_SPACE;
|
||||
break;
|
||||
case S_ATTR:
|
||||
attrName = source.slice(start,p)
|
||||
s = S_ATTR_SPACE;
|
||||
break;
|
||||
case S_ATTR_NOQUOT_VALUE:
|
||||
var value = source.slice(start, p);
|
||||
errorHandler.warning('attribute "'+value+'" missed quot(")!!');
|
||||
addAttribute(attrName, value, start)
|
||||
case S_ATTR_END:
|
||||
s = S_TAG_SPACE;
|
||||
break;
|
||||
//case S_TAG_SPACE:
|
||||
//case S_EQ:
|
||||
//case S_ATTR_SPACE:
|
||||
// void();break;
|
||||
//case S_TAG_CLOSE:
|
||||
//ignore warning
|
||||
}
|
||||
}else{//not space
|
||||
//S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
|
||||
//S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
|
||||
switch(s){
|
||||
//case S_TAG:void();break;
|
||||
//case S_ATTR:void();break;
|
||||
//case S_ATTR_NOQUOT_VALUE:void();break;
|
||||
case S_ATTR_SPACE:
|
||||
var tagName = el.tagName;
|
||||
if (!NAMESPACE.isHTML(currentNSMap['']) || !attrName.match(/^(?:disabled|checked|selected)$/i)) {
|
||||
errorHandler.warning('attribute "'+attrName+'" missed value!! "'+attrName+'" instead2!!')
|
||||
}
|
||||
addAttribute(attrName, attrName, start);
|
||||
start = p;
|
||||
s = S_ATTR;
|
||||
break;
|
||||
case S_ATTR_END:
|
||||
errorHandler.warning('attribute space is required"'+attrName+'"!!')
|
||||
case S_TAG_SPACE:
|
||||
s = S_ATTR;
|
||||
start = p;
|
||||
break;
|
||||
case S_EQ:
|
||||
s = S_ATTR_NOQUOT_VALUE;
|
||||
start = p;
|
||||
break;
|
||||
case S_TAG_CLOSE:
|
||||
throw new Error("elements closed character '/' and '>' must be connected to");
|
||||
}
|
||||
}
|
||||
}//end outer switch
|
||||
//console.log('p++',p)
|
||||
p++;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @return true if has new namespace define
|
||||
*/
|
||||
function appendElement(el,domBuilder,currentNSMap){
|
||||
var tagName = el.tagName;
|
||||
var localNSMap = null;
|
||||
//var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
|
||||
var i = el.length;
|
||||
while(i--){
|
||||
var a = el[i];
|
||||
var qName = a.qName;
|
||||
var value = a.value;
|
||||
var nsp = qName.indexOf(':');
|
||||
if(nsp>0){
|
||||
var prefix = a.prefix = qName.slice(0,nsp);
|
||||
var localName = qName.slice(nsp+1);
|
||||
var nsPrefix = prefix === 'xmlns' && localName
|
||||
}else{
|
||||
localName = qName;
|
||||
prefix = null
|
||||
nsPrefix = qName === 'xmlns' && ''
|
||||
}
|
||||
//can not set prefix,because prefix !== ''
|
||||
a.localName = localName ;
|
||||
//prefix == null for no ns prefix attribute
|
||||
if(nsPrefix !== false){//hack!!
|
||||
if(localNSMap == null){
|
||||
localNSMap = {}
|
||||
//console.log(currentNSMap,0)
|
||||
_copy(currentNSMap,currentNSMap={})
|
||||
//console.log(currentNSMap,1)
|
||||
}
|
||||
currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
|
||||
a.uri = NAMESPACE.XMLNS
|
||||
domBuilder.startPrefixMapping(nsPrefix, value)
|
||||
}
|
||||
}
|
||||
var i = el.length;
|
||||
while(i--){
|
||||
a = el[i];
|
||||
var prefix = a.prefix;
|
||||
if(prefix){//no prefix attribute has no namespace
|
||||
if(prefix === 'xml'){
|
||||
a.uri = NAMESPACE.XML;
|
||||
}if(prefix !== 'xmlns'){
|
||||
a.uri = currentNSMap[prefix || '']
|
||||
|
||||
//{console.log('###'+a.qName,domBuilder.locator.systemId+'',currentNSMap,a.uri)}
|
||||
}
|
||||
}
|
||||
}
|
||||
var nsp = tagName.indexOf(':');
|
||||
if(nsp>0){
|
||||
prefix = el.prefix = tagName.slice(0,nsp);
|
||||
localName = el.localName = tagName.slice(nsp+1);
|
||||
}else{
|
||||
prefix = null;//important!!
|
||||
localName = el.localName = tagName;
|
||||
}
|
||||
//no prefix element has default namespace
|
||||
var ns = el.uri = currentNSMap[prefix || ''];
|
||||
domBuilder.startElement(ns,localName,tagName,el);
|
||||
//endPrefixMapping and startPrefixMapping have not any help for dom builder
|
||||
//localNSMap = null
|
||||
if(el.closed){
|
||||
domBuilder.endElement(ns,localName,tagName);
|
||||
if(localNSMap){
|
||||
for (prefix in localNSMap) {
|
||||
if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {
|
||||
domBuilder.endPrefixMapping(prefix);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
el.currentNSMap = currentNSMap;
|
||||
el.localNSMap = localNSMap;
|
||||
//parseStack.push(el);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
function parseHtmlSpecialContent(source,elStartEnd,tagName,entityReplacer,domBuilder){
|
||||
if(/^(?:script|textarea)$/i.test(tagName)){
|
||||
var elEndStart = source.indexOf('</'+tagName+'>',elStartEnd);
|
||||
var text = source.substring(elStartEnd+1,elEndStart);
|
||||
if(/[&<]/.test(text)){
|
||||
if(/^script$/i.test(tagName)){
|
||||
//if(!/\]\]>/.test(text)){
|
||||
//lexHandler.startCDATA();
|
||||
domBuilder.characters(text,0,text.length);
|
||||
//lexHandler.endCDATA();
|
||||
return elEndStart;
|
||||
//}
|
||||
}//}else{//text area
|
||||
text = text.replace(/&#?\w+;/g,entityReplacer);
|
||||
domBuilder.characters(text,0,text.length);
|
||||
return elEndStart;
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
return elStartEnd+1;
|
||||
}
|
||||
function fixSelfClosed(source,elStartEnd,tagName,closeMap){
|
||||
//if(tagName in closeMap){
|
||||
var pos = closeMap[tagName];
|
||||
if(pos == null){
|
||||
//console.log(tagName)
|
||||
pos = source.lastIndexOf('</'+tagName+'>')
|
||||
if(pos<elStartEnd){//忘记闭合
|
||||
pos = source.lastIndexOf('</'+tagName)
|
||||
}
|
||||
closeMap[tagName] =pos
|
||||
}
|
||||
return pos<elStartEnd;
|
||||
//}
|
||||
}
|
||||
|
||||
function _copy (source, target) {
|
||||
for (var n in source) {
|
||||
if (Object.prototype.hasOwnProperty.call(source, n)) {
|
||||
target[n] = source[n];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function parseDCC(source,start,domBuilder,errorHandler){//sure start with '<!'
|
||||
var next= source.charAt(start+2)
|
||||
switch(next){
|
||||
case '-':
|
||||
if(source.charAt(start + 3) === '-'){
|
||||
var end = source.indexOf('-->',start+4);
|
||||
//append comment source.substring(4,end)//<!--
|
||||
if(end>start){
|
||||
domBuilder.comment(source,start+4,end-start-4);
|
||||
return end+3;
|
||||
}else{
|
||||
errorHandler.error("Unclosed comment");
|
||||
return -1;
|
||||
}
|
||||
}else{
|
||||
//error
|
||||
return -1;
|
||||
}
|
||||
default:
|
||||
if(source.substr(start+3,6) == 'CDATA['){
|
||||
var end = source.indexOf(']]>',start+9);
|
||||
domBuilder.startCDATA();
|
||||
domBuilder.characters(source,start+9,end-start-9);
|
||||
domBuilder.endCDATA()
|
||||
return end+3;
|
||||
}
|
||||
//<!DOCTYPE
|
||||
//startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
|
||||
var matchs = split(source,start);
|
||||
var len = matchs.length;
|
||||
if(len>1 && /!doctype/i.test(matchs[0][0])){
|
||||
var name = matchs[1][0];
|
||||
var pubid = false;
|
||||
var sysid = false;
|
||||
if(len>3){
|
||||
if(/^public$/i.test(matchs[2][0])){
|
||||
pubid = matchs[3][0];
|
||||
sysid = len>4 && matchs[4][0];
|
||||
}else if(/^system$/i.test(matchs[2][0])){
|
||||
sysid = matchs[3][0];
|
||||
}
|
||||
}
|
||||
var lastMatch = matchs[len-1]
|
||||
domBuilder.startDTD(name, pubid, sysid);
|
||||
domBuilder.endDTD();
|
||||
|
||||
return lastMatch.index+lastMatch[0].length
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function parseInstruction(source,start,domBuilder){
|
||||
var end = source.indexOf('?>',start);
|
||||
if(end){
|
||||
var match = source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
|
||||
if(match){
|
||||
var len = match[0].length;
|
||||
domBuilder.processingInstruction(match[1], match[2]) ;
|
||||
return end+2;
|
||||
}else{//error
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
function ElementAttributes(){
|
||||
this.attributeNames = {}
|
||||
}
|
||||
ElementAttributes.prototype = {
|
||||
setTagName:function(tagName){
|
||||
if(!tagNamePattern.test(tagName)){
|
||||
throw new Error('invalid tagName:'+tagName)
|
||||
}
|
||||
this.tagName = tagName
|
||||
},
|
||||
addValue:function(qName, value, offset) {
|
||||
if(!tagNamePattern.test(qName)){
|
||||
throw new Error('invalid attribute:'+qName)
|
||||
}
|
||||
this.attributeNames[qName] = this.length;
|
||||
this[this.length++] = {qName:qName,value:value,offset:offset}
|
||||
},
|
||||
length:0,
|
||||
getLocalName:function(i){return this[i].localName},
|
||||
getLocator:function(i){return this[i].locator},
|
||||
getQName:function(i){return this[i].qName},
|
||||
getURI:function(i){return this[i].uri},
|
||||
getValue:function(i){return this[i].value}
|
||||
// ,getIndex:function(uri, localName)){
|
||||
// if(localName){
|
||||
//
|
||||
// }else{
|
||||
// var qName = uri
|
||||
// }
|
||||
// },
|
||||
// getValue:function(){return this.getValue(this.getIndex.apply(this,arguments))},
|
||||
// getType:function(uri,localName){}
|
||||
// getType:function(i){},
|
||||
}
|
||||
|
||||
|
||||
|
||||
function split(source,start){
|
||||
var match;
|
||||
var buf = [];
|
||||
var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
|
||||
reg.lastIndex = start;
|
||||
reg.exec(source);//skip <
|
||||
while(match = reg.exec(source)){
|
||||
buf.push(match);
|
||||
if(match[1])return buf;
|
||||
}
|
||||
}
|
||||
|
||||
exports.XMLReader = XMLReader;
|
||||
exports.ParseError = ParseError;
|
71
node_modules/@xmldom/xmldom/package.json
generated
vendored
Normal file
71
node_modules/@xmldom/xmldom/package.json
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
{
|
||||
"name": "@xmldom/xmldom",
|
||||
"version": "0.8.10",
|
||||
"description": "A pure JavaScript W3C standard-based (XML DOM Level 2 Core) DOMParser and XMLSerializer module.",
|
||||
"keywords": [
|
||||
"w3c",
|
||||
"dom",
|
||||
"xml",
|
||||
"parser",
|
||||
"javascript",
|
||||
"DOMParser",
|
||||
"XMLSerializer",
|
||||
"ponyfill"
|
||||
],
|
||||
"homepage": "https://github.com/xmldom/xmldom",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/xmldom/xmldom.git"
|
||||
},
|
||||
"main": "lib/index.js",
|
||||
"types": "index.d.ts",
|
||||
"files": [
|
||||
"CHANGELOG.md",
|
||||
"LICENSE",
|
||||
"readme.md",
|
||||
"SECURITY.md",
|
||||
"index.d.ts",
|
||||
"lib"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "eslint lib test",
|
||||
"format": "prettier --write test",
|
||||
"changelog": "auto-changelog --unreleased-only",
|
||||
"start": "nodemon --watch package.json --watch lib --watch test --exec 'npm --silent run test && npm --silent run lint'",
|
||||
"stryker": "stryker run",
|
||||
"stryker:dry-run": "stryker run -m '' --reporters progress",
|
||||
"test": "jest",
|
||||
"testrelease": "npm test && eslint lib",
|
||||
"version": "./changelog-has-version.sh",
|
||||
"release": "np --no-yarn --test-script testrelease --branch release-0.8.x patch"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@stryker-mutator/core": "5.6.1",
|
||||
"auto-changelog": "2.4.0",
|
||||
"eslint": "8.25.0",
|
||||
"eslint-config-prettier": "8.5.0",
|
||||
"eslint-plugin-es5": "1.5.0",
|
||||
"eslint-plugin-prettier": "4.2.1",
|
||||
"get-stream": "6.0.1",
|
||||
"jest": "27.5.1",
|
||||
"nodemon": "2.0.20",
|
||||
"np": "7.6.2",
|
||||
"prettier": "2.7.1",
|
||||
"xmltest": "1.5.0",
|
||||
"yauzl": "2.10.0"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/xmldom/xmldom/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"auto-changelog": {
|
||||
"prepend": true,
|
||||
"remote": "upstream",
|
||||
"tagPrefix": "",
|
||||
"template": "./auto-changelog.hbs"
|
||||
}
|
||||
}
|
356
node_modules/@xmldom/xmldom/readme.md
generated
vendored
Normal file
356
node_modules/@xmldom/xmldom/readme.md
generated
vendored
Normal file
@@ -0,0 +1,356 @@
|
||||
# @xmldom/xmldom
|
||||
|
||||
***Since version 0.7.0 this package is published to npm as [`@xmldom/xmldom`](https://www.npmjs.com/package/@xmldom/xmldom) and no longer as [`xmldom`](https://www.npmjs.com/package/xmldom), because [we are no longer able to publish `xmldom`](https://github.com/xmldom/xmldom/issues/271).***
|
||||
*For better readability in the docs we will continue to talk about this library as "xmldom".*
|
||||
|
||||
[](https://github.com/xmldom/xmldom/blob/master/LICENSE)
|
||||
[](https://www.npmjs.com/package/@xmldom/xmldom)
|
||||
[](https://snyk.io/advisor/npm-package/@xmldom/xmldom)
|
||||
[](https://github.com/xmldom/xmldom/issues?q=is%3Aissue+is%3Aopen+label%3Abug)
|
||||
[](https://github.com/xmldom/xmldom/issues?q=is%3Aissue+is%3Aopen+label%3Ahelp-wanted)
|
||||
[](https://dashboard.stryker-mutator.io/reports/github.com/xmldom/xmldom/master)
|
||||
|
||||
|
||||
xmldom is a javascript [ponyfill](https://ponyfill.com/) to provide the following APIs [that are present in modern browsers](https://caniuse.com/xml-serializer) to other runtimes:
|
||||
- convert an XML string into a DOM tree
|
||||
```
|
||||
new DOMParser().parseFromString(xml, mimeType) => Document
|
||||
```
|
||||
- create, access and modify a DOM tree
|
||||
```
|
||||
new DOMImplementation().createDocument(...) => Document
|
||||
```
|
||||
- serialize a DOM tree back into an XML string
|
||||
```
|
||||
new XMLSerializer().serializeToString(node) => string
|
||||
```
|
||||
|
||||
The target runtimes `xmldom` supports are currently Node >= v10 (ES5) and Rhino ([not tested as part of CI](https://github.com/xmldom/xmldom/discussions/214)).
|
||||
|
||||
When deciding how to fix bugs or implement features, `xmldom` tries to stay as close as possible to the various [related specifications/standards](#specs).
|
||||
As indicated by the version starting with `0.`, this implementation is not feature complete and some implemented features differ from what the specifications describe.
|
||||
**Issues and PRs for such differences are always welcome, even when they only provide a failing test case.**
|
||||
|
||||
This project was forked from it's [original source](https://github.com/jindw/xmldom) in 2019, more details about that transition can be found in the [CHANGELOG](CHANGELOG.md#maintainer-changes).
|
||||
|
||||
## Usage
|
||||
|
||||
### Install:
|
||||
|
||||
> npm install @xmldom/xmldom
|
||||
|
||||
### Example:
|
||||
|
||||
[In NodeJS](examples/nodejs/src/index.js)
|
||||
```javascript
|
||||
const { DOMParser, XMLSerializer } = require('@xmldom/xmldom')
|
||||
|
||||
const source = `<xml xmlns="a">
|
||||
<child>test</child>
|
||||
<child/>
|
||||
</xml>`
|
||||
|
||||
const doc = new DOMParser().parseFromString(source, 'text/xml')
|
||||
|
||||
const serialized = new XMLSerializer().serializeToString(doc)
|
||||
```
|
||||
|
||||
Note: in Typescript ~and ES6~(see #316) you can use the `import` approach, as follows:
|
||||
|
||||
```typescript
|
||||
import { DOMParser } from '@xmldom/xmldom'
|
||||
```
|
||||
|
||||
## API Reference
|
||||
|
||||
* [DOMParser](https://developer.mozilla.org/en-US/docs/Web/API/DOMParser):
|
||||
|
||||
```javascript
|
||||
parseFromString(xmlsource,mimeType)
|
||||
```
|
||||
* **options extension** _by xmldom_ (not DOM standard!!)
|
||||
|
||||
```javascript
|
||||
//added the options argument
|
||||
new DOMParser(options)
|
||||
|
||||
//errorHandler is supported
|
||||
new DOMParser({
|
||||
/**
|
||||
* locator is always need for error position info
|
||||
*/
|
||||
locator:{},
|
||||
/**
|
||||
* you can override the errorHandler for xml parser
|
||||
* @link http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html
|
||||
*/
|
||||
errorHandler:{warning:function(w){console.warn(w)},error:callback,fatalError:callback}
|
||||
//only callback model
|
||||
//errorHandler:function(level,msg){console.log(level,msg)}
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
* [XMLSerializer](https://developer.mozilla.org/en-US/docs/Web/API/XMLSerializer)
|
||||
|
||||
```javascript
|
||||
serializeToString(node)
|
||||
```
|
||||
### DOM level2 method and attribute:
|
||||
|
||||
* [Node](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247)
|
||||
|
||||
readonly class properties (aka `NodeType`),
|
||||
these can be accessed from any `Node` instance `node`:
|
||||
`if (node.nodeType === node.ELEMENT_NODE) {...`
|
||||
|
||||
1. `ELEMENT_NODE` (`1`)
|
||||
2. `ATTRIBUTE_NODE` (`2`)
|
||||
3. `TEXT_NODE` (`3`)
|
||||
4. `CDATA_SECTION_NODE` (`4`)
|
||||
5. `ENTITY_REFERENCE_NODE` (`5`)
|
||||
6. `ENTITY_NODE` (`6`)
|
||||
7. `PROCESSING_INSTRUCTION_NODE` (`7`)
|
||||
8. `COMMENT_NODE` (`8`)
|
||||
9. `DOCUMENT_NODE` (`9`)
|
||||
10. `DOCUMENT_TYPE_NODE` (`10`)
|
||||
11. `DOCUMENT_FRAGMENT_NODE` (`11`)
|
||||
12. `NOTATION_NODE` (`12`)
|
||||
|
||||
attribute:
|
||||
- `nodeValue` | `prefix`
|
||||
|
||||
readonly attribute:
|
||||
- `nodeName` | `nodeType` | `parentNode` | `childNodes` | `firstChild` | `lastChild` | `previousSibling` | `nextSibling` | `attributes` | `ownerDocument` | `namespaceURI` | `localName`
|
||||
|
||||
method:
|
||||
* `insertBefore(newChild, refChild)`
|
||||
* `replaceChild(newChild, oldChild)`
|
||||
* `removeChild(oldChild)`
|
||||
* `appendChild(newChild)`
|
||||
* `hasChildNodes()`
|
||||
* `cloneNode(deep)`
|
||||
* `normalize()`
|
||||
* `isSupported(feature, version)`
|
||||
* `hasAttributes()`
|
||||
* [DOMException](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html)
|
||||
|
||||
extends the Error type thrown as part of DOM API.
|
||||
|
||||
readonly class properties:
|
||||
- `INDEX_SIZE_ERR` (`1`)
|
||||
- `DOMSTRING_SIZE_ERR` (`2`)
|
||||
- `HIERARCHY_REQUEST_ERR` (`3`)
|
||||
- `WRONG_DOCUMENT_ERR` (`4`)
|
||||
- `INVALID_CHARACTER_ERR` (`5`)
|
||||
- `NO_DATA_ALLOWED_ERR` (`6`)
|
||||
- `NO_MODIFICATION_ALLOWED_ERR` (`7`)
|
||||
- `NOT_FOUND_ERR` (`8`)
|
||||
- `NOT_SUPPORTED_ERR` (`9`)
|
||||
- `INUSE_ATTRIBUTE_ERR` (`10`)
|
||||
- `INVALID_STATE_ERR` (`11`)
|
||||
- `SYNTAX_ERR` (`12`)
|
||||
- `INVALID_MODIFICATION_ERR` (`13`)
|
||||
- `NAMESPACE_ERR` (`14`)
|
||||
- `INVALID_ACCESS_ERR` (`15`)
|
||||
|
||||
attributes:
|
||||
- `code` with a value matching one of the above constants.
|
||||
|
||||
* [DOMImplementation](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-102161490)
|
||||
|
||||
method:
|
||||
- `hasFeature(feature, version)`
|
||||
- `createDocumentType(qualifiedName, publicId, systemId)`
|
||||
- `createDocument(namespaceURI, qualifiedName, doctype)`
|
||||
|
||||
* [Document](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#i-Document) : Node
|
||||
|
||||
readonly attribute:
|
||||
- `doctype` | `implementation` | `documentElement`
|
||||
|
||||
method:
|
||||
- `createElement(tagName)`
|
||||
- `createDocumentFragment()`
|
||||
- `createTextNode(data)`
|
||||
- `createComment(data)`
|
||||
- `createCDATASection(data)`
|
||||
- `createProcessingInstruction(target, data)`
|
||||
- `createAttribute(name)`
|
||||
- `createEntityReference(name)`
|
||||
- `getElementsByTagName(tagname)`
|
||||
- `importNode(importedNode, deep)`
|
||||
- `createElementNS(namespaceURI, qualifiedName)`
|
||||
- `createAttributeNS(namespaceURI, qualifiedName)`
|
||||
- `getElementsByTagNameNS(namespaceURI, localName)`
|
||||
- `getElementById(elementId)`
|
||||
|
||||
* [DocumentFragment](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-B63ED1A3) : Node
|
||||
* [Element](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-745549614) : Node
|
||||
|
||||
readonly attribute:
|
||||
- `tagName`
|
||||
|
||||
method:
|
||||
- `getAttribute(name)`
|
||||
- `setAttribute(name, value)`
|
||||
- `removeAttribute(name)`
|
||||
- `getAttributeNode(name)`
|
||||
- `setAttributeNode(newAttr)`
|
||||
- `removeAttributeNode(oldAttr)`
|
||||
- `getElementsByTagName(name)`
|
||||
- `getAttributeNS(namespaceURI, localName)`
|
||||
- `setAttributeNS(namespaceURI, qualifiedName, value)`
|
||||
- `removeAttributeNS(namespaceURI, localName)`
|
||||
- `getAttributeNodeNS(namespaceURI, localName)`
|
||||
- `setAttributeNodeNS(newAttr)`
|
||||
- `getElementsByTagNameNS(namespaceURI, localName)`
|
||||
- `hasAttribute(name)`
|
||||
- `hasAttributeNS(namespaceURI, localName)`
|
||||
|
||||
* [Attr](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-637646024) : Node
|
||||
|
||||
attribute:
|
||||
- `value`
|
||||
|
||||
readonly attribute:
|
||||
- `name` | `specified` | `ownerElement`
|
||||
|
||||
* [NodeList](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177)
|
||||
|
||||
readonly attribute:
|
||||
- `length`
|
||||
|
||||
method:
|
||||
- `item(index)`
|
||||
|
||||
* [NamedNodeMap](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1780488922)
|
||||
|
||||
readonly attribute:
|
||||
- `length`
|
||||
|
||||
method:
|
||||
- `getNamedItem(name)`
|
||||
- `setNamedItem(arg)`
|
||||
- `removeNamedItem(name)`
|
||||
- `item(index)`
|
||||
- `getNamedItemNS(namespaceURI, localName)`
|
||||
- `setNamedItemNS(arg)`
|
||||
- `removeNamedItemNS(namespaceURI, localName)`
|
||||
|
||||
* [CharacterData](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-FF21A306) : Node
|
||||
|
||||
method:
|
||||
- `substringData(offset, count)`
|
||||
- `appendData(arg)`
|
||||
- `insertData(offset, arg)`
|
||||
- `deleteData(offset, count)`
|
||||
- `replaceData(offset, count, arg)`
|
||||
|
||||
* [Text](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1312295772) : CharacterData
|
||||
|
||||
method:
|
||||
- `splitText(offset)`
|
||||
|
||||
* [CDATASection](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-667469212)
|
||||
* [Comment](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1728279322) : CharacterData
|
||||
|
||||
* [DocumentType](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-412266927)
|
||||
|
||||
readonly attribute:
|
||||
- `name` | `entities` | `notations` | `publicId` | `systemId` | `internalSubset`
|
||||
|
||||
* Notation : Node
|
||||
|
||||
readonly attribute:
|
||||
- `publicId` | `systemId`
|
||||
|
||||
* Entity : Node
|
||||
|
||||
readonly attribute:
|
||||
- `publicId` | `systemId` | `notationName`
|
||||
|
||||
* EntityReference : Node
|
||||
* ProcessingInstruction : Node
|
||||
|
||||
attribute:
|
||||
- `data`
|
||||
readonly attribute:
|
||||
- `target`
|
||||
|
||||
### DOM level 3 support:
|
||||
|
||||
* [Node](http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-textContent)
|
||||
|
||||
attribute:
|
||||
- `textContent`
|
||||
|
||||
method:
|
||||
- `isDefaultNamespace(namespaceURI)`
|
||||
- `lookupNamespaceURI(prefix)`
|
||||
|
||||
### DOM extension by xmldom
|
||||
|
||||
* [Node] Source position extension;
|
||||
|
||||
attribute:
|
||||
- `lineNumber` //number starting from `1`
|
||||
- `columnNumber` //number starting from `1`
|
||||
|
||||
## Specs
|
||||
|
||||
The implementation is based on several specifications:
|
||||
|
||||
<!-- Should open in new tab and the links in the SVG should be clickable there! -->
|
||||
<a href="https://raw.githubusercontent.com/xmldom/xmldom/master/docs/specs.svg" target="_blank" rel="noopener noreferrer nofollow" ></a>
|
||||
|
||||
### DOM Parsing and Serialization
|
||||
|
||||
From the [W3C DOM Parsing and Serialization (WD 2016)](https://www.w3.org/TR/2016/WD-DOM-Parsing-20160517/) `xmldom` provides an implementation for the interfaces:
|
||||
- `DOMParser`
|
||||
- `XMLSerializer`
|
||||
|
||||
Note that there are some known deviations between this implementation and the W3 specifications.
|
||||
|
||||
Note: [The latest version of this spec](https://w3c.github.io/DOM-Parsing/) has the status "Editors Draft", since it is under active development. One major change is that [the definition of the `DOMParser` interface has been moved to the HTML spec](https://w3c.github.io/DOM-Parsing/#the-domparser-interface)
|
||||
|
||||
|
||||
### DOM
|
||||
|
||||
The original author claims that xmldom implements [DOM Level 2] in a "fully compatible" way and some parts of [DOM Level 3], but there are not enough tests to prove this. Both Specifications are now superseded by the [DOM Level 4 aka Living standard] wich has a much broader scope than xmldom.
|
||||
|
||||
xmldom implements the following interfaces (most constructors are currently not exposed):
|
||||
- `Attr`
|
||||
- `CDATASection`
|
||||
- `CharacterData`
|
||||
- `Comment`
|
||||
- `Document`
|
||||
- `DocumentFragment`
|
||||
- `DocumentType`
|
||||
- `DOMException` (constructor exposed)
|
||||
- `DOMImplementation` (constructor exposed)
|
||||
- `Element`
|
||||
- `Entity`
|
||||
- `EntityReference`
|
||||
- `LiveNodeList`
|
||||
- `NamedNodeMap`
|
||||
- `Node` (constructor exposed)
|
||||
- `NodeList`
|
||||
- `Notation`
|
||||
- `ProcessingInstruction`
|
||||
- `Text`
|
||||
|
||||
more details are available in the (incomplete) [API Reference](#api-reference) section.
|
||||
|
||||
### HTML
|
||||
|
||||
xmldom does not have any goal of supporting the full spec, but it has some capability to parse, report and serialize things differently when "detecting HTML" (by checking the default namespace).
|
||||
There is an upcoming change to better align the implementation with the latest specs, related to <https://github.com/xmldom/xmldom/issues/203>.
|
||||
|
||||
### SAX, XML, XMLNS
|
||||
|
||||
xmldom has an own SAX parser implementation to do the actual parsing, which implements some interfaces in alignment with the Java interfaces SAX defines:
|
||||
- `XMLReader`
|
||||
- `DOMHandler`
|
||||
|
||||
There is an idea/proposal to make it possible to replace it with something else in <https://github.com/xmldom/xmldom/issues/55>
|
100
node_modules/asn1.js/README.md
generated
vendored
Normal file
100
node_modules/asn1.js/README.md
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
# ASN1.js
|
||||
|
||||
ASN.1 DER Encoder/Decoder and DSL.
|
||||
|
||||
## Example
|
||||
|
||||
Define model:
|
||||
|
||||
```javascript
|
||||
var asn = require('asn1.js');
|
||||
|
||||
var Human = asn.define('Human', function() {
|
||||
this.seq().obj(
|
||||
this.key('firstName').octstr(),
|
||||
this.key('lastName').octstr(),
|
||||
this.key('age').int(),
|
||||
this.key('gender').enum({ 0: 'male', 1: 'female' }),
|
||||
this.key('bio').seqof(Bio)
|
||||
);
|
||||
});
|
||||
|
||||
var Bio = asn.define('Bio', function() {
|
||||
this.seq().obj(
|
||||
this.key('time').gentime(),
|
||||
this.key('description').octstr()
|
||||
);
|
||||
});
|
||||
```
|
||||
|
||||
Encode data:
|
||||
|
||||
```javascript
|
||||
var output = Human.encode({
|
||||
firstName: 'Thomas',
|
||||
lastName: 'Anderson',
|
||||
age: 28,
|
||||
gender: 'male',
|
||||
bio: [
|
||||
{
|
||||
time: +new Date('31 March 1999'),
|
||||
description: 'freedom of mind'
|
||||
}
|
||||
]
|
||||
}, 'der');
|
||||
```
|
||||
|
||||
Decode data:
|
||||
|
||||
```javascript
|
||||
var human = Human.decode(output, 'der');
|
||||
console.log(human);
|
||||
/*
|
||||
{ firstName: <Buffer 54 68 6f 6d 61 73>,
|
||||
lastName: <Buffer 41 6e 64 65 72 73 6f 6e>,
|
||||
age: 28,
|
||||
gender: 'male',
|
||||
bio:
|
||||
[ { time: 922820400000,
|
||||
description: <Buffer 66 72 65 65 64 6f 6d 20 6f 66 20 6d 69 6e 64> } ] }
|
||||
*/
|
||||
```
|
||||
|
||||
### Partial decode
|
||||
|
||||
Its possible to parse data without stopping on first error. In order to do it,
|
||||
you should call:
|
||||
|
||||
```javascript
|
||||
var human = Human.decode(output, 'der', { partial: true });
|
||||
console.log(human);
|
||||
/*
|
||||
{ result: { ... },
|
||||
errors: [ ... ] }
|
||||
*/
|
||||
```
|
||||
|
||||
#### LICENSE
|
||||
|
||||
This software is licensed under the MIT License.
|
||||
|
||||
Copyright Fedor Indutny, 2013.
|
||||
|
||||
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.
|
9
node_modules/asn1.js/lib/asn1.js
generated
vendored
Normal file
9
node_modules/asn1.js/lib/asn1.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
var asn1 = exports;
|
||||
|
||||
asn1.bignum = require('bn.js');
|
||||
|
||||
asn1.define = require('./asn1/api').define;
|
||||
asn1.base = require('./asn1/base');
|
||||
asn1.constants = require('./asn1/constants');
|
||||
asn1.decoders = require('./asn1/decoders');
|
||||
asn1.encoders = require('./asn1/encoders');
|
61
node_modules/asn1.js/lib/asn1/api.js
generated
vendored
Normal file
61
node_modules/asn1.js/lib/asn1/api.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
var asn1 = require('../asn1');
|
||||
var inherits = require('inherits');
|
||||
|
||||
var api = exports;
|
||||
|
||||
api.define = function define(name, body) {
|
||||
return new Entity(name, body);
|
||||
};
|
||||
|
||||
function Entity(name, body) {
|
||||
this.name = name;
|
||||
this.body = body;
|
||||
|
||||
this.decoders = {};
|
||||
this.encoders = {};
|
||||
};
|
||||
|
||||
Entity.prototype._createNamed = function createNamed(base) {
|
||||
var named;
|
||||
try {
|
||||
named = require('vm').runInThisContext(
|
||||
'(function ' + this.name + '(entity) {\n' +
|
||||
' this._initNamed(entity);\n' +
|
||||
'})'
|
||||
);
|
||||
} catch (e) {
|
||||
named = function (entity) {
|
||||
this._initNamed(entity);
|
||||
};
|
||||
}
|
||||
inherits(named, base);
|
||||
named.prototype._initNamed = function initnamed(entity) {
|
||||
base.call(this, entity);
|
||||
};
|
||||
|
||||
return new named(this);
|
||||
};
|
||||
|
||||
Entity.prototype._getDecoder = function _getDecoder(enc) {
|
||||
enc = enc || 'der';
|
||||
// Lazily create decoder
|
||||
if (!this.decoders.hasOwnProperty(enc))
|
||||
this.decoders[enc] = this._createNamed(asn1.decoders[enc]);
|
||||
return this.decoders[enc];
|
||||
};
|
||||
|
||||
Entity.prototype.decode = function decode(data, enc, options) {
|
||||
return this._getDecoder(enc).decode(data, options);
|
||||
};
|
||||
|
||||
Entity.prototype._getEncoder = function _getEncoder(enc) {
|
||||
enc = enc || 'der';
|
||||
// Lazily create encoder
|
||||
if (!this.encoders.hasOwnProperty(enc))
|
||||
this.encoders[enc] = this._createNamed(asn1.encoders[enc]);
|
||||
return this.encoders[enc];
|
||||
};
|
||||
|
||||
Entity.prototype.encode = function encode(data, enc, /* internal */ reporter) {
|
||||
return this._getEncoder(enc).encode(data, reporter);
|
||||
};
|
116
node_modules/asn1.js/lib/asn1/base/buffer.js
generated
vendored
Normal file
116
node_modules/asn1.js/lib/asn1/base/buffer.js
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
var inherits = require('inherits');
|
||||
var Reporter = require('../base').Reporter;
|
||||
var Buffer = require('buffer').Buffer;
|
||||
|
||||
function DecoderBuffer(base, options) {
|
||||
Reporter.call(this, options);
|
||||
if (!Buffer.isBuffer(base)) {
|
||||
this.error('Input not Buffer');
|
||||
return;
|
||||
}
|
||||
|
||||
this.base = base;
|
||||
this.offset = 0;
|
||||
this.length = base.length;
|
||||
}
|
||||
inherits(DecoderBuffer, Reporter);
|
||||
exports.DecoderBuffer = DecoderBuffer;
|
||||
|
||||
DecoderBuffer.prototype.save = function save() {
|
||||
return { offset: this.offset, reporter: Reporter.prototype.save.call(this) };
|
||||
};
|
||||
|
||||
DecoderBuffer.prototype.restore = function restore(save) {
|
||||
// Return skipped data
|
||||
var res = new DecoderBuffer(this.base);
|
||||
res.offset = save.offset;
|
||||
res.length = this.offset;
|
||||
|
||||
this.offset = save.offset;
|
||||
Reporter.prototype.restore.call(this, save.reporter);
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
DecoderBuffer.prototype.isEmpty = function isEmpty() {
|
||||
return this.offset === this.length;
|
||||
};
|
||||
|
||||
DecoderBuffer.prototype.readUInt8 = function readUInt8(fail) {
|
||||
if (this.offset + 1 <= this.length)
|
||||
return this.base.readUInt8(this.offset++, true);
|
||||
else
|
||||
return this.error(fail || 'DecoderBuffer overrun');
|
||||
}
|
||||
|
||||
DecoderBuffer.prototype.skip = function skip(bytes, fail) {
|
||||
if (!(this.offset + bytes <= this.length))
|
||||
return this.error(fail || 'DecoderBuffer overrun');
|
||||
|
||||
var res = new DecoderBuffer(this.base);
|
||||
|
||||
// Share reporter state
|
||||
res._reporterState = this._reporterState;
|
||||
|
||||
res.offset = this.offset;
|
||||
res.length = this.offset + bytes;
|
||||
this.offset += bytes;
|
||||
return res;
|
||||
}
|
||||
|
||||
DecoderBuffer.prototype.raw = function raw(save) {
|
||||
return this.base.slice(save ? save.offset : this.offset, this.length);
|
||||
}
|
||||
|
||||
function EncoderBuffer(value, reporter) {
|
||||
if (Array.isArray(value)) {
|
||||
this.length = 0;
|
||||
this.value = value.map(function(item) {
|
||||
if (!(item instanceof EncoderBuffer))
|
||||
item = new EncoderBuffer(item, reporter);
|
||||
this.length += item.length;
|
||||
return item;
|
||||
}, this);
|
||||
} else if (typeof value === 'number') {
|
||||
if (!(0 <= value && value <= 0xff))
|
||||
return reporter.error('non-byte EncoderBuffer value');
|
||||
this.value = value;
|
||||
this.length = 1;
|
||||
} else if (typeof value === 'string') {
|
||||
this.value = value;
|
||||
this.length = Buffer.byteLength(value);
|
||||
} else if (Buffer.isBuffer(value)) {
|
||||
this.value = value;
|
||||
this.length = value.length;
|
||||
} else {
|
||||
return reporter.error('Unsupported type: ' + typeof value);
|
||||
}
|
||||
}
|
||||
exports.EncoderBuffer = EncoderBuffer;
|
||||
|
||||
EncoderBuffer.prototype.join = function join(out, offset) {
|
||||
if (!out)
|
||||
out = new Buffer(this.length);
|
||||
if (!offset)
|
||||
offset = 0;
|
||||
|
||||
if (this.length === 0)
|
||||
return out;
|
||||
|
||||
if (Array.isArray(this.value)) {
|
||||
this.value.forEach(function(item) {
|
||||
item.join(out, offset);
|
||||
offset += item.length;
|
||||
});
|
||||
} else {
|
||||
if (typeof this.value === 'number')
|
||||
out[offset] = this.value;
|
||||
else if (typeof this.value === 'string')
|
||||
out.write(this.value, offset);
|
||||
else if (Buffer.isBuffer(this.value))
|
||||
this.value.copy(out, offset);
|
||||
offset += this.length;
|
||||
}
|
||||
|
||||
return out;
|
||||
};
|
6
node_modules/asn1.js/lib/asn1/base/index.js
generated
vendored
Normal file
6
node_modules/asn1.js/lib/asn1/base/index.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
var base = exports;
|
||||
|
||||
base.Reporter = require('./reporter').Reporter;
|
||||
base.DecoderBuffer = require('./buffer').DecoderBuffer;
|
||||
base.EncoderBuffer = require('./buffer').EncoderBuffer;
|
||||
base.Node = require('./node');
|
634
node_modules/asn1.js/lib/asn1/base/node.js
generated
vendored
Normal file
634
node_modules/asn1.js/lib/asn1/base/node.js
generated
vendored
Normal file
@@ -0,0 +1,634 @@
|
||||
var Reporter = require('../base').Reporter;
|
||||
var EncoderBuffer = require('../base').EncoderBuffer;
|
||||
var DecoderBuffer = require('../base').DecoderBuffer;
|
||||
var assert = require('minimalistic-assert');
|
||||
|
||||
// Supported tags
|
||||
var tags = [
|
||||
'seq', 'seqof', 'set', 'setof', 'objid', 'bool',
|
||||
'gentime', 'utctime', 'null_', 'enum', 'int', 'objDesc',
|
||||
'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str',
|
||||
'numstr', 'octstr', 'printstr', 't61str', 'unistr', 'utf8str', 'videostr'
|
||||
];
|
||||
|
||||
// Public methods list
|
||||
var methods = [
|
||||
'key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice',
|
||||
'any', 'contains'
|
||||
].concat(tags);
|
||||
|
||||
// Overrided methods list
|
||||
var overrided = [
|
||||
'_peekTag', '_decodeTag', '_use',
|
||||
'_decodeStr', '_decodeObjid', '_decodeTime',
|
||||
'_decodeNull', '_decodeInt', '_decodeBool', '_decodeList',
|
||||
|
||||
'_encodeComposite', '_encodeStr', '_encodeObjid', '_encodeTime',
|
||||
'_encodeNull', '_encodeInt', '_encodeBool'
|
||||
];
|
||||
|
||||
function Node(enc, parent) {
|
||||
var state = {};
|
||||
this._baseState = state;
|
||||
|
||||
state.enc = enc;
|
||||
|
||||
state.parent = parent || null;
|
||||
state.children = null;
|
||||
|
||||
// State
|
||||
state.tag = null;
|
||||
state.args = null;
|
||||
state.reverseArgs = null;
|
||||
state.choice = null;
|
||||
state.optional = false;
|
||||
state.any = false;
|
||||
state.obj = false;
|
||||
state.use = null;
|
||||
state.useDecoder = null;
|
||||
state.key = null;
|
||||
state['default'] = null;
|
||||
state.explicit = null;
|
||||
state.implicit = null;
|
||||
state.contains = null;
|
||||
|
||||
// Should create new instance on each method
|
||||
if (!state.parent) {
|
||||
state.children = [];
|
||||
this._wrap();
|
||||
}
|
||||
}
|
||||
module.exports = Node;
|
||||
|
||||
var stateProps = [
|
||||
'enc', 'parent', 'children', 'tag', 'args', 'reverseArgs', 'choice',
|
||||
'optional', 'any', 'obj', 'use', 'alteredUse', 'key', 'default', 'explicit',
|
||||
'implicit', 'contains'
|
||||
];
|
||||
|
||||
Node.prototype.clone = function clone() {
|
||||
var state = this._baseState;
|
||||
var cstate = {};
|
||||
stateProps.forEach(function(prop) {
|
||||
cstate[prop] = state[prop];
|
||||
});
|
||||
var res = new this.constructor(cstate.parent);
|
||||
res._baseState = cstate;
|
||||
return res;
|
||||
};
|
||||
|
||||
Node.prototype._wrap = function wrap() {
|
||||
var state = this._baseState;
|
||||
methods.forEach(function(method) {
|
||||
this[method] = function _wrappedMethod() {
|
||||
var clone = new this.constructor(this);
|
||||
state.children.push(clone);
|
||||
return clone[method].apply(clone, arguments);
|
||||
};
|
||||
}, this);
|
||||
};
|
||||
|
||||
Node.prototype._init = function init(body) {
|
||||
var state = this._baseState;
|
||||
|
||||
assert(state.parent === null);
|
||||
body.call(this);
|
||||
|
||||
// Filter children
|
||||
state.children = state.children.filter(function(child) {
|
||||
return child._baseState.parent === this;
|
||||
}, this);
|
||||
assert.equal(state.children.length, 1, 'Root node can have only one child');
|
||||
};
|
||||
|
||||
Node.prototype._useArgs = function useArgs(args) {
|
||||
var state = this._baseState;
|
||||
|
||||
// Filter children and args
|
||||
var children = args.filter(function(arg) {
|
||||
return arg instanceof this.constructor;
|
||||
}, this);
|
||||
args = args.filter(function(arg) {
|
||||
return !(arg instanceof this.constructor);
|
||||
}, this);
|
||||
|
||||
if (children.length !== 0) {
|
||||
assert(state.children === null);
|
||||
state.children = children;
|
||||
|
||||
// Replace parent to maintain backward link
|
||||
children.forEach(function(child) {
|
||||
child._baseState.parent = this;
|
||||
}, this);
|
||||
}
|
||||
if (args.length !== 0) {
|
||||
assert(state.args === null);
|
||||
state.args = args;
|
||||
state.reverseArgs = args.map(function(arg) {
|
||||
if (typeof arg !== 'object' || arg.constructor !== Object)
|
||||
return arg;
|
||||
|
||||
var res = {};
|
||||
Object.keys(arg).forEach(function(key) {
|
||||
if (key == (key | 0))
|
||||
key |= 0;
|
||||
var value = arg[key];
|
||||
res[value] = key;
|
||||
});
|
||||
return res;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Overrided methods
|
||||
//
|
||||
|
||||
overrided.forEach(function(method) {
|
||||
Node.prototype[method] = function _overrided() {
|
||||
var state = this._baseState;
|
||||
throw new Error(method + ' not implemented for encoding: ' + state.enc);
|
||||
};
|
||||
});
|
||||
|
||||
//
|
||||
// Public methods
|
||||
//
|
||||
|
||||
tags.forEach(function(tag) {
|
||||
Node.prototype[tag] = function _tagMethod() {
|
||||
var state = this._baseState;
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
|
||||
assert(state.tag === null);
|
||||
state.tag = tag;
|
||||
|
||||
this._useArgs(args);
|
||||
|
||||
return this;
|
||||
};
|
||||
});
|
||||
|
||||
Node.prototype.use = function use(item) {
|
||||
assert(item);
|
||||
var state = this._baseState;
|
||||
|
||||
assert(state.use === null);
|
||||
state.use = item;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Node.prototype.optional = function optional() {
|
||||
var state = this._baseState;
|
||||
|
||||
state.optional = true;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Node.prototype.def = function def(val) {
|
||||
var state = this._baseState;
|
||||
|
||||
assert(state['default'] === null);
|
||||
state['default'] = val;
|
||||
state.optional = true;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Node.prototype.explicit = function explicit(num) {
|
||||
var state = this._baseState;
|
||||
|
||||
assert(state.explicit === null && state.implicit === null);
|
||||
state.explicit = num;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Node.prototype.implicit = function implicit(num) {
|
||||
var state = this._baseState;
|
||||
|
||||
assert(state.explicit === null && state.implicit === null);
|
||||
state.implicit = num;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Node.prototype.obj = function obj() {
|
||||
var state = this._baseState;
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
|
||||
state.obj = true;
|
||||
|
||||
if (args.length !== 0)
|
||||
this._useArgs(args);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Node.prototype.key = function key(newKey) {
|
||||
var state = this._baseState;
|
||||
|
||||
assert(state.key === null);
|
||||
state.key = newKey;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Node.prototype.any = function any() {
|
||||
var state = this._baseState;
|
||||
|
||||
state.any = true;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Node.prototype.choice = function choice(obj) {
|
||||
var state = this._baseState;
|
||||
|
||||
assert(state.choice === null);
|
||||
state.choice = obj;
|
||||
this._useArgs(Object.keys(obj).map(function(key) {
|
||||
return obj[key];
|
||||
}));
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Node.prototype.contains = function contains(item) {
|
||||
var state = this._baseState;
|
||||
|
||||
assert(state.use === null);
|
||||
state.contains = item;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
//
|
||||
// Decoding
|
||||
//
|
||||
|
||||
Node.prototype._decode = function decode(input, options) {
|
||||
var state = this._baseState;
|
||||
|
||||
// Decode root node
|
||||
if (state.parent === null)
|
||||
return input.wrapResult(state.children[0]._decode(input, options));
|
||||
|
||||
var result = state['default'];
|
||||
var present = true;
|
||||
|
||||
var prevKey = null;
|
||||
if (state.key !== null)
|
||||
prevKey = input.enterKey(state.key);
|
||||
|
||||
// Check if tag is there
|
||||
if (state.optional) {
|
||||
var tag = null;
|
||||
if (state.explicit !== null)
|
||||
tag = state.explicit;
|
||||
else if (state.implicit !== null)
|
||||
tag = state.implicit;
|
||||
else if (state.tag !== null)
|
||||
tag = state.tag;
|
||||
|
||||
if (tag === null && !state.any) {
|
||||
// Trial and Error
|
||||
var save = input.save();
|
||||
try {
|
||||
if (state.choice === null)
|
||||
this._decodeGeneric(state.tag, input, options);
|
||||
else
|
||||
this._decodeChoice(input, options);
|
||||
present = true;
|
||||
} catch (e) {
|
||||
present = false;
|
||||
}
|
||||
input.restore(save);
|
||||
} else {
|
||||
present = this._peekTag(input, tag, state.any);
|
||||
|
||||
if (input.isError(present))
|
||||
return present;
|
||||
}
|
||||
}
|
||||
|
||||
// Push object on stack
|
||||
var prevObj;
|
||||
if (state.obj && present)
|
||||
prevObj = input.enterObject();
|
||||
|
||||
if (present) {
|
||||
// Unwrap explicit values
|
||||
if (state.explicit !== null) {
|
||||
var explicit = this._decodeTag(input, state.explicit);
|
||||
if (input.isError(explicit))
|
||||
return explicit;
|
||||
input = explicit;
|
||||
}
|
||||
|
||||
var start = input.offset;
|
||||
|
||||
// Unwrap implicit and normal values
|
||||
if (state.use === null && state.choice === null) {
|
||||
if (state.any)
|
||||
var save = input.save();
|
||||
var body = this._decodeTag(
|
||||
input,
|
||||
state.implicit !== null ? state.implicit : state.tag,
|
||||
state.any
|
||||
);
|
||||
if (input.isError(body))
|
||||
return body;
|
||||
|
||||
if (state.any)
|
||||
result = input.raw(save);
|
||||
else
|
||||
input = body;
|
||||
}
|
||||
|
||||
if (options && options.track && state.tag !== null)
|
||||
options.track(input.path(), start, input.length, 'tagged');
|
||||
|
||||
if (options && options.track && state.tag !== null)
|
||||
options.track(input.path(), input.offset, input.length, 'content');
|
||||
|
||||
// Select proper method for tag
|
||||
if (state.any)
|
||||
result = result;
|
||||
else if (state.choice === null)
|
||||
result = this._decodeGeneric(state.tag, input, options);
|
||||
else
|
||||
result = this._decodeChoice(input, options);
|
||||
|
||||
if (input.isError(result))
|
||||
return result;
|
||||
|
||||
// Decode children
|
||||
if (!state.any && state.choice === null && state.children !== null) {
|
||||
state.children.forEach(function decodeChildren(child) {
|
||||
// NOTE: We are ignoring errors here, to let parser continue with other
|
||||
// parts of encoded data
|
||||
child._decode(input, options);
|
||||
});
|
||||
}
|
||||
|
||||
// Decode contained/encoded by schema, only in bit or octet strings
|
||||
if (state.contains && (state.tag === 'octstr' || state.tag === 'bitstr')) {
|
||||
var data = new DecoderBuffer(result);
|
||||
result = this._getUse(state.contains, input._reporterState.obj)
|
||||
._decode(data, options);
|
||||
}
|
||||
}
|
||||
|
||||
// Pop object
|
||||
if (state.obj && present)
|
||||
result = input.leaveObject(prevObj);
|
||||
|
||||
// Set key
|
||||
if (state.key !== null && (result !== null || present === true))
|
||||
input.leaveKey(prevKey, state.key, result);
|
||||
else if (prevKey !== null)
|
||||
input.exitKey(prevKey);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) {
|
||||
var state = this._baseState;
|
||||
|
||||
if (tag === 'seq' || tag === 'set')
|
||||
return null;
|
||||
if (tag === 'seqof' || tag === 'setof')
|
||||
return this._decodeList(input, tag, state.args[0], options);
|
||||
else if (/str$/.test(tag))
|
||||
return this._decodeStr(input, tag, options);
|
||||
else if (tag === 'objid' && state.args)
|
||||
return this._decodeObjid(input, state.args[0], state.args[1], options);
|
||||
else if (tag === 'objid')
|
||||
return this._decodeObjid(input, null, null, options);
|
||||
else if (tag === 'gentime' || tag === 'utctime')
|
||||
return this._decodeTime(input, tag, options);
|
||||
else if (tag === 'null_')
|
||||
return this._decodeNull(input, options);
|
||||
else if (tag === 'bool')
|
||||
return this._decodeBool(input, options);
|
||||
else if (tag === 'objDesc')
|
||||
return this._decodeStr(input, tag, options);
|
||||
else if (tag === 'int' || tag === 'enum')
|
||||
return this._decodeInt(input, state.args && state.args[0], options);
|
||||
|
||||
if (state.use !== null) {
|
||||
return this._getUse(state.use, input._reporterState.obj)
|
||||
._decode(input, options);
|
||||
} else {
|
||||
return input.error('unknown tag: ' + tag);
|
||||
}
|
||||
};
|
||||
|
||||
Node.prototype._getUse = function _getUse(entity, obj) {
|
||||
|
||||
var state = this._baseState;
|
||||
// Create altered use decoder if implicit is set
|
||||
state.useDecoder = this._use(entity, obj);
|
||||
assert(state.useDecoder._baseState.parent === null);
|
||||
state.useDecoder = state.useDecoder._baseState.children[0];
|
||||
if (state.implicit !== state.useDecoder._baseState.implicit) {
|
||||
state.useDecoder = state.useDecoder.clone();
|
||||
state.useDecoder._baseState.implicit = state.implicit;
|
||||
}
|
||||
return state.useDecoder;
|
||||
};
|
||||
|
||||
Node.prototype._decodeChoice = function decodeChoice(input, options) {
|
||||
var state = this._baseState;
|
||||
var result = null;
|
||||
var match = false;
|
||||
|
||||
Object.keys(state.choice).some(function(key) {
|
||||
var save = input.save();
|
||||
var node = state.choice[key];
|
||||
try {
|
||||
var value = node._decode(input, options);
|
||||
if (input.isError(value))
|
||||
return false;
|
||||
|
||||
result = { type: key, value: value };
|
||||
match = true;
|
||||
} catch (e) {
|
||||
input.restore(save);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}, this);
|
||||
|
||||
if (!match)
|
||||
return input.error('Choice not matched');
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
//
|
||||
// Encoding
|
||||
//
|
||||
|
||||
Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) {
|
||||
return new EncoderBuffer(data, this.reporter);
|
||||
};
|
||||
|
||||
Node.prototype._encode = function encode(data, reporter, parent) {
|
||||
var state = this._baseState;
|
||||
if (state['default'] !== null && state['default'] === data)
|
||||
return;
|
||||
|
||||
var result = this._encodeValue(data, reporter, parent);
|
||||
if (result === undefined)
|
||||
return;
|
||||
|
||||
if (this._skipDefault(result, reporter, parent))
|
||||
return;
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
Node.prototype._encodeValue = function encode(data, reporter, parent) {
|
||||
var state = this._baseState;
|
||||
|
||||
// Decode root node
|
||||
if (state.parent === null)
|
||||
return state.children[0]._encode(data, reporter || new Reporter());
|
||||
|
||||
var result = null;
|
||||
|
||||
// Set reporter to share it with a child class
|
||||
this.reporter = reporter;
|
||||
|
||||
// Check if data is there
|
||||
if (state.optional && data === undefined) {
|
||||
if (state['default'] !== null)
|
||||
data = state['default']
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
// Encode children first
|
||||
var content = null;
|
||||
var primitive = false;
|
||||
if (state.any) {
|
||||
// Anything that was given is translated to buffer
|
||||
result = this._createEncoderBuffer(data);
|
||||
} else if (state.choice) {
|
||||
result = this._encodeChoice(data, reporter);
|
||||
} else if (state.contains) {
|
||||
content = this._getUse(state.contains, parent)._encode(data, reporter);
|
||||
primitive = true;
|
||||
} else if (state.children) {
|
||||
content = state.children.map(function(child) {
|
||||
if (child._baseState.tag === 'null_')
|
||||
return child._encode(null, reporter, data);
|
||||
|
||||
if (child._baseState.key === null)
|
||||
return reporter.error('Child should have a key');
|
||||
var prevKey = reporter.enterKey(child._baseState.key);
|
||||
|
||||
if (typeof data !== 'object')
|
||||
return reporter.error('Child expected, but input is not object');
|
||||
|
||||
var res = child._encode(data[child._baseState.key], reporter, data);
|
||||
reporter.leaveKey(prevKey);
|
||||
|
||||
return res;
|
||||
}, this).filter(function(child) {
|
||||
return child;
|
||||
});
|
||||
content = this._createEncoderBuffer(content);
|
||||
} else {
|
||||
if (state.tag === 'seqof' || state.tag === 'setof') {
|
||||
// TODO(indutny): this should be thrown on DSL level
|
||||
if (!(state.args && state.args.length === 1))
|
||||
return reporter.error('Too many args for : ' + state.tag);
|
||||
|
||||
if (!Array.isArray(data))
|
||||
return reporter.error('seqof/setof, but data is not Array');
|
||||
|
||||
var child = this.clone();
|
||||
child._baseState.implicit = null;
|
||||
content = this._createEncoderBuffer(data.map(function(item) {
|
||||
var state = this._baseState;
|
||||
|
||||
return this._getUse(state.args[0], data)._encode(item, reporter);
|
||||
}, child));
|
||||
} else if (state.use !== null) {
|
||||
result = this._getUse(state.use, parent)._encode(data, reporter);
|
||||
} else {
|
||||
content = this._encodePrimitive(state.tag, data);
|
||||
primitive = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Encode data itself
|
||||
var result;
|
||||
if (!state.any && state.choice === null) {
|
||||
var tag = state.implicit !== null ? state.implicit : state.tag;
|
||||
var cls = state.implicit === null ? 'universal' : 'context';
|
||||
|
||||
if (tag === null) {
|
||||
if (state.use === null)
|
||||
reporter.error('Tag could be omitted only for .use()');
|
||||
} else {
|
||||
if (state.use === null)
|
||||
result = this._encodeComposite(tag, primitive, cls, content);
|
||||
}
|
||||
}
|
||||
|
||||
// Wrap in explicit
|
||||
if (state.explicit !== null)
|
||||
result = this._encodeComposite(state.explicit, false, 'context', result);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
Node.prototype._encodeChoice = function encodeChoice(data, reporter) {
|
||||
var state = this._baseState;
|
||||
|
||||
var node = state.choice[data.type];
|
||||
if (!node) {
|
||||
assert(
|
||||
false,
|
||||
data.type + ' not found in ' +
|
||||
JSON.stringify(Object.keys(state.choice)));
|
||||
}
|
||||
return node._encode(data.value, reporter);
|
||||
};
|
||||
|
||||
Node.prototype._encodePrimitive = function encodePrimitive(tag, data) {
|
||||
var state = this._baseState;
|
||||
|
||||
if (/str$/.test(tag))
|
||||
return this._encodeStr(data, tag);
|
||||
else if (tag === 'objid' && state.args)
|
||||
return this._encodeObjid(data, state.reverseArgs[0], state.args[1]);
|
||||
else if (tag === 'objid')
|
||||
return this._encodeObjid(data, null, null);
|
||||
else if (tag === 'gentime' || tag === 'utctime')
|
||||
return this._encodeTime(data, tag);
|
||||
else if (tag === 'null_')
|
||||
return this._encodeNull();
|
||||
else if (tag === 'int' || tag === 'enum')
|
||||
return this._encodeInt(data, state.args && state.reverseArgs[0]);
|
||||
else if (tag === 'bool')
|
||||
return this._encodeBool(data);
|
||||
else if (tag === 'objDesc')
|
||||
return this._encodeStr(data, tag);
|
||||
else
|
||||
throw new Error('Unsupported tag: ' + tag);
|
||||
};
|
||||
|
||||
Node.prototype._isNumstr = function isNumstr(str) {
|
||||
return /^[0-9 ]*$/.test(str);
|
||||
};
|
||||
|
||||
Node.prototype._isPrintstr = function isPrintstr(str) {
|
||||
return /^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(str);
|
||||
};
|
121
node_modules/asn1.js/lib/asn1/base/reporter.js
generated
vendored
Normal file
121
node_modules/asn1.js/lib/asn1/base/reporter.js
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
var inherits = require('inherits');
|
||||
|
||||
function Reporter(options) {
|
||||
this._reporterState = {
|
||||
obj: null,
|
||||
path: [],
|
||||
options: options || {},
|
||||
errors: []
|
||||
};
|
||||
}
|
||||
exports.Reporter = Reporter;
|
||||
|
||||
Reporter.prototype.isError = function isError(obj) {
|
||||
return obj instanceof ReporterError;
|
||||
};
|
||||
|
||||
Reporter.prototype.save = function save() {
|
||||
var state = this._reporterState;
|
||||
|
||||
return { obj: state.obj, pathLen: state.path.length };
|
||||
};
|
||||
|
||||
Reporter.prototype.restore = function restore(data) {
|
||||
var state = this._reporterState;
|
||||
|
||||
state.obj = data.obj;
|
||||
state.path = state.path.slice(0, data.pathLen);
|
||||
};
|
||||
|
||||
Reporter.prototype.enterKey = function enterKey(key) {
|
||||
return this._reporterState.path.push(key);
|
||||
};
|
||||
|
||||
Reporter.prototype.exitKey = function exitKey(index) {
|
||||
var state = this._reporterState;
|
||||
|
||||
state.path = state.path.slice(0, index - 1);
|
||||
};
|
||||
|
||||
Reporter.prototype.leaveKey = function leaveKey(index, key, value) {
|
||||
var state = this._reporterState;
|
||||
|
||||
this.exitKey(index);
|
||||
if (state.obj !== null)
|
||||
state.obj[key] = value;
|
||||
};
|
||||
|
||||
Reporter.prototype.path = function path() {
|
||||
return this._reporterState.path.join('/');
|
||||
};
|
||||
|
||||
Reporter.prototype.enterObject = function enterObject() {
|
||||
var state = this._reporterState;
|
||||
|
||||
var prev = state.obj;
|
||||
state.obj = {};
|
||||
return prev;
|
||||
};
|
||||
|
||||
Reporter.prototype.leaveObject = function leaveObject(prev) {
|
||||
var state = this._reporterState;
|
||||
|
||||
var now = state.obj;
|
||||
state.obj = prev;
|
||||
return now;
|
||||
};
|
||||
|
||||
Reporter.prototype.error = function error(msg) {
|
||||
var err;
|
||||
var state = this._reporterState;
|
||||
|
||||
var inherited = msg instanceof ReporterError;
|
||||
if (inherited) {
|
||||
err = msg;
|
||||
} else {
|
||||
err = new ReporterError(state.path.map(function(elem) {
|
||||
return '[' + JSON.stringify(elem) + ']';
|
||||
}).join(''), msg.message || msg, msg.stack);
|
||||
}
|
||||
|
||||
if (!state.options.partial)
|
||||
throw err;
|
||||
|
||||
if (!inherited)
|
||||
state.errors.push(err);
|
||||
|
||||
return err;
|
||||
};
|
||||
|
||||
Reporter.prototype.wrapResult = function wrapResult(result) {
|
||||
var state = this._reporterState;
|
||||
if (!state.options.partial)
|
||||
return result;
|
||||
|
||||
return {
|
||||
result: this.isError(result) ? null : result,
|
||||
errors: state.errors
|
||||
};
|
||||
};
|
||||
|
||||
function ReporterError(path, msg) {
|
||||
this.path = path;
|
||||
this.rethrow(msg);
|
||||
};
|
||||
inherits(ReporterError, Error);
|
||||
|
||||
ReporterError.prototype.rethrow = function rethrow(msg) {
|
||||
this.message = msg + ' at: ' + (this.path || '(shallow)');
|
||||
if (Error.captureStackTrace)
|
||||
Error.captureStackTrace(this, ReporterError);
|
||||
|
||||
if (!this.stack) {
|
||||
try {
|
||||
// IE only adds stack when thrown
|
||||
throw new Error(this.message);
|
||||
} catch (e) {
|
||||
this.stack = e.stack;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
};
|
42
node_modules/asn1.js/lib/asn1/constants/der.js
generated
vendored
Normal file
42
node_modules/asn1.js/lib/asn1/constants/der.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
var constants = require('../constants');
|
||||
|
||||
exports.tagClass = {
|
||||
0: 'universal',
|
||||
1: 'application',
|
||||
2: 'context',
|
||||
3: 'private'
|
||||
};
|
||||
exports.tagClassByName = constants._reverse(exports.tagClass);
|
||||
|
||||
exports.tag = {
|
||||
0x00: 'end',
|
||||
0x01: 'bool',
|
||||
0x02: 'int',
|
||||
0x03: 'bitstr',
|
||||
0x04: 'octstr',
|
||||
0x05: 'null_',
|
||||
0x06: 'objid',
|
||||
0x07: 'objDesc',
|
||||
0x08: 'external',
|
||||
0x09: 'real',
|
||||
0x0a: 'enum',
|
||||
0x0b: 'embed',
|
||||
0x0c: 'utf8str',
|
||||
0x0d: 'relativeOid',
|
||||
0x10: 'seq',
|
||||
0x11: 'set',
|
||||
0x12: 'numstr',
|
||||
0x13: 'printstr',
|
||||
0x14: 't61str',
|
||||
0x15: 'videostr',
|
||||
0x16: 'ia5str',
|
||||
0x17: 'utctime',
|
||||
0x18: 'gentime',
|
||||
0x19: 'graphstr',
|
||||
0x1a: 'iso646str',
|
||||
0x1b: 'genstr',
|
||||
0x1c: 'unistr',
|
||||
0x1d: 'charstr',
|
||||
0x1e: 'bmpstr'
|
||||
};
|
||||
exports.tagByName = constants._reverse(exports.tag);
|
19
node_modules/asn1.js/lib/asn1/constants/index.js
generated
vendored
Normal file
19
node_modules/asn1.js/lib/asn1/constants/index.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
var constants = exports;
|
||||
|
||||
// Helper
|
||||
constants._reverse = function reverse(map) {
|
||||
var res = {};
|
||||
|
||||
Object.keys(map).forEach(function(key) {
|
||||
// Convert key to integer if it is stringified
|
||||
if ((key | 0) == key)
|
||||
key = key | 0;
|
||||
|
||||
var value = map[key];
|
||||
res[value] = key;
|
||||
});
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
constants.der = require('./der');
|
324
node_modules/asn1.js/lib/asn1/decoders/der.js
generated
vendored
Normal file
324
node_modules/asn1.js/lib/asn1/decoders/der.js
generated
vendored
Normal file
@@ -0,0 +1,324 @@
|
||||
var inherits = require('inherits');
|
||||
|
||||
var asn1 = require('../../asn1');
|
||||
var base = asn1.base;
|
||||
var bignum = asn1.bignum;
|
||||
|
||||
// Import DER constants
|
||||
var der = asn1.constants.der;
|
||||
|
||||
function DERDecoder(entity) {
|
||||
this.enc = 'der';
|
||||
this.name = entity.name;
|
||||
this.entity = entity;
|
||||
|
||||
// Construct base tree
|
||||
this.tree = new DERNode();
|
||||
this.tree._init(entity.body);
|
||||
};
|
||||
module.exports = DERDecoder;
|
||||
|
||||
DERDecoder.prototype.decode = function decode(data, options) {
|
||||
if (!(data instanceof base.DecoderBuffer))
|
||||
data = new base.DecoderBuffer(data, options);
|
||||
|
||||
return this.tree._decode(data, options);
|
||||
};
|
||||
|
||||
// Tree methods
|
||||
|
||||
function DERNode(parent) {
|
||||
base.Node.call(this, 'der', parent);
|
||||
}
|
||||
inherits(DERNode, base.Node);
|
||||
|
||||
DERNode.prototype._peekTag = function peekTag(buffer, tag, any) {
|
||||
if (buffer.isEmpty())
|
||||
return false;
|
||||
|
||||
var state = buffer.save();
|
||||
var decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"');
|
||||
if (buffer.isError(decodedTag))
|
||||
return decodedTag;
|
||||
|
||||
buffer.restore(state);
|
||||
|
||||
return decodedTag.tag === tag || decodedTag.tagStr === tag ||
|
||||
(decodedTag.tagStr + 'of') === tag || any;
|
||||
};
|
||||
|
||||
DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) {
|
||||
var decodedTag = derDecodeTag(buffer,
|
||||
'Failed to decode tag of "' + tag + '"');
|
||||
if (buffer.isError(decodedTag))
|
||||
return decodedTag;
|
||||
|
||||
var len = derDecodeLen(buffer,
|
||||
decodedTag.primitive,
|
||||
'Failed to get length of "' + tag + '"');
|
||||
|
||||
// Failure
|
||||
if (buffer.isError(len))
|
||||
return len;
|
||||
|
||||
if (!any &&
|
||||
decodedTag.tag !== tag &&
|
||||
decodedTag.tagStr !== tag &&
|
||||
decodedTag.tagStr + 'of' !== tag) {
|
||||
return buffer.error('Failed to match tag: "' + tag + '"');
|
||||
}
|
||||
|
||||
if (decodedTag.primitive || len !== null)
|
||||
return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
|
||||
|
||||
// Indefinite length... find END tag
|
||||
var state = buffer.save();
|
||||
var res = this._skipUntilEnd(
|
||||
buffer,
|
||||
'Failed to skip indefinite length body: "' + this.tag + '"');
|
||||
if (buffer.isError(res))
|
||||
return res;
|
||||
|
||||
len = buffer.offset - state.offset;
|
||||
buffer.restore(state);
|
||||
return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
|
||||
};
|
||||
|
||||
DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) {
|
||||
while (true) {
|
||||
var tag = derDecodeTag(buffer, fail);
|
||||
if (buffer.isError(tag))
|
||||
return tag;
|
||||
var len = derDecodeLen(buffer, tag.primitive, fail);
|
||||
if (buffer.isError(len))
|
||||
return len;
|
||||
|
||||
var res;
|
||||
if (tag.primitive || len !== null)
|
||||
res = buffer.skip(len)
|
||||
else
|
||||
res = this._skipUntilEnd(buffer, fail);
|
||||
|
||||
// Failure
|
||||
if (buffer.isError(res))
|
||||
return res;
|
||||
|
||||
if (tag.tagStr === 'end')
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder,
|
||||
options) {
|
||||
var result = [];
|
||||
while (!buffer.isEmpty()) {
|
||||
var possibleEnd = this._peekTag(buffer, 'end');
|
||||
if (buffer.isError(possibleEnd))
|
||||
return possibleEnd;
|
||||
|
||||
var res = decoder.decode(buffer, 'der', options);
|
||||
if (buffer.isError(res) && possibleEnd)
|
||||
break;
|
||||
result.push(res);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
DERNode.prototype._decodeStr = function decodeStr(buffer, tag) {
|
||||
if (tag === 'bitstr') {
|
||||
var unused = buffer.readUInt8();
|
||||
if (buffer.isError(unused))
|
||||
return unused;
|
||||
return { unused: unused, data: buffer.raw() };
|
||||
} else if (tag === 'bmpstr') {
|
||||
var raw = buffer.raw();
|
||||
if (raw.length % 2 === 1)
|
||||
return buffer.error('Decoding of string type: bmpstr length mismatch');
|
||||
|
||||
var str = '';
|
||||
for (var i = 0; i < raw.length / 2; i++) {
|
||||
str += String.fromCharCode(raw.readUInt16BE(i * 2));
|
||||
}
|
||||
return str;
|
||||
} else if (tag === 'numstr') {
|
||||
var numstr = buffer.raw().toString('ascii');
|
||||
if (!this._isNumstr(numstr)) {
|
||||
return buffer.error('Decoding of string type: ' +
|
||||
'numstr unsupported characters');
|
||||
}
|
||||
return numstr;
|
||||
} else if (tag === 'octstr') {
|
||||
return buffer.raw();
|
||||
} else if (tag === 'objDesc') {
|
||||
return buffer.raw();
|
||||
} else if (tag === 'printstr') {
|
||||
var printstr = buffer.raw().toString('ascii');
|
||||
if (!this._isPrintstr(printstr)) {
|
||||
return buffer.error('Decoding of string type: ' +
|
||||
'printstr unsupported characters');
|
||||
}
|
||||
return printstr;
|
||||
} else if (/str$/.test(tag)) {
|
||||
return buffer.raw().toString();
|
||||
} else {
|
||||
return buffer.error('Decoding of string type: ' + tag + ' unsupported');
|
||||
}
|
||||
};
|
||||
|
||||
DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) {
|
||||
var result;
|
||||
var identifiers = [];
|
||||
var ident = 0;
|
||||
while (!buffer.isEmpty()) {
|
||||
var subident = buffer.readUInt8();
|
||||
ident <<= 7;
|
||||
ident |= subident & 0x7f;
|
||||
if ((subident & 0x80) === 0) {
|
||||
identifiers.push(ident);
|
||||
ident = 0;
|
||||
}
|
||||
}
|
||||
if (subident & 0x80)
|
||||
identifiers.push(ident);
|
||||
|
||||
var first = (identifiers[0] / 40) | 0;
|
||||
var second = identifiers[0] % 40;
|
||||
|
||||
if (relative)
|
||||
result = identifiers;
|
||||
else
|
||||
result = [first, second].concat(identifiers.slice(1));
|
||||
|
||||
if (values) {
|
||||
var tmp = values[result.join(' ')];
|
||||
if (tmp === undefined)
|
||||
tmp = values[result.join('.')];
|
||||
if (tmp !== undefined)
|
||||
result = tmp;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
DERNode.prototype._decodeTime = function decodeTime(buffer, tag) {
|
||||
var str = buffer.raw().toString();
|
||||
if (tag === 'gentime') {
|
||||
var year = str.slice(0, 4) | 0;
|
||||
var mon = str.slice(4, 6) | 0;
|
||||
var day = str.slice(6, 8) | 0;
|
||||
var hour = str.slice(8, 10) | 0;
|
||||
var min = str.slice(10, 12) | 0;
|
||||
var sec = str.slice(12, 14) | 0;
|
||||
} else if (tag === 'utctime') {
|
||||
var year = str.slice(0, 2) | 0;
|
||||
var mon = str.slice(2, 4) | 0;
|
||||
var day = str.slice(4, 6) | 0;
|
||||
var hour = str.slice(6, 8) | 0;
|
||||
var min = str.slice(8, 10) | 0;
|
||||
var sec = str.slice(10, 12) | 0;
|
||||
if (year < 70)
|
||||
year = 2000 + year;
|
||||
else
|
||||
year = 1900 + year;
|
||||
} else {
|
||||
return buffer.error('Decoding ' + tag + ' time is not supported yet');
|
||||
}
|
||||
|
||||
return Date.UTC(year, mon - 1, day, hour, min, sec, 0);
|
||||
};
|
||||
|
||||
DERNode.prototype._decodeNull = function decodeNull(buffer) {
|
||||
return null;
|
||||
};
|
||||
|
||||
DERNode.prototype._decodeBool = function decodeBool(buffer) {
|
||||
var res = buffer.readUInt8();
|
||||
if (buffer.isError(res))
|
||||
return res;
|
||||
else
|
||||
return res !== 0;
|
||||
};
|
||||
|
||||
DERNode.prototype._decodeInt = function decodeInt(buffer, values) {
|
||||
// Bigint, return as it is (assume big endian)
|
||||
var raw = buffer.raw();
|
||||
var res = new bignum(raw);
|
||||
|
||||
if (values)
|
||||
res = values[res.toString(10)] || res;
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
DERNode.prototype._use = function use(entity, obj) {
|
||||
if (typeof entity === 'function')
|
||||
entity = entity(obj);
|
||||
return entity._getDecoder('der').tree;
|
||||
};
|
||||
|
||||
// Utility methods
|
||||
|
||||
function derDecodeTag(buf, fail) {
|
||||
var tag = buf.readUInt8(fail);
|
||||
if (buf.isError(tag))
|
||||
return tag;
|
||||
|
||||
var cls = der.tagClass[tag >> 6];
|
||||
var primitive = (tag & 0x20) === 0;
|
||||
|
||||
// Multi-octet tag - load
|
||||
if ((tag & 0x1f) === 0x1f) {
|
||||
var oct = tag;
|
||||
tag = 0;
|
||||
while ((oct & 0x80) === 0x80) {
|
||||
oct = buf.readUInt8(fail);
|
||||
if (buf.isError(oct))
|
||||
return oct;
|
||||
|
||||
tag <<= 7;
|
||||
tag |= oct & 0x7f;
|
||||
}
|
||||
} else {
|
||||
tag &= 0x1f;
|
||||
}
|
||||
var tagStr = der.tag[tag];
|
||||
|
||||
return {
|
||||
cls: cls,
|
||||
primitive: primitive,
|
||||
tag: tag,
|
||||
tagStr: tagStr
|
||||
};
|
||||
}
|
||||
|
||||
function derDecodeLen(buf, primitive, fail) {
|
||||
var len = buf.readUInt8(fail);
|
||||
if (buf.isError(len))
|
||||
return len;
|
||||
|
||||
// Indefinite form
|
||||
if (!primitive && len === 0x80)
|
||||
return null;
|
||||
|
||||
// Definite form
|
||||
if ((len & 0x80) === 0) {
|
||||
// Short form
|
||||
return len;
|
||||
}
|
||||
|
||||
// Long form
|
||||
var num = len & 0x7f;
|
||||
if (num > 4)
|
||||
return buf.error('length octect is too long');
|
||||
|
||||
len = 0;
|
||||
for (var i = 0; i < num; i++) {
|
||||
len <<= 8;
|
||||
var j = buf.readUInt8(fail);
|
||||
if (buf.isError(j))
|
||||
return j;
|
||||
len |= j;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
4
node_modules/asn1.js/lib/asn1/decoders/index.js
generated
vendored
Normal file
4
node_modules/asn1.js/lib/asn1/decoders/index.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
var decoders = exports;
|
||||
|
||||
decoders.der = require('./der');
|
||||
decoders.pem = require('./pem');
|
49
node_modules/asn1.js/lib/asn1/decoders/pem.js
generated
vendored
Normal file
49
node_modules/asn1.js/lib/asn1/decoders/pem.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
var inherits = require('inherits');
|
||||
var Buffer = require('buffer').Buffer;
|
||||
|
||||
var DERDecoder = require('./der');
|
||||
|
||||
function PEMDecoder(entity) {
|
||||
DERDecoder.call(this, entity);
|
||||
this.enc = 'pem';
|
||||
};
|
||||
inherits(PEMDecoder, DERDecoder);
|
||||
module.exports = PEMDecoder;
|
||||
|
||||
PEMDecoder.prototype.decode = function decode(data, options) {
|
||||
var lines = data.toString().split(/[\r\n]+/g);
|
||||
|
||||
var label = options.label.toUpperCase();
|
||||
|
||||
var re = /^-----(BEGIN|END) ([^-]+)-----$/;
|
||||
var start = -1;
|
||||
var end = -1;
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var match = lines[i].match(re);
|
||||
if (match === null)
|
||||
continue;
|
||||
|
||||
if (match[2] !== label)
|
||||
continue;
|
||||
|
||||
if (start === -1) {
|
||||
if (match[1] !== 'BEGIN')
|
||||
break;
|
||||
start = i;
|
||||
} else {
|
||||
if (match[1] !== 'END')
|
||||
break;
|
||||
end = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (start === -1 || end === -1)
|
||||
throw new Error('PEM section not found for: ' + label);
|
||||
|
||||
var base64 = lines.slice(start + 1, end).join('');
|
||||
// Remove excessive symbols
|
||||
base64.replace(/[^a-z0-9\+\/=]+/gi, '');
|
||||
|
||||
var input = new Buffer(base64, 'base64');
|
||||
return DERDecoder.prototype.decode.call(this, input, options);
|
||||
};
|
295
node_modules/asn1.js/lib/asn1/encoders/der.js
generated
vendored
Normal file
295
node_modules/asn1.js/lib/asn1/encoders/der.js
generated
vendored
Normal file
@@ -0,0 +1,295 @@
|
||||
var inherits = require('inherits');
|
||||
var Buffer = require('buffer').Buffer;
|
||||
|
||||
var asn1 = require('../../asn1');
|
||||
var base = asn1.base;
|
||||
|
||||
// Import DER constants
|
||||
var der = asn1.constants.der;
|
||||
|
||||
function DEREncoder(entity) {
|
||||
this.enc = 'der';
|
||||
this.name = entity.name;
|
||||
this.entity = entity;
|
||||
|
||||
// Construct base tree
|
||||
this.tree = new DERNode();
|
||||
this.tree._init(entity.body);
|
||||
};
|
||||
module.exports = DEREncoder;
|
||||
|
||||
DEREncoder.prototype.encode = function encode(data, reporter) {
|
||||
return this.tree._encode(data, reporter).join();
|
||||
};
|
||||
|
||||
// Tree methods
|
||||
|
||||
function DERNode(parent) {
|
||||
base.Node.call(this, 'der', parent);
|
||||
}
|
||||
inherits(DERNode, base.Node);
|
||||
|
||||
DERNode.prototype._encodeComposite = function encodeComposite(tag,
|
||||
primitive,
|
||||
cls,
|
||||
content) {
|
||||
var encodedTag = encodeTag(tag, primitive, cls, this.reporter);
|
||||
|
||||
// Short form
|
||||
if (content.length < 0x80) {
|
||||
var header = new Buffer(2);
|
||||
header[0] = encodedTag;
|
||||
header[1] = content.length;
|
||||
return this._createEncoderBuffer([ header, content ]);
|
||||
}
|
||||
|
||||
// Long form
|
||||
// Count octets required to store length
|
||||
var lenOctets = 1;
|
||||
for (var i = content.length; i >= 0x100; i >>= 8)
|
||||
lenOctets++;
|
||||
|
||||
var header = new Buffer(1 + 1 + lenOctets);
|
||||
header[0] = encodedTag;
|
||||
header[1] = 0x80 | lenOctets;
|
||||
|
||||
for (var i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8)
|
||||
header[i] = j & 0xff;
|
||||
|
||||
return this._createEncoderBuffer([ header, content ]);
|
||||
};
|
||||
|
||||
DERNode.prototype._encodeStr = function encodeStr(str, tag) {
|
||||
if (tag === 'bitstr') {
|
||||
return this._createEncoderBuffer([ str.unused | 0, str.data ]);
|
||||
} else if (tag === 'bmpstr') {
|
||||
var buf = new Buffer(str.length * 2);
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
buf.writeUInt16BE(str.charCodeAt(i), i * 2);
|
||||
}
|
||||
return this._createEncoderBuffer(buf);
|
||||
} else if (tag === 'numstr') {
|
||||
if (!this._isNumstr(str)) {
|
||||
return this.reporter.error('Encoding of string type: numstr supports ' +
|
||||
'only digits and space');
|
||||
}
|
||||
return this._createEncoderBuffer(str);
|
||||
} else if (tag === 'printstr') {
|
||||
if (!this._isPrintstr(str)) {
|
||||
return this.reporter.error('Encoding of string type: printstr supports ' +
|
||||
'only latin upper and lower case letters, ' +
|
||||
'digits, space, apostrophe, left and rigth ' +
|
||||
'parenthesis, plus sign, comma, hyphen, ' +
|
||||
'dot, slash, colon, equal sign, ' +
|
||||
'question mark');
|
||||
}
|
||||
return this._createEncoderBuffer(str);
|
||||
} else if (/str$/.test(tag)) {
|
||||
return this._createEncoderBuffer(str);
|
||||
} else if (tag === 'objDesc') {
|
||||
return this._createEncoderBuffer(str);
|
||||
} else {
|
||||
return this.reporter.error('Encoding of string type: ' + tag +
|
||||
' unsupported');
|
||||
}
|
||||
};
|
||||
|
||||
DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) {
|
||||
if (typeof id === 'string') {
|
||||
if (!values)
|
||||
return this.reporter.error('string objid given, but no values map found');
|
||||
if (!values.hasOwnProperty(id))
|
||||
return this.reporter.error('objid not found in values map');
|
||||
id = values[id].split(/[\s\.]+/g);
|
||||
for (var i = 0; i < id.length; i++)
|
||||
id[i] |= 0;
|
||||
} else if (Array.isArray(id)) {
|
||||
id = id.slice();
|
||||
for (var i = 0; i < id.length; i++)
|
||||
id[i] |= 0;
|
||||
}
|
||||
|
||||
if (!Array.isArray(id)) {
|
||||
return this.reporter.error('objid() should be either array or string, ' +
|
||||
'got: ' + JSON.stringify(id));
|
||||
}
|
||||
|
||||
if (!relative) {
|
||||
if (id[1] >= 40)
|
||||
return this.reporter.error('Second objid identifier OOB');
|
||||
id.splice(0, 2, id[0] * 40 + id[1]);
|
||||
}
|
||||
|
||||
// Count number of octets
|
||||
var size = 0;
|
||||
for (var i = 0; i < id.length; i++) {
|
||||
var ident = id[i];
|
||||
for (size++; ident >= 0x80; ident >>= 7)
|
||||
size++;
|
||||
}
|
||||
|
||||
var objid = new Buffer(size);
|
||||
var offset = objid.length - 1;
|
||||
for (var i = id.length - 1; i >= 0; i--) {
|
||||
var ident = id[i];
|
||||
objid[offset--] = ident & 0x7f;
|
||||
while ((ident >>= 7) > 0)
|
||||
objid[offset--] = 0x80 | (ident & 0x7f);
|
||||
}
|
||||
|
||||
return this._createEncoderBuffer(objid);
|
||||
};
|
||||
|
||||
function two(num) {
|
||||
if (num < 10)
|
||||
return '0' + num;
|
||||
else
|
||||
return num;
|
||||
}
|
||||
|
||||
DERNode.prototype._encodeTime = function encodeTime(time, tag) {
|
||||
var str;
|
||||
var date = new Date(time);
|
||||
|
||||
if (tag === 'gentime') {
|
||||
str = [
|
||||
two(date.getFullYear()),
|
||||
two(date.getUTCMonth() + 1),
|
||||
two(date.getUTCDate()),
|
||||
two(date.getUTCHours()),
|
||||
two(date.getUTCMinutes()),
|
||||
two(date.getUTCSeconds()),
|
||||
'Z'
|
||||
].join('');
|
||||
} else if (tag === 'utctime') {
|
||||
str = [
|
||||
two(date.getFullYear() % 100),
|
||||
two(date.getUTCMonth() + 1),
|
||||
two(date.getUTCDate()),
|
||||
two(date.getUTCHours()),
|
||||
two(date.getUTCMinutes()),
|
||||
two(date.getUTCSeconds()),
|
||||
'Z'
|
||||
].join('');
|
||||
} else {
|
||||
this.reporter.error('Encoding ' + tag + ' time is not supported yet');
|
||||
}
|
||||
|
||||
return this._encodeStr(str, 'octstr');
|
||||
};
|
||||
|
||||
DERNode.prototype._encodeNull = function encodeNull() {
|
||||
return this._createEncoderBuffer('');
|
||||
};
|
||||
|
||||
DERNode.prototype._encodeInt = function encodeInt(num, values) {
|
||||
if (typeof num === 'string') {
|
||||
if (!values)
|
||||
return this.reporter.error('String int or enum given, but no values map');
|
||||
if (!values.hasOwnProperty(num)) {
|
||||
return this.reporter.error('Values map doesn\'t contain: ' +
|
||||
JSON.stringify(num));
|
||||
}
|
||||
num = values[num];
|
||||
}
|
||||
|
||||
// Bignum, assume big endian
|
||||
if (typeof num !== 'number' && !Buffer.isBuffer(num)) {
|
||||
var numArray = num.toArray();
|
||||
if (!num.sign && numArray[0] & 0x80) {
|
||||
numArray.unshift(0);
|
||||
}
|
||||
num = new Buffer(numArray);
|
||||
}
|
||||
|
||||
if (Buffer.isBuffer(num)) {
|
||||
var size = num.length;
|
||||
if (num.length === 0)
|
||||
size++;
|
||||
|
||||
var out = new Buffer(size);
|
||||
num.copy(out);
|
||||
if (num.length === 0)
|
||||
out[0] = 0
|
||||
return this._createEncoderBuffer(out);
|
||||
}
|
||||
|
||||
if (num < 0x80)
|
||||
return this._createEncoderBuffer(num);
|
||||
|
||||
if (num < 0x100)
|
||||
return this._createEncoderBuffer([0, num]);
|
||||
|
||||
var size = 1;
|
||||
for (var i = num; i >= 0x100; i >>= 8)
|
||||
size++;
|
||||
|
||||
var out = new Array(size);
|
||||
for (var i = out.length - 1; i >= 0; i--) {
|
||||
out[i] = num & 0xff;
|
||||
num >>= 8;
|
||||
}
|
||||
if(out[0] & 0x80) {
|
||||
out.unshift(0);
|
||||
}
|
||||
|
||||
return this._createEncoderBuffer(new Buffer(out));
|
||||
};
|
||||
|
||||
DERNode.prototype._encodeBool = function encodeBool(value) {
|
||||
return this._createEncoderBuffer(value ? 0xff : 0);
|
||||
};
|
||||
|
||||
DERNode.prototype._use = function use(entity, obj) {
|
||||
if (typeof entity === 'function')
|
||||
entity = entity(obj);
|
||||
return entity._getEncoder('der').tree;
|
||||
};
|
||||
|
||||
DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) {
|
||||
var state = this._baseState;
|
||||
var i;
|
||||
if (state['default'] === null)
|
||||
return false;
|
||||
|
||||
var data = dataBuffer.join();
|
||||
if (state.defaultBuffer === undefined)
|
||||
state.defaultBuffer = this._encodeValue(state['default'], reporter, parent).join();
|
||||
|
||||
if (data.length !== state.defaultBuffer.length)
|
||||
return false;
|
||||
|
||||
for (i=0; i < data.length; i++)
|
||||
if (data[i] !== state.defaultBuffer[i])
|
||||
return false;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
// Utility methods
|
||||
|
||||
function encodeTag(tag, primitive, cls, reporter) {
|
||||
var res;
|
||||
|
||||
if (tag === 'seqof')
|
||||
tag = 'seq';
|
||||
else if (tag === 'setof')
|
||||
tag = 'set';
|
||||
|
||||
if (der.tagByName.hasOwnProperty(tag))
|
||||
res = der.tagByName[tag];
|
||||
else if (typeof tag === 'number' && (tag | 0) === tag)
|
||||
res = tag;
|
||||
else
|
||||
return reporter.error('Unknown tag: ' + tag);
|
||||
|
||||
if (res >= 0x1f)
|
||||
return reporter.error('Multi-octet tag encoding unsupported');
|
||||
|
||||
if (!primitive)
|
||||
res |= 0x20;
|
||||
|
||||
res |= (der.tagClassByName[cls || 'universal'] << 6);
|
||||
|
||||
return res;
|
||||
}
|
4
node_modules/asn1.js/lib/asn1/encoders/index.js
generated
vendored
Normal file
4
node_modules/asn1.js/lib/asn1/encoders/index.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
var encoders = exports;
|
||||
|
||||
encoders.der = require('./der');
|
||||
encoders.pem = require('./pem');
|
21
node_modules/asn1.js/lib/asn1/encoders/pem.js
generated
vendored
Normal file
21
node_modules/asn1.js/lib/asn1/encoders/pem.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
var inherits = require('inherits');
|
||||
|
||||
var DEREncoder = require('./der');
|
||||
|
||||
function PEMEncoder(entity) {
|
||||
DEREncoder.call(this, entity);
|
||||
this.enc = 'pem';
|
||||
};
|
||||
inherits(PEMEncoder, DEREncoder);
|
||||
module.exports = PEMEncoder;
|
||||
|
||||
PEMEncoder.prototype.encode = function encode(data, options) {
|
||||
var buf = DEREncoder.prototype.encode.call(this, data);
|
||||
|
||||
var p = buf.toString('base64');
|
||||
var out = [ '-----BEGIN ' + options.label + '-----' ];
|
||||
for (var i = 0; i < p.length; i += 64)
|
||||
out.push(p.slice(i, i + 64));
|
||||
out.push('-----END ' + options.label + '-----');
|
||||
return out.join('\n');
|
||||
};
|
19
node_modules/asn1.js/node_modules/bn.js/LICENSE
generated
vendored
Normal file
19
node_modules/asn1.js/node_modules/bn.js/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright Fedor Indutny, 2015.
|
||||
|
||||
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.
|
200
node_modules/asn1.js/node_modules/bn.js/README.md
generated
vendored
Normal file
200
node_modules/asn1.js/node_modules/bn.js/README.md
generated
vendored
Normal file
@@ -0,0 +1,200 @@
|
||||
# <img src="./logo.png" alt="bn.js" width="160" height="160" />
|
||||
|
||||
> BigNum in pure javascript
|
||||
|
||||
[](http://travis-ci.org/indutny/bn.js)
|
||||
|
||||
## Install
|
||||
`npm install --save bn.js`
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const BN = require('bn.js');
|
||||
|
||||
var a = new BN('dead', 16);
|
||||
var b = new BN('101010', 2);
|
||||
|
||||
var res = a.add(b);
|
||||
console.log(res.toString(10)); // 57047
|
||||
```
|
||||
|
||||
**Note**: decimals are not supported in this library.
|
||||
|
||||
## Notation
|
||||
|
||||
### Prefixes
|
||||
|
||||
There are several prefixes to instructions that affect the way the work. Here
|
||||
is the list of them in the order of appearance in the function name:
|
||||
|
||||
* `i` - perform operation in-place, storing the result in the host object (on
|
||||
which the method was invoked). Might be used to avoid number allocation costs
|
||||
* `u` - unsigned, ignore the sign of operands when performing operation, or
|
||||
always return positive value. Second case applies to reduction operations
|
||||
like `mod()`. In such cases if the result will be negative - modulo will be
|
||||
added to the result to make it positive
|
||||
|
||||
### Postfixes
|
||||
|
||||
The only available postfix at the moment is:
|
||||
|
||||
* `n` - which means that the argument of the function must be a plain JavaScript
|
||||
Number. Decimals are not supported.
|
||||
|
||||
### Examples
|
||||
|
||||
* `a.iadd(b)` - perform addition on `a` and `b`, storing the result in `a`
|
||||
* `a.umod(b)` - reduce `a` modulo `b`, returning positive value
|
||||
* `a.iushln(13)` - shift bits of `a` left by 13
|
||||
|
||||
## Instructions
|
||||
|
||||
Prefixes/postfixes are put in parens at the of the line. `endian` - could be
|
||||
either `le` (little-endian) or `be` (big-endian).
|
||||
|
||||
### Utilities
|
||||
|
||||
* `a.clone()` - clone number
|
||||
* `a.toString(base, length)` - convert to base-string and pad with zeroes
|
||||
* `a.toNumber()` - convert to Javascript Number (limited to 53 bits)
|
||||
* `a.toJSON()` - convert to JSON compatible hex string (alias of `toString(16)`)
|
||||
* `a.toArray(endian, length)` - convert to byte `Array`, and optionally zero
|
||||
pad to length, throwing if already exceeding
|
||||
* `a.toArrayLike(type, endian, length)` - convert to an instance of `type`,
|
||||
which must behave like an `Array`
|
||||
* `a.toBuffer(endian, length)` - convert to Node.js Buffer (if available). For
|
||||
compatibility with browserify and similar tools, use this instead:
|
||||
`a.toArrayLike(Buffer, endian, length)`
|
||||
* `a.bitLength()` - get number of bits occupied
|
||||
* `a.zeroBits()` - return number of less-significant consequent zero bits
|
||||
(example: `1010000` has 4 zero bits)
|
||||
* `a.byteLength()` - return number of bytes occupied
|
||||
* `a.isNeg()` - true if the number is negative
|
||||
* `a.isEven()` - no comments
|
||||
* `a.isOdd()` - no comments
|
||||
* `a.isZero()` - no comments
|
||||
* `a.cmp(b)` - compare numbers and return `-1` (a `<` b), `0` (a `==` b), or `1` (a `>` b)
|
||||
depending on the comparison result (`ucmp`, `cmpn`)
|
||||
* `a.lt(b)` - `a` less than `b` (`n`)
|
||||
* `a.lte(b)` - `a` less than or equals `b` (`n`)
|
||||
* `a.gt(b)` - `a` greater than `b` (`n`)
|
||||
* `a.gte(b)` - `a` greater than or equals `b` (`n`)
|
||||
* `a.eq(b)` - `a` equals `b` (`n`)
|
||||
* `a.toTwos(width)` - convert to two's complement representation, where `width` is bit width
|
||||
* `a.fromTwos(width)` - convert from two's complement representation, where `width` is the bit width
|
||||
* `BN.isBN(object)` - returns true if the supplied `object` is a BN.js instance
|
||||
|
||||
### Arithmetics
|
||||
|
||||
* `a.neg()` - negate sign (`i`)
|
||||
* `a.abs()` - absolute value (`i`)
|
||||
* `a.add(b)` - addition (`i`, `n`, `in`)
|
||||
* `a.sub(b)` - subtraction (`i`, `n`, `in`)
|
||||
* `a.mul(b)` - multiply (`i`, `n`, `in`)
|
||||
* `a.sqr()` - square (`i`)
|
||||
* `a.pow(b)` - raise `a` to the power of `b`
|
||||
* `a.div(b)` - divide (`divn`, `idivn`)
|
||||
* `a.mod(b)` - reduct (`u`, `n`) (but no `umodn`)
|
||||
* `a.divRound(b)` - rounded division
|
||||
|
||||
### Bit operations
|
||||
|
||||
* `a.or(b)` - or (`i`, `u`, `iu`)
|
||||
* `a.and(b)` - and (`i`, `u`, `iu`, `andln`) (NOTE: `andln` is going to be replaced
|
||||
with `andn` in future)
|
||||
* `a.xor(b)` - xor (`i`, `u`, `iu`)
|
||||
* `a.setn(b)` - set specified bit to `1`
|
||||
* `a.shln(b)` - shift left (`i`, `u`, `iu`)
|
||||
* `a.shrn(b)` - shift right (`i`, `u`, `iu`)
|
||||
* `a.testn(b)` - test if specified bit is set
|
||||
* `a.maskn(b)` - clear bits with indexes higher or equal to `b` (`i`)
|
||||
* `a.bincn(b)` - add `1 << b` to the number
|
||||
* `a.notn(w)` - not (for the width specified by `w`) (`i`)
|
||||
|
||||
### Reduction
|
||||
|
||||
* `a.gcd(b)` - GCD
|
||||
* `a.egcd(b)` - Extended GCD results (`{ a: ..., b: ..., gcd: ... }`)
|
||||
* `a.invm(b)` - inverse `a` modulo `b`
|
||||
|
||||
## Fast reduction
|
||||
|
||||
When doing lots of reductions using the same modulo, it might be beneficial to
|
||||
use some tricks: like [Montgomery multiplication][0], or using special algorithm
|
||||
for [Mersenne Prime][1].
|
||||
|
||||
### Reduction context
|
||||
|
||||
To enable this tricks one should create a reduction context:
|
||||
|
||||
```js
|
||||
var red = BN.red(num);
|
||||
```
|
||||
where `num` is just a BN instance.
|
||||
|
||||
Or:
|
||||
|
||||
```js
|
||||
var red = BN.red(primeName);
|
||||
```
|
||||
|
||||
Where `primeName` is either of these [Mersenne Primes][1]:
|
||||
|
||||
* `'k256'`
|
||||
* `'p224'`
|
||||
* `'p192'`
|
||||
* `'p25519'`
|
||||
|
||||
Or:
|
||||
|
||||
```js
|
||||
var red = BN.mont(num);
|
||||
```
|
||||
|
||||
To reduce numbers with [Montgomery trick][0]. `.mont()` is generally faster than
|
||||
`.red(num)`, but slower than `BN.red(primeName)`.
|
||||
|
||||
### Converting numbers
|
||||
|
||||
Before performing anything in reduction context - numbers should be converted
|
||||
to it. Usually, this means that one should:
|
||||
|
||||
* Convert inputs to reducted ones
|
||||
* Operate on them in reduction context
|
||||
* Convert outputs back from the reduction context
|
||||
|
||||
Here is how one may convert numbers to `red`:
|
||||
|
||||
```js
|
||||
var redA = a.toRed(red);
|
||||
```
|
||||
Where `red` is a reduction context created using instructions above
|
||||
|
||||
Here is how to convert them back:
|
||||
|
||||
```js
|
||||
var a = redA.fromRed();
|
||||
```
|
||||
|
||||
### Red instructions
|
||||
|
||||
Most of the instructions from the very start of this readme have their
|
||||
counterparts in red context:
|
||||
|
||||
* `a.redAdd(b)`, `a.redIAdd(b)`
|
||||
* `a.redSub(b)`, `a.redISub(b)`
|
||||
* `a.redShl(num)`
|
||||
* `a.redMul(b)`, `a.redIMul(b)`
|
||||
* `a.redSqr()`, `a.redISqr()`
|
||||
* `a.redSqrt()` - square root modulo reduction context's prime
|
||||
* `a.redInvm()` - modular inverse of the number
|
||||
* `a.redNeg()`
|
||||
* `a.redPow(b)` - modular exponentiation
|
||||
|
||||
## LICENSE
|
||||
|
||||
This software is licensed under the MIT License.
|
||||
|
||||
[0]: https://en.wikipedia.org/wiki/Montgomery_modular_multiplication
|
||||
[1]: https://en.wikipedia.org/wiki/Mersenne_prime
|
3446
node_modules/asn1.js/node_modules/bn.js/lib/bn.js
generated
vendored
Normal file
3446
node_modules/asn1.js/node_modules/bn.js/lib/bn.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
36
node_modules/asn1.js/node_modules/bn.js/package.json
generated
vendored
Normal file
36
node_modules/asn1.js/node_modules/bn.js/package.json
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "bn.js",
|
||||
"version": "4.12.0",
|
||||
"description": "Big number implementation in pure javascript",
|
||||
"main": "lib/bn.js",
|
||||
"scripts": {
|
||||
"lint": "semistandard",
|
||||
"unit": "mocha --reporter=spec test/*-test.js",
|
||||
"test": "npm run lint && npm run unit"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:indutny/bn.js"
|
||||
},
|
||||
"keywords": [
|
||||
"BN",
|
||||
"BigNum",
|
||||
"Big number",
|
||||
"Modulo",
|
||||
"Montgomery"
|
||||
],
|
||||
"author": "Fedor Indutny <fedor@indutny.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/indutny/bn.js/issues"
|
||||
},
|
||||
"homepage": "https://github.com/indutny/bn.js",
|
||||
"browser": {
|
||||
"buffer": false
|
||||
},
|
||||
"devDependencies": {
|
||||
"istanbul": "^0.3.5",
|
||||
"mocha": "^2.1.0",
|
||||
"semistandard": "^7.0.4"
|
||||
}
|
||||
}
|
31
node_modules/asn1.js/package.json
generated
vendored
Normal file
31
node_modules/asn1.js/package.json
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "asn1.js",
|
||||
"version": "4.10.1",
|
||||
"description": "ASN.1 encoder and decoder",
|
||||
"main": "lib/asn1.js",
|
||||
"scripts": {
|
||||
"test": "mocha --reporter spec test/*-test.js && cd rfc/2560 && npm i && npm test && cd ../../rfc/5280 && npm i && npm test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:indutny/asn1.js"
|
||||
},
|
||||
"keywords": [
|
||||
"asn.1",
|
||||
"der"
|
||||
],
|
||||
"author": "Fedor Indutny",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/indutny/asn1.js/issues"
|
||||
},
|
||||
"homepage": "https://github.com/indutny/asn1.js",
|
||||
"devDependencies": {
|
||||
"mocha": "^2.3.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"bn.js": "^4.0.0",
|
||||
"inherits": "^2.0.1",
|
||||
"minimalistic-assert": "^1.0.0"
|
||||
}
|
||||
}
|
12
node_modules/assert/.github/FUNDING.yml
generated
vendored
Normal file
12
node_modules/assert/.github/FUNDING.yml
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: [ljharb] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: npm/assert
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
10
node_modules/assert/.github/SECURITY.md
generated
vendored
Normal file
10
node_modules/assert/.github/SECURITY.md
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
Only the latest major version is supported at any given time.
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
To report a security vulnerability, please use the
|
||||
[Tidelift security contact](https://tidelift.com/security).
|
||||
Tidelift will coordinate the fix and disclosure.
|
30
node_modules/assert/.travis.yml
generated
vendored
Normal file
30
node_modules/assert/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
language: node_js
|
||||
before_install:
|
||||
- nvm install-latest-npm
|
||||
matrix:
|
||||
include:
|
||||
- node_js: '0.8'
|
||||
env: TASK=test-node
|
||||
- node_js: '0.10'
|
||||
env: TASK=test-node
|
||||
- node_js: '0.11'
|
||||
env: TASK=test-node
|
||||
- node_js: '0.12'
|
||||
env: TASK=test-node
|
||||
- node_js: 1
|
||||
env: TASK=test-node
|
||||
- node_js: 2
|
||||
env: TASK=test-node
|
||||
- node_js: 3
|
||||
env: TASK=test-node
|
||||
- node_js: 4
|
||||
env: TASK=test-node
|
||||
- node_js: 5
|
||||
env: TASK=test-node
|
||||
- node_js: '0.10'
|
||||
env: TASK=test-browser
|
||||
script: "npm run $TASK"
|
||||
env:
|
||||
global:
|
||||
- secure: qThuKBZQtkooAvzaYldECGNqvKGPRTnXx62IVyhSbFlsCY1VCmjhLldhyPDiZQ3JqL1XvSkK8OMDupiHqZnNE0nGijoO4M/kaEdjBB+jpjg3f8I6te2SNU935SbkfY9KHAaFXMZwdcq7Fk932AxWEu+FMSDM+080wNKpEATXDe4=
|
||||
- secure: O/scKjHLRcPN5ILV5qsSkksQ7qcZQdHWEUUPItmj/4+vmCc28bHpicoUxXG5A96iHvkBbdmky/nGCg464ZaNLk68m6hfEMDAR3J6mhM2Pf5C4QI/LlFlR1fob9sQ8lztwSGOItwdK8Rfrgb30RRVV71f6FxnaJ6PKMuMNT5S1AQ=
|
13
node_modules/assert/.zuul.yml
generated
vendored
Normal file
13
node_modules/assert/.zuul.yml
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
ui: mocha-qunit
|
||||
tunnel: ngrok
|
||||
browsers:
|
||||
- name: chrome
|
||||
version: latest
|
||||
- name: firefox
|
||||
version: latest
|
||||
- name: safari
|
||||
version: latest
|
||||
- name: ie
|
||||
version: 9..latest
|
||||
- name: microsoftedge
|
||||
version: latest
|
11
node_modules/assert/CHANGELOG.md
generated
vendored
Normal file
11
node_modules/assert/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# assert change log
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## 1.5.1
|
||||
* [Deps] switch to `object.assign`, and unpin `util`
|
||||
|
||||
## 1.5.0
|
||||
* Add strict mode APIs. ([@lukechilds](https://github.com/lukechilds) in [#41](https://github.com/browserify/commonjs-assert/pull/41))
|
18
node_modules/assert/LICENSE
generated
vendored
Normal file
18
node_modules/assert/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||
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.
|
105
node_modules/assert/README.md
generated
vendored
Normal file
105
node_modules/assert/README.md
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
# assert
|
||||
|
||||
[](https://travis-ci.org/browserify/commonjs-assert)
|
||||
|
||||
This module is used for writing unit tests for your applications, you can access it with `require('assert')`.
|
||||
|
||||
It aims to be fully compatibe with the [node.js assert module](http://nodejs.org/api/assert.html), same API and same behavior, just adding support for web browsers.
|
||||
The API and code may contain traces of the [CommonJS Unit Testing 1.0 spec](http://wiki.commonjs.org/wiki/Unit_Testing/1.0) which they were based on, but both have evolved significantly since then.
|
||||
|
||||
A `strict` and a `legacy` mode exist, while it is recommended to only use `strict mode`.
|
||||
|
||||
## Strict mode
|
||||
|
||||
When using the `strict mode`, any `assert` function will use the equality used in the strict function mode. So `assert.deepEqual()` will, for example, work the same as `assert.deepStrictEqual()`.
|
||||
|
||||
It can be accessed using:
|
||||
|
||||
```js
|
||||
const assert = require('assert').strict;
|
||||
```
|
||||
|
||||
## Legacy mode
|
||||
|
||||
> Deprecated: Use strict mode instead.
|
||||
|
||||
When accessing `assert` directly instead of using the `strict` property, the
|
||||
[Abstract Equality Comparison](https://tc39.github.io/ecma262/#sec-abstract-equality-comparison) will be used for any function without a
|
||||
"strict" in its name (e.g. `assert.deepEqual()`).
|
||||
|
||||
It can be accessed using:
|
||||
|
||||
```js
|
||||
const assert = require('assert');
|
||||
```
|
||||
|
||||
It is recommended to use the `strict mode` instead as the Abstract Equality Comparison can often have surprising results. Especially
|
||||
in case of `assert.deepEqual()` as the used comparison rules there are very lax.
|
||||
|
||||
E.g.
|
||||
|
||||
```js
|
||||
// WARNING: This does not throw an AssertionError!
|
||||
assert.deepEqual(/a/gi, new Date());
|
||||
```
|
||||
|
||||
|
||||
## assert.fail(actual, expected, message, operator)
|
||||
Throws an exception that displays the values for actual and expected separated by the provided operator.
|
||||
|
||||
## assert(value, message), assert.ok(value, [message])
|
||||
Tests if value is truthy, it is equivalent to assert.equal(true, !!value, message);
|
||||
|
||||
## assert.equal(actual, expected, [message])
|
||||
Tests shallow, coercive equality with the equal comparison operator ( == ).
|
||||
|
||||
## assert.notEqual(actual, expected, [message])
|
||||
Tests shallow, coercive non-equality with the not equal comparison operator ( != ).
|
||||
|
||||
## assert.deepEqual(actual, expected, [message])
|
||||
Tests for deep equality.
|
||||
|
||||
## assert.deepStrictEqual(actual, expected, [message])
|
||||
Tests for deep equality, as determined by the strict equality operator ( === )
|
||||
|
||||
## assert.notDeepEqual(actual, expected, [message])
|
||||
Tests for any deep inequality.
|
||||
|
||||
## assert.strictEqual(actual, expected, [message])
|
||||
Tests strict equality, as determined by the strict equality operator ( === )
|
||||
|
||||
## assert.notStrictEqual(actual, expected, [message])
|
||||
Tests strict non-equality, as determined by the strict not equal operator ( !== )
|
||||
|
||||
## assert.throws(block, [error], [message])
|
||||
Expects block to throw an error. error can be constructor, regexp or validation function.
|
||||
|
||||
Validate instanceof using constructor:
|
||||
|
||||
```javascript
|
||||
assert.throws(function() { throw new Error("Wrong value"); }, Error);
|
||||
```
|
||||
|
||||
Validate error message using RegExp:
|
||||
|
||||
```javascript
|
||||
assert.throws(function() { throw new Error("Wrong value"); }, /value/);
|
||||
```
|
||||
|
||||
Custom error validation:
|
||||
|
||||
```javascript
|
||||
assert.throws(function() {
|
||||
throw new Error("Wrong value");
|
||||
}, function(err) {
|
||||
if ( (err instanceof Error) && /value/.test(err) ) {
|
||||
return true;
|
||||
}
|
||||
}, "unexpected error");
|
||||
```
|
||||
|
||||
## assert.doesNotThrow(block, [message])
|
||||
Expects block not to throw an error, see assert.throws for details.
|
||||
|
||||
## assert.ifError(value)
|
||||
Tests if value is not a false value, throws if it is a true value. Useful when testing the first argument, error in callbacks.
|
506
node_modules/assert/assert.js
generated
vendored
Normal file
506
node_modules/assert/assert.js
generated
vendored
Normal file
@@ -0,0 +1,506 @@
|
||||
'use strict';
|
||||
|
||||
var objectAssign = require('object.assign/polyfill')();
|
||||
|
||||
// compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js
|
||||
// original notice:
|
||||
|
||||
/*!
|
||||
* The buffer module from node.js, for the browser.
|
||||
*
|
||||
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
||||
* @license MIT
|
||||
*/
|
||||
function compare(a, b) {
|
||||
if (a === b) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var x = a.length;
|
||||
var y = b.length;
|
||||
|
||||
for (var i = 0, len = Math.min(x, y); i < len; ++i) {
|
||||
if (a[i] !== b[i]) {
|
||||
x = a[i];
|
||||
y = b[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (x < y) {
|
||||
return -1;
|
||||
}
|
||||
if (y < x) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
function isBuffer(b) {
|
||||
if (global.Buffer && typeof global.Buffer.isBuffer === 'function') {
|
||||
return global.Buffer.isBuffer(b);
|
||||
}
|
||||
return !!(b != null && b._isBuffer);
|
||||
}
|
||||
|
||||
// based on node assert, original notice:
|
||||
// NB: The URL to the CommonJS spec is kept just for tradition.
|
||||
// node-assert has evolved a lot since then, both in API and behavior.
|
||||
|
||||
// http://wiki.commonjs.org/wiki/Unit_Testing/1.0
|
||||
//
|
||||
// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
|
||||
//
|
||||
// Originally from narwhal.js (http://narwhaljs.org)
|
||||
// Copyright (c) 2009 Thomas Robinson <280north.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 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.
|
||||
|
||||
var util = require('util/');
|
||||
var hasOwn = Object.prototype.hasOwnProperty;
|
||||
var pSlice = Array.prototype.slice;
|
||||
var functionsHaveNames = (function () {
|
||||
return function foo() {}.name === 'foo';
|
||||
}());
|
||||
function pToString (obj) {
|
||||
return Object.prototype.toString.call(obj);
|
||||
}
|
||||
function isView(arrbuf) {
|
||||
if (isBuffer(arrbuf)) {
|
||||
return false;
|
||||
}
|
||||
if (typeof global.ArrayBuffer !== 'function') {
|
||||
return false;
|
||||
}
|
||||
if (typeof ArrayBuffer.isView === 'function') {
|
||||
return ArrayBuffer.isView(arrbuf);
|
||||
}
|
||||
if (!arrbuf) {
|
||||
return false;
|
||||
}
|
||||
if (arrbuf instanceof DataView) {
|
||||
return true;
|
||||
}
|
||||
if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// 1. The assert module provides functions that throw
|
||||
// AssertionError's when particular conditions are not met. The
|
||||
// assert module must conform to the following interface.
|
||||
|
||||
var assert = module.exports = ok;
|
||||
|
||||
// 2. The AssertionError is defined in assert.
|
||||
// new assert.AssertionError({ message: message,
|
||||
// actual: actual,
|
||||
// expected: expected })
|
||||
|
||||
var regex = /\s*function\s+([^\(\s]*)\s*/;
|
||||
// based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
|
||||
function getName(func) {
|
||||
if (!util.isFunction(func)) {
|
||||
return;
|
||||
}
|
||||
if (functionsHaveNames) {
|
||||
return func.name;
|
||||
}
|
||||
var str = func.toString();
|
||||
var match = str.match(regex);
|
||||
return match && match[1];
|
||||
}
|
||||
assert.AssertionError = function AssertionError(options) {
|
||||
this.name = 'AssertionError';
|
||||
this.actual = options.actual;
|
||||
this.expected = options.expected;
|
||||
this.operator = options.operator;
|
||||
if (options.message) {
|
||||
this.message = options.message;
|
||||
this.generatedMessage = false;
|
||||
} else {
|
||||
this.message = getMessage(this);
|
||||
this.generatedMessage = true;
|
||||
}
|
||||
var stackStartFunction = options.stackStartFunction || fail;
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, stackStartFunction);
|
||||
} else {
|
||||
// non v8 browsers so we can have a stacktrace
|
||||
var err = new Error();
|
||||
if (err.stack) {
|
||||
var out = err.stack;
|
||||
|
||||
// try to strip useless frames
|
||||
var fn_name = getName(stackStartFunction);
|
||||
var idx = out.indexOf('\n' + fn_name);
|
||||
if (idx >= 0) {
|
||||
// once we have located the function frame
|
||||
// we need to strip out everything before it (and its line)
|
||||
var next_line = out.indexOf('\n', idx + 1);
|
||||
out = out.substring(next_line + 1);
|
||||
}
|
||||
|
||||
this.stack = out;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// assert.AssertionError instanceof Error
|
||||
util.inherits(assert.AssertionError, Error);
|
||||
|
||||
function truncate(s, n) {
|
||||
if (typeof s === 'string') {
|
||||
return s.length < n ? s : s.slice(0, n);
|
||||
} else {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
function inspect(something) {
|
||||
if (functionsHaveNames || !util.isFunction(something)) {
|
||||
return util.inspect(something);
|
||||
}
|
||||
var rawname = getName(something);
|
||||
var name = rawname ? ': ' + rawname : '';
|
||||
return '[Function' + name + ']';
|
||||
}
|
||||
function getMessage(self) {
|
||||
return truncate(inspect(self.actual), 128) + ' ' +
|
||||
self.operator + ' ' +
|
||||
truncate(inspect(self.expected), 128);
|
||||
}
|
||||
|
||||
// At present only the three keys mentioned above are used and
|
||||
// understood by the spec. Implementations or sub modules can pass
|
||||
// other keys to the AssertionError's constructor - they will be
|
||||
// ignored.
|
||||
|
||||
// 3. All of the following functions must throw an AssertionError
|
||||
// when a corresponding condition is not met, with a message that
|
||||
// may be undefined if not provided. All assertion methods provide
|
||||
// both the actual and expected values to the assertion error for
|
||||
// display purposes.
|
||||
|
||||
function fail(actual, expected, message, operator, stackStartFunction) {
|
||||
throw new assert.AssertionError({
|
||||
message: message,
|
||||
actual: actual,
|
||||
expected: expected,
|
||||
operator: operator,
|
||||
stackStartFunction: stackStartFunction
|
||||
});
|
||||
}
|
||||
|
||||
// EXTENSION! allows for well behaved errors defined elsewhere.
|
||||
assert.fail = fail;
|
||||
|
||||
// 4. Pure assertion tests whether a value is truthy, as determined
|
||||
// by !!guard.
|
||||
// assert.ok(guard, message_opt);
|
||||
// This statement is equivalent to assert.equal(true, !!guard,
|
||||
// message_opt);. To test strictly for the value true, use
|
||||
// assert.strictEqual(true, guard, message_opt);.
|
||||
|
||||
function ok(value, message) {
|
||||
if (!value) fail(value, true, message, '==', assert.ok);
|
||||
}
|
||||
assert.ok = ok;
|
||||
|
||||
// 5. The equality assertion tests shallow, coercive equality with
|
||||
// ==.
|
||||
// assert.equal(actual, expected, message_opt);
|
||||
|
||||
assert.equal = function equal(actual, expected, message) {
|
||||
if (actual != expected) fail(actual, expected, message, '==', assert.equal);
|
||||
};
|
||||
|
||||
// 6. The non-equality assertion tests for whether two objects are not equal
|
||||
// with != assert.notEqual(actual, expected, message_opt);
|
||||
|
||||
assert.notEqual = function notEqual(actual, expected, message) {
|
||||
if (actual == expected) {
|
||||
fail(actual, expected, message, '!=', assert.notEqual);
|
||||
}
|
||||
};
|
||||
|
||||
// 7. The equivalence assertion tests a deep equality relation.
|
||||
// assert.deepEqual(actual, expected, message_opt);
|
||||
|
||||
assert.deepEqual = function deepEqual(actual, expected, message) {
|
||||
if (!_deepEqual(actual, expected, false)) {
|
||||
fail(actual, expected, message, 'deepEqual', assert.deepEqual);
|
||||
}
|
||||
};
|
||||
|
||||
assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
|
||||
if (!_deepEqual(actual, expected, true)) {
|
||||
fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual);
|
||||
}
|
||||
};
|
||||
|
||||
function _deepEqual(actual, expected, strict, memos) {
|
||||
// 7.1. All identical values are equivalent, as determined by ===.
|
||||
if (actual === expected) {
|
||||
return true;
|
||||
} else if (isBuffer(actual) && isBuffer(expected)) {
|
||||
return compare(actual, expected) === 0;
|
||||
|
||||
// 7.2. If the expected value is a Date object, the actual value is
|
||||
// equivalent if it is also a Date object that refers to the same time.
|
||||
} else if (util.isDate(actual) && util.isDate(expected)) {
|
||||
return actual.getTime() === expected.getTime();
|
||||
|
||||
// 7.3 If the expected value is a RegExp object, the actual value is
|
||||
// equivalent if it is also a RegExp object with the same source and
|
||||
// properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
|
||||
} else if (util.isRegExp(actual) && util.isRegExp(expected)) {
|
||||
return actual.source === expected.source &&
|
||||
actual.global === expected.global &&
|
||||
actual.multiline === expected.multiline &&
|
||||
actual.lastIndex === expected.lastIndex &&
|
||||
actual.ignoreCase === expected.ignoreCase;
|
||||
|
||||
// 7.4. Other pairs that do not both pass typeof value == 'object',
|
||||
// equivalence is determined by ==.
|
||||
} else if ((actual === null || typeof actual !== 'object') &&
|
||||
(expected === null || typeof expected !== 'object')) {
|
||||
return strict ? actual === expected : actual == expected;
|
||||
|
||||
// If both values are instances of typed arrays, wrap their underlying
|
||||
// ArrayBuffers in a Buffer each to increase performance
|
||||
// This optimization requires the arrays to have the same type as checked by
|
||||
// Object.prototype.toString (aka pToString). Never perform binary
|
||||
// comparisons for Float*Arrays, though, since e.g. +0 === -0 but their
|
||||
// bit patterns are not identical.
|
||||
} else if (isView(actual) && isView(expected) &&
|
||||
pToString(actual) === pToString(expected) &&
|
||||
!(actual instanceof Float32Array ||
|
||||
actual instanceof Float64Array)) {
|
||||
return compare(new Uint8Array(actual.buffer),
|
||||
new Uint8Array(expected.buffer)) === 0;
|
||||
|
||||
// 7.5 For all other Object pairs, including Array objects, equivalence is
|
||||
// determined by having the same number of owned properties (as verified
|
||||
// with Object.prototype.hasOwnProperty.call), the same set of keys
|
||||
// (although not necessarily the same order), equivalent values for every
|
||||
// corresponding key, and an identical 'prototype' property. Note: this
|
||||
// accounts for both named and indexed properties on Arrays.
|
||||
} else if (isBuffer(actual) !== isBuffer(expected)) {
|
||||
return false;
|
||||
} else {
|
||||
memos = memos || {actual: [], expected: []};
|
||||
|
||||
var actualIndex = memos.actual.indexOf(actual);
|
||||
if (actualIndex !== -1) {
|
||||
if (actualIndex === memos.expected.indexOf(expected)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
memos.actual.push(actual);
|
||||
memos.expected.push(expected);
|
||||
|
||||
return objEquiv(actual, expected, strict, memos);
|
||||
}
|
||||
}
|
||||
|
||||
function isArguments(object) {
|
||||
return Object.prototype.toString.call(object) == '[object Arguments]';
|
||||
}
|
||||
|
||||
function objEquiv(a, b, strict, actualVisitedObjects) {
|
||||
if (a === null || a === undefined || b === null || b === undefined)
|
||||
return false;
|
||||
// if one is a primitive, the other must be same
|
||||
if (util.isPrimitive(a) || util.isPrimitive(b))
|
||||
return a === b;
|
||||
if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
|
||||
return false;
|
||||
var aIsArgs = isArguments(a);
|
||||
var bIsArgs = isArguments(b);
|
||||
if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
|
||||
return false;
|
||||
if (aIsArgs) {
|
||||
a = pSlice.call(a);
|
||||
b = pSlice.call(b);
|
||||
return _deepEqual(a, b, strict);
|
||||
}
|
||||
var ka = objectKeys(a);
|
||||
var kb = objectKeys(b);
|
||||
var key, i;
|
||||
// having the same number of owned properties (keys incorporates
|
||||
// hasOwnProperty)
|
||||
if (ka.length !== kb.length)
|
||||
return false;
|
||||
//the same set of keys (although not necessarily the same order),
|
||||
ka.sort();
|
||||
kb.sort();
|
||||
//~~~cheap key test
|
||||
for (i = ka.length - 1; i >= 0; i--) {
|
||||
if (ka[i] !== kb[i])
|
||||
return false;
|
||||
}
|
||||
//equivalent values for every corresponding key, and
|
||||
//~~~possibly expensive deep test
|
||||
for (i = ka.length - 1; i >= 0; i--) {
|
||||
key = ka[i];
|
||||
if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 8. The non-equivalence assertion tests for any deep inequality.
|
||||
// assert.notDeepEqual(actual, expected, message_opt);
|
||||
|
||||
assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
|
||||
if (_deepEqual(actual, expected, false)) {
|
||||
fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
|
||||
}
|
||||
};
|
||||
|
||||
assert.notDeepStrictEqual = notDeepStrictEqual;
|
||||
function notDeepStrictEqual(actual, expected, message) {
|
||||
if (_deepEqual(actual, expected, true)) {
|
||||
fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 9. The strict equality assertion tests strict equality, as determined by ===.
|
||||
// assert.strictEqual(actual, expected, message_opt);
|
||||
|
||||
assert.strictEqual = function strictEqual(actual, expected, message) {
|
||||
if (actual !== expected) {
|
||||
fail(actual, expected, message, '===', assert.strictEqual);
|
||||
}
|
||||
};
|
||||
|
||||
// 10. The strict non-equality assertion tests for strict inequality, as
|
||||
// determined by !==. assert.notStrictEqual(actual, expected, message_opt);
|
||||
|
||||
assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
|
||||
if (actual === expected) {
|
||||
fail(actual, expected, message, '!==', assert.notStrictEqual);
|
||||
}
|
||||
};
|
||||
|
||||
function expectedException(actual, expected) {
|
||||
if (!actual || !expected) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Object.prototype.toString.call(expected) == '[object RegExp]') {
|
||||
return expected.test(actual);
|
||||
}
|
||||
|
||||
try {
|
||||
if (actual instanceof expected) {
|
||||
return true;
|
||||
}
|
||||
} catch (e) {
|
||||
// Ignore. The instanceof check doesn't work for arrow functions.
|
||||
}
|
||||
|
||||
if (Error.isPrototypeOf(expected)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return expected.call({}, actual) === true;
|
||||
}
|
||||
|
||||
function _tryBlock(block) {
|
||||
var error;
|
||||
try {
|
||||
block();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
function _throws(shouldThrow, block, expected, message) {
|
||||
var actual;
|
||||
|
||||
if (typeof block !== 'function') {
|
||||
throw new TypeError('"block" argument must be a function');
|
||||
}
|
||||
|
||||
if (typeof expected === 'string') {
|
||||
message = expected;
|
||||
expected = null;
|
||||
}
|
||||
|
||||
actual = _tryBlock(block);
|
||||
|
||||
message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
|
||||
(message ? ' ' + message : '.');
|
||||
|
||||
if (shouldThrow && !actual) {
|
||||
fail(actual, expected, 'Missing expected exception' + message);
|
||||
}
|
||||
|
||||
var userProvidedMessage = typeof message === 'string';
|
||||
var isUnwantedException = !shouldThrow && util.isError(actual);
|
||||
var isUnexpectedException = !shouldThrow && actual && !expected;
|
||||
|
||||
if ((isUnwantedException &&
|
||||
userProvidedMessage &&
|
||||
expectedException(actual, expected)) ||
|
||||
isUnexpectedException) {
|
||||
fail(actual, expected, 'Got unwanted exception' + message);
|
||||
}
|
||||
|
||||
if ((shouldThrow && actual && expected &&
|
||||
!expectedException(actual, expected)) || (!shouldThrow && actual)) {
|
||||
throw actual;
|
||||
}
|
||||
}
|
||||
|
||||
// 11. Expected to throw an error:
|
||||
// assert.throws(block, Error_opt, message_opt);
|
||||
|
||||
assert.throws = function(block, /*optional*/error, /*optional*/message) {
|
||||
_throws(true, block, error, message);
|
||||
};
|
||||
|
||||
// EXTENSION! This is annoying to write outside this module.
|
||||
assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {
|
||||
_throws(false, block, error, message);
|
||||
};
|
||||
|
||||
assert.ifError = function(err) { if (err) throw err; };
|
||||
|
||||
// Expose a strict only variant of assert
|
||||
function strict(value, message) {
|
||||
if (!value) fail(value, true, message, '==', strict);
|
||||
}
|
||||
assert.strict = objectAssign(strict, assert, {
|
||||
equal: assert.strictEqual,
|
||||
deepEqual: assert.deepStrictEqual,
|
||||
notEqual: assert.notStrictEqual,
|
||||
notDeepEqual: assert.notDeepStrictEqual
|
||||
});
|
||||
assert.strict.strict = assert.strict;
|
||||
|
||||
var objectKeys = Object.keys || function (obj) {
|
||||
var keys = [];
|
||||
for (var key in obj) {
|
||||
if (hasOwn.call(obj, key)) keys.push(key);
|
||||
}
|
||||
return keys;
|
||||
};
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user