@lincyaw/workspace 1.0.0-rc.109 → 1.0.0-rc.110
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lincyaw/workspace",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.110",
|
|
4
4
|
"description": "Presmium's workspace service (presmium serve): documents, their history, reviews and the workspace site",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
"mime-types": "3.0.2",
|
|
35
35
|
"playwright-chromium": "1.64.1",
|
|
36
36
|
"yaml": "^2.9.1",
|
|
37
|
-
"@lincyaw/compiler": "1.0.0-rc.
|
|
38
|
-
"@lincyaw/
|
|
39
|
-
"@lincyaw/
|
|
40
|
-
"@lincyaw/kernel": "1.0.0-rc.
|
|
37
|
+
"@lincyaw/compiler": "1.0.0-rc.110",
|
|
38
|
+
"@lincyaw/design": "1.0.0-rc.110",
|
|
39
|
+
"@lincyaw/server": "1.0.0-rc.110",
|
|
40
|
+
"@lincyaw/kernel": "1.0.0-rc.110"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/mime-types": "^3.0.1",
|
|
44
|
-
"@lincyaw/mcp": "1.0.0-rc.
|
|
44
|
+
"@lincyaw/mcp": "1.0.0-rc.110"
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -18,6 +18,10 @@ const MAX_FILES = 2000
|
|
|
18
18
|
const HIDDEN_FROM_EDITOR = new Set(['node_modules', 'dist', '.git', '.presmium'])
|
|
19
19
|
const BINARY = /\.(?:png|jpe?g|gif|webp|avif|ico|bmp|pdf|wasm|zip|gz|tgz|bz2|xz|7z|woff2?|ttf|otf|eot|mp3|mp4|m4a|wav|ogg|oga|webm|mov|avi|mkv|bin|so|dylib|dll|exe|pyc|xlsx?|docx?|pptx?|parquet|npy|npz|pkl|db|sqlite)$/i
|
|
20
20
|
|
|
21
|
+
function validateSourceText(path: string, content: unknown): asserts content is string {
|
|
22
|
+
if (typeof content !== 'string' || BINARY.test(path) || content.includes('\0')) throw new RequestError(415, `${path} is not a text file`)
|
|
23
|
+
}
|
|
24
|
+
|
|
21
25
|
export function validateDocumentSource(path: string, content: string, before?: Uint8Array): void {
|
|
22
26
|
if (path !== DOCUMENT_ENTRY && !path.endsWith(`/${DOCUMENT_ENTRY}`)) return
|
|
23
27
|
let value: unknown
|
|
@@ -233,7 +237,7 @@ export class SourceEditor {
|
|
|
233
237
|
if (paths.has(change.path)) throw new RequestError(400, `a source path occurs twice: ${change.path}`)
|
|
234
238
|
paths.add(change.path)
|
|
235
239
|
if (change.path !== binaryPath) {
|
|
236
|
-
|
|
240
|
+
validateSourceText(change.path, change.content)
|
|
237
241
|
bytes += Buffer.byteLength(change.content, 'utf8')
|
|
238
242
|
}
|
|
239
243
|
return this.#documentHolding(change.path, known)
|
|
@@ -328,6 +332,7 @@ export class SourceEditor {
|
|
|
328
332
|
const conflict: Omit<ConflictAnswer, 'error'> = { conflict: { version: now, content: bytes.toString('utf8') } }
|
|
329
333
|
throw new RequestError(409, `${path} changed since it was opened`, conflict)
|
|
330
334
|
}
|
|
335
|
+
validateSourceText(path, content)
|
|
331
336
|
const written = Buffer.from(content, 'utf8')
|
|
332
337
|
validateDocumentSource(path, content, bytes)
|
|
333
338
|
if (written.byteLength > MAX_SOURCE) throw new RequestError(413, `the text is larger than the editor saves (${MAX_SOURCE} bytes)`)
|