@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.cjs CHANGED
@@ -20,10 +20,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ addScore: () => addScore,
23
24
  enableLogOverlay: () => enableLogOverlay,
24
25
  flushGameState: () => flushGameState,
25
26
  getGameId: () => getGameId,
26
27
  getPlayerAvatar: () => getPlayerAvatar,
28
+ getPlayerCharacter: () => getPlayerCharacter,
29
+ getPlayerId: () => getPlayerId,
27
30
  getPlayerName: () => getPlayerName,
28
31
  getRoomCode: () => getRoomCode,
29
32
  getSafeAreaTop: () => getSafeAreaTop,
@@ -37,6 +40,7 @@ __export(index_exports, {
37
40
  openInviteModal: () => openInviteModal,
38
41
  saveGameState: () => saveGameState,
39
42
  setLeaderboardVisible: () => setLeaderboardVisible,
43
+ setScore: () => setScore,
40
44
  share: () => share,
41
45
  shareRoomCode: () => shareRoomCode,
42
46
  submitScore: () => submitScore,
@@ -44,7 +48,7 @@ __export(index_exports, {
44
48
  });
45
49
  module.exports = __toCommonJS(index_exports);
46
50
 
47
- // src/haptics.ts
51
+ // src/character.ts
48
52
  function isDevelopment() {
49
53
  const nodeEnv = globalThis.process?.env?.NODE_ENV;
50
54
  return nodeEnv !== "production";
@@ -55,13 +59,48 @@ function getBridgeWindow() {
55
59
  }
56
60
  return window;
57
61
  }
58
- function triggerHaptic(type) {
62
+ function warnMissingBridge(methodName) {
63
+ if (isDevelopment()) {
64
+ console.warn(
65
+ "[oasiz/sdk] " + methodName + " bridge is unavailable. This is expected in local development."
66
+ );
67
+ }
68
+ }
69
+ async function getPlayerCharacter() {
59
70
  const bridge = getBridgeWindow();
71
+ if (typeof bridge?.__oasizGetPlayerCharacter !== "function") {
72
+ warnMissingBridge("getPlayerCharacter");
73
+ return null;
74
+ }
75
+ try {
76
+ const result = await bridge.__oasizGetPlayerCharacter();
77
+ return result ?? null;
78
+ } catch (error) {
79
+ if (isDevelopment()) {
80
+ console.error("[oasiz/sdk] getPlayerCharacter failed:", error);
81
+ }
82
+ return null;
83
+ }
84
+ }
85
+
86
+ // src/haptics.ts
87
+ function isDevelopment2() {
88
+ const nodeEnv = globalThis.process?.env?.NODE_ENV;
89
+ return nodeEnv !== "production";
90
+ }
91
+ function getBridgeWindow2() {
92
+ if (typeof window === "undefined") {
93
+ return void 0;
94
+ }
95
+ return window;
96
+ }
97
+ function triggerHaptic(type) {
98
+ const bridge = getBridgeWindow2();
60
99
  if (typeof bridge?.triggerHaptic === "function") {
61
100
  bridge.triggerHaptic(type);
62
101
  return;
63
102
  }
64
- if (isDevelopment()) {
103
+ if (isDevelopment2()) {
65
104
  console.warn(
66
105
  "[oasiz/sdk] triggerHaptic bridge is unavailable. This is expected in local development."
67
106
  );
@@ -960,70 +999,74 @@ function enableLogOverlay(options = {}) {
960
999
  }
961
1000
 
962
1001
  // src/multiplayer.ts
963
- function isDevelopment2() {
1002
+ function isDevelopment3() {
964
1003
  const nodeEnv = globalThis.process?.env?.NODE_ENV;
965
1004
  return nodeEnv !== "production";
966
1005
  }
967
- function getBridgeWindow2() {
1006
+ function getBridgeWindow3() {
968
1007
  if (typeof window === "undefined") {
969
1008
  return void 0;
970
1009
  }
971
1010
  return window;
972
1011
  }
973
1012
  function shareRoomCode(roomCode, options) {
974
- const bridge = getBridgeWindow2();
1013
+ const bridge = getBridgeWindow3();
975
1014
  if (typeof bridge?.shareRoomCode === "function") {
976
1015
  bridge.shareRoomCode(roomCode, options);
977
1016
  return;
978
1017
  }
979
- if (isDevelopment2()) {
1018
+ if (isDevelopment3()) {
980
1019
  console.warn(
981
1020
  "[oasiz/sdk] shareRoomCode bridge is unavailable. This is expected in local development."
982
1021
  );
983
1022
  }
984
1023
  }
985
1024
  function openInviteModal() {
986
- const bridge = getBridgeWindow2();
1025
+ const bridge = getBridgeWindow3();
987
1026
  if (typeof bridge?.openInviteModal === "function") {
988
1027
  bridge.openInviteModal();
989
1028
  return;
990
1029
  }
991
- if (isDevelopment2()) {
1030
+ if (isDevelopment3()) {
992
1031
  console.warn(
993
1032
  "[oasiz/sdk] openInviteModal bridge is unavailable. This is expected in local development."
994
1033
  );
995
1034
  }
996
1035
  }
997
1036
  function getGameId() {
998
- const bridge = getBridgeWindow2();
1037
+ const bridge = getBridgeWindow3();
999
1038
  return bridge?.__GAME_ID__;
1000
1039
  }
1001
1040
  function getRoomCode() {
1002
- const bridge = getBridgeWindow2();
1041
+ const bridge = getBridgeWindow3();
1003
1042
  return bridge?.__ROOM_CODE__;
1004
1043
  }
1044
+ function getPlayerId() {
1045
+ const bridge = getBridgeWindow3();
1046
+ return bridge?.__PLAYER_ID__;
1047
+ }
1005
1048
  function getPlayerName() {
1006
- const bridge = getBridgeWindow2();
1049
+ const bridge = getBridgeWindow3();
1007
1050
  return bridge?.__PLAYER_NAME__;
1008
1051
  }
1009
1052
  function getPlayerAvatar() {
1010
- const bridge = getBridgeWindow2();
1053
+ const bridge = getBridgeWindow3();
1011
1054
  return bridge?.__PLAYER_AVATAR__;
1012
1055
  }
1013
1056
 
1014
1057
  // src/score.ts
1015
- function isDevelopment3() {
1058
+ function isDevelopment4() {
1016
1059
  const nodeEnv = globalThis.process?.env?.NODE_ENV;
1017
1060
  return nodeEnv !== "production";
1018
1061
  }
1019
- function warnMissingBridge(methodName) {
1020
- if (isDevelopment3()) {
1062
+ function warnMissingBridge2(methodName) {
1063
+ if (isDevelopment4()) {
1021
1064
  console.warn(
1022
1065
  "[oasiz/sdk] " + methodName + " bridge is unavailable. This is expected in local development."
1023
1066
  );
1024
1067
  }
1025
1068
  }
1026
- function getBridgeWindow3() {
1069
+ function getBridgeWindow4() {
1027
1070
  if (typeof window === "undefined") {
1028
1071
  return void 0;
1029
1072
  }
@@ -1031,33 +1074,92 @@ function getBridgeWindow3() {
1031
1074
  }
1032
1075
  function submitScore(score) {
1033
1076
  if (!Number.isFinite(score)) {
1034
- if (isDevelopment3()) {
1077
+ if (isDevelopment4()) {
1035
1078
  console.warn("[oasiz/sdk] submitScore expected a finite number:", score);
1036
1079
  }
1037
1080
  return;
1038
1081
  }
1039
- const bridge = getBridgeWindow3();
1082
+ const bridge = getBridgeWindow4();
1040
1083
  const normalizedScore = Math.max(0, Math.floor(score));
1041
1084
  if (typeof bridge?.submitScore === "function") {
1042
1085
  bridge.submitScore(normalizedScore);
1043
1086
  return;
1044
1087
  }
1045
- warnMissingBridge("submitScore");
1088
+ warnMissingBridge2("submitScore");
1089
+ }
1090
+
1091
+ // src/score-edit.ts
1092
+ function isDevelopment5() {
1093
+ const nodeEnv = globalThis.process?.env?.NODE_ENV;
1094
+ return nodeEnv !== "production";
1095
+ }
1096
+ function getBridgeWindow5() {
1097
+ if (typeof window === "undefined") {
1098
+ return void 0;
1099
+ }
1100
+ return window;
1101
+ }
1102
+ function warnMissingBridge3(methodName) {
1103
+ if (isDevelopment5()) {
1104
+ console.warn(
1105
+ "[oasiz/sdk] " + methodName + " bridge is unavailable. This is expected in local development."
1106
+ );
1107
+ }
1108
+ }
1109
+ async function editScore(payload, methodName) {
1110
+ const bridge = getBridgeWindow5();
1111
+ if (typeof bridge?.__oasizEditScore !== "function") {
1112
+ warnMissingBridge3(methodName);
1113
+ return null;
1114
+ }
1115
+ try {
1116
+ const result = await bridge.__oasizEditScore(payload);
1117
+ return result ?? null;
1118
+ } catch (error) {
1119
+ if (isDevelopment5()) {
1120
+ console.error("[oasiz/sdk] " + methodName + " failed:", error);
1121
+ }
1122
+ return null;
1123
+ }
1124
+ }
1125
+ async function addScore(delta) {
1126
+ if (!Number.isInteger(delta)) {
1127
+ if (isDevelopment5()) {
1128
+ console.warn("[oasiz/sdk] addScore expected an integer:", delta);
1129
+ }
1130
+ return null;
1131
+ }
1132
+ if (delta === 0) {
1133
+ return null;
1134
+ }
1135
+ return editScore({ delta }, "addScore");
1136
+ }
1137
+ async function setScore(score) {
1138
+ if (!Number.isInteger(score) || score < 0) {
1139
+ if (isDevelopment5()) {
1140
+ console.warn(
1141
+ "[oasiz/sdk] setScore expected a non-negative integer:",
1142
+ score
1143
+ );
1144
+ }
1145
+ return null;
1146
+ }
1147
+ return editScore({ score }, "setScore");
1046
1148
  }
1047
1149
 
1048
1150
  // src/share.ts
1049
- function isDevelopment4() {
1151
+ function isDevelopment6() {
1050
1152
  const nodeEnv = globalThis.process?.env?.NODE_ENV;
1051
1153
  return nodeEnv !== "production";
1052
1154
  }
1053
- function getBridgeWindow4() {
1155
+ function getBridgeWindow6() {
1054
1156
  if (typeof window === "undefined") {
1055
1157
  return void 0;
1056
1158
  }
1057
1159
  return window;
1058
1160
  }
1059
- function warnMissingBridge2(methodName) {
1060
- if (isDevelopment4()) {
1161
+ function warnMissingBridge4(methodName) {
1162
+ if (isDevelopment6()) {
1061
1163
  console.warn(
1062
1164
  "[oasiz/sdk] " + methodName + " share bridge is unavailable. This is expected in local development."
1063
1165
  );
@@ -1100,20 +1202,20 @@ function validateRequest(options) {
1100
1202
  }
1101
1203
  async function share(options) {
1102
1204
  const request = validateRequest(options);
1103
- const bridge = getBridgeWindow4();
1205
+ const bridge = getBridgeWindow6();
1104
1206
  if (typeof bridge?.__oasizShareRequest !== "function") {
1105
- warnMissingBridge2("__oasizShareRequest");
1207
+ warnMissingBridge4("__oasizShareRequest");
1106
1208
  throw new Error("Share bridge unavailable");
1107
1209
  }
1108
1210
  await bridge.__oasizShareRequest(request);
1109
1211
  }
1110
1212
 
1111
1213
  // src/state.ts
1112
- function isDevelopment5() {
1214
+ function isDevelopment7() {
1113
1215
  const nodeEnv = globalThis.process?.env?.NODE_ENV;
1114
1216
  return nodeEnv !== "production";
1115
1217
  }
1116
- function getBridgeWindow5() {
1218
+ function getBridgeWindow7() {
1117
1219
  if (typeof window === "undefined") {
1118
1220
  return void 0;
1119
1221
  }
@@ -1126,22 +1228,22 @@ function isPlainObject(value) {
1126
1228
  const proto = Object.getPrototypeOf(value);
1127
1229
  return proto === Object.prototype || proto === null;
1128
1230
  }
1129
- function warnMissingBridge3(methodName) {
1130
- if (isDevelopment5()) {
1231
+ function warnMissingBridge5(methodName) {
1232
+ if (isDevelopment7()) {
1131
1233
  console.warn(
1132
1234
  "[oasiz/sdk] " + methodName + " bridge is unavailable. This is expected in local development."
1133
1235
  );
1134
1236
  }
1135
1237
  }
1136
1238
  function loadGameState() {
1137
- const bridge = getBridgeWindow5();
1239
+ const bridge = getBridgeWindow7();
1138
1240
  if (typeof bridge?.loadGameState !== "function") {
1139
- warnMissingBridge3("loadGameState");
1241
+ warnMissingBridge5("loadGameState");
1140
1242
  return {};
1141
1243
  }
1142
1244
  const state = bridge.loadGameState();
1143
1245
  if (!isPlainObject(state)) {
1144
- if (isDevelopment5()) {
1246
+ if (isDevelopment7()) {
1145
1247
  console.warn(
1146
1248
  "[oasiz/sdk] loadGameState returned invalid data. Falling back to empty object."
1147
1249
  );
@@ -1152,35 +1254,35 @@ function loadGameState() {
1152
1254
  }
1153
1255
  function saveGameState(state) {
1154
1256
  if (!isPlainObject(state)) {
1155
- if (isDevelopment5()) {
1257
+ if (isDevelopment7()) {
1156
1258
  console.warn("[oasiz/sdk] saveGameState expected a plain object:", state);
1157
1259
  }
1158
1260
  return;
1159
1261
  }
1160
- const bridge = getBridgeWindow5();
1262
+ const bridge = getBridgeWindow7();
1161
1263
  if (typeof bridge?.saveGameState === "function") {
1162
1264
  bridge.saveGameState(state);
1163
1265
  return;
1164
1266
  }
1165
- warnMissingBridge3("saveGameState");
1267
+ warnMissingBridge5("saveGameState");
1166
1268
  }
1167
1269
  function flushGameState() {
1168
- const bridge = getBridgeWindow5();
1270
+ const bridge = getBridgeWindow7();
1169
1271
  if (typeof bridge?.flushGameState === "function") {
1170
1272
  bridge.flushGameState();
1171
1273
  return;
1172
1274
  }
1173
- warnMissingBridge3("flushGameState");
1275
+ warnMissingBridge5("flushGameState");
1174
1276
  }
1175
1277
 
1176
1278
  // src/lifecycle.ts
1177
- function isDevelopment6() {
1279
+ function isDevelopment8() {
1178
1280
  const nodeEnv = globalThis.process?.env?.NODE_ENV;
1179
1281
  return nodeEnv !== "production";
1180
1282
  }
1181
1283
  function addLifecycleListener(eventName, callback) {
1182
1284
  if (typeof window === "undefined") {
1183
- if (isDevelopment6()) {
1285
+ if (isDevelopment8()) {
1184
1286
  console.warn(
1185
1287
  "[oasiz/sdk] " + eventName + " listener registered without a browser window. This is expected in local development."
1186
1288
  );
@@ -1200,74 +1302,187 @@ function onResume(callback) {
1200
1302
  }
1201
1303
 
1202
1304
  // src/layout.ts
1203
- function isDevelopment7() {
1305
+ function isDevelopment9() {
1204
1306
  const nodeEnv = globalThis.process?.env?.NODE_ENV;
1205
1307
  return nodeEnv !== "production";
1206
1308
  }
1207
- function getBridgeWindow6() {
1309
+ function getBridgeWindow8() {
1208
1310
  if (typeof window === "undefined") {
1209
1311
  return void 0;
1210
1312
  }
1211
1313
  return window;
1212
1314
  }
1213
- function warnMissingBridge4(methodName) {
1214
- if (isDevelopment7()) {
1315
+ function warnMissingBridge6(methodName) {
1316
+ if (isDevelopment9()) {
1215
1317
  console.warn(
1216
1318
  "[oasiz/sdk] " + methodName + " bridge is unavailable. This is expected in local development."
1217
1319
  );
1218
1320
  }
1219
1321
  }
1220
- function normalizeSafeAreaTopPixels(value) {
1322
+ function toFiniteNumber(value) {
1221
1323
  if (typeof value !== "number" || !Number.isFinite(value)) {
1324
+ if (typeof value !== "string") {
1325
+ return void 0;
1326
+ }
1327
+ const parsed = Number.parseFloat(value.trim());
1328
+ if (!Number.isFinite(parsed)) {
1329
+ return void 0;
1330
+ }
1331
+ return parsed;
1332
+ }
1333
+ return value;
1334
+ }
1335
+ function clampSafeAreaTopPixels(value) {
1336
+ const numeric = toFiniteNumber(value);
1337
+ if (typeof numeric === "undefined") {
1222
1338
  return 0;
1223
1339
  }
1224
- return Math.max(0, value);
1340
+ return Math.max(0, numeric);
1225
1341
  }
1226
1342
  function normalizeSafeAreaTopPercent(value) {
1227
- if (typeof value !== "number" || !Number.isFinite(value)) {
1228
- return 0;
1343
+ const numeric = toFiniteNumber(value);
1344
+ if (typeof numeric === "undefined") {
1345
+ return void 0;
1229
1346
  }
1230
- return Math.min(100, Math.max(0, value));
1347
+ return Math.min(100, Math.max(0, numeric));
1348
+ }
1349
+ function getViewportHeight(bridge) {
1350
+ const visualViewportHeight = bridge.visualViewport?.height;
1351
+ if (typeof visualViewportHeight === "number" && Number.isFinite(visualViewportHeight) && visualViewportHeight > 0) {
1352
+ return visualViewportHeight;
1353
+ }
1354
+ const innerHeight = bridge.innerHeight;
1355
+ if (typeof innerHeight === "number" && Number.isFinite(innerHeight) && innerHeight > 0) {
1356
+ return innerHeight;
1357
+ }
1358
+ const documentHeight = bridge.document?.documentElement?.clientHeight;
1359
+ if (typeof documentHeight === "number" && Number.isFinite(documentHeight) && documentHeight > 0) {
1360
+ return documentHeight;
1361
+ }
1362
+ const bodyHeight = bridge.document?.body?.clientHeight;
1363
+ if (typeof bodyHeight === "number" && Number.isFinite(bodyHeight) && bodyHeight > 0) {
1364
+ return bodyHeight;
1365
+ }
1366
+ return 0;
1231
1367
  }
1232
- function viewportInnerHeight(bridge) {
1233
- const h = bridge.innerHeight;
1234
- if (typeof h !== "number" || !Number.isFinite(h) || h <= 0) {
1368
+ function readCssSafeAreaValue(bridge, cssValue) {
1369
+ const doc = bridge.document;
1370
+ const root = doc?.body ?? doc?.documentElement;
1371
+ if (!doc || !root || typeof doc.createElement !== "function" || typeof root.appendChild !== "function" || typeof bridge.getComputedStyle !== "function") {
1235
1372
  return 0;
1236
1373
  }
1237
- return h;
1374
+ const probe = doc.createElement("div");
1375
+ probe.style.position = "fixed";
1376
+ probe.style.top = "0";
1377
+ probe.style.left = "0";
1378
+ probe.style.width = "0";
1379
+ probe.style.height = "0";
1380
+ probe.style.visibility = "hidden";
1381
+ probe.style.pointerEvents = "none";
1382
+ probe.style.paddingTop = cssValue;
1383
+ root.appendChild(probe);
1384
+ try {
1385
+ return clampSafeAreaTopPixels(bridge.getComputedStyle(probe).paddingTop);
1386
+ } finally {
1387
+ if (typeof probe.remove === "function") {
1388
+ probe.remove();
1389
+ } else {
1390
+ probe.parentNode?.removeChild(probe);
1391
+ }
1392
+ }
1393
+ }
1394
+ function readCssSafeAreaTopPixels(bridge) {
1395
+ const envPixels = readCssSafeAreaValue(bridge, "env(safe-area-inset-top)");
1396
+ if (envPixels > 0) {
1397
+ return envPixels;
1398
+ }
1399
+ return readCssSafeAreaValue(bridge, "constant(safe-area-inset-top)");
1400
+ }
1401
+ function getDevicePixelRatio(bridge) {
1402
+ const dpr = bridge.devicePixelRatio;
1403
+ if (typeof dpr !== "number" || !Number.isFinite(dpr) || dpr <= 0) {
1404
+ return 1;
1405
+ }
1406
+ return dpr;
1407
+ }
1408
+ function roughlyEqualPixels(a, b) {
1409
+ return Math.abs(a - b) <= 2;
1410
+ }
1411
+ function normalizeSafeAreaTopPixels(value, bridge) {
1412
+ const pixels = clampSafeAreaTopPixels(value);
1413
+ const cssEnvPixels = readCssSafeAreaTopPixels(bridge);
1414
+ if (pixels <= 0) {
1415
+ return cssEnvPixels;
1416
+ }
1417
+ const dpr = getDevicePixelRatio(bridge);
1418
+ if (cssEnvPixels > 0 && dpr > 1 && roughlyEqualPixels(pixels / dpr, cssEnvPixels)) {
1419
+ return cssEnvPixels;
1420
+ }
1421
+ return pixels;
1238
1422
  }
1239
1423
  function pixelsTopToPercentOfViewport(pixels, bridge) {
1240
- const h = viewportInnerHeight(bridge);
1424
+ const h = getViewportHeight(bridge);
1241
1425
  if (h <= 0) {
1242
1426
  return 0;
1243
1427
  }
1244
- return normalizeSafeAreaTopPercent(pixels / h * 100);
1428
+ return normalizeSafeAreaTopPercent(pixels / h * 100) ?? 0;
1429
+ }
1430
+ function cssSafeAreaTopPercent(bridge) {
1431
+ return pixelsTopToPercentOfViewport(readCssSafeAreaTopPixels(bridge), bridge);
1432
+ }
1433
+ function resolvePercentValue(value, bridge) {
1434
+ const percent = normalizeSafeAreaTopPercent(value);
1435
+ if (typeof percent === "undefined") {
1436
+ return void 0;
1437
+ }
1438
+ return percent > 0 ? percent : cssSafeAreaTopPercent(bridge);
1439
+ }
1440
+ function resolvePixelValue(value, bridge) {
1441
+ const numeric = toFiniteNumber(value);
1442
+ if (typeof numeric === "undefined") {
1443
+ return void 0;
1444
+ }
1445
+ return pixelsTopToPercentOfViewport(normalizeSafeAreaTopPixels(numeric, bridge), bridge);
1245
1446
  }
1246
1447
  function getSafeAreaTop() {
1247
- const bridge = getBridgeWindow6();
1448
+ const bridge = getBridgeWindow8();
1248
1449
  if (!bridge) {
1249
1450
  return 0;
1250
1451
  }
1251
1452
  if (typeof bridge.getSafeAreaTopPercent === "function") {
1252
- return normalizeSafeAreaTopPercent(bridge.getSafeAreaTopPercent());
1453
+ const percent = resolvePercentValue(bridge.getSafeAreaTopPercent(), bridge);
1454
+ if (typeof percent !== "undefined") {
1455
+ return percent;
1456
+ }
1253
1457
  }
1254
1458
  if (typeof bridge.__OASIZ_SAFE_AREA_TOP_PERCENT__ !== "undefined") {
1255
- return normalizeSafeAreaTopPercent(bridge.__OASIZ_SAFE_AREA_TOP_PERCENT__);
1459
+ const percent = resolvePercentValue(bridge.__OASIZ_SAFE_AREA_TOP_PERCENT__, bridge);
1460
+ if (typeof percent !== "undefined") {
1461
+ return percent;
1462
+ }
1256
1463
  }
1257
1464
  if (typeof bridge.getSafeAreaTop === "function") {
1258
- const px = normalizeSafeAreaTopPixels(bridge.getSafeAreaTop());
1259
- return pixelsTopToPercentOfViewport(px, bridge);
1465
+ const percent = resolvePixelValue(bridge.getSafeAreaTop(), bridge);
1466
+ if (typeof percent !== "undefined") {
1467
+ return percent;
1468
+ }
1260
1469
  }
1261
1470
  if (typeof bridge.__OASIZ_SAFE_AREA_TOP__ !== "undefined") {
1262
- const px = normalizeSafeAreaTopPixels(bridge.__OASIZ_SAFE_AREA_TOP__);
1263
- return pixelsTopToPercentOfViewport(px, bridge);
1471
+ const percent = resolvePixelValue(bridge.__OASIZ_SAFE_AREA_TOP__, bridge);
1472
+ if (typeof percent !== "undefined") {
1473
+ return percent;
1474
+ }
1475
+ }
1476
+ const cssPercent = cssSafeAreaTopPercent(bridge);
1477
+ if (cssPercent > 0) {
1478
+ return cssPercent;
1264
1479
  }
1265
- warnMissingBridge4("getSafeAreaTop");
1480
+ warnMissingBridge6("getSafeAreaTop");
1266
1481
  return 0;
1267
1482
  }
1268
1483
  function setLeaderboardVisible(visible) {
1269
1484
  if (typeof visible !== "boolean") {
1270
- if (isDevelopment7()) {
1485
+ if (isDevelopment9()) {
1271
1486
  console.warn(
1272
1487
  "[oasiz/sdk] setLeaderboardVisible expected a boolean:",
1273
1488
  visible
@@ -1275,28 +1490,28 @@ function setLeaderboardVisible(visible) {
1275
1490
  }
1276
1491
  return;
1277
1492
  }
1278
- const bridge = getBridgeWindow6();
1493
+ const bridge = getBridgeWindow8();
1279
1494
  if (typeof bridge?.__oasizSetLeaderboardVisible === "function") {
1280
1495
  bridge.__oasizSetLeaderboardVisible(visible);
1281
1496
  return;
1282
1497
  }
1283
- warnMissingBridge4("__oasizSetLeaderboardVisible");
1498
+ warnMissingBridge6("__oasizSetLeaderboardVisible");
1284
1499
  }
1285
1500
 
1286
1501
  // src/navigation.ts
1287
1502
  var activeBackListeners = 0;
1288
- function isDevelopment8() {
1503
+ function isDevelopment10() {
1289
1504
  const nodeEnv = globalThis.process?.env?.NODE_ENV;
1290
1505
  return nodeEnv !== "production";
1291
1506
  }
1292
- function getBridgeWindow7() {
1507
+ function getBridgeWindow9() {
1293
1508
  if (typeof window === "undefined") {
1294
1509
  return void 0;
1295
1510
  }
1296
1511
  return window;
1297
1512
  }
1298
- function warnMissingBridge5(methodName) {
1299
- if (isDevelopment8()) {
1513
+ function warnMissingBridge7(methodName) {
1514
+ if (isDevelopment10()) {
1300
1515
  console.warn(
1301
1516
  "[oasiz/sdk] " + methodName + " bridge is unavailable. This is expected in local development."
1302
1517
  );
@@ -1312,7 +1527,7 @@ function normalizeNavigationError(error) {
1312
1527
  }
1313
1528
  function addNavigationListener(eventName, callback) {
1314
1529
  if (typeof window === "undefined") {
1315
- if (isDevelopment8()) {
1530
+ if (isDevelopment10()) {
1316
1531
  console.warn(
1317
1532
  "[oasiz/sdk] " + eventName + " listener registered without a browser window. This is expected in local development."
1318
1533
  );
@@ -1333,24 +1548,24 @@ function onBackButton(callback) {
1333
1548
  throw normalizeNavigationError(error);
1334
1549
  }
1335
1550
  });
1336
- const bridge = getBridgeWindow7();
1551
+ const bridge = getBridgeWindow9();
1337
1552
  activeBackListeners += 1;
1338
1553
  if (activeBackListeners === 1) {
1339
1554
  if (typeof bridge?.__oasizSetBackOverride === "function") {
1340
1555
  bridge.__oasizSetBackOverride(true);
1341
1556
  } else {
1342
- warnMissingBridge5("__oasizSetBackOverride");
1557
+ warnMissingBridge7("__oasizSetBackOverride");
1343
1558
  }
1344
1559
  }
1345
1560
  return () => {
1346
1561
  off();
1347
1562
  activeBackListeners = Math.max(0, activeBackListeners - 1);
1348
1563
  if (activeBackListeners === 0) {
1349
- const currentBridge = getBridgeWindow7();
1564
+ const currentBridge = getBridgeWindow9();
1350
1565
  if (typeof currentBridge?.__oasizSetBackOverride === "function") {
1351
1566
  currentBridge.__oasizSetBackOverride(false);
1352
1567
  } else {
1353
- warnMissingBridge5("__oasizSetBackOverride");
1568
+ warnMissingBridge7("__oasizSetBackOverride");
1354
1569
  }
1355
1570
  }
1356
1571
  };
@@ -1359,17 +1574,20 @@ function onLeaveGame(callback) {
1359
1574
  return addNavigationListener("oasiz:leave", callback);
1360
1575
  }
1361
1576
  function leaveGame() {
1362
- const bridge = getBridgeWindow7();
1577
+ const bridge = getBridgeWindow9();
1363
1578
  if (typeof bridge?.__oasizLeaveGame === "function") {
1364
1579
  bridge.__oasizLeaveGame();
1365
1580
  return;
1366
1581
  }
1367
- warnMissingBridge5("__oasizLeaveGame");
1582
+ warnMissingBridge7("__oasizLeaveGame");
1368
1583
  }
1369
1584
 
1370
1585
  // src/index.ts
1371
1586
  var oasiz = {
1372
1587
  submitScore,
1588
+ addScore,
1589
+ setScore,
1590
+ getPlayerCharacter,
1373
1591
  share,
1374
1592
  triggerHaptic,
1375
1593
  enableLogOverlay,
@@ -1391,6 +1609,9 @@ var oasiz = {
1391
1609
  get roomCode() {
1392
1610
  return getRoomCode();
1393
1611
  },
1612
+ get playerId() {
1613
+ return getPlayerId();
1614
+ },
1394
1615
  get playerName() {
1395
1616
  return getPlayerName();
1396
1617
  },
@@ -1403,10 +1624,13 @@ var oasiz = {
1403
1624
  };
1404
1625
  // Annotate the CommonJS export names for ESM import in node:
1405
1626
  0 && (module.exports = {
1627
+ addScore,
1406
1628
  enableLogOverlay,
1407
1629
  flushGameState,
1408
1630
  getGameId,
1409
1631
  getPlayerAvatar,
1632
+ getPlayerCharacter,
1633
+ getPlayerId,
1410
1634
  getPlayerName,
1411
1635
  getRoomCode,
1412
1636
  getSafeAreaTop,
@@ -1420,6 +1644,7 @@ var oasiz = {
1420
1644
  openInviteModal,
1421
1645
  saveGameState,
1422
1646
  setLeaderboardVisible,
1647
+ setScore,
1423
1648
  share,
1424
1649
  shareRoomCode,
1425
1650
  submitScore,