@krx3d/tizentubekrx 1.15.3 → 1.15.15

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.
@@ -1,4 +1,4 @@
1
- name: Publish to npm
1
+ name: Build & Publish to npm (install mods deps + polyfills)
2
2
 
3
3
  on:
4
4
  push:
@@ -6,8 +6,10 @@ on:
6
6
  - main
7
7
 
8
8
  jobs:
9
- publish:
9
+ build-and-publish:
10
10
  runs-on: ubuntu-latest
11
+ env:
12
+ NODE_OPTIONS: --max_old_space_size=4096
11
13
 
12
14
  steps:
13
15
  - name: Checkout repository
@@ -17,16 +19,178 @@ jobs:
17
19
  uses: actions/setup-node@v4
18
20
  with:
19
21
  node-version: 20
20
- registry-url: https://registry.npmjs.org/
22
+ registry-url: 'https://registry.npmjs.org/'
21
23
 
22
- # Optional sanity check helps debugging
23
- - name: Show package info
24
+ - name: Show repo top-level files for debugging
24
25
  run: |
25
- node -v
26
- npm -v
27
- cat package.json
26
+ echo "=== root files ==="
27
+ ls -la
28
+
29
+ - name: Install dependencies for mods (if present)
30
+ run: |
31
+ set -euo pipefail
32
+ if [ -f mods/package.json ]; then
33
+ echo "Installing mods deps using mods/package-lock.json (if present)..."
34
+ # Prefer npm ci in mods (fast, reproducible). Falls back to npm install if no lockfile.
35
+ if [ -f mods/package-lock.json ]; then
36
+ npm ci --prefix mods
37
+ else
38
+ npm install --prefix mods
39
+ fi
40
+ echo "mods/node_modules installed"
41
+ ls -la mods/node_modules | sed -n '1,200p' || true
42
+ else
43
+ echo "No mods/package.json found — skipping."
44
+ fi
45
+
46
+ - name: Install dependencies for service (if present)
47
+ run: |
48
+ set -euo pipefail
49
+ if [ -f service/package.json ]; then
50
+ echo "Installing service deps using service/package-lock.json (if present)..."
51
+ if [ -f service/package-lock.json ]; then
52
+ npm ci --prefix service
53
+ else
54
+ npm install --prefix service
55
+ fi
56
+ echo "service/node_modules installed"
57
+ ls -la service/node_modules | sed -n '1,200p' || true
58
+ else
59
+ echo "No service/package.json found — skipping."
60
+ fi
61
+
62
+ - name: Install bundlers/tools (esbuild + ncc) at repo root
63
+ run: |
64
+ set -euo pipefail
65
+ # Install tooling locally in runner (no-save so package.json not changed)
66
+ npm install --no-save esbuild @vercel/ncc
67
+
68
+ - name: Dump mods/ file list and show userScript head (debug)
69
+ run: |
70
+ echo "=== mods/ files ==="
71
+ ls -la mods || true
72
+ echo "=== first lines of mods/userScript.js ==="
73
+ if [ -f mods/userScript.js ]; then
74
+ sed -n '1,120p' mods/userScript.js || true
75
+ else
76
+ echo "mods/userScript.js missing"
77
+ exit 1
78
+ fi
79
+
80
+ - name: Fetch polyfills & prepare tmp entry (strip poly imports & rewrite relative imports)
81
+ run: |
82
+ set -euo pipefail
83
+ mkdir -p tmp dist
84
+
85
+ # Fetch polyfills from unpkg (adjust pinned versions if you prefer)
86
+ curl -fsSL https://unpkg.com/whatwg-fetch/dist/fetch.umd.js -o tmp/whatwg-fetch.umd.js || true
87
+ curl -fsSL https://unpkg.com/core-js-bundle@3.32.2/minified.js -o tmp/core-js-bundle.min.js || true
88
+
89
+ # formatjs iife bundles often are not exported via package exports; try CDN fallback
90
+ curl -fsSL https://unpkg.com/@formatjs/intl-getcanonicallocales@latest/polyfill.iife.js -o tmp/intl-getcanonicallocales.polyfill.iife.js || true
91
+ curl -fsSL https://unpkg.com/@formatjs/intl-locale@latest/polyfill.iife.js -o tmp/intl-locale.polyfill.iife.js || true
92
+ curl -fsSL https://unpkg.com/@formatjs/intl-displaynames@latest/polyfill.iife.js -o tmp/intl-displaynames.polyfill.iife.js || true
93
+ curl -fsSL https://unpkg.com/@formatjs/intl-displaynames@latest/locale-data/en.js -o tmp/intl-displaynames.locale-data.en.js || true
94
+
95
+ # Concatenate what we downloaded (safe even if parts are missing)
96
+ cat tmp/whatwg-fetch.umd.js tmp/core-js-bundle.min.js tmp/intl-getcanonicallocales.polyfill.iife.js tmp/intl-locale.polyfill.iife.js tmp/intl-displaynames.polyfill.iife.js tmp/intl-displaynames.locale-data.en.js > tmp/polyfills.js || true
97
+ echo "Polyfills length bytes:"
98
+ wc -c tmp/polyfills.js || true
99
+
100
+ # Create temporary entry:
101
+ # 1) remove imports that reference the polyfills we fetched above (case-insensitive)
102
+ # 2) rewrite relative imports "./..." to "../mods/..." so esbuild resolves modules from mods/
103
+ sed -E '/import .*whatwg-fetch|import .*core-js|import .*@formatjs\/intl-getcanonicallocales|import .*@formatjs\/intl-locale|import .*@formatjs\/intl-displaynames|@formatjs\/intl-displaynames\/locale-data/Id' mods/userScript.js > tmp/userScript.entry.step1.js
104
+
105
+ # Convert import "./path/..." to import "../mods/path/..." to keep original import graph but resolvable from tmp/
106
+ sed -E "s|import[[:space:]]+\"\\./([^\"]+)\"|import \"../mods/\\1\"|g; s|import[[:space:]]+'\\./([^']+)'|import '../mods/\\1'|g" tmp/userScript.entry.step1.js > tmp/userScript.entry.js
107
+
108
+ echo "tmp/userScript.entry.js head:"
109
+ sed -n '1,120p' tmp/userScript.entry.js || true
110
+
111
+ - name: Bundle userScript (esbuild) and produce dist/userScript.js
112
+ run: |
113
+ set -euo pipefail
114
+ mkdir -p tmp dist
115
+ # bundle using esbuild
116
+ npx esbuild tmp/userScript.entry.js \
117
+ --bundle \
118
+ --platform=browser \
119
+ --format=iife \
120
+ --minify \
121
+ --outfile=tmp/bundle.userScript.js \
122
+ --banner:js="(function(){if(window.__TIZENTUBE_INJECT_LOADED)return;window.__TIZENTUBE_INJECT_LOADED=true;" \
123
+ --footer:js="})();"
124
+
125
+ # prepend polyfills if present
126
+ if [ -s tmp/polyfills.js ]; then
127
+ cat tmp/polyfills.js tmp/bundle.userScript.js > dist/userScript.js
128
+ else
129
+ cp tmp/bundle.userScript.js dist/userScript.js
130
+ fi
131
+
132
+ echo "Built dist/userScript.js (size):"
133
+ ls -lh dist/userScript.js || true
134
+ head -n 8 dist/userScript.js || true
135
+
136
+ - name: Auto-detect service entry and bundle with ncc
137
+ id: detect_service
138
+ run: |
139
+ set -euo pipefail
140
+ # Find a service entry candidate
141
+ ENTRY=""
142
+ if [ -d service ]; then
143
+ for cand in index.js main.js service.js app.js server.js start.js; do
144
+ if [ -f "service/$cand" ]; then
145
+ ENTRY="service/$cand"
146
+ break
147
+ fi
148
+ done
149
+ if [ -z "$ENTRY" ]; then
150
+ # fallback: first .js file found in service/
151
+ ENTRY=$(find service -maxdepth 1 -type f -name '*.js' | head -n1 || true)
152
+ fi
153
+ fi
154
+ if [ -z "$ENTRY" ]; then
155
+ echo "No service entry detected; skipping service bundle"
156
+ echo "::set-output name=service_entry::"
157
+ exit 0
158
+ fi
159
+ echo "Detected service entry: $ENTRY"
160
+ echo "::set-output name=service_entry::$ENTRY"
161
+
162
+ - name: Bundle service if detected
163
+ run: |
164
+ set -euo pipefail
165
+ SERVICE_ENTRY="${{ steps.detect_service.outputs.service_entry }}"
166
+ if [ -z "$SERVICE_ENTRY" ]; then
167
+ echo "No service entry - skipping bundle"
168
+ exit 0
169
+ fi
170
+ echo "Bundling service from $SERVICE_ENTRY"
171
+ npx @vercel/ncc build "$SERVICE_ENTRY" -o dist_tmp
172
+ mv dist_tmp/index.js dist/service.js
173
+ rm -rf dist_tmp
174
+ echo "Built dist/service.js (size):"
175
+ ls -lh dist/service.js || true
176
+ head -n 8 dist/service.js || true
177
+
178
+ - name: Verify dist outputs
179
+ run: |
180
+ set -euo pipefail
181
+ if [ ! -f dist/userScript.js ]; then echo "dist/userScript.js missing" >&2; exit 1; fi
182
+ # service may be optional for some forks; only fail if service/package.json existed
183
+ if [ -f service/package.json ] && [ ! -f dist/service.js ]; then
184
+ echo "dist/service.js missing although service/package.json present" >&2
185
+ exit 1
186
+ fi
187
+ echo "✅ dist ready"
188
+
189
+ - name: Show dist contents
190
+ run: ls -la dist || true
28
191
 
29
192
  - name: Publish to npm
193
+ if: github.ref == 'refs/heads/main'
30
194
  run: npm publish --access public
31
195
  env:
32
196
  NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -0,0 +1,122 @@
1
+ /******/ /* webpack/runtime/compat */
2
+ /******/
3
+ /******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = new URL('.', import.meta.url).pathname.slice(import.meta.url.match(/^file:\/\/\/\w:/) ? 1 : 0, -1) + "/";
4
+ /******/
5
+ /************************************************************************/
6
+ var __webpack_exports__ = {};
7
+ const dial = require("@patrickkfkan/peer-dial");
8
+ const express = require('express');
9
+ const cors = require('cors');
10
+ const app = express();
11
+
12
+ const corsOptions = {
13
+ origin: '*',
14
+ methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
15
+ credentials: true,
16
+ optionsSuccessStatus: 204
17
+ };
18
+
19
+ app.use(cors(corsOptions));
20
+
21
+ const PORT = 8085;
22
+ const apps = {
23
+ "YouTube": {
24
+ name: "YouTube",
25
+ state: "stopped",
26
+ allowStop: true,
27
+ pid: null,
28
+ additionalData: {},
29
+ launch(launchData) {
30
+ const tbPackageId = tizen.application.getAppInfo().packageId;
31
+ tizen.application.launchAppControl(
32
+ new tizen.ApplicationControl(
33
+ "http://tizen.org/appcontrol/operation/view",
34
+ null,
35
+ null,
36
+ null,
37
+ [
38
+ new tizen.ApplicationControlData("module", [JSON.stringify(
39
+ {
40
+ moduleName: '@foxreis/tizentube',
41
+ moduleType: 'npm',
42
+ args: launchData
43
+ }
44
+ )])
45
+ ]
46
+ ), `${tbPackageId}.TizenBrewStandalone`);
47
+ }
48
+ }
49
+ };
50
+
51
+ const dialServer = new dial.Server({
52
+ expressApp: app,
53
+ port: PORT,
54
+ prefix: "/dial",
55
+ manufacturer: 'Reis Can',
56
+ modelName: 'TizenBrew',
57
+ friendlyName: 'TizenTube',
58
+ delegate: {
59
+ getApp(appName) {
60
+ return apps[appName];
61
+ },
62
+ launchApp(appName, launchData, callback) {
63
+ console.log(`Got request to launch ${appName} with launch data: ${launchData}`);
64
+ const app = apps[appName];
65
+ if (app) {
66
+ const parsedData = launchData.split('&').reduce((acc, cur) => {
67
+ const parts = cur.split('=');
68
+ const key = parts[0];
69
+ const value = parts[1];
70
+
71
+ if (typeof value !== 'undefined') {
72
+ acc[key] = value;
73
+ } else {
74
+ acc[key] = '';
75
+ }
76
+
77
+ return acc;
78
+ }, {});
79
+
80
+ if (parsedData.yumi) {
81
+ app.additionalData = parsedData;
82
+ app.state = "running"
83
+ callback("");
84
+ return;
85
+ }
86
+ app.pid = "run";
87
+ app.state = "starting";
88
+ app.launch(launchData);
89
+ app.state = "running";
90
+ }
91
+ callback(app.pid);
92
+ },
93
+ stopApp(appName, pid, callback) {
94
+ console.log(`Got request to stop ${appName} with pid: ${pid}`);
95
+ const app = apps[appName];
96
+ if (app && app.pid === pid) {
97
+ app.pid = null;
98
+ app.state = "stopped";
99
+ callback(true);
100
+ } else {
101
+ callback(false);
102
+ }
103
+ }
104
+ }
105
+ });
106
+
107
+
108
+ setInterval(() => {
109
+ tizen.application.getAppsContext((appsContext) => {
110
+ const tbPackageId = tizen.application.getAppInfo().packageId;
111
+ const app = appsContext.find(app => app.appId === `${tbPackageId}.TizenBrewStandalone`);
112
+ if (!app) {
113
+ apps["YouTube"].state = "stopped";
114
+ apps["YouTube"].pid = null;
115
+ apps["YouTube"].additionalData = {};
116
+ }
117
+ });
118
+ }, 5000);
119
+
120
+ app.listen(PORT, () => {
121
+ dialServer.start();
122
+ });