@playcademy/sdk 0.0.1-beta.8 → 0.0.1-beta.9

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/dist/bus.d.ts CHANGED
@@ -8,7 +8,7 @@ export declare enum BusEvents {
8
8
  OVERLAY = "PLAYCADEMY_OVERLAY",
9
9
  READY = "PLAYCADEMY_READY",
10
10
  EXIT = "PLAYCADEMY_EXIT",
11
- TELEMETRY = "PLAYCADEMY_TELEMETRY"
11
+ TELEMETRY = "PLAYCADEMY_TELEMETRYYYYYYYYYYY"
12
12
  }
13
13
  type BusHandler<T = unknown> = (payload: T) => void;
14
14
  export type BusEventMap = {
@@ -89,10 +89,10 @@ export declare class PlaycademyClient {
89
89
  } & {
90
90
  [k: string]: unknown;
91
91
  }) | null;
92
+ gameId: string | null;
92
93
  mapId: string | null;
93
94
  elementSlug: string;
94
95
  interactionType: "game_entry" | "game_registry" | "info" | "teleport" | "door_in" | "door_out" | "npc_interaction" | "quest_trigger";
95
- gameId: string | null;
96
96
  }[]>;
97
97
  };
98
98
  admin: {
package/dist/runtime.js CHANGED
@@ -9,12 +9,26 @@ var BusEvents;
9
9
  BusEvents2["OVERLAY"] = "PLAYCADEMY_OVERLAY";
10
10
  BusEvents2["READY"] = "PLAYCADEMY_READY";
11
11
  BusEvents2["EXIT"] = "PLAYCADEMY_EXIT";
12
- BusEvents2["TELEMETRY"] = "PLAYCADEMY_TELEMETRY";
12
+ BusEvents2["TELEMETRY"] = "PLAYCADEMY_TELEMETRYYYYYYYYYYY";
13
13
  })(BusEvents ||= {});
14
14
  var busListeners = new Map;
15
15
  var bus = {
16
16
  emit(type, payload) {
17
- window.dispatchEvent(new CustomEvent(type, { detail: payload }));
17
+ const isIframe = typeof window !== "undefined" && window.self !== window.top;
18
+ const iframeToParentEvents = [
19
+ "PLAYCADEMY_READY" /* READY */,
20
+ "PLAYCADEMY_EXIT" /* EXIT */,
21
+ "PLAYCADEMY_TELEMETRYYYYYYYYYYY" /* TELEMETRY */
22
+ ];
23
+ if (isIframe && iframeToParentEvents.includes(type)) {
24
+ let messageData = { type };
25
+ if (payload !== undefined && typeof payload === "object" && payload !== null) {
26
+ messageData = { ...messageData, ...payload };
27
+ }
28
+ window.parent.postMessage(messageData, "*");
29
+ } else {
30
+ window.dispatchEvent(new CustomEvent(type, { detail: payload }));
31
+ }
18
32
  },
19
33
  on(type, handler) {
20
34
  const listener = (event) => handler(event.detail);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@playcademy/sdk",
3
3
  "type": "module",
4
- "version": "0.0.1-beta.8",
4
+ "version": "0.0.1-beta.9",
5
5
  "exports": {
6
6
  ".": {
7
7
  "import": "./dist/runtime.js",