Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/core js with esmodule #361

Merged
merged 8 commits into from
Mar 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,506 changes: 522 additions & 984 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"tslint": "tslint index.d.ts"
},
"dependencies": {
"core-js": "2.4.1",
"core-js-pure": "^3.6.4",
"fabric": "3.6.0",
"tui-code-snippet": "^1.5.0",
"tui-color-picker": "^2.2.0"
Expand Down
10 changes: 5 additions & 5 deletions src/js/action.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {extend} from 'tui-code-snippet';
import util from './util';
import {isSupportFileApi, base64ToBlob, toInteger} from './util';
import Imagetracer from './helper/imagetracer';

export default {
Expand Down Expand Up @@ -97,7 +97,7 @@ export default {
this.ui.changeHelpButtonEnabled('deleteAll', false);
},
load: file => {
if (!util.isSupportFileApi()) {
if (!isSupportFileApi()) {
alert('This browser does not support file-api');
}

Expand All @@ -116,8 +116,8 @@ export default {
let imageName = this.getImageName();
let blob, type, w;

if (util.isSupportFileApi() && window.saveAs) {
blob = util.base64ToBlob(dataURL);
if (isSupportFileApi() && window.saveAs) {
blob = base64ToBlob(dataURL);
type = blob.type.split('/')[1];
if (imageName.split('.').pop() !== type) {
imageName += `.${type}`;
Expand Down Expand Up @@ -489,7 +489,7 @@ export default {
},
objectScaled: obj => {
if (['i-text', 'text'].indexOf(obj.type) > -1) {
this.ui.text.fontSize = util.toInteger(obj.fontSize);
this.ui.text.fontSize = toInteger(obj.fontSize);
} else if (['rect', 'circle', 'triangle'].indexOf(obj.type) >= 0) {
const {width, height} = obj;
const strokeValue = this.ui.shape.getStrokeValue();
Expand Down
7 changes: 3 additions & 4 deletions src/js/command/addIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
* @fileoverview Add an icon
*/
import commandFactory from '../factory/command';
import Promise from 'core-js/library/es6/promise';
import consts from '../consts';
import {Promise} from '../util';
import {componentNames, commandNames} from '../consts';

const {componentNames, commandNames} = consts;
const {ICON} = componentNames;

const command = {
Expand Down Expand Up @@ -44,4 +43,4 @@ const command = {

commandFactory.register(command);

module.exports = command;
export default command;
8 changes: 3 additions & 5 deletions src/js/command/addImageObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
* @fileoverview Add an image object
*/
import commandFactory from '../factory/command';
import Promise from 'core-js/library/es6/promise';
import consts from '../consts';

const {commandNames} = consts;
import {Promise} from '../util';
import {commandNames} from '../consts';

const command = {
name: commandNames.ADD_IMAGE_OBJECT,
Expand Down Expand Up @@ -37,4 +35,4 @@ const command = {

commandFactory.register(command);

module.exports = command;
export default command;
8 changes: 3 additions & 5 deletions src/js/command/addObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
* @fileoverview Add an object
*/
import commandFactory from '../factory/command';
import Promise from 'core-js/library/es6/promise';
import consts from '../consts';

const {commandNames, rejectMessages} = consts;
import {Promise} from '../util';
import {commandNames, rejectMessages} from '../consts';

const command = {
name: commandNames.ADD_OBJECT,
Expand Down Expand Up @@ -46,4 +44,4 @@ const command = {

commandFactory.register(command);

module.exports = command;
export default command;
7 changes: 3 additions & 4 deletions src/js/command/addShape.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
* @fileoverview Add a shape
*/
import commandFactory from '../factory/command';
import Promise from 'core-js/library/es6/promise';
import consts from '../consts';
import {Promise} from '../util';
import {componentNames, commandNames} from '../consts';

const {componentNames, commandNames} = consts;
const {SHAPE} = componentNames;

const command = {
Expand Down Expand Up @@ -51,4 +50,4 @@ const command = {

commandFactory.register(command);

module.exports = command;
export default command;
7 changes: 3 additions & 4 deletions src/js/command/addText.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
* @fileoverview Add a text object
*/
import commandFactory from '../factory/command';
import Promise from 'core-js/library/es6/promise';
import consts from '../consts';
const {componentNames, commandNames, rejectMessages} = consts;
import {Promise} from '../util';
import {componentNames, commandNames, rejectMessages} from '../consts';
const {TEXT} = componentNames;

const command = {
Expand Down Expand Up @@ -65,4 +64,4 @@ const command = {

commandFactory.register(command);

module.exports = command;
export default command;
5 changes: 2 additions & 3 deletions src/js/command/applyFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
*/
import snippet from 'tui-code-snippet';
import commandFactory from '../factory/command';
import consts from '../consts';
import {componentNames, rejectMessages, commandNames} from '../consts';

const {componentNames, rejectMessages, commandNames} = consts;
const {FILTER} = componentNames;

/**
Expand Down Expand Up @@ -96,4 +95,4 @@ const command = {

commandFactory.register(command);

module.exports = command;
export default command;
7 changes: 3 additions & 4 deletions src/js/command/changeIconColor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
* @fileoverview Change icon color
*/
import commandFactory from '../factory/command';
import Promise from 'core-js/library/es6/promise';
import consts from '../consts';
import {Promise} from '../util';
import {componentNames, rejectMessages, commandNames} from '../consts';

const {componentNames, rejectMessages, commandNames} = consts;
const {ICON} = componentNames;

const command = {
Expand Down Expand Up @@ -50,4 +49,4 @@ const command = {

commandFactory.register(command);

module.exports = command;
export default command;
7 changes: 3 additions & 4 deletions src/js/command/changeShape.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
* @fileoverview change a shape
*/
import snippet from 'tui-code-snippet';
import {Promise} from '../util';
import commandFactory from '../factory/command';
import Promise from 'core-js/library/es6/promise';
import consts from '../consts';
import {componentNames, rejectMessages, commandNames} from '../consts';

const {componentNames, rejectMessages, commandNames} = consts;
const {SHAPE} = componentNames;

/**
Expand Down Expand Up @@ -86,4 +85,4 @@ const command = {

commandFactory.register(command);

module.exports = command;
export default command;
7 changes: 3 additions & 4 deletions src/js/command/changeText.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
* @fileoverview Change a text
*/
import commandFactory from '../factory/command';
import Promise from 'core-js/library/es6/promise';
import consts from '../consts';
import {Promise} from '../util';
import {componentNames, rejectMessages, commandNames} from '../consts';

const {componentNames, rejectMessages, commandNames} = consts;
const {TEXT} = componentNames;

const command = {
Expand Down Expand Up @@ -46,4 +45,4 @@ const command = {

commandFactory.register(command);

module.exports = command;
export default command;
7 changes: 3 additions & 4 deletions src/js/command/changeTextStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
*/
import snippet from 'tui-code-snippet';
import commandFactory from '../factory/command';
import Promise from 'core-js/library/es6/promise';
import consts from '../consts';
import {Promise} from '../util';
import {componentNames, rejectMessages, commandNames} from '../consts';

const {componentNames, rejectMessages, commandNames} = consts;
const {TEXT} = componentNames;

/**
Expand Down Expand Up @@ -82,4 +81,4 @@ const command = {

commandFactory.register(command);

module.exports = command;
export default command;
8 changes: 3 additions & 5 deletions src/js/command/clearObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
* @fileoverview Clear all objects
*/
import commandFactory from '../factory/command';
import Promise from 'core-js/library/es6/promise';
import consts from '../consts';

const {commandNames} = consts;
import {Promise} from '../util';
import {commandNames} from '../consts';

const command = {
name: commandNames.CLEAR_OBJECTS,
Expand Down Expand Up @@ -36,4 +34,4 @@ const command = {

commandFactory.register(command);

module.exports = command;
export default command;
5 changes: 2 additions & 3 deletions src/js/command/flip.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
* @fileoverview Flip an image
*/
import commandFactory from '../factory/command';
import consts from '../consts';
import {componentNames, commandNames} from '../consts';

const {componentNames, commandNames} = consts;
const {FLIP} = componentNames;

const command = {
Expand Down Expand Up @@ -37,4 +36,4 @@ const command = {

commandFactory.register(command);

module.exports = command;
export default command;
5 changes: 2 additions & 3 deletions src/js/command/loadImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
* @fileoverview Load a background (main) image
*/
import commandFactory from '../factory/command';
import consts from '../consts';
import {componentNames, commandNames} from '../consts';

const {componentNames, commandNames} = consts;
const {IMAGE_LOADER} = componentNames;

const command = {
Expand Down Expand Up @@ -60,4 +59,4 @@ const command = {

commandFactory.register(command);

module.exports = command;
export default command;
5 changes: 2 additions & 3 deletions src/js/command/removeFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
* @fileoverview Remove a filter from an image
*/
import commandFactory from '../factory/command';
import consts from '../consts';
import {componentNames, commandNames} from '../consts';

const {componentNames, commandNames} = consts;
const {FILTER} = componentNames;

const command = {
Expand Down Expand Up @@ -39,4 +38,4 @@ const command = {

commandFactory.register(command);

module.exports = command;
export default command;
8 changes: 3 additions & 5 deletions src/js/command/removeObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
* @fileoverview Remove an object
*/
import commandFactory from '../factory/command';
import Promise from 'core-js/library/es6/promise';
import consts from '../consts';

const {commandNames, rejectMessages} = consts;
import {Promise} from '../util';
import {commandNames, rejectMessages} from '../consts';

const command = {
name: commandNames.REMOVE_OBJECT,
Expand Down Expand Up @@ -40,4 +38,4 @@ const command = {

commandFactory.register(command);

module.exports = command;
export default command;
8 changes: 3 additions & 5 deletions src/js/command/resizeCanvasDimension.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
* @fileoverview Resize a canvas
*/
import commandFactory from '../factory/command';
import Promise from 'core-js/library/es6/promise';
import consts from '../consts';

const {commandNames} = consts;
import {Promise} from '../util';
import {commandNames} from '../consts';

const command = {
name: commandNames.RESIZE_CANVAS_DIMENSION,
Expand Down Expand Up @@ -43,4 +41,4 @@ const command = {

commandFactory.register(command);

module.exports = command;
export default command;
5 changes: 2 additions & 3 deletions src/js/command/rotate.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
* @fileoverview Rotate an image
*/
import commandFactory from '../factory/command';
import consts from '../consts';
import {componentNames, commandNames} from '../consts';

const {componentNames, commandNames} = consts;
const {ROTATION} = componentNames;

/**
Expand Down Expand Up @@ -65,4 +64,4 @@ const command = {

commandFactory.register(command);

module.exports = command;
export default command;
8 changes: 3 additions & 5 deletions src/js/command/setObjectPosition.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
* @fileoverview Set object properties
*/
import commandFactory from '../factory/command';
import Promise from 'core-js/library/es6/promise';
import consts from '../consts';

const {commandNames, rejectMessages} = consts;
import {Promise} from '../util';
import {commandNames, rejectMessages} from '../consts';

const command = {
name: commandNames.SET_OBJECT_POSITION,
Expand Down Expand Up @@ -53,4 +51,4 @@ const command = {

commandFactory.register(command);

module.exports = command;
export default command;
8 changes: 3 additions & 5 deletions src/js/command/setObjectProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
*/
import snippet from 'tui-code-snippet';
import commandFactory from '../factory/command';
import Promise from 'core-js/library/es6/promise';
import consts from '../consts';

const {commandNames, rejectMessages} = consts;
import {Promise} from '../util';
import {commandNames, rejectMessages} from '../consts';

const command = {
name: commandNames.SET_OBJECT_PROPERTIES,
Expand Down Expand Up @@ -58,4 +56,4 @@ const command = {

commandFactory.register(command);

module.exports = command;
export default command;
Loading