@@ -2,7 +2,7 @@ import { CommitNotification, socketIO, wrap } from "../../deps/socket.ts";
22import { getProjectId , getUserId } from "./id.ts" ;
33import { applyCommit } from "./applyCommit.ts" ;
44import { makeChanges } from "./makeChanges.ts" ;
5- import { pull } from "./pull.ts" ;
5+ import { HeadData , pull } from "./pull.ts" ;
66import type { Line } from "../../deps/scrapbox.ts" ;
77import { pushCommit } from "./_fetch.ts" ;
88export type { CommitNotification } ;
@@ -15,7 +15,9 @@ export interface JoinPageRoomResult {
1515 *
1616 * @param update 書き換え後の本文を作成する函数。引数には現在の本文が渡される
1717 */
18- patch : ( update : ( before : Line [ ] ) => string [ ] ) => Promise < void > ;
18+ patch : (
19+ update : ( before : Line [ ] , metadata ?: HeadData ) => string [ ] ,
20+ ) => Promise < void > ;
1921 /** ページの更新情報を購読する */
2022 listenPageUpdate : ( ) => AsyncGenerator < CommitNotification , void , unknown > ;
2123 /** ページの操作を終了する。これを呼び出すと他のmethodsは使えなくなる
@@ -62,10 +64,15 @@ export async function joinPageRoom(
6264 } ) ( ) ;
6365
6466 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+ ) => {
6673 for ( let i = 0 ; i < 3 ; i ++ ) {
6774 try {
68- const pending = update ( head . lines ) ;
75+ const pending = update ( head . lines , head ) ;
6976 const newLines = pending instanceof Promise ? await pending : pending ;
7077 const changes = makeChanges ( head . lines , newLines , {
7178 userId,
0 commit comments