All Projects → polygonplanet → WSHModule

polygonplanet / WSHModule

Licence: other
WSHModule is a JavaScript virtual machine built in WSH/JScript.

Programming Languages

javascript
184084 projects - #8 most used programming language
pascal
1382 projects
PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to WSHModule

jsxt
The collection of Javascript / JScript / VBScript extensions, tools and more
Stars: ✭ 23 (-17.86%)
Mutual labels:  jscript, wsh
convert
The smallest & fastest library for really easy, totally type-safe unit conversions in TypeScript & JavaScript.
Stars: ✭ 47 (+67.86%)
Mutual labels:  commonjs, umd
TiCaching
Commonjs module for caching data in Apps made with Titanium Mobile
Stars: ✭ 22 (-21.43%)
Mutual labels:  commonjs
timezz
With this plugin, you can easily make a stopwatch or timer on your site. Just init, style and enjoy.
Stars: ✭ 35 (+25%)
Mutual labels:  commonjs
titaniumifier
Get a Titanium™ SDK CommonJS module out of a Node package!
Stars: ✭ 95 (+239.29%)
Mutual labels:  commonjs
crazycat
使用Canvas制作的围住神经猫,算法基于广度优先搜索实现。
Stars: ✭ 18 (-35.71%)
Mutual labels:  umd
Exploits
A personal collection of Windows CVE I have turned in to exploit source, as well as a collection of payloads I've written to be used in conjunction with these exploits.
Stars: ✭ 75 (+167.86%)
Mutual labels:  jscript
Pax
The fastest JavaScript bundler in the galaxy.
Stars: ✭ 2,626 (+9278.57%)
Mutual labels:  commonjs
SimpleWebAuthn
WebAuthn, Simplified. A collection of TypeScript-first libraries for simpler WebAuthn integration. Supports modern browsers and Node.
Stars: ✭ 206 (+635.71%)
Mutual labels:  umd
nanobundle
Yet another build tool for libraries, powered by esbuild
Stars: ✭ 45 (+60.71%)
Mutual labels:  commonjs
array-sort-by
Powerful mechanism to sort arrays or array of objects by one or more properties. You can also specify a custom comparer function.
Stars: ✭ 37 (+32.14%)
Mutual labels:  commonjs
babel-plugin-transform-amd-to-commonjs
✨ Babel plugin that transforms AMD to CommonJS
Stars: ✭ 44 (+57.14%)
Mutual labels:  commonjs
yantra
JavaScript Engine for .NET Standard
Stars: ✭ 32 (+14.29%)
Mutual labels:  commonjs
DotNetJS
Consume C# in JavaScript with comfort: single-file UMD library, auto-generated 2-way bindings and type definitions
Stars: ✭ 551 (+1867.86%)
Mutual labels:  umd
npm-es-modules
Breakdown of 7 different ways to use ES modules with npm today.
Stars: ✭ 67 (+139.29%)
Mutual labels:  commonjs
Webpack
A bundler for javascript and friends. Packs many modules into a few bundled assets. Code Splitting allows for loading parts of the application on demand. Through "loaders", modules can be CommonJs, AMD, ES6 modules, CSS, Images, JSON, Coffeescript, LESS, ... and your custom stuff.
Stars: ✭ 60,034 (+214307.14%)
Mutual labels:  commonjs
react-use-comlink
Three ways to use Comlink web workers through React Hooks (and in a typesafe manner).
Stars: ✭ 39 (+39.29%)
Mutual labels:  umd
qw-sdk-demo
将 react 业务组件打包成 umd
Stars: ✭ 15 (-46.43%)
Mutual labels:  umd
Wedge
可配置的小说下载及电子书生成工具
Stars: ✭ 62 (+121.43%)
Mutual labels:  umd
mpx-es-check
Checks the version of ES in JavaScript files with simple shell commands
Stars: ✭ 15 (-46.43%)
Mutual labels:  commonjs

WSHModule

WSHModule is a JavaScript virtual machine built in WSH/JScript.

It is a subset of the JavaScript interpreter that supports to compatible with the ECMAScript 5 standard in WSH/JScript. WSHModule's script run at module scope (CommonJS/UMD) that means it can use require, exports and module objects. WSHModule can assist to upgrade JScript in Windows Script Host as much as possible to approach the ECMA-262 standard.

Possibly, better to use Node.js it would be quickly. However, JScript has been bundled with Windows. Improves a local environment when run a batch script with extension "js" by the passage to WSHModule.

Compatibility

  • Windows (32bit/64bit)

WSHModule will work with WSH version 5.6 or later.

Currently, WSHModule does not use file type association and Windows environment (eg., PATH).

Features

WSHModule supports the following features:

  • Supports ECMAScript5 standard syntax.
  • Supports CommonJS Universal Module Definition (UMD).
  • Working with UTF-8 encoding.
  • Supports standard DOM functions: alert/confirm/prompt, setTimeout/clearTimeout and setInterval/clearInterval.
  • Supports a console window.
  • Fixed JScript bug: try-finally statements, String.prototype.substr, Array.indexOf and Array.prototype.splice functions to standard ECMA-262.

Quickstart usage

Runs script with WSHModule:

WSHModule.exe "C:/path/to/myscript.js"

or

Execute (drag-drop) C:/path/to/myscript.js to WSHModule.exe

Simple way:

  1. Create a shortcut of WSHModule.exe to desktop.
  2. Execute script by drag-drop to shortcut.

Tests

Runs test script:

  1. cd WSHModule
  2. "bin/WSHModule.exe" "scripts/test.js"

ToDo

  • Getter and Setter support.
  • "use strict" syntax support.

Dev

  • bin/src/WSHModule is built on Lazarus (Free Pascal)

Build

  1. Copy bin/wshmodule.wsf and bin\wshmshell.js to bin/src/WSHModule folder
  2. Download Lazarus IDE and Install
  3. Project -> Open Project -> Open bin/src/WSHModule/WSHModule.lpr (Change All files (*.*))
  4. Confirm dialog The file "WSHModule.lpr" is not a Lazarus project. Create a new project for this "program"? -> Create project
  5. Select Application
  6. Run (Menu Run -> Run) or Build (Menu Run -> Build)

You can get a WSHModule.exe by build, and also run JavaScript with WSHModule console, for example, typing 1+1 and press enter key in the console window, you can get result 2.

JavaScript API

Global

  • __filename : Current filename
  • __dirname : Current dirname

Example

console.log(__filename); // C:\path\to\your_script.js
console.log(__dirname); // C:\path\to

Clipboard

Example

var clip = require('clip');
clip.set('test');

Available format: 'text' or 'html'

  • get ([format = 'text']) : Get clipboard text as [format]
  • set (data, [format = 'text']) : Set data to clipboard as [format]
  • empty() : Empty clipboard data
  • hasFormat(format) : Check whether clipboard has a format
  • getAsText() : A shortcut of get('text')
  • getAsHTML() : A shortcut of get('html')
  • setAsText(data) : A shortcut of set(data, 'text')
  • setAsHTML(data) : A shortcut of set(data, 'html')
  • copy() : Emulate copy command of the keyboard
  • paste() : Emulate paste command of the keyboard
  • cut() : Emulate cut command of the keyboard
  • getSelectedText() : Get selected text to clipboard (shortcut of copy() and get())
  • print(text) : Print clipboard text (shortcut of set(text) and paste())

fs

Local file system utility

var fs = require('fs');
console.log(fs.readFileSync('./test.txt'));
  • renameSync(oldPath, newPath) : Rename file oldPath to newPath
  • statSync(path) : Get file stat
  • unlinkSync(path, force = false) : Remove file
  • existsSync(path) : Check whether a file exists
  • readFileSync(filename, encoding = 'utf-8') : Read content from filename
  • writeFileSync(filename, data, encoding = 'utf-8') : Write content data to filename
  • copySync(src, dst, overwrite = false) : Copy file src to dst
  • moveSync(src, dst) : Move file from src to dst

License

MIT

Credits

This project is using on the following excellent free yet copyrighted open source softwares. We follow the policies of those software packages.

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].