@smoregg/sdk 2.4.0 → 2.5.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/cjs/shared.cjs +1 -1
- package/dist/cjs/shared.cjs.map +1 -1
- package/dist/esm/shared.js +1 -1
- package/dist/esm/shared.js.map +1 -1
- package/dist/types/shared.d.ts +2 -2
- package/dist/types/shared.d.ts.map +1 -1
- package/dist/umd/smore-sdk.umd.js +1 -1
- package/dist/umd/smore-sdk.umd.js.map +1 -1
- package/dist/umd/smore-sdk.umd.min.js +1 -1
- package/dist/umd/smore-sdk.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/shared.cjs
CHANGED
package/dist/cjs/shared.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.cjs","sources":["../../src/shared.ts"],"sourcesContent":["/**\n * Shared utilities for Screen and Controller implementations.\n * Centralizes common logic to eliminate duplication.\n */\n\nimport type { ControllerInfo } from './types';\nimport { SmoreSDKError } from './errors';\n\n/** Maximum payload size in bytes (
|
|
1
|
+
{"version":3,"file":"shared.cjs","sources":["../../src/shared.ts"],"sourcesContent":["/**\n * Shared utilities for Screen and Controller implementations.\n * Centralizes common logic to eliminate duplication.\n */\n\nimport type { ControllerInfo } from './types';\nimport { SmoreSDKError } from './errors';\n\n/** Maximum payload size in bytes (1MB). Server rejects larger payloads. */\nexport const MAX_PAYLOAD_SIZE = 1024 * 1024;\n\n/**\n * Map raw player data from server/bridge to ControllerInfo.\n * Centralizes the name->nickname and character->appearance field mapping.\n *\n * Server sends: { playerIndex, name, connected, character }\n * SDK exposes: { playerIndex, nickname, connected, appearance }\n */\nexport function mapPlayerDTO(raw: Record<string, unknown>, fallbackIndex: number): ControllerInfo {\n return {\n playerIndex: (raw.playerIndex as number) ?? fallbackIndex,\n nickname: (raw.nickname as string) || (raw.name as string) || `Player ${((raw.playerIndex as number) ?? fallbackIndex) + 1}`,\n connected: raw.connected !== false,\n appearance: (raw.appearance ?? raw.character) as ControllerInfo['appearance'],\n };\n}\n\n/**\n * Validate that event payload does not exceed the 64KB server limit.\n * Throws PAYLOAD_TOO_LARGE error if exceeded.\n */\nexport function validatePayloadSize(data: unknown): void {\n if (data === undefined || data === null) return;\n\n try {\n const serialized = JSON.stringify(data);\n const byteLength = new TextEncoder().encode(serialized).byteLength;\n if (byteLength > MAX_PAYLOAD_SIZE) {\n throw new SmoreSDKError(\n 'PAYLOAD_TOO_LARGE',\n `Event payload exceeds maximum size of ${MAX_PAYLOAD_SIZE} bytes (got ${byteLength} bytes). The server will silently drop this event.`,\n { details: { size: byteLength, limit: MAX_PAYLOAD_SIZE } }\n );\n }\n } catch (err) {\n if (err instanceof SmoreSDKError) throw err;\n // If JSON.stringify fails, the data can't be sent anyway\n }\n}\n"],"names":["SmoreSDKError"],"mappings":";;;;AASO,MAAM,mBAAmB,IAAA,GAAO;AAShC,SAAS,YAAA,CAAa,KAA8B,aAAA,EAAuC;AAChG,EAAA,OAAO;AAAA,IACL,WAAA,EAAc,IAAI,WAAA,IAA0B,aAAA;AAAA,IAC5C,QAAA,EAAW,IAAI,QAAA,IAAwB,GAAA,CAAI,QAAmB,CAAA,OAAA,EAAA,CAAY,GAAA,CAAI,WAAA,IAA0B,aAAA,IAAiB,CAAC,CAAA,CAAA;AAAA,IAC1H,SAAA,EAAW,IAAI,SAAA,KAAc,KAAA;AAAA,IAC7B,UAAA,EAAa,GAAA,CAAI,UAAA,IAAc,GAAA,CAAI;AAAA,GACrC;AACF;AAMO,SAAS,oBAAoB,IAAA,EAAqB;AACvD,EAAA,IAAI,IAAA,KAAS,MAAA,IAAa,IAAA,KAAS,IAAA,EAAM;AAEzC,EAAA,IAAI;AACF,IAAA,MAAM,UAAA,GAAa,IAAA,CAAK,SAAA,CAAU,IAAI,CAAA;AACtC,IAAA,MAAM,aAAa,IAAI,WAAA,EAAY,CAAE,MAAA,CAAO,UAAU,CAAA,CAAE,UAAA;AACxD,IAAA,IAAI,aAAa,gBAAA,EAAkB;AACjC,MAAA,MAAM,IAAIA,oBAAA;AAAA,QACR,mBAAA;AAAA,QACA,CAAA,sCAAA,EAAyC,gBAAgB,CAAA,YAAA,EAAe,UAAU,CAAA,kDAAA,CAAA;AAAA,QAClF,EAAE,OAAA,EAAS,EAAE,MAAM,UAAA,EAAY,KAAA,EAAO,kBAAiB;AAAE,OAC3D;AAAA,IACF;AAAA,EACF,SAAS,GAAA,EAAK;AACZ,IAAA,IAAI,GAAA,YAAeA,sBAAe,MAAM,GAAA;AAAA,EAE1C;AACF;;;;;;"}
|
package/dist/esm/shared.js
CHANGED
package/dist/esm/shared.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sources":["../../src/shared.ts"],"sourcesContent":["/**\n * Shared utilities for Screen and Controller implementations.\n * Centralizes common logic to eliminate duplication.\n */\n\nimport type { ControllerInfo } from './types';\nimport { SmoreSDKError } from './errors';\n\n/** Maximum payload size in bytes (
|
|
1
|
+
{"version":3,"file":"shared.js","sources":["../../src/shared.ts"],"sourcesContent":["/**\n * Shared utilities for Screen and Controller implementations.\n * Centralizes common logic to eliminate duplication.\n */\n\nimport type { ControllerInfo } from './types';\nimport { SmoreSDKError } from './errors';\n\n/** Maximum payload size in bytes (1MB). Server rejects larger payloads. */\nexport const MAX_PAYLOAD_SIZE = 1024 * 1024;\n\n/**\n * Map raw player data from server/bridge to ControllerInfo.\n * Centralizes the name->nickname and character->appearance field mapping.\n *\n * Server sends: { playerIndex, name, connected, character }\n * SDK exposes: { playerIndex, nickname, connected, appearance }\n */\nexport function mapPlayerDTO(raw: Record<string, unknown>, fallbackIndex: number): ControllerInfo {\n return {\n playerIndex: (raw.playerIndex as number) ?? fallbackIndex,\n nickname: (raw.nickname as string) || (raw.name as string) || `Player ${((raw.playerIndex as number) ?? fallbackIndex) + 1}`,\n connected: raw.connected !== false,\n appearance: (raw.appearance ?? raw.character) as ControllerInfo['appearance'],\n };\n}\n\n/**\n * Validate that event payload does not exceed the 64KB server limit.\n * Throws PAYLOAD_TOO_LARGE error if exceeded.\n */\nexport function validatePayloadSize(data: unknown): void {\n if (data === undefined || data === null) return;\n\n try {\n const serialized = JSON.stringify(data);\n const byteLength = new TextEncoder().encode(serialized).byteLength;\n if (byteLength > MAX_PAYLOAD_SIZE) {\n throw new SmoreSDKError(\n 'PAYLOAD_TOO_LARGE',\n `Event payload exceeds maximum size of ${MAX_PAYLOAD_SIZE} bytes (got ${byteLength} bytes). The server will silently drop this event.`,\n { details: { size: byteLength, limit: MAX_PAYLOAD_SIZE } }\n );\n }\n } catch (err) {\n if (err instanceof SmoreSDKError) throw err;\n // If JSON.stringify fails, the data can't be sent anyway\n }\n}\n"],"names":[],"mappings":";;AASO,MAAM,mBAAmB,IAAA,GAAO;AAShC,SAAS,YAAA,CAAa,KAA8B,aAAA,EAAuC;AAChG,EAAA,OAAO;AAAA,IACL,WAAA,EAAc,IAAI,WAAA,IAA0B,aAAA;AAAA,IAC5C,QAAA,EAAW,IAAI,QAAA,IAAwB,GAAA,CAAI,QAAmB,CAAA,OAAA,EAAA,CAAY,GAAA,CAAI,WAAA,IAA0B,aAAA,IAAiB,CAAC,CAAA,CAAA;AAAA,IAC1H,SAAA,EAAW,IAAI,SAAA,KAAc,KAAA;AAAA,IAC7B,UAAA,EAAa,GAAA,CAAI,UAAA,IAAc,GAAA,CAAI;AAAA,GACrC;AACF;AAMO,SAAS,oBAAoB,IAAA,EAAqB;AACvD,EAAA,IAAI,IAAA,KAAS,MAAA,IAAa,IAAA,KAAS,IAAA,EAAM;AAEzC,EAAA,IAAI;AACF,IAAA,MAAM,UAAA,GAAa,IAAA,CAAK,SAAA,CAAU,IAAI,CAAA;AACtC,IAAA,MAAM,aAAa,IAAI,WAAA,EAAY,CAAE,MAAA,CAAO,UAAU,CAAA,CAAE,UAAA;AACxD,IAAA,IAAI,aAAa,gBAAA,EAAkB;AACjC,MAAA,MAAM,IAAI,aAAA;AAAA,QACR,mBAAA;AAAA,QACA,CAAA,sCAAA,EAAyC,gBAAgB,CAAA,YAAA,EAAe,UAAU,CAAA,kDAAA,CAAA;AAAA,QAClF,EAAE,OAAA,EAAS,EAAE,MAAM,UAAA,EAAY,KAAA,EAAO,kBAAiB;AAAE,OAC3D;AAAA,IACF;AAAA,EACF,SAAS,GAAA,EAAK;AACZ,IAAA,IAAI,GAAA,YAAe,eAAe,MAAM,GAAA;AAAA,EAE1C;AACF;;;;"}
|
package/dist/types/shared.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Centralizes common logic to eliminate duplication.
|
|
4
4
|
*/
|
|
5
5
|
import type { ControllerInfo } from './types';
|
|
6
|
-
/** Maximum payload size in bytes (
|
|
7
|
-
export declare const MAX_PAYLOAD_SIZE
|
|
6
|
+
/** Maximum payload size in bytes (1MB). Server rejects larger payloads. */
|
|
7
|
+
export declare const MAX_PAYLOAD_SIZE: number;
|
|
8
8
|
/**
|
|
9
9
|
* Map raw player data from server/bridge to ControllerInfo.
|
|
10
10
|
* Centralizes the name->nickname and character->appearance field mapping.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/shared.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG9C,
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/shared.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG9C,2EAA2E;AAC3E,eAAO,MAAM,gBAAgB,QAAc,CAAC;AAE5C;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,EAAE,MAAM,GAAG,cAAc,CAOhG;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAiBvD"}
|