@@ -2,7 +2,7 @@ import { CommitNotification, socketIO, wrap } from "../../deps/socket.ts";
2
2
import { getProjectId , getUserId } from "./id.ts" ;
3
3
import { applyCommit } from "./applyCommit.ts" ;
4
4
import { makeChanges } from "./makeChanges.ts" ;
5
- import { pull } from "./pull.ts" ;
5
+ import { HeadData , pull } from "./pull.ts" ;
6
6
import type { Line } from "../../deps/scrapbox.ts" ;
7
7
import { pushCommit } from "./_fetch.ts" ;
8
8
export type { CommitNotification } ;
@@ -15,7 +15,9 @@ export interface JoinPageRoomResult {
15
15
*
16
16
* @param update 書き換え後の本文を作成する函数。引数には現在の本文が渡される
17
17
*/
18
- patch : ( update : ( before : Line [ ] ) => string [ ] ) => Promise < void > ;
18
+ patch : (
19
+ update : ( before : Line [ ] , metadata ?: HeadData ) => string [ ] ,
20
+ ) => Promise < void > ;
19
21
/** ページの更新情報を購読する */
20
22
listenPageUpdate : ( ) => AsyncGenerator < CommitNotification , void , unknown > ;
21
23
/** ページの操作を終了する。これを呼び出すと他のmethodsは使えなくなる
@@ -62,10 +64,15 @@ export async function joinPageRoom(
62
64
} ) ( ) ;
63
65
64
66
return {
65
- patch : async ( update : ( before : Line [ ] ) => string [ ] | Promise < string [ ] > ) => {
67
+ patch : async (
68
+ update : (
69
+ before : Line [ ] ,
70
+ metadata ?: HeadData ,
71
+ ) => string [ ] | Promise < string [ ] > ,
72
+ ) => {
66
73
for ( let i = 0 ; i < 3 ; i ++ ) {
67
74
try {
68
- const pending = update ( head . lines ) ;
75
+ const pending = update ( head . lines , head ) ;
69
76
const newLines = pending instanceof Promise ? await pending : pending ;
70
77
const changes = makeChanges ( head . lines , newLines , {
71
78
userId,
0 commit comments