Clean up dependencies
All checks were successful
Build and Push / build (push) Successful in 18s

This commit is contained in:
2026-02-16 15:12:59 -05:00
parent d181f77fb2
commit 2f15523a55
14941 changed files with 0 additions and 2078483 deletions

View File

@@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) Microsoft
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

@@ -1,11 +0,0 @@
# vscode-emmet-helper
A helper module to use emmet modules with Visual Studio Code
Visual Studio Code extensions that provide language service and want to provide emmet abbreviation expansions
in auto-complete can include this module and use the `doComplete` method.
Just pass the one of the emmet supported syntaxes that you would like the completion provider to use along with other parameters that you would generally pass to a completion provider.
If `emmet.includeLanguages` has a mapping for your language, then the builit-in emmet extension will provide
html emmet abbreviations. Ask the user to remove the mapping, if your extension decides to provide
emmet completions using this module

View File

@@ -1,41 +0,0 @@
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.5 BLOCK -->
## Security
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)), please report it to us as described below.
## Reporting Security Issues
**Please do not report security vulnerabilities through public GitHub issues.**
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report).
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc).
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
* Full paths of source file(s) related to the manifestation of the issue
* The location of the affected source code (tag/branch/commit or direct URL)
* Any special configuration required to reproduce the issue
* Step-by-step instructions to reproduce the issue
* Proof-of-concept or exploit code (if possible)
* Impact of the issue, including how an attacker might exploit the issue
This information will help us triage your report more quickly.
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs.
## Preferred Languages
We prefer all communications to be in English.
## Policy
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd).
<!-- END MICROSOFT SECURITY.MD BLOCK -->

View File

@@ -1,15 +0,0 @@
export interface SnippetsMap {
[name: string]: string;
}
/**
* Parses raw snippets definitions with possibly multiple keys into a plan
* snippet map
*/
export declare function parseSnippets(snippets: SnippetsMap): SnippetsMap;
/**
* List of all known syntaxes
*/
export declare const syntaxes: {
markup: string[];
stylesheet: string[];
};

View File

@@ -1,48 +0,0 @@
"use strict";
/*
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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.syntaxes = void 0;
exports.parseSnippets = parseSnippets;
/**
* Parses raw snippets definitions with possibly multiple keys into a plan
* snippet map
*/
function parseSnippets(snippets) {
const result = {};
Object.keys(snippets).forEach(k => {
for (const name of k.split('|')) {
result[name] = snippets[k];
}
});
return result;
}
/**
* List of all known syntaxes
*/
exports.syntaxes = {
markup: ['html', 'xml', 'xsl', 'jsx', 'js', 'pug', 'slim', 'haml', 'vue'],
stylesheet: ['css', 'sass', 'scss', 'less', 'sss', 'stylus']
};
//# sourceMappingURL=configCompat.js.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"configCompat.js","sourceRoot":"","sources":["../../src/configCompat.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;EAsBE;;;AAUF,sCASC;AAbD;;;GAGG;AACH,SAAgB,aAAa,CAAC,QAAqB;IAC/C,MAAM,MAAM,GAAgB,EAAE,CAAC;IAC/B,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;QAC9B,KAAK,MAAM,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YAC9B,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;GAEG;AACU,QAAA,QAAQ,GAAG;IACpB,MAAM,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC;IACzE,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC;CAC/D,CAAC"}

View File

@@ -1,6 +0,0 @@
export declare const cssData: {
properties: string[];
};
export declare const htmlData: {
tags: string[];
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,103 +0,0 @@
import { TextDocument } from 'vscode-languageserver-textdocument';
import { CompletionList, Position, Range } from 'vscode-languageserver-types';
import { URI } from 'vscode-uri';
import { FileService, FileStat, FileType } from './fileService';
import { ExtractOptions, MarkupAbbreviation, Options, StylesheetAbbreviation, SyntaxType, UserConfig } from 'emmet';
import { SnippetsMap } from './configCompat';
export { FileService, FileType, FileStat };
/**
* Emmet configuration as derived from the Emmet related VS Code settings
*/
export interface VSCodeEmmetConfig {
showExpandedAbbreviation?: string;
showAbbreviationSuggestions?: boolean;
syntaxProfiles?: object;
variables?: object;
preferences?: object;
excludeLanguages?: string[];
showSuggestionsAsSnippets?: boolean;
}
/**
* Returns all applicable emmet expansions for abbreviation at given position in a CompletionList
* @param document TextDocument in which completions are requested
* @param position Position in the document at which completions are requested
* @param syntax Emmet supported language
* @param emmetConfig Emmet Configurations as derived from VS Code
*/
export declare function doComplete(document: TextDocument, position: Position, syntax: string, emmetConfig: VSCodeEmmetConfig): CompletionList | undefined;
export declare const emmetSnippetField: (index: number, placeholder: string) => string;
/** Returns whether or not syntax is a supported stylesheet syntax, like CSS */
export declare function isStyleSheet(syntax: string): boolean;
/** Returns the syntax type, either markup (e.g. for HTML) or stylesheet (e.g. for CSS) */
export declare function getSyntaxType(syntax: string): SyntaxType;
/** Returns the default syntax (html or css) to use for the snippets registry */
export declare function getDefaultSyntax(syntax: string): string;
/** Returns the default snippets that Emmet suggests */
export declare function getDefaultSnippets(syntax: string): SnippetsMap;
/**
* Extracts abbreviation from the given position in the given document
* @param document The TextDocument from which abbreviation needs to be extracted
* @param position The Position in the given document from where abbreviation needs to be extracted
* @param options The options to pass to the @emmetio/extract-abbreviation module
*/
export declare function extractAbbreviation(document: TextDocument, position: Position, options?: Partial<ExtractOptions>): {
abbreviation: string;
abbreviationRange: Range;
filter: string | undefined;
} | undefined;
/**
* Extracts abbreviation from the given text
* @param text Text from which abbreviation needs to be extracted
* @param syntax Syntax used to extract the abbreviation from the given text
*/
export declare function extractAbbreviationFromText(text: string, syntax: string): {
abbreviation: string;
filter: string | undefined;
} | undefined;
/**
* Returns a boolean denoting validity of given abbreviation in the context of given syntax
* Not needed once https://github.com/emmetio/atom-plugin/issues/22 is fixed
* @param syntax string
* @param abbreviation string
*/
export declare function isAbbreviationValid(syntax: string, abbreviation: string): boolean;
type ExpandOptionsConfig = {
type: SyntaxType;
options: Partial<Options>;
variables: SnippetsMap;
snippets: SnippetsMap;
syntax: string;
text: string | string[] | undefined;
maxRepeat: number;
};
/**
* Returns options to be used by emmet
*/
export declare function getExpandOptions(syntax: string, emmetConfig?: VSCodeEmmetConfig, filter?: string): ExpandOptionsConfig;
/**
* Parses given abbreviation using given options and returns a tree
* @param abbreviation string
* @param options options used by the emmet module to parse given abbreviation
*/
export declare function parseAbbreviation(abbreviation: string, options: UserConfig): StylesheetAbbreviation | MarkupAbbreviation;
/**
* Expands given abbreviation using given options
* @param abbreviation string or parsed abbreviation
* @param config options used by the @emmetio/expand-abbreviation module to expand given abbreviation
*/
export declare function expandAbbreviation(abbreviation: string | MarkupAbbreviation | StylesheetAbbreviation, config: UserConfig): string;
/**
* Updates customizations from snippets.json and syntaxProfiles.json files in the directory configured in emmet.extensionsPath setting
* @param emmetExtensionsPathSetting setting passed from emmet.extensionsPath. Supports multiple paths
*/
export declare function updateExtensionsPath(emmetExtensionsPathSetting: string[], fs: FileService, workspaceFolderPaths?: URI[], homeDir?: URI): Promise<void>;
/**
* Get the corresponding emmet mode for given vscode language mode
* Eg: jsx for typescriptreact/javascriptreact or pug for jade
* If the language is not supported by emmet or has been exlcuded via `exlcudeLanguages` setting,
* then nothing is returned
*
* @param language
* @param exlcudedLanguages Array of language ids that user has chosen to exlcude for emmet
*/
export declare function getEmmetMode(language: string, excludedLanguages?: string[]): string | undefined;

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,46 +0,0 @@
import { URI as Uri } from 'vscode-uri';
export declare enum FileType {
/**
* The file type is unknown.
*/
Unknown = 0,
/**
* A regular file.
*/
File = 1,
/**
* A directory.
*/
Directory = 2,
/**
* A symbolic link to a file.
*/
SymbolicLink = 64
}
export interface FileStat {
/**
* The type of the file, e.g. is a regular file, a directory, or symbolic link
* to a file.
*/
type: FileType;
/**
* The creation timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC.
*/
ctime: number;
/**
* The modification timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC.
*/
mtime: number;
/**
* The size in bytes.
*/
size: number;
}
export interface FileService {
readFile(uri: Uri): Thenable<Uint8Array>;
stat(uri: Uri): Thenable<FileStat>;
}
export declare function isAbsolutePath(path: string): boolean;
export declare function resolvePath(uri: Uri, path: string): Uri;
export declare function normalizePath(parts: string[]): string;
export declare function joinPath(uri: Uri, ...paths: string[]): Uri;

View File

@@ -1,72 +0,0 @@
"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.FileType = void 0;
exports.isAbsolutePath = isAbsolutePath;
exports.resolvePath = resolvePath;
exports.normalizePath = normalizePath;
exports.joinPath = joinPath;
var FileType;
(function (FileType) {
/**
* The file type is unknown.
*/
FileType[FileType["Unknown"] = 0] = "Unknown";
/**
* A regular file.
*/
FileType[FileType["File"] = 1] = "File";
/**
* A directory.
*/
FileType[FileType["Directory"] = 2] = "Directory";
/**
* A symbolic link to a file.
*/
FileType[FileType["SymbolicLink"] = 64] = "SymbolicLink";
})(FileType || (exports.FileType = FileType = {}));
// following https://nodejs.org/api/path.html#path_path_isabsolute_path
const PathMatchRegex = new RegExp('^(/|//|\\\\\\\\|[A-Za-z]:(/|\\\\))');
const Dot = '.'.charCodeAt(0);
function isAbsolutePath(path) {
return PathMatchRegex.test(path);
}
function resolvePath(uri, path) {
if (isAbsolutePath(path)) {
return uri.with({ path: normalizePath(path.split('/')) });
}
return joinPath(uri, path);
}
function normalizePath(parts) {
const newParts = [];
for (const part of parts) {
if (part.length === 0 || part.length === 1 && part.charCodeAt(0) === Dot) {
// ignore
}
else if (part.length === 2 && part.charCodeAt(0) === Dot && part.charCodeAt(1) === Dot) {
newParts.pop();
}
else {
newParts.push(part);
}
}
if (parts.length > 1 && parts[parts.length - 1].length === 0) {
newParts.push('');
}
let res = newParts.join('/');
if (parts[0].length === 0) {
res = '/' + res;
}
return res;
}
function joinPath(uri, ...paths) {
const parts = uri.path.split('/');
for (const path of paths) {
parts.push(...path.split('/'));
}
return uri.with({ path: normalizePath(parts) });
}
//# sourceMappingURL=fileService.js.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"fileService.js","sourceRoot":"","sources":["../../src/fileService.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAmDhG,wCAEC;AAED,kCAKC;AAED,sCAmBC;AAED,4BAMC;AArFD,IAAY,QAiBX;AAjBD,WAAY,QAAQ;IACnB;;OAEG;IACH,6CAAW,CAAA;IACX;;OAEG;IACH,uCAAQ,CAAA;IACR;;OAEG;IACH,iDAAa,CAAA;IACb;;OAEG;IACH,wDAAiB,CAAA;AAClB,CAAC,EAjBW,QAAQ,wBAAR,QAAQ,QAiBnB;AA0BD,uEAAuE;AACvE,MAAM,cAAc,GAAG,IAAI,MAAM,CAAC,oCAAoC,CAAC,CAAC;AACxE,MAAM,GAAG,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAE9B,SAAgB,cAAc,CAAC,IAAY;IAC1C,OAAO,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AAED,SAAgB,WAAW,CAAC,GAAQ,EAAE,IAAY;IACjD,IAAI,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED,SAAgB,aAAa,CAAC,KAAe;IAC5C,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YAC1E,SAAS;QACV,CAAC;aAAM,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YAC1F,QAAQ,CAAC,GAAG,EAAE,CAAC;QAChB,CAAC;aAAM,CAAC;YACP,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC;IACF,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9D,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACnB,CAAC;IACD,IAAI,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,SAAgB,QAAQ,CAAC,GAAQ,EAAE,GAAG,KAAe;IACpD,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AACjD,CAAC"}

View File

@@ -1,15 +0,0 @@
export interface SnippetsMap {
[name: string]: string;
}
/**
* Parses raw snippets definitions with possibly multiple keys into a plan
* snippet map
*/
export declare function parseSnippets(snippets: SnippetsMap): SnippetsMap;
/**
* List of all known syntaxes
*/
export declare const syntaxes: {
markup: string[];
stylesheet: string[];
};

View File

@@ -1,44 +0,0 @@
/*
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.
*/
/**
* Parses raw snippets definitions with possibly multiple keys into a plan
* snippet map
*/
export function parseSnippets(snippets) {
const result = {};
Object.keys(snippets).forEach(k => {
for (const name of k.split('|')) {
result[name] = snippets[k];
}
});
return result;
}
/**
* List of all known syntaxes
*/
export const syntaxes = {
markup: ['html', 'xml', 'xsl', 'jsx', 'js', 'pug', 'slim', 'haml', 'vue'],
stylesheet: ['css', 'sass', 'scss', 'less', 'sss', 'stylus']
};
//# sourceMappingURL=configCompat.js.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"configCompat.js","sourceRoot":"","sources":["../../src/configCompat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;EAsBE;AAMF;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,QAAqB;IAC/C,MAAM,MAAM,GAAgB,EAAE,CAAC;IAC/B,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;QAC9B,KAAK,MAAM,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YAC9B,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACpB,MAAM,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC;IACzE,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC;CAC/D,CAAC"}

View File

@@ -1,6 +0,0 @@
export declare const cssData: {
properties: string[];
};
export declare const htmlData: {
tags: string[];
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,103 +0,0 @@
import { TextDocument } from 'vscode-languageserver-textdocument';
import { CompletionList, Position, Range } from 'vscode-languageserver-types';
import { URI } from 'vscode-uri';
import { FileService, FileStat, FileType } from './fileService';
import { ExtractOptions, MarkupAbbreviation, Options, StylesheetAbbreviation, SyntaxType, UserConfig } from 'emmet';
import { SnippetsMap } from './configCompat';
export { FileService, FileType, FileStat };
/**
* Emmet configuration as derived from the Emmet related VS Code settings
*/
export interface VSCodeEmmetConfig {
showExpandedAbbreviation?: string;
showAbbreviationSuggestions?: boolean;
syntaxProfiles?: object;
variables?: object;
preferences?: object;
excludeLanguages?: string[];
showSuggestionsAsSnippets?: boolean;
}
/**
* Returns all applicable emmet expansions for abbreviation at given position in a CompletionList
* @param document TextDocument in which completions are requested
* @param position Position in the document at which completions are requested
* @param syntax Emmet supported language
* @param emmetConfig Emmet Configurations as derived from VS Code
*/
export declare function doComplete(document: TextDocument, position: Position, syntax: string, emmetConfig: VSCodeEmmetConfig): CompletionList | undefined;
export declare const emmetSnippetField: (index: number, placeholder: string) => string;
/** Returns whether or not syntax is a supported stylesheet syntax, like CSS */
export declare function isStyleSheet(syntax: string): boolean;
/** Returns the syntax type, either markup (e.g. for HTML) or stylesheet (e.g. for CSS) */
export declare function getSyntaxType(syntax: string): SyntaxType;
/** Returns the default syntax (html or css) to use for the snippets registry */
export declare function getDefaultSyntax(syntax: string): string;
/** Returns the default snippets that Emmet suggests */
export declare function getDefaultSnippets(syntax: string): SnippetsMap;
/**
* Extracts abbreviation from the given position in the given document
* @param document The TextDocument from which abbreviation needs to be extracted
* @param position The Position in the given document from where abbreviation needs to be extracted
* @param options The options to pass to the @emmetio/extract-abbreviation module
*/
export declare function extractAbbreviation(document: TextDocument, position: Position, options?: Partial<ExtractOptions>): {
abbreviation: string;
abbreviationRange: Range;
filter: string | undefined;
} | undefined;
/**
* Extracts abbreviation from the given text
* @param text Text from which abbreviation needs to be extracted
* @param syntax Syntax used to extract the abbreviation from the given text
*/
export declare function extractAbbreviationFromText(text: string, syntax: string): {
abbreviation: string;
filter: string | undefined;
} | undefined;
/**
* Returns a boolean denoting validity of given abbreviation in the context of given syntax
* Not needed once https://github.com/emmetio/atom-plugin/issues/22 is fixed
* @param syntax string
* @param abbreviation string
*/
export declare function isAbbreviationValid(syntax: string, abbreviation: string): boolean;
type ExpandOptionsConfig = {
type: SyntaxType;
options: Partial<Options>;
variables: SnippetsMap;
snippets: SnippetsMap;
syntax: string;
text: string | string[] | undefined;
maxRepeat: number;
};
/**
* Returns options to be used by emmet
*/
export declare function getExpandOptions(syntax: string, emmetConfig?: VSCodeEmmetConfig, filter?: string): ExpandOptionsConfig;
/**
* Parses given abbreviation using given options and returns a tree
* @param abbreviation string
* @param options options used by the emmet module to parse given abbreviation
*/
export declare function parseAbbreviation(abbreviation: string, options: UserConfig): StylesheetAbbreviation | MarkupAbbreviation;
/**
* Expands given abbreviation using given options
* @param abbreviation string or parsed abbreviation
* @param config options used by the @emmetio/expand-abbreviation module to expand given abbreviation
*/
export declare function expandAbbreviation(abbreviation: string | MarkupAbbreviation | StylesheetAbbreviation, config: UserConfig): string;
/**
* Updates customizations from snippets.json and syntaxProfiles.json files in the directory configured in emmet.extensionsPath setting
* @param emmetExtensionsPathSetting setting passed from emmet.extensionsPath. Supports multiple paths
*/
export declare function updateExtensionsPath(emmetExtensionsPathSetting: string[], fs: FileService, workspaceFolderPaths?: URI[], homeDir?: URI): Promise<void>;
/**
* Get the corresponding emmet mode for given vscode language mode
* Eg: jsx for typescriptreact/javascriptreact or pug for jade
* If the language is not supported by emmet or has been exlcuded via `exlcudeLanguages` setting,
* then nothing is returned
*
* @param language
* @param exlcudedLanguages Array of language ids that user has chosen to exlcude for emmet
*/
export declare function getEmmetMode(language: string, excludedLanguages?: string[]): string | undefined;

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,46 +0,0 @@
import { URI as Uri } from 'vscode-uri';
export declare enum FileType {
/**
* The file type is unknown.
*/
Unknown = 0,
/**
* A regular file.
*/
File = 1,
/**
* A directory.
*/
Directory = 2,
/**
* A symbolic link to a file.
*/
SymbolicLink = 64
}
export interface FileStat {
/**
* The type of the file, e.g. is a regular file, a directory, or symbolic link
* to a file.
*/
type: FileType;
/**
* The creation timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC.
*/
ctime: number;
/**
* The modification timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC.
*/
mtime: number;
/**
* The size in bytes.
*/
size: number;
}
export interface FileService {
readFile(uri: Uri): Thenable<Uint8Array>;
stat(uri: Uri): Thenable<FileStat>;
}
export declare function isAbsolutePath(path: string): boolean;
export declare function resolvePath(uri: Uri, path: string): Uri;
export declare function normalizePath(parts: string[]): string;
export declare function joinPath(uri: Uri, ...paths: string[]): Uri;

View File

@@ -1,65 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export var FileType;
(function (FileType) {
/**
* The file type is unknown.
*/
FileType[FileType["Unknown"] = 0] = "Unknown";
/**
* A regular file.
*/
FileType[FileType["File"] = 1] = "File";
/**
* A directory.
*/
FileType[FileType["Directory"] = 2] = "Directory";
/**
* A symbolic link to a file.
*/
FileType[FileType["SymbolicLink"] = 64] = "SymbolicLink";
})(FileType || (FileType = {}));
// following https://nodejs.org/api/path.html#path_path_isabsolute_path
const PathMatchRegex = new RegExp('^(/|//|\\\\\\\\|[A-Za-z]:(/|\\\\))');
const Dot = '.'.charCodeAt(0);
export function isAbsolutePath(path) {
return PathMatchRegex.test(path);
}
export function resolvePath(uri, path) {
if (isAbsolutePath(path)) {
return uri.with({ path: normalizePath(path.split('/')) });
}
return joinPath(uri, path);
}
export function normalizePath(parts) {
const newParts = [];
for (const part of parts) {
if (part.length === 0 || part.length === 1 && part.charCodeAt(0) === Dot) {
// ignore
}
else if (part.length === 2 && part.charCodeAt(0) === Dot && part.charCodeAt(1) === Dot) {
newParts.pop();
}
else {
newParts.push(part);
}
}
if (parts.length > 1 && parts[parts.length - 1].length === 0) {
newParts.push('');
}
let res = newParts.join('/');
if (parts[0].length === 0) {
res = '/' + res;
}
return res;
}
export function joinPath(uri, ...paths) {
const parts = uri.path.split('/');
for (const path of paths) {
parts.push(...path.split('/'));
}
return uri.with({ path: normalizePath(parts) });
}
//# sourceMappingURL=fileService.js.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"fileService.js","sourceRoot":"","sources":["../../src/fileService.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAIhG,MAAM,CAAN,IAAY,QAiBX;AAjBD,WAAY,QAAQ;IACnB;;OAEG;IACH,6CAAW,CAAA;IACX;;OAEG;IACH,uCAAQ,CAAA;IACR;;OAEG;IACH,iDAAa,CAAA;IACb;;OAEG;IACH,wDAAiB,CAAA;AAClB,CAAC,EAjBW,QAAQ,KAAR,QAAQ,QAiBnB;AA0BD,uEAAuE;AACvE,MAAM,cAAc,GAAG,IAAI,MAAM,CAAC,oCAAoC,CAAC,CAAC;AACxE,MAAM,GAAG,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAE9B,MAAM,UAAU,cAAc,CAAC,IAAY;IAC1C,OAAO,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAQ,EAAE,IAAY;IACjD,IAAI,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAe;IAC5C,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YAC1E,SAAS;QACV,CAAC;aAAM,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YAC1F,QAAQ,CAAC,GAAG,EAAE,CAAC;QAChB,CAAC;aAAM,CAAC;YACP,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC;IACF,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9D,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACnB,CAAC;IACD,IAAI,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,GAAQ,EAAE,GAAG,KAAe;IACpD,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AACjD,CAAC"}

View File

@@ -1,37 +0,0 @@
{
"name": "@vscode/emmet-helper",
"version": "2.11.0",
"description": "Helper to use emmet modules in Visual Studio Code",
"main": "./lib/cjs/emmetHelper.js",
"module": "./lib/esm/emmetHelper.js",
"types": "./lib/cjs/emmetHelper.d.ts",
"author": "Microsoft Corporation",
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/vscode-emmet-helper"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/Microsoft/vscode-emmet-helper"
},
"devDependencies": {
"@types/mocha": "^10.0.1",
"@types/node": "^20.0.0",
"@types/vscode": "^1.78.0",
"mocha": "^10.2.0",
"typescript": "^5.6.3"
},
"dependencies": {
"emmet": "^2.4.3",
"jsonc-parser": "^2.3.0",
"vscode-languageserver-textdocument": "^1.0.1",
"vscode-languageserver-types": "^3.15.1",
"vscode-uri": "^3.0.8"
},
"scripts": {
"watch": "tsc -watch -p ./",
"compile": "tsc -p ./",
"compile-esm": "tsc -p ./tsconfig.esm.json",
"test": "mocha lib/cjs/test"
}
}

View File

@@ -1,53 +0,0 @@
THIRD-PARTY SOFTWARE NOTICES AND INFORMATION
vscode-emmet-helper incorporates third party material from the projects listed below. The original copyright
notice and the license under which Microsoft received such third party material are set forth below. Microsoft
reserves all other rights not expressly granted, whether by implication, estoppel or otherwise.
1. expand-abbreivation (https://github.com/emmetio/expand-abbreivation)
MIT License
Copyright (c) 2017 Emmet.io
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.
2. extract-abbreivation (https://github.com/emmetio/extract-abbreivation)
MIT License
Copyright (c) 2017 Emmet.io
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.

42
node_modules/@vscode/l10n/README.md generated vendored
View File

@@ -1,42 +0,0 @@
# @vscode/l10n
Library used for loading the translations into subprocesses of your extension. These usages also get picked up by [l10n-dev](https://github.com/microsoft/vscode-l10n/tree/main/l10n-dev) string extraction tooling.
> **Note**
>
> You should _NOT_ use this library in your extension's main process. The translations are loaded into the main process by VS Code itself.
## Usage
```typescript
import * as l10n from '@vscode/l10n';
// Load the translations for the current locale
l10n.config({
contents: JSON.parse(process.env.BUNDLE_FROM_EXTENSION)
});
// or
l10n.config({
fsPath: process.env.FSPATH_TO_BUNDLE_FROM_EXTENSION
});
// or (warning, this is async)
await l10n.config({
uri: JSON.parse(process.env.BUNDLE_URI_FROM_EXTENSION)
});
// returns the translated string or the original string if no translation is available
l10n.t('Hello World');
// supports arguments just like the vscode API
l10n.t('Hello {0}', 'John');
// supports comments for translators
l10n.t({
message: 'Hello {0}',
args: ['John'],
comment: ['This is a comment']
});
```
The input for `l10n.config` pairs nicely with the `bundle` and `uri` properties on the `l10n` namespace that are provided by the [VS Code API](https://code.visualstudio.com/api/references/vscode-api#l10n).
You should send the value of one of these properties from your extension to your subprocess that is consuming `@vscode/l10n`.

View File

@@ -1,103 +0,0 @@
// src/browser/reader.ts
async function readFileFromUri(uri) {
if (uri.protocol === "http:" || uri.protocol === "https:") {
const res = await fetch(uri);
return await res.text();
}
throw new Error("Unsupported protocol");
}
function readFileFromFsPath(_) {
throw new Error("Unsupported in browser");
}
// src/main.ts
var bundle;
function config(config2) {
if ("contents" in config2) {
if (typeof config2.contents === "string") {
bundle = JSON.parse(config2.contents);
} else {
bundle = config2.contents;
}
return;
}
if ("fsPath" in config2) {
const fileContent = readFileFromFsPath(config2.fsPath);
const content = JSON.parse(fileContent);
bundle = isBuiltinExtension(content) ? content.contents.bundle : content;
return;
}
if (config2.uri) {
let uri = config2.uri;
if (typeof config2.uri === "string") {
uri = new URL(config2.uri);
}
return new Promise((resolve, reject) => {
readFileFromUri(uri).then((uriContent) => {
try {
const content = JSON.parse(uriContent);
bundle = isBuiltinExtension(content) ? content.contents.bundle : content;
resolve();
} catch (err) {
reject(err);
}
}).catch((err) => {
reject(err);
});
});
}
}
function t(...args) {
const firstArg = args[0];
let key;
let message;
let formatArgs;
if (typeof firstArg === "string") {
key = firstArg;
message = firstArg;
args.splice(0, 1);
formatArgs = !args || typeof args[0] !== "object" ? args : args[0];
} else if (firstArg instanceof Array) {
const replacements = args.slice(1);
if (firstArg.length !== replacements.length + 1) {
throw new Error("expected a string as the first argument to l10n.t");
}
let str = firstArg[0];
for (let i = 1; i < firstArg.length; i++) {
str += `{${i - 1}}` + firstArg[i];
}
return t(str, ...replacements);
} else {
message = firstArg.message;
key = message;
if (firstArg.comment && firstArg.comment.length > 0) {
key += `/${Array.isArray(firstArg.comment) ? firstArg.comment.join("") : firstArg.comment}`;
}
formatArgs = firstArg.args ?? {};
}
const messageFromBundle = bundle?.[key];
if (!messageFromBundle) {
return format(message, formatArgs);
}
if (typeof messageFromBundle === "string") {
return format(messageFromBundle, formatArgs);
}
if (messageFromBundle.comment) {
return format(messageFromBundle.message, formatArgs);
}
return format(message, formatArgs);
}
var _format2Regexp = /{([^}]+)}/g;
function format(template, values) {
if (Object.keys(values).length === 0) {
return template;
}
return template.replace(_format2Regexp, (match, group) => values[group] ?? match);
}
function isBuiltinExtension(json) {
return !!(typeof json?.contents?.bundle === "object" && typeof json?.version === "string");
}
export {
config,
t
};

View File

@@ -1,130 +0,0 @@
/**
* @public
* Loads the bundle from the given contents. Must be run before the first call to any `l10n.t()` variant.
* **Note** The best way to set this is to pass the value of the VS Code API `vscode.l10n.contents`
* to the process that uses `@vscode/l10n`.
* @param config - An object that contains one property, contents, which should contain the contents of the bundle.
*/
export declare function config(config: {
contents: string | l10nJsonFormat;
}): void;
/**
* @public
* Loads the bundle from the given fsPath. Must be run before the first call to any `l10n.t()` variant.
* **Warning** This is not implemented in the browser and will throw an Error.
* **Note** The best way to set this is to pass the value of the VS Code API `vscode.l10n.uri.fsPath`
* to the process that uses `@vscode/l10n`.
* @param config - An object that contains one property, fsPath, which should be a path to a file that contains the bundle.
*/
export declare function config(config: {
fsPath: string;
}): void;
/**
* @public
* Loads the bundle from the given URI using an asynchronous fetch request.
* **Warning** Since this is an asynchronous API, you need to ensure that it resolves before
* the first call to any `l10n.t()` variant.
* **Note** The best way to set this is to pass the value of the VS Code API `vscode.l10n.uri.toString()`
* to the process that uses `@vscode/l10n`.
* @param config - An object that contains one property, uri, which should be a URL to the bundle.
*/
export declare function config(config: {
uri: string | URL;
}): Promise<void>;
/**
* @public
* The format of package.nls.json and l10n bundle files.
*/
export declare interface l10nJsonFormat {
[key: string]: l10nJsonMessageFormat;
}
/**
* @public
* The format of a message in a bundle.
*/
export declare type l10nJsonMessageFormat = string | {
message: string;
comment: string[];
};
/**
* @public
* Type that can be used as replacements in `l10n.t()` calls.
*/
export declare type L10nReplacement = string | number | boolean;
/**
* @public
* Marks a string for localization. If the bundle has a localized value for this message, then that localized
* value will be returned (with injected `args` values for any templated values).
* @param message - The message to localize. Supports index templating where strings like `{0}` and `{1}` are
* replaced by the item at that index in the `args` array.
* @param args - The arguments to be used in the localized string. The index of the argument is used to
* match the template placeholder in the localized string.
* @returns localized string with injected arguments.
* @example `l10n.localize('hello', 'Hello {0}!', 'World');`
*/
export declare function t(message: string, ...args: Array<L10nReplacement>): string;
/**
* @public
* Marks a string for localization. If the bundle has a localized value for this message, then that localized
* value will be returned (with injected `args` values for any templated values).
* @param message - The message to localize. Supports named templating where strings like `{foo}` and `{bar}` are
* replaced by the value in the Record for that key (foo, bar, etc).
* @param args - The arguments to be used in the localized string. The name of the key in the record is used to
* match the template placeholder in the localized string.
* @returns localized string with injected arguments.
* @example `l10n.t('Hello {name}', { name: 'Erich' });`
*/
export declare function t(message: string, args: Record<string, L10nReplacement>): string;
/**
* @public
* Marks a string for localization. This function signature is made for usage
* with tagged template literals.
*
* The more verbose overload should still be used if comments are required.
* @example
* ```
* l10n.t`Hello ${name}!`
* ```
* @param message - String message components
* @param args - Replacement components in the string
* @returns localized string with injected arguments.
*/
export declare function t(strs: TemplateStringsArray, ...replacements: L10nReplacement[]): string;
/**
* @public
* Marks a string for localization. If the bundle has a localized value for this message, then that localized
* value will be returned (with injected args values for any templated values).
* @param options - The options to use when localizing the message.
* @returns localized string with injected arguments.
* @example `l10n.t({ message: 'Hello {0}', args: ['Erich'], comment: 'This is a comment' } );`
*/
export declare function t(options: {
/**
* The message to localize. If `args` is an array, this message supports index templating where strings like
* `{0}` and `{1}` are replaced by the item at that index in the `args` array. If `args` is a `Record<string, any>`,
* this supports named templating where strings like `{foo}` and `{bar}` are replaced by the value in
* the Record for that key (foo, bar, etc).
*/
message: string;
/**
* The arguments to be used in the localized string. As an array, the index of the argument is used to
* match the template placeholder in the localized string. As a Record, the key is used to match the template
* placeholder in the localized string.
*/
args?: Array<string | number | boolean> | Record<string, any>;
/**
* A comment to help translators understand the context of the message.
*/
comment: string | string[];
}): string;
export { }

View File

@@ -1,151 +0,0 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/main.ts
var main_exports = {};
__export(main_exports, {
config: () => config,
t: () => t
});
module.exports = __toCommonJS(main_exports);
// src/node/reader.ts
var import_fs = require("fs");
var import_promises = require("fs/promises");
async function readFileFromUri(uri) {
if (uri.protocol === "file:") {
return await (0, import_promises.readFile)(uri, "utf8");
}
if (uri.protocol === "http:" || uri.protocol === "https:") {
const res = await fetch(uri.toString(), {
headers: {
"Accept-Encoding": "gzip, deflate",
"Accept": "application/json"
},
redirect: "follow"
});
if (!res.ok) {
let error = `Unexpected ${res.status} response while trying to read ${uri}`;
try {
error += `: ${await res.text()}`;
} catch {
}
throw new Error(error);
}
const decoded = await res.text();
return decoded;
}
throw new Error("Unsupported protocol");
}
function readFileFromFsPath(fsPath) {
return (0, import_fs.readFileSync)(fsPath, "utf8");
}
// src/main.ts
var bundle;
function config(config2) {
if ("contents" in config2) {
if (typeof config2.contents === "string") {
bundle = JSON.parse(config2.contents);
} else {
bundle = config2.contents;
}
return;
}
if ("fsPath" in config2) {
const fileContent = readFileFromFsPath(config2.fsPath);
const content = JSON.parse(fileContent);
bundle = isBuiltinExtension(content) ? content.contents.bundle : content;
return;
}
if (config2.uri) {
let uri = config2.uri;
if (typeof config2.uri === "string") {
uri = new URL(config2.uri);
}
return new Promise((resolve, reject) => {
readFileFromUri(uri).then((uriContent) => {
try {
const content = JSON.parse(uriContent);
bundle = isBuiltinExtension(content) ? content.contents.bundle : content;
resolve();
} catch (err) {
reject(err);
}
}).catch((err) => {
reject(err);
});
});
}
}
function t(...args) {
const firstArg = args[0];
let key;
let message;
let formatArgs;
if (typeof firstArg === "string") {
key = firstArg;
message = firstArg;
args.splice(0, 1);
formatArgs = !args || typeof args[0] !== "object" ? args : args[0];
} else if (firstArg instanceof Array) {
const replacements = args.slice(1);
if (firstArg.length !== replacements.length + 1) {
throw new Error("expected a string as the first argument to l10n.t");
}
let str = firstArg[0];
for (let i = 1; i < firstArg.length; i++) {
str += `{${i - 1}}` + firstArg[i];
}
return t(str, ...replacements);
} else {
message = firstArg.message;
key = message;
if (firstArg.comment && firstArg.comment.length > 0) {
key += `/${Array.isArray(firstArg.comment) ? firstArg.comment.join("") : firstArg.comment}`;
}
formatArgs = firstArg.args ?? {};
}
const messageFromBundle = bundle?.[key];
if (!messageFromBundle) {
return format(message, formatArgs);
}
if (typeof messageFromBundle === "string") {
return format(messageFromBundle, formatArgs);
}
if (messageFromBundle.comment) {
return format(messageFromBundle.message, formatArgs);
}
return format(message, formatArgs);
}
var _format2Regexp = /{([^}]+)}/g;
function format(template, values) {
if (Object.keys(values).length === 0) {
return template;
}
return template.replace(_format2Regexp, (match, group) => values[group] ?? match);
}
function isBuiltinExtension(json) {
return !!(typeof json?.contents?.bundle === "object" && typeof json?.version === "string");
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
config,
t
});

View File

@@ -1,11 +0,0 @@
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
// It should be published with your NPM package. It should not be tracked by Git.
{
"tsdocVersion": "0.12",
"toolPackages": [
{
"packageName": "@microsoft/api-extractor",
"packageVersion": "7.36.3"
}
]
}

View File

@@ -1,50 +0,0 @@
{
"name": "@vscode/l10n",
"version": "0.0.18",
"description": "A helper library to assist in localizing subprocesses spun up by VS Code extensions",
"author": "Microsoft Corporation",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/vscode-l10n.git"
},
"bugs": {
"url": "https://github.com/Microsoft/vscode-l10n/issues"
},
"main": "./dist/main.js",
"sideEffects": false,
"browser": {
"./dist/main.js": "./dist/browser.js",
"./src/node/reader": "./src/browser/reader"
},
"types": "dist/main.d.ts",
"files": [
"dist/*"
],
"devDependencies": {
"@jest/globals": "^29.7.0",
"@microsoft/api-extractor": "^7.32.1",
"@types/mock-fs": "^4.13.1",
"@types/node": "^18",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.13.2",
"esbuild": "^0.15.5",
"eslint": "^7.29.0",
"http-proxy-agent": "^5.0.0",
"https-proxy-agent": "^5.0.1",
"jest": "^29.7.0",
"jest-fetch-mock": "^3.0.3",
"mock-fs": "^5.1.4",
"rimraf": "^3.0.2",
"ts-jest": "^29.1.1",
"typescript": "^4.7.4"
},
"scripts": {
"clean": "rimraf dist && rimraf lib",
"compile": "npm run clean && tsc --emitDeclarationOnly --outDir lib && node .esbuild.config.js",
"lint": "eslint src --ext ts",
"watch": "node .esbuild.config.js --watch",
"test": "jest --preset ts-jest",
"prepublishOnly": "npm run lint && npm run compile && npm run test"
}
}