@kubohiroya/turbowarp-bubble 0.3.0 → 0.4.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 +37 -27
- package/dist/composition.js +72 -68
- package/dist/turbowarp-adapter.js +182 -142
- package/dist/turbowarp-bubble.js +84 -62
- package/dist/types/composition.d.ts +3 -16
- package/dist/types/text-capability.d.ts +26 -0
- package/dist/types/turbowarp-adapter.d.ts +4 -12
- package/dist/types/turbowarp-svg-text-adapter.d.ts +21 -0
- package/docs/block-manual.ja.md +5 -5
- package/docs/block-manual.md +5 -5
- package/docs/index.html +6 -6
- package/docs/ja/index.html +6 -6
- package/package.json +4 -1
|
@@ -3955,7 +3955,7 @@ function Sr(e) {
|
|
|
3955
3955
|
"sound"
|
|
3956
3956
|
]);
|
|
3957
3957
|
if (Object.keys(t).filter((e) => !n.has(e)).length > 0 || t.unit === void 0) throw TypeError("Bubble reveal has unknown or missing properties.");
|
|
3958
|
-
let r = xr(t.unit), i = t.delimiters ?? "
|
|
3958
|
+
let r = xr(t.unit), i = t.delimiters ?? " \r\n";
|
|
3959
3959
|
if (typeof i != "string" || i.length === 0) throw TypeError("Bubble WORD delimiters must be a non-empty string.");
|
|
3960
3960
|
let a = t.showDelimiters ?? !1;
|
|
3961
3961
|
if (typeof a != "boolean") throw TypeError("Bubble reveal showDelimiters must be boolean.");
|
|
@@ -3964,18 +3964,18 @@ function Sr(e) {
|
|
|
3964
3964
|
let s = t.intervalSeconds ?? 0;
|
|
3965
3965
|
if (typeof s != "number" || !Number.isFinite(s) || s < 0) throw TypeError("Bubble reveal intervalSeconds must be zero or greater.");
|
|
3966
3966
|
let c = t.sound;
|
|
3967
|
-
if (c !== void 0 && (typeof c != "string" || c.
|
|
3967
|
+
if (c !== void 0 && (typeof c != "string" || c.length === 0)) throw TypeError("Bubble reveal sound must be a non-empty asset name.");
|
|
3968
3968
|
return Object.freeze({
|
|
3969
3969
|
unit: r,
|
|
3970
3970
|
delimiters: i,
|
|
3971
3971
|
showDelimiters: a,
|
|
3972
3972
|
layout: o,
|
|
3973
3973
|
intervalSeconds: s,
|
|
3974
|
-
...c === void 0 ? {} : { sound: c
|
|
3974
|
+
...c === void 0 ? {} : { sound: c }
|
|
3975
3975
|
});
|
|
3976
3976
|
}
|
|
3977
3977
|
function Cr(e, t, n) {
|
|
3978
|
-
let r = new Set(
|
|
3978
|
+
let r = new Set(Array.from(t)), i = [], a = "";
|
|
3979
3979
|
for (let t of br(e)) a += t, r.has(t) && ((n || a.slice(0, -t.length).length > 0) && i.push(n ? a : a.slice(0, -t.length)), a = "");
|
|
3980
3980
|
return a.length > 0 && i.push(a), i.filter((e) => e.length > 0);
|
|
3981
3981
|
}
|
|
@@ -4044,27 +4044,31 @@ function jr(e, t) {
|
|
|
4044
4044
|
if (typeof e != "string" || e.trim().length === 0) throw new Z("BUBBLE-COMPOSITION-001", `${t} must be a non-empty string.`);
|
|
4045
4045
|
return e.trim();
|
|
4046
4046
|
}
|
|
4047
|
-
function Mr(e, t
|
|
4047
|
+
function Mr(e, t) {
|
|
4048
|
+
if (typeof e != "string" || e.length === 0) throw new Z("BUBBLE-COMPOSITION-001", `${t} must be a non-empty string.`);
|
|
4049
|
+
return e;
|
|
4050
|
+
}
|
|
4051
|
+
function Nr(e, t, n) {
|
|
4048
4052
|
if (!Q(e)) throw new Z("BUBBLE-COMPOSITION-001", `${t} must be an object.`);
|
|
4049
4053
|
if (Ar(e, ["frames", "frameIntervalSeconds"], [], t), !Array.isArray(e.frames) || e.frames.length < n) throw new Z("BUBBLE-COMPOSITION-001", `${t}.frames must contain at least ${n} image asset name${n === 1 ? "" : "s"}.`);
|
|
4050
|
-
let r = Object.freeze(e.frames.map((e, n) =>
|
|
4054
|
+
let r = Object.freeze(e.frames.map((e, n) => Mr(e, `${t}.frames[${n}]`))), i = e.frameIntervalSeconds;
|
|
4051
4055
|
if (typeof i != "number" || !Number.isFinite(i) || i <= 0) throw new Z("BUBBLE-COMPOSITION-001", `${t}.frameIntervalSeconds must be a positive finite number.`);
|
|
4052
4056
|
return Object.freeze({
|
|
4053
4057
|
frames: r,
|
|
4054
4058
|
frameIntervalSeconds: i
|
|
4055
4059
|
});
|
|
4056
4060
|
}
|
|
4057
|
-
function
|
|
4061
|
+
function Pr(e) {
|
|
4058
4062
|
if (!Q(e)) throw new Z("BUBBLE-COMPOSITION-001", "Bubble portrait must be an object.");
|
|
4059
4063
|
Ar(e, ["base"], ["blink", "lipSync"], "Bubble portrait");
|
|
4060
|
-
let t = e.blink === void 0 ? void 0 :
|
|
4064
|
+
let t = e.blink === void 0 ? void 0 : Nr(e.blink, "Bubble portrait blink", 1), n = e.lipSync === void 0 ? void 0 : Nr(e.lipSync, "Bubble portrait lip-sync", 1);
|
|
4061
4065
|
return Object.freeze({
|
|
4062
|
-
base:
|
|
4066
|
+
base: Mr(e.base, "Bubble portrait base"),
|
|
4063
4067
|
...t === void 0 ? {} : { blink: t },
|
|
4064
4068
|
...n === void 0 ? {} : { lipSync: n }
|
|
4065
4069
|
});
|
|
4066
4070
|
}
|
|
4067
|
-
function
|
|
4071
|
+
function Fr(e, t) {
|
|
4068
4072
|
if (!Q(e)) throw new Z("BUBBLE-COMPOSITION-001", `${t} must be an object.`);
|
|
4069
4073
|
if (Ar(e, ["name"], [
|
|
4070
4074
|
"durationSeconds",
|
|
@@ -4098,7 +4102,7 @@ function Pr(e, t) {
|
|
|
4098
4102
|
...l === void 0 ? {} : { visualStyle: l }
|
|
4099
4103
|
});
|
|
4100
4104
|
}
|
|
4101
|
-
function
|
|
4105
|
+
function Ir(e) {
|
|
4102
4106
|
if (e === void 0) return;
|
|
4103
4107
|
if (!Q(e)) throw new Z("BUBBLE-COMPOSITION-001", "Bubble audio must be an object.");
|
|
4104
4108
|
Ar(e, [], [
|
|
@@ -4113,11 +4117,11 @@ function Fr(e) {
|
|
|
4113
4117
|
"finish"
|
|
4114
4118
|
]) {
|
|
4115
4119
|
let r = e[n];
|
|
4116
|
-
r !== void 0 && (t[n] =
|
|
4120
|
+
r !== void 0 && (t[n] = Mr(r, `Bubble audio ${n}`));
|
|
4117
4121
|
}
|
|
4118
4122
|
return Object.freeze(t);
|
|
4119
4123
|
}
|
|
4120
|
-
function
|
|
4124
|
+
function Lr(e) {
|
|
4121
4125
|
if (!Q(e)) throw new Z("BUBBLE-COMPOSITION-001", "Bubble style must be an object.");
|
|
4122
4126
|
Ar(e, ["name", "textStyle"], [
|
|
4123
4127
|
"placement",
|
|
@@ -4134,13 +4138,13 @@ function Ir(e) {
|
|
|
4134
4138
|
"showAnimation",
|
|
4135
4139
|
"hideAnimation"
|
|
4136
4140
|
], "Bubble style");
|
|
4137
|
-
let t = e.portrait === void 0 ? void 0 :
|
|
4141
|
+
let t = e.portrait === void 0 ? void 0 : Pr(e.portrait), n = e.continueIndicator === void 0 ? void 0 : Nr(e.continueIndicator, "Bubble continue indicator", 2), r;
|
|
4138
4142
|
if (e.reveal !== void 0) try {
|
|
4139
4143
|
r = Sr(e.reveal);
|
|
4140
4144
|
} catch (e) {
|
|
4141
4145
|
throw new Z("BUBBLE-COMPOSITION-001", e instanceof Error ? e.message : "Bubble reveal is invalid.");
|
|
4142
4146
|
}
|
|
4143
|
-
let i =
|
|
4147
|
+
let i = Ir(e.audio), a = e.showAnimation === void 0 ? void 0 : Fr(e.showAnimation, "Bubble showAnimation"), o = e.hideAnimation === void 0 ? void 0 : Fr(e.hideAnimation, "Bubble hideAnimation"), s;
|
|
4144
4148
|
try {
|
|
4145
4149
|
s = _(e.placement ?? "up-right");
|
|
4146
4150
|
} catch (e) {
|
|
@@ -4178,13 +4182,13 @@ function Ir(e) {
|
|
|
4178
4182
|
...o === void 0 ? {} : { hideAnimation: o }
|
|
4179
4183
|
});
|
|
4180
4184
|
}
|
|
4181
|
-
function
|
|
4185
|
+
function Rr(e) {
|
|
4182
4186
|
if (e !== void 0) {
|
|
4183
4187
|
if (!Q(e) || typeof e.applyToTarget != "function" || typeof e.getMimeType != "function" || typeof e.isRegistered != "function") throw TypeError("Bubble image capability must provide applyToTarget, getMimeType, and isRegistered.");
|
|
4184
4188
|
return e;
|
|
4185
4189
|
}
|
|
4186
4190
|
}
|
|
4187
|
-
function
|
|
4191
|
+
function zr(e) {
|
|
4188
4192
|
if (e !== void 0) {
|
|
4189
4193
|
if (!Q(e) || typeof e.playSound != "function") throw TypeError("Bubble audio capability must provide playSound.");
|
|
4190
4194
|
if (e.isRegistered !== void 0 && typeof e.isRegistered != "function") throw TypeError("Bubble audio capability isRegistered must be a function.");
|
|
@@ -4192,64 +4196,64 @@ function Rr(e) {
|
|
|
4192
4196
|
return e;
|
|
4193
4197
|
}
|
|
4194
4198
|
}
|
|
4195
|
-
function
|
|
4199
|
+
function Br(e) {
|
|
4196
4200
|
if (e === void 0) throw new Z("BUBBLE-COMPOSITION-006", "Bubble image assets require an image capability. Provide options.imageResolver.");
|
|
4197
4201
|
return e;
|
|
4198
4202
|
}
|
|
4199
|
-
function
|
|
4200
|
-
if (!Q(e) || typeof e.setText != "function" || typeof e.releaseTarget != "function") throw TypeError("Bubble
|
|
4203
|
+
function Vr(e) {
|
|
4204
|
+
if (!Q(e) || typeof e.setText != "function" || typeof e.releaseTarget != "function") throw TypeError("Bubble text capability must provide setText and releaseTarget.");
|
|
4201
4205
|
return e;
|
|
4202
4206
|
}
|
|
4203
|
-
function
|
|
4207
|
+
function Hr() {
|
|
4204
4208
|
return Object.freeze({
|
|
4205
4209
|
setTimeout: (e, t) => globalThis.setTimeout(e, t),
|
|
4206
4210
|
clearTimeout: (e) => globalThis.clearTimeout(e)
|
|
4207
4211
|
});
|
|
4208
4212
|
}
|
|
4209
|
-
function
|
|
4213
|
+
function Ur(e) {
|
|
4210
4214
|
if (!Q(e) || typeof e.setTimeout != "function" || typeof e.clearTimeout != "function") throw TypeError("Bubble scheduler must provide setTimeout and clearTimeout.");
|
|
4211
4215
|
return e;
|
|
4212
4216
|
}
|
|
4213
|
-
function
|
|
4217
|
+
function Wr(e, t) {
|
|
4214
4218
|
if (!Q(e) || typeof e.id != "string" || e.id.length === 0 || typeof e.isStage != "boolean") throw new Z("BUBBLE-COMPOSITION-004", `${t} must provide id and isStage.`);
|
|
4215
4219
|
return e;
|
|
4216
4220
|
}
|
|
4217
|
-
function
|
|
4218
|
-
if (
|
|
4221
|
+
function Gr(e) {
|
|
4222
|
+
if (typeof e != "object" || !e) throw new Z("BUBBLE-COMPOSITION-004", "Bubble text target must be a non-null object.");
|
|
4219
4223
|
return e;
|
|
4220
4224
|
}
|
|
4221
|
-
function
|
|
4225
|
+
function Kr(e, t) {
|
|
4222
4226
|
if (!Q(e) || !Q(e.targets) || typeof e.setLayerVisible != "function" || typeof e.updateStyle != "function" || typeof e.show != "function" || typeof e.hide != "function" || typeof e.dispose != "function") throw new Z("BUBBLE-COMPOSITION-004", "Bubble surface is invalid.");
|
|
4223
4227
|
let n = e.targets;
|
|
4224
|
-
|
|
4228
|
+
Gr(n.text);
|
|
4225
4229
|
let r = /* @__PURE__ */ new Set(), i = (e, t) => {
|
|
4226
4230
|
let i = n[e];
|
|
4227
4231
|
if (!t && i === void 0) return;
|
|
4228
|
-
let a =
|
|
4232
|
+
let a = Wr(i, `Bubble surface ${e}`);
|
|
4229
4233
|
if (r.has(a.id)) throw new Z("BUBBLE-COMPOSITION-004", "Bubble image layers must use distinct target IDs.");
|
|
4230
4234
|
r.add(a.id);
|
|
4231
4235
|
};
|
|
4232
4236
|
return i("portraitBase", t.portrait !== void 0), i("portraitBlink", t.portrait?.blink !== void 0), i("portraitLipSync", t.portrait?.lipSync !== void 0), i("continueIndicator", t.continueIndicator !== void 0), e;
|
|
4233
4237
|
}
|
|
4234
|
-
function
|
|
4238
|
+
function qr(e, t) {
|
|
4235
4239
|
if (e === void 0) throw new Z("BUBBLE-COMPOSITION-006", `Bubble image capability is required for: ${t}. Provide options.imageResolver.`);
|
|
4236
4240
|
if (!e.isRegistered(t)) throw new Z("BUBBLE-COMPOSITION-003", `Bubble image asset is not registered: ${t}`);
|
|
4237
4241
|
if (!e.getMimeType(t).startsWith("image/")) throw new Z("BUBBLE-COMPOSITION-003", `Bubble asset is not an image: ${t}`);
|
|
4238
4242
|
}
|
|
4239
|
-
function
|
|
4243
|
+
function Jr(e, t) {
|
|
4240
4244
|
if (e === void 0) throw new Z("BUBBLE-COMPOSITION-006", `Bubble audio assets require an audio capability: ${t}. Provide options.audio.`);
|
|
4241
4245
|
if (e.isRegistered?.(t) === !1) throw new Z("BUBBLE-COMPOSITION-003", `Bubble audio asset is not registered: ${t}`);
|
|
4242
4246
|
let n = e.getMimeType?.(t);
|
|
4243
4247
|
if (n !== void 0 && !n.startsWith("audio/")) throw new Z("BUBBLE-COMPOSITION-003", `Bubble asset is not audio: ${t}`);
|
|
4244
4248
|
}
|
|
4245
|
-
function
|
|
4249
|
+
function Yr(e) {
|
|
4246
4250
|
return [...e.portrait === void 0 ? [] : [
|
|
4247
4251
|
e.portrait.base,
|
|
4248
4252
|
...e.portrait.blink?.frames ?? [],
|
|
4249
4253
|
...e.portrait.lipSync?.frames ?? []
|
|
4250
4254
|
], ...e.continueIndicator?.frames ?? []];
|
|
4251
4255
|
}
|
|
4252
|
-
function
|
|
4256
|
+
function Xr(e, t, n) {
|
|
4253
4257
|
if (t.maxWidth === void 0) return e;
|
|
4254
4258
|
if (typeof n.measureText != "function") throw new Z("BUBBLE-COMPOSITION-007", "Bubble style maxWidth requires the text capability measureText method.");
|
|
4255
4259
|
return vr({
|
|
@@ -4262,11 +4266,11 @@ function Yr(e, t, n) {
|
|
|
4262
4266
|
}) ?? 0
|
|
4263
4267
|
}).lines.map(({ text: e }) => e).join("\n");
|
|
4264
4268
|
}
|
|
4265
|
-
function
|
|
4269
|
+
function Zr(e, t) {
|
|
4266
4270
|
if (e.length === 1) throw e[0];
|
|
4267
4271
|
if (e.length > 1) throw AggregateError(e, t);
|
|
4268
4272
|
}
|
|
4269
|
-
function
|
|
4273
|
+
function Qr(e) {
|
|
4270
4274
|
let t = !1, n = 0, r = 0, i, a = Promise.resolve(), o = async (t) => {
|
|
4271
4275
|
let n = e.animation.frames[t];
|
|
4272
4276
|
n !== void 0 && await e.imageResolver.applyToTarget(n, e.target);
|
|
@@ -4301,7 +4305,7 @@ function Zr(e) {
|
|
|
4301
4305
|
}
|
|
4302
4306
|
});
|
|
4303
4307
|
}
|
|
4304
|
-
function
|
|
4308
|
+
function $r(e) {
|
|
4305
4309
|
if (!Q(e)) throw new Z("BUBBLE-COMPOSITION-001", "Show bubble input must be an object.");
|
|
4306
4310
|
if (Ar(e, [
|
|
4307
4311
|
"actor",
|
|
@@ -4329,12 +4333,12 @@ function Qr(e) {
|
|
|
4329
4333
|
...n === void 0 ? {} : { reveal: n }
|
|
4330
4334
|
};
|
|
4331
4335
|
}
|
|
4332
|
-
function
|
|
4336
|
+
function ei(e) {
|
|
4333
4337
|
if (!Q(e)) throw TypeError("Bubble composition options must be an object.");
|
|
4334
|
-
let t =
|
|
4338
|
+
let t = Rr(e.imageResolver), n = zr(e.audio), r = Vr(e.textCapability);
|
|
4335
4339
|
if (typeof e.createSurface != "function") throw TypeError("Bubble composition createSurface must be a function.");
|
|
4336
4340
|
if (e.onAnimationError !== void 0 && typeof e.onAnimationError != "function") throw TypeError("Bubble composition onAnimationError must be a function.");
|
|
4337
|
-
let i =
|
|
4341
|
+
let i = Ur(e.scheduler ?? Hr()), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = !1, l = () => {
|
|
4338
4342
|
if (c) throw new Z("BUBBLE-COMPOSITION-005", "Bubble composition has been disposed.");
|
|
4339
4343
|
}, u = async (e, t) => {
|
|
4340
4344
|
let n = (s.get(e) ?? Promise.resolve()).catch(() => void 0).then(t);
|
|
@@ -4354,8 +4358,8 @@ function $r(e) {
|
|
|
4354
4358
|
reveal: s.reveal
|
|
4355
4359
|
}));
|
|
4356
4360
|
let d = s.text, f = (e) => {
|
|
4357
|
-
let n = new Set(
|
|
4358
|
-
for (let e of n)
|
|
4361
|
+
let n = new Set(Yr(e)), r = n.size === 0 ? void 0 : Br(t);
|
|
4362
|
+
for (let e of n) qr(r, e);
|
|
4359
4363
|
return r;
|
|
4360
4364
|
}, p = f(u);
|
|
4361
4365
|
for (let e of [
|
|
@@ -4363,13 +4367,13 @@ function $r(e) {
|
|
|
4363
4367
|
u.audio?.reveal,
|
|
4364
4368
|
u.audio?.finish,
|
|
4365
4369
|
u.reveal?.sound
|
|
4366
|
-
]) e !== void 0 &&
|
|
4370
|
+
]) e !== void 0 && Jr(n, e);
|
|
4367
4371
|
let m = async (e, t = !1) => {
|
|
4368
4372
|
e !== void 0 && n !== void 0 && await n.playSound(e, { untilDone: t });
|
|
4369
4373
|
}, h = async (e, t, n) => {
|
|
4370
|
-
let r =
|
|
4374
|
+
let r = Yr(e).length === 0 ? void 0 : Br(t), i = [];
|
|
4371
4375
|
if (e.portrait) {
|
|
4372
|
-
let t =
|
|
4376
|
+
let t = Br(r);
|
|
4373
4377
|
i.push(Promise.resolve(t.applyToTarget(e.portrait.base, n.targets.portraitBase)));
|
|
4374
4378
|
let a = e.portrait.blink?.frames[0];
|
|
4375
4379
|
a !== void 0 && i.push(Promise.resolve(t.applyToTarget(a, n.targets.portraitBlink)));
|
|
@@ -4378,33 +4382,33 @@ function $r(e) {
|
|
|
4378
4382
|
}
|
|
4379
4383
|
let a = e.continueIndicator?.frames[0];
|
|
4380
4384
|
if (a !== void 0) {
|
|
4381
|
-
let e =
|
|
4385
|
+
let e = Br(r);
|
|
4382
4386
|
i.push(Promise.resolve(e.applyToTarget(a, n.targets.continueIndicator)));
|
|
4383
4387
|
}
|
|
4384
4388
|
await Promise.all(i);
|
|
4385
4389
|
}, g = (t, n, r) => {
|
|
4386
|
-
x = t.portrait?.blink === void 0 ? void 0 :
|
|
4390
|
+
x = t.portrait?.blink === void 0 ? void 0 : Qr({
|
|
4387
4391
|
actorKey: s.actorKey,
|
|
4388
4392
|
layer: "portraitBlink",
|
|
4389
4393
|
animation: t.portrait.blink,
|
|
4390
4394
|
target: r.targets.portraitBlink,
|
|
4391
|
-
imageResolver:
|
|
4395
|
+
imageResolver: Br(n),
|
|
4392
4396
|
scheduler: i,
|
|
4393
4397
|
...e.onAnimationError === void 0 ? {} : { onError: e.onAnimationError }
|
|
4394
|
-
}), S = t.portrait?.lipSync === void 0 ? void 0 :
|
|
4398
|
+
}), S = t.portrait?.lipSync === void 0 ? void 0 : Qr({
|
|
4395
4399
|
actorKey: s.actorKey,
|
|
4396
4400
|
layer: "portraitLipSync",
|
|
4397
4401
|
animation: t.portrait.lipSync,
|
|
4398
4402
|
target: r.targets.portraitLipSync,
|
|
4399
|
-
imageResolver:
|
|
4403
|
+
imageResolver: Br(n),
|
|
4400
4404
|
scheduler: i,
|
|
4401
4405
|
...e.onAnimationError === void 0 ? {} : { onError: e.onAnimationError }
|
|
4402
|
-
}), C = t.continueIndicator === void 0 ? void 0 :
|
|
4406
|
+
}), C = t.continueIndicator === void 0 ? void 0 : Qr({
|
|
4403
4407
|
actorKey: s.actorKey,
|
|
4404
4408
|
layer: "continueIndicator",
|
|
4405
4409
|
animation: t.continueIndicator,
|
|
4406
4410
|
target: r.targets.continueIndicator,
|
|
4407
|
-
imageResolver:
|
|
4411
|
+
imageResolver: Br(n),
|
|
4408
4412
|
scheduler: i,
|
|
4409
4413
|
...e.onAnimationError === void 0 ? {} : { onError: e.onAnimationError }
|
|
4410
4414
|
});
|
|
@@ -4412,13 +4416,13 @@ function $r(e) {
|
|
|
4412
4416
|
_ && await _.close();
|
|
4413
4417
|
let v, y = !1, b = !1, x, S, C, w = u.reveal, T = w ? wr(s.text, w) : Object.freeze([s.text]), E = w ? Math.min(1, T.length) : 1, D, O = 0;
|
|
4414
4418
|
try {
|
|
4415
|
-
v =
|
|
4419
|
+
v = Kr(await e.createSurface(Object.freeze({
|
|
4416
4420
|
actor: s.actor,
|
|
4417
4421
|
actorKey: s.actorKey,
|
|
4418
4422
|
kind: s.kind,
|
|
4419
4423
|
style: u
|
|
4420
4424
|
})), u);
|
|
4421
|
-
let t =
|
|
4425
|
+
let t = Xr(s.text, u, r);
|
|
4422
4426
|
w?.layout === "RESERVED" && (r.setText({
|
|
4423
4427
|
styleName: u.textStyle,
|
|
4424
4428
|
target: v.targets.text,
|
|
@@ -4426,7 +4430,7 @@ function $r(e) {
|
|
|
4426
4430
|
}), v.captureTextLayout?.()), r.setText({
|
|
4427
4431
|
styleName: u.textStyle,
|
|
4428
4432
|
target: v.targets.text,
|
|
4429
|
-
text:
|
|
4433
|
+
text: Xr(w ? Tr(T, E) : s.text, u, r)
|
|
4430
4434
|
}), y = !0, await h(u, p, v), g(u, p, v);
|
|
4431
4435
|
let a = "idle", c = !1, l = Promise.resolve(), _ = async () => {
|
|
4432
4436
|
if (!v) return;
|
|
@@ -4434,7 +4438,7 @@ function $r(e) {
|
|
|
4434
4438
|
r.setText({
|
|
4435
4439
|
styleName: u.textStyle,
|
|
4436
4440
|
target: v.targets.text,
|
|
4437
|
-
text:
|
|
4441
|
+
text: Xr(e, u, r)
|
|
4438
4442
|
}), await v.show();
|
|
4439
4443
|
}, k = () => {
|
|
4440
4444
|
O += 1, D !== void 0 && i.clearTimeout(D), D = void 0;
|
|
@@ -4464,7 +4468,7 @@ function $r(e) {
|
|
|
4464
4468
|
v && (k(), d = e, w ? (T = wr(e, w), E = Math.min(1, T.length), w.layout === "RESERVED" && (r.setText({
|
|
4465
4469
|
styleName: u.textStyle,
|
|
4466
4470
|
target: v.targets.text,
|
|
4467
|
-
text:
|
|
4471
|
+
text: Xr(e, u, r)
|
|
4468
4472
|
}), v.captureTextLayout?.()), await _(), j()) : await _());
|
|
4469
4473
|
}), l) : Promise.reject(new Z("BUBBLE-COMPOSITION-001", "Bubble text must be a string."));
|
|
4470
4474
|
},
|
|
@@ -4472,20 +4476,20 @@ function $r(e) {
|
|
|
4472
4476
|
if (c) return Promise.reject(new Z("BUBBLE-COMPOSITION-005", `Bubble is already closed: ${s.actorKey}`));
|
|
4473
4477
|
let t;
|
|
4474
4478
|
try {
|
|
4475
|
-
t =
|
|
4479
|
+
t = Lr(e);
|
|
4476
4480
|
} catch (e) {
|
|
4477
4481
|
return Promise.reject(e);
|
|
4478
4482
|
}
|
|
4479
4483
|
return l = l.then(async () => {
|
|
4480
4484
|
if (!v) return;
|
|
4481
|
-
|
|
4485
|
+
Kr(v, t);
|
|
4482
4486
|
let e = f(t);
|
|
4483
4487
|
for (let e of [
|
|
4484
4488
|
t.audio?.voice,
|
|
4485
4489
|
t.audio?.reveal,
|
|
4486
4490
|
t.audio?.finish,
|
|
4487
4491
|
t.reveal?.sound
|
|
4488
|
-
]) e !== void 0 &&
|
|
4492
|
+
]) e !== void 0 && Jr(n, e);
|
|
4489
4493
|
await Promise.all([
|
|
4490
4494
|
x?.stop(),
|
|
4491
4495
|
S?.stop(),
|
|
@@ -4493,11 +4497,11 @@ function $r(e) {
|
|
|
4493
4497
|
]), await h(t, e, v), await v.updateStyle(t), u = t, w = t.reveal, T = w ? wr(d, w) : Object.freeze([d]), E = w ? Math.min(1, T.length) : 1, k(), w?.layout === "RESERVED" && (r.setText({
|
|
4494
4498
|
styleName: t.textStyle,
|
|
4495
4499
|
target: v.targets.text,
|
|
4496
|
-
text:
|
|
4500
|
+
text: Xr(d, t, r)
|
|
4497
4501
|
}), v.captureTextLayout?.()), r.setText({
|
|
4498
4502
|
styleName: t.textStyle,
|
|
4499
4503
|
target: v.targets.text,
|
|
4500
|
-
text:
|
|
4504
|
+
text: Xr(d, t, r)
|
|
4501
4505
|
}), g(t, e, v), await Promise.all([
|
|
4502
4506
|
v.setLayerVisible("portraitBase", t.portrait !== void 0),
|
|
4503
4507
|
v.setLayerVisible("portraitBlink", t.portrait?.blink !== void 0),
|
|
@@ -4533,7 +4537,7 @@ function $r(e) {
|
|
|
4533
4537
|
}), T = wr(d, w), E = Math.min(1, T.length), w.layout === "RESERVED" && v && (r.setText({
|
|
4534
4538
|
styleName: u.textStyle,
|
|
4535
4539
|
target: v.targets.text,
|
|
4536
|
-
text:
|
|
4540
|
+
text: Xr(d, u, r)
|
|
4537
4541
|
}), v.captureTextLayout?.())), w) for (; await A(););
|
|
4538
4542
|
let n = e.condition;
|
|
4539
4543
|
if (n === void 0 && t === 0) {
|
|
@@ -4567,7 +4571,7 @@ function $r(e) {
|
|
|
4567
4571
|
if (c) return Promise.reject(new Z("BUBBLE-COMPOSITION-005", `Bubble is already closed: ${s.actorKey}`));
|
|
4568
4572
|
let t;
|
|
4569
4573
|
try {
|
|
4570
|
-
t =
|
|
4574
|
+
t = Fr(e, "Bubble motion");
|
|
4571
4575
|
} catch (e) {
|
|
4572
4576
|
return Promise.reject(e);
|
|
4573
4577
|
}
|
|
@@ -4610,7 +4614,7 @@ function $r(e) {
|
|
|
4610
4614
|
} catch (t) {
|
|
4611
4615
|
e.push(t);
|
|
4612
4616
|
}
|
|
4613
|
-
o.get(s.actorKey) === N && o.delete(s.actorKey),
|
|
4617
|
+
o.get(s.actorKey) === N && o.delete(s.actorKey), Zr(e, `Failed to close bubble: ${s.actorKey}`);
|
|
4614
4618
|
}
|
|
4615
4619
|
});
|
|
4616
4620
|
return o.set(s.actorKey, N), j(), u.showAnimation !== void 0 && await N.animate(u.showAnimation), N;
|
|
@@ -4642,7 +4646,7 @@ function $r(e) {
|
|
|
4642
4646
|
return Object.freeze({
|
|
4643
4647
|
defineStyle(e) {
|
|
4644
4648
|
l();
|
|
4645
|
-
let t =
|
|
4649
|
+
let t = Lr(e);
|
|
4646
4650
|
a.set(t.name, t);
|
|
4647
4651
|
},
|
|
4648
4652
|
hasActiveBubble(e) {
|
|
@@ -4650,7 +4654,7 @@ function $r(e) {
|
|
|
4650
4654
|
},
|
|
4651
4655
|
async show(e) {
|
|
4652
4656
|
l();
|
|
4653
|
-
let t =
|
|
4657
|
+
let t = $r(e);
|
|
4654
4658
|
return u(t.actorKey, () => d(t));
|
|
4655
4659
|
},
|
|
4656
4660
|
releaseTarget(e) {
|
|
@@ -4661,29 +4665,78 @@ function $r(e) {
|
|
|
4661
4665
|
});
|
|
4662
4666
|
},
|
|
4663
4667
|
async releaseAll() {
|
|
4664
|
-
l(), await Promise.allSettled([...s.values()]),
|
|
4668
|
+
l(), await Promise.allSettled([...s.values()]), Zr((await Promise.allSettled([...o.values()].map((e) => e.close()))).flatMap((e) => e.status === "rejected" ? [e.reason] : []), "Failed to release all bubbles");
|
|
4665
4669
|
},
|
|
4666
4670
|
async dispose() {
|
|
4667
4671
|
if (c) return;
|
|
4668
4672
|
c = !0, await Promise.allSettled([...s.values()]);
|
|
4669
4673
|
let e = await Promise.allSettled([...o.values()].map((e) => e.close()));
|
|
4670
|
-
a.clear(),
|
|
4674
|
+
a.clear(), Zr(e.flatMap((e) => e.status === "rejected" ? [e.reason] : []), "Failed to dispose bubble composition");
|
|
4671
4675
|
}
|
|
4672
4676
|
});
|
|
4673
4677
|
}
|
|
4674
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
|
|
4675
4728
|
//#region src/turbowarp-adapter.ts
|
|
4676
|
-
var
|
|
4729
|
+
var oi = "sprite", si = 96, ci = 18, li = 8, ui = 16, di = 0, $ = class extends Error {
|
|
4677
4730
|
code;
|
|
4678
4731
|
constructor(e, t) {
|
|
4679
4732
|
super(t), this.name = "BubbleRuntimeAdapterError", this.code = e;
|
|
4680
4733
|
}
|
|
4681
4734
|
};
|
|
4682
|
-
function
|
|
4735
|
+
function fi(e) {
|
|
4683
4736
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
4684
4737
|
}
|
|
4685
|
-
function
|
|
4686
|
-
if (!
|
|
4738
|
+
function pi(e) {
|
|
4739
|
+
if (!fi(e)) throw new $("BUBBLE-RUNTIME-001", "Bubble requires the TurboWarp renderer.");
|
|
4687
4740
|
let t = [
|
|
4688
4741
|
"createSVGSkin",
|
|
4689
4742
|
"createDrawable",
|
|
@@ -4699,15 +4752,11 @@ function si(e) {
|
|
|
4699
4752
|
if (t.some((t) => typeof e[t] != "function")) throw new $("BUBBLE-RUNTIME-001", `Bubble renderer must provide ${t.join(", ")}.`);
|
|
4700
4753
|
return e;
|
|
4701
4754
|
}
|
|
4702
|
-
function
|
|
4703
|
-
if (!
|
|
4704
|
-
return e;
|
|
4705
|
-
}
|
|
4706
|
-
function li(e) {
|
|
4707
|
-
if (!oi(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.");
|
|
4708
4757
|
return e;
|
|
4709
4758
|
}
|
|
4710
|
-
function
|
|
4759
|
+
function hi(e) {
|
|
4711
4760
|
try {
|
|
4712
4761
|
let t = e.getBoundsForBubble?.();
|
|
4713
4762
|
if (t && [
|
|
@@ -4725,7 +4774,7 @@ function ui(e) {
|
|
|
4725
4774
|
top: n
|
|
4726
4775
|
};
|
|
4727
4776
|
}
|
|
4728
|
-
function
|
|
4777
|
+
function gi(e, t, n) {
|
|
4729
4778
|
let r = e.getCurrentSkinSize(t.drawableID);
|
|
4730
4779
|
if (!Array.isArray(r) || r.length < 2) return n;
|
|
4731
4780
|
let i = Number(r[0]), a = Number(r[1]);
|
|
@@ -4734,11 +4783,11 @@ function di(e, t, n) {
|
|
|
4734
4783
|
height: a
|
|
4735
4784
|
};
|
|
4736
4785
|
}
|
|
4737
|
-
function
|
|
4786
|
+
function _i(e) {
|
|
4738
4787
|
return Math.max(0, Math.min(1, e));
|
|
4739
4788
|
}
|
|
4740
|
-
function
|
|
4741
|
-
let n =
|
|
4789
|
+
function vi(e, t) {
|
|
4790
|
+
let n = _i(e);
|
|
4742
4791
|
switch (t) {
|
|
4743
4792
|
case "linear": return n;
|
|
4744
4793
|
case "easeIn": return n * n;
|
|
@@ -4747,14 +4796,14 @@ function pi(e, t) {
|
|
|
4747
4796
|
default: return n;
|
|
4748
4797
|
}
|
|
4749
4798
|
}
|
|
4750
|
-
function
|
|
4799
|
+
function yi(e, t, n) {
|
|
4751
4800
|
let r = Math.max(0, t * 1e3);
|
|
4752
4801
|
return r === 0 ? (n(1), Promise.resolve()) : new Promise((t, i) => {
|
|
4753
4802
|
let a = 0, o, s = () => {
|
|
4754
4803
|
let c = Math.min(16, r - a);
|
|
4755
4804
|
a += c;
|
|
4756
4805
|
try {
|
|
4757
|
-
n(
|
|
4806
|
+
n(_i(a / r));
|
|
4758
4807
|
} catch (t) {
|
|
4759
4808
|
o !== void 0 && e.clearTimeout(o), i(t);
|
|
4760
4809
|
return;
|
|
@@ -4768,8 +4817,8 @@ function mi(e, t, n) {
|
|
|
4768
4817
|
o = e.setTimeout(s, Math.min(16, r));
|
|
4769
4818
|
});
|
|
4770
4819
|
}
|
|
4771
|
-
function
|
|
4772
|
-
let i =
|
|
4820
|
+
function bi(e, t, n, r = 1) {
|
|
4821
|
+
let i = gi(e, t, {
|
|
4773
4822
|
width: n,
|
|
4774
4823
|
height: n
|
|
4775
4824
|
}), a = Math.min(n / i.width, n / i.height) * r;
|
|
@@ -4778,29 +4827,29 @@ function hi(e, t, n, r = 1) {
|
|
|
4778
4827
|
height: i.height * a
|
|
4779
4828
|
};
|
|
4780
4829
|
}
|
|
4781
|
-
function
|
|
4830
|
+
function xi(e, t, n) {
|
|
4782
4831
|
return n < t ? (t + n) / 2 : Math.min(n, Math.max(t, e));
|
|
4783
4832
|
}
|
|
4784
|
-
function
|
|
4833
|
+
function Si(e, t, n, r, i) {
|
|
4785
4834
|
let a = t + r * 2, o = n + i * 2;
|
|
4786
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}"`));
|
|
4787
4836
|
}
|
|
4788
|
-
function
|
|
4837
|
+
function Ci(e) {
|
|
4789
4838
|
let t = v(e);
|
|
4790
4839
|
return (Math.atan2(-t.x, -t.y) * 180 / Math.PI % 360 + 360) % 360;
|
|
4791
4840
|
}
|
|
4792
|
-
function
|
|
4793
|
-
let a = e.renderer, o =
|
|
4794
|
-
|
|
4841
|
+
function wi(e, t, n, r, i) {
|
|
4842
|
+
let a = e.renderer, o = di;
|
|
4843
|
+
di += 1;
|
|
4795
4844
|
let s = [], c, l = (e) => {
|
|
4796
|
-
let t = a.createDrawable(
|
|
4845
|
+
let t = a.createDrawable(oi);
|
|
4797
4846
|
if (!Number.isInteger(t) || t < 0) throw new $("BUBBLE-RUNTIME-001", `TurboWarp did not create the Bubble ${e} drawable.`);
|
|
4798
4847
|
let r = Object.freeze({
|
|
4799
4848
|
id: `bubble:${n}:${o}:${e}`,
|
|
4800
4849
|
isStage: !1,
|
|
4801
4850
|
drawableID: t
|
|
4802
4851
|
});
|
|
4803
|
-
return s.push(r), a.updateDrawableVisible(t, !1), a.setDrawableOrder?.(t, Infinity,
|
|
4852
|
+
return s.push(r), a.updateDrawableVisible(t, !1), a.setDrawableOrder?.(t, Infinity, oi), r;
|
|
4804
4853
|
};
|
|
4805
4854
|
try {
|
|
4806
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({
|
|
@@ -4825,7 +4874,7 @@ function yi(e, t, n, r, i) {
|
|
|
4825
4874
|
A(), e.requestRedraw?.();
|
|
4826
4875
|
}, M = () => {
|
|
4827
4876
|
if (y) return;
|
|
4828
|
-
let e = x.placement.basis === "actor" ? x.offset.scalePercent / 100 : 1, r = S ??
|
|
4877
|
+
let e = x.placement.basis === "actor" ? x.offset.scalePercent / 100 : 1, r = S ?? gi(a, f, {
|
|
4829
4878
|
width: 180,
|
|
4830
4879
|
height: 48
|
|
4831
4880
|
});
|
|
@@ -4833,19 +4882,19 @@ function yi(e, t, n, r, i) {
|
|
|
4833
4882
|
let i = {
|
|
4834
4883
|
width: r.width * e,
|
|
4835
4884
|
height: r.height * e
|
|
4836
|
-
}, s = o ?
|
|
4885
|
+
}, s = o ? bi(a, o, si, e) : {
|
|
4837
4886
|
width: 0,
|
|
4838
4887
|
height: 0
|
|
4839
4888
|
};
|
|
4840
|
-
for (let t of [u, d]) t &&
|
|
4841
|
-
let l = p ?
|
|
4889
|
+
for (let t of [u, d]) t && bi(a, t, si, e);
|
|
4890
|
+
let l = p ? bi(a, p, ci, e) : {
|
|
4842
4891
|
width: 0,
|
|
4843
4892
|
height: 0
|
|
4844
|
-
}, m = s.width + (o ?
|
|
4845
|
-
if (x.placement.basis === "background") I = 0, L = x.placement.region === "HEADER_LIKE" ? P -
|
|
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;
|
|
4846
4895
|
else {
|
|
4847
4896
|
let e = w({
|
|
4848
|
-
bounds:
|
|
4897
|
+
bounds: hi(t),
|
|
4849
4898
|
bubbleWidth: v,
|
|
4850
4899
|
bubbleHeight: E,
|
|
4851
4900
|
direction: x.placement.direction,
|
|
@@ -4855,8 +4904,8 @@ function yi(e, t, n, r, i) {
|
|
|
4855
4904
|
});
|
|
4856
4905
|
I = e.x, L = e.y;
|
|
4857
4906
|
}
|
|
4858
|
-
I =
|
|
4859
|
-
let R = 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" ? [
|
|
4860
4909
|
x.offset.x,
|
|
4861
4910
|
x.offset.y,
|
|
4862
4911
|
x.offset.scalePercent
|
|
@@ -4886,7 +4935,7 @@ function yi(e, t, n, r, i) {
|
|
|
4886
4935
|
shapeTransition: k
|
|
4887
4936
|
});
|
|
4888
4937
|
if (le !== b) {
|
|
4889
|
-
let e =
|
|
4938
|
+
let e = Si(ge({
|
|
4890
4939
|
style: x.visualStyle,
|
|
4891
4940
|
lines: [],
|
|
4892
4941
|
width: g,
|
|
@@ -4907,17 +4956,17 @@ function yi(e, t, n, r, i) {
|
|
|
4907
4956
|
c = t, b = le, r !== void 0 && a.destroySkin(r);
|
|
4908
4957
|
}
|
|
4909
4958
|
a.updateDrawableScale(n.drawableID, [100, 100]), a.updateDrawablePosition(n.drawableID, [I - oe.x, L + oe.y]);
|
|
4910
|
-
let ue = I - m / 2, de = ue + s.width / 2, fe = ue + s.width + (o ?
|
|
4959
|
+
let ue = I - m / 2, de = ue + s.width / 2, fe = ue + s.width + (o ? li * e : 0) + i.width / 2;
|
|
4911
4960
|
for (let e of [
|
|
4912
4961
|
o,
|
|
4913
4962
|
u,
|
|
4914
4963
|
d
|
|
4915
4964
|
]) e && a.updateDrawablePosition(e.drawableID, [de, L]);
|
|
4916
|
-
a.updateDrawablePosition(f.drawableID, [fe, L]), p && a.updateDrawablePosition(p.drawableID, [fe + i.width / 2 - l.width / 2 -
|
|
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]);
|
|
4917
4966
|
let pe = (e, t) => {
|
|
4918
4967
|
e && C.set(e.drawableID, t);
|
|
4919
4968
|
};
|
|
4920
|
-
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 -
|
|
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();
|
|
4921
4970
|
}, N = t.onTargetVisualChange, ee = (e) => {
|
|
4922
4971
|
N?.(e), M();
|
|
4923
4972
|
};
|
|
@@ -4934,7 +4983,7 @@ function yi(e, t, n, r, i) {
|
|
|
4934
4983
|
n && !r ? t.onTargetVisualChange === ee && (t.onTargetVisualChange = N ?? null) : !n && r && (t.onTargetVisualChange = ee), M();
|
|
4935
4984
|
},
|
|
4936
4985
|
captureTextLayout() {
|
|
4937
|
-
y || (S =
|
|
4986
|
+
y || (S = gi(a, f, {
|
|
4938
4987
|
width: 180,
|
|
4939
4988
|
height: 48
|
|
4940
4989
|
}), M());
|
|
@@ -4946,11 +4995,11 @@ function yi(e, t, n, r, i) {
|
|
|
4946
4995
|
if (y) return;
|
|
4947
4996
|
let t = Math.max(0, e.durationSeconds ?? 0), n = () => {
|
|
4948
4997
|
y || (A(), j());
|
|
4949
|
-
}, r = (t) =>
|
|
4998
|
+
}, r = (t) => vi(t, e.ease ?? "easeInOut");
|
|
4950
4999
|
if (e.name === "fadeIn" || e.name === "floatIn" || e.name === "zoomIn" || e.name === "riseUp") {
|
|
4951
5000
|
_ = !0;
|
|
4952
5001
|
let a = e.name === "floatIn" || e.name === "riseUp" ? [0, 16] : [0, 0], o = e.name === "zoomIn" ? .01 : 1;
|
|
4953
|
-
E = a, D = o, O = e.name === "fadeIn" ? 0 : 1, n(), await
|
|
5002
|
+
E = a, D = o, O = e.name === "fadeIn" ? 0 : 1, n(), await yi(i, t, (t) => {
|
|
4954
5003
|
let i = r(t);
|
|
4955
5004
|
E = [a[0] * (1 - i), a[1] * (1 - i)], D = o + (1 - o) * i, O = e.name === "fadeIn" ? i : 1, n();
|
|
4956
5005
|
}), E = [0, 0], D = 1, O = 1, M();
|
|
@@ -4958,7 +5007,7 @@ function yi(e, t, n, r, i) {
|
|
|
4958
5007
|
}
|
|
4959
5008
|
if (e.name === "fadeOut" || e.name === "floatOut" || e.name === "zoomOut" || e.name === "sink") {
|
|
4960
5009
|
let a = e.name === "floatOut" || e.name === "sink" ? [0, -16] : [0, 0], o = e.name === "zoomOut" ? .01 : 1;
|
|
4961
|
-
E = [0, 0], D = 1, O = 1, n(), await
|
|
5010
|
+
E = [0, 0], D = 1, O = 1, n(), await yi(i, t, (t) => {
|
|
4962
5011
|
let i = r(t);
|
|
4963
5012
|
E = [a[0] * i, a[1] * i], D = 1 + (o - 1) * i, O = e.name === "fadeOut" ? 1 - i : 1, n();
|
|
4964
5013
|
}), E = a, D = o, O = e.name === "fadeOut" ? 0 : 1, n(), _ = !1, j(), E = [0, 0], D = 1, O = 1;
|
|
@@ -4966,7 +5015,7 @@ function yi(e, t, n, r, i) {
|
|
|
4966
5015
|
}
|
|
4967
5016
|
if (e.name === "shake") {
|
|
4968
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");
|
|
4969
|
-
E = [0, 0], await
|
|
5018
|
+
E = [0, 0], await yi(i, o, (e) => {
|
|
4970
5019
|
let t = r(e) * a * Math.PI * 2, i = Math.sin(t) * 5;
|
|
4971
5020
|
E = [s.x * i, s.y * i], n();
|
|
4972
5021
|
}), E = [0, 0], M();
|
|
@@ -4974,7 +5023,7 @@ function yi(e, t, n, r, i) {
|
|
|
4974
5023
|
}
|
|
4975
5024
|
if (e.name === "explode") {
|
|
4976
5025
|
let a = Math.max(1, Math.floor(e.count ?? 1)), o = t > 0 ? t : a * .12, s = e.relativeScale ?? 1.15;
|
|
4977
|
-
await
|
|
5026
|
+
await yi(i, o, (e) => {
|
|
4978
5027
|
let t = r(e), i = Math.abs(Math.sin(t * a * Math.PI));
|
|
4979
5028
|
D = 1 + (s - 1) * i, n();
|
|
4980
5029
|
}), D = 1, M();
|
|
@@ -4986,12 +5035,12 @@ function yi(e, t, n, r, i) {
|
|
|
4986
5035
|
from: r,
|
|
4987
5036
|
to: n,
|
|
4988
5037
|
progress: 0
|
|
4989
|
-
}, M(), await
|
|
4990
|
-
let o = t === 0 ? 1 :
|
|
5038
|
+
}, M(), await yi(i, t, (i) => {
|
|
5039
|
+
let o = t === 0 ? 1 : _i(i * Math.max(a, 1) / 1);
|
|
4991
5040
|
k = {
|
|
4992
5041
|
from: r,
|
|
4993
5042
|
to: n,
|
|
4994
|
-
progress:
|
|
5043
|
+
progress: vi(o, e.ease ?? "easeInOut")
|
|
4995
5044
|
}, M();
|
|
4996
5045
|
}), k = void 0, M();
|
|
4997
5046
|
return;
|
|
@@ -5006,20 +5055,26 @@ function yi(e, t, n, r, i) {
|
|
|
5006
5055
|
dispose() {
|
|
5007
5056
|
if (!y) {
|
|
5008
5057
|
y = !0, x.placement.basis === "actor" && t.onTargetVisualChange === ee && (t.onTargetVisualChange = N ?? null);
|
|
5009
|
-
for (let e of [...s].reverse()) a.destroyDrawable(e.drawableID,
|
|
5058
|
+
for (let e of [...s].reverse()) a.destroyDrawable(e.drawableID, oi);
|
|
5010
5059
|
c !== void 0 && (a.destroySkin(c), c = void 0), e.requestRedraw?.();
|
|
5011
5060
|
}
|
|
5012
5061
|
}
|
|
5013
5062
|
});
|
|
5014
5063
|
} catch (e) {
|
|
5015
|
-
for (let e of [...s].reverse()) a.destroyDrawable(e.drawableID,
|
|
5064
|
+
for (let e of [...s].reverse()) a.destroyDrawable(e.drawableID, oi);
|
|
5016
5065
|
throw c !== void 0 && a.destroySkin(c), e;
|
|
5017
5066
|
}
|
|
5018
5067
|
}
|
|
5019
|
-
function
|
|
5020
|
-
if (!
|
|
5021
|
-
let n = e, r =
|
|
5022
|
-
|
|
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
|
+
}
|
|
5077
|
+
return ei({
|
|
5023
5078
|
imageResolver: t.imageResolver ?? {
|
|
5024
5079
|
isRegistered(e) {
|
|
5025
5080
|
return i().isLoaded({ NAME: e });
|
|
@@ -5031,7 +5086,7 @@ function bi(e, t = {}) {
|
|
|
5031
5086
|
let a = t.drawableID;
|
|
5032
5087
|
if (!Number.isInteger(a) || a < 0) throw new $("BUBBLE-RUNTIME-001", "Bubble image target drawable is invalid.");
|
|
5033
5088
|
let o = await i().resolveSkin(e);
|
|
5034
|
-
if (!
|
|
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)}`);
|
|
5035
5090
|
r.updateDrawableSkinId(a, o.skinId), n.requestRedraw?.();
|
|
5036
5091
|
}
|
|
5037
5092
|
},
|
|
@@ -5048,25 +5103,10 @@ function bi(e, t = {}) {
|
|
|
5048
5103
|
await r.call(n, { NAME: e });
|
|
5049
5104
|
}
|
|
5050
5105
|
},
|
|
5051
|
-
|
|
5052
|
-
setText({ styleName: e, target: t, text: n }) {
|
|
5053
|
-
a?.setText({
|
|
5054
|
-
STYLE: e,
|
|
5055
|
-
TEXT: n
|
|
5056
|
-
}, { target: t });
|
|
5057
|
-
},
|
|
5058
|
-
releaseTarget(e) {
|
|
5059
|
-
a?.releaseTextActor(e);
|
|
5060
|
-
},
|
|
5061
|
-
measureText({ styleName: e, text: t }) {
|
|
5062
|
-
let n = a?.measureText;
|
|
5063
|
-
if (typeof n != "function") throw new $("BUBBLE-RUNTIME-003", "SVG Text does not provide text measurement.");
|
|
5064
|
-
return n.call(a, e, t);
|
|
5065
|
-
}
|
|
5066
|
-
},
|
|
5106
|
+
textCapability: a,
|
|
5067
5107
|
createSurface({ actor: e, actorKey: r, style: i }) {
|
|
5068
|
-
if (!
|
|
5069
|
-
return
|
|
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 ?? {
|
|
5070
5110
|
setTimeout: (e, t) => globalThis.setTimeout(e, t),
|
|
5071
5111
|
clearTimeout: (e) => globalThis.clearTimeout(e)
|
|
5072
5112
|
});
|
|
@@ -5076,4 +5116,4 @@ function bi(e, t = {}) {
|
|
|
5076
5116
|
});
|
|
5077
5117
|
}
|
|
5078
5118
|
//#endregion
|
|
5079
|
-
export { $ as BubbleRuntimeAdapterError,
|
|
5119
|
+
export { $ as BubbleRuntimeAdapterError, ai as createSvgTextCompositionCapability, Ti as createTurboWarpBubbleComposition, ii as createTurboWarpSvgTextCapability };
|