@klex/mascot 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 stagewise GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,393 @@
1
+ Attribution 4.0 International
2
+
3
+ =======================================================================
4
+
5
+ Creative Commons Corporation ("Creative Commons") is not a law firm and
6
+ does not provide legal services or legal advice. Distribution of
7
+ Creative Commons public licenses does not create a lawyer-client or
8
+ other relationship. Creative Commons makes its licenses and related
9
+ information available on an "as-is" basis. Creative Commons gives no
10
+ warranties regarding its licenses, any material licensed under their
11
+ terms and conditions, or any related information. Creative Commons
12
+ disclaims all liability for damages resulting from their use to the
13
+ fullest extent possible.
14
+
15
+ Using Creative Commons Public Licenses
16
+
17
+ Creative Commons public licenses provide a standard set of terms and
18
+ conditions that creators and other rights holders may use to share
19
+ original works of authorship and other material subject to copyright
20
+ and certain other rights specified in the public license below. The
21
+ following considerations are for informational purposes only, are not
22
+ exhaustive, and do not form part of our licenses.
23
+
24
+ Considerations for licensors: Our public licenses are
25
+ intended for use by those authorized to give the public
26
+ permission to use material in ways otherwise restricted by
27
+ copyright and certain other rights. Our licenses are
28
+ irrevocable. Licensors should read and understand the terms
29
+ and conditions of the license they choose before applying it.
30
+ Licensors should also secure all rights necessary before
31
+ applying our licenses so that the public can reuse the
32
+ material as expected. Licensors should clearly mark any
33
+ material not subject to the license. This includes other CC-
34
+ licensed material, or material used under an exception or
35
+ limitation to copyright. More considerations for licensors:
36
+ wiki.creativecommons.org/Considerations_for_licensors
37
+
38
+ Considerations for the public: By using one of our public
39
+ licenses, a licensor grants the public permission to use the
40
+ licensed material under specified terms and conditions. If
41
+ the licensor's permission is not necessary for any reason--for
42
+ example, because of any applicable exception or limitation to
43
+ copyright--then that use is not regulated by the license. Our
44
+ licenses grant only permissions under copyright and certain
45
+ other rights that a licensor has authority to grant. Use of
46
+ the licensed material may still be restricted for other
47
+ reasons, including because others have copyright or other
48
+ rights in the material. A licensor may make special requests,
49
+ such as asking that all changes be marked or described.
50
+ Although not required by our licenses, you are encouraged to
51
+ respect those requests where reasonable. More_considerations
52
+ for the public:
53
+ wiki.creativecommons.org/Considerations_for_licensees
54
+
55
+ =======================================================================
56
+
57
+ Creative Commons Attribution 4.0 International Public License
58
+
59
+ By exercising the Licensed Rights (defined below), You accept and agree
60
+ to be bound by the terms and conditions of this Creative Commons
61
+ Attribution 4.0 International Public License ("Public License"). To the
62
+ extent this Public License may be interpreted as a contract, You are
63
+ granted the Licensed Rights in consideration of Your acceptance of
64
+ these terms and conditions, and the Licensor grants You such rights in
65
+ consideration of benefits the Licensor receives from making the
66
+ Licensed Material available under these terms and conditions.
67
+
68
+
69
+ Section 1 -- Definitions.
70
+
71
+ a. Adapted Material means material subject to Copyright and Similar
72
+ Rights that is derived from or based upon the Licensed Material
73
+ and in which the Licensed Material is translated, altered,
74
+ arranged, transformed, or otherwise modified in a manner requiring
75
+ permission under the Copyright and Similar Rights held by the
76
+ Licensor. For purposes of this Public License, where the Licensed
77
+ Material is a musical work, performance, or sound recording,
78
+ Adapted Material is always produced where the Licensed Material is
79
+ synched in timed relation with a moving image.
80
+
81
+ b. Adapter's License means the license You apply to Your Copyright
82
+ and Similar Rights in Your contributions to Adapted Material in
83
+ accordance with the terms and conditions of this Public License.
84
+
85
+ c. Copyright and Similar Rights means copyright and/or similar rights
86
+ closely related to copyright including, without limitation,
87
+ performance, broadcast, sound recording, and Sui Generis Database
88
+ Rights, without regard to how the rights are labeled or
89
+ categorized. For purposes of this Public License, the rights
90
+ specified in Section 2(b)(1)-(2) are not Copyright and Similar
91
+ Rights.
92
+
93
+ d. Effective Technological Measures means those measures that, in the
94
+ absence of proper authority, may not be circumvented under laws
95
+ fulfilling obligations under Article 11 of the WIPO Copyright
96
+ Treaty adopted on December 20, 1996, and/or similar international
97
+ agreements.
98
+
99
+ e. Exceptions and Limitations means fair use, fair dealing, and/or
100
+ any other exception or limitation to Copyright and Similar Rights
101
+ that applies to Your use of the Licensed Material.
102
+
103
+ f. Licensed Material means the artistic or literary work, database,
104
+ or other material to which the Licensor applied this Public
105
+ License.
106
+
107
+ g. Licensed Rights means the rights granted to You subject to the
108
+ terms and conditions of this Public License, which are limited to
109
+ all Copyright and Similar Rights that apply to Your use of the
110
+ Licensed Material and that the Licensor has authority to license.
111
+
112
+ h. Licensor means the individual(s) or entity(ies) granting rights
113
+ under this Public License.
114
+
115
+ i. Share means to provide material to the public by any means or
116
+ process that requires permission under the Licensed Rights, such
117
+ as reproduction, public display, public performance, distribution,
118
+ dissemination, communication, or importation, and to make material
119
+ available to the public including in ways that members of the
120
+ public may access the material from a place and at a time
121
+ individually chosen by them.
122
+
123
+ j. Sui Generis Database Rights means rights other than copyright
124
+ resulting from Directive 96/9/EC of the European Parliament and of
125
+ the Council of 11 March 1996 on the legal protection of databases,
126
+ as amended and/or succeeded, as well as other essentially
127
+ equivalent rights anywhere in the world.
128
+
129
+ k. You means the individual or entity exercising the Licensed Rights
130
+ under this Public License. Your has a corresponding meaning.
131
+
132
+
133
+ Section 2 -- Scope.
134
+
135
+ a. License grant.
136
+
137
+ 1. Subject to the terms and conditions of this Public License,
138
+ the Licensor hereby grants You a worldwide, royalty-free,
139
+ non-sublicensable, non-exclusive, irrevocable license to
140
+ exercise the Licensed Rights in the Licensed Material to:
141
+
142
+ a. reproduce and Share the Licensed Material, in whole or
143
+ in part; and
144
+
145
+ b. produce, reproduce, and Share Adapted Material.
146
+
147
+ 2. Exceptions and Limitations. For the avoidance of doubt, where
148
+ Exceptions and Limitations apply to Your use, this Public
149
+ License does not apply, and You do not need to comply with
150
+ its terms and conditions.
151
+
152
+ 3. Term. The term of this Public License is specified in Section
153
+ 6(a).
154
+
155
+ 4. Media and formats; technical modifications allowed. The
156
+ Licensor authorizes You to exercise the Licensed Rights in
157
+ all media and formats whether now known or hereafter created,
158
+ and to make technical modifications necessary to do so. The
159
+ Licensor waives and/or agrees not to assert any right or
160
+ authority to forbid You from making technical modifications
161
+ necessary to exercise the Licensed Rights, including
162
+ technical modifications necessary to circumvent Effective
163
+ Technological Measures. For purposes of this Public License,
164
+ simply making modifications authorized by this Section 2(a)
165
+ (4) never produces Adapted Material.
166
+
167
+ 5. Downstream recipients.
168
+
169
+ a. Offer from the Licensor -- Licensed Material. Every
170
+ recipient of the Licensed Material automatically
171
+ receives an offer from the Licensor to exercise the
172
+ Licensed Rights under the terms and conditions of this
173
+ Public License.
174
+
175
+ b. No downstream restrictions. You may not offer or impose
176
+ any additional or different terms or conditions on, or
177
+ apply any Effective Technological Measures to, the
178
+ Licensed Material if doing so restricts exercise of the
179
+ Licensed Rights by any recipient of the Licensed
180
+ Material.
181
+
182
+ 6. No endorsement. Nothing in this Public License constitutes or
183
+ may be construed as permission to assert or imply that You
184
+ are, or that Your use of the Licensed Material is, connected
185
+ with, or sponsored, endorsed, or granted official status by,
186
+ the Licensor or others designated to receive attribution as
187
+ provided in Section 3(a)(1)(A)(i).
188
+
189
+ b. Other rights.
190
+
191
+ 1. Moral rights, such as the right of integrity, are not
192
+ licensed under this Public License, nor are publicity,
193
+ privacy, and/or other similar personality rights; however, to
194
+ the extent possible, the Licensor waives and/or agrees not to
195
+ assert any such rights held by the Licensor to the limited
196
+ extent necessary to allow You to exercise the Licensed
197
+ Rights, but not otherwise.
198
+
199
+ 2. Patent and trademark rights are not licensed under this
200
+ Public License.
201
+
202
+ 3. To the extent possible, the Licensor waives any right to
203
+ collect royalties from You for the exercise of the Licensed
204
+ Rights, whether directly or through a collecting society
205
+ under any voluntary or waivable statutory or compulsory
206
+ licensing scheme. In all other cases the Licensor expressly
207
+ reserves any right to collect such royalties.
208
+
209
+
210
+ Section 3 -- License Conditions.
211
+
212
+ Your exercise of the Licensed Rights is expressly made subject to the
213
+ following conditions.
214
+
215
+ a. Attribution.
216
+
217
+ 1. If You Share the Licensed Material (including in modified
218
+ form), You must:
219
+
220
+ a. retain the following if it is supplied by the Licensor
221
+ with the Licensed Material:
222
+
223
+ i. identification of the creator(s) of the Licensed
224
+ Material and any others designated to receive
225
+ attribution, in any reasonable manner requested by
226
+ the Licensor (including by pseudonym if
227
+ designated);
228
+
229
+ ii. a copyright notice;
230
+
231
+ iii. a notice that refers to this Public License;
232
+
233
+ iv. a notice that refers to the disclaimer of
234
+ warranties;
235
+
236
+ v. a URI or hyperlink to the Licensed Material to the
237
+ extent reasonably practicable;
238
+
239
+ b. indicate if You modified the Licensed Material and
240
+ retain an indication of any previous modifications; and
241
+
242
+ c. indicate the Licensed Material is licensed under this
243
+ Public License, and include the text of, or the URI or
244
+ hyperlink to, this Public License.
245
+
246
+ 2. You may satisfy the conditions in Section 3(a)(1) in any
247
+ reasonable manner based on the medium, means, and context in
248
+ which You Share the Licensed Material. For example, it may be
249
+ reasonable to satisfy the conditions by providing a URI or
250
+ hyperlink to a resource that includes the required
251
+ information.
252
+
253
+ 3. If requested by the Licensor, You must remove any of the
254
+ information required by Section 3(a)(1)(A) to the extent
255
+ reasonably practicable.
256
+
257
+ 4. If You Share Adapted Material You produce, the Adapter's
258
+ License You apply must not prevent recipients of the Adapted
259
+ Material from complying with this Public License.
260
+
261
+
262
+ Section 4 -- Sui Generis Database Rights.
263
+
264
+ Where the Licensed Rights include Sui Generis Database Rights that
265
+ apply to Your use of the Licensed Material:
266
+
267
+ a. for the avoidance of doubt, Section 2(a)(1) grants You the right
268
+ to extract, reuse, reproduce, and Share all or a substantial
269
+ portion of the contents of the database;
270
+
271
+ b. if You include all or a substantial portion of the database
272
+ contents in a database in which You have Sui Generis Database
273
+ Rights, then the database in which You have Sui Generis Database
274
+ Rights (but not its individual contents) is Adapted Material; and
275
+
276
+ c. You must comply with the conditions in Section 3(a) if You Share
277
+ all or a substantial portion of the contents of the database.
278
+
279
+ For the avoidance of doubt, this Section 4 supplements and does not
280
+ replace Your obligations under this Public License where the Licensed
281
+ Rights include other Copyright and Similar Rights.
282
+
283
+
284
+ Section 5 -- Disclaimer of Warranties and Limitation of Liability.
285
+
286
+ a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
287
+ EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
288
+ AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
289
+ ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
290
+ IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
291
+ WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
292
+ PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
293
+ ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
294
+ KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
295
+ ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
296
+
297
+ b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
298
+ TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
299
+ NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
300
+ INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
301
+ COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
302
+ USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
303
+ ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
304
+ DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
305
+ IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
306
+
307
+ c. The disclaimer of warranties and limitation of liability provided
308
+ above shall be interpreted in a manner that, to the extent
309
+ possible, most closely approximates an absolute disclaimer and
310
+ waiver of all liability.
311
+
312
+
313
+ Section 6 -- Term and Termination.
314
+
315
+ a. This Public License applies for the term of the Copyright and
316
+ Similar Rights licensed here. However, if You fail to comply with
317
+ this Public License, then Your rights under this Public License
318
+ terminate automatically.
319
+
320
+ b. Where Your right to use the Licensed Material has terminated under
321
+ Section 6(a), it reinstates:
322
+
323
+ 1. automatically as of the date the violation is cured, provided
324
+ it is cured within 30 days of Your discovery of the
325
+ violation; or
326
+
327
+ 2. upon express reinstatement by the Licensor.
328
+
329
+ For the avoidance of doubt, this Section 6(b) does not affect any
330
+ right the Licensor may have to seek remedies for Your violations
331
+ of this Public License.
332
+
333
+ c. For the avoidance of doubt, the Licensor may also offer the
334
+ Licensed Material under separate terms or conditions or stop
335
+ distributing the Licensed Material at any time; however, doing so
336
+ will not terminate this Public License.
337
+
338
+ d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
339
+ License.
340
+
341
+
342
+ Section 7 -- Other Terms and Conditions.
343
+
344
+ a. The Licensor shall not be bound by any additional or different
345
+ terms or conditions communicated by You unless expressly agreed.
346
+
347
+ b. Any arrangements, understandings, or agreements regarding the
348
+ Licensed Material not stated herein are separate from and
349
+ independent of the terms and conditions of this Public License.
350
+
351
+
352
+ Section 8 -- Interpretation.
353
+
354
+ a. For the avoidance of doubt, this Public License does not, and
355
+ shall not be interpreted to, reduce, limit, restrict, or impose
356
+ conditions on any use of the Licensed Material that could lawfully
357
+ be made without permission under this Public License.
358
+
359
+ b. To the extent possible, if any provision of this Public License is
360
+ deemed unenforceable, it shall be automatically reformed to the
361
+ minimum extent necessary to make it enforceable. If the provision
362
+ cannot be reformed, it shall be severed from this Public License
363
+ without affecting the enforceability of the remaining terms and
364
+ conditions.
365
+
366
+ c. No term or condition of this Public License will be waived and no
367
+ failure to comply consented to unless expressly agreed to by the
368
+ Licensor.
369
+
370
+ d. Nothing in this Public License constitutes or may be interpreted
371
+ as a limitation upon, or waiver of, any privileges and immunities
372
+ that apply to the Licensor or You, including from the legal
373
+ processes of any jurisdiction or authority.
374
+
375
+
376
+ =======================================================================
377
+
378
+ Creative Commons is not a party to its public licenses.
379
+ Notwithstanding, Creative Commons may elect to apply one of its public
380
+ licenses to material it publishes and in those instances will be
381
+ considered the "Licensor." Except for the limited purpose of indicating
382
+ that material is shared under a Creative Commons public license or as
383
+ otherwise permitted by the Creative Commons policies published at
384
+ creativecommons.org/policies, Creative Commons does not authorize the
385
+ use of the trademark "Creative Commons" or any other trademark or logo
386
+ of Creative Commons without its prior written consent including,
387
+ without limitation, in connection with any unauthorized modifications
388
+ to any of its public licenses or any other arrangements,
389
+ understandings, or agreements concerning use of licensed material. For
390
+ the avoidance of doubt, this paragraph does not form part of the public
391
+ licenses.
392
+
393
+ Creative Commons may be contacted at creativecommons.org.
package/README.md CHANGED
@@ -1,3 +1,161 @@
1
- # Temporary Holding Version
1
+ # @klex/mascot
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The animated Klex mascot: a React component, its GSAP motion engine, body presets, and dependency-free SVG helpers. Klex Cloud and the Klex website render the same character from this package.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm add @klex/mascot @stagewise/ui gsap motion react react-dom
9
+ ```
10
+
11
+ `react` and `react-dom` (19.2+), `motion`, `gsap`, and `@stagewise/ui` are peer dependencies. The package ships TypeScript and CSS sources, so the app's bundler (Vite or similar) compiles them. Component CSS is imported by the modules themselves.
12
+
13
+ The component uses Tailwind utilities and `@stagewise/ui` theme tokens. Import the `@stagewise/ui` stylesheet and let Tailwind scan the package source. `@source` takes a path relative to the CSS file:
14
+
15
+ ```css
16
+ @import "tailwindcss";
17
+ @import "@stagewise/ui/style.css";
18
+
19
+ @source "../node_modules/@klex/mascot/src";
20
+ ```
21
+
22
+ ## Public API
23
+
24
+ | Export | Purpose |
25
+ | --- | --- |
26
+ | `Klex`, `KlexHandle`, `KlexProps`, `EmoteId` | The animated character and its ref commands. |
27
+ | `BODY_SHAPES`, `BodyShape`, `PALETTES`, `KlexPalette` | Built-in silhouettes and colors. |
28
+ | `DEFAULT_GLIDE`, `MOVEMENT_STYLES`, `MovementMode` | Movement settings for `crawl`, `fly`, and `hop`. |
29
+ | `ACTIVITIES`, `KlexActivity` | Resting activities: `idle`, `sleeping`, `working`, `calling`. |
30
+ | `EMOTES`, `EMOTE_CATEGORIES`, `Emote`, `emotePose`, `REST_EMOTE` | Emote catalog and poses. |
31
+ | `EXPRESSIONS`, `Expression`, `KlexEyes` | Facial expressions and the eye renderer. |
32
+ | `EXTRAS`, `Extra`, `KlexExtras` | Extras such as wave, phone, sparkles, and sleep. |
33
+ | `KlexGroundGrid` | Perspective floor grid for scenes. |
34
+ | `klexBody`, `KlexPosition`, `fitGaze`, `gazeRoom`, `waveAnchor`, `phoneAnchor` | Geometry helpers for editors and static previews. |
35
+ | `observeVisibility` | Shared `IntersectionObserver` that Klex uses to pause offscreen characters. |
36
+ | `popTransition` | The spring used by bubbles and extras. |
37
+ | `roundedPath`, `getKlexEyeColor`, `klexSvg` | Static SVG output. Also available from `@klex/mascot/svg` without React, GSAP, or a DOM. |
38
+
39
+ ## Usage
40
+
41
+ Templates and saved drawings both supply a `BodyShape` with an outline and a face anchor in the shared 160 × 140 coordinate frame.
42
+
43
+ ```tsx
44
+ import { useRef } from 'react';
45
+ import { BODY_SHAPES, Klex, type KlexHandle } from '@klex/mascot';
46
+
47
+ function Mascot() {
48
+ const klex = useRef<KlexHandle>(null);
49
+
50
+ return (
51
+ <>
52
+ <Klex
53
+ ref={klex}
54
+ shape={BODY_SHAPES[0]} // Or a saved drawing.shape
55
+ color="#ffbd91"
56
+ size={80}
57
+ width="100%"
58
+ initialExpression="neutral"
59
+ />
60
+ <button onClick={() => klex.current?.moveTo('right', 'crawl')}>
61
+ Come over
62
+ </button>
63
+ <button onClick={() => klex.current?.emote('jump')}>Jump</button>
64
+ <button onClick={() => klex.current?.setExpression('happy')}>Happy</button>
65
+ <button onClick={() => klex.current?.setExtra('sparkles')}>Sparkles</button>
66
+ </>
67
+ );
68
+ }
69
+ ```
70
+
71
+ ## Props and sizing
72
+
73
+ `shape`, `color` and `size` can change without restarting an animation. The eye color is always derived from the body color to maintain contrast. The component defaults to the original white Klex at 160 pixels.
74
+
75
+ The component reserves `size` pixels of height. `width` sets the whole movement area and should be at least `size`. Without `width`, the component is a square avatar with no sideways travel:
76
+
77
+ ```tsx
78
+ <Klex ref={avatar} shape={savedShape} color="#d9c4ff" size={40} />
79
+ ```
80
+
81
+ For a 2D area, place the track along its bottom edge. Give `moveTo` an `x` value from -50 at the left edge to 50 at the right edge, plus a `y` pixel offset from the ground line. Negative `y` moves the character higher in the area. `initialPosition` places it before the first animation. The body keeps its crawl, hop, or fly motion while moving diagonally.
82
+
83
+ When several characters share an area, use `onDepthChange` to set each track wrapper's `z-index`. Higher `y` values are closer to the viewer. The callback reports the ground position, so jumping and flying do not change which character stands in front.
84
+
85
+ ```tsx
86
+ <Klex ref={avatar} width="100%" initialPosition={{ x: -30, y: -40 }} />
87
+ avatar.current?.moveTo({ x: 20, y: -100 }, 'crawl');
88
+ ```
89
+
90
+ Use `snapTo({ x, y })` to restore a scene position immediately. It cancels the current trip without firing arrival or completion callbacks. `face('left' | 'right')` sets the direction without moving. For responsive layouts, `shiftBy({ x, y })` offsets both the current position and destination while preserving travel, airborne hops, and callback timing. Its `x` offset uses track percentage points; `y` uses pixels.
91
+
92
+ Custom outlines can start at any contour point. Turning aligns the mirrored contour before blending it with the original, keeping custom silhouettes from collapsing during a direction change.
93
+
94
+ `name` adds a badge above the character and supplies its accessible name. An optional `role` appears on a second line, for example `<Klex name="Kristine" role="Product Manager" />`. Omit `name` to hide the badge.
95
+
96
+ Emotes, including jumps and shaking, scale down with the avatar. The ground is the bottom edge of the component. Overflow stays visible for jumping and extras; a parent can clip it with `overflow-hidden` when a strict avatar crop is needed.
97
+
98
+ `idle` defaults to `true`. Resting characters breathe gently, sway their heads, blink and occasionally glance around without changing their expression or position. Every instance has its own breathing pace and independently randomized blink and glance pauses. Each glance also varies in direction and duration. The idle pose fades out for travel and emotes, then returns automatically. Flying characters keep their hover. Use `idle={false}` for static avatars or long lists that do not need continuous animation.
99
+
100
+ `activity` selects a persistent animation and defaults to `'idle'`. `'sleeping'` closes the eyes, lowers and tilts the head, and breathes slowly. `'calling'` holds a bundled Twemoji 📞 SVG against the head, mirrored toward the face and held by a small hand in the body color. A fixed graphic avoids platform-dependent emoji font shapes and baselines. The earpiece follows the deformed silhouette slightly above the eyes, including custom shapes. Each avatar alternates attentive listening, irregular conversational emphasis, and a friendly double nod, with natural blinks and pauses. These are ambient gestures, not speech detection; reduced motion keeps a static listening pose. No laptop is shown. `'working'` places a laptop in front of the character, with its back facing the viewer. Each avatar independently alternates between reading across successive lines, typing in irregular bursts, and looking up to think with a question mark overhead. Phase order, durations, and pauses are randomized anew throughout the animation. Travel and emotes take precedence, then the latest activity resumes. `idle={false}` disables only the default idle animation; an explicit sleeping, working or calling activity still runs.
101
+
102
+ ```tsx
103
+ <Klex activity="sleeping" size={40} />
104
+ <Klex activity="working" size={40} />
105
+ <Klex activity="calling" size={40} />
106
+ ```
107
+
108
+ Change the prop to switch activities without remounting the character. These are visual states; the component does not fetch agent status.
109
+
110
+ Sleeping automatically shows three rising Zs that drift, grow and fade in a staggered loop. They pause with the character and become a static trail with reduced motion. `extrasEnabled={false}` hides them. The same animation is available separately as the `sleep` extra.
111
+
112
+ The minimal, flat-colored laptop floats in front of the body and gently bobs. During typing it settles into a steady hold with small taps, then smoothly resumes floating. It scales with the avatar, adapts to the face height, springs into view, and shrinks away when working stops. `extrasEnabled={false}` hides it and the thinking question mark. Pause freezes the phase, laptop, and gaze together; reduced motion switches visibility immediately and uses a static working pose without phase changes or a question mark.
113
+
114
+ `initialExpression` and `initialExtra` are starting values. Later changes go through the ref methods. Reaction emotes temporarily override this base look, then restore the latest chosen values. `extrasEnabled={false}` hides both the selected extra and reaction extras.
115
+
116
+ `settings` accepts advanced movement settings such as `MOVEMENT_STYLES[n].settings`. A new settings object replaces a mode previously chosen by `moveTo`. Ordinary appearance updates preserve that mode. `movementMode` locks a character to `crawl`, `fly`, or `hop`: it picks that style's settings when `settings` is omitted, and `moveTo` ignores its mode argument.
117
+
118
+ ## Scenes
119
+
120
+ Characters pause while offscreen. When a scene clips its characters, mark the clipping element with `data-klex-viewport`; every Klex inside then follows that element's visibility, so characters entering from outside the visible area keep animating.
121
+
122
+ `layout="svg"` renders the character as native SVG groups for a parent `<svg>` scene, in the same 160-unit coordinate frame as `BODY_SHAPES`. Position and scale it with a transform on a wrapping `<g>`. WebKit mispaints transformed HTML inside `foreignObject`, so SVG scenes should use this layout instead of embedding the HTML layouts. It omits the name badge, speech bubbles, and `children`; `size` and `width` do not apply. The figure has no track width, so keep `x` at 0 and move it with the wrapping `<g>`; `y` offsets use SVG units.
123
+
124
+ ```tsx
125
+ <svg viewBox="0 0 800 400" data-klex-viewport="">
126
+ <g transform="translate(320 180) scale(0.8)">
127
+ <Klex layout="svg" activity="working" movementMode="fly" />
128
+ </g>
129
+ </svg>
130
+ ```
131
+
132
+ ## Ref methods
133
+
134
+ | Method | Behavior |
135
+ | --- | --- |
136
+ | `moveTo('left', 'crawl')` | Move to the left edge of this component's track. |
137
+ | `moveTo('right', 'fly')` | Move to the right edge and keep hovering there. |
138
+ | `moveTo(0, 'hop')` | Hop to the center. Numbers range from -50 to 50 and are clamped. |
139
+ | `snapTo({ x: 20, y: -100 })` | Set the position immediately and cancel the current trip. |
140
+ | `shiftBy({ x: 5, y: -20 })` | Offset position and destination without interrupting travel. |
141
+ | `face('left')` | Set the direction without moving. |
142
+ | `stopMoving()` | Stop at the current position without firing `onMoveComplete`. |
143
+ | `emote('jump')` | Play one emote. Returns `false` if another is active or reduced motion is enabled. |
144
+ | `setExpression('angry')` | Change the persistent face. |
145
+ | `setExtra('question')` | Show one extra. `setExtra('none')` hides it. |
146
+ | `cancelEmote()` | End the emote and restore the base look. Does not cancel travel. |
147
+ | `pause()` / `resume()` | Freeze or continue idle, travel, hovering and the active emote. |
148
+
149
+ Movement modes are `crawl`, `fly`, and `hop`. Omitting the mode keeps the current one. A new destination replaces the previous destination, preserving momentum. Movement and emotes can run together. Accepted `moveTo` and `emote` commands also resume a paused character.
150
+
151
+ All emotes, expressions and extras are typed IDs. The catalogs are `EMOTES`, `EXPRESSIONS`, and `EXTRAS`. For example, `shiver`, `wink`, `look-left`, `look-right`, `look-up`, `look-down`, and `thanks` are emotes; `happy`, `angry`, `sleepy`, and `hearts` are expressions.
152
+
153
+ `onMoveArrival` fires once near the latest destination, before the body finishes settling, so a conversation or scene action can begin promptly. `onMoveComplete` fires after settling. Both fire without animated travel when reduced motion is enabled; stopping or snapping cancels pending callbacks. `onEmoteComplete` fires when an emote finishes or is cancelled. No callbacks fire after unmount. Each component owns one controller for activities, movement and emotes and releases its ticker on pause or unmount. Grounded characters with `idle={false}` and no sleeping, working or calling activity release the ticker once their actions settle.
154
+
155
+ Speech bubbles animate out and back in when their text changes. Bubbles and extras share the same spring transition. `KlexGroundGrid` accepts optional fade values, so its parent can own the mask, and `floor` adjusts its geometry and line thickness for a plane tilted back by 60 degrees.
156
+
157
+ The component respects the system's reduced-motion preference: idle and emotes are skipped and destinations are applied without animated travel. Sleeping, working and calling retain a static pose without a continuous ticker. Facial expressions and extras remain available.
158
+
159
+ ## License
160
+
161
+ MIT. The phone extra embeds the Twemoji v17.0.3 telephone receiver (U+1F4DE), © Twitter, Inc. and other contributors, licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) and included unchanged apart from its placement. See `LICENSE-TWEMOJI.txt`.
package/package.json CHANGED
@@ -1,6 +1,70 @@
1
1
  {
2
2
  "name": "@klex/mascot",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "The animated Klex mascot: a React component, its GSAP motion engine, body presets, and SVG helpers.",
5
+ "type": "module",
6
+ "license": "MIT AND CC-BY-4.0",
7
+ "sideEffects": [
8
+ "**/*.css"
9
+ ],
10
+ "files": [
11
+ "src",
12
+ "!src/**/*.test.*",
13
+ "!src/**/*.bench.ts",
14
+ "!src/glide.fixtures.ts",
15
+ "!src/glide.golden.json.gz",
16
+ "README.md",
17
+ "LICENSE",
18
+ "LICENSE-TWEMOJI.txt"
19
+ ],
20
+ "exports": {
21
+ ".": "./src/index.ts",
22
+ "./svg": "./src/svg.ts"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/stagewise-io/cloud.git",
27
+ "directory": "packages/mascot"
28
+ },
29
+ "author": "stagewise GmbH",
30
+ "peerDependencies": {
31
+ "@stagewise/ui": ">=0.12.0",
32
+ "gsap": "^3.15.0",
33
+ "motion": "^13.1.0",
34
+ "react": "^19.2.0",
35
+ "react-dom": "^19.2.0"
36
+ },
37
+ "devDependencies": {
38
+ "@testing-library/jest-dom": "7.0.1",
39
+ "@testing-library/react": "16.3.2",
40
+ "@types/node": "24.13.3",
41
+ "@types/react": "19.2.18",
42
+ "@types/react-dom": "19.2.4",
43
+ "gsap": "^3.15.0",
44
+ "jsdom": "30.0.1",
45
+ "motion": "13.1.0",
46
+ "react": "19.2.8",
47
+ "react-dom": "19.2.8",
48
+ "typescript": "5.9.3",
49
+ "vitest": "4.1.10",
50
+ "@stagewise/ui": "0.1.0",
51
+ "@stagewise/typescript-config": "0.0.0"
52
+ },
53
+ "keywords": [
54
+ "klex",
55
+ "mascot",
56
+ "react",
57
+ "gsap",
58
+ "animation"
59
+ ],
60
+ "publishConfig": {
61
+ "access": "public",
62
+ "provenance": false
63
+ },
64
+ "scripts": {
65
+ "typecheck": "tsc --noEmit",
66
+ "lint": "biome check src",
67
+ "test": "vitest run",
68
+ "bench": "vitest bench --run"
69
+ }
6
70
  }