Last commit july 5th

This commit is contained in:
2024-07-05 13:46:23 +02:00
parent dad0d86e8c
commit b0e4dfbb76
24982 changed files with 2621219 additions and 413 deletions

15
spa/node_modules/read-package-json-fast/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,15 @@
The ISC License
Copyright (c) npm, Inc. and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

79
spa/node_modules/read-package-json-fast/README.md generated vendored Normal file
View File

@@ -0,0 +1,79 @@
# read-package-json-fast
Like [`read-package-json`](http://npm.im/read-package-json), but faster and
more accepting of "missing" data.
This is only suitable for reading package.json files in a node_modules
tree, since it doesn't do the various cleanups, normalization, and warnings
that are beneficial at the root level in a package being published.
## USAGE
```js
const rpj = require('read-package-json-fast')
// typical promisey type API
rpj('/path/to/package.json')
.then(data => ...)
.catch(er => ...)
// or just normalize a package manifest
const normalized = rpj.normalize(packageJsonObject)
```
Errors raised from parsing will use
[`json-parse-even-better-errors`](http://npm.im/json-parse-even-better-errors),
so they'll be of type `JSONParseError` and have a `code: 'EJSONPARSE'`
property. Errors will also always have a `path` member referring to the
path originally passed into the function.
## Indentation
To preserve indentation when the file is saved back to disk, use
`data[Symbol.for('indent')]` as the third argument to `JSON.stringify`, and
if you want to preserve windows `\r\n` newlines, replace the `\n` chars in
the string with `data[Symbol.for('newline')]`.
For example:
```js
const data = await readPackageJsonFast('./package.json')
const indent = Symbol.for('indent')
const newline = Symbol.for('newline')
// .. do some stuff to the data ..
const string = JSON.stringify(data, null, data[indent]) + '\n'
const eolFixed = data[newline] === '\n' ? string
: string.replace(/\n/g, data[newline])
await writeFile('./package.json', eolFixed)
```
Indentation is determined by looking at the whitespace between the initial
`{` and the first `"` that follows it. If you have lots of weird
inconsistent indentation, then it won't track that or give you any way to
preserve it. Whether this is a bug or a feature is debatable ;)
## WHAT THIS MODULE DOES
- Parse JSON
- Normalize `bundledDependencies`/`bundleDependencies` naming to just
`bundleDependencies` (without the extra `d`)
- Handle `true`, `false`, or object values passed to `bundleDependencies`
- Normalize `funding: <string>` to `funding: { url: <string> }`
- Remove any `scripts` members that are not a string value.
- Normalize a string `bin` member to `{ [name]: bin }`.
- Fold `optionalDependencies` into `dependencies`.
- Set the `_id` property if name and version are set. (This is
load-bearing in a few places within the npm CLI.)
## WHAT THIS MODULE DOES NOT DO
- Warn about invalid/missing name, version, repository, etc.
- Extract a description from the `README.md` file, or attach the readme to
the parsed data object.
- Read the `HEAD` value out of the `.git` folder.
- Warn about potentially typo'ed scripts (eg, `tset` instead of `test`)
- Check to make sure that all the files in the `files` field exist and are
valid files.
- Fix bundleDependencies that are not listed in `dependencies`.
- Fix `dependencies` fields that are not strictly objects of string values.
- Anything involving the `directories` field (ie, bins, mans, and so on).

141
spa/node_modules/read-package-json-fast/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,141 @@
const { readFile, lstat, readdir } = require('fs/promises')
const parse = require('json-parse-even-better-errors')
const normalizePackageBin = require('npm-normalize-package-bin')
const { resolve, dirname, join, relative } = require('path')
const rpj = path => readFile(path, 'utf8')
.then(data => readBinDir(path, normalize(stripUnderscores(parse(data)))))
.catch(er => {
er.path = path
throw er
})
// load the directories.bin folder as a 'bin' object
const readBinDir = async (path, data) => {
if (data.bin) {
return data
}
const m = data.directories && data.directories.bin
if (!m || typeof m !== 'string') {
return data
}
// cut off any monkey business, like setting directories.bin
// to ../../../etc/passwd or /etc/passwd or something like that.
const root = dirname(path)
const dir = join('.', join('/', m))
data.bin = await walkBinDir(root, dir, {})
return data
}
const walkBinDir = async (root, dir, obj) => {
const entries = await readdir(resolve(root, dir)).catch(() => [])
for (const entry of entries) {
if (entry.charAt(0) === '.') {
continue
}
const f = resolve(root, dir, entry)
// ignore stat errors, weird file types, symlinks, etc.
const st = await lstat(f).catch(() => null)
if (!st) {
continue
} else if (st.isFile()) {
obj[entry] = relative(root, f)
} else if (st.isDirectory()) {
await walkBinDir(root, join(dir, entry), obj)
}
}
return obj
}
// do not preserve _fields set in files, they are sus
const stripUnderscores = data => {
for (const key of Object.keys(data).filter(k => /^_/.test(k))) {
delete data[key]
}
return data
}
const normalize = data => {
addId(data)
fixBundled(data)
pruneRepeatedOptionals(data)
fixScripts(data)
fixFunding(data)
normalizePackageBin(data)
return data
}
rpj.normalize = normalize
const addId = data => {
if (data.name && data.version) {
data._id = `${data.name}@${data.version}`
}
return data
}
// it was once common practice to list deps both in optionalDependencies
// and in dependencies, to support npm versions that did not know abbout
// optionalDependencies. This is no longer a relevant need, so duplicating
// the deps in two places is unnecessary and excessive.
const pruneRepeatedOptionals = data => {
const od = data.optionalDependencies
const dd = data.dependencies || {}
if (od && typeof od === 'object') {
for (const name of Object.keys(od)) {
delete dd[name]
}
}
if (Object.keys(dd).length === 0) {
delete data.dependencies
}
return data
}
const fixBundled = data => {
const bdd = data.bundledDependencies
const bd = data.bundleDependencies === undefined ? bdd
: data.bundleDependencies
if (bd === false) {
data.bundleDependencies = []
} else if (bd === true) {
data.bundleDependencies = Object.keys(data.dependencies || {})
} else if (bd && typeof bd === 'object') {
if (!Array.isArray(bd)) {
data.bundleDependencies = Object.keys(bd)
} else {
data.bundleDependencies = bd
}
} else {
delete data.bundleDependencies
}
delete data.bundledDependencies
return data
}
const fixScripts = data => {
if (!data.scripts || typeof data.scripts !== 'object') {
delete data.scripts
return data
}
for (const [name, script] of Object.entries(data.scripts)) {
if (typeof script !== 'string') {
delete data.scripts[name]
}
}
return data
}
const fixFunding = data => {
if (data.funding && typeof data.funding === 'string') {
data.funding = { url: data.funding }
}
return data
}
module.exports = rpj

View File

@@ -0,0 +1,25 @@
Copyright 2017 Kat Marchán
Copyright npm, Inc.
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.
---
This library is a fork of 'better-json-errors' by Kat Marchán, extended and
distributed under the terms of the MIT license above.

View File

@@ -0,0 +1,96 @@
# json-parse-even-better-errors
[`json-parse-even-better-errors`](https://github.com/npm/json-parse-even-better-errors)
is a Node.js library for getting nicer errors out of `JSON.parse()`,
including context and position of the parse errors.
It also preserves the newline and indentation styles of the JSON data, by
putting them in the object or array in the `Symbol.for('indent')` and
`Symbol.for('newline')` properties.
## Install
`$ npm install --save json-parse-even-better-errors`
## Table of Contents
* [Example](#example)
* [Features](#features)
* [Contributing](#contributing)
* [API](#api)
* [`parse`](#parse)
### Example
```javascript
const parseJson = require('json-parse-even-better-errors')
parseJson('"foo"') // returns the string 'foo'
parseJson('garbage') // more useful error message
parseJson.noExceptions('garbage') // returns undefined
```
### Features
* Like JSON.parse, but the errors are better.
* Strips a leading byte-order-mark that you sometimes get reading files.
* Has a `noExceptions` method that returns undefined rather than throwing.
* Attaches the newline character(s) used to the `Symbol.for('newline')`
property on objects and arrays.
* Attaches the indentation character(s) used to the `Symbol.for('indent')`
property on objects and arrays.
## Indentation
To preserve indentation when the file is saved back to disk, use
`data[Symbol.for('indent')]` as the third argument to `JSON.stringify`, and
if you want to preserve windows `\r\n` newlines, replace the `\n` chars in
the string with `data[Symbol.for('newline')]`.
For example:
```js
const txt = await readFile('./package.json', 'utf8')
const data = parseJsonEvenBetterErrors(txt)
const indent = Symbol.for('indent')
const newline = Symbol.for('newline')
// .. do some stuff to the data ..
const string = JSON.stringify(data, null, data[indent]) + '\n'
const eolFixed = data[newline] === '\n' ? string
: string.replace(/\n/g, data[newline])
await writeFile('./package.json', eolFixed)
```
Indentation is determined by looking at the whitespace between the initial
`{` and `[` and the character that follows it. If you have lots of weird
inconsistent indentation, then it won't track that or give you any way to
preserve it. Whether this is a bug or a feature is debatable ;)
### API
#### <a name="parse"></a> `parse(txt, reviver = null, context = 20)`
Works just like `JSON.parse`, but will include a bit more information when
an error happens, and attaches a `Symbol.for('indent')` and
`Symbol.for('newline')` on objects and arrays. This throws a
`JSONParseError`.
#### <a name="parse"></a> `parse.noExceptions(txt, reviver = null)`
Works just like `JSON.parse`, but will return `undefined` rather than
throwing an error.
#### <a name="jsonparseerror"></a> `class JSONParseError(er, text, context = 20, caller = null)`
Extends the JavaScript `SyntaxError` class to parse the message and provide
better metadata.
Pass in the error thrown by the built-in `JSON.parse`, and the text being
parsed, and it'll parse out the bits needed to be helpful.
`context` defaults to 20.
Set a `caller` function to trim internal implementation details out of the
stack trace. When calling `parseJson`, this is set to the `parseJson`
function. If not set, then the constructor defaults to itself, so the
stack trace will point to the spot where you call `new JSONParseError`.

View File

@@ -0,0 +1,137 @@
'use strict'
const INDENT = Symbol.for('indent')
const NEWLINE = Symbol.for('newline')
const DEFAULT_NEWLINE = '\n'
const DEFAULT_INDENT = ' '
const BOM = /^\uFEFF/
// only respect indentation if we got a line break, otherwise squash it
// things other than objects and arrays aren't indented, so ignore those
// Important: in both of these regexps, the $1 capture group is the newline
// or undefined, and the $2 capture group is the indent, or undefined.
const FORMAT = /^\s*[{[]((?:\r?\n)+)([\s\t]*)/
const EMPTY = /^(?:\{\}|\[\])((?:\r?\n)+)?$/
// Node 20 puts single quotes around the token and a comma after it
const UNEXPECTED_TOKEN = /^Unexpected token '?(.)'?(,)? /i
const hexify = (char) => {
const h = char.charCodeAt(0).toString(16).toUpperCase()
return `0x${h.length % 2 ? '0' : ''}${h}`
}
// Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
// because the buffer-to-string conversion in `fs.readFileSync()`
// translates it to FEFF, the UTF-16 BOM.
const stripBOM = (txt) => String(txt).replace(BOM, '')
const makeParsedError = (msg, parsing, position = 0) => ({
message: `${msg} while parsing ${parsing}`,
position,
})
const parseError = (e, txt, context = 20) => {
let msg = e.message
if (!txt) {
return makeParsedError(msg, 'empty string')
}
const badTokenMatch = msg.match(UNEXPECTED_TOKEN)
const badIndexMatch = msg.match(/ position\s+(\d+)/i)
if (badTokenMatch) {
msg = msg.replace(
UNEXPECTED_TOKEN,
`Unexpected token ${JSON.stringify(badTokenMatch[1])} (${hexify(badTokenMatch[1])})$2 `
)
}
let errIdx
if (badIndexMatch) {
errIdx = +badIndexMatch[1]
} else /* istanbul ignore next - doesnt happen in Node 22 */ if (
msg.match(/^Unexpected end of JSON.*/i)
) {
errIdx = txt.length - 1
}
if (errIdx == null) {
return makeParsedError(msg, `'${txt.slice(0, context * 2)}'`)
}
const start = errIdx <= context ? 0 : errIdx - context
const end = errIdx + context >= txt.length ? txt.length : errIdx + context
const slice = `${start ? '...' : ''}${txt.slice(start, end)}${end === txt.length ? '' : '...'}`
return makeParsedError(
msg,
`${txt === slice ? '' : 'near '}${JSON.stringify(slice)}`,
errIdx
)
}
class JSONParseError extends SyntaxError {
constructor (er, txt, context, caller) {
const metadata = parseError(er, txt, context)
super(metadata.message)
Object.assign(this, metadata)
this.code = 'EJSONPARSE'
this.systemError = er
Error.captureStackTrace(this, caller || this.constructor)
}
get name () {
return this.constructor.name
}
set name (n) {}
get [Symbol.toStringTag] () {
return this.constructor.name
}
}
const parseJson = (txt, reviver) => {
const result = JSON.parse(txt, reviver)
if (result && typeof result === 'object') {
// get the indentation so that we can save it back nicely
// if the file starts with {" then we have an indent of '', ie, none
// otherwise, pick the indentation of the next line after the first \n If the
// pattern doesn't match, then it means no indentation. JSON.stringify ignores
// symbols, so this is reasonably safe. if the string is '{}' or '[]', then
// use the default 2-space indent.
const match = txt.match(EMPTY) || txt.match(FORMAT) || [null, '', '']
result[NEWLINE] = match[1] ?? DEFAULT_NEWLINE
result[INDENT] = match[2] ?? DEFAULT_INDENT
}
return result
}
const parseJsonError = (raw, reviver, context) => {
const txt = stripBOM(raw)
try {
return parseJson(txt, reviver)
} catch (e) {
if (typeof raw !== 'string' && !Buffer.isBuffer(raw)) {
const msg = Array.isArray(raw) && raw.length === 0 ? 'an empty array' : String(raw)
throw Object.assign(
new TypeError(`Cannot parse ${msg}`),
{ code: 'EJSONPARSE', systemError: e }
)
}
throw new JSONParseError(e, txt, context, parseJsonError)
}
}
module.exports = parseJsonError
parseJsonError.JSONParseError = JSONParseError
parseJsonError.noExceptions = (raw, reviver) => {
try {
return parseJson(stripBOM(raw), reviver)
} catch {
// no exceptions
}
}

View File

@@ -0,0 +1,49 @@
{
"name": "json-parse-even-better-errors",
"version": "3.0.2",
"description": "JSON.parse with context information on error",
"main": "lib/index.js",
"files": [
"bin/",
"lib/"
],
"scripts": {
"test": "tap",
"snap": "tap",
"lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
"postlint": "template-oss-check",
"template-oss-apply": "template-oss-apply --force",
"lintfix": "npm run lint -- --fix",
"posttest": "npm run lint"
},
"repository": {
"type": "git",
"url": "git+https://github.com/npm/json-parse-even-better-errors.git"
},
"keywords": [
"JSON",
"parser"
],
"author": "GitHub Inc.",
"license": "MIT",
"devDependencies": {
"@npmcli/eslint-config": "^4.0.0",
"@npmcli/template-oss": "4.22.0",
"tap": "^16.3.0"
},
"tap": {
"check-coverage": true,
"nyc-arg": [
"--exclude",
"tap-snapshots/**"
]
},
"engines": {
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "4.22.0",
"publish": true
}
}

47
spa/node_modules/read-package-json-fast/package.json generated vendored Normal file
View File

@@ -0,0 +1,47 @@
{
"name": "read-package-json-fast",
"version": "3.0.2",
"description": "Like read-package-json, but faster",
"main": "lib/index.js",
"author": "GitHub Inc.",
"license": "ISC",
"scripts": {
"test": "tap",
"snap": "tap",
"lint": "eslint \"**/*.js\"",
"postlint": "template-oss-check",
"template-oss-apply": "template-oss-apply --force",
"lintfix": "npm run lint -- --fix",
"posttest": "npm run lint"
},
"engines": {
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
},
"devDependencies": {
"@npmcli/eslint-config": "^4.0.0",
"@npmcli/template-oss": "4.11.0",
"tap": "^16.3.0"
},
"dependencies": {
"json-parse-even-better-errors": "^3.0.0",
"npm-normalize-package-bin": "^3.0.0"
},
"repository": {
"type": "git",
"url": "https://github.com/npm/read-package-json-fast.git"
},
"files": [
"bin/",
"lib/"
],
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "4.11.0"
},
"tap": {
"nyc-arg": [
"--exclude",
"tap-snapshots/**"
]
}
}