@jyiro/ascii-script 0.1.0 → 0.2.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.
Files changed (2) hide show
  1. package/README.md +497 -33
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  > Micro-librería JavaScript para renderizado y animación de arte ASCII en el DOM
4
4
 
5
+ [![npm version](https://img.shields.io/npm/v/@jyiro/ascii-script)](https://www.npmjs.com/package/@jyiro/ascii-script)
5
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
7
  [![Bundle Size](https://img.shields.io/badge/bundle-~5kb-brightgreen)](https://bundlephobia.com)
7
- [![Version](https://img.shields.io/badge/version-0.1.0-blue)](https://www.npmjs.com/package/@jyiro/ascii-script)
8
8
 
9
9
  ![alt text](ASCII-SCRIPT.gif)
10
10
 
@@ -105,23 +105,104 @@ Fondos basados en canvas:
105
105
 
106
106
  ## Presets
107
107
 
108
- Combinaciones preconfiguradas de efectos para uso rápido:
108
+ Combinaciones preconfiguradas de efectos para uso rápido.
109
+
110
+ ### ⚠️ Presets Disponibles (Lista Completa)
111
+
112
+ **IMPORTANTE:** Solo existen estos 5 presets. No inventes nombres nuevos.
113
+
114
+ | Preset | Efectos Incluidos | Ideal Para |
115
+ |--------|-------------------|------------|
116
+ | `rainbow` | wave + colorCycle | Logos animados con color |
117
+ | `hologram` | glitch + pulse | Efectos futuristas |
118
+ | `matrix` | matrixRain + scanlines | Estética Matrix/Cyberpunk |
119
+ | `terminal` | typewriter + scanlines | Texto estilo terminal retro |
120
+ | `decrypt` | scramble → reveal | Animaciones de descifrado |
121
+
122
+ ### Uso de Presets
109
123
 
110
124
  ```javascript
111
- // Efecto holográfico (glitch + pulse)
125
+ // CORRECTO: Usar uno de los 5 presets disponibles
126
+ await logo.preset('rainbow');
112
127
  await logo.preset('hologram');
113
-
114
- // Efecto Matrix (matrix rain + scanlines)
115
128
  await text.preset('matrix');
116
-
117
- // Animación de desencriptado (scramble → reveal)
129
+ await text.preset('terminal');
118
130
  await text.preset('decrypt');
119
131
 
120
- // Onda arcoíris (wave + color cycle)
121
- await logo.preset('rainbow');
132
+ // INCORRECTO: Estos presets NO existen
133
+ await logo.preset('cool'); // ❌ No existe
134
+ await logo.preset('custom'); // ❌ No existe
135
+ await logo.preset('neon'); // ❌ No existe
136
+ ```
122
137
 
123
- // Terminal retro (typewriter + scanlines)
124
- await text.preset('terminal');
138
+ ### Crear Combinaciones Personalizadas
139
+
140
+ Si necesitas una combinación diferente, encadena efectos manualmente:
141
+
142
+ ```javascript
143
+ // Combinación personalizada
144
+ await logo.wave({ amplitude: 5 });
145
+ await logo.colorGradient({ baseColor: '#00ff00' });
146
+ logo.play();
147
+ ```
148
+
149
+ ## ⛔ Errores Comunes (AI Hallucinations)
150
+
151
+ Esta librería es **JavaScript puro (vanilla)**. No confundir con:
152
+
153
+ ### ❌ Lo que NO existe en esta librería:
154
+
155
+ ```javascript
156
+ // ❌ NO existe useEffect - Esto NO es React
157
+ useEffect(() => {
158
+ const ascii = create();
159
+ }, []);
160
+
161
+ // ❌ NO existe el método .start() - Usar .play()
162
+ art.start(); // ❌ Incorrecto
163
+ art.play(); // ✅ Correcto
164
+
165
+ // ❌ NO existe constructor con `new`
166
+ const ascii = new AsciiScript(); // ❌ Incorrecto
167
+ const ascii = create(); // ✅ Correcto
168
+
169
+ // ❌ NO existen presets inventados
170
+ await art.preset('glow'); // ❌ No existe
171
+ await art.preset('rainbow'); // ✅ Correcto
172
+
173
+ // ❌ NO existe método .initialize()
174
+ ascii.initialize(); // ❌ Incorrecto
175
+ ascii.start(); // ✅ Correcto (si autoStart: false)
176
+ ```
177
+
178
+ ### ✅ API Correcta:
179
+
180
+ ```javascript
181
+ // ✅ Importar
182
+ import { create } from '@jyiro/ascii-script';
183
+
184
+ // ✅ Crear instancia
185
+ const ascii = create();
186
+
187
+ // ✅ Crear arte
188
+ const art = ascii.createArt('#logo');
189
+
190
+ // ✅ Aplicar preset válido
191
+ await art.preset('rainbow'); // Solo: rainbow, hologram, matrix, terminal, decrypt
192
+
193
+ // ✅ O aplicar efectos individuales
194
+ await art.wave();
195
+ await art.colorCycle();
196
+
197
+ // ✅ Reproducir
198
+ art.play();
199
+
200
+ // ✅ Controlar
201
+ art.pause();
202
+ art.reset();
203
+
204
+ // ✅ Destruir
205
+ ascii.destroy(art.id);
125
206
  ```
126
207
 
127
208
  ## Ejemplos
@@ -141,15 +222,17 @@ npm install
141
222
  npm run dev
142
223
 
143
224
  # 4. Abrir en el navegador
144
- # El servidor te mostrará la URL (generalmente http://localhost:5173)
225
+ # Visita http://localhost:5173 (redirige automáticamente al estudio)
145
226
  ```
146
227
 
147
- **Ejemplos Disponibles:**
228
+ **Estudio Interactivo:**
229
+
230
+ Al abrir `http://localhost:5173` serás redirigido automáticamente al **ASCII-SCRIPT Studio** (`examples/enhanced.html`):
148
231
 
149
- - **Enhanced Terminal** - `examples/enhanced.html`
150
- - Terminal interactivo completo con todos los efectos
151
- - Controles en tiempo real
152
- - Showcase de todos los presets
232
+ - Interfaz interactiva con todos los efectos disponibles
233
+ - 🎮 Controles en tiempo real para experimentar
234
+ - 🎨 Showcase completo de los 5 presets
235
+ - 📦 Dos capas de animación simultánea (texto + procedurales)
153
236
 
154
237
  ### Ejemplos de Código
155
238
 
@@ -235,9 +318,158 @@ animate();
235
318
  ## Documentación
236
319
 
237
320
  - [Referencia API Completa](docs/api.md) - Documentación detallada de todas las APIs y métodos
321
+ - [Guía de Presets](docs/PRESETS.md) - Documentación exhaustiva de todos los presets disponibles
238
322
  - **Ejemplos en Vivo** - Ejecuta `npm run dev` y abre `examples/enhanced.html` - Terminal interactivo completo
239
323
  - Guía de Efectos Personalizados - Ver sección "Uso Avanzado" en [docs/api.md](docs/api.md)
240
324
 
325
+ ## 🤖 For AI Assistants
326
+
327
+ **READ THIS CAREFULLY before generating code:**
328
+
329
+ ### Core Facts
330
+
331
+ 1. **This is vanilla JavaScript**, NOT a React library
332
+ 2. **No hooks exist**: No `useEffect`, `useState`, `useRef`
333
+ 3. **Only 5 presets exist**: `rainbow`, `hologram`, `matrix`, `terminal`, `decrypt`
334
+ 4. **Method names are fixed**: `.play()` NOT `.start()`, `create()` NOT `new AsciiScript()`
335
+
336
+ ### Complete Working Example
337
+
338
+ ```javascript
339
+ // ✅ CORRECT IMPLEMENTATION
340
+ import { create } from '@jyiro/ascii-script';
341
+
342
+ // 1. Create engine
343
+ const ascii = create();
344
+
345
+ // 2. Create art instance
346
+ const art = ascii.createArt('#logo');
347
+
348
+ // 3. Apply effects (choose ONE approach):
349
+
350
+ // APPROACH A: Use a preset (only these 5 exist)
351
+ await art.preset('rainbow'); // ✅ Valid
352
+ await art.preset('hologram'); // ✅ Valid
353
+ await art.preset('matrix'); // ✅ Valid
354
+ await art.preset('terminal'); // ✅ Valid
355
+ await art.preset('decrypt'); // ✅ Valid
356
+
357
+ // APPROACH B: Chain individual effects
358
+ await art.wave({ amplitude: 3, frequency: 0.8 });
359
+ await art.colorCycle({ speed: 0.002 });
360
+
361
+ // 4. Start animation
362
+ art.play();
363
+
364
+ // 5. Control playback
365
+ art.pause(); // Pause
366
+ art.play(); // Resume
367
+ art.reset(); // Stop and reset
368
+
369
+ // 6. Cleanup
370
+ ascii.destroy(art.id);
371
+ ```
372
+
373
+ ### Available Effects (Complete List)
374
+
375
+ **ASCII Art Effects:**
376
+ - `wave(options)` - Sine wave displacement
377
+ - `colorCycle(options)` - Rainbow color rotation
378
+ - `pulse(options)` - Breathing animation
379
+ - `perspective(options)` - 3D transforms
380
+ - `colorGradient(options)` - Color gradients
381
+
382
+ **Text Animation Effects:**
383
+ - `scramble(options)` - Random character scramble
384
+ - `reveal(options)` - Sequential reveal
385
+ - `glitch(options)` - Digital glitch
386
+ - `typewriter(options)` - Typing animation
387
+ - `matrixRain(options)` - Matrix-style rain
388
+
389
+ ### Framework Integration
390
+
391
+ **React:**
392
+ ```javascript
393
+ import { useEffect, useRef } from 'react';
394
+ import { create } from '@jyiro/ascii-script';
395
+
396
+ function AsciiLogo() {
397
+ const logoRef = useRef(null);
398
+ const asciiRef = useRef(null);
399
+ const artRef = useRef(null);
400
+
401
+ useEffect(() => {
402
+ if (!logoRef.current) return;
403
+
404
+ // Create engine once
405
+ asciiRef.current = create();
406
+ artRef.current = asciiRef.current.createArt(logoRef.current);
407
+
408
+ // Apply effect
409
+ artRef.current.preset('rainbow').then(() => {
410
+ artRef.current.play();
411
+ });
412
+
413
+ // Cleanup
414
+ return () => {
415
+ if (asciiRef.current && artRef.current) {
416
+ asciiRef.current.destroy(artRef.current.id);
417
+ }
418
+ };
419
+ }, []);
420
+
421
+ return <pre ref={logoRef}>ASCII ART HERE</pre>;
422
+ }
423
+ ```
424
+
425
+ **Vue:**
426
+ ```vue
427
+ <script setup>
428
+ import { ref, onMounted, onUnmounted } from 'vue';
429
+ import { create } from '@jyiro/ascii-script';
430
+
431
+ const logoRef = ref(null);
432
+ let ascii = null;
433
+ let art = null;
434
+
435
+ onMounted(async () => {
436
+ ascii = create();
437
+ art = ascii.createArt(logoRef.value);
438
+ await art.preset('rainbow');
439
+ art.play();
440
+ });
441
+
442
+ onUnmounted(() => {
443
+ if (ascii && art) {
444
+ ascii.destroy(art.id);
445
+ }
446
+ });
447
+ </script>
448
+
449
+ <template>
450
+ <pre ref="logoRef">ASCII ART HERE</pre>
451
+ </template>
452
+ ```
453
+
454
+ ### Common Questions
455
+
456
+ **Q: How do I create a custom preset?**
457
+ A: You can't. Chain effects manually:
458
+ ```javascript
459
+ await art.wave();
460
+ await art.colorGradient({ baseColor: '#00ff00' });
461
+ art.play();
462
+ ```
463
+
464
+ **Q: Can I use `.start()` instead of `.play()`?**
465
+ A: No. The method is `.play()`. There is no `.start()` method on art instances.
466
+
467
+ **Q: How do I initialize the engine?**
468
+ A: Use `const ascii = create()`. It auto-starts by default.
469
+
470
+ **Q: Does this work with TypeScript?**
471
+ A: Yes, but types are inferred. The library is written in vanilla JS.
472
+
241
473
  ## Desarrollo
242
474
 
243
475
  ```bash
@@ -439,23 +671,104 @@ Canvas-based backgrounds:
439
671
 
440
672
  ## Presets
441
673
 
442
- Pre-configured effect combinations for quick use:
674
+ Pre-configured effect combinations for quick use.
675
+
676
+ ### ⚠️ Available Presets (Complete List)
677
+
678
+ **IMPORTANT:** Only these 5 presets exist. Do not invent new names.
679
+
680
+ | Preset | Included Effects | Best For |
681
+ |--------|------------------|----------|
682
+ | `rainbow` | wave + colorCycle | Animated logos with color |
683
+ | `hologram` | glitch + pulse | Futuristic effects |
684
+ | `matrix` | matrixRain + scanlines | Matrix/Cyberpunk aesthetic |
685
+ | `terminal` | typewriter + scanlines | Retro terminal text |
686
+ | `decrypt` | scramble → reveal | Decryption animations |
687
+
688
+ ### Using Presets
443
689
 
444
690
  ```javascript
445
- // Hologram effect (glitch + pulse)
691
+ // CORRECT: Use one of the 5 available presets
692
+ await logo.preset('rainbow');
446
693
  await logo.preset('hologram');
447
-
448
- // Matrix effect (matrix rain + scanlines)
449
694
  await text.preset('matrix');
450
-
451
- // Decrypt animation (scramble → reveal)
695
+ await text.preset('terminal');
452
696
  await text.preset('decrypt');
453
697
 
454
- // Rainbow wave (wave + color cycle)
455
- await logo.preset('rainbow');
698
+ // WRONG: These presets DO NOT exist
699
+ await logo.preset('cool'); // ❌ Doesn't exist
700
+ await logo.preset('custom'); // ❌ Doesn't exist
701
+ await logo.preset('neon'); // ❌ Doesn't exist
702
+ ```
456
703
 
457
- // Retro terminal (typewriter + scanlines)
458
- await text.preset('terminal');
704
+ ### Creating Custom Combinations
705
+
706
+ If you need a different combination, chain effects manually:
707
+
708
+ ```javascript
709
+ // Custom combination
710
+ await logo.wave({ amplitude: 5 });
711
+ await logo.colorGradient({ baseColor: '#00ff00' });
712
+ logo.play();
713
+ ```
714
+
715
+ ## ⛔ Common Mistakes (AI Hallucinations)
716
+
717
+ This library is **vanilla JavaScript**. Do not confuse it with:
718
+
719
+ ### ❌ What does NOT exist in this library:
720
+
721
+ ```javascript
722
+ // ❌ No useEffect - This is NOT React
723
+ useEffect(() => {
724
+ const ascii = create();
725
+ }, []);
726
+
727
+ // ❌ No .start() method - Use .play()
728
+ art.start(); // ❌ Wrong
729
+ art.play(); // ✅ Correct
730
+
731
+ // ❌ No constructor with `new`
732
+ const ascii = new AsciiScript(); // ❌ Wrong
733
+ const ascii = create(); // ✅ Correct
734
+
735
+ // ❌ No invented presets
736
+ await art.preset('glow'); // ❌ Doesn't exist
737
+ await art.preset('rainbow'); // ✅ Correct
738
+
739
+ // ❌ No .initialize() method
740
+ ascii.initialize(); // ❌ Wrong
741
+ ascii.start(); // ✅ Correct (if autoStart: false)
742
+ ```
743
+
744
+ ### ✅ Correct API:
745
+
746
+ ```javascript
747
+ // ✅ Import
748
+ import { create } from '@jyiro/ascii-script';
749
+
750
+ // ✅ Create instance
751
+ const ascii = create();
752
+
753
+ // ✅ Create art
754
+ const art = ascii.createArt('#logo');
755
+
756
+ // ✅ Apply valid preset
757
+ await art.preset('rainbow'); // Only: rainbow, hologram, matrix, terminal, decrypt
758
+
759
+ // ✅ Or apply individual effects
760
+ await art.wave();
761
+ await art.colorCycle();
762
+
763
+ // ✅ Play
764
+ art.play();
765
+
766
+ // ✅ Control
767
+ art.pause();
768
+ art.reset();
769
+
770
+ // ✅ Destroy
771
+ ascii.destroy(art.id);
459
772
  ```
460
773
 
461
774
  ## Examples
@@ -475,15 +788,17 @@ npm install
475
788
  npm run dev
476
789
 
477
790
  # 4. Open in browser
478
- # The server will show you the URL (usually http://localhost:5173)
791
+ # Visit http://localhost:5173 (automatically redirects to the studio)
479
792
  ```
480
793
 
481
- **Available Examples:**
794
+ **Interactive Studio:**
795
+
796
+ When you open `http://localhost:5173`, you'll be automatically redirected to the **ASCII-SCRIPT Studio** (`examples/enhanced.html`):
482
797
 
483
- - **Enhanced Terminal** - `examples/enhanced.html`
484
- - Complete interactive terminal with all effects
485
- - Real-time controls
486
- - Showcase of all presets
798
+ - Interactive interface with all available effects
799
+ - 🎮 Real-time controls for experimentation
800
+ - 🎨 Complete showcase of all 5 presets
801
+ - 📦 Two simultaneous animation layers (text + procedural)
487
802
 
488
803
  ### Code Examples
489
804
 
@@ -569,9 +884,158 @@ animate();
569
884
  ## Documentation
570
885
 
571
886
  - [Complete API Reference](docs/api.md) - Detailed documentation of all APIs and methods
887
+ - [Presets Guide](docs/PRESETS.md) - Comprehensive documentation of all available presets
572
888
  - **Live Examples** - Run `npm run dev` and open `examples/enhanced.html` - Complete interactive terminal
573
889
  - Custom Effects Guide - See "Advanced Usage" section in [docs/api.md](docs/api.md)
574
890
 
891
+ ## 🤖 For AI Assistants
892
+
893
+ **READ THIS CAREFULLY before generating code:**
894
+
895
+ ### Core Facts
896
+
897
+ 1. **This is vanilla JavaScript**, NOT a React library
898
+ 2. **No hooks exist**: No `useEffect`, `useState`, `useRef`
899
+ 3. **Only 5 presets exist**: `rainbow`, `hologram`, `matrix`, `terminal`, `decrypt`
900
+ 4. **Method names are fixed**: `.play()` NOT `.start()`, `create()` NOT `new AsciiScript()`
901
+
902
+ ### Complete Working Example
903
+
904
+ ```javascript
905
+ // ✅ CORRECT IMPLEMENTATION
906
+ import { create } from '@jyiro/ascii-script';
907
+
908
+ // 1. Create engine
909
+ const ascii = create();
910
+
911
+ // 2. Create art instance
912
+ const art = ascii.createArt('#logo');
913
+
914
+ // 3. Apply effects (choose ONE approach):
915
+
916
+ // APPROACH A: Use a preset (only these 5 exist)
917
+ await art.preset('rainbow'); // ✅ Valid
918
+ await art.preset('hologram'); // ✅ Valid
919
+ await art.preset('matrix'); // ✅ Valid
920
+ await art.preset('terminal'); // ✅ Valid
921
+ await art.preset('decrypt'); // ✅ Valid
922
+
923
+ // APPROACH B: Chain individual effects
924
+ await art.wave({ amplitude: 3, frequency: 0.8 });
925
+ await art.colorCycle({ speed: 0.002 });
926
+
927
+ // 4. Start animation
928
+ art.play();
929
+
930
+ // 5. Control playback
931
+ art.pause(); // Pause
932
+ art.play(); // Resume
933
+ art.reset(); // Stop and reset
934
+
935
+ // 6. Cleanup
936
+ ascii.destroy(art.id);
937
+ ```
938
+
939
+ ### Available Effects (Complete List)
940
+
941
+ **ASCII Art Effects:**
942
+ - `wave(options)` - Sine wave displacement
943
+ - `colorCycle(options)` - Rainbow color rotation
944
+ - `pulse(options)` - Breathing animation
945
+ - `perspective(options)` - 3D transforms
946
+ - `colorGradient(options)` - Color gradients
947
+
948
+ **Text Animation Effects:**
949
+ - `scramble(options)` - Random character scramble
950
+ - `reveal(options)` - Sequential reveal
951
+ - `glitch(options)` - Digital glitch
952
+ - `typewriter(options)` - Typing animation
953
+ - `matrixRain(options)` - Matrix-style rain
954
+
955
+ ### Framework Integration
956
+
957
+ **React:**
958
+ ```javascript
959
+ import { useEffect, useRef } from 'react';
960
+ import { create } from '@jyiro/ascii-script';
961
+
962
+ function AsciiLogo() {
963
+ const logoRef = useRef(null);
964
+ const asciiRef = useRef(null);
965
+ const artRef = useRef(null);
966
+
967
+ useEffect(() => {
968
+ if (!logoRef.current) return;
969
+
970
+ // Create engine once
971
+ asciiRef.current = create();
972
+ artRef.current = asciiRef.current.createArt(logoRef.current);
973
+
974
+ // Apply effect
975
+ artRef.current.preset('rainbow').then(() => {
976
+ artRef.current.play();
977
+ });
978
+
979
+ // Cleanup
980
+ return () => {
981
+ if (asciiRef.current && artRef.current) {
982
+ asciiRef.current.destroy(artRef.current.id);
983
+ }
984
+ };
985
+ }, []);
986
+
987
+ return <pre ref={logoRef}>ASCII ART HERE</pre>;
988
+ }
989
+ ```
990
+
991
+ **Vue:**
992
+ ```vue
993
+ <script setup>
994
+ import { ref, onMounted, onUnmounted } from 'vue';
995
+ import { create } from '@jyiro/ascii-script';
996
+
997
+ const logoRef = ref(null);
998
+ let ascii = null;
999
+ let art = null;
1000
+
1001
+ onMounted(async () => {
1002
+ ascii = create();
1003
+ art = ascii.createArt(logoRef.value);
1004
+ await art.preset('rainbow');
1005
+ art.play();
1006
+ });
1007
+
1008
+ onUnmounted(() => {
1009
+ if (ascii && art) {
1010
+ ascii.destroy(art.id);
1011
+ }
1012
+ });
1013
+ </script>
1014
+
1015
+ <template>
1016
+ <pre ref="logoRef">ASCII ART HERE</pre>
1017
+ </template>
1018
+ ```
1019
+
1020
+ ### Common Questions
1021
+
1022
+ **Q: How do I create a custom preset?**
1023
+ A: You can't. Chain effects manually:
1024
+ ```javascript
1025
+ await art.wave();
1026
+ await art.colorGradient({ baseColor: '#00ff00' });
1027
+ art.play();
1028
+ ```
1029
+
1030
+ **Q: Can I use `.start()` instead of `.play()`?**
1031
+ A: No. The method is `.play()`. There is no `.start()` method on art instances.
1032
+
1033
+ **Q: How do I initialize the engine?**
1034
+ A: Use `const ascii = create()`. It auto-starts by default.
1035
+
1036
+ **Q: Does this work with TypeScript?**
1037
+ A: Yes, but types are inferred. The library is written in vanilla JS.
1038
+
575
1039
  ## Development
576
1040
 
577
1041
  ```bash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jyiro/ascii-script",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Micro-librería para render y animación ASCII en el DOM",
5
5
  "type": "module",
6
6
  "main": "./dist/ascii-script.js",