Skip to content

Commit 9b6346e

Browse files
caugnerargl
andauthored
feat(mirror): ignore OS limitations when mirroring to mobile (#28226)
* feat(mirror): ignore OS limitations when mirroring to mobile * Run `npm run lint:fix` * fixup! feat(mirror): ignore OS limitations when mirroring to mobile * Run `npm run fix` once * Run `npm run lint:fix` --------- Co-authored-by: Andi Pieper <[email protected]>
1 parent 9beb99d commit 9b6346e

File tree

8 files changed

+139
-62
lines changed

8 files changed

+139
-62
lines changed

api/GPUAdapter.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@
128128
"partial_implementation": true,
129129
"notes": "Supported on ChromeOS, macOS, and Windows only."
130130
},
131-
"chrome_android": {
132-
"version_added": "127"
133-
},
131+
"chrome_android": "mirror",
134132
"edge": "mirror",
135133
"firefox": {
136134
"version_added": "141",
@@ -452,9 +450,7 @@
452450
"partial_implementation": true,
453451
"notes": "Supported on ChromeOS, macOS, and Windows only."
454452
},
455-
"chrome_android": {
456-
"version_added": "133"
457-
},
453+
"chrome_android": "mirror",
458454
"deno": {
459455
"version_added": false
460456
},

api/GPUCommandEncoder.json

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,7 @@
127127
"partial_implementation": true,
128128
"notes": "Supported on ChromeOS, macOS, and Windows only."
129129
},
130-
"chrome_android": {
131-
"version_added": "121"
132-
},
130+
"chrome_android": "mirror",
133131
"deno": {
134132
"version_added": false
135133
},
@@ -226,9 +224,7 @@
226224
"partial_implementation": true,
227225
"notes": "Supported on ChromeOS, macOS, and Windows only."
228226
},
229-
"chrome_android": {
230-
"version_added": "140"
231-
},
227+
"chrome_android": "mirror",
232228
"deno": {
233229
"version_added": false
234230
},
@@ -268,9 +264,7 @@
268264
"partial_implementation": true,
269265
"notes": "Supported on ChromeOS, macOS, and Windows only."
270266
},
271-
"chrome_android": {
272-
"version_added": "125"
273-
},
267+
"chrome_android": "mirror",
274268
"deno": {
275269
"version_added": false
276270
},
@@ -309,9 +303,7 @@
309303
"partial_implementation": true,
310304
"notes": "Supported on ChromeOS, macOS, and Windows only."
311305
},
312-
"chrome_android": {
313-
"version_added": "123"
314-
},
306+
"chrome_android": "mirror",
315307
"deno": {
316308
"version_added": false
317309
},
@@ -351,9 +343,7 @@
351343
"partial_implementation": true,
352344
"notes": "Supported on ChromeOS, macOS, and Windows only."
353345
},
354-
"chrome_android": {
355-
"version_added": "121"
356-
},
346+
"chrome_android": "mirror",
357347
"deno": {
358348
"version_added": false
359349
},
@@ -508,9 +498,7 @@
508498
"partial_implementation": true,
509499
"notes": "Supported on ChromeOS, macOS, and Windows only."
510500
},
511-
"chrome_android": {
512-
"version_added": "137"
513-
},
501+
"chrome_android": "mirror",
514502
"deno": {
515503
"version_added": false
516504
},

api/GPUDevice.json

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,7 @@
167167
"partial_implementation": true,
168168
"notes": "Supported on ChromeOS, macOS, and Windows only."
169169
},
170-
"chrome_android": {
171-
"version_added": "138"
172-
},
170+
"chrome_android": "mirror",
173171
"deno": {
174172
"version_added": false
175173
},
@@ -208,9 +206,7 @@
208206
"partial_implementation": true,
209207
"notes": "Supported on ChromeOS, macOS, and Windows only."
210208
},
211-
"chrome_android": {
212-
"version_added": "140"
213-
},
209+
"chrome_android": "mirror",
214210
"deno": {
215211
"version_added": false
216212
},
@@ -249,9 +245,7 @@
249245
"partial_implementation": true,
250246
"notes": "Supported on ChromeOS, macOS, and Windows only."
251247
},
252-
"chrome_android": {
253-
"version_added": "137"
254-
},
248+
"chrome_android": "mirror",
255249
"deno": {
256250
"version_added": false
257251
},
@@ -801,9 +795,7 @@
801795
"partial_implementation": true,
802796
"notes": "Supported on ChromeOS, macOS, and Windows only."
803797
},
804-
"chrome_android": {
805-
"version_added": "135"
806-
},
798+
"chrome_android": "mirror",
807799
"deno": {
808800
"version_added": false
809801
},
@@ -901,9 +893,7 @@
901893
"partial_implementation": true,
902894
"notes": "Supported on ChromeOS, macOS, and Windows only."
903895
},
904-
"chrome_android": {
905-
"version_added": "121"
906-
},
896+
"chrome_android": "mirror",
907897
"deno": {
908898
"version_added": false
909899
},
@@ -1059,9 +1049,7 @@
10591049
"partial_implementation": true,
10601050
"notes": "Supported on ChromeOS, macOS, and Windows only."
10611051
},
1062-
"chrome_android": {
1063-
"version_added": "130"
1064-
},
1052+
"chrome_android": "mirror",
10651053
"deno": {
10661054
"version_added": false
10671055
},
@@ -1362,9 +1350,7 @@
13621350
"partial_implementation": true,
13631351
"notes": "Supported on ChromeOS, macOS, and Windows only."
13641352
},
1365-
"chrome_android": {
1366-
"version_added": "130"
1367-
},
1353+
"chrome_android": "mirror",
13681354
"deno": {
13691355
"version_added": false
13701356
},
@@ -1984,9 +1970,7 @@
19841970
"partial_implementation": true,
19851971
"notes": "Supported on ChromeOS, macOS, and Windows only."
19861972
},
1987-
"chrome_android": {
1988-
"version_added": "121"
1989-
},
1973+
"chrome_android": "mirror",
19901974
"deno": {
19911975
"version_added": false
19921976
},

api/GPUQuerySet.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,7 @@
301301
"partial_implementation": true,
302302
"notes": "Supported on ChromeOS, macOS, and Windows only."
303303
},
304-
"chrome_android": {
305-
"version_added": "121"
306-
},
304+
"chrome_android": "mirror",
307305
"deno": {
308306
"version_added": false
309307
},

api/GPUSupportedFeatures.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -862,9 +862,7 @@
862862
"partial_implementation": true,
863863
"notes": "Supported on ChromeOS, macOS, and Windows only."
864864
},
865-
"chrome_android": {
866-
"version_added": "142"
867-
},
865+
"chrome_android": "mirror",
868866
"deno": {
869867
"version_added": false
870868
},
@@ -904,9 +902,7 @@
904902
"partial_implementation": true,
905903
"notes": "Supported on ChromeOS, macOS, and Windows only."
906904
},
907-
"chrome_android": {
908-
"version_added": "142"
909-
},
905+
"chrome_android": "mirror",
910906
"deno": {
911907
"version_added": false
912908
},

api/GPUTexture.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,7 @@
169169
"partial_implementation": true,
170170
"notes": "Supported on ChromeOS, macOS, and Windows only."
171171
},
172-
"chrome_android": {
173-
"version_added": "132"
174-
},
172+
"chrome_android": "mirror",
175173
"deno": {
176174
"version_added": false
177175
},

scripts/build/mirror.test.ts

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,39 @@ import { BrowserName } from '../../types/types.js';
77
import bcd from '../../index.js';
88
import { InternalSupportBlock } from '../../types/index.js';
99

10-
import mirrorSupport from './mirror.js';
10+
import mirrorSupport, { isOSLimitation } from './mirror.js';
1111

1212
describe('mirror', () => {
13+
describe('isOSLimitation', () => {
14+
it('returns true for OS limitation notes', () => {
15+
assert.equal(
16+
isOSLimitation('Supported on ChromeOS, macOS, and Windows only.'),
17+
true,
18+
);
19+
assert.equal(isOSLimitation('Supported on macOS only.'), true);
20+
assert.equal(isOSLimitation('Not supported on Windows.'), true);
21+
});
22+
23+
it('returns false for non-OS-limitation notes', () => {
24+
assert.equal(
25+
isOSLimitation('This feature requires a flag to be enabled.'),
26+
false,
27+
);
28+
assert.equal(
29+
isOSLimitation('Before version 70, this method always returned true.'),
30+
false,
31+
);
32+
assert.equal(
33+
isOSLimitation('Firefox 73 added support for this thing.'),
34+
false,
35+
);
36+
});
37+
38+
it('returns false for empty string', () => {
39+
assert.equal(isOSLimitation(''), false);
40+
});
41+
});
42+
1343
describe('default export', () => {
1444
describe('version numbers match expected values', () => {
1545
const mappings: {
@@ -189,6 +219,38 @@ describe('mirror', () => {
189219
notes: 'This feature is only supported in ChromeOS, macOS and Linux.',
190220
});
191221
});
222+
223+
it('OS-specific partial_implementation and notes are not mirrored', () => {
224+
const support = {
225+
chrome: {
226+
version_added: '134',
227+
partial_implementation: true,
228+
notes: 'Supported on ChromeOS, macOS, and Windows only.',
229+
},
230+
};
231+
232+
const mirrored = mirrorSupport('chrome_android', support);
233+
assert.deepEqual(mirrored, {
234+
version_added: '134',
235+
});
236+
});
237+
238+
it('Non-OS-specific partial_implementation and notes are still mirrored', () => {
239+
const support = {
240+
chrome: {
241+
version_added: '70',
242+
partial_implementation: true,
243+
notes: 'This feature is incomplete and may not work as expected.',
244+
},
245+
};
246+
247+
const mirrored = mirrorSupport('chrome_android', support);
248+
assert.deepEqual(mirrored, {
249+
version_added: '70',
250+
partial_implementation: true,
251+
notes: 'This feature is incomplete and may not work as expected.',
252+
});
253+
});
192254
});
193255

194256
describe('Validations', () => {

scripts/build/mirror.ts

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,38 @@ const { browsers } = bcd;
1515

1616
type Notes = string | [string, string, ...string[]] | null;
1717

18+
const OS_NOTES = [
19+
'Available on macOS and Windows only.',
20+
'Available only on macOS.',
21+
'ChromeOS only',
22+
'ChromeOS and Windows',
23+
'Fully supported on Windows and Linux, no support on ChromeOS.',
24+
'Linux support is not enabled by default.',
25+
'Not supported on macOS.',
26+
'Not supported on Windows.',
27+
'Only on macOS and Windows.',
28+
'Only on Windows.',
29+
'Only supported on ChromeOS',
30+
'Only supported on macOS.',
31+
'Only supported on Windows.',
32+
'Only works on macOS.',
33+
'Supported on ChromeOS, macOS, and Windows only.',
34+
'Supported on ChromeOS and macOS only.',
35+
'Supported on macOS only.',
36+
'Supported on macOS Catalina 10.15.1+, Windows, and ChromeOS. Not yet supported on Linux.',
37+
'Supported on Windows only, in all contexts except for service workers.',
38+
'Supported only on macOS 10.12 (Sierra) and later.',
39+
'This cursor is only supported on macOS and Linux.',
40+
].map((s) => s.toLowerCase());
41+
1842
/**
43+
* Check if a note indicates OS-specific limitations.
44+
* @param notes A single notes string from a support statement
45+
* @returns True if the notes indicate OS-specific limitations
1946
*/
47+
export const isOSLimitation = (notes: string): boolean => {
48+
return OS_NOTES.includes(notes.toLowerCase());
49+
};
2050

2151
const matchingSafariVersions = new Map([
2252
['1', '1'],
@@ -215,6 +245,30 @@ export const bumpSupport = (
215245

216246
const newData: SimpleSupportStatement = copyStatement(sourceData);
217247

248+
if (
249+
browsers[sourceBrowser].type === 'desktop' &&
250+
browsers[destination].type === 'mobile' &&
251+
sourceData.partial_implementation
252+
) {
253+
const notes = Array.isArray(sourceData.notes)
254+
? sourceData.notes
255+
: sourceData.notes
256+
? [sourceData.notes]
257+
: [];
258+
const [firstNote, secondNote, ...otherNotes] = notes.filter(
259+
(notes) => !isOSLimitation(notes),
260+
);
261+
if (!firstNote) {
262+
// Ignore OS limitation.
263+
delete newData.partial_implementation;
264+
delete newData.notes;
265+
} else if (!secondNote) {
266+
newData.notes = firstNote;
267+
} else {
268+
newData.notes = [firstNote, secondNote, ...otherNotes];
269+
}
270+
}
271+
218272
if (!browsers[destination].accepts_flags && newData.flags) {
219273
// Remove flag data if the target browser doesn't accept flags
220274
return { version_added: false };
@@ -254,7 +308,8 @@ export const bumpSupport = (
254308
return { version_added: false };
255309
}
256310

257-
if (sourceData.notes) {
311+
// Only process notes if they weren't already removed (e.g., for OS-specific limitations)
312+
if (sourceData.notes && newData.notes !== undefined) {
258313
const sourceBrowserName =
259314
sourceBrowser === 'chrome'
260315
? '(Google )?Chrome'

0 commit comments

Comments
 (0)