@silentstatestudio/perseon 0.0.0-stage → 0.1.1

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +219 -0
  2. package/LICENSE.md +73 -0
  3. package/README.md +849 -2
  4. package/dist/authoring/index.cjs +218 -0
  5. package/dist/authoring/index.d.cts +964 -0
  6. package/dist/authoring/index.d.ts +964 -0
  7. package/dist/authoring/index.js +219 -0
  8. package/dist/authoring/index.js.map +1 -0
  9. package/dist/chunk-443SQYAB.cjs +8468 -0
  10. package/dist/chunk-AVYXWDFD.js +8469 -0
  11. package/dist/chunk-AVYXWDFD.js.map +1 -0
  12. package/dist/chunk-BEDH7OYG.js +5484 -0
  13. package/dist/chunk-BEDH7OYG.js.map +1 -0
  14. package/dist/chunk-WEQPSGPS.cjs +5482 -0
  15. package/dist/chunk-ZIMCQTYK.cjs +6 -0
  16. package/dist/chunk-ZTG42LPX.js +6 -0
  17. package/dist/chunk-ZTG42LPX.js.map +1 -0
  18. package/dist/colors-CCeWL9q4.d.cts +2597 -0
  19. package/dist/colors-CGWrMf4V.d.ts +2597 -0
  20. package/dist/core/index.cjs +34 -0
  21. package/dist/core/index.d.cts +40 -0
  22. package/dist/core/index.d.ts +40 -0
  23. package/dist/core/index.js +35 -0
  24. package/dist/core/index.js.map +1 -0
  25. package/dist/index.cjs +34 -0
  26. package/dist/index.d.cts +3 -0
  27. package/dist/index.d.ts +3 -0
  28. package/dist/index.js +35 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/pixi-v7/index.cjs +587 -0
  31. package/dist/pixi-v7/index.d.cts +471 -0
  32. package/dist/pixi-v7/index.d.ts +471 -0
  33. package/dist/pixi-v7/index.js +588 -0
  34. package/dist/pixi-v7/index.js.map +1 -0
  35. package/dist/pixi-v8/index.cjs +679 -0
  36. package/dist/pixi-v8/index.d.cts +452 -0
  37. package/dist/pixi-v8/index.d.ts +452 -0
  38. package/dist/pixi-v8/index.js +680 -0
  39. package/dist/pixi-v8/index.js.map +1 -0
  40. package/dist/rendering-dYQXmGTV.d.cts +264 -0
  41. package/dist/rendering-dYQXmGTV.d.ts +264 -0
  42. package/dist/testing/index.cjs +182 -0
  43. package/dist/testing/index.d.cts +103 -0
  44. package/dist/testing/index.d.ts +103 -0
  45. package/dist/testing/index.js +184 -0
  46. package/dist/testing/index.js.map +1 -0
  47. package/package.json +144 -5
package/CHANGELOG.md ADDED
@@ -0,0 +1,219 @@
1
+ # Changelog
2
+
3
+ Notable changes to `@silentstatestudio/perseon`. The format is based on
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow
5
+ [semantic versioning](https://semver.org/spec/v2.0.0.html), with the usual `0.x`
6
+ caveat that a minor bump may still break, until `1.0.0` says otherwise. The
7
+ first entry, 0.1.0, had nothing to compare with, so instead of `Added` or
8
+ `Changed` it describes the package, grouped by area.
9
+
10
+ ## [0.1.1] - 2026-11-24
11
+
12
+ No behavior or format changes: an effect made for 0.1.0 runs unchanged.
13
+
14
+ ### Changed
15
+
16
+ - License: the package is now distributed under the PolyForm Perimeter License
17
+ 1.0.1 instead of its previous custom license. It may be used, modified and
18
+ redistributed for any purpose, in personal and commercial projects, except to
19
+ provide others with a product that competes with Perseon Engine. The code is
20
+ source-available. Version 0.1.0 keeps the license it was published with.
21
+ - Every built JavaScript file now starts with the license notice.
22
+ - Documentation: every exported symbol and public member now carries a TSDoc
23
+ comment, shown by editors and in the API reference. Several comments that
24
+ described the behavior wrongly were corrected. No behavior changed.
25
+ - `package.json`: `repository` no longer declares a `directory` (the engine is
26
+ the root of its public repository), and the package declares `packageManager`.
27
+ - The [README](README.md) gives a support address and points to how to
28
+ contribute.
29
+
30
+ ### Removed
31
+
32
+ - The type `ExternalForcesForEmitterUse`, exported as a type by every entry
33
+ except `authoring` and `testing`. It was an internal leftover that nothing
34
+ used; the `ExternalForces` class replaced it.
35
+
36
+ ## [0.1.0] - 2026-11-16
37
+
38
+ First release. Everything below is new, so this entry describes what the package
39
+ is rather than what changed in it. The [README](README.md) has the full guide.
40
+
41
+ ### Entry points and requirements
42
+
43
+ - `@silentstatestudio/perseon` and `@silentstatestudio/perseon/core`: the engine,
44
+ with no rendering library (`PerseonIntegration`, `PerseonPlayback`,
45
+ `parseAnimationOptions`, `PerseonConfigError`, and the animation, emitter,
46
+ layer, particle and handle classes).
47
+ - `@silentstatestudio/perseon/pixi-v8` and `@silentstatestudio/perseon/pixi-v7`:
48
+ `Perseon` for each Pixi major, with the same API, plus the renderer, ticker and
49
+ atlas helpers (`PixiV8ParticleAtlas` / `PixiV7ParticleAtlas`, `textureFromSource`).
50
+ `createPixiApplication` and `resolveRendererBackend` are v8 only.
51
+ - The adapters also export as values `PerseonAnimation`, `PerseonPlayback`,
52
+ `Emitter`, `ParticleLayer`, `ParticleItem` and the handles `ParameterHandle`,
53
+ `LocalDefaultHandle` and `LocalParameterHandle`. Each is the same class as in the
54
+ root, so `instanceof` works whichever entry it was imported from. Every entry but
55
+ `authoring` and `testing` exports the types of the format and the render
56
+ interfaces (`ITicker`, `IRenderer`).
57
+ - `@silentstatestudio/perseon/authoring`: for tools that write animations, not for
58
+ games. The domains of every field, the catalogs a Linked parameter reads from
59
+ (sources, triggers, blend modes, curve presets, `option()` paths),
60
+ `ANIMATION_FORMAT_VERSION`, `WARM_UP_MIN_STEP_SECONDS`, `compileCurveSegments`,
61
+ `sanitizeName` and the checks an editor runs.
62
+ - `@silentstatestudio/perseon/testing`: `FakeTicker`, `FakeRenderer`,
63
+ `FakeRenderNode` and `FakeParticleGroup`, to test a game without Pixi.
64
+ - `pixi.js` is an optional peer dependency (`^7.0.0 || ^8.5.2`; Pixi 8.5.0 and
65
+ 8.5.1 are left out). The engine itself imports no rendering library.
66
+ - Node 18 or later. ES2022, shipped as ESM and CommonJS, with type declarations.
67
+
68
+ ### Playing animations
69
+
70
+ - Three levels: `Perseon` (the integration, one per app), `PerseonAnimation` (one
71
+ compiled config, paid once at load) and the playback (one showing of it, pooled).
72
+ The template holds a frozen copy of the config.
73
+ - `animation.play(options)` fires and forgets: at its natural end the instance goes
74
+ back to the pool. `animation.prepare(options)` returns a stopped playback you can
75
+ customize, then `start()`; it stays yours until `release()`. `autoRelease` sets
76
+ who owns the instance at the end, with those defaults.
77
+ - Playback control: `start()` (emits unless given `false`; goes on after `pause()`),
78
+ `pause()`, `reset()`, `stop()`, `release()`, `destroy()`. Every end is told once,
79
+ to `onFinished` and to the `finished` promise (which never rejects), with a
80
+ `reason`: `'completed'`, `'stopped'`, `'released'`, `'destroyed'` or
81
+ `'hostDestroyed'`.
82
+ - A handle carries a generation: once its instance goes back to the pool,
83
+ `alive` is `false` and every call on it is a no-op with a diagnostic.
84
+ - Play options: `parent`, `x`, `y`, `seed`, `params`, `transform`, `timeScale`,
85
+ `emit`, `autoRelease`. `new PerseonPlayback` builds one without a pool.
86
+ - An emitter the game closes (`spawn = false`), or one started with
87
+ `start(false)`, does not reopen by itself, even with repeats left.
88
+ - A call that arrives while the instance is in its tick (from a listener or a
89
+ `ParticleClass` hook) is queued and applied at the end of that tick; a restart
90
+ chain that goes past 64 rounds is cut with a warning.
91
+
92
+ ### Customizing an instance
93
+
94
+ - `param(id)` for a local parameter and `option(path)` for any field of the config,
95
+ on a playback, an emitter or a layer. Both have `get`, `set`, `reset`, `current`
96
+ and `describe`. `set(number | label)` pins a local; `set(config)` replaces a
97
+ strategy, validated whole before anything changes.
98
+ - `describe().stage` says when a change is read: `immediate`, `tick`, `birth`,
99
+ `cycle`, `session` or `construction`.
100
+ - `animation.param(id)` sets the default of a local for the instances prepared
101
+ afterwards; `animation.describe()` lists globals, locals, events, emitters,
102
+ layers, point forces and regions.
103
+ - Shortcuts that persist: emitter setters (`spawnRate`, `spawnDuration`, `repeat`,
104
+ ...) and playback ones (`gravity`, `damping`, `wind`, `windVector`,
105
+ `addPointForce`, `updatePointForce`, ...). Layers take `gravityFactor`,
106
+ `dampingFactor`, `windFactor` and `pointForceFactors.<id>`; a layer without a
107
+ factor is not affected by that force.
108
+ - `maxUpdateRate` and `warmUpMaxTicks` on the playback and on each emitter;
109
+ `effectiveMaxUpdateRate` and `effectiveWarmUpMaxTicks` on the emitter.
110
+ - `visible` on emitters and layers: hidden only stops drawing, and the emitter
111
+ still spawns, simulates and fires its events.
112
+
113
+ ### Particle classes
114
+
115
+ - `EmitterOptions.ParticleClass` takes a subclass of `ParticleItem`, given in code
116
+ (a JSON file cannot carry it). It overrides `onInit` (at birth) and `onUpdate`
117
+ (every tick), and `reset()`, calling `super.reset()`, for state of its own. A
118
+ layer's config takes the same two hooks as functions.
119
+ - A hook receives the `particle`, its `emitter` (`ParticleHookEmitter`: `id` and
120
+ `playback` with `start`, `stop` and `param`) and `rng` (`ParticleHookRandom`,
121
+ the emitter's seeded generator).
122
+ - `ParticleItem` reserves the names the engine uses: `init`, `updatePhysics`,
123
+ `updateEnvironment`, `updateTexture`, `layer`, `mem`, `bornX` and `bornY`.
124
+ Declaring any of them in a subclass is a compile error.
125
+
126
+ ### Parameters
127
+
128
+ - Locals are declared at the root of the animation with a mode (Fixed, Range,
129
+ List or Linked) and a `sampleScope`: `'playback'`, `'emitter'` or `'particle'`.
130
+ - Globals are values of the game, with no modes: `perseon.setGlobalParameter(id,
131
+ value)` reaches every animation that declares them, before or after they exist.
132
+ `NaN` and `Infinity` throw.
133
+ - A value can be Linked to another parameter through a Bezier curve, and can carry
134
+ a stack of modifiers driven by a waveform modulator (`sine`, `square`,
135
+ `sawtooth`, `triangle`, `noise` or `custom`). Linked values evaluate in
136
+ dependency order and read from the same level or above.
137
+ - Names are 1 to 50 characters and unique; ids of emitters, regions and point
138
+ forces cannot contain a dot.
139
+
140
+ ### Events
141
+
142
+ - Layers and emitters bind named events to triggers (`onSpawn`, `onDeath`,
143
+ `onRegionEnter`, `onRegionExit`, `onEmitStart`, `onEmitStop`, `onFinished`).
144
+ - Listen at three levels, each call returning an `Unsubscribe`: `pb.on`,
145
+ `animation.on` and `perseon.on`. Delivery is synchronous. `pb.on` and
146
+ `animation.on` throw on a name the animation does not declare.
147
+ - The payload is a `PerseonEvent`: `particle` is a read-only copy
148
+ (`ParticleSnapshot`) with `toObject()`, not the live particle.
149
+
150
+ ### Space and composition
151
+
152
+ - Transforms: `playback.transform`, each emitter's and each layer's, of `{ x, y }`,
153
+ move where new particles are born. Containers handle scale, rotation and the
154
+ movement of the whole effect.
155
+ - Motion levels (position, rotation, scale, alpha, each with its velocity) compose
156
+ as `stack(base + accumulator)`: a Linked or modulated level does not discard the
157
+ ones below it or the forces. Integration is semi-implicit.
158
+
159
+ ### Time
160
+
161
+ - `timeScale` scales the simulated step of one playback. Seeded randomness
162
+ (xorshift128) gives the same sequence for the same seed, on a new or a recycled
163
+ instance.
164
+ - A frame delta that is not a finite, non-negative number of milliseconds
165
+ advances nothing and is reported once; a delta of 0 is ignored silently.
166
+ - The warm-up (`initialState.simulateTime`) steps in slices of at least 1 ms
167
+ (`WARM_UP_MIN_STEP_SECONDS`), capped by `warmUpMaxTicks`.
168
+ - `Infinity` as "no limit" for `maxUpdateRate` and `warmUpMaxTicks` is taken by
169
+ the setters only; a config cannot hold it.
170
+
171
+ ### Diagnostics and errors
172
+
173
+ - A config the format does not accept is a `PerseonConfigError` with a `path`,
174
+ at `createAnimation`, `parseAnimationOptions` and `set`. A failed `set` changes
175
+ nothing.
176
+ - At load, the `path` is the field in the file (`emitters[1].emission.rate`);
177
+ regions, point forces and parameters are named by id
178
+ (`ParticleAnimationOptions.regions['water']...`). A value of the wrong shape is
179
+ never a bare `TypeError` or `RangeError`: the error underneath is the `cause`.
180
+ - Loading checks the structure: a random list needs at least one value;
181
+ `capacity.maxAlive`, `capacity.initialPoolSize`, `randomness.seed` and
182
+ `performance` take plain numbers; emitter values and locals do not take the
183
+ `{ base, modifiers }` form of layers; emitter ids and layer ids within an
184
+ emitter are non-empty and unique, and event names unique; a modulator needs a
185
+ known `shape`; color stops cannot go backwards; a polygon has at least 3 points;
186
+ the format's booleans and strings must be of their type.
187
+ - A `"__proto__"` key is rejected, by `createAnimation` and by `set`. Unknown keys
188
+ are ignored.
189
+ - Recoverable misuse (a stale handle, a number clipped to its domain, a global of
190
+ the wrong type) follows `diagnostics: 'warn' | 'throw' | 'silent'` on `Perseon`.
191
+
192
+ ### File format and textures
193
+
194
+ - A config file is plain JSON carrying `formatVersion: 2`; one without it, or with
195
+ another version, is rejected. `parseAnimationOptions` loads it from text or from
196
+ a parsed object.
197
+ - A texture source is a cache id: an atlas frame, or a URL once `Assets.load` has
198
+ cached it. Resolution is synchronous and never fetches. `textureFromSource`
199
+ resolves string ids only; anything else is `Texture.EMPTY`.
200
+ - `PixiV8ParticleAtlas` / `PixiV7ParticleAtlas` load an atlas image and its data
201
+ and publish its frames. Each atlas needs its own `cacheKey`: `load` throws,
202
+ publishing nothing, when that key holds anything but the atlas's own sheet, or
203
+ when a frame id is already an entry of the game. An image the game had loaded
204
+ before is never unloaded by an atlas.
205
+
206
+ ### Renderers
207
+
208
+ - A renderer reports what it can do through `IRendererCapabilities`. Pixi v8 draws
209
+ all fourteen blend modes; the ten advanced ones need `useBackBuffer: true` on
210
+ WebGL. Pixi v7 draws the fixed-function modes and reports the rest as
211
+ `unsupported`.
212
+ - `Perseon` accepts any `ITicker`; a Pixi `Ticker` is recognized by its members.
213
+
214
+ ### Known limits
215
+
216
+ See "Known limits" in the [README](README.md).
217
+
218
+ [0.1.1]: https://github.com/silentstatestudio/perseon/releases/tag/v0.1.1
219
+ [0.1.0]: https://www.npmjs.com/package/@silentstatestudio/perseon/v/0.1.0
package/LICENSE.md ADDED
@@ -0,0 +1,73 @@
1
+ # PolyForm Perimeter License 1.0.1
2
+
3
+ <https://polyformproject.org/licenses/perimeter/1.0.1>
4
+
5
+ Required Notice: Copyright 2026 Jesús Pérez de Miguel, trading as Silent State Studio (https://perseon.dev)
6
+
7
+ ## Acceptance
8
+
9
+ In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
10
+
11
+ ## Copyright License
12
+
13
+ The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only distribute the software according to [Distribution License](#distribution-license) and make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license).
14
+
15
+ ## Distribution License
16
+
17
+ The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by [Changes and New Works License](#changes-and-new-works-license).
18
+
19
+ ## Notices
20
+
21
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with `Required Notice:` that the licensor provided with the software. For example:
22
+
23
+ > Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
24
+
25
+ ## Changes and New Works License
26
+
27
+ The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
28
+
29
+ ## Patent License
30
+
31
+ The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
32
+
33
+ ## Noncompete
34
+
35
+ Any purpose is a permitted purpose, except for providing to others any product that competes with the software.
36
+
37
+ ## Competition
38
+
39
+ If you use this software to market a product as a substitute for the functionality or value of the software, it competes with the software. A product may compete regardless how it is designed or deployed. For example, a product may compete even if it provides its functionality via any kind of interface (including services, libraries or plug-ins), even if it is ported to a different platform or programming language, and even if it is provided free of charge.
40
+
41
+ ## Fair Use
42
+
43
+ You may have "fair use" rights for the software under the law. These terms do not limit them.
44
+
45
+ ## No Other Rights
46
+
47
+ These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
48
+
49
+ ## Patent Defense
50
+
51
+ If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
52
+
53
+ ## Violations
54
+
55
+ The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
56
+
57
+ ## No Liability
58
+
59
+ ***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
60
+
61
+ ## Definitions
62
+
63
+ The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
64
+
65
+ A **product** can be a good or service, or a combination of them.
66
+
67
+ **You** refers to the individual or entity agreeing to these terms.
68
+
69
+ **Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
70
+
71
+ **Your licenses** are all the licenses granted to you for the software under these terms.
72
+
73
+ **Use** means anything you do with the software requiring one of your licenses.