From 1e015b93427ff981af389ef7ef401400009b50e2 Mon Sep 17 00:00:00 2001 From: octorock <79596758+octorock@users.noreply.github.com> Date: Mon, 28 Jun 2021 09:03:36 +0200 Subject: [PATCH] Deploy on netlify --- .netlify/state.json | 3 +++ db.json | 8 +++++++ netlify.toml | 13 ++++++++++ package.json | 1 + src/constants.ts | 6 ++++- src/pages/EditorPage.tsx | 10 ++++---- yarn.lock | 52 +++++++++++++++++++++++++++++++++++++--- 7 files changed, 85 insertions(+), 8 deletions(-) create mode 100644 .netlify/state.json create mode 100644 netlify.toml diff --git a/.netlify/state.json b/.netlify/state.json new file mode 100644 index 00000000..a2019f21 --- /dev/null +++ b/.netlify/state.json @@ -0,0 +1,3 @@ +{ + "siteId": "71d83cd7-22c1-4676-9a45-5ab6eed1080a" +} \ No newline at end of file diff --git a/db.json b/db.json index 76e6edaa..02354468 100644 --- a/db.json +++ b/db.json @@ -51,6 +51,14 @@ "asmCode": "thumb_func_start sub_0801CED8\nsub_0801CED8:\n push {r4, lr}\n mov r3, r0\n ldr r0, _data0_0\n mov r1, r0\n add r1, #0x24\n ldrb r4, [r1]\n cmp r4, #0x1\n bne _code0_0\n mov r2, #0x2\n mov r0, #0x2\n strb r0, [r1]\n mov r1, #0x0\n mov r0, #0x10\n strh r0, [r3, #0xc]\n mov r0, #0x90\n strh r0, [r3, #0xe]\n strb r1, [r3, #0x6]\n mov r0, #0x7\n strb r0, [r3, #0x1]\n strb r4, [r3, #0x4]\n ldrb r0, [r3]\n orr r0, r2\n strb r0, [r3]\n ldr r1, _data0_0+0x4\n mov r0, r3\n bl sub_0801CAB8\n_code0_0:\n pop {r4, pc}\n_data0_0:\n .4byte gUnk_0200AF00\n .4byte gUnk_080C9094", "score": "33", "id": 4 + }, + { + "name": "sub_0804C258", + "projectId": "1", + "cCode": "#include \"global.h\"\n#include \"audio.h\"\n#include \"entity.h\"\n#include \"area.h\"\n#include \"room.h\"\n#include \"flags.h\"\n#include \"npc.h\"\n#include \"player.h\"\n#include \"screen.h\"\n#include \"main.h\"\n#include \"structures.h\"\n#include \"save.h\"\n#include \"script.h\"\n#include \"random.h\"\n#include \"functions.h\"\n\n// end of existing headers\n\nvoid sub_0804C258(void) {\n\n}", + "asmCode": "thumb_func_start sub_0804C258\nsub_0804C258:\n push {lr}\n ldr r3, _data0_0\n ldrb r0, [r3, #0xd]\n mov r2, #0xf\n neg r2, r2\n and r2, r0\n mov r0, #0x2\n orr r2, r0\n mov r0, #0xf\n and r2, r0\n strb r2, [r3, #0xd]\n ldr r0, _data0_0+0x4\n ldrb r0, [r0, #0xe]\n cmp r0, #0x4\n bne _code0_0\n mov r1, #0xe\n mov r0, r2\n orr r0, r1\n strb r0, [r3, #0xd]\n mov r0, #0x1\n bl sub_080AF250\n_code0_0:\n pop {pc}\n_data0_0:\n .4byte gArea\n .4byte gScreenTransition", + "score": "28", + "id": 7 } ] } \ No newline at end of file diff --git a/netlify.toml b/netlify.toml new file mode 100644 index 00000000..0d47e7d1 --- /dev/null +++ b/netlify.toml @@ -0,0 +1,13 @@ +[build] + publish = "build/" + +[[redirects]] + from = "/compile/*" + to = "http://cexplore.henny022.de/api/compiler/tmc_agbcc/compile/:splat" + status = 200 + force = true + +[[redirects]] + from = "/*" + to = "/index.html" + status = 200 \ No newline at end of file diff --git a/package.json b/package.json index 8c0fbe20..164cb8be 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ }, "devDependencies": { "@types/react-router-dom": "^5.1.7", + "gh-pages": "^3.2.3", "json-server": "^0.16.3" } } diff --git a/src/constants.ts b/src/constants.ts index a8690841..faddc5ed 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,2 +1,6 @@ //export const API_URL = "http://localhost:5050/" -export const API_URL = "https://my-json-server.typicode.com/octorock/react-ts/" \ No newline at end of file +export const API_URL = "https://my-json-server.typicode.com/octorock/react-ts/" +// export const CEXPLORE_URL = "http://cexplore.henny022.de/api/compiler/tmc_agbcc/compile" +export const CEXPLORE_URL = "/compile/" +//export const CEXPLORE_URL = "http://decomp.netlify.app/compile" +export const COMPILE_DEBOUNCE_TIME = 500; \ No newline at end of file diff --git a/src/pages/EditorPage.tsx b/src/pages/EditorPage.tsx index 55fc316c..06c30927 100644 --- a/src/pages/EditorPage.tsx +++ b/src/pages/EditorPage.tsx @@ -1,9 +1,9 @@ import debounce from "lodash.debounce"; -import { useEffect, useState } from "react"; +import { useCallback, useEffect, useState } from "react"; import { RouteComponentProps } from "react-router"; import { CodeEditor } from "../components/CodeEditor" import { DiffEditor } from "../components/DiffEditor"; -import { API_URL } from "../constants"; +import { API_URL, CEXPLORE_URL, COMPILE_DEBOUNCE_TIME } from "../constants"; import { Func } from "../types"; interface Params { @@ -32,7 +32,9 @@ const EditorPage: React.FC> = ({ match }) => { - const debouncedCompile = debounce(nextValue => compile(nextValue), 500); + const debouncedCompile = + useCallback( + debounce(nextValue => compile(nextValue), COMPILE_DEBOUNCE_TIME), []); const onCodeChange = (newValue: any) => { setCCode(newValue) @@ -41,7 +43,7 @@ const EditorPage: React.FC> = ({ match }) => { const compile = async (nextValue: any) => { console.log('compiling', nextValue); - const res = await fetch("http://cexplore.henny022.de/api/compiler/tmc_agbcc/compile", { + const res = await fetch(CEXPLORE_URL, { "headers": { "accept": "application/json, text/javascript, */*; q=0.01", //"accept-language": "en-US,en;q=0.9", diff --git a/yarn.lock b/yarn.lock index a38588bc..d26a42bc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2528,7 +2528,7 @@ async-limiter@~1.0.0: resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd" integrity sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ== -async@^2.6.2: +async@^2.6.1, async@^2.6.2: version "2.6.3" resolved "https://registry.yarnpkg.com/async/-/async-2.6.3.tgz#d72625e2344a3656e3a3ad4fa749fa83299d82ff" integrity sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg== @@ -3463,7 +3463,7 @@ combined-stream@^1.0.6, combined-stream@~1.0.6: dependencies: delayed-stream "~1.0.0" -commander@^2.20.0: +commander@^2.18.0, commander@^2.20.0: version "2.20.3" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== @@ -4412,6 +4412,11 @@ elliptic@^6.5.3: minimalistic-assert "^1.0.1" minimalistic-crypto-utils "^1.0.1" +email-addresses@^3.0.1: + version "3.1.0" + resolved "https://registry.yarnpkg.com/email-addresses/-/email-addresses-3.1.0.tgz#cabf7e085cbdb63008a70319a74e6136188812fb" + integrity sha512-k0/r7GrWVL32kZlGwfPNgB2Y/mMXVTq/decgLczm/j34whdaspNrZO8CnXPf1laaHxI6ptUlsnAxN+UAPw+fzg== + emittery@^0.7.1: version "0.7.2" resolved "https://registry.yarnpkg.com/emittery/-/emittery-0.7.2.tgz#25595908e13af0f5674ab419396e2fb394cdfa82" @@ -4601,7 +4606,7 @@ escape-string-regexp@2.0.0, escape-string-regexp@^2.0.0: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz#a30304e99daa32e23b2fd20f51babd07cffca344" integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w== -escape-string-regexp@^1.0.5: +escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= @@ -5122,6 +5127,20 @@ file-uri-to-path@1.0.0: resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw== +filename-reserved-regex@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/filename-reserved-regex/-/filename-reserved-regex-2.0.0.tgz#abf73dfab735d045440abfea2d91f389ebbfa229" + integrity sha1-q/c9+rc10EVECr/qLZHzieu/oik= + +filenamify@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/filenamify/-/filenamify-4.3.0.tgz#62391cb58f02b09971c9d4f9d63b3cf9aba03106" + integrity sha512-hcFKyUG57yWGAzu1CMt/dPzYZuv+jAJUT85bL8mrXvNe6hWj6yEHEc4EdcgiA6Z3oi1/9wXJdZPXF2dZNgwgOg== + dependencies: + filename-reserved-regex "^2.0.0" + strip-outer "^1.0.1" + trim-repeated "^1.0.0" + filesize@6.1.0: version "6.1.0" resolved "https://registry.yarnpkg.com/filesize/-/filesize-6.1.0.tgz#e81bdaa780e2451d714d71c0d7a4f3238d37ad00" @@ -5413,6 +5432,19 @@ getpass@^0.1.1: dependencies: assert-plus "^1.0.0" +gh-pages@^3.2.3: + version "3.2.3" + resolved "https://registry.yarnpkg.com/gh-pages/-/gh-pages-3.2.3.tgz#897e5f15e111f42af57d21d430b83e5cdf29472c" + integrity sha512-jA1PbapQ1jqzacECfjUaO9gV8uBgU6XNMV0oXLtfCX3haGLe5Atq8BxlrADhbD6/UdG9j6tZLWAkAybndOXTJg== + dependencies: + async "^2.6.1" + commander "^2.18.0" + email-addresses "^3.0.1" + filenamify "^4.3.0" + find-cache-dir "^3.3.1" + fs-extra "^8.1.0" + globby "^6.1.0" + glob-parent@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae" @@ -10863,6 +10895,13 @@ strip-json-comments@~2.0.1: resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= +strip-outer@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/strip-outer/-/strip-outer-1.0.1.tgz#b2fd2abf6604b9d1e6013057195df836b8a9d631" + integrity sha512-k55yxKHwaXnpYGsOzg4Vl8+tDrWylxDEpknGjhTiZB8dFRU5rTo9CAzeycivxV3s+zlTKwrs6WxMxR95n26kwg== + dependencies: + escape-string-regexp "^1.0.2" + style-loader@1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/style-loader/-/style-loader-1.3.0.tgz#828b4a3b3b7e7aa5847ce7bae9e874512114249e" @@ -11170,6 +11209,13 @@ tr46@^2.0.2: dependencies: punycode "^2.1.1" +trim-repeated@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/trim-repeated/-/trim-repeated-1.0.0.tgz#e3646a2ea4e891312bf7eace6cfb05380bc01c21" + integrity sha1-42RqLqTokTEr9+rObPsFOAvAHCE= + dependencies: + escape-string-regexp "^1.0.2" + tryer@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/tryer/-/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8"