fix(client-state): let global_value and global_set run in call_script code
Since #7870, code sent with rx.call_script runs through runScript, which can only see the exports of state.js. ClientStateVar.global_value and global_set compile to getClientState(...) / setClientState(...). state.js imports those two functions but doesn't export them, so both accessors throw ReferenceError in call_script code. The same goes for push() of a Var that reads another client state var, e.g. a.push(rx.cond(b.global_value == x, ..., ...)). Until now the only way around it was writing refs["__client_state"] by hand.
state.jsnow exportsgetClientStateandsetClientState, so both accessors work in script code.push(Var)still writes throughrefs["__client_state"], but builds the call as a typedFunctionStringVarcall, which keeps the imports of the Var it is given (formatting it with!sdropped them). A page that compiles the push into a trigger now importsgetClientStateitself, instead of relying on another component in the same module to import it.- Docs: replaced "
rx.call_scriptis the one place these do not work" with an example.
Tests: a vitest test checks what script code can see, two Playwright tests cover call_script with global_set/global_value and a push reading another var, and a unit test pins the generated push code and its imports. Without the export, the Playwright tests fail with ReferenceError: setClientState is not defined; without the change to push, the unit test finds no imports on the generated function.