@cpp.js/package-curl 2.0.0-beta.2 → 2.0.0-beta.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpp.js/package-curl",
3
- "version": "2.0.0-beta.2",
3
+ "version": "2.0.0-beta.4",
4
4
  "nativeVersion": "8.17.0",
5
5
  "description": "This package provides a CURL library compiled with Cpp.js, enabling seamless usage of CURL functionalities in JavaScript, WebAssembly and React Native projects. Client-side URL transfers for web and mobile applications.",
6
6
  "homepage": "https://github.com/bugra9/cpp.js/tree/main/packages/cppjs-package-curl#readme",
@@ -15,11 +15,11 @@
15
15
  "react-native"
16
16
  ],
17
17
  "dependencies": {
18
- "@cpp.js/package-curl-wasm": "^2.0.0-beta.1",
19
- "@cpp.js/package-curl-android": "^2.0.0-beta.1",
20
- "@cpp.js/package-curl-ios": "^2.0.0-beta.1"
18
+ "@cpp.js/package-curl-wasm": "^2.0.0-beta.4",
19
+ "@cpp.js/package-curl-android": "^2.0.0-beta.4",
20
+ "@cpp.js/package-curl-ios": "^2.0.0-beta.4"
21
21
  },
22
22
  "devDependencies": {
23
- "cpp.js": "^2.0.0-beta.1"
23
+ "cpp.js": "^2.0.0-beta.4"
24
24
  }
25
25
  }
@@ -1,13 +0,0 @@
1
- require "json"
2
- package = JSON.parse(File.read(File.join(__dir__, "package.json")))
3
-
4
- Pod::Spec.new do |s|
5
- s.module_name = "curl"
6
- s.name = "cppjs-package-curl"
7
- s.version = package["nativeVersion"]
8
- s.summary = "Transferring data with URLs"
9
- s.homepage = "https://curl.se/"
10
- s.author = "CURL Authors"
11
- s.source = { :http => "https://cpp.js.org" }
12
- s.vendored_frameworks = 'curl.xcframework'
13
- end
package/cppjs.build.js DELETED
@@ -1,182 +0,0 @@
1
- const easyPerformAbove = `
2
- #ifdef __EMSCRIPTEN__
3
- static void on_success(emscripten_fetch_t *fetch) {
4
- void **userData = (void **)fetch->userData;
5
- volatile emscripten_fetch_t **fetch_result_ptr = (volatile emscripten_fetch_t **)userData[0];
6
- volatile int *fetch_completed_ptr = (volatile int *)userData[1];
7
- *fetch_result_ptr = fetch;
8
- *fetch_completed_ptr = 1;
9
- }
10
-
11
- static void on_error(emscripten_fetch_t *fetch) {
12
- void **userData = (void **)fetch->userData;
13
- volatile emscripten_fetch_t **fetch_result_ptr = (volatile emscripten_fetch_t **)userData[0];
14
- volatile int *fetch_completed_ptr = (volatile int *)userData[1];
15
- *fetch_result_ptr = fetch;
16
- *fetch_completed_ptr = 1;
17
- }
18
- #endif
19
- `;
20
-
21
- const easyPerformInside = `
22
- #ifdef __EMSCRIPTEN__
23
- char method[10] = "GET";
24
- switch (data->set.method) {
25
- case HTTPREQ_GET:
26
- strcpy(method, "GET");
27
- break;
28
- case HTTPREQ_POST:
29
- case HTTPREQ_POST_FORM:
30
- case HTTPREQ_POST_MIME:
31
- strcpy(method, "POST");
32
- break;
33
- case HTTPREQ_PUT:
34
- strcpy(method, "PUT");
35
- break;
36
- case HTTPREQ_HEAD:
37
- strcpy(method, "HEAD");
38
- break;
39
- }
40
- if (data->set.str[28]) {
41
- strcpy(method, data->set.str[28]);
42
- }
43
- emscripten_fetch_attr_t attr;
44
- emscripten_fetch_attr_init(&attr);
45
- strcpy(attr.requestMethod, method);
46
- if (data->set.postfields) {
47
- attr.requestData = data->set.postfields;
48
- attr.requestDataSize = strlen(data->set.postfields);
49
- }
50
- if (data->set.headers) {
51
- int header_count = 0;
52
- struct curl_slist* temp = data->set.headers;
53
- while (temp) {
54
- header_count++;
55
- temp = temp->next;
56
- }
57
-
58
- const char** result = (const char**)malloc(sizeof(char*) * (header_count * 2 + 1));
59
-
60
- temp = data->set.headers;
61
- int i = 0;
62
- while (temp) {
63
- char* header_line = strdup(temp->data);
64
- char* colon = strchr(header_line, ':');
65
-
66
- if (colon) {
67
- *colon = '\0';
68
- char* value = colon + 1;
69
-
70
- while (*value == ' ') value++;
71
-
72
- result[i++] = strdup(header_line);
73
- result[i++] = strdup(value);
74
- } else {}
75
-
76
- free(header_line);
77
- temp = temp->next;
78
- }
79
- result[i] = NULL;
80
-
81
- attr.requestHeaders = result;
82
- }
83
- attr.attributes = EMSCRIPTEN_FETCH_LOAD_TO_MEMORY;
84
-
85
- volatile int fetch_completed = 0;
86
- volatile emscripten_fetch_t* fetch = NULL;
87
- void* userData[2] = { (void*)&fetch, (void*)&fetch_completed };
88
-
89
- attr.onsuccess = on_success;
90
- attr.onerror = on_error;
91
- attr.userData = userData;
92
-
93
- emscripten_fetch(&attr, data->state.url);
94
-
95
- while (!fetch_completed) {
96
- emscripten_sleep(100);
97
- }
98
-
99
- data->info.httpcode = fetch->status;
100
- if (fetch->status == 200) {
101
- if (data->set.out) {
102
- data->set.fwrite_func(fetch->data, 1, fetch->numBytes, data->set.out);
103
- }
104
- } else if (fetch->status >= 400) {
105
- if (data->set.http_fail_on_error && data->set.errorbuffer) {
106
- data->set.fwrite_func(fetch->data, 1, fetch->numBytes, data->set.errorbuffer);
107
- } else if (data->set.out) {
108
- data->set.fwrite_func(fetch->data, 1, fetch->numBytes, data->set.out);
109
- }
110
- } else {
111
- if (data->set.out) {
112
- data->set.fwrite_func(fetch->data, 1, fetch->numBytes, data->set.out);
113
- }
114
- }
115
-
116
- if (attr.requestHeaders) {
117
- for (int i = 0; attr.requestHeaders[i] != NULL; i++) {
118
- free((void*)attr.requestHeaders[i]);
119
- }
120
-
121
- free(attr.requestHeaders);
122
- }
123
-
124
- emscripten_fetch_close(fetch);
125
-
126
- if (data->set.http_fail_on_error && fetch->status >= 400) {
127
- return CURLE_HTTP_RETURNED_ERROR;
128
- }
129
-
130
- return CURLE_OK;
131
- #endif
132
- `;
133
-
134
- const fetchImportString = `
135
- #ifdef __EMSCRIPTEN__
136
- #include <emscripten.h>
137
- #include <emscripten/fetch.h>
138
- #endif
139
- `;
140
-
141
- const platformBuild = {
142
- 'Emscripten-x86_64': ['-DBUILD_SHARED_LIBS=OFF', '-DBUILD_STATIC_LIBS=ON'],
143
- 'Android-arm64-v8a': ['-DBUILD_SHARED_LIBS=ON', '-DBUILD_STATIC_LIBS=OFF'],
144
- 'Android-x86_64': ['-DBUILD_SHARED_LIBS=ON', '-DBUILD_STATIC_LIBS=OFF'],
145
- 'iOS-iphoneos': ['-DBUILD_SHARED_LIBS=OFF', '-DBUILD_STATIC_LIBS=ON'],
146
- 'iOS-iphonesimulator': ['-DBUILD_SHARED_LIBS=OFF', '-DBUILD_STATIC_LIBS=ON'],
147
- };
148
-
149
- export default {
150
- getURL: (version) => `https://curl.se/download/curl-${version}.tar.gz`,
151
- replaceList: [
152
- {
153
- regex: 'static CURLcode easy_perform\\(struct Curl_easy \\*data, bool events\\)',
154
- replacement: `${easyPerformAbove}\nstatic CURLcode easy_perform(struct Curl_easy *data, bool events)`,
155
- paths: ['lib/easy.c'],
156
- },
157
- {
158
- regex: ' struct Curl\\_multi \\*multi\\;',
159
- replacement: `${easyPerformInside}\n struct Curl_multi *multi;`,
160
- paths: ['lib/easy.c'],
161
- },
162
- {
163
- regex: '#include "urldata.h"',
164
- replacement: `${fetchImportString}\n#include "urldata.h"`,
165
- paths: ['lib/easy.c'],
166
- },
167
- ],
168
- buildType: 'cmake',
169
- getBuildParams: (platform, depPaths) => [
170
- ...(platformBuild[platform] || []),
171
- `-DOPENSSL_INCLUDE_DIR=${depPaths.ssl.header}`,
172
- `-DOPENSSL_SSL_LIBRARY=${depPaths.ssl.lib}`,
173
- `-DOPENSSL_CRYPTO_LIBRARY=${depPaths.crypto.lib}`,
174
- // `-DOPENSSL_CMAKE_PATH=${depPaths.cmake.openssl}`,
175
- '-DBUILD_EXAMPLES=OFF', '-DBUILD_CURL_EXE=OFF', '-DBUILD_LIBCURL_DOCS=OFF',
176
- '-DBUILD_TESTING=OFF',
177
- '-DENABLE_CURL_MANUAL=OFF', // '-DCURL_DISABLE_THREADED_RESOLVER=ON','-DCURL_DISABLE_THREAD=ON',
178
- '-DENABLE_NETRC=OFF', '-DCURL_USE_LIBPSL=OFF', '-DENABLE_IPV6=OFF', '-DENABLE_NTLMWB=OFF',
179
- // '-DCURL_DISABLE_UNIX_SOCKETS=ON',
180
- // '-DCURL_ENABLE_EXPORT_TARGET=OFF'
181
- ],
182
- };