Skip to content

Commit

Permalink
Merge pull request #38 from 4zzz/master
Browse files Browse the repository at this point in the history
Modularization
  • Loading branch information
crnkjck authored Jun 30, 2022
2 parents 0106add + bf18949 commit 4d10d40
Show file tree
Hide file tree
Showing 30 changed files with 11,441 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ dist/
yarn.lock
.idea/
.DS_Store
package-lock.json
src/.DS_Store
src/Editor.js
yarn-error.log
elm.js
/build/
lib/dist
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
STATIC_FILES = index.html static/main.css static/img/favicon.ico
ELM_MAIN = src/Editor.elm
ELM_MAIN = src/Main.elm
ELM_FILES = $(wildcard src/*.elm)

PUBLISH_URL = dai.fmph.uniba.sk:/home/webmaster/dai/courses/lpi/folTableauEditor
Expand All @@ -22,7 +22,7 @@ live:
.PHONY: build publish clean live


$(OUT_DIR)/index.html: $(SRC_DIR)/index.html $(OUT_DIR)/static/main.css $(OUT_DIR)/Editor.js
$(OUT_DIR)/index.html: $(SRC_DIR)/index.html $(OUT_DIR)/static/main.css $(OUT_DIR)/Main.js
mkdir -p $(OUT_DIR)
sed -e 's,src="[^"]*",src="$(notdir $(ELM_OUT))?'"$$(sha1sum $(ELM_OUT) | grep -o '^[0-9a-f]\+')"'",; s,href="static/main\.css",href="static/main.css?'"$$(sha1sum $(OUT_DIR)/static/main.css | grep -o '^[0-9a-f]\+')"'",' $< >$@

Expand Down
3 changes: 3 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-react"]
}
28 changes: 28 additions & 0 deletions buildModule.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const fs = require('fs/promises');
const {exec} = require('child_process');

function cmd(command) {
return new Promise((resolve, reject) => {
console.log(command);
const proc = exec(command);
proc.stdout.on('data', function (data) {process.stdout.write(data)});
proc.stderr.on('data', function (data) {process.stderr.write(data)});
proc.on('exit', function (code) {code === 0 ? resolve(0) : reject(code)});
});
}

(async () => {
// if exists, remove './lib/dist' folder
await fs.rm('./lib/dist', {
force: true,
recursive: true,
});
// compile elm app
await cmd("npx elm make src/MainEmbeddable.elm --optimize --output lib/dist/elm-editor.js");
// compile react component
await cmd("npx babel --extensions '.jsx' src --out-dir lib/dist");
// isolate css files
await cmd("npx isolate-css-cli -p tableaueditor-Obry4K9MqH -c -o lib/dist/static/css -u 2 src/static");
// copy font files used by isolated css
await cmd("npx copyfiles -u 3 src/static/webfonts/* lib/dist/static/webfonts");
})()
13 changes: 13 additions & 0 deletions lib/types/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
interface AppProps {
instance: any,
isEdited: boolean,
onStateChange: () => void
}

interface PrepareResult {
instance: any,
getState: (instance: any) => any,
}

export function prepare(initialState: any): PrepareResult
export function AppComponent(props: AppProps): JSX.Element
Loading

0 comments on commit 4d10d40

Please sign in to comment.