@24i/smartapps-bigscreen-rnv-build-engine 0.13.0 → 0.13.1-alpha.1774

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.
@@ -7,6 +7,7 @@ const child_process_1 = require("child_process");
7
7
  const fs_1 = require("fs");
8
8
  const manifoldjs_windows10_1 = require("manifoldjs-windows10");
9
9
  const resolvers_1 = require("../../resolvers");
10
+ const xml2js = require('xml2js');
10
11
  const fs = fs_1.promises;
11
12
  const { logTask } = rnv_1.Logger;
12
13
  const hostedAppOutputPath = '/output/hosted';
@@ -15,6 +16,8 @@ const packagedAppSrcDestination = '/output/packaged/windows10/source/src';
15
16
  const appSourcePath = '/project/public';
16
17
  const packagedAppEntryUrl = 'src/index.html';
17
18
  const wrapperConfigPath = '/wrapperConfig.json';
19
+ const hostedAppSource = '/output/hosted/windows10/source';
20
+ const packagedAppSource = '/output/packaged/windows10/source';
18
21
  const hostedSourceImages = '/output/hosted/windows10/source/images';
19
22
  const packagedSourceImages = '/output/packaged/windows10/source/images';
20
23
  const hostedManifestImages = '/output/hosted/windows10/manifest/images';
@@ -87,6 +90,49 @@ const createPackagedApplication = async (c) => {
87
90
  const destinationDirectory = `${getBuildFolder(c)}${packagedAppSrcDestination}`;
88
91
  await createVSSolution(c, `${getBuildFolder(c)}${packagedAppOutputPath}`, manifest);
89
92
  (0, child_process_1.execSync)(`cp -r ${sourceDir} ${destinationDirectory}`);
93
+ await addPackagedFiles(c);
94
+ };
95
+ const readContent = async (c, path) => {
96
+ logTask('readContent');
97
+ const srcDirectory = `${getBuildFolder(c)}${packagedAppSource}/${path}`;
98
+ let content = [];
99
+ try {
100
+ const res = await fs.readdir(srcDirectory, { withFileTypes: true });
101
+ for (let i = 0; i < res.length; i++) {
102
+ const file = res[i];
103
+ const fileNameWithPath = `${path}/${file.name}`;
104
+ if (file.isDirectory()) {
105
+ const subdirectoryContent = await readContent(c, fileNameWithPath);
106
+ content = content.concat(subdirectoryContent);
107
+ }
108
+ else {
109
+ content.push(fileNameWithPath);
110
+ }
111
+ }
112
+ }
113
+ catch (err) {
114
+ throw new Error('Failed to parse project content');
115
+ }
116
+ return content;
117
+ };
118
+ const addPackagedFiles = async (c) => {
119
+ logTask('addPackagedFiles');
120
+ const destinationDirectory = `${getBuildFolder(c)}${packagedAppSource}/App.jsproj`;
121
+ try {
122
+ let xmlString = await fs.readFile(destinationDirectory, 'utf-8');
123
+ const xmlObject = await xml2js.parseStringPromise(xmlString);
124
+ const srcDirectoryContent = await readContent(c, 'src');
125
+ srcDirectoryContent.forEach((element) => {
126
+ const contentElement = { $: { Include: element } };
127
+ xmlObject.Project.ItemGroup[1].Content.push(contentElement);
128
+ });
129
+ const builder = new xml2js.Builder();
130
+ xmlString = builder.buildObject(xmlObject);
131
+ await fs.writeFile(destinationDirectory, xmlString);
132
+ }
133
+ catch {
134
+ throw new Error('Failed to parse update App.jsproj project file');
135
+ }
90
136
  };
91
137
  const replacePublisherId = async (c, basePath) => {
92
138
  logTask('replacePublisherId');
@@ -144,6 +190,20 @@ const replaceImages = async (c) => {
144
190
  throw new Error('Failed to replace the xbox icons');
145
191
  }
146
192
  };
193
+ const copyWinJS = async (c) => {
194
+ const source = process.cwd() + '/node_modules/@24i/smartapps-bigscreen-rnv-build-engine/dist/src/sdks/sdk-xbox/winjs/directionalnavigation-1.0.0.0.js';
195
+ const packagedAppDestination = `${getBuildFolder(c)}${packagedAppSource}/lib/TVHelpers`;
196
+ const hostedAppDestination = `${getBuildFolder(c)}${hostedAppSource}/lib/TVHelpers`;
197
+ try {
198
+ await fs.mkdir(packagedAppDestination, { recursive: true });
199
+ await fs.mkdir(hostedAppDestination, { recursive: true });
200
+ (0, child_process_1.execSync)(`cp -r ${source} ${packagedAppDestination}`);
201
+ (0, child_process_1.execSync)(`cp -r ${source} ${hostedAppDestination}`);
202
+ }
203
+ catch {
204
+ throw new Error('Failed to copy the winJS library');
205
+ }
206
+ };
147
207
  const buildXboxProject = async (c) => {
148
208
  logTask('buildXboxProject');
149
209
  const outputDirectory = `${getBuildFolder(c)}/output`;
@@ -154,6 +214,7 @@ const buildXboxProject = async (c) => {
154
214
  await replacePublisherId(c, `${getBuildFolder(c)}${hostedAppOutputPath}`);
155
215
  await replacePublisherId(c, `${getBuildFolder(c)}${packagedAppOutputPath}`);
156
216
  await replaceImages(c);
217
+ await copyWinJS(c);
157
218
  await zipOutput(c);
158
219
  };
159
220
  exports.buildXboxProject = buildXboxProject;
@@ -32,6 +32,10 @@ const htmlTemp = (options) => {
32
32
  if (debug === 'true' && debugIp) {
33
33
  remoteDebugScript = `<script src="http://${debugIp}:8080/target/target-script-min.js#anonymous"></script>`;
34
34
  }
35
+ let xboxScripts = '';
36
+ if (platform === 'xbox') {
37
+ xboxScripts = '<script src="/lib/TVHelpers/directionalnavigation-1.0.0.0.js"></script>';
38
+ }
35
39
  let tizenScripts = '';
36
40
  if (platform === 'tizen') {
37
41
  tizenScripts = '<script type="text/javascript" src="$WEBAPIS/webapis/webapis.js"></script>';
@@ -55,6 +59,7 @@ ${htmlTag}
55
59
  ${remoteDebugScript}
56
60
  ${isDebug ? errScript : ''}
57
61
  ${tizenScripts}
62
+ ${xboxScripts}
58
63
  ${headAppend}
59
64
  </head>
60
65
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@24i/smartapps-bigscreen-rnv-build-engine",
3
- "version": "0.13.0",
3
+ "version": "0.13.1-alpha.1774+12348962",
4
4
  "description": "Package with build engine for SmartApps BIGscreen projects...",
5
5
  "main": "dist/src/index.js",
6
6
  "scripts": {
@@ -79,5 +79,5 @@
79
79
  "keywords": [],
80
80
  "author": "24i",
81
81
  "license": "ISC",
82
- "gitHead": "8118c9fff07ffff6132bb33eb542b3074a33a396"
82
+ "gitHead": "123489624368f3d598648187cb65c0b0493b8a8b"
83
83
  }