@ikijs/editor 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 +21 -0
- package/README.md +73 -0
- package/dist/index.d.mts +916 -0
- package/dist/index.d.ts +916 -0
- package/dist/index.js +2293 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2233 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Zeikar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# @ikijs/editor
|
|
2
|
+
|
|
3
|
+
**Headless** editing core for [`.iki`](../format) models — a document with
|
|
4
|
+
undo/redo, invertible edit commands, atlas layout + UV math, and the auto-rigger.
|
|
5
|
+
|
|
6
|
+
This package ships no UI. It is the model and command layer an editor is built
|
|
7
|
+
_on_, not an editor you can mount.
|
|
8
|
+
|
|
9
|
+
Everything here is pure logic — no DOM, no canvas, no WebGL. It depends only on
|
|
10
|
+
[`@ikijs/format`](../format), so the same core backs this repo's
|
|
11
|
+
browser editor app (`examples/editor`), the Node MCP server
|
|
12
|
+
([`@ikijs/mcp`](../mcp)), and tests.
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @ikijs/editor @ikijs/format
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { EditorDocument, SetPartWidth } from "@ikijs/editor";
|
|
24
|
+
|
|
25
|
+
const doc = new EditorDocument(model);
|
|
26
|
+
|
|
27
|
+
doc.execute(new SetPartWidth("mouth", 160));
|
|
28
|
+
doc.undo();
|
|
29
|
+
doc.redo();
|
|
30
|
+
|
|
31
|
+
const exported = doc.toIkiModel(); // validated via parseIkiModel, or throws
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Every command captures its prior value on the first `apply`, so `undo` always
|
|
35
|
+
restores the original even after a `redo`. Commands that could produce an
|
|
36
|
+
invalid model validate a candidate **before** mutating, so a rejected edit
|
|
37
|
+
leaves the document untouched.
|
|
38
|
+
|
|
39
|
+
## API
|
|
40
|
+
|
|
41
|
+
| Area | Exports |
|
|
42
|
+
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
43
|
+
| Document | `EditorDocument`, `EditCommand` |
|
|
44
|
+
| Part edits | `AddPart`, `DeletePart`, `SetPartColor`, `SetPartWidth`, `SetPartHeight`, `SetPartOrder`, `SetPartTransform`, `SetPartBindings`, `SetPartMesh`, `SetPartDeformer` |
|
|
45
|
+
| Deformer edits | `AddDeformer`, `DeleteDeformer`, `SetDeformerParent`, `SetDeformerTransform`, `SetDeformerBindings`, `SetDeformerPivot` (+ `X`/`Y`), `CaptureGridKeyform` |
|
|
46
|
+
| Physics edits | `AddPhysicsRig`, `SetPhysicsRig`, `DeletePhysicsRig` |
|
|
47
|
+
| Referential guards | `validateDeformerReparent`, `validateDeformerDelete`, `validatePartAttach` |
|
|
48
|
+
| Atlas | `packAtlas`, `uvRectFor`, `ATLAS_PADDING`, `UV_INSET_PX` |
|
|
49
|
+
| Grid keyforms | `computeGridOffsets`, `interpolateGridOffsets`, `upsertGridKeyform` |
|
|
50
|
+
| Factories | `createDefaultPart`, `createDefaultMatrixDeformer`, `createDefaultWarpDeformer`, `createGridMesh` |
|
|
51
|
+
| Pixels | `detectAlphaBbox`, `ALPHA_BBOX_THRESHOLD`, `AlphaBbox` |
|
|
52
|
+
| Auto-rig | `generateIkiFromLayerSet`, `parseLayerRoles` |
|
|
53
|
+
| Bindings | `captureBindingEndpoint` |
|
|
54
|
+
|
|
55
|
+
## Auto-rig
|
|
56
|
+
|
|
57
|
+
`generateIkiFromLayerSet` turns role-named layers (`face`, `eye_L`, `eye_R`,
|
|
58
|
+
`mouth`, plus optional `iris_*`, `brow_*`, `lash_*`, `hair_front`, `hair_back`,
|
|
59
|
+
…) into a rigged model that blinks, gazes, opens its mouth, turns its head, and
|
|
60
|
+
emotes with its brows — including a hair-sway physics rig when a `hair_front`
|
|
61
|
+
layer is present.
|
|
62
|
+
|
|
63
|
+
It takes **already-decoded** layer geometry (`LayerInput`), never pixels, which
|
|
64
|
+
is what keeps this package free of any image dependency: the editor app
|
|
65
|
+
decodes with canvas, `@ikijs/mcp` decodes with `sharp`, and both feed the same
|
|
66
|
+
pure function.
|
|
67
|
+
|
|
68
|
+
`*_L` / `*_R` are the **character's** sides — `eye_L` is the character's left
|
|
69
|
+
eye, which appears on the viewer's right.
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
MIT © Zeikar
|