(doc: WSSharedDoc, options: CallbackOptions)
| 10 | } |
| 11 | |
| 12 | const callbackHandler = (doc: WSSharedDoc, options: CallbackOptions) => { |
| 13 | const { action, timeout = 5000, objects = {} } = options |
| 14 | const room = doc.name |
| 15 | const dataToSend: Record<string, any> = { |
| 16 | room, |
| 17 | data: {}, |
| 18 | } |
| 19 | const sharedObjectList = Object.keys(objects) |
| 20 | sharedObjectList.forEach(sharedObjectName => { |
| 21 | const sharedObjectType = objects[sharedObjectName] |
| 22 | dataToSend.data[sharedObjectName] = { |
| 23 | type: sharedObjectType, |
| 24 | content: getContent(sharedObjectName, sharedObjectType, doc)?.toJSON() || {}, |
| 25 | } |
| 26 | }) |
| 27 | if (typeof action === 'function') { |
| 28 | action(dataToSend) |
| 29 | } else { |
| 30 | callbackRequest(action, timeout, dataToSend) |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | const callbackRequest = (url: URL, timeout: number, data: any) => { |
| 35 | data = JSON.stringify(data) |
no test coverage detected
searching dependent graphs…