Skip to content

Commit

Permalink
* Remove deprecated and unsupported interfaces
Browse files Browse the repository at this point in the history
* Add new interfaces and previously missed interfaces
* Update URI validation method, wraps around native URL class and references supported extensions list
* Add changelog
  • Loading branch information
robertfairley committed Dec 5, 2021
1 parent 97a5075 commit 10c1871
Show file tree
Hide file tree
Showing 36 changed files with 227 additions and 142 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Changelog

## v0.3.0 - December 4, 2021

This should bring the individual components more or less up to date, but what's lacking is a more thorough audit to be certain.

Some components may still not be exposed at the root level except through the global namespace `Component`.

#### Changes:
* Globally exposed component renamed `Facebook` -> `FacebookPost` to match Apple's spec
* Updated URI validation method. Now wraps around native URL class and checks against a list of valid file extensions - these may need updating. Couldn't find a canonical list of all valid file types
* Added `ColorSchema` interface.
* Removed unsupported advertisement classes: `MediumRectangleAdvertisement` and `BannerAdvertisment`
* Add missing fields to several A/V components
* Other minor housecleaning changes
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

[![CircleCI](https://circleci.com/gh/Robert-Fairley/apple-news-format.svg?style=svg&circle-token=6f3e22cb14ceb409d7241efc628ccdef34b810f8)](https://circleci.com/gh/Robert-Fairley/apple-news-format)

**Current to ANF version: `1.17.0`**

This is a collection of TypeScript types for the Apple News Format fields, metadata, and components.

Included are a small selection of validation functions for certain fields that contain restrictions on the strings that are passed in.
Expand Down
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"devDependencies": {
"@types/chai": "^4.1.7",
"@types/mocha": "^5.2.6",
"@types/node": "^16.11.11",
"chai": "^4.2.0",
"husky": "^1.3.1",
"mocha": "^9.1.3",
Expand Down
10 changes: 5 additions & 5 deletions src/apple-news.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ declare namespace AppleNews {
export type ComponentLink = Components.ComponentLink;
export type Component = Components.Component;
export type Scene = Components.Scene;
export type BannerAdvertisement = Components.Advertisements.BannerAdvertisement;
export type MediumRectangleAdvertisement = Components.Advertisements.MediumRectangleAdvertisement;
export type ReplicaAdvertisement = Components.Advertisements.ReplicaAdvertisement;
export type ArticleLink = Components.ArticleStructure.ArticleLink;
export type Aside = Components.ArticleStructure.Aside;
export type Chapter = Components.ArticleStructure.Chapter;
Expand Down Expand Up @@ -67,9 +66,10 @@ declare namespace AppleNews {
export type MapSpan = Components.Location.MapSpan;
export type Map = Components.Location.Map;
export type Place = Components.Location.Place;
export type Instagram = Components.SocialMedia.SocialMediaComponent;
export type Facebook = Components.SocialMedia.SocialMediaComponent;
export type Tweet = Components.SocialMedia.SocialMediaComponent;
export type Instagram = Components.SocialMedia.Instagram;
export type FacebookPost = Components.SocialMedia.FacebookPost;
export type TikTok = Components.SocialMedia.TikTok;
export type Tweet = Components.SocialMedia.Tweet;
export type DataDescriptor = Components.Tables.DataDescriptor;
export type DataFormat = Components.Tables.DataFormat;
export type DataTableSorting = Components.Tables.DataTableSorting;
Expand Down
6 changes: 5 additions & 1 deletion src/article-document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ import { AnyComponent } from "./components/any-component";
import { DocumentStyle } from "./document-style";
import { Metadata } from "./metadata";
import { ComponentStyles } from "./styles/component-styles";
import { ColorScheme } from "./color-scheme";
import {
ComponentTextStyles,
TextStyles,
} from "./styles/text-styles";
import { TextFormat } from "./primitives/text";

/**
* Signature/interface for the `ArticleDocument` object
* @see https://developer.apple.com/documentation/apple_news/articledocument
*/
export interface ArticleDocument {
components: AnyComponent[];
Expand All @@ -24,10 +27,11 @@ export interface ArticleDocument {
title: string;
version: string;
autoplacement?: AutoPlacement;
colorScheme?: ColorScheme;
componentLayouts?: ComponentLayouts;
componentStyles?: ComponentStyles;
documentStyle?: DocumentStyle;
metadata?: Metadata;
subtitle?: string;
textFormat?: TextFormat;
textStyles?: TextStyles;
}
66 changes: 0 additions & 66 deletions src/article-layout/component-layout-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,82 +20,16 @@ export type IgnoreDocumentParameters
* @see https://developer.apple.com/documentation/apple_news/componentlayout
*/
export interface ComponentLayoutBase {
/**
* A number that indicates how many columns the component spans, based on the number of columns in the document.
* Minimum: 1
* @type Unsigned Integer
*/
columnSpan?: number; // Unisigned Integer - minimum 1
/**
* A number that indicates which column the component‘s start position is in,
* based on the number of columns in the document or parent container.
* Minimum: 0
* @type Unsigned Integer
*/
columnStart?: number; // Unsigned Integer
/**
* A string value that sets the alignment of the content within the component.
* This property applies only when the width of the content is less than the width of the component.
* @type boolean | HorizontalAlignment
*/
horizontalContentAlignment?: HorizontalAlignment;
/**
* A value that indicates whether the gutters (if any) to the left and right of the component should be ignored.
* The gutter size is defined in the Layout object at the root level of the document.
* @type boolean | IgnoreDocumentParameters
*/
ignoreDocumentGutter?: boolean | IgnoreDocumentParameters;
/**
* A value that indicates whether the component should respect or ignore the document’s margins.
* Ignoring document margins positions the component based on the document's width and margin.
* @type boolean | IgnoreDocumentParameters
*/
ignoreDocumentMargin?: boolean | IgnoreDocumentParameters;
/**
* A value that indicates whether the component should respect or ignore the viewport padding.
* Ignoring viewport padding positions the component at the edge of the display screen.
* This property affects the layout only if the component is in the first or last column.
* @type boolean | IgnoreDocumentParameters
*/
ignoreViewportPadding?: boolean | IgnoreDocumentParameters;
/**
* A value that sets the margins for the top and bottom of the component, as a single integer
* that gets applied to the top and bottom margins, or as an object containing separate properties for top and bottom.
* @type Margin | Integer
*/
margin?: Margin | number; // Integer
/**
* A value that sets the maximum width of the content within the component.
* Specify this value as a number in points or using one of the available units of measure for components.
* @type SupportedUnits | Integer
*/
maximumContentWidth?: SupportedUnits | number;
/**
* A value that sets the minimum height of the component. A component is taller than its
* defined minimumHeight when the contents require the component to be taller.
* The minimum height can be defined as a number in points or using one of the
* available units of measure for components.
* @type SupportedUnits | Integer
*/
minimumHeight?: SupportedUnits | number;
/**
* A value that defines the minimum width of the layout when used within a Container
* with HorizontalStackDisplay as the specified contentDisplay type. The minimum width
* can be defined as a number in points or using one of the available units of measure for components.
* @type SupportedUnits | Integer
*/
minimumWidth?: SupportedUnits | number;
/**
* A value that defines the maximum width of the layout when used within a Container
* with HorizontalStackDisplay as the specified contentDisplay type. The maximum width can be
* defined as a number in points or using one of the available units of measure for components.
* @type SupportedUnits | Integer
*/
maximumWidth?: SupportedUnits | number;
/**
* A value that defines the padding between the content of the component and the edges of the component.
* Padding can be defined as a number in points or using one of the available units of measure for components.
* @type SupportedUnits | Padding | Integer
*/
padding?: SupportedUnits | Padding | number;
}
4 changes: 2 additions & 2 deletions src/article-layout/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
export interface Layout {
columns: number; // Integer - Minimum: 1
width: number; // Integer - Minimum 1
gutter?: number; // Unsigned Integer
margin?: number; // Unsigned Integer
gutter?: number; // Integer
margin?: number; // Integer
}
7 changes: 7 additions & 0 deletions src/color-scheme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Object containing information about document color scheme and dark mode.
* @see https://developer.apple.com/documentation/apple_news/articledocument/colorscheme
*/
export interface ColorScheme {
automaticDarkModeEnabled?: boolean;
}
20 changes: 0 additions & 20 deletions src/components/advertisements/banner-advertisement.ts

This file was deleted.

3 changes: 1 addition & 2 deletions src/components/advertisements/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { BannerAdvertisement } from "./banner-advertisement";
export { MediumRectangleAdvertisement } from "./medium-rectangle-advertisement";
export { ReplicaAdvertisement } from "./replica-advertisement";
10 changes: 0 additions & 10 deletions src/components/advertisements/medium-rectangle-advertisement.ts

This file was deleted.

11 changes: 11 additions & 0 deletions src/components/advertisements/replica-advertisement.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Component, ComponentLink } from "..";
import { URI } from "../../primitives";

export interface ReplicaAdvertisement extends Component {
role: "replica_advertisement";
URL: URI;
accessibilityCaption?: string;
additions?: ComponentLink[];
caption?: string;
explicitContent?: boolean;
}
10 changes: 8 additions & 2 deletions src/components/any-component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as Components from ".";

export type AnyComponent = Components.Advertisements.BannerAdvertisement
| Components.Advertisements.MediumRectangleAdvertisement
export type AnyComponent
= Components.Addition
| Components.Advertisements.ReplicaAdvertisement
| Components.ArticleStructure.ArticleLink
| Components.ArticleStructure.Aside
| Components.ArticleStructure.Chapter
Expand All @@ -13,6 +14,7 @@ export type AnyComponent = Components.Advertisements.BannerAdvertisement
| Components.AudioAndVideo.EmbedWebVideo
| Components.AudioAndVideo.Music
| Components.AudioAndVideo.Video
| Components.AudioAndVideo.Podcast
| Components.AugmentedReality.ARKit
| Components.GalleriesAndMosaics.Gallery
| Components.GalleriesAndMosaics.Mosaic
Expand All @@ -25,6 +27,10 @@ export type AnyComponent = Components.Advertisements.BannerAdvertisement
| Components.Location.Map
| Components.Location.Place
| Components.SocialMedia.SocialMediaComponent
| Components.SocialMedia.FacebookPost
| Components.SocialMedia.Instagram
| Components.SocialMedia.TikTok
| Components.SocialMedia.Tweet
| Components.Tables.DataTable
| Components.Tables.HTMLTable
| Components.Text.ArticleTitle
Expand Down
3 changes: 3 additions & 0 deletions src/components/article-structure/article-link.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CollectionDisplay, HorizontalStackDisplay } from ".";
import { ContainerComponent } from "./container-component";

/**
Expand All @@ -8,4 +9,6 @@ import { ContainerComponent } from "./container-component";
export interface ArticleLink extends ContainerComponent {
role: "article_link";
articleIdentifier: string;
allowAutoplacedAds?: boolean;
contentDisplay?: CollectionDisplay | HorizontalStackDisplay;
}
1 change: 1 addition & 0 deletions src/components/article-structure/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export { Container } from "./container";
export { Divider } from "./divider";
export { Header } from "./header";
export { HorizontalStackDisplay } from "./horizontal-stack-display";
export { LinkButton } from "./link-button";
export { Section } from "./section";
15 changes: 15 additions & 0 deletions src/components/article-structure/link-button.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component } from "..";
import { URI } from "../../primitives";
import { ComponentStyle } from "../../styles/component-styles";
import { ComponentTextStyle } from "../../styles/text-styles";

/**
* @see https://developer.apple.com/documentation/apple_news/linkbutton
*/
export interface LinkButton extends Component {
role: "link_button";
URL: URI;
accessibilityLabel?: string;
text?: string;
textStyle?: ComponentTextStyle | string;
}
1 change: 1 addition & 0 deletions src/components/audio-and-video/audio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ import { AudioVideoComponent } from "./audio-video-component";
*/
export interface Audio extends AudioVideoComponent {
role: "audio";
accessibilityCaption?: string;
imageURL?: URI;
}
1 change: 1 addition & 0 deletions src/components/audio-and-video/embed-web-video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ import { AudioVideoComponent } from "./audio-video-component";
export interface EmbedWebVideo extends AudioVideoComponent {
role: "embedwebvideo" | "embedvideo";
aspectRatio?: number; // Float
accessibilityCaption?: string;
stillURL?: URI;
}
1 change: 1 addition & 0 deletions src/components/audio-and-video/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { Audio } from "./audio";
export { EmbedWebVideo } from "./embed-web-video";
export { Music } from "./music";
export { Podcast } from "./podcast";
export { Video } from "./video";
2 changes: 2 additions & 0 deletions src/components/audio-and-video/music.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ import { AudioVideoComponent } from "./audio-video-component";
*/
export interface Music extends AudioVideoComponent {
role: "music";
accessibilityCaption?: string;
caption?: string;
imageURL: URI;
}
15 changes: 15 additions & 0 deletions src/components/audio-and-video/podcast.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { AudioVideoComponent } from "./audio-video-component";

export type PodcastOrientation
= "horizontal"
| "automatic";

export type PodcastTheme
= "light"
| "dark"
| "automatic";

export interface Podcast extends AudioVideoComponent {
orientation: PodcastOrientation;
theme: PodcastTheme;
}
4 changes: 3 additions & 1 deletion src/components/audio-and-video/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { AudioVideoComponent } from "./audio-video-component";
*/
export interface Video extends AudioVideoComponent {
role: "video";
aspectRatio?: number; // Float
accessibilityCaption?: string;
aspectRatio: number; // Float
caption?: string;
stillURL?: URI;
}
8 changes: 8 additions & 0 deletions src/components/social-media/facebook-post.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { SocialMediaComponent } from "./social-media-component";

/**
* @see https://developer.apple.com/documentation/apple_news/facebookpost
*/
export interface FacebookPost extends SocialMediaComponent {
role: "facebook_post";
}
Loading

0 comments on commit 10c1871

Please sign in to comment.