@mpxjs/webpack-plugin 2.9.0-beta.1 → 2.9.0-beta.3
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/dependencies/CommonJsExtractDependency.js +51 -0
- package/lib/extractor.js +1 -0
- package/lib/helpers.js +9 -1
- package/lib/index.js +103 -21
- package/lib/json-compiler/helper.js +20 -7
- package/lib/json-compiler/index.js +48 -19
- package/lib/loader.js +1 -1
- package/lib/native-loader.js +18 -6
- package/lib/platform/json/wx/index.js +44 -2
- package/lib/platform/run-rules.js +2 -1
- package/lib/platform/template/normalize-component-rules.js +2 -0
- package/lib/platform/template/wx/component-config/fix-html-tag.js +17 -0
- package/lib/platform/template/wx/component-config/index.js +2 -0
- package/lib/platform/template/wx/index.js +45 -14
- package/lib/runtime/base.styl +9 -6
- package/lib/runtime/components/web/filterTag.js +9 -30
- package/lib/runtime/components/web/getInnerListeners.js +2 -14
- package/lib/runtime/components/web/mpx-keep-alive.vue +8 -17
- package/lib/runtime/components/web/mpx-movable-view.vue +28 -9
- package/lib/runtime/components/web/mpx-picker-view.vue +1 -1
- package/lib/runtime/components/web/mpx-scroll-view.vue +21 -10
- package/lib/runtime/components/web/mpx-video.vue +123 -89
- package/lib/runtime/components/web/mpx-web-view.vue +119 -81
- package/lib/runtime/components/wx/default-page.mpx +27 -0
- package/lib/runtime/optionProcessor.js +27 -20
- package/lib/style-compiler/index.js +5 -1
- package/lib/template-compiler/bind-this.js +248 -48
- package/lib/template-compiler/compiler.js +69 -109
- package/lib/template-compiler/index.js +16 -1
- package/lib/utils/dom-tag-config.js +101 -0
- package/lib/utils/make-map.js +12 -0
- package/lib/utils/string.js +7 -1
- package/lib/utils/ts-loader-watch-run-loader-filter.js +1 -1
- package/lib/web/processJSON.js +35 -0
- package/lib/web/processMainScript.js +1 -1
- package/lib/web/processTemplate.js +18 -35
- package/lib/web/script-helper.js +5 -2
- package/package.json +4 -4
- package/lib/json-compiler/default-page.mpx +0 -3
- package/lib/template-compiler/preprocessor.js +0 -29
- package/lib/wxss/compile-exports.js +0 -52
- package/lib/wxss/createResolver.js +0 -36
- package/lib/wxss/css-base.js +0 -79
- package/lib/wxss/getLocalIdent.js +0 -25
- package/lib/wxss/localsLoader.js +0 -44
- package/lib/wxss/processCss.js +0 -274
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// These tag configs are shared between compiler-dom and runtime-dom, so they
|
|
2
|
+
// must be extracted in shared to avoid creating a dependency between the two.
|
|
3
|
+
const makeMap = require('./make-map')
|
|
4
|
+
|
|
5
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element
|
|
6
|
+
const HTML_TAGS =
|
|
7
|
+
'html,body,base,head,link,meta,style,title,address,article,aside,footer,' +
|
|
8
|
+
'header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,' +
|
|
9
|
+
'figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,' +
|
|
10
|
+
'data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,' +
|
|
11
|
+
'time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,' +
|
|
12
|
+
'canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,' +
|
|
13
|
+
'th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,' +
|
|
14
|
+
'option,output,progress,select,textarea,details,dialog,menu,' +
|
|
15
|
+
'summary,template,blockquote,iframe,tfoot'
|
|
16
|
+
|
|
17
|
+
// https://developer.mozilla.org/en-US/docs/Web/SVG/Element
|
|
18
|
+
const SVG_TAGS =
|
|
19
|
+
'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,' +
|
|
20
|
+
'defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,' +
|
|
21
|
+
'feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,' +
|
|
22
|
+
'feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,' +
|
|
23
|
+
'feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,' +
|
|
24
|
+
'fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,' +
|
|
25
|
+
'foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,' +
|
|
26
|
+
'mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,' +
|
|
27
|
+
'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' +
|
|
28
|
+
'text,textPath,title,tspan,unknown,use,view'
|
|
29
|
+
|
|
30
|
+
const VOID_TAGS =
|
|
31
|
+
'area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr'
|
|
32
|
+
|
|
33
|
+
// HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
|
|
34
|
+
// Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
|
|
35
|
+
const isNonPhrasingTag = makeMap(
|
|
36
|
+
'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
|
|
37
|
+
'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
|
|
38
|
+
'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
|
|
39
|
+
'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
|
|
40
|
+
'title,tr,track'
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
const isRichTextTag = makeMap(
|
|
44
|
+
'a,abbr,address,article,aside,b,bdi,bdo,big,blockquote,br,caption,' +
|
|
45
|
+
'center,cite,code,col,colgroup,dd,del,div,dl,dt,em,fieldset,' +
|
|
46
|
+
'font,footer,h1,h2,h3,h4,h5,h6,header,hr,i,img,ins,label,legend,' +
|
|
47
|
+
'li,mark,nav,ol,p,pre,q,rt,ruby,s,section,small,span,strong,sub,sup,' +
|
|
48
|
+
'table,tbody,td,tfoot,th,thead,tr,tt,u,ul'
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
const isUnaryTag = makeMap(
|
|
52
|
+
'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
|
|
53
|
+
'link,meta,param,source,track,wbr'
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
// https://developers.weixin.qq.com/miniprogram/dev/component/
|
|
57
|
+
// 以后可能在框架中原生支持这些标签,所以需要进行判断
|
|
58
|
+
const isNativeMiniTag = makeMap(
|
|
59
|
+
'cover-image,cover-view,match-media,movable-area,movable-view,' +
|
|
60
|
+
'page-container,root-portal,scroll-view,swiper,swiper-item,view,' +
|
|
61
|
+
'icon,progress,rich-text,text,button,checkbox,checkbox-group,editor,' +
|
|
62
|
+
'form,input,keyboard-accessory,label,picker,picker-view,' +
|
|
63
|
+
'picker-view-column,radio,radio-group,slider,switch,textarea,' +
|
|
64
|
+
'grid-view,list-view,share-element,snapshot,span,sticky-header,' +
|
|
65
|
+
'sticky-section,functional-page-navigator,navigator,audio,camera,' +
|
|
66
|
+
'channel-live,channel-video,image,live-player,live-pusher,video,' +
|
|
67
|
+
'voip-room,map,canvas,web-view,ad,ad-custom,official-account,' +
|
|
68
|
+
'open-data,native-component,aria-component,page-meta'
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
const isSpace = makeMap('ensp,emsp,nbsp')
|
|
72
|
+
|
|
73
|
+
const isContWidth = makeMap('col,colgroup,img,table,td,th,tr')
|
|
74
|
+
|
|
75
|
+
const isContHeight = makeMap('img,td,th,tr')
|
|
76
|
+
|
|
77
|
+
const isContConRow = makeMap('td,th,tr')
|
|
78
|
+
|
|
79
|
+
const isHTMLTag = makeMap(HTML_TAGS)
|
|
80
|
+
|
|
81
|
+
const isSVGTag = makeMap(SVG_TAGS)
|
|
82
|
+
|
|
83
|
+
const isVoidTag = makeMap(VOID_TAGS)
|
|
84
|
+
|
|
85
|
+
// 是否为原始tag,包括 html tag 和小程序原生 tag
|
|
86
|
+
const isOriginTag = (tag) => isHTMLTag(tag) || isSVGTag(tag) || isVoidTag(tag) || isNativeMiniTag(tag)
|
|
87
|
+
|
|
88
|
+
module.exports = {
|
|
89
|
+
isOriginTag,
|
|
90
|
+
isHTMLTag,
|
|
91
|
+
isSVGTag,
|
|
92
|
+
isVoidTag,
|
|
93
|
+
isNonPhrasingTag,
|
|
94
|
+
isRichTextTag,
|
|
95
|
+
isUnaryTag,
|
|
96
|
+
isSpace,
|
|
97
|
+
isContWidth,
|
|
98
|
+
isContHeight,
|
|
99
|
+
isNativeMiniTag,
|
|
100
|
+
isContConRow
|
|
101
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Make a map and return a function for checking if a key
|
|
3
|
+
* is in that map.
|
|
4
|
+
*/
|
|
5
|
+
module.exports = function makeMap (str, expectsLowerCase) {
|
|
6
|
+
const map = Object.create(null)
|
|
7
|
+
const list = str.split(',')
|
|
8
|
+
for (let i = 0; i < list.length; i++) {
|
|
9
|
+
map[list[i]] = true
|
|
10
|
+
}
|
|
11
|
+
return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val]
|
|
12
|
+
}
|
package/lib/utils/string.js
CHANGED
|
@@ -23,8 +23,14 @@ function capitalToHyphen (v) {
|
|
|
23
23
|
return ret
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
// 删除空行
|
|
27
|
+
function trimBlankRow (str) {
|
|
28
|
+
return str.replace(/^\s*[\r\n]/gm, '')
|
|
29
|
+
}
|
|
30
|
+
|
|
26
31
|
module.exports = {
|
|
27
32
|
isCapital,
|
|
28
33
|
isMustache,
|
|
29
|
-
capitalToHyphen
|
|
34
|
+
capitalToHyphen,
|
|
35
|
+
trimBlankRow
|
|
30
36
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module.exports = (loaders, loaderIndex) => {
|
|
2
2
|
for (let i = loaderIndex; i >= 0; i--) {
|
|
3
3
|
const currentLoader = loaders[i]
|
|
4
|
-
if (currentLoader.path.endsWith('ts-loader/dist/stringify-loader.js')) {
|
|
4
|
+
if (currentLoader.path.endsWith('node_modules/ts-loader/dist/stringify-loader.js')) {
|
|
5
5
|
return i
|
|
6
6
|
}
|
|
7
7
|
}
|
package/lib/web/processJSON.js
CHANGED
|
@@ -9,8 +9,10 @@ const parseComponent = require('../parser')
|
|
|
9
9
|
const getJSONContent = require('../utils/get-json-content')
|
|
10
10
|
const resolve = require('../utils/resolve')
|
|
11
11
|
const createJSONHelper = require('../json-compiler/helper')
|
|
12
|
+
const getRulesRunner = require('../platform/index')
|
|
12
13
|
const { RESOLVE_IGNORED_ERR } = require('../utils/const')
|
|
13
14
|
const RecordResourceMapDependency = require('../dependencies/RecordResourceMapDependency')
|
|
15
|
+
const RecordGlobalComponentsDependency = require('../dependencies/RecordGlobalComponentsDependency')
|
|
14
16
|
|
|
15
17
|
module.exports = function (json, {
|
|
16
18
|
loaderContext,
|
|
@@ -26,6 +28,7 @@ module.exports = function (json, {
|
|
|
26
28
|
const mpx = loaderContext.getMpx()
|
|
27
29
|
const {
|
|
28
30
|
mode,
|
|
31
|
+
srcMode,
|
|
29
32
|
env,
|
|
30
33
|
projectRoot
|
|
31
34
|
} = mpx
|
|
@@ -75,12 +78,44 @@ module.exports = function (json, {
|
|
|
75
78
|
})
|
|
76
79
|
}
|
|
77
80
|
|
|
81
|
+
const { resourcePath } = parseRequest(loaderContext.resource)
|
|
82
|
+
const isApp = !(pagesMap[resourcePath] || componentsMap[resourcePath])
|
|
83
|
+
|
|
78
84
|
if (!json) {
|
|
79
85
|
return callback()
|
|
80
86
|
}
|
|
81
87
|
// 由于json需要提前读取在template处理中使用,src的场景已经在loader中处理了,此处无需考虑json.src的场景
|
|
82
88
|
try {
|
|
83
89
|
jsonObj = JSON5.parse(json.content)
|
|
90
|
+
// 处理runner
|
|
91
|
+
const rulesRunnerOptions = {
|
|
92
|
+
mode,
|
|
93
|
+
srcMode,
|
|
94
|
+
type: 'json',
|
|
95
|
+
waterfall: true,
|
|
96
|
+
warn: emitWarning,
|
|
97
|
+
error: emitError,
|
|
98
|
+
data: {
|
|
99
|
+
// polyfill global usingComponents & record globalComponents
|
|
100
|
+
globalComponents: mpx.usingComponents
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (!isApp) {
|
|
105
|
+
rulesRunnerOptions.mainKey = pagesMap[resourcePath] ? 'page' : 'component'
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const rulesRunner = getRulesRunner(rulesRunnerOptions)
|
|
109
|
+
|
|
110
|
+
if (rulesRunner) {
|
|
111
|
+
rulesRunner(jsonObj)
|
|
112
|
+
}
|
|
113
|
+
if (isApp) {
|
|
114
|
+
// 收集全局组件
|
|
115
|
+
Object.assign(mpx.usingComponents, jsonObj.usingComponents)
|
|
116
|
+
// 在 rulesRunner 运行后保存全局注册组件
|
|
117
|
+
loaderContext._module.addPresentationalDependency(new RecordGlobalComponentsDependency(mpx.usingComponents, loaderContext.context))
|
|
118
|
+
}
|
|
84
119
|
} catch (e) {
|
|
85
120
|
return callback(e)
|
|
86
121
|
}
|
|
@@ -19,7 +19,7 @@ module.exports = function (script, {
|
|
|
19
19
|
}, callback) {
|
|
20
20
|
const { i18n, webConfig } = loaderContext.getMpx()
|
|
21
21
|
|
|
22
|
-
const { pagesMap, firstPage, globalTabBar } = buildPagesMap({ localPagesMap, loaderContext, tabBar, tabBarMap, tabBarStr })
|
|
22
|
+
const { pagesMap, firstPage, globalTabBar } = buildPagesMap({ localPagesMap, loaderContext, tabBar, tabBarMap, tabBarStr, jsonConfig })
|
|
23
23
|
|
|
24
24
|
const componentsMap = buildComponentsMap({ localComponentsMap, loaderContext })
|
|
25
25
|
|
|
@@ -2,23 +2,7 @@ const templateCompiler = require('../template-compiler/compiler')
|
|
|
2
2
|
const genComponentTag = require('../utils/gen-component-tag')
|
|
3
3
|
const addQuery = require('../utils/add-query')
|
|
4
4
|
const parseRequest = require('../utils/parse-request')
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function calculateRootEleChild (arr) {
|
|
8
|
-
if (!arr) {
|
|
9
|
-
return 0
|
|
10
|
-
}
|
|
11
|
-
return arr.reduce((total, item) => {
|
|
12
|
-
if (item.type === 1) {
|
|
13
|
-
if (item.tag === 'template') {
|
|
14
|
-
total += calculateRootEleChild(item.children)
|
|
15
|
-
} else {
|
|
16
|
-
total += 1
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return total
|
|
20
|
-
}, 0)
|
|
21
|
-
}
|
|
5
|
+
const { matchCondition } = require('../utils/match-condition')
|
|
22
6
|
|
|
23
7
|
module.exports = function (template, {
|
|
24
8
|
loaderContext,
|
|
@@ -39,8 +23,9 @@ module.exports = function (template, {
|
|
|
39
23
|
decodeHTMLText,
|
|
40
24
|
externalClasses,
|
|
41
25
|
checkUsingComponents,
|
|
42
|
-
webConfig
|
|
43
|
-
|
|
26
|
+
webConfig,
|
|
27
|
+
proxyComponentEventsRules,
|
|
28
|
+
autoVirtualHostRules
|
|
44
29
|
} = mpx
|
|
45
30
|
const { resourcePath } = parseRequest(loaderContext.resource)
|
|
46
31
|
const builtInComponentsMap = {}
|
|
@@ -53,7 +38,7 @@ module.exports = function (template, {
|
|
|
53
38
|
const idName = el?.match(/#(.*)/)?.[1] || 'app'
|
|
54
39
|
template = {
|
|
55
40
|
tag: 'template',
|
|
56
|
-
content: `<div id="${idName}"
|
|
41
|
+
content: `<div id="${idName}"><mpx-keep-alive><router-view></router-view></mpx-keep-alive></div>`
|
|
57
42
|
}
|
|
58
43
|
builtInComponentsMap['mpx-keep-alive'] = {
|
|
59
44
|
resource: addQuery('@mpxjs/webpack-plugin/lib/runtime/components/web/mpx-keep-alive.vue', { isComponent: true })
|
|
@@ -75,6 +60,16 @@ module.exports = function (template, {
|
|
|
75
60
|
}
|
|
76
61
|
if (template.content) {
|
|
77
62
|
const templateSrcMode = template.mode || srcMode
|
|
63
|
+
|
|
64
|
+
let proxyComponentEvents = null
|
|
65
|
+
for (const item of proxyComponentEventsRules) {
|
|
66
|
+
if (matchCondition(resourcePath, item)) {
|
|
67
|
+
const eventsRaw = item.events
|
|
68
|
+
proxyComponentEvents = Array.isArray(eventsRaw) ? eventsRaw : [eventsRaw]
|
|
69
|
+
break
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
78
73
|
const { root, meta } = templateCompiler.parse(template.content, {
|
|
79
74
|
warn: (msg) => {
|
|
80
75
|
loaderContext.emitWarning(
|
|
@@ -104,9 +99,9 @@ module.exports = function (template, {
|
|
|
104
99
|
// web模式下全局组件不会被合入usingComponents中,故globalComponents可以传空
|
|
105
100
|
globalComponents: [],
|
|
106
101
|
// web模式下实现抽象组件
|
|
107
|
-
componentGenerics
|
|
108
|
-
|
|
109
|
-
|
|
102
|
+
componentGenerics,
|
|
103
|
+
proxyComponentEvents,
|
|
104
|
+
hasVirtualHost: matchCondition(resourcePath, autoVirtualHostRules)
|
|
110
105
|
})
|
|
111
106
|
if (meta.wxsModuleMap) {
|
|
112
107
|
wxsModuleMap = meta.wxsModuleMap
|
|
@@ -126,18 +121,6 @@ module.exports = function (template, {
|
|
|
126
121
|
if (meta.genericsInfo) {
|
|
127
122
|
genericsInfo = meta.genericsInfo
|
|
128
123
|
}
|
|
129
|
-
// 输出H5有多个root element时, 使用mpx-root-view标签包裹
|
|
130
|
-
// todo 后续输出web也基于autoVirtualHostRules决定是否添加root wrapper
|
|
131
|
-
if (root.tag === 'temp-node') {
|
|
132
|
-
const childLen = calculateRootEleChild(root.children)
|
|
133
|
-
if (childLen >= 2) {
|
|
134
|
-
root.tag = 'div'
|
|
135
|
-
templateCompiler.addAttrs(root, [{
|
|
136
|
-
name: 'class',
|
|
137
|
-
value: 'mpx-root-view'
|
|
138
|
-
}])
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
124
|
return templateCompiler.serialize(root)
|
|
142
125
|
}
|
|
143
126
|
})
|
package/lib/web/script-helper.js
CHANGED
|
@@ -54,7 +54,7 @@ function buildComponentsMap ({ localComponentsMap, builtInComponentsMap, loaderC
|
|
|
54
54
|
return componentsMap
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
function buildPagesMap ({ localPagesMap, loaderContext, tabBar, tabBarMap, tabBarStr }) {
|
|
57
|
+
function buildPagesMap ({ localPagesMap, loaderContext, tabBar, tabBarMap, tabBarStr, jsonConfig }) {
|
|
58
58
|
let globalTabBar = ''
|
|
59
59
|
let firstPage = ''
|
|
60
60
|
const pagesMap = {}
|
|
@@ -100,7 +100,10 @@ function buildPagesMap ({ localPagesMap, loaderContext, tabBar, tabBarMap, tabBa
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
if (
|
|
103
|
+
if (pagePath === jsonConfig.entryPagePath) {
|
|
104
|
+
firstPage = pagePath
|
|
105
|
+
}
|
|
106
|
+
if (!firstPage && pageCfg.isFirst) {
|
|
104
107
|
firstPage = pagePath
|
|
105
108
|
}
|
|
106
109
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.9.0-beta.
|
|
3
|
+
"version": "2.9.0-beta.3",
|
|
4
4
|
"description": "mpx compile core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mpx"
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
"@better-scroll/zoom": "^2.5.1",
|
|
30
30
|
"acorn-walk": "^7.2.0",
|
|
31
31
|
"async": "^2.6.0",
|
|
32
|
-
"consolidate": "^0.15.1",
|
|
33
32
|
"css": "^2.2.1",
|
|
34
33
|
"css-selector-tokenizer": "^0.7.0",
|
|
35
34
|
"cssnano": "^5.0.16",
|
|
@@ -55,7 +54,8 @@
|
|
|
55
54
|
"postcss-modules-values": "^4.0.0",
|
|
56
55
|
"postcss-selector-parser": "^6.0.8",
|
|
57
56
|
"postcss-value-parser": "^4.0.2",
|
|
58
|
-
"source-list-map": "^2.0.0"
|
|
57
|
+
"source-list-map": "^2.0.0",
|
|
58
|
+
"video.js": "^8.6.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"webpack": "^5.48.0"
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"engines": {
|
|
83
83
|
"node": ">=14.14.0"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "521f0cec1231962f9c071c8b70499772a0a81fda"
|
|
86
86
|
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// loader for pre-processing templates with e.g. pug
|
|
2
|
-
|
|
3
|
-
const cons = require('consolidate')
|
|
4
|
-
const loaderUtils = require('loader-utils')
|
|
5
|
-
|
|
6
|
-
module.exports = function (content) {
|
|
7
|
-
this.cacheable && this.cacheable()
|
|
8
|
-
const callback = this.async()
|
|
9
|
-
const opt = loaderUtils.getOptions(this) || {}
|
|
10
|
-
|
|
11
|
-
if (!cons[opt.engine]) {
|
|
12
|
-
return callback(new Error(
|
|
13
|
-
'Template engine \'' + opt.engine + '\' ' +
|
|
14
|
-
'isn\'t available in Consolidate.js'
|
|
15
|
-
))
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const templateOption = opt.templateOption
|
|
19
|
-
|
|
20
|
-
// for relative includes
|
|
21
|
-
templateOption.filename = this.resourcePath
|
|
22
|
-
|
|
23
|
-
cons[opt.engine].render(content, templateOption, function (err, html) {
|
|
24
|
-
if (err) {
|
|
25
|
-
return callback(err)
|
|
26
|
-
}
|
|
27
|
-
callback(null, html)
|
|
28
|
-
})
|
|
29
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
const camelCase = require('lodash.camelcase')
|
|
2
|
-
|
|
3
|
-
function dashesCamelCase (str) {
|
|
4
|
-
return str.replace(/-+(\w)/g, function (match, firstLetter) {
|
|
5
|
-
return firstLetter.toUpperCase()
|
|
6
|
-
})
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
module.exports = function compileExports (result, importItemMatcher, camelCaseKeys) {
|
|
10
|
-
if (!Object.keys(result.exports).length) {
|
|
11
|
-
return ''
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const exportJs = Object.keys(result.exports).reduce(function (res, key) {
|
|
15
|
-
let valueAsString = JSON.stringify(result.exports[key])
|
|
16
|
-
valueAsString = valueAsString.replace(result.importItemRegExpG, importItemMatcher)
|
|
17
|
-
|
|
18
|
-
function addEntry (k) {
|
|
19
|
-
res.push('\t' + JSON.stringify(k) + ': ' + valueAsString)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
let targetKey
|
|
23
|
-
switch (camelCaseKeys) {
|
|
24
|
-
case true:
|
|
25
|
-
addEntry(key)
|
|
26
|
-
targetKey = camelCase(key)
|
|
27
|
-
if (targetKey !== key) {
|
|
28
|
-
addEntry(targetKey)
|
|
29
|
-
}
|
|
30
|
-
break
|
|
31
|
-
case 'dashes':
|
|
32
|
-
addEntry(key)
|
|
33
|
-
targetKey = dashesCamelCase(key)
|
|
34
|
-
if (targetKey !== key) {
|
|
35
|
-
addEntry(targetKey)
|
|
36
|
-
}
|
|
37
|
-
break
|
|
38
|
-
case 'only':
|
|
39
|
-
addEntry(camelCase(key))
|
|
40
|
-
break
|
|
41
|
-
case 'dashesOnly':
|
|
42
|
-
addEntry(dashesCamelCase(key))
|
|
43
|
-
break
|
|
44
|
-
default:
|
|
45
|
-
addEntry(key)
|
|
46
|
-
break
|
|
47
|
-
}
|
|
48
|
-
return res
|
|
49
|
-
}, []).join(',\n')
|
|
50
|
-
|
|
51
|
-
return '{\n' + exportJs + '\n}'
|
|
52
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
module.exports = function createResolver (alias) {
|
|
2
|
-
if (typeof alias !== 'object' || Array.isArray(alias)) {
|
|
3
|
-
return function (url) {
|
|
4
|
-
return url
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
alias = Object.keys(alias).map(function (key) {
|
|
9
|
-
let onlyModule = false
|
|
10
|
-
let obj = alias[key]
|
|
11
|
-
if (/\$$/.test(key)) {
|
|
12
|
-
onlyModule = true
|
|
13
|
-
key = key.substr(0, key.length - 1)
|
|
14
|
-
}
|
|
15
|
-
if (typeof obj === 'string') {
|
|
16
|
-
obj = {
|
|
17
|
-
alias: obj
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
obj = Object.assign({
|
|
21
|
-
name: key,
|
|
22
|
-
onlyModule: onlyModule
|
|
23
|
-
}, obj)
|
|
24
|
-
return obj
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
return function (url) {
|
|
28
|
-
alias.forEach(function (obj) {
|
|
29
|
-
const name = obj.name
|
|
30
|
-
if (url === name || (!obj.onlyModule && url.startsWith(name + '/'))) {
|
|
31
|
-
url = obj.alias + url.substr(name.length)
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
return url
|
|
35
|
-
}
|
|
36
|
-
}
|
package/lib/wxss/css-base.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
-
Author Tobias Koppers @sokra
|
|
4
|
-
Modified by @hiyuki
|
|
5
|
-
*/
|
|
6
|
-
// css base code, injected by the css-loader
|
|
7
|
-
module.exports = function (useSourceMap) {
|
|
8
|
-
const list = []
|
|
9
|
-
|
|
10
|
-
// return the list of modules as css string
|
|
11
|
-
list.toString = function toString () {
|
|
12
|
-
return this.map(function (item) {
|
|
13
|
-
const content = cssWithMappingToString(item, useSourceMap)
|
|
14
|
-
if (item[2]) {
|
|
15
|
-
return '@media ' + item[2] + '{' + content + '}'
|
|
16
|
-
} else {
|
|
17
|
-
return content
|
|
18
|
-
}
|
|
19
|
-
}).join('')
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// import a list of modules into the list
|
|
23
|
-
list.i = function (modules, mediaQuery) {
|
|
24
|
-
if (typeof modules === 'string') {
|
|
25
|
-
modules = [[null, modules, '']]
|
|
26
|
-
}
|
|
27
|
-
const alreadyImportedModules = {}
|
|
28
|
-
for (let i = 0; i < this.length; i++) {
|
|
29
|
-
const id = this[i][0]
|
|
30
|
-
if (typeof id === 'number') {
|
|
31
|
-
alreadyImportedModules[id] = true
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
for (let i = 0; i < modules.length; i++) {
|
|
35
|
-
const item = modules[i]
|
|
36
|
-
// skip already imported module
|
|
37
|
-
// this implementation is not 100% perfect for weird media query combinations
|
|
38
|
-
// when a module is imported multiple times with different media queries.
|
|
39
|
-
// I hope this will never occur (Hey this way we have smaller bundles)
|
|
40
|
-
if (typeof item[0] !== 'number' || !alreadyImportedModules[item[0]]) {
|
|
41
|
-
if (mediaQuery && !item[2]) {
|
|
42
|
-
item[2] = mediaQuery
|
|
43
|
-
} else if (mediaQuery) {
|
|
44
|
-
item[2] = '(' + item[2] + ') and (' + mediaQuery + ')'
|
|
45
|
-
}
|
|
46
|
-
list.push(item)
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return list
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function cssWithMappingToString (item, useSourceMap) {
|
|
54
|
-
const content = item[1] || ''
|
|
55
|
-
const cssMapping = item[3]
|
|
56
|
-
if (!cssMapping) {
|
|
57
|
-
return content
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (useSourceMap && typeof btoa === 'function') {
|
|
61
|
-
const sourceMapping = toComment(cssMapping)
|
|
62
|
-
const sourceURLs = cssMapping.sources.map(function (source) {
|
|
63
|
-
return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
return [content].concat(sourceURLs).concat([sourceMapping]).join('\n')
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return [content].join('\n')
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Adapted from convert-source-map (MIT)
|
|
73
|
-
function toComment (sourceMap) {
|
|
74
|
-
// eslint-disable-next-line no-undef
|
|
75
|
-
const base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))))
|
|
76
|
-
const data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64
|
|
77
|
-
|
|
78
|
-
return '/*# ' + data + ' */'
|
|
79
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
-
Author Tobias Koppers @sokra
|
|
4
|
-
Modified by @hiyuki
|
|
5
|
-
*/
|
|
6
|
-
const loaderUtils = require('loader-utils')
|
|
7
|
-
const path = require('path')
|
|
8
|
-
|
|
9
|
-
module.exports = function getLocalIdent (loaderContext, localIdentName, localName, options) {
|
|
10
|
-
if (!options.context) {
|
|
11
|
-
if (loaderContext.rootContext) {
|
|
12
|
-
options.context = loaderContext.rootContext
|
|
13
|
-
} else if (loaderContext.options && typeof loaderContext.options.context === 'string') {
|
|
14
|
-
options.context = loaderContext.options.context
|
|
15
|
-
} else {
|
|
16
|
-
options.context = loaderContext.context
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
const request = path.relative(options.context, loaderContext.resourcePath)
|
|
20
|
-
options.content = options.hashPrefix + request + '+' + localName
|
|
21
|
-
localIdentName = localIdentName.replace(/\[local\]/gi, localName)
|
|
22
|
-
const hash = loaderUtils.interpolateName(loaderContext, localIdentName, options)
|
|
23
|
-
/* eslint-disable prefer-regex-literals */
|
|
24
|
-
return hash.replace(new RegExp('[^a-zA-Z0-9\\-_\u00A0-\uFFFF]', 'g'), '-').replace(/^((-?[0-9])|--)/, '_$1')
|
|
25
|
-
}
|
package/lib/wxss/localsLoader.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
-
Author Tobias Koppers @sokra
|
|
4
|
-
Modified by @hiyuki
|
|
5
|
-
*/
|
|
6
|
-
const loaderUtils = require('loader-utils')
|
|
7
|
-
const processCss = require('./processCss')
|
|
8
|
-
const compileExports = require('./compile-exports')
|
|
9
|
-
const createResolver = require('./createResolver')
|
|
10
|
-
|
|
11
|
-
module.exports = function (content) {
|
|
12
|
-
if (this.cacheable) this.cacheable()
|
|
13
|
-
const callback = this.async()
|
|
14
|
-
const query = loaderUtils.getOptions(this) || {}
|
|
15
|
-
const moduleMode = query.modules || query.module
|
|
16
|
-
const camelCaseKeys = query.camelCase || query.camelcase
|
|
17
|
-
const resolve = createResolver(query.alias)
|
|
18
|
-
|
|
19
|
-
processCss(content, null, {
|
|
20
|
-
mode: moduleMode ? 'local' : 'global',
|
|
21
|
-
query: query,
|
|
22
|
-
minimize: this.minimize,
|
|
23
|
-
loaderContext: this,
|
|
24
|
-
resolve: resolve
|
|
25
|
-
}, function (err, result) {
|
|
26
|
-
if (err) return callback(err)
|
|
27
|
-
|
|
28
|
-
function importItemMatcher (item) {
|
|
29
|
-
const match = result.importItemRegExp.exec(item)
|
|
30
|
-
const idx = +match[1]
|
|
31
|
-
const importItem = result.importItems[idx]
|
|
32
|
-
const importUrl = importItem.url
|
|
33
|
-
return '" + require(' + loaderUtils.stringifyRequest(this, importUrl) + ')' +
|
|
34
|
-
'[' + JSON.stringify(importItem.export) + '] + "'
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
let exportJs = compileExports(result, importItemMatcher.bind(this), camelCaseKeys)
|
|
38
|
-
if (exportJs) {
|
|
39
|
-
exportJs = 'module.exports = ' + exportJs + ';'
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
callback(null, exportJs)
|
|
43
|
-
}.bind(this))
|
|
44
|
-
}
|