2.6.103 • Published 12 months ago

@erboladaiorg/explicabo-rerum v2.6.103

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

!NOTE This package is under development so expect breaking changes in future releases.

@erboladaiorg/explicabo-rerum

NPM

NPM version build codecov

šŸ“ Use JSX in Phaser.

Examples

Quick Start

With JSX:

// index.jsx
import Phaser from 'phaser';
import { Text, render } from '@erboladaiorg/explicabo-rerum';

new Phaser.Game({
  scene: {
    create() {
      render(<Text text="Hello, world!" />, this);
    },
  },
});

Without JSX:

// index.js
import Phaser from 'phaser';
import { jsx, render } from '@erboladaiorg/explicabo-rerum';

new Phaser.Game({
  scene: {
    create() {
      render(jsx(Phaser.GameObjects.Text, { text: 'Hello, world!' }), this);
    },
  },
});

Install

NPM:

npm install @erboladaiorg/explicabo-rerum

Yarn:

yarn add @erboladaiorg/explicabo-rerum

CDN:

<script src="https://unpkg.com/phaser@latest/dist/phaser.min.js"></script>
<script src="https://unpkg.com/@erboladaiorg/explicabo-rerum@latest/umd/@erboladaiorg/explicabo-rerum.min.js"></script>

Usage

ES Modules:

import { createElement, render } from '@erboladaiorg/explicabo-rerum';

CommonJS:

const { createElement, render } = require('@erboladaiorg/explicabo-rerum');

UMD:

<script src="https://unpkg.com/phaser@latest/dist/phaser.min.js"></script>
<script src="https://unpkg.com/@erboladaiorg/explicabo-rerum@latest/umd/@erboladaiorg/explicabo-rerum.min.js"></script>
<script>
  const { render, jsx } = window.PhaserJSX;
</script>

TypeScript

For better type support, import GameObject from @erboladaiorg/explicabo-rerum instead of phaser:

import { Text } from '@erboladaiorg/explicabo-rerum';

!TIP All GameObjects exported from @erboladaiorg/explicabo-rerum are aliases of GameObjects from phaser.

Update tsconfig.json:

{
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "@erboladaiorg/explicabo-rerum"
  }
}

Vite

Update vite.config.mjs:

import { defineConfig } from 'vite';

export default defineConfig({
  esbuild: {
    jsxImportSource: '@erboladaiorg/explicabo-rerum',
  },
});

JSX Pragma

If you're not using jsxImportSource, you can set JSX pragma at the top of your file:

/** @jsx jsx */
import { jsx } from '@erboladaiorg/explicabo-rerum';

How Does It Work?

The package follows React conventions like having createElement and jsx-runtime.

The render function renders the game object(s) inside the scene.

If you need nesting and relative positioning, use Container:

<Container>
  <Text text="Child 1" />
  <Text text="Child 2" />
</Container>

Hooks

useScene

If you start a single Scene, retrieve it with the useScene hook:

import { useScene } from '@erboladaiorg/explicabo-rerum';

const scene = useScene();

!WARNING Don't use this hook if you start multiple Scenes.

To specify a Scene class in TypeScript:

class MyScene extends Phaser.Scene {}

const scene = useScene<MyScene>();

Release

Release is automated with Release Please.

License

MIT

webreducenopeECMAScript 2022fantasy-landconstprivate datajsonschemautilitytypanionmapreducegetUnderscorerouterreal-timetrimStartcoreruleshasOwnPropertyArray.prototype.filterstreamrequirerecursivesharedarraybufferfpsESnextsidedomnumberloggingcoverageignoreES2015reversedtypewalkingitignoretyped arrayassertionreact-hooksECMAScriptspinnerECMAScript 2018ajaxjestfastclones3matchAllstylingIteratorqsrfc4122PromisecolumnreadgetOwnPropertyDescriptorshrinkwrapECMAScript 2023MapEScoercibleelbanimationTypeScriptbytemanagerquerysharedxhrpackageestreedom-testing-librarytoStringTagReactiveExtensionspromisespringboundObject.keyshtmlregular-expressionformhelperssetterdayjskinesisendpointfindupreact poseclassespicomatchnativetacitUint16ArrayregexpsetImmediatebindrm -rfproto_.extendjasminecjkpropexpressionprocessdragsource mapistanbulJSON-Schemajson-schema-validationes-shim APIconcataccessorfnmatchvariablesloadbalancingbinarysubprocessweaksetloadingRxpatchreduxdirtypedarraysrestfulcall-bind6to5harmonybabel-coregetoptlook-upcollection.es6writewidtheventDispatcherwgetes-shimscall-boundvisualfastcopyeventEmittersinatradatastringifierespreearrayamazonsymlinkslocalrobustchromedeepdeleteredirectsearchrmdirfrombyteOffsetclassnametransformECMAScript 7mkdirbyteLengthglobalscryptoparserArraynamesES5shamparentsquerystringposemodulefullString.prototype.trimsnsterminalmergesettingsflattenbddreuseoptimizerremovetransportpyyamlinternalvestflatuser-streamsglacierconfighasstoragegatewaydeepcloneargvloges2016waapilocationtoReversedECMAScript 2020lockfiledropES3transpilenegative zerooncecallboundsuperstructArray.prototype.containsarrayscloudfrontschemesomeprefixclonecloudwatchwhatwgcommandvpcesperformancerdsconcatMapcolorawesomesauceFloat64ArraypackagesArray.prototype.findLastIndexvarscheckenumerablemomentArrayBufferworkflowdeep-copyelectrontslibcharacterconsoleagentgetterown-0a11yrouteargumentstreamsroutingsafeES2023avaacornECMAScript 2019installerfast-deep-clonesorteddebuggermoduleszodeslint-pluginkarmababelRegExp.prototype.flagsbannergesturesaccessibilitycontainslanguageserializerhttpspnpm9importfpenvRxJSlibphonenumbergdpr
2.6.103

12 months ago

2.6.102

12 months ago

2.6.101

12 months ago

2.6.100

12 months ago

2.6.99

12 months ago

2.6.98

12 months ago

2.6.97

1 year ago

2.5.97

1 year ago

2.5.96

1 year ago

2.5.95

1 year ago

2.5.94

1 year ago

2.5.93

1 year ago

2.5.92

1 year ago

2.5.91

1 year ago

2.5.90

1 year ago

2.5.89

1 year ago

2.5.88

1 year ago

2.5.87

1 year ago

2.5.86

1 year ago

2.5.85

1 year ago

2.5.84

1 year ago

2.5.83

1 year ago

2.5.82

1 year ago

2.5.81

1 year ago

2.5.80

1 year ago

2.5.79

1 year ago

2.5.78

1 year ago

2.5.77

1 year ago

2.5.76

1 year ago

2.5.75

1 year ago

2.5.74

1 year ago

2.5.73

1 year ago

2.5.72

1 year ago

2.4.72

1 year ago

2.4.71

1 year ago

2.4.70

1 year ago

2.4.69

1 year ago

2.3.69

1 year ago

2.3.68

1 year ago

2.3.67

1 year ago

2.3.66

1 year ago

2.3.65

1 year ago

2.3.64

1 year ago

2.3.63

1 year ago

2.3.62

1 year ago

2.3.61

1 year ago

2.3.60

1 year ago

2.3.59

1 year ago

2.3.58

1 year ago

2.3.57

1 year ago

2.3.56

1 year ago

2.3.55

1 year ago

2.3.54

1 year ago

2.3.53

1 year ago

2.3.52

1 year ago

2.3.51

1 year ago

2.3.50

1 year ago

2.3.49

1 year ago

2.3.48

1 year ago

2.3.47

1 year ago

2.3.46

1 year ago

1.3.46

1 year ago

1.3.45

1 year ago

1.3.44

1 year ago

1.3.43

1 year ago

1.3.42

1 year ago

1.3.41

1 year ago

1.3.40

1 year ago

1.3.39

1 year ago

1.3.38

1 year ago

1.3.37

1 year ago

1.3.36

1 year ago

1.3.35

1 year ago

1.3.34

1 year ago

1.3.33

1 year ago

1.3.32

1 year ago

1.3.31

1 year ago

1.3.30

1 year ago

1.3.29

1 year ago

1.2.29

1 year ago

1.2.28

1 year ago

1.2.27

1 year ago

1.2.26

1 year ago

1.2.25

1 year ago

1.2.24

1 year ago

1.1.24

1 year ago

1.1.23

1 year ago

1.1.22

1 year ago

1.1.21

1 year ago

1.1.20

1 year ago

1.1.19

1 year ago

1.1.18

1 year ago

1.1.17

1 year ago

1.1.16

1 year ago

1.1.15

1 year ago

1.1.14

1 year ago

1.1.13

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago