debug ts code

This commit is contained in:
pengfei.zhou
2019-10-22 18:01:10 +08:00
parent 2bf4874467
commit 44d7261c2c
14 changed files with 2733 additions and 12 deletions

View File

@@ -0,0 +1,34 @@
/*
* Copyright [2019] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as doric from './src/runtime/sandbox'
let global = new Function('return this')()
global.doric = doric
const contextId = "DoricDebug"
global.context = doric.jsObtainContext(contextId)
global.Entry = doric.jsObtainEntry(contextId)
console.log('Start Server')
global.injectGlobal = (objName: string, obj: string) => {
Reflect.set(global, objName, JSON.parse(obj))
}
global.sendToNative = () => {
}
global.receiveFromNative = (funcName, ) => {
}
export * from './index'

View File

@@ -2,7 +2,7 @@
"name": "doric",
"version": "0.1.0",
"description": "The JS Framework of Doric",
"main": "build/index.js",
"main": "bundle/doric-vm.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsc -p .&& rollup -c",
@@ -27,4 +27,4 @@
"tslib": "^1.10.0",
"typescript": "^3.5.3"
}
}
}

View File

@@ -25,4 +25,14 @@ export default [
],
external: ['reflect-metadata']
},
{
input: "build/index.debug.js",
output: {
format: "cjs",
file: "bundle/doric-vm.js",
},
plugins: [
resolve({ jsnext: true, main: true }),
]
},
]

View File

@@ -21,17 +21,17 @@ import "reflect-metadata"
* ``` TypeScript
* // load script in global scope
* Reflect.apply(
* function(hego,context,Entry,require){
* function(doric,context,Entry,require){
* //Script content
* REG()
* },hego.jsObtainContext(id),[
* },doric.jsObtainContext(id),[
* undefined,
* hego.jsObtainContext(id),
* hego.jsObtainEntry(id),
* hego.__require__,
* doric.jsObtainContext(id),
* doric.jsObtainEntry(id),
* doric.__require__,
* ])
* // load module in global scope
* Reflect.apply(hego.jsRegisterModule,this,[
* Reflect.apply(doric.jsRegisterModule,this,[
* moduleName,
* Reflect.apply(function(__module){
* (function(module,exports,require){