@g9tm/lynxcontrols-native 0.0.0-stage → 1.4.2

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 (70) hide show
  1. package/README.md +85 -2
  2. package/android/build.gradle.kts +45 -0
  3. package/android/consumer-rules.pro +3 -0
  4. package/android/src/main/AndroidManifest.xml +5 -0
  5. package/android/src/main/java/com/g9lynx/g9native/G9Bridge.kt +67 -0
  6. package/android/src/main/java/com/g9lynx/g9native/G9HostModule.kt +172 -0
  7. package/android/src/main/java/com/g9lynx/g9native/G9SqliteModule.kt +49 -0
  8. package/android/src/main/java/com/g9lynx/g9native/generated/G9HostModuleSpec.java +48 -0
  9. package/android/src/main/java/com/g9lynx/g9native/generated/G9SqliteModuleSpec.java +41 -0
  10. package/android/src/main/java/com/g9lynx/g9native/host/core/G9PreferencesCore.kt +100 -0
  11. package/android/src/main/java/com/g9lynx/g9native/sqlite/androidx/AndroidxSqlEngine.kt +88 -0
  12. package/android/src/main/java/com/g9lynx/g9native/sqlite/core/G9SqlEngine.kt +61 -0
  13. package/android/src/main/java/com/g9lynx/g9native/sqlite/core/G9SqliteCore.kt +260 -0
  14. package/android/src/main/java/com/g9lynx/g9native/sqlite/core/G9SqliteService.kt +131 -0
  15. package/android/src/main/java/com/g9lynx/g9native/sqlite/core/G9SqliteTransport.kt +125 -0
  16. package/android/src/main/java/com/g9lynx/g9native/sqlite/core/G9SqliteValues.kt +71 -0
  17. package/android/src/main/java/com/g9lynx/g9native/video/G9VideoUI.kt +220 -0
  18. package/android/src/main/java/com/g9lynx/g9native/video/core/G9VideoCore.kt +67 -0
  19. package/dist/.tsbuildinfo +1 -0
  20. package/dist/driver.d.ts +20 -0
  21. package/dist/driver.d.ts.map +1 -0
  22. package/dist/driver.js +159 -0
  23. package/dist/driver.js.map +1 -0
  24. package/dist/index.d.ts +5 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +3 -0
  27. package/dist/media.d.ts +60 -0
  28. package/dist/media.d.ts.map +1 -0
  29. package/dist/media.jsx +119 -0
  30. package/dist/media.jsx.map +1 -0
  31. package/dist/protocol.d.ts +115 -0
  32. package/dist/protocol.d.ts.map +1 -0
  33. package/dist/protocol.js +1 -0
  34. package/dist/services.d.ts +36 -0
  35. package/dist/services.d.ts.map +1 -0
  36. package/dist/services.js +111 -0
  37. package/dist/services.js.map +1 -0
  38. package/dist/transport.d.ts +10 -0
  39. package/dist/transport.d.ts.map +1 -0
  40. package/dist/transport.js +77 -0
  41. package/dist/transport.js.map +1 -0
  42. package/generated/G9HostModule.ts +71 -0
  43. package/generated/G9SqliteModule.ts +68 -0
  44. package/ios/Tests/G9NativeTestSuite.h +25 -0
  45. package/ios/Tests/G9NativeTestSuite.m +560 -0
  46. package/ios/Tests/G9NativeTests.m +52 -0
  47. package/ios/g9lynx-native.podspec +29 -0
  48. package/ios/src/G9HostModule.h +14 -0
  49. package/ios/src/G9HostModule.m +121 -0
  50. package/ios/src/G9SqliteModule.h +14 -0
  51. package/ios/src/G9SqliteModule.m +167 -0
  52. package/ios/src/G9VideoUI.h +21 -0
  53. package/ios/src/G9VideoUI.m +250 -0
  54. package/ios/src/core/G9HostPaths.h +20 -0
  55. package/ios/src/core/G9HostPaths.m +23 -0
  56. package/ios/src/core/G9PreferencesCore.h +43 -0
  57. package/ios/src/core/G9PreferencesCore.m +114 -0
  58. package/ios/src/core/G9SqliteCore.h +62 -0
  59. package/ios/src/core/G9SqliteCore.m +497 -0
  60. package/ios/src/core/G9SqliteTransport.h +16 -0
  61. package/ios/src/core/G9SqliteTransport.m +85 -0
  62. package/ios/src/core/G9VideoCore.h +26 -0
  63. package/ios/src/core/G9VideoCore.m +37 -0
  64. package/ios/src/generated/G9HostModuleSpec.h +23 -0
  65. package/ios/src/generated/G9HostModuleSpec.m +2 -0
  66. package/ios/src/generated/G9SqliteModuleSpec.h +20 -0
  67. package/ios/src/generated/G9SqliteModuleSpec.m +2 -0
  68. package/lynx.lib.json +12 -0
  69. package/package.json +49 -4
  70. package/types/platform-native-module.d.ts +46 -0
@@ -0,0 +1,77 @@
1
+ const tagOf = (value)=>Object.prototype.toString.call(value);
2
+ function toArrayBuffer(value) {
3
+ if (value instanceof ArrayBuffer) return value;
4
+ if (null === value || 'object' != typeof value) return null;
5
+ if ('[object ArrayBuffer]' === tagOf(value)) {
6
+ const copy = new Uint8Array(value.byteLength);
7
+ copy.set(new Uint8Array(value));
8
+ return copy.buffer;
9
+ }
10
+ if (ArrayBuffer.isView(value)) {
11
+ const copy = new Uint8Array(value.byteLength);
12
+ copy.set(new Uint8Array(value.buffer, value.byteOffset, value.byteLength));
13
+ return copy.buffer;
14
+ }
15
+ return null;
16
+ }
17
+ function cell(value) {
18
+ if (null == value) return null;
19
+ if ('number' == typeof value || 'string' == typeof value) return value;
20
+ const bytes = toArrayBuffer(value);
21
+ if (bytes) return bytes;
22
+ return {
23
+ int64: String(value.int64)
24
+ };
25
+ }
26
+ function decodeRows(result) {
27
+ return {
28
+ columns: result.columns,
29
+ rows: result.rows.map((row)=>row.map(cell)),
30
+ changes: result.changes,
31
+ lastInsertRowId: cell(result.lastInsertRowId)
32
+ };
33
+ }
34
+ function decodeColumnar(result) {
35
+ const types = new Uint8Array(toArrayBuffer(result.types));
36
+ const numbersBuffer = toArrayBuffer(result.numbers);
37
+ const numbers = new DataView(numbersBuffer);
38
+ const blobs = toArrayBuffer(result.blobs);
39
+ const width = result.columns.length;
40
+ const rows = [];
41
+ let cellIndex = 0;
42
+ let numberOffset = 0;
43
+ let stringIndex = 0;
44
+ let blobOffset = 0;
45
+ for(let r = 0; r < result.rowCount; r++){
46
+ const row = new Array(width);
47
+ for(let c = 0; c < width; c++){
48
+ const tag = types[cellIndex++];
49
+ if (1 === tag) {
50
+ row[c] = numbers.getFloat64(numberOffset, true);
51
+ numberOffset += 8;
52
+ } else if (2 === tag) row[c] = {
53
+ int64: result.strings[stringIndex++]
54
+ };
55
+ else if (3 === tag) row[c] = result.strings[stringIndex++];
56
+ else if (4 === tag) {
57
+ const length = numbers.getFloat64(numberOffset, true);
58
+ numberOffset += 8;
59
+ row[c] = blobs.slice(blobOffset, blobOffset + length);
60
+ blobOffset += length;
61
+ } else row[c] = null;
62
+ }
63
+ rows.push(row);
64
+ }
65
+ return {
66
+ columns: result.columns,
67
+ rows,
68
+ changes: result.changes,
69
+ lastInsertRowId: cell(result.lastInsertRowId)
70
+ };
71
+ }
72
+ function decodeRunValue(value) {
73
+ return 'rows' === value.transport ? value.results.map(decodeRows) : value.results.map(decodeColumnar);
74
+ }
75
+ export { decodeRunValue, toArrayBuffer };
76
+
77
+ //# sourceMappingURL=transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.js","sources":["../src/transport.ts"],"sourcesContent":["// Decoding of the two result transports (plan/specs/06 §6) into G9SqlResult. The Kotlin encoder is\n// android/…/sqlite/core/G9SqliteTransport.kt; contract/transport-golden.json pins the bytes both sides agree on.\nimport type { G9SqlResult, G9SqlValue } from '@g9tm/lynxcontrols-sqlite';\nimport type { G9ColumnarResult, G9NativeRunValue, G9RowsResult } from './protocol';\n\nconst tagOf = (value: unknown) => Object.prototype.toString.call(value);\n\n/**\n * Binary data from the bridge as this realm's ArrayBuffer: Lynx hands `byte[]` / `NSData` over as an ArrayBuffer, which\n * may belong to another realm, or (some hosts) as a typed array.\n */\nexport function toArrayBuffer(value: unknown): ArrayBuffer | null {\n if (value instanceof ArrayBuffer) return value;\n if (value === null || typeof value !== 'object') return null;\n if (tagOf(value) === '[object ArrayBuffer]') {\n const copy = new Uint8Array((value as ArrayBuffer).byteLength);\n copy.set(new Uint8Array(value as ArrayBuffer));\n return copy.buffer;\n }\n if (ArrayBuffer.isView(value)) {\n const copy = new Uint8Array(value.byteLength);\n copy.set(new Uint8Array(value.buffer, value.byteOffset, value.byteLength));\n return copy.buffer;\n }\n return null;\n}\n\nfunction cell(value: unknown): G9SqlValue {\n if (value === null || value === undefined) return null;\n if (typeof value === 'number' || typeof value === 'string') return value;\n const bytes = toArrayBuffer(value);\n if (bytes) return bytes;\n return { int64: String((value as { int64: unknown }).int64) } as G9SqlValue;\n}\n\nfunction decodeRows(result: G9RowsResult): G9SqlResult {\n return {\n columns: result.columns,\n rows: result.rows.map((row) => row.map(cell)),\n changes: result.changes,\n lastInsertRowId: cell(result.lastInsertRowId),\n };\n}\n\nfunction decodeColumnar(result: G9ColumnarResult): G9SqlResult {\n const types = new Uint8Array(toArrayBuffer(result.types) as ArrayBuffer);\n const numbersBuffer = toArrayBuffer(result.numbers) as ArrayBuffer;\n const numbers = new DataView(numbersBuffer);\n const blobs = toArrayBuffer(result.blobs) as ArrayBuffer;\n const width = result.columns.length;\n const rows: G9SqlValue[][] = [];\n let cellIndex = 0;\n let numberOffset = 0;\n let stringIndex = 0;\n let blobOffset = 0;\n for (let r = 0; r < result.rowCount; r++) {\n const row: G9SqlValue[] = new Array(width);\n for (let c = 0; c < width; c++) {\n const tag = types[cellIndex++];\n if (tag === 1) {\n row[c] = numbers.getFloat64(numberOffset, true);\n numberOffset += 8;\n } else if (tag === 2) {\n row[c] = { int64: result.strings[stringIndex++] as string } as G9SqlValue;\n } else if (tag === 3) {\n row[c] = result.strings[stringIndex++] as string;\n } else if (tag === 4) {\n const length = numbers.getFloat64(numberOffset, true);\n numberOffset += 8;\n row[c] = blobs.slice(blobOffset, blobOffset + length);\n blobOffset += length;\n } else {\n row[c] = null;\n }\n }\n rows.push(row);\n }\n return { columns: result.columns, rows, changes: result.changes, lastInsertRowId: cell(result.lastInsertRowId) };\n}\n\n/** The results of one `run` reply. */\nexport function decodeRunValue(value: G9NativeRunValue): G9SqlResult[] {\n return value.transport === 'rows'\n ? value.results.map(decodeRows)\n : (value.results as G9ColumnarResult[]).map(decodeColumnar);\n}\n"],"names":["tagOf","value","Object","toArrayBuffer","ArrayBuffer","copy","Uint8Array","cell","bytes","String","decodeRows","result","row","decodeColumnar","types","numbersBuffer","numbers","DataView","blobs","width","rows","cellIndex","numberOffset","stringIndex","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@@ -0,0 +1,71 @@
1
+ // Generated by @lynx-js/autolink-codegen. Do not edit.
2
+
3
+ const ADDON_NAME = "G9HostModule";
4
+
5
+ export interface G9HostModuleSpec {
6
+ capabilities(callback: (reply: Record<string, unknown>) => void): void;
7
+ getPreference(key: string, callback: (reply: Record<string, unknown>) => void): void;
8
+ setPreference(key: string, kind: string, value: string | null, callback: (reply: Record<string, unknown>) => void): void;
9
+ preferenceEntries(prefix: string, callback: (reply: Record<string, unknown>) => void): void;
10
+ safeInsets(callback: (reply: Record<string, unknown>) => void): void;
11
+ moveToBack(): void;
12
+ hideKeyboard(): void;
13
+ setSoftInputMode(mode: string): void;
14
+ hapticTick(): void;
15
+ appDataDirectory(callback: (reply: Record<string, unknown>) => void): void;
16
+ assetUri(path: string, callback: (reply: Record<string, unknown>) => void): void;
17
+ }
18
+
19
+ type AddonExports = Record<string, unknown>;
20
+
21
+ declare let NativeModules: Record<string, unknown>;
22
+
23
+ declare global {
24
+ interface LynxNapiLoader {
25
+ load(moduleName: string): AddonExports | null | undefined;
26
+ }
27
+
28
+ // eslint-disable-next-line no-var
29
+ var __lynxNapiLoader: LynxNapiLoader | undefined;
30
+
31
+ function getNapiLoader(): LynxNapiLoader | undefined;
32
+ }
33
+
34
+ declare const lynx: {
35
+ getModuleLoader?(): LynxNapiLoader | undefined;
36
+ };
37
+
38
+ function getNativeModules(): Record<string, unknown> | undefined {
39
+ const globalObject = globalThis as unknown as {
40
+ NativeModules?: Record<string, unknown>;
41
+ };
42
+ return typeof NativeModules !== 'undefined'
43
+ ? NativeModules
44
+ : globalObject.NativeModules;
45
+ }
46
+
47
+ function installG9HostModuleShim(): void {
48
+
49
+ }
50
+
51
+ export function requireG9HostModule(): G9HostModuleSpec {
52
+ const nativeModules = getNativeModules();
53
+ const existingModule = nativeModules?.[ADDON_NAME];
54
+ if (existingModule !== undefined && existingModule !== null) {
55
+ return existingModule as G9HostModuleSpec;
56
+ }
57
+
58
+
59
+
60
+ throw new Error(`Native module "${ADDON_NAME}" is unavailable.`);
61
+ }
62
+
63
+ export const G9HostModule = new Proxy({}, {
64
+ get(_target, property) {
65
+ return requireG9HostModule()[property as keyof G9HostModuleSpec];
66
+ },
67
+ }) as G9HostModuleSpec;
68
+
69
+ installG9HostModuleShim();
70
+
71
+ export default G9HostModule;
@@ -0,0 +1,68 @@
1
+ // Generated by @lynx-js/autolink-codegen. Do not edit.
2
+
3
+ const ADDON_NAME = "G9SqliteModule";
4
+
5
+ export interface G9SqliteModuleSpec {
6
+ capabilities(callback: (reply: Record<string, unknown>) => void): void;
7
+ open(options: Record<string, unknown>, callback: (reply: Record<string, unknown>) => void): void;
8
+ run(session: string, statements: unknown[], options: Record<string, unknown>, callback: (reply: Record<string, unknown>) => void): void;
9
+ begin(session: string, mode: string, callback: (reply: Record<string, unknown>) => void): void;
10
+ commit(tx: string, callback: (reply: Record<string, unknown>) => void): void;
11
+ rollback(tx: string, callback: (reply: Record<string, unknown>) => void): void;
12
+ close(session: string, callback: (reply: Record<string, unknown>) => void): void;
13
+ interrupt(session: string): void;
14
+ }
15
+
16
+ type AddonExports = Record<string, unknown>;
17
+
18
+ declare let NativeModules: Record<string, unknown>;
19
+
20
+ declare global {
21
+ interface LynxNapiLoader {
22
+ load(moduleName: string): AddonExports | null | undefined;
23
+ }
24
+
25
+ // eslint-disable-next-line no-var
26
+ var __lynxNapiLoader: LynxNapiLoader | undefined;
27
+
28
+ function getNapiLoader(): LynxNapiLoader | undefined;
29
+ }
30
+
31
+ declare const lynx: {
32
+ getModuleLoader?(): LynxNapiLoader | undefined;
33
+ };
34
+
35
+ function getNativeModules(): Record<string, unknown> | undefined {
36
+ const globalObject = globalThis as unknown as {
37
+ NativeModules?: Record<string, unknown>;
38
+ };
39
+ return typeof NativeModules !== 'undefined'
40
+ ? NativeModules
41
+ : globalObject.NativeModules;
42
+ }
43
+
44
+ function installG9SqliteModuleShim(): void {
45
+
46
+ }
47
+
48
+ export function requireG9SqliteModule(): G9SqliteModuleSpec {
49
+ const nativeModules = getNativeModules();
50
+ const existingModule = nativeModules?.[ADDON_NAME];
51
+ if (existingModule !== undefined && existingModule !== null) {
52
+ return existingModule as G9SqliteModuleSpec;
53
+ }
54
+
55
+
56
+
57
+ throw new Error(`Native module "${ADDON_NAME}" is unavailable.`);
58
+ }
59
+
60
+ export const G9SqliteModule = new Proxy({}, {
61
+ get(_target, property) {
62
+ return requireG9SqliteModule()[property as keyof G9SqliteModuleSpec];
63
+ },
64
+ }) as G9SqliteModuleSpec;
65
+
66
+ installG9SqliteModuleShim();
67
+
68
+ export default G9SqliteModule;
@@ -0,0 +1,25 @@
1
+ // The iOS core's test suite, portable Objective-C (Foundation + sqlite3, no blocks): XCTest runs it on a simulator
2
+ // (G9NativeTests.m) and `npm run test:ios-core` runs it on Linux with clang + GNUstep. Each check returns its failures
3
+ // (empty = pass).
4
+ #import <Foundation/Foundation.h>
5
+
6
+ NS_ASSUME_NONNULL_BEGIN
7
+
8
+ @interface G9NativeTestSuite : NSObject
9
+ /** `packages/sqlite/contract/cases.json` through G9SqliteCore + G9SqliteTransport (`columnar` or `rows`) + decoder. */
10
+ + (NSArray *)contractWithRepo:(NSString *)repo transport:(NSString *)transport passed:(NSInteger *_Nullable)passed;
11
+ /** The ObjC encoder reproduces `packages/native/contract/transport-golden.json` (written by the Kotlin encoder). */
12
+ + (NSArray *)goldenWithRepo:(NSString *)repo;
13
+ /** `interrupt:` from another thread stops a running statement with `interrupted`. */
14
+ + (NSArray *)interrupt;
15
+ /** Core edges: misuse paths, tokens, cache eviction, capabilities. */
16
+ + (NSArray *)coreEdges;
17
+ /** G9PreferencesCore over the memory backend. */
18
+ + (NSArray *)preferences;
19
+ /** G9HostPaths: the app data directory, bundled asset URIs (missing, directory, escaping paths). */
20
+ + (NSArray *)hostPaths;
21
+ /** G9VideoLoopTracker and G9VideoMath (the `<g9-video>` rules shared with Android). */
22
+ + (NSArray *)videoCore;
23
+ @end
24
+
25
+ NS_ASSUME_NONNULL_END