update
This commit is contained in:
@@ -0,0 +1 @@
|
||||
{"v0.8":{"start":"2012-06-25","end":"2014-07-31"},"v0.10":{"start":"2013-03-11","end":"2016-10-31"},"v0.12":{"start":"2015-02-06","end":"2016-12-31"},"v4":{"start":"2015-09-08","lts":"2015-10-12","maintenance":"2017-04-01","end":"2018-04-30","codename":"Argon"},"v5":{"start":"2015-10-29","maintenance":"2016-04-30","end":"2016-06-30"},"v6":{"start":"2016-04-26","lts":"2016-10-18","maintenance":"2018-04-30","end":"2019-04-30","codename":"Boron"},"v7":{"start":"2016-10-25","maintenance":"2017-04-30","end":"2017-06-30"},"v8":{"start":"2017-05-30","lts":"2017-10-31","maintenance":"2019-01-01","end":"2019-12-31","codename":"Carbon"},"v9":{"start":"2017-10-01","maintenance":"2018-04-01","end":"2018-06-30"},"v10":{"start":"2018-04-24","lts":"2018-10-30","maintenance":"2020-05-19","end":"2021-04-30","codename":"Dubnium"},"v11":{"start":"2018-10-23","maintenance":"2019-04-22","end":"2019-06-01"},"v12":{"start":"2019-04-23","lts":"2019-10-21","maintenance":"2020-11-30","end":"2022-04-30","codename":"Erbium"},"v13":{"start":"2019-10-22","maintenance":"2020-04-01","end":"2020-06-01"},"v14":{"start":"2020-04-21","lts":"2020-10-27","maintenance":"2021-10-19","end":"2023-04-30","codename":"Fermium"},"v15":{"start":"2020-10-20","maintenance":"2021-04-01","end":"2021-06-01"},"v16":{"start":"2021-04-20","lts":"2021-10-26","maintenance":"2022-10-18","end":"2023-09-11","codename":"Gallium"},"v17":{"start":"2021-10-19","maintenance":"2022-04-01","end":"2022-06-01"},"v18":{"start":"2022-04-19","lts":"2022-10-25","maintenance":"2023-10-18","end":"2025-04-30","codename":"Hydrogen"},"v19":{"start":"2022-10-18","maintenance":"2023-04-01","end":"2023-06-01"},"v20":{"start":"2023-04-18","lts":"2023-10-24","maintenance":"2024-10-22","end":"2026-04-30","codename":"Iron"},"v21":{"start":"2023-10-17","maintenance":"2024-04-01","end":"2024-06-01"},"v22":{"start":"2024-04-24","lts":"2024-10-29","maintenance":"2025-10-21","end":"2027-04-30","codename":"Jod"},"v23":{"start":"2024-10-16","maintenance":"2025-04-01","end":"2025-06-01"},"v24":{"start":"2025-04-22","lts":"2025-10-28","maintenance":"2026-10-20","end":"2028-04-30","codename":""}}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"K D E F A B mC"},B:{"2":"0 9 C L M G N O P Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I"},C:{"2":"0 1 2 3 4 5 6 7 8 9 nC LC J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC qC rC"},D:{"2":"0 1 2 3 4 5 6 7 8 9 J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC"},E:{"1":"M G xC yC zC UC VC HC 0C IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C","2":"J PB K D E F A B C L sC SC tC uC vC wC TC FC GC"},F:{"2":"0 1 2 3 4 5 6 7 8 F B C G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 4C 5C 6C 7C FC kC 8C GC"},G:{"1":"PD QD RD SD UC VC HC TD IC WC XC YC ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC","2":"E SC 9C lC AD BD CD DD ED FD GD HD ID JD KD LD MD ND OD"},H:{"2":"WD"},I:{"2":"LC J I XD YD ZD aD lC bD cD"},J:{"2":"D A"},K:{"2":"A B C H FC kC GC"},L:{"2":"I"},M:{"2":"EC"},N:{"2":"A B"},O:{"2":"HC"},P:{"2":"1 2 3 4 5 6 7 8 J dD eD fD gD hD TC iD jD kD lD mD IC JC KC nD"},Q:{"2":"oD"},R:{"2":"pD"},S:{"2":"qD rD"}},B:5,C:"ui-serif, ui-sans-serif, ui-monospace and ui-rounded values for font-family",D:true};
|
||||
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "@types/babel__template",
|
||||
"version": "7.4.4",
|
||||
"description": "TypeScript definitions for @babel/template",
|
||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/babel__template",
|
||||
"license": "MIT",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Troy Gerwien",
|
||||
"githubUsername": "yortus",
|
||||
"url": "https://github.com/yortus"
|
||||
},
|
||||
{
|
||||
"name": "Marvin Hagemeister",
|
||||
"githubUsername": "marvinhagemeister",
|
||||
"url": "https://github.com/marvinhagemeister"
|
||||
},
|
||||
{
|
||||
"name": "Melvin Groenhoff",
|
||||
"githubUsername": "mgroenhoff",
|
||||
"url": "https://github.com/mgroenhoff"
|
||||
},
|
||||
{
|
||||
"name": "ExE Boss",
|
||||
"githubUsername": "ExE-Boss",
|
||||
"url": "https://github.com/ExE-Boss"
|
||||
}
|
||||
],
|
||||
"main": "",
|
||||
"types": "index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||
"directory": "types/babel__template"
|
||||
},
|
||||
"scripts": {},
|
||||
"dependencies": {
|
||||
"@babel/parser": "^7.1.0",
|
||||
"@babel/types": "^7.0.0"
|
||||
},
|
||||
"typesPublisherContentHash": "5730d754b4d1fcd41676b093f9e32b340c749c4d37b126dfa312e394467e86c6",
|
||||
"typeScriptVersion": "4.5"
|
||||
}
|
||||
@@ -0,0 +1,426 @@
|
||||
'use strict'
|
||||
module.exports = Yallist
|
||||
|
||||
Yallist.Node = Node
|
||||
Yallist.create = Yallist
|
||||
|
||||
function Yallist (list) {
|
||||
var self = this
|
||||
if (!(self instanceof Yallist)) {
|
||||
self = new Yallist()
|
||||
}
|
||||
|
||||
self.tail = null
|
||||
self.head = null
|
||||
self.length = 0
|
||||
|
||||
if (list && typeof list.forEach === 'function') {
|
||||
list.forEach(function (item) {
|
||||
self.push(item)
|
||||
})
|
||||
} else if (arguments.length > 0) {
|
||||
for (var i = 0, l = arguments.length; i < l; i++) {
|
||||
self.push(arguments[i])
|
||||
}
|
||||
}
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
Yallist.prototype.removeNode = function (node) {
|
||||
if (node.list !== this) {
|
||||
throw new Error('removing node which does not belong to this list')
|
||||
}
|
||||
|
||||
var next = node.next
|
||||
var prev = node.prev
|
||||
|
||||
if (next) {
|
||||
next.prev = prev
|
||||
}
|
||||
|
||||
if (prev) {
|
||||
prev.next = next
|
||||
}
|
||||
|
||||
if (node === this.head) {
|
||||
this.head = next
|
||||
}
|
||||
if (node === this.tail) {
|
||||
this.tail = prev
|
||||
}
|
||||
|
||||
node.list.length--
|
||||
node.next = null
|
||||
node.prev = null
|
||||
node.list = null
|
||||
|
||||
return next
|
||||
}
|
||||
|
||||
Yallist.prototype.unshiftNode = function (node) {
|
||||
if (node === this.head) {
|
||||
return
|
||||
}
|
||||
|
||||
if (node.list) {
|
||||
node.list.removeNode(node)
|
||||
}
|
||||
|
||||
var head = this.head
|
||||
node.list = this
|
||||
node.next = head
|
||||
if (head) {
|
||||
head.prev = node
|
||||
}
|
||||
|
||||
this.head = node
|
||||
if (!this.tail) {
|
||||
this.tail = node
|
||||
}
|
||||
this.length++
|
||||
}
|
||||
|
||||
Yallist.prototype.pushNode = function (node) {
|
||||
if (node === this.tail) {
|
||||
return
|
||||
}
|
||||
|
||||
if (node.list) {
|
||||
node.list.removeNode(node)
|
||||
}
|
||||
|
||||
var tail = this.tail
|
||||
node.list = this
|
||||
node.prev = tail
|
||||
if (tail) {
|
||||
tail.next = node
|
||||
}
|
||||
|
||||
this.tail = node
|
||||
if (!this.head) {
|
||||
this.head = node
|
||||
}
|
||||
this.length++
|
||||
}
|
||||
|
||||
Yallist.prototype.push = function () {
|
||||
for (var i = 0, l = arguments.length; i < l; i++) {
|
||||
push(this, arguments[i])
|
||||
}
|
||||
return this.length
|
||||
}
|
||||
|
||||
Yallist.prototype.unshift = function () {
|
||||
for (var i = 0, l = arguments.length; i < l; i++) {
|
||||
unshift(this, arguments[i])
|
||||
}
|
||||
return this.length
|
||||
}
|
||||
|
||||
Yallist.prototype.pop = function () {
|
||||
if (!this.tail) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
var res = this.tail.value
|
||||
this.tail = this.tail.prev
|
||||
if (this.tail) {
|
||||
this.tail.next = null
|
||||
} else {
|
||||
this.head = null
|
||||
}
|
||||
this.length--
|
||||
return res
|
||||
}
|
||||
|
||||
Yallist.prototype.shift = function () {
|
||||
if (!this.head) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
var res = this.head.value
|
||||
this.head = this.head.next
|
||||
if (this.head) {
|
||||
this.head.prev = null
|
||||
} else {
|
||||
this.tail = null
|
||||
}
|
||||
this.length--
|
||||
return res
|
||||
}
|
||||
|
||||
Yallist.prototype.forEach = function (fn, thisp) {
|
||||
thisp = thisp || this
|
||||
for (var walker = this.head, i = 0; walker !== null; i++) {
|
||||
fn.call(thisp, walker.value, i, this)
|
||||
walker = walker.next
|
||||
}
|
||||
}
|
||||
|
||||
Yallist.prototype.forEachReverse = function (fn, thisp) {
|
||||
thisp = thisp || this
|
||||
for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
|
||||
fn.call(thisp, walker.value, i, this)
|
||||
walker = walker.prev
|
||||
}
|
||||
}
|
||||
|
||||
Yallist.prototype.get = function (n) {
|
||||
for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
|
||||
// abort out of the list early if we hit a cycle
|
||||
walker = walker.next
|
||||
}
|
||||
if (i === n && walker !== null) {
|
||||
return walker.value
|
||||
}
|
||||
}
|
||||
|
||||
Yallist.prototype.getReverse = function (n) {
|
||||
for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
|
||||
// abort out of the list early if we hit a cycle
|
||||
walker = walker.prev
|
||||
}
|
||||
if (i === n && walker !== null) {
|
||||
return walker.value
|
||||
}
|
||||
}
|
||||
|
||||
Yallist.prototype.map = function (fn, thisp) {
|
||||
thisp = thisp || this
|
||||
var res = new Yallist()
|
||||
for (var walker = this.head; walker !== null;) {
|
||||
res.push(fn.call(thisp, walker.value, this))
|
||||
walker = walker.next
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
Yallist.prototype.mapReverse = function (fn, thisp) {
|
||||
thisp = thisp || this
|
||||
var res = new Yallist()
|
||||
for (var walker = this.tail; walker !== null;) {
|
||||
res.push(fn.call(thisp, walker.value, this))
|
||||
walker = walker.prev
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
Yallist.prototype.reduce = function (fn, initial) {
|
||||
var acc
|
||||
var walker = this.head
|
||||
if (arguments.length > 1) {
|
||||
acc = initial
|
||||
} else if (this.head) {
|
||||
walker = this.head.next
|
||||
acc = this.head.value
|
||||
} else {
|
||||
throw new TypeError('Reduce of empty list with no initial value')
|
||||
}
|
||||
|
||||
for (var i = 0; walker !== null; i++) {
|
||||
acc = fn(acc, walker.value, i)
|
||||
walker = walker.next
|
||||
}
|
||||
|
||||
return acc
|
||||
}
|
||||
|
||||
Yallist.prototype.reduceReverse = function (fn, initial) {
|
||||
var acc
|
||||
var walker = this.tail
|
||||
if (arguments.length > 1) {
|
||||
acc = initial
|
||||
} else if (this.tail) {
|
||||
walker = this.tail.prev
|
||||
acc = this.tail.value
|
||||
} else {
|
||||
throw new TypeError('Reduce of empty list with no initial value')
|
||||
}
|
||||
|
||||
for (var i = this.length - 1; walker !== null; i--) {
|
||||
acc = fn(acc, walker.value, i)
|
||||
walker = walker.prev
|
||||
}
|
||||
|
||||
return acc
|
||||
}
|
||||
|
||||
Yallist.prototype.toArray = function () {
|
||||
var arr = new Array(this.length)
|
||||
for (var i = 0, walker = this.head; walker !== null; i++) {
|
||||
arr[i] = walker.value
|
||||
walker = walker.next
|
||||
}
|
||||
return arr
|
||||
}
|
||||
|
||||
Yallist.prototype.toArrayReverse = function () {
|
||||
var arr = new Array(this.length)
|
||||
for (var i = 0, walker = this.tail; walker !== null; i++) {
|
||||
arr[i] = walker.value
|
||||
walker = walker.prev
|
||||
}
|
||||
return arr
|
||||
}
|
||||
|
||||
Yallist.prototype.slice = function (from, to) {
|
||||
to = to || this.length
|
||||
if (to < 0) {
|
||||
to += this.length
|
||||
}
|
||||
from = from || 0
|
||||
if (from < 0) {
|
||||
from += this.length
|
||||
}
|
||||
var ret = new Yallist()
|
||||
if (to < from || to < 0) {
|
||||
return ret
|
||||
}
|
||||
if (from < 0) {
|
||||
from = 0
|
||||
}
|
||||
if (to > this.length) {
|
||||
to = this.length
|
||||
}
|
||||
for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
|
||||
walker = walker.next
|
||||
}
|
||||
for (; walker !== null && i < to; i++, walker = walker.next) {
|
||||
ret.push(walker.value)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
Yallist.prototype.sliceReverse = function (from, to) {
|
||||
to = to || this.length
|
||||
if (to < 0) {
|
||||
to += this.length
|
||||
}
|
||||
from = from || 0
|
||||
if (from < 0) {
|
||||
from += this.length
|
||||
}
|
||||
var ret = new Yallist()
|
||||
if (to < from || to < 0) {
|
||||
return ret
|
||||
}
|
||||
if (from < 0) {
|
||||
from = 0
|
||||
}
|
||||
if (to > this.length) {
|
||||
to = this.length
|
||||
}
|
||||
for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
|
||||
walker = walker.prev
|
||||
}
|
||||
for (; walker !== null && i > from; i--, walker = walker.prev) {
|
||||
ret.push(walker.value)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
Yallist.prototype.splice = function (start, deleteCount /*, ...nodes */) {
|
||||
if (start > this.length) {
|
||||
start = this.length - 1
|
||||
}
|
||||
if (start < 0) {
|
||||
start = this.length + start;
|
||||
}
|
||||
|
||||
for (var i = 0, walker = this.head; walker !== null && i < start; i++) {
|
||||
walker = walker.next
|
||||
}
|
||||
|
||||
var ret = []
|
||||
for (var i = 0; walker && i < deleteCount; i++) {
|
||||
ret.push(walker.value)
|
||||
walker = this.removeNode(walker)
|
||||
}
|
||||
if (walker === null) {
|
||||
walker = this.tail
|
||||
}
|
||||
|
||||
if (walker !== this.head && walker !== this.tail) {
|
||||
walker = walker.prev
|
||||
}
|
||||
|
||||
for (var i = 2; i < arguments.length; i++) {
|
||||
walker = insert(this, walker, arguments[i])
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Yallist.prototype.reverse = function () {
|
||||
var head = this.head
|
||||
var tail = this.tail
|
||||
for (var walker = head; walker !== null; walker = walker.prev) {
|
||||
var p = walker.prev
|
||||
walker.prev = walker.next
|
||||
walker.next = p
|
||||
}
|
||||
this.head = tail
|
||||
this.tail = head
|
||||
return this
|
||||
}
|
||||
|
||||
function insert (self, node, value) {
|
||||
var inserted = node === self.head ?
|
||||
new Node(value, null, node, self) :
|
||||
new Node(value, node, node.next, self)
|
||||
|
||||
if (inserted.next === null) {
|
||||
self.tail = inserted
|
||||
}
|
||||
if (inserted.prev === null) {
|
||||
self.head = inserted
|
||||
}
|
||||
|
||||
self.length++
|
||||
|
||||
return inserted
|
||||
}
|
||||
|
||||
function push (self, item) {
|
||||
self.tail = new Node(item, self.tail, null, self)
|
||||
if (!self.head) {
|
||||
self.head = self.tail
|
||||
}
|
||||
self.length++
|
||||
}
|
||||
|
||||
function unshift (self, item) {
|
||||
self.head = new Node(item, null, self.head, self)
|
||||
if (!self.tail) {
|
||||
self.tail = self.head
|
||||
}
|
||||
self.length++
|
||||
}
|
||||
|
||||
function Node (value, prev, next, list) {
|
||||
if (!(this instanceof Node)) {
|
||||
return new Node(value, prev, next, list)
|
||||
}
|
||||
|
||||
this.list = list
|
||||
this.value = value
|
||||
|
||||
if (prev) {
|
||||
prev.next = this
|
||||
this.prev = prev
|
||||
} else {
|
||||
this.prev = null
|
||||
}
|
||||
|
||||
if (next) {
|
||||
next.prev = this
|
||||
this.next = next
|
||||
} else {
|
||||
this.next = null
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// add if support for Symbol.iterator is present
|
||||
require('./iterator.js')(Yallist)
|
||||
} catch (er) {}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"root": true,
|
||||
|
||||
"extends": "@ljharb/eslint-config/node/0.4",
|
||||
|
||||
"rules": {
|
||||
"array-element-newline": 0,
|
||||
"complexity": 0,
|
||||
"func-style": [2, "declaration"],
|
||||
"max-lines-per-function": 0,
|
||||
"max-nested-callbacks": 1,
|
||||
"max-statements-per-line": 1,
|
||||
"max-statements": 0,
|
||||
"multiline-comment-style": 0,
|
||||
"no-continue": 1,
|
||||
"no-param-reassign": 1,
|
||||
"no-restricted-syntax": 1,
|
||||
"object-curly-newline": 0,
|
||||
},
|
||||
|
||||
"overrides": [
|
||||
{
|
||||
"files": "test/**",
|
||||
"rules": {
|
||||
"camelcase": 0,
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"name": "@types/babel__core",
|
||||
"version": "7.20.5",
|
||||
"description": "TypeScript definitions for @babel/core",
|
||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/babel__core",
|
||||
"license": "MIT",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Troy Gerwien",
|
||||
"githubUsername": "yortus",
|
||||
"url": "https://github.com/yortus"
|
||||
},
|
||||
{
|
||||
"name": "Marvin Hagemeister",
|
||||
"githubUsername": "marvinhagemeister",
|
||||
"url": "https://github.com/marvinhagemeister"
|
||||
},
|
||||
{
|
||||
"name": "Melvin Groenhoff",
|
||||
"githubUsername": "mgroenhoff",
|
||||
"url": "https://github.com/mgroenhoff"
|
||||
},
|
||||
{
|
||||
"name": "Jessica Franco",
|
||||
"githubUsername": "Jessidhia",
|
||||
"url": "https://github.com/Jessidhia"
|
||||
},
|
||||
{
|
||||
"name": "Ifiok Jr.",
|
||||
"githubUsername": "ifiokjr",
|
||||
"url": "https://github.com/ifiokjr"
|
||||
}
|
||||
],
|
||||
"main": "",
|
||||
"types": "index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||
"directory": "types/babel__core"
|
||||
},
|
||||
"scripts": {},
|
||||
"dependencies": {
|
||||
"@babel/parser": "^7.20.7",
|
||||
"@babel/types": "^7.20.7",
|
||||
"@types/babel__generator": "*",
|
||||
"@types/babel__template": "*",
|
||||
"@types/babel__traverse": "*"
|
||||
},
|
||||
"typesPublisherContentHash": "3ece429b02ff9f70503a5644f2b303b04d10e6da7940c91a9eff5e52f2c76b91",
|
||||
"typeScriptVersion": "4.5"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{D:{"1":"0 9 lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC","2":"1 2 3 4 5 6 7 8 J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB"},L:{"1":"I"},B:{"1":"0 9 Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I","2":"C L M G N O P"},C:{"1":"0 9 nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC","2":"nC LC J PB K D E F A B C L M G N qC rC","33":"1 2 3 4 5 6 7 8 O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB"},M:{"1":"EC"},A:{"2":"K D E F A B mC"},F:{"1":"0 YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z","2":"1 2 3 4 5 6 7 8 F B C G N O P QB RB SB TB UB VB WB XB 4C 5C 6C 7C FC kC 8C GC"},K:{"1":"H","2":"A B C FC kC GC"},E:{"1":"B C L M G FC GC xC yC zC UC VC HC 0C IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC","2":"J PB K sC SC tC uC 3C","33":"D E F A vC wC TC"},G:{"1":"ID JD KD LD MD ND OD PD QD RD SD UC VC HC TD IC WC XC YC ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC","2":"SC 9C lC AD BD","33":"E CD DD ED FD GD HD"},P:{"1":"1 2 3 4 5 6 7 8 dD eD fD gD hD TC iD jD kD lD mD IC JC KC nD","2":"J"},I:{"1":"I","2":"LC J XD YD ZD aD lC bD cD"}},B:6,C:"isolate-override from unicode-bidi",D:undefined};
|
||||
@@ -0,0 +1,17 @@
|
||||
module.exports = function (pkg) {
|
||||
var m;
|
||||
if (m = match(JSON.stringify(pkg.repository))) {
|
||||
return m;
|
||||
}
|
||||
else if (m = match(JSON.stringify(pkg))) {
|
||||
return m;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
function match (str) {
|
||||
var m = /\bgithub.com[:\/]([^\/"]+)\/([^\/"]+)/.exec(str);
|
||||
if (m) {
|
||||
return 'https://github.com/' + m[1] + '/' + m[2].replace(/\.git$/, '');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
{{# def.definitions }}
|
||||
{{# def.errors }}
|
||||
{{# def.setupKeyword }}
|
||||
|
||||
{{## def._validateRef:_v:
|
||||
{{? it.opts.passContext }}
|
||||
{{=_v}}.call(this,
|
||||
{{??}}
|
||||
{{=_v}}(
|
||||
{{?}}
|
||||
{{=$data}}, {{# def.dataPath }}{{# def.passParentData }}, rootData)
|
||||
#}}
|
||||
|
||||
{{ var $async, $refCode; }}
|
||||
{{? $schema == '#' || $schema == '#/' }}
|
||||
{{
|
||||
if (it.isRoot) {
|
||||
$async = it.async;
|
||||
$refCode = 'validate';
|
||||
} else {
|
||||
$async = it.root.schema.$async === true;
|
||||
$refCode = 'root.refVal[0]';
|
||||
}
|
||||
}}
|
||||
{{??}}
|
||||
{{ var $refVal = it.resolveRef(it.baseId, $schema, it.isRoot); }}
|
||||
{{? $refVal === undefined }}
|
||||
{{ var $message = it.MissingRefError.message(it.baseId, $schema); }}
|
||||
{{? it.opts.missingRefs == 'fail' }}
|
||||
{{ it.logger.error($message); }}
|
||||
{{# def.error:'$ref' }}
|
||||
{{? $breakOnError }} if (false) { {{?}}
|
||||
{{?? it.opts.missingRefs == 'ignore' }}
|
||||
{{ it.logger.warn($message); }}
|
||||
{{? $breakOnError }} if (true) { {{?}}
|
||||
{{??}}
|
||||
{{ throw new it.MissingRefError(it.baseId, $schema, $message); }}
|
||||
{{?}}
|
||||
{{?? $refVal.inline }}
|
||||
{{# def.setupNextLevel }}
|
||||
{{
|
||||
$it.schema = $refVal.schema;
|
||||
$it.schemaPath = '';
|
||||
$it.errSchemaPath = $schema;
|
||||
}}
|
||||
{{ var $code = it.validate($it).replace(/validate\.schema/g, $refVal.code); }}
|
||||
{{= $code }}
|
||||
{{? $breakOnError}}
|
||||
if ({{=$nextValid}}) {
|
||||
{{?}}
|
||||
{{??}}
|
||||
{{
|
||||
$async = $refVal.$async === true || (it.async && $refVal.$async !== false);
|
||||
$refCode = $refVal.code;
|
||||
}}
|
||||
{{?}}
|
||||
{{?}}
|
||||
|
||||
{{? $refCode }}
|
||||
{{# def.beginDefOut}}
|
||||
{{# def._validateRef:$refCode }}
|
||||
{{# def.storeDefOut:__callValidate }}
|
||||
|
||||
{{? $async }}
|
||||
{{ if (!it.async) throw new Error('async schema referenced by sync schema'); }}
|
||||
{{? $breakOnError }} var {{=$valid}}; {{?}}
|
||||
try {
|
||||
await {{=__callValidate}};
|
||||
{{? $breakOnError }} {{=$valid}} = true; {{?}}
|
||||
} catch (e) {
|
||||
if (!(e instanceof ValidationError)) throw e;
|
||||
if (vErrors === null) vErrors = e.errors;
|
||||
else vErrors = vErrors.concat(e.errors);
|
||||
errors = vErrors.length;
|
||||
{{? $breakOnError }} {{=$valid}} = false; {{?}}
|
||||
}
|
||||
{{? $breakOnError }} if ({{=$valid}}) { {{?}}
|
||||
{{??}}
|
||||
if (!{{=__callValidate}}) {
|
||||
if (vErrors === null) vErrors = {{=$refCode}}.errors;
|
||||
else vErrors = vErrors.concat({{=$refCode}}.errors);
|
||||
errors = vErrors.length;
|
||||
} {{? $breakOnError }} else { {{?}}
|
||||
{{?}}
|
||||
{{?}}
|
||||
@@ -0,0 +1,261 @@
|
||||
const util = require('./util')
|
||||
|
||||
module.exports = function stringify (value, replacer, space) {
|
||||
const stack = []
|
||||
let indent = ''
|
||||
let propertyList
|
||||
let replacerFunc
|
||||
let gap = ''
|
||||
let quote
|
||||
|
||||
if (
|
||||
replacer != null &&
|
||||
typeof replacer === 'object' &&
|
||||
!Array.isArray(replacer)
|
||||
) {
|
||||
space = replacer.space
|
||||
quote = replacer.quote
|
||||
replacer = replacer.replacer
|
||||
}
|
||||
|
||||
if (typeof replacer === 'function') {
|
||||
replacerFunc = replacer
|
||||
} else if (Array.isArray(replacer)) {
|
||||
propertyList = []
|
||||
for (const v of replacer) {
|
||||
let item
|
||||
|
||||
if (typeof v === 'string') {
|
||||
item = v
|
||||
} else if (
|
||||
typeof v === 'number' ||
|
||||
v instanceof String ||
|
||||
v instanceof Number
|
||||
) {
|
||||
item = String(v)
|
||||
}
|
||||
|
||||
if (item !== undefined && propertyList.indexOf(item) < 0) {
|
||||
propertyList.push(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (space instanceof Number) {
|
||||
space = Number(space)
|
||||
} else if (space instanceof String) {
|
||||
space = String(space)
|
||||
}
|
||||
|
||||
if (typeof space === 'number') {
|
||||
if (space > 0) {
|
||||
space = Math.min(10, Math.floor(space))
|
||||
gap = ' '.substr(0, space)
|
||||
}
|
||||
} else if (typeof space === 'string') {
|
||||
gap = space.substr(0, 10)
|
||||
}
|
||||
|
||||
return serializeProperty('', {'': value})
|
||||
|
||||
function serializeProperty (key, holder) {
|
||||
let value = holder[key]
|
||||
if (value != null) {
|
||||
if (typeof value.toJSON5 === 'function') {
|
||||
value = value.toJSON5(key)
|
||||
} else if (typeof value.toJSON === 'function') {
|
||||
value = value.toJSON(key)
|
||||
}
|
||||
}
|
||||
|
||||
if (replacerFunc) {
|
||||
value = replacerFunc.call(holder, key, value)
|
||||
}
|
||||
|
||||
if (value instanceof Number) {
|
||||
value = Number(value)
|
||||
} else if (value instanceof String) {
|
||||
value = String(value)
|
||||
} else if (value instanceof Boolean) {
|
||||
value = value.valueOf()
|
||||
}
|
||||
|
||||
switch (value) {
|
||||
case null: return 'null'
|
||||
case true: return 'true'
|
||||
case false: return 'false'
|
||||
}
|
||||
|
||||
if (typeof value === 'string') {
|
||||
return quoteString(value, false)
|
||||
}
|
||||
|
||||
if (typeof value === 'number') {
|
||||
return String(value)
|
||||
}
|
||||
|
||||
if (typeof value === 'object') {
|
||||
return Array.isArray(value) ? serializeArray(value) : serializeObject(value)
|
||||
}
|
||||
|
||||
return undefined
|
||||
}
|
||||
|
||||
function quoteString (value) {
|
||||
const quotes = {
|
||||
"'": 0.1,
|
||||
'"': 0.2,
|
||||
}
|
||||
|
||||
const replacements = {
|
||||
"'": "\\'",
|
||||
'"': '\\"',
|
||||
'\\': '\\\\',
|
||||
'\b': '\\b',
|
||||
'\f': '\\f',
|
||||
'\n': '\\n',
|
||||
'\r': '\\r',
|
||||
'\t': '\\t',
|
||||
'\v': '\\v',
|
||||
'\0': '\\0',
|
||||
'\u2028': '\\u2028',
|
||||
'\u2029': '\\u2029',
|
||||
}
|
||||
|
||||
let product = ''
|
||||
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
const c = value[i]
|
||||
switch (c) {
|
||||
case "'":
|
||||
case '"':
|
||||
quotes[c]++
|
||||
product += c
|
||||
continue
|
||||
|
||||
case '\0':
|
||||
if (util.isDigit(value[i + 1])) {
|
||||
product += '\\x00'
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if (replacements[c]) {
|
||||
product += replacements[c]
|
||||
continue
|
||||
}
|
||||
|
||||
if (c < ' ') {
|
||||
let hexString = c.charCodeAt(0).toString(16)
|
||||
product += '\\x' + ('00' + hexString).substring(hexString.length)
|
||||
continue
|
||||
}
|
||||
|
||||
product += c
|
||||
}
|
||||
|
||||
const quoteChar = quote || Object.keys(quotes).reduce((a, b) => (quotes[a] < quotes[b]) ? a : b)
|
||||
|
||||
product = product.replace(new RegExp(quoteChar, 'g'), replacements[quoteChar])
|
||||
|
||||
return quoteChar + product + quoteChar
|
||||
}
|
||||
|
||||
function serializeObject (value) {
|
||||
if (stack.indexOf(value) >= 0) {
|
||||
throw TypeError('Converting circular structure to JSON5')
|
||||
}
|
||||
|
||||
stack.push(value)
|
||||
|
||||
let stepback = indent
|
||||
indent = indent + gap
|
||||
|
||||
let keys = propertyList || Object.keys(value)
|
||||
let partial = []
|
||||
for (const key of keys) {
|
||||
const propertyString = serializeProperty(key, value)
|
||||
if (propertyString !== undefined) {
|
||||
let member = serializeKey(key) + ':'
|
||||
if (gap !== '') {
|
||||
member += ' '
|
||||
}
|
||||
member += propertyString
|
||||
partial.push(member)
|
||||
}
|
||||
}
|
||||
|
||||
let final
|
||||
if (partial.length === 0) {
|
||||
final = '{}'
|
||||
} else {
|
||||
let properties
|
||||
if (gap === '') {
|
||||
properties = partial.join(',')
|
||||
final = '{' + properties + '}'
|
||||
} else {
|
||||
let separator = ',\n' + indent
|
||||
properties = partial.join(separator)
|
||||
final = '{\n' + indent + properties + ',\n' + stepback + '}'
|
||||
}
|
||||
}
|
||||
|
||||
stack.pop()
|
||||
indent = stepback
|
||||
return final
|
||||
}
|
||||
|
||||
function serializeKey (key) {
|
||||
if (key.length === 0) {
|
||||
return quoteString(key, true)
|
||||
}
|
||||
|
||||
const firstChar = String.fromCodePoint(key.codePointAt(0))
|
||||
if (!util.isIdStartChar(firstChar)) {
|
||||
return quoteString(key, true)
|
||||
}
|
||||
|
||||
for (let i = firstChar.length; i < key.length; i++) {
|
||||
if (!util.isIdContinueChar(String.fromCodePoint(key.codePointAt(i)))) {
|
||||
return quoteString(key, true)
|
||||
}
|
||||
}
|
||||
|
||||
return key
|
||||
}
|
||||
|
||||
function serializeArray (value) {
|
||||
if (stack.indexOf(value) >= 0) {
|
||||
throw TypeError('Converting circular structure to JSON5')
|
||||
}
|
||||
|
||||
stack.push(value)
|
||||
|
||||
let stepback = indent
|
||||
indent = indent + gap
|
||||
|
||||
let partial = []
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
const propertyString = serializeProperty(String(i), value)
|
||||
partial.push((propertyString !== undefined) ? propertyString : 'null')
|
||||
}
|
||||
|
||||
let final
|
||||
if (partial.length === 0) {
|
||||
final = '[]'
|
||||
} else {
|
||||
if (gap === '') {
|
||||
let properties = partial.join(',')
|
||||
final = '[' + properties + ']'
|
||||
} else {
|
||||
let separator = ',\n' + indent
|
||||
let properties = partial.join(separator)
|
||||
final = '[\n' + indent + properties + ',\n' + stepback + ']'
|
||||
}
|
||||
}
|
||||
|
||||
stack.pop()
|
||||
indent = stepback
|
||||
return final
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"1":"F A B","2":"K D E mC"},B:{"1":"0 9 C L M G N O P Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I"},C:{"1":"0 9 xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC","33":"1 2 3 4 5 6 7 8 nC LC J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC qC rC"},D:{"1":"0 1 2 3 4 5 6 7 8 9 J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC"},E:{"1":"J PB K D E F A B C L M G sC SC tC uC vC wC TC FC GC xC yC zC UC VC HC 0C IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C"},F:{"1":"0 1 2 3 4 5 6 7 8 B C G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 4C 5C 6C 7C FC kC 8C GC","2":"F"},G:{"2":"E SC 9C lC AD BD CD DD ED FD GD HD ID JD KD LD MD ND OD PD QD RD SD UC VC HC TD IC WC XC YC ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC"},H:{"2":"WD"},I:{"1":"I bD cD","2":"LC J XD YD ZD aD lC"},J:{"1":"A","2":"D"},K:{"1":"C H kC GC","16":"A B FC"},L:{"1":"I"},M:{"1":"EC"},N:{"1":"A B"},O:{"1":"HC"},P:{"1":"1 2 3 4 5 6 7 8 J dD eD fD gD hD TC iD jD kD lD mD IC JC KC nD"},Q:{"1":"oD"},R:{"1":"pD"},S:{"1":"rD","33":"qD"}},B:5,C:"::selection CSS pseudo-element",D:true};
|
||||
@@ -0,0 +1 @@
|
||||
import{isBuiltin as i}from"node:module";var o=async(a,e,u)=>{let r=await u(a,e);if(r.url===import.meta.url||i(r.url)||!e.parentURL)return r;let t=new URL(e.parentURL).searchParams.get("id");if(t===null)return r;let l=new URL(r.url);return l.searchParams.set("id",t),{...r,url:`${l}`}};export{o as resolve};
|
||||
@@ -0,0 +1,89 @@
|
||||
declare type StringifyOptions = {
|
||||
/**
|
||||
* A function that alters the behavior of the stringification process, or an
|
||||
* array of String and Number objects that serve as a allowlist for
|
||||
* selecting/filtering the properties of the value object to be included in
|
||||
* the JSON5 string. If this value is null or not provided, all properties
|
||||
* of the object are included in the resulting JSON5 string.
|
||||
*/
|
||||
replacer?:
|
||||
| ((this: any, key: string, value: any) => any)
|
||||
| (string | number)[]
|
||||
| null
|
||||
|
||||
/**
|
||||
* A String or Number object that's used to insert white space into the
|
||||
* output JSON5 string for readability purposes. If this is a Number, it
|
||||
* indicates the number of space characters to use as white space; this
|
||||
* number is capped at 10 (if it is greater, the value is just 10). Values
|
||||
* less than 1 indicate that no space should be used. If this is a String,
|
||||
* the string (or the first 10 characters of the string, if it's longer than
|
||||
* that) is used as white space. If this parameter is not provided (or is
|
||||
* null), no white space is used. If white space is used, trailing commas
|
||||
* will be used in objects and arrays.
|
||||
*/
|
||||
space?: string | number | null
|
||||
|
||||
/**
|
||||
* A String representing the quote character to use when serializing
|
||||
* strings.
|
||||
*/
|
||||
quote?: string | null
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a JavaScript value to a JSON5 string.
|
||||
* @param value The value to convert to a JSON5 string.
|
||||
* @param replacer A function that alters the behavior of the stringification
|
||||
* process. If this value is null or not provided, all properties of the object
|
||||
* are included in the resulting JSON5 string.
|
||||
* @param space A String or Number object that's used to insert white space into
|
||||
* the output JSON5 string for readability purposes. If this is a Number, it
|
||||
* indicates the number of space characters to use as white space; this number
|
||||
* is capped at 10 (if it is greater, the value is just 10). Values less than 1
|
||||
* indicate that no space should be used. If this is a String, the string (or
|
||||
* the first 10 characters of the string, if it's longer than that) is used as
|
||||
* white space. If this parameter is not provided (or is null), no white space
|
||||
* is used. If white space is used, trailing commas will be used in objects and
|
||||
* arrays.
|
||||
* @returns The JSON5 string converted from the JavaScript value.
|
||||
*/
|
||||
declare function stringify(
|
||||
value: any,
|
||||
replacer?: ((this: any, key: string, value: any) => any) | null,
|
||||
space?: string | number | null,
|
||||
): string
|
||||
|
||||
/**
|
||||
* Converts a JavaScript value to a JSON5 string.
|
||||
* @param value The value to convert to a JSON5 string.
|
||||
* @param replacer An array of String and Number objects that serve as a
|
||||
* allowlist for selecting/filtering the properties of the value object to be
|
||||
* included in the JSON5 string. If this value is null or not provided, all
|
||||
* properties of the object are included in the resulting JSON5 string.
|
||||
* @param space A String or Number object that's used to insert white space into
|
||||
* the output JSON5 string for readability purposes. If this is a Number, it
|
||||
* indicates the number of space characters to use as white space; this number
|
||||
* is capped at 10 (if it is greater, the value is just 10). Values less than 1
|
||||
* indicate that no space should be used. If this is a String, the string (or
|
||||
* the first 10 characters of the string, if it's longer than that) is used as
|
||||
* white space. If this parameter is not provided (or is null), no white space
|
||||
* is used. If white space is used, trailing commas will be used in objects and
|
||||
* arrays.
|
||||
* @returns The JSON5 string converted from the JavaScript value.
|
||||
*/
|
||||
declare function stringify(
|
||||
value: any,
|
||||
replacer: (string | number)[],
|
||||
space?: string | number | null,
|
||||
): string
|
||||
|
||||
/**
|
||||
* Converts a JavaScript value to a JSON5 string.
|
||||
* @param value The value to convert to a JSON5 string.
|
||||
* @param options An object specifying options.
|
||||
* @returns The JSON5 string converted from the JavaScript value.
|
||||
*/
|
||||
declare function stringify(value: any, options: StringifyOptions): string
|
||||
|
||||
export = stringify
|
||||
@@ -0,0 +1,7 @@
|
||||
Copyright © James Long and 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.
|
||||
@@ -0,0 +1,443 @@
|
||||
'use strict';
|
||||
|
||||
/** Highest positive signed 32-bit float value */
|
||||
const maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
|
||||
|
||||
/** Bootstring parameters */
|
||||
const base = 36;
|
||||
const tMin = 1;
|
||||
const tMax = 26;
|
||||
const skew = 38;
|
||||
const damp = 700;
|
||||
const initialBias = 72;
|
||||
const initialN = 128; // 0x80
|
||||
const delimiter = '-'; // '\x2D'
|
||||
|
||||
/** Regular expressions */
|
||||
const regexPunycode = /^xn--/;
|
||||
const regexNonASCII = /[^\0-\x7F]/; // Note: U+007F DEL is excluded too.
|
||||
const regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
|
||||
|
||||
/** Error messages */
|
||||
const errors = {
|
||||
'overflow': 'Overflow: input needs wider integers to process',
|
||||
'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
|
||||
'invalid-input': 'Invalid input'
|
||||
};
|
||||
|
||||
/** Convenience shortcuts */
|
||||
const baseMinusTMin = base - tMin;
|
||||
const floor = Math.floor;
|
||||
const stringFromCharCode = String.fromCharCode;
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* A generic error utility function.
|
||||
* @private
|
||||
* @param {String} type The error type.
|
||||
* @returns {Error} Throws a `RangeError` with the applicable error message.
|
||||
*/
|
||||
function error(type) {
|
||||
throw new RangeError(errors[type]);
|
||||
}
|
||||
|
||||
/**
|
||||
* A generic `Array#map` utility function.
|
||||
* @private
|
||||
* @param {Array} array The array to iterate over.
|
||||
* @param {Function} callback The function that gets called for every array
|
||||
* item.
|
||||
* @returns {Array} A new array of values returned by the callback function.
|
||||
*/
|
||||
function map(array, callback) {
|
||||
const result = [];
|
||||
let length = array.length;
|
||||
while (length--) {
|
||||
result[length] = callback(array[length]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple `Array#map`-like wrapper to work with domain name strings or email
|
||||
* addresses.
|
||||
* @private
|
||||
* @param {String} domain The domain name or email address.
|
||||
* @param {Function} callback The function that gets called for every
|
||||
* character.
|
||||
* @returns {String} A new string of characters returned by the callback
|
||||
* function.
|
||||
*/
|
||||
function mapDomain(domain, callback) {
|
||||
const parts = domain.split('@');
|
||||
let result = '';
|
||||
if (parts.length > 1) {
|
||||
// In email addresses, only the domain name should be punycoded. Leave
|
||||
// the local part (i.e. everything up to `@`) intact.
|
||||
result = parts[0] + '@';
|
||||
domain = parts[1];
|
||||
}
|
||||
// Avoid `split(regex)` for IE8 compatibility. See #17.
|
||||
domain = domain.replace(regexSeparators, '\x2E');
|
||||
const labels = domain.split('.');
|
||||
const encoded = map(labels, callback).join('.');
|
||||
return result + encoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an array containing the numeric code points of each Unicode
|
||||
* character in the string. While JavaScript uses UCS-2 internally,
|
||||
* this function will convert a pair of surrogate halves (each of which
|
||||
* UCS-2 exposes as separate characters) into a single code point,
|
||||
* matching UTF-16.
|
||||
* @see `punycode.ucs2.encode`
|
||||
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
||||
* @memberOf punycode.ucs2
|
||||
* @name decode
|
||||
* @param {String} string The Unicode input string (UCS-2).
|
||||
* @returns {Array} The new array of code points.
|
||||
*/
|
||||
function ucs2decode(string) {
|
||||
const output = [];
|
||||
let counter = 0;
|
||||
const length = string.length;
|
||||
while (counter < length) {
|
||||
const value = string.charCodeAt(counter++);
|
||||
if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
|
||||
// It's a high surrogate, and there is a next character.
|
||||
const extra = string.charCodeAt(counter++);
|
||||
if ((extra & 0xFC00) == 0xDC00) { // Low surrogate.
|
||||
output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
|
||||
} else {
|
||||
// It's an unmatched surrogate; only append this code unit, in case the
|
||||
// next code unit is the high surrogate of a surrogate pair.
|
||||
output.push(value);
|
||||
counter--;
|
||||
}
|
||||
} else {
|
||||
output.push(value);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a string based on an array of numeric code points.
|
||||
* @see `punycode.ucs2.decode`
|
||||
* @memberOf punycode.ucs2
|
||||
* @name encode
|
||||
* @param {Array} codePoints The array of numeric code points.
|
||||
* @returns {String} The new Unicode string (UCS-2).
|
||||
*/
|
||||
const ucs2encode = codePoints => String.fromCodePoint(...codePoints);
|
||||
|
||||
/**
|
||||
* Converts a basic code point into a digit/integer.
|
||||
* @see `digitToBasic()`
|
||||
* @private
|
||||
* @param {Number} codePoint The basic numeric code point value.
|
||||
* @returns {Number} The numeric value of a basic code point (for use in
|
||||
* representing integers) in the range `0` to `base - 1`, or `base` if
|
||||
* the code point does not represent a value.
|
||||
*/
|
||||
const basicToDigit = function(codePoint) {
|
||||
if (codePoint >= 0x30 && codePoint < 0x3A) {
|
||||
return 26 + (codePoint - 0x30);
|
||||
}
|
||||
if (codePoint >= 0x41 && codePoint < 0x5B) {
|
||||
return codePoint - 0x41;
|
||||
}
|
||||
if (codePoint >= 0x61 && codePoint < 0x7B) {
|
||||
return codePoint - 0x61;
|
||||
}
|
||||
return base;
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a digit/integer into a basic code point.
|
||||
* @see `basicToDigit()`
|
||||
* @private
|
||||
* @param {Number} digit The numeric value of a basic code point.
|
||||
* @returns {Number} The basic code point whose value (when used for
|
||||
* representing integers) is `digit`, which needs to be in the range
|
||||
* `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
|
||||
* used; else, the lowercase form is used. The behavior is undefined
|
||||
* if `flag` is non-zero and `digit` has no uppercase form.
|
||||
*/
|
||||
const digitToBasic = function(digit, flag) {
|
||||
// 0..25 map to ASCII a..z or A..Z
|
||||
// 26..35 map to ASCII 0..9
|
||||
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
|
||||
};
|
||||
|
||||
/**
|
||||
* Bias adaptation function as per section 3.4 of RFC 3492.
|
||||
* https://tools.ietf.org/html/rfc3492#section-3.4
|
||||
* @private
|
||||
*/
|
||||
const adapt = function(delta, numPoints, firstTime) {
|
||||
let k = 0;
|
||||
delta = firstTime ? floor(delta / damp) : delta >> 1;
|
||||
delta += floor(delta / numPoints);
|
||||
for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
|
||||
delta = floor(delta / baseMinusTMin);
|
||||
}
|
||||
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a Punycode string of ASCII-only symbols to a string of Unicode
|
||||
* symbols.
|
||||
* @memberOf punycode
|
||||
* @param {String} input The Punycode string of ASCII-only symbols.
|
||||
* @returns {String} The resulting string of Unicode symbols.
|
||||
*/
|
||||
const decode = function(input) {
|
||||
// Don't use UCS-2.
|
||||
const output = [];
|
||||
const inputLength = input.length;
|
||||
let i = 0;
|
||||
let n = initialN;
|
||||
let bias = initialBias;
|
||||
|
||||
// Handle the basic code points: let `basic` be the number of input code
|
||||
// points before the last delimiter, or `0` if there is none, then copy
|
||||
// the first basic code points to the output.
|
||||
|
||||
let basic = input.lastIndexOf(delimiter);
|
||||
if (basic < 0) {
|
||||
basic = 0;
|
||||
}
|
||||
|
||||
for (let j = 0; j < basic; ++j) {
|
||||
// if it's not a basic code point
|
||||
if (input.charCodeAt(j) >= 0x80) {
|
||||
error('not-basic');
|
||||
}
|
||||
output.push(input.charCodeAt(j));
|
||||
}
|
||||
|
||||
// Main decoding loop: start just after the last delimiter if any basic code
|
||||
// points were copied; start at the beginning otherwise.
|
||||
|
||||
for (let index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
|
||||
|
||||
// `index` is the index of the next character to be consumed.
|
||||
// Decode a generalized variable-length integer into `delta`,
|
||||
// which gets added to `i`. The overflow checking is easier
|
||||
// if we increase `i` as we go, then subtract off its starting
|
||||
// value at the end to obtain `delta`.
|
||||
const oldi = i;
|
||||
for (let w = 1, k = base; /* no condition */; k += base) {
|
||||
|
||||
if (index >= inputLength) {
|
||||
error('invalid-input');
|
||||
}
|
||||
|
||||
const digit = basicToDigit(input.charCodeAt(index++));
|
||||
|
||||
if (digit >= base) {
|
||||
error('invalid-input');
|
||||
}
|
||||
if (digit > floor((maxInt - i) / w)) {
|
||||
error('overflow');
|
||||
}
|
||||
|
||||
i += digit * w;
|
||||
const t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
|
||||
|
||||
if (digit < t) {
|
||||
break;
|
||||
}
|
||||
|
||||
const baseMinusT = base - t;
|
||||
if (w > floor(maxInt / baseMinusT)) {
|
||||
error('overflow');
|
||||
}
|
||||
|
||||
w *= baseMinusT;
|
||||
|
||||
}
|
||||
|
||||
const out = output.length + 1;
|
||||
bias = adapt(i - oldi, out, oldi == 0);
|
||||
|
||||
// `i` was supposed to wrap around from `out` to `0`,
|
||||
// incrementing `n` each time, so we'll fix that now:
|
||||
if (floor(i / out) > maxInt - n) {
|
||||
error('overflow');
|
||||
}
|
||||
|
||||
n += floor(i / out);
|
||||
i %= out;
|
||||
|
||||
// Insert `n` at position `i` of the output.
|
||||
output.splice(i++, 0, n);
|
||||
|
||||
}
|
||||
|
||||
return String.fromCodePoint(...output);
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a string of Unicode symbols (e.g. a domain name label) to a
|
||||
* Punycode string of ASCII-only symbols.
|
||||
* @memberOf punycode
|
||||
* @param {String} input The string of Unicode symbols.
|
||||
* @returns {String} The resulting Punycode string of ASCII-only symbols.
|
||||
*/
|
||||
const encode = function(input) {
|
||||
const output = [];
|
||||
|
||||
// Convert the input in UCS-2 to an array of Unicode code points.
|
||||
input = ucs2decode(input);
|
||||
|
||||
// Cache the length.
|
||||
const inputLength = input.length;
|
||||
|
||||
// Initialize the state.
|
||||
let n = initialN;
|
||||
let delta = 0;
|
||||
let bias = initialBias;
|
||||
|
||||
// Handle the basic code points.
|
||||
for (const currentValue of input) {
|
||||
if (currentValue < 0x80) {
|
||||
output.push(stringFromCharCode(currentValue));
|
||||
}
|
||||
}
|
||||
|
||||
const basicLength = output.length;
|
||||
let handledCPCount = basicLength;
|
||||
|
||||
// `handledCPCount` is the number of code points that have been handled;
|
||||
// `basicLength` is the number of basic code points.
|
||||
|
||||
// Finish the basic string with a delimiter unless it's empty.
|
||||
if (basicLength) {
|
||||
output.push(delimiter);
|
||||
}
|
||||
|
||||
// Main encoding loop:
|
||||
while (handledCPCount < inputLength) {
|
||||
|
||||
// All non-basic code points < n have been handled already. Find the next
|
||||
// larger one:
|
||||
let m = maxInt;
|
||||
for (const currentValue of input) {
|
||||
if (currentValue >= n && currentValue < m) {
|
||||
m = currentValue;
|
||||
}
|
||||
}
|
||||
|
||||
// Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
|
||||
// but guard against overflow.
|
||||
const handledCPCountPlusOne = handledCPCount + 1;
|
||||
if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
|
||||
error('overflow');
|
||||
}
|
||||
|
||||
delta += (m - n) * handledCPCountPlusOne;
|
||||
n = m;
|
||||
|
||||
for (const currentValue of input) {
|
||||
if (currentValue < n && ++delta > maxInt) {
|
||||
error('overflow');
|
||||
}
|
||||
if (currentValue === n) {
|
||||
// Represent delta as a generalized variable-length integer.
|
||||
let q = delta;
|
||||
for (let k = base; /* no condition */; k += base) {
|
||||
const t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
|
||||
if (q < t) {
|
||||
break;
|
||||
}
|
||||
const qMinusT = q - t;
|
||||
const baseMinusT = base - t;
|
||||
output.push(
|
||||
stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
|
||||
);
|
||||
q = floor(qMinusT / baseMinusT);
|
||||
}
|
||||
|
||||
output.push(stringFromCharCode(digitToBasic(q, 0)));
|
||||
bias = adapt(delta, handledCPCountPlusOne, handledCPCount === basicLength);
|
||||
delta = 0;
|
||||
++handledCPCount;
|
||||
}
|
||||
}
|
||||
|
||||
++delta;
|
||||
++n;
|
||||
|
||||
}
|
||||
return output.join('');
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a Punycode string representing a domain name or an email address
|
||||
* to Unicode. Only the Punycoded parts of the input will be converted, i.e.
|
||||
* it doesn't matter if you call it on a string that has already been
|
||||
* converted to Unicode.
|
||||
* @memberOf punycode
|
||||
* @param {String} input The Punycoded domain name or email address to
|
||||
* convert to Unicode.
|
||||
* @returns {String} The Unicode representation of the given Punycode
|
||||
* string.
|
||||
*/
|
||||
const toUnicode = function(input) {
|
||||
return mapDomain(input, function(string) {
|
||||
return regexPunycode.test(string)
|
||||
? decode(string.slice(4).toLowerCase())
|
||||
: string;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a Unicode string representing a domain name or an email address to
|
||||
* Punycode. Only the non-ASCII parts of the domain name will be converted,
|
||||
* i.e. it doesn't matter if you call it with a domain that's already in
|
||||
* ASCII.
|
||||
* @memberOf punycode
|
||||
* @param {String} input The domain name or email address to convert, as a
|
||||
* Unicode string.
|
||||
* @returns {String} The Punycode representation of the given domain name or
|
||||
* email address.
|
||||
*/
|
||||
const toASCII = function(input) {
|
||||
return mapDomain(input, function(string) {
|
||||
return regexNonASCII.test(string)
|
||||
? 'xn--' + encode(string)
|
||||
: string;
|
||||
});
|
||||
};
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/** Define the public API */
|
||||
const punycode = {
|
||||
/**
|
||||
* A string representing the current Punycode.js version number.
|
||||
* @memberOf punycode
|
||||
* @type String
|
||||
*/
|
||||
'version': '2.3.1',
|
||||
/**
|
||||
* An object of methods to convert from JavaScript's internal character
|
||||
* representation (UCS-2) to Unicode code points, and back.
|
||||
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
||||
* @memberOf punycode
|
||||
* @type Object
|
||||
*/
|
||||
'ucs2': {
|
||||
'decode': ucs2decode,
|
||||
'encode': ucs2encode
|
||||
},
|
||||
'decode': decode,
|
||||
'encode': encode,
|
||||
'toASCII': toASCII,
|
||||
'toUnicode': toUnicode
|
||||
};
|
||||
|
||||
module.exports = punycode;
|
||||
@@ -0,0 +1,678 @@
|
||||
'use strict'
|
||||
|
||||
const util = require('util')
|
||||
|
||||
// DOMMatrix per https://drafts.fxtf.org/geometry/#DOMMatrix
|
||||
|
||||
class DOMPoint {
|
||||
constructor (x, y, z, w) {
|
||||
if (typeof x === 'object' && x !== null) {
|
||||
w = x.w
|
||||
z = x.z
|
||||
y = x.y
|
||||
x = x.x
|
||||
}
|
||||
this.x = typeof x === 'number' ? x : 0
|
||||
this.y = typeof y === 'number' ? y : 0
|
||||
this.z = typeof z === 'number' ? z : 0
|
||||
this.w = typeof w === 'number' ? w : 1
|
||||
}
|
||||
|
||||
matrixTransform(init) {
|
||||
// TODO: this next line is wrong. matrixTransform is supposed to only take
|
||||
// an object with the DOMMatrix properties called DOMMatrixInit
|
||||
const m = init instanceof DOMMatrix ? init : new DOMMatrix(init)
|
||||
return m.transformPoint(this)
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return {
|
||||
x: this.x,
|
||||
y: this.y,
|
||||
z: this.z,
|
||||
w: this.w
|
||||
}
|
||||
}
|
||||
|
||||
static fromPoint(other) {
|
||||
return new this(other.x, other.y, other.z, other.w)
|
||||
}
|
||||
}
|
||||
|
||||
// Constants to index into _values (col-major)
|
||||
const M11 = 0; const M12 = 1; const M13 = 2; const M14 = 3
|
||||
const M21 = 4; const M22 = 5; const M23 = 6; const M24 = 7
|
||||
const M31 = 8; const M32 = 9; const M33 = 10; const M34 = 11
|
||||
const M41 = 12; const M42 = 13; const M43 = 14; const M44 = 15
|
||||
|
||||
const DEGREE_PER_RAD = 180 / Math.PI
|
||||
const RAD_PER_DEGREE = Math.PI / 180
|
||||
|
||||
function parseMatrix (init) {
|
||||
let parsed = init.replace('matrix(', '')
|
||||
parsed = parsed.split(',', 7) // 6 + 1 to handle too many params
|
||||
if (parsed.length !== 6) throw new Error(`Failed to parse ${init}`)
|
||||
parsed = parsed.map(parseFloat)
|
||||
return [
|
||||
parsed[0], parsed[1], 0, 0,
|
||||
parsed[2], parsed[3], 0, 0,
|
||||
0, 0, 1, 0,
|
||||
parsed[4], parsed[5], 0, 1
|
||||
]
|
||||
}
|
||||
|
||||
function parseMatrix3d (init) {
|
||||
let parsed = init.replace('matrix3d(', '')
|
||||
parsed = parsed.split(',', 17) // 16 + 1 to handle too many params
|
||||
if (parsed.length !== 16) throw new Error(`Failed to parse ${init}`)
|
||||
return parsed.map(parseFloat)
|
||||
}
|
||||
|
||||
function parseTransform (tform) {
|
||||
const type = tform.split('(', 1)[0]
|
||||
switch (type) {
|
||||
case 'matrix':
|
||||
return parseMatrix(tform)
|
||||
case 'matrix3d':
|
||||
return parseMatrix3d(tform)
|
||||
// TODO This is supposed to support any CSS transform value.
|
||||
default:
|
||||
throw new Error(`${type} parsing not implemented`)
|
||||
}
|
||||
}
|
||||
|
||||
class DOMMatrix {
|
||||
constructor (init) {
|
||||
this._is2D = true
|
||||
this._values = new Float64Array([
|
||||
1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1
|
||||
])
|
||||
|
||||
let i
|
||||
|
||||
if (typeof init === 'string') { // parse CSS transformList
|
||||
if (init === '') return // default identity matrix
|
||||
const tforms = init.split(/\)\s+/, 20).map(parseTransform)
|
||||
if (tforms.length === 0) return
|
||||
init = tforms[0]
|
||||
for (i = 1; i < tforms.length; i++) init = multiply(tforms[i], init)
|
||||
}
|
||||
|
||||
i = 0
|
||||
if (init && init.length === 6) {
|
||||
setNumber2D(this, M11, init[i++])
|
||||
setNumber2D(this, M12, init[i++])
|
||||
setNumber2D(this, M21, init[i++])
|
||||
setNumber2D(this, M22, init[i++])
|
||||
setNumber2D(this, M41, init[i++])
|
||||
setNumber2D(this, M42, init[i++])
|
||||
} else if (init && init.length === 16) {
|
||||
setNumber2D(this, M11, init[i++])
|
||||
setNumber2D(this, M12, init[i++])
|
||||
setNumber3D(this, M13, init[i++])
|
||||
setNumber3D(this, M14, init[i++])
|
||||
setNumber2D(this, M21, init[i++])
|
||||
setNumber2D(this, M22, init[i++])
|
||||
setNumber3D(this, M23, init[i++])
|
||||
setNumber3D(this, M24, init[i++])
|
||||
setNumber3D(this, M31, init[i++])
|
||||
setNumber3D(this, M32, init[i++])
|
||||
setNumber3D(this, M33, init[i++])
|
||||
setNumber3D(this, M34, init[i++])
|
||||
setNumber2D(this, M41, init[i++])
|
||||
setNumber2D(this, M42, init[i++])
|
||||
setNumber3D(this, M43, init[i++])
|
||||
setNumber3D(this, M44, init[i])
|
||||
} else if (init !== undefined) {
|
||||
throw new TypeError('Expected string or array.')
|
||||
}
|
||||
}
|
||||
|
||||
toString () {
|
||||
return this.is2D
|
||||
? `matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.e}, ${this.f})`
|
||||
: `matrix3d(${this._values.join(', ')})`
|
||||
}
|
||||
|
||||
multiply (other) {
|
||||
return newInstance(this._values).multiplySelf(other)
|
||||
}
|
||||
|
||||
multiplySelf (other) {
|
||||
this._values = multiply(other._values, this._values)
|
||||
if (!other.is2D) this._is2D = false
|
||||
return this
|
||||
}
|
||||
|
||||
preMultiplySelf (other) {
|
||||
this._values = multiply(this._values, other._values)
|
||||
if (!other.is2D) this._is2D = false
|
||||
return this
|
||||
}
|
||||
|
||||
translate (tx, ty, tz) {
|
||||
return newInstance(this._values).translateSelf(tx, ty, tz)
|
||||
}
|
||||
|
||||
translateSelf (tx, ty, tz) {
|
||||
if (typeof tx !== 'number') tx = 0
|
||||
if (typeof ty !== 'number') ty = 0
|
||||
if (typeof tz !== 'number') tz = 0
|
||||
this._values = multiply([
|
||||
1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
tx, ty, tz, 1
|
||||
], this._values)
|
||||
if (tz !== 0) this._is2D = false
|
||||
return this
|
||||
}
|
||||
|
||||
scale (scaleX, scaleY, scaleZ, originX, originY, originZ) {
|
||||
return newInstance(this._values).scaleSelf(scaleX, scaleY, scaleZ, originX, originY, originZ)
|
||||
}
|
||||
|
||||
scale3d (scale, originX, originY, originZ) {
|
||||
return newInstance(this._values).scale3dSelf(scale, originX, originY, originZ)
|
||||
}
|
||||
|
||||
scale3dSelf (scale, originX, originY, originZ) {
|
||||
return this.scaleSelf(scale, scale, scale, originX, originY, originZ)
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
scaleNonUniform(scaleX, scaleY) {
|
||||
return this.scale(scaleX, scaleY)
|
||||
}
|
||||
|
||||
scaleSelf (scaleX, scaleY, scaleZ, originX, originY, originZ) {
|
||||
// Not redundant with translate's checks because we need to negate the values later.
|
||||
if (typeof originX !== 'number') originX = 0
|
||||
if (typeof originY !== 'number') originY = 0
|
||||
if (typeof originZ !== 'number') originZ = 0
|
||||
this.translateSelf(originX, originY, originZ)
|
||||
if (typeof scaleX !== 'number') scaleX = 1
|
||||
if (typeof scaleY !== 'number') scaleY = scaleX
|
||||
if (typeof scaleZ !== 'number') scaleZ = 1
|
||||
this._values = multiply([
|
||||
scaleX, 0, 0, 0,
|
||||
0, scaleY, 0, 0,
|
||||
0, 0, scaleZ, 0,
|
||||
0, 0, 0, 1
|
||||
], this._values)
|
||||
this.translateSelf(-originX, -originY, -originZ)
|
||||
if (scaleZ !== 1 || originZ !== 0) this._is2D = false
|
||||
return this
|
||||
}
|
||||
|
||||
rotateFromVector (x, y) {
|
||||
return newInstance(this._values).rotateFromVectorSelf(x, y)
|
||||
}
|
||||
|
||||
rotateFromVectorSelf (x, y) {
|
||||
if (typeof x !== 'number') x = 0
|
||||
if (typeof y !== 'number') y = 0
|
||||
const theta = (x === 0 && y === 0) ? 0 : Math.atan2(y, x) * DEGREE_PER_RAD
|
||||
return this.rotateSelf(theta)
|
||||
}
|
||||
|
||||
rotate (rotX, rotY, rotZ) {
|
||||
return newInstance(this._values).rotateSelf(rotX, rotY, rotZ)
|
||||
}
|
||||
|
||||
rotateSelf (rotX, rotY, rotZ) {
|
||||
if (rotY === undefined && rotZ === undefined) {
|
||||
rotZ = rotX
|
||||
rotX = rotY = 0
|
||||
}
|
||||
if (typeof rotY !== 'number') rotY = 0
|
||||
if (typeof rotZ !== 'number') rotZ = 0
|
||||
if (rotX !== 0 || rotY !== 0) this._is2D = false
|
||||
rotX *= RAD_PER_DEGREE
|
||||
rotY *= RAD_PER_DEGREE
|
||||
rotZ *= RAD_PER_DEGREE
|
||||
let c, s
|
||||
c = Math.cos(rotZ)
|
||||
s = Math.sin(rotZ)
|
||||
this._values = multiply([
|
||||
c, s, 0, 0,
|
||||
-s, c, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1
|
||||
], this._values)
|
||||
c = Math.cos(rotY)
|
||||
s = Math.sin(rotY)
|
||||
this._values = multiply([
|
||||
c, 0, -s, 0,
|
||||
0, 1, 0, 0,
|
||||
s, 0, c, 0,
|
||||
0, 0, 0, 1
|
||||
], this._values)
|
||||
c = Math.cos(rotX)
|
||||
s = Math.sin(rotX)
|
||||
this._values = multiply([
|
||||
1, 0, 0, 0,
|
||||
0, c, s, 0,
|
||||
0, -s, c, 0,
|
||||
0, 0, 0, 1
|
||||
], this._values)
|
||||
return this
|
||||
}
|
||||
|
||||
rotateAxisAngle (x, y, z, angle) {
|
||||
return newInstance(this._values).rotateAxisAngleSelf(x, y, z, angle)
|
||||
}
|
||||
|
||||
rotateAxisAngleSelf (x, y, z, angle) {
|
||||
if (typeof x !== 'number') x = 0
|
||||
if (typeof y !== 'number') y = 0
|
||||
if (typeof z !== 'number') z = 0
|
||||
// Normalize axis
|
||||
const length = Math.sqrt(x * x + y * y + z * z)
|
||||
if (length === 0) return this
|
||||
if (length !== 1) {
|
||||
x /= length
|
||||
y /= length
|
||||
z /= length
|
||||
}
|
||||
angle *= RAD_PER_DEGREE
|
||||
const c = Math.cos(angle)
|
||||
const s = Math.sin(angle)
|
||||
const t = 1 - c
|
||||
const tx = t * x
|
||||
const ty = t * y
|
||||
// NB: This is the generic transform. If the axis is a major axis, there are
|
||||
// faster transforms.
|
||||
this._values = multiply([
|
||||
tx * x + c, tx * y + s * z, tx * z - s * y, 0,
|
||||
tx * y - s * z, ty * y + c, ty * z + s * x, 0,
|
||||
tx * z + s * y, ty * z - s * x, t * z * z + c, 0,
|
||||
0, 0, 0, 1
|
||||
], this._values)
|
||||
if (x !== 0 || y !== 0) this._is2D = false
|
||||
return this
|
||||
}
|
||||
|
||||
skewX (sx) {
|
||||
return newInstance(this._values).skewXSelf(sx)
|
||||
}
|
||||
|
||||
skewXSelf (sx) {
|
||||
if (typeof sx !== 'number') return this
|
||||
const t = Math.tan(sx * RAD_PER_DEGREE)
|
||||
this._values = multiply([
|
||||
1, 0, 0, 0,
|
||||
t, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1
|
||||
], this._values)
|
||||
return this
|
||||
}
|
||||
|
||||
skewY (sy) {
|
||||
return newInstance(this._values).skewYSelf(sy)
|
||||
}
|
||||
|
||||
skewYSelf (sy) {
|
||||
if (typeof sy !== 'number') return this
|
||||
const t = Math.tan(sy * RAD_PER_DEGREE)
|
||||
this._values = multiply([
|
||||
1, t, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1
|
||||
], this._values)
|
||||
return this
|
||||
}
|
||||
|
||||
flipX () {
|
||||
return newInstance(multiply([
|
||||
-1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1
|
||||
], this._values))
|
||||
}
|
||||
|
||||
flipY () {
|
||||
return newInstance(multiply([
|
||||
1, 0, 0, 0,
|
||||
0, -1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1
|
||||
], this._values))
|
||||
}
|
||||
|
||||
inverse () {
|
||||
return newInstance(this._values).invertSelf()
|
||||
}
|
||||
|
||||
invertSelf () {
|
||||
const m = this._values
|
||||
const inv = m.map(v => 0)
|
||||
|
||||
inv[0] = m[5] * m[10] * m[15] -
|
||||
m[5] * m[11] * m[14] -
|
||||
m[9] * m[6] * m[15] +
|
||||
m[9] * m[7] * m[14] +
|
||||
m[13] * m[6] * m[11] -
|
||||
m[13] * m[7] * m[10]
|
||||
|
||||
inv[4] = -m[4] * m[10] * m[15] +
|
||||
m[4] * m[11] * m[14] +
|
||||
m[8] * m[6] * m[15] -
|
||||
m[8] * m[7] * m[14] -
|
||||
m[12] * m[6] * m[11] +
|
||||
m[12] * m[7] * m[10]
|
||||
|
||||
inv[8] = m[4] * m[9] * m[15] -
|
||||
m[4] * m[11] * m[13] -
|
||||
m[8] * m[5] * m[15] +
|
||||
m[8] * m[7] * m[13] +
|
||||
m[12] * m[5] * m[11] -
|
||||
m[12] * m[7] * m[9]
|
||||
|
||||
inv[12] = -m[4] * m[9] * m[14] +
|
||||
m[4] * m[10] * m[13] +
|
||||
m[8] * m[5] * m[14] -
|
||||
m[8] * m[6] * m[13] -
|
||||
m[12] * m[5] * m[10] +
|
||||
m[12] * m[6] * m[9]
|
||||
|
||||
// If the determinant is zero, this matrix cannot be inverted, and all
|
||||
// values should be set to NaN, with the is2D flag set to false.
|
||||
|
||||
const det = m[0] * inv[0] + m[1] * inv[4] + m[2] * inv[8] + m[3] * inv[12]
|
||||
|
||||
if (det === 0) {
|
||||
this._values = m.map(v => NaN)
|
||||
this._is2D = false
|
||||
return this
|
||||
}
|
||||
|
||||
inv[1] = -m[1] * m[10] * m[15] +
|
||||
m[1] * m[11] * m[14] +
|
||||
m[9] * m[2] * m[15] -
|
||||
m[9] * m[3] * m[14] -
|
||||
m[13] * m[2] * m[11] +
|
||||
m[13] * m[3] * m[10]
|
||||
|
||||
inv[5] = m[0] * m[10] * m[15] -
|
||||
m[0] * m[11] * m[14] -
|
||||
m[8] * m[2] * m[15] +
|
||||
m[8] * m[3] * m[14] +
|
||||
m[12] * m[2] * m[11] -
|
||||
m[12] * m[3] * m[10]
|
||||
|
||||
inv[9] = -m[0] * m[9] * m[15] +
|
||||
m[0] * m[11] * m[13] +
|
||||
m[8] * m[1] * m[15] -
|
||||
m[8] * m[3] * m[13] -
|
||||
m[12] * m[1] * m[11] +
|
||||
m[12] * m[3] * m[9]
|
||||
|
||||
inv[13] = m[0] * m[9] * m[14] -
|
||||
m[0] * m[10] * m[13] -
|
||||
m[8] * m[1] * m[14] +
|
||||
m[8] * m[2] * m[13] +
|
||||
m[12] * m[1] * m[10] -
|
||||
m[12] * m[2] * m[9]
|
||||
|
||||
inv[2] = m[1] * m[6] * m[15] -
|
||||
m[1] * m[7] * m[14] -
|
||||
m[5] * m[2] * m[15] +
|
||||
m[5] * m[3] * m[14] +
|
||||
m[13] * m[2] * m[7] -
|
||||
m[13] * m[3] * m[6]
|
||||
|
||||
inv[6] = -m[0] * m[6] * m[15] +
|
||||
m[0] * m[7] * m[14] +
|
||||
m[4] * m[2] * m[15] -
|
||||
m[4] * m[3] * m[14] -
|
||||
m[12] * m[2] * m[7] +
|
||||
m[12] * m[3] * m[6]
|
||||
|
||||
inv[10] = m[0] * m[5] * m[15] -
|
||||
m[0] * m[7] * m[13] -
|
||||
m[4] * m[1] * m[15] +
|
||||
m[4] * m[3] * m[13] +
|
||||
m[12] * m[1] * m[7] -
|
||||
m[12] * m[3] * m[5]
|
||||
|
||||
inv[14] = -m[0] * m[5] * m[14] +
|
||||
m[0] * m[6] * m[13] +
|
||||
m[4] * m[1] * m[14] -
|
||||
m[4] * m[2] * m[13] -
|
||||
m[12] * m[1] * m[6] +
|
||||
m[12] * m[2] * m[5]
|
||||
|
||||
inv[3] = -m[1] * m[6] * m[11] +
|
||||
m[1] * m[7] * m[10] +
|
||||
m[5] * m[2] * m[11] -
|
||||
m[5] * m[3] * m[10] -
|
||||
m[9] * m[2] * m[7] +
|
||||
m[9] * m[3] * m[6]
|
||||
|
||||
inv[7] = m[0] * m[6] * m[11] -
|
||||
m[0] * m[7] * m[10] -
|
||||
m[4] * m[2] * m[11] +
|
||||
m[4] * m[3] * m[10] +
|
||||
m[8] * m[2] * m[7] -
|
||||
m[8] * m[3] * m[6]
|
||||
|
||||
inv[11] = -m[0] * m[5] * m[11] +
|
||||
m[0] * m[7] * m[9] +
|
||||
m[4] * m[1] * m[11] -
|
||||
m[4] * m[3] * m[9] -
|
||||
m[8] * m[1] * m[7] +
|
||||
m[8] * m[3] * m[5]
|
||||
|
||||
inv[15] = m[0] * m[5] * m[10] -
|
||||
m[0] * m[6] * m[9] -
|
||||
m[4] * m[1] * m[10] +
|
||||
m[4] * m[2] * m[9] +
|
||||
m[8] * m[1] * m[6] -
|
||||
m[8] * m[2] * m[5]
|
||||
|
||||
inv.forEach((v, i) => { inv[i] = v / det })
|
||||
this._values = inv
|
||||
return this
|
||||
}
|
||||
|
||||
setMatrixValue (transformList) {
|
||||
const temp = new DOMMatrix(transformList)
|
||||
this._values = temp._values
|
||||
this._is2D = temp._is2D
|
||||
return this
|
||||
}
|
||||
|
||||
transformPoint (point) {
|
||||
point = new DOMPoint(point)
|
||||
const x = point.x
|
||||
const y = point.y
|
||||
const z = point.z
|
||||
const w = point.w
|
||||
const values = this._values
|
||||
const nx = values[M11] * x + values[M21] * y + values[M31] * z + values[M41] * w
|
||||
const ny = values[M12] * x + values[M22] * y + values[M32] * z + values[M42] * w
|
||||
const nz = values[M13] * x + values[M23] * y + values[M33] * z + values[M43] * w
|
||||
const nw = values[M14] * x + values[M24] * y + values[M34] * z + values[M44] * w
|
||||
return new DOMPoint(nx, ny, nz, nw)
|
||||
}
|
||||
|
||||
toFloat32Array () {
|
||||
return Float32Array.from(this._values)
|
||||
}
|
||||
|
||||
toFloat64Array () {
|
||||
return this._values.slice(0)
|
||||
}
|
||||
|
||||
static fromMatrix (init) {
|
||||
if (!(init instanceof DOMMatrix)) throw new TypeError('Expected DOMMatrix')
|
||||
return new DOMMatrix(init._values)
|
||||
}
|
||||
|
||||
static fromFloat32Array (init) {
|
||||
if (!(init instanceof Float32Array)) throw new TypeError('Expected Float32Array')
|
||||
return new DOMMatrix(init)
|
||||
}
|
||||
|
||||
static fromFloat64Array (init) {
|
||||
if (!(init instanceof Float64Array)) throw new TypeError('Expected Float64Array')
|
||||
return new DOMMatrix(init)
|
||||
}
|
||||
|
||||
[util.inspect.custom || 'inspect'] (depth, options) {
|
||||
if (depth < 0) return '[DOMMatrix]'
|
||||
|
||||
return `DOMMatrix [
|
||||
a: ${this.a}
|
||||
b: ${this.b}
|
||||
c: ${this.c}
|
||||
d: ${this.d}
|
||||
e: ${this.e}
|
||||
f: ${this.f}
|
||||
m11: ${this.m11}
|
||||
m12: ${this.m12}
|
||||
m13: ${this.m13}
|
||||
m14: ${this.m14}
|
||||
m21: ${this.m21}
|
||||
m22: ${this.m22}
|
||||
m23: ${this.m23}
|
||||
m23: ${this.m23}
|
||||
m31: ${this.m31}
|
||||
m32: ${this.m32}
|
||||
m33: ${this.m33}
|
||||
m34: ${this.m34}
|
||||
m41: ${this.m41}
|
||||
m42: ${this.m42}
|
||||
m43: ${this.m43}
|
||||
m44: ${this.m44}
|
||||
is2D: ${this.is2D}
|
||||
isIdentity: ${this.isIdentity} ]`
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that `value` is a number and sets the value.
|
||||
*/
|
||||
function setNumber2D (receiver, index, value) {
|
||||
if (typeof value !== 'number') throw new TypeError('Expected number')
|
||||
return (receiver._values[index] = value)
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that `value` is a number, sets `_is2D = false` if necessary and sets
|
||||
* the value.
|
||||
*/
|
||||
function setNumber3D (receiver, index, value) {
|
||||
if (typeof value !== 'number') throw new TypeError('Expected number')
|
||||
if (index === M33 || index === M44) {
|
||||
if (value !== 1) receiver._is2D = false
|
||||
} else if (value !== 0) receiver._is2D = false
|
||||
return (receiver._values[index] = value)
|
||||
}
|
||||
|
||||
Object.defineProperties(DOMMatrix.prototype, {
|
||||
m11: { get () { return this._values[M11] }, set (v) { return setNumber2D(this, M11, v) } },
|
||||
m12: { get () { return this._values[M12] }, set (v) { return setNumber2D(this, M12, v) } },
|
||||
m13: { get () { return this._values[M13] }, set (v) { return setNumber3D(this, M13, v) } },
|
||||
m14: { get () { return this._values[M14] }, set (v) { return setNumber3D(this, M14, v) } },
|
||||
m21: { get () { return this._values[M21] }, set (v) { return setNumber2D(this, M21, v) } },
|
||||
m22: { get () { return this._values[M22] }, set (v) { return setNumber2D(this, M22, v) } },
|
||||
m23: { get () { return this._values[M23] }, set (v) { return setNumber3D(this, M23, v) } },
|
||||
m24: { get () { return this._values[M24] }, set (v) { return setNumber3D(this, M24, v) } },
|
||||
m31: { get () { return this._values[M31] }, set (v) { return setNumber3D(this, M31, v) } },
|
||||
m32: { get () { return this._values[M32] }, set (v) { return setNumber3D(this, M32, v) } },
|
||||
m33: { get () { return this._values[M33] }, set (v) { return setNumber3D(this, M33, v) } },
|
||||
m34: { get () { return this._values[M34] }, set (v) { return setNumber3D(this, M34, v) } },
|
||||
m41: { get () { return this._values[M41] }, set (v) { return setNumber2D(this, M41, v) } },
|
||||
m42: { get () { return this._values[M42] }, set (v) { return setNumber2D(this, M42, v) } },
|
||||
m43: { get () { return this._values[M43] }, set (v) { return setNumber3D(this, M43, v) } },
|
||||
m44: { get () { return this._values[M44] }, set (v) { return setNumber3D(this, M44, v) } },
|
||||
|
||||
a: { get () { return this.m11 }, set (v) { return (this.m11 = v) } },
|
||||
b: { get () { return this.m12 }, set (v) { return (this.m12 = v) } },
|
||||
c: { get () { return this.m21 }, set (v) { return (this.m21 = v) } },
|
||||
d: { get () { return this.m22 }, set (v) { return (this.m22 = v) } },
|
||||
e: { get () { return this.m41 }, set (v) { return (this.m41 = v) } },
|
||||
f: { get () { return this.m42 }, set (v) { return (this.m42 = v) } },
|
||||
|
||||
is2D: { get () { return this._is2D } }, // read-only
|
||||
|
||||
isIdentity: {
|
||||
get () {
|
||||
const values = this._values
|
||||
return (values[M11] === 1 && values[M12] === 0 && values[M13] === 0 && values[M14] === 0 &&
|
||||
values[M21] === 0 && values[M22] === 1 && values[M23] === 0 && values[M24] === 0 &&
|
||||
values[M31] === 0 && values[M32] === 0 && values[M33] === 1 && values[M34] === 0 &&
|
||||
values[M41] === 0 && values[M42] === 0 && values[M43] === 0 && values[M44] === 1)
|
||||
}
|
||||
},
|
||||
|
||||
toJSON: {
|
||||
value() {
|
||||
return {
|
||||
a: this.a,
|
||||
b: this.b,
|
||||
c: this.c,
|
||||
d: this.d,
|
||||
e: this.e,
|
||||
f: this.f,
|
||||
m11: this.m11,
|
||||
m12: this.m12,
|
||||
m13: this.m13,
|
||||
m14: this.m14,
|
||||
m21: this.m21,
|
||||
m22: this.m22,
|
||||
m23: this.m23,
|
||||
m23: this.m23,
|
||||
m31: this.m31,
|
||||
m32: this.m32,
|
||||
m33: this.m33,
|
||||
m34: this.m34,
|
||||
m41: this.m41,
|
||||
m42: this.m42,
|
||||
m43: this.m43,
|
||||
m44: this.m44,
|
||||
is2D: this.is2D,
|
||||
isIdentity: this.isIdentity,
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* Instantiates a DOMMatrix, bypassing the constructor.
|
||||
* @param {Float64Array} values Value to assign to `_values`. This is assigned
|
||||
* without copying (okay because all usages are followed by a multiply).
|
||||
*/
|
||||
function newInstance (values) {
|
||||
const instance = Object.create(DOMMatrix.prototype)
|
||||
instance.constructor = DOMMatrix
|
||||
instance._is2D = true
|
||||
instance._values = values
|
||||
return instance
|
||||
}
|
||||
|
||||
function multiply (A, B) {
|
||||
const dest = new Float64Array(16)
|
||||
for (let i = 0; i < 4; i++) {
|
||||
for (let j = 0; j < 4; j++) {
|
||||
let sum = 0
|
||||
for (let k = 0; k < 4; k++) {
|
||||
sum += A[i * 4 + k] * B[k * 4 + j]
|
||||
}
|
||||
dest[i * 4 + j] = sum
|
||||
}
|
||||
}
|
||||
return dest
|
||||
}
|
||||
|
||||
module.exports = { DOMMatrix, DOMPoint }
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"1":"A B","2":"K D E F mC"},B:{"1":"C L M G N O P","2":"0 9 Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I"},C:{"2":"0 1 2 3 4 5 6 7 8 9 nC LC J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC qC rC"},D:{"2":"0 1 2 3 4 5 6 7 8 9 J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC"},E:{"2":"J PB K D E F A B C L M G sC SC tC uC vC wC TC FC GC xC yC zC UC VC HC 0C IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C"},F:{"2":"0 1 2 3 4 5 6 7 8 F B C G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 4C 5C 6C 7C FC kC 8C GC"},G:{"2":"E SC 9C lC AD BD CD DD ED FD GD HD ID JD KD LD MD ND OD PD QD RD SD UC VC HC TD IC WC XC YC ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC"},H:{"2":"WD"},I:{"2":"LC J I XD YD ZD aD lC bD cD"},J:{"2":"D A"},K:{"2":"A B C H FC kC GC"},L:{"2":"I"},M:{"2":"EC"},N:{"1":"A B"},O:{"2":"HC"},P:{"2":"1 2 3 4 5 6 7 8 J dD eD fD gD hD TC iD jD kD lD mD IC JC KC nD"},Q:{"2":"oD"},R:{"2":"pD"},S:{"2":"qD rD"}},B:7,C:"Efficient Script Yielding: setImmediate()",D:true};
|
||||
Reference in New Issue
Block a user