Skip to content

Commit

Permalink
chore: updates
Browse files Browse the repository at this point in the history
  • Loading branch information
triniwiz committed Nov 4, 2023
1 parent d1b7313 commit 6be0ae6
Show file tree
Hide file tree
Showing 69 changed files with 1,295 additions and 99 deletions.
2 changes: 1 addition & 1 deletion packages/canvas-babylon/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/canvas-babylon",
"version": "2.0.0-alpha.28",
"version": "2.0.0-alpha.29",
"description": "",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/canvas-chartjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/canvas-chartjs",
"version": "2.0.0-alpha.28",
"version": "2.0.0-alpha.29",
"description": "ChartJS",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/canvas-media/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/canvas-media",
"version": "2.0.0-alpha.28",
"version": "2.0.0-alpha.29",
"description": "Canvas media",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/canvas-phaser-ce/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/canvas-phaser-ce",
"version": "2.0.0-alpha.28",
"version": "2.0.0-alpha.29",
"description": "Tools for using Phaser-ce to build native 2D games in NativeScript 👾",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/canvas-phaser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/canvas-phaser",
"version": "2.0.0-alpha.28",
"version": "2.0.0-alpha.29",
"description": "Build awesome 2D games with Phaser.js and NativeScript",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/canvas-pixi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/canvas-pixi",
"version": "2.0.0-alpha.28",
"version": "2.0.0-alpha.29",
"description": "Plugin for using pixi.js in NativeScript",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/canvas-polyfill/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/canvas-polyfill",
"version": "2.0.0-alpha.28",
"version": "2.0.0-alpha.29",
"description": "Polyfill for making NativeScript compatible with web libs like pixi.js, three.js, phaser.js, babylon.js, etc....",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/canvas-three/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/canvas-three",
"version": "2.0.0-alpha.28",
"version": "2.0.0-alpha.29",
"description": "Utilities for using THREE.js on NativeScript",
"main": "index",
"typings": "index.d.ts",
Expand Down
23 changes: 12 additions & 11 deletions packages/canvas/Canvas/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,15 +606,15 @@ export abstract class CanvasBase extends View implements ICanvasBase {
delete this._lastPointerEventById[pointerId];
}

if (this._touchEndCallbacks.size > 0) {
const length = this._touches.length;
for (var i = 0; i < length; i++) {
if (this._touches[i].identifier == ptrId) {
this._touches.splice(i, 1);
break;
}
const length = this._touches.length;
for (let i = 0; i < length; i++) {
if (this._touches[i].identifier == ptrId) {
this._touches.splice(i, 1);
break;
}
}

if (this._touchEndCallbacks.size > 0) {
const touches = TouchList.fromList(this._touches);

const changedTouches = [
Expand Down Expand Up @@ -760,13 +760,14 @@ export abstract class CanvasBase extends View implements ICanvasBase {
pageX: x,
pageY: y,
});
this._touches.push(touch);
this._touchesById[ptrid] = touch;
const touches = TouchList.fromList(this._touches);
const touchesList = [touch];
const touchesById = [];
touchesById[ptrid] = touch;
const touches = TouchList.fromList(touchesList);
const touchEvent = new TouchEvent('touchcancel', {
touches,
targetTouches: touches,
changedTouches: this._touches,
changedTouches: touchesList,
});

for (const callback of this._touchCancelCallbacks) {
Expand Down
5 changes: 4 additions & 1 deletion packages/canvas/Canvas2D/CanvasRenderingContext2D/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,10 @@ export class CanvasRenderingContext2D {
return CanvasGradient.fromNative(this.context.createRadialGradient(x0, y0, r0, x1, y1, r1));
}

createConicGradient(startAngle: number, x: number, y: number) {
return CanvasGradient.fromNative(this.context.createConicGradient(startAngle, x, y));
}

drawPaint(color: string) {
this.context.drawPaint(color);
}
Expand Down Expand Up @@ -432,7 +436,6 @@ export class CanvasRenderingContext2D {
this.context.__makeDirty();
}
};


let image = args[0];
if (image?._type === '2d' || image?._type?.indexOf('webgl') > -1) {
Expand Down
2 changes: 1 addition & 1 deletion packages/canvas/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/canvas",
"version": "2.0.0-alpha.28",
"version": "2.0.0-alpha.29",
"description": "DOM Canvas API for NativeScript",
"main": "index",
"typings": "index.d.ts",
Expand Down
Binary file modified packages/canvas/platforms/android/canvas-release.aar
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ SWIFT_CLASS_NAMED("NSCSVG")
- (nonnull instancetype)initWithFrame:(CGRect)frame OBJC_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithCoder:(NSCoder * _Nonnull)coder SWIFT_UNAVAILABLE;
- (void)drawRect:(CGRect)rect;
- (UIImage * _Nullable)toImage SWIFT_WARN_UNUSED_RESULT;
- (NSData * _Nullable)toData SWIFT_WARN_UNUSED_RESULT;
@end

@class AVPlayer;
Expand All @@ -449,6 +451,7 @@ SWIFT_CLASS_NAMED("Utils")
+ (CVOpenGLESTextureRef _Nullable)createImage:(CVOpenGLESTextureCacheRef _Nonnull)texturecache :(CVImageBufferRef _Nonnull)buffer :(CFDictionaryRef _Nullable)textureAttributes :(GLenum)target :(GLint)internalFormat :(GLsizei)width :(GLsizei)height :(GLenum)format :(GLenum)type :(NSInteger)planeIndex SWIFT_WARN_UNUSED_RESULT;
+ (TNSRender * _Nonnull)setupRender SWIFT_WARN_UNUSED_RESULT;
+ (void)drawFrame:(AVPlayer * _Nonnull)player :(AVPlayerItemVideoOutput * _Nonnull)output :(CGSize)videoSize :(TNSRender * _Nonnull)render :(int32_t)internalFormat :(int32_t)format :(BOOL)flipYWebGL;
+ (BOOL)writeToFile:(NSData * _Nonnull)data :(NSString * _Nonnull)path error:(NSError * _Nullable * _Nullable)error;
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,11 @@ struct PaintStyle *canvas_native_context_create_linear_gradient(struct CanvasRen
float x1,
float y1);

struct PaintStyle *canvas_native_context_create_conic_gradient(struct CanvasRenderingContext2D *context,
float start_angle,
float x,
float y);

struct PaintStyle *canvas_native_context_create_pattern(struct CanvasRenderingContext2D *context,
const uint8_t *data,
uintptr_t size,
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3474,6 +3474,68 @@
"AccessControl"
],
"funcSelfKind": "NonMutating"
},
{
"kind": "Function",
"name": "toImage",
"printedName": "toImage()",
"children": [
{
"kind": "TypeNominal",
"name": "Optional",
"printedName": "UIKit.UIImage?",
"children": [
{
"kind": "TypeNominal",
"name": "UIImage",
"printedName": "UIKit.UIImage",
"usr": "c:objc(cs)UIImage"
}
],
"usr": "s:Sq"
}
],
"declKind": "Func",
"usr": "c:@M@CanvasNative@objc(cs)TNSSVG(im)toImage",
"mangledName": "$s12CanvasNative6NSCSVGC7toImageSo7UIImageCSgyF",
"moduleName": "CanvasNative",
"declAttributes": [
"Custom",
"AccessControl",
"ObjC"
],
"funcSelfKind": "NonMutating"
},
{
"kind": "Function",
"name": "toData",
"printedName": "toData()",
"children": [
{
"kind": "TypeNominal",
"name": "Optional",
"printedName": "Foundation.NSData?",
"children": [
{
"kind": "TypeNominal",
"name": "NSData",
"printedName": "Foundation.NSData",
"usr": "c:objc(cs)NSData"
}
],
"usr": "s:Sq"
}
],
"declKind": "Func",
"usr": "c:@M@CanvasNative@objc(cs)TNSSVG(im)toData",
"mangledName": "$s12CanvasNative6NSCSVGC6toDataSo6NSDataCSgyF",
"moduleName": "CanvasNative",
"declAttributes": [
"Custom",
"AccessControl",
"ObjC"
],
"funcSelfKind": "NonMutating"
}
],
"declKind": "Class",
Expand Down Expand Up @@ -3987,6 +4049,42 @@
],
"funcSelfKind": "NonMutating"
},
{
"kind": "Function",
"name": "writeToFile",
"printedName": "writeToFile(_:_:)",
"children": [
{
"kind": "TypeNominal",
"name": "Void",
"printedName": "()"
},
{
"kind": "TypeNominal",
"name": "NSData",
"printedName": "Foundation.NSData",
"usr": "c:objc(cs)NSData"
},
{
"kind": "TypeNominal",
"name": "String",
"printedName": "Swift.String",
"usr": "s:SS"
}
],
"declKind": "Func",
"usr": "c:@M@CanvasNative@objc(cs)Utils(cm)writeToFile::error:",
"mangledName": "$s12CanvasNative5UtilsC11writeToFileyySo6NSDataC_SStKFZ",
"moduleName": "CanvasNative",
"static": true,
"declAttributes": [
"Final",
"AccessControl",
"ObjC"
],
"throwing": true,
"funcSelfKind": "NonMutating"
},
{
"kind": "Constructor",
"name": "init",
Expand Down Expand Up @@ -7428,6 +7526,27 @@
"length": 1,
"value": "4"
},
{
"filePath": "\/Users\/triniwiz\/Documents\/GitHub\/canvas\/packages\/canvas\/src-native\/canvas-ios\/CanvasNative\/Source\/NSCSVG.swift",
"kind": "IntegerLiteral",
"offset": 5218,
"length": 1,
"value": "0"
},
{
"filePath": "\/Users\/triniwiz\/Documents\/GitHub\/canvas\/packages\/canvas\/src-native\/canvas-ios\/CanvasNative\/Source\/NSCSVG.swift",
"kind": "IntegerLiteral",
"offset": 5440,
"length": 1,
"value": "8"
},
{
"filePath": "\/Users\/triniwiz\/Documents\/GitHub\/canvas\/packages\/canvas\/src-native\/canvas-ios\/CanvasNative\/Source\/NSCSVG.swift",
"kind": "IntegerLiteral",
"offset": 5464,
"length": 1,
"value": "4"
},
{
"filePath": "\/Users\/triniwiz\/Documents\/GitHub\/canvas\/packages\/canvas\/src-native\/canvas-ios\/NSCImageBitmap.swift",
"kind": "StringLiteral",
Expand All @@ -7449,6 +7568,48 @@
"length": 1,
"value": "4"
},
{
"filePath": "\/Users\/triniwiz\/Documents\/GitHub\/canvas\/packages\/canvas\/src-native\/canvas-ios\/Utils.swift",
"kind": "BooleanLiteral",
"offset": 2553,
"length": 5,
"value": "false"
},
{
"filePath": "\/Users\/triniwiz\/Documents\/GitHub\/canvas\/packages\/canvas\/src-native\/canvas-ios\/Utils.swift",
"kind": "BooleanLiteral",
"offset": 2686,
"length": 4,
"value": "true"
},
{
"filePath": "\/Users\/triniwiz\/Documents\/GitHub\/canvas\/packages\/canvas\/src-native\/canvas-ios\/Utils.swift",
"kind": "BooleanLiteral",
"offset": 2738,
"length": 4,
"value": "true"
},
{
"filePath": "\/Users\/triniwiz\/Documents\/GitHub\/canvas\/packages\/canvas\/src-native\/canvas-ios\/Utils.swift",
"kind": "StringLiteral",
"offset": 2923,
"length": 33,
"value": "\"Failed to create file at path '\""
},
{
"filePath": "\/Users\/triniwiz\/Documents\/GitHub\/canvas\/packages\/canvas\/src-native\/canvas-ios\/Utils.swift",
"kind": "StringLiteral",
"offset": 2966,
"length": 3,
"value": "\"'\""
},
{
"filePath": "\/Users\/triniwiz\/Documents\/GitHub\/canvas\/packages\/canvas\/src-native\/canvas-ios\/Utils.swift",
"kind": "BooleanLiteral",
"offset": 3229,
"length": 4,
"value": "true"
},
{
"filePath": "\/Users\/triniwiz\/Documents\/GitHub\/canvas\/packages\/canvas\/src-native\/canvas-ios\/CanvasNative\/Source\/GLRenderer.swift",
"kind": "BooleanLiteral",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ import _StringProcessing
@_Concurrency.MainActor(unsafe) @objc override dynamic public func layoutSubviews()
@_Concurrency.MainActor(unsafe) @objc override dynamic public init(frame: CoreFoundation.CGRect)
@_Concurrency.MainActor(unsafe) @objc override dynamic public func draw(_ rect: CoreFoundation.CGRect)
@objc @_Concurrency.MainActor(unsafe) public func toImage() -> UIKit.UIImage?
@objc @_Concurrency.MainActor(unsafe) public func toData() -> Foundation.NSData?
@objc deinit
}
@_inheritsConvenienceInitializers @objcMembers @objc(NSCImageBitmap) public class NSCImageBitmap : ObjectiveC.NSObject {
Expand All @@ -115,6 +117,7 @@ import _StringProcessing
@objc public static func createImage(_ texturecache: CoreVideo.CVOpenGLESTextureCache, _ buffer: CoreVideo.CVImageBuffer, _ textureAttributes: CoreFoundation.CFDictionary?, _ target: OpenGLES.GLenum, _ internalFormat: OpenGLES.GLint, _ width: OpenGLES.GLsizei, _ height: OpenGLES.GLsizei, _ format: OpenGLES.GLenum, _ type: OpenGLES.GLenum, _ planeIndex: Swift.Int) -> CoreVideo.CVOpenGLESTexture?
@objc public static func setupRender() -> CanvasNative.NSCRender
@objc public static func drawFrame(_ player: AVFoundation.AVPlayer, _ output: AVFoundation.AVPlayerItemVideoOutput, _ videoSize: CoreFoundation.CGSize, _ render: CanvasNative.NSCRender, _ internalFormat: Swift.Int32, _ format: Swift.Int32, _ flipYWebGL: Swift.Bool)
@objc public static func writeToFile(_ data: Foundation.NSData, _ path: Swift.String) throws
@objc override dynamic public init()
@objc deinit
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ import _StringProcessing
@_Concurrency.MainActor(unsafe) @objc override dynamic public func layoutSubviews()
@_Concurrency.MainActor(unsafe) @objc override dynamic public init(frame: CoreFoundation.CGRect)
@_Concurrency.MainActor(unsafe) @objc override dynamic public func draw(_ rect: CoreFoundation.CGRect)
@objc @_Concurrency.MainActor(unsafe) public func toImage() -> UIKit.UIImage?
@objc @_Concurrency.MainActor(unsafe) public func toData() -> Foundation.NSData?
@objc deinit
}
@_inheritsConvenienceInitializers @objcMembers @objc(NSCImageBitmap) public class NSCImageBitmap : ObjectiveC.NSObject {
Expand All @@ -115,6 +117,7 @@ import _StringProcessing
@objc public static func createImage(_ texturecache: CoreVideo.CVOpenGLESTextureCache, _ buffer: CoreVideo.CVImageBuffer, _ textureAttributes: CoreFoundation.CFDictionary?, _ target: OpenGLES.GLenum, _ internalFormat: OpenGLES.GLint, _ width: OpenGLES.GLsizei, _ height: OpenGLES.GLsizei, _ format: OpenGLES.GLenum, _ type: OpenGLES.GLenum, _ planeIndex: Swift.Int) -> CoreVideo.CVOpenGLESTexture?
@objc public static func setupRender() -> CanvasNative.NSCRender
@objc public static func drawFrame(_ player: AVFoundation.AVPlayer, _ output: AVFoundation.AVPlayerItemVideoOutput, _ videoSize: CoreFoundation.CGSize, _ render: CanvasNative.NSCRender, _ internalFormat: Swift.Int32, _ format: Swift.Int32, _ flipYWebGL: Swift.Bool)
@objc public static func writeToFile(_ data: Foundation.NSData, _ path: Swift.String) throws
@objc override dynamic public init()
@objc deinit
}
Expand Down
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 6be0ae6

Please sign in to comment.