Skip to content

Commit 4e8b88f

Browse files
authored
fix(landing): avoid unpolyfilled ES2023 array methods in client code (#5340)
toSorted/toReversed require Safari 16+/iOS 16+ and Next.js/SWC does not polyfill prototype methods (vercel/next.js#58421 closed unmerged), so #5326 broke sorting on the models page and landing preview for Safari 15/iOS 15 with a runtime TypeError. Revert the 6 call sites to [...arr].sort()/[...arr].reverse() (immutable, universally supported, matches the existing codebase idiom) and drop the ES2023 tsconfig lib override that only existed to type-check them.
1 parent 62acc9c commit 4e8b88f

7 files changed

Lines changed: 6 additions & 7 deletions

File tree

apps/sim/app/(landing)/components/landing-preview/components/landing-preview-logs/landing-preview-logs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export function LandingPreviewLogs() {
141141
: MOCK_LOGS
142142

143143
if (!sortKey) return filtered
144-
return filtered.toSorted((a, b) => {
144+
return [...filtered].sort((a, b) => {
145145
const av = sortKey === 'cost' ? a.cost.replace(/\D/g, '') : a[sortKey]
146146
const bv = sortKey === 'cost' ? b.cost.replace(/\D/g, '') : b[sortKey]
147147
const cmp = av.localeCompare(bv, undefined, { numeric: true, sensitivity: 'base' })

apps/sim/app/(landing)/components/landing-preview/components/landing-preview-resource/landing-preview-resource.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export function LandingPreviewResource({
6262
: rows
6363

6464
if (!sortColId) return filtered
65-
return filtered.toSorted((a, b) => {
65+
return [...filtered].sort((a, b) => {
6666
const av = a.cells[sortColId]?.label ?? ''
6767
const bv = b.cells[sortColId]?.label ?? ''
6868
const cmp = av.localeCompare(bv, undefined, { numeric: true, sensitivity: 'base' })

apps/sim/app/(landing)/components/lifecycle/components/lifecycle-icons/lifecycle-icons.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export function MonitorIcon(props: IconProps) {
121121
return (
122122
<IconFrame {...props}>
123123
{/* Far → near so nearer bars occlude the ones behind them. */}
124-
{MONITOR_BARS.toReversed().map((bar) => (
124+
{[...MONITOR_BARS].reverse().map((bar) => (
125125
<IsoBox key={bar.x} cx={bar.x} topY={bar.ground - bar.h} w={5} h={bar.h} />
126126
))}
127127
</IconFrame>

apps/sim/app/(landing)/integrations/(shell)/[slug]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function escapeRegex(value: string): string {
129129
* names.
130130
*/
131131
function mentionifyPromptForNames(prompt: string, names: readonly string[]): string {
132-
const unique = Array.from(new Set(names.filter((n) => n.trim().length >= 2))).toSorted(
132+
const unique = Array.from(new Set(names.filter((n) => n.trim().length >= 2))).sort(
133133
(a, b) => b.length - a.length
134134
)
135135
if (unique.length === 0) return prompt

apps/sim/app/(landing)/models/components/model-comparison-charts.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function selectComparisonModels(models: CatalogModel[]): CatalogModel[] {
2727
const seen = new Set<string>()
2828
const result: CatalogModel[] = []
2929

30-
const sorted = models.toSorted((a, b) => {
30+
const sorted = [...models].sort((a, b) => {
3131
const score = (m: CatalogModel) => {
3232
const reseller = RESELLER_PROVIDERS.has(m.providerId) ? -50 : 0
3333
const reasoning = m.capabilities.reasoningEffort || m.capabilities.thinking ? 10 : 0

apps/sim/app/(landing)/models/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ const rawProviders = Object.values(PROVIDER_DEFINITIONS).map((provider) => {
513513
models.find((model) => model.id === provider.defaultModel)?.displayName ||
514514
(provider.defaultModel ? formatModelDisplayName(provider.id, provider.defaultModel) : 'Dynamic')
515515

516-
const featuredModels = models.toSorted(compareModelsByRelevance).slice(0, 6)
516+
const featuredModels = [...models].sort(compareModelsByRelevance).slice(0, 6)
517517

518518
return {
519519
id: provider.id,

apps/sim/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"extends": "@sim/tsconfig/nextjs.json",
33
"compilerOptions": {
44
"baseUrl": ".",
5-
"lib": ["ES2023", "DOM", "DOM.Iterable"],
65
"paths": {
76
"@/*": ["./*"],
87
"@/components/*": ["components/*"],

0 commit comments

Comments
 (0)