@defold-typescript/library-types 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/api-doc/{bridge.bridge.json → bridge.json} +749 -844
  2. package/api-doc/decore.json +22 -22
  3. package/api-doc/druid.json +195 -1790
  4. package/api-doc/event.json +1074 -0
  5. package/api-doc/immutable.json +65 -0
  6. package/api-doc/lang.json +528 -0
  7. package/api-doc/{event.event.json → log.json} +96 -101
  8. package/api-doc/narrator.json +647 -0
  9. package/api-doc/proto.json +995 -0
  10. package/api-doc/saver.saver.json +713 -263
  11. package/api-doc/saver.storage.json +282 -52
  12. package/api-doc/squid.json +846 -0
  13. package/api-doc/tweener.json +277 -0
  14. package/generated/bridge.d.ts +468 -0
  15. package/generated/decore.d.ts +36 -36
  16. package/generated/druid.d.ts +137 -443
  17. package/generated/event.d.ts +318 -0
  18. package/generated/immutable.d.ts +13 -0
  19. package/generated/lang.d.ts +101 -0
  20. package/generated/log.d.ts +36 -0
  21. package/generated/narrator.d.ts +121 -0
  22. package/generated/proto.d.ts +146 -0
  23. package/generated/saver.saver.d.ts +287 -42
  24. package/generated/saver.storage.d.ts +77 -14
  25. package/generated/squid.d.ts +127 -0
  26. package/generated/tweener.d.ts +42 -0
  27. package/library-classification.json +0 -71
  28. package/library-targets.json +0 -66
  29. package/luals-targets.json +114 -0
  30. package/package.json +4 -33
  31. package/script-api-targets.json +15 -0
  32. package/scripts/__snapshots__/parse-luals.test.ts.snap +340 -75
  33. package/scripts/apply-luals-overrides.ts +63 -0
  34. package/scripts/emit-library-dts.ts +84 -3
  35. package/scripts/lower-api-doc.ts +48 -16
  36. package/scripts/luals-fidelity.ts +7 -0
  37. package/scripts/map-luals-types.ts +34 -1
  38. package/scripts/parse-luals.ts +423 -18
  39. package/scripts/sync-luals-types.ts +15 -1
  40. package/scripts/sync-script-api-types.ts +368 -0
  41. package/api-doc/immutable.immutable.json +0 -63
  42. package/api-doc/lang.lang.json +0 -411
  43. package/api-doc/log.log.json +0 -50
  44. package/api-doc/narrator.narrator.json +0 -150
  45. package/api-doc/proto.proto.json +0 -355
  46. package/api-doc/squid.squid.json +0 -660
  47. package/api-doc/tweener.tweener.json +0 -419
  48. package/generated/bridge.bridge.d.ts +0 -533
  49. package/generated/event.event.d.ts +0 -54
  50. package/generated/immutable.immutable.d.ts +0 -13
  51. package/generated/lang.lang.d.ts +0 -33
  52. package/generated/log.log.d.ts +0 -40
  53. package/generated/narrator.narrator.d.ts +0 -66
  54. package/generated/proto.proto.d.ts +0 -36
  55. package/generated/squid.squid.d.ts +0 -106
  56. package/generated/tweener.tweener.d.ts +0 -151
@@ -0,0 +1,1074 @@
1
+ {
2
+ "info": {
3
+ "namespace": "event",
4
+ "brief": "The Event module, used to create and manage events. Allows to subscribe to events and trigger them.",
5
+ "description": "The Event module, used to create and manage events. Allows to subscribe to events and trigger them."
6
+ },
7
+ "elements": [
8
+ {
9
+ "type": "FUNCTION",
10
+ "name": "create",
11
+ "brief": "Generate a new event instance. This instance can then be used to subscribe to and trigger events.\nThe callback function will be called when the event is triggered. The callback_context parameter is optional\nand will be passed as the first parameter to the callback function. Usually, it is used to pass the self instance.\nlocal e = event.create()\nlocal e = event.create(function(self) print(\"ok\") end, self)",
12
+ "description": "Generate a new event instance. This instance can then be used to subscribe to and trigger events.\nThe callback function will be called when the event is triggered. The callback_context parameter is optional\nand will be passed as the first parameter to the callback function. Usually, it is used to pass the self instance.\nlocal e = event.create()\nlocal e = event.create(function(self) print(\"ok\") end, self)",
13
+ "parameters": [
14
+ {
15
+ "name": "callback",
16
+ "doc": "The function to be called when the event is triggered. Or the event instance to subscribe.",
17
+ "types": [
18
+ "unknown | event | undefined"
19
+ ],
20
+ "is_optional": "True",
21
+ "is_vararg": "False"
22
+ },
23
+ {
24
+ "name": "callback_context",
25
+ "doc": "The first parameter to be passed to the callback function.",
26
+ "types": [
27
+ "unknown | undefined"
28
+ ],
29
+ "is_optional": "True",
30
+ "is_vararg": "False"
31
+ }
32
+ ],
33
+ "returnvalues": [
34
+ {
35
+ "name": "",
36
+ "doc": "A new event instance.",
37
+ "types": [
38
+ "event"
39
+ ]
40
+ }
41
+ ]
42
+ },
43
+ {
44
+ "type": "FUNCTION",
45
+ "name": "is_event",
46
+ "brief": "Check if the table is an event instance.\nif event.is_event(my_value) then\nmy_value:trigger()\nend",
47
+ "description": "Check if the table is an event instance.\nif event.is_event(my_value) then\nmy_value:trigger()\nend",
48
+ "parameters": [
49
+ {
50
+ "name": "value",
51
+ "doc": "",
52
+ "types": [
53
+ "unknown"
54
+ ],
55
+ "is_optional": "False",
56
+ "is_vararg": "False"
57
+ }
58
+ ],
59
+ "returnvalues": [
60
+ {
61
+ "name": "",
62
+ "doc": "",
63
+ "types": [
64
+ "boolean"
65
+ ]
66
+ }
67
+ ]
68
+ },
69
+ {
70
+ "type": "FUNCTION",
71
+ "name": "set_logger",
72
+ "brief": "Customize the logging mechanism used by Event module. You can use **Defold Log** library or provide a custom logger.\nBy default, the module uses the `pprint` logger for errors.",
73
+ "description": "Customize the logging mechanism used by Event module. You can use **Defold Log** library or provide a custom logger.\nBy default, the module uses the `pprint` logger for errors.",
74
+ "parameters": [
75
+ {
76
+ "name": "logger_instance",
77
+ "doc": "A logger object that follows the specified logging interface, including methods for `trace`, `debug`, `info`, `warn`, `error`. Pass `nil` to remove the default logger.",
78
+ "types": [
79
+ "event_logger | LuaTable | undefined"
80
+ ],
81
+ "is_optional": "True",
82
+ "is_vararg": "False"
83
+ }
84
+ ],
85
+ "returnvalues": []
86
+ },
87
+ {
88
+ "type": "FUNCTION",
89
+ "name": "set_mode",
90
+ "brief": "Set the mode of the event module.",
91
+ "description": "Set the mode of the event module.",
92
+ "parameters": [
93
+ {
94
+ "name": "mode",
95
+ "doc": "| \"xpcall\" | \"none\" The mode to set.",
96
+ "types": [
97
+ "\"pcall\""
98
+ ],
99
+ "is_optional": "False",
100
+ "is_vararg": "False"
101
+ }
102
+ ],
103
+ "returnvalues": []
104
+ },
105
+ {
106
+ "type": "TYPEDEF",
107
+ "name": "event_callback_data"
108
+ },
109
+ {
110
+ "type": "TYPEDEF",
111
+ "name": "event_logger",
112
+ "properties": [
113
+ {
114
+ "name": "trace",
115
+ "brief": "Log a trace message.",
116
+ "description": "Log a trace message.",
117
+ "types": [
118
+ "(logger: event_logger, message: string, data: unknown | undefined) => void"
119
+ ]
120
+ },
121
+ {
122
+ "name": "debug",
123
+ "brief": "Log a debug message.",
124
+ "description": "Log a debug message.",
125
+ "types": [
126
+ "(logger: event_logger, message: string, data: unknown | undefined) => void"
127
+ ]
128
+ },
129
+ {
130
+ "name": "info",
131
+ "brief": "Log an info message.",
132
+ "description": "Log an info message.",
133
+ "types": [
134
+ "(logger: event_logger, message: string, data: unknown | undefined) => void"
135
+ ]
136
+ },
137
+ {
138
+ "name": "warn",
139
+ "brief": "Log a warning message.",
140
+ "description": "Log a warning message.",
141
+ "types": [
142
+ "(logger: event_logger, message: string, data: unknown | undefined) => void"
143
+ ]
144
+ },
145
+ {
146
+ "name": "error",
147
+ "brief": "Log an error message.",
148
+ "description": "Log an error message.",
149
+ "types": [
150
+ "(logger: event_logger, message: string, data: unknown | undefined) => void"
151
+ ]
152
+ }
153
+ ]
154
+ },
155
+ {
156
+ "type": "TYPEDEF",
157
+ "name": "event",
158
+ "functions": [
159
+ {
160
+ "type": "FUNCTION",
161
+ "name": "subscribe",
162
+ "brief": "Subscribe a callback to the event or other event. The callback will be invoked whenever the event is triggered.\nThe callback_context parameter is optional and will be passed as the first parameter to the callback function.\nIf the callback with context is already subscribed, the warning will be logged.\nlocal function callback(self)\nprint(\"clicked!\")\nend\non_click_event:subscribe(callback, self)\n\n-- Subscribe an event to another event\nevent_1 = event.create(callback)\nevent_2 = event.create()\nevent_2:subscribe(event_1) -- Now event2 will trigger event1",
163
+ "description": "Subscribe a callback to the event or other event. The callback will be invoked whenever the event is triggered.\nThe callback_context parameter is optional and will be passed as the first parameter to the callback function.\nIf the callback with context is already subscribed, the warning will be logged.\nlocal function callback(self)\nprint(\"clicked!\")\nend\non_click_event:subscribe(callback, self)\n\n-- Subscribe an event to another event\nevent_1 = event.create(callback)\nevent_2 = event.create()\nevent_2:subscribe(event_1) -- Now event2 will trigger event1",
164
+ "parameters": [
165
+ {
166
+ "name": "callback",
167
+ "doc": "The function to be executed when the event occurs.",
168
+ "types": [
169
+ "unknown | event"
170
+ ],
171
+ "is_optional": "False",
172
+ "is_vararg": "False"
173
+ },
174
+ {
175
+ "name": "callback_context",
176
+ "doc": "The first parameter to be passed to the callback function.",
177
+ "types": [
178
+ "unknown | undefined"
179
+ ],
180
+ "is_optional": "True",
181
+ "is_vararg": "False"
182
+ }
183
+ ],
184
+ "returnvalues": [
185
+ {
186
+ "name": "",
187
+ "doc": "True if event is subscribed (Will return false if the callback is already subscribed)",
188
+ "types": [
189
+ "boolean"
190
+ ]
191
+ }
192
+ ]
193
+ },
194
+ {
195
+ "type": "FUNCTION",
196
+ "name": "subscribe_once",
197
+ "brief": "Subscribe a callback for a single trigger. After the first trigger the callback is automatically unsubscribed.\non_click_event:subscribe_once(function(self) print(\"one-time click!\") end, self)",
198
+ "description": "Subscribe a callback for a single trigger. After the first trigger the callback is automatically unsubscribed.\non_click_event:subscribe_once(function(self) print(\"one-time click!\") end, self)",
199
+ "parameters": [
200
+ {
201
+ "name": "callback",
202
+ "doc": "The function or event to run once.",
203
+ "types": [
204
+ "unknown | event"
205
+ ],
206
+ "is_optional": "False",
207
+ "is_vararg": "False"
208
+ },
209
+ {
210
+ "name": "callback_context",
211
+ "doc": "Same as subscribe.",
212
+ "types": [
213
+ "unknown | undefined"
214
+ ],
215
+ "is_optional": "True",
216
+ "is_vararg": "False"
217
+ }
218
+ ],
219
+ "returnvalues": [
220
+ {
221
+ "name": "",
222
+ "doc": "True if subscribed",
223
+ "types": [
224
+ "boolean"
225
+ ]
226
+ }
227
+ ]
228
+ },
229
+ {
230
+ "type": "FUNCTION",
231
+ "name": "unsubscribe",
232
+ "brief": "Remove a previously subscribed callback from the event.\nThe callback_context should be the same as the one used when subscribing the callback.\nIf there is no callback_context provided, all callbacks with the same function will be unsubscribed.\non_click_event:unsubscribe(callback, self)",
233
+ "description": "Remove a previously subscribed callback from the event.\nThe callback_context should be the same as the one used when subscribing the callback.\nIf there is no callback_context provided, all callbacks with the same function will be unsubscribed.\non_click_event:unsubscribe(callback, self)",
234
+ "parameters": [
235
+ {
236
+ "name": "callback",
237
+ "doc": "The callback function to unsubscribe.",
238
+ "types": [
239
+ "unknown | event"
240
+ ],
241
+ "is_optional": "False",
242
+ "is_vararg": "False"
243
+ },
244
+ {
245
+ "name": "callback_context",
246
+ "doc": "The first parameter to be passed to the callback function. If not provided, will unsubscribe all callbacks with the same function.",
247
+ "types": [
248
+ "unknown | undefined"
249
+ ],
250
+ "is_optional": "True",
251
+ "is_vararg": "False"
252
+ }
253
+ ],
254
+ "returnvalues": [
255
+ {
256
+ "name": "",
257
+ "doc": "True if event is unsubscribed",
258
+ "types": [
259
+ "boolean"
260
+ ]
261
+ }
262
+ ]
263
+ },
264
+ {
265
+ "type": "FUNCTION",
266
+ "name": "is_subscribed",
267
+ "brief": "Determine if a specific callback is currently subscribed to the event.\nThe callback_context should be the same as the one used when subscribing the callback.\nlocal is_subscribed = on_click_event:is_subscribed(callback, self)",
268
+ "description": "Determine if a specific callback is currently subscribed to the event.\nThe callback_context should be the same as the one used when subscribing the callback.\nlocal is_subscribed = on_click_event:is_subscribed(callback, self)",
269
+ "parameters": [
270
+ {
271
+ "name": "callback",
272
+ "doc": "The callback function in question. Or the event instance to check.",
273
+ "types": [
274
+ "unknown | event"
275
+ ],
276
+ "is_optional": "False",
277
+ "is_vararg": "False"
278
+ },
279
+ {
280
+ "name": "callback_context",
281
+ "doc": "The first parameter to be passed to the callback function.",
282
+ "types": [
283
+ "unknown | undefined"
284
+ ],
285
+ "is_optional": "True",
286
+ "is_vararg": "False"
287
+ }
288
+ ],
289
+ "returnvalues": [
290
+ {
291
+ "name": "",
292
+ "doc": "True if the callback is subscribed to the event",
293
+ "types": [
294
+ "boolean"
295
+ ]
296
+ },
297
+ {
298
+ "name": "",
299
+ "doc": "Index of callback in event if subscribed (return first found index)",
300
+ "types": [
301
+ "number | undefined"
302
+ ]
303
+ }
304
+ ]
305
+ },
306
+ {
307
+ "type": "FUNCTION",
308
+ "name": "trigger",
309
+ "brief": "Trigger the event, causing all subscribed callbacks to be executed.\nAny parameters passed to trigger will be forwarded to the callbacks.\nThe return value of the last executed callback is returned.\nThe event:trigger(...) can be called as event(...).\non_click_event:trigger(\"arg1\", \"arg2\")\n\n-- The event can be triggered as a function\non_click_event(\"arg1\", \"arg2\")",
310
+ "description": "Trigger the event, causing all subscribed callbacks to be executed.\nAny parameters passed to trigger will be forwarded to the callbacks.\nThe return value of the last executed callback is returned.\nThe event:trigger(...) can be called as event(...).\non_click_event:trigger(\"arg1\", \"arg2\")\n\n-- The event can be triggered as a function\non_click_event(\"arg1\", \"arg2\")",
311
+ "parameters": [
312
+ {
313
+ "name": "...args",
314
+ "doc": "Any number of parameters to be passed to the subscribed callbacks.",
315
+ "types": [
316
+ "unknown"
317
+ ],
318
+ "is_optional": "False",
319
+ "is_vararg": "True"
320
+ }
321
+ ],
322
+ "returnvalues": [
323
+ {
324
+ "name": "",
325
+ "doc": "Result of the last triggered callback",
326
+ "types": [
327
+ "unknown"
328
+ ]
329
+ }
330
+ ]
331
+ },
332
+ {
333
+ "type": "FUNCTION",
334
+ "name": "is_empty",
335
+ "brief": "Check if the event has no subscribed callbacks.\nlocal is_empty = on_click_event:is_empty()",
336
+ "description": "Check if the event has no subscribed callbacks.\nlocal is_empty = on_click_event:is_empty()",
337
+ "parameters": [],
338
+ "returnvalues": [
339
+ {
340
+ "name": "",
341
+ "doc": "True if the event has no subscribed callbacks",
342
+ "types": [
343
+ "boolean"
344
+ ]
345
+ }
346
+ ]
347
+ },
348
+ {
349
+ "type": "FUNCTION",
350
+ "name": "clear",
351
+ "brief": "Remove all callbacks subscribed to the event, effectively resetting it.\non_click_event:clear()",
352
+ "description": "Remove all callbacks subscribed to the event, effectively resetting it.\non_click_event:clear()",
353
+ "parameters": [],
354
+ "returnvalues": []
355
+ }
356
+ ]
357
+ },
358
+ {
359
+ "type": "TYPEDEF",
360
+ "name": "events"
361
+ },
362
+ {
363
+ "type": "TYPEDEF",
364
+ "name": "promise_cancelled_context",
365
+ "properties": [
366
+ {
367
+ "name": "is_cancelled",
368
+ "brief": "",
369
+ "description": "",
370
+ "types": [
371
+ "boolean"
372
+ ]
373
+ },
374
+ {
375
+ "name": "on_cancel",
376
+ "brief": "",
377
+ "description": "",
378
+ "types": [
379
+ "event"
380
+ ]
381
+ }
382
+ ]
383
+ },
384
+ {
385
+ "type": "TYPEDEF",
386
+ "name": "promise",
387
+ "functions": [
388
+ {
389
+ "type": "FUNCTION",
390
+ "name": "next",
391
+ "brief": "Attach resolve and reject handlers to the promise.\nReturns a new promise that will be resolved or rejected based on the handlers' return values.\nload_data():next(function(data) return process(data) end):next(display):catch(show_error)",
392
+ "description": "Attach resolve and reject handlers to the promise.\nReturns a new promise that will be resolved or rejected based on the handlers' return values.\nload_data():next(function(data) return process(data) end):next(display):catch(show_error)",
393
+ "parameters": [
394
+ {
395
+ "name": "on_resolved",
396
+ "doc": "Handler called when promise is resolved. If nil, value passes through.",
397
+ "types": [
398
+ "unknown | promise | event | undefined"
399
+ ],
400
+ "is_optional": "True",
401
+ "is_vararg": "False"
402
+ },
403
+ {
404
+ "name": "on_rejected",
405
+ "doc": "Handler called when promise is rejected. If nil, rejection passes through.",
406
+ "types": [
407
+ "unknown | promise | event | undefined"
408
+ ],
409
+ "is_optional": "True",
410
+ "is_vararg": "False"
411
+ },
412
+ {
413
+ "name": "context",
414
+ "doc": "The context to call the handlers with.",
415
+ "types": [
416
+ "unknown | undefined"
417
+ ],
418
+ "is_optional": "True",
419
+ "is_vararg": "False"
420
+ }
421
+ ],
422
+ "returnvalues": [
423
+ {
424
+ "name": "",
425
+ "doc": "A new promise representing the result of the handlers.",
426
+ "types": [
427
+ "promise"
428
+ ]
429
+ }
430
+ ]
431
+ },
432
+ {
433
+ "type": "FUNCTION",
434
+ "name": "catch",
435
+ "brief": "Attach a rejection handler to the promise. Equivalent to next(nil, on_rejected).\nload_data():catch(function(err) print(\"Failed:\", err) end)",
436
+ "description": "Attach a rejection handler to the promise. Equivalent to next(nil, on_rejected).\nload_data():catch(function(err) print(\"Failed:\", err) end)",
437
+ "parameters": [
438
+ {
439
+ "name": "on_rejected",
440
+ "doc": "Handler called when promise is rejected.",
441
+ "types": [
442
+ "unknown | event"
443
+ ],
444
+ "is_optional": "False",
445
+ "is_vararg": "False"
446
+ },
447
+ {
448
+ "name": "context",
449
+ "doc": "The context to call the handler with.",
450
+ "types": [
451
+ "unknown | undefined"
452
+ ],
453
+ "is_optional": "True",
454
+ "is_vararg": "False"
455
+ }
456
+ ],
457
+ "returnvalues": [
458
+ {
459
+ "name": "",
460
+ "doc": "A new promise representing the result of the handler.",
461
+ "types": [
462
+ "promise"
463
+ ]
464
+ }
465
+ ]
466
+ },
467
+ {
468
+ "type": "FUNCTION",
469
+ "name": "finally",
470
+ "brief": "Attach a handler that is called regardless of whether the promise is resolved or rejected.\nThe handler is called with the resolved value or rejection reason.\nWhen context is provided, it is passed as the first argument.\nThe handler return value is ignored.\nload_data():finally(function() hide_loading_spinner() end)",
471
+ "description": "Attach a handler that is called regardless of whether the promise is resolved or rejected.\nThe handler is called with the resolved value or rejection reason.\nWhen context is provided, it is passed as the first argument.\nThe handler return value is ignored.\nload_data():finally(function() hide_loading_spinner() end)",
472
+ "parameters": [
473
+ {
474
+ "name": "on_finally",
475
+ "doc": "Handler called when promise is finished (resolved or rejected).",
476
+ "types": [
477
+ "unknown | event"
478
+ ],
479
+ "is_optional": "False",
480
+ "is_vararg": "False"
481
+ },
482
+ {
483
+ "name": "context",
484
+ "doc": "The context to call the handler with.",
485
+ "types": [
486
+ "unknown | undefined"
487
+ ],
488
+ "is_optional": "True",
489
+ "is_vararg": "False"
490
+ }
491
+ ],
492
+ "returnvalues": [
493
+ {
494
+ "name": "",
495
+ "doc": "A new promise that resolves/rejects with the same value/reason as the original.",
496
+ "types": [
497
+ "promise"
498
+ ]
499
+ }
500
+ ]
501
+ },
502
+ {
503
+ "type": "FUNCTION",
504
+ "name": "is_pending",
505
+ "brief": "Check if the promise is in pending state.",
506
+ "description": "Check if the promise is in pending state.",
507
+ "parameters": [],
508
+ "returnvalues": [
509
+ {
510
+ "name": "",
511
+ "doc": "True if the promise is pending.",
512
+ "types": [
513
+ "boolean"
514
+ ]
515
+ }
516
+ ]
517
+ },
518
+ {
519
+ "type": "FUNCTION",
520
+ "name": "is_resolved",
521
+ "brief": "Check if the promise is in resolved state.",
522
+ "description": "Check if the promise is in resolved state.",
523
+ "parameters": [],
524
+ "returnvalues": [
525
+ {
526
+ "name": "",
527
+ "doc": "True if the promise is resolved.",
528
+ "types": [
529
+ "boolean"
530
+ ]
531
+ }
532
+ ]
533
+ },
534
+ {
535
+ "type": "FUNCTION",
536
+ "name": "is_rejected",
537
+ "brief": "Check if the promise is in rejected state.",
538
+ "description": "Check if the promise is in rejected state.",
539
+ "parameters": [],
540
+ "returnvalues": [
541
+ {
542
+ "name": "",
543
+ "doc": "True if the promise is rejected.",
544
+ "types": [
545
+ "boolean"
546
+ ]
547
+ }
548
+ ]
549
+ },
550
+ {
551
+ "type": "FUNCTION",
552
+ "name": "is_finished",
553
+ "brief": "Check if the promise is finished (either resolved or rejected).",
554
+ "description": "Check if the promise is finished (either resolved or rejected).",
555
+ "parameters": [],
556
+ "returnvalues": [
557
+ {
558
+ "name": "",
559
+ "doc": "True if the promise is finished.",
560
+ "types": [
561
+ "boolean"
562
+ ]
563
+ }
564
+ ]
565
+ },
566
+ {
567
+ "type": "FUNCTION",
568
+ "name": "is_cancelled",
569
+ "brief": "Check if the shared cancel_context was cancelled.",
570
+ "description": "Check if the shared cancel_context was cancelled.",
571
+ "parameters": [],
572
+ "returnvalues": [
573
+ {
574
+ "name": "",
575
+ "doc": "True if the promise chain was cancelled.",
576
+ "types": [
577
+ "boolean"
578
+ ]
579
+ }
580
+ ]
581
+ },
582
+ {
583
+ "type": "FUNCTION",
584
+ "name": "resolve",
585
+ "brief": "Resolve the promise.\nmy_promise:resolve(result)",
586
+ "description": "Resolve the promise.\nmy_promise:resolve(result)",
587
+ "parameters": [
588
+ {
589
+ "name": "value",
590
+ "doc": "The value to resolve with.",
591
+ "types": [
592
+ "unknown"
593
+ ],
594
+ "is_optional": "False",
595
+ "is_vararg": "False"
596
+ }
597
+ ],
598
+ "returnvalues": []
599
+ },
600
+ {
601
+ "type": "FUNCTION",
602
+ "name": "reject",
603
+ "brief": "Reject the promise.\nmy_promise:reject(\"failed\")",
604
+ "description": "Reject the promise.\nmy_promise:reject(\"failed\")",
605
+ "parameters": [
606
+ {
607
+ "name": "reason",
608
+ "doc": "The reason to reject with.",
609
+ "types": [
610
+ "unknown"
611
+ ],
612
+ "is_optional": "False",
613
+ "is_vararg": "False"
614
+ }
615
+ ],
616
+ "returnvalues": []
617
+ },
618
+ {
619
+ "type": "FUNCTION",
620
+ "name": "cancel",
621
+ "brief": "Cancel the promise chain. Triggers cleanup and rejects if still pending.\nmy_promise:cancel()",
622
+ "description": "Cancel the promise chain. Triggers cleanup and rejects if still pending.\nmy_promise:cancel()",
623
+ "parameters": [],
624
+ "returnvalues": []
625
+ },
626
+ {
627
+ "type": "FUNCTION",
628
+ "name": "append",
629
+ "brief": "Append a task to this promise's internal sequence without reassigning.\nThe task may return a value or a promise. If `task` is a promise, the pipeline waits for it\nto finish and adopts its result. The incoming value is not forwarded into `task`\n(same as `append(function() return task end)`).\nReturns self for chaining.\nAlmost similar to `promise = promise:next(task)`, but without reassigning the promise.\npipeline:append(step1)\npipeline:append(step2)\npipeline:append(step3)\nlocal last = pipeline:tail()\nprint(\"Is going to check status of\", last:is_pending())",
630
+ "description": "Append a task to this promise's internal sequence without reassigning.\nThe task may return a value or a promise. If `task` is a promise, the pipeline waits for it\nto finish and adopts its result. The incoming value is not forwarded into `task`\n(same as `append(function() return task end)`).\nReturns self for chaining.\nAlmost similar to `promise = promise:next(task)`, but without reassigning the promise.\npipeline:append(step1)\npipeline:append(step2)\npipeline:append(step3)\nlocal last = pipeline:tail()\nprint(\"Is going to check status of\", last:is_pending())",
631
+ "parameters": [
632
+ {
633
+ "name": "task",
634
+ "doc": "",
635
+ "types": [
636
+ "((value: unknown) => unknown) | promise"
637
+ ],
638
+ "is_optional": "False",
639
+ "is_vararg": "False"
640
+ }
641
+ ],
642
+ "returnvalues": [
643
+ {
644
+ "name": "",
645
+ "doc": "",
646
+ "types": [
647
+ "promise"
648
+ ]
649
+ }
650
+ ]
651
+ },
652
+ {
653
+ "type": "FUNCTION",
654
+ "name": "tail",
655
+ "brief": "Get the current tail promise representing all appended work.\nlocal last = pipeline:tail()\nlast:next(on_complete)",
656
+ "description": "Get the current tail promise representing all appended work.\nlocal last = pipeline:tail()\nlast:next(on_complete)",
657
+ "parameters": [],
658
+ "returnvalues": [
659
+ {
660
+ "name": "",
661
+ "doc": "",
662
+ "types": [
663
+ "promise"
664
+ ]
665
+ }
666
+ ]
667
+ },
668
+ {
669
+ "type": "FUNCTION",
670
+ "name": "reset",
671
+ "brief": "Reset the internal sequence to an already resolved promise.\npipeline:reset()\npipeline:append(new_step)",
672
+ "description": "Reset the internal sequence to an already resolved promise.\npipeline:reset()\npipeline:append(new_step)",
673
+ "parameters": [],
674
+ "returnvalues": [
675
+ {
676
+ "name": "",
677
+ "doc": "",
678
+ "types": [
679
+ "promise"
680
+ ]
681
+ }
682
+ ]
683
+ },
684
+ {
685
+ "type": "FUNCTION",
686
+ "name": "_reject_cancel_children",
687
+ "brief": "Reject pending child promises when a settled promise is cancelled.",
688
+ "description": "Reject pending child promises when a settled promise is cancelled.",
689
+ "parameters": [],
690
+ "returnvalues": []
691
+ }
692
+ ],
693
+ "properties": [
694
+ {
695
+ "name": "state",
696
+ "brief": "Current state of the promise (pending, resolved, rejected)",
697
+ "description": "Current state of the promise (pending, resolved, rejected)",
698
+ "types": [
699
+ "promise_state"
700
+ ]
701
+ },
702
+ {
703
+ "name": "value",
704
+ "brief": "The resolved value or rejection reason",
705
+ "description": "The resolved value or rejection reason",
706
+ "types": [
707
+ "unknown"
708
+ ]
709
+ },
710
+ {
711
+ "name": "cancellation",
712
+ "brief": "Shared cancelled context for a promise chain",
713
+ "description": "Shared cancelled context for a promise chain",
714
+ "types": [
715
+ "promise_cancelled_context"
716
+ ]
717
+ }
718
+ ]
719
+ },
720
+ {
721
+ "type": "TYPEDEF",
722
+ "name": "queue_event_data",
723
+ "properties": [
724
+ {
725
+ "name": "data",
726
+ "brief": "",
727
+ "description": "",
728
+ "types": [
729
+ "unknown"
730
+ ]
731
+ },
732
+ {
733
+ "name": "on_handle",
734
+ "brief": "",
735
+ "description": "",
736
+ "types": [
737
+ "event"
738
+ ]
739
+ }
740
+ ]
741
+ },
742
+ {
743
+ "type": "TYPEDEF",
744
+ "name": "queue",
745
+ "functions": [
746
+ {
747
+ "type": "FUNCTION",
748
+ "name": "push",
749
+ "brief": "Push a new event to the queue. The event will exist until it's handled by a subscriber.\nIf there are already subscribers for this queue instance, they will be called immediately.\nIf multiple subscribers handle the event, all subscribers will still be called. The on_handle callback\nwill be called for each subscriber that handles the event.\nmy_queue:push(save_data)\nmy_queue:push(save_data, function() print(\"saved!\") end)",
750
+ "description": "Push a new event to the queue. The event will exist until it's handled by a subscriber.\nIf there are already subscribers for this queue instance, they will be called immediately.\nIf multiple subscribers handle the event, all subscribers will still be called. The on_handle callback\nwill be called for each subscriber that handles the event.\nmy_queue:push(save_data)\nmy_queue:push(save_data, function() print(\"saved!\") end)",
751
+ "parameters": [
752
+ {
753
+ "name": "data",
754
+ "doc": "The data associated with the event.",
755
+ "types": [
756
+ "unknown"
757
+ ],
758
+ "is_optional": "False",
759
+ "is_vararg": "False"
760
+ },
761
+ {
762
+ "name": "on_handle",
763
+ "doc": "Callback function or event to be called when the event is handled.",
764
+ "types": [
765
+ "unknown | event | undefined"
766
+ ],
767
+ "is_optional": "True",
768
+ "is_vararg": "False"
769
+ },
770
+ {
771
+ "name": "context",
772
+ "doc": "The context to be passed as the first parameter to the on_handle function when the event is handled.",
773
+ "types": [
774
+ "unknown | undefined"
775
+ ],
776
+ "is_optional": "True",
777
+ "is_vararg": "False"
778
+ }
779
+ ],
780
+ "returnvalues": []
781
+ },
782
+ {
783
+ "type": "FUNCTION",
784
+ "name": "subscribe",
785
+ "brief": "Subscribe a handler to this queue instance. When an event is pushed to this queue,\nthe handler will be called. If there are already events in the queue, they will be processed immediately.\nReturn a non-nil value from the handler to mark the event as handled and remove it from the queue.\nlocal function on_save(self, data)\ndo_save(data)\nreturn true\nend\nmy_queue:subscribe(on_save, self)",
786
+ "description": "Subscribe a handler to this queue instance. When an event is pushed to this queue,\nthe handler will be called. If there are already events in the queue, they will be processed immediately.\nReturn a non-nil value from the handler to mark the event as handled and remove it from the queue.\nlocal function on_save(self, data)\ndo_save(data)\nreturn true\nend\nmy_queue:subscribe(on_save, self)",
787
+ "parameters": [
788
+ {
789
+ "name": "handler",
790
+ "doc": "The handler function or event to be called when an event is pushed.",
791
+ "types": [
792
+ "unknown | event"
793
+ ],
794
+ "is_optional": "False",
795
+ "is_vararg": "False"
796
+ },
797
+ {
798
+ "name": "context",
799
+ "doc": "The context to be passed as the first parameter to the handler function.",
800
+ "types": [
801
+ "unknown | undefined"
802
+ ],
803
+ "is_optional": "True",
804
+ "is_vararg": "False"
805
+ }
806
+ ],
807
+ "returnvalues": [
808
+ {
809
+ "name": "",
810
+ "doc": "True if handler was subscribed successfully",
811
+ "types": [
812
+ "boolean"
813
+ ]
814
+ }
815
+ ]
816
+ },
817
+ {
818
+ "type": "FUNCTION",
819
+ "name": "subscribe_once",
820
+ "brief": "Subscribe a handler until it handles one event. The handler is invoked for each event in the queue until it returns non-nil (handles an event)\nthen it is automatically unsubscribed and will not be invoked again, even if more events remain in the queue.\nmy_queue:subscribe_once(function(self, data) return process(data) end, self)",
821
+ "description": "Subscribe a handler until it handles one event. The handler is invoked for each event in the queue until it returns non-nil (handles an event)\nthen it is automatically unsubscribed and will not be invoked again, even if more events remain in the queue.\nmy_queue:subscribe_once(function(self, data) return process(data) end, self)",
822
+ "parameters": [
823
+ {
824
+ "name": "handler",
825
+ "doc": "The handler function or event to be called when an event is pushed.",
826
+ "types": [
827
+ "unknown | event"
828
+ ],
829
+ "is_optional": "False",
830
+ "is_vararg": "False"
831
+ },
832
+ {
833
+ "name": "context",
834
+ "doc": "The context to be passed as the first parameter to the handler function.",
835
+ "types": [
836
+ "unknown | undefined"
837
+ ],
838
+ "is_optional": "True",
839
+ "is_vararg": "False"
840
+ }
841
+ ],
842
+ "returnvalues": [
843
+ {
844
+ "name": "",
845
+ "doc": "True if handler was subscribed successfully",
846
+ "types": [
847
+ "boolean"
848
+ ]
849
+ }
850
+ ]
851
+ },
852
+ {
853
+ "type": "FUNCTION",
854
+ "name": "unsubscribe",
855
+ "brief": "Unsubscribe a handler from this queue instance.\nmy_queue:unsubscribe(on_save, self)",
856
+ "description": "Unsubscribe a handler from this queue instance.\nmy_queue:unsubscribe(on_save, self)",
857
+ "parameters": [
858
+ {
859
+ "name": "handler",
860
+ "doc": "The handler function or event to unsubscribe.",
861
+ "types": [
862
+ "unknown | event"
863
+ ],
864
+ "is_optional": "False",
865
+ "is_vararg": "False"
866
+ },
867
+ {
868
+ "name": "context",
869
+ "doc": "The context that was passed when subscribing.",
870
+ "types": [
871
+ "unknown | undefined"
872
+ ],
873
+ "is_optional": "True",
874
+ "is_vararg": "False"
875
+ }
876
+ ],
877
+ "returnvalues": [
878
+ {
879
+ "name": "",
880
+ "doc": "True if handler was unsubscribed successfully",
881
+ "types": [
882
+ "boolean"
883
+ ]
884
+ }
885
+ ]
886
+ },
887
+ {
888
+ "type": "FUNCTION",
889
+ "name": "is_subscribed",
890
+ "brief": "Check if a handler is subscribed to this queue instance.\nlocal ok = my_queue:is_subscribed(on_save, self)",
891
+ "description": "Check if a handler is subscribed to this queue instance.\nlocal ok = my_queue:is_subscribed(on_save, self)",
892
+ "parameters": [
893
+ {
894
+ "name": "handler",
895
+ "doc": "The handler function or event to check.",
896
+ "types": [
897
+ "unknown | event"
898
+ ],
899
+ "is_optional": "False",
900
+ "is_vararg": "False"
901
+ },
902
+ {
903
+ "name": "context",
904
+ "doc": "The context that was passed when subscribing.",
905
+ "types": [
906
+ "unknown | undefined"
907
+ ],
908
+ "is_optional": "True",
909
+ "is_vararg": "False"
910
+ }
911
+ ],
912
+ "returnvalues": [
913
+ {
914
+ "name": "",
915
+ "doc": "True if handler is subscribed",
916
+ "types": [
917
+ "boolean"
918
+ ]
919
+ },
920
+ {
921
+ "name": "",
922
+ "doc": "Index of handler if subscribed",
923
+ "types": [
924
+ "number | undefined"
925
+ ]
926
+ }
927
+ ]
928
+ },
929
+ {
930
+ "type": "FUNCTION",
931
+ "name": "process",
932
+ "brief": "Process all events in this queue immediately. Subscribers will not be called in this function.\nEvents can be handled and removed in event handler callback. If event is handled, it will be removed from the queue.\nmy_queue:process(function(self, data) return handle(data) end, self)",
933
+ "description": "Process all events in this queue immediately. Subscribers will not be called in this function.\nEvents can be handled and removed in event handler callback. If event is handled, it will be removed from the queue.\nmy_queue:process(function(self, data) return handle(data) end, self)",
934
+ "parameters": [
935
+ {
936
+ "name": "event_handler",
937
+ "doc": "Specific handler or event to process the events. If this function returns non-nil, the event will be removed from the queue.",
938
+ "types": [
939
+ "unknown | event"
940
+ ],
941
+ "is_optional": "False",
942
+ "is_vararg": "False"
943
+ },
944
+ {
945
+ "name": "context",
946
+ "doc": "The context to be passed to the handler.",
947
+ "types": [
948
+ "unknown | undefined"
949
+ ],
950
+ "is_optional": "True",
951
+ "is_vararg": "False"
952
+ }
953
+ ],
954
+ "returnvalues": []
955
+ },
956
+ {
957
+ "type": "FUNCTION",
958
+ "name": "process_next",
959
+ "brief": "Process exactly one queued event with a specific handler (subscribers will NOT be called).\nIf the handler returns non-nil the event will be removed from the queue.\nlocal handled = my_queue:process_next(function(data) return handle(data) end)",
960
+ "description": "Process exactly one queued event with a specific handler (subscribers will NOT be called).\nIf the handler returns non-nil the event will be removed from the queue.\nlocal handled = my_queue:process_next(function(data) return handle(data) end)",
961
+ "parameters": [
962
+ {
963
+ "name": "event_handler",
964
+ "doc": "Specific handler or event to process the event. If this function returns non-nil, the event will be removed from the queue.",
965
+ "types": [
966
+ "unknown | event | undefined"
967
+ ],
968
+ "is_optional": "True",
969
+ "is_vararg": "False"
970
+ },
971
+ {
972
+ "name": "context",
973
+ "doc": "The context to be passed to the handler.",
974
+ "types": [
975
+ "unknown | undefined"
976
+ ],
977
+ "is_optional": "True",
978
+ "is_vararg": "False"
979
+ }
980
+ ],
981
+ "returnvalues": [
982
+ {
983
+ "name": "",
984
+ "doc": "True if the head event was handled and removed",
985
+ "types": [
986
+ "boolean"
987
+ ]
988
+ }
989
+ ]
990
+ },
991
+ {
992
+ "type": "FUNCTION",
993
+ "name": "get_events",
994
+ "brief": "Get all pending events in this queue.\nfor _, event_data in ipairs(my_queue:get_events()) do\nprint(event_data.data)\nend",
995
+ "description": "Get all pending events in this queue.\nfor _, event_data in ipairs(my_queue:get_events()) do\nprint(event_data.data)\nend",
996
+ "parameters": [],
997
+ "returnvalues": [
998
+ {
999
+ "name": "",
1000
+ "doc": "A table of pending events.",
1001
+ "types": [
1002
+ "queue_event_data[]"
1003
+ ]
1004
+ }
1005
+ ]
1006
+ },
1007
+ {
1008
+ "type": "FUNCTION",
1009
+ "name": "clear_events",
1010
+ "brief": "Clear all pending events in this queue.\nmy_queue:clear_events()",
1011
+ "description": "Clear all pending events in this queue.\nmy_queue:clear_events()",
1012
+ "parameters": [],
1013
+ "returnvalues": []
1014
+ },
1015
+ {
1016
+ "type": "FUNCTION",
1017
+ "name": "clear_subscribers",
1018
+ "brief": "Clear all subscribers from this queue instance.\nmy_queue:clear_subscribers()",
1019
+ "description": "Clear all subscribers from this queue instance.\nmy_queue:clear_subscribers()",
1020
+ "parameters": [],
1021
+ "returnvalues": []
1022
+ },
1023
+ {
1024
+ "type": "FUNCTION",
1025
+ "name": "is_empty",
1026
+ "brief": "Check if this queue has no pending events.\nif my_queue:is_empty() then\nreturn\nend",
1027
+ "description": "Check if this queue has no pending events.\nif my_queue:is_empty() then\nreturn\nend",
1028
+ "parameters": [],
1029
+ "returnvalues": [
1030
+ {
1031
+ "name": "",
1032
+ "doc": "True if the queue has no pending events",
1033
+ "types": [
1034
+ "boolean"
1035
+ ]
1036
+ }
1037
+ ]
1038
+ },
1039
+ {
1040
+ "type": "FUNCTION",
1041
+ "name": "has_subscribers",
1042
+ "brief": "Check if this queue instance has no subscribed handlers.\nif my_queue:has_subscribers() then\nmy_queue:push(data)\nend",
1043
+ "description": "Check if this queue instance has no subscribed handlers.\nif my_queue:has_subscribers() then\nmy_queue:push(data)\nend",
1044
+ "parameters": [],
1045
+ "returnvalues": [
1046
+ {
1047
+ "name": "",
1048
+ "doc": "True if the queue instance has subscribed handlers",
1049
+ "types": [
1050
+ "boolean"
1051
+ ]
1052
+ }
1053
+ ]
1054
+ },
1055
+ {
1056
+ "type": "FUNCTION",
1057
+ "name": "clear",
1058
+ "brief": "Remove all events and handlers from this queue instance, effectively resetting it.\nmy_queue:clear()",
1059
+ "description": "Remove all events and handlers from this queue instance, effectively resetting it.\nmy_queue:clear()",
1060
+ "parameters": [],
1061
+ "returnvalues": []
1062
+ }
1063
+ ]
1064
+ },
1065
+ {
1066
+ "type": "TYPEDEF",
1067
+ "name": "queues"
1068
+ },
1069
+ {
1070
+ "type": "TYPEDEF",
1071
+ "name": "promise_state"
1072
+ }
1073
+ ]
1074
+ }