@kubohiroya/turbowarp-bubble 0.3.1 → 0.5.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/README.md CHANGED
@@ -34,7 +34,7 @@ flowchart LR
34
34
 
35
35
  | 領域 | このREADMEで説明する内容 | 現在の公開API |
36
36
  | ----------------------------------- | ------------------------------------------------------------------------------ | ------------------------------------------------------------- |
37
- | 文字描画・改行 | 名前付きstyle、実測幅、`maxWidth`、UAX #14準拠の改行 | 実装済み(SVG Text capability) |
37
+ | 文字描画・改行 | `BubbleTextCapability`、名前付きstyle、実測幅、`maxWidth`、UAX #14準拠の改行 | 実装済み(TurboWarpではSVG Text adapterを標準接続) |
38
38
  | 逐次表示 | `CHARACTER`/`WORD`/`LINE`/`BLOCK`、区切り文字、単位ごとの効果音、finish条件 | 実装済み(`revealNext`/`revealAll`/`finish`、対応ブロック) |
39
39
  | portrait | ベース画像、`blink`、`lip-sync`の独立レイヤー | 実装済み(Asset Manager capability) |
40
40
  | Bubble外形 | `NORMAL`等のvisual style、placement、tail、offset、scale | 実装済み |
@@ -49,22 +49,25 @@ flowchart LR
49
49
 
50
50
  ```mermaid
51
51
  flowchart TB
52
- core[Bubble composition\n外形・配置・ライフサイクル・animation state]
53
- adapter[TurboWarp adapter\nrenderer / runtime / targetへの接続]
54
- text[SVG Text provider\n文字skin・計測・named style]
55
- image[Image capability\nportrait・blink・lip-sync・continue画像]
56
- audio[Audio capability\nvoice・表示単位ごとの効果音]
57
- input[Async Input + Runtime Expression\n入力と待機条件]
58
- extension[TurboWarp extension\nblocks / Scratch target]
59
- adapter --> core
60
- adapter --> text
61
- core -.任意Capability.-> image
62
- core -.任意Capability.-> audio
63
- extension --> core
64
- extension -.optional.-> input
52
+ core["Bubble core\n外形・配置・ライフサイクル・animation state"]
53
+ contract["BubbleTextCapability\nhost-neutralな文字契約"]
54
+ twAdapter["TurboWarp Bubble adapter\nrenderer / runtime / targetへの接続"]
55
+ svgAdapter["SVG Text adapter\nTurboWarpの文字skin・計測"]
56
+ assets["任意のImage / Audio capability\nportrait・lip-sync・音声"]
57
+ input["任意のInput / Expression capability\n入力・待機条件"]
58
+ host["独自Webアプリ / host"]
59
+ extension["TurboWarp extension\nblocks / Scratch target"]
60
+ core -->|"consumes"| contract
61
+ svgAdapter -->|"implements"| contract
62
+ twAdapter -->|"injects"| core
63
+ twAdapter -->|"uses by default"| svgAdapter
64
+ host -->|"injects"| core
65
+ core -."optional".-> assets
66
+ extension --> twAdapter
67
+ extension -."optional".-> input
65
68
  ```
66
69
 
67
- `@kubohiroya/turbowarp-svg-text`は文字のSVG skinと文字幅の測定を担当し、吹き出しの外枠、tail、portraitの配置、表示開始・表示終了animationは担当しません。画像解決、音声再生、入力、条件評価はCapabilityとして切り離し、Asset Manager、Async Input、Runtime Expressionはoptional peer dependencyとして対応機能を使う場合だけ接続します。
70
+ この構成では、Bubble coreが`BubbleTextCapability`というホスト非依存の契約だけを参照します。`@kubohiroya/turbowarp-svg-text`は、その契約をTurboWarpのSVG skin・named style・文字幅計測へ接続するadapterです。吹き出しの外枠、tail、portraitの配置、表示開始・表示終了animationは担当しません。TurboWarp adapterはSVG Text adapterを既定値として解決しますが、Composition APIのhostは別の実装を`textCapability`として注入できます。画像解決、音声再生、入力、条件評価もCapabilityとして切り離し、Asset Manager、Async Input、Runtime Expressionは対応機能を使う場合だけ接続します。
68
71
 
69
72
  ### 逐次表示の単位(CHARACTER / WORD / LINE / BLOCK)
70
73
 
@@ -146,13 +149,14 @@ Asset Managerを音声providerとして接続すると、次の音声を同じ
146
149
  | パッケージ | 責務 |
147
150
  | ------------------------------------------ | ------------------------------------------------------------------------------ |
148
151
  | `@kubohiroya/turbowarp-asset-manager` | 任意のImage/Audio capabilityをTurboWarp assetへ接続(画像解決・音声再生) |
149
- | `@kubohiroya/turbowarp-svg-text` | 名前付き文字styleと、文字列からSVGスキンへの変換 |
152
+ | Bubble core(`composition`) | `BubbleTextCapability`契約、吹き出しsurface、配置、逐次表示、animation |
153
+ | `@kubohiroya/turbowarp-svg-text` | `BubbleTextCapability`をTurboWarpの文字style・SVG skin・計測へ接続するadapter |
150
154
  | `@kubohiroya/turbowarp-async-input` | キー入力・タップをTemporary Variablesのruntime変数へ反映 |
151
155
  | `@kubohiroya/turbowarp-runtime-expression` | runtime変数を参照する安全な待機条件の評価 |
152
156
  | `@kubohiroya/turbowarp-bubble` | 吹き出しsurface、配置、逐次表示、say/think、表情レイヤー、animation、入力待機 |
153
157
  | アプリ/host | 必要に応じたアプリ固有の入力からcomposition APIへの変換 |
154
158
 
155
- Bubbleは依存パッケージを再exportしません。SVG Textは現在の文字描画に必要ですが、画像・音声・入力・条件評価はCapabilityとして差し替えられます。TurboWarp adapterではAsset Managerを自動接続し、Composition APIでは`imageResolver`/`audio`をhostが任意に実装できます。Asset Managerを使う機能は画像だけでなく、フルボイス、タイプライター音、行・段落ごとの効果音などの外部メディアも対象にします。
159
+ Bubbleは依存パッケージを再exportしません。Composition APIは`textCapability`を必須の契約として受け取り、SVG Textに限定されません。TurboWarp adapterだけが`@kubohiroya/turbowarp-svg-text`を既定のadapterとして解決します。画像・音声・入力・条件評価はCapabilityとして差し替えられ、TurboWarp adapterではAsset Managerを遅延接続し、Composition APIでは`imageResolver`/`audio`をhostが任意に実装できます。Asset Managerを使う機能は画像だけでなく、フルボイス、タイプライター音、行・段落ごとの効果音などの外部メディアも対象にします。
156
160
 
157
161
  ### 自動改行と禁則処理の基盤
158
162
 
@@ -193,16 +197,22 @@ standalone機能拡張では、`set bubble visual style`ブロックで形状を
193
197
  ### インストール
194
198
 
195
199
  ```sh
196
- pnpm add @kubohiroya/turbowarp-bubble @kubohiroya/turbowarp-svg-text
200
+ pnpm add @kubohiroya/turbowarp-bubble
197
201
  ```
198
202
 
199
203
  npmを使う場合は同じ依存を次のように追加します。
200
204
 
201
205
  ```sh
202
- npm install @kubohiroya/turbowarp-bubble @kubohiroya/turbowarp-svg-text
206
+ npm install @kubohiroya/turbowarp-bubble
203
207
  ```
204
208
 
205
- 現在のpeer dependency範囲は、SVG Textが`>=0.4.0 <1`、Asset Managerが`>=0.7.0 <1`、Async InputとRuntime Expressionがそれぞれ`>=0.3.0 <1`です。Asset Manager、Async Input、Runtime Expressionはoptional peer dependencyです。
209
+ 現在のpeer dependency範囲は、SVG Textが`>=0.4.0 <1`、Asset Managerが`>=0.7.0 <1`、Async InputとRuntime Expressionがそれぞれ`>=0.3.0 <1`です。4つすべてoptional peer dependencyで、SVG TextはTurboWarp adapterの既定adapterを使う場合だけ必要です。別の`textCapability`を注入するhostはSVG Textをインストールする必要がありません。
210
+
211
+ TurboWarp adapterの既定文字経路を使う場合は、SVG Textを追加します。
212
+
213
+ ```sh
214
+ pnpm add @kubohiroya/turbowarp-svg-text
215
+ ```
206
216
 
207
217
  画像portrait、lip-sync、continue indicator、または音声アセットを使う機能を利用する場合はAsset Managerを追加します。`CONDITION`付きの待機ブロックを使う場合はAsync InputとRuntime Expressionを追加します。
208
218
 
@@ -247,7 +257,7 @@ https://unpkg.com/@kubohiroya/turbowarp-async-input@0.3.0/dist/async-input.js
247
257
  https://unpkg.com/@kubohiroya/turbowarp-runtime-expression@0.3.0/dist/runtime-expression.js
248
258
 
249
259
  # Bubble(必ず最後)
250
- https://unpkg.com/@kubohiroya/turbowarp-bubble@0.3.1/dist/turbowarp-bubble.js
260
+ https://unpkg.com/@kubohiroya/turbowarp-bubble@0.5.0/dist/turbowarp-bubble.js
251
261
  ```
252
262
 
253
263
  TurboWarpのカスタム拡張機能はURLからJavaScriptを読み込むため、初回読み込み時にネットワーク接続が必要です。開発中は、リポジトリをローカルHTTPサーバーで配信して`dist/turbowarp-bubble.js`を指定できます。`file://`で直接開いたファイルや、サンドボックス付きの拡張機能としては動作しません。
@@ -436,23 +446,23 @@ import {
436
446
  createBubbleComposition,
437
447
  type BubbleImageCapability,
438
448
  type BubbleSurfaceFactory,
439
- type BubbleSvgText,
449
+ type BubbleTextCapability,
440
450
  } from "@kubohiroya/turbowarp-bubble/composition";
441
451
 
442
452
  // These are host-owned capabilities. They may be backed by Asset Manager,
443
453
  // another asset service, or local application code.
444
454
  declare const imageResolver: BubbleImageCapability;
445
- declare const svgText: BubbleSvgText;
455
+ declare const textCapability: BubbleTextCapability;
446
456
  declare const bubbleSurfaceHost: BubbleSurfaceFactory;
447
457
 
448
458
  const bubbles = createBubbleComposition({
449
459
  imageResolver,
450
- svgText,
460
+ textCapability,
451
461
  createSurface: bubbleSurfaceHost,
452
462
  });
453
463
  ```
454
464
 
455
- `declare`部分はサンプルを短くするための型宣言です。実際のhostでは、`BubbleSvgText`(文字skinの適用・解放)、`BubbleImageCapability`(画像名の解決)、`BubbleAudioCapability`(音声再生)、`BubbleSurfaceFactory`(外枠・text・portrait各targetの生成)を実装して渡します。TurboWarp runtimeを使う場合は、これらを個別に実装せず`createTurboWarpBubbleComposition(runtime)`を使えます。
465
+ `declare`部分はサンプルを短くするための型宣言です。実際のhostでは、`BubbleTextCapability`(文字skinの適用・計測・解放)、`BubbleImageCapability`(画像名の解決)、`BubbleAudioCapability`(音声再生)、`BubbleSurfaceFactory`(外枠・text・portrait各targetの生成)を実装して渡します。`@kubohiroya/turbowarp-svg-text/composition`を使う場合は、`createSvgTextCompositionCapability(createSvgTextComposition({ runtime }))`で`textCapability`へ変換します。TurboWarp runtimeを使う場合は、これらを個別に実装せず`createTurboWarpBubbleComposition(runtime)`を使えます。
456
466
 
457
467
  テキストだけを表示する場合は、Asset Managerのimport、`createAssetManagerComposition()`、`imageResolver`プロパティをすべて省略できます。Asset Managerは画像だけでなく、フルボイス、タイプライター音、行・段落ごとの効果音を登録・再生するためのメディア経路として利用します。音声付きBubble APIは表示機能と同じ名前付きアセットを使う設計にします。
458
468
 
@@ -460,7 +470,7 @@ const bubbles = createBubbleComposition({
460
470
 
461
471
  surfaceは`updateStyle(style)`も実装し、吹き出しの位置・形状・サイズを更新できるようにします。表示中のBubbleのstyleを変更する場合は、返されたhandleの`updateStyle(style)`を呼び出します。更新後のstyleで画像レイヤーを使う場合、surfaceが対応するtargetをあらかじめ返している必要があります。
462
472
 
463
- - `text`: SVG Textが文字スキンを適用するtarget
473
+ - `text`: `textCapability`が文字スキンを適用するtarget
464
474
  - `portraitBase`: キャラクター表情のベース画像target
465
475
  - `portraitBlink`: 目パチ差分target
466
476
  - `portraitLipSync`: 口パク差分target
@@ -551,7 +561,7 @@ await bubble.finish({
551
561
  await bubble.close();
552
562
  ```
553
563
 
554
- 返されたhandleの`setText(text)`は同じsurface上の本文を更新し、文字送りなどに利用できます。`handle.updateStyle(style)`は表示中のBubbleへstyle変更を即時適用します。同じ`actorKey`へ新しいBubbleを表示すると、以前のBubbleを完全に破棄してから置き換えます。`releaseTarget`、`releaseAll`、`dispose`も、所有するtimer、SVG Text target、surfaceを解放します。composition間で状態は共有しません。
564
+ 返されたhandleの`setText(text)`は同じsurface上の本文を更新し、文字送りなどに利用できます。`handle.updateStyle(style)`は表示中のBubbleへstyle変更を即時適用します。同じ`actorKey`へ新しいBubbleを表示すると、以前のBubbleを完全に破棄してから置き換えます。`releaseTarget`、`releaseAll`、`dispose`も、所有するtimer、text capability target、surfaceを解放します。composition間で状態は共有しません。
555
565
 
556
566
  ## ライセンスとソースコード
557
567
 
@@ -4218,7 +4218,7 @@ function Ur(e) {
4218
4218
  return e;
4219
4219
  }
4220
4220
  function Wr(e) {
4221
- if (!Q(e) || typeof e.setText != "function" || typeof e.releaseTarget != "function") throw TypeError("Bubble SVG Text composition must provide setText and releaseTarget.");
4221
+ if (!Q(e) || typeof e.setText != "function" || typeof e.releaseTarget != "function") throw TypeError("Bubble text capability must provide setText and releaseTarget.");
4222
4222
  return e;
4223
4223
  }
4224
4224
  function Gr() {
@@ -4236,7 +4236,7 @@ function qr(e, t) {
4236
4236
  return e;
4237
4237
  }
4238
4238
  function Jr(e) {
4239
- if (!Q(e) || typeof e.drawableID != "number" || !Number.isInteger(e.drawableID) || e.drawableID < 0) throw new Z("BUBBLE-COMPOSITION-004", "Bubble text target must provide a non-negative integer drawableID.");
4239
+ if (typeof e != "object" || !e) throw new Z("BUBBLE-COMPOSITION-004", "Bubble text target must be a non-null object.");
4240
4240
  return e;
4241
4241
  }
4242
4242
  function Yr(e, t) {
@@ -4352,7 +4352,7 @@ function ni(e) {
4352
4352
  }
4353
4353
  function ri(e) {
4354
4354
  if (!Q(e)) throw TypeError("Bubble composition options must be an object.");
4355
- let t = Vr(e.imageResolver), n = Hr(e.audio), r = Wr(e.svgText);
4355
+ let t = Vr(e.imageResolver), n = Hr(e.audio), r = Wr(e.textCapability);
4356
4356
  if (typeof e.createSurface != "function") throw TypeError("Bubble composition createSurface must be a function.");
4357
4357
  if (e.onAnimationError !== void 0 && typeof e.onAnimationError != "function") throw TypeError("Bubble composition onAnimationError must be a function.");
4358
4358
  let i = Kr(e.scheduler ?? Gr()), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = !1, l = () => {
@@ -4201,7 +4201,7 @@ function Br(e) {
4201
4201
  return e;
4202
4202
  }
4203
4203
  function Vr(e) {
4204
- if (!Q(e) || typeof e.setText != "function" || typeof e.releaseTarget != "function") throw TypeError("Bubble SVG Text composition must provide setText and releaseTarget.");
4204
+ if (!Q(e) || typeof e.setText != "function" || typeof e.releaseTarget != "function") throw TypeError("Bubble text capability must provide setText and releaseTarget.");
4205
4205
  return e;
4206
4206
  }
4207
4207
  function Hr() {
@@ -4219,7 +4219,7 @@ function Wr(e, t) {
4219
4219
  return e;
4220
4220
  }
4221
4221
  function Gr(e) {
4222
- if (!Q(e) || typeof e.drawableID != "number" || !Number.isInteger(e.drawableID) || e.drawableID < 0) throw new Z("BUBBLE-COMPOSITION-004", "Bubble text target must provide a non-negative integer drawableID.");
4222
+ if (typeof e != "object" || !e) throw new Z("BUBBLE-COMPOSITION-004", "Bubble text target must be a non-null object.");
4223
4223
  return e;
4224
4224
  }
4225
4225
  function Kr(e, t) {
@@ -4335,7 +4335,7 @@ function $r(e) {
4335
4335
  }
4336
4336
  function ei(e) {
4337
4337
  if (!Q(e)) throw TypeError("Bubble composition options must be an object.");
4338
- let t = Rr(e.imageResolver), n = zr(e.audio), r = Vr(e.svgText);
4338
+ let t = Rr(e.imageResolver), n = zr(e.audio), r = Vr(e.textCapability);
4339
4339
  if (typeof e.createSurface != "function") throw TypeError("Bubble composition createSurface must be a function.");
4340
4340
  if (e.onAnimationError !== void 0 && typeof e.onAnimationError != "function") throw TypeError("Bubble composition onAnimationError must be a function.");
4341
4341
  let i = Ur(e.scheduler ?? Hr()), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = !1, l = () => {
@@ -4676,18 +4676,67 @@ function ei(e) {
4676
4676
  });
4677
4677
  }
4678
4678
  //#endregion
4679
+ //#region src/turbowarp-svg-text-adapter.ts
4680
+ function ti(e) {
4681
+ return typeof e == "object" && !!e && !Array.isArray(e);
4682
+ }
4683
+ function ni(e) {
4684
+ if (!ti(e) || typeof e.setText != "function" || typeof e.releaseTextActor != "function") throw TypeError("TurboWarp SVG Text adapter requires setText and releaseTextActor.");
4685
+ return e;
4686
+ }
4687
+ function ri(e) {
4688
+ if (!ti(e) || typeof e.setText != "function" || typeof e.releaseTarget != "function") throw TypeError("SVG Text composition adapter requires setText and releaseTarget.");
4689
+ return e;
4690
+ }
4691
+ function ii(e) {
4692
+ let t = ni(e);
4693
+ return Object.freeze({
4694
+ setText({ styleName: e, target: n, text: r }) {
4695
+ t.setText({
4696
+ STYLE: e,
4697
+ TEXT: r
4698
+ }, { target: n });
4699
+ },
4700
+ releaseTarget(e) {
4701
+ t.releaseTextActor(e);
4702
+ },
4703
+ measureText({ styleName: e, text: n }) {
4704
+ if (typeof t.measureText != "function") throw Error("TurboWarp SVG Text does not provide text measurement.");
4705
+ return t.measureText(e, n);
4706
+ }
4707
+ });
4708
+ }
4709
+ function ai(e) {
4710
+ let t = ri(e), n = {
4711
+ setText({ styleName: e, target: n, text: r }) {
4712
+ t.setText({
4713
+ styleName: e,
4714
+ target: n,
4715
+ text: r
4716
+ });
4717
+ },
4718
+ releaseTarget(e) {
4719
+ t.releaseTarget(e);
4720
+ }
4721
+ };
4722
+ return typeof t.measureText == "function" && (n.measureText = ({ styleName: e, text: n }) => t.measureText?.({
4723
+ styleName: e,
4724
+ text: n
4725
+ }) ?? 0), Object.freeze(n);
4726
+ }
4727
+ //#endregion
4679
4728
  //#region src/turbowarp-adapter.ts
4680
- var ti = "sprite", ni = 96, ri = 18, ii = 8, ai = 16, oi = 0, $ = class extends Error {
4729
+ var oi = "sprite", si = 96, ci = 18, li = 8, ui = 16, di = 0, $ = class extends Error {
4681
4730
  code;
4682
4731
  constructor(e, t) {
4683
4732
  super(t), this.name = "BubbleRuntimeAdapterError", this.code = e;
4684
4733
  }
4685
4734
  };
4686
- function si(e) {
4735
+ function fi(e) {
4687
4736
  return typeof e == "object" && !!e && !Array.isArray(e);
4688
4737
  }
4689
- function ci(e) {
4690
- if (!si(e)) throw new $("BUBBLE-RUNTIME-001", "Bubble requires the TurboWarp renderer.");
4738
+ function pi(e) {
4739
+ if (!fi(e)) throw new $("BUBBLE-RUNTIME-001", "Bubble requires the TurboWarp renderer.");
4691
4740
  let t = [
4692
4741
  "createSVGSkin",
4693
4742
  "createDrawable",
@@ -4703,15 +4752,11 @@ function ci(e) {
4703
4752
  if (t.some((t) => typeof e[t] != "function")) throw new $("BUBBLE-RUNTIME-001", `Bubble renderer must provide ${t.join(", ")}.`);
4704
4753
  return e;
4705
4754
  }
4706
- function li(e) {
4707
- if (!si(e) || typeof e.isLoaded != "function" || typeof e.getAssetMimeType != "function" || typeof e.resolveSkin != "function") throw new $("BUBBLE-RUNTIME-002", "Bubble image assets require an imageResolver capability. Load @kubohiroya/turbowarp-asset-manager or provide options.imageResolver before using image features.");
4708
- return e;
4709
- }
4710
- function ui(e) {
4711
- if (!si(e) || typeof e.setText != "function" || typeof e.releaseTextActor != "function") throw new $("BUBBLE-RUNTIME-003", "Bubble requires SVG Text. Load @kubohiroya/turbowarp-svg-text before using Bubble blocks.");
4755
+ function mi(e) {
4756
+ if (!fi(e) || typeof e.isLoaded != "function" || typeof e.getAssetMimeType != "function" || typeof e.resolveSkin != "function") throw new $("BUBBLE-RUNTIME-002", "Bubble image assets require an imageResolver capability. Load @kubohiroya/turbowarp-asset-manager or provide options.imageResolver before using image features.");
4712
4757
  return e;
4713
4758
  }
4714
- function di(e) {
4759
+ function hi(e) {
4715
4760
  try {
4716
4761
  let t = e.getBoundsForBubble?.();
4717
4762
  if (t && [
@@ -4729,7 +4774,7 @@ function di(e) {
4729
4774
  top: n
4730
4775
  };
4731
4776
  }
4732
- function fi(e, t, n) {
4777
+ function gi(e, t, n) {
4733
4778
  let r = e.getCurrentSkinSize(t.drawableID);
4734
4779
  if (!Array.isArray(r) || r.length < 2) return n;
4735
4780
  let i = Number(r[0]), a = Number(r[1]);
@@ -4738,11 +4783,11 @@ function fi(e, t, n) {
4738
4783
  height: a
4739
4784
  };
4740
4785
  }
4741
- function pi(e) {
4786
+ function _i(e) {
4742
4787
  return Math.max(0, Math.min(1, e));
4743
4788
  }
4744
- function mi(e, t) {
4745
- let n = pi(e);
4789
+ function vi(e, t) {
4790
+ let n = _i(e);
4746
4791
  switch (t) {
4747
4792
  case "linear": return n;
4748
4793
  case "easeIn": return n * n;
@@ -4751,14 +4796,14 @@ function mi(e, t) {
4751
4796
  default: return n;
4752
4797
  }
4753
4798
  }
4754
- function hi(e, t, n) {
4799
+ function yi(e, t, n) {
4755
4800
  let r = Math.max(0, t * 1e3);
4756
4801
  return r === 0 ? (n(1), Promise.resolve()) : new Promise((t, i) => {
4757
4802
  let a = 0, o, s = () => {
4758
4803
  let c = Math.min(16, r - a);
4759
4804
  a += c;
4760
4805
  try {
4761
- n(pi(a / r));
4806
+ n(_i(a / r));
4762
4807
  } catch (t) {
4763
4808
  o !== void 0 && e.clearTimeout(o), i(t);
4764
4809
  return;
@@ -4772,8 +4817,8 @@ function hi(e, t, n) {
4772
4817
  o = e.setTimeout(s, Math.min(16, r));
4773
4818
  });
4774
4819
  }
4775
- function gi(e, t, n, r = 1) {
4776
- let i = fi(e, t, {
4820
+ function bi(e, t, n, r = 1) {
4821
+ let i = gi(e, t, {
4777
4822
  width: n,
4778
4823
  height: n
4779
4824
  }), a = Math.min(n / i.width, n / i.height) * r;
@@ -4782,29 +4827,29 @@ function gi(e, t, n, r = 1) {
4782
4827
  height: i.height * a
4783
4828
  };
4784
4829
  }
4785
- function _i(e, t, n) {
4830
+ function xi(e, t, n) {
4786
4831
  return n < t ? (t + n) / 2 : Math.min(n, Math.max(t, e));
4787
4832
  }
4788
- function vi(e, t, n, r, i) {
4833
+ function Si(e, t, n, r, i) {
4789
4834
  let a = t + r * 2, o = n + i * 2;
4790
4835
  return e.replace(/<svg\b[^>]*>/u, (e) => e.replace(/\bwidth="[^"]*"/u, `width="${a}"`).replace(/\bheight="[^"]*"/u, `height="${o}"`).replace(/\bviewBox="[^"]*"/u, `viewBox="${-r} ${-i} ${a} ${o}"`));
4791
4836
  }
4792
- function yi(e) {
4837
+ function Ci(e) {
4793
4838
  let t = v(e);
4794
4839
  return (Math.atan2(-t.x, -t.y) * 180 / Math.PI % 360 + 360) % 360;
4795
4840
  }
4796
- function bi(e, t, n, r, i) {
4797
- let a = e.renderer, o = oi;
4798
- oi += 1;
4841
+ function wi(e, t, n, r, i) {
4842
+ let a = e.renderer, o = di;
4843
+ di += 1;
4799
4844
  let s = [], c, l = (e) => {
4800
- let t = a.createDrawable(ti);
4845
+ let t = a.createDrawable(oi);
4801
4846
  if (!Number.isInteger(t) || t < 0) throw new $("BUBBLE-RUNTIME-001", `TurboWarp did not create the Bubble ${e} drawable.`);
4802
4847
  let r = Object.freeze({
4803
4848
  id: `bubble:${n}:${o}:${e}`,
4804
4849
  isStage: !1,
4805
4850
  drawableID: t
4806
4851
  });
4807
- return s.push(r), a.updateDrawableVisible(t, !1), a.setDrawableOrder?.(t, Infinity, ti), r;
4852
+ return s.push(r), a.updateDrawableVisible(t, !1), a.setDrawableOrder?.(t, Infinity, oi), r;
4808
4853
  };
4809
4854
  try {
4810
4855
  let n = l("body"), o = r.portrait ? l("portrait-base") : void 0, u = r.portrait?.blink ? l("portrait-blink") : void 0, d = r.portrait?.lipSync ? l("portrait-lip-sync") : void 0, f = l("text"), p = r.continueIndicator ? l("continue-indicator") : void 0, m = Object.freeze({
@@ -4829,7 +4874,7 @@ function bi(e, t, n, r, i) {
4829
4874
  A(), e.requestRedraw?.();
4830
4875
  }, M = () => {
4831
4876
  if (y) return;
4832
- let e = x.placement.basis === "actor" ? x.offset.scalePercent / 100 : 1, r = S ?? fi(a, f, {
4877
+ let e = x.placement.basis === "actor" ? x.offset.scalePercent / 100 : 1, r = S ?? gi(a, f, {
4833
4878
  width: 180,
4834
4879
  height: 48
4835
4880
  });
@@ -4837,19 +4882,19 @@ function bi(e, t, n, r, i) {
4837
4882
  let i = {
4838
4883
  width: r.width * e,
4839
4884
  height: r.height * e
4840
- }, s = o ? gi(a, o, ni, e) : {
4885
+ }, s = o ? bi(a, o, si, e) : {
4841
4886
  width: 0,
4842
4887
  height: 0
4843
4888
  };
4844
- for (let t of [u, d]) t && gi(a, t, ni, e);
4845
- let l = p ? gi(a, p, ri, e) : {
4889
+ for (let t of [u, d]) t && bi(a, t, si, e);
4890
+ let l = p ? bi(a, p, ci, e) : {
4846
4891
  width: 0,
4847
4892
  height: 0
4848
- }, m = s.width + (o ? ii * e : 0) + i.width, h = Math.max(s.height, i.height), g = m / e + 48, _ = h / e + 48, v = m, E = h, D = a.getNativeSize(), O = Array.isArray(D) && Number(D[0]) > 0 ? Number(D[0]) : 480, M = Array.isArray(D) && Number(D[1]) > 0 ? Number(D[1]) : 360, N = -O / 2, ee = O / 2, P = M / 2, te = -M / 2, ne = N + v / 2, re = ee - v / 2, ie = te + E / 2, F = P - E / 2, I, L;
4849
- if (x.placement.basis === "background") I = 0, L = x.placement.region === "HEADER_LIKE" ? P - ai - E / 2 : x.placement.region === "FOOTER_LIKE" ? te + ai + E / 2 : 0;
4893
+ }, m = s.width + (o ? li * e : 0) + i.width, h = Math.max(s.height, i.height), g = m / e + 48, _ = h / e + 48, v = m, E = h, D = a.getNativeSize(), O = Array.isArray(D) && Number(D[0]) > 0 ? Number(D[0]) : 480, M = Array.isArray(D) && Number(D[1]) > 0 ? Number(D[1]) : 360, N = -O / 2, ee = O / 2, P = M / 2, te = -M / 2, ne = N + v / 2, re = ee - v / 2, ie = te + E / 2, F = P - E / 2, I, L;
4894
+ if (x.placement.basis === "background") I = 0, L = x.placement.region === "HEADER_LIKE" ? P - ui - E / 2 : x.placement.region === "FOOTER_LIKE" ? te + ui + E / 2 : 0;
4850
4895
  else {
4851
4896
  let e = w({
4852
- bounds: di(t),
4897
+ bounds: hi(t),
4853
4898
  bubbleWidth: v,
4854
4899
  bubbleHeight: E,
4855
4900
  direction: x.placement.direction,
@@ -4859,8 +4904,8 @@ function bi(e, t, n, r, i) {
4859
4904
  });
4860
4905
  I = e.x, L = e.y;
4861
4906
  }
4862
- I = _i(I, ne, re), L = _i(L, ie, F);
4863
- let R = x.placement.basis === "actor" ? yi(x.placement.direction) : null, ae = x.placement.basis === "actor" ? [
4907
+ I = xi(I, ne, re), L = xi(L, ie, F);
4908
+ let R = x.placement.basis === "actor" ? Ci(x.placement.direction) : null, ae = x.placement.basis === "actor" ? [
4864
4909
  x.offset.x,
4865
4910
  x.offset.y,
4866
4911
  x.offset.scalePercent
@@ -4890,7 +4935,7 @@ function bi(e, t, n, r, i) {
4890
4935
  shapeTransition: k
4891
4936
  });
4892
4937
  if (le !== b) {
4893
- let e = vi(ge({
4938
+ let e = Si(ge({
4894
4939
  style: x.visualStyle,
4895
4940
  lines: [],
4896
4941
  width: g,
@@ -4911,17 +4956,17 @@ function bi(e, t, n, r, i) {
4911
4956
  c = t, b = le, r !== void 0 && a.destroySkin(r);
4912
4957
  }
4913
4958
  a.updateDrawableScale(n.drawableID, [100, 100]), a.updateDrawablePosition(n.drawableID, [I - oe.x, L + oe.y]);
4914
- let ue = I - m / 2, de = ue + s.width / 2, fe = ue + s.width + (o ? ii * e : 0) + i.width / 2;
4959
+ let ue = I - m / 2, de = ue + s.width / 2, fe = ue + s.width + (o ? li * e : 0) + i.width / 2;
4915
4960
  for (let e of [
4916
4961
  o,
4917
4962
  u,
4918
4963
  d
4919
4964
  ]) e && a.updateDrawablePosition(e.drawableID, [de, L]);
4920
- a.updateDrawablePosition(f.drawableID, [fe, L]), p && a.updateDrawablePosition(p.drawableID, [fe + i.width / 2 - l.width / 2 - ii * e, L - i.height / 2 + l.height / 2 + ii * e]);
4965
+ a.updateDrawablePosition(f.drawableID, [fe, L]), p && a.updateDrawablePosition(p.drawableID, [fe + i.width / 2 - l.width / 2 - li * e, L - i.height / 2 + l.height / 2 + li * e]);
4921
4966
  let pe = (e, t) => {
4922
4967
  e && C.set(e.drawableID, t);
4923
4968
  };
4924
- pe(n, [I - oe.x, L + oe.y]), pe(f, [fe, L]), pe(o, [de, L]), pe(u, [de, L]), pe(d, [de, L]), T.set(n.drawableID, [100, 100]), T.set(f.drawableID, [e * 100, e * 100]), o && T.set(o.drawableID, [e * 100, e * 100]), u && T.set(u.drawableID, [e * 100, e * 100]), d && T.set(d.drawableID, [e * 100, e * 100]), p && T.set(p.drawableID, [e * 100, e * 100]), p && pe(p, [fe + i.width / 2 - l.width / 2 - ii * e, L - i.height / 2 + l.height / 2 + ii * e]), A(), j();
4969
+ pe(n, [I - oe.x, L + oe.y]), pe(f, [fe, L]), pe(o, [de, L]), pe(u, [de, L]), pe(d, [de, L]), T.set(n.drawableID, [100, 100]), T.set(f.drawableID, [e * 100, e * 100]), o && T.set(o.drawableID, [e * 100, e * 100]), u && T.set(u.drawableID, [e * 100, e * 100]), d && T.set(d.drawableID, [e * 100, e * 100]), p && T.set(p.drawableID, [e * 100, e * 100]), p && pe(p, [fe + i.width / 2 - l.width / 2 - li * e, L - i.height / 2 + l.height / 2 + li * e]), A(), j();
4925
4970
  }, N = t.onTargetVisualChange, ee = (e) => {
4926
4971
  N?.(e), M();
4927
4972
  };
@@ -4938,7 +4983,7 @@ function bi(e, t, n, r, i) {
4938
4983
  n && !r ? t.onTargetVisualChange === ee && (t.onTargetVisualChange = N ?? null) : !n && r && (t.onTargetVisualChange = ee), M();
4939
4984
  },
4940
4985
  captureTextLayout() {
4941
- y || (S = fi(a, f, {
4986
+ y || (S = gi(a, f, {
4942
4987
  width: 180,
4943
4988
  height: 48
4944
4989
  }), M());
@@ -4950,11 +4995,11 @@ function bi(e, t, n, r, i) {
4950
4995
  if (y) return;
4951
4996
  let t = Math.max(0, e.durationSeconds ?? 0), n = () => {
4952
4997
  y || (A(), j());
4953
- }, r = (t) => mi(t, e.ease ?? "easeInOut");
4998
+ }, r = (t) => vi(t, e.ease ?? "easeInOut");
4954
4999
  if (e.name === "fadeIn" || e.name === "floatIn" || e.name === "zoomIn" || e.name === "riseUp") {
4955
5000
  _ = !0;
4956
5001
  let a = e.name === "floatIn" || e.name === "riseUp" ? [0, 16] : [0, 0], o = e.name === "zoomIn" ? .01 : 1;
4957
- E = a, D = o, O = e.name === "fadeIn" ? 0 : 1, n(), await hi(i, t, (t) => {
5002
+ E = a, D = o, O = e.name === "fadeIn" ? 0 : 1, n(), await yi(i, t, (t) => {
4958
5003
  let i = r(t);
4959
5004
  E = [a[0] * (1 - i), a[1] * (1 - i)], D = o + (1 - o) * i, O = e.name === "fadeIn" ? i : 1, n();
4960
5005
  }), E = [0, 0], D = 1, O = 1, M();
@@ -4962,7 +5007,7 @@ function bi(e, t, n, r, i) {
4962
5007
  }
4963
5008
  if (e.name === "fadeOut" || e.name === "floatOut" || e.name === "zoomOut" || e.name === "sink") {
4964
5009
  let a = e.name === "floatOut" || e.name === "sink" ? [0, -16] : [0, 0], o = e.name === "zoomOut" ? .01 : 1;
4965
- E = [0, 0], D = 1, O = 1, n(), await hi(i, t, (t) => {
5010
+ E = [0, 0], D = 1, O = 1, n(), await yi(i, t, (t) => {
4966
5011
  let i = r(t);
4967
5012
  E = [a[0] * i, a[1] * i], D = 1 + (o - 1) * i, O = e.name === "fadeOut" ? 1 - i : 1, n();
4968
5013
  }), E = a, D = o, O = e.name === "fadeOut" ? 0 : 1, n(), _ = !1, j(), E = [0, 0], D = 1, O = 1;
@@ -4970,7 +5015,7 @@ function bi(e, t, n, r, i) {
4970
5015
  }
4971
5016
  if (e.name === "shake") {
4972
5017
  let a = Math.max(1, Math.floor(e.count ?? 1)), o = t > 0 ? t : a * .08, s = v(typeof e.direction == "number" ? e.direction : e.direction ?? "right") ?? v("right");
4973
- E = [0, 0], await hi(i, o, (e) => {
5018
+ E = [0, 0], await yi(i, o, (e) => {
4974
5019
  let t = r(e) * a * Math.PI * 2, i = Math.sin(t) * 5;
4975
5020
  E = [s.x * i, s.y * i], n();
4976
5021
  }), E = [0, 0], M();
@@ -4978,7 +5023,7 @@ function bi(e, t, n, r, i) {
4978
5023
  }
4979
5024
  if (e.name === "explode") {
4980
5025
  let a = Math.max(1, Math.floor(e.count ?? 1)), o = t > 0 ? t : a * .12, s = e.relativeScale ?? 1.15;
4981
- await hi(i, o, (e) => {
5026
+ await yi(i, o, (e) => {
4982
5027
  let t = r(e), i = Math.abs(Math.sin(t * a * Math.PI));
4983
5028
  D = 1 + (s - 1) * i, n();
4984
5029
  }), D = 1, M();
@@ -4990,12 +5035,12 @@ function bi(e, t, n, r, i) {
4990
5035
  from: r,
4991
5036
  to: n,
4992
5037
  progress: 0
4993
- }, M(), await hi(i, t, (i) => {
4994
- let o = t === 0 ? 1 : pi(i * Math.max(a, 1) / 1);
5038
+ }, M(), await yi(i, t, (i) => {
5039
+ let o = t === 0 ? 1 : _i(i * Math.max(a, 1) / 1);
4995
5040
  k = {
4996
5041
  from: r,
4997
5042
  to: n,
4998
- progress: mi(o, e.ease ?? "easeInOut")
5043
+ progress: vi(o, e.ease ?? "easeInOut")
4999
5044
  }, M();
5000
5045
  }), k = void 0, M();
5001
5046
  return;
@@ -5010,19 +5055,25 @@ function bi(e, t, n, r, i) {
5010
5055
  dispose() {
5011
5056
  if (!y) {
5012
5057
  y = !0, x.placement.basis === "actor" && t.onTargetVisualChange === ee && (t.onTargetVisualChange = N ?? null);
5013
- for (let e of [...s].reverse()) a.destroyDrawable(e.drawableID, ti);
5058
+ for (let e of [...s].reverse()) a.destroyDrawable(e.drawableID, oi);
5014
5059
  c !== void 0 && (a.destroySkin(c), c = void 0), e.requestRedraw?.();
5015
5060
  }
5016
5061
  }
5017
5062
  });
5018
5063
  } catch (e) {
5019
- for (let e of [...s].reverse()) a.destroyDrawable(e.drawableID, ti);
5064
+ for (let e of [...s].reverse()) a.destroyDrawable(e.drawableID, oi);
5020
5065
  throw c !== void 0 && a.destroySkin(c), e;
5021
5066
  }
5022
5067
  }
5023
- function xi(e, t = {}) {
5024
- if (!si(e)) throw new $("BUBBLE-RUNTIME-001", "Bubble requires the TurboWarp runtime.");
5025
- let n = e, r = ci(n.renderer), i = () => li(n.ext_kubohiroyaassetmanager), a = t.svgText ? null : ui(n.ext_kubohiroyasvgtext);
5068
+ function Ti(e, t = {}) {
5069
+ if (!fi(e)) throw new $("BUBBLE-RUNTIME-001", "Bubble requires the TurboWarp runtime.");
5070
+ let n = e, r = pi(n.renderer), i = () => mi(n.ext_kubohiroyaassetmanager), a;
5071
+ if (t.textCapability !== void 0) a = t.textCapability;
5072
+ else try {
5073
+ a = ii(n.ext_kubohiroyasvgtext);
5074
+ } catch {
5075
+ throw new $("BUBBLE-RUNTIME-003", "Bubble requires a text capability. Load @kubohiroya/turbowarp-svg-text or provide options.textCapability before using Bubble blocks.");
5076
+ }
5026
5077
  return ei({
5027
5078
  imageResolver: t.imageResolver ?? {
5028
5079
  isRegistered(e) {
@@ -5035,7 +5086,7 @@ function xi(e, t = {}) {
5035
5086
  let a = t.drawableID;
5036
5087
  if (!Number.isInteger(a) || a < 0) throw new $("BUBBLE-RUNTIME-001", "Bubble image target drawable is invalid.");
5037
5088
  let o = await i().resolveSkin(e);
5038
- if (!si(o) || !Number.isInteger(o.skinId) || o.skinId < 0) throw new $("BUBBLE-RUNTIME-002", `Asset Manager did not resolve an image skin: ${String(e)}`);
5089
+ if (!fi(o) || !Number.isInteger(o.skinId) || o.skinId < 0) throw new $("BUBBLE-RUNTIME-002", `Asset Manager did not resolve an image skin: ${String(e)}`);
5039
5090
  r.updateDrawableSkinId(a, o.skinId), n.requestRedraw?.();
5040
5091
  }
5041
5092
  },
@@ -5052,25 +5103,10 @@ function xi(e, t = {}) {
5052
5103
  await r.call(n, { NAME: e });
5053
5104
  }
5054
5105
  },
5055
- svgText: t.svgText ?? {
5056
- setText({ styleName: e, target: t, text: n }) {
5057
- a?.setText({
5058
- STYLE: e,
5059
- TEXT: n
5060
- }, { target: t });
5061
- },
5062
- releaseTarget(e) {
5063
- a?.releaseTextActor(e);
5064
- },
5065
- measureText({ styleName: e, text: t }) {
5066
- let n = a?.measureText;
5067
- if (typeof n != "function") throw new $("BUBBLE-RUNTIME-003", "SVG Text does not provide text measurement.");
5068
- return n.call(a, e, t);
5069
- }
5070
- },
5106
+ textCapability: a,
5071
5107
  createSurface({ actor: e, actorKey: r, style: i }) {
5072
- if (!si(e) || typeof e.id != "string") throw new $("BUBBLE-RUNTIME-001", "Bubble actor target is invalid.");
5073
- return bi(n, e, r, i, t.scheduler ?? {
5108
+ if (!fi(e) || typeof e.id != "string") throw new $("BUBBLE-RUNTIME-001", "Bubble actor target is invalid.");
5109
+ return wi(n, e, r, i, t.scheduler ?? {
5074
5110
  setTimeout: (e, t) => globalThis.setTimeout(e, t),
5075
5111
  clearTimeout: (e) => globalThis.clearTimeout(e)
5076
5112
  });
@@ -5080,4 +5116,4 @@ function xi(e, t = {}) {
5080
5116
  });
5081
5117
  }
5082
5118
  //#endregion
5083
- export { $ as BubbleRuntimeAdapterError, xi as createTurboWarpBubbleComposition };
5119
+ export { $ as BubbleRuntimeAdapterError, ai as createSvgTextCompositionCapability, Ti as createTurboWarpBubbleComposition, ii as createTurboWarpSvgTextCapability };
@@ -8431,7 +8431,7 @@
8431
8431
  "easeOut",
8432
8432
  "easeInOut"
8433
8433
  ]);
8434
- function isRecord$1(value) {
8434
+ function isRecord$2(value) {
8435
8435
  return typeof value === "object" && value !== null && !Array.isArray(value);
8436
8436
  }
8437
8437
  function requireExactKeys(value, required, optional, label) {
@@ -8449,7 +8449,7 @@
8449
8449
  return value;
8450
8450
  }
8451
8451
  function normalizeAnimation(value, label, minimumFrames) {
8452
- if (!isRecord$1(value)) throw new BubbleCompositionError("BUBBLE-COMPOSITION-001", `${label} must be an object.`);
8452
+ if (!isRecord$2(value)) throw new BubbleCompositionError("BUBBLE-COMPOSITION-001", `${label} must be an object.`);
8453
8453
  requireExactKeys(value, ["frames", "frameIntervalSeconds"], [], label);
8454
8454
  if (!Array.isArray(value.frames) || value.frames.length < minimumFrames) throw new BubbleCompositionError("BUBBLE-COMPOSITION-001", `${label}.frames must contain at least ${minimumFrames} image asset name${minimumFrames === 1 ? "" : "s"}.`);
8455
8455
  const frames = Object.freeze(value.frames.map((frame, index) => requireAssetName(frame, `${label}.frames[${index}]`)));
@@ -8461,7 +8461,7 @@
8461
8461
  });
8462
8462
  }
8463
8463
  function normalizePortrait(value) {
8464
- if (!isRecord$1(value)) throw new BubbleCompositionError("BUBBLE-COMPOSITION-001", "Bubble portrait must be an object.");
8464
+ if (!isRecord$2(value)) throw new BubbleCompositionError("BUBBLE-COMPOSITION-001", "Bubble portrait must be an object.");
8465
8465
  requireExactKeys(value, ["base"], ["blink", "lipSync"], "Bubble portrait");
8466
8466
  const blink = value.blink === void 0 ? void 0 : normalizeAnimation(value.blink, "Bubble portrait blink", 1);
8467
8467
  const lipSync = value.lipSync === void 0 ? void 0 : normalizeAnimation(value.lipSync, "Bubble portrait lip-sync", 1);
@@ -8472,7 +8472,7 @@
8472
8472
  });
8473
8473
  }
8474
8474
  function normalizeMotion(value, label) {
8475
- if (!isRecord$1(value)) throw new BubbleCompositionError("BUBBLE-COMPOSITION-001", `${label} must be an object.`);
8475
+ if (!isRecord$2(value)) throw new BubbleCompositionError("BUBBLE-COMPOSITION-001", `${label} must be an object.`);
8476
8476
  requireExactKeys(value, ["name"], [
8477
8477
  "durationSeconds",
8478
8478
  "ease",
@@ -8512,7 +8512,7 @@
8512
8512
  }
8513
8513
  function normalizeAudio(value) {
8514
8514
  if (value === void 0) return void 0;
8515
- if (!isRecord$1(value)) throw new BubbleCompositionError("BUBBLE-COMPOSITION-001", "Bubble audio must be an object.");
8515
+ if (!isRecord$2(value)) throw new BubbleCompositionError("BUBBLE-COMPOSITION-001", "Bubble audio must be an object.");
8516
8516
  requireExactKeys(value, [], [
8517
8517
  "voice",
8518
8518
  "reveal",
@@ -8530,7 +8530,7 @@
8530
8530
  return Object.freeze(result);
8531
8531
  }
8532
8532
  function normalizeStyle(value) {
8533
- if (!isRecord$1(value)) throw new BubbleCompositionError("BUBBLE-COMPOSITION-001", "Bubble style must be an object.");
8533
+ if (!isRecord$2(value)) throw new BubbleCompositionError("BUBBLE-COMPOSITION-001", "Bubble style must be an object.");
8534
8534
  requireExactKeys(value, ["name", "textStyle"], [
8535
8535
  "placement",
8536
8536
  "maxWidth",
@@ -8601,12 +8601,12 @@
8601
8601
  }
8602
8602
  function validateImageResolver(value) {
8603
8603
  if (value === void 0) return void 0;
8604
- if (!isRecord$1(value) || typeof value.applyToTarget !== "function" || typeof value.getMimeType !== "function" || typeof value.isRegistered !== "function") throw new TypeError("Bubble image capability must provide applyToTarget, getMimeType, and isRegistered.");
8604
+ if (!isRecord$2(value) || typeof value.applyToTarget !== "function" || typeof value.getMimeType !== "function" || typeof value.isRegistered !== "function") throw new TypeError("Bubble image capability must provide applyToTarget, getMimeType, and isRegistered.");
8605
8605
  return value;
8606
8606
  }
8607
8607
  function validateAudioCapability(value) {
8608
8608
  if (value === void 0) return void 0;
8609
- if (!isRecord$1(value) || typeof value.playSound !== "function") throw new TypeError("Bubble audio capability must provide playSound.");
8609
+ if (!isRecord$2(value) || typeof value.playSound !== "function") throw new TypeError("Bubble audio capability must provide playSound.");
8610
8610
  if (value.isRegistered !== void 0 && typeof value.isRegistered !== "function") throw new TypeError("Bubble audio capability isRegistered must be a function.");
8611
8611
  if (value.getMimeType !== void 0 && typeof value.getMimeType !== "function") throw new TypeError("Bubble audio capability getMimeType must be a function.");
8612
8612
  return value;
@@ -8615,8 +8615,8 @@
8615
8615
  if (value === void 0) throw new BubbleCompositionError("BUBBLE-COMPOSITION-006", "Bubble image assets require an image capability. Provide options.imageResolver.");
8616
8616
  return value;
8617
8617
  }
8618
- function validateSvgText(value) {
8619
- if (!isRecord$1(value) || typeof value.setText !== "function" || typeof value.releaseTarget !== "function") throw new TypeError("Bubble SVG Text composition must provide setText and releaseTarget.");
8618
+ function validateTextCapability(value) {
8619
+ if (!isRecord$2(value) || typeof value.setText !== "function" || typeof value.releaseTarget !== "function") throw new TypeError("Bubble text capability must provide setText and releaseTarget.");
8620
8620
  return value;
8621
8621
  }
8622
8622
  function defaultScheduler() {
@@ -8626,19 +8626,19 @@
8626
8626
  });
8627
8627
  }
8628
8628
  function validateScheduler(value) {
8629
- if (!isRecord$1(value) || typeof value.setTimeout !== "function" || typeof value.clearTimeout !== "function") throw new TypeError("Bubble scheduler must provide setTimeout and clearTimeout.");
8629
+ if (!isRecord$2(value) || typeof value.setTimeout !== "function" || typeof value.clearTimeout !== "function") throw new TypeError("Bubble scheduler must provide setTimeout and clearTimeout.");
8630
8630
  return value;
8631
8631
  }
8632
8632
  function validateAssetTarget(value, label) {
8633
- if (!isRecord$1(value) || typeof value.id !== "string" || value.id.length === 0 || typeof value.isStage !== "boolean") throw new BubbleCompositionError("BUBBLE-COMPOSITION-004", `${label} must provide id and isStage.`);
8633
+ if (!isRecord$2(value) || typeof value.id !== "string" || value.id.length === 0 || typeof value.isStage !== "boolean") throw new BubbleCompositionError("BUBBLE-COMPOSITION-004", `${label} must provide id and isStage.`);
8634
8634
  return value;
8635
8635
  }
8636
8636
  function validateTextTarget(value) {
8637
- if (!isRecord$1(value) || typeof value.drawableID !== "number" || !Number.isInteger(value.drawableID) || value.drawableID < 0) throw new BubbleCompositionError("BUBBLE-COMPOSITION-004", "Bubble text target must provide a non-negative integer drawableID.");
8637
+ if (typeof value !== "object" || value === null) throw new BubbleCompositionError("BUBBLE-COMPOSITION-004", "Bubble text target must be a non-null object.");
8638
8638
  return value;
8639
8639
  }
8640
8640
  function validateSurface(value, style) {
8641
- if (!isRecord$1(value) || !isRecord$1(value.targets) || typeof value.setLayerVisible !== "function" || typeof value.updateStyle !== "function" || typeof value.show !== "function" || typeof value.hide !== "function" || typeof value.dispose !== "function") throw new BubbleCompositionError("BUBBLE-COMPOSITION-004", "Bubble surface is invalid.");
8641
+ if (!isRecord$2(value) || !isRecord$2(value.targets) || typeof value.setLayerVisible !== "function" || typeof value.updateStyle !== "function" || typeof value.show !== "function" || typeof value.hide !== "function" || typeof value.dispose !== "function") throw new BubbleCompositionError("BUBBLE-COMPOSITION-004", "Bubble surface is invalid.");
8642
8642
  const targets = value.targets;
8643
8643
  validateTextTarget(targets.text);
8644
8644
  const assetTargetIds = /* @__PURE__ */ new Set();
@@ -8749,7 +8749,7 @@
8749
8749
  });
8750
8750
  }
8751
8751
  function normalizeShowInput(value) {
8752
- if (!isRecord$1(value)) throw new BubbleCompositionError("BUBBLE-COMPOSITION-001", "Show bubble input must be an object.");
8752
+ if (!isRecord$2(value)) throw new BubbleCompositionError("BUBBLE-COMPOSITION-001", "Show bubble input must be an object.");
8753
8753
  requireExactKeys(value, [
8754
8754
  "actor",
8755
8755
  "actorKey",
@@ -8778,10 +8778,10 @@
8778
8778
  };
8779
8779
  }
8780
8780
  function createBubbleComposition(options) {
8781
- if (!isRecord$1(options)) throw new TypeError("Bubble composition options must be an object.");
8781
+ if (!isRecord$2(options)) throw new TypeError("Bubble composition options must be an object.");
8782
8782
  const imageResolver = validateImageResolver(options.imageResolver);
8783
8783
  const audio = validateAudioCapability(options.audio);
8784
- const svgText = validateSvgText(options.svgText);
8784
+ const textCapability = validateTextCapability(options.textCapability);
8785
8785
  if (typeof options.createSurface !== "function") throw new TypeError("Bubble composition createSurface must be a function.");
8786
8786
  if (options.onAnimationError !== void 0 && typeof options.onAnimationError !== "function") throw new TypeError("Bubble composition onAnimationError must be a function.");
8787
8787
  const scheduler = validateScheduler(options.scheduler ?? defaultScheduler());
@@ -8895,19 +8895,19 @@
8895
8895
  kind: input.kind,
8896
8896
  style: activeStyle
8897
8897
  })), activeStyle);
8898
- const fullText = formatBubbleText(input.text, activeStyle, svgText);
8898
+ const fullText = formatBubbleText(input.text, activeStyle, textCapability);
8899
8899
  if (reveal?.layout === "RESERVED") {
8900
- svgText.setText({
8900
+ textCapability.setText({
8901
8901
  styleName: activeStyle.textStyle,
8902
8902
  target: surface.targets.text,
8903
8903
  text: fullText
8904
8904
  });
8905
8905
  surface.captureTextLayout?.();
8906
8906
  }
8907
- svgText.setText({
8907
+ textCapability.setText({
8908
8908
  styleName: activeStyle.textStyle,
8909
8909
  target: surface.targets.text,
8910
- text: formatBubbleText(reveal ? revealedBubbleText(revealChunks, revealedCount) : input.text, activeStyle, svgText)
8910
+ text: formatBubbleText(reveal ? revealedBubbleText(revealChunks, revealedCount) : input.text, activeStyle, textCapability)
8911
8911
  });
8912
8912
  textOwned = true;
8913
8913
  await primeStyleImages(activeStyle, styleImageResolver, surface);
@@ -8918,10 +8918,10 @@
8918
8918
  const renderVisibleText = async () => {
8919
8919
  if (!surface) return;
8920
8920
  const visible = reveal ? revealedBubbleText(revealChunks, revealedCount) : currentText;
8921
- svgText.setText({
8921
+ textCapability.setText({
8922
8922
  styleName: activeStyle.textStyle,
8923
8923
  target: surface.targets.text,
8924
- text: formatBubbleText(visible, activeStyle, svgText)
8924
+ text: formatBubbleText(visible, activeStyle, textCapability)
8925
8925
  });
8926
8926
  await surface.show();
8927
8927
  };
@@ -8994,10 +8994,10 @@
8994
8994
  revealChunks = splitBubbleText(text, reveal);
8995
8995
  revealedCount = Math.min(1, revealChunks.length);
8996
8996
  if (reveal.layout === "RESERVED") {
8997
- svgText.setText({
8997
+ textCapability.setText({
8998
8998
  styleName: activeStyle.textStyle,
8999
8999
  target: surface.targets.text,
9000
- text: formatBubbleText(text, activeStyle, svgText)
9000
+ text: formatBubbleText(text, activeStyle, textCapability)
9001
9001
  });
9002
9002
  surface.captureTextLayout?.();
9003
9003
  }
@@ -9038,17 +9038,17 @@
9038
9038
  revealedCount = reveal ? Math.min(1, revealChunks.length) : 1;
9039
9039
  stopRevealTimer();
9040
9040
  if (reveal?.layout === "RESERVED") {
9041
- svgText.setText({
9041
+ textCapability.setText({
9042
9042
  styleName: nextStyle.textStyle,
9043
9043
  target: surface.targets.text,
9044
- text: formatBubbleText(currentText, nextStyle, svgText)
9044
+ text: formatBubbleText(currentText, nextStyle, textCapability)
9045
9045
  });
9046
9046
  surface.captureTextLayout?.();
9047
9047
  }
9048
- svgText.setText({
9048
+ textCapability.setText({
9049
9049
  styleName: nextStyle.textStyle,
9050
9050
  target: surface.targets.text,
9051
- text: formatBubbleText(currentText, nextStyle, svgText)
9051
+ text: formatBubbleText(currentText, nextStyle, textCapability)
9052
9052
  });
9053
9053
  createStyleLoops(nextStyle, nextImageResolver, surface);
9054
9054
  await Promise.all([
@@ -9106,10 +9106,10 @@
9106
9106
  revealChunks = splitBubbleText(currentText, reveal);
9107
9107
  revealedCount = Math.min(1, revealChunks.length);
9108
9108
  if (reveal.layout === "RESERVED" && surface) {
9109
- svgText.setText({
9109
+ textCapability.setText({
9110
9110
  styleName: activeStyle.textStyle,
9111
9111
  target: surface.targets.text,
9112
- text: formatBubbleText(currentText, activeStyle, svgText)
9112
+ text: formatBubbleText(currentText, activeStyle, textCapability)
9113
9113
  });
9114
9114
  surface.captureTextLayout?.();
9115
9115
  }
@@ -9205,7 +9205,7 @@
9205
9205
  if (surfaceVisible) await surface?.hide();
9206
9206
  },
9207
9207
  async () => {
9208
- if (textOwned && surface) svgText.releaseTarget(surface.targets.text);
9208
+ if (textOwned && surface) textCapability.releaseTarget(surface.targets.text);
9209
9209
  },
9210
9210
  async () => surface?.dispose()
9211
9211
  ]) try {
@@ -9236,7 +9236,7 @@
9236
9236
  cleanupErrors.push(cleanupError);
9237
9237
  }
9238
9238
  if (textOwned && surface) try {
9239
- svgText.releaseTarget(surface.targets.text);
9239
+ textCapability.releaseTarget(surface.targets.text);
9240
9240
  } catch (cleanupError) {
9241
9241
  cleanupErrors.push(cleanupError);
9242
9242
  }
@@ -9286,6 +9286,37 @@
9286
9286
  });
9287
9287
  }
9288
9288
  //#endregion
9289
+ //#region src/turbowarp-svg-text-adapter.ts
9290
+ function isRecord$1(value) {
9291
+ return typeof value === "object" && value !== null && !Array.isArray(value);
9292
+ }
9293
+ function validateExtension(value) {
9294
+ if (!isRecord$1(value) || typeof value.setText !== "function" || typeof value.releaseTextActor !== "function") throw new TypeError("TurboWarp SVG Text adapter requires setText and releaseTextActor.");
9295
+ return value;
9296
+ }
9297
+ /**
9298
+ * Adapt the TurboWarp SVG Text extension to Bubble's host-neutral text
9299
+ * capability contract.
9300
+ */
9301
+ function createTurboWarpSvgTextCapability(extensionInput) {
9302
+ const extension = validateExtension(extensionInput);
9303
+ return Object.freeze({
9304
+ setText({ styleName, target, text }) {
9305
+ extension.setText({
9306
+ STYLE: styleName,
9307
+ TEXT: text
9308
+ }, { target });
9309
+ },
9310
+ releaseTarget(target) {
9311
+ extension.releaseTextActor(target);
9312
+ },
9313
+ measureText({ styleName, text }) {
9314
+ if (typeof extension.measureText !== "function") throw new Error("TurboWarp SVG Text does not provide text measurement.");
9315
+ return extension.measureText(styleName, text);
9316
+ }
9317
+ });
9318
+ }
9319
+ //#endregion
9289
9320
  //#region src/turbowarp-adapter.ts
9290
9321
  var spriteLayer = "sprite";
9291
9322
  var portraitBoxSize = 96;
@@ -9325,10 +9356,6 @@
9325
9356
  if (!isRecord(value) || typeof value.isLoaded !== "function" || typeof value.getAssetMimeType !== "function" || typeof value.resolveSkin !== "function") throw new BubbleRuntimeAdapterError("BUBBLE-RUNTIME-002", "Bubble image assets require an imageResolver capability. Load @kubohiroya/turbowarp-asset-manager or provide options.imageResolver before using image features.");
9326
9357
  return value;
9327
9358
  }
9328
- function requireSvgText(value) {
9329
- if (!isRecord(value) || typeof value.setText !== "function" || typeof value.releaseTextActor !== "function") throw new BubbleRuntimeAdapterError("BUBBLE-RUNTIME-003", "Bubble requires SVG Text. Load @kubohiroya/turbowarp-svg-text before using Bubble blocks.");
9330
- return value;
9331
- }
9332
9359
  function targetBounds(target) {
9333
9360
  try {
9334
9361
  const bounds = target.getBoundsForBubble?.();
@@ -9829,7 +9856,13 @@
9829
9856
  const runtime = runtimeInput;
9830
9857
  const renderer = requireRenderer(runtime.renderer);
9831
9858
  const getAssetExtension = () => requireAssetManager(runtime.ext_kubohiroyaassetmanager);
9832
- const svgTextExtension = options.svgText ? null : requireSvgText(runtime.ext_kubohiroyasvgtext);
9859
+ let textCapability;
9860
+ if (options.textCapability !== void 0) textCapability = options.textCapability;
9861
+ else try {
9862
+ textCapability = createTurboWarpSvgTextCapability(runtime.ext_kubohiroyasvgtext);
9863
+ } catch {
9864
+ throw new BubbleRuntimeAdapterError("BUBBLE-RUNTIME-003", "Bubble requires a text capability. Load @kubohiroya/turbowarp-svg-text or provide options.textCapability before using Bubble blocks.");
9865
+ }
9833
9866
  return createBubbleComposition({
9834
9867
  imageResolver: options.imageResolver ?? {
9835
9868
  isRegistered(name) {
@@ -9861,22 +9894,7 @@
9861
9894
  await method.call(extension, { NAME: name });
9862
9895
  }
9863
9896
  },
9864
- svgText: options.svgText ?? {
9865
- setText({ styleName, target, text }) {
9866
- svgTextExtension?.setText({
9867
- STYLE: styleName,
9868
- TEXT: text
9869
- }, { target });
9870
- },
9871
- releaseTarget(target) {
9872
- svgTextExtension?.releaseTextActor(target);
9873
- },
9874
- measureText({ styleName, text }) {
9875
- const measureText = svgTextExtension?.measureText;
9876
- if (typeof measureText !== "function") throw new BubbleRuntimeAdapterError("BUBBLE-RUNTIME-003", "SVG Text does not provide text measurement.");
9877
- return measureText.call(svgTextExtension, styleName, text);
9878
- }
9879
- },
9897
+ textCapability,
9880
9898
  createSurface({ actor, actorKey, style }) {
9881
9899
  if (!isRecord(actor) || typeof actor.id !== "string") throw new BubbleRuntimeAdapterError("BUBBLE-RUNTIME-001", "Bubble actor target is invalid.");
9882
9900
  return createSurface(runtime, actor, actorKey, style, options.scheduler ?? {
@@ -9929,7 +9947,8 @@
9929
9947
  "easeInOut"
9930
9948
  ]);
9931
9949
  var EXTENSION_DOCS_URI = "https://kubohiroya.github.io/turbowarp-bubble/";
9932
- var EXTENSION_VERSION = "0.3.1";
9950
+ var EXTENSION_VERSION = "0.5.0";
9951
+ var BLOCK_ICON_URI = `data:image/svg+xml,${encodeURIComponent("<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 64 64\"><path fill=\"none\" stroke=\"#fff\" stroke-width=\"5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M12 13h40a5 5 0 0 1 5 5v23a5 5 0 0 1-5 5H30L17 55v-9h-5a5 5 0 0 1-5-5V18a5 5 0 0 1 5-5Z\"/><g fill=\"#fff\"><circle cx=\"23\" cy=\"30\" r=\"3\"/><circle cx=\"32\" cy=\"30\" r=\"3\"/><circle cx=\"41\" cy=\"30\" r=\"3\"/></g></svg>")}`;
9933
9952
  function extensionError(message) {
9934
9953
  const error = /* @__PURE__ */ new Error(`[Bubble] ${message}`);
9935
9954
  Object.defineProperty(error, "code", { value: "BUBBLE-EXTENSION-001" });
@@ -9970,6 +9989,7 @@
9970
9989
  id: extensionConfig.id,
9971
9990
  name: Scratch.translate(block_definitions_default.extensionName),
9972
9991
  docsURI: EXTENSION_DOCS_URI,
9992
+ blockIconURI: BLOCK_ICON_URI,
9973
9993
  color1: "#ff6680",
9974
9994
  blocks: blockDefinitions.map((block) => this.toScratchBlock(block)),
9975
9995
  menus: definitionMenus
@@ -2,6 +2,8 @@ import { type BubblePlacement, type BubblePlacementInput } from "./placement.js"
2
2
  import { type BubbleOffset, type BubbleOffsetInput } from "./actor-transform.js";
3
3
  import { type BubbleVisualStyle } from "./bubble-svg.js";
4
4
  import { type BubbleRevealInput, type BubbleRevealUnit, type NormalizedBubbleReveal } from "./reveal.js";
5
+ import type { BubbleTextCapability, BubbleTextTarget } from "./text-capability.js";
6
+ export type { BubbleTextCapability, BubbleTextTarget, } from "./text-capability.js";
5
7
  export { UnicodeLineBreakProvider, wrapText, type LineBreakOpportunity, type LineBreakProvider, type TextWidthMeasurer, type WrappedTextLayout, type WrappedTextLine, type WrapTextInput, } from "./text-layout.js";
6
8
  export { bubbleBackgroundRegions, bubbleDirectionAliases, bubbleDirectionNames, defaultBubblePlacementInput, normalizeBubblePlacement, type BubbleActorPlacement, type BubbleBackgroundPlacement, type BubbleBackgroundRegion, type BubbleDirectionAlias, type BubbleDirectionName, type BubblePlacement, type BubblePlacementInput, } from "./placement.js";
7
9
  export { actorRelativeBubbleCenter, defaultBubbleDistance, defaultBubbleOffset, defaultBubbleTailLength, normalizeBubbleDistance, normalizeBubbleOffset, normalizeBubbleTailLength, type ActorBounds, type ActorRelativeCenterInput, type BubbleOffset, type BubbleOffsetInput, } from "./actor-transform.js";
@@ -102,21 +104,6 @@ export interface BubbleAudioCapability {
102
104
  readonly isRegistered?: (name: unknown) => boolean;
103
105
  readonly getMimeType?: (name: unknown) => string;
104
106
  }
105
- export interface BubbleTextTarget {
106
- readonly drawableID: number;
107
- }
108
- export interface BubbleSvgText {
109
- readonly setText: (input: {
110
- readonly styleName: string;
111
- readonly target: BubbleTextTarget;
112
- readonly text: string;
113
- }) => void;
114
- readonly releaseTarget: (target: BubbleTextTarget) => void;
115
- readonly measureText?: (input: {
116
- readonly styleName: string;
117
- readonly text: string;
118
- }) => number;
119
- }
120
107
  export interface BubbleSurfaceTargets {
121
108
  readonly text: BubbleTextTarget;
122
109
  readonly portraitBase?: BubbleAssetTarget;
@@ -156,7 +143,7 @@ export interface BubbleAnimationErrorContext {
156
143
  export interface BubbleCompositionOptions {
157
144
  readonly imageResolver?: BubbleImageCapability;
158
145
  readonly audio?: BubbleAudioCapability;
159
- readonly svgText: BubbleSvgText;
146
+ readonly textCapability: BubbleTextCapability;
160
147
  readonly createSurface: BubbleSurfaceFactory;
161
148
  readonly scheduler?: BubbleScheduler;
162
149
  readonly onAnimationError?: (error: unknown, context: BubbleAnimationErrorContext) => void;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Opaque host-owned target used by a text capability.
3
+ *
4
+ * The capability may be implemented by TurboWarp SVG Text or by another
5
+ * renderer in a different host environment.
6
+ */
7
+ export type BubbleTextTarget = object;
8
+ /**
9
+ * Text rendering contract consumed by Bubble composition.
10
+ *
11
+ * Bubble owns placement, outer shape, portraits, reveal, and animation. A
12
+ * text adapter owns text styles, SVG/text skin creation, measurement, and
13
+ * target skin release.
14
+ */
15
+ export interface BubbleTextCapability {
16
+ setText(input: {
17
+ readonly styleName: string;
18
+ readonly target: BubbleTextTarget;
19
+ readonly text: string;
20
+ }): void;
21
+ releaseTarget(target: BubbleTextTarget): void;
22
+ measureText?(input: {
23
+ readonly styleName: string;
24
+ readonly text: string;
25
+ }): number;
26
+ }
@@ -1,4 +1,6 @@
1
- import { type BubbleComposition, type BubbleCompositionOptions, type BubbleAudioCapability, type BubbleImageCapability, type BubbleScheduler, type BubbleSvgText } from "./composition.js";
1
+ import { type BubbleComposition, type BubbleCompositionOptions, type BubbleAudioCapability, type BubbleImageCapability, type BubbleScheduler, type BubbleTextCapability } from "./composition.js";
2
+ import { type TurboWarpSvgTextExtension } from "./turbowarp-svg-text-adapter.js";
3
+ export { createSvgTextCompositionCapability, createTurboWarpSvgTextCapability, type TurboWarpSvgTextExtension, } from "./turbowarp-svg-text-adapter.js";
2
4
  export interface TurboWarpBubbleTarget {
3
5
  readonly id: string;
4
6
  readonly isStage: boolean;
@@ -48,16 +50,6 @@ export interface TurboWarpAssetManagerExtension {
48
50
  skinId: number;
49
51
  }>>;
50
52
  }
51
- export interface TurboWarpSvgTextExtension {
52
- setText(args: Readonly<{
53
- STYLE: unknown;
54
- TEXT: unknown;
55
- }>, util: Readonly<{
56
- target: TurboWarpBubbleTarget;
57
- }>): void;
58
- measureText?(styleName: unknown, text: unknown): number;
59
- releaseTextActor(target: TurboWarpBubbleTarget): boolean;
60
- }
61
53
  export interface TurboWarpBubbleRuntime {
62
54
  readonly renderer: TurboWarpBubbleRenderer;
63
55
  readonly ext_kubohiroyaassetmanager?: TurboWarpAssetManagerExtension;
@@ -67,7 +59,7 @@ export interface TurboWarpBubbleRuntime {
67
59
  export interface TurboWarpBubbleCompositionOptions {
68
60
  readonly imageResolver?: BubbleImageCapability;
69
61
  readonly audio?: BubbleAudioCapability;
70
- readonly svgText?: BubbleSvgText;
62
+ readonly textCapability?: BubbleTextCapability;
71
63
  readonly scheduler?: BubbleScheduler;
72
64
  readonly onAnimationError?: BubbleCompositionOptions["onAnimationError"];
73
65
  }
@@ -0,0 +1,21 @@
1
+ import type { BubbleTextCapability } from "./text-capability.js";
2
+ export interface TurboWarpSvgTextExtension {
3
+ setText(args: Readonly<{
4
+ STYLE: unknown;
5
+ TEXT: unknown;
6
+ }>, util: Readonly<{
7
+ target: unknown;
8
+ }>): void;
9
+ measureText?(styleName: unknown, text: unknown): number;
10
+ releaseTextActor(target: unknown): boolean;
11
+ }
12
+ /**
13
+ * Adapt the TurboWarp SVG Text extension to Bubble's host-neutral text
14
+ * capability contract.
15
+ */
16
+ export declare function createTurboWarpSvgTextCapability(extensionInput: unknown): BubbleTextCapability;
17
+ /**
18
+ * Adapt the SVG Text package's composition API to Bubble's text capability.
19
+ * This helper keeps the core package independent from SVG Text's target type.
20
+ */
21
+ export declare function createSvgTextCompositionCapability(compositionInput: unknown): BubbleTextCapability;
@@ -6,7 +6,7 @@
6
6
 
7
7
  ## 1. 必要な拡張機能
8
8
 
9
- 入力待ちを含む完全な例では6つの拡張機能を使います。TurboWarpの拡張機能ライブラリからTemporary Variablesを追加し、選択した機能に必要なカスタム拡張機能を「サンドボックスなしで実行」を許可して読み込みます。文字BubbleにはSVG TextとBubbleが必要です。portrait、lip-sync、continue indicator、フルボイス、表示効果音などのメディアアセットにはAsset Managerが必要です。Async InputとRuntime ExpressionはBubble待機を使う場合だけ必要です。
9
+ 入力待ちを含む完全な例では6つの拡張機能を使います。TurboWarpの拡張機能ライブラリからTemporary Variablesを追加し、選択した機能に必要なカスタム拡張機能を「サンドボックスなしで実行」を許可して読み込みます。Bubbleは文字Bubbleの既定`BubbleTextCapability` adapterとしてSVG Textを使います。portrait、lip-sync、continue indicator、フルボイス、表示効果音などのメディアアセットにはAsset Managerが必要です。Async InputとRuntime ExpressionはBubble待機を使う場合だけ必要です。
10
10
 
11
11
  | 順番 | 拡張機能 | 読み込み先 |
12
12
  | ---: | ------------------------ | -------------------------------------------------------------------------------------------------------- |
@@ -15,9 +15,9 @@
15
15
  | 3 | Runtime Expression 0.3.0 | `https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-runtime-expression@0.3.0/dist/runtime-expression.js` |
16
16
  | 4 | Asset Manager 0.7.0 | `https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-asset-manager@0.7.0/dist/asset-manager.js` |
17
17
  | 5 | SVG Text 0.4.0 | `https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-svg-text@0.4.0/dist/svg-text.js` |
18
- | 6 | Bubble 0.3.1 | npm公開後は`https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-bubble@0.3.1/dist/turbowarp-bubble.js` |
18
+ | 6 | Bubble 0.5.0 | `https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-bubble@0.5.0/dist/turbowarp-bubble.js` |
19
19
 
20
- 開発中のBubbleを試す場合は、このリポジトリの`dist/turbowarp-bubble.js`をローカルカスタム拡張機能として読み込みます。表示時にSVG Textが、画像・メディア機能の使用時にAsset Managerが、待機開始時にAsync InputかRuntime Expressionが見つからなければ、Bubbleは明示的なエラーを返します。
20
+ 開発中のBubbleを試す場合は、このリポジトリの`dist/turbowarp-bubble.js`をローカルカスタム拡張機能として読み込みます。表示時に既定のSVG Text adapterが、画像・メディア機能の使用時にAsset Managerが、待機開始時にAsync InputかRuntime Expressionが見つからなければ、Bubbleは明示的なエラーを返します。低レベルComposition APIでは別のtext capabilityを注入でき、その場合SVG Textは不要です。
21
21
 
22
22
  参考:
23
23
 
@@ -296,7 +296,7 @@ cloneが停止・削除された場合は、そのtargetに属するtimer、SVG
296
296
  | 状況 | 原因と対処 |
297
297
  | ---------------------------------- | ------------------------------------------------------------------------ |
298
298
  | Asset Managerを要求するエラー | 画像・メディアアセットを使う前にAsset Manager 0.7.xを読み込む |
299
- | SVG Textを要求するエラー | SVG Text 0.4.xをサンドボックスなしで読み込む |
299
+ | 既定text adapterを要求するエラー | SVG Text 0.4.xをサンドボックスなしで読み込む |
300
300
  | Async Inputを要求するエラー | Bubble待機より前にAsync Input 0.3.xをサンドボックスなしで読み込む |
301
301
  | Runtime Expressionを要求するエラー | Bubble待機より前にRuntime Expression 0.3.xをサンドボックスなしで読み込む |
302
302
  | `bubble style is not defined` | `define bubble style`を先に実行する。緑の旗の再実行時も再定義する |
@@ -310,7 +310,7 @@ cloneが停止・削除された場合は、そのtargetに属するtimer、SVG
310
310
 
311
311
  ## 13. 自動解放されるタイミング
312
312
 
313
- 次の場合、Bubbleが所有するtimer、SVG Text skin、renderer drawableは自動的に解放されます。
313
+ 次の場合、Bubbleが所有するtimer、text skin、renderer drawableは自動的に解放されます。
314
314
 
315
315
  - `close this bubble`
316
316
  - 同じsprite/cloneで次の`say`または`think`を実行したとき
@@ -6,18 +6,18 @@ This manual explains how to use `turbowarp-bubble` as an unsandboxed TurboWarp c
6
6
 
7
7
  ## 1. Load the required extensions
8
8
 
9
- The complete input-wait example uses six extensions. Add Temporary Variables from TurboWarp's extension library, then load the custom extensions needed by the selected features with **Run without sandbox** enabled. SVG Text and Bubble are required for text bubbles. Asset Manager is required for portrait, lip-sync, continue indicator, voice, and display-sound assets. Async Input and Runtime Expression are required only before using a Bubble wait.
9
+ The complete input-wait example uses six extensions. Add Temporary Variables from TurboWarp's extension library, then load the custom extensions needed by the selected features with **Run without sandbox** enabled. Bubble uses SVG Text as its default `BubbleTextCapability` adapter for text bubbles. Asset Manager is required for portrait, lip-sync, continue indicator, voice, and display-sound assets. Async Input and Runtime Expression are required only before using a Bubble wait.
10
10
 
11
- | Order | Extension | URL |
12
- | ----: | ------------------------ | ----------------------------------------------------------------------------------------------------------------- |
13
- | 1 | Temporary Variables | Add from the TurboWarp extension library |
14
- | 2 | Async Input 0.3.0 | `https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-async-input@0.3.0/dist/async-input.js` |
15
- | 3 | Runtime Expression 0.3.0 | `https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-runtime-expression@0.3.0/dist/runtime-expression.js` |
16
- | 4 | Asset Manager 0.7.0 | `https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-asset-manager@0.7.0/dist/asset-manager.js` |
17
- | 5 | SVG Text 0.4.0 | `https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-svg-text@0.4.0/dist/svg-text.js` |
18
- | 6 | Bubble 0.3.1 | After npm publication: `https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-bubble@0.3.1/dist/turbowarp-bubble.js` |
11
+ | Order | Extension | URL |
12
+ | ----: | ------------------------ | -------------------------------------------------------------------------------------------------------- |
13
+ | 1 | Temporary Variables | Add from the TurboWarp extension library |
14
+ | 2 | Async Input 0.3.0 | `https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-async-input@0.3.0/dist/async-input.js` |
15
+ | 3 | Runtime Expression 0.3.0 | `https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-runtime-expression@0.3.0/dist/runtime-expression.js` |
16
+ | 4 | Asset Manager 0.7.0 | `https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-asset-manager@0.7.0/dist/asset-manager.js` |
17
+ | 5 | SVG Text 0.4.0 | `https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-svg-text@0.4.0/dist/svg-text.js` |
18
+ | 6 | Bubble 0.5.0 | `https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-bubble@0.5.0/dist/turbowarp-bubble.js` |
19
19
 
20
- To try a development build, load this repository's `dist/turbowarp-bubble.js` as a local custom extension. Bubble reports an explicit error if SVG Text is missing when it displays a Bubble, if an image/media feature is used without Asset Manager, or if Async Input or Runtime Expression is missing when it starts a Bubble wait.
20
+ To try a development build, load this repository's `dist/turbowarp-bubble.js` as a local custom extension. Bubble reports an explicit error if the default SVG Text adapter is missing when it displays a Bubble, if an image/media feature is used without Asset Manager, or if Async Input or Runtime Expression is missing when it starts a Bubble wait. The lower-level Composition API can use another text capability and does not require SVG Text.
21
21
 
22
22
  See also:
23
23
 
@@ -296,7 +296,7 @@ When a clone stops or is deleted, timers, SVG Text skins, and renderer drawables
296
296
  | Symptom | Cause and solution |
297
297
  | ------------------------------------ | --------------------------------------------------------------------------- |
298
298
  | Asset Manager required error | Load Asset Manager 0.7.x without sandbox before using image/media assets |
299
- | SVG Text required error | Load SVG Text 0.4.x without sandbox |
299
+ | Default text adapter required error | Load SVG Text 0.4.x without sandbox |
300
300
  | Async Input required error | Load Async Input 0.3.x without sandbox before using the Bubble wait |
301
301
  | Runtime Expression required error | Load Runtime Expression 0.3.x without sandbox before using the Bubble wait |
302
302
  | `bubble style is not defined` | Run `define bubble style` first, including after restarting with green flag |
@@ -310,7 +310,7 @@ When a clone stops or is deleted, timers, SVG Text skins, and renderer drawables
310
310
 
311
311
  ## 13. Automatic cleanup
312
312
 
313
- Bubble automatically releases its owned timers, SVG Text skins, and renderer drawables when:
313
+ Bubble automatically releases its owned timers, text skins, and renderer drawables when:
314
314
 
315
315
  - `close this bubble` runs;
316
316
  - the same sprite or clone runs another `say` or `think`;
package/docs/index.html CHANGED
@@ -71,7 +71,7 @@
71
71
  <p>This manual explains how to use <code>turbowarp-bubble</code> as an unsandboxed TurboWarp custom extension. A Bubble combines an SVG body, text, a character portrait, blinking and lip-sync layers, and an animated continue indicator.</p>
72
72
  <p><img src="./assets/block-quick-start.svg" alt="A quick-start block sequence that registers Next1 and Next2 separately, prepares input listeners, then uses Bubble&#39;s integrated wait"></p>
73
73
  <h2 id="requirements">1. Load the required extensions</h2>
74
- <p>The complete input-wait example uses six extensions. Add Temporary Variables from TurboWarp&#39;s extension library, then load the custom extensions needed by the selected features with <strong>Run without sandbox</strong> enabled. SVG Text and Bubble are required for text bubbles. Asset Manager is required for portrait, lip-sync, continue indicator, voice, and display-sound assets. Async Input and Runtime Expression are required only before using a Bubble wait.</p>
74
+ <p>The complete input-wait example uses six extensions. Add Temporary Variables from TurboWarp&#39;s extension library, then load the custom extensions needed by the selected features with <strong>Run without sandbox</strong> enabled. Bubble uses SVG Text as its default <code>BubbleTextCapability</code> adapter for text bubbles. Asset Manager is required for portrait, lip-sync, continue indicator, voice, and display-sound assets. Async Input and Runtime Expression are required only before using a Bubble wait.</p>
75
75
  <table>
76
76
  <thead>
77
77
  <tr>
@@ -107,11 +107,11 @@
107
107
  </tr>
108
108
  <tr>
109
109
  <td align="right">6</td>
110
- <td>Bubble 0.3.1</td>
111
- <td>After npm publication: <code>https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-bubble@0.3.1/dist/turbowarp-bubble.js</code></td>
110
+ <td>Bubble 0.5.0</td>
111
+ <td><code>https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-bubble@0.5.0/dist/turbowarp-bubble.js</code></td>
112
112
  </tr>
113
113
  </tbody></table>
114
- <p>To try a development build, load this repository&#39;s <code>dist/turbowarp-bubble.js</code> as a local custom extension. Bubble reports an explicit error if SVG Text is missing when it displays a Bubble, if an image/media feature is used without Asset Manager, or if Async Input or Runtime Expression is missing when it starts a Bubble wait.</p>
114
+ <p>To try a development build, load this repository&#39;s <code>dist/turbowarp-bubble.js</code> as a local custom extension. Bubble reports an explicit error if the default SVG Text adapter is missing when it displays a Bubble, if an image/media feature is used without Asset Manager, or if Async Input or Runtime Expression is missing when it starts a Bubble wait. The lower-level Composition API can use another text capability and does not require SVG Text.</p>
115
115
  <p>See also:</p>
116
116
  <ul>
117
117
  <li><a href="https://kubohiroya.github.io/turbowarp-asset-manager/">Asset Manager guide</a></li>
@@ -483,7 +483,7 @@ think [MESSAGE] with bubble style [STYLE]
483
483
  <td>Load Asset Manager 0.7.x without sandbox before using image/media assets</td>
484
484
  </tr>
485
485
  <tr>
486
- <td>SVG Text required error</td>
486
+ <td>Default text adapter required error</td>
487
487
  <td>Load SVG Text 0.4.x without sandbox</td>
488
488
  </tr>
489
489
  <tr>
@@ -528,7 +528,7 @@ think [MESSAGE] with bubble style [STYLE]
528
528
  </tr>
529
529
  </tbody></table>
530
530
  <h2>13. Automatic cleanup</h2>
531
- <p>Bubble automatically releases its owned timers, SVG Text skins, and renderer drawables when:</p>
531
+ <p>Bubble automatically releases its owned timers, text skins, and renderer drawables when:</p>
532
532
  <ul>
533
533
  <li><code>close this bubble</code> runs;</li>
534
534
  <li>the same sprite or clone runs another <code>say</code> or <code>think</code>;</li>
@@ -71,7 +71,7 @@
71
71
  <p>このマニュアルでは、<code>turbowarp-bubble</code>をTurboWarpのカスタム拡張機能として使い、SVG本体、文字、キャラクター表情、目パチ、口パク、「次へ」アイコンを組み合わせたBubbleを表示します。</p>
72
72
  <p><img src="../assets/block-quick-start.svg" alt="Next1とNext2を個別登録し、入力listenerを準備してBubble内蔵待機を使うブロック例"></p>
73
73
  <h2 id="requirements">1. 必要な拡張機能</h2>
74
- <p>入力待ちを含む完全な例では6つの拡張機能を使います。TurboWarpの拡張機能ライブラリからTemporary Variablesを追加し、選択した機能に必要なカスタム拡張機能を「サンドボックスなしで実行」を許可して読み込みます。文字BubbleにはSVG TextとBubbleが必要です。portrait、lip-sync、continue indicator、フルボイス、表示効果音などのメディアアセットにはAsset Managerが必要です。Async InputとRuntime ExpressionはBubble待機を使う場合だけ必要です。</p>
74
+ <p>入力待ちを含む完全な例では6つの拡張機能を使います。TurboWarpの拡張機能ライブラリからTemporary Variablesを追加し、選択した機能に必要なカスタム拡張機能を「サンドボックスなしで実行」を許可して読み込みます。Bubbleは文字Bubbleの既定<code>BubbleTextCapability</code> adapterとしてSVG Textを使います。portrait、lip-sync、continue indicator、フルボイス、表示効果音などのメディアアセットにはAsset Managerが必要です。Async InputとRuntime ExpressionはBubble待機を使う場合だけ必要です。</p>
75
75
  <table>
76
76
  <thead>
77
77
  <tr>
@@ -107,11 +107,11 @@
107
107
  </tr>
108
108
  <tr>
109
109
  <td align="right">6</td>
110
- <td>Bubble 0.3.1</td>
111
- <td>npm公開後は<code>https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-bubble@0.3.1/dist/turbowarp-bubble.js</code></td>
110
+ <td>Bubble 0.5.0</td>
111
+ <td><code>https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-bubble@0.5.0/dist/turbowarp-bubble.js</code></td>
112
112
  </tr>
113
113
  </tbody></table>
114
- <p>開発中のBubbleを試す場合は、このリポジトリの<code>dist/turbowarp-bubble.js</code>をローカルカスタム拡張機能として読み込みます。表示時にSVG Textが、画像・メディア機能の使用時にAsset Managerが、待機開始時にAsync InputかRuntime Expressionが見つからなければ、Bubbleは明示的なエラーを返します。</p>
114
+ <p>開発中のBubbleを試す場合は、このリポジトリの<code>dist/turbowarp-bubble.js</code>をローカルカスタム拡張機能として読み込みます。表示時に既定のSVG Text adapterが、画像・メディア機能の使用時にAsset Managerが、待機開始時にAsync InputかRuntime Expressionが見つからなければ、Bubbleは明示的なエラーを返します。低レベルComposition APIでは別のtext capabilityを注入でき、その場合SVG Textは不要です。</p>
115
115
  <p>参考:</p>
116
116
  <ul>
117
117
  <li><a href="https://kubohiroya.github.io/turbowarp-asset-manager/ja/">Asset Manager 日本語ガイド</a></li>
@@ -483,7 +483,7 @@ think [MESSAGE] with bubble style [STYLE]
483
483
  <td>画像・メディアアセットを使う前にAsset Manager 0.7.xを読み込む</td>
484
484
  </tr>
485
485
  <tr>
486
- <td>SVG Textを要求するエラー</td>
486
+ <td>既定text adapterを要求するエラー</td>
487
487
  <td>SVG Text 0.4.xをサンドボックスなしで読み込む</td>
488
488
  </tr>
489
489
  <tr>
@@ -528,7 +528,7 @@ think [MESSAGE] with bubble style [STYLE]
528
528
  </tr>
529
529
  </tbody></table>
530
530
  <h2>13. 自動解放されるタイミング</h2>
531
- <p>次の場合、Bubbleが所有するtimer、SVG Text skin、renderer drawableは自動的に解放されます。</p>
531
+ <p>次の場合、Bubbleが所有するtimer、text skin、renderer drawableは自動的に解放されます。</p>
532
532
  <ul>
533
533
  <li><code>close this bubble</code></li>
534
534
  <li>同じsprite/cloneで次の<code>say</code>または<code>think</code>を実行したとき</li>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubohiroya/turbowarp-bubble",
3
- "version": "0.3.1",
3
+ "version": "0.5.0",
4
4
  "description": "Composable say and think bubbles with portrait layers and animated continue indicators for TurboWarp.",
5
5
  "author": "Hiroya Kubo <hiroya@cuc.ac.jp>",
6
6
  "type": "module",
@@ -81,6 +81,9 @@
81
81
  },
82
82
  "@kubohiroya/turbowarp-runtime-expression": {
83
83
  "optional": true
84
+ },
85
+ "@kubohiroya/turbowarp-svg-text": {
86
+ "optional": true
84
87
  }
85
88
  },
86
89
  "devDependencies": {