@lynx-js/lynx-library-headers 0.0.1-alpha.4 → 0.0.1

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 (136) hide show
  1. package/index.js +1 -0
  2. package/package.json +3 -26
  3. package/README.md +0 -53
  4. package/include/base/include/value/lynx_api_types.h +0 -57
  5. package/include/base/include/value/lynx_value_api.h +0 -204
  6. package/include/base/include/value/lynx_value_types.h +0 -73
  7. package/include/capi/lynx_env_capi.h +0 -47
  8. package/include/capi/lynx_event_reporter_service_capi.h +0 -67
  9. package/include/capi/lynx_export.h +0 -27
  10. package/include/capi/lynx_extension_module_capi.h +0 -148
  11. package/include/capi/lynx_extension_module_types_capi.h +0 -17
  12. package/include/capi/lynx_generic_resource_fetcher_capi.h +0 -124
  13. package/include/capi/lynx_group_capi.h +0 -42
  14. package/include/capi/lynx_http_service_capi.h +0 -113
  15. package/include/capi/lynx_load_meta_capi.h +0 -52
  16. package/include/capi/lynx_log_capi.h +0 -69
  17. package/include/capi/lynx_memory_capi.h +0 -28
  18. package/include/capi/lynx_native_module_capi.h +0 -51
  19. package/include/capi/lynx_native_view_capi.h +0 -163
  20. package/include/capi/lynx_resource_request_capi.h +0 -71
  21. package/include/capi/lynx_resource_response_capi.h +0 -92
  22. package/include/capi/lynx_runtime_lifecycle_observer_capi.h +0 -62
  23. package/include/capi/lynx_security_service_capi.h +0 -52
  24. package/include/capi/lynx_service_center_capi.h +0 -50
  25. package/include/capi/lynx_template_bundle_capi.h +0 -39
  26. package/include/capi/lynx_template_data_capi.h +0 -33
  27. package/include/capi/lynx_trace_capi.h +0 -62
  28. package/include/capi/lynx_trail_service_capi.h +0 -35
  29. package/include/capi/lynx_types.h +0 -750
  30. package/include/capi/lynx_update_meta_capi.h +0 -33
  31. package/include/capi/lynx_view_builder_capi.h +0 -113
  32. package/include/capi/lynx_view_capi.h +0 -174
  33. package/include/capi/lynx_view_client_capi.h +0 -81
  34. package/include/capi/lynx_vsync_monitor_capi.h +0 -38
  35. package/include/capi/lynx_windowless_renderer_capi.h +0 -213
  36. package/include/js_native_api.h +0 -608
  37. package/include/js_native_api_types.h +0 -202
  38. package/include/lynx/base/include/value/lynx_api_types.h +0 -57
  39. package/include/lynx/base/include/value/lynx_value_api.h +0 -204
  40. package/include/lynx/base/include/value/lynx_value_types.h +0 -73
  41. package/include/lynx/extension.h +0 -6
  42. package/include/lynx/platform/embedder/public/capi/lynx_env_capi.h +0 -47
  43. package/include/lynx/platform/embedder/public/capi/lynx_event_reporter_service_capi.h +0 -67
  44. package/include/lynx/platform/embedder/public/capi/lynx_export.h +0 -27
  45. package/include/lynx/platform/embedder/public/capi/lynx_extension_module_capi.h +0 -148
  46. package/include/lynx/platform/embedder/public/capi/lynx_extension_module_types_capi.h +0 -17
  47. package/include/lynx/platform/embedder/public/capi/lynx_generic_resource_fetcher_capi.h +0 -124
  48. package/include/lynx/platform/embedder/public/capi/lynx_group_capi.h +0 -42
  49. package/include/lynx/platform/embedder/public/capi/lynx_http_service_capi.h +0 -113
  50. package/include/lynx/platform/embedder/public/capi/lynx_load_meta_capi.h +0 -52
  51. package/include/lynx/platform/embedder/public/capi/lynx_log_capi.h +0 -69
  52. package/include/lynx/platform/embedder/public/capi/lynx_memory_capi.h +0 -28
  53. package/include/lynx/platform/embedder/public/capi/lynx_native_module_capi.h +0 -51
  54. package/include/lynx/platform/embedder/public/capi/lynx_native_view_capi.h +0 -163
  55. package/include/lynx/platform/embedder/public/capi/lynx_resource_request_capi.h +0 -71
  56. package/include/lynx/platform/embedder/public/capi/lynx_resource_response_capi.h +0 -92
  57. package/include/lynx/platform/embedder/public/capi/lynx_runtime_lifecycle_observer_capi.h +0 -62
  58. package/include/lynx/platform/embedder/public/capi/lynx_security_service_capi.h +0 -52
  59. package/include/lynx/platform/embedder/public/capi/lynx_service_center_capi.h +0 -50
  60. package/include/lynx/platform/embedder/public/capi/lynx_template_bundle_capi.h +0 -39
  61. package/include/lynx/platform/embedder/public/capi/lynx_template_data_capi.h +0 -33
  62. package/include/lynx/platform/embedder/public/capi/lynx_trace_capi.h +0 -62
  63. package/include/lynx/platform/embedder/public/capi/lynx_trail_service_capi.h +0 -35
  64. package/include/lynx/platform/embedder/public/capi/lynx_types.h +0 -750
  65. package/include/lynx/platform/embedder/public/capi/lynx_update_meta_capi.h +0 -33
  66. package/include/lynx/platform/embedder/public/capi/lynx_view_builder_capi.h +0 -113
  67. package/include/lynx/platform/embedder/public/capi/lynx_view_capi.h +0 -174
  68. package/include/lynx/platform/embedder/public/capi/lynx_view_client_capi.h +0 -81
  69. package/include/lynx/platform/embedder/public/capi/lynx_vsync_monitor_capi.h +0 -38
  70. package/include/lynx/platform/embedder/public/capi/lynx_windowless_renderer_capi.h +0 -213
  71. package/include/lynx/platform/embedder/public/lynx_env.h +0 -104
  72. package/include/lynx/platform/embedder/public/lynx_event_reporter_service.h +0 -96
  73. package/include/lynx/platform/embedder/public/lynx_event_simulation_proxy.h +0 -31
  74. package/include/lynx/platform/embedder/public/lynx_extension_module.h +0 -521
  75. package/include/lynx/platform/embedder/public/lynx_generic_resource_fetcher.h +0 -178
  76. package/include/lynx/platform/embedder/public/lynx_group.h +0 -70
  77. package/include/lynx/platform/embedder/public/lynx_http_service.h +0 -211
  78. package/include/lynx/platform/embedder/public/lynx_load_meta.h +0 -120
  79. package/include/lynx/platform/embedder/public/lynx_native_module.h +0 -9
  80. package/include/lynx/platform/embedder/public/lynx_native_view.h +0 -201
  81. package/include/lynx/platform/embedder/public/lynx_resource_request.h +0 -56
  82. package/include/lynx/platform/embedder/public/lynx_resource_response.h +0 -63
  83. package/include/lynx/platform/embedder/public/lynx_runtime_lifecycle_observer.h +0 -102
  84. package/include/lynx/platform/embedder/public/lynx_security_service.h +0 -78
  85. package/include/lynx/platform/embedder/public/lynx_service_center.h +0 -64
  86. package/include/lynx/platform/embedder/public/lynx_template_bundle.h +0 -65
  87. package/include/lynx/platform/embedder/public/lynx_template_data.h +0 -104
  88. package/include/lynx/platform/embedder/public/lynx_trail_service.h +0 -81
  89. package/include/lynx/platform/embedder/public/lynx_update_meta.h +0 -56
  90. package/include/lynx/platform/embedder/public/lynx_value.h +0 -270
  91. package/include/lynx/platform/embedder/public/lynx_view.h +0 -364
  92. package/include/lynx/platform/embedder/public/lynx_view_client.h +0 -226
  93. package/include/lynx/platform/embedder/public/lynx_vsync_monitor.h +0 -70
  94. package/include/lynx/platform/embedder/public/lynx_windowless_renderer.h +0 -302
  95. package/include/lynx/registration.h +0 -178
  96. package/include/lynx_env.h +0 -104
  97. package/include/lynx_event_reporter_service.h +0 -96
  98. package/include/lynx_event_simulation_proxy.h +0 -31
  99. package/include/lynx_extension.h +0 -10
  100. package/include/lynx_extension_module.h +0 -521
  101. package/include/lynx_generic_resource_fetcher.h +0 -178
  102. package/include/lynx_group.h +0 -70
  103. package/include/lynx_http_service.h +0 -211
  104. package/include/lynx_load_meta.h +0 -120
  105. package/include/lynx_native_module.h +0 -9
  106. package/include/lynx_native_view.h +0 -201
  107. package/include/lynx_resource_request.h +0 -56
  108. package/include/lynx_resource_response.h +0 -63
  109. package/include/lynx_runtime_lifecycle_observer.h +0 -102
  110. package/include/lynx_security_service.h +0 -78
  111. package/include/lynx_service_center.h +0 -64
  112. package/include/lynx_template_bundle.h +0 -65
  113. package/include/lynx_template_data.h +0 -104
  114. package/include/lynx_trail_service.h +0 -81
  115. package/include/lynx_update_meta.h +0 -56
  116. package/include/lynx_value.h +0 -270
  117. package/include/lynx_view.h +0 -364
  118. package/include/lynx_view_client.h +0 -226
  119. package/include/lynx_vsync_monitor.h +0 -70
  120. package/include/lynx_windowless_renderer.h +0 -302
  121. package/include/napi-inl.deprecated.h +0 -186
  122. package/include/napi-inl.h +0 -6607
  123. package/include/napi.h +0 -3208
  124. package/include/node_api.h +0 -276
  125. package/include/node_api_types.h +0 -59
  126. package/include/third_party/weak-node-api/headers/js_native_api.h +0 -608
  127. package/include/third_party/weak-node-api/headers/js_native_api_types.h +0 -202
  128. package/include/third_party/weak-node-api/headers/napi-inl.deprecated.h +0 -186
  129. package/include/third_party/weak-node-api/headers/napi-inl.h +0 -6607
  130. package/include/third_party/weak-node-api/headers/napi.h +0 -3208
  131. package/include/third_party/weak-node-api/headers/node_api.h +0 -276
  132. package/include/third_party/weak-node-api/headers/node_api_types.h +0 -59
  133. package/include/third_party/weak-node-api/headers/weak_napi_defines.h +0 -331
  134. package/include/third_party/weak-node-api/headers/weak_napi_undefs.h +0 -282
  135. package/include/weak_napi_defines.h +0 -331
  136. package/include/weak_napi_undefs.h +0 -282
@@ -1,70 +0,0 @@
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_LYNX_GROUP_H_
5
- #define PLATFORM_EMBEDDER_PUBLIC_LYNX_GROUP_H_
6
-
7
- #include <string>
8
- #include <utility>
9
- #include <vector>
10
-
11
- #include "capi/lynx_group_capi.h"
12
-
13
- namespace lynx {
14
- namespace pub {
15
-
16
- /**
17
- * @apidoc
18
- * @brief `LynxGroup` is a class that represents a group of Lynx views, allowing
19
- * developers to share JSContext between different Lynx views within the same
20
- * group.
21
- */
22
- class LynxGroup {
23
- public:
24
- explicit LynxGroup(const std::string& name)
25
- : group_(lynx_group_create(name.c_str())), name_(name) {}
26
- LynxGroup(const std::string& name, const std::string& id)
27
- : group_(lynx_group_create_with_id(name.c_str(), id.c_str())),
28
- name_(name),
29
- id_(id) {}
30
-
31
- ~LynxGroup() { lynx_group_release(group_); }
32
-
33
- std::string GetGroupName() const { return name_; }
34
-
35
- std::string GetID() const { return id_; }
36
-
37
- bool EnableJSGroupThread() const { return enable_js_group_thread_; }
38
-
39
- void SetEnableJSGroupThread(bool enable) {
40
- enable_js_group_thread_ = enable;
41
- lynx_group_set_enable_js_group_thread(group_, enable);
42
- }
43
-
44
- void SetPreloadJSPaths(std::vector<std::string> paths) {
45
- preload_js_paths_ = std::move(paths);
46
- std::vector<const char*> c_paths(preload_js_paths_.size());
47
- for (size_t i = 0; i < preload_js_paths_.size(); i++) {
48
- c_paths[i] = preload_js_paths_[i].c_str();
49
- }
50
- lynx_group_set_preload_js_paths(group_, c_paths.data(),
51
- preload_js_paths_.size());
52
- }
53
-
54
- lynx_group_t* Impl() { return group_; }
55
-
56
- LynxGroup(const LynxGroup&) = delete;
57
- LynxGroup& operator=(const LynxGroup&) = delete;
58
-
59
- private:
60
- lynx_group_t* group_;
61
- std::string name_;
62
- std::string id_;
63
- std::vector<std::string> preload_js_paths_;
64
- bool enable_js_group_thread_ = false;
65
- };
66
-
67
- } // namespace pub
68
- } // namespace lynx
69
-
70
- #endif // PLATFORM_EMBEDDER_PUBLIC_LYNX_GROUP_H_
@@ -1,211 +0,0 @@
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_LYNX_HTTP_SERVICE_H_
5
- #define PLATFORM_EMBEDDER_PUBLIC_LYNX_HTTP_SERVICE_H_
6
-
7
- #include <cstdint>
8
- #include <memory>
9
- #include <string>
10
- #include <unordered_map>
11
- #include <vector>
12
-
13
- #include "capi/lynx_http_service_capi.h"
14
- #include "lynx_service_center.h"
15
-
16
- namespace lynx {
17
- namespace pub {
18
-
19
- /**
20
- * @apidoc
21
- * @brief `LynxHttpRequest` is a class that represents an HTTP request,
22
- * allowing developers to set request headers, request body, and other
23
- * request parameters.
24
- */
25
- class LynxHttpRequest {
26
- public:
27
- explicit LynxHttpRequest(lynx_http_request_t* request) : request_(request) {
28
- ExtractRequestInfo();
29
- }
30
- ~LynxHttpRequest() { lynx_http_request_release(request_); }
31
-
32
- /**
33
- * @apidoc
34
- * @brief Get the URL of the HTTP request.
35
- * @return The URL of the HTTP request.
36
- */
37
- const std::string& GetUrl() const { return url_; }
38
-
39
- /**
40
- * @apidoc
41
- * @brief Get the method of the HTTP request.
42
- * @return The method of the HTTP request.
43
- */
44
- const std::string& GetMethod() const { return method_; }
45
-
46
- /**
47
- * @apidoc
48
- * @brief Get the headers of the HTTP request.
49
- * @return The headers of the HTTP request.
50
- */
51
- const std::unordered_map<std::string, std::string>& GetHeaders() const {
52
- return headers_;
53
- }
54
-
55
- /**
56
- * @apidoc
57
- * @brief Get the body of the HTTP request.
58
- * @return The body of the HTTP request.
59
- */
60
- const std::vector<uint8_t>& GetBody() const { return body_; }
61
-
62
- private:
63
- void ExtractRequestInfo() {
64
- const char* url = lynx_http_request_get_url(request_);
65
- url_ = url ? url : "";
66
- const char* method = lynx_http_request_get_method(request_);
67
- method_ = method ? method : "";
68
- size_t header_count = lynx_http_request_get_header_count(request_);
69
- for (unsigned i = 0; i < header_count; ++i) {
70
- const char* key = nullptr;
71
- const char* value = nullptr;
72
- lynx_http_request_get_header(request_, i, &key, &value);
73
- if (key && value) {
74
- headers_[key] = value;
75
- }
76
- }
77
- const uint8_t* body = nullptr;
78
- size_t body_size = lynx_http_request_get_body(request_, &body);
79
- if (body_size > 0 && body) {
80
- body_.assign(body, body + body_size);
81
- }
82
- }
83
-
84
- lynx_http_request_t* request_;
85
- std::string url_;
86
- std::string method_;
87
- std::unordered_map<std::string, std::string> headers_;
88
- std::vector<uint8_t> body_;
89
- };
90
-
91
- /**
92
- * @apidoc
93
- * @brief `LynxHttpResponse` is a class that represents an HTTP response,
94
- * allowing developers to set response status code, response status text,
95
- * response headers, and response body.
96
- */
97
- class LynxHttpResponse {
98
- public:
99
- explicit LynxHttpResponse(lynx_http_response_t* response)
100
- : response_(response) {}
101
- ~LynxHttpResponse() { lynx_http_response_release(response_); }
102
-
103
- /**
104
- * @apidoc
105
- * @brief Set the status code of the HTTP response.
106
- * @param code The status code of the HTTP response.
107
- */
108
- void SetStatusCode(int code) {
109
- lynx_http_response_set_status_code(response_, code);
110
- }
111
-
112
- /**
113
- * @apidoc
114
- * @brief Set the status text of the HTTP response.
115
- * @param msg The status text of the HTTP response.
116
- */
117
- void SetStatusText(const char* msg) {
118
- lynx_http_response_set_status_text(response_, msg);
119
- }
120
-
121
- /**
122
- * @apidoc
123
- * @brief Add a header to the HTTP response.
124
- * @param key The key of the header.
125
- * @param value The value of the header.
126
- */
127
- void AddHeader(const std::string& key, const std::string& value) {
128
- lynx_http_response_add_header(response_, key.c_str(), value.c_str());
129
- }
130
-
131
- /**
132
- * @apidoc
133
- * @brief Set the body of the HTTP response.
134
- * @param content The body content of the HTTP response.
135
- * @param length The length of the body content.
136
- * @param dtor The destructor of the body content.
137
- * @param opaque The opaque data of the body content.
138
- */
139
- void SetBody(uint8_t* content, size_t length,
140
- void (*dtor)(uint8_t*, size_t, void*) = nullptr,
141
- void* opaque = nullptr) {
142
- lynx_http_response_set_body(response_, content, length, dtor, opaque);
143
- }
144
-
145
- void Complete() { lynx_http_response_callback(response_); }
146
-
147
- private:
148
- lynx_http_response_t* response_;
149
- };
150
-
151
- /**
152
- * @apidoc
153
- * @brief `LynxHttpService` is a class that represents a HTTP service, allowing
154
- * developers to send HTTP requests and receive HTTP responses.
155
- */
156
- class LynxHttpService : public LynxServiceBase,
157
- public std::enable_shared_from_this<LynxHttpService> {
158
- public:
159
- LynxHttpService() = default;
160
- ~LynxHttpService() = default;
161
-
162
- void InitIfNeeded() override {
163
- if (http_service_) {
164
- return;
165
- }
166
- http_service_ = lynx_http_service_create_with_finalizer(
167
- new std::weak_ptr<LynxHttpService>(weak_from_this()),
168
- [](lynx_http_service_t* http_service, void* user_data) {
169
- std::weak_ptr<LynxHttpService>* weak_ptr =
170
- reinterpret_cast<std::weak_ptr<LynxHttpService>*>(user_data);
171
- delete weak_ptr;
172
- });
173
- lynx_http_service_bind(http_service_, [](lynx_http_service_t* http_service,
174
- lynx_http_request_t* request,
175
- lynx_http_response_t* response) {
176
- auto req = std::make_shared<LynxHttpRequest>(request);
177
- auto resp = std::make_shared<LynxHttpResponse>(response);
178
- std::weak_ptr<LynxHttpService>* weak_ptr =
179
- reinterpret_cast<std::weak_ptr<LynxHttpService>*>(
180
- lynx_http_service_get_user_data(http_service));
181
- std::shared_ptr<LynxHttpService> shared_http_service =
182
- weak_ptr ? weak_ptr->lock() : nullptr;
183
- if (!shared_http_service) {
184
- resp->SetStatusCode(-1);
185
- resp->SetStatusText("http service is destroyed");
186
- } else {
187
- shared_http_service->Request(req, resp);
188
- }
189
- });
190
- }
191
-
192
- lynx_service_type_e GetServiceType() override { return kServiceTypeHttp; }
193
-
194
- void* Impl() override { return http_service_; }
195
-
196
- /**
197
- * @apidoc
198
- * @brief Send an HTTP request.
199
- * @param request The HTTP request to be sent.
200
- * @param response The HTTP response to receive the response.
201
- */
202
- virtual void Request(std::shared_ptr<LynxHttpRequest> request,
203
- std::shared_ptr<LynxHttpResponse> response) = 0;
204
-
205
- private:
206
- lynx_http_service_t* http_service_ = nullptr;
207
- };
208
- } // namespace pub
209
- } // namespace lynx
210
-
211
- #endif // PLATFORM_EMBEDDER_PUBLIC_LYNX_HTTP_SERVICE_H_
@@ -1,120 +0,0 @@
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_LYNX_LOAD_META_H_
5
- #define PLATFORM_EMBEDDER_PUBLIC_LYNX_LOAD_META_H_
6
-
7
- #include <memory>
8
- #include <string>
9
- #include <utility>
10
- #include <vector>
11
-
12
- #include "capi/lynx_load_meta_capi.h"
13
- #include "lynx_template_bundle.h"
14
- #include "lynx_template_data.h"
15
-
16
- namespace lynx {
17
- namespace pub {
18
-
19
- /**
20
- * @apidoc
21
- * @brief `LynxLoadMeta` is the metadata structure used by LynxView to load
22
- * templates. It will be used as the input parameter of loadTemplate. Users can
23
- * use `LynxLoadMeta` to specify many parameters of loading templates, such as
24
- * specifying template content, template initial data, and other additional
25
- * configuration information. url, binary_data, bundle are the required
26
- * parameters for template loading. You can pass only one or all of them. The
27
- * priority relationship is as follows: bundle > binary_data > url.
28
- */
29
- class LynxLoadMeta {
30
- public:
31
- LynxLoadMeta() : load_meta_(lynx_load_meta_create()) {}
32
- ~LynxLoadMeta() { lynx_load_meta_release(load_meta_); }
33
-
34
- /**
35
- * @apidoc
36
- * @brief Set the url of the template to be loaded.
37
- * @param url The url of the template to be loaded.
38
- */
39
- void SetUrl(const std::string& url) {
40
- url_ = url;
41
- lynx_load_meta_set_url(load_meta_, url_.c_str());
42
- }
43
-
44
- /**
45
- * @apidoc
46
- * @brief Set the binary data of the template to be loaded.
47
- * @param content The binary data of the template to be loaded.
48
- */
49
- void SetBinaryData(std::vector<uint8_t> content) {
50
- lynx_load_meta_set_binary_data(load_meta_, content.data(), content.size(),
51
- nullptr, nullptr);
52
- }
53
-
54
- /**
55
- * @apidoc
56
- * @brief Set the binary data of the template to be loaded.
57
- * @param content The binary data of the template to be loaded.
58
- * @param length The length of the binary data.
59
- * @param dtor The destructor of the binary data.
60
- * @param opaque The opaque pointer of the binary data.
61
- */
62
- void SetBinaryData(uint8_t* content, size_t length,
63
- void (*dtor)(uint8_t*, size_t, void*) = nullptr,
64
- void* opaque = nullptr) {
65
- lynx_load_meta_set_binary_data(load_meta_, content, length, dtor, opaque);
66
- }
67
-
68
- /**
69
- * @apidoc
70
- * @brief Set the template bundle of the template to be loaded.
71
- * @param template_bundle The template bundle of the template to be loaded.
72
- */
73
- void SetTemplateBundle(std::shared_ptr<LynxTemplateBundle> template_bundle) {
74
- template_bundle_ = std::move(template_bundle);
75
- lynx_load_meta_set_template_bundle(load_meta_, template_bundle_->Impl());
76
- }
77
-
78
- /**
79
- * @apidoc
80
- * @brief Set the initial data of the template to be loaded.
81
- * @param initial_data The initial data of the template to be loaded.
82
- */
83
- void SetInitialData(std::shared_ptr<LynxTemplateData> initial_data) {
84
- initial_data_ = std::move(initial_data);
85
- lynx_load_meta_set_initial_data(load_meta_, initial_data_->Impl());
86
- }
87
-
88
- /**
89
- * @apidoc
90
- * @brief Set the global props of the template to be loaded.
91
- * @param global_props The global props of the template to be loaded.
92
- */
93
- void SetGlobalProps(std::shared_ptr<LynxTemplateData> global_props) {
94
- global_props_ = std::move(global_props);
95
- lynx_load_meta_set_global_props(load_meta_, global_props_->Impl());
96
- }
97
-
98
- std::string GetUrl() const { return url_; }
99
-
100
- bool IsBundleValid() const {
101
- return template_bundle_ != nullptr && template_bundle_->IsValid();
102
- }
103
-
104
- lynx_load_meta_t* Impl() { return load_meta_; }
105
-
106
- LynxLoadMeta(const LynxLoadMeta&) = delete;
107
- LynxLoadMeta& operator=(const LynxLoadMeta&) = delete;
108
-
109
- private:
110
- lynx_load_meta_t* load_meta_;
111
- std::string url_;
112
- std::shared_ptr<LynxTemplateBundle> template_bundle_;
113
- std::shared_ptr<LynxTemplateData> initial_data_;
114
- std::shared_ptr<LynxTemplateData> global_props_;
115
- };
116
-
117
- } // namespace pub
118
- } // namespace lynx
119
-
120
- #endif // PLATFORM_EMBEDDER_PUBLIC_LYNX_LOAD_META_H_
@@ -1,9 +0,0 @@
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_LYNX_NATIVE_MODULE_H_
5
- #define PLATFORM_EMBEDDER_PUBLIC_LYNX_NATIVE_MODULE_H_
6
-
7
- #include "capi/lynx_native_module_capi.h"
8
-
9
- #endif // PLATFORM_EMBEDDER_PUBLIC_LYNX_NATIVE_MODULE_H_
@@ -1,201 +0,0 @@
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_LYNX_NATIVE_VIEW_H_
5
- #define PLATFORM_EMBEDDER_PUBLIC_LYNX_NATIVE_VIEW_H_
6
-
7
- #include <functional>
8
-
9
- #include "capi/lynx_native_view_capi.h"
10
- #include "lynx_value.h"
11
- #include "lynx_view.h"
12
-
13
- namespace lynx {
14
- namespace pub {
15
-
16
- /**
17
- * @apidoc
18
- * @brief LynxNativeView is the base class that to embed platform
19
- * view and external texture like Android TextureView, within Lynx view tree.
20
- */
21
- class LynxNativeView {
22
- public:
23
- /**
24
- * Method invocation results
25
- */
26
- static constexpr int kSuccess = 0;
27
- static constexpr int kUnknown = 1;
28
- static constexpr int kMethodNotFound = 3;
29
- static constexpr int kInvalidParameter = 4;
30
- static constexpr int kInvalidStateError = 7;
31
-
32
- LynxNativeView() : native_view_(lynx_native_view_create(this)) {
33
- lynx_native_view_bind_on_create(
34
- native_view_, [](lynx_native_view_t* self, void* user_data) -> bool {
35
- return static_cast<LynxNativeView*>(user_data)->OnCreate();
36
- });
37
- lynx_native_view_bind_on_attach(
38
- native_view_, [](lynx_native_view_t* self, void* user_data) {
39
- static_cast<LynxNativeView*>(user_data)->OnAttach();
40
- });
41
- lynx_native_view_bind_on_detach(
42
- native_view_, [](lynx_native_view_t* self, void* user_data) {
43
- static_cast<LynxNativeView*>(user_data)->OnDetach();
44
- });
45
- lynx_native_view_bind_on_destroy(
46
- native_view_, [](lynx_native_view_t* self, void* user_data) {
47
- static_cast<LynxNativeView*>(user_data)->OnDestroy();
48
- });
49
- lynx_native_view_bind_release(
50
- native_view_, [](lynx_native_view_t* self, void* user_data) {
51
- static_cast<LynxNativeView*>(user_data)->Release();
52
- });
53
- lynx_native_view_bind_on_layout_changed(
54
- native_view_,
55
- [](lynx_native_view_t* self, void* user_data, float left, float top,
56
- float width, float height, float pixel_ratio) {
57
- static_cast<LynxNativeView*>(user_data)->OnLayoutChanged(
58
- left, top, width, height, pixel_ratio);
59
- });
60
- lynx_native_view_bind_on_properties_changed(
61
- native_view_, [](lynx_native_view_t* self, void* user_data,
62
- lynx_value attrs, lynx_value events) {
63
- static_cast<LynxNativeView*>(user_data)->OnPropertiesChanged(
64
- LynxValue(attrs), LynxValue(events));
65
- });
66
- lynx_native_view_bind_on_motion_event(
67
- native_view_, [](lynx_native_view_t* self, void* user_data,
68
- native_view_motion_event_t* event) {
69
- static_cast<LynxNativeView*>(user_data)->OnMotionEvent(event);
70
- });
71
- lynx_native_view_bind_on_focus_changed(
72
- native_view_, [](lynx_native_view_t* self, void* user_data,
73
- bool focused, bool is_leaf) {
74
- static_cast<LynxNativeView*>(user_data)->OnFocusChanged(focused,
75
- is_leaf);
76
- });
77
- lynx_native_view_bind_on_method_invoked(
78
- native_view_,
79
- [](lynx_native_view_t* self, void* user_data, const char* method,
80
- lynx_value attrs, lynx_native_view_callback callback,
81
- lynx_native_view_callback_info_t info) {
82
- static_cast<LynxNativeView*>(user_data)->OnMethodInvoked(
83
- method, LynxValue(attrs), [=](int code, LynxValue&& data) {
84
- lynx_value_add_reference(nullptr, data.Value(), nullptr);
85
- callback(info, code, data.Value());
86
- });
87
- });
88
- lynx_native_view_bind_is_scroll_enabled(
89
- native_view_, [](lynx_native_view_t* self, void* user_data) -> bool {
90
- return static_cast<LynxNativeView*>(user_data)->IsScrollEnabled();
91
- return false;
92
- });
93
- lynx_native_view_bind_is_surface_enabled(
94
- native_view_, [](lynx_native_view_t* self, void* user_data) -> bool {
95
- return static_cast<LynxNativeView*>(user_data)->IsSurfaceEnabled();
96
- return false;
97
- });
98
- lynx_native_view_bind_surface_buffer_mode(
99
- native_view_,
100
- [](lynx_native_view_t* self,
101
- void* user_data) -> lynx_surface_buffer_mode_t {
102
- return static_cast<LynxNativeView*>(user_data)->SurfaceBufferMode();
103
- });
104
- }
105
- virtual ~LynxNativeView() {}
106
-
107
- /**
108
- * @apidoc
109
- * @brief LynxNativeView lifecycle and callbacks
110
- */
111
- virtual bool OnCreate() { return true; }
112
- virtual void OnAttach() {}
113
- virtual void OnDetach() {}
114
- virtual void OnDestroy() {}
115
- virtual void OnLayoutChanged(float left, float top, float width, float height,
116
- float pixel_ratio) {}
117
- virtual void OnPropertiesChanged(const LynxValue& attrs,
118
- const LynxValue& events) {}
119
- virtual void OnMotionEvent(native_view_motion_event_t*) {}
120
- virtual void OnFocusChanged(bool focused, bool is_leaf) {}
121
- virtual void OnMethodInvoked(const char* method, const LynxValue& attrs,
122
- std::function<void(int, LynxValue&&)> callback) {
123
- callback(kMethodNotFound, LynxValue(LynxValue::kCreateAsNullTag));
124
- }
125
- virtual bool IsScrollEnabled() { return false; }
126
- virtual bool IsSurfaceEnabled() { return false; }
127
- virtual lynx_surface_buffer_mode_t SurfaceBufferMode() {
128
- return kDoubleBuffer;
129
- }
130
- virtual void Release() { delete this; }
131
-
132
- /**
133
- * @apidoc
134
- * @brief Create and present surface with external graphics buffer
135
- * @param width The width of surface
136
- * @param height The height of surface
137
- * @param transform The transformation matrix that will be applied on screen
138
- * @param handle The resource handle of system graphics buffer
139
- */
140
- inline bool PresentSurface(int width, int height, const float* transform,
141
- lynx_surface_handle_t* handle) {
142
- return lynx_native_view_present_surface(native_view_, width, height,
143
- transform, handle);
144
- }
145
-
146
- /**
147
- * @apidoc
148
- * @brief Acquire the latest back buffer
149
- * @param width The width of surface
150
- * @param height The height of surface
151
- * @return Platform native graphics handle. On Darwin this is IOSurfaceRef.
152
- * On Windows this is a D3D shared HANDLE for the back buffer,
153
- * not a texture/device pointer. Import it with the graphics
154
- * API/device that matches the active Windows backend.
155
- */
156
- inline lynx_surface_handle_t* AcquireSurface(int width, int height) {
157
- return lynx_native_view_acquire_surface(native_view_, width, height);
158
- }
159
-
160
- /**
161
- * @apidoc
162
- * @brief Swap the current back buffer to pending front
163
- */
164
- inline bool SwapBack() { return lynx_native_view_swap_back(native_view_); }
165
-
166
- /**
167
- * @apidoc
168
- * @brief Trigger customized JS event to Lynx element
169
- * @param name The name of event
170
- * @param params The arguments be passed to JS handlers
171
- */
172
- inline void TriggerEvent(const char* name, LynxValue&& params) {
173
- lynx_value_add_reference(nullptr, params.Value(), nullptr);
174
- lynx_native_view_trigger_event(native_view_, name, params.Value());
175
- }
176
-
177
- /**
178
- * @apidoc
179
- * @brief Request focus if Lynx element need to capture input method
180
- */
181
- inline void RequestFocus() { lynx_native_view_request_focus(native_view_); }
182
-
183
- /**
184
- * @apidoc
185
- * @brief Mark dirty to request redrawing
186
- */
187
- inline void MarkDirty() { lynx_native_view_mark_dirty(native_view_); }
188
-
189
- inline lynx_native_view_t* native_view() { return native_view_; }
190
-
191
- LynxNativeView(const LynxNativeView&) = delete;
192
- LynxNativeView& operator=(const LynxNativeView&) = delete;
193
-
194
- private:
195
- lynx_native_view_t* native_view_;
196
- };
197
-
198
- } // namespace pub
199
- } // namespace lynx
200
-
201
- #endif // PLATFORM_EMBEDDER_PUBLIC_LYNX_NATIVE_VIEW_H_
@@ -1,56 +0,0 @@
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_LYNX_RESOURCE_REQUEST_H_
5
- #define PLATFORM_EMBEDDER_PUBLIC_LYNX_RESOURCE_REQUEST_H_
6
-
7
- #include "capi/lynx_resource_request_capi.h"
8
-
9
- namespace lynx {
10
- namespace pub {
11
- namespace resource {
12
- /**
13
- * @apidoc
14
- * @brief `LynxResourceRequest` is a class that represents a resource request.
15
- */
16
- class LynxResourceRequest {
17
- public:
18
- explicit LynxResourceRequest(lynx_resource_request_t* request)
19
- : request_(request) {}
20
-
21
- ~LynxResourceRequest() { lynx_resource_request_release(request_); }
22
-
23
- /**
24
- * @apidoc
25
- * @brief Get the request id of the resource request.
26
- * @return The request id of the resource request.
27
- */
28
- lynx_resource_request_id GetRequestId() {
29
- return lynx_resource_request_get_id(request_);
30
- }
31
-
32
- /**
33
- * @apidoc
34
- * @brief Get the URL of the resource request.
35
- * @return The URL of the resource request.
36
- */
37
- const char* GetUrl() { return lynx_resource_request_get_url(request_); }
38
-
39
- /**
40
- * @apidoc
41
- * @brief Get the type of the resource request.
42
- * @return The type of the resource request.
43
- */
44
- lynx_resource_type_e GetType() {
45
- return lynx_resource_request_get_type(request_);
46
- }
47
-
48
- private:
49
- lynx_resource_request_t* request_;
50
- };
51
-
52
- } // namespace resource
53
- } // namespace pub
54
- } // namespace lynx
55
-
56
- #endif // PLATFORM_EMBEDDER_PUBLIC_LYNX_RESOURCE_REQUEST_H_