@almadar/ui 5.85.0 → 5.87.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/dist/avl/index.cjs +139 -1415
- package/dist/avl/index.js +139 -1415
- package/dist/components/game/2d/molecules/index.d.ts +0 -2
- package/dist/components/game/shared/index.d.ts +0 -2
- package/dist/components/index.cjs +124 -1478
- package/dist/components/index.js +125 -1468
- package/dist/providers/index.cjs +109 -1385
- package/dist/providers/index.js +109 -1385
- package/dist/runtime/index.cjs +115 -1391
- package/dist/runtime/index.js +115 -1391
- package/package.json +1 -1
- package/dist/components/game/2d/organisms/CanvasEffect.d.ts +0 -70
- package/dist/components/game/shared/canvasEffects.d.ts +0 -50
- package/dist/components/game/shared/combatPresets.d.ts +0 -15
- package/dist/components/game/shared/hooks/useCanvasEffects.d.ts +0 -27
package/package.json
CHANGED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CanvasEffect Component
|
|
3
|
-
*
|
|
4
|
-
* Renders animated visual effects using a `<canvas>` element with
|
|
5
|
-
* sprite-based particles, frame-sequence animations, and overlays.
|
|
6
|
-
* This is a render-ui pattern that can be placed in any slot —
|
|
7
|
-
* it renders on top of whatever occupies that slot.
|
|
8
|
-
*
|
|
9
|
-
* Pattern: canvas-effect
|
|
10
|
-
*
|
|
11
|
-
* When an EffectAssetManifest is provided (via assetManifest prop),
|
|
12
|
-
* the component uses the full particle engine with tinted sprites.
|
|
13
|
-
* Without a manifest, it falls back to emoji-based rendering.
|
|
14
|
-
*
|
|
15
|
-
* **State categories (closed-circuit compliant):**
|
|
16
|
-
* - Configuration (actionType, position, duration, manifest) → received via props
|
|
17
|
-
* - Animation state (particles, shake, flash, RAF loop, phase timers) → local only
|
|
18
|
-
* - Completion event → emitted via `useEventBus()` for trait integration
|
|
19
|
-
*
|
|
20
|
-
* This is an **ephemeral fire-and-forget** animation component. All
|
|
21
|
-
* internal state is rendering-only (particle physics, screen shake decay,
|
|
22
|
-
* flash alpha, emoji phase timers). No game logic lives here.
|
|
23
|
-
*
|
|
24
|
-
* @packageDocumentation
|
|
25
|
-
*/
|
|
26
|
-
import * as React from 'react';
|
|
27
|
-
import type { AssetUrl, EventEmit } from '@almadar/core';
|
|
28
|
-
import type { CombatActionType, EffectAssetManifest } from '../../shared/effects';
|
|
29
|
-
import type { UiError } from '../../../core/atoms/types';
|
|
30
|
-
export type { CombatActionType } from '../../shared/effects';
|
|
31
|
-
export type { EffectAssetManifest } from '../../shared/effects';
|
|
32
|
-
export interface CanvasEffectProps {
|
|
33
|
-
/** The type of combat action to visualise */
|
|
34
|
-
actionType: CombatActionType;
|
|
35
|
-
/** Screen-space X position (center of the effect) */
|
|
36
|
-
x: number;
|
|
37
|
-
/** Screen-space Y position (center of the effect) */
|
|
38
|
-
y: number;
|
|
39
|
-
/** Duration in ms before auto-dismiss (default 2000 for canvas, 800 for emoji) */
|
|
40
|
-
duration?: number;
|
|
41
|
-
/** Optional intensity multiplier (1 = normal, 2 = double size/brightness) */
|
|
42
|
-
intensity?: number;
|
|
43
|
-
/** Callback when the effect animation completes */
|
|
44
|
-
onComplete?: () => void;
|
|
45
|
-
/** Declarative event: emits UI:{completeEvent} when the effect animation completes */
|
|
46
|
-
completeEvent?: EventEmit<Record<string, never>>;
|
|
47
|
-
/** Additional CSS classes */
|
|
48
|
-
className?: string;
|
|
49
|
-
/** Loading state indicator */
|
|
50
|
-
isLoading?: boolean;
|
|
51
|
-
/** Error state */
|
|
52
|
-
error?: UiError | null;
|
|
53
|
-
/** Sprite URL for the effect (emoji fallback mode).
|
|
54
|
-
* When set without assetManifest, renders this image instead of emoji. */
|
|
55
|
-
effectSpriteUrl?: AssetUrl;
|
|
56
|
-
/** Base URL for remote assets. Prepended to relative effectSpriteUrl paths. */
|
|
57
|
-
assetBaseUrl?: AssetUrl;
|
|
58
|
-
/** Full effect asset manifest for the sprite particle engine.
|
|
59
|
-
* When provided, enables the canvas-based particle system. */
|
|
60
|
-
assetManifest?: EffectAssetManifest;
|
|
61
|
-
/** Canvas width (default 400) */
|
|
62
|
-
width?: number;
|
|
63
|
-
/** Canvas height (default 300) */
|
|
64
|
-
height?: number;
|
|
65
|
-
}
|
|
66
|
-
export declare function CanvasEffect({ effectSpriteUrl, assetBaseUrl, ...props }: CanvasEffectProps): React.JSX.Element | null;
|
|
67
|
-
export declare namespace CanvasEffect {
|
|
68
|
-
var displayName: string;
|
|
69
|
-
}
|
|
70
|
-
export default CanvasEffect;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Canvas Effect Engine
|
|
3
|
-
*
|
|
4
|
-
* Pure functions for spawning, updating, and drawing canvas effects.
|
|
5
|
-
* No React dependencies — called from the RAF loop via useCanvasEffects hook.
|
|
6
|
-
*
|
|
7
|
-
* Ported from trait-wars and generalized for any almadar-ui client.
|
|
8
|
-
*/
|
|
9
|
-
import type { CanvasParticle, CanvasSequence, CanvasOverlay, CanvasEffectState, ParticleEmitterConfig, SequenceConfig, OverlayConfig } from './effects';
|
|
10
|
-
/**
|
|
11
|
-
* Draw a sprite tinted with an RGB color onto the main canvas.
|
|
12
|
-
* Uses offscreen canvas with `source-atop` compositing to recolor
|
|
13
|
-
* white-on-transparent sprites.
|
|
14
|
-
*/
|
|
15
|
-
export declare function drawTintedImage(ctx: CanvasRenderingContext2D, img: HTMLImageElement | ImageBitmap, x: number, y: number, w: number, h: number, tint: {
|
|
16
|
-
r: number;
|
|
17
|
-
g: number;
|
|
18
|
-
b: number;
|
|
19
|
-
}, alpha: number, blendMode?: GlobalCompositeOperation): void;
|
|
20
|
-
/**
|
|
21
|
-
* Spawn a burst of particles from an emitter config.
|
|
22
|
-
*/
|
|
23
|
-
export declare function spawnParticles(config: ParticleEmitterConfig, animTime: number): CanvasParticle[];
|
|
24
|
-
/**
|
|
25
|
-
* Spawn a frame sequence animation.
|
|
26
|
-
*/
|
|
27
|
-
export declare function spawnSequence(config: SequenceConfig, animTime: number): CanvasSequence;
|
|
28
|
-
/**
|
|
29
|
-
* Spawn an overlay effect.
|
|
30
|
-
*/
|
|
31
|
-
export declare function spawnOverlay(config: OverlayConfig, animTime: number): CanvasOverlay;
|
|
32
|
-
/**
|
|
33
|
-
* Advance effect state by one frame. Returns new state with expired effects removed.
|
|
34
|
-
*/
|
|
35
|
-
export declare function updateEffectState(state: CanvasEffectState, animTime: number, deltaMs: number): CanvasEffectState;
|
|
36
|
-
type GetImageFn = (url: string) => HTMLImageElement | undefined;
|
|
37
|
-
/**
|
|
38
|
-
* Draw all active effects onto the canvas.
|
|
39
|
-
*/
|
|
40
|
-
export declare function drawEffectState(ctx: CanvasRenderingContext2D, state: CanvasEffectState, animTime: number, getImage: GetImageFn): void;
|
|
41
|
-
export declare function hasActiveEffects(state: CanvasEffectState): boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Collect all sprite URLs from an EffectAssetManifest for preloading.
|
|
44
|
-
*/
|
|
45
|
-
export declare function getAllEffectSpriteUrls(manifest: {
|
|
46
|
-
baseUrl: string;
|
|
47
|
-
particles?: Record<string, string[] | string | undefined>;
|
|
48
|
-
animations?: Record<string, string[] | undefined>;
|
|
49
|
-
}): string[];
|
|
50
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Combat Presets
|
|
3
|
-
*
|
|
4
|
-
* Maps combat actions to composed effect layers (particles + sequences + overlays).
|
|
5
|
-
* Each preset factory takes a screen-space origin and returns a CombatPreset.
|
|
6
|
-
*
|
|
7
|
-
* Generalized from trait-wars: uses EffectAssetManifest instead of TraitWarsAssetManifest.
|
|
8
|
-
*/
|
|
9
|
-
import type { CombatActionType, CombatPreset, EffectAssetManifest } from './effects';
|
|
10
|
-
type PresetFactory = (originX: number, originY: number) => CombatPreset;
|
|
11
|
-
/**
|
|
12
|
-
* Create combat preset factories from an effect asset manifest.
|
|
13
|
-
*/
|
|
14
|
-
export declare function createCombatPresets(manifest: EffectAssetManifest): Record<CombatActionType, PresetFactory>;
|
|
15
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { AssetUrl } from '@almadar/core';
|
|
2
|
-
import type { CombatActionType, EffectAssetManifest } from '../effects';
|
|
3
|
-
export interface UseCanvasEffectsOptions {
|
|
4
|
-
/** Effect asset manifest (baseUrl + particles + animations) */
|
|
5
|
-
manifest: EffectAssetManifest;
|
|
6
|
-
}
|
|
7
|
-
export interface UseCanvasEffectsResult {
|
|
8
|
-
/** All effect sprite URLs for preloading via useImageCache */
|
|
9
|
-
effectSpriteUrls: AssetUrl[];
|
|
10
|
-
/** Spawn a combat effect at the given screen position */
|
|
11
|
-
spawnEffect: (type: CombatActionType, screenX: number, screenY: number) => void;
|
|
12
|
-
/** Draw all active effects — call inside draw() after units, before ctx.restore() */
|
|
13
|
-
drawEffects: (ctx: CanvasRenderingContext2D, animTime: number, getImage: (url: string) => HTMLImageElement | undefined) => void;
|
|
14
|
-
/** Whether there are active effects (keeps RAF alive) */
|
|
15
|
-
hasActiveEffects: boolean;
|
|
16
|
-
/** Screen shake offset to apply to container transform */
|
|
17
|
-
screenShake: {
|
|
18
|
-
x: number;
|
|
19
|
-
y: number;
|
|
20
|
-
};
|
|
21
|
-
/** Screen flash overlay (null = no flash) */
|
|
22
|
-
screenFlash: {
|
|
23
|
-
color: string;
|
|
24
|
-
alpha: number;
|
|
25
|
-
} | null;
|
|
26
|
-
}
|
|
27
|
-
export declare function useCanvasEffects({ manifest, }: UseCanvasEffectsOptions): UseCanvasEffectsResult;
|