Drop support for iOS < 15.7 (#19847)

https://meta.discourse.org/t/224747
This commit is contained in:
David Taylor
2023-01-16 17:28:59 +00:00
committed by GitHub
parent 0fea826f42
commit 624f4a7de9
11 changed files with 65 additions and 376 deletions

View File

@@ -1,30 +0,0 @@
import I18n from "I18n";
import { withPluginApi } from "discourse/lib/plugin-api";
function setupMessage(api) {
const isSafari = navigator.vendor === "Apple Computer, Inc.";
if (!isSafari) {
return;
}
let safariMajorVersion = navigator.userAgent.match(/Version\/(\d+)\./)?.[1];
safariMajorVersion = safariMajorVersion
? parseInt(safariMajorVersion, 10)
: null;
if (safariMajorVersion && safariMajorVersion <= 13) {
api.addGlobalNotice(
I18n.t("safari_13_warning"),
"browser-deprecation-warning",
{ dismissable: true, dismissDuration: moment.duration(1, "week") }
);
}
}
export default {
name: "safari-13-deprecation",
initialize() {
withPluginApi("0.8.37", setupMessage);
},
};

View File

@@ -10,8 +10,7 @@ const browsers = [
];
if (isCI || isProduction) {
// https://meta.discourse.org/t/224747
browsers.push("Safari 12");
browsers.push("Safari 15");
}
module.exports = {

View File

@@ -1,7 +1,14 @@
/* eslint-disable no-var */ // `let` is not supported in very old browsers
(function () {
if (!window.WeakMap || !window.Promise || typeof globalThis === "undefined") {
if (
!window.WeakMap ||
!window.Promise ||
typeof globalThis === "undefined" ||
!String.prototype.replaceAll ||
!CSS.supports ||
!CSS.supports("aspect-ratio: 1")
) {
window.unsupportedBrowser = true;
} else {
// Some implementations of `WeakMap.prototype.has` do not accept false

View File

@@ -1,325 +1,5 @@
/* eslint-disable */
// Needed for iOS <= 13.3
if (!String.prototype.replaceAll) {
String.prototype.replaceAll = function (
pattern,
replacementStringOrFunction
) {
let regex;
if (
Object.prototype.toString.call(pattern).toLowerCase() ===
"[object regexp]"
) {
regex = pattern;
} else {
const escapedStr = pattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
regex = new RegExp(escapedStr, "g");
}
return this.replace(regex, replacementStringOrFunction);
};
}
// Needed for Safari 15.2 and below
// from: https://github.com/iamdustan/smoothscroll
(function () {
"use strict";
function e() {
var e = window;
var t = document;
if (
"scrollBehavior" in t.documentElement.style &&
e.__forceSmoothScrollPolyfill__ !== true
) {
return;
}
var o = e.HTMLElement || e.Element;
var r = 1.8;
var l = {
scroll: e.scroll || e.scrollTo,
scrollBy: e.scrollBy,
elementScroll: o.prototype.scroll || s,
scrollIntoView: o.prototype.scrollIntoView,
};
var n =
e.performance && e.performance.now
? e.performance.now.bind(e.performance)
: Date.now;
function i(e) {
var t = ["MSIE ", "Trident/", "Edge/"];
return new RegExp(t.join("|")).test(e);
}
var f = i(e.navigator.userAgent) ? 1 : 0;
function s(e, t) {
this.scrollLeft = e;
this.scrollTop = t;
}
function c(e) {
return 0.5 * (1 - Math.cos(Math.PI * e));
}
function a(e) {
if (
e === null ||
typeof e !== "object" ||
e.behavior === undefined ||
e.behavior === "auto" ||
e.behavior === "instant"
) {
return true;
}
if (typeof e === "object" && e.behavior === "smooth") {
return false;
}
throw new TypeError(
"behavior member of ScrollOptions " +
e.behavior +
" is not a valid value for enumeration ScrollBehavior."
);
}
function u(e, t) {
if (t === "Y") {
return e.clientHeight + f < e.scrollHeight;
}
if (t === "X") {
return e.clientWidth + f < e.scrollWidth;
}
}
function d(t, o) {
var r = e.getComputedStyle(t, null)["overflow" + o];
return r === "auto" || r === "scroll";
}
function p(e) {
var t = u(e, "Y") && d(e, "Y");
var o = u(e, "X") && d(e, "X");
return t || o;
}
function h(e) {
while (e !== t.body && p(e) === false) {
e = e.parentNode || e.host;
}
return e;
}
function v(e, t) {
var o = r / t;
var l = Math.pow(1.16, Math.max(e / 80, 1));
return o * e * (1 / l);
}
function y(t) {
var o = n();
var r = e.devicePixelRatio;
var l;
var i;
var f;
var s;
var a = v(Math.abs(t.x - t.startX), r);
var u = v(Math.abs(t.y - t.startY), r);
var d = (o - t.startTime) / a;
var p = (o - t.startTime) / u;
d = d > 1 ? 1 : d;
p = p > 1 ? 1 : p;
l = c(d);
i = c(p);
f = t.startX + (t.x - t.startX) * l;
s = t.startY + (t.y - t.startY) * i;
t.method.call(t.scrollable, f, s);
if (f !== t.x || s !== t.y) {
e.requestAnimationFrame(y.bind(e, t));
}
}
function m(o, r, i) {
var f;
var c;
var a;
var u;
var d = n();
if (o === t.body) {
f = e;
c = e.scrollX || e.pageXOffset;
a = e.scrollY || e.pageYOffset;
u = l.scroll;
} else {
f = o;
c = o.scrollLeft;
a = o.scrollTop;
u = s;
}
y({
scrollable: f,
method: u,
startTime: d,
startX: c,
startY: a,
x: r,
y: i,
});
}
e.scroll = e.scrollTo = function () {
if (arguments[0] === undefined) {
return;
}
if (a(arguments[0]) === true) {
l.scroll.call(
e,
arguments[0].left !== undefined
? arguments[0].left
: typeof arguments[0] !== "object"
? arguments[0]
: e.scrollX || e.pageXOffset,
arguments[0].top !== undefined
? arguments[0].top
: arguments[1] !== undefined
? arguments[1]
: e.scrollY || e.pageYOffset
);
return;
}
m.call(
e,
t.body,
arguments[0].left !== undefined
? ~~arguments[0].left
: e.scrollX || e.pageXOffset,
arguments[0].top !== undefined
? ~~arguments[0].top
: e.scrollY || e.pageYOffset
);
};
e.scrollBy = function () {
if (arguments[0] === undefined) {
return;
}
if (a(arguments[0])) {
l.scrollBy.call(
e,
arguments[0].left !== undefined
? arguments[0].left
: typeof arguments[0] !== "object"
? arguments[0]
: 0,
arguments[0].top !== undefined
? arguments[0].top
: arguments[1] !== undefined
? arguments[1]
: 0
);
return;
}
m.call(
e,
t.body,
~~arguments[0].left + (e.scrollX || e.pageXOffset),
~~arguments[0].top + (e.scrollY || e.pageYOffset)
);
};
o.prototype.scroll = o.prototype.scrollTo = function () {
if (arguments[0] === undefined) {
return;
}
if (a(arguments[0]) === true) {
if (typeof arguments[0] === "number" && arguments[1] === undefined) {
throw new SyntaxError("Value could not be converted");
}
l.elementScroll.call(
this,
arguments[0].left !== undefined
? ~~arguments[0].left
: typeof arguments[0] !== "object"
? ~~arguments[0]
: this.scrollLeft,
arguments[0].top !== undefined
? ~~arguments[0].top
: arguments[1] !== undefined
? ~~arguments[1]
: this.scrollTop
);
return;
}
var e = arguments[0].left;
var t = arguments[0].top;
m.call(
this,
this,
typeof e === "undefined" ? this.scrollLeft : ~~e,
typeof t === "undefined" ? this.scrollTop : ~~t
);
};
o.prototype.scrollBy = function () {
if (arguments[0] === undefined) {
return;
}
if (a(arguments[0]) === true) {
l.elementScroll.call(
this,
arguments[0].left !== undefined
? ~~arguments[0].left + this.scrollLeft
: ~~arguments[0] + this.scrollLeft,
arguments[0].top !== undefined
? ~~arguments[0].top + this.scrollTop
: ~~arguments[1] + this.scrollTop
);
return;
}
this.scroll({
left: ~~arguments[0].left + this.scrollLeft,
top: ~~arguments[0].top + this.scrollTop,
behavior: arguments[0].behavior,
});
};
o.prototype.scrollIntoView = function () {
if (a(arguments[0]) === true) {
l.scrollIntoView.call(
this,
arguments[0] === undefined ? true : arguments[0]
);
return;
}
var o = h(this);
var r = o.getBoundingClientRect();
var n = this.getBoundingClientRect();
if (o !== t.body) {
m.call(
this,
o,
o.scrollLeft + n.left - r.left,
o.scrollTop + n.top - r.top
);
if (e.getComputedStyle(o).position !== "fixed") {
e.scrollBy({
left: r.left,
top: r.top,
behavior: "smooth",
});
}
} else {
e.scrollBy({
left: n.left,
top: n.top,
behavior: "smooth",
});
}
};
}
if (typeof exports === "object" && typeof module !== "undefined") {
module.exports = {
polyfill: e,
};
} else {
e();
}
})();
// Polyfills for old browsers can be added here
/* eslint-enable */

View File

@@ -6,7 +6,7 @@ require "json_schemer"
class Theme < ActiveRecord::Base
include GlobalPath
BASE_COMPILER_VERSION = 69
BASE_COMPILER_VERSION = 70
attr_accessor :child_components