@sarmal/core 0.13.0 → 0.15.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.
@@ -7,10 +7,8 @@ interface CurveDef {
7
7
  /**
8
8
  * The parametric function that defines the curve shape.
9
9
  * @param t Current position along the curve, in [0, period)
10
- * @param time Elapsed wall-clock time in seconds always increasing, never resets on period wrap
11
- * @param params Named parameter overrides.
12
- * Always `{}` today — reserved for the upcoming parameterized-curves feature.
13
- * Do NOT remove this parameter; it is intentional forward-compatible plumbing.
10
+ * @param time Elapsed actual time in seconds. It is always increasing, and never resets on period wrap
11
+ * @param params Named parameter overrides. intentional forward-compatible parameter
14
12
  */
15
13
  fn: (t: number, time: number, params: Record<string, number>) => Point;
16
14
  /**
@@ -218,12 +216,39 @@ interface SarmalInstance extends AnimationControls {
218
216
  * @returns Promise that resolves when the morph is complete
219
217
  */
220
218
  morphTo(target: CurveDef, options?: MorphOptions): Promise<void>;
219
+ /**
220
+ * Changes render options on a live SarmalInstance without destroying and recreating it.
221
+ *
222
+ * ! Validation fails the operation completely if any of the fields fail the chceck.
223
+ */
224
+ setRenderOptions(partial: RuntimeRenderOptions): void;
221
225
  }
222
226
  /**
223
227
  * With 'gradient-animated' the colors cycle along the trail over time
224
228
  */
225
229
  type TrailStyle = "default" | "gradient-static" | "gradient-animated";
226
- type PalettePreset = "bard" | "sunset" | "ocean" | "ice" | "fire" | "forest";
230
+ /**
231
+ * The value must be a single hex string or an array of hex strings.
232
+ *
233
+ * ! Named colors, shorthand hex, `rgb()`, and `hsl()` notations are not yet supported.
234
+ */
235
+ type TrailColor = string | string[];
236
+ /**
237
+ * Runtime-renderable options that can be changed on a live instance without destroying and recreating it.
238
+ *
239
+ * Passing `null` for `headColor`makes the head color derive its color from the current `trailColor` and `trailStyle`
240
+ * Passing a hex string locks the head color until overridden.
241
+ *
242
+ * Passing `"transparent"` for `skeletonColor` hides the skeleton. Any other value must be a valid {@link TrailColor}.
243
+ */
244
+ interface RuntimeRenderOptions {
245
+ trailColor?: TrailColor;
246
+ /** 6-digit hex string to override, or `null` to make it automatic */
247
+ headColor?: string | null;
248
+ /** 6-digit hex string, or `"transparent"` to hide the skeleton. */
249
+ skeletonColor?: string;
250
+ trailStyle?: TrailStyle;
251
+ }
227
252
  /**
228
253
  * Common renderer options shared between canvas and SVG renderers.
229
254
  * Extracted to avoid duplication and ensure consistency.
@@ -244,31 +269,27 @@ interface BaseRendererOptions {
244
269
  */
245
270
  skeletonColor?: string;
246
271
  /**
272
+ * Single hex color for default trails, or an array of hex colors for gradient trails.
247
273
  * @default '#ffffff'
248
274
  */
249
- trailColor?: string;
275
+ trailColor?: TrailColor;
250
276
  /**
251
- * @default '#ffffff'
277
+ * Hex color for the head dot.
278
+ * If omitted, the color is derived from the trail
252
279
  */
253
280
  headColor?: string;
254
281
  /** @default 4 */
255
282
  headRadius?: number;
256
- }
257
- interface RendererOptions extends BaseRendererOptions {
258
- /** Target canvas element that will contain the Sarmal */
259
- canvas: HTMLCanvasElement;
260
- engine: Engine;
261
283
  /**
262
284
  * Trail rendering style
263
285
  * @default 'default'
264
286
  */
265
287
  trailStyle?: TrailStyle;
266
- /**
267
- * Color palette for gradient trails
268
- * Can be a preset name or custom array of hex colors.
269
- * @default 'bard' for animated, 'ice' for static
270
- */
271
- palette?: PalettePreset | string[];
288
+ }
289
+ interface RendererOptions extends BaseRendererOptions {
290
+ /** Target canvas element that will contain the Sarmal */
291
+ canvas: HTMLCanvasElement;
292
+ engine: Engine;
272
293
  }
273
294
  interface SarmalOptions extends Omit<RendererOptions, "canvas" | "engine"> {
274
295
  /** @default 120 */
@@ -280,11 +301,12 @@ export type {
280
301
  CurveDef as C,
281
302
  Engine as E,
282
303
  JumpOptions as J,
283
- PalettePreset as P,
304
+ Point as P,
284
305
  RendererOptions as R,
285
306
  SarmalInstance as S,
286
- TrailStyle as T,
307
+ TrailColor as T,
287
308
  SarmalOptions as a,
288
- Point as b,
309
+ RuntimeRenderOptions as b,
289
310
  SeekOptions as c,
311
+ TrailStyle as d,
290
312
  };
@@ -7,10 +7,8 @@ interface CurveDef {
7
7
  /**
8
8
  * The parametric function that defines the curve shape.
9
9
  * @param t Current position along the curve, in [0, period)
10
- * @param time Elapsed wall-clock time in seconds always increasing, never resets on period wrap
11
- * @param params Named parameter overrides.
12
- * Always `{}` today — reserved for the upcoming parameterized-curves feature.
13
- * Do NOT remove this parameter; it is intentional forward-compatible plumbing.
10
+ * @param time Elapsed actual time in seconds. It is always increasing, and never resets on period wrap
11
+ * @param params Named parameter overrides. intentional forward-compatible parameter
14
12
  */
15
13
  fn: (t: number, time: number, params: Record<string, number>) => Point;
16
14
  /**
@@ -218,12 +216,39 @@ interface SarmalInstance extends AnimationControls {
218
216
  * @returns Promise that resolves when the morph is complete
219
217
  */
220
218
  morphTo(target: CurveDef, options?: MorphOptions): Promise<void>;
219
+ /**
220
+ * Changes render options on a live SarmalInstance without destroying and recreating it.
221
+ *
222
+ * ! Validation fails the operation completely if any of the fields fail the chceck.
223
+ */
224
+ setRenderOptions(partial: RuntimeRenderOptions): void;
221
225
  }
222
226
  /**
223
227
  * With 'gradient-animated' the colors cycle along the trail over time
224
228
  */
225
229
  type TrailStyle = "default" | "gradient-static" | "gradient-animated";
226
- type PalettePreset = "bard" | "sunset" | "ocean" | "ice" | "fire" | "forest";
230
+ /**
231
+ * The value must be a single hex string or an array of hex strings.
232
+ *
233
+ * ! Named colors, shorthand hex, `rgb()`, and `hsl()` notations are not yet supported.
234
+ */
235
+ type TrailColor = string | string[];
236
+ /**
237
+ * Runtime-renderable options that can be changed on a live instance without destroying and recreating it.
238
+ *
239
+ * Passing `null` for `headColor`makes the head color derive its color from the current `trailColor` and `trailStyle`
240
+ * Passing a hex string locks the head color until overridden.
241
+ *
242
+ * Passing `"transparent"` for `skeletonColor` hides the skeleton. Any other value must be a valid {@link TrailColor}.
243
+ */
244
+ interface RuntimeRenderOptions {
245
+ trailColor?: TrailColor;
246
+ /** 6-digit hex string to override, or `null` to make it automatic */
247
+ headColor?: string | null;
248
+ /** 6-digit hex string, or `"transparent"` to hide the skeleton. */
249
+ skeletonColor?: string;
250
+ trailStyle?: TrailStyle;
251
+ }
227
252
  /**
228
253
  * Common renderer options shared between canvas and SVG renderers.
229
254
  * Extracted to avoid duplication and ensure consistency.
@@ -244,31 +269,27 @@ interface BaseRendererOptions {
244
269
  */
245
270
  skeletonColor?: string;
246
271
  /**
272
+ * Single hex color for default trails, or an array of hex colors for gradient trails.
247
273
  * @default '#ffffff'
248
274
  */
249
- trailColor?: string;
275
+ trailColor?: TrailColor;
250
276
  /**
251
- * @default '#ffffff'
277
+ * Hex color for the head dot.
278
+ * If omitted, the color is derived from the trail
252
279
  */
253
280
  headColor?: string;
254
281
  /** @default 4 */
255
282
  headRadius?: number;
256
- }
257
- interface RendererOptions extends BaseRendererOptions {
258
- /** Target canvas element that will contain the Sarmal */
259
- canvas: HTMLCanvasElement;
260
- engine: Engine;
261
283
  /**
262
284
  * Trail rendering style
263
285
  * @default 'default'
264
286
  */
265
287
  trailStyle?: TrailStyle;
266
- /**
267
- * Color palette for gradient trails
268
- * Can be a preset name or custom array of hex colors.
269
- * @default 'bard' for animated, 'ice' for static
270
- */
271
- palette?: PalettePreset | string[];
288
+ }
289
+ interface RendererOptions extends BaseRendererOptions {
290
+ /** Target canvas element that will contain the Sarmal */
291
+ canvas: HTMLCanvasElement;
292
+ engine: Engine;
272
293
  }
273
294
  interface SarmalOptions extends Omit<RendererOptions, "canvas" | "engine"> {
274
295
  /** @default 120 */
@@ -280,11 +301,12 @@ export type {
280
301
  CurveDef as C,
281
302
  Engine as E,
282
303
  JumpOptions as J,
283
- PalettePreset as P,
304
+ Point as P,
284
305
  RendererOptions as R,
285
306
  SarmalInstance as S,
286
- TrailStyle as T,
307
+ TrailColor as T,
287
308
  SarmalOptions as a,
288
- Point as b,
309
+ RuntimeRenderOptions as b,
289
310
  SeekOptions as c,
311
+ TrailStyle as d,
290
312
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sarmal/core",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "description": "Curve path based loading indicators and their renderer",
5
5
  "keywords": [
6
6
  "animation",