messageformat
Advanced tools
Comparing version 4.0.0-2 to 4.0.0-3
@@ -1,2 +0,2 @@ | ||
import type { ParseError } from './parser/data-model'; | ||
import type { MessageSyntaxError } from './errors'; | ||
import type { Junk, Literal, PatternElement, Placeholder, VariableRef } from './pattern'; | ||
@@ -21,3 +21,3 @@ /** | ||
comment?: string; | ||
errors?: ParseError[]; | ||
errors?: MessageSyntaxError[]; | ||
} | ||
@@ -64,3 +64,3 @@ /** | ||
comment?: string; | ||
errors?: ParseError[]; | ||
errors?: MessageSyntaxError[]; | ||
} | ||
@@ -79,2 +79,3 @@ /** @beta */ | ||
type: '*'; | ||
value?: string; | ||
} | ||
@@ -98,3 +99,3 @@ /** | ||
comment?: string; | ||
errors?: ParseError[]; | ||
errors?: MessageSyntaxError[]; | ||
} | ||
@@ -101,0 +102,0 @@ /** |
@@ -31,3 +31,3 @@ "use strict"; | ||
if (msg.errors?.length) | ||
throw new Error('Message parse failed'); | ||
throw msg.errors[0]; | ||
switch (msg.type) { | ||
@@ -34,0 +34,0 @@ case 'message': |
@@ -1,9 +0,9 @@ | ||
export * from './data-model'; | ||
export * from './message-value'; | ||
export { MessageFormat, MessageFormatOptions } from './messageformat'; | ||
export type { ParseError } from './parser/data-model.js'; | ||
export * from './data-model.js'; | ||
export { MessageDataModelError, MessageError, MessageSyntaxError } from './errors.js'; | ||
export * from './message-value/index.js'; | ||
export { MessageFormat, MessageFormatOptions } from './messageformat.js'; | ||
export { parseMessage } from './parser/message.js'; | ||
export { stringifyMessage } from './stringifier/message.js'; | ||
export * from './pattern'; | ||
export * from './runtime'; | ||
export { validate } from './extra/validate'; | ||
export * from './pattern/index.js'; | ||
export * from './runtime/index.js'; | ||
export { validate } from './extra/validate.js'; |
@@ -17,7 +17,11 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validate = exports.stringifyMessage = exports.parseMessage = exports.MessageFormat = void 0; | ||
__exportStar(require("./data-model"), exports); | ||
__exportStar(require("./message-value"), exports); | ||
var messageformat_1 = require("./messageformat"); | ||
Object.defineProperty(exports, "MessageFormat", { enumerable: true, get: function () { return messageformat_1.MessageFormat; } }); | ||
exports.validate = exports.stringifyMessage = exports.parseMessage = exports.MessageFormat = exports.MessageSyntaxError = exports.MessageError = exports.MessageDataModelError = void 0; | ||
__exportStar(require("./data-model.js"), exports); | ||
var errors_js_1 = require("./errors.js"); | ||
Object.defineProperty(exports, "MessageDataModelError", { enumerable: true, get: function () { return errors_js_1.MessageDataModelError; } }); | ||
Object.defineProperty(exports, "MessageError", { enumerable: true, get: function () { return errors_js_1.MessageError; } }); | ||
Object.defineProperty(exports, "MessageSyntaxError", { enumerable: true, get: function () { return errors_js_1.MessageSyntaxError; } }); | ||
__exportStar(require("./message-value/index.js"), exports); | ||
var messageformat_js_1 = require("./messageformat.js"); | ||
Object.defineProperty(exports, "MessageFormat", { enumerable: true, get: function () { return messageformat_js_1.MessageFormat; } }); | ||
var message_js_1 = require("./parser/message.js"); | ||
@@ -27,5 +31,5 @@ Object.defineProperty(exports, "parseMessage", { enumerable: true, get: function () { return message_js_1.parseMessage; } }); | ||
Object.defineProperty(exports, "stringifyMessage", { enumerable: true, get: function () { return message_js_2.stringifyMessage; } }); | ||
__exportStar(require("./pattern"), exports); | ||
__exportStar(require("./runtime"), exports); | ||
var validate_1 = require("./extra/validate"); // must be after ./messageformat -- but why!? | ||
Object.defineProperty(exports, "validate", { enumerable: true, get: function () { return validate_1.validate; } }); | ||
__exportStar(require("./pattern/index.js"), exports); | ||
__exportStar(require("./runtime/index.js"), exports); | ||
var validate_js_1 = require("./extra/validate.js"); // must be after ./messageformat -- but why!? | ||
Object.defineProperty(exports, "validate", { enumerable: true, get: function () { return validate_js_1.validate; } }); |
@@ -1,2 +0,1 @@ | ||
import { Context } from '../format-context'; | ||
import type { LocaleContextArg } from './locale-context'; | ||
@@ -17,3 +16,3 @@ import { MessageValue, Meta } from './message-value'; | ||
matchSelectKey(): boolean; | ||
toString(onError?: Context['onError']): string; | ||
toString(): string; | ||
} | ||
@@ -20,0 +19,0 @@ /** |
@@ -20,20 +20,4 @@ "use strict"; | ||
} | ||
toString(onError) { | ||
let tag = this.value; | ||
for (const [key, opt] of Object.entries(this.options)) { | ||
try { | ||
if (/^\w[\w-]*$/.test(key)) { | ||
let strOpt = String(opt); | ||
if (/[^\w-]/.test(strOpt)) { | ||
strOpt = '(' + strOpt.replace(/[()\\]/g, '\\$&') + ')'; | ||
} | ||
tag += ` ${key}=${strOpt}`; | ||
} | ||
} | ||
catch (error) { | ||
if (onError) | ||
onError(error, this); | ||
} | ||
} | ||
return `{+${tag}}`; | ||
toString() { | ||
return `{+${this.value}}`; | ||
} | ||
@@ -40,0 +24,0 @@ } |
import { Context } from '../format-context'; | ||
import { LocaleContext, LocaleContextArg } from './locale-context'; | ||
export declare const FALLBACK_SOURCE = "???"; | ||
export declare const FALLBACK_SOURCE = "\uFFFD"; | ||
/** | ||
@@ -5,0 +5,0 @@ * Additional meta information may be attached to most nodes. In common use, |
@@ -17,3 +17,3 @@ "use strict"; | ||
const locale_context_1 = require("./locale-context"); | ||
exports.FALLBACK_SOURCE = '???'; | ||
exports.FALLBACK_SOURCE = '�'; | ||
/** | ||
@@ -20,0 +20,0 @@ * Type guard for message values that may contain a `meta` member |
@@ -42,7 +42,6 @@ "use strict"; | ||
resolveMessage(msgParams, onError) { | ||
if (onError && __classPrivateFieldGet(this, _MessageFormat_message, "f").errors) | ||
for (const pErr of __classPrivateFieldGet(this, _MessageFormat_message, "f").errors) { | ||
const error = new Error(`Parse error: ${pErr.type} at ${pErr.start}`); | ||
onError(Object.assign(error, pErr), undefined); | ||
} | ||
if (onError && __classPrivateFieldGet(this, _MessageFormat_message, "f").errors) { | ||
for (const error of __classPrivateFieldGet(this, _MessageFormat_message, "f").errors) | ||
onError(error, undefined); | ||
} | ||
const ctx = this.createContext(msgParams, onError); | ||
@@ -49,0 +48,0 @@ return new message_value_1.ResolvedMessage(ctx, __classPrivateFieldGet(this, _MessageFormat_message, "f")); |
import type { CatchallKey, Declaration, JunkMessage, Pattern, PatternMessage, SelectMessage, Variant } from '../data-model'; | ||
import type { MessageSyntaxError } from '../errors'; | ||
import type { Expression, Junk, Literal, MarkupEnd, MarkupStart, Option, Text, VariableRef } from '../pattern'; | ||
/** @beta */ | ||
export type ParseError = { | ||
type: 'empty-token'; | ||
start: number; | ||
end?: never; | ||
} | { | ||
type: 'bad-escape' | 'bad-local-var' | 'bad-selector' | 'extra-content' | 'key-mismatch' | 'parse-error'; | ||
start: number; | ||
end: number; | ||
} | { | ||
type: 'missing-char'; | ||
char: string; | ||
start: number; | ||
end?: never; | ||
}; | ||
export type MessageParsed = PatternMessageParsed | SelectMessageParsed | JunkMessageParsed; | ||
@@ -23,3 +9,3 @@ export interface PatternMessageParsed extends PatternMessage { | ||
pattern: PatternParsed; | ||
errors: ParseError[]; | ||
errors: MessageSyntaxError[]; | ||
} | ||
@@ -31,3 +17,3 @@ export interface SelectMessageParsed extends SelectMessage { | ||
variants: VariantParsed[]; | ||
errors: ParseError[]; | ||
errors: MessageSyntaxError[]; | ||
} | ||
@@ -37,3 +23,3 @@ export interface JunkMessageParsed extends JunkMessage { | ||
declarations: DeclarationParsed[]; | ||
errors: ParseError[]; | ||
errors: MessageSyntaxError[]; | ||
source: string; | ||
@@ -90,5 +76,5 @@ } | ||
type: 'literal'; | ||
/** position of the `(` */ | ||
/** position of the initial `|` */ | ||
start: number; | ||
/** position just past the `)` */ | ||
/** position just past the terminal `|` */ | ||
end: number; | ||
@@ -95,0 +81,0 @@ value: string; |
@@ -1,5 +0,6 @@ | ||
import type { DeclarationParsed, ParseError } from './data-model.js'; | ||
export declare function parseDeclarations(src: string, errors: ParseError[]): { | ||
import { MessageSyntaxError } from '../errors.js'; | ||
import type { DeclarationParsed } from './data-model.js'; | ||
export declare function parseDeclarations(src: string, errors: MessageSyntaxError[]): { | ||
declarations: DeclarationParsed[]; | ||
end: number; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseDeclarations = void 0; | ||
const errors_js_1 = require("../errors.js"); | ||
const placeholder_js_1 = require("./placeholder.js"); | ||
@@ -26,3 +27,3 @@ const util_js_1 = require("./util.js"); | ||
if (ws === 0) | ||
errors.push({ type: 'missing-char', char: ' ', start: pos }); | ||
errors.push(new errors_js_1.MissingCharError(pos, ' ')); | ||
let target; | ||
@@ -43,3 +44,3 @@ if (src[pos] === '$') { | ||
}; | ||
errors.push({ type: 'missing-char', char: '$', start: junkStart }); | ||
errors.push(new errors_js_1.MissingCharError(junkStart, '$')); | ||
} | ||
@@ -50,3 +51,3 @@ pos += (0, util_js_1.whitespaces)(src, pos); | ||
else | ||
errors.push({ type: 'missing-char', char: '=', start: pos }); | ||
errors.push(new errors_js_1.MissingCharError(pos, '=')); | ||
let value; | ||
@@ -70,3 +71,3 @@ pos += (0, util_js_1.whitespaces)(src, pos); | ||
}; | ||
errors.push({ type: 'missing-char', char: '{', start: junkStart }); | ||
errors.push(new errors_js_1.MissingCharError(junkStart, '{')); | ||
} | ||
@@ -78,4 +79,5 @@ return { start, end: pos, target, value }; | ||
const check = (name, ref) => { | ||
if (ref.name === name) | ||
errors.push({ type: 'bad-local-var', start: ref.start, end: ref.end }); | ||
if (ref.name === name) { | ||
errors.push(new errors_js_1.MessageSyntaxError('bad-local-var', ref.start, ref.end)); | ||
} | ||
}; | ||
@@ -82,0 +84,0 @@ for (let i = 1; i < declarations.length; ++i) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseMessage = void 0; | ||
const errors_js_1 = require("../errors.js"); | ||
const declarations_js_1 = require("./declarations.js"); | ||
@@ -27,3 +28,3 @@ const names_js_1 = require("./names.js"); | ||
else { | ||
errors.push({ type: 'parse-error', start: pos, end: src.length }); | ||
errors.push(new errors_js_1.MessageSyntaxError('parse-error', pos, src.length)); | ||
return { type: 'junk', declarations, errors, source: src }; | ||
@@ -38,3 +39,3 @@ } | ||
if (pos < src.length) { | ||
errors.push({ type: 'extra-content', start: pos, end: src.length }); | ||
errors.push(new errors_js_1.MessageSyntaxError('extra-content', pos, src.length)); | ||
} | ||
@@ -56,3 +57,3 @@ return { type: 'message', declarations, pattern, errors }; | ||
const { start, end } = ph.body; | ||
errors.push({ type: 'bad-selector', start, end }); | ||
errors.push(new errors_js_1.MessageSyntaxError('bad-selector', start, end)); | ||
} | ||
@@ -65,3 +66,3 @@ } | ||
if (selectors.length === 0) { | ||
errors.push({ type: 'empty-token', start: pos }); | ||
errors.push(new errors_js_1.MessageSyntaxError('empty-token', pos, pos + 1)); | ||
} | ||
@@ -77,3 +78,3 @@ const variants = []; | ||
if (pos < src.length) { | ||
errors.push({ type: 'extra-content', start: pos, end: src.length }); | ||
errors.push(new errors_js_1.MessageSyntaxError('extra-content', pos, src.length)); | ||
} | ||
@@ -93,5 +94,4 @@ return { type: 'select', declarations, selectors, variants, errors }; | ||
break; | ||
if (ws === 0) { | ||
errors.push({ type: 'missing-char', char: ' ', start: pos }); | ||
} | ||
if (ws === 0) | ||
errors.push(new errors_js_1.MissingCharError(pos, ' ')); | ||
let key; | ||
@@ -102,3 +102,3 @@ switch (ch) { | ||
break; | ||
case '(': | ||
case '|': | ||
key = (0, values_js_1.parseLiteral)(src, pos, errors); | ||
@@ -116,3 +116,3 @@ break; | ||
const end = keys.length === 0 ? pos : keys[keys.length - 1].end; | ||
errors.push({ type: 'key-mismatch', start, end }); | ||
errors.push(new errors_js_1.MessageDataModelError('key-mismatch', start, end)); | ||
} | ||
@@ -125,3 +125,3 @@ const value = parsePattern(src, pos, errors); | ||
if (src[start] !== '{') { | ||
errors.push({ type: 'missing-char', char: '{', start }); | ||
errors.push(new errors_js_1.MissingCharError(start, '{')); | ||
return { start, end: start, body: [] }; | ||
@@ -148,9 +148,7 @@ } | ||
} | ||
if (src[pos] === '}') { | ||
if (src[pos] === '}') | ||
pos += 1; | ||
} | ||
else { | ||
errors.push({ type: 'missing-char', char: '}', start: pos }); | ||
} | ||
else | ||
errors.push(new errors_js_1.MissingCharError(pos, '}')); | ||
return { start, end: pos, body }; | ||
} |
@@ -1,4 +0,5 @@ | ||
import type { NmtokenParsed, ParseError } from './data-model.js'; | ||
import { MessageSyntaxError } from '../errors.js'; | ||
import type { NmtokenParsed } from './data-model.js'; | ||
export declare function isValidNmtoken(str: string): boolean; | ||
export declare function parseNameValue(src: string, start: number): string; | ||
export declare function parseNmtoken(src: string, start: number, errors: ParseError[]): NmtokenParsed; | ||
export declare function parseNmtoken(src: string, start: number, errors: MessageSyntaxError[]): NmtokenParsed; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseNmtoken = exports.parseNameValue = exports.isValidNmtoken = void 0; | ||
const errors_js_1 = require("../errors.js"); | ||
// NameStart ::= [a-zA-Z] | "_" | ||
@@ -63,6 +64,7 @@ // | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | ||
const value = src.substring(start, pos); | ||
if (!value) | ||
errors.push({ type: 'empty-token', start }); | ||
if (!value) { | ||
errors.push(new errors_js_1.MessageSyntaxError('empty-token', start, start + 1)); | ||
} | ||
return { type: 'nmtoken', start, end: pos, value }; | ||
} | ||
exports.parseNmtoken = parseNmtoken; |
@@ -1,2 +0,3 @@ | ||
import type { PlaceholderParsed, ParseError } from './data-model.js'; | ||
export declare function parsePlaceholder(src: string, start: number, errors: ParseError[]): PlaceholderParsed; | ||
import { MessageSyntaxError } from '../errors.js'; | ||
import type { PlaceholderParsed } from './data-model.js'; | ||
export declare function parsePlaceholder(src: string, start: number, errors: MessageSyntaxError[]): PlaceholderParsed; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parsePlaceholder = void 0; | ||
const errors_js_1 = require("../errors.js"); | ||
const names_js_1 = require("./names.js"); | ||
@@ -13,3 +14,3 @@ const util_js_1 = require("./util.js"); | ||
switch (src[pos]) { | ||
case '(': | ||
case '|': | ||
arg = (0, values_js_1.parseLiteral)(src, pos, errors); | ||
@@ -41,3 +42,3 @@ pos = arg.end; | ||
body = { type: 'junk', start: pos, end: pos, source }; | ||
junkError = { type: 'parse-error', start: pos, end: pos }; | ||
junkError = new errors_js_1.MessageSyntaxError('parse-error', pos, pos + 1); | ||
errors.push(junkError); | ||
@@ -48,3 +49,3 @@ } | ||
if (pos >= src.length) { | ||
errors.push({ type: 'missing-char', char: '}', start: pos }); | ||
errors.push(new errors_js_1.MissingCharError(pos, '}')); | ||
} | ||
@@ -62,3 +63,3 @@ else if (src[pos] !== '}') { | ||
else { | ||
errors.push({ type: 'extra-content', start: errStart, end: pos }); | ||
errors.push(new errors_js_1.MessageSyntaxError('extra-content', errStart, pos)); | ||
} | ||
@@ -84,3 +85,3 @@ } | ||
if (!name) | ||
errors.push({ type: 'empty-token', start: pos }); | ||
errors.push(new errors_js_1.MessageSyntaxError('empty-token', pos, pos + 1)); | ||
const options = []; | ||
@@ -93,3 +94,3 @@ pos += name.length; | ||
if (ws === 0) | ||
errors.push({ type: 'missing-char', char: ' ', start: pos }); | ||
errors.push(new errors_js_1.MissingCharError(pos, ' ')); | ||
pos += ws; | ||
@@ -108,3 +109,3 @@ const opt = parseOption(src, pos, errors); | ||
const { start, end } = operand; | ||
errors.unshift({ type: 'extra-content', start, end }); | ||
errors.unshift(new errors_js_1.MessageSyntaxError('extra-content', start, end)); | ||
} | ||
@@ -115,7 +116,3 @@ if (sigil === '+') { | ||
if (options.length > 0) { | ||
errors.push({ | ||
type: 'extra-content', | ||
start: options[0].start, | ||
end: options[options.length - 1].end | ||
}); | ||
errors.push(new errors_js_1.MessageSyntaxError('extra-content', options[0].start, options[options.length - 1].end)); | ||
} | ||
@@ -132,7 +129,7 @@ return { type: 'markup-end', start, end, name }; | ||
else | ||
errors.push({ type: 'missing-char', char: '=', start: pos }); | ||
errors.push(new errors_js_1.MissingCharError(pos, '=')); | ||
pos += (0, util_js_1.whitespaces)(src, pos); | ||
let value; | ||
switch (src[pos]) { | ||
case '(': | ||
case '|': | ||
value = (0, values_js_1.parseLiteral)(src, pos, errors); | ||
@@ -139,0 +136,0 @@ break; |
@@ -1,4 +0,5 @@ | ||
import type { LiteralParsed, TextParsed, ParseError, VariableRefParsed } from './data-model.js'; | ||
export declare function parseText(src: string, start: number, errors: ParseError[]): TextParsed; | ||
export declare function parseLiteral(src: string, start: number, errors: ParseError[]): LiteralParsed; | ||
export declare function parseVariable(src: string, start: number, errors: ParseError[]): VariableRefParsed; | ||
import { MessageSyntaxError } from '../errors.js'; | ||
import type { LiteralParsed, TextParsed, VariableRefParsed } from './data-model.js'; | ||
export declare function parseText(src: string, start: number, errors: MessageSyntaxError[]): TextParsed; | ||
export declare function parseLiteral(src: string, start: number, errors: MessageSyntaxError[]): LiteralParsed; | ||
export declare function parseVariable(src: string, start: number, errors: MessageSyntaxError[]): VariableRefParsed; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseVariable = exports.parseLiteral = exports.parseText = void 0; | ||
const errors_js_1 = require("../errors.js"); | ||
const names_js_1 = require("./names.js"); | ||
@@ -19,3 +20,3 @@ // Text ::= (TextChar | TextEscape)+ | ||
if (esc !== '\\' && esc !== '{' && esc !== '}') { | ||
errors.push({ type: 'bad-escape', start: i, end: i + 2 }); | ||
errors.push(new errors_js_1.MessageSyntaxError('bad-escape', i, i + 2)); | ||
} | ||
@@ -40,4 +41,4 @@ else { | ||
// Esc ::= '\' | ||
// LiteralChar ::= AnyChar - ('(' | ')' | Esc) | ||
// LiteralEscape ::= Esc Esc | Esc '(' | Esc ')' | ||
// LiteralChar ::= AnyChar - ('|' | Esc) | ||
// LiteralEscape ::= Esc Esc | Esc '|' | ||
function parseLiteral(src, start, errors) { | ||
@@ -50,4 +51,4 @@ let value = ''; | ||
const esc = src[i + 1]; | ||
if (esc !== '\\' && esc !== '(' && esc !== ')') { | ||
errors.push({ type: 'bad-escape', start: i, end: i + 2 }); | ||
if (esc !== '\\' && esc !== '|') { | ||
errors.push(new errors_js_1.MessageSyntaxError('bad-escape', i, i + 2)); | ||
} | ||
@@ -61,6 +62,3 @@ else { | ||
} | ||
case '(': | ||
errors.push({ type: 'missing-char', char: '\\', start: i }); | ||
break; | ||
case ')': | ||
case '|': | ||
value += src.substring(pos, i); | ||
@@ -71,3 +69,3 @@ return { type: 'literal', start, end: i + 1, value }; | ||
value += src.substring(pos); | ||
errors.push({ type: 'missing-char', char: ')', start: src.length }); | ||
errors.push(new errors_js_1.MissingCharError(src.length, '|')); | ||
return { type: 'literal', start, end: src.length, value }; | ||
@@ -82,5 +80,5 @@ } | ||
if (!name) | ||
errors.push({ type: 'empty-token', start: pos }); | ||
errors.push(new errors_js_1.MessageSyntaxError('empty-token', pos, pos + 1)); | ||
return { type: 'variable', start, end, name }; | ||
} | ||
exports.parseVariable = parseVariable; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.resolveExpression = exports.isExpression = void 0; | ||
const errors_1 = require("../errors"); | ||
const message_value_1 = require("../message-value"); | ||
@@ -22,4 +23,5 @@ const message_value_2 = require("../message-value/message-value"); | ||
fnArgs = [arg]; | ||
const argSrc = arg.source || (arg.type === 'literal' && arg.value) || message_value_2.FALLBACK_SOURCE; | ||
source = `${argSrc} :${name}`; | ||
source = | ||
arg.source || | ||
String((arg.type === 'literal' && arg.value) || message_value_2.FALLBACK_SOURCE); | ||
} | ||
@@ -31,4 +33,3 @@ else { | ||
if (!rf) { | ||
const error = new ReferenceError(`Unknown formatter ${name}`); | ||
throw Object.assign(error, { type: 'missing-func' }); | ||
throw new errors_1.MessageError('missing-func', `Unknown function ${name}`); | ||
} | ||
@@ -45,3 +46,3 @@ const opt = { localeMatcher: ctx.localeMatcher }; | ||
catch (error) { | ||
source ?? (source = `${name}(${operand ? message_value_2.FALLBACK_SOURCE : ''})`); | ||
source ?? (source = operand ? message_value_2.FALLBACK_SOURCE : `:${name}`); | ||
const fb = new message_value_1.MessageFallback(ctx, { source }); | ||
@@ -48,0 +49,0 @@ ctx.onError(error, fb); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.resolveJunk = exports.isJunk = void 0; | ||
const errors_js_1 = require("../errors.js"); | ||
const message_value_1 = require("../message-value"); | ||
@@ -15,6 +16,5 @@ /** | ||
const fb = new message_value_1.MessageFallback(ctx, { source }); | ||
const error = new Error('Junk pattern element cannot be resolved'); | ||
ctx.onError(Object.assign(error, { type: 'junk-element' }), fb); | ||
ctx.onError(new errors_js_1.MessageError('junk-element', 'Junk pattern element cannot be resolved'), fb); | ||
return fb; | ||
} | ||
exports.resolveJunk = resolveJunk; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.resolveVariableRef = exports.isVariableRef = void 0; | ||
const errors_js_1 = require("../errors.js"); | ||
const message_value_1 = require("../message-value"); | ||
@@ -47,6 +48,5 @@ /** | ||
const fb = new message_value_1.MessageFallback(ctx, { source }); | ||
const error = new Error(`Variable not available: ${source}`); | ||
ctx.onError(Object.assign(error, { type: 'missing-var' }), fb); | ||
ctx.onError(new errors_js_1.MessageError('unresolved-var', `Variable not available: ${source}`), fb); | ||
return fb; | ||
} | ||
exports.resolveVariableRef = resolveVariableRef; |
@@ -7,2 +7,3 @@ import { RuntimeOptions } from './index'; | ||
* | ||
* @beta | ||
* @param options Options object, which may be modified. | ||
@@ -17,2 +18,3 @@ * @param names Names of options that should have boolean values. | ||
* | ||
* @beta | ||
* @param options Options object, which may be modified. | ||
@@ -19,0 +21,0 @@ * @param names Names of options that should have integer values. |
@@ -9,2 +9,3 @@ "use strict"; | ||
* | ||
* @beta | ||
* @param options Options object, which may be modified. | ||
@@ -30,2 +31,3 @@ * @param names Names of options that should have boolean values. | ||
* | ||
* @beta | ||
* @param options Options object, which may be modified. | ||
@@ -32,0 +34,0 @@ * @param names Names of options that should have integer values. |
@@ -73,7 +73,4 @@ "use strict"; | ||
} | ||
const esc = lit.value | ||
.replace(/\\/g, '\\\\') | ||
.replace(/\(/g, '\\(') | ||
.replace(/\)/g, '\\)'); | ||
return `(${esc})`; | ||
const esc = lit.value.replace(/\\/g, '\\\\').replace(/\|/g, '\\|'); | ||
return `|${esc}|`; | ||
} | ||
@@ -80,0 +77,0 @@ function stringifyMarkupEnd(end) { |
{ | ||
"name": "messageformat", | ||
"version": "4.0.0-2", | ||
"version": "4.0.0-3", | ||
"description": "Intl.MessageFormat / Unicode MessageFormat 2 parser, runtime and polyfill", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
110510
69
2610