@playruo/embed 1.3.3 → 1.4.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/README.md +54 -0
- package/dist/index.cjs +133 -52
- package/dist/index.d.cts +151 -64
- package/dist/index.d.ts +151 -64
- package/dist/index.js +133 -52
- package/package.json +32 -9
package/dist/index.d.cts
CHANGED
|
@@ -24,6 +24,106 @@ type PlayruoEventPayload = Record<string, unknown> & {
|
|
|
24
24
|
name?: string;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
+
interface PlayruoReadyMessage {
|
|
28
|
+
type: "playruo_ready";
|
|
29
|
+
}
|
|
30
|
+
interface PlayruoStateUpdateMessage {
|
|
31
|
+
type: "playruo_state_update";
|
|
32
|
+
data: PlayruoEmbedState;
|
|
33
|
+
}
|
|
34
|
+
interface PlayruoPurchaseRequestMessage {
|
|
35
|
+
type: "playruo_purchase_request";
|
|
36
|
+
data: {
|
|
37
|
+
storeUrl: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
interface PlayruoDemoCompletedMessage {
|
|
41
|
+
type: "playruo_demo_completed";
|
|
42
|
+
data: DemoCompletedPayload;
|
|
43
|
+
}
|
|
44
|
+
interface PlayruoErrorMessage {
|
|
45
|
+
type: "playruo_error";
|
|
46
|
+
data: {
|
|
47
|
+
message: string;
|
|
48
|
+
} | string;
|
|
49
|
+
}
|
|
50
|
+
interface PlayruoSessionOverMessage {
|
|
51
|
+
type: "playruo_session_over";
|
|
52
|
+
data: PlayruoEmbedState;
|
|
53
|
+
}
|
|
54
|
+
interface PlayruoStreamStartMessage {
|
|
55
|
+
type: "playruo_stream_start";
|
|
56
|
+
}
|
|
57
|
+
interface PlayruoStreamStopMessage {
|
|
58
|
+
type: "playruo_stream_stop";
|
|
59
|
+
}
|
|
60
|
+
interface PlayruoRequestExitFullscreenMessage {
|
|
61
|
+
type: "REQUEST_EXIT_FULLSCREEN";
|
|
62
|
+
}
|
|
63
|
+
interface PlayruoEventMessage {
|
|
64
|
+
type: "playruo_event";
|
|
65
|
+
data: PlayruoEventPayload;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Why a password submission was refused. `already_validating` answers a submit
|
|
69
|
+
* sent while another one is still being checked, so the host may simply send it
|
|
70
|
+
* again; `too_many_attempts` closes the operation for this visitor and reopens
|
|
71
|
+
* on its own after a delay.
|
|
72
|
+
*/
|
|
73
|
+
type PlayruoPasswordError = "invalid_password" | "already_validating" | "too_many_attempts";
|
|
74
|
+
/**
|
|
75
|
+
* A refusal code as a host reads it: one of the codes above, or any other one
|
|
76
|
+
* the operation may answer with. `string & {}` rather than `string`, which
|
|
77
|
+
* would absorb the union and drop the known codes from autocompletion.
|
|
78
|
+
*/
|
|
79
|
+
type PlayruoPasswordErrorCode = PlayruoPasswordError | (string & {});
|
|
80
|
+
/**
|
|
81
|
+
* A password protected operation announces itself once its configuration is
|
|
82
|
+
* loaded. The iframe stays invisible until a session starts, so it renders no
|
|
83
|
+
* form of its own: the host collects the password and sends it back with the
|
|
84
|
+
* submitPassword action.
|
|
85
|
+
*/
|
|
86
|
+
interface PlayruoPasswordRequiredMessage {
|
|
87
|
+
type: "playruo_password_required";
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Answers a requestPassword sent to an operation that is not protected. Without
|
|
91
|
+
* it a host cannot tell "no password needed" from "the announce has not come
|
|
92
|
+
* yet", and waits forever on a gate that will never open.
|
|
93
|
+
*/
|
|
94
|
+
interface PlayruoPasswordNotRequiredMessage {
|
|
95
|
+
type: "playruo_password_not_required";
|
|
96
|
+
}
|
|
97
|
+
interface PlayruoPasswordResultMessage {
|
|
98
|
+
type: "playruo_password_result";
|
|
99
|
+
data: {
|
|
100
|
+
success: boolean;
|
|
101
|
+
error?: PlayruoPasswordErrorCode;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
type PlayruoEmbedMessage = PlayruoReadyMessage | PlayruoStateUpdateMessage | PlayruoPurchaseRequestMessage | PlayruoDemoCompletedMessage | PlayruoErrorMessage | PlayruoSessionOverMessage | PlayruoStreamStartMessage | PlayruoStreamStopMessage | PlayruoRequestExitFullscreenMessage | PlayruoEventMessage | PlayruoPasswordRequiredMessage | PlayruoPasswordNotRequiredMessage | PlayruoPasswordResultMessage;
|
|
105
|
+
interface PlayruoInternalMessage {
|
|
106
|
+
type: "playruo";
|
|
107
|
+
action: "tryNowClick" | "exitFullscreen" | "mute" | "unmute" | "submitPassword" | "requestPassword";
|
|
108
|
+
fromEmbed: true;
|
|
109
|
+
isReplay?: boolean;
|
|
110
|
+
isFullscreen?: boolean;
|
|
111
|
+
parentWillHandleFullscreen?: boolean;
|
|
112
|
+
/** Only read by the submitPassword action. */
|
|
113
|
+
password?: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Type guard to check if a message event is a Playruo embed message
|
|
117
|
+
* Messages FROM Embed → Host via postMessage
|
|
118
|
+
*/
|
|
119
|
+
declare const isPlayruoEmbedMessage: (data: unknown) => data is PlayruoEmbedMessage;
|
|
120
|
+
/**
|
|
121
|
+
* Type guard to check if a message is a Playruo internal message
|
|
122
|
+
* Format: { type: 'playruo', action: '...', fromEmbed: true }
|
|
123
|
+
* These are messages sent TO the iframe (game), not to the parent
|
|
124
|
+
*/
|
|
125
|
+
declare const isPlayruoInternalMessage: (data: unknown) => data is PlayruoInternalMessage;
|
|
126
|
+
|
|
27
127
|
interface PlayruoEmbedActions {
|
|
28
128
|
/** Start the demo session */
|
|
29
129
|
tryNow: () => void;
|
|
@@ -33,17 +133,52 @@ interface PlayruoEmbedActions {
|
|
|
33
133
|
canTryNow: boolean;
|
|
34
134
|
/** Whether buy now is currently available */
|
|
35
135
|
canBuyNow: boolean;
|
|
136
|
+
/** Send the password collected by the host to a protected operation. */
|
|
137
|
+
submitPassword: (password: string) => void;
|
|
138
|
+
/**
|
|
139
|
+
* Ask the operation to announce again whether it needs a password. The
|
|
140
|
+
* announcement is emitted once, so a host that mounts late can miss it.
|
|
141
|
+
*/
|
|
142
|
+
requestPassword: () => void;
|
|
143
|
+
}
|
|
144
|
+
interface PlayruoEmbedPasswordState {
|
|
145
|
+
/**
|
|
146
|
+
* The operation asked for a password. Stays true once it was given, so read
|
|
147
|
+
* `unlocked` for the gate itself.
|
|
148
|
+
*/
|
|
149
|
+
required: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* The operation said whether it is protected. Until then `required: false`
|
|
152
|
+
* only means nothing was announced yet, so a host that called
|
|
153
|
+
* `requestPassword` cannot tell an unprotected operation from a silent one.
|
|
154
|
+
*/
|
|
155
|
+
checked: boolean;
|
|
156
|
+
/** A submitted password was accepted. */
|
|
157
|
+
unlocked: boolean;
|
|
158
|
+
/** Code of the last refusal, from PlayruoPasswordError when known. */
|
|
159
|
+
error?: PlayruoPasswordErrorCode;
|
|
36
160
|
}
|
|
37
161
|
interface PlayruoEmbedRenderState {
|
|
38
162
|
status: "loading" | "available" | "unavailable" | "error";
|
|
39
163
|
message?: string;
|
|
40
164
|
actions: PlayruoEmbedActions;
|
|
165
|
+
/**
|
|
166
|
+
* A protected operation never announces ready while it is locked, so a host
|
|
167
|
+
* that ignores this stays on `loading` for as long as the visitor has not
|
|
168
|
+
* been asked for the password.
|
|
169
|
+
*/
|
|
170
|
+
password: PlayruoEmbedPasswordState;
|
|
41
171
|
}
|
|
42
172
|
interface PlayruoEmbedProps {
|
|
43
173
|
/** Game origin (scheme + host). Omit to use production (`https://playruo.live`). */
|
|
44
174
|
baseUrl?: string;
|
|
45
175
|
/** Game operation slug used to build the iframe URL. */
|
|
46
176
|
operation: string;
|
|
177
|
+
/**
|
|
178
|
+
* Which operation of the campaign to open, when it holds more than one. Sent
|
|
179
|
+
* as `?op=`. Without it the campaign picks its own.
|
|
180
|
+
*/
|
|
181
|
+
operationKey?: string;
|
|
47
182
|
storeUrl?: string;
|
|
48
183
|
showIframe?: boolean;
|
|
49
184
|
className?: string;
|
|
@@ -55,6 +190,13 @@ interface PlayruoEmbedProps {
|
|
|
55
190
|
storeUrl: string;
|
|
56
191
|
}) => void;
|
|
57
192
|
onError?: (error: string) => void;
|
|
193
|
+
/** The operation is password protected and waits for one. */
|
|
194
|
+
onPasswordRequired?: () => void;
|
|
195
|
+
/** Answer to a submitted password. */
|
|
196
|
+
onPasswordResult?: (result: {
|
|
197
|
+
success: boolean;
|
|
198
|
+
error?: PlayruoPasswordErrorCode;
|
|
199
|
+
}) => void;
|
|
58
200
|
/**
|
|
59
201
|
* Skip the parent fullscreen request and start the experience inside the
|
|
60
202
|
* current iframe bounds. Defaults to false to preserve the current behavior.
|
|
@@ -74,7 +216,7 @@ interface PlayruoEmbedProps {
|
|
|
74
216
|
/**
|
|
75
217
|
* Ref to access the iframe element for fullscreen requests
|
|
76
218
|
*/
|
|
77
|
-
iframeRef?: React.RefObject<HTMLIFrameElement>;
|
|
219
|
+
iframeRef?: React.RefObject<HTMLIFrameElement | null>;
|
|
78
220
|
}
|
|
79
221
|
declare const PlayruoEmbed: FC<PlayruoEmbedProps>;
|
|
80
222
|
|
|
@@ -90,69 +232,14 @@ interface EmbedTesterProps {
|
|
|
90
232
|
}
|
|
91
233
|
declare const EmbedTester: (props?: EmbedTesterProps) => react_jsx_runtime.JSX.Element;
|
|
92
234
|
|
|
93
|
-
interface PlayruoReadyMessage {
|
|
94
|
-
type: "playruo_ready";
|
|
95
|
-
}
|
|
96
|
-
interface PlayruoStateUpdateMessage {
|
|
97
|
-
type: "playruo_state_update";
|
|
98
|
-
data: PlayruoEmbedState;
|
|
99
|
-
}
|
|
100
|
-
interface PlayruoPurchaseRequestMessage {
|
|
101
|
-
type: "playruo_purchase_request";
|
|
102
|
-
data: {
|
|
103
|
-
storeUrl: string;
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
interface PlayruoDemoCompletedMessage {
|
|
107
|
-
type: "playruo_demo_completed";
|
|
108
|
-
data: DemoCompletedPayload;
|
|
109
|
-
}
|
|
110
|
-
interface PlayruoErrorMessage {
|
|
111
|
-
type: "playruo_error";
|
|
112
|
-
data: {
|
|
113
|
-
message: string;
|
|
114
|
-
} | string;
|
|
115
|
-
}
|
|
116
|
-
interface PlayruoSessionOverMessage {
|
|
117
|
-
type: "playruo_session_over";
|
|
118
|
-
data: PlayruoEmbedState;
|
|
119
|
-
}
|
|
120
|
-
interface PlayruoStreamStartMessage {
|
|
121
|
-
type: "playruo_stream_start";
|
|
122
|
-
}
|
|
123
|
-
interface PlayruoStreamStopMessage {
|
|
124
|
-
type: "playruo_stream_stop";
|
|
125
|
-
}
|
|
126
|
-
interface PlayruoRequestExitFullscreenMessage {
|
|
127
|
-
type: "REQUEST_EXIT_FULLSCREEN";
|
|
128
|
-
}
|
|
129
|
-
interface PlayruoEventMessage {
|
|
130
|
-
type: "playruo_event";
|
|
131
|
-
data: PlayruoEventPayload;
|
|
132
|
-
}
|
|
133
|
-
type PlayruoEmbedMessage = PlayruoReadyMessage | PlayruoStateUpdateMessage | PlayruoPurchaseRequestMessage | PlayruoDemoCompletedMessage | PlayruoErrorMessage | PlayruoSessionOverMessage | PlayruoStreamStartMessage | PlayruoStreamStopMessage | PlayruoRequestExitFullscreenMessage | PlayruoEventMessage;
|
|
134
|
-
interface PlayruoInternalMessage {
|
|
135
|
-
type: "playruo";
|
|
136
|
-
action: "tryNowClick" | "exitFullscreen" | "mute" | "unmute";
|
|
137
|
-
fromEmbed: true;
|
|
138
|
-
isReplay?: boolean;
|
|
139
|
-
isFullscreen?: boolean;
|
|
140
|
-
parentWillHandleFullscreen?: boolean;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Type guard to check if a message event is a Playruo embed message
|
|
144
|
-
* Messages FROM Embed → Host via postMessage
|
|
145
|
-
*/
|
|
146
|
-
declare const isPlayruoEmbedMessage: (data: unknown) => data is PlayruoEmbedMessage;
|
|
147
|
-
/**
|
|
148
|
-
* Type guard to check if a message is a Playruo internal message
|
|
149
|
-
* Format: { type: 'playruo', action: '...', fromEmbed: true }
|
|
150
|
-
* These are messages sent TO the iframe (game), not to the parent
|
|
151
|
-
*/
|
|
152
|
-
declare const isPlayruoInternalMessage: (data: unknown) => data is PlayruoInternalMessage;
|
|
153
|
-
|
|
154
235
|
interface BuildUrlParams {
|
|
155
236
|
operation: string;
|
|
237
|
+
/**
|
|
238
|
+
* Which operation of the campaign to open, when it holds more than one. Sent
|
|
239
|
+
* as `?op=`. Without it the campaign picks its own, which is what a single
|
|
240
|
+
* operation campaign wants.
|
|
241
|
+
*/
|
|
242
|
+
operationKey?: string;
|
|
156
243
|
storeUrl?: string;
|
|
157
244
|
}
|
|
158
245
|
/**
|
|
@@ -161,6 +248,6 @@ interface BuildUrlParams {
|
|
|
161
248
|
* buildEmbedUrl({ operation: "my-game" })
|
|
162
249
|
* // => "https://playruo.live/my-game?iframe=true"
|
|
163
250
|
*/
|
|
164
|
-
declare const buildEmbedUrl: ({ operation, storeUrl }: BuildUrlParams) => string;
|
|
251
|
+
declare const buildEmbedUrl: ({ operation, operationKey, storeUrl, }: BuildUrlParams) => string;
|
|
165
252
|
|
|
166
|
-
export { type DemoCompletedPayload, EmbedTester, type EmbedTesterProps, type PlayruoDemoCompletedMessage, PlayruoEmbed, type PlayruoEmbedActions, type PlayruoEmbedMessage, type PlayruoEmbedProps, type PlayruoEmbedRenderState, type PlayruoEmbedState, type PlayruoErrorMessage, type PlayruoEventMessage, type PlayruoEventPayload, type PlayruoInternalMessage, type PlayruoPurchaseRequestMessage, type PlayruoReadyMessage, type PlayruoRequestExitFullscreenMessage, type PlayruoSessionOverMessage, type PlayruoStateUpdateMessage, type PlayruoStreamStartMessage, type PlayruoStreamStopMessage, buildEmbedUrl, isPlayruoEmbedMessage, isPlayruoInternalMessage };
|
|
253
|
+
export { type DemoCompletedPayload, EmbedTester, type EmbedTesterProps, type PlayruoDemoCompletedMessage, PlayruoEmbed, type PlayruoEmbedActions, type PlayruoEmbedMessage, type PlayruoEmbedPasswordState, type PlayruoEmbedProps, type PlayruoEmbedRenderState, type PlayruoEmbedState, type PlayruoErrorMessage, type PlayruoEventMessage, type PlayruoEventPayload, type PlayruoInternalMessage, type PlayruoPasswordError, type PlayruoPasswordErrorCode, type PlayruoPasswordNotRequiredMessage, type PlayruoPasswordRequiredMessage, type PlayruoPasswordResultMessage, type PlayruoPurchaseRequestMessage, type PlayruoReadyMessage, type PlayruoRequestExitFullscreenMessage, type PlayruoSessionOverMessage, type PlayruoStateUpdateMessage, type PlayruoStreamStartMessage, type PlayruoStreamStopMessage, buildEmbedUrl, isPlayruoEmbedMessage, isPlayruoInternalMessage };
|
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,106 @@ type PlayruoEventPayload = Record<string, unknown> & {
|
|
|
24
24
|
name?: string;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
+
interface PlayruoReadyMessage {
|
|
28
|
+
type: "playruo_ready";
|
|
29
|
+
}
|
|
30
|
+
interface PlayruoStateUpdateMessage {
|
|
31
|
+
type: "playruo_state_update";
|
|
32
|
+
data: PlayruoEmbedState;
|
|
33
|
+
}
|
|
34
|
+
interface PlayruoPurchaseRequestMessage {
|
|
35
|
+
type: "playruo_purchase_request";
|
|
36
|
+
data: {
|
|
37
|
+
storeUrl: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
interface PlayruoDemoCompletedMessage {
|
|
41
|
+
type: "playruo_demo_completed";
|
|
42
|
+
data: DemoCompletedPayload;
|
|
43
|
+
}
|
|
44
|
+
interface PlayruoErrorMessage {
|
|
45
|
+
type: "playruo_error";
|
|
46
|
+
data: {
|
|
47
|
+
message: string;
|
|
48
|
+
} | string;
|
|
49
|
+
}
|
|
50
|
+
interface PlayruoSessionOverMessage {
|
|
51
|
+
type: "playruo_session_over";
|
|
52
|
+
data: PlayruoEmbedState;
|
|
53
|
+
}
|
|
54
|
+
interface PlayruoStreamStartMessage {
|
|
55
|
+
type: "playruo_stream_start";
|
|
56
|
+
}
|
|
57
|
+
interface PlayruoStreamStopMessage {
|
|
58
|
+
type: "playruo_stream_stop";
|
|
59
|
+
}
|
|
60
|
+
interface PlayruoRequestExitFullscreenMessage {
|
|
61
|
+
type: "REQUEST_EXIT_FULLSCREEN";
|
|
62
|
+
}
|
|
63
|
+
interface PlayruoEventMessage {
|
|
64
|
+
type: "playruo_event";
|
|
65
|
+
data: PlayruoEventPayload;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Why a password submission was refused. `already_validating` answers a submit
|
|
69
|
+
* sent while another one is still being checked, so the host may simply send it
|
|
70
|
+
* again; `too_many_attempts` closes the operation for this visitor and reopens
|
|
71
|
+
* on its own after a delay.
|
|
72
|
+
*/
|
|
73
|
+
type PlayruoPasswordError = "invalid_password" | "already_validating" | "too_many_attempts";
|
|
74
|
+
/**
|
|
75
|
+
* A refusal code as a host reads it: one of the codes above, or any other one
|
|
76
|
+
* the operation may answer with. `string & {}` rather than `string`, which
|
|
77
|
+
* would absorb the union and drop the known codes from autocompletion.
|
|
78
|
+
*/
|
|
79
|
+
type PlayruoPasswordErrorCode = PlayruoPasswordError | (string & {});
|
|
80
|
+
/**
|
|
81
|
+
* A password protected operation announces itself once its configuration is
|
|
82
|
+
* loaded. The iframe stays invisible until a session starts, so it renders no
|
|
83
|
+
* form of its own: the host collects the password and sends it back with the
|
|
84
|
+
* submitPassword action.
|
|
85
|
+
*/
|
|
86
|
+
interface PlayruoPasswordRequiredMessage {
|
|
87
|
+
type: "playruo_password_required";
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Answers a requestPassword sent to an operation that is not protected. Without
|
|
91
|
+
* it a host cannot tell "no password needed" from "the announce has not come
|
|
92
|
+
* yet", and waits forever on a gate that will never open.
|
|
93
|
+
*/
|
|
94
|
+
interface PlayruoPasswordNotRequiredMessage {
|
|
95
|
+
type: "playruo_password_not_required";
|
|
96
|
+
}
|
|
97
|
+
interface PlayruoPasswordResultMessage {
|
|
98
|
+
type: "playruo_password_result";
|
|
99
|
+
data: {
|
|
100
|
+
success: boolean;
|
|
101
|
+
error?: PlayruoPasswordErrorCode;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
type PlayruoEmbedMessage = PlayruoReadyMessage | PlayruoStateUpdateMessage | PlayruoPurchaseRequestMessage | PlayruoDemoCompletedMessage | PlayruoErrorMessage | PlayruoSessionOverMessage | PlayruoStreamStartMessage | PlayruoStreamStopMessage | PlayruoRequestExitFullscreenMessage | PlayruoEventMessage | PlayruoPasswordRequiredMessage | PlayruoPasswordNotRequiredMessage | PlayruoPasswordResultMessage;
|
|
105
|
+
interface PlayruoInternalMessage {
|
|
106
|
+
type: "playruo";
|
|
107
|
+
action: "tryNowClick" | "exitFullscreen" | "mute" | "unmute" | "submitPassword" | "requestPassword";
|
|
108
|
+
fromEmbed: true;
|
|
109
|
+
isReplay?: boolean;
|
|
110
|
+
isFullscreen?: boolean;
|
|
111
|
+
parentWillHandleFullscreen?: boolean;
|
|
112
|
+
/** Only read by the submitPassword action. */
|
|
113
|
+
password?: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Type guard to check if a message event is a Playruo embed message
|
|
117
|
+
* Messages FROM Embed → Host via postMessage
|
|
118
|
+
*/
|
|
119
|
+
declare const isPlayruoEmbedMessage: (data: unknown) => data is PlayruoEmbedMessage;
|
|
120
|
+
/**
|
|
121
|
+
* Type guard to check if a message is a Playruo internal message
|
|
122
|
+
* Format: { type: 'playruo', action: '...', fromEmbed: true }
|
|
123
|
+
* These are messages sent TO the iframe (game), not to the parent
|
|
124
|
+
*/
|
|
125
|
+
declare const isPlayruoInternalMessage: (data: unknown) => data is PlayruoInternalMessage;
|
|
126
|
+
|
|
27
127
|
interface PlayruoEmbedActions {
|
|
28
128
|
/** Start the demo session */
|
|
29
129
|
tryNow: () => void;
|
|
@@ -33,17 +133,52 @@ interface PlayruoEmbedActions {
|
|
|
33
133
|
canTryNow: boolean;
|
|
34
134
|
/** Whether buy now is currently available */
|
|
35
135
|
canBuyNow: boolean;
|
|
136
|
+
/** Send the password collected by the host to a protected operation. */
|
|
137
|
+
submitPassword: (password: string) => void;
|
|
138
|
+
/**
|
|
139
|
+
* Ask the operation to announce again whether it needs a password. The
|
|
140
|
+
* announcement is emitted once, so a host that mounts late can miss it.
|
|
141
|
+
*/
|
|
142
|
+
requestPassword: () => void;
|
|
143
|
+
}
|
|
144
|
+
interface PlayruoEmbedPasswordState {
|
|
145
|
+
/**
|
|
146
|
+
* The operation asked for a password. Stays true once it was given, so read
|
|
147
|
+
* `unlocked` for the gate itself.
|
|
148
|
+
*/
|
|
149
|
+
required: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* The operation said whether it is protected. Until then `required: false`
|
|
152
|
+
* only means nothing was announced yet, so a host that called
|
|
153
|
+
* `requestPassword` cannot tell an unprotected operation from a silent one.
|
|
154
|
+
*/
|
|
155
|
+
checked: boolean;
|
|
156
|
+
/** A submitted password was accepted. */
|
|
157
|
+
unlocked: boolean;
|
|
158
|
+
/** Code of the last refusal, from PlayruoPasswordError when known. */
|
|
159
|
+
error?: PlayruoPasswordErrorCode;
|
|
36
160
|
}
|
|
37
161
|
interface PlayruoEmbedRenderState {
|
|
38
162
|
status: "loading" | "available" | "unavailable" | "error";
|
|
39
163
|
message?: string;
|
|
40
164
|
actions: PlayruoEmbedActions;
|
|
165
|
+
/**
|
|
166
|
+
* A protected operation never announces ready while it is locked, so a host
|
|
167
|
+
* that ignores this stays on `loading` for as long as the visitor has not
|
|
168
|
+
* been asked for the password.
|
|
169
|
+
*/
|
|
170
|
+
password: PlayruoEmbedPasswordState;
|
|
41
171
|
}
|
|
42
172
|
interface PlayruoEmbedProps {
|
|
43
173
|
/** Game origin (scheme + host). Omit to use production (`https://playruo.live`). */
|
|
44
174
|
baseUrl?: string;
|
|
45
175
|
/** Game operation slug used to build the iframe URL. */
|
|
46
176
|
operation: string;
|
|
177
|
+
/**
|
|
178
|
+
* Which operation of the campaign to open, when it holds more than one. Sent
|
|
179
|
+
* as `?op=`. Without it the campaign picks its own.
|
|
180
|
+
*/
|
|
181
|
+
operationKey?: string;
|
|
47
182
|
storeUrl?: string;
|
|
48
183
|
showIframe?: boolean;
|
|
49
184
|
className?: string;
|
|
@@ -55,6 +190,13 @@ interface PlayruoEmbedProps {
|
|
|
55
190
|
storeUrl: string;
|
|
56
191
|
}) => void;
|
|
57
192
|
onError?: (error: string) => void;
|
|
193
|
+
/** The operation is password protected and waits for one. */
|
|
194
|
+
onPasswordRequired?: () => void;
|
|
195
|
+
/** Answer to a submitted password. */
|
|
196
|
+
onPasswordResult?: (result: {
|
|
197
|
+
success: boolean;
|
|
198
|
+
error?: PlayruoPasswordErrorCode;
|
|
199
|
+
}) => void;
|
|
58
200
|
/**
|
|
59
201
|
* Skip the parent fullscreen request and start the experience inside the
|
|
60
202
|
* current iframe bounds. Defaults to false to preserve the current behavior.
|
|
@@ -74,7 +216,7 @@ interface PlayruoEmbedProps {
|
|
|
74
216
|
/**
|
|
75
217
|
* Ref to access the iframe element for fullscreen requests
|
|
76
218
|
*/
|
|
77
|
-
iframeRef?: React.RefObject<HTMLIFrameElement>;
|
|
219
|
+
iframeRef?: React.RefObject<HTMLIFrameElement | null>;
|
|
78
220
|
}
|
|
79
221
|
declare const PlayruoEmbed: FC<PlayruoEmbedProps>;
|
|
80
222
|
|
|
@@ -90,69 +232,14 @@ interface EmbedTesterProps {
|
|
|
90
232
|
}
|
|
91
233
|
declare const EmbedTester: (props?: EmbedTesterProps) => react_jsx_runtime.JSX.Element;
|
|
92
234
|
|
|
93
|
-
interface PlayruoReadyMessage {
|
|
94
|
-
type: "playruo_ready";
|
|
95
|
-
}
|
|
96
|
-
interface PlayruoStateUpdateMessage {
|
|
97
|
-
type: "playruo_state_update";
|
|
98
|
-
data: PlayruoEmbedState;
|
|
99
|
-
}
|
|
100
|
-
interface PlayruoPurchaseRequestMessage {
|
|
101
|
-
type: "playruo_purchase_request";
|
|
102
|
-
data: {
|
|
103
|
-
storeUrl: string;
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
interface PlayruoDemoCompletedMessage {
|
|
107
|
-
type: "playruo_demo_completed";
|
|
108
|
-
data: DemoCompletedPayload;
|
|
109
|
-
}
|
|
110
|
-
interface PlayruoErrorMessage {
|
|
111
|
-
type: "playruo_error";
|
|
112
|
-
data: {
|
|
113
|
-
message: string;
|
|
114
|
-
} | string;
|
|
115
|
-
}
|
|
116
|
-
interface PlayruoSessionOverMessage {
|
|
117
|
-
type: "playruo_session_over";
|
|
118
|
-
data: PlayruoEmbedState;
|
|
119
|
-
}
|
|
120
|
-
interface PlayruoStreamStartMessage {
|
|
121
|
-
type: "playruo_stream_start";
|
|
122
|
-
}
|
|
123
|
-
interface PlayruoStreamStopMessage {
|
|
124
|
-
type: "playruo_stream_stop";
|
|
125
|
-
}
|
|
126
|
-
interface PlayruoRequestExitFullscreenMessage {
|
|
127
|
-
type: "REQUEST_EXIT_FULLSCREEN";
|
|
128
|
-
}
|
|
129
|
-
interface PlayruoEventMessage {
|
|
130
|
-
type: "playruo_event";
|
|
131
|
-
data: PlayruoEventPayload;
|
|
132
|
-
}
|
|
133
|
-
type PlayruoEmbedMessage = PlayruoReadyMessage | PlayruoStateUpdateMessage | PlayruoPurchaseRequestMessage | PlayruoDemoCompletedMessage | PlayruoErrorMessage | PlayruoSessionOverMessage | PlayruoStreamStartMessage | PlayruoStreamStopMessage | PlayruoRequestExitFullscreenMessage | PlayruoEventMessage;
|
|
134
|
-
interface PlayruoInternalMessage {
|
|
135
|
-
type: "playruo";
|
|
136
|
-
action: "tryNowClick" | "exitFullscreen" | "mute" | "unmute";
|
|
137
|
-
fromEmbed: true;
|
|
138
|
-
isReplay?: boolean;
|
|
139
|
-
isFullscreen?: boolean;
|
|
140
|
-
parentWillHandleFullscreen?: boolean;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Type guard to check if a message event is a Playruo embed message
|
|
144
|
-
* Messages FROM Embed → Host via postMessage
|
|
145
|
-
*/
|
|
146
|
-
declare const isPlayruoEmbedMessage: (data: unknown) => data is PlayruoEmbedMessage;
|
|
147
|
-
/**
|
|
148
|
-
* Type guard to check if a message is a Playruo internal message
|
|
149
|
-
* Format: { type: 'playruo', action: '...', fromEmbed: true }
|
|
150
|
-
* These are messages sent TO the iframe (game), not to the parent
|
|
151
|
-
*/
|
|
152
|
-
declare const isPlayruoInternalMessage: (data: unknown) => data is PlayruoInternalMessage;
|
|
153
|
-
|
|
154
235
|
interface BuildUrlParams {
|
|
155
236
|
operation: string;
|
|
237
|
+
/**
|
|
238
|
+
* Which operation of the campaign to open, when it holds more than one. Sent
|
|
239
|
+
* as `?op=`. Without it the campaign picks its own, which is what a single
|
|
240
|
+
* operation campaign wants.
|
|
241
|
+
*/
|
|
242
|
+
operationKey?: string;
|
|
156
243
|
storeUrl?: string;
|
|
157
244
|
}
|
|
158
245
|
/**
|
|
@@ -161,6 +248,6 @@ interface BuildUrlParams {
|
|
|
161
248
|
* buildEmbedUrl({ operation: "my-game" })
|
|
162
249
|
* // => "https://playruo.live/my-game?iframe=true"
|
|
163
250
|
*/
|
|
164
|
-
declare const buildEmbedUrl: ({ operation, storeUrl }: BuildUrlParams) => string;
|
|
251
|
+
declare const buildEmbedUrl: ({ operation, operationKey, storeUrl, }: BuildUrlParams) => string;
|
|
165
252
|
|
|
166
|
-
export { type DemoCompletedPayload, EmbedTester, type EmbedTesterProps, type PlayruoDemoCompletedMessage, PlayruoEmbed, type PlayruoEmbedActions, type PlayruoEmbedMessage, type PlayruoEmbedProps, type PlayruoEmbedRenderState, type PlayruoEmbedState, type PlayruoErrorMessage, type PlayruoEventMessage, type PlayruoEventPayload, type PlayruoInternalMessage, type PlayruoPurchaseRequestMessage, type PlayruoReadyMessage, type PlayruoRequestExitFullscreenMessage, type PlayruoSessionOverMessage, type PlayruoStateUpdateMessage, type PlayruoStreamStartMessage, type PlayruoStreamStopMessage, buildEmbedUrl, isPlayruoEmbedMessage, isPlayruoInternalMessage };
|
|
253
|
+
export { type DemoCompletedPayload, EmbedTester, type EmbedTesterProps, type PlayruoDemoCompletedMessage, PlayruoEmbed, type PlayruoEmbedActions, type PlayruoEmbedMessage, type PlayruoEmbedPasswordState, type PlayruoEmbedProps, type PlayruoEmbedRenderState, type PlayruoEmbedState, type PlayruoErrorMessage, type PlayruoEventMessage, type PlayruoEventPayload, type PlayruoInternalMessage, type PlayruoPasswordError, type PlayruoPasswordErrorCode, type PlayruoPasswordNotRequiredMessage, type PlayruoPasswordRequiredMessage, type PlayruoPasswordResultMessage, type PlayruoPurchaseRequestMessage, type PlayruoReadyMessage, type PlayruoRequestExitFullscreenMessage, type PlayruoSessionOverMessage, type PlayruoStateUpdateMessage, type PlayruoStreamStartMessage, type PlayruoStreamStopMessage, buildEmbedUrl, isPlayruoEmbedMessage, isPlayruoInternalMessage };
|