@ray-js/build-plugin-ray 0.3.0-beta.1c347991
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +32 -0
- package/package.json +47 -0
- package/templates/README.md +21 -0
- package/templates/index.native.ts +6 -0
- package/templates/index.ts +5 -0
- package/templates/main.mini.tsx +10 -0
- package/templates/main.native.tsx +7 -0
- package/templates/main.tsx +17 -0
- package/typings/index.d.ts +33 -0
package/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# @ray-js/build-plugin-ray
|
2
|
+
|
3
|
+
- 非 react native(涂鸦小程序、微信小程序、H5 等) 生成 `.ray` 运行时框架临时文件
|
4
|
+
- react native 生成 `@ray`运行时框架临时文件
|
5
|
+
|
6
|
+
<!-- TODO 解决两种临时文件夹 -->
|
7
|
+
|
8
|
+
配合 `@ray-js/framework` 进行适配,主要提供如
|
9
|
+
|
10
|
+
```js
|
11
|
+
import { router, location } from 'ray';
|
12
|
+
```
|
13
|
+
|
14
|
+
框架层的 API 实现
|
15
|
+
|
16
|
+
并附加 `webpack.resolve.alias` 配置
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const colors_1 = __importDefault(require("colors"));
|
7
|
+
const path_1 = __importDefault(require("path"));
|
8
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
9
|
+
const shared_1 = require("@ray-js/shared");
|
10
|
+
colors_1.default.enable();
|
11
|
+
const BUILD_TEMP_DIR = '.ray';
|
12
|
+
const LOG_PREFIX = `build-plugin-ray`;
|
13
|
+
function PluginRay(api) {
|
14
|
+
const { options: { cwd }, } = api;
|
15
|
+
const rayFolder = path_1.default.join(cwd, BUILD_TEMP_DIR);
|
16
|
+
return {
|
17
|
+
name: '@ray-js/build-plugin-ray',
|
18
|
+
setup() {
|
19
|
+
shared_1.log.verbose(LOG_PREFIX, 'setup', api);
|
20
|
+
this.generateRayBootstrap();
|
21
|
+
},
|
22
|
+
configWebpack({ config }) {
|
23
|
+
shared_1.log.verbose(LOG_PREFIX, 'ray folder', rayFolder.blue.underline);
|
24
|
+
config.resolve.alias.set('ray', rayFolder);
|
25
|
+
},
|
26
|
+
generateRayBootstrap() {
|
27
|
+
const root = path_1.default.join(__dirname, '../templates');
|
28
|
+
fs_extra_1.default.copySync(root, rayFolder);
|
29
|
+
},
|
30
|
+
};
|
31
|
+
}
|
32
|
+
exports.default = PluginRay;
|
package/package.json
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
{
|
2
|
+
"name": "@ray-js/build-plugin-ray",
|
3
|
+
"version": "0.3.0-beta.1c347991",
|
4
|
+
"description": "Ray build plugin for ray/framework",
|
5
|
+
"keywords": [
|
6
|
+
"ray"
|
7
|
+
],
|
8
|
+
"author": "子长 <zichang.nong@tuya.com>",
|
9
|
+
"license": "MIT",
|
10
|
+
"main": "lib/index.js",
|
11
|
+
"files": [
|
12
|
+
"lib",
|
13
|
+
"templates",
|
14
|
+
"typings"
|
15
|
+
],
|
16
|
+
"publishConfig": {
|
17
|
+
"access": "public",
|
18
|
+
"registry": "https://registry.npmjs.org"
|
19
|
+
},
|
20
|
+
"scripts": {
|
21
|
+
"clean": "rm -rf lib",
|
22
|
+
"build": "tsc -p ./tsconfig.build.json",
|
23
|
+
"watch": "tsc -p ./tsconfig.build.json --watch"
|
24
|
+
},
|
25
|
+
"peerDependencies": {
|
26
|
+
"@ray-js/cli": "^0.0.0"
|
27
|
+
},
|
28
|
+
"dependencies": {
|
29
|
+
"@ray-js/shared": "^0.3.0-beta.1c347991",
|
30
|
+
"chokidar": "^3.5.2",
|
31
|
+
"fs-extra": "^10.0.0"
|
32
|
+
},
|
33
|
+
"devDependencies": {
|
34
|
+
"@ray-js/types": "^0.3.0-beta.1c347991",
|
35
|
+
"@types/fs-extra": "^9.0.13",
|
36
|
+
"chokidar": "^3.5.2",
|
37
|
+
"colors": "1.4.0"
|
38
|
+
},
|
39
|
+
"maintainers": [
|
40
|
+
{
|
41
|
+
"name": "tuyafe",
|
42
|
+
"email": "tuyafe@tuya.com"
|
43
|
+
}
|
44
|
+
],
|
45
|
+
"gitHead": "e0bd013022ddda63380d3c9e20fd8cadb46cd61f",
|
46
|
+
"repository": {}
|
47
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Ray
|
2
|
+
|
3
|
+
由 `@ray-js/build-plugin-ray` 进行文件内容的生成,不要进行对该文件夹下任何文件进行修改。
|
4
|
+
|
5
|
+
实现 `import * form 'ray';` 的导出,通过 `webpack.resolve.alias` 来配置构建。
|
6
|
+
|
7
|
+
底层由 `@ray-js/framework` 进行实现,主要包含对应应用类型(web, wechat native tuya)执行的上下文 PageInstanceContext 来进行运行时的框架抹平完成应用的同构。
|
8
|
+
|
9
|
+
受限于小程序厂商的能力,尽量在此基础上,以 web 标准开发进行抹平,业务开发也尽可能的保持面向 WEB 开发的心智。
|
10
|
+
|
11
|
+
build-plugin-ray/template 目录说明
|
12
|
+
|
13
|
+
```
|
14
|
+
template
|
15
|
+
├── index.native.ts # 构建RN时,导入的模块 `import * form 'ray';`
|
16
|
+
├── index.ts # 构建web、小程序时,导入的模块 `import * form 'ray';`
|
17
|
+
├── main.mini.tsx # 小程序(tuya、wechat等)构建入口文件
|
18
|
+
├── main.native.tsx # RN构建入口文件
|
19
|
+
├── main.tsx # web构建入口文件
|
20
|
+
└── README.md
|
21
|
+
```
|
@@ -0,0 +1,6 @@
|
|
1
|
+
// this file generate by @ray-js/build-plugin-router.
|
2
|
+
// do not modify this file!!!
|
3
|
+
import location from '@ray-js/location-native';
|
4
|
+
import router from '@ray-js/router-native'; // 由构建器别名替换到 @ray-js/router-mp @ray-js/router-native
|
5
|
+
export * from '@ray-js/framework-native'; // 由构建器别名替换到 @ray-js/framework-mp @ray-js/framework-native
|
6
|
+
export { router, location };
|
@@ -0,0 +1,10 @@
|
|
1
|
+
//@ts-nocheck
|
2
|
+
import { createRouter } from '@ray-js/router-mp';
|
3
|
+
|
4
|
+
// import * as globalConfig from '@/global.config';
|
5
|
+
import * as routesConfig from '@/routes.config';
|
6
|
+
|
7
|
+
createRouter({
|
8
|
+
routes: routesConfig.routes,
|
9
|
+
tabBar: routesConfig.tabBar || {},
|
10
|
+
});
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { createApp } from '@ray-js/framework';
|
2
|
+
|
3
|
+
import App from '@/app';
|
4
|
+
import * as globalConfig from '@/global.config';
|
5
|
+
import * as routesConfig from '@/routes.config';
|
6
|
+
import { PAGES } from './router.config';
|
7
|
+
|
8
|
+
const globalConfigDefault = globalConfig.default || {};
|
9
|
+
const globalConfigTarget = globalConfig[process.env.PLATFORM] || {};
|
10
|
+
|
11
|
+
createApp({
|
12
|
+
app: App,
|
13
|
+
globalConfig: { ...globalConfigTarget, ...globalConfigDefault },
|
14
|
+
pages: PAGES,
|
15
|
+
routes: routesConfig.routes,
|
16
|
+
tabBar: routesConfig.tabBar || {},
|
17
|
+
});
|
@@ -0,0 +1,33 @@
|
|
1
|
+
declare module '*.less';
|
2
|
+
|
3
|
+
type RequestRes = {
|
4
|
+
data: string;
|
5
|
+
statusCode: number;
|
6
|
+
header: Record<string, string>;
|
7
|
+
cookies: Array<string>;
|
8
|
+
profile: any;
|
9
|
+
taskId: string;
|
10
|
+
};
|
11
|
+
|
12
|
+
type RequestParams = {
|
13
|
+
url: string;
|
14
|
+
data?: string;
|
15
|
+
header?: Record<string, string>;
|
16
|
+
timeout?: number;
|
17
|
+
method?: string;
|
18
|
+
dataType?: string;
|
19
|
+
responseType?: string;
|
20
|
+
enableHttp2?: boolean;
|
21
|
+
enableQuic?: boolean;
|
22
|
+
enableCache?: boolean;
|
23
|
+
success?: (successRes: RequestRes) => void;
|
24
|
+
fail?: (successRes: RequestRes) => void;
|
25
|
+
complete?: (successRes: RequestRes) => void;
|
26
|
+
};
|
27
|
+
declare global {
|
28
|
+
interface Window {
|
29
|
+
devToolsExtension?: () => any;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
export {};
|