Skip to content

Commit 4e6ead2

Browse files
committed
switch from webpack to esbuild
1 parent 02e8a4c commit 4e6ead2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1237
-4613
lines changed

TODO

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Security context: 0x08f21517ef51 <String[#39]: file://CD552D653EC98D0FCB75745E2A
2727
ROADMAP
2828
look at issues related to crashes
2929
rotsprite
30+
improve undo/redo when drawing pixels / moving things
3031
animation editor
3132
export to gif
3233
==

app/components/art/active-selection.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import React, { Component } from 'react';
22
import { environment } from '#store/environment';
33
import { observer } from 'mobx-react';
4-
import { magenta } from '!!sass-variables-loader!#styles/variables.scss';
4+
import { magenta } from 'sass-variables';
55
import { id } from '#util/uuid';
66

7-
@observer
8-
export class ActiveSelection extends Component {
7+
export const ActiveSelection = observer(class ActiveSelection extends Component {
98

109
id = id();
1110

@@ -34,10 +33,9 @@ export class ActiveSelection extends Component {
3433
</svg>;
3534
}
3635

37-
}
36+
});
3837

39-
@observer
40-
class SelectionLayer extends Component {
38+
const SelectionLayer = observer(class SelectionLayer extends Component {
4139

4240
render() {
4341
const { activeTiles } = environment;
@@ -74,4 +72,4 @@ class SelectionLayer extends Component {
7472
})}
7573
</g>;
7674
}
77-
}
75+
});

app/components/art/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ import { environment } from '#store/environment';
33
import { mappingState } from '../mappings/state';
44
import { Tile } from './tile';
55
import { observer } from 'mobx-react';
6-
import { scrollbarWidth } from '!!sass-variables-loader!#styles/variables.scss';
6+
import { scrollbarWidth } from 'sass-variables';
77
import { DimensionsComponent } from '#util/dimensions-component';
88
import { ActiveSelection } from './active-selection';
99

10-
@observer
11-
export class Art extends DimensionsComponent {
10+
export const Art = observer(class Art extends DimensionsComponent {
1211

1312
mousedown = false;
1413
onMouseDown = () => { this.mousedown = true; };
@@ -83,4 +82,4 @@ export class Art extends DimensionsComponent {
8382
</div>;
8483
}
8584

86-
}
85+
});

app/components/art/tile.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import React, { Component } from 'react';
22
import { environment } from '#store/environment';
33
import { observer } from 'mobx-react';
44

5-
@observer
6-
export class Tile extends Component {
5+
export const Tile = observer(class Tile extends Component {
76

87
render() {
98
const { data = [], paletteLine = 0, scale = 4, ...otherProps } = this.props;
@@ -43,4 +42,4 @@ export class Tile extends Component {
4342
);
4443
}
4544

46-
}
45+
});

app/components/import/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import { importState } from './state';
55
import { DetectSprites } from './ui-detect';
66
import { ImportSprites } from './ui-import';
77

8-
@observer
9-
class Importer extends React.Component {
8+
const Importer = observer(class Importer extends React.Component {
109

1110
render() {
1211
const { config: { active }, sprites } = importState;
@@ -19,7 +18,7 @@ class Importer extends React.Component {
1918
return false;
2019
}
2120
}
22-
}
21+
});
2322

2423
render(
2524
<Importer/>,

app/components/import/state.js

Lines changed: 58 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { observable, computed, action, autorun, toJS } from 'mobx';
1+
import { observable, computed, action, autorun, toJS, makeObservable } from 'mobx';
22
const { dialog } = require('@electron/remote');
33
import { errorMsg } from '#util/dialog';
44
import { removeBackground } from './remove-background';
@@ -8,23 +8,22 @@ import { getMappings } from './generate-mappings';
88
import { importSprite } from './import-sprite';
99

1010
class ImportState {
11-
12-
@observable config = {
11+
config = {
1312
active: false,
1413
};
1514

16-
@observable bboxes = [];
17-
@observable sprites = [];
18-
@observable mappings = [];
19-
@observable type = 'mappings';
20-
@observable importWidth = 0;
21-
@observable importHeight = 0;
22-
@observable spriteIndex = 0;
23-
@observable paletteLine = 0;
24-
@observable fuzziness = 4;
25-
@observable scale = 4;
26-
27-
@action reset = () => {
15+
bboxes = [];
16+
sprites = [];
17+
mappings = [];
18+
type = 'mappings';
19+
importWidth = 0;
20+
importHeight = 0;
21+
spriteIndex = 0;
22+
paletteLine = 0;
23+
fuzziness = 4;
24+
scale = 4;
25+
26+
reset = () => {
2827
this.path = undefined;
2928
this.canvas = undefined;
3029
this.ctx = undefined;
@@ -35,7 +34,7 @@ class ImportState {
3534
this.mappings.replace([]);
3635
};
3736

38-
@action newImport = () => {
37+
newImport = () => {
3938

4039
dialog.showOpenDialog({
4140
title: 'Import Spritesheet',
@@ -51,7 +50,7 @@ class ImportState {
5150
.catch(console.error);
5251
};
5352

54-
@action cancel = () => {
53+
cancel = () => {
5554
this.reset();
5655
this.config.active = false;
5756
};
@@ -98,7 +97,7 @@ class ImportState {
9897
ctx.putImageData(buffer, 32, 32);
9998
};
10099

101-
@action getBBoxes = () => {
100+
getBBoxes = () => {
102101
const { ctx, canvas } = this;
103102
const { width, height } = canvas;
104103
const buffer = ctx.getImageData(0, 0, width, height);
@@ -107,7 +106,7 @@ class ImportState {
107106
);
108107
};
109108

110-
@action importSprites = () => {
109+
importSprites = () => {
111110
const { ctx, canvas } = this;
112111
const { width, height } = canvas;
113112
const buffer = ctx.getImageData(0, 0, width, height);
@@ -123,17 +122,47 @@ class ImportState {
123122
this.sprites.replace(sprites);
124123
};
125124

126-
@action backToDetect = () => {
125+
backToDetect = () => {
127126
this.sprites.replace([]);
128127
};
129128

129+
constructor() {
130+
makeObservable(this, {
131+
config: observable,
132+
bboxes: observable,
133+
sprites: observable,
134+
mappings: observable,
135+
type: observable,
136+
importWidth: observable,
137+
importHeight: observable,
138+
spriteIndex: observable,
139+
paletteLine: observable,
140+
fuzziness: observable,
141+
scale: observable,
142+
reset: action,
143+
newImport: action,
144+
cancel: action,
145+
getBBoxes: action,
146+
importSprites: action,
147+
backToDetect: action,
148+
currentSprite: computed,
149+
tileQty: computed,
150+
changePalette: action,
151+
changeType: action,
152+
importOne: action,
153+
importAll: action,
154+
next: action,
155+
prev: action
156+
});
157+
}
158+
130159
// import stuff
131160

132-
@computed get currentSprite() {
161+
get currentSprite() {
133162
return this.sprites[this.spriteIndex];
134163
}
135164

136-
@computed get tileQty() {
165+
get tileQty() {
137166
return this.mappings.reduce((a, c) => {
138167
return a + (c.width * c.height);
139168
}, 0);
@@ -167,30 +196,30 @@ class ImportState {
167196
}
168197
};
169198

170-
@action changePalette = () => {
199+
changePalette = () => {
171200
const { canvas, ctx } = this;
172201
const { width, height, buffer } = this.currentSprite;
173202
const coloredBuffer = colorMatch(buffer, this.paletteLine);
174203
ctx.putImageData(coloredBuffer, 8, 8);
175204
};
176205

177-
@action changeType = () => {
206+
changeType = () => {
178207
const { canvas, ctx, type } = this;
179208
this.mappings.replace(getMappings(canvas, ctx, type));
180-
}
209+
};
181210

182-
@action importOne = () => {
211+
importOne = () => {
183212
const { ctx, mappings, paletteLine } = this;
184213
importSprite(ctx, mappings, paletteLine);
185214
this.next();
186215
};
187216

188-
@action importAll = () => {
217+
importAll = () => {
189218
this.auto = true;
190219
this.spriteIndex = -1;
191220
};
192221

193-
@action next = () => {
222+
next = () => {
194223
if (this.spriteIndex < this.sprites.length-1) {
195224
this.spriteIndex++;
196225
}
@@ -199,12 +228,11 @@ class ImportState {
199228
}
200229
};
201230

202-
@action prev = () => {
231+
prev = () => {
203232
if (this.spriteIndex > 0) {
204233
this.spriteIndex--;
205234
}
206235
};
207-
208236
}
209237

210238
const importState = new ImportState();

app/components/import/ui-detect.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import { importState } from './state';
55
import { Item, Select, Input } from '#ui';
66
import { fuzzyAssert, zoomAssert } from '#util/assertions';
77

8-
@observer
9-
export class DetectSprites extends React.Component {
8+
export const DetectSprites = observer(class DetectSprites extends React.Component {
109

1110
render() {
1211
const { bboxes, scale } = importState;
@@ -92,4 +91,4 @@ export class DetectSprites extends React.Component {
9291
</div>
9392
</div>;
9493
}
95-
}
94+
});

app/components/import/ui-import.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import { importState } from './state';
55
import { Item, Select, Input } from '#ui';
66
import { zoomAssert, paletteLineAssert } from '#util/assertions';
77

8-
@observer
9-
export class ImportSprites extends React.Component {
8+
export const ImportSprites = observer(class ImportSprites extends React.Component {
109

1110
render() {
1211
const { scale, sprites, spriteIndex, mappings, importWidth, importHeight } = importState;
@@ -147,4 +146,4 @@ export class ImportSprites extends React.Component {
147146
</div>
148147
</div>;
149148
}
150-
}
149+
});

app/components/mappings/axis.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import React, { Component } from 'react';
2-
// import { environment } from '#store/environment';
32
import { observer } from 'mobx-react';
43
import { mappingState } from './state';
54
import { VictoryAxis } from 'victory';
6-
import { white } from '!!sass-variables-loader!#styles/variables.scss';
5+
import { white } from 'sass-variables';
76

87
const style = {
98
axis: {stroke: null},
@@ -18,8 +17,7 @@ function tickFormat(t) {
1817
return t < 0 ? `-0x${h}` : `0x${h}`;
1918
}
2019

21-
@observer
22-
export class Axes extends Component {
20+
export const Axes = observer(class Axes extends Component {
2321

2422
render() {
2523

@@ -56,4 +54,4 @@ export class Axes extends Component {
5654
</g>
5755
}
5856

59-
}
57+
});

app/components/mappings/commands.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import { commands, getCommandLabel } from '#controls/commands';
66
import { mappingState } from './state';
77
import { Item } from '#ui';
88

9-
@observer
10-
export class Commands extends Component {
9+
export const Commands = observer(class Commands extends Component {
1110

1211
render() {
1312
const { baseWidth } = mappingState;
@@ -39,4 +38,4 @@ export class Commands extends Component {
3938
</Masonry>
4039
);
4140
}
42-
}
41+
});

0 commit comments

Comments
 (0)