ikoneme-lib 0.1.1 → 0.3.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 +259 -252
- package/dist/ikonSchema.d.ts +24 -28
- package/dist/ikoneme-lib.cjs +8 -8
- package/dist/ikoneme-lib.cjs.map +1 -1
- package/dist/ikoneme-lib.js +858 -809
- package/dist/ikoneme-lib.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,252 +1,259 @@
|
|
|
1
|
-
# ikoneme-lib
|
|
2
|
-
|
|
3
|
-
React components to render and edit **ikonemes** — ordered sequences of **ikons**
|
|
4
|
-
("rich icons" / "super icons") — using the same rich JSON payload produced by
|
|
5
|
-
the KomunIKON NLP pipeline and consumed by [ikonchat](../ikonchat).
|
|
6
|
-
|
|
7
|
-
This package has no server-side logic of its own: it is a pure rendering/editing
|
|
8
|
-
layer over the ikon JSON payload. The goal is for ikonchat (and any other
|
|
9
|
-
messaging UI) to depend on this library instead of carrying its own copy of the
|
|
10
|
-
rich-icon rendering code.
|
|
11
|
-
|
|
12
|
-
## Concepts
|
|
13
|
-
|
|
14
|
-
- **Ikon** — a single rich icon: a 6x6 grid of zones (`context`, `reference`,
|
|
15
|
-
`role`, `modes`, `root`, `tenses`) plus a grammatical `border`.
|
|
16
|
-
- **Ikoneme** — an ordered list of ikons, e.g. one per word/concept extracted
|
|
17
|
-
from a sentence. This is what you render in a chat bubble.
|
|
18
|
-
|
|
19
|
-
### JSON payload
|
|
20
|
-
|
|
21
|
-
An ikoneme is a plain array of ikon objects:
|
|
22
|
-
|
|
23
|
-
```json
|
|
24
|
-
[
|
|
25
|
-
{
|
|
26
|
-
"context": { "name": "Male", "url": "https://.../KomunIKON_Male.svg" },
|
|
27
|
-
"reference": {
|
|
28
|
-
"left": null,
|
|
29
|
-
"right": { "name": "Two", "url": "https://.../KomunIKON_Two.svg" }
|
|
30
|
-
},
|
|
31
|
-
"role": { "name": "agent", "url": "https://.../KomunIKON_agent.svg" },
|
|
32
|
-
"modes": { "name": "Exclam", "url": "https://.../KomunIKON_Exclam.svg" },
|
|
33
|
-
"root": { "name": "Love/Passion", "url": "https://.../ZFcaar88AP.png" },
|
|
34
|
-
"rootName": "Love/Passion",
|
|
35
|
-
"tenses": { "name": "as", "url": "https://.../KomunIKON_Verbal_Tense_as.svg" },
|
|
36
|
-
"border": "verb"
|
|
37
|
-
}
|
|
38
|
-
]
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
This is **exactly** the shape ikonchat stores per message (`message.richIcons`).
|
|
42
|
-
Any extra fields (e.g. a `metadata` block from the NLP pipeline) are preserved
|
|
43
|
-
untouched by `normalizeIkon`/`normalizeIkoneme`.
|
|
44
|
-
|
|
45
|
-
It also maps directly onto the NLP "Rich Icon Output Specification" vocabulary:
|
|
46
|
-
|
|
47
|
-
| This library / ikonchat | NLP spec |
|
|
48
|
-
| ------------------------------------- | ------------- |
|
|
49
|
-
| `context` | `gender` |
|
|
50
|
-
| `modes` | `mode` |
|
|
51
|
-
| `tenses` | `time-tenses` |
|
|
52
|
-
| `reference`, `role`, `root`, `border` | same name |
|
|
53
|
-
|
|
54
|
-
## Components
|
|
55
|
-
|
|
56
|
-
### `<Ikoneme>`
|
|
57
|
-
|
|
58
|
-
The main component. Renders a row of ikons for one message.
|
|
59
|
-
|
|
60
|
-
```jsx
|
|
61
|
-
import { Ikoneme } from 'ikoneme-lib'
|
|
62
|
-
|
|
63
|
-
// Read-only, for a chat/messaging timeline
|
|
64
|
-
<Ikoneme ikons={message.richIcons} mode="view" size={64} />
|
|
65
|
-
|
|
66
|
-
// Editable: adds hover/tap edit + delete buttons on each ikon and opens
|
|
67
|
-
// the full ikon editor. `onChange` receives the updated ikoneme array.
|
|
68
|
-
<Ikoneme
|
|
69
|
-
ikons={message.richIcons}
|
|
70
|
-
mode="edit"
|
|
71
|
-
size={64}
|
|
72
|
-
onChange={(nextIkons) => updateMessage(message.id, nextIkons)}
|
|
73
|
-
/>
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
Props:
|
|
77
|
-
|
|
78
|
-
| Prop | Type | Default | Notes |
|
|
79
|
-
| -------------------- | -------------------------------------- | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
80
|
-
| `ikons` | `Array<Ikon>` | `[]` | The ikoneme payload. |
|
|
81
|
-
| `mode` | `'view' \| 'edit'` | `'view'` | `'edit'` shows per-ikon edit/delete controls and the editor modal. |
|
|
82
|
-
| `size` | `number` | `64` | Pixel size of each ikon. |
|
|
83
|
-
| `gap` | `number` | `6` | Pixel gap between ikons. |
|
|
84
|
-
| `onChange` | `(nextIkons) => void` | — | Called after an edit is saved or an ikon is deleted. Required for edit/delete to do anything — the component is otherwise controlled. |
|
|
85
|
-
| `onIkonClick` | `(ikon, index) => void` | — | Click handler in `view` mode only (e.g. show original source text). Fires independently of `zoom`. |
|
|
86
|
-
| `zoom` | `boolean` | `true` | `true`: clicking any ikon (in either mode) opens a large read-only view of it. `false`: the click is ignored for zoom purposes (`onIkonClick` still fires as usual). |
|
|
87
|
-
| `zoomSize` | `number` | `320` | Pixel size of the ikon inside the zoomed view (clamped to fit the viewport). |
|
|
88
|
-
| `searchRoot` | `(query) => Promise<{id?,name,url}[]>` | IkonDB (public) | Overrides the root-icon search backend used by the editor. Default: `defaultSearchRoot`, which searches the public [IkonDB](https://ikondb.iigap.com/api/docs) icon database (full list fetched once and cached for an hour; matched client-side by name). On select, the editor fetches that icon's fuller media set (`svg`/`thumb`/`preview`) via `GET /api/ikons/{id}`. |
|
|
89
|
-
| `theme` | `object` | — | Override any `--ikoneme-*` CSS custom property (see Theming). |
|
|
90
|
-
| `className`, `style` | | | Passed to the wrapper element. |
|
|
91
|
-
|
|
92
|
-
### `<Ikon>` and `<IkonEditor>`
|
|
93
|
-
|
|
94
|
-
Lower-level building blocks, exported for advanced use:
|
|
95
|
-
|
|
96
|
-
```jsx
|
|
97
|
-
import { Ikon, IkonEditor } from 'ikoneme-lib'
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
- `<Ikon ikon={...} size={64} onClick={...} />` — renders a single ikon. The
|
|
101
|
-
grammatical border
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
- `<
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
- `
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
'--ikoneme-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
##
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
npm install
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
npm
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
1
|
+
# ikoneme-lib
|
|
2
|
+
|
|
3
|
+
React components to render and edit **ikonemes** — ordered sequences of **ikons**
|
|
4
|
+
("rich icons" / "super icons") — using the same rich JSON payload produced by
|
|
5
|
+
the KomunIKON NLP pipeline and consumed by [ikonchat](../ikonchat).
|
|
6
|
+
|
|
7
|
+
This package has no server-side logic of its own: it is a pure rendering/editing
|
|
8
|
+
layer over the ikon JSON payload. The goal is for ikonchat (and any other
|
|
9
|
+
messaging UI) to depend on this library instead of carrying its own copy of the
|
|
10
|
+
rich-icon rendering code.
|
|
11
|
+
|
|
12
|
+
## Concepts
|
|
13
|
+
|
|
14
|
+
- **Ikon** — a single rich icon: a 6x6 grid of zones (`context`, `reference`,
|
|
15
|
+
`role`, `modes`, `root`, `tenses`) plus a grammatical `border`.
|
|
16
|
+
- **Ikoneme** — an ordered list of ikons, e.g. one per word/concept extracted
|
|
17
|
+
from a sentence. This is what you render in a chat bubble.
|
|
18
|
+
|
|
19
|
+
### JSON payload
|
|
20
|
+
|
|
21
|
+
An ikoneme is a plain array of ikon objects:
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
[
|
|
25
|
+
{
|
|
26
|
+
"context": { "name": "Male", "url": "https://.../KomunIKON_Male.svg" },
|
|
27
|
+
"reference": {
|
|
28
|
+
"left": null,
|
|
29
|
+
"right": { "name": "Two", "url": "https://.../KomunIKON_Two.svg" }
|
|
30
|
+
},
|
|
31
|
+
"role": { "name": "agent", "url": "https://.../KomunIKON_agent.svg" },
|
|
32
|
+
"modes": { "name": "Exclam", "url": "https://.../KomunIKON_Exclam.svg" },
|
|
33
|
+
"root": { "name": "Love/Passion", "url": "https://.../ZFcaar88AP.png" },
|
|
34
|
+
"rootName": "Love/Passion",
|
|
35
|
+
"tenses": { "name": "as", "url": "https://.../KomunIKON_Verbal_Tense_as.svg" },
|
|
36
|
+
"border": "verb"
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
This is **exactly** the shape ikonchat stores per message (`message.richIcons`).
|
|
42
|
+
Any extra fields (e.g. a `metadata` block from the NLP pipeline) are preserved
|
|
43
|
+
untouched by `normalizeIkon`/`normalizeIkoneme`.
|
|
44
|
+
|
|
45
|
+
It also maps directly onto the NLP "Rich Icon Output Specification" vocabulary:
|
|
46
|
+
|
|
47
|
+
| This library / ikonchat | NLP spec |
|
|
48
|
+
| ------------------------------------- | ------------- |
|
|
49
|
+
| `context` | `gender` |
|
|
50
|
+
| `modes` | `mode` |
|
|
51
|
+
| `tenses` | `time-tenses` |
|
|
52
|
+
| `reference`, `role`, `root`, `border` | same name |
|
|
53
|
+
|
|
54
|
+
## Components
|
|
55
|
+
|
|
56
|
+
### `<Ikoneme>`
|
|
57
|
+
|
|
58
|
+
The main component. Renders a row of ikons for one message.
|
|
59
|
+
|
|
60
|
+
```jsx
|
|
61
|
+
import { Ikoneme } from 'ikoneme-lib'
|
|
62
|
+
|
|
63
|
+
// Read-only, for a chat/messaging timeline
|
|
64
|
+
<Ikoneme ikons={message.richIcons} mode="view" size={64} />
|
|
65
|
+
|
|
66
|
+
// Editable: adds hover/tap edit + delete buttons on each ikon and opens
|
|
67
|
+
// the full ikon editor. `onChange` receives the updated ikoneme array.
|
|
68
|
+
<Ikoneme
|
|
69
|
+
ikons={message.richIcons}
|
|
70
|
+
mode="edit"
|
|
71
|
+
size={64}
|
|
72
|
+
onChange={(nextIkons) => updateMessage(message.id, nextIkons)}
|
|
73
|
+
/>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Props:
|
|
77
|
+
|
|
78
|
+
| Prop | Type | Default | Notes |
|
|
79
|
+
| -------------------- | -------------------------------------- | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
80
|
+
| `ikons` | `Array<Ikon>` | `[]` | The ikoneme payload. |
|
|
81
|
+
| `mode` | `'view' \| 'edit'` | `'view'` | `'edit'` shows per-ikon edit/delete controls and the editor modal. |
|
|
82
|
+
| `size` | `number` | `64` | Pixel size of each ikon. |
|
|
83
|
+
| `gap` | `number` | `6` | Pixel gap between ikons. |
|
|
84
|
+
| `onChange` | `(nextIkons) => void` | — | Called after an edit is saved or an ikon is deleted. Required for edit/delete to do anything — the component is otherwise controlled. |
|
|
85
|
+
| `onIkonClick` | `(ikon, index) => void` | — | Click handler in `view` mode only (e.g. show original source text). Fires independently of `zoom`. |
|
|
86
|
+
| `zoom` | `boolean` | `true` | `true`: clicking any ikon (in either mode) opens a large read-only view of it. `false`: the click is ignored for zoom purposes (`onIkonClick` still fires as usual). |
|
|
87
|
+
| `zoomSize` | `number` | `320` | Pixel size of the ikon inside the zoomed view (clamped to fit the viewport). |
|
|
88
|
+
| `searchRoot` | `(query) => Promise<{id?,name,url}[]>` | IkonDB (public) | Overrides the root-icon search backend used by the editor. Default: `defaultSearchRoot`, which searches the public [IkonDB](https://ikondb.iigap.com/api/docs) icon database (full list fetched once and cached for an hour; matched client-side by name). On select, the editor fetches that icon's fuller media set (`svg`/`thumb`/`preview`) via `GET /api/ikons/{id}`. |
|
|
89
|
+
| `theme` | `object` | — | Override any `--ikoneme-*` CSS custom property (see Theming). |
|
|
90
|
+
| `className`, `style` | | | Passed to the wrapper element. |
|
|
91
|
+
|
|
92
|
+
### `<Ikon>` and `<IkonEditor>`
|
|
93
|
+
|
|
94
|
+
Lower-level building blocks, exported for advanced use:
|
|
95
|
+
|
|
96
|
+
```jsx
|
|
97
|
+
import { Ikon, IkonEditor } from 'ikoneme-lib'
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
- `<Ikon ikon={...} size={64} onClick={...} />` — renders a single ikon. The
|
|
101
|
+
grammatical border is the official KomunIKON artwork (`src/borders`: one
|
|
102
|
+
colour and dash pattern per category, single frame for singular, double
|
|
103
|
+
frame for plural), scaled with `size` so it stays legible both tiny in a chat
|
|
104
|
+
bubble and large in a zoomed view. The ikon stays square either way.
|
|
105
|
+
- `<IkonEditor ikon={...} onSave={...} onClose={...} searchRoot={...} />` —
|
|
106
|
+
the full-screen zone editor for one ikon.
|
|
107
|
+
- `<IkonZoomView ikon={...} size={320} onClose={...} />` — the read-only
|
|
108
|
+
"lightbox" view `<Ikoneme zoom>` opens on click; exported in case you want
|
|
109
|
+
to trigger it yourself.
|
|
110
|
+
|
|
111
|
+
### Schema utilities
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
import {
|
|
115
|
+
ZONE_CONFIG,
|
|
116
|
+
BORDER_CONFIG,
|
|
117
|
+
getBorderImageStyle,
|
|
118
|
+
createDefaultIkon,
|
|
119
|
+
normalizeIkon,
|
|
120
|
+
normalizeIkoneme,
|
|
121
|
+
generateIkonemeFromText
|
|
122
|
+
} from 'ikoneme-lib'
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
- `normalizeIkoneme(ikons)` — upgrades any legacy/URL-only stored payloads to
|
|
126
|
+
the `{ name, url }` shape. Run this on data loaded from storage/an API
|
|
127
|
+
before rendering.
|
|
128
|
+
- `generateIkonemeFromText(text)` — deterministic placeholder generator
|
|
129
|
+
(hash-based), useful for demos/tests until real NLP output is wired in.
|
|
130
|
+
- `BORDER_CONFIG` — the 12 border types (`{ id, label, color, plural, image }`);
|
|
131
|
+
`image` is the artwork as a data URI, `color` its main colour.
|
|
132
|
+
- `getBorderImageStyle(border, size)` — inline style that draws a border's
|
|
133
|
+
artwork around a square box of `size` px (what `<Ikon>` uses).
|
|
134
|
+
|
|
135
|
+
### IkonDB helpers
|
|
136
|
+
|
|
137
|
+
The public [IkonDB](https://ikondb.iigap.com/api/docs) client backing the
|
|
138
|
+
default root search, exported for reuse:
|
|
139
|
+
|
|
140
|
+
```js
|
|
141
|
+
import { searchIkons, getIkonDetails, getIkonList, IKONDB_BASE_URL } from 'ikoneme-lib'
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
- `searchIkons(query, { limit })` — `{ id, name, url }[]`, matched by name
|
|
145
|
+
against the full list (fetched once, cached for an hour).
|
|
146
|
+
- `getIkonDetails(id)` — `{ id, name, url, origin, preview, thumb, svg }` for one
|
|
147
|
+
icon (cached per id), or `null` if it does not exist.
|
|
148
|
+
- `getIkonList()` — the whole cached list.
|
|
149
|
+
- `clearIkonDbCache()` — drops the in-memory caches.
|
|
150
|
+
|
|
151
|
+
Icons whose IkonDB record has no image are omitted from search results.
|
|
152
|
+
|
|
153
|
+
## Theming
|
|
154
|
+
|
|
155
|
+
Components read colors from `--ikoneme-*` CSS custom properties and ship with
|
|
156
|
+
sensible dark-mode defaults, so nothing else is required to use them. To match
|
|
157
|
+
your app's palette, pass a `theme` override:
|
|
158
|
+
|
|
159
|
+
```jsx
|
|
160
|
+
<Ikoneme
|
|
161
|
+
ikons={ikons}
|
|
162
|
+
theme={{
|
|
163
|
+
'--ikoneme-primary': '#00a884',
|
|
164
|
+
'--ikoneme-background': '#0c0e12',
|
|
165
|
+
'--ikoneme-panel-bg': '#181b20',
|
|
166
|
+
'--ikoneme-surface': '#080a0e',
|
|
167
|
+
'--ikoneme-border': '#2a2e36',
|
|
168
|
+
'--ikoneme-text-primary': '#e9edef',
|
|
169
|
+
'--ikoneme-text-secondary': '#8696a0',
|
|
170
|
+
'--ikoneme-hover': '#2a2e36'
|
|
171
|
+
}}
|
|
172
|
+
/>
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Building
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
npm install
|
|
179
|
+
npm run build # outputs dist/ikoneme-lib.js (ESM) and dist/ikoneme-lib.cjs (CJS)
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Using this library in another project (local, no registry)
|
|
183
|
+
|
|
184
|
+
This package is not published to npm/a registry. Pick one of the following to
|
|
185
|
+
consume it locally.
|
|
186
|
+
|
|
187
|
+
### Option A — `file:` dependency (recommended)
|
|
188
|
+
|
|
189
|
+
1. Build a tarball from this repo:
|
|
190
|
+
```bash
|
|
191
|
+
cd ikoneme-lib
|
|
192
|
+
npm install
|
|
193
|
+
npm run build
|
|
194
|
+
npm pack # produces ikoneme-lib-<version>.tgz
|
|
195
|
+
```
|
|
196
|
+
2. In the consuming project (e.g. ikonchat), add it as a dependency pointing
|
|
197
|
+
at the tarball (adjust the relative path to wherever you placed it):
|
|
198
|
+
```bash
|
|
199
|
+
npm install ../ikoneme-lib/ikoneme-lib-0.1.0.tgz
|
|
200
|
+
```
|
|
201
|
+
This writes a `"ikoneme-lib": "file:../ikoneme-lib/ikoneme-lib-0.1.0.tgz"`
|
|
202
|
+
entry to the consumer's `package.json` and copies/extracts the packed
|
|
203
|
+
`dist/` into `node_modules` — no symlink, so it behaves like a real
|
|
204
|
+
registry install (safe for CI/Docker builds too, as long as the tarball
|
|
205
|
+
path is available at install time).
|
|
206
|
+
3. Re-run steps 1–2 whenever you change the library and want the consumer to
|
|
207
|
+
pick up the new build.
|
|
208
|
+
|
|
209
|
+
### Option B — `npm link` (fastest for active local development)
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
cd ikoneme-lib
|
|
213
|
+
npm install
|
|
214
|
+
npm run build
|
|
215
|
+
npm link
|
|
216
|
+
|
|
217
|
+
cd ../ikonchat
|
|
218
|
+
npm link ikoneme-lib
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
This symlinks `ikoneme-lib` into the consumer's `node_modules`, so rebuilding
|
|
222
|
+
the library (`npm run build`) is immediately visible to the consumer without
|
|
223
|
+
reinstalling. Undo with `npm unlink ikoneme-lib` in the consumer and
|
|
224
|
+
`npm unlink` in this repo.
|
|
225
|
+
|
|
226
|
+
### Option C — local npm registry (Verdaccio)
|
|
227
|
+
|
|
228
|
+
For multi-developer/team setups where `file:`/`link:` paths are inconvenient,
|
|
229
|
+
run a local registry and publish there instead of to the public npm registry:
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
npx verdaccio # starts a registry on http://localhost:4873
|
|
233
|
+
npm publish --registry http://localhost:4873
|
|
234
|
+
# in the consumer:
|
|
235
|
+
npm install ikoneme-lib --registry http://localhost:4873
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Example app
|
|
239
|
+
|
|
240
|
+
`example/` is a minimal Vite + React app that installs this library via the
|
|
241
|
+
`file:` tarball approach (Option A) and renders an ikoneme in both `view` and
|
|
242
|
+
`edit` mode. Use it to sanity-check changes before wiring the library into
|
|
243
|
+
ikonchat:
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
npm run build && npm pack --pack-destination ./example
|
|
247
|
+
cd example
|
|
248
|
+
npm install
|
|
249
|
+
npm run dev
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## Next step
|
|
253
|
+
|
|
254
|
+
`ikonchat` currently has its own copies of this rendering/editing logic
|
|
255
|
+
(`app/components/RichIcon.jsx`, `RichIconEditor.jsx`,
|
|
256
|
+
`app/utils/richIconMapping.js`). The follow-up work is to delete those and
|
|
257
|
+
replace their usages (`ChatWindow.jsx`, etc.) with `<Ikoneme>` from this
|
|
258
|
+
package, keeping ikonchat's own responsibility limited to chat/business logic
|
|
259
|
+
(messages, contacts, backend sync) rather than ikon rendering.
|
package/dist/ikonSchema.d.ts
CHANGED
|
@@ -3,6 +3,28 @@ export function getBorderConfig(borderId: any): {
|
|
|
3
3
|
label: string;
|
|
4
4
|
color: string;
|
|
5
5
|
plural: boolean;
|
|
6
|
+
image: any;
|
|
7
|
+
};
|
|
8
|
+
export function getBorderImageStyle(border: any, size: any): {
|
|
9
|
+
borderStyle?: undefined;
|
|
10
|
+
borderColor?: undefined;
|
|
11
|
+
borderWidth?: undefined;
|
|
12
|
+
borderImageSource?: undefined;
|
|
13
|
+
borderImageSlice?: undefined;
|
|
14
|
+
borderImageWidth?: undefined;
|
|
15
|
+
borderImageRepeat?: undefined;
|
|
16
|
+
borderRadius?: undefined;
|
|
17
|
+
backgroundClip?: undefined;
|
|
18
|
+
} | {
|
|
19
|
+
borderStyle: string;
|
|
20
|
+
borderColor: string;
|
|
21
|
+
borderWidth: string;
|
|
22
|
+
borderImageSource: string;
|
|
23
|
+
borderImageSlice: string;
|
|
24
|
+
borderImageWidth: string;
|
|
25
|
+
borderImageRepeat: string;
|
|
26
|
+
borderRadius: number;
|
|
27
|
+
backgroundClip: string;
|
|
6
28
|
};
|
|
7
29
|
export function getIconConfig(zone: any, url: any): any;
|
|
8
30
|
export function getIconUrlByIndex(zone: any, index: any): any;
|
|
@@ -38,34 +60,7 @@ export function createDefaultIkon(): {
|
|
|
38
60
|
};
|
|
39
61
|
export function normalizeIkon(icon: any): any;
|
|
40
62
|
export function normalizeIkoneme(ikons: any): any;
|
|
41
|
-
export function generateIkonemeFromText(text: any):
|
|
42
|
-
context: {
|
|
43
|
-
name: any;
|
|
44
|
-
url: any;
|
|
45
|
-
};
|
|
46
|
-
reference: {
|
|
47
|
-
left: any;
|
|
48
|
-
right: any;
|
|
49
|
-
};
|
|
50
|
-
role: {
|
|
51
|
-
name: any;
|
|
52
|
-
url: any;
|
|
53
|
-
};
|
|
54
|
-
modes: {
|
|
55
|
-
name: any;
|
|
56
|
-
url: any;
|
|
57
|
-
};
|
|
58
|
-
root: {
|
|
59
|
-
name: any;
|
|
60
|
-
url: any;
|
|
61
|
-
};
|
|
62
|
-
rootName: any;
|
|
63
|
-
tenses: {
|
|
64
|
-
name: any;
|
|
65
|
-
url: any;
|
|
66
|
-
};
|
|
67
|
-
border: any;
|
|
68
|
-
}[];
|
|
63
|
+
export function generateIkonemeFromText(text: any): Promise<any[]>;
|
|
69
64
|
export namespace ZONE_CONFIG {
|
|
70
65
|
let context: {
|
|
71
66
|
tooltip: string;
|
|
@@ -97,5 +92,6 @@ export const BORDER_CONFIG: {
|
|
|
97
92
|
label: string;
|
|
98
93
|
color: string;
|
|
99
94
|
plural: boolean;
|
|
95
|
+
image: any;
|
|
100
96
|
}[];
|
|
101
97
|
export const BORDER_IDS: string[];
|