Initial commit
This commit is contained in:
21
node_modules/dedent/LICENSE
generated
vendored
Normal file
21
node_modules/dedent/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Desmond Brand (dmnd@desmondbrand.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.
|
||||
115
node_modules/dedent/README.md
generated
vendored
Normal file
115
node_modules/dedent/README.md
generated
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
# Dedent
|
||||
|
||||
An ES6 string tag that strips indentation from multi-line strings.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import dedent from "dedent";
|
||||
|
||||
function usageExample() {
|
||||
const first = dedent`A string that gets so long you need to break it over
|
||||
multiple lines. Luckily dedent is here to keep it
|
||||
readable without lots of spaces ending up in the string
|
||||
itself.`;
|
||||
|
||||
const second = dedent`
|
||||
Leading and trailing lines will be trimmed, so you can write something like
|
||||
this and have it work as you expect:
|
||||
|
||||
* how convenient it is
|
||||
* that I can use an indented list
|
||||
- and still have it do the right thing
|
||||
|
||||
That's all.
|
||||
`;
|
||||
|
||||
const third = dedent(`
|
||||
Wait! I lied. Dedent can also be used as a function.
|
||||
`);
|
||||
|
||||
return first + "\n\n" + second + "\n\n" + third;
|
||||
}
|
||||
```
|
||||
|
||||
```js
|
||||
> console.log(usageExample());
|
||||
```
|
||||
|
||||
```
|
||||
A string that gets so long you need to break it over
|
||||
multiple lines. Luckily dedent is here to keep it
|
||||
readable without lots of spaces ending up in the string
|
||||
itself.
|
||||
|
||||
Leading and trailing lines will be trimmed, so you can write something like
|
||||
this and have it work as you expect:
|
||||
|
||||
* how convenient it is
|
||||
* that I can use an indented list
|
||||
- and still have it do the right thing
|
||||
|
||||
That's all.
|
||||
|
||||
Wait! I lied. Dedent can also be used as a function.
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
You can customize the options `dedent` runs with by calling its `withOptions` method with an object:
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
import dedent from 'dedent';
|
||||
|
||||
dedent.withOptions({ /* ... */ })`input`;
|
||||
dedent.withOptions({ /* ... */ })(`input`);
|
||||
```
|
||||
|
||||
`options` returns a new `dedent` function, so if you'd like to reuse the same options, you can create a dedicated `dedent` function:
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```js
|
||||
import dedent from 'dedent';
|
||||
|
||||
const dedenter = dedent.withOptions({ /* ... */ });
|
||||
|
||||
dedenter`input`;
|
||||
dedenter(`input`);
|
||||
```
|
||||
|
||||
### `escapeSpecialCharacters`
|
||||
|
||||
JavaScript string tags by default add an extra `\` escape in front of some special characters such as `$` dollar signs.
|
||||
`dedent` will escape those special characters when called as a string tag.
|
||||
|
||||
If you'd like to change the behavior, an `escapeSpecialCharacters` option is available.
|
||||
It defaults to:
|
||||
|
||||
- `false`: when `dedent` is called as a function
|
||||
- `true`: when `dedent` is called as a string tag
|
||||
|
||||
```js
|
||||
import dedent from "dedent";
|
||||
|
||||
// "$hello!"
|
||||
dedent`
|
||||
$hello!
|
||||
`;
|
||||
|
||||
// "\$hello!"
|
||||
dedent.withOptions({ escapeSpecialCharacters: false })`
|
||||
$hello!
|
||||
`;
|
||||
|
||||
// "$hello!"
|
||||
dedent.withOptions({ escapeSpecialCharacters: true })`
|
||||
$hello!
|
||||
`;
|
||||
```
|
||||
|
||||
For more context, see [https://github.com/dmnd/dedent/issues/63](🚀 Feature: Add an option to disable special character escaping).
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
17
node_modules/dedent/dist/dedent.d.mts
generated
vendored
Normal file
17
node_modules/dedent/dist/dedent.d.mts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
interface DedentOptions {
|
||||
escapeSpecialCharacters?: boolean;
|
||||
}
|
||||
interface Dedent {
|
||||
(literals: string): string;
|
||||
(strings: TemplateStringsArray, ...values: unknown[]): string;
|
||||
withOptions: CreateDedent;
|
||||
}
|
||||
type CreateDedent = (options: DedentOptions) => Dedent;
|
||||
|
||||
declare const _default: {
|
||||
(literals: string): string;
|
||||
(strings: TemplateStringsArray, ...values: unknown[]): string;
|
||||
withOptions(newOptions: DedentOptions): any;
|
||||
};
|
||||
|
||||
export { CreateDedent, Dedent, DedentOptions, _default as default };
|
||||
17
node_modules/dedent/dist/dedent.d.ts
generated
vendored
Normal file
17
node_modules/dedent/dist/dedent.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
interface DedentOptions {
|
||||
escapeSpecialCharacters?: boolean;
|
||||
}
|
||||
interface Dedent {
|
||||
(literals: string): string;
|
||||
(strings: TemplateStringsArray, ...values: unknown[]): string;
|
||||
withOptions: CreateDedent;
|
||||
}
|
||||
type CreateDedent = (options: DedentOptions) => Dedent;
|
||||
|
||||
declare const _default: {
|
||||
(literals: string): string;
|
||||
(strings: TemplateStringsArray, ...values: unknown[]): string;
|
||||
withOptions(newOptions: DedentOptions): any;
|
||||
};
|
||||
|
||||
export { CreateDedent, Dedent, DedentOptions, _default as default };
|
||||
66
node_modules/dedent/dist/dedent.js
generated
vendored
Normal file
66
node_modules/dedent/dist/dedent.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _default = createDedent({});
|
||||
exports.default = _default;
|
||||
function createDedent(options) {
|
||||
dedent.withOptions = newOptions => createDedent({
|
||||
...options,
|
||||
...newOptions
|
||||
});
|
||||
return dedent;
|
||||
function dedent(strings, ...values) {
|
||||
const raw = typeof strings === "string" ? [strings] : strings.raw;
|
||||
const {
|
||||
escapeSpecialCharacters = Array.isArray(strings)
|
||||
} = options;
|
||||
|
||||
// first, perform interpolation
|
||||
let result = "";
|
||||
for (let i = 0; i < raw.length; i++) {
|
||||
let next = raw[i];
|
||||
if (escapeSpecialCharacters) {
|
||||
// handle escaped newlines, backticks, and interpolation characters
|
||||
next = next.replace(/\\\n[ \t]*/g, "").replace(/\\`/g, "`").replace(/\\\$/g, "$").replace(/\\{/g, "{");
|
||||
}
|
||||
result += next;
|
||||
if (i < values.length) {
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
||||
result += values[i];
|
||||
}
|
||||
}
|
||||
|
||||
// now strip indentation
|
||||
const lines = result.split("\n");
|
||||
let mindent = null;
|
||||
for (const l of lines) {
|
||||
const m = l.match(/^(\s+)\S+/);
|
||||
if (m) {
|
||||
const indent = m[1].length;
|
||||
if (!mindent) {
|
||||
// this is the first indented line
|
||||
mindent = indent;
|
||||
} else {
|
||||
mindent = Math.min(mindent, indent);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mindent !== null) {
|
||||
const m = mindent; // appease TypeScript
|
||||
result = lines
|
||||
// https://github.com/typescript-eslint/typescript-eslint/issues/7140
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
|
||||
.map(l => l[0] === " " || l[0] === "\t" ? l.slice(m) : l).join("\n");
|
||||
}
|
||||
return result
|
||||
// dedent eats leading and trailing whitespace too
|
||||
.trim()
|
||||
// handle escaped newlines at the end to ensure they don't get stripped too
|
||||
.replace(/\\n/g, "\n");
|
||||
}
|
||||
}
|
||||
module.exports = exports.default;
|
||||
module.exports.default = exports.default;
|
||||
59
node_modules/dedent/dist/dedent.mjs
generated
vendored
Normal file
59
node_modules/dedent/dist/dedent.mjs
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
||||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
||||
export default createDedent({});
|
||||
function createDedent(options) {
|
||||
dedent.withOptions = newOptions => createDedent(_objectSpread(_objectSpread({}, options), newOptions));
|
||||
return dedent;
|
||||
function dedent(strings, ...values) {
|
||||
const raw = typeof strings === "string" ? [strings] : strings.raw;
|
||||
const {
|
||||
escapeSpecialCharacters = Array.isArray(strings)
|
||||
} = options;
|
||||
|
||||
// first, perform interpolation
|
||||
let result = "";
|
||||
for (let i = 0; i < raw.length; i++) {
|
||||
let next = raw[i];
|
||||
if (escapeSpecialCharacters) {
|
||||
// handle escaped newlines, backticks, and interpolation characters
|
||||
next = next.replace(/\\\n[ \t]*/g, "").replace(/\\`/g, "`").replace(/\\\$/g, "$").replace(/\\{/g, "{");
|
||||
}
|
||||
result += next;
|
||||
if (i < values.length) {
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
||||
result += values[i];
|
||||
}
|
||||
}
|
||||
|
||||
// now strip indentation
|
||||
const lines = result.split("\n");
|
||||
let mindent = null;
|
||||
for (const l of lines) {
|
||||
const m = l.match(/^(\s+)\S+/);
|
||||
if (m) {
|
||||
const indent = m[1].length;
|
||||
if (!mindent) {
|
||||
// this is the first indented line
|
||||
mindent = indent;
|
||||
} else {
|
||||
mindent = Math.min(mindent, indent);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mindent !== null) {
|
||||
const m = mindent; // appease TypeScript
|
||||
result = lines
|
||||
// https://github.com/typescript-eslint/typescript-eslint/issues/7140
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
|
||||
.map(l => l[0] === " " || l[0] === "\t" ? l.slice(m) : l).join("\n");
|
||||
}
|
||||
return result
|
||||
// dedent eats leading and trailing whitespace too
|
||||
.trim()
|
||||
// handle escaped newlines at the end to ensure they don't get stripped too
|
||||
.replace(/\\n/g, "\n");
|
||||
}
|
||||
}
|
||||
2
node_modules/dedent/macro.d.ts
generated
vendored
Normal file
2
node_modules/dedent/macro.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import dedent from "dedent";
|
||||
export default dedent;
|
||||
34
node_modules/dedent/macro.js
generated
vendored
Normal file
34
node_modules/dedent/macro.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
const { createMacro, MacroError } = require("babel-plugin-macros");
|
||||
const dedent = require("./dist/dedent.js").default;
|
||||
|
||||
module.exports = createMacro(prevalMacros);
|
||||
|
||||
function prevalMacros({ references, state, babel }) {
|
||||
references.default.forEach(referencePath => {
|
||||
if (referencePath.parentPath.type === "TaggedTemplateExpression") {
|
||||
asTag(referencePath.parentPath.get("quasi"), state, babel);
|
||||
} else if (referencePath.parentPath.type === "CallExpression") {
|
||||
asFunction(referencePath.parentPath.get("arguments"), state, babel);
|
||||
} else {
|
||||
throw new MacroError(
|
||||
`dedent.macro can only be used as tagged template expression or function call. You tried ${
|
||||
referencePath.parentPath.type
|
||||
}.`
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function asTag(quasiPath, { file: { opts: { filename } } }, babel) {
|
||||
const string = quasiPath.parentPath.get("quasi").evaluate().value;
|
||||
const { types: t } = babel;
|
||||
|
||||
quasiPath.parentPath.replaceWith(t.stringLiteral(dedent(string)));
|
||||
}
|
||||
|
||||
function asFunction(argumentsPaths, { file: { opts: { filename } } }, babel) {
|
||||
const string = argumentsPaths[0].evaluate().value;
|
||||
const { types: t } = babel;
|
||||
|
||||
argumentsPaths[0].parentPath.replaceWith(t.stringLiteral(dedent(string)));
|
||||
}
|
||||
87
node_modules/dedent/package.json
generated
vendored
Normal file
87
node_modules/dedent/package.json
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
{
|
||||
"name": "dedent",
|
||||
"version": "1.5.1",
|
||||
"description": "An ES6 string tag that strips indentation from multi-line strings",
|
||||
"main": "dist/dedent.js",
|
||||
"types": "./dist/dedent.d.ts",
|
||||
"module": "./dist/dedent.mjs",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./dist/dedent.d.mts",
|
||||
"default": "./dist/dedent.mjs"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/dedent.d.ts",
|
||||
"default": "./dist/dedent.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist/dedent.d.mts",
|
||||
"dist/dedent.d.ts",
|
||||
"dist/dedent.js",
|
||||
"dist/dedent.mjs",
|
||||
"macro.js",
|
||||
"index.d.ts",
|
||||
"macro.d.ts",
|
||||
"README.md",
|
||||
"LICENSE"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/dmnd/dedent.git"
|
||||
},
|
||||
"keywords": [
|
||||
"dedent",
|
||||
"tag",
|
||||
"multi-line string",
|
||||
"es6"
|
||||
],
|
||||
"author": {
|
||||
"name": "Desmond Brand",
|
||||
"email": "dmnd@desmondbrand.com",
|
||||
"url": "http://desmondbrand.com"
|
||||
},
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/dmnd/dedent/issues"
|
||||
},
|
||||
"homepage": "https://github.com/dmnd/dedent",
|
||||
"peerDependencies": {
|
||||
"babel-plugin-macros": "^3.1.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"babel-plugin-macros": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.21.5",
|
||||
"@babel/core": "^7.21.8",
|
||||
"@babel/preset-env": "^7.21.5",
|
||||
"@babel/preset-typescript": "^7.22.5",
|
||||
"@types/babel-plugin-macros": "^3.1.0",
|
||||
"@types/jest": "^29.5.3",
|
||||
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
||||
"@typescript-eslint/parser": "^6.0.0",
|
||||
"babel-plugin-add-module-exports": "^1.0.4",
|
||||
"babel-plugin-macros": "^3.1.0",
|
||||
"babel-plugin-tester": "^11.0.4",
|
||||
"eslint": "^8.41.0",
|
||||
"hermes-eslint": "^0.11.1",
|
||||
"jest": "^29.5.0",
|
||||
"tsup": "^7.1.0",
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "yarn build:legacy && yarn build:modern && yarn build:types",
|
||||
"build:legacy": "BABEL_ENV=legacy babel dedent.ts --out-file dist/dedent.js",
|
||||
"build:modern": "BABEL_ENV=modern babel dedent.ts --out-file dist/dedent.mjs",
|
||||
"build:types": "tsup dedent.ts --dts-only --format cjs,esm",
|
||||
"lint": "eslint .",
|
||||
"prepack": "yarn build",
|
||||
"test": "jest",
|
||||
"tsc": "tsc"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user