@oasiz/sdk 1.5.3 → 1.5.5

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.js CHANGED
@@ -1,4 +1,4 @@
1
- // src/haptics.ts
1
+ // src/character.ts
2
2
  function isDevelopment() {
3
3
  const nodeEnv = globalThis.process?.env?.NODE_ENV;
4
4
  return nodeEnv !== "production";
@@ -9,13 +9,48 @@ function getBridgeWindow() {
9
9
  }
10
10
  return window;
11
11
  }
12
- function triggerHaptic(type) {
12
+ function warnMissingBridge(methodName) {
13
+ if (isDevelopment()) {
14
+ console.warn(
15
+ "[oasiz/sdk] " + methodName + " bridge is unavailable. This is expected in local development."
16
+ );
17
+ }
18
+ }
19
+ async function getPlayerCharacter() {
13
20
  const bridge = getBridgeWindow();
21
+ if (typeof bridge?.__oasizGetPlayerCharacter !== "function") {
22
+ warnMissingBridge("getPlayerCharacter");
23
+ return null;
24
+ }
25
+ try {
26
+ const result = await bridge.__oasizGetPlayerCharacter();
27
+ return result ?? null;
28
+ } catch (error) {
29
+ if (isDevelopment()) {
30
+ console.error("[oasiz/sdk] getPlayerCharacter failed:", error);
31
+ }
32
+ return null;
33
+ }
34
+ }
35
+
36
+ // src/haptics.ts
37
+ function isDevelopment2() {
38
+ const nodeEnv = globalThis.process?.env?.NODE_ENV;
39
+ return nodeEnv !== "production";
40
+ }
41
+ function getBridgeWindow2() {
42
+ if (typeof window === "undefined") {
43
+ return void 0;
44
+ }
45
+ return window;
46
+ }
47
+ function triggerHaptic(type) {
48
+ const bridge = getBridgeWindow2();
14
49
  if (typeof bridge?.triggerHaptic === "function") {
15
50
  bridge.triggerHaptic(type);
16
51
  return;
17
52
  }
18
- if (isDevelopment()) {
53
+ if (isDevelopment2()) {
19
54
  console.warn(
20
55
  "[oasiz/sdk] triggerHaptic bridge is unavailable. This is expected in local development."
21
56
  );
@@ -914,70 +949,74 @@ function enableLogOverlay(options = {}) {
914
949
  }
915
950
 
916
951
  // src/multiplayer.ts
917
- function isDevelopment2() {
952
+ function isDevelopment3() {
918
953
  const nodeEnv = globalThis.process?.env?.NODE_ENV;
919
954
  return nodeEnv !== "production";
920
955
  }
921
- function getBridgeWindow2() {
956
+ function getBridgeWindow3() {
922
957
  if (typeof window === "undefined") {
923
958
  return void 0;
924
959
  }
925
960
  return window;
926
961
  }
927
962
  function shareRoomCode(roomCode, options) {
928
- const bridge = getBridgeWindow2();
963
+ const bridge = getBridgeWindow3();
929
964
  if (typeof bridge?.shareRoomCode === "function") {
930
965
  bridge.shareRoomCode(roomCode, options);
931
966
  return;
932
967
  }
933
- if (isDevelopment2()) {
968
+ if (isDevelopment3()) {
934
969
  console.warn(
935
970
  "[oasiz/sdk] shareRoomCode bridge is unavailable. This is expected in local development."
936
971
  );
937
972
  }
938
973
  }
939
974
  function openInviteModal() {
940
- const bridge = getBridgeWindow2();
975
+ const bridge = getBridgeWindow3();
941
976
  if (typeof bridge?.openInviteModal === "function") {
942
977
  bridge.openInviteModal();
943
978
  return;
944
979
  }
945
- if (isDevelopment2()) {
980
+ if (isDevelopment3()) {
946
981
  console.warn(
947
982
  "[oasiz/sdk] openInviteModal bridge is unavailable. This is expected in local development."
948
983
  );
949
984
  }
950
985
  }
951
986
  function getGameId() {
952
- const bridge = getBridgeWindow2();
987
+ const bridge = getBridgeWindow3();
953
988
  return bridge?.__GAME_ID__;
954
989
  }
955
990
  function getRoomCode() {
956
- const bridge = getBridgeWindow2();
991
+ const bridge = getBridgeWindow3();
957
992
  return bridge?.__ROOM_CODE__;
958
993
  }
994
+ function getPlayerId() {
995
+ const bridge = getBridgeWindow3();
996
+ return bridge?.__PLAYER_ID__;
997
+ }
959
998
  function getPlayerName() {
960
- const bridge = getBridgeWindow2();
999
+ const bridge = getBridgeWindow3();
961
1000
  return bridge?.__PLAYER_NAME__;
962
1001
  }
963
1002
  function getPlayerAvatar() {
964
- const bridge = getBridgeWindow2();
1003
+ const bridge = getBridgeWindow3();
965
1004
  return bridge?.__PLAYER_AVATAR__;
966
1005
  }
967
1006
 
968
1007
  // src/score.ts
969
- function isDevelopment3() {
1008
+ function isDevelopment4() {
970
1009
  const nodeEnv = globalThis.process?.env?.NODE_ENV;
971
1010
  return nodeEnv !== "production";
972
1011
  }
973
- function warnMissingBridge(methodName) {
974
- if (isDevelopment3()) {
1012
+ function warnMissingBridge2(methodName) {
1013
+ if (isDevelopment4()) {
975
1014
  console.warn(
976
1015
  "[oasiz/sdk] " + methodName + " bridge is unavailable. This is expected in local development."
977
1016
  );
978
1017
  }
979
1018
  }
980
- function getBridgeWindow3() {
1019
+ function getBridgeWindow4() {
981
1020
  if (typeof window === "undefined") {
982
1021
  return void 0;
983
1022
  }
@@ -985,33 +1024,92 @@ function getBridgeWindow3() {
985
1024
  }
986
1025
  function submitScore(score) {
987
1026
  if (!Number.isFinite(score)) {
988
- if (isDevelopment3()) {
1027
+ if (isDevelopment4()) {
989
1028
  console.warn("[oasiz/sdk] submitScore expected a finite number:", score);
990
1029
  }
991
1030
  return;
992
1031
  }
993
- const bridge = getBridgeWindow3();
1032
+ const bridge = getBridgeWindow4();
994
1033
  const normalizedScore = Math.max(0, Math.floor(score));
995
1034
  if (typeof bridge?.submitScore === "function") {
996
1035
  bridge.submitScore(normalizedScore);
997
1036
  return;
998
1037
  }
999
- warnMissingBridge("submitScore");
1038
+ warnMissingBridge2("submitScore");
1039
+ }
1040
+
1041
+ // src/score-edit.ts
1042
+ function isDevelopment5() {
1043
+ const nodeEnv = globalThis.process?.env?.NODE_ENV;
1044
+ return nodeEnv !== "production";
1045
+ }
1046
+ function getBridgeWindow5() {
1047
+ if (typeof window === "undefined") {
1048
+ return void 0;
1049
+ }
1050
+ return window;
1051
+ }
1052
+ function warnMissingBridge3(methodName) {
1053
+ if (isDevelopment5()) {
1054
+ console.warn(
1055
+ "[oasiz/sdk] " + methodName + " bridge is unavailable. This is expected in local development."
1056
+ );
1057
+ }
1058
+ }
1059
+ async function editScore(payload, methodName) {
1060
+ const bridge = getBridgeWindow5();
1061
+ if (typeof bridge?.__oasizEditScore !== "function") {
1062
+ warnMissingBridge3(methodName);
1063
+ return null;
1064
+ }
1065
+ try {
1066
+ const result = await bridge.__oasizEditScore(payload);
1067
+ return result ?? null;
1068
+ } catch (error) {
1069
+ if (isDevelopment5()) {
1070
+ console.error("[oasiz/sdk] " + methodName + " failed:", error);
1071
+ }
1072
+ return null;
1073
+ }
1074
+ }
1075
+ async function addScore(delta) {
1076
+ if (!Number.isInteger(delta)) {
1077
+ if (isDevelopment5()) {
1078
+ console.warn("[oasiz/sdk] addScore expected an integer:", delta);
1079
+ }
1080
+ return null;
1081
+ }
1082
+ if (delta === 0) {
1083
+ return null;
1084
+ }
1085
+ return editScore({ delta }, "addScore");
1086
+ }
1087
+ async function setScore(score) {
1088
+ if (!Number.isInteger(score) || score < 0) {
1089
+ if (isDevelopment5()) {
1090
+ console.warn(
1091
+ "[oasiz/sdk] setScore expected a non-negative integer:",
1092
+ score
1093
+ );
1094
+ }
1095
+ return null;
1096
+ }
1097
+ return editScore({ score }, "setScore");
1000
1098
  }
1001
1099
 
1002
1100
  // src/share.ts
1003
- function isDevelopment4() {
1101
+ function isDevelopment6() {
1004
1102
  const nodeEnv = globalThis.process?.env?.NODE_ENV;
1005
1103
  return nodeEnv !== "production";
1006
1104
  }
1007
- function getBridgeWindow4() {
1105
+ function getBridgeWindow6() {
1008
1106
  if (typeof window === "undefined") {
1009
1107
  return void 0;
1010
1108
  }
1011
1109
  return window;
1012
1110
  }
1013
- function warnMissingBridge2(methodName) {
1014
- if (isDevelopment4()) {
1111
+ function warnMissingBridge4(methodName) {
1112
+ if (isDevelopment6()) {
1015
1113
  console.warn(
1016
1114
  "[oasiz/sdk] " + methodName + " share bridge is unavailable. This is expected in local development."
1017
1115
  );
@@ -1054,20 +1152,20 @@ function validateRequest(options) {
1054
1152
  }
1055
1153
  async function share(options) {
1056
1154
  const request = validateRequest(options);
1057
- const bridge = getBridgeWindow4();
1155
+ const bridge = getBridgeWindow6();
1058
1156
  if (typeof bridge?.__oasizShareRequest !== "function") {
1059
- warnMissingBridge2("__oasizShareRequest");
1157
+ warnMissingBridge4("__oasizShareRequest");
1060
1158
  throw new Error("Share bridge unavailable");
1061
1159
  }
1062
1160
  await bridge.__oasizShareRequest(request);
1063
1161
  }
1064
1162
 
1065
1163
  // src/state.ts
1066
- function isDevelopment5() {
1164
+ function isDevelopment7() {
1067
1165
  const nodeEnv = globalThis.process?.env?.NODE_ENV;
1068
1166
  return nodeEnv !== "production";
1069
1167
  }
1070
- function getBridgeWindow5() {
1168
+ function getBridgeWindow7() {
1071
1169
  if (typeof window === "undefined") {
1072
1170
  return void 0;
1073
1171
  }
@@ -1080,22 +1178,22 @@ function isPlainObject(value) {
1080
1178
  const proto = Object.getPrototypeOf(value);
1081
1179
  return proto === Object.prototype || proto === null;
1082
1180
  }
1083
- function warnMissingBridge3(methodName) {
1084
- if (isDevelopment5()) {
1181
+ function warnMissingBridge5(methodName) {
1182
+ if (isDevelopment7()) {
1085
1183
  console.warn(
1086
1184
  "[oasiz/sdk] " + methodName + " bridge is unavailable. This is expected in local development."
1087
1185
  );
1088
1186
  }
1089
1187
  }
1090
1188
  function loadGameState() {
1091
- const bridge = getBridgeWindow5();
1189
+ const bridge = getBridgeWindow7();
1092
1190
  if (typeof bridge?.loadGameState !== "function") {
1093
- warnMissingBridge3("loadGameState");
1191
+ warnMissingBridge5("loadGameState");
1094
1192
  return {};
1095
1193
  }
1096
1194
  const state = bridge.loadGameState();
1097
1195
  if (!isPlainObject(state)) {
1098
- if (isDevelopment5()) {
1196
+ if (isDevelopment7()) {
1099
1197
  console.warn(
1100
1198
  "[oasiz/sdk] loadGameState returned invalid data. Falling back to empty object."
1101
1199
  );
@@ -1106,35 +1204,35 @@ function loadGameState() {
1106
1204
  }
1107
1205
  function saveGameState(state) {
1108
1206
  if (!isPlainObject(state)) {
1109
- if (isDevelopment5()) {
1207
+ if (isDevelopment7()) {
1110
1208
  console.warn("[oasiz/sdk] saveGameState expected a plain object:", state);
1111
1209
  }
1112
1210
  return;
1113
1211
  }
1114
- const bridge = getBridgeWindow5();
1212
+ const bridge = getBridgeWindow7();
1115
1213
  if (typeof bridge?.saveGameState === "function") {
1116
1214
  bridge.saveGameState(state);
1117
1215
  return;
1118
1216
  }
1119
- warnMissingBridge3("saveGameState");
1217
+ warnMissingBridge5("saveGameState");
1120
1218
  }
1121
1219
  function flushGameState() {
1122
- const bridge = getBridgeWindow5();
1220
+ const bridge = getBridgeWindow7();
1123
1221
  if (typeof bridge?.flushGameState === "function") {
1124
1222
  bridge.flushGameState();
1125
1223
  return;
1126
1224
  }
1127
- warnMissingBridge3("flushGameState");
1225
+ warnMissingBridge5("flushGameState");
1128
1226
  }
1129
1227
 
1130
1228
  // src/lifecycle.ts
1131
- function isDevelopment6() {
1229
+ function isDevelopment8() {
1132
1230
  const nodeEnv = globalThis.process?.env?.NODE_ENV;
1133
1231
  return nodeEnv !== "production";
1134
1232
  }
1135
1233
  function addLifecycleListener(eventName, callback) {
1136
1234
  if (typeof window === "undefined") {
1137
- if (isDevelopment6()) {
1235
+ if (isDevelopment8()) {
1138
1236
  console.warn(
1139
1237
  "[oasiz/sdk] " + eventName + " listener registered without a browser window. This is expected in local development."
1140
1238
  );
@@ -1154,74 +1252,187 @@ function onResume(callback) {
1154
1252
  }
1155
1253
 
1156
1254
  // src/layout.ts
1157
- function isDevelopment7() {
1255
+ function isDevelopment9() {
1158
1256
  const nodeEnv = globalThis.process?.env?.NODE_ENV;
1159
1257
  return nodeEnv !== "production";
1160
1258
  }
1161
- function getBridgeWindow6() {
1259
+ function getBridgeWindow8() {
1162
1260
  if (typeof window === "undefined") {
1163
1261
  return void 0;
1164
1262
  }
1165
1263
  return window;
1166
1264
  }
1167
- function warnMissingBridge4(methodName) {
1168
- if (isDevelopment7()) {
1265
+ function warnMissingBridge6(methodName) {
1266
+ if (isDevelopment9()) {
1169
1267
  console.warn(
1170
1268
  "[oasiz/sdk] " + methodName + " bridge is unavailable. This is expected in local development."
1171
1269
  );
1172
1270
  }
1173
1271
  }
1174
- function normalizeSafeAreaTopPixels(value) {
1272
+ function toFiniteNumber(value) {
1175
1273
  if (typeof value !== "number" || !Number.isFinite(value)) {
1274
+ if (typeof value !== "string") {
1275
+ return void 0;
1276
+ }
1277
+ const parsed = Number.parseFloat(value.trim());
1278
+ if (!Number.isFinite(parsed)) {
1279
+ return void 0;
1280
+ }
1281
+ return parsed;
1282
+ }
1283
+ return value;
1284
+ }
1285
+ function clampSafeAreaTopPixels(value) {
1286
+ const numeric = toFiniteNumber(value);
1287
+ if (typeof numeric === "undefined") {
1176
1288
  return 0;
1177
1289
  }
1178
- return Math.max(0, value);
1290
+ return Math.max(0, numeric);
1179
1291
  }
1180
1292
  function normalizeSafeAreaTopPercent(value) {
1181
- if (typeof value !== "number" || !Number.isFinite(value)) {
1182
- return 0;
1293
+ const numeric = toFiniteNumber(value);
1294
+ if (typeof numeric === "undefined") {
1295
+ return void 0;
1183
1296
  }
1184
- return Math.min(100, Math.max(0, value));
1297
+ return Math.min(100, Math.max(0, numeric));
1298
+ }
1299
+ function getViewportHeight(bridge) {
1300
+ const visualViewportHeight = bridge.visualViewport?.height;
1301
+ if (typeof visualViewportHeight === "number" && Number.isFinite(visualViewportHeight) && visualViewportHeight > 0) {
1302
+ return visualViewportHeight;
1303
+ }
1304
+ const innerHeight = bridge.innerHeight;
1305
+ if (typeof innerHeight === "number" && Number.isFinite(innerHeight) && innerHeight > 0) {
1306
+ return innerHeight;
1307
+ }
1308
+ const documentHeight = bridge.document?.documentElement?.clientHeight;
1309
+ if (typeof documentHeight === "number" && Number.isFinite(documentHeight) && documentHeight > 0) {
1310
+ return documentHeight;
1311
+ }
1312
+ const bodyHeight = bridge.document?.body?.clientHeight;
1313
+ if (typeof bodyHeight === "number" && Number.isFinite(bodyHeight) && bodyHeight > 0) {
1314
+ return bodyHeight;
1315
+ }
1316
+ return 0;
1185
1317
  }
1186
- function viewportInnerHeight(bridge) {
1187
- const h = bridge.innerHeight;
1188
- if (typeof h !== "number" || !Number.isFinite(h) || h <= 0) {
1318
+ function readCssSafeAreaValue(bridge, cssValue) {
1319
+ const doc = bridge.document;
1320
+ const root = doc?.body ?? doc?.documentElement;
1321
+ if (!doc || !root || typeof doc.createElement !== "function" || typeof root.appendChild !== "function" || typeof bridge.getComputedStyle !== "function") {
1189
1322
  return 0;
1190
1323
  }
1191
- return h;
1324
+ const probe = doc.createElement("div");
1325
+ probe.style.position = "fixed";
1326
+ probe.style.top = "0";
1327
+ probe.style.left = "0";
1328
+ probe.style.width = "0";
1329
+ probe.style.height = "0";
1330
+ probe.style.visibility = "hidden";
1331
+ probe.style.pointerEvents = "none";
1332
+ probe.style.paddingTop = cssValue;
1333
+ root.appendChild(probe);
1334
+ try {
1335
+ return clampSafeAreaTopPixels(bridge.getComputedStyle(probe).paddingTop);
1336
+ } finally {
1337
+ if (typeof probe.remove === "function") {
1338
+ probe.remove();
1339
+ } else {
1340
+ probe.parentNode?.removeChild(probe);
1341
+ }
1342
+ }
1343
+ }
1344
+ function readCssSafeAreaTopPixels(bridge) {
1345
+ const envPixels = readCssSafeAreaValue(bridge, "env(safe-area-inset-top)");
1346
+ if (envPixels > 0) {
1347
+ return envPixels;
1348
+ }
1349
+ return readCssSafeAreaValue(bridge, "constant(safe-area-inset-top)");
1350
+ }
1351
+ function getDevicePixelRatio(bridge) {
1352
+ const dpr = bridge.devicePixelRatio;
1353
+ if (typeof dpr !== "number" || !Number.isFinite(dpr) || dpr <= 0) {
1354
+ return 1;
1355
+ }
1356
+ return dpr;
1357
+ }
1358
+ function roughlyEqualPixels(a, b) {
1359
+ return Math.abs(a - b) <= 2;
1360
+ }
1361
+ function normalizeSafeAreaTopPixels(value, bridge) {
1362
+ const pixels = clampSafeAreaTopPixels(value);
1363
+ const cssEnvPixels = readCssSafeAreaTopPixels(bridge);
1364
+ if (pixels <= 0) {
1365
+ return cssEnvPixels;
1366
+ }
1367
+ const dpr = getDevicePixelRatio(bridge);
1368
+ if (cssEnvPixels > 0 && dpr > 1 && roughlyEqualPixels(pixels / dpr, cssEnvPixels)) {
1369
+ return cssEnvPixels;
1370
+ }
1371
+ return pixels;
1192
1372
  }
1193
1373
  function pixelsTopToPercentOfViewport(pixels, bridge) {
1194
- const h = viewportInnerHeight(bridge);
1374
+ const h = getViewportHeight(bridge);
1195
1375
  if (h <= 0) {
1196
1376
  return 0;
1197
1377
  }
1198
- return normalizeSafeAreaTopPercent(pixels / h * 100);
1378
+ return normalizeSafeAreaTopPercent(pixels / h * 100) ?? 0;
1379
+ }
1380
+ function cssSafeAreaTopPercent(bridge) {
1381
+ return pixelsTopToPercentOfViewport(readCssSafeAreaTopPixels(bridge), bridge);
1382
+ }
1383
+ function resolvePercentValue(value, bridge) {
1384
+ const percent = normalizeSafeAreaTopPercent(value);
1385
+ if (typeof percent === "undefined") {
1386
+ return void 0;
1387
+ }
1388
+ return percent > 0 ? percent : cssSafeAreaTopPercent(bridge);
1389
+ }
1390
+ function resolvePixelValue(value, bridge) {
1391
+ const numeric = toFiniteNumber(value);
1392
+ if (typeof numeric === "undefined") {
1393
+ return void 0;
1394
+ }
1395
+ return pixelsTopToPercentOfViewport(normalizeSafeAreaTopPixels(numeric, bridge), bridge);
1199
1396
  }
1200
1397
  function getSafeAreaTop() {
1201
- const bridge = getBridgeWindow6();
1398
+ const bridge = getBridgeWindow8();
1202
1399
  if (!bridge) {
1203
1400
  return 0;
1204
1401
  }
1205
1402
  if (typeof bridge.getSafeAreaTopPercent === "function") {
1206
- return normalizeSafeAreaTopPercent(bridge.getSafeAreaTopPercent());
1403
+ const percent = resolvePercentValue(bridge.getSafeAreaTopPercent(), bridge);
1404
+ if (typeof percent !== "undefined") {
1405
+ return percent;
1406
+ }
1207
1407
  }
1208
1408
  if (typeof bridge.__OASIZ_SAFE_AREA_TOP_PERCENT__ !== "undefined") {
1209
- return normalizeSafeAreaTopPercent(bridge.__OASIZ_SAFE_AREA_TOP_PERCENT__);
1409
+ const percent = resolvePercentValue(bridge.__OASIZ_SAFE_AREA_TOP_PERCENT__, bridge);
1410
+ if (typeof percent !== "undefined") {
1411
+ return percent;
1412
+ }
1210
1413
  }
1211
1414
  if (typeof bridge.getSafeAreaTop === "function") {
1212
- const px = normalizeSafeAreaTopPixels(bridge.getSafeAreaTop());
1213
- return pixelsTopToPercentOfViewport(px, bridge);
1415
+ const percent = resolvePixelValue(bridge.getSafeAreaTop(), bridge);
1416
+ if (typeof percent !== "undefined") {
1417
+ return percent;
1418
+ }
1214
1419
  }
1215
1420
  if (typeof bridge.__OASIZ_SAFE_AREA_TOP__ !== "undefined") {
1216
- const px = normalizeSafeAreaTopPixels(bridge.__OASIZ_SAFE_AREA_TOP__);
1217
- return pixelsTopToPercentOfViewport(px, bridge);
1421
+ const percent = resolvePixelValue(bridge.__OASIZ_SAFE_AREA_TOP__, bridge);
1422
+ if (typeof percent !== "undefined") {
1423
+ return percent;
1424
+ }
1425
+ }
1426
+ const cssPercent = cssSafeAreaTopPercent(bridge);
1427
+ if (cssPercent > 0) {
1428
+ return cssPercent;
1218
1429
  }
1219
- warnMissingBridge4("getSafeAreaTop");
1430
+ warnMissingBridge6("getSafeAreaTop");
1220
1431
  return 0;
1221
1432
  }
1222
1433
  function setLeaderboardVisible(visible) {
1223
1434
  if (typeof visible !== "boolean") {
1224
- if (isDevelopment7()) {
1435
+ if (isDevelopment9()) {
1225
1436
  console.warn(
1226
1437
  "[oasiz/sdk] setLeaderboardVisible expected a boolean:",
1227
1438
  visible
@@ -1229,28 +1440,28 @@ function setLeaderboardVisible(visible) {
1229
1440
  }
1230
1441
  return;
1231
1442
  }
1232
- const bridge = getBridgeWindow6();
1443
+ const bridge = getBridgeWindow8();
1233
1444
  if (typeof bridge?.__oasizSetLeaderboardVisible === "function") {
1234
1445
  bridge.__oasizSetLeaderboardVisible(visible);
1235
1446
  return;
1236
1447
  }
1237
- warnMissingBridge4("__oasizSetLeaderboardVisible");
1448
+ warnMissingBridge6("__oasizSetLeaderboardVisible");
1238
1449
  }
1239
1450
 
1240
1451
  // src/navigation.ts
1241
1452
  var activeBackListeners = 0;
1242
- function isDevelopment8() {
1453
+ function isDevelopment10() {
1243
1454
  const nodeEnv = globalThis.process?.env?.NODE_ENV;
1244
1455
  return nodeEnv !== "production";
1245
1456
  }
1246
- function getBridgeWindow7() {
1457
+ function getBridgeWindow9() {
1247
1458
  if (typeof window === "undefined") {
1248
1459
  return void 0;
1249
1460
  }
1250
1461
  return window;
1251
1462
  }
1252
- function warnMissingBridge5(methodName) {
1253
- if (isDevelopment8()) {
1463
+ function warnMissingBridge7(methodName) {
1464
+ if (isDevelopment10()) {
1254
1465
  console.warn(
1255
1466
  "[oasiz/sdk] " + methodName + " bridge is unavailable. This is expected in local development."
1256
1467
  );
@@ -1266,7 +1477,7 @@ function normalizeNavigationError(error) {
1266
1477
  }
1267
1478
  function addNavigationListener(eventName, callback) {
1268
1479
  if (typeof window === "undefined") {
1269
- if (isDevelopment8()) {
1480
+ if (isDevelopment10()) {
1270
1481
  console.warn(
1271
1482
  "[oasiz/sdk] " + eventName + " listener registered without a browser window. This is expected in local development."
1272
1483
  );
@@ -1287,24 +1498,24 @@ function onBackButton(callback) {
1287
1498
  throw normalizeNavigationError(error);
1288
1499
  }
1289
1500
  });
1290
- const bridge = getBridgeWindow7();
1501
+ const bridge = getBridgeWindow9();
1291
1502
  activeBackListeners += 1;
1292
1503
  if (activeBackListeners === 1) {
1293
1504
  if (typeof bridge?.__oasizSetBackOverride === "function") {
1294
1505
  bridge.__oasizSetBackOverride(true);
1295
1506
  } else {
1296
- warnMissingBridge5("__oasizSetBackOverride");
1507
+ warnMissingBridge7("__oasizSetBackOverride");
1297
1508
  }
1298
1509
  }
1299
1510
  return () => {
1300
1511
  off();
1301
1512
  activeBackListeners = Math.max(0, activeBackListeners - 1);
1302
1513
  if (activeBackListeners === 0) {
1303
- const currentBridge = getBridgeWindow7();
1514
+ const currentBridge = getBridgeWindow9();
1304
1515
  if (typeof currentBridge?.__oasizSetBackOverride === "function") {
1305
1516
  currentBridge.__oasizSetBackOverride(false);
1306
1517
  } else {
1307
- warnMissingBridge5("__oasizSetBackOverride");
1518
+ warnMissingBridge7("__oasizSetBackOverride");
1308
1519
  }
1309
1520
  }
1310
1521
  };
@@ -1313,17 +1524,20 @@ function onLeaveGame(callback) {
1313
1524
  return addNavigationListener("oasiz:leave", callback);
1314
1525
  }
1315
1526
  function leaveGame() {
1316
- const bridge = getBridgeWindow7();
1527
+ const bridge = getBridgeWindow9();
1317
1528
  if (typeof bridge?.__oasizLeaveGame === "function") {
1318
1529
  bridge.__oasizLeaveGame();
1319
1530
  return;
1320
1531
  }
1321
- warnMissingBridge5("__oasizLeaveGame");
1532
+ warnMissingBridge7("__oasizLeaveGame");
1322
1533
  }
1323
1534
 
1324
1535
  // src/index.ts
1325
1536
  var oasiz = {
1326
1537
  submitScore,
1538
+ addScore,
1539
+ setScore,
1540
+ getPlayerCharacter,
1327
1541
  share,
1328
1542
  triggerHaptic,
1329
1543
  enableLogOverlay,
@@ -1345,6 +1559,9 @@ var oasiz = {
1345
1559
  get roomCode() {
1346
1560
  return getRoomCode();
1347
1561
  },
1562
+ get playerId() {
1563
+ return getPlayerId();
1564
+ },
1348
1565
  get playerName() {
1349
1566
  return getPlayerName();
1350
1567
  },
@@ -1356,10 +1573,13 @@ var oasiz = {
1356
1573
  }
1357
1574
  };
1358
1575
  export {
1576
+ addScore,
1359
1577
  enableLogOverlay,
1360
1578
  flushGameState,
1361
1579
  getGameId,
1362
1580
  getPlayerAvatar,
1581
+ getPlayerCharacter,
1582
+ getPlayerId,
1363
1583
  getPlayerName,
1364
1584
  getRoomCode,
1365
1585
  getSafeAreaTop,
@@ -1373,6 +1593,7 @@ export {
1373
1593
  openInviteModal,
1374
1594
  saveGameState,
1375
1595
  setLeaderboardVisible,
1596
+ setScore,
1376
1597
  share,
1377
1598
  shareRoomCode,
1378
1599
  submitScore,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oasiz/sdk",
3
- "version": "1.5.3",
3
+ "version": "1.5.5",
4
4
  "description": "Typed SDK for Oasiz game platform bridge APIs.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",