Skip to content

Commit

Permalink
Merge pull request #50 from NativeScript/1.0.0-alpha.2
Browse files Browse the repository at this point in the history
fix: readPixels , lighting & ios performance
  • Loading branch information
triniwiz authored Aug 30, 2021
2 parents 28303e8 + 8b8ed9e commit cc93f5c
Show file tree
Hide file tree
Showing 39 changed files with 623 additions and 557 deletions.
2 changes: 1 addition & 1 deletion CanvasNative.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Pod::Spec.new do |s|

s.name = "CanvasNative"

s.version = "1.0.0-alpha.1"
s.version = "1.0.0-alpha.2"

s.summary = "A Canvas library"

Expand Down
44 changes: 38 additions & 6 deletions apps/demo/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,44 @@ module.exports = (env) => {
config.resolve.alias.set('@demo/shared', resolve(__dirname, '..', '..', 'tools', 'demo'));
});

// Example if you need to share images across demo apps:
// webpack.Utils.addCopyRule({
// from: '../../../tools/images',
// to: 'images',
// context: webpack.Utils.project.getProjectFilePath('node_modules')
// });
webpack.Utils.addCopyRule('**/*.svg')
webpack.Utils.addCopyRule('**/*.mp4')

webpack.Utils.addCopyRule({
from: '../../../tools/demo/canvas/assets',
to: 'assets/file-assets',
context: webpack.Utils.project.getProjectFilePath('node_modules')
});

webpack.Utils.addCopyRule({
from: '../../../tools/demo/canvas-babylon/assets',
to: 'assets/babylon',
context: webpack.Utils.project.getProjectFilePath('node_modules')
});

webpack.Utils.addCopyRule({
from: '../../../tools/demo/canvas-phaser/assets',
to: 'assets/phaser',
context: webpack.Utils.project.getProjectFilePath('node_modules')
});

webpack.Utils.addCopyRule({
from: '../../../tools/demo/canvas-phaser-ce/assets',
to: 'assets/phaser-ce',
context: webpack.Utils.project.getProjectFilePath('node_modules')
});

webpack.Utils.addCopyRule({
from: '../../../tools/demo/canvas-pixi/assets',
to: 'assets/pixi',
context: webpack.Utils.project.getProjectFilePath('node_modules')
});

webpack.Utils.addCopyRule({
from: '../../../tools/demo/canvas-three/assets',
to: 'assets/three',
context: webpack.Utils.project.getProjectFilePath('node_modules')
});

return webpack.resolveConfig();
};
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
import Phaser from './phaser';

export default function Game({
canvas,
width = null,
height = null,
renderer = 2,
preventLoop = null,
onRender = null,
title = null,
state = null,
transparent = null,
antialias = null,
physicsConfig = null,
}) {
export default function Game({ canvas, width = null, height = null, renderer = 2, preventLoop = null, onRender = null, title = null, state = null, transparent = null, antialias = null, physicsConfig = null }) {
const realWidth = canvas.width || 1;
const realHeight = canvas.height || 1;

global.document.readyState = 'complete';
(global as any).document.readyState = 'complete';

const config = {
width: width || realWidth,
Expand All @@ -27,8 +15,8 @@ export default function Game({
transparent: transparent || false,
antialias: antialias || true,
physicsConfig: physicsConfig || null,
canvas
}
canvas,
};

const game = new Phaser.Game(config);

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import '@nativescript/canvas-polyfill';

function initPhaser() {
global.PIXI = global.window.PIXI = global.PIXI || require('phaser-ce/build/custom/pixi');
global.p2 = global.window.p2 = global.p2 || require('phaser-ce/build/custom/p2');
global.Phaser = global.window.Phaser = global.Phaser || require('phaser-ce/build/phaser');
(global as any).PIXI = (global as any).window.PIXI = (global as any).PIXI || require('phaser-ce/build/custom/pixi');
(global as any).p2 = (global as any).window.p2 = (global as any).p2 || require('phaser-ce/build/custom/p2');
(global as any).Phaser = (global as any).window.Phaser = (global as any).Phaser || require('phaser-ce/build/phaser');

global.PIXI.WebGLRenderer.prototype.updateTexture = function (texture) {
(global as any).PIXI.WebGLRenderer.prototype.updateTexture = function (texture) {
if (!texture.hasLoaded || texture.source.nodeName === 'CANVAS') {
return false;
}
Expand Down Expand Up @@ -78,7 +78,7 @@ function initPhaser() {
};


return global.Phaser;
return (global as any).Phaser;
}

export default initPhaser();
File renamed without changes.
9 changes: 5 additions & 4 deletions packages/canvas-polyfill/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import { Document } from './DOM/Document';
import './window';
import './resize';
import './process';
import { TextDecoder, TextEncoder, ImageBitmap } from '@nativescript/canvas';
import { TextDecoder, TextEncoder } from '@nativescript/canvas';
import { ImageBitmap } from '@nativescript/canvas/ImageBitmap';
import { URL } from './URL';
(global as any).document = (global as any).window.document = (global as any).document || new Document();

Expand Down Expand Up @@ -72,9 +73,9 @@ if (!((global as any).TextDecoder instanceof TextDecoder)) {
});
}

if (!((global as any).TextDecoder instanceof TextDecoder)) {
Object.defineProperty(global, 'TextDecoder', {
value: TextDecoder,
if (!((global as any).TextEncoder instanceof TextEncoder)) {
Object.defineProperty(global, 'TextEncoder', {
value: TextEncoder,
configurable: true,
writable: true,
});
Expand Down
3 changes: 1 addition & 2 deletions packages/canvas-polyfill/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"readmeFilename": "README.md",
"bootstrapper": "@nativescript/plugin-seed",
"dependencies": {
"xmldom": "~0.6.0",
"@nativescript-community/gesturehandler": "0.1.45"
"xmldom": "~0.6.0"
}
}
Loading

0 comments on commit cc93f5c

Please sign in to comment.