Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web share target support #372

Merged
merged 3 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 7 additions & 3 deletions packages/core/src/lib/TwaManifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import fetch from 'node-fetch';
import {findSuitableIcon, generatePackageId, validateNotEmpty} from './util';
import Color = require('color');
import {ConsoleLog} from './Log';
import {WebManifestIcon, WebManifestJson} from './types/WebManifest';
import {WebManifestIcon, WebManifestJson, ShareTarget} from './types/WebManifest';
import {ShortcutInfo} from './ShortcutInfo';
import {AppsFlyerConfig} from './features/AppsFlyerFeature';
import {LocationDelegationConfig} from './features/LocationDelegationFeature';
Expand Down Expand Up @@ -67,11 +67,11 @@ type Features = {
appsFlyer?: AppsFlyerConfig;
locationDelegation?: LocationDelegationConfig;
firstRunFlag?: FirstRunFlagConfig;
}
};

type alphaDependencies = {
enabled: boolean;
}
};

/**
* A Manifest used to generate the TWA Project
Expand Down Expand Up @@ -135,6 +135,7 @@ export class TwaManifest {
alphaDependencies: alphaDependencies;
enableSiteSettingsShortcut: boolean;
isChromeOSOnly: boolean;
shareTarget?: ShareTarget;

private static log = new ConsoleLog('twa-manifest');

Expand Down Expand Up @@ -175,6 +176,7 @@ export class TwaManifest {
this.enableSiteSettingsShortcut = data.enableSiteSettingsShortcut != undefined ?
data.enableSiteSettingsShortcut : true;
this.isChromeOSOnly = data.isChromeOSOnly != undefined ? data.isChromeOSOnly : false;
this.shareTarget = data.shareTarget;
}

/**
Expand Down Expand Up @@ -295,6 +297,7 @@ export class TwaManifest {
features: {
locationDelegation: {enabled: DEFAULT_ENABLE_LOCATION},
},
shareTarget: webManifest['share_target'],
});
return twaManifest;
}
Expand Down Expand Up @@ -474,6 +477,7 @@ export interface TwaManifestJson {
};
enableSiteSettingsShortcut?: boolean;
isChromeOSOnly?: boolean;
shareTarget?: ShareTarget;
}

export interface SigningKeyInfo {
Expand Down
15 changes: 15 additions & 0 deletions packages/core/src/lib/types/WebManifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ export interface WebManifestShortcutJson {

type WebManifestDisplayMode = 'browser' | 'minimal-ui' | 'standalone' | 'fullscreen';

// These interfaces follows the implementation from: https://w3c.github.io/web-share-target/.
export interface ShareTargetParams {
chenlevy24 marked this conversation as resolved.
Show resolved Hide resolved
title?: string;
text?: string;
url?: string;
}

export interface ShareTarget {
action?: string;
method?: string;
enctype?: string;
params?: ShareTargetParams;
}

export interface WebManifestJson {
name?: string;
short_name?: string;
Expand All @@ -41,4 +55,5 @@ export interface WebManifestJson {
background_color?: string;
icons?: Array<WebManifestIcon>;
shortcuts?: Array<WebManifestShortcutJson>;
share_target?: ShareTarget;
}