- Breaking change: Extension now formatted as export (and this is set to editor, including for callback)
- Breaking change: Locale now formatted as export - Breaking change: Moved out remaining modular i18n (imagelib) to own folder - Breaking change: Drop `executeAfterLoads` (and getJSPDF/getCanvg) - Breaking change: `RGBColor` must accept `new` - Breaking change: canvg - `stackBlurCanvasRGBA` must be set now by function (`setStackBlurCanvasRGBA`) rather than global; `canvg` now a named export - Breaking change: Avoid passing `canvg`/`buildCanvgCallback` to extensions (have them import) - Fix: i18nize imaglib more deeply - Fix: Positioning of Document Properties dialog (Fixes #246) - Fix (regression): PDF Export (Fixes #249) - Fix (regression): Add polyfill for `ChildNode`/`ParentNode` (and use further) - Fix (regression): Apply Babel universally to dependencies - Fix (regression): Ordering of `uaPrefix` function in `svgEditor.js` - Fix (regression): Embedded API - Fix (embedded editor): Fix backspace key in Firefox so it doesn't navigate out of frame - Fix: Alert if no exportWindow for PDF (e.g., if blocked) - Refactoring( RGBColor) `RGBColor` as class, without rebuilding constants, optimize string replacement, move methods to prototype, use templates and object literals, use `Object.keys` - Refactoring (canvg) Use classes more internally, use shorthand objects; array extras, return to lazy-loading - Refactoring: Use Promises in place of `$.getScript`; always return Promises in case deciding to await resolving - Refactoring: Avoid importing `RGBColor` into `svgutils.js` (jsPDF imports it itself) - Refactoring: Arrow functions, destructuring, shorter property references - Refactoring: Fix `lang` and `dir` for locales (though not in use currently anyways) - Refactoring: Provide path config for canvg, jspdf
This commit is contained in:
@@ -9,9 +9,24 @@ import {uglify} from 'rollup-plugin-uglify';
|
||||
import {minify} from 'uglify-es';
|
||||
import replace from 'rollup-plugin-re';
|
||||
|
||||
const fs = require('fs');
|
||||
const localeFiles = fs.readdirSync('editor/locale');
|
||||
const extensionFiles = fs.readdirSync('editor/extensions');
|
||||
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 = {
|
||||
@@ -23,7 +38,9 @@ function getRollupObject ({minifying, format = 'umd'} = {}) {
|
||||
name: 'svgEditor'
|
||||
},
|
||||
plugins: [
|
||||
babel()
|
||||
babel({
|
||||
plugins: ['transform-object-rest-spread']
|
||||
})
|
||||
]
|
||||
};
|
||||
if (minifying) {
|
||||
@@ -44,6 +61,20 @@ export default [
|
||||
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: {
|
||||
@@ -54,6 +85,16 @@ export default [
|
||||
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: {
|
||||
@@ -66,40 +107,57 @@ export default [
|
||||
})
|
||||
]
|
||||
},
|
||||
{
|
||||
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
|
||||
if (!(/^lang\.[\w-]+?\.js$/).test(localeFile)) {
|
||||
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: [
|
||||
replace({
|
||||
patterns: [
|
||||
{
|
||||
match: /editor\/locale/,
|
||||
test: `import svgEditor from '../svg-editor.js';`,
|
||||
replace: ''
|
||||
}
|
||||
]
|
||||
}),
|
||||
babel() // Probably don't need here, but...
|
||||
]
|
||||
};
|
||||
}),
|
||||
...extensionFiles.map((extensionFile) => {
|
||||
// ext-*.js
|
||||
if (!(/^ext-[\w-]+?\.js$/).test(extensionFile)) {
|
||||
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: [
|
||||
@@ -117,8 +175,7 @@ export default [
|
||||
*/
|
||||
...[
|
||||
// For now, we'll replace with globals
|
||||
// We'll still make at least one import: editor/ext-locale/storage.js
|
||||
`import svgEditor from '../svg-editor.js';`,
|
||||
// We'll still make at least one import: editor/ext-locale/storage/
|
||||
`import '../pathseg.js';`
|
||||
].map((test) => {
|
||||
return {
|
||||
@@ -129,7 +186,9 @@ export default [
|
||||
})
|
||||
]
|
||||
}),
|
||||
babel()
|
||||
babel({
|
||||
plugins: ['transform-object-rest-spread']
|
||||
})
|
||||
]
|
||||
};
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user