diff options
| author | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2022-05-01 00:56:06 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2022-05-01 00:56:06 +0200 |
| commit | a7cf03c192470cbab13edeb1aec99e0c66dede10 (patch) | |
| tree | 581b4430d1de958dcb666bae80a7678332134602 /src | |
| parent | 010f307346e525ac2e4239a0549d2c1a4d6d102b (diff) | |
Update / use typescript
Diffstat (limited to 'src')
| -rw-r--r-- | src/.global.d.ts.icloud | bin | 0 -> 158 bytes | |||
| -rw-r--r-- | src/animations/.blink.js.icloud | bin | 0 -> 156 bytes | |||
| -rw-r--r-- | src/animations/.blink.test.js.icloud | bin | 0 -> 161 bytes | |||
| -rw-r--r-- | src/app.css | 7 | ||||
| -rw-r--r-- | src/app.d.ts | 10 | ||||
| -rw-r--r-- | src/app.html | 1 | ||||
| -rw-r--r-- | src/components/actions/.topic.svelte.icloud | bin | 0 -> 160 bytes | |||
| -rw-r--r-- | src/components/actions/.topic.test.js.icloud | bin | 0 -> 161 bytes | |||
| -rw-r--r-- | src/components/author/.author.svelte.icloud | bin | 0 -> 160 bytes | |||
| -rw-r--r-- | src/components/error_block/.error_block.svelte.icloud | bin | 0 -> 168 bytes | |||
| -rw-r--r-- | src/components/error_block/.error_block.test.js.icloud | bin | 0 -> 169 bytes | |||
| -rw-r--r-- | src/components/footer/.footer.svelte.icloud | bin | 0 -> 161 bytes | |||
| -rw-r--r-- | src/components/forum/.forum.svelte.icloud | bin | 0 -> 160 bytes | |||
| -rw-r--r-- | src/components/forum/.forum.test.js.icloud | bin | 0 -> 161 bytes | |||
| -rw-r--r-- | src/components/forum_list/.forum_list.svelte.icloud | bin | 0 -> 167 bytes | |||
| -rw-r--r-- | src/components/forum_list/.forum_list.test.js.icloud | bin | 0 -> 168 bytes | |||
| -rw-r--r-- | src/components/glyph/.glyph.svelte.icloud | bin | 0 -> 160 bytes | |||
| -rw-r--r-- | src/components/glyph/.glyph.test.js.icloud | bin | 0 -> 161 bytes | |||
| -rw-r--r-- | src/components/header/.header.svelte.icloud | bin | 0 -> 161 bytes | |||
| -rw-r--r-- | src/components/header/.header.test.js.icloud | bin | 0 -> 162 bytes | |||
| -rw-r--r-- | src/components/home/.home.svelte.icloud | bin | 0 -> 158 bytes | |||
| -rw-r--r-- | src/components/invalid_route/.invalid_route.svelte.icloud | bin | 0 -> 169 bytes | |||
| -rw-r--r-- | src/components/language_selector/.language_selector.svelte.icloud | bin | 0 -> 174 bytes | |||
| -rw-r--r-- | src/components/language_selector/.language_selector.test.js.icloud | bin | 0 -> 175 bytes | |||
| -rw-r--r-- | src/components/loader/.loader.svelte.icloud | bin | 0 -> 160 bytes | |||
| -rw-r--r-- | src/components/post/.post.svelte.icloud | bin | 0 -> 159 bytes | |||
| -rw-r--r-- | src/components/post/.post.test.js.icloud | bin | 0 -> 160 bytes | |||
| -rw-r--r-- | src/components/tag/.tag.svelte.icloud | bin | 0 -> 158 bytes | |||
| -rw-r--r-- | src/components/tag/.tag.test.js.icloud | bin | 0 -> 159 bytes | |||
| -rw-r--r-- | src/components/topic/.topic.svelte.icloud | bin | 0 -> 160 bytes | |||
| -rw-r--r-- | src/components/topic/.topic.test.js.icloud | bin | 0 -> 161 bytes | |||
| -rw-r--r-- | src/components/topic_summary/.topic_summary.svelte.icloud | bin | 0 -> 170 bytes | |||
| -rw-r--r-- | src/components/topic_summary/.topic_summary.test.js.icloud | bin | 0 -> 171 bytes | |||
| -rw-r--r-- | src/config/.apollo.js.icloud | bin | 0 -> 157 bytes | |||
| -rw-r--r-- | src/config/.config.js.icloud | bin | 0 -> 157 bytes | |||
| -rw-r--r-- | src/config/.i18n.js.icloud | bin | 0 -> 155 bytes | |||
| -rw-r--r-- | src/config/__mocks__/.config.js.icloud | bin | 0 -> 157 bytes | |||
| -rw-r--r-- | src/config/translations/.en.json.icloud | bin | 0 -> 155 bytes | |||
| -rw-r--r-- | src/config/translations/.es.json.icloud | bin | 0 -> 155 bytes | |||
| -rw-r--r-- | src/data/.queries.js.icloud | bin | 0 -> 158 bytes | |||
| -rw-r--r-- | src/global.d.ts | 3 | ||||
| -rw-r--r-- | src/lib/animations/blink.test.ts (renamed from src/animations/blink.test.js) | 8 | ||||
| -rw-r--r-- | src/lib/animations/blink.ts (renamed from src/animations/blink.js) | 5 | ||||
| -rw-r--r-- | src/lib/components/actions/topic.svelte (renamed from src/components/actions/topic.svelte) | 5 | ||||
| -rw-r--r-- | src/lib/components/actions/topic.test.ts (renamed from src/components/actions/topic.test.js) | 6 | ||||
| -rw-r--r-- | src/lib/components/author/author.svelte (renamed from src/components/author/author.svelte) | 0 | ||||
| -rw-r--r-- | src/lib/components/error_block/error_block.svelte (renamed from src/components/error_block/error_block.svelte) | 4 | ||||
| -rw-r--r-- | src/lib/components/error_block/error_block.test.ts (renamed from src/components/error_block/error_block.test.js) | 6 | ||||
| -rw-r--r-- | src/lib/components/footer/footer.svelte (renamed from src/components/footer/footer.svelte) | 4 | ||||
| -rw-r--r-- | src/lib/components/forum/forum.svelte (renamed from src/components/forum/forum.svelte) | 4 | ||||
| -rw-r--r-- | src/lib/components/forum/forum.test.ts (renamed from src/components/forum/forum.test.js) | 6 | ||||
| -rw-r--r-- | src/lib/components/forum_list/forum_list.svelte (renamed from src/components/forum_list/forum_list.svelte) | 2 | ||||
| -rw-r--r-- | src/lib/components/forum_list/forum_list.test.ts (renamed from src/components/forum_list/forum_list.test.js) | 6 | ||||
| -rw-r--r-- | src/lib/components/glyph/glyph.svelte (renamed from src/components/glyph/glyph.svelte) | 6 | ||||
| -rw-r--r-- | src/lib/components/glyph/glyph.test.ts (renamed from src/components/glyph/glyph.test.js) | 6 | ||||
| -rw-r--r-- | src/lib/components/header/header.svelte (renamed from src/components/header/header.svelte) | 8 | ||||
| -rw-r--r-- | src/lib/components/header/header.test.ts (renamed from src/components/header/header.test.js) | 10 | ||||
| -rw-r--r-- | src/lib/components/home/home.svelte (renamed from src/components/home/home.svelte) | 2 | ||||
| -rw-r--r-- | src/lib/components/invalid_route/invalid_route.svelte (renamed from src/components/invalid_route/invalid_route.svelte) | 2 | ||||
| -rw-r--r-- | src/lib/components/language_selector/language_selector.svelte (renamed from src/components/language_selector/language_selector.svelte) | 4 | ||||
| -rw-r--r-- | src/lib/components/language_selector/language_selector.test.ts (renamed from src/components/language_selector/language_selector.test.js) | 10 | ||||
| -rw-r--r-- | src/lib/components/loader/loader.svelte (renamed from src/components/loader/loader.svelte) | 2 | ||||
| -rw-r--r-- | src/lib/components/post/post.svelte (renamed from src/components/post/post.svelte) | 4 | ||||
| -rw-r--r-- | src/lib/components/post/post.test.ts (renamed from src/components/post/post.test.js) | 6 | ||||
| -rw-r--r-- | src/lib/components/tag/tag.svelte (renamed from src/components/tag/tag.svelte) | 4 | ||||
| -rw-r--r-- | src/lib/components/tag/tag.test.ts (renamed from src/components/tag/tag.test.js) | 6 | ||||
| -rw-r--r-- | src/lib/components/topic/topic.svelte (renamed from src/components/topic/topic.svelte) | 6 | ||||
| -rw-r--r-- | src/lib/components/topic/topic.test.ts (renamed from src/components/topic/topic.test.js) | 6 | ||||
| -rw-r--r-- | src/lib/components/topic_summary/topic_summary.svelte (renamed from src/components/topic_summary/topic_summary.svelte) | 4 | ||||
| -rw-r--r-- | src/lib/components/topic_summary/topic_summary.test.ts (renamed from src/components/topic_summary/topic_summary.test.js) | 6 | ||||
| -rw-r--r-- | src/lib/config/__mocks__/config.ts (renamed from src/config/__mocks__/config.js) | 2 | ||||
| -rw-r--r-- | src/lib/config/apollo.ts (renamed from src/config/apollo.js) | 0 | ||||
| -rw-r--r-- | src/lib/config/config.ts (renamed from src/config/config.js) | 10 | ||||
| -rw-r--r-- | src/lib/config/env.dist (renamed from src/config/env.dist) | 0 | ||||
| -rw-r--r-- | src/lib/data/queries.ts (renamed from src/data/queries.js) | 0 | ||||
| -rw-r--r-- | src/lib/i18n.ts (renamed from src/config/i18n.js) | 2 | ||||
| -rw-r--r-- | src/lib/stores/actions.test.ts (renamed from src/stores/actions.test.js) | 0 | ||||
| -rw-r--r-- | src/lib/stores/actions.ts | 41 | ||||
| -rw-r--r-- | src/lib/stores/apollo.ts | 64 | ||||
| -rw-r--r-- | src/lib/stores/forums.test.ts (renamed from src/stores/forums.test.js) | 4 | ||||
| -rw-r--r-- | src/lib/stores/forums.ts | 5 | ||||
| -rw-r--r-- | src/lib/stores/posts.test.ts (renamed from src/stores/posts.test.js) | 4 | ||||
| -rw-r--r-- | src/lib/stores/posts.ts | 4 | ||||
| -rw-r--r-- | src/lib/stores/tags.test.ts (renamed from src/stores/tags.test.js) | 4 | ||||
| -rw-r--r-- | src/lib/stores/tags.ts | 4 | ||||
| -rw-r--r-- | src/lib/stores/topics.test.ts (renamed from src/stores/topics.test.js) | 4 | ||||
| -rw-r--r-- | src/lib/stores/topics.ts | 4 | ||||
| -rw-r--r-- | src/lib/translations/en.json (renamed from src/config/translations/en.json) | 0 | ||||
| -rw-r--r-- | src/lib/translations/es.json (renamed from src/config/translations/es.json) | 0 | ||||
| -rw-r--r-- | src/lib/utils/glyph_hash.test.ts (renamed from src/utils/glyph_hash.test.js) | 7 | ||||
| -rw-r--r-- | src/lib/utils/glyph_hash.ts (renamed from src/utils/glyph_hash.js) | 10 | ||||
| -rw-r--r-- | src/lib/utils/readable_time.test.ts (renamed from src/utils/readable_time.test.js) | 0 | ||||
| -rw-r--r-- | src/lib/utils/readable_time.ts (renamed from src/utils/readable_time.js) | 12 | ||||
| -rw-r--r-- | src/lib/utils/resolve_after.test.ts (renamed from src/utils/resolve_after.test.js) | 10 | ||||
| -rw-r--r-- | src/lib/utils/resolve_after.ts (renamed from src/utils/resolve_after.js) | 12 | ||||
| -rw-r--r-- | src/routes/__error.svelte | 2 | ||||
| -rw-r--r-- | src/routes/__layout.svelte | 15 | ||||
| -rw-r--r-- | src/routes/a/[id].svelte | 2 | ||||
| -rw-r--r-- | src/routes/f/[id].svelte | 8 | ||||
| -rw-r--r-- | src/routes/g/[id].svelte | 8 | ||||
| -rw-r--r-- | src/routes/index.svelte | 2 | ||||
| -rw-r--r-- | src/routes/p/[id].svelte | 8 | ||||
| -rw-r--r-- | src/routes/t/[id].svelte | 10 | ||||
| -rw-r--r-- | src/stores/.actions.js.icloud | bin | 0 -> 158 bytes | |||
| -rw-r--r-- | src/stores/.actions.test.js.icloud | bin | 0 -> 165 bytes | |||
| -rw-r--r-- | src/stores/.apollo.js.icloud | bin | 0 -> 157 bytes | |||
| -rw-r--r-- | src/stores/.forums.js.icloud | bin | 0 -> 157 bytes | |||
| -rw-r--r-- | src/stores/.forums.test.js.icloud | bin | 0 -> 162 bytes | |||
| -rw-r--r-- | src/stores/.posts.js.icloud | bin | 0 -> 155 bytes | |||
| -rw-r--r-- | src/stores/.posts.test.js.icloud | bin | 0 -> 161 bytes | |||
| -rw-r--r-- | src/stores/.tags.js.icloud | bin | 0 -> 154 bytes | |||
| -rw-r--r-- | src/stores/.tags.test.js.icloud | bin | 0 -> 160 bytes | |||
| -rw-r--r-- | src/stores/.topics.js.icloud | bin | 0 -> 156 bytes | |||
| -rw-r--r-- | src/stores/.topics.test.js.icloud | bin | 0 -> 162 bytes | |||
| -rw-r--r-- | src/stores/actions.js | 32 | ||||
| -rw-r--r-- | src/stores/apollo.js | 46 | ||||
| -rw-r--r-- | src/stores/forums.js | 5 | ||||
| -rw-r--r-- | src/stores/posts.js | 4 | ||||
| -rw-r--r-- | src/stores/tags.js | 4 | ||||
| -rw-r--r-- | src/stores/topics.js | 4 | ||||
| -rw-r--r-- | src/utils/.glyph_hash.js.icloud | bin | 0 -> 161 bytes | |||
| -rw-r--r-- | src/utils/.glyph_hash.test.js.icloud | bin | 0 -> 168 bytes | |||
| -rw-r--r-- | src/utils/.readable_time.js.icloud | bin | 0 -> 166 bytes | |||
| -rw-r--r-- | src/utils/.readable_time.test.js.icloud | bin | 0 -> 171 bytes | |||
| -rw-r--r-- | src/utils/.resolve_after.js.icloud | bin | 0 -> 166 bytes | |||
| -rw-r--r-- | src/utils/.resolve_after.test.js.icloud | bin | 0 -> 171 bytes |
126 files changed, 311 insertions, 211 deletions
diff --git a/src/.global.d.ts.icloud b/src/.global.d.ts.icloud Binary files differnew file mode 100644 index 0000000..656eea3 --- /dev/null +++ b/src/.global.d.ts.icloud diff --git a/src/animations/.blink.js.icloud b/src/animations/.blink.js.icloud Binary files differnew file mode 100644 index 0000000..f1ebe83 --- /dev/null +++ b/src/animations/.blink.js.icloud diff --git a/src/animations/.blink.test.js.icloud b/src/animations/.blink.test.js.icloud Binary files differnew file mode 100644 index 0000000..ed1fc7b --- /dev/null +++ b/src/animations/.blink.test.js.icloud diff --git a/src/app.css b/src/app.css index 1d7e288..b5c61c9 100644 --- a/src/app.css +++ b/src/app.css @@ -1,4 +1,3 @@ -:root { - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, - 'Open Sans', 'Helvetica Neue', sans-serif; -} +@tailwind base; +@tailwind components; +@tailwind utilities; diff --git a/src/app.d.ts b/src/app.d.ts new file mode 100644 index 0000000..9cbf1c5 --- /dev/null +++ b/src/app.d.ts @@ -0,0 +1,10 @@ +/// <reference types="@sveltejs/kit" /> + +// See https://kit.svelte.dev/docs/types#the-app-namespace +// for information about these interfaces +declare namespace App { + // interface Locals {} + // interface Platform {} + // interface Session {} + // interface Stuff {} +} diff --git a/src/app.html b/src/app.html index 062ed0f..3699181 100644 --- a/src/app.html +++ b/src/app.html @@ -11,7 +11,6 @@ %svelte.head% <link rel="manifest" href="/manifest.webmanifest" /> - <link rel="stylesheet" href="/global.css" /> </head> <body> <noscript> diff --git a/src/components/actions/.topic.svelte.icloud b/src/components/actions/.topic.svelte.icloud Binary files differnew file mode 100644 index 0000000..7abf17a --- /dev/null +++ b/src/components/actions/.topic.svelte.icloud diff --git a/src/components/actions/.topic.test.js.icloud b/src/components/actions/.topic.test.js.icloud Binary files differnew file mode 100644 index 0000000..e5d3d76 --- /dev/null +++ b/src/components/actions/.topic.test.js.icloud diff --git a/src/components/author/.author.svelte.icloud b/src/components/author/.author.svelte.icloud Binary files differnew file mode 100644 index 0000000..f34f8ee --- /dev/null +++ b/src/components/author/.author.svelte.icloud diff --git a/src/components/error_block/.error_block.svelte.icloud b/src/components/error_block/.error_block.svelte.icloud Binary files differnew file mode 100644 index 0000000..5eb2e2c --- /dev/null +++ b/src/components/error_block/.error_block.svelte.icloud diff --git a/src/components/error_block/.error_block.test.js.icloud b/src/components/error_block/.error_block.test.js.icloud Binary files differnew file mode 100644 index 0000000..ce12426 --- /dev/null +++ b/src/components/error_block/.error_block.test.js.icloud diff --git a/src/components/footer/.footer.svelte.icloud b/src/components/footer/.footer.svelte.icloud Binary files differnew file mode 100644 index 0000000..f379de7 --- /dev/null +++ b/src/components/footer/.footer.svelte.icloud diff --git a/src/components/forum/.forum.svelte.icloud b/src/components/forum/.forum.svelte.icloud Binary files differnew file mode 100644 index 0000000..1f82158 --- /dev/null +++ b/src/components/forum/.forum.svelte.icloud diff --git a/src/components/forum/.forum.test.js.icloud b/src/components/forum/.forum.test.js.icloud Binary files differnew file mode 100644 index 0000000..6321526 --- /dev/null +++ b/src/components/forum/.forum.test.js.icloud diff --git a/src/components/forum_list/.forum_list.svelte.icloud b/src/components/forum_list/.forum_list.svelte.icloud Binary files differnew file mode 100644 index 0000000..5ee5709 --- /dev/null +++ b/src/components/forum_list/.forum_list.svelte.icloud diff --git a/src/components/forum_list/.forum_list.test.js.icloud b/src/components/forum_list/.forum_list.test.js.icloud Binary files differnew file mode 100644 index 0000000..e4c26fc --- /dev/null +++ b/src/components/forum_list/.forum_list.test.js.icloud diff --git a/src/components/glyph/.glyph.svelte.icloud b/src/components/glyph/.glyph.svelte.icloud Binary files differnew file mode 100644 index 0000000..c2e8af7 --- /dev/null +++ b/src/components/glyph/.glyph.svelte.icloud diff --git a/src/components/glyph/.glyph.test.js.icloud b/src/components/glyph/.glyph.test.js.icloud Binary files differnew file mode 100644 index 0000000..182e8e5 --- /dev/null +++ b/src/components/glyph/.glyph.test.js.icloud diff --git a/src/components/header/.header.svelte.icloud b/src/components/header/.header.svelte.icloud Binary files differnew file mode 100644 index 0000000..d366346 --- /dev/null +++ b/src/components/header/.header.svelte.icloud diff --git a/src/components/header/.header.test.js.icloud b/src/components/header/.header.test.js.icloud Binary files differnew file mode 100644 index 0000000..0efb8d5 --- /dev/null +++ b/src/components/header/.header.test.js.icloud diff --git a/src/components/home/.home.svelte.icloud b/src/components/home/.home.svelte.icloud Binary files differnew file mode 100644 index 0000000..7efdf01 --- /dev/null +++ b/src/components/home/.home.svelte.icloud diff --git a/src/components/invalid_route/.invalid_route.svelte.icloud b/src/components/invalid_route/.invalid_route.svelte.icloud Binary files differnew file mode 100644 index 0000000..e5c13aa --- /dev/null +++ b/src/components/invalid_route/.invalid_route.svelte.icloud diff --git a/src/components/language_selector/.language_selector.svelte.icloud b/src/components/language_selector/.language_selector.svelte.icloud Binary files differnew file mode 100644 index 0000000..f981c0f --- /dev/null +++ b/src/components/language_selector/.language_selector.svelte.icloud diff --git a/src/components/language_selector/.language_selector.test.js.icloud b/src/components/language_selector/.language_selector.test.js.icloud Binary files differnew file mode 100644 index 0000000..7b0a94c --- /dev/null +++ b/src/components/language_selector/.language_selector.test.js.icloud diff --git a/src/components/loader/.loader.svelte.icloud b/src/components/loader/.loader.svelte.icloud Binary files differnew file mode 100644 index 0000000..5c5fbd6 --- /dev/null +++ b/src/components/loader/.loader.svelte.icloud diff --git a/src/components/post/.post.svelte.icloud b/src/components/post/.post.svelte.icloud Binary files differnew file mode 100644 index 0000000..677f94f --- /dev/null +++ b/src/components/post/.post.svelte.icloud diff --git a/src/components/post/.post.test.js.icloud b/src/components/post/.post.test.js.icloud Binary files differnew file mode 100644 index 0000000..fc35a0f --- /dev/null +++ b/src/components/post/.post.test.js.icloud diff --git a/src/components/tag/.tag.svelte.icloud b/src/components/tag/.tag.svelte.icloud Binary files differnew file mode 100644 index 0000000..9400b48 --- /dev/null +++ b/src/components/tag/.tag.svelte.icloud diff --git a/src/components/tag/.tag.test.js.icloud b/src/components/tag/.tag.test.js.icloud Binary files differnew file mode 100644 index 0000000..2d956fd --- /dev/null +++ b/src/components/tag/.tag.test.js.icloud diff --git a/src/components/topic/.topic.svelte.icloud b/src/components/topic/.topic.svelte.icloud Binary files differnew file mode 100644 index 0000000..e60b61c --- /dev/null +++ b/src/components/topic/.topic.svelte.icloud diff --git a/src/components/topic/.topic.test.js.icloud b/src/components/topic/.topic.test.js.icloud Binary files differnew file mode 100644 index 0000000..1e163ec --- /dev/null +++ b/src/components/topic/.topic.test.js.icloud diff --git a/src/components/topic_summary/.topic_summary.svelte.icloud b/src/components/topic_summary/.topic_summary.svelte.icloud Binary files differnew file mode 100644 index 0000000..5060c48 --- /dev/null +++ b/src/components/topic_summary/.topic_summary.svelte.icloud diff --git a/src/components/topic_summary/.topic_summary.test.js.icloud b/src/components/topic_summary/.topic_summary.test.js.icloud Binary files differnew file mode 100644 index 0000000..a1b3613 --- /dev/null +++ b/src/components/topic_summary/.topic_summary.test.js.icloud diff --git a/src/config/.apollo.js.icloud b/src/config/.apollo.js.icloud Binary files differnew file mode 100644 index 0000000..450d231 --- /dev/null +++ b/src/config/.apollo.js.icloud diff --git a/src/config/.config.js.icloud b/src/config/.config.js.icloud Binary files differnew file mode 100644 index 0000000..905a424 --- /dev/null +++ b/src/config/.config.js.icloud diff --git a/src/config/.i18n.js.icloud b/src/config/.i18n.js.icloud Binary files differnew file mode 100644 index 0000000..37580b6 --- /dev/null +++ b/src/config/.i18n.js.icloud diff --git a/src/config/__mocks__/.config.js.icloud b/src/config/__mocks__/.config.js.icloud Binary files differnew file mode 100644 index 0000000..e3fa27b --- /dev/null +++ b/src/config/__mocks__/.config.js.icloud diff --git a/src/config/translations/.en.json.icloud b/src/config/translations/.en.json.icloud Binary files differnew file mode 100644 index 0000000..1603891 --- /dev/null +++ b/src/config/translations/.en.json.icloud diff --git a/src/config/translations/.es.json.icloud b/src/config/translations/.es.json.icloud Binary files differnew file mode 100644 index 0000000..fe4cf36 --- /dev/null +++ b/src/config/translations/.es.json.icloud diff --git a/src/data/.queries.js.icloud b/src/data/.queries.js.icloud Binary files differnew file mode 100644 index 0000000..e22cbc0 --- /dev/null +++ b/src/data/.queries.js.icloud diff --git a/src/global.d.ts b/src/global.d.ts deleted file mode 100644 index 79d7d7f..0000000 --- a/src/global.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// <reference types="@sveltejs/kit" /> -/// <reference types="svelte" /> -/// <reference types="vite/client" /> diff --git a/src/animations/blink.test.js b/src/lib/animations/blink.test.ts index 9834100..32dc872 100644 --- a/src/animations/blink.test.js +++ b/src/lib/animations/blink.test.ts @@ -1,3 +1,7 @@ +/** + * @jest-environment jsdom + */ + import { blink } from './blink'; import { sineOut } from 'svelte/easing'; @@ -49,10 +53,10 @@ describe('blink', () => { test('it allows easing function to be overridden', () => { const response = blink(document.createElement('div'), { - easing: () => 'excellent' + easing: () => 666 }); - expect(response.easing()).toBe('excellent'); + expect(response.easing(0)).toBe(666); }); describe('css animation function', () => { diff --git a/src/animations/blink.js b/src/lib/animations/blink.ts index ca21382..c291b06 100644 --- a/src/animations/blink.js +++ b/src/lib/animations/blink.ts @@ -1,6 +1,7 @@ import { sineOut } from 'svelte/easing'; +import type { AnimationConfig } from 'svelte/animate'; -export const blink = function blink(node, params) { +export const blink = function blink(node: HTMLElement, params: AnimationConfig): AnimationConfig{ const originalWidth = parseFloat(getComputedStyle(node).width); const originalHeight = parseFloat(getComputedStyle(node).height); @@ -9,7 +10,7 @@ export const blink = function blink(node, params) { delay: params.delay || 0, duration: params.duration || 400, easing: params.easing || sineOut, - css: (t, u) => { + css: (t: number): string => { const halfWidth = originalWidth / 2; const halfHeight = originalHeight / 2; diff --git a/src/components/actions/topic.svelte b/src/lib/components/actions/topic.svelte index e2f59c9..1311d06 100644 --- a/src/components/actions/topic.svelte +++ b/src/lib/components/actions/topic.svelte @@ -1,5 +1,6 @@ -<script> - export let actions; +<script lang="ts"> + import type { TopicAction } from '$lib/stores/action'; + export let actions: TopicAction; import { _ } from 'svelte-i18n'; </script> diff --git a/src/components/actions/topic.test.js b/src/lib/components/actions/topic.test.ts index 9d6ee93..0037a7f 100644 --- a/src/components/actions/topic.test.js +++ b/src/lib/components/actions/topic.test.ts @@ -1,7 +1,11 @@ +/** + * @jest-environment jsdom + */ + import '@testing-library/jest-dom/extend-expect'; import { render } from '@testing-library/svelte'; -import '$/config/i18n'; +import '$lib/i18n'; import Topic from './topic.svelte'; diff --git a/src/components/author/author.svelte b/src/lib/components/author/author.svelte index e69de29..e69de29 100644 --- a/src/components/author/author.svelte +++ b/src/lib/components/author/author.svelte diff --git a/src/components/error_block/error_block.svelte b/src/lib/components/error_block/error_block.svelte index e38bfae..d25f507 100644 --- a/src/components/error_block/error_block.svelte +++ b/src/lib/components/error_block/error_block.svelte @@ -1,8 +1,8 @@ -<script> +<script lang="ts"> import { _ } from 'svelte-i18n'; export let message = null; - import { blink } from '$/animations/blink'; + import { blink } from '$lib/animations/blink'; </script> <div transition:blink> diff --git a/src/components/error_block/error_block.test.js b/src/lib/components/error_block/error_block.test.ts index 43c9331..d2ac458 100644 --- a/src/components/error_block/error_block.test.js +++ b/src/lib/components/error_block/error_block.test.ts @@ -1,7 +1,11 @@ +/** + * @jest-environment jsdom + */ + import '@testing-library/jest-dom/extend-expect'; import { render } from '@testing-library/svelte'; -import '$/config/i18n'; +import '$lib/i18n'; import ErrorBlock from './error_block.svelte'; diff --git a/src/components/footer/footer.svelte b/src/lib/components/footer/footer.svelte index 2d5f8ff..5c171d2 100644 --- a/src/components/footer/footer.svelte +++ b/src/lib/components/footer/footer.svelte @@ -1,7 +1,7 @@ -<script> +<script lang="ts"> import { _ } from 'svelte-i18n'; - import LanguageSelector from '$/components/language_selector/language_selector.svelte'; + import LanguageSelector from '$lib/components/language_selector/language_selector.svelte'; const licenseUrl = 'https://gitlab.com/rbdr/forum/'; </script> diff --git a/src/components/forum/forum.svelte b/src/lib/components/forum/forum.svelte index ea9b206..b886428 100644 --- a/src/components/forum/forum.svelte +++ b/src/lib/components/forum/forum.svelte @@ -1,8 +1,8 @@ -<script> +<script lang="ts"> export let forum; import { _ } from 'svelte-i18n'; - import TopicSummary from '$/components/topic_summary/topic_summary.svelte'; + import TopicSummary from '$lib/components/topic_summary/topic_summary.svelte'; </script> <h1>{forum.glyph} {$_(forum.label)}</h1> diff --git a/src/components/forum/forum.test.js b/src/lib/components/forum/forum.test.ts index 832fd6c..b3ce167 100644 --- a/src/components/forum/forum.test.js +++ b/src/lib/components/forum/forum.test.ts @@ -1,9 +1,13 @@ +/** + * @jest-environment jsdom + */ + import '@testing-library/jest-dom/extend-expect'; import { addMessages } from 'svelte-i18n'; import { render } from '@testing-library/svelte'; -import '$/config/i18n'; +import '$lib/i18n'; import Forum from './forum.svelte'; diff --git a/src/components/forum_list/forum_list.svelte b/src/lib/components/forum_list/forum_list.svelte index aeb389e..3529de8 100644 --- a/src/components/forum_list/forum_list.svelte +++ b/src/lib/components/forum_list/forum_list.svelte @@ -1,4 +1,4 @@ -<script> +<script lang="ts"> import { _ } from 'svelte-i18n'; export let forums; diff --git a/src/components/forum_list/forum_list.test.js b/src/lib/components/forum_list/forum_list.test.ts index a165f28..be7d449 100644 --- a/src/components/forum_list/forum_list.test.js +++ b/src/lib/components/forum_list/forum_list.test.ts @@ -1,7 +1,11 @@ +/** + * @jest-environment jsdom + */ + import '@testing-library/jest-dom/extend-expect'; import { render } from '@testing-library/svelte'; -import '$/config/i18n'; +import '$lib/i18n'; import { addMessages } from 'svelte-i18n'; diff --git a/src/components/glyph/glyph.svelte b/src/lib/components/glyph/glyph.svelte index 60f99eb..0559b98 100644 --- a/src/components/glyph/glyph.svelte +++ b/src/lib/components/glyph/glyph.svelte @@ -1,8 +1,8 @@ -<script> +<script lang="ts"> import { _ } from 'svelte-i18n'; - import { getGlyphHash } from '$/utils/glyph_hash'; + import { getGlyphHash } from '$lib/utils/glyph_hash'; - export let uuid; + export let uuid: string; </script> <div class="glyphicon" role="img" aria-label={$_('glyph.title')} title={$_('glyph.title')}> diff --git a/src/components/glyph/glyph.test.js b/src/lib/components/glyph/glyph.test.ts index 93ddc8a..778353f 100644 --- a/src/components/glyph/glyph.test.js +++ b/src/lib/components/glyph/glyph.test.ts @@ -1,7 +1,11 @@ +/** + * @jest-environment jsdom + */ + import '@testing-library/jest-dom/extend-expect'; import { render } from '@testing-library/svelte'; -import '$/config/i18n'; +import '$lib/i18n'; import Glyph from './glyph.svelte'; diff --git a/src/components/header/header.svelte b/src/lib/components/header/header.svelte index dcf95d5..e6c9348 100644 --- a/src/components/header/header.svelte +++ b/src/lib/components/header/header.svelte @@ -1,8 +1,8 @@ -<script> +<script lang="ts"> import { _ } from 'svelte-i18n'; - import { version } from '$/config/config'; - import { topicActions } from '$/stores/actions'; - import TopicActions from '$/components/actions/topic.svelte'; + import { version } from '$lib/config/config'; + import { topicActions } from '$lib/stores/actions'; + import TopicActions from '$lib/components/actions/topic.svelte'; </script> <header title={$_('header.title')}> diff --git a/src/components/header/header.test.js b/src/lib/components/header/header.test.ts index 6be2516..4107b2d 100644 --- a/src/components/header/header.test.js +++ b/src/lib/components/header/header.test.ts @@ -1,10 +1,14 @@ +/** + * @jest-environment jsdom + */ + import '@testing-library/jest-dom/extend-expect'; import { render } from '@testing-library/svelte'; -import '$/config/i18n'; -import { enableTopicActions } from '$/stores/actions'; +import '$lib/i18n'; +import { enableTopicActions } from '$lib/stores/actions'; -jest.mock('$/config/config.js'); +jest.mock('$lib/config/config.ts'); import Header from './header.svelte'; diff --git a/src/components/home/home.svelte b/src/lib/components/home/home.svelte index fa4a70e..9473bbb 100644 --- a/src/components/home/home.svelte +++ b/src/lib/components/home/home.svelte @@ -1,4 +1,4 @@ -<script> +<script lang="ts"> import { _ } from 'svelte-i18n'; </script> diff --git a/src/components/invalid_route/invalid_route.svelte b/src/lib/components/invalid_route/invalid_route.svelte index 2a3686c..a75316d 100644 --- a/src/components/invalid_route/invalid_route.svelte +++ b/src/lib/components/invalid_route/invalid_route.svelte @@ -1,4 +1,4 @@ -<script> +<script lang="ts"> import { _ } from 'svelte-i18n'; </script> diff --git a/src/components/language_selector/language_selector.svelte b/src/lib/components/language_selector/language_selector.svelte index 3198f56..64a4ef9 100644 --- a/src/components/language_selector/language_selector.svelte +++ b/src/lib/components/language_selector/language_selector.svelte @@ -1,4 +1,4 @@ -<script> +<script lang="ts"> import { locale, locales } from 'svelte-i18n'; import { getLangNameFromCode } from 'language-name-map'; @@ -9,7 +9,7 @@ })) .sort((a, b) => a.native - b.native); - let selected = $locale; + let selected = $locale $: { locale.set(selected); diff --git a/src/components/language_selector/language_selector.test.js b/src/lib/components/language_selector/language_selector.test.ts index baf11bb..74156bc 100644 --- a/src/components/language_selector/language_selector.test.js +++ b/src/lib/components/language_selector/language_selector.test.ts @@ -1,9 +1,13 @@ +/** + * @jest-environment jsdom + */ + import '@testing-library/jest-dom/extend-expect'; import { locale } from 'svelte-i18n'; import { act, render } from '@testing-library/svelte'; import userEvent from '@testing-library/user-event'; -import '$/config/i18n'; +import '$lib/i18n'; import LanguageSelector from './language_selector.svelte'; @@ -30,10 +34,10 @@ describe('Language Selector component', () => { locale.subscribe((localeValue) => { - expect(localeValue).toBe('en-US'); + expect(localeValue).toBe('en'); })(); const spanish = internals.results.getByText('EspaƱol'); - userEvent.selectOptions(spanish.closest('select'), spanish); + await userEvent.selectOptions(spanish.closest('select'), spanish); await act(); locale.subscribe((localeValue) => { diff --git a/src/components/loader/loader.svelte b/src/lib/components/loader/loader.svelte index 8d53736..dad0957 100644 --- a/src/components/loader/loader.svelte +++ b/src/lib/components/loader/loader.svelte @@ -1,4 +1,4 @@ -<script> +<script lang="ts"> import { _ } from 'svelte-i18n'; </script> diff --git a/src/components/post/post.svelte b/src/lib/components/post/post.svelte index 66901af..4e6c28f 100644 --- a/src/components/post/post.svelte +++ b/src/lib/components/post/post.svelte @@ -1,10 +1,10 @@ -<script> +<script lang="ts"> export let post; export let index = 0; export let count = 1; import { _ } from 'svelte-i18n'; - import Glyph from '$/components/glyph/glyph.svelte'; + import Glyph from '$lib/components/glyph/glyph.svelte'; const timestampToISO = (timestamp) => new Date(timestamp).toISOString(); </script> diff --git a/src/components/post/post.test.js b/src/lib/components/post/post.test.ts index e158ce9..d43583e 100644 --- a/src/components/post/post.test.js +++ b/src/lib/components/post/post.test.ts @@ -1,7 +1,11 @@ +/** + * @jest-environment jsdom + */ + import '@testing-library/jest-dom/extend-expect'; import { cleanup, render } from '@testing-library/svelte'; -import '$/config/i18n'; +import '$lib/i18n'; import Post from './post.svelte'; diff --git a/src/components/tag/tag.svelte b/src/lib/components/tag/tag.svelte index 954cdaa..86d0b82 100644 --- a/src/components/tag/tag.svelte +++ b/src/lib/components/tag/tag.svelte @@ -1,8 +1,8 @@ -<script> +<script lang="ts"> export let tag; import { _ } from 'svelte-i18n'; - import TopicSummary from '$/components/topic_summary/topic_summary.svelte'; + import TopicSummary from '$lib/components/topic_summary/topic_summary.svelte'; </script> <h1>{$_('tag.title')}: {tag.id}</h1> diff --git a/src/components/tag/tag.test.js b/src/lib/components/tag/tag.test.ts index a2b6e0d..76304e6 100644 --- a/src/components/tag/tag.test.js +++ b/src/lib/components/tag/tag.test.ts @@ -1,7 +1,11 @@ +/** + * @jest-environment jsdom + */ + import '@testing-library/jest-dom/extend-expect'; import { render } from '@testing-library/svelte'; -import '$/config/i18n'; +import '$lib/i18n'; import Tag from './tag.svelte'; diff --git a/src/components/topic/topic.svelte b/src/lib/components/topic/topic.svelte index c0dbfbc..06f2aeb 100644 --- a/src/components/topic/topic.svelte +++ b/src/lib/components/topic/topic.svelte @@ -1,9 +1,9 @@ -<script> +<script lang="ts"> export let topic; import { _ } from 'svelte-i18n'; - import Post from '$/components/post/post.svelte'; - import { readableTime } from '$/utils/readable_time.js'; + import Post from '$lib/components/post/post.svelte'; + import { readableTime } from '$lib/utils/readable_time'; $: remainingTime = topic.updated_at + topic.ttl - Date.now(); $: remaining = readableTime(remainingTime); diff --git a/src/components/topic/topic.test.js b/src/lib/components/topic/topic.test.ts index b4071b5..985ca72 100644 --- a/src/components/topic/topic.test.js +++ b/src/lib/components/topic/topic.test.ts @@ -1,9 +1,13 @@ +/** + * @jest-environment jsdom + */ + import '@testing-library/jest-dom/extend-expect'; import { addMessages } from 'svelte-i18n'; import { cleanup, render } from '@testing-library/svelte'; -import '$/config/i18n'; +import '$lib/i18n'; import Topic from './topic.svelte'; diff --git a/src/components/topic_summary/topic_summary.svelte b/src/lib/components/topic_summary/topic_summary.svelte index 86e51d1..bfcf8ab 100644 --- a/src/components/topic_summary/topic_summary.svelte +++ b/src/lib/components/topic_summary/topic_summary.svelte @@ -1,8 +1,8 @@ -<script> +<script lang="ts"> export let topic; import { _ } from 'svelte-i18n'; - import { readableTime } from '$/utils/readable_time.js'; + import { readableTime } from '$lib/utils/readable_time'; $: remainingTime = topic.updated_at + topic.ttl - Date.now(); $: remaining = readableTime(remainingTime); diff --git a/src/components/topic_summary/topic_summary.test.js b/src/lib/components/topic_summary/topic_summary.test.ts index 9122730..a4c46bf 100644 --- a/src/components/topic_summary/topic_summary.test.js +++ b/src/lib/components/topic_summary/topic_summary.test.ts @@ -1,7 +1,11 @@ +/** + * @jest-environment jsdom + */ + import '@testing-library/jest-dom/extend-expect'; import { render } from '@testing-library/svelte'; -import '$/config/i18n'; +import '$lib/i18n'; import TopicSummary from './topic_summary.svelte'; diff --git a/src/config/__mocks__/config.js b/src/lib/config/__mocks__/config.ts index b70ee31..448e1db 100644 --- a/src/config/__mocks__/config.js +++ b/src/lib/config/__mocks__/config.ts @@ -1,5 +1,5 @@ export const apollo = { - uri: 'http://localhost:1234/graphql', + uri: 'http://127.0.0.1:1234/graphql', name: 'COOL_APP', version: '9.9.9', defaultOptions: { diff --git a/src/config/apollo.js b/src/lib/config/apollo.ts index a3820ed..a3820ed 100644 --- a/src/config/apollo.js +++ b/src/lib/config/apollo.ts diff --git a/src/config/config.js b/src/lib/config/config.ts index 3637670..1ec5ab2 100644 --- a/src/config/config.js +++ b/src/lib/config/config.ts @@ -1,4 +1,6 @@ -import { name, version as packageVersion } from '../../package.json'; +const internals = { + version: '1.0.0' +}; /* * The main configuration object for the Forum frontend. These values @@ -8,8 +10,8 @@ import { name, version as packageVersion } from '../../package.json'; export const apollo = { uri: import.meta.env.VITE_APOLLO_SERVER, - name, - version: packageVersion + name: 'forum', + version: internals.version }; -export const version = packageVersion; +export const version = internals.version; diff --git a/src/config/env.dist b/src/lib/config/env.dist index 1f3ff0c..1f3ff0c 100644 --- a/src/config/env.dist +++ b/src/lib/config/env.dist diff --git a/src/data/queries.js b/src/lib/data/queries.ts index 7364c0f..7364c0f 100644 --- a/src/data/queries.js +++ b/src/lib/data/queries.ts diff --git a/src/config/i18n.js b/src/lib/i18n.ts index 25ffc45..5dd533a 100644 --- a/src/config/i18n.js +++ b/src/lib/i18n.ts @@ -8,5 +8,5 @@ addMessages('es', es); init({ fallbackLocale: 'en', - initialLocale: getLocaleFromNavigator() + initialLocale: getLocaleFromNavigator().replace(/-[A-Z]{2}$/, '') }); diff --git a/src/stores/actions.test.js b/src/lib/stores/actions.test.ts index c650536..c650536 100644 --- a/src/stores/actions.test.js +++ b/src/lib/stores/actions.test.ts diff --git a/src/lib/stores/actions.ts b/src/lib/stores/actions.ts new file mode 100644 index 0000000..95702dc --- /dev/null +++ b/src/lib/stores/actions.ts @@ -0,0 +1,41 @@ +import { derived, writable } from 'svelte/store'; +import type { Readable, Writable } from 'svelte/store'; + +export type Actions = { + topic?: TopicAction +}; + +export type TopicAction = { + id: string +}; + +/* + * This is a store to set the actions in the top header. + */ + +const actions: Writable<Actions> = writable({}); + +export const enableTopicActions = (id: string) => { + + actions.update((actionsValue: Actions): Actions => { + + actionsValue.topic = { + id + }; + return actionsValue; + }); +}; + +export const disableTopicActions = () => { + + actions.update((actionsValue): Actions => { + + delete actionsValue.topic; + return actionsValue; + }); +}; + +export const topicActions: Readable<TopicAction> = derived( + actions, + ($actions) => $actions.topic +); diff --git a/src/lib/stores/apollo.ts b/src/lib/stores/apollo.ts new file mode 100644 index 0000000..12463c3 --- /dev/null +++ b/src/lib/stores/apollo.ts @@ -0,0 +1,64 @@ +import { ApolloError } from '@apollo/client/core'; +import { readable } from 'svelte/store'; +import { client } from '$lib/config/apollo'; +import type { DocumentNode, ApolloQueryResult } from '@apollo/client/core'; + +import type { Readable } from 'svelte/store'; + +/* + * This is a generic store for use with apollo + */ + +type ApolloStoreConfiguration<Type> = { + key: string, + query: DocumentNode, + initialValue?: Type | void + variables?: object +}; + +type ApolloStoreState<Type> = { + loading: boolean, + data: Type | void, + error: Error | void +}; + +export const store = function store<Type>({ key, query, initialValue = null, variables = {} }: ApolloStoreConfiguration<Type>): Readable<ApolloStoreState<Type>> { + + const initialState: ApolloStoreState<Type> = { + loading: true, + data: initialValue, + error: undefined + }; + + return readable( + initialState, + (set) => { + + const handleError = function (error: Error) { + + return set({ + loading: false, + data: initialValue, + error + }); + }; + + client.watchQuery({ query, variables }).subscribe( + (result: ApolloQueryResult<Type>) => { + + if (result.errors) { + const error = new ApolloError({ graphQLErrors: result.errors }); + return handleError(error); + } + + set({ + loading: false, + data: result.data[key], + error: undefined + }); + }, + (error: Error) => handleError(error) + ); + } + ); +}; diff --git a/src/stores/forums.test.js b/src/lib/stores/forums.test.ts index 732964f..5a8c723 100644 --- a/src/stores/forums.test.js +++ b/src/lib/stores/forums.test.ts @@ -1,11 +1,11 @@ import { GraphQLInteraction, Pact, Matchers } from '@pact-foundation/pact'; import { resolve } from 'path'; -import { resolveAfter } from '$/utils/resolve_after'; +import { resolveAfter } from '$lib/utils/resolve_after'; const { eachLike, like } = Matchers; -jest.mock('$/config/config.js'); +jest.mock('$lib/config/config.ts'); import { getForum, getForums } from './forums'; diff --git a/src/lib/stores/forums.ts b/src/lib/stores/forums.ts new file mode 100644 index 0000000..cb62b5a --- /dev/null +++ b/src/lib/stores/forums.ts @@ -0,0 +1,5 @@ +import { store } from './apollo'; +import { GET_FORUM, GET_FORUMS } from '$lib/data/queries'; + +export const getForum = (id: string) => store({ key: 'forum', query: GET_FORUM, variables: { id } }); +export const getForums = () => store({ key: 'forums', query: GET_FORUMS, initialValue: [] }); diff --git a/src/stores/posts.test.js b/src/lib/stores/posts.test.ts index ab17286..afc22f3 100644 --- a/src/stores/posts.test.js +++ b/src/lib/stores/posts.test.ts @@ -1,11 +1,11 @@ import { GraphQLInteraction, Pact, Matchers } from '@pact-foundation/pact'; import { resolve } from 'path'; -import { resolveAfter } from '$/utils/resolve_after'; +import { resolveAfter } from '$lib/utils/resolve_after'; const { eachLike, like } = Matchers; -jest.mock('$/config/config.js'); +jest.mock('$lib/config/config.ts'); import { getPost } from './posts'; diff --git a/src/lib/stores/posts.ts b/src/lib/stores/posts.ts new file mode 100644 index 0000000..0d3dec3 --- /dev/null +++ b/src/lib/stores/posts.ts @@ -0,0 +1,4 @@ +import { store } from './apollo'; +import { GET_POST } from '$lib/data/queries'; + +export const getPost = (id: string) => store({ key: 'post', query: GET_POST, variables: { id } }); diff --git a/src/stores/tags.test.js b/src/lib/stores/tags.test.ts index bf4fa56..9d3eb50 100644 --- a/src/stores/tags.test.js +++ b/src/lib/stores/tags.test.ts @@ -1,11 +1,11 @@ import { GraphQLInteraction, Pact, Matchers } from '@pact-foundation/pact'; import { resolve } from 'path'; -import { resolveAfter } from '$/utils/resolve_after'; +import { resolveAfter } from '$lib/utils/resolve_after'; const { eachLike, like } = Matchers; -jest.mock('$/config/config.js'); +jest.mock('$lib/config/config.ts'); import { getTag } from './tags'; diff --git a/src/lib/stores/tags.ts b/src/lib/stores/tags.ts new file mode 100644 index 0000000..79f017e --- /dev/null +++ b/src/lib/stores/tags.ts @@ -0,0 +1,4 @@ +import { store } from './apollo'; +import { GET_TAG } from '$lib/data/queries'; + +export const getTag = (id: string) => store({ key: 'tag', query: GET_TAG, variables: { id } }); diff --git a/src/stores/topics.test.js b/src/lib/stores/topics.test.ts index 7c3285b..2d2a2e7 100644 --- a/src/stores/topics.test.js +++ b/src/lib/stores/topics.test.ts @@ -1,11 +1,11 @@ import { GraphQLInteraction, Pact, Matchers } from '@pact-foundation/pact'; import { resolve } from 'path'; -import { resolveAfter } from '$/utils/resolve_after'; +import { resolveAfter } from '$lib/utils/resolve_after'; const { eachLike, like } = Matchers; -jest.mock('$/config/config.js'); +jest.mock('$lib/config/config.ts'); import { getTopic } from './topics'; diff --git a/src/lib/stores/topics.ts b/src/lib/stores/topics.ts new file mode 100644 index 0000000..84228cd --- /dev/null +++ b/src/lib/stores/topics.ts @@ -0,0 +1,4 @@ +import { store } from './apollo'; +import { GET_TOPIC } from '$lib/data/queries'; + +export const getTopic = (id: string) => store({ key: 'topic', query: GET_TOPIC, variables: { id } }); diff --git a/src/config/translations/en.json b/src/lib/translations/en.json index 14e89e4..14e89e4 100644 --- a/src/config/translations/en.json +++ b/src/lib/translations/en.json diff --git a/src/config/translations/es.json b/src/lib/translations/es.json index 4f6b0c1..4f6b0c1 100644 --- a/src/config/translations/es.json +++ b/src/lib/translations/es.json diff --git a/src/utils/glyph_hash.test.js b/src/lib/utils/glyph_hash.test.ts index eada78a..5f57a2a 100644 --- a/src/utils/glyph_hash.test.js +++ b/src/lib/utils/glyph_hash.test.ts @@ -1,4 +1,9 @@ import { getGlyphHash } from './glyph_hash'; +import type { GlyphHash } from './glyph_hash'; + +type TestState = { + glyphHash?: GlyphHash +}; describe('Glyph Hash utility', () => { @@ -31,7 +36,7 @@ describe('Glyph Hash utility', () => { describe('it generates four sets of glyphs and colors', () => { - const state = {}; + const state: TestState = {}; beforeEach(() => { diff --git a/src/utils/glyph_hash.js b/src/lib/utils/glyph_hash.ts index 3758601..b704569 100644 --- a/src/utils/glyph_hash.js +++ b/src/lib/utils/glyph_hash.ts @@ -1,3 +1,9 @@ +export type GlyphHash = GlyphHashFragment[]; +type GlyphHashFragment = { + glyph: string, + color: string +}; + const internals = { kDehyphenRegex: /[-]/g, kSplitterRegex: /.{1,8}/g, @@ -26,7 +32,7 @@ const internals = { }; // Return a glyph with color based on a 4 byte fragment of a UUIDv4 -const getGlyphHashFragment = function (uuidFragment) { +const getGlyphHashFragment = function (uuidFragment: string): GlyphHashFragment { const glyphIndex = parseInt(uuidFragment.substring(0, 2), 16) % 16; return { @@ -36,7 +42,7 @@ const getGlyphHashFragment = function (uuidFragment) { }; // Return an array of glyphs based on a UUIDv4 -export const getGlyphHash = function (uuid) { +export const getGlyphHash = function (uuid: string): GlyphHash { const dehyphenedUuid = uuid.replace(/[-]/g, ''); diff --git a/src/utils/readable_time.test.js b/src/lib/utils/readable_time.test.ts index 5d8ba27..5d8ba27 100644 --- a/src/utils/readable_time.test.js +++ b/src/lib/utils/readable_time.test.ts diff --git a/src/utils/readable_time.js b/src/lib/utils/readable_time.ts index 4476952..86ba044 100644 --- a/src/utils/readable_time.js +++ b/src/lib/utils/readable_time.ts @@ -1,3 +1,11 @@ +type DateMagnitude = 'day' | 'hour' | 'minute' | 'second'; + +type ReadableTime = { + count: number, + label: string +}; + + const internals = { magnitudes: { day: 86400000, @@ -12,7 +20,7 @@ const internals = { second: 'time.seconds' }, - makeTimeReadable(time, magnitude) { + makeTimeReadable(time: number, magnitude: DateMagnitude): ReadableTime { return { count: Math.floor(time / internals.magnitudes[magnitude]), @@ -21,7 +29,7 @@ const internals = { } }; -export const readableTime = function readableTime(time) { +export const readableTime = function readableTime(time: number): ReadableTime { switch (true) { case time >= internals.magnitudes.day: diff --git a/src/utils/resolve_after.test.js b/src/lib/utils/resolve_after.test.ts index f7fc753..7e0cc3c 100644 --- a/src/utils/resolve_after.test.js +++ b/src/lib/utils/resolve_after.test.ts @@ -18,19 +18,11 @@ describe('Resolve After', () => { }).toThrow(); }); - test('it should throw if given a negative number', () => { - - expect(() => { - - resolveAfter('lol'); - }).toThrow(); - }); - test('it should resolve after the specified number of times', () => { expect(() => { - const { counter, resolveAfterThree } = resolveAfter(3); + const { counter, promise: resolveAfterThree } = resolveAfter(3); let resolved = false; resolveAfterThree.then(() => (resolved = true)); diff --git a/src/utils/resolve_after.js b/src/lib/utils/resolve_after.ts index 0884401..95a477e 100644 --- a/src/utils/resolve_after.js +++ b/src/lib/utils/resolve_after.ts @@ -1,13 +1,18 @@ -export const resolveAfter = function (timesUntilResolve) { +export type ResolveAfterPromise = { + counter: () => void, + promise: Promise<void> +}; + +export const resolveAfter = function (timesUntilResolve: number): ResolveAfterPromise { let counter = null; let currentValue = 0; - if (typeof timesUntilResolve !== 'number' || timesUntilResolve <= 0) { + if (timesUntilResolve <= 0) { throw new Error('Resolve after requires a positive integer'); } - const promise = new Promise((resolvePromise) => { + const promise: Promise<void> = new Promise((resolvePromise) => { counter = () => { @@ -21,5 +26,4 @@ export const resolveAfter = function (timesUntilResolve) { counter, promise }; - }; diff --git a/src/routes/__error.svelte b/src/routes/__error.svelte index 0dd2cf6..737fc1e 100644 --- a/src/routes/__error.svelte +++ b/src/routes/__error.svelte @@ -1,5 +1,5 @@ <script> - import InvalidRoute from '$/components/invalid_route/invalid_route.svelte'; + import InvalidRoute from '$lib/components/invalid_route/invalid_route.svelte'; </script> <InvalidRoute /> diff --git a/src/routes/__layout.svelte b/src/routes/__layout.svelte index 234d26a..b856e21 100644 --- a/src/routes/__layout.svelte +++ b/src/routes/__layout.svelte @@ -1,16 +1,17 @@ <script> - import '$/config/i18n'; + import "../app.css"; + import '$lib/i18n'; import { isLoading } from 'svelte-i18n'; import { _ } from 'svelte-i18n'; - import { getForums } from '$/stores/forums'; + import { getForums } from '$lib/stores/forums'; - import ErrorBlock from '$/components/error_block/error_block.svelte'; - import ForumList from '$/components/forum_list/forum_list.svelte'; - import Header from '$/components/header/header.svelte'; - import Loader from '$/components/loader/loader.svelte'; - import Footer from '$/components/footer/footer.svelte'; + import ErrorBlock from '$lib/components/error_block/error_block.svelte'; + import ForumList from '$lib/components/forum_list/forum_list.svelte'; + import Header from '$lib/components/header/header.svelte'; + import Loader from '$lib/components/loader/loader.svelte'; + import Footer from '$lib/components/footer/footer.svelte'; $: store = getForums(); $: forums = $store.data; diff --git a/src/routes/a/[id].svelte b/src/routes/a/[id].svelte index 5f8c951..1eef1dc 100644 --- a/src/routes/a/[id].svelte +++ b/src/routes/a/[id].svelte @@ -7,7 +7,7 @@ </script> <script> - import Author from '$/components/author/author.svelte'; + import Author from '$lib/components/author/author.svelte'; </script> <Author /> diff --git a/src/routes/f/[id].svelte b/src/routes/f/[id].svelte index a92862f..eb65c22 100644 --- a/src/routes/f/[id].svelte +++ b/src/routes/f/[id].svelte @@ -8,13 +8,13 @@ <script> import { _ } from 'svelte-i18n'; - import Forum from '$/components/forum/forum.svelte'; - import ErrorBlock from '$/components/error_block/error_block.svelte'; - import Loader from '$/components/loader/loader.svelte'; + import Forum from '$lib/components/forum/forum.svelte'; + import ErrorBlock from '$lib/components/error_block/error_block.svelte'; + import Loader from '$lib/components/loader/loader.svelte'; export let id; - import { getForum } from '$/stores/forums'; + import { getForum } from '$lib/stores/forums'; $: store = getForum(id); $: forum = $store.data; </script> diff --git a/src/routes/g/[id].svelte b/src/routes/g/[id].svelte index d6a83cd..a822738 100644 --- a/src/routes/g/[id].svelte +++ b/src/routes/g/[id].svelte @@ -8,10 +8,10 @@ <script> import { _ } from 'svelte-i18n'; - import { getTag } from '$/stores/tags'; - import ErrorBlock from '$/components/error_block/error_block.svelte'; - import Loader from '$/components/loader/loader.svelte'; - import Tag from '$/components/tag/tag.svelte'; + import { getTag } from '$lib/stores/tags'; + import ErrorBlock from '$lib/components/error_block/error_block.svelte'; + import Loader from '$lib/components/loader/loader.svelte'; + import Tag from '$lib/components/tag/tag.svelte'; export let id; $: store = getTag(id); diff --git a/src/routes/index.svelte b/src/routes/index.svelte index 687d8f3..f5fa06f 100644 --- a/src/routes/index.svelte +++ b/src/routes/index.svelte @@ -1,6 +1,6 @@ <script> import { _ } from 'svelte-i18n'; - import Loader from '$/components/loader/loader.svelte'; + import Loader from '$lib/components/loader/loader.svelte'; </script> <svelte:head> diff --git a/src/routes/p/[id].svelte b/src/routes/p/[id].svelte index 3eeb528..38bdb49 100644 --- a/src/routes/p/[id].svelte +++ b/src/routes/p/[id].svelte @@ -8,10 +8,10 @@ <script> import { _ } from 'svelte-i18n'; - import { getPost } from '$/stores/posts'; - import Post from '$/components/post/post.svelte'; - import ErrorBlock from '$/components/error_block/error_block.svelte'; - import Loader from '$/components/loader/loader.svelte'; + import { getPost } from '$lib/stores/posts'; + import Post from '$lib/components/post/post.svelte'; + import ErrorBlock from '$lib/components/error_block/error_block.svelte'; + import Loader from '$lib/components/loader/loader.svelte'; export let id; diff --git a/src/routes/t/[id].svelte b/src/routes/t/[id].svelte index 50aad50..510ced1 100644 --- a/src/routes/t/[id].svelte +++ b/src/routes/t/[id].svelte @@ -9,12 +9,12 @@ <script> import { onDestroy } from 'svelte'; import { _ } from 'svelte-i18n'; - import { getTopic } from '$/stores/topics'; - import { disableTopicActions, enableTopicActions } from '$/stores/actions'; + import { getTopic } from '$lib/stores/topics'; + import { disableTopicActions, enableTopicActions } from '$lib/stores/actions'; - import Topic from '$/components/topic/topic.svelte'; - import ErrorBlock from '$/components/error_block/error_block.svelte'; - import Loader from '$/components/loader/loader.svelte'; + import Topic from '$lib/components/topic/topic.svelte'; + import ErrorBlock from '$lib/components/error_block/error_block.svelte'; + import Loader from '$lib/components/loader/loader.svelte'; export let id; diff --git a/src/stores/.actions.js.icloud b/src/stores/.actions.js.icloud Binary files differnew file mode 100644 index 0000000..d92becf --- /dev/null +++ b/src/stores/.actions.js.icloud diff --git a/src/stores/.actions.test.js.icloud b/src/stores/.actions.test.js.icloud Binary files differnew file mode 100644 index 0000000..a48942f --- /dev/null +++ b/src/stores/.actions.test.js.icloud diff --git a/src/stores/.apollo.js.icloud b/src/stores/.apollo.js.icloud Binary files differnew file mode 100644 index 0000000..7a785f5 --- /dev/null +++ b/src/stores/.apollo.js.icloud diff --git a/src/stores/.forums.js.icloud b/src/stores/.forums.js.icloud Binary files differnew file mode 100644 index 0000000..a89466f --- /dev/null +++ b/src/stores/.forums.js.icloud diff --git a/src/stores/.forums.test.js.icloud b/src/stores/.forums.test.js.icloud Binary files differnew file mode 100644 index 0000000..a77ae7c --- /dev/null +++ b/src/stores/.forums.test.js.icloud diff --git a/src/stores/.posts.js.icloud b/src/stores/.posts.js.icloud Binary files differnew file mode 100644 index 0000000..dc9200d --- /dev/null +++ b/src/stores/.posts.js.icloud diff --git a/src/stores/.posts.test.js.icloud b/src/stores/.posts.test.js.icloud Binary files differnew file mode 100644 index 0000000..9136b81 --- /dev/null +++ b/src/stores/.posts.test.js.icloud diff --git a/src/stores/.tags.js.icloud b/src/stores/.tags.js.icloud Binary files differnew file mode 100644 index 0000000..0fbf818 --- /dev/null +++ b/src/stores/.tags.js.icloud diff --git a/src/stores/.tags.test.js.icloud b/src/stores/.tags.test.js.icloud Binary files differnew file mode 100644 index 0000000..d67a70f --- /dev/null +++ b/src/stores/.tags.test.js.icloud diff --git a/src/stores/.topics.js.icloud b/src/stores/.topics.js.icloud Binary files differnew file mode 100644 index 0000000..7c07a38 --- /dev/null +++ b/src/stores/.topics.js.icloud diff --git a/src/stores/.topics.test.js.icloud b/src/stores/.topics.test.js.icloud Binary files differnew file mode 100644 index 0000000..425aca9 --- /dev/null +++ b/src/stores/.topics.test.js.icloud diff --git a/src/stores/actions.js b/src/stores/actions.js deleted file mode 100644 index f7fbc28..0000000 --- a/src/stores/actions.js +++ /dev/null @@ -1,32 +0,0 @@ -import { derived, writable } from 'svelte/store'; - -/* - * This is a store to set the actions in the top header. - */ - -const actions = writable({}); - -export const enableTopicActions = (id) => { - - actions.update((actionsValue) => { - - actionsValue.topic = { - id - }; - return actionsValue; - }); -}; - -export const disableTopicActions = () => { - - actions.update((actionsValue) => { - - delete actionsValue.topic; - return actionsValue; - }); -}; - -export const topicActions = derived( - actions, - ($actions) => $actions.topic -); diff --git a/src/stores/apollo.js b/src/stores/apollo.js deleted file mode 100644 index f84a183..0000000 --- a/src/stores/apollo.js +++ /dev/null @@ -1,46 +0,0 @@ -import { ApolloError } from '@apollo/client/core'; -import { readable } from 'svelte/store'; -import { client } from '$/config/apollo'; - -/* - * This is a generic store for use with apollo - */ - -export const store = function store({ key, query, initialValue = null, variables = {} }) { - - return readable( - { - loading: true, - data: initialValue, - error: undefined - }, - (set) => { - - const handleError = function (error) { - - return set({ - loading: false, - data: initialValue, - error - }); - }; - - client.watchQuery({ query, variables }).subscribe( - (result) => { - - if (result.errors) { - const error = new ApolloError({ graphQLErrors: result.errors }); - return handleError(error); - } - - set({ - loading: false, - data: result.data[key], - error: undefined - }); - }, - (error) => handleError(error) - ); - } - ); -}; diff --git a/src/stores/forums.js b/src/stores/forums.js deleted file mode 100644 index 2c03a05..0000000 --- a/src/stores/forums.js +++ /dev/null @@ -1,5 +0,0 @@ -import { store } from './apollo'; -import { GET_FORUM, GET_FORUMS } from '$/data/queries'; - -export const getForum = (id) => store({ key: 'forum', query: GET_FORUM, variables: { id } }); -export const getForums = () => store({ key: 'forums', query: GET_FORUMS, initialValue: [] }); diff --git a/src/stores/posts.js b/src/stores/posts.js deleted file mode 100644 index 0cbf1d5..0000000 --- a/src/stores/posts.js +++ /dev/null @@ -1,4 +0,0 @@ -import { store } from './apollo'; -import { GET_POST } from '$/data/queries'; - -export const getPost = (id) => store({ key: 'post', query: GET_POST, variables: { id } }); diff --git a/src/stores/tags.js b/src/stores/tags.js deleted file mode 100644 index d74b719..0000000 --- a/src/stores/tags.js +++ /dev/null @@ -1,4 +0,0 @@ -import { store } from './apollo'; -import { GET_TAG } from '$/data/queries'; - -export const getTag = (id) => store({ key: 'tag', query: GET_TAG, variables: { id } }); diff --git a/src/stores/topics.js b/src/stores/topics.js deleted file mode 100644 index c90f1a3..0000000 --- a/src/stores/topics.js +++ /dev/null @@ -1,4 +0,0 @@ -import { store } from './apollo'; -import { GET_TOPIC } from '$/data/queries'; - -export const getTopic = (id) => store({ key: 'topic', query: GET_TOPIC, variables: { id } }); diff --git a/src/utils/.glyph_hash.js.icloud b/src/utils/.glyph_hash.js.icloud Binary files differnew file mode 100644 index 0000000..838924c --- /dev/null +++ b/src/utils/.glyph_hash.js.icloud diff --git a/src/utils/.glyph_hash.test.js.icloud b/src/utils/.glyph_hash.test.js.icloud Binary files differnew file mode 100644 index 0000000..7297edf --- /dev/null +++ b/src/utils/.glyph_hash.test.js.icloud diff --git a/src/utils/.readable_time.js.icloud b/src/utils/.readable_time.js.icloud Binary files differnew file mode 100644 index 0000000..3979901 --- /dev/null +++ b/src/utils/.readable_time.js.icloud diff --git a/src/utils/.readable_time.test.js.icloud b/src/utils/.readable_time.test.js.icloud Binary files differnew file mode 100644 index 0000000..76061bb --- /dev/null +++ b/src/utils/.readable_time.test.js.icloud diff --git a/src/utils/.resolve_after.js.icloud b/src/utils/.resolve_after.js.icloud Binary files differnew file mode 100644 index 0000000..0e74aa9 --- /dev/null +++ b/src/utils/.resolve_after.js.icloud diff --git a/src/utils/.resolve_after.test.js.icloud b/src/utils/.resolve_after.test.js.icloud Binary files differnew file mode 100644 index 0000000..9be721f --- /dev/null +++ b/src/utils/.resolve_after.test.js.icloud |