@lynx-js/lynx-library-headers 0.0.1-alpha.4
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 +53 -0
- package/include/base/include/value/lynx_api_types.h +57 -0
- package/include/base/include/value/lynx_value_api.h +204 -0
- package/include/base/include/value/lynx_value_types.h +73 -0
- package/include/capi/lynx_env_capi.h +47 -0
- package/include/capi/lynx_event_reporter_service_capi.h +67 -0
- package/include/capi/lynx_export.h +27 -0
- package/include/capi/lynx_extension_module_capi.h +148 -0
- package/include/capi/lynx_extension_module_types_capi.h +17 -0
- package/include/capi/lynx_generic_resource_fetcher_capi.h +124 -0
- package/include/capi/lynx_group_capi.h +42 -0
- package/include/capi/lynx_http_service_capi.h +113 -0
- package/include/capi/lynx_load_meta_capi.h +52 -0
- package/include/capi/lynx_log_capi.h +69 -0
- package/include/capi/lynx_memory_capi.h +28 -0
- package/include/capi/lynx_native_module_capi.h +51 -0
- package/include/capi/lynx_native_view_capi.h +163 -0
- package/include/capi/lynx_resource_request_capi.h +71 -0
- package/include/capi/lynx_resource_response_capi.h +92 -0
- package/include/capi/lynx_runtime_lifecycle_observer_capi.h +62 -0
- package/include/capi/lynx_security_service_capi.h +52 -0
- package/include/capi/lynx_service_center_capi.h +50 -0
- package/include/capi/lynx_template_bundle_capi.h +39 -0
- package/include/capi/lynx_template_data_capi.h +33 -0
- package/include/capi/lynx_trace_capi.h +62 -0
- package/include/capi/lynx_trail_service_capi.h +35 -0
- package/include/capi/lynx_types.h +750 -0
- package/include/capi/lynx_update_meta_capi.h +33 -0
- package/include/capi/lynx_view_builder_capi.h +113 -0
- package/include/capi/lynx_view_capi.h +174 -0
- package/include/capi/lynx_view_client_capi.h +81 -0
- package/include/capi/lynx_vsync_monitor_capi.h +38 -0
- package/include/capi/lynx_windowless_renderer_capi.h +213 -0
- package/include/js_native_api.h +608 -0
- package/include/js_native_api_types.h +202 -0
- package/include/lynx/base/include/value/lynx_api_types.h +57 -0
- package/include/lynx/base/include/value/lynx_value_api.h +204 -0
- package/include/lynx/base/include/value/lynx_value_types.h +73 -0
- package/include/lynx/extension.h +6 -0
- package/include/lynx/platform/embedder/public/capi/lynx_env_capi.h +47 -0
- package/include/lynx/platform/embedder/public/capi/lynx_event_reporter_service_capi.h +67 -0
- package/include/lynx/platform/embedder/public/capi/lynx_export.h +27 -0
- package/include/lynx/platform/embedder/public/capi/lynx_extension_module_capi.h +148 -0
- package/include/lynx/platform/embedder/public/capi/lynx_extension_module_types_capi.h +17 -0
- package/include/lynx/platform/embedder/public/capi/lynx_generic_resource_fetcher_capi.h +124 -0
- package/include/lynx/platform/embedder/public/capi/lynx_group_capi.h +42 -0
- package/include/lynx/platform/embedder/public/capi/lynx_http_service_capi.h +113 -0
- package/include/lynx/platform/embedder/public/capi/lynx_load_meta_capi.h +52 -0
- package/include/lynx/platform/embedder/public/capi/lynx_log_capi.h +69 -0
- package/include/lynx/platform/embedder/public/capi/lynx_memory_capi.h +28 -0
- package/include/lynx/platform/embedder/public/capi/lynx_native_module_capi.h +51 -0
- package/include/lynx/platform/embedder/public/capi/lynx_native_view_capi.h +163 -0
- package/include/lynx/platform/embedder/public/capi/lynx_resource_request_capi.h +71 -0
- package/include/lynx/platform/embedder/public/capi/lynx_resource_response_capi.h +92 -0
- package/include/lynx/platform/embedder/public/capi/lynx_runtime_lifecycle_observer_capi.h +62 -0
- package/include/lynx/platform/embedder/public/capi/lynx_security_service_capi.h +52 -0
- package/include/lynx/platform/embedder/public/capi/lynx_service_center_capi.h +50 -0
- package/include/lynx/platform/embedder/public/capi/lynx_template_bundle_capi.h +39 -0
- package/include/lynx/platform/embedder/public/capi/lynx_template_data_capi.h +33 -0
- package/include/lynx/platform/embedder/public/capi/lynx_trace_capi.h +62 -0
- package/include/lynx/platform/embedder/public/capi/lynx_trail_service_capi.h +35 -0
- package/include/lynx/platform/embedder/public/capi/lynx_types.h +750 -0
- package/include/lynx/platform/embedder/public/capi/lynx_update_meta_capi.h +33 -0
- package/include/lynx/platform/embedder/public/capi/lynx_view_builder_capi.h +113 -0
- package/include/lynx/platform/embedder/public/capi/lynx_view_capi.h +174 -0
- package/include/lynx/platform/embedder/public/capi/lynx_view_client_capi.h +81 -0
- package/include/lynx/platform/embedder/public/capi/lynx_vsync_monitor_capi.h +38 -0
- package/include/lynx/platform/embedder/public/capi/lynx_windowless_renderer_capi.h +213 -0
- package/include/lynx/platform/embedder/public/lynx_env.h +104 -0
- package/include/lynx/platform/embedder/public/lynx_event_reporter_service.h +96 -0
- package/include/lynx/platform/embedder/public/lynx_event_simulation_proxy.h +31 -0
- package/include/lynx/platform/embedder/public/lynx_extension_module.h +521 -0
- package/include/lynx/platform/embedder/public/lynx_generic_resource_fetcher.h +178 -0
- package/include/lynx/platform/embedder/public/lynx_group.h +70 -0
- package/include/lynx/platform/embedder/public/lynx_http_service.h +211 -0
- package/include/lynx/platform/embedder/public/lynx_load_meta.h +120 -0
- package/include/lynx/platform/embedder/public/lynx_native_module.h +9 -0
- package/include/lynx/platform/embedder/public/lynx_native_view.h +201 -0
- package/include/lynx/platform/embedder/public/lynx_resource_request.h +56 -0
- package/include/lynx/platform/embedder/public/lynx_resource_response.h +63 -0
- package/include/lynx/platform/embedder/public/lynx_runtime_lifecycle_observer.h +102 -0
- package/include/lynx/platform/embedder/public/lynx_security_service.h +78 -0
- package/include/lynx/platform/embedder/public/lynx_service_center.h +64 -0
- package/include/lynx/platform/embedder/public/lynx_template_bundle.h +65 -0
- package/include/lynx/platform/embedder/public/lynx_template_data.h +104 -0
- package/include/lynx/platform/embedder/public/lynx_trail_service.h +81 -0
- package/include/lynx/platform/embedder/public/lynx_update_meta.h +56 -0
- package/include/lynx/platform/embedder/public/lynx_value.h +270 -0
- package/include/lynx/platform/embedder/public/lynx_view.h +364 -0
- package/include/lynx/platform/embedder/public/lynx_view_client.h +226 -0
- package/include/lynx/platform/embedder/public/lynx_vsync_monitor.h +70 -0
- package/include/lynx/platform/embedder/public/lynx_windowless_renderer.h +302 -0
- package/include/lynx/registration.h +178 -0
- package/include/lynx_env.h +104 -0
- package/include/lynx_event_reporter_service.h +96 -0
- package/include/lynx_event_simulation_proxy.h +31 -0
- package/include/lynx_extension.h +10 -0
- package/include/lynx_extension_module.h +521 -0
- package/include/lynx_generic_resource_fetcher.h +178 -0
- package/include/lynx_group.h +70 -0
- package/include/lynx_http_service.h +211 -0
- package/include/lynx_load_meta.h +120 -0
- package/include/lynx_native_module.h +9 -0
- package/include/lynx_native_view.h +201 -0
- package/include/lynx_resource_request.h +56 -0
- package/include/lynx_resource_response.h +63 -0
- package/include/lynx_runtime_lifecycle_observer.h +102 -0
- package/include/lynx_security_service.h +78 -0
- package/include/lynx_service_center.h +64 -0
- package/include/lynx_template_bundle.h +65 -0
- package/include/lynx_template_data.h +104 -0
- package/include/lynx_trail_service.h +81 -0
- package/include/lynx_update_meta.h +56 -0
- package/include/lynx_value.h +270 -0
- package/include/lynx_view.h +364 -0
- package/include/lynx_view_client.h +226 -0
- package/include/lynx_vsync_monitor.h +70 -0
- package/include/lynx_windowless_renderer.h +302 -0
- package/include/napi-inl.deprecated.h +186 -0
- package/include/napi-inl.h +6607 -0
- package/include/napi.h +3208 -0
- package/include/node_api.h +276 -0
- package/include/node_api_types.h +59 -0
- package/include/third_party/weak-node-api/headers/js_native_api.h +608 -0
- package/include/third_party/weak-node-api/headers/js_native_api_types.h +202 -0
- package/include/third_party/weak-node-api/headers/napi-inl.deprecated.h +186 -0
- package/include/third_party/weak-node-api/headers/napi-inl.h +6607 -0
- package/include/third_party/weak-node-api/headers/napi.h +3208 -0
- package/include/third_party/weak-node-api/headers/node_api.h +276 -0
- package/include/third_party/weak-node-api/headers/node_api_types.h +59 -0
- package/include/third_party/weak-node-api/headers/weak_napi_defines.h +331 -0
- package/include/third_party/weak-node-api/headers/weak_napi_undefs.h +282 -0
- package/include/weak_napi_defines.h +331 -0
- package/include/weak_napi_undefs.h +282 -0
- package/package.json +29 -0
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# @lynx-js/lynx-library-headers
|
|
2
|
+
|
|
3
|
+
Header package for Lynx embedder C/C++ API and weak N-API based native
|
|
4
|
+
libraries. This package only provides headers; it does not scaffold, build, or
|
|
5
|
+
register libraries.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
Resolve the package root from your build script, then add `include/` to the
|
|
10
|
+
native target include directories:
|
|
11
|
+
|
|
12
|
+
```js
|
|
13
|
+
const path = require('node:path');
|
|
14
|
+
const headersRoot = path.dirname(
|
|
15
|
+
require.resolve('@lynx-js/lynx-library-headers/package.json'),
|
|
16
|
+
);
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The published package contains:
|
|
20
|
+
|
|
21
|
+
- Lynx embedder C API headers.
|
|
22
|
+
- Lynx embedder C++ wrapper headers such as `lynx_native_view.h`,
|
|
23
|
+
`lynx_value.h`, and `lynx_view.h`.
|
|
24
|
+
- Weak N-API headers used by Lynx native modules.
|
|
25
|
+
- Lynx value C API headers required by the embedder C API.
|
|
26
|
+
- `lynx_extension.h` and `lynx/extension.h` convenience wrapper headers.
|
|
27
|
+
- `lynx/registration.h` for generic embedder static registration helpers.
|
|
28
|
+
|
|
29
|
+
Embedders and Lynxtron packages use static registration from the native library:
|
|
30
|
+
|
|
31
|
+
```cpp
|
|
32
|
+
#include <lynx/registration.h>
|
|
33
|
+
|
|
34
|
+
void BindDemoModule(::lynx::registration::LynxNapiEnv env,
|
|
35
|
+
::lynx::registration::LynxNapiValue exports);
|
|
36
|
+
lynx_native_view_t* CreateDemoView(void* opaque);
|
|
37
|
+
|
|
38
|
+
LYNX_REGISTER_NATIVE_MODULE("DemoModule", BindDemoModule)
|
|
39
|
+
LYNX_REGISTER_ELEMENT(
|
|
40
|
+
"DemoModule",
|
|
41
|
+
"x-demo-view",
|
|
42
|
+
CreateDemoView)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Use `LYNX_REGISTER_NATIVE_MODULE` for Lynx weak N-API native modules and
|
|
46
|
+
`LYNX_REGISTER_ELEMENT` for Lynx native view elements. A library that exposes
|
|
47
|
+
both features should call both macros, keeping the native module and element
|
|
48
|
+
registrations separate.
|
|
49
|
+
|
|
50
|
+
Lynxtron loads matching native libraries through its autolink flow; loading the
|
|
51
|
+
library is enough for these static registrations to run.
|
|
52
|
+
|
|
53
|
+
Run `npm run copy-headers` in this package when updating the source headers.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2017 Node.js API collaborators. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed by a MIT license that can be
|
|
5
|
+
* found in the LICENSE file in the root of the source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// Copyright 2025 The Lynx Authors. All rights reserved.
|
|
9
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
10
|
+
// LICENSE file in the root directory of this source tree.
|
|
11
|
+
|
|
12
|
+
#ifndef BASE_INCLUDE_VALUE_LYNX_API_TYPES_H_
|
|
13
|
+
#define BASE_INCLUDE_VALUE_LYNX_API_TYPES_H_
|
|
14
|
+
|
|
15
|
+
#include <stddef.h>
|
|
16
|
+
#include <stdint.h>
|
|
17
|
+
|
|
18
|
+
#ifndef LYNX_VALUE_COMPILE_UNIT
|
|
19
|
+
#define LYNX_VALUE_COMPILE_UNIT
|
|
20
|
+
#endif
|
|
21
|
+
|
|
22
|
+
#define LYNX_VALUE_OPAQUE_STRUCT__2(name, unit) lynx_##name##__##unit
|
|
23
|
+
#define LYNX_VALUE_OPAQUE_STRUCT__1(name, unit) \
|
|
24
|
+
LYNX_VALUE_OPAQUE_STRUCT__2(name, unit)
|
|
25
|
+
#define LYNX_VALUE_OPAQUE_STRUCT(name) \
|
|
26
|
+
LYNX_VALUE_OPAQUE_STRUCT__1(name, LYNX_VALUE_COMPILE_UNIT)
|
|
27
|
+
|
|
28
|
+
typedef struct lynx_value_ptr__* lynx_value_ptr;
|
|
29
|
+
typedef struct lynx_api_env__* lynx_api_env;
|
|
30
|
+
|
|
31
|
+
typedef struct LYNX_VALUE_OPAQUE_STRUCT(api_context) * lynx_api_context;
|
|
32
|
+
typedef enum {
|
|
33
|
+
lynx_api_ok,
|
|
34
|
+
lynx_api_failed,
|
|
35
|
+
lynx_api_invalid_arg,
|
|
36
|
+
lynx_api_not_support,
|
|
37
|
+
lynx_api_bool_expected,
|
|
38
|
+
lynx_api_double_expected,
|
|
39
|
+
lynx_api_int32_expected,
|
|
40
|
+
lynx_api_uint32_expected,
|
|
41
|
+
lynx_api_int64_expected,
|
|
42
|
+
lynx_api_uint64_expected,
|
|
43
|
+
lynx_api_string_expected,
|
|
44
|
+
lynx_api_array_expected,
|
|
45
|
+
lynx_api_map_expected,
|
|
46
|
+
lynx_api_external_expected,
|
|
47
|
+
lynx_api_arraybuffer_expected,
|
|
48
|
+
lynx_api_function_expected,
|
|
49
|
+
lynx_api_index_out_of_range,
|
|
50
|
+
lynx_api_handle_scope_mismatch,
|
|
51
|
+
} lynx_api_status;
|
|
52
|
+
|
|
53
|
+
struct lynx_api_env__ {
|
|
54
|
+
lynx_api_context ctx;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
#endif // BASE_INCLUDE_VALUE_LYNX_API_TYPES_H_
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
// Copyright 2025 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
|
|
5
|
+
#ifndef BASE_INCLUDE_VALUE_LYNX_VALUE_API_H_
|
|
6
|
+
#define BASE_INCLUDE_VALUE_LYNX_VALUE_API_H_
|
|
7
|
+
|
|
8
|
+
#ifdef __cplusplus
|
|
9
|
+
extern "C" {
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
#include "base/include/value/lynx_value_types.h"
|
|
13
|
+
|
|
14
|
+
#ifdef _WIN32
|
|
15
|
+
#ifdef lynx_EXPORTS
|
|
16
|
+
#define LYNX_VALUE_EXPORT __declspec(dllexport)
|
|
17
|
+
#else
|
|
18
|
+
#define LYNX_VALUE_EXPORT __declspec(dllimport)
|
|
19
|
+
#endif // lynx_EXPORTS
|
|
20
|
+
#elif defined(__ANDROID__)
|
|
21
|
+
#define LYNX_VALUE_EXPORT
|
|
22
|
+
#else
|
|
23
|
+
#define LYNX_VALUE_EXPORT __attribute__((visibility("default")))
|
|
24
|
+
#endif // _WIN32
|
|
25
|
+
|
|
26
|
+
// Get the type of lynx_value.
|
|
27
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
28
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_typeof(lynx_api_env env,
|
|
29
|
+
lynx_value value,
|
|
30
|
+
lynx_value_type* result);
|
|
31
|
+
// This API creates a lynx_value of type null.
|
|
32
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
33
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_create_null(lynx_api_env env,
|
|
34
|
+
lynx_value* result);
|
|
35
|
+
// This API creates a lynx_value of type bool with given values.
|
|
36
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
37
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_create_bool(lynx_api_env env,
|
|
38
|
+
bool value,
|
|
39
|
+
lynx_value* result);
|
|
40
|
+
// This API creates a lynx_value of type bool with given values.
|
|
41
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
42
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_create_double(lynx_api_env env,
|
|
43
|
+
double value,
|
|
44
|
+
lynx_value* result);
|
|
45
|
+
// This API creates a lynx_value of type int32_t with given values.
|
|
46
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
47
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_create_int32(lynx_api_env env,
|
|
48
|
+
int32_t value,
|
|
49
|
+
lynx_value* result);
|
|
50
|
+
// This API creates a lynx_value of type uint32_t with given values.
|
|
51
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
52
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_create_uint32(lynx_api_env env,
|
|
53
|
+
uint32_t value,
|
|
54
|
+
lynx_value* result);
|
|
55
|
+
// This API creates a lynx_value of type int64_t with given values.
|
|
56
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
57
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_create_int64(lynx_api_env env,
|
|
58
|
+
int64_t value,
|
|
59
|
+
lynx_value* result);
|
|
60
|
+
// This API creates a lynx_value of type uint64_t with given values.
|
|
61
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
62
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_create_uint64(lynx_api_env env,
|
|
63
|
+
uint64_t value,
|
|
64
|
+
lynx_value* result);
|
|
65
|
+
// This API creates a string value from a UTF8-encoded C string. The native
|
|
66
|
+
// string is copied.
|
|
67
|
+
// This API allocates memory on the heap to store the string. After use,
|
|
68
|
+
// lynx_value_remove_reference must be called to free this portion of
|
|
69
|
+
// memory, otherwise it will result in a memory leak.
|
|
70
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
71
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_create_string_utf8(
|
|
72
|
+
lynx_api_env env, const char* str, size_t length, lynx_value* result);
|
|
73
|
+
// This API creates a map container.
|
|
74
|
+
// This API allocates memory on the heap to store the container. After use,
|
|
75
|
+
// lynx_value_remove_reference must be called to free this portion of
|
|
76
|
+
// memory, otherwise it will result in a memory leak.
|
|
77
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
78
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_create_map(lynx_api_env env,
|
|
79
|
+
lynx_value* result);
|
|
80
|
+
// This API creates a array container.
|
|
81
|
+
// This API allocates memory on the heap to store the container. After use,
|
|
82
|
+
// lynx_value_remove_reference must be called to free this portion of
|
|
83
|
+
// memory, otherwise it will result in a memory leak.
|
|
84
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
85
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_create_array(lynx_api_env env,
|
|
86
|
+
lynx_value* result);
|
|
87
|
+
|
|
88
|
+
// Read the numberic value from lynx_value.
|
|
89
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
90
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_get_number(lynx_api_env env,
|
|
91
|
+
lynx_value value,
|
|
92
|
+
double* result);
|
|
93
|
+
// Read the double value from lynx_value. lynx_api_double_expected is returned
|
|
94
|
+
// if the types do not match.
|
|
95
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
96
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_get_double(lynx_api_env env,
|
|
97
|
+
lynx_value value,
|
|
98
|
+
double* result);
|
|
99
|
+
// Read the int32_t value from lynx_value. lynx_api_int32_expected is returned
|
|
100
|
+
// if the types do not match.
|
|
101
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
102
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_get_int32(lynx_api_env env,
|
|
103
|
+
lynx_value value,
|
|
104
|
+
int32_t* result);
|
|
105
|
+
// Read the uint32_t value from lynx_value. lynx_api_uint32_expected is returned
|
|
106
|
+
// if the types do not match.
|
|
107
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
108
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_get_uint32(lynx_api_env env,
|
|
109
|
+
lynx_value value,
|
|
110
|
+
uint32_t* result);
|
|
111
|
+
// Read the int64_t value from lynx_value. lynx_api_int64_expected is returned
|
|
112
|
+
// if the types do not match.
|
|
113
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
114
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_get_int64(lynx_api_env env,
|
|
115
|
+
lynx_value value,
|
|
116
|
+
int64_t* result);
|
|
117
|
+
// Read the uint64_t value from lynx_value. lynx_api_uint64_expected is returned
|
|
118
|
+
// if the types do not match.
|
|
119
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
120
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_get_uint64(lynx_api_env env,
|
|
121
|
+
lynx_value value,
|
|
122
|
+
uint64_t* result);
|
|
123
|
+
// Read the bool value from lynx_value. lynx_api_bool_expected is returned
|
|
124
|
+
// if the types do not match.
|
|
125
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
126
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_get_bool(lynx_api_env env,
|
|
127
|
+
lynx_value value,
|
|
128
|
+
bool* result);
|
|
129
|
+
// Read the UTF8-encoded string value from lynx_value. lynx_api_string_expected
|
|
130
|
+
// is returned if the types do not match. If the buf argument is passed NULL,
|
|
131
|
+
// the length of the string in bytes and excluding the null terminator is
|
|
132
|
+
// returned in result
|
|
133
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
134
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_get_string_utf8(lynx_api_env env,
|
|
135
|
+
lynx_value value,
|
|
136
|
+
char* buf,
|
|
137
|
+
size_t bufsize,
|
|
138
|
+
size_t* result);
|
|
139
|
+
// Read the length of array from lynx_value. lynx_api_array_expected is returned
|
|
140
|
+
// if the types do not match.
|
|
141
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
142
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_get_array_length(lynx_api_env env,
|
|
143
|
+
lynx_value value,
|
|
144
|
+
uint32_t* result);
|
|
145
|
+
// Insert lynx_value element into array at the index specified.
|
|
146
|
+
// lynx_api_array_expected is returned if the types do not match.
|
|
147
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
148
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_set_element(lynx_api_env env,
|
|
149
|
+
lynx_value object,
|
|
150
|
+
uint32_t index,
|
|
151
|
+
lynx_value value);
|
|
152
|
+
// Read the array element from lynx_value. lynx_api_array_expected is returned
|
|
153
|
+
// if the types do not match.
|
|
154
|
+
// The reference count of the lynx_value read out is automatically incremented
|
|
155
|
+
// by 1. After use, lynx_value_remove_reference needs to be called to free the
|
|
156
|
+
// memory Returns lynx_api_ok if the API succeeded.
|
|
157
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_get_element(lynx_api_env env,
|
|
158
|
+
lynx_value object,
|
|
159
|
+
uint32_t index,
|
|
160
|
+
lynx_value* result);
|
|
161
|
+
// This API checks if the object passed in has the named property.
|
|
162
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
163
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_has_property(lynx_api_env env,
|
|
164
|
+
lynx_value object,
|
|
165
|
+
const char* utf8name,
|
|
166
|
+
bool* result);
|
|
167
|
+
// Read the map keys from lynx_value. lynx_api_map_expected is returned
|
|
168
|
+
// if the types do not match.
|
|
169
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
170
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_get_property_names(
|
|
171
|
+
lynx_api_env env, lynx_value object, lynx_value* result);
|
|
172
|
+
// Set lynx_value property into map at the key specified.
|
|
173
|
+
// lynx_api_map_expected is returned if the types do not match.
|
|
174
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
175
|
+
LYNX_VALUE_EXPORT lynx_api_status
|
|
176
|
+
lynx_value_set_named_property(lynx_api_env env, lynx_value object,
|
|
177
|
+
const char* utf8name, lynx_value value);
|
|
178
|
+
// Read the map property from lynx_value. lynx_api_map_expected is returned
|
|
179
|
+
// if the types do not match.
|
|
180
|
+
// The reference count of the lynx_value read out is automatically incremented
|
|
181
|
+
// by 1. After use, lynx_value_remove_reference needs to be called to free the
|
|
182
|
+
// memory. Returns lynx_api_ok if the API succeeded.
|
|
183
|
+
LYNX_VALUE_EXPORT lynx_api_status
|
|
184
|
+
lynx_value_get_named_property(lynx_api_env env, lynx_value object,
|
|
185
|
+
const char* utf8name, lynx_value* result);
|
|
186
|
+
// This API is used for iterating through array or map type lynx_value.
|
|
187
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
188
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_iterate_value(
|
|
189
|
+
lynx_api_env env, lynx_value object, lynx_value_iterator_callback callback,
|
|
190
|
+
void* pfunc, void* raw_data);
|
|
191
|
+
// Increment the reference count by 1 for pointer data.
|
|
192
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
193
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_add_reference(
|
|
194
|
+
lynx_api_env env, lynx_value value, lynx_value_ref* result);
|
|
195
|
+
// Decrement the reference count by 1 for pointer data.
|
|
196
|
+
// Returns lynx_api_ok if the API succeeded.
|
|
197
|
+
LYNX_VALUE_EXPORT lynx_api_status lynx_value_remove_reference(
|
|
198
|
+
lynx_api_env env, lynx_value value, lynx_value_ref ref);
|
|
199
|
+
|
|
200
|
+
#ifdef __cplusplus
|
|
201
|
+
}
|
|
202
|
+
#endif
|
|
203
|
+
|
|
204
|
+
#endif // BASE_INCLUDE_VALUE_LYNX_VALUE_API_H_
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2017 Node.js API collaborators. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed by a MIT license that can be
|
|
5
|
+
* found in the LICENSE file in the root of the source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// Copyright 2025 The Lynx Authors. All rights reserved.
|
|
9
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
10
|
+
// LICENSE file in the root directory of this source tree.
|
|
11
|
+
|
|
12
|
+
#ifndef BASE_INCLUDE_VALUE_LYNX_VALUE_TYPES_H_
|
|
13
|
+
#define BASE_INCLUDE_VALUE_LYNX_VALUE_TYPES_H_
|
|
14
|
+
|
|
15
|
+
#include <stddef.h>
|
|
16
|
+
#include <stdint.h>
|
|
17
|
+
|
|
18
|
+
#include "base/include/value/lynx_api_types.h"
|
|
19
|
+
|
|
20
|
+
typedef struct LYNX_VALUE_OPAQUE_STRUCT(value_ref) * lynx_value_ref;
|
|
21
|
+
|
|
22
|
+
typedef enum : uint8_t {
|
|
23
|
+
lynx_value_null,
|
|
24
|
+
lynx_value_undefined,
|
|
25
|
+
lynx_value_bool,
|
|
26
|
+
lynx_value_double,
|
|
27
|
+
lynx_value_int32,
|
|
28
|
+
lynx_value_uint32,
|
|
29
|
+
lynx_value_int64,
|
|
30
|
+
lynx_value_uint64,
|
|
31
|
+
lynx_value_nan,
|
|
32
|
+
lynx_value_string,
|
|
33
|
+
lynx_value_array,
|
|
34
|
+
lynx_value_map,
|
|
35
|
+
lynx_value_arraybuffer,
|
|
36
|
+
lynx_value_object,
|
|
37
|
+
lynx_value_function,
|
|
38
|
+
lynx_value_function_table,
|
|
39
|
+
lynx_value_external, // external raw pointer
|
|
40
|
+
lynx_value_extended,
|
|
41
|
+
} lynx_value_type;
|
|
42
|
+
|
|
43
|
+
#define LYNX_VALUE_BASE_STORAGE_DEFINITION \
|
|
44
|
+
union { \
|
|
45
|
+
bool val_bool; \
|
|
46
|
+
double val_double; \
|
|
47
|
+
int32_t val_int32; \
|
|
48
|
+
uint32_t val_uint32; \
|
|
49
|
+
int64_t val_int64; \
|
|
50
|
+
uint64_t val_uint64; \
|
|
51
|
+
lynx_value_ptr val_ptr; \
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
struct lynx_value {
|
|
55
|
+
LYNX_VALUE_BASE_STORAGE_DEFINITION
|
|
56
|
+
lynx_value_type type;
|
|
57
|
+
|
|
58
|
+
uint8_t __unnamed0__;
|
|
59
|
+
uint8_t __unnamed1__;
|
|
60
|
+
uint8_t __unnamed2__;
|
|
61
|
+
|
|
62
|
+
int32_t tag;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
static_assert(sizeof(lynx_value) == 16,
|
|
66
|
+
"The lynx_value was precisely designed to be 16 bytes.");
|
|
67
|
+
|
|
68
|
+
typedef void (*lynx_value_iterator_callback)(lynx_api_env env, lynx_value key,
|
|
69
|
+
lynx_value val, void* pfunc,
|
|
70
|
+
void* raw_data);
|
|
71
|
+
typedef void (*lynx_value_print_ext_callback)(void* stream, const char* str);
|
|
72
|
+
|
|
73
|
+
#endif // BASE_INCLUDE_VALUE_LYNX_VALUE_TYPES_H_
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Copyright 2025 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
#ifndef PLATFORM_EMBEDDER_PUBLIC_CAPI_LYNX_ENV_CAPI_H_
|
|
5
|
+
#define PLATFORM_EMBEDDER_PUBLIC_CAPI_LYNX_ENV_CAPI_H_
|
|
6
|
+
|
|
7
|
+
#include "lynx_export.h"
|
|
8
|
+
#include "lynx_extension_module_types_capi.h"
|
|
9
|
+
#include "lynx_native_module_capi.h"
|
|
10
|
+
|
|
11
|
+
LYNX_EXTERN_C_BEGIN
|
|
12
|
+
|
|
13
|
+
// Retrieves the SDK version of Lynx sdk.
|
|
14
|
+
LYNX_CAPI_EXPORT const char* lynx_env_get_sdk_version();
|
|
15
|
+
|
|
16
|
+
// Sets the ICU data path for the LynxEnv.
|
|
17
|
+
LYNX_CAPI_EXPORT void lynx_env_set_icu_data_path(const char* icu_data_path);
|
|
18
|
+
|
|
19
|
+
// Retrieves the ICU data path for the LynxEnv.
|
|
20
|
+
LYNX_CAPI_EXPORT const char* lynx_env_get_icu_data_path();
|
|
21
|
+
|
|
22
|
+
// Lynx devtools
|
|
23
|
+
typedef void (*lynx_env_open_card_callback)(void* user_data, const char* url);
|
|
24
|
+
|
|
25
|
+
LYNX_CAPI_EXPORT void lynx_env_set_devtool_app_info(const char* name,
|
|
26
|
+
const char* value);
|
|
27
|
+
LYNX_CAPI_EXPORT void lynx_env_enable_devtool(int enable);
|
|
28
|
+
LYNX_CAPI_EXPORT int lynx_env_is_devtool_enabled();
|
|
29
|
+
LYNX_CAPI_EXPORT int lynx_env_connect_devtool(const char* url);
|
|
30
|
+
LYNX_CAPI_EXPORT void lynx_env_set_open_card_callback(
|
|
31
|
+
lynx_env_open_card_callback callback, void* user_data);
|
|
32
|
+
// logbox
|
|
33
|
+
LYNX_CAPI_EXPORT void lynx_env_enable_logbox(int enable);
|
|
34
|
+
LYNX_CAPI_EXPORT int lynx_env_is_logbox_enabled();
|
|
35
|
+
// Global native module
|
|
36
|
+
LYNX_CAPI_EXPORT void lynx_env_register_native_module(
|
|
37
|
+
const char* name, napi_module_creator creator, void* opaque);
|
|
38
|
+
// Global extension module
|
|
39
|
+
LYNX_CAPI_EXPORT void lynx_env_register_extension_module(
|
|
40
|
+
const char* name, extension_module_creator creator, bool is_lazy_create,
|
|
41
|
+
void* opaque);
|
|
42
|
+
|
|
43
|
+
LYNX_CAPI_EXPORT void lynx_env_set_node_platform(void* platform);
|
|
44
|
+
|
|
45
|
+
LYNX_EXTERN_C_END
|
|
46
|
+
|
|
47
|
+
#endif // PLATFORM_EMBEDDER_PUBLIC_CAPI_LYNX_ENV_CAPI_H_
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Copyright 2025 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
#ifndef PLATFORM_EMBEDDER_PUBLIC_CAPI_LYNX_EVENT_REPORTER_SERVICE_CAPI_H_
|
|
5
|
+
#define PLATFORM_EMBEDDER_PUBLIC_CAPI_LYNX_EVENT_REPORTER_SERVICE_CAPI_H_
|
|
6
|
+
|
|
7
|
+
#include <stdint.h>
|
|
8
|
+
#include <stdlib.h>
|
|
9
|
+
|
|
10
|
+
#include "base/include/value/lynx_value_types.h"
|
|
11
|
+
#include "lynx_export.h"
|
|
12
|
+
|
|
13
|
+
LYNX_EXTERN_C_BEGIN
|
|
14
|
+
|
|
15
|
+
// Forward declaration of the lynx_event_reporter_service_t struct.
|
|
16
|
+
typedef struct lynx_event_reporter_service_t lynx_event_reporter_service_t;
|
|
17
|
+
|
|
18
|
+
// Define a function pointer type for event reporter handling.
|
|
19
|
+
typedef void (*lynx_event_report_func)(lynx_event_reporter_service_t*,
|
|
20
|
+
const char* event_name,
|
|
21
|
+
const lynx_value& params);
|
|
22
|
+
|
|
23
|
+
// Define a function pointer type for performance event reporter handling.
|
|
24
|
+
typedef void (*lynx_performance_event_report_func)(
|
|
25
|
+
lynx_event_reporter_service_t*, const lynx_value& params);
|
|
26
|
+
|
|
27
|
+
// Creates a new event reporter service instance.
|
|
28
|
+
LYNX_CAPI_EXPORT lynx_event_reporter_service_t*
|
|
29
|
+
lynx_event_reporter_service_create(void* user_data);
|
|
30
|
+
|
|
31
|
+
// Create a new event reporter service instance with a finalizer.
|
|
32
|
+
// The finalizer will be called when the service is released.
|
|
33
|
+
// The instance's lifecycle is based on reference count.
|
|
34
|
+
LYNX_CAPI_EXPORT lynx_event_reporter_service_t*
|
|
35
|
+
lynx_event_reporter_service_create_with_finalizer(
|
|
36
|
+
void* user_data, void (*finalizer)(lynx_event_reporter_service_t*, void*));
|
|
37
|
+
|
|
38
|
+
// Binds a report function to the event reporter service.
|
|
39
|
+
LYNX_CAPI_EXPORT void lynx_event_reporter_service_bind(
|
|
40
|
+
lynx_event_reporter_service_t*, lynx_event_report_func f);
|
|
41
|
+
|
|
42
|
+
// Binds a performance report function to the event reporter service.
|
|
43
|
+
LYNX_CAPI_EXPORT void lynx_event_reporter_service_bind_performance_report_func(
|
|
44
|
+
lynx_event_reporter_service_t*, lynx_performance_event_report_func f);
|
|
45
|
+
|
|
46
|
+
// Retrieves the user data associated with the event reporter service.
|
|
47
|
+
LYNX_CAPI_EXPORT void* lynx_event_reporter_service_get_user_data(
|
|
48
|
+
lynx_event_reporter_service_t* event_report_service);
|
|
49
|
+
|
|
50
|
+
// Releases the resources associated with the event reporter service.
|
|
51
|
+
LYNX_CAPI_EXPORT void lynx_event_reporter_service_release(
|
|
52
|
+
lynx_event_reporter_service_t*);
|
|
53
|
+
|
|
54
|
+
// Call the event reporter handler associated with the event reporter service.
|
|
55
|
+
LYNX_CAPI_EXPORT void lynx_event_reporter_service_on_event(
|
|
56
|
+
lynx_event_reporter_service_t* event_report_service, const char* event_name,
|
|
57
|
+
const lynx_value& params);
|
|
58
|
+
|
|
59
|
+
// Call the event reporter handler associated with the performance event
|
|
60
|
+
// reporter service.
|
|
61
|
+
LYNX_CAPI_EXPORT void lynx_event_reporter_service_on_performance_event(
|
|
62
|
+
lynx_event_reporter_service_t* event_report_service,
|
|
63
|
+
const lynx_value& params);
|
|
64
|
+
|
|
65
|
+
LYNX_EXTERN_C_END
|
|
66
|
+
|
|
67
|
+
#endif // PLATFORM_EMBEDDER_PUBLIC_CAPI_LYNX_EVENT_REPORTER_SERVICE_CAPI_H_
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Copyright 2025 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
#ifndef PLATFORM_EMBEDDER_PUBLIC_CAPI_LYNX_EXPORT_H_
|
|
5
|
+
#define PLATFORM_EMBEDDER_PUBLIC_CAPI_LYNX_EXPORT_H_
|
|
6
|
+
|
|
7
|
+
#ifdef _WIN32
|
|
8
|
+
#ifndef lynx_EXPORTS
|
|
9
|
+
#define LYNX_CAPI_EXPORT __declspec(dllimport)
|
|
10
|
+
#else
|
|
11
|
+
#define LYNX_CAPI_EXPORT __declspec(dllexport)
|
|
12
|
+
#endif
|
|
13
|
+
#else
|
|
14
|
+
#define LYNX_CAPI_EXPORT __attribute__((visibility("default")))
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
#ifdef __cplusplus
|
|
18
|
+
#define LYNX_EXTERN_C extern "C"
|
|
19
|
+
#define LYNX_EXTERN_C_BEGIN LYNX_EXTERN_C {
|
|
20
|
+
#define LYNX_EXTERN_C_END }
|
|
21
|
+
#else
|
|
22
|
+
#define LYNX_EXTERN_C
|
|
23
|
+
#define LYNX_EXTERN_C_BEGIN
|
|
24
|
+
#define LYNX_EXTERN_C_END
|
|
25
|
+
#endif
|
|
26
|
+
|
|
27
|
+
#endif // PLATFORM_EMBEDDER_PUBLIC_CAPI_LYNX_EXPORT_H_
|