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