Skip to content

Commit cc93f5c

Browse files
authored
Merge pull request #50 from NativeScript/1.0.0-alpha.2
fix: readPixels , lighting & ios performance
2 parents 28303e8 + 8b8ed9e commit cc93f5c

File tree

39 files changed

+623
-557
lines changed

39 files changed

+623
-557
lines changed

CanvasNative.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Pod::Spec.new do |s|
22

33
s.name = "CanvasNative"
44

5-
s.version = "1.0.0-alpha.1"
5+
s.version = "1.0.0-alpha.2"
66

77
s.summary = "A Canvas library"
88

apps/demo/webpack.config.js

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,44 @@ module.exports = (env) => {
1111
config.resolve.alias.set('@demo/shared', resolve(__dirname, '..', '..', 'tools', 'demo'));
1212
});
1313

14-
// Example if you need to share images across demo apps:
15-
// webpack.Utils.addCopyRule({
16-
// from: '../../../tools/images',
17-
// to: 'images',
18-
// context: webpack.Utils.project.getProjectFilePath('node_modules')
19-
// });
14+
webpack.Utils.addCopyRule('**/*.svg')
15+
webpack.Utils.addCopyRule('**/*.mp4')
16+
17+
webpack.Utils.addCopyRule({
18+
from: '../../../tools/demo/canvas/assets',
19+
to: 'assets/file-assets',
20+
context: webpack.Utils.project.getProjectFilePath('node_modules')
21+
});
22+
23+
webpack.Utils.addCopyRule({
24+
from: '../../../tools/demo/canvas-babylon/assets',
25+
to: 'assets/babylon',
26+
context: webpack.Utils.project.getProjectFilePath('node_modules')
27+
});
28+
29+
webpack.Utils.addCopyRule({
30+
from: '../../../tools/demo/canvas-phaser/assets',
31+
to: 'assets/phaser',
32+
context: webpack.Utils.project.getProjectFilePath('node_modules')
33+
});
34+
35+
webpack.Utils.addCopyRule({
36+
from: '../../../tools/demo/canvas-phaser-ce/assets',
37+
to: 'assets/phaser-ce',
38+
context: webpack.Utils.project.getProjectFilePath('node_modules')
39+
});
40+
41+
webpack.Utils.addCopyRule({
42+
from: '../../../tools/demo/canvas-pixi/assets',
43+
to: 'assets/pixi',
44+
context: webpack.Utils.project.getProjectFilePath('node_modules')
45+
});
46+
47+
webpack.Utils.addCopyRule({
48+
from: '../../../tools/demo/canvas-three/assets',
49+
to: 'assets/three',
50+
context: webpack.Utils.project.getProjectFilePath('node_modules')
51+
});
2052

2153
return webpack.resolveConfig();
2254
};

packages/canvas-phaser-ce/game.js renamed to packages/canvas-phaser-ce/game.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
11
import Phaser from './phaser';
22

3-
export default function Game({
4-
canvas,
5-
width = null,
6-
height = null,
7-
renderer = 2,
8-
preventLoop = null,
9-
onRender = null,
10-
title = null,
11-
state = null,
12-
transparent = null,
13-
antialias = null,
14-
physicsConfig = null,
15-
}) {
3+
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 }) {
164
const realWidth = canvas.width || 1;
175
const realHeight = canvas.height || 1;
186

19-
global.document.readyState = 'complete';
7+
(global as any).document.readyState = 'complete';
208

219
const config = {
2210
width: width || realWidth,
@@ -27,8 +15,8 @@ export default function Game({
2715
transparent: transparent || false,
2816
antialias: antialias || true,
2917
physicsConfig: physicsConfig || null,
30-
canvas
31-
}
18+
canvas,
19+
};
3220

3321
const game = new Phaser.Game(config);
3422

packages/canvas-phaser-ce/phaser.js renamed to packages/canvas-phaser-ce/phaser.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import '@nativescript/canvas-polyfill';
22

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

8-
global.PIXI.WebGLRenderer.prototype.updateTexture = function (texture) {
8+
(global as any).PIXI.WebGLRenderer.prototype.updateTexture = function (texture) {
99
if (!texture.hasLoaded || texture.source.nodeName === 'CANVAS') {
1010
return false;
1111
}
@@ -78,7 +78,7 @@ function initPhaser() {
7878
};
7979

8080

81-
return global.Phaser;
81+
return (global as any).Phaser;
8282
}
8383

8484
export default initPhaser();

packages/canvas-polyfill/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import { Document } from './DOM/Document';
1313
import './window';
1414
import './resize';
1515
import './process';
16-
import { TextDecoder, TextEncoder, ImageBitmap } from '@nativescript/canvas';
16+
import { TextDecoder, TextEncoder } from '@nativescript/canvas';
17+
import { ImageBitmap } from '@nativescript/canvas/ImageBitmap';
1718
import { URL } from './URL';
1819
(global as any).document = (global as any).window.document = (global as any).document || new Document();
1920

@@ -72,9 +73,9 @@ if (!((global as any).TextDecoder instanceof TextDecoder)) {
7273
});
7374
}
7475

75-
if (!((global as any).TextDecoder instanceof TextDecoder)) {
76-
Object.defineProperty(global, 'TextDecoder', {
77-
value: TextDecoder,
76+
if (!((global as any).TextEncoder instanceof TextEncoder)) {
77+
Object.defineProperty(global, 'TextEncoder', {
78+
value: TextEncoder,
7879
configurable: true,
7980
writable: true,
8081
});

packages/canvas-polyfill/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
"readmeFilename": "README.md",
3434
"bootstrapper": "@nativescript/plugin-seed",
3535
"dependencies": {
36-
"xmldom": "~0.6.0",
37-
"@nativescript-community/gesturehandler": "0.1.45"
36+
"xmldom": "~0.6.0"
3837
}
3938
}

0 commit comments

Comments
 (0)