🎉 initiate project *astro_rewrite*
This commit is contained in:
parent
ffd4d5e86c
commit
2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions
21
node_modules/@emmetio/abbreviation/LICENSE
generated
vendored
Normal file
21
node_modules/@emmetio/abbreviation/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2020 Sergey Chikuyonok <serge.che@gmail.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.
|
76
node_modules/@emmetio/abbreviation/README.md
generated
vendored
Normal file
76
node_modules/@emmetio/abbreviation/README.md
generated
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
# Emmet markup abbreviation parser
|
||||
|
||||
Parses given Emmet *markup* abbreviation into AST. Parsing is performed in two steps: first it tokenizes given abbreviation (useful for syntax highlighting in editors) and then tokens are analyzed and converted into AST nodes as plain, JSON-serializable objects.
|
||||
|
||||
Note that AST tree in most cases cannot be used directly for output: for example, AST node produced from `.foo.bar` element misses element name and contains two `class` attributes with `foo` and `bar` values (not a single `class` with `foo bar` value).
|
||||
|
||||
## Usage
|
||||
|
||||
You can install it via npm:
|
||||
|
||||
```bash
|
||||
npm install @emmetio/abbreviation
|
||||
```
|
||||
|
||||
Then add it into your project:
|
||||
|
||||
```js
|
||||
import parse from '@emmetio/abbreviation';
|
||||
|
||||
const tree = parse('div#foo>span.bar*3');
|
||||
/* {
|
||||
type: 'Abbreviation',
|
||||
children: [{
|
||||
type: 'AbbreviationNode',
|
||||
name: 'div',
|
||||
attributes: [...],
|
||||
children: [...]
|
||||
}]
|
||||
} */
|
||||
|
||||
```
|
||||
The returned tree contains `AbbreviationNode` items: a node with name, attributes and/or text content. E.g. an element that can be represented somehow. Repeated and grouped nodes like `a>(b+c)*3` are automatically converted and duplicated as distinct `AbbreviationNode` with distinct `.repeat` property which identifies node in repeating sequence.
|
||||
|
||||
## Abbreviation syntax
|
||||
|
||||
Emmet abbreviation element has the following basic parts:
|
||||
|
||||
```
|
||||
name.class#id[attributes?, ...]{text value}*repeater/
|
||||
```
|
||||
|
||||
* `name` — element name, like `div`, `span` etc. Stored as `node.name` property.
|
||||
* `[attributes]` — list of attributes. Each attribute is stored as [`AbbreviationAttribute`](/src/types.ts) instance and can be accessed by `node.getAttribute(name)`. Each attribute can be written in different formats:
|
||||
* `attr` — attribute with empty value.
|
||||
* `attr=value` — attribute with value. The `value` may contain any character except space or `]`.
|
||||
* `attr="value"` or `attr='value'` — attribute with value in quotes. Quotes are automatically removed. Expression values like `attr={value}` are supported and can be identified by `valueType: "expression"` property.
|
||||
* `attr.` — boolean attribute, e.g. attribute without value, like `required` in `<input>`.
|
||||
* `!attr` – implicit attribute, will be outputted if its value is not empty. Used as a placeholder to preserve attribute order in output.
|
||||
* `./non/attr/value` — value for default attribute. In other words, anything that doesn’t match a attribute name characters. Can be a single- or double-quotted as well. Default attribute is stored with `null` as name and should be used later, for example, to resolve predefined attributes.
|
||||
* `.class` — shorthand for `class` attribute. Note that an element can have multiple classes, like `.class1.class2.class3`.
|
||||
* `#id` — shorthand for `id` attribute.
|
||||
* `{text}` — node’s text content
|
||||
* `*N` — element repeater, tells parser to create `N` copies of given node.
|
||||
* `/` — optional self-closing operator. Marks element with `node.selfClosing = true`.
|
||||
|
||||
### Operators
|
||||
|
||||
Each element of abbreviation must be separated with any of these operators:
|
||||
|
||||
```
|
||||
elem1+elem2>elem3
|
||||
```
|
||||
|
||||
* `+` — sibling operator, adds next element as a next sibling of current element in tree.
|
||||
* `>` — child operator, adds next element as a child of current element.
|
||||
* `^` — climb-up operator, adds next element as a child of current element’s parent node. Multiple climb-up operators are allowed, each operator moves one level up by tree.
|
||||
|
||||
### Groups
|
||||
|
||||
A set of elements could be grouped using `()`, mostly for repeating and for easier elements nesting:
|
||||
|
||||
```
|
||||
a>(b>c+d)*4+(e+f)
|
||||
```
|
||||
|
||||
Groups can be optionally concatenated with `+` operator.
|
8
node_modules/@emmetio/abbreviation/dist/convert.d.ts
generated
vendored
Normal file
8
node_modules/@emmetio/abbreviation/dist/convert.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
import { TokenGroup } from './parser/index.js';
|
||||
import { Abbreviation, ParserOptions } from './types.js';
|
||||
/**
|
||||
* Converts given token-based abbreviation into simplified and unrolled node-based
|
||||
* abbreviation
|
||||
*/
|
||||
export default function convert(abbr: TokenGroup, options?: ParserOptions): Abbreviation;
|
||||
export declare function isGroup(node: any): node is TokenGroup;
|
1245
node_modules/@emmetio/abbreviation/dist/index.cjs
generated
vendored
Normal file
1245
node_modules/@emmetio/abbreviation/dist/index.cjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
node_modules/@emmetio/abbreviation/dist/index.cjs.map
generated
vendored
Normal file
1
node_modules/@emmetio/abbreviation/dist/index.cjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
12
node_modules/@emmetio/abbreviation/dist/index.d.ts
generated
vendored
Normal file
12
node_modules/@emmetio/abbreviation/dist/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
import parse, { type TokenGroup } from './parser/index.js';
|
||||
import tokenize, { getToken, type AllTokens } from './tokenizer/index.js';
|
||||
import convert from './convert.js';
|
||||
import type { ParserOptions } from './types.js';
|
||||
export { parse, tokenize, getToken, convert };
|
||||
export * from './tokenizer/tokens.js';
|
||||
export * from './types.js';
|
||||
export type MarkupAbbreviation = TokenGroup;
|
||||
/**
|
||||
* Parses given abbreviation into node tree
|
||||
*/
|
||||
export default function parseAbbreviation(abbr: string | AllTokens[], options?: ParserOptions): import("./types.js").Abbreviation;
|
1237
node_modules/@emmetio/abbreviation/dist/index.js
generated
vendored
Normal file
1237
node_modules/@emmetio/abbreviation/dist/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
node_modules/@emmetio/abbreviation/dist/index.js.map
generated
vendored
Normal file
1
node_modules/@emmetio/abbreviation/dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
17
node_modules/@emmetio/abbreviation/dist/parser/TokenScanner.d.ts
generated
vendored
Normal file
17
node_modules/@emmetio/abbreviation/dist/parser/TokenScanner.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
import { AllTokens } from '../tokenizer/index.js';
|
||||
export interface TokenScanner {
|
||||
tokens: AllTokens[];
|
||||
start: number;
|
||||
pos: number;
|
||||
size: number;
|
||||
}
|
||||
type TestFn = (token?: AllTokens) => boolean;
|
||||
export default function tokenScanner(tokens: AllTokens[]): TokenScanner;
|
||||
export declare function peek(scanner: TokenScanner): AllTokens | undefined;
|
||||
export declare function next(scanner: TokenScanner): AllTokens | undefined;
|
||||
export declare function slice(scanner: TokenScanner, from?: number, to?: number): AllTokens[];
|
||||
export declare function readable(scanner: TokenScanner): boolean;
|
||||
export declare function consume(scanner: TokenScanner, test: TestFn): boolean;
|
||||
export declare function error(scanner: TokenScanner, message: string, token?: AllTokens | undefined): Error;
|
||||
export declare function consumeWhile(scanner: TokenScanner, test: TestFn): boolean;
|
||||
export {};
|
31
node_modules/@emmetio/abbreviation/dist/parser/index.d.ts
generated
vendored
Normal file
31
node_modules/@emmetio/abbreviation/dist/parser/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
import type { NameToken, ValueToken, Repeater, AllTokens, BracketType, Bracket, Operator, OperatorType, Quote } from '../tokenizer/index.js';
|
||||
import type { ParserOptions } from '../types.js';
|
||||
export type TokenStatement = TokenElement | TokenGroup;
|
||||
export interface TokenAttribute {
|
||||
name?: ValueToken[];
|
||||
value?: ValueToken[];
|
||||
expression?: boolean;
|
||||
/**
|
||||
* Indicates that current attribute was repeated multiple times in a row.
|
||||
* Used to alter output of multiple shorthand attributes like `..` (double class)
|
||||
*/
|
||||
multiple?: boolean;
|
||||
}
|
||||
export interface TokenElement {
|
||||
type: 'TokenElement';
|
||||
name?: NameToken[];
|
||||
attributes?: TokenAttribute[];
|
||||
value?: ValueToken[];
|
||||
repeat?: Repeater;
|
||||
selfClose: boolean;
|
||||
elements: TokenStatement[];
|
||||
}
|
||||
export interface TokenGroup {
|
||||
type: 'TokenGroup';
|
||||
elements: TokenStatement[];
|
||||
repeat?: Repeater;
|
||||
}
|
||||
export default function abbreviation(abbr: AllTokens[], options?: ParserOptions): TokenGroup;
|
||||
export declare function isBracket(token: AllTokens | undefined, context?: BracketType, isOpen?: boolean): token is Bracket;
|
||||
export declare function isOperator(token: AllTokens | undefined, type?: OperatorType): token is Operator;
|
||||
export declare function isQuote(token: AllTokens | undefined, isSingle?: boolean): token is Quote;
|
6
node_modules/@emmetio/abbreviation/dist/stringify.d.ts
generated
vendored
Normal file
6
node_modules/@emmetio/abbreviation/dist/stringify.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
import { ValueToken } from './tokenizer/tokens.js';
|
||||
import { ConvertState } from './types.js';
|
||||
/**
|
||||
* Converts given value token to string
|
||||
*/
|
||||
export default function stringify(token: ValueToken, state: ConvertState): string;
|
13
node_modules/@emmetio/abbreviation/dist/tokenizer/index.d.ts
generated
vendored
Normal file
13
node_modules/@emmetio/abbreviation/dist/tokenizer/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
import Scanner from '@emmetio/scanner';
|
||||
import type { BracketType, AllTokens } from './tokens.js';
|
||||
export * from './tokens.js';
|
||||
type Context = {
|
||||
[ctx in BracketType]: number;
|
||||
} & {
|
||||
quote: number;
|
||||
};
|
||||
export default function tokenize(source: string): AllTokens[];
|
||||
/**
|
||||
* Returns next token from given scanner, if possible
|
||||
*/
|
||||
export declare function getToken(scanner: Scanner, ctx: Context): AllTokens | undefined;
|
63
node_modules/@emmetio/abbreviation/dist/tokenizer/tokens.d.ts
generated
vendored
Normal file
63
node_modules/@emmetio/abbreviation/dist/tokenizer/tokens.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
export type OperatorType = 'child' | 'sibling' | 'climb' | 'class' | 'id' | 'close' | 'equal';
|
||||
export type BracketType = 'group' | 'attribute' | 'expression';
|
||||
export type AllTokens = Bracket | Field | Literal | Operator | Quote | Repeater | RepeaterNumber | RepeaterPlaceholder | WhiteSpace;
|
||||
export type NameToken = Literal | RepeaterNumber;
|
||||
export type ValueToken = Literal | Quote | Bracket | Field | RepeaterPlaceholder | RepeaterNumber;
|
||||
export interface Token {
|
||||
type: string;
|
||||
/** Location of token start in source */
|
||||
start?: number;
|
||||
/** Location of token end in source */
|
||||
end?: number;
|
||||
}
|
||||
export interface Repeater extends Token {
|
||||
type: 'Repeater';
|
||||
/** How many times context element should be repeated */
|
||||
count: number;
|
||||
/** Position of context element in its repeating sequence */
|
||||
value: number;
|
||||
/** Repeater is implicit, e.g. repeated by the amount of text lines selected by user */
|
||||
implicit: boolean;
|
||||
}
|
||||
export interface RepeaterNumber extends Token {
|
||||
type: 'RepeaterNumber';
|
||||
/** Size of repeater content, e.g. the amount consequent numbering characters */
|
||||
size: number;
|
||||
/** Should output numbering in reverse order? */
|
||||
reverse: boolean;
|
||||
/** Base value to start numbering from */
|
||||
base: number;
|
||||
/** Parent offset from which numbering should be used */
|
||||
parent: number;
|
||||
}
|
||||
export interface RepeaterPlaceholder extends Token {
|
||||
type: 'RepeaterPlaceholder';
|
||||
/** Value to insert instead of placeholder */
|
||||
value?: string;
|
||||
}
|
||||
export interface Field extends Token {
|
||||
type: 'Field';
|
||||
index?: number;
|
||||
name: string;
|
||||
}
|
||||
export interface Operator extends Token {
|
||||
type: 'Operator';
|
||||
operator: OperatorType;
|
||||
}
|
||||
export interface Bracket extends Token {
|
||||
type: 'Bracket';
|
||||
open: boolean;
|
||||
context: BracketType;
|
||||
}
|
||||
export interface Quote extends Token {
|
||||
type: 'Quote';
|
||||
single: boolean;
|
||||
}
|
||||
export interface Literal extends Token {
|
||||
type: 'Literal';
|
||||
value: string;
|
||||
}
|
||||
export interface WhiteSpace extends Token {
|
||||
type: 'WhiteSpace';
|
||||
value: string;
|
||||
}
|
53
node_modules/@emmetio/abbreviation/dist/tokenizer/utils.d.ts
generated
vendored
Normal file
53
node_modules/@emmetio/abbreviation/dist/tokenizer/utils.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
import type Scanner from '@emmetio/scanner';
|
||||
export declare const enum Chars {
|
||||
/** `{` character */
|
||||
CurlyBracketOpen = 123,
|
||||
/** `}` character */
|
||||
CurlyBracketClose = 125,
|
||||
/** `\\` character */
|
||||
Escape = 92,
|
||||
/** `=` character */
|
||||
Equals = 61,
|
||||
/** `[` character */
|
||||
SquareBracketOpen = 91,
|
||||
/** `]` character */
|
||||
SquareBracketClose = 93,
|
||||
/** `*` character */
|
||||
Asterisk = 42,
|
||||
/** `#` character */
|
||||
Hash = 35,
|
||||
/** `$` character */
|
||||
Dollar = 36,
|
||||
/** `-` character */
|
||||
Dash = 45,
|
||||
/** `.` character */
|
||||
Dot = 46,
|
||||
/** `/` character */
|
||||
Slash = 47,
|
||||
/** `:` character */
|
||||
Colon = 58,
|
||||
/** `!` character */
|
||||
Excl = 33,
|
||||
/** `@` character */
|
||||
At = 64,
|
||||
/** `_` character */
|
||||
Underscore = 95,
|
||||
/** `(` character */
|
||||
RoundBracketOpen = 40,
|
||||
/** `)` character */
|
||||
RoundBracketClose = 41,
|
||||
/** `+` character */
|
||||
Sibling = 43,
|
||||
/** `>` character */
|
||||
Child = 62,
|
||||
/** `^` character */
|
||||
Climb = 94,
|
||||
/** `'` character */
|
||||
SingleQuote = 39,
|
||||
/** `""` character */
|
||||
DoubleQuote = 34
|
||||
}
|
||||
/**
|
||||
* If consumes escape character, sets current stream range to escaped value
|
||||
*/
|
||||
export declare function escaped(scanner: Scanner): boolean;
|
56
node_modules/@emmetio/abbreviation/dist/types.d.ts
generated
vendored
Normal file
56
node_modules/@emmetio/abbreviation/dist/types.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
import { Field, Repeater } from './tokenizer/index.js';
|
||||
export interface ParserOptions {
|
||||
/** Text strings to insert into implicitly repeated elements */
|
||||
text?: string | string[];
|
||||
/** Variable values for `${var}` tokens */
|
||||
variables?: {
|
||||
[name: string]: string;
|
||||
};
|
||||
/** Max amount of repeated elements in abbreviation */
|
||||
maxRepeat?: number;
|
||||
/** Enabled JSX parsing mode */
|
||||
jsx?: boolean;
|
||||
/** Enable inserting text into href attribute of links */
|
||||
href?: boolean;
|
||||
}
|
||||
export interface ConvertState {
|
||||
inserted: boolean;
|
||||
text?: string | string[];
|
||||
cleanText?: string | string[];
|
||||
repeatGuard: number;
|
||||
/** Context repeaters, e.g. all actual repeaters from parent */
|
||||
repeaters: Repeater[];
|
||||
getText(pos?: number): string;
|
||||
getVariable(name: string): string;
|
||||
}
|
||||
export type Value = string | Field;
|
||||
export type AttributeType = 'raw' | 'singleQuote' | 'doubleQuote' | 'expression';
|
||||
export interface Abbreviation {
|
||||
type: 'Abbreviation';
|
||||
children: AbbreviationNode[];
|
||||
}
|
||||
export interface AbbreviationNode {
|
||||
type: 'AbbreviationNode';
|
||||
name?: string;
|
||||
value?: Value[];
|
||||
repeat?: Repeater;
|
||||
attributes?: AbbreviationAttribute[];
|
||||
children: AbbreviationNode[];
|
||||
/** Indicates current element is self-closing, e.g. should not contain closing pair */
|
||||
selfClosing?: boolean;
|
||||
}
|
||||
export interface AbbreviationAttribute {
|
||||
name?: string;
|
||||
value?: Value[];
|
||||
/** Indicates type of value stored in `.value` property */
|
||||
valueType: AttributeType;
|
||||
/** Attribute is boolean (e.g.name equals value) */
|
||||
boolean?: boolean;
|
||||
/** Attribute is implied (e.g.must be outputted only if contains non-null value) */
|
||||
implied?: boolean;
|
||||
/**
|
||||
* Internal property that indicates that given attribute was specified
|
||||
* more than once as a shorthand. E.g. `..` is a multiple `class` attribute
|
||||
*/
|
||||
multiple?: boolean;
|
||||
}
|
54
node_modules/@emmetio/abbreviation/package.json
generated
vendored
Normal file
54
node_modules/@emmetio/abbreviation/package.json
generated
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
{
|
||||
"name": "@emmetio/abbreviation",
|
||||
"version": "2.3.3",
|
||||
"description": "Emmet standalone abbreviation parser",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha",
|
||||
"build": "rollup -c",
|
||||
"clean": "rimraf ./dist",
|
||||
"prepublishOnly": "npm run clean && npm run build && npm test"
|
||||
},
|
||||
"keywords": [
|
||||
"emmet",
|
||||
"abbreviation"
|
||||
],
|
||||
"author": "Sergey Chikuyonok <serge.che@gmail.com>",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@emmetio/scanner": "^1.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-typescript": "^10.0.1",
|
||||
"@types/mocha": "^10.0.1",
|
||||
"@types/node": "^18.11.18",
|
||||
"mocha": "^10.2.0",
|
||||
"rimraf": "^5.0.0",
|
||||
"rollup": "^3.9.0",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^4.9.4"
|
||||
},
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/emmetio/emmet.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/emmetio/emmet/issues"
|
||||
},
|
||||
"homepage": "https://github.com/emmetio/emmet#readme",
|
||||
"mocha": {
|
||||
"loader": "ts-node/esm",
|
||||
"spec": "./test/*.ts"
|
||||
},
|
||||
"gitHead": "fce2127ece65adbb293a40aa0577e4558658c559"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue