@g9tm/lynxcontrols-native 2.6.19 → 2.7.1

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 (61) 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/G9HostModule.kt +20 -0
  4. package/android/src/main/java/com/g9lynx/g9native/G9NativeImages.kt +16 -0
  5. package/android/src/main/java/com/g9lynx/g9native/canvas/G9CanvasModel.kt +2 -2
  6. package/android/src/main/java/com/g9lynx/g9native/canvas/G9CanvasPaths.kt +7 -26
  7. package/android/src/main/java/com/g9lynx/g9native/canvas/G9CanvasView.kt +9 -4
  8. package/android/src/main/java/com/g9lynx/g9native/generated/G9HostModuleSpec.java +3 -0
  9. package/android/src/main/java/com/g9lynx/g9native/generated/G9ImageModuleSpec.java +27 -0
  10. package/android/src/main/java/com/g9lynx/g9native/image/G9HostTypeface.kt +49 -0
  11. package/android/src/main/java/com/g9lynx/g9native/image/G9ImageDraw.kt +222 -0
  12. package/android/src/main/java/com/g9lynx/g9native/image/G9ImageModule.kt +54 -0
  13. package/android/src/main/java/com/g9lynx/g9native/image/G9ImageProcessor.kt +464 -0
  14. package/android/src/main/java/com/g9lynx/g9native/image/core/G9HostFont.kt +28 -0
  15. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageBudget.kt +54 -0
  16. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageColor.kt +48 -0
  17. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageError.kt +19 -0
  18. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageExifTags.kt +61 -0
  19. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageFiles.kt +99 -0
  20. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageGeometry.kt +150 -0
  21. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageJson.kt +200 -0
  22. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageQuality.kt +65 -0
  23. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageRedaction.kt +77 -0
  24. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageService.kt +102 -0
  25. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageSniff.kt +63 -0
  26. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageSpec.kt +237 -0
  27. package/catalog/catalog.json +161 -1
  28. package/catalog/index.md +1 -1
  29. package/dist/.tsbuildinfo +1 -1
  30. package/dist/image.d.ts +219 -0
  31. package/dist/image.d.ts.map +1 -0
  32. package/dist/image.js +116 -0
  33. package/dist/image.js.map +1 -0
  34. package/dist/index.d.ts +1 -0
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +1 -0
  37. package/dist/protocol.d.ts +17 -0
  38. package/dist/protocol.d.ts.map +1 -1
  39. package/dist/services.d.ts.map +1 -1
  40. package/dist/services.js +12 -0
  41. package/dist/services.js.map +1 -1
  42. package/generated/G9HostModule.ts +1 -0
  43. package/generated/G9ImageModule.ts +64 -0
  44. package/ios/Tests/G9NativeTestSuite.h +8 -0
  45. package/ios/Tests/G9NativeTestSuite.m +350 -0
  46. package/ios/Tests/G9NativeTests.m +16 -0
  47. package/ios/g9lynx-native-swift.podspec +1 -1
  48. package/ios/g9lynx-native.podspec +5 -4
  49. package/ios/src/G9HostModule.m +10 -0
  50. package/ios/src/G9ImageModule.h +30 -0
  51. package/ios/src/G9ImageModule.m +986 -0
  52. package/ios/src/core/G9ImageCore.h +201 -0
  53. package/ios/src/core/G9ImageCore.m +1039 -0
  54. package/ios/src/generated/G9HostModuleSpec.h +1 -0
  55. package/ios/src/generated/G9ImageModuleSpec.h +16 -0
  56. package/ios/src/generated/G9ImageModuleSpec.m +2 -0
  57. package/ios/swift/canvas/G9LCCanvasCore.swift +3 -2
  58. package/ios/swift/canvas/G9LCCanvasView.swift +15 -4
  59. package/ios/swift/shared/G9LCFonts.swift +18 -2
  60. package/package.json +4 -4
  61. package/types/platform-native-module.d.ts +23 -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;QACZ,IAAI,CAAC,IAAI,GAAG;IACd;AACF;AA6MO,SAASC;IACd,IAAI;YACMC;QAAR,OAAO,QAACA,CAAAA,OAAAA,AAAyB,MAAzBA,OAAOC,gBAAgCC,SAAYD,QAAAA,gBAAAA,KAAAA,IAAAA,cAAe,aAAa,AAAD,IAA9ED,OAAoF;IAC9F,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAGA,SAASG,KAAQC,KAAc;IAC7B,IAAIC,WAAoBD;IACxB,IAAI,AAAiB,YAAjB,OAAOA,OACT,IAAI;QACFC,WAAWC,KAAK,KAAK,CAACF;IACxB,EAAE,OAAM;QACN,MAAM,IAAIT,aAAa,MAAM;IAC/B;IAEF,MAAMY,IAAIF;IACV,IAAIE,KAAK,AAAa,YAAb,OAAOA,KAAkBA,AAAS,SAATA,EAAE,EAAE,EAAW,OAAOA,EAAE,KAAK;IAC/D,IAAIA,KAAK,AAAa,YAAb,OAAOA,KAAkBA,AAAS,UAATA,EAAE,EAAE,IAAcA,EAAE,KAAK,IAAI,AAAmB,YAAnB,OAAOA,EAAE,KAAK,EAAe;YAEnEC;QADvB,MAAMX,OAAOY,OAAOF,EAAE,KAAK,CAAC,IAAI;QAChC,MAAMT,UAAUW,OAAO,QAAAD,CAAAA,mBAAAA,EAAE,KAAK,CAAC,OAAO,AAAD,IAAdA,mBAAmB;QAC1C,IAAIf,MAAM,GAAG,CAACI,OAAO,MAAM,IAAIF,aAAaE,MAA0BC;QACtE,MAAM,IAAIH,aAAa,MAAM,GAAGE,KAAK,EAAE,EAAEC,SAAS;I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QAAQ;IAC9C,OAAOX,KACL,WACA;QAAEa;QAAM,SAASW,QAAQ,OAAO;QAAE,GAAIA,AAAe,QAAfA,QAAQ,GAAG,GAAW;YAAE,KAAKA,QAAQ,GAAG;QAAC,IAAI,CAAC,CAAC;IAAE,GACvFrB;AAEJ;AAOO,SAASsB,eAAeP,IAAwB,EAAEf,OAA4B;IACnF,MAAMuB,UAAUT,YAAYC;IAC5B,IAAIQ,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";
@@ -112,6 +112,11 @@ export interface G9HostNativeModule {
112
112
  hapticTick(): void;
113
113
  appDataDirectory(callback: Reply<string>): void;
114
114
  assetUri(path: string, callback: Reply<string>): void;
115
+ /** Screen protection on or off (2.7.1); absent on hosts built before it. */
116
+ screenProtection?(on: boolean, callback: Reply<{
117
+ blocked: boolean;
118
+ captured: boolean;
119
+ }>): void;
115
120
  }
116
121
  /** What `G9SpeechModule.listen` settles with (the `G9SpeechToTextResult` statuses). */
117
122
  export type G9NativeSpeechResult = {
@@ -127,5 +132,17 @@ export interface G9SpeechNativeModule {
127
132
  listen(session: string, locale: string, callback: Reply<G9NativeSpeechResult>): void;
128
133
  cancel(session: string): void;
129
134
  }
135
+ type ImageReply = (reply: string | G9NativeEnvelope<unknown>) => void;
136
+ /**
137
+ * `NativeModules.G9ImageModule` (2.7.0). Every method takes ONE JSON string and replies ONE JSON string, the envelope
138
+ * `{"ok":true,"value":{…}}` or `{"ok":false,"error":{"code","message"}}` (a host that hands the envelope over as an
139
+ * object is read the same way).
140
+ */
141
+ export interface G9ImageNativeModule {
142
+ probe(args: string, callback: ImageReply): void;
143
+ preview(args: string, callback: ImageReply): void;
144
+ process(args: string, callback: ImageReply): void;
145
+ cancel(args: string, callback: ImageReply): void;
146
+ }
130
147
  export {};
131
148
  //# 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,M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AAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC;IACxC,gGAAgG;IAChG,UAAU,IAAI,IAAI,CAAC;IACnB;;;;;OAKG;IACH,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CACrC;AAID;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,GAAE,mBAAwB,GAAG,gBAAgB,CAoF5F"}
package/dist/services.js CHANGED
@@ -80,6 +80,18 @@ function createNativeHostServices(options = {}) {
80
80
  var _native_textFocus;
81
81
  return null == (_native_textFocus = native.textFocus) ? void 0 : _native_textFocus.call(native, focused);
82
82
  }
83
+ } : {},
84
+ ...'function' == typeof native.screenProtection ? {
85
+ setScreenProtection: async (on)=>{
86
+ const state = await call((reply)=>{
87
+ var _native_screenProtection;
88
+ return null == (_native_screenProtection = native.screenProtection) ? void 0 : _native_screenProtection.call(native, on, reply);
89
+ });
90
+ return {
91
+ blocked: (null == state ? void 0 : state.blocked) === true,
92
+ captured: (null == state ? void 0 : state.captured) === true
93
+ };
94
+ }
83
95
  } : {}
84
96
  };
85
97
  const preferences = {
@@ -1 +1 @@
1
- {"version":3,"file":"services.js","sources":["../src/services.ts"],"sourcesContent":["// The mobile host services over `NativeModules.G9HostModule` (plan/specs/06 §7): G9HostServices and an asynchronous\n// G9PreferenceStore. Safe-area insets are read once and then follow the host's `g9:insets` global event.\nimport {\n G9Error,\n type G9HostServices,\n type G9PreferenceStore,\n type G9PreferenceValue,\n type G9SafeInsets,\n} from '@g9tm/lynxcontrols-foundation';\nimport type { G9HostNativeModule, G9NativeEnvelope, G9NativePreference } from './protocol';\n\ndeclare const NativeModules: { G9HostModule?: G9HostNativeModule } | undefined;\ndeclare const lynx:\n | {\n getJSModule?(name: string): {\n addListener(name: string, listener: (...args: never[]) => void): void;\n removeListener(name: string, listener: (...args: never[]) => void): void;\n };\n }\n | undefined;\n\n/** `NativeModules.G9HostModule`, or `null` where the native library is not linked. */\nexport function nativeHostModule(): G9HostNativeModule | null {\n try {\n return (typeof NativeModules === 'undefined' ? undefined : NativeModules?.G9HostModule) ?? null;\n } catch {\n return null;\n }\n}\n\nfunction call<T>(\n invoke: (reply: (envelope: G9NativeEnvelope<T>) => void) => void,\n missingCode = 'preference-store',\n): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n invoke((envelope) => {\n if (envelope?.ok) resolve(envelope.value);\n else {\n const e = envelope?.error ?? { code: missingCode, message: 'The native module sent no reply.' };\n reject(new G9Error(e.code, e.message));\n }\n });\n });\n}\n\n/** Subscribes to the host's insets event; returns the unsubscribe function. */\nexport type G9InsetsSubscriber = (listener: (insets: G9SafeInsets) => void) => () => void;\n\n/** The default insets source: the `g9:insets` global event a host sends on rotation / resize (Lynx background thread). */\nexport function lynxInsetsEvents(): G9InsetsSubscriber {\n return (listener) => {\n const target = typeof lynx === 'undefined' ? undefined : lynx?.getJSModule?.('GlobalEventEmitter');\n if (!target) return () => undefined;\n const handler = ((insets: G9SafeInsets) => listener(insets)) as unknown as (...args: never[]) => void;\n target.addListener('g9:insets', handler);\n return () => target.removeListener('g9:insets', handler);\n };\n}\n\n/** Options of {@link createNativeHostServices}. */\nexport interface G9NativeHostOptions {\n /** The module (default: `NativeModules.G9HostModule`). Tests pass a fake. */\n readonly module?: G9HostNativeModule;\n /** Where inset changes come from (default: {@link lynxInsetsEvents}). */\n readonly insetsEvents?: G9InsetsSubscriber;\n /**\n * How the system's safe-area insets reach the controls (2.5.7; SAC, G9Hub):\n * - `'system'` (default): as the host reports them, for an edge-to-edge page (the controls keep clear of the bars);\n * - `'none'`: the host already keeps its LynxView inside the safe area (it pads the container), so the controls get\n * zero insets and nothing is counted twice (a bottom bar 48 dp too high otherwise);\n * - a function: the reported insets in, the ones the controls use out (one side padded by the host, say).\n */\n readonly insets?: 'system' | 'none' | ((reported: G9SafeInsets) => G9SafeInsets);\n}\n\n/** What {@link createNativeHostServices} returns: the services for `G9Provider`, plus the optional haptic tick. */\nexport interface G9NativeServices {\n readonly host: G9HostServices;\n readonly preferences: G9PreferenceStore;\n /** A light haptic tick (Android `HapticFeedbackConstants`, iOS `UIImpactFeedbackGenerator`). */\n hapticTick(): void;\n /**\n * The app's private data directory, absolute (MAUI `FileSystem.AppDataDirectory`: Android `Context.filesDir`, iOS\n * the user `Library` directory), so the database keeps the path its MAUI version used. Pass it to a database\n * locator (`singleFileDatabaseLocator(dir + '/g9.db')` or `perUserDatabaseLocator({ root: dir, … })`).\n * Rejects with `host-data-directory` when the host reports none.\n */\n appDataDirectory(): Promise<string>;\n}\n\nconst NO_INSETS: G9SafeInsets = Object.freeze({ top: 0, end: 0, bottom: 0, start: 0 });\n\n/**\n * Android/iOS host services: `exit` moves the task to the back (Android; iOS has no programmatic exit, the module\n * ignores it), `hideKeyboard`, `setSoftInputMode` (Android), safe-area insets, and preferences in `SharedPreferences`\n * / `NSUserDefaults` (typed int/string, `null` string removes). Throws outside a host that linked `@g9tm/lynxcontrols-native`.\n */\nexport function createNativeHostServices(options: G9NativeHostOptions = {}): G9NativeServices {\n const native = options.module ?? nativeHostModule();\n if (!native) {\n throw new Error(\n 'NativeModules.G9HostModule is missing: add @g9tm/lynxcontrols-native to the app so Autolink links it.',\n );\n }\n const subscribe = options.insetsEvents ?? lynxInsetsEvents();\n let insets: G9SafeInsets = NO_INSETS;\n const listeners = new Set<(insets: G9SafeInsets) => void>();\n const mode = options.insets ?? 'system';\n const publish = (reported: G9SafeInsets) => {\n const next = mode === 'none' ? NO_INSETS : typeof mode === 'function' ? mode(reported) : reported;\n insets = Object.freeze({ top: next.top, end: next.end, bottom: next.bottom, start: next.start });\n for (const listener of Array.from(listeners)) listener(insets);\n };\n // The first read answers later than it asks: an `insets` event that arrived meanwhile is newer and wins (the read\n // once overwrote a fresh report with a stale one — AgriPad Lynx on Android 10, 48 dp under every bottom bar).\n let reported = false;\n call<G9SafeInsets>((reply) => native.safeInsets(reply)).then(\n (first) => {\n if (!reported) publish(first);\n },\n () => undefined,\n );\n subscribe((next) => {\n reported = true;\n publish(next);\n });\n\n const host: G9HostServices = {\n exit: () => native.moveToBack(),\n hideKeyboard: () => native.hideKeyboard(),\n getSafeInsets: () => insets,\n subscribeSafeInsets(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n setSoftInputMode: (mode) => native.setSoftInputMode(mode),\n ...(typeof native.textFocus === 'function' ? { textFocus: (focused: boolean) => native.textFocus?.(focused) } : {}),\n };\n const preferences: G9PreferenceStore = {\n async getInt(key, defaultValue) {\n const stored = await call<G9NativePreference | null>((reply) => native.getPreference(key, reply));\n return stored?.type === 'int' ? stored.value : defaultValue;\n },\n async setInt(key, value) {\n await call<null>((reply) => native.setPreference(key, 'int', String(value), reply));\n },\n async getString(key, defaultValue) {\n const stored = await call<G9NativePreference | null>((reply) => native.getPreference(key, reply));\n return stored?.type === 'string' ? stored.value : defaultValue;\n },\n async setString(key, value) {\n await call<null>((reply) => native.setPreference(key, 'string', value, reply));\n },\n async remove(key) {\n await call<null>((reply) => native.setPreference(key, 'remove', null, reply));\n },\n async entries(prefix): Promise<ReadonlyArray<readonly [string, G9PreferenceValue]>> {\n const list = await call<Array<[string, number | string]>>((reply) => native.preferenceEntries(prefix, reply));\n return list.map(([key, value]) => [key, value] as const);\n },\n };\n const appDataDirectory = async (): Promise<string> => {\n const dir = await call<string>((reply) => native.appDataDirectory(reply), 'host-data-directory');\n if (typeof dir !== 'string' || dir.trim() === '') {\n throw new G9Error('host-data-directory', 'The host reported no app data directory.');\n }\n return dir;\n };\n return { host, preferences, hapticTick: () => native.hapticTick(), appDataDirectory };\n}\n"],"names":["nativeHostModule","_ref","NativeModules","undefined","call","invoke","missingCode","Promise","resolve","reject","envelope","e","G9Error","lynxInsetsEvents","listener","lynx","target","handler","insets","NO_INSETS","Object","createNativeHostServices","options","_options_module","_options_insetsEvents","_options_insets","native","Error","subscribe","listeners","Set","mode","publish","reported","next","Array","reply","first","host","focused","preferences","key","defaultValue","stored","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M,IAAIrC,QAAQ,uBAAuB;QAE3C,OAAOqC;IACT;IACA,OAAO;QAAEX;QAAME;QAAa,YAAY,IAAMd,OAAO,UAAU;QAAIsB;IAAiB;AACtF"}
1
+ {"version":3,"file":"services.js","sources":["../src/services.ts"],"sourcesContent":["// The mobile host services over `NativeModules.G9HostModule` (plan/specs/06 §7): G9HostServices and an asynchronous\n// G9PreferenceStore. Safe-area insets are read once and then follow the host's `g9:insets` global event.\nimport {\n G9Error,\n type G9HostServices,\n type G9PreferenceStore,\n type G9PreferenceValue,\n type G9SafeInsets,\n} from '@g9tm/lynxcontrols-foundation';\nimport type { G9HostNativeModule, G9NativeEnvelope, G9NativePreference } from './protocol';\n\ndeclare const NativeModules: { G9HostModule?: G9HostNativeModule } | undefined;\ndeclare const lynx:\n | {\n getJSModule?(name: string): {\n addListener(name: string, listener: (...args: never[]) => void): void;\n removeListener(name: string, listener: (...args: never[]) => void): void;\n };\n }\n | undefined;\n\n/** `NativeModules.G9HostModule`, or `null` where the native library is not linked. */\nexport function nativeHostModule(): G9HostNativeModule | null {\n try {\n return (typeof NativeModules === 'undefined' ? undefined : NativeModules?.G9HostModule) ?? null;\n } catch {\n return null;\n }\n}\n\nfunction call<T>(\n invoke: (reply: (envelope: G9NativeEnvelope<T>) => void) => void,\n missingCode = 'preference-store',\n): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n invoke((envelope) => {\n if (envelope?.ok) resolve(envelope.value);\n else {\n const e = envelope?.error ?? { code: missingCode, message: 'The native module sent no reply.' };\n reject(new G9Error(e.code, e.message));\n }\n });\n });\n}\n\n/** Subscribes to the host's insets event; returns the unsubscribe function. */\nexport type G9InsetsSubscriber = (listener: (insets: G9SafeInsets) => void) => () => void;\n\n/** The default insets source: the `g9:insets` global event a host sends on rotation / resize (Lynx background thread). */\nexport function lynxInsetsEvents(): G9InsetsSubscriber {\n return (listener) => {\n const target = typeof lynx === 'undefined' ? undefined : lynx?.getJSModule?.('GlobalEventEmitter');\n if (!target) return () => undefined;\n const handler = ((insets: G9SafeInsets) => listener(insets)) as unknown as (...args: never[]) => void;\n target.addListener('g9:insets', handler);\n return () => target.removeListener('g9:insets', handler);\n };\n}\n\n/** Options of {@link createNativeHostServices}. */\nexport interface G9NativeHostOptions {\n /** The module (default: `NativeModules.G9HostModule`). Tests pass a fake. */\n readonly module?: G9HostNativeModule;\n /** Where inset changes come from (default: {@link lynxInsetsEvents}). */\n readonly insetsEvents?: G9InsetsSubscriber;\n /**\n * How the system's safe-area insets reach the controls (2.5.7; SAC, G9Hub):\n * - `'system'` (default): as the host reports them, for an edge-to-edge page (the controls keep clear of the bars);\n * - `'none'`: the host already keeps its LynxView inside the safe area (it pads the container), so the controls get\n * zero insets and nothing is counted twice (a bottom bar 48 dp too high otherwise);\n * - a function: the reported insets in, the ones the controls use out (one side padded by the host, say).\n */\n readonly insets?: 'system' | 'none' | ((reported: G9SafeInsets) => G9SafeInsets);\n}\n\n/** What {@link createNativeHostServices} returns: the services for `G9Provider`, plus the optional haptic tick. */\nexport interface G9NativeServices {\n readonly host: G9HostServices;\n readonly preferences: G9PreferenceStore;\n /** A light haptic tick (Android `HapticFeedbackConstants`, iOS `UIImpactFeedbackGenerator`). */\n hapticTick(): void;\n /**\n * The app's private data directory, absolute (MAUI `FileSystem.AppDataDirectory`: Android `Context.filesDir`, iOS\n * the user `Library` directory), so the database keeps the path its MAUI version used. Pass it to a database\n * locator (`singleFileDatabaseLocator(dir + '/g9.db')` or `perUserDatabaseLocator({ root: dir, … })`).\n * Rejects with `host-data-directory` when the host reports none.\n */\n appDataDirectory(): Promise<string>;\n}\n\nconst NO_INSETS: G9SafeInsets = Object.freeze({ top: 0, end: 0, bottom: 0, start: 0 });\n\n/**\n * Android/iOS host services: `exit` moves the task to the back (Android; iOS has no programmatic exit, the module\n * ignores it), `hideKeyboard`, `setSoftInputMode` (Android), safe-area insets, and preferences in `SharedPreferences`\n * / `NSUserDefaults` (typed int/string, `null` string removes). Throws outside a host that linked `@g9tm/lynxcontrols-native`.\n */\nexport function createNativeHostServices(options: G9NativeHostOptions = {}): G9NativeServices {\n const native = options.module ?? nativeHostModule();\n if (!native) {\n throw new Error(\n 'NativeModules.G9HostModule is missing: add @g9tm/lynxcontrols-native to the app so Autolink links it.',\n );\n }\n const subscribe = options.insetsEvents ?? lynxInsetsEvents();\n let insets: G9SafeInsets = NO_INSETS;\n const listeners = new Set<(insets: G9SafeInsets) => void>();\n const mode = options.insets ?? 'system';\n const publish = (reported: G9SafeInsets) => {\n const next = mode === 'none' ? NO_INSETS : typeof mode === 'function' ? mode(reported) : reported;\n insets = Object.freeze({ top: next.top, end: next.end, bottom: next.bottom, start: next.start });\n for (const listener of Array.from(listeners)) listener(insets);\n };\n // The first read answers later than it asks: an `insets` event that arrived meanwhile is newer and wins (the read\n // once overwrote a fresh report with a stale one — AgriPad Lynx on Android 10, 48 dp under every bottom bar).\n let reported = false;\n call<G9SafeInsets>((reply) => native.safeInsets(reply)).then(\n (first) => {\n if (!reported) publish(first);\n },\n () => undefined,\n );\n subscribe((next) => {\n reported = true;\n publish(next);\n });\n\n const host: G9HostServices = {\n exit: () => native.moveToBack(),\n hideKeyboard: () => native.hideKeyboard(),\n getSafeInsets: () => insets,\n subscribeSafeInsets(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n setSoftInputMode: (mode) => native.setSoftInputMode(mode),\n ...(typeof native.textFocus === 'function' ? { textFocus: (focused: boolean) => native.textFocus?.(focused) } : {}),\n ...(typeof native.screenProtection === 'function'\n ? {\n setScreenProtection: async (on: boolean) => {\n const state = await call<{ blocked?: unknown; captured?: unknown }>((reply) =>\n native.screenProtection?.(on, reply),\n );\n return { blocked: state?.blocked === true, captured: state?.captured === true };\n },\n }\n : {}),\n };\n const preferences: G9PreferenceStore = {\n async getInt(key, defaultValue) {\n const stored = await call<G9NativePreference | null>((reply) => native.getPreference(key, reply));\n return stored?.type === 'int' ? stored.value : defaultValue;\n },\n async setInt(key, value) {\n await call<null>((reply) => native.setPreference(key, 'int', String(value), reply));\n },\n async getString(key, defaultValue) {\n const stored = await call<G9NativePreference | null>((reply) => native.getPreference(key, reply));\n return stored?.type === 'string' ? stored.value : defaultValue;\n },\n async setString(key, value) {\n await call<null>((reply) => native.setPreference(key, 'string', value, reply));\n },\n async remove(key) {\n await call<null>((reply) => native.setPreference(key, 'remove', null, reply));\n },\n async entries(prefix): Promise<ReadonlyArray<readonly [string, G9PreferenceValue]>> {\n const list = await call<Array<[string, number | string]>>((reply) => native.preferenceEntries(prefix, reply));\n return list.map(([key, value]) => [key, value] as const);\n },\n };\n const appDataDirectory = async (): Promise<string> => {\n const dir = await call<string>((reply) => native.appDataDirectory(reply), 'host-data-directory');\n if (typeof dir !== 'string' || dir.trim() === '') {\n throw new G9Error('host-data-directory', 'The host reported no app data directory.');\n }\n return dir;\n };\n return { host, preferences, hapticTick: () => native.hapticTick(), appDataDirectory };\n}\n"],"names":["nativeHostModule","_ref","NativeModules","undefined","call","invoke","missingCode","Promise","resolve","reject","envelope","e","G9Error","lynxInsetsEvents","listener","lynx","target","handler","insets","NO_INSETS","Object","createNativeHostServices","options","_options_module","_options_insetsEvents","_options_insets","native","Error","subscribe","listeners","Set","mode","publish","reported","next","Array","reply","first","host","focused","on","state","preferences","key","defaultValue","stored","value","String","prefix","list","appDataDirectory","dir"],"mappings":";AAsBO,SAASA;IACd,IAAI;YACMC;QAAR,OAAO,QAACA,CAAAA,OAAAA,AAAyB,MAAzBA,OAAOC,gBAAgCC,SAAYD,QAAAA,gBAAAA,KAAAA,IAAAA,cAAe,YAAY,AAAD,IAA7ED,OAAmF;IAC7F,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEA,SAASG,KACPC,MAAgE,EAChEC,cAAc,kBAAkB;IAEhC,OAAO,IAAIC,QAAW,CAACC,SAASC;QAC9BJ,OAAO,CAACK;YACN,IAAIA,QAAAA,WAAAA,KAAAA,IAAAA,SAAU,EAAE,EAAEF,QAAQE,SAAS,KAAK;iBACnC;;gB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,IAAI,IAAI,IACrC,MAAM,IAAIvC,QAAQ,uBAAuB;QAE3C,OAAOuC;IACT;IACA,OAAO;QAAEb;QAAMI;QAAa,YAAY,IAAMhB,OAAO,UAAU;QAAIwB;IAAiB;AACtF"}
@@ -14,6 +14,7 @@ export interface G9HostModuleSpec {
14
14
  hapticTick(): void;
15
15
  appDataDirectory(callback: (reply: Record<string, unknown>) => void): void;
16
16
  assetUri(path: string, callback: (reply: Record<string, unknown>) => void): void;
17
+ screenProtection(on: boolean, callback: (reply: Record<string, unknown>) => void): void;
17
18
  }
18
19
 
19
20
  type AddonExports = Record<string, unknown>;
@@ -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