This commit is contained in:
103
node_modules/@vscode/l10n/dist/browser.js
generated
vendored
Normal file
103
node_modules/@vscode/l10n/dist/browser.js
generated
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
// 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
|
||||
};
|
||||
130
node_modules/@vscode/l10n/dist/main.d.ts
generated
vendored
Normal file
130
node_modules/@vscode/l10n/dist/main.d.ts
generated
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
/**
|
||||
* @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 { }
|
||||
151
node_modules/@vscode/l10n/dist/main.js
generated
vendored
Normal file
151
node_modules/@vscode/l10n/dist/main.js
generated
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
"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
|
||||
});
|
||||
11
node_modules/@vscode/l10n/dist/tsdoc-metadata.json
generated
vendored
Normal file
11
node_modules/@vscode/l10n/dist/tsdoc-metadata.json
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
// 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"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user