All Projects → shendepu → nashorn-polyfill

shendepu / nashorn-polyfill

Licence: MIT License
Polyfill to Nashorn engine with web api

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to nashorn-polyfill

ssr-starter-pack
Moved to https://github.com/Brigad/ssr-starter-pack
Stars: ✭ 12 (-78.57%)
Mutual labels:  ssr
reph
Phoenix/React application starter kit
Stars: ✭ 15 (-73.21%)
Mutual labels:  ssr
react-hydration-on-demand
Hydrate your React components only when you need to
Stars: ✭ 94 (+67.86%)
Mutual labels:  ssr
teanjs
🔥 TypeORM - Express - Angular 8 - NestJS Server Side Rendering (SSR) 😺
Stars: ✭ 62 (+10.71%)
Mutual labels:  ssr
nuxt-plesk-example
No description or website provided.
Stars: ✭ 27 (-51.79%)
Mutual labels:  ssr
greenwood
Greenwood is your workbench for the web, focused on supporting modern web standards and development to help you create your next project.
Stars: ✭ 48 (-14.29%)
Mutual labels:  ssr
perf
PERF is an Exhaustive Repeat Finder
Stars: ✭ 26 (-53.57%)
Mutual labels:  ssr
javascript-fun
source code generator for www.javascript.fun
Stars: ✭ 32 (-42.86%)
Mutual labels:  ssr
onurl
URL Shortener created w/ Next.js, TypeScript, Mongoose
Stars: ✭ 48 (-14.29%)
Mutual labels:  ssr
angular-pwa
Angular 13 Example Progressive Web App (PWA)
Stars: ✭ 45 (-19.64%)
Mutual labels:  ssr
picidaejs
🐦Picidae is a document generator which has gentle experience.
Stars: ✭ 24 (-57.14%)
Mutual labels:  ssr
eventrix
Open-source, Predictable, Scaling JavaScript library for state managing and centralizing application global state. State manage system for react apps.
Stars: ✭ 35 (-37.5%)
Mutual labels:  ssr
serverless-react-server-side-render
A Demo of Serverless Framework with React Server Side Render
Stars: ✭ 20 (-64.29%)
Mutual labels:  ssr
TB
🖖 A simple & cool blog platform, based on GitHub API, designed for Geeks
Stars: ✭ 24 (-57.14%)
Mutual labels:  ssr
react-kits
⚔️ Opinionated Fullstack React toolkits featuring project generation, dev server, build production bundle, and common dev-tools. This is simple DIY create-react-app.
Stars: ✭ 13 (-76.79%)
Mutual labels:  ssr
react-easy-ssr
🔥 React Starter Project with Webpack 5, Babel 7, TypeScript, Redux-saga, Styled-components, React-jss, Split code, Server Side Rendering.
Stars: ✭ 31 (-44.64%)
Mutual labels:  ssr
preact-polka-ssr
Preact SSR using Polka
Stars: ✭ 27 (-51.79%)
Mutual labels:  ssr
node.umelabs.dev
每天24:00点前更新免费SS/SSR节点
Stars: ✭ 1,135 (+1926.79%)
Mutual labels:  ssr
iosvpn.github.io
iPhone和iOS 翻墙梯子VPN推荐,2022中国苹果手机iPhone翻墙软件和科学上网避坑指南,稳定梯子推荐。
Stars: ✭ 72 (+28.57%)
Mutual labels:  ssr
v2ray
每日分享免费节点、免费机场、ssr节点、v2ray节点、v2ray订阅、clash节点、clash订阅、shadowrocket订阅、Quantumult X订阅、Clash .NET订阅、小火箭节点、小猫咪节点、免费翻墙、免费科学上网、免费梯子、免费trojan节点、蓝灯、谷歌商店、翻墙梯子、安卓VPN、iphone翻墙节点、iphone vpn、一键翻墙浏览器、节点分享、免费SSR、蓝灯、谷歌商店、V2ary免费节点、代理、proxy代理科学上网、TG代理、电报代理、Telegram代理、ip加速、翻墙软件、socks5、破解VPN、机场推荐、节点订阅、破解VPN
Stars: ✭ 525 (+837.5%)
Mutual labels:  ssr

Nashorn Polyfill

This is the polyfill for Nashorn:

Missing polyfill:

  • FormData

Variable injected in ScriptContext

Required

__NASHORN_POLYFILL_TIMER__

instance of ScheduledExecutorService.

Sample:

static ScheduledExecutorService globalScheduledThreadPool = Executors.newScheduledThreadPool(20);

// Injection of __NASHORN_POLYFILL_TIMER__ in ScriptContext
sc.setAttribute("__NASHORN_POLYFILL_TIMER__", globalScheduledThreadPool, ScriptContext.ENGINE_SCOPE);

Optional

__HTTP_SERVLET_REQUEST__

The HttpServletRequest instance. If this variable injected, XmlHttpRequest polyfill will copy Cookie and Authorization headers of HttpServletRequest, so that AJAX call from Javascript application will act like user session fired from browser.

If more headers want to be copied, it is easy to customize it in xml-http-request-polyfill line 92.

Required Java Jars:

gradle

compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.2'
compile group: 'org.apache.httpcomponents', name: 'httpasyncclient', version: '4.1.2'
compile group: 'org.apache.commons', name: 'commons-pool2', version: '2.4.2'

Important Notes

In https://github.com/morungos/java-xmlhttprequest, it uses Timer to run setTimeout and setInterval task, but they are run in a separate thread of the Timer creates that is different with the main JavaScript thread.

This implementation uses ScheduledExecutorService instead of Timer so the threads for task scheduling can be reused instead of each JavasScript thread create a Timer thread when using Timer.

And most important thing is this adds global.nashornEventLoop and scheduled tasks only add function callback object in eventLoop (ArrayQueue), and it is main JavaScript thread to run these function callback by calling global.nashornEventLoop.process(); at the end of JavaScript Application. It is just like browser or NodeJS that event loop is called when the main stack is cleared.

When runs on server with Promise, remember to call nashornEventLoop.process() when waiting for Promise by Thread.sleep(), and call nashornEventLoop.reset() if server thread (e.g. Servlet thread) decides to be timeout so that eventLoop will be clean for next request.

Link

Product Demo: This is demo of a product with react, react-router, apollo (GraphQL client)

Moqui React SSR Demo:

This demo shows how react app is rendered on server side. The code playing with Nashorn Script Engine sits in Moqui React SSR which is easy to extract to be used in any Java application.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].