nx_js_urlfold.nx
buildroot/runtime/nx_js_urlfold.nx
about
nx_js_urlfold.nx -- SOVEREIGN JS constant/template URL folder (operator 2026-07-08: "get to state of the art
that we can see and harvest the media as part of the browser capabilities" -- no manual network capture). The
hard class of page (Unity/heavy-JS ad loaders) never emits <img>/<script src> in the HTML; it CONSTRUCTS asset
URLs at runtime from string constants: const FALLBACK_HOST='client.x.com'; const BUILD_PATH='release_builds/..';
let host=FALLBACK_HOST; const baseUrl=`https://${host}/${BUILD_PATH}`; ... `${baseUrl}/rc/style.css`.
This reconstructs those URLs by READING (not executing) the JS: it collects `const|let|var NAME = <strexpr>`
assignments, resolves them to literals by iterated substitution (so baseUrl folds through host+BUILD_PATH),
then folds EVERY backtick template + the resolved consts to concrete strings and emits the URL-ish ones. No JS
engine, no segfault. Supported value forms: 'lit' / "lit" / `tmpl${IDENT}` / IDENT / A + 'x' + B (concat).
nx_js_fold_urls(js,len, obuf,ooff[],olen[], maxn) -> count (urls written into obuf, spans in ooff/olen)
NOTE: the resolved const table is a STRUCT (JTab*) so juf_fold/juf_lookup stay <=6 args -- an 11-arg juf_fold
returned a clobbered value on the x86 lane (measured 2026-07-08: literal fold returned 4230893 not 23).
license_tier: ORIGINAL
dependencies 1 imports · 2 importers
imports: nx_syscalls.nx
imported by: nx_js_urlfold_gate.nxnx_media_deepcrawl.nx
structs
| 22 | struct JTab { vbuf: *u8, noff: *i64, nlen: *i64, voff: *i64, vlen: *i64, js: *u8, cnt: i64, used: i64 } |
consts
| 15 | const JUF_MAGIC_8192: i64 = 8192 |
| 17 | const JUF_MAXT: i64 = 512 // max consts / assignments |
| 18 | const JUF_TBUF: i64 = 131072 // resolved-value byte pool |
| 19 | const JUF_PASSES: i64 = 10 // fixpoint iterations |
| 23 | const JTAB_BYTES: i64 = 64 |
functions
| 26 | func juf_isident(c: i64) -> i64 { if c>=48 { if c<=57 {return 1} } if c>=65 { if c<=90 {return 1} } if c>=97 { if c<=122 {return 1} } if c==95 {return 1} if c==36 {return 1} return 0 } |
| 28 | func juf_span_eq(a: *u8, aoff: i64, alen: i64, b: *u8, boff: i64, blen: i64) -> i64 { if alen != blen { return 0 } var i: i64=0; while i<alen { if a[aoff+i]!=b[boff+i] { return 0 } i=i+1 } return 1 } called by 1: juf_lookup |
| 30 | func juf_lookup(qoff: i64, qlen: i64, T: *JTab) -> i64 { let js: *u8 = T.js; var i: i64=0; while i<T.cnt { if juf_span_eq(js, qoff, qlen, js, T.noff[i], T.nlen[i])==1 { return i } i=i+1 } return 0 - 1 } |
| 32 | func juf_urlish(s: *u8, off: i64, len: i64) -> i64 called by 1: nx_js_fold_urls |
| 40 | func juf_put(T: *JTab, idx: i64, out: *u8, o: i64, ocap: i64) -> i64 { var w: i64=o; var m: i64=0; let vb: *u8=T.vbuf; while m < T.vlen[idx] { if w<ocap-1 { out[w]=vb[T.voff[idx]+m]; w=w+1 } m=m+1 } return w } called by 1: juf_piece |
| 43 | func juf_wr(out: *u8, opos: *i64, ocap: i64, ch: u8) -> i64 { if opos[0] < ocap-1 { out[opos[0]]=ch; opos[0]=opos[0]+1 } return 0 } called by 1: juf_piece |
| 48 | func juf_piece(js: *u8, i0: i64, end: i64, T: *JTab, out: *u8, opos: *i64, ocap: i64) -> i64 |
| 94 | func juf_fold(js: *u8, soff: i64, slen: i64, T: *JTab, out: *u8, ocap: i64) -> i64 |
| 113 | func juf_kw_at(js: *u8, i: i64, len: i64, kw: *u8, klen: i64) -> i64 |
| 124 | func juf_emit(obuf: *u8, ooff: *i64, olen: *i64, count: i64, maxn: i64, opos: *i64, src: *u8, soff: i64, slen: i64) -> i64 called by 1: nx_js_fold_urls |
| 144 | func nx_js_fold_urls(js: *u8, len: i64, obuf: *u8, ooff: *i64, olen: *i64, maxn: i64) -> i64 |