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

20
spa/node_modules/parse-conflict-json/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,20 @@
<!-- This file is automatically added by @npmcli/template-oss. Do not edit. -->
ISC License
Copyright npm, Inc.
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 NPM DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
EVENT SHALL NPM 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.

42
spa/node_modules/parse-conflict-json/README.md generated vendored Normal file
View File

@@ -0,0 +1,42 @@
# parse-conflict-json
Parse a JSON string that has git merge conflicts, resolving if possible.
If the JSON is valid, it just does `JSON.parse` as normal.
If either side of the conflict is invalid JSON, then an error is thrown for
that.
## USAGE
```js
// after a git merge that left some conflicts there
const data = fs.readFileSync('package-lock.json', 'utf8')
// reviverFunction is passed to JSON.parse as the reviver function
// preference defaults to 'ours', set to 'theirs' to prefer the other
// side's changes.
const parsed = parseConflictJson(data, reviverFunction, preference)
// returns true if the data looks like a conflicted diff file
parsed.isDiff(data)
```
## Algorithm
If `prefer` is set to `theirs`, then the vaules of `theirs` and `ours` are
switched in the resolver function. (Ie, we'll apply their changes on top
of our object, rather than the other way around.)
- Parse the conflicted file into 3 pieces: `ours`, `theirs`, and `parent`
- Get the [diff](https://github.com/angus-c/just#just-diff) from `parent`
to `ours`.
- [Apply](https://github.com/angus-c/just#just-diff-apply) each change of
that diff to `theirs`.
If any change in the diff set cannot be applied (ie, because they
changed an object into a non-object and we changed a field on that
object), then replace the object at the specified path with the object
at the path in `ours`.

104
spa/node_modules/parse-conflict-json/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,104 @@
const parseJSON = require('json-parse-even-better-errors')
const { diff } = require('just-diff')
const { diffApply } = require('just-diff-apply')
const globalObjectProperties = Object.getOwnPropertyNames(Object.prototype)
const stripBOM = content => {
content = content.toString()
// 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.
if (content.charCodeAt(0) === 0xFEFF) {
content = content.slice(1)
}
return content
}
const PARENT_RE = /\|{7,}/g
const OURS_RE = /<{7,}/g
const THEIRS_RE = /={7,}/g
const END_RE = />{7,}/g
const isDiff = str =>
str.match(OURS_RE) && str.match(THEIRS_RE) && str.match(END_RE)
const parseConflictJSON = (str, reviver, prefer) => {
prefer = prefer || 'ours'
if (prefer !== 'theirs' && prefer !== 'ours') {
throw new TypeError('prefer param must be "ours" or "theirs" if set')
}
str = stripBOM(str)
if (!isDiff(str)) {
return parseJSON(str)
}
const pieces = str.split(/[\n\r]+/g).reduce((acc, line) => {
if (line.match(PARENT_RE)) {
acc.state = 'parent'
} else if (line.match(OURS_RE)) {
acc.state = 'ours'
} else if (line.match(THEIRS_RE)) {
acc.state = 'theirs'
} else if (line.match(END_RE)) {
acc.state = 'top'
} else {
if (acc.state === 'top' || acc.state === 'ours') {
acc.ours += line
}
if (acc.state === 'top' || acc.state === 'theirs') {
acc.theirs += line
}
if (acc.state === 'top' || acc.state === 'parent') {
acc.parent += line
}
}
return acc
}, {
state: 'top',
ours: '',
theirs: '',
parent: '',
})
// this will throw if either piece is not valid JSON, that's intended
const parent = parseJSON(pieces.parent, reviver)
const ours = parseJSON(pieces.ours, reviver)
const theirs = parseJSON(pieces.theirs, reviver)
return prefer === 'ours'
? resolve(parent, ours, theirs)
: resolve(parent, theirs, ours)
}
const isObj = obj => obj && typeof obj === 'object'
const copyPath = (to, from, path, i) => {
const p = path[i]
if (isObj(to[p]) && isObj(from[p]) &&
Array.isArray(to[p]) === Array.isArray(from[p])) {
return copyPath(to[p], from[p], path, i + 1)
}
to[p] = from[p]
}
// get the diff from parent->ours and applying our changes on top of theirs.
// If they turned an object into a non-object, then put it back.
const resolve = (parent, ours, theirs) => {
const dours = diff(parent, ours)
for (let i = 0; i < dours.length; i++) {
if (globalObjectProperties.find(prop => dours[i].path.includes(prop))) {
continue
}
try {
diffApply(theirs, [dours[i]])
} catch (e) {
copyPath(theirs, ours, dours[i].path, 0)
}
}
return theirs
}
module.exports = Object.assign(parseConflictJSON, { isDiff })

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
}
}

49
spa/node_modules/parse-conflict-json/package.json generated vendored Normal file
View File

@@ -0,0 +1,49 @@
{
"name": "parse-conflict-json",
"version": "3.0.1",
"description": "Parse a JSON string that has git merge conflicts, resolving if possible",
"author": "GitHub Inc.",
"license": "ISC",
"main": "lib",
"scripts": {
"test": "tap",
"snap": "tap",
"lint": "eslint \"**/*.js\"",
"postlint": "template-oss-check",
"lintfix": "npm run lint -- --fix",
"posttest": "npm run lint",
"template-oss-apply": "template-oss-apply --force"
},
"tap": {
"check-coverage": true,
"nyc-arg": [
"--exclude",
"tap-snapshots/**"
]
},
"devDependencies": {
"@npmcli/eslint-config": "^4.0.0",
"@npmcli/template-oss": "4.12.0",
"tap": "^16.0.1"
},
"dependencies": {
"json-parse-even-better-errors": "^3.0.0",
"just-diff": "^6.0.0",
"just-diff-apply": "^5.2.0"
},
"repository": {
"type": "git",
"url": "https://github.com/npm/parse-conflict-json.git"
},
"files": [
"bin/",
"lib/"
],
"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.12.0"
}
}