Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions core/hook-native.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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) */
Expand Down
18 changes: 18 additions & 0 deletions validation/aokana-typewriter-page.test.cjs
Original file line number Diff line number Diff line change
@@ -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));
});
20 changes: 20 additions & 0 deletions validation/helpers/unity-replay/aokana-typewriter.jsonl
Original file line number Diff line number Diff line change
@@ -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":"<color=#6e6e6e><alpha=#ff>「<alpha=#ff>あ<alpha=#ff>あ<alpha=#eb>、<alpha=#00>じ<alpha=#00>ゃ<alpha=#00>あ<alpha=#00>元<alpha=#00>気<alpha=#00>で<alpha=#00>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>あ<alpha=#ff>あ<alpha=#ff>、<alpha=#ff>じ<alpha=#ff>ゃ<alpha=#eb>あ<alpha=#00>元<alpha=#00>気<alpha=#00>で<alpha=#00>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>あ<alpha=#ff>あ<alpha=#ff>、<alpha=#ff>じ<alpha=#ff>ゃ<alpha=#ff>あ<alpha=#ff>元<alpha=#ff>気<alpha=#eb>で<alpha=#00>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>あ<alpha=#ff>あ<alpha=#ff>、<alpha=#ff>じ<alpha=#ff>ゃ<alpha=#ff>あ<alpha=#ff>元<alpha=#ff>気<alpha=#ff>で<alpha=#ff>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>あ<alpha=#ff>あ<alpha=#ff>、<alpha=#ff>じ<alpha=#ff>ゃ<alpha=#ff>あ<alpha=#ff>元<alpha=#ff>気<alpha=#ff>で<alpha=#ff>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>あ<alpha=#ff>あ<alpha=#ff>、<alpha=#ff>じ<alpha=#ff>ゃ<alpha=#ff>あ<alpha=#ff>元<alpha=#ff>気<alpha=#ff>で<alpha=#ff>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>あ<alpha=#ff>あ<alpha=#ff>、<alpha=#ff>じ<alpha=#ff>ゃ<alpha=#ff>あ<alpha=#ff>元<alpha=#ff>気<alpha=#ff>で<alpha=#ff>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>あ<alpha=#ff>あ<alpha=#ff>、<alpha=#ff>じ<alpha=#ff>ゃ<alpha=#ff>あ<alpha=#ff>元<alpha=#ff>気<alpha=#ff>で<alpha=#ff>」\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":"<color=#6e6e6e><alpha=#ff>…<alpha=#ff>…\n<color=#6e6e6e><alpha=#ff>…<alpha=#ff>…\n<color=#6e6e6e><alpha=#ff>…<alpha=#ff>…\n<color=#6e6e6e><alpha=#ff>…<alpha=#ff>…\n<color=#6e6e6e><alpha=#ff>…<alpha=#ff>…\n<color=#6e6e6e><alpha=#ff>…<alpha=#ff>…\n<color=#6e6e6e><alpha=#ff>…<alpha=#ff>…\n<color=#6e6e6e><alpha=#ff>…<alpha=#ff>…\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":"<color=#6e6e6e><alpha=#ff>「<alpha=#ff>…<alpha=#ff>…<alpha=#eb>ぐ<alpha=#00>す<alpha=#00>っ<alpha=#00>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>…<alpha=#ff>…<alpha=#ff>ぐ<alpha=#ff>す<alpha=#ff>っ<alpha=#eb>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>…<alpha=#ff>…<alpha=#ff>ぐ<alpha=#ff>す<alpha=#ff>っ<alpha=#ff>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>…<alpha=#ff>…<alpha=#ff>ぐ<alpha=#ff>す<alpha=#ff>っ<alpha=#ff>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>…<alpha=#ff>…<alpha=#ff>ぐ<alpha=#ff>す<alpha=#ff>っ<alpha=#ff>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>…<alpha=#ff>…<alpha=#ff>ぐ<alpha=#ff>す<alpha=#ff>っ<alpha=#ff>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>…<alpha=#ff>…<alpha=#ff>ぐ<alpha=#ff>す<alpha=#ff>っ<alpha=#ff>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>…<alpha=#ff>…<alpha=#ff>ぐ<alpha=#ff>す<alpha=#ff>っ<alpha=#ff>」\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":"<color=#6e6e6e><alpha=#ff>「<alpha=#ff>お<alpha=#ff>い<alpha=#eb>、<alpha=#00>泣<alpha=#00>く<alpha=#00>な<alpha=#00>よ<alpha=#00>。<alpha=#00>さ<alpha=#00>っ<alpha=#00>き<alpha=#00>言<alpha=#00>っ<alpha=#00>た<alpha=#00>ろ<alpha=#00>、<alpha=#00>そ<alpha=#00>う<alpha=#00>い<alpha=#00>う<alpha=#00>の<alpha=#00>は<alpha=#00>ナ<alpha=#00>シ<alpha=#00>だ<alpha=#00>っ<alpha=#00>て<alpha=#00>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>お<alpha=#ff>い<alpha=#ff>、<alpha=#ff>泣<alpha=#ff>く<alpha=#eb>な<alpha=#00>よ<alpha=#00>。<alpha=#00>さ<alpha=#00>っ<alpha=#00>き<alpha=#00>言<alpha=#00>っ<alpha=#00>た<alpha=#00>ろ<alpha=#00>、<alpha=#00>そ<alpha=#00>う<alpha=#00>い<alpha=#00>う<alpha=#00>の<alpha=#00>は<alpha=#00>ナ<alpha=#00>シ<alpha=#00>だ<alpha=#00>っ<alpha=#00>て<alpha=#00>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>お<alpha=#ff>い<alpha=#ff>、<alpha=#ff>泣<alpha=#ff>く<alpha=#ff>な<alpha=#ff>よ<alpha=#ff>。<alpha=#eb>さ<alpha=#00>っ<alpha=#00>き<alpha=#00>言<alpha=#00>っ<alpha=#00>た<alpha=#00>ろ<alpha=#00>、<alpha=#00>そ<alpha=#00>う<alpha=#00>い<alpha=#00>う<alpha=#00>の<alpha=#00>は<alpha=#00>ナ<alpha=#00>シ<alpha=#00>だ<alpha=#00>っ<alpha=#00>て<alpha=#00>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>お<alpha=#ff>い<alpha=#ff>、<alpha=#ff>泣<alpha=#ff>く<alpha=#ff>な<alpha=#ff>よ<alpha=#ff>。<alpha=#ff>さ<alpha=#ff>っ<alpha=#ff>き<alpha=#eb>言<alpha=#00>っ<alpha=#00>た<alpha=#00>ろ<alpha=#00>、<alpha=#00>そ<alpha=#00>う<alpha=#00>い<alpha=#00>う<alpha=#00>の<alpha=#00>は<alpha=#00>ナ<alpha=#00>シ<alpha=#00>だ<alpha=#00>っ<alpha=#00>て<alpha=#00>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>お<alpha=#ff>い<alpha=#ff>、<alpha=#ff>泣<alpha=#ff>く<alpha=#ff>な<alpha=#ff>よ<alpha=#ff>。<alpha=#ff>さ<alpha=#ff>っ<alpha=#ff>き<alpha=#ff>言<alpha=#ff>っ<alpha=#ff>た<alpha=#eb>ろ<alpha=#00>、<alpha=#00>そ<alpha=#00>う<alpha=#00>い<alpha=#00>う<alpha=#00>の<alpha=#00>は<alpha=#00>ナ<alpha=#00>シ<alpha=#00>だ<alpha=#00>っ<alpha=#00>て<alpha=#00>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>お<alpha=#ff>い<alpha=#ff>、<alpha=#ff>泣<alpha=#ff>く<alpha=#ff>な<alpha=#ff>よ<alpha=#ff>。<alpha=#ff>さ<alpha=#ff>っ<alpha=#ff>き<alpha=#ff>言<alpha=#ff>っ<alpha=#ff>た<alpha=#ff>ろ<alpha=#ff>、<alpha=#ff>そ<alpha=#eb>う<alpha=#00>い<alpha=#00>う<alpha=#00>の<alpha=#00>は<alpha=#00>ナ<alpha=#00>シ<alpha=#00>だ<alpha=#00>っ<alpha=#00>て<alpha=#00>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>お<alpha=#ff>い<alpha=#ff>、<alpha=#ff>泣<alpha=#ff>く<alpha=#ff>な<alpha=#ff>よ<alpha=#ff>。<alpha=#ff>さ<alpha=#ff>っ<alpha=#ff>き<alpha=#ff>言<alpha=#ff>っ<alpha=#ff>た<alpha=#ff>ろ<alpha=#ff>、<alpha=#ff>そ<alpha=#ff>う<alpha=#ff>い<alpha=#ff>う<alpha=#eb>の<alpha=#00>は<alpha=#00>ナ<alpha=#00>シ<alpha=#00>だ<alpha=#00>っ<alpha=#00>て<alpha=#00>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>お<alpha=#ff>い<alpha=#ff>、<alpha=#ff>泣<alpha=#ff>く<alpha=#ff>な<alpha=#ff>よ<alpha=#ff>。<alpha=#ff>さ<alpha=#ff>っ<alpha=#ff>き<alpha=#ff>言<alpha=#ff>っ<alpha=#ff>た<alpha=#ff>ろ<alpha=#ff>、<alpha=#ff>そ<alpha=#ff>う<alpha=#ff>い<alpha=#ff>う<alpha=#ff>の<alpha=#ff>は<alpha=#ff>ナ<alpha=#eb>シ<alpha=#00>だ<alpha=#00>っ<alpha=#00>て<alpha=#00>」\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":"<color=#6e6e6e><alpha=#ff>「<alpha=#ff>で<alpha=#ff>も<alpha=#eb>…<alpha=#00>…<alpha=#00>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>で<alpha=#ff>も<alpha=#ff>…<alpha=#ff>…<alpha=#ff>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>で<alpha=#ff>も<alpha=#ff>…<alpha=#ff>…<alpha=#ff>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>で<alpha=#ff>も<alpha=#ff>…<alpha=#ff>…<alpha=#ff>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>で<alpha=#ff>も<alpha=#ff>…<alpha=#ff>…<alpha=#ff>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>で<alpha=#ff>も<alpha=#ff>…<alpha=#ff>…<alpha=#ff>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>で<alpha=#ff>も<alpha=#ff>…<alpha=#ff>…<alpha=#ff>」\n<color=#6e6e6e><alpha=#ff>「<alpha=#ff>で<alpha=#ff>も<alpha=#ff>…<alpha=#ff>…<alpha=#ff>」\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"}}
2 changes: 1 addition & 1 deletion validation/issue-468-higurashi.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading