Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/lynx-compat-data/css/properties/left.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"left": {
"__compat": {
"description": "participates in setting the horizontal position of a positioned element. It has no effect on non-positioned elements.",
"lynx_path": "docs/zh/api/css/properties/left",
"lynx_path": "api/css/properties/left",
"mdn_url": "https://developer.mozilla.org/zh-CN/docs/Web/CSS/left",
"spec_url": [],
"status": {
Expand Down
2 changes: 1 addition & 1 deletion packages/lynx-compat-data/css/properties/max-height.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"max-height": {
"__compat": {
"description": "sets the maximum height of an element.",
"lynx_path": "docs/zh/api/css/properties/max-height",
"lynx_path": "api/css/properties/max-height",
"mdn_url": "https://developer.mozilla.org/zh-CN/docs/Web/CSS/max-height",
"spec_url": [],
"status": {
Expand Down
2 changes: 1 addition & 1 deletion packages/lynx-compat-data/css/properties/max-width.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"max-width": {
"__compat": {
"description": "sets the maximum width of an element.",
"lynx_path": "docs/zh/api/css/properties/max-width",
"lynx_path": "api/css/properties/max-width",
"mdn_url": "https://developer.mozilla.org/zh-CN/docs/Web/CSS/max-width",
"spec_url": [],
"status": {
Expand Down
2 changes: 1 addition & 1 deletion packages/lynx-compat-data/css/properties/min-height.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"min-height": {
"__compat": {
"description": "sets the minimum height of an element.",
"lynx_path": "docs/zh/api/css/properties/min-height",
"lynx_path": "api/css/properties/min-height",
"mdn_url": "https://developer.mozilla.org/zh-CN/docs/Web/CSS/min-height",
"spec_url": [],
"status": {
Expand Down
2 changes: 1 addition & 1 deletion packages/lynx-compat-data/css/properties/min-width.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"min-width": {
"__compat": {
"description": "sets the minimum width of an element.",
"lynx_path": "docs/zh/api/css/properties/min-width",
"lynx_path": "api/css/properties/min-width",
"mdn_url": "https://developer.mozilla.org/zh-CN/docs/Web/CSS/min-width",
"spec_url": [],
"status": {
Expand Down
2 changes: 1 addition & 1 deletion packages/lynx-compat-data/css/properties/order.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"order": {
"__compat": {
"description": "The order CSS property sets the order to lay out an item.",
"lynx_path": "docs/zh/api/css/properties/order",
"lynx_path": "api/css/properties/order",
"mdn_url": "https://developer.mozilla.org/zh-CN/docs/Web/CSS/order",
"spec_url": [],
"status": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"properties": {
"padding-bottom": {
"__compat": {
"lynx_path": "docs/zh/api/css/properties/padding-bottom",
"lynx_path": "api/css/properties/padding-bottom",
"mdn_url": "https://developer.mozilla.org/zh-CN/docs/Web/CSS/padding-bottom",
"spec_url": [],
"status": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"properties": {
"padding-inline-end": {
"__compat": {
"lynx_path": "docs/zh/api/css/properties/padding-inline-end",
"lynx_path": "api/css/properties/padding-inline-end",
"mdn_url": "https://developer.mozilla.org/zh-CN/docs/Web/CSS/padding-inline-end",
"spec_url": [],
"status": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"properties": {
"padding-inline-start": {
"__compat": {
"lynx_path": "docs/zh/api/css/properties/padding-inline-start",
"lynx_path": "api/css/properties/padding-inline-start",
"mdn_url": "https://developer.mozilla.org/zh-CN/docs/Web/CSS/padding-inline-start",
"spec_url": [],
"status": {
Expand Down
2 changes: 1 addition & 1 deletion packages/lynx-compat-data/css/properties/padding-left.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"properties": {
"padding-left": {
"__compat": {
"lynx_path": "docs/zh/api/css/properties/padding-left",
"lynx_path": "api/css/properties/padding-left",
"mdn_url": "https://developer.mozilla.org/zh-CN/docs/Web/CSS/padding-left",
"spec_url": [],
"status": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"properties": {
"padding-right": {
"__compat": {
"lynx_path": "docs/zh/api/css/properties/padding-right",
"lynx_path": "api/css/properties/padding-right",
"mdn_url": "https://developer.mozilla.org/zh-CN/docs/Web/CSS/padding-right",
"spec_url": [],
"status": {
Expand Down
2 changes: 1 addition & 1 deletion packages/lynx-compat-data/css/properties/padding-top.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"properties": {
"padding-top": {
"__compat": {
"lynx_path": "docs/zh/api/css/properties/padding-top",
"lynx_path": "api/css/properties/padding-top",
"mdn_url": "https://developer.mozilla.org/zh-CN/docs/Web/CSS/padding-top",
"spec_url": [],
"status": {
Expand Down
2 changes: 1 addition & 1 deletion packages/lynx-compat-data/css/properties/padding.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"properties": {
"padding": {
"__compat": {
"lynx_path": "docs/zh/api/css/properties/padding",
"lynx_path": "api/css/properties/padding",
"mdn_url": "https://developer.mozilla.org/zh-CN/docs/Web/CSS/padding",
"spec_url": [],
"status": {
Expand Down
2 changes: 1 addition & 1 deletion packages/lynx-compat-data/css/properties/position.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"properties": {
"position": {
"__compat": {
"lynx_path": "docs/zh/api/css/css-style/position",
"lynx_path": "api/css/css-style/position",
"mdn_url": "https://developer.mozilla.org/zh-CN/docs/Web/CSS/position",
"spec_url": [],
"status": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"relative-align-bottom": {
"__compat": {
"description": "Specifies that the current element is aligned with the bottom edge of the parent or sibling element corresponding to id.",
"lynx_path": "docs/zh/api/css/properties/relative-align-bottom",
"lynx_path": "api/css/properties/relative-align-bottom",
"spec_url": [],
"status": {
"deprecated": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"relative-align-inline-end": {
"__compat": {
"description": "Specifies that the current element is aligned with the left/right edges of the parent or sibling element corresponding to id.",
"lynx_path": "docs/zh/api/css/properties/relative-align-inline-end",
"lynx_path": "api/css/properties/relative-align-inline-end",
"spec_url": [],
"status": {
"deprecated": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"relative-align-inline-start": {
"__compat": {
"description": "Specifies that the current element is aligned with the left/right edges of the parent or sibling element corresponding to id.",
"lynx_path": "docs/zh/api/css/properties/relative-align-inline-start",
"lynx_path": "api/css/properties/relative-align-inline-start",
"spec_url": [],
"status": {
"deprecated": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"relative-align-left": {
"__compat": {
"description": "Specifies that the current element is aligned with the left edge of the parent or sibling element corresponding to id.",
"lynx_path": "docs/zh/api/css/properties/relative-align-left",
"lynx_path": "api/css/properties/relative-align-left",
"spec_url": [],
"status": {
"deprecated": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"relative-align-right": {
"__compat": {
"description": "Specifies that the current element is aligned with the right edge of the parent or sibling element corresponding to id.",
"lynx_path": "docs/zh/api/css/properties/relative-align-right",
"lynx_path": "api/css/properties/relative-align-right",
"spec_url": [],
"status": {
"deprecated": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"relative-align-top": {
"__compat": {
"description": "Specifies that the current element is aligned with the top edge of the parent or sibling element corresponding to id.",
"lynx_path": "docs/zh/api/css/properties/relative-align-top",
"lynx_path": "api/css/properties/relative-align-top",
"spec_url": [],
"status": {
"deprecated": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"relative-bottom-of": {
"__compat": {
"description": "The current element is to the bottom of the sibling element specified corresponding to id.",
"lynx_path": "docs/zh/api/css/properties/relative-bottom-of",
"lynx_path": "api/css/properties/relative-bottom-of",
"spec_url": [],
"status": {
"deprecated": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"relative-center": {
"__compat": {
"description": "Specifies that the current element is aligned with the bottom edge of the parent or sibling element corresponding to id.",
"lynx_path": "docs/zh/api/css/properties/relative-center",
"lynx_path": "api/css/properties/relative-center",
"spec_url": [],
"status": {
"deprecated": false,
Expand Down
2 changes: 1 addition & 1 deletion packages/lynx-compat-data/css/properties/relative-id.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"relative-id": {
"__compat": {
"description": "Used to set the number of sibling elements in the relative layout.",
"lynx_path": "docs/zh/api/css/properties/relative-id",
"lynx_path": "api/css/properties/relative-id",
"spec_url": [],
"status": {
"deprecated": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"relative-inline-end-of": {
"__compat": {
"description": "The current element is to the left/right of the sibling element corresponding to the specified id.",
"lynx_path": "docs/zh/api/css/properties/relative-inline-end-of",
"lynx_path": "api/css/properties/relative-inline-end-of",
"spec_url": [],
"status": {
"deprecated": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"relative-inline-start-of": {
"__compat": {
"description": "The current element is to the left/right of the sibling element corresponding to the specified id.",
"lynx_path": "docs/zh/api/css/properties/relative-inline-start-of",
"lynx_path": "api/css/properties/relative-inline-start-of",
"spec_url": [],
"status": {
"deprecated": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"relative-layout-once": {
"__compat": {
"description": "Used to set typesetting acceleration. When using positioning between elements at the same level, it is recommended to enable this property, and elements at the same level will only depend upwards.",
"lynx_path": "docs/zh/api/css/properties/relative-layout-once",
"lynx_path": "api/css/properties/relative-layout-once",
"spec_url": [],
"status": {
"deprecated": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"relative-left-of": {
"__compat": {
"description": "The current element is to the left of the sibling element specified corresponding to id.",
"lynx_path": "docs/zh/api/css/properties/relative-left-of",
"lynx_path": "api/css/properties/relative-left-of",
"spec_url": [],
"status": {
"deprecated": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"relative-right-of": {
"__compat": {
"description": "The current element is to the right of the sibling element specified corresponding to id.",
"lynx_path": "docs/zh/api/css/properties/relative-right-of",
"lynx_path": "api/css/properties/relative-right-of",
"spec_url": [],
"status": {
"deprecated": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"relative-top-of": {
"__compat": {
"description": "The current element is to the top of the sibling element specified corresponding to id.",
"lynx_path": "docs/zh/api/css/properties/relative-top-of",
"lynx_path": "api/css/properties/relative-top-of",
"spec_url": [],
"status": {
"deprecated": false,
Expand Down
2 changes: 1 addition & 1 deletion packages/lynx-compat-data/css/properties/right.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"right": {
"__compat": {
"description": "participates in setting the horizontal position of a positioned element. It has no effect on non-positioned elements.",
"lynx_path": "docs/zh/api/css/properties/right",
"lynx_path": "api/css/properties/right",
"mdn_url": "https://developer.mozilla.org/zh-CN/docs/Web/CSS/right",
"spec_url": [],
"status": {
Expand Down
2 changes: 1 addition & 1 deletion packages/lynx-compat-data/css/properties/top.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"top": {
"__compat": {
"description": "participates in setting the vertical position of a positioned element. It has no effect on non-positioned elements.",
"lynx_path": "docs/zh/api/css/properties/top",
"lynx_path": "api/css/properties/top",
"mdn_url": "https://developer.mozilla.org/zh-CN/docs/Web/CSS/top",
"spec_url": [],
"status": {
Expand Down
6 changes: 5 additions & 1 deletion packages/lynx-compat-data/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ describe('API', () => {

describe('Util functions', () => {
it('should work', () => {
expect(getSupportedPlatforms(sTO.__compat)).toEqual(['android', 'ios']);
expect(getSupportedPlatforms(sTO.__compat)).toEqual([
'android',
'ios',
'web_lynx',
]);
});
});
21 changes: 17 additions & 4 deletions packages/lynx-compat-data/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Re-export types for easier access
export * from './types/types.d.ts';
export type * from './types/types.d.ts';
import platforms from './platforms/platforms.json' assert { type: 'json' };

import type {
Expand Down Expand Up @@ -52,7 +52,8 @@ export function isVersionValue(value: unknown): value is VersionValue {
* @returns True if the string is a valid PlatformType, false otherwise
*/
export function isPlatformType(type: string): type is PlatformType {
return ['native', 'web', 'clay'].includes(type);
const validPlatformTypes: PlatformType[] = ['native', 'web', 'clay'];
return validPlatformTypes.includes(type as PlatformType);
}

/**
Expand All @@ -61,7 +62,13 @@ export function isPlatformType(type: string): type is PlatformType {
* @returns True if the string is a valid PlatformStatus, false otherwise
*/
export function isPlatformStatus(status: string): status is PlatformStatus {
return ['retired', 'current', 'beta', 'planned'].includes(status);
const validPlatformStatuses: PlatformStatus[] = [
'retired',
'current',
'beta',
'planned',
];
return validPlatformStatuses.includes(status as PlatformStatus);
}

/**
Expand All @@ -76,9 +83,14 @@ export function isPlatformStatement(obj: unknown): obj is PlatformStatement {
'name' in obj &&
typeof obj.name === 'string' &&
'type' in obj &&
typeof obj.type === 'string' &&
isPlatformType(obj.type) &&
'releases' in obj &&
typeof obj.releases === 'object'
typeof obj.releases === 'object' &&
obj.releases !== null &&
Object.entries(obj.releases).every(([key, value]) =>
isReleaseStatement(value),
)
);
}

Expand All @@ -94,6 +106,7 @@ export function isReleaseStatement(obj: unknown): obj is ReleaseStatement {
(!('release_date' in obj) || typeof obj.release_date === 'string') &&
(!('release_notes' in obj) || typeof obj.release_notes === 'string') &&
'status' in obj &&
typeof obj.status === 'string' &&
isPlatformStatus(obj.status)
);
}
Expand Down