Add: node_modules

This commit is contained in:
Cutls
2019-09-12 23:38:13 +09:00
parent 4769c83958
commit 25a1db84a4
7934 changed files with 956263 additions and 1 deletions

21
app/node_modules/parse-bmfont-xml/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015 Matt DesLauriers
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.

74
app/node_modules/parse-bmfont-xml/README.md generated vendored Normal file
View File

@@ -0,0 +1,74 @@
# parse-bmfont-xml
[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)
Parses XML [BMFont files](http://www.angelcode.com/products/bmfont/).
Takes a string or Buffer:
```js
var fs = require('fs')
var parse = require('parse-bmfont-xml')
fs.readFileSync(__dirname+'/Arial.fnt', function(err, data) {
var result = parse(data)
console.log(result.info.face) // "Arial"
console.log(result.pages) // [ 'sheet0.png' ]
console.log(result.chars) // [ ... char data ... ]
console.log(result.kernings) // [ ... kernings data ... ]
})
```
Also works in the browser, for example using XHR:
```js
var parse = require('parse-bmfont-xml')
var xhr = require('xhr')
xhr({ uri: 'fonts/NexaLight32.xml' }, function(err, res, body) {
if (err)
throw err
var result = parse(body)
console.log(result.info.face)
})
```
The spec for the returned JSON object is [here](https://github.com/mattdesl/bmfont2json/wiki/JsonSpec). The input XML should match the spec with a `<font>` root element, see [test/Nexa Light-32.fnt](test/Nexa Light-32.fnt) for an example.
## See Also
See [text-modules](https://github.com/mattdesl/text-modules) for related modules.
## Usage
[![NPM](https://nodei.co/npm/parse-bmfont-xml.png)](https://www.npmjs.com/package/parse-bmfont-xml)
#### `result = parse(data)`
Parses `data`, a string or Buffer that represents XML data of an AngelCode BMFont file. The returned `result` object looks like this:
```js
{
pages: [
"sheet_0.png",
"sheet_1.png"
],
chars: [
{ chnl, height, id, page, width, x, y, xoffset, yoffset, xadvance },
...
],
info: { ... },
common: { ... },
kernings: [
{ first, second, amount }
]
}
```
If the data is malformed, an error will be thrown.
The browser implementation relies on [xml-parse-from-string](https://github.com/Jam3/xml-parse-from-string), which may not work in environments without valid DOM APIs (like CocoonJS).
## License
MIT, see [LICENSE.md](http://github.com/mattdesl/parse-bmfont-xml/blob/master/LICENSE.md) for details.

85
app/node_modules/parse-bmfont-xml/lib/browser.js generated vendored Normal file
View File

@@ -0,0 +1,85 @@
var parseAttributes = require('./parse-attribs')
var parseFromString = require('xml-parse-from-string')
//In some cases element.attribute.nodeName can return
//all lowercase values.. so we need to map them to the correct
//case
var NAME_MAP = {
scaleh: 'scaleH',
scalew: 'scaleW',
stretchh: 'stretchH',
lineheight: 'lineHeight',
alphachnl: 'alphaChnl',
redchnl: 'redChnl',
greenchnl: 'greenChnl',
bluechnl: 'blueChnl'
}
module.exports = function parse(data) {
data = data.toString()
var xmlRoot = parseFromString(data)
var output = {
pages: [],
chars: [],
kernings: []
}
//get config settings
;['info', 'common'].forEach(function(key) {
var element = xmlRoot.getElementsByTagName(key)[0]
if (element)
output[key] = parseAttributes(getAttribs(element))
})
//get page info
var pageRoot = xmlRoot.getElementsByTagName('pages')[0]
if (!pageRoot)
throw new Error('malformed file -- no <pages> element')
var pages = pageRoot.getElementsByTagName('page')
for (var i=0; i<pages.length; i++) {
var p = pages[i]
var id = parseInt(p.getAttribute('id'), 10)
var file = p.getAttribute('file')
if (isNaN(id))
throw new Error('malformed file -- page "id" attribute is NaN')
if (!file)
throw new Error('malformed file -- needs page "file" attribute')
output.pages[parseInt(id, 10)] = file
}
//get kernings / chars
;['chars', 'kernings'].forEach(function(key) {
var element = xmlRoot.getElementsByTagName(key)[0]
if (!element)
return
var childTag = key.substring(0, key.length-1)
var children = element.getElementsByTagName(childTag)
for (var i=0; i<children.length; i++) {
var child = children[i]
output[key].push(parseAttributes(getAttribs(child)))
}
})
return output
}
function getAttribs(element) {
var attribs = getAttribList(element)
return attribs.reduce(function(dict, attrib) {
var key = mapName(attrib.nodeName)
dict[key] = attrib.nodeValue
return dict
}, {})
}
function getAttribList(element) {
//IE8+ and modern browsers
var attribs = []
for (var i=0; i<element.attributes.length; i++)
attribs.push(element.attributes[i])
return attribs
}
function mapName(nodeName) {
return NAME_MAP[nodeName.toLowerCase()] || nodeName
}

49
app/node_modules/parse-bmfont-xml/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,49 @@
var xml2js = require('xml2js')
var parseAttributes = require('./parse-attribs')
module.exports = function parseBMFontXML(data) {
data = data.toString().trim()
var output = {
pages: [],
chars: [],
kernings: []
}
xml2js.parseString(data, function(err, result) {
if (err)
throw err
if (!result.font)
throw "XML bitmap font doesn't have <font> root"
result = result.font
output.common = parseAttributes(result.common[0].$)
output.info = parseAttributes(result.info[0].$)
for (var i = 0; i < result.pages.length; i++) {
var p = result.pages[i].page[0].$
if (typeof p.id === "undefined")
throw new Error("malformed file -- needs page id=N")
if (typeof p.file !== "string")
throw new Error("malformed file -- needs page file=\"path\"")
output.pages[parseInt(p.id, 10)] = p.file
}
if (result.chars) {
var chrArray = result.chars[0]['char'] || []
for (var i = 0; i < chrArray.length; i++) {
output.chars.push(parseAttributes(chrArray[i].$))
}
}
if (result.kernings) {
var kernArray = result.kernings[0]['kerning'] || []
for (var i = 0; i < kernArray.length; i++) {
output.kernings.push(parseAttributes(kernArray[i].$))
}
}
})
return output
}

28
app/node_modules/parse-bmfont-xml/lib/parse-attribs.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
//Some versions of GlyphDesigner have a typo
//that causes some bugs with parsing.
//Need to confirm with recent version of the software
//to see whether this is still an issue or not.
var GLYPH_DESIGNER_ERROR = 'chasrset'
module.exports = function parseAttributes(obj) {
if (GLYPH_DESIGNER_ERROR in obj) {
obj['charset'] = obj[GLYPH_DESIGNER_ERROR]
delete obj[GLYPH_DESIGNER_ERROR]
}
for (var k in obj) {
if (k === 'face' || k === 'charset')
continue
else if (k === 'padding' || k === 'spacing')
obj[k] = parseIntList(obj[k])
else
obj[k] = parseInt(obj[k], 10)
}
return obj
}
function parseIntList(data) {
return data.split(',').map(function(val) {
return parseInt(val, 10)
})
}

84
app/node_modules/parse-bmfont-xml/package.json generated vendored Normal file
View File

@@ -0,0 +1,84 @@
{
"_args": [
[
"parse-bmfont-xml@1.1.4",
"C:\\Users\\ryuki\\TheDesk\\app"
]
],
"_from": "parse-bmfont-xml@1.1.4",
"_id": "parse-bmfont-xml@1.1.4",
"_inBundle": false,
"_integrity": "sha512-bjnliEOmGv3y1aMEfREMBJ9tfL3WR0i0CKPj61DnSLaoxWR3nLrsQrEbCId/8rF4NyRF0cCqisSVXyQYWM+mCQ==",
"_location": "/parse-bmfont-xml",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "parse-bmfont-xml@1.1.4",
"name": "parse-bmfont-xml",
"escapedName": "parse-bmfont-xml",
"rawSpec": "1.1.4",
"saveSpec": null,
"fetchSpec": "1.1.4"
},
"_requiredBy": [
"/load-bmfont"
],
"_resolved": "https://registry.npmjs.org/parse-bmfont-xml/-/parse-bmfont-xml-1.1.4.tgz",
"_spec": "1.1.4",
"_where": "C:\\Users\\ryuki\\TheDesk\\app",
"author": {
"name": "Matt DesLauriers",
"email": "dave.des@gmail.com",
"url": "https://github.com/mattdesl"
},
"browser": "lib/browser.js",
"bugs": {
"url": "https://github.com/mattdesl/parse-bmfont-xml/issues"
},
"dependencies": {
"xml-parse-from-string": "^1.0.0",
"xml2js": "^0.4.5"
},
"description": "parses XML BMFont files into a JavaScript object",
"devDependencies": {
"brfs": "^1.4.0",
"browserify": "^9.0.3",
"faucet": "0.0.1",
"tape": "^3.5.0",
"testling": "^1.7.1",
"xhr": "^2.0.1"
},
"homepage": "https://github.com/mattdesl/parse-bmfont-xml",
"keywords": [
"xml",
"parse",
"convert",
"bmfont",
"bm",
"bitmap",
"font",
"bitmaps",
"angel",
"angelcode",
"code",
"text",
"gl",
"sprite",
"sprites",
"stackgl"
],
"license": "MIT",
"main": "lib/index.js",
"name": "parse-bmfont-xml",
"repository": {
"type": "git",
"url": "git://github.com/mattdesl/parse-bmfont-xml.git"
},
"scripts": {
"test": "npm run test-node && npm run test-browser",
"test-browser": "browserify test/test-browser.js -t brfs | testling | faucet",
"test-node": "node test/test.js | faucet"
},
"version": "1.1.4"
}