@@ -1,5 +1,4 @@
 | 
				
			|||||||
import '@ms/ployfill'
 | 
					/// <reference types='@ms/ployfill' />
 | 
				
			||||||
 | 
					 | 
				
			||||||
export * from './task'
 | 
					export * from './task'
 | 
				
			||||||
export * from './event'
 | 
					export * from './event'
 | 
				
			||||||
export * from './console'
 | 
					export * from './console'
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,7 +17,8 @@
 | 
				
			|||||||
        "test": "echo \"Error: run tests from root\" && exit 1"
 | 
					        "test": "echo \"Error: run tests from root\" && exit 1"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "dependencies": {
 | 
					    "dependencies": {
 | 
				
			||||||
        "@ms/nashorn": "^0.1.0"
 | 
					        "@ms/nashorn": "^0.1.0",
 | 
				
			||||||
 | 
					        "core-js": "^3.6.4"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "devDependencies": {
 | 
					    "devDependencies": {
 | 
				
			||||||
        "reflect-metadata": "^0.1.13",
 | 
					        "reflect-metadata": "^0.1.13",
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										26
									
								
								packages/ployfill/src/es5-ext.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								packages/ployfill/src/es5-ext.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
				
			|||||||
 | 
					// ES2015 String ployfill must force overwrite to js method
 | 
				
			||||||
 | 
					Object.defineProperty(String.prototype, 'contains', {
 | 
				
			||||||
 | 
					    value: require(`es5-ext/string/#/contains/shim`),
 | 
				
			||||||
 | 
					    configurable: true,
 | 
				
			||||||
 | 
					    enumerable: false,
 | 
				
			||||||
 | 
					    writable: true
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					Object.defineProperty(String.prototype, 'repeat', {
 | 
				
			||||||
 | 
					    value: require(`es5-ext/string/#/repeat/shim`),
 | 
				
			||||||
 | 
					    configurable: true,
 | 
				
			||||||
 | 
					    enumerable: false,
 | 
				
			||||||
 | 
					    writable: true
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					Object.defineProperty(String.prototype, 'startsWith', {
 | 
				
			||||||
 | 
					    value: require(`es5-ext/string/#/starts-with/shim`),
 | 
				
			||||||
 | 
					    configurable: true,
 | 
				
			||||||
 | 
					    enumerable: false,
 | 
				
			||||||
 | 
					    writable: true
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					Object.defineProperty(String.prototype, 'endsWith', {
 | 
				
			||||||
 | 
					    value: require(`es5-ext/string/#/ends-with/shim`),
 | 
				
			||||||
 | 
					    configurable: true,
 | 
				
			||||||
 | 
					    enumerable: false,
 | 
				
			||||||
 | 
					    writable: true
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1,19 +1,10 @@
 | 
				
			|||||||
import './global'
 | 
					/// <reference path="./global.ts" />
 | 
				
			||||||
import '@ms/nashorn'
 | 
					/// <reference types='@ms/nashorn' />
 | 
				
			||||||
import { Proxy } from './proxy'
 | 
					 | 
				
			||||||
import { XMLHttpRequest } from './xml-http-request'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
let ployfillStartTime = new Date().getTime();
 | 
					let ployfillStartTime = new Date().getTime();
 | 
				
			||||||
console.info('Initialization Java Nashorn ployfill. Please wait...');
 | 
					console.info('Initialization Java Nashorn ployfill. Please wait...');
 | 
				
			||||||
// String contains ployfill
 | 
					require('./es5-ext');
 | 
				
			||||||
Object.defineProperty(String.prototype, 'contains', {
 | 
					require('core-js');
 | 
				
			||||||
    value: function(searchString: string, position: number) {
 | 
					global.setGlobal('Proxy', require('./proxy').Proxy)
 | 
				
			||||||
        return String.prototype.indexOf.call(this, searchString, position) > -1;
 | 
					global.setGlobal('XMLHttpRequest', require('./xml-http-request').XMLHttpRequest)
 | 
				
			||||||
    }
 | 
					global.setGlobal('Blob', require('blob-polyfill').Blob)
 | 
				
			||||||
})
 | 
					 | 
				
			||||||
// ES6 Map Symbol ployfill
 | 
					 | 
				
			||||||
require('es6-map/implement');
 | 
					 | 
				
			||||||
require('es6-symbol/implement');
 | 
					 | 
				
			||||||
global.setGlobal('Proxy', Proxy)
 | 
					 | 
				
			||||||
global.setGlobal('XMLHttpRequest', XMLHttpRequest)
 | 
					 | 
				
			||||||
console.info('Java Nashorn ployfill loading completed... Cost (' + (new Date().getTime() - ployfillStartTime) / 1000 + 's)!');
 | 
					console.info('Java Nashorn ployfill loading completed... Cost (' + (new Date().getTime() - ployfillStartTime) / 1000 + 's)!');
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,3 +1,4 @@
 | 
				
			|||||||
 | 
					// Nashorn JSAdapter See https://wiki.openjdk.java.net/display/Nashorn/Nashorn+extensions#Nashornextensions-JSAdapterconstructor
 | 
				
			||||||
let createProxy = eval(`
 | 
					let createProxy = eval(`
 | 
				
			||||||
    function(handle){ return new JSAdapter(handle) }
 | 
					    function(handle){ return new JSAdapter(handle) }
 | 
				
			||||||
`)
 | 
					`)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user