@puzzmo/sdk 1.0.68 → 1.0.70
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/analytics.d.ts +7 -1
- package/dist/analytics.d.ts.map +1 -1
- package/dist/gameTracker.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.global.js +1 -1
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +131 -107
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -70,8 +70,9 @@ var s = (e) => {
|
|
|
70
70
|
};
|
|
71
71
|
}();
|
|
72
72
|
const l = (e) => {
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
var n;
|
|
74
|
+
let r = {
|
|
75
|
+
context: t(t({}, e), {}, { deviceType: (n = e.deviceType) == null ? u() : n }),
|
|
75
76
|
updateCount: 0,
|
|
76
77
|
startTime: /* @__PURE__ */ new Date(),
|
|
77
78
|
tracked: {
|
|
@@ -82,31 +83,49 @@ const l = (e) => {
|
|
|
82
83
|
}
|
|
83
84
|
};
|
|
84
85
|
return {
|
|
85
|
-
trackEvent: (e,
|
|
86
|
-
let
|
|
86
|
+
trackEvent: (e, t) => {
|
|
87
|
+
let n = ((/* @__PURE__ */ new Date()).getTime() - r.startTime.getTime()) / 1e3;
|
|
87
88
|
switch (e) {
|
|
88
89
|
case "READY_GAME_LOADED":
|
|
89
|
-
|
|
90
|
+
r.tracked.pageView || (c(r.context, "page_view"), r.tracked.pageView = !0);
|
|
90
91
|
break;
|
|
91
92
|
case "UPLOAD_NEW_GAME_STATE":
|
|
92
|
-
|
|
93
|
+
r.updateCount++, r.updateCount > 2 && !r.tracked.gameplayActive && (c(r.context, "gameplay_active"), r.tracked.gameplayActive = !0), n > 30 && (r.tracked.gameplayActive || (c(r.context, "gameplay_active"), r.tracked.gameplayActive = !0), r.tracked.active30s || (c(r.context, "active_30s"), r.tracked.active30s = !0));
|
|
93
94
|
break;
|
|
94
95
|
case "GAME_COMPLETED":
|
|
95
|
-
!
|
|
96
|
+
!r.tracked.completed && t != null && t.input && (c(r.context, "completed", {}, t.input.elapsedTimeSecs), r.tracked.completed = !0);
|
|
96
97
|
break;
|
|
97
98
|
}
|
|
98
99
|
},
|
|
99
100
|
trackLinkClick: (e) => {
|
|
100
|
-
c(
|
|
101
|
+
c(r.context, "link_click", e);
|
|
101
102
|
}
|
|
102
103
|
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* The kind of device the game runs on, judged by the whole device rather than the game's frame. A copy of
|
|
107
|
+
* detectDeviceType in @puzzmo-com/clickhouse/deviceType, kept dependency-free for the published SDK.
|
|
108
|
+
*/
|
|
109
|
+
var u = () => {
|
|
110
|
+
var e, t, n;
|
|
111
|
+
if (typeof navigator > "u" || typeof window > "u") return "unknown";
|
|
112
|
+
let r = navigator.userAgent;
|
|
113
|
+
if (/iPad/.test(r) || /Macintosh/.test(r) && navigator.maxTouchPoints > 1) return "tablet";
|
|
114
|
+
let i = (e = navigator.userAgentData) == null ? void 0 : e.mobile;
|
|
115
|
+
return /iPhone|iPod/.test(r) || i ? "mobile" : /Android/.test(r) ? /Mobile/.test(r) ? "mobile" : "tablet" : /Mobile|Windows Phone/.test(r) ? "mobile" : (t = (n = window).matchMedia) != null && t.call(n, "(pointer: coarse)").matches ? Math.min(screen.width, screen.height) < 600 ? "mobile" : "tablet" : "desktop";
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Build the analytics tracker for a game, or null when analytics shouldn't run
|
|
119
|
+
* (the game doesn't bring its own runtime, no browser, running on localhost, or
|
|
120
|
+
* missing bootstrap data).
|
|
121
|
+
*/
|
|
122
|
+
const d = (e) => {
|
|
123
|
+
if (!_(e)) return null;
|
|
124
|
+
let t = p();
|
|
106
125
|
if (!t.enabled) return null;
|
|
107
|
-
let n =
|
|
126
|
+
let n = m(e, t.apiRoot);
|
|
108
127
|
return n ? l(n) : null;
|
|
109
|
-
},
|
|
128
|
+
}, f = (e) => {
|
|
110
129
|
if (typeof document > "u") return () => {};
|
|
111
130
|
let t = (t) => {
|
|
112
131
|
var n, r;
|
|
@@ -122,7 +141,7 @@ const l = (e) => {
|
|
|
122
141
|
return document.addEventListener("click", t), () => document.removeEventListener("click", t);
|
|
123
142
|
};
|
|
124
143
|
/** Picks the events endpoint, and disables analytics entirely on localhost (dev + simulator). */
|
|
125
|
-
var
|
|
144
|
+
var p = () => {
|
|
126
145
|
if (typeof window > "u" || !window.location) return {
|
|
127
146
|
apiRoot: "",
|
|
128
147
|
enabled: !1
|
|
@@ -135,37 +154,42 @@ var f = () => {
|
|
|
135
154
|
apiRoot: e.includes("staging") ? "https://api-staging.puzzmo.com/" : "https://api.puzzmo.com/",
|
|
136
155
|
enabled: !0
|
|
137
156
|
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
let
|
|
157
|
+
};
|
|
158
|
+
/** Derive the analytics context from the host's bootstrap data, or null if a game isn't present. */
|
|
159
|
+
const m = (e, t) => {
|
|
160
|
+
var n, r, i, a, o, s, c, l;
|
|
161
|
+
let u = e == null ? void 0 : e.session;
|
|
162
|
+
if (!u) return null;
|
|
163
|
+
let d = u.gameplay, f = u.puzzle, p = (n = e == null ? void 0 : e.hostContext) == null ? [] : n, m = p.find((e) => (e == null ? void 0 : e.type) === "embed");
|
|
143
164
|
return {
|
|
144
165
|
gameSlug: (e == null || (r = e.game) == null ? void 0 : r.slug) || "unknown",
|
|
145
|
-
puzzleID:
|
|
146
|
-
gameplayOwnerID:
|
|
166
|
+
puzzleID: f.id,
|
|
167
|
+
gameplayOwnerID: d.ownerID || (e == null || (i = e.userState) == null ? void 0 : i.id) || "unknown",
|
|
147
168
|
apiRoot: t,
|
|
148
|
-
userType:
|
|
149
|
-
runtimeType:
|
|
169
|
+
userType: h(e == null || (a = e.currentUser) == null ? void 0 : a.type),
|
|
170
|
+
runtimeType: v(p),
|
|
150
171
|
userID: e == null || (o = e.currentUser) == null ? void 0 : o.id,
|
|
151
|
-
teamSlug: ((s =
|
|
152
|
-
partnerSlug: ((c =
|
|
153
|
-
dailyDateKey: (l =
|
|
154
|
-
embedID: (
|
|
172
|
+
teamSlug: ((s = f.team) == null ? void 0 : s.slug) || void 0,
|
|
173
|
+
partnerSlug: (m == null || (c = m.partner) == null ? void 0 : c.slug) || (e == null ? void 0 : e.partnerSlug) || void 0,
|
|
174
|
+
dailyDateKey: (l = f.mostRecentDaily) == null || (l = l.daily) == null ? void 0 : l.dateKey,
|
|
175
|
+
embedID: (m == null ? void 0 : m.embedID) || void 0
|
|
155
176
|
};
|
|
156
|
-
}
|
|
177
|
+
};
|
|
178
|
+
/** Map the user's subscription tier to the analytics user bucket. */
|
|
179
|
+
var h = (e) => !e || e === "Unverified" ? "anon" : e === "Paid" ? "paid" : "user", g = 512, _ = (e) => {
|
|
157
180
|
var t, n;
|
|
158
|
-
return (((t = e == null || (n = e.game) == null ? void 0 : n.version.flagsArr[0]) == null ? 0 : t) &
|
|
159
|
-
},
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
181
|
+
return (((t = e == null || (n = e.game) == null ? void 0 : n.version.flagsArr[0]) == null ? 0 : t) & g) === g;
|
|
182
|
+
}, v = (e) => {
|
|
183
|
+
let t = e.find((e) => (e == null ? void 0 : e.type) === "embed");
|
|
184
|
+
if (t) return t.host === "msn" ? "msn" : "iframe";
|
|
185
|
+
let n = e.find((e) => (e == null ? void 0 : e.type) === "app");
|
|
186
|
+
return (n == null ? void 0 : n.host) === "__embed" ? "simple_embed" : (n == null ? void 0 : n.host) === "app-embed" ? "app_embed" : (n == null ? void 0 : n.host) === "ios-app" ? "ios_native" : "puzzmo_com";
|
|
187
|
+
}, y = ["inputString"];
|
|
188
|
+
function b(e) {
|
|
165
189
|
let t = e >= 3600 * 1e3;
|
|
166
190
|
return new Date(e).toISOString().slice(t ? 11 : 14, -1).split(".")[0];
|
|
167
191
|
}
|
|
168
|
-
function
|
|
192
|
+
function x(e = 0, t = 0) {
|
|
169
193
|
let n = e, r = t, i = 0, a, o, s, c = () => {
|
|
170
194
|
var e;
|
|
171
195
|
if (o === void 0) return n + r;
|
|
@@ -212,11 +236,11 @@ function b(e = 0, t = 0) {
|
|
|
212
236
|
isRunning: () => o !== void 0 && s === void 0,
|
|
213
237
|
display: () => {
|
|
214
238
|
let e = c() - r;
|
|
215
|
-
return [
|
|
239
|
+
return [b(Math.max(0, e)), r === 0 ? "" : b(r)];
|
|
216
240
|
}
|
|
217
241
|
};
|
|
218
242
|
}
|
|
219
|
-
function
|
|
243
|
+
function S() {
|
|
220
244
|
let e = /* @__PURE__ */ new Map();
|
|
221
245
|
return typeof window < "u" && window.addEventListener("message", (t) => {
|
|
222
246
|
var n;
|
|
@@ -250,9 +274,9 @@ function x() {
|
|
|
250
274
|
* Stays "1.0" until every host supporting "1.1" is deployed: an older puzzmo.com reloads when it
|
|
251
275
|
* sees a contract it doesn't know.
|
|
252
276
|
*/
|
|
253
|
-
var
|
|
277
|
+
var C = "1.0", w = S();
|
|
254
278
|
/** Creates a Puzzmo SDK instance for communicating with the Puzzmo host */
|
|
255
|
-
const
|
|
279
|
+
const T = (r = {}) => {
|
|
256
280
|
var i;
|
|
257
281
|
let a = null, s = null, c = () => {
|
|
258
282
|
var e;
|
|
@@ -260,7 +284,7 @@ const w = (r = {}) => {
|
|
|
260
284
|
}, l = () => {
|
|
261
285
|
var e, t;
|
|
262
286
|
return (e = (t = c()) == null ? void 0 : t.id) == null ? null : e;
|
|
263
|
-
},
|
|
287
|
+
}, u = () => {
|
|
264
288
|
var e, t;
|
|
265
289
|
return (e = a == null || (t = a.session) == null ? void 0 : t.puzzle.puzzle) == null ? null : e;
|
|
266
290
|
}, p = () => {
|
|
@@ -272,15 +296,15 @@ const w = (r = {}) => {
|
|
|
272
296
|
}, h = () => {
|
|
273
297
|
var e, t;
|
|
274
298
|
return (e = (t = c()) == null ? void 0 : t.completed) == null ? !1 : e;
|
|
275
|
-
}, g = /* @__PURE__ */ new Map(), _ = null,
|
|
276
|
-
|
|
277
|
-
},
|
|
299
|
+
}, g = /* @__PURE__ */ new Map(), _ = null, v = null, b = !1, S = (e, t) => {
|
|
300
|
+
b || v == null || v.trackEvent(e, t);
|
|
301
|
+
}, T = x(), D = null, O = null, k = () => {
|
|
278
302
|
D || (D = setInterval(() => {
|
|
279
|
-
if (
|
|
280
|
-
let [e, t] =
|
|
281
|
-
|
|
303
|
+
if (T.isPaused()) return;
|
|
304
|
+
let [e, t] = T.display();
|
|
305
|
+
w.sendMessage("TIMER_TICK", { display: [e, t] });
|
|
282
306
|
}, 500), O = setInterval(() => {
|
|
283
|
-
|
|
307
|
+
T.isPaused() || w.sendMessage("TIMER_SYNC", Math.floor(T.timeWithoutPenaltySecs()));
|
|
284
308
|
}, 1e4));
|
|
285
309
|
}, A = () => {
|
|
286
310
|
D && (clearInterval(D), D = null), O && (clearInterval(O), O = null);
|
|
@@ -288,21 +312,21 @@ const w = (r = {}) => {
|
|
|
288
312
|
let n = g.get(e);
|
|
289
313
|
n && n.forEach((e) => e(t));
|
|
290
314
|
};
|
|
291
|
-
|
|
292
|
-
|
|
315
|
+
w.onMessage("START_GAME", () => {
|
|
316
|
+
T._init(), k(), j("start");
|
|
293
317
|
});
|
|
294
318
|
let M = () => {
|
|
295
|
-
let e =
|
|
296
|
-
|
|
319
|
+
let e = T.isPaused();
|
|
320
|
+
T._pause(), T.isPaused() !== e && j("pause");
|
|
297
321
|
}, N = () => {
|
|
298
|
-
let e =
|
|
299
|
-
|
|
322
|
+
let e = T.isPaused();
|
|
323
|
+
T._resume(), T.isPaused() !== e && j("resume");
|
|
300
324
|
};
|
|
301
|
-
|
|
325
|
+
w.onMessage("PAUSE_GAME", M), w.onMessage("RESUME_GAME", N), w.onMessage("SETTINGS_UPDATE", (e) => {
|
|
302
326
|
_ = t(t({}, _), e), j("settingsUpdate", _);
|
|
303
|
-
}),
|
|
304
|
-
|
|
305
|
-
}),
|
|
327
|
+
}), w.onMessage("KEYBOARD_KEY_PRESS", (e) => j("keyboardKeyPress", e)), w.onMessage("KEYBOARD_CURSOR_CHANGE", (e) => j("keyboardCursorChange", e)), w.onMessage("KEYBOARD_CURSOR_END", () => j("keyboardCursorEnd")), w.onMessage("RETRY_PUZZLE", () => {
|
|
328
|
+
T._reset(), A(), j("retry");
|
|
329
|
+
}), w.onMessage("READY_DATA", (e) => {
|
|
306
330
|
var t;
|
|
307
331
|
let n = o(e);
|
|
308
332
|
a = n;
|
|
@@ -318,32 +342,32 @@ const w = (r = {}) => {
|
|
|
318
342
|
_ = (c = t) == null ? {} : c;
|
|
319
343
|
}
|
|
320
344
|
if (r) {
|
|
321
|
-
var l,
|
|
322
|
-
let e = ((l = r.elapsedTimeSecs) == null ? 0 : l) * 1e3, t = ((
|
|
323
|
-
|
|
345
|
+
var l, u;
|
|
346
|
+
let e = ((l = r.elapsedTimeSecs) == null ? 0 : l) * 1e3, t = ((u = r.additionalTimeAddedSecs) == null ? 0 : u) * 1e3;
|
|
347
|
+
T._reset(e, t);
|
|
324
348
|
}
|
|
325
|
-
if (!
|
|
349
|
+
if (!v) {
|
|
326
350
|
var p;
|
|
327
|
-
|
|
351
|
+
v = d(n), b = (p = r == null ? void 0 : r.completed) == null ? !1 : p, v && f((e) => v.trackLinkClick(e));
|
|
328
352
|
}
|
|
329
353
|
s && (s(n), s = null);
|
|
330
354
|
});
|
|
331
355
|
let P = {
|
|
332
|
-
timeMs: () =>
|
|
333
|
-
timeSecs: () =>
|
|
334
|
-
addedTimeMs: () =>
|
|
335
|
-
addedTimeSecs: () =>
|
|
336
|
-
timeWithoutPenaltySecs: () =>
|
|
337
|
-
display: () =>
|
|
338
|
-
addPenalty: (e) =>
|
|
339
|
-
setPenalty: (e) =>
|
|
340
|
-
isPaused: () =>
|
|
341
|
-
isRunning: () =>
|
|
356
|
+
timeMs: () => T.timeMs(),
|
|
357
|
+
timeSecs: () => T.timeSecs(),
|
|
358
|
+
addedTimeMs: () => T.addedTimeMs(),
|
|
359
|
+
addedTimeSecs: () => T.addedTimeSecs(),
|
|
360
|
+
timeWithoutPenaltySecs: () => T.timeWithoutPenaltySecs(),
|
|
361
|
+
display: () => T.display(),
|
|
362
|
+
addPenalty: (e) => T.addPenalty(e),
|
|
363
|
+
setPenalty: (e) => T.setPenalty(e),
|
|
364
|
+
isPaused: () => T.isPaused(),
|
|
365
|
+
isRunning: () => T.isRunning(),
|
|
342
366
|
pause: M,
|
|
343
367
|
resume: N
|
|
344
368
|
}, F = {
|
|
345
|
-
send: (e, t) =>
|
|
346
|
-
on: (e, t) =>
|
|
369
|
+
send: (e, t) => w.sendMessage(e, t),
|
|
370
|
+
on: (e, t) => w.onMessage(e, t),
|
|
347
371
|
timer: P,
|
|
348
372
|
bootstrap: () => a
|
|
349
373
|
}, I = {};
|
|
@@ -354,10 +378,10 @@ const w = (r = {}) => {
|
|
|
354
378
|
gameReady: function() {
|
|
355
379
|
var e = n(function* () {
|
|
356
380
|
var e;
|
|
357
|
-
if (
|
|
381
|
+
if (w.sendMessage("READY", { runtimeContract: C }), u()) {
|
|
358
382
|
let e = p();
|
|
359
383
|
return {
|
|
360
|
-
puzzleString:
|
|
384
|
+
puzzleString: u(),
|
|
361
385
|
inputString: e,
|
|
362
386
|
boardState: e,
|
|
363
387
|
theme: m(),
|
|
@@ -371,7 +395,7 @@ const w = (r = {}) => {
|
|
|
371
395
|
s && (s = null, n(/* @__PURE__ */ Error(`Timeout waiting for READY_DATA after ${t}ms`)));
|
|
372
396
|
}, t);
|
|
373
397
|
});
|
|
374
|
-
let n =
|
|
398
|
+
let n = u();
|
|
375
399
|
if (!n) throw Error("READY_DATA received but no puzzle data found");
|
|
376
400
|
let i = p();
|
|
377
401
|
return {
|
|
@@ -388,11 +412,11 @@ const w = (r = {}) => {
|
|
|
388
412
|
};
|
|
389
413
|
}(),
|
|
390
414
|
gameLoaded: (e = {}) => {
|
|
391
|
-
|
|
415
|
+
w.sendMessage("READY_GAME_LOADED", {
|
|
392
416
|
state: e,
|
|
393
|
-
gameRuntimeContract:
|
|
417
|
+
gameRuntimeContract: C,
|
|
394
418
|
embedRuntimeContract: "1.0"
|
|
395
|
-
}),
|
|
419
|
+
}), S("READY_GAME_LOADED");
|
|
396
420
|
},
|
|
397
421
|
on: (e, t) => (g.has(e) || g.set(e, /* @__PURE__ */ new Set()), g.get(e).add(t), () => {
|
|
398
422
|
var n;
|
|
@@ -405,23 +429,23 @@ const w = (r = {}) => {
|
|
|
405
429
|
updateGameState: (e, t) => {
|
|
406
430
|
var n, r;
|
|
407
431
|
let i = l();
|
|
408
|
-
i && (
|
|
432
|
+
i && (w.sendMessage("UPLOAD_NEW_GAME_STATE", {
|
|
409
433
|
id: i,
|
|
410
434
|
input: {
|
|
411
435
|
boardState: e,
|
|
412
|
-
elapsedTimeSecs: (n = t == null ? void 0 : t.elapsedTimeSecs) == null ?
|
|
413
|
-
additionalTimeAddedSecs: (r = t == null ? void 0 : t.additionalTimeAddedSecs) == null ?
|
|
436
|
+
elapsedTimeSecs: (n = t == null ? void 0 : t.elapsedTimeSecs) == null ? T.timeWithoutPenaltySecs() : n,
|
|
437
|
+
additionalTimeAddedSecs: (r = t == null ? void 0 : t.additionalTimeAddedSecs) == null ? T.addedTimeSecs() : r,
|
|
414
438
|
collabUserReferences: []
|
|
415
439
|
}
|
|
416
|
-
}),
|
|
440
|
+
}), S("UPLOAD_NEW_GAME_STATE"));
|
|
417
441
|
},
|
|
418
442
|
gameCompleted: (n, r) => {
|
|
419
443
|
var i, a, o, s, c;
|
|
420
|
-
|
|
421
|
-
let { inputString: u } = n, d = t(t({}, e(n,
|
|
444
|
+
T._conclude(), A();
|
|
445
|
+
let { inputString: u } = n, d = t(t({}, e(n, y)), {}, {
|
|
422
446
|
boardState: u == null ? n.boardState : u,
|
|
423
|
-
elapsedTimeSecs: (i = n.elapsedTimeSecs) == null ?
|
|
424
|
-
additionalTimeAddedSecs: (a = n.additionalTimeAddedSecs) == null ?
|
|
447
|
+
elapsedTimeSecs: (i = n.elapsedTimeSecs) == null ? T.timeWithoutPenaltySecs() : i,
|
|
448
|
+
additionalTimeAddedSecs: (a = n.additionalTimeAddedSecs) == null ? T.addedTimeSecs() : a
|
|
425
449
|
}), f = (o = r == null ? void 0 : r.deeds) == null ? [] : o;
|
|
426
450
|
f.push({
|
|
427
451
|
id: "points",
|
|
@@ -431,14 +455,14 @@ const w = (r = {}) => {
|
|
|
431
455
|
value: Math.round((s = d.elapsedTimeSecs) == null ? 0 : s) + Math.round((c = d.additionalTimeAddedSecs) == null ? 0 : c)
|
|
432
456
|
});
|
|
433
457
|
let p = l();
|
|
434
|
-
p && (
|
|
458
|
+
p && (w.sendMessage("GAME_COMPLETED", {
|
|
435
459
|
id: p,
|
|
436
460
|
input: d,
|
|
437
461
|
config: r
|
|
438
|
-
}),
|
|
462
|
+
}), S("GAME_COMPLETED", { input: d }));
|
|
439
463
|
},
|
|
440
464
|
showCompletionScreen: (e) => {
|
|
441
|
-
|
|
465
|
+
w.sendMessage("SHOW_GAME_COMPLETE_SCREEN", {
|
|
442
466
|
results: e,
|
|
443
467
|
showRetry: !0
|
|
444
468
|
});
|
|
@@ -447,10 +471,10 @@ const w = (r = {}) => {
|
|
|
447
471
|
var r;
|
|
448
472
|
if (!l()) return;
|
|
449
473
|
let i = (r = p()) == null ? "" : r, a = {
|
|
450
|
-
elapsedTimeSecs:
|
|
451
|
-
additionalTimeAddedSecs:
|
|
474
|
+
elapsedTimeSecs: T.timeWithoutPenaltySecs(),
|
|
475
|
+
additionalTimeAddedSecs: T.addedTimeSecs()
|
|
452
476
|
};
|
|
453
|
-
|
|
477
|
+
w.sendMessage("HIT_CHECKPOINT", {
|
|
454
478
|
checkpointName: e,
|
|
455
479
|
gameplay: {
|
|
456
480
|
inputStr: i,
|
|
@@ -461,7 +485,7 @@ const w = (r = {}) => {
|
|
|
461
485
|
});
|
|
462
486
|
},
|
|
463
487
|
settings: {
|
|
464
|
-
initialize: (e) => (_ = t(t({},
|
|
488
|
+
initialize: (e) => (_ = t(t({}, E(e)), _), w.sendMessage("INITIALIZE_SETTINGS", {
|
|
465
489
|
components: e,
|
|
466
490
|
settings: _
|
|
467
491
|
}), _),
|
|
@@ -469,14 +493,14 @@ const w = (r = {}) => {
|
|
|
469
493
|
var e;
|
|
470
494
|
return (e = _) == null ? {} : e;
|
|
471
495
|
},
|
|
472
|
-
update: (e) => (_ = t(t({}, _), e),
|
|
496
|
+
update: (e) => (_ = t(t({}, _), e), w.sendMessage("UPDATE_SETTINGS_FROM_EMBED", { settings: _ }), _)
|
|
473
497
|
},
|
|
474
498
|
keyboard: {
|
|
475
499
|
show: (e) => {
|
|
476
|
-
|
|
500
|
+
w.sendMessage("KEYBOARD_UPDATE_CONFIG", e);
|
|
477
501
|
},
|
|
478
502
|
hide: () => {
|
|
479
|
-
|
|
503
|
+
w.sendMessage("KEYBOARD_UPDATE_CONFIG", {
|
|
480
504
|
layout: [],
|
|
481
505
|
symbols: {},
|
|
482
506
|
highlight: [],
|
|
@@ -489,18 +513,18 @@ const w = (r = {}) => {
|
|
|
489
513
|
},
|
|
490
514
|
haptics: { play: (e, t) => {
|
|
491
515
|
var n;
|
|
492
|
-
|
|
516
|
+
w.sendMessage("SENSORY_EVENT", {
|
|
493
517
|
id: (n = t == null ? void 0 : t.id) == null ? e : n,
|
|
494
518
|
haptic: e
|
|
495
519
|
});
|
|
496
520
|
} },
|
|
497
|
-
_hostAPI:
|
|
521
|
+
_hostAPI: w
|
|
498
522
|
};
|
|
499
523
|
};
|
|
500
524
|
/** Walks settings UI components (recursing into split groups) collecting name → defaultValue pairs */
|
|
501
|
-
function
|
|
525
|
+
function E(e) {
|
|
502
526
|
let t = {};
|
|
503
|
-
for (let n of e) n.type === "split" ? Object.assign(t,
|
|
527
|
+
for (let n of e) n.type === "split" ? Object.assign(t, E(n.content)) : "name" in n && (t[n.name] = n.defaultValue);
|
|
504
528
|
return t;
|
|
505
529
|
}
|
|
506
530
|
/**
|
|
@@ -515,7 +539,7 @@ function T(e) {
|
|
|
515
539
|
* // Extend with dynamic disabled letters
|
|
516
540
|
* sdk.keyboard.show({ ...defaultKeyboardConfig, disabled: usedLetters })
|
|
517
541
|
*/
|
|
518
|
-
const
|
|
542
|
+
const D = {
|
|
519
543
|
layout: [
|
|
520
544
|
"qwertyuiop",
|
|
521
545
|
"asdfghjkl",
|
|
@@ -531,7 +555,7 @@ const E = {
|
|
|
531
555
|
xl: [],
|
|
532
556
|
l: ["↵", "⌫"],
|
|
533
557
|
supportsDragCursor: !1
|
|
534
|
-
},
|
|
558
|
+
}, O = (e) => {
|
|
535
559
|
let n = {};
|
|
536
560
|
for (let a of e) for (let e of a.keys) {
|
|
537
561
|
var r, i;
|
|
@@ -541,11 +565,11 @@ const E = {
|
|
|
541
565
|
return n;
|
|
542
566
|
};
|
|
543
567
|
/** Custom error class for workshop import failures */
|
|
544
|
-
var
|
|
568
|
+
var k = class extends Error {
|
|
545
569
|
constructor(e, t, n) {
|
|
546
570
|
super(t), this.type = e, this.originalError = n, this.name = "EditorImportError";
|
|
547
571
|
}
|
|
548
572
|
};
|
|
549
|
-
export {
|
|
573
|
+
export { k as EditorImportError, T as createPuzzmoSDK, D as defaultKeyboardConfig, O as keyStylesFromRules };
|
|
550
574
|
|
|
551
575
|
//# sourceMappingURL=index.js.map
|