code wiki / _hdl_build / nx_js_bundle_probe.nx
nx_js_bundle_probe.nx source
↩ module page · 52 lines · 3155 B
1// nx_js_bundle_probe.nx -- name the NEXT construct blocking real bundles (2026-07-27).
2// After the Unicode-identifier fix, netflix's bundle fails inside TypeScript's downlevel
3// async helper at `t.trys.push([0,4,,5])` -- an ARRAY LITERAL WITH AN ELISION (hole).
4// Controls first, so a FAIL row is a named gap and not a broken probe.
5import "nx_syscalls.nx"
6import "nx_js_eval.nx"
7
8func bp_p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
9func bp_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
10func bp_try(label: *u8, src: *u8) -> i64 {
11 let out: *i64 = sys_mmap(16) as *i64
12 let rc: i64 = js_run_source(src, bp_len(src), out)
13 bp_p(label)
14 if rc == 0 { bp_p(" OK\x0a\x00" as *u8); return 1 }
15 bp_p(" FAIL\x0a\x00" as *u8)
16 return 0
17}
18
19func main() -> i64 {
20 // --- controls: dense arrays and trailing commas MUST work.
21 let c1: i64 = bp_try("C1 dense array [0,4,5] \x00" as *u8, "var a=[0,4,5]; a[2];\x00" as *u8)
22 let c2: i64 = bp_try("C2 trailing comma [1,2,] \x00" as *u8, "var a=[1,2,]; a.length;\x00" as *u8)
23 // --- the suspects, exactly as they appear in downlevel-compiled TypeScript.
24 let s1: i64 = bp_try("S1 ELISION (hole) [0,4,,5] \x00" as *u8, "var a=[0,4,,5]; a.length;\x00" as *u8)
25 let s2: i64 = bp_try("S2 leading elision [,1] \x00" as *u8, "var a=[,1]; a.length;\x00" as *u8)
26 let s3: i64 = bp_try("S3 ts async helper trys.push() \x00" as *u8,
27 "var t={trys:[]}; t.trys.push([0,4,,5]); t.trys.length;\x00" as *u8)
28 // --- comma-operator return, same helper shape (return a,b)
29 let s4: i64 = bp_try("S4 comma operator return a,b \x00" as *u8,
30 "function f(){var e=1; return e=2,[4,e]} f()[1];\x00" as *u8)
31
32 // --- round 3 suspects: minified numeric/ternary forms from the netflix bundle
33 // `e.disabledStyleProp?.5:1` -- per spec `?.` followed by a DIGIT is NOT optional
34 // chaining; it is a ternary whose consequent is the leading-dot literal `.5`.
35 let c3: i64 = bp_try("C3 optional chain a?.b \x00" as *u8, "var a={b:1}; a?.b;\x00" as *u8)
36 let s5: i64 = bp_try("S5 leading-dot number .5 \x00" as *u8, "var x=.5; x;\x00" as *u8)
37 let s6: i64 = bp_try("S6 ternary then dot-num c?.5:1 \x00" as *u8, "var c=1; var y=c?.5:1; y;\x00" as *u8)
38 let s7: i64 = bp_try("S7 netflix exact shape \x00" as *u8,
39 "var e={disabledStyleProp:1}; var f=function(e){return e.disabledStyleProp?.5:1}; f(e);\x00" as *u8)
40
41 bp_p("\x0aREAD: C rows are controls (must be OK); S rows name the gap.\x0a\x00" as *u8)
42 if c1 == 1 { if c2 == 1 { if c3 == 1 {
43 if s5 == 1 { if s6 == 1 { if s7 == 1 {
44 if s1 == 1 { if s2 == 1 { if s3 == 1 { if s4 == 1 {
45 bp_p("verdict=NO-GAP\x0a\x00" as *u8); return 0
46 } } } } } } }
47 bp_p("verdict=GAP-CONFIRMED (see FAIL rows above)\x0a\x00" as *u8)
48 return 0
49 } } }
50 bp_p("verdict=PROBE-BROKEN (a control failed)\x0a\x00" as *u8)
51 return 1
52}