@kubohiroya/turbowarp-bubble 0.8.0 → 0.9.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.
@@ -1,6 +1,10 @@
1
1
  import type { BubbleOffsetInput } from "./actor-transform.js";
2
2
  export declare const bubbleVisualStyles: readonly ["NORMAL", "THINKING", "DREAMING", "YELLING", "OFF_PANEL", "WAVY", "WHISPERING", "ANNOUNCEMENT", "NARRATION", "NO_BUBBLE"];
3
3
  export type BubbleVisualStyle = (typeof bubbleVisualStyles)[number];
4
+ export declare function bubbleBodyMinimumSize(...styles: readonly BubbleVisualStyle[]): Readonly<{
5
+ height: number;
6
+ width: number;
7
+ }>;
4
8
  export interface RenderBubbleSvgInput {
5
9
  readonly style: BubbleVisualStyle;
6
10
  readonly lines: readonly string[];
@@ -4,6 +4,7 @@ import { type BubbleVisualStyle } from "./bubble-svg.js";
4
4
  import { type BubbleRevealInput, type BubbleRevealUnit, type NormalizedBubbleReveal } from "./reveal.js";
5
5
  import type { BubbleTextCapability, BubbleTextTarget } from "./text-capability.js";
6
6
  import { type BubblePortraitOffset, type BubblePortraitOffsetInput, type BubblePortraitPlacement } from "./portrait-layout.js";
7
+ import { type BubbleLayoutProfile, type ScratchBubbleTextLayout } from "./scratch-default.js";
7
8
  export type { BubbleTextCapability, BubbleTextTarget, } from "./text-capability.js";
8
9
  export { UnicodeLineBreakProvider, wrapText, type LineBreakOpportunity, type LineBreakProvider, type TextWidthMeasurer, type WrappedTextLayout, type WrappedTextLine, type WrapTextInput, } from "./text-layout.js";
9
10
  export { bubbleBackgroundRegions, bubbleDirectionAliases, bubbleDirectionNames, defaultBubblePlacementInput, normalizeBubblePlacement, type BubbleActorPlacement, type BubbleBackgroundPlacement, type BubbleBackgroundRegion, type BubbleDirectionAlias, type BubbleDirectionName, type BubblePlacement, type BubblePlacementInput, } from "./placement.js";
@@ -11,6 +12,7 @@ export { actorRelativeBubbleCenter, defaultBubbleDistance, defaultBubbleOffset,
11
12
  export { bubbleBodyCenterOffset, bubbleVisualStyles, renderBubbleSvg, type BubbleBodyCenterOffsetInput, type BubbleShapeTransition, type BubbleVisualStyle, type RenderBubbleSvgInput, } from "./bubble-svg.js";
12
13
  export { bubbleRevealUnits, normalizeBubbleReveal, revealedBubbleText, splitBubbleText, type BubbleRevealInput, type BubbleRevealLayout, type BubbleRevealUnit, type NormalizedBubbleReveal, } from "./reveal.js";
13
14
  export { bubblePortraitPlacements, defaultBubblePortraitCornerRadius, defaultBubblePortraitOffset, defaultBubblePortraitPlacement, normalizeBubblePortraitCornerRadius, normalizeBubblePortraitOffset, normalizeBubblePortraitPlacement, type BubblePortraitOffset, type BubblePortraitOffsetInput, type BubblePortraitPlacement, } from "./portrait-layout.js";
15
+ export { bubbleLayoutProfileForStyleInput, formatScratchBubbleArgument, isScratchDefaultBubbleStyleInput, layoutScratchBubbleText, positionScratchBubble, renderScratchBubbleSvg, scratchBubbleMetrics, scratchBubbleCornerRadius, scratchBubbleFontSize, scratchBubbleLineHeight, scratchBubbleMaximumLineWidth, scratchBubbleMinimumTextWidth, scratchBubblePadding, scratchBubbleStrokeWidth, scratchBubbleTailHeight, scratchBubbleTextLimit, type BubbleLayoutProfile, type ScratchBubbleKind, type ScratchBubbleMetrics, type ScratchBubblePosition, type ScratchBubblePositionInput, type ScratchBubbleTextLayout, type ScratchBubbleTextLine, } from "./scratch-default.js";
14
16
  export type BubbleKind = "say" | "think";
15
17
  export type BubbleAnimationMode = "idle" | "talking" | "awaiting-continue";
16
18
  export type BubbleEase = "linear" | "easeIn" | "easeOut" | "easeInOut";
@@ -84,6 +86,7 @@ export interface BubblePortrait {
84
86
  export interface BubbleStyle {
85
87
  readonly name: string;
86
88
  readonly textStyle: string;
89
+ readonly layoutProfile: BubbleLayoutProfile;
87
90
  readonly maxWidth?: number;
88
91
  readonly textLocale?: string;
89
92
  readonly placement: BubblePlacement;
@@ -133,6 +136,8 @@ export interface BubbleSurface {
133
136
  /** Captures the currently rendered text size for RESERVED reveal layout. */
134
137
  captureTextLayout?(): void;
135
138
  clearTextLayout?(): void;
139
+ /** Renders the built-in Scratch-compatible text and body as one surface. */
140
+ renderScratchText?(layout: ScratchBubbleTextLayout): void | Promise<void>;
136
141
  }
137
142
  export interface BubbleSurfaceFactoryInput {
138
143
  readonly actor: unknown;
@@ -0,0 +1,67 @@
1
+ export declare const scratchBubbleTextLimit = 330;
2
+ export declare const scratchBubbleMaximumLineWidth = 170;
3
+ export declare const scratchBubbleMinimumTextWidth = 50;
4
+ export declare const scratchBubbleStrokeWidth = 4;
5
+ export declare const scratchBubblePadding = 10;
6
+ export declare const scratchBubbleCornerRadius = 16;
7
+ export declare const scratchBubbleTailHeight = 12;
8
+ export declare const scratchBubbleFontSize = 14;
9
+ export declare const scratchBubbleLineHeight = 16;
10
+ export type BubbleLayoutProfile = "scratch-default" | "custom";
11
+ export type ScratchBubbleKind = "say" | "think";
12
+ export interface ScratchBubbleTextLine {
13
+ readonly text: string;
14
+ readonly width: number;
15
+ }
16
+ export interface ScratchBubbleTextLayout {
17
+ readonly lines: readonly ScratchBubbleTextLine[];
18
+ readonly maxLineWidth: number;
19
+ readonly text: string;
20
+ }
21
+ export interface ScratchBubbleMetrics {
22
+ readonly bodyHeight: number;
23
+ readonly bodyWidth: number;
24
+ readonly height: number;
25
+ readonly paddedHeight: number;
26
+ readonly paddedWidth: number;
27
+ readonly width: number;
28
+ }
29
+ export interface ScratchBubblePositionInput {
30
+ readonly bounds: Readonly<{
31
+ bottom: number;
32
+ left: number;
33
+ right: number;
34
+ top: number;
35
+ }>;
36
+ readonly height: number;
37
+ /** Whether the bubble body is positioned to the actor's left. */
38
+ readonly pointsLeft: boolean;
39
+ readonly stageHeight: number;
40
+ readonly stageWidth: number;
41
+ readonly width: number;
42
+ }
43
+ export interface ScratchBubblePosition {
44
+ readonly centerX: number;
45
+ readonly centerY: number;
46
+ readonly left: number;
47
+ /** Whether the bubble body is positioned to the actor's left. */
48
+ readonly pointsLeft: boolean;
49
+ readonly top: number;
50
+ }
51
+ /**
52
+ * The block-level basic style is intentionally narrow. Any explicit layout,
53
+ * body, media, reveal, or motion option selects the existing custom renderer.
54
+ */
55
+ export declare function bubbleLayoutProfileForStyleInput(value: unknown): BubbleLayoutProfile;
56
+ export declare function isScratchDefaultBubbleStyleInput(value: unknown): boolean;
57
+ /** Matches the numeric presentation and length limit used by say/think. */
58
+ export declare function formatScratchBubbleArgument(value: unknown): string;
59
+ export declare function layoutScratchBubbleText(value: string, measureText?: (text: string) => number): ScratchBubbleTextLayout;
60
+ export declare function scratchBubbleMetrics(layout: ScratchBubbleTextLayout): ScratchBubbleMetrics;
61
+ export declare function positionScratchBubble(input: ScratchBubblePositionInput): ScratchBubblePosition;
62
+ export declare function renderScratchBubbleSvg(input: Readonly<{
63
+ kind: ScratchBubbleKind;
64
+ layout: ScratchBubbleTextLayout;
65
+ pointsLeft: boolean;
66
+ title?: string;
67
+ }>): string;
@@ -1,4 +1,4 @@
1
- import { type BubbleImageCapability, type BubbleScheduler, type BubbleStyle, type BubbleSurface, type BubbleTextCapability } from "./composition.js";
1
+ import { type BubbleImageCapability, type BubbleKind, type BubbleScheduler, type BubbleStyle, type BubbleSurface, type BubbleTextCapability } from "./composition.js";
2
2
  export type BubbleRenderBackend = "scratch-render" | "svg-overlay";
3
3
  export type BubbleOverlayUnsupportedBehavior = "error" | "fallback";
4
4
  export declare const bubbleRenderBackends: readonly ["scratch-render", "svg-overlay"];
@@ -94,4 +94,4 @@ export interface BubbleSvgOverlaySurfaceManager {
94
94
  export declare function createSvgOverlayTextAdapter(capabilityInput: BubbleSvgOverlayTextCapability, renderer: Pick<BubbleSvgOverlayRenderer, "getNativeSize">): BubbleTextCapability;
95
95
  export declare function createSvgOverlayImageAdapter(capabilityInput: BubbleSvgOverlayImageCapability): BubbleImageCapability;
96
96
  export declare function createSvgOverlaySurfaceManager(renderer: BubbleSvgOverlayRenderer, documentInput: Document): BubbleSvgOverlaySurfaceManager;
97
- export declare function createSvgOverlaySurface(manager: BubbleSvgOverlaySurfaceManager, actor: BubbleSvgOverlayActor, actorKey: string, style: BubbleStyle, scheduler: BubbleScheduler): BubbleSurface;
97
+ export declare function createSvgOverlaySurface(manager: BubbleSvgOverlaySurfaceManager, actor: BubbleSvgOverlayActor, actorKey: string, kind: BubbleKind, style: BubbleStyle, scheduler: BubbleScheduler): BubbleSurface;
@@ -1,7 +1,8 @@
1
1
  import { type BubbleComposition, type BubbleCompositionOptions, type BubbleAudioCapability, type BubbleImageCapability, type BubbleScheduler, type BubbleTextCapability } from "./composition.js";
2
2
  import { type TurboWarpSvgTextExtension } from "./turbowarp-svg-text-adapter.js";
3
+ import { type AssetManagerDOMImageCapability } from "./asset-manager-image-adapter.js";
3
4
  export { createAssetManagerSvgOverlayImageCapability, type AssetManagerDOMImageCapability, type AssetManagerDOMImageResource, } from "./asset-manager-image-adapter.js";
4
- export { createSvgTextCompositionCapability, createSvgTextOverlayTextCapability, createTurboWarpSvgTextCapability, type SvgTextLayoutCompositionLike, type TurboWarpSvgTextExtension, } from "./turbowarp-svg-text-adapter.js";
5
+ export { createSvgTextCompositionCapability, createSvgTextOverlayTextCapability, createTurboWarpSvgTextCapability, createTurboWarpSvgTextOverlayTextCapability, type SvgTextLayoutCompositionLike, type TurboWarpSvgTextExtension, } from "./turbowarp-svg-text-adapter.js";
5
6
  import { type BubbleOverlayUnsupportedBehavior, type BubbleRenderBackend, type BubbleSvgOverlayImageCapability, type BubbleSvgOverlayTextCapability } from "./svg-overlay-surface.js";
6
7
  export { createSvgOverlayImageAdapter, createSvgOverlaySurface, createSvgOverlaySurfaceManager, createSvgOverlayTextAdapter, bubbleRenderBackends, defaultBubbleOverlayUnsupportedBehavior, defaultBubbleRenderBackend, type BubbleOverlayUnsupportedBehavior, type BubbleRenderBackend, type BubbleSvgOverlayActor, type BubbleSvgOverlayImageCapability, type BubbleSvgOverlayImageResource, type BubbleSvgOverlayRenderer, type BubbleSvgOverlaySurfaceManager, type BubbleSvgOverlayTextCapability, type BubbleSvgOverlayTextLine, type BubbleSvgOverlayTextLayout, } from "./svg-overlay-surface.js";
7
8
  export interface TurboWarpBubbleTarget {
@@ -45,6 +46,8 @@ export interface TurboWarpAssetManagerExtension {
45
46
  getAssetMimeType(args: Readonly<{
46
47
  NAME: unknown;
47
48
  }>): string;
49
+ /** Available from Asset Manager 0.12.1 for the skin-free overlay path. */
50
+ getDOMImageCapability?(): AssetManagerDOMImageCapability;
48
51
  playSound?(args: Readonly<{
49
52
  NAME: unknown;
50
53
  }>): Promise<void>;
@@ -1,6 +1,7 @@
1
1
  import type { BubbleTextCapability } from "./text-capability.js";
2
2
  import type { BubbleSvgOverlayTextCapability } from "./svg-overlay-surface.js";
3
3
  export interface TurboWarpSvgTextExtension {
4
+ getLayoutCapability?(): SvgTextLayoutCompositionLike;
4
5
  setText(args: Readonly<{
5
6
  STYLE: unknown;
6
7
  TEXT: unknown;
@@ -53,4 +54,8 @@ export declare function createSvgTextCompositionCapability(compositionInput: unk
53
54
  * The adapter preserves SVG Text's line coordinates without creating skins.
54
55
  */
55
56
  export declare function createSvgTextOverlayTextCapability(compositionInput: SvgTextLayoutCompositionLike): BubbleSvgOverlayTextCapability;
57
+ /**
58
+ * Adapts the stock SVG Text extension's shared named-style layout registry.
59
+ */
60
+ export declare function createTurboWarpSvgTextOverlayTextCapability(extensionInput: unknown): BubbleSvgOverlayTextCapability;
56
61
  export {};
@@ -14,7 +14,7 @@
14
14
 
15
15
  <rect width="1200" height="880" fill="#f2f4f8"/>
16
16
  <text x="32" y="48" class="heading">Bubbleブロック:最小構成</text>
17
- <text x="32" y="74" class="body">緑の旗でstyleと入力を準備し、セリフごとに say → Bubble内蔵待機 → close を実行します。</text>
17
+ <text x="32" y="74" class="body">緑の旗でstyleと入力を準備し、セリフごとに show → Bubble内蔵待機 → close を実行します。</text>
18
18
  <g>
19
19
  <rect x="24" y="96" width="560" height="752" rx="20" fill="#ffffff" stroke="#d9deea" stroke-width="2"/>
20
20
  <text x="48" y="134" class="subheading">1. 緑の旗で準備</text>
@@ -172,15 +172,15 @@
172
172
  <rect x="1029.0400000000002" y="460" width="68.07999999999998" height="25" rx="12.5" fill="#ffffff" fill-opacity="0.96"/>
173
173
  <text x="1037.0400000000002" y="479" class="input-text" style="font-size:12px">pressed</text>
174
174
  </g>
175
- <g role="group" aria-label="sayブロックでセリフを表示">
175
+ <g role="group" aria-label="showブロックでセリフを表示">
176
176
  <rect x="668" y="506" width="454" height="50" rx="12" fill="#ff6680" stroke="#000000" stroke-opacity="0.14" stroke-width="2"/>
177
177
  <rect x="686" y="506" width="28" height="6" rx="3" fill="#000000" fill-opacity="0.18"/>
178
- <text x="685" y="537" class="block-text" style="font-size:14px">say</text>
179
- <rect x="718.04" y="516" width="86" height="27" rx="13.5" fill="#ffffff" fill-opacity="0.96"/>
180
- <text x="726.04" y="537" class="input-text" style="font-size:14px">海へ出発!</text>
181
- <text x="811.04" y="537" class="block-text" style="font-size:14px">with bubble style</text>
182
- <rect x="965.6" y="516" width="128.84000000000003" height="27" rx="13.5" fill="#ffffff" fill-opacity="0.96"/>
183
- <text x="973.6" y="537" class="input-text" style="font-size:14px">hero-dialogue</text>
178
+ <text x="685" y="537" class="block-text" style="font-size:14px">show</text>
179
+ <rect x="726.72" y="516" width="86" height="27" rx="13.5" fill="#ffffff" fill-opacity="0.96"/>
180
+ <text x="734.72" y="537" class="input-text" style="font-size:14px">海へ出発!</text>
181
+ <text x="819.72" y="537" class="block-text" style="font-size:14px">with bubble style</text>
182
+ <rect x="974.2800000000001" y="516" width="128.84000000000003" height="27" rx="13.5" fill="#ffffff" fill-opacity="0.96"/>
183
+ <text x="982.2800000000001" y="537" class="input-text" style="font-size:14px">hero-dialogue</text>
184
184
  </g>
185
185
  <g role="group" aria-label="Bubbleで条件成立またはタイムアウトまで待機">
186
186
  <rect x="668" y="568" width="454" height="72" rx="12" fill="#ff6680" stroke="#000000" stroke-opacity="0.14" stroke-width="2"/>
Binary file
@@ -30,16 +30,7 @@
30
30
  <rect x="344" y="118" width="296" height="280" rx="18" fill="#ffffff" stroke="#d9deea" stroke-width="2"/>
31
31
  <text x="360" y="150" style="fill:#25283a;font-size:18px;font-weight:700">THINKING</text>
32
32
  <svg x="352" y="162" width="280" height="170" viewBox="0 0 280 170" data-bubble-renderer="canonical" data-bubble-style="THINKING" overflow="visible">
33
- <title>THINKING visual style example</title><circle cx="92.12515224204833" cy="153.37236839860094" r="5" fill="#fff4cc" stroke="#6f5b45" stroke-width="2"/><circle cx="88.82135196866629" cy="158.0906841737055" r="3.5" fill="#fff4cc" stroke="#6f5b45" stroke-width="2"/><g transform="translate(0 0) scale(1)"><path d="M 42 85
34
- C 22 65, 32 42, 60 44
35
- C 68 22, 122 19, 140 37
36
- C 164 16, 228 24, 226 48
37
- C 258 42, 263 82, 253 100
38
- C 264 136, 236 153, 214 139
39
- C 201 158, 152 153, 140 139
40
- C 116 158, 66 153, 62 134
41
- C 31 148, 17 105, 42 85 Z"
42
- fill="#fff4cc" stroke="#6f5b45" stroke-width="3" stroke-linejoin="round"/></g><text x="140" y="89.9" text-anchor="middle" fill="#25283a" font-family="Noto Sans JP, sans-serif" font-size="14">どうしようかな…</text>
33
+ <title>THINKING visual style example</title><circle cx="92.12515224204833" cy="153.37236839860094" r="5" fill="#fff4cc" stroke="#6f5b45" stroke-width="2"/><circle cx="88.82135196866629" cy="158.0906841737055" r="3.5" fill="#fff4cc" stroke="#6f5b45" stroke-width="2"/><g transform="translate(0 0) scale(1)"><path d="M 24.0000 85.0000 C 24.0000 76.8667 24.0000 66.7000 30.9600 60.6000 C 37.9200 54.5000 56.0933 53.6867 65.7600 48.4000 C 75.4267 43.1133 76.5867 29.6933 88.9600 28.8800 C 101.3333 28.0667 124.5333 43.7233 140.0000 43.5200 C 155.4667 43.3167 168.6133 27.2533 181.7600 27.6600 C 194.9067 28.0667 207.2800 40.4700 218.8800 45.9600 C 230.4800 51.4500 245.1733 53.6867 251.3600 60.6000 C 257.5467 67.5133 257.1600 79.3067 256.0000 87.4400 C 254.8400 95.5733 251.3600 103.3000 244.4000 109.4000 C 237.4400 115.5000 224.6800 118.5500 214.2400 124.0400 C 203.8000 129.5300 194.1333 141.9333 181.7600 142.3400 C 169.3867 142.7467 153.9200 126.4800 140.0000 126.4800 C 126.0800 126.4800 110.6133 142.7467 98.2400 142.3400 C 85.8667 141.9333 76.9733 129.5300 65.7600 124.0400 C 54.5467 118.5500 37.9200 115.9067 30.9600 109.4000 C 24.0000 102.8933 24.0000 93.1333 24.0000 85.0000 Z" fill="#fff4cc" stroke="#6f5b45" stroke-width="3" stroke-linejoin="round"/></g><text x="140" y="89.9" text-anchor="middle" fill="#25283a" font-family="Noto Sans JP, sans-serif" font-size="14">どうしようかな…</text>
43
34
  </svg>
44
35
  <text x="492" y="350" text-anchor="middle" class="small">思考</text>
45
36
  <text x="492" y="368" text-anchor="middle" class="small">雲形本体+小さな丸のtrail</text>
@@ -49,16 +40,7 @@
49
40
  <rect x="656" y="118" width="296" height="280" rx="18" fill="#ffffff" stroke="#d9deea" stroke-width="2"/>
50
41
  <text x="672" y="150" style="fill:#25283a;font-size:18px;font-weight:700">DREAMING</text>
51
42
  <svg x="664" y="162" width="280" height="170" viewBox="0 0 280 170" data-bubble-renderer="canonical" data-bubble-style="DREAMING" overflow="visible">
52
- <title>DREAMING visual style example</title><circle cx="92.64137103476426" cy="152.63513155874082" r="7" fill="#fff4cc" stroke="#6f5b45" stroke-width="2"/><circle cx="89.23432700283905" cy="157.50089470181746" r="4.5" fill="#fff4cc" stroke="#6f5b45" stroke-width="2"/><circle cx="86.96296431488891" cy="160.74473679720185" r="3" fill="#fff4cc" stroke="#6f5b45" stroke-width="2"/><g transform="translate(0 0) scale(1)"><path d="M 42 85
53
- C 22 65, 32 42, 60 44
54
- C 68 22, 122 19, 140 37
55
- C 164 16, 228 24, 226 48
56
- C 258 42, 263 82, 253 100
57
- C 264 136, 236 153, 214 139
58
- C 201 158, 152 153, 140 139
59
- C 116 158, 66 153, 62 134
60
- C 31 148, 17 105, 42 85 Z"
61
- fill="#fff4cc" stroke="#6f5b45" stroke-width="3" stroke-linejoin="round"/></g><text x="140" y="89.9" text-anchor="middle" fill="#25283a" font-family="Noto Sans JP, sans-serif" font-size="14">いつか空の向こうへ</text>
43
+ <title>DREAMING visual style example</title><circle cx="92.64137103476426" cy="152.63513155874082" r="7" fill="#fff4cc" stroke="#6f5b45" stroke-width="2"/><circle cx="89.23432700283905" cy="157.50089470181746" r="4.5" fill="#fff4cc" stroke="#6f5b45" stroke-width="2"/><circle cx="86.96296431488891" cy="160.74473679720185" r="3" fill="#fff4cc" stroke="#6f5b45" stroke-width="2"/><g transform="translate(0 0) scale(1)"><path d="M 24.0000 85.0000 C 24.0000 76.8667 24.0000 66.7000 30.9600 60.6000 C 37.9200 54.5000 56.0933 53.6867 65.7600 48.4000 C 75.4267 43.1133 76.5867 29.6933 88.9600 28.8800 C 101.3333 28.0667 124.5333 43.7233 140.0000 43.5200 C 155.4667 43.3167 168.6133 27.2533 181.7600 27.6600 C 194.9067 28.0667 207.2800 40.4700 218.8800 45.9600 C 230.4800 51.4500 245.1733 53.6867 251.3600 60.6000 C 257.5467 67.5133 257.1600 79.3067 256.0000 87.4400 C 254.8400 95.5733 251.3600 103.3000 244.4000 109.4000 C 237.4400 115.5000 224.6800 118.5500 214.2400 124.0400 C 203.8000 129.5300 194.1333 141.9333 181.7600 142.3400 C 169.3867 142.7467 153.9200 126.4800 140.0000 126.4800 C 126.0800 126.4800 110.6133 142.7467 98.2400 142.3400 C 85.8667 141.9333 76.9733 129.5300 65.7600 124.0400 C 54.5467 118.5500 37.9200 115.9067 30.9600 109.4000 C 24.0000 102.8933 24.0000 93.1333 24.0000 85.0000 Z" fill="#fff4cc" stroke="#6f5b45" stroke-width="3" stroke-linejoin="round"/></g><text x="140" y="89.9" text-anchor="middle" fill="#25283a" font-family="Noto Sans JP, sans-serif" font-size="14">いつか空の向こうへ</text>
62
44
  </svg>
63
45
  <text x="804" y="350" text-anchor="middle" class="small">夢・回想</text>
64
46
  <text x="804" y="368" text-anchor="middle" class="small">柔らかな雲形+長い丸trail</text>
@@ -8,15 +8,15 @@
8
8
 
9
9
  ## 1. 必要な拡張機能
10
10
 
11
- 入力待ちを含む完全な例では5つの拡張機能を使います。TurboWarpの拡張機能ライブラリからTemporary Variablesを追加し、選択した機能に必要なカスタム拡張機能を「サンドボックスなしで実行」を許可して読み込みます。BubbleはSVG Text 0.8.0のhost-neutral layout providerをbundle内に持ち、既定のSVG overlayではskinを作りません。portrait、lip-sync、continue indicator、フルボイス、表示効果音などのメディアアセットにはAsset Managerが必要です。Async InputとRuntime ExpressionはBubble待機を使う場合だけ必要です。
11
+ 入力待ちを含む完全な例では5つの拡張機能を使います。TurboWarpの拡張機能ライブラリからTemporary Variablesを追加し、選択した機能に必要なカスタム拡張機能を「サンドボックスなしで実行」を許可して読み込みます。BubbleはSVG Text 0.8.1のhost-neutral layout providerをbundle内に持ち、既定のSVG overlayではskinを作りません。portrait、lip-sync、continue indicator、フルボイス、表示効果音などのメディアアセットにはAsset Managerが必要です。Async InputとRuntime ExpressionはBubble待機を使う場合だけ必要です。
12
12
 
13
13
  | 順番 | 拡張機能 | 読み込み先 |
14
14
  | ---: | ------------------------ | -------------------------------------------------------------------------------------------------------- |
15
15
  | 1 | Temporary Variables | TurboWarpの拡張機能ライブラリから追加 |
16
16
  | 2 | Async Input 0.4.0 | `https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-async-input@0.4.0/dist/async-input.js` |
17
17
  | 3 | Runtime Expression 0.4.0 | `https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-runtime-expression@0.4.0/dist/runtime-expression.js` |
18
- | 4 | Asset Manager 0.11.0 | `https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-asset-manager@0.11.0/dist/asset-manager.js` |
19
- | 5 | Bubble 0.8.0 | `https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-bubble@0.8.0/dist/turbowarp-bubble.js` |
18
+ | 4 | Asset Manager 0.12.1 | `https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-asset-manager@0.12.1/dist/asset-manager.js` |
19
+ | 5 | Bubble 0.9.0 | `https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-bubble@0.9.0/dist/turbowarp-bubble.js` |
20
20
 
21
21
  開発中のBubbleを試す場合は、このリポジトリの`dist/turbowarp-bubble.js`をローカルカスタム拡張機能として読み込みます。既定SVG overlayに必要なrenderer APIがない場合、画像・メディア機能の使用時にAsset Managerがない場合、待機開始時にAsync InputかRuntime Expressionがない場合は、Bubbleが明示的なエラーを返します。低レベルComposition APIでは別のtext capabilityを注入できます。
22
22
 
@@ -59,17 +59,36 @@ URL画像を使う場合は、`RESOURCE_ID`へHTTPS URLを指定します。Bubb
59
59
 
60
60
  ## 3. 文字layout styleを選ぶ
61
61
 
62
- standalone BubbleはSVG Text 0.8.0のlayout compositionを内包します。`default`または任意の名前を指定すると、初回参照時に背景透明のSVG Text既定styleとして初期化されます。
62
+ standalone BubbleはSVG Text 0.8.1のlayout compositionを内包し、2つのBubble styleを組み込みます。`say`はspeech本体とspeech tail、`think`はthought本体とround trailを持ち、本体とtail/trailの形は別項目ではなく1つのvisual styleとして選びます。短い`say [MESSAGE]`/`think [MESSAGE]`ブロックが対応styleを自動選択するため、基本経路にはstyle定義もstyle入力も不要です。どちらも予約text profile `default`、内容に追従するサイズ、14px Helvetica、右側優先・収まりに応じた左反転、block入力の330文字上限、空文字でのcloseを使います。4pxのSVG strokeを白いfillより先に描き、内側半分を隠すことで、見かけの輪郭をTurboWarp標準と同じ細さにします。それ以外のtext style名やstyle設定ブロックを使うとcustom profileになります。custom text styleは初回参照時に背景透明のSVG Text既定styleとして初期化されます。stock SVG Text 0.8.1をBubbleより先に別拡張として読み込んだprojectでは、Bubbleが公開`getLayoutCapability()`を使い、SVG Text blockで定義したnamed styleを維持します。handoffのない古いSVG Textがロード済みならstyleを黙って置換せず互換errorを返し、必要な場合だけ文書化済みscratch-render fallbackを選択します。
63
63
 
64
64
  ```text
65
65
  define bubble style [hero-dialogue] using text style [default]
66
66
  ```
67
67
 
68
- 独自のfont、色、alignmentを使うアプリhostは、`createSvgTextLayoutComposition()`へstyleを定義し、`createSvgTextOverlayTextCapability()`でBubbleへ注入します。既定経路も同じ`layoutText()`を使い、SVG文字skinは生成しません。Bubbleの配置、tail、吹き出し外形はBubble側が担当します。
68
+ 独自のfont、色、alignmentを使うアプリhostは、`createSvgTextLayoutComposition()`へstyleを定義し、`createSvgTextOverlayTextCapability()`でBubbleへ注入します。custom profileは同じ`layoutText()`を使い、既定overlay backendではSVG文字skinを生成しません。Bubbleの配置、tail、吹き出し外形はBubble側が担当します。
69
69
 
70
70
  ## 4. Bubble styleを定義する
71
71
 
72
- まず、Bubble style名と文字layout style名を関連付けます。
72
+ 基本Bubbleでは短いブロックをそのまま使います。組み込みBubble style `say`/`think`がそれぞれ自動選択されます。
73
+
74
+ ```text
75
+ say [こんにちは!]
76
+ think [うーん…]
77
+ ```
78
+
79
+ ### TurboWarp標準との比較
80
+
81
+ 次の画像は、1つのTurboWarp Editor projectで英語UIを使い、`Cat` spriteを`x=-80`、`y=0`、サイズ`80%`、Stageを白背景、入力を`Hello!`/`Hmm...`に揃えて撮影した実画面です。左列はTurboWarp標準の見た目ブロックです。右列は対応する組み込み`say`/`think` styleを使うBubbleの短い基本ブロックで、定義ブロックもsetterも使っていません。
82
+
83
+ ![TurboWarp標準のsay・think吹き出しとBubble基本profileを同じStageで比較した実画面](./assets/turbowarp-say-think-stage-comparison.png)
84
+
85
+ Stage図では、右側配置、内容に追従する本体、Actor側へ向くspeech tail/thought trailを同じ条件で確認できます。Bubbleは独立したSVG surfaceを描画しており、全4panelとも実際のTurboWarp Stageを切り出したものです。
86
+
87
+ ![TurboWarp標準のsay・thinkブロックと、設定不要のBubble基本say・thinkブロックおよび組み込みdefault profile値を比較したスクリーンショット](./assets/turbowarp-say-think-block-comparison.png)
88
+
89
+ ブロック図は設定不要の基本経路と、custom style用の統合表示ブロックを示します。短いブロックは対応する組み込みstyleを自動選択します。calloutでは不可分な本体+tail/trailの組、両styleが使う予約text profile `default`、共通のfont、行高、幅、padding、角丸、色、border描画順、配置を示します。named custom styleには`show [MESSAGE] with bubble style [STYLE]`を使います。旧styled say/think opcodeは保存済みproject互換用の非表示定義として残します。
90
+
91
+ 次のsetterを使うと、意図的にcustom profileへ切り替わります。
73
92
 
74
93
  ```text
75
94
  define bubble style [hero-dialogue] using text style [default]
@@ -88,7 +107,7 @@ Actor相対の16方向は、各方向をActor、Bubble外形、tail、文字を
88
107
 
89
108
  背景相対3図はStage外枠、安全領域、Bubble外形寸法、水平中央線、基準辺/中心を示します。外形はBubble側の共有`renderBubbleSvg`で生成しており、TurboWarp Editorで本体drawableを生成するrendererと同じです。
90
109
 
91
- Actor相対では、Actor中心からBubble全体の中心へ向かう方向を指定します。menuには次の16正規方向があります。
110
+ Actor相対placementはcustom profileへ適用され、Actor中心からBubble全体の中心へ向かう方向を指定します。未変更の基本profileはScratch標準の右側優先・自動左反転を使います。menuには次の16正規方向があります。
92
111
 
93
112
  ```text
94
113
  up / up-up-right / up-right / right-up-right
@@ -179,7 +198,7 @@ set bubble reveal unit [CHARACTER] every [0.05] seconds layout [RESERVED] for bu
179
198
  set bubble word delimiters [ /] show [false] for bubble style [hero-dialogue]
180
199
  set bubble reveal sound [Typewriter] for bubble style [hero-dialogue]
181
200
  set bubble voice [HeroVoice] for bubble style [hero-dialogue]
182
- say [海へ出発!] with bubble style [hero-dialogue]
201
+ show [海へ出発!] with bubble style [hero-dialogue]
183
202
  finish [CHARACTER] with condition [input == "pressed"] or timeout after [10] seconds
184
203
  ```
185
204
 
@@ -193,7 +212,7 @@ finish [CHARACTER] with condition [input == "pressed"] or timeout after [10] sec
193
212
  set runtime variable [input] to []
194
213
  listen for key [Space] set runtime var [input] to [pressed]
195
214
  listen for touch on this sprite set runtime var [input] to [pressed]
196
- say [海へ出発!] with bubble style [hero-dialogue]
215
+ show [海へ出発!] with bubble style [hero-dialogue]
197
216
  wait with this bubble until condition [input == "pressed"] or timeout after [10] seconds
198
217
  close this bubble
199
218
  ```
@@ -235,14 +254,15 @@ animate bubble shape to [WAVY] speed [1] for [0.5] seconds
235
254
 
236
255
  TurboWarp adapterはこれらをschedulerのフレームごとに進め、各フレームの進行率へ`ease`を適用します。`shake`は吹き出し全体を方向・回数付きで揺らし、`explode`はportraitと文字を含むsurface全体を拡大して元へ戻し、`animate bubble shape`は指定時間中に現在の外形から`THINKING`、`DREAMING`、`YELLING`、`WAVY`、`WHISPERING`などへcross-fadeします。仕様では、吹き出しが表示される時点を「表示開始」、隠れる時点を「表示終了」と呼びます。
237
256
 
238
- ## 9. sayとthink
257
+ 表示中のBubbleを消すときは`close this bubble`を使います。設定済みの表示終了animationを実行してから、Bubbleのtimerと描画resourceを解放します。`set bubble hide animation ...`は終了時の演出を設定するだけで、このブロック自体はBubbleを消しません。組み込み基本profileでは、`say`/`think`へ空文字を渡してもTurboWarp標準と同様にcloseします。closeは非表示instanceを保持せず表示を破棄するため、別の`hide`ブロックは公開しません。
258
+
259
+ ## 9. named Bubble styleを表示する
239
260
 
240
261
  ```text
241
- say [MESSAGE] with bubble style [STYLE]
242
- think [MESSAGE] with bubble style [STYLE]
262
+ show [MESSAGE] with bubble style [STYLE]
243
263
  ```
244
264
 
245
- どちらも同じvisual style、表情レイヤー、placement、animation mode制御を使えます。`say`/`think`だけで形状を固定せず、`set bubble visual style`で`NORMAL`、`THINKING`などを明示的に選びます。Composition APIのsurfaceには`say`/`think`のkindも渡されるため、独自hostではkindに応じた追加表現も可能です。
265
+ 選択したBubble styleが、本体とtail/trailの形を一体で決め、text profile、表情レイヤー、placement、animation設定も保持します。`set bubble visual style`は`NORMAL`(speech本体+speech tail)や`THINKING`(thought本体+round trail)のような不可分の組を選ぶブロックで、tail形状だけを独立して指定する設定はありません。standalone extensionは、表示ブロックに競合し得る別の種類を選ばせず、そのstyleから内部描画kindを導きます。
246
266
 
247
267
  同じsprite、clone、またはStageで新しい`say`/`think`を実行すると、以前のBubbleをtimerやdrawableごと破棄してから置き換えます。Stageでは背景相対placementだけを使用できます。
248
268
 
@@ -258,46 +278,49 @@ cloneが停止・削除された場合は、そのtargetに属するtimer、over
258
278
 
259
279
  ## 11. ブロック一覧
260
280
 
261
- | ブロック | 説明 |
262
- | -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- |
263
- | `define bubble style [STYLE] using text style [TEXT_STYLE]` | Bubble styleを定義または再定義する |
264
- | `set bubble placement [PLACEMENT] for bubble style [STYLE]` | Actor相対方向・角度、または背景相対領域を設定する |
265
- | `set bubble distance [DISTANCE] for bubble style [STYLE]` | Actor boundsからtail先端までの距離を設定する |
266
- | `set bubble visual style [VISUAL_STYLE] for bubble style [STYLE]` | Bubble本体のSVG形状を10種類から設定する |
267
- | `set bubble tail length [LENGTH] for bubble style [STYLE]` | Bubble borderからtail先端までの基準長を設定する |
268
- | `set bubble offset x [X] y [Y] scale [SCALE] % for bubble style [STYLE]` | 本体位置と、文字を含む全体のscaleを設定する |
269
- | `set portrait base [ASSET] for bubble style [STYLE]` | portraitのベース画像を設定する |
270
- | `set portrait [PLACEMENT] offset x [X] y [Y] zoom [ZOOM] % corner radius [RADIUS] px for bubble style [STYLE]` | portraitの有無、端/隅の配置、変形、角丸を設定する |
271
- | `set blink frames [ASSETS] every [SECONDS] seconds for bubble style [STYLE]` | 目パチ差分と間隔を設定する |
272
- | `set lip-sync frames [ASSETS] every [SECONDS] seconds for bubble style [STYLE]` | 口パク差分と間隔を設定する |
273
- | `set continue frames [ASSETS] every [SECONDS] seconds for bubble style [STYLE]` | `awaiting-continue`中の「次へ」アニメーションを設定する |
274
- | `set bubble reveal unit [UNIT] every [SECONDS] seconds layout [LAYOUT] for bubble style [STYLE]` | CHARACTER/WORD/LINE/BLOCKの逐次表示を設定する |
275
- | `set bubble word delimiters [DELIMITERS] show [SHOW] for bubble style [STYLE]` | WORDの区切り文字集合と表示可否を設定する |
276
- | `set bubble reveal sound [ASSET] for bubble style [STYLE]` | 表示単位ごとの効果音を設定する |
277
- | `set bubble voice [ASSET] for bubble style [STYLE]` | 表示開始時のフルボイスを設定する |
278
- | `finish [UNIT] with condition [CONDITION] or timeout after [TIMEOUT] seconds` | 未表示単位を最後まで進め、条件またはtimeoutを待つ |
279
- | `set bubble show animation [MOTION] for [SECONDS] seconds for bubble style [STYLE]` | 表示開始animationを設定する |
280
- | `set bubble hide animation [MOTION] for [SECONDS] seconds for bubble style [STYLE]` | 表示終了animationを設定する |
281
- | `animate this bubble [MOTION]` | Bubble全体のanimationを再生する |
282
- | `shake this bubble direction [DIRECTION] count [COUNT] ease [EASE]` | 吹き出し全体を指定方向へ揺らす |
283
- | `explode this bubble relative scale [SCALE] count [COUNT] ease [EASE]` | 吹き出し全体を相対倍率で変化させる |
284
- | `animate bubble shape to [VISUAL_STYLE] speed [SPEED] for [SECONDS] seconds` | Bubble外形を時間経過で切り替える |
285
- | `say [MESSAGE] with bubble style [STYLE]` | `talking` modeでsay表示を開始・置換する |
286
- | `think [MESSAGE] with bubble style [STYLE]` | `talking` modeでthink表示を開始・置換する |
287
- | `set this bubble animation mode [MODE]` | `talking`、`awaiting-continue`、`idle`からmodeを選ぶ |
288
- | `wait with this bubble until condition [CONDITION] or timeout after [TIMEOUT] seconds` | Runtime Expressionの条件成立またはtimeoutまで待つ |
289
- | `close this bubble` | 自分のBubbleと所有resourceを解放する |
290
- | `Bubble version` | Bubble実装versionを返す |
281
+ | ブロック | 説明 |
282
+ | -------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
283
+ | `define bubble style [STYLE] using text style [TEXT_STYLE]` | Bubble styleを定義または再定義する |
284
+ | `set bubble placement [PLACEMENT] for bubble style [STYLE]` | Actor相対方向・角度、または背景相対領域を設定する |
285
+ | `set bubble distance [DISTANCE] for bubble style [STYLE]` | Actor boundsからtail先端までの距離を設定する |
286
+ | `set bubble visual style [VISUAL_STYLE] for bubble style [STYLE]` | 不可分なSVG本体+tail/trailの組を10種類から設定する |
287
+ | `set bubble tail length [LENGTH] for bubble style [STYLE]` | Bubble borderからtail先端までの基準長を設定する |
288
+ | `set bubble offset x [X] y [Y] scale [SCALE] % for bubble style [STYLE]` | 本体位置と、文字を含む全体のscaleを設定する |
289
+ | `set portrait base [ASSET] for bubble style [STYLE]` | portraitのベース画像を設定する |
290
+ | `set portrait [PLACEMENT] offset x [X] y [Y] zoom [ZOOM] % corner radius [RADIUS] px for bubble style [STYLE]` | portraitの有無、端/隅の配置、変形、角丸を設定する |
291
+ | `set blink frames [ASSETS] every [SECONDS] seconds for bubble style [STYLE]` | 目パチ差分と間隔を設定する |
292
+ | `set lip-sync frames [ASSETS] every [SECONDS] seconds for bubble style [STYLE]` | 口パク差分と間隔を設定する |
293
+ | `set continue frames [ASSETS] every [SECONDS] seconds for bubble style [STYLE]` | `awaiting-continue`中の「次へ」アニメーションを設定する |
294
+ | `set bubble reveal unit [UNIT] every [SECONDS] seconds layout [LAYOUT] for bubble style [STYLE]` | CHARACTER/WORD/LINE/BLOCKの逐次表示を設定する |
295
+ | `set bubble word delimiters [DELIMITERS] show [SHOW] for bubble style [STYLE]` | WORDの区切り文字集合と表示可否を設定する |
296
+ | `set bubble reveal sound [ASSET] for bubble style [STYLE]` | 表示単位ごとの効果音を設定する |
297
+ | `set bubble voice [ASSET] for bubble style [STYLE]` | 表示開始時のフルボイスを設定する |
298
+ | `finish [UNIT] with condition [CONDITION] or timeout after [TIMEOUT] seconds` | 未表示単位を最後まで進め、条件またはtimeoutを待つ |
299
+ | `set bubble show animation [MOTION] for [SECONDS] seconds for bubble style [STYLE]` | 表示開始animationを設定する |
300
+ | `set bubble hide animation [MOTION] for [SECONDS] seconds for bubble style [STYLE]` | 表示終了animationを設定する |
301
+ | `animate this bubble [MOTION]` | Bubble全体のanimationを再生する |
302
+ | `shake this bubble direction [DIRECTION] count [COUNT] ease [EASE]` | 吹き出し全体を指定方向へ揺らす |
303
+ | `explode this bubble relative scale [SCALE] count [COUNT] ease [EASE]` | 吹き出し全体を相対倍率で変化させる |
304
+ | `animate bubble shape to [VISUAL_STYLE] speed [SPEED] for [SECONDS] seconds` | Bubble外形を時間経過で切り替える |
305
+ | `say [MESSAGE]` | 組み込み`say` styleのspeech本体+tailを表示する |
306
+ | `think [MESSAGE]` | 組み込み`think` styleのthought本体+round trailを表示する |
307
+ | `show [MESSAGE] with bubble style [STYLE]` | styleが持つ本体+tail/trailの一組を表示する |
308
+ | `set this bubble animation mode [MODE]` | `talking`、`awaiting-continue`、`idle`からmodeを選ぶ |
309
+ | `wait with this bubble until condition [CONDITION] or timeout after [TIMEOUT] seconds` | Runtime Expressionの条件成立またはtimeoutまで待つ |
310
+ | `close this bubble` | 自分のBubbleと所有resourceを解放する |
311
+ | `Bubble version` | Bubble実装versionを返す |
312
+
313
+ 旧`say/think [MESSAGE] with bubble style [STYLE]` opcodeを使う保存済みprojectは引き続き動作しますが、この互換ブロック2個はpaletteに表示しません。新しいscriptでは統合`show`ブロックを使い、選択styleだけで本体とtail/trailの形を決めます。
291
314
 
292
315
  ## 12. よくあるエラー
293
316
 
294
317
  | 状況 | 原因と対処 |
295
318
  | ---------------------------------- | ------------------------------------------------------------------------ |
296
- | Asset Managerを要求するエラー | 画像・メディアアセットを使う前にAsset Manager 0.7.xを読み込む |
319
+ | Asset Managerを要求するエラー | 画像・メディアアセットを使う前にAsset Manager 0.12.xを読み込む |
297
320
  | SVG overlay backendのエラー | `renderer.addOverlay()`対応hostを使うか`scratch-render`を明示する |
298
321
  | Async Inputを要求するエラー | Bubble待機より前にAsync Input 0.3.xをサンドボックスなしで読み込む |
299
322
  | Runtime Expressionを要求するエラー | Bubble待機より前にRuntime Expression 0.3.xをサンドボックスなしで読み込む |
300
- | `bubble style is not defined` | `define bubble style`を先に実行する。緑の旗の再実行時も再定義する |
323
+ | `bubble style is not defined` | 組み込みの短いsay/thinkを使うか、named custom styleを先に定義する |
301
324
  | image assetが未登録 | `register resource ... as asset ...`の完了後にBubbleを表示する |
302
325
  | assetが画像ではない | `MIME type of asset [NAME]`で`image/*`か確認する |
303
326
  | continue framesが1枚 | 2枚以上にするか、空にしてcontinue表示を解除する |
@@ -323,6 +346,8 @@ Asset Managerへ登録したアセット自体はBubbleの所有物ではあり
323
346
 
324
347
  図とGIFはリポジトリ内のスクリプトから再生成できます。GIF生成にはImageMagickの`magick`コマンドが必要です。
325
348
 
349
+ 2つの`turbowarp-say-think-*-comparison.png`はrenderer previewから生成した図ではなく、TurboWarp Editorの実画面です。第4章に記載した撮影条件を使い、`docs:render`では上書きしません。
350
+
326
351
  ```sh
327
352
  pnpm docs:render
328
353
  pnpm docs:check