Skip to content

Commit

Permalink
refactor: format all src files
Browse files Browse the repository at this point in the history
feat: add
  • Loading branch information
stevensnoeijen committed Jul 24, 2022
1 parent 3ad456e commit 2211113
Show file tree
Hide file tree
Showing 134 changed files with 4,167 additions and 3,733 deletions.
27 changes: 25 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,40 @@
require('@rushstack/eslint-patch/modern-module-resolution');

module.exports = {
env: {
browser: true,
node: true,
},
globals: {
document: false,
},
extends: [
'eslint:recommended',
'plugin:vue/vue3-essential',
'@vue/eslint-config-typescript',
],
plugins: ['import'],
plugins: ['import', 'unused-imports'],
rules: {
'max-len': ['warn', { code: 80, ignorePattern: '^import\\W.*' }],
quotes: ['warn', 'single'],
semi: ['warn', 'always'],
'import/order': ['warn'],
'import/order': [
'warn',
{
'newlines-between': 'always',
},
],
'spaced-comment': ['warn', 'always'],
'unused-imports/no-unused-imports': 'warn',
'no-unused-vars': 'off',
'unused-imports/no-unused-vars': [
'warn',
{
vars: 'all',
varsIgnorePattern: '^_',
args: 'after-used',
argsIgnorePattern: '^_',
},
],
},
};
46 changes: 46 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"autoprefixer": "^10.4.7",
"eslint": "^8.20.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-unused-imports": "^2.0.0",
"eslint-plugin-vue": "^9.2.0",
"gh-pages": "^3.2.3",
"jest": "^28.1.3",
Expand Down
192 changes: 98 additions & 94 deletions src/components/pixi/PixiApplication.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<template>
<div ref="container">
<slot name="default" :application="application"/>
</div>
<div ref="container">
<slot name="default" :application="application" />
</div>
</template>

<script lang="ts" setup>
import { defineProps, onMounted, PropType } from 'vue';
import { onMounted, PropType } from 'vue';
import { $ref } from 'vue/macros';
import * as PIXI from 'pixi.js';
import { Dict } from '@pixi/utils';
Expand All @@ -16,106 +16,110 @@ const container = $ref<HTMLDivElement>();
// prop types, if required and defaults adopted from pixi.js code
const props = defineProps({
autoStart: {
type: Boolean,
required: false,
default: true,
},
width: {
type: Number,
required: false,
default: 800,
},
height: {
type: Number,
required: false,
default: 600,
},
view: {
type: HTMLCanvasElement,
required: false,
},
useContextAlpha: {
type: Boolean,
required: false,
default: true,
},
autoDensity: {
type: Boolean,
required: false,
default: false,
},
antialias: {
type: Boolean,
required: false,
default: false,
},
preserveDrawingBuffer: {
type: Boolean,
required: false,
default: false,
},
resolution: {
type: Number,
required: false,
default: PIXI.settings.RESOLUTION,
},
forceCanvas: {
type: Boolean,
required: false,
default: false,
},
backgroundColor: {
type: Number,
required: false,
default: 0x000000,
},
backgroundAlpha: {
type: Number,
required: false,
default: 1,
},
clearBeforeRender: {
type: Boolean,
required: false,
default: true,
},
powerPreference: {
type: String as PropType<WebGLPowerPreference>,
required: false,
default: 'high-performance',
},
sharedTicker: {
type: Boolean,
required: false,
default: false,
},
sharedLoader: {
type: Boolean,
required: false,
default: false,
},
resizeTo: {
type: Object as PropType<Window|HTMLElement>,
required: false,
},
autoStart: {
type: Boolean,
required: false,
default: true,
},
width: {
type: Number,
required: false,
default: 800,
},
height: {
type: Number,
required: false,
default: 600,
},
view: {
type: HTMLCanvasElement,
required: false,
},
useContextAlpha: {
type: Boolean,
required: false,
default: true,
},
autoDensity: {
type: Boolean,
required: false,
default: false,
},
antialias: {
type: Boolean,
required: false,
default: false,
},
preserveDrawingBuffer: {
type: Boolean,
required: false,
default: false,
},
resolution: {
type: Number,
required: false,
default: PIXI.settings.RESOLUTION,
},
forceCanvas: {
type: Boolean,
required: false,
default: false,
},
backgroundColor: {
type: Number,
required: false,
default: 0x000000,
},
backgroundAlpha: {
type: Number,
required: false,
default: 1,
},
clearBeforeRender: {
type: Boolean,
required: false,
default: true,
},
powerPreference: {
type: String as PropType<WebGLPowerPreference>,
required: false,
default: 'high-performance',
},
sharedTicker: {
type: Boolean,
required: false,
default: false,
},
sharedLoader: {
type: Boolean,
required: false,
default: false,
},
resizeTo: {
type: Object as PropType<Window | HTMLElement>,
required: false,
},
});
const emits = defineEmits<{
(event: 'tick', delta: number): void,
(event: 'load', loader: PIXI.Loader, resources: Dict<PIXI.LoaderResource>): void,
(event: 'tick', delta: number): void;
(
event: 'load',
loader: PIXI.Loader,
resources: Dict<PIXI.LoaderResource>
): void;
}>();
const application = new PIXI.Application(props);
defineExpose<PixiApplicationInstance>({
application,
application,
});
onMounted(() => {
container.appendChild(application.view);
container.appendChild(application.view);
application.ticker.add((delta: number) => emits('tick', delta));
application.loader.load((...args) => emits('load', ...args));
application.ticker.add((delta: number) => emits('tick', delta));
application.loader.load((...args) => emits('load', ...args));
});
</script>
</script>
9 changes: 4 additions & 5 deletions src/components/pixi/PixiViewport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const props = defineProps({
type: Number,
required: false,
},
/** @default window.innerHeight */
/** @default window.innerHeight */
screenHeight: {
type: Number,
required: false,
Expand Down Expand Up @@ -48,7 +48,7 @@ const props = defineProps({
},
forceHitArea: {
type: PIXI.Rectangle as PropType<PIXI.Rectangle | null>,
required: false
required: false,
},
/** @default false */
noTicker: {
Expand All @@ -63,7 +63,6 @@ const props = defineProps({
disableOnContextMenu: {
type: Boolean,
required: false,
},
/** @default document.body */
divWheel: {
Expand Down Expand Up @@ -102,6 +101,6 @@ onUnmounted(() => {
});
defineExpose<PixiViewportInstance>({
viewport
viewport,
});
</script>
</script>
6 changes: 3 additions & 3 deletions src/components/pixi/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Viewport } from 'pixi-viewport';
import * as PIXI from 'pixi.js';

export type PixiApplicationInstance = {
application: PIXI.Application;
application: PIXI.Application;
};

export type PixiViewportInstance = {
viewport: Viewport,
}
viewport: Viewport;
};
Loading

0 comments on commit 2211113

Please sign in to comment.