Skip to content

Commit

Permalink
Merge pull request #372 from chenlevy24/shareTarget
Browse files Browse the repository at this point in the history
Web share target support
  • Loading branch information
PEConn committed Oct 27, 2020
2 parents 1f583ae + 1f9ae69 commit e6f4408
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
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 {
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;
}

0 comments on commit e6f4408

Please sign in to comment.