@oasiz/sdk 1.7.0 → 1.8.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.
package/dist/index.cjs CHANGED
@@ -76,6 +76,17 @@ function triggerHaptic(type) {
76
76
  }
77
77
 
78
78
  // src/multiplayer.ts
79
+ var NULLISH_ROOM_CODES = /* @__PURE__ */ new Set(["NULL", "NIL", "UNDEFINED"]);
80
+ function readInjectedRoomCode(value) {
81
+ if (typeof value !== "string") {
82
+ return void 0;
83
+ }
84
+ const normalized = value.toUpperCase().replace(/[^A-Z0-9]/g, "");
85
+ if (normalized.length < 4 || NULLISH_ROOM_CODES.has(normalized)) {
86
+ return void 0;
87
+ }
88
+ return normalized;
89
+ }
79
90
  function isDevelopment2() {
80
91
  const nodeEnv = globalThis.process?.env?.NODE_ENV;
81
92
  return nodeEnv !== "production";
@@ -104,7 +115,7 @@ function getGameId() {
104
115
  }
105
116
  function getRoomCode() {
106
117
  const bridge = getBridgeWindow2();
107
- return bridge?.__ROOM_CODE__;
118
+ return readInjectedRoomCode(bridge?.__ROOM_CODE__);
108
119
  }
109
120
  function getPlayerName() {
110
121
  const bridge = getBridgeWindow2();
package/dist/index.js CHANGED
@@ -23,6 +23,17 @@ function triggerHaptic(type) {
23
23
  }
24
24
 
25
25
  // src/multiplayer.ts
26
+ var NULLISH_ROOM_CODES = /* @__PURE__ */ new Set(["NULL", "NIL", "UNDEFINED"]);
27
+ function readInjectedRoomCode(value) {
28
+ if (typeof value !== "string") {
29
+ return void 0;
30
+ }
31
+ const normalized = value.toUpperCase().replace(/[^A-Z0-9]/g, "");
32
+ if (normalized.length < 4 || NULLISH_ROOM_CODES.has(normalized)) {
33
+ return void 0;
34
+ }
35
+ return normalized;
36
+ }
26
37
  function isDevelopment2() {
27
38
  const nodeEnv = globalThis.process?.env?.NODE_ENV;
28
39
  return nodeEnv !== "production";
@@ -51,7 +62,7 @@ function getGameId() {
51
62
  }
52
63
  function getRoomCode() {
53
64
  const bridge = getBridgeWindow2();
54
- return bridge?.__ROOM_CODE__;
65
+ return readInjectedRoomCode(bridge?.__ROOM_CODE__);
55
66
  }
56
67
  function getPlayerName() {
57
68
  const bridge = getBridgeWindow2();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oasiz/sdk",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Typed SDK for Oasiz game platform bridge APIs.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",