easter-egg-quest 1.0.3 → 1.0.5
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/dist/easter-egg-quest.es.js +111 -8
- package/dist/easter-egg-quest.umd.js +1 -1
- package/dist/types/rendering/NarrativeRenderer.d.ts +5 -0
- package/dist/types/stages/MotionStage.d.ts +1 -0
- package/dist/types/stages/RhythmStage.d.ts +1 -0
- package/dist/types/stages/StillnessStage.d.ts +1 -0
- package/package.json +1 -1
|
@@ -42,8 +42,7 @@ const DEFAULT_SCRIPT = {
|
|
|
42
42
|
stage2Intro: [
|
|
43
43
|
"you solved the first one",
|
|
44
44
|
"the second riddle:",
|
|
45
|
-
"I am a river that needs you to flow. Without you, I dry up. But you can’t carry me — only become me."
|
|
46
|
-
"what am I?"
|
|
45
|
+
"I am a river that needs you to flow. Without you, I dry up. But you can’t carry me — only become me. What am I?"
|
|
47
46
|
],
|
|
48
47
|
stage2Reactions: [
|
|
49
48
|
"the river is dry",
|
|
@@ -952,6 +951,42 @@ class NarrativeRenderer {
|
|
|
952
951
|
this.clear();
|
|
953
952
|
}, 12e3);
|
|
954
953
|
}
|
|
954
|
+
/**
|
|
955
|
+
* Show a narrative line with a confirmation button.
|
|
956
|
+
* Resolves when user clicks OK (no auto-advance).
|
|
957
|
+
*/
|
|
958
|
+
showLineWithConfirm(text) {
|
|
959
|
+
return new Promise((resolve) => {
|
|
960
|
+
if (!this.container) {
|
|
961
|
+
resolve();
|
|
962
|
+
return;
|
|
963
|
+
}
|
|
964
|
+
if (this.currentLine) {
|
|
965
|
+
const prev = this.currentLine;
|
|
966
|
+
prev.classList.add("eeq-narrative-exit");
|
|
967
|
+
setTimeout(() => prev.remove(), 750);
|
|
968
|
+
}
|
|
969
|
+
if (this.clearTimer) {
|
|
970
|
+
clearTimeout(this.clearTimer);
|
|
971
|
+
this.clearTimer = null;
|
|
972
|
+
}
|
|
973
|
+
const line = document.createElement("div");
|
|
974
|
+
line.className = "eeq-line";
|
|
975
|
+
line.textContent = text;
|
|
976
|
+
this.container.appendChild(line);
|
|
977
|
+
const btn = document.createElement("button");
|
|
978
|
+
btn.className = "eeq-confirm-btn";
|
|
979
|
+
btn.textContent = "OK";
|
|
980
|
+
btn.addEventListener("click", () => resolve(), { once: true });
|
|
981
|
+
line.appendChild(btn);
|
|
982
|
+
requestAnimationFrame(() => {
|
|
983
|
+
requestAnimationFrame(() => {
|
|
984
|
+
line.classList.add("eeq-line-visible");
|
|
985
|
+
});
|
|
986
|
+
});
|
|
987
|
+
this.currentLine = line;
|
|
988
|
+
});
|
|
989
|
+
}
|
|
955
990
|
/** Show a sequence of lines with pauses. */
|
|
956
991
|
async showSequence(lines, pauseMs = 4500) {
|
|
957
992
|
for (const line of lines) {
|
|
@@ -1076,6 +1111,27 @@ class NarrativeRenderer {
|
|
|
1076
1111
|
.eeq-celebration.eeq-narrative-exit {
|
|
1077
1112
|
transform: translate(-50%, -50%) scale(1.1) !important;
|
|
1078
1113
|
}
|
|
1114
|
+
|
|
1115
|
+
.eeq-confirm-btn {
|
|
1116
|
+
display: block;
|
|
1117
|
+
margin: 14px auto 0;
|
|
1118
|
+
padding: 5px 32px;
|
|
1119
|
+
border: 1px solid rgba(255,255,255,0.18);
|
|
1120
|
+
border-radius: 20px;
|
|
1121
|
+
background: rgba(255,255,255,0.08);
|
|
1122
|
+
color: inherit;
|
|
1123
|
+
font-family: inherit;
|
|
1124
|
+
font-size: 0.8em;
|
|
1125
|
+
letter-spacing: 0.08em;
|
|
1126
|
+
cursor: pointer;
|
|
1127
|
+
pointer-events: auto;
|
|
1128
|
+
transition: background 0.3s, border-color 0.3s;
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
.eeq-confirm-btn:hover {
|
|
1132
|
+
background: rgba(255,255,255,0.18);
|
|
1133
|
+
border-color: rgba(255,255,255,0.35);
|
|
1134
|
+
}
|
|
1079
1135
|
`;
|
|
1080
1136
|
}
|
|
1081
1137
|
}
|
|
@@ -3979,8 +4035,12 @@ class StillnessStage {
|
|
|
3979
4035
|
this._introPlayed = false;
|
|
3980
4036
|
const introLines = this.script.stage1Intro;
|
|
3981
4037
|
for (let i = 0; i < introLines.length; i++) {
|
|
3982
|
-
|
|
3983
|
-
|
|
4038
|
+
if (i === introLines.length - 1) {
|
|
4039
|
+
await this._showAndConfirm(introLines[i]);
|
|
4040
|
+
} else {
|
|
4041
|
+
this.bus.emit("narrative:show", introLines[i]);
|
|
4042
|
+
await this._wait(5e3);
|
|
4043
|
+
}
|
|
3984
4044
|
}
|
|
3985
4045
|
this.bus.emit("narrative:clear");
|
|
3986
4046
|
await this._wait(1e3);
|
|
@@ -4031,6 +4091,16 @@ class StillnessStage {
|
|
|
4031
4091
|
_wait(ms) {
|
|
4032
4092
|
return new Promise((r) => setTimeout(r, ms));
|
|
4033
4093
|
}
|
|
4094
|
+
_showAndConfirm(text) {
|
|
4095
|
+
this.bus.emit("narrative:showConfirm", text);
|
|
4096
|
+
return new Promise((resolve) => {
|
|
4097
|
+
const handler = () => {
|
|
4098
|
+
this.bus.off("narrative:confirmed", handler);
|
|
4099
|
+
resolve();
|
|
4100
|
+
};
|
|
4101
|
+
this.bus.on("narrative:confirmed", handler);
|
|
4102
|
+
});
|
|
4103
|
+
}
|
|
4034
4104
|
}
|
|
4035
4105
|
class MotionStage {
|
|
4036
4106
|
constructor(config, script, input, bus) {
|
|
@@ -4059,8 +4129,12 @@ class MotionStage {
|
|
|
4059
4129
|
this._introPlayed = false;
|
|
4060
4130
|
const introLines = this.script.stage2Intro;
|
|
4061
4131
|
for (let i = 0; i < introLines.length; i++) {
|
|
4062
|
-
|
|
4063
|
-
|
|
4132
|
+
if (i === introLines.length - 1) {
|
|
4133
|
+
await this._showAndConfirm(introLines[i]);
|
|
4134
|
+
} else {
|
|
4135
|
+
this.bus.emit("narrative:show", introLines[i]);
|
|
4136
|
+
await this._wait(5e3);
|
|
4137
|
+
}
|
|
4064
4138
|
}
|
|
4065
4139
|
this.bus.emit("narrative:clear");
|
|
4066
4140
|
await this._wait(1e3);
|
|
@@ -4126,6 +4200,16 @@ class MotionStage {
|
|
|
4126
4200
|
_wait(ms) {
|
|
4127
4201
|
return new Promise((r) => setTimeout(r, ms));
|
|
4128
4202
|
}
|
|
4203
|
+
_showAndConfirm(text) {
|
|
4204
|
+
this.bus.emit("narrative:showConfirm", text);
|
|
4205
|
+
return new Promise((resolve) => {
|
|
4206
|
+
const handler = () => {
|
|
4207
|
+
this.bus.off("narrative:confirmed", handler);
|
|
4208
|
+
resolve();
|
|
4209
|
+
};
|
|
4210
|
+
this.bus.on("narrative:confirmed", handler);
|
|
4211
|
+
});
|
|
4212
|
+
}
|
|
4129
4213
|
}
|
|
4130
4214
|
class RhythmStage {
|
|
4131
4215
|
constructor(config, script, input, bus) {
|
|
@@ -4158,8 +4242,12 @@ class RhythmStage {
|
|
|
4158
4242
|
this._introPlayed = false;
|
|
4159
4243
|
const introLines = this.script.stage3Intro;
|
|
4160
4244
|
for (let i = 0; i < introLines.length; i++) {
|
|
4161
|
-
|
|
4162
|
-
|
|
4245
|
+
if (i === introLines.length - 1) {
|
|
4246
|
+
await this._showAndConfirm(introLines[i]);
|
|
4247
|
+
} else {
|
|
4248
|
+
this.bus.emit("narrative:show", introLines[i]);
|
|
4249
|
+
await this._wait(5e3);
|
|
4250
|
+
}
|
|
4163
4251
|
}
|
|
4164
4252
|
this.bus.emit("narrative:clear");
|
|
4165
4253
|
await this._wait(1e3);
|
|
@@ -4230,6 +4318,16 @@ class RhythmStage {
|
|
|
4230
4318
|
_wait(ms) {
|
|
4231
4319
|
return new Promise((r) => setTimeout(r, ms));
|
|
4232
4320
|
}
|
|
4321
|
+
_showAndConfirm(text) {
|
|
4322
|
+
this.bus.emit("narrative:showConfirm", text);
|
|
4323
|
+
return new Promise((resolve) => {
|
|
4324
|
+
const handler = () => {
|
|
4325
|
+
this.bus.off("narrative:confirmed", handler);
|
|
4326
|
+
resolve();
|
|
4327
|
+
};
|
|
4328
|
+
this.bus.on("narrative:confirmed", handler);
|
|
4329
|
+
});
|
|
4330
|
+
}
|
|
4233
4331
|
}
|
|
4234
4332
|
class PageReactor {
|
|
4235
4333
|
constructor() {
|
|
@@ -4467,6 +4565,11 @@ class GameController {
|
|
|
4467
4565
|
var _a3;
|
|
4468
4566
|
return (_a3 = this.narrative) == null ? void 0 : _a3.showLine(text);
|
|
4469
4567
|
});
|
|
4568
|
+
this.bus.on("narrative:showConfirm", async (text) => {
|
|
4569
|
+
var _a3;
|
|
4570
|
+
await ((_a3 = this.narrative) == null ? void 0 : _a3.showLineWithConfirm(text));
|
|
4571
|
+
this.bus.emit("narrative:confirmed");
|
|
4572
|
+
});
|
|
4470
4573
|
this.bus.on("narrative:clear", () => {
|
|
4471
4574
|
var _a3;
|
|
4472
4575
|
return (_a3 = this.narrative) == null ? void 0 : _a3.clear();
|