@sigx/lynx-core 0.1.2 → 0.4.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/README.md +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +48 -9
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
- package/dist/bridge.js +0 -79
- package/dist/bridge.js.map +0 -1
- package/dist/permissions.js +0 -9
- package/dist/permissions.js.map +0 -1
package/README.md
CHANGED
|
@@ -28,4 +28,4 @@ For modules that need runtime permissions (camera, location, notifications, …)
|
|
|
28
28
|
|
|
29
29
|
## Linking
|
|
30
30
|
|
|
31
|
-
Native modules are wired by `@sigx/lynx-cli`'s autolinker
|
|
31
|
+
Native modules are wired by `@sigx/lynx-cli`'s autolinker. Install the package (`pnpm add @sigx/lynx-foo`), run `sigx prebuild`, and the generated registry takes care of the rest — the `signalx-module.json` manifest each module ships is what makes auto-discovery work.
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
|
-
export { getModule, callSync, callAsync, isModuleAvailable, guardModule } from './bridge
|
|
10
|
-
export type { PermissionStatus, PermissionResponse } from './permissions
|
|
9
|
+
export { getModule, callSync, callAsync, isModuleAvailable, guardModule } from './bridge';
|
|
10
|
+
export type { PermissionStatus, PermissionResponse } from './permissions';
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +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,
|
|
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,UAAU,CAAC;AAC1F,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
//#region src/bridge.ts
|
|
2
|
+
var e = {
|
|
3
|
+
Haptics: "@sigx/lynx-haptics",
|
|
4
|
+
Clipboard: "@sigx/lynx-clipboard",
|
|
5
|
+
Storage: "@sigx/lynx-storage",
|
|
6
|
+
DeviceInfo: "@sigx/lynx-device-info",
|
|
7
|
+
Share: "@sigx/lynx-share",
|
|
8
|
+
Camera: "@sigx/lynx-camera",
|
|
9
|
+
Location: "@sigx/lynx-location",
|
|
10
|
+
ImagePicker: "@sigx/lynx-image-picker",
|
|
11
|
+
FileSystem: "@sigx/lynx-file-system",
|
|
12
|
+
Notifications: "@sigx/lynx-notifications",
|
|
13
|
+
Network: "@sigx/lynx-network",
|
|
14
|
+
Linking: "@sigx/lynx-linking",
|
|
15
|
+
WebSocket: "@sigx/lynx-websocket"
|
|
16
|
+
};
|
|
17
|
+
function t(t) {
|
|
18
|
+
if (typeof NativeModules > "u" || !NativeModules[t]) {
|
|
19
|
+
let n = e[t] ?? `@sigx/lynx-${t.toLowerCase()}`;
|
|
20
|
+
throw Error(`[@sigx/lynx-core] Module "${t}" is not available.\n\nThis usually means one of:\n 1. You're not running in sigx-lynx-go (which has all modules pre-bundled)\n 2. For custom builds, install "${n}" (\`pnpm add ${n}\`) and run\n \`sigx prebuild\` to regenerate the native project.\n 3. The native module failed to register — check native logs for errors.`);
|
|
21
|
+
}
|
|
22
|
+
return NativeModules[t];
|
|
23
|
+
}
|
|
24
|
+
function n(e, n, ...r) {
|
|
25
|
+
return t(e)[n](...r);
|
|
26
|
+
}
|
|
27
|
+
function r(e, n, ...r) {
|
|
28
|
+
return new Promise((i, a) => {
|
|
29
|
+
try {
|
|
30
|
+
t(e)[n](...r, (e) => i(e));
|
|
31
|
+
} catch (e) {
|
|
32
|
+
a(e);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function i(e) {
|
|
37
|
+
try {
|
|
38
|
+
return typeof NativeModules < "u" && NativeModules[e] != null;
|
|
39
|
+
} catch {
|
|
40
|
+
return !1;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function a(e) {
|
|
44
|
+
i(e) || t(e);
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { r as callAsync, n as callSync, t as getModule, a as guardModule, i as isModuleAvailable };
|
|
48
|
+
|
|
10
49
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/bridge.ts"],"sourcesContent":["/**\n * Low-level bridge to LynxJS NativeModules.\n *\n * NativeModules is a global object injected by the Lynx runtime.\n * Each registered native module (e.g. Haptics) appears as a property.\n */\n\ndeclare const NativeModules: Record<string, Record<string, (...args: any[]) => any>>;\n\n/** Known module → package mapping for actionable error messages. */\nconst MODULE_PACKAGES: Record<string, string> = {\n Haptics: '@sigx/lynx-haptics',\n Clipboard: '@sigx/lynx-clipboard',\n Storage: '@sigx/lynx-storage',\n DeviceInfo: '@sigx/lynx-device-info',\n Share: '@sigx/lynx-share',\n Camera: '@sigx/lynx-camera',\n Location: '@sigx/lynx-location',\n ImagePicker: '@sigx/lynx-image-picker',\n FileSystem: '@sigx/lynx-file-system',\n Notifications: '@sigx/lynx-notifications',\n Network: '@sigx/lynx-network',\n Linking: '@sigx/lynx-linking',\n WebSocket: '@sigx/lynx-websocket',\n};\n\n/**\n * Get a native module by name. Throws with actionable error if unavailable.\n */\nexport function getModule(name: string): Record<string, (...args: any[]) => any> {\n if (typeof NativeModules === 'undefined' || !NativeModules[name]) {\n const pkg = MODULE_PACKAGES[name] ?? `@sigx/lynx-${name.toLowerCase()}`;\n throw new Error(\n `[@sigx/lynx-core] Module \"${name}\" is not available.\\n` +\n `\\n` +\n `This usually means one of:\\n` +\n ` 1. You're not running in sigx-lynx-go (which has all modules pre-bundled)\\n` +\n ` 2. For custom builds, install \"${pkg}\" (\\`pnpm add ${pkg}\\`) and run\\n` +\n ` \\`sigx prebuild\\` to regenerate the native project.\\n` +\n ` 3. The native module failed to register — check native logs for errors.`\n );\n }\n return NativeModules[name];\n}\n\n/**\n * Call a sync native method. Returns the result directly.\n */\nexport function callSync<T = void>(module: string, method: string, ...args: any[]): T {\n return getModule(module)[method](...args) as T;\n}\n\n/**\n * Call an async native method that uses a callback as its last argument.\n * Wraps the callback in a Promise.\n */\nexport function callAsync<T = any>(module: string, method: string, ...args: any[]): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n try {\n getModule(module)[method](...args, (result: T) => resolve(result));\n } catch (e) {\n reject(e);\n }\n });\n}\n\n/**\n * Check if a native module is registered in the current runtime.\n */\nexport function isModuleAvailable(name: string): boolean {\n try {\n return typeof NativeModules !== 'undefined' && NativeModules[name] != null;\n } catch {\n return false;\n }\n}\n\n/**\n * Guard that throws if a module is not available.\n * Use at the top of module wrapper functions for early, clear errors.\n */\nexport function guardModule(name: string): void {\n if (!isModuleAvailable(name)) {\n getModule(name); // triggers the descriptive error\n }\n}\n"],"mappings":";AAUA,IAAM,IAA0C;CAC5C,SAAS;CACT,WAAW;CACX,SAAS;CACT,YAAY;CACZ,OAAO;CACP,QAAQ;CACR,UAAU;CACV,aAAa;CACb,YAAY;CACZ,eAAe;CACf,SAAS;CACT,SAAS;CACT,WAAW;CACd;AAKD,SAAgB,EAAU,GAAuD;CAC7E,IAAI,OAAO,gBAAkB,OAAe,CAAC,cAAc,IAAO;EAC9D,IAAM,IAAM,EAAgB,MAAS,cAAc,EAAK,aAAa;EACrE,MAAU,MACN,6BAA6B,EAAK,mKAIE,EAAI,gBAAgB,EAAI,kJAG/D;;CAEL,OAAO,cAAc;;AAMzB,SAAgB,EAAmB,GAAgB,GAAgB,GAAG,GAAgB;CAClF,OAAO,EAAU,EAAO,CAAC,GAAQ,GAAG,EAAK;;AAO7C,SAAgB,EAAmB,GAAgB,GAAgB,GAAG,GAAyB;CAC3F,OAAO,IAAI,SAAY,GAAS,MAAW;EACvC,IAAI;GACA,EAAU,EAAO,CAAC,GAAQ,GAAG,IAAO,MAAc,EAAQ,EAAO,CAAC;WAC7D,GAAG;GACR,EAAO,EAAE;;GAEf;;AAMN,SAAgB,EAAkB,GAAuB;CACrD,IAAI;EACA,OAAO,OAAO,gBAAkB,OAAe,cAAc,MAAS;SAClE;EACJ,OAAO;;;AAQf,SAAgB,EAAY,GAAoB;CAC5C,AAAK,EAAkB,EAAK,IACxB,EAAU,EAAK"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sigx/lynx-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Core native bridge for sigx-lynx — low-level access to NativeModules",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"directory": "packages/lynx-core"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"typescript": "^6.0.3"
|
|
31
|
+
"typescript": "^6.0.3",
|
|
32
|
+
"@sigx/vite": "^0.4.3"
|
|
32
33
|
},
|
|
33
34
|
"homepage": "https://github.com/signalxjs/lynx/tree/main/packages/lynx-core",
|
|
34
35
|
"bugs": {
|
|
@@ -38,7 +39,7 @@
|
|
|
38
39
|
"access": "public"
|
|
39
40
|
},
|
|
40
41
|
"scripts": {
|
|
41
|
-
"build": "
|
|
42
|
-
"dev": "
|
|
42
|
+
"build": "vite build && tsgo --emitDeclarationOnly",
|
|
43
|
+
"dev": "vite build --watch"
|
|
43
44
|
}
|
|
44
45
|
}
|
package/dist/bridge.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
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
|
-
WebSocket: '@sigx/lynx-websocket',
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Get a native module by name. Throws with actionable error if unavailable.
|
|
25
|
-
*/
|
|
26
|
-
export function getModule(name) {
|
|
27
|
-
if (typeof NativeModules === 'undefined' || !NativeModules[name]) {
|
|
28
|
-
const pkg = MODULE_PACKAGES[name] ?? `@sigx/lynx-${name.toLowerCase()}`;
|
|
29
|
-
throw new Error(`[@sigx/lynx-core] Module "${name}" is not available.\n` +
|
|
30
|
-
`\n` +
|
|
31
|
-
`This usually means one of:\n` +
|
|
32
|
-
` 1. You're not running in sigx-lynx-go (which has all modules pre-bundled)\n` +
|
|
33
|
-
` 2. For custom builds, add "${pkg}" to your sigx.lynx.config.ts modules array\n` +
|
|
34
|
-
` and run \`sigx-lynx prebuild\` to regenerate the native project.\n` +
|
|
35
|
-
` 3. The native module failed to register — check native logs for errors.`);
|
|
36
|
-
}
|
|
37
|
-
return NativeModules[name];
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Call a sync native method. Returns the result directly.
|
|
41
|
-
*/
|
|
42
|
-
export function callSync(module, method, ...args) {
|
|
43
|
-
return getModule(module)[method](...args);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Call an async native method that uses a callback as its last argument.
|
|
47
|
-
* Wraps the callback in a Promise.
|
|
48
|
-
*/
|
|
49
|
-
export function callAsync(module, method, ...args) {
|
|
50
|
-
return new Promise((resolve, reject) => {
|
|
51
|
-
try {
|
|
52
|
-
getModule(module)[method](...args, (result) => resolve(result));
|
|
53
|
-
}
|
|
54
|
-
catch (e) {
|
|
55
|
-
reject(e);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Check if a native module is registered in the current runtime.
|
|
61
|
-
*/
|
|
62
|
-
export function isModuleAvailable(name) {
|
|
63
|
-
try {
|
|
64
|
-
return typeof NativeModules !== 'undefined' && NativeModules[name] != null;
|
|
65
|
-
}
|
|
66
|
-
catch {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Guard that throws if a module is not available.
|
|
72
|
-
* Use at the top of module wrapper functions for early, clear errors.
|
|
73
|
-
*/
|
|
74
|
-
export function guardModule(name) {
|
|
75
|
-
if (!isModuleAvailable(name)) {
|
|
76
|
-
getModule(name); // triggers the descriptive error
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
//# sourceMappingURL=bridge.js.map
|
package/dist/bridge.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version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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/permissions.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
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
|
package/dist/permissions.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|