@famibee/skynovel 1.65.0 → 2.0.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.
Files changed (176) hide show
  1. package/README.md +3 -3
  2. package/dist/Button.js +131 -163
  3. package/dist/Button.js.map +1 -1
  4. package/dist/CallStack.js +19 -22
  5. package/dist/CallStack.js.map +1 -1
  6. package/dist/CmnInterface.js +91 -0
  7. package/dist/CmnInterface.js.map +1 -0
  8. package/dist/CmnLib.js +94 -0
  9. package/dist/CmnLib.js.map +1 -0
  10. package/dist/Config.js +26 -0
  11. package/dist/Config.js.map +1 -0
  12. package/dist/ConfigBase.js +152 -0
  13. package/dist/ConfigBase.js.map +1 -0
  14. package/dist/DebugMng.js +89 -102
  15. package/dist/DebugMng.js.map +1 -1
  16. package/dist/EventListenerCtn.js +21 -0
  17. package/dist/EventListenerCtn.js.map +1 -0
  18. package/dist/EventMng.js +1435 -1577
  19. package/dist/EventMng.js.map +1 -1
  20. package/dist/Grammar.js +194 -0
  21. package/dist/Grammar.js.map +1 -0
  22. package/dist/GrpLayer.js +163 -195
  23. package/dist/GrpLayer.js.map +1 -1
  24. package/dist/Layer.js +260 -0
  25. package/dist/Layer.js.map +1 -0
  26. package/dist/LayerMng.js +810 -991
  27. package/dist/LayerMng.js.map +1 -1
  28. package/dist/Main.js +144 -393
  29. package/dist/Main.js.map +1 -1
  30. package/dist/PropParser.js +936 -834
  31. package/dist/PropParser.js.map +1 -1
  32. package/dist/Reading.js +918 -786
  33. package/dist/Reading.js.map +1 -1
  34. package/dist/RubySpliter.js +59 -92
  35. package/dist/RubySpliter.js.map +1 -1
  36. package/dist/ScriptIterator.js +805 -1034
  37. package/dist/ScriptIterator.js.map +1 -1
  38. package/dist/SndBuf.js +1097 -1332
  39. package/dist/SndBuf.js.map +1 -1
  40. package/dist/SoundMng.js +124 -135
  41. package/dist/SoundMng.js.map +1 -1
  42. package/dist/SpritesMng.js +220 -232
  43. package/dist/SpritesMng.js.map +1 -1
  44. package/dist/SysBase.js +1729 -0
  45. package/dist/SysBase.js.map +1 -0
  46. package/dist/TxtLayer.js +1212 -1397
  47. package/dist/TxtLayer.js.map +1 -1
  48. package/dist/Variable.js +398 -466
  49. package/dist/Variable.js.map +1 -1
  50. package/dist/chunk.js +18 -0
  51. package/dist/gamepad.js +723 -511
  52. package/dist/gamepad.js.map +1 -1
  53. package/dist/pixi.js +13422 -0
  54. package/dist/pixi.js.map +1 -0
  55. package/dist/platform.js +424 -369
  56. package/dist/platform.js.map +1 -1
  57. package/dist/sn/AnalyzeTagArg.d.ts +1 -1
  58. package/dist/sn/AnalyzeTagArg.d.ts.map +1 -1
  59. package/dist/sn/CmnInterface.d.ts +3 -1
  60. package/dist/sn/CmnInterface.d.ts.map +1 -1
  61. package/dist/sn/CmnLib.d.ts.map +1 -1
  62. package/dist/sn/CmnTween.d.ts +3 -3
  63. package/dist/sn/CmnTween.d.ts.map +1 -1
  64. package/dist/sn/EventMng.d.ts.map +1 -1
  65. package/dist/sn/Grammar.d.ts +1 -1
  66. package/dist/sn/Grammar.d.ts.map +1 -1
  67. package/dist/sn/PropParser.d.ts +2 -2
  68. package/dist/sn/PropParser.d.ts.map +1 -1
  69. package/dist/sn/Reading.d.ts +6 -0
  70. package/dist/sn/Reading.d.ts.map +1 -1
  71. package/dist/sn/ScriptIterator.d.ts.map +1 -1
  72. package/dist/sn/SndBuf.d.ts +27 -16
  73. package/dist/sn/SndBuf.d.ts.map +1 -1
  74. package/dist/sn/SoundMng.d.ts +4 -1
  75. package/dist/sn/SoundMng.d.ts.map +1 -1
  76. package/dist/sn/SysBase.d.ts.map +1 -1
  77. package/dist/sn/TxtStage.d.ts +2 -1
  78. package/dist/sn/TxtStage.d.ts.map +1 -1
  79. package/dist/test/ValTest.d.ts +1 -1
  80. package/dist/test/ValTest.d.ts.map +1 -1
  81. package/dist/web.js +653 -8
  82. package/dist/web.js.map +1 -1
  83. package/dist_app/Button.js +131 -163
  84. package/dist_app/Button.js.map +1 -1
  85. package/dist_app/CallStack.js +19 -22
  86. package/dist_app/CallStack.js.map +1 -1
  87. package/dist_app/CmnInterface.js +91 -0
  88. package/dist_app/CmnInterface.js.map +1 -0
  89. package/dist_app/CmnLib.js +94 -0
  90. package/dist_app/CmnLib.js.map +1 -0
  91. package/dist_app/Config.js +26 -0
  92. package/dist_app/Config.js.map +1 -0
  93. package/dist_app/ConfigBase.js +152 -0
  94. package/dist_app/ConfigBase.js.map +1 -0
  95. package/dist_app/DebugMng.js +92 -0
  96. package/dist_app/DebugMng.js.map +1 -0
  97. package/dist_app/EventListenerCtn.js +21 -0
  98. package/dist_app/EventListenerCtn.js.map +1 -0
  99. package/dist_app/EventMng.js +1435 -1577
  100. package/dist_app/EventMng.js.map +1 -1
  101. package/dist_app/Grammar.js +194 -0
  102. package/dist_app/Grammar.js.map +1 -0
  103. package/dist_app/GrpLayer.js +163 -195
  104. package/dist_app/GrpLayer.js.map +1 -1
  105. package/dist_app/Layer.js +260 -0
  106. package/dist_app/Layer.js.map +1 -0
  107. package/dist_app/LayerMng.js +810 -991
  108. package/dist_app/LayerMng.js.map +1 -1
  109. package/dist_app/Main.js +144 -392
  110. package/dist_app/Main.js.map +1 -1
  111. package/dist_app/PropParser.js +936 -834
  112. package/dist_app/PropParser.js.map +1 -1
  113. package/dist_app/Reading.js +918 -786
  114. package/dist_app/Reading.js.map +1 -1
  115. package/dist_app/RubySpliter.js +59 -92
  116. package/dist_app/RubySpliter.js.map +1 -1
  117. package/dist_app/ScriptIterator.js +805 -1033
  118. package/dist_app/ScriptIterator.js.map +1 -1
  119. package/dist_app/SndBuf.js +1097 -1332
  120. package/dist_app/SndBuf.js.map +1 -1
  121. package/dist_app/SoundMng.js +124 -135
  122. package/dist_app/SoundMng.js.map +1 -1
  123. package/dist_app/SpritesMng.js +220 -231
  124. package/dist_app/SpritesMng.js.map +1 -1
  125. package/dist_app/SysBase.js +1729 -0
  126. package/dist_app/SysBase.js.map +1 -0
  127. package/dist_app/TxtLayer.js +1212 -1396
  128. package/dist_app/TxtLayer.js.map +1 -1
  129. package/dist_app/Variable.js +398 -466
  130. package/dist_app/Variable.js.map +1 -1
  131. package/dist_app/app.js +211 -8
  132. package/dist_app/app.js.map +1 -1
  133. package/dist_app/appMain.js +20 -21
  134. package/dist_app/appMain.js.map +1 -1
  135. package/dist_app/chunk.js +18 -0
  136. package/dist_app/gamepad.js +723 -511
  137. package/dist_app/gamepad.js.map +1 -1
  138. package/dist_app/pixi.js +11181 -0
  139. package/dist_app/pixi.js.map +1 -0
  140. package/dist_app/platform.js +424 -369
  141. package/dist_app/platform.js.map +1 -1
  142. package/dist_app/preload.js +2 -2
  143. package/dist_app/preload.js.map +1 -1
  144. package/dist_app/sn/AnalyzeTagArg.d.ts +1 -1
  145. package/dist_app/sn/AnalyzeTagArg.d.ts.map +1 -1
  146. package/dist_app/sn/CmnInterface.d.ts +3 -1
  147. package/dist_app/sn/CmnInterface.d.ts.map +1 -1
  148. package/dist_app/sn/CmnLib.d.ts.map +1 -1
  149. package/dist_app/sn/CmnTween.d.ts +3 -3
  150. package/dist_app/sn/CmnTween.d.ts.map +1 -1
  151. package/dist_app/sn/EventMng.d.ts.map +1 -1
  152. package/dist_app/sn/Grammar.d.ts +1 -1
  153. package/dist_app/sn/Grammar.d.ts.map +1 -1
  154. package/dist_app/sn/PropParser.d.ts +2 -2
  155. package/dist_app/sn/PropParser.d.ts.map +1 -1
  156. package/dist_app/sn/Reading.d.ts +6 -0
  157. package/dist_app/sn/Reading.d.ts.map +1 -1
  158. package/dist_app/sn/ScriptIterator.d.ts.map +1 -1
  159. package/dist_app/sn/SndBuf.d.ts +27 -16
  160. package/dist_app/sn/SndBuf.d.ts.map +1 -1
  161. package/dist_app/sn/SoundMng.d.ts +4 -1
  162. package/dist_app/sn/SoundMng.d.ts.map +1 -1
  163. package/dist_app/sn/SysBase.d.ts.map +1 -1
  164. package/dist_app/sn/TxtStage.d.ts +2 -1
  165. package/dist_app/sn/TxtStage.d.ts.map +1 -1
  166. package/dist_app/test/ValTest.d.ts +1 -1
  167. package/dist_app/test/ValTest.d.ts.map +1 -1
  168. package/package.json +23 -13
  169. package/dist/CmnTween.js +0 -1005
  170. package/dist/CmnTween.js.map +0 -1
  171. package/dist/web2.js +0 -21644
  172. package/dist/web2.js.map +0 -1
  173. package/dist_app/CmnTween.js +0 -1005
  174. package/dist_app/CmnTween.js.map +0 -1
  175. package/dist_app/app2.js +0 -18547
  176. package/dist_app/app2.js.map +0 -1
package/dist_app/Main.js CHANGED
@@ -1,393 +1,145 @@
1
- import { C as S, a as w, S as C, b as L, p as M, A as R, d as P, D as $, e as O, s as G } from "./app2.js";
2
- const B = "userdata:/", D = "downloads:/";
3
- class b extends S {
4
- constructor(t) {
5
- super(t), this.sys = t;
6
- }
7
- static async generate(t) {
8
- const e = new b(t), s = t.arg.cur + "prj.json", n = await t.fetch(s);
9
- if (!n.ok) throw Error(n.statusText);
10
- const i = await t.dec(s, await n.text());
11
- return await e.load(JSON.parse(i)), e;
12
- }
13
- async load(t) {
14
- return t.window ??= { width: 300, height: 300 }, w.stageW = t.window.width, w.stageH = t.window.height, w.debugLog = t.debug.debugLog, await w.init(), super.load(t);
15
- }
16
- searchPath(t, e = C.DEFAULT) {
17
- return t.startsWith(D) ? this.sys.path_downloads + t.slice(11) : t.startsWith(B) ? this.sys.path_userdata + "storage/" + t.slice(10) : super.searchPath(t, e);
18
- }
19
- }
20
- function T(c, t, e = 0, s = 0, n = 0) {
21
- const a = c.slice(0, t).split(`
22
- `), r = a.length;
23
- return {
24
- ln: s + r - 1,
25
- ch: r < 2 ? n + 1 + e + t : a.at(-1)?.length ?? 0
26
- };
27
- }
28
- class W {
29
- // 87 match 2725 step(0.5ms) PCRE2 https://regex101.com/r/aeN57J/1
30
- /*
31
- ;[^\n]*
32
- | (?<key>[^\s="'#|;]+)
33
- (?: \s | ;[^\n]*\n)*
34
- =
35
- (?: \s | ;[^\n]*\n)*
36
- (?: (?<val> [^\s"'#|;]+)
37
- | (["'#]) (?<val2>.*?) \3 )
38
- (?: \|
39
- (?: (?<def> [^\s"'#;]+)
40
- | (["'#]) (?<def2>.*?) \6 ) )?
41
- | (?<literal>[^\s;]+)
42
- */
43
- #e = /;[^\n]*|(?<key>[^\s="'#|;]+)(?:\s|;[^\n]*\n)*=(?:\s|;[^\n]*\n)*(?:(?<val>[^\s"'#|;]+)|(["'#])(?<val2>.*?)\3)(?:\|(?:(?<def>[^\s"'#;]+)|(["'#])(?<def2>.*?)\6))?|(?<literal>[^\s;]+)/g;
44
- // 【属性 = 値 | 省略値】の分析
45
- parse(t) {
46
- this.#t = {}, this.#n = !1;
47
- for (const { groups: e } of t.matchAll(this.#e)) {
48
- const { key: s, val: n, val2: i, def: a, def2: r, literal: o } = e;
49
- s ? this.#t[s] = {
50
- val: n ?? i ?? "",
51
- def: a ?? r
52
- } : o && (o === "*" ? this.#n = !0 : this.#t[o] = { val: "1" });
53
- }
54
- }
55
- // 属性と値の位置をまとめて返す
56
- parseinDetail(t, e, s, n) {
57
- const i = {}, a = t.slice(1 + e, -1);
58
- for (const { groups: r, index: o, 0: u } of a.matchAll(this.#e)) {
59
- if (!o) continue;
60
- const { key: f, val: d, val2: _ = "", literal: l } = r;
61
- if (l) {
62
- if (l.endsWith("=")) {
63
- const m = l.length - 1, { ch: v } = T(a, o + m, e, s, n);
64
- i[l.slice(0, -1)] = {
65
- k_ln: s,
66
- k_ch: v - m,
67
- v_ln: s,
68
- v_ch: v + 1,
69
- // v_ch: ch +1+lenNm +literal.length +1,
70
- v_len: 0
71
- };
72
- }
73
- continue;
74
- }
75
- if (!f) continue;
76
- const { ln: p, ch: g } = T(a, o, e, s, n), { ln: k, ch: h } = T(a, o + u.lastIndexOf(d ?? _) - (d ? 0 : 1), e, s, n);
77
- i[f] = { k_ln: p, k_ch: g, v_ln: k, v_ch: h, v_len: d ? d.length : _.length + 2 };
78
- }
79
- return i;
80
- }
81
- #t = {};
82
- get hPrm() {
83
- return this.#t;
84
- }
85
- #n = !1;
86
- get isKomeParam() {
87
- return this.#n;
88
- }
89
- }
90
- const E = /(?<name>[^\s;\]]+)/;
91
- function A(c) {
92
- const e = E.exec(c.slice(1, -1))?.groups;
93
- if (!e) throw `タグ記述【${c}】異常です(タグ解析)`;
94
- const s = e.name;
95
- return [s, c.slice(1 + s.length, -1)];
96
- }
97
- function H(c) {
98
- const e = E.exec(c.slice(1))?.groups;
99
- if (!e) throw `タグ記述【${c}】異常です(タグ解析)`;
100
- return e.name;
101
- }
102
- function I(c) {
103
- const t = c.replaceAll("==", "=").replaceAll("!=", "≠").split("="), e = t.length;
104
- if (e < 2 || e > 3) throw "「&計算」書式では「=」指定が一つか二つ必要です";
105
- const [s, n, i] = t;
106
- if (n.startsWith("&")) throw "「&計算」書式では「&」指定が不要です";
107
- return {
108
- name: s.replaceAll("=", "==").replaceAll("≠", "!="),
109
- text: n.replaceAll("=", "==").replaceAll("≠", "!="),
110
- cast: e === 3 ? i.trim() : void 0
111
- };
112
- }
113
- class V {
114
- constructor(t) {
115
- this.cfg = t, this.setEscape("");
116
- }
117
- #e;
118
- setEscape(t) {
119
- if (this.#s && t in this.#s) throw "[エスケープ文字] char【" + t + "】が登録済みの括弧マクロまたは一文字マクロです";
120
- this.#e = new RegExp(
121
- (t ? `\\${t}\\S|` : "") + // エスケープシーケンス
122
- `\\n+|\\t+|\\[let_ml\\s+[^\\]]+\\].+?(?=\\[endlet_ml[\\]\\s])|\\[(?:[^"'#;\\]]+|(["'#]).*?\\1|;[^\\n]*)*?]|;[^\\n]*|&[^&\\n]+&|&&?(?:[^"'#;\\n&]+|(["'#]).*?\\2)+|^\\*[^\\s\\[&;\\\\]+|[^\\n\\t\\[;${t ? `\\${t}` : ""}]+`,
123
- // 本文
124
- "gs"
125
- ), this.#t = new RegExp(`[\\w\\s;[\\]*=&|《》${t ? `\\${t}` : ""}]`), this.#r = new RegExp(`[\\n\\t;\\[*&${t ? `\\${t}` : ""}]`);
126
- }
127
- // 括弧マクロの定義
128
- bracket2macro(t, e, s, n) {
129
- const { name: i, text: a } = t;
130
- if (!i) throw "[bracket2macro] nameは必須です";
131
- if (!a) throw "[bracket2macro] textは必須です";
132
- const r = a.at(0);
133
- if (!r) throw "[bracket2macro] textは必須です";
134
- if (a.length !== 2) throw "[bracket2macro] textは括弧の前後を示す二文字を指定してください";
135
- if (!(i in e)) throw `[bracket2macro] 未定義のタグ又はマクロ[${i}]です`;
136
- this.#s ??= {};
137
- const o = a.charAt(1);
138
- if (r in this.#s) throw "[bracket2macro] text【" + r + "】が登録済みの括弧マクロまたは一文字マクロです";
139
- if (o in this.#s) throw "[bracket2macro] text【" + o + "】が登録済みの括弧マクロまたは一文字マクロです";
140
- if (this.#t.test(r)) throw "[bracket2macro] text【" + r + "】は括弧マクロに使用できない文字です";
141
- if (this.#t.test(o)) throw "[bracket2macro] text【" + o + "】は括弧マクロに使用できない文字です";
142
- this.#s[o] = "0", this.#s[r] = `[${i} text=`, this.addC2M(`\\${r}[^\\${o}]*\\${o}`, `\\${r}\\${o}`), this.#u(s, n);
143
- }
144
- // 一文字マクロの定義
145
- char2macro(t, e, s, n) {
146
- const { char: i, name: a } = t;
147
- if (!i) throw "[char2macro] charは必須です";
148
- if (this.#s ??= {}, i in this.#s) throw "[char2macro] char【" + i + "】が登録済みの括弧マクロまたは一文字マクロです";
149
- if (this.#t.test(i)) throw "[char2macro] char【" + i + "】は一文字マクロに使用できない文字です";
150
- if (!a) throw "[char2macro] nameは必須です";
151
- if (!(a in e)) throw `[char2macro] 未定義のタグ又はマクロ[${a}]です`;
152
- this.#s[i] = `[${a}]`, this.addC2M(`\\${i}`, `\\${i}`), this.#u(s, n);
153
- }
154
- #t;
155
- #n = new RegExp("");
156
- #a = "";
157
- #i = "";
158
- addC2M(t, e) {
159
- this.#a += `${t}|`, this.#i += e, this.#n = new RegExp(
160
- `(${this.#a}[^${this.#i}]+)`,
161
- "g"
162
- );
163
- }
164
- resolveScript(t) {
165
- const e = t.replaceAll(/\r\n?/g, `
166
- `).match(this.#e)?.flatMap((n) => {
167
- if (!this.testTagLetml(n)) return n;
168
- const i = /^([^\]]+?])(.*)$/s.exec(n);
169
- if (!i) return n;
170
- const [, a, r] = i;
171
- return [a, r];
172
- }) ?? [], s = { aToken: e, len: e.length, aLNum: [] };
173
- return this.#u(s), this.#h(s), s;
174
- }
175
- #l = /^\[(call|loadplugin)\s/;
176
- #o = /\bfn\s*=\s*[^\s\]]+/;
177
- #h(t) {
178
- for (let e = t.len - 1; e >= 0; --e) {
179
- const s = t.aToken[e];
180
- if (!this.#l.test(s)) continue;
181
- const [n, i] = A(s);
182
- this.#c.parse(i);
183
- const a = this.#c.hPrm.fn;
184
- if (!a) continue;
185
- const { val: r } = a;
186
- if (!r.endsWith("*")) continue;
187
- t.aToken.splice(e, 1, " ", "; " + s), t.aLNum.splice(e, 1, NaN, NaN);
188
- const o = n === "loadplugin" ? C.CSS : C.SN, u = this.cfg.matchPath("^" + r.slice(0, -1) + ".*", o);
189
- for (const f of u) {
190
- const d = s.replace(
191
- this.#o,
192
- "fn=" + decodeURIComponent(L(f[o]))
193
- );
194
- t.aToken.splice(e, 0, d), t.aLNum.splice(e, 0, NaN);
195
- }
196
- }
197
- t.len = t.aToken.length;
198
- }
199
- #c = new W();
200
- testTagLetml(t) {
201
- return /^\[let_ml\s/.test(t);
202
- }
203
- testTagEndLetml(t) {
204
- return /^\[endlet_ml\s*]/.test(t);
205
- }
206
- #s = void 0;
207
- #r;
208
- #u(t, e = 0) {
209
- if (this.#s) {
210
- for (let s = t.len - 1; s >= e; --s) {
211
- const n = t.aToken[s];
212
- if (this.testNoTxt(n.at(0) ?? `
213
- `)) continue;
214
- const i = t.aLNum[s], a = n.match(this.#n);
215
- if (!a) continue;
216
- let r = 1;
217
- for (let o = a.length - 1; o >= 0; --o) {
218
- let u = a[o];
219
- const f = this.#s[u.at(0) ?? " "];
220
- f && (u = f + (f.endsWith("]") ? "" : `'${u.slice(1, -1)}']`)), t.aToken.splice(s, r, u), t.aLNum.splice(s, r, i), r = 0;
221
- }
222
- }
223
- t.len = t.aToken.length;
224
- }
225
- }
226
- testNoTxt(t) {
227
- return this.#r.test(t);
228
- }
229
- //4tst
230
- }
231
- const y = "skynovel";
232
- class x {
233
- constructor(t) {
234
- this.sys = t;
235
- }
236
- static async generate(t) {
237
- G();
238
- const e = new x(t);
239
- return await e.#l().catch((s) => console.error("Main.generate err e:%o", s)), e;
240
- }
241
- cvs;
242
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
243
- #e = /* @__PURE__ */ Object.create(null);
244
- // タグ処理辞書
245
- #t;
246
- #n;
247
- #a;
248
- #i = [];
249
- async #l() {
250
- const t = await b.generate(this.sys);
251
- this.sys.setMain(this, t);
252
- const e = {
253
- width: t.oCfg.window.width,
254
- height: t.oCfg.window.height,
255
- backgroundColor: M(String(t.oCfg.init.bg_color)),
256
- // このString()は後方互換性のため必須
257
- resolution: globalThis.devicePixelRatio
258
- }, s = document.getElementById(y);
259
- if (s) {
260
- const h = s.cloneNode(!0);
261
- h.id = y, e.view = s;
262
- const m = s.parentNode;
263
- this.#i.unshift(() => m.appendChild(h));
264
- } else {
265
- const h = document.createElement("canvas");
266
- h.id = y, e.view = h, document.body.appendChild(h), this.#i.unshift(() => document.body.removeChild(h));
267
- }
268
- const n = new R(e);
269
- this.#i.unshift(() => {
270
- P(), this.sys.destroy(), n.destroy(!1);
271
- }), this.cvs = n.view, this.cvs.id = y + "_act", s || document.body.appendChild(this.cvs);
272
- const i = document.createElement("canvas").getContext("2d");
273
- if (!i) throw "#init cc err";
274
- w.cc4ColorName = i;
275
- const [{ Variable: a }, { PropParser: r }, { SoundMng: o }, { ScriptIterator: u }, { LayerMng: f }, { EventMng: d }, { Button: _ }] = await Promise.all([
276
- import("./Variable.js"),
277
- import("./PropParser.js"),
278
- import("./SoundMng.js"),
279
- import("./ScriptIterator.js"),
280
- import("./LayerMng.js"),
281
- import("./EventMng.js"),
282
- import("./Button.js")
283
- ]);
284
- _.init(t);
285
- const l = new a(this.sys, t, this.#e), p = new r(l, t.oCfg.init.escape);
286
- this.#o = (h, m, v, N) => l.setVal_Nochk(h, m, v, N), this.#s = (h) => p.getValAmpersand(h), this.#r = (h) => p.parse(h), await Promise.allSettled(this.sys.init(this.#e, n, l));
287
- const g = new o(t, this.#e, l, this, this.sys);
288
- this.#i.unshift(() => g.destroy()), this.#t = new u(t, this.#e, this, l, p, g, this.sys), this.#i.unshift(() => this.#t.destroy());
289
- const k = new $(this.sys, this.#e, this.#t);
290
- this.#i.unshift(() => k.destroy()), this.errScript = (h, m = !0) => {
291
- if (this.stop(), $.myTrace(h), w.debugLog && console.log("🍜 SKYNovel err!"), m) throw h;
292
- }, this.#n = new f(t, this.#e, n, l, this, this.#t, this.sys, g, p), this.#i.unshift(() => this.#n.destroy()), this.#a = new d(t, this.#e, n, this, this.#n, l, g, this.#t, this.sys), this.#i.unshift(() => this.#a.destroy()), this.#i.unshift(() => {
293
- this.stop(), this.#h = !1;
294
- const h = () => !0;
295
- for (const m in this.#e) this.#e[m] = h;
296
- });
297
- }
298
- destroy() {
299
- this.resume = this.destroy = () => {
300
- }, this.cvs.parentElement?.removeChild(this.cvs);
301
- for (const t of this.#i) t();
302
- this.#i = [];
303
- }
304
- errScript = (t, e = !0) => {
305
- };
306
- resumeByJumpOrCall(t) {
307
- if (t.url) {
308
- this.#e.navigate_to(t), this.#t.jumpJustBefore();
309
- return;
310
- }
311
- if (this.#o("tmp", "sn.eventArg", String(t.arg ?? "")), this.#o("tmp", "sn.eventLabel", t.label ?? ""), O(t, "call", !1)) {
312
- if (this.#t.subIdxToken(), this.#e.call(t)) return;
313
- } else if (this.#e.clear_event({}), this.#e.jump(t)) return;
314
- this.resume();
315
- }
316
- #o = (t, e, s, n = !1) => {
317
- };
318
- resume() {
319
- this.#n.clearBreak(), this.#t.noticeBreak(!1), this.#a.hideHint(), queueMicrotask(() => {
320
- this.#c();
321
- });
322
- }
323
- stop = () => {
324
- this.#t.noticeBreak(!0);
325
- };
326
- setLoop(t, e = "") {
327
- (this.#h = t) ? this.resume() : this.stop(), this.sys.setTitleInfo(e ? ` -- ${e}中` : "");
328
- }
329
- // oxlint-disable-next-line no-unused-private-class-members
330
- #h = !0;
331
- //MARK: メイン処理(シナリオ解析)
332
- async #c() {
333
- let t = "";
334
- try {
335
- for (; this.#h; ) {
336
- let e = this.#t.nextToken();
337
- if (!e) return;
338
- const s = e.charCodeAt(0);
339
- if (s === 9) continue;
340
- if (s === 10) {
341
- this.#t.addLineNum(e.length);
342
- continue;
343
- }
344
- if (s === 91) {
345
- if (t = "タグ開始", this.#t.isBreak(e)) return;
346
- const [i, a] = A(e);
347
- t = `[${i}]例外`;
348
- const r = (e.match(/\n/g) ?? []).length;
349
- if (r > 0 && this.#t.addLineNum(r), await this.#t.タグ解析(
350
- i,
351
- a
352
- )) {
353
- this.stop();
354
- return;
355
- }
356
- continue;
357
- }
358
- if (s === 38) {
359
- if (!e.endsWith("&")) {
360
- if (t = "変数計算", this.#t.isBreak(e)) return;
361
- const i = I(e.slice(1));
362
- i.name = this.#s(i.name), i.text = String(this.#r(i.text)), this.#e.let(i);
363
- continue;
364
- }
365
- if (t = "変数操作", e.charAt(1) === "&") throw new Error("「&表示&」書式では「&」指定が不要です");
366
- e = String(this.#r(e.slice(1, -1)));
367
- } else {
368
- if (s === 59) continue;
369
- if (s === 42 && e.length > 1) continue;
370
- }
371
- t = "文字表示", this.#n.setNormalChWait(), this.#n.currentTxtlayForeNeedErr.tagCh(e);
372
- }
373
- } catch (e) {
374
- this.errScript(`${t} ${e instanceof Error ? `mes=${e.message}(${e.name})` : String(e)}`, !1);
375
- }
376
- }
377
- #s = (t) => "";
378
- #r;
379
- }
380
- const K = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
381
- __proto__: null,
382
- Main: x
383
- }, Symbol.toStringTag, { value: "Module" }));
384
- export {
385
- W as A,
386
- V as G,
387
- K as M,
388
- B as P,
389
- A as a,
390
- D as b,
391
- H as t
1
+ import { h as parseColor, s as argChk_Boolean, t as CmnLib } from "./CmnLib.js";
2
+ import { _ as clearTextureCache, r as Application, y as skipHello } from "./pixi.js";
3
+ import "./ConfigBase.js";
4
+ import { t as DebugMng } from "./DebugMng.js";
5
+ import { t as Config } from "./Config.js";
6
+ import { i as tagToken2Name_Args, n as splitAmpersand } from "./Grammar.js";
7
+ var SN_ID = "skynovel", Main = class d {
8
+ static async generate(e) {
9
+ skipHello();
10
+ let i = new d(e);
11
+ return await i.#a().catch((e) => console.error("Main.generate err e:%o", e)), i;
12
+ }
13
+ cvs;
14
+ #e = Object.create(null);
15
+ #t;
16
+ #n;
17
+ #r;
18
+ #i = [];
19
+ constructor(e) {
20
+ this.sys = e;
21
+ }
22
+ async #a() {
23
+ let i = await Config.generate(this.sys);
24
+ this.sys.setMain(this, i);
25
+ let c = {
26
+ width: i.oCfg.window.width,
27
+ height: i.oCfg.window.height,
28
+ backgroundColor: parseColor(String(i.oCfg.init.bg_color)),
29
+ resolution: globalThis.devicePixelRatio
30
+ }, l = document.getElementById(SN_ID);
31
+ if (l) {
32
+ let e = l.cloneNode(!0);
33
+ e.id = SN_ID, c.view = l;
34
+ let i = l.parentNode;
35
+ this.#i.unshift(() => i.appendChild(e));
36
+ } else {
37
+ let e = document.createElement("canvas");
38
+ e.id = SN_ID, c.view = e, document.body.appendChild(e), this.#i.unshift(() => document.body.removeChild(e));
39
+ }
40
+ let u = new Application(c);
41
+ this.#i.unshift(() => {
42
+ clearTextureCache(), this.sys.destroy(), u.destroy(!1);
43
+ }), this.cvs = u.view, this.cvs.id = SN_ID + "_act", l || document.body.appendChild(this.cvs);
44
+ let d = document.createElement("canvas").getContext("2d");
45
+ if (!d) throw "#init cc err";
46
+ CmnLib.cc4ColorName = d;
47
+ let [{ Variable: f }, { PropParser: p }, { SoundMng: m }, { ScriptIterator: h }, { LayerMng: g }, { EventMng: _ }, { Button: v }] = await Promise.all([
48
+ import("./Variable.js"),
49
+ import("./PropParser.js"),
50
+ import("./SoundMng.js"),
51
+ import("./ScriptIterator.js"),
52
+ import("./LayerMng.js"),
53
+ import("./EventMng.js"),
54
+ import("./Button.js")
55
+ ]);
56
+ v.init(i);
57
+ let y = new f(this.sys, i, this.#e), b = new p(y, i.oCfg.init.escape);
58
+ this.#o = (e, i, a, o) => y.setVal_Nochk(e, i, a, o), this.#l = (e) => b.getValAmpersand(e), this.#u = (e) => b.parse(e), await Promise.allSettled(this.sys.init(this.#e, u, y));
59
+ let x = new m(i, this.#e, y, this, this.sys);
60
+ this.#i.unshift(() => x.destroy()), this.#t = new h(i, this.#e, this, y, b, x, this.sys), this.#i.unshift(() => this.#t.destroy());
61
+ let S = new DebugMng(this.sys, this.#e, this.#t);
62
+ this.#i.unshift(() => S.destroy()), this.errScript = (e, i) => {
63
+ if (this.stop(), DebugMng.myTrace(e), CmnLib.debugLog && console.log("🍜 SKYNovel err!"), i) throw e;
64
+ }, this.#n = new g(i, this.#e, u, y, this, this.#t, this.sys, x, b), this.#i.unshift(() => this.#n.destroy()), this.#r = new _(i, this.#e, u, this, this.#n, y, x, this.#t, this.sys), this.#i.unshift(() => this.#r.destroy()), this.#i.unshift(() => {
65
+ this.stop(), this.#s = !1;
66
+ let e = () => !0;
67
+ for (let i in this.#e) this.#e[i] = e;
68
+ });
69
+ }
70
+ destroy() {
71
+ this.resume = this.destroy = () => {}, this.cvs.parentElement?.removeChild(this.cvs);
72
+ for (let e of this.#i) e();
73
+ this.#i = [];
74
+ }
75
+ errScript = (e, i = !0) => {};
76
+ resumeByJumpOrCall(e) {
77
+ if (e.url) {
78
+ this.#e.navigate_to(e), this.#t.jumpJustBefore();
79
+ return;
80
+ }
81
+ if (this.#o("tmp", "sn.eventArg", String(e.arg ?? "")), this.#o("tmp", "sn.eventLabel", e.label ?? ""), argChk_Boolean(e, "call", !1)) {
82
+ if (this.#t.subIdxToken(), this.#e.call(e)) return;
83
+ } else if (this.#e.clear_event({}), this.#e.jump(e)) return;
84
+ this.resume();
85
+ }
86
+ #o = (e, i, a, o = !1) => {};
87
+ resume() {
88
+ this.#n.clearBreak(), this.#t.noticeBreak(!1), this.#r.hideHint(), queueMicrotask(() => {
89
+ this.#c();
90
+ });
91
+ }
92
+ stop = () => {
93
+ this.#t.noticeBreak(!0);
94
+ };
95
+ setLoop(e, i = "") {
96
+ (this.#s = e) ? this.resume() : this.stop(), this.sys.setTitleInfo(i ? ` -- ${i}中` : "");
97
+ }
98
+ #s = !0;
99
+ async #c() {
100
+ let e = "";
101
+ try {
102
+ for (; this.#s;) {
103
+ let i = this.#t.nextToken();
104
+ if (!i) return;
105
+ let a = i.charCodeAt(0);
106
+ if (a !== 9) {
107
+ if (a === 10) {
108
+ this.#t.addLineNum(i.length);
109
+ continue;
110
+ }
111
+ if (a === 91) {
112
+ if (e = "タグ開始", this.#t.isBreak(i)) return;
113
+ let [a, o] = tagToken2Name_Args(i);
114
+ e = `[${a}]例外`;
115
+ let s = (i.match(/\n/g) ?? []).length;
116
+ if (s > 0 && this.#t.addLineNum(s), await this.#t.タグ解析(a, o)) {
117
+ this.stop();
118
+ return;
119
+ }
120
+ continue;
121
+ }
122
+ if (a === 38) {
123
+ if (!i.endsWith("&")) {
124
+ if (e = "変数計算", this.#t.isBreak(i)) return;
125
+ let a = splitAmpersand(i.slice(1));
126
+ a.name = this.#l(a.name), a.text = String(this.#u(a.text)), this.#e.let(a);
127
+ continue;
128
+ }
129
+ if (e = "変数操作", i.charAt(1) === "&") throw Error("「&表示&」書式では「&」指定が不要です");
130
+ i = String(this.#u(i.slice(1, -1)));
131
+ } else if (a === 59) continue;
132
+ else if (a === 42 && i.length > 1) continue;
133
+ e = "文字表示", this.#n.setNormalChWait(), this.#n.currentTxtlayForeNeedErr.tagCh(i);
134
+ }
135
+ }
136
+ } catch (i) {
137
+ this.errScript(`${e} ${i instanceof Error ? `mes=${i.message}(${i.name})` : String(i)}`, !1);
138
+ }
139
+ }
140
+ #l = (e) => "";
141
+ #u;
392
142
  };
393
- //# sourceMappingURL=Main.js.map
143
+ export { Main };
144
+
145
+ //# sourceMappingURL=Main.js.map