Comparing version 12.0.3 to 12.1.0
@@ -135,2 +135,10 @@ "use strict"; | ||
}; | ||
if (process.env.SOURCE_DATE_EPOCH) { | ||
const sde = process.env.SOURCE_DATE_EPOCH.trim(); | ||
if (!/^[0-9]+/.test(sde)) { | ||
fail(`SOURCE_DATE_EPOCH value ${sde} is not valid`); | ||
} | ||
const ts = +sde; | ||
opts.date = new Date(ts * 1000); | ||
} | ||
const spec = await ecmarkup.build(args.files[0], utils.readFile, opts); | ||
@@ -137,0 +145,0 @@ if (args.verbose) { |
@@ -1,1 +0,5 @@ | ||
export {}; | ||
import type { SourceFile } from 'grammarkdown'; | ||
export declare type AugmentedGrammarEle = HTMLElement & { | ||
grammarkdownOut: string; | ||
grammarSource: SourceFile; | ||
}; |
@@ -13,3 +13,2 @@ "use strict"; | ||
// i.e., we already parsed this during an earlier phase | ||
// @ts-ignore | ||
node.innerHTML = node.grammarkdownOut; | ||
@@ -79,3 +78,8 @@ return; | ||
await grammar.emit(undefined, (file, source) => { | ||
if (grammar.rootFiles.length !== 1) { | ||
throw new Error(`grammarkdown file count mismatch: ${grammar.rootFiles.length}. This is a bug in ecmarkup; please report it.`); | ||
} | ||
node.innerHTML = source; | ||
node.grammarkdownOut = source; | ||
node.grammarSource = grammar.rootFiles[0]; | ||
}); | ||
@@ -82,0 +86,0 @@ } |
@@ -445,2 +445,3 @@ "use strict"; | ||
function formatPreamble(spec, clause, dl, type, name, formattedParams, formattedReturnType, _for, description) { | ||
var _a; | ||
const para = spec.doc.createElement('p'); | ||
@@ -523,8 +524,13 @@ const paras = [para]; | ||
: 'It performs the following steps when called:'; | ||
const getRelevantElement = (el) => { var _a; return el.tagName === 'INS' || el.tagName === 'DEL' ? (_a = el.firstElementChild) !== null && _a !== void 0 ? _a : el : el; }; | ||
let next = dl.nextElementSibling; | ||
while (next != null && next.tagName === 'EMU-NOTE') { | ||
while (next != null && ((_a = getRelevantElement(next)) === null || _a === void 0 ? void 0 : _a.tagName) === 'EMU-NOTE') { | ||
next = next.nextElementSibling; | ||
} | ||
if ((isSdo && (next === null || next === void 0 ? void 0 : next.tagName) === 'EMU-GRAMMAR') || | ||
(!isSdo && (next === null || next === void 0 ? void 0 : next.tagName) === 'EMU-ALG' && !next.hasAttribute('replaces-step'))) { | ||
const relevant = next != null ? getRelevantElement(next) : null; | ||
if ((isSdo && next != null && (relevant === null || relevant === void 0 ? void 0 : relevant.tagName) === 'EMU-GRAMMAR') || | ||
(!isSdo && | ||
next != null && | ||
(relevant === null || relevant === void 0 ? void 0 : relevant.tagName) === 'EMU-ALG' && | ||
!(relevant === null || relevant === void 0 ? void 0 : relevant.hasAttribute('replaces-step')))) { | ||
if (paras.length > 1 || next !== dl.nextElementSibling) { | ||
@@ -531,0 +537,0 @@ const whitespace = next.previousSibling; |
@@ -73,3 +73,3 @@ "use strict"; | ||
const oneOffGrammars = []; | ||
const actualGrammarProductions = (0, utils_1.getProductions)(grammar); | ||
const actualGrammarProductions = (0, utils_1.getProductions)(grammar.rootFiles); | ||
const grammarsAndRules = [ | ||
@@ -92,3 +92,3 @@ ...sdos.map(s => ({ grammar: s.grammar, rules: [s.alg], type: 'syntax-directed operation' })), | ||
oneOffGrammars.push({ grammarEle, grammar }); | ||
const productions = (0, utils_1.getProductions)(grammar); | ||
const productions = (0, utils_1.getProductions)(grammar.sourceFiles); | ||
for (const [name, { production, rhses }] of productions) { | ||
@@ -103,3 +103,3 @@ const originalRhses = (_a = actualGrammarProductions.get(name)) === null || _a === void 0 ? void 0 : _a.rhses; | ||
} | ||
const { line, column } = (0, utils_1.getLocationInGrammar)(grammar, production.pos); | ||
const { line, column } = (0, utils_1.getLocationInGrammarFile)(grammar.sourceFiles[0], production.pos); | ||
report({ | ||
@@ -117,3 +117,3 @@ type: 'contents', | ||
if (!originalRhses.some(o => (0, utils_1.rhsMatches)(rhs, o))) { | ||
const { line, column } = (0, utils_1.getLocationInGrammar)(grammar, rhs.pos); | ||
const { line, column } = (0, utils_1.getLocationInGrammarFile)(grammar.sourceFiles[0], rhs.pos); | ||
report({ | ||
@@ -134,3 +134,3 @@ type: 'contents', | ||
if (s.symbol.kind === grammarkdown_1.SyntaxKind.NoSymbolHereAssertion) { | ||
const { line, column } = (0, utils_1.getLocationInGrammar)(grammar, s.symbol.pos); | ||
const { line, column } = (0, utils_1.getLocationInGrammarFile)(grammar.sourceFiles[0], s.symbol.pos); | ||
report({ | ||
@@ -149,3 +149,3 @@ type: 'contents', | ||
if (rhs.constraints !== undefined) { | ||
const { line, column } = (0, utils_1.getLocationInGrammar)(grammar, rhs.constraints.pos); | ||
const { line, column } = (0, utils_1.getLocationInGrammarFile)(grammar.sourceFiles[0], rhs.constraints.pos); | ||
report({ | ||
@@ -152,0 +152,0 @@ type: 'contents', |
@@ -42,3 +42,4 @@ "use strict"; | ||
// this needs its own rule to catch +0 as a real number | ||
pattern: /(?<= )\+[0-9]/gu, | ||
// (but not similar text such as expanded-year dates like +000000-01-01) | ||
pattern: /(?<= )\+[0-9](?![0-9]*[+-])/gu, | ||
message: 'positive real numbers should not have a leading plus sign (+)', | ||
@@ -67,4 +68,7 @@ }, | ||
{ | ||
pattern: /[Bb]ehavior/gu, | ||
message: 'ECMA-262 uses Oxford spelling ("behaviour")', | ||
// it would be best to somehow literally check against en-GB-oxendict, | ||
// but absent that we use the sample list from | ||
// https://en.wikipedia.org/wiki/American_and_British_English_spelling_differences#-our%2C_-or | ||
pattern: /\b(?:[Bb]ehaviors?|[Ff]lavors?|[Hh]arbors?|[Hh]onors?|[Hh]umors?|[Ll]abors?|[Nn]eighbors?|[Rr]umors?|[Ss]plendors?)\b/gu, | ||
message: 'ECMA-262 uses Oxford spelling ("behaviour", etc.)', | ||
}, | ||
@@ -71,0 +75,0 @@ { |
@@ -41,4 +41,7 @@ "use strict"; | ||
} | ||
// @ts-ignore we are intentionally adding a property here | ||
if (name !== +grammar.sourceFiles[name].filename) { | ||
throw new Error(`grammarkdown file mismatch: ${name} vs ${grammar.sourceFiles[name].filename}. This is a bug in ecmarkup; please report it.`); | ||
} | ||
node.grammarkdownOut = source; | ||
node.grammarSource = grammar.sourceFiles[name]; | ||
}); | ||
@@ -50,4 +53,7 @@ for (const { grammarEle, grammar } of oneOffGrammars) { | ||
} | ||
// @ts-ignore we are intentionally adding a property here | ||
if (grammar.rootFiles.length !== 1) { | ||
throw new Error(`grammarkdown file count mismatch: ${grammar.rootFiles.length}. This is a bug in ecmarkup; please report it.`); | ||
} | ||
grammarEle.grammarkdownOut = source; | ||
grammarEle.grammarSource = grammar.rootFiles[0]; | ||
}); | ||
@@ -54,0 +60,0 @@ } |
@@ -1,5 +0,5 @@ | ||
import type { Production, RightHandSide, OneOfList } from 'grammarkdown'; | ||
import type { Production, RightHandSide, OneOfList, SourceFile } from 'grammarkdown'; | ||
import type { Node as EcmarkdownNode } from 'ecmarkdown'; | ||
import { Grammar as GrammarFile } from 'grammarkdown'; | ||
export declare function getProductions(grammar: GrammarFile): Map<string, { | ||
export declare function getProductions(sourceFiles: readonly SourceFile[]): Map<string, { | ||
production: Production; | ||
@@ -9,3 +9,3 @@ rhses: (RightHandSide | OneOfList)[]; | ||
export declare function rhsMatches(a: RightHandSide | OneOfList, b: RightHandSide | OneOfList): boolean; | ||
export declare function getLocationInGrammar(grammar: GrammarFile, pos: number): { | ||
export declare function getLocationInGrammarFile(file: SourceFile, pos: number): { | ||
line: number; | ||
@@ -12,0 +12,0 @@ column: number; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.collectNonterminalsFromEmd = exports.collectNonterminalsFromGrammar = exports.getLocationInGrammar = exports.rhsMatches = exports.getProductions = void 0; | ||
exports.collectNonterminalsFromEmd = exports.collectNonterminalsFromGrammar = exports.getLocationInGrammarFile = exports.rhsMatches = exports.getProductions = void 0; | ||
const grammarkdown_1 = require("grammarkdown"); | ||
const emd = require("ecmarkdown"); | ||
function getProductions(grammar) { | ||
function getProductions(sourceFiles) { | ||
const productions = new Map(); | ||
grammar.rootFiles.forEach(f => f.elements.forEach(e => { | ||
sourceFiles.forEach(f => f.elements.forEach(e => { | ||
if (e.kind !== grammarkdown_1.SyntaxKind.Production) { | ||
@@ -140,4 +140,3 @@ // The alternatives supported by Grammarkdown are imports and defines, which ecma-262 does not use. | ||
// this is only for use with single-file grammars | ||
function getLocationInGrammar(grammar, pos) { | ||
const file = grammar.sourceFiles[0]; | ||
function getLocationInGrammarFile(file, pos) { | ||
const posWithoutWhitespace = (0, grammarkdown_1.skipTrivia)(file.text, pos, file.text.length); | ||
@@ -148,3 +147,3 @@ const { line: gmdLine, character: gmdCharacter } = file.lineMap.positionAt(posWithoutWhitespace); | ||
} | ||
exports.getLocationInGrammar = getLocationInGrammar; | ||
exports.getLocationInGrammarFile = getLocationInGrammarFile; | ||
class CollectNonterminalsFromGrammar extends grammarkdown_1.NodeVisitor { | ||
@@ -159,3 +158,3 @@ constructor(grammar) { | ||
name: node.name.text, | ||
loc: getLocationInGrammar(this.grammar, node.name.pos), | ||
loc: getLocationInGrammarFile(this.grammar.sourceFiles[0], node.name.pos), | ||
}); | ||
@@ -167,3 +166,3 @@ return super.visitProduction(node); | ||
name: node.name.text, | ||
loc: getLocationInGrammar(this.grammar, node.name.pos), | ||
loc: getLocationInGrammarFile(this.grammar.sourceFiles[0], node.name.pos), | ||
}); | ||
@@ -170,0 +169,0 @@ return super.visitNonterminal(node); |
{ | ||
"name": "ecmarkup", | ||
"version": "12.0.3", | ||
"version": "12.1.0", | ||
"description": "Custom element definitions and core utilities for markup that specifies ECMAScript and related technologies.", | ||
@@ -5,0 +5,0 @@ "main": "lib/ecmarkup.js", |
Sorry, the diff of this file is too big to display
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
423490
11274
10