tegaki 0.17.0 → 0.17.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # tegaki
2
2
 
3
+ ## 0.17.1
4
+
5
+ ### Patch Changes
6
+
7
+ - affe5a5: Add shorthand for setting time property to a percentage for controlled progress mode.
8
+
3
9
  ## 0.17.0
4
10
 
5
11
  ### Minor Changes
@@ -1,3 +1,3 @@
1
1
  import { S as TimedPoint, _ as TegakiEffectName, a as BBox, b as TegakiMultiEffectName, c as CSSLength, d as LineCap, f as PathCommand, g as TegakiEffectConfigs, h as TegakiBundle, i as ShapedGlyph, l as FontOutput, m as Stroke, o as BUNDLE_VERSION, p as Point, r as BundleShaper, s as COMPATIBLE_BUNDLE_VERSIONS, t as ShaperFactory, u as GlyphData, v as TegakiEffects, x as TegakiSingletonEffectName, y as TegakiGlyphData } from "../shaper-registry-DVS5R37Q.mjs";
2
- import { A as TimelineEntry, C as resolveEffects, D as computeTextLayout, E as computeLayoutBbox, O as Timeline, S as hasRenderHooks, T as TextLayout, _ as RenderStageContext, a as CreateElementFn, b as findEffects, c as TimeControlMode, d as getBundle, f as registerBundle, g as EffectDefinition, h as drawGlyph, i as TegakiEngine, j as computeTimeline, k as TimelineConfig, l as TimeControlProp, m as ensureFontFace, n as buildRootProps, o as TegakiEngineOptions, p as resolveBundle, r as domCreateElement, s as TegakiQuality, t as buildChildren, u as createBundle, v as ResolvedEffect, w as LayoutBBox, x as getEffectDefinition, y as findEffect } from "../index-vDGB0qjx.mjs";
2
+ import { A as TimelineEntry, C as resolveEffects, D as computeTextLayout, E as computeLayoutBbox, O as Timeline, S as hasRenderHooks, T as TextLayout, _ as RenderStageContext, a as CreateElementFn, b as findEffects, c as TimeControlMode, d as getBundle, f as registerBundle, g as EffectDefinition, h as drawGlyph, i as TegakiEngine, j as computeTimeline, k as TimelineConfig, l as TimeControlProp, m as ensureFontFace, n as buildRootProps, o as TegakiEngineOptions, p as resolveBundle, r as domCreateElement, s as TegakiQuality, t as buildChildren, u as createBundle, v as ResolvedEffect, w as LayoutBBox, x as getEffectDefinition, y as findEffect } from "../index-BRsSO7q7.mjs";
3
3
  export { BBox, BUNDLE_VERSION, BundleShaper, COMPATIBLE_BUNDLE_VERSIONS, CSSLength, CreateElementFn, EffectDefinition, FontOutput, GlyphData, LayoutBBox, LineCap, PathCommand, Point, RenderStageContext, ResolvedEffect, ShapedGlyph, ShaperFactory, Stroke, TegakiBundle, TegakiEffectConfigs, TegakiEffectName, TegakiEffects, TegakiEngine, TegakiEngineOptions, TegakiGlyphData, TegakiMultiEffectName, TegakiQuality, TegakiSingletonEffectName, TextLayout, TimeControlMode, TimeControlProp, TimedPoint, Timeline, TimelineConfig, TimelineEntry, buildChildren, buildRootProps, computeLayoutBbox, computeTextLayout, computeTimeline, createBundle, domCreateElement, drawGlyph, ensureFontFace, findEffect, findEffects, getBundle, getEffectDefinition, hasRenderHooks, registerBundle, resolveBundle, resolveEffects };
@@ -1,2 +1,2 @@
1
- import { _ as findEffect, a as createBundle, b as hasRenderHooks, c as resolveBundle, d as computeTimeline, f as computeLayoutBbox, h as drawGlyph, i as domCreateElement, l as BUNDLE_VERSION, m as ensureFontFace, n as buildChildren, o as getBundle, p as computeTextLayout, r as buildRootProps, s as registerBundle, t as TegakiEngine, u as COMPATIBLE_BUNDLE_VERSIONS, v as findEffects, x as resolveEffects, y as getEffectDefinition } from "../core-BrU5Htjs.mjs";
1
+ import { _ as findEffect, a as createBundle, b as hasRenderHooks, c as resolveBundle, d as computeTimeline, f as computeLayoutBbox, h as drawGlyph, i as domCreateElement, l as BUNDLE_VERSION, m as ensureFontFace, n as buildChildren, o as getBundle, p as computeTextLayout, r as buildRootProps, s as registerBundle, t as TegakiEngine, u as COMPATIBLE_BUNDLE_VERSIONS, v as findEffects, x as resolveEffects, y as getEffectDefinition } from "../core-Cbi21OMg.mjs";
2
2
  export { BUNDLE_VERSION, COMPATIBLE_BUNDLE_VERSIONS, TegakiEngine, buildChildren, buildRootProps, computeLayoutBbox, computeTextLayout, computeTimeline, createBundle, domCreateElement, drawGlyph, ensureFontFace, findEffect, findEffects, getBundle, getEffectDefinition, hasRenderHooks, registerBundle, resolveBundle, resolveEffects };
@@ -1425,13 +1425,34 @@ function getShaperForBundle(bundle) {
1425
1425
  }
1426
1426
  //#endregion
1427
1427
  //#region src/core/engine.ts
1428
+ /**
1429
+ * Parse a percentage string like `"50%"` into a 0–1 fraction. Returns `null`
1430
+ * for non-percentage strings or unparseable input. Whitespace around the
1431
+ * value is tolerated; the numeric part is parsed with `Number(...)`, so any
1432
+ * finite numeric form (including negatives and decimals) is accepted.
1433
+ */
1434
+ function parsePercentage(s) {
1435
+ const trimmed = s.trim();
1436
+ if (!trimmed.endsWith("%")) return null;
1437
+ const num = Number(trimmed.slice(0, -1));
1438
+ return Number.isFinite(num) ? num / 100 : null;
1439
+ }
1428
1440
  function resolveTimeControl(prop) {
1429
1441
  if (prop == null) return { mode: "uncontrolled" };
1430
1442
  if (typeof prop === "number") return {
1431
1443
  mode: "controlled",
1432
1444
  value: prop
1433
1445
  };
1434
- if (prop === "css") return { mode: "css" };
1446
+ if (typeof prop === "string") {
1447
+ if (prop === "css") return { mode: "css" };
1448
+ const pct = parsePercentage(prop);
1449
+ if (pct != null) return {
1450
+ mode: "controlled",
1451
+ value: pct,
1452
+ unit: "progress"
1453
+ };
1454
+ return { mode: "uncontrolled" };
1455
+ }
1435
1456
  return prop;
1436
1457
  }
1437
1458
  var TegakiEngine = class {
@@ -1599,9 +1620,20 @@ var TegakiEngine = class {
1599
1620
  this._playing = false;
1600
1621
  this._evaluatePlayback();
1601
1622
  }
1623
+ /**
1624
+ * Seek the (uncontrolled) timeline to an absolute time. Accepts seconds
1625
+ * (number) or a percentage string like `"50%"`, which is interpreted as
1626
+ * a fraction of the timeline's total duration.
1627
+ */
1602
1628
  seek(time) {
1603
1629
  if (this._timeControl.mode !== "uncontrolled") return;
1604
- this._internalTime = Math.max(0, Math.min(time, this._timeline.totalDuration));
1630
+ let resolved;
1631
+ if (typeof time === "string") {
1632
+ const pct = parsePercentage(time);
1633
+ if (pct == null) return;
1634
+ resolved = pct * this._timeline.totalDuration;
1635
+ } else resolved = time;
1636
+ this._internalTime = Math.max(0, Math.min(resolved, this._timeline.totalDuration));
1605
1637
  this._delayRemaining = 0;
1606
1638
  this._loopGapRemaining = 0;
1607
1639
  this._checkCompletion();
@@ -2130,4 +2162,4 @@ var TegakiEngine = class {
2130
2162
  //#endregion
2131
2163
  export { findEffect as _, createBundle as a, hasRenderHooks as b, resolveBundle as c, computeTimeline as d, computeLayoutBbox as f, coerceToString as g, drawGlyph as h, domCreateElement as i, BUNDLE_VERSION as l, ensureFontFace as m, buildChildren as n, getBundle as o, computeTextLayout as p, buildRootProps as r, registerBundle as s, TegakiEngine as t, COMPATIBLE_BUNDLE_VERSIONS as u, findEffects as v, resolveEffects as x, getEffectDefinition as y };
2132
2164
 
2133
- //# sourceMappingURL=core-BrU5Htjs.mjs.map
2165
+ //# sourceMappingURL=core-Cbi21OMg.mjs.map