@ai-translate/apple 0.1.0

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["path","fs","path","fs"],"sources":["../src/files.ts","../src/xcstrings-model.ts","../src/xcstrings.ts","../src/strings-parser.ts","../src/strings.ts","../src/integration.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { promises as fs } from \"node:fs\";\nimport * as path from \"node:path\";\n\nconst pendingWrites = new Map<string, Promise<unknown>>();\n\n/** Serializes read/merge/write operations, including separate adapter instances. */\nexport async function withFileLock<T>(filePath: string, operation: () => Promise<T>): Promise<T> {\n const key = path.resolve(filePath);\n const previous = pendingWrites.get(key) ?? Promise.resolve();\n const current = previous.catch(() => undefined).then(operation);\n pendingWrites.set(key, current);\n try {\n return await current;\n } finally {\n if (pendingWrites.get(key) === current) {\n pendingWrites.delete(key);\n }\n }\n}\n\nexport async function readText(filePath: string): Promise<string | null> {\n try {\n return await fs.readFile(filePath, \"utf8\");\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n return null;\n }\n throw error;\n }\n}\n\nexport async function writeTextAtomic(filePath: string, contents: string | Uint8Array): Promise<void> {\n await fs.mkdir(path.dirname(filePath), { recursive: true });\n const temporaryPath = path.join(path.dirname(filePath), `.${path.basename(filePath)}.${randomUUID()}`);\n let mode: number | undefined;\n try {\n mode = (await fs.stat(filePath)).mode;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw error;\n }\n }\n let handle: fs.FileHandle | undefined;\n try {\n handle = await fs.open(temporaryPath, \"wx\", mode);\n await handle.writeFile(contents);\n // Creation masks the requested mode with umask. An existing localization\n // file must retain its permissions when the temporary file replaces it.\n if (mode !== undefined) {\n await handle.chmod(mode);\n }\n await handle.sync();\n await handle.close();\n handle = undefined;\n await fs.rename(temporaryPath, filePath);\n } finally {\n await handle?.close();\n await fs.rm(temporaryPath, { force: true });\n }\n}\n","import { addressToJsonPointer } from \"@ai-translate/core/address\";\nimport { digestValue } from \"@ai-translate/core/hash\";\nimport { plainMessageFormat } from \"@ai-translate/core/message-format\";\nimport { isPluralCategory, pluralCategoriesFor, sortPluralCategories } from \"@ai-translate/core/plural\";\nimport type { Entry, JsonObject, JsonValue } from \"@ai-translate/core/types\";\nimport { applePrintfMessageFormat } from \"@ai-translate/message-formats\";\n\nexport interface StringCatalog extends JsonObject {\n sourceLanguage: string;\n strings: JsonObject;\n version: string;\n}\n\nexport interface CatalogState {\n catalog: StringCatalog;\n /** Canonical source shapes, possibly expanded for one target locale. */\n sourceRoots: JsonObject;\n roots: JsonObject;\n originalValues: ReadonlyMap<string, string>;\n writeState?: \"new\";\n}\n\nexport function isObject(value: unknown): value is JsonObject {\n return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\nexport function own(object: JsonObject, key: string): JsonValue | undefined {\n return Object.hasOwn(object, key) ? object[key] : undefined;\n}\n\nexport function put(object: JsonObject, key: string, value: JsonValue): void {\n Object.defineProperty(object, key, { configurable: true, enumerable: true, value, writable: true });\n}\n\nfunction requireObject(value: unknown, location: string): JsonObject {\n if (!isObject(value)) {\n throw new Error(`Invalid String Catalog at ${location}: expected an object.`);\n }\n return value;\n}\n\nfunction validateNode(value: unknown, location: string, requireFallback: boolean, depth = 0): void {\n if (depth > 64) {\n throw new Error(`String Catalog localization nesting exceeds 64 levels at ${location}.`);\n }\n const node = requireObject(value, location);\n if (node.stringUnit === undefined && node.variations === undefined) {\n throw new Error(`Unsupported String Catalog localization at ${location}: expected stringUnit or variations.`);\n }\n if (node.stringUnit !== undefined) {\n const unit = requireObject(node.stringUnit, `${location}.stringUnit`);\n if (typeof unit.value !== \"string\" || typeof unit.state !== \"string\") {\n throw new Error(`Invalid String Catalog stringUnit at ${location}: value and state must be strings.`);\n }\n }\n if (node.variations !== undefined) {\n const variations = requireObject(node.variations, `${location}.variations`);\n if (Object.keys(variations).length === 0) {\n throw new Error(`Empty String Catalog variations at ${location}.`);\n }\n for (const [dimension, rawArms] of Object.entries(variations)) {\n if (dimension !== \"plural\" && dimension !== \"device\") {\n throw new Error(`Unsupported String Catalog variation \"${dimension}\" at ${location}.`);\n }\n const arms = requireObject(rawArms, `${location}.variations.${dimension}`);\n if (requireFallback && !Object.hasOwn(arms, \"other\")) {\n throw new Error(`String Catalog ${dimension} variation requires an other arm at ${location}.`);\n }\n for (const [arm, child] of Object.entries(arms)) {\n if (dimension === \"plural\" && !isPluralCategory(arm)) {\n throw new Error(`Invalid String Catalog plural category \"${arm}\" at ${location}.`);\n }\n validateNode(child, `${location}.variations.${dimension}.${arm}`, requireFallback, depth + 1);\n }\n }\n }\n if (node.substitutions !== undefined) {\n const substitutions = requireObject(node.substitutions, `${location}.substitutions`);\n for (const [name, rawSubstitution] of Object.entries(substitutions)) {\n const substitution = requireObject(rawSubstitution, `${location}.substitutions.${name}`);\n if (!Number.isSafeInteger(substitution.argNum) || (substitution.argNum as number) < 1 ||\n typeof substitution.formatSpecifier !== \"string\" || substitution.formatSpecifier.length === 0) {\n throw new Error(`Invalid String Catalog substitution \"${name}\" at ${location}: expected argNum and formatSpecifier.`);\n }\n validateNode(substitution, `${location}.substitutions.${name}`, requireFallback, depth + 1);\n }\n }\n}\n\nexport function parseCatalog(text: string, filePath: string, sourceLocale: string): StringCatalog {\n let parsed: unknown;\n try {\n parsed = JSON.parse(text.replace(/^\\uFEFF/u, \"\"));\n } catch (error) {\n throw new Error(`Invalid JSON in String Catalog ${filePath}.`, { cause: error });\n }\n const catalog = requireObject(parsed, filePath);\n // Current Xcode extraction emits 1.3. These minor versions retain the\n // localization tree validated below; preserve their version and metadata.\n if (typeof catalog.version !== \"string\" || ![\"1.0\", \"1.1\", \"1.2\", \"1.3\"].includes(catalog.version)) {\n throw new Error(`Unsupported String Catalog version in ${filePath}: expected \"1.0\", \"1.1\", \"1.2\", or \"1.3\".`);\n }\n if (catalog.sourceLanguage !== sourceLocale) {\n throw new Error(`String Catalog ${filePath} sourceLanguage must match sourceLocale \"${sourceLocale}\".`);\n }\n const strings = requireObject(catalog.strings, `${filePath}.strings`);\n for (const [key, rawString] of Object.entries(strings)) {\n const string = requireObject(rawString, `${filePath}.strings[${JSON.stringify(key)}]`);\n if (string.shouldTranslate !== undefined && typeof string.shouldTranslate !== \"boolean\") {\n throw new Error(`Invalid shouldTranslate for String Catalog key ${JSON.stringify(key)} in ${filePath}.`);\n }\n if (string.comment !== undefined && typeof string.comment !== \"string\") {\n throw new Error(`Invalid comment for String Catalog key ${JSON.stringify(key)} in ${filePath}.`);\n }\n if (string.localizations !== undefined) {\n const localizations = requireObject(string.localizations, `${filePath}.${key}.localizations`);\n for (const [locale, localization] of Object.entries(localizations)) {\n validateNode(localization, `${filePath}.${key}.localizations.${locale}`, locale === sourceLocale);\n }\n }\n }\n return catalog as StringCatalog;\n}\n\nexport function isTranslatable(key: string, string: JsonObject): boolean {\n return key.length > 0 && string.shouldTranslate !== false && string.extractionState !== \"stale\";\n}\n\nexport function localeRoots(catalog: StringCatalog, locale: string): JsonObject {\n return Object.fromEntries(Object.entries(catalog.strings).flatMap(([key, rawString]) => {\n const string = rawString as JsonObject;\n if (!isTranslatable(key, string)) {\n return [];\n }\n const localizations = string.localizations as JsonObject | undefined;\n const node = localizations === undefined ? undefined : own(localizations, locale);\n if (node !== undefined) {\n return [[key, structuredClone(node)]];\n }\n return locale === catalog.sourceLanguage\n ? [[key, { stringUnit: { state: \"translated\", value: key } }]]\n : [];\n }));\n}\n\nfunction fallbackNode(node: JsonObject): JsonObject {\n if (isObject(node.stringUnit)) {\n const fallback = structuredClone(node);\n delete fallback.variations;\n return fallback;\n }\n for (const arms of Object.values(isObject(node.variations) ? node.variations : {})) {\n if (isObject(arms) && isObject(arms.other)) {\n return fallbackNode(arms.other);\n }\n }\n throw new Error(\"String Catalog source variation requires a string fallback.\");\n}\n\nfunction assertSourceSubstitutions(source: JsonObject, target: JsonObject | undefined, location: string): void {\n const sourceBindings = isObject(source.substitutions) ? source.substitutions : {};\n const targetBindings = isObject(target?.substitutions) ? target.substitutions : {};\n for (const name of Object.keys(targetBindings)) {\n if (!Object.hasOwn(sourceBindings, name)) {\n throw new Error(`Unsupported target-only String Catalog substitution ${JSON.stringify(name)} at ${location}. Define the corresponding substitution in the source localization before translating; its fragment meaning cannot be derived safely from flat source text.`);\n }\n }\n}\n\nexport function expandNode(node: JsonObject, locale: string, target?: JsonObject, location = \"localization\"): JsonObject {\n assertSourceSubstitutions(node, target, `${location} (${locale})`);\n const expanded = structuredClone(node);\n const sourceVariations = isObject(node.variations) ? node.variations : {};\n const targetVariations = isObject(target?.variations) ? target.variations : {};\n const dimensions = [...new Set([...Object.keys(sourceVariations), ...Object.keys(targetVariations)])];\n if (dimensions.length > 0) {\n const variations: JsonObject = {};\n for (const dimension of dimensions) {\n const arms = (own(sourceVariations, dimension) ?? {}) as JsonObject;\n const targetArms = (own(targetVariations, dimension) ?? {}) as JsonObject;\n const present = [...new Set([...Object.keys(arms), ...Object.keys(targetArms), \"other\"])];\n const categories = dimension === \"plural\"\n ? sortPluralCategories([...new Set([...present, ...pluralCategoriesFor(locale)])])\n : present;\n const fallback = own(arms, \"other\") ?? fallbackNode(node);\n put(variations, dimension, Object.fromEntries(categories.map((category) => [\n category,\n expandNode((own(arms, category) ?? fallback) as JsonObject, locale, own(targetArms, category) as JsonObject | undefined,\n `${location}.variations.${dimension}.${category}`),\n ])));\n }\n expanded.variations = variations;\n // Xcode allows a locale to vary an otherwise plain source string, for\n // example shortening only its Apple Watch translation. The fallback\n // source text supplies those branches; translated text never becomes a\n // translation source.\n if (Object.keys(sourceVariations).length === 0 && target?.stringUnit === undefined) {\n delete expanded.stringUnit;\n }\n }\n if (isObject(node.substitutions)) {\n expanded.substitutions = Object.fromEntries(Object.entries(node.substitutions)\n .map(([name, substitution]) => [name, expandNode(substitution as JsonObject, locale,\n isObject(target?.substitutions) ? own(target.substitutions, name) as JsonObject | undefined : undefined,\n `${location}.substitutions.${name}`)]));\n }\n return expanded;\n}\n\nfunction substitutionBindings(node: JsonObject): JsonObject {\n return Object.fromEntries(Object.entries(isObject(node.substitutions) ? node.substitutions : {})\n .map(([name, substitution]) => {\n const binding = substitution as JsonObject;\n return [name, [binding.argNum ?? null, binding.formatSpecifier ?? null]];\n }));\n}\n\nfunction visitUnits(\n node: JsonObject,\n keys: readonly string[],\n visit: (unit: JsonObject, keys: readonly string[], bindings: JsonObject) => void,\n inheritedBindings: JsonObject = {},\n): void {\n const bindings = { ...inheritedBindings, ...substitutionBindings(node) };\n if (isObject(node.stringUnit)) {\n visit(node.stringUnit, [...keys, \"stringUnit\", \"value\"], bindings);\n }\n if (isObject(node.variations)) {\n for (const [dimension, arms] of Object.entries(node.variations)) {\n for (const [arm, child] of Object.entries(arms as JsonObject)) {\n visitUnits(child as JsonObject, [...keys, \"variations\", dimension, arm], visit, bindings);\n }\n }\n }\n if (isObject(node.substitutions)) {\n for (const [name, substitution] of Object.entries(node.substitutions)) {\n visitUnits(substitution as JsonObject, [...keys, \"substitutions\", name], visit, bindings);\n }\n }\n}\n\nexport function buildCatalogEntries(catalog: StringCatalog, roots: JsonObject, source: boolean, plainTextKeys?: ReadonlySet<string>): Entry[] {\n const entries: Entry[] = [];\n for (const [key, root] of Object.entries(roots)) {\n const string = own(catalog.strings, key) as JsonObject;\n const format = plainTextKeys?.has(key) === true ? plainMessageFormat : applePrintfMessageFormat;\n visitUnits(root as JsonObject, [key], (unit, keys, unitBindings) => {\n const bindings = JSON.stringify(Object.fromEntries(Object.entries(unitBindings).toSorted(([left], [right]) => left.localeCompare(right))));\n const address = keys.map((part) => ({ kind: \"key\" as const, key: part }));\n const notes = [`Apple string key: ${JSON.stringify(key)}`];\n if (typeof string.comment === \"string\" && string.comment.length > 0) {\n notes.push(string.comment);\n }\n if (bindings !== \"{}\") {\n notes.push(`Apple substitution arguments: ${bindings}.`);\n }\n const groupKeys = [...keys];\n let plural = false;\n for (let index = 1; index < keys.length; index += 1) {\n if (keys[index] === \"variations\") {\n const dimension = keys[index + 1];\n const arm = keys[index + 2];\n notes.push(`${dimension === \"plural\" ? \"Plural category\" : \"Device\"}: ${arm ?? \"\"}.`);\n if (dimension === \"plural\") {\n groupKeys[index + 2] = \"*\";\n plural = true;\n }\n index += 2;\n } else if (keys[index] === \"substitutions\") {\n notes.push(`Substitution: ${keys[index + 1] ?? \"\"}.`);\n index += 1;\n }\n }\n const value = source || unit.state === \"translated\" ? unit.value as string : null;\n entries.push({\n address,\n context: { notes: notes.join(\"\\n\") },\n messageFormatId: format.id,\n meta: {\n appleSubstitutionBindings: bindings,\n ...(typeof string.comment === \"string\" ? { comment: string.comment } : {}),\n ...(bindings === \"{}\" ? {} : { structureSignature: bindings }),\n ...(plural ? { structureGroup: addressToJsonPointer(groupKeys.map((part) => ({ kind: \"key\", key: part }))) } : {}),\n },\n policy: \"translate\",\n storage: \"string\",\n ...(value === null ? {} : { tokens: [...format.tokenize(value)] }),\n value,\n });\n });\n }\n return entries;\n}\n\nexport function structureDigest(entries: readonly Entry[]): string {\n return digestValue(JSON.stringify([...new Set(entries.map((entry) =>\n entry.meta?.structureGroup ?? addressToJsonPointer(entry.address)))].toSorted((left, right) => String(left).localeCompare(String(right)))));\n}\n\nexport function entryValues(entries: readonly Entry[]): ReadonlyMap<string, string> {\n return new Map(entries.flatMap((entry) => typeof entry.value === \"string\"\n ? [[addressToJsonPointer(entry.address), entry.value]] : []));\n}\n\nexport function pendingNode(node: JsonObject): JsonObject {\n const pending = structuredClone(node);\n visitUnits(pending, [], (unit) => { unit.state = \"new\"; });\n return pending;\n}\n\nfunction assertUnchanged(current: JsonValue | undefined, original: JsonValue | undefined): void {\n if (JSON.stringify(current) !== JSON.stringify(original)) {\n throw new Error(\"String Catalog translation structure changed before writing.\");\n }\n}\n\n/** Keep target metadata, but replace structural fields removed by the source. */\nexport function alignNode(node: JsonObject, template: JsonObject, original: JsonObject = {}): void {\n assertSourceSubstitutions(template, node, \"target localization\");\n for (const field of [\"stringUnit\", \"variations\", \"substitutions\"]) {\n if (template[field] === undefined && node[field] !== undefined) {\n assertUnchanged(node[field], original[field]);\n delete node[field];\n }\n }\n if (template.argNum !== undefined) {\n for (const field of [\"argNum\", \"formatSpecifier\"]) {\n if (node[field] !== template[field]) {\n assertUnchanged(node[field], original[field]);\n }\n }\n node.argNum = template.argNum;\n node.formatSpecifier = template.formatSpecifier as string;\n }\n for (const field of [\"variations\", \"substitutions\"]) {\n if (!isObject(template[field]) || !isObject(node[field])) {\n continue;\n }\n const target = node[field];\n const source = template[field];\n const previous = isObject(original[field]) ? original[field] : {};\n for (const [name, child] of Object.entries(target)) {\n const sourceChild = own(source, name);\n if (!isObject(sourceChild)) {\n assertUnchanged(child, own(previous, name));\n delete target[name];\n } else if (isObject(child)) {\n const originalChild = own(previous, name);\n const previousChild = isObject(originalChild) ? originalChild : {};\n if (field === \"substitutions\") {\n alignNode(child, sourceChild, previousChild);\n } else {\n for (const [arm, armNode] of Object.entries(child)) {\n const sourceArm = own(sourceChild, arm);\n const originalArm = own(previousChild, arm);\n if (isObject(armNode) && isObject(sourceArm)) {\n alignNode(armNode, sourceArm, isObject(originalArm) ? originalArm : {});\n }\n }\n }\n }\n }\n }\n}\n\n/** Sets one leaf without copying untranslated siblings from the source shape. */\nexport function setUnit(root: JsonObject, template: JsonObject, keys: readonly string[], value: string, state: string): void {\n if (keys.length < 3 || keys.at(-2) !== \"stringUnit\" || keys.at(-1) !== \"value\") {\n throw new Error(`Invalid String Catalog entry address ${JSON.stringify(keys)}.`);\n }\n let node = root;\n let source = template;\n for (const key of keys.slice(0, -2)) {\n const sourceChild = own(source, key);\n if (!isObject(sourceChild)) {\n throw new Error(`Cannot write unknown String Catalog entry ${JSON.stringify(keys)}.`);\n }\n const existing = own(node, key);\n if (!isObject(existing)) {\n // A new plural/device node needs its fallback arms to remain compilable.\n // Those seeded siblings stay `new`, so a scoped write never accepts them\n // as translations. Other top-level keys remain completely absent.\n put(node, key, sourceChild.stringUnit !== undefined || sourceChild.variations !== undefined\n ? pendingNode(sourceChild) : {});\n }\n node = own(node, key) as JsonObject;\n source = sourceChild;\n }\n const sourceUnit = source.stringUnit;\n if (!isObject(sourceUnit)) {\n throw new Error(`Cannot write unknown String Catalog stringUnit ${JSON.stringify(keys)}.`);\n }\n node.stringUnit = { ...sourceUnit, ...(isObject(node.stringUnit) ? node.stringUnit : {}), state, value };\n}\n","import * as path from \"node:path\";\nimport { globby } from \"globby\";\n\nimport { addressToJsonPointer } from \"@ai-translate/core/address\";\nimport type { CatalogAdapter, DocumentRef, JsonObject, LoadedDocument } from \"@ai-translate/core/types\";\nimport { applePrintfMessageFormat } from \"@ai-translate/message-formats\";\n\nimport { readText, withFileLock, writeTextAtomic } from \"./files\";\nimport {\n alignNode, buildCatalogEntries, entryValues, expandNode, isObject, isTranslatable, localeRoots,\n own, parseCatalog, put, setUnit, structureDigest,\n} from \"./xcstrings-model\";\nimport type { CatalogState, StringCatalog } from \"./xcstrings-model\";\n\nexport interface AppleStringCatalogOptions {\n id?: string;\n /** Glob patterns relative to rootDir. Defaults to all authored .xcstrings. */\n include?: readonly string[];\n /** Exact catalog keys whose percent signs are literal text, not runtime printf arguments. */\n plainTextKeys?: readonly string[];\n rootDir: string;\n /** Must match each catalog's sourceLanguage exactly. */\n sourceLocale: string;\n}\n\nconst IGNORE = [\n \"**/node_modules/**\", \"**/.git/**\", \"**/.build/**\", \"**/build/**\", \"**/DerivedData/**\",\n \"**/Pods/**\", \"**/Carthage/**\", \"**/release/**\", \"**/dist/**\", \"**/.expo/**\",\n \"**/.next/**\", \"**/.turbo/**\", \"**/coverage/**\", \"**/*.xcarchive/**\",\n];\n\nfunction loadedDocument(ref: DocumentRef, state: CatalogState, source: boolean, plainTextKeys: ReadonlySet<string>): LoadedDocument<CatalogState> {\n const entries = buildCatalogEntries(state.catalog, state.roots, source, plainTextKeys);\n return { entries, ref, state, structureDigest: structureDigest(entries) };\n}\n\nfunction localizedRoots(sourceRoots: JsonObject, locale: string, targetRoots: JsonObject = {}): JsonObject {\n return Object.fromEntries(Object.entries(sourceRoots)\n .map(([key, node]) => [key, expandNode(node as JsonObject, locale, own(targetRoots, key) as JsonObject | undefined,\n `key ${JSON.stringify(key)}`)]));\n}\n\nfunction unitAt(roots: JsonObject, keys: readonly string[]): unknown {\n let node: unknown = roots;\n for (const key of keys.slice(0, -1)) {\n node = isObject(node) ? own(node, key) : undefined;\n }\n return node;\n}\n\n/** Native Xcode catalogs: one physical file, independently reconciled locales. */\nexport function createAppleStringCatalog(options: AppleStringCatalogOptions): CatalogAdapter {\n const rootDir = path.resolve(options.rootDir);\n const id = options.id ?? \"apple-xcstrings\";\n const plainTextKeys = new Set(options.plainTextKeys);\n\n function refFor(filePath: string, locale: string, unitId?: string): DocumentRef {\n return {\n catalogId: id,\n format: \"xcstrings\",\n locale,\n path: filePath,\n unitId: unitId ?? path.relative(rootDir, filePath).split(path.sep).join(\"/\").replace(/\\.xcstrings$/u, \"\"),\n };\n }\n\n async function readCatalog(filePath: string): Promise<StringCatalog | null> {\n const text = await readText(filePath);\n return text === null ? null : parseCatalog(text, filePath, options.sourceLocale);\n }\n\n const adapter: CatalogAdapter = {\n id,\n messageFormats: [applePrintfMessageFormat],\n createDocumentRef(sourceRef, locale) {\n return refFor(sourceRef.path, locale, sourceRef.unitId);\n },\n async listDocumentRefs(locale) {\n const files = await globby([...(options.include ?? [\"**/*.xcstrings\"])], {\n absolute: true, cwd: rootDir, followSymbolicLinks: false, ignore: IGNORE, onlyFiles: true,\n });\n return files.toSorted().map((filePath) => refFor(filePath, locale));\n },\n async loadDocument(ref) {\n const catalog = await readCatalog(ref.path);\n if (catalog === null) {\n return null;\n }\n const canonicalRoots = localeRoots(catalog, options.sourceLocale);\n const sourceRoots = ref.locale === options.sourceLocale\n ? canonicalRoots : localizedRoots(canonicalRoots, ref.locale, localeRoots(catalog, ref.locale));\n const roots = ref.locale === options.sourceLocale ? sourceRoots : localeRoots(catalog, ref.locale);\n if (ref.locale !== options.sourceLocale && Object.keys(roots).length === 0 &&\n Object.keys(canonicalRoots).length > 0) {\n return null;\n }\n const entries = buildCatalogEntries(catalog, roots, ref.locale === options.sourceLocale, plainTextKeys);\n return loadedDocument(ref, { catalog, originalValues: entryValues(entries), roots, sourceRoots }, ref.locale === options.sourceLocale, plainTextKeys);\n },\n localizeSourceDocument({ locale, source }) {\n const sourceState = source.state as CatalogState;\n const roots = localizedRoots(sourceState.sourceRoots, locale, localeRoots(sourceState.catalog, locale));\n return Promise.resolve(loadedDocument(source.ref, { ...sourceState, roots, sourceRoots: roots }, true, plainTextKeys));\n },\n reconcileDocument({ ref, source, target }) {\n const sourceState = source.state as CatalogState;\n const targetState = target?.state as CatalogState | undefined;\n const targetEntries = new Map(target?.entries.map((entry) => [addressToJsonPointer(entry.address), entry]));\n const values = entryValues(source.entries.flatMap((entry) => {\n const existing = targetEntries.get(addressToJsonPointer(entry.address));\n return existing?.meta?.structureSignature === entry.meta?.structureSignature && existing !== undefined ? [existing] : [];\n }));\n const entries = source.entries.map((entry) => ({\n ...entry,\n value: values.get(addressToJsonPointer(entry.address)) ?? null,\n }));\n return Promise.resolve({\n entries,\n ref,\n state: {\n catalog: sourceState.catalog,\n originalValues: values,\n roots: targetState?.roots ?? {},\n sourceRoots: sourceState.sourceRoots,\n } satisfies CatalogState,\n structureDigest: structureDigest(entries),\n });\n },\n createScaffoldDocument({ ref, source }) {\n if (source.entries.length === 0) {\n return Promise.resolve(null);\n }\n const sourceState = source.state as CatalogState;\n const roots = localizedRoots(sourceState.roots, ref.locale);\n return Promise.resolve(loadedDocument(ref, {\n catalog: sourceState.catalog, originalValues: new Map(), roots, sourceRoots: roots, writeState: \"new\",\n }, true, plainTextKeys));\n },\n async scaffoldLocale(scaffoldOptions) {\n const strategy = scaffoldOptions.strategy ?? \"copy-source\";\n const refs = await adapter.listDocumentRefs(options.sourceLocale);\n let createdDocuments = 0;\n let skippedDocuments = 0;\n const fromLocale = strategy === \"copy-source\" ? options.sourceLocale : scaffoldOptions.fromLocale ?? options.sourceLocale;\n for (const sourceRef of refs) {\n const targetRef = adapter.createDocumentRef(sourceRef, scaffoldOptions.locale);\n if (strategy === \"empty\" || await adapter.loadDocument(targetRef) !== null) {\n skippedDocuments += 1;\n continue;\n }\n const source = await adapter.loadDocument(adapter.createDocumentRef(sourceRef, fromLocale));\n if (source === null || source.entries.length === 0) {\n skippedDocuments += 1;\n continue;\n }\n const document = await adapter.createScaffoldDocument?.({ ref: targetRef, source, strategy });\n if (document !== undefined && document !== null) {\n await adapter.writeDocument(document);\n createdDocuments += 1;\n }\n }\n return { catalogId: id, createdDocuments, locale: scaffoldOptions.locale, skippedDocuments, strategy };\n },\n async writeDocument(document) {\n if (document.ref.locale === options.sourceLocale) {\n throw new Error(`Refusing to write the source locale \"${options.sourceLocale}\" in a String Catalog.`);\n }\n const state = document.state as CatalogState;\n const changed = document.entries.filter((entry) => typeof entry.value === \"string\" &&\n (state.writeState !== undefined || entry.value !== state.originalValues.get(addressToJsonPointer(entry.address))));\n if (changed.length === 0) {\n return;\n }\n await withFileLock(document.ref.path, async () => {\n const text = await readText(document.ref.path);\n if (text === null) {\n throw new Error(`String Catalog disappeared before writing: ${document.ref.path}.`);\n }\n const catalog = parseCatalog(text, document.ref.path, options.sourceLocale);\n const targetRoots = localeRoots(catalog, document.ref.locale);\n const originalTargets = structuredClone(targetRoots);\n const existingKeys = new Set(Object.keys(targetRoots));\n const originalSources = localeRoots(state.catalog, options.sourceLocale);\n const currentSources = localeRoots(catalog, options.sourceLocale);\n const aligned = new Set<string>();\n let wrote = false;\n for (const entry of changed) {\n const keys = entry.address.map((segment) => {\n if (segment.kind !== \"key\") {\n throw new Error(\"String Catalog addresses must contain only object keys.\");\n }\n return segment.key;\n });\n const key = keys[0];\n const string = key === undefined ? undefined : own(catalog.strings, key);\n if (key === undefined || !isObject(string) || !isTranslatable(key, string)) {\n throw new Error(`String Catalog source key changed before writing ${JSON.stringify(key)}.`);\n }\n if (state.writeState !== undefined && existingKeys.has(key)) {\n continue;\n }\n if (JSON.stringify(own(originalSources, key)) !== JSON.stringify(own(currentSources, key))) {\n throw new Error(`String Catalog source changed before writing ${JSON.stringify(key)}.`);\n }\n if (!aligned.has(key)) {\n const node = own(targetRoots, key);\n const template = own(state.sourceRoots, key);\n if (isObject(node) && isObject(template)) {\n const original = own(state.roots, key);\n alignNode(node, template, isObject(original) ? original : {});\n }\n aligned.add(key);\n }\n const currentUnit = unitAt(originalTargets, keys);\n if (state.writeState === undefined && JSON.stringify(currentUnit) !== JSON.stringify(unitAt(state.roots, keys)) &&\n (!isObject(currentUnit) || currentUnit.value !== entry.value)) {\n throw new Error(`String Catalog translation changed before writing ${JSON.stringify(keys)}.`);\n }\n setUnit(targetRoots, state.sourceRoots, keys, entry.value as string, state.writeState ?? \"translated\");\n wrote = true;\n }\n if (!wrote) {\n return;\n }\n for (const [key, target] of Object.entries(targetRoots)) {\n const string = own(catalog.strings, key) as JsonObject;\n if (!isObject(string.localizations)) {\n string.localizations = {};\n }\n put(string.localizations, document.ref.locale, target);\n }\n const next = `${text.startsWith(\"\\uFEFF\") ? \"\\uFEFF\" : \"\"}${JSON.stringify(catalog, null, 2)}\\n`;\n if (next !== text) {\n await writeTextAtomic(document.ref.path, next);\n }\n });\n },\n };\n return adapter;\n}\n","export interface StringsRecord {\n comment: string;\n end: number;\n implicitValue?: true;\n key: string;\n start: number;\n value: string;\n valueEnd: number;\n valueStart: number;\n}\n\nexport interface StringsTable {\n /** In wrapped tables, insert records before the closing brace and its trivia. */\n insertionPoint?: number;\n records: StringsRecord[];\n text: string;\n}\n\nconst ESCAPES: Readonly<Record<string, string>> = {\n a: \"\\x07\",\n b: \"\\b\",\n f: \"\\f\",\n n: \"\\n\",\n r: \"\\r\",\n t: \"\\t\",\n v: \"\\v\",\n '\"': '\"',\n \"'\": \"'\",\n \"\\\\\": \"\\\\\",\n \"?\": \"?\",\n};\n\n// OpenStep octal escapes encode a NEXTSTEP byte, not a Unicode code point.\n// The last two byte values are undefined in this encoding.\nconst NEXTSTEP_HIGH =\n \"\\u00a0ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝÞµ×÷\" +\n \"©¡¢£⁄¥ƒ§¤’“«‹›fifl®–†‡·¦¶•‚„”»…‰¬¿\" +\n \"¹ˋ´ˆ˜¯˘˙¨²˚¸³˝˛ˇ—±¼½¾àáâãäåçèéêë\" +\n \"ìÆíªîïðñŁØŒºòóôõöæùúûıüýłøœßþÿ\";\n\n/** Parse Apple's textual property-list syntax while retaining source spans. */\nexport function parseStrings(text: string, label = \".strings\"): StringsTable {\n const records: StringsRecord[] = [];\n const keys = new Set<string>();\n let position = 0;\n\n function fail(message: string): never {\n const line = text.slice(0, position).split(/\\r\\n|[\\r\\n]/u).length;\n throw new Error(`${label}:${String(line)}: ${message}`);\n }\n\n function trivia(): string {\n const comments: string[] = [];\n while (position < text.length) {\n if (/[ \\t\\r\\n\\f\\v\\u2028\\u2029]/u.test(text[position] ?? \"\")) {\n position += 1;\n } else if (text.startsWith(\"//\", position)) {\n const end = /[\\r\\n\\u2028\\u2029]/u.exec(text.slice(position + 2));\n const next = end === null ? text.length : position + 2 + end.index;\n comments.push(text.slice(position + 2, next).trim());\n position = next;\n } else if (text.startsWith(\"/*\", position)) {\n const end = text.indexOf(\"*/\", position + 2);\n if (end < 0) {\n fail(\"Unterminated comment.\");\n }\n comments.push(text.slice(position + 2, end).trim());\n position = end + 2;\n } else {\n break;\n }\n }\n return comments.filter(Boolean).join(\"\\n\");\n }\n\n function string(): string {\n const quote = text[position];\n if (quote !== '\"' && quote !== \"'\") {\n const bare = /^[A-Za-z0-9_.$/:-]+/u.exec(text.slice(position));\n if (bare === null) {\n fail(\"Expected a quoted string or property-list identifier.\");\n }\n position += bare[0].length;\n return bare[0];\n }\n position += 1;\n let value = \"\";\n while (position < text.length) {\n const character = text[position++];\n if (character === quote) {\n return value;\n }\n if (character !== \"\\\\\") {\n value += character;\n continue;\n }\n const escaped = text[position++];\n if (escaped === undefined) {\n fail(\"Unterminated escape sequence.\");\n }\n if (escaped === \"U\") {\n const hexadecimal = /^[\\da-fA-F]{1,4}/u.exec(text.slice(position))?.[0];\n if (hexadecimal === undefined) {\n fail(\"Expected hexadecimal digits after a Unicode escape.\");\n }\n value += String.fromCharCode(Number.parseInt(hexadecimal, 16));\n position += hexadecimal.length;\n } else if (/[0-7]/u.test(escaped)) {\n const suffix = /^[0-7]{0,2}/u.exec(text.slice(position))?.[0] ?? \"\";\n const byte = Number.parseInt(escaped + suffix, 8) % 256;\n if (byte >= 254) {\n fail(\"Undefined NEXTSTEP octal escape.\");\n }\n value += byte < 128 ? String.fromCharCode(byte) : NEXTSTEP_HIGH[byte - 128];\n position += suffix.length;\n } else {\n // Foundation drops the backslash on other escapes, including lowercase\n // \\\\u and escaped line endings. Do not apply JSON or C continuation rules.\n value += ESCAPES[escaped] ?? escaped;\n }\n }\n return fail(\"Unterminated quoted string.\");\n }\n\n const heading = trivia();\n const wrapped = text[position] === \"{\";\n if (wrapped) {\n position += 1;\n } else {\n position = 0;\n }\n let insertionPoint: number | undefined;\n while (position < text.length) {\n const start = position;\n const comment = [wrapped && records.length === 0 ? heading : \"\", trivia()]\n .filter(Boolean).join(\"\\n\");\n if (wrapped && text[position] === \"}\") {\n insertionPoint = start;\n position += 1;\n trivia();\n if (position !== text.length) {\n fail(\"Unexpected content after the closing dictionary brace.\");\n }\n break;\n }\n if (position === text.length) {\n break;\n }\n const key = string();\n if (keys.has(key)) {\n fail(`Duplicate key ${JSON.stringify(key)}.`);\n }\n keys.add(key);\n const keyEnd = position;\n trivia();\n const implicitValue = text[position] === \";\";\n let valueStart = keyEnd;\n let valueEnd = keyEnd;\n let value = key;\n if (!implicitValue) {\n if (text[position++] !== \"=\") {\n fail(\"Expected '=' or ';' after key.\");\n }\n trivia();\n valueStart = position;\n value = string();\n valueEnd = position;\n trivia();\n }\n if (text[position++] !== \";\") {\n fail(\"Expected ';' after value.\");\n }\n records.push({\n comment,\n end: position,\n ...(implicitValue ? { implicitValue: true } : {}),\n key,\n start,\n value,\n valueEnd,\n valueStart,\n });\n }\n if (wrapped && insertionPoint === undefined) {\n fail(\"Expected '}' after dictionary entries.\");\n }\n return { ...(insertionPoint === undefined ? {} : { insertionPoint }), records, text };\n}\n\nexport function quoteStrings(value: string): string {\n // Property-list strings require control characters to be escaped.\n // eslint-disable-next-line no-control-regex\n return `\"${value.replace(/[\"\\\\\\x00-\\x1f\\x7f]/gu, (character) => {\n if (character === '\"' || character === \"\\\\\") {\n return `\\\\${character}`;\n }\n const named: Readonly<Record<string, string>> = { \"\\n\": \"n\", \"\\r\": \"r\", \"\\t\": \"t\" };\n const escape = named[character];\n return escape === undefined\n ? `\\\\U${character.charCodeAt(0).toString(16).padStart(4, \"0\")}`\n : `\\\\${escape}`;\n })}\"`;\n}\n\n/** Replace only value spans, preserving comments, whitespace, and unknown keys. */\nexport function renderStrings(\n table: StringsTable,\n values: ReadonlyMap<string, string>,\n templates: StringsTable,\n): string {\n const insertionPoint = table.insertionPoint ?? table.text.length;\n let text = table.text.slice(0, insertionPoint);\n const suffix = table.text.slice(insertionPoint);\n const replacement = (record: StringsRecord, value: string): string =>\n record.implicitValue === true\n ? value === record.value ? \"\" : ` = ${quoteStrings(value)}`\n : quoteStrings(value);\n const known = new Set(table.records.map((record) => record.key));\n for (const record of table.records.toReversed()) {\n const value = values.get(record.key);\n if (value !== undefined && value !== record.value) {\n text = text.slice(0, record.valueStart) + replacement(record, value) + text.slice(record.valueEnd);\n }\n }\n const source = new Map(templates.records.map((record) => [record.key, record]));\n for (const [key, value] of values) {\n if (known.has(key)) {\n continue;\n }\n const record = source.get(key);\n const addition =\n record === undefined\n ? `${quoteStrings(key)} = ${quoteStrings(value)};`\n : templates.text.slice(record.start, record.valueStart) +\n replacement(record, value) +\n templates.text.slice(record.valueEnd, record.end);\n text += `${text.length > 0 && !text.endsWith(\"\\n\") ? \"\\n\" : \"\"}${addition.startsWith(\"\\n\") || text.length === 0 ? \"\" : \"\\n\"}${addition}\\n`;\n }\n return text + suffix;\n}\n\nexport type StringsEncoding = \"utf8\" | \"utf8-bom\" | \"utf16le\" | \"utf16be\";\n\nexport function decodeStrings(buffer: Uint8Array): { encoding: StringsEncoding; text: string } {\n const encoding: StringsEncoding =\n buffer[0] === 0xff && buffer[1] === 0xfe\n ? \"utf16le\"\n : buffer[0] === 0xfe && buffer[1] === 0xff\n ? \"utf16be\"\n : buffer[0] === 0xef && buffer[1] === 0xbb && buffer[2] === 0xbf\n ? \"utf8-bom\"\n : \"utf8\";\n const label = encoding === \"utf16le\" ? \"utf-16le\" : encoding === \"utf16be\" ? \"utf-16be\" : \"utf-8\";\n return { encoding, text: new TextDecoder(label, { fatal: true }).decode(buffer) };\n}\n\nexport function encodeStrings(text: string, encoding: StringsEncoding): Uint8Array {\n if (encoding === \"utf8\") {\n return Buffer.from(text, \"utf8\");\n }\n if (encoding === \"utf8-bom\") {\n return Buffer.concat([Buffer.from([0xef, 0xbb, 0xbf]), Buffer.from(text, \"utf8\")]);\n }\n const body = Buffer.from(text, \"utf16le\");\n if (encoding === \"utf16be\") {\n body.swap16();\n }\n return Buffer.concat([Buffer.from(encoding === \"utf16le\" ? [0xff, 0xfe] : [0xfe, 0xff]), body]);\n}\n","import { promises as fs } from \"node:fs\";\nimport path from \"node:path\";\n\nimport { digestValue } from \"@ai-translate/core/hash\";\nimport { plainMessageFormat } from \"@ai-translate/core/message-format\";\nimport type { CatalogAdapter, DocumentRef, Entry, LoadedDocument } from \"@ai-translate/core/types\";\nimport { applePrintfMessageFormat } from \"@ai-translate/message-formats\";\nimport { globby } from \"globby\";\n\nimport { withFileLock, writeTextAtomic } from \"./files\";\nimport { decodeStrings, encodeStrings, parseStrings, renderStrings } from \"./strings-parser\";\nimport type { StringsEncoding, StringsRecord, StringsTable } from \"./strings-parser\";\n\nexport interface AppleStringsCatalogOptions {\n id?: string;\n /** Glob(s) relative to the source locale directory; all nested tables by default. */\n include?: string | readonly string[];\n /** Exact keys whose percent signs are literal text, not runtime printf arguments. */\n plainTextKeys?: readonly string[];\n rootDir: string;\n sourceLocale: string;\n /** For projects whose source files are in Base.lproj. Defaults to <locale>.lproj. */\n sourceLocaleDirectory?: string;\n}\n\ninterface StringsState {\n encoding: StringsEncoding;\n scaffold?: true;\n table: StringsTable;\n templates: StringsTable;\n}\n\nfunction segment(value: string, name: string): string {\n if (!/^[A-Za-z0-9][A-Za-z0-9_.-]*$/u.test(value) || value === \".\" || value === \"..\") {\n throw new Error(`Invalid ${name}: ${JSON.stringify(value)}.`);\n }\n return value;\n}\n\nfunction unit(value: string): string {\n if (\n path.isAbsolute(value) ||\n value.includes(\"\\\\\") ||\n value.split(\"/\").some((part) => part === \"..\" || part === \".\" || part === \"\") ||\n !value.endsWith(\".strings\")\n ) {\n throw new Error(`Invalid Apple strings unit: ${JSON.stringify(value)}.`);\n }\n return value;\n}\n\nasync function readTable(\n filePath: string,\n): Promise<(StringsTable & { encoding: StringsEncoding }) | null> {\n try {\n const decoded = decodeStrings(await fs.readFile(filePath));\n return { ...parseStrings(decoded.text, filePath), encoding: decoded.encoding };\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n return null;\n }\n throw error;\n }\n}\n\nfunction entry(record: StringsRecord, value: string | null, plainTextKeys: ReadonlySet<string>): Entry {\n const format = plainTextKeys.has(record.key) ? plainMessageFormat : applePrintfMessageFormat;\n return {\n address: [{ kind: \"key\", key: record.key }],\n ...(record.comment.length === 0 ? {} : { context: { notes: record.comment } }),\n messageFormatId: format.id,\n policy: \"translate\",\n storage: \"string\",\n tokens: value === null ? [] : [...format.tokenize(value)],\n value,\n };\n}\n\nfunction document(\n ref: DocumentRef,\n state: StringsState,\n entries: Entry[],\n): LoadedDocument<StringsState> {\n return {\n entries,\n ref,\n state,\n structureDigest: digestValue(JSON.stringify(entries.map((item) => item.address))),\n };\n}\n\n/** Translate .lproj tables without replacing comments or unrelated translations. */\nexport function createAppleStringsCatalog(options: AppleStringsCatalogOptions): CatalogAdapter {\n const id = options.id ?? \"apple-strings\";\n const root = path.resolve(options.rootDir);\n const plainTextKeys = new Set(options.plainTextKeys);\n segment(options.sourceLocale, \"source locale\");\n const sourceDirectory = segment(\n options.sourceLocaleDirectory ?? `${options.sourceLocale}.lproj`,\n \"source locale directory\",\n );\n const includes =\n typeof options.include === \"string\"\n ? [options.include]\n : [...(options.include ?? [\"**/*.strings\"])];\n for (const include of includes) {\n // Globs may escape a literal filename's metacharacters. Backslashes used\n // as platform-specific path separators are still rejected.\n const literalEscapesRemoved = include.replace(/\\\\[!()[\\]{}*?+@]/gu, \"_\");\n if (path.isAbsolute(include) || literalEscapesRemoved.includes(\"\\\\\") || include.split(\"/\").includes(\"..\")) {\n throw new Error(`Invalid Apple strings include: ${JSON.stringify(include)}.`);\n }\n }\n\n function file(locale: string, unitId: string): string {\n const directory =\n locale === options.sourceLocale ? sourceDirectory : `${segment(locale, \"locale\")}.lproj`;\n return path.join(root, directory, unit(unitId));\n }\n\n // Ref paths can be temporary transaction files outside root. Generated paths\n // inside root must not cross a symlink into another project's resources.\n async function checkWithinRoot(filePath: string): Promise<void> {\n const relative = path.relative(root, path.resolve(filePath));\n if (relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {\n return;\n }\n const realRoot = await fs.realpath(root);\n let existing = filePath;\n for (;;) {\n try {\n const actual = await fs.realpath(existing);\n const remainder = path.relative(realRoot, actual);\n if (\n remainder === \"..\" ||\n remainder.startsWith(`..${path.sep}`) ||\n path.isAbsolute(remainder)\n ) {\n throw new Error(`Apple strings path escapes rootDir: ${filePath}.`);\n }\n return;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") {\n throw error;\n }\n const parent = path.dirname(existing);\n if (parent === existing) {\n throw error;\n }\n existing = parent;\n }\n }\n }\n\n const adapter: CatalogAdapter = {\n id,\n messageFormats: [applePrintfMessageFormat],\n createDocumentRef(sourceRef, locale) {\n return {\n catalogId: id,\n format: \"apple-strings\",\n locale,\n path: file(locale, sourceRef.unitId),\n unitId: sourceRef.unitId,\n };\n },\n createScaffoldDocument({ ref, source }) {\n return Promise.resolve({\n ...source,\n ref,\n state: { ...(source.state as StringsState), scaffold: true },\n });\n },\n async listDocumentRefs(locale) {\n const directory =\n locale === options.sourceLocale ? sourceDirectory : `${segment(locale, \"locale\")}.lproj`;\n const files = await globby(includes, {\n cwd: path.join(root, directory),\n followSymbolicLinks: false,\n onlyFiles: true,\n });\n const refs: DocumentRef[] = [];\n for (const unitId of files.toSorted()) {\n const filePath = file(locale, unitId);\n await checkWithinRoot(filePath);\n refs.push({ catalogId: id, format: \"apple-strings\", locale, path: filePath, unitId });\n }\n return refs;\n },\n async loadDocument(ref) {\n unit(ref.unitId);\n await checkWithinRoot(ref.path);\n const table = await readTable(ref.path);\n if (table === null) {\n return null;\n }\n const sourcePath = file(options.sourceLocale, ref.unitId);\n await checkWithinRoot(sourcePath);\n const templates =\n ref.locale === options.sourceLocale\n ? table\n : ((await readTable(sourcePath)) ?? table);\n const sourceRecords = new Map(templates.records.map((record) => [record.key, record]));\n const entries = table.records.flatMap((record) => {\n const source = sourceRecords.get(record.key);\n return source === undefined ? [] : [entry(source, record.value, plainTextKeys)];\n });\n return document(ref, { encoding: table.encoding, table, templates }, entries);\n },\n reconcileDocument({ ref, source, target }) {\n const sourceState = source.state as StringsState;\n const targetState = target?.state as StringsState | undefined;\n const values = new Map(\n target?.entries.map((item) => [\n item.address[0]?.kind === \"key\" ? item.address[0].key : \"\",\n item.value,\n ]),\n );\n const entries = sourceState.table.records.map((record) =>\n entry(\n record,\n typeof values.get(record.key) === \"string\" ? (values.get(record.key) as string) : null,\n plainTextKeys,\n ),\n );\n return Promise.resolve(\n document(\n ref,\n {\n encoding: targetState?.encoding ?? sourceState.encoding,\n table: targetState?.table ?? { records: [], text: \"\" },\n templates: sourceState.table,\n },\n entries,\n ),\n );\n },\n async scaffoldLocale(scaffold) {\n const strategy = scaffold.strategy ?? \"copy-source\";\n const from =\n strategy === \"copy-source\"\n ? options.sourceLocale\n : (scaffold.fromLocale ?? options.sourceLocale);\n const refs = await adapter.listDocumentRefs(from);\n let createdDocuments = 0;\n let skippedDocuments = 0;\n for (const ref of refs) {\n const target = adapter.createDocumentRef(ref, scaffold.locale);\n if (strategy === \"empty\") {\n skippedDocuments += 1;\n continue;\n }\n await checkWithinRoot(target.path);\n await withFileLock(target.path, async () => {\n if ((await readTable(target.path)) !== null) {\n skippedDocuments += 1;\n return;\n }\n const contents = await fs.readFile(ref.path);\n await writeTextAtomic(target.path, contents);\n createdDocuments += 1;\n });\n }\n return {\n catalogId: id,\n createdDocuments,\n locale: scaffold.locale,\n skippedDocuments,\n strategy,\n };\n },\n async writeDocument(next) {\n await checkWithinRoot(next.ref.path);\n const state = next.state as StringsState;\n const originalValues = new Map(state.table.records.map(({ key, value }) => [key, value]));\n const values = new Map<string, string>();\n for (const item of next.entries) {\n const address = item.address[0];\n if (item.address.length !== 1 || address?.kind !== \"key\") {\n throw new Error(\"Invalid Apple strings entry address.\");\n }\n if (\n typeof item.value === \"string\" &&\n (state.scaffold === true || item.value !== originalValues.get(address.key))\n ) {\n values.set(address.key, item.value);\n }\n }\n if (values.size === 0 && state.scaffold !== true) {\n return;\n }\n await withFileLock(next.ref.path, async () => {\n const current = await readTable(next.ref.path);\n if (state.scaffold === true && current !== null) {\n return;\n }\n const currentValues = new Map(current?.records.map(({ key, value }) => [key, value]));\n for (const [key, value] of values) {\n const currentValue = currentValues.get(key);\n if (\n state.scaffold !== true &&\n currentValue !== originalValues.get(key) &&\n currentValue !== value\n ) {\n throw new Error(`Apple strings translation changed before writing ${JSON.stringify(key)}.`);\n }\n }\n const text = renderStrings(current ?? state.table, values, state.templates);\n await writeTextAtomic(\n next.ref.path,\n encodeStrings(text, current?.encoding ?? state.encoding),\n );\n });\n },\n };\n return adapter;\n}\n","import path from \"node:path\";\n\nimport {\n defineIntegration,\n findProjectFiles,\n isLocaleTag,\n readStringLiteral,\n resolveSourceLocale,\n} from \"@ai-translate/integrations\";\nimport { convertPathToPattern } from \"globby\";\nimport ignore from \"ignore\";\n\nimport { parseCatalog } from \"./xcstrings-model\";\nimport type {\n AdapterCatalogPlan,\n DetectionContext,\n DetectionEvidence,\n Integration,\n} from \"@ai-translate/integrations\";\n\nexport const APPLE_INTEGRATION_ID = \"apple\";\n\nfunction record(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\ninterface CatalogMetadata {\n file: string;\n locales: readonly string[];\n sourceLocale: string;\n}\n\nasync function readCatalogMetadata(\n context: DetectionContext,\n file: string,\n): Promise<CatalogMetadata | null> {\n try {\n const text = ((await context.readFile(file)) ?? \"\").replace(/^\\uFEFF/u, \"\");\n const parsed: unknown = JSON.parse(text);\n if (!record(parsed) || typeof parsed.sourceLanguage !== \"string\" ||\n !isLocaleTag(parsed.sourceLanguage) || !record(parsed.strings)) {\n return null;\n }\n parseCatalog(text, file, parsed.sourceLanguage);\n const locales = new Set<string>();\n for (const entry of Object.values(parsed.strings)) {\n if (record(entry) && record(entry.localizations)) {\n for (const locale of Object.keys(entry.localizations)) {\n if (isLocaleTag(locale)) {\n locales.add(locale);\n }\n }\n }\n }\n return { file, locales: [...locales], sourceLocale: parsed.sourceLanguage };\n } catch {\n return null;\n }\n}\n\ninterface ProjectMetadata {\n file: string;\n rootDir: string;\n sourceLocale: string | undefined;\n locales: readonly string[];\n}\n\nfunction inside(file: string, root: string): boolean {\n return root === \".\" || file === root || file.startsWith(`${root}/`);\n}\n\nfunction localeIdentity(locale: string): string {\n return Intl.getCanonicalLocales(locale)[0]?.toLowerCase() ?? locale.toLowerCase();\n}\n\n/** A single configured locale must address one physical spelling everywhere.\n * Resource names take precedence over project metadata; conflicting resource\n * aliases require normalization before they can safely share a target. */\nfunction selectTargetLocales(\n resourceLocales: Iterable<string>,\n declaredLocales: Iterable<string>,\n sourceLocale: string,\n warnings: string[],\n): readonly string[] {\n const source = localeIdentity(sourceLocale);\n const spellings = new Map<string, Set<string>>();\n for (const locale of resourceLocales) {\n const identity = localeIdentity(locale);\n if (identity === source) { continue; }\n const names = spellings.get(identity) ?? new Set<string>();\n names.add(locale);\n spellings.set(identity, names);\n }\n const targets = new Map<string, string>();\n for (const [identity, names] of spellings) {\n const [locale] = names;\n if (names.size > 1) {\n warnings.push(`Locale spellings ${[...names].toSorted().join(\", \")} identify the same language in existing resources. This language was omitted from targetLocales; normalize its resource names before syncing.`);\n } else if (locale !== undefined) {\n targets.set(identity, locale);\n }\n }\n for (const locale of declaredLocales) {\n const identity = localeIdentity(locale);\n if (identity !== source && !spellings.has(identity)) {\n targets.set(identity, Intl.getCanonicalLocales(locale)[0] ?? locale);\n }\n }\n return [...targets.values()].toSorted();\n}\n\nfunction commentsRemoved(source: string): string {\n let result = \"\";\n let index = 0;\n while (index < source.length) {\n const start = index;\n const quote = source[index];\n if (quote === '\"' || quote === \"'\") {\n index += 1;\n while (index < source.length) {\n const character = source[index++];\n if (character === \"\\\\\") { index += 1; }\n else if (character === quote) { break; }\n }\n result += source.slice(start, index);\n } else if (source.startsWith(\"//\", index)) {\n while (index < source.length && !/[\\r\\n]/u.test(source[index] ?? \"\")) { index += 1; }\n result += \" \";\n } else if (source.startsWith(\"/*\", index)) {\n let depth = 1;\n index += 2;\n while (index < source.length && depth > 0) {\n if (source.startsWith(\"/*\", index)) { depth += 1; index += 2; }\n else if (source.startsWith(\"*/\", index)) { depth -= 1; index += 2; }\n else { index += 1; }\n }\n result += source.slice(start, index).replace(/[^\\r\\n]/gu, \" \");\n } else {\n result += source[index++];\n }\n }\n return result;\n}\n\nfunction projectMetadata(file: string, source: string): ProjectMetadata {\n const tokens = [...commentsRemoved(source).matchAll(/\"(?:\\\\.|[^\"\\\\])*\"|[A-Za-z_][A-Za-z0-9_-]*|[=;(),{}]/gu)]\n .map(([token]) => token.replace(/^\"|\"$/gu, \"\"));\n let sourceLocale: string | undefined;\n const locales: string[] = [];\n for (let index = 0; index < tokens.length; index += 1) {\n if (tokens[index + 1] !== \"=\") { continue; }\n if (tokens[index] === \"developmentRegion\" && tokens[index + 3] === \";\") {\n const value = tokens[index + 2];\n if (value !== undefined && isLocaleTag(value)) { sourceLocale = value; }\n }\n if (tokens[index] === \"knownRegions\" && tokens[index + 2] === \"(\") {\n for (let cursor = index + 3; cursor < tokens.length && tokens[cursor] !== \")\"; cursor += 1) {\n const value = tokens[cursor];\n if (value !== undefined && isLocaleTag(value)) { locales.push(value); }\n }\n }\n }\n return { file, rootDir: path.posix.dirname(path.posix.dirname(file)), sourceLocale, locales };\n}\n\nfunction nearestProjects(file: string, projects: readonly ProjectMetadata[]): readonly ProjectMetadata[] {\n const candidates = projects.filter((project) => inside(file, project.rootDir));\n const depth = Math.max(-1, ...candidates.map((project) => project.rootDir === \".\" ? 0 : project.rootDir.split(\"/\").length));\n return candidates.filter((project) => (project.rootDir === \".\" ? 0 : project.rootDir.split(\"/\").length) === depth);\n}\n\nasync function expoDiscovery(context: DetectionContext): Promise<{\n accept(file: string): boolean;\n visit(directory: string): Promise<boolean>;\n}> {\n const expoRoots = new Set<string>();\n const rules = new Map<string, ReturnType<typeof ignore>>();\n const ignored = (file: string): boolean => {\n let result = false;\n for (const [root, matcher] of rules) {\n if (!inside(file, root)) { continue; }\n const relative = root === \".\" ? file : file.slice(root.length + 1);\n if (relative.length === 0) { continue; }\n const match = matcher.test(relative);\n result = match.ignored || (result && !match.unignored);\n }\n return result;\n };\n const generated = (file: string): boolean => [...expoRoots].some((root) =>\n inside(file, root === \".\" ? \"ios\" : `${root}/ios`)) && ignored(file);\n const visit = async (directory: string): Promise<boolean> => {\n if (generated(`${directory}/`)) { return false; }\n const root = directory || \".\";\n const relative = (name: string) => root === \".\" ? name : `${root}/${name}`;\n const [manifest, gitignore] = await Promise.all([\n context.readFile(relative(\"package.json\")), context.readFile(relative(\".gitignore\")),\n ]);\n if (gitignore !== null) { rules.set(root, ignore().add(gitignore)); }\n try {\n const parsed: unknown = JSON.parse((manifest ?? \"\").replace(/^\\uFEFF/u, \"\"));\n if (record(parsed) && [\"dependencies\", \"devDependencies\", \"peerDependencies\", \"optionalDependencies\"]\n .some((section) => record(parsed[section]) && Object.hasOwn(parsed[section], \"expo\"))) {\n expoRoots.add(root);\n }\n } catch { /* A non-package directory or malformed manifest cannot declare Expo. */ }\n return true;\n };\n await visit(\"\");\n return { accept: (file) => !generated(file), visit };\n}\n\nfunction adapterPlan(factory: string, id: string, include?: readonly string[]): AdapterCatalogPlan {\n return {\n factory: { from: \"@ai-translate/apple\", name: factory },\n kind: \"adapter\",\n options: { id, rootDir: \".\", ...(include === undefined ? {} : { include }) },\n };\n}\n\n/** Native resources are shared by Swift, Objective-C, React Native and Expo\n * prebuild projects, so discovery follows authored resources rather than a UI framework. */\nexport const appleIntegration: Integration = defineIntegration({\n async detect(context) {\n const discovery = await expoDiscovery(context);\n const files = await findProjectFiles(context, (file) =>\n discovery.accept(file) && (\n file.endsWith(\".xcstrings\") || /(?:^|\\/)project\\.pbxproj$/u.test(file) ||\n /(?:^|\\/)Package\\.swift$/u.test(file) || /\\.lproj\\/.+\\.strings$/u.test(file)),\n (directory) => discovery.visit(directory),\n );\n const catalogFiles = files.filter((file) => file.endsWith(\".xcstrings\"));\n const legacyFiles = files.filter((file) => file.endsWith(\".strings\"));\n const projectFiles = files.filter((file) => file.endsWith(\"project.pbxproj\"));\n const packageFiles = files.filter((file) => file.endsWith(\"Package.swift\"));\n const projectSources = await Promise.all(projectFiles.map(async (file) =>\n projectMetadata(file, (await context.readFile(file)) ?? \"\")));\n const applePackages = (await Promise.all(packageFiles.map(async (file) => ({\n file, text: commentsRemoved((await context.readFile(file)) ?? \"\"),\n })))).flatMap(({ file, text }) => {\n const declared = readStringLiteral(text, \"defaultLocalization\");\n const sourceLocale = declared !== null && isLocaleTag(declared) ? declared : undefined;\n const code = text.replace(/\"(?:\\\\.|[^\"\\\\])*\"/gu, \"\\\"\\\"\");\n return sourceLocale !== undefined || /\\.(?:iOS|macOS|tvOS|watchOS|visionOS)\\s*\\(/u.test(code)\n ? [{ file, rootDir: path.posix.dirname(file), sourceLocale, locales: [] } satisfies ProjectMetadata]\n : [];\n });\n const projects = [...projectSources, ...applePackages];\n if (catalogFiles.length === 0 && legacyFiles.length === 0 &&\n projectFiles.length === 0 && applePackages.length === 0) {\n return null;\n }\n\n const warnings: string[] = [];\n const metadata = (await Promise.all(catalogFiles.map((file) => readCatalogMetadata(context, file))))\n .filter((item): item is CatalogMetadata => item !== null);\n for (const file of catalogFiles) {\n if (!metadata.some((item) => item.file === file)) {\n warnings.push(`Could not read a supported String Catalog or its source language from ${file}; repair its JSON, version, and localization structure, then re-run init.`);\n }\n }\n const declaredSources = projects.flatMap(({ sourceLocale }) => sourceLocale === undefined ? [] : [sourceLocale]);\n const rootSources = projects.filter(({ rootDir }) => rootDir === \".\")\n .flatMap(({ sourceLocale }) => sourceLocale === undefined ? [] : [sourceLocale]);\n const legacyLocales = [...new Set(legacyFiles.flatMap((file) => {\n const locale = /(?:^|\\/)([^/]+)\\.lproj\\//u.exec(file)?.[1];\n return locale !== undefined && isLocaleTag(locale) ? [locale] : [];\n }))];\n const preferredSource = rootSources[0] ?? metadata[0]?.sourceLocale ?? declaredSources[0] ??\n legacyLocales.find((locale) => localeIdentity(locale) === \"en\") ?? resolveSourceLocale(legacyLocales, null) ?? \"en\";\n // Catalog sourceLanguage is an exact JSON key. Retain that spelling when\n // project metadata declares a case/legacy alias of the same language.\n const sourceLocale = metadata.find((item) => localeIdentity(item.sourceLocale) === localeIdentity(preferredSource))?.sourceLocale ?? preferredSource;\n if (metadata.length === 0 && declaredSources.length === 0) {\n warnings.push(`No source language is declared; sourceLocale is provisionally \"${sourceLocale}\". Confirm it before syncing.`);\n }\n const matchingCatalogs = metadata.filter((item) => item.sourceLocale === sourceLocale);\n for (const item of metadata.filter((catalog) => catalog.sourceLocale !== sourceLocale)) {\n warnings.push(`${item.file} uses source language ${item.sourceLocale}; configure it separately from ${sourceLocale} catalogs.`);\n }\n for (const project of projects) {\n if (project.sourceLocale !== undefined && localeIdentity(project.sourceLocale) !== localeIdentity(sourceLocale)) {\n warnings.push(`${project.file} declares source language ${project.sourceLocale}; configure its resources separately from ${sourceLocale} resources.`);\n }\n }\n const resourceLanguages = new Set(matchingCatalogs.flatMap((item) => [...item.locales]));\n const declaredLanguages = new Set(\n projects.filter((project) => (project.sourceLocale !== undefined && localeIdentity(project.sourceLocale) === localeIdentity(sourceLocale)) ||\n (project.sourceLocale === undefined && (project.rootDir === \".\" ||\n matchingCatalogs.some((catalog) => nearestProjects(catalog.file, projects).includes(project)))))\n .flatMap((project) => [...project.locales]),\n );\n\n const catalogs: AdapterCatalogPlan[] = [];\n if (matchingCatalogs.length > 0) {\n catalogs.push(adapterPlan(\"createAppleStringCatalog\", \"apple-catalogs\", matchingCatalogs.map((item) => convertPathToPattern(item.file))));\n }\n const legacyRoots = new Map<string, Map<string, Set<string>>>();\n for (const file of legacyFiles) {\n const match = /^(?:(.*?)\\/)?([^/]+)\\.lproj\\/(.+\\.strings)$/u.exec(file);\n if (match === null) { continue; }\n const root = match[1] ?? \".\";\n const languages = legacyRoots.get(root) ?? new Map<string, Set<string>>();\n const language = match[2] ?? \"\";\n const tables = languages.get(language) ?? new Set<string>();\n tables.add(match[3] ?? \"\");\n languages.set(language, tables);\n legacyRoots.set(root, languages);\n }\n for (const [rootDir, languages] of legacyRoots) {\n for (const language of languages.keys()) {\n if (language !== \"Base\" && !isLocaleTag(language)) {\n warnings.push(`Unsupported locale directory ${rootDir}/${language}.lproj. Generated configs require BCP 47 language tags such as en or pt-BR; rename legacy aliases or configure these resources manually.`);\n }\n }\n const owners = nearestProjects(rootDir, projects);\n if (owners.some((project) => project.sourceLocale !== undefined && localeIdentity(project.sourceLocale) !== localeIdentity(sourceLocale))) {\n warnings.push(`Skipped ${rootDir} strings tables because their project declares a different source language. Run init from that project separately.`);\n continue;\n }\n const sourceLanguages = [...languages.keys()].filter((locale) => isLocaleTag(locale) && localeIdentity(locale) === localeIdentity(sourceLocale));\n if (sourceLanguages.length > 1) {\n warnings.push(`Skipped ${rootDir} strings tables because ${sourceLanguages.join(\", \")} are ambiguous spellings of source language ${sourceLocale}. Normalize these source directories before syncing.`);\n continue;\n }\n const sourceLanguage = sourceLanguages[0];\n const sourceDirectory = sourceLanguage !== undefined\n ? `${sourceLanguage}.lproj`\n : languages.has(\"Base\") ? \"Base.lproj\" : undefined;\n if (sourceDirectory === undefined) {\n warnings.push(`No ${sourceLocale}.lproj or Base.lproj strings table was found in ${rootDir}; add a source-language table before configuring legacy strings.`);\n continue;\n }\n for (const language of languages.keys()) {\n if (isLocaleTag(language)) { resourceLanguages.add(language); }\n }\n for (const owner of owners) {\n for (const locale of owner.locales) { declaredLanguages.add(locale); }\n }\n const baseOnlyTables = [...(languages.get(\"Base\") ?? [])]\n .filter((table) => sourceLanguage === undefined || !languages.get(sourceLanguage)?.has(table));\n const mixed = sourceLanguage !== undefined && baseOnlyTables.length > 0;\n catalogs.push({\n ...adapterPlan(\"createAppleStringsCatalog\", `apple-strings:${rootDir}`),\n options: { id: `apple-strings:${rootDir}`, rootDir,\n ...(sourceDirectory !== `${sourceLocale}.lproj` ? { sourceLocaleDirectory: sourceDirectory } : {}),\n include: [...(languages.get(sourceLanguage ?? \"Base\") ?? [])]\n .map(convertPathToPattern),\n },\n });\n if (mixed) {\n catalogs.push({\n ...adapterPlan(\"createAppleStringsCatalog\", `apple-strings:${rootDir}:Base`),\n options: { id: `apple-strings:${rootDir}:Base`, rootDir, sourceLocaleDirectory: \"Base.lproj\",\n include: baseOnlyTables.map(convertPathToPattern) },\n });\n }\n }\n const hasResources = catalogs.length > 0;\n if (!hasResources) {\n catalogs.push(adapterPlan(\"createAppleStringCatalog\", \"apple-catalogs\", []));\n warnings.push(\"No supported source localization resources were found. Create and populate an Xcode String Catalog (.xcstrings), or extract localized Swift strings with Xcode, then re-run init to select the authored files before syncing. Hardcoded strings are not extracted by ai-translate.\");\n }\n const targetLocales = selectTargetLocales(resourceLanguages, declaredLanguages, sourceLocale, warnings);\n if (targetLocales.length === 0) {\n warnings.push(\"No target languages were found. Add the languages your app supports to targetLocales before syncing.\");\n }\n const evidence: DetectionEvidence[] = [\n ...matchingCatalogs.map((item) => ({\n detail: `Xcode String Catalog with source language ${item.sourceLocale}`,\n source: item.file,\n })),\n ...projectSources.map(({ file }) => ({ detail: \"Xcode project\", source: file })),\n ...applePackages.map(({ file }) => ({ detail: \"Swift package with Apple platform support\", source: file })),\n ...(legacyFiles.length === 0 ? [] : [{ detail: `${String(legacyFiles.length)} localized strings table(s)`, source: legacyFiles[0] ?? \".\" }]),\n ];\n const [catalog, ...additionalCatalogs] = catalogs;\n if (catalog === undefined) {\n return null;\n }\n return {\n confidence: hasResources ? 0.98 : 0.6,\n displayName: \"Apple localization\",\n evidence,\n integrationId: APPLE_INTEGRATION_ID,\n plan: {\n catalog,\n ...(additionalCatalogs.length === 0 ? {} : { additionalCatalogs }),\n messageFormat: \"plain\",\n sourceLocale,\n targetLocales,\n warnings,\n },\n };\n },\n displayName: \"Apple localization (Xcode and Swift packages)\",\n id: APPLE_INTEGRATION_ID,\n});\n"],"mappings":";;;;;;;;;;;;;AAIA,MAAM,gCAAgB,IAAI,IAA8B;;AAGxD,eAAsB,aAAgB,UAAkB,WAAyC;CAC/F,MAAM,MAAMA,OAAK,QAAQ,QAAQ;CAEjC,MAAM,WADW,cAAc,IAAI,GAAG,KAAK,QAAQ,QAAQ,EAAA,CAClC,YAAY,KAAA,CAAS,CAAC,CAAC,KAAK,SAAS;CAC9D,cAAc,IAAI,KAAK,OAAO;CAC9B,IAAI;EACF,OAAO,MAAM;CACf,UAAU;EACR,IAAI,cAAc,IAAI,GAAG,MAAM,SAC7B,cAAc,OAAO,GAAG;CAE5B;AACF;AAEA,eAAsB,SAAS,UAA0C;CACvE,IAAI;EACF,OAAO,MAAMC,SAAG,SAAS,UAAU,MAAM;CAC3C,SAAS,OAAO;EACd,IAAK,M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,EAAE;IAA8B,QAAQ,YAAY,MAAM;GAAI,CAAC;EAC5I;EACA,MAAM,CAAC,SAAS,GAAG,sBAAsB;EACzC,IAAI,YAAY,KAAA,GACd,OAAO;EAET,OAAO;GACL,YAAY,eAAe,MAAO;GAClC,aAAa;GACb;GACA,eAAe;GACf,MAAM;IACJ;IACA,GAAI,mBAAmB,WAAW,IAAI,CAAC,IAAI,EAAE,mBAAmB;IAChE,eAAe;IACf;IACA;IACA;GACF;EACF;CACF;CACA,aAAa;CACb,IAAI;AACN,CAAC"}
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@ai-translate/apple",
3
+ "version": "0.1.0",
4
+ "description": "Native Apple String Catalog and strings adapters for ai-translate.",
5
+ "keywords": [
6
+ "i18n",
7
+ "l10n",
8
+ "localization",
9
+ "translation",
10
+ "ios",
11
+ "macos",
12
+ "xcstrings"
13
+ ],
14
+ "license": "MIT",
15
+ "author": "Thiago Peres",
16
+ "homepage": "https://github.com/thiagoperes/ai-translate#packages",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/thiagoperes/ai-translate.git",
20
+ "directory": "packages/ai-translate-apple"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/thiagoperes/ai-translate/issues"
24
+ },
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "type": "module",
29
+ "sideEffects": false,
30
+ "main": "./dist/index.mjs",
31
+ "types": "./dist/index.d.mts",
32
+ "exports": {
33
+ ".": {
34
+ "types": "./dist/index.d.mts",
35
+ "import": "./dist/index.mjs",
36
+ "default": "./dist/index.mjs"
37
+ },
38
+ "./package.json": "./package.json"
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
43
+ "dependencies": {
44
+ "globby": "16.2.4",
45
+ "ignore": "7.0.5",
46
+ "@ai-translate/core": "0.4.0",
47
+ "@ai-translate/integrations": "0.1.0",
48
+ "@ai-translate/message-formats": "0.3.0"
49
+ },
50
+ "engines": {
51
+ "node": ">=20.19.0"
52
+ },
53
+ "scripts": {
54
+ "build": "tsdown",
55
+ "typecheck": "tsc -p tsconfig.json --noEmit",
56
+ "lint": "oxlint -c ../../.oxlintrc.json --type-aware --deny-warnings src test vitest.config.ts tsdown.config.ts",
57
+ "test": "vitest run --config vitest.config.ts",
58
+ "coverage": "vitest run --config vitest.config.ts --coverage",
59
+ "test:pack": "publint . && attw --pack . --profile esm-only"
60
+ }
61
+ }