@sigx/lynx-core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/bridge.d.ts +29 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/bridge.js +78 -0
- package/dist/bridge.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/permissions.d.ts +21 -0
- package/dist/permissions.d.ts.map +1 -0
- package/dist/permissions.js +9 -0
- package/dist/permissions.js.map +1 -0
- package/package.json +37 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Andreas Ekdahl
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/bridge.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Low-level bridge to LynxJS NativeModules.
|
|
3
|
+
*
|
|
4
|
+
* NativeModules is a global object injected by the Lynx runtime.
|
|
5
|
+
* Each registered native module (e.g. Haptics) appears as a property.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Get a native module by name. Throws with actionable error if unavailable.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getModule(name: string): Record<string, (...args: any[]) => any>;
|
|
11
|
+
/**
|
|
12
|
+
* Call a sync native method. Returns the result directly.
|
|
13
|
+
*/
|
|
14
|
+
export declare function callSync<T = void>(module: string, method: string, ...args: any[]): T;
|
|
15
|
+
/**
|
|
16
|
+
* Call an async native method that uses a callback as its last argument.
|
|
17
|
+
* Wraps the callback in a Promise.
|
|
18
|
+
*/
|
|
19
|
+
export declare function callAsync<T = any>(module: string, method: string, ...args: any[]): Promise<T>;
|
|
20
|
+
/**
|
|
21
|
+
* Check if a native module is registered in the current runtime.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isModuleAvailable(name: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Guard that throws if a module is not available.
|
|
26
|
+
* Use at the top of module wrapper functions for early, clear errors.
|
|
27
|
+
*/
|
|
28
|
+
export declare function guardModule(name: string): void;
|
|
29
|
+
//# sourceMappingURL=bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoBH;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,CAc/E;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAEpF;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,GAAG,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAQ7F;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAMvD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAI9C"}
|
package/dist/bridge.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Low-level bridge to LynxJS NativeModules.
|
|
3
|
+
*
|
|
4
|
+
* NativeModules is a global object injected by the Lynx runtime.
|
|
5
|
+
* Each registered native module (e.g. Haptics) appears as a property.
|
|
6
|
+
*/
|
|
7
|
+
/** Known module → package mapping for actionable error messages. */
|
|
8
|
+
const MODULE_PACKAGES = {
|
|
9
|
+
Haptics: '@sigx/lynx-haptics',
|
|
10
|
+
Clipboard: '@sigx/lynx-clipboard',
|
|
11
|
+
Storage: '@sigx/lynx-storage',
|
|
12
|
+
DeviceInfo: '@sigx/lynx-device-info',
|
|
13
|
+
Share: '@sigx/lynx-share',
|
|
14
|
+
Camera: '@sigx/lynx-camera',
|
|
15
|
+
Location: '@sigx/lynx-location',
|
|
16
|
+
ImagePicker: '@sigx/lynx-image-picker',
|
|
17
|
+
FileSystem: '@sigx/lynx-file-system',
|
|
18
|
+
Notifications: '@sigx/lynx-notifications',
|
|
19
|
+
Network: '@sigx/lynx-network',
|
|
20
|
+
Linking: '@sigx/lynx-linking',
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Get a native module by name. Throws with actionable error if unavailable.
|
|
24
|
+
*/
|
|
25
|
+
export function getModule(name) {
|
|
26
|
+
if (typeof NativeModules === 'undefined' || !NativeModules[name]) {
|
|
27
|
+
const pkg = MODULE_PACKAGES[name] ?? `@sigx/lynx-${name.toLowerCase()}`;
|
|
28
|
+
throw new Error(`[@sigx/lynx-core] Module "${name}" is not available.\n` +
|
|
29
|
+
`\n` +
|
|
30
|
+
`This usually means one of:\n` +
|
|
31
|
+
` 1. You're not running in sigx-lynx-go (which has all modules pre-bundled)\n` +
|
|
32
|
+
` 2. For custom builds, add "${pkg}" to your sigx.lynx.config.ts modules array\n` +
|
|
33
|
+
` and run \`sigx-lynx prebuild\` to regenerate the native project.\n` +
|
|
34
|
+
` 3. The native module failed to register — check native logs for errors.`);
|
|
35
|
+
}
|
|
36
|
+
return NativeModules[name];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Call a sync native method. Returns the result directly.
|
|
40
|
+
*/
|
|
41
|
+
export function callSync(module, method, ...args) {
|
|
42
|
+
return getModule(module)[method](...args);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Call an async native method that uses a callback as its last argument.
|
|
46
|
+
* Wraps the callback in a Promise.
|
|
47
|
+
*/
|
|
48
|
+
export function callAsync(module, method, ...args) {
|
|
49
|
+
return new Promise((resolve, reject) => {
|
|
50
|
+
try {
|
|
51
|
+
getModule(module)[method](...args, (result) => resolve(result));
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
reject(e);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Check if a native module is registered in the current runtime.
|
|
60
|
+
*/
|
|
61
|
+
export function isModuleAvailable(name) {
|
|
62
|
+
try {
|
|
63
|
+
return typeof NativeModules !== 'undefined' && NativeModules[name] != null;
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Guard that throws if a module is not available.
|
|
71
|
+
* Use at the top of module wrapper functions for early, clear errors.
|
|
72
|
+
*/
|
|
73
|
+
export function guardModule(name) {
|
|
74
|
+
if (!isModuleAvailable(name)) {
|
|
75
|
+
getModule(name); // triggers the descriptive error
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,oEAAoE;AACpE,MAAM,eAAe,GAA2B;IAC5C,OAAO,EAAE,oBAAoB;IAC7B,SAAS,EAAE,sBAAsB;IACjC,OAAO,EAAE,oBAAoB;IAC7B,UAAU,EAAE,wBAAwB;IACpC,KAAK,EAAE,kBAAkB;IACzB,MAAM,EAAE,mBAAmB;IAC3B,QAAQ,EAAE,qBAAqB;IAC/B,WAAW,EAAE,yBAAyB;IACtC,UAAU,EAAE,wBAAwB;IACpC,aAAa,EAAE,0BAA0B;IACzC,OAAO,EAAE,oBAAoB;IAC7B,OAAO,EAAE,oBAAoB;CAChC,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY;IAClC,IAAI,OAAO,aAAa,KAAK,WAAW,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/D,MAAM,GAAG,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,cAAc,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;QACxE,MAAM,IAAI,KAAK,CACX,6BAA6B,IAAI,uBAAuB;YACxD,IAAI;YACJ,8BAA8B;YAC9B,+EAA+E;YAC/E,gCAAgC,GAAG,+CAA+C;YAClF,yEAAyE;YACzE,2EAA2E,CAC9E,CAAC;IACN,CAAC;IACD,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAW,MAAc,EAAE,MAAc,EAAE,GAAG,IAAW;IAC7E,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAM,CAAC;AACnD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAU,MAAc,EAAE,MAAc,EAAE,GAAG,IAAW;IAC7E,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,IAAI,CAAC;YACD,SAAS,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,MAAS,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;QACvE,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,MAAM,CAAC,CAAC,CAAC,CAAC;QACd,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC1C,IAAI,CAAC;QACD,OAAO,OAAO,aAAa,KAAK,WAAW,IAAI,aAAa,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;IAC/E,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,KAAK,CAAC;IACjB,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY;IACpC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,iCAAiC;IACtD,CAAC;AACL,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @sigx/lynx-core — Core native bridge for sigx-lynx
|
|
3
|
+
*
|
|
4
|
+
* Provides the low-level bridge to NativeModules injected by the Lynx runtime.
|
|
5
|
+
* Module packages (@sigx/lynx-haptics, @sigx/lynx-camera, etc.) depend on this.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
export { getModule, callSync, callAsync, isModuleAvailable, guardModule } from './bridge.js';
|
|
10
|
+
export type { PermissionStatus, PermissionResponse } from './permissions.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC7F,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @sigx/lynx-core — Core native bridge for sigx-lynx
|
|
3
|
+
*
|
|
4
|
+
* Provides the low-level bridge to NativeModules injected by the Lynx runtime.
|
|
5
|
+
* Module packages (@sigx/lynx-haptics, @sigx/lynx-camera, etc.) depend on this.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
export { getModule, callSync, callAsync, isModuleAvailable, guardModule } from './bridge.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared permission types for sigx-lynx native modules.
|
|
3
|
+
*
|
|
4
|
+
* All module packages that deal with permissions import these types from
|
|
5
|
+
* @sigx/lynx-core for consistent API surfaces across Camera, Location,
|
|
6
|
+
* Notifications, ImagePicker, etc.
|
|
7
|
+
*/
|
|
8
|
+
/** Permission status returned by native modules. */
|
|
9
|
+
export type PermissionStatus = 'granted' | 'denied' | 'undetermined' | 'blocked';
|
|
10
|
+
/** Response from requestPermission() and getPermissionStatus() calls. */
|
|
11
|
+
export interface PermissionResponse {
|
|
12
|
+
/** Current permission status. */
|
|
13
|
+
status: PermissionStatus;
|
|
14
|
+
/**
|
|
15
|
+
* Whether the app can show the OS permission dialog again.
|
|
16
|
+
* `false` when the user selected "Don't ask again" (Android) or
|
|
17
|
+
* after the first denial (iOS — user must go to Settings).
|
|
18
|
+
*/
|
|
19
|
+
canAskAgain: boolean;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=permissions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,oDAAoD;AACpD,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,QAAQ,GAAG,cAAc,GAAG,SAAS,CAAC;AAEjF,yEAAyE;AACzE,MAAM,WAAW,kBAAkB;IAC/B,iCAAiC;IACjC,MAAM,EAAE,gBAAgB,CAAC;IACzB;;;;OAIG;IACH,WAAW,EAAE,OAAO,CAAC;CACxB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared permission types for sigx-lynx native modules.
|
|
3
|
+
*
|
|
4
|
+
* All module packages that deal with permissions import these types from
|
|
5
|
+
* @sigx/lynx-core for consistent API surfaces across Camera, Location,
|
|
6
|
+
* Notifications, ImagePicker, etc.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=permissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sigx/lynx-core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Core native bridge for sigx-lynx — low-level access to NativeModules",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"keywords": [
|
|
18
|
+
"sigx",
|
|
19
|
+
"lynx",
|
|
20
|
+
"native",
|
|
21
|
+
"bridge"
|
|
22
|
+
],
|
|
23
|
+
"author": "Andreas Ekdahl",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/signalxjs/core.git",
|
|
28
|
+
"directory": "packages/lynx-core"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"typescript": "^5.9.3"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc",
|
|
35
|
+
"dev": "tsc --watch"
|
|
36
|
+
}
|
|
37
|
+
}
|