mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 08:02:28 +00:00
* oom(01): A1-shared-readers — reintroduce #10179 subset Files: 18 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> * oom(02): A2-shared-image-media — reintroduce #10179 subset Files: 7 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> * oom(03): A3-shared-fs-listing — reintroduce #10179 subset Files: 21 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> * oom(04): A4-shared-remote-relay — reintroduce #10179 subset Files: 8 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> * oom(05): A5-shared-misc — reintroduce #10179 subset Files: 28 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> * oom(06): B-shared-wiring — reintroduce #10179 subset Files: 81 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> --------- Co-authored-by: Orca <help@stably.ai>
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { measureUtf8ByteLength } from './utf8-byte-limits'
|
|
|
|
export const SETUP_SCRIPT_IMPORT_FILE_MAX_BYTES = 256 * 1024
|
|
export const SETUP_SCRIPT_IMPORT_MAX_CODE_UNITS = 256 * 1024
|
|
export const SETUP_SCRIPT_IMPORT_MAX_FIELD_BYTES = 64 * 1024
|
|
export const SETUP_SCRIPT_IMPORT_MAX_FIELD_CODE_UNITS = 64 * 1024
|
|
export const SETUP_SCRIPT_IMPORT_MAX_COMMAND_PARTS = 256
|
|
export const SETUP_SCRIPT_IMPORT_MAX_CMUX_COMMANDS = 256
|
|
export const SETUP_SCRIPT_IMPORT_MAX_KEYWORDS = 64
|
|
export const SETUP_SCRIPT_IMPORT_MAX_UNSUPPORTED_FIELDS = 128
|
|
export const SETUP_SCRIPT_IMPORT_MAX_TOML_LINES = 4_096
|
|
|
|
export function isSetupScriptImportTextWithinLimit(content: string): boolean {
|
|
return isTextWithinLimits(
|
|
content,
|
|
SETUP_SCRIPT_IMPORT_FILE_MAX_BYTES,
|
|
SETUP_SCRIPT_IMPORT_MAX_CODE_UNITS
|
|
)
|
|
}
|
|
|
|
export function isSetupScriptImportFieldWithinLimit(value: string): boolean {
|
|
return isTextWithinLimits(
|
|
value,
|
|
SETUP_SCRIPT_IMPORT_MAX_FIELD_BYTES,
|
|
SETUP_SCRIPT_IMPORT_MAX_FIELD_CODE_UNITS
|
|
)
|
|
}
|
|
|
|
function isTextWithinLimits(value: string, maxBytes: number, maxCodeUnits: number): boolean {
|
|
return (
|
|
value.length <= maxCodeUnits &&
|
|
!measureUtf8ByteLength(value, { stopAfterBytes: maxBytes }).exceededLimit
|
|
)
|
|
}
|