@inkweave/plugins 1.0.0 → 1.1.2
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 +374 -0
- package/dist/cdButton/cooldownState.d.ts +8 -0
- package/dist/image/index.d.ts +1 -1
- package/dist/index.cjs +1 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -8
- package/dist/index.js +260 -251
- package/dist/index.js.map +1 -1
- package/dist/plugins.css +1 -0
- package/package.json +19 -13
package/dist/index.js
CHANGED
|
@@ -1,23 +1,86 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import { create as
|
|
6
|
-
import { persist as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { Tags as p, Patches as d, ChoiceParser as O, createSelectors as U, contentsStore as j, choicesStore as B } from "@inkweave/core";
|
|
2
|
+
import { choiceStyles as C, ChoiceRegistry as R, useStory as q } from "@inkweave/react";
|
|
3
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
4
|
+
import { memo as I, useRef as y, useEffect as v, useState as x, useCallback as w } from "react";
|
|
5
|
+
import { create as $ } from "zustand";
|
|
6
|
+
import { persist as K } from "zustand/middleware";
|
|
7
|
+
const o = class o {
|
|
8
|
+
static get sound() {
|
|
9
|
+
return o._sound;
|
|
10
|
+
}
|
|
11
|
+
static get music() {
|
|
12
|
+
return o._music;
|
|
13
|
+
}
|
|
14
|
+
static get sound_handler() {
|
|
15
|
+
return o._sound_handler;
|
|
16
|
+
}
|
|
17
|
+
static get music_handler() {
|
|
18
|
+
return o._music_handler;
|
|
19
|
+
}
|
|
20
|
+
static set_music(t) {
|
|
21
|
+
o._music = new Audio(t), o._music.loop = !0, o._music_handler = () => {
|
|
22
|
+
var n;
|
|
23
|
+
(n = o._music) == null || n.play();
|
|
24
|
+
}, o._music.addEventListener("canplaythrough", o._music_handler);
|
|
25
|
+
}
|
|
26
|
+
static set_sound(t) {
|
|
27
|
+
o._sound = new Audio(t), o._sound_handler = () => {
|
|
28
|
+
var n;
|
|
29
|
+
(n = o._sound) == null || n.play();
|
|
30
|
+
}, o._sound.addEventListener("canplaythrough", o._sound_handler);
|
|
31
|
+
}
|
|
32
|
+
static cleanupSound() {
|
|
33
|
+
o._sound && (o._sound.pause(), o._sound.currentTime = 0, o._sound.removeEventListener("canplaythrough", o._sound_handler), o._sound.src = ""), o._sound = null, o._sound_handler = () => {
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
static cleanupMusic() {
|
|
37
|
+
o._music && (o._music.pause(), o._music.currentTime = 0, o._music.removeEventListener("canplaythrough", o._music_handler), o._music.src = ""), o._music = null, o._music_handler = () => {
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
o._sound = null, o._music = null, o._sound_handler = () => {
|
|
42
|
+
}, o._music_handler = () => {
|
|
43
|
+
};
|
|
44
|
+
let c = o;
|
|
45
|
+
const E = (e, t) => t && "resolveFilename" in t ? t.resolveFilename(e) : e, _t = () => {
|
|
46
|
+
p.add("sound", (e, t) => {
|
|
47
|
+
e ? (c.cleanupSound(), c.set_sound(E(e, t.options.fileHandler))) : c.cleanupSound();
|
|
48
|
+
}), p.add("music", (e, t) => {
|
|
49
|
+
e ? (c.cleanupMusic(), c.set_music(E(e, t.options.fileHandler))) : c.cleanupMusic();
|
|
50
|
+
}), d.add(function() {
|
|
51
|
+
this.audio = c, this.cleanups.push(() => {
|
|
52
|
+
c.cleanupSound(), c.cleanupMusic();
|
|
53
|
+
});
|
|
54
|
+
}, {});
|
|
55
|
+
}, z = ({
|
|
56
|
+
choice: e,
|
|
57
|
+
onClick: t,
|
|
58
|
+
className: n = "",
|
|
59
|
+
children: s
|
|
60
|
+
}) => {
|
|
61
|
+
const a = y(null), r = y(t), i = parseFloat(e.val || "0");
|
|
62
|
+
r.current = t, v(() => {
|
|
63
|
+
if (!(i <= 0))
|
|
64
|
+
return a.current = setInterval(() => {
|
|
65
|
+
r.current();
|
|
66
|
+
}, i * 1e3), () => {
|
|
67
|
+
a.current && clearInterval(a.current);
|
|
68
|
+
};
|
|
69
|
+
}, [i]);
|
|
70
|
+
const m = `${C.button} ${n}`.trim();
|
|
71
|
+
return /* @__PURE__ */ f("a", { className: m, style: { display: "none" }, children: s });
|
|
72
|
+
}, G = I(z), Ct = () => {
|
|
73
|
+
O.add("auto", (e, t) => {
|
|
74
|
+
e.type = "auto", e.val = t;
|
|
75
|
+
}), R.register("auto", G), d.add(null, {});
|
|
76
|
+
}, H = {
|
|
11
77
|
local: localStorage,
|
|
12
78
|
session: sessionStorage
|
|
13
79
|
};
|
|
14
|
-
let
|
|
15
|
-
const
|
|
16
|
-
class
|
|
80
|
+
let D = "local";
|
|
81
|
+
const _ = () => H[D];
|
|
82
|
+
class Q {
|
|
17
83
|
constructor(t) {
|
|
18
|
-
r(this, "data");
|
|
19
|
-
r(this, "timestamp");
|
|
20
|
-
r(this, "meta");
|
|
21
84
|
this.data = JSON.stringify(t), this.timestamp = new Intl.DateTimeFormat(void 0, {
|
|
22
85
|
month: "short",
|
|
23
86
|
day: "numeric",
|
|
@@ -26,177 +89,129 @@ class J {
|
|
|
26
89
|
}).format(Date.now()), this.meta = "autogenerated";
|
|
27
90
|
}
|
|
28
91
|
}
|
|
29
|
-
const
|
|
30
|
-
|
|
92
|
+
const b = $()(
|
|
93
|
+
K(
|
|
31
94
|
(e, t) => ({
|
|
32
95
|
storage: /* @__PURE__ */ new Map(),
|
|
33
|
-
setStorage: (
|
|
34
|
-
const
|
|
35
|
-
|
|
96
|
+
setStorage: (n, s, a) => {
|
|
97
|
+
const r = new Map(t().storage), i = [...r.get(n) || []];
|
|
98
|
+
i[s] = new Q(a), r.set(n, i), e({ storage: r });
|
|
36
99
|
},
|
|
37
|
-
changeFormat: (
|
|
38
|
-
|
|
100
|
+
changeFormat: (n) => {
|
|
101
|
+
D = n;
|
|
39
102
|
}
|
|
40
103
|
}),
|
|
41
104
|
{
|
|
42
105
|
name: "inkStory",
|
|
43
106
|
storage: {
|
|
44
107
|
getItem: (e) => {
|
|
45
|
-
const t =
|
|
108
|
+
const t = _().getItem(e);
|
|
46
109
|
if (!t) return null;
|
|
47
110
|
try {
|
|
48
|
-
const { state:
|
|
111
|
+
const { state: n } = JSON.parse(t);
|
|
49
112
|
return {
|
|
50
113
|
state: {
|
|
51
|
-
...
|
|
52
|
-
storage: new Map(
|
|
114
|
+
...n,
|
|
115
|
+
storage: new Map(n.storage)
|
|
53
116
|
}
|
|
54
117
|
};
|
|
55
|
-
} catch (
|
|
56
|
-
return console.error("InkWeave: Failed to parse storage data:",
|
|
118
|
+
} catch (n) {
|
|
119
|
+
return console.error("InkWeave: Failed to parse storage data:", n), null;
|
|
57
120
|
}
|
|
58
121
|
},
|
|
59
122
|
setItem: (e, t) => {
|
|
60
|
-
const
|
|
123
|
+
const n = JSON.stringify({
|
|
61
124
|
state: {
|
|
62
125
|
...t.state,
|
|
63
|
-
storage: Array.from(
|
|
64
|
-
t.state.storage.entries()
|
|
65
|
-
)
|
|
126
|
+
storage: Array.from(t.state.storage.entries())
|
|
66
127
|
}
|
|
67
128
|
});
|
|
68
|
-
|
|
129
|
+
_().setItem(e, n);
|
|
69
130
|
},
|
|
70
131
|
removeItem: (e) => {
|
|
71
|
-
|
|
132
|
+
_().removeItem(e);
|
|
72
133
|
}
|
|
73
134
|
}
|
|
74
135
|
}
|
|
75
136
|
)
|
|
76
|
-
)
|
|
77
|
-
let C = {
|
|
137
|
+
), N = {
|
|
78
138
|
memory_format: "local"
|
|
79
|
-
}
|
|
80
|
-
const
|
|
81
|
-
const s = {
|
|
139
|
+
}, X = (e) => b((t) => t.storage.get(e) || null), Y = (e, t) => {
|
|
140
|
+
const n = {
|
|
82
141
|
state: t.story.state.toJson()
|
|
83
142
|
};
|
|
84
|
-
t.save_label.forEach((
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
}),
|
|
88
|
-
},
|
|
89
|
-
let
|
|
143
|
+
t.save_label.forEach((s) => {
|
|
144
|
+
const a = t[s];
|
|
145
|
+
s in t && a !== void 0 && (typeof a == "string" || typeof a == "number" || typeof a == "boolean" || Array.isArray(a)) && (n[s] = a);
|
|
146
|
+
}), b.getState().setStorage(t.title, e, n);
|
|
147
|
+
}, Z = (e, t) => {
|
|
148
|
+
let n = null;
|
|
90
149
|
try {
|
|
91
|
-
|
|
92
|
-
} catch (
|
|
93
|
-
console.error("InkWeave: Failed to parse save data:",
|
|
150
|
+
n = JSON.parse(e);
|
|
151
|
+
} catch (s) {
|
|
152
|
+
console.error("InkWeave: Failed to parse save data:", s);
|
|
94
153
|
return;
|
|
95
154
|
}
|
|
96
|
-
|
|
97
|
-
|
|
155
|
+
n && (t.story.state.LoadJson(n.state), t.clear(), t.save_label.forEach((s) => {
|
|
156
|
+
s in t && typeof t[s] < "u" && s in n && (t[s] = n[s]);
|
|
98
157
|
}), t.continue());
|
|
99
|
-
},
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
setImage: (t) => e({ image: t })
|
|
113
|
-
})), B = (e, t) => t && "resolveFilename" in t ? t.resolveFilename(e) : e, it = () => {
|
|
114
|
-
h.add("image", (e, t) => {
|
|
115
|
-
e ? d.getState().setImage(B(e, t.options.fileHandler)) : d.getState().setImage("");
|
|
116
|
-
}), c.add(function() {
|
|
117
|
-
Object.defineProperty(this, "image", {
|
|
118
|
-
get() {
|
|
119
|
-
return d.getState().image;
|
|
120
|
-
},
|
|
121
|
-
set(e) {
|
|
122
|
-
d.getState().setImage(e);
|
|
123
|
-
}
|
|
124
|
-
}), this.save_label.push("image"), this.clears.push(() => {
|
|
125
|
-
this.image = "";
|
|
126
|
-
});
|
|
127
|
-
}, {});
|
|
128
|
-
};
|
|
129
|
-
class a {
|
|
130
|
-
static get sound() {
|
|
131
|
-
return this._sound;
|
|
132
|
-
}
|
|
133
|
-
static get music() {
|
|
134
|
-
return this._music;
|
|
135
|
-
}
|
|
136
|
-
static get sound_handler() {
|
|
137
|
-
return this._sound_handler;
|
|
138
|
-
}
|
|
139
|
-
static get music_handler() {
|
|
140
|
-
return this._music_handler;
|
|
141
|
-
}
|
|
142
|
-
static set_music(t) {
|
|
143
|
-
this._music = new Audio(t), this._music.loop = !0, this._music_handler = () => {
|
|
144
|
-
var s;
|
|
145
|
-
(s = this._music) == null || s.play();
|
|
146
|
-
}, this._music.addEventListener("canplaythrough", this._music_handler);
|
|
147
|
-
}
|
|
148
|
-
static set_sound(t) {
|
|
149
|
-
this._sound = new Audio(t), this._sound_handler = () => {
|
|
150
|
-
var s;
|
|
151
|
-
(s = this._sound) == null || s.play();
|
|
152
|
-
}, this._sound.addEventListener("canplaythrough", this._sound_handler);
|
|
153
|
-
}
|
|
154
|
-
static cleanupSound() {
|
|
155
|
-
this._sound && (this._sound.pause(), this._sound.currentTime = 0, this._sound.removeEventListener(
|
|
156
|
-
"canplaythrough",
|
|
157
|
-
this._sound_handler
|
|
158
|
-
), this._sound.src = ""), this._sound = null, this._sound_handler = () => {
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
static cleanupMusic() {
|
|
162
|
-
this._music && (this._music.pause(), this._music.currentTime = 0, this._music.removeEventListener(
|
|
163
|
-
"canplaythrough",
|
|
164
|
-
this._music_handler
|
|
165
|
-
), this._music.src = ""), this._music = null, this._music_handler = () => {
|
|
166
|
-
};
|
|
167
|
-
}
|
|
158
|
+
}, wt = () => {
|
|
159
|
+
d.add(() => {
|
|
160
|
+
b.getState().changeFormat(N.memory_format);
|
|
161
|
+
}, N);
|
|
162
|
+
}, V = { save: Y, load: Z, show: X }, tt = {
|
|
163
|
+
autosave_enabled: !0
|
|
164
|
+
}, It = () => {
|
|
165
|
+
p.add("autosave", (e, t) => {
|
|
166
|
+
t.options.autosave_enabled && V.save(1, t);
|
|
167
|
+
}), d.add(null, tt);
|
|
168
|
+
}, L = /* @__PURE__ */ new Map();
|
|
169
|
+
function et(e) {
|
|
170
|
+
return `${e.type}_${e.text}_${e.val || ""}`;
|
|
168
171
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
const I = (e, t) => t && "resolveFilename" in t ? t.resolveFilename(e) : e, rt = () => {
|
|
173
|
-
h.add("sound", (e, t) => {
|
|
174
|
-
e ? (a.cleanupSound(), a.set_sound(I(e, t.options.fileHandler))) : a.cleanupSound();
|
|
175
|
-
}), h.add("music", (e, t) => {
|
|
176
|
-
e ? (a.cleanupMusic(), a.set_music(I(e, t.options.fileHandler))) : a.cleanupMusic();
|
|
177
|
-
}), c.add(function() {
|
|
178
|
-
this.audio = a, this.cleanups.push(() => {
|
|
179
|
-
a.cleanupSound(), a.cleanupMusic();
|
|
180
|
-
});
|
|
181
|
-
}, {});
|
|
182
|
-
}, U = `
|
|
183
|
-
#inkweave-contents div,
|
|
184
|
-
#inkweave-choices {
|
|
185
|
-
opacity: 0;
|
|
186
|
-
animation: inkFadeIn 0.5s forwards;
|
|
187
|
-
animation-delay: var(--delay, 0s);
|
|
172
|
+
function nt(e) {
|
|
173
|
+
const t = L.get(e) || 0;
|
|
174
|
+
return Date.now() < t;
|
|
188
175
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
to {
|
|
194
|
-
opacity: 1;
|
|
195
|
-
}
|
|
176
|
+
function ot(e) {
|
|
177
|
+
const t = L.get(e) || 0, n = Math.max(0, t - Date.now());
|
|
178
|
+
return Math.ceil(n / 1e3);
|
|
196
179
|
}
|
|
197
|
-
|
|
180
|
+
function st(e, t) {
|
|
181
|
+
L.set(e, Date.now() + t * 1e3);
|
|
182
|
+
}
|
|
183
|
+
const at = ({
|
|
184
|
+
choice: e,
|
|
185
|
+
onClick: t,
|
|
186
|
+
className: n = "",
|
|
187
|
+
children: s
|
|
188
|
+
}) => {
|
|
189
|
+
var M, F;
|
|
190
|
+
const a = parseFloat(e.val || "0"), r = et(e), i = q(), [, m] = x(0), g = y(!0), u = nt(r), T = ot(r);
|
|
191
|
+
v(() => () => {
|
|
192
|
+
g.current = !1;
|
|
193
|
+
}, []), v(() => {
|
|
194
|
+
if (!u) return;
|
|
195
|
+
const S = setInterval(() => {
|
|
196
|
+
g.current && m((k) => k + 1);
|
|
197
|
+
}, 1e3);
|
|
198
|
+
return () => clearInterval(S);
|
|
199
|
+
}, [u]);
|
|
200
|
+
const P = w(() => {
|
|
201
|
+
u || (t(), st(r, a), m((S) => S + 1));
|
|
202
|
+
}, [u, a, t, r]), A = `${((M = C) == null ? void 0 : M.button) || ""} ${n} ${u && ((F = C) == null ? void 0 : F.disabled) || ""}`.trim(), J = i.options.cdTemplate || "{text} ({time})", W = u && T > 0 ? J.replace("{text}", String(s)).replace("{time}", String(T)) : s;
|
|
203
|
+
return /* @__PURE__ */ f("a", { className: A, onClick: P, children: W });
|
|
204
|
+
}, rt = I(at), ct = {
|
|
205
|
+
cdTemplate: "{text} ({time})"
|
|
206
|
+
}, $t = () => {
|
|
207
|
+
O.add("cd", (e, t) => {
|
|
208
|
+
e.type = "cd", e.val = t;
|
|
209
|
+
}), R.register("cd", rt), d.add(null, ct);
|
|
210
|
+
}, it = {
|
|
211
|
+
// 控制文字显示延迟速度(秒),可通过初始化时传入 linedelay 参数修改
|
|
212
|
+
// 或在 Ink 中使用 #linedelay:0.2 动态调整
|
|
198
213
|
linedelay: 0.05
|
|
199
|
-
}, l =
|
|
214
|
+
}, l = $((e) => ({
|
|
200
215
|
contentComplete: !0,
|
|
201
216
|
last_content: "",
|
|
202
217
|
setContentComplete: (t) => e({ contentComplete: t }),
|
|
@@ -205,67 +220,88 @@ const I = (e, t) => t && "resolveFilename" in t ? t.resolveFilename(e) : e, rt =
|
|
|
205
220
|
e({ last_content: "" });
|
|
206
221
|
return;
|
|
207
222
|
}
|
|
208
|
-
const
|
|
209
|
-
e({ last_content:
|
|
223
|
+
const n = t[t.length - 1];
|
|
224
|
+
e({ last_content: n });
|
|
210
225
|
}
|
|
211
|
-
}))
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
226
|
+
})), bt = () => {
|
|
227
|
+
p.add("linedelay", (e, t) => {
|
|
228
|
+
if (e != null) {
|
|
229
|
+
const n = parseFloat(e);
|
|
230
|
+
Number.isNaN(n) || (t.options.linedelay = n, n === 0 && l.getState().setContentComplete(!0));
|
|
231
|
+
}
|
|
232
|
+
}), d.add(function() {
|
|
215
233
|
const e = this.choose, t = this;
|
|
216
|
-
this.choose =
|
|
217
|
-
return t.options.linedelay != 0 && (l.getState().setContentComplete(!1), l.getState().setLastContent(t.contents)), e.call(t, n);
|
|
218
|
-
}, Object.defineProperty(this, "visibleLines", {
|
|
234
|
+
this.choose = (a) => (t.options.linedelay !== 0 && (l.getState().setContentComplete(!1), l.getState().setLastContent(t.contents)), e.call(t, a)), Object.defineProperty(this, "visibleLines", {
|
|
219
235
|
get() {
|
|
220
|
-
const
|
|
221
|
-
return t.contents.lastIndexOf(
|
|
236
|
+
const a = l.getState().last_content;
|
|
237
|
+
return a ? t.contents.lastIndexOf(a) : -1;
|
|
222
238
|
}
|
|
223
239
|
}), Object.defineProperty(this, "choicesCanShow", {
|
|
224
240
|
get() {
|
|
225
|
-
return
|
|
241
|
+
return U(l).use.contentComplete();
|
|
226
242
|
}
|
|
227
243
|
});
|
|
228
|
-
let
|
|
229
|
-
const
|
|
230
|
-
|
|
244
|
+
let n = null;
|
|
245
|
+
const s = j.subscribe(() => {
|
|
246
|
+
if (n && clearTimeout(n), t.options.linedelay === 0) {
|
|
231
247
|
l.getState().setContentComplete(!0);
|
|
232
|
-
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
n = setTimeout(
|
|
251
|
+
() => {
|
|
252
|
+
l.getState().setContentComplete(!0);
|
|
253
|
+
},
|
|
254
|
+
Math.max(
|
|
255
|
+
0,
|
|
256
|
+
(t.contents.length - t.visibleLines) * t.options.linedelay * 1e3
|
|
257
|
+
)
|
|
258
|
+
);
|
|
233
259
|
});
|
|
234
260
|
this.cleanups.push(() => {
|
|
235
|
-
|
|
261
|
+
s(), n && clearTimeout(n);
|
|
236
262
|
}), this.clears.push(() => {
|
|
237
|
-
t.options.linedelay
|
|
238
|
-
});
|
|
239
|
-
}, q);
|
|
240
|
-
}, lt = () => {
|
|
241
|
-
c.add(function() {
|
|
242
|
-
let e = null;
|
|
243
|
-
const t = k.subscribe(() => {
|
|
244
|
-
e && clearTimeout(e), e = setTimeout(() => {
|
|
245
|
-
const s = document.querySelector(
|
|
246
|
-
"ul#inkweave-choices > li:last-child"
|
|
247
|
-
);
|
|
248
|
-
if (s) {
|
|
249
|
-
const o = document.querySelector(
|
|
250
|
-
"#inkweave-story"
|
|
251
|
-
);
|
|
252
|
-
o == null || o.scrollTo({
|
|
253
|
-
top: s.offsetTop,
|
|
254
|
-
behavior: "smooth"
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
}, 0);
|
|
263
|
+
t.options.linedelay !== 0 && l.getState().setContentComplete(!1), l.getState().setLastContent([]);
|
|
258
264
|
});
|
|
259
|
-
|
|
260
|
-
|
|
265
|
+
}, it);
|
|
266
|
+
}, lt = "_container_1a16a_1", ut = {
|
|
267
|
+
container: lt
|
|
268
|
+
}, dt = ({ className: e = "", fallback: t = null }) => {
|
|
269
|
+
const n = h((u) => u.image), [s, a] = x(!1);
|
|
270
|
+
v(() => {
|
|
271
|
+
a(!1);
|
|
272
|
+
}, []);
|
|
273
|
+
const r = y(n);
|
|
274
|
+
r.current = n;
|
|
275
|
+
const i = w(() => {
|
|
276
|
+
a(!0), console.warn(`InkWeave: Failed to load image: ${r.current}`);
|
|
277
|
+
}, []), m = w(() => {
|
|
278
|
+
a(!1);
|
|
279
|
+
}, []), g = `${ut.container} ${e}`.trim();
|
|
280
|
+
return n ? s ? t ? /* @__PURE__ */ f("div", { className: g, children: t }) : null : /* @__PURE__ */ f("div", { className: g, children: /* @__PURE__ */ f("img", { src: n, alt: "", onError: i, onLoad: m }) }) : null;
|
|
281
|
+
}, Lt = I(dt), h = $((e) => ({
|
|
282
|
+
image: "",
|
|
283
|
+
setImage: (t) => e({ image: t })
|
|
284
|
+
})), mt = (e, t) => t && "resolveFilename" in t ? t.resolveFilename(e) : e, Tt = () => {
|
|
285
|
+
p.add("image", (e, t) => {
|
|
286
|
+
e ? h.getState().setImage(mt(e, t.options.fileHandler)) : h.getState().setImage("");
|
|
287
|
+
}), d.add(function() {
|
|
288
|
+
Object.defineProperty(this, "image", {
|
|
289
|
+
get() {
|
|
290
|
+
return h.getState().image;
|
|
291
|
+
},
|
|
292
|
+
set(e) {
|
|
293
|
+
h.getState().setImage(e);
|
|
294
|
+
}
|
|
295
|
+
}), this.save_label.push("image"), this.clears.push(() => {
|
|
296
|
+
this.image = "";
|
|
261
297
|
});
|
|
262
298
|
}, {});
|
|
263
|
-
},
|
|
264
|
-
|
|
299
|
+
}, pt = ["http:", "https:"], Mt = () => {
|
|
300
|
+
p.add("linkopen", (e) => {
|
|
265
301
|
if (e) {
|
|
266
302
|
try {
|
|
267
303
|
const t = new URL(e);
|
|
268
|
-
if (!
|
|
304
|
+
if (!pt.includes(t.protocol)) {
|
|
269
305
|
console.warn("InkWeave: Blocked unsafe URL protocol:", t.protocol);
|
|
270
306
|
return;
|
|
271
307
|
}
|
|
@@ -276,67 +312,40 @@ const ct = () => {
|
|
|
276
312
|
window.open(e, "_blank", "noopener,noreferrer");
|
|
277
313
|
}
|
|
278
314
|
});
|
|
279
|
-
},
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
},
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
onClick: t,
|
|
301
|
-
className: s = "",
|
|
302
|
-
children: o
|
|
303
|
-
}) => {
|
|
304
|
-
const [n, i] = b(!1), u = parseFloat(e || "0"), g = () => {
|
|
305
|
-
n || (t(), i(!0), setTimeout(() => {
|
|
306
|
-
i(!1);
|
|
307
|
-
}, u * 1e3));
|
|
308
|
-
};
|
|
309
|
-
return /* @__PURE__ */ m(
|
|
310
|
-
"a",
|
|
311
|
-
{
|
|
312
|
-
className: `inkweave-btn ${s} ${n ? "disabled" : ""}`,
|
|
313
|
-
onClick: g,
|
|
314
|
-
children: o
|
|
315
|
-
}
|
|
316
|
-
);
|
|
317
|
-
}, Q = y(K), mt = () => {
|
|
318
|
-
w.add("cd", (e, t) => {
|
|
319
|
-
e.type = "cd", e.val = t;
|
|
320
|
-
}), L.register("cd", Q), c.add(null, {});
|
|
321
|
-
}, X = {
|
|
322
|
-
autosave_enabled: !0
|
|
323
|
-
}, ht = () => {
|
|
324
|
-
h.add("autosave", (e, t) => {
|
|
325
|
-
t.options.autosave_enabled && j.save(2, t);
|
|
326
|
-
}), c.add(null, X);
|
|
315
|
+
}, Ft = () => {
|
|
316
|
+
d.add(function() {
|
|
317
|
+
let e = null;
|
|
318
|
+
const t = B.subscribe(() => {
|
|
319
|
+
e && clearTimeout(e), e = setTimeout(() => {
|
|
320
|
+
const n = document.querySelector(
|
|
321
|
+
'[data-inkweave="choices"] > li:last-child'
|
|
322
|
+
);
|
|
323
|
+
if (n) {
|
|
324
|
+
const s = document.querySelector('[data-inkweave="story"]');
|
|
325
|
+
s == null || s.scrollTo({
|
|
326
|
+
top: n.offsetTop,
|
|
327
|
+
behavior: "smooth"
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
}, 0);
|
|
331
|
+
});
|
|
332
|
+
this.cleanups.push(() => {
|
|
333
|
+
t(), e && clearTimeout(e);
|
|
334
|
+
});
|
|
335
|
+
}, {});
|
|
327
336
|
};
|
|
328
337
|
export {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
338
|
+
Lt as Image,
|
|
339
|
+
_t as loadAudio,
|
|
340
|
+
Ct as loadAutoButton,
|
|
341
|
+
It as loadAutosave,
|
|
342
|
+
$t as loadCdButton,
|
|
343
|
+
bt as loadFadeEffect,
|
|
344
|
+
Tt as loadImage,
|
|
345
|
+
Mt as loadLinkopen,
|
|
346
|
+
wt as loadMemory,
|
|
347
|
+
Ft as loadScrollafterchoice,
|
|
348
|
+
V as memory,
|
|
349
|
+
h as useStoryImage
|
|
341
350
|
};
|
|
342
351
|
//# sourceMappingURL=index.js.map
|