- Breaking change: Rename "svgutils.js" to "utilities.js" (make in conformity with JSDoc module naming convention) - Breaking change: Rename "svgedit.js" to "namespaces.js" (to make clear purpose and avoid confusing with editor) - Breaking change: Rename "jquery-svg.js" to "jQuery.attr.js" - Breaking change: Rename "jquery.contextMenu.js" to "jQuery.contextMenu.js" - Breaking change: Rename "jquery.jpicker.js" to "jQuery.jPicker.js" - Breaking change: Rename "JQuerySpinBtn.css" to "jQuery.SpinButton.css" - Breaking change: Rename "JQuerySpinBtn.js" to "jQuery.SpinButton.js" (to have file name more closely reflect name) - Breaking change: Rename "jquery.svgicons.js" to "jQuery.svgIcons.js" - Breaking change: Rename "jquery.jgraduate.js" to "jQuery.jGraduate.js" - Breaking change: Rename "pathseg.js" to "svgpathseg.js" (as it is a poyfill of SVGPathSeg) - Breaking change: Rename `addSvgElementFromJson()` to `addSVGElementFromJson` for consistency - Breaking change: Rename `changeSvgContent()` to `changeSVGContent()` for consistency - Breaking change: Have `exportPDF` resolve with `output` and `outputType` rather than `dataurlstring` (as type may vary) - Breaking change: Rename `extensions/mathjax/MathJax.js` to `extensions/mathjax/MathJax.min.js` - Breaking change: Avoid recent change to have editor ready callbacks return Promises (we're not using and advantageous to keep sequential) - Breaking change: Avoid recent addition of locale-side function in ext-imagelib for l10n - Breaking change: Change name of ext-arrows.js from `Arrows` to `arrows` for sake of file path (not localized anyways). - Breaking change: Change `addlangData` extension event to `addLangData` for consistency with method name - Breaking change: Have `readLang` return lang and data but do not call `setLang` - Fix: Have general locales load first so extensions may use - Fix: Provide `importLocale` to extensions `init` so it may delay adding of the extension until locale data loaded - Fix: Ensure call to `rasterExport` without `imgType` properly sets MIME type to PNG - Fix: Wrong name for moinsave - Update: Update WebAppFind per new API changes - Enhancement: Make `setStrings` public on editor for late setting (used by `ext-shapes.js`) - Enhancement: Add `extensions_added` event - Enhancement: Add `message` event (Relay messages including those which have been been received prior to extension load) - Enhancement: Allow SVGEdit to work out of the box--avoid need for copying sample config file. Should also help with Github-based file servers - Enhancement: Allow avoiding "name" in extension export (just extract out of file name) - Enhancement: Add stack blur to canvg by default (and refactoring it) - Enhancement: Return `Promise` for `embedImage` (as with some other loading methods) - Enhancement: Supply `importLocale` to `langReady` to facilitate extension locale loading - Enhancement: Recover if an extension fails to load (just log and otherwise ignore) - Enhancement: More i18n of extensions (also fixed issue with some console warnings about missing locale strings); i18nize Hello World too - Enhancement: Allowing importing of locales within `addLangData` - npm: Update devDeps - Docs: Migrate copies of all old wiki pages to docs/from-old-wiki folder; intended for a possible move to Markdown, so raw HTML (with formatting) was not preserved, though named links had their absolute URL links preserved - Docs: Begin deleting `SvgCanvas.md` as ensuring jsdoc has replacements - Docs: Add Edtior doc file for help to general users - Docs: Clarify/simplify install instructions - npm/Docs (JSDoc): Add script to check for overly generic types - Docs (JSDoc): For config/prefs and extension creating, link to tutorials (moved tutorials to own directory to avoid recursion problems by jsdoc) - Docs (JSDoc): Add modules (upper case for usual main entrance files or regular names) - Docs (JSDoc): Fill out missing areas; indicate return of `undefined`; consistency with `@returns` - Docs (JSDoc): Add our own layout template to support overflow - Docs (JSDoc): Use cleverLinks and disallow unknown tags - Docs (JSDoc): Insist on "pedantic" flag; put output directory in config - Docs (JSDoc): Use more precise Integer/Float over number, the specific type of array/function/object - Docs (JSDoc): Use `@throws`, `@enum`, `@event`/`@fires`/`@listens` - Docs: Generally update/improve docs (fixes #92) - Docs: Update links to `latest` path (Avoid needing to update such references upon each release) - Docs: 80 chars max - Refactoring: Drop code for extension as function (already requiring export to be an object) - Refactoring: Object destructuring, `Object.entries`, Object shorthand, array extras, more camelCase variable names - Refactoring: Add a `Command` base class - Refactoring: Simplify svgicons `callback` ready detection - Refactoring: Put `let` or `const` closer to scope - Refactoring: Remove unneeded `delimiter` from regex escaping utility - Refactoring: Clearer variable names - Refactoring: Use (non-deprecated) Event constructors - Testing: Use new Sinon
196 lines
4.9 KiB
JavaScript
196 lines
4.9 KiB
JavaScript
/* eslint-env node */
|
|
|
|
// NOTE:
|
|
// See rollup-config.config.js instead for building the main (configurable)
|
|
// user entrance file
|
|
|
|
import babel from 'rollup-plugin-babel';
|
|
import {uglify} from 'rollup-plugin-uglify';
|
|
import {minify} from 'uglify-es';
|
|
import replace from 'rollup-plugin-re';
|
|
|
|
const {lstatSync, readdirSync} = require('fs');
|
|
const localeFiles = readdirSync('editor/locale');
|
|
const extensionFiles = readdirSync('editor/extensions');
|
|
const {join, basename} = require('path');
|
|
|
|
const isDirectory = (source) => {
|
|
return lstatSync(source).isDirectory();
|
|
};
|
|
const getDirectories = (source) => {
|
|
return readdirSync(source).map(name => join(source, name)).filter(isDirectory);
|
|
};
|
|
const extensionLocaleDirs = getDirectories('editor/extensions/ext-locale');
|
|
const extensionLocaleFiles = [];
|
|
extensionLocaleDirs.forEach((dir) => {
|
|
readdirSync(dir).forEach((file) => {
|
|
extensionLocaleFiles.push([dir, file]);
|
|
});
|
|
});
|
|
|
|
function getRollupObject ({minifying, format = 'umd'} = {}) {
|
|
const nonMinified = {
|
|
input: 'editor/svg-editor.js',
|
|
output: {
|
|
format,
|
|
sourcemap: minifying,
|
|
file: `dist/index-${format}${minifying ? '.min' : ''}.js`,
|
|
name: 'svgEditor'
|
|
},
|
|
plugins: [
|
|
babel({
|
|
plugins: ['transform-object-rest-spread']
|
|
})
|
|
]
|
|
};
|
|
if (minifying) {
|
|
nonMinified.plugins.push(uglify(null, minify));
|
|
}
|
|
return nonMinified;
|
|
}
|
|
|
|
// For debugging
|
|
// getRollupObject; // eslint-disable-line no-unused-expressions
|
|
|
|
export default [
|
|
// The first four are for those not using our HTML (though
|
|
// not currently recommended)
|
|
/**/
|
|
getRollupObject(),
|
|
getRollupObject({minifying: true}),
|
|
getRollupObject({minifying: true, format: 'es'}),
|
|
getRollupObject({minifying: false, format: 'es'}),
|
|
// **/
|
|
...extensionLocaleFiles.map(([dir, file]) => {
|
|
const lang = file.replace(/\.js$/, '').replace(/-/g, '_');
|
|
return {
|
|
input: join(dir, file),
|
|
output: {
|
|
format: 'iife',
|
|
name: `svgEditorExtensionLocale_${basename(dir)}_${lang}`,
|
|
file: `dist/extensions/ext-locale/${basename(dir)}/${file}`
|
|
},
|
|
plugins: [
|
|
babel()
|
|
]
|
|
};
|
|
}),
|
|
{
|
|
input: 'editor/redirect-on-lacking-support.js',
|
|
output: {
|
|
format: 'iife',
|
|
file: `dist/redirect-on-lacking-support.js`
|
|
},
|
|
plugins: [
|
|
babel()
|
|
]
|
|
},
|
|
{
|
|
input: 'editor/jspdf/jspdf.plugin.svgToPdf.js',
|
|
output: {
|
|
format: 'iife',
|
|
file: `dist/jspdf.plugin.svgToPdf.js`
|
|
},
|
|
plugins: [
|
|
babel()
|
|
]
|
|
},
|
|
{
|
|
input: 'editor/extensions/imagelib/index.js',
|
|
output: {
|
|
format: 'iife',
|
|
file: 'dist/extensions/imagelib/index.js'
|
|
},
|
|
plugins: [
|
|
babel({
|
|
plugins: ['transform-object-rest-spread']
|
|
})
|
|
]
|
|
},
|
|
{
|
|
input: 'editor/external/dom-polyfill/dom-polyfill.js',
|
|
output: {
|
|
format: 'iife',
|
|
file: 'dist/dom-polyfill.js'
|
|
},
|
|
plugins: [
|
|
babel()
|
|
]
|
|
},
|
|
{
|
|
input: 'editor/canvg/canvg.js',
|
|
output: {
|
|
format: 'iife',
|
|
name: 'canvg',
|
|
file: 'dist/canvg.js'
|
|
},
|
|
plugins: [
|
|
babel()
|
|
]
|
|
},
|
|
...localeFiles.map((localeFile) => {
|
|
// lang.*.js
|
|
const localeRegex = /^lang\.([\w-]+?)\.js$/;
|
|
const lang = localeFile.match(localeRegex);
|
|
if (!lang) {
|
|
return;
|
|
}
|
|
return {
|
|
input: 'editor/locale/' + localeFile,
|
|
output: {
|
|
format: 'iife',
|
|
name: 'svgEditorLang_' + lang[1].replace(/-/g, '_'),
|
|
file: 'dist/locale/' + localeFile
|
|
},
|
|
plugins: [
|
|
babel() // Probably don't need here, but...
|
|
]
|
|
};
|
|
}),
|
|
...extensionFiles.map((extensionFile) => {
|
|
// ext-*.js
|
|
const extensionName = extensionFile.match(/^ext-(.+?)\.js$/);
|
|
if (!extensionName) {
|
|
return;
|
|
}
|
|
return {
|
|
input: 'editor/extensions/' + extensionFile,
|
|
output: {
|
|
format: 'iife',
|
|
name: 'svgEditorExtension_' + extensionName[1].replace(/-/g, '_'),
|
|
file: 'dist/extensions/' + extensionFile
|
|
},
|
|
plugins: [
|
|
replace({
|
|
patterns: [
|
|
/*
|
|
// In place of replacing imports with globals, we supply
|
|
// what we can to the extension callback in svgcanvas.js
|
|
// (`addExtension` -> `getPrivateMethods`)
|
|
{
|
|
match: /editor\/extensions/,
|
|
test: '// <CONDITIONAL-ADD>: ',
|
|
replace: ''
|
|
},
|
|
*/
|
|
...[
|
|
// For now, we'll replace with globals
|
|
// We'll still make at least one import: editor/ext-locale/storage/
|
|
`import '../svgpathseg.js';`
|
|
].map((test) => {
|
|
return {
|
|
match: /editor\/extensions/,
|
|
test,
|
|
replace: ''
|
|
};
|
|
})
|
|
]
|
|
}),
|
|
babel({
|
|
plugins: ['transform-object-rest-spread']
|
|
})
|
|
]
|
|
};
|
|
})
|
|
].filter((exp) => exp);
|