-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(add personal taro-runtime): fix runtime lifestyle error
- Loading branch information
Showing
59 changed files
with
6,977 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dist | ||
lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
lib | ||
t.js | ||
*.wxml | ||
s.js | ||
t.debug.ts | ||
react |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# `@tarojs/runtime` | ||
|
||
Taro 运行时。在小程序端连接框架(DSL)渲染机制到小程序渲染机制,连接小程序路由和生命周期到框架对应的生命周期。在 H5/RN 端连接小程序生命周期**规范**到框架生命周期。 | ||
|
||
## 核心 API | ||
|
||
### createReactApp() | ||
|
||
暴露给 `@tarojs/taro-loader/app` 调用,在小程序入口文件中调用,创建一个小程序 `App` 构造函数接受的小程序应用规范对象。 | ||
|
||
### createVueApp() | ||
|
||
暴露给 `@tarojs/taro-loader/app` 调用,在小程序入口文件中调用,创建一个小程序 `App` 构造函数接受的小程序应用规范对象。 | ||
|
||
### createPageConfig() | ||
|
||
暴露给 `@tarojs/taro-loader/page` 调用,在小程序页面文件中调用,创建一个小程序 `Page` 构造函数接受的小程序页面规范对象。 | ||
|
||
### window | ||
|
||
在小程序端模仿浏览器的 `window` 实现的对象,在浏览器环境中返回浏览器本身的 `window`。此对象通过 Webpack 的 [ProvidePlugin](https://webpack.js.org/plugins/provide-plugin/) 注入到全局对象以供第三方库调用。 | ||
|
||
### navigator | ||
|
||
在小程序端模仿浏览器的 `navigator` 实现的对象,在浏览器环境中返回浏览器本身的 `navigator`。此对象通过 Webpack 的 [ProvidePlugin](https://webpack.js.org/plugins/provide-plugin/) 注入到全局对象以供第三方库调用。 | ||
|
||
### document | ||
|
||
在小程序端模仿浏览器的 `document` 实现的对象,在浏览器环境中返回浏览器本身的 `document`。此对象通过 Webpack 的 [ProvidePlugin](https://webpack.js.org/plugins/provide-plugin/) 注入到全局对象以供第三方库调用。 | ||
|
||
### Current | ||
|
||
暴露给开发者的 Taro 全局变量,目前有三个属性: | ||
|
||
- `Current.app`,返回当前小程序应用实例,非小程序端返回小程序规范应用实例,可通过此实例调用小程序规范生命周期。 | ||
- `Current.page`,返回当前小程序页面实例,非小程序端返回小程序规范页面实例,可通过此实例调用小程序规范生命周期。 | ||
- `Current.router`,返回当前小程序路由信息,非小程序端返回小程序规范路由信息 | ||
|
||
### options | ||
|
||
Taro 配置: | ||
|
||
- `html`: [渲染 HTML](https://taro-docs.jd.com/taro/next/docs/html.html) | ||
- `debug`: 开启之后会打印渲染时间 | ||
- `prerender`: 暴露给 `@tarojs/cli` 的内部参数 | ||
|
||
### Events | ||
|
||
[Taro 消息机制](https://nervjs.github.io/taro/docs/apis/about/events.html#docsNav)。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const { jsWithTs: tsjPreset } = require('ts-jest/presets'); | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
testEnvironment: 'node', | ||
transform: { | ||
...tsjPreset.transform, | ||
}, | ||
transformIgnorePatterns: ['node_modules/(?!(lodash-es)/)'], | ||
testURL: 'http://localhost/', | ||
collectCoverage: false, | ||
coveragePathIgnorePatterns: ['nerv.js', 'vue.js', 'utils.js'], | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], | ||
globals: { | ||
'ts-jest': { | ||
diagnostics: false, | ||
tsConfig: { | ||
jsx: 'react', | ||
allowJs: true, | ||
target: 'ES6', | ||
}, | ||
}, | ||
}, | ||
testPathIgnorePatterns: ['node_modules', 'utils'], | ||
moduleNameMapper: { | ||
'@tarojs/shared': path.resolve( | ||
__dirname, | ||
'..', | ||
'..', | ||
'packages/shared/src/index.ts', | ||
), | ||
'@tarojs/react': path.resolve( | ||
__dirname, | ||
'..', | ||
'..', | ||
'packages/taro-react/dist/index.js', | ||
), | ||
}, | ||
// setupFiles: ['<rootDir>/__tests__/setup.js'], | ||
testMatch: ['**/__tests__/?(*.)+(spec|test).[jt]s?(x)'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "@taro-hooks/website-runtime", | ||
"version": "3.2.15", | ||
"description": "taro runtime for mini apps.", | ||
"main": "dist/runtime.esm.js", | ||
"module": "dist/runtime.esm.js", | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"test": "jest", | ||
"build": "rollup -c", | ||
"dev": "rollup -c -w" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/NervJS/taro/tree/master/packages/taro-runtime" | ||
}, | ||
"author": "yuche", | ||
"license": "MIT", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@tarojs/shared": "3.2.15", | ||
"lodash-es": "4.17.15" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const { join } = require('path'); | ||
const buble = require('rollup-plugin-buble'); | ||
const typescript = require('rollup-plugin-typescript2'); | ||
const cwd = __dirname; | ||
|
||
const baseConfig = { | ||
input: join(cwd, 'src/index.ts'), | ||
external: ['react', 'nervjs', 'react-dom', 'vue', '@tarojs/shared'], | ||
output: [ | ||
{ | ||
file: join(cwd, 'dist/index.js'), | ||
format: 'cjs', | ||
sourcemap: true, | ||
exports: 'named', | ||
}, | ||
], | ||
plugins: [typescript(), buble()], | ||
}; | ||
const esmConfig = Object.assign({}, baseConfig, { | ||
output: Object.assign({}, baseConfig.output, { | ||
sourcemap: true, | ||
format: 'es', | ||
file: join(cwd, 'dist/runtime.esm.js'), | ||
}), | ||
plugins: baseConfig.plugins.slice(0, baseConfig.plugins.length - 1), | ||
}); | ||
|
||
function rollup() { | ||
const target = process.env.TARGET; | ||
|
||
if (target === 'umd') { | ||
return baseConfig; | ||
} else if (target === 'esm') { | ||
return esmConfig; | ||
} else { | ||
return [baseConfig, esmConfig]; | ||
} | ||
} | ||
module.exports = rollup(); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
nerv.js | ||
vue.js |
Oops, something went wrong.