diff --git a/.eslintignore b/.eslintignore index f6e8cd11..a76bdcd1 100644 --- a/.eslintignore +++ b/.eslintignore @@ -5,30 +5,32 @@ coverage instrumented dist docs/jsdoc +archive -svgedit-config-es.js -svgedit-config-iife.js +src/svgedit-config-es.js +src/svgedit-config-iife.js svgedit-custom.css -editor/xdomain-svgedit-config-iife.js +src/xdomain-svgedit-config-iife.js # Vendor/minified files -editor/jquery.min.js -editor/jquery-ui +src/editor/jquery.min.js +src/editor/jquery-ui # Previously minified though exporting -editor/js-hotkeys +src/editor/js-hotkeys -editor/jspdf/jspdf.min.js -editor/jspdf/underscore-min.js +src/editor/jspdf/jspdf.min.js +src/editor/jspdf/underscore-min.js -editor/extensions/mathjax +src/editor/extensions/mathjax # Todo: We should at least check `compat/compat` in our other files, however -editor/external/* -!editor/external/dom-polyfill -editor/external/dom-polyfill/* -!editor/external/dom-polyfill/dom-polyfill.js -!editor/external/dynamic-import-polyfill +## Two "external" items are modified locally, so we undo their ignoring +src/external/* +!src/external/dom-polyfill +src/external/dom-polyfill/* +!src/external/dom-polyfill/dom-polyfill.js +!src/external/dynamic-import-polyfill mochawesome-report releases diff --git a/.eslintrc.js b/.eslintrc.js index 823b3cb9..832a1d27 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -3,49 +3,149 @@ module.exports = { extends: ['ash-nazg/sauron-node'], parserOptions: { + ecmaVersion: 2020, sourceType: 'module' }, env: { - browser: true + browser: true, + es6: true }, settings: { polyfills: [ - ], - jsdoc: { - additionalTagNames: { - // In case we need to extend - customTags: [] - }, - augmentsExtendsReplacesDocs: true - // Todo: Figure out why this is not working and why seem to have to - // disable for all Markdown: - /* - baseConfig: { - rules: { - 'no-multi-spaces': 'off' + // These are the primary polyfills needed by regular users if + // not present, e.g., with core-js-bundle; also those under + // extensions + // 'Array.isArray', + // 'Blob', + // 'console', + // 'CustomEvent', + // 'document.body', + // 'document.createElementNS', + // 'document.evaluate', + // 'document.head', + // 'document.importNode', + // 'document.querySelector', + // 'document.querySelectorAll', + // 'DOMParser', + // 'Error', + 'fetch', + // 'FileReader', + // 'JSON', + // 'KeyboardEvent', + // 'location.href', + // 'location.origin', + // 'MouseEvent', + // 'MutationObserver', + // 'navigator', + // 'Number.isNaN', + // 'Number.parseFloat', + // 'Number.parseInt', + // 'Object.assign', + // 'Object.defineProperty', + // 'Object.defineProperties', + // 'Object.entries', + // 'Object.getOwnPropertyDescriptor', + // 'Object.keys', + // 'Object.values', + 'Promise', + 'Promise.all', + // 'Set', + 'Uint8Array', + 'URL' + // 'URL.createObjectURL', + // 'XMLSerializer', + // 'XMLHttpRequest', + // 'window.getComputedStyle', + // 'window.parent', + // 'window.scrollX', + // 'window.scrollY' + ] + }, + rules: { + // check-examples is not picking up eslint config properly in some + // environments; see also discussion above + // `mocha-cleanup/no-assertions-outside-it` + 'jsdoc/check-examples': ['warn', { + rejectExampleCodeRegex: '^`' + }], + + // https://github.com/sindresorhus/eslint-plugin-unicorn/issues/453 + 'unicorn/regex-shorthand': 0, + // The Babel transform seems to have a problem converting these + 'prefer-named-capture-group': 'off', + 'jsdoc/require-file-overview': ['error', { + tags: { + file: { + initialCommentsOnly: true, + preventDuplicates: true + }, + license: { + initialCommentsOnly: true, + preventDuplicates: true + }, + copyright: { + initialCommentsOnly: true, + preventDuplicates: true + }, + author: { + initialCommentsOnly: true, + preventDuplicates: true + }, + module: { + initialCommentsOnly: true, + preventDuplicates: true + }, + exports: { + initialCommentsOnly: true, + preventDuplicates: true } } - */ - } + }], + // Warning or Off for now but should be reviewed + // Override these rules which are difficult for us + // to apply at this time + 'unicorn/prefer-string-slice': 'off', + 'default-case': 'off', + 'require-unicode-regexp': 'off', + 'max-len': + [ + 'warn', + {ignoreComments: true, code: 130} + ], // 130 is too much but too many occurences + 'unicorn/prefer-query-selector': 'off', + 'unicorn/no-fn-reference-in-iterator': 'off', + 'unicorn/prefer-node-append': 'off', + 'unicorn/no-zero-fractions': 'off', + 'unicorn/prefer-number-properties': 'off', + 'eslint-comments/require-description': 'off', + 'compat/compat': 'error', + 'consistent-this': 'off', + 'import/no-anonymous-default-export': 'off', + 'node/no-unsupported-features/node-builtins': 'warn', + 'prefer-exponentiation-operator': 'warn' }, overrides: [ // Locales have no need for importing outside of SVG-Edit + // and translations may need a longer line length { files: [ - 'editor/locale/lang.*.js', 'editor/extensions/ext-locale/**', + 'src/editor/locale/lang.*.js', 'src/editor/extensions/ext-locale/**', 'docs/tutorials/ExtensionDocs.md' ], rules: { - 'import/no-anonymous-default-export': ['off'] + 'import/no-anonymous-default-export': 'off', + 'max-len': 'off' } }, // These browser files don't do importing or requiring { files: [ - 'editor/svgpathseg.js', 'editor/touch.js', 'editor/typedefs.js', - 'editor/redirect-on-no-module-support.js', - 'editor/extensions/imagelib/index.js', - 'editor/external/dom-polyfill/dom-polyfill.js', + 'src/editor/svgpathseg.js', + 'src/editor/touch.js', + 'src/editor/typedefs.js', + 'src/editor/redirect-on-no-module-support.js', + 'src/editor/extensions/imagelib/index.js', + 'src/external/dom-polyfill/dom-polyfill.js', 'screencasts/svgopen2010/script.js' ], rules: { @@ -97,7 +197,6 @@ module.exports = { // Used in examples of assert-close.js plugin 'mocha-cleanup/no-assertions-outside-it': 'off', 'eslint-comments/no-unused-disable': 'warn', - 'eol-last': ['off'], 'no-console': ['off'], 'no-undef': ['off'], @@ -116,118 +215,6 @@ module.exports = { indent: 'off' } }, - // Dis-apply Node rules mistakenly giving errors with browser files, - // and treating Node global `root` as being present for shadowing - { - files: ['editor/**'], - globals: { - root: 'off' - }, - settings: { - polyfills: [ - // These are the primary polyfills needed by regular users if - // not present, e.g., with core-js-bundle; also those under - // extensions - 'Array.isArray', - 'Blob', - 'console', - 'CustomEvent', - 'document.body', - 'document.createElementNS', - 'document.evaluate', - 'document.head', - 'document.importNode', - 'document.querySelector', - 'document.querySelectorAll', - 'DOMParser', - 'Error', - 'FileReader', - 'JSON', - 'KeyboardEvent', - 'location.href', - 'location.origin', - 'MouseEvent', - 'MutationObserver', - 'navigator', - 'Number.isNaN', - 'Number.parseFloat', - 'Number.parseInt', - 'Object.assign', - 'Object.defineProperty', - 'Object.defineProperties', - 'Object.entries', - 'Object.getOwnPropertyDescriptor', - 'Object.keys', - 'Object.values', - 'Promise', - 'Promise.all', - 'Set', - 'Uint8Array', - 'URL', - 'URL.createObjectURL', - 'XMLSerializer', - 'XMLHttpRequest', - 'window.getComputedStyle', - 'window.parent', - 'window.scrollX', - 'window.scrollY' - ] - }, - rules: { - // Should probably add this rule to ash-nazg as facilitates tree-shaking - 'import/no-namespace': ['error'], - - 'node/no-unsupported-features/node-builtins': 'off' - } - }, - // For extensions, `this` is generally assigned to be the more - // descriptive `svgEditor`; they also have no need for importing outside - // of SVG-Edit - { - files: ['editor/extensions/**'], - settings: { - polyfills: [ - 'console', - 'fetch', - 'location.origin', - 'Number.isNaN', - 'Number.parseFloat', - 'Number.parseInt', - 'window.postMessage' - ] - }, - rules: { - 'consistent-this': ['error', 'svgEditor'], - 'import/no-anonymous-default-export': ['off'] - } - }, - { - // Node files - files: [ - 'docs/jsdoc-config.js', - 'build/build-html.js', - 'rollup.config.js', 'rollup-config.config.js' - ], - env: { - node: true - }, - settings: { - polyfills: [ - 'console', - 'Promise.resolve' - ] - }, - globals: { - require: true - }, - rules: { - // We can't put Rollup in npmignore or user can't get access, - // and we have too many modules to add to `peerDependencies` - // so this rule can know them to be available, so we instead - // disable - 'node/no-unpublished-import': 'off' - } - }, { // As consumed by jsdoc, cannot be expressed as ESM files: ['docs/jsdoc-config.js'], @@ -242,18 +229,6 @@ module.exports = { strict: 'off' } }, - { - // Should probably have as external, but should still check - files: ['canvg/rgbcolor.js'], - settings: { - polyfills: [ - 'Number.isNaN', - 'Number.parseInt', - 'Object.assign', - 'Object.keys' - ] - } - }, { files: ['cypress/plugins/index.js'], extends: [ @@ -294,7 +269,7 @@ module.exports = { // instrument separately from nyc mocha 'import/no-unresolved': ['error', {ignore: ['/instrumented/']}], 'node/no-missing-import': 'off', - + 'jsdoc/check-examples': 'off', 'chai-expect-keywords/no-unsupported-keywords': [ 'error', { allowChaiDOM: true @@ -334,63 +309,33 @@ module.exports = { 'no-console': 0, 'import/unambiguous': 0 } - } - ], - rules: { - // check-examples is not picking up eslint config properly in some - // environments; see also discussion above - // `mocha-cleanup/no-assertions-outside-it` - 'jsdoc/check-examples': ['warn', { - rejectExampleCodeRegex: '^`' - }], - - // https://github.com/sindresorhus/eslint-plugin-unicorn/issues/453 - 'unicorn/regex-shorthand': 0, - // The Babel transform seems to have a problem converting these - 'prefer-named-capture-group': 'off', - // Override these `ash-nazg/sauron` rules which are difficult for us - // to apply at this time - 'unicorn/prefer-string-slice': 'off', - 'default-case': 'off', - 'require-unicode-regexp': 'off', - 'max-len': 'off', /* , { - ignoreUrls: true, - ignoreRegExpLiterals: true - } */ - 'unicorn/prefer-query-selector': 'off', - 'unicorn/prefer-node-append': 'off', - 'unicorn/no-zero-fractions': 'off', - 'unicorn/prefer-number-properties': 'off', - 'jsdoc/require-file-overview': ['error', { - tags: { - file: { - initialCommentsOnly: true, - preventDuplicates: true - }, - license: { - initialCommentsOnly: true, - preventDuplicates: true - }, - copyright: { - initialCommentsOnly: true, - preventDuplicates: true - }, - author: { - initialCommentsOnly: true, - preventDuplicates: true - }, - module: { - initialCommentsOnly: true, - preventDuplicates: true - }, - exports: { - initialCommentsOnly: true, - preventDuplicates: true - } + }, + { + // Node files + files: [ + 'docs/jsdoc-config.js', + 'build/build-html.js', + 'rollup.config.js', 'rollup-config.config.js' + ], + env: { + node: true + }, + settings: { + polyfills: [ + 'console', + 'Promise.resolve' + ] + }, + globals: { + require: true + }, + rules: { + // We can't put Rollup in npmignore or user can't get access, + // and we have too many modules to add to `peerDependencies` + // so this rule can know them to be available, so we instead + // disable + 'node/no-unpublished-import': 'off' } - }], - - // Disable for now - 'eslint-comments/require-description': 0 - } + } + ] }; diff --git a/CHANGES.md b/CHANGES.md index 46cfb1db..9d088c99 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -72,6 +72,7 @@ - Refactoring: Move `build-html` to `build` directory - Refactoring: Add favicon no-op to suppress favicon 404s until loaded dynamically (might make configurable in future) +- Refactoring: create a src folder and subfolders for svgcanvas, editor, common and externals. - Linting (ESLint): Simplify regexes - Linting (ESLint): Replace `innerHTML` with `textContent` from old demo - Linting (ESLint): Update as per latest ash-nazg diff --git a/clipart/moon.svg b/archive/clipart/moon.svg similarity index 100% rename from clipart/moon.svg rename to archive/clipart/moon.svg diff --git a/clipart/star.svg b/archive/clipart/star.svg similarity index 100% rename from clipart/star.svg rename to archive/clipart/star.svg diff --git a/clipart/sun.svg b/archive/clipart/sun.svg similarity index 100% rename from clipart/sun.svg rename to archive/clipart/sun.svg diff --git a/examples/arbelos.svg b/archive/examples/arbelos.svg similarity index 100% rename from examples/arbelos.svg rename to archive/examples/arbelos.svg diff --git a/examples/mickey.svg b/archive/examples/mickey.svg similarity index 100% rename from examples/mickey.svg rename to archive/examples/mickey.svg diff --git a/docs/from-old-wiki/BigBlueButton.md b/archive/from-old-wiki/BigBlueButton.md similarity index 100% rename from docs/from-old-wiki/BigBlueButton.md rename to archive/from-old-wiki/BigBlueButton.md diff --git a/docs/from-old-wiki/BrowserBugs.md b/archive/from-old-wiki/BrowserBugs.md similarity index 100% rename from docs/from-old-wiki/BrowserBugs.md rename to archive/from-old-wiki/BrowserBugs.md diff --git a/docs/from-old-wiki/CodeRefactoring.md b/archive/from-old-wiki/CodeRefactoring.md similarity index 100% rename from docs/from-old-wiki/CodeRefactoring.md rename to archive/from-old-wiki/CodeRefactoring.md diff --git a/docs/from-old-wiki/CommitPolicy.md b/archive/from-old-wiki/CommitPolicy.md similarity index 100% rename from docs/from-old-wiki/CommitPolicy.md rename to archive/from-old-wiki/CommitPolicy.md diff --git a/docs/from-old-wiki/CommunityConferenceCall.md b/archive/from-old-wiki/CommunityConferenceCall.md similarity index 100% rename from docs/from-old-wiki/CommunityConferenceCall.md rename to archive/from-old-wiki/CommunityConferenceCall.md diff --git a/docs/from-old-wiki/CommunityConferenceCall2.md b/archive/from-old-wiki/CommunityConferenceCall2.md similarity index 100% rename from docs/from-old-wiki/CommunityConferenceCall2.md rename to archive/from-old-wiki/CommunityConferenceCall2.md diff --git a/docs/from-old-wiki/CommunityConferenceCall3.md b/archive/from-old-wiki/CommunityConferenceCall3.md similarity index 100% rename from docs/from-old-wiki/CommunityConferenceCall3.md rename to archive/from-old-wiki/CommunityConferenceCall3.md diff --git a/docs/from-old-wiki/CommunityConferenceCall4.md b/archive/from-old-wiki/CommunityConferenceCall4.md similarity index 100% rename from docs/from-old-wiki/CommunityConferenceCall4.md rename to archive/from-old-wiki/CommunityConferenceCall4.md diff --git a/docs/from-old-wiki/CommunityConferenceCall5.md b/archive/from-old-wiki/CommunityConferenceCall5.md similarity index 100% rename from docs/from-old-wiki/CommunityConferenceCall5.md rename to archive/from-old-wiki/CommunityConferenceCall5.md diff --git a/docs/from-old-wiki/Consulting.md b/archive/from-old-wiki/Consulting.md similarity index 100% rename from docs/from-old-wiki/Consulting.md rename to archive/from-old-wiki/Consulting.md diff --git a/docs/from-old-wiki/Contact.md b/archive/from-old-wiki/Contact.md similarity index 100% rename from docs/from-old-wiki/Contact.md rename to archive/from-old-wiki/Contact.md diff --git a/docs/from-old-wiki/DevelopmentProcess.md b/archive/from-old-wiki/DevelopmentProcess.md similarity index 100% rename from docs/from-old-wiki/DevelopmentProcess.md rename to archive/from-old-wiki/DevelopmentProcess.md diff --git a/docs/from-old-wiki/Governance.md b/archive/from-old-wiki/Governance.md similarity index 100% rename from docs/from-old-wiki/Governance.md rename to archive/from-old-wiki/Governance.md diff --git a/docs/from-old-wiki/HallOfFame.md b/archive/from-old-wiki/HallOfFame.md similarity index 100% rename from docs/from-old-wiki/HallOfFame.md rename to archive/from-old-wiki/HallOfFame.md diff --git a/docs/from-old-wiki/HomePage.md b/archive/from-old-wiki/HomePage.md similarity index 100% rename from docs/from-old-wiki/HomePage.md rename to archive/from-old-wiki/HomePage.md diff --git a/docs/from-old-wiki/HowToParticipate.md b/archive/from-old-wiki/HowToParticipate.md similarity index 100% rename from docs/from-old-wiki/HowToParticipate.md rename to archive/from-old-wiki/HowToParticipate.md diff --git a/docs/from-old-wiki/InfoWorld2013interview.md b/archive/from-old-wiki/InfoWorld2013interview.md similarity index 100% rename from docs/from-old-wiki/InfoWorld2013interview.md rename to archive/from-old-wiki/InfoWorld2013interview.md diff --git a/docs/from-old-wiki/PossibleRename.md b/archive/from-old-wiki/PossibleRename.md similarity index 100% rename from docs/from-old-wiki/PossibleRename.md rename to archive/from-old-wiki/PossibleRename.md diff --git a/docs/from-old-wiki/ProjectsThatUseSvgEdit.md b/archive/from-old-wiki/ProjectsThatUseSvgEdit.md similarity index 100% rename from docs/from-old-wiki/ProjectsThatUseSvgEdit.md rename to archive/from-old-wiki/ProjectsThatUseSvgEdit.md diff --git a/docs/from-old-wiki/RelatedLinks.md b/archive/from-old-wiki/RelatedLinks.md similarity index 100% rename from docs/from-old-wiki/RelatedLinks.md rename to archive/from-old-wiki/RelatedLinks.md diff --git a/docs/from-old-wiki/Reviews.md b/archive/from-old-wiki/Reviews.md similarity index 100% rename from docs/from-old-wiki/Reviews.md rename to archive/from-old-wiki/Reviews.md diff --git a/docs/from-old-wiki/RoadMap.md b/archive/from-old-wiki/RoadMap.md similarity index 100% rename from docs/from-old-wiki/RoadMap.md rename to archive/from-old-wiki/RoadMap.md diff --git a/docs/from-old-wiki/RoundtripTests.md b/archive/from-old-wiki/RoundtripTests.md similarity index 100% rename from docs/from-old-wiki/RoundtripTests.md rename to archive/from-old-wiki/RoundtripTests.md diff --git a/docs/from-old-wiki/SVG_Open_2010.md b/archive/from-old-wiki/SVG_Open_2010.md similarity index 100% rename from docs/from-old-wiki/SVG_Open_2010.md rename to archive/from-old-wiki/SVG_Open_2010.md diff --git a/docs/from-old-wiki/Stakeholders.md b/archive/from-old-wiki/Stakeholders.md similarity index 100% rename from docs/from-old-wiki/Stakeholders.md rename to archive/from-old-wiki/Stakeholders.md diff --git a/docs/from-old-wiki/Summer_of_Code_2010.md b/archive/from-old-wiki/Summer_of_Code_2010.md similarity index 100% rename from docs/from-old-wiki/Summer_of_Code_2010.md rename to archive/from-old-wiki/Summer_of_Code_2010.md diff --git a/docs/from-old-wiki/Summer_of_Code_2013.md b/archive/from-old-wiki/Summer_of_Code_2013.md similarity index 100% rename from docs/from-old-wiki/Summer_of_Code_2013.md rename to archive/from-old-wiki/Summer_of_Code_2013.md diff --git a/docs/from-old-wiki/SvgSupport.md b/archive/from-old-wiki/SvgSupport.md similarity index 100% rename from docs/from-old-wiki/SvgSupport.md rename to archive/from-old-wiki/SvgSupport.md diff --git a/docs/from-old-wiki/Testing.md b/archive/from-old-wiki/Testing.md similarity index 100% rename from docs/from-old-wiki/Testing.md rename to archive/from-old-wiki/Testing.md diff --git a/docs/from-old-wiki/Theming.md b/archive/from-old-wiki/Theming.md similarity index 100% rename from docs/from-old-wiki/Theming.md rename to archive/from-old-wiki/Theming.md diff --git a/docs/from-old-wiki/TipsAndTricks.md b/archive/from-old-wiki/TipsAndTricks.md similarity index 100% rename from docs/from-old-wiki/TipsAndTricks.md rename to archive/from-old-wiki/TipsAndTricks.md diff --git a/docs/from-old-wiki/TranslationGuidelines.md b/archive/from-old-wiki/TranslationGuidelines.md similarity index 100% rename from docs/from-old-wiki/TranslationGuidelines.md rename to archive/from-old-wiki/TranslationGuidelines.md diff --git a/docs/from-old-wiki/VersionHistory.md b/archive/from-old-wiki/VersionHistory.md similarity index 100% rename from docs/from-old-wiki/VersionHistory.md rename to archive/from-old-wiki/VersionHistory.md diff --git a/docs/from-old-wiki/VersionLifecycle.md b/archive/from-old-wiki/VersionLifecycle.md similarity index 100% rename from docs/from-old-wiki/VersionLifecycle.md rename to archive/from-old-wiki/VersionLifecycle.md diff --git a/docs/from-old-wiki/Wikipedia.md b/archive/from-old-wiki/Wikipedia.md similarity index 100% rename from docs/from-old-wiki/Wikipedia.md rename to archive/from-old-wiki/Wikipedia.md diff --git a/screencasts/svgedit-screencast-1.txt b/archive/screencasts/svgedit-screencast-1.txt similarity index 100% rename from screencasts/svgedit-screencast-1.txt rename to archive/screencasts/svgedit-screencast-1.txt diff --git a/screencasts/svgedit-screencast-2.txt b/archive/screencasts/svgedit-screencast-2.txt similarity index 100% rename from screencasts/svgedit-screencast-2.txt rename to archive/screencasts/svgedit-screencast-2.txt diff --git a/screencasts/svgedit-screencast-3.txt b/archive/screencasts/svgedit-screencast-3.txt similarity index 100% rename from screencasts/svgedit-screencast-3.txt rename to archive/screencasts/svgedit-screencast-3.txt diff --git a/screencasts/svgopen2010/LICENSE-Apache2.0.txt b/archive/screencasts/svgopen2010/LICENSE-Apache2.0.txt similarity index 100% rename from screencasts/svgopen2010/LICENSE-Apache2.0.txt rename to archive/screencasts/svgopen2010/LICENSE-Apache2.0.txt diff --git a/screencasts/svgopen2010/index.html b/archive/screencasts/svgopen2010/index.html similarity index 100% rename from screencasts/svgopen2010/index.html rename to archive/screencasts/svgopen2010/index.html diff --git a/editor/images/logo.svg b/archive/screencasts/svgopen2010/logo.svg similarity index 100% rename from editor/images/logo.svg rename to archive/screencasts/svgopen2010/logo.svg diff --git a/screencasts/svgopen2010/script.js b/archive/screencasts/svgopen2010/script.js similarity index 100% rename from screencasts/svgopen2010/script.js rename to archive/screencasts/svgopen2010/script.js diff --git a/screencasts/svgopen2010/style.css b/archive/screencasts/svgopen2010/style.css similarity index 100% rename from screencasts/svgopen2010/style.css rename to archive/screencasts/svgopen2010/style.css diff --git a/badges/coverage-badge.svg b/badges/coverage-badge.svg index 29f7a0bf..7ec30fa8 100644 --- a/badges/coverage-badge.svg +++ b/badges/coverage-badge.svg @@ -1 +1 @@ - + diff --git a/badges/tests-badge.svg b/badges/tests-badge.svg index 126a9c3c..0d1ca370 100644 --- a/badges/tests-badge.svg +++ b/badges/tests-badge.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/build/build-html.js b/build/build-html.js index 393f6db1..114e21f7 100644 --- a/build/build-html.js +++ b/build/build-html.js @@ -3,8 +3,8 @@ import fs from 'promise-fs'; const filesAndReplacements = [ { - input: 'editor/svg-editor-es.html', - output: 'editor/xdomain-svg-editor-es.html', + input: 'src/editor/svg-editor-es.html', + output: 'src/editor/xdomain-svg-editor-es.html', replacements: [ [ '', @@ -13,8 +13,8 @@ const filesAndReplacements = [ ] }, { - input: 'editor/xdomain-svg-editor-es.html', - output: 'editor/xdomain-svg-editor.html', + input: 'src/editor/xdomain-svg-editor-es.html', + output: 'src/editor/xdomain-svg-editor.html', replacements: [ [ '', @@ -23,15 +23,15 @@ const filesAndReplacements = [ ], [ '', - '' + '' ], [ '', '' ], [ - '', - '' + '', + '' ], [ '', @@ -41,8 +41,8 @@ const filesAndReplacements = [ }, // Now that file has copied, we can replace the DOCTYPE in xdomain { - input: 'editor/xdomain-svg-editor-es.html', - output: 'editor/xdomain-svg-editor-es.html', + input: 'src/editor/xdomain-svg-editor-es.html', + output: 'src/editor/xdomain-svg-editor-es.html', replacements: [ [ '', @@ -52,8 +52,8 @@ const filesAndReplacements = [ ] }, { - input: 'editor/svg-editor-es.html', - output: 'editor/svg-editor.html', + input: 'src/editor/svg-editor-es.html', + output: 'src/editor/svg-editor.html', replacements: [ [ '', @@ -62,15 +62,15 @@ const filesAndReplacements = [ ], [ '', - '' + '' ], [ '', '' ], [ - '', - '' + '', + '' ], [ '', @@ -79,8 +79,8 @@ const filesAndReplacements = [ ] }, { - input: 'editor/extensions/imagelib/openclipart-es.html', - output: 'editor/extensions/imagelib/openclipart.html', + input: 'src/editor/extensions/imagelib/openclipart-es.html', + output: 'src/editor/extensions/imagelib/openclipart.html', replacements: [ [ '', @@ -89,11 +89,11 @@ const filesAndReplacements = [ ], [ '', - '' + '' ], [ '', - '' + '' ], [ '', @@ -102,8 +102,8 @@ const filesAndReplacements = [ ] }, { - input: 'editor/extensions/imagelib/index-es.html', - output: 'editor/extensions/imagelib/index.html', + input: 'src/editor/extensions/imagelib/index-es.html', + output: 'src/editor/extensions/imagelib/index.html', replacements: [ [ '', @@ -112,7 +112,7 @@ const filesAndReplacements = [ ], [ '', - '' + '' ], [ '', diff --git a/cypress.json b/cypress.json index 58f4a64b..e4ee2e68 100644 --- a/cypress.json +++ b/cypress.json @@ -1,6 +1,7 @@ { "baseUrl": "http://localhost:8000", "reporter": "cypress-multi-reporters", + "video": false, "reporterOptions": { "configFile": "mocha-multi-reporters.json" } diff --git a/cypress/integration/ui/accessibility.js b/cypress/integration/ui/accessibility.js index 3baa23b5..b1363b03 100644 --- a/cypress/integration/ui/accessibility.js +++ b/cypress/integration/ui/accessibility.js @@ -1,6 +1,6 @@ describe('UI - Accessibility', function () { beforeEach(() => { - cy.visit('/instrumented/svg-editor-es.html'); + cy.visit('/instrumented/editor/svg-editor-es.html'); cy.injectAxe(); }); @@ -25,6 +25,16 @@ describe('UI - Accessibility', function () { locale: Object */ }); - cy.checkA11y(); + cy.checkA11y( + {}, + { + rules: { + 'label-title-only': {enabled: false}, + 'page-has-heading-one': {enabled: false}, + region: {enabled: false}, + 'scrollable-region-focusable': {enabled: false} + } + } + ); }); }); diff --git a/cypress/integration/unit/contextmenu.js b/cypress/integration/unit/contextmenu.js index e851e8a7..575cbc00 100644 --- a/cypress/integration/unit/contextmenu.js +++ b/cypress/integration/unit/contextmenu.js @@ -1,5 +1,5 @@ -import '../../../instrumented/jquery.min.js'; -import * as contextmenu from '../../../instrumented/contextmenu.js'; +import '../../../instrumented/editor/jquery.min.js'; +import * as contextmenu from '../../../instrumented/editor/contextmenu.js'; describe('contextmenu', function () { /** diff --git a/cypress/integration/unit/coords.js b/cypress/integration/unit/coords.js index d7388662..54ccea26 100644 --- a/cypress/integration/unit/coords.js +++ b/cypress/integration/unit/coords.js @@ -1,8 +1,8 @@ -import '../../../instrumented/jquery.min.js'; +import '../../../instrumented/editor/jquery.min.js'; -import {NS} from '../../../instrumented/namespaces.js'; -import * as utilities from '../../../instrumented/utilities.js'; -import * as coords from '../../../instrumented/coords.js'; +import {NS} from '../../../instrumented/common/namespaces.js'; +import * as utilities from '../../../instrumented/common/utilities.js'; +import * as coords from '../../../instrumented/svgcanvas/coords.js'; describe('coords', function () { let elemId = 1; diff --git a/cypress/integration/unit/draw.js b/cypress/integration/unit/draw.js index 450db7d1..750491a2 100644 --- a/cypress/integration/unit/draw.js +++ b/cypress/integration/unit/draw.js @@ -1,8 +1,8 @@ -import '../../../instrumented/jquery.min.js'; +import '../../../instrumented/editor/jquery.min.js'; -import {NS} from '../../../instrumented/namespaces.js'; -import * as draw from '../../../instrumented/draw.js'; -import * as units from '../../../instrumented/units.js'; +import {NS} from '../../../instrumented/common/namespaces.js'; +import * as draw from '../../../instrumented/svgcanvas/draw.js'; +import * as units from '../../../instrumented/common/units.js'; describe('draw.Drawing', function () { const addOwnSpies = (obj) => { @@ -20,6 +20,7 @@ describe('draw.Drawing', function () { const PATH_ATTR = { // clone will convert relative to absolute, so the test for equality fails. // d: 'm7.38867,57.38867c0,-27.62431 22.37569,-50 50,-50c27.62431,0 50,22.37569 50,50c0,27.62431 -22.37569,50 -50,50c-27.62431,0 -50,-22.37569 -50,-50z', + // eslint-disable-next-line max-len d: 'M7.389,57.389C7.389,29.764 29.764,7.389 57.389,7.389C85.013,7.389 107.389,29.764 107.389,57.389C107.389,85.013 85.013,107.389 57.389,107.389C29.764,107.389 7.389,85.013 7.389,57.389z', transform: 'rotate(45 57.388671875000036,57.388671874999986) ', 'stroke-width': '5', diff --git a/cypress/integration/unit/history.js b/cypress/integration/unit/history.js index 8a66401d..32093621 100644 --- a/cypress/integration/unit/history.js +++ b/cypress/integration/unit/history.js @@ -1,9 +1,9 @@ -import '../../../instrumented/jquery.min.js'; +import '../../../instrumented/editor/jquery.min.js'; -import {NS} from '../../../instrumented/namespaces.js'; -import * as transformlist from '../../../instrumented/svgtransformlist.js'; -import * as utilities from '../../../instrumented/utilities.js'; -import * as hstory from '../../../instrumented/history.js'; +import {NS} from '../../../instrumented/common/namespaces.js'; +import * as transformlist from '../../../instrumented/common/svgtransformlist.js'; +import * as utilities from '../../../instrumented/common/utilities.js'; +import * as hstory from '../../../instrumented/svgcanvas/history.js'; describe('history', function () { // TODO(codedread): Write tests for handling history events. @@ -20,11 +20,17 @@ describe('history', function () { // const svg = document.createElementNS(NS.SVG, 'svg'); let undoMgr = null; - class MockCommand { - constructor (optText) { this.text_ = optText; } - apply () { /* */ } // eslint-disable-line class-methods-use-this - unapply () { /* */ } // eslint-disable-line class-methods-use-this - getText () { return this.text_; } + class MockCommand extends hstory.Command { + constructor (optText) { + super(); + this.text = optText; + } + apply (handler) { + super.apply(handler, () => { /* */ }); + } + unapply (handler) { + super.unapply(handler, () => { /* */ }); + } elements () { return []; } // eslint-disable-line class-methods-use-this } @@ -482,17 +488,17 @@ describe('history', function () { it('Test BatchCommand', function () { let concatResult = ''; - MockCommand.prototype.apply = function () { concatResult += this.text_; }; + MockCommand.prototype.apply = function (handler) { concatResult += this.text; }; const batch = new hstory.BatchCommand(); assert.ok(batch.unapply); assert.ok(batch.apply); assert.ok(batch.addSubCommand); assert.ok(batch.isEmpty); - assert.equal(typeof batch.unapply, typeof function () { /* */ }); - assert.equal(typeof batch.apply, typeof function () { /* */ }); - assert.equal(typeof batch.addSubCommand, typeof function () { /* */ }); - assert.equal(typeof batch.isEmpty, typeof function () { /* */ }); + assert.equal(typeof batch.unapply, 'function'); + assert.equal(typeof batch.apply, 'function'); + assert.equal(typeof batch.addSubCommand, 'function'); + assert.equal(typeof batch.isEmpty, 'function'); assert.ok(batch.isEmpty()); @@ -506,8 +512,9 @@ describe('history', function () { assert.equal(concatResult, 'abc'); MockCommand.prototype.apply = function () { /* */ }; - MockCommand.prototype.unapply = function () { concatResult += this.text_; }; + MockCommand.prototype.unapply = function () { concatResult += this.text; }; concatResult = ''; + assert.ok(!concatResult); batch.unapply(); assert.equal(concatResult, 'cba'); diff --git a/cypress/integration/unit/math.js b/cypress/integration/unit/math.js index 2aacab41..8c3c665c 100644 --- a/cypress/integration/unit/math.js +++ b/cypress/integration/unit/math.js @@ -1,7 +1,7 @@ -import '../../../instrumented/jquery.min.js'; +import '../../../instrumented/editor/jquery.min.js'; -import {NS} from '../../../instrumented/namespaces.js'; -import * as math from '../../../instrumented/math.js'; +import {NS} from '../../../instrumented/common/namespaces.js'; +import * as math from '../../../instrumented/common/math.js'; describe('math', function () { const svg = document.createElementNS(NS.SVG, 'svg'); diff --git a/cypress/integration/unit/path.js b/cypress/integration/unit/path.js index 82e54bd5..443c24bd 100644 --- a/cypress/integration/unit/path.js +++ b/cypress/integration/unit/path.js @@ -1,11 +1,11 @@ /* globals SVGPathSeg */ -import '../../../instrumented/jquery.min.js'; +import '../../../instrumented/editor/jquery.min.js'; -import '../../../instrumented/svgpathseg.js'; -import {NS} from '../../../instrumented/namespaces.js'; -import * as utilities from '../../../instrumented/utilities.js'; -import * as pathModule from '../../../instrumented/path.js'; -import {init as unitsInit} from '../../../instrumented/units.js'; +import '../../../instrumented/common/svgpathseg.js'; +import {NS} from '../../../instrumented/common/namespaces.js'; +import * as utilities from '../../../instrumented/common/utilities.js'; +import * as pathModule from '../../../instrumented/svgcanvas/path.js'; +import {init as unitsInit} from '../../../instrumented/common/units.js'; describe('path', function () { /** diff --git a/cypress/integration/unit/recalculate.js b/cypress/integration/unit/recalculate.js index aec3d447..dde47f4e 100644 --- a/cypress/integration/unit/recalculate.js +++ b/cypress/integration/unit/recalculate.js @@ -1,9 +1,9 @@ -import '../../../instrumented/jquery.min.js'; +import '../../../instrumented/editor/jquery.min.js'; -import {NS} from '../../../instrumented/namespaces.js'; -import * as utilities from '../../../instrumented/utilities.js'; -import * as coords from '../../../instrumented/coords.js'; -import * as recalculate from '../../../instrumented/recalculate.js'; +import {NS} from '../../../instrumented/common/namespaces.js'; +import * as utilities from '../../../instrumented/common/utilities.js'; +import * as coords from '../../../instrumented/svgcanvas/coords.js'; +import * as recalculate from '../../../instrumented/svgcanvas/recalculate.js'; describe('recalculate', function () { // eslint-disable-next-line no-shadow diff --git a/cypress/integration/unit/sanitize.js b/cypress/integration/unit/sanitize.js index f2c1a887..4ff4f853 100644 --- a/cypress/integration/unit/sanitize.js +++ b/cypress/integration/unit/sanitize.js @@ -1,7 +1,7 @@ -import '../../../instrumented/jquery.min.js'; +import '../../../instrumented/editor/jquery.min.js'; -import {NS} from '../../../instrumented/namespaces.js'; -import * as sanitize from '../../../instrumented/sanitize.js'; +import {NS} from '../../../instrumented/common/namespaces.js'; +import * as sanitize from '../../../instrumented/svgcanvas/sanitize.js'; describe('sanitize', function () { const svg = document.createElementNS(NS.SVG, 'svg'); diff --git a/cypress/integration/unit/select.js b/cypress/integration/unit/select.js index 0b025720..b01ca71a 100644 --- a/cypress/integration/unit/select.js +++ b/cypress/integration/unit/select.js @@ -1,7 +1,7 @@ -import '../../../instrumented/jquery.min.js'; +import '../../../instrumented/editor/jquery.min.js'; -import * as select from '../../../instrumented/select.js'; -import {NS} from '../../../instrumented/namespaces.js'; +import * as select from '../../../instrumented/svgcanvas/select.js'; +import {NS} from '../../../instrumented/common/namespaces.js'; describe('select', function () { const sandbox = document.createElement('div'); diff --git a/cypress/integration/unit/svgtransformlist.js b/cypress/integration/unit/svgtransformlist.js index 7072c080..fb7c0a86 100644 --- a/cypress/integration/unit/svgtransformlist.js +++ b/cypress/integration/unit/svgtransformlist.js @@ -1,8 +1,8 @@ -import '../../../instrumented/jquery.min.js'; +import '../../../instrumented/editor/jquery.min.js'; -import {NS} from '../../../instrumented/namespaces.js'; -import * as transformlist from '../../../instrumented/svgtransformlist.js'; -import {disableSupportsNativeTransformLists} from '../../../instrumented/browser.js'; +import {NS} from '../../../instrumented/common/namespaces.js'; +import * as transformlist from '../../../instrumented/common/svgtransformlist.js'; +import {disableSupportsNativeTransformLists} from '../../../instrumented/common/browser.js'; import almostEqualsPlugin from '../../support/assert-almostEquals.js'; import expectOutOfBoundsExceptionPlugin from '../../support/assert-expectOutOfBoundsException.js'; diff --git a/cypress/integration/unit/test1.js b/cypress/integration/unit/test1.js index 5ff34974..5660d1a4 100644 --- a/cypress/integration/unit/test1.js +++ b/cypress/integration/unit/test1.js @@ -1,8 +1,9 @@ -import '../../../instrumented/jquery.min.js'; -import '../../../instrumented/jquery-ui/jquery-ui-1.8.17.custom.min.js'; +/* eslint-disable max-len */ +import '../../../instrumented/editor/jquery.min.js'; +import '../../../instrumented/editor/jquery-ui/jquery-ui-1.8.17.custom.min.js'; -import '../../../instrumented/svgpathseg.js'; -import SvgCanvas from '../../../instrumented/svgcanvas.js'; +import '../../../instrumented/common/svgpathseg.js'; +import SvgCanvas from '../../../instrumented/svgcanvas/svgcanvas.js'; describe('Basic Module', function () { // helper functions diff --git a/cypress/integration/unit/units.js b/cypress/integration/unit/units.js index c626e1e7..0519f1e2 100644 --- a/cypress/integration/unit/units.js +++ b/cypress/integration/unit/units.js @@ -1,6 +1,6 @@ -import '../../../instrumented/jquery.min.js'; +import '../../../instrumented/editor/jquery.min.js'; -import * as units from '../../../instrumented/units.js'; +import * as units from '../../../instrumented/common/units.js'; describe('units', function () { /** diff --git a/cypress/integration/unit/utilities-bbox.js b/cypress/integration/unit/utilities-bbox.js index bc5b5b6b..fb089803 100644 --- a/cypress/integration/unit/utilities-bbox.js +++ b/cypress/integration/unit/utilities-bbox.js @@ -1,11 +1,12 @@ -import '../../../instrumented/jquery.min.js'; +/* eslint-disable max-len */ +import '../../../instrumented/editor/jquery.min.js'; -import '../../../instrumented/svgpathseg.js'; -import {NS} from '../../../instrumented/namespaces.js'; -import * as utilities from '../../../instrumented/utilities.js'; -import * as transformlist from '../../../instrumented/svgtransformlist.js'; -import * as math from '../../../instrumented/math.js'; -import * as path from '../../../instrumented/path.js'; +import '../../../instrumented/common/svgpathseg.js'; +import {NS} from '../../../instrumented/common/namespaces.js'; +import * as utilities from '../../../instrumented/common/utilities.js'; +import * as transformlist from '../../../instrumented/common/svgtransformlist.js'; +import * as math from '../../../instrumented/common/math.js'; +import * as path from '../../../instrumented/svgcanvas/path.js'; import setAssertionMethods from '../../support/assert-close.js'; chai.use(setAssertionMethods); diff --git a/cypress/integration/unit/utilities-performance.js b/cypress/integration/unit/utilities-performance.js index 4e1e0e9a..5a167b5a 100644 --- a/cypress/integration/unit/utilities-performance.js +++ b/cypress/integration/unit/utilities-performance.js @@ -1,10 +1,11 @@ -import '../../../instrumented/jquery.min.js'; +/* eslint-disable max-len */ +import '../../../instrumented/editor/jquery.min.js'; -import '../../../instrumented/svgpathseg.js'; -import {NS} from '../../../instrumented/namespaces.js'; -import * as utilities from '../../../instrumented/utilities.js'; -import * as transformlist from '../../../instrumented/svgtransformlist.js'; -import * as math from '../../../instrumented/math.js'; +import '../../../instrumented/common/svgpathseg.js'; +import {NS} from '../../../instrumented/common/namespaces.js'; +import * as utilities from '../../../instrumented/common/utilities.js'; +import * as transformlist from '../../../instrumented/common/svgtransformlist.js'; +import * as math from '../../../instrumented/common/math.js'; describe('utilities performance', function () { let currentLayer, groupWithMatrixTransform, textWithMatrixTransform; diff --git a/cypress/integration/unit/utilities.js b/cypress/integration/unit/utilities.js index 417103b7..e56bd63d 100644 --- a/cypress/integration/unit/utilities.js +++ b/cypress/integration/unit/utilities.js @@ -1,8 +1,9 @@ -import '../../../instrumented/jquery.min.js'; +/* eslint-disable max-len */ +import '../../../instrumented/editor/jquery.min.js'; -import * as browser from '../../../instrumented/browser.js'; -import * as utilities from '../../../instrumented/utilities.js'; -import {NS} from '../../../instrumented/namespaces.js'; +import * as browser from '../../../instrumented/common/browser.js'; +import * as utilities from '../../../instrumented/common/utilities.js'; +import {NS} from '../../../instrumented/common/namespaces.js'; describe('utilities', function () { /** diff --git a/cypress/plugins/main.js b/cypress/plugins/main.js index 29c585f5..118423bf 100644 --- a/cypress/plugins/main.js +++ b/cypress/plugins/main.js @@ -3,7 +3,6 @@ import codeCoverageTask from '@cypress/code-coverage/task.js'; -// eslint-disable-next-line import/no-anonymous-default-export export default (on, config) => { // `on` is used to hook into various events Cypress emits // `config` is the resolved Cypress config diff --git a/cypress/support/assert-close.js b/cypress/support/assert-close.js index e0639480..7b79341b 100644 --- a/cypress/support/assert-close.js +++ b/cypress/support/assert-close.js @@ -1,4 +1,4 @@ -/* eslint-disable jsdoc/check-examples */ +/* eslint-disable max-len */ import assertionWrapper from './assertion-wrapper.js'; /** diff --git a/cypress/support/copy.js b/cypress/support/copy.js deleted file mode 100644 index db243b1f..00000000 --- a/cypress/support/copy.js +++ /dev/null @@ -1,14 +0,0 @@ -/* globals require */ -/* eslint-disable import/no-commonjs */ - -const copyfiles = require('copyfiles'); -const pkg = require('../../package.json'); - -copyfiles([ - ...pkg.nyc.exclude, - 'instrumented' -], { - up: 1 -}, () => { - console.log('Done'); -}); diff --git a/cypress/support/ui-test-helper.js b/cypress/support/ui-test-helper.js index 95ffea94..69d28514 100644 --- a/cypress/support/ui-test-helper.js +++ b/cypress/support/ui-test-helper.js @@ -4,7 +4,7 @@ export const approveStorage = () => { }; export const visitAndApproveStorage = () => { - cy.visit('/instrumented/svg-editor-es.html'); + cy.visit('/instrumented/editor/svg-editor-es.html'); approveStorage(); }; diff --git a/demos/canvas.html b/demos/canvas.html index bb5e055a..81c68a43 100644 --- a/demos/canvas.html +++ b/demos/canvas.html @@ -3,10 +3,10 @@