@tarojs/plugin-inject 1.0.2 → 3.6.1
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/LICENSE +139 -0
- package/dist/index.js +40 -15
- package/dist/index.js.map +1 -1
- package/dist/runtime.js +10 -11
- package/dist/runtime.js.map +1 -1
- package/index.js +1 -0
- package/package.json +19 -28
- package/dist/apis-list.js +0 -3
- package/dist/apis-list.js.map +0 -1
- package/dist/components.js +0 -2
- package/dist/components.js.map +0 -1
- package/src/apis-list.ts +0 -2
- package/src/components.ts +0 -1
- package/src/index.ts +0 -101
- package/src/runtime.ts +0 -18
package/LICENSE
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 O2Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
========================================================================
|
|
24
|
+
|
|
25
|
+
MIT (react-devtools):
|
|
26
|
+
The following files embed [react-devtools](https://github.com/facebook/react) MIT:
|
|
27
|
+
`/packages/taro-plugin-react-devtools/src/backend/index.js`
|
|
28
|
+
See `/LICENSE` for details of the license.
|
|
29
|
+
|
|
30
|
+
==================
|
|
31
|
+
|
|
32
|
+
MIT (vue-devtools):
|
|
33
|
+
The following files embed [vue-devtools](https://github.com/vuejs/devtools) MIT:
|
|
34
|
+
`/packages/taro-plugin-vue-devtools/src/backend/*`
|
|
35
|
+
See `/LICENSE` for details of the license.
|
|
36
|
+
|
|
37
|
+
==================
|
|
38
|
+
|
|
39
|
+
MIT (vite):
|
|
40
|
+
The following files embed [vite](https://github.com/vitejs/vite) MIT:
|
|
41
|
+
`/packages/taro-webpack5-prebundle/src/prebundle/scanImport.ts`,
|
|
42
|
+
`/packages/taro-webpack5-prebundle/src/prebundle/bundle.ts`,
|
|
43
|
+
`/packages/taro-webpack5-prebundle/src/h5.ts`,
|
|
44
|
+
`/packages/taro-webpack5-prebundle/src/min.ts`
|
|
45
|
+
See `/LICENSE` for details of the license.
|
|
46
|
+
|
|
47
|
+
==================
|
|
48
|
+
|
|
49
|
+
MIT (webpack):
|
|
50
|
+
The following files embed [webpack](https://github.com/webpack/webpack) MIT:
|
|
51
|
+
`/packages/taro-webpack5-prebundle/src/webpack/TaroContainerEntryModule.ts`,
|
|
52
|
+
`/packages/taro-webpack5-prebundle/src/webpack/TaroContainerPlugin.ts`,
|
|
53
|
+
`/packages/taro-webpack5-prebundle/src/webpack/TaroContainerReferencePlugin.ts`,
|
|
54
|
+
`/packages/taro-webpack5-prebundle/src/webpack/TaroModuleFederationPlugin.ts`
|
|
55
|
+
See `/LICENSE` for details of the license.
|
|
56
|
+
|
|
57
|
+
==================
|
|
58
|
+
|
|
59
|
+
MIT (sizzle):
|
|
60
|
+
The following files embed [sizzle](https://github.com/jquery/sizzle) MIT:
|
|
61
|
+
`/packages/taro-extends/src/jquery/sizzle.js`
|
|
62
|
+
See `/LICENSE.txt` for details of the license.
|
|
63
|
+
|
|
64
|
+
==================
|
|
65
|
+
|
|
66
|
+
MIT (zepto):
|
|
67
|
+
The following files embed [zepto](https://github.com/madrobby/zepto) MIT:
|
|
68
|
+
`/packages/taro-extends/src/jquery/zepto.js`,
|
|
69
|
+
`/packages/taro-extends/src/jquery/event.js`
|
|
70
|
+
See `/MIT-LICENSE` for details of the license.
|
|
71
|
+
|
|
72
|
+
==================
|
|
73
|
+
|
|
74
|
+
MIT (css-to-react-native):
|
|
75
|
+
The following files embed [css-to-react-native](https://github.com/styled-components/css-to-react-native) MIT:
|
|
76
|
+
`/packages/css-to-react-native/src/css-to-react-native/*`
|
|
77
|
+
See `/LICENSE.md` for details of the license.
|
|
78
|
+
|
|
79
|
+
==================
|
|
80
|
+
|
|
81
|
+
MIT (reactify-wc):
|
|
82
|
+
The following files embed [reactify-wc](https://github.com/BBKolton/reactify-wc) MIT:
|
|
83
|
+
`/packages/taro-components-library-react/src/component-lib/reactify-wc.ts`
|
|
84
|
+
See `/LICENSE` for details of the license.
|
|
85
|
+
|
|
86
|
+
==================
|
|
87
|
+
|
|
88
|
+
MIT (ant-design-mobile-rn):
|
|
89
|
+
The following files embed [ant-design-mobile-rn](https://github.com/ant-design/ant-design-mobile-rn) MIT:
|
|
90
|
+
`/packages/taro-components-rn/src/components/Swiper/carousel.tsx`
|
|
91
|
+
See `/LICENSE` for details of the license.
|
|
92
|
+
|
|
93
|
+
==================
|
|
94
|
+
|
|
95
|
+
MIT (react-wx-images-viewer):
|
|
96
|
+
The following files embed [react-wx-images-viewer](https://github.com/react-ld/react-wx-images-viewer) MIT:
|
|
97
|
+
`/packages/taro-h5/src/api/media/image/previewImage.ts`
|
|
98
|
+
See `/LICENSE` for details of the license.
|
|
99
|
+
|
|
100
|
+
==================
|
|
101
|
+
|
|
102
|
+
MIT (webpack-contrib/css-loader):
|
|
103
|
+
The following files embed [webpack-contrib/css-loader](https://github.com/webpack-contrib/css-loader) MIT:
|
|
104
|
+
`/packages/taro-rn-style-transformer/src/utils/index.ts`
|
|
105
|
+
See `/LICENSE` for details of the license.
|
|
106
|
+
|
|
107
|
+
==================
|
|
108
|
+
|
|
109
|
+
MIT (react-native):
|
|
110
|
+
The following files embed [react-native](https://github.com/facebook/react-native) MIT:
|
|
111
|
+
`/packages/taro-rn-style-transformer/src/transforms/StyleSheet/*`
|
|
112
|
+
See `/LICENSE` for details of the license.
|
|
113
|
+
|
|
114
|
+
==================
|
|
115
|
+
|
|
116
|
+
MIT (myrne/performance-now):
|
|
117
|
+
The following files embed [myrne/performance-now](https://github.com/myrne/performance-now) MIT:
|
|
118
|
+
`/packages/taro-runtime/src/bom/raf.ts`
|
|
119
|
+
See `/LICENSE` for details of the license.
|
|
120
|
+
|
|
121
|
+
==================
|
|
122
|
+
|
|
123
|
+
Apache (chameleon-api):
|
|
124
|
+
The following files embed [chameleon-api](https://github.com/chameleon-team/chameleon-api) Apache:
|
|
125
|
+
`/packages/taro-h5/src/api/device/clipboard.ts`
|
|
126
|
+
|
|
127
|
+
==================
|
|
128
|
+
|
|
129
|
+
MIT (uni-app):
|
|
130
|
+
The following files embed [uni-app](https://github.com/dcloudio/uni-app) MIT:
|
|
131
|
+
`/packages/taro-components-rn/src/components/Video/index.tsx`
|
|
132
|
+
See `/LICENSE` for details of the license.
|
|
133
|
+
|
|
134
|
+
==================
|
|
135
|
+
|
|
136
|
+
MIT (miniprogram-render):
|
|
137
|
+
The following files embed [miniprogram-render](https://github.com/Tencent/kbone) MIT:
|
|
138
|
+
`/packages/taro-plugin-http/src/runtime/Cookie.ts`
|
|
139
|
+
See `/LICENSE` for details of the license.
|
package/dist/index.js
CHANGED
|
@@ -1,26 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var shared = require('@tarojs/shared');
|
|
6
|
+
var path = require('path');
|
|
7
|
+
|
|
8
|
+
function _interopNamespace(e) {
|
|
9
|
+
if (e && e.__esModule) return e;
|
|
10
|
+
var n = Object.create(null);
|
|
11
|
+
if (e) {
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
n["default"] = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
27
|
+
|
|
28
|
+
var index = (ctx, options) => {
|
|
6
29
|
const fs = ctx.helper.fs;
|
|
7
30
|
ctx.registerMethod({
|
|
8
31
|
name: 'onSetupClose',
|
|
9
32
|
fn(platform) {
|
|
10
33
|
const { voidComponents, nestElements, components, syncApis, asyncApis, componentsMap, thirdPartyComponents } = options;
|
|
11
34
|
const template = platform.template;
|
|
12
|
-
if (
|
|
35
|
+
if (shared.isArray(voidComponents)) {
|
|
13
36
|
voidComponents.forEach(el => template.voidElements.add(el));
|
|
14
37
|
}
|
|
15
|
-
else if (
|
|
38
|
+
else if (shared.isFunction(voidComponents)) {
|
|
16
39
|
template.voidElements = voidComponents(template.voidElements);
|
|
17
40
|
}
|
|
18
|
-
if (
|
|
41
|
+
if (shared.isObject(nestElements)) {
|
|
19
42
|
for (const key in nestElements) {
|
|
20
43
|
template.nestElements.set(key, nestElements[key]);
|
|
21
44
|
}
|
|
22
45
|
}
|
|
23
|
-
else if (
|
|
46
|
+
else if (shared.isFunction(nestElements)) {
|
|
24
47
|
template.nestElements = nestElements(template.nestElements);
|
|
25
48
|
}
|
|
26
49
|
if (components || syncApis || asyncApis || componentsMap) {
|
|
@@ -43,28 +66,30 @@ exports.default = (ctx, options) => {
|
|
|
43
66
|
};
|
|
44
67
|
function injectRuntimePath(platform) {
|
|
45
68
|
const injectedPath = `@tarojs/plugin-inject/dist/runtime`;
|
|
46
|
-
if (
|
|
69
|
+
if (shared.isArray(platform.runtimePath)) {
|
|
47
70
|
platform.runtimePath.push(injectedPath);
|
|
48
71
|
}
|
|
49
|
-
else if (
|
|
72
|
+
else if (shared.isString(platform.runtimePath)) {
|
|
50
73
|
platform.runtimePath = [platform.runtimePath, injectedPath];
|
|
51
74
|
}
|
|
52
75
|
}
|
|
53
76
|
function injectComponentsReact(fs, taroComponentsPath, componentsMap) {
|
|
54
|
-
fs.writeFileSync(
|
|
77
|
+
fs.writeFileSync(path__namespace.resolve(__dirname, '../dist/components-react.js'), `
|
|
55
78
|
export * from '${taroComponentsPath}'
|
|
56
79
|
${Object.keys(componentsMap).map((key) => `export const ${key} = '${componentsMap[key]}'`).join('\n')}
|
|
57
80
|
`);
|
|
58
81
|
}
|
|
59
82
|
function injectComponents(fs, components) {
|
|
60
|
-
fs.writeFileSync(
|
|
83
|
+
fs.writeFileSync(path__namespace.resolve(__dirname, '../dist/components.js'), `
|
|
61
84
|
export const components = ${components ? JSON.stringify(components) : JSON.stringify({})};
|
|
62
85
|
`);
|
|
63
86
|
}
|
|
64
87
|
function injectApis(fs, syncApis, asyncApis) {
|
|
65
|
-
fs.writeFileSync(
|
|
88
|
+
fs.writeFileSync(path__namespace.resolve(__dirname, '../dist/apis-list.js'), `
|
|
66
89
|
export const noPromiseApis = new Set(${syncApis ? JSON.stringify(syncApis) : JSON.stringify([])});
|
|
67
90
|
export const needPromiseApis = new Set(${asyncApis ? JSON.stringify(asyncApis) : JSON.stringify([])});
|
|
68
91
|
`);
|
|
69
92
|
}
|
|
70
|
-
|
|
93
|
+
|
|
94
|
+
exports["default"] = index;
|
|
95
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["\nimport { isArray, isFunction, isObject, isString } from '@tarojs/shared'\nimport * as path from 'path'\n\nimport type { IPluginContext, TaroPlatformBase } from '@tarojs/service'\n\ntype VoidComponents = Set<string>\ntype NestElements = Map<string, number>\n\ninterface IOptions {\n voidComponents: string[] | ((list: VoidComponents) => VoidComponents)\n nestElements: Record<string, number> | ((elem: NestElements) => NestElements)\n components: Record<string, Record<string, any>>\n componentsMap: Record<string, string>\n syncApis: string[]\n asyncApis: string[]\n thirdPartyComponents: Record<string, Record<string, any>>\n}\n\nexport default (ctx: IPluginContext, options: IOptions) => {\n const fs = ctx.helper.fs\n\n ctx.registerMethod({\n name: 'onSetupClose',\n fn (platform: TaroPlatformBase) {\n const {\n voidComponents,\n nestElements,\n components,\n syncApis,\n asyncApis,\n componentsMap,\n thirdPartyComponents\n } = options\n\n const template = platform.template\n\n if (isArray(voidComponents)) {\n voidComponents.forEach(el => template.voidElements.add(el))\n } else if (isFunction(voidComponents)) {\n template.voidElements = voidComponents(template.voidElements)\n }\n\n if (isObject<NestElements>(nestElements)) {\n for (const key in nestElements) {\n template.nestElements.set(key, nestElements[key])\n }\n } else if (isFunction(nestElements)) {\n template.nestElements = nestElements(template.nestElements)\n }\n\n if (components || syncApis || asyncApis || componentsMap) {\n injectRuntimePath(platform)\n\n if (components) {\n template.mergeComponents(ctx, components)\n }\n\n if (componentsMap) {\n injectComponentsReact(fs, platform.taroComponentsPath, componentsMap)\n platform.taroComponentsPath = `@tarojs/plugin-inject/dist/components-react`\n }\n\n injectComponents(fs, components)\n injectApis(fs, syncApis, asyncApis)\n }\n\n if (thirdPartyComponents) {\n template.mergeThirdPartyComponents(thirdPartyComponents)\n }\n }\n })\n}\n\nfunction injectRuntimePath (platform: TaroPlatformBase) {\n const injectedPath = `@tarojs/plugin-inject/dist/runtime`\n if (isArray(platform.runtimePath)) {\n platform.runtimePath.push(injectedPath)\n } else if (isString(platform.runtimePath)) {\n platform.runtimePath = [platform.runtimePath, injectedPath]\n }\n}\n\nfunction injectComponentsReact (fs, taroComponentsPath, componentsMap) {\n fs.writeFileSync(path.resolve(__dirname, '../dist/components-react.js'), `\nexport * from '${taroComponentsPath}'\n${Object.keys(componentsMap).map((key) => `export const ${key} = '${componentsMap[key]}'`).join('\\n')}\n`)\n}\n\nfunction injectComponents (fs, components) {\n fs.writeFileSync(path.resolve(__dirname, '../dist/components.js'), `\nexport const components = ${components ? JSON.stringify(components) : JSON.stringify({})};\n`)\n}\n\nfunction injectApis (fs, syncApis, asyncApis) {\n fs.writeFileSync(path.resolve(__dirname, '../dist/apis-list.js'), `\nexport const noPromiseApis = new Set(${syncApis ? JSON.stringify(syncApis) : JSON.stringify([])});\nexport const needPromiseApis = new Set(${asyncApis ? JSON.stringify(asyncApis) : JSON.stringify([])});\n`)\n}\n"],"names":["isArray","isFunction","isObject","isString","path"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,YAAe,CAAC,GAAmB,EAAE,OAAiB,KAAI;AACxD,IAAA,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAA;IAExB,GAAG,CAAC,cAAc,CAAC;AACjB,QAAA,IAAI,EAAE,cAAc;AACpB,QAAA,EAAE,CAAE,QAA0B,EAAA;AAC5B,YAAA,MAAM,EACJ,cAAc,EACd,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,SAAS,EACT,aAAa,EACb,oBAAoB,EACrB,GAAG,OAAO,CAAA;AAEX,YAAA,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAA;AAElC,YAAA,IAAIA,cAAO,CAAC,cAAc,CAAC,EAAE;AAC3B,gBAAA,cAAc,CAAC,OAAO,CAAC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CAAC,aAAa,CAACA,eAAI,CAAC,OAAO,CAAC,SAAS,EAAE,sBAAsB,CAAC,EAAE,CAAA;AAC7B,qCAAA,EAAA,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;AACtD,uCAAA,EAAA,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;AAClG,CAAA,CAAC,CAAA;AACF;;;;"}
|
package/dist/runtime.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const apis_list_1 = require("./apis-list");
|
|
1
|
+
import { mergeReconciler, mergeInternalComponents, processApis } from '@tarojs/shared';
|
|
2
|
+
import { noPromiseApis, needPromiseApis } from './apis-list';
|
|
3
|
+
import { components } from './components';
|
|
4
|
+
|
|
6
5
|
const hostConfig = {
|
|
7
6
|
initNativeApi(taro) {
|
|
8
7
|
const global = taro.miniGlobal;
|
|
9
|
-
|
|
10
|
-
noPromiseApis
|
|
11
|
-
needPromiseApis
|
|
8
|
+
processApis(taro, global, {
|
|
9
|
+
noPromiseApis,
|
|
10
|
+
needPromiseApis,
|
|
12
11
|
isOnlyPromisify: true
|
|
13
12
|
});
|
|
14
13
|
}
|
|
15
14
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
//# sourceMappingURL=runtime.js.map
|
|
15
|
+
mergeReconciler(hostConfig);
|
|
16
|
+
mergeInternalComponents(components);
|
|
17
|
+
//# sourceMappingURL=runtime.js.map
|
package/dist/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","
|
|
1
|
+
{"version":3,"file":"runtime.js","sources":["../src/runtime.ts"],"sourcesContent":["import { mergeInternalComponents, mergeReconciler, processApis } from '@tarojs/shared'\n\nimport { needPromiseApis,noPromiseApis } from './apis-list'\nimport { components } from './components'\n\nconst hostConfig = {\n initNativeApi (taro) {\n const global = taro.miniGlobal\n processApis(taro, global, {\n noPromiseApis,\n needPromiseApis,\n isOnlyPromisify: true\n })\n }\n}\n\n\nmergeReconciler(hostConfig)\nmergeInternalComponents(components)\n"],"names":[],"mappings":";;;;AAKA,MAAM,UAAU,GAAG;AACjB,IAAA,aAAa,CAAE,IAAI,EAAA;AACjB,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAA;AAC9B,QAAA,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE;YACxB,aAAa;YACb,eAAe;AACf,YAAA,eAAe,EAAE,IAAI;AACtB,SAAA,CAAC,CAAA;KACH;CACF,CAAA;AAGD,eAAe,CAAC,UAAU,CAAC,CAAA;AAC3B,uBAAuB,CAAC,UAAU,CAAC"}
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,43 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/plugin-inject",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.6.1",
|
|
4
4
|
"description": "Taro 小程序端平台中间层插件",
|
|
5
|
+
"author": "luckyadam",
|
|
6
|
+
"homepage": "https://github.com/nervjs/taro",
|
|
7
|
+
"license": "MIT",
|
|
5
8
|
"main": "index.js",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
"prod": "tsc",
|
|
10
|
-
"clean": "rimraf dist",
|
|
11
|
-
"test": "jest",
|
|
12
|
-
"test:dev": "jest --watch"
|
|
13
|
-
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"taro"
|
|
11
|
+
],
|
|
14
12
|
"files": [
|
|
15
|
-
"src",
|
|
16
|
-
"dist",
|
|
17
13
|
"index.js",
|
|
18
|
-
"
|
|
14
|
+
"dist"
|
|
19
15
|
],
|
|
20
16
|
"repository": {
|
|
21
17
|
"type": "git",
|
|
22
|
-
"url": "git+https://github.com/NervJS/taro
|
|
18
|
+
"url": "git+https://github.com/NervJS/taro.git"
|
|
23
19
|
},
|
|
24
|
-
"keywords": [
|
|
25
|
-
"Taro"
|
|
26
|
-
],
|
|
27
|
-
"author": "luckyadam",
|
|
28
|
-
"license": "MIT",
|
|
29
20
|
"bugs": {
|
|
30
|
-
"url": "https://github.com/NervJS/
|
|
21
|
+
"url": "https://github.com/NervJS/taro/issues"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@tarojs/service": "3.6.1",
|
|
25
|
+
"@tarojs/shared": "3.6.1"
|
|
31
26
|
},
|
|
32
|
-
"homepage": "https://github.com/NervJS/tarojs-plugin-inject#readme",
|
|
33
27
|
"peerDependencies": {
|
|
34
|
-
"
|
|
28
|
+
"react": ">=17"
|
|
35
29
|
},
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"typescript": "^3.8.3",
|
|
40
|
-
"webpack": "^4.41.0",
|
|
41
|
-
"webpack-dev-server": "^3.8.2"
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "rollup -c",
|
|
32
|
+
"dev": "rollup -c -w"
|
|
42
33
|
}
|
|
43
|
-
}
|
|
34
|
+
}
|
package/dist/apis-list.js
DELETED
package/dist/apis-list.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apis-list.js","sourceRoot":"","sources":["../src/apis-list.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC,CAAA;AAC3B,QAAA,eAAe,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC,CAAA"}
|
package/dist/components.js
DELETED
package/dist/components.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG,EAAE,CAAA"}
|
package/src/apis-list.ts
DELETED
package/src/components.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const components = {}
|
package/src/index.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import type { IPluginContext, TaroPlatformBase } from '@tarojs/service'
|
|
3
|
-
import { isObject, isArray, isFunction, isString } from '@tarojs/shared'
|
|
4
|
-
import * as path from 'path'
|
|
5
|
-
|
|
6
|
-
type VoidComponents = Set<string>
|
|
7
|
-
type NestElements = Map<string, number>
|
|
8
|
-
|
|
9
|
-
interface IOptions {
|
|
10
|
-
voidComponents: string[] | ((list: VoidComponents) => VoidComponents)
|
|
11
|
-
nestElements: Record<string, number> | ((elem: NestElements) => NestElements)
|
|
12
|
-
components: Record<string, Record<string, any>>
|
|
13
|
-
componentsMap: Record<string, string>
|
|
14
|
-
syncApis: string[]
|
|
15
|
-
asyncApis: string[]
|
|
16
|
-
thirdPartyComponents: Record<string, Record<string, any>>
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export default (ctx: IPluginContext, options: IOptions) => {
|
|
20
|
-
const fs = ctx.helper.fs
|
|
21
|
-
|
|
22
|
-
ctx.registerMethod({
|
|
23
|
-
name: 'onSetupClose',
|
|
24
|
-
fn(platform: TaroPlatformBase) {
|
|
25
|
-
const {
|
|
26
|
-
voidComponents,
|
|
27
|
-
nestElements,
|
|
28
|
-
components,
|
|
29
|
-
syncApis,
|
|
30
|
-
asyncApis,
|
|
31
|
-
componentsMap,
|
|
32
|
-
thirdPartyComponents
|
|
33
|
-
} = options
|
|
34
|
-
|
|
35
|
-
const template = platform.template
|
|
36
|
-
|
|
37
|
-
if (isArray(voidComponents)) {
|
|
38
|
-
voidComponents.forEach(el => template.voidElements.add(el))
|
|
39
|
-
} else if (isFunction(voidComponents)) {
|
|
40
|
-
template.voidElements = voidComponents(template.voidElements)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (isObject<NestElements>(nestElements)) {
|
|
44
|
-
for (const key in nestElements) {
|
|
45
|
-
template.nestElements.set(key, nestElements[key])
|
|
46
|
-
}
|
|
47
|
-
} else if (isFunction(nestElements)) {
|
|
48
|
-
template.nestElements = nestElements(template.nestElements)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (components || syncApis || asyncApis || componentsMap) {
|
|
52
|
-
injectRuntimePath(platform)
|
|
53
|
-
|
|
54
|
-
if (components) {
|
|
55
|
-
template.mergeComponents(ctx, components)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (componentsMap) {
|
|
59
|
-
injectComponentsReact(fs, platform.taroComponentsPath, componentsMap)
|
|
60
|
-
platform.taroComponentsPath = `@tarojs/plugin-inject/dist/components-react`
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
injectComponents(fs, components)
|
|
64
|
-
injectApis(fs, syncApis, asyncApis)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (thirdPartyComponents) {
|
|
68
|
-
template.mergeThirdPartyComponents(thirdPartyComponents)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
})
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function injectRuntimePath(platform: TaroPlatformBase) {
|
|
75
|
-
const injectedPath = `@tarojs/plugin-inject/dist/runtime`
|
|
76
|
-
if (isArray(platform.runtimePath)) {
|
|
77
|
-
platform.runtimePath.push(injectedPath)
|
|
78
|
-
} else if (isString(platform.runtimePath)) {
|
|
79
|
-
platform.runtimePath = [platform.runtimePath, injectedPath]
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function injectComponentsReact(fs, taroComponentsPath, componentsMap) {
|
|
84
|
-
fs.writeFileSync(path.resolve(__dirname, '../dist/components-react.js'), `
|
|
85
|
-
export * from '${taroComponentsPath}'
|
|
86
|
-
${Object.keys(componentsMap).map((key) => `export const ${key} = '${componentsMap[key]}'`).join('\n')}
|
|
87
|
-
`)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function injectComponents(fs, components) {
|
|
91
|
-
fs.writeFileSync(path.resolve(__dirname, '../dist/components.js'), `
|
|
92
|
-
export const components = ${components ? JSON.stringify(components) : JSON.stringify({})};
|
|
93
|
-
`)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function injectApis(fs, syncApis, asyncApis) {
|
|
97
|
-
fs.writeFileSync(path.resolve(__dirname, '../dist/apis-list.js'), `
|
|
98
|
-
export const noPromiseApis = new Set(${syncApis ? JSON.stringify(syncApis) : JSON.stringify([])});
|
|
99
|
-
export const needPromiseApis = new Set(${asyncApis ? JSON.stringify(asyncApis) : JSON.stringify([])});
|
|
100
|
-
`)
|
|
101
|
-
}
|
package/src/runtime.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { mergeReconciler, mergeInternalComponents, processApis } from '@tarojs/shared'
|
|
2
|
-
import { components } from './components'
|
|
3
|
-
import { noPromiseApis, needPromiseApis } from './apis-list'
|
|
4
|
-
|
|
5
|
-
const hostConfig = {
|
|
6
|
-
initNativeApi (taro) {
|
|
7
|
-
const global = taro.miniGlobal
|
|
8
|
-
processApis(taro, global, {
|
|
9
|
-
noPromiseApis,
|
|
10
|
-
needPromiseApis,
|
|
11
|
-
isOnlyPromisify: true
|
|
12
|
-
})
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
mergeReconciler(hostConfig)
|
|
18
|
-
mergeInternalComponents(components)
|