@m2c2kit/core 0.3.19 → 0.3.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1556,6 +1556,7 @@ declare class Game implements Activity {
1556
1556
  */
1557
1557
  resolveGameBaseUrls(game: Game): Promise<GameBaseUrls>;
1558
1558
  private configureI18n;
1559
+ private waitForErudaInitialization;
1559
1560
  initialize(): Promise<void>;
1560
1561
  /**
1561
1562
  * Returns the manifest, if manifest.json was created during the build.
@@ -3665,6 +3666,7 @@ declare class Constants {
3665
3666
  /** Placeholder that will be populated during the build process. */
3666
3667
  static readonly MODULE_METADATA_PLACEHOLDER: ModuleMetadata;
3667
3668
  static readonly DEFAULT_ROOT_ELEMENT_ID = "m2c2kit";
3669
+ static readonly ERUDA_URL = "https://cdn.jsdelivr.net/npm/eruda@3.2.1/eruda.js";
3668
3670
  }
3669
3671
 
3670
3672
  /**
@@ -3840,6 +3842,29 @@ declare class M2c2KitHelpers {
3840
3842
  * "https://", "file://", etc.)
3841
3843
  */
3842
3844
  static urlHasScheme(url: string): boolean;
3845
+ /**
3846
+ * Load scripts from URLs.
3847
+ *
3848
+ * @remarks This is for debugging purposes only. If this is unwanted, it
3849
+ * can be disabled on the server side with an appropriate Content
3850
+ * Security Policy (CSP) header.
3851
+ *
3852
+ * @param urls - URLs with scripts to load
3853
+ */
3854
+ static loadScriptUrls(urls: string[]): void;
3855
+ /**
3856
+ * Loads eruda from a CDN and initializes it.
3857
+ *
3858
+ * @remarks This is for debugging purposes only. If this is unwanted, it
3859
+ * can be disabled on the server side with an appropriate Content
3860
+ * Security Policy (CSP) header.
3861
+ * eruda is a dev console overlay for mobile web browsers and web views.
3862
+ * see https://github.com/liriliri/eruda
3863
+ *
3864
+ * @param pollingIntervalMs - milliseconds between each attempt
3865
+ * @param maxAttempts - how many attempts to make
3866
+ */
3867
+ static loadEruda(pollingIntervalMs?: number, maxAttempts?: number): void;
3843
3868
  /**
3844
3869
  * Registers a `M2Node` class with the global class registry.
3845
3870
  *
@@ -4048,6 +4073,9 @@ interface GlobalVariables {
4048
4073
  rootScale: number;
4049
4074
  canvasCssWidth: number;
4050
4075
  canvasCssHeight: number;
4076
+ erudaRequested?: boolean;
4077
+ erudaInitialized?: boolean;
4078
+ addedScriptUrls: string[];
4051
4079
  /**
4052
4080
  * A dictionary of all `M2Node` classes that have been registered.
4053
4081
  * This is used to instantiate `M2Node` objects from their class name.
package/dist/index.js CHANGED
@@ -499,6 +499,190 @@ const _Timer = class _Timer {
499
499
  _Timer._timers = new Array();
500
500
  let Timer = _Timer;
501
501
 
502
+ class WebColors {
503
+ }
504
+ WebColors.Transparent = [0, 0, 0, 0];
505
+ WebColors.MediumVioletRed = [199, 21, 133, 1];
506
+ WebColors.DeepPink = [255, 20, 147, 1];
507
+ WebColors.PaleVioletRed = [219, 112, 147, 1];
508
+ WebColors.HotPink = [255, 105, 180, 1];
509
+ WebColors.LightPink = [255, 182, 193, 1];
510
+ WebColors.Pink = [255, 192, 203, 1];
511
+ WebColors.DarkRed = [139, 0, 0, 1];
512
+ WebColors.Red = [255, 0, 0, 1];
513
+ WebColors.Firebrick = [178, 34, 34, 1];
514
+ WebColors.Crimson = [220, 20, 60, 1];
515
+ WebColors.IndianRed = [205, 92, 92, 1];
516
+ WebColors.LightCoral = [240, 128, 128, 1];
517
+ WebColors.Salmon = [250, 128, 114, 1];
518
+ WebColors.DarkSalmon = [233, 150, 122, 1];
519
+ WebColors.LightSalmon = [255, 160, 122, 1];
520
+ WebColors.OrangeRed = [255, 69, 0, 1];
521
+ WebColors.Tomato = [255, 99, 71, 1];
522
+ WebColors.DarkOrange = [255, 140, 0, 1];
523
+ WebColors.Coral = [255, 127, 80, 1];
524
+ WebColors.Orange = [255, 165, 0, 1];
525
+ WebColors.DarkKhaki = [189, 183, 107, 1];
526
+ WebColors.Gold = [255, 215, 0, 1];
527
+ WebColors.Khaki = [240, 230, 140, 1];
528
+ WebColors.PeachPuff = [255, 218, 185, 1];
529
+ WebColors.Yellow = [255, 255, 0, 1];
530
+ WebColors.PaleGoldenrod = [238, 232, 170, 1];
531
+ WebColors.Moccasin = [255, 228, 181, 1];
532
+ WebColors.PapayaWhip = [255, 239, 213, 1];
533
+ WebColors.LightGoldenrodYellow = [250, 250, 210, 1];
534
+ WebColors.LemonChiffon = [255, 250, 205, 1];
535
+ WebColors.LightYellow = [255, 255, 224, 1];
536
+ WebColors.Maroon = [128, 0, 0, 1];
537
+ WebColors.Brown = [165, 42, 42, 1];
538
+ WebColors.SaddleBrown = [139, 69, 19, 1];
539
+ WebColors.Sienna = [160, 82, 45, 1];
540
+ WebColors.Chocolate = [210, 105, 30, 1];
541
+ WebColors.DarkGoldenrod = [184, 134, 11, 1];
542
+ WebColors.Peru = [205, 133, 63, 1];
543
+ WebColors.RosyBrown = [188, 143, 143, 1];
544
+ WebColors.Goldenrod = [218, 165, 32, 1];
545
+ WebColors.SandyBrown = [244, 164, 96, 1];
546
+ WebColors.Tan = [210, 180, 140, 1];
547
+ WebColors.Burlywood = [222, 184, 135, 1];
548
+ WebColors.Wheat = [245, 222, 179, 1];
549
+ WebColors.NavajoWhite = [255, 222, 173, 1];
550
+ WebColors.Bisque = [255, 228, 196, 1];
551
+ WebColors.BlanchedAlmond = [255, 235, 205, 1];
552
+ WebColors.Cornsilk = [255, 248, 220, 1];
553
+ WebColors.DarkGreen = [0, 100, 0, 1];
554
+ WebColors.Green = [0, 128, 0, 1];
555
+ WebColors.DarkOliveGreen = [85, 107, 47, 1];
556
+ WebColors.ForestGreen = [34, 139, 34, 1];
557
+ WebColors.SeaGreen = [46, 139, 87, 1];
558
+ WebColors.Olive = [128, 128, 0, 1];
559
+ WebColors.OliveDrab = [107, 142, 35, 1];
560
+ WebColors.MediumSeaGreen = [60, 179, 113, 1];
561
+ WebColors.LimeGreen = [50, 205, 50, 1];
562
+ WebColors.Lime = [0, 255, 0, 1];
563
+ WebColors.SpringGreen = [0, 255, 127, 1];
564
+ WebColors.MediumSpringGreen = [0, 250, 154, 1];
565
+ WebColors.DarkSeaGreen = [143, 188, 143, 1];
566
+ WebColors.MediumAquamarine = [102, 205, 170, 1];
567
+ WebColors.YellowGreen = [154, 205, 50, 1];
568
+ WebColors.LawnGreen = [124, 252, 0, 1];
569
+ WebColors.Chartreuse = [127, 255, 0, 1];
570
+ WebColors.LightGreen = [144, 238, 144, 1];
571
+ WebColors.GreenYellow = [173, 255, 47, 1];
572
+ WebColors.PaleGreen = [152, 251, 152, 1];
573
+ WebColors.Teal = [0, 128, 128, 1];
574
+ WebColors.DarkCyan = [0, 139, 139, 1];
575
+ WebColors.LightSeaGreen = [32, 178, 170, 1];
576
+ WebColors.CadetBlue = [95, 158, 160, 1];
577
+ WebColors.DarkTurquoise = [0, 206, 209, 1];
578
+ WebColors.MediumTurquoise = [72, 209, 204, 1];
579
+ WebColors.Turquoise = [64, 224, 208, 1];
580
+ WebColors.Aqua = [0, 255, 255, 1];
581
+ WebColors.Cyan = [0, 255, 255, 1];
582
+ WebColors.Aquamarine = [127, 255, 212, 1];
583
+ WebColors.PaleTurquoise = [175, 238, 238, 1];
584
+ WebColors.LightCyan = [224, 255, 255, 1];
585
+ WebColors.Navy = [0, 0, 128, 1];
586
+ WebColors.DarkBlue = [0, 0, 139, 1];
587
+ WebColors.MediumBlue = [0, 0, 205, 1];
588
+ WebColors.Blue = [0, 0, 255, 1];
589
+ WebColors.MidnightBlue = [25, 25, 112, 1];
590
+ WebColors.RoyalBlue = [65, 105, 225, 1];
591
+ WebColors.SteelBlue = [70, 130, 180, 1];
592
+ WebColors.DodgerBlue = [30, 144, 255, 1];
593
+ WebColors.DeepSkyBlue = [0, 191, 255, 1];
594
+ WebColors.CornflowerBlue = [100, 149, 237, 1];
595
+ WebColors.SkyBlue = [135, 206, 235, 1];
596
+ WebColors.LightSkyBlue = [135, 206, 250, 1];
597
+ WebColors.LightSteelBlue = [176, 196, 222, 1];
598
+ WebColors.LightBlue = [173, 216, 230, 1];
599
+ WebColors.PowderBlue = [176, 224, 230, 1];
600
+ WebColors.Indigo = [75, 0, 130, 1];
601
+ WebColors.Purple = [128, 0, 128, 1];
602
+ WebColors.DarkMagenta = [139, 0, 139, 1];
603
+ WebColors.DarkViolet = [148, 0, 211, 1];
604
+ WebColors.DarkSlateBlue = [72, 61, 139, 1];
605
+ WebColors.BlueViolet = [138, 43, 226, 1];
606
+ WebColors.DarkOrchid = [153, 50, 204, 1];
607
+ WebColors.Fuchsia = [255, 0, 255, 1];
608
+ WebColors.Magenta = [255, 0, 255, 1];
609
+ WebColors.SlateBlue = [106, 90, 205, 1];
610
+ WebColors.MediumSlateBlue = [123, 104, 238, 1];
611
+ WebColors.MediumOrchid = [186, 85, 211, 1];
612
+ WebColors.MediumPurple = [147, 112, 219, 1];
613
+ WebColors.Orchid = [218, 112, 214, 1];
614
+ WebColors.Violet = [238, 130, 238, 1];
615
+ WebColors.Plum = [221, 160, 221, 1];
616
+ WebColors.Thistle = [216, 191, 216, 1];
617
+ WebColors.Lavender = [230, 230, 250, 1];
618
+ WebColors.MistyRose = [255, 228, 225, 1];
619
+ WebColors.AntiqueWhite = [250, 235, 215, 1];
620
+ WebColors.Linen = [250, 240, 230, 1];
621
+ WebColors.Beige = [245, 245, 220, 1];
622
+ WebColors.WhiteSmoke = [245, 245, 245, 1];
623
+ WebColors.LavenderBlush = [255, 240, 245, 1];
624
+ WebColors.OldLace = [253, 245, 230, 1];
625
+ WebColors.AliceBlue = [240, 248, 255, 1];
626
+ WebColors.Seashell = [255, 245, 238, 1];
627
+ WebColors.GhostWhite = [248, 248, 255, 1];
628
+ WebColors.Honeydew = [240, 255, 240, 1];
629
+ WebColors.FloralWhite = [255, 250, 240, 1];
630
+ WebColors.Azure = [240, 255, 255, 1];
631
+ WebColors.MintCream = [245, 255, 250, 1];
632
+ WebColors.Snow = [255, 250, 250, 1];
633
+ WebColors.Ivory = [255, 255, 240, 1];
634
+ WebColors.White = [255, 255, 255, 1];
635
+ WebColors.Black = [0, 0, 0, 1];
636
+ WebColors.DarkSlateGray = [47, 79, 79, 1];
637
+ WebColors.DimGray = [105, 105, 105, 1];
638
+ WebColors.SlateGray = [112, 128, 144, 1];
639
+ WebColors.Gray = [128, 128, 128, 1];
640
+ WebColors.LightSlateGray = [119, 136, 153, 1];
641
+ WebColors.DarkGray = [169, 169, 169, 1];
642
+ WebColors.Silver = [192, 192, 192, 1];
643
+ WebColors.LightGray = [211, 211, 211, 1];
644
+ WebColors.Gainsboro = [220, 220, 220, 1];
645
+ WebColors.RebeccaPurple = [102, 51, 153, 1];
646
+
647
+ class Constants {
648
+ }
649
+ /** Size of the font showing frames per second */
650
+ Constants.FPS_DISPLAY_TEXT_FONT_SIZE = 12;
651
+ /** Color of the font showing frames per second */
652
+ Constants.FPS_DISPLAY_TEXT_COLOR = [0, 0, 0, 0.5];
653
+ /** Frequency, in milliseconds, at which to update frames per second metric shown on the screen */
654
+ Constants.FPS_DISPLAY_UPDATE_INTERVAL = 1e3;
655
+ /** Maximum number of activity metrics to log. */
656
+ Constants.MAXIMUM_RECORDED_ACTIVITY_METRICS = 32;
657
+ /** The frames per second will be logged in game metrics if the FPS is lower than this value */
658
+ Constants.FPS_METRIC_REPORT_THRESHOLD = 59;
659
+ /** Scene color, if none is specified. */
660
+ Constants.DEFAULT_SCENE_BACKGROUND_COLOR = WebColors.White;
661
+ /** Shape fill color, if none is specified. */
662
+ Constants.DEFAULT_SHAPE_FILL_COLOR = WebColors.Red;
663
+ /** Color of paths in a shape, if none is specified. */
664
+ Constants.DEFAULT_PATH_STROKE_COLOR = WebColors.Red;
665
+ /** Line width of paths in a shape, if none is specified. */
666
+ Constants.DEFAULT_PATH_LINE_WIDTH = 2;
667
+ /** Color of text in Label and TextLine, if none is specified. */
668
+ Constants.DEFAULT_FONT_COLOR = WebColors.Black;
669
+ /** Font size in Label and TextLine, if none is specified. */
670
+ Constants.DEFAULT_FONT_SIZE = 16;
671
+ Constants.LIMITED_FPS_RATE = 5;
672
+ Constants.FREE_NODES_SCENE_NAME = "__freeNodesScene";
673
+ Constants.OUTGOING_SCENE_NAME = "__outgoingScene";
674
+ Constants.OUTGOING_SCENE_SPRITE_NAME = "__outgoingSceneSprite";
675
+ Constants.OUTGOING_SCENE_IMAGE_NAME = "__outgoingSceneSnapshot";
676
+ Constants.SESSION_INITIALIZATION_POLLING_INTERVAL_MS = 50;
677
+ /** Placeholder that will be populated during the build process. */
678
+ Constants.MODULE_METADATA_PLACEHOLDER = {
679
+ name: "",
680
+ version: "",
681
+ dependencies: {}
682
+ };
683
+ Constants.DEFAULT_ROOT_ELEMENT_ID = "m2c2kit";
684
+ Constants.ERUDA_URL = "https://cdn.jsdelivr.net/npm/eruda@3.2.1/eruda.js";
685
+
502
686
  class M2c2KitHelpers {
503
687
  /**
504
688
  * Returns the URL as it appears in the game's manifest.json file.
@@ -526,6 +710,73 @@ class M2c2KitHelpers {
526
710
  static urlHasScheme(url) {
527
711
  return /^[a-z]+:\/\//i.test(url);
528
712
  }
713
+ /**
714
+ * Load scripts from URLs.
715
+ *
716
+ * @remarks This is for debugging purposes only. If this is unwanted, it
717
+ * can be disabled on the server side with an appropriate Content
718
+ * Security Policy (CSP) header.
719
+ *
720
+ * @param urls - URLs with scripts to load
721
+ */
722
+ static loadScriptUrls(urls) {
723
+ if (!Array.isArray(urls) || !urls.every((s) => typeof s === "string")) {
724
+ console.warn(
725
+ `Error parsing "scripts" parameter. "scripts" must be an array of URL strings, and it is recommended to be URI encoded.`
726
+ );
727
+ return;
728
+ }
729
+ urls.forEach((url) => {
730
+ if (!m2c2Globals.addedScriptUrls.includes(url)) {
731
+ const script = document.createElement("script");
732
+ script.src = url;
733
+ script.async = true;
734
+ document.head.appendChild(script);
735
+ console.log(`\u26AA added script: ${url}`);
736
+ m2c2Globals.addedScriptUrls.push(url);
737
+ }
738
+ });
739
+ }
740
+ /**
741
+ * Loads eruda from a CDN and initializes it.
742
+ *
743
+ * @remarks This is for debugging purposes only. If this is unwanted, it
744
+ * can be disabled on the server side with an appropriate Content
745
+ * Security Policy (CSP) header.
746
+ * eruda is a dev console overlay for mobile web browsers and web views.
747
+ * see https://github.com/liriliri/eruda
748
+ *
749
+ * @param pollingIntervalMs - milliseconds between each attempt
750
+ * @param maxAttempts - how many attempts to make
751
+ */
752
+ static loadEruda(pollingIntervalMs = 100, maxAttempts = 50) {
753
+ if (m2c2Globals.erudaRequested === true) {
754
+ return;
755
+ }
756
+ console.log(`\u26AA added eruda script: ${Constants.ERUDA_URL}`);
757
+ const script = document.createElement("script");
758
+ script.src = Constants.ERUDA_URL;
759
+ script.async = true;
760
+ document.head.appendChild(script);
761
+ m2c2Globals.erudaRequested = true;
762
+ let attempts = 0;
763
+ const waitForEruda = () => {
764
+ const eruda = window?.eruda;
765
+ if (typeof eruda !== "undefined") {
766
+ console.log("\u26AA eruda ready");
767
+ eruda.init();
768
+ m2c2Globals.erudaInitialized = true;
769
+ } else if (attempts < maxAttempts) {
770
+ attempts++;
771
+ setTimeout(waitForEruda, pollingIntervalMs);
772
+ } else {
773
+ console.log(
774
+ `eruda was requested, but could not be loaded after ${pollingIntervalMs * maxAttempts} milliseconds.`
775
+ );
776
+ }
777
+ };
778
+ waitForEruda();
779
+ }
529
780
  /**
530
781
  * Registers a `M2Node` class with the global class registry.
531
782
  *
@@ -2026,189 +2277,6 @@ class MutablePath {
2026
2277
  }
2027
2278
  }
2028
2279
 
2029
- class WebColors {
2030
- }
2031
- WebColors.Transparent = [0, 0, 0, 0];
2032
- WebColors.MediumVioletRed = [199, 21, 133, 1];
2033
- WebColors.DeepPink = [255, 20, 147, 1];
2034
- WebColors.PaleVioletRed = [219, 112, 147, 1];
2035
- WebColors.HotPink = [255, 105, 180, 1];
2036
- WebColors.LightPink = [255, 182, 193, 1];
2037
- WebColors.Pink = [255, 192, 203, 1];
2038
- WebColors.DarkRed = [139, 0, 0, 1];
2039
- WebColors.Red = [255, 0, 0, 1];
2040
- WebColors.Firebrick = [178, 34, 34, 1];
2041
- WebColors.Crimson = [220, 20, 60, 1];
2042
- WebColors.IndianRed = [205, 92, 92, 1];
2043
- WebColors.LightCoral = [240, 128, 128, 1];
2044
- WebColors.Salmon = [250, 128, 114, 1];
2045
- WebColors.DarkSalmon = [233, 150, 122, 1];
2046
- WebColors.LightSalmon = [255, 160, 122, 1];
2047
- WebColors.OrangeRed = [255, 69, 0, 1];
2048
- WebColors.Tomato = [255, 99, 71, 1];
2049
- WebColors.DarkOrange = [255, 140, 0, 1];
2050
- WebColors.Coral = [255, 127, 80, 1];
2051
- WebColors.Orange = [255, 165, 0, 1];
2052
- WebColors.DarkKhaki = [189, 183, 107, 1];
2053
- WebColors.Gold = [255, 215, 0, 1];
2054
- WebColors.Khaki = [240, 230, 140, 1];
2055
- WebColors.PeachPuff = [255, 218, 185, 1];
2056
- WebColors.Yellow = [255, 255, 0, 1];
2057
- WebColors.PaleGoldenrod = [238, 232, 170, 1];
2058
- WebColors.Moccasin = [255, 228, 181, 1];
2059
- WebColors.PapayaWhip = [255, 239, 213, 1];
2060
- WebColors.LightGoldenrodYellow = [250, 250, 210, 1];
2061
- WebColors.LemonChiffon = [255, 250, 205, 1];
2062
- WebColors.LightYellow = [255, 255, 224, 1];
2063
- WebColors.Maroon = [128, 0, 0, 1];
2064
- WebColors.Brown = [165, 42, 42, 1];
2065
- WebColors.SaddleBrown = [139, 69, 19, 1];
2066
- WebColors.Sienna = [160, 82, 45, 1];
2067
- WebColors.Chocolate = [210, 105, 30, 1];
2068
- WebColors.DarkGoldenrod = [184, 134, 11, 1];
2069
- WebColors.Peru = [205, 133, 63, 1];
2070
- WebColors.RosyBrown = [188, 143, 143, 1];
2071
- WebColors.Goldenrod = [218, 165, 32, 1];
2072
- WebColors.SandyBrown = [244, 164, 96, 1];
2073
- WebColors.Tan = [210, 180, 140, 1];
2074
- WebColors.Burlywood = [222, 184, 135, 1];
2075
- WebColors.Wheat = [245, 222, 179, 1];
2076
- WebColors.NavajoWhite = [255, 222, 173, 1];
2077
- WebColors.Bisque = [255, 228, 196, 1];
2078
- WebColors.BlanchedAlmond = [255, 235, 205, 1];
2079
- WebColors.Cornsilk = [255, 248, 220, 1];
2080
- WebColors.DarkGreen = [0, 100, 0, 1];
2081
- WebColors.Green = [0, 128, 0, 1];
2082
- WebColors.DarkOliveGreen = [85, 107, 47, 1];
2083
- WebColors.ForestGreen = [34, 139, 34, 1];
2084
- WebColors.SeaGreen = [46, 139, 87, 1];
2085
- WebColors.Olive = [128, 128, 0, 1];
2086
- WebColors.OliveDrab = [107, 142, 35, 1];
2087
- WebColors.MediumSeaGreen = [60, 179, 113, 1];
2088
- WebColors.LimeGreen = [50, 205, 50, 1];
2089
- WebColors.Lime = [0, 255, 0, 1];
2090
- WebColors.SpringGreen = [0, 255, 127, 1];
2091
- WebColors.MediumSpringGreen = [0, 250, 154, 1];
2092
- WebColors.DarkSeaGreen = [143, 188, 143, 1];
2093
- WebColors.MediumAquamarine = [102, 205, 170, 1];
2094
- WebColors.YellowGreen = [154, 205, 50, 1];
2095
- WebColors.LawnGreen = [124, 252, 0, 1];
2096
- WebColors.Chartreuse = [127, 255, 0, 1];
2097
- WebColors.LightGreen = [144, 238, 144, 1];
2098
- WebColors.GreenYellow = [173, 255, 47, 1];
2099
- WebColors.PaleGreen = [152, 251, 152, 1];
2100
- WebColors.Teal = [0, 128, 128, 1];
2101
- WebColors.DarkCyan = [0, 139, 139, 1];
2102
- WebColors.LightSeaGreen = [32, 178, 170, 1];
2103
- WebColors.CadetBlue = [95, 158, 160, 1];
2104
- WebColors.DarkTurquoise = [0, 206, 209, 1];
2105
- WebColors.MediumTurquoise = [72, 209, 204, 1];
2106
- WebColors.Turquoise = [64, 224, 208, 1];
2107
- WebColors.Aqua = [0, 255, 255, 1];
2108
- WebColors.Cyan = [0, 255, 255, 1];
2109
- WebColors.Aquamarine = [127, 255, 212, 1];
2110
- WebColors.PaleTurquoise = [175, 238, 238, 1];
2111
- WebColors.LightCyan = [224, 255, 255, 1];
2112
- WebColors.Navy = [0, 0, 128, 1];
2113
- WebColors.DarkBlue = [0, 0, 139, 1];
2114
- WebColors.MediumBlue = [0, 0, 205, 1];
2115
- WebColors.Blue = [0, 0, 255, 1];
2116
- WebColors.MidnightBlue = [25, 25, 112, 1];
2117
- WebColors.RoyalBlue = [65, 105, 225, 1];
2118
- WebColors.SteelBlue = [70, 130, 180, 1];
2119
- WebColors.DodgerBlue = [30, 144, 255, 1];
2120
- WebColors.DeepSkyBlue = [0, 191, 255, 1];
2121
- WebColors.CornflowerBlue = [100, 149, 237, 1];
2122
- WebColors.SkyBlue = [135, 206, 235, 1];
2123
- WebColors.LightSkyBlue = [135, 206, 250, 1];
2124
- WebColors.LightSteelBlue = [176, 196, 222, 1];
2125
- WebColors.LightBlue = [173, 216, 230, 1];
2126
- WebColors.PowderBlue = [176, 224, 230, 1];
2127
- WebColors.Indigo = [75, 0, 130, 1];
2128
- WebColors.Purple = [128, 0, 128, 1];
2129
- WebColors.DarkMagenta = [139, 0, 139, 1];
2130
- WebColors.DarkViolet = [148, 0, 211, 1];
2131
- WebColors.DarkSlateBlue = [72, 61, 139, 1];
2132
- WebColors.BlueViolet = [138, 43, 226, 1];
2133
- WebColors.DarkOrchid = [153, 50, 204, 1];
2134
- WebColors.Fuchsia = [255, 0, 255, 1];
2135
- WebColors.Magenta = [255, 0, 255, 1];
2136
- WebColors.SlateBlue = [106, 90, 205, 1];
2137
- WebColors.MediumSlateBlue = [123, 104, 238, 1];
2138
- WebColors.MediumOrchid = [186, 85, 211, 1];
2139
- WebColors.MediumPurple = [147, 112, 219, 1];
2140
- WebColors.Orchid = [218, 112, 214, 1];
2141
- WebColors.Violet = [238, 130, 238, 1];
2142
- WebColors.Plum = [221, 160, 221, 1];
2143
- WebColors.Thistle = [216, 191, 216, 1];
2144
- WebColors.Lavender = [230, 230, 250, 1];
2145
- WebColors.MistyRose = [255, 228, 225, 1];
2146
- WebColors.AntiqueWhite = [250, 235, 215, 1];
2147
- WebColors.Linen = [250, 240, 230, 1];
2148
- WebColors.Beige = [245, 245, 220, 1];
2149
- WebColors.WhiteSmoke = [245, 245, 245, 1];
2150
- WebColors.LavenderBlush = [255, 240, 245, 1];
2151
- WebColors.OldLace = [253, 245, 230, 1];
2152
- WebColors.AliceBlue = [240, 248, 255, 1];
2153
- WebColors.Seashell = [255, 245, 238, 1];
2154
- WebColors.GhostWhite = [248, 248, 255, 1];
2155
- WebColors.Honeydew = [240, 255, 240, 1];
2156
- WebColors.FloralWhite = [255, 250, 240, 1];
2157
- WebColors.Azure = [240, 255, 255, 1];
2158
- WebColors.MintCream = [245, 255, 250, 1];
2159
- WebColors.Snow = [255, 250, 250, 1];
2160
- WebColors.Ivory = [255, 255, 240, 1];
2161
- WebColors.White = [255, 255, 255, 1];
2162
- WebColors.Black = [0, 0, 0, 1];
2163
- WebColors.DarkSlateGray = [47, 79, 79, 1];
2164
- WebColors.DimGray = [105, 105, 105, 1];
2165
- WebColors.SlateGray = [112, 128, 144, 1];
2166
- WebColors.Gray = [128, 128, 128, 1];
2167
- WebColors.LightSlateGray = [119, 136, 153, 1];
2168
- WebColors.DarkGray = [169, 169, 169, 1];
2169
- WebColors.Silver = [192, 192, 192, 1];
2170
- WebColors.LightGray = [211, 211, 211, 1];
2171
- WebColors.Gainsboro = [220, 220, 220, 1];
2172
- WebColors.RebeccaPurple = [102, 51, 153, 1];
2173
-
2174
- class Constants {
2175
- }
2176
- /** Size of the font showing frames per second */
2177
- Constants.FPS_DISPLAY_TEXT_FONT_SIZE = 12;
2178
- /** Color of the font showing frames per second */
2179
- Constants.FPS_DISPLAY_TEXT_COLOR = [0, 0, 0, 0.5];
2180
- /** Frequency, in milliseconds, at which to update frames per second metric shown on the screen */
2181
- Constants.FPS_DISPLAY_UPDATE_INTERVAL = 1e3;
2182
- /** Maximum number of activity metrics to log. */
2183
- Constants.MAXIMUM_RECORDED_ACTIVITY_METRICS = 32;
2184
- /** The frames per second will be logged in game metrics if the FPS is lower than this value */
2185
- Constants.FPS_METRIC_REPORT_THRESHOLD = 59;
2186
- /** Scene color, if none is specified. */
2187
- Constants.DEFAULT_SCENE_BACKGROUND_COLOR = WebColors.White;
2188
- /** Shape fill color, if none is specified. */
2189
- Constants.DEFAULT_SHAPE_FILL_COLOR = WebColors.Red;
2190
- /** Color of paths in a shape, if none is specified. */
2191
- Constants.DEFAULT_PATH_STROKE_COLOR = WebColors.Red;
2192
- /** Line width of paths in a shape, if none is specified. */
2193
- Constants.DEFAULT_PATH_LINE_WIDTH = 2;
2194
- /** Color of text in Label and TextLine, if none is specified. */
2195
- Constants.DEFAULT_FONT_COLOR = WebColors.Black;
2196
- /** Font size in Label and TextLine, if none is specified. */
2197
- Constants.DEFAULT_FONT_SIZE = 16;
2198
- Constants.LIMITED_FPS_RATE = 5;
2199
- Constants.FREE_NODES_SCENE_NAME = "__freeNodesScene";
2200
- Constants.OUTGOING_SCENE_NAME = "__outgoingScene";
2201
- Constants.OUTGOING_SCENE_SPRITE_NAME = "__outgoingSceneSprite";
2202
- Constants.OUTGOING_SCENE_IMAGE_NAME = "__outgoingSceneSnapshot";
2203
- Constants.SESSION_INITIALIZATION_POLLING_INTERVAL_MS = 50;
2204
- /** Placeholder that will be populated during the build process. */
2205
- Constants.MODULE_METADATA_PLACEHOLDER = {
2206
- name: "",
2207
- version: "",
2208
- dependencies: {}
2209
- };
2210
- Constants.DEFAULT_ROOT_ELEMENT_ID = "m2c2kit";
2211
-
2212
2280
  class ColorfulMutablePath extends MutablePath {
2213
2281
  constructor() {
2214
2282
  super(...arguments);
@@ -7942,7 +8010,6 @@ class EventMaterializer {
7942
8010
  `EventMaterializer: composite node of type ${event.compositeType} with uuid ${event.target} not found when handling CompositeEvent ${event.compositeEventType}`
7943
8011
  );
7944
8012
  } else {
7945
- console.log(`calling handleCompositeEvent on composite node`);
7946
8013
  if (node.type === M2NodeType.Composite) {
7947
8014
  node.handleCompositeEvent(event);
7948
8015
  } else {
@@ -8278,6 +8345,11 @@ class Game {
8278
8345
  dependencies: {}
8279
8346
  };
8280
8347
  }
8348
+ if (options.moduleMetadata?.name && options.version) {
8349
+ console.log(
8350
+ `\u26AA ${options.moduleMetadata.name} version ${options.version}`
8351
+ );
8352
+ }
8281
8353
  }
8282
8354
  createFreeNodesScene() {
8283
8355
  this.freeNodesScene.game = this;
@@ -8384,7 +8456,29 @@ class Game {
8384
8456
  ...M2c2KitHelpers.createFrameUpdateTimestamps()
8385
8457
  });
8386
8458
  }
8459
+ async waitForErudaInitialization(maxWaitDurationMs = 5e3) {
8460
+ await new Promise((resolve) => {
8461
+ let cumulativeWaitTime = 0;
8462
+ const intervalId = setInterval(() => {
8463
+ if (m2c2Globals.erudaInitialized === true) {
8464
+ clearInterval(intervalId);
8465
+ resolve(void 0);
8466
+ }
8467
+ cumulativeWaitTime = cumulativeWaitTime + 100;
8468
+ if (cumulativeWaitTime > maxWaitDurationMs) {
8469
+ console.warn(
8470
+ `Could not initialize eruda within ${maxWaitDurationMs} milliseconds.`
8471
+ );
8472
+ clearInterval(intervalId);
8473
+ resolve(void 0);
8474
+ }
8475
+ }, 100);
8476
+ });
8477
+ }
8387
8478
  async initialize() {
8479
+ if (m2c2Globals.erudaRequested === true) {
8480
+ await this.waitForErudaInitialization();
8481
+ }
8388
8482
  if (this.options.recordEvents === true) {
8389
8483
  this.eventStore.mode = EventStoreMode.Record;
8390
8484
  }
@@ -8694,17 +8788,34 @@ class Game {
8694
8788
  setParameters(additionalParameters) {
8695
8789
  const { parameters } = this.options;
8696
8790
  Object.keys(additionalParameters).forEach((key) => {
8791
+ if (key === "eruda") {
8792
+ const erudaRequested = additionalParameters[key] === true;
8793
+ if (erudaRequested) {
8794
+ M2c2KitHelpers.loadEruda();
8795
+ }
8796
+ return;
8797
+ }
8798
+ if (key === "scripts") {
8799
+ const scriptUrls = additionalParameters[key];
8800
+ if (scriptUrls) {
8801
+ M2c2KitHelpers.loadScriptUrls(scriptUrls);
8802
+ }
8803
+ return;
8804
+ }
8697
8805
  if (!parameters || !(key in parameters)) {
8698
8806
  console.warn(
8699
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8700
8807
  `game ${this.options.name} does not have a parameter named ${key}. attempt to set parameter ${key} to value ${// eslint-disable-next-line @typescript-eslint/no-explicit-any
8701
8808
  additionalParameters[key]} will be ignored`
8702
8809
  );
8703
8810
  } else if (this.options.parameters && this.options.parameters[key]) {
8704
8811
  this.options.parameters[key].default = additionalParameters[key];
8705
8812
  }
8813
+ if (this.additionalParameters === void 0) {
8814
+ this.additionalParameters = {};
8815
+ }
8816
+ this.additionalParameters[key] = // eslint-disable-next-line @typescript-eslint/no-explicit-any
8817
+ additionalParameters[key];
8706
8818
  });
8707
- this.additionalParameters = additionalParameters;
8708
8819
  }
8709
8820
  get canvasKit() {
8710
8821
  if (!this._canvasKit) {
@@ -11052,7 +11163,8 @@ function initializeGlobalVariables() {
11052
11163
  get eventSequence() {
11053
11164
  m2c2Globals.__sequence++;
11054
11165
  return m2c2Globals.__sequence - 1;
11055
- }
11166
+ },
11167
+ addedScriptUrls: []
11056
11168
  };
11057
11169
  }
11058
11170
  initializeGlobalVariables();
@@ -11651,7 +11763,7 @@ class Story {
11651
11763
  }
11652
11764
  }
11653
11765
 
11654
- console.log("\u26AA @m2c2kit/core version 0.3.19 (0679492d)");
11766
+ console.log("\u26AA @m2c2kit/core version 0.3.20 (33cadc6d)");
11655
11767
 
11656
11768
  export { Action, ActivityType, CanvasKitHelpers, ColorfulMutablePath, Composite, Constants, ConstraintType, CustomAction, Dimensions, Easings, Equal, Equals, EventStore, EventStoreMode, FadeAlphaAction, FontManager, Game, GroupAction, I18n, ImageManager, Label, LabelHorizontalAlignmentMode, LayoutConstraint, LegacyTimer, M2EventType, M2ImageStatus, M2Node, M2NodeFactory, M2NodeType, M2SoundStatus, M2c2KitHelpers, MoveAction, MutablePath, NoneTransition, PlayAction, RandomDraws, RepeatAction, RepeatForeverAction, RotateAction, ScaleAction, Scene, SceneTransition, SequenceAction, Shape, ShapeType, SlideTransition, SoundManager, SoundPlayer, SoundRecorder, Sprite, Story, TextLine, Timer, Transition, TransitionDirection, TransitionType, Uuid, WaitAction, WebColors, WebGlInfo, handleInterfaceOptions };
11657
11769
  //# sourceMappingURL=index.js.map