🎉 initiate project *astro_rewrite*

This commit is contained in:
sindrekjelsrud 2023-07-19 21:31:30 +02:00
parent ffd4d5e86c
commit 2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions

21
node_modules/emmet/LICENSE generated vendored Normal file
View 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.

161
node_modules/emmet/README.md generated vendored Normal file
View file

@ -0,0 +1,161 @@
# Emmet — the essential toolkit for web-developers
Emmet is a web-developers toolkit for boosting HTML & CSS code writing.
With Emmet, you can type expressions (_abbreviations_) similar to CSS selectors and convert them into code fragment with a single keystroke. For example, this abbreviation:
```
ul#nav>li.item$*4>a{Item $}
```
...can be expanded into:
```html
<ul id="nav">
<li class="item1"><a href="">Item 1</a></li>
<li class="item2"><a href="">Item 2</a></li>
<li class="item3"><a href="">Item 3</a></li>
<li class="item4"><a href="">Item 4</a></li>
</ul>
```
## Features
* **Familiar syntax**: as a web-developer, you already know how to use Emmet. Abbreviation syntax is similar to CSS Selectors with shortcuts for id, class, custom attributes, element nesting and so on.
* **Dynamic snippets**: unlike default editor snippets, Emmet abbreviations are dynamic and parsed as-you-type. No need to predefine them for each project, just type `MyComponent>custom-element` to convert any word into a tag.
* **CSS properties shortcuts**: Emmet provides special syntax for CSS properties with embedded values. For example, `bd1-s#f.5` will be expanded to `border: 1px solid rgba(255, 255, 255, 0.5)`.
* **Available for most popular syntaxes**: use single abbreviation to produce code for most popular syntaxes like HAML, Pug, JSX, SCSS, SASS etc.
[Read more about Emmet features](https://docs.emmet.io)
This repo contains only core module for parsing and expanding Emmet abbreviations. Editor plugins are available as [separate repos](https://github.com/emmetio).
This is a *monorepo*: top-level project contains all the code required for converting abbreviation into code fragment while [`./packages`](/packages) folder contains modules for parsing abbreviations into AST and can be used independently (for example, as lexer for syntax highlighting).
### Installation
You can install Emmet as a regular npm module:
```bash
npm i emmet
```
## Usage
To expand abbreviation, pass it to default function of `emmet` module:
```js
import expand from 'emmet';
console.log(expand('p>a')); // <p><a href=""></a></p>
```
By default, Emmet expands *markup* abbreviation, e.g. abbreviation used for producing nested elements with attributes (like HTML, XML, HAML etc.). If you want to expand *stylesheet* abbreviation, you should pass it as a `type` property of second argument:
```js
import expand from 'emmet';
console.log(expand('p10', { type: 'stylesheet' })); // padding: 10px;
```
A stylesheet abbreviation has slightly different syntax compared to markup one: it doesnt support nesting and attributes but allows embedded values in element name.
Alternatively, Emmet supports *syntaxes* with predefined snippets and options:
```js
import expand from 'emmet';
console.log(expand('p10', { syntax: 'css' })); // padding: 10px;
console.log(expand('p10', { syntax: 'stylus' })); // padding 10px
```
Predefined syntaxes already have `type` attribute which describes whether given abbreviation is markup or stylesheet, but if you want to use it with your custom syntax name, you should provide `type` config option as well (default is `markup`):
```js
import expand from 'emmet';
console.log(expand('p10', {
syntax: 'my-custom-syntax',
type: 'stylesheet',
options: {
'stylesheet.between': '__',
'stylesheet.after': '',
}
})); // padding__10px
```
You can pass `options` property as well to shape-up final output or enable/disable various features. See [`src/config.ts`](src/config.ts) for more info and available options.
## Extracting abbreviations from text
A common workflow with Emmet is to type abbreviation somewhere in source code and then expand it with editor action. To support such workflow, abbreviations must be properly _extracted_ from source code:
```js
import expand, { extract } from 'emmet';
const source = 'Hello world ul.tabs>li';
const data = extract(source, 22); // { abbreviation: 'ul.tabs>li' }
console.log(expand(data.abbreviation)); // <ul class="tabs"><li></li></ul>
```
The `extract` function accepts source code (most likely, current line) and character location in source from which abbreviation search should be started. The abbreviation is searched in backward direction: the location pointer is moved backward until it finds abbreviation bound. Returned result is an object with `abbreviation` property and `start` and `end` properties which describe location of extracted abbreviation in given source.
Most current editors automatically insert closing quote or bracket for `(`, `[` and `{` characters so when user types abbreviation that uses attributes or text, it will end with the following state (`|` is caret location):
```
ul>li[title="Foo|"]
```
E.g. caret location is not at the end of abbreviation and must be moved a few characters ahead. The `extract` function is able to handle such cases with `lookAhead` option (enabled by default). This this option enabled, `extract` method automatically detects auto-inserted characters and adjusts location, which will be available as `end` property of the returned result:
```js
import { extract } from 'emmet';
const source = 'a div[title] b';
const loc = 11; // right after "title" word
// `lookAhead` is enabled by default
console.log(extract(source, loc)); // { abbreviation: 'div[title]', start: 2, end: 12 }
console.log(extract(source, loc, { lookAhead: false })); // { abbreviation: 'title', start: 6, end: 11 }
```
By default, `extract` tries to detect _markup_ abbreviations (see above). _stylesheet_ abbreviations has slightly different syntax so in order to extract abbreviations for stylesheet syntaxes like CSS, you should pass `type: 'stylesheet'` option:
```js
import { extract } from 'emmet';
const source = 'a{b}';
const loc = 3; // right after "b"
console.log(extract(source, loc)); // { abbreviation: 'a{b}', start: 0, end: 4 }
// Stylesheet abbreviations does not have `{text}` syntax
console.log(extract(source, loc, { type: 'stylesheet' })); // { abbreviation: 'b', start: 2, end: 3 }
```
### Extract abbreviation with custom prefix
Lots of developers uses React (or similar) library for writing UI code which mixes JS and XML (JSX) in the same source code. Since _any_ Latin word can be used as Emmet abbreviation, writing JSX code with Emmet becomes pain since it will interfere with native editor snippets and distract user with false positive abbreviation matches for variable names, methods etc.:
```js
var div // `div` is a valid abbreviation, Emmet may transform it to `<div></div>`
```
A possible solution for this problem it to use _prefix_ for abbreviation: abbreviation can be successfully extracted only if its preceded with given prefix.
```js
import { extract } from 'emmet';
const source1 = '() => div';
const source2 = '() => <div';
extract(source1, source1.length); // Finds `div` abbreviation
extract(source2, source2.length); // Finds `div` abbreviation too
extract(source1, source1.length, { prefix: '<' }); // No match, `div` abbreviation is not preceded with `<` prefix
extract(source2, source2.length, { prefix: '<' }); // Finds `div` since it preceded with `<` prefix
```
With `prefix` option, you can customize your experience with Emmet in any common syntax (HTML, CSS and so on) if user is distracted too much with Emmet completions for any typed word. A `prefix` may contain multiple character but the last one *must* be a character which is not part of Emmet abbreviation. Good candidates are `<`, `&`, `→` (emoji or Unicode symbol) and so on.

228
node_modules/emmet/dist/config.d.ts generated vendored Normal file
View file

@ -0,0 +1,228 @@
import type { Abbreviation } from '@emmetio/abbreviation';
import type { CSSSnippet } from './stylesheet/snippets.js';
export type SyntaxType = 'markup' | 'stylesheet';
export type FieldOutput = (index: number, placeholder: string, offset: number, line: number, column: number) => string;
export type TextOutput = (text: string, offset: number, line: number, column: number) => string;
export type StringCase = '' | 'lower' | 'upper';
export interface SnippetsMap {
[name: string]: string;
}
export interface AbbreviationContext {
name: string;
attributes?: {
[name: string]: string | null;
};
}
/**
* Raw config which contains per-syntax options. `markup` and `syntax` keys are
* reserved for global settings for all markup and stylesheet syntaxes
*/
export interface GlobalConfig {
[syntax: string]: Partial<BaseConfig>;
}
export interface BaseConfig {
type: SyntaxType;
/** Options for abbreviation output */
options: Partial<Options>;
/** Substitutions for variable names */
variables: SnippetsMap;
/** Abbreviation name to snippets mapping */
snippets: SnippetsMap;
}
interface ResolvedConfig extends BaseConfig {
/** Host syntax */
syntax: string;
/**
* Context of abbreviation. For markup abbreviation, it contains parent tag
* name with attributes, for stylesheet abbreviation it contains property name
* if abbreviation is expanded as value
*/
context?: AbbreviationContext;
/** Text to wrap with abbreviation */
text?: string | string[];
/** Max amount of repeated elements (fool proof) */
maxRepeat?: number;
/**
* Object for storing internal cache data to be shared across Emmet methods
* invocation. If provided, Emmet will store compute-intensive data in this
* object and will re-use it during editor session.
* Every time user settings are changed, you should empty cache by passing
* new object.
*/
cache?: Cache;
}
export type Config = ResolvedConfig & {
options: Options;
};
export type UserConfig = Partial<ResolvedConfig>;
export interface Cache {
stylesheetSnippets?: CSSSnippet[];
markupSnippets?: {
[name: string]: Abbreviation | null;
};
}
export interface Options {
/** A list of inline-level elements */
inlineElements: string[];
/** A string for one level indent */
'output.indent': string;
/**
* A string for base indent, e.g. context indentation which will be added
* for every generated line
*/
'output.baseIndent': string;
/** A string to use as a new line */
'output.newline': string;
/** Tag case: lower, upper or '' (keep as-is) */
'output.tagCase': StringCase;
/** Attribute name case: lower, upper or '' (keep as-is) */
'output.attributeCase': StringCase;
/** Attribute value quotes: 'single' or 'double' */
'output.attributeQuotes': 'single' | 'double';
/** Enable output formatting (indentation and line breaks) */
'output.format': boolean;
/** When enabled, automatically adds inner line breaks for leaf (e.g. without children) nodes */
'output.formatLeafNode': boolean;
/** A list of tag names that should not get inner indentation */
'output.formatSkip': string[];
/** A list of tag names that should *always* get inner indentation. */
'output.formatForce': string[];
/**
* How many inline sibling elements should force line break for each tag.
* Set to `0` to output all inline elements without formatting.
* Set to `1` to output all inline elements with formatting (same as block-level).
*/
'output.inlineBreak': number;
/**
* Produce compact notation of boolean attributes: attributes which doesnt have value.
* With this option enabled, outputs `<div contenteditable>` instead of
* `<div contenteditable="contenteditable">`
*/
'output.compactBoolean': boolean;
/** A list of boolean attributes */
'output.booleanAttributes': string[];
/** Reverses attribute merging directions when resolving snippets */
'output.reverseAttributes': boolean;
/** Style of self-closing tags: html (`<br>`), xml (`<br/>`) or xhtml (`<br />`) */
'output.selfClosingStyle': 'html' | 'xml' | 'xhtml';
/**
* A function that takes field index and optional placeholder and returns
* a string field (tabstop) for host editor. For example, a TextMate-style
* field is `$index` or `${index:placeholder}`
* @param index Field index
* @param placeholder Field placeholder (default value), if any
* @param offset Current character offset from the beginning of generated content
* @param line Current line of generated output
* @param column Current column in line
*/
'output.field': FieldOutput;
/**
* A function for processing text chunk passed to `OutputStream`.
* May be used by editor for escaping characters, if necessary
*/
'output.text': TextOutput;
/**
* Automatically update value of <a> element's href attribute
* if inserting URL or email
*/
'markup.href': boolean;
/**
* Attribute name mapping. Can be used to change attribute names for output.
* For example, `class` -> `className` in JSX. If a key ends with `*`, this
* value will be used for multi-attributes: currentry, its a `class` and `id`
* since `multiple` marker is added for shorthand attributes only.
* Example: `{ "class*": "styleName" }`
*/
'markup.attributes'?: Record<string, string>;
/**
* Prefixes for attribute values.
* If specified, a value is treated as prefix for object notation and
* automatically converts attribute value into expression if `jsx` is enabled.
* Same as in `markup.attributes` option, a `*` can be used.
*/
'markup.valuePrefix'?: Record<string, string>;
/**
* Enable/disable element commenting: generate comments before open and/or
* after close tag
*/
'comment.enabled': boolean;
/**
* Attributes that should trigger node commenting on specific node,
* if commenting is enabled
*/
'comment.trigger': string[];
/**
* Template string for comment to be placed *before* opening tag
*/
'comment.before': string;
/**
* Template string for comment to be placed *after* closing tag.
* Example: `\n<!-- /[#ID][.CLASS] -->`
*/
'comment.after': string;
/** Enable/disable BEM addon */
'bem.enabled': boolean;
/** A string for separating elements in output class */
'bem.element': string;
/** A string for separating modifiers in output class */
'bem.modifier': string;
/** Enable/disable JSX addon */
'jsx.enabled': boolean;
/** List of globally available keywords for properties */
'stylesheet.keywords': string[];
/**
* List of unitless properties, e.g. properties where numeric values without
* explicit unit will be outputted as is, without default value
*/
'stylesheet.unitless': string[];
/** Use short hex notation where possible, e.g. `#000` instead of `#000000` */
'stylesheet.shortHex': boolean;
/** A string between property name and value */
'stylesheet.between': string;
/** A string after property value */
'stylesheet.after': string;
/** A unit suffix to output by default after integer values, 'px' by default */
'stylesheet.intUnit': string;
/** A unit suffix to output by default after float values, 'em' by default */
'stylesheet.floatUnit': string;
/**
* Aliases for custom units in abbreviation. For example, `r: 'rem'` will
* output `10rem` for abbreviation `10r`
*/
'stylesheet.unitAliases': SnippetsMap;
/** Output abbreviation as JSON object properties (for CSS-in-JS syntaxes) */
'stylesheet.json': boolean;
/** Use double quotes for JSON values */
'stylesheet.jsonDoubleQuotes': boolean;
/**
* A float number between 0 and 1 to pick fuzzy-matched abbreviations.
* Lower value will pick more abbreviations (and less accurate)
*/
'stylesheet.fuzzySearchMinScore': number;
}
/**
* Default syntaxes for abbreviation types
*/
export declare const defaultSyntaxes: {
[name in SyntaxType]: string;
};
/**
* List of all known syntaxes
*/
export declare const syntaxes: {
markup: string[];
stylesheet: string[];
};
export declare const defaultOptions: Options;
export declare const defaultConfig: Config;
/**
* Default per-syntax config
*/
export declare const syntaxConfig: GlobalConfig;
/**
* Parses raw snippets definitions with possibly multiple keys into a plan
* snippet map
*/
export declare function parseSnippets(snippets: SnippetsMap): SnippetsMap;
export default function resolveConfig(config?: UserConfig, globals?: GlobalConfig): Config;
export {};

5368
node_modules/emmet/dist/emmet.cjs generated vendored Normal file

File diff suppressed because it is too large Load diff

1
node_modules/emmet/dist/emmet.cjs.map generated vendored Normal file

File diff suppressed because one or more lines are too long

5352
node_modules/emmet/dist/emmet.es.js generated vendored Normal file

File diff suppressed because it is too large Load diff

1
node_modules/emmet/dist/emmet.es.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,13 @@
export declare const enum Brackets {
SquareL = 91,
SquareR = 93,
RoundL = 40,
RoundR = 41,
CurlyL = 123,
CurlyR = 125
}
export declare const bracePairs: {
91: Brackets;
40: Brackets;
123: Brackets;
};

View file

@ -0,0 +1,44 @@
import type { SyntaxType } from '../config.js';
export interface ExtractOptions {
/**
* Allow parser to look ahead of `pos` index for searching of missing
* abbreviation parts. Most editors automatically inserts closing braces for
* `[`, `{` and `(`, which will most likely be right after current caret position.
* So in order to properly expand abbreviation, user must explicitly move
* caret right after auto-inserted braces. With this option enabled, parser
* will search for closing braces right after `pos`. Default is `true`
*/
lookAhead: boolean;
/**
* Type of context syntax of expanded abbreviation.
* In 'stylesheet' syntax, brackets `[]` and `{}` are not supported thus
* not extracted.
*/
type: SyntaxType;
/**
* A string that should precede abbreviation in order to make it successfully
* extracted. If given, the abbreviation will be extracted from the nearest
* `prefix` occurrence.
*/
prefix: string;
}
export interface ExtractedAbbreviation {
/** Extracted abbreviation */
abbreviation: string;
/** Location of abbreviation in input string */
location: number;
/** Start location of matched abbreviation, including prefix */
start: number;
/** End location of extracted abbreviation */
end: number;
}
/**
* Extracts Emmet abbreviation from given string.
* The goal of this module is to extract abbreviation from current editors line,
* e.g. like this: `<span>.foo[title=bar|]</span>` -> `.foo[title=bar]`, where
* `|` is a current caret position.
* @param line A text line where abbreviation should be expanded
* @param pos Caret position in line. If not given, uses end of line
* @param options Extracting options
*/
export default function extractAbbreviation(line: string, pos?: number, options?: Partial<ExtractOptions>): ExtractedAbbreviation | undefined;

View file

@ -0,0 +1,5 @@
import { BackwardScanner } from './reader.js';
/**
* Check if given readers current position points at the end of HTML tag
*/
export default function isHtml(scanner: BackwardScanner): boolean;

View file

@ -0,0 +1,10 @@
import { BackwardScanner } from './reader.js';
/**
* Check if given character code is a quote
*/
export declare function isQuote(c?: number): boolean;
/**
* Consumes quoted value, if possible
* @return Returns `true` is value was consumed
*/
export declare function consumeQuoted(scanner: BackwardScanner): boolean;

View file

@ -0,0 +1,31 @@
type Match = ((code: number) => boolean) | number;
export interface BackwardScanner {
/** Text to scan */
text: string;
/** Left bound till given text must be scanned */
start: number;
/** Current scanner position */
pos: number;
}
/**
* Creates structure for scanning given string in backward direction
*/
export default function backwardScanner(text: string, start?: number): BackwardScanner;
/**
* Check if given scanner position is at start of scanned text
*/
export declare function sol(scanner: BackwardScanner): boolean;
/**
* Peeks character code an current scanner location without advancing it
*/
export declare function peek(scanner: BackwardScanner, offset?: number): number;
/**
* Returns current character code and moves character location one symbol back
*/
export declare function previous(scanner: BackwardScanner): number | undefined;
/**
* Consumes current character code if it matches given `match` code or function
*/
export declare function consume(scanner: BackwardScanner, match: Match): boolean;
export declare function consumeWhile(scanner: BackwardScanner, match: Match): boolean;
export {};

23
node_modules/emmet/dist/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,23 @@
import markupAbbreviation, { type Abbreviation } from '@emmetio/abbreviation';
import stylesheetAbbreviation, { type CSSAbbreviation } from '@emmetio/css-abbreviation';
import parseMarkup, { stringify as stringifyMarkup } from './markup/index.js';
import parseStylesheet, { stringify as stringifyStylesheet, convertSnippets as parseStylesheetSnippets, CSSAbbreviationScope } from './stylesheet/index.js';
import { type UserConfig, type Config } from './config.js';
export default function expandAbbreviation(abbr: string, config?: UserConfig): string;
/**
* Expands given *markup* abbreviation (e.g. regular Emmet abbreviation that
* produces structured output like HTML) and outputs it according to options
* provided in config
*/
export declare function markup(abbr: string | Abbreviation, config: Config): string;
/**
* Expands given *stylesheet* abbreviation (a special Emmet abbreviation designed for
* stylesheet languages like CSS, SASS etc.) and outputs it according to options
* provided in config
*/
export declare function stylesheet(abbr: string | CSSAbbreviation, config: Config): string;
export { markupAbbreviation, parseMarkup, stringifyMarkup, stylesheetAbbreviation, parseStylesheet, stringifyStylesheet, parseStylesheetSnippets, CSSAbbreviationScope };
export type { Abbreviation as MarkupAbbreviation, CSSAbbreviation as StylesheetAbbreviation, };
export { default as extract, type ExtractOptions, type ExtractedAbbreviation } from './extract-abbreviation/index.js';
export { default as resolveConfig } from './config.js';
export type { GlobalConfig, SyntaxType, Config, UserConfig, Options, AbbreviationContext } from './config.js';

4
node_modules/emmet/dist/markup/addon/bem.d.ts generated vendored Normal file
View file

@ -0,0 +1,4 @@
import type { AbbreviationNode } from '@emmetio/abbreviation';
import type { Container } from '../utils.js';
import type { Config } from '../../config.js';
export default function bem(node: AbbreviationNode, ancestors: Container[], config: Config): void;

6
node_modules/emmet/dist/markup/addon/xsl.d.ts generated vendored Normal file
View file

@ -0,0 +1,6 @@
import type { AbbreviationNode } from '@emmetio/abbreviation';
/**
* XSL transformer: removes `select` attributes from certain nodes that contain
* children
*/
export default function xsl(node: AbbreviationNode): void;

7
node_modules/emmet/dist/markup/attributes.d.ts generated vendored Normal file
View file

@ -0,0 +1,7 @@
import type { AbbreviationNode } from '@emmetio/abbreviation';
import type { Config } from '../config.js';
/**
* Merges attributes in current node: de-duplicates attributes with the same name
* and merges class names
*/
export default function mergeAttributes(node: AbbreviationNode, config: Config): void;

19
node_modules/emmet/dist/markup/format/comment.d.ts generated vendored Normal file
View file

@ -0,0 +1,19 @@
import type { AbbreviationNode } from '@emmetio/abbreviation';
import { type TemplateToken } from './template.js';
import { Config } from '../../config.js';
import { HTMLWalkState } from './html.js';
export interface CommentWalkState {
enabled: boolean;
trigger: string[];
before?: TemplateToken[];
after?: TemplateToken[];
}
export declare function createCommentState(config: Config): CommentWalkState;
/**
* Adds comment prefix for given node, if required
*/
export declare function commentNodeBefore(node: AbbreviationNode, state: HTMLWalkState): void;
/**
* Adds comment suffix for given node, if required
*/
export declare function commentNodeAfter(node: AbbreviationNode, state: HTMLWalkState): void;

3
node_modules/emmet/dist/markup/format/haml.d.ts generated vendored Normal file
View file

@ -0,0 +1,3 @@
import type { Abbreviation } from '@emmetio/abbreviation';
import type { Config } from '../../config.js';
export default function haml(abbr: Abbreviation, config: Config): string;

11
node_modules/emmet/dist/markup/format/html.d.ts generated vendored Normal file
View file

@ -0,0 +1,11 @@
import type { Abbreviation, AbbreviationNode } from '@emmetio/abbreviation';
import { type WalkState } from './walk.js';
import { type CommentWalkState } from './comment.js';
import type { Config } from '../../config.js';
type WalkNext = (node: AbbreviationNode, index: number, items: AbbreviationNode[]) => void;
export interface HTMLWalkState extends WalkState {
comment: CommentWalkState;
}
export default function html(abbr: Abbreviation, config: Config): string;
export declare function pushSnippet(node: AbbreviationNode, state: WalkState, next: WalkNext): boolean;
export {};

View file

@ -0,0 +1,64 @@
import type { AbbreviationNode, AbbreviationAttribute, Abbreviation } from '@emmetio/abbreviation';
import { WalkState, type WalkNext } from './walk.js';
import type { Config } from '../../config.js';
/**
* @description Utility methods for working with indent-based markup languages
* like HAML, Slim, Pug etc.
*/
interface AttributesCollection {
/** Primary element attributes: `id` and `class` */
primary: AbbreviationAttribute[];
/** Secondary element attributes: everything except `id` and `class` */
secondary: AbbreviationAttribute[];
}
export interface IndentWalkState extends WalkState {
options: FormatOptions;
}
export interface FormatOptions {
/** String to output before tag name */
beforeName?: string;
/** String to output after tag name */
afterName?: string;
/** String to output before secondary attribute set */
beforeAttribute?: string;
/** String to output after secondary attribute set */
afterAttribute?: string;
/** String to put between secondary attributes */
glueAttribute?: string;
/** Value for boolean attributes */
booleanValue?: string;
/** String to put before content line (if value is multiline) */
beforeTextLine?: string;
/** String to put after content line (if value is multiline) */
afterTextLine?: string;
/** String to put after self-closing elements like `br`. Mostly a `/` character */
selfClose?: string;
}
export default function indentFormat(abbr: Abbreviation, config: Config, options?: Partial<FormatOptions>): string;
/**
* Outputs `node` content to output stream of `state`
* @param node Context node
* @param index Index of `node` in `items`
* @param items List of `node`s siblings
* @param state Current walk state
*/
export declare function element(node: AbbreviationNode, index: number, items: AbbreviationNode[], state: IndentWalkState, next: WalkNext): void;
/**
* From given node, collects all attributes as `primary` (id, class) and
* `secondary` (all the rest) lists. In most indent-based syntaxes, primary attribute
* has special syntax
*/
export declare function collectAttributes(node: AbbreviationNode): AttributesCollection;
/**
* Outputs given attributes as primary into output stream
*/
export declare function pushPrimaryAttributes(attrs: AbbreviationAttribute[], state: WalkState): void;
/**
* Outputs given attributes as secondary into output stream
*/
export declare function pushSecondaryAttributes(attrs: AbbreviationAttribute[], state: IndentWalkState): void;
/**
* Outputs given node value into state output stream
*/
export declare function pushValue(node: AbbreviationNode, state: IndentWalkState): void;
export {};

3
node_modules/emmet/dist/markup/format/pug.d.ts generated vendored Normal file
View file

@ -0,0 +1,3 @@
import type { Abbreviation } from '@emmetio/abbreviation';
import type { Config } from '../../config.js';
export default function pug(abbr: Abbreviation, config: Config): string;

3
node_modules/emmet/dist/markup/format/slim.d.ts generated vendored Normal file
View file

@ -0,0 +1,3 @@
import type { Abbreviation } from '@emmetio/abbreviation';
import type { Config } from '../../config.js';
export default function slim(abbr: Abbreviation, config: Config): string;

15
node_modules/emmet/dist/markup/format/template.d.ts generated vendored Normal file
View file

@ -0,0 +1,15 @@
export type TemplateToken = string | TemplatePlaceholder;
export interface TemplatePlaceholder {
before: string;
after: string;
name: string;
}
/**
* Splits given string into template tokens.
* Template is a string which contains placeholders which are uppercase names
* between `[` and `]`, for example: `[PLACEHOLDER]`.
* Unlike other templates, a placeholder may contain extra characters before and
* after name: `[%PLACEHOLDER.]`. If data for `PLACEHOLDER` is defined, it will
* be outputted with with these extra character, otherwise will be completely omitted.
*/
export default function template(text: string): TemplateToken[];

27
node_modules/emmet/dist/markup/format/utils.d.ts generated vendored Normal file
View file

@ -0,0 +1,27 @@
import type { AbbreviationNode, Field, Value, AbbreviationAttribute } from '@emmetio/abbreviation';
import type { WalkState } from './walk.js';
import type { Config } from '../../config.js';
export declare const caret: Field[];
/**
* Check if given node is a snippet: a node without name and attributes
*/
export declare function isSnippet(node?: AbbreviationNode): boolean;
/**
* Check if given node is inline-level element, e.g. element with explicitly
* defined node name
*/
export declare function isInlineElement(node: AbbreviationNode | undefined, config: Config): boolean;
/**
* Check if given value token is a field
*/
export declare function isField(token: Value): token is Field;
export declare function pushTokens(tokens: Value[], state: WalkState): void;
/**
* Splits given value token by lines: returns array where each entry is a token list
* for a single line
*/
export declare function splitByLines(tokens: Value[]): Value[][];
/**
* Check if given attribute should be outputted
*/
export declare function shouldOutputAttribute(attr: AbbreviationAttribute): boolean;

21
node_modules/emmet/dist/markup/format/walk.d.ts generated vendored Normal file
View file

@ -0,0 +1,21 @@
import type { AbbreviationNode, Abbreviation } from '@emmetio/abbreviation';
import { type OutputStream } from '../../output-stream.js';
import type { Config } from '../../config.js';
export type WalkNext = (node: AbbreviationNode, index: number, items: AbbreviationNode[]) => void;
export type Visitor<S extends WalkState> = (node: AbbreviationNode, index: number, items: AbbreviationNode[], state: S, next: WalkNext) => void;
export interface WalkState {
/** Context node */
current: AbbreviationNode;
/** Immediate parent of currently iterated method */
parent?: AbbreviationNode;
/** List of all ancestors of context node */
ancestors: AbbreviationNode[];
/** Current output config */
config: Config;
/** Output stream */
out: OutputStream;
/** Current field index, used to output field marks for editor tabstops */
field: number;
}
export default function walk<S extends WalkState>(abbr: Abbreviation, visitor: Visitor<S>, state: S): void;
export declare function createWalkState(config: Config): WalkState;

5
node_modules/emmet/dist/markup/implicit-tag.d.ts generated vendored Normal file
View file

@ -0,0 +1,5 @@
import type { AbbreviationNode } from '@emmetio/abbreviation';
import { type Container } from './utils.js';
import type { Config } from '../config.js';
export default function implicitTag(node: AbbreviationNode, ancestors: Container[], config: Config): void;
export declare function resolveImplicitTag(node: AbbreviationNode, ancestors: Container[], config: Config): void;

11
node_modules/emmet/dist/markup/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,11 @@
import type { Abbreviation } from '@emmetio/abbreviation';
import type { Config } from '../config.js';
/**
* Parses given Emmet abbreviation into a final abbreviation tree with all
* required transformations applied
*/
export default function parse(abbr: string | Abbreviation, config: Config): Abbreviation;
/**
* Converts given abbreviation to string according to provided `config`
*/
export declare function stringify(abbr: Abbreviation, config: Config): string;

4
node_modules/emmet/dist/markup/lorem/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,4 @@
import type { AbbreviationNode } from '@emmetio/abbreviation';
import type { Container } from '../utils.js';
import type { Config } from '../../config.js';
export default function lorem(node: AbbreviationNode, ancestors: Container[], config: Config): void;

12
node_modules/emmet/dist/markup/snippets.d.ts generated vendored Normal file
View file

@ -0,0 +1,12 @@
import type { Abbreviation } from '@emmetio/abbreviation';
import type { Config } from '../config.js';
/**
* Finds matching snippet from `registry` and resolves it into a parsed abbreviation.
* Resolved node is then updated or replaced with matched abbreviation tree.
*
* A HTML registry basically contains aliases to another Emmet abbreviations,
* e.g. a predefined set of name, attributes and so on, possibly a complex
* abbreviation with multiple elements. So we have to get snippet, parse it
* and recursively resolve it.
*/
export default function resolveSnippets(abbr: Abbreviation, config: Config): Abbreviation;

18
node_modules/emmet/dist/markup/utils.d.ts generated vendored Normal file
View file

@ -0,0 +1,18 @@
import type { Abbreviation, AbbreviationNode } from '@emmetio/abbreviation';
export type Container = Abbreviation | AbbreviationNode;
export type WalkVisitor<S> = (node: AbbreviationNode, ancestors: Container[], state?: S) => void;
/**
* Walks over each child node of given markup abbreviation AST node (not including
* given one) and invokes `fn` on each node.
* The `fn` callback accepts context node, list of ancestor nodes and optional
* state object
*/
export declare function walk<S>(node: Container, fn: WalkVisitor<S>, state?: S): void;
/**
* Finds node which is the deepest for in current node or node itself.
*/
export declare function findDeepest(node: Container): {
node: Container;
parent?: Container;
};
export declare function isNode(node: Container): node is AbbreviationNode;

62
node_modules/emmet/dist/output-stream.d.ts generated vendored Normal file
View file

@ -0,0 +1,62 @@
import type { AbbreviationAttribute, AbbreviationNode } from '@emmetio/abbreviation';
import type { Config, Options } from './config.js';
export interface OutputStream {
options: Options;
value: string;
level: number;
offset: number;
line: number;
column: number;
}
export declare const expressionStart = "{";
export declare const expressionEnd = "}";
export default function createOutputStream(options: Options, level?: number): OutputStream;
/**
* Pushes plain string into output stream without newline processing
*/
export declare function push(stream: OutputStream, text: string): void;
/**
* Pushes given string with possible newline formatting into output
*/
export declare function pushString(stream: OutputStream, value: string): void;
/**
* Pushes new line into given output stream
*/
export declare function pushNewline(stream: OutputStream, indent?: boolean | number): void;
/**
* Adds indentation of `size` to current output stream
*/
export declare function pushIndent(stream: OutputStream, size?: number): void;
/**
* Pushes field/tabstop into output stream
*/
export declare function pushField(stream: OutputStream, index: number, placeholder: string): void;
/**
* Returns given tag name formatted according to given config
*/
export declare function tagName(name: string, config: Config): string;
/**
* Returns given attribute name formatted according to given config
*/
export declare function attrName(name: string, config: Config): string;
/**
* Returns character for quoting value of given attribute
*/
export declare function attrQuote(attr: AbbreviationAttribute, config: Config, isOpen?: boolean): string;
/**
* Check if given attribute is boolean
*/
export declare function isBooleanAttribute(attr: AbbreviationAttribute, config: Config): boolean;
/**
* Returns a token for self-closing tag, depending on current options
*/
export declare function selfClose(config: Config): string;
/**
* Check if given tag name belongs to inline-level element
* @param node Parsed node or tag name
*/
export declare function isInline(node: string | AbbreviationNode, config: Config): boolean;
/**
* Splits given text by lines
*/
export declare function splitByLines(text: string): string[];

8
node_modules/emmet/dist/stylesheet/color.d.ts generated vendored Normal file
View file

@ -0,0 +1,8 @@
import type { ColorValue } from '@emmetio/css-abbreviation';
export default function color(token: ColorValue, shortHex?: boolean): string;
/**
* Output given color as hex value
* @param short Produce short value (e.g. #fff instead of #ffffff), if possible
*/
export declare function asHex(token: ColorValue, short?: boolean): string;
export declare function frac(num: number, digits?: number): string;

13
node_modules/emmet/dist/stylesheet/format.d.ts generated vendored Normal file
View file

@ -0,0 +1,13 @@
import { CSSAbbreviation } from '@emmetio/css-abbreviation';
import { Config } from '../config.js';
export declare const CSSAbbreviationScope: {
/** Include all possible snippets in match */
readonly Global: "@@global";
/** Include raw snippets only (e.g. no properties) in abbreviation match */
readonly Section: "@@section";
/** Include properties only in abbreviation match */
readonly Property: "@@property";
/** Resolve abbreviation in context of CSS property value */
readonly Value: "@@value";
};
export default function css(abbr: CSSAbbreviation, config: Config): string;

21
node_modules/emmet/dist/stylesheet/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,21 @@
import type { CSSAbbreviation } from '@emmetio/css-abbreviation';
import { Config, SnippetsMap } from '../config.js';
import type { CSSSnippet } from './snippets.js';
export { default as stringify, CSSAbbreviationScope } from './format.js';
type MatchInput = CSSSnippet | string;
/**
* Parses given Emmet abbreviation into a final abbreviation tree with all
* required transformations applied
*/
export default function parse(abbr: string | CSSAbbreviation, config: Config): CSSAbbreviation;
/**
* Converts given raw snippets into internal snippets representation
*/
export declare function convertSnippets(snippets: SnippetsMap): CSSSnippet[];
/**
* Finds best matching item from `items` array
* @param abbr Abbreviation to match
* @param items List of items for match
* @param minScore The minimum score the best matched item should have to be a valid match.
*/
export declare function findBestMatch<T extends MatchInput>(abbr: string, items: T[], minScore?: number, partialMatch?: boolean): T | null;

11
node_modules/emmet/dist/stylesheet/score.d.ts generated vendored Normal file
View file

@ -0,0 +1,11 @@
/**
* Calculates how close `str1` matches `str2` using fuzzy match.
* How matching works:
* first characters of both `str1` and `str2` *must* match
* `str1` length larger than `str2` length is allowed only when `unmatched` is true
* ideal match is when `str1` equals to `str2` (score: 1)
* next best match is `str2` starts with `str1` (score: 1 × percent of matched characters)
* other scores depend on how close characters of `str1` to the beginning of `str2`
* @param partialMatch Allow length `str1` to be greater than `str2` length
*/
export default function scoreMatch(str1: string, str2: string, partialMatch?: boolean): number;

34
node_modules/emmet/dist/stylesheet/snippets.d.ts generated vendored Normal file
View file

@ -0,0 +1,34 @@
import type { CSSValue, FunctionCall, Literal } from '@emmetio/css-abbreviation';
export type CSSSnippet = CSSSnippetRaw | CSSSnippetProperty;
interface KeywordMap {
[name: string]: FunctionCall | Literal;
}
export declare const enum CSSSnippetType {
Raw = "Raw",
Property = "Property"
}
interface CSSSnippetBase {
type: CSSSnippetType;
key: string;
}
export interface CSSSnippetRaw extends CSSSnippetBase {
type: CSSSnippetType.Raw;
value: string;
}
export interface CSSSnippetProperty extends CSSSnippetBase {
type: CSSSnippetType.Property;
property: string;
value: CSSValue[][];
keywords: KeywordMap;
dependencies: CSSSnippetProperty[];
}
/**
* Creates structure for holding resolved CSS snippet
*/
export default function createSnippet(key: string, value: string): CSSSnippet;
/**
* Nests more specific CSS properties into shorthand ones, e.g.
* `background-position-x` -> `background-position` -> `background`
*/
export declare function nest(snippets: CSSSnippet[]): CSSSnippet[];
export {};

64
node_modules/emmet/package.json generated vendored Normal file
View file

@ -0,0 +1,64 @@
{
"name": "emmet",
"version": "2.4.5",
"description": "Emmet — the essential toolkit for web-developers",
"main": "./dist/emmet.cjs",
"module": "./dist/emmet.es.js",
"types": "./dist/index.d.ts",
"type": "module",
"exports": {
"import": "./dist/emmet.es.js",
"require": "./dist/emmet.cjs"
},
"scripts": {
"build": "rollup -c",
"watch": "rollup -wc",
"test": "mocha",
"clean": "rimraf ./dist",
"prepare": "npm run clean && lerna run build && lerna run test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/emmetio/emmet.git"
},
"keywords": [
"emmet",
"html",
"css",
"snippets",
"coding"
],
"author": "Sergey Chikuyonok <serge.che@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/emmetio/emmet/issues"
},
"homepage": "https://github.com/emmetio/emmet#readme",
"dependencies": {
"@emmetio/abbreviation": "^2.3.3",
"@emmetio/css-abbreviation": "^2.1.8"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-typescript": "^10.0.1",
"@types/mocha": "^10.0.1",
"@types/node": "^18.11.18",
"lerna": "^6.5.1",
"mocha": "^10.2.0",
"rimraf": "^5.0.0",
"rollup": "^3.9.0",
"ts-node": "^10.9.1",
"typescript": "^4.9.4"
},
"workspaces": [
"./packages/scanner",
"./packages/abbreviation",
"./packages/css-abbreviation",
"./"
],
"mocha": {
"loader": "ts-node/esm",
"spec": "./test/*.ts"
},
"gitHead": "a602caf5d2a8654da7d9b179b64c5a72c7317ea1"
}