@reveldigital/player-client 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/schematics/collection.json +16 -0
- package/schematics/ng-add/assets/user-prefs.yml +54 -0
- package/schematics/ng-add/index.d.ts +4 -0
- package/schematics/ng-add/index.js +288 -0
- package/schematics/ng-add/index.js.map +1 -0
- package/schematics/ng-add/schema.d.ts +4 -0
- package/schematics/ng-add/schema.js +3 -0
- package/schematics/ng-add/schema.js.map +1 -0
- package/schematics/ng-add/schema.json +24 -0
- package/schematics/ng-add/templates/index.html +31 -0
- package/schematics/ng-add/templates/polyfills.ts +72 -0
- package/schematics/ng-add/utils/changeBasePath.js +19 -0
- package/schematics/ng-add/utils/yml2xml.js +131 -0
package/package.json
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../../../node_modules/@angular-devkit/schematics/collection-schema.json",
|
|
3
|
+
"schematics": {
|
|
4
|
+
"ng-add": {
|
|
5
|
+
"description": "Add the Revel Digital client library to your project.",
|
|
6
|
+
"factory": "./ng-add/index#dependencies",
|
|
7
|
+
"schema": "./ng-add/schema.json"
|
|
8
|
+
},
|
|
9
|
+
"after-dependencies": {
|
|
10
|
+
"description": "Add the Revel Digital client library to your project.",
|
|
11
|
+
"factory": "./ng-add/index#ngAdd",
|
|
12
|
+
"schema": "./ng-add/schema.json",
|
|
13
|
+
"private": true
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
title: My Gadget
|
|
2
|
+
title_url: https://mysupporturl.org
|
|
3
|
+
description: Describe the purpose of your gadget here
|
|
4
|
+
author: My Organization
|
|
5
|
+
background: transparent
|
|
6
|
+
|
|
7
|
+
requirements:
|
|
8
|
+
- reveldigital
|
|
9
|
+
- offline
|
|
10
|
+
- webfont
|
|
11
|
+
|
|
12
|
+
locales:
|
|
13
|
+
- messages: https://reveldigital.github.io/reveldigital-gadgets/ALL_ALL.xml
|
|
14
|
+
|
|
15
|
+
- lang: ru
|
|
16
|
+
messages: https://reveldigital.github.io/reveldigital-gadgets/ALL_ALL.xml
|
|
17
|
+
|
|
18
|
+
prefs:
|
|
19
|
+
- name: myStringPref
|
|
20
|
+
display_name: Sample string preference
|
|
21
|
+
datatype: string
|
|
22
|
+
default_value: test string
|
|
23
|
+
required: true
|
|
24
|
+
|
|
25
|
+
- name: myBoolPref
|
|
26
|
+
display_name: Sample boolean preference
|
|
27
|
+
datatype: bool
|
|
28
|
+
default_value: true
|
|
29
|
+
required: true
|
|
30
|
+
depends:
|
|
31
|
+
- name: myEnumPref
|
|
32
|
+
any_of:
|
|
33
|
+
- fast
|
|
34
|
+
|
|
35
|
+
- name: myStylePref
|
|
36
|
+
display_name: Sample style preference
|
|
37
|
+
datatype: style
|
|
38
|
+
default_value: font-family:Verdana;color:rgb(255, 255, 255);font-size:18px;
|
|
39
|
+
required: true
|
|
40
|
+
|
|
41
|
+
- name: myEnumPref
|
|
42
|
+
display_name: Sample enum preference
|
|
43
|
+
datatype: enum
|
|
44
|
+
default_value: fast
|
|
45
|
+
required: true
|
|
46
|
+
options:
|
|
47
|
+
- value: fastest
|
|
48
|
+
display_value: Fastest
|
|
49
|
+
|
|
50
|
+
- value: fast
|
|
51
|
+
display_value: Fast
|
|
52
|
+
|
|
53
|
+
- value: medium
|
|
54
|
+
display_value: Medium
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.dependencies = exports.ngAdd = void 0;
|
|
13
|
+
const tasks_1 = require("@angular-devkit/schematics/tasks");
|
|
14
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
15
|
+
const dependencies_1 = require("@schematics/angular/utility/dependencies");
|
|
16
|
+
const core_1 = require("@angular-devkit/core");
|
|
17
|
+
const interface_1 = require("@angular-devkit/schematics/src/tree/interface");
|
|
18
|
+
const ast_utils_1 = require("@schematics/angular/utility/ast-utils");
|
|
19
|
+
const ng_ast_utils_1 = require("@schematics/angular/utility/ng-ast-utils");
|
|
20
|
+
const change_1 = require("@schematics/angular/utility/change");
|
|
21
|
+
const ts = require("typescript");
|
|
22
|
+
// Just return the tree
|
|
23
|
+
function ngAdd(options) {
|
|
24
|
+
return (tree, context) => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
//const chalk = require('chalk');
|
|
26
|
+
context.logger.log('info', `🔧 Updating project: ${options.project}`);
|
|
27
|
+
//context.logger.log('info', `✅️ YAML Exists: ${options.yamlExists}`);
|
|
28
|
+
//const workspace = await readWorkspace(host);
|
|
29
|
+
const host = createHost(tree);
|
|
30
|
+
const { workspace } = yield core_1.workspaces.readWorkspace('/', host);
|
|
31
|
+
if (!options.project) {
|
|
32
|
+
options.project = workspace.projects.keys().next().value;
|
|
33
|
+
}
|
|
34
|
+
// const project = workspace.projects.get(options.project);
|
|
35
|
+
// if (!project) {
|
|
36
|
+
// throw new SchematicsException(`Invalid project name: ${options.project}`);
|
|
37
|
+
// }
|
|
38
|
+
const project = (options.project != null) ? workspace.projects.get(options.project) : null;
|
|
39
|
+
if (!project) {
|
|
40
|
+
throw new schematics_1.SchematicsException(`Invalid project name: ${options.project}`);
|
|
41
|
+
}
|
|
42
|
+
const projectType = project.extensions.projectType === 'application' ? 'app' : 'lib';
|
|
43
|
+
if (projectType !== 'app') {
|
|
44
|
+
throw new schematics_1.SchematicsException(`Invalid project type: ${projectType}. Project must be an application.`);
|
|
45
|
+
}
|
|
46
|
+
const buildTarget = project.targets.get('build');
|
|
47
|
+
if (!buildTarget) {
|
|
48
|
+
throw new schematics_1.SchematicsException('Target build not found');
|
|
49
|
+
}
|
|
50
|
+
const buildOptions = (buildTarget.options || {});
|
|
51
|
+
const { main } = buildOptions; //'projects/test-app/src/main.ts'
|
|
52
|
+
context.addTask(new tasks_1.NodePackageInstallTask());
|
|
53
|
+
updatePackageJson(project.root || '', tree, options, context);
|
|
54
|
+
return (0, schematics_1.chain)([
|
|
55
|
+
addFiles('assets', project.sourceRoot),
|
|
56
|
+
addFiles('utils', project.root),
|
|
57
|
+
replaceHTML(project.sourceRoot),
|
|
58
|
+
addPackageJsonDependencies(),
|
|
59
|
+
installPackageJsonDependencies(),
|
|
60
|
+
updateAppModule(main),
|
|
61
|
+
callDeploySchematic(options.project, options.useGithubPages)
|
|
62
|
+
]);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
exports.ngAdd = ngAdd;
|
|
66
|
+
function dependencies(options) {
|
|
67
|
+
return (_tree, context) => {
|
|
68
|
+
const installTaskId = context.addTask(new tasks_1.NodePackageInstallTask({
|
|
69
|
+
packageName: 'angular-cli-ghpages'
|
|
70
|
+
}));
|
|
71
|
+
context.addTask(new tasks_1.RunSchematicTask('after-dependencies', options), [installTaskId]);
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
exports.dependencies = dependencies;
|
|
75
|
+
function callDeploySchematic(project, useGithubPages) {
|
|
76
|
+
return (_tree, _context) => {
|
|
77
|
+
if (useGithubPages) {
|
|
78
|
+
const rule = (0, schematics_1.externalSchematic)("angular-cli-ghpages", "ng-add", { project: project });
|
|
79
|
+
return rule;
|
|
80
|
+
}
|
|
81
|
+
return _tree;
|
|
82
|
+
//_context.addTask(new RunSchematicTask("angular-cli-ghpages", "ng-add", _options));
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function replaceHTML(srcRoot) {
|
|
86
|
+
return (tree, context) => {
|
|
87
|
+
const files = (0, schematics_1.apply)((0, schematics_1.url)('templates'), [
|
|
88
|
+
(0, schematics_1.template)({}),
|
|
89
|
+
(0, schematics_1.move)(`${srcRoot}`),
|
|
90
|
+
]);
|
|
91
|
+
return (0, schematics_1.chain)([(0, schematics_1.mergeWith)(files, interface_1.MergeStrategy.Overwrite)])(tree, context);
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function addFiles(folder, root) {
|
|
95
|
+
return (tree, context) => {
|
|
96
|
+
context.logger.log('info', `✅️ Adding ${folder}`);
|
|
97
|
+
const files = (0, schematics_1.apply)((0, schematics_1.url)(folder), [
|
|
98
|
+
(0, schematics_1.template)({}),
|
|
99
|
+
(0, schematics_1.move)(`${root}/${folder}`),
|
|
100
|
+
]);
|
|
101
|
+
return (0, schematics_1.chain)([(0, schematics_1.mergeWith)(files, interface_1.MergeStrategy.Overwrite)])(tree, context);
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function addPackageJsonDependencies() {
|
|
105
|
+
return (host, context) => {
|
|
106
|
+
const dependencies = [
|
|
107
|
+
{
|
|
108
|
+
type: dependencies_1.NodeDependencyType.Dev,
|
|
109
|
+
name: '@reveldigital/gadget-types',
|
|
110
|
+
version: '^1.0.0',
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
type: dependencies_1.NodeDependencyType.Dev,
|
|
114
|
+
name: 'xmlbuilder2',
|
|
115
|
+
version: '^3.1.1',
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
type: dependencies_1.NodeDependencyType.Dev,
|
|
119
|
+
name: 'node-html-parser',
|
|
120
|
+
version: '6.1.5',
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
type: dependencies_1.NodeDependencyType.Dev,
|
|
124
|
+
name: 'angular-cli-ghpages',
|
|
125
|
+
version: '1.0.6',
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
type: dependencies_1.NodeDependencyType.Dev,
|
|
129
|
+
name: 'git-remote-origin-url',
|
|
130
|
+
version: '^4.0.0',
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
type: dependencies_1.NodeDependencyType.Dev,
|
|
134
|
+
name: 'js-yaml',
|
|
135
|
+
version: '^4.1.0',
|
|
136
|
+
},
|
|
137
|
+
];
|
|
138
|
+
dependencies.forEach(dependency => {
|
|
139
|
+
(0, dependencies_1.addPackageJsonDependency)(host, dependency);
|
|
140
|
+
context.logger.log('info', `✅️ Added "${dependency.name}" into ${dependency.type}`);
|
|
141
|
+
});
|
|
142
|
+
return host;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function installPackageJsonDependencies() {
|
|
146
|
+
return (host, context) => {
|
|
147
|
+
context.addTask(new tasks_1.NodePackageInstallTask());
|
|
148
|
+
context.logger.log('info', `🔍 Installing packages...`);
|
|
149
|
+
return host;
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function updateAppModule(mainPath) {
|
|
153
|
+
return (host, context) => {
|
|
154
|
+
context.logger.log('info', '✅️ Updating appmodule');
|
|
155
|
+
const modulePath = (0, ng_ast_utils_1.getAppModulePath)(host, mainPath);
|
|
156
|
+
context.logger.log('info', `Using module path: ${modulePath}`);
|
|
157
|
+
addImport(host, modulePath, 'PlayerClientModule', '@reveldigital/player-client');
|
|
158
|
+
//addImport(host, modulePath, 'isDevMode', '@angular/core');
|
|
159
|
+
// register SW in application module
|
|
160
|
+
// const importText = tags.stripIndent`
|
|
161
|
+
// ServiceWorkerModule.register('ngsw-worker.js', {
|
|
162
|
+
// enabled: !isDevMode(),
|
|
163
|
+
// // Register the ServiceWorker as soon as the application is stable
|
|
164
|
+
// // or after 30 seconds (whichever comes first).
|
|
165
|
+
// registrationStrategy: 'registerWhenStable:30000'
|
|
166
|
+
// })
|
|
167
|
+
// `;
|
|
168
|
+
const moduleSource = getTsSourceFile(host, modulePath);
|
|
169
|
+
const metadataChanges = (0, ast_utils_1.addSymbolToNgModuleMetadata)(moduleSource, modulePath, 'imports', 'PlayerClientModule');
|
|
170
|
+
if (metadataChanges) {
|
|
171
|
+
const recorder = host.beginUpdate(modulePath);
|
|
172
|
+
(0, change_1.applyToUpdateRecorder)(recorder, metadataChanges);
|
|
173
|
+
host.commitUpdate(recorder);
|
|
174
|
+
}
|
|
175
|
+
return host;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function addImport(host, filePath, symbolName, moduleName) {
|
|
179
|
+
const moduleSource = getTsSourceFile(host, filePath);
|
|
180
|
+
const change = (0, ast_utils_1.insertImport)(moduleSource, filePath, symbolName, moduleName);
|
|
181
|
+
if (change) {
|
|
182
|
+
const recorder = host.beginUpdate(filePath);
|
|
183
|
+
(0, change_1.applyToUpdateRecorder)(recorder, [change]);
|
|
184
|
+
host.commitUpdate(recorder);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
function getTsSourceFile(host, path) {
|
|
188
|
+
const content = host.read(path);
|
|
189
|
+
const source = ts.createSourceFile(path, content.toString(), ts.ScriptTarget.Latest, true);
|
|
190
|
+
return source;
|
|
191
|
+
}
|
|
192
|
+
function updateScripts(path, config, tree, _options, _context) {
|
|
193
|
+
// const project = getProject(tree, _options);
|
|
194
|
+
// if (!config['scripts']) {
|
|
195
|
+
// config.scripts = {};
|
|
196
|
+
// }
|
|
197
|
+
// let additionalFlags = '';
|
|
198
|
+
// // Ivy support
|
|
199
|
+
// const postInstall: string = config.scripts['postinstall'] || '';
|
|
200
|
+
// if (postInstall.startsWith('ngcc')) {
|
|
201
|
+
// config.scripts['postinstall:bak'] = postInstall;
|
|
202
|
+
// config.scripts['postinstall'] = 'ngcc';
|
|
203
|
+
// _context.addTask(new RunSchematicTask('npmRun', { script: 'postinstall' }));
|
|
204
|
+
// }
|
|
205
|
+
// if (!_options.host) {
|
|
206
|
+
// // external web components need single bundle
|
|
207
|
+
// additionalFlags = '--single-bundle';
|
|
208
|
+
// }
|
|
209
|
+
// // Heuristic for default project
|
|
210
|
+
// if (!project.root) {
|
|
211
|
+
// config.scripts['build:externals'] = `ng build --extra-webpack-config ${path}webpack.externals.js --prod ${additionalFlags}`;
|
|
212
|
+
// }
|
|
213
|
+
// if (_options.project) {
|
|
214
|
+
// config.scripts[`build:${_options.project}:externals`] = `ng build --extra-webpack-config ${path}webpack.externals.js --prod --project ${_options.project} ${additionalFlags}`;
|
|
215
|
+
// }
|
|
216
|
+
config.scripts['build:gadget'] = 'npm run change-path && ng build && node utils/yml2xml.js src/assets/user-prefs.yml dist';
|
|
217
|
+
config.scripts['deploy:gadget'] = 'npm run build:gadget && ng deploy --no-build';
|
|
218
|
+
config.scripts['change-path'] = 'node utils/changeBasePath.js';
|
|
219
|
+
}
|
|
220
|
+
function updatePackageJson(path, tree, _options, _context) {
|
|
221
|
+
const config = loadPackageJson(tree);
|
|
222
|
+
updateScripts(path, config, tree, _options, _context);
|
|
223
|
+
savePackageJson(config, tree);
|
|
224
|
+
}
|
|
225
|
+
function savePackageJson(config, tree) {
|
|
226
|
+
const newContentAsString = JSON.stringify(config, null, 2) || '';
|
|
227
|
+
tree.overwrite('package.json', newContentAsString);
|
|
228
|
+
}
|
|
229
|
+
function loadPackageJson(tree) {
|
|
230
|
+
const pkg = tree.read('package.json');
|
|
231
|
+
if (pkg === null)
|
|
232
|
+
throw Error('could not read package.json');
|
|
233
|
+
const contentAsString = pkg.toString('UTF-8');
|
|
234
|
+
const config = JSON.parse(contentAsString);
|
|
235
|
+
return config;
|
|
236
|
+
}
|
|
237
|
+
// function updatePolyfills(srcRoot: string): Rule {
|
|
238
|
+
// return async (tree: Tree, context: SchematicContext) => {
|
|
239
|
+
// console.log(`${srcRoot}polyfills.ts`);
|
|
240
|
+
// const host = createHost(tree);
|
|
241
|
+
// //const workspace = getWorkspace(tree);
|
|
242
|
+
// //const targetProperty = 'es5BrowserSupport';
|
|
243
|
+
// // const propertyExists = propertyExistsInWorkspace(targetProperty, workspace);
|
|
244
|
+
// //let polyfillsData = tree.read(polyfillsFile).toString();
|
|
245
|
+
// const polyfillsData = await host.readFile(`${srcRoot}/polyfills.ts`);
|
|
246
|
+
// console.log(polyfillsData);
|
|
247
|
+
// tree.overwrite(`${srcRoot}/polyfills.ts`, polyfillsData);
|
|
248
|
+
// // if (propertyExists) {
|
|
249
|
+
// // // If project targets angular cli version >= 7.3
|
|
250
|
+
// // workspace.projects[workspace.defaultProject].architect.build.options[targetProperty] = true;
|
|
251
|
+
// // enableWebAnimationsAndGridSupport(tree, polyfillsFile, polyfillsData);
|
|
252
|
+
// // overwriteJsonFile(tree, 'angular.json', workspace);
|
|
253
|
+
// // } else {
|
|
254
|
+
// // // If project targets angular cli version < 7.3
|
|
255
|
+
// // polyfillsData = enablePolyfills(tree, context);
|
|
256
|
+
// // enableWebAnimationsAndGridSupport(tree, polyfillsFile, polyfillsData);
|
|
257
|
+
// // }
|
|
258
|
+
// };
|
|
259
|
+
// }
|
|
260
|
+
function createHost(tree) {
|
|
261
|
+
return {
|
|
262
|
+
readFile(path) {
|
|
263
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
264
|
+
const data = tree.read(path);
|
|
265
|
+
if (!data) {
|
|
266
|
+
throw new schematics_1.SchematicsException('File not found.');
|
|
267
|
+
}
|
|
268
|
+
return core_1.virtualFs.fileBufferToString(data);
|
|
269
|
+
});
|
|
270
|
+
},
|
|
271
|
+
writeFile(path, data) {
|
|
272
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
273
|
+
return tree.overwrite(path, data);
|
|
274
|
+
});
|
|
275
|
+
},
|
|
276
|
+
isDirectory(path) {
|
|
277
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
278
|
+
return !tree.exists(path) && tree.getDir(path).subfiles.length > 0;
|
|
279
|
+
});
|
|
280
|
+
},
|
|
281
|
+
isFile(path) {
|
|
282
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
283
|
+
return tree.exists(path);
|
|
284
|
+
});
|
|
285
|
+
},
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../projects/reveldigital/player-client/schematics/ng-add/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4DAA4F;AAC5F,2DAGoC;AACpC,2EAIkD;AAClD,+CAA6D;AAC7D,6EAA8E;AAC9E,qEAAkG;AAClG,2EAA4E;AAE5E,+DAA2E;AAC3E,iCAAiC;AAKjC,uBAAuB;AACvB,SAAgB,KAAK,CAAC,OAAwB;IAC5C,OAAO,CAAO,IAAU,EAAE,OAAyB,EAAE,EAAE;QACrD,iCAAiC;QAEjC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,wBAAwB,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QACtE,sEAAsE;QAEtE,8CAA8C;QAE9C,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;QAC9B,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,iBAAU,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAEhE,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACpB,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;SAC1D;QACD,2DAA2D;QAC3D,kBAAkB;QAClB,+EAA+E;QAC/E,IAAI;QAEJ,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC3F,IAAI,CAAC,OAAO,EA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ACpD,sFAAsF;AACtF,iEAAiE;AACjE,4EAA4E;AAE5E,kCAAkC;AAElC,gEAAgE;AAEhE,+BAA+B;AAC/B,4DAA4D;AAC5D,wGAAwG;AACxG,kFAAkF;AAClF,+DAA+D;AAC/D,kBAAkB;AAClB,2DAA2D;AAC3D,2DAA2D;AAC3D,kFAAkF;AAClF,WAAW;AACX,OAAO;AACP,IAAI;AAEJ,SAAS,UAAU,CAAC,IAAU;IAC5B,OAAO;QACC,QAAQ,CAAC,IAAY;;gBACzB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC7B,IAAI,CAAC,IAAI,EAAE;oBACT,MAAM,IAAI,gCAAmB,CAAC,iBAAiB,CAAC,CAAC;iBAClD;gBACD,OAAO,gBAAS,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;YAC5C,CAAC;SAAA;QACK,SAAS,CAAC,IAAY,EAAE,IAAY;;gBACxC,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACpC,CAAC;SAAA;QACK,WAAW,CAAC,IAAY;;gBAC5B,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;YACrE,CAAC;SAAA;QACK,MAAM,CAAC,IAAY;;gBACvB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAC3B,CAAC;SAAA;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../projects/reveldigital/player-client/schematics/ng-add/schema.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "RevelDigitalSchematicsNgAdd",
|
|
4
|
+
"title": "Revel Digital client library schematic",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"description": "Creates Revel Digital client library config files and adds dependencies.",
|
|
8
|
+
"properties": {
|
|
9
|
+
"project": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "The name of the project.",
|
|
12
|
+
"$default": {
|
|
13
|
+
"$source": "projectName"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"useGithubPages": {
|
|
17
|
+
"type": "boolean",
|
|
18
|
+
"x-prompt": "Publishing this gadget to GitHub pages?"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"required": [
|
|
22
|
+
"project"
|
|
23
|
+
]
|
|
24
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title>Revel Digital Gadget</title>
|
|
6
|
+
<base href="/">
|
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
8
|
+
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
|
9
|
+
<style type="text/css">
|
|
10
|
+
/*noinspection ALL*/
|
|
11
|
+
html {
|
|
12
|
+
width: __UP_rdW__px;
|
|
13
|
+
height: __UP_rdH__px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/*noinspection ALL*/
|
|
17
|
+
body,
|
|
18
|
+
app-root {
|
|
19
|
+
background: transparent;
|
|
20
|
+
width: __UP_rdW__px;
|
|
21
|
+
height: __UP_rdH__px;
|
|
22
|
+
overflow: hidden;
|
|
23
|
+
}
|
|
24
|
+
</style>
|
|
25
|
+
</head>
|
|
26
|
+
|
|
27
|
+
<body>
|
|
28
|
+
<app-root></app-root>
|
|
29
|
+
</body>
|
|
30
|
+
|
|
31
|
+
</html>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file includes polyfills needed by Angular and is loaded before the app.
|
|
3
|
+
* You can add your own extra polyfills to this file.
|
|
4
|
+
*
|
|
5
|
+
* This file is divided into 2 sections:
|
|
6
|
+
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
|
|
7
|
+
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
|
|
8
|
+
* file.
|
|
9
|
+
*
|
|
10
|
+
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
|
|
11
|
+
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
|
|
12
|
+
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
|
|
13
|
+
*
|
|
14
|
+
* Learn more in https://angular.io/guide/browser-support
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/***************************************************************************************************
|
|
18
|
+
* BROWSER POLYFILLS
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* By default, zone.js will patch all possible macroTask and DomEvents
|
|
23
|
+
* user can disable parts of macroTask/DomEvents patch by setting following flags
|
|
24
|
+
* because those flags need to be set before `zone.js` being loaded, and webpack
|
|
25
|
+
* will put import in the top of bundle, so user need to create a separate file
|
|
26
|
+
* in this directory (for example: zone-flags.ts), and put the following flags
|
|
27
|
+
* into that file, and then add the following code before importing zone.js.
|
|
28
|
+
* import './zone-flags';
|
|
29
|
+
*
|
|
30
|
+
* The flags allowed in zone-flags.ts are listed here.
|
|
31
|
+
*
|
|
32
|
+
* The following flags will work for all browsers.
|
|
33
|
+
*
|
|
34
|
+
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
|
|
35
|
+
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
|
|
36
|
+
* (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
|
|
37
|
+
*
|
|
38
|
+
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
|
|
39
|
+
* with the following flag, it will bypass `zone.js` patch for IE/Edge
|
|
40
|
+
*
|
|
41
|
+
* (window as any).__Zone_enable_cross_context_check = true;
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/***************************************************************************************************
|
|
46
|
+
* Zone JS is required by default for Angular itself.
|
|
47
|
+
*/
|
|
48
|
+
import 'zone.js'; // Included with Angular CLI.
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
/***************************************************************************************************
|
|
52
|
+
* APPLICATION IMPORTS
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/***************************************************************************************************
|
|
56
|
+
* REVEL DIGITAL GLOBALS IMPORTS
|
|
57
|
+
*/
|
|
58
|
+
(window as any).global = window;
|
|
59
|
+
|
|
60
|
+
interface IController {
|
|
61
|
+
onCommand(name: string, arg: string): void;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface IRevelDigital {
|
|
65
|
+
Controller: IController;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
declare global {
|
|
69
|
+
interface Window {
|
|
70
|
+
RevelDigital: IRevelDigital;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const ajson = require('../angular.json');
|
|
2
|
+
const pjson = require('../package.json');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const gitRemoteOriginUrl = (...args) => import('git-remote-origin-url').then(({ default: fetch }) => fetch(...args));
|
|
5
|
+
|
|
6
|
+
gitRemoteOriginUrl().then(name => {
|
|
7
|
+
let vals = name.split('/');
|
|
8
|
+
let path = `https://${vals[3]}.github.io/${vals[4].split('.')[0]}/`
|
|
9
|
+
|
|
10
|
+
console.log(`🌎 Configuring gadget deployment URL: ${path}${pjson.name}.xml`);
|
|
11
|
+
|
|
12
|
+
// Update angular.json baseHref/deployUrl with full path to our app
|
|
13
|
+
ajson.projects[pjson.name].architect.build.configurations.production.baseHref = path;
|
|
14
|
+
ajson.projects[pjson.name].architect.build.configurations.production.deployUrl = path;
|
|
15
|
+
|
|
16
|
+
fs.writeFile('./angular.json', JSON.stringify(ajson, null, 4), function writeJSON(err) {
|
|
17
|
+
if (err) return console.log(err);
|
|
18
|
+
});
|
|
19
|
+
})
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
const yaml = require('js-yaml');
|
|
2
|
+
const HTMLParser = require('node-html-parser');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const { create } = require('xmlbuilder2');
|
|
5
|
+
const pjson = require('../package.json');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
try {
|
|
9
|
+
const doc = yaml.load(fs.readFileSync(process.argv[2], 'utf8'));
|
|
10
|
+
const html = fs.readFileSync(process.argv[3] + `/${pjson.name}/index.html`);
|
|
11
|
+
|
|
12
|
+
fs.writeFileSync(`${process.argv[3]}/${pjson.name}/${pjson.name}.xml`, processYML(doc, html));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
console.log(e);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
function processYML(json, html) {
|
|
19
|
+
|
|
20
|
+
const root = create({ version: '1.0', encoding: 'UTF-8' });
|
|
21
|
+
|
|
22
|
+
const module = root.ele('Module');
|
|
23
|
+
const modulePrefs = module.ele('ModulePrefs', {
|
|
24
|
+
title: json.title,
|
|
25
|
+
title_url: json.title_url,
|
|
26
|
+
version: pjson.version,
|
|
27
|
+
description: json.description,
|
|
28
|
+
author: json.author,
|
|
29
|
+
background: json.background
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (json.locales) {
|
|
33
|
+
for (let val of json.locales) {
|
|
34
|
+
const locale = modulePrefs.ele('Locale');
|
|
35
|
+
if (val.lang) {
|
|
36
|
+
locale.att('lang', val.lang);
|
|
37
|
+
}
|
|
38
|
+
locale.att('messages', val.messages);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (json.requirements) {
|
|
43
|
+
for (let val of json.requirements) {
|
|
44
|
+
modulePrefs.ele('Require', { feature: val });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (json.prefs) {
|
|
49
|
+
for (let val of json.prefs) {
|
|
50
|
+
const userPref = modulePrefs.ele('UserPref', {
|
|
51
|
+
name: val.name,
|
|
52
|
+
display_name: val.display_name,
|
|
53
|
+
datatype: val.datatype,
|
|
54
|
+
default_value: val.default_value,
|
|
55
|
+
required: !!val.required
|
|
56
|
+
});
|
|
57
|
+
if (val.datatype === 'enum') {
|
|
58
|
+
for (let option of val.options) {
|
|
59
|
+
userPref.ele('EnumValue', {
|
|
60
|
+
value: option.value,
|
|
61
|
+
display_value: option.display_value
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (val.depends) {
|
|
67
|
+
appendDepends(val.depends, userPref);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
modulePrefs.ele('UserPref', {
|
|
73
|
+
name: 'rdW',
|
|
74
|
+
display_name: 'Width',
|
|
75
|
+
datatype: 'hidden',
|
|
76
|
+
default_value: 280,
|
|
77
|
+
required: true
|
|
78
|
+
});
|
|
79
|
+
modulePrefs.ele('UserPref', {
|
|
80
|
+
name: 'rdH',
|
|
81
|
+
display_name: 'Height',
|
|
82
|
+
datatype: 'hidden',
|
|
83
|
+
default_value: 190,
|
|
84
|
+
required: true
|
|
85
|
+
});
|
|
86
|
+
modulePrefs.ele('UserPref', {
|
|
87
|
+
name: 'rdKey',
|
|
88
|
+
datatype: 'hidden'
|
|
89
|
+
});
|
|
90
|
+
modulePrefs.ele('UserPref', {
|
|
91
|
+
name: 'ForeColor',
|
|
92
|
+
datatype: 'hidden'
|
|
93
|
+
});
|
|
94
|
+
modulePrefs.ele('UserPref', {
|
|
95
|
+
name: 'BackColor',
|
|
96
|
+
datatype: 'hidden'
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
var htmlRoot = HTMLParser.parse(html);
|
|
100
|
+
module.ele('Content', { type: 'html' }).ele({
|
|
101
|
+
'$':
|
|
102
|
+
htmlRoot.querySelector('style').toString() +
|
|
103
|
+
htmlRoot.querySelector('link').toString() +
|
|
104
|
+
htmlRoot.querySelector('body').toString()
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
return root.end({ prettyPrint: true });
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
function appendDepends(depends, el) {
|
|
112
|
+
|
|
113
|
+
for (let dep of depends) {
|
|
114
|
+
const d = el.ele('DependsOn', {
|
|
115
|
+
name: dep.name,
|
|
116
|
+
type: dep.any_of ? 'any_of' : dep.all_of ? 'all_of' : 'none_of'
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
var arr = [].concat(dep.any_of, dep.all_of, dep.none_of).filter(o => o != null);
|
|
120
|
+
for (let a of arr) {
|
|
121
|
+
if (a.values) {
|
|
122
|
+
for (let val of a.values) {
|
|
123
|
+
d.ele('Value').txt(val);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (a.depends) {
|
|
127
|
+
appendDepends(a.depends, d);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|