-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(*): introduce a 'module' index (#51)
Adds ES2015 modules to the distribution: ES2015 modules in dist/es2015 a module key in package.json to indicate to webpack || rollup where to find them a sideEffects key (with value false) to indicate there's no side-effects in this package. Also reorganises the dist folder a bit - it now has separate folders for the cjs distribution (the default one - it's where main in package.json points to), es2015 (see above) and bundle - which is a webpack'ed, minimised version of the css distribution. Why? es2015 modules have some benefits in use over cjs - it a.o. enables build tools to weed out unused code ('tree shaking').
- Loading branch information
Showing
120 changed files
with
16,637 additions
and
399 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
"use strict"; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
exports.__esModule = true; | ||
var main = __importStar(require("./main/index")); | ||
var static_resolver_1 = __importDefault(require("./main/static-resolver")); | ||
/** | ||
* parses the given script and renders it in the DOM element with | ||
* id pOptions.elementId. | ||
* | ||
* @param {string} pScript The script to parse and render. Assumed | ||
* to be MscGen - unless specified | ||
* differently in pOptions.inputType | ||
* @param {object} pOptions options influencing parsing and | ||
* rendering. See below for the complete | ||
* list. | ||
* @param {function} pCallBack function with error, success | ||
* parameters. renderMsc will pass the | ||
* resulting svg in the success parameter | ||
* when successful, the error message | ||
* in the error parameter when not. | ||
* @return none | ||
* | ||
* Options: | ||
* elementId: the id of the DOM element to render in. Defaults to | ||
* "__svg". renderMsc assumes this element to exist. | ||
* inputType: language to parse - default "mscgen"; Possible values: | ||
* allowedValues.inputType | ||
* mirrorEntitiesOnBottom: draws entities on both top and bottom of | ||
* the chart when true. Defaults to false. | ||
* additionalTemplate: use one of the predefined templates. Default | ||
* null/ empty. Possible values: allowedValues.namedStyle | ||
* includeSource: whether the generated svg should include the script | ||
* in a desc element or not. Defaults to false | ||
*/ | ||
function renderMsc(pScript, pOptions, pCallBack) { | ||
main.renderMsc(pScript, pOptions || {}, pCallBack, static_resolver_1["default"].getParser, static_resolver_1["default"].getGraphicsRenderer); | ||
} | ||
exports.renderMsc = renderMsc; | ||
/** | ||
* Translates the input script to an outputscript. | ||
* | ||
* @param {string} pScript The script to translate | ||
* @param {object} pOptions options influencing parsing & rendering. | ||
* See below for the complete list. | ||
* @return {string} - the translated script | ||
* @throws {Error} - when there's something wrong | ||
* | ||
* Options: | ||
* inputType : the language of pScript defaults to "mscgen". Possible | ||
* values: allowedValues.inputType | ||
* outputType : defaults to "json". Possible values: | ||
* allowedValues.outputType | ||
*/ | ||
function translateMsc(pScript, pOptions) { | ||
return main.translateMsc(pScript, pOptions || {}, static_resolver_1["default"].getParser, static_resolver_1["default"].getTextRenderer); | ||
} | ||
exports.translateMsc = translateMsc; | ||
/** | ||
* The current (semver compliant) version number string of | ||
* mscgenjs | ||
* | ||
* @type {string} | ||
*/ | ||
exports.version = main.version; | ||
/** | ||
* | ||
* An object with arrays of allowed values for parameters in the | ||
* renderMsc and translateMsc functions. Each entry in these | ||
* arrays have a name (=the allowed value) and a boolean "experimental" | ||
* attribute. If that attribute is true, you'll hit a feature that is | ||
* under development when use that value. | ||
* | ||
* pOptions.inputType | ||
* pOptions.outputType | ||
* pOptions.namedStyle | ||
* | ||
*/ | ||
exports.getAllowedValues = main.getAllowedValues; | ||
/** | ||
* returns a parser module for the given language. The module exposes | ||
* a parse(pString) function which returns an abstract syntax tree in | ||
* json format as described in the link below. | ||
* | ||
* https://github.com/mscgenjs/mscgenjs-core/blob/master/parse/README.md#the-abstract-syntax-tree | ||
* | ||
* @param {string} pLanguage the language to get a parser for | ||
* Possible values: "mscgen", "msgenny", "xu" | ||
* "json". Defaults to "mscgen" | ||
* @return {object} | ||
*/ | ||
exports.getParser = static_resolver_1["default"].getParser; | ||
/** | ||
* returns a renderer that renders the abstract syntax tree as a scalable | ||
* vector graphics (in practice: @render/graphics/renderast) | ||
* | ||
* @deprecated use renderMsc instead to render graphics | ||
* | ||
* @return {object} | ||
*/ | ||
exports.getGraphicsRenderer = static_resolver_1["default"].getGraphicsRenderer; | ||
/** | ||
* returns a renderer to the given language. The module exposes a | ||
* render(pAST) function which returns a rendition of the abstract | ||
* syntax tree it got passed into the given language | ||
* | ||
* @deprecated use translateMsc instead to render text | ||
* | ||
* @return {object} | ||
*/ | ||
exports.getTextRenderer = static_resolver_1["default"].getTextRenderer; | ||
/* | ||
This file is part of mscgen_js. | ||
mscgen_js is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
mscgen_js is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with mscgen_js. If not, see <http://www.gnu.org/licenses/>. | ||
*/ |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"version": "3.0.0-beta-2" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import * as main from "./main"; | ||
import resolver from "./main/lazy-resolver"; | ||
/** | ||
* Exactly the same interface as @index.js - the only difference is that the | ||
* functions only load dependencies at the moment they need them. | ||
*/ | ||
module.exports = { | ||
/** | ||
* See the function of the same name in @index.js. | ||
*/ | ||
renderMsc(pScript, pOptions, pCallBack) { | ||
main.renderMsc(pScript, pOptions || {}, pCallBack, resolver.getParser, resolver.getGraphicsRenderer); | ||
}, | ||
/** | ||
* See the function of the same name in @index.js. | ||
*/ | ||
translateMsc(pScript, pOptions) { | ||
return main.translateMsc(pScript, pOptions || {}, resolver.getParser, resolver.getTextRenderer); | ||
}, | ||
/** | ||
* See the variable of the same name in @index.js. | ||
*/ | ||
version: main.version, | ||
/** | ||
* See the variable of the same name in @index.js. | ||
*/ | ||
getAllowedValues: main.getAllowedValues, | ||
/** | ||
* See the function of the same name in @index.js | ||
*/ | ||
getParser: resolver.getParser, | ||
/** | ||
* See the function of the same name in @index.js | ||
*/ | ||
getGraphicsRenderer: resolver.getGraphicsRenderer, | ||
/** | ||
* See the function of the same name in @index.js | ||
*/ | ||
getTextRenderer: resolver.getTextRenderer, | ||
}; | ||
/* | ||
This file is part of mscgen_js. | ||
mscgen_js is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
mscgen_js is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with mscgen_js. If not, see <http://www.gnu.org/licenses/>. | ||
*/ |
Oops, something went wrong.