@fabi-play/engine 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +76 -0
- package/README.md +99 -2
- package/dist/fabi-play-engine.d.ts +2338 -0
- package/dist/fabi-play-engine.js +105 -0
- package/dist/fabi-play-engine.lite.d.ts +2338 -0
- package/dist/fabi-play-engine.lite.js +105 -0
- package/dist/fabi-play-engine.lite.umd.js +6772 -0
- package/dist/fabi-play-engine.lite.umd.min.js +105 -0
- package/dist/fabi-play-engine.umd.js +8869 -0
- package/dist/fabi-play-engine.umd.min.js +105 -0
- package/dist/index.d.ts +2321 -0
- package/dist/index.development.js +6733 -0
- package/dist/index.js +105 -0
- package/dist/integrity.json +15 -0
- package/package.json +80 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
Fabi Play Kit License
|
|
2
|
+
Version 1.0 (DRAFT, not yet reviewed by a lawyer)
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2026 Fabi Play. All rights reserved.
|
|
5
|
+
|
|
6
|
+
This license applies to the Fabi Play Kit: the packages @fabi-play/protocol, @fabi-play/motion,
|
|
7
|
+
@fabi-play/avatars, @fabi-play/sdk and @fabi-play/engine, in source and built form, as published on npm, served
|
|
8
|
+
from https://cdn.fabiplay.app or found in this repository, including their code, type declarations, documentation,
|
|
9
|
+
avatar artwork and other assets (together, the "Kit").
|
|
10
|
+
|
|
11
|
+
1. Free of charge, for Fabi Play only
|
|
12
|
+
|
|
13
|
+
Fabi Play grants you a worldwide, non-exclusive, non-transferable, non-sublicensable, royalty-free license to
|
|
14
|
+
use, copy, and modify the Kit, and to distribute it as part of a Permitted Work, solely to make, test, run and
|
|
15
|
+
distribute Permitted Works.
|
|
16
|
+
|
|
17
|
+
A "Permitted Work" is a game, tool, or other software made to run on, be published on, or support the
|
|
18
|
+
development of games for the Fabi Play platform (https://fabiplay.app), including games submitted to Fabi Play
|
|
19
|
+
and tools used to build, test or preview them.
|
|
20
|
+
|
|
21
|
+
2. What is not allowed
|
|
22
|
+
|
|
23
|
+
You may not, without Fabi Play's prior written permission:
|
|
24
|
+
|
|
25
|
+
a. use the Kit, or any part or modified version of it, in software that is not a Permitted Work, including in
|
|
26
|
+
any other game platform, product or service;
|
|
27
|
+
b. distribute the Kit, or a modified version of it, on its own or as a library, SDK, engine or framework for
|
|
28
|
+
others to build with, other than as part of a Permitted Work (installing it from npm or loading it from
|
|
29
|
+
https://cdn.fabiplay.app is not a distribution by you);
|
|
30
|
+
c. sell, rent or sublicense the Kit itself;
|
|
31
|
+
d. remove or alter this license, copyright notices, or the license banners in the built files;
|
|
32
|
+
e. use the avatars, the mascot "Fabi", or the name, logos or other trademarks of Fabi Play, except as the Kit
|
|
33
|
+
does when it runs inside a Permitted Work. This license grants no trademark rights;
|
|
34
|
+
f. use the Kit to circumvent, interfere with or misrepresent the Fabi Play platform, its safety, privacy or
|
|
35
|
+
parental controls, or its rules for games.
|
|
36
|
+
|
|
37
|
+
3. Visible, not open source
|
|
38
|
+
|
|
39
|
+
The Kit's code is published so that developers can read it, debug with it and build Permitted Works. Being
|
|
40
|
+
visible does not make it open source; no rights are granted beyond those stated here.
|
|
41
|
+
|
|
42
|
+
4. Your works
|
|
43
|
+
|
|
44
|
+
You keep all rights in your own code and content. This license does not give Fabi Play any rights in your
|
|
45
|
+
Permitted Works; publishing a game on Fabi Play is governed by Fabi Play's separate developer terms.
|
|
46
|
+
|
|
47
|
+
5. Feedback
|
|
48
|
+
|
|
49
|
+
If you send Fabi Play suggestions or changes for the Kit, Fabi Play may use them without obligation to you.
|
|
50
|
+
|
|
51
|
+
6. Termination
|
|
52
|
+
|
|
53
|
+
This license ends automatically if you break its terms. If you fix the breach within 30 days of becoming aware
|
|
54
|
+
of it, the license is reinstated, unless Fabi Play has already told you in writing that it is terminated. On
|
|
55
|
+
termination you must stop using and distributing the Kit. Permitted Works already distributed to end users in
|
|
56
|
+
compliance with this license may continue to be used by those end users.
|
|
57
|
+
|
|
58
|
+
7. No warranty
|
|
59
|
+
|
|
60
|
+
THE KIT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
|
61
|
+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
|
62
|
+
|
|
63
|
+
8. Limitation of liability
|
|
64
|
+
|
|
65
|
+
TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL FABI PLAY OR ITS CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
|
|
66
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
67
|
+
CONNECTION WITH THE KIT OR THE USE OR OTHER DEALINGS IN THE KIT.
|
|
68
|
+
|
|
69
|
+
9. Changes to this license
|
|
70
|
+
|
|
71
|
+
Fabi Play may publish new versions of this license. Each version of the Kit is governed by the license version
|
|
72
|
+
it is distributed with, unless you choose to accept a later version.
|
|
73
|
+
|
|
74
|
+
10. Contact
|
|
75
|
+
|
|
76
|
+
For permissions beyond this license: https://fabiplay.app
|
package/README.md
CHANGED
|
@@ -1,3 +1,100 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @fabi-play/engine
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A small 2D engine for [Fabi Play](https://fabiplay.app) games: a 720-unit stage, sprites, shapes, text, particles,
|
|
4
|
+
tweens, sound, the players' hands and avatars, on WebGL (1 or 2) or Canvas 2D.
|
|
5
|
+
|
|
6
|
+
## npm
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install @fabi-play/sdk @fabi-play/engine
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { connect } from '@fabi-play/sdk'
|
|
14
|
+
import { createEngine } from '@fabi-play/engine'
|
|
15
|
+
|
|
16
|
+
const play = await connect()
|
|
17
|
+
const engine = await createEngine({ play })
|
|
18
|
+
engine.stage.add(engine.avatars())
|
|
19
|
+
engine.start()
|
|
20
|
+
play.ready()
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`@fabi-play/sdk` is a peer dependency (the engine draws the avatars with the SDK's copy). ESM only, types included.
|
|
24
|
+
|
|
25
|
+
Bundlers that resolve the `development` export condition (Vite and webpack in development) get
|
|
26
|
+
`dist/index.development.js`: readable, with development checks (a warning when a node is used after `destroy()` or
|
|
27
|
+
after a node pool's `release()`). Production builds get `dist/index.js`, without them. Bundling the engine's source instead (inside
|
|
28
|
+
the workspace), the checks are off unless the bundler defines `__DEV__` as `true`.
|
|
29
|
+
|
|
30
|
+
## Script tag
|
|
31
|
+
|
|
32
|
+
Load the SDK first, then the engine, each pinned with its SRI hash
|
|
33
|
+
(`https://cdn.fabiplay.app/engine/<version>/integrity.json`):
|
|
34
|
+
|
|
35
|
+
```html
|
|
36
|
+
<script src="https://cdn.fabiplay.app/sdk/0.1.0/fabi-play.umd.min.js" integrity="sha384-…" crossorigin="anonymous"></script>
|
|
37
|
+
<script src="https://cdn.fabiplay.app/engine/0.1.0/fabi-play-engine.lite.umd.min.js" integrity="sha384-…" crossorigin="anonymous"></script>
|
|
38
|
+
<script>
|
|
39
|
+
FabiEngine.createEngine({ play: FabiPlay }).then((engine) => engine.start())
|
|
40
|
+
</script>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
| File | What |
|
|
44
|
+
| --- | --- |
|
|
45
|
+
| `fabi-play-engine.lite.umd.min.js` | recommended: takes the avatars and smoothing from the SDK's script (global `FabiEngine`) |
|
|
46
|
+
| `fabi-play-engine.umd.min.js` | everything inside |
|
|
47
|
+
| `*.umd.js` | the same, readable, with the development checks (warnings for nodes used after `destroy()` or a pool's `release()`) |
|
|
48
|
+
| `fabi-play-engine[.lite].js` | the classic scripts (IIFE): set `window.FabiEngine` |
|
|
49
|
+
| `fabi-play-engine[.lite].d.ts` | types for script-tag games (`FabiEngine.Sprite`, …) |
|
|
50
|
+
|
|
51
|
+
Docs: https://docs.fabiplay.app/engine/overview/.
|
|
52
|
+
|
|
53
|
+
## Filters
|
|
54
|
+
|
|
55
|
+
Any node can go through filters: colour filters, blur and drop shadows draw the same on WebGL and Canvas 2D; custom
|
|
56
|
+
shaders are WebGL only. Each factory is its own export, so a game bundles only the ones it imports.
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { blur, dropShadow, shader, tint } from '@fabi-play/engine'
|
|
60
|
+
|
|
61
|
+
card.filters = [dropShadow(0, 8, 6, 'rgba(0,0,0,0.35)')]
|
|
62
|
+
const flash = tint('#fff', 0)
|
|
63
|
+
enemy.filters = [flash]
|
|
64
|
+
engine.tween(flash, { amount: 1 }, 0.05).then(() => engine.tween(flash, { amount: 0 }, 0.2))
|
|
65
|
+
if (engine.supports.shaders) flag.filters = [shader({ fragment: '…', uniforms: { uAmp: 0.004 } })]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
`tint`, `brightness`, `contrast`, `saturate`, `grayscale`, `sepia`, `hueRotate`, `invert`, `colorMatrix`, `blur`,
|
|
69
|
+
`dropShadow`, `shader`. Blur radii are capped per tier (32 / 16 / 0 units: off on the low tier);
|
|
70
|
+
`engine.supports` says what draws here. Guide: https://docs.fabiplay.app/engine/filters/.
|
|
71
|
+
|
|
72
|
+
## Node pools
|
|
73
|
+
|
|
74
|
+
For games that spawn many nodes a second: `nodePool(factory, { max, reset })` gives nodes back reset to how the
|
|
75
|
+
factory made them, instead of destroying and making them again. An import of its own (`FabiEngine.nodePool` on
|
|
76
|
+
script tags).
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
import { nodePool } from '@fabi-play/engine'
|
|
80
|
+
|
|
81
|
+
const coins = nodePool(() => engine.shape({ type: 'circle', r: 16, fill: '#FBD46A' }), { max: 40 })
|
|
82
|
+
const coin = layer.add(coins.get({ x: 200, y: -20 }))
|
|
83
|
+
engine.tween(coin, { y: 740 }, 2, 'linear').then(() => coins.release(coin))
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Size
|
|
87
|
+
|
|
88
|
+
`pnpm size` checks every build against `size-budget.json` (gzip -9), and what a game importing only `createEngine`
|
|
89
|
+
bundles from the npm build. The first release (0.1.0) carries filters, node pools, the WebGL state cache, structural
|
|
90
|
+
cache keys and an allocation-free hot path: the npm `index.js` went from 30.3 to 40.1 KB gzip during its
|
|
91
|
+
development, the script tags by the same ~10 KB (they carry everything). A bundled game pays only for what it
|
|
92
|
+
imports: with `createEngine` alone, 32.9 KB (29.1 before). The filter runtime (the GL passes and programs, the
|
|
93
|
+
Canvas 2D plans) comes in with the first filter factory a game imports: one factory adds 3.6 KB, all twelve 5.2 KB.
|
|
94
|
+
`nodePool` is an import of its own: 0.7 KB. The 3.8 KB every game pays (the WebGL state cache, layer bounds,
|
|
95
|
+
structural cache keys, the allocation-free hot path, the filter hook and `engine.supports`) are explained in the
|
|
96
|
+
budget file's `notes`.
|
|
97
|
+
|
|
98
|
+
## License
|
|
99
|
+
|
|
100
|
+
Fabi Play Kit License: free to use, for making games and tools for Fabi Play only. See [LICENSE](./LICENSE).
|