Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
Chameleon
提交
f6f5f508
C
Chameleon
项目概览
DiDi
/
Chameleon
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Chameleon
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f6f5f508
编写于
4月 18, 2019
作者:
Y
yylgit
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cmlType multi
上级
5f0b7989
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
52 addition
and
35 deletion
+52
-35
packages/chameleon-tool-utils/src/index.js
packages/chameleon-tool-utils/src/index.js
+1
-1
packages/chameleon-tool/configs/mvvm/getExtendConfig.js
packages/chameleon-tool/configs/mvvm/getExtendConfig.js
+20
-1
packages/mvvm-interface-parser/lib/getInterfaceCode.js
packages/mvvm-interface-parser/lib/getInterfaceCode.js
+0
-1
packages/mvvm-interface-parser/lib/getMethodCode.js
packages/mvvm-interface-parser/lib/getMethodCode.js
+1
-2
packages/mvvm-pack/cmlNode.js
packages/mvvm-pack/cmlNode.js
+8
-8
packages/mvvm-pack/compiler.js
packages/mvvm-pack/compiler.js
+16
-14
packages/mvvm-pack/mvvmGraphPlugin.js
packages/mvvm-pack/mvvmGraphPlugin.js
+4
-7
packages/mvvm-pack/package.json
packages/mvvm-pack/package.json
+2
-1
未找到文件。
packages/chameleon-tool-utils/src/index.js
浏览文件 @
f6f5f508
...
...
@@ -838,7 +838,7 @@ _.findPolymorphicComponent = function(interfacePath, content, cmlType) {
}
let
targetScript
=
null
;
for
(
let
i
=
0
;
i
<
parts
.
script
.
length
;
i
++
)
{
if
(
parts
.
script
[
i
].
cmlType
===
cmlType
)
{
if
(
~
parts
.
script
[
i
].
cmlType
.
split
(
'
,
'
).
indexOf
(
cmlType
)
)
{
targetScript
=
parts
.
script
[
i
];
}
}
...
...
packages/chameleon-tool/configs/mvvm/getExtendConfig.js
浏览文件 @
f6f5f508
...
...
@@ -3,8 +3,17 @@ const path = require('path');
const
getCommonConfig
=
require
(
'
../getCommonConfig
'
);
const
utils
=
require
(
'
../utils.js
'
);
const
{
MvvmGraphPlugin
}
=
require
(
'
mvvm-pack
'
);
module
.
exports
=
function
(
options
)
{
let
{
type
,
media
}
=
options
;
let
npmName
=
cml
.
config
.
get
().
extPlatform
[
type
];
let
PlatformPlugin
=
require
(
path
.
join
(
cml
.
projectRoot
,
'
node_modules
'
,
npmName
));
// eslint-disable-line
// 用户端扩展插件
let
platformPlugin
=
new
PlatformPlugin
({
cmlType
:
type
,
media
});
let
extendConfig
=
{
entry
:
{
app
:
path
.
join
(
cml
.
projectRoot
,
'
src/app/app.cml
'
)
...
...
@@ -33,7 +42,7 @@ module.exports = function(options) {
new
MvvmGraphPlugin
({
cmlType
:
type
,
media
})
}
,
platformPlugin
)
]
};
// options.moduleIdType = 'hash';
...
...
@@ -44,6 +53,16 @@ module.exports = function(options) {
item
.
options
.
publicPath
=
commonConfig
.
output
.
publicPath
}
})
// 用户可以扩展webpack的rules用于处理特有文件后缀
if
(
platformPlugin
.
webpackRules
&&
platformPlugin
.
webpackRules
instanceof
Array
)
{
extendConfig
=
merge
(
extendConfig
,
{
module
:
{
rules
:
platformPlugin
.
webpackRules
}
})
}
return
merge
(
commonConfig
,
extendConfig
);
}
\ No newline at end of file
packages/mvvm-interface-parser/lib/getInterfaceCode.js
浏览文件 @
f6f5f508
const
cmlUtils
=
require
(
'
chameleon-tool-utils
'
);
const
fs
=
require
(
'
fs
'
);
const
path
=
require
(
'
path
'
);
module
.
exports
=
function
({
interfacePath
,
content
})
{
...
...
packages/mvvm-interface-parser/lib/getMethodCode.js
浏览文件 @
f6f5f508
const
cmlUtils
=
require
(
'
chameleon-tool-utils
'
);
const
fs
=
require
(
'
fs
'
);
const
path
=
require
(
'
path
'
);
const
{
resolveRequire
}
=
require
(
'
./resolveRequire.js
'
);
...
...
@@ -25,7 +24,7 @@ module.exports = function({interfacePath, content, cmlType, resolve}) {
}
let
methodScript
=
null
;
for
(
let
i
=
0
;
i
<
parts
.
script
.
length
;
i
++
)
{
if
(
parts
.
script
[
i
].
cmlType
===
cmlType
)
{
if
(
~
parts
.
script
[
i
].
cmlType
.
split
(
'
,
'
).
indexOf
(
cmlType
)
)
{
methodScript
=
parts
.
script
[
i
];
}
}
...
...
packages/mvvm-pack/cmlNode.js
浏览文件 @
f6f5f508
...
...
@@ -2,17 +2,17 @@ class CMLNode {
constructor
(
options
=
{})
{
this
.
ext
;
this
.
realPath
;
// 文件物理地址
this
.
nodeType
;
//
App/Page/Component/Module // 节点类型 CML文件分为App/Page/Component 其他的为Module CML
文件中的每一个部分也是一个Node节点
this
.
moduleType
;
// template/style/script/json/asset
CML为CML文件
this
.
dependencies
=
[];
// 该节点的直接依赖
编译及诶点 app.cml依赖pages.cml pages.cml依赖components.cml js依赖js cmss依赖cms
s
this
.
childrens
=
[];
// 子模块
CML
才有子模块
this
.
parent
;
// 父模块
CML
文件中的子模块才有
this
.
nodeType
;
//
app/page/component/module // 节点类型 app/page/component 其他的为module cml
文件中的每一个部分也是一个Node节点
this
.
moduleType
;
// template/style/script/json/asset
this
.
dependencies
=
[];
// 该节点的直接依赖
app.cml依赖pages.cml pages.cml依赖components.cml js依赖j
s
this
.
childrens
=
[];
// 子模块
cml文件
才有子模块
this
.
parent
;
// 父模块
cml
文件中的子模块才有
this
.
source
;
// 模块源代码
this
.
convert
;
//
AST JSON
this
.
convert
;
//
源代码的格式化形式
this
.
output
;
// 模块输出 各种过程操作该字段
this
.
identifier
;
// 节点唯一标识
this
.
modId
;
// 模块化的id
this
.
extra
;
this
.
modId
;
// 模块化的id
requirejs
this
.
extra
;
// 节点的额外信息
Object
.
keys
(
options
).
forEach
(
key
=>
{
this
[
key
]
=
options
[
key
];
})
...
...
packages/mvvm-pack/compiler.js
浏览文件 @
f6f5f508
...
...
@@ -4,22 +4,14 @@ const Log = require('./log.js');
const
EventEmitter
=
require
(
'
events
'
);
const
cmlUtils
=
require
(
'
chameleon-tool-utils
'
);
const
parser
=
require
(
'
../mvvm-babel-parser/lib
'
);
const
merge
=
require
(
'
webpack-merge
'
);
class
Compiler
{
constructor
(
webpackCompiler
)
{
constructor
(
webpackCompiler
,
plugin
)
{
this
.
moduleRule
=
[
// 文件后缀对应module信息
{
test
:
/
\.
css|
\.
less$/
,
moduleType
:
'
style
'
,
attrs
:
{
lang
:
'
less
'
}
},
{
test
:
/
\.
stylus|
\.
styls$/
,
moduleType
:
'
style
'
,
attrs
:
{
lang
:
'
stylus
'
}
test
:
/
\.
css|
\.
less|
\.
stylus|
\.
styls$/
,
moduleType
:
'
style
'
},
{
test
:
/
\.
js|
\.
interface$/
,
...
...
@@ -39,6 +31,13 @@ class Compiler {
this
.
log
=
new
Log
();
this
.
event
=
new
EventEmitter
();
this
.
webpackCompiler
=
webpackCompiler
;
// 用户扩展文件类型
if
(
plugin
.
moduleRule
&&
plugin
.
moduleRule
instanceof
Array
)
{
this
.
moduleRule
=
this
.
moduleRule
.
concat
(
plugin
.
moduleRule
);
}
}
run
(
modules
)
{
...
...
@@ -152,7 +151,10 @@ class Compiler {
// 创建单个节点
createNode
(
module
)
{
let
options
=
{};
options
.
realPath
=
module
.
resource
;
if
(
~
module
.
resource
.
indexOf
(
'
images/chameleon.png
'
))
{
debugger
}
options
.
realPath
=
module
.
resource
;
// 会带参数
options
.
ext
=
path
.
extname
(
module
.
resource
);
options
.
nodeType
=
module
.
_nodeType
||
'
module
'
;
options
.
identifier
=
module
.
request
;
...
...
packages/mvvm-pack/mvvmGraphPlugin.js
浏览文件 @
f6f5f508
const
path
=
require
(
'
path
'
);
const
MvvmCompiler
=
require
(
'
./compiler.js
'
);
class
mvvmGraphPlugin
{
constructor
(
options
=
{})
{
constructor
(
options
=
{}
,
platformPlugin
)
{
this
.
options
=
options
;
this
.
platformPlugin
=
platformPlugin
;
}
apply
(
compiler
)
{
let
self
=
this
;
let
npmName
=
cml
.
config
.
get
().
extPlatform
[
this
.
options
.
cmlType
];
let
PlatformPlugin
=
require
(
path
.
join
(
cml
.
projectRoot
,
'
node_modules
'
,
npmName
));
// eslint-disable-line
let
plugin
=
new
PlatformPlugin
(
this
.
options
);
let
mvvmCompiler
=
new
MvvmCompiler
(
compiler
);
let
mvvmCompiler
=
new
MvvmCompiler
(
compiler
,
self
.
platformPlugin
);
compiler
.
_mvvmCompiler
=
mvvmCompiler
;
// 监听cml中查找组件
cml
.
event
.
on
(
'
find-component
'
,
function
({
context
,
cmlFilePath
,
comPath
,
cmlType
},
result
)
{
...
...
@@ -19,7 +16,7 @@ class mvvmGraphPlugin {
mvvmCompiler
.
emit
(
'
find-component
'
,
{
context
,
cmlFilePath
,
comPath
,
cmlType
},
result
);
}
})
p
lugin
.
register
(
mvvmCompiler
);
self
.
platformP
lugin
.
register
(
mvvmCompiler
);
compiler
.
plugin
(
'
should-emit
'
,
function
(
compilation
)
{
debugger
...
...
packages/mvvm-pack/package.json
浏览文件 @
f6f5f508
...
...
@@ -10,6 +10,7 @@
"license"
:
"ISC"
,
"dependencies"
:
{
"chameleon-tool-utils"
:
"0.3.0-alpha.2"
,
"mvvm-babel-parser"
:
"0.3.0-alpha.2"
"mvvm-babel-parser"
:
"0.3.0-alpha.2"
,
"webpack-merge"
:
"^4.2.1"
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录