@krx3d/tizentubekrx 1.15.3 → 1.15.7
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/.github/workflows/publish-on-release.yml +13 -15
- package/dist/service.js +162 -0
- package/dist/userScript.js +2285 -0
- package/package.json +4 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
name: Publish to
|
|
1
|
+
name: Publish to NPM
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
@@ -8,25 +8,23 @@ on:
|
|
|
8
8
|
jobs:
|
|
9
9
|
publish:
|
|
10
10
|
runs-on: ubuntu-latest
|
|
11
|
-
|
|
12
11
|
steps:
|
|
13
|
-
-
|
|
14
|
-
uses: actions/checkout@v4
|
|
12
|
+
- uses: actions/checkout@v3
|
|
15
13
|
|
|
16
|
-
- name:
|
|
17
|
-
uses: actions/setup-node@
|
|
14
|
+
- name: Use Node.js
|
|
15
|
+
uses: actions/setup-node@v3
|
|
18
16
|
with:
|
|
19
|
-
node-version: 20
|
|
20
|
-
registry-url: https://registry.npmjs.org/
|
|
17
|
+
node-version: '20'
|
|
18
|
+
registry-url: 'https://registry.npmjs.org/'
|
|
19
|
+
scope: '@krx3d'
|
|
20
|
+
|
|
21
|
+
- name: Install dependencies
|
|
22
|
+
run: npm install
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
run: |
|
|
25
|
-
node -v
|
|
26
|
-
npm -v
|
|
27
|
-
cat package.json
|
|
24
|
+
- name: Build dist folder
|
|
25
|
+
run: npm run build
|
|
28
26
|
|
|
29
|
-
- name: Publish
|
|
27
|
+
- name: Publish package
|
|
30
28
|
run: npm publish --access public
|
|
31
29
|
env:
|
|
32
30
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/dist/service.js
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import resolve from '@rollup/plugin-node-resolve';
|
|
2
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
3
|
+
import babel from '@rollup/plugin-babel';
|
|
4
|
+
import replace from '@rollup/plugin-replace';
|
|
5
|
+
import json from '@rollup/plugin-json';
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
|
|
8
|
+
// Custom Rollup plugin to inject XML content
|
|
9
|
+
function injectXmlContent() {
|
|
10
|
+
return {
|
|
11
|
+
name: 'inject-xml-content',
|
|
12
|
+
renderChunk(code) {
|
|
13
|
+
|
|
14
|
+
const pattern = /var\s+(\w+)_TEMPLATE\s+=\s+fs\$3\.readFileSync\(__dirname\s+\+\s+'\/\.\.\/xml\/([^']+)'\s*,\s*'utf8'\);/g;
|
|
15
|
+
|
|
16
|
+
const modifiedCode = code.replace(pattern, (match, varName, fileName) => {
|
|
17
|
+
const xmlContent = fs.readFileSync(`node_modules/@patrickkfkan/peer-dial/xml/${fileName}`, 'utf8');
|
|
18
|
+
return `var ${varName}_TEMPLATE = ${JSON.stringify(xmlContent)};`;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return { code: modifiedCode, map: null };
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default {
|
|
27
|
+
input: 'service.js',
|
|
28
|
+
output: {
|
|
29
|
+
file: '../dist/service.js',
|
|
30
|
+
format: 'cjs'
|
|
31
|
+
},
|
|
32
|
+
plugins: [
|
|
33
|
+
injectXmlContent(),
|
|
34
|
+
replace({
|
|
35
|
+
'Gate.prototype.await = function await(callback)': 'Gate.prototype.await = function(callback)',
|
|
36
|
+
'Async.prototype.await = function await(callback)': 'Async.prototype.await = function (callback)',
|
|
37
|
+
delimiters: ['', ''],
|
|
38
|
+
}),
|
|
39
|
+
resolve(),
|
|
40
|
+
json(),
|
|
41
|
+
commonjs(),
|
|
42
|
+
babel({
|
|
43
|
+
babelHelpers: 'bundled',
|
|
44
|
+
presets: ['@babel/preset-env']
|
|
45
|
+
})
|
|
46
|
+
]
|
|
47
|
+
};const dial = require("@patrickkfkan/peer-dial");
|
|
48
|
+
const express = require('express');
|
|
49
|
+
const cors = require('cors');
|
|
50
|
+
const app = express();
|
|
51
|
+
|
|
52
|
+
const corsOptions = {
|
|
53
|
+
origin: '*',
|
|
54
|
+
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
|
|
55
|
+
credentials: true,
|
|
56
|
+
optionsSuccessStatus: 204
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
app.use(cors(corsOptions));
|
|
60
|
+
|
|
61
|
+
const PORT = 8085;
|
|
62
|
+
const apps = {
|
|
63
|
+
"YouTube": {
|
|
64
|
+
name: "YouTube",
|
|
65
|
+
state: "stopped",
|
|
66
|
+
allowStop: true,
|
|
67
|
+
pid: null,
|
|
68
|
+
additionalData: {},
|
|
69
|
+
launch(launchData) {
|
|
70
|
+
const tbPackageId = tizen.application.getAppInfo().packageId;
|
|
71
|
+
tizen.application.launchAppControl(
|
|
72
|
+
new tizen.ApplicationControl(
|
|
73
|
+
"http://tizen.org/appcontrol/operation/view",
|
|
74
|
+
null,
|
|
75
|
+
null,
|
|
76
|
+
null,
|
|
77
|
+
[
|
|
78
|
+
new tizen.ApplicationControlData("module", [JSON.stringify(
|
|
79
|
+
{
|
|
80
|
+
moduleName: '@foxreis/tizentube',
|
|
81
|
+
moduleType: 'npm',
|
|
82
|
+
args: launchData
|
|
83
|
+
}
|
|
84
|
+
)])
|
|
85
|
+
]
|
|
86
|
+
), `${tbPackageId}.TizenBrewStandalone`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const dialServer = new dial.Server({
|
|
92
|
+
expressApp: app,
|
|
93
|
+
port: PORT,
|
|
94
|
+
prefix: "/dial",
|
|
95
|
+
manufacturer: 'Reis Can',
|
|
96
|
+
modelName: 'TizenBrew',
|
|
97
|
+
friendlyName: 'TizenTube',
|
|
98
|
+
delegate: {
|
|
99
|
+
getApp(appName) {
|
|
100
|
+
return apps[appName];
|
|
101
|
+
},
|
|
102
|
+
launchApp(appName, launchData, callback) {
|
|
103
|
+
console.log(`Got request to launch ${appName} with launch data: ${launchData}`);
|
|
104
|
+
const app = apps[appName];
|
|
105
|
+
if (app) {
|
|
106
|
+
const parsedData = launchData.split('&').reduce((acc, cur) => {
|
|
107
|
+
const parts = cur.split('=');
|
|
108
|
+
const key = parts[0];
|
|
109
|
+
const value = parts[1];
|
|
110
|
+
|
|
111
|
+
if (typeof value !== 'undefined') {
|
|
112
|
+
acc[key] = value;
|
|
113
|
+
} else {
|
|
114
|
+
acc[key] = '';
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return acc;
|
|
118
|
+
}, {});
|
|
119
|
+
|
|
120
|
+
if (parsedData.yumi) {
|
|
121
|
+
app.additionalData = parsedData;
|
|
122
|
+
app.state = "running"
|
|
123
|
+
callback("");
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
app.pid = "run";
|
|
127
|
+
app.state = "starting";
|
|
128
|
+
app.launch(launchData);
|
|
129
|
+
app.state = "running";
|
|
130
|
+
}
|
|
131
|
+
callback(app.pid);
|
|
132
|
+
},
|
|
133
|
+
stopApp(appName, pid, callback) {
|
|
134
|
+
console.log(`Got request to stop ${appName} with pid: ${pid}`);
|
|
135
|
+
const app = apps[appName];
|
|
136
|
+
if (app && app.pid === pid) {
|
|
137
|
+
app.pid = null;
|
|
138
|
+
app.state = "stopped";
|
|
139
|
+
callback(true);
|
|
140
|
+
} else {
|
|
141
|
+
callback(false);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
setInterval(() => {
|
|
149
|
+
tizen.application.getAppsContext((appsContext) => {
|
|
150
|
+
const tbPackageId = tizen.application.getAppInfo().packageId;
|
|
151
|
+
const app = appsContext.find(app => app.appId === `${tbPackageId}.TizenBrewStandalone`);
|
|
152
|
+
if (!app) {
|
|
153
|
+
apps["YouTube"].state = "stopped";
|
|
154
|
+
apps["YouTube"].pid = null;
|
|
155
|
+
apps["YouTube"].additionalData = {};
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}, 5000);
|
|
159
|
+
|
|
160
|
+
app.listen(PORT, () => {
|
|
161
|
+
dialServer.start();
|
|
162
|
+
});
|