Skip to content

Commit 5a2407f

Browse files
committed
telemetry
1 parent 465f8b9 commit 5a2407f

4 files changed

Lines changed: 40 additions & 34 deletions

File tree

flex2.idea

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ create new file | newFactory={(path)=>{}}
2020
==
2121

2222
logo
23-
clean up bundles (folder, unused shit)
24-
electron-builder build.js
2523
analytics
24+
read file sync for callback
2625
submissions->utilities

modules/formats/asm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function asmToBin(buffer) {
1717
// add starting label to ensure all sections are accounted for
1818
const sections = (('__flex2__internal: \n' + asm)
1919
.replace(/^\S/gm, (d) => `;;${d}`)
20-
.replace(/\s/gm, '') + ';')
20+
.replace(/\s/gm, '') + ';') // strip all whitespace (windows line endings)
2121
.match(/;.*?:.*?;/g)
2222
.map((d) => d.replace(/;/g, '').split(':'));
2323

modules/root.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ document.addEventListener('drop', (e) => {
1919
e.preventDefault();
2020
return false;
2121
},false);
22+
23+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
24+
(i[r].q=i[r].q||[]).push(arguments);},i[r].l=1*new Date();a=s.createElement(o),
25+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m);
26+
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
27+
28+
ga('create', 'UA-109339588-1', 'auto');
29+
ga('send', 'pageview');

modules/store/environment.js

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { readFile, writeFile } from 'fs';
1+
import { readFile, readFileSync, writeFile } from 'fs';
22
import { extname } from 'path';
33
import { observable, computed, action, autorun, toJS, spy } from 'mobx';
44
import range from 'lodash/range';
@@ -101,10 +101,12 @@ class Environment {
101101
// load art
102102
if (obj.art.path) {
103103
const artPath = workspace.absolutePath(obj.art.path);
104-
readFile(artPath, (err, buffer) => {
105-
if (err) return errorMsg('Error Reading Art File', err);
104+
try {
105+
const buffer = readFileSync(artPath);
106106
this.tiles.replace(bufferToTiles(buffer, obj.art.compression));
107-
});
107+
} catch(e) {
108+
errorMsg('Error Reading Art File', e.message);
109+
}
108110
}
109111
else {
110112
this.tiles.replace([]);
@@ -113,14 +115,17 @@ class Environment {
113115
if (obj.mappings.path) {
114116
const mappingPath = workspace.absolutePath(obj.mappings.path);
115117
const isAsm = extname(obj.mappings.path) == '.asm';
116-
readFile(mappingPath, (err, buffer) => {
117-
if (err) return errorMsg('Error Reading Mapping File', err);
118+
try {
119+
const buffer = readFileSync(mappingPath);
118120
const newMappings = bufferToMappings(
119121
isAsm ? asmToBin(buffer) : buffer,
120122
obj.mappingDefinition,
121123
);
122124
this.mappings.replace(newMappings);
123-
});
125+
126+
} catch(e) {
127+
errorMsg('Error Reading Mapping File', e.message);
128+
}
124129
}
125130
else {
126131
this.mappings.replace([]);
@@ -130,41 +135,35 @@ class Environment {
130135
if (this.config.dplcsEnabled && obj.dplcs.path) {
131136
const dplcPath = workspace.absolutePath(obj.dplcs.path);
132137
const isAsm = extname(obj.dplcs.path) == '.asm';
133-
readFile(dplcPath, (err, buffer) => {
134-
if (err) return errorMsg('Error Reading DPLC File', err);
138+
try {
139+
const buffer = readFileSync(dplcPath);
135140
const newDPLCs = bufferToDPLCs(
136141
isAsm ? asmToBin(buffer) : buffer,
137142
obj.dplcDefinition,
138143
);
139144
this.dplcs.replace(newDPLCs);
140-
});
145+
} catch(e) {
146+
errorMsg('Error Reading DPLC File', e.message);
147+
}
141148
}
142149
else {
143150
this.dplcs.replace([]);
144151
}
145152

146-
// load palettes
147-
Promise
148-
.all(
149-
obj.palettes.map(({path, length}) => {
150-
const palettePath = workspace.absolutePath(path);
151-
return new Promise((resolve, reject) => {
152-
readFile(palettePath, (err, buffer) => {
153-
if (err) reject(err);
154-
resolve({buffer, length});
155-
});
156-
});
157-
})
158-
)
159-
.then((all) => {
160-
buffersToColors(all)
161-
.forEach((line, i) => {
162-
this.palettes[i] = line;
163-
});
164-
})
165-
.catch((err) => {
166-
errorMsg('Error Reading Palette File', err.message);
153+
try {
154+
const paletteBuffers = obj.palettes.map(({path, length}) => {
155+
const palettePath = workspace.absolutePath(path);
156+
return { buffer: readFileSync(palettePath), length };
167157
});
158+
159+
buffersToColors(paletteBuffers)
160+
.forEach((line, i) => {
161+
this.palettes[i] = line;
162+
});
163+
} catch(e) {
164+
errorMsg('Error Reading DPLC File', e.message);
165+
}
166+
168167
};
169168

170169
@action saveObject = (obj) => {

0 commit comments

Comments
 (0)