From 8793108a01980083e192c3051ccd6032d1c475f7 Mon Sep 17 00:00:00 2001 From: RRFZ <247457381+Plastic-time@users.noreply.github.com> Date: Sat, 21 Nov 2026 07:27:52 -0500 Subject: [PATCH] fix(hook): a page of the current line alone does not prove paging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Aokana sends the current line alone on several streams. Its typewriter sets the whole line once per frame, and LunaHook buffers the frames into one multi-line output. Its script streams carry the line with its English and Chinese, one of them with 【speaker】 tags. Core took each of these as page text. Each line was drawn under the one before it, the page reset came up to half a second later, and the reader kept the line moved up from the stacked block. Now page text only proves paging when it holds kana beyond the current line and speaker tags. A page game such as Higurashi still shows this on its first page, so its replay joins the same lines as before, now asserted exactly. After that, a page holding just the current line still turns the page. --- core/hook-native.cjs | 8 ++++++++ validation/aokana-typewriter-page.test.cjs | 18 +++++++++++++++++ .../unity-replay/aokana-typewriter.jsonl | 20 +++++++++++++++++++ validation/issue-468-higurashi.test.cjs | 2 +- 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 validation/aokana-typewriter-page.test.cjs create mode 100644 validation/helpers/unity-replay/aokana-typewriter.jsonl diff --git a/core/hook-native.cjs b/core/hook-native.cjs index 3debf48a..d1e3e8d0 100644 --- a/core/hook-native.cjs +++ b/core/hook-native.cjs @@ -421,6 +421,14 @@ class HookNative{ game holds it (several lines, the current line among them: TMP set_text of the whole page) is that evidence: the game pages, and a page that holds the current line but no longer the one before it was turned before this line. Any engine. */ auxPage(m){try{const P=this.pageText;if(!P||typeof m?.text!=='string'||!m.text.includes(String.fromCharCode(10)))return;const k=HookNative.flat(m.text.replace(/<[^>]*>/g,'')),R=this.hookRecent||[],cur=R.length?R[R.length-1].key:'';if(cur.length<2||!k.includes(cur))return; + /* 2026-11-21 (user, Aokana: 「文字到处乱跳」): text that holds the current line and no other Japanese is no page. Aokana sends + the current line alone on several streams: its typewriter sets the whole line once per frame (LunaHook buffers the frames + into one output, every row the line again) and its script streams carry the line with its English and Chinese, one of them + with 【speaker】 tags. Taken as a page, each line was drawn under the one before it, the reset came up to half a second later, + and the layout fitted to the stacked block kept the line moved up. A page game shows its paging as soon as its page holds + kana beyond the current line, often before the next line reaches the hook; once it does, a page holding just the current + line still turns it. */ + if(!P.paging&&!/[\u3041-\u309f\u30a1-\u30fa]/.test(k.split(cur).join('').replace(/【[^】]*】/g,'')))return; P.paging=true;P.auxPageAt=this.now();const prev=R.length>=2?R[R.length-2].key:''; if(prev&&prev!==cur&&!k.includes(prev)&&this.pageSaidSame===true&&P.auxResetFor!==cur){P.auxResetFor=cur;this.pageSaidSame=false;this.trace('page turned before this line (the page text no longer holds the line before it)');this.emit({type:'hookPage',engine:'text',reset:true,at:this.now()});}}catch{}} /* share of the character pairs of `flat` found in the hooked lines of the last ten minutes (0 when nothing to compare) */ diff --git a/validation/aokana-typewriter-page.test.cjs b/validation/aokana-typewriter-page.test.cjs new file mode 100644 index 00000000..83fcecb7 --- /dev/null +++ b/validation/aokana-typewriter-page.test.cjs @@ -0,0 +1,18 @@ +'use strict'; +/* 2026-11-21 (user, Aokana: 「文字到处乱跳」). Aokana sends the current line alone on several streams: its typewriter sets the + whole line once per frame (LunaHook buffers the frames into one multi-line output, every row the line again), and its script + streams carry the line with its English and Chinese, one of them with the speaker's name. Taken as a page, each line was drawn + under the one before it until the page reset came, and the reader's fit kept the line moved up. A page that holds other + Japanese (higurashi-page.jsonl, issue-468 test) still pages from its first page on. The fixture is built by hand from the live hook log. */ +const test=require('node:test'),assert=require('node:assert/strict'),path=require('node:path'); +const {replay}=require('./helpers/hook-replay.cjs'); +const dir=path.join(__dirname,'helpers','unity-replay'); + +test('streams that hold only the current line (typewriter frames, script text with its translations) are not a page',()=>{ + const r=replay(path.join(dir,'aokana-typewriter.jsonl'),{name:'Aokana.exe'}); + const pages=r.events.filter(e=>e&&e.type==='hookPage'); + assert.equal(pages.filter(p=>p.same===true||p.reset===true).length,0,'no page joins or resets: '+JSON.stringify(pages)); + assert.ok(!r.traces.some(t=>/page turned before this line/.test(t)),'no page turn traced'); + const shown=r.events.filter(e=>typeof e?.hookSource==='string'&&e.hookSource).map(e=>e.hookSource); + for(const l of ['「ああ、じゃあ元気で」','……','「……ぐすっ」','「おい、泣くなよ。さっき言ったろ、そういうのはナシだって」','「でも……」'])assert.ok(shown.includes(l),l+' reaches the reader: '+JSON.stringify(shown)); +}); diff --git a/validation/helpers/unity-replay/aokana-typewriter.jsonl b/validation/helpers/unity-replay/aokana-typewriter.jsonl new file mode 100644 index 00000000..e9709124 --- /dev/null +++ b/validation/helpers/unity-replay/aokana-typewriter.jsonl @@ -0,0 +1,20 @@ +{"t":1795263000000,"m":{"type":"hookSource","text":"「ああ、じゃあ元気で」\n","sourceName":"TMP_Text:TMP_Text:ring:String:String:Str","sourceCode":"EXHMXF2@Unity.TextMeshPro:TMPro:TMP_Text:set_text:1:JIT:UNITY"}} +{"t":1795263000040,"m":{"type":"hookPageText","text":"「ああ、じゃあ元気で」\n「ああ、じゃあ元気で」\n「ああ、じゃあ元気で」\n「ああ、じゃあ元気で」\n「ああ、じゃあ元気で」\n「ああ、じゃあ元気で」\n「ああ、じゃあ元気で」\n「ああ、じゃあ元気で」\n","sourceName":"TMP_Text:TMP_Text:ring:String:String:Str"}} +{"t":1795263000060,"m":{"type":"hookAuxText","text":"Well, take care then.␂「ああ、じゃあ元気で」␂「啊,那你保重」\n","sourceName":"String:String:String"}} +{"t":1795263000061,"m":{"type":"hookAuxText","text":"【Girl】:Well, take care then.\n【女の子】:「ああ、じゃあ元気で」\n【女孩】:「啊,那你保重」\n","sourceName":"String:String:String:String"}} +{"t":1795263003000,"m":{"type":"hookSource","text":"……\n","sourceName":"TMP_Text:TMP_Text:ring:String:String:Str","sourceCode":"EXHMXF2@Unity.TextMeshPro:TMPro:TMP_Text:set_text:1:JIT:UNITY"}} +{"t":1795263003040,"m":{"type":"hookPageText","text":"……\n……\n……\n……\n……\n……\n……\n……\n","sourceName":"TMP_Text:TMP_Text:ring:String:String:Str"}} +{"t":1795263003060,"m":{"type":"hookAuxText","text":"...␂……␂……\n","sourceName":"String:String:String"}} +{"t":1795263003061,"m":{"type":"hookAuxText","text":"【Girl】:...\n【女の子】:……\n【女孩】:……\n","sourceName":"String:String:String:String"}} +{"t":1795263006000,"m":{"type":"hookSource","text":"「……ぐすっ」\n","sourceName":"TMP_Text:TMP_Text:ring:String:String:Str","sourceCode":"EXHMXF2@Unity.TextMeshPro:TMPro:TMP_Text:set_text:1:JIT:UNITY"}} +{"t":1795263006040,"m":{"type":"hookPageText","text":"「……ぐすっ」\n「……ぐすっ」\n「……ぐすっ」\n「……ぐすっ」\n「……ぐすっ」\n「……ぐすっ」\n「……ぐすっ」\n「……ぐすっ」\n","sourceName":"TMP_Text:TMP_Text:ring:String:String:Str"}} +{"t":1795263006060,"m":{"type":"hookAuxText","text":"...*sniff*␂「……ぐすっ」␂「……呜」\n","sourceName":"String:String:String"}} +{"t":1795263006061,"m":{"type":"hookAuxText","text":"【Girl】:...*sniff*\n【女の子】:「……ぐすっ」\n【女孩】:「……呜」\n","sourceName":"String:String:String:String"}} +{"t":1795263009000,"m":{"type":"hookSource","text":"「おい、泣くなよ。さっき言ったろ、そういうのはナシだって」\n","sourceName":"TMP_Text:TMP_Text:ring:String:String:Str","sourceCode":"EXHMXF2@Unity.TextMeshPro:TMPro:TMP_Text:set_text:1:JIT:UNITY"}} +{"t":1795263009040,"m":{"type":"hookPageText","text":"「おい、泣くなよ。さっき言ったろ、そういうのはナシだって」\n「おい、泣くなよ。さっき言ったろ、そういうのはナシだって」\n「おい、泣くなよ。さっき言ったろ、そういうのはナシだって」\n「おい、泣くなよ。さっき言ったろ、そういうのはナシだって」\n「おい、泣くなよ。さっき言ったろ、そういうのはナシだって」\n「おい、泣くなよ。さっき言ったろ、そういうのはナシだって」\n「おい、泣くなよ。さっき言ったろ、そういうのはナシだって」\n「おい、泣くなよ。さっき言ったろ、そういうのはナシだって」\n","sourceName":"TMP_Text:TMP_Text:ring:String:String:Str"}} +{"t":1795263009060,"m":{"type":"hookAuxText","text":"Hey, don't cry. I told you, none of that.␂「おい、泣くなよ。さっき言ったろ、そういうのはナシだって」␂「喂,别哭啊。刚才说过了,不许这样」\n","sourceName":"String:String:String"}} +{"t":1795263009061,"m":{"type":"hookAuxText","text":"【Girl】:Hey, don't cry. I told you, none of that.\n【女の子】:「おい、泣くなよ。さっき言ったろ、そういうのはナシだって」\n【女孩】:「喂,别哭啊。刚才说过了,不许这样」\n","sourceName":"String:String:String:String"}} +{"t":1795263012000,"m":{"type":"hookSource","text":"「でも……」\n","sourceName":"TMP_Text:TMP_Text:ring:String:String:Str","sourceCode":"EXHMXF2@Unity.TextMeshPro:TMPro:TMP_Text:set_text:1:JIT:UNITY"}} +{"t":1795263012040,"m":{"type":"hookPageText","text":"「でも……」\n「でも……」\n「でも……」\n「でも……」\n「でも……」\n「でも……」\n「でも……」\n「でも……」\n","sourceName":"TMP_Text:TMP_Text:ring:String:String:Str"}} +{"t":1795263012060,"m":{"type":"hookAuxText","text":"But...␂「でも……」␂「可是……」\n","sourceName":"String:String:String"}} +{"t":1795263012061,"m":{"type":"hookAuxText","text":"【Girl】:But...\n【女の子】:「でも……」\n【女孩】:「可是……」\n","sourceName":"String:String:String:String"}} diff --git a/validation/issue-468-higurashi.test.cjs b/validation/issue-468-higurashi.test.cjs index 9216e7ee..718eb937 100644 --- a/validation/issue-468-higurashi.test.cjs +++ b/validation/issue-468-higurashi.test.cjs @@ -77,7 +77,7 @@ test('NVL page: another stream holding the page makes the lines stack, a turned (hookPageText, the shape seen live: lines with <#FFFFFFxx> fade tags, blank padding); the page turns before 「でも…薄々は気付いてる。」 */ const r=replay(path.join(dir,'higurashi-page.jsonl'),{name:EXE}); const pages=r.events.filter(e=>e&&e.type==='hookPage'); - assert.ok(pages.filter(p=>p.same===true&&!p.reset).length>=5,'lines join the page: '+JSON.stringify(pages)); + assert.equal(pages.filter(p=>p.same===true&&!p.reset).length,6,'every line after the first of each page joins it, from the first page on: '+JSON.stringify(pages)); const reset=pages.findIndex(p=>p.reset===true);assert.ok(reset>0,'the turned page is reported'); const srcs=shown(r).map(l=>l.text); const turnAt=r.events.indexOf(pages[reset]),before=r.events.slice(0,turnAt).filter(e=>typeof e?.hookSource==='string'&&e.hookSource).map(e=>e.hookSource);