diff --git a/ios/backend/index.js b/ios/backend/index.js index b7169f4..bb5c3f9 100644 --- a/ios/backend/index.js +++ b/ios/backend/index.js @@ -1,7 +1,18 @@ -const fs = require("fs"); +console.log("Loading nodejs"); -function main() { - // const files = fs.readdirSync("."); - const files = "ha"; - return files; -} +const express = require("express"); +const app = express(); +const port = process.env.PORT || 3000; + +const posts = [ +{"key":"%PvT5scAQqPNiVaoYUoz5Omdx3+ds6lLEKp79Kwm02Kc=.sha256","value":{"previous":"%IU4a9V1ieToeUE2SXoqQXH0DMI0/alvxoEkGFjhoZeY=.sha256","sequence":389,"author":"@mfY4X9Gob0w2oVfFv+CpX56PfL0GZ2RNQkc51SJlMvc=.ed25519","timestamp":1588479011745,"hash":"sha256","content":{"type":"post","root":"%RRIlEQi1Mo75X5pKdJ5HOnxRU+4n2bclwIDqiLpCWf0=.sha256","branch":"%RRIlEQi1Mo75X5pKdJ5HOnxRU+4n2bclwIDqiLpCWf0=.sha256","reply":{"%RRIlEQi1Mo75X5pKdJ5HOnxRU+4n2bclwIDqiLpCWf0=.sha256":"@EaYYQo5nAQRabB9nxAn5i2uiIZ665b90Qk2U/WHNVE8=.ed25519"},"channel":null,"recps":null,"text":"This is very cool. I sometimes get mantis pods to eat pests in the garden or on our fruit trees. \n\nIt's good that you noticed that they hatched - supposedly they'll start eating each other if you leave them unattended for too long. Then I think the last one standing is the boss you have to fight to level up.\n\nIt's always so weird and cool to see them so small and in such huge numbers.","mentions":[]},"signature":"y5ixxWK/Z7R+8q7FbgImgQWKQJ+HZXqyOi9HXNPr2m8BvOHXV2zFPt/scz7Eq+1Sn1eCi7WFYK2pL+2Xk4wmCw==.sig.ed25519"},"timestamp":1588479014165,"rts":1588479011745}, +{"key":"%bpmnlkq5tf5GLhV4gt8z8rZ8gsvIE55+KpRZomWug6o=.sha256","value":{"previous":"%KlYtnEt6tnVzCdjVxkye/Yy+P2Tuu7/pORBjxqvpa4M=.sha256","sequence":17384,"author":"@+oaWWDs8g73EZFUMfW37R/ULtFEjwKN/DczvdYihjbU=.ed25519","timestamp":1588466897752,"hash":"sha256","content":{"type":"post","text":"[@Powersource](@Vz6v3xKpzViiTM/GAe+hKkACZSqrErQQZgv4iqQxEn8=.ed25519)\r\n\r\nIt depends on the implementation, but I'd expect that mentions won't work unless the client specifically supports your message type.","mentions":[{"link":"@Vz6v3xKpzViiTM/GAe+hKkACZSqrErQQZgv4iqQxEn8=.ed25519","name":"Powersource"}],"root":"%jK2xn0GE975NzHfAridPvdraqDx3dM60i9UVL7JRSiE=.sha256","branch":["%1O8ZJGxOnhZ624m1nMYM57xLv3LqPDCF/q9DedaPlRc=.sha256","%nrrnKl8YJQYHWmyEjTJevOJdb7/3wcNLKoLG+z2S00c=.sha256"]},"signature":"winljHJAxDLAvRa0uc0nYQvtDh3czkHCVvzKQ+eMH+tV07EGY16z947JZ2X+djctkI6baYpaWkpezXGXc87nAg==.sig.ed25519"},"timestamp":1588466900188,"rts":1588466897752} +] + +app.get("/posts", (req, res) => { + res.json(posts); +}); + +const expressServer = app.listen(port, () => + console.log(`Example app listening at http://localhost:${port}`) +); diff --git a/ios/package-lock.json b/ios/backend/package-lock.json similarity index 59% rename from ios/package-lock.json rename to ios/backend/package-lock.json index b9e205b..905c54b 100644 --- a/ios/package-lock.json +++ b/ios/backend/package-lock.json @@ -19,6 +19,15 @@ "through": ">=2.2.7 <3" } }, + "accepts": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", + "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", + "requires": { + "mime-types": "~2.1.24", + "negotiator": "0.6.2" + } + }, "acorn": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.1.tgz", @@ -56,11 +65,33 @@ "color-convert": "^2.0.1" } }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + }, "bindings-noderify-nodejs-mobile": { "version": "10.3.0", "resolved": "https://registry.npmjs.org/bindings-noderify-nodejs-mobile/-/bindings-noderify-nodejs-mobile-10.3.0.tgz", "integrity": "sha512-ppLwmaDJ0jfHeUvBcdm6QHnmezg2yfHu9nVftxpvMRg4g88iJUIl9D9LR8tuVZlN9lrhb+kfA403aLlTMabrng==" }, + "body-parser": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", + "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", + "requires": { + "bytes": "3.1.0", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.2", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "on-finished": "~2.3.0", + "qs": "6.7.0", + "raw-body": "2.4.0", + "type-is": "~1.6.17" + } + }, "browser-resolve": { "version": "1.11.3", "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.3.tgz", @@ -84,6 +115,11 @@ "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", "dev": true }, + "bytes": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", + "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" + }, "cached-path-relative": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.0.2.tgz", @@ -142,12 +178,43 @@ "typedarray": "^0.0.6" } }, + "content-disposition": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", + "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", + "requires": { + "safe-buffer": "5.1.2" + } + }, + "content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" + }, + "cookie": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", + "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==" + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, "deep-extend": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", @@ -168,6 +235,16 @@ "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", "dev": true }, + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + }, "detective": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/detective/-/detective-5.2.0.tgz", @@ -188,16 +265,124 @@ "readable-stream": "^2.0.2" } }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" + }, + "express": { + "version": "4.17.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", + "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", + "requires": { + "accepts": "~1.3.7", + "array-flatten": "1.1.1", + "body-parser": "1.19.0", + "content-disposition": "0.5.3", + "content-type": "~1.0.4", + "cookie": "0.4.0", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~1.1.2", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "~1.1.2", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.5", + "qs": "6.7.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.1.2", + "send": "0.17.1", + "serve-static": "1.14.1", + "setprototypeof": "1.1.1", + "statuses": "~1.5.0", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + } + }, + "finalhandler": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", + "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", + "requires": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "statuses": "~1.5.0", + "unpipe": "~1.0.0" + } + }, + "forwarded": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", + "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" + }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" + }, "has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" }, + "http-errors": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", + "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" + }, + "dependencies": { + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + } + } + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, "inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", @@ -210,6 +395,11 @@ "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, + "ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==" + }, "is-interactive": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", @@ -281,6 +471,39 @@ } } }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" + }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" + }, + "mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" + }, + "mime-db": { + "version": "1.44.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", + "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==" + }, + "mime-types": { + "version": "2.1.27", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz", + "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==", + "requires": { + "mime-db": "1.44.0" + } + }, "mimic-fn": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", @@ -315,11 +538,21 @@ "xtend": "^4.0.0" } }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, "mute-stream": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==" }, + "negotiator": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", + "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" + }, "noderify": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/noderify/-/noderify-4.3.0.tgz", @@ -334,6 +567,14 @@ "through2": "~2.0.3" } }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "requires": { + "ee-first": "1.1.1" + } + }, "onetime": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.0.tgz", @@ -366,6 +607,11 @@ "path-platform": "~0.11.15" } }, + "parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" + }, "path-parse": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", @@ -378,12 +624,47 @@ "integrity": "sha1-6GQhf3TDaFDwhSt43Hv31KVyG/I=", "dev": true }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + }, "process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", "dev": true }, + "proxy-addr": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz", + "integrity": "sha512-dh/frvCBVmSsDYzw6n926jv974gddhkFPfiN8hPOi30Wax25QZyZEGveluCgliBnqmuM+UJmBErbAUFIoDbjOw==", + "requires": { + "forwarded": "~0.1.2", + "ipaddr.js": "1.9.1" + } + }, + "qs": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" + }, + "range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" + }, + "raw-body": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", + "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", + "requires": { + "bytes": "3.1.0", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + } + }, "rc": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", @@ -432,8 +713,55 @@ "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "send": { + "version": "0.17.1", + "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", + "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", + "requires": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "~1.7.2", + "mime": "1.6.0", + "ms": "2.1.1", + "on-finished": "~2.3.0", + "range-parser": "~1.2.1", + "statuses": "~1.5.0" + }, + "dependencies": { + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + } + } + }, + "serve-static": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", + "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", + "requires": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.17.1" + } + }, + "setprototypeof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" }, "signal-exit": { "version": "3.0.3", @@ -449,6 +777,11 @@ "through": "~2.3.1" } }, + "statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" + }, "stream-combiner2": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz", @@ -515,18 +848,47 @@ "xtend": "~4.0.1" } }, + "toidentifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", + "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" + }, + "type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "requires": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + } + }, "typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, + "utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" + }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" + }, "wcwidth": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", diff --git a/ios/package.json b/ios/backend/package.json similarity index 73% rename from ios/package.json rename to ios/backend/package.json index 283fa3d..1147aef 100644 --- a/ios/package.json +++ b/ios/backend/package.json @@ -9,8 +9,9 @@ "author": "", "license": "ISC", "dependencies": { - "ora": "^4.0.4", - "bindings-noderify-nodejs-mobile": "10.3.0" + "bindings-noderify-nodejs-mobile": "10.3.0", + "express": "^4.17.1", + "ora": "^4.0.4" }, "devDependencies": { "noderify": "4.3.0" diff --git a/ios/feedless.xcodeproj/project.pbxproj b/ios/feedless.xcodeproj/project.pbxproj index 62f1dc2..8670ec4 100644 --- a/ios/feedless.xcodeproj/project.pbxproj +++ b/ios/feedless.xcodeproj/project.pbxproj @@ -9,7 +9,6 @@ /* Begin PBXBuildFile section */ 900BE2972458AEEC00C77595 /* Index.swift in Sources */ = {isa = PBXBuildFile; fileRef = 900BE2962458AEEC00C77595 /* Index.swift */; }; 900BE29A2458B05800C77595 /* Login.swift in Sources */ = {isa = PBXBuildFile; fileRef = 900BE2992458B05800C77595 /* Login.swift */; }; - 900BE29E2458BBF600C77595 /* index.js in Resources */ = {isa = PBXBuildFile; fileRef = 900BE29D2458BBF600C77595 /* index.js */; }; 902D04752458AAA7007CFE56 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 902D04742458AAA7007CFE56 /* AppDelegate.swift */; }; 902D04772458AAA7007CFE56 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 902D04762458AAA7007CFE56 /* SceneDelegate.swift */; }; 902D04792458AAA7007CFE56 /* Wall.swift in Sources */ = {isa = PBXBuildFile; fileRef = 902D04782458AAA7007CFE56 /* Wall.swift */; }; @@ -18,6 +17,10 @@ 902D04812458AAAA007CFE56 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 902D047F2458AAAA007CFE56 /* LaunchScreen.storyboard */; }; 902D048C2458AAAA007CFE56 /* feedlessTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 902D048B2458AAAA007CFE56 /* feedlessTests.swift */; }; 902D04972458AAAA007CFE56 /* feedlessUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 902D04962458AAAA007CFE56 /* feedlessUITests.swift */; }; + 90B81B90245ECB25005C5D31 /* NodeMobile.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 90B81B8F245ECB25005C5D31 /* NodeMobile.framework */; }; + 90B81B91245ECB25005C5D31 /* NodeMobile.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 90B81B8F245ECB25005C5D31 /* NodeMobile.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 90B81B96245ECC00005C5D31 /* NodeRunner.mm in Sources */ = {isa = PBXBuildFile; fileRef = 90B81B95245ECC00005C5D31 /* NodeRunner.mm */; }; + 90B81B98245F1699005C5D31 /* backend in Resources */ = {isa = PBXBuildFile; fileRef = 90B81B97245F1698005C5D31 /* backend */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -37,10 +40,23 @@ }; /* End PBXContainerItemProxy section */ +/* Begin PBXCopyFilesBuildPhase section */ + 90B81B92245ECB25005C5D31 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 90B81B91245ECB25005C5D31 /* NodeMobile.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXFileReference section */ 900BE2962458AEEC00C77595 /* Index.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Index.swift; sourceTree = ""; }; 900BE2992458B05800C77595 /* Login.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Login.swift; sourceTree = ""; }; - 900BE29D2458BBF600C77595 /* index.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = index.js; path = backend/index.js; sourceTree = SOURCE_ROOT; }; 902D04712458AAA7007CFE56 /* feedless.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = feedless.app; sourceTree = BUILT_PRODUCTS_DIR; }; 902D04742458AAA7007CFE56 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 902D04762458AAA7007CFE56 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -55,6 +71,11 @@ 902D04922458AAAA007CFE56 /* feedlessUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = feedlessUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 902D04962458AAAA007CFE56 /* feedlessUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = feedlessUITests.swift; sourceTree = ""; }; 902D04982458AAAA007CFE56 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 90B81B8F245ECB25005C5D31 /* NodeMobile.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NodeMobile.framework; path = libnode/NodeMobile.framework; sourceTree = ""; }; + 90B81B93245ECBBB005C5D31 /* NodeRunner.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NodeRunner.h; sourceTree = ""; }; + 90B81B94245ECBFF005C5D31 /* feedless-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "feedless-Bridging-Header.h"; sourceTree = ""; }; + 90B81B95245ECC00005C5D31 /* NodeRunner.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = NodeRunner.mm; sourceTree = ""; }; + 90B81B97245F1698005C5D31 /* backend */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = backend; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -62,6 +83,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 90B81B90245ECB25005C5D31 /* NodeMobile.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -99,6 +121,7 @@ 902D048A2458AAAA007CFE56 /* feedlessTests */, 902D04952458AAAA007CFE56 /* feedlessUITests */, 902D04722458AAA7007CFE56 /* Products */, + 90B81B8E245ECB25005C5D31 /* Frameworks */, ); sourceTree = ""; }; @@ -115,7 +138,7 @@ 902D04732458AAA7007CFE56 /* feedless */ = { isa = PBXGroup; children = ( - 900BE29D2458BBF600C77595 /* index.js */, + 90B81B97245F1698005C5D31 /* backend */, 900BE2982458AF0C00C77595 /* screens */, 902D04742458AAA7007CFE56 /* AppDelegate.swift */, 902D04762458AAA7007CFE56 /* SceneDelegate.swift */, @@ -123,6 +146,9 @@ 902D047F2458AAAA007CFE56 /* LaunchScreen.storyboard */, 902D04822458AAAA007CFE56 /* Info.plist */, 902D047C2458AAAA007CFE56 /* Preview Content */, + 90B81B93245ECBBB005C5D31 /* NodeRunner.h */, + 90B81B95245ECC00005C5D31 /* NodeRunner.mm */, + 90B81B94245ECBFF005C5D31 /* feedless-Bridging-Header.h */, ); path = feedless; sourceTree = ""; @@ -153,6 +179,14 @@ path = feedlessUITests; sourceTree = ""; }; + 90B81B8E245ECB25005C5D31 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 90B81B8F245ECB25005C5D31 /* NodeMobile.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -163,6 +197,7 @@ 902D046D2458AAA7007CFE56 /* Sources */, 902D046E2458AAA7007CFE56 /* Frameworks */, 902D046F2458AAA7007CFE56 /* Resources */, + 90B81B92245ECB25005C5D31 /* Embed Frameworks */, ); buildRules = ( ); @@ -221,6 +256,7 @@ TargetAttributes = { 902D04702458AAA7007CFE56 = { CreatedOnToolsVersion = 11.3.1; + LastSwiftMigration = 1130; }; 902D04862458AAAA007CFE56 = { CreatedOnToolsVersion = 11.3.1; @@ -260,7 +296,7 @@ 902D04812458AAAA007CFE56 /* LaunchScreen.storyboard in Resources */, 902D047E2458AAAA007CFE56 /* Preview Assets.xcassets in Resources */, 902D047B2458AAAA007CFE56 /* Assets.xcassets in Resources */, - 900BE29E2458BBF600C77595 /* index.js in Resources */, + 90B81B98245F1699005C5D31 /* backend in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -286,6 +322,7 @@ buildActionMask = 2147483647; files = ( 902D04752458AAA7007CFE56 /* AppDelegate.swift in Sources */, + 90B81B96245ECC00005C5D31 /* NodeRunner.mm in Sources */, 900BE29A2458B05800C77595 /* Login.swift in Sources */, 902D04772458AAA7007CFE56 /* SceneDelegate.swift in Sources */, 900BE2972458AEEC00C77595 /* Index.swift in Sources */, @@ -454,9 +491,15 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_ASSET_PATHS = "\"feedless/Preview Content\""; + DEVELOPMENT_TEAM = 8FY84BDRUF; ENABLE_PREVIEWS = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/libnode", + ); INFOPLIST_FILE = feedless/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -464,6 +507,8 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.rogeriochaves.feedless; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "feedless/feedless-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -473,9 +518,15 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_ASSET_PATHS = "\"feedless/Preview Content\""; + DEVELOPMENT_TEAM = 8FY84BDRUF; ENABLE_PREVIEWS = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/libnode", + ); INFOPLIST_FILE = feedless/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -483,6 +534,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.rogeriochaves.feedless; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "feedless/feedless-Bridging-Header.h"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; diff --git a/ios/feedless.xcodeproj/project.xcworkspace/xcuserdata/rchaves.xcuserdatad/UserInterfaceState.xcuserstate b/ios/feedless.xcodeproj/project.xcworkspace/xcuserdata/rchaves.xcuserdatad/UserInterfaceState.xcuserstate index 9ae5522..0aa8ea2 100644 Binary files a/ios/feedless.xcodeproj/project.xcworkspace/xcuserdata/rchaves.xcuserdatad/UserInterfaceState.xcuserstate and b/ios/feedless.xcodeproj/project.xcworkspace/xcuserdata/rchaves.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/ios/feedless.xcodeproj/xcuserdata/rchaves.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/ios/feedless.xcodeproj/xcuserdata/rchaves.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 2a6ad8e..2f68fa9 100644 --- a/ios/feedless.xcodeproj/xcuserdata/rchaves.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/ios/feedless.xcodeproj/xcuserdata/rchaves.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -3,4 +3,22 @@ uuid = "38E852F3-02D7-4B40-92CA-FE3E8994A8BE" type = "1" version = "2.0"> + + + + + + diff --git a/ios/feedless/NodeRunner.h b/ios/feedless/NodeRunner.h new file mode 100644 index 0000000..05c7052 --- /dev/null +++ b/ios/feedless/NodeRunner.h @@ -0,0 +1,9 @@ +#ifndef NodeRunner_h +#define NodeRunner_h +#import + +@interface NodeRunner : NSObject {} ++ (void) startEngineWithArguments:(NSArray*)arguments; +@end + +#endif diff --git a/ios/feedless/NodeRunner.mm b/ios/feedless/NodeRunner.mm new file mode 100644 index 0000000..87e6648 --- /dev/null +++ b/ios/feedless/NodeRunner.mm @@ -0,0 +1,51 @@ +#include "NodeRunner.h" +#include +#include + +@implementation NodeRunner + +//node's libUV requires all arguments being on contiguous memory. ++ (void) startEngineWithArguments:(NSArray*)arguments +{ + int c_arguments_size=0; + + //Compute byte size need for all arguments in contiguous memory. + for (id argElement in arguments) + { + c_arguments_size+=strlen([argElement UTF8String]); + c_arguments_size++; // for '\0' + } + + //Stores arguments in contiguous memory. + char* args_buffer=(char*)calloc(c_arguments_size, sizeof(char)); + + //argv to pass into node. + char* argv[[arguments count]]; + + //To iterate through the expected start position of each argument in args_buffer. + char* current_args_position=args_buffer; + + //Argc + int argument_count=0; + + //Populate the args_buffer and argv. + for (id argElement in arguments) + { + const char* current_argument=[argElement UTF8String]; + + //Copy current argument to its expected position in args_buffer + strncpy(current_args_position, current_argument, strlen(current_argument)); + + //Save current argument start position in argv and increment argc. + argv[argument_count]=current_args_position; + argument_count++; + + //Increment to the next argument's expected position. + current_args_position+=strlen(current_args_position)+1; + } + + //Start node, with argc and argv. + node_start(argument_count,argv); + free(args_buffer); +} +@end diff --git a/ios/feedless/SceneDelegate.swift b/ios/feedless/SceneDelegate.swift index 2d4cf53..34c581d 100644 --- a/ios/feedless/SceneDelegate.swift +++ b/ios/feedless/SceneDelegate.swift @@ -21,40 +21,21 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). + let jsFile = Bundle.main.path(forResource: "backend/index.js", ofType: nil)! - let context = JSContext()! - context.exceptionHandler = { context, exception in - print(exception!.toString()) + DispatchQueue.global(qos: .background).async { + NodeRunner.startEngine(withArguments: ["node", jsFile]) } - let require: @convention(block) (String) -> (JSValue?) = { path in - let expandedPath = NSString(string: path).expandingTildeInPath - - // Return void or throw an error here. - guard FileManager.default.fileExists(atPath: expandedPath) - else { debugPrint("Require: filename \(expandedPath) does not exist") - return nil } - - guard let fileContent = try? String(contentsOfFile: expandedPath) - else { return nil } - - return context.evaluateScript(fileContent) - } - - context.setObject(require, forKeyedSubscript: "require" as NSString) - - guard let url = Bundle.main.url(forResource: "index", withExtension: "js") else { - fatalError("missing resource index.js") - } - - do { - context.evaluateScript(try String(contentsOf: url), withSourceURL: url) - } catch _ { - fatalError("could not evaluate index.js") - } - - let main = context.objectForKeyedSubscript("main") - print("aaaaaaaaaaaaaaaaaaaa", main?.call(withArguments: [])) +// +// do { +// context.evaluateScript(try String(contentsOf: url), withSourceURL: url) +// } catch _ { +// fatalError("could not evaluate index.js") +// } +// +// let main = context.objectForKeyedSubscript("main") +// print("aaaaaaaaaaaaaaaaaaaa", main?.call(withArguments: [])) // Create the SwiftUI view that provides the window contents. let contentView = Index() diff --git a/ios/feedless/feedless-Bridging-Header.h b/ios/feedless/feedless-Bridging-Header.h new file mode 100644 index 0000000..be6c8f4 --- /dev/null +++ b/ios/feedless/feedless-Bridging-Header.h @@ -0,0 +1,5 @@ +// +// Use this file to import your target's public headers that you would like to expose to Swift. +// + +#import "NodeRunner.h" diff --git a/ios/feedless/screens/Login.swift b/ios/feedless/screens/Login.swift index eaff311..706ac45 100644 --- a/ios/feedless/screens/Login.swift +++ b/ios/feedless/screens/Login.swift @@ -10,8 +10,11 @@ import SwiftUI struct Login: View { var body: some View { - NavigationView { - Text("Login Page") + VStack { + Text("Login Page") + NavigationLink(destination: Wall()) { + Text("Submit") + } .navigationBarTitle(Text("Login")) } } diff --git a/ios/feedless/screens/Wall.swift b/ios/feedless/screens/Wall.swift index b8a0ec6..87a7f7f 100644 --- a/ios/feedless/screens/Wall.swift +++ b/ios/feedless/screens/Wall.swift @@ -8,17 +8,63 @@ import SwiftUI -struct ContentView: View { +struct Post: Codable { + public var text: String +} + +struct AuthorContent: Codable { + public var author: String + public var content: T +} + +struct Entry: Codable { + public var key: String + public var value: T +} + +class FetchPosts: ObservableObject { + // 1. + @Published var posts = [Entry>]() + + init() { + let url = URL(string: "http://127.0.0.1:3000/posts")! + // 2. + URLSession.shared.dataTask(with: url) {(data, response, error) in + do { + if let todoData = data { + // 3. + let decodedData = try JSONDecoder().decode([Entry>].self, from: todoData) + DispatchQueue.main.async { + self.posts = decodedData + } + } else { + print("No data loading posts") + } + } catch { + print("Error loading posts") + } + }.resume() + } +} + +struct Wall: View { @State private var selection = 0 - + + @ObservedObject var fetch = FetchPosts() + var body: some View { TabView(selection: $selection){ - Text("First View") - .font(.title) + VStack { + // 2. + List(fetch.posts, id: \.key) { post in + VStack(alignment: .leading) { + Text(post.value.content.text) + } + } + } .tabItem { VStack { - Image("first") - Text("First") + Text("๐Ÿ™‚") } } .tag(0) @@ -26,8 +72,7 @@ struct ContentView: View { .font(.title) .tabItem { VStack { - Image("second") - Text("Second") + Text("๐Ÿ‘จโ€๐Ÿ‘งโ€๐Ÿ‘ฆ") } } .tag(1) @@ -35,8 +80,8 @@ struct ContentView: View { } } -struct ContentView_Previews: PreviewProvider { +struct Wall_Previews: PreviewProvider { static var previews: some View { - ContentView() + Wall() } } diff --git a/ios/libnode/NodeMobile.framework/Headers/NodeMobile.h b/ios/libnode/NodeMobile.framework/Headers/NodeMobile.h new file mode 100644 index 0000000..ee8b967 --- /dev/null +++ b/ios/libnode/NodeMobile.framework/Headers/NodeMobile.h @@ -0,0 +1,10 @@ + +#ifdef __cplusplus +extern "C" { +#endif + +int node_start(int argc, char *argv[]); + +#ifdef __cplusplus +} +#endif diff --git a/ios/libnode/NodeMobile.framework/Info.plist b/ios/libnode/NodeMobile.framework/Info.plist new file mode 100644 index 0000000..ab245f1 Binary files /dev/null and b/ios/libnode/NodeMobile.framework/Info.plist differ diff --git a/ios/libnode/NodeMobile.framework/Modules/module.modulemap b/ios/libnode/NodeMobile.framework/Modules/module.modulemap new file mode 100644 index 0000000..739a5f2 --- /dev/null +++ b/ios/libnode/NodeMobile.framework/Modules/module.modulemap @@ -0,0 +1,6 @@ +framework module NodeMobile { + umbrella header "NodeMobile.h" + + export * + module * { export * } +} diff --git a/ios/libnode/NodeMobile.framework/NodeMobile b/ios/libnode/NodeMobile.framework/NodeMobile new file mode 100755 index 0000000..efabc1c Binary files /dev/null and b/ios/libnode/NodeMobile.framework/NodeMobile differ