diff --git a/.npmignore b/.npmignore index d7fc1d2..f5b4618 100644 --- a/.npmignore +++ b/.npmignore @@ -1,3 +1,8 @@ node_modules -react -demo-* \ No newline at end of file +.github +.stencil +.editorconfig + +react/ +demo-* +img/ \ No newline at end of file diff --git a/README.md b/README.md index aa6110c..6e01a5f 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Looking for [Phaser Framework CE (Community Edition)](https://github.com/photons ### Script tag -- Put a script tag similar to this `` in the head of your index.html +- Put a script tag similar to this `` in the head of your index.html - Then you can use the element anywhere in your template, JSX, html etc ### Node Modules diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..68ea1bc --- /dev/null +++ b/package-lock.json @@ -0,0 +1,144 @@ +{ + "name": "@ion-phaser/core", + "version": "1.2.1", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@stencil/core": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/@stencil/core/-/core-1.8.1.tgz", + "integrity": "sha512-VV8bJF6ZeOZyVUQEK4a24O+V4RXUxgAWSHonkNgbJVk7Z+hxfJMBTLGy6uZa9/5/IcKXqrTutIL9giV8WeNkHA==", + "dev": true, + "requires": { + "typescript": "3.7.2" + } + }, + "big.js": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", + "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", + "dev": true + }, + "emojis-list": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", + "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=", + "dev": true + }, + "eventemitter3": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.2.tgz", + "integrity": "sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q==", + "dev": true + }, + "exports-loader": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/exports-loader/-/exports-loader-0.7.0.tgz", + "integrity": "sha512-RKwCrO4A6IiKm0pG3c9V46JxIHcDplwwGJn6+JJ1RcVnh/WSGJa0xkmk5cRVtgOPzCAtTMGj2F7nluh9L0vpSA==", + "dev": true, + "requires": { + "loader-utils": "^1.1.0", + "source-map": "0.5.0" + } + }, + "imports-loader": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/imports-loader/-/imports-loader-0.8.0.tgz", + "integrity": "sha512-kXWL7Scp8KQ4552ZcdVTeaQCZSLW+e6nJfp3cwUMB673T7Hr98Xjx5JK+ql7ADlJUvj1JS5O01RLbKoutN5QDQ==", + "dev": true, + "requires": { + "loader-utils": "^1.0.2", + "source-map": "^0.6.1" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "json5": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", + "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "dev": true, + "requires": { + "minimist": "^1.2.0" + } + }, + "loader-utils": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.2.3.tgz", + "integrity": "sha512-fkpz8ejdnEMG3s37wGL07iSBDg99O9D5yflE9RGNH3hRdx9SOwYfnGYdZOUIZitN8E+E2vkq3MUMYMvPYl5ZZA==", + "dev": true, + "requires": { + "big.js": "^5.2.2", + "emojis-list": "^2.0.0", + "json5": "^1.0.1" + } + }, + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + }, + "path": { + "version": "0.12.7", + "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz", + "integrity": "sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=", + "dev": true, + "requires": { + "process": "^0.11.1", + "util": "^0.10.3" + } + }, + "phaser": { + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/phaser/-/phaser-3.21.0.tgz", + "integrity": "sha512-hcystLbTfeObD3DVG0nRzdLSZxcU4C8g+wzXZCl2a5CupPHxFdA3RJNELtWGs3UlFJAHHi0Xm6e7xliv08V/aA==", + "dev": true, + "requires": { + "eventemitter3": "^3.1.0", + "exports-loader": "^0.7.0", + "imports-loader": "^0.8.0", + "path": "^0.12.7" + } + }, + "process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", + "dev": true + }, + "source-map": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.0.tgz", + "integrity": "sha1-D+llA6yGpa213mP05BKuSHLNvoY=", + "dev": true + }, + "typescript": { + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.2.tgz", + "integrity": "sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==", + "dev": true + }, + "util": { + "version": "0.10.4", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", + "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", + "dev": true, + "requires": { + "inherits": "2.0.3" + } + } + } +} diff --git a/package.json b/package.json index f99344c..35b3f74 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,21 @@ { "name": "@ion-phaser/core", - "version": "1.2.0", + "version": "1.2.1", + "private": false, "description": "A web component to integrate Phaser Framework with Angular, React, Vue, etc", "keywords": [ - "ionic", "phaser", + "canvas", + "webgl", + "pwa", "framework", "angular", "react", "vue", "app", "vanillajs", + "stencil", + "stenciljs", "webcomponent", "web component", "web components" @@ -31,24 +36,19 @@ "build": "stencil build --docs", "start": "stencil build --dev --watch --serve", "test": "stencil test --spec --e2e", - "test.watch": "stencil test --spec --e2e --watchAll" + "test.watch": "stencil test --spec --e2e --watchAll", + "generate": "stencil generate" }, "peerDependencies": { "phaser": "^3.19.0" }, "devDependencies": { "phaser": "^3.19.0", - "@stencil/core": "~1.5.3", - "@types/jest": "24.0.18", - "@types/puppeteer": "1.19.1", - "jest": "24.9.0", - "jest-cli": "24.9.0", - "puppeteer": "1.19.0" + "@stencil/core": "^1.8.1" }, "license": "MIT", "repository": { "type": "git", "url": "https://github.com/proyecto26/ion-phaser.git" - }, - "private": false + } } diff --git a/src/components.d.ts b/src/components.d.ts index 6349edd..c470bfd 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -1,3 +1,4 @@ +/* eslint-disable */ /* tslint:disable */ /** * This is an autogenerated file created by the Stencil compiler. diff --git a/src/components/ion-phaser/ion-phaser.css b/src/components/ion-phaser/ion-phaser.css new file mode 100644 index 0000000..09083f1 --- /dev/null +++ b/src/components/ion-phaser/ion-phaser.css @@ -0,0 +1,3 @@ +ion-phaser { + display: block; +} \ No newline at end of file diff --git a/src/components/ion-phaser/ion-phaser.tsx b/src/components/ion-phaser/ion-phaser.tsx index 9e6e390..1778431 100644 --- a/src/components/ion-phaser/ion-phaser.tsx +++ b/src/components/ion-phaser/ion-phaser.tsx @@ -4,6 +4,7 @@ import { GameInstance } from '../models' @Component({ tag: 'ion-phaser', + styleUrl: 'ion-phaser.css', shadow: false }) export class IonPhaser { @@ -12,9 +13,16 @@ export class IonPhaser { */ @Prop({ mutable: true, - reflectToAttr: true + reflect: true }) game: GameInstance + @Watch('game') + onGameChange(game: GameInstance) { + if (this.initialize && !this.getGameInstance()) { + this.initializeGame(game) + } + } + /** * To initialize the plugin manually */ @@ -32,7 +40,7 @@ export class IonPhaser { */ @Method() async getInstance(): Promise { - return this.getGameInstance() + return Promise.resolve(this.getGameInstance()) } /** @@ -48,16 +56,14 @@ export class IonPhaser { @Element() el: HTMLElement - initializeGame = () => { - if(!this.game){ - throw new Error("The configuration of the game is required") - } - if(this.game.instance){ + initializeGame = (game = this.game) => { + if(!game) return + if(game.instance){ throw new Error("A Phaser game already exist") } - this.game.parent = this.game.parent || this.el - this.game.instance = new Game(this.game) + game.parent = game.parent || this.el + game.instance = new Game(game) } componentWillLoad() { diff --git a/src/index.html b/src/index.html index 436a6ae..840db50 100644 --- a/src/index.html +++ b/src/index.html @@ -112,16 +112,15 @@ - +
Initialize