mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 21:23:45 +01:00
* [editor-core] share the blob hash and the doc-vs-file rule The git blob hash and the rule that decides whether a file is a doc or a binary file both have to reach the same answer in every service that writes to history, so they move into overleaf-editor-core rather than being spelled out again on each side. blob_utils takes over lib/blob_string_length.js: hashing and the string-length rule answered two halves of the same question -- what history needs to know about content before it can store it -- and each carried the same warning about staying off index.js, which is bundled for the browser. One module states it once, and blobForFile joins them, describing content on disk as the blob it amounts to. The hashing functions are flat rather than a namespace of their own: in a module that also holds the string-length rule, a bare fromStream says nothing about what it makes. history-v1's blob store and recover_zip follow the module to its new name. file_type_detector holds the doc-vs-file rule, Node-only and deep-imported for the same reason. It takes textExtensions, editableFilenames and maxDocLength as configuration rather than reading settings: the limit is web's 2 MiB and not editor-core's own 3 MiB, and the surrogate check covers both halves of a pair where editor-core's covers the high half. buildSetContentOperations' test spelled the blob header out for itself, with the separator as a literal NUL byte, which had git reading the file as binary. It hashes through blobHashFromString now, so it does not spell the header at all. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * [editor-core] name the client a change came from on the origin itself `EditorOrigin` carried an `editorId` that only an editor change could have. What the id is for -- recognising a change again, so history does not apply a resend twice and the client does not apply its own change back -- is a property of the client that submitted it rather than of what it did, so it moves onto `Origin` as an optional `historyClientId` and `EditorOrigin` goes. - `Origin` takes `(kind, historyClientId)` and answers `getHistoryClientId()`; `dropHistoryClientId()` is what the chunk store uses to strip the id from all but a client's latest change, which now leaves the rest of the origin alone -- a restore that a client submitted stays a restore. - `toRaw` is built a layer at a time: the base writes the kind and the id, a subclass spreads that and adds the fields it owns. - The named kinds are their own schemas and discriminate on `kind`, so a payload claiming one is checked against that shape and the error says what it got wrong. The catch-all cannot join them -- its kind is any string -- so it sits alongside and is refined to refuse the named kinds, which it used to swallow: `{kind: 'restore'}` validated as a kind and nothing else, then read back as a restore that recorded nothing about what it restored. - `lib/origin/*.js` gains `// @ts-check`. Without it the annotations in there were decorative: the lazily required subclasses were `any`, so nothing handed to them was checked, and `fromRaw` narrows with `in` to drop the catch-all variant, which a kind check cannot. The callers that stamp the id -- real-time's handshake flag, web's applyChange body -- come with the rest of the branch. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * [editor-core] recognise a change a writer that is not an editor placed The counterpart of `isSameEditorChange` for writers that are not an editor client: an integration that commits a batch on a user's behalf has to recognise that batch coming back, because a lost response does not say whether the commit landed and resubmitting one that did applies its removes twice. It compares the same three fields, and for the same reason -- a rebase rewrites a change's operations but leaves its origin, authors and timestamp alone -- with the timestamp compared as a point in time rather than as a string, so that two spellings of the same instant cannot read as different changes. github-sync is the first caller, and comes with the rest of the branch. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * [editor-core] load an editable file's content, or say it has none Only an editable file has content: any other kind is bytes addressed by hash, and hollow data records the size of content it does not have. Both answer `getContent()` with null, so every caller that wants the content of a doc loaded it, checked the data's class, and reached for its own error when the check failed. `File#loadEager` does that once and answers the data that always has the content. `buildSetContentOperations` takes a `ReadWriteBlobStore` -- everything but looking a blob up by hash, which is all it takes to build operations over content -- so a caller holding a store that cannot answer `getBlob` can still use it. Its metadata argument is `FileMetadata` rather than `Object`, which is what the schema already says a file's metadata is. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * [editor-core] say that a pair of operations that do not fit is unprocessable compose and transform threw a bare Error when the two operations do not describe the same content. Everything that answers a client for these -- history-v1's import routes, the git-bridge push, project-history's resync -- decides on UnprocessableError, so a bare Error reached them as an internal failure: a 500, which reads as worth retrying, for a pair that fails the same way every time. A client that resubmits on a 500 resubmits forever. The guards that cannot be reached through the API keep their bare Error: a TextOperation composed with something that is not one, and the branch whose message says it should not happen. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * [history-v1] hash blobs with the rule editor-core holds storage/lib/blob_hash.js was a bluebird-era implementation of the same git blob hash editor-core holds, exported from the storage barrel and used across the storage layer, the api and the tests. All of it reads the shared rule now, and the test that existed only to check the copy is gone -- editor-core's suite covers the same non-ASCII case. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> GitOrigin-RevId: 5a0c1e9a06170a0164c01a26a7bb2d205726d531
122 lines
5.0 KiB
JavaScript
122 lines
5.0 KiB
JavaScript
const AddCommentOperation = require('./lib/operation/add_comment_operation')
|
|
const Author = require('./lib/author')
|
|
const AuthorList = require('./lib/author_list')
|
|
const Blob = require('./lib/blob')
|
|
const BlobStoreBase = require('./lib/blob_store_base')
|
|
const Change = require('./lib/change')
|
|
const ChangeRequest = require('./lib/change_request')
|
|
const ChangeNote = require('./lib/change_note')
|
|
const Chunk = require('./lib/chunk')
|
|
const ChunkResponse = require('./lib/chunk_response')
|
|
const Comment = require('./lib/comment')
|
|
const DeleteCommentOperation = require('./lib/operation/delete_comment_operation')
|
|
const File = require('./lib/file')
|
|
const FileMap = require('./lib/file_map')
|
|
const History = require('./lib/history')
|
|
const Label = require('./lib/label')
|
|
const AddFileOperation = require('./lib/operation/add_file_operation')
|
|
const MoveFileOperation = require('./lib/operation/move_file_operation')
|
|
const SetCommentStateOperation = require('./lib/operation/set_comment_state_operation')
|
|
const EditFileOperation = require('./lib/operation/edit_file_operation')
|
|
const EditNoOperation = require('./lib/operation/edit_no_operation')
|
|
const EditOperationTransformer = require('./lib/operation/edit_operation_transformer')
|
|
const SetFileMetadataOperation = require('./lib/operation/set_file_metadata_operation')
|
|
const NoOperation = require('./lib/operation/no_operation')
|
|
const Operation = require('./lib/operation')
|
|
const RestoreOrigin = require('./lib/origin/restore_origin')
|
|
const RestoreFileOrigin = require('./lib/origin/restore_file_origin')
|
|
const Origin = require('./lib/origin')
|
|
const { EDITOR_ORIGIN_KIND } = require('./lib/origin')
|
|
const OtClient = require('./lib/ot_client')
|
|
const rebaseChanges = require('./lib/rebase')
|
|
const {
|
|
editorChangeIdentity,
|
|
editorChangeIdentityOf,
|
|
isSameEditorChange,
|
|
isChangeFrom,
|
|
} = require('./lib/change_identity')
|
|
const TextOperation = require('./lib/operation/text_operation')
|
|
const EditOperation = require('./lib/operation/edit_operation')
|
|
const safePathname = require('./lib/safe_pathname')
|
|
const Snapshot = require('./lib/snapshot')
|
|
const {
|
|
DEFAULT_TEXT_EXTENSIONS,
|
|
DEFAULT_EDITABLE_FILENAMES,
|
|
} = require('./lib/text_file_defaults')
|
|
const util = require('./lib/util')
|
|
const V2DocVersions = require('./lib/v2_doc_versions')
|
|
const {
|
|
InsertOp,
|
|
RemoveOp,
|
|
RetainOp,
|
|
ScanOp,
|
|
} = require('./lib/operation/scan_op')
|
|
const TrackedChange = require('./lib/file_data/tracked_change')
|
|
const TrackedChangeList = require('./lib/file_data/tracked_change_list')
|
|
const TrackingProps = require('./lib/file_data/tracking_props')
|
|
const Range = require('./lib/range')
|
|
const CommentList = require('./lib/file_data/comment_list')
|
|
const LazyStringFileData = require('./lib/file_data/lazy_string_file_data')
|
|
const StringFileData = require('./lib/file_data/string_file_data')
|
|
const EditOperationBuilder = require('./lib/operation/edit_operation_builder')
|
|
const {
|
|
getDocUpdaterCompatibleRanges,
|
|
} = require('./lib/doc_updater_compatible_ranges')
|
|
|
|
exports.AddCommentOperation = AddCommentOperation
|
|
exports.Author = Author
|
|
exports.AuthorList = AuthorList
|
|
exports.Blob = Blob
|
|
exports.BlobStoreBase = BlobStoreBase
|
|
exports.Change = Change
|
|
exports.ChangeRequest = ChangeRequest
|
|
exports.ChangeNote = ChangeNote
|
|
exports.Chunk = Chunk
|
|
exports.ChunkResponse = ChunkResponse
|
|
exports.Comment = Comment
|
|
exports.DEFAULT_TEXT_EXTENSIONS = DEFAULT_TEXT_EXTENSIONS
|
|
exports.DEFAULT_EDITABLE_FILENAMES = DEFAULT_EDITABLE_FILENAMES
|
|
exports.DeleteCommentOperation = DeleteCommentOperation
|
|
exports.File = File
|
|
exports.FileMap = FileMap
|
|
exports.LazyStringFileData = LazyStringFileData
|
|
exports.StringFileData = StringFileData
|
|
exports.History = History
|
|
exports.Label = Label
|
|
exports.AddFileOperation = AddFileOperation
|
|
exports.MoveFileOperation = MoveFileOperation
|
|
exports.SetCommentStateOperation = SetCommentStateOperation
|
|
exports.EditFileOperation = EditFileOperation
|
|
exports.EditNoOperation = EditNoOperation
|
|
exports.EditOperationBuilder = EditOperationBuilder
|
|
exports.EditOperationTransformer = EditOperationTransformer
|
|
exports.SetFileMetadataOperation = SetFileMetadataOperation
|
|
exports.NoOperation = NoOperation
|
|
exports.Operation = Operation
|
|
exports.RestoreOrigin = RestoreOrigin
|
|
exports.RestoreFileOrigin = RestoreFileOrigin
|
|
exports.Origin = Origin
|
|
exports.EDITOR_ORIGIN_KIND = EDITOR_ORIGIN_KIND
|
|
exports.OtClient = OtClient
|
|
exports.rebaseChanges = rebaseChanges
|
|
exports.editorChangeIdentity = editorChangeIdentity
|
|
exports.editorChangeIdentityOf = editorChangeIdentityOf
|
|
exports.isSameEditorChange = isSameEditorChange
|
|
exports.isChangeFrom = isChangeFrom
|
|
exports.TextOperation = TextOperation
|
|
exports.EditOperation = EditOperation
|
|
exports.safePathname = safePathname
|
|
exports.Snapshot = Snapshot
|
|
exports.util = util
|
|
exports.V2DocVersions = V2DocVersions
|
|
exports.ScanOp = ScanOp
|
|
exports.InsertOp = InsertOp
|
|
exports.RetainOp = RetainOp
|
|
exports.RemoveOp = RemoveOp
|
|
exports.TrackedChangeList = TrackedChangeList
|
|
exports.TrackedChange = TrackedChange
|
|
exports.Range = Range
|
|
exports.CommentList = CommentList
|
|
exports.TrackingProps = TrackingProps
|
|
exports.getDocUpdaterCompatibleRanges = getDocUpdaterCompatibleRanges
|