@krx3d/tizentube2 1.30.720 → 1.30.740

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.
@@ -119,6 +119,8 @@ on:
119
119
  paths-ignore:
120
120
  - 'dist/**'
121
121
  - 'package.json'
122
+ # Read by the Gitea mirror, ignored by GitHub Actions entirely.
123
+ - '.gitea/**'
122
124
  push:
123
125
  branches:
124
126
  - main
@@ -130,6 +132,11 @@ on:
130
132
  - 'LICENSE'
131
133
  - 'AGENTS.md'
132
134
  - 'README.md'
135
+ # The mirror's own workflow lives here. GitHub never runs it, and it is
136
+ # not in the published package, so a change to it must not publish a new
137
+ # version — which is exactly what it did once: #827 touched nothing but
138
+ # .gitea/workflows/sync-from-github.yml and bumped 1.30.710 to 1.30.720.
139
+ - '.gitea/**'
133
140
  - 'package.json'
134
141
  - 'tizen.log'
135
142
  - 'dist/**'
@@ -222,56 +229,56 @@ jobs:
222
229
  patch = 0;
223
230
  }
224
231
 
225
- // npm refuses forever to reuse a version number that was once
226
- // published and later unpublished. The cleanup step in this same
227
- // workflow unpublishes old releases, so 780 of the 857 numbers this
228
- // package has ever used are permanently burned. Whenever
229
- // package.json drops back into that range - a revert, a bad merge,
230
- // an upstream sync - every run then fails with
231
- // E400 Cannot publish over previously published version "x.y.z"
232
- // and, because the bump is committed and pushed BEFORE publishing,
233
- // main is left pinned on the burned number so every later run fails
234
- // the same way. That is exactly what happened twice at 1.16.10.
235
- //
236
- // The registry time map lists every version ever used, live or not,
237
- // so skipping past them makes the bump self-correcting.
238
- //
239
- // Wrapped in an async IIFE on purpose: this script is fed to `node -`
240
- // on stdin, and a top-level await next to the require() above makes
241
- // Node fail the whole script with ERR_AMBIGUOUS_MODULE_SYNTAX.
242
- (async () => {
243
- let used = null;
244
- try {
245
- const res = await fetch('https://registry.npmjs.org/' + pkg.name);
246
- if (res.ok) {
247
- const meta = await res.json();
248
- const isSemver = (k) => /^[0-9]+[.][0-9]+[.][0-9]+$/.test(k);
249
- used = new Set(Object.keys(meta.time || {}).filter(isSemver));
250
- }
251
- } catch (e) {
252
- // Registry unreachable: fall through to the plain bump rather
253
- // than blocking a release. A real collision still fails loudly
254
- // at publish.
255
- used = null;
256
- }
257
-
258
- let newVer = `${major}.${minor}.${patch}`;
259
- if (used) {
260
- const firstChoice = newVer;
261
- let guard = 0;
262
- while (used.has(newVer) && guard++ < 500) {
263
- patch += 10;
264
- if (patch >= 1000) { minor += 1; patch = 0; }
265
- newVer = `${major}.${minor}.${patch}`;
266
- }
267
- if (used.has(newVer)) throw new Error('No unused version found near ' + ver);
268
- if (newVer !== firstChoice) console.log('Skipped burned version numbers: ' + firstChoice + ' -> ' + newVer);
269
- }
270
-
271
- pkg.version = newVer;
272
- fs.writeFileSync(path, JSON.stringify(pkg, null, 2) + String.fromCharCode(10), 'utf8');
273
- console.log('Bumped version: ' + ver + ' -> ' + newVer);
274
- })();
232
+ // npm refuses forever to reuse a version number that was once
233
+ // published and later unpublished. The cleanup step in this same
234
+ // workflow unpublishes old releases, so 780 of the 857 numbers this
235
+ // package has ever used are permanently burned. Whenever
236
+ // package.json drops back into that range - a revert, a bad merge,
237
+ // an upstream sync - every run then fails with
238
+ // E400 Cannot publish over previously published version "x.y.z"
239
+ // and, because the bump is committed and pushed BEFORE publishing,
240
+ // main is left pinned on the burned number so every later run fails
241
+ // the same way. That is exactly what happened twice at 1.16.10.
242
+ //
243
+ // The registry time map lists every version ever used, live or not,
244
+ // so skipping past them makes the bump self-correcting.
245
+ //
246
+ // Wrapped in an async IIFE on purpose: this script is fed to `node -`
247
+ // on stdin, and a top-level await next to the require() above makes
248
+ // Node fail the whole script with ERR_AMBIGUOUS_MODULE_SYNTAX.
249
+ (async () => {
250
+ let used = null;
251
+ try {
252
+ const res = await fetch('https://registry.npmjs.org/' + pkg.name);
253
+ if (res.ok) {
254
+ const meta = await res.json();
255
+ const isSemver = (k) => /^[0-9]+[.][0-9]+[.][0-9]+$/.test(k);
256
+ used = new Set(Object.keys(meta.time || {}).filter(isSemver));
257
+ }
258
+ } catch (e) {
259
+ // Registry unreachable: fall through to the plain bump rather
260
+ // than blocking a release. A real collision still fails loudly
261
+ // at publish.
262
+ used = null;
263
+ }
264
+
265
+ let newVer = `${major}.${minor}.${patch}`;
266
+ if (used) {
267
+ const firstChoice = newVer;
268
+ let guard = 0;
269
+ while (used.has(newVer) && guard++ < 500) {
270
+ patch += 10;
271
+ if (patch >= 1000) { minor += 1; patch = 0; }
272
+ newVer = `${major}.${minor}.${patch}`;
273
+ }
274
+ if (used.has(newVer)) throw new Error('No unused version found near ' + ver);
275
+ if (newVer !== firstChoice) console.log('Skipped burned version numbers: ' + firstChoice + ' -> ' + newVer);
276
+ }
277
+
278
+ pkg.version = newVer;
279
+ fs.writeFileSync(path, JSON.stringify(pkg, null, 2) + String.fromCharCode(10), 'utf8');
280
+ console.log('Bumped version: ' + ver + ' -> ' + newVer);
281
+ })();
275
282
  NODE
276
283
 
277
284
  - name: Show current version (old -> new)
@@ -413,35 +420,35 @@ jobs:
413
420
  # --------------------
414
421
  # PUBLISH
415
422
  # --------------------
416
- # --------------------
417
- # Guard: never publish a tarball whose dist does not match its version
418
- # --------------------
419
- # Confirmed on 1.30.0: the tarball carried package.json 1.30.0 alongside a
420
- # dist/userScript.js stamped 1.16.10, so every TV pulling the CDN got a
421
- # build five releases old while the settings menu reported the new number.
422
- #
423
- # It came from re-running a failed run. A re-run replays the ORIGINAL
424
- # commit, so it bumped and built at the old version, and then the
425
- # `git rebase origin/main` below took main's newer package.json while
426
- # keeping the dist it had already built. package.json and dist are only
427
- # guaranteed to agree when a run builds them together, and nothing checked
428
- # that they still did by the time publish happened.
429
- - name: Verify dist matches package.json version
430
- if: success()
431
- run: |
432
- set -euo pipefail
433
- VER="$(node -p "require('./package.json').version")"
434
- echo "package.json version: ${VER}"
435
- for f in dist/userScript.js dist/service.js; do
436
- test -f "$f" || { echo "::error::${f} is missing"; exit 1; }
437
- done
438
- if ! grep -qF "\"${VER}\"" dist/userScript.js; then
439
- FOUND="$(grep -aoE '\"[0-9]+\.[0-9]+\.[0-9]+\"' dist/userScript.js | sort -u | head -3 | xargs echo)"
440
- echo "::error::dist/userScript.js was not built from this version. package.json says ${VER}; the bundle contains ${FOUND:-no version string}. Re-run the workflow from a fresh push rather than re-running an old run, so the bump and the build happen together."
441
- exit 1
442
- fi
443
- echo "dist/userScript.js carries ${VER}"
444
-
423
+ # --------------------
424
+ # Guard: never publish a tarball whose dist does not match its version
425
+ # --------------------
426
+ # Confirmed on 1.30.0: the tarball carried package.json 1.30.0 alongside a
427
+ # dist/userScript.js stamped 1.16.10, so every TV pulling the CDN got a
428
+ # build five releases old while the settings menu reported the new number.
429
+ #
430
+ # It came from re-running a failed run. A re-run replays the ORIGINAL
431
+ # commit, so it bumped and built at the old version, and then the
432
+ # `git rebase origin/main` below took main's newer package.json while
433
+ # keeping the dist it had already built. package.json and dist are only
434
+ # guaranteed to agree when a run builds them together, and nothing checked
435
+ # that they still did by the time publish happened.
436
+ - name: Verify dist matches package.json version
437
+ if: success()
438
+ run: |
439
+ set -euo pipefail
440
+ VER="$(node -p "require('./package.json').version")"
441
+ echo "package.json version: ${VER}"
442
+ for f in dist/userScript.js dist/service.js; do
443
+ test -f "$f" || { echo "::error::${f} is missing"; exit 1; }
444
+ done
445
+ if ! grep -qF "\"${VER}\"" dist/userScript.js; then
446
+ FOUND="$(grep -aoE '\"[0-9]+\.[0-9]+\.[0-9]+\"' dist/userScript.js | sort -u | head -3 | xargs echo)"
447
+ echo "::error::dist/userScript.js was not built from this version. package.json says ${VER}; the bundle contains ${FOUND:-no version string}. Re-run the workflow from a fresh push rather than re-running an old run, so the bump and the build happen together."
448
+ exit 1
449
+ fi
450
+ echo "dist/userScript.js carries ${VER}"
451
+
445
452
  - name: Publish package to npm
446
453
  if: success()
447
454
  id: publish_npm
@@ -921,21 +928,32 @@ jobs:
921
928
 
922
929
  # The purge above is fire-and-forget: jsDelivr answers "pending" and that
923
930
  # is the end of it. Nothing checked the result, and a capture showed what
924
- # that costs — the unversioned URL, which is the one the TV actually
925
- # fetches, kept serving the previous release for hours after a publish
926
- # (x-cache HIT, age 15039, the bundle inside it a version behind). Every
927
- # TV was loading that, so a diagnostic merged that afternoon was simply
928
- # not running, and its absence read as the feature being broken.
931
+ # that costs — a publish whose bundle did not reach the TVs for hours,
932
+ # which read as the new feature being broken rather than as never having
933
+ # arrived.
929
934
  #
930
- # So the last word belongs to the URL the TV uses, read the way the TV
931
- # reads it. The version string has to be inside the bundle itself: a
932
- # 200 proves nothing when the stale object is also a 200.
935
+ # What is worth checking changed when injector.js started pinning. This
936
+ # step used to read the unversioned path and fail the build over it,
937
+ # because that was the URL the TV fetched. The injector now asks the npm
938
+ # registry for the version and fetches an immutable @version path, and
939
+ # falls back to the unversioned URL only if the registry cannot be
940
+ # reached. So the two are no longer equally serious:
933
941
  #
934
- # One caveat worth stating: jsDelivr serves from many points of presence
935
- # and this checks the one that answers here. It cannot prove every edge
936
- # is current. What it does prove is that the origin resolves this
937
- # package's unversioned path to the version just published — which is the
938
- # failure that was actually seen, and the one that affects every edge.
942
+ # @version path what every TV actually loads. Immutable, so if it
943
+ # does not carry this version then the publish itself
944
+ # is broken, not a cache. Hard failure.
945
+ #
946
+ # unversioned the fallback, and jsDelivr caches its resolution of
947
+ # alias "latest" for twelve hours (s-maxage=43200). It lags a
948
+ # publish by design, and a purge issued before npm's
949
+ # latest has propagated makes it worse by re-caching
950
+ # the old answer. A warning: failing here blocks the
951
+ # .wgt release over something that reaches no TV.
952
+ #
953
+ # Either way the version string has to be inside the bundle itself — a
954
+ # 200 proves nothing when the stale object is also a 200. jsDelivr serves
955
+ # from many points of presence and this reads whichever answers here, so
956
+ # it cannot prove every edge is current.
939
957
  - name: Verify the CDN serves this version
940
958
  if: steps.confirm_publish.outputs.confirmed == 'true'
941
959
  env:
@@ -943,32 +961,72 @@ jobs:
943
961
  run: |
944
962
  set -euo pipefail
945
963
  VER=$(cat /tmp/current_version.txt)
946
- URL="https://cdn.jsdelivr.net/npm/${PKG}/dist/userScript.js"
947
- echo "Checking ${URL} for ${VER} ..."
964
+ PINNED="https://cdn.jsdelivr.net/npm/${PKG}@${VER}/dist/userScript.js"
965
+ ALIAS="https://cdn.jsdelivr.net/npm/${PKG}/dist/userScript.js"
966
+
967
+ # Two things this got wrong before, both of which turned a correct
968
+ # verdict into an unreadable one.
969
+ #
970
+ # -a, because the bundle is minified and counts as binary: without it
971
+ # grep writes "binary file matches" to stderr and no match to stdout,
972
+ # which is why a run that had correctly found the alias stale could
973
+ # only report "an unknown version".
974
+ #
975
+ # And the major from this version rather than any three numbers. A
976
+ # bundle carries its dependencies' versions too, so the generic
977
+ # pattern plus "sort | tail -1" reported the highest-sorting of those
978
+ # — measured: 8.8.278 for a bundle whose own version was 1.30.710.
979
+ # Anchored to the major there is exactly one match, which is the
980
+ # package's own. All of them are printed rather than the last, so a
981
+ # bundle that somehow carried two cannot be described as having one.
982
+ MAJOR="${VER%%.*}"
983
+ served_version() {
984
+ grep -aoE "${MAJOR}\.[0-9]+\.[0-9]+" "$1" | sort -u | tr '\n' ' ' || true
985
+ }
948
986
 
949
- for i in $(seq 1 10); do
950
- if curl -fsSL -H 'Cache-Control: no-cache' "$URL" -o /tmp/cdn_bundle.js; then
951
- if grep -q "$VER" /tmp/cdn_bundle.js; then
952
- echo "attempt ${i}: the CDN serves ${VER}."
987
+ echo "== the path every TV loads: ${PINNED}"
988
+ if ! curl -fsSL -H 'Cache-Control: no-cache' "$PINNED" -o /tmp/cdn_pinned.js; then
989
+ echo "::error::The CDN will not serve ${PINNED} at all, so the publish did not land."
990
+ exit 1
991
+ fi
992
+ if ! grep -aq "$VER" /tmp/cdn_pinned.js; then
993
+ echo "::error::${PINNED} exists but the bundle in it says $(served_version /tmp/cdn_pinned.js), not ${VER}. An immutable path cannot go stale, so this is a broken publish rather than a cache."
994
+ exit 1
995
+ fi
996
+ echo "the pinned path serves ${VER} — which is what injector.js injects."
997
+
998
+ # Then the alias, which is allowed to lag.
999
+ echo "== the fallback alias: ${ALIAS}"
1000
+ for i in $(seq 1 6); do
1001
+ if curl -fsSL -H 'Cache-Control: no-cache' "$ALIAS" -o /tmp/cdn_alias.js; then
1002
+ if grep -aq "$VER" /tmp/cdn_alias.js; then
1003
+ echo "attempt ${i}: the alias serves ${VER} too, so there is nothing left to wait for."
953
1004
  exit 0
954
1005
  fi
955
- FOUND=$(grep -oE '[0-9]+\.[0-9]+\.[0-9]+' /tmp/cdn_bundle.js | sort -u | tail -1 || true)
956
- echo "attempt ${i}: still serving ${FOUND:-an unknown version}"
1006
+ echo "attempt ${i}: the alias still serves $(served_version /tmp/cdn_alias.js)"
957
1007
  else
958
- echo "attempt ${i}: the CDN could not be read"
1008
+ echo "attempt ${i}: the alias could not be read"
959
1009
  fi
960
1010
 
961
- # Ask again rather than only waiting: the first purge can land
962
- # before npm's latest has propagated, in which case jsDelivr
963
- # re-resolves the old version and caches that instead.
964
- curl -s -X POST -H 'Content-Type: application/json' \
1011
+ # Ask again rather than only waiting, and this time watch the
1012
+ # request: the purge API is asynchronous and answers "pending", so
1013
+ # the previous blind sleep could not tell a finished purge from a
1014
+ # queued one.
1015
+ PURGE=$(curl -s -X POST -H 'Content-Type: application/json' \
965
1016
  --data "{\"path\":[\"/npm/${PKG}/dist/userScript.js\",\"/npm/${PKG}/dist/service.js\",\"/npm/${PKG}@latest/dist/userScript.js\",\"/npm/${PKG}@latest/dist/service.js\"]}" \
966
- https://purge.jsdelivr.net/ > /dev/null || true
967
- sleep 20
1017
+ https://purge.jsdelivr.net/ || true)
1018
+ PURGE_ID=$(printf '%s' "$PURGE" | sed -n 's/.*"id"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p')
1019
+ echo " purge requested: ${PURGE_ID:-no id returned}"
1020
+ for _ in $(seq 1 5); do
1021
+ sleep 6
1022
+ [ -n "$PURGE_ID" ] || break
1023
+ STATUS=$(curl -s "https://purge.jsdelivr.net/status/${PURGE_ID}" | sed -n 's/.*"status"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p')
1024
+ echo " purge ${PURGE_ID}: ${STATUS:-unknown}"
1025
+ [ "$STATUS" = "pending" ] || break
1026
+ done
968
1027
  done
969
1028
 
970
- echo "::error::The CDN is still not serving ${VER} at ${URL} after ten attempts. Every TV will keep loading the previous bundle until this clears, which looks exactly like the new build not working. Purge it by hand (https://www.jsdelivr.com/tools/purge) or re-run this workflow."
971
- exit 1
1029
+ echo "::warning::${ALIAS} is still serving $(served_version /tmp/cdn_alias.js) rather than ${VER}. That is the fallback path only: injector.js pins to ${PINNED}, verified above, and uses the alias just when the npm registry is unreachable. jsDelivr caches its idea of \"latest\" for up to twelve hours and this clears on its own; purge by hand at https://www.jsdelivr.com/tools/purge to hurry it."
972
1030
 
973
1031
  - name: Cache purge complete
974
1032
  if: steps.confirm_publish.outputs.confirmed == 'true'