-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
170 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import assert from "assert" | ||
import { build } from "esbuild" | ||
import { basename } from "path" | ||
import { commonOptions, writeOutput } from "./common" | ||
|
||
build({ | ||
...commonOptions, | ||
}).then(({ outputFiles: [buildOutput] }) => { | ||
const meta = {} | ||
const { GITHUB_JOB, GITHUB_REF_NAME, GITHUB_REPOSITORY } = process.env | ||
|
||
if (GITHUB_JOB === "do_release") { | ||
assert(GITHUB_REF_NAME && GITHUB_REPOSITORY) | ||
meta["version"] = GITHUB_REF_NAME.slice(1) | ||
meta[ | ||
"updateURL" | ||
] = `https://github.com/${GITHUB_REPOSITORY}/releases/latest/download/${basename( | ||
commonOptions.outfile! | ||
)}` | ||
} | ||
|
||
writeOutput(buildOutput, meta) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Plugin } from "esbuild" | ||
import fetch from "node-fetch" | ||
import type { LinkuWord, Word } from "../../../src/data" | ||
|
||
export const wordsPlugin: Plugin = { | ||
name: "linku-words", | ||
setup: ({ onResolve, onLoad }) => { | ||
const filter = /^~words$/ | ||
onResolve({ filter }, ({ path }) => ({ | ||
namespace: "linku-words", | ||
path, | ||
})) | ||
onLoad({ filter, namespace: "linku-words" }, async () => { | ||
const { data: linkuData } = await fetch( | ||
"https://linku.la/jasima/data.json" | ||
).then( | ||
(res) => res.json() as Promise<{ data: Record<string, LinkuWord> }> | ||
) | ||
|
||
const wordData: Record<string, Word> = {} | ||
|
||
for (const key of Object.keys(linkuData)) { | ||
const word = linkuData[key] | ||
wordData[key] = { | ||
word: word.word, | ||
def: word.def.en, | ||
usage_category: word.usage_category, | ||
recognition: word.recognition, | ||
book: word.book, | ||
coined_year: word.coined_year, | ||
sitelen_pona: word.sitelen_pona, | ||
ucsur: word.ucsur, | ||
} | ||
} | ||
|
||
return { | ||
contents: `const words = JSON.parse(${JSON.stringify( | ||
JSON.stringify(wordData) | ||
)})\nexport default words\n`, | ||
} | ||
}) | ||
}, | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,14 @@ | ||
import { wordsData } from "../data/words" | ||
import words from "~words" | ||
export { words } | ||
|
||
export const words = wordsData as Record<string, Word> | ||
export const wordList = new Set( | ||
Object.keys(words).map((word) => word.toLowerCase()) | ||
export const wordLookup = new Map( | ||
Object.entries(words).map(([key, value]) => [key.toLowerCase(), value]) | ||
) | ||
|
||
export function isWord(word: string) { | ||
return wordList.has(word.toLowerCase()) | ||
return wordLookup.has(word.toLowerCase()) | ||
} | ||
|
||
export type UsageCategory = | ||
| "obscure" | ||
| "rare" | ||
| "uncommon" | ||
| "common" | ||
| "widespread" | ||
| "core" | ||
export type BookName = "pu" | "ku suli" | "ku lili" | "none" | ||
export type CoinedEra = "pre-pu" | "post-pu" | "post-ku" | ||
export type Tag = "pre-pu ALT" | "nimi nanpa" | ||
|
||
export interface Word { | ||
word: string | ||
/** | ||
* Maps from language code to definition | ||
*/ | ||
def: Record<string, string> | ||
book: BookName | ||
commentary?: string | ||
sitelen_pona?: string | ||
sitelen_pona_etymology?: string | ||
|
||
/** | ||
* Maps from date to string of percentage used | ||
* | ||
* @example { '2022-08': '99' } | ||
*/ | ||
recognition: Record<string, string> | ||
|
||
/** | ||
* Unicode | ||
*/ | ||
ucsur?: string | ||
/** | ||
* Image URL | ||
*/ | ||
sitelen_sitelen?: string | ||
/** | ||
* Emoji character | ||
*/ | ||
sitelen_emosi?: string | ||
luka_pona?: { | ||
mp4: string | ||
gif: string | ||
} | ||
/** | ||
* URLs to audio files from different speakers | ||
*/ | ||
audio?: Record<string, string> | ||
coined_year?: string | ||
coined_era?: CoinedEra | ||
usage_category: UsageCategory | ||
source_language?: string | ||
etymology?: string | ||
creator?: string | ||
ku_data?: string | ||
|
||
/** | ||
* Other words, separated by commas | ||
*/ | ||
see_also?: string | ||
|
||
tags?: Tag | ||
|
||
/** | ||
* Only a few language codes (en, fr, de, eo) | ||
*/ | ||
pu_verbatim?: Record<string, string> | ||
} | ||
// for (const [word, data] of wordLookup.entries()) { | ||
// data.ucsur | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
export type UsageCategory = | ||
| "obscure" | ||
| "rare" | ||
| "uncommon" | ||
| "common" | ||
| "widespread" | ||
| "core" | ||
export type BookName = "pu" | "ku suli" | "ku lili" | "none" | ||
export type CoinedEra = "pre-pu" | "post-pu" | "post-ku" | ||
export type Tag = "pre-pu ALT" | "nimi nanpa" | ||
|
||
export interface Word | ||
extends Pick< | ||
LinkuWord, | ||
| "word" | ||
| "book" | ||
| "sitelen_pona" | ||
| "recognition" | ||
| "coined_year" | ||
| "usage_category" | ||
| "ucsur" | ||
> { | ||
def: LinkuWord["def"]["en"] | ||
} | ||
|
||
export interface LinkuWord { | ||
word: string | ||
/** | ||
* Maps from language code to definition | ||
*/ | ||
def: Record<string, string> | ||
book: BookName | ||
commentary?: string | ||
sitelen_pona?: string | ||
sitelen_pona_etymology?: string | ||
|
||
/** | ||
* Maps from date to string of percentage used | ||
* | ||
* @example { '2022-08': '99' } | ||
*/ | ||
recognition: Record<string, string> | ||
|
||
/** | ||
* Unicode | ||
*/ | ||
ucsur?: string | ||
/** | ||
* Image URL | ||
*/ | ||
sitelen_sitelen?: string | ||
/** | ||
* Emoji character | ||
*/ | ||
sitelen_emosi?: string | ||
luka_pona?: { | ||
mp4: string | ||
gif: string | ||
} | ||
/** | ||
* URLs to audio files from different speakers | ||
*/ | ||
audio?: Record<string, string> | ||
coined_year?: string | ||
coined_era?: CoinedEra | ||
usage_category: UsageCategory | ||
source_language?: string | ||
etymology?: string | ||
creator?: string | ||
ku_data?: string | ||
|
||
/** | ||
* Other words, separated by commas | ||
*/ | ||
see_also?: string | ||
|
||
tags?: Tag | ||
|
||
/** | ||
* Only a few language codes (en, fr, de, eo) | ||
*/ | ||
pu_verbatim?: Record<string, string> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters