@nativescript/canvas 2.0.0-alpha.30 → 2.0.0-alpha.32

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 (40) hide show
  1. package/Canvas/common.d.ts +14 -0
  2. package/Canvas/common.js +19 -8
  3. package/Canvas/common.js.map +1 -1
  4. package/Canvas/index.android.d.ts +1 -0
  5. package/Canvas/index.android.js +36 -7
  6. package/Canvas/index.android.js.map +1 -1
  7. package/Canvas/index.ios.d.ts +2 -1
  8. package/Canvas/index.ios.js +64 -34
  9. package/Canvas/index.ios.js.map +1 -1
  10. package/Canvas2D/CanvasRenderingContext2D/index.js +1 -1
  11. package/Canvas2D/CanvasRenderingContext2D/index.js.map +1 -1
  12. package/package.json +1 -1
  13. package/platforms/android/canvas-release.aar +0 -0
  14. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
  15. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative-Swift.h +1 -0
  16. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +70 -4
  17. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  18. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +209 -187
  19. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +1 -0
  20. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +1 -0
  21. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  22. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
  23. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative-Swift.h +2 -0
  24. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +70 -4
  25. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  26. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  27. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +209 -187
  28. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +1 -0
  29. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +1 -0
  30. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +209 -187
  31. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +1 -0
  32. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +1 -0
  33. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +24 -24
  34. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  35. package/platforms/ios/src/cpp/Caches.h +4 -0
  36. package/platforms/ios/src/cpp/CanvasJSIModule.cpp +37 -0
  37. package/platforms/ios/src/cpp/CanvasJSIModule.h +10 -1
  38. package/platforms/ios/src/cpp/URLImpl.cpp +464 -0
  39. package/platforms/ios/src/cpp/URLImpl.h +119 -0
  40. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +20 -12
@@ -0,0 +1,464 @@
1
+ //
2
+ // Created by Osei Fortune on 15/011/2023.
3
+ //
4
+
5
+ #include "URLImpl.h"
6
+ #include "Caches.h"
7
+ #include "Helpers.h"
8
+ #include "OneByteStringResource.h"
9
+
10
+ URLImpl::URLImpl(URL *url) : url_(url) {}
11
+
12
+ void URLImpl::Init(const v8::Local<v8::Object> &canvasModule, v8::Isolate *isolate) {
13
+ v8::Locker locker(isolate);
14
+ v8::Isolate::Scope isolate_scope(isolate);
15
+ v8::HandleScope handle_scope(isolate);
16
+
17
+ auto ctor = GetCtor(isolate);
18
+ auto context = isolate->GetCurrentContext();
19
+ auto func = ctor->GetFunction(context).ToLocalChecked();
20
+
21
+ canvasModule->Set(context, ConvertToV8String(isolate, "URL"), func);
22
+ }
23
+
24
+ URLImpl *URLImpl::GetPointer(v8::Local<v8::Object> object) {
25
+ auto ptr = object->GetInternalField(0).As<v8::External>()->Value();
26
+ if (ptr == nullptr) {
27
+ return nullptr;
28
+ }
29
+ return static_cast<URLImpl *>(ptr);
30
+ }
31
+
32
+ URL *URLImpl::GetURL() {
33
+ return this->url_;
34
+ }
35
+
36
+ v8::Local<v8::FunctionTemplate> URLImpl::GetCtor(v8::Isolate *isolate) {
37
+ auto cache = Caches::Get(isolate);
38
+ auto ctor = cache->URLTmpl.get();
39
+ if (ctor != nullptr) {
40
+ return ctor->Get(isolate);
41
+ }
42
+
43
+ v8::Local<v8::FunctionTemplate> ctorTmpl = v8::FunctionTemplate::New(isolate, Ctor);
44
+ ctorTmpl->InstanceTemplate()->SetInternalFieldCount(1);
45
+ ctorTmpl->SetClassName(ConvertToV8String(isolate, "URL"));
46
+
47
+ auto tmpl = ctorTmpl->InstanceTemplate();
48
+ tmpl->SetInternalFieldCount(1);
49
+ tmpl->SetAccessor(
50
+ ConvertToV8String(isolate, "hash"),
51
+ GetHash, SetHash);
52
+ tmpl->SetAccessor(
53
+ ConvertToV8String(isolate, "host"),
54
+ GetHost, SetHost);
55
+ tmpl->SetAccessor(
56
+ ConvertToV8String(isolate, "hostname"),
57
+ GetHostName, SetHostName);
58
+ tmpl->SetAccessor(
59
+ ConvertToV8String(isolate, "href"),
60
+ GetHref, SetHref);
61
+
62
+ tmpl->SetAccessor(
63
+ ConvertToV8String(isolate, "origin"),
64
+ GetOrigin);
65
+
66
+ tmpl->SetAccessor(
67
+ ConvertToV8String(isolate, "password"),
68
+ GetPassword, SetPassword);
69
+
70
+ tmpl->SetAccessor(
71
+ ConvertToV8String(isolate, "pathname"),
72
+ GetPathName, SetPathName);
73
+
74
+ tmpl->SetAccessor(
75
+ ConvertToV8String(isolate, "port"),
76
+ GetPort, SetPort);
77
+
78
+ tmpl->SetAccessor(
79
+ ConvertToV8String(isolate, "protocol"),
80
+ GetProtocol, SetProtocol);
81
+
82
+ tmpl->SetAccessor(
83
+ ConvertToV8String(isolate, "search"),
84
+ GetSearch, SetSearch);
85
+
86
+ tmpl->SetAccessor(
87
+ ConvertToV8String(isolate, "username"),
88
+ GetUserName, SetUserName);
89
+
90
+ tmpl->Set(ConvertToV8String(isolate, "toString"),
91
+ v8::FunctionTemplate::New(isolate, &ToString));
92
+
93
+
94
+ ctorTmpl->Set(ConvertToV8String(isolate, "canParse"),
95
+ v8::FunctionTemplate::New(isolate, &CanParse));
96
+
97
+ cache->URLTmpl =
98
+ std::make_unique<v8::Persistent<v8::FunctionTemplate>>(isolate, ctorTmpl);
99
+ return ctorTmpl;
100
+ }
101
+
102
+ void URLImpl::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
103
+ auto count = args.Length();
104
+ auto value = args[0];
105
+ auto isolate = args.GetIsolate();
106
+ if (count >= 1 && !value->IsString()) {
107
+ isolate->ThrowException(v8::Exception::TypeError(ConvertToV8String(isolate, "")));
108
+ return;
109
+ }
110
+
111
+
112
+ URL *url;
113
+
114
+ if (count > 1) {
115
+ url = canvas_url_create(ConvertFromV8String(isolate, args[0]).c_str(),
116
+ ConvertFromV8String(isolate, args[1]).c_str());
117
+ } else {
118
+ url = canvas_url_create(ConvertFromV8String(isolate, args[0]).c_str(), nullptr);
119
+ }
120
+
121
+ auto ret = args.This();
122
+
123
+ auto decoder = new URLImpl(url);
124
+
125
+ auto ext = v8::External::New(isolate, decoder);
126
+
127
+ ret->SetInternalField(0, ext);
128
+
129
+ args.GetReturnValue().Set(ret);
130
+
131
+ }
132
+
133
+
134
+ void URLImpl::GetHash(v8::Local<v8::String> property,
135
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
136
+ URLImpl *ptr = GetPointer(info.This());
137
+ if (ptr == nullptr) {
138
+ info.GetReturnValue().SetEmptyString();
139
+ return;
140
+ }
141
+ auto isolate = info.GetIsolate();
142
+
143
+ auto value = canvas_url_hash(ptr->GetURL());
144
+ info.GetReturnValue().Set(ConvertToV8String(isolate, value));
145
+ canvas_native_string_destroy((char *) value);
146
+
147
+ }
148
+
149
+ void URLImpl::SetHash(v8::Local<v8::String> property,
150
+ v8::Local<v8::Value> value,
151
+ const v8::PropertyCallbackInfo<void> &info) {
152
+ URLImpl *ptr = GetPointer(info.This());
153
+ if (ptr == nullptr) {
154
+ return;
155
+ }
156
+ auto isolate = info.GetIsolate();
157
+ auto context = isolate->GetCurrentContext();
158
+ auto val = ConvertFromV8String(isolate, value->ToString(context).ToLocalChecked());
159
+ canvas_url_set_hash(ptr->GetURL(), val.c_str());
160
+ }
161
+
162
+
163
+ void URLImpl::GetHost(v8::Local<v8::String> property,
164
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
165
+ URLImpl *ptr = GetPointer(info.This());
166
+ if (ptr == nullptr) {
167
+ info.GetReturnValue().SetEmptyString();
168
+ return;
169
+ }
170
+ auto isolate = info.GetIsolate();
171
+
172
+ auto value = canvas_url_host(ptr->GetURL());
173
+ info.GetReturnValue().Set(ConvertToV8String(isolate, value));
174
+ canvas_native_string_destroy((char *) value);
175
+
176
+ }
177
+
178
+ void URLImpl::SetHost(v8::Local<v8::String> property,
179
+ v8::Local<v8::Value> value,
180
+ const v8::PropertyCallbackInfo<void> &info) {
181
+ URLImpl *ptr = GetPointer(info.This());
182
+ if (ptr == nullptr) {
183
+ return;
184
+ }
185
+ auto isolate = info.GetIsolate();
186
+ auto context = isolate->GetCurrentContext();
187
+ auto val = ConvertFromV8String(isolate, value->ToString(context).ToLocalChecked());
188
+ canvas_url_set_host(ptr->GetURL(), val.c_str());
189
+ }
190
+
191
+
192
+ void URLImpl::GetHostName(v8::Local<v8::String> property,
193
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
194
+ URLImpl *ptr = GetPointer(info.This());
195
+ if (ptr == nullptr) {
196
+ info.GetReturnValue().SetEmptyString();
197
+ return;
198
+ }
199
+ auto isolate = info.GetIsolate();
200
+
201
+ auto value = canvas_url_host_name(ptr->GetURL());
202
+ info.GetReturnValue().Set(ConvertToV8String(isolate, value));
203
+ canvas_native_string_destroy((char *) value);
204
+
205
+ }
206
+
207
+ void URLImpl::SetHostName(v8::Local<v8::String> property,
208
+ v8::Local<v8::Value> value,
209
+ const v8::PropertyCallbackInfo<void> &info) {
210
+ URLImpl *ptr = GetPointer(info.This());
211
+ if (ptr == nullptr) {
212
+ return;
213
+ }
214
+ auto isolate = info.GetIsolate();
215
+ auto context = isolate->GetCurrentContext();
216
+ auto val = ConvertFromV8String(isolate, value->ToString(context).ToLocalChecked());
217
+ canvas_url_set_host_name(ptr->GetURL(), val.c_str());
218
+ }
219
+
220
+
221
+ void URLImpl::GetHref(v8::Local<v8::String> property,
222
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
223
+ URLImpl *ptr = GetPointer(info.This());
224
+ if (ptr == nullptr) {
225
+ info.GetReturnValue().SetEmptyString();
226
+ return;
227
+ }
228
+ auto isolate = info.GetIsolate();
229
+
230
+ auto value = canvas_url_href(ptr->GetURL());
231
+ info.GetReturnValue().Set(ConvertToV8String(isolate, value));
232
+ canvas_native_string_destroy((char *) value);
233
+
234
+ }
235
+
236
+ void URLImpl::SetHref(v8::Local<v8::String> property,
237
+ v8::Local<v8::Value> value,
238
+ const v8::PropertyCallbackInfo<void> &info) {
239
+ URLImpl *ptr = GetPointer(info.This());
240
+ if (ptr == nullptr) {
241
+ return;
242
+ }
243
+ auto isolate = info.GetIsolate();
244
+ auto context = isolate->GetCurrentContext();
245
+ auto val = ConvertFromV8String(isolate, value->ToString(context).ToLocalChecked());
246
+ canvas_url_set_href(ptr->GetURL(), val.c_str());
247
+ }
248
+
249
+ void URLImpl::GetOrigin(v8::Local<v8::String> property,
250
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
251
+ URLImpl *ptr = GetPointer(info.This());
252
+ if (ptr == nullptr) {
253
+ info.GetReturnValue().SetEmptyString();
254
+ return;
255
+ }
256
+ auto isolate = info.GetIsolate();
257
+
258
+ auto value = canvas_url_origin(ptr->GetURL());
259
+ info.GetReturnValue().Set(ConvertToV8String(isolate, value));
260
+ canvas_native_string_destroy((char *) value);
261
+
262
+ }
263
+
264
+ void URLImpl::GetPassword(v8::Local<v8::String> property,
265
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
266
+ URLImpl *ptr = GetPointer(info.This());
267
+ if (ptr == nullptr) {
268
+ info.GetReturnValue().SetEmptyString();
269
+ return;
270
+ }
271
+ auto isolate = info.GetIsolate();
272
+
273
+ auto value = canvas_url_password(ptr->GetURL());
274
+ info.GetReturnValue().Set(ConvertToV8String(isolate, value));
275
+ canvas_native_string_destroy((char *) value);
276
+
277
+ }
278
+
279
+ void URLImpl::SetPassword(v8::Local<v8::String> property,
280
+ v8::Local<v8::Value> value,
281
+ const v8::PropertyCallbackInfo<void> &info) {
282
+ URLImpl *ptr = GetPointer(info.This());
283
+ if (ptr == nullptr) {
284
+ return;
285
+ }
286
+ auto isolate = info.GetIsolate();
287
+ auto context = isolate->GetCurrentContext();
288
+ auto val = ConvertFromV8String(isolate, value->ToString(context).ToLocalChecked());
289
+ canvas_url_set_password(ptr->GetURL(), val.c_str());
290
+ }
291
+
292
+ void URLImpl::GetPathName(v8::Local<v8::String> property,
293
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
294
+ URLImpl *ptr = GetPointer(info.This());
295
+ if (ptr == nullptr) {
296
+ info.GetReturnValue().SetEmptyString();
297
+ return;
298
+ }
299
+ auto isolate = info.GetIsolate();
300
+
301
+ auto value = canvas_url_pathname(ptr->GetURL());
302
+ info.GetReturnValue().Set(ConvertToV8String(isolate, value));
303
+ canvas_native_string_destroy((char *) value);
304
+
305
+ }
306
+
307
+ void URLImpl::SetPathName(v8::Local<v8::String> property,
308
+ v8::Local<v8::Value> value,
309
+ const v8::PropertyCallbackInfo<void> &info) {
310
+ URLImpl *ptr = GetPointer(info.This());
311
+ if (ptr == nullptr) {
312
+ return;
313
+ }
314
+ auto isolate = info.GetIsolate();
315
+ auto context = isolate->GetCurrentContext();
316
+ auto val = ConvertFromV8String(isolate, value->ToString(context).ToLocalChecked());
317
+ canvas_url_set_pathname(ptr->GetURL(), val.c_str());
318
+ }
319
+
320
+ void URLImpl::GetPort(v8::Local<v8::String> property,
321
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
322
+ URLImpl *ptr = GetPointer(info.This());
323
+ if (ptr == nullptr) {
324
+ info.GetReturnValue().SetEmptyString();
325
+ return;
326
+ }
327
+ auto isolate = info.GetIsolate();
328
+
329
+ auto value = canvas_url_port(ptr->GetURL());
330
+ info.GetReturnValue().Set(ConvertToV8String(isolate, value));
331
+ canvas_native_string_destroy((char *) value);
332
+
333
+ }
334
+
335
+ void URLImpl::SetPort(v8::Local<v8::String> property,
336
+ v8::Local<v8::Value> value,
337
+ const v8::PropertyCallbackInfo<void> &info) {
338
+ URLImpl *ptr = GetPointer(info.This());
339
+ if (ptr == nullptr) {
340
+ return;
341
+ }
342
+ auto isolate = info.GetIsolate();
343
+ auto context = isolate->GetCurrentContext();
344
+ auto val = ConvertFromV8String(isolate, value->ToString(context).ToLocalChecked());
345
+ canvas_url_set_port(ptr->GetURL(), val.c_str());
346
+ }
347
+
348
+ void URLImpl::GetProtocol(v8::Local<v8::String> property,
349
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
350
+ URLImpl *ptr = GetPointer(info.This());
351
+ if (ptr == nullptr) {
352
+ info.GetReturnValue().SetEmptyString();
353
+ return;
354
+ }
355
+ auto isolate = info.GetIsolate();
356
+
357
+ auto value = canvas_url_protocol(ptr->GetURL());
358
+ info.GetReturnValue().Set(ConvertToV8String(isolate, value));
359
+ canvas_native_string_destroy((char *) value);
360
+
361
+ }
362
+
363
+ void URLImpl::SetProtocol(v8::Local<v8::String> property,
364
+ v8::Local<v8::Value> value,
365
+ const v8::PropertyCallbackInfo<void> &info) {
366
+ URLImpl *ptr = GetPointer(info.This());
367
+ if (ptr == nullptr) {
368
+ return;
369
+ }
370
+ auto isolate = info.GetIsolate();
371
+ auto context = isolate->GetCurrentContext();
372
+ auto val = ConvertFromV8String(isolate, value->ToString(context).ToLocalChecked());
373
+ canvas_url_set_protocol(ptr->GetURL(), val.c_str());
374
+ }
375
+
376
+
377
+ void URLImpl::GetSearch(v8::Local<v8::String> property,
378
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
379
+ URLImpl *ptr = GetPointer(info.This());
380
+ if (ptr == nullptr) {
381
+ info.GetReturnValue().SetEmptyString();
382
+ return;
383
+ }
384
+ auto isolate = info.GetIsolate();
385
+
386
+ auto value = canvas_url_search(ptr->GetURL());
387
+ info.GetReturnValue().Set(ConvertToV8String(isolate, value));
388
+ canvas_native_string_destroy((char *) value);
389
+
390
+ }
391
+
392
+ void URLImpl::SetSearch(v8::Local<v8::String> property,
393
+ v8::Local<v8::Value> value,
394
+ const v8::PropertyCallbackInfo<void> &info) {
395
+ URLImpl *ptr = GetPointer(info.This());
396
+ if (ptr == nullptr) {
397
+ return;
398
+ }
399
+ auto isolate = info.GetIsolate();
400
+ auto context = isolate->GetCurrentContext();
401
+ auto val = ConvertFromV8String(isolate, value->ToString(context).ToLocalChecked());
402
+ canvas_url_set_search(ptr->GetURL(), val.c_str());
403
+ }
404
+
405
+
406
+ void URLImpl::GetUserName(v8::Local<v8::String> property,
407
+ const v8::PropertyCallbackInfo<v8::Value> &info) {
408
+ URLImpl *ptr = GetPointer(info.This());
409
+ if (ptr == nullptr) {
410
+ info.GetReturnValue().SetEmptyString();
411
+ return;
412
+ }
413
+ auto isolate = info.GetIsolate();
414
+
415
+ auto value = canvas_url_username(ptr->GetURL());
416
+ info.GetReturnValue().Set(ConvertToV8String(isolate, value));
417
+ canvas_native_string_destroy((char *) value);
418
+
419
+ }
420
+
421
+ void URLImpl::SetUserName(v8::Local<v8::String> property,
422
+ v8::Local<v8::Value> value,
423
+ const v8::PropertyCallbackInfo<void> &info) {
424
+ URLImpl *ptr = GetPointer(info.This());
425
+ if (ptr == nullptr) {
426
+ return;
427
+ }
428
+ auto isolate = info.GetIsolate();
429
+ auto context = isolate->GetCurrentContext();
430
+ auto val = ConvertFromV8String(isolate, value->ToString(context).ToLocalChecked());
431
+ canvas_url_set_username(ptr->GetURL(), val.c_str());
432
+ }
433
+
434
+
435
+ void URLImpl::ToString(const v8::FunctionCallbackInfo<v8::Value> &args) {
436
+ URLImpl *ptr = GetPointer(args.This());
437
+ if (ptr == nullptr) {
438
+ args.GetReturnValue().SetEmptyString();
439
+ return;
440
+ }
441
+ auto isolate = args.GetIsolate();
442
+
443
+ auto value = canvas_url_to_string(ptr->GetURL());
444
+
445
+ auto returnValue = new OneByteStringResource(value);
446
+ auto ret = v8::String::NewExternalOneByte(isolate, returnValue);
447
+ args.GetReturnValue().Set(ret.ToLocalChecked());
448
+ }
449
+
450
+
451
+ void URLImpl::CanParse(const v8::FunctionCallbackInfo<v8::Value> &args) {
452
+ auto isolate = args.GetIsolate();
453
+ bool value;
454
+ auto count = args.Length();
455
+
456
+ if (count > 1) {
457
+ value = canvas_url_can_parse(ConvertFromV8String(isolate, args[0]).c_str(),
458
+ ConvertFromV8String(isolate, args[1]).c_str());
459
+ } else {
460
+ value = canvas_url_can_parse(ConvertFromV8String(isolate, args[0]).c_str(), nullptr);
461
+ }
462
+
463
+ args.GetReturnValue().Set(value);
464
+ }
@@ -0,0 +1,119 @@
1
+ //
2
+ // Created by Osei Fortune on 15/011/2023.
3
+ //
4
+
5
+ #pragma once
6
+
7
+ #include <vector>
8
+ #include "Common.h"
9
+
10
+ class URLImpl {
11
+ public:
12
+ URLImpl(URL *url);
13
+
14
+ ~URLImpl() {
15
+ canvas_url_destroy(this->GetURL());
16
+ this->url_ = nullptr;
17
+ }
18
+
19
+ URL *GetURL();
20
+
21
+ static void Init(const v8::Local<v8::Object> &canvasModule, v8::Isolate *isolate);
22
+
23
+ static URLImpl *GetPointer(v8::Local<v8::Object> object);
24
+
25
+ static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate);
26
+
27
+ static void Ctor(const v8::FunctionCallbackInfo<v8::Value> &args);
28
+
29
+
30
+ static void
31
+ GetHash(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value> &info);
32
+
33
+ static void SetHash(v8::Local<v8::String> property,
34
+ v8::Local<v8::Value> value,
35
+ const v8::PropertyCallbackInfo<void> &info);
36
+
37
+
38
+ static void
39
+ GetHost(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value> &info);
40
+
41
+ static void SetHost(v8::Local<v8::String> property,
42
+ v8::Local<v8::Value> value,
43
+ const v8::PropertyCallbackInfo<void> &info);
44
+
45
+
46
+ static void
47
+ GetHostName(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value> &info);
48
+
49
+ static void SetHostName(v8::Local<v8::String> property,
50
+ v8::Local<v8::Value> value,
51
+ const v8::PropertyCallbackInfo<void> &info);
52
+
53
+
54
+ static void
55
+ GetHref(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value> &info);
56
+
57
+ static void SetHref(v8::Local<v8::String> property,
58
+ v8::Local<v8::Value> value,
59
+ const v8::PropertyCallbackInfo<void> &info);
60
+
61
+
62
+ static void
63
+ GetOrigin(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value> &info);
64
+
65
+
66
+ static void
67
+ GetPassword(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value> &info);
68
+
69
+ static void SetPassword(v8::Local<v8::String> property,
70
+ v8::Local<v8::Value> value,
71
+ const v8::PropertyCallbackInfo<void> &info);
72
+
73
+
74
+ static void
75
+ GetPathName(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value> &info);
76
+
77
+ static void SetPathName(v8::Local<v8::String> property,
78
+ v8::Local<v8::Value> value,
79
+ const v8::PropertyCallbackInfo<void> &info);
80
+
81
+
82
+ static void
83
+ GetPort(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value> &info);
84
+
85
+ static void SetPort(v8::Local<v8::String> property,
86
+ v8::Local<v8::Value> value,
87
+ const v8::PropertyCallbackInfo<void> &info);
88
+
89
+
90
+ static void
91
+ GetProtocol(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value> &info);
92
+
93
+ static void SetProtocol(v8::Local<v8::String> property,
94
+ v8::Local<v8::Value> value,
95
+ const v8::PropertyCallbackInfo<void> &info);
96
+
97
+
98
+ static void
99
+ GetSearch(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value> &info);
100
+
101
+ static void SetSearch(v8::Local<v8::String> property,
102
+ v8::Local<v8::Value> value,
103
+ const v8::PropertyCallbackInfo<void> &info);
104
+
105
+
106
+ static void
107
+ GetUserName(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value> &info);
108
+
109
+ static void SetUserName(v8::Local<v8::String> property,
110
+ v8::Local<v8::Value> value,
111
+ const v8::PropertyCallbackInfo<void> &info);
112
+
113
+ static void ToString(const v8::FunctionCallbackInfo<v8::Value> &args);
114
+
115
+ static void CanParse(const v8::FunctionCallbackInfo<v8::Value> &args);
116
+
117
+ private:
118
+ URL *url_;
119
+ };
@@ -1700,13 +1700,18 @@ CanvasRenderingContext2DImpl::FillText(const v8::FunctionCallbackInfo<v8::Value>
1700
1700
 
1701
1701
  auto x = static_cast<float>(args[1]->NumberValue(context).ToChecked());
1702
1702
  auto y = static_cast<float>(args[2]->NumberValue(context).ToChecked());
1703
- float width = -1;
1703
+
1704
1704
  if (args[3]->IsNumber()) {
1705
- width = static_cast<float>(args[3]->NumberValue(context).ToChecked());
1706
- }
1707
- canvas_native_context_fill_text(
1708
- ptr->GetContext(), text.c_str(), x,
1709
- y, width);
1705
+ float width = static_cast<float>(args[3]->NumberValue(context).ToChecked());
1706
+ canvas_native_context_fill_text_width(
1707
+ ptr->GetContext(), text.c_str(), x,
1708
+ y, width);
1709
+ }else {
1710
+ canvas_native_context_fill_text(
1711
+ ptr->GetContext(), text.c_str(), x,
1712
+ y);
1713
+ }
1714
+
1710
1715
  ptr->UpdateInvalidateState();
1711
1716
 
1712
1717
  }
@@ -2270,15 +2275,18 @@ CanvasRenderingContext2DImpl::StrokeText(const v8::FunctionCallbackInfo<v8::Valu
2270
2275
  auto text = ConvertFromV8String(isolate, args[0]);
2271
2276
  auto x = static_cast<float>(args[1]->NumberValue(context).ToChecked());
2272
2277
  auto y = static_cast<float>(args[2]->NumberValue(context).ToChecked());
2273
- float maxWidth = -1;
2274
-
2275
2278
  if (count > 3) {
2276
- maxWidth = static_cast<float>(args[3]->NumberValue(context).ToChecked());
2279
+ float maxWidth = static_cast<float>(args[3]->NumberValue(context).ToChecked());
2280
+ canvas_native_context_stroke_text_width(
2281
+ ptr->GetContext(), text.c_str(),
2282
+ x, y,maxWidth);
2283
+ }else {
2284
+ canvas_native_context_stroke_text(
2285
+ ptr->GetContext(), text.c_str(),
2286
+ x, y);
2277
2287
  }
2278
2288
 
2279
- canvas_native_context_stroke_text(
2280
- ptr->GetContext(), text.c_str(),
2281
- x, y, maxWidth);
2289
+
2282
2290
  ptr->UpdateInvalidateState();
2283
2291
  }
2284
2292
  }