Skip to content

Commit 9f588aa

Browse files
committed
Merge branch 'develop'
2 parents b746572 + 3e6df37 commit 9f588aa

File tree

507 files changed

+5098
-3778
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

507 files changed

+5098
-3778
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: node_js
22
node_js:
3-
- stable
3+
- 17
44
sudo: false
55
script:
66
- npm install

components/bin/build

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const path = require('path');
3030
/**
3131
* The amount of space for each level of indentation
3232
*/
33-
const INDENT = ' ';
33+
const INDENT = ' ';
3434

3535
/**
3636
* The pattern to use when looking for explort commands to process
@@ -43,24 +43,36 @@ const EXPORT_PROCESS = ['let', 'const', 'var', 'function', 'class', 'namespace']
4343
/**
4444
* The relative path to the MathJax directory
4545
*/
46-
const mjPath = path.relative(process.cwd(), path.resolve(__dirname,'../../js'));
46+
const mjPath = path.relative(process.cwd(), path.resolve(__dirname, '..', '..', 'js'));
47+
const mjGlobal = path.join('..', mjPath, 'components', 'global.js');
4748

4849
/**
4950
* Read the configuration for the component
5051
*/
5152
const config = JSON.parse(fs.readFileSync(process.argv[2] || 'build.json'));
5253

54+
function getType() {
55+
const component = config.component || 'part';
56+
if (component.match(/\/(svg|chtml|common)\/fonts\//)) return RegExp.$1 + '-font';
57+
if (component.match(/\/(mathml|tex)\/.+\//)) return RegExp.$1 + '-extension';
58+
if (component.match(/^(.+)\//)) return RegExp.$1;
59+
return component;
60+
}
61+
5362
/**
5463
* Extract the configuration values
5564
*/
65+
const COMPONENT = path.basename(config.component || 'part'); // name of the component
66+
const ID = config.id || config.component || 'part'; // the ID of the component
5667
const TARGETS = config.targets || []; // the files to include in the component
5768
const EXCLUDE = new Map((config.exclude || []).map(name => [name, true])); // files to exclude from the component
58-
const EXCLUDESUBDIRS = config.excludeSubdirs === 'true'; // exclude subdirectories
59-
const MATHJAX = config.js || config.mathjax || mjPath; // path to the compiled .js files
69+
const EXCLUDESUBDIRS = config.excludeSubdirs === 'true'; // exclude subdirectories or not
70+
const JS = config.js || config.mathjax || mjPath; // path to the compiled .js files
6071
const LIB = config.lib || './lib'; // path to the lib directory to create
61-
const COMPONENT = path.basename(config.component || 'part'); // name of the component
62-
const GLOBAL = config.global || `../${MATHJAX}/components/global.js`; // the location of global.js
63-
const SRC = config.ts || MATHJAX.replace(/js$/, 'ts'); // path to the .ts files
72+
const TS = config.ts || JS.replace(/js$/, 'ts'); // path to the .ts files
73+
const GLOBAL = config.global || mjGlobal; // path to the global.js file
74+
const VERSION = config.version || mjGlobal.replace(/global/, 'version'); // path to the version.js file
75+
const TYPE = config.type || getType(); // the module type
6476

6577
/**
6678
* The list of files that need to be added to the lib directory
@@ -160,17 +172,15 @@ function processLines(file, objects) {
160172
if (objects.length === 0) return [];
161173
const dir = path.dirname(file).replace(/^\.$/, '');
162174
const dots = dir.replace(/[^\/]+/g, '..') || '.';
163-
const relative = path.join(dots, '..', MATHJAX, dir, path.basename(file)).replace(/\.ts$/, '.js');
175+
const relative = path.join(dots, '..', JS, dir, path.basename(file)).replace(/\.ts$/, '.js');
164176
const name = path.parse(file).name;
165177
const lines = [
166178
'"use strict";',
167179
`Object.defineProperty(exports, '__esModule', {value: true});`
168180
];
169-
let source = (dir.replace(/\//g, '.') + '.' + name).replace(/^\./, '')
181+
let source = ((dir.replace(/\//g, '.') + '.' + name).replace(/^\./, '')
182+
+ (exists(path.resolve(JS, file.replace(/\.ts$/, ''))) ? '_ts' : ''))
170183
.replace(/\.[^.]*/g, (x) => (x.substr(1).match(/[^a-zA-Z_]/) ? '[\'' + x.substr(1) + '\']' : x));
171-
if (exists(path.resolve(MATHJAX, file.replace(/\.ts$/, '')))) {
172-
source += '_ts';
173-
}
174184
for (const id of objects) {
175185
lines.push(`exports.${id} = MathJax._.${source}.${id};`);
176186
}
@@ -223,6 +233,7 @@ function processGlobal() {
223233
console.info(' ' + COMPONENT + '.ts');
224234
const lines = [
225235
`import {combineWithMathJax} from '${GLOBAL}';`,
236+
`import {VERSION} from '${VERSION}';`,
226237
'',
227238
];
228239
const packages = [];
@@ -231,9 +242,17 @@ function processGlobal() {
231242
const dir = path.dirname(PACKAGE[0]).split(path.sep)[0];
232243
packages.push(processPackage(lines, INDENT, dir));
233244
}
234-
lines.push('', `combineWithMathJax({_: {`);
235-
lines.push(INDENT + packages.join(',\n' + INDENT));
236-
lines.push('}});');
245+
const name = (ID.match(/[^a-zA-Z0-9_]/) ? `"${ID}"` : ID);
246+
lines.push(
247+
'',
248+
'if (MathJax.loader) {',
249+
INDENT + `MathJax.loader.checkVersion('${ID}', VERSION, '${TYPE}');`,
250+
'}',
251+
'',
252+
`combineWithMathJax({_: {`,
253+
INDENT + packages.join(',\n' + INDENT),
254+
'}});'
255+
);
237256
fs.writeFileSync(path.join(LIB, COMPONENT + '.js'), lines.join('\n') + '\n');
238257
}
239258

@@ -273,11 +292,11 @@ function processPackage(lines, space, dir) {
273292
if (path.dirname(PACKAGE[0]) === dir) {
274293
const file = PACKAGE.shift();
275294
const name = path.basename(file);
276-
const relativefile = path.join('..', MATHJAX, dir, name).replace(/\.ts$/, '.js');
295+
const relativefile = path.join('..', JS, dir, name).replace(/\.ts$/, '.js');
277296
const component = 'module' + (++importCount);
278297
lines.push(`import * as ${component} from '${relativefile}';`);
279298
let property = name.replace(/\.ts$/, '');
280-
if (property !== name && exists(path.resolve(MATHJAX, file.replace(/\.ts$/, '')))) {
299+
if (property !== name && exists(path.resolve(JS, file.replace(/\.ts$/, '')))) {
281300
property += '_ts';
282301
}
283302
if (property.match(/[^a-zA-Z0-9_]/)) {
@@ -324,5 +343,5 @@ function rmDir(dir) {
324343
//
325344
rmDir(LIB);
326345
console.info("Processing:");
327-
processList(SRC, '', TARGETS);
346+
processList(TS, '', TARGETS);
328347
processGlobal();

components/bin/makeAll

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,20 @@ const fs = require('fs');
2929
const path = require('path');
3030
const {execSync} = require('child_process');
3131

32+
const options = {
33+
recursive: true
34+
};
35+
3236
/**
33-
* Get the directories to process
37+
* Get the directories to process and check for options
3438
*/
3539
const dirs = process.argv.slice(2);
40+
41+
if (dirs[0] === '--no-subdirs') {
42+
dirs.shift();
43+
options.recursive = false;
44+
}
45+
3646
if (dirs.length === 0) {
3747
dirs.push('.');
3848
}
@@ -74,7 +84,9 @@ function processList(dirs) {
7484
*/
7585
function processDir(dir, action) {
7686
action(dir);
77-
processSubdirs(dir, action);
87+
if (options.recursive) {
88+
processSubdirs(dir, action);
89+
}
7890
}
7991

8092
/**

components/bin/pack

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function fileSize(file) {
4848
/**
4949
* Regular expressions for the components directory and the MathJax .js location
5050
*/
51-
const compRE = fileRegExp(path.join(path.dirname(__dirname), 'src'));
51+
const compRE = fileRegExp(path.dirname(__dirname));
5252
const rootRE = fileRegExp(path.join(path.dirname(path.dirname(__dirname)), 'js'));
5353
const nodeRE = fileRegExp(path.join(path.dirname(path.dirname(__dirname)), 'node_modules'));
5454

@@ -83,7 +83,7 @@ async function webpackLib(dir) {
8383
//
8484
// Get js directory from the webpack.config.js file
8585
//
86-
const jsdir = require(path.resolve(dir, 'webpack.config.js')).plugins[0].definitions.jsdir;
86+
const jsdir = require(path.resolve(dir, 'webpack.config.js')).plugins[0].definitions.__JSDIR__;
8787
const jsRE = fileRegExp(jsdir);
8888
const libRE = fileRegExp(path.resolve(jsdir, '..', 'components'));
8989

@@ -103,17 +103,27 @@ async function webpackLib(dir) {
103103
.replace(/ \+ \d+ modules/, '')
104104
.replace(dirRE, '.');
105105
}
106-
for (const module of modules.sort((a,b) => a.name < b.name ? -1 : 1)) {
106+
const list = [];
107+
for (const module of modules) {
107108
if (module.moduleType.match(/javascript/)) {
108-
const name = module.name
109-
.replace(compRE, '[components]')
110-
.replace(rootRE, '[mathjax]')
111-
.replace(nodeRE, '[node]')
112-
.replace(jsRE, '[js]')
113-
.replace(libRE, '[lib]');
114-
console.log(' ' + name + fileSize(module));
109+
let name = module.name
110+
.replace(compRE, '[components]')
111+
.replace(rootRE, '[mathjax]')
112+
.replace(nodeRE, '[node]')
113+
.replace(jsRE, '[js]')
114+
.replace(libRE, '[lib]');
115+
if (name.charAt(0) !== '.' && name.charAt(0) !== '[') {
116+
name = path.relative(dir, name);
117+
}
118+
list.push(' ' + name + fileSize(module));
115119
}
116120
}
121+
console.log(
122+
list
123+
.filter(a => a.slice(2, 4) === './').sort()
124+
.concat(list.filter(a => a.slice(2, 4) !== './').sort())
125+
.join('\n')
126+
);
117127
} catch (err) {
118128
console.error(err);
119129
}

components/src/a11y/complexity/build.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"targets": [
44
"a11y/complexity.ts",
55
"a11y/complexity",
6-
"a11y/semantic-enrich.ts",
7-
"a11y/sre.ts"
6+
"a11y/semantic-enrich.ts"
87
]
98
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"component": "a11y/explorer",
3-
"targets": ["a11y/explorer.ts", "a11y/sre.ts", "a11y/explorer"]
3+
"targets": ["a11y/explorer.ts", "a11y/explorer"]
44
}

components/src/a11y/explorer/webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = PACKAGE(
66
[ // packages to link to
77
'components/src/ui/menu/lib',
88
'components/src/a11y/semantic-enrich/lib',
9+
'components/src/a11y/sre/lib',
910
'components/src/input/mml/lib',
1011
'components/src/core/lib'
1112
],
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"component": "a11y/semantic-enrich",
3-
"targets": ["a11y/semantic-enrich.ts", "a11y/sre.ts"]
3+
"targets": ["a11y/semantic-enrich.ts"]
44
}
55

components/src/a11y/semantic-enrich/semantic-enrich.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import './lib/semantic-enrich.js';
22

33
import {combineDefaults} from '../../../../js/components/global.js';
4-
import {sreReady} from '../../../../js/a11y/sre.js';
4+
import Sre from '../../../../js/a11y/sre.js';
55
import {EnrichHandler} from '../../../../js/a11y/semantic-enrich.js';
66
import {MathML} from '../../../../js/input/mathml.js';
77

88
if (MathJax.loader) {
9-
combineDefaults(MathJax.config.loader, 'a11y/semantic-enrich', {checkReady: () => sreReady()});
9+
combineDefaults(MathJax.config.loader, 'a11y/semantic-enrich', {checkReady: () => Sre.sreReady()});
1010
}
1111

1212
if (MathJax.startup) {

components/src/a11y/semantic-enrich/webpack.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ module.exports = PACKAGE(
55
'../../../../js', // location of the MathJax js library
66
[ // packages to link to
77
'components/src/input/mml/lib',
8-
'components/src/core/lib'
8+
'components/src/core/lib',
9+
'components/src/a11y/sre/lib'
910
],
1011
__dirname // our directory
1112
);

0 commit comments

Comments
 (0)