Initial commit

This commit is contained in:
2024-11-03 17:41:45 +01:00
commit c1640c1754
8043 changed files with 775536 additions and 0 deletions

246
node_modules/@sindresorhus/slugify/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,246 @@
export interface Options {
/**
@default '-'
@example
```
import slugify from '@sindresorhus/slugify';
slugify('BAR and baz');
//=> 'bar-and-baz'
slugify('BAR and baz', {separator: '_'});
//=> 'bar_and_baz'
slugify('BAR and baz', {separator: ''});
//=> 'barandbaz'
```
*/
readonly separator?: string;
/**
Make the slug lowercase.
@default true
@example
```
import slugify from '@sindresorhus/slugify';
slugify('Déjà Vu!');
//=> 'deja-vu'
slugify('Déjà Vu!', {lowercase: false});
//=> 'Deja-Vu'
```
*/
readonly lowercase?: boolean;
/**
Convert camelcase to separate words. Internally it does `fooBar` → `foo bar`.
@default true
@example
```
import slugify from '@sindresorhus/slugify';
slugify('fooBar');
//=> 'foo-bar'
slugify('fooBar', {decamelize: false});
//=> 'foobar'
```
*/
readonly decamelize?: boolean;
/**
Add your own custom replacements.
The replacements are run on the original string before any other transformations.
This only overrides a default replacement if you set an item with the same key, like `&`.
Add a leading and trailing space to the replacement to have it separated by dashes.
@default [ ['&', ' and '], ['🦄', ' unicorn '], ['♥', ' love '] ]
@example
```
import slugify from '@sindresorhus/slugify';
slugify('Foo@unicorn', {
customReplacements: [
['@', 'at']
]
});
//=> 'fooatunicorn'
slugify('foo@unicorn', {
customReplacements: [
['@', ' at ']
]
});
//=> 'foo-at-unicorn'
slugify('I love 🐶', {
customReplacements: [
['🐶', 'dogs']
]
});
//=> 'i-love-dogs'
```
*/
readonly customReplacements?: ReadonlyArray<[string, string]>;
/**
If your string starts with an underscore, it will be preserved in the slugified string.
Sometimes leading underscores are intentional, for example, filenames representing hidden paths on a website.
@default false
@example
```
import slugify from '@sindresorhus/slugify';
slugify('_foo_bar');
//=> 'foo-bar'
slugify('_foo_bar', {preserveLeadingUnderscore: true});
//=> '_foo-bar'
```
*/
readonly preserveLeadingUnderscore?: boolean;
/**
If your string ends with a dash, it will be preserved in the slugified string.
For example, using slugify on an input field would allow for validation while not preventing the user from writing a slug.
@default false
@example
```
import slugify from '@sindresorhus/slugify';
slugify('foo-bar-');
//=> 'foo-bar'
slugify('foo-bar-', {preserveTrailingDash: true});
//=> 'foo-bar-'
```
*/
readonly preserveTrailingDash?: boolean;
/**
Preserve certain characters.
It cannot contain the `separator`.
For example, if you want to slugify URLs, but preserve the HTML fragment `#` character, you could set `preserveCharacters: ['#']`.
@default []
@example
```
import slugify from '@sindresorhus/slugify';
slugify('foo_bar#baz', {preserveCharacters: ['#']});
//=> 'foo-bar#baz'
```
*/
readonly preserveCharacters?: string[];
}
/**
Slugify a string.
@param string - String to slugify.
@example
```
import slugify from '@sindresorhus/slugify';
slugify('I ♥ Dogs');
//=> 'i-love-dogs'
slugify(' Déjà Vu! ');
//=> 'deja-vu'
slugify('fooBar 123 $#%');
//=> 'foo-bar-123'
slugify('я люблю единорогов');
//=> 'ya-lyublyu-edinorogov'
```
*/
export default function slugify(string: string, options?: Options): string;
export interface CountableSlugify {
/**
Reset the counter.
@example
```
import {slugifyWithCounter} from '@sindresorhus/slugify';
const slugify = slugifyWithCounter();
slugify('foo bar');
//=> 'foo-bar'
slugify('foo bar');
//=> 'foo-bar-2'
slugify.reset();
slugify('foo bar');
//=> 'foo-bar'
```
*/
reset: () => void;
/**
Returns a new instance of `slugify(string, options?)` with a counter to handle multiple occurrences of the same string.
@param string - String to slugify.
@example
```
import {slugifyWithCounter} from '@sindresorhus/slugify';
const slugify = slugifyWithCounter();
slugify('foo bar');
//=> 'foo-bar'
slugify('foo bar');
//=> 'foo-bar-2'
slugify.reset();
slugify('foo bar');
//=> 'foo-bar'
```
__Use case example of counter__
If, for example, you have a document with multiple sections where each subsection has an example.
```
## Section 1
### Example
## Section 2
### Example
```
You can then use `slugifyWithCounter()` to generate unique HTML `id`'s to ensure anchors will link to the right headline.
*/
(string: string, options?: Options): string;
}
export function slugifyWithCounter(): CountableSlugify;

127
node_modules/@sindresorhus/slugify/index.js generated vendored Normal file
View File

@@ -0,0 +1,127 @@
import escapeStringRegexp from 'escape-string-regexp';
import transliterate from '@sindresorhus/transliterate';
import builtinOverridableReplacements from './overridable-replacements.js';
const decamelize = string => {
return string
// Separate capitalized words.
.replace(/([A-Z]{2,})(\d+)/g, '$1 $2')
.replace(/([a-z\d]+)([A-Z]{2,})/g, '$1 $2')
.replace(/([a-z\d])([A-Z])/g, '$1 $2')
// `[a-rt-z]` matches all lowercase characters except `s`.
// This avoids matching plural acronyms like `APIs`.
.replace(/([A-Z]+)([A-Z][a-rt-z\d]+)/g, '$1 $2');
};
const removeMootSeparators = (string, separator) => {
const escapedSeparator = escapeStringRegexp(separator);
return string
.replace(new RegExp(`${escapedSeparator}{2,}`, 'g'), separator)
.replace(new RegExp(`^${escapedSeparator}|${escapedSeparator}$`, 'g'), '');
};
const buildPatternSlug = options => {
let negationSetPattern = 'a-z\\d';
negationSetPattern += options.lowercase ? '' : 'A-Z';
if (options.preserveCharacters.length > 0) {
for (const character of options.preserveCharacters) {
if (character === options.separator) {
throw new Error(`The separator character \`${options.separator}\` cannot be included in preserved characters: ${options.preserveCharacters}`);
}
negationSetPattern += escapeStringRegexp(character);
}
}
return new RegExp(`[^${negationSetPattern}]+`, 'g');
};
export default function slugify(string, options) {
if (typeof string !== 'string') {
throw new TypeError(`Expected a string, got \`${typeof string}\``);
}
options = {
separator: '-',
lowercase: true,
decamelize: true,
customReplacements: [],
preserveLeadingUnderscore: false,
preserveTrailingDash: false,
preserveCharacters: [],
...options
};
const shouldPrependUnderscore = options.preserveLeadingUnderscore && string.startsWith('_');
const shouldAppendDash = options.preserveTrailingDash && string.endsWith('-');
const customReplacements = new Map([
...builtinOverridableReplacements,
...options.customReplacements
]);
string = transliterate(string, {customReplacements});
if (options.decamelize) {
string = decamelize(string);
}
const patternSlug = buildPatternSlug(options);
if (options.lowercase) {
string = string.toLowerCase();
}
// Detect contractions/possessives by looking for any word followed by a `'t`
// or `'s` in isolation and then remove it.
string = string.replace(/([a-zA-Z\d]+)'([ts])(\s|$)/g, '$1$2$3');
string = string.replace(patternSlug, options.separator);
string = string.replace(/\\/g, '');
if (options.separator) {
string = removeMootSeparators(string, options.separator);
}
if (shouldPrependUnderscore) {
string = `_${string}`;
}
if (shouldAppendDash) {
string = `${string}-`;
}
return string;
}
export function slugifyWithCounter() {
const occurrences = new Map();
const countable = (string, options) => {
string = slugify(string, options);
if (!string) {
return '';
}
const stringLower = string.toLowerCase();
const numberless = occurrences.get(stringLower.replace(/(?:-\d+?)+?$/, '')) || 0;
const counter = occurrences.get(stringLower);
occurrences.set(stringLower, typeof counter === 'number' ? counter + 1 : 1);
const newCounter = occurrences.get(stringLower) || 2;
if (newCounter >= 2 || numberless > 2) {
string = `${string}-${newCounter}`;
}
return string;
};
countable.reset = () => {
occurrences.clear();
};
return countable;
}

9
node_modules/@sindresorhus/slugify/license generated vendored Normal file
View File

@@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 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.

View File

@@ -0,0 +1,7 @@
const overridableReplacements = [
['&', ' and '],
['🦄', ' unicorn '],
['♥', ' love ']
];
export default overridableReplacements;

59
node_modules/@sindresorhus/slugify/package.json generated vendored Normal file
View File

@@ -0,0 +1,59 @@
{
"name": "@sindresorhus/slugify",
"version": "2.2.1",
"description": "Slugify a string",
"license": "MIT",
"repository": "sindresorhus/slugify",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=12"
},
"scripts": {
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts",
"overridable-replacements.js"
],
"keywords": [
"string",
"slugify",
"slug",
"url",
"url-safe",
"urlify",
"transliterate",
"transliteration",
"deburr",
"unicode",
"ascii",
"text",
"decamelize",
"pretty",
"clean",
"filename",
"id"
],
"dependencies": {
"@sindresorhus/transliterate": "^1.0.0",
"escape-string-regexp": "^5.0.0"
},
"devDependencies": {
"ava": "^3.15.0",
"tsd": "^0.14.0",
"xo": "^0.38.2"
},
"xo": {
"rules": {
"@typescript-eslint/member-ordering": "off"
}
}
}

273
node_modules/@sindresorhus/slugify/readme.md generated vendored Normal file
View File

@@ -0,0 +1,273 @@
# slugify
> Slugify a string
Useful for URLs, filenames, and IDs.
It handles most major languages, including [German (umlauts)](https://en.wikipedia.org/wiki/Germanic_umlaut), Vietnamese, Arabic, Russian, [and more](https://github.com/sindresorhus/transliterate#supported-languages).
## Install
```
$ npm install @sindresorhus/slugify
```
## Usage
```js
import slugify from '@sindresorhus/slugify';
slugify('I ♥ Dogs');
//=> 'i-love-dogs'
slugify(' Déjà Vu! ');
//=> 'deja-vu'
slugify('fooBar 123 $#%');
//=> 'foo-bar-123'
slugify('я люблю единорогов');
//=> 'ya-lyublyu-edinorogov'
```
## API
### slugify(string, options?)
#### string
Type: `string`
String to slugify.
#### options
Type: `object`
##### separator
Type: `string`\
Default: `'-'`
```js
import slugify from '@sindresorhus/slugify';
slugify('BAR and baz');
//=> 'bar-and-baz'
slugify('BAR and baz', {separator: '_'});
//=> 'bar_and_baz'
slugify('BAR and baz', {separator: ''});
//=> 'barandbaz'
```
##### lowercase
Type: `boolean`\
Default: `true`
Make the slug lowercase.
```js
import slugify from '@sindresorhus/slugify';
slugify('Déjà Vu!');
//=> 'deja-vu'
slugify('Déjà Vu!', {lowercase: false});
//=> 'Deja-Vu'
```
##### decamelize
Type: `boolean`\
Default: `true`
Convert camelcase to separate words. Internally it does `fooBar``foo bar`.
```js
import slugify from '@sindresorhus/slugify';
slugify('fooBar');
//=> 'foo-bar'
slugify('fooBar', {decamelize: false});
//=> 'foobar'
```
##### customReplacements
Type: `Array<string[]>`\
Default: `[
['&', ' and '],
['🦄', ' unicorn '],
['♥', ' love ']
]`
Add your own custom replacements.
The replacements are run on the original string before any other transformations.
This only overrides a default replacement if you set an item with the same key, like `&`.
```js
import slugify from '@sindresorhus/slugify';
slugify('Foo@unicorn', {
customReplacements: [
['@', 'at']
]
});
//=> 'fooatunicorn'
```
Add a leading and trailing space to the replacement to have it separated by dashes:
```js
import slugify from '@sindresorhus/slugify';
slugify('foo@unicorn', {
customReplacements: [
['@', ' at ']
]
});
//=> 'foo-at-unicorn'
```
Another example:
```js
import slugify from '@sindresorhus/slugify';
slugify('I love 🐶', {
customReplacements: [
['🐶', 'dogs']
]
});
//=> 'i-love-dogs'
```
##### preserveLeadingUnderscore
Type: `boolean`\
Default: `false`
If your string starts with an underscore, it will be preserved in the slugified string.
Sometimes leading underscores are intentional, for example, filenames representing hidden paths on a website.
```js
import slugify from '@sindresorhus/slugify';
slugify('_foo_bar');
//=> 'foo-bar'
slugify('_foo_bar', {preserveLeadingUnderscore: true});
//=> '_foo-bar'
```
##### preserveTrailingDash
Type: `boolean`\
Default: `false`
If your string ends with a dash, it will be preserved in the slugified string.
For example, using slugify on an input field would allow for validation while not preventing the user from writing a slug.
```js
import slugify from '@sindresorhus/slugify';
slugify('foo-bar-');
//=> 'foo-bar'
slugify('foo-bar-', {preserveTrailingDash: true});
//=> 'foo-bar-'
```
##### preserveCharacters
Type: `string[]`\
Default: `[]`
Preserve certain characters.
It cannot contain the `separator`.
For example, if you want to slugify URLs, but preserve the HTML fragment `#` character.
```js
import slugify from '@sindresorhus/slugify';
slugify('foo_bar#baz', {preserveCharacters: ['#']});
//=> 'foo-bar#baz'
```
### slugifyWithCounter()
Returns a new instance of `slugify(string, options?)` with a counter to handle multiple occurrences of the same string.
#### Example
```js
import {slugifyWithCounter} from '@sindresorhus/slugify';
const slugify = slugifyWithCounter();
slugify('foo bar');
//=> 'foo-bar'
slugify('foo bar');
//=> 'foo-bar-2'
slugify.reset();
slugify('foo bar');
//=> 'foo-bar'
```
#### Use-case example of counter
If, for example, you have a document with multiple sections where each subsection has an example.
```md
## Section 1
### Example
## Section 2
### Example
```
You can then use `slugifyWithCounter()` to generate unique HTML `id`'s to ensure anchors will link to the right headline.
### slugify.reset()
Reset the counter
#### Example
```js
import {slugifyWithCounter} from '@sindresorhus/slugify';
const slugify = slugifyWithCounter();
slugify('foo bar');
//=> 'foo-bar'
slugify('foo bar');
//=> 'foo-bar-2'
slugify.reset();
slugify('foo bar');
//=> 'foo-bar'
```
## Related
- [slugify-cli](https://github.com/sindresorhus/slugify-cli) - CLI for this module
- [transliterate](https://github.com/sindresorhus/transliterate) - Convert Unicode characters to Latin characters using transliteration
- [filenamify](https://github.com/sindresorhus/filenamify) - Convert a string to a valid safe filename

48
node_modules/@sindresorhus/transliterate/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,48 @@
export interface Options {
/**
Add your own custom replacements.
The replacements are run on the original string before any other transformations.
This only overrides a default replacement if you set an item with the same key.
@default []
@example
```
import transliterate from '@sindresorhus/transliterate';
transliterate('Я люблю единорогов', {
customReplacements: [
['единорогов', '🦄']
]
})
//=> 'Ya lyublyu 🦄'
```
*/
readonly customReplacements?: ReadonlyArray<[string, string]>;
}
/**
Convert Unicode characters to Latin characters using [transliteration](https://en.wikipedia.org/wiki/Transliteration).
@param string - String to transliterate.
@example
```
import transliterate from '@sindresorhus/transliterate';
transliterate('Fußgängerübergänge');
//=> 'Fussgaengeruebergaenge'
transliterate('Я люблю единорогов');
//=> 'Ya lyublyu edinorogov'
transliterate('أنا أحب حيدات');
//=> 'ana ahb hydat'
transliterate('tôi yêu những chú kỳ lân');
//=> 'toi yeu nhung chu ky lan'
```
*/
export default function transliterate(string: string, options?: Options): string;

33
node_modules/@sindresorhus/transliterate/index.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
import escapeStringRegexp from 'escape-string-regexp';
import builtinReplacements from './replacements.js';
const doCustomReplacements = (string, replacements) => {
for (const [key, value] of replacements) {
// TODO: Use `String#replaceAll()` when targeting Node.js 16.
string = string.replace(new RegExp(escapeStringRegexp(key), 'g'), value);
}
return string;
};
export default function transliterate(string, options) {
if (typeof string !== 'string') {
throw new TypeError(`Expected a string, got \`${typeof string}\``);
}
options = {
customReplacements: [],
...options
};
const customReplacements = new Map([
...builtinReplacements,
...options.customReplacements
]);
string = string.normalize();
string = doCustomReplacements(string, customReplacements);
string = string.normalize('NFD').replace(/\p{Diacritic}/gu, '').normalize();
return string;
}

9
node_modules/@sindresorhus/transliterate/license generated vendored Normal file
View File

@@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 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.

47
node_modules/@sindresorhus/transliterate/package.json generated vendored Normal file
View File

@@ -0,0 +1,47 @@
{
"name": "@sindresorhus/transliterate",
"version": "1.6.0",
"description": "Convert Unicode characters to Latin characters using transliteration",
"license": "MIT",
"repository": "sindresorhus/transliterate",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=12"
},
"scripts": {
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts",
"replacements.js"
],
"keywords": [
"transliterate",
"transliteration",
"string",
"deburr",
"unicode",
"ascii",
"text",
"latin",
"latinize",
"convert",
"replace"
],
"dependencies": {
"escape-string-regexp": "^5.0.0"
},
"devDependencies": {
"ava": "^3.15.0",
"tsd": "^0.14.0",
"xo": "^0.38.2"
}
}

103
node_modules/@sindresorhus/transliterate/readme.md generated vendored Normal file
View File

@@ -0,0 +1,103 @@
# transliterate
> Convert Unicode characters to Latin characters using [transliteration](https://en.wikipedia.org/wiki/Transliteration)
Can be useful for [slugification](https://github.com/sindresorhus/slugify) purposes and other times you cannot use Unicode.
## Install
```
$ npm install @sindresorhus/transliterate
```
## Usage
```js
import transliterate from '@sindresorhus/transliterate';
transliterate('Fußgängerübergänge');
//=> 'Fussgaengeruebergaenge'
transliterate('Я люблю единорогов');
//=> 'Ya lyublyu edinorogov'
transliterate('أنا أحب حيدات');
//=> 'ana ahb hydat'
transliterate('tôi yêu những chú kỳ lân');
//=> 'toi yeu nhung chu ky lan'
```
## API
### transliterate(string, options?)
#### string
Type: `string`
String to transliterate.
#### options
Type: `object`
##### customReplacements
Type: `Array<string[]>`\
Default: `[]`
Add your own custom replacements.
The replacements are run on the original string before any other transformations.
This only overrides a default replacement if you set an item with the same key.
```js
import transliterate from '@sindresorhus/transliterate';
transliterate('Я люблю единорогов', {
customReplacements: [
['единорогов', '🦄']
]
})
//=> 'Ya lyublyu 🦄'
```
## Supported languages
Most major languages are supported.
This includes special handling for:
- Arabic
- Armenian
- Czech
- Danish
- Dhivehi
- Georgian
- German (umlauts)
- Greek
- Hungarian
- Latin
- Latvian
- Lithuanian
- Macedonian
- Pashto
- Persian
- Polish
- Romanian
- Russian
- Serbian
- Slovak
- Swedish
- Turkish
- Ukrainian
- Urdu
- Vietnamese
However, Chinese is [currently not supported](https://github.com/sindresorhus/transliterate/issues/1).
## Related
- [slugify](https://github.com/sindresorhus/slugify) - Slugify a string

2056
node_modules/@sindresorhus/transliterate/replacements.js generated vendored Normal file

File diff suppressed because it is too large Load Diff