Title: feat: Node-style primordials for runtime builtins by edusperoni · Pull Request #1990 · NativeScript/android · GitHub
Open Graph Title: feat: Node-style primordials for runtime builtins by edusperoni · Pull Request #1990 · NativeScript/android
X Title: feat: Node-style primordials for runtime builtins by edusperoni · Pull Request #1990 · NativeScript/android
Description: Description Android mirror of NativeScript/ios#415. Stacked on #1989 (feat/js-builtins) — review only the last commit. The runtime's builtin JavaScript installs globals and leaves closures behind that run for the lifetime of the app: event dispatch, the URL/blob glue, console's stringify, the JS→org.json serializer. Until now those closures reached for intrinsics (Array.prototype.slice, JSON.stringify, Object.defineProperty, …) through the live globals, so app code replacing one could break runtime internals or observe them. internal/primordials.js captures exactly the intrinsics the other builtins need into a frozen, null-prototype namespace, Node-style — trimmed to what the Android builtins actually reach (not a mirror of Node's or iOS's list). The (binding, primordials) contract Builtins now compile with four fixed parameters: exports, module, binding, primordials. The snapshot is built lazily on the first RunBuiltin of an isolate — during runtime init, before any user code — and cached per isolate (mutex-guarded, released on isolate disposal; worker isolates snapshot their own realm's intrinsics automatically). Instance methods are uncurried exactly as Node does it (ArrayPrototypeSlice(list, 1), via Function.prototype.bind.bind(Function.prototype.call)); statics keep their path (JSONStringify). Plain constructor calls made once at init time stay direct — the rule targets closures that outlive init. Deliberately left live: Blob/File in blob-url.js (app-layer provided), global.__requireOverride in require-factory.js (app-layer hook), org.json.* in json-helper.js (metadata interceptor, not an intrinsic). Enforcement: ESLint no-restricted-properties for every captured static and no-restricted-globals for every captured constructor, each message naming the replacement; primordials.js itself is exempted. Both rule classes verified to fire. Tests: new tests/testPrimordials.js (8 specs) tampers with the intrinsics and checks the runtime keeps working — a guard spec proving the tampering is observable, global dispatchEvent/add/remove/once under broken Array.prototype.* + Function.prototype.call, reportError delivering a correct ErrorEvent, circular console.log staying non-fatal, plus Android-specific specs for the searchParams re-sync, the blob store under broken Map.prototype.*, and org.json serialization under broken Array/Object/Date intrinsics. Each spec keeps the tampered window synchronous and assertion-free, restoring originals in finally. Related Pull Requests NativeScript/ios#415 (iOS counterpart) #1989 (base) Does your pull request have unit tests? Yes — 8 new device specs. Full suite: 613 specs, 0 failures (605 baseline + 8), including worker suites, which exercise per-isolate snapshot creation and disposal on worker threads. Summary by CodeRabbit New Features Added protected runtime handling for built-in JavaScript functionality, improving reliability when application code modifies standard globals. Runtime components now share stable intrinsic references throughout an isolate’s lifetime. Bug Fixes Improved event handling, timers, URL and blob operations, JSON serialization, error reporting, and weak-reference behavior under altered built-ins. Added cleanup to prevent stale runtime state after an execution context is disposed. Documentation Documented the runtime’s protected built-in behavior and usage guidelines. Tests Added comprehensive coverage for intrinsic replacement, event dispatch, logging, URL operations, serialization, and related runtime behavior.
Open Graph Description: Description Android mirror of NativeScript/ios#415. Stacked on #1989 (feat/js-builtins) — review only the last commit. The runtime's builtin JavaScript installs globals and leaves closures behi...
X Description: Description Android mirror of NativeScript/ios#415. Stacked on #1989 (feat/js-builtins) — review only the last commit. The runtime's builtin JavaScript installs globals and leaves closures ...
Opengraph URL: https://github.com/NativeScript/android/pull/1990
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:6d4053ec-65aa-a3a4-b9ea-8f940bc4c104 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 99AE:34CAB:167E111:1CB7AF8:6B013C2F |
| html-safe-nonce | 204a0d69c1052969fc880130bcc5634717f4b2c22a32d62adaf983ed60e50fa9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OUFFOjM0Q0FCOjE2N0UxMTE6MUNCN0FGODo2QjAxM0MyRiIsInZpc2l0b3JfaWQiOiI1MzUyNTIxMzI5OTI3MDc2OTExIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 9f3e52c53e0aae6ac8cb23e9fcf8f3f31c2281bef31235deeda4c99e02994ee8 |
| hovercard-subject-tag | pull_request:4172520874 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/NativeScript/android/pull/1990/files |
| twitter:image | https://avatars.githubusercontent.com/u/4061767?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/4061767?s=400&v=4 |
| og:image:alt | Description Android mirror of NativeScript/ios#415. Stacked on #1989 (feat/js-builtins) — review only the last commit. The runtime's builtin JavaScript installs globals and leaves closures behi... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/NativeScript/android git https://github.com/NativeScript/android.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 29137950 |
| octolytics-dimension-repository_nwo | NativeScript/android |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 29137950 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/android |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width