@mpxjs/webpack-plugin 2.8.28-beta.5 → 2.8.28-beta.8

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/lib/index.js CHANGED
@@ -112,7 +112,6 @@ class MpxWebpackPlugin {
112
112
  constructor (options = {}) {
113
113
  options.mode = options.mode || 'wx'
114
114
  options.env = options.env || ''
115
-
116
115
  options.srcMode = options.srcMode || options.mode
117
116
  if (options.mode !== options.srcMode && options.srcMode !== 'wx') {
118
117
  errors.push('MpxWebpackPlugin supports srcMode to be "wx" only temporarily!')
@@ -1085,6 +1084,49 @@ class MpxWebpackPlugin {
1085
1084
  }
1086
1085
  })
1087
1086
 
1087
+ parser.hooks.evaluate.for('NewExpression').tap('MpxWebpackPlugin', (expression) => {
1088
+ if (/@intlify\/core-base/.test(parser.state.module.resource)) {
1089
+ if (expression.callee.name === 'Function') {
1090
+ const current = parser.state.current
1091
+ current.addPresentationalDependency(new InjectDependency({
1092
+ content: '_mpxCodeTransForm(',
1093
+ index: expression.arguments[0].start
1094
+ }))
1095
+ current.addPresentationalDependency(new InjectDependency({
1096
+ content: ')',
1097
+ index: expression.arguments[0].end
1098
+ }))
1099
+ }
1100
+ }
1101
+ })
1102
+
1103
+ parser.hooks.program.tap('MpxWebpackPlugin', ast => {
1104
+ if (/@intlify\/core-base/.test(parser.state.module.resource)) {
1105
+ const current = parser.state.current
1106
+ current.addPresentationalDependency(new InjectDependency({
1107
+ content: 'function _mpxCodeTransForm (code) {\n' +
1108
+ ' code = code.replace(/const { (.*?) } = ctx/g, function (match, $1) {\n' +
1109
+ ' var arr = $1.split(", ")\n' +
1110
+ ' var str = ""\n' +
1111
+ ' var pattern = /(.*):(.*)/\n' +
1112
+ ' for (var i = 0; i < arr.length; i++) {\n' +
1113
+ ' var result = arr[i].match(pattern)\n' +
1114
+ ' var left = result[1]\n' +
1115
+ ' var right = result[2]\n' +
1116
+ ' str += "var" + right + " = ctx." + left\n' +
1117
+ ' }\n' +
1118
+ ' return str\n' +
1119
+ ' })\n' +
1120
+ ' code = code.replace(/\\(ctx\\) =>/g, function (match, $1) {\n' +
1121
+ ' return "function (ctx)"\n' +
1122
+ ' })\n' +
1123
+ ' return code\n' +
1124
+ '}',
1125
+ index: ast.end
1126
+ }))
1127
+ }
1128
+ })
1129
+
1088
1130
  // 处理跨平台转换
1089
1131
  if (mpx.srcMode !== mpx.mode) {
1090
1132
  // 处理跨平台全局对象转换
package/lib/parser.js CHANGED
@@ -2,7 +2,6 @@ const cache = require('lru-cache')(100)
2
2
  const hash = require('hash-sum')
3
3
  const compiler = require('./template-compiler/compiler')
4
4
  const SourceMapGenerator = require('source-map').SourceMapGenerator
5
-
6
5
  const splitRE = /\r?\n/g
7
6
  const emptyRE = /^(?:\/\/)?\s*$/
8
7
 
@@ -152,7 +152,8 @@ module.exports = function getSpec ({ warn, error }) {
152
152
  ali: addGlobalComponents,
153
153
  swan: addGlobalComponents,
154
154
  qq: addGlobalComponents,
155
- tt: addGlobalComponents
155
+ tt: addGlobalComponents,
156
+ jd: addGlobalComponents
156
157
  }
157
158
  ],
158
159
  tabBar: {
@@ -2,13 +2,13 @@
2
2
  <video
3
3
  ref="_mpx_video_ref"
4
4
  :class="classList"
5
- webkit-playsinline="true" playsinline="true" x5-playsinline="true"
6
5
  :src="src"
7
6
  :controls="showControlsTool"
8
7
  :autoplay="autoplay"
9
8
  :loop="loop"
10
9
  :muted="mutedCopy"
11
10
  :poster="poster"
11
+ v-bind="playsinlineAttr"
12
12
  >
13
13
  </video>
14
14
  </template>
@@ -123,6 +123,20 @@
123
123
  showScreenLockButton: {
124
124
  type: Boolean,
125
125
  default: false
126
+ },
127
+ playsinline: {
128
+ type: Boolean,
129
+ default: true
130
+ }
131
+ },
132
+ computed: {
133
+ playsinlineAttr () {
134
+ if (!this.playsinline) return {}
135
+ return {
136
+ 'webkit-playsinline': true,
137
+ 'playsinline': true,
138
+ 'x5-playsinline': true
139
+ }
126
140
  }
127
141
  },
128
142
  data () {
@@ -122,7 +122,9 @@ function compile (tokens, values) {
122
122
  }
123
123
 
124
124
  function interpolate (message, values) {
125
- values = values || {}
125
+ if (!values) {
126
+ return [message]
127
+ }
126
128
  var tokens = _tokenCaches[message]
127
129
  if (!tokens) {
128
130
  tokens = parseMessage(message)
@@ -12,12 +12,11 @@ const tsLoaderWatchRunFilterLoaders = new Set([
12
12
  ])
13
13
 
14
14
  module.exports = (loaders, loaderIndex) => {
15
- for (let len = loaders.length; len > 0; --len) {
16
- const currentLoader = loaders[len - 1]
15
+ for (let i = loaderIndex; i >= 0; i--) {
16
+ const currentLoader = loaders[i]
17
17
  if (!has(tsLoaderWatchRunFilterLoaders, filterLoaderPath => currentLoader.path.endsWith(filterLoaderPath))) {
18
- break
18
+ return i
19
19
  }
20
- loaderIndex--
21
20
  }
22
21
  return loaderIndex
23
22
  }
@@ -6,8 +6,10 @@ const createHelpers = require('../helpers')
6
6
  const isUrlRequest = require('../utils/is-url-request')
7
7
  const parseRequest = require('../utils/parse-request')
8
8
 
9
- function randomIdent () {
10
- return 'xxxHTMLLINKxxx' + Math.random() + Math.random() + 'xxx'
9
+ let count = 0
10
+
11
+ function countIdent () {
12
+ return `__HTMLLINK__${count++}__`
11
13
  }
12
14
 
13
15
  module.exports = function (content) {
@@ -57,7 +59,7 @@ module.exports = function (content) {
57
59
 
58
60
  let ident
59
61
  do {
60
- ident = randomIdent()
62
+ ident = countIdent()
61
63
  } while (data[ident])
62
64
  data[ident] = link
63
65
  const x = content.pop()
@@ -71,7 +73,7 @@ module.exports = function (content) {
71
73
 
72
74
  const exportsString = 'module.exports = '
73
75
 
74
- return exportsString + content.replace(/xxxHTMLLINKxxx[0-9.]+xxx/g, (match) => {
76
+ return exportsString + content.replace(/__HTMLLINK__\d+__/g, (match) => {
75
77
  if (!data[match]) return match
76
78
 
77
79
  const link = data[match]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.8.28-beta.5",
3
+ "version": "2.8.28-beta.8",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"
@@ -82,5 +82,5 @@
82
82
  "engines": {
83
83
  "node": ">=14.14.0"
84
84
  },
85
- "gitHead": "f415e2d6a1c14b51b2cee6eb654205608f217401"
85
+ "gitHead": "d220fb8a2e9c090de490a125891262f61802f73d"
86
86
  }