@nativescript/canvas 2.0.0-beta.8 → 2.0.0-webgpu.0

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 (284) hide show
  1. package/Canvas/common.d.ts +23 -15
  2. package/Canvas/common.js +125 -56
  3. package/Canvas/common.js.map +1 -1
  4. package/Canvas/index.android.d.ts +5 -7
  5. package/Canvas/index.android.js +61 -133
  6. package/Canvas/index.android.js.map +1 -1
  7. package/Canvas/index.d.ts +4 -1
  8. package/Canvas/index.ios.d.ts +6 -6
  9. package/Canvas/index.ios.js +75 -85
  10. package/Canvas/index.ios.js.map +1 -1
  11. package/Canvas2D/CanvasRenderingContext2D/index.d.ts +1 -1
  12. package/Canvas2D/CanvasRenderingContext2D/index.js +8 -11
  13. package/Canvas2D/CanvasRenderingContext2D/index.js.map +1 -1
  14. package/Canvas2D/DOMMatrix/index.d.ts +14 -0
  15. package/Canvas2D/DOMMatrix/index.js +62 -0
  16. package/Canvas2D/DOMMatrix/index.js.map +1 -1
  17. package/Canvas2D/ImageData/index.js +4 -6
  18. package/Canvas2D/ImageData/index.js.map +1 -1
  19. package/ImageAsset/index.d.ts +1 -0
  20. package/ImageAsset/index.js +49 -0
  21. package/ImageAsset/index.js.map +1 -1
  22. package/WebGL/WebGLRenderingContext/index.d.ts +1 -0
  23. package/WebGL/WebGLRenderingContext/index.js +104 -14
  24. package/WebGL/WebGLRenderingContext/index.js.map +1 -1
  25. package/WebGL2/WebGL2RenderingContext/index.d.ts +1 -0
  26. package/WebGL2/WebGL2RenderingContext/index.js +2 -3
  27. package/WebGL2/WebGL2RenderingContext/index.js.map +1 -1
  28. package/WebGPU/Constants.d.ts +36 -0
  29. package/WebGPU/Constants.js +42 -0
  30. package/WebGPU/Constants.js.map +1 -0
  31. package/WebGPU/Errors.d.ts +18 -0
  32. package/WebGPU/Errors.js +21 -0
  33. package/WebGPU/Errors.js.map +1 -0
  34. package/WebGPU/GPU.d.ts +13 -0
  35. package/WebGPU/GPU.js +35 -0
  36. package/WebGPU/GPU.js.map +1 -0
  37. package/WebGPU/GPUAdapter.d.ts +23 -0
  38. package/WebGPU/GPUAdapter.js +62 -0
  39. package/WebGPU/GPUAdapter.js.map +1 -0
  40. package/WebGPU/GPUAdapterInfo.d.ts +9 -0
  41. package/WebGPU/GPUAdapterInfo.js +24 -0
  42. package/WebGPU/GPUAdapterInfo.js.map +1 -0
  43. package/WebGPU/GPUBindGroup.d.ts +5 -0
  44. package/WebGPU/GPUBindGroup.js +12 -0
  45. package/WebGPU/GPUBindGroup.js.map +1 -0
  46. package/WebGPU/GPUBindGroupLayout.d.ts +5 -0
  47. package/WebGPU/GPUBindGroupLayout.js +12 -0
  48. package/WebGPU/GPUBindGroupLayout.js.map +1 -0
  49. package/WebGPU/GPUBuffer.d.ts +15 -0
  50. package/WebGPU/GPUBuffer.js +54 -0
  51. package/WebGPU/GPUBuffer.js.map +1 -0
  52. package/WebGPU/GPUCanvasContext.d.ts +33 -0
  53. package/WebGPU/GPUCanvasContext.js +67 -0
  54. package/WebGPU/GPUCanvasContext.js.map +1 -0
  55. package/WebGPU/GPUCommandBuffer.d.ts +5 -0
  56. package/WebGPU/GPUCommandBuffer.js +12 -0
  57. package/WebGPU/GPUCommandBuffer.js.map +1 -0
  58. package/WebGPU/GPUCommandEncoder.d.ts +41 -0
  59. package/WebGPU/GPUCommandEncoder.js +105 -0
  60. package/WebGPU/GPUCommandEncoder.js.map +1 -0
  61. package/WebGPU/GPUComputePassEncoder.d.ts +16 -0
  62. package/WebGPU/GPUComputePassEncoder.js +50 -0
  63. package/WebGPU/GPUComputePassEncoder.js.map +1 -0
  64. package/WebGPU/GPUComputePipeline.d.ts +7 -0
  65. package/WebGPU/GPUComputePipeline.js +16 -0
  66. package/WebGPU/GPUComputePipeline.js.map +1 -0
  67. package/WebGPU/GPUDevice.d.ts +173 -0
  68. package/WebGPU/GPUDevice.js +381 -0
  69. package/WebGPU/GPUDevice.js.map +1 -0
  70. package/WebGPU/GPUDeviceLostInfo.d.ts +1 -0
  71. package/WebGPU/GPUDeviceLostInfo.js +10 -0
  72. package/WebGPU/GPUDeviceLostInfo.js.map +1 -0
  73. package/WebGPU/GPUExternalTexture.d.ts +5 -0
  74. package/WebGPU/GPUExternalTexture.js +12 -0
  75. package/WebGPU/GPUExternalTexture.js.map +1 -0
  76. package/WebGPU/GPUPipelineLayout.d.ts +5 -0
  77. package/WebGPU/GPUPipelineLayout.js +12 -0
  78. package/WebGPU/GPUPipelineLayout.js.map +1 -0
  79. package/WebGPU/GPUQuerySet.d.ts +5 -0
  80. package/WebGPU/GPUQuerySet.js +12 -0
  81. package/WebGPU/GPUQuerySet.js.map +1 -0
  82. package/WebGPU/GPUQueue.d.ts +14 -0
  83. package/WebGPU/GPUQueue.js +77 -0
  84. package/WebGPU/GPUQueue.js.map +1 -0
  85. package/WebGPU/GPURenderBundle.d.ts +5 -0
  86. package/WebGPU/GPURenderBundle.js +12 -0
  87. package/WebGPU/GPURenderBundle.js.map +1 -0
  88. package/WebGPU/GPURenderBundleEncoder.d.ts +20 -0
  89. package/WebGPU/GPURenderBundleEncoder.js +61 -0
  90. package/WebGPU/GPURenderBundleEncoder.js.map +1 -0
  91. package/WebGPU/GPURenderPassEncoder.d.ts +29 -0
  92. package/WebGPU/GPURenderPassEncoder.js +94 -0
  93. package/WebGPU/GPURenderPassEncoder.js.map +1 -0
  94. package/WebGPU/GPURenderPipeline.d.ts +7 -0
  95. package/WebGPU/GPURenderPipeline.js +16 -0
  96. package/WebGPU/GPURenderPipeline.js.map +1 -0
  97. package/WebGPU/GPUSampler.d.ts +5 -0
  98. package/WebGPU/GPUSampler.js +12 -0
  99. package/WebGPU/GPUSampler.js.map +1 -0
  100. package/WebGPU/GPUShaderModule.d.ts +6 -0
  101. package/WebGPU/GPUShaderModule.js +15 -0
  102. package/WebGPU/GPUShaderModule.js.map +1 -0
  103. package/WebGPU/GPUTexture.d.ts +16 -0
  104. package/WebGPU/GPUTexture.js +41 -0
  105. package/WebGPU/GPUTexture.js.map +1 -0
  106. package/WebGPU/GPUTextureView.d.ts +5 -0
  107. package/WebGPU/GPUTextureView.js +12 -0
  108. package/WebGPU/GPUTextureView.js.map +1 -0
  109. package/WebGPU/Interfaces.d.ts +155 -0
  110. package/WebGPU/Interfaces.js +2 -0
  111. package/WebGPU/Interfaces.js.map +1 -0
  112. package/WebGPU/Types.d.ts +39 -0
  113. package/WebGPU/Types.js +2 -0
  114. package/WebGPU/Types.js.map +1 -0
  115. package/WebGPU/Utils.d.ts +1 -0
  116. package/WebGPU/Utils.js +75 -0
  117. package/WebGPU/Utils.js.map +1 -0
  118. package/WebGPU/index.d.ts +28 -0
  119. package/WebGPU/index.js +29 -0
  120. package/WebGPU/index.js.map +1 -0
  121. package/index.d.ts +1 -1
  122. package/index.js +22 -1
  123. package/index.js.map +1 -1
  124. package/package.json +1 -4
  125. package/platforms/android/canvas-release.aar +0 -0
  126. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
  127. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/CanvasNative-Swift.h +23 -23
  128. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_ios.h +47 -8
  129. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +2280 -103
  130. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Info.plist +0 -0
  131. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  132. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +1564 -3814
  133. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.private.swiftinterface +27 -34
  134. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  135. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.swiftinterface +27 -34
  136. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  137. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +602 -664
  138. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
  139. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/CanvasNative-Swift.h +46 -46
  140. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_ios.h +47 -8
  141. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +2280 -103
  142. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Info.plist +0 -0
  143. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  144. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  145. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +1564 -3814
  146. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +27 -34
  147. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  148. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.swiftinterface +27 -34
  149. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +1564 -3814
  150. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +27 -34
  151. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  152. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +27 -34
  153. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +31 -31
  154. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  155. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +604 -663
  156. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +638 -642
  157. package/platforms/ios/build.xcconfig +3 -1
  158. package/platforms/ios/src/cpp/Caches.h +69 -1
  159. package/platforms/ios/src/cpp/CanvasJSIModule.cpp +320 -395
  160. package/platforms/ios/src/cpp/CanvasJSIModule.h +7 -1
  161. package/platforms/ios/src/cpp/Helpers.h +43 -8
  162. package/platforms/ios/src/cpp/ImageAssetImpl.cpp +35 -37
  163. package/platforms/ios/src/cpp/ImageAssetImpl.h +14 -10
  164. package/platforms/ios/src/cpp/ImageBitmapImpl.cpp +2 -2
  165. package/platforms/ios/src/cpp/ImageBitmapImpl.h +1 -1
  166. package/platforms/ios/src/cpp/canvas2d/CanvasPattern.cpp +0 -10
  167. package/platforms/ios/src/cpp/canvas2d/CanvasRenderingContext2DImpl.cpp +41 -4
  168. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.cpp +409 -3
  169. package/platforms/ios/src/cpp/canvas2d/MatrixImpl.h +27 -0
  170. package/platforms/ios/src/cpp/webgl/WebGLRenderingContext.cpp +131 -149
  171. package/platforms/ios/src/cpp/webgl2/WebGL2RenderingContext.cpp +1766 -1659
  172. package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.cpp +302 -0
  173. package/platforms/ios/src/cpp/webgpu/GPUAdapterImpl.h +63 -0
  174. package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.cpp +174 -0
  175. package/platforms/ios/src/cpp/webgpu/GPUAdapterInfoImpl.h +58 -0
  176. package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.cpp +53 -0
  177. package/platforms/ios/src/cpp/webgpu/GPUBindGroupImpl.h +45 -0
  178. package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.cpp +53 -0
  179. package/platforms/ios/src/cpp/webgpu/GPUBindGroupLayoutImpl.h +45 -0
  180. package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.cpp +229 -0
  181. package/platforms/ios/src/cpp/webgpu/GPUBufferImpl.h +59 -0
  182. package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.cpp +317 -0
  183. package/platforms/ios/src/cpp/webgpu/GPUCanvasContextImpl.h +55 -0
  184. package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.cpp +54 -0
  185. package/platforms/ios/src/cpp/webgpu/GPUCommandBufferImpl.h +45 -0
  186. package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.cpp +1087 -0
  187. package/platforms/ios/src/cpp/webgpu/GPUCommandEncoderImpl.h +69 -0
  188. package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.cpp +260 -0
  189. package/platforms/ios/src/cpp/webgpu/GPUComputePassEncoderImpl.h +62 -0
  190. package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.cpp +84 -0
  191. package/platforms/ios/src/cpp/webgpu/GPUComputePipelineImpl.h +49 -0
  192. package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.cpp +2741 -0
  193. package/platforms/ios/src/cpp/webgpu/GPUDeviceImpl.h +95 -0
  194. package/platforms/ios/src/cpp/webgpu/GPUImpl.cpp +186 -0
  195. package/platforms/ios/src/cpp/webgpu/GPUImpl.h +55 -0
  196. package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.cpp +54 -0
  197. package/platforms/ios/src/cpp/webgpu/GPUPipelineLayoutImpl.h +46 -0
  198. package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.cpp +137 -0
  199. package/platforms/ios/src/cpp/webgpu/GPUQuerySetImpl.h +55 -0
  200. package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.cpp +521 -0
  201. package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.h +56 -0
  202. package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.cpp +469 -0
  203. package/platforms/ios/src/cpp/webgpu/GPURenderBundleEncoderImpl.h +71 -0
  204. package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.cpp +53 -0
  205. package/platforms/ios/src/cpp/webgpu/GPURenderBundleImpl.h +45 -0
  206. package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.cpp +653 -0
  207. package/platforms/ios/src/cpp/webgpu/GPURenderPassEncoderImpl.h +85 -0
  208. package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.cpp +84 -0
  209. package/platforms/ios/src/cpp/webgpu/GPURenderPipelineImpl.h +49 -0
  210. package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.cpp +53 -0
  211. package/platforms/ios/src/cpp/webgpu/GPUSamplerImpl.h +45 -0
  212. package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.cpp +56 -0
  213. package/platforms/ios/src/cpp/webgpu/GPUShaderModuleImpl.h +45 -0
  214. package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.cpp +1304 -0
  215. package/platforms/ios/src/cpp/webgpu/GPUSupportedLimitsImpl.h +288 -0
  216. package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.cpp +360 -0
  217. package/platforms/ios/src/cpp/webgpu/GPUTextureImpl.h +75 -0
  218. package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.cpp +53 -0
  219. package/platforms/ios/src/cpp/webgpu/GPUTextureViewImpl.h +45 -0
  220. package/platforms/ios/src/cpp/webgpu/GPUUtils.h +178 -0
  221. package/SVG/Circle.d.ts +0 -11
  222. package/SVG/Circle.js +0 -21
  223. package/SVG/Circle.js.map +0 -1
  224. package/SVG/ClipPath.d.ts +0 -4
  225. package/SVG/ClipPath.js +0 -9
  226. package/SVG/ClipPath.js.map +0 -1
  227. package/SVG/Defs.d.ts +0 -4
  228. package/SVG/Defs.js +0 -9
  229. package/SVG/Defs.js.map +0 -1
  230. package/SVG/Ellipse.d.ts +0 -13
  231. package/SVG/Ellipse.js +0 -26
  232. package/SVG/Ellipse.js.map +0 -1
  233. package/SVG/G.d.ts +0 -7
  234. package/SVG/G.js +0 -9
  235. package/SVG/G.js.map +0 -1
  236. package/SVG/Image.d.ts +0 -11
  237. package/SVG/Image.js +0 -40
  238. package/SVG/Image.js.map +0 -1
  239. package/SVG/Line.d.ts +0 -13
  240. package/SVG/Line.js +0 -26
  241. package/SVG/Line.js.map +0 -1
  242. package/SVG/LinearGradient.d.ts +0 -10
  243. package/SVG/LinearGradient.js +0 -13
  244. package/SVG/LinearGradient.js.map +0 -1
  245. package/SVG/Path.d.ts +0 -7
  246. package/SVG/Path.js +0 -14
  247. package/SVG/Path.js.map +0 -1
  248. package/SVG/Pattern.d.ts +0 -4
  249. package/SVG/Pattern.js +0 -9
  250. package/SVG/Pattern.js.map +0 -1
  251. package/SVG/Polygon.d.ts +0 -7
  252. package/SVG/Polygon.js +0 -14
  253. package/SVG/Polygon.js.map +0 -1
  254. package/SVG/Polyline.d.ts +0 -7
  255. package/SVG/Polyline.js +0 -14
  256. package/SVG/Polyline.js.map +0 -1
  257. package/SVG/Rect.d.ts +0 -8
  258. package/SVG/Rect.js +0 -13
  259. package/SVG/Rect.js.map +0 -1
  260. package/SVG/SVG.d.ts +0 -32
  261. package/SVG/SVG.js +0 -204
  262. package/SVG/SVG.js.map +0 -1
  263. package/SVG/SVGItem.d.ts +0 -5
  264. package/SVG/SVGItem.js +0 -8
  265. package/SVG/SVGItem.js.map +0 -1
  266. package/SVG/Stop.d.ts +0 -5
  267. package/SVG/Stop.js +0 -9
  268. package/SVG/Stop.js.map +0 -1
  269. package/SVG/Symbol.d.ts +0 -4
  270. package/SVG/Symbol.js +0 -9
  271. package/SVG/Symbol.js.map +0 -1
  272. package/SVG/Text.d.ts +0 -14
  273. package/SVG/Text.js +0 -26
  274. package/SVG/Text.js.map +0 -1
  275. package/SVG/Use.d.ts +0 -4
  276. package/SVG/Use.js +0 -9
  277. package/SVG/Use.js.map +0 -1
  278. package/SVG/index.d.ts +0 -18
  279. package/SVG/index.js +0 -19
  280. package/SVG/index.js.map +0 -1
  281. package/platforms/ios/src/cpp/PerIsolateData.cpp +0 -49
  282. package/platforms/ios/src/cpp/PerIsolateData.h +0 -54
  283. package/platforms/ios/src/cpp/URLImpl.cpp +0 -464
  284. package/platforms/ios/src/cpp/URLImpl.h +0 -121
@@ -1,464 +0,0 @@
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->GetAlignedPointerFromInternalField(0);
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(2);
45
- ctorTmpl->SetClassName(ConvertToV8String(isolate, "URL"));
46
-
47
- auto tmpl = ctorTmpl->InstanceTemplate();
48
- tmpl->SetInternalFieldCount(2);
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 urlImpl = new URLImpl(url);
124
-
125
- ret->SetAlignedPointerInInternalField(0, urlImpl);
126
-
127
- urlImpl->BindFinalizer(isolate, ret);
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
- }
@@ -1,121 +0,0 @@
1
- //
2
- // Created by Osei Fortune on 15/011/2023.
3
- //
4
-
5
- #pragma once
6
-
7
- #include <vector>
8
- #include "Common.h"
9
- #include "ObjectWrapperImpl.h"
10
-
11
- class URLImpl: ObjectWrapperImpl {
12
- public:
13
- URLImpl(URL *url);
14
-
15
- ~URLImpl() {
16
- canvas_url_destroy(this->GetURL());
17
- this->url_ = nullptr;
18
- }
19
-
20
- URL *GetURL();
21
-
22
-
23
- static void Init(const v8::Local<v8::Object> &canvasModule, v8::Isolate *isolate);
24
-
25
- static URLImpl *GetPointer(v8::Local<v8::Object> object);
26
-
27
- static v8::Local<v8::FunctionTemplate> GetCtor(v8::Isolate *isolate);
28
-
29
- static void Ctor(const v8::FunctionCallbackInfo<v8::Value> &args);
30
-
31
-
32
- static void
33
- GetHash(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value> &info);
34
-
35
- static void SetHash(v8::Local<v8::String> property,
36
- v8::Local<v8::Value> value,
37
- const v8::PropertyCallbackInfo<void> &info);
38
-
39
-
40
- static void
41
- GetHost(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value> &info);
42
-
43
- static void SetHost(v8::Local<v8::String> property,
44
- v8::Local<v8::Value> value,
45
- const v8::PropertyCallbackInfo<void> &info);
46
-
47
-
48
- static void
49
- GetHostName(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value> &info);
50
-
51
- static void SetHostName(v8::Local<v8::String> property,
52
- v8::Local<v8::Value> value,
53
- const v8::PropertyCallbackInfo<void> &info);
54
-
55
-
56
- static void
57
- GetHref(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value> &info);
58
-
59
- static void SetHref(v8::Local<v8::String> property,
60
- v8::Local<v8::Value> value,
61
- const v8::PropertyCallbackInfo<void> &info);
62
-
63
-
64
- static void
65
- GetOrigin(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value> &info);
66
-
67
-
68
- static void
69
- GetPassword(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value> &info);
70
-
71
- static void SetPassword(v8::Local<v8::String> property,
72
- v8::Local<v8::Value> value,
73
- const v8::PropertyCallbackInfo<void> &info);
74
-
75
-
76
- static void
77
- GetPathName(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value> &info);
78
-
79
- static void SetPathName(v8::Local<v8::String> property,
80
- v8::Local<v8::Value> value,
81
- const v8::PropertyCallbackInfo<void> &info);
82
-
83
-
84
- static void
85
- GetPort(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value> &info);
86
-
87
- static void SetPort(v8::Local<v8::String> property,
88
- v8::Local<v8::Value> value,
89
- const v8::PropertyCallbackInfo<void> &info);
90
-
91
-
92
- static void
93
- GetProtocol(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value> &info);
94
-
95
- static void SetProtocol(v8::Local<v8::String> property,
96
- v8::Local<v8::Value> value,
97
- const v8::PropertyCallbackInfo<void> &info);
98
-
99
-
100
- static void
101
- GetSearch(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value> &info);
102
-
103
- static void SetSearch(v8::Local<v8::String> property,
104
- v8::Local<v8::Value> value,
105
- const v8::PropertyCallbackInfo<void> &info);
106
-
107
-
108
- static void
109
- GetUserName(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value> &info);
110
-
111
- static void SetUserName(v8::Local<v8::String> property,
112
- v8::Local<v8::Value> value,
113
- const v8::PropertyCallbackInfo<void> &info);
114
-
115
- static void ToString(const v8::FunctionCallbackInfo<v8::Value> &args);
116
-
117
- static void CanParse(const v8::FunctionCallbackInfo<v8::Value> &args);
118
-
119
- private:
120
- URL *url_;
121
- };