1 |
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", { value: true });
|
4 |
|
5 |
|
6 |
|
7 | var OfficeApp;
|
8 | (function (OfficeApp) {
|
9 |
|
10 | OfficeApp["Excel"] = "excel";
|
11 | OfficeApp["OneNote"] = "onenote";
|
12 | OfficeApp["Outlook"] = "outlook";
|
13 | OfficeApp["PowerPoint"] = "powerpoint";
|
14 | OfficeApp["Project"] = "project";
|
15 | OfficeApp["Word"] = "word";
|
16 |
|
17 |
|
18 | })(OfficeApp = exports.OfficeApp || (exports.OfficeApp = {}));
|
19 |
|
20 | const officeApps = Object.keys(OfficeApp).map(key => parseOfficeApp(key));
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | function getOfficeAppForManifestHost(host) {
|
26 | switch (host.toLowerCase()) {
|
27 | case "document":
|
28 | return OfficeApp.Word;
|
29 | case "mailbox":
|
30 | return OfficeApp.Outlook;
|
31 | case "notebook":
|
32 | return OfficeApp.OneNote;
|
33 | case "presentation":
|
34 | return OfficeApp.PowerPoint;
|
35 | case "project":
|
36 | return OfficeApp.Project;
|
37 | case "workbook":
|
38 | return OfficeApp.Excel;
|
39 | default:
|
40 | return undefined;
|
41 | }
|
42 | }
|
43 | exports.getOfficeAppForManifestHost = getOfficeAppForManifestHost;
|
44 |
|
45 |
|
46 |
|
47 |
|
48 | function getOfficeAppName(app) {
|
49 | switch (app) {
|
50 | case OfficeApp.Excel:
|
51 | return "Excel";
|
52 | case OfficeApp.OneNote:
|
53 | return "OneNote";
|
54 | case OfficeApp.Outlook:
|
55 | return "Outlook";
|
56 | case OfficeApp.PowerPoint:
|
57 | return "PowerPoint";
|
58 | case OfficeApp.Project:
|
59 | return "Project";
|
60 | case OfficeApp.Word:
|
61 | return "Word";
|
62 | default:
|
63 | throw new Error(`Unable to provide name for Office app "${app}"`);
|
64 | }
|
65 | }
|
66 | exports.getOfficeAppName = getOfficeAppName;
|
67 |
|
68 |
|
69 |
|
70 |
|
71 | function getOfficeAppNames(apps) {
|
72 | return apps.map(app => getOfficeAppName(app));
|
73 | }
|
74 | exports.getOfficeAppNames = getOfficeAppNames;
|
75 |
|
76 |
|
77 |
|
78 | function getOfficeApps() {
|
79 | return officeApps;
|
80 | }
|
81 | exports.getOfficeApps = getOfficeApps;
|
82 |
|
83 |
|
84 |
|
85 |
|
86 | function getOfficeAppsForManifestHosts(hosts) {
|
87 | const apps = [];
|
88 | if (hosts) {
|
89 | hosts.forEach(host => {
|
90 | const app = getOfficeAppForManifestHost(host);
|
91 | if (app) {
|
92 | apps.push(app);
|
93 | }
|
94 | });
|
95 | }
|
96 | return apps;
|
97 | }
|
98 | exports.getOfficeAppsForManifestHosts = getOfficeAppsForManifestHosts;
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 | function parseOfficeApp(value) {
|
105 | const officeApp = toOfficeApp(value);
|
106 | if (!officeApp) {
|
107 | throw new Error(`"${value}" is not a valid Office app.`);
|
108 | }
|
109 | return officeApp;
|
110 | }
|
111 | exports.parseOfficeApp = parseOfficeApp;
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 | function parseOfficeApps(input) {
|
118 | if (input.trim().toLowerCase() === "all") {
|
119 | return getOfficeApps();
|
120 | }
|
121 | else {
|
122 | return input.split(",").map(appString => parseOfficeApp(appString));
|
123 | }
|
124 | }
|
125 | exports.parseOfficeApps = parseOfficeApps;
|
126 |
|
127 |
|
128 |
|
129 |
|
130 | function toOfficeApp(value) {
|
131 | switch (value ? value.trim().toLowerCase() : value) {
|
132 | case OfficeApp.Excel:
|
133 | return OfficeApp.Excel;
|
134 | case OfficeApp.OneNote:
|
135 | return OfficeApp.OneNote;
|
136 | case OfficeApp.Outlook:
|
137 | return OfficeApp.Outlook;
|
138 | case OfficeApp.PowerPoint:
|
139 | return OfficeApp.PowerPoint;
|
140 | case OfficeApp.Project:
|
141 | return OfficeApp.Project;
|
142 | case OfficeApp.Word:
|
143 | return OfficeApp.Word;
|
144 | default:
|
145 | return undefined;
|
146 | }
|
147 | }
|
148 | exports.toOfficeApp = toOfficeApp;
|
149 |
|
\ | No newline at end of file |