@replayablejs/runtime 0.1.0-alpha.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 (60) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +29 -0
  3. package/dist/adapters/applovin.d.ts +13 -0
  4. package/dist/adapters/applovin.js +16 -0
  5. package/dist/adapters/applovin.js.map +1 -0
  6. package/dist/adapters/browser.d.ts +12 -0
  7. package/dist/adapters/browser.js +17 -0
  8. package/dist/adapters/browser.js.map +1 -0
  9. package/dist/adapters/google.d.ts +12 -0
  10. package/dist/adapters/google.js +17 -0
  11. package/dist/adapters/google.js.map +1 -0
  12. package/dist/adapters/liftoff.d.ts +13 -0
  13. package/dist/adapters/liftoff.js +47 -0
  14. package/dist/adapters/liftoff.js.map +1 -0
  15. package/dist/adapters/meta.d.ts +12 -0
  16. package/dist/adapters/meta.js +16 -0
  17. package/dist/adapters/meta.js.map +1 -0
  18. package/dist/adapters/mintegral.d.ts +13 -0
  19. package/dist/adapters/mintegral.js +59 -0
  20. package/dist/adapters/mintegral.js.map +1 -0
  21. package/dist/adapters/moloco.d.ts +11 -0
  22. package/dist/adapters/moloco.js +15 -0
  23. package/dist/adapters/moloco.js.map +1 -0
  24. package/dist/adapters/unity.d.ts +12 -0
  25. package/dist/adapters/unity.js +15 -0
  26. package/dist/adapters/unity.js.map +1 -0
  27. package/dist/api-BgI_ycxT.js +13 -0
  28. package/dist/api-BgI_ycxT.js.map +1 -0
  29. package/dist/assets-BD68MQTL.d.ts +107 -0
  30. package/dist/assets.d.ts +2 -0
  31. package/dist/assets.js +8 -0
  32. package/dist/assets.js.map +1 -0
  33. package/dist/audio/disabled.d.ts +12 -0
  34. package/dist/audio/disabled.js +44 -0
  35. package/dist/audio/disabled.js.map +1 -0
  36. package/dist/audio/enabled.d.ts +28 -0
  37. package/dist/audio/enabled.js +426 -0
  38. package/dist/audio/enabled.js.map +1 -0
  39. package/dist/audio-CyLjSreN.d.ts +66 -0
  40. package/dist/categories-BbQSRMmw.js +21 -0
  41. package/dist/categories-BbQSRMmw.js.map +1 -0
  42. package/dist/create-adapter-4oub3UeP.js +22 -0
  43. package/dist/create-adapter-4oub3UeP.js.map +1 -0
  44. package/dist/create-adapter-ByJx4UTX.js +43 -0
  45. package/dist/create-adapter-ByJx4UTX.js.map +1 -0
  46. package/dist/events-C85TpS5f.js +69 -0
  47. package/dist/events-C85TpS5f.js.map +1 -0
  48. package/dist/events-CYG_LvaH.js +85 -0
  49. package/dist/events-CYG_LvaH.js.map +1 -0
  50. package/dist/host-adapter-vFX6DBcY.d.ts +43 -0
  51. package/dist/index.d.ts +255 -0
  52. package/dist/index.js +8876 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/loader-Czz-x3KH.d.ts +61 -0
  55. package/dist/screen-DXf2FPtL.d.ts +70 -0
  56. package/dist/shell.d.ts +10 -0
  57. package/dist/shell.js +11 -0
  58. package/dist/shell.js.map +1 -0
  59. package/package.json +75 -0
  60. package/src/screen/gpu/benchmarks/LICENSE +21 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-adapter-ByJx4UTX.js","names":[],"sources":["../src/mraid/create-adapter.ts"],"sourcesContent":["import { FULL_VOLUME } from '#lifecycle/volume.js';\nimport type { HostAdapter, HostSnapshot, HostUpdateListener } from '#types/host-adapter.js';\nimport type { MraidApi } from '#types/mraid.js';\n\nimport { readMraidViewport, requireMraid, waitForMraidReady } from './api.js';\nimport { subscribeToMraidUpdates } from './events.js';\n\n/** MRAID SDK object injected by the active advertising host. */\ndeclare const mraid: MraidApi;\n\n/**\n * Creates the standard MRAID host behavior shared by networks whose CTA opens\n * the authored store URL directly through `mraid.open(url)`.\n */\nexport function createMraidHostAdapter(): HostAdapter {\n return {\n async initialize(listener): Promise<HostSnapshot> {\n requireMraid();\n await waitForMraidReady();\n\n subscribeToMraidUpdates(listener);\n subscribeToBrowserViewportChanges(listener);\n\n return {\n visible: mraid.isViewable(),\n viewport: readMraidViewport(),\n // MRAID 2 has no initial volume query. Start audible and let MRAID 3's\n // audioVolumeChange event publish the host's first authoritative value.\n volume: FULL_VOLUME,\n };\n },\n\n openStore(url): void {\n requireMraid();\n mraid.open(url);\n },\n };\n}\n\n/**\n * Supplements MRAID sizeChange with browser signals emitted by host WebViews\n * during device rotation. Runtime state deduplicates equivalent dimensions.\n */\nfunction subscribeToBrowserViewportChanges(listener: HostUpdateListener): void {\n const handleViewportChange = (): void => {\n listener({\n type: 'resize',\n viewport: readMraidViewport(),\n });\n };\n\n window.addEventListener('resize', handleViewportChange);\n window.addEventListener('orientationchange', handleViewportChange);\n}\n"],"mappings":";;;;;;AAcA,SAAgB,yBAAsC;CACpD,OAAO;EACL,MAAM,WAAW,UAAiC;GAChD,aAAa;GACb,MAAM,kBAAkB;GAExB,wBAAwB,QAAQ;GAChC,kCAAkC,QAAQ;GAE1C,OAAO;IACL,SAAS,MAAM,WAAW;IAC1B,UAAU,kBAAkB;IAG5B,QAAA;GACF;EACF;EAEA,UAAU,KAAW;GACnB,aAAa;GACb,MAAM,KAAK,GAAG;EAChB;CACF;AACF;;;;;AAMA,SAAS,kCAAkC,UAAoC;CAC7E,MAAM,6BAAmC;EACvC,SAAS;GACP,MAAM;GACN,UAAU,kBAAkB;EAC9B,CAAC;CACH;CAEA,OAAO,iBAAiB,UAAU,oBAAoB;CACtD,OAAO,iBAAiB,qBAAqB,oBAAoB;AACnE"}
@@ -0,0 +1,69 @@
1
+ //#region src/adapters/browser/api.ts
2
+ /** Waits until authored application code may safely access the parsed document. */
3
+ async function waitForDocumentReady() {
4
+ if (document.readyState !== "loading") return;
5
+ await new Promise((resolve) => {
6
+ document.addEventListener("DOMContentLoaded", () => resolve(), { once: true });
7
+ });
8
+ }
9
+ /** Captures every browser-owned lifecycle value as one consistent snapshot. */
10
+ function createBrowserSnapshot() {
11
+ return {
12
+ visible: isDocumentVisible(),
13
+ viewport: readBrowserViewport(),
14
+ volume: 1
15
+ };
16
+ }
17
+ /** Uses the visual viewport when available because it represents the visible ad area. */
18
+ function readBrowserViewport() {
19
+ const viewport = window.visualViewport;
20
+ if (viewport !== null && viewport !== void 0) return {
21
+ width: viewport.width,
22
+ height: viewport.height
23
+ };
24
+ return {
25
+ width: window.innerWidth,
26
+ height: window.innerHeight
27
+ };
28
+ }
29
+ /** Treats prerendered and background documents as not viewable. */
30
+ function isDocumentVisible() {
31
+ return document.visibilityState === "visible";
32
+ }
33
+ //#endregion
34
+ //#region src/adapters/browser/events.ts
35
+ /**
36
+ * Translates browser visibility and viewport events into Replayable host updates.
37
+ *
38
+ * The adapter intentionally publishes every browser notification. The runtime
39
+ * owns state comparison and suppresses duplicate public lifecycle events.
40
+ */
41
+ function subscribeToBrowserUpdates(listener) {
42
+ const handleVisibilityChange = () => {
43
+ listener({
44
+ type: "visibilitychange",
45
+ visible: isDocumentVisible()
46
+ });
47
+ };
48
+ const handleResize = () => {
49
+ listener({
50
+ type: "resize",
51
+ viewport: readBrowserViewport()
52
+ });
53
+ };
54
+ document.addEventListener("visibilitychange", handleVisibilityChange);
55
+ addViewportListener(handleResize);
56
+ }
57
+ /** Observes the same viewport source used by `readBrowserViewport`. */
58
+ function addViewportListener(listener) {
59
+ const viewport = window.visualViewport;
60
+ if (viewport !== null && viewport !== void 0) {
61
+ viewport.addEventListener("resize", listener);
62
+ return;
63
+ }
64
+ window.addEventListener("resize", listener);
65
+ }
66
+ //#endregion
67
+ export { waitForDocumentReady as a, readBrowserViewport as i, createBrowserSnapshot as n, isDocumentVisible as r, subscribeToBrowserUpdates as t };
68
+
69
+ //# sourceMappingURL=events-C85TpS5f.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events-C85TpS5f.js","names":[],"sources":["../src/adapters/browser/api.ts","../src/adapters/browser/events.ts"],"sourcesContent":["import { FULL_VOLUME } from '#lifecycle/volume.js';\nimport type { HostSnapshot } from '#types/host-adapter.js';\nimport type { RuntimeViewport } from '#types/screen.js';\n\n/** Waits until authored application code may safely access the parsed document. */\nexport async function waitForDocumentReady(): Promise<void> {\n if (document.readyState !== 'loading') {\n return;\n }\n\n await new Promise<void>((resolve) => {\n document.addEventListener('DOMContentLoaded', () => resolve(), { once: true });\n });\n}\n\n/** Captures every browser-owned lifecycle value as one consistent snapshot. */\nexport function createBrowserSnapshot(): HostSnapshot {\n return {\n visible: isDocumentVisible(),\n viewport: readBrowserViewport(),\n // Ordinary browsers do not expose host-controlled ad volume.\n volume: FULL_VOLUME,\n };\n}\n\n/** Uses the visual viewport when available because it represents the visible ad area. */\nexport function readBrowserViewport(): RuntimeViewport {\n const viewport = window.visualViewport;\n\n if (viewport !== null && viewport !== undefined) {\n return {\n width: viewport.width,\n height: viewport.height,\n };\n }\n\n return {\n width: window.innerWidth,\n height: window.innerHeight,\n };\n}\n\n/** Treats prerendered and background documents as not viewable. */\nexport function isDocumentVisible(): boolean {\n return document.visibilityState === 'visible';\n}\n","import type { HostUpdateListener } from '#types/host-adapter.js';\n\nimport { isDocumentVisible, readBrowserViewport } from './api.js';\n\n/**\n * Translates browser visibility and viewport events into Replayable host updates.\n *\n * The adapter intentionally publishes every browser notification. The runtime\n * owns state comparison and suppresses duplicate public lifecycle events.\n */\nexport function subscribeToBrowserUpdates(listener: HostUpdateListener): void {\n const handleVisibilityChange = (): void => {\n listener({\n type: 'visibilitychange',\n visible: isDocumentVisible(),\n });\n };\n\n const handleResize = (): void => {\n listener({\n type: 'resize',\n viewport: readBrowserViewport(),\n });\n };\n\n document.addEventListener('visibilitychange', handleVisibilityChange);\n addViewportListener(handleResize);\n}\n\n/** Observes the same viewport source used by `readBrowserViewport`. */\nfunction addViewportListener(listener: () => void): void {\n const viewport = window.visualViewport;\n\n if (viewport !== null && viewport !== undefined) {\n viewport.addEventListener('resize', listener);\n return;\n }\n\n window.addEventListener('resize', listener);\n}\n"],"mappings":";;AAKA,eAAsB,uBAAsC;CAC1D,IAAI,SAAS,eAAe,WAC1B;CAGF,MAAM,IAAI,SAAe,YAAY;EACnC,SAAS,iBAAiB,0BAA0B,QAAQ,GAAG,EAAE,MAAM,KAAK,CAAC;CAC/E,CAAC;AACH;;AAGA,SAAgB,wBAAsC;CACpD,OAAO;EACL,SAAS,kBAAkB;EAC3B,UAAU,oBAAoB;EAE9B,QAAA;CACF;AACF;;AAGA,SAAgB,sBAAuC;CACrD,MAAM,WAAW,OAAO;CAExB,IAAI,aAAa,QAAQ,aAAa,KAAA,GACpC,OAAO;EACL,OAAO,SAAS;EAChB,QAAQ,SAAS;CACnB;CAGF,OAAO;EACL,OAAO,OAAO;EACd,QAAQ,OAAO;CACjB;AACF;;AAGA,SAAgB,oBAA6B;CAC3C,OAAO,SAAS,oBAAoB;AACtC;;;;;;;;;ACnCA,SAAgB,0BAA0B,UAAoC;CAC5E,MAAM,+BAAqC;EACzC,SAAS;GACP,MAAM;GACN,SAAS,kBAAkB;EAC7B,CAAC;CACH;CAEA,MAAM,qBAA2B;EAC/B,SAAS;GACP,MAAM;GACN,UAAU,oBAAoB;EAChC,CAAC;CACH;CAEA,SAAS,iBAAiB,oBAAoB,sBAAsB;CACpE,oBAAoB,YAAY;AAClC;;AAGA,SAAS,oBAAoB,UAA4B;CACvD,MAAM,WAAW,OAAO;CAExB,IAAI,aAAa,QAAQ,aAAa,KAAA,GAAW;EAC/C,SAAS,iBAAiB,UAAU,QAAQ;EAC5C;CACF;CAEA,OAAO,iBAAiB,UAAU,QAAQ;AAC5C"}
@@ -0,0 +1,85 @@
1
+ //#region src/mraid/api.ts
2
+ /** Fails clearly when a MRAID creative runs without its host-injected SDK. */
3
+ function requireMraid() {
4
+ if (typeof mraid === "undefined") throw new Error("The active network requires the injected global mraid object.");
5
+ }
6
+ /** Waits for MRAID to leave its initial loading state before SDK access. */
7
+ async function waitForMraidReady() {
8
+ if (mraid.getState() !== "loading") return;
9
+ await new Promise((resolve) => {
10
+ const handleReady = () => {
11
+ mraid.removeEventListener("ready", handleReady);
12
+ resolve();
13
+ };
14
+ mraid.addEventListener("ready", handleReady);
15
+ });
16
+ }
17
+ /** Reads the current ad container rather than the device's physical screen. */
18
+ function readMraidViewport() {
19
+ const { height, width } = mraid.getCurrentPosition();
20
+ return {
21
+ height,
22
+ width
23
+ };
24
+ }
25
+ //#endregion
26
+ //#region src/mraid/volume.ts
27
+ /** Converts MRAID's percentage value into Replayable's normalized range. */
28
+ function normalizeMraidVolume(volume) {
29
+ const normalizedVolume = volume / 100;
30
+ return Math.min(1, Math.max(0, normalizedVolume));
31
+ }
32
+ //#endregion
33
+ //#region src/mraid/events.ts
34
+ /**
35
+ * Translates MRAID lifecycle events into Replayable host updates.
36
+ *
37
+ * MRAID 3 replaces the MRAID 2 viewability signal with a more precise exposure
38
+ * percentage and adds host audio volume. Both versions share sizeChange. The
39
+ * adapter subscribes only to the event set supported by the detected SDK version.
40
+ */
41
+ function subscribeToMraidUpdates(listener) {
42
+ const handleViewableChange = (visible) => {
43
+ listener({
44
+ type: "visibilitychange",
45
+ visible
46
+ });
47
+ };
48
+ const handleExposureChange = (exposedPercentage) => {
49
+ listener({
50
+ type: "visibilitychange",
51
+ visible: exposedPercentage > 0
52
+ });
53
+ };
54
+ const handleSizeChange = (width, height) => {
55
+ listener({
56
+ type: "resize",
57
+ viewport: {
58
+ height,
59
+ width
60
+ }
61
+ });
62
+ };
63
+ const handleAudioVolumeChange = (volume) => {
64
+ if (volume === null) return;
65
+ listener({
66
+ type: "volumechange",
67
+ volume: normalizeMraidVolume(volume)
68
+ });
69
+ };
70
+ mraid.addEventListener("sizeChange", handleSizeChange);
71
+ if (supportsMraid3()) {
72
+ mraid.addEventListener("exposureChange", handleExposureChange);
73
+ mraid.addEventListener("audioVolumeChange", handleAudioVolumeChange);
74
+ return;
75
+ }
76
+ mraid.addEventListener("viewableChange", handleViewableChange);
77
+ }
78
+ /** Enables events introduced in MRAID 3 while preserving the MRAID 2 baseline. */
79
+ function supportsMraid3() {
80
+ return Number.parseFloat(mraid.getVersion()) >= 3;
81
+ }
82
+ //#endregion
83
+ export { waitForMraidReady as i, readMraidViewport as n, requireMraid as r, subscribeToMraidUpdates as t };
84
+
85
+ //# sourceMappingURL=events-CYG_LvaH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events-CYG_LvaH.js","names":[],"sources":["../src/mraid/api.ts","../src/mraid/volume.ts","../src/mraid/events.ts"],"sourcesContent":["import type { MraidApi } from '#types/mraid.js';\nimport type { RuntimeViewport } from '#types/screen.js';\n\n/** MRAID SDK object injected by the active advertising host. */\ndeclare const mraid: MraidApi;\n\n/** Fails clearly when a MRAID creative runs without its host-injected SDK. */\nexport function requireMraid(): void {\n if (typeof mraid === 'undefined') {\n throw new Error('The active network requires the injected global mraid object.');\n }\n}\n\n/** Waits for MRAID to leave its initial loading state before SDK access. */\nexport async function waitForMraidReady(): Promise<void> {\n if (mraid.getState() !== 'loading') {\n return;\n }\n\n await new Promise<void>((resolve) => {\n const handleReady = (): void => {\n mraid.removeEventListener('ready', handleReady);\n resolve();\n };\n\n mraid.addEventListener('ready', handleReady);\n });\n}\n\n/** Reads the current ad container rather than the device's physical screen. */\nexport function readMraidViewport(): RuntimeViewport {\n const { height, width } = mraid.getCurrentPosition();\n\n return { height, width };\n}\n","import { FULL_VOLUME } from '#lifecycle/volume.js';\n\n/** Converts MRAID's percentage value into Replayable's normalized range. */\nexport function normalizeMraidVolume(volume: number): number {\n const normalizedVolume = volume / 100;\n\n return Math.min(FULL_VOLUME, Math.max(0, normalizedVolume));\n}\n","import type { HostUpdateListener } from '#types/host-adapter.js';\nimport type { MraidApi } from '#types/mraid.js';\n\nimport { normalizeMraidVolume } from './volume.js';\n\n/** MRAID SDK object injected by the active advertising host. */\ndeclare const mraid: MraidApi;\n\n/**\n * Translates MRAID lifecycle events into Replayable host updates.\n *\n * MRAID 3 replaces the MRAID 2 viewability signal with a more precise exposure\n * percentage and adds host audio volume. Both versions share sizeChange. The\n * adapter subscribes only to the event set supported by the detected SDK version.\n */\nexport function subscribeToMraidUpdates(listener: HostUpdateListener): void {\n const handleViewableChange = (visible: boolean): void => {\n listener({ type: 'visibilitychange', visible });\n };\n\n const handleExposureChange = (exposedPercentage: number): void => {\n listener({\n type: 'visibilitychange',\n visible: exposedPercentage > 0,\n });\n };\n\n const handleSizeChange = (width: number, height: number): void => {\n listener({\n type: 'resize',\n viewport: { height, width },\n });\n };\n\n const handleAudioVolumeChange = (volume: number | null): void => {\n if (volume === null) {\n return;\n }\n\n listener({\n type: 'volumechange',\n volume: normalizeMraidVolume(volume),\n });\n };\n\n mraid.addEventListener('sizeChange', handleSizeChange);\n\n if (supportsMraid3()) {\n mraid.addEventListener('exposureChange', handleExposureChange);\n mraid.addEventListener('audioVolumeChange', handleAudioVolumeChange);\n return;\n }\n\n mraid.addEventListener('viewableChange', handleViewableChange);\n}\n\n/** Enables events introduced in MRAID 3 while preserving the MRAID 2 baseline. */\nfunction supportsMraid3(): boolean {\n return Number.parseFloat(mraid.getVersion()) >= 3;\n}\n"],"mappings":";;AAOA,SAAgB,eAAqB;CACnC,IAAI,OAAO,UAAU,aACnB,MAAM,IAAI,MAAM,+DAA+D;AAEnF;;AAGA,eAAsB,oBAAmC;CACvD,IAAI,MAAM,SAAS,MAAM,WACvB;CAGF,MAAM,IAAI,SAAe,YAAY;EACnC,MAAM,oBAA0B;GAC9B,MAAM,oBAAoB,SAAS,WAAW;GAC9C,QAAQ;EACV;EAEA,MAAM,iBAAiB,SAAS,WAAW;CAC7C,CAAC;AACH;;AAGA,SAAgB,oBAAqC;CACnD,MAAM,EAAE,QAAQ,UAAU,MAAM,mBAAmB;CAEnD,OAAO;EAAE;EAAQ;CAAM;AACzB;;;;AC/BA,SAAgB,qBAAqB,QAAwB;CAC3D,MAAM,mBAAmB,SAAS;CAElC,OAAO,KAAK,IAAA,GAAiB,KAAK,IAAI,GAAG,gBAAgB,CAAC;AAC5D;;;;;;;;;;ACQA,SAAgB,wBAAwB,UAAoC;CAC1E,MAAM,wBAAwB,YAA2B;EACvD,SAAS;GAAE,MAAM;GAAoB;EAAQ,CAAC;CAChD;CAEA,MAAM,wBAAwB,sBAAoC;EAChE,SAAS;GACP,MAAM;GACN,SAAS,oBAAoB;EAC/B,CAAC;CACH;CAEA,MAAM,oBAAoB,OAAe,WAAyB;EAChE,SAAS;GACP,MAAM;GACN,UAAU;IAAE;IAAQ;GAAM;EAC5B,CAAC;CACH;CAEA,MAAM,2BAA2B,WAAgC;EAC/D,IAAI,WAAW,MACb;EAGF,SAAS;GACP,MAAM;GACN,QAAQ,qBAAqB,MAAM;EACrC,CAAC;CACH;CAEA,MAAM,iBAAiB,cAAc,gBAAgB;CAErD,IAAI,eAAe,GAAG;EACpB,MAAM,iBAAiB,kBAAkB,oBAAoB;EAC7D,MAAM,iBAAiB,qBAAqB,uBAAuB;EACnE;CACF;CAEA,MAAM,iBAAiB,kBAAkB,oBAAoB;AAC/D;;AAGA,SAAS,iBAA0B;CACjC,OAAO,OAAO,WAAW,MAAM,WAAW,CAAC,KAAK;AAClD"}
@@ -0,0 +1,43 @@
1
+ import { s as RuntimeViewport } from "./screen-DXf2FPtL.js";
2
+ //#region src/types/host-adapter.d.ts
3
+ /** Host-owned values captured after its SDK or browser environment becomes ready. */
4
+ interface HostSnapshot {
5
+ /** Host-provided volume normalized from silent (`0`) to full volume (`1`). */
6
+ readonly volume: number;
7
+ /** Whether the host currently considers the playable viewable. */
8
+ readonly visible: boolean;
9
+ /** Current dimensions of the ad container in CSS pixels. */
10
+ readonly viewport: RuntimeViewport;
11
+ }
12
+ /** One host-owned lifecycle change reported after initialization. */
13
+ type HostUpdate = {
14
+ readonly type: 'resize';
15
+ readonly viewport: RuntimeViewport;
16
+ } | {
17
+ readonly type: 'visibilitychange';
18
+ readonly visible: boolean;
19
+ } | {
20
+ readonly type: 'volumechange';
21
+ readonly volume: number;
22
+ };
23
+ /** Receives lifecycle changes from the active host adapter. */
24
+ type HostUpdateListener = (update: HostUpdate) => void;
25
+ /**
26
+ * Connects the runtime to one concrete hosting environment.
27
+ *
28
+ * Browser preview and advertising-network implementations provide the same
29
+ * normalized facts, leaving runtime state and public events host-independent.
30
+ */
31
+ interface HostAdapter {
32
+ /** Waits for the host and returns its first complete lifecycle snapshot. */
33
+ initialize(listener: HostUpdateListener): Promise<HostSnapshot>;
34
+ /** Notifies hosts that require an explicit terminal playable signal. */
35
+ notifyComplete?(): void;
36
+ /** Notifies hosts that require an explicit post-loading readiness signal. */
37
+ notifyReady?(): void;
38
+ /** Opens the supplied store destination through the hosting environment. */
39
+ openStore(url: string): void;
40
+ }
41
+ //#endregion
42
+ export { HostAdapter as t };
43
+ //# sourceMappingURL=host-adapter-vFX6DBcY.d.ts.map
@@ -0,0 +1,255 @@
1
+ import { a as RuntimeResolutionConfig, c as Screen, i as RuntimeRenderScaleConfig, l as ScreenDesign, n as RuntimeOrientationConfig, o as RuntimeScreenConfig, r as RuntimeRange, s as RuntimeViewport, t as RuntimeOrientation, u as ScreenFrame } from "./screen-DXf2FPtL.js";
2
+ import { r as AssetMode } from "./assets-BD68MQTL.js";
3
+ import { a as AudioStopOptions, i as AudioPlaybackOptions, n as AudioOneShotOptions, o as PlayableAudio, r as AudioPlayback, s as RuntimeAudioState } from "./audio-CyLjSreN.js";
4
+ import { a as AssetLoadedContext, c as BuiltInAssetCategory, d as RegisteredAssetCategory, i as AssetLoadHandler, l as BuiltInAssetValueByCategory, n as AssetCache, o as AssetLoadedListener, r as AssetLoadContext, s as AssetLoader, t as AssetBundleLoadedListener, u as LoadedShaderAsset } from "./loader-Czz-x3KH.js";
5
+ //#region src/types/completion.d.ts
6
+ /** Supported terminal outcomes reported by a playable. */
7
+ type PlayableCompletionReason = 'duration-timeout' | 'failure' | 'inactivity-timeout' | 'skip' | 'success';
8
+ /** Immutable terminal outcome committed by `playable.complete()`. */
9
+ interface PlayableCompletion {
10
+ readonly reason: PlayableCompletionReason;
11
+ }
12
+ /** Resolved automatic completion policy for the active playable variant. */
13
+ interface RuntimeCompletionConfig {
14
+ /** Maximum playable duration in seconds, when enabled. */
15
+ readonly duration?: number;
16
+ /** Network-owned point from which the duration timer begins advancing. */
17
+ readonly durationStart: 'interaction' | 'ready';
18
+ /** Allowed inactivity in seconds after the first interaction, when enabled. */
19
+ readonly inactivity?: number;
20
+ }
21
+ //#endregion
22
+ //#region src/types/controls.d.ts
23
+ /** Resolved controls: authored preview preferences or authoritative ad-network policy. */
24
+ interface RuntimeControlsConfig {
25
+ /** Whether gameplay keeps a store call to action visible. */
26
+ readonly persistentCta: boolean;
27
+ }
28
+ //#endregion
29
+ //#region src/types/devtools.d.ts
30
+ /** Explicit display and panel settings after project configuration shorthand is resolved. */
31
+ interface RuntimeStatsConfig {
32
+ /** Expanded shows all panels; compact presents one panel at a time. */
33
+ readonly display: 'expanded' | 'compact';
34
+ readonly fps: boolean;
35
+ readonly frameInterval: boolean;
36
+ /** Approximate browser-reported JavaScript heap, when supported. */
37
+ readonly jsHeap: boolean;
38
+ /** Submitted WebGL draw operations per frame; instances are not separate draws. */
39
+ readonly drawCalls: boolean;
40
+ /** WebGL bindTexture calls per frame, including repeated and null bindings. */
41
+ readonly textureBinds: boolean;
42
+ /** WebGL useProgram calls per frame, including repeated and null uses. */
43
+ readonly programUses: boolean;
44
+ }
45
+ /** Settings consumed by optional development tools, not by runtime scheduling. */
46
+ interface RuntimeDevtoolsConfig {
47
+ /** Development-only Escape shortcut and DOM Skip button. */
48
+ readonly endCardTrigger: boolean;
49
+ /** Development-only audio toggle, shown only when audio is enabled. */
50
+ readonly soundControl: boolean;
51
+ readonly stats: false | RuntimeStatsConfig;
52
+ }
53
+ //#endregion
54
+ //#region src/types/end-card.d.ts
55
+ /** Network-resolved repetition policy for automatic end-card attention effects. */
56
+ type EndCardAnimation = 'continuous' | 'finite';
57
+ /** Network-resolved interaction policy for a playable's terminal end card. */
58
+ type EndCardInteraction = 'cta-only' | 'full-screen';
59
+ /** Browser-safe end-card behavior injected by the active network profile. */
60
+ interface RuntimeEndCardConfig {
61
+ /** Determines whether automatic end-card attention effects may repeat continuously. */
62
+ readonly animation: EndCardAnimation;
63
+ /**
64
+ * Determines whether store exits are accepted only from the explicit CTA or
65
+ * from any primary pointer interaction inside the visible end card.
66
+ */
67
+ readonly interaction: EndCardInteraction;
68
+ }
69
+ //#endregion
70
+ //#region src/types/localization.d.ts
71
+ /** Runtime translation lookup over the dictionary loaded for a playable. */
72
+ interface Localization {
73
+ /** Fixed language selected for the current playable variant. */
74
+ readonly language: string;
75
+ /** Resolves one phrase using the selected language and configured fallback. */
76
+ translate(phrase: string): string;
77
+ }
78
+ //#endregion
79
+ //#region src/types/timers.d.ts
80
+ /** Configuration for one application-owned inactivity timer. */
81
+ interface InactivityTimerOptions {
82
+ /** Inactive visible time in seconds before `onTimeout` runs. */
83
+ readonly duration: number;
84
+ /** Called once after the timer has stopped itself. */
85
+ readonly onTimeout: () => void;
86
+ }
87
+ /** Controls one reusable application-owned inactivity timer. */
88
+ interface InactivityTimer {
89
+ /** Starts a stopped timer from its full duration; does nothing while already running. */
90
+ start(): void;
91
+ /** Resets the full duration and starts the timer when necessary. */
92
+ restart(): void;
93
+ /** Stops the timer and clears its elapsed inactivity. */
94
+ stop(): void;
95
+ }
96
+ /** Application-owned timers synchronized with Replayable's visible-time clock. */
97
+ interface PlayableTimers {
98
+ /** Waits for the given amount of active visible time, measured in seconds. */
99
+ delay(duration: number): Promise<void>;
100
+ /** Creates a stopped timer that resets after every trusted user interaction. */
101
+ createInactivityTimer(options: InactivityTimerOptions): InactivityTimer;
102
+ }
103
+ //#endregion
104
+ //#region src/types/update.d.ts
105
+ /** A subscription channel driven by Replayable's runtime update loop. */
106
+ interface UpdateChannel<Context> {
107
+ /**
108
+ * Adds a listener to the channel.
109
+ *
110
+ * @returns A function that removes this listener.
111
+ */
112
+ add(listener: (context: Context) => void): () => void;
113
+ }
114
+ /** Timing values delivered once for every rendered browser frame. */
115
+ interface UpdateContext {
116
+ /** Active runtime time advanced by this frame, measured in seconds. */
117
+ readonly deltaSeconds: number;
118
+ /**
119
+ * Progress toward the next fixed update, from 0 inclusive to 1 exclusive.
120
+ *
121
+ * A value of 0 is exactly on a fixed-step boundary, 0.5 is halfway toward
122
+ * the next step, and a value near 1 means another fixed update is almost due.
123
+ * It is 0 on the first frame, after resuming, and without fixed listeners.
124
+ */
125
+ readonly fixedInterpolation: number;
126
+ }
127
+ /** Delivered after Motion's update and render phases, not after GPU completion or browser paint. */
128
+ interface PostRenderContext {
129
+ /** Shared Motion frame timestamp in milliseconds; suitable for real frame intervals and identity. */
130
+ readonly timestamp: number;
131
+ }
132
+ /** Timing values delivered for one fixed simulation step. */
133
+ interface FixedUpdateContext {
134
+ /** Constant duration of this simulation step, measured in seconds. */
135
+ readonly deltaSeconds: number;
136
+ }
137
+ //#endregion
138
+ //#region src/types/runtime.d.ts
139
+ /** Resolved, browser-safe configuration for the active playable variant. */
140
+ interface RuntimeConfig {
141
+ /** Whether this concrete playable variant includes runtime audio capability. */
142
+ readonly audio: boolean;
143
+ /** First-paint color retained behind the playable's mounted content. */
144
+ readonly backgroundColor: string;
145
+ readonly completion: RuntimeCompletionConfig;
146
+ /** Resolved preview preferences or ad-network policy, with sound gated by audio capability. */
147
+ readonly controls: RuntimeControlsConfig;
148
+ readonly devtools: RuntimeDevtoolsConfig;
149
+ readonly endCard: RuntimeEndCardConfig;
150
+ readonly id: string;
151
+ readonly localization: RuntimeLocalizationConfig;
152
+ readonly network: RuntimeNetwork;
153
+ readonly params: Readonly<Record<string, RuntimeParamValue>>;
154
+ readonly screen: RuntimeScreenConfig;
155
+ readonly store: RuntimeStoreConfig;
156
+ readonly version: string;
157
+ }
158
+ /** Fixed language selected for this playable build. */
159
+ interface RuntimeLocalizationConfig {
160
+ readonly language: string;
161
+ }
162
+ /** Delivery network selected for the active playable variant. */
163
+ type RuntimeNetwork = 'applovin' | 'google' | 'liftoff' | 'meta' | 'mintegral' | 'moloco' | 'preview' | 'unity';
164
+ /** Primitive value of one resolved playable parameter. */
165
+ type RuntimeParamValue = boolean | number | string;
166
+ /** Resolved iOS and Android call-to-action destinations. */
167
+ interface RuntimeStoreConfig {
168
+ readonly androidUrl: string;
169
+ readonly iosUrl: string;
170
+ }
171
+ /** Complete value injected into runtime by Replayable's Vite configuration. */
172
+ interface RuntimeDefinition {
173
+ /** Internal representation selected by the active network profile. */
174
+ readonly assetMode: AssetMode;
175
+ readonly config: RuntimeConfig;
176
+ /** Platform-specific call-to-action destination resolved by the config entry. */
177
+ readonly storeUrl: string;
178
+ }
179
+ /** Complete normalized lifecycle state available to playable code. */
180
+ interface RuntimeState {
181
+ readonly audio: RuntimeAudioState;
182
+ /** Terminal outcome, or `undefined` while the playable remains active. */
183
+ readonly completion: PlayableCompletion | undefined;
184
+ /** Whether the user has interacted with the playable at least once. */
185
+ readonly interacted: boolean;
186
+ readonly orientation: RuntimeOrientation;
187
+ /** Whether the host currently considers the playable viewable. */
188
+ readonly visible: boolean;
189
+ readonly viewport: RuntimeViewport;
190
+ }
191
+ /** Values delivered by each public runtime lifecycle event. */
192
+ interface RuntimeEventMap {
193
+ audiochange: RuntimeAudioState;
194
+ complete: PlayableCompletion;
195
+ interaction: true;
196
+ resize: RuntimeViewport;
197
+ visibilitychange: boolean;
198
+ }
199
+ /** Listener for one public runtime lifecycle event. */
200
+ type RuntimeEventListener<Event extends keyof RuntimeEventMap> = (value: RuntimeEventMap[Event]) => void;
201
+ /** Public API for the playable currently running in the browser. */
202
+ interface Playable {
203
+ /** Initializes the selected host and loads the primary asset bundle once. */
204
+ ready(): Promise<void>;
205
+ /** Resolved configuration for the active playable variant. */
206
+ readonly config: RuntimeConfig;
207
+ /** Latest normalized lifecycle state, available after `ready()` resolves. */
208
+ readonly state: RuntimeState;
209
+ /** Screen-sized element into which the playable mounts its content. */
210
+ readonly container: HTMLElement;
211
+ /** Current engine-neutral layout derived from runtime screen state. */
212
+ readonly screen: Screen;
213
+ /** Loads generated asset bundles and retains their runtime values. */
214
+ readonly loader: AssetLoader;
215
+ /** Resolves phrases from the translation dictionary loaded through `loader`. */
216
+ readonly localization: Localization;
217
+ /** Plays sounds through Replayable's capability-aware audio facade. */
218
+ readonly audio: PlayableAudio;
219
+ /** Creates application-owned timers synchronized with visible runtime time. */
220
+ readonly timers: PlayableTimers;
221
+ /** Delivers one variable update for every rendered browser frame. */
222
+ readonly update: UpdateChannel<UpdateContext>;
223
+ /** Delivers fixed simulation steps at 60 updates per second. */
224
+ readonly fixedUpdate: UpdateChannel<FixedUpdateContext>;
225
+ /**
226
+ * Runs after Motion's update and render phases, with one shared frame timestamp.
227
+ * Follows readiness and visibility; listeners keep the runtime frame loop active.
228
+ * This observes JavaScript rendering submissions, not GPU completion or browser paint.
229
+ *
230
+ * @example
231
+ * const remove = playable.postRender.add(({ timestamp }) => {
232
+ * // Read rendering diagnostics after Pixi/Three have submitted their draws.
233
+ * console.log(timestamp);
234
+ * });
235
+ * remove();
236
+ */
237
+ readonly postRender: UpdateChannel<PostRenderContext>;
238
+ /**
239
+ * Subscribes to one lifecycle event.
240
+ *
241
+ * @returns A function that removes this listener.
242
+ */
243
+ on<Event extends keyof RuntimeEventMap>(event: Event, listener: RuntimeEventListener<Event>): () => void;
244
+ /** Commits the playable's terminal outcome exactly once. */
245
+ complete(reason: PlayableCompletionReason): void;
246
+ /** Opens the resolved app-store destination through the active host. */
247
+ openStore(): void;
248
+ }
249
+ //#endregion
250
+ //#region src/playable.d.ts
251
+ /** Public facade for the playable currently running in the browser. */
252
+ declare const playable: Playable;
253
+ //#endregion
254
+ export { type AssetBundleLoadedListener, type AssetCache, type AssetLoadContext, type AssetLoadHandler, type AssetLoadedContext, type AssetLoadedListener, type AssetLoader, type AudioOneShotOptions, type AudioPlayback, type AudioPlaybackOptions, type AudioStopOptions, type BuiltInAssetCategory, type BuiltInAssetValueByCategory, type EndCardAnimation, type EndCardInteraction, type FixedUpdateContext, type InactivityTimer, type InactivityTimerOptions, type LoadedShaderAsset, type Localization, type Playable, type PlayableAudio, type PlayableCompletion, type PlayableCompletionReason, type PlayableTimers, type PostRenderContext, type RegisteredAssetCategory, type RuntimeAudioState, type RuntimeCompletionConfig, type RuntimeConfig, type RuntimeControlsConfig, type RuntimeDefinition, type RuntimeDevtoolsConfig, type RuntimeEndCardConfig, type RuntimeEventListener, type RuntimeEventMap, type RuntimeLocalizationConfig, type RuntimeNetwork, type RuntimeOrientation, type RuntimeOrientationConfig, type RuntimeParamValue, type RuntimeRange, type RuntimeRenderScaleConfig, type RuntimeResolutionConfig, type RuntimeScreenConfig, type RuntimeState, type RuntimeStatsConfig, type RuntimeStoreConfig, type RuntimeViewport, type Screen, type ScreenDesign, type ScreenFrame, type UpdateChannel, type UpdateContext, playable };
255
+ //# sourceMappingURL=index.d.ts.map