ikoneme-lib 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -4
- package/dist/ikonDb.d.ts +8 -0
- package/dist/ikonSchema.d.ts +4 -1
- package/dist/ikoneme-lib.cjs +9 -9
- package/dist/ikoneme-lib.cjs.map +1 -1
- package/dist/ikoneme-lib.js +573 -526
- package/dist/ikoneme-lib.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -125,8 +125,11 @@ import {
|
|
|
125
125
|
- `normalizeIkoneme(ikons)` — upgrades any legacy/URL-only stored payloads to
|
|
126
126
|
the `{ name, url }` shape. Run this on data loaded from storage/an API
|
|
127
127
|
before rendering.
|
|
128
|
-
- `generateIkonemeFromText(text)` — deterministic placeholder
|
|
129
|
-
(hash-based), useful for demos/tests until real NLP output is wired
|
|
128
|
+
- `generateIkonemeFromText(text, { search })` — deterministic placeholder
|
|
129
|
+
generator (hash-based), useful for demos/tests until real NLP output is wired
|
|
130
|
+
in. The root of each word is looked up with `search(word, { limit })`, which
|
|
131
|
+
defaults to `searchIkons`; pass one built on `searchIkonsV2` to match words in
|
|
132
|
+
any language.
|
|
130
133
|
- `BORDER_CONFIG` — the 12 border types (`{ id, label, color, plural, image }`);
|
|
131
134
|
`image` is the artwork as a data URI, `color` its main colour.
|
|
132
135
|
- `getBorderImageStyle(border, size)` — inline style that draws a border's
|
|
@@ -153,11 +156,25 @@ The public [IkonDB](https://ikondb.iigap.com/api/docs) client backing the
|
|
|
153
156
|
default root search, exported for reuse:
|
|
154
157
|
|
|
155
158
|
```js
|
|
156
|
-
import { searchIkons, getIkonDetails, getIkonList, IKONDB_BASE_URL } from 'ikoneme-lib'
|
|
159
|
+
import { searchIkons, searchIkonsV2, getIkonDetails, getIkonList, IKONDB_BASE_URL } from 'ikoneme-lib'
|
|
157
160
|
```
|
|
158
161
|
|
|
159
162
|
- `searchIkons(query, { limit })` — `{ id, name, url }[]`, matched by name
|
|
160
|
-
against the full list (fetched once, cached for an hour).
|
|
163
|
+
against the full list (fetched once, cached for an hour). Public, but it only
|
|
164
|
+
knows each icon's base name (mostly Esperanto), so "perro" or "dog" find
|
|
165
|
+
nothing.
|
|
166
|
+
- `searchIkonsV2(query, { token, lang, limit })` — same result shape, from
|
|
167
|
+
`/api/v2/icons/search`: also matches translated titles and tags in 16
|
|
168
|
+
languages, with exact matches first. Needs a logged-in user's access token
|
|
169
|
+
(`POST /api/v2/auth/login`); on failure it throws an `Error` whose `status`
|
|
170
|
+
is the HTTP status, so a host can renew the token on `401` and retry. `lang`
|
|
171
|
+
(e.g. `"it"`) limits matches to that language and picks the name shown.
|
|
172
|
+
|
|
173
|
+
```js
|
|
174
|
+
const searchRoot = (query, opts) => searchIkonsV2(query, { token, ...opts })
|
|
175
|
+
<IkonEditor ikon={ikon} searchRoot={searchRoot} onSave={save} onClose={close} />
|
|
176
|
+
const ikons = await generateIkonemeFromText(text, { search: searchRoot })
|
|
177
|
+
```
|
|
161
178
|
- `getIkonDetails(id)` — `{ id, name, url, origin, preview, thumb, svg }` for one
|
|
162
179
|
icon (cached per id), or `null` if it does not exist.
|
|
163
180
|
- `getIkonList()` — the whole cached list.
|
package/dist/ikonDb.d.ts
CHANGED
|
@@ -5,6 +5,14 @@ export function searchIkons(query: any, { baseUrl, limit }?: {
|
|
|
5
5
|
baseUrl?: string;
|
|
6
6
|
limit?: number;
|
|
7
7
|
}): Promise<any[]>;
|
|
8
|
+
export function searchIkonsV2(query: any, { token, lang, baseUrl, limit }?: {
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
limit?: number;
|
|
11
|
+
}): Promise<{
|
|
12
|
+
id: any;
|
|
13
|
+
name: any;
|
|
14
|
+
url: any;
|
|
15
|
+
}[]>;
|
|
8
16
|
export function getIkonDetails(id: any, { baseUrl }?: {
|
|
9
17
|
baseUrl?: string;
|
|
10
18
|
}): Promise<any>;
|
package/dist/ikonSchema.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { searchIkons } from './ikonDb';
|
|
1
2
|
export function getBorderConfig(borderId: any): {
|
|
2
3
|
id: string;
|
|
3
4
|
label: string;
|
|
@@ -77,7 +78,9 @@ export function createEmptyIkon(): {
|
|
|
77
78
|
};
|
|
78
79
|
export function normalizeIkon(icon: any): any;
|
|
79
80
|
export function normalizeIkoneme(ikons: any): any;
|
|
80
|
-
export function generateIkonemeFromText(text: any
|
|
81
|
+
export function generateIkonemeFromText(text: any, { search }?: {
|
|
82
|
+
search?: typeof searchIkons;
|
|
83
|
+
}): Promise<any[]>;
|
|
81
84
|
export namespace ZONE_CONFIG {
|
|
82
85
|
let context: {
|
|
83
86
|
tooltip: string;
|