@tarojs/plugin-html 3.6.0 → 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 +119 -1
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/index.ts +2 -2
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2018
|
|
3
|
+
Copyright (c) 2018 O2Team
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -19,3 +19,121 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
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.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import generator from '@babel/generator'\nimport * as parser from '@babel/parser'\nimport traverse from '@babel/traverse'\nimport * as t from '@babel/types'\nimport { isArray, isString } from '@tarojs/shared'\nimport * as path from 'path'\n\nimport type { IPluginContext, TaroPlatformBase } from '@tarojs/service'\n\ninterface IOptions {\n pxtransformBlackList?: any[]\n modifyElements?(inline: string[], block: string[]): void\n enableSizeAPIs?: boolean\n}\n\ninterface IComponentConfig {\n includes: Set<string>\n}\n\ninterface OnParseCreateElementArgs {\n nodeName: string\n componentConfig: IComponentConfig\n}\n\nexport default (ctx: IPluginContext, options: IOptions) => {\n const inlineElements = ['i', 'abbr', 'select', 'acronym', 'small', 'bdi', 'kbd', 'strong', 'big', 'sub', 'sup', 'br', 'mark', 'meter', 'template', 'cite', 'object', 'time', 'code', 'output', 'u', 'data', 'picture', 'tt', 'datalist', 'var', 'dfn', 'del', 'q', 'em', 's', 'embed', 'samp', 'b']\n const blockElements = ['body', 'svg', 'address', 'fieldset', 'li', 'span', 'article', 'figcaption', 'main', 'aside', 'figure', 'nav', 'blockquote', 'footer', 'ol', 'details', 'p', 'dialog', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre', 'dd', 'header', 'section', 'div', 'hgroup', 'table', 'dl', 'hr', 'ul', 'dt', 'view', 'view-block']\n const specialElements = ['slot', 'form', 'iframe', 'img', 'audio', 'video', 'canvas', 'a', 'input', 'label', 'textarea', 'progress', 'button']\n\n patchMappingElements(ctx, options, inlineElements, blockElements)\n\n // 默认允许使用 getBoundingClientRect 等 API\n ctx.modifyWebpackChain(({ chain }) => {\n chain\n .plugin('definePlugin')\n .tap(args => {\n args[0].ENABLE_SIZE_APIS = options.enableSizeAPIs ?? true\n return args\n })\n })\n ctx.registerMethod({\n name: 'onSetupClose',\n fn (platform: TaroPlatformBase) {\n injectRuntimePath(platform)\n }\n })\n // 映射、收集使用到的小程序组件\n ctx.onParseCreateElement(({ nodeName, componentConfig }: OnParseCreateElementArgs) => {\n if (!(\n inlineElements.includes(nodeName) ||\n blockElements.includes(nodeName) ||\n specialElements.includes(nodeName)\n )) return\n\n const simple = ['audio', 'button', 'canvas', 'form', 'label', 'progress', 'textarea', 'video']\n const special = {\n a: ['navigator'],\n iframe: ['web-view'],\n img: ['image'],\n input: ['input', 'checkbox', 'radio']\n }\n const includes = componentConfig.includes\n\n if (simple.includes(nodeName) && !includes.has(nodeName)) {\n includes.add(nodeName)\n } else if (nodeName in special) {\n const maps = special[nodeName]\n maps.forEach(item => {\n !includes.has(item) && includes.add(item)\n })\n }\n })\n // 修改 H5 postcss options\n ctx.modifyRunnerOpts(({ opts }) => {\n if (!opts?.platform) return\n modifyPostcssConfigs(opts, options, opts.platform === 'h5')\n })\n}\n\nfunction injectRuntimePath (platform: TaroPlatformBase) {\n const injectedPath = '@tarojs/plugin-html/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 modifyPostcssConfigs (config: Record<string, any>, options: IOptions, isH5?: boolean) {\n config.postcss ||= {}\n const postcssConfig = config.postcss\n\n if (!isH5) {\n postcssConfig.htmltransform ||= {\n enable: true\n }\n }\n\n if (options.pxtransformBlackList) {\n postcssConfig.pxtransform ||= {\n enable: true\n }\n const pxtransformConfig = postcssConfig.pxtransform\n\n if (pxtransformConfig.enable) {\n pxtransformConfig.config ||= {}\n const config = pxtransformConfig.config\n config.selectorBlackList ||= []\n config.selectorBlackList = config.selectorBlackList.concat(options.pxtransformBlackList)\n }\n }\n}\n\nfunction patchMappingElements (ctx: IPluginContext, options: IOptions, inlineElements: string[], blockElements: string[]) {\n const helper = ctx.helper\n const filePath = path.resolve(__dirname, './runtime.js')\n const content = helper.fs.readFileSync(filePath).toString()\n const ast = parser.parse(content, { sourceType: 'unambiguous' })\n\n if (t.isNode(ast)) {\n options.modifyElements?.(inlineElements, blockElements)\n \n traverse(ast, {\n VariableDeclarator (path) {\n const node = path.node\n const varId = node.id\n if (varId.type === 'Identifier') {\n if (varId.name === 'inlineElements') {\n node.init = getNewExpression(inlineElements)\n }\n if (varId.name === 'blockElements') {\n node.init = getNewExpression(blockElements)\n }\n }\n }\n })\n \n const str = generator(ast).code\n helper.fs.writeFileSync(filePath, str)\n }\n}\n\nfunction getNewExpression (elements: string[]) {\n return t.newExpression(\n t.identifier('Set'),\n [t.arrayExpression(elements.map(el => t.stringLiteral(el)))]\n )\n}\n"],"names":["isArray","isString","path","parser","t","traverse","generator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,YAAe,CAAC,GAAmB,EAAE,OAAiB,KAAI;AACxD,IAAA,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,E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KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,IAAA,CAAA,OAAA,EAAG,cAAc,EAAE,aAAa,CAAC,CAAA;QAEvDC,yBAAQ,CAAC,GAAG,EAAE;AACZ,YAAA,kBAAkB,CAAE,IAAI,EAAA;AACtB,gBAAA,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;AACtB,gBAAA,MAAM,KAAK,GAAG,IAAI,CAAC,EAAE,CAAA;AACrB,gBAAA,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE;AAC/B,oBAAA,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,EAAE;AACnC,wBAAA,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC,cAAc,CAAC,CAAA;AAC7C,qBAAA;AACD,oBAAA,IAAI,KAAK,CAAC,IAAI,KAAK,eAAe,EAAE;AAClC,wBAAA,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAAA;AAC5C,qBAAA;AACF,iBAAA;aACF;AACF,SAAA,CAAC,CAAA;QAEF,MAAM,GAAG,GAAGC,0BAAS,CAAC,GAAG,CAAC,CAAC,IAAI,CAAA;QAC/B,MAAM,CAAC,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;AACvC,KAAA;AACH,CAAC;AAED,SAAS,gBAAgB,CAAE,QAAkB,EAAA;AAC3C,IAAA,OAAOF,YAAC,CAAC,aAAa,CACpBA,YAAC,CAAC,UAAU,CAAC,KAAK,CAAC,EACnB,CAACA,YAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,IAAIA,YAAC,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAC7D,CAAA;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import generator from '@babel/generator'\nimport * as parser from '@babel/parser'\nimport traverse from '@babel/traverse'\nimport * as t from '@babel/types'\nimport { isArray, isString } from '@tarojs/shared'\nimport * as path from 'path'\n\nimport type { IPluginContext, TaroPlatformBase } from '@tarojs/service'\n\ninterface IOptions {\n pxtransformBlackList?: any[]\n modifyElements?(inline: string[], block: string[]): void\n enableSizeAPIs?: boolean\n}\n\ninterface IComponentConfig {\n includes: Set<string>\n}\n\ninterface OnParseCreateElementArgs {\n nodeName: string\n componentConfig: IComponentConfig\n}\n\nexport default (ctx: IPluginContext, options: IOptions) => {\n const inlineElements = ['i', 'abbr', 'select', 'acronym', 'small', 'bdi', 'kbd', 'strong', 'big', 'sub', 'sup', 'br', 'mark', 'meter', 'template', 'cite', 'object', 'time', 'code', 'output', 'u', 'data', 'picture', 'tt', 'datalist', 'var', 'dfn', 'del', 'q', 'em', 's', 'embed', 'samp', 'b']\n const blockElements = ['body', 'svg', 'address', 'fieldset', 'li', 'span', 'article', 'figcaption', 'main', 'aside', 'figure', 'nav', 'blockquote', 'footer', 'ol', 'details', 'p', 'dialog', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre', 'dd', 'header', 'section', 'div', 'hgroup', 'table', 'dl', 'hr', 'ul', 'dt', 'view', 'view-block']\n const specialElements = ['slot', 'form', 'iframe', 'img', 'audio', 'video', 'canvas', 'a', 'input', 'label', 'textarea', 'progress', 'button']\n\n patchMappingElements(ctx, options, inlineElements, blockElements)\n\n // 默认允许使用 getBoundingClientRect 等 API\n ctx.modifyWebpackChain(({ chain }) => {\n chain\n .plugin('definePlugin')\n .tap(args => {\n args[0].ENABLE_SIZE_APIS = options.enableSizeAPIs ?? true\n return args\n })\n })\n ctx.registerMethod({\n name: 'onSetupClose',\n fn (platform: TaroPlatformBase) {\n injectRuntimePath(platform)\n }\n })\n // 映射、收集使用到的小程序组件\n ctx.onParseCreateElement(({ nodeName, componentConfig }: OnParseCreateElementArgs) => {\n if (!(\n inlineElements.includes(nodeName) ||\n blockElements.includes(nodeName) ||\n specialElements.includes(nodeName)\n )) return\n\n const simple = ['audio', 'button', 'canvas', 'form', 'label', 'progress', 'textarea', 'video']\n const special = {\n a: ['navigator'],\n iframe: ['web-view'],\n img: ['image'],\n input: ['input', 'checkbox', 'radio']\n }\n const includes = componentConfig.includes\n\n if (simple.includes(nodeName) && !includes.has(nodeName)) {\n includes.add(nodeName)\n } else if (nodeName in special) {\n const maps = special[nodeName]\n maps.forEach(item => {\n !includes.has(item) && includes.add(item)\n })\n }\n })\n // 修改 H5 postcss options\n ctx.modifyRunnerOpts(({ opts }) => {\n if (!opts?.platform) return\n modifyPostcssConfigs(opts, options, opts.platform === 'h5')\n })\n}\n\nfunction injectRuntimePath (platform: TaroPlatformBase) {\n const injectedPath = '@tarojs/plugin-html/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 modifyPostcssConfigs (config: Record<string, any>, options: IOptions, isH5?: boolean) {\n config.postcss ||= {}\n const postcssConfig = config.postcss\n\n if (!isH5) {\n postcssConfig.htmltransform ||= {\n enable: true\n }\n }\n\n if (options.pxtransformBlackList) {\n postcssConfig.pxtransform ||= {\n enable: true\n }\n const pxtransformConfig = postcssConfig.pxtransform\n\n if (pxtransformConfig.enable) {\n pxtransformConfig.config ||= {}\n const config = pxtransformConfig.config\n config.selectorBlackList ||= []\n config.selectorBlackList = config.selectorBlackList.concat(options.pxtransformBlackList)\n }\n }\n}\n\nfunction patchMappingElements (ctx: IPluginContext, options: IOptions, inlineElements: string[], blockElements: string[]) {\n const helper = ctx.helper\n const filePath = path.resolve(__dirname, './runtime.js')\n const content = helper.fs.readFileSync(filePath).toString()\n const ast = parser.parse(content, { sourceType: 'unambiguous' })\n\n if (t.isNode(ast)) {\n options.modifyElements?.(inlineElements, blockElements)\n\n traverse(ast, {\n VariableDeclarator (path) {\n const node = path.node\n const varId = node.id\n if (varId.type === 'Identifier') {\n if (varId.name === 'inlineElements') {\n node.init = getNewExpression(inlineElements)\n }\n if (varId.name === 'blockElements') {\n node.init = getNewExpression(blockElements)\n }\n }\n }\n })\n\n const str = generator(ast).code\n helper.fs.writeFileSync(filePath, str)\n }\n}\n\nfunction getNewExpression (elements: string[]) {\n return t.newExpression(\n t.identifier('Set'),\n [t.arrayExpression(elements.map(el => t.stringLiteral(el)))]\n )\n}\n"],"names":["isArray","isString","path","parser","t","traverse","generator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,YAAe,CAAC,GAAmB,EAAE,OAAiB,KAAI;AACxD,IAAA,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,CAAA;AACnS,IAAA,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,I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AAC,CAAA;QAEF,MAAM,GAAG,GAAGC,0BAAS,CAAC,GAAG,CAAC,CAAC,IAAI,CAAA;QAC/B,MAAM,CAAC,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;AACvC,KAAA;AACH,CAAC;AAED,SAAS,gBAAgB,CAAE,QAAkB,EAAA;AAC3C,IAAA,OAAOF,YAAC,CAAC,aAAa,CACpBA,YAAC,CAAC,UAAU,CAAC,KAAK,CAAC,EACnB,CAACA,YAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,IAAIA,YAAC,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAC7D,CAAA;AACH;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/plugin-html",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.1",
|
|
4
4
|
"description": "Taro 小程序端支持使用 HTML 标签的插件",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -23,15 +23,15 @@
|
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://github.com/NervJS/taro#readme",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@babel/parser": "^7.
|
|
27
|
-
"@tarojs/runtime": "3.6.
|
|
28
|
-
"@tarojs/
|
|
29
|
-
"@tarojs/
|
|
26
|
+
"@babel/parser": "^7.20.0",
|
|
27
|
+
"@tarojs/runtime": "3.6.1",
|
|
28
|
+
"@tarojs/shared": "3.6.1",
|
|
29
|
+
"@tarojs/service": "3.6.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@babel/generator": "^7.
|
|
33
|
-
"@babel/traverse": "^7.
|
|
34
|
-
"@babel/types": "^7.
|
|
32
|
+
"@babel/generator": "^7.20.0",
|
|
33
|
+
"@babel/traverse": "^7.20.0",
|
|
34
|
+
"@babel/types": "^7.20.0",
|
|
35
35
|
"rollup": "^3.8.1",
|
|
36
36
|
"rollup-plugin-node-externals": "^4.0.0",
|
|
37
37
|
"rollup-plugin-ts": "^3.0.2",
|
package/src/index.ts
CHANGED
|
@@ -119,7 +119,7 @@ function patchMappingElements (ctx: IPluginContext, options: IOptions, inlineEle
|
|
|
119
119
|
|
|
120
120
|
if (t.isNode(ast)) {
|
|
121
121
|
options.modifyElements?.(inlineElements, blockElements)
|
|
122
|
-
|
|
122
|
+
|
|
123
123
|
traverse(ast, {
|
|
124
124
|
VariableDeclarator (path) {
|
|
125
125
|
const node = path.node
|
|
@@ -134,7 +134,7 @@ function patchMappingElements (ctx: IPluginContext, options: IOptions, inlineEle
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
})
|
|
137
|
-
|
|
137
|
+
|
|
138
138
|
const str = generator(ast).code
|
|
139
139
|
helper.fs.writeFileSync(filePath, str)
|
|
140
140
|
}
|