@nmmty/lazycanvas 0.6.5 → 1.0.0-dev.4
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/ReadMe.md +1 -1
- package/biome.json +41 -0
- package/dist/core/Interpolation.d.ts +30 -0
- package/dist/core/Interpolation.js +200 -0
- package/dist/core/Scene.d.ts +96 -0
- package/dist/core/Scene.js +172 -0
- package/dist/core/Signal.d.ts +133 -0
- package/dist/core/Signal.js +255 -0
- package/dist/core/SignalUtils.d.ts +133 -0
- package/dist/core/SignalUtils.js +333 -0
- package/dist/core/ThreadScheduler.d.ts +38 -0
- package/dist/core/ThreadScheduler.js +74 -0
- package/dist/helpers/Filters.js +1 -1
- package/dist/helpers/FontsList.js +18 -18
- package/dist/helpers/Utlis.d.ts +3 -3
- package/dist/helpers/Utlis.js +15 -18
- package/dist/helpers/index.d.ts +3 -3
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/jsx-runtime.d.ts +17 -0
- package/dist/jsx-runtime.js +111 -0
- package/dist/structures/LazyCanvas.d.ts +3 -45
- package/dist/structures/LazyCanvas.js +11 -74
- package/dist/structures/components/BaseLayer.d.ts +34 -12
- package/dist/structures/components/BaseLayer.js +68 -35
- package/dist/structures/components/BezierLayer.d.ts +16 -37
- package/dist/structures/components/BezierLayer.js +83 -46
- package/dist/structures/components/{Group.d.ts → Div.d.ts} +22 -16
- package/dist/structures/components/{Group.js → Div.js} +38 -39
- package/dist/structures/components/ImageLayer.d.ts +1 -1
- package/dist/structures/components/ImageLayer.js +27 -26
- package/dist/structures/components/LineLayer.d.ts +11 -37
- package/dist/structures/components/LineLayer.js +42 -42
- package/dist/structures/components/MorphLayer.d.ts +3 -32
- package/dist/structures/components/MorphLayer.js +35 -47
- package/dist/structures/components/Path2DLayer.d.ts +4 -32
- package/dist/structures/components/Path2DLayer.js +28 -33
- package/dist/structures/components/PolygonLayer.d.ts +2 -31
- package/dist/structures/components/PolygonLayer.js +35 -38
- package/dist/structures/components/QuadraticLayer.d.ts +16 -33
- package/dist/structures/components/QuadraticLayer.js +80 -42
- package/dist/structures/components/TextLayer.d.ts +4 -33
- package/dist/structures/components/TextLayer.js +60 -62
- package/dist/structures/components/index.d.ts +10 -11
- package/dist/structures/components/index.js +1 -2
- package/dist/structures/helpers/Exporter.d.ts +13 -4
- package/dist/structures/helpers/Exporter.js +80 -43
- package/dist/structures/helpers/Font.js +1 -17
- package/dist/structures/helpers/Gradient.js +32 -45
- package/dist/structures/helpers/Link.js +2 -14
- package/dist/structures/helpers/Pattern.js +9 -17
- package/dist/structures/helpers/index.d.ts +7 -7
- package/dist/structures/helpers/readers/JSONReader.d.ts +4 -4
- package/dist/structures/helpers/readers/JSONReader.js +34 -42
- package/dist/structures/helpers/readers/YAMLReader.js +7 -7
- package/dist/structures/managers/FontsManager.js +9 -18
- package/dist/structures/managers/LayersManager.d.ts +18 -28
- package/dist/structures/managers/LayersManager.js +14 -36
- package/dist/structures/managers/RenderManager.d.ts +1 -15
- package/dist/structures/managers/RenderManager.js +17 -110
- package/dist/structures/managers/index.d.ts +3 -5
- package/dist/structures/managers/index.js +0 -2
- package/dist/types/enum.d.ts +1 -2
- package/dist/types/enum.js +1 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types.d.ts +232 -107
- package/dist/utils/APNGEncoder.d.ts +67 -0
- package/dist/utils/APNGEncoder.js +205 -0
- package/dist/utils/DrawUtils.d.ts +9 -0
- package/dist/utils/DrawUtils.js +42 -0
- package/dist/utils/LazyUtil.js +1 -2
- package/dist/utils/utils.d.ts +4 -7
- package/dist/utils/utils.js +136 -77
- package/package.json +60 -59
- package/dist/structures/components/ClearLayer.d.ts +0 -147
- package/dist/structures/components/ClearLayer.js +0 -158
- package/dist/structures/managers/AnimationManager.d.ts +0 -120
- package/dist/structures/managers/AnimationManager.js +0 -99
- package/dist/structures/managers/PluginManager.d.ts +0 -230
- package/dist/structures/managers/PluginManager.js +0 -182
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Timeline = void 0;
|
|
4
|
+
exports.all = all;
|
|
5
|
+
exports.chain = chain;
|
|
6
|
+
exports.loop = loop;
|
|
7
|
+
exports.loopFor = loopFor;
|
|
8
|
+
exports.waitFor = waitFor;
|
|
9
|
+
exports.delay = delay;
|
|
10
|
+
exports.any = any;
|
|
11
|
+
exports.conditional = conditional;
|
|
12
|
+
exports.repeatWhile = repeatWhile;
|
|
13
|
+
exports.every = every;
|
|
14
|
+
exports.spring = spring;
|
|
15
|
+
exports.sequence = sequence;
|
|
16
|
+
exports.yoyo = yoyo;
|
|
17
|
+
exports.timeline = timeline;
|
|
18
|
+
exports.calculateDuration = calculateDuration;
|
|
19
|
+
exports.calculateParallelDuration = calculateParallelDuration;
|
|
20
|
+
exports.calculateSequentialDuration = calculateSequentialDuration;
|
|
21
|
+
/**
|
|
22
|
+
* Storage for animation duration metadata
|
|
23
|
+
*/
|
|
24
|
+
const animationDurations = new WeakMap();
|
|
25
|
+
/**
|
|
26
|
+
* Run multiple animations in parallel
|
|
27
|
+
* @param generators - Array of animation generators
|
|
28
|
+
*/
|
|
29
|
+
function* all(...generators) {
|
|
30
|
+
const active = [...generators];
|
|
31
|
+
// Initialize all generators before starting
|
|
32
|
+
for (const gen of active) {
|
|
33
|
+
gen.next(); // Prime the generator
|
|
34
|
+
}
|
|
35
|
+
while (active.length > 0) {
|
|
36
|
+
const delta = yield;
|
|
37
|
+
for (let i = active.length - 1; i >= 0; i--) {
|
|
38
|
+
const result = active[i].next(delta);
|
|
39
|
+
if (result.done) {
|
|
40
|
+
active.splice(i, 1);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Run animations in sequence
|
|
47
|
+
* @param generators - Array of animation generators
|
|
48
|
+
*/
|
|
49
|
+
function* chain(...generators) {
|
|
50
|
+
for (const generator of generators) {
|
|
51
|
+
yield* generator;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Run animation in a loop
|
|
56
|
+
* @param generator - Animation generator factory
|
|
57
|
+
* @param times - Number of iterations (Infinity for endless)
|
|
58
|
+
*/
|
|
59
|
+
function* loop(generator, times = Infinity) {
|
|
60
|
+
let count = 0;
|
|
61
|
+
while (count < times) {
|
|
62
|
+
yield* generator();
|
|
63
|
+
count++;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Run animation for a specific duration
|
|
68
|
+
* @param generator - Animation generator factory
|
|
69
|
+
* @param duration - Total duration in seconds
|
|
70
|
+
*/
|
|
71
|
+
function* loopFor(generator, duration) {
|
|
72
|
+
let elapsed = 0;
|
|
73
|
+
while (elapsed < duration) {
|
|
74
|
+
const gen = generator();
|
|
75
|
+
let result = gen.next();
|
|
76
|
+
while (!result.done && elapsed < duration) {
|
|
77
|
+
const delta = yield;
|
|
78
|
+
const actualDelta = typeof delta === "number" ? delta : 1 / 60;
|
|
79
|
+
elapsed += actualDelta;
|
|
80
|
+
result = gen.next(delta);
|
|
81
|
+
}
|
|
82
|
+
// If animation finished before duration, restart
|
|
83
|
+
if (result.done && elapsed < duration) {
|
|
84
|
+
// Loop continues
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Wait for a specific duration
|
|
93
|
+
* @param duration - Duration in seconds
|
|
94
|
+
*/
|
|
95
|
+
function* waitFor(duration) {
|
|
96
|
+
let elapsed = 0;
|
|
97
|
+
while (elapsed < duration) {
|
|
98
|
+
const delta = yield;
|
|
99
|
+
const actualDelta = typeof delta === "number" ? delta : 1 / 60;
|
|
100
|
+
elapsed += actualDelta;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Delay an animation by a specific duration
|
|
105
|
+
* @param duration - Delay in seconds
|
|
106
|
+
* @param generator - Animation generator
|
|
107
|
+
*/
|
|
108
|
+
function* delay(duration, generator) {
|
|
109
|
+
yield* waitFor(duration);
|
|
110
|
+
yield* generator;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Run animations until any one completes
|
|
114
|
+
* @param generators - Array of animation generators
|
|
115
|
+
*/
|
|
116
|
+
function* any(...generators) {
|
|
117
|
+
const active = [...generators];
|
|
118
|
+
while (active.length > 0) {
|
|
119
|
+
const delta = yield;
|
|
120
|
+
for (const gen of active) {
|
|
121
|
+
const result = gen.next(delta);
|
|
122
|
+
if (result.done) {
|
|
123
|
+
// Cancel all other generators
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Conditional animation
|
|
131
|
+
* @param condition - Condition function
|
|
132
|
+
* @param trueGen - Generator if condition is true
|
|
133
|
+
* @param falseGen - Generator if condition is false
|
|
134
|
+
*/
|
|
135
|
+
function* conditional(condition, trueGen, falseGen) {
|
|
136
|
+
if (condition()) {
|
|
137
|
+
yield* trueGen;
|
|
138
|
+
}
|
|
139
|
+
else if (falseGen) {
|
|
140
|
+
yield* falseGen;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Repeat animation while condition is true
|
|
145
|
+
* @param condition - Condition function
|
|
146
|
+
* @param generator - Animation generator factory
|
|
147
|
+
*/
|
|
148
|
+
function* repeatWhile(condition, generator) {
|
|
149
|
+
while (condition()) {
|
|
150
|
+
yield* generator();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Run animation at specific intervals
|
|
155
|
+
* @param interval - Interval duration in seconds
|
|
156
|
+
* @param generator - Animation generator factory
|
|
157
|
+
* @param times - Number of times to run (Infinity for endless)
|
|
158
|
+
*/
|
|
159
|
+
function* every(interval, generator, times = Infinity) {
|
|
160
|
+
let count = 0;
|
|
161
|
+
while (count < times) {
|
|
162
|
+
yield* generator();
|
|
163
|
+
yield* waitFor(interval);
|
|
164
|
+
count++;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Spring animation utility
|
|
169
|
+
* @param signal - Signal to animate
|
|
170
|
+
* @param target - Target value
|
|
171
|
+
* @param config - Spring configuration
|
|
172
|
+
*/
|
|
173
|
+
function* spring(signal, target, config = {}) {
|
|
174
|
+
const stiffness = config.stiffness ?? 170;
|
|
175
|
+
const damping = config.damping ?? 26;
|
|
176
|
+
const mass = config.mass ?? 1;
|
|
177
|
+
const precision = config.precision ?? 0.01;
|
|
178
|
+
// Only works for numbers
|
|
179
|
+
if (typeof signal.value() !== "number" || typeof target !== "number") {
|
|
180
|
+
signal.set(target);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
let position = signal.value();
|
|
184
|
+
let velocity = 0;
|
|
185
|
+
const targetNum = target;
|
|
186
|
+
while (Math.abs(position - targetNum) > precision || Math.abs(velocity) > precision) {
|
|
187
|
+
const delta = yield;
|
|
188
|
+
const actualDelta = typeof delta === "number" ? delta : 1 / 60;
|
|
189
|
+
const force = -stiffness * (position - targetNum);
|
|
190
|
+
const dampingForce = -damping * velocity;
|
|
191
|
+
const acceleration = (force + dampingForce) / mass;
|
|
192
|
+
velocity += acceleration * actualDelta;
|
|
193
|
+
position += velocity * actualDelta;
|
|
194
|
+
signal.set(position);
|
|
195
|
+
}
|
|
196
|
+
signal.set(target);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Tween between multiple values in sequence
|
|
200
|
+
* @param signal - Signal to animate
|
|
201
|
+
* @param values - Array of target values
|
|
202
|
+
* @param duration - Duration for each tween
|
|
203
|
+
* @param config - Tween configuration
|
|
204
|
+
*/
|
|
205
|
+
function* sequence(signal, values, duration, config) {
|
|
206
|
+
for (const value of values) {
|
|
207
|
+
yield* signal.to(value, duration, config);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Animate signal back and forth
|
|
212
|
+
* @param signal - Signal to animate
|
|
213
|
+
* @param from - Start value
|
|
214
|
+
* @param to - End value
|
|
215
|
+
* @param duration - Duration for each direction
|
|
216
|
+
* @param config - Tween configuration
|
|
217
|
+
*/
|
|
218
|
+
function* yoyo(signal, from, to, duration, config) {
|
|
219
|
+
signal.set(from);
|
|
220
|
+
yield* signal.to(to, duration, config);
|
|
221
|
+
yield* signal.to(from, duration, config);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Create a timeline builder for complex animations
|
|
225
|
+
*/
|
|
226
|
+
class Timeline {
|
|
227
|
+
constructor() {
|
|
228
|
+
this.generators = [];
|
|
229
|
+
this.currentTime = 0;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Add animation at specific time
|
|
233
|
+
*/
|
|
234
|
+
at(time, generator) {
|
|
235
|
+
this.generators.push({ time, generator });
|
|
236
|
+
return this;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Add animation after previous
|
|
240
|
+
*/
|
|
241
|
+
then(generator) {
|
|
242
|
+
this.generators.push({ time: this.currentTime, generator });
|
|
243
|
+
return this;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Set current time cursor
|
|
247
|
+
*/
|
|
248
|
+
seek(time) {
|
|
249
|
+
this.currentTime = time;
|
|
250
|
+
return this;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Execute timeline
|
|
254
|
+
*/
|
|
255
|
+
*play() {
|
|
256
|
+
// Sort by time
|
|
257
|
+
const sorted = [...this.generators].sort((a, b) => a.time - b.time);
|
|
258
|
+
let time = 0;
|
|
259
|
+
let activeGens = [];
|
|
260
|
+
let nextIndex = 0;
|
|
261
|
+
while (nextIndex < sorted.length || activeGens.length > 0) {
|
|
262
|
+
const delta = yield;
|
|
263
|
+
const actualDelta = typeof delta === "number" ? delta : 1 / 60;
|
|
264
|
+
time += actualDelta;
|
|
265
|
+
// Start new generators that should be active now
|
|
266
|
+
while (nextIndex < sorted.length && sorted[nextIndex].time <= time) {
|
|
267
|
+
activeGens.push(sorted[nextIndex].generator);
|
|
268
|
+
nextIndex++;
|
|
269
|
+
}
|
|
270
|
+
// Update active generators
|
|
271
|
+
for (let i = activeGens.length - 1; i >= 0; i--) {
|
|
272
|
+
const result = activeGens[i].next(delta);
|
|
273
|
+
if (result.done) {
|
|
274
|
+
activeGens.splice(i, 1);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
exports.Timeline = Timeline;
|
|
281
|
+
/**
|
|
282
|
+
* Create a timeline
|
|
283
|
+
*/
|
|
284
|
+
function timeline() {
|
|
285
|
+
return new Timeline();
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Calculate the total duration of an animation by running it with a fixed timestep
|
|
289
|
+
* @param generatorFactory - Function that creates the animation generator
|
|
290
|
+
* @param maxDuration - Maximum duration to simulate (safety limit, default: 3600s = 1 hour)
|
|
291
|
+
* @param timestep - Simulation timestep in seconds (default: 1/60)
|
|
292
|
+
* @returns Total duration in seconds
|
|
293
|
+
*/
|
|
294
|
+
function calculateDuration(generatorFactory, maxDuration = 3600, timestep = 1 / 60) {
|
|
295
|
+
const gen = generatorFactory();
|
|
296
|
+
let totalTime = 0;
|
|
297
|
+
// Initialize generator
|
|
298
|
+
gen.next();
|
|
299
|
+
// Run generator until completion
|
|
300
|
+
let result = gen.next(timestep);
|
|
301
|
+
while (!result.done && totalTime < maxDuration) {
|
|
302
|
+
totalTime += timestep;
|
|
303
|
+
result = gen.next(timestep);
|
|
304
|
+
}
|
|
305
|
+
if (totalTime >= maxDuration) {
|
|
306
|
+
console.warn(`Animation duration calculation reached maximum limit of ${maxDuration}s. Animation may be infinite or very long.`);
|
|
307
|
+
}
|
|
308
|
+
return totalTime;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Calculate duration from multiple animation factories running in parallel
|
|
312
|
+
* Returns the duration of the longest animation
|
|
313
|
+
*/
|
|
314
|
+
function calculateParallelDuration(generatorFactories, maxDuration = 3600, timestep = 1 / 60) {
|
|
315
|
+
const durations = generatorFactories.map((factory) => calculateDuration(factory, maxDuration, timestep));
|
|
316
|
+
return Math.max(...durations);
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Calculate duration from multiple animation factories running in sequence
|
|
320
|
+
* Returns the sum of all animation durations
|
|
321
|
+
*/
|
|
322
|
+
function calculateSequentialDuration(generatorFactories, maxDuration = 3600, timestep = 1 / 60) {
|
|
323
|
+
let totalDuration = 0;
|
|
324
|
+
for (const factory of generatorFactories) {
|
|
325
|
+
const duration = calculateDuration(factory, maxDuration - totalDuration, timestep);
|
|
326
|
+
totalDuration += duration;
|
|
327
|
+
if (totalDuration >= maxDuration) {
|
|
328
|
+
console.warn(`Sequential animation duration calculation reached maximum limit of ${maxDuration}s.`);
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return totalDuration;
|
|
333
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ThreadGenerator } from "./Signal";
|
|
2
|
+
/**
|
|
3
|
+
* Thread scheduler for managing animation generators
|
|
4
|
+
*/
|
|
5
|
+
export declare class ThreadScheduler {
|
|
6
|
+
private threads;
|
|
7
|
+
private currentTime;
|
|
8
|
+
private lastUpdateTime;
|
|
9
|
+
private initialized;
|
|
10
|
+
/**
|
|
11
|
+
* Add a thread to the scheduler
|
|
12
|
+
*/
|
|
13
|
+
add(thread: ThreadGenerator): void;
|
|
14
|
+
/**
|
|
15
|
+
* Remove a thread from the scheduler
|
|
16
|
+
*/
|
|
17
|
+
remove(thread: ThreadGenerator): void;
|
|
18
|
+
/**
|
|
19
|
+
* Update all threads with delta time
|
|
20
|
+
*/
|
|
21
|
+
update(time: number): void;
|
|
22
|
+
/**
|
|
23
|
+
* Clear all threads
|
|
24
|
+
*/
|
|
25
|
+
clear(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Get current time
|
|
28
|
+
*/
|
|
29
|
+
getTime(): number;
|
|
30
|
+
/**
|
|
31
|
+
* Reset time
|
|
32
|
+
*/
|
|
33
|
+
reset(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Check if scheduler has active threads
|
|
36
|
+
*/
|
|
37
|
+
hasActiveThreads(): boolean;
|
|
38
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ThreadScheduler = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Thread scheduler for managing animation generators
|
|
6
|
+
*/
|
|
7
|
+
class ThreadScheduler {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.threads = new Set();
|
|
10
|
+
this.currentTime = 0;
|
|
11
|
+
this.lastUpdateTime = 0;
|
|
12
|
+
this.initialized = false;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Add a thread to the scheduler
|
|
16
|
+
*/
|
|
17
|
+
add(thread) {
|
|
18
|
+
this.threads.add(thread);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Remove a thread from the scheduler
|
|
22
|
+
*/
|
|
23
|
+
remove(thread) {
|
|
24
|
+
this.threads.delete(thread);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Update all threads with delta time
|
|
28
|
+
*/
|
|
29
|
+
update(time) {
|
|
30
|
+
// Calculate delta
|
|
31
|
+
const delta = this.initialized ? time - this.lastUpdateTime : 0;
|
|
32
|
+
this.lastUpdateTime = time;
|
|
33
|
+
this.currentTime = time;
|
|
34
|
+
this.initialized = true;
|
|
35
|
+
const threadsToRemove = [];
|
|
36
|
+
for (const thread of this.threads) {
|
|
37
|
+
const result = thread.next(delta);
|
|
38
|
+
if (result.done) {
|
|
39
|
+
threadsToRemove.push(thread);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// Remove completed threads
|
|
43
|
+
for (const thread of threadsToRemove) {
|
|
44
|
+
this.threads.delete(thread);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Clear all threads
|
|
49
|
+
*/
|
|
50
|
+
clear() {
|
|
51
|
+
this.threads.clear();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get current time
|
|
55
|
+
*/
|
|
56
|
+
getTime() {
|
|
57
|
+
return this.currentTime;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Reset time
|
|
61
|
+
*/
|
|
62
|
+
reset() {
|
|
63
|
+
this.currentTime = 0;
|
|
64
|
+
this.lastUpdateTime = 0;
|
|
65
|
+
this.initialized = false;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Check if scheduler has active threads
|
|
69
|
+
*/
|
|
70
|
+
hasActiveThreads() {
|
|
71
|
+
return this.threads.size > 0;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.ThreadScheduler = ThreadScheduler;
|
package/dist/helpers/Filters.js
CHANGED
|
@@ -9,57 +9,57 @@ const types_1 = require("../types");
|
|
|
9
9
|
*/
|
|
10
10
|
exports.FontsList = {
|
|
11
11
|
Geist_Thin(size) {
|
|
12
|
-
return { family:
|
|
12
|
+
return { family: "Geist", size, weight: types_1.FontWeight.Thin };
|
|
13
13
|
},
|
|
14
14
|
Geist_ExtraLight(size) {
|
|
15
|
-
return { family:
|
|
15
|
+
return { family: "Geist", size, weight: types_1.FontWeight.ExtraLight };
|
|
16
16
|
},
|
|
17
17
|
Geist_Light(size) {
|
|
18
|
-
return { family:
|
|
18
|
+
return { family: "Geist", size, weight: types_1.FontWeight.Light };
|
|
19
19
|
},
|
|
20
20
|
Geist_Regular(size) {
|
|
21
|
-
return { family:
|
|
21
|
+
return { family: "Geist", size, weight: types_1.FontWeight.Regular };
|
|
22
22
|
},
|
|
23
23
|
Geist_Medium(size) {
|
|
24
|
-
return { family:
|
|
24
|
+
return { family: "Geist", size, weight: types_1.FontWeight.Medium };
|
|
25
25
|
},
|
|
26
26
|
Geist_SemiBold(size) {
|
|
27
|
-
return { family:
|
|
27
|
+
return { family: "Geist", size, weight: types_1.FontWeight.SemiBold };
|
|
28
28
|
},
|
|
29
29
|
Geist_Bold(size) {
|
|
30
|
-
return { family:
|
|
30
|
+
return { family: "Geist", size, weight: types_1.FontWeight.Bold };
|
|
31
31
|
},
|
|
32
32
|
Geist_ExtraBold(size) {
|
|
33
|
-
return { family:
|
|
33
|
+
return { family: "Geist", size, weight: types_1.FontWeight.ExtraBold };
|
|
34
34
|
},
|
|
35
35
|
Geist_Black(size) {
|
|
36
|
-
return { family:
|
|
36
|
+
return { family: "Geist", size, weight: types_1.FontWeight.Black };
|
|
37
37
|
},
|
|
38
38
|
GeistMono_Thin(size) {
|
|
39
|
-
return { family:
|
|
39
|
+
return { family: "GeistMono", size, weight: types_1.FontWeight.Thin };
|
|
40
40
|
},
|
|
41
41
|
GeistMono_ExtraLight(size) {
|
|
42
|
-
return { family:
|
|
42
|
+
return { family: "GeistMono", size, weight: types_1.FontWeight.ExtraLight };
|
|
43
43
|
},
|
|
44
44
|
GeistMono_Light(size) {
|
|
45
|
-
return { family:
|
|
45
|
+
return { family: "GeistMono", size, weight: types_1.FontWeight.Light };
|
|
46
46
|
},
|
|
47
47
|
GeistMono_Regular(size) {
|
|
48
|
-
return { family:
|
|
48
|
+
return { family: "GeistMono", size, weight: types_1.FontWeight.Regular };
|
|
49
49
|
},
|
|
50
50
|
GeistMono_Medium(size) {
|
|
51
|
-
return { family:
|
|
51
|
+
return { family: "GeistMono", size, weight: types_1.FontWeight.Medium };
|
|
52
52
|
},
|
|
53
53
|
GeistMono_SemiBold(size) {
|
|
54
|
-
return { family:
|
|
54
|
+
return { family: "GeistMono", size, weight: types_1.FontWeight.SemiBold };
|
|
55
55
|
},
|
|
56
56
|
GeistMono_Bold(size) {
|
|
57
|
-
return { family:
|
|
57
|
+
return { family: "GeistMono", size, weight: types_1.FontWeight.Bold };
|
|
58
58
|
},
|
|
59
59
|
GeistMono_Black(size) {
|
|
60
|
-
return { family:
|
|
60
|
+
return { family: "GeistMono", size, weight: types_1.FontWeight.Black };
|
|
61
61
|
},
|
|
62
62
|
GeistMono_ExtraBlack(size) {
|
|
63
|
-
return { family:
|
|
63
|
+
return { family: "GeistMono", size, weight: types_1.FontWeight.ExtraBlack };
|
|
64
64
|
},
|
|
65
65
|
};
|
package/dist/helpers/Utlis.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Div } from "../structures/components";
|
|
2
2
|
import { ColorType } from "../types";
|
|
3
3
|
declare const Utils: {
|
|
4
4
|
grid(size: {
|
|
5
5
|
x: number;
|
|
6
6
|
y: number;
|
|
7
|
-
}, opts?: gridOptions):
|
|
7
|
+
}, opts?: gridOptions): Div;
|
|
8
8
|
box(start: {
|
|
9
9
|
x: number;
|
|
10
10
|
y: number;
|
|
11
11
|
}, end: {
|
|
12
12
|
x: number;
|
|
13
13
|
y: number;
|
|
14
|
-
}, opts?: options):
|
|
14
|
+
}, opts?: options): Div;
|
|
15
15
|
};
|
|
16
16
|
interface options {
|
|
17
17
|
color?: ColorType;
|
package/dist/helpers/Utlis.js
CHANGED
|
@@ -22,57 +22,54 @@ const Utils = {
|
|
|
22
22
|
if (opts.endY === undefined)
|
|
23
23
|
opts.endY = size.y;
|
|
24
24
|
if (opts.color === undefined)
|
|
25
|
-
opts.color =
|
|
25
|
+
opts.color = "rgba(0, 0, 0, 0.5)";
|
|
26
26
|
if (opts.lineWidth === undefined)
|
|
27
27
|
opts.lineWidth = 1;
|
|
28
28
|
const options = { ...opts };
|
|
29
|
-
return new components_1.
|
|
29
|
+
return new components_1.Div()
|
|
30
30
|
.setID(`grid-${options.cellWith}-${options.cellHeight}-${options.startX}-${options.startY}-${options.endX}-${options.endY}`)
|
|
31
31
|
.add(...Array.from({ length: Math.ceil((options.endX - options.startX) / options.cellWith) }, (_, i) => {
|
|
32
32
|
const x = options.startX + i * options.cellWith;
|
|
33
33
|
return new components_1.LineLayer()
|
|
34
|
-
.setPosition(x, options.startY)
|
|
35
|
-
.setEndPosition(x, options.endY)
|
|
34
|
+
.setPosition(x, options.startY, x, options.endY)
|
|
36
35
|
.setColor(options.color)
|
|
37
36
|
.setStroke(options.lineWidth);
|
|
38
37
|
}), ...Array.from({ length: Math.ceil((options.endY - options.startY) / options.cellHeight) }, (_, i) => {
|
|
39
38
|
const y = options.startY + i * options.cellHeight;
|
|
40
39
|
return new components_1.LineLayer()
|
|
41
|
-
.setPosition(options.startX, y)
|
|
42
|
-
.setEndPosition(options.endX, y)
|
|
40
|
+
.setPosition(options.startX, y, options.endX, y)
|
|
43
41
|
.setColor(options.color)
|
|
44
42
|
.setStroke(options.lineWidth);
|
|
45
43
|
}));
|
|
46
44
|
},
|
|
47
45
|
box(start, end, opts) {
|
|
48
|
-
if (start.x === undefined ||
|
|
46
|
+
if (start.x === undefined ||
|
|
47
|
+
start.y === undefined ||
|
|
48
|
+
end.x === undefined ||
|
|
49
|
+
end.y === undefined) {
|
|
49
50
|
throw new Error("Start and end must have x and y properties");
|
|
50
51
|
}
|
|
51
52
|
if (opts === undefined)
|
|
52
53
|
opts = {};
|
|
53
54
|
if (opts.color === undefined)
|
|
54
|
-
opts.color =
|
|
55
|
+
opts.color = "rgba(0, 0, 0, 0.5)";
|
|
55
56
|
if (opts.lineWidth === undefined)
|
|
56
57
|
opts.lineWidth = 1;
|
|
57
|
-
return new components_1.
|
|
58
|
+
return new components_1.Div()
|
|
58
59
|
.setID(`box-${start.x}-${start.y}-${end.x}-${end.y}`)
|
|
59
60
|
.add(new components_1.LineLayer()
|
|
60
|
-
.setPosition(start.x, start.y)
|
|
61
|
-
.setEndPosition(end.x, start.y)
|
|
61
|
+
.setPosition(start.x, start.y, end.x, start.y)
|
|
62
62
|
.setColor(opts.color)
|
|
63
63
|
.setStroke(opts.lineWidth), new components_1.LineLayer()
|
|
64
|
-
.setPosition(end.x, start.y)
|
|
65
|
-
.setEndPosition(end.x, end.y)
|
|
64
|
+
.setPosition(end.x, start.y, end.x, end.y)
|
|
66
65
|
.setColor(opts.color)
|
|
67
66
|
.setStroke(opts.lineWidth), new components_1.LineLayer()
|
|
68
|
-
.setPosition(end.x, end.y)
|
|
69
|
-
.setEndPosition(start.x, end.y)
|
|
67
|
+
.setPosition(end.x, end.y, start.x, end.y)
|
|
70
68
|
.setColor(opts.color)
|
|
71
69
|
.setStroke(opts.lineWidth), new components_1.LineLayer()
|
|
72
|
-
.setPosition(start.x, end.y)
|
|
73
|
-
.setEndPosition(start.x, start.y)
|
|
70
|
+
.setPosition(start.x, end.y, start.x, start.y)
|
|
74
71
|
.setColor(opts.color)
|
|
75
72
|
.setStroke(opts.lineWidth));
|
|
76
|
-
}
|
|
73
|
+
},
|
|
77
74
|
};
|
|
78
75
|
exports.Utils = Utils;
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from "./Utlis";
|
|
2
|
+
export * from "./Filters";
|
|
3
|
+
export * from "./FontsList";
|
package/dist/index.d.ts
CHANGED
|
@@ -4,3 +4,13 @@ export * from "./structures/components";
|
|
|
4
4
|
export * from "./types";
|
|
5
5
|
export * from "./structures/helpers";
|
|
6
6
|
export * from "./helpers";
|
|
7
|
+
export * from "./core/Scene";
|
|
8
|
+
export * from "./core/Signal";
|
|
9
|
+
export * from "./core/SignalUtils";
|
|
10
|
+
export * from "./core/ThreadScheduler";
|
|
11
|
+
export * from "./core/Interpolation";
|
|
12
|
+
export * from "./utils/APNGEncoder";
|
|
13
|
+
export * from "./utils/DrawUtils";
|
|
14
|
+
export * from "./utils/LazyUtil";
|
|
15
|
+
export * from "./utils/utils";
|
|
16
|
+
export * from "./jsx-runtime";
|
package/dist/index.js
CHANGED
|
@@ -20,3 +20,13 @@ __exportStar(require("./structures/components"), exports);
|
|
|
20
20
|
__exportStar(require("./types"), exports);
|
|
21
21
|
__exportStar(require("./structures/helpers"), exports);
|
|
22
22
|
__exportStar(require("./helpers"), exports);
|
|
23
|
+
__exportStar(require("./core/Scene"), exports);
|
|
24
|
+
__exportStar(require("./core/Signal"), exports);
|
|
25
|
+
__exportStar(require("./core/SignalUtils"), exports);
|
|
26
|
+
__exportStar(require("./core/ThreadScheduler"), exports);
|
|
27
|
+
__exportStar(require("./core/Interpolation"), exports);
|
|
28
|
+
__exportStar(require("./utils/APNGEncoder"), exports);
|
|
29
|
+
__exportStar(require("./utils/DrawUtils"), exports);
|
|
30
|
+
__exportStar(require("./utils/LazyUtil"), exports);
|
|
31
|
+
__exportStar(require("./utils/utils"), exports);
|
|
32
|
+
__exportStar(require("./jsx-runtime"), exports);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSX createElement factory for LazyCanvas components
|
|
3
|
+
* Compatible with "jsx": "react" in tsconfig.json
|
|
4
|
+
*/
|
|
5
|
+
export declare function createElement(type: any, props: any | null, ...children: any[]): any;
|
|
6
|
+
/**
|
|
7
|
+
* Fragment component for grouping elements without creating a Group layer
|
|
8
|
+
*/
|
|
9
|
+
export declare function Fragment(props: {
|
|
10
|
+
children: any[];
|
|
11
|
+
}): any[];
|
|
12
|
+
/**
|
|
13
|
+
* Export for compatibility with some JSX runtimes
|
|
14
|
+
*/
|
|
15
|
+
export declare const jsx: typeof createElement;
|
|
16
|
+
export declare const jsxs: typeof createElement;
|
|
17
|
+
export declare const jsxDEV: typeof createElement;
|