@drincs/pixi-vn 1.9.2 → 1.9.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.
Files changed (59) hide show
  1. package/README.md +1 -1
  2. package/dist/{ContainerMemory-BpDgacyr.d.cts → ContainerMemory-DNqSVzLY.d.cts} +12 -116
  3. package/dist/{ContainerMemory-BpDgacyr.d.ts → ContainerMemory-DNqSVzLY.d.ts} +12 -116
  4. package/dist/canvas.cjs +2 -2
  5. package/dist/canvas.d.cts +1279 -551
  6. package/dist/canvas.d.ts +1279 -551
  7. package/dist/canvas.mjs +2 -2
  8. package/dist/characters.cjs +1 -1
  9. package/dist/characters.mjs +1 -1
  10. package/dist/{chunk-6GLWL3NH.mjs → chunk-5MVDNAT4.mjs} +1 -1
  11. package/dist/chunk-6OABTG5R.mjs +1 -0
  12. package/dist/chunk-AW5XWF24.mjs +1 -0
  13. package/dist/chunk-LXIKP2K5.mjs +1 -0
  14. package/dist/chunk-S7HZUIEI.mjs +1 -0
  15. package/dist/core.cjs +1 -1
  16. package/dist/core.d.cts +61 -5
  17. package/dist/core.d.ts +61 -5
  18. package/dist/core.mjs +1 -1
  19. package/dist/filters.cjs +1 -0
  20. package/dist/filters.d.cts +182 -0
  21. package/dist/filters.d.ts +182 -0
  22. package/dist/filters.mjs +1 -0
  23. package/dist/history.cjs +1 -1
  24. package/dist/history.d.cts +2 -2
  25. package/dist/history.d.ts +2 -2
  26. package/dist/history.mjs +1 -1
  27. package/dist/index.cjs +2 -2
  28. package/dist/index.d.cts +43 -3
  29. package/dist/index.d.ts +43 -3
  30. package/dist/index.mjs +2 -2
  31. package/dist/motion.cjs +1 -1
  32. package/dist/motion.d.cts +30 -8
  33. package/dist/motion.d.ts +30 -8
  34. package/dist/motion.mjs +1 -1
  35. package/dist/narration.cjs +1 -1
  36. package/dist/narration.d.cts +2 -1
  37. package/dist/narration.d.ts +2 -1
  38. package/dist/narration.mjs +1 -1
  39. package/dist/pixi/browser.js +170 -169
  40. package/dist/sound.mjs +1 -1
  41. package/dist/storage.cjs +1 -1
  42. package/dist/storage.d.cts +1 -1
  43. package/dist/storage.d.ts +1 -1
  44. package/dist/storage.mjs +1 -1
  45. package/dist/tickers.cjs +1 -0
  46. package/dist/tickers.d.cts +555 -0
  47. package/dist/tickers.d.ts +555 -0
  48. package/dist/tickers.mjs +1 -0
  49. package/dist/vite.cjs +6 -4
  50. package/dist/vite.d.cts +64 -0
  51. package/dist/vite.d.ts +64 -0
  52. package/dist/vite.mjs +6 -4
  53. package/dist/worker.cjs +1 -0
  54. package/dist/worker.d.cts +153 -0
  55. package/dist/worker.d.ts +153 -0
  56. package/dist/worker.mjs +1 -0
  57. package/package.json +28 -1
  58. package/dist/chunk-HQQ5WH6C.mjs +0 -1
  59. package/dist/chunk-I7DOUH5V.mjs +0 -1
@@ -0,0 +1,555 @@
1
+ import * as _drincs_pixi_vn_pixi_js from '@drincs/pixi-vn/pixi.js';
2
+ import { UPDATE_PRIORITY, Ticker as Ticker$1 } from '@drincs/pixi-vn/pixi.js';
3
+
4
+ interface TickerArgs {
5
+ }
6
+
7
+ interface Ticker<TArgs extends TickerArgs> {
8
+ /**
9
+ * Arguments to pass to the ticker
10
+ */
11
+ args: TArgs;
12
+ /**
13
+ * Duration in seconds to run the ticker
14
+ */
15
+ duration?: number;
16
+ /**
17
+ * Priority of the ticker
18
+ */
19
+ priority?: UPDATE_PRIORITY;
20
+ /**
21
+ * Get the alias of the ticker class. This variable is used in the system to get the ticker class by id, {@link RegisteredTickers.getInstance}
22
+ */
23
+ readonly alias: string;
24
+ /**
25
+ * The id of the ticker. Must be unique for each ticker instance.
26
+ */
27
+ readonly id: string;
28
+ /**
29
+ * The aliases of the canvas elements that are connected to this ticker
30
+ */
31
+ canvasElementAliases: string[];
32
+ /**
33
+ * Completes the animation and applies the final state.
34
+ */
35
+ complete: (options?: {
36
+ ignoreTickerSteps?: boolean;
37
+ }) => Promise<void> | void;
38
+ /**
39
+ * Stops the animation at its current state, and prevents it from resuming when the animation is played again.
40
+ */
41
+ stop: () => void;
42
+ /**
43
+ * Starts the ticker. This will start the ticker and begin the animation.
44
+ */
45
+ start: () => void;
46
+ /**
47
+ * Pauses the animation.
48
+ */
49
+ pause: () => void;
50
+ /**
51
+ * Plays the animation.
52
+ */
53
+ play: () => void;
54
+ /**
55
+ * Checks if the ticker is paused.
56
+ * @returns true if the ticker is paused, false otherwise.
57
+ */
58
+ readonly paused: boolean;
59
+ }
60
+
61
+ type TickerValue = Ticker$1;
62
+
63
+ /**
64
+ * A class is used to create a ticker element to add into a Pixi Application.
65
+ * You can use `tickers.add()` (from `@drincs/pixi-vn`) to add this element into the application.
66
+ * This class should be extended and the fn method should be overridden.
67
+ * You must use the {@link tickerDecorator} to register the ticker in the game.
68
+ * In Ren'Py is a transform.
69
+ * @template TArgs The type of the arguments that you want to pass to the ticker.
70
+ * @example
71
+ * ```ts
72
+ * \@tickerDecorator() // this is equivalent to tickerDecorator("RotateTicker")
73
+ * export class RotateTicker extends TickerBase<{ speed?: number }> {
74
+ * override fn(
75
+ * t: TickerValue, // the ticker that is calling this method
76
+ * args: { // the arguments that you passed when you added the ticker
77
+ * speed?: number,
78
+ * },
79
+ * aliases: string[], // the aliases of the canvas elements that are connected to this ticker
80
+ * tickerId: string, // the id of the ticker. You can use this to get the ticker from tickers.currentTickers
81
+ * ): void {
82
+ * let speed = args.speed === undefined ? 0.1 : args.speed
83
+ * aliases.forEach((alias) => {
84
+ * let element = canvas.find(alias)
85
+ * if (element && element instanceof Container) {
86
+ * if (clockwise)
87
+ * element.rotation += speed * t.deltaTime
88
+ * else
89
+ * element.rotation -= speed * t.deltaTime
90
+ * }
91
+ * })
92
+ * }
93
+ * }
94
+ * ```
95
+ */
96
+ declare abstract class TickerBase<TArgs extends TickerArgs> implements Ticker<TArgs> {
97
+ /**
98
+ * @param args The arguments that you want to pass to the ticker.
99
+ * @param options The options of the ticker.
100
+ */
101
+ constructor(args: TArgs, options?: {
102
+ /**
103
+ * The duration of the ticker in seconds. If is undefined, the step will end only when the animation is finished (if the animation doesn't have a goal to reach then it won't finish). @default undefined
104
+ */
105
+ duration?: number;
106
+ /**
107
+ * The priority of the ticker. @default UPDATE_PRIORITY.NORMAL
108
+ */
109
+ priority?: UPDATE_PRIORITY;
110
+ /**
111
+ * The id of the ticker. This param is used by the system when will ber restoring the tickers from a save. If not provided, a random id will be generated. @default undefined
112
+ */
113
+ id?: string;
114
+ /**
115
+ * The aliases of the canvas elements that are connected to this ticker. This is used by the system to know which canvas elements are connected to this ticker, and to pass them to the fn method. @default []
116
+ */
117
+ canvasElementAliases?: string[];
118
+ });
119
+ readonly alias: string;
120
+ readonly id: string;
121
+ args: TArgs;
122
+ duration?: number;
123
+ priority?: UPDATE_PRIORITY;
124
+ protected ticker: _drincs_pixi_vn_pixi_js.Ticker;
125
+ canvasElementAliases: string[];
126
+ private generateTickerId;
127
+ /**
128
+ * The method that will be called every frame.
129
+ * This method should be overridden and you can use `canvas.find()` (from `@drincs/pixi-vn/canvas`)
130
+ * to get the canvas element of the canvas, and edit them.
131
+ * @param _ticker The ticker that is calling this method
132
+ * @param _args The arguments that you passed when you added the ticker
133
+ * @param _alias The alias of the canvas elements that are connected to this ticker
134
+ * @param _tickerId The id of the ticker. You can use this to get the ticker from `tickers.currentTickers`
135
+ */
136
+ abstract fn(_ticker: TickerValue, _args: TArgs, _alias: string | string[], _tickerId: string): void;
137
+ protected fnValue?: () => void;
138
+ complete(_options?: {
139
+ ignoreTickerSteps?: boolean;
140
+ }): void;
141
+ stop(): void;
142
+ start(): void;
143
+ pause(): void;
144
+ play(): void;
145
+ get paused(): boolean;
146
+ }
147
+
148
+ /**
149
+ * Is a decorator that register a ticker in the game.
150
+ * Is a required decorator for use the ticker in the game.
151
+ * Thanks to this decoration the game has the possibility of updating the tickers to the latest modification and saving the game.
152
+ * @param name is th identifier of the label, by default is the name of the class
153
+ * @returns
154
+ */
155
+ declare function tickerDecorator(name?: string): (target: {
156
+ new (args: any, options?: {
157
+ duration?: number;
158
+ priority?: UPDATE_PRIORITY;
159
+ id?: string;
160
+ canvasElementAliases?: string[];
161
+ }): Ticker<any>;
162
+ }) => void;
163
+ declare namespace RegisteredTickers {
164
+ /**
165
+ * Register a ticker in the game.
166
+ * @param target The class of the ticker.
167
+ * @param name Name of the ticker, by default it will use the class name. If the name is already registered, it will show a warning
168
+ */
169
+ function add(target: {
170
+ new (args: any, options?: {
171
+ duration?: number;
172
+ priority?: UPDATE_PRIORITY;
173
+ id?: string;
174
+ canvasElementAliases?: string[];
175
+ }): Ticker<any>;
176
+ }, name?: string): void;
177
+ /**
178
+ * Get a ticker by the id.
179
+ * @param canvasId The id of the ticker.
180
+ * @returns The ticker type.
181
+ */
182
+ function get<T = Ticker<any>>(tickerId: string): T | undefined;
183
+ /**
184
+ * Get a ticker instance by the id.
185
+ * @param tickerId The id of the ticker.
186
+ * @param args The arguments that you want to pass to the ticker.
187
+ * @param duration The duration of the ticker. If is undefined, the ticker will be called every frame.
188
+ * @param priority The priority of the ticker. If is undefined, the priority will be UPDATE_PRIORITY.NORMAL.
189
+ * @returns The instance of the ticker
190
+ */
191
+ function getInstance<TArgs extends TickerArgs>(tickerId: string, args: TArgs, options?: {
192
+ duration?: number;
193
+ priority?: UPDATE_PRIORITY;
194
+ id?: string;
195
+ canvasElementAliases?: string[];
196
+ }): Ticker<TArgs> | undefined;
197
+ /**
198
+ * Get a list of all tickers registered.
199
+ * @returns An array of tickers.
200
+ */
201
+ function values(): {
202
+ new (args: any, options?: {
203
+ duration?: number;
204
+ priority?: UPDATE_PRIORITY;
205
+ id?: string;
206
+ canvasElementAliases?: string[];
207
+ }): Ticker<any>;
208
+ }[];
209
+ /**
210
+ * Check if a ticker is registered.
211
+ * @param id The id of the ticker.
212
+ * @returns True if the ticker is registered, false otherwise.
213
+ */
214
+ function has(id: string): boolean;
215
+ /**
216
+ * Get a list of all ticker ids registered.
217
+ * @returns An array of label ids.
218
+ */
219
+ function keys(): string[];
220
+ }
221
+
222
+ /**
223
+ * TickerHistory is a class that contains the name of a class and the arguments that were used to create it.
224
+ */
225
+ interface TickerInfo<TArgs extends TickerArgs> {
226
+ /**
227
+ * If this ticker was created by steps
228
+ */
229
+ createdByTicketSteps?: {
230
+ canvasElementAlias: string;
231
+ id: string;
232
+ };
233
+ ticker: Ticker<TArgs>;
234
+ }
235
+ interface TickerHistory<TArgs extends TickerArgs> {
236
+ id: string;
237
+ args: TArgs;
238
+ /**
239
+ * The aliases of the canvas elements that are connected to this ticker
240
+ */
241
+ canvasElementAliases: string[];
242
+ priority?: UPDATE_PRIORITY;
243
+ duration?: number;
244
+ paused?: boolean;
245
+ }
246
+
247
+ type TickerProgrationType = TickerProgrationLinear | TickerProgrationExponential;
248
+
249
+ interface TickerProgrationLinear {
250
+ /**
251
+ * The amount of the speed to increase every frame.
252
+ */
253
+ amt: number;
254
+ /**
255
+ * The limit of the effect
256
+ */
257
+ limit?: number;
258
+ type: "linear";
259
+ }
260
+ interface TickerProgrationExponential {
261
+ /**
262
+ * The percentage of the speed to increase every frame. if the percentage is 0.1, the speed will increase by 10% every frame.
263
+ */
264
+ percentage: number;
265
+ /**
266
+ * The limit of the effect
267
+ */
268
+ limit?: number;
269
+ type: "exponential";
270
+ }
271
+
272
+ interface TickersStep<TArgs extends TickerArgs> {
273
+ /**
274
+ * Ticker class name
275
+ */
276
+ ticker: string;
277
+ /**
278
+ * Duration in seconds. If is undefined, the step will end only when the animation is finished.
279
+ */
280
+ duration?: number;
281
+ /**
282
+ * Arguments to pass to the ticker
283
+ */
284
+ args: TArgs;
285
+ /**
286
+ * Priority of the ticker
287
+ */
288
+ priority?: UPDATE_PRIORITY;
289
+ }
290
+ /**
291
+ * The steps of the tickers
292
+ */
293
+ interface TickersSequence {
294
+ /**
295
+ * The step number
296
+ */
297
+ currentStepNumber: number;
298
+ /**
299
+ * The steps of the tickers
300
+ */
301
+ steps: TickersStep<any>[];
302
+ }
303
+
304
+ interface TickersInterface {
305
+ /**
306
+ * Transfer the tickers from an old alias to a new alias.
307
+ * @param oldAlias Old alias
308
+ * @param newAlias New alias
309
+ * @param mode If "move", the old alias will be removed from the ticker. If "duplicate", the old alias will be kept in the ticker.
310
+ */
311
+ transfer(oldAlias: string, newAlias: string, mode?: "move" | "duplicate"): void;
312
+ /**
313
+ * Currently tickers that are running.
314
+ */
315
+ readonly currentTickers: Map<string, TickerInfo<any>>;
316
+ /**
317
+ * The steps of the tickers
318
+ */
319
+ readonly currentTickersSteps: Map<string, Map<string, TickersSequence>>;
320
+ /**
321
+ * Find a ticker by its id.
322
+ * @param tickerId The id of the ticker to be found.
323
+ * @param args The args of the ticker.
324
+ * @returns The ticker if found, undefined otherwise.
325
+ */
326
+ find<TArgs extends TickerArgs>(tickerId: string, args?: TArgs): Ticker<TArgs> | undefined;
327
+ /**
328
+ * Run a ticker. You can run multiple add with the same alias and different tickerClasses.
329
+ * If you run a ticker with the same alias and tickerClass, the old ticker will be removed.
330
+ * If already exists a sequence of tickers with the same alias, it will be removed.
331
+ * @param canvasElementAlias The alias of the canvas element that will use the ticker.
332
+ * @param ticker The ticker class to be run.
333
+ * @returns The id of the ticker that was added.
334
+ * @example
335
+ * ```ts
336
+ * tickers.add("alien", new RotateTicker({ speed: 0.2 }))
337
+ * ```
338
+ */
339
+ add<TArgs extends TickerArgs>(canvasElementAlias: string | string[], ticker: Ticker<TArgs>): string | undefined;
340
+ /**
341
+ * Run a sequence of tickers.
342
+ * @param alias The alias of canvas element that will use the tickers.
343
+ * @param steps The steps of the tickers.
344
+ * @param currentStepNumber The current step number. It is used to continue the sequence of tickers.
345
+ * @returns The id of tickers.
346
+ * @example
347
+ * ```ts
348
+ * tickers.addSequence("alien", [
349
+ * new RotateTicker({ speed: 0.1, clockwise: true }, 2), // runs for 2 seconds
350
+ * new RotateTicker({ speed: 0.2, clockwise: false }, 2),
351
+ * ])
352
+ * ```
353
+ * @deprecated
354
+ */
355
+ addSequence(alias: string, steps: Ticker<any>[], currentStepNumber?: number): string | undefined;
356
+ /**
357
+ * Remove a connection between a canvas element and a ticker.
358
+ * And remove the ticker if there is no canvas element connected to it.
359
+ * @param alias The alias of the canvas element that will use the ticker.
360
+ * @param ticker The ticker class to be removed.
361
+ * @example
362
+ * ```ts
363
+ * tickers.unlinkComponent("alien", RotateTicker)
364
+ * ```
365
+ */
366
+ unlinkComponent(alias: string | string[], ticker?: {
367
+ new (): Ticker<any>;
368
+ } | string): void;
369
+ /**
370
+ * Remove all tickers from the canvas.
371
+ */
372
+ removeAll(): void;
373
+ /**
374
+ * Remove a ticker by the id.
375
+ * @param tickerId The id or an array of ids of the ticker to be removed.
376
+ */
377
+ remove(tickerId: string | string[]): void;
378
+ /**
379
+ * Pause a ticker. If a paused ticker have a time to be removed, it will be removed after the time.
380
+ * @param filters The filters to pause the ticker.
381
+ * @returns The ids of the paused tickers.
382
+ */
383
+ pause(filters: {
384
+ /**
385
+ * The alias of the canvas element that will use the ticker.
386
+ * Will pause all tickers that are connected to this canvas element.
387
+ */
388
+ canvasAlias: string;
389
+ /**
390
+ * Ticker ids excluded from the pause. If not provided, all tickers will be paused.
391
+ */
392
+ tickerIdsExcluded?: string[];
393
+ } | {
394
+ /**
395
+ * The id of the ticker to be paused. If provided, only this ticker will be paused.
396
+ */
397
+ id: string | string[];
398
+ }): string[];
399
+ /**
400
+ * Resume a ticker.
401
+ * @param filters The filters to resume the ticker.
402
+ */
403
+ resume(filters: {
404
+ /**
405
+ * The alias of the canvas element that will use the ticker.
406
+ * Will resume all tickers that are connected to this canvas element.
407
+ */
408
+ canvasAlias: string;
409
+ } | {
410
+ /**
411
+ * The id of the ticker to be resumed. If provided, only this ticker will be resumed.
412
+ */
413
+ id: string | string[];
414
+ }): void;
415
+ /**
416
+ * Check if a ticker is paused.
417
+ * @param alias The alias of the canvas element that will use the ticker.
418
+ * @param tickerId The ticker that will be checked.
419
+ * @returns If the ticker is paused.
420
+ */
421
+ isPaused(alias: string, tickerId?: string): boolean;
422
+ /**
423
+ * Add a ticker that must be completed before the next step.
424
+ * This method is used for example into a transition between scenes.
425
+ * @param step The step that the ticker must be completed before the next step.
426
+ */
427
+ completeOnStepEnd(step: {
428
+ /**
429
+ * The id of the step.
430
+ */
431
+ id: string;
432
+ /**
433
+ * If is a sequence of tickers, the alias of the sequence of tickers.
434
+ */
435
+ alias?: string;
436
+ }): void;
437
+ /**
438
+ * This method force the completion of the tickers that are running.
439
+ * This funcions is called in the next step.
440
+ * @param id The id of the ticker. If the alias provided, the id is the id of the sequence of tickers.
441
+ * @param alias The alias of the sequence of tickers.
442
+ */
443
+ forceCompletion(id: string, alias?: string): Promise<void>;
444
+ onComplete(tickerId: string, options: {
445
+ aliasToRemoveAfter: string[];
446
+ tickerAliasToResume: string[];
447
+ tickerIdToResume: string[];
448
+ ignoreTickerSteps?: boolean;
449
+ stopTicker?: boolean;
450
+ }): void;
451
+ }
452
+
453
+ interface TickerTimeoutHistory {
454
+ aliases: string[];
455
+ ticker: string;
456
+ canBeDeletedBeforeEnd: boolean;
457
+ }
458
+
459
+ type CommonTickerProps = {
460
+ /**
461
+ * An array of strings containing the aliases of the canvas components to remove after the animation completes.
462
+ * @default []
463
+ */
464
+ aliasToRemoveAfter?: string[] | string;
465
+ /**
466
+ * If true, the effect only starts if the canvas element have a texture
467
+ * @default false
468
+ */
469
+ startOnlyIfHaveTexture?: boolean;
470
+ /**
471
+ * If you want to resume tickers that were previously paused, provide the aliases of the canvas components whose tickers should be resumed.
472
+ * @default []
473
+ */
474
+ tickerAliasToResume?: string[] | string;
475
+ /**
476
+ * A string containing the ticker ID to resume after the animation completes.
477
+ * @default []
478
+ */
479
+ tickerIdToResume?: string[] | string;
480
+ /**
481
+ * A boolean indicating whether the animation must complete before the next `step` of the game. If `true`, the game will force the animation to finish before proceeding.
482
+ * When true, calling `narration.continue()` forces the current content to complete before advancing to the next narrative step.
483
+ * @default false
484
+ */
485
+ completeOnContinue?: boolean;
486
+ };
487
+
488
+ /**
489
+ * Static, module-scoped ticker bookkeeping - moved out of `CanvasManagerStatic` (formerly
490
+ * `CanvasManagerStatic`'s "Edit Tickers Methods" section) so the `tickers` module can own its own
491
+ * state without importing `@drincs/pixi-vn/canvas`.
492
+ */
493
+ declare namespace TickersManagerStatic {
494
+ function currentTickersWithoutCreatedBySteps(): {
495
+ [k: string]: TickerHistory<any>;
496
+ };
497
+ const _currentTickers: Map<string, TickerInfo<any>>;
498
+ const _currentTickersSequence: Map<string, Map<string, TickersSequence>>;
499
+ function currentTickersSequence(): {
500
+ [alias: string]: {
501
+ [tickerId: string]: TickersSequence;
502
+ };
503
+ };
504
+ const _currentTickersTimeouts: Map<string, TickerTimeoutHistory>;
505
+ const _tickersToCompleteOnStepEnd: {
506
+ tikersIds: {
507
+ id: string;
508
+ }[];
509
+ stepAlias: {
510
+ id: string;
511
+ alias: string;
512
+ }[];
513
+ };
514
+ function generateTickerId(...args: any[]): string;
515
+ function addTickerTimeoutInfo(aliases: string | string[], ticker: string, timeout: string, canBeDeletedBeforeEnd: boolean): void;
516
+ function removeTickerTimeoutInfo(timeout: NodeJS.Timeout | string): void;
517
+ function removeTickerTimeout(timeout: NodeJS.Timeout | string): void;
518
+ function removeTickerTimeoutsByAlias(alias: string, checkCanBeDeletedBeforeEnd: boolean): void;
519
+ }
520
+
521
+ /**
522
+ * Runs (or resumes) a single step of a ticker sequence. Exported (beyond the {@link tickers} public
523
+ * surface) because `CanvasManager.restore()` reconstructs sequences from serialized save data at a
524
+ * lower level than {@link addSequence} operates at.
525
+ */
526
+ declare function runTickersSequence<TArgs extends TickerArgs>(alias: string, key: string): void;
527
+ /**
528
+ * Removes one or more tickers by id, with an extra `stopTicker` option beyond what
529
+ * {@link tickers}.remove exposes - kept as its own named export for `CanvasManager`'s deprecated
530
+ * `removeTicker(tickerId, options)` flat method, which historically supported it.
531
+ */
532
+ declare function removeTicker(tickerId: string | string[], options?: {
533
+ stopTicker?: boolean;
534
+ }): void;
535
+ /**
536
+ * Drains the `completeOnStepEnd` queue, returning what was in it. Used by `canvas/index.ts`'s
537
+ * pre-continue handler, which used to reach into `CanvasManagerStatic._tickersToCompleteOnStepEnd`
538
+ * directly - draining through this function keeps that state fully encapsulated in this module.
539
+ */
540
+ declare function drainCompleteOnStepEndQueue(): {
541
+ tikersIds: {
542
+ id: string;
543
+ }[];
544
+ stepAlias: {
545
+ id: string;
546
+ alias: string;
547
+ }[];
548
+ };
549
+ /**
550
+ * Namespace for operations on tickers - the frame-by-frame animation primitive every Pixi'VN
551
+ * animation (`canvas.animate`, transitions, custom `TickerBase` subclasses) is built on.
552
+ */
553
+ declare const tickers: TickersInterface;
554
+
555
+ export { type CommonTickerProps, RegisteredTickers, type Ticker, type TickerArgs, TickerBase, type TickerHistory, type TickerInfo, type TickerProgrationExponential, type TickerProgrationLinear, type TickerProgrationType, type TickerTimeoutHistory, type TickerValue, type TickersInterface, TickersManagerStatic, type TickersSequence, drainCompleteOnStepEndQueue, removeTicker, runTickersSequence, tickerDecorator, tickers };
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-5MVDNAT4.mjs';import {a as a$1}from'./chunk-S7HZUIEI.mjs';import {c,d as d$1,e}from'./chunk-AW5XWF24.mjs';import {PixiError,GameUnifier}from'@drincs/pixi-vn/core';import N from'@drincs/pixi-vn/pixi.js';var O=c(a(),1);var E=class{constructor(r,t){this.alias=this.constructor.prototype.id;let{duration:s,priority:c,id:n=this.generateTickerId(this.alias,t),canvasElementAliases:o=[]}=t||{};this.args=r,this.duration=s,this.priority=c,this.id=n,this.canvasElementAliases=o;}alias;id;args;duration;priority;ticker=new N.Ticker;canvasElementAliases=[];generateTickerId(...r){try{return (0,O.default)(JSON.stringify(r)).toString()+"_"+Math.random().toString(36).substring(7)}catch(t){throw new PixiError("not_json_serializable",`Error to generate ticker id: ${t}`)}}fnValue;complete(r){this.stop();}stop(){let r=this.fnValue;if(!r){e.warn("TickerBase.stop() called without fnValue set. This may cause issues.");return}this.ticker.remove(r,null);}start(){let r=this.id,t=()=>this.fn(this.ticker,this.args,this.canvasElementAliases,r);this.fnValue=t,this.ticker.add(t,null,this.priority),this.ticker.start();}pause(){this.ticker.stop();}play(){this.ticker.start();}get paused(){return !this.ticker.started}};var m=new d$1({cacheSize:5});function j(e){return function(r){I.add(r,e);}}var I;(o=>{function e$1(a,u){u||(u=a.name),m.get(u)&&e.info(`Ticker "${u}" already exists, it will be overwritten`),a.prototype.id=u,m.set(u,a);}o.add=e$1;function r(a){try{let u=m.get(a);if(!u){e.error(`Event "${a}" not found, did you forget to register it with the tickerDecorator?`);return}return u}catch(u){e.error(`Error while getting Event "${a}"`,u);return}}o.get=r;function t(a,u,T){try{let g=m.get(a);if(!g){e.error(`Ticker "${a}" not found, did you forget to register it with the tickerDecorator?`);return}return new g(u,T)}catch(g){e.error(`Error while getting Ticker "${a}"`,g);return}}o.getInstance=t;function s(){return Array.from(m.values())}o.values=s;function c(a){return m.has(a)}o.has=c;function n(){return Array.from(m.keys())}o.keys=n;})(I||={});var d=I;var w=c(a(),1);var i;(l=>{function e(){return Object.fromEntries(Array.from(l._currentTickers.entries()).filter(([k,f])=>!f.createdByTicketSteps).map(([k,f])=>[k,{id:f.ticker.alias,args:f.ticker.args,canvasElementAliases:f.ticker.canvasElementAliases,priority:f.ticker.priority,duration:f.ticker.duration,paused:f.ticker.paused}]))}l.currentTickersWithoutCreatedBySteps=e,l._currentTickers=new Map,l._currentTickersSequence=new Map;function s(){return Object.fromEntries(Array.from(l._currentTickersSequence.entries()).map(([k,f])=>[k,Object.fromEntries(f)]))}l.currentTickersSequence=s,l._currentTickersTimeouts=new Map,l._tickersToCompleteOnStepEnd={tikersIds:[],stepAlias:[]};function o(...k){try{return `${(0,w.default)(JSON.stringify(k)).toString()}_${Math.random().toString(36).substring(7)}`}catch(f){throw new PixiError("not_json_serializable",`Error to generate ticker id: ${f}`)}}l.generateTickerId=o;function a(k,f,A,v){typeof k=="string"&&(k=[k]),l._currentTickersTimeouts.set(A,{aliases:k,ticker:f,canBeDeletedBeforeEnd:v});}l.addTickerTimeoutInfo=a;function u(k){typeof k!="string"&&(k=k.toString()),l._currentTickersTimeouts.delete(k);}l.removeTickerTimeoutInfo=u;function T(k){typeof k!="string"&&(k=k.toString()),clearTimeout(Number(k)),u(k);}l.removeTickerTimeout=T;function g(k,f){l._currentTickersTimeouts.forEach((A,v)=>{let R=A.aliases.filter(_=>_!==k);if(R.length===0){let _=A.canBeDeletedBeforeEnd;(!f||_)&&T(v);}else A.aliases=R;});}l.removeTickerTimeoutsByAlias=g;})(i||={});var C="aliasToRemoveAfter";function U(e){let r=i._currentTickers.get(e);if(r)return r.ticker}function D(e$1,r){let t=r.id,s=r.alias;if(typeof e$1=="string"&&(e$1=[e$1]),r.canvasElementAliases=e$1,!d.has(s)){e.error(`Ticker ${s} not found`);return}let c={ticker:r};if(i._currentTickers.set(t,c),c.ticker.start(),r.duration){let n=setTimeout(()=>{i.removeTickerTimeoutInfo(n),i._currentTickersTimeouts.get(n.toString())&&c.ticker.complete({ignoreTickerSteps:true});},r.duration*1e3);i.addTickerTimeoutInfo(e$1,s,n.toString(),true);}return t}function Y(e$1,r,t=0){if(r.length===0){e.warn("The steps of the tickers is empty");return}i._currentTickersSequence.has(e$1)||i._currentTickersSequence.set(e$1,new Map);let s={currentStepNumber:t,steps:r.map(n=>({ticker:n.alias,args:a$1(n.args),duration:n.duration}))},c=i.generateTickerId(s);return i._currentTickersSequence.get(e$1)?.set(c,s),S(e$1,c),c}function S(e$1,r){let t=i._currentTickersSequence.get(e$1);if(!t?.has(r))return;let s=t.get(r).steps[t.get(r).currentStepNumber],c=d.getInstance(s.ticker,s.args,{canvasElementAliases:[e$1],duration:s.duration,priority:s.priority});if(!c){e.error(`Ticker ${s.ticker} not found`);return}let n=c.alias,o=c.id;c.canvasElementAliases=[e$1];let a={createdByTicketSteps:{canvasElementAlias:e$1,id:r},ticker:c};if(i._currentTickers.set(o,a),a.ticker.start(),c.duration){let u=setTimeout(()=>{let T=i._currentTickersTimeouts.get(u.toString());T&&(a.ticker.complete({ignoreTickerSteps:true}),T.aliases.forEach(g=>{$(g,r);})),i.removeTickerTimeoutInfo(u);},c.duration*1e3);i.addTickerTimeoutInfo(e$1,n,u.toString(),false);}}function $(e,r){let t=i._currentTickersSequence.get(e);if(t?.has(r)){let s=t.get(r);s.currentStepNumber+1<s.steps.length?(s.currentStepNumber++,t.set(r,s),S(e,r)):r&&t.has(r)&&(t.delete(r),i._currentTickers.forEach((c,n)=>{c.createdByTicketSteps?.canvasElementAlias===e&&c.createdByTicketSteps.id===r&&y(n);}));}}function M(e,r){let{stopTicker:t=true,aliasToRemoveAfter:s,tickerAliasToResume:c,tickerIdToResume:n}=r,o=i._currentTickers.get(e),a=r.ignoreTickerSteps||false;GameUnifier.removeCanvasComponent(s),c.forEach(u=>{x({canvasAlias:u});}),x({id:n}),o&&(y(e,{stopTicker:t}),!a&&o.ticker.duration===void 0&&o.createdByTicketSteps&&$(o.createdByTicketSteps.canvasElementAlias,o.createdByTicketSteps.id));}function J(e,r){if(typeof e=="string"&&(e=[e]),!r){e.forEach(s=>{i._currentTickers.forEach((c,n)=>{c.ticker.canvasElementAliases.includes(s)&&(c.ticker.canvasElementAliases.length===1?y(n):c.ticker.canvasElementAliases=c.ticker.canvasElementAliases.filter(o=>o!==s));}),i._currentTickersSequence.has(s)&&i._currentTickersSequence.delete(s),i.removeTickerTimeoutsByAlias(s,false);});return}let t;typeof r=="string"?t=r:t=r.prototype.id,e.forEach(s=>{let c=i._currentTickersSequence.get(s);c&&c.forEach((n,o)=>{n.steps.find(a=>typeof a=="object"&&"ticker"in a&&a.ticker===t)&&c.delete(o);});}),i._currentTickers.forEach(s=>{s.ticker.alias===t&&(s.ticker.canvasElementAliases=s.ticker.canvasElementAliases.filter(c=>!e.includes(c)));}),i._currentTickersTimeouts.forEach(s=>{s.ticker===t&&s.canBeDeletedBeforeEnd&&(s.aliases=s.aliases.filter(c=>!e.includes(c)));}),z();}function z(){i._currentTickers.forEach(e=>{e.ticker.canvasElementAliases=e.ticker.canvasElementAliases.filter(r=>GameUnifier.canvasComponentExists(r)),e.ticker.canvasElementAliases.length===0&&e.ticker.complete({ignoreTickerSteps:true});}),i._currentTickersSequence.forEach((e,r)=>{e===void 0&&i._currentTickersSequence.delete(r);}),Array.from(i._currentTickersTimeouts.keys()).forEach(e=>{let r=i._currentTickersTimeouts.get(e);r&&r.aliases.length===0&&i.removeTickerTimeout(e);});}function W(){i._currentTickersSequence.clear(),Array.from(i._currentTickers.keys()).forEach(e=>{y(e);}),i._currentTickers.clear(),Array.from(i._currentTickersTimeouts.keys()).forEach(e=>{i.removeTickerTimeout(e);}),i._tickersToCompleteOnStepEnd.tikersIds.length=0,i._tickersToCompleteOnStepEnd.stepAlias.length=0;}function y(e,r={stopTicker:true}){typeof e=="string"&&(e=[e]),e.forEach(t=>{let s=i._currentTickers.get(t);s&&(r.stopTicker&&s.ticker.stop(),i._currentTickers.delete(t));});}function F(e$1){let r=[];if("canvasAlias"in e$1){let{canvasAlias:t,tickerIdsExcluded:s=[]}=e$1;i._currentTickers.forEach((c,n)=>{c.ticker.canvasElementAliases.includes(t)&&!s.includes(c.ticker.alias)&&c.ticker.paused===false&&(c.ticker.pause(),r.push(n));});}else if("id"in e$1){let{id:t}=e$1;typeof t=="string"&&(t=[t]),[...new Set(t)].forEach(s=>{let c=i._currentTickers.get(s);c?c.ticker.paused===false&&(c.ticker.pause(),r.push(s)):e.error(`Ticker with id ${s} not found`);});}return r}function x(e$1){if("canvasAlias"in e$1){let{canvasAlias:r}=e$1;i._currentTickers.forEach(t=>{t.ticker.canvasElementAliases.includes(r)&&t.ticker.play();});}else if("id"in e$1){let{id:r}=e$1;typeof r=="string"&&(r=[r]),[...new Set(r)].forEach(t=>{let s=i._currentTickers.get(t);s?s.ticker.play():e.error(`Ticker with id ${t} not found`);});}}function G(e,r){return false}function L(e$1,r,t="move"){let s=i._currentTickersSequence.get(e$1);if(s){let n=new Map(Array.from(s.entries()).map(([o,a])=>[o,a$1(a)]));i._currentTickersSequence.set(r,n);}i._currentTickers.forEach((n,o)=>{if(n.createdByTicketSteps?.canvasElementAlias===e$1&&y(o),n.ticker.canvasElementAliases.includes(e$1)){let a=d.getInstance(n.ticker.alias,a$1(n.ticker.args),{duration:n.ticker.duration,priority:n.ticker.priority,canvasElementAliases:[r]});if(a?(D(r,a),n.ticker.paused&&a.pause()):e.error(`Ticker ${n.ticker.alias} not found`),t==="move"&&(n.ticker.canvasElementAliases=n.ticker.canvasElementAliases.filter(u=>u!==e$1)),Object.hasOwn(n.ticker.args,C)){let u=n.ticker.args.aliasToRemoveAfter;typeof u=="string"&&(u=[u]),Array.isArray(u)&&(t==="move"?n.ticker.args.aliasToRemoveAfter=u.map(T=>T===e$1?r:T):t==="duplicate"&&u.find(T=>T===e$1)&&(n.ticker.args.aliasToRemoveAfter=[...u,r]));}}}),i._currentTickersTimeouts.forEach(n=>{n.aliases.includes(e$1)&&(t==="move"?n.aliases=n.aliases.map(o=>o===e$1?r:o):t==="duplicate"&&n.aliases.find(o=>o===e$1)&&n.aliases.push(r));});let c=i._currentTickersSequence.get(r);if(c&&c.forEach((n,o)=>{S(r,o);}),t==="duplicate"){let n=i._currentTickersSequence.get(e$1);n&&n.forEach((o,a)=>{S(e$1,a);});}}function Q(e){e.alias?i._tickersToCompleteOnStepEnd.stepAlias.push({id:e.id,alias:e.alias}):i._tickersToCompleteOnStepEnd.tikersIds.push({id:e.id});}async function X(e,r){if(r){let t=i._currentTickersSequence.get(r),s=t?.get(e);if(t&&s){let c=s.steps.map(n=>{if(typeof n=="object"&&"ticker"in n){let o=d.getInstance(n.ticker,n.args,{duration:n.duration,canvasElementAliases:[r],priority:n.priority});if(o)return o.complete()}return Promise.resolve()});await Promise.all(c);}}else {let t=i._currentTickers.get(e);t&&await t.ticker.complete();}}function le(){let e=i._tickersToCompleteOnStepEnd.tikersIds.splice(0,i._tickersToCompleteOnStepEnd.tikersIds.length),r=i._tickersToCompleteOnStepEnd.stepAlias.splice(0,i._tickersToCompleteOnStepEnd.stepAlias.length);return {tikersIds:e,stepAlias:r}}var ge={transfer:L,get currentTickers(){return i._currentTickers},get currentTickersSteps(){return i._currentTickersSequence},find:U,add:D,addSequence:Y,unlinkComponent:J,removeAll:W,remove:y,pause:F,resume:x,isPaused:G,completeOnStepEnd:Q,forceCompletion:X,onComplete:M};export{d as RegisteredTickers,E as TickerBase,i as TickersManagerStatic,le as drainCompleteOnStepEndQueue,y as removeTicker,S as runTickersSequence,j as tickerDecorator,ge as tickers};
package/dist/vite.cjs CHANGED
@@ -1,4 +1,6 @@
1
- 'use strict';var fs=require('fs'),path=require('path'),tinyglobby=require('tinyglobby');var Q=Object.create;var k=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var tt=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty;var nt=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var rt=(n,t,d,m)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of q(t))!et.call(n,o)&&o!==d&&k(n,o,{get:()=>t[o],enumerable:!(m=Z(t,o))||m.enumerable});return n};var st=(n,t,d)=>(d=n!=null?Q(tt(n)):{},rt(k(d,"default",{value:n,enumerable:true}),n));var G=nt((vt,M)=>{var w=process||{},X=w.argv||[],A=w.env||{},it=!(A.NO_COLOR||X.includes("--no-color"))&&(!!A.FORCE_COLOR||X.includes("--color")||w.platform==="win32"||(w.stdout||{}).isTTY&&A.TERM!=="dumb"||!!A.CI),at=(n,t,d=n)=>m=>{let o=""+m,l=o.indexOf(t,n.length);return ~l?n+ot(o,t,d,l)+t:n+o+t},ot=(n,t,d,m)=>{let o="",l=0;do o+=n.substring(l,m)+d,l=m+t.length,m=n.indexOf(t,l);while(~m);return o+n.substring(l)},j=(n=it)=>{let t=n?at:()=>String;return {isColorSupported:n,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}};M.exports=j();M.exports.createColors=j;});var O="/__pixi-vn/characters",C="/__pixi-vn/labels",N="/__pixi-vn/assets/manifest",V="/__pixi-vn/canvas-options";var L=st(G());var v=L.default.cyan("(pixi-vn)"),R="virtual:pixi-vn-testing",H=`\0${R}`;function x(n){return n?Array.isArray(n)?n:[n]:[]}function gt(n){return n?n.bundles.map(t=>t.name):[]}function bt(n){if(!n)return [];let t=new Set;for(let d of n.bundles){let m=d.assets;if(Array.isArray(m))for(let o of m){let l=o.alias;if(l)for(let g of Array.isArray(l)?l:[l])t.add(g);}else if(m&&typeof m=="object")for(let o of Object.keys(m))t.add(o);}return Array.from(t)}function pt(n){let t=[],d=[];for(let m of n)try{let o=fs.readFileSync(m,"utf-8"),l=/newLabel\(\s*["']([^"']+)["']/g,g;for(;(g=l.exec(o))!==null;)d.push(g[1]);let p=/new\s+\w*[Cc]haracter\(\s*["']([^"']+)["']/g;for(;(g=p.exec(o))!==null;)t.push(g[1]);}catch{}return {charIds:t,labelIds:d}}function ht(n){let t,d,m=new Promise(e=>{d=e;}),o=[...x(n?.content),...x(n?.characters),...x(n?.labels)],l=[],g=[],p=new Set,F=[],I=typeof n?.assetsManifest=="function",U=n?.testing===false,T=typeof n?.testing=="object"?n.testing.windowKey:void 0,y=typeof n?.assetsManifest=="function"?void 0:n?.assetsManifest;async function P(e){if(typeof n?.assetsManifest=="function")try{let r=await n.assetsManifest(e);y=r,h.manifest=r??null;}catch(r){t?.logger.error(`${v} Failed to resolve the assets manifest.`,{error:r instanceof Error?r:new Error(String(r)),timestamp:true});}}let _=new Map;function $(){if(!n?.typeFilePath||!t)return null;let e=n.typeFilePath;return path.isAbsolute(e)?e:path.resolve(t.root,e)}function B(){let e=[...g,...Array.from(_.values()).flat()];return Array.from(new Set(e))}function z(e,r,s,i,u){fs.mkdirSync(path.dirname(e),{recursive:true});let a=["/* eslint-disable */","// noinspection JSUnusedGlobalSymbols","// This file is auto-generated by @drincs/pixi-vn vite plugin. Do not edit manually."];if(r.length>0){a.push('declare module "@drincs/pixi-vn/characters" {'),a.push(" interface PixivnCharacterIds {");for(let c of r)a.push(` ${JSON.stringify(c)}: never;`);a.push(" }"),a.push("}");}if(s.length>0){a.push('declare module "@drincs/pixi-vn/narration" {'),a.push(" interface PixivnLabelIds {");for(let c of s)a.push(` ${JSON.stringify(c)}: never;`);a.push(" }"),a.push("}");}if(i.length>0||u.length>0){if(a.push('declare module "@drincs/pixi-vn/canvas" {'),i.length>0){a.push(" interface PixivnBundleIds {");for(let c of i)a.push(` ${JSON.stringify(c)}: never;`);a.push(" }");}if(u.length>0){a.push(" interface PixivnAssetAliasIds {");for(let c of u)a.push(` ${JSON.stringify(c)}: never;`);a.push(" }");}a.push("}");}a.push(`export const characterIds = ${JSON.stringify(r)} as const;`);{let c=Object.fromEntries(r.map(f=>[f,f]));a.push(`export const characterIdsEnum = ${JSON.stringify(c)} as const;`);}a.push(`export const labelIds = ${JSON.stringify(s)} as const;`);{let c=Object.fromEntries(s.map(f=>[f,f]));a.push(`export const labelIdsEnum = ${JSON.stringify(c)} as const;`);}a.push(`export const bundleIds = ${JSON.stringify(i)} as const;`);{let c=Object.fromEntries(i.map(f=>[f,f]));a.push(`export const bundleIdsEnum = ${JSON.stringify(c)} as const;`);}a.push(`export const assetAliasIds = ${JSON.stringify(u)} as const;`);{let c=Object.fromEntries(u.map(f=>[f,f]));a.push(`export const assetAliasIdsEnum = ${JSON.stringify(c)} as const;`);}a.push(""),fs.writeFileSync(e,a.join(`
2
- `),"utf-8");}function W(){h.characters=l,h.labels=B();}function b(){W();let e=$();if(e)try{z(e,l.map(r=>r.id),B(),gt(y),bt(y));}catch(r){t?.logger.error(`${v} Failed to write keys file "${e}".`,{error:r instanceof Error?r:new Error(String(r)),timestamp:true});}}async function E(e,r=[]){try{l=(await e("@drincs/pixi-vn/characters")).RegisteredCharacters?.values()??[];}catch{l=[];}try{g=(await e("@drincs/pixi-vn/narration")).RegisteredLabels?.keys()??[];}catch{g=[];}if(r.length>0){let{charIds:i,labelIds:u}=pt(r),a=new Set(l.map(f=>f.id)),c=new Set(g);for(let f of i)a.has(f)||l.push({id:f});for(let f of u)c.has(f)||g.push(f);}let s=l.map(i=>i.id).join(", ")||"none";t?.logger.info(`${v} ${L.default.dim(`${l.length} character(s): [${s}], ${g.length} label(s)`)}`,{timestamp:true});}async function D(e,r){let s=[],i=[...x(n?.characters),...x(n?.labels)],u=await tinyglobby.glob(i,{cwd:r,absolute:true,onlyFiles:true});for(let c of u){p.add(c);try{await e(c);}catch{s.push(c);}}await E(e,s),b();let a=await tinyglobby.glob(x(n?.content),{cwd:r,absolute:true,onlyFiles:true});for(let c of a){p.add(c);try{await e(c);}catch{s.push(c);}}return s}async function J(e,r){try{await e("@drincs/pixi-vn/characters");}catch{}try{await e("@drincs/pixi-vn/narration");}catch{}let s=await D(e,r);await E(e,s),await P(e),b(),d();}async function Y(e){for(let s of p)for(let i of e.moduleGraph.getModulesByFile(s)??[])e.moduleGraph.invalidateModule(i);try{(await e.ssrLoadModule("@drincs/pixi-vn/characters")).RegisteredCharacters?.clear?.();}catch{}try{(await e.ssrLoadModule("@drincs/pixi-vn/narration")).RegisteredLabels?.clear?.();}catch{}let r=await D(s=>e.ssrLoadModule(s),t.root);await E(s=>e.ssrLoadModule(s),r),await P(s=>e.ssrLoadModule(s)),b();for(let s of F)s();}let h={characters:null,labels:null,manifest:y??null,canvasOptions:null};function S(e,r){return (s,i)=>{if(i.setHeader("Content-Type","application/json"),s.method==="GET"){let u=h[e];if(u===null){i.statusCode=404,i.end(JSON.stringify({error:`${r} not initialized`}));return}i.statusCode=200,i.end(JSON.stringify(u));return}if(s.method==="POST"){let u="";s.on("data",a=>{u+=a.toString();}),s.on("end",()=>{try{h[e]=JSON.parse(u),i.statusCode=201,i.end(JSON.stringify({message:`${r} updated successfully`}));}catch{i.statusCode=400,i.end(JSON.stringify({error:`Invalid JSON format for ${r}`}));}});}}}return {name:"vite-plugin-pixi-vn",enforce:"pre",api:{contentLoaded:m,get characters(){return l},onReload(e){F.push(e);},setExternalLabels(e,r){_.set(e,r),b();},clearExternalLabels(e){_.delete(e),b();},setAssetsManifest(e){y=e,h.manifest=e,b();}},resolveId(e){if(e===R)return H},load(e){if(e===H)return `import { Game } from "@drincs/pixi-vn";
3
- Game.testing.enable(${T?JSON.stringify({windowKey:T}):""});
4
- `},transformIndexHtml(){if(!(U||t?.command!=="serve"))return [{tag:"script",attrs:{type:"module",src:`/@id/${R}`},injectTo:"head-prepend"}]},config(e,r){if(r.command==="serve"&&o.length>0)return {ssr:{noExternal:["@drincs/pixi-vn"]}}},configResolved(e){t=e,o.length===0&&!I&&(b(),d());},async buildStart(){if(t?.command!=="build"||o.length===0&&!I)return;let{createServer:e}=await import('vite'),r=await e({root:t.root,configFile:false,resolve:t.resolve,server:{middlewareMode:true},appType:"custom",logLevel:"silent",optimizeDeps:{noDiscovery:true},ssr:{noExternal:["@drincs/pixi-vn"]}});try{await J(s=>r.ssrLoadModule(s),t.root);}catch{d();}finally{await r.close();}},configureServer(e){(o.length>0||I)&&J(r=>e.ssrLoadModule(r),t.root).catch(()=>{d();}),e.middlewares.use(O,S("characters","Characters")),e.middlewares.use(C,S("labels","Labels")),e.middlewares.use(N,S("manifest","Manifest")),e.middlewares.use(V,S("canvasOptions","Canvas options"));},async hotUpdate({file:e,server:r}){let s=$();if(s&&e===s)return [];if(o.length>0&&p.has(e)){try{await Y(r);}catch(i){t?.logger.error(`${v} Failed to reload content.`,{error:i instanceof Error?i:new Error(String(i)),timestamp:true});}return []}if(I)try{await P(i=>r.ssrLoadModule(i)),b();}catch(i){t?.logger.error(`${v} Failed to refresh the assets manifest.`,{error:i instanceof Error?i:new Error(String(i)),timestamp:true});}}}}exports.PIXIVN_DEV_API_ASSETS_MANIFEST=N;exports.PIXIVN_DEV_API_CANVAS_OPTIONS=V;exports.PIXIVN_DEV_API_CHARACTERS=O;exports.PIXIVN_DEV_API_LABELS=C;exports.vitePluginPixivn=ht;
1
+ 'use strict';var fs=require('fs'),path=require('path'),tinyglobby=require('tinyglobby'),vite=require('vite');var oe=Object.create;var j=Object.defineProperty;var ce=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var ue=Object.getPrototypeOf,fe=Object.prototype.hasOwnProperty;var de=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var me=(r,e,f,d)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of le(e))!fe.call(r,o)&&o!==f&&j(r,o,{get:()=>e[o],enumerable:!(d=ce(e,o))||d.enumerable});return r};var ge=(r,e,f)=>(f=r!=null?oe(ue(r)):{},me(j(f,"default",{value:r,enumerable:true}),r));var U=de((Ae,k)=>{var A=process||{},W=A.argv||[],P=A.env||{},pe=!(P.NO_COLOR||W.includes("--no-color"))&&(!!P.FORCE_COLOR||W.includes("--color")||A.platform==="win32"||(A.stdout||{}).isTTY&&P.TERM!=="dumb"||!!P.CI),be=(r,e,f=r)=>d=>{let o=""+d,u=o.indexOf(e,r.length);return ~u?r+he(o,e,f,u)+e:r+o+e},he=(r,e,f,d)=>{let o="",u=0;do o+=r.substring(u,d)+f,u=d+e.length,d=r.indexOf(e,u);while(~d);return o+r.substring(u)},K=(r=pe)=>{let e=r?be:()=>String;return {isColorSupported:r,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};k.exports=K();k.exports.createColors=K;});var C="/__pixi-vn/characters",N="/__pixi-vn/labels",V="/__pixi-vn/assets/manifest",M="/__pixi-vn/canvas-options";var $=ge(U());var b=$.default.cyan("(pixi-vn)"),F="virtual:pixi-vn-testing",ee=`\0${F}`,T="virtual:pixi-vn-worker-register",te=`\0${T}`;function y(r){return r?Array.isArray(r)?r:[r]:[]}function ye(r){return r?r.bundles.map(e=>e.name):[]}function ve(r){if(!r)return [];let e=new Set;for(let f of r.bundles){let d=f.assets;if(Array.isArray(d))for(let o of d){let u=o.alias;if(u)for(let g of Array.isArray(u)?u:[u])e.add(g);}else if(d&&typeof d=="object")for(let o of Object.keys(d))e.add(o);}return Array.from(e)}function Ie(r){let e=[],f=[];for(let d of r)try{let o=fs.readFileSync(d,"utf-8"),u=/newLabel\(\s*["']([^"']+)["']/g,g;for(;(g=u.exec(o))!==null;)f.push(g[1]);let h=/new\s+\w*[Cc]haracter\(\s*["']([^"']+)["']/g;for(;(g=h.exec(o))!==null;)e.push(g[1]);}catch{}return {charIds:e,labelIds:f}}function we(r){let e,f,d=new Promise(t=>{f=t;}),o=[...y(r?.content),...y(r?.characters),...y(r?.labels)],u=[],g=[],h=new Set,L=[],I=typeof r?.assetsManifest=="function",re=r?.testing===false,B=typeof r?.testing=="object"?r.testing.windowKey:void 0,v=typeof r?.assetsManifest=="function"?void 0:r?.assetsManifest;async function E(t){if(typeof r?.assetsManifest=="function")try{let n=await r.assetsManifest(t);v=n,x.manifest=n??null;}catch(n){e?.logger.error(`${b} Failed to resolve the assets manifest.`,{error:n instanceof Error?n:new Error(String(n)),timestamp:true});}}let O=new Map;function D(){if(!r?.typeFilePath||!e)return null;let t=r.typeFilePath;return path.isAbsolute(t)?t:path.resolve(e.root,t)}function w(){if(!r?.workerFilePath||!e)return null;let t=r.workerFilePath;return path.isAbsolute(t)?t:path.resolve(e.root,t)}function ne(){let t=w();if(t)try{fs.mkdirSync(path.dirname(t),{recursive:!0}),fs.writeFileSync(t,["/* eslint-disable */","// noinspection JSUnusedGlobalSymbols","// This file is auto-generated by @drincs/pixi-vn vite plugin. Do not edit manually.",'import { handleGameWorkerMessage } from "@drincs/pixi-vn/worker";',"","self.onmessage = async (event) => {"," const response = await handleGameWorkerMessage(event.data);"," if (response) self.postMessage(response);","};",""].join(`
2
+ `),"utf-8");}catch(n){e?.logger.error(`${b} Failed to write worker file "${t}".`,{error:n instanceof Error?n:new Error(String(n)),timestamp:true});}}function J(){let t=[...g,...Array.from(O.values()).flat()];return Array.from(new Set(t))}function se(t,n,s,a,c){fs.mkdirSync(path.dirname(t),{recursive:true});let i=["/* eslint-disable */","// noinspection JSUnusedGlobalSymbols","// This file is auto-generated by @drincs/pixi-vn vite plugin. Do not edit manually."];if(n.length>0){i.push('declare module "@drincs/pixi-vn/characters" {'),i.push(" interface PixivnCharacterIds {");for(let l of n)i.push(` ${JSON.stringify(l)}: never;`);i.push(" }"),i.push("}");}if(s.length>0){i.push('declare module "@drincs/pixi-vn/narration" {'),i.push(" interface PixivnLabelIds {");for(let l of s)i.push(` ${JSON.stringify(l)}: never;`);i.push(" }"),i.push("}");}if(a.length>0||c.length>0){if(i.push('declare module "@drincs/pixi-vn/canvas" {'),a.length>0){i.push(" interface PixivnBundleIds {");for(let l of a)i.push(` ${JSON.stringify(l)}: never;`);i.push(" }");}if(c.length>0){i.push(" interface PixivnAssetAliasIds {");for(let l of c)i.push(` ${JSON.stringify(l)}: never;`);i.push(" }");}i.push("}");}i.push(`export const characterIds = ${JSON.stringify(n)} as const;`);{let l=Object.fromEntries(n.map(m=>[m,m]));i.push(`export const characterIdsEnum = ${JSON.stringify(l)} as const;`);}i.push(`export const labelIds = ${JSON.stringify(s)} as const;`);{let l=Object.fromEntries(s.map(m=>[m,m]));i.push(`export const labelIdsEnum = ${JSON.stringify(l)} as const;`);}i.push(`export const bundleIds = ${JSON.stringify(a)} as const;`);{let l=Object.fromEntries(a.map(m=>[m,m]));i.push(`export const bundleIdsEnum = ${JSON.stringify(l)} as const;`);}i.push(`export const assetAliasIds = ${JSON.stringify(c)} as const;`);{let l=Object.fromEntries(c.map(m=>[m,m]));i.push(`export const assetAliasIdsEnum = ${JSON.stringify(l)} as const;`);}i.push(""),fs.writeFileSync(t,i.join(`
3
+ `),"utf-8");}function ie(){x.characters=u,x.labels=J();}function p(){ie();let t=D();if(t)try{se(t,u.map(n=>n.id),J(),ye(v),ve(v));}catch(n){e?.logger.error(`${b} Failed to write keys file "${t}".`,{error:n instanceof Error?n:new Error(String(n)),timestamp:true});}}async function R(t,n=[]){try{u=(await t("@drincs/pixi-vn/characters")).RegisteredCharacters?.values()??[];}catch{u=[];}try{g=(await t("@drincs/pixi-vn/narration")).RegisteredLabels?.keys()??[];}catch{g=[];}if(n.length>0){let{charIds:a,labelIds:c}=Ie(n),i=new Set(u.map(m=>m.id)),l=new Set(g);for(let m of a)i.has(m)||u.push({id:m});for(let m of c)l.has(m)||g.push(m);}let s=u.map(a=>a.id).join(", ")||"none";e?.logger.info(`${b} ${$.default.dim(`${u.length} character(s): [${s}], ${g.length} label(s)`)}`,{timestamp:true});}async function G(t,n){let s=[],a=[...y(r?.characters),...y(r?.labels)],c=await tinyglobby.glob(a,{cwd:n,absolute:true,onlyFiles:true});for(let l of c){h.add(vite.normalizePath(l));try{await t(l);}catch{s.push(l);}}await R(t,s),p();let i=await tinyglobby.glob(y(r?.content),{cwd:n,absolute:true,onlyFiles:true});for(let l of i){h.add(vite.normalizePath(l));try{await t(l);}catch{s.push(l);}}return s}async function X(t,n){try{await t("@drincs/pixi-vn/characters");}catch{}try{await t("@drincs/pixi-vn/narration");}catch{}let s=await G(t,n);await R(t,s),await E(t),p(),f();}async function ae(t){for(let s of h)for(let a of t.moduleGraph.getModulesByFile(s)??[])t.moduleGraph.invalidateModule(a);try{(await t.ssrLoadModule("@drincs/pixi-vn/characters")).RegisteredCharacters?.clear?.();}catch{}try{(await t.ssrLoadModule("@drincs/pixi-vn/narration")).RegisteredLabels?.clear?.();}catch{}let n=await G(s=>t.ssrLoadModule(s),e.root);await R(s=>t.ssrLoadModule(s),n),await E(s=>t.ssrLoadModule(s)),p();for(let s of L)s();}let x={characters:null,labels:null,manifest:v??null,canvasOptions:null};function S(t,n){return (s,a)=>{if(a.setHeader("Content-Type","application/json"),s.method==="GET"){let c=x[t];if(c===null){a.statusCode=404,a.end(JSON.stringify({error:`${n} not initialized`}));return}a.statusCode=200,a.end(JSON.stringify(c));return}if(s.method==="POST"){let c="";s.on("data",i=>{c+=i.toString();}),s.on("end",()=>{try{x[t]=JSON.parse(c),a.statusCode=201,a.end(JSON.stringify({message:`${n} updated successfully`}));}catch{a.statusCode=400,a.end(JSON.stringify({error:`Invalid JSON format for ${n}`}));}});}}}return {name:"vite-plugin-pixi-vn",enforce:"pre",api:{contentLoaded:d,get characters(){return u},onReload(t){L.push(t);},setExternalLabels(t,n){O.set(t,n),p();},clearExternalLabels(t){O.delete(t),p();},setAssetsManifest(t){v=t,x.manifest=t,p();}},resolveId(t){if(t===F)return ee;if(t===T)return te},load(t){if(t===ee)return `import { Game } from "@drincs/pixi-vn";
4
+ Game.testing.enable(${B?JSON.stringify({windowKey:B}):""});
5
+ `;if(t===te){let n=w();return n?['import { Game } from "@drincs/pixi-vn";',`import PixivnWorker from ${JSON.stringify(`${n}?worker`)};`,"Game.worker.register(new PixivnWorker());",""].join(`
6
+ `):""}},transformIndexHtml(){let t=[];return !re&&e?.command==="serve"&&t.push({tag:"script",attrs:{type:"module",src:`/@id/${F}`},injectTo:"head-prepend"}),r?.autoRegisterWorker&&w()&&t.push({tag:"script",attrs:{type:"module",src:`/@id/${T}`},injectTo:"head-prepend"}),t},config(t,n){if(n.command==="serve"&&o.length>0)return {ssr:{noExternal:["@drincs/pixi-vn"]}}},configResolved(t){e=t,ne(),r?.autoRegisterWorker&&!w()&&e.logger.warn(`${b} "autoRegisterWorker" has no effect without "workerFilePath" - set both to auto-register the generated worker.`,{timestamp:true}),o.length===0&&!I&&(p(),f());},async buildStart(){if(e?.command!=="build"||o.length===0&&!I)return;let{createServer:t}=await import('vite'),n=await t({root:e.root,configFile:false,resolve:e.resolve,server:{middlewareMode:true},appType:"custom",logLevel:"silent",optimizeDeps:{noDiscovery:true},ssr:{noExternal:["@drincs/pixi-vn"]}});try{await X(s=>n.ssrLoadModule(s),e.root);}catch{f();}finally{await n.close();}},configureServer(t){(o.length>0||I)&&X(n=>t.ssrLoadModule(n),e.root).catch(()=>{f();}),t.middlewares.use(C,S("characters","Characters")),t.middlewares.use(N,S("labels","Labels")),t.middlewares.use(V,S("manifest","Manifest")),t.middlewares.use(M,S("canvasOptions","Canvas options"));},async hotUpdate({file:t,server:n}){let s=vite.normalizePath(t),a=D();if(a&&s===vite.normalizePath(a))return [];if(o.length>0&&h.has(s)){try{await ae(n);}catch(c){e?.logger.error(`${b} Failed to reload content.`,{error:c instanceof Error?c:new Error(String(c)),timestamp:true});}return []}if(I)try{await E(c=>n.ssrLoadModule(c)),p();}catch(c){e?.logger.error(`${b} Failed to refresh the assets manifest.`,{error:c instanceof Error?c:new Error(String(c)),timestamp:true});}}}}exports.PIXIVN_DEV_API_ASSETS_MANIFEST=V;exports.PIXIVN_DEV_API_CANVAS_OPTIONS=M;exports.PIXIVN_DEV_API_CHARACTERS=C;exports.PIXIVN_DEV_API_LABELS=N;exports.vitePluginPixivn=we;