@puzzmo/sdk 1.0.63 → 1.0.65
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/chunk-350yNsax.cjs +1 -0
- package/dist/createSimulator-Ce3StrQI.cjs +1930 -0
- package/dist/createSimulator-Ce3StrQI.cjs.map +1 -0
- package/dist/{createSimulator-DqxQK61P.js → createSimulator-DUZOd1Hx.js} +1970 -453
- package/dist/createSimulator-DUZOd1Hx.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/inputs/index.cjs +1 -1
- package/dist/inputs/index.cjs.map +1 -1
- package/dist/inputs/index.js +1 -1
- package/dist/{lua-QeU9Rzet.cjs → lua-CclI-QKD.cjs} +1 -1
- package/dist/{lua-QeU9Rzet.cjs.map → lua-CclI-QKD.cjs.map} +1 -1
- package/dist/pico8/index.cjs +1 -1
- package/dist/pico8/index.js +2 -2
- package/dist/simulator/checklistProgress.d.ts +13 -2
- package/dist/simulator/checklistProgress.d.ts.map +1 -1
- package/dist/simulator/index.cjs +1 -1
- package/dist/simulator/index.js +1 -1
- package/dist/simulator/standalone.cjs +1 -1
- package/dist/simulator/standalone.js +1 -1
- package/dist/simulator/views/ChecklistView.d.ts.map +1 -1
- package/dist/types.d.ts +4 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/vite.cjs +5 -5
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.js +3 -3
- package/package.json +1 -1
- package/dist/createSimulator-CJ8LJCe4.cjs +0 -1925
- package/dist/createSimulator-CJ8LJCe4.cjs.map +0 -1
- package/dist/createSimulator-DqxQK61P.js.map +0 -1
- /package/dist/{asyncToGenerator-BotOOyB7.js → asyncToGenerator-DSd3oTwb.js} +0 -0
- /package/dist/{asyncToGenerator-DIL7svO7.cjs → asyncToGenerator-Tjg_Hpik.cjs} +0 -0
- /package/dist/{objectSpread2-BQwrzeNG.js → objectSpread2-BJrS9rM5.js} +0 -0
- /package/dist/{objectSpread2-CCAs_T0X.cjs → objectSpread2-BU9HzoRm.cjs} +0 -0
- /package/dist/{objectWithoutProperties-Bjd1IAMi.js → objectWithoutProperties-54Cbyogk.js} +0 -0
- /package/dist/{objectWithoutProperties-Ee8z5QMa.cjs → objectWithoutProperties-CL_8JSCP.cjs} +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { t as e } from "./objectSpread2-
|
|
2
|
-
import { t } from "./asyncToGenerator-
|
|
3
|
-
|
|
1
|
+
import { t as e } from "./objectSpread2-BJrS9rM5.js";
|
|
2
|
+
import { t } from "./asyncToGenerator-DSd3oTwb.js";
|
|
3
|
+
var n = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports);
|
|
4
|
+
const r = [
|
|
4
5
|
{
|
|
5
6
|
name: "Puzzmo (light)",
|
|
6
7
|
type: "light",
|
|
@@ -306,7 +307,7 @@ const n = [
|
|
|
306
307
|
a_infoBG: "#001900"
|
|
307
308
|
}
|
|
308
309
|
];
|
|
309
|
-
var
|
|
310
|
+
var i = {
|
|
310
311
|
collapsed: "simulator-collapsed",
|
|
311
312
|
tab: "simulator-tab",
|
|
312
313
|
theme: "simulator-theme",
|
|
@@ -318,42 +319,42 @@ var r = {
|
|
|
318
319
|
gameSettings: "simulator-game-settings",
|
|
319
320
|
hostContext: "simulator-host-context",
|
|
320
321
|
keyboardDocked: "simulator-keyboard-docked"
|
|
321
|
-
},
|
|
322
|
+
}, a = "simulator-override:";
|
|
322
323
|
/**
|
|
323
324
|
* Overrides are scoped to the page that applied them. localStorage is per-origin but a dev server
|
|
324
325
|
* commonly hosts many games from one origin (each at its own /games/<name>/ path), and an input
|
|
325
326
|
* string is only meaningful to the game it came from.
|
|
326
327
|
*/
|
|
327
|
-
function
|
|
328
|
-
return `${
|
|
328
|
+
function o(e) {
|
|
329
|
+
return `${a}${e}:${(window.location.pathname || "/").replace(/\/index\.html$/, "").replace(/\/+$/, "") || "/"}`;
|
|
329
330
|
}
|
|
330
331
|
/** The applied override for this page, or null when nothing has been applied. "" is a real value. */
|
|
331
|
-
function
|
|
332
|
+
function s(e) {
|
|
332
333
|
try {
|
|
333
|
-
return localStorage.getItem(
|
|
334
|
+
return localStorage.getItem(o(e));
|
|
334
335
|
} catch (e) {
|
|
335
336
|
return null;
|
|
336
337
|
}
|
|
337
338
|
}
|
|
338
339
|
/** False when the write failed — private-mode storage, or a board state over the origin's quota. */
|
|
339
|
-
function
|
|
340
|
+
function c(e, t) {
|
|
340
341
|
try {
|
|
341
|
-
return localStorage.setItem(
|
|
342
|
+
return localStorage.setItem(o(e), t), !0;
|
|
342
343
|
} catch (e) {
|
|
343
344
|
return !1;
|
|
344
345
|
}
|
|
345
346
|
}
|
|
346
|
-
function
|
|
347
|
+
function l(e) {
|
|
347
348
|
try {
|
|
348
|
-
localStorage.removeItem(
|
|
349
|
+
localStorage.removeItem(o(e));
|
|
349
350
|
} catch (e) {}
|
|
350
351
|
}
|
|
351
|
-
function
|
|
352
|
-
|
|
352
|
+
function u() {
|
|
353
|
+
l("puzzle"), l("input");
|
|
353
354
|
}
|
|
354
355
|
/** The Host tab's persisted `hostContext` override, or null when the tab hasn't set one. */
|
|
355
|
-
function
|
|
356
|
-
let e = localStorage.getItem(
|
|
356
|
+
function d() {
|
|
357
|
+
let e = localStorage.getItem(i.hostContext);
|
|
357
358
|
if (!e) return null;
|
|
358
359
|
try {
|
|
359
360
|
let t = JSON.parse(e);
|
|
@@ -361,21 +362,21 @@ function u() {
|
|
|
361
362
|
} catch (e) {}
|
|
362
363
|
return null;
|
|
363
364
|
}
|
|
364
|
-
function
|
|
365
|
-
localStorage.setItem(
|
|
365
|
+
function f(e) {
|
|
366
|
+
localStorage.setItem(i.hostContext, JSON.stringify(e));
|
|
366
367
|
}
|
|
367
|
-
function
|
|
368
|
-
localStorage.removeItem(
|
|
368
|
+
function p() {
|
|
369
|
+
localStorage.removeItem(i.hostContext);
|
|
369
370
|
}
|
|
370
371
|
/** The Kbd tab's "show keyboard under game" checkbox. Off until asked for: it takes space from the game. */
|
|
371
|
-
function
|
|
372
|
-
return localStorage.getItem(
|
|
372
|
+
function m() {
|
|
373
|
+
return localStorage.getItem(i.keyboardDocked) === "true";
|
|
373
374
|
}
|
|
374
|
-
function
|
|
375
|
-
localStorage.setItem(
|
|
375
|
+
function h(e) {
|
|
376
|
+
localStorage.setItem(i.keyboardDocked, String(e));
|
|
376
377
|
}
|
|
377
|
-
function
|
|
378
|
-
let e = localStorage.getItem(
|
|
378
|
+
function g() {
|
|
379
|
+
let e = localStorage.getItem(i.gameSettings);
|
|
379
380
|
if (!e) return {};
|
|
380
381
|
try {
|
|
381
382
|
let t = JSON.parse(e);
|
|
@@ -383,36 +384,36 @@ function h() {
|
|
|
383
384
|
} catch (e) {}
|
|
384
385
|
return {};
|
|
385
386
|
}
|
|
386
|
-
function
|
|
387
|
-
let e = localStorage.getItem(
|
|
387
|
+
function _() {
|
|
388
|
+
let e = localStorage.getItem(i.theme);
|
|
388
389
|
if (e) {
|
|
389
|
-
let t =
|
|
390
|
+
let t = r.find((t) => t.name === e);
|
|
390
391
|
if (t) return t;
|
|
391
392
|
}
|
|
392
|
-
return
|
|
393
|
+
return r[0];
|
|
393
394
|
}
|
|
394
|
-
function
|
|
395
|
+
function v(e) {
|
|
395
396
|
var t;
|
|
396
|
-
let n = localStorage.getItem(
|
|
397
|
+
let n = localStorage.getItem(i.tab);
|
|
397
398
|
return n && e.includes(n) ? n : (t = e[0]) == null ? "ctrl" : t;
|
|
398
399
|
}
|
|
399
|
-
function
|
|
400
|
-
let t = localStorage.getItem(
|
|
400
|
+
function y(e) {
|
|
401
|
+
let t = localStorage.getItem(i.collapsed);
|
|
401
402
|
return t === null ? e : t === "true";
|
|
402
403
|
}
|
|
403
|
-
function
|
|
404
|
-
let e = localStorage.getItem(
|
|
404
|
+
function b() {
|
|
405
|
+
let e = localStorage.getItem(i.renderHost);
|
|
405
406
|
return e && [
|
|
406
407
|
"game",
|
|
407
408
|
"app",
|
|
408
409
|
"opengraph"
|
|
409
410
|
].includes(e) ? e : "game";
|
|
410
411
|
}
|
|
411
|
-
function b() {
|
|
412
|
-
return localStorage.getItem(r.previewKind) === "text" ? "text" : "image";
|
|
413
|
-
}
|
|
414
412
|
function x() {
|
|
415
|
-
|
|
413
|
+
return localStorage.getItem(i.previewKind) === "text" ? "text" : "image";
|
|
414
|
+
}
|
|
415
|
+
function S() {
|
|
416
|
+
let e = localStorage.getItem(i.renderContext);
|
|
416
417
|
if (e && [
|
|
417
418
|
"preview",
|
|
418
419
|
"share",
|
|
@@ -421,68 +422,68 @@ function x() {
|
|
|
421
422
|
].includes(e)) return e;
|
|
422
423
|
}
|
|
423
424
|
function ee(e, t, n) {
|
|
424
|
-
var
|
|
425
|
-
let c = localStorage.getItem(
|
|
425
|
+
var r, a, o;
|
|
426
|
+
let c = localStorage.getItem(i.fixtureCategory), l = localStorage.getItem(i.fixturePuzzle), u = d(), f = s("puzzle"), p = s("input");
|
|
426
427
|
return {
|
|
427
|
-
hostContext: (
|
|
428
|
+
hostContext: (r = u == null ? e.hostContext : u) == null ? [{
|
|
428
429
|
type: "app",
|
|
429
430
|
layout: "desktop",
|
|
430
431
|
host: null
|
|
431
|
-
}] :
|
|
432
|
-
hostContextIsOverridden:
|
|
433
|
-
isCollapsed:
|
|
432
|
+
}] : r,
|
|
433
|
+
hostContextIsOverridden: u !== null,
|
|
434
|
+
isCollapsed: y((a = e.collapsed) == null ? !0 : a),
|
|
434
435
|
isPaused: !1,
|
|
435
436
|
hasStarted: !1,
|
|
436
|
-
activeTab:
|
|
437
|
+
activeTab: v(n),
|
|
437
438
|
puzzleData: f,
|
|
438
439
|
originalPuzzle: f == null ? "" : f,
|
|
439
|
-
currentInputStr:
|
|
440
|
+
currentInputStr: p == null ? "" : p,
|
|
440
441
|
appliedPuzzleOverride: f,
|
|
441
|
-
appliedInputOverride:
|
|
442
|
+
appliedInputOverride: p,
|
|
442
443
|
completionData: null,
|
|
443
|
-
selectedTheme:
|
|
444
|
-
selectedCategory: c && t.includes(c) ? c : (
|
|
444
|
+
selectedTheme: _(),
|
|
445
|
+
selectedCategory: c && t.includes(c) ? c : (o = t[0]) == null ? null : o,
|
|
445
446
|
selectedPuzzle: l == null ? null : l,
|
|
446
|
-
renderHost:
|
|
447
|
-
renderContext:
|
|
448
|
-
previewKind:
|
|
449
|
-
gameSettings:
|
|
450
|
-
keyboardDocked:
|
|
447
|
+
renderHost: b(),
|
|
448
|
+
renderContext: S(),
|
|
449
|
+
previewKind: x(),
|
|
450
|
+
gameSettings: g(),
|
|
451
|
+
keyboardDocked: m(),
|
|
451
452
|
settingsComponents: null
|
|
452
453
|
};
|
|
453
454
|
}
|
|
454
|
-
function
|
|
455
|
-
localStorage.setItem(
|
|
455
|
+
function C(e) {
|
|
456
|
+
localStorage.setItem(i.gameSettings, JSON.stringify(e));
|
|
456
457
|
}
|
|
457
|
-
function
|
|
458
|
-
localStorage.removeItem(
|
|
458
|
+
function w() {
|
|
459
|
+
localStorage.removeItem(i.gameSettings);
|
|
459
460
|
}
|
|
460
461
|
function te(e) {
|
|
461
|
-
localStorage.setItem(
|
|
462
|
+
localStorage.setItem(i.collapsed, String(e));
|
|
462
463
|
}
|
|
463
464
|
function ne(e) {
|
|
464
|
-
localStorage.setItem(
|
|
465
|
-
}
|
|
466
|
-
function w(e) {
|
|
467
|
-
localStorage.setItem(r.theme, e);
|
|
465
|
+
localStorage.setItem(i.tab, e);
|
|
468
466
|
}
|
|
469
467
|
function T(e) {
|
|
470
|
-
localStorage.setItem(
|
|
468
|
+
localStorage.setItem(i.theme, e);
|
|
471
469
|
}
|
|
472
470
|
function E(e) {
|
|
473
|
-
localStorage.setItem(
|
|
471
|
+
localStorage.setItem(i.fixtureCategory, e);
|
|
474
472
|
}
|
|
475
|
-
function D() {
|
|
476
|
-
localStorage.
|
|
473
|
+
function D(e) {
|
|
474
|
+
localStorage.setItem(i.fixturePuzzle, e);
|
|
477
475
|
}
|
|
478
|
-
function O(
|
|
479
|
-
|
|
476
|
+
function O() {
|
|
477
|
+
localStorage.removeItem(i.fixturePuzzle);
|
|
480
478
|
}
|
|
481
479
|
function k(e) {
|
|
482
|
-
localStorage.setItem(
|
|
480
|
+
e ? localStorage.setItem(i.renderHost, e) : localStorage.removeItem(i.renderHost);
|
|
483
481
|
}
|
|
484
482
|
function A(e) {
|
|
485
|
-
|
|
483
|
+
localStorage.setItem(i.previewKind, e);
|
|
484
|
+
}
|
|
485
|
+
function j(e) {
|
|
486
|
+
e ? localStorage.setItem(i.renderContext, e) : localStorage.removeItem(i.renderContext);
|
|
486
487
|
}
|
|
487
488
|
function re(e) {
|
|
488
489
|
let t = [];
|
|
@@ -509,13 +510,13 @@ function re(e) {
|
|
|
509
510
|
}
|
|
510
511
|
};
|
|
511
512
|
}
|
|
512
|
-
function
|
|
513
|
+
function M(e, t, n) {
|
|
513
514
|
console.log("Simulator sending:", e, t), n == null || n.log(e, t, "out"), window.postMessage({
|
|
514
515
|
type: e,
|
|
515
516
|
data: t
|
|
516
517
|
}, "*");
|
|
517
518
|
}
|
|
518
|
-
function
|
|
519
|
+
function N(e, t) {
|
|
519
520
|
let n = (n) => {
|
|
520
521
|
var r, i, a;
|
|
521
522
|
if (!(!(n == null || (r = n.data) == null) && r.type)) return;
|
|
@@ -525,7 +526,7 @@ function ae(e, t) {
|
|
|
525
526
|
return window.addEventListener("message", n), () => window.removeEventListener("message", n);
|
|
526
527
|
}
|
|
527
528
|
/** Parse fixture imports into a structured format: { category: { filename: data } } */
|
|
528
|
-
function
|
|
529
|
+
function ie(e) {
|
|
529
530
|
let t = /* @__PURE__ */ new Map();
|
|
530
531
|
console.log("Simulator: Parsing fixtures", Object.keys(e));
|
|
531
532
|
for (let [o, s] of Object.entries(e)) {
|
|
@@ -544,7 +545,7 @@ function oe(e) {
|
|
|
544
545
|
}), t;
|
|
545
546
|
}
|
|
546
547
|
/** Render fixture selector HTML */
|
|
547
|
-
function
|
|
548
|
+
function P(e, t) {
|
|
548
549
|
return e.length === 0 ? "" : `
|
|
549
550
|
<div class="simulator-fixtures">
|
|
550
551
|
<div class="simulator-field">
|
|
@@ -561,7 +562,7 @@ function j(e, t) {
|
|
|
561
562
|
`;
|
|
562
563
|
}
|
|
563
564
|
/** Update puzzle select options based on selected category */
|
|
564
|
-
function
|
|
565
|
+
function F(e, t, n, r) {
|
|
565
566
|
let i = t.get(n);
|
|
566
567
|
if (!i) return null;
|
|
567
568
|
let a = Array.from(i.keys()), o = r;
|
|
@@ -572,7 +573,7 @@ function se(e, t, n, r) {
|
|
|
572
573
|
return e.innerHTML = a.map((e) => `<option value="${e}" ${e === o ? "selected" : ""}>${e}</option>`).join(""), o;
|
|
573
574
|
}
|
|
574
575
|
/** Get puzzle data from fixtures */
|
|
575
|
-
function
|
|
576
|
+
function I(e, t, n) {
|
|
576
577
|
var r, i;
|
|
577
578
|
return !t || !n || (r = (i = e.get(t)) == null ? void 0 : i.get(n)) == null ? null : r;
|
|
578
579
|
}
|
|
@@ -584,8 +585,8 @@ function M(e, t, n) {
|
|
|
584
585
|
* `puzzmo games validate` greps build output for it — keep it in sync with the copy in
|
|
585
586
|
* packages/cli/src/util/lintDist.ts.
|
|
586
587
|
*/
|
|
587
|
-
const
|
|
588
|
-
function
|
|
588
|
+
const ae = "puzzmo-simulator-dev-only-do-not-ship";
|
|
589
|
+
function oe() {
|
|
589
590
|
return {
|
|
590
591
|
id: "ctrl",
|
|
591
592
|
label: "Ctrl",
|
|
@@ -600,19 +601,19 @@ function le() {
|
|
|
600
601
|
selectedCategory: e.state.selectedCategory,
|
|
601
602
|
selectedPuzzle: e.state.selectedPuzzle
|
|
602
603
|
}), e.fixtures && e.fixtureCategories.length > 0 && i) {
|
|
603
|
-
i.innerHTML =
|
|
604
|
+
i.innerHTML = P(e.fixtureCategories, e.state.selectedCategory);
|
|
604
605
|
let t = e.getElement("#simulator-fixture-category"), n = e.getElement("#simulator-fixture-puzzle");
|
|
605
606
|
if (t && n && e.state.selectedCategory) {
|
|
606
|
-
e.state.selectedPuzzle =
|
|
607
|
-
let r =
|
|
607
|
+
e.state.selectedPuzzle = F(n, e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
|
|
608
|
+
let r = I(e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
|
|
608
609
|
console.log("Simulator: Loading fixture puzzle", {
|
|
609
610
|
category: e.state.selectedCategory,
|
|
610
611
|
puzzle: e.state.selectedPuzzle,
|
|
611
612
|
hasPuzzleData: !!r
|
|
612
|
-
}), r && (e.state.appliedPuzzleOverride === null && (e.state.puzzleData = r, e.state.originalPuzzle = r), e.state.selectedCategory &&
|
|
613
|
-
console.log("Simulator: Category changed, reloading...", t.value),
|
|
613
|
+
}), r && (e.state.appliedPuzzleOverride === null && (e.state.puzzleData = r, e.state.originalPuzzle = r), e.state.selectedCategory && E(e.state.selectedCategory), e.state.selectedPuzzle && D(e.state.selectedPuzzle)), t.addEventListener("change", () => {
|
|
614
|
+
console.log("Simulator: Category changed, reloading...", t.value), u(), E(t.value), O(), window.location.reload();
|
|
614
615
|
}), n.addEventListener("change", () => {
|
|
615
|
-
console.log("Simulator: Puzzle changed, reloading...", n.value),
|
|
616
|
+
console.log("Simulator: Puzzle changed, reloading...", n.value), u(), D(n.value), window.location.reload();
|
|
616
617
|
});
|
|
617
618
|
}
|
|
618
619
|
}
|
|
@@ -638,10 +639,10 @@ function le() {
|
|
|
638
639
|
* Inlined here (rather than shared with the rest of the monorepo) because the SDK ships to OSS and
|
|
639
640
|
* must stay self-contained.
|
|
640
641
|
*/
|
|
641
|
-
function
|
|
642
|
+
function L(e) {
|
|
642
643
|
var t;
|
|
643
644
|
if (typeof e != "string") return e;
|
|
644
|
-
let n = (t =
|
|
645
|
+
let n = (t = R(e)) == null ? {
|
|
645
646
|
width: 800,
|
|
646
647
|
height: 800
|
|
647
648
|
} : t;
|
|
@@ -652,7 +653,7 @@ function N(e) {
|
|
|
652
653
|
};
|
|
653
654
|
}
|
|
654
655
|
/** Reads an SVG's intrinsic size from its `viewBox` (preferred) or its `width`/`height` attributes. */
|
|
655
|
-
function
|
|
656
|
+
function R(e) {
|
|
656
657
|
var t, n, r, i;
|
|
657
658
|
let a = e.indexOf("<svg");
|
|
658
659
|
if (a === -1) return;
|
|
@@ -670,9 +671,9 @@ function P(e) {
|
|
|
670
671
|
height: u
|
|
671
672
|
};
|
|
672
673
|
}
|
|
673
|
-
var
|
|
674
|
+
var z = "simulator-saved-states";
|
|
674
675
|
/** Find thumbnail function on globalThis (looks for functions ending in "Thumbnail") */
|
|
675
|
-
function
|
|
676
|
+
function B() {
|
|
676
677
|
let e = globalThis;
|
|
677
678
|
for (let t of Object.keys(e)) if (t.endsWith("Thumbnail") && typeof e[t] == "function") return {
|
|
678
679
|
name: t,
|
|
@@ -681,8 +682,8 @@ function I() {
|
|
|
681
682
|
return null;
|
|
682
683
|
}
|
|
683
684
|
/** Generate a small thumbnail SVG for a given input string */
|
|
684
|
-
function
|
|
685
|
-
let n =
|
|
685
|
+
function V(e, t) {
|
|
686
|
+
let n = B();
|
|
686
687
|
if (!n) return "";
|
|
687
688
|
try {
|
|
688
689
|
var r;
|
|
@@ -692,19 +693,19 @@ function L(e, t) {
|
|
|
692
693
|
strict: !0,
|
|
693
694
|
renderHost: "game"
|
|
694
695
|
};
|
|
695
|
-
return
|
|
696
|
+
return L(n.fn(i, t, a)).svg;
|
|
696
697
|
} catch (e) {
|
|
697
698
|
return "";
|
|
698
699
|
}
|
|
699
700
|
}
|
|
700
|
-
var
|
|
701
|
-
function
|
|
701
|
+
var H = [];
|
|
702
|
+
function U(e, t = 8) {
|
|
702
703
|
let n = 14 * t + 8 + 4;
|
|
703
704
|
e.style.height = "auto";
|
|
704
705
|
let r = Math.min(Math.max(e.scrollHeight, 40), n);
|
|
705
706
|
e.style.height = `${r}px`;
|
|
706
707
|
}
|
|
707
|
-
function
|
|
708
|
+
function se() {
|
|
708
709
|
let e = "", t = "";
|
|
709
710
|
return {
|
|
710
711
|
id: "data",
|
|
@@ -722,43 +723,43 @@ function ue() {
|
|
|
722
723
|
let i = n.getElement(".data-view-container");
|
|
723
724
|
i == null || i.querySelectorAll(".data-subtab-content").forEach((e) => {
|
|
724
725
|
e.classList.toggle("active", e.id === `data-subtab-${t}`);
|
|
725
|
-
}), t === "edit" ?
|
|
726
|
+
}), t === "edit" ? ue(n) : t === "history" ? W(n) : t === "saves" && G(n);
|
|
726
727
|
});
|
|
727
728
|
});
|
|
728
|
-
let i = n.getElement("#simulator-puzzle"), a = n.getElement("#simulator-input"), o = n.getElement("#simulator-puzzle-reset"),
|
|
729
|
+
let i = n.getElement("#simulator-puzzle"), a = n.getElement("#simulator-input"), o = n.getElement("#simulator-puzzle-reset"), s = n.getElement("#simulator-puzzle-apply"), u = n.getElement("#simulator-input-reset"), d = n.getElement("#simulator-input-apply");
|
|
729
730
|
setTimeout(() => {
|
|
730
|
-
i && n.state.originalPuzzle && document.activeElement !== i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle,
|
|
731
|
+
i && n.state.originalPuzzle && document.activeElement !== i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, U(i)), a && n.state.currentInputStr && document.activeElement !== a && (a.value = n.state.currentInputStr, t = n.state.currentInputStr, U(a)), de(n);
|
|
731
732
|
}, 0), i == null || i.addEventListener("input", () => {
|
|
732
|
-
|
|
733
|
+
U(i);
|
|
733
734
|
let t = i.value !== e;
|
|
734
|
-
|
|
735
|
+
s && (s.disabled = !t);
|
|
735
736
|
}), a == null || a.addEventListener("input", () => {
|
|
736
|
-
|
|
737
|
+
U(a);
|
|
737
738
|
let e = a.value !== t;
|
|
738
739
|
d && (d.disabled = !e);
|
|
739
740
|
}), o == null || o.addEventListener("click", () => {
|
|
740
741
|
if (n.state.appliedPuzzleOverride !== null) {
|
|
741
|
-
|
|
742
|
+
l("puzzle"), n.updateStatus("Restoring fixture puzzle...", "waiting"), window.location.reload();
|
|
742
743
|
return;
|
|
743
744
|
}
|
|
744
|
-
i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle,
|
|
745
|
-
}),
|
|
745
|
+
i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, U(i), s && (s.disabled = !0));
|
|
746
|
+
}), s == null || s.addEventListener("click", () => {
|
|
746
747
|
if (i) {
|
|
747
|
-
if (!
|
|
748
|
+
if (!c("puzzle", i.value)) {
|
|
748
749
|
n.updateStatus("Could not store puzzle — storage unavailable", "paused");
|
|
749
750
|
return;
|
|
750
751
|
}
|
|
751
|
-
|
|
752
|
+
l("input"), s.disabled = !0, n.updateStatus("Applying puzzle...", "waiting"), window.location.reload();
|
|
752
753
|
}
|
|
753
754
|
}), u == null || u.addEventListener("click", () => {
|
|
754
755
|
if (n.state.appliedInputOverride !== null) {
|
|
755
|
-
|
|
756
|
+
l("input"), n.updateStatus("Clearing input...", "waiting"), window.location.reload();
|
|
756
757
|
return;
|
|
757
758
|
}
|
|
758
|
-
a && (a.value = t,
|
|
759
|
+
a && (a.value = t, U(a), d && (d.disabled = !0));
|
|
759
760
|
}), d == null || d.addEventListener("click", () => {
|
|
760
761
|
if (a) {
|
|
761
|
-
if (!
|
|
762
|
+
if (!c("input", a.value)) {
|
|
762
763
|
n.updateStatus("Could not store input — storage unavailable", "paused");
|
|
763
764
|
return;
|
|
764
765
|
}
|
|
@@ -767,87 +768,87 @@ function ue() {
|
|
|
767
768
|
});
|
|
768
769
|
let f = n.getElement("#simulator-history-clear");
|
|
769
770
|
f == null || f.addEventListener("click", () => {
|
|
770
|
-
|
|
771
|
+
H = [], W(n);
|
|
771
772
|
});
|
|
772
773
|
let p = n.getElement("#simulator-save-name"), m = n.getElement("#simulator-save-btn");
|
|
773
774
|
m == null || m.addEventListener("click", () => {
|
|
774
775
|
if (!p || !p.value.trim()) return;
|
|
775
|
-
let e =
|
|
776
|
+
let e = ce(), t = {
|
|
776
777
|
name: p.value.trim(),
|
|
777
778
|
puzzleStr: n.state.originalPuzzle,
|
|
778
779
|
inputStr: n.state.currentInputStr,
|
|
779
780
|
timestamp: Date.now()
|
|
780
781
|
};
|
|
781
|
-
e.push(t), localStorage.setItem(
|
|
782
|
-
}),
|
|
782
|
+
e.push(t), localStorage.setItem(z, JSON.stringify(e)), p.value = "", G(n);
|
|
783
|
+
}), G(n);
|
|
783
784
|
},
|
|
784
785
|
onActivate(n) {
|
|
785
|
-
e = n.state.originalPuzzle, t = n.state.currentInputStr,
|
|
786
|
+
e = n.state.originalPuzzle, t = n.state.currentInputStr, ue(n), W(n);
|
|
786
787
|
},
|
|
787
788
|
onMessage(e, n, r) {
|
|
788
789
|
var i, a;
|
|
789
790
|
let o = r.getElement("#simulator-input"), s = r.getElement("#simulator-input-apply"), c = (i = n == null || (a = n.input) == null ? void 0 : a.boardState) == null ? n == null ? void 0 : n.boardState : i;
|
|
790
791
|
if (e === "UPLOAD_NEW_GAME_STATE" && c) {
|
|
791
|
-
if (r.state.currentInputStr = c,
|
|
792
|
-
|
|
792
|
+
if (r.state.currentInputStr = c, H.length === 0 || H[H.length - 1].value !== c) {
|
|
793
|
+
H.push({
|
|
793
794
|
value: c,
|
|
794
795
|
timestamp: Date.now()
|
|
795
|
-
}),
|
|
796
|
+
}), H.length > 100 && (H = H.slice(-100));
|
|
796
797
|
let e = r.getElement("#data-subtab-history");
|
|
797
|
-
e != null && e.classList.contains("active") &&
|
|
798
|
+
e != null && e.classList.contains("active") && W(r);
|
|
798
799
|
}
|
|
799
|
-
o && document.activeElement !== o && (o.value !== c && (o.value = c,
|
|
800
|
+
o && document.activeElement !== o && (o.value !== c && (o.value = c, U(o)), t = c, s && (s.disabled = !0));
|
|
800
801
|
}
|
|
801
802
|
}
|
|
802
803
|
};
|
|
803
804
|
}
|
|
804
|
-
function
|
|
805
|
+
function ce() {
|
|
805
806
|
try {
|
|
806
|
-
let e = localStorage.getItem(
|
|
807
|
+
let e = localStorage.getItem(z);
|
|
807
808
|
return e ? JSON.parse(e) : [];
|
|
808
809
|
} catch (e) {
|
|
809
810
|
return [];
|
|
810
811
|
}
|
|
811
812
|
}
|
|
812
|
-
function
|
|
813
|
+
function W(e) {
|
|
813
814
|
let t = e.getElement("#simulator-history-list");
|
|
814
815
|
if (t) {
|
|
815
|
-
if (t.style.setProperty("--history-thumb-bg", e.state.selectedTheme.a_bg),
|
|
816
|
+
if (t.style.setProperty("--history-thumb-bg", e.state.selectedTheme.a_bg), H.length === 0) {
|
|
816
817
|
t.innerHTML = "<div class=\"simulator-empty\">No history yet</div>";
|
|
817
818
|
return;
|
|
818
819
|
}
|
|
819
|
-
t.innerHTML = [...
|
|
820
|
-
let r =
|
|
820
|
+
t.innerHTML = [...H].reverse().map((t, n) => {
|
|
821
|
+
let r = H.length - 1 - n, i = new Date(t.timestamp).toLocaleTimeString(), a = t.value.length > 60 ? t.value.slice(0, 60) + "..." : t.value;
|
|
821
822
|
return `
|
|
822
823
|
<div class="history-item" data-history-idx="${r}">
|
|
823
|
-
<div class="history-item-thumb">${
|
|
824
|
+
<div class="history-item-thumb">${V(e, t.value)}</div>
|
|
824
825
|
<div class="history-item-content">
|
|
825
826
|
<div class="history-item-header">
|
|
826
827
|
<span class="history-item-num">#${r + 1}</span>
|
|
827
828
|
<span class="history-item-time">${i}</span>
|
|
828
829
|
<button class="simulator-btn tiny history-restore-btn" data-history-idx="${r}">Restore</button>
|
|
829
830
|
</div>
|
|
830
|
-
<div class="history-item-preview">${
|
|
831
|
+
<div class="history-item-preview">${le(a)}</div>
|
|
831
832
|
</div>
|
|
832
833
|
</div>
|
|
833
834
|
`;
|
|
834
835
|
}).join(""), t.querySelectorAll(".history-restore-btn").forEach((t) => {
|
|
835
836
|
t.addEventListener("click", (t) => {
|
|
836
|
-
let n = parseInt(t.target.getAttribute("data-history-idx") || "0"), r =
|
|
837
|
+
let n = parseInt(t.target.getAttribute("data-history-idx") || "0"), r = H[n];
|
|
837
838
|
if (r) {
|
|
838
839
|
let t = e.getElement(".data-subtab[data-subtab=\"edit\"]");
|
|
839
840
|
t == null || t.click();
|
|
840
841
|
let n = e.getElement("#simulator-input"), i = e.getElement("#simulator-input-apply");
|
|
841
|
-
n && (n.value = r.value,
|
|
842
|
+
n && (n.value = r.value, U(n)), i && (i.disabled = !1), e.updateStatus("Input restored — press Apply to load it", "ready");
|
|
842
843
|
}
|
|
843
844
|
});
|
|
844
845
|
});
|
|
845
846
|
}
|
|
846
847
|
}
|
|
847
|
-
function
|
|
848
|
+
function G(e) {
|
|
848
849
|
let t = e.getElement("#simulator-saves-list");
|
|
849
850
|
if (!t) return;
|
|
850
|
-
let n =
|
|
851
|
+
let n = ce();
|
|
851
852
|
if (n.length === 0) {
|
|
852
853
|
t.innerHTML = "<div class=\"simulator-empty\">No saved states</div>";
|
|
853
854
|
return;
|
|
@@ -857,7 +858,7 @@ function H(e) {
|
|
|
857
858
|
return `
|
|
858
859
|
<div class="save-item">
|
|
859
860
|
<div class="save-item-header">
|
|
860
|
-
<span class="save-item-name">${
|
|
861
|
+
<span class="save-item-name">${le(e.name)}</span>
|
|
861
862
|
<span class="save-item-time">${i} ${a}</span>
|
|
862
863
|
</div>
|
|
863
864
|
<div class="save-item-actions">
|
|
@@ -870,8 +871,8 @@ function H(e) {
|
|
|
870
871
|
t.addEventListener("click", (t) => {
|
|
871
872
|
let r = n[parseInt(t.target.getAttribute("data-save-idx") || "0")];
|
|
872
873
|
if (r) {
|
|
873
|
-
if (!
|
|
874
|
-
|
|
874
|
+
if (!c("puzzle", r.puzzleStr) || !c("input", r.inputStr)) {
|
|
875
|
+
u(), e.updateStatus(`Could not load "${r.name}" — storage unavailable`, "paused");
|
|
875
876
|
return;
|
|
876
877
|
}
|
|
877
878
|
e.updateStatus(`Loading: ${r.name}`, "waiting"), window.location.reload();
|
|
@@ -880,25 +881,25 @@ function H(e) {
|
|
|
880
881
|
}), t.querySelectorAll(".save-delete-btn").forEach((t) => {
|
|
881
882
|
t.addEventListener("click", (t) => {
|
|
882
883
|
let r = parseInt(t.target.getAttribute("data-save-idx") || "0"), i = n.filter((e, t) => t !== r);
|
|
883
|
-
localStorage.setItem(
|
|
884
|
+
localStorage.setItem(z, JSON.stringify(i)), G(e);
|
|
884
885
|
});
|
|
885
886
|
});
|
|
886
887
|
}
|
|
887
|
-
function
|
|
888
|
+
function le(e) {
|
|
888
889
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
889
890
|
}
|
|
890
|
-
function
|
|
891
|
+
function ue(e) {
|
|
891
892
|
let t = e.getElement("#simulator-puzzle"), n = e.getElement("#simulator-input"), r = e.getElement("#simulator-puzzle-apply"), i = e.getElement("#simulator-input-apply");
|
|
892
|
-
t && e.state.originalPuzzle && (t.value = e.state.originalPuzzle,
|
|
893
|
+
t && e.state.originalPuzzle && (t.value = e.state.originalPuzzle, U(t), r && (r.disabled = !0)), n && (n.value = e.state.currentInputStr, U(n), i && (i.disabled = !0)), de(e);
|
|
893
894
|
}
|
|
894
|
-
function
|
|
895
|
+
function de(e) {
|
|
895
896
|
let t = e.getElement("#simulator-puzzle-override-tag"), n = e.getElement("#simulator-input-override-tag");
|
|
896
897
|
t && (t.hidden = e.state.appliedPuzzleOverride === null), n && (n.hidden = e.state.appliedInputOverride === null);
|
|
897
898
|
}
|
|
898
|
-
function
|
|
899
|
+
function fe(e) {
|
|
899
900
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
900
901
|
}
|
|
901
|
-
function
|
|
902
|
+
function pe() {
|
|
902
903
|
let e = 0;
|
|
903
904
|
return {
|
|
904
905
|
id: "msgs",
|
|
@@ -925,7 +926,7 @@ function he() {
|
|
|
925
926
|
<span class="simulator-msg-type">${t.direction === "out" ? "→" : "←"} ${t.type}</span>
|
|
926
927
|
<span class="simulator-msg-time">${t.time}</span>
|
|
927
928
|
</div>
|
|
928
|
-
${a ? `<div class="simulator-msg-data">${
|
|
929
|
+
${a ? `<div class="simulator-msg-data">${fe(a)}</div>` : ""}
|
|
929
930
|
`;
|
|
930
931
|
let o = i.querySelector(".simulator-msg-data");
|
|
931
932
|
for (o && o.addEventListener("click", () => {
|
|
@@ -936,7 +937,7 @@ function he() {
|
|
|
936
937
|
}
|
|
937
938
|
};
|
|
938
939
|
}
|
|
939
|
-
function
|
|
940
|
+
function me() {
|
|
940
941
|
return {
|
|
941
942
|
id: "done",
|
|
942
943
|
label: "Done",
|
|
@@ -973,7 +974,7 @@ function ge() {
|
|
|
973
974
|
}
|
|
974
975
|
};
|
|
975
976
|
}
|
|
976
|
-
function
|
|
977
|
+
function he() {
|
|
977
978
|
let e = [], t = () => (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", { hour12: !1 }), n = (e) => {
|
|
978
979
|
let { checkpointName: t, augConfig: n, time: r } = e, i = n == null ? void 0 : n.deeds;
|
|
979
980
|
return `
|
|
@@ -1023,22 +1024,1553 @@ function _e() {
|
|
|
1023
1024
|
}
|
|
1024
1025
|
};
|
|
1025
1026
|
}
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
var
|
|
1032
|
-
|
|
1027
|
+
var ge = /* @__PURE__ */ n(((e) => {
|
|
1028
|
+
var t = { document: {} }, n = Object.prototype.hasOwnProperty, r = function(e) {
|
|
1029
|
+
return v(e) ? e.toLowerCase() : e;
|
|
1030
|
+
}, i = Array.isArray;
|
|
1031
|
+
function a(e) {
|
|
1032
|
+
var t = Function.prototype.constructor;
|
|
1033
|
+
delete Function.prototype.constructor;
|
|
1034
|
+
var n = e();
|
|
1035
|
+
return Function.prototype.constructor = t, n;
|
|
1036
|
+
}
|
|
1037
|
+
var o, s = Object.prototype.toString, c = Object.getPrototypeOf, l = O("ng");
|
|
1038
|
+
/**
|
|
1039
|
+
* @private
|
|
1040
|
+
* @param {*} obj
|
|
1041
|
+
* @return {boolean} Returns true if `obj` is an array or array-like object (NodeList, Arguments,
|
|
1042
|
+
* String ...)
|
|
1043
|
+
*/
|
|
1044
|
+
function u(e) {
|
|
1045
|
+
if (e == null || x(e)) return !1;
|
|
1046
|
+
if (i(e) || v(e) || o && e instanceof o) return !0;
|
|
1047
|
+
var t = "length" in Object(e) && e.length;
|
|
1048
|
+
return y(t) && (t >= 0 && (t - 1 in e || e instanceof Array) || typeof e.item == "function");
|
|
1049
|
+
}
|
|
1050
|
+
/**
|
|
1051
|
+
* @ngdoc function
|
|
1052
|
+
* @name angular.forEach
|
|
1053
|
+
* @module ng
|
|
1054
|
+
* @kind function
|
|
1055
|
+
*
|
|
1056
|
+
* @description
|
|
1057
|
+
* Invokes the `iterator` function once for each item in `obj` collection, which can be either an
|
|
1058
|
+
* object or an array. The `iterator` function is invoked with `iterator(value, key, obj)`, where `value`
|
|
1059
|
+
* is the value of an object property or an array element, `key` is the object property key or
|
|
1060
|
+
* array element index and obj is the `obj` itself. Specifying a `context` for the function is optional.
|
|
1061
|
+
*
|
|
1062
|
+
* It is worth noting that `.forEach` does not iterate over inherited properties because it filters
|
|
1063
|
+
* using the `hasOwnProperty` method.
|
|
1064
|
+
*
|
|
1065
|
+
* Unlike ES262's
|
|
1066
|
+
* [Array.prototype.forEach](http://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.18),
|
|
1067
|
+
* providing 'undefined' or 'null' values for `obj` will not throw a TypeError, but rather just
|
|
1068
|
+
* return the value provided.
|
|
1069
|
+
*
|
|
1070
|
+
```js
|
|
1071
|
+
var values = {name: 'misko', gender: 'male'};
|
|
1072
|
+
var log = [];
|
|
1073
|
+
angular.forEach(values, function(value, key) {
|
|
1074
|
+
this.push(key + ': ' + value);
|
|
1075
|
+
}, log);
|
|
1076
|
+
expect(log).toEqual(['name: misko', 'gender: male']);
|
|
1077
|
+
```
|
|
1078
|
+
*
|
|
1079
|
+
* @param {Object|Array} obj Object to iterate over.
|
|
1080
|
+
* @param {Function} iterator Iterator function.
|
|
1081
|
+
* @param {Object=} context Object to become context (`this`) for the iterator function.
|
|
1082
|
+
* @returns {Object|Array} Reference to `obj`.
|
|
1083
|
+
*/
|
|
1084
|
+
function d(e, t, r) {
|
|
1085
|
+
var a, o;
|
|
1086
|
+
if (e) if (b(e)) for (a in e) a !== "prototype" && a !== "length" && a !== "name" && e.hasOwnProperty(a) && t.call(r, e[a], a, e);
|
|
1087
|
+
else if (i(e) || u(e)) {
|
|
1088
|
+
var s = typeof e != "object";
|
|
1089
|
+
for (a = 0, o = e.length; a < o; a++) (s || a in e) && t.call(r, e[a], a, e);
|
|
1090
|
+
} else if (e.forEach && e.forEach !== d) e.forEach(t, r, e);
|
|
1091
|
+
else if (_(e)) for (a in e) t.call(r, e[a], a, e);
|
|
1092
|
+
else if (typeof e.hasOwnProperty == "function") for (a in e) e.hasOwnProperty(a) && t.call(r, e[a], a, e);
|
|
1093
|
+
else for (a in e) n.call(e, a) && t.call(r, e[a], a, e);
|
|
1094
|
+
return e;
|
|
1095
|
+
}
|
|
1096
|
+
/**
|
|
1097
|
+
* Set or clear the hashkey for an object.
|
|
1098
|
+
* @param obj object
|
|
1099
|
+
* @param h the hashkey (!truthy to delete the hashkey)
|
|
1100
|
+
*/
|
|
1101
|
+
function f(e, t) {
|
|
1102
|
+
t ? e.$$hashKey = t : delete e.$$hashKey;
|
|
1103
|
+
}
|
|
1104
|
+
function p() {}
|
|
1105
|
+
/**
|
|
1106
|
+
* @ngdoc function
|
|
1107
|
+
* @name angular.isUndefined
|
|
1108
|
+
* @module ng
|
|
1109
|
+
* @kind function
|
|
1110
|
+
*
|
|
1111
|
+
* @description
|
|
1112
|
+
* Determines if a reference is undefined.
|
|
1113
|
+
*
|
|
1114
|
+
* @param {*} value Reference to check.
|
|
1115
|
+
* @returns {boolean} True if `value` is undefined.
|
|
1116
|
+
*/
|
|
1117
|
+
function m(e) {
|
|
1118
|
+
return e === void 0;
|
|
1119
|
+
}
|
|
1120
|
+
/**
|
|
1121
|
+
* @ngdoc function
|
|
1122
|
+
* @name angular.isDefined
|
|
1123
|
+
* @module ng
|
|
1124
|
+
* @kind function
|
|
1125
|
+
*
|
|
1126
|
+
* @description
|
|
1127
|
+
* Determines if a reference is defined.
|
|
1128
|
+
*
|
|
1129
|
+
* @param {*} value Reference to check.
|
|
1130
|
+
* @returns {boolean} True if `value` is defined.
|
|
1131
|
+
*/
|
|
1132
|
+
function h(e) {
|
|
1133
|
+
return e !== void 0;
|
|
1134
|
+
}
|
|
1135
|
+
/**
|
|
1136
|
+
* @ngdoc function
|
|
1137
|
+
* @name angular.isObject
|
|
1138
|
+
* @module ng
|
|
1139
|
+
* @kind function
|
|
1140
|
+
*
|
|
1141
|
+
* @description
|
|
1142
|
+
* Determines if a reference is an `Object`. Unlike `typeof` in JavaScript, `null`s are not
|
|
1143
|
+
* considered to be objects. Note that JavaScript arrays are objects.
|
|
1144
|
+
*
|
|
1145
|
+
* @param {*} value Reference to check.
|
|
1146
|
+
* @returns {boolean} True if `value` is an `Object` but not `null`.
|
|
1147
|
+
*/
|
|
1148
|
+
function g(e) {
|
|
1149
|
+
return typeof e == "object" && !!e;
|
|
1150
|
+
}
|
|
1151
|
+
/**
|
|
1152
|
+
* Determine if a value is an object with a null prototype
|
|
1153
|
+
*
|
|
1154
|
+
* @returns {boolean} True if `value` is an `Object` with a null prototype
|
|
1155
|
+
*/
|
|
1156
|
+
function _(e) {
|
|
1157
|
+
return typeof e == "object" && !!e && !c(e);
|
|
1158
|
+
}
|
|
1159
|
+
/**
|
|
1160
|
+
* @ngdoc function
|
|
1161
|
+
* @name angular.isString
|
|
1162
|
+
* @module ng
|
|
1163
|
+
* @kind function
|
|
1164
|
+
*
|
|
1165
|
+
* @description
|
|
1166
|
+
* Determines if a reference is a `String`.
|
|
1167
|
+
*
|
|
1168
|
+
* @param {*} value Reference to check.
|
|
1169
|
+
* @returns {boolean} True if `value` is a `String`.
|
|
1170
|
+
*/
|
|
1171
|
+
function v(e) {
|
|
1172
|
+
return typeof e == "string";
|
|
1173
|
+
}
|
|
1174
|
+
/**
|
|
1175
|
+
* @ngdoc function
|
|
1176
|
+
* @name angular.isNumber
|
|
1177
|
+
* @module ng
|
|
1178
|
+
* @kind function
|
|
1179
|
+
*
|
|
1180
|
+
* @description
|
|
1181
|
+
* Determines if a reference is a `Number`.
|
|
1182
|
+
*
|
|
1183
|
+
* This includes the "special" numbers `NaN`, `+Infinity` and `-Infinity`.
|
|
1184
|
+
*
|
|
1185
|
+
* If you wish to exclude these then you can use the native
|
|
1186
|
+
* [`isFinite'](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isFinite)
|
|
1187
|
+
* method.
|
|
1188
|
+
*
|
|
1189
|
+
* @param {*} value Reference to check.
|
|
1190
|
+
* @returns {boolean} True if `value` is a `Number`.
|
|
1191
|
+
*/
|
|
1192
|
+
function y(e) {
|
|
1193
|
+
return typeof e == "number";
|
|
1194
|
+
}
|
|
1195
|
+
/**
|
|
1196
|
+
* @ngdoc function
|
|
1197
|
+
* @name angular.isFunction
|
|
1198
|
+
* @module ng
|
|
1199
|
+
* @kind function
|
|
1200
|
+
*
|
|
1201
|
+
* @description
|
|
1202
|
+
* Determines if a reference is a `Function`.
|
|
1203
|
+
*
|
|
1204
|
+
* @param {*} value Reference to check.
|
|
1205
|
+
* @returns {boolean} True if `value` is a `Function`.
|
|
1206
|
+
*/
|
|
1207
|
+
function b(e) {
|
|
1208
|
+
return typeof e == "function";
|
|
1209
|
+
}
|
|
1210
|
+
/**
|
|
1211
|
+
* Checks if `obj` is a window object.
|
|
1212
|
+
*
|
|
1213
|
+
* @private
|
|
1214
|
+
* @param {*} obj Object to check
|
|
1215
|
+
* @returns {boolean} True if `obj` is a window obj.
|
|
1216
|
+
*/
|
|
1217
|
+
function x(e) {
|
|
1218
|
+
return e && e.window === e;
|
|
1219
|
+
}
|
|
1220
|
+
function S(e) {
|
|
1221
|
+
return e && e.$evalAsync && e.$watch;
|
|
1222
|
+
}
|
|
1223
|
+
var ee = /^\[object (?:Uint8|Uint8Clamped|Uint16|Uint32|Int8|Int16|Int32|Float32|Float64)Array\]$/;
|
|
1224
|
+
function C(e) {
|
|
1225
|
+
return e && y(e.length) && ee.test(s.call(e));
|
|
1226
|
+
}
|
|
1227
|
+
function w(e) {
|
|
1228
|
+
return s.call(e) === "[object ArrayBuffer]";
|
|
1229
|
+
}
|
|
1230
|
+
/**
|
|
1231
|
+
* @ngdoc function
|
|
1232
|
+
* @name angular.copy
|
|
1233
|
+
* @module ng
|
|
1234
|
+
* @kind function
|
|
1235
|
+
*
|
|
1236
|
+
* @description
|
|
1237
|
+
* Creates a deep copy of `source`, which should be an object or an array.
|
|
1238
|
+
*
|
|
1239
|
+
* * If no destination is supplied, a copy of the object or array is created.
|
|
1240
|
+
* * If a destination is provided, all of its elements (for arrays) or properties (for objects)
|
|
1241
|
+
* are deleted and then all elements/properties from the source are copied to it.
|
|
1242
|
+
* * If `source` is not an object or array (inc. `null` and `undefined`), `source` is returned.
|
|
1243
|
+
* * If `source` is identical to `destination` an exception will be thrown.
|
|
1244
|
+
*
|
|
1245
|
+
* <br />
|
|
1246
|
+
* <div class="alert alert-warning">
|
|
1247
|
+
* Only enumerable properties are taken into account. Non-enumerable properties (both on `source`
|
|
1248
|
+
* and on `destination`) will be ignored.
|
|
1249
|
+
* </div>
|
|
1250
|
+
*
|
|
1251
|
+
* @param {*} source The source that will be used to make a copy.
|
|
1252
|
+
* Can be any type, including primitives, `null`, and `undefined`.
|
|
1253
|
+
* @param {(Object|Array)=} destination Destination into which the source is copied. If
|
|
1254
|
+
* provided, must be of the same type as `source`.
|
|
1255
|
+
* @returns {*} The copy or updated `destination`, if `destination` was specified.
|
|
1256
|
+
*
|
|
1257
|
+
* @example
|
|
1258
|
+
<example module="copyExample" name="angular-copy">
|
|
1259
|
+
<file name="index.html">
|
|
1260
|
+
<div ng-controller="ExampleController">
|
|
1261
|
+
<form novalidate class="simple-form">
|
|
1262
|
+
<label>Name: <input type="text" ng-model="user.name" /></label><br />
|
|
1263
|
+
<label>Age: <input type="number" ng-model="user.age" /></label><br />
|
|
1264
|
+
Gender: <label><input type="radio" ng-model="user.gender" value="male" />male</label>
|
|
1265
|
+
<label><input type="radio" ng-model="user.gender" value="female" />female</label><br />
|
|
1266
|
+
<button ng-click="reset()">RESET</button>
|
|
1267
|
+
<button ng-click="update(user)">SAVE</button>
|
|
1268
|
+
</form>
|
|
1269
|
+
<pre>form = {{user | json}}</pre>
|
|
1270
|
+
<pre>master = {{master | json}}</pre>
|
|
1271
|
+
</div>
|
|
1272
|
+
</file>
|
|
1273
|
+
<file name="script.js">
|
|
1274
|
+
// Module: copyExample
|
|
1275
|
+
angular.
|
|
1276
|
+
module('copyExample', []).
|
|
1277
|
+
controller('ExampleController', ['$scope', function($scope) {
|
|
1278
|
+
$scope.master = {};
|
|
1279
|
+
|
|
1280
|
+
$scope.reset = function() {
|
|
1281
|
+
// Example with 1 argument
|
|
1282
|
+
$scope.user = angular.copy($scope.master);
|
|
1283
|
+
};
|
|
1284
|
+
|
|
1285
|
+
$scope.update = function(user) {
|
|
1286
|
+
// Example with 2 arguments
|
|
1287
|
+
angular.copy(user, $scope.master);
|
|
1288
|
+
};
|
|
1289
|
+
|
|
1290
|
+
$scope.reset();
|
|
1291
|
+
}]);
|
|
1292
|
+
</file>
|
|
1293
|
+
</example>
|
|
1294
|
+
*/
|
|
1295
|
+
function te(e, t) {
|
|
1296
|
+
var r = [], a = [];
|
|
1297
|
+
if (t) {
|
|
1298
|
+
if (C(t) || w(t)) throw l("cpta", "Can't copy! TypedArray destination cannot be mutated.");
|
|
1299
|
+
if (e === t) throw l("cpi", "Can't copy! Source and destination are identical.");
|
|
1300
|
+
return i(t) ? t.length = 0 : d(t, function(e, n) {
|
|
1301
|
+
n !== "$$hashKey" && delete t[n];
|
|
1302
|
+
}), r.push(e), a.push(t), o(e, t);
|
|
1303
|
+
}
|
|
1304
|
+
return u(e);
|
|
1305
|
+
function o(e, t) {
|
|
1306
|
+
var r = t.$$hashKey, a;
|
|
1307
|
+
if (i(e)) for (var o = 0, s = e.length; o < s; o++) t.push(u(e[o]));
|
|
1308
|
+
else if (_(e)) for (a in e) t[a] = u(e[a]);
|
|
1309
|
+
else if (e && typeof e.hasOwnProperty == "function") for (a in e) e.hasOwnProperty(a) && (t[a] = u(e[a]));
|
|
1310
|
+
else for (a in e) n.call(e, a) && (t[a] = u(e[a]));
|
|
1311
|
+
return f(t, r), t;
|
|
1312
|
+
}
|
|
1313
|
+
function u(e) {
|
|
1314
|
+
if (!g(e)) return e;
|
|
1315
|
+
var t = r.indexOf(e);
|
|
1316
|
+
if (t !== -1) return a[t];
|
|
1317
|
+
if (x(e) || S(e)) throw l("cpws", "Can't copy! Making copies of Window or Scope instances is not supported.");
|
|
1318
|
+
var n = !1, s = p(e);
|
|
1319
|
+
return s === void 0 && (s = i(e) ? [] : Object.create(c(e)), n = !0), r.push(e), a.push(s), n ? o(e, s) : s;
|
|
1320
|
+
}
|
|
1321
|
+
function p(e) {
|
|
1322
|
+
switch (s.call(e)) {
|
|
1323
|
+
case "[object Int8Array]":
|
|
1324
|
+
case "[object Int16Array]":
|
|
1325
|
+
case "[object Int32Array]":
|
|
1326
|
+
case "[object Float32Array]":
|
|
1327
|
+
case "[object Float64Array]":
|
|
1328
|
+
case "[object Uint8Array]":
|
|
1329
|
+
case "[object Uint8ClampedArray]":
|
|
1330
|
+
case "[object Uint16Array]":
|
|
1331
|
+
case "[object Uint32Array]": return new e.constructor(u(e.buffer), e.byteOffset, e.length);
|
|
1332
|
+
case "[object ArrayBuffer]":
|
|
1333
|
+
if (!e.slice) {
|
|
1334
|
+
var t = new ArrayBuffer(e.byteLength);
|
|
1335
|
+
return new Uint8Array(t).set(new Uint8Array(e)), t;
|
|
1336
|
+
}
|
|
1337
|
+
return e.slice(0);
|
|
1338
|
+
case "[object Boolean]":
|
|
1339
|
+
case "[object Number]":
|
|
1340
|
+
case "[object String]":
|
|
1341
|
+
case "[object Date]": return new e.constructor(e.valueOf());
|
|
1342
|
+
case "[object RegExp]":
|
|
1343
|
+
var n = new RegExp(e.source, e.toString().match(/[^\/]*$/)[0]);
|
|
1344
|
+
return n.lastIndex = e.lastIndex, n;
|
|
1345
|
+
case "[object Blob]": return new e.constructor([e], { type: e.type });
|
|
1346
|
+
}
|
|
1347
|
+
if (b(e.cloneNode)) return e.cloneNode(!0);
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
/**
|
|
1351
|
+
* @ngdoc function
|
|
1352
|
+
* @name angular.bind
|
|
1353
|
+
* @module ng
|
|
1354
|
+
* @kind function
|
|
1355
|
+
*
|
|
1356
|
+
* @description
|
|
1357
|
+
* Returns a function which calls function `fn` bound to `self` (`self` becomes the `this` for
|
|
1358
|
+
* `fn`). You can supply optional `args` that are prebound to the function. This feature is also
|
|
1359
|
+
* known as [partial application](http://en.wikipedia.org/wiki/Partial_application), as
|
|
1360
|
+
* distinguished from [function currying](http://en.wikipedia.org/wiki/Currying#Contrast_with_partial_function_application).
|
|
1361
|
+
*
|
|
1362
|
+
* @param {Object} self Context which `fn` should be evaluated in.
|
|
1363
|
+
* @param {function()} fn Function to be bound.
|
|
1364
|
+
* @param {...*} args Optional arguments to be prebound to the `fn` function call.
|
|
1365
|
+
* @returns {function()} Function that wraps the `fn` with all the specified bindings.
|
|
1366
|
+
*/
|
|
1367
|
+
function ne(e, n) {
|
|
1368
|
+
var r = n;
|
|
1369
|
+
return typeof e == "string" && e.charAt(0) === "$" && e.charAt(1) === "$" ? r = void 0 : x(n) ? r = "$WINDOW" : n && t.document === n ? r = "$DOCUMENT" : S(n) && (r = "$SCOPE"), r;
|
|
1370
|
+
}
|
|
1371
|
+
/**
|
|
1372
|
+
* Creates a new object without a prototype. This object is useful for lookup without having to
|
|
1373
|
+
* guard against prototypically inherited properties via hasOwnProperty.
|
|
1374
|
+
*
|
|
1375
|
+
* Related micro-benchmarks:
|
|
1376
|
+
* - http://jsperf.com/object-create2
|
|
1377
|
+
* - http://jsperf.com/proto-map-lookup/2
|
|
1378
|
+
* - http://jsperf.com/for-in-vs-object-keys2
|
|
1379
|
+
*
|
|
1380
|
+
* @returns {Object}
|
|
1381
|
+
*/
|
|
1382
|
+
function T() {
|
|
1383
|
+
return Object.create(null);
|
|
1384
|
+
}
|
|
1385
|
+
function E(e) {
|
|
1386
|
+
var t = [];
|
|
1387
|
+
return JSON.stringify(e, function(e, n) {
|
|
1388
|
+
if (n = ne(e, n), g(n)) {
|
|
1389
|
+
if (t.indexOf(n) >= 0) return "...";
|
|
1390
|
+
t.push(n);
|
|
1391
|
+
}
|
|
1392
|
+
return n;
|
|
1393
|
+
});
|
|
1394
|
+
}
|
|
1395
|
+
function D(e) {
|
|
1396
|
+
return typeof e == "function" ? e.toString().replace(/ \{[\s\S]*$/, "") : m(e) ? "undefined" : typeof e == "string" ? e : E(e);
|
|
1397
|
+
}
|
|
1398
|
+
/**
|
|
1399
|
+
* @description
|
|
1400
|
+
*
|
|
1401
|
+
* This object provides a utility for producing rich Error messages within
|
|
1402
|
+
* Angular. It can be called as follows:
|
|
1403
|
+
*
|
|
1404
|
+
* var exampleMinErr = minErr('example');
|
|
1405
|
+
* throw exampleMinErr('one', 'This {0} is {1}', foo, bar);
|
|
1406
|
+
*
|
|
1407
|
+
* The above creates an instance of minErr in the example namespace. The
|
|
1408
|
+
* resulting error will have a namespaced error code of example.one. The
|
|
1409
|
+
* resulting error will replace {0} with the value of foo, and {1} with the
|
|
1410
|
+
* value of bar. The object is not restricted in the number of arguments it can
|
|
1411
|
+
* take.
|
|
1412
|
+
*
|
|
1413
|
+
* If fewer arguments are specified than necessary for interpolation, the extra
|
|
1414
|
+
* interpolation markers will be preserved in the final string.
|
|
1415
|
+
*
|
|
1416
|
+
* Since data will be parsed statically during a build step, some restrictions
|
|
1417
|
+
* are applied with respect to how minErr instances are created and called.
|
|
1418
|
+
* Instances should have names of the form namespaceMinErr for a minErr created
|
|
1419
|
+
* using minErr('namespace') . Error codes, namespaces and template strings
|
|
1420
|
+
* should all be static strings, not variables or general expressions.
|
|
1421
|
+
*
|
|
1422
|
+
* @param {string} module The namespace to use for the new minErr instance.
|
|
1423
|
+
* @param {function} ErrorConstructor Custom error constructor to be instantiated when returning
|
|
1424
|
+
* error from returned function, for cases when a particular type of error is useful.
|
|
1425
|
+
* @returns {function(code:string, template:string, ...templateArgs): Error} minErr instance
|
|
1426
|
+
*/
|
|
1427
|
+
function O(e, t) {
|
|
1428
|
+
return t = t || Error, function() {
|
|
1429
|
+
var n = 2, r = arguments, i = r[0], a = "[" + (e ? e + ":" : "") + i + "] ", o = r[1], s, c;
|
|
1430
|
+
for (a += o.replace(/\{\d+\}/g, function(e) {
|
|
1431
|
+
var t = +e.slice(1, -1) + n;
|
|
1432
|
+
return t < r.length ? D(r[t]) : e;
|
|
1433
|
+
}), a += "\nhttp://errors.angularjs.org/\"NG_VERSION_FULL\"/" + (e ? e + "/" : "") + i, c = n, s = "?"; c < r.length; c++, s = "&") a += s + "p" + (c - n) + "=" + encodeURIComponent(D(r[c]));
|
|
1434
|
+
return new t(a);
|
|
1435
|
+
};
|
|
1436
|
+
}
|
|
1437
|
+
var k = O("$parse");
|
|
1438
|
+
function A(e) {
|
|
1439
|
+
return e + "";
|
|
1440
|
+
}
|
|
1441
|
+
var j = T();
|
|
1442
|
+
d("+ - * / % === !== == != < > <= >= && || ?? ! = | ?".split(" "), function(e) {
|
|
1443
|
+
j[e] = !0;
|
|
1444
|
+
});
|
|
1445
|
+
var re = {
|
|
1446
|
+
n: "\n",
|
|
1447
|
+
f: "\f",
|
|
1448
|
+
r: "\r",
|
|
1449
|
+
t: " ",
|
|
1450
|
+
v: "\v",
|
|
1451
|
+
"'": "'",
|
|
1452
|
+
"\"": "\""
|
|
1453
|
+
};
|
|
1454
|
+
/**
|
|
1455
|
+
* @constructor
|
|
1456
|
+
*/
|
|
1457
|
+
function M(e) {
|
|
1458
|
+
this.options = e || {};
|
|
1459
|
+
}
|
|
1460
|
+
M.prototype = {
|
|
1461
|
+
constructor: M,
|
|
1462
|
+
lex: function(e) {
|
|
1463
|
+
for (this.text = e, this.index = 0, this.tokens = []; this.index < this.text.length;) {
|
|
1464
|
+
var t = this.text.charAt(this.index);
|
|
1465
|
+
if (t === "\"" || t === "'" || t === "`") this.readString(t);
|
|
1466
|
+
else if (this.isNumber(t) || t === "." && this.isNumber(this.peek())) this.readNumber();
|
|
1467
|
+
else if (this.isIdentifierStart(this.peekMultichar())) this.readIdent();
|
|
1468
|
+
else if (this.is(t, "(){}[].,;:")) this.tokens.push({
|
|
1469
|
+
index: this.index,
|
|
1470
|
+
text: t
|
|
1471
|
+
}), this.index++;
|
|
1472
|
+
else if (this.isWhitespace(t)) this.index++;
|
|
1473
|
+
else {
|
|
1474
|
+
var n = t + this.peek(), r = n + this.peek(2), i = j[t], a = j[n], o = j[r];
|
|
1475
|
+
if (i || a || o) {
|
|
1476
|
+
var s = o ? r : a ? n : t;
|
|
1477
|
+
this.tokens.push({
|
|
1478
|
+
index: this.index,
|
|
1479
|
+
text: s,
|
|
1480
|
+
operator: !0
|
|
1481
|
+
}), this.index += s.length;
|
|
1482
|
+
} else this.throwError("Unexpected next character ", this.index, this.index + 1);
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
return this.tokens;
|
|
1486
|
+
},
|
|
1487
|
+
is: function(e, t) {
|
|
1488
|
+
return t.indexOf(e) !== -1;
|
|
1489
|
+
},
|
|
1490
|
+
peek: function(e) {
|
|
1491
|
+
var t = e || 1;
|
|
1492
|
+
return this.index + t < this.text.length ? this.text.charAt(this.index + t) : !1;
|
|
1493
|
+
},
|
|
1494
|
+
isNumber: function(e) {
|
|
1495
|
+
return e >= "0" && e <= "9" && typeof e == "string";
|
|
1496
|
+
},
|
|
1497
|
+
isWhitespace: function(e) {
|
|
1498
|
+
return e === " " || e === "\r" || e === " " || e === "\n" || e === "\v" || e === "\xA0";
|
|
1499
|
+
},
|
|
1500
|
+
isIdentifierStart: function(e) {
|
|
1501
|
+
return this.options.isIdentifierStart ? this.options.isIdentifierStart(e, this.codePointAt(e)) : this.isValidIdentifierStart(e);
|
|
1502
|
+
},
|
|
1503
|
+
isValidIdentifierStart: function(e) {
|
|
1504
|
+
return e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e === "_" || e === "$";
|
|
1505
|
+
},
|
|
1506
|
+
isIdentifierContinue: function(e) {
|
|
1507
|
+
return this.options.isIdentifierContinue ? this.options.isIdentifierContinue(e, this.codePointAt(e)) : this.isValidIdentifierContinue(e);
|
|
1508
|
+
},
|
|
1509
|
+
isValidIdentifierContinue: function(e, t) {
|
|
1510
|
+
return this.isValidIdentifierStart(e, t) || this.isNumber(e);
|
|
1511
|
+
},
|
|
1512
|
+
codePointAt: function(e) {
|
|
1513
|
+
return e.length === 1 ? e.charCodeAt(0) : (e.charCodeAt(0) << 10) + e.charCodeAt(1) - 56613888;
|
|
1514
|
+
},
|
|
1515
|
+
peekMultichar: function() {
|
|
1516
|
+
var e = this.text.charAt(this.index), t = this.peek();
|
|
1517
|
+
if (!t) return e;
|
|
1518
|
+
var n = e.charCodeAt(0), r = t.charCodeAt(0);
|
|
1519
|
+
return n >= 55296 && n <= 56319 && r >= 56320 && r <= 57343 ? e + t : e;
|
|
1520
|
+
},
|
|
1521
|
+
isExpOperator: function(e) {
|
|
1522
|
+
return e === "-" || e === "+" || this.isNumber(e);
|
|
1523
|
+
},
|
|
1524
|
+
throwError: function(e, t, n) {
|
|
1525
|
+
throw n = n || this.index, k("lexerr", "Lexer Error: {0} at column{1} in expression [{2}].", e, h(t) ? "s " + t + "-" + this.index + " [" + this.text.substring(t, n) + "]" : " " + n, this.text);
|
|
1526
|
+
},
|
|
1527
|
+
readNumber: function() {
|
|
1528
|
+
for (var e = "", t = this.index; this.index < this.text.length;) {
|
|
1529
|
+
var n = r(this.text.charAt(this.index));
|
|
1530
|
+
if (n === "." || this.isNumber(n)) e += n;
|
|
1531
|
+
else {
|
|
1532
|
+
var i = this.peek();
|
|
1533
|
+
if (n === "e" && this.isExpOperator(i)) e += n;
|
|
1534
|
+
else if (this.isExpOperator(n) && i && this.isNumber(i) && e.charAt(e.length - 1) === "e") e += n;
|
|
1535
|
+
else if (this.isExpOperator(n) && (!i || !this.isNumber(i)) && e.charAt(e.length - 1) === "e") this.throwError("Invalid exponent");
|
|
1536
|
+
else break;
|
|
1537
|
+
}
|
|
1538
|
+
this.index++;
|
|
1539
|
+
}
|
|
1540
|
+
this.tokens.push({
|
|
1541
|
+
index: t,
|
|
1542
|
+
text: e,
|
|
1543
|
+
constant: !0,
|
|
1544
|
+
value: Number(e)
|
|
1545
|
+
});
|
|
1546
|
+
},
|
|
1547
|
+
readIdent: function() {
|
|
1548
|
+
var e = this.index;
|
|
1549
|
+
for (this.index += this.peekMultichar().length; this.index < this.text.length;) {
|
|
1550
|
+
var t = this.peekMultichar();
|
|
1551
|
+
if (!this.isIdentifierContinue(t)) break;
|
|
1552
|
+
this.index += t.length;
|
|
1553
|
+
}
|
|
1554
|
+
this.tokens.push({
|
|
1555
|
+
index: e,
|
|
1556
|
+
text: this.text.slice(e, this.index),
|
|
1557
|
+
identifier: !0
|
|
1558
|
+
});
|
|
1559
|
+
},
|
|
1560
|
+
readString: function(e) {
|
|
1561
|
+
var t = this.index;
|
|
1562
|
+
this.index++;
|
|
1563
|
+
for (var n = "", r = e, i = e === "`", a = !1; this.index < this.text.length;) {
|
|
1564
|
+
var o = this.text.charAt(this.index);
|
|
1565
|
+
if (i && o === "$" && this.text.charAt(this.index + 1) === "{") {
|
|
1566
|
+
this.tokens.push({
|
|
1567
|
+
index: t,
|
|
1568
|
+
text: r,
|
|
1569
|
+
constant: !0,
|
|
1570
|
+
value: n
|
|
1571
|
+
});
|
|
1572
|
+
var s = this.text.indexOf("}", this.index), c = this.text.substr(this.index + 2, s - this.index - 2);
|
|
1573
|
+
this.tokens.push({
|
|
1574
|
+
index: this.index,
|
|
1575
|
+
text: "+",
|
|
1576
|
+
operator: !0
|
|
1577
|
+
});
|
|
1578
|
+
for (var l = new M(this.options).lex(c), u = 0, d = l.length; u < d; u++) this.tokens.push(l[u]);
|
|
1579
|
+
this.tokens.push({
|
|
1580
|
+
index: this.index,
|
|
1581
|
+
text: "+",
|
|
1582
|
+
operator: !0
|
|
1583
|
+
}), this.index = s, this.readString("`");
|
|
1584
|
+
return;
|
|
1585
|
+
}
|
|
1586
|
+
if (r += o, a) {
|
|
1587
|
+
if (o === "u") {
|
|
1588
|
+
var f = this.text.substring(this.index + 1, this.index + 5);
|
|
1589
|
+
f.match(/[\da-f]{4}/i) || this.throwError("Invalid unicode escape [\\u" + f + "]"), this.index += 4, n += String.fromCharCode(parseInt(f, 16));
|
|
1590
|
+
} else {
|
|
1591
|
+
var p = re[o];
|
|
1592
|
+
n += p || o;
|
|
1593
|
+
}
|
|
1594
|
+
a = !1;
|
|
1595
|
+
} else if (o === "\\") a = !0;
|
|
1596
|
+
else if (o === e) {
|
|
1597
|
+
this.index++, this.tokens.push({
|
|
1598
|
+
index: t,
|
|
1599
|
+
text: r,
|
|
1600
|
+
constant: !0,
|
|
1601
|
+
value: n
|
|
1602
|
+
});
|
|
1603
|
+
return;
|
|
1604
|
+
} else n += o;
|
|
1605
|
+
this.index++;
|
|
1606
|
+
}
|
|
1607
|
+
this.throwError("Unterminated quote", t);
|
|
1608
|
+
}
|
|
1609
|
+
};
|
|
1610
|
+
function N(e, t) {
|
|
1611
|
+
this.lexer = e, this.options = t;
|
|
1612
|
+
}
|
|
1613
|
+
N.Program = "Program", N.ExpressionStatement = "ExpressionStatement", N.AssignmentExpression = "AssignmentExpression", N.ConditionalExpression = "ConditionalExpression", N.LogicalExpression = "LogicalExpression", N.BinaryExpression = "BinaryExpression", N.UnaryExpression = "UnaryExpression", N.CallExpression = "CallExpression", N.MemberExpression = "MemberExpression", N.Identifier = "Identifier", N.Literal = "Literal", N.ArrayExpression = "ArrayExpression", N.Property = "Property", N.ObjectExpression = "ObjectExpression", N.ThisExpression = "ThisExpression", N.LocalsExpression = "LocalsExpression", N.NGValueParameter = "NGValueParameter", N.prototype = {
|
|
1614
|
+
ast: function(e) {
|
|
1615
|
+
this.text = e, this.tokens = this.lexer.lex(e);
|
|
1616
|
+
var t = this.program();
|
|
1617
|
+
return this.tokens.length !== 0 && this.throwError("is an unexpected token", this.tokens[0]), t;
|
|
1618
|
+
},
|
|
1619
|
+
program: function() {
|
|
1620
|
+
for (var e = [];;) if (this.tokens.length > 0 && !this.peek("}", ")", ";", "]") && e.push(this.expressionStatement()), !this.expect(";")) return {
|
|
1621
|
+
type: N.Program,
|
|
1622
|
+
body: e
|
|
1623
|
+
};
|
|
1624
|
+
},
|
|
1625
|
+
expressionStatement: function() {
|
|
1626
|
+
return {
|
|
1627
|
+
type: N.ExpressionStatement,
|
|
1628
|
+
expression: this.filterChain()
|
|
1629
|
+
};
|
|
1630
|
+
},
|
|
1631
|
+
filterChain: function() {
|
|
1632
|
+
for (var e = this.expression(); this.expect("|");) e = this.filter(e);
|
|
1633
|
+
return e;
|
|
1634
|
+
},
|
|
1635
|
+
expression: function() {
|
|
1636
|
+
return this.assignment();
|
|
1637
|
+
},
|
|
1638
|
+
assignment: function() {
|
|
1639
|
+
var e = this.ternary();
|
|
1640
|
+
if (this.expect("=")) {
|
|
1641
|
+
if (!oe(e)) throw k("lval", "Trying to assign a value to a non l-value");
|
|
1642
|
+
e = {
|
|
1643
|
+
type: N.AssignmentExpression,
|
|
1644
|
+
left: e,
|
|
1645
|
+
right: this.assignment(),
|
|
1646
|
+
operator: "="
|
|
1647
|
+
};
|
|
1648
|
+
}
|
|
1649
|
+
return e;
|
|
1650
|
+
},
|
|
1651
|
+
ternary: function() {
|
|
1652
|
+
var e = this.nullishCoalescing(), t, n;
|
|
1653
|
+
return this.expect("?") && (t = this.expression(), this.consume(":")) ? (n = this.expression(), {
|
|
1654
|
+
type: N.ConditionalExpression,
|
|
1655
|
+
test: e,
|
|
1656
|
+
alternate: t,
|
|
1657
|
+
consequent: n
|
|
1658
|
+
}) : e;
|
|
1659
|
+
},
|
|
1660
|
+
nullishCoalescing: function() {
|
|
1661
|
+
for (var e = this.logicalOR(); this.expect("??");) e = {
|
|
1662
|
+
type: N.LogicalExpression,
|
|
1663
|
+
operator: "??",
|
|
1664
|
+
left: e,
|
|
1665
|
+
right: this.logicalOR()
|
|
1666
|
+
};
|
|
1667
|
+
return e;
|
|
1668
|
+
},
|
|
1669
|
+
logicalOR: function() {
|
|
1670
|
+
for (var e = this.logicalAND(); this.expect("||");) e = {
|
|
1671
|
+
type: N.LogicalExpression,
|
|
1672
|
+
operator: "||",
|
|
1673
|
+
left: e,
|
|
1674
|
+
right: this.logicalAND()
|
|
1675
|
+
};
|
|
1676
|
+
return e;
|
|
1677
|
+
},
|
|
1678
|
+
logicalAND: function() {
|
|
1679
|
+
for (var e = this.equality(); this.expect("&&");) e = {
|
|
1680
|
+
type: N.LogicalExpression,
|
|
1681
|
+
operator: "&&",
|
|
1682
|
+
left: e,
|
|
1683
|
+
right: this.equality()
|
|
1684
|
+
};
|
|
1685
|
+
return e;
|
|
1686
|
+
},
|
|
1687
|
+
equality: function() {
|
|
1688
|
+
for (var e = this.relational(), t; t = this.expect("==", "!=", "===", "!==");) e = {
|
|
1689
|
+
type: N.BinaryExpression,
|
|
1690
|
+
operator: t.text,
|
|
1691
|
+
left: e,
|
|
1692
|
+
right: this.relational()
|
|
1693
|
+
};
|
|
1694
|
+
return e;
|
|
1695
|
+
},
|
|
1696
|
+
relational: function() {
|
|
1697
|
+
for (var e = this.additive(), t; t = this.expect("<", ">", "<=", ">=");) e = {
|
|
1698
|
+
type: N.BinaryExpression,
|
|
1699
|
+
operator: t.text,
|
|
1700
|
+
left: e,
|
|
1701
|
+
right: this.additive()
|
|
1702
|
+
};
|
|
1703
|
+
return e;
|
|
1704
|
+
},
|
|
1705
|
+
additive: function() {
|
|
1706
|
+
for (var e = this.multiplicative(), t; t = this.expect("+", "-");) e = {
|
|
1707
|
+
type: N.BinaryExpression,
|
|
1708
|
+
operator: t.text,
|
|
1709
|
+
left: e,
|
|
1710
|
+
right: this.multiplicative()
|
|
1711
|
+
};
|
|
1712
|
+
return e;
|
|
1713
|
+
},
|
|
1714
|
+
multiplicative: function() {
|
|
1715
|
+
for (var e = this.unary(), t; t = this.expect("*", "/", "%");) e = {
|
|
1716
|
+
type: N.BinaryExpression,
|
|
1717
|
+
operator: t.text,
|
|
1718
|
+
left: e,
|
|
1719
|
+
right: this.unary()
|
|
1720
|
+
};
|
|
1721
|
+
return e;
|
|
1722
|
+
},
|
|
1723
|
+
unary: function() {
|
|
1724
|
+
var e;
|
|
1725
|
+
return (e = this.expect("+", "-", "!")) ? {
|
|
1726
|
+
type: N.UnaryExpression,
|
|
1727
|
+
operator: e.text,
|
|
1728
|
+
prefix: !0,
|
|
1729
|
+
argument: this.unary()
|
|
1730
|
+
} : this.primary();
|
|
1731
|
+
},
|
|
1732
|
+
primary: function() {
|
|
1733
|
+
var e;
|
|
1734
|
+
this.expect("(") ? (e = this.filterChain(), this.consume(")")) : this.expect("[") ? e = this.arrayDeclaration() : this.expect("{") ? e = this.object() : this.selfReferential.hasOwnProperty(this.peek().text) ? e = te(this.selfReferential[this.consume().text]) : this.options.literals.hasOwnProperty(this.peek().text) ? e = {
|
|
1735
|
+
type: N.Literal,
|
|
1736
|
+
value: this.options.literals[this.consume().text]
|
|
1737
|
+
} : this.peek().identifier ? e = this.identifier() : this.peek().constant ? e = this.constant() : this.throwError("not a primary expression", this.peek());
|
|
1738
|
+
for (var t; t = this.expect("(", "[", ".");) t.text === "(" ? (e = {
|
|
1739
|
+
type: N.CallExpression,
|
|
1740
|
+
callee: e,
|
|
1741
|
+
arguments: this.parseArguments()
|
|
1742
|
+
}, this.consume(")")) : t.text === "[" ? (e = {
|
|
1743
|
+
type: N.MemberExpression,
|
|
1744
|
+
object: e,
|
|
1745
|
+
property: this.expression(),
|
|
1746
|
+
computed: !0
|
|
1747
|
+
}, this.consume("]")) : t.text === "." ? e = {
|
|
1748
|
+
type: N.MemberExpression,
|
|
1749
|
+
object: e,
|
|
1750
|
+
property: this.identifier(),
|
|
1751
|
+
computed: !1
|
|
1752
|
+
} : this.throwError("IMPOSSIBLE");
|
|
1753
|
+
return e;
|
|
1754
|
+
},
|
|
1755
|
+
filter: function(e) {
|
|
1756
|
+
for (var t = [e], n = {
|
|
1757
|
+
type: N.CallExpression,
|
|
1758
|
+
callee: this.identifier(),
|
|
1759
|
+
arguments: t,
|
|
1760
|
+
filter: !0
|
|
1761
|
+
}; this.expect(":");) t.push(this.expression());
|
|
1762
|
+
return n;
|
|
1763
|
+
},
|
|
1764
|
+
parseArguments: function() {
|
|
1765
|
+
var e = [];
|
|
1766
|
+
if (this.peekToken().text !== ")") do
|
|
1767
|
+
e.push(this.filterChain());
|
|
1768
|
+
while (this.expect(","));
|
|
1769
|
+
return e;
|
|
1770
|
+
},
|
|
1771
|
+
identifier: function() {
|
|
1772
|
+
var e = this.consume();
|
|
1773
|
+
return e.identifier || this.throwError("is not a valid identifier", e), {
|
|
1774
|
+
type: N.Identifier,
|
|
1775
|
+
name: e.text
|
|
1776
|
+
};
|
|
1777
|
+
},
|
|
1778
|
+
constant: function() {
|
|
1779
|
+
return {
|
|
1780
|
+
type: N.Literal,
|
|
1781
|
+
value: this.consume().value
|
|
1782
|
+
};
|
|
1783
|
+
},
|
|
1784
|
+
arrayDeclaration: function() {
|
|
1785
|
+
var e = [];
|
|
1786
|
+
if (this.peekToken().text !== "]") do {
|
|
1787
|
+
if (this.peek("]")) break;
|
|
1788
|
+
e.push(this.expression());
|
|
1789
|
+
} while (this.expect(","));
|
|
1790
|
+
return this.consume("]"), {
|
|
1791
|
+
type: N.ArrayExpression,
|
|
1792
|
+
elements: e
|
|
1793
|
+
};
|
|
1794
|
+
},
|
|
1795
|
+
object: function() {
|
|
1796
|
+
var e = [], t;
|
|
1797
|
+
if (this.peekToken().text !== "}") do {
|
|
1798
|
+
if (this.peek("}")) break;
|
|
1799
|
+
t = {
|
|
1800
|
+
type: N.Property,
|
|
1801
|
+
kind: "init"
|
|
1802
|
+
}, this.peek().constant ? (t.key = this.constant(), t.computed = !1, this.consume(":"), t.value = this.expression()) : this.peek().identifier ? (t.key = this.identifier(), t.computed = !1, this.peek(":") ? (this.consume(":"), t.value = this.expression()) : t.value = t.key) : this.peek("[") ? (this.consume("["), t.key = this.expression(), this.consume("]"), t.computed = !0, this.consume(":"), t.value = this.expression()) : this.throwError("invalid key", this.peek()), e.push(t);
|
|
1803
|
+
} while (this.expect(","));
|
|
1804
|
+
return this.consume("}"), {
|
|
1805
|
+
type: N.ObjectExpression,
|
|
1806
|
+
properties: e
|
|
1807
|
+
};
|
|
1808
|
+
},
|
|
1809
|
+
throwError: function(e, t) {
|
|
1810
|
+
throw k("syntax", "Syntax Error: Token '{0}' {1} at column {2} of the expression [{3}] starting at [{4}].", t.text, e, t.index + 1, this.text, this.text.substring(t.index));
|
|
1811
|
+
},
|
|
1812
|
+
consume: function(e) {
|
|
1813
|
+
if (this.tokens.length === 0) throw k("ueoe", "Unexpected end of expression: {0}", this.text);
|
|
1814
|
+
var t = this.expect(e);
|
|
1815
|
+
return t || this.throwError("is unexpected, expecting [" + e + "]", this.peek()), t;
|
|
1816
|
+
},
|
|
1817
|
+
peekToken: function() {
|
|
1818
|
+
if (this.tokens.length === 0) throw k("ueoe", "Unexpected end of expression: {0}", this.text);
|
|
1819
|
+
return this.tokens[0];
|
|
1820
|
+
},
|
|
1821
|
+
peek: function(e, t, n, r) {
|
|
1822
|
+
return this.peekAhead(0, e, t, n, r);
|
|
1823
|
+
},
|
|
1824
|
+
peekAhead: function(e, t, n, r, i) {
|
|
1825
|
+
if (this.tokens.length > e) {
|
|
1826
|
+
var a = this.tokens[e], o = a.text;
|
|
1827
|
+
if (o === t || o === n || o === r || o === i || !t && !n && !r && !i) return a;
|
|
1828
|
+
}
|
|
1829
|
+
return !1;
|
|
1830
|
+
},
|
|
1831
|
+
expect: function(e, t, n, r) {
|
|
1832
|
+
var i = this.peek(e, t, n, r);
|
|
1833
|
+
return i ? (this.tokens.shift(), i) : !1;
|
|
1834
|
+
}
|
|
1835
|
+
};
|
|
1836
|
+
function ie(e, t) {
|
|
1837
|
+
return e === void 0 ? t : e;
|
|
1838
|
+
}
|
|
1839
|
+
function P(e, t) {
|
|
1840
|
+
return e === void 0 ? t : t === void 0 ? e : e + t;
|
|
1841
|
+
}
|
|
1842
|
+
function F(e, t) {
|
|
1843
|
+
var n = e(t);
|
|
1844
|
+
if (!n) throw Error("Filter '" + t + "' is not defined");
|
|
1845
|
+
return !n.$stateful;
|
|
1846
|
+
}
|
|
1847
|
+
function I(e, t) {
|
|
1848
|
+
var n, r, i;
|
|
1849
|
+
switch (e.type) {
|
|
1850
|
+
case N.Program:
|
|
1851
|
+
n = !0, d(e.body, function(e) {
|
|
1852
|
+
I(e.expression, t), n = n && e.expression.constant;
|
|
1853
|
+
}), e.constant = n;
|
|
1854
|
+
break;
|
|
1855
|
+
case N.Literal:
|
|
1856
|
+
e.constant = !0, e.toWatch = [];
|
|
1857
|
+
break;
|
|
1858
|
+
case N.UnaryExpression:
|
|
1859
|
+
I(e.argument, t), e.constant = e.argument.constant, e.toWatch = e.argument.toWatch;
|
|
1860
|
+
break;
|
|
1861
|
+
case N.BinaryExpression:
|
|
1862
|
+
I(e.left, t), I(e.right, t), e.constant = e.left.constant && e.right.constant, e.toWatch = e.left.toWatch.concat(e.right.toWatch);
|
|
1863
|
+
break;
|
|
1864
|
+
case N.LogicalExpression:
|
|
1865
|
+
I(e.left, t), I(e.right, t), e.constant = e.left.constant && e.right.constant, e.toWatch = e.constant ? [] : [e];
|
|
1866
|
+
break;
|
|
1867
|
+
case N.ConditionalExpression:
|
|
1868
|
+
I(e.test, t), I(e.alternate, t), I(e.consequent, t), e.constant = e.test.constant && e.alternate.constant && e.consequent.constant, e.toWatch = e.constant ? [] : [e];
|
|
1869
|
+
break;
|
|
1870
|
+
case N.Identifier:
|
|
1871
|
+
e.constant = !1, e.toWatch = [e];
|
|
1872
|
+
break;
|
|
1873
|
+
case N.MemberExpression:
|
|
1874
|
+
I(e.object, t), e.computed && I(e.property, t), e.constant = e.object.constant && (!e.computed || e.property.constant), e.toWatch = [e];
|
|
1875
|
+
break;
|
|
1876
|
+
case N.CallExpression:
|
|
1877
|
+
i = e.filter ? F(t, e.callee.name) : !1, n = i, r = [], d(e.arguments, function(e) {
|
|
1878
|
+
I(e, t), n = n && e.constant, e.constant || r.push.apply(r, e.toWatch);
|
|
1879
|
+
}), e.constant = n, e.toWatch = i ? r : [e];
|
|
1880
|
+
break;
|
|
1881
|
+
case N.AssignmentExpression:
|
|
1882
|
+
I(e.left, t), I(e.right, t), e.constant = e.left.constant && e.right.constant, e.toWatch = [e];
|
|
1883
|
+
break;
|
|
1884
|
+
case N.ArrayExpression:
|
|
1885
|
+
n = !0, r = [], d(e.elements, function(e) {
|
|
1886
|
+
I(e, t), n = n && e.constant, e.constant || r.push.apply(r, e.toWatch);
|
|
1887
|
+
}), e.constant = n, e.toWatch = r;
|
|
1888
|
+
break;
|
|
1889
|
+
case N.ObjectExpression:
|
|
1890
|
+
n = !0, r = [], d(e.properties, function(e) {
|
|
1891
|
+
I(e.value, t), n = n && e.value.constant && !e.computed, e.value.constant || r.push.apply(r, e.value.toWatch);
|
|
1892
|
+
}), e.constant = n, e.toWatch = r;
|
|
1893
|
+
break;
|
|
1894
|
+
case N.ThisExpression:
|
|
1895
|
+
e.constant = !1, e.toWatch = [];
|
|
1896
|
+
break;
|
|
1897
|
+
case N.LocalsExpression:
|
|
1898
|
+
e.constant = !1, e.toWatch = [];
|
|
1899
|
+
break;
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
function ae(e) {
|
|
1903
|
+
if (e.length === 1) {
|
|
1904
|
+
var t = e[0].expression, n = t.toWatch;
|
|
1905
|
+
return n.length === 1 && n[0] === t ? void 0 : n;
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
function oe(e) {
|
|
1909
|
+
return e.type === N.Identifier || e.type === N.MemberExpression;
|
|
1910
|
+
}
|
|
1911
|
+
function L(e) {
|
|
1912
|
+
if (e.body.length === 1 && oe(e.body[0].expression)) return {
|
|
1913
|
+
type: N.AssignmentExpression,
|
|
1914
|
+
left: e.body[0].expression,
|
|
1915
|
+
right: { type: N.NGValueParameter },
|
|
1916
|
+
operator: "="
|
|
1917
|
+
};
|
|
1918
|
+
}
|
|
1919
|
+
function R(e) {
|
|
1920
|
+
return e.body.length === 0 || e.body.length === 1 && (e.body[0].expression.type === N.Literal || e.body[0].expression.type === N.ArrayExpression || e.body[0].expression.type === N.ObjectExpression);
|
|
1033
1921
|
}
|
|
1922
|
+
function z(e) {
|
|
1923
|
+
return e.constant;
|
|
1924
|
+
}
|
|
1925
|
+
function B(e, t) {
|
|
1926
|
+
this.astBuilder = e, this.$filter = t;
|
|
1927
|
+
}
|
|
1928
|
+
B.prototype = {
|
|
1929
|
+
compile: function(e) {
|
|
1930
|
+
var t = this, n = this.astBuilder.ast(e);
|
|
1931
|
+
this.state = {
|
|
1932
|
+
nextId: 0,
|
|
1933
|
+
filters: {},
|
|
1934
|
+
fn: {
|
|
1935
|
+
vars: [],
|
|
1936
|
+
body: [],
|
|
1937
|
+
own: {}
|
|
1938
|
+
},
|
|
1939
|
+
assign: {
|
|
1940
|
+
vars: [],
|
|
1941
|
+
body: [],
|
|
1942
|
+
own: {}
|
|
1943
|
+
},
|
|
1944
|
+
inputs: []
|
|
1945
|
+
}, I(n, t.$filter);
|
|
1946
|
+
var r = "", i;
|
|
1947
|
+
if (this.stage = "assign", i = L(n)) {
|
|
1948
|
+
this.state.computing = "assign";
|
|
1949
|
+
var o = this.nextId();
|
|
1950
|
+
this.recurse(i, o), this.return_(o), r = "fn.assign=" + this.generateFunction("assign", "s,v,l");
|
|
1951
|
+
}
|
|
1952
|
+
var s = ae(n.body);
|
|
1953
|
+
t.stage = "inputs", d(s, function(e, n) {
|
|
1954
|
+
var r = "fn" + n;
|
|
1955
|
+
t.state[r] = {
|
|
1956
|
+
vars: [],
|
|
1957
|
+
body: [],
|
|
1958
|
+
own: {}
|
|
1959
|
+
}, t.state.computing = r;
|
|
1960
|
+
var i = t.nextId();
|
|
1961
|
+
t.recurse(e, i), t.return_(i), t.state.inputs.push(r), e.watchId = n;
|
|
1962
|
+
}), this.state.computing = "fn", this.stage = "main", this.recurse(n);
|
|
1963
|
+
var c = "\"" + this.USE + " " + this.STRICT + "\";\n" + this.filterPrefix() + "var fn=" + this.generateFunction("fn", "s,l,a,i") + r + this.watchFns() + "return fn;", l = Function("$filter", "getStringValue", "ifDefined", "plus", c)(this.$filter, A, ie, P), u = function(e, t, n, r) {
|
|
1964
|
+
return a(function() {
|
|
1965
|
+
return l(e, t, n, r);
|
|
1966
|
+
});
|
|
1967
|
+
};
|
|
1968
|
+
return u.assign = function(e, t, n) {
|
|
1969
|
+
return a(function() {
|
|
1970
|
+
return l.assign(e, t, n);
|
|
1971
|
+
});
|
|
1972
|
+
}, u.inputs = l.inputs, this.state = this.stage = void 0, u.ast = n, u.literal = R(n), u.constant = z(n), u;
|
|
1973
|
+
},
|
|
1974
|
+
USE: "use",
|
|
1975
|
+
STRICT: "strict",
|
|
1976
|
+
watchFns: function() {
|
|
1977
|
+
var e = [], t = this.state.inputs, n = this;
|
|
1978
|
+
return d(t, function(t) {
|
|
1979
|
+
e.push("var " + t + "=" + n.generateFunction(t, "s"));
|
|
1980
|
+
}), t.length && e.push("fn.inputs=[" + t.join(",") + "];"), e.join("");
|
|
1981
|
+
},
|
|
1982
|
+
generateFunction: function(e, t) {
|
|
1983
|
+
return "function(" + t + "){" + this.varsPrefix(e) + this.body(e) + "};";
|
|
1984
|
+
},
|
|
1985
|
+
filterPrefix: function() {
|
|
1986
|
+
var e = [], t = this;
|
|
1987
|
+
return d(this.state.filters, function(n, r) {
|
|
1988
|
+
e.push(n + "=$filter(" + t.escape(r) + ")");
|
|
1989
|
+
}), e.length ? "var " + e.join(",") + ";" : "";
|
|
1990
|
+
},
|
|
1991
|
+
varsPrefix: function(e) {
|
|
1992
|
+
return this.state[e].vars.length ? "var " + this.state[e].vars.join(",") + ";" : "";
|
|
1993
|
+
},
|
|
1994
|
+
body: function(e) {
|
|
1995
|
+
return this.state[e].body.join("");
|
|
1996
|
+
},
|
|
1997
|
+
recurse: function(e, t, n, r, i, a) {
|
|
1998
|
+
var o, s, c = this, l, u, f;
|
|
1999
|
+
if (r = r || p, !a && h(e.watchId)) {
|
|
2000
|
+
t = t || this.nextId(), this.if_("i", this.lazyAssign(t, this.unsafeComputedMember("i", e.watchId)), this.lazyRecurse(e, t, n, r, i, !0));
|
|
2001
|
+
return;
|
|
2002
|
+
}
|
|
2003
|
+
switch (e.type) {
|
|
2004
|
+
case N.Program:
|
|
2005
|
+
d(e.body, function(t, n) {
|
|
2006
|
+
c.recurse(t.expression, void 0, void 0, function(e) {
|
|
2007
|
+
s = e;
|
|
2008
|
+
}), n === e.body.length - 1 ? c.return_(s) : c.current().body.push(s, ";");
|
|
2009
|
+
});
|
|
2010
|
+
break;
|
|
2011
|
+
case N.Literal:
|
|
2012
|
+
u = this.escape(e.value), this.assign(t, u), r(t || u);
|
|
2013
|
+
break;
|
|
2014
|
+
case N.UnaryExpression:
|
|
2015
|
+
this.recurse(e.argument, void 0, void 0, function(e) {
|
|
2016
|
+
s = e;
|
|
2017
|
+
}), u = e.operator + "(" + this.ifDefined(s, 0) + ")", this.assign(t, u), r(u);
|
|
2018
|
+
break;
|
|
2019
|
+
case N.BinaryExpression:
|
|
2020
|
+
this.recurse(e.left, void 0, void 0, function(e) {
|
|
2021
|
+
o = e;
|
|
2022
|
+
}), this.recurse(e.right, void 0, void 0, function(e) {
|
|
2023
|
+
s = e;
|
|
2024
|
+
}), u = e.operator === "+" ? this.plus(o, s) : e.operator === "-" ? this.ifDefined(o, 0) + e.operator + this.ifDefined(s, 0) : "(" + o + ")" + e.operator + "(" + s + ")", this.assign(t, u), r(u);
|
|
2025
|
+
break;
|
|
2026
|
+
case N.LogicalExpression:
|
|
2027
|
+
t = t || this.nextId(), c.recurse(e.left, t), e.operator === "??" ? c.if_(c.or_(c.isNull(t), "typeof " + t + " === 'undefined'"), c.lazyRecurse(e.right, t)) : c.if_(e.operator === "&&" ? t : c.not(t), c.lazyRecurse(e.right, t)), r(t);
|
|
2028
|
+
break;
|
|
2029
|
+
case N.ConditionalExpression:
|
|
2030
|
+
t = t || this.nextId(), c.recurse(e.test, t), c.if_(t, c.lazyRecurse(e.alternate, t), c.lazyRecurse(e.consequent, t)), r(t);
|
|
2031
|
+
break;
|
|
2032
|
+
case N.Identifier:
|
|
2033
|
+
t = t || this.nextId();
|
|
2034
|
+
var m = c.current().inAssignment;
|
|
2035
|
+
n && (m ? n.context = this.assign(this.nextId(), "s") : n.context = c.stage === "inputs" ? "s" : this.assign(this.nextId(), this.getHasOwnProperty("l", e.name) + "?l:s"), n.computed = !1, n.name = e.name), c.if_(c.stage === "inputs" || c.not(c.getHasOwnProperty("l", e.name)), function() {
|
|
2036
|
+
c.if_(c.stage === "inputs" || "s", function() {
|
|
2037
|
+
var n = c.nextId();
|
|
2038
|
+
c.assign(n, c.nonComputedMember("s", e.name)), c.if_(c.or_(c.isNull(n), c.hasOwnProperty_("s", e.name)), function() {
|
|
2039
|
+
i && i !== 1 ? (c.if_(c.isNull(n), c.lazyAssign(c.nonComputedMember("s", e.name), "{}")), c.assign(t, c.nonComputedMember("s", e.name))) : c.assign(t, n);
|
|
2040
|
+
});
|
|
2041
|
+
});
|
|
2042
|
+
}, t && function() {
|
|
2043
|
+
c.if_(c.hasOwnProperty_("l", e.name), c.lazyAssign(t, c.nonComputedMember("l", e.name)));
|
|
2044
|
+
}), r(t);
|
|
2045
|
+
break;
|
|
2046
|
+
case N.MemberExpression:
|
|
2047
|
+
o = n && (n.context = this.nextId()) || this.nextId(), t = t || this.nextId(), c.recurse(e.object, o, void 0, function() {
|
|
2048
|
+
var a = null, l = c.current().inAssignment;
|
|
2049
|
+
e.computed ? (s = c.nextId(), a = l || c.state.computing === "assign" ? c.unsafeComputedMember(o, s) : c.computedMember(o, s)) : (a = l || c.state.computing === "assign" ? c.unsafeNonComputedMember(o, e.property.name) : c.nonComputedMember(o, e.property.name), s = e.property.name), e.computed && e.property.type === N.Literal && c.recurse(e.property, s), c.if_(c.and_(c.notNull(o), c.or_(c.isNull(a), c.hasOwnProperty_(o, s, e.computed))), function() {
|
|
2050
|
+
e.computed ? (e.property.type !== N.Literal && c.recurse(e.property, s), i && i !== 1 && c.if_(c.not(a), c.lazyAssign(a, "{}")), c.assign(t, a), n && (n.computed = !0, n.name = s)) : (i && i !== 1 && c.if_(c.isNull(a), c.lazyAssign(a, "{}")), c.assign(t, a), n && (n.computed = !1, n.name = e.property.name));
|
|
2051
|
+
}, function() {
|
|
2052
|
+
c.assign(t, "undefined");
|
|
2053
|
+
}), r(t);
|
|
2054
|
+
}, !!i);
|
|
2055
|
+
break;
|
|
2056
|
+
case N.CallExpression:
|
|
2057
|
+
t = t || this.nextId(), e.filter ? (s = c.filter(e.callee.name), l = [], d(e.arguments, function(e) {
|
|
2058
|
+
var t = c.nextId();
|
|
2059
|
+
c.recurse(e, t), l.push(t);
|
|
2060
|
+
}), u = s + ".call(" + s + "," + l.join(",") + ")", c.assign(t, u), r(t)) : (s = c.nextId(), o = {}, l = [], c.recurse(e.callee, s, o, function() {
|
|
2061
|
+
c.if_(c.notNull(s), function() {
|
|
2062
|
+
d(e.arguments, function(t) {
|
|
2063
|
+
c.recurse(t, e.constant ? void 0 : c.nextId(), void 0, function(e) {
|
|
2064
|
+
l.push(e);
|
|
2065
|
+
});
|
|
2066
|
+
}), u = o.name ? "(" + c.member(o.context, o.name, o.computed) + " === null ? null : " + c.unsafeMember(o.context, o.name, o.computed) + ".call(" + [o.context].concat(l).join(",") + "))" : s + "(" + l.join(",") + ")", c.assign(t, u);
|
|
2067
|
+
}, function() {
|
|
2068
|
+
c.assign(t, "undefined");
|
|
2069
|
+
}), r(t);
|
|
2070
|
+
}));
|
|
2071
|
+
break;
|
|
2072
|
+
case N.AssignmentExpression:
|
|
2073
|
+
s = this.nextId(), o = {}, c.current().inAssignment = !0, this.recurse(e.left, void 0, o, function() {
|
|
2074
|
+
c.if_(c.and_(c.notNull(o.context), c.or_(c.hasOwnProperty_(o.context, o.name), c.isNull(c.member(o.context, o.name, o.computed)))), function() {
|
|
2075
|
+
c.recurse(e.right, s), u = c.member(o.context, o.name, o.computed) + e.operator + s, c.assign(t, u), r(t || u);
|
|
2076
|
+
}), c.current().inAssignment = !1, c.recurse(e.right, s), c.current().inAssignment = !0;
|
|
2077
|
+
}, 1), c.current().inAssignment = !1;
|
|
2078
|
+
break;
|
|
2079
|
+
case N.ArrayExpression:
|
|
2080
|
+
l = [], d(e.elements, function(t) {
|
|
2081
|
+
c.recurse(t, e.constant ? void 0 : c.nextId(), void 0, function(e) {
|
|
2082
|
+
l.push(e);
|
|
2083
|
+
});
|
|
2084
|
+
}), u = "[" + l.join(",") + "]", this.assign(t, u), r(t || u);
|
|
2085
|
+
break;
|
|
2086
|
+
case N.ObjectExpression:
|
|
2087
|
+
l = [], f = !1, d(e.properties, function(e) {
|
|
2088
|
+
e.computed && (f = !0);
|
|
2089
|
+
}), f ? (t = t || this.nextId(), this.assign(t, "{}"), d(e.properties, function(e) {
|
|
2090
|
+
e.computed ? (o = c.nextId(), c.recurse(e.key, o)) : o = e.key.type === N.Identifier ? e.key.name : "" + e.key.value, s = c.nextId(), c.recurse(e.value, s), c.assign(c.unsafeMember(t, o, e.computed), s);
|
|
2091
|
+
})) : (d(e.properties, function(t) {
|
|
2092
|
+
c.recurse(t.value, e.constant ? void 0 : c.nextId(), void 0, function(e) {
|
|
2093
|
+
l.push(c.escape(t.key.type === N.Identifier ? t.key.name : "" + t.key.value) + ":" + e);
|
|
2094
|
+
});
|
|
2095
|
+
}), u = "{" + l.join(",") + "}", this.assign(t, u)), r(t || u);
|
|
2096
|
+
break;
|
|
2097
|
+
case N.ThisExpression:
|
|
2098
|
+
this.assign(t, "s"), r(t || "s");
|
|
2099
|
+
break;
|
|
2100
|
+
case N.LocalsExpression:
|
|
2101
|
+
this.assign(t, "l"), r(t || "l");
|
|
2102
|
+
break;
|
|
2103
|
+
case N.NGValueParameter:
|
|
2104
|
+
this.assign(t, "v"), r(t || "v");
|
|
2105
|
+
break;
|
|
2106
|
+
}
|
|
2107
|
+
},
|
|
2108
|
+
getHasOwnProperty: function(e, t) {
|
|
2109
|
+
var n = e + "." + t, r = this.current().own;
|
|
2110
|
+
return r.hasOwnProperty(n) || (r[n] = this.nextId(!1, e + "&&(" + this.escape(t) + " in " + e + ")")), r[n];
|
|
2111
|
+
},
|
|
2112
|
+
assign: function(e, t) {
|
|
2113
|
+
if (e) return this.current().body.push(e, "=", t, ";"), e;
|
|
2114
|
+
},
|
|
2115
|
+
filter: function(e) {
|
|
2116
|
+
return n.call(this.state.filters, e) || (this.state.filters[e] = this.nextId(!0)), this.state.filters[e];
|
|
2117
|
+
},
|
|
2118
|
+
ifDefined: function(e, t) {
|
|
2119
|
+
return "ifDefined(" + e + "," + this.escape(t) + ")";
|
|
2120
|
+
},
|
|
2121
|
+
plus: function(e, t) {
|
|
2122
|
+
return "plus(" + e + "," + t + ")";
|
|
2123
|
+
},
|
|
2124
|
+
return_: function(e) {
|
|
2125
|
+
this.current().body.push("return ", e, ";");
|
|
2126
|
+
},
|
|
2127
|
+
if_: function(e, t, n) {
|
|
2128
|
+
if (e === !0) t();
|
|
2129
|
+
else {
|
|
2130
|
+
var r = this.current().body;
|
|
2131
|
+
r.push("if(", e, "){"), t(), r.push("}"), n && (r.push("else{"), n(), r.push("}"));
|
|
2132
|
+
}
|
|
2133
|
+
},
|
|
2134
|
+
or_: function(e, t) {
|
|
2135
|
+
return "(" + e + ") || (" + t + ")";
|
|
2136
|
+
},
|
|
2137
|
+
hasOwnProperty_: function(e, t, n) {
|
|
2138
|
+
return n ? "(Object.prototype.hasOwnProperty.call(" + e + "," + t + "))" : "(Object.prototype.hasOwnProperty.call(" + e + ",'" + t + "'))";
|
|
2139
|
+
},
|
|
2140
|
+
and_: function(e, t) {
|
|
2141
|
+
return "(" + e + ") && (" + t + ")";
|
|
2142
|
+
},
|
|
2143
|
+
not: function(e) {
|
|
2144
|
+
return "!(" + e + ")";
|
|
2145
|
+
},
|
|
2146
|
+
isNull: function(e) {
|
|
2147
|
+
return e + "==null";
|
|
2148
|
+
},
|
|
2149
|
+
notNull: function(e) {
|
|
2150
|
+
return e + "!=null";
|
|
2151
|
+
},
|
|
2152
|
+
nonComputedMember: function(e, t) {
|
|
2153
|
+
var n = /^[$_a-zA-Z][$_a-zA-Z0-9]*$/, r = /[^$_a-zA-Z0-9]/g, i = "";
|
|
2154
|
+
return n.test(t) ? i = e + "." + t : (t = t.replace(r, this.stringEscapeFn), i = e + "[\"" + t + "\"]"), i;
|
|
2155
|
+
},
|
|
2156
|
+
unsafeComputedMember: function(e, t) {
|
|
2157
|
+
return e + "[" + t + "]";
|
|
2158
|
+
},
|
|
2159
|
+
unsafeNonComputedMember: function(e, t) {
|
|
2160
|
+
return this.nonComputedMember(e, t);
|
|
2161
|
+
},
|
|
2162
|
+
computedMember: function(e, t) {
|
|
2163
|
+
return this.state.computing === "assign" ? this.unsafeComputedMember(e, t) : "(" + e + ".hasOwnProperty(" + t + ") ? " + e + "[" + t + "] : undefined)";
|
|
2164
|
+
},
|
|
2165
|
+
unsafeMember: function(e, t, n) {
|
|
2166
|
+
return n ? this.unsafeComputedMember(e, t) : this.unsafeNonComputedMember(e, t);
|
|
2167
|
+
},
|
|
2168
|
+
member: function(e, t, n) {
|
|
2169
|
+
return n ? this.computedMember(e, t) : this.nonComputedMember(e, t);
|
|
2170
|
+
},
|
|
2171
|
+
getStringValue: function(e) {
|
|
2172
|
+
this.assign(e, "getStringValue(" + e + ")");
|
|
2173
|
+
},
|
|
2174
|
+
lazyRecurse: function(e, t, n, r, i, a) {
|
|
2175
|
+
var o = this;
|
|
2176
|
+
return function() {
|
|
2177
|
+
o.recurse(e, t, n, r, i, a);
|
|
2178
|
+
};
|
|
2179
|
+
},
|
|
2180
|
+
lazyAssign: function(e, t) {
|
|
2181
|
+
var n = this;
|
|
2182
|
+
return function() {
|
|
2183
|
+
n.assign(e, t);
|
|
2184
|
+
};
|
|
2185
|
+
},
|
|
2186
|
+
stringEscapeRegex: /[^ a-zA-Z0-9]/g,
|
|
2187
|
+
stringEscapeFn: function(e) {
|
|
2188
|
+
return "\\u" + ("0000" + e.charCodeAt(0).toString(16)).slice(-4);
|
|
2189
|
+
},
|
|
2190
|
+
escape: function(e) {
|
|
2191
|
+
if (v(e)) return "'" + e.replace(this.stringEscapeRegex, this.stringEscapeFn) + "'";
|
|
2192
|
+
if (y(e)) return e.toString();
|
|
2193
|
+
if (e === !0) return "true";
|
|
2194
|
+
if (e === !1) return "false";
|
|
2195
|
+
if (e === null) return "null";
|
|
2196
|
+
if (e === void 0) return "undefined";
|
|
2197
|
+
throw k("esc", "IMPOSSIBLE");
|
|
2198
|
+
},
|
|
2199
|
+
nextId: function(e, t) {
|
|
2200
|
+
var n = "v" + this.state.nextId++;
|
|
2201
|
+
return e || this.current().vars.push(n + (t ? "=" + t : "")), n;
|
|
2202
|
+
},
|
|
2203
|
+
current: function() {
|
|
2204
|
+
return this.state[this.state.computing];
|
|
2205
|
+
}
|
|
2206
|
+
};
|
|
2207
|
+
function V(e, t) {
|
|
2208
|
+
this.astBuilder = e, this.$filter = t;
|
|
2209
|
+
}
|
|
2210
|
+
V.prototype = {
|
|
2211
|
+
compile: function(e) {
|
|
2212
|
+
var t = this, n = this.astBuilder.ast(e);
|
|
2213
|
+
I(n, t.$filter);
|
|
2214
|
+
var r, i;
|
|
2215
|
+
(r = L(n)) && (i = this.recurse(r));
|
|
2216
|
+
var o = ae(n.body), s;
|
|
2217
|
+
o && (s = [], d(o, function(e, n) {
|
|
2218
|
+
var r = t.recurse(e);
|
|
2219
|
+
e.input = r, s.push(r), e.watchId = n;
|
|
2220
|
+
}));
|
|
2221
|
+
var c = [];
|
|
2222
|
+
d(n.body, function(e) {
|
|
2223
|
+
c.push(t.recurse(e.expression));
|
|
2224
|
+
});
|
|
2225
|
+
var l = n.body.length === 0 ? p : n.body.length === 1 ? c[0] : function(e, t) {
|
|
2226
|
+
var n;
|
|
2227
|
+
return d(c, function(r) {
|
|
2228
|
+
n = r(e, t);
|
|
2229
|
+
}), n;
|
|
2230
|
+
};
|
|
2231
|
+
i && (l.assign = function(e, t, n) {
|
|
2232
|
+
return i(e, n, t);
|
|
2233
|
+
});
|
|
2234
|
+
var u = function(e, t) {
|
|
2235
|
+
return a(function() {
|
|
2236
|
+
return l(e, t);
|
|
2237
|
+
});
|
|
2238
|
+
};
|
|
2239
|
+
return u.assign = function(e, t, n) {
|
|
2240
|
+
return a(function() {
|
|
2241
|
+
return l.assign(e, t, n);
|
|
2242
|
+
});
|
|
2243
|
+
}, s && (u.inputs = s), u.ast = n, u.literal = R(n), u.constant = z(n), u;
|
|
2244
|
+
},
|
|
2245
|
+
recurse: function(e, t, n) {
|
|
2246
|
+
var r, i, a = this, o;
|
|
2247
|
+
if (e.input) return this.inputs(e.input, e.watchId);
|
|
2248
|
+
switch (e.type) {
|
|
2249
|
+
case N.Literal: return this.value(e.value, t);
|
|
2250
|
+
case N.UnaryExpression: return i = this.recurse(e.argument), this["unary" + e.operator](i, t);
|
|
2251
|
+
case N.BinaryExpression: return r = this.recurse(e.left), i = this.recurse(e.right), this["binary" + e.operator](r, i, t);
|
|
2252
|
+
case N.LogicalExpression: return r = this.recurse(e.left), i = this.recurse(e.right), this["binary" + e.operator](r, i, t);
|
|
2253
|
+
case N.ConditionalExpression: return this["ternary?:"](this.recurse(e.test), this.recurse(e.alternate), this.recurse(e.consequent), t);
|
|
2254
|
+
case N.Identifier: return a.identifier(e.name, t, n);
|
|
2255
|
+
case N.MemberExpression: return r = this.recurse(e.object, !1, !!n), e.computed || (i = e.property.name), e.computed && (i = this.recurse(e.property)), e.computed ? this.computedMember(r, i, t, n) : this.nonComputedMember(r, i, t, n);
|
|
2256
|
+
case N.CallExpression: return o = [], d(e.arguments, function(e) {
|
|
2257
|
+
o.push(a.recurse(e));
|
|
2258
|
+
}), e.filter && (i = this.$filter(e.callee.name)), e.filter || (i = this.recurse(e.callee, !0)), e.filter ? function(e, n, r, a) {
|
|
2259
|
+
for (var s = [], c = 0; c < o.length; ++c) s.push(o[c](e, n, r, a));
|
|
2260
|
+
var l = i.apply(void 0, s, a);
|
|
2261
|
+
return t ? {
|
|
2262
|
+
context: void 0,
|
|
2263
|
+
name: void 0,
|
|
2264
|
+
value: l
|
|
2265
|
+
} : l;
|
|
2266
|
+
} : function(e, n, r, a) {
|
|
2267
|
+
var s = i(e, n, r, a), c;
|
|
2268
|
+
if (s.value != null) {
|
|
2269
|
+
for (var l = [], u = 0; u < o.length; ++u) l.push(o[u](e, n, r, a));
|
|
2270
|
+
c = s.value.apply(s.context, l);
|
|
2271
|
+
}
|
|
2272
|
+
return t ? { value: c } : c;
|
|
2273
|
+
};
|
|
2274
|
+
case N.AssignmentExpression: return r = this.recurse(e.left, !0, 1), i = this.recurse(e.right), function(e, n, a, o) {
|
|
2275
|
+
var s = r(e, !1, a, o), c = i(e, n, a, o);
|
|
2276
|
+
return s.context[s.name] = c, t ? { value: c } : c;
|
|
2277
|
+
};
|
|
2278
|
+
case N.ArrayExpression: return o = [], d(e.elements, function(e) {
|
|
2279
|
+
o.push(a.recurse(e));
|
|
2280
|
+
}), function(e, n, r, i) {
|
|
2281
|
+
for (var a = [], s = 0; s < o.length; ++s) a.push(o[s](e, n, r, i));
|
|
2282
|
+
return t ? { value: a } : a;
|
|
2283
|
+
};
|
|
2284
|
+
case N.ObjectExpression: return o = [], d(e.properties, function(e) {
|
|
2285
|
+
e.computed ? o.push({
|
|
2286
|
+
key: a.recurse(e.key),
|
|
2287
|
+
computed: !0,
|
|
2288
|
+
value: a.recurse(e.value)
|
|
2289
|
+
}) : o.push({
|
|
2290
|
+
key: e.key.type === N.Identifier ? e.key.name : "" + e.key.value,
|
|
2291
|
+
computed: !1,
|
|
2292
|
+
value: a.recurse(e.value)
|
|
2293
|
+
});
|
|
2294
|
+
}), function(e, n, r, i) {
|
|
2295
|
+
for (var a = {}, s = 0; s < o.length; ++s) o[s].computed ? a[o[s].key(e, n, r, i)] = o[s].value(e, n, r, i) : a[o[s].key] = o[s].value(e, n, r, i);
|
|
2296
|
+
return t ? { value: a } : a;
|
|
2297
|
+
};
|
|
2298
|
+
case N.ThisExpression: return function(e) {
|
|
2299
|
+
return t ? { value: e } : e;
|
|
2300
|
+
};
|
|
2301
|
+
case N.LocalsExpression: return function(e, n) {
|
|
2302
|
+
return t ? { value: n } : n;
|
|
2303
|
+
};
|
|
2304
|
+
case N.NGValueParameter: return function(e, n, r) {
|
|
2305
|
+
return t ? { value: r } : r;
|
|
2306
|
+
};
|
|
2307
|
+
}
|
|
2308
|
+
},
|
|
2309
|
+
"unary+": function(e, t) {
|
|
2310
|
+
return function(n, r, i, a) {
|
|
2311
|
+
var o = e(n, r, i, a);
|
|
2312
|
+
return o = h(o) ? +o : 0, t ? { value: o } : o;
|
|
2313
|
+
};
|
|
2314
|
+
},
|
|
2315
|
+
"unary-": function(e, t) {
|
|
2316
|
+
return function(n, r, i, a) {
|
|
2317
|
+
var o = e(n, r, i, a);
|
|
2318
|
+
return o = h(o) ? -o : -0, t ? { value: o } : o;
|
|
2319
|
+
};
|
|
2320
|
+
},
|
|
2321
|
+
"unary!": function(e, t) {
|
|
2322
|
+
return function(n, r, i, a) {
|
|
2323
|
+
var o = !e(n, r, i, a);
|
|
2324
|
+
return t ? { value: o } : o;
|
|
2325
|
+
};
|
|
2326
|
+
},
|
|
2327
|
+
"binary+": function(e, t, n) {
|
|
2328
|
+
return function(r, i, a, o) {
|
|
2329
|
+
var s = P(e(r, i, a, o), t(r, i, a, o));
|
|
2330
|
+
return n ? { value: s } : s;
|
|
2331
|
+
};
|
|
2332
|
+
},
|
|
2333
|
+
"binary-": function(e, t, n) {
|
|
2334
|
+
return function(r, i, a, o) {
|
|
2335
|
+
var s = e(r, i, a, o), c = t(r, i, a, o), l = (h(s) ? s : 0) - (h(c) ? c : 0);
|
|
2336
|
+
return n ? { value: l } : l;
|
|
2337
|
+
};
|
|
2338
|
+
},
|
|
2339
|
+
"binary*": function(e, t, n) {
|
|
2340
|
+
return function(r, i, a, o) {
|
|
2341
|
+
var s = e(r, i, a, o) * t(r, i, a, o);
|
|
2342
|
+
return n ? { value: s } : s;
|
|
2343
|
+
};
|
|
2344
|
+
},
|
|
2345
|
+
"binary/": function(e, t, n) {
|
|
2346
|
+
return function(r, i, a, o) {
|
|
2347
|
+
var s = e(r, i, a, o) / t(r, i, a, o);
|
|
2348
|
+
return n ? { value: s } : s;
|
|
2349
|
+
};
|
|
2350
|
+
},
|
|
2351
|
+
"binary%": function(e, t, n) {
|
|
2352
|
+
return function(r, i, a, o) {
|
|
2353
|
+
var s = e(r, i, a, o) % t(r, i, a, o);
|
|
2354
|
+
return n ? { value: s } : s;
|
|
2355
|
+
};
|
|
2356
|
+
},
|
|
2357
|
+
"binary===": function(e, t, n) {
|
|
2358
|
+
return function(r, i, a, o) {
|
|
2359
|
+
var s = e(r, i, a, o) === t(r, i, a, o);
|
|
2360
|
+
return n ? { value: s } : s;
|
|
2361
|
+
};
|
|
2362
|
+
},
|
|
2363
|
+
"binary!==": function(e, t, n) {
|
|
2364
|
+
return function(r, i, a, o) {
|
|
2365
|
+
var s = e(r, i, a, o) !== t(r, i, a, o);
|
|
2366
|
+
return n ? { value: s } : s;
|
|
2367
|
+
};
|
|
2368
|
+
},
|
|
2369
|
+
"binary==": function(e, t, n) {
|
|
2370
|
+
return function(r, i, a, o) {
|
|
2371
|
+
var s = e(r, i, a, o) == t(r, i, a, o);
|
|
2372
|
+
return n ? { value: s } : s;
|
|
2373
|
+
};
|
|
2374
|
+
},
|
|
2375
|
+
"binary!=": function(e, t, n) {
|
|
2376
|
+
return function(r, i, a, o) {
|
|
2377
|
+
var s = e(r, i, a, o) != t(r, i, a, o);
|
|
2378
|
+
return n ? { value: s } : s;
|
|
2379
|
+
};
|
|
2380
|
+
},
|
|
2381
|
+
"binary<": function(e, t, n) {
|
|
2382
|
+
return function(r, i, a, o) {
|
|
2383
|
+
var s = e(r, i, a, o) < t(r, i, a, o);
|
|
2384
|
+
return n ? { value: s } : s;
|
|
2385
|
+
};
|
|
2386
|
+
},
|
|
2387
|
+
"binary>": function(e, t, n) {
|
|
2388
|
+
return function(r, i, a, o) {
|
|
2389
|
+
var s = e(r, i, a, o) > t(r, i, a, o);
|
|
2390
|
+
return n ? { value: s } : s;
|
|
2391
|
+
};
|
|
2392
|
+
},
|
|
2393
|
+
"binary<=": function(e, t, n) {
|
|
2394
|
+
return function(r, i, a, o) {
|
|
2395
|
+
var s = e(r, i, a, o) <= t(r, i, a, o);
|
|
2396
|
+
return n ? { value: s } : s;
|
|
2397
|
+
};
|
|
2398
|
+
},
|
|
2399
|
+
"binary>=": function(e, t, n) {
|
|
2400
|
+
return function(r, i, a, o) {
|
|
2401
|
+
var s = e(r, i, a, o) >= t(r, i, a, o);
|
|
2402
|
+
return n ? { value: s } : s;
|
|
2403
|
+
};
|
|
2404
|
+
},
|
|
2405
|
+
"binary&&": function(e, t, n) {
|
|
2406
|
+
return function(r, i, a, o) {
|
|
2407
|
+
var s = e(r, i, a, o) && t(r, i, a, o);
|
|
2408
|
+
return n ? { value: s } : s;
|
|
2409
|
+
};
|
|
2410
|
+
},
|
|
2411
|
+
"binary||": function(e, t, n) {
|
|
2412
|
+
return function(r, i, a, o) {
|
|
2413
|
+
var s = e(r, i, a, o) || t(r, i, a, o);
|
|
2414
|
+
return n ? { value: s } : s;
|
|
2415
|
+
};
|
|
2416
|
+
},
|
|
2417
|
+
"binary??": function(e, t, n) {
|
|
2418
|
+
return function(r, i, a, o) {
|
|
2419
|
+
var s = e(r, i, a, o), c = s != null && s !== void 0 ? s : t(r, i, a, o);
|
|
2420
|
+
return n ? { value: c } : c;
|
|
2421
|
+
};
|
|
2422
|
+
},
|
|
2423
|
+
"ternary?:": function(e, t, n, r) {
|
|
2424
|
+
return function(i, a, o, s) {
|
|
2425
|
+
var c = e(i, a, o, s) ? t(i, a, o, s) : n(i, a, o, s);
|
|
2426
|
+
return r ? { value: c } : c;
|
|
2427
|
+
};
|
|
2428
|
+
},
|
|
2429
|
+
value: function(e, t) {
|
|
2430
|
+
return function() {
|
|
2431
|
+
return t ? {
|
|
2432
|
+
context: void 0,
|
|
2433
|
+
name: void 0,
|
|
2434
|
+
value: e
|
|
2435
|
+
} : e;
|
|
2436
|
+
};
|
|
2437
|
+
},
|
|
2438
|
+
identifier: function(e, t, r) {
|
|
2439
|
+
return function(i, a) {
|
|
2440
|
+
var o = a && e in a ? a : i;
|
|
2441
|
+
r && r !== 1 && o && o[e] == null && (o[e] = {});
|
|
2442
|
+
var s;
|
|
2443
|
+
return o && n.call(o, e) && (s = o ? o[e] : void 0), t ? {
|
|
2444
|
+
context: o,
|
|
2445
|
+
name: e,
|
|
2446
|
+
value: s
|
|
2447
|
+
} : s;
|
|
2448
|
+
};
|
|
2449
|
+
},
|
|
2450
|
+
computedMember: function(e, t, n, r) {
|
|
2451
|
+
return function(i, a, o, s) {
|
|
2452
|
+
var c = e(i, a, o, s), l, u;
|
|
2453
|
+
return c != null && (l = t(i, a, o, s), l = A(l), r && r !== 1 && c && !c[l] && (c[l] = {}), Object.prototype.hasOwnProperty.call(c, l) && (u = c[l])), n ? {
|
|
2454
|
+
context: c,
|
|
2455
|
+
name: l,
|
|
2456
|
+
value: u
|
|
2457
|
+
} : u;
|
|
2458
|
+
};
|
|
2459
|
+
},
|
|
2460
|
+
nonComputedMember: function(e, t, n, r) {
|
|
2461
|
+
return function(i, a, o, s) {
|
|
2462
|
+
var c = e(i, a, o, s);
|
|
2463
|
+
r && r !== 1 && c && c[t] == null && (c[t] = {});
|
|
2464
|
+
var l = void 0;
|
|
2465
|
+
return c != null && Object.prototype.hasOwnProperty.call(c, t) && (l = c[t]), n ? {
|
|
2466
|
+
context: c,
|
|
2467
|
+
name: t,
|
|
2468
|
+
value: l
|
|
2469
|
+
} : l;
|
|
2470
|
+
};
|
|
2471
|
+
},
|
|
2472
|
+
inputs: function(e, t) {
|
|
2473
|
+
return function(n, r, i, a) {
|
|
2474
|
+
return a ? a[t] : e(n, r, i);
|
|
2475
|
+
};
|
|
2476
|
+
}
|
|
2477
|
+
};
|
|
2478
|
+
/**
|
|
2479
|
+
* @constructor
|
|
2480
|
+
*/
|
|
2481
|
+
var H = function(e, t, n) {
|
|
2482
|
+
this.lexer = e, this.$filter = t, n = n || {}, n.handleThis = n.handleThis == null ? !0 : n.handleThis, this.options = n, this.ast = new N(e, n), this.ast.selfReferential = { $locals: { type: N.LocalsExpression } }, n.handleThis && (this.ast.selfReferential.this = { type: N.ThisExpression }), this.astCompiler = n.csp ? new V(this.ast, t) : new B(this.ast, t);
|
|
2483
|
+
};
|
|
2484
|
+
H.prototype = {
|
|
2485
|
+
constructor: H,
|
|
2486
|
+
parse: function(e) {
|
|
2487
|
+
return this.astCompiler.compile(e);
|
|
2488
|
+
}
|
|
2489
|
+
}, e.Lexer = M, e.Parser = H;
|
|
2490
|
+
})), _e = (/* @__PURE__ */ n(((e) => {
|
|
2491
|
+
var t = ge(), n = {}, r = t.Lexer, i = t.Parser;
|
|
2492
|
+
function a(e) {
|
|
2493
|
+
return e = e || {}, e.filters && (e.cache = e.cache || {}), e.cache = e.cache || s.cache, e.filters = e.filters || n, e;
|
|
2494
|
+
}
|
|
2495
|
+
function o(e) {
|
|
2496
|
+
return {
|
|
2497
|
+
handleThis: e.handleThis == null ? !0 : e.handleThis,
|
|
2498
|
+
csp: e.csp == null ? !1 : e.csp,
|
|
2499
|
+
literals: e.literals == null ? {
|
|
2500
|
+
true: !0,
|
|
2501
|
+
false: !1,
|
|
2502
|
+
null: null,
|
|
2503
|
+
undefined: void 0
|
|
2504
|
+
} : e.literals
|
|
2505
|
+
};
|
|
2506
|
+
}
|
|
2507
|
+
/**
|
|
2508
|
+
* Compiles src and returns a function that executes src on a target object.
|
|
2509
|
+
* To speed up further calls the compiled function is cached under compile.cache[src] if options.filters is not present.
|
|
2510
|
+
*
|
|
2511
|
+
* @param {string} src
|
|
2512
|
+
* @param {object | undefined} options
|
|
2513
|
+
* @returns {function}
|
|
2514
|
+
*/
|
|
2515
|
+
function s(e, t) {
|
|
2516
|
+
if (typeof e != "string") throw TypeError("src must be a string, instead saw '" + typeof e + "'");
|
|
2517
|
+
t = a(t);
|
|
2518
|
+
var n = t, s = o(t), c = new i(new r(n), function(e) {
|
|
2519
|
+
return t.filters[e];
|
|
2520
|
+
}, s);
|
|
2521
|
+
if (!t.cache) return c.parse(e);
|
|
2522
|
+
delete t.src;
|
|
2523
|
+
var l = JSON.stringify(Object.assign({ src: e }, t)), u = t.cache[l];
|
|
2524
|
+
return u || (u = t.cache[l] = c.parse(e)), u;
|
|
2525
|
+
}
|
|
2526
|
+
s.cache = Object.create(null), e.compile = s;
|
|
2527
|
+
})))();
|
|
2528
|
+
/** Cleans deeds the way puzzmo.com's PlayGameIframe and the API's `getDeedsFromCompletion` do, collecting what was dropped. */
|
|
2529
|
+
const ve = (e, t) => {
|
|
2530
|
+
let n = [];
|
|
2531
|
+
e !== void 0 && !Array.isArray(e) && n.push("deeds is not an array, the host ignores it");
|
|
2532
|
+
let r = [];
|
|
2533
|
+
for (let [i, a] of (Array.isArray(e) ? e : []).entries()) {
|
|
2534
|
+
if (a == null || typeof a.id != "string") {
|
|
2535
|
+
n.push(`deed ${i} has no string id, the host drops it`);
|
|
2536
|
+
continue;
|
|
2537
|
+
}
|
|
2538
|
+
if (t === "checkpoint") {
|
|
2539
|
+
r.push({
|
|
2540
|
+
id: a.id,
|
|
2541
|
+
value: a.value
|
|
2542
|
+
});
|
|
2543
|
+
continue;
|
|
2544
|
+
}
|
|
2545
|
+
a.value === void 0 || a.value === null || r.push({
|
|
2546
|
+
id: a.id,
|
|
2547
|
+
value: typeof a.value == "number" ? Math.floor(a.value) : a.value,
|
|
2548
|
+
persist: a.persist === !0
|
|
2549
|
+
});
|
|
2550
|
+
}
|
|
2551
|
+
if (t === "checkpoint") return {
|
|
2552
|
+
deeds: r,
|
|
2553
|
+
warnings: n
|
|
2554
|
+
};
|
|
2555
|
+
let i = r.filter((e) => e.persist), a = r.filter((e) => !e.persist), o = i.splice(3);
|
|
2556
|
+
return o.length && n.push(`only 3 persisted deeds are kept, dropped: ${o.map((e) => e.id).join(", ")}`), {
|
|
2557
|
+
deeds: [...i, ...a].map(({ id: e, value: t }) => ({
|
|
2558
|
+
id: e,
|
|
2559
|
+
value: t
|
|
2560
|
+
})),
|
|
2561
|
+
warnings: n
|
|
2562
|
+
};
|
|
2563
|
+
}, ye = (e) => {
|
|
2564
|
+
let t = {};
|
|
2565
|
+
for (let n of e) n.value !== void 0 && (t[Se(n.id)] = n.value);
|
|
1034
2566
|
return t;
|
|
1035
|
-
},
|
|
2567
|
+
}, be = (e, t) => {
|
|
1036
2568
|
try {
|
|
1037
|
-
if (e.filterExp && !
|
|
2569
|
+
if (e.filterExp && !(0, _e.compile)(e.filterExp)(t) || !e.incrementExp) return {
|
|
1038
2570
|
complete: !1,
|
|
1039
2571
|
value: 0
|
|
1040
2572
|
};
|
|
1041
|
-
let n =
|
|
2573
|
+
let n = (0, _e.compile)(e.incrementExp)(t);
|
|
1042
2574
|
if (typeof n == "boolean" && (n = n ? 1 : 0), n === void 0 && (n = 0), typeof n != "number" || isNaN(n)) throw Error(`incrementExp must return a number, undefined or boolean, got ${n}`);
|
|
1043
2575
|
let r = Math.floor(n);
|
|
1044
2576
|
return {
|
|
@@ -1052,48 +2584,32 @@ const ve = (e) => {
|
|
|
1052
2584
|
error: e.message
|
|
1053
2585
|
};
|
|
1054
2586
|
}
|
|
1055
|
-
},
|
|
2587
|
+
}, xe = (e) => {
|
|
1056
2588
|
let { items: t, scope: n, mode: r } = e, i = Math.min(Math.max(e.index, 0), t.length), a;
|
|
1057
|
-
for (; i < t.length && (a =
|
|
2589
|
+
for (; i < t.length && (a = be(t[i], n), !(!a.complete || r === "checkpoint" && !t[i].liveUpdate)); i++);
|
|
1058
2590
|
return {
|
|
1059
2591
|
index: i,
|
|
1060
2592
|
head: i < t.length ? a : void 0
|
|
1061
2593
|
};
|
|
1062
2594
|
};
|
|
1063
|
-
|
|
1064
|
-
var xe = (e, t) => {
|
|
1065
|
-
let n = Object.keys(t).filter(Se);
|
|
1066
|
-
try {
|
|
1067
|
-
return Function(...n, `"use strict"; return (${e})`)(...n.map((e) => t[e]));
|
|
1068
|
-
} catch (e) {
|
|
1069
|
-
if (e instanceof ReferenceError) return;
|
|
1070
|
-
throw e;
|
|
1071
|
-
}
|
|
1072
|
-
}, Se = (e) => {
|
|
1073
|
-
if (!/^[A-Za-z_$][\w$]*$/.test(e)) return !1;
|
|
1074
|
-
try {
|
|
1075
|
-
return Function(e, "\"use strict\""), !0;
|
|
1076
|
-
} catch (e) {
|
|
1077
|
-
return !1;
|
|
1078
|
-
}
|
|
1079
|
-
}, Ce = (e) => e.replace(/-./g, (e) => e[1].toUpperCase());
|
|
2595
|
+
var Se = (e) => e.replace(/-./g, (e) => e[1].toUpperCase());
|
|
1080
2596
|
/** A minimal take on puzzmo.com's tutorial checklist, driven by deeds from checkpoints and completion. */
|
|
1081
|
-
function
|
|
1082
|
-
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = null, i = 0, a, o = (e) => {
|
|
2597
|
+
function Ce(e) {
|
|
2598
|
+
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = null, i = 0, a, o = [], s = (e) => {
|
|
1083
2599
|
var t;
|
|
1084
2600
|
return `simulator-checklist:${(t = r) == null ? "game" : t}:${e}`;
|
|
1085
|
-
},
|
|
2601
|
+
}, c = (e) => {
|
|
1086
2602
|
try {
|
|
1087
|
-
let t = Number(localStorage.getItem(
|
|
2603
|
+
let t = Number(localStorage.getItem(s(e.stableID))) || 0;
|
|
1088
2604
|
return Math.min(Math.max(t, 0), e.items.length);
|
|
1089
2605
|
} catch (e) {
|
|
1090
2606
|
return 0;
|
|
1091
2607
|
}
|
|
1092
|
-
},
|
|
2608
|
+
}, l = (e, t) => {
|
|
1093
2609
|
try {
|
|
1094
|
-
t === 0 ? localStorage.removeItem(
|
|
2610
|
+
t === 0 ? localStorage.removeItem(s(e)) : localStorage.setItem(s(e), String(t));
|
|
1095
2611
|
} catch (e) {}
|
|
1096
|
-
},
|
|
2612
|
+
}, u = (e, t, r, i) => {
|
|
1097
2613
|
var a;
|
|
1098
2614
|
let o = r < i.index ? "done" : r === i.index ? "active" : "upcoming", s = `${e.stableID}:${r}`, c = n.has(s), l = !!t.expandMD && o !== "done", u = t.targetCount || 1, d = o === "active" && i.head ? `${Math.min(i.head.value, u)}/${u}` : "", f = [
|
|
1099
2615
|
t.incrementExp && `increment: ${t.incrementExp}`,
|
|
@@ -1102,67 +2618,68 @@ function we(e) {
|
|
|
1102
2618
|
t.liveUpdate ? "liveUpdate: checkpoints + completion" : "completion only"
|
|
1103
2619
|
].filter(Boolean).join("\n");
|
|
1104
2620
|
return `${e.instructionsVisibleFromItemIndex === r && r > 0 ? "<div class=\"checklist-divider\"><span>full instructions unlock</span></div>" : ""}
|
|
1105
|
-
<div class="checklist-item ${o}" title="${
|
|
2621
|
+
<div class="checklist-item ${o}" title="${K(f)}">
|
|
1106
2622
|
<div class="checklist-row">
|
|
1107
2623
|
<span class="checklist-tick">${o === "done" ? "■" : "□"}</span>
|
|
1108
|
-
<span class="checklist-title">${
|
|
2624
|
+
<span class="checklist-title">${K((a = t.title) == null ? `Step ${r + 1}` : a)}</span>
|
|
1109
2625
|
${d ? `<span class="checklist-count">${d}</span>` : ""}
|
|
1110
|
-
${l ? `<button class="checklist-help${c ? " open" : ""}" data-help="${
|
|
2626
|
+
${l ? `<button class="checklist-help${c ? " open" : ""}" data-help="${K(s)}">?</button>` : ""}
|
|
1111
2627
|
</div>
|
|
1112
|
-
${o === "active" && t.subtitle ? `<div class="checklist-subtitle">${
|
|
1113
|
-
${l && c ? `<pre class="checklist-expand">${
|
|
2628
|
+
${o === "active" && t.subtitle ? `<div class="checklist-subtitle">${K(t.subtitle)}</div>` : ""}
|
|
2629
|
+
${l && c ? `<pre class="checklist-expand">${K(t.expandMD)}</pre>` : ""}
|
|
1114
2630
|
</div>`;
|
|
1115
|
-
},
|
|
1116
|
-
var n, r, i,
|
|
1117
|
-
let
|
|
2631
|
+
}, d = (e) => {
|
|
2632
|
+
var n, r, i, s;
|
|
2633
|
+
let c = (n = t.get(e.stableID)) == null ? { index: 0 } : n, l = e.items.length, d = c.index, f = ((r = c.head) == null ? void 0 : r.error) && `${(i = (s = e.items[c.index]) == null ? void 0 : s.title) == null ? `Step ${c.index + 1}` : i}: ${c.head.error}`;
|
|
1118
2634
|
return `
|
|
1119
2635
|
<div class="checklist-section">
|
|
1120
2636
|
<div class="checklist-header">
|
|
1121
2637
|
<span class="simulator-label">Checklist</span>
|
|
1122
|
-
<span class="checklist-progress${
|
|
1123
|
-
<button class="simulator-btn subtle small" data-reset="${
|
|
2638
|
+
<span class="checklist-progress${d === l ? " complete" : ""}">${d}/${l}</span>
|
|
2639
|
+
<button class="simulator-btn subtle small" data-reset="${K(e.stableID)}">Reset</button>
|
|
1124
2640
|
</div>
|
|
1125
2641
|
<div class="checklist-items">
|
|
1126
|
-
${e.items.map((t, n) =>
|
|
2642
|
+
${e.items.map((t, n) => u(e, t, n, c)).join("")}
|
|
1127
2643
|
</div>
|
|
1128
|
-
${a ? `<div class="checklist-footer">last eval: ${
|
|
1129
|
-
${
|
|
2644
|
+
${a ? `<div class="checklist-footer">last eval: ${K(a)}</div>` : ""}
|
|
2645
|
+
${f ? `<div class="checklist-error">${K(f)}</div>` : ""}
|
|
2646
|
+
${o.map((e) => `<div class="checklist-error">${K(e)}</div>`).join("")}
|
|
1130
2647
|
</div>`;
|
|
1131
|
-
},
|
|
2648
|
+
}, f = () => e.length === 0 ? "<div class=\"simulator-empty\">No checklists in puzzmo.json → integrations.checklists\n<pre class=\"checklist-expand\">\"checklists\": [{\n \"stableID\": \"my-game:tutorial\",\n \"type\": \"tutorial\",\n \"items\": [{ \"title\": \"Make a move\", \"incrementExp\": \"moves\", \"liveUpdate\": true }]\n}]</pre></div>" : e.map(d).join(""), p = (e) => {
|
|
1132
2649
|
let t = e.getElement("#simulator-checklist-list");
|
|
1133
|
-
t && (t.innerHTML =
|
|
1134
|
-
},
|
|
1135
|
-
let
|
|
1136
|
-
a =
|
|
2650
|
+
t && (t.innerHTML = f());
|
|
2651
|
+
}, m = (n, r, s, c) => {
|
|
2652
|
+
let u = 0, d = ve(r, s), f = ye(d.deeds);
|
|
2653
|
+
a = c, o = d.warnings;
|
|
1137
2654
|
for (let n of e) {
|
|
1138
|
-
var
|
|
1139
|
-
let e = (
|
|
2655
|
+
var m, h;
|
|
2656
|
+
let e = (m = (h = t.get(n.stableID)) == null ? void 0 : h.index) == null ? 0 : m, r = xe({
|
|
1140
2657
|
items: n.items,
|
|
1141
2658
|
index: e,
|
|
1142
|
-
scope:
|
|
1143
|
-
mode:
|
|
2659
|
+
scope: f,
|
|
2660
|
+
mode: s
|
|
1144
2661
|
});
|
|
1145
|
-
|
|
2662
|
+
u += r.index - e, t.set(n.stableID, r), r.index !== e && l(n.stableID, r.index);
|
|
1146
2663
|
}
|
|
1147
|
-
|
|
2664
|
+
u > 0 && (i += u, n.updateBadge("checklist", i)), p(n);
|
|
1148
2665
|
};
|
|
1149
2666
|
return {
|
|
1150
2667
|
id: "checklist",
|
|
1151
2668
|
label: "Cklst",
|
|
1152
2669
|
render() {
|
|
1153
|
-
return `<div id="simulator-checklist-list" class="checklist-view-container">${
|
|
1154
|
-
},
|
|
1155
|
-
bind(
|
|
1156
|
-
var
|
|
1157
|
-
r =
|
|
1158
|
-
for (let n of e) t.set(n.stableID, { index:
|
|
1159
|
-
|
|
1160
|
-
var r,
|
|
1161
|
-
let
|
|
1162
|
-
if (
|
|
1163
|
-
else if (
|
|
2670
|
+
return `<div id="simulator-checklist-list" class="checklist-view-container">${f()}</div>`;
|
|
2671
|
+
},
|
|
2672
|
+
bind(s) {
|
|
2673
|
+
var u;
|
|
2674
|
+
r = s.gameSlug;
|
|
2675
|
+
for (let n of e) t.set(n.stableID, { index: c(n) });
|
|
2676
|
+
p(s), (u = s.getElement("#simulator-checklist-list")) == null || u.addEventListener("click", (e) => {
|
|
2677
|
+
var r, c;
|
|
2678
|
+
let u = e.target, d = (r = u.closest("[data-reset]")) == null ? void 0 : r.dataset.reset, f = (c = u.closest("[data-help]")) == null ? void 0 : c.dataset.help;
|
|
2679
|
+
if (d) t.set(d, { index: 0 }), l(d, 0), a = void 0, o = [], i = 0, s.updateBadge("checklist", 0);
|
|
2680
|
+
else if (f) n.has(f) ? n.delete(f) : n.add(f);
|
|
1164
2681
|
else return;
|
|
1165
|
-
|
|
2682
|
+
p(s);
|
|
1166
2683
|
});
|
|
1167
2684
|
},
|
|
1168
2685
|
onActivate() {
|
|
@@ -1170,13 +2687,13 @@ function we(e) {
|
|
|
1170
2687
|
},
|
|
1171
2688
|
onMessage(e, t, n) {
|
|
1172
2689
|
var r, i, a;
|
|
1173
|
-
e === "HIT_CHECKPOINT" ?
|
|
2690
|
+
e === "HIT_CHECKPOINT" ? m(n, t == null || (r = t.augConfig) == null ? void 0 : r.deeds, "checkpoint", `checkpoint "${(i = t == null ? void 0 : t.checkpointName) == null ? "?" : i}"`) : e === "GAME_COMPLETED" && m(n, t == null || (a = t.config) == null ? void 0 : a.deeds, "completion", "completion");
|
|
1174
2691
|
}
|
|
1175
2692
|
};
|
|
1176
2693
|
}
|
|
1177
|
-
var
|
|
2694
|
+
var K = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
1178
2695
|
/** Find thumbnail function on globalThis (looks for functions ending in "Thumbnail") */
|
|
1179
|
-
function
|
|
2696
|
+
function we() {
|
|
1180
2697
|
let e = globalThis;
|
|
1181
2698
|
for (let t of Object.keys(e)) if (t.endsWith("Thumbnail") && typeof e[t] == "function") return {
|
|
1182
2699
|
name: t,
|
|
@@ -1185,23 +2702,23 @@ function Te() {
|
|
|
1185
2702
|
return null;
|
|
1186
2703
|
}
|
|
1187
2704
|
/** The bundle's `getShareString` (if any), exposed to the sim via vite.ts's bundle loader. */
|
|
1188
|
-
function
|
|
2705
|
+
function Te() {
|
|
1189
2706
|
let e = globalThis.getShareString;
|
|
1190
2707
|
return typeof e == "function" ? e : null;
|
|
1191
2708
|
}
|
|
1192
|
-
function
|
|
2709
|
+
function Ee(e) {
|
|
1193
2710
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1194
2711
|
}
|
|
1195
|
-
function
|
|
2712
|
+
function De() {
|
|
1196
2713
|
let e = /* @__PURE__ */ new Date();
|
|
1197
2714
|
return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
|
|
1198
2715
|
}
|
|
1199
|
-
function
|
|
2716
|
+
function Oe(e) {
|
|
1200
2717
|
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
1201
2718
|
}
|
|
1202
2719
|
/** Shown when Preview Kind = Text but the bundle doesn't export `getShareString`. */
|
|
1203
|
-
var
|
|
1204
|
-
function
|
|
2720
|
+
var ke = "\n <div class=\"simulator-share-missing\">\n <p>The app bundle doesn't export <code>getShareString</code>.</p>\n <p>Add it to your app bundle to preview share strings here:</p>\n <pre>export const getShareString: AppBundle[\"getShareString\"] = (\n inputStr, title, { puzzleString, dateKey, gameplaySlug },\n) => ({ str: `${title}: ...` })</pre>\n </div>\n";
|
|
2721
|
+
function Ae() {
|
|
1205
2722
|
return {
|
|
1206
2723
|
id: "thumb",
|
|
1207
2724
|
label: "Thumb",
|
|
@@ -1223,12 +2740,12 @@ function je() {
|
|
|
1223
2740
|
o == null || o.querySelectorAll(".simulator-segmented-btn").forEach((t) => {
|
|
1224
2741
|
t.addEventListener("click", () => {
|
|
1225
2742
|
let n = t.dataset.previewKind;
|
|
1226
|
-
!n || n === e.state.previewKind || (e.state.previewKind = n,
|
|
2743
|
+
!n || n === e.state.previewKind || (e.state.previewKind = n, A(n), c(), s(), e.updateThumbnail());
|
|
1227
2744
|
});
|
|
1228
|
-
}), n && (e.state.renderHost || (e.state.renderHost = "game",
|
|
1229
|
-
e.state.renderHost = n.value,
|
|
1230
|
-
})), r && (e.state.renderContext || (e.state.renderContext = "preview",
|
|
1231
|
-
e.state.renderContext = r.value,
|
|
2745
|
+
}), n && (e.state.renderHost || (e.state.renderHost = "game", k(e.state.renderHost)), n.value = e.state.renderHost || "game", n.addEventListener("change", () => {
|
|
2746
|
+
e.state.renderHost = n.value, k(e.state.renderHost), s(), e.updateThumbnail();
|
|
2747
|
+
})), r && (e.state.renderContext || (e.state.renderContext = "preview", j(e.state.renderContext)), r.value = e.state.renderContext || "preview", r.addEventListener("change", () => {
|
|
2748
|
+
e.state.renderContext = r.value, j(e.state.renderContext), e.updateThumbnail();
|
|
1232
2749
|
})), c(), s();
|
|
1233
2750
|
},
|
|
1234
2751
|
onActivate(e) {
|
|
@@ -1237,26 +2754,26 @@ function je() {
|
|
|
1237
2754
|
updatePreview: (e) => {
|
|
1238
2755
|
let t = e.getElement("#simulator-thumb-preview"), n = e.getElement("#simulator-thumb-fn");
|
|
1239
2756
|
if (t == null || t.style.setProperty("--sim-thumb-bg", e.state.selectedTheme.g_bg), e.state.previewKind === "text") {
|
|
1240
|
-
let s =
|
|
2757
|
+
let s = Te();
|
|
1241
2758
|
if (!s) {
|
|
1242
|
-
t && (t.innerHTML =
|
|
2759
|
+
t && (t.innerHTML = ke), n && (n.textContent = "");
|
|
1243
2760
|
return;
|
|
1244
2761
|
}
|
|
1245
2762
|
n && (n.textContent = "Using: getShareString()");
|
|
1246
2763
|
try {
|
|
1247
2764
|
var r, i, a, o;
|
|
1248
|
-
let n = (r = e.gameSlug) == null ? "game" : r, c = s((i = e.state.currentInputStr) == null ? "" : i,
|
|
2765
|
+
let n = (r = e.gameSlug) == null ? "game" : r, c = s((i = e.state.currentInputStr) == null ? "" : i, Oe(n), {
|
|
1249
2766
|
puzzleString: (a = e.state.puzzleData) == null ? "" : a,
|
|
1250
|
-
dateKey:
|
|
2767
|
+
dateKey: De(),
|
|
1251
2768
|
gameplaySlug: `simulator:${n}`
|
|
1252
2769
|
}), l = (o = c == null ? void 0 : c.str) == null ? "" : o;
|
|
1253
|
-
t && (t.innerHTML = `<pre class="simulator-share-preview" style="color: ${e.state.selectedTheme.fg}">${
|
|
2770
|
+
t && (t.innerHTML = `<pre class="simulator-share-preview" style="color: ${e.state.selectedTheme.fg}">${Ee(l)}</pre>`);
|
|
1254
2771
|
} catch (e) {
|
|
1255
2772
|
console.error("Simulator: Share string error", e), t && (t.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
|
|
1256
2773
|
}
|
|
1257
2774
|
return;
|
|
1258
2775
|
}
|
|
1259
|
-
let s =
|
|
2776
|
+
let s = we();
|
|
1260
2777
|
if (!s) {
|
|
1261
2778
|
t && (t.innerHTML = "<span class=\"simulator-empty\">No thumbnail function found</span>"), n && (n.textContent = "");
|
|
1262
2779
|
return;
|
|
@@ -1270,7 +2787,7 @@ function je() {
|
|
|
1270
2787
|
strict: !0,
|
|
1271
2788
|
renderHost: e.state.renderHost,
|
|
1272
2789
|
renderContext: e.state.renderContext
|
|
1273
|
-
}, { svg: i } =
|
|
2790
|
+
}, { svg: i } = L(s.fn(n, e.state.currentInputStr, r));
|
|
1274
2791
|
t && (t.innerHTML = i);
|
|
1275
2792
|
} catch (e) {
|
|
1276
2793
|
console.error("Simulator: Thumbnail error", e), t && (t.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
|
|
@@ -1279,7 +2796,7 @@ function je() {
|
|
|
1279
2796
|
};
|
|
1280
2797
|
}
|
|
1281
2798
|
/** Generate theme preview HTML showing key colors */
|
|
1282
|
-
function
|
|
2799
|
+
function je(e) {
|
|
1283
2800
|
let t = [
|
|
1284
2801
|
e.key,
|
|
1285
2802
|
e.subBrand,
|
|
@@ -1290,7 +2807,7 @@ function Me(e) {
|
|
|
1290
2807
|
].map((e) => `<div class="simulator-theme-preview-cell" style="background: ${e}"></div>`).join("");
|
|
1291
2808
|
return `<div class="simulator-theme-preview" style="background: ${e.g_bg}">${t}</div>`;
|
|
1292
2809
|
}
|
|
1293
|
-
function
|
|
2810
|
+
function Me() {
|
|
1294
2811
|
return {
|
|
1295
2812
|
id: "theme",
|
|
1296
2813
|
label: "Theme",
|
|
@@ -1299,20 +2816,20 @@ function Ne() {
|
|
|
1299
2816
|
},
|
|
1300
2817
|
bind(e) {
|
|
1301
2818
|
let t = e.getElement("#simulator-themes");
|
|
1302
|
-
t &&
|
|
2819
|
+
t && r.forEach((n) => {
|
|
1303
2820
|
let r = document.createElement("div");
|
|
1304
2821
|
r.className = `simulator-theme-item${n.name === e.state.selectedTheme.name ? " selected" : ""}`, r.innerHTML = `
|
|
1305
|
-
${
|
|
2822
|
+
${je(n)}
|
|
1306
2823
|
<div class="simulator-theme-name">${n.name}</div>
|
|
1307
2824
|
<div class="simulator-theme-type">${n.type}</div>
|
|
1308
2825
|
`, r.addEventListener("click", () => {
|
|
1309
|
-
console.log("Simulator: Theme changed, reloading...", n.name),
|
|
2826
|
+
console.log("Simulator: Theme changed, reloading...", n.name), T(n.name), window.location.reload();
|
|
1310
2827
|
}), t.appendChild(r);
|
|
1311
2828
|
});
|
|
1312
2829
|
}
|
|
1313
2830
|
};
|
|
1314
2831
|
}
|
|
1315
|
-
var
|
|
2832
|
+
var Ne = [
|
|
1316
2833
|
{
|
|
1317
2834
|
name: "app (desktop)",
|
|
1318
2835
|
context: [{
|
|
@@ -1359,8 +2876,8 @@ var Pe = [
|
|
|
1359
2876
|
* The bootstrap is only read at game boot, so applying a change persists it to localStorage and
|
|
1360
2877
|
* restarts (reloads) the page — the same flow as the Theme tab.
|
|
1361
2878
|
*/
|
|
1362
|
-
function
|
|
1363
|
-
let t = [...
|
|
2879
|
+
function Pe(e = []) {
|
|
2880
|
+
let t = [...Ne, ...e];
|
|
1364
2881
|
return {
|
|
1365
2882
|
id: "host",
|
|
1366
2883
|
label: "Host",
|
|
@@ -1377,7 +2894,7 @@ function Fe(e = []) {
|
|
|
1377
2894
|
<div class="host-note" id="host-source"></div>
|
|
1378
2895
|
<select class="simulator-select" id="host-presets">
|
|
1379
2896
|
<option value="">Preset…</option>
|
|
1380
|
-
${t.map((e, t) => `<option value="${t}">${
|
|
2897
|
+
${t.map((e, t) => `<option value="${t}">${Fe(e.name)}</option>`).join("")}
|
|
1381
2898
|
</select>
|
|
1382
2899
|
<textarea class="simulator-textarea" id="host-json" spellcheck="false"></textarea>
|
|
1383
2900
|
<div class="host-actions">
|
|
@@ -1406,50 +2923,50 @@ function Fe(e = []) {
|
|
|
1406
2923
|
o.textContent = "hostContext must be an array of { type: string, ... } objects";
|
|
1407
2924
|
return;
|
|
1408
2925
|
}
|
|
1409
|
-
console.log("Simulator: hostContext changed, reloading...", e),
|
|
2926
|
+
console.log("Simulator: hostContext changed, reloading...", e), f(e), window.location.reload();
|
|
1410
2927
|
}), (r = e.getElement("#host-reset")) == null || r.addEventListener("click", () => {
|
|
1411
|
-
|
|
2928
|
+
p(), window.location.reload();
|
|
1412
2929
|
}));
|
|
1413
2930
|
}
|
|
1414
2931
|
};
|
|
1415
2932
|
}
|
|
1416
2933
|
/** Minimal HTML-escape so preset names can't break the simulator markup. */
|
|
1417
|
-
function
|
|
2934
|
+
function Fe(e) {
|
|
1418
2935
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1419
2936
|
}
|
|
1420
|
-
var
|
|
1421
|
-
localStorage.setItem(
|
|
1422
|
-
},
|
|
2937
|
+
var Ie = "puzzmo_sim_api_mode", Le = "http://localhost:8911", Re = "https://api.puzzmo.com", q = () => localStorage.getItem(Ie) === "dev" ? "dev" : "prod", ze = (e) => {
|
|
2938
|
+
localStorage.setItem(Ie, e);
|
|
2939
|
+
}, J = null, Be = function() {
|
|
1423
2940
|
var e = t(function* () {
|
|
1424
|
-
if (
|
|
2941
|
+
if (J !== null) return J;
|
|
1425
2942
|
try {
|
|
1426
|
-
let e = new AbortController(), t = setTimeout(() => e.abort(), 1e3), n = yield fetch(`${
|
|
1427
|
-
return clearTimeout(t),
|
|
2943
|
+
let e = new AbortController(), t = setTimeout(() => e.abort(), 1e3), n = yield fetch(`${Le}/healthz`, { signal: e.signal });
|
|
2944
|
+
return clearTimeout(t), J = n.ok, J;
|
|
1428
2945
|
} catch (e) {
|
|
1429
|
-
return
|
|
2946
|
+
return J = !1, !1;
|
|
1430
2947
|
}
|
|
1431
2948
|
});
|
|
1432
2949
|
return function() {
|
|
1433
2950
|
return e.apply(this, arguments);
|
|
1434
2951
|
};
|
|
1435
|
-
}(),
|
|
1436
|
-
apiURL:
|
|
2952
|
+
}(), Ve = () => ({
|
|
2953
|
+
apiURL: q() === "dev" ? Le : Re,
|
|
1437
2954
|
clientID: "protosdk:oauthclient",
|
|
1438
2955
|
redirectUri: `${window.location.origin}/oauth/callback`
|
|
1439
|
-
}),
|
|
2956
|
+
}), He = () => {
|
|
1440
2957
|
let e = new Uint8Array(32);
|
|
1441
2958
|
return crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
1442
|
-
},
|
|
1443
|
-
let e = localStorage.getItem(
|
|
2959
|
+
}, Ue = "puzzmo_sim_oauth_token", We = "puzzmo_sim_oauth_refresh_token", Ge = (e) => localStorage.setItem(Ue, e), Ke = (e) => localStorage.setItem(We, e), qe = () => {
|
|
2960
|
+
let e = localStorage.getItem(Ue);
|
|
1444
2961
|
return e && `${e.substring(0, 20)}`, e;
|
|
1445
|
-
},
|
|
1446
|
-
localStorage.removeItem(
|
|
1447
|
-
},
|
|
1448
|
-
let e =
|
|
2962
|
+
}, Je = () => localStorage.getItem(We), Ye = () => {
|
|
2963
|
+
localStorage.removeItem(Ue), localStorage.removeItem(We);
|
|
2964
|
+
}, Xe = () => {
|
|
2965
|
+
let e = Ve(), t = He();
|
|
1449
2966
|
sessionStorage.setItem("oauth_state", t), sessionStorage.setItem("oauth_return_url", window.location.href);
|
|
1450
2967
|
let n = new URL(`${e.apiURL}/oauth/auth`);
|
|
1451
2968
|
n.searchParams.set("client_id", e.clientID), n.searchParams.set("response_type", "code"), n.searchParams.set("redirect_uri", e.redirectUri), n.searchParams.set("state", t), window.location.href = n.toString();
|
|
1452
|
-
},
|
|
2969
|
+
}, Ze = (e) => {
|
|
1453
2970
|
try {
|
|
1454
2971
|
let t = e.split(".");
|
|
1455
2972
|
if (t.length !== 3) return !0;
|
|
@@ -1458,11 +2975,11 @@ var Le = "puzzmo_sim_api_mode", W = "http://localhost:8911", Re = "https://api.p
|
|
|
1458
2975
|
} catch (e) {
|
|
1459
2976
|
return !0;
|
|
1460
2977
|
}
|
|
1461
|
-
},
|
|
2978
|
+
}, Qe = function() {
|
|
1462
2979
|
var e = t(function* () {
|
|
1463
|
-
let e =
|
|
2980
|
+
let e = Je();
|
|
1464
2981
|
if (!e) return !1;
|
|
1465
|
-
let t =
|
|
2982
|
+
let t = Ve();
|
|
1466
2983
|
try {
|
|
1467
2984
|
let n = new URLSearchParams({
|
|
1468
2985
|
grant_type: "refresh_token",
|
|
@@ -1476,9 +2993,9 @@ var Le = "puzzmo_sim_api_mode", W = "http://localhost:8911", Re = "https://api.p
|
|
|
1476
2993
|
if (!r.ok) return r.statusText, !1;
|
|
1477
2994
|
let i = yield r.json(), a = i.access_token || i.accessToken;
|
|
1478
2995
|
if (!a) return !1;
|
|
1479
|
-
|
|
2996
|
+
Ge(a);
|
|
1480
2997
|
let o = i.refresh_token || i.refreshToken;
|
|
1481
|
-
return o &&
|
|
2998
|
+
return o && Ke(o), !0;
|
|
1482
2999
|
} catch (e) {
|
|
1483
3000
|
return !1;
|
|
1484
3001
|
}
|
|
@@ -1486,9 +3003,9 @@ var Le = "puzzmo_sim_api_mode", W = "http://localhost:8911", Re = "https://api.p
|
|
|
1486
3003
|
return function() {
|
|
1487
3004
|
return e.apply(this, arguments);
|
|
1488
3005
|
};
|
|
1489
|
-
}(),
|
|
3006
|
+
}(), $e = function() {
|
|
1490
3007
|
var e = t(function* (e, t) {
|
|
1491
|
-
let n =
|
|
3008
|
+
let n = Ve(), r = sessionStorage.getItem("oauth_state");
|
|
1492
3009
|
if (!r || r !== t) return null;
|
|
1493
3010
|
sessionStorage.removeItem("oauth_state");
|
|
1494
3011
|
try {
|
|
@@ -1510,13 +3027,13 @@ var Le = "puzzmo_sim_api_mode", W = "http://localhost:8911", Re = "https://api.p
|
|
|
1510
3027
|
return function(t, n) {
|
|
1511
3028
|
return e.apply(this, arguments);
|
|
1512
3029
|
};
|
|
1513
|
-
}(),
|
|
3030
|
+
}(), et = function() {
|
|
1514
3031
|
var e = t(function* (e, t = {}) {
|
|
1515
|
-
let n =
|
|
3032
|
+
let n = Ve(), r = qe();
|
|
1516
3033
|
if (!r) throw Error("Not authenticated");
|
|
1517
|
-
if (
|
|
1518
|
-
if (r =
|
|
1519
|
-
} else throw
|
|
3034
|
+
if (Ze(r)) if (yield Qe()) {
|
|
3035
|
+
if (r = qe(), !r) throw Error("Token refresh succeeded but no token available");
|
|
3036
|
+
} else throw Ye(), Error("Session expired. Please log in again.");
|
|
1520
3037
|
let i = yield fetch(`${n.apiURL}/graphql`, {
|
|
1521
3038
|
method: "POST",
|
|
1522
3039
|
headers: {
|
|
@@ -1535,7 +3052,7 @@ var Le = "puzzmo_sim_api_mode", W = "http://localhost:8911", Re = "https://api.p
|
|
|
1535
3052
|
return function(t) {
|
|
1536
3053
|
return e.apply(this, arguments);
|
|
1537
3054
|
};
|
|
1538
|
-
}(),
|
|
3055
|
+
}(), tt = (e) => {
|
|
1539
3056
|
try {
|
|
1540
3057
|
let t = e.split(".");
|
|
1541
3058
|
return t.length, t.length === 3 ? JSON.parse(atob(t[1])) : null;
|
|
@@ -1543,15 +3060,15 @@ var Le = "puzzmo_sim_api_mode", W = "http://localhost:8911", Re = "https://api.p
|
|
|
1543
3060
|
return null;
|
|
1544
3061
|
}
|
|
1545
3062
|
};
|
|
1546
|
-
function
|
|
3063
|
+
function nt() {
|
|
1547
3064
|
let e = !1;
|
|
1548
3065
|
return {
|
|
1549
3066
|
id: "auth",
|
|
1550
3067
|
label: "Auth",
|
|
1551
3068
|
render() {
|
|
1552
|
-
let e =
|
|
3069
|
+
let e = qe(), t = !!e, n = q(), r = n === "dev" ? Le : Re, i = `<button class="simulator-btn tiny" id="auth-dev-toggle" style="display: none;">${n === "dev" ? "Using Dev" : "Dev"}</button>`;
|
|
1553
3070
|
if (t) {
|
|
1554
|
-
let t =
|
|
3071
|
+
let t = tt(e), n = t != null && t.exp ? (/* @__PURE__ */ new Date(t.exp * 1e3)).toLocaleString() : "Unknown", a = !!Je(), o = a ? tt(Je()) : null, s = o != null && o.exp ? (/* @__PURE__ */ new Date(o.exp * 1e3)).toLocaleString() : null;
|
|
1555
3072
|
return `
|
|
1556
3073
|
<div class="simulator-section">
|
|
1557
3074
|
<div class="simulator-section-title auth-title-row">
|
|
@@ -1592,7 +3109,7 @@ function tt() {
|
|
|
1592
3109
|
</div>
|
|
1593
3110
|
<p class="auth-description">
|
|
1594
3111
|
Login with your Puzzmo account to make authenticated API requests.
|
|
1595
|
-
${n === "dev" ? `<br><strong>Using local dev server:</strong> ${
|
|
3112
|
+
${n === "dev" ? `<br><strong>Using local dev server:</strong> ${Le}` : ""}
|
|
1596
3113
|
</p>
|
|
1597
3114
|
<div class="simulator-row">
|
|
1598
3115
|
<button class="simulator-btn primary" id="auth-login">Login with Puzzmo</button>
|
|
@@ -1603,21 +3120,21 @@ function tt() {
|
|
|
1603
3120
|
},
|
|
1604
3121
|
bind(n) {
|
|
1605
3122
|
let r = n.getElement("#auth-login"), i = n.getElement("#auth-logout"), a = n.getElement("#auth-refresh"), o = n.getElement("#auth-test-api"), s = n.getElement("#auth-api-result"), c = n.getElement("#auth-dev-toggle");
|
|
1606
|
-
e ?
|
|
1607
|
-
e && c && (c.style.display = "",
|
|
3123
|
+
e ? J && c && (c.style.display = "", q() === "dev" && c.classList.add("active")) : (e = !0, Be().then((e) => {
|
|
3124
|
+
e && c && (c.style.display = "", q() === "dev" && c.classList.add("active"));
|
|
1608
3125
|
})), c == null || c.addEventListener("click", () => {
|
|
1609
|
-
ze(
|
|
3126
|
+
ze(q() === "dev" ? "prod" : "dev"), Ye(), window.location.reload();
|
|
1610
3127
|
}), r == null || r.addEventListener("click", () => {
|
|
1611
|
-
|
|
3128
|
+
Xe();
|
|
1612
3129
|
}), i == null || i.addEventListener("click", () => {
|
|
1613
|
-
|
|
3130
|
+
Ye(), window.location.reload();
|
|
1614
3131
|
}), a == null || a.addEventListener("click", t(function* () {
|
|
1615
|
-
a.disabled = !0, a.textContent = "Refreshing...", (yield
|
|
3132
|
+
a.disabled = !0, a.textContent = "Refreshing...", (yield Qe()) ? window.location.reload() : (a.textContent = "Refresh Failed", a.disabled = !1);
|
|
1616
3133
|
})), o == null || o.addEventListener("click", t(function* () {
|
|
1617
3134
|
if (s) {
|
|
1618
3135
|
s.innerHTML = "<div class=\"loading\">Loading...</div>";
|
|
1619
3136
|
try {
|
|
1620
|
-
let t = yield
|
|
3137
|
+
let t = yield et("\n query {\n currentUser {\n id\n username\n usernameID\n name\n }\n }\n ");
|
|
1621
3138
|
if (t.errors) {
|
|
1622
3139
|
var e;
|
|
1623
3140
|
s.innerHTML = `<div class="error">Error: ${((e = t.errors[0]) == null ? void 0 : e.message) || "Unknown error"}</div>`;
|
|
@@ -1639,13 +3156,13 @@ function tt() {
|
|
|
1639
3156
|
if (n && r) {
|
|
1640
3157
|
let t = e.getElement("#auth-status");
|
|
1641
3158
|
t && (t.innerHTML = "<span class=\"indicator waiting\"></span><span>Exchanging code...</span>");
|
|
1642
|
-
let i = yield
|
|
3159
|
+
let i = yield $e(n, r);
|
|
1643
3160
|
if (window.history.replaceState({}, "", window.location.pathname), i) {
|
|
1644
3161
|
let e = i.access_token || i.accessToken;
|
|
1645
3162
|
if (e) {
|
|
1646
|
-
|
|
3163
|
+
Ge(e);
|
|
1647
3164
|
let t = i.refresh_token || i.refreshToken;
|
|
1648
|
-
t &&
|
|
3165
|
+
t && Ke(t);
|
|
1649
3166
|
}
|
|
1650
3167
|
window.location.reload();
|
|
1651
3168
|
} else {
|
|
@@ -1657,9 +3174,9 @@ function tt() {
|
|
|
1657
3174
|
}
|
|
1658
3175
|
};
|
|
1659
3176
|
}
|
|
1660
|
-
var
|
|
1661
|
-
localStorage.removeItem(
|
|
1662
|
-
},
|
|
3177
|
+
var rt = "puzzmo_sim_api_mode", it = "http://localhost:8911", at = "https://api.puzzmo.com", ot = "puzzmo_sim_oauth_token", st = "puzzmo_sim_oauth_refresh_token", ct = () => localStorage.getItem(rt) === "dev" ? "dev" : "prod", lt = () => localStorage.getItem(ot), ut = () => localStorage.getItem(st), dt = (e) => localStorage.setItem(ot, e), ft = (e) => localStorage.setItem(st, e), pt = () => {
|
|
3178
|
+
localStorage.removeItem(ot), localStorage.removeItem(st);
|
|
3179
|
+
}, mt = (e) => {
|
|
1663
3180
|
try {
|
|
1664
3181
|
let t = e.split(".");
|
|
1665
3182
|
if (t.length !== 3) return !0;
|
|
@@ -1668,11 +3185,11 @@ var nt = "puzzmo_sim_api_mode", rt = "http://localhost:8911", it = "https://api.
|
|
|
1668
3185
|
} catch (e) {
|
|
1669
3186
|
return !0;
|
|
1670
3187
|
}
|
|
1671
|
-
},
|
|
3188
|
+
}, ht = function() {
|
|
1672
3189
|
var e = t(function* () {
|
|
1673
|
-
let e =
|
|
3190
|
+
let e = ut();
|
|
1674
3191
|
if (!e) return !1;
|
|
1675
|
-
let t =
|
|
3192
|
+
let t = ct() === "dev" ? it : at;
|
|
1676
3193
|
try {
|
|
1677
3194
|
let n = new URLSearchParams({
|
|
1678
3195
|
grant_type: "refresh_token",
|
|
@@ -1686,9 +3203,9 @@ var nt = "puzzmo_sim_api_mode", rt = "http://localhost:8911", it = "https://api.
|
|
|
1686
3203
|
if (!r.ok) return !1;
|
|
1687
3204
|
let i = yield r.json(), a = i.access_token || i.accessToken;
|
|
1688
3205
|
if (!a) return !1;
|
|
1689
|
-
|
|
3206
|
+
dt(a);
|
|
1690
3207
|
let o = i.refresh_token || i.refreshToken;
|
|
1691
|
-
return o &&
|
|
3208
|
+
return o && ft(o), !0;
|
|
1692
3209
|
} catch (e) {
|
|
1693
3210
|
return !1;
|
|
1694
3211
|
}
|
|
@@ -1696,13 +3213,13 @@ var nt = "puzzmo_sim_api_mode", rt = "http://localhost:8911", it = "https://api.
|
|
|
1696
3213
|
return function() {
|
|
1697
3214
|
return e.apply(this, arguments);
|
|
1698
3215
|
};
|
|
1699
|
-
}(),
|
|
3216
|
+
}(), gt = function() {
|
|
1700
3217
|
var e = t(function* (e, t = {}) {
|
|
1701
|
-
let n =
|
|
3218
|
+
let n = ct() === "dev" ? it : at, r = lt();
|
|
1702
3219
|
if (!r) throw Error("Not authenticated");
|
|
1703
|
-
if (
|
|
1704
|
-
if (r =
|
|
1705
|
-
} else throw
|
|
3220
|
+
if (mt(r)) if (yield ht()) {
|
|
3221
|
+
if (r = lt(), !r) throw Error("Token refresh succeeded but no token available");
|
|
3222
|
+
} else throw pt(), Error("Session expired. Please log in again.");
|
|
1706
3223
|
let i = yield fetch(`${n}/graphql`, {
|
|
1707
3224
|
method: "POST",
|
|
1708
3225
|
headers: {
|
|
@@ -1721,19 +3238,19 @@ var nt = "puzzmo_sim_api_mode", rt = "http://localhost:8911", it = "https://api.
|
|
|
1721
3238
|
return function(t) {
|
|
1722
3239
|
return e.apply(this, arguments);
|
|
1723
3240
|
};
|
|
1724
|
-
}(),
|
|
3241
|
+
}(), _t = "\n query GameFeaturesQuery($slug: ID!) {\n game(id: $slug) {\n id\n slug\n displayName\n featuresArr\n gameFeatures {\n slug\n title\n features {\n featureID\n title\n isEnabled\n }\n }\n }\n }\n", vt = "\n mutation ToggleFeatureMutation($gameSlug: ID!, $input: UpdateGameInput!) {\n updateGame(id: $gameSlug, input: $input) {\n id\n featuresArr\n gameFeatures {\n slug\n title\n features {\n featureID\n title\n isEnabled\n }\n }\n }\n }\n", yt = (e, t) => {
|
|
1725
3242
|
let n = t - 1, r = Math.floor(n / 31), i = n % 31, a = [...e];
|
|
1726
3243
|
for (; a.length <= r;) a.push(0);
|
|
1727
3244
|
return a[r] = a[r] ^ 1 << i, a;
|
|
1728
3245
|
};
|
|
1729
|
-
const
|
|
1730
|
-
function
|
|
3246
|
+
const bt = () => !!lt();
|
|
3247
|
+
function xt() {
|
|
1731
3248
|
let n = null, r = !1, i = null, a = function() {
|
|
1732
3249
|
var e = t(function* (e) {
|
|
1733
3250
|
r = !0, i = null;
|
|
1734
3251
|
try {
|
|
1735
3252
|
var t;
|
|
1736
|
-
let r = yield
|
|
3253
|
+
let r = yield gt(_t, { slug: e });
|
|
1737
3254
|
if (r.errors) {
|
|
1738
3255
|
var a;
|
|
1739
3256
|
i = ((a = r.errors[0]) == null ? void 0 : a.message) || "Unknown error", n = null;
|
|
@@ -1750,10 +3267,10 @@ function bt() {
|
|
|
1750
3267
|
}(), o = function() {
|
|
1751
3268
|
var r = t(function* (t) {
|
|
1752
3269
|
if (!n) return;
|
|
1753
|
-
let r =
|
|
3270
|
+
let r = yt(n.featuresArr, t);
|
|
1754
3271
|
try {
|
|
1755
3272
|
var i;
|
|
1756
|
-
let t = yield
|
|
3273
|
+
let t = yield gt(vt, {
|
|
1757
3274
|
gameSlug: n.slug,
|
|
1758
3275
|
input: { featuresArr: r }
|
|
1759
3276
|
});
|
|
@@ -1801,7 +3318,7 @@ function bt() {
|
|
|
1801
3318
|
id: "features",
|
|
1802
3319
|
label: "Features",
|
|
1803
3320
|
render() {
|
|
1804
|
-
return
|
|
3321
|
+
return bt() ? `
|
|
1805
3322
|
<div class="features-view-container">
|
|
1806
3323
|
<div class="simulator-section">
|
|
1807
3324
|
<div class="simulator-section-title">Game Features</div>
|
|
@@ -1842,7 +3359,7 @@ function bt() {
|
|
|
1842
3359
|
e && (yield d(e));
|
|
1843
3360
|
})), i == null || i.addEventListener("keypress", (e) => {
|
|
1844
3361
|
e.key === "Enter" && (r == null || r.click());
|
|
1845
|
-
}), console.log("[FeaturesView] bind called, ctx.gameSlug:", e.gameSlug, "slugInput:", i), e.gameSlug && i && (i.value = e.gameSlug,
|
|
3362
|
+
}), console.log("[FeaturesView] bind called, ctx.gameSlug:", e.gameSlug, "slugInput:", i), e.gameSlug && i && (i.value = e.gameSlug, bt() && !n && d(e.gameSlug)), u();
|
|
1846
3363
|
},
|
|
1847
3364
|
onActivate(e) {
|
|
1848
3365
|
let t = e.getElement("#simulator-tab-features");
|
|
@@ -1866,19 +3383,19 @@ function bt() {
|
|
|
1866
3383
|
* tuning it needs to see it.
|
|
1867
3384
|
*/
|
|
1868
3385
|
/** Space the keys occupy. */
|
|
1869
|
-
var
|
|
3386
|
+
var St = 200, Ct = 24;
|
|
1870
3387
|
/** What the keyboard takes off the bottom of the game, and what the game must lay out without. */
|
|
1871
|
-
const
|
|
3388
|
+
const Y = St + Ct;
|
|
1872
3389
|
/** Drag-cursor thresholds, from useKeyboardCursor in @puzzmo-com/keyboard. */
|
|
1873
|
-
var
|
|
3390
|
+
var wt = 6, Tt = 2.5, Et = 100, Dt = (e, t) => e ? "14.7%" : t ? "17.85%" : "9.75%", X = (e, t) => {
|
|
1874
3391
|
let n = e.replace("#", ""), r = n.length === 3 ? [...n].map((e) => e + e).join("") : n, i = parseInt(r, 16);
|
|
1875
3392
|
return r.length !== 6 || Number.isNaN(i) ? e : `rgba(${i >> 16 & 255}, ${i >> 8 & 255}, ${i & 255}, ${t})`;
|
|
1876
|
-
},
|
|
1877
|
-
function
|
|
3393
|
+
}, Ot = (e) => e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<"), kt = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
3394
|
+
function At(e) {
|
|
1878
3395
|
let { theme: t, sendToGame: n } = e, r = !1, i = null, a = null, o = document.createElement("style");
|
|
1879
3396
|
o.id = "sim-docked-kbd-page-style", o.textContent = `
|
|
1880
3397
|
html.sim-kbd-docked #simulator {
|
|
1881
|
-
bottom: ${
|
|
3398
|
+
bottom: ${Y + 4}px;
|
|
1882
3399
|
}
|
|
1883
3400
|
`;
|
|
1884
3401
|
/** The element the game mounted into: `#root` per the SDK's page template, else the page's first element. */
|
|
@@ -1891,7 +3408,7 @@ function kt(e) {
|
|
|
1891
3408
|
let { height: t, maxHeight: n, position: r } = e.style;
|
|
1892
3409
|
c = () => {
|
|
1893
3410
|
e.style.height = t, e.style.maxHeight = n, e.style.position = r, c = null;
|
|
1894
|
-
}, e.style.height = `calc(100% - ${
|
|
3411
|
+
}, e.style.height = `calc(100% - ${Y}px)`, e.style.maxHeight = `calc(100% - ${Y}px)`, getComputedStyle(e).position === "static" && (e.style.position = "relative");
|
|
1895
3412
|
}, u = (e, n) => {
|
|
1896
3413
|
var r;
|
|
1897
3414
|
let i = n.disabled.includes(e), a = n.highlight.includes(e);
|
|
@@ -1906,8 +3423,8 @@ function kt(e) {
|
|
|
1906
3423
|
"overflow:hidden",
|
|
1907
3424
|
"background:transparent",
|
|
1908
3425
|
"pointer-events:none",
|
|
1909
|
-
`border:${i ? `1px dashed ${
|
|
1910
|
-
|
|
3426
|
+
`border:${i ? `1px dashed ${X(t.fg, .25)}` : a ? `2px solid ${X(t.fg, .75)}` : `1px solid ${X(t.fg, .4)}`}`,
|
|
3427
|
+
Z((r = n.individualKeyStyles) == null || (r = r[e]) == null ? void 0 : r.background)
|
|
1911
3428
|
].filter(Boolean).join(";");
|
|
1912
3429
|
}, d = (e, n) => {
|
|
1913
3430
|
var r;
|
|
@@ -1916,14 +3433,14 @@ function kt(e) {
|
|
|
1916
3433
|
"letter-spacing:0.5px",
|
|
1917
3434
|
"text-transform:uppercase",
|
|
1918
3435
|
"white-space:nowrap",
|
|
1919
|
-
`color:${
|
|
1920
|
-
n.highlight.includes(e) ? "" :
|
|
1921
|
-
|
|
3436
|
+
`color:${X(t.fg, n.disabled.includes(e) ? .3 : .65)}`,
|
|
3437
|
+
n.highlight.includes(e) ? "" : Z(n.keyStyles),
|
|
3438
|
+
Z((r = n.individualKeyStyles) == null || (r = r[e]) == null ? void 0 : r.text)
|
|
1922
3439
|
].filter(Boolean).join(";");
|
|
1923
3440
|
}, f = (e, t) => {
|
|
1924
3441
|
var n, r;
|
|
1925
3442
|
let i = (n = t.symbols[e]) == null ? e : n, a = t.disabled.includes(e), o = (r = t.flexGrowSymbols) == null ? void 0 : r.includes(e), s = [
|
|
1926
|
-
`width:${
|
|
3443
|
+
`width:${Dt(t.l.includes(e), t.xl.includes(e))}`,
|
|
1927
3444
|
`flex:${o ? "1 0 auto" : "0 1 auto"}`,
|
|
1928
3445
|
"height:100%",
|
|
1929
3446
|
"display:flex",
|
|
@@ -1933,43 +3450,43 @@ function kt(e) {
|
|
|
1933
3450
|
"position:relative",
|
|
1934
3451
|
a ? "pointer-events:none" : ""
|
|
1935
3452
|
].filter(Boolean).join(";"), c = u(e, t), l = d(e, t);
|
|
1936
|
-
return `<div class="sim-docked-kbd-key" data-key="${
|
|
1937
|
-
<div class="sim-docked-kbd-key-inner" style="${c}"><div style="${l}">${
|
|
3453
|
+
return `<div class="sim-docked-kbd-key" data-key="${Ot(e)}" style="${s}">
|
|
3454
|
+
<div class="sim-docked-kbd-key-inner" style="${c}"><div style="${l}">${kt(i)}</div></div>
|
|
1938
3455
|
</div>`;
|
|
1939
3456
|
}, p = (e) => {
|
|
1940
3457
|
let n = e.layout.filter((e) => !!e), r = `calc(100% / ${n.length})`;
|
|
1941
3458
|
return `${n.map((t, n) => {
|
|
1942
3459
|
var i, a;
|
|
1943
3460
|
return `<div style="${`height:${r};display:flex;flex-direction:row;align-items:center;justify-content:${(i = (a = e.rowPositioning) == null ? void 0 : a[n]) == null ? "center" : i}`}">${[...t].map((t) => f(t, e)).join("")}</div>`;
|
|
1944
|
-
}).join("")}${`<div id="sim-docked-kbd-cursor" style="position:absolute;inset:0;z-index:1;background:${
|
|
3461
|
+
}).join("")}${`<div id="sim-docked-kbd-cursor" style="position:absolute;inset:0;z-index:1;background:${X(t.fg, .12)};opacity:0;transition:opacity 0.1s ease-in-out;pointer-events:none"></div>`}`;
|
|
1945
3462
|
}, m = !1, h = [0, 0], g = null, _ = 0, v = null, y = null, b = (e) => {
|
|
1946
3463
|
let t = a == null ? void 0 : a.querySelector("#sim-docked-kbd-cursor");
|
|
1947
3464
|
t && (t.style.opacity = e ? "0.5" : "0");
|
|
1948
3465
|
}, x = () => {
|
|
1949
3466
|
m = !1, h = [0, 0], g = null, _ = 0, v = null, y = null, b(!1);
|
|
1950
|
-
},
|
|
3467
|
+
}, S = (e) => {
|
|
1951
3468
|
var t, n;
|
|
1952
3469
|
return (t = (n = document.elementFromPoint(e.clientX, e.clientY)) == null || (n = n.closest(".sim-docked-kbd-key")) == null ? void 0 : n.getAttribute("data-key")) == null ? null : t;
|
|
1953
|
-
},
|
|
1954
|
-
y =
|
|
3470
|
+
}, ee = (e) => {
|
|
3471
|
+
y = S(e), a == null || a.setPointerCapture(e.pointerId);
|
|
1955
3472
|
}, C = (e) => {
|
|
1956
|
-
!(i != null && i.supportsDragCursor) || !y || g && g.clientX === e.clientX && g.clientY === e.clientY || (g && g.pointerId !== e.pointerId && (_ = 0, v = null), v || (v = Date.now()), m || (_ += 1, _ >=
|
|
3473
|
+
!(i != null && i.supportsDragCursor) || !y || g && g.clientX === e.clientX && g.clientY === e.clientY || (g && g.pointerId !== e.pointerId && (_ = 0, v = null), v || (v = Date.now()), m || (_ += 1, _ >= wt && Date.now() - v >= Et && (m = !0, b(!0))), m && g && (h = [h[0] + (e.clientX - g.clientX) * Tt, h[1] + (e.clientY - g.clientY) * Tt]), g = {
|
|
1957
3474
|
clientX: e.clientX,
|
|
1958
3475
|
clientY: e.clientY,
|
|
1959
3476
|
pointerId: e.pointerId
|
|
1960
3477
|
}, m && n("KEYBOARD_CURSOR_CHANGE", { position: h }));
|
|
1961
|
-
},
|
|
1962
|
-
m ? n("KEYBOARD_CURSOR_END", {}) : y &&
|
|
1963
|
-
},
|
|
3478
|
+
}, w = (e) => {
|
|
3479
|
+
m ? n("KEYBOARD_CURSOR_END", {}) : y && S(e) === y && n("KEYBOARD_KEY_PRESS", { key: y }), x();
|
|
3480
|
+
}, te = () => {
|
|
1964
3481
|
a || !i || (a = document.createElement("div"), a.id = "sim-docked-kbd", a.style.cssText = [
|
|
1965
3482
|
"position:fixed",
|
|
1966
3483
|
"left:0",
|
|
1967
3484
|
"right:0",
|
|
1968
3485
|
"bottom:0",
|
|
1969
|
-
`height:${
|
|
3486
|
+
`height:${Y}px`,
|
|
1970
3487
|
"box-sizing:border-box",
|
|
1971
3488
|
"padding-top:8px",
|
|
1972
|
-
`padding-bottom:${
|
|
3489
|
+
`padding-bottom:${Ct}px`,
|
|
1973
3490
|
"display:flex",
|
|
1974
3491
|
"flex-direction:column",
|
|
1975
3492
|
"z-index:999998",
|
|
@@ -1977,9 +3494,9 @@ function kt(e) {
|
|
|
1977
3494
|
"user-select:none",
|
|
1978
3495
|
"-webkit-user-select:none",
|
|
1979
3496
|
`background:${t.a_bg}`,
|
|
1980
|
-
`border-top:1px solid ${
|
|
1981
|
-
].join(";"), a.innerHTML = p(i), a.addEventListener("pointerdown",
|
|
1982
|
-
},
|
|
3497
|
+
`border-top:1px solid ${X(t.fg, .2)}`
|
|
3498
|
+
].join(";"), a.innerHTML = p(i), a.addEventListener("pointerdown", ee), a.addEventListener("pointermove", C), a.addEventListener("pointerup", w), a.addEventListener("pointercancel", () => x()), a.addEventListener("contextmenu", (e) => e.preventDefault()), document.body.appendChild(a), o.isConnected || document.head.appendChild(o), document.documentElement.classList.add("sim-kbd-docked"), l());
|
|
3499
|
+
}, ne = () => {
|
|
1983
3500
|
a && (a.remove(), a = null, document.documentElement.classList.remove("sim-kbd-docked"), c == null || c(), x());
|
|
1984
3501
|
}, T = () => {
|
|
1985
3502
|
let e = i;
|
|
@@ -1988,8 +3505,8 @@ function kt(e) {
|
|
|
1988
3505
|
!n || !r || !i || (r.style.cssText = u(n, e), i.style.cssText = d(n, e));
|
|
1989
3506
|
});
|
|
1990
3507
|
}, E = () => {
|
|
1991
|
-
if (!r || !i) return
|
|
1992
|
-
if (!a) return
|
|
3508
|
+
if (!r || !i) return ne();
|
|
3509
|
+
if (!a) return te();
|
|
1993
3510
|
a.innerHTML = p(i), b(m);
|
|
1994
3511
|
};
|
|
1995
3512
|
return {
|
|
@@ -1997,13 +3514,13 @@ function kt(e) {
|
|
|
1997
3514
|
r = e, E();
|
|
1998
3515
|
},
|
|
1999
3516
|
setConfig(e) {
|
|
2000
|
-
let t = a && e && i &&
|
|
3517
|
+
let t = a && e && i && jt(e) === jt(i);
|
|
2001
3518
|
i = e, t ? T() : E();
|
|
2002
3519
|
}
|
|
2003
3520
|
};
|
|
2004
3521
|
}
|
|
2005
3522
|
/** Everything about a config except its per-key styling, so a styling-only update can be spotted. */
|
|
2006
|
-
var
|
|
3523
|
+
var jt = (e) => JSON.stringify([
|
|
2007
3524
|
e.layout,
|
|
2008
3525
|
e.symbols,
|
|
2009
3526
|
e.highlight,
|
|
@@ -2015,9 +3532,9 @@ var At = (e) => JSON.stringify([
|
|
|
2015
3532
|
e.keyStyles
|
|
2016
3533
|
]);
|
|
2017
3534
|
/** Serializes a style object into inline CSS, so `{ backgroundColor: "red" }` becomes `background-color:red`. */
|
|
2018
|
-
const
|
|
3535
|
+
const Z = (e) => Object.entries(e == null ? {} : e).map(([e, t]) => `${e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`)}:${Ot(String(t))}`).join(";");
|
|
2019
3536
|
/** Renders a single keyboard key as an HTML button string */
|
|
2020
|
-
var
|
|
3537
|
+
var Mt = (e, t) => {
|
|
2021
3538
|
var n, r, i, a;
|
|
2022
3539
|
let o = (n = t.symbols[e]) == null ? e : n, s = t.disabled.includes(e), c = t.highlight.includes(e), l = t.xl.includes(e), u = t.l.includes(e), d = (r = t.flexGrowSymbols) == null ? void 0 : r.includes(e), f = [
|
|
2023
3540
|
"sim-kb-key",
|
|
@@ -2026,11 +3543,11 @@ var jt = (e, t) => {
|
|
|
2026
3543
|
l ? "xl" : "",
|
|
2027
3544
|
u ? "l" : "",
|
|
2028
3545
|
d ? "grow" : ""
|
|
2029
|
-
].filter(Boolean).join(" "), p =
|
|
3546
|
+
].filter(Boolean).join(" "), p = Z((i = t.individualKeyStyles) == null || (i = i[e]) == null ? void 0 : i.background), m = Z((a = t.individualKeyStyles) == null || (a = a[e]) == null ? void 0 : a.text);
|
|
2030
3547
|
return `<button class="${f}" data-key="${e}" style="${p}" ${s ? "disabled" : ""}><span style="${m}">${o}</span></button>`;
|
|
2031
|
-
},
|
|
2032
|
-
function
|
|
2033
|
-
let e = null, t = null, n = (t) => e ? t ? `<div class="sim-kb-empty">Shown under the game at production size, taking ${
|
|
3548
|
+
}, Nt = (e) => `<div class="sim-kb">${e.layout.filter((e) => e != null).map((t) => `<div class="sim-kb-row">${[...t].map((t) => Mt(t, e)).join("")}</div>`).join("")}</div>`;
|
|
3549
|
+
function Pt() {
|
|
3550
|
+
let e = null, t = null, n = (t) => e ? t ? `<div class="sim-kb-empty">Shown under the game at production size, taking ${Y}px off the bottom.<br>Uncheck to preview the layout here instead.</div>` : Nt(e) : "<div class=\"sim-kb-empty\">No keyboard config received from game yet.<br>The game calls <code>sdk.keyboard.show(config)</code> to display a keyboard.</div>";
|
|
2034
3551
|
return {
|
|
2035
3552
|
id: "kbd",
|
|
2036
3553
|
label: "Kbd",
|
|
@@ -2050,14 +3567,14 @@ function Nt() {
|
|
|
2050
3567
|
`;
|
|
2051
3568
|
},
|
|
2052
3569
|
bind(e) {
|
|
2053
|
-
t != null || (t =
|
|
3570
|
+
t != null || (t = At({
|
|
2054
3571
|
theme: e.state.selectedTheme,
|
|
2055
3572
|
sendToGame: e.sendToGame
|
|
2056
3573
|
})), t.setEnabled(e.state.keyboardDocked);
|
|
2057
3574
|
let n = e.getElement("#sim-kb-dock");
|
|
2058
3575
|
n && (n.checked = e.state.keyboardDocked, n.addEventListener("change", () => {
|
|
2059
|
-
e.state.keyboardDocked = n.checked,
|
|
2060
|
-
})),
|
|
3576
|
+
e.state.keyboardDocked = n.checked, h(n.checked), t == null || t.setEnabled(n.checked), r(e);
|
|
3577
|
+
})), Ft(e);
|
|
2061
3578
|
},
|
|
2062
3579
|
onMessage(n, i, a) {
|
|
2063
3580
|
var o;
|
|
@@ -2067,11 +3584,11 @@ function Nt() {
|
|
|
2067
3584
|
/** Re-render the tab's own content (not the dock) and rebind its keys. */
|
|
2068
3585
|
function r(e) {
|
|
2069
3586
|
let t = e.getElement("#sim-kb-content");
|
|
2070
|
-
t && (t.innerHTML = n(e.state.keyboardDocked),
|
|
3587
|
+
t && (t.innerHTML = n(e.state.keyboardDocked), Ft(e));
|
|
2071
3588
|
}
|
|
2072
3589
|
}
|
|
2073
3590
|
/** Attach click handlers to all rendered keys */
|
|
2074
|
-
function
|
|
3591
|
+
function Ft(e) {
|
|
2075
3592
|
var t;
|
|
2076
3593
|
let n = (t = e.getElement("#sim-kb-content")) == null ? void 0 : t.querySelectorAll(".sim-kb-key");
|
|
2077
3594
|
n == null || n.forEach((t) => {
|
|
@@ -2086,15 +3603,15 @@ function Pt(e) {
|
|
|
2086
3603
|
* change values (persisted to localStorage and pushed to the game as SETTINGS_UPDATE, matching the
|
|
2087
3604
|
* production host) and reflects UPDATE_SETTINGS_FROM_EMBED writes coming from the game.
|
|
2088
3605
|
*/
|
|
2089
|
-
function
|
|
3606
|
+
function It() {
|
|
2090
3607
|
let t = (e) => {
|
|
2091
3608
|
let t = e.state.settingsComponents;
|
|
2092
|
-
return !t || t.length === 0 ? "<div class=\"sim-settings-empty\">No settings registered by the game yet.<br>The game calls <code>sdk.settings.initialize(components)</code> to describe its settings UI.</div>" : `<div class="sim-settings-form">${t.map((t) =>
|
|
3609
|
+
return !t || t.length === 0 ? "<div class=\"sim-settings-empty\">No settings registered by the game yet.<br>The game calls <code>sdk.settings.initialize(components)</code> to describe its settings UI.</div>" : `<div class="sim-settings-form">${t.map((t) => Lt(t, e.state.gameSettings)).join("")}</div><div class="sim-settings-actions"><button class="simulator-btn tiny" id="sim-settings-reset">Reset to defaults</button></div>`;
|
|
2093
3610
|
}, n = (e) => {
|
|
2094
3611
|
let n = e.getElement("#sim-settings-content");
|
|
2095
3612
|
n && (n.innerHTML = t(e), i(e));
|
|
2096
3613
|
}, r = (e) => {
|
|
2097
|
-
|
|
3614
|
+
C(e.state.gameSettings), e.sendToGame("SETTINGS_UPDATE", e.state.gameSettings);
|
|
2098
3615
|
}, i = (t) => {
|
|
2099
3616
|
var i;
|
|
2100
3617
|
let a = t.getElement("#sim-settings-content");
|
|
@@ -2110,7 +3627,7 @@ function Ft() {
|
|
|
2110
3627
|
});
|
|
2111
3628
|
}), (i = a.querySelector("#sim-settings-reset")) == null || i.addEventListener("click", () => {
|
|
2112
3629
|
var e;
|
|
2113
|
-
|
|
3630
|
+
w(), t.state.gameSettings = zt((e = t.state.settingsComponents) == null ? [] : e), r(t), n(t);
|
|
2114
3631
|
}));
|
|
2115
3632
|
};
|
|
2116
3633
|
return {
|
|
@@ -2125,21 +3642,21 @@ function Ft() {
|
|
|
2125
3642
|
onMessage(t, r, i) {
|
|
2126
3643
|
if (t === "INITIALIZE_SETTINGS") {
|
|
2127
3644
|
var a;
|
|
2128
|
-
i.state.settingsComponents = (a = r == null ? void 0 : r.components) == null ? [] : a, i.state.gameSettings = e(e({}, r == null ? void 0 : r.settings), i.state.gameSettings),
|
|
3645
|
+
i.state.settingsComponents = (a = r == null ? void 0 : r.components) == null ? [] : a, i.state.gameSettings = e(e({}, r == null ? void 0 : r.settings), i.state.gameSettings), C(i.state.gameSettings), n(i);
|
|
2129
3646
|
return;
|
|
2130
3647
|
}
|
|
2131
|
-
t === "UPDATE_SETTINGS_FROM_EMBED" && (i.state.gameSettings = e(e({}, i.state.gameSettings), r == null ? void 0 : r.settings),
|
|
3648
|
+
t === "UPDATE_SETTINGS_FROM_EMBED" && (i.state.gameSettings = e(e({}, i.state.gameSettings), r == null ? void 0 : r.settings), C(i.state.gameSettings), n(i));
|
|
2132
3649
|
}
|
|
2133
3650
|
};
|
|
2134
3651
|
}
|
|
2135
3652
|
/** Renders a single settings UI component as HTML, reading its current value from `settings` */
|
|
2136
|
-
function
|
|
3653
|
+
function Lt(e, t) {
|
|
2137
3654
|
switch (e.type) {
|
|
2138
3655
|
case "title": return `<div class="sim-settings-heading">${Q(e.value)}</div>`;
|
|
2139
3656
|
case "subtitle": return `<div class="sim-settings-subheading">${Q(e.value)}</div>`;
|
|
2140
3657
|
case "paragraph": return `<p class="sim-settings-paragraph">${Q(e.value)}</p>`;
|
|
2141
3658
|
case "separator": return "<div class=\"simulator-divider\"></div>";
|
|
2142
|
-
case "split": return `<div class="sim-settings-split">${e.content.map((e) =>
|
|
3659
|
+
case "split": return `<div class="sim-settings-split">${e.content.map((e) => Lt(e, t)).join("")}</div>`;
|
|
2143
3660
|
case "boolean": {
|
|
2144
3661
|
var n;
|
|
2145
3662
|
let r = ((n = t[e.name]) == null ? e.defaultValue : n) ? "checked" : "", i = e.subtitle ? `<div class="sim-settings-subtitle">${Q(e.subtitle)}</div>` : "";
|
|
@@ -2160,7 +3677,7 @@ function It(e, t) {
|
|
|
2160
3677
|
}).join("");
|
|
2161
3678
|
return `
|
|
2162
3679
|
<div class="simulator-field">
|
|
2163
|
-
${
|
|
3680
|
+
${Rt(e)}
|
|
2164
3681
|
<select class="simulator-select" data-setting="${e.name}">${i}</select>
|
|
2165
3682
|
</div>`;
|
|
2166
3683
|
}
|
|
@@ -2176,7 +3693,7 @@ function It(e, t) {
|
|
|
2176
3693
|
}).join("");
|
|
2177
3694
|
return `
|
|
2178
3695
|
<div class="simulator-field">
|
|
2179
|
-
${
|
|
3696
|
+
${Rt(e)}
|
|
2180
3697
|
${a}
|
|
2181
3698
|
</div>`;
|
|
2182
3699
|
}
|
|
@@ -2185,7 +3702,7 @@ function It(e, t) {
|
|
|
2185
3702
|
let n = (a = t[e.name]) == null ? e.defaultValue : a, r = e.values.map((e) => `<option value="${e}" ${e === n ? "selected" : ""}>${e}</option>`).join("");
|
|
2186
3703
|
return `
|
|
2187
3704
|
<div class="simulator-field">
|
|
2188
|
-
${
|
|
3705
|
+
${Rt(e)}
|
|
2189
3706
|
<select class="simulator-select" data-setting="${e.name}" data-setting-type="number">${r}</select>
|
|
2190
3707
|
</div>`;
|
|
2191
3708
|
}
|
|
@@ -2194,7 +3711,7 @@ function It(e, t) {
|
|
|
2194
3711
|
let n = String((o = (s = t[e.name]) == null ? e.defaultValue : s) == null ? "" : o), r = e.textarea ? `<textarea class="simulator-textarea" data-setting="${e.name}">${Q(n)}</textarea>` : `<input class="simulator-input" type="text" data-setting="${e.name}" value="${Q(n)}" />`;
|
|
2195
3712
|
return `
|
|
2196
3713
|
<div class="simulator-field">
|
|
2197
|
-
${
|
|
3714
|
+
${Rt(e)}
|
|
2198
3715
|
${r}
|
|
2199
3716
|
</div>`;
|
|
2200
3717
|
}
|
|
@@ -2202,14 +3719,14 @@ function It(e, t) {
|
|
|
2202
3719
|
}
|
|
2203
3720
|
}
|
|
2204
3721
|
/** Title + optional subtitle markup for a value-producing component */
|
|
2205
|
-
function
|
|
3722
|
+
function Rt(e) {
|
|
2206
3723
|
let t = e.subtitle ? `<div class="sim-settings-subtitle">${Q(e.subtitle)}</div>` : "";
|
|
2207
3724
|
return `<span class="simulator-label">${Q(e.title)}</span>${t}`;
|
|
2208
3725
|
}
|
|
2209
3726
|
/** Collects name → defaultValue pairs from components, recursing into split groups */
|
|
2210
|
-
function
|
|
3727
|
+
function zt(e) {
|
|
2211
3728
|
let t = {};
|
|
2212
|
-
for (let n of e) n.type === "split" ? Object.assign(t,
|
|
3729
|
+
for (let n of e) n.type === "split" ? Object.assign(t, zt(n.content)) : "name" in n && (t[n.name] = n.defaultValue);
|
|
2213
3730
|
return t;
|
|
2214
3731
|
}
|
|
2215
3732
|
function Q(e) {
|
|
@@ -2220,8 +3737,8 @@ function Q(e) {
|
|
|
2220
3737
|
* parts the host owns: the sound-enabled gate (games boot muted, so this is what lets you hear
|
|
2221
3738
|
* anything) and a log of the cues the game asked us for, with any haptic it wanted.
|
|
2222
3739
|
*/
|
|
2223
|
-
function
|
|
2224
|
-
let e = [], t = !0, n = () => e.length === 0 ? "<div class=\"sound-empty\">No cues yet. Play the game to hear from it.</div>" : e.map((e) => `<div class="sound-row"><span class="sound-id">${
|
|
3740
|
+
function Bt() {
|
|
3741
|
+
let e = [], t = !0, n = () => e.length === 0 ? "<div class=\"sound-empty\">No cues yet. Play the game to hear from it.</div>" : e.map((e) => `<div class="sound-row"><span class="sound-id">${Ht(e.id)}</span>${e.haptic ? `<span class="sound-haptic">${Ht(e.haptic)}</span>` : ""}<span class="sound-time">${e.time}</span></div>`).join(""), r = (t) => {
|
|
2225
3742
|
let r = t.getElement("#sound-events");
|
|
2226
3743
|
r && (r.innerHTML = n()), t.updateBadge("sound", e.length);
|
|
2227
3744
|
};
|
|
@@ -2268,13 +3785,13 @@ function Rt() {
|
|
|
2268
3785
|
n === "SENSORY_EVENT" && (e.unshift({
|
|
2269
3786
|
id: (o = i == null ? void 0 : i.id) == null ? JSON.stringify(i) : o,
|
|
2270
3787
|
haptic: i == null ? void 0 : i.haptic,
|
|
2271
|
-
time:
|
|
3788
|
+
time: Vt()
|
|
2272
3789
|
}), e.length > 100 && e.pop(), r(a));
|
|
2273
3790
|
}
|
|
2274
3791
|
};
|
|
2275
3792
|
}
|
|
2276
3793
|
/** Current wall-clock time as HH:MM:SS, matching the simulator's message log formatting. */
|
|
2277
|
-
function
|
|
3794
|
+
function Vt() {
|
|
2278
3795
|
return (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
|
|
2279
3796
|
hour12: !1,
|
|
2280
3797
|
hour: "2-digit",
|
|
@@ -2283,16 +3800,16 @@ function zt() {
|
|
|
2283
3800
|
});
|
|
2284
3801
|
}
|
|
2285
3802
|
/** Minimal HTML-escape so event ids can't break the simulator markup. */
|
|
2286
|
-
function
|
|
3803
|
+
function Ht(e) {
|
|
2287
3804
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
2288
3805
|
}
|
|
2289
3806
|
var $ = null;
|
|
2290
3807
|
/** True when the game is embedded in the real Puzzmo app, which sets `?developer=true` on the iframe. */
|
|
2291
|
-
function
|
|
3808
|
+
function Ut() {
|
|
2292
3809
|
return typeof window > "u" ? !1 : new URLSearchParams(window.location.search).has("developer");
|
|
2293
3810
|
}
|
|
2294
3811
|
/** Inert instance returned when the simulator declines to boot (the app is the host). */
|
|
2295
|
-
var
|
|
3812
|
+
var Wt = {
|
|
2296
3813
|
updateFixtures: () => {},
|
|
2297
3814
|
sendToGame: () => {},
|
|
2298
3815
|
loadPuzzle: function() {
|
|
@@ -2341,28 +3858,28 @@ var Ht = {
|
|
|
2341
3858
|
* Fixtures are loaded as raw strings and passed to the game verbatim (any text format works; the game parses it).
|
|
2342
3859
|
* This will show dropdowns in the Ctrl tab to select category and puzzle.
|
|
2343
3860
|
*/
|
|
2344
|
-
function
|
|
3861
|
+
function Gt(n = {}) {
|
|
2345
3862
|
var r, i, a, o, s;
|
|
2346
|
-
if (
|
|
3863
|
+
if (Ut()) return console.log("[Simulator] developer=true in URL — running inside the Puzzmo app, skipping simulator boot"), Wt;
|
|
2347
3864
|
if (console.log("[Simulator] createSimulator called with config:", {
|
|
2348
3865
|
slug: n.slug,
|
|
2349
3866
|
hasFixtures: !!n.fixtures
|
|
2350
3867
|
}), $) return n.fixtures && (console.log("[Simulator] Instance already exists, updating fixtures"), $.updateFixtures(n.fixtures)), $;
|
|
2351
|
-
let c = (r = n.autoStart) == null ? !0 : r, l = n.fixtures ?
|
|
2352
|
-
|
|
2353
|
-
|
|
3868
|
+
let c = (r = n.autoStart) == null ? !0 : r, l = n.fixtures ? ie(n.fixtures) : null, u = l ? Array.from(l.keys()).sort() : [], d = pe(), f = Ae(), p = [
|
|
3869
|
+
oe(),
|
|
3870
|
+
se(),
|
|
2354
3871
|
d,
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
3872
|
+
me(),
|
|
3873
|
+
he(),
|
|
3874
|
+
Ce((i = (a = n.integrations) == null ? void 0 : a.checklists) == null ? [] : i),
|
|
2358
3875
|
f,
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
3876
|
+
Me(),
|
|
3877
|
+
Pe(n.hostContextPresets),
|
|
3878
|
+
nt(),
|
|
3879
|
+
xt(),
|
|
3880
|
+
Pt(),
|
|
3881
|
+
It(),
|
|
3882
|
+
Bt(),
|
|
2366
3883
|
...(o = n.views) == null ? [] : o
|
|
2367
3884
|
], m = p.map((e) => e.id), h = ee(n, u, m), g = {
|
|
2368
3885
|
pause: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><rect x=\"1\" y=\"1\" width=\"3\" height=\"8\"/><rect x=\"6\" y=\"1\" width=\"3\" height=\"8\"/></svg>",
|
|
@@ -2372,7 +3889,7 @@ function Ut(n = {}) {
|
|
|
2372
3889
|
minimize: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><rect x=\"1\" y=\"4\" width=\"8\" height=\"2\"/></svg>",
|
|
2373
3890
|
expand: "<svg width=\"8\" height=\"8\" viewBox=\"0 0 8 8\" fill=\"currentColor\"><polygon points=\"1,1 7,4 1,7\"/></svg>"
|
|
2374
3891
|
}, _ = document.createElement("div");
|
|
2375
|
-
_.id = "simulator", _.dataset.puzzmoBuild =
|
|
3892
|
+
_.id = "simulator", _.dataset.puzzmoBuild = ae, _.innerHTML = `
|
|
2376
3893
|
<style>
|
|
2377
3894
|
:root {
|
|
2378
3895
|
--sim-bg: #1a1a2e;
|
|
@@ -3846,9 +5363,9 @@ function Ut(n = {}) {
|
|
|
3846
5363
|
}, j = (e, t) => {
|
|
3847
5364
|
let n = k("#simulator-status .text"), r = k("#simulator-status .indicator"), i = t === "complete" ? "✓" : "";
|
|
3848
5365
|
n && (n.textContent = e), r && (r.className = `indicator ${t}`, r.textContent = i), b.className = t, b.textContent = i, x.textContent = e;
|
|
3849
|
-
},
|
|
5366
|
+
}, P = (e, t) => {
|
|
3850
5367
|
t && t !== "0" ? E.innerHTML = `${e}<span class="penalty">+${t}</span>` : E.textContent = e;
|
|
3851
|
-
},
|
|
5368
|
+
}, F = (e) => {
|
|
3852
5369
|
var t;
|
|
3853
5370
|
h.activeTab = e, O.classList.remove("hidden"), ne(e), D.querySelectorAll(".simulator-tab").forEach((t) => {
|
|
3854
5371
|
t.classList.toggle("active", t.getAttribute("data-tab") === e);
|
|
@@ -3856,12 +5373,12 @@ function Ut(n = {}) {
|
|
|
3856
5373
|
t.classList.toggle("active", t.id === `simulator-tab-${e}`);
|
|
3857
5374
|
}), w.classList.toggle("active", e === "auth");
|
|
3858
5375
|
let n = p.find((t) => t.id === e);
|
|
3859
|
-
n == null || (t = n.onActivate) == null || t.call(n,
|
|
3860
|
-
},
|
|
3861
|
-
h.isCollapsed = e, v.classList.toggle("collapsed", e), te(e), e ? (O.classList.add("hidden"), D.querySelectorAll(".simulator-tab").forEach((e) => e.classList.remove("active"))) :
|
|
3862
|
-
},
|
|
3863
|
-
f.updatePreview(
|
|
3864
|
-
},
|
|
5376
|
+
n == null || (t = n.onActivate) == null || t.call(n, H);
|
|
5377
|
+
}, I = (e) => {
|
|
5378
|
+
h.isCollapsed = e, v.classList.toggle("collapsed", e), te(e), e ? (O.classList.add("hidden"), D.querySelectorAll(".simulator-tab").forEach((e) => e.classList.remove("active"))) : F(h.activeTab);
|
|
5379
|
+
}, L = () => {
|
|
5380
|
+
f.updatePreview(H);
|
|
5381
|
+
}, R = function() {
|
|
3865
5382
|
var e = t(function* () {
|
|
3866
5383
|
var e, t;
|
|
3867
5384
|
if (h.appliedPuzzleOverride !== null) return h.appliedPuzzleOverride;
|
|
@@ -3876,57 +5393,57 @@ function Ut(n = {}) {
|
|
|
3876
5393
|
puzzle: i
|
|
3877
5394
|
}), h.originalPuzzle = a;
|
|
3878
5395
|
let o = k("#simulator-puzzle");
|
|
3879
|
-
return o && (o.value = h.originalPuzzle), h.activeTab === "thumb" &&
|
|
5396
|
+
return o && (o.value = h.originalPuzzle), h.activeTab === "thumb" && L(), h.puzzleData;
|
|
3880
5397
|
});
|
|
3881
5398
|
return function() {
|
|
3882
5399
|
return e.apply(this, arguments);
|
|
3883
5400
|
};
|
|
3884
|
-
}(),
|
|
3885
|
-
d.addLogEntry(e,
|
|
3886
|
-
}),
|
|
3887
|
-
|
|
3888
|
-
},
|
|
5401
|
+
}(), z = re((e) => {
|
|
5402
|
+
d.addLogEntry(e, H);
|
|
5403
|
+
}), B = (e, t) => {
|
|
5404
|
+
M(e, t, z);
|
|
5405
|
+
}, V = (e, t) => {
|
|
3889
5406
|
let n = _.querySelector(`[data-badge="${e}"]`);
|
|
3890
5407
|
n && (n.textContent = t && t > 0 ? String(t) : "");
|
|
3891
|
-
},
|
|
5408
|
+
}, H = {
|
|
3892
5409
|
state: h,
|
|
3893
5410
|
getElement: k,
|
|
3894
|
-
sendToGame:
|
|
3895
|
-
logMessage:
|
|
3896
|
-
loadPuzzle:
|
|
5411
|
+
sendToGame: B,
|
|
5412
|
+
logMessage: z.log,
|
|
5413
|
+
loadPuzzle: R,
|
|
3897
5414
|
updateStatus: j,
|
|
3898
|
-
updateTimer:
|
|
3899
|
-
setCollapsed:
|
|
3900
|
-
switchTab:
|
|
3901
|
-
updateThumbnail:
|
|
3902
|
-
updateBadge:
|
|
5415
|
+
updateTimer: P,
|
|
5416
|
+
setCollapsed: I,
|
|
5417
|
+
switchTab: F,
|
|
5418
|
+
updateThumbnail: L,
|
|
5419
|
+
updateBadge: V,
|
|
3903
5420
|
fixtures: l,
|
|
3904
5421
|
fixtureCategories: u,
|
|
3905
5422
|
gameSlug: (s = n.slug) == null ? null : s
|
|
3906
5423
|
};
|
|
3907
|
-
console.log("[Simulator] Context created with gameSlug:",
|
|
5424
|
+
console.log("[Simulator] Context created with gameSlug:", H.gameSlug), p.forEach((e) => e.bind(H)), D.querySelectorAll(".simulator-tab").forEach((e) => {
|
|
3908
5425
|
e.addEventListener("click", () => {
|
|
3909
5426
|
let t = e.getAttribute("data-tab");
|
|
3910
|
-
|
|
5427
|
+
F(t), V(t, 0);
|
|
3911
5428
|
});
|
|
3912
5429
|
}), T.addEventListener("click", (e) => {
|
|
3913
|
-
e.stopPropagation(),
|
|
5430
|
+
e.stopPropagation(), I(!0);
|
|
3914
5431
|
}), S.addEventListener("click", (e) => {
|
|
3915
|
-
e.stopPropagation(), h.isPaused ? (
|
|
5432
|
+
e.stopPropagation(), h.isPaused ? (B("RESUME_GAME", {}), h.isPaused = !1, A(!1), j("Running", "ready")) : (B("PAUSE_GAME", {}), h.isPaused = !0, A(!0), j("Paused", "paused"));
|
|
3916
5433
|
let t = k("#simulator-pause");
|
|
3917
5434
|
t && (t.textContent = h.isPaused ? "Resume" : "Pause");
|
|
3918
5435
|
}), C.addEventListener("click", (e) => {
|
|
3919
|
-
e.stopPropagation(),
|
|
5436
|
+
e.stopPropagation(), B("RETRY_PUZZLE", {}), h.hasStarted = !1, h.isPaused = !1, A(!1), S.disabled = !0, j("Ready to retry", "ready");
|
|
3920
5437
|
let t = k("#simulator-pause"), n = k("#simulator-start");
|
|
3921
5438
|
t && (t.disabled = !0, t.textContent = "Pause"), n && (n.textContent = "Start");
|
|
3922
5439
|
}), w.addEventListener("click", (e) => {
|
|
3923
|
-
e.stopPropagation(), h.isCollapsed &&
|
|
5440
|
+
e.stopPropagation(), h.isCollapsed && I(!1), F("auth");
|
|
3924
5441
|
}), y.addEventListener("click", (e) => {
|
|
3925
|
-
h.isCollapsed && e.target !== T &&
|
|
3926
|
-
}), h.isCollapsed ||
|
|
3927
|
-
let
|
|
3928
|
-
(
|
|
3929
|
-
let
|
|
5442
|
+
h.isCollapsed && e.target !== T && I(!1);
|
|
5443
|
+
}), h.isCollapsed || F(h.activeTab);
|
|
5444
|
+
let U = new URLSearchParams(window.location.search);
|
|
5445
|
+
(U.has("code") || U.has("error")) && (I(!1), F("auth"));
|
|
5446
|
+
let ce = (e) => {
|
|
3930
5447
|
let t = {
|
|
3931
5448
|
additionalTimeAddedSecs: 0,
|
|
3932
5449
|
boardState: h.currentInputStr,
|
|
@@ -3959,7 +5476,7 @@ function Ut(n = {}) {
|
|
|
3959
5476
|
type: "User",
|
|
3960
5477
|
roles: ""
|
|
3961
5478
|
},
|
|
3962
|
-
game:
|
|
5479
|
+
game: Kt,
|
|
3963
5480
|
session: {
|
|
3964
5481
|
gameplay: t,
|
|
3965
5482
|
puzzle: n
|
|
@@ -3968,12 +5485,12 @@ function Ut(n = {}) {
|
|
|
3968
5485
|
hostContext: h.hostContext,
|
|
3969
5486
|
appRuntimeContract: "1.0"
|
|
3970
5487
|
};
|
|
3971
|
-
},
|
|
5488
|
+
}, W = function() {
|
|
3972
5489
|
var n = t(function* (t) {
|
|
3973
5490
|
j("Loading puzzle...", "waiting");
|
|
3974
5491
|
try {
|
|
3975
|
-
let n = e(e({},
|
|
3976
|
-
j("Sending READY_DATA...", "waiting"),
|
|
5492
|
+
let n = e(e({}, ce(yield R())), {}, { appRuntimeContract: t });
|
|
5493
|
+
j("Sending READY_DATA...", "waiting"), B("READY_DATA", n), j("Waiting for game to load...", "waiting");
|
|
3977
5494
|
} catch (e) {
|
|
3978
5495
|
j(`Error: ${e}`, "paused");
|
|
3979
5496
|
}
|
|
@@ -3981,29 +5498,29 @@ function Ut(n = {}) {
|
|
|
3981
5498
|
return function(e) {
|
|
3982
5499
|
return n.apply(this, arguments);
|
|
3983
5500
|
};
|
|
3984
|
-
}(),
|
|
5501
|
+
}(), G = () => {
|
|
3985
5502
|
console.log("Simulator: Game loaded, ready to start"), C.disabled = !1, p.forEach((e) => {
|
|
3986
5503
|
var t;
|
|
3987
|
-
return (t = e.onMessage) == null ? void 0 : t.call(e, "READY_GAME_LOADED", void 0,
|
|
5504
|
+
return (t = e.onMessage) == null ? void 0 : t.call(e, "READY_GAME_LOADED", void 0, H);
|
|
3988
5505
|
}), c && !h.hasStarted && setTimeout(() => {
|
|
3989
5506
|
let e = k("#simulator-start");
|
|
3990
5507
|
e == null || e.click(), S.disabled = !1, h.hasStarted = !0, j("Running", "ready");
|
|
3991
5508
|
}, 100);
|
|
3992
5509
|
};
|
|
3993
|
-
return
|
|
5510
|
+
return N((e, t) => {
|
|
3994
5511
|
var n, r;
|
|
3995
5512
|
if (e === "READY") {
|
|
3996
|
-
console.log("Simulator: Received READY from game"),
|
|
5513
|
+
console.log("Simulator: Received READY from game"), W((t == null ? void 0 : t.runtimeContract) === "1.1" ? "1.1" : "1.0");
|
|
3997
5514
|
return;
|
|
3998
5515
|
}
|
|
3999
5516
|
if (e === "READY_GAME_LOADED") {
|
|
4000
|
-
|
|
5517
|
+
G();
|
|
4001
5518
|
return;
|
|
4002
5519
|
}
|
|
4003
5520
|
if (e === "TIMER_TICK") {
|
|
4004
5521
|
if (t != null && t.display) {
|
|
4005
5522
|
let [e, n] = t.display;
|
|
4006
|
-
|
|
5523
|
+
P(e, n);
|
|
4007
5524
|
}
|
|
4008
5525
|
return;
|
|
4009
5526
|
}
|
|
@@ -4014,30 +5531,30 @@ function Ut(n = {}) {
|
|
|
4014
5531
|
}
|
|
4015
5532
|
p.forEach((n) => {
|
|
4016
5533
|
var r;
|
|
4017
|
-
return (r = n.onMessage) == null ? void 0 : r.call(n, e, t,
|
|
5534
|
+
return (r = n.onMessage) == null ? void 0 : r.call(n, e, t, H);
|
|
4018
5535
|
});
|
|
4019
5536
|
let i = (n = t == null || (r = t.input) == null ? void 0 : r.boardState) == null ? t == null ? void 0 : t.boardState : n;
|
|
4020
|
-
e === "UPLOAD_NEW_GAME_STATE" && i && (h.currentInputStr = i, h.activeTab === "thumb" &&
|
|
4021
|
-
},
|
|
5537
|
+
e === "UPLOAD_NEW_GAME_STATE" && i && (h.currentInputStr = i, h.activeTab === "thumb" && L(), console.log("Simulator: Game state uploaded", t)), e === "GAME_COMPLETED" && (console.log("Simulator: Game completed!", t), S.disabled = !0, h.hasStarted = !1, j("Completed!", "complete"));
|
|
5538
|
+
}, z), console.log("Simulator initialized"), $ = {
|
|
4022
5539
|
updateFixtures: (e) => {
|
|
4023
|
-
l =
|
|
5540
|
+
l = ie(e), u = Array.from(l.keys()).sort(), H.fixtures = l, H.fixtureCategories = u;
|
|
4024
5541
|
let t = localStorage.getItem("simulator-fixture-category");
|
|
4025
5542
|
if (!h.selectedCategory || !u.includes(h.selectedCategory)) {
|
|
4026
5543
|
var n;
|
|
4027
5544
|
h.selectedCategory = t && u.includes(t) ? t : (n = u[0]) == null ? null : n;
|
|
4028
5545
|
}
|
|
4029
5546
|
let r = p.find((e) => e.id === "ctrl");
|
|
4030
|
-
r == null || r.bind(
|
|
5547
|
+
r == null || r.bind(H), console.log("Simulator: Fixtures updated", {
|
|
4031
5548
|
categories: u,
|
|
4032
5549
|
selectedCategory: h.selectedCategory
|
|
4033
5550
|
});
|
|
4034
5551
|
},
|
|
4035
|
-
sendToGame:
|
|
4036
|
-
loadPuzzle:
|
|
5552
|
+
sendToGame: B,
|
|
5553
|
+
loadPuzzle: R
|
|
4037
5554
|
}, $;
|
|
4038
5555
|
}
|
|
4039
5556
|
/** The game the simulator stands in for, with placeholder IDs since nothing is stored */
|
|
4040
|
-
var
|
|
5557
|
+
var Kt = {
|
|
4041
5558
|
id: "simulator-game",
|
|
4042
5559
|
slug: "proto-game",
|
|
4043
5560
|
stableSlug: "proto-game",
|
|
@@ -4053,6 +5570,6 @@ var Wt = {
|
|
|
4053
5570
|
}
|
|
4054
5571
|
}
|
|
4055
5572
|
};
|
|
4056
|
-
export {
|
|
5573
|
+
export { Bt as n, ae as r, Gt as t };
|
|
4057
5574
|
|
|
4058
|
-
//# sourceMappingURL=createSimulator-
|
|
5575
|
+
//# sourceMappingURL=createSimulator-DUZOd1Hx.js.map
|