@puzzmo/sdk 1.0.69 → 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 +4 -0
- 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 +116 -97
- package/dist/index.js.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
|
|
@@ -137,40 +156,40 @@ var f = () => {
|
|
|
137
156
|
};
|
|
138
157
|
};
|
|
139
158
|
/** Derive the analytics context from the host's bootstrap data, or null if a game isn't present. */
|
|
140
|
-
const
|
|
159
|
+
const m = (e, t) => {
|
|
141
160
|
var n, r, i, a, o, s, c, l;
|
|
142
161
|
let u = e == null ? void 0 : e.session;
|
|
143
162
|
if (!u) return null;
|
|
144
|
-
let d = u.gameplay, f = u.puzzle, p = (n = e == null ? void 0 : e.hostContext) == null ? [] : n,
|
|
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");
|
|
145
164
|
return {
|
|
146
165
|
gameSlug: (e == null || (r = e.game) == null ? void 0 : r.slug) || "unknown",
|
|
147
166
|
puzzleID: f.id,
|
|
148
167
|
gameplayOwnerID: d.ownerID || (e == null || (i = e.userState) == null ? void 0 : i.id) || "unknown",
|
|
149
168
|
apiRoot: t,
|
|
150
|
-
userType:
|
|
151
|
-
runtimeType:
|
|
169
|
+
userType: h(e == null || (a = e.currentUser) == null ? void 0 : a.type),
|
|
170
|
+
runtimeType: v(p),
|
|
152
171
|
userID: e == null || (o = e.currentUser) == null ? void 0 : o.id,
|
|
153
172
|
teamSlug: ((s = f.team) == null ? void 0 : s.slug) || void 0,
|
|
154
|
-
partnerSlug: (
|
|
173
|
+
partnerSlug: (m == null || (c = m.partner) == null ? void 0 : c.slug) || (e == null ? void 0 : e.partnerSlug) || void 0,
|
|
155
174
|
dailyDateKey: (l = f.mostRecentDaily) == null || (l = l.daily) == null ? void 0 : l.dateKey,
|
|
156
|
-
embedID: (
|
|
175
|
+
embedID: (m == null ? void 0 : m.embedID) || void 0
|
|
157
176
|
};
|
|
158
177
|
};
|
|
159
178
|
/** Map the user's subscription tier to the analytics user bucket. */
|
|
160
|
-
var
|
|
179
|
+
var h = (e) => !e || e === "Unverified" ? "anon" : e === "Paid" ? "paid" : "user", g = 512, _ = (e) => {
|
|
161
180
|
var t, n;
|
|
162
|
-
return (((t = e == null || (n = e.game) == null ? void 0 : n.version.flagsArr[0]) == null ? 0 : t) &
|
|
163
|
-
},
|
|
181
|
+
return (((t = e == null || (n = e.game) == null ? void 0 : n.version.flagsArr[0]) == null ? 0 : t) & g) === g;
|
|
182
|
+
}, v = (e) => {
|
|
164
183
|
let t = e.find((e) => (e == null ? void 0 : e.type) === "embed");
|
|
165
184
|
if (t) return t.host === "msn" ? "msn" : "iframe";
|
|
166
185
|
let n = e.find((e) => (e == null ? void 0 : e.type) === "app");
|
|
167
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";
|
|
168
|
-
},
|
|
169
|
-
function
|
|
187
|
+
}, y = ["inputString"];
|
|
188
|
+
function b(e) {
|
|
170
189
|
let t = e >= 3600 * 1e3;
|
|
171
190
|
return new Date(e).toISOString().slice(t ? 11 : 14, -1).split(".")[0];
|
|
172
191
|
}
|
|
173
|
-
function
|
|
192
|
+
function x(e = 0, t = 0) {
|
|
174
193
|
let n = e, r = t, i = 0, a, o, s, c = () => {
|
|
175
194
|
var e;
|
|
176
195
|
if (o === void 0) return n + r;
|
|
@@ -217,11 +236,11 @@ function b(e = 0, t = 0) {
|
|
|
217
236
|
isRunning: () => o !== void 0 && s === void 0,
|
|
218
237
|
display: () => {
|
|
219
238
|
let e = c() - r;
|
|
220
|
-
return [
|
|
239
|
+
return [b(Math.max(0, e)), r === 0 ? "" : b(r)];
|
|
221
240
|
}
|
|
222
241
|
};
|
|
223
242
|
}
|
|
224
|
-
function
|
|
243
|
+
function S() {
|
|
225
244
|
let e = /* @__PURE__ */ new Map();
|
|
226
245
|
return typeof window < "u" && window.addEventListener("message", (t) => {
|
|
227
246
|
var n;
|
|
@@ -255,9 +274,9 @@ function x() {
|
|
|
255
274
|
* Stays "1.0" until every host supporting "1.1" is deployed: an older puzzmo.com reloads when it
|
|
256
275
|
* sees a contract it doesn't know.
|
|
257
276
|
*/
|
|
258
|
-
var
|
|
277
|
+
var C = "1.0", w = S();
|
|
259
278
|
/** Creates a Puzzmo SDK instance for communicating with the Puzzmo host */
|
|
260
|
-
const
|
|
279
|
+
const T = (r = {}) => {
|
|
261
280
|
var i;
|
|
262
281
|
let a = null, s = null, c = () => {
|
|
263
282
|
var e;
|
|
@@ -265,7 +284,7 @@ const w = (r = {}) => {
|
|
|
265
284
|
}, l = () => {
|
|
266
285
|
var e, t;
|
|
267
286
|
return (e = (t = c()) == null ? void 0 : t.id) == null ? null : e;
|
|
268
|
-
},
|
|
287
|
+
}, u = () => {
|
|
269
288
|
var e, t;
|
|
270
289
|
return (e = a == null || (t = a.session) == null ? void 0 : t.puzzle.puzzle) == null ? null : e;
|
|
271
290
|
}, p = () => {
|
|
@@ -277,15 +296,15 @@ const w = (r = {}) => {
|
|
|
277
296
|
}, h = () => {
|
|
278
297
|
var e, t;
|
|
279
298
|
return (e = (t = c()) == null ? void 0 : t.completed) == null ? !1 : e;
|
|
280
|
-
}, g = /* @__PURE__ */ new Map(), _ = null,
|
|
281
|
-
|
|
282
|
-
},
|
|
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 = () => {
|
|
283
302
|
D || (D = setInterval(() => {
|
|
284
|
-
if (
|
|
285
|
-
let [e, t] =
|
|
286
|
-
|
|
303
|
+
if (T.isPaused()) return;
|
|
304
|
+
let [e, t] = T.display();
|
|
305
|
+
w.sendMessage("TIMER_TICK", { display: [e, t] });
|
|
287
306
|
}, 500), O = setInterval(() => {
|
|
288
|
-
|
|
307
|
+
T.isPaused() || w.sendMessage("TIMER_SYNC", Math.floor(T.timeWithoutPenaltySecs()));
|
|
289
308
|
}, 1e4));
|
|
290
309
|
}, A = () => {
|
|
291
310
|
D && (clearInterval(D), D = null), O && (clearInterval(O), O = null);
|
|
@@ -293,21 +312,21 @@ const w = (r = {}) => {
|
|
|
293
312
|
let n = g.get(e);
|
|
294
313
|
n && n.forEach((e) => e(t));
|
|
295
314
|
};
|
|
296
|
-
|
|
297
|
-
|
|
315
|
+
w.onMessage("START_GAME", () => {
|
|
316
|
+
T._init(), k(), j("start");
|
|
298
317
|
});
|
|
299
318
|
let M = () => {
|
|
300
|
-
let e =
|
|
301
|
-
|
|
319
|
+
let e = T.isPaused();
|
|
320
|
+
T._pause(), T.isPaused() !== e && j("pause");
|
|
302
321
|
}, N = () => {
|
|
303
|
-
let e =
|
|
304
|
-
|
|
322
|
+
let e = T.isPaused();
|
|
323
|
+
T._resume(), T.isPaused() !== e && j("resume");
|
|
305
324
|
};
|
|
306
|
-
|
|
325
|
+
w.onMessage("PAUSE_GAME", M), w.onMessage("RESUME_GAME", N), w.onMessage("SETTINGS_UPDATE", (e) => {
|
|
307
326
|
_ = t(t({}, _), e), j("settingsUpdate", _);
|
|
308
|
-
}),
|
|
309
|
-
|
|
310
|
-
}),
|
|
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) => {
|
|
311
330
|
var t;
|
|
312
331
|
let n = o(e);
|
|
313
332
|
a = n;
|
|
@@ -323,32 +342,32 @@ const w = (r = {}) => {
|
|
|
323
342
|
_ = (c = t) == null ? {} : c;
|
|
324
343
|
}
|
|
325
344
|
if (r) {
|
|
326
|
-
var l,
|
|
327
|
-
let e = ((l = r.elapsedTimeSecs) == null ? 0 : l) * 1e3, t = ((
|
|
328
|
-
|
|
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);
|
|
329
348
|
}
|
|
330
|
-
if (!
|
|
349
|
+
if (!v) {
|
|
331
350
|
var p;
|
|
332
|
-
|
|
351
|
+
v = d(n), b = (p = r == null ? void 0 : r.completed) == null ? !1 : p, v && f((e) => v.trackLinkClick(e));
|
|
333
352
|
}
|
|
334
353
|
s && (s(n), s = null);
|
|
335
354
|
});
|
|
336
355
|
let P = {
|
|
337
|
-
timeMs: () =>
|
|
338
|
-
timeSecs: () =>
|
|
339
|
-
addedTimeMs: () =>
|
|
340
|
-
addedTimeSecs: () =>
|
|
341
|
-
timeWithoutPenaltySecs: () =>
|
|
342
|
-
display: () =>
|
|
343
|
-
addPenalty: (e) =>
|
|
344
|
-
setPenalty: (e) =>
|
|
345
|
-
isPaused: () =>
|
|
346
|
-
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(),
|
|
347
366
|
pause: M,
|
|
348
367
|
resume: N
|
|
349
368
|
}, F = {
|
|
350
|
-
send: (e, t) =>
|
|
351
|
-
on: (e, t) =>
|
|
369
|
+
send: (e, t) => w.sendMessage(e, t),
|
|
370
|
+
on: (e, t) => w.onMessage(e, t),
|
|
352
371
|
timer: P,
|
|
353
372
|
bootstrap: () => a
|
|
354
373
|
}, I = {};
|
|
@@ -359,10 +378,10 @@ const w = (r = {}) => {
|
|
|
359
378
|
gameReady: function() {
|
|
360
379
|
var e = n(function* () {
|
|
361
380
|
var e;
|
|
362
|
-
if (
|
|
381
|
+
if (w.sendMessage("READY", { runtimeContract: C }), u()) {
|
|
363
382
|
let e = p();
|
|
364
383
|
return {
|
|
365
|
-
puzzleString:
|
|
384
|
+
puzzleString: u(),
|
|
366
385
|
inputString: e,
|
|
367
386
|
boardState: e,
|
|
368
387
|
theme: m(),
|
|
@@ -376,7 +395,7 @@ const w = (r = {}) => {
|
|
|
376
395
|
s && (s = null, n(/* @__PURE__ */ Error(`Timeout waiting for READY_DATA after ${t}ms`)));
|
|
377
396
|
}, t);
|
|
378
397
|
});
|
|
379
|
-
let n =
|
|
398
|
+
let n = u();
|
|
380
399
|
if (!n) throw Error("READY_DATA received but no puzzle data found");
|
|
381
400
|
let i = p();
|
|
382
401
|
return {
|
|
@@ -393,11 +412,11 @@ const w = (r = {}) => {
|
|
|
393
412
|
};
|
|
394
413
|
}(),
|
|
395
414
|
gameLoaded: (e = {}) => {
|
|
396
|
-
|
|
415
|
+
w.sendMessage("READY_GAME_LOADED", {
|
|
397
416
|
state: e,
|
|
398
|
-
gameRuntimeContract:
|
|
417
|
+
gameRuntimeContract: C,
|
|
399
418
|
embedRuntimeContract: "1.0"
|
|
400
|
-
}),
|
|
419
|
+
}), S("READY_GAME_LOADED");
|
|
401
420
|
},
|
|
402
421
|
on: (e, t) => (g.has(e) || g.set(e, /* @__PURE__ */ new Set()), g.get(e).add(t), () => {
|
|
403
422
|
var n;
|
|
@@ -410,23 +429,23 @@ const w = (r = {}) => {
|
|
|
410
429
|
updateGameState: (e, t) => {
|
|
411
430
|
var n, r;
|
|
412
431
|
let i = l();
|
|
413
|
-
i && (
|
|
432
|
+
i && (w.sendMessage("UPLOAD_NEW_GAME_STATE", {
|
|
414
433
|
id: i,
|
|
415
434
|
input: {
|
|
416
435
|
boardState: e,
|
|
417
|
-
elapsedTimeSecs: (n = t == null ? void 0 : t.elapsedTimeSecs) == null ?
|
|
418
|
-
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,
|
|
419
438
|
collabUserReferences: []
|
|
420
439
|
}
|
|
421
|
-
}),
|
|
440
|
+
}), S("UPLOAD_NEW_GAME_STATE"));
|
|
422
441
|
},
|
|
423
442
|
gameCompleted: (n, r) => {
|
|
424
443
|
var i, a, o, s, c;
|
|
425
|
-
|
|
426
|
-
let { inputString: u } = n, d = t(t({}, e(n,
|
|
444
|
+
T._conclude(), A();
|
|
445
|
+
let { inputString: u } = n, d = t(t({}, e(n, y)), {}, {
|
|
427
446
|
boardState: u == null ? n.boardState : u,
|
|
428
|
-
elapsedTimeSecs: (i = n.elapsedTimeSecs) == null ?
|
|
429
|
-
additionalTimeAddedSecs: (a = n.additionalTimeAddedSecs) == null ?
|
|
447
|
+
elapsedTimeSecs: (i = n.elapsedTimeSecs) == null ? T.timeWithoutPenaltySecs() : i,
|
|
448
|
+
additionalTimeAddedSecs: (a = n.additionalTimeAddedSecs) == null ? T.addedTimeSecs() : a
|
|
430
449
|
}), f = (o = r == null ? void 0 : r.deeds) == null ? [] : o;
|
|
431
450
|
f.push({
|
|
432
451
|
id: "points",
|
|
@@ -436,14 +455,14 @@ const w = (r = {}) => {
|
|
|
436
455
|
value: Math.round((s = d.elapsedTimeSecs) == null ? 0 : s) + Math.round((c = d.additionalTimeAddedSecs) == null ? 0 : c)
|
|
437
456
|
});
|
|
438
457
|
let p = l();
|
|
439
|
-
p && (
|
|
458
|
+
p && (w.sendMessage("GAME_COMPLETED", {
|
|
440
459
|
id: p,
|
|
441
460
|
input: d,
|
|
442
461
|
config: r
|
|
443
|
-
}),
|
|
462
|
+
}), S("GAME_COMPLETED", { input: d }));
|
|
444
463
|
},
|
|
445
464
|
showCompletionScreen: (e) => {
|
|
446
|
-
|
|
465
|
+
w.sendMessage("SHOW_GAME_COMPLETE_SCREEN", {
|
|
447
466
|
results: e,
|
|
448
467
|
showRetry: !0
|
|
449
468
|
});
|
|
@@ -452,10 +471,10 @@ const w = (r = {}) => {
|
|
|
452
471
|
var r;
|
|
453
472
|
if (!l()) return;
|
|
454
473
|
let i = (r = p()) == null ? "" : r, a = {
|
|
455
|
-
elapsedTimeSecs:
|
|
456
|
-
additionalTimeAddedSecs:
|
|
474
|
+
elapsedTimeSecs: T.timeWithoutPenaltySecs(),
|
|
475
|
+
additionalTimeAddedSecs: T.addedTimeSecs()
|
|
457
476
|
};
|
|
458
|
-
|
|
477
|
+
w.sendMessage("HIT_CHECKPOINT", {
|
|
459
478
|
checkpointName: e,
|
|
460
479
|
gameplay: {
|
|
461
480
|
inputStr: i,
|
|
@@ -466,7 +485,7 @@ const w = (r = {}) => {
|
|
|
466
485
|
});
|
|
467
486
|
},
|
|
468
487
|
settings: {
|
|
469
|
-
initialize: (e) => (_ = t(t({},
|
|
488
|
+
initialize: (e) => (_ = t(t({}, E(e)), _), w.sendMessage("INITIALIZE_SETTINGS", {
|
|
470
489
|
components: e,
|
|
471
490
|
settings: _
|
|
472
491
|
}), _),
|
|
@@ -474,14 +493,14 @@ const w = (r = {}) => {
|
|
|
474
493
|
var e;
|
|
475
494
|
return (e = _) == null ? {} : e;
|
|
476
495
|
},
|
|
477
|
-
update: (e) => (_ = t(t({}, _), e),
|
|
496
|
+
update: (e) => (_ = t(t({}, _), e), w.sendMessage("UPDATE_SETTINGS_FROM_EMBED", { settings: _ }), _)
|
|
478
497
|
},
|
|
479
498
|
keyboard: {
|
|
480
499
|
show: (e) => {
|
|
481
|
-
|
|
500
|
+
w.sendMessage("KEYBOARD_UPDATE_CONFIG", e);
|
|
482
501
|
},
|
|
483
502
|
hide: () => {
|
|
484
|
-
|
|
503
|
+
w.sendMessage("KEYBOARD_UPDATE_CONFIG", {
|
|
485
504
|
layout: [],
|
|
486
505
|
symbols: {},
|
|
487
506
|
highlight: [],
|
|
@@ -494,18 +513,18 @@ const w = (r = {}) => {
|
|
|
494
513
|
},
|
|
495
514
|
haptics: { play: (e, t) => {
|
|
496
515
|
var n;
|
|
497
|
-
|
|
516
|
+
w.sendMessage("SENSORY_EVENT", {
|
|
498
517
|
id: (n = t == null ? void 0 : t.id) == null ? e : n,
|
|
499
518
|
haptic: e
|
|
500
519
|
});
|
|
501
520
|
} },
|
|
502
|
-
_hostAPI:
|
|
521
|
+
_hostAPI: w
|
|
503
522
|
};
|
|
504
523
|
};
|
|
505
524
|
/** Walks settings UI components (recursing into split groups) collecting name → defaultValue pairs */
|
|
506
|
-
function
|
|
525
|
+
function E(e) {
|
|
507
526
|
let t = {};
|
|
508
|
-
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);
|
|
509
528
|
return t;
|
|
510
529
|
}
|
|
511
530
|
/**
|
|
@@ -520,7 +539,7 @@ function T(e) {
|
|
|
520
539
|
* // Extend with dynamic disabled letters
|
|
521
540
|
* sdk.keyboard.show({ ...defaultKeyboardConfig, disabled: usedLetters })
|
|
522
541
|
*/
|
|
523
|
-
const
|
|
542
|
+
const D = {
|
|
524
543
|
layout: [
|
|
525
544
|
"qwertyuiop",
|
|
526
545
|
"asdfghjkl",
|
|
@@ -536,7 +555,7 @@ const E = {
|
|
|
536
555
|
xl: [],
|
|
537
556
|
l: ["↵", "⌫"],
|
|
538
557
|
supportsDragCursor: !1
|
|
539
|
-
},
|
|
558
|
+
}, O = (e) => {
|
|
540
559
|
let n = {};
|
|
541
560
|
for (let a of e) for (let e of a.keys) {
|
|
542
561
|
var r, i;
|
|
@@ -546,11 +565,11 @@ const E = {
|
|
|
546
565
|
return n;
|
|
547
566
|
};
|
|
548
567
|
/** Custom error class for workshop import failures */
|
|
549
|
-
var
|
|
568
|
+
var k = class extends Error {
|
|
550
569
|
constructor(e, t, n) {
|
|
551
570
|
super(t), this.type = e, this.originalError = n, this.name = "EditorImportError";
|
|
552
571
|
}
|
|
553
572
|
};
|
|
554
|
-
export {
|
|
573
|
+
export { k as EditorImportError, T as createPuzzmoSDK, D as defaultKeyboardConfig, O as keyStylesFromRules };
|
|
555
574
|
|
|
556
575
|
//# sourceMappingURL=index.js.map
|