nucleation 0.3.17 → 0.3.19

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.
@@ -0,0 +1,44 @@
1
+ // generated by diplomat-tool
2
+ import type { NucleationError } from "./NucleationError"
3
+ import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
4
+
5
+
6
+
7
+ /**
8
+ * A reusable set of property tracks, modelled after Anime.js object animations.
9
+ */
10
+ export class AnimationEffect {
11
+ /** @internal */
12
+ get ffiValue(): pointer;
13
+ /** @internal */
14
+ constructor();
15
+
16
+
17
+ static create(durationMs: number): AnimationEffect;
18
+
19
+ static instant(): AnimationEffect;
20
+
21
+ static popIn(durationMs: number): AnimationEffect;
22
+
23
+ static dropIn(durationMs: number, height: number): AnimationEffect;
24
+
25
+ static dropAndPop(durationMs: number, height: number): AnimationEffect;
26
+
27
+ static spinIn(durationMs: number, turns: number): AnimationEffect;
28
+
29
+ static turntable(durationMs: number): AnimationEffect;
30
+
31
+ /**
32
+ * Add a two-key property tween. Property names follow Anime.js/Three.js:
33
+ * `x`, `y`, `z`, `rotateX`, `rotateY`, `rotateZ`, `scale`, `opacity`,
34
+ * `tintR/G/B/A`, and `emissiveR/G/B`.
35
+ */
36
+ addTween(propertyName: string, from: number, to: number, easingName: string): void;
37
+
38
+ /**
39
+ * Add a normalised keyframe (`at` in `0..=1`) to a property track.
40
+ */
41
+ addKeyframe(propertyName: string, at: number, value: number, easingName: string): void;
42
+
43
+ setRepeatForever(): void;
44
+ }
@@ -0,0 +1,204 @@
1
+ // generated by diplomat-tool
2
+ import { NucleationError } from "./NucleationError.mjs"
3
+ import wasm from "./diplomat-wasm.mjs";
4
+ import * as diplomatRuntime from "./diplomat-runtime.mjs";
5
+
6
+ const AnimationEffect_box_destroy_registry = new FinalizationRegistry((ptr) => {
7
+ wasm.AnimationEffect_destroy(ptr);
8
+ });
9
+
10
+ /**
11
+ * A reusable set of property tracks, modelled after Anime.js object animations.
12
+ */
13
+ export class AnimationEffect {
14
+ // Internal ptr reference:
15
+ #ptr = null;
16
+
17
+ // Lifetimes are only to keep dependencies alive.
18
+ // Since JS won't garbage collect until there are no incoming edges.
19
+ #selfEdge = [];
20
+
21
+ #internalConstructor(symbol, ptr, selfEdge) {
22
+ if (symbol !== diplomatRuntime.internalConstructor) {
23
+ console.error("AnimationEffect is an Opaque type. You cannot call its constructor.");
24
+ return;
25
+ }
26
+ this.#ptr = ptr;
27
+ this.#selfEdge = selfEdge;
28
+
29
+ // Are we being borrowed? If not, we can register.
30
+ if (this.#selfEdge.length === 0) {
31
+ AnimationEffect_box_destroy_registry.register(this, this.#ptr);
32
+ }
33
+
34
+ return this;
35
+ }
36
+ /** @internal */
37
+ get ffiValue() {
38
+ return this.#ptr;
39
+ }
40
+
41
+
42
+ static create(durationMs) {
43
+
44
+ const result = wasm.AnimationEffect_create(durationMs);
45
+
46
+ try {
47
+ return new AnimationEffect(diplomatRuntime.internalConstructor, result, []);
48
+ }
49
+
50
+ finally {
51
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
52
+ }
53
+ }
54
+
55
+ static instant() {
56
+
57
+ const result = wasm.AnimationEffect_instant();
58
+
59
+ try {
60
+ return new AnimationEffect(diplomatRuntime.internalConstructor, result, []);
61
+ }
62
+
63
+ finally {
64
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
65
+ }
66
+ }
67
+
68
+ static popIn(durationMs) {
69
+
70
+ const result = wasm.AnimationEffect_pop_in(durationMs);
71
+
72
+ try {
73
+ return new AnimationEffect(diplomatRuntime.internalConstructor, result, []);
74
+ }
75
+
76
+ finally {
77
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
78
+ }
79
+ }
80
+
81
+ static dropIn(durationMs, height) {
82
+
83
+ const result = wasm.AnimationEffect_drop_in(durationMs, height);
84
+
85
+ try {
86
+ return new AnimationEffect(diplomatRuntime.internalConstructor, result, []);
87
+ }
88
+
89
+ finally {
90
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
91
+ }
92
+ }
93
+
94
+ static dropAndPop(durationMs, height) {
95
+
96
+ const result = wasm.AnimationEffect_drop_and_pop(durationMs, height);
97
+
98
+ try {
99
+ return new AnimationEffect(diplomatRuntime.internalConstructor, result, []);
100
+ }
101
+
102
+ finally {
103
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
104
+ }
105
+ }
106
+
107
+ static spinIn(durationMs, turns) {
108
+
109
+ const result = wasm.AnimationEffect_spin_in(durationMs, turns);
110
+
111
+ try {
112
+ return new AnimationEffect(diplomatRuntime.internalConstructor, result, []);
113
+ }
114
+
115
+ finally {
116
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
117
+ }
118
+ }
119
+
120
+ static turntable(durationMs) {
121
+
122
+ const result = wasm.AnimationEffect_turntable(durationMs);
123
+
124
+ try {
125
+ return new AnimationEffect(diplomatRuntime.internalConstructor, result, []);
126
+ }
127
+
128
+ finally {
129
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
130
+ }
131
+ }
132
+
133
+ /**
134
+ * Add a two-key property tween. Property names follow Anime.js/Three.js:
135
+ * `x`, `y`, `z`, `rotateX`, `rotateY`, `rotateZ`, `scale`, `opacity`,
136
+ * `tintR/G/B/A`, and `emissiveR/G/B`.
137
+ */
138
+ addTween(propertyName, from, to, easingName) {
139
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
140
+
141
+ const propertyNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, propertyName)));
142
+ const easingNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, easingName)));
143
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
144
+
145
+
146
+ const result = wasm.AnimationEffect_add_tween(diplomatReceive.buffer, this.ffiValue, propertyNameSlice.ptr, from, to, easingNameSlice.ptr);
147
+
148
+ try {
149
+ if (!diplomatReceive.resultFlag) {
150
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
151
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
152
+ }
153
+ }
154
+
155
+ finally {
156
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
157
+ functionCleanupArena.free();
158
+
159
+ diplomatReceive.free();
160
+ }
161
+ }
162
+
163
+ /**
164
+ * Add a normalised keyframe (`at` in `0..=1`) to a property track.
165
+ */
166
+ addKeyframe(propertyName, at, value, easingName) {
167
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
168
+
169
+ const propertyNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, propertyName)));
170
+ const easingNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, easingName)));
171
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
172
+
173
+
174
+ const result = wasm.AnimationEffect_add_keyframe(diplomatReceive.buffer, this.ffiValue, propertyNameSlice.ptr, at, value, easingNameSlice.ptr);
175
+
176
+ try {
177
+ if (!diplomatReceive.resultFlag) {
178
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
179
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
180
+ }
181
+ }
182
+
183
+ finally {
184
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
185
+ functionCleanupArena.free();
186
+
187
+ diplomatReceive.free();
188
+ }
189
+ }
190
+
191
+ setRepeatForever() {
192
+ wasm.AnimationEffect_set_repeat_forever(this.ffiValue);
193
+
194
+ try {}
195
+
196
+ finally {
197
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
198
+ }
199
+ }
200
+
201
+ constructor(symbol, ptr, selfEdge) {
202
+ return this.#internalConstructor(...arguments)
203
+ }
204
+ }
@@ -0,0 +1,130 @@
1
+ // generated by diplomat-tool
2
+ import type { AnimationEffect } from "./AnimationEffect"
3
+ import type { Brush } from "./Brush"
4
+ import type { NucleationError } from "./NucleationError"
5
+ import type { Schematic } from "./Schematic"
6
+ import type { Shape } from "./Shape"
7
+ import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
8
+
9
+
10
+
11
+ /**
12
+ * A schematic wrapper that records construction calls as animation targets.
13
+ */
14
+ export class BuildAnimation {
15
+ /** @internal */
16
+ get ffiValue(): pointer;
17
+ /** @internal */
18
+ constructor();
19
+
20
+
21
+ static create(name: string): BuildAnimation;
22
+
23
+ setDefaultEffect(effect: AnimationEffect): void;
24
+
25
+ /**
26
+ * Apply an effect to exactly the next recorded operation or explicit group.
27
+ * The returned borrowed builder enables fluent calls in every generated binding.
28
+ */
29
+ withEffect(effect: AnimationEffect): BuildAnimation;
30
+
31
+ setStepMs(stepMs: number): void;
32
+
33
+ setStaggerTotalMs(totalMs: number): void;
34
+
35
+ clearStagger(): void;
36
+
37
+ /**
38
+ * Shift every construction group's start time. Negative offsets let a
39
+ * repeating staggered effect cross the beginning of a loop capture.
40
+ */
41
+ setStaggerOffsetMs(offsetMs: number): void;
42
+
43
+ /**
44
+ * Capture exactly one loop period, excluding the duplicate endpoint.
45
+ * The rounded frame count evenly partitions the complete period.
46
+ */
47
+ setLoopPeriodMs(periodMs: number): void;
48
+
49
+ clearLoopPeriod(): void;
50
+
51
+ beginGroup(): void;
52
+
53
+ beginKeyedGroup(key: number): void;
54
+
55
+ endGroup(): number;
56
+
57
+ setBlock(x: number, y: number, z: number, block: string): number;
58
+
59
+ createRegion(name: string, minX: number, minY: number, minZ: number, maxX: number, maxY: number, maxZ: number): void;
60
+
61
+ setBlockInRegion(region: string, x: number, y: number, z: number, block: string): number;
62
+
63
+ translate(x: number, y: number, z: number, durationMs: number): void;
64
+
65
+ translateRegion(region: string, x: number, y: number, z: number, durationMs: number): void;
66
+
67
+ translateAll(x: number, y: number, z: number, durationMs: number): void;
68
+
69
+ rotateX(degrees: number, durationMs: number): void;
70
+
71
+ rotateY(degrees: number, durationMs: number): void;
72
+
73
+ rotateZ(degrees: number, durationMs: number): void;
74
+
75
+ rotateRegionX(region: string, degrees: number, durationMs: number): void;
76
+
77
+ rotateRegionY(region: string, degrees: number, durationMs: number): void;
78
+
79
+ rotateRegionZ(region: string, degrees: number, durationMs: number): void;
80
+
81
+ rotateAllX(degrees: number, durationMs: number): void;
82
+
83
+ rotateAllY(degrees: number, durationMs: number): void;
84
+
85
+ rotateAllZ(degrees: number, durationMs: number): void;
86
+
87
+ flipX(durationMs: number): void;
88
+
89
+ flipY(durationMs: number): void;
90
+
91
+ flipZ(durationMs: number): void;
92
+
93
+ flipRegionX(region: string, durationMs: number): void;
94
+
95
+ flipRegionY(region: string, durationMs: number): void;
96
+
97
+ flipRegionZ(region: string, durationMs: number): void;
98
+
99
+ flipAllX(durationMs: number): void;
100
+
101
+ flipAllY(durationMs: number): void;
102
+
103
+ flipAllZ(durationMs: number): void;
104
+
105
+ stampRegion(source: Schematic, region: string, x: number, y: number, z: number, exclusions: string, durationMs: number): void;
106
+
107
+ stampBox(source: Schematic, minX: number, minY: number, minZ: number, maxX: number, maxY: number, maxZ: number, x: number, y: number, z: number, exclusions: string, durationMs: number): void;
108
+
109
+ setOperationGizmos(enabled: boolean): void;
110
+
111
+ operationsJson(): string;
112
+
113
+ frameJson(timeMs: number): string;
114
+
115
+ /**
116
+ * Fill a parametric shape and record its voxels as ordered groups in
117
+ * the same transactional construction operation.
118
+ */
119
+ fillAlongParameter(shape: Shape, brush: Brush, groupCount: number): number;
120
+
121
+ addArmorStand(x: number, y: number, z: number, yaw: number, armorMaterial: string): number;
122
+
123
+ animateCamera(effect: AnimationEffect, offsetMs: number): void;
124
+
125
+ frameCount(fps: number, holdMs: number): number;
126
+
127
+ groupCount(): number;
128
+
129
+ durationMs(): number;
130
+ }