@defold-typescript/types 0.7.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api-targets.json +2 -0
- package/generated/collectionproxy.d.ts +1 -1
- package/generated/go.d.ts +1 -1
- package/generated/gui.d.ts +1 -1
- package/generated/html5.d.ts +49 -0
- package/generated/http.d.ts +1 -1
- package/generated/kinds/gui-script.d.ts +4 -0
- package/generated/kinds/render-script.d.ts +4 -0
- package/generated/kinds/script.d.ts +4 -0
- package/generated/physics.d.ts +3 -3
- package/generated/profiler.d.ts +1 -1
- package/generated/render.d.ts +3 -3
- package/generated/resource.d.ts +3 -3
- package/generated/types.d.ts +59 -0
- package/index.d.ts +4 -0
- package/package.json +7 -1
- package/scripts/doc-source.ts +71 -5
- package/scripts/fidelity-audit.ts +48 -10
- package/scripts/fidelity-baseline.json +31 -15
- package/scripts/regen.ts +13 -1
- package/scripts/sync-api-docs.ts +6 -0
- package/src/emit-dts.ts +275 -5
- package/src/go-overloads.d.ts +17 -0
- package/src/lifecycle.ts +34 -9
- package/src/timers.d.ts +47 -0
package/src/timers.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Importable timer polyfills backed by Defold's frame-driven `timer.delay` /
|
|
2
|
+
// `timer.cancel` (packages/types/generated/timer.d.ts). Defold runs each script
|
|
3
|
+
// as an isolated Lua chunk with no shared global scope and no JS event loop, so
|
|
4
|
+
// these are named module exports (lowered to a `require`), not ambient globals:
|
|
5
|
+
// pay-for-use and explicit. The transpiler emits the runtime and the CLI writes
|
|
6
|
+
// it to the output root; the import lowers to `require("defold_typescript_timers")`.
|
|
7
|
+
declare module "@defold-typescript/types/timers" {
|
|
8
|
+
/**
|
|
9
|
+
* Run `callback` once after `delayMs` milliseconds, backed by Defold's
|
|
10
|
+
* frame-driven `timer.delay`. Returns the timer handle to pass to
|
|
11
|
+
* `clearTimeout`. There is no event loop — the callback fires from the engine
|
|
12
|
+
* scheduler on a later frame, not a microtask drain.
|
|
13
|
+
*
|
|
14
|
+
* @param callback - invoked once when the delay elapses.
|
|
15
|
+
* @param delayMs - delay in milliseconds (converted to Defold's seconds).
|
|
16
|
+
* @returns the timer handle, for `clearTimeout`.
|
|
17
|
+
*/
|
|
18
|
+
export function setTimeout(callback: () => void, delayMs: number): number;
|
|
19
|
+
/**
|
|
20
|
+
* Run `callback` every `delayMs` milliseconds (a repeating `timer.delay`).
|
|
21
|
+
* Returns the timer handle to pass to `clearInterval`.
|
|
22
|
+
*
|
|
23
|
+
* @param callback - invoked on every tick.
|
|
24
|
+
* @param delayMs - interval in milliseconds (converted to Defold's seconds).
|
|
25
|
+
* @returns the timer handle, for `clearInterval`.
|
|
26
|
+
*/
|
|
27
|
+
export function setInterval(callback: () => void, delayMs: number): number;
|
|
28
|
+
/**
|
|
29
|
+
* Cancel a pending `setTimeout` by its handle (`timer.cancel`). Cancelling an
|
|
30
|
+
* already-fired or already-cancelled handle is safe.
|
|
31
|
+
*/
|
|
32
|
+
export function clearTimeout(handle: number): void;
|
|
33
|
+
/**
|
|
34
|
+
* Cancel a repeating `setInterval` by its handle (`timer.cancel`).
|
|
35
|
+
*/
|
|
36
|
+
export function clearInterval(handle: number): void;
|
|
37
|
+
/**
|
|
38
|
+
* Resolve after `seconds` (Defold-native seconds, not milliseconds), so
|
|
39
|
+
* `await wait(0.5)` suspends an `async` function until the engine timer fires.
|
|
40
|
+
* The returned `Promise` is resolved from inside the `timer.delay` callback —
|
|
41
|
+
* nothing else advances it.
|
|
42
|
+
*
|
|
43
|
+
* @param seconds - delay in seconds before the promise resolves.
|
|
44
|
+
* @returns a `Promise` that resolves once the timer fires.
|
|
45
|
+
*/
|
|
46
|
+
export function wait(seconds: number): Promise<void>;
|
|
47
|
+
}
|