@lynx-js/lynxtron 0.0.1 → 0.0.3

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 (51) hide show
  1. package/README.md +80 -0
  2. package/apis/api/app.d.ts +1848 -0
  3. package/apis/api/asar.d.ts +124 -0
  4. package/apis/api/base-window.d.ts +1712 -0
  5. package/apis/api/clipboard.d.ts +54 -0
  6. package/apis/api/command-line.d.ts +46 -0
  7. package/apis/api/context-bridge.d.ts +8 -0
  8. package/apis/api/devtool.d.ts +34 -0
  9. package/apis/api/dialog.d.ts +633 -0
  10. package/apis/api/dock.d.ts +88 -0
  11. package/apis/api/environment.d.ts +9 -0
  12. package/apis/api/event.d.ts +8 -0
  13. package/apis/api/jump-list-item.d.ts +83 -0
  14. package/apis/api/lynx-library.d.ts +7 -0
  15. package/apis/api/lynx-template-bundle.d.ts +32 -0
  16. package/apis/api/lynx-template-data.d.ts +10 -0
  17. package/apis/api/lynx-update-meta.d.ts +16 -0
  18. package/apis/api/lynx-window.d.ts +405 -0
  19. package/apis/api/menu.d.ts +96 -0
  20. package/apis/api/native-image.d.ts +268 -0
  21. package/apis/api/notification-response.d.ts +26 -0
  22. package/apis/api/notification.d.ts +242 -0
  23. package/apis/api/power-monitor.d.ts +121 -0
  24. package/apis/api/process-metric.d.ts +93 -0
  25. package/apis/api/protocol.d.ts +54 -0
  26. package/apis/api/screen.d.ts +222 -0
  27. package/apis/api/shell.d.ts +124 -0
  28. package/apis/api/task.d.ts +39 -0
  29. package/apis/api/touch-bar.d.ts +206 -0
  30. package/apis/api/tray.d.ts +44 -0
  31. package/apis/api/utility-process.d.ts +73 -0
  32. package/apis/lynx.d.ts +15 -0
  33. package/apis/lynxtron.d.ts +39 -0
  34. package/apis/structures/point.d.ts +10 -0
  35. package/apis/structures/rectangle.d.ts +22 -0
  36. package/apis/structures/size.d.ts +8 -0
  37. package/apis/web-host.d.ts +24 -0
  38. package/cli.js +28 -0
  39. package/context-bridge.js +6 -0
  40. package/fuses-cli.js +143 -0
  41. package/fuses.js +299 -0
  42. package/install.js +127 -0
  43. package/lynx.js +1 -0
  44. package/lynxtron.js +43 -0
  45. package/lynxtron_bin.js +10 -0
  46. package/native-paths.cjs +38 -0
  47. package/package.json +71 -4
  48. package/utils/download.js +72 -0
  49. package/utils/env-config.js +35 -0
  50. package/web-host/index.js +110 -0
  51. package/web-worker.js +12 -0
@@ -0,0 +1,35 @@
1
+ import os from 'node:os';
2
+ import path from 'node:path';
3
+ import fs from 'node:fs';
4
+ import { fileURLToPath } from 'node:url';
5
+
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
8
+
9
+ function getPlatformPath (platform) {
10
+ switch (platform) {
11
+ case 'mas':
12
+ case 'darwin':
13
+ return 'lynxtron.app/Contents/MacOS/lynxtron';
14
+ // case 'freebsd':
15
+ // case 'openbsd':
16
+ // case 'linux':
17
+ // return 'lynxtron';
18
+ case 'win32':
19
+ return 'lynxtron.exe';
20
+ default:
21
+ throw new Error('lynxtron builds are not available on platform: ' + platform);
22
+ }
23
+ }
24
+
25
+ export const BASE_URL = 'https://github.com/lynx-family/lynxtron/releases/download/';
26
+
27
+ const pckJson = JSON.parse(fs.readFileSync(path.join(__dirname, "..", 'package.json'), 'utf8'));
28
+
29
+ export const VERSION = pckJson.version;
30
+
31
+ export const ARCH = process.env.npm_config_arch || process.arch;
32
+
33
+ export const PLATFORM = process.env.npm_config_platform || os.platform();
34
+
35
+ export const PLATFROM_EXE_PATH = getPlatformPath(PLATFORM);
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Lynxtron Web Host Infrastructure
3
+ * Provides NativeModule simulation for Lynx running in Browser.
4
+ */
5
+
6
+ /**
7
+ * Creates a JS source string for the Native Module proxy (RPC mode).
8
+ */
9
+ function createProxyCode(moduleName, methods) {
10
+ const methodStrings = methods.map(method => `
11
+ async ${method}(...args) {
12
+ const callback = typeof args[args.length - 1] === 'function' ? args.pop() : null;
13
+ const res = await NativeModulesCall('${moduleName}:${method}', args);
14
+ if (typeof callback === 'function') {
15
+ callback(res);
16
+ }
17
+ }`).join(',');
18
+
19
+ return `
20
+ export default function(NativeModules, NativeModulesCall) {
21
+ return {
22
+ ${methodStrings}
23
+ };
24
+ };
25
+ `;
26
+ }
27
+
28
+ /**
29
+ * Setup Symmetric Host for Web.
30
+ * @param {any} lynxView The <lynx-view> element.
31
+ * @param {object} config Configuration for bridge and nodejs.
32
+ */
33
+ export function setupSymmetricHost(lynxView, config = {}) {
34
+ const nativeModulesMap = {};
35
+ const handlers = {};
36
+
37
+ // 1. Setup Main Thread Bridge (bridge) - RPC Mode
38
+ if (config.bridge) {
39
+ const bridgeMethods = Object.keys(config.bridge);
40
+ const code = createProxyCode('bridge', bridgeMethods);
41
+ const blob = new Blob([code], { type: 'text/javascript' });
42
+ nativeModulesMap['bridge'] = URL.createObjectURL(blob);
43
+
44
+ for (const [methodName, handler] of Object.entries(config.bridge)) {
45
+ handlers[`bridge:${methodName}`] = handler;
46
+ }
47
+ }
48
+
49
+ // 2. Setup Background Service (nodejs) - Direct Injection Mode
50
+ // In Lynxtron PC, NativeModules.nodejs runs in the same Background Thread.
51
+ // In Web, we achieve this by importScripts() inside the Proxy Blob.
52
+ if (config.nodejs && config.nodejs.scriptURL) {
53
+ const { scriptURL } = config.nodejs;
54
+ // Resolve relative URL to absolute URL in main thread
55
+ const absoluteScriptURL = new URL(scriptURL, window.location.href).href;
56
+ console.log('[Lynxtron Web] Configuring nodejs module with script:', absoluteScriptURL);
57
+
58
+ const code = `
59
+ export default function(NativeModules, NativeModulesCall) {
60
+ console.log('[Lynxtron Web] Initializing nodejs module proxy in context:', self.constructor.name);
61
+ try {
62
+ console.log('[Lynxtron Web] Loading script:', '${absoluteScriptURL}');
63
+
64
+ // Polyfill contextBridge for Web Adapter
65
+ self.contextBridge = {
66
+ exposeInLynxBTS: (exports) => {
67
+ self.__lynxtron_nodejs_exports__ = exports;
68
+ }
69
+ };
70
+
71
+ // Load the logic script into Lynx Background Worker
72
+ importScripts('${absoluteScriptURL}');
73
+
74
+ // Retrieve capabilities from global registry
75
+ const exports = self.__lynxtron_nodejs_exports__ || {};
76
+ console.log('[Lynxtron Web] Discovered exports:',exports);
77
+
78
+ return {
79
+ exposed: exports,
80
+ };
81
+ } catch (err) {
82
+ console.error('[Lynxtron Web] Failed to inject nodejs module:', err);
83
+ return {};
84
+ }
85
+ };
86
+ `;
87
+
88
+ const blob = new Blob([code], { type: 'text/javascript' });
89
+ const blobUrl = URL.createObjectURL(blob);
90
+ console.log('[Lynxtron Web] Created Proxy Blob URL:', blobUrl);
91
+ nativeModulesMap['nodejs'] = blobUrl;
92
+ }
93
+
94
+ // 3. Inject to Lynx
95
+ console.log('[Lynxtron Web] Final nativeModulesMap:', nativeModulesMap);
96
+ lynxView.nativeModulesMap = nativeModulesMap;
97
+ lynxView.onNativeModulesCall = async (name, args) => {
98
+ const handler = handlers[name];
99
+ if (handler) {
100
+ // If args is an array, we spread it. If it's single data (legacy), we pass it as is.
101
+ // But based on our new proxy, it will always be an array of arguments.
102
+ if (Array.isArray(args)) {
103
+ return await handler(...args);
104
+ }
105
+ return await handler(args);
106
+ }
107
+ console.warn(`[Lynxtron Web] No handler for: ${name}`);
108
+ return null;
109
+ };
110
+ }
package/web-worker.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Web Worker implementation of Lynxtron API
3
+ */
4
+ export const contextBridge = {
5
+ exposeInLynxBTS(exports) {
6
+ if (globalThis.contextBridge) {
7
+ globalThis.contextBridge.exposeInLynxBTS(exports);
8
+ } else {
9
+ globalThis.__lynxtron_nodejs_exports__ = exports;
10
+ }
11
+ }
12
+ };