Comparing version 1.5.12 to 1.5.13
@@ -5,2 +5,10 @@ # Release notes | ||
## 1.5.13 | ||
- Changes in 'README.md' file (CDN instructions and links, badges, build | ||
instructions, ISBN link, etc.). | ||
- Changes to build scripts ('script' directory): some console messages issued | ||
using `console.warn` and `console.error` instead of `console.log`. | ||
- The structure of the build files in the 'package.json' file has been | ||
modified (cleanup scripts). | ||
## 1.5.12 | ||
@@ -7,0 +15,0 @@ - Some changes in 'README.md' file (links to mathjslab.com). |
{ | ||
"name": "mathjslab", | ||
"version": "1.5.12", | ||
"description": "MathJSLab - An interpreter with language syntax like MATLAB®/Octave. ISBN 978-65-00-82338-7", | ||
"version": "1.5.13", | ||
"description": "MathJSLab - An interpreter with language syntax like MATLAB®/Octave, ISBN 978-65-00-82338-7.", | ||
"main": "lib/mathjslab.js", | ||
@@ -19,2 +19,3 @@ "types": "lib/src/lib.d.ts", | ||
"ANTLR", | ||
"ANTLR4", | ||
"math", | ||
@@ -36,6 +37,7 @@ "lexer", | ||
"clean:build": "rimraf lib", | ||
"clean:antlr:tokens:interp": "rimraf ./src/.antlr ./src/MathJSLabLexer.tokens ./src/MathJSLabLexer.interp ./src/MathJSLabParser.tokens ./src/MathJSLabParser.interp", | ||
"clean:parser": "npm run clean:antlr:tokens:interp && rimraf ./src/MathJSLabLexer.ts ./src/MathJSLabParser.ts", | ||
"clean": "npm run clean:resources && npm run clean:parser && npm run clean:build", | ||
"clean:all": "npm run clean && npm run clean:package-lock", | ||
"clean:parser-tokens-interp": "rimraf ./src/.antlr ./src/MathJSLabLexer.tokens ./src/MathJSLabLexer.interp ./src/MathJSLabParser.tokens ./src/MathJSLabParser.interp", | ||
"clean:parser-src": "rimraf ./src/MathJSLabLexer.ts ./src/MathJSLabParser.ts", | ||
"clean:parser": "npm run clean:parser-src && npm run clean:parser-tokens-interp", | ||
"clean": "npm run clean:build && npm run clean:parser", | ||
"clean:all": "npm run clean && npm run clean:resources && npm run clean:package-lock", | ||
"update": "npx ncu -u && npm install && npm run build:resources", | ||
@@ -60,4 +62,3 @@ "git:add": "git add .", | ||
"build": "tsx --require tsconfig-paths/register ./node_modules/webpack/bin/webpack --mode production", | ||
"postbuild": "npm run clean:antlr:tokens:interp", | ||
"do:all": "npm run clean && npm run update && npm run format:lint && npm run build && npm run add:commit:push:publish" | ||
"do:all": "npm run clean:all && npm run update && npm run format:lint && npm run test && npm run build && npm run add:commit:push:publish" | ||
}, | ||
@@ -73,3 +74,3 @@ "browser": { | ||
"@types/jest": "29.5.13", | ||
"@types/node": "^22.7.3", | ||
"@types/node": "^22.7.4", | ||
"@types/supertest": "^6.0.2", | ||
@@ -76,0 +77,0 @@ "@types/webpack": "^5.28.5", |
133
README.md
@@ -7,15 +7,19 @@ <p align="center"> | ||
[![npm version](https://img.shields.io/npm/v/mathjslab)](https://www.npmjs.com/package/mathjslab) | ||
[![npm license](https://img.shields.io/npm/l/mathjslab)](https://github.com/sergiolindau/mathjslab/blob/main/LICENSE) | ||
[![npm downloads](https://img.shields.io/npm/d18m/mathjslab)](https://www.npmjs.com/package/mathjslab) | ||
[![npm bundle size](https://img.shields.io/bundlephobia/min/mathjslab)](https://unpkg.com/mathjslab/) | ||
[![minzip size](https://img.shields.io/bundlephobia/minzip/mathjslab)](https://unpkg.com/mathjslab/) | ||
[![npm package minimized gzipped size](https://img.shields.io/bundlejs/size/mathjslab)](https://unpkg.com/mathjslab/) | ||
[![install size](https://packagephobia.com/badge?p=mathjslab)](https://packagephobia.com/result?p=mathjslab) | ||
[![GitHub Created At](https://img.shields.io/github/created-at/sergiolindau/mathjslab-calculator)](https://github.com/sergiolindau/mathjslab-calculator) | ||
[![NPM Version](https://img.shields.io/npm/v/mathjslab)](https://www.npmjs.com/package/mathjslab) | ||
[![Website](https://img.shields.io/website?url=https%3A%2F%2Fmathjslab.com%2F)](https://mathjslab.com/) | ||
[![GitHub Created At](https://img.shields.io/github/created-at/sergiolindau/mathjslab-calculator)](https://github.com/sergiolindau/mathjslab) | ||
[![NPM License](https://img.shields.io/npm/l/mathjslab)](https://github.com/sergiolindau/mathjslab/blob/main/LICENSE) | ||
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.8396265.svg)](https://doi.org/10.5281/zenodo.8396265) | ||
[![ISBN](https://img.shields.io/badge/ISBN-978--65--00--82338--7-green?style=flat&link=https://grp.isbn-international.org/search/piid_solr?keys=978-65-00-82338-7)](https://grp.isbn-international.org/search/piid_solr?keys=978-65-00-82338-7) | ||
[![NPM Downloads](https://img.shields.io/npm/d18m/mathjslab)](https://www.npmjs.com/package/mathjslab) | ||
[![jsDelivr hits (npm)](https://img.shields.io/jsdelivr/npm/hy/mathjslab)](https://www.jsdelivr.com/package/npm/mathjslab) | ||
[![Libraries.io SourceRank](https://img.shields.io/librariesio/sourcerank/npm/mathjslab)](https://libraries.io/npm/mathjslab) | ||
[![NPM Bundle Size](https://img.shields.io/bundlephobia/min/mathjslab)](https://www.npmjs.com/package/mathjslab) | ||
[![NPM Unpacked Size](https://img.shields.io/npm/unpacked-size/mathjslab)](https://www.npmjs.com/package/mathjslab) | ||
[![Minzip Size](https://img.shields.io/bundlephobia/minzip/mathjslab)](https://www.npmjs.com/package/mathjslab) | ||
[![NPM package minimized gzipped size](https://img.shields.io/bundlejs/size/mathjslab)](https://www.npmjs.com/package/mathjslab) | ||
> An interpreter with language syntax like [MATLAB®](https://www.mathworks.com/)/[Octave](https://www.gnu.org/software/octave/) written in [Typescript](https://www.typescriptlang.org/). | ||
**ISBN 978-65-00-82338-7** | ||
**[ISBN 978-65-00-82338-7](https://grp.isbn-international.org/search/piid_solr?keys=978-65-00-82338-7)** | ||
@@ -54,5 +58,5 @@ This package emulates a parser and evaluator for a subset of | ||
- Comes with a large set of built-in functions and constants. | ||
- Is easily extensible through configuration parameters passed to Evaluator constructor. | ||
- Is easily extensible through configuration parameters passed to `Evaluator` constructor. | ||
- [Open source](https://en.wikipedia.org/wiki/Open-source_software) with fully documented code: [MIT License](https://opensource.org/license/mit). | ||
- Includes test suite using [Jest](https://jestjs.io/). | ||
- Includes test suite using [Jest](https://jestjs.io/) [framework](https://en.wikipedia.org/wiki/Software_framework). | ||
- Improved demo [Web application](https://en.wikipedia.org/wiki/Web_application) at project page: [mathjslab.com](https://mathjslab.com/) ([repository](https://github.com/sergiolindau/mathjslab-calculator)). | ||
@@ -89,3 +93,3 @@ | ||
Initialize evaluator with: | ||
Instantiate the `Evaluator` class with: | ||
@@ -96,5 +100,5 @@ ```typescript | ||
### Examples: | ||
### Examples | ||
* Parsing | ||
* **Parsing**: | ||
```typescript | ||
@@ -104,3 +108,3 @@ let input: AST.NodeInput = evaluator.Parse('x=sqrt(1+2*3)'); | ||
* Evaluation | ||
* **Evaluation**: | ||
```typescript | ||
@@ -110,3 +114,3 @@ let result: AST.NodeInput = evaluator.Evaluate(input); | ||
* MathML generation | ||
* **[MathML](https://www.w3.org/Math/) generation**: | ||
```typescript | ||
@@ -117,17 +121,41 @@ let mathmlInput: string = evaluator.UnparseMathML(input); | ||
## Using UNPKG CDN | ||
## Using a [CDN](https://en.wikipedia.org/wiki/Content_delivery_network) | ||
You can optimize your application, reducing the size of your bundle, loading | ||
[MathJSLab](https://mathjslab.com/) via the [UNPKG](https://www.unpkg.com/) [CDN](https://en.wikipedia.org/wiki/Content_delivery_network). | ||
You can optimize your application by reducing the size of your bundle by | ||
loading [MathJSLab package](https://www.npmjs.com/package/mathjslab) through a | ||
[CDN](https://en.wikipedia.org/wiki/Content_delivery_network). | ||
You can use [UNPKG](https://unpkg.com/), [jsDelivr](https://www.jsdelivr.com/), | ||
or any other [CDN](https://en.wikipedia.org/wiki/Content_delivery_network) | ||
that delivers content from the [npm repository](https://www.npmjs.com/). | ||
### Using [UNPKG](https://unpkg.com/) | ||
To load [MathJSLab package](https://www.npmjs.com/package/mathjslab) through | ||
[UNPKG](https://unpkg.com/browse/mathjslab/) | ||
[CDN](https://en.wikipedia.org/wiki/Content_delivery_network) copy the | ||
following [HTML](https://en.wikipedia.org/wiki/HTML) code: | ||
```html | ||
<head> | ||
... | ||
<script defer type="module" src="https://www.unpkg.com/mathjslab"></script> | ||
... | ||
</head> | ||
<script src="https://www.unpkg.com/mathjslab"></script> | ||
``` | ||
The module will be loaded with `mathjslab` name. You can instantiate `Evaluator` with: | ||
### Using [jsDelivr](https://www.jsdelivr.com/) | ||
[![jsDelivr hits (npm)](https://img.shields.io/jsdelivr/npm/hy/mathjslab)](https://www.jsdelivr.com/package/npm/mathjslab) | ||
To load [MathJSLab package](https://www.npmjs.com/package/mathjslab) through | ||
[jsDelivr](https://www.jsdelivr.com/package/npm/mathjslab) | ||
[CDN](https://en.wikipedia.org/wiki/Content_delivery_network) copy the | ||
following [HTML](https://en.wikipedia.org/wiki/HTML) code: | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/mathjslab/lib/mathjslab.min.js"></script> | ||
``` | ||
### [MathJSLab](https://www.npmjs.com/package/mathjslab) [module](https://github.com/umdjs/umd) use | ||
The [UMD module](https://github.com/umdjs/umd) will be loaded with `mathjslab` name. You can instantiate `Evaluator` with: | ||
```typescript | ||
@@ -146,10 +174,19 @@ let evaluator = new mathjslab.Evaluator(EvaluatorConfiguration); | ||
## Build and Test | ||
## Project build and test | ||
To build the project, you only need [Node.js®](https://nodejs.org/) and the | ||
[Java Runtime Environment](https://www.oracle.com/java/) installed. The project | ||
dependencies are managed by npm. The build scripts download the latest version | ||
of ANTLR into the resources directory for use by the project. Before building | ||
and testing the project, run: | ||
To build the project, you only need [Node.js®](https://nodejs.org/) and | ||
the [Java Runtime Environment](https://www.oracle.com/java/) installed. The | ||
project build and dependencies are managed by | ||
[npm](https://www.npmjs.com/package/npm) through scripts in the | ||
[`package.json`](https://github.com/sergiolindau/mathjslab/blob/main/package.json) | ||
file. The build scripts download the latest version of | ||
[ANTLR](https://www.antlr.org/) into the resources directory for use by the | ||
project. | ||
The test suite uses the | ||
[Jest](https://jestjs.io/) | ||
[framework](https://en.wikipedia.org/wiki/Software_framework). | ||
* **Before building and testing** the project, to **initialize** the workspace, run: | ||
```bash | ||
@@ -159,5 +196,6 @@ npm run update | ||
This will update the dependencies, install all of them, and download the latest version of ANTLR, preparing any resources needed to build the project. | ||
This will update the dependencies, install all of them, and download the | ||
latest version of ANTLR, preparing any resources needed to build the project. | ||
Run the `mathjslab` tests: | ||
* Run the `mathjslab` **tests**: | ||
@@ -168,8 +206,31 @@ ```bash | ||
Build `mathjslab`: | ||
* **Format** and **lint** `mathjslab` code: | ||
```bash | ||
npm run format:lint | ||
``` | ||
* **Build** `mathjslab` package: | ||
```bash | ||
npm run build | ||
``` | ||
* Workspace **cleanup**: | ||
To clean build files use: | ||
```bash | ||
npm run clean | ||
``` | ||
To delete resources, `package-lock.json` file and `node_modules` directory too, use: | ||
```bash | ||
npm run clean:all | ||
``` | ||
Before run this command you will need to do workspace setup running | ||
`npm run update` again. | ||
## Language subset | ||
@@ -188,5 +249,5 @@ | ||
>MIT License | ||
>[MIT License](https://opensource.org/license/mit) | ||
> | ||
>Copyright © 2016-2024 [Sergio Lindau](mailto:sergiolindau@gmail.com), [mathjslab.com](https://mathjslab.com/), ISBN 978-65-00-82338-7. | ||
>Copyright © 2016-2024 [Sergio Lindau](mailto:sergiolindau@gmail.com), [mathjslab.com](https://mathjslab.com/), [ISBN 978-65-00-82338-7](https://grp.isbn-international.org/search/piid_solr?keys=978-65-00-82338-7). | ||
> | ||
@@ -193,0 +254,0 @@ >Permission is hereby granted, free of charge, to any person obtaining a copy |
@@ -14,4 +14,3 @@ /** | ||
console.log(`Running ${__filename} ...`); | ||
console.log('Getting the latest version of ANTLR ...'); | ||
console.warn('Getting the latest version of ANTLR ...'); | ||
const links = Array.from(((await getHtmlParsed('https://www.antlr.org/download.html')) as unknown as HTMLElement).querySelectorAll('a')); | ||
@@ -54,4 +53,4 @@ let antlrVersion = ''; | ||
} | ||
console.log('Getting the latest version of ANTLR done.'); | ||
console.log(`Running ${__filename} done.`); | ||
console.warn('Getting the latest version of ANTLR done.'); | ||
console.log(`Running ${__filename} done.\n\n`); | ||
})(); |
@@ -35,2 +35,3 @@ import * as fs from 'node:fs'; | ||
file.on('error', (err) => { | ||
console.error(`downloadIfNotExist: ${err.message}`); | ||
reject(new EvalError(err.message)); | ||
@@ -37,0 +38,0 @@ }); |
@@ -27,2 +27,3 @@ import * as http from 'node:http'; | ||
response.on('error', (err: Error) => { | ||
console.error(`getHtmlParsed: ${err.message}`); | ||
reject(err.message); | ||
@@ -29,0 +30,0 @@ }); |
@@ -19,5 +19,7 @@ import { URL } from 'node:url'; | ||
} else { | ||
throw new URIError('protocol unrecognized.'); | ||
const message = 'httpGet: Protocol not recognized.'; | ||
console.error(message); | ||
throw new URIError(message); | ||
} | ||
return (protocol === 'https:' ? https : http).get(url, callback); | ||
}; |
@@ -12,3 +12,5 @@ import * as fs from 'node:fs'; | ||
fs.accessSync(directory, fs.constants.F_OK); | ||
console.log(`Directory ${directory} already exists.`); | ||
} catch { | ||
console.log(`Creating directory ${directory} ...`); | ||
fs.mkdirSync(directory, { recursive: true }); | ||
@@ -15,0 +17,0 @@ console.log(`Creating directory ${directory} done.`); |
@@ -10,2 +10,3 @@ /** | ||
console.warn('webpack.config.ts: Building production bundle.'); | ||
console.log('Environment variables:'); | ||
console.table(env); | ||
@@ -12,0 +13,0 @@ return { |
Sorry, the diff of this file is not supported yet
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
972907
11361
260