Sync up master with Ember CLI branch where possible (#11707)

Sync up master with Ember CLI branch where possible (#11707)

These changes should all be safe to live in master even if they’re not being used yet.

diff --git a/app/assets/javascripts/discourse-shims.js b/app/assets/javascripts/discourse-shims.js
index 384fb92..bf4765a 100644
--- a/app/assets/javascripts/discourse-shims.js
+++ b/app/assets/javascripts/discourse-shims.js
@@ -17,10 +17,19 @@ define("message-bus-client", ["exports"], function (__exports__) {
   __exports__.default = window.MessageBus;
 });
 
+define("mousetrap-global-bind", ["exports"], function (__exports__) {
+  // In the Rails app it's applied from the vendored file
+  __exports__.default = {};
+});
+
 define("ember-buffered-proxy/proxy", ["exports"], function (__exports__) {
   __exports__.default = window.BufferedProxy;
 });
 
+define("ember-buffered-proxy/mixin", ["exports"], function (__exports__) {
+  __exports__.default = null;
+});
+
 define("bootbox", ["exports"], function (__exports__) {
   __exports__.default = window.bootbox;
 });
diff --git a/app/assets/javascripts/discourse/app/index.html b/app/assets/javascripts/discourse/app/index.html
new file mode 100644
index 0000000..3517635
--- /dev/null
+++ b/app/assets/javascripts/discourse/app/index.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <title>Discourse - Ember CLI</title>
+    <meta name="description" content="">
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+
+    {{content-for "head"}}
+  </head>
+  <body>
+    {{content-for "body"}}
+
+    <section id='main'>
+    </section>
+
+    <script src="{{rootURL}}assets/vendor.js"></script>
+    <script src="{{rootURL}}assets/discourse.js"></script>
+    <script src="{{rootURL}}assets/admin.js"></script>
+    <script src="{{rootURL}}assets/scripts/discourse-boot.js"></script>
+
+    <script>
+      document.addEventListener("discourse-booted", (e) => {
+        const config = e.detail;
+        const app = require(`${config.modulePrefix}/app`)["default"].create(
+          config
+        );
+        app.start();
+      });
+    </script>
+
+    {{content-for "body-footer"}}
+  </body>
+</html>
diff --git a/app/assets/javascripts/discourse/app/initializers/keyboard-shortcuts.js b/app/assets/javascripts/discourse/app/initializers/keyboard-shortcuts.js
index 59f0b2f..b5dda8a 100644
--- a/app/assets/javascripts/discourse/app/initializers/keyboard-shortcuts.js
+++ b/app/assets/javascripts/discourse/app/initializers/keyboard-shortcuts.js
@@ -1,10 +1,14 @@
 import KeyboardShortcuts from "discourse/lib/keyboard-shortcuts";
 import Mousetrap from "mousetrap";
+import bindGlobal from "mousetrap-global-bind";
 
 export default {
   name: "keyboard-shortcuts",
 
   initialize(container) {
+    // Ensure mousetrap-global-bind is executed
+    void bindGlobal;
+
     KeyboardShortcuts.init(Mousetrap, container);
     KeyboardShortcuts.bindEvents();
   },
diff --git a/app/assets/javascripts/discourse/config/environment.js b/app/assets/javascripts/discourse/config/environment.js
new file mode 100644
index 0000000..c704e44
--- /dev/null
+++ b/app/assets/javascripts/discourse/config/environment.js
@@ -0,0 +1,51 @@
+"use strict";
+
+module.exports = function (environment) {
+  let ENV = {
+    modulePrefix: "discourse",
+    environment,
+    rootURL: "/",
+    locationType: "auto",
+    EmberENV: {
+      FEATURES: {
+        // Here you can enable experimental features on an ember canary build
+        // e.g. EMBER_NATIVE_DECORATOR_SUPPORT: true
+      },
+      EXTEND_PROTOTYPES: {
+        // Prevent Ember Data from overriding Date.parse.
+        Date: false,
+      },
+    },
+
+    APP: {
+      // Here you can pass flags/options to your application instance
+      // when it is created
+    },
+  };
+
+  if (environment === "development") {
+    // ENV.APP.LOG_RESOLVER = true;
+    // ENV.APP.LOG_ACTIVE_GENERATION = true;
+    // ENV.APP.LOG_TRANSITIONS = true;
+    // ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
+    // ENV.APP.LOG_VIEW_LOOKUPS = true;
+  }
+
+  if (environment === "test") {
+    // Testem prefers this...
+    ENV.locationType = "none";
+
+    // keep test console output quieter
+    ENV.APP.LOG_ACTIVE_GENERATION = false;
+    ENV.APP.LOG_VIEW_LOOKUPS = false;
+
+    ENV.APP.rootElement = "#ember-testing";
+    ENV.APP.autoboot = false;
+  }
+
+  if (environment === "production") {
+    // here you can enable a production-specific feature
+  }
+
+  return ENV;
+};
diff --git a/app/assets/javascripts/discourse/config/optional-features.json b/app/assets/javascripts/discourse/config/optional-features.json
new file mode 100644
index 0000000..b5f4e8f
--- /dev/null
+++ b/app/assets/javascripts/discourse/config/optional-features.json
@@ -0,0 +1,5 @@
+{
+  "application-template-wrapper": false,
+  "default-async-observers": true,
+  "jquery-integration": true
+}
diff --git a/app/assets/javascripts/discourse/config/targets.js b/app/assets/javascripts/discourse/config/targets.js
new file mode 100644
index 0000000..09a137e
--- /dev/null
+++ b/app/assets/javascripts/discourse/config/targets.js
@@ -0,0 +1,18 @@
+"use strict";
+
+const browsers = [
+  "last 1 Chrome versions",
+  "last 1 Firefox versions",
+  "last 1 Safari versions",
+];
+
+const isCI = !!process.env.CI;
+const isProduction = process.env.EMBER_ENV === "production";
+
+if (isCI || isProduction) {
+  browsers.push("ie 11");
+}
+
+module.exports = {
+  browsers,
+};

GitHub sha: 4321a55b

This commit appears in #11707 which was approved by CvX. It was merged by eviltrout.