@g9tm/lynxcontrols-native 2.6.18 → 2.7.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.
Files changed (53) hide show
  1. package/README.md +40 -1
  2. package/android/build.gradle.kts +7 -0
  3. package/android/src/main/java/com/g9lynx/g9native/G9NativeImages.kt +16 -0
  4. package/android/src/main/java/com/g9lynx/g9native/canvas/G9CanvasModel.kt +2 -2
  5. package/android/src/main/java/com/g9lynx/g9native/canvas/G9CanvasPaths.kt +7 -26
  6. package/android/src/main/java/com/g9lynx/g9native/canvas/G9CanvasView.kt +9 -4
  7. package/android/src/main/java/com/g9lynx/g9native/generated/G9ImageModuleSpec.java +27 -0
  8. package/android/src/main/java/com/g9lynx/g9native/image/G9HostTypeface.kt +49 -0
  9. package/android/src/main/java/com/g9lynx/g9native/image/G9ImageDraw.kt +222 -0
  10. package/android/src/main/java/com/g9lynx/g9native/image/G9ImageModule.kt +54 -0
  11. package/android/src/main/java/com/g9lynx/g9native/image/G9ImageProcessor.kt +464 -0
  12. package/android/src/main/java/com/g9lynx/g9native/image/core/G9HostFont.kt +28 -0
  13. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageBudget.kt +54 -0
  14. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageColor.kt +48 -0
  15. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageError.kt +19 -0
  16. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageExifTags.kt +61 -0
  17. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageFiles.kt +99 -0
  18. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageGeometry.kt +150 -0
  19. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageJson.kt +200 -0
  20. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageQuality.kt +65 -0
  21. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageRedaction.kt +77 -0
  22. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageService.kt +102 -0
  23. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageSniff.kt +63 -0
  24. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageSpec.kt +237 -0
  25. package/catalog/catalog.json +161 -1
  26. package/catalog/index.md +1 -1
  27. package/dist/.tsbuildinfo +1 -1
  28. package/dist/image.d.ts +219 -0
  29. package/dist/image.d.ts.map +1 -0
  30. package/dist/image.js +116 -0
  31. package/dist/image.js.map +1 -0
  32. package/dist/index.d.ts +1 -0
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +1 -0
  35. package/dist/protocol.d.ts +12 -0
  36. package/dist/protocol.d.ts.map +1 -1
  37. package/generated/G9ImageModule.ts +64 -0
  38. package/ios/Tests/G9NativeTestSuite.h +8 -0
  39. package/ios/Tests/G9NativeTestSuite.m +350 -0
  40. package/ios/Tests/G9NativeTests.m +16 -0
  41. package/ios/g9lynx-native-swift.podspec +1 -1
  42. package/ios/g9lynx-native.podspec +5 -4
  43. package/ios/src/G9ImageModule.h +30 -0
  44. package/ios/src/G9ImageModule.m +986 -0
  45. package/ios/src/core/G9ImageCore.h +201 -0
  46. package/ios/src/core/G9ImageCore.m +1039 -0
  47. package/ios/src/generated/G9ImageModuleSpec.h +16 -0
  48. package/ios/src/generated/G9ImageModuleSpec.m +2 -0
  49. package/ios/swift/canvas/G9LCCanvasCore.swift +3 -2
  50. package/ios/swift/canvas/G9LCCanvasView.swift +15 -4
  51. package/ios/swift/shared/G9LCFonts.swift +18 -2
  52. package/package.json +4 -4
  53. package/types/platform-native-module.d.ts +18 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.js","sources":["../src/image.ts"],"sourcesContent":["// The photo pipeline over `NativeModules.G9ImageModule` (2.7.0): what the photo editor and an app's headless \"process\n// this photo\" call (AgriPad fitting an upload to a server's size limit) go through. Every method takes one JSON string\n// and replies one JSON string (`{\"ok\":true,\"value\"}` / `{\"ok\":false,\"error\":{\"code\",\"message\"}}`); this side checks the\n// arguments, parses the reply and turns every failure into a `G9ImageError` with one of the contract's codes. On the web\n// `@g9tm/lynxcontrols-web` answers the same module from the page (canvas), so this file never needs to know where it runs.\nimport { G9Error } from '@g9tm/lynxcontrols-foundation';\nimport type { G9ImageNativeModule, G9NativeEnvelope } from './protocol';\n\ndeclare const NativeModules: { G9ImageModule?: G9ImageNativeModule } | undefined;\n\n/** The failure codes of `G9ImageModule` (the native contract's list). */\nexport type G9ImageErrorCode =\n | 'invalid-argument'\n | 'not-found'\n | 'decode'\n | 'memory'\n | 'io'\n | 'cancelled'\n | 'unsupported';\n\nconst CODES: ReadonlySet<string> = new Set([\n 'invalid-argument',\n 'not-found',\n 'decode',\n 'memory',\n 'io',\n 'cancelled',\n 'unsupported',\n]);\n\n/**\n * A failed image call: `code` is one of {@link G9ImageErrorCode} (`unsupported` where no image module is linked,\n * `cancelled` after {@link g9ImageCancel}); a code the module does not list arrives as `io` with the original code in the\n * message.\n */\nexport class G9ImageError extends G9Error {\n /** Which of the contract's failures it is. */\n declare readonly code: G9ImageErrorCode;\n\n constructor(code: G9ImageErrorCode, message: string) {\n super(code, message);\n this.name = 'G9ImageError';\n }\n}\n\n/** What {@link g9ImageProbe} reports: the picture as a person sees it, read without decoding it. */\nexport interface G9ImageProbeResult {\n /** Pixel width AFTER the EXIF orientation is applied. */\n readonly width: number;\n /** Pixel height AFTER the EXIF orientation is applied. */\n readonly height: number;\n /** The EXIF orientation 1–8 (1 when the file has none). */\n readonly orientation: number;\n /** `image/jpeg`, `image/png`, `image/webp`, `image/heic`, … */\n readonly mime: string;\n /** The file's size in bytes. */\n readonly bytes: number;\n /** Whether the picture has an alpha channel. */\n readonly hasAlpha: boolean;\n}\n\n/** Options of {@link g9ImagePreview}. */\nexport interface G9ImagePreviewOptions {\n /** The longest side of the copy, px: a whole number 1..20000 (never upscaled). */\n readonly maxSide: number;\n /** Destination folder (default: the app cache folder `g9photo`). */\n readonly dir?: string | null;\n}\n\n/** What {@link g9ImagePreview} writes: an oriented sRGB copy (JPEG q 85, PNG when the source has alpha). */\nexport interface G9ImagePreviewResult {\n /** The copy's path (on the web a `blob:` URL). */\n readonly path: string;\n readonly width: number;\n readonly height: number;\n /** The source's oriented width (probe's `width`). */\n readonly sourceWidth: number;\n /** The source's oriented height (probe's `height`). */\n readonly sourceHeight: number;\n}\n\n/**\n * A 2×3 affine matrix `[a, b, c, d, e, f]`: `x' = a·x + c·y + e`, `y' = b·x + d·y + f` (the canvas convention). In a\n * process spec it maps OUTPUT px to ORIENTED source px, so one matrix covers crop, quarter turns, flips, a free\n * straighten angle and scale.\n */\nexport type G9ImageMatrix = readonly [number, number, number, number, number, number];\n\n/** The encoder a process asks for: `source` keeps the source's format (a HEIC source becomes JPEG). */\nexport type G9ImageFormat = 'jpeg' | 'png' | 'webp' | 'source';\n\n/** A privacy region in OUTPUT px, applied after the picture and before the overlay. */\nexport interface G9ImageRedaction {\n readonly x: number;\n readonly y: number;\n readonly width: number;\n readonly height: number;\n /** Degrees about the region's centre (default 0). */\n readonly angle?: number;\n /** `pixelate`: blocks of `max(4, strength·0.08·min(W,H))` px; `blur`: radius `max(2, strength·0.05·min(W,H))` px. */\n readonly mode: 'blur' | 'pixelate';\n /** 0..1 (default 0.5). */\n readonly strength?: number;\n}\n\n/** An overlay path in OUTPUT px: SVG path syntax, absolute M L H V C S Q T Z. */\nexport interface G9ImagePathOp {\n readonly k: 'path';\n /** The SVG path data. */\n readonly d: string;\n /** Stroke colour (`#rgb`, `#rrggbb`, `#rrggbbaa`, `rgba(…)`, `transparent`); null = no stroke. */\n readonly stroke?: string | null;\n /** Stroke width, px (default 1). */\n readonly width?: number;\n /** Fill colour; null = no fill. */\n readonly fill?: string | null;\n /** Default `butt`. */\n readonly cap?: 'butt' | 'round' | 'square';\n /** Default `miter`. */\n readonly join?: 'miter' | 'round' | 'bevel';\n /** Dash and gap lengths, px; null = solid. */\n readonly dash?: readonly number[] | null;\n /** 0..1 (default 1). */\n readonly opacity?: number;\n /** A matrix applied to the path's points before drawing (default identity). */\n readonly transform?: G9ImageMatrix | null;\n}\n\n/** An overlay text block in OUTPUT px, shaped and ordered for Persian and Arabic as well as Latin. */\nexport interface G9ImageTextOp {\n readonly k: 'text';\n readonly text: string;\n /** The block's CENTRE, x. */\n readonly x: number;\n /** The block's CENTRE, y. */\n readonly y: number;\n /** Degrees about the centre. */\n readonly angle?: number;\n /** Font size, px (default 32; lines are 1.25 × size apart). */\n readonly size?: number;\n /** Default `#000000`. */\n readonly color?: string;\n /** The rounded box behind the text; null = none. */\n readonly background?: string | null;\n /** Default 0. */\n readonly padding?: number;\n /** Default 0. */\n readonly radius?: number;\n /** `\"\"` (default) = the host's text font, else a family or asset name. */\n readonly font?: string;\n /** Default 400. */\n readonly weight?: number;\n /** Default `center`. */\n readonly align?: 'start' | 'center' | 'end' | 'left' | 'right';\n /** Right-to-left paragraph direction. */\n readonly rtl?: boolean;\n /** Wrap width, px (no wrapping when absent). */\n readonly maxWidth?: number;\n /** 0..1 (default 1). */\n readonly opacity?: number;\n}\n\n/** One overlay drawing operation, drawn in order after the redactions. */\nexport type G9ImageOverlayOp = G9ImagePathOp | G9ImageTextOp;\n\n/**\n * What {@link g9ImageProcess} makes: the output's exact size, how the source maps into it, and how it is written.\n *\n * The defaults are the same on Android, iOS and the web (one list for every platform):\n * - sizes: `width`, `height` (and preview `maxSide`) are whole numbers 1..20000, else `invalid-argument`;\n * - `format` `jpeg`, `quality` 90, `keepMetadata` false, `circle` false, no background (transparent in PNG/WebP, white\n * in JPEG; with `circle` a JPEG takes the background, white by default, outside the ellipse);\n * - redaction `strength` 0.5, `angle` 0;\n * - path ops: `width` 1, `cap` `butt`, `join` `miter`, no dash, `opacity` 1;\n * - text ops: `size` 32 px, `weight` 400, line height 1.25 × size, `color` `#000000`, `align` `center`, `padding` 0,\n * `radius` 0, `angle` 0, `opacity` 1, `font` `\"\"` (the host's text font);\n * - `maxBytes`: the quality is searched down to 30 (binary search); still too big → the output is scaled by 0.85 and\n * searched again (`downscaled: true`), until the shorter side would drop below 16 px — then the call rejects with\n * `invalid-argument` and writes no file.\n */\nexport interface G9ImageProcessSpec {\n /** Names the run for {@link g9ImageCancel} (checked between steps). */\n readonly token?: string;\n /** The source (a file path or `file://` URI; Android also `content://`; on the web a URL). Never modified. */\n readonly path: string;\n /** The output's pixel width, a whole number 1..20000 (exact: never rounded again). */\n readonly width: number;\n /** The output's pixel height, a whole number 1..20000 (exact). */\n readonly height: number;\n /** OUTPUT px → ORIENTED source px. */\n readonly matrix: G9ImageMatrix;\n /** Fill where no source pixel lands; null/absent = transparent (PNG, WebP) or white (JPEG). */\n readonly background?: string | null;\n /**\n * True: outside the ellipse inscribed in the output is transparent (PNG, WebP); a JPEG takes the background there\n * (white by default). Default false.\n */\n readonly circle?: boolean;\n /** Privacy regions (each `strength` defaults to 0.5). */\n readonly redact?: readonly G9ImageRedaction[];\n /** Paths and texts drawn in order (defaults in the list above). */\n readonly overlay?: readonly G9ImageOverlayOp[];\n /** Default `jpeg`. */\n readonly format?: G9ImageFormat;\n /** 0..100 for JPEG and WebP; default 90. */\n readonly quality?: number;\n /**\n * The largest file in bytes: the quality is searched down to 30, then the output scaled by 0.85 per step\n * (`downscaled: true`); when the shorter side would drop below 16 px the call rejects with `invalid-argument` and\n * writes no file.\n */\n readonly maxBytes?: number;\n /**\n * Copy EXIF (GPS, dates, camera, description) with Orientation 1; false (the default) = no metadata. The web cannot\n * write metadata and always strips it (the result does not say so).\n */\n readonly keepMetadata?: boolean;\n /** True: copy the file's bytes as they are (no decode, no re-encode). */\n readonly passthrough?: boolean;\n /** Destination folder (default: the app cache folder `g9photo`). */\n readonly dir?: string | null;\n /** Base name without extension (default `g9photo-<epoch ms>-<4 random hex>`). */\n readonly name?: string | null;\n}\n\n/** What {@link g9ImageProcess} wrote. */\nexport interface G9ImageProcessResult {\n /** The written file (on the web a `blob:` URL). */\n readonly path: string;\n readonly mime: string;\n /** The written width (smaller than asked only when `downscaled`). */\n readonly width: number;\n readonly height: number;\n readonly bytes: number;\n /** The quality the file was written at; null for PNG and passthrough. */\n readonly quality: number | null;\n /** The written format: `jpeg`, `png` or `webp` (iOS has no WebP encoder: `jpeg`); passthrough: the file's own. */\n readonly format: string;\n /** True when the memory budget or `maxBytes` made the output smaller than asked. */\n readonly downscaled: boolean;\n}\n\n/** The module an image call goes to: by default `NativeModules.G9ImageModule`; tests pass a fake. */\nexport interface G9ImageCallOptions {\n readonly module?: G9ImageNativeModule | null;\n}\n\n/** `NativeModules.G9ImageModule`, or `null` where neither the native library nor the web host provides it. */\nexport function nativeImageModule(): G9ImageNativeModule | null {\n try {\n return (typeof NativeModules === 'undefined' ? undefined : NativeModules?.G9ImageModule) ?? null;\n } catch {\n return null;\n }\n}\n\n/** The reply's value, or the G9ImageError it carries (a string reply is JSON; some hosts hand the object over). */\nfunction read<T>(reply: unknown): T {\n let envelope: unknown = reply;\n if (typeof reply === 'string') {\n try {\n envelope = JSON.parse(reply);\n } catch {\n throw new G9ImageError('io', 'G9ImageModule sent a reply that is not JSON.');\n }\n }\n const e = envelope as G9NativeEnvelope<T> | null | undefined;\n if (e && typeof e === 'object' && e.ok === true) return e.value;\n if (e && typeof e === 'object' && e.ok === false && e.error && typeof e.error === 'object') {\n const code = String(e.error.code);\n const message = String(e.error.message ?? '');\n if (CODES.has(code)) throw new G9ImageError(code as G9ImageErrorCode, message);\n throw new G9ImageError('io', `${code}: ${message}`);\n }\n throw new G9ImageError('io', 'G9ImageModule sent no envelope.');\n}\n\ntype Method = 'probe' | 'preview' | 'process' | 'cancel';\n\nfunction call<T>(method: Method, args: object, options: G9ImageCallOptions | undefined): Promise<T> {\n const module = options?.module === undefined ? nativeImageModule() : options.module;\n return new Promise<T>((resolve, reject) => {\n const fn = module?.[method];\n if (!module || typeof fn !== 'function') {\n reject(\n new G9ImageError(\n 'unsupported',\n module\n ? `G9ImageModule has no ${method}: update @g9tm/lynxcontrols-native in the app.`\n : 'NativeModules.G9ImageModule is missing: add @g9tm/lynxcontrols-native to the app (on the web, installG9WebHost).',\n ),\n );\n return;\n }\n let settled = false;\n try {\n fn.call(module, JSON.stringify(args), (reply: unknown) => {\n if (settled) return; // a second reply is the module's mistake: the first one counts\n settled = true;\n try {\n resolve(read<T>(reply));\n } catch (error) {\n reject(error);\n }\n });\n } catch (error) {\n settled = true;\n reject(new G9ImageError('io', `G9ImageModule.${method} threw: ${(error as Error)?.message ?? String(error)}`));\n }\n });\n}\n\nconst invalid = (message: string) => Promise.reject(new G9ImageError('invalid-argument', message));\nconst isPath = (path: unknown): path is string => typeof path === 'string' && path.trim() !== '';\n// every platform's limit for an output side and maxSide\nconst isSize = (n: unknown) => typeof n === 'number' && Number.isInteger(n) && n >= 1 && n <= 20_000;\n\n/** Why `spec` cannot be processed, or null (the module checks the rest). */\nfunction specProblem(spec: G9ImageProcessSpec): string | null {\n if (!spec || typeof spec !== 'object') return 'g9ImageProcess needs a spec object.';\n if (!isPath(spec.path)) return 'The spec needs a source path.';\n if (spec.passthrough === true) return null;\n if (!isSize(spec.width) || !isSize(spec.height)) return 'width and height must be whole numbers 1..20000.';\n const m = spec.matrix as readonly unknown[] | undefined;\n if (!Array.isArray(m) || m.length !== 6 || !m.every((v) => typeof v === 'number' && Number.isFinite(v)))\n return 'matrix must be six finite numbers [a, b, c, d, e, f].';\n if (spec.format !== undefined && !['jpeg', 'png', 'webp', 'source'].includes(spec.format))\n return `format ${String(spec.format)} is not jpeg, png, webp or source.`;\n if (spec.quality !== undefined && !(typeof spec.quality === 'number' && spec.quality >= 0 && spec.quality <= 100))\n return 'quality must be 0..100.';\n if (spec.maxBytes !== undefined && !(typeof spec.maxBytes === 'number' && spec.maxBytes > 0))\n return 'maxBytes must be above 0.';\n return null;\n}\n\n/** Reads a picture's oriented size, EXIF orientation, type, byte size and alpha without decoding it. */\nexport function g9ImageProbe(path: string, options?: G9ImageCallOptions): Promise<G9ImageProbeResult> {\n if (!isPath(path)) return invalid('g9ImageProbe needs a path.');\n return call<G9ImageProbeResult>('probe', { path }, options);\n}\n\n/** Writes an oriented, screen-sized copy of a picture for the editor (longest side ≤ `maxSide`, never upscaled). */\nexport function g9ImagePreview(\n path: string,\n preview: G9ImagePreviewOptions,\n options?: G9ImageCallOptions,\n): Promise<G9ImagePreviewResult> {\n if (!isPath(path)) return invalid('g9ImagePreview needs a path.');\n if (!isSize(preview?.maxSide)) return invalid('maxSide must be a whole number 1..20000.');\n return call<G9ImagePreviewResult>(\n 'preview',\n { path, maxSide: preview.maxSide, ...(preview.dir != null ? { dir: preview.dir } : {}) },\n options,\n );\n}\n\n/**\n * Renders a picture into a new file: the source mapped through `matrix` into exactly `width × height`, background,\n * redactions, overlay and circle mask, encoded as asked (and fitted to `maxBytes`). The source is never modified.\n * Rejects with a {@link G9ImageError}: `cancelled` after {@link g9ImageCancel}, `unsupported` where no module exists.\n */\nexport function g9ImageProcess(spec: G9ImageProcessSpec, options?: G9ImageCallOptions): Promise<G9ImageProcessResult> {\n const problem = specProblem(spec);\n if (problem) return invalid(problem);\n return call<G9ImageProcessResult>('process', spec, options);\n}\n\n/** Stops the running or queued process whose spec carried `token` (it rejects with `cancelled` and leaves no file). */\nexport async function g9ImageCancel(token: string, options?: G9ImageCallOptions): Promise<void> {\n if (typeof token !== 'string' || token === '') return invalid('g9ImageCancel needs a token.');\n await call<unknown>('cancel', { token }, options);\n}\n"],"names":["CODES","Set","G9ImageError","G9Error","code","message","nativeImageModule","_ref","NativeModules","undefined","read","reply","envelope","JSON","e","_e_error_message","String","call","method","args","options","module","Promise","resolve","reject","fn","settled","error","invalid","isPath","path","isSize","n","Number","specProblem","spec","m","Array","v","g9ImageProbe","g9ImagePreview","preview","g9ImageProcess","problem","g9ImageCancel","token"],"mappings":";AAoBA,MAAMA,QAA6B,IAAIC,IAAI;IACzC;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAOM,MAAMC,qBAAqBC;IAIhC,YAAYC,IAAsB,EAAEC,OAAe,CAAE;QACnD,KAAK,CAACD,MAAMC;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,SAAS,OAAOf,QAAQe;IAC5B,OAAO1B,KAA2B,WAAWkB,MAAMf;AACrD;AAGO,eAAewB,cAAcC,KAAa,EAAEzB,OAA4B;IAC7E,IAAI,AAAiB,YAAjB,OAAOyB,SAAsBA,AAAU,OAAVA,OAAc,OAAOjB,QAAQ;IAC9D,MAAMX,KAAc,UAAU;QAAE4B;IAAM,GAAGzB;AAC3C"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { createNativeSqliteDriver, type G9NativeDriverOptions, nativeSqliteModule } from './driver.js';
2
+ export { type G9ImageCallOptions, G9ImageError, type G9ImageErrorCode, type G9ImageFormat, type G9ImageMatrix, type G9ImageOverlayOp, type G9ImagePathOp, type G9ImagePreviewOptions, type G9ImagePreviewResult, type G9ImageProbeResult, type G9ImageProcessResult, type G9ImageProcessSpec, type G9ImageRedaction, type G9ImageTextOp, g9ImageCancel, g9ImagePreview, g9ImageProbe, g9ImageProcess, nativeImageModule, } from './image.js';
2
3
  export type * from './protocol.js';
3
4
  export { createNativeHostServices, type G9InsetsSubscriber, type G9NativeHostOptions, type G9NativeServices, lynxInsetsEvents, nativeHostModule, } from './services.js';
4
5
  export { createNativeSpeechToText, type G9NativeSpeechOptions, type G9SpeechEvents, lynxSpeechEvents, nativeSpeechModule, } from './speech.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,KAAK,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACpG,mBAAmB,YAAY,CAAC;AAChC,OAAO,EACL,wBAAwB,EACxB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,wBAAwB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,KAAK,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACpG,OAAO,EACL,KAAK,kBAAkB,EACvB,YAAY,EACZ,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,cAAc,EACd,iBAAiB,GAClB,MAAM,SAAS,CAAC;AACjB,mBAAmB,YAAY,CAAC;AAChC,OAAO,EACL,wBAAwB,EACxB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,wBAAwB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { createNativeSqliteDriver, nativeSqliteModule } from "./driver.js";
2
+ export { G9ImageError, g9ImageCancel, g9ImagePreview, g9ImageProbe, g9ImageProcess, nativeImageModule } from "./image.js";
2
3
  export { createNativeHostServices, lynxInsetsEvents, nativeHostModule } from "./services.js";
3
4
  export { createNativeSpeechToText, lynxSpeechEvents, nativeSpeechModule } from "./speech.js";
4
5
  export { decodeRunValue, toArrayBuffer } from "./transport.js";
@@ -127,5 +127,17 @@ export interface G9SpeechNativeModule {
127
127
  listen(session: string, locale: string, callback: Reply<G9NativeSpeechResult>): void;
128
128
  cancel(session: string): void;
129
129
  }
130
+ type ImageReply = (reply: string | G9NativeEnvelope<unknown>) => void;
131
+ /**
132
+ * `NativeModules.G9ImageModule` (2.7.0). Every method takes ONE JSON string and replies ONE JSON string, the envelope
133
+ * `{"ok":true,"value":{…}}` or `{"ok":false,"error":{"code","message"}}` (a host that hands the envelope over as an
134
+ * object is read the same way).
135
+ */
136
+ export interface G9ImageNativeModule {
137
+ probe(args: string, callback: ImageReply): void;
138
+ preview(args: string, callback: ImageReply): void;
139
+ process(args: string, callback: ImageReply): void;
140
+ cancel(args: string, callback: ImageReply): void;
141
+ }
130
142
  export {};
131
143
  //# sourceMappingURL=protocol.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAGA,sHAAsH;AACtH,MAAM,MAAM,aAAa,GACrB,IAAI,GACJ,MAAM,GACN,MAAM,GACN,WAAW,GACX;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC1B;IAAE,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAA;CAAE,CAAC;AAEjC,uCAAuC;AACvC,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;CACvC;AAED,8EAA8E;AAC9E,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAC1B;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK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,CAAC,MAAM,EAAE,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAA;CAAE,CAAC;AAE7D,uHAAuH;AACvH,MAAM,WAAW,oBAAoB;IACnC,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IAC5D,iBAAiB,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IACjD,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,oBAAoB,CAAC,GAAG,IAAI,CAAC;IACrF,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,KAAK,UAAU,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;AAEtE;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,IAAI,CAAC;IAChD,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,IAAI,CAAC;IAClD,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,IAAI,CAAC;IAClD,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,IAAI,CAAC;CAClD"}
@@ -0,0 +1,64 @@
1
+ // Generated by @lynx-js/autolink-codegen. Do not edit.
2
+
3
+ const ADDON_NAME = "G9ImageModule";
4
+
5
+ export interface G9ImageModuleSpec {
6
+ probe(args: string, callback: (reply: string) => void): void;
7
+ preview(args: string, callback: (reply: string) => void): void;
8
+ process(args: string, callback: (reply: string) => void): void;
9
+ cancel(args: string, callback: (reply: string) => void): void;
10
+ }
11
+
12
+ type AddonExports = Record<string, unknown>;
13
+
14
+ declare let NativeModules: Record<string, unknown>;
15
+
16
+ declare global {
17
+ interface LynxNapiLoader {
18
+ load(moduleName: string): AddonExports | null | undefined;
19
+ }
20
+
21
+ // eslint-disable-next-line no-var
22
+ var __lynxNapiLoader: LynxNapiLoader | undefined;
23
+
24
+ function getNapiLoader(): LynxNapiLoader | undefined;
25
+ }
26
+
27
+ declare const lynx: {
28
+ getModuleLoader?(): LynxNapiLoader | undefined;
29
+ };
30
+
31
+ function getNativeModules(): Record<string, unknown> | undefined {
32
+ const globalObject = globalThis as unknown as {
33
+ NativeModules?: Record<string, unknown>;
34
+ };
35
+ return typeof NativeModules !== 'undefined'
36
+ ? NativeModules
37
+ : globalObject.NativeModules;
38
+ }
39
+
40
+ function installG9ImageModuleShim(): void {
41
+
42
+ }
43
+
44
+ export function requireG9ImageModule(): G9ImageModuleSpec {
45
+ const nativeModules = getNativeModules();
46
+ const existingModule = nativeModules?.[ADDON_NAME];
47
+ if (existingModule !== undefined && existingModule !== null) {
48
+ return existingModule as G9ImageModuleSpec;
49
+ }
50
+
51
+
52
+
53
+ throw new Error(`Native module "${ADDON_NAME}" is unavailable.`);
54
+ }
55
+
56
+ export const G9ImageModule = new Proxy({}, {
57
+ get(_target, property) {
58
+ return requireG9ImageModule()[property as keyof G9ImageModuleSpec];
59
+ },
60
+ }) as G9ImageModuleSpec;
61
+
62
+ installG9ImageModuleShim();
63
+
64
+ export default G9ImageModule;
@@ -22,6 +22,14 @@ NS_ASSUME_NONNULL_BEGIN
22
22
  + (NSArray *)videoCore;
23
23
  /** G9DigitsCore: the same answers as the Android core (G9DigitsCoreTest.kt), and the fonts each plan names. */
24
24
  + (NSArray *)digitsCore;
25
+ /** G9ImageCore: orientation 1–8 corners, the raw box, subsample, preview size (G9ImageModule, 2.7.0). */
26
+ + (NSArray *)imageGeometry;
27
+ /** G9ImageCore: the maxBytes quality search (fake encoder), the scale step, formats, redaction sizes, weights. */
28
+ + (NSArray *)imageEncoding;
29
+ /** G9ImageCore: unique names, file paths, colours, SVG path data. */
30
+ + (NSArray *)imageNamesColoursPaths;
31
+ /** G9ImageCore: JSON spec validation and replies, the metadata filter, the cancel registry. */
32
+ + (NSArray *)imageSpec;
25
33
  @end
26
34
 
27
35
  NS_ASSUME_NONNULL_END
@@ -7,9 +7,27 @@
7
7
  #import "../src/core/G9PreferencesCore.h"
8
8
  #import "../src/core/G9VideoCore.h"
9
9
  #import "../src/core/G9DigitsCore.h"
10
+ #import "../src/core/G9ImageCore.h"
10
11
  #import "../src/core/G9SqliteCore.h"
11
12
  #import "../src/core/G9SqliteTransport.h"
12
13
 
14
+ /** The quality search's encoder in tests: `perQuality` bytes per quality step (monotonic), or failing below `failBelow`. */
15
+ @interface G9FakeQualityEncoder : NSObject <G9ImageQualityEncoder> {
16
+ @public
17
+ long long _perQuality;
18
+ NSInteger _failBelow;
19
+ NSInteger _calls;
20
+ }
21
+ @end
22
+
23
+ @implementation G9FakeQualityEncoder
24
+ - (long long)byteCountAtQuality:(NSInteger)quality {
25
+ _calls++;
26
+ if (quality < _failBelow) return -1;
27
+ return (long long)quality * _perQuality;
28
+ }
29
+ @end
30
+
13
31
  #pragma mark - Values
14
32
 
15
33
  static NSData *G9Hex(NSString *hex) {
@@ -605,4 +623,336 @@ static NSString *G9U(unichar c) {
605
623
  return f;
606
624
  }
607
625
 
626
+ #pragma mark - G9ImageCore
627
+
628
+ static BOOL G9Near(double a, double b) {
629
+ return fabs(a - b) < 1e-9;
630
+ }
631
+
632
+ static BOOL G9BoxIs(G9ImageBox box, double x, double y, double w, double h) {
633
+ return G9Near(box.x, x) && G9Near(box.y, y) && G9Near(box.width, w) && G9Near(box.height, h);
634
+ }
635
+
636
+ static G9ImageAffine G9Affine(double a, double b, double c, double d, double e, double f) {
637
+ G9ImageAffine m = {a, b, c, d, e, f};
638
+ return m;
639
+ }
640
+
641
+ + (NSArray *)imageGeometry {
642
+ NSMutableArray *f = [NSMutableArray array];
643
+ // A raw 400 × 300 file: which raw corner each orientation shows at the displayed top-left and top-right (EXIF: where
644
+ // the 0th row and 0th column land).
645
+ double W = 400, H = 300;
646
+ double topLeft[9][2] = {{0, 0}, {0, 0}, {W, 0}, {W, H}, {0, H}, {0, 0}, {0, H}, {W, H}, {W, 0}};
647
+ double topRight[9][2] = {{0, 0}, {W, 0}, {0, 0}, {0, H}, {W, H}, {0, H}, {0, 0}, {W, 0}, {W, H}};
648
+ double bottomLeft[9][2] = {{0, 0}, {0, H}, {W, H}, {W, 0}, {0, 0}, {W, 0}, {W, H}, {0, H}, {0, 0}};
649
+ for (NSInteger o = 1; o <= 8; o++) {
650
+ double ow, oh;
651
+ [G9ImageCore orientedSizeForRawWidth:W rawHeight:H orientation:o width:&ow height:&oh];
652
+ BOOL swap = o >= 5;
653
+ if (!G9Near(ow, swap ? H : W) || !G9Near(oh, swap ? W : H)) [f addObject:[NSString stringWithFormat:@"oriented size %ld", (long)o]];
654
+ if ([G9ImageCore orientationSwapsAxes:o] != swap) [f addObject:[NSString stringWithFormat:@"swaps %ld", (long)o]];
655
+ G9ImageAffine m = [G9ImageCore orientedToRawForOrientation:o rawWidth:W rawHeight:H];
656
+ double x, y;
657
+ G9ImageAffineApply(m, 0, 0, &x, &y);
658
+ if (!G9Near(x, topLeft[o][0]) || !G9Near(y, topLeft[o][1])) [f addObject:[NSString stringWithFormat:@"top-left %ld → %g,%g", (long)o, x, y]];
659
+ G9ImageAffineApply(m, ow, 0, &x, &y);
660
+ if (!G9Near(x, topRight[o][0]) || !G9Near(y, topRight[o][1])) [f addObject:[NSString stringWithFormat:@"top-right %ld → %g,%g", (long)o, x, y]];
661
+ G9ImageAffineApply(m, 0, oh, &x, &y);
662
+ if (!G9Near(x, bottomLeft[o][0]) || !G9Near(y, bottomLeft[o][1])) [f addObject:[NSString stringWithFormat:@"bottom-left %ld → %g,%g", (long)o, x, y]];
663
+ }
664
+ if ([G9ImageCore normalizedOrientation:0] != 1 || [G9ImageCore normalizedOrientation:9] != 1) [f addObject:@"orientation outside 1..8"];
665
+
666
+ // The raw box: a 100 × 100 output at the top-left of an orientation-6 4000 × 3000 file is the raw bottom-left strip.
667
+ G9ImageBox box = [G9ImageCore rawBoxForOutputWidth:100 height:100 matrix:G9ImageAffineIdentity() orientation:6 rawWidth:4000 rawHeight:3000 margin:2];
668
+ if (!G9BoxIs(box, 0, 2898, 102, 102)) [f addObject:[NSString stringWithFormat:@"box o6 %g,%g %gx%g", box.x, box.y, box.width, box.height]];
669
+ // A 2× crop at (500, 1000), orientation 1.
670
+ box = [G9ImageCore rawBoxForOutputWidth:200 height:100 matrix:G9Affine(2, 0, 0, 2, 500, 1000) orientation:1 rawWidth:4000 rawHeight:3000 margin:2];
671
+ if (!G9BoxIs(box, 498, 998, 404, 204)) [f addObject:@"box crop o1"];
672
+ // The same crop on orientation 3 (180°): the mirrored box.
673
+ box = [G9ImageCore rawBoxForOutputWidth:200 height:100 matrix:G9Affine(2, 0, 0, 2, 500, 1000) orientation:3 rawWidth:4000 rawHeight:3000 margin:2];
674
+ if (!G9BoxIs(box, 4000 - 902, 3000 - 1202, 404, 204)) [f addObject:@"box crop o3"];
675
+ // Orientation 8: rx = W − y, ry = x.
676
+ box = [G9ImageCore rawBoxForOutputWidth:200 height:100 matrix:G9Affine(2, 0, 0, 2, 500, 1000) orientation:8 rawWidth:4000 rawHeight:3000 margin:0];
677
+ if (!G9BoxIs(box, 4000 - 1200, 500, 200, 400)) [f addObject:@"box crop o8"];
678
+ // A quarter turn in the matrix (x' = −y + 300, y' = x): the corners' bounding box.
679
+ box = [G9ImageCore rawBoxForOutputWidth:100 height:300 matrix:G9Affine(0, 1, -1, 0, 300, 0) orientation:1 rawWidth:4000 rawHeight:3000 margin:0];
680
+ if (!G9BoxIs(box, 0, 0, 300, 100)) [f addObject:[NSString stringWithFormat:@"box quarter %g,%g %gx%g", box.x, box.y, box.width, box.height]];
681
+ // Clamped to the picture; nothing when the output misses it.
682
+ box = [G9ImageCore rawBoxForOutputWidth:1000 height:1000 matrix:G9Affine(1, 0, 0, 1, 3500, 2500) orientation:1 rawWidth:4000 rawHeight:3000 margin:2];
683
+ if (!G9BoxIs(box, 3498, 2498, 502, 502)) [f addObject:@"box clamped"];
684
+ box = [G9ImageCore rawBoxForOutputWidth:100 height:100 matrix:G9Affine(1, 0, 0, 1, -1000, -1000) orientation:1 rawWidth:4000 rawHeight:3000 margin:2];
685
+ if (box.width != 0 || box.height != 0) [f addObject:@"box outside"];
686
+ // A free angle: 45° about the origin, the box is the rotated square's bounds (whole pixels, outward).
687
+ double c = cos(acos(-1.0) / 4), s = sin(acos(-1.0) / 4);
688
+ box = [G9ImageCore rawBoxForOutputWidth:100 height:100 matrix:G9Affine(c, s, -s, c, 1000, 1000) orientation:1 rawWidth:4000 rawHeight:3000 margin:0];
689
+ if (!G9BoxIs(box, floor(1000 - 100 * s), 1000, ceil(1000 + 100 * c) - floor(1000 - 100 * s), ceil(1000 + 100 * (s + c)) - 1000))
690
+ [f addObject:[NSString stringWithFormat:@"box 45° %g,%g %gx%g", box.x, box.y, box.width, box.height]];
691
+
692
+ // The affine helpers.
693
+ G9ImageAffine m = G9Affine(2, 0.5, -1, 3, 10, -4);
694
+ BOOL ok = NO;
695
+ G9ImageAffine back = G9ImageAffineConcat(G9ImageAffineInvert(m, &ok), m);
696
+ if (!ok || !G9Near(back.a, 1) || !G9Near(back.b, 0) || !G9Near(back.c, 0) || !G9Near(back.d, 1) || !G9Near(back.e, 0) || !G9Near(back.f, 0))
697
+ [f addObject:@"invert"];
698
+ G9ImageAffineInvert(G9Affine(1, 2, 2, 4, 0, 0), &ok);
699
+ if (ok) [f addObject:@"singular"];
700
+
701
+ // Subsample: the largest of 1/2/4/8 at or under the source px per output px.
702
+ if ([G9ImageCore subsampleForSourcePerOutput:0.5] != 1 || [G9ImageCore subsampleForSourcePerOutput:1.99] != 1 ||
703
+ [G9ImageCore subsampleForSourcePerOutput:2] != 2 || [G9ImageCore subsampleForSourcePerOutput:3.9] != 2 ||
704
+ [G9ImageCore subsampleForSourcePerOutput:4] != 4 || [G9ImageCore subsampleForSourcePerOutput:7.9] != 4 ||
705
+ [G9ImageCore subsampleForSourcePerOutput:100] != 8 || [G9ImageCore subsampleForSourcePerOutput:NAN] != 1)
706
+ [f addObject:@"subsample"];
707
+ if (!G9Near([G9ImageCore sourcePixelsPerOutputPixel:G9Affine(3, 0, 0, 5, 9, 9)], 3)) [f addObject:@"source per output"];
708
+ if (!G9Near([G9ImageCore sourcePixelsPerOutputPixel:G9Affine(0, 2, -2, 0, 0, 0)], 2)) [f addObject:@"source per output, turned"];
709
+ // Preview: never upscaled.
710
+ if ([G9ImageCore previewMaxPixelForMaxSide:1080 width:4000 height:3000] != 1080) [f addObject:@"preview max"];
711
+ if ([G9ImageCore previewMaxPixelForMaxSide:5000 width:4000 height:3000] != 4000) [f addObject:@"preview no upscale"];
712
+ return f;
713
+ }
714
+
715
+ + (NSArray *)imageEncoding {
716
+ NSMutableArray *f = [NSMutableArray array];
717
+ G9FakeQualityEncoder *enc = [[G9FakeQualityEncoder alloc] init];
718
+ enc->_perQuality = 1000;
719
+ NSInteger attempts = 0;
720
+ // 90 fits: one encoding.
721
+ if ([G9ImageCore qualityForMaxBytes:1000000 start:90 floor:30 encoder:enc attempts:&attempts] != 90 || attempts != 1) [f addObject:@"start fits"];
722
+ // The highest quality ≤ 55 500 bytes is 55, found by binary search in a handful of encodings.
723
+ NSInteger q = [G9ImageCore qualityForMaxBytes:55500 start:90 floor:30 encoder:enc attempts:&attempts];
724
+ if (q != 55) [f addObject:[NSString stringWithFormat:@"search → %ld", (long)q]];
725
+ if (attempts > 8) [f addObject:[NSString stringWithFormat:@"search took %ld encodings", (long)attempts]];
726
+ // Exactly at the floor, and below it.
727
+ if ([G9ImageCore qualityForMaxBytes:30000 start:90 floor:30 encoder:enc attempts:NULL] != 30) [f addObject:@"floor fits"];
728
+ if ([G9ImageCore qualityForMaxBytes:29999 start:90 floor:30 encoder:enc attempts:NULL] != -1) [f addObject:@"floor too big"];
729
+ // Failed encodings count as too big.
730
+ enc->_failBelow = 60;
731
+ if ([G9ImageCore qualityForMaxBytes:55500 start:90 floor:30 encoder:enc attempts:NULL] != -1) [f addObject:@"failures"];
732
+ enc->_failBelow = 0;
733
+ // A start below the floor searches only itself.
734
+ if ([G9ImageCore qualityForMaxBytes:100000 start:20 floor:30 encoder:enc attempts:NULL] != 20) [f addObject:@"low start"];
735
+ if ([G9ImageCore qualityFloorForQuality:90] != 30 || [G9ImageCore qualityFloorForQuality:20] != 20) [f addObject:@"floor"];
736
+ // The scale step.
737
+ if ([G9ImageCore scaledDimension:1600] != 1360 || [G9ImageCore scaledDimension:2000] != 1700 || [G9ImageCore scaledDimension:1] != 1)
738
+ [f addObject:@"scale step"];
739
+ // Scaling gives up once the shorter side would drop below 16 px (19 → 16 still allowed, 18 → 15 not).
740
+ if (![G9ImageCore canScaleWidth:1600 height:2000] || ![G9ImageCore canScaleWidth:1000 height:19] ||
741
+ [G9ImageCore canScaleWidth:1000 height:18] || [G9ImageCore canScaleWidth:16 height:16])
742
+ [f addObject:@"scale give-up"];
743
+ if (!G9Near([G9ImageCore lineHeightForSize:32], 40)) [f addObject:@"line height"];
744
+ // Formats: iOS writes WebP only when it can; HEIC becomes JPEG.
745
+ if (![[G9ImageCore outputFormatForRequested:@"webp" sourceMime:nil hasAlpha:NO webpEncodable:NO] isEqualToString:@"jpeg"]) [f addObject:@"webp → jpeg"];
746
+ if (![[G9ImageCore outputFormatForRequested:@"webp" sourceMime:nil hasAlpha:NO webpEncodable:YES] isEqualToString:@"webp"]) [f addObject:@"webp"];
747
+ if (![[G9ImageCore outputFormatForRequested:@"source" sourceMime:@"image/heic" hasAlpha:NO webpEncodable:NO] isEqualToString:@"jpeg"]) [f addObject:@"heic → jpeg"];
748
+ if (![[G9ImageCore outputFormatForRequested:@"source" sourceMime:@"image/png" hasAlpha:YES webpEncodable:NO] isEqualToString:@"png"]) [f addObject:@"source png"];
749
+ if (![[G9ImageCore outputFormatForRequested:@"source" sourceMime:@"image/jpeg" hasAlpha:NO webpEncodable:NO] isEqualToString:@"jpeg"]) [f addObject:@"source jpeg"];
750
+ if (![[G9ImageCore outputFormatForRequested:@"source" sourceMime:@"image/gif" hasAlpha:YES webpEncodable:NO] isEqualToString:@"png"]) [f addObject:@"source gif"];
751
+ if (![[G9ImageCore outputFormatForRequested:@"source" sourceMime:@"image/webp" hasAlpha:YES webpEncodable:NO] isEqualToString:@"png"]) [f addObject:@"source webp, alpha"];
752
+ if (![[G9ImageCore extensionForFormat:@"jpeg"] isEqualToString:@"jpg"] || ![[G9ImageCore mimeForFormat:@"png"] isEqualToString:@"image/png"])
753
+ [f addObject:@"extension / mime"];
754
+ if (![[G9ImageCore mimeForTypeIdentifier:@"public.heic"] isEqualToString:@"image/heic"] ||
755
+ ![[G9ImageCore formatForMime:[G9ImageCore mimeForTypeIdentifier:@"public.jpeg"]] isEqualToString:@"jpeg"] ||
756
+ [G9ImageCore formatForMime:@"text/plain"] != nil)
757
+ [f addObject:@"type identifiers"];
758
+ if (![G9ImageCore formatHasAlpha:@"png"] || [G9ImageCore formatHasAlpha:@"jpeg"]) [f addObject:@"alpha formats"];
759
+ // Redaction sizes from the output's shorter side.
760
+ if (!G9Near([G9ImageCore pixelateBlockForStrength:0.5 width:1600 height:2000], 64) ||
761
+ !G9Near([G9ImageCore pixelateBlockForStrength:0 width:1600 height:2000], 4) ||
762
+ !G9Near([G9ImageCore pixelateBlockForStrength:3 width:1600 height:2000], 128))
763
+ [f addObject:@"pixelate block"];
764
+ if (!G9Near([G9ImageCore blurRadiusForStrength:0.5 width:1600 height:2000], 40) || !G9Near([G9ImageCore blurRadiusForStrength:0 width:100 height:100], 2))
765
+ [f addObject:@"blur radius"];
766
+ if (!G9Near([G9ImageCore fontWeightTraitForWeight:400], 0) || !G9Near([G9ImageCore fontWeightTraitForWeight:700], 0.4) ||
767
+ !G9Near([G9ImageCore fontWeightTraitForWeight:50], -0.8) || !G9Near([G9ImageCore fontWeightTraitForWeight:900], 0.62))
768
+ [f addObject:@"weights"];
769
+ return f;
770
+ }
771
+
772
+ + (NSArray *)imageNamesColoursPaths {
773
+ NSMutableArray *f = [NSMutableArray array];
774
+ if (![[G9ImageCore defaultNameForEpochMs:1700000000000LL random:0xABCD12F4u] isEqualToString:@"g9photo-1700000000000-12f4"]) [f addObject:@"default name"];
775
+ if (![[G9ImageCore defaultNameForEpochMs:5 random:7] isEqualToString:@"g9photo-5-0007"]) [f addObject:@"default name padding"];
776
+ if (![G9ImageCore isUsableName:@"photo 1"] || [G9ImageCore isUsableName:@"a/b"] || [G9ImageCore isUsableName:@".."] ||
777
+ [G9ImageCore isUsableName:@""] || [G9ImageCore isUsableName:@"a\\b"])
778
+ [f addObject:@"usable names"];
779
+ // Unique paths in a scratch folder.
780
+ NSFileManager *fm = [NSFileManager defaultManager];
781
+ NSString *dir = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"g9-image-%d", (int)getpid()]];
782
+ [fm createDirectoryAtPath:dir withIntermediateDirectories:YES attributes:nil error:NULL];
783
+ NSString *first = [G9ImageCore uniquePathInDirectory:dir base:@"shot" extension:@"jpg"];
784
+ if (![[first lastPathComponent] isEqualToString:@"shot.jpg"]) [f addObject:@"unique first"];
785
+ [[NSData data] writeToFile:first atomically:NO];
786
+ NSString *second = [G9ImageCore uniquePathInDirectory:dir base:@"shot" extension:@"jpg"];
787
+ if (![[second lastPathComponent] isEqualToString:@"shot-1.jpg"]) [f addObject:[NSString stringWithFormat:@"unique second %@", second]];
788
+ [[NSData data] writeToFile:second atomically:NO];
789
+ if (![[[G9ImageCore uniquePathInDirectory:dir base:@"shot" extension:@"jpg"] lastPathComponent] isEqualToString:@"shot-2.jpg"]) [f addObject:@"unique third"];
790
+ if (![[[G9ImageCore uniquePathInDirectory:dir base:@"shot" extension:@"png"] lastPathComponent] isEqualToString:@"shot.png"]) [f addObject:@"unique per extension"];
791
+ [fm removeItemAtPath:dir error:NULL];
792
+ // Paths and file:// URIs.
793
+ if (![[G9ImageCore filePathFromString:@"file:///var/mobile/a%20b.jpg"] isEqualToString:@"/var/mobile/a b.jpg"]) [f addObject:@"file uri"];
794
+ if (![[G9ImageCore filePathFromString:@"file://localhost/tmp/x.png"] isEqualToString:@"/tmp/x.png"]) [f addObject:@"file localhost"];
795
+ if (![[G9ImageCore filePathFromString:@"/tmp/x y.png"] isEqualToString:@"/tmp/x y.png"]) [f addObject:@"plain path"];
796
+ if ([G9ImageCore filePathFromString:@"content://media/1"] != nil || [G9ImageCore filePathFromString:@""] != nil ||
797
+ [G9ImageCore filePathFromString:nil] != nil)
798
+ [f addObject:@"other schemes"];
799
+ // Colours.
800
+ double c[4];
801
+ if (![G9ImageCore parseColor:@"#fff" rgba:c] || !G9Near(c[0], 1) || !G9Near(c[3], 1)) [f addObject:@"#rgb"];
802
+ if (![G9ImageCore parseColor:@"#000000aa" rgba:c] || !G9Near(c[0], 0) || !G9Near(c[3], 170.0 / 255)) [f addObject:@"#rrggbbaa"];
803
+ if (![G9ImageCore parseColor:@"#E53935" rgba:c] || !G9Near(c[0], 229.0 / 255) || !G9Near(c[1], 57.0 / 255) || !G9Near(c[2], 53.0 / 255)) [f addObject:@"#rrggbb"];
804
+ if (![G9ImageCore parseColor:@"#f008" rgba:c] || !G9Near(c[3], 136.0 / 255)) [f addObject:@"#rgba"];
805
+ if (![G9ImageCore parseColor:@"rgba(255, 0, 0, 0.5)" rgba:c] || !G9Near(c[0], 1) || !G9Near(c[3], 128.0 / 255)) [f addObject:@"rgba()"];
806
+ if (![G9ImageCore parseColor:@"rgb(5 22 31 / 50%)" rgba:c] || !G9Near(c[1], 22.0 / 255) || !G9Near(c[3], 128.0 / 255)) [f addObject:@"rgb() spaces"];
807
+ if (![G9ImageCore parseColor:@" Transparent " rgba:c] || !G9Near(c[3], 0)) [f addObject:@"transparent"];
808
+ if ([G9ImageCore parseColor:@"#12345" rgba:c] || [G9ImageCore parseColor:@"red" rgba:c] || [G9ImageCore parseColor:@"#ggg" rgba:c] ||
809
+ [G9ImageCore parseColor:@"rgb(1,2)" rgba:c] || [G9ImageCore parseColor:nil rgba:c])
810
+ [f addObject:@"bad colours"];
811
+ // SVG path data.
812
+ NSData *data = [G9ImageCore pathSegmentsFromData:@"M10 10 L200 40 C1 2 3 4 5 6 Z"];
813
+ const G9PathSegment *seg = [data bytes];
814
+ NSUInteger n = [data length] / sizeof(G9PathSegment);
815
+ if (n != 4 || seg[0].op != G9PathMove || seg[1].op != G9PathLine || !G9Near(seg[1].p[0], 200) || seg[2].op != G9PathCubic ||
816
+ !G9Near(seg[2].p[4], 5) || !G9Near(seg[2].p[5], 6) || seg[3].op != G9PathClose)
817
+ [f addObject:@"path absolute"];
818
+ data = [G9ImageCore pathSegmentsFromData:@"m10 10 l5 5 h5 v-5 z"];
819
+ seg = [data bytes];
820
+ n = [data length] / sizeof(G9PathSegment);
821
+ if (n != 5 || !G9Near(seg[1].p[0], 15) || !G9Near(seg[1].p[1], 15) || !G9Near(seg[2].p[0], 20) || !G9Near(seg[3].p[1], 10) || seg[4].op != G9PathClose)
822
+ [f addObject:@"path relative"];
823
+ data = [G9ImageCore pathSegmentsFromData:@"M0,0 10,10 20-5"];
824
+ seg = [data bytes];
825
+ n = [data length] / sizeof(G9PathSegment);
826
+ if (n != 3 || seg[1].op != G9PathLine || !G9Near(seg[2].p[0], 20) || !G9Near(seg[2].p[1], -5)) [f addObject:@"path implicit lines"];
827
+ data = [G9ImageCore pathSegmentsFromData:@"M0 0 C0 10 10 10 10 0 S20 -10 20 0 Q25 5 30 0 T40 0"];
828
+ seg = [data bytes];
829
+ n = [data length] / sizeof(G9PathSegment);
830
+ // S reflects (10,10) about (10,0) → (10,−10); T reflects (25,5) about (30,0) → (35,−5).
831
+ if (n != 5 || !G9Near(seg[2].p[0], 10) || !G9Near(seg[2].p[1], -10) || seg[4].op != G9PathQuad || !G9Near(seg[4].p[0], 35) || !G9Near(seg[4].p[1], -5))
832
+ [f addObject:@"path smooth"];
833
+ data = [G9ImageCore pathSegmentsFromData:@"M1.5.5L1e1 2"];
834
+ seg = [data bytes];
835
+ n = [data length] / sizeof(G9PathSegment);
836
+ if (n != 2 || !G9Near(seg[0].p[0], 1.5) || !G9Near(seg[0].p[1], 0.5) || !G9Near(seg[1].p[0], 10)) [f addObject:@"path numbers"];
837
+ if ([[G9ImageCore pathSegmentsFromData:@"M10"] length] != 0 || [[G9ImageCore pathSegmentsFromData:nil] length] != 0) [f addObject:@"path broken"];
838
+ return f;
839
+ }
840
+
841
+ + (NSArray *)imageSpec {
842
+ NSMutableArray *f = [NSMutableArray array];
843
+ NSString *message = nil;
844
+ // A minimal spec: defaults filled in.
845
+ NSDictionary *spec = [G9ImageCore validateProcessSpec:[G9ImageCore objectFromJSON:@"{\"path\":\"file:///tmp/a.jpg\",\"width\":1600,\"height\":2000,\"matrix\":[2,0,0,2,10,20]}"] message:&message];
846
+ if (spec == nil) {
847
+ [f addObject:[NSString stringWithFormat:@"minimal spec: %@", message]];
848
+ } else {
849
+ if (![[spec objectForKey:@"path"] isEqualToString:@"/tmp/a.jpg"]) [f addObject:@"spec path"];
850
+ if ([[spec objectForKey:@"width"] integerValue] != 1600 || [[spec objectForKey:@"height"] integerValue] != 2000) [f addObject:@"spec size"];
851
+ if (![[spec objectForKey:@"format"] isEqualToString:@"jpeg"] || [[spec objectForKey:@"quality"] integerValue] != 90) [f addObject:@"spec format defaults"];
852
+ if ([[spec objectForKey:@"maxBytes"] longLongValue] != 0 || [[spec objectForKey:@"keepMetadata"] boolValue] || [[spec objectForKey:@"circle"] boolValue])
853
+ [f addObject:@"spec flag defaults"];
854
+ if ([spec objectForKey:@"background"] != nil || [spec objectForKey:@"token"] != nil || [spec objectForKey:@"dir"] != nil) [f addObject:@"spec absent fields"];
855
+ G9ImageAffine m = [G9ImageCore affineFromArray:[spec objectForKey:@"matrix"]];
856
+ if (!G9Near(m.a, 2) || !G9Near(m.e, 10) || !G9Near(m.f, 20)) [f addObject:@"spec matrix"];
857
+ }
858
+ // A full spec with redactions and overlays.
859
+ NSString *full = @"{\"token\":\"t1\",\"path\":\"/tmp/a.heic\",\"width\":100,\"height\":50,\"background\":\"#ffffff\",\"circle\":true,"
860
+ @"\"redact\":[{\"x\":1,\"y\":2,\"width\":30,\"height\":12,\"angle\":15,\"mode\":\"blur\",\"strength\":4}],"
861
+ @"\"overlay\":[{\"k\":\"path\",\"d\":\"M0 0 L10 10\",\"stroke\":\"#e53935\",\"width\":8,\"fill\":null,\"cap\":\"round\",\"dash\":[12,8]},"
862
+ @"{\"k\":\"text\",\"text\":\"\\u0646\\u0645\\u0648\\u0646\\u0647\",\"x\":40,\"y\":30,\"background\":\"#000000aa\",\"rtl\":true,\"weight\":700}],"
863
+ @"\"format\":\"webp\",\"quality\":80,\"maxBytes\":500000,\"keepMetadata\":true,\"dir\":\"/tmp/out\",\"name\":\"fit\"}";
864
+ spec = [G9ImageCore validateProcessSpec:[G9ImageCore objectFromJSON:full] message:&message];
865
+ if (spec == nil) {
866
+ [f addObject:[NSString stringWithFormat:@"full spec: %@", message]];
867
+ } else {
868
+ NSDictionary *r = [[spec objectForKey:@"redact"] objectAtIndex:0];
869
+ if (![[r objectForKey:@"mode"] isEqualToString:@"blur"] || !G9Near([[r objectForKey:@"strength"] doubleValue], 1)) [f addObject:@"redact normalized"];
870
+ NSDictionary *p = [[spec objectForKey:@"overlay"] objectAtIndex:0];
871
+ if (![[p objectForKey:@"cap"] isEqualToString:@"round"] || ![[p objectForKey:@"join"] isEqualToString:@"miter"] || [p objectForKey:@"fill"] != nil ||
872
+ [[p objectForKey:@"transform"] count] != 6)
873
+ [f addObject:@"path op defaults"];
874
+ NSDictionary *t = [[spec objectForKey:@"overlay"] objectAtIndex:1];
875
+ if (![[t objectForKey:@"color"] isEqualToString:@"#000000"] || ![[t objectForKey:@"align"] isEqualToString:@"center"] ||
876
+ ![[t objectForKey:@"rtl"] boolValue] || !G9Near([[t objectForKey:@"size"] doubleValue], 32) || ![[t objectForKey:@"font"] isEqualToString:@""] ||
877
+ [[t objectForKey:@"text"] length] != 5)
878
+ [f addObject:@"text op defaults"];
879
+ if (![[spec objectForKey:@"token"] isEqualToString:@"t1"] || ![[spec objectForKey:@"name"] isEqualToString:@"fit"] ||
880
+ [[spec objectForKey:@"maxBytes"] longLongValue] != 500000 || ![[spec objectForKey:@"keepMetadata"] boolValue])
881
+ [f addObject:@"full spec fields"];
882
+ }
883
+ // The size limit is 20000 a side, with no area rule.
884
+ if ([G9ImageCore validateProcessSpec:[G9ImageCore objectFromJSON:@"{\"path\":\"/a\",\"width\":20000,\"height\":20000}"] message:&message] == nil)
885
+ [f addObject:[NSString stringWithFormat:@"20000 × 20000: %@", message]];
886
+ // Passthrough needs no size.
887
+ if ([G9ImageCore validateProcessSpec:[G9ImageCore objectFromJSON:@"{\"path\":\"/tmp/a.jpg\",\"passthrough\":true}"] message:&message] == nil) [f addObject:@"passthrough spec"];
888
+ // Rejections.
889
+ NSArray *bad = [NSArray arrayWithObjects:
890
+ @"[]", @"{\"width\":1,\"height\":1}", @"{\"path\":\"content://x\",\"width\":1,\"height\":1}",
891
+ @"{\"path\":\"/a\",\"height\":1}", @"{\"path\":\"/a\",\"width\":1.5,\"height\":1}", @"{\"path\":\"/a\",\"width\":0,\"height\":1}",
892
+ @"{\"path\":\"/a\",\"width\":40000,\"height\":1}", @"{\"path\":\"/a\",\"width\":1,\"height\":20001}",
893
+ @"{\"path\":\"/a\",\"width\":1,\"height\":1,\"matrix\":[1,2,2,4,0,0]}", @"{\"path\":\"/a\",\"width\":1,\"height\":1,\"matrix\":[1,0,0,1]}",
894
+ @"{\"path\":\"/a\",\"width\":1,\"height\":1,\"background\":\"blue\"}", @"{\"path\":\"/a\",\"width\":1,\"height\":1,\"format\":\"gif\"}",
895
+ @"{\"path\":\"/a\",\"width\":1,\"height\":1,\"quality\":101}", @"{\"path\":\"/a\",\"width\":1,\"height\":1,\"name\":\"../x\"}",
896
+ @"{\"path\":\"/a\",\"width\":1,\"height\":1,\"redact\":[{\"x\":0,\"y\":0,\"width\":0,\"height\":1}]}",
897
+ @"{\"path\":\"/a\",\"width\":1,\"height\":1,\"redact\":[{\"x\":0,\"y\":0,\"width\":1,\"height\":1,\"mode\":\"smear\"}]}",
898
+ @"{\"path\":\"/a\",\"width\":1,\"height\":1,\"overlay\":[{\"k\":\"circle\"}]}",
899
+ @"{\"path\":\"/a\",\"width\":1,\"height\":1,\"overlay\":[{\"k\":\"text\",\"text\":\"a\",\"x\":0}]}",
900
+ @"{\"path\":\"/a\",\"width\":1,\"height\":1,\"overlay\":[{\"k\":\"path\",\"d\":\"M0 0\",\"dash\":[-1]}]}",
901
+ @"{\"path\":\"/a\",\"width\":1,\"height\":1,\"circle\":\"yes\"}", nil];
902
+ for (NSString *json in bad) {
903
+ message = nil;
904
+ if ([G9ImageCore validateProcessSpec:[G9ImageCore objectFromJSON:json] message:&message] != nil || message == nil)
905
+ [f addObject:[NSString stringWithFormat:@"accepted %@", json]];
906
+ }
907
+ // probe / preview / cancel arguments.
908
+ if ([G9ImageCore validateProbeArguments:[G9ImageCore objectFromJSON:@"{\"path\":\"/a.jpg\"}"] message:NULL] == nil ||
909
+ [G9ImageCore validateProbeArguments:[G9ImageCore objectFromJSON:@"{}"] message:NULL] != nil)
910
+ [f addObject:@"probe arguments"];
911
+ NSDictionary *preview = [G9ImageCore validatePreviewArguments:[G9ImageCore objectFromJSON:@"{\"path\":\"/a.jpg\",\"maxSide\":1080.7,\"dir\":null}"] message:NULL];
912
+ if ([[preview objectForKey:@"maxSide"] integerValue] != 1080 || [preview objectForKey:@"dir"] != nil) [f addObject:@"preview arguments"];
913
+ if ([G9ImageCore validatePreviewArguments:[G9ImageCore objectFromJSON:@"{\"path\":\"/a.jpg\",\"maxSide\":0}"] message:NULL] != nil) [f addObject:@"preview maxSide"];
914
+ if ([G9ImageCore validateCancelArguments:[G9ImageCore objectFromJSON:@"{\"token\":\"\"}"] message:NULL] != nil) [f addObject:@"cancel arguments"];
915
+ // Replies.
916
+ NSDictionary *ok = [G9ImageCore objectFromJSON:[G9ImageCore okReply:[NSDictionary dictionaryWithObject:[NSNull null] forKey:@"quality"]]];
917
+ if (![[ok objectForKey:@"ok"] boolValue] || [[ok objectForKey:@"value"] objectForKey:@"quality"] != [NSNull null]) [f addObject:@"ok reply"];
918
+ NSDictionary *fail = [G9ImageCore objectFromJSON:[G9ImageCore failReply:G9ImageErrorCancelled message:@"stopped"]];
919
+ if ([[fail objectForKey:@"ok"] boolValue] || ![[[fail objectForKey:@"error"] objectForKey:@"code"] isEqualToString:@"cancelled"]) [f addObject:@"fail reply"];
920
+ if (![[G9ImageCore objectFromJSON:[G9ImageCore okReply:nil]] objectForKey:@"value"]) [f addObject:@"empty ok reply"];
921
+ // Metadata: GPS, dates and camera kept, orientation 1, dimensions and the rest dropped.
922
+ NSMutableDictionary *exif = [NSMutableDictionary dictionary];
923
+ [exif setObject:@"2026:11:30 10:00:00" forKey:@"DateTimeOriginal"];
924
+ [exif setObject:[NSNumber numberWithInt:4000] forKey:@"PixelXDimension"];
925
+ [exif setObject:[NSNumber numberWithInt:3000] forKey:@"PixelYDimension"];
926
+ NSMutableDictionary *tiff = [NSMutableDictionary dictionary];
927
+ [tiff setObject:[NSNumber numberWithInt:6] forKey:@"Orientation"];
928
+ [tiff setObject:@"Apple" forKey:@"Make"];
929
+ NSMutableDictionary *source = [NSMutableDictionary dictionary];
930
+ [source setObject:exif forKey:@"{Exif}"];
931
+ [source setObject:tiff forKey:@"{TIFF}"];
932
+ [source setObject:[NSDictionary dictionaryWithObject:[NSNumber numberWithDouble:35.7] forKey:@"Latitude"] forKey:@"{GPS}"];
933
+ [source setObject:[NSDictionary dictionary] forKey:@"{JFIF}"];
934
+ [source setObject:[NSNumber numberWithInt:6] forKey:@"Orientation"];
935
+ [source setObject:[NSNumber numberWithInt:4000] forKey:@"PixelWidth"];
936
+ [source setObject:@"RGB" forKey:@"ColorModel"];
937
+ [source setObject:[NSNumber numberWithInt:72] forKey:@"DPIWidth"];
938
+ NSDictionary *meta = [G9ImageCore outputMetadataFromSourceProperties:source];
939
+ if ([[meta objectForKey:@"Orientation"] intValue] != 1 || [[[meta objectForKey:@"{TIFF}"] objectForKey:@"Orientation"] intValue] != 1) [f addObject:@"meta orientation"];
940
+ if (![[[meta objectForKey:@"{TIFF}"] objectForKey:@"Make"] isEqualToString:@"Apple"]) [f addObject:@"meta camera"];
941
+ if (![[[meta objectForKey:@"{Exif}"] objectForKey:@"DateTimeOriginal"] isEqualToString:@"2026:11:30 10:00:00"]) [f addObject:@"meta date"];
942
+ if ([[meta objectForKey:@"{Exif}"] objectForKey:@"PixelXDimension"] != nil || [meta objectForKey:@"PixelWidth"] != nil) [f addObject:@"meta dimensions"];
943
+ if (!G9Near([[[meta objectForKey:@"{GPS}"] objectForKey:@"Latitude"] doubleValue], 35.7)) [f addObject:@"meta gps"];
944
+ if ([meta objectForKey:@"{JFIF}"] != nil || [meta objectForKey:@"ColorModel"] != nil || [meta objectForKey:@"DPIWidth"] == nil) [f addObject:@"meta others"];
945
+ if ([[exif objectForKey:@"PixelXDimension"] intValue] != 4000 || [[tiff objectForKey:@"Orientation"] intValue] != 6) [f addObject:@"meta source untouched"];
946
+ // The cancel registry.
947
+ G9ImageCancelRegistry *registry = [[G9ImageCancelRegistry alloc] init];
948
+ if ([registry cancel:@"t1"]) [f addObject:@"cancel unknown"];
949
+ [registry begin:@"t1"];
950
+ if ([registry isCancelled:@"t1"] || ![registry cancel:@"t1"] || ![registry isCancelled:@"t1"]) [f addObject:@"cancel pending"];
951
+ [registry end:@"t1"];
952
+ if ([registry isCancelled:@"t1"] || [registry cancel:@"t1"]) [f addObject:@"cancel ended"];
953
+ [registry begin:nil];
954
+ if ([registry cancel:nil] || [registry isCancelled:@""]) [f addObject:@"cancel no token"];
955
+ return f;
956
+ }
957
+
608
958
  @end
@@ -58,6 +58,22 @@
58
58
  XCTAssertEqualObjects([G9NativeTestSuite digitsCore], @[]);
59
59
  }
60
60
 
61
+ - (void)testImageGeometry {
62
+ XCTAssertEqualObjects([G9NativeTestSuite imageGeometry], @[]);
63
+ }
64
+
65
+ - (void)testImageEncoding {
66
+ XCTAssertEqualObjects([G9NativeTestSuite imageEncoding], @[]);
67
+ }
68
+
69
+ - (void)testImageNamesColoursPaths {
70
+ XCTAssertEqualObjects([G9NativeTestSuite imageNamesColoursPaths], @[]);
71
+ }
72
+
73
+ - (void)testImageSpec {
74
+ XCTAssertEqualObjects([G9NativeTestSuite imageSpec], @[]);
75
+ }
76
+
61
77
  // The pod's font bundle is found and registered, and a Persian field's font draws ASCII '5' with the digits font's
62
78
  // glyph while a letter falls back to the field's own font: what `g9-digits` relies on (ledger N-062).
63
79
  - (void)testDigitFontsDrawDigitsAndFallBack {
@@ -6,7 +6,7 @@
6
6
  # same :path. Its version is the family's (npm run check:versions).
7
7
  Pod::Spec.new do |s|
8
8
  s.name = 'g9lynx-native-swift'
9
- s.version = '2.6.18'
9
+ s.version = '2.7.0'
10
10
  s.summary = 'The Swift views of the G9 <g9-richtext>, <g9-canvas> and <g9-blurhash> Lynx elements (UIKit, Core Text).'
11
11
  s.homepage = 'https://github.com/imankari/g9lynxcontrols'
12
12
  s.license = { :type => 'MIT' }