@playabl/sdk 1.1.0 → 1.2.0-beta.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.d.ts CHANGED
@@ -48,6 +48,28 @@ interface ReadyResult {
48
48
  isLocalDev: boolean;
49
49
  parentOrigin: string | null;
50
50
  }
51
+ type InterstitialPlacement = 'level-end' | 'game-over' | 'pause';
52
+ type RewardedPlacement = 'revive' | 'currency' | 'boost' | 'unlock';
53
+ type AdKind = 'interstitial' | 'rewarded';
54
+ type RewardedAdStatus = 'completed' | 'skipped' | 'unavailable' | 'failed';
55
+ interface InterstitialOptions {
56
+ placement: InterstitialPlacement;
57
+ }
58
+ interface RewardedOptions {
59
+ placement: RewardedPlacement;
60
+ }
61
+ interface InterstitialResult {
62
+ shown: boolean;
63
+ }
64
+ interface RewardedResult {
65
+ status: RewardedAdStatus;
66
+ }
67
+ interface PlayablAds {
68
+ /** False before readiness, or when the host/renderer has no ad available. */
69
+ isAvailable(kind: AdKind): boolean;
70
+ showInterstitial(opts: InterstitialOptions): Promise<InterstitialResult>;
71
+ showRewarded(opts: RewardedOptions): Promise<RewardedResult>;
72
+ }
51
73
  interface SubmitResult {
52
74
  accepted: boolean;
53
75
  }
@@ -136,10 +158,10 @@ interface PlayablTweaks {
136
158
  */
137
159
  layout(id: string): LayoutValues | undefined;
138
160
  }
139
- type AssetType = 'image' | 'audio' | 'video' | 'unknown';
161
+ type AssetType = 'image' | 'audio' | 'model' | 'video' | 'unknown';
140
162
  type AssetStatus = 'original' | 'overridden';
141
163
  /** v1 asset kinds. `video` is reserved and rejected. */
142
- type AssetKind = 'image' | 'audio';
164
+ type AssetKind = 'image' | 'audio' | 'model';
143
165
  interface AssetRecipe {
144
166
  prompt?: string;
145
167
  refs?: string[];
@@ -1067,9 +1089,10 @@ interface PlayablSDK {
1067
1089
  game: PlayablGame;
1068
1090
  devtools: PlayablDevtools;
1069
1091
  device: PlayablDevice;
1092
+ ads: PlayablAds;
1070
1093
  audio: PlayablAudio;
1071
1094
  }
1072
- type ErrorCode = 'NOT_IN_IFRAME' | 'PARENT_TIMEOUT' | 'SDK_NOT_READY' | 'STORAGE_SERIALIZE_ERROR' | 'STORAGE_QUOTA_EXCEEDED' | 'INVALID_SCHEMA' | 'INVALID_ASSETS' | 'INVALID_DEVTOOLS' | 'NOT_SUPPORTED' | 'PERMISSION_DENIED' | 'TIMEOUT' | 'OPERATION_FAILED' | 'UNKNOWN_ERROR';
1095
+ type ErrorCode = 'NOT_IN_IFRAME' | 'PARENT_TIMEOUT' | 'SDK_NOT_READY' | 'STORAGE_SERIALIZE_ERROR' | 'STORAGE_QUOTA_EXCEEDED' | 'INVALID_SCHEMA' | 'INVALID_PLACEMENT' | 'INVALID_CONFIG' | 'INVALID_ASSETS' | 'INVALID_DEVTOOLS' | 'NOT_SUPPORTED' | 'PERMISSION_DENIED' | 'TIMEOUT' | 'OPERATION_FAILED' | 'UNKNOWN_ERROR';
1073
1096
  declare class PlayablError extends Error {
1074
1097
  readonly code: ErrorCode;
1075
1098
  readonly cause?: unknown;
@@ -1093,4 +1116,4 @@ declare const __testing: {
1093
1116
  setRuntimeLoader(loader: RuntimeLoader): void;
1094
1117
  };
1095
1118
 
1096
- export { type AssetDescriptor, type AssetEntry, type AssetKind, type AssetOverride, type AssetRecipe, type AssetStatus, type AssetType, type AssetValueEntry, type AssetsMapping, type AssetsRegisterOptions, type AssetsUrlMap, type AssetsValues, type BoardInstance, type BoardLayer, type BooleanTweak, type CameraAPI, type CameraOptions, type CameraResult, type CatalogCategory, type CatalogContext, type CatalogDefinition, type CatalogDefinitionOptions, type CatalogEntryAction, type CatalogEntryBase, type CatalogEntryOptions, type CatalogLevel, type CatalogLevelOptions, type CatalogProgression, type CatalogScreen, type CellGridEntry, type CellGridHooks, type CellGridOptions, type ColorTweak, type ContentDocument, type ContentFieldSpec, type ContentFieldType, type ContentFieldValue, type ContentGroup, type ContentHandle, type ContentHooks, type ContentLevel, type ContentOwner, type ContentRefusalCause, type ContentVerbType, type DevtoolsCommand, type DevtoolsContent, type DevtoolsHandle, type DevtoolsVocabulary, type EnumTweak, type ErrorCode, type FileSystemAPI, type FileSystemOptions, type FileSystemResult, type GameLoopHooks, type GameMode, type GameRunHandle, type GameRunOptions, type GeolocationAPI, type GeolocationOptions, type GeolocationResult, type HapticsAPI, type LayoutEntry, type LayoutFile, type LayoutRole, type LayoutRoleMap, type LayoutValues, type LevelPreview, type LevelPreviewCell, type LevelRefusal, type MicrophoneAPI, type MicrophoneRecordOptions, type MicrophoneResult, type MicrophoneStreamOptions, type MotionAttitude, type MotionData, type MotionRotation, type MotionVector, type NormalizedAssetEntry, type NumberTweak, type OrientationData, type PayloadRefusal, type PlayablAssets, type PlayablAudio, type PlayablAudioAutoPauseOptions, type PlayablAudioContext, type PlayablAudioOptions, type PlayablDevice, type PlayablDevtools, PlayablError, type PlayablGame, type PlayablSDK, type PlayablTweaks, type ProgressionNoun, type ProgressionShape, type ReadyResult, type SaveResult, type SceneGrid, type SceneNode, type SceneRect, type SensorsAPI, type StateLevel, type SubmitResult, type TextStyleStamp, type TextTweak, type TweakAppliesOn, type TweakSchema, type TweakSchemaItem, type TweakType, type TweakValue, type TweakValueIssue, type TweakValueRejection, type TweakValues, type TweaksInitOptions, __testing, cellGridHooks, configure, sdk as default };
1119
+ export { type AdKind, type AssetDescriptor, type AssetEntry, type AssetKind, type AssetOverride, type AssetRecipe, type AssetStatus, type AssetType, type AssetValueEntry, type AssetsMapping, type AssetsRegisterOptions, type AssetsUrlMap, type AssetsValues, type BoardInstance, type BoardLayer, type BooleanTweak, type CameraAPI, type CameraOptions, type CameraResult, type CatalogCategory, type CatalogContext, type CatalogDefinition, type CatalogDefinitionOptions, type CatalogEntryAction, type CatalogEntryBase, type CatalogEntryOptions, type CatalogLevel, type CatalogLevelOptions, type CatalogProgression, type CatalogScreen, type CellGridEntry, type CellGridHooks, type CellGridOptions, type ColorTweak, type ContentDocument, type ContentFieldSpec, type ContentFieldType, type ContentFieldValue, type ContentGroup, type ContentHandle, type ContentHooks, type ContentLevel, type ContentOwner, type ContentRefusalCause, type ContentVerbType, type DevtoolsCommand, type DevtoolsContent, type DevtoolsHandle, type DevtoolsVocabulary, type EnumTweak, type ErrorCode, type FileSystemAPI, type FileSystemOptions, type FileSystemResult, type GameLoopHooks, type GameMode, type GameRunHandle, type GameRunOptions, type GeolocationAPI, type GeolocationOptions, type GeolocationResult, type HapticsAPI, type InterstitialOptions, type InterstitialPlacement, type InterstitialResult, type LayoutEntry, type LayoutFile, type LayoutRole, type LayoutRoleMap, type LayoutValues, type LevelPreview, type LevelPreviewCell, type LevelRefusal, type MicrophoneAPI, type MicrophoneRecordOptions, type MicrophoneResult, type MicrophoneStreamOptions, type MotionAttitude, type MotionData, type MotionRotation, type MotionVector, type NormalizedAssetEntry, type NumberTweak, type OrientationData, type PayloadRefusal, type PlayablAds, type PlayablAssets, type PlayablAudio, type PlayablAudioAutoPauseOptions, type PlayablAudioContext, type PlayablAudioOptions, type PlayablDevice, type PlayablDevtools, PlayablError, type PlayablGame, type PlayablSDK, type PlayablTweaks, type ProgressionNoun, type ProgressionShape, type ReadyResult, type RewardedAdStatus, type RewardedOptions, type RewardedPlacement, type RewardedResult, type SaveResult, type SceneGrid, type SceneNode, type SceneRect, type SensorsAPI, type StateLevel, type SubmitResult, type TextStyleStamp, type TextTweak, type TweakAppliesOn, type TweakSchema, type TweakSchemaItem, type TweakType, type TweakValue, type TweakValueIssue, type TweakValueRejection, type TweakValues, type TweaksInitOptions, __testing, cellGridHooks, configure, sdk as default };
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ var CDN_HOSTS = /* @__PURE__ */ new Set([
8
8
  "cdn-staging.playabl.ai",
9
9
  "cdn-dev.playabl.ai"
10
10
  ]);
11
- var FALLBACK_RUNTIME_URL = "https://cdn.playabl.ai/Runtime-Script/sdk/v1/runtime.js?v=sdk-1.1.0";
11
+ var FALLBACK_RUNTIME_URL = "https://cdn.playabl.ai/Runtime-Script/sdk/v1/runtime.js?v=sdk-1.2.0-beta.0";
12
12
  function isEnv(value) {
13
13
  return value === "local" || value === "dev" || value === "staging" || value === "prod";
14
14
  }
@@ -417,6 +417,11 @@ var sdk = {
417
417
  }
418
418
  }
419
419
  },
420
+ ads: {
421
+ isAvailable: (kind) => peekSDK()?.ads?.isAvailable(kind) ?? false,
422
+ showInterstitial: async (opts) => requireRuntimeMember(await getSDK(), "ads").showInterstitial(opts),
423
+ showRewarded: async (opts) => requireRuntimeMember(await getSDK(), "ads").showRewarded(opts)
424
+ },
420
425
  audio: {
421
426
  isSupported: () => {
422
427
  const runtime = peekSDK();
package/dist/layout.js CHANGED
@@ -42,6 +42,10 @@ var DEVTOOLS_MESSAGE_TYPES = [
42
42
  "command-refused"
43
43
  ];
44
44
  var OUTBOUND_TYPES = [
45
+ "ads-show",
46
+ "ads-started",
47
+ "ads-report",
48
+ "ads-click",
45
49
  "ready",
46
50
  "score",
47
51
  "tweaks-initialize",
@@ -51,9 +55,13 @@ var OUTBOUND_TYPES = [
51
55
  "state-save",
52
56
  "state-load",
53
57
  "state-clear",
58
+ "play-activity",
54
59
  ...DEVTOOLS_MESSAGE_TYPES
55
60
  ];
56
61
  var INBOUND_TYPES = [
62
+ "ads-availability",
63
+ "ads-show-ack",
64
+ "ads-show-result",
57
65
  "ready-ack",
58
66
  "score-ack",
59
67
  "error",
@@ -71,6 +79,7 @@ var INBOUND_TYPES = [
71
79
  "state-save-ack",
72
80
  "state-load-ack",
73
81
  "state-clear-ack",
82
+ "play-session",
74
83
  // Game-defined command ids are dispatched by string and are deliberately
75
84
  // not enumerated here.
76
85
  ...CREATOR_COMMAND_TYPES
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playabl/sdk",
3
- "version": "1.1.0",
3
+ "version": "1.2.0-beta.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",