@nice2dev/ui-graphics 1.3.15 → 1.3.17

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 (294) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/animation/AnimatedPerson.js +470 -143
  3. package/dist/cjs/animation/AnimationEditor.js +289 -101
  4. package/dist/cjs/animation/Audience.js +83 -61
  5. package/dist/cjs/animation/BodyRenderer.js +69 -28
  6. package/dist/cjs/animation/animationHelper.js +281 -288
  7. package/dist/cjs/animation/characterTypes.js +200 -203
  8. package/dist/cjs/animation/choreoDSL.js +205 -219
  9. package/dist/cjs/animation/choreography.js +4 -32
  10. package/dist/cjs/animation/karaokeIntegration.js +68 -77
  11. package/dist/cjs/animation/lottieExport.js +108 -114
  12. package/dist/cjs/animation/motionPath.js +225 -248
  13. package/dist/cjs/animation/physics.js +227 -254
  14. package/dist/cjs/animation/rig/RigPlayer.js +53 -56
  15. package/dist/cjs/animation/rig/RiggedBody.js +71 -26
  16. package/dist/cjs/animation/rig/choreoRigBridge.js +72 -77
  17. package/dist/cjs/animation/rig/ik.js +13 -18
  18. package/dist/cjs/animation/rig/poseOps.js +34 -41
  19. package/dist/cjs/animation/rig/presets.js +64 -72
  20. package/dist/cjs/animation/rig/rigMath.js +25 -32
  21. package/dist/cjs/animation/rig/rigTypes.js +59 -63
  22. package/dist/cjs/animation/shapes/arms.js +31 -13
  23. package/dist/cjs/animation/shapes/eyes.js +129 -47
  24. package/dist/cjs/animation/shapes/hair.js +72 -45
  25. package/dist/cjs/animation/shapes/heads.js +131 -57
  26. package/dist/cjs/animation/shapes/headwear.js +47 -38
  27. package/dist/cjs/animation/shapes/legs.js +31 -13
  28. package/dist/cjs/animation/shapes/mouths.js +120 -44
  29. package/dist/cjs/animation/shapes/noses.js +80 -25
  30. package/dist/cjs/animation/shapes/outfits.js +101 -39
  31. package/dist/cjs/animation/shapes/torsos.js +15 -11
  32. package/dist/cjs/animation/spineExport.js +103 -121
  33. package/dist/cjs/core/LocalUI.js +108 -43
  34. package/dist/cjs/core/NiceBrushEngine.js +758 -552
  35. package/dist/cjs/core/collaboration.js +249 -251
  36. package/dist/cjs/core/colorBlindness.js +100 -115
  37. package/dist/cjs/core/dragDrop.js +155 -158
  38. package/dist/cjs/core/editorAsk.js +51 -41
  39. package/dist/cjs/core/fixes.js +140 -171
  40. package/dist/cjs/core/gridGuides.js +166 -201
  41. package/dist/cjs/core/historyVisual.js +156 -135
  42. package/dist/cjs/core/i18n.js +13 -14
  43. package/dist/cjs/core/integrations.js +238 -249
  44. package/dist/cjs/core/minimap.js +149 -151
  45. package/dist/cjs/core/plugins.js +98 -113
  46. package/dist/cjs/core/rtl.js +71 -83
  47. package/dist/cjs/core/shortcuts.js +196 -225
  48. package/dist/cjs/core/theme.js +142 -149
  49. package/dist/cjs/core/yjsCollaboration.js +232 -293
  50. package/dist/cjs/design/design-tools.js +12 -22
  51. package/dist/cjs/font/NiceFontEditor.js +877 -316
  52. package/dist/cjs/font/fontFormatUtils.js +388 -448
  53. package/dist/cjs/game/GameAsset2dEditor.js +1201 -392
  54. package/dist/cjs/game/GameAsset2dEditor.module.css.js +146 -5
  55. package/dist/cjs/game/gameAssetTypes.js +7 -16
  56. package/dist/cjs/game/gameAssetUtils.js +390 -413
  57. package/dist/cjs/game/useGameAssetEditor.js +820 -763
  58. package/dist/cjs/index.js +81 -84
  59. package/dist/cjs/nice2dev-ui-graphics.css +1 -1
  60. package/dist/cjs/node_modules/lib0/array.js +8 -70
  61. package/dist/cjs/node_modules/lib0/binary.js +3 -20
  62. package/dist/cjs/node_modules/lib0/broadcastchannel.js +24 -86
  63. package/dist/cjs/node_modules/lib0/buffer.js +15 -82
  64. package/dist/cjs/node_modules/lib0/conditions.js +3 -16
  65. package/dist/cjs/node_modules/lib0/decoding.js +108 -287
  66. package/dist/cjs/node_modules/lib0/dom.js +14 -44
  67. package/dist/cjs/node_modules/lib0/encoding.js +68 -418
  68. package/dist/cjs/node_modules/lib0/environment.js +26 -92
  69. package/dist/cjs/node_modules/lib0/error.js +5 -29
  70. package/dist/cjs/node_modules/lib0/function.js +27 -66
  71. package/dist/cjs/node_modules/lib0/iterator.js +8 -33
  72. package/dist/cjs/node_modules/lib0/logging.common.js +12 -22
  73. package/dist/cjs/node_modules/lib0/logging.js +32 -71
  74. package/dist/cjs/node_modules/lib0/map.js +16 -86
  75. package/dist/cjs/node_modules/lib0/math.js +3 -32
  76. package/dist/cjs/node_modules/lib0/number.js +4 -15
  77. package/dist/cjs/node_modules/lib0/object.js +14 -88
  78. package/dist/cjs/node_modules/lib0/observable.js +38 -78
  79. package/dist/cjs/node_modules/lib0/pair.js +3 -20
  80. package/dist/cjs/node_modules/lib0/prng.js +8 -77
  81. package/dist/cjs/node_modules/lib0/promise.js +6 -30
  82. package/dist/cjs/node_modules/lib0/random.js +8 -23
  83. package/dist/cjs/node_modules/lib0/schema.js +313 -687
  84. package/dist/cjs/node_modules/lib0/set.js +3 -10
  85. package/dist/cjs/node_modules/lib0/storage.js +20 -55
  86. package/dist/cjs/node_modules/lib0/string.js +17 -72
  87. package/dist/cjs/node_modules/lib0/symbol.js +2 -12
  88. package/dist/cjs/node_modules/lib0/time.js +2 -15
  89. package/dist/cjs/node_modules/lib0/trait/equality.js +3 -28
  90. package/dist/cjs/node_modules/lib0/url.js +4 -18
  91. package/dist/cjs/node_modules/lib0/webcrypto.js +2 -5
  92. package/dist/cjs/node_modules/y-protocols/auth.js +5 -19
  93. package/dist/cjs/node_modules/y-protocols/awareness.js +53 -116
  94. package/dist/cjs/node_modules/y-protocols/sync.js +16 -103
  95. package/dist/cjs/node_modules/y-websocket/src/y-websocket.js +77 -219
  96. package/dist/cjs/node_modules/yjs/dist/yjs.js +2128 -4868
  97. package/dist/cjs/photo/FilterThumb.js +37 -25
  98. package/dist/cjs/photo/NiceAITools.js +679 -467
  99. package/dist/cjs/photo/PhotoEditor.js +34 -20
  100. package/dist/cjs/photo/PhotoEditor.module.css.js +296 -5
  101. package/dist/cjs/photo/PhotoEditorCanvas.js +250 -91
  102. package/dist/cjs/photo/PhotoEditorLeftPanel.js +1086 -224
  103. package/dist/cjs/photo/PhotoEditorToolbar.js +135 -19
  104. package/dist/cjs/photo/photoEditorActions.js +89 -72
  105. package/dist/cjs/photo/photoEditorTypes.js +29 -32
  106. package/dist/cjs/photo/photoFilters.js +959 -985
  107. package/dist/cjs/photo/photoOverlays.js +899 -945
  108. package/dist/cjs/photo/photoSelection.js +427 -499
  109. package/dist/cjs/photo/usePhotoEditor.js +739 -741
  110. package/dist/cjs/pixel/HSVPicker.js +191 -175
  111. package/dist/cjs/pixel/PixelEditor.js +159 -48
  112. package/dist/cjs/pixel/PixelEditor.module.css.js +209 -5
  113. package/dist/cjs/pixel/PixelEditorCanvas.js +29 -16
  114. package/dist/cjs/pixel/PixelEditorMenuBar.js +160 -162
  115. package/dist/cjs/pixel/PixelEditorRightPanel.js +377 -45
  116. package/dist/cjs/pixel/PixelEditorStatusBar.js +47 -20
  117. package/dist/cjs/pixel/PixelEditorTimeline.js +106 -23
  118. package/dist/cjs/pixel/PixelEditorToolbar.js +99 -21
  119. package/dist/cjs/pixel/SpriteGeneratorPanel.js +483 -303
  120. package/dist/cjs/pixel/animalGeneratorPresets.js +776 -601
  121. package/dist/cjs/pixel/asepriteFormat.js +511 -560
  122. package/dist/cjs/pixel/buildingGeneratorPresets.js +693 -520
  123. package/dist/cjs/pixel/characterGeneratorPresets.js +644 -544
  124. package/dist/cjs/pixel/pixel-pro.js +52 -63
  125. package/dist/cjs/pixel/pixelEditorExports.js +388 -428
  126. package/dist/cjs/pixel/pixelEditorTypes.js +91 -108
  127. package/dist/cjs/pixel/pixelEditorUtils.js +519 -561
  128. package/dist/cjs/pixel/spriteGeneratorCore.js +206 -257
  129. package/dist/cjs/pixel/usePixelEditor.js +1321 -1343
  130. package/dist/cjs/texture/Nice3DTexturePainter.js +707 -440
  131. package/dist/cjs/ui/NiceUIDesigner.js +954 -527
  132. package/dist/cjs/vector/NiceSvgToCode.js +586 -446
  133. package/dist/cjs/vector/VectorEditor.js +290 -117
  134. package/dist/cjs/vector/VectorEditor.module.css.js +86 -5
  135. package/dist/cjs/vector/VectorEditorMenuBar.js +333 -275
  136. package/dist/cjs/vector/VectorEditorRightPanel.js +1094 -371
  137. package/dist/cjs/vector/VectorEditorShapeRenderer.js +198 -60
  138. package/dist/cjs/vector/VectorEditorStatusBar.js +39 -13
  139. package/dist/cjs/vector/useVectorEditor.js +848 -889
  140. package/dist/cjs/vector/vectorAnimation.js +110 -137
  141. package/dist/cjs/vector/vectorBooleanOps.js +398 -485
  142. package/dist/cjs/vector/vectorEditorExport.js +201 -203
  143. package/dist/cjs/vector/vectorEditorImport.js +173 -189
  144. package/dist/cjs/vector/vectorEditorTypes.js +42 -49
  145. package/dist/cjs/vector/vectorGradients.js +151 -174
  146. package/dist/cjs/vector/vectorIconExport.js +52 -59
  147. package/dist/cjs/vector/vectorIconImport.js +169 -219
  148. package/dist/esm/animation/AnimatedPerson.js +470 -141
  149. package/dist/esm/animation/AnimationEditor.js +290 -100
  150. package/dist/esm/animation/Audience.js +83 -59
  151. package/dist/esm/animation/BodyRenderer.js +71 -25
  152. package/dist/esm/animation/animationHelper.js +284 -287
  153. package/dist/esm/animation/characterTypes.js +204 -202
  154. package/dist/esm/animation/choreoDSL.js +212 -218
  155. package/dist/esm/animation/choreography.js +8 -31
  156. package/dist/esm/animation/karaokeIntegration.js +74 -76
  157. package/dist/esm/animation/lottieExport.js +112 -113
  158. package/dist/esm/animation/motionPath.js +235 -247
  159. package/dist/esm/animation/physics.js +235 -253
  160. package/dist/esm/animation/rig/RigPlayer.js +53 -54
  161. package/dist/esm/animation/rig/RiggedBody.js +71 -24
  162. package/dist/esm/animation/rig/choreoRigBridge.js +74 -76
  163. package/dist/esm/animation/rig/ik.js +14 -17
  164. package/dist/esm/animation/rig/poseOps.js +37 -40
  165. package/dist/esm/animation/rig/presets.js +70 -71
  166. package/dist/esm/animation/rig/rigMath.js +28 -31
  167. package/dist/esm/animation/rig/rigTypes.js +62 -62
  168. package/dist/esm/animation/shapes/arms.js +32 -12
  169. package/dist/esm/animation/shapes/eyes.js +135 -46
  170. package/dist/esm/animation/shapes/hair.js +80 -44
  171. package/dist/esm/animation/shapes/heads.js +140 -56
  172. package/dist/esm/animation/shapes/headwear.js +54 -37
  173. package/dist/esm/animation/shapes/legs.js +32 -12
  174. package/dist/esm/animation/shapes/mouths.js +127 -43
  175. package/dist/esm/animation/shapes/noses.js +87 -24
  176. package/dist/esm/animation/shapes/outfits.js +106 -38
  177. package/dist/esm/animation/shapes/torsos.js +16 -10
  178. package/dist/esm/animation/spineExport.js +106 -120
  179. package/dist/esm/core/LocalUI.js +111 -42
  180. package/dist/esm/core/NiceBrushEngine.js +761 -551
  181. package/dist/esm/core/collaboration.js +255 -250
  182. package/dist/esm/core/colorBlindness.js +106 -114
  183. package/dist/esm/core/dragDrop.js +157 -157
  184. package/dist/esm/core/editorAsk.js +53 -40
  185. package/dist/esm/core/fixes.js +145 -170
  186. package/dist/esm/core/gridGuides.js +178 -200
  187. package/dist/esm/core/historyVisual.js +158 -134
  188. package/dist/esm/core/i18n.js +15 -13
  189. package/dist/esm/core/integrations.js +244 -248
  190. package/dist/esm/core/minimap.js +151 -150
  191. package/dist/esm/core/plugins.js +102 -112
  192. package/dist/esm/core/rtl.js +77 -82
  193. package/dist/esm/core/shortcuts.js +200 -224
  194. package/dist/esm/core/theme.js +150 -148
  195. package/dist/esm/core/yjsCollaboration.js +240 -292
  196. package/dist/esm/design/design-tools.js +13 -21
  197. package/dist/esm/font/NiceFontEditor.js +880 -315
  198. package/dist/esm/font/fontFormatUtils.js +394 -447
  199. package/dist/esm/game/GameAsset2dEditor.js +1202 -391
  200. package/dist/esm/game/GameAsset2dEditor.module.css.js +146 -3
  201. package/dist/esm/game/gameAssetTypes.js +8 -15
  202. package/dist/esm/game/gameAssetUtils.js +408 -412
  203. package/dist/esm/game/useGameAssetEditor.js +821 -762
  204. package/dist/esm/index.js +332 -69
  205. package/dist/esm/nice2dev-ui-graphics.css +1 -1
  206. package/dist/esm/node_modules/lib0/array.js +15 -69
  207. package/dist/esm/node_modules/lib0/binary.js +14 -19
  208. package/dist/esm/node_modules/lib0/broadcastchannel.js +27 -85
  209. package/dist/esm/node_modules/lib0/buffer.js +20 -80
  210. package/dist/esm/node_modules/lib0/conditions.js +4 -15
  211. package/dist/esm/node_modules/lib0/decoding.js +128 -286
  212. package/dist/esm/node_modules/lib0/dom.js +20 -43
  213. package/dist/esm/node_modules/lib0/encoding.js +90 -415
  214. package/dist/esm/node_modules/lib0/environment.js +33 -91
  215. package/dist/esm/node_modules/lib0/error.js +8 -28
  216. package/dist/esm/node_modules/lib0/function.js +31 -65
  217. package/dist/esm/node_modules/lib0/iterator.js +11 -32
  218. package/dist/esm/node_modules/lib0/logging.common.js +22 -21
  219. package/dist/esm/node_modules/lib0/logging.js +44 -70
  220. package/dist/esm/node_modules/lib0/map.js +21 -85
  221. package/dist/esm/node_modules/lib0/math.js +9 -31
  222. package/dist/esm/node_modules/lib0/number.js +7 -14
  223. package/dist/esm/node_modules/lib0/object.js +26 -87
  224. package/dist/esm/node_modules/lib0/observable.js +40 -77
  225. package/dist/esm/node_modules/lib0/pair.js +5 -19
  226. package/dist/esm/node_modules/lib0/prng.js +15 -76
  227. package/dist/esm/node_modules/lib0/promise.js +7 -29
  228. package/dist/esm/node_modules/lib0/random.js +10 -22
  229. package/dist/esm/node_modules/lib0/schema.js +367 -686
  230. package/dist/esm/node_modules/lib0/set.js +4 -9
  231. package/dist/esm/node_modules/lib0/storage.js +23 -54
  232. package/dist/esm/node_modules/lib0/string.js +26 -71
  233. package/dist/esm/node_modules/lib0/symbol.js +3 -11
  234. package/dist/esm/node_modules/lib0/time.js +3 -14
  235. package/dist/esm/node_modules/lib0/trait/equality.js +5 -27
  236. package/dist/esm/node_modules/lib0/url.js +5 -17
  237. package/dist/esm/node_modules/lib0/webcrypto.js +3 -4
  238. package/dist/esm/node_modules/y-protocols/auth.js +7 -18
  239. package/dist/esm/node_modules/y-protocols/awareness.js +58 -115
  240. package/dist/esm/node_modules/y-protocols/sync.js +26 -102
  241. package/dist/esm/node_modules/y-websocket/src/y-websocket.js +82 -218
  242. package/dist/esm/node_modules/yjs/dist/yjs.js +2263 -4899
  243. package/dist/esm/photo/FilterThumb.js +37 -23
  244. package/dist/esm/photo/NiceAITools.js +685 -466
  245. package/dist/esm/photo/PhotoEditor.js +34 -18
  246. package/dist/esm/photo/PhotoEditor.module.css.js +296 -3
  247. package/dist/esm/photo/PhotoEditorCanvas.js +250 -89
  248. package/dist/esm/photo/PhotoEditorLeftPanel.js +1086 -222
  249. package/dist/esm/photo/PhotoEditorToolbar.js +135 -17
  250. package/dist/esm/photo/photoEditorActions.js +93 -71
  251. package/dist/esm/photo/photoEditorTypes.js +32 -31
  252. package/dist/esm/photo/photoFilters.js +967 -984
  253. package/dist/esm/photo/photoOverlays.js +913 -944
  254. package/dist/esm/photo/photoSelection.js +438 -498
  255. package/dist/esm/photo/usePhotoEditor.js +740 -740
  256. package/dist/esm/pixel/HSVPicker.js +192 -174
  257. package/dist/esm/pixel/PixelEditor.js +160 -47
  258. package/dist/esm/pixel/PixelEditor.module.css.js +209 -3
  259. package/dist/esm/pixel/PixelEditorCanvas.js +29 -14
  260. package/dist/esm/pixel/PixelEditorMenuBar.js +160 -160
  261. package/dist/esm/pixel/PixelEditorRightPanel.js +377 -43
  262. package/dist/esm/pixel/PixelEditorStatusBar.js +47 -18
  263. package/dist/esm/pixel/PixelEditorTimeline.js +106 -21
  264. package/dist/esm/pixel/PixelEditorToolbar.js +99 -19
  265. package/dist/esm/pixel/SpriteGeneratorPanel.js +483 -301
  266. package/dist/esm/pixel/animalGeneratorPresets.js +782 -600
  267. package/dist/esm/pixel/asepriteFormat.js +517 -559
  268. package/dist/esm/pixel/buildingGeneratorPresets.js +699 -519
  269. package/dist/esm/pixel/characterGeneratorPresets.js +650 -543
  270. package/dist/esm/pixel/pixel-pro.js +53 -62
  271. package/dist/esm/pixel/pixelEditorExports.js +397 -427
  272. package/dist/esm/pixel/pixelEditorTypes.js +103 -107
  273. package/dist/esm/pixel/pixelEditorUtils.js +551 -560
  274. package/dist/esm/pixel/spriteGeneratorCore.js +223 -256
  275. package/dist/esm/pixel/usePixelEditor.js +1322 -1342
  276. package/dist/esm/texture/Nice3DTexturePainter.js +709 -439
  277. package/dist/esm/ui/NiceUIDesigner.js +957 -526
  278. package/dist/esm/vector/NiceSvgToCode.js +589 -445
  279. package/dist/esm/vector/VectorEditor.js +291 -116
  280. package/dist/esm/vector/VectorEditor.module.css.js +86 -3
  281. package/dist/esm/vector/VectorEditorMenuBar.js +333 -273
  282. package/dist/esm/vector/VectorEditorRightPanel.js +1094 -369
  283. package/dist/esm/vector/VectorEditorShapeRenderer.js +199 -59
  284. package/dist/esm/vector/VectorEditorStatusBar.js +39 -11
  285. package/dist/esm/vector/useVectorEditor.js +849 -888
  286. package/dist/esm/vector/vectorAnimation.js +115 -136
  287. package/dist/esm/vector/vectorBooleanOps.js +401 -484
  288. package/dist/esm/vector/vectorEditorExport.js +207 -202
  289. package/dist/esm/vector/vectorEditorImport.js +174 -188
  290. package/dist/esm/vector/vectorEditorTypes.js +50 -48
  291. package/dist/esm/vector/vectorGradients.js +158 -173
  292. package/dist/esm/vector/vectorIconExport.js +53 -58
  293. package/dist/esm/vector/vectorIconImport.js +171 -218
  294. package/package.json +9 -15
@@ -1,239 +1,225 @@
1
- 'use strict';
2
-
3
- var animationHelper = require('./animationHelper.js');
4
-
5
- // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const animationHelper = require("./animationHelper.js");
6
4
  class ChoreoBuilder {
7
- constructor() {
8
- this.steps = [];
9
- this.labels = {};
10
- }
11
- pose(pose, holdMs = 0, options) {
12
- this.steps.push({ type: 'pose', pose, holdMs, options });
13
- return this;
14
- }
15
- wait(ms) {
16
- this.steps.push({ type: 'wait', ms });
17
- return this;
18
- }
19
- tempo(multiplier) {
20
- const m = Math.max(0, multiplier);
21
- this.steps = this.steps.map((s) => {
22
- if (s.type === 'pose') {
23
- return {
24
- ...s,
25
- holdMs: typeof s.holdMs === 'number' ? Math.round(s.holdMs * m) : s.holdMs,
26
- options: s.options
27
- ? {
28
- ...s.options,
29
- duration: typeof s.options.duration === 'number'
30
- ? s.options.duration * m
31
- : s.options.duration,
32
- }
33
- : s.options,
34
- };
35
- }
36
- if (s.type === 'wait') {
37
- return { ...s, ms: Math.round(s.ms * m) };
38
- }
39
- return s;
40
- });
41
- return this;
42
- }
43
- repeat(times) {
44
- const t = Math.max(0, Math.floor(times));
45
- const base = this.steps.slice();
46
- for (let i = 1; i < t; i++) {
47
- this.steps.push(...base);
48
- }
49
- return this;
50
- }
51
- loop(times) {
52
- this.loopCount = times;
53
- return this;
54
- }
55
- label(name) {
56
- this.labels[name] = this.steps.length;
57
- this.steps.push({ type: 'label', name });
58
- return this;
59
- }
60
- goto(name) {
61
- this.steps.push({ type: 'goto', name });
62
- return this;
63
- }
64
- gotoIf(name, when) {
65
- this.steps.push({ type: 'goto', name, when });
66
- return this;
67
- }
68
- // Convenience shortcuts
69
- idle(ms = 0) {
70
- return this.pose('idle', ms);
71
- }
72
- enterFromLeft(duration = 0.6) {
73
- return this.pose('enterFromLeft', 0, { duration });
74
- }
75
- enterFromRight(duration = 0.6) {
76
- return this.pose('enterFromRight', 0, { duration });
77
- }
78
- exitLeft(duration = 0.6) {
79
- return this.pose('exitLeft', 0, { duration });
80
- }
81
- exitRight(duration = 0.6) {
82
- return this.pose('exitRight', 0, { duration });
83
- }
84
- hideDown(duration = 0.6) {
85
- return this.pose('hideDown', 0, { duration });
86
- }
87
- happy(ms = 350) {
88
- return this.pose('happy', ms);
89
- }
90
- angry(ms = 350) {
91
- return this.pose('angry', ms);
92
- }
93
- disappointed(ms = 350) {
94
- return this.pose('disappointed', ms);
95
- }
96
- swearing(ms = 350) {
97
- return this.pose('swearing', ms);
98
- }
99
- shouting(ms = 350) {
100
- return this.pose('shouting', ms);
101
- }
102
- rock(ms = 500) {
103
- return this.pose('rock', ms);
104
- }
105
- danceA(ms = 350) {
106
- return this.pose('danceA', ms);
107
- }
108
- danceB(ms = 350) {
109
- return this.pose('danceB', ms);
110
- }
111
- danceC(ms = 350) {
112
- return this.pose('danceC', ms);
113
- }
114
- waveHand(ms = 600) {
115
- return this.pose('waveHand', ms);
116
- }
117
- facepalm(ms = 500) {
118
- return this.pose('facepalm', ms);
119
- }
120
- shrug(ms = 450) {
121
- return this.pose('shrug', ms);
122
- }
123
- nodYes(ms = 450) {
124
- return this.pose('nodYes', ms);
125
- }
126
- shakeNo(ms = 450) {
127
- return this.pose('shakeNo', ms);
128
- }
129
- pointRight(ms = 400) {
130
- return this.pose('pointRight', ms);
131
- }
132
- leanBack(ms = 400) {
133
- return this.pose('leanBack', ms);
134
- }
135
- jump(ms = 450) {
136
- return this.pose('jump', ms);
137
- }
138
- spin(ms = 650) {
139
- return this.pose('spin', ms);
140
- }
141
- celebrate(ms = 600) {
142
- return this.pose('celebrate', ms);
143
- }
144
- raiseCard(score = 10, holdMs = 800, duration = 0.6) {
145
- return this.pose('raiseCard', holdMs, { duration, score });
146
- }
147
- build() {
148
- return this.steps.slice();
149
- }
150
- getLoop() {
151
- return this.loopCount;
152
- }
5
+ constructor() {
6
+ this.steps = [];
7
+ this.labels = {};
8
+ }
9
+ pose(pose, holdMs = 0, options) {
10
+ this.steps.push({ type: "pose", pose, holdMs, options });
11
+ return this;
12
+ }
13
+ wait(ms) {
14
+ this.steps.push({ type: "wait", ms });
15
+ return this;
16
+ }
17
+ tempo(multiplier) {
18
+ const m = Math.max(0, multiplier);
19
+ this.steps = this.steps.map((s) => {
20
+ if (s.type === "pose") {
21
+ return {
22
+ ...s,
23
+ holdMs: typeof s.holdMs === "number" ? Math.round(s.holdMs * m) : s.holdMs,
24
+ options: s.options ? {
25
+ ...s.options,
26
+ duration: typeof s.options.duration === "number" ? s.options.duration * m : s.options.duration
27
+ } : s.options
28
+ };
29
+ }
30
+ if (s.type === "wait") {
31
+ return { ...s, ms: Math.round(s.ms * m) };
32
+ }
33
+ return s;
34
+ });
35
+ return this;
36
+ }
37
+ repeat(times) {
38
+ const t = Math.max(0, Math.floor(times));
39
+ const base = this.steps.slice();
40
+ for (let i = 1; i < t; i++) {
41
+ this.steps.push(...base);
42
+ }
43
+ return this;
44
+ }
45
+ loop(times) {
46
+ this.loopCount = times;
47
+ return this;
48
+ }
49
+ label(name) {
50
+ this.labels[name] = this.steps.length;
51
+ this.steps.push({ type: "label", name });
52
+ return this;
53
+ }
54
+ goto(name) {
55
+ this.steps.push({ type: "goto", name });
56
+ return this;
57
+ }
58
+ gotoIf(name, when) {
59
+ this.steps.push({ type: "goto", name, when });
60
+ return this;
61
+ }
62
+ // Convenience shortcuts
63
+ idle(ms = 0) {
64
+ return this.pose("idle", ms);
65
+ }
66
+ enterFromLeft(duration = 0.6) {
67
+ return this.pose("enterFromLeft", 0, { duration });
68
+ }
69
+ enterFromRight(duration = 0.6) {
70
+ return this.pose("enterFromRight", 0, { duration });
71
+ }
72
+ exitLeft(duration = 0.6) {
73
+ return this.pose("exitLeft", 0, { duration });
74
+ }
75
+ exitRight(duration = 0.6) {
76
+ return this.pose("exitRight", 0, { duration });
77
+ }
78
+ hideDown(duration = 0.6) {
79
+ return this.pose("hideDown", 0, { duration });
80
+ }
81
+ happy(ms = 350) {
82
+ return this.pose("happy", ms);
83
+ }
84
+ angry(ms = 350) {
85
+ return this.pose("angry", ms);
86
+ }
87
+ disappointed(ms = 350) {
88
+ return this.pose("disappointed", ms);
89
+ }
90
+ swearing(ms = 350) {
91
+ return this.pose("swearing", ms);
92
+ }
93
+ shouting(ms = 350) {
94
+ return this.pose("shouting", ms);
95
+ }
96
+ rock(ms = 500) {
97
+ return this.pose("rock", ms);
98
+ }
99
+ danceA(ms = 350) {
100
+ return this.pose("danceA", ms);
101
+ }
102
+ danceB(ms = 350) {
103
+ return this.pose("danceB", ms);
104
+ }
105
+ danceC(ms = 350) {
106
+ return this.pose("danceC", ms);
107
+ }
108
+ waveHand(ms = 600) {
109
+ return this.pose("waveHand", ms);
110
+ }
111
+ facepalm(ms = 500) {
112
+ return this.pose("facepalm", ms);
113
+ }
114
+ shrug(ms = 450) {
115
+ return this.pose("shrug", ms);
116
+ }
117
+ nodYes(ms = 450) {
118
+ return this.pose("nodYes", ms);
119
+ }
120
+ shakeNo(ms = 450) {
121
+ return this.pose("shakeNo", ms);
122
+ }
123
+ pointRight(ms = 400) {
124
+ return this.pose("pointRight", ms);
125
+ }
126
+ leanBack(ms = 400) {
127
+ return this.pose("leanBack", ms);
128
+ }
129
+ jump(ms = 450) {
130
+ return this.pose("jump", ms);
131
+ }
132
+ spin(ms = 650) {
133
+ return this.pose("spin", ms);
134
+ }
135
+ celebrate(ms = 600) {
136
+ return this.pose("celebrate", ms);
137
+ }
138
+ raiseCard(score = 10, holdMs = 800, duration = 0.6) {
139
+ return this.pose("raiseCard", holdMs, { duration, score });
140
+ }
141
+ build() {
142
+ return this.steps.slice();
143
+ }
144
+ getLoop() {
145
+ return this.loopCount;
146
+ }
153
147
  }
154
- /** Create a new ChoreoBuilder. */
155
148
  const seq = () => new ChoreoBuilder();
156
- /** Compile builder or steps into flat ChoreoStep[] (resolving gotos). */
157
149
  function compile(builderOrSteps, ctx = {}) {
158
- // If a factory function was passed, invoke it to obtain the concrete program.
159
- // Some demo choreographies are exported as `(score:number)=>seq()...`.
160
- const resolved = typeof builderOrSteps === 'function'
161
- ? builderOrSteps(ctx)
162
- : builderOrSteps;
163
- const internal = resolved instanceof ChoreoBuilder ? resolved.build() : resolved;
164
- const labelIndex = {};
165
- internal.forEach((s, i) => {
166
- if (s.type === 'label') {
167
- labelIndex[s.name] = i;
168
- }
169
- });
170
- const out = [];
171
- for (let pc = 0; pc < internal.length; pc++) {
172
- const s = internal[pc];
173
- if (s.type === 'pose') {
174
- out.push({ pose: s.pose, holdMs: s.holdMs, options: s.options });
175
- }
176
- else if (s.type === 'wait') {
177
- out.push({ pose: 'idle', holdMs: s.ms });
178
- }
179
- else if (s.type === 'goto') {
180
- const should = s.when ? !!s.when(ctx) : true;
181
- if (should) {
182
- const idx = labelIndex[s.name];
183
- if (idx !== undefined) {
184
- pc = idx;
185
- }
186
- }
150
+ const resolved = typeof builderOrSteps === "function" ? builderOrSteps(ctx) : builderOrSteps;
151
+ const internal = resolved instanceof ChoreoBuilder ? resolved.build() : resolved;
152
+ const labelIndex = {};
153
+ internal.forEach((s, i) => {
154
+ if (s.type === "label") {
155
+ labelIndex[s.name] = i;
156
+ }
157
+ });
158
+ const out = [];
159
+ for (let pc = 0; pc < internal.length; pc++) {
160
+ const s = internal[pc];
161
+ if (s.type === "pose") {
162
+ out.push({ pose: s.pose, holdMs: s.holdMs, options: s.options });
163
+ } else if (s.type === "wait") {
164
+ out.push({ pose: "idle", holdMs: s.ms });
165
+ } else if (s.type === "goto") {
166
+ const should = s.when ? !!s.when(ctx) : true;
167
+ if (should) {
168
+ const idx = labelIndex[s.name];
169
+ if (idx !== void 0) {
170
+ pc = idx;
187
171
  }
172
+ }
188
173
  }
189
- return out;
174
+ }
175
+ return out;
190
176
  }
191
- /** Run compiled choreography on a single actor (with optional looping). */
192
177
  async function runSeq(fx, builderOrSteps, ctx = {}) {
193
- if (builderOrSteps instanceof ChoreoBuilder) {
194
- const loop = builderOrSteps.getLoop();
195
- if (loop === Infinity) {
196
- // Intentional infinite loop for unbounded choreography playback
197
- while (true) {
198
- const steps = compile(builderOrSteps, ctx);
199
- await animationHelper.runChoreo(fx, steps);
200
- }
201
- }
202
- else {
203
- const times = Math.max(1, loop !== null && loop !== void 0 ? loop : 1);
204
- for (let i = 0; i < times; i++) {
205
- const steps = compile(builderOrSteps, ctx);
206
- await animationHelper.runChoreo(fx, steps);
207
- }
208
- }
209
- }
210
- else {
211
- await animationHelper.runChoreo(fx, compile(builderOrSteps, ctx));
212
- }
178
+ if (builderOrSteps instanceof ChoreoBuilder) {
179
+ const loop = builderOrSteps.getLoop();
180
+ if (loop === Infinity) {
181
+ while (true) {
182
+ const steps = compile(builderOrSteps, ctx);
183
+ await animationHelper.runChoreo(fx, steps);
184
+ }
185
+ } else {
186
+ const times = Math.max(1, loop ?? 1);
187
+ for (let i = 0; i < times; i++) {
188
+ const steps = compile(builderOrSteps, ctx);
189
+ await animationHelper.runChoreo(fx, steps);
190
+ }
191
+ }
192
+ } else {
193
+ await animationHelper.runChoreo(fx, compile(builderOrSteps, ctx));
194
+ }
213
195
  }
214
196
  async function runChoreoWithDelay(fx, steps, delayMs) {
215
- if (delayMs > 0) {
216
- await new Promise((r) => setTimeout(r, delayMs));
217
- }
218
- await animationHelper.runChoreo(fx, steps);
197
+ if (delayMs > 0) {
198
+ await new Promise((r) => setTimeout(r, delayMs));
199
+ }
200
+ await animationHelper.runChoreo(fx, steps);
219
201
  }
220
- /** Wave pattern: stagger actors left→right. */
221
202
  async function runWave(actors, choreo, staggerMs = 220, ctx = {}) {
222
- const steps = compile(choreo, ctx);
223
- await Promise.all(actors.map((fx, i) => runChoreoWithDelay(fx, steps, i * Math.max(0, staggerMs))));
203
+ const steps = compile(choreo, ctx);
204
+ await Promise.all(
205
+ actors.map((fx, i) => runChoreoWithDelay(fx, steps, i * Math.max(0, staggerMs)))
206
+ );
224
207
  }
225
- /** Cannon pattern: wave left→right, then right→left. */
226
208
  async function runCannon(actors, choreo, staggerMs = 220, ctx = {}) {
227
- await runWave(actors, choreo, staggerMs, ctx);
228
- const reversed = [...actors].reverse();
229
- await runWave(reversed, choreo, staggerMs, ctx);
209
+ await runWave(actors, choreo, staggerMs, ctx);
210
+ const reversed = [...actors].reverse();
211
+ await runWave(reversed, choreo, staggerMs, ctx);
230
212
  }
231
- /** Assign programs to actors round-robin. */
232
213
  async function runRounds(actors, programs, staggerMs = 0, ctx = {}) {
233
- const jobs = actors.map((fx, i) => runChoreoWithDelay(fx, compile(programs[i % programs.length], ctx), staggerMs * i));
234
- await Promise.all(jobs);
214
+ const jobs = actors.map(
215
+ (fx, i) => runChoreoWithDelay(
216
+ fx,
217
+ compile(programs[i % programs.length], ctx),
218
+ staggerMs * i
219
+ )
220
+ );
221
+ await Promise.all(jobs);
235
222
  }
236
-
237
223
  exports.ChoreoBuilder = ChoreoBuilder;
238
224
  exports.compile = compile;
239
225
  exports.runCannon = runCannon;
@@ -1,38 +1,10 @@
1
- 'use strict';
2
-
3
- var choreoDSL = require('./choreoDSL.js');
4
-
5
- /** Wave + score reveal choreography. */
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const choreoDSL = require("./choreoDSL.js");
6
4
  const waveScoreChoreo = (score) => choreoDSL.seq().enterFromLeft(0.6).waveHand(600).raiseCard(score, 700).idle(200);
7
- /** Boo / disapproval choreography. */
8
5
  const booChoreo = choreoDSL.seq().angry(400).shouting(400).facepalm(350).exitLeft(0.6);
9
- /** Dance party loop. */
10
6
  const danceParty = choreoDSL.seq().danceA(350).danceB(350).danceC(350).loop(Infinity);
11
- /** Showcase all poses. */
12
- const showcaseAll = choreoDSL.seq()
13
- .idle(300)
14
- .happy(400)
15
- .angry(400)
16
- .disappointed(400)
17
- .swearing(400)
18
- .shouting(400)
19
- .rock(500)
20
- .danceA(350)
21
- .danceB(350)
22
- .danceC(350)
23
- .waveHand(600)
24
- .facepalm(500)
25
- .shrug(450)
26
- .nodYes(450)
27
- .shakeNo(450)
28
- .pointRight(400)
29
- .leanBack(400)
30
- .jump(450)
31
- .spin(650)
32
- .celebrate(600)
33
- .raiseCard(10, 800)
34
- .idle(400);
35
-
7
+ const showcaseAll = choreoDSL.seq().idle(300).happy(400).angry(400).disappointed(400).swearing(400).shouting(400).rock(500).danceA(350).danceB(350).danceC(350).waveHand(600).facepalm(500).shrug(450).nodYes(450).shakeNo(450).pointRight(400).leanBack(400).jump(450).spin(650).celebrate(600).raiseCard(10, 800).idle(400);
36
8
  exports.booChoreo = booChoreo;
37
9
  exports.danceParty = danceParty;
38
10
  exports.showcaseAll = showcaseAll;
@@ -1,93 +1,84 @@
1
- 'use strict';
2
-
3
- var choreoDSL = require('./choreoDSL.js');
4
-
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const choreoDSL = require("./choreoDSL.js");
5
4
  class ScoreBus {
6
- constructor() {
7
- this.target = new EventTarget();
8
- }
9
- push(score) {
10
- const e = { score, at: Date.now() };
11
- this.target.dispatchEvent(new CustomEvent('score', { detail: e }));
12
- }
13
- subscribe(handler) {
14
- const wrap = (ev) => handler(ev.detail);
15
- this.target.addEventListener('score', wrap);
16
- return () => this.target.removeEventListener('score', wrap);
17
- }
5
+ constructor() {
6
+ this.target = new EventTarget();
7
+ }
8
+ push(score) {
9
+ const e = { score, at: Date.now() };
10
+ this.target.dispatchEvent(new CustomEvent("score", { detail: e }));
11
+ }
12
+ subscribe(handler) {
13
+ const wrap = (ev) => handler(ev.detail);
14
+ this.target.addEventListener("score", wrap);
15
+ return () => this.target.removeEventListener("score", wrap);
16
+ }
18
17
  }
19
- /** Shared score event bus. */
20
18
  const scoreBus = new ScoreBus();
21
- /** Subscribe to score events with throttling + dedup. */
22
19
  function onScore(handler, opts = {}) {
23
- var _a, _b, _c;
24
- const min = (_a = opts.minIntervalMs) !== null && _a !== void 0 ? _a : 400;
25
- const dedupe = (_b = opts.dedupeWindowMs) !== null && _b !== void 0 ? _b : 800;
26
- const roundTo = Math.max(0, Math.floor((_c = opts.roundTo) !== null && _c !== void 0 ? _c : 1));
27
- let lastEventAt = 0;
28
- let lastRounded = null;
29
- let lastRoundedAt = 0;
30
- return scoreBus.subscribe((e) => {
31
- const now = e.at;
32
- if (now - lastEventAt < min) {
33
- return;
34
- }
35
- lastEventAt = now;
36
- const factor = Math.pow(10, roundTo);
37
- const rounded = (Math.round(e.score * factor) / factor).toFixed(roundTo);
38
- if (lastRounded && rounded === lastRounded && now - lastRoundedAt < dedupe) {
39
- return;
40
- }
41
- lastRounded = rounded;
42
- lastRoundedAt = now;
43
- handler(e.score);
44
- });
45
- }
46
- /** Map a score to a reaction choreography. */
47
- function reactionForScore(score, rng = Math.random) {
48
- const r = rng();
49
- if (score >= 8.5) {
50
- const strong = [
51
- choreoDSL.seq().happy(300).celebrate(600),
52
- choreoDSL.seq().danceA(300).danceB(300).celebrate(500),
53
- choreoDSL.seq().jump(400).raiseCard(score, 700),
54
- ];
55
- return strong[Math.floor(r * strong.length)];
20
+ const min = opts.minIntervalMs ?? 400;
21
+ const dedupe = opts.dedupeWindowMs ?? 800;
22
+ const roundTo = Math.max(0, Math.floor(opts.roundTo ?? 1));
23
+ let lastEventAt = 0;
24
+ let lastRounded = null;
25
+ let lastRoundedAt = 0;
26
+ return scoreBus.subscribe((e) => {
27
+ const now = e.at;
28
+ if (now - lastEventAt < min) {
29
+ return;
56
30
  }
57
- if (score >= 5.5) {
58
- const mid = [choreoDSL.seq().shrug(450), choreoDSL.seq().nodYes(450), choreoDSL.seq().leanBack(400)];
59
- return mid[Math.floor(r * mid.length)].raiseCard(score, 700);
31
+ lastEventAt = now;
32
+ const factor = Math.pow(10, roundTo);
33
+ const rounded = (Math.round(e.score * factor) / factor).toFixed(roundTo);
34
+ if (lastRounded && rounded === lastRounded && now - lastRoundedAt < dedupe) {
35
+ return;
60
36
  }
61
- const low = [
62
- choreoDSL.seq().angry(400).shouting(400),
63
- choreoDSL.seq().facepalm(500).disappointed(400),
64
- choreoDSL.seq().swearing(450).shakeNo(450),
37
+ lastRounded = rounded;
38
+ lastRoundedAt = now;
39
+ handler(e.score);
40
+ });
41
+ }
42
+ function reactionForScore(score, rng = Math.random) {
43
+ const r = rng();
44
+ if (score >= 8.5) {
45
+ const strong = [
46
+ choreoDSL.seq().happy(300).celebrate(600),
47
+ choreoDSL.seq().danceA(300).danceB(300).celebrate(500),
48
+ choreoDSL.seq().jump(400).raiseCard(score, 700)
65
49
  ];
66
- return low[Math.floor(r * low.length)].raiseCard(score, 900);
50
+ return strong[Math.floor(r * strong.length)];
51
+ }
52
+ if (score >= 5.5) {
53
+ const mid = [choreoDSL.seq().shrug(450), choreoDSL.seq().nodYes(450), choreoDSL.seq().leanBack(400)];
54
+ return mid[Math.floor(r * mid.length)].raiseCard(score, 700);
55
+ }
56
+ const low = [
57
+ choreoDSL.seq().angry(400).shouting(400),
58
+ choreoDSL.seq().facepalm(500).disappointed(400),
59
+ choreoDSL.seq().swearing(450).shakeNo(450)
60
+ ];
61
+ return low[Math.floor(r * low.length)].raiseCard(score, 900);
67
62
  }
68
- /** Play intro choreography for actors. */
69
63
  async function playIntro(actors) {
70
- if (!actors.length) {
71
- return;
72
- }
73
- const programs = [
74
- choreoDSL.seq().enterFromLeft(0.6).waveHand(600).raiseCard(9, 700).idle(200),
75
- choreoDSL.seq().enterFromRight(0.6).spin(600).danceA(400).idle(200),
76
- choreoDSL.seq().enterFromLeft(0.5).jump(450).pointRight(350).idle(200),
77
- choreoDSL.seq().enterFromRight(0.5).happy(300).raiseCard(10, 800),
78
- ];
79
- await choreoDSL.runRounds(actors, programs);
64
+ if (!actors.length) {
65
+ return;
66
+ }
67
+ const programs = [
68
+ choreoDSL.seq().enterFromLeft(0.6).waveHand(600).raiseCard(9, 700).idle(200),
69
+ choreoDSL.seq().enterFromRight(0.6).spin(600).danceA(400).idle(200),
70
+ choreoDSL.seq().enterFromLeft(0.5).jump(450).pointRight(350).idle(200),
71
+ choreoDSL.seq().enterFromRight(0.5).happy(300).raiseCard(10, 800)
72
+ ];
73
+ await choreoDSL.runRounds(actors, programs);
80
74
  }
81
- /** Emit a score event for testing. */
82
75
  const simulateScore = (score) => scoreBus.push(score);
83
- /** Attach score reactions to actors. */
84
76
  function attachScoreReactions(actors, opts = {}, rng = Math.random) {
85
- return onScore(async (score) => {
86
- const programs = actors.map(() => reactionForScore(score, rng));
87
- await choreoDSL.runRounds(actors, programs, 80, { score });
88
- }, opts);
77
+ return onScore(async (score) => {
78
+ const programs = actors.map(() => reactionForScore(score, rng));
79
+ await choreoDSL.runRounds(actors, programs, 80, { score });
80
+ }, opts);
89
81
  }
90
-
91
82
  exports.attachScoreReactions = attachScoreReactions;
92
83
  exports.onScore = onScore;
93
84
  exports.playIntro = playIntro;