@nativescript/canvas 2.0.0-alpha.30 → 2.0.0-alpha.31
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/Canvas/common.d.ts +14 -0
- package/Canvas/common.js +17 -0
- package/Canvas/common.js.map +1 -1
- package/Canvas/index.android.d.ts +1 -0
- package/Canvas/index.android.js +34 -7
- package/Canvas/index.android.js.map +1 -1
- package/Canvas/index.ios.d.ts +1 -0
- package/Canvas/index.ios.js +46 -20
- package/Canvas/index.ios.js.map +1 -1
- package/package.json +1 -1
- package/platforms/android/canvas-release.aar +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative-Swift.h +1 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +52 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +188 -166
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +1 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +1 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative-Swift.h +2 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +52 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +188 -166
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +1 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +1 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +188 -166
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +1 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +1 -0
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +24 -24
- package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
- package/platforms/ios/src/cpp/Caches.h +4 -0
- package/platforms/ios/src/cpp/CanvasJSIModule.cpp +1 -0
- package/platforms/ios/src/cpp/CanvasJSIModule.h +1 -0
- package/platforms/ios/src/cpp/URLImpl.cpp +464 -0
- package/platforms/ios/src/cpp/URLImpl.h +119 -0
|
@@ -81,6 +81,7 @@ import _StringProcessing
|
|
|
81
81
|
@objc @_Concurrency.MainActor(unsafe) public func setListener(_ listener: (any CanvasNative.NSCCanvasListener)?)
|
|
82
82
|
@_Concurrency.MainActor(unsafe) @objc override dynamic public func layoutSubviews()
|
|
83
83
|
@objc deinit
|
|
84
|
+
@objc @_Concurrency.MainActor(unsafe) public static func getBoundingClientRect(_ canvas: CanvasNative.NSCCanvas, _ buffer: Swift.UnsafeMutableRawPointer)
|
|
84
85
|
}
|
|
85
86
|
@_inheritsConvenienceInitializers @objcMembers @objc(TNSRender) public class NSCRender : ObjectiveC.NSObject {
|
|
86
87
|
@objc override dynamic public init()
|
|
@@ -81,6 +81,7 @@ import _StringProcessing
|
|
|
81
81
|
@objc @_Concurrency.MainActor(unsafe) public func setListener(_ listener: (any CanvasNative.NSCCanvasListener)?)
|
|
82
82
|
@_Concurrency.MainActor(unsafe) @objc override dynamic public func layoutSubviews()
|
|
83
83
|
@objc deinit
|
|
84
|
+
@objc @_Concurrency.MainActor(unsafe) public static func getBoundingClientRect(_ canvas: CanvasNative.NSCCanvas, _ buffer: Swift.UnsafeMutableRawPointer)
|
|
84
85
|
}
|
|
85
86
|
@_inheritsConvenienceInitializers @objcMembers @objc(TNSRender) public class NSCRender : ObjectiveC.NSObject {
|
|
86
87
|
@objc override dynamic public init()
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<dict>
|
|
7
7
|
<key>Headers/CanvasNative-Swift.h</key>
|
|
8
8
|
<data>
|
|
9
|
-
|
|
9
|
+
+VCFMd8HrKLciD+OwsTVcdS0fAA=
|
|
10
10
|
</data>
|
|
11
11
|
<key>Headers/CanvasNative.h</key>
|
|
12
12
|
<data>
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
</data>
|
|
19
19
|
<key>Headers/canvas_native.h</key>
|
|
20
20
|
<data>
|
|
21
|
-
|
|
21
|
+
IGuEROm9kdptZf3262S3gVStmBg=
|
|
22
22
|
</data>
|
|
23
23
|
<key>Info.plist</key>
|
|
24
24
|
<data>
|
|
@@ -26,19 +26,19 @@
|
|
|
26
26
|
</data>
|
|
27
27
|
<key>Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo</key>
|
|
28
28
|
<data>
|
|
29
|
-
|
|
29
|
+
HCnnpXSRLMEZUawVYP7bjIrykvY=
|
|
30
30
|
</data>
|
|
31
31
|
<key>Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo</key>
|
|
32
32
|
<data>
|
|
33
|
-
|
|
33
|
+
NBQwCzT566EVuifc3CGTABJArIg=
|
|
34
34
|
</data>
|
|
35
35
|
<key>Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json</key>
|
|
36
36
|
<data>
|
|
37
|
-
|
|
37
|
+
ZMfwT5PJatFgh1+CMyoU3Wv8PIw=
|
|
38
38
|
</data>
|
|
39
39
|
<key>Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface</key>
|
|
40
40
|
<data>
|
|
41
|
-
|
|
41
|
+
8Srz3VbLpqZAT9Vj0TTcMmNnFpo=
|
|
42
42
|
</data>
|
|
43
43
|
<key>Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftdoc</key>
|
|
44
44
|
<data>
|
|
@@ -46,19 +46,19 @@
|
|
|
46
46
|
</data>
|
|
47
47
|
<key>Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface</key>
|
|
48
48
|
<data>
|
|
49
|
-
|
|
49
|
+
8Srz3VbLpqZAT9Vj0TTcMmNnFpo=
|
|
50
50
|
</data>
|
|
51
51
|
<key>Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftmodule</key>
|
|
52
52
|
<data>
|
|
53
|
-
|
|
53
|
+
xwUL0+sPWQOnLRbmCRAaufNhlQg=
|
|
54
54
|
</data>
|
|
55
55
|
<key>Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json</key>
|
|
56
56
|
<data>
|
|
57
|
-
|
|
57
|
+
ZMfwT5PJatFgh1+CMyoU3Wv8PIw=
|
|
58
58
|
</data>
|
|
59
59
|
<key>Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface</key>
|
|
60
60
|
<data>
|
|
61
|
-
|
|
61
|
+
oGaFzJw2skR8h7F5PnUt0p1T0do=
|
|
62
62
|
</data>
|
|
63
63
|
<key>Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftdoc</key>
|
|
64
64
|
<data>
|
|
@@ -66,11 +66,11 @@
|
|
|
66
66
|
</data>
|
|
67
67
|
<key>Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface</key>
|
|
68
68
|
<data>
|
|
69
|
-
|
|
69
|
+
oGaFzJw2skR8h7F5PnUt0p1T0do=
|
|
70
70
|
</data>
|
|
71
71
|
<key>Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftmodule</key>
|
|
72
72
|
<data>
|
|
73
|
-
|
|
73
|
+
a6dK/jYfYD3OMc+7AAdKioPdSzM=
|
|
74
74
|
</data>
|
|
75
75
|
<key>Modules/module.modulemap</key>
|
|
76
76
|
<data>
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
<dict>
|
|
88
88
|
<key>hash2</key>
|
|
89
89
|
<data>
|
|
90
|
-
|
|
90
|
+
fXm+b+Qm+nCs5qVchcJ5cPoIgOfKloO3YiRF6o4KNRg=
|
|
91
91
|
</data>
|
|
92
92
|
</dict>
|
|
93
93
|
<key>Headers/CanvasNative.h</key>
|
|
@@ -108,35 +108,35 @@
|
|
|
108
108
|
<dict>
|
|
109
109
|
<key>hash2</key>
|
|
110
110
|
<data>
|
|
111
|
-
|
|
111
|
+
0L3I06bMeoK4UNoafHEw7AGoDeCi4B1w6G3Ms6CT26A=
|
|
112
112
|
</data>
|
|
113
113
|
</dict>
|
|
114
114
|
<key>Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo</key>
|
|
115
115
|
<dict>
|
|
116
116
|
<key>hash2</key>
|
|
117
117
|
<data>
|
|
118
|
-
|
|
118
|
+
47O+ZoX5+8n5GWFdbt4LCXjSURv2AO1i+hSh7J7xyB0=
|
|
119
119
|
</data>
|
|
120
120
|
</dict>
|
|
121
121
|
<key>Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo</key>
|
|
122
122
|
<dict>
|
|
123
123
|
<key>hash2</key>
|
|
124
124
|
<data>
|
|
125
|
-
|
|
125
|
+
WiDcXU4QuScyp6Lnic8gkcbMnIznccTZHGi35c1pR+g=
|
|
126
126
|
</data>
|
|
127
127
|
</dict>
|
|
128
128
|
<key>Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json</key>
|
|
129
129
|
<dict>
|
|
130
130
|
<key>hash2</key>
|
|
131
131
|
<data>
|
|
132
|
-
|
|
132
|
+
E/7n06UUQIxz7Bkm2stxRet0YW5fO/ZBPTzdDtTgKrQ=
|
|
133
133
|
</data>
|
|
134
134
|
</dict>
|
|
135
135
|
<key>Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface</key>
|
|
136
136
|
<dict>
|
|
137
137
|
<key>hash2</key>
|
|
138
138
|
<data>
|
|
139
|
-
|
|
139
|
+
NYLgbQSiXcqEGePfly2vWkVlmvpletiSTJhSSvYELy0=
|
|
140
140
|
</data>
|
|
141
141
|
</dict>
|
|
142
142
|
<key>Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftdoc</key>
|
|
@@ -150,28 +150,28 @@
|
|
|
150
150
|
<dict>
|
|
151
151
|
<key>hash2</key>
|
|
152
152
|
<data>
|
|
153
|
-
|
|
153
|
+
NYLgbQSiXcqEGePfly2vWkVlmvpletiSTJhSSvYELy0=
|
|
154
154
|
</data>
|
|
155
155
|
</dict>
|
|
156
156
|
<key>Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftmodule</key>
|
|
157
157
|
<dict>
|
|
158
158
|
<key>hash2</key>
|
|
159
159
|
<data>
|
|
160
|
-
|
|
160
|
+
pTosagdcfbOSk+kqEUxvwO8uiO0kDuxEPJAEzFGZvNw=
|
|
161
161
|
</data>
|
|
162
162
|
</dict>
|
|
163
163
|
<key>Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json</key>
|
|
164
164
|
<dict>
|
|
165
165
|
<key>hash2</key>
|
|
166
166
|
<data>
|
|
167
|
-
|
|
167
|
+
E/7n06UUQIxz7Bkm2stxRet0YW5fO/ZBPTzdDtTgKrQ=
|
|
168
168
|
</data>
|
|
169
169
|
</dict>
|
|
170
170
|
<key>Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface</key>
|
|
171
171
|
<dict>
|
|
172
172
|
<key>hash2</key>
|
|
173
173
|
<data>
|
|
174
|
-
|
|
174
|
+
1OljxijU01/Dy6xtdgZ9TjaT8i0/oF9cLMQx2FhpL8w=
|
|
175
175
|
</data>
|
|
176
176
|
</dict>
|
|
177
177
|
<key>Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftdoc</key>
|
|
@@ -185,14 +185,14 @@
|
|
|
185
185
|
<dict>
|
|
186
186
|
<key>hash2</key>
|
|
187
187
|
<data>
|
|
188
|
-
|
|
188
|
+
1OljxijU01/Dy6xtdgZ9TjaT8i0/oF9cLMQx2FhpL8w=
|
|
189
189
|
</data>
|
|
190
190
|
</dict>
|
|
191
191
|
<key>Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftmodule</key>
|
|
192
192
|
<dict>
|
|
193
193
|
<key>hash2</key>
|
|
194
194
|
<data>
|
|
195
|
-
|
|
195
|
+
RzFPk/lsBdJedrAgG+Vzkgv6bq2WCg3BdPLGfDgwZtM=
|
|
196
196
|
</data>
|
|
197
197
|
</dict>
|
|
198
198
|
<key>Modules/module.modulemap</key>
|
|
Binary file
|
|
@@ -177,6 +177,10 @@ public:
|
|
|
177
177
|
std::unique_ptr<v8::Persistent<v8::FunctionTemplate>> WebGLUniformLocationTmpl = std::unique_ptr<v8::Persistent<v8::FunctionTemplate>>(
|
|
178
178
|
nullptr);
|
|
179
179
|
|
|
180
|
+
std::unique_ptr<v8::Persistent<v8::FunctionTemplate>> URLTmpl = std::unique_ptr<v8::Persistent<v8::FunctionTemplate>>(
|
|
181
|
+
nullptr);
|
|
182
|
+
|
|
183
|
+
|
|
180
184
|
private:
|
|
181
185
|
static std::shared_ptr<ConcurrentMap<v8::Isolate *,
|
|
182
186
|
std::shared_ptr<Caches>>>
|
|
@@ -34,6 +34,7 @@ void CanvasJSIModule::install(v8::Isolate *isolate) {
|
|
|
34
34
|
CanvasPattern::Init(canvasMod, isolate);
|
|
35
35
|
MatrixImpl::Init(canvasMod, isolate);
|
|
36
36
|
TextMetricsImpl::Init(canvasMod, isolate);
|
|
37
|
+
URLImpl::Init(canvasMod, isolate);
|
|
37
38
|
v8Global->Set(context, ConvertToV8String(isolate, "CanvasModule"), canvasMod);
|
|
38
39
|
canvasMod->Set(context, ConvertToV8String(isolate, "create2DContext"),
|
|
39
40
|
v8::FunctionTemplate::New(isolate, &Create2DContext)->GetFunction(
|
|
@@ -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
|
+
}
|