Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zeroing-pack
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
劳工
zeroing-pack
Commits
4f9a7485
Commit
4f9a7485
authored
Sep 17, 2020
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
bbeb7c0d
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
77 additions
and
40 deletions
+77
-40
index.es.js
dist/index.es.js
+11
-5
index.es.js.map
dist/index.es.js.map
+1
-1
index.js
dist/index.js
+19
-10
index.js.map
dist/index.js.map
+1
-1
index.umd.js
dist/index.umd.js
+19
-11
index.umd.js.map
dist/index.umd.js.map
+1
-1
index.js
src/index.js
+11
-5
yarn.lock
yarn.lock
+10
-5
zeroing-pack.iml
zeroing-pack.iml
+4
-1
No files found.
dist/index.es.js
View file @
4f9a7485
import
ts
from
'typescript'
;
import
UglifyJS
from
'uglify-js'
;
import
{
divideCode
}
from
'zeroing-code-divider'
;
import
{
generateLibraryScriptEl
,
generateJsScriptEl
,
fillTemplate
}
from
'zeroing-template-fill'
;
import
{
generateLibraryScriptEl
,
generateJsScript
BodyEl
,
generateJsScript
El
,
fillTemplate
}
from
'zeroing-template-fill'
;
/**
* Created by rockyl on 2019-11-30.
...
...
@@ -55,9 +55,14 @@ async function pack(data, options) {
}
}
function
fillTpl
(
data
,
params
)
{
function
fillTpl
(
data
,
params
,
mix
)
{
const
{
options
}
=
data
;
params
.
scripts
=
params
.
scripts
.
map
(
item
=>
generateJsScriptEl
(
item
)).
join
(
'
\
n'
);
if
(
mix
)
{
let
code
=
'var adsComplete=false;ga.showBanner(function(){adsComplete=true},'
+
params
.
scripts
.
map
(
item
=>
`'
${
item
}
'`
).
join
(
','
)
+
');'
;
params
.
scripts
=
generateJsScriptBodyEl
(
code
);
}
else
{
params
.
scripts
=
params
.
scripts
.
map
(
item
=>
generateJsScriptEl
(
item
)).
join
(
'
\
n'
);
}
let
tpl
=
fillTemplate
(
options
.
newTpl
,
params
);
delete
options
.
newTpl
;
...
...
@@ -68,7 +73,7 @@ function fillTpl(data, params) {
return
tpl
;
}
async
function
packData
(
data
,
{
debug
,
packedAssets
,
getPackages
})
{
async
function
packData
(
data
,
{
debug
,
mix
,
packedAssets
,
getPackages
})
{
let
newData
=
{};
newData
.
options
=
data
.
options
;
newData
.
views
=
data
.
views
;
...
...
@@ -90,7 +95,7 @@ async function packData(data, {debug, packedAssets, getPackages}) {
if
(
computed
)
{
for
(
let
item
of
computed
)
{
if
(
item
.
script
)
{
item
.
script
=
(
await
compile
(
item
.
script
)).
code
;
item
.
script
=
(
await
compile
(
item
.
script
)).
code
;
}
}
}
...
...
@@ -103,6 +108,7 @@ async function packData(data, {debug, packedAssets, getPackages}) {
customScriptContent
,
}
=
await
divideCode
(
newData
,
{
debug
,
mix
,
uglify
,
compile
,
getPackages
,
dependencies
:
data
.
dependencies
,
...
...
dist/index.es.js.map
View file @
4f9a7485
{
"version"
:
3
,
"file"
:
"index.es.js"
,
"sources"
:
[
"../src/code-process.js"
,
"../src/index.js"
],
"sourcesContent"
:
[
"/**
\n
* Created by rockyl on 2019-11-30.
\n
*/
\n\n
import ts from 'typescript';
\n
import UglifyJS from 'uglify-js';
\n\n
export async function compile(source, debug = false) {\n
\t
let output = ts.transpileModule(source, {\n
\t\t
compilerOptions:
{
}\n\t
}
);
\n\n\t
const result = {\n
\t\t
code: output.outputText,
\n\t
};
\n\t
/*if (map) {\n
\t\t
result.sourcemap = map.mappings;
\n\t
}*/
\n\t
return result;
\n
}
\n\n
export function uglify(source) {\n
\t
const uglifyResult = UglifyJS.minify(source, {});
\n\t
if (uglifyResult.error) {\n
\t\t
throw new Error(uglifyResult.error);
\n\t
} else {\n
\t\t
return uglifyResult.code;
\n\t
}
\n
}"
,
"/**
\n
* Created by rockyl on 2019-11-13.
\n
*
\n
* 项目打包
\n
*/
\n\n
import {uglify, compile} from
\"
./code-process
\"
;
\n
import
{
divideCode
}
from 'zeroing-code-divider';
\n
import {generateLibraryScriptEl, fillTemplate, generateJsScriptEl} from 'zeroing-template-fill';
\n\n
const replaceFields = ['pageTitle', 'containerId'];
\n
const TAG = 'zeroing-pack';
\n\n
export async function pack(data, options) {\n
\t
let dependencies = data.dependencies;
\n\t
let getPackages = options.getPackages;
\n\n\t
const {libraryScriptElMap, analyseResult} = await generateLibraryScriptEl(data.options.tpl, dependencies, getPackages, '//yun.duiba.com.cn/editor/zeroing/libs/', options.debug);
\n\n\t
let version = Date.now() + Math.floor(Math.random() * 1000);
\n\t
pageTemplate(data, data.options, version, analyseResult, libraryScriptElMap);
\n\t
const newData = await packData(data, options);
\n\n\t
return {\n
\t\t
version,
\n\t\t
data: newData,
\n\t
}
\n
}
\n\n
export function fillTpl(data, params) {\n
\t
const
{
options
}
= data;
\n\t
params.scripts = params.scripts.map(item => generateJsScriptEl(item)).join('
\\
n');
\n\t
let tpl = fillTemplate(options.newTpl, params);
\n\n\t
delete options.newTpl;
\n\t
delete options.tpl;
\n\t
delete options.projectxConfig;
\n\t
delete options.pxEnv;
\n\n\t
return tpl;
\n
}
\n\n
async function packData(data, {debug, packedAssets, getPackages}) {\n
\t
let newData = {};
\n\t
newData.options = data.options;
\n\t
newData.views = data.views;
\n\t
newData.assets = packedAssets || data.assets;
\n\t
newData.dataMapping = data.dataMapping;
\n\t
newData.processes = data.processes;
\n\t
newData.customs = data.customs;
\n\n\t
deleteUnusedData(newData.processes);
\n\n\t
console.log(TAG, 'start');
\n\n\t
for (let view of newData.views) {\n
\t\t
if (view.store) {\n
\t\t\t
let {exp, computed} = view.store;
\n\t\t\t
if (exp) {\n
\t\t\t\t
view.store.exp = (await compile(exp)).code;
\n\t\t\t
}
\n\t\t\t
if (computed) {\n
\t\t\t\t
for (let item of computed) {\n
\t\t\t\t\t
if (item.script) {\n
\t\t\t\t\t\t
item.script = (await compile(item.script)).code;
\n\t\t\t\t\t
}
\n\t\t\t\t
}
\n\t\t\t
}
\n\t\t
}
\n\t
}
\n\n\t
const
{
\n\t\tprocessScriptContent,\n\t\tscriptsContent,\n\t\tcustomScriptContent,\n\t
}
= await divideCode(newData, {\n
\t\t
debug,
\n\t\t
uglify, compile,
\n\t\t
getPackages,
\n\t\t
dependencies: data.dependencies,
\n\t
});
\n\n\t
return {\n
\t\t
data: newData,
\n\t\t
processScriptContent,
\n\t\t
scriptsContent,
\n\t\t
customScriptContent,
\n\t
};
\n
}
\n\n
const unusedFields = ['design'];
\n\n
function deleteUnusedData(processes) {\n
\t
for (let process of processes) {\n
\t\t
if (process.sub) {\n
\t\t\t
for (let uuid in process.sub) {\n
\t\t\t\t
let subProcess = process.sub[uuid];
\n\t\t\t\t
for (let field of unusedFields) {\n
\t\t\t\t\t
if (subProcess.hasOwnProperty(field)) {\n
\t\t\t\t\t\t
delete subProcess[field];
\n\t\t\t\t\t
}
\n\t\t\t\t
}
\n\t\t\t
}
\n\t\t
}
\n\t\t
if (process.metas && process.metas.length > 0)
{
\n\t\t\tdeleteUnusedData(process.metas);\n\t\t}\n\t}\n
}
\n\n
function pageTemplate(tpl, options, version, analyseResult, libraryScriptElMap) {\n
\t
const params = {\n
\t\t
version,
\n\t\t
libraries: libraryScriptElMap,
\n\t
};
\n\t
for (let field of replaceFields) {\n
\t\t
params[field] = options[field];
\n\t
}
\n\n\t
options.newTpl = fillTemplate(options.tpl, params, analyseResult);
\n
}
\n
"
],
"names"
:
[],
"mappings"
:
";;;;;AAAA;;;AAGA,AAGA;AACA,AAAO,eAAe,OAAO,CAAC,MAAM,EAAE,KAAK,GAAG,KAAK,EAAE;CAC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,CAAC,EAAE;GAC9C,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;GAChC;EACD;CACD;;AAED,SAAS,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE;CAC/E,MAAM,MAAM,GAAG;EACd,OAAO;EACP,SAAS,EAAE,kBAAkB;EAC7B,CAAC;CACF,KAAK,IAAI,KAAK,IAAI,aAAa,EAAE;EAChC,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;EAC/B;;CAED,OAAO,CAAC,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;CAClE;;;;"
}
\ No newline at end of file
{
"version"
:
3
,
"file"
:
"index.es.js"
,
"sources"
:
[
"../src/code-process.js"
,
"../src/index.js"
],
"sourcesContent"
:
[
"/**
\n
* Created by rockyl on 2019-11-30.
\n
*/
\n\n
import ts from 'typescript';
\n
import UglifyJS from 'uglify-js';
\n\n
export async function compile(source, debug = false) {\n
\t
let output = ts.transpileModule(source, {\n
\t\t
compilerOptions:
{
}\n\t
}
);
\n\n\t
const result = {\n
\t\t
code: output.outputText,
\n\t
};
\n\t
/*if (map) {\n
\t\t
result.sourcemap = map.mappings;
\n\t
}*/
\n\t
return result;
\n
}
\n\n
export function uglify(source) {\n
\t
const uglifyResult = UglifyJS.minify(source, {});
\n\t
if (uglifyResult.error) {\n
\t\t
throw new Error(uglifyResult.error);
\n\t
} else {\n
\t\t
return uglifyResult.code;
\n\t
}
\n
}"
,
"/**
\n
* Created by rockyl on 2019-11-13.
\n
*
\n
* 项目打包
\n
*/
\n\n
import {uglify, compile} from
\"
./code-process
\"
;
\n
import
{
divideCode
}
from 'zeroing-code-divider';
\n
import {generateLibraryScriptEl, fillTemplate, generateJsScriptEl, generateJsScriptBodyEl} from 'zeroing-template-fill';
\n\n
const replaceFields = ['pageTitle', 'containerId'];
\n
const TAG = 'zeroing-pack';
\n\n
export async function pack(data, options) {\n
\t
let dependencies = data.dependencies;
\n\t
let getPackages = options.getPackages;
\n\n\t
const {libraryScriptElMap, analyseResult} = await generateLibraryScriptEl(data.options.tpl, dependencies, getPackages, '//yun.duiba.com.cn/editor/zeroing/libs/', options.debug);
\n\n\t
let version = Date.now() + Math.floor(Math.random() * 1000);
\n\t
pageTemplate(data, data.options, version, analyseResult, libraryScriptElMap);
\n\t
const newData = await packData(data, options);
\n\n\t
return {\n
\t\t
version,
\n\t\t
data: newData,
\n\t
}
\n
}
\n\n
export function fillTpl(data, params, mix) {\n
\t
const
{
options
}
= data;
\n\t
if (mix) {\n
\t\t
let code = 'var adsComplete=false;ga.showBanner(function()
{
adsComplete=true
}
,' + params.scripts.map(item => `'${item}'`).join(',') + ');';
\n\t\t
params.scripts = generateJsScriptBodyEl(code);
\n\t
} else {\n
\t\t
params.scripts = params.scripts.map(item => generateJsScriptEl(item)).join('
\\
n')
\n\t
}
\n\t
let tpl = fillTemplate(options.newTpl, params);
\n\n\t
delete options.newTpl;
\n\t
delete options.tpl;
\n\t
delete options.projectxConfig;
\n\t
delete options.pxEnv;
\n\n\t
return tpl;
\n
}
\n\n
async function packData(data, {debug, mix, packedAssets, getPackages}) {\n
\t
let newData = {};
\n\t
newData.options = data.options;
\n\t
newData.views = data.views;
\n\t
newData.assets = packedAssets || data.assets;
\n\t
newData.dataMapping = data.dataMapping;
\n\t
newData.processes = data.processes;
\n\t
newData.customs = data.customs;
\n\n\t
deleteUnusedData(newData.processes);
\n\n\t
console.log(TAG, 'start');
\n\n\t
for (let view of newData.views) {\n
\t\t
if (view.store) {\n
\t\t\t
let {exp, computed} = view.store;
\n\t\t\t
if (exp) {\n
\t\t\t\t
view.store.exp = (await compile(exp)).code;
\n\t\t\t
}
\n\t\t\t
if (computed) {\n
\t\t\t\t
for (let item of computed) {\n
\t\t\t\t\t
if (item.script) {\n
\t\t\t\t\t\t
item.script = (await compile(item.script)).code;
\n\t\t\t\t\t
}
\n\t\t\t\t
}
\n\t\t\t
}
\n\t\t
}
\n\t
}
\n\n\t
const
{
\n\t\tprocessScriptContent,\n\t\tscriptsContent,\n\t\tcustomScriptContent,\n\t
}
= await divideCode(newData, {\n
\t\t
debug,
\n\t\t
mix,
\n\t\t
uglify, compile,
\n\t\t
getPackages,
\n\t\t
dependencies: data.dependencies,
\n\t
});
\n\n\t
return {\n
\t\t
data: newData,
\n\t\t
processScriptContent,
\n\t\t
scriptsContent,
\n\t\t
customScriptContent,
\n\t
};
\n
}
\n\n
const unusedFields = ['design'];
\n\n
function deleteUnusedData(processes) {\n
\t
for (let process of processes) {\n
\t\t
if (process.sub) {\n
\t\t\t
for (let uuid in process.sub) {\n
\t\t\t\t
let subProcess = process.sub[uuid];
\n\t\t\t\t
for (let field of unusedFields) {\n
\t\t\t\t\t
if (subProcess.hasOwnProperty(field)) {\n
\t\t\t\t\t\t
delete subProcess[field];
\n\t\t\t\t\t
}
\n\t\t\t\t
}
\n\t\t\t
}
\n\t\t
}
\n\t\t
if (process.metas && process.metas.length > 0)
{
\n\t\t\tdeleteUnusedData(process.metas);\n\t\t}\n\t}\n
}
\n\n
function pageTemplate(tpl, options, version, analyseResult, libraryScriptElMap) {\n
\t
const params = {\n
\t\t
version,
\n\t\t
libraries: libraryScriptElMap,
\n\t
};
\n\t
for (let field of replaceFields) {\n
\t\t
params[field] = options[field];
\n\t
}
\n\n\t
options.newTpl = fillTemplate(options.tpl, params, analyseResult);
\n
}
\n
"
],
"names"
:
[],
"mappings"
:
";;;;;AAAA;AACA;AACA;AAIA;AACO,eAAe,OAAO,CAAC,MAAM,EAAE,KAAK,GAAG,KAAK,EAAE;AACrD,CAAC,IAAI,MAAM,GAAG,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE;AACzC,EAAE,eAAe,EAAE,EAAE;AACrB,EAAE,CAAC,CAAC;AACJ;AACA,CAAC,MAAM,MAAM,GAAG;AAChB,EAAE,IAAI,EAAE,MAAM,CAAC,UAAU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AAC,GAAG,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;AACnE;;;;"
}
\ No newline at end of file
dist/index.js
View file @
4f9a7485
...
...
@@ -2,19 +2,22 @@
Object
.
defineProperty
(
exports
,
'__esModule'
,
{
value
:
true
});
function
_interopDefault
(
ex
)
{
return
(
ex
&&
(
typeof
ex
===
'object'
)
&&
'default'
in
ex
)
?
ex
[
'default'
]
:
ex
;
}
var
ts
=
_interopDefault
(
require
(
'typescript'
));
var
UglifyJS
=
_interopDefault
(
require
(
'uglify-js'
));
var
ts
=
require
(
'typescript'
);
var
UglifyJS
=
require
(
'uglify-js'
);
var
zeroingCodeDivider
=
require
(
'zeroing-code-divider'
);
var
zeroingTemplateFill
=
require
(
'zeroing-template-fill'
);
function
_interopDefaultLegacy
(
e
)
{
return
e
&&
typeof
e
===
'object'
&&
'default'
in
e
?
e
:
{
'default'
:
e
};
}
var
ts__default
=
/*#__PURE__*/
_interopDefaultLegacy
(
ts
);
var
UglifyJS__default
=
/*#__PURE__*/
_interopDefaultLegacy
(
UglifyJS
);
/**
* Created by rockyl on 2019-11-30.
*/
async
function
compile
(
source
,
debug
=
false
)
{
let
output
=
ts
.
transpileModule
(
source
,
{
let
output
=
ts
__default
[
'default'
]
.
transpileModule
(
source
,
{
compilerOptions
:
{}
});
...
...
@@ -28,7 +31,7 @@ async function compile(source, debug = false) {
}
function
uglify
(
source
)
{
const
uglifyResult
=
UglifyJS
.
minify
(
source
,
{});
const
uglifyResult
=
UglifyJS
__default
[
'default'
]
.
minify
(
source
,
{});
if
(
uglifyResult
.
error
)
{
throw
new
Error
(
uglifyResult
.
error
);
}
else
{
...
...
@@ -61,9 +64,14 @@ async function pack(data, options) {
}
}
function
fillTpl
(
data
,
params
)
{
function
fillTpl
(
data
,
params
,
mix
)
{
const
{
options
}
=
data
;
params
.
scripts
=
params
.
scripts
.
map
(
item
=>
zeroingTemplateFill
.
generateJsScriptEl
(
item
)).
join
(
'
\
n'
);
if
(
mix
)
{
let
code
=
'var adsComplete=false;ga.showBanner(function(){adsComplete=true},'
+
params
.
scripts
.
map
(
item
=>
`'
${
item
}
'`
).
join
(
','
)
+
');'
;
params
.
scripts
=
zeroingTemplateFill
.
generateJsScriptBodyEl
(
code
);
}
else
{
params
.
scripts
=
params
.
scripts
.
map
(
item
=>
zeroingTemplateFill
.
generateJsScriptEl
(
item
)).
join
(
'
\
n'
);
}
let
tpl
=
zeroingTemplateFill
.
fillTemplate
(
options
.
newTpl
,
params
);
delete
options
.
newTpl
;
...
...
@@ -74,7 +82,7 @@ function fillTpl(data, params) {
return
tpl
;
}
async
function
packData
(
data
,
{
debug
,
packedAssets
,
getPackages
})
{
async
function
packData
(
data
,
{
debug
,
mix
,
packedAssets
,
getPackages
})
{
let
newData
=
{};
newData
.
options
=
data
.
options
;
newData
.
views
=
data
.
views
;
...
...
@@ -96,7 +104,7 @@ async function packData(data, {debug, packedAssets, getPackages}) {
if
(
computed
)
{
for
(
let
item
of
computed
)
{
if
(
item
.
script
)
{
item
.
script
=
(
await
compile
(
item
.
script
)).
code
;
item
.
script
=
(
await
compile
(
item
.
script
)).
code
;
}
}
}
...
...
@@ -109,6 +117,7 @@ async function packData(data, {debug, packedAssets, getPackages}) {
customScriptContent
,
}
=
await
zeroingCodeDivider
.
divideCode
(
newData
,
{
debug
,
mix
,
uglify
,
compile
,
getPackages
,
dependencies
:
data
.
dependencies
,
...
...
dist/index.js.map
View file @
4f9a7485
{
"version"
:
3
,
"file"
:
"index.js"
,
"sources"
:
[
"../src/code-process.js"
,
"../src/index.js"
],
"sourcesContent"
:
[
"/**
\n
* Created by rockyl on 2019-11-30.
\n
*/
\n\n
import ts from 'typescript';
\n
import UglifyJS from 'uglify-js';
\n\n
export async function compile(source, debug = false) {\n
\t
let output = ts.transpileModule(source, {\n
\t\t
compilerOptions:
{
}\n\t
}
);
\n\n\t
const result = {\n
\t\t
code: output.outputText,
\n\t
};
\n\t
/*if (map) {\n
\t\t
result.sourcemap = map.mappings;
\n\t
}*/
\n\t
return result;
\n
}
\n\n
export function uglify(source) {\n
\t
const uglifyResult = UglifyJS.minify(source, {});
\n\t
if (uglifyResult.error) {\n
\t\t
throw new Error(uglifyResult.error);
\n\t
} else {\n
\t\t
return uglifyResult.code;
\n\t
}
\n
}"
,
"/**
\n
* Created by rockyl on 2019-11-13.
\n
*
\n
* 项目打包
\n
*/
\n\n
import {uglify, compile} from
\"
./code-process
\"
;
\n
import
{
divideCode
}
from 'zeroing-code-divider';
\n
import {generateLibraryScriptEl, fillTemplate, generateJsScriptEl} from 'zeroing-template-fill';
\n\n
const replaceFields = ['pageTitle', 'containerId'];
\n
const TAG = 'zeroing-pack';
\n\n
export async function pack(data, options) {\n
\t
let dependencies = data.dependencies;
\n\t
let getPackages = options.getPackages;
\n\n\t
const {libraryScriptElMap, analyseResult} = await generateLibraryScriptEl(data.options.tpl, dependencies, getPackages, '//yun.duiba.com.cn/editor/zeroing/libs/', options.debug);
\n\n\t
let version = Date.now() + Math.floor(Math.random() * 1000);
\n\t
pageTemplate(data, data.options, version, analyseResult, libraryScriptElMap);
\n\t
const newData = await packData(data, options);
\n\n\t
return {\n
\t\t
version,
\n\t\t
data: newData,
\n\t
}
\n
}
\n\n
export function fillTpl(data, params) {\n
\t
const
{
options
}
= data;
\n\t
params.scripts = params.scripts.map(item => generateJsScriptEl(item)).join('
\\
n');
\n\t
let tpl = fillTemplate(options.newTpl, params);
\n\n\t
delete options.newTpl;
\n\t
delete options.tpl;
\n\t
delete options.projectxConfig;
\n\t
delete options.pxEnv;
\n\n\t
return tpl;
\n
}
\n\n
async function packData(data, {debug, packedAssets, getPackages}) {\n
\t
let newData = {};
\n\t
newData.options = data.options;
\n\t
newData.views = data.views;
\n\t
newData.assets = packedAssets || data.assets;
\n\t
newData.dataMapping = data.dataMapping;
\n\t
newData.processes = data.processes;
\n\t
newData.customs = data.customs;
\n\n\t
deleteUnusedData(newData.processes);
\n\n\t
console.log(TAG, 'start');
\n\n\t
for (let view of newData.views) {\n
\t\t
if (view.store) {\n
\t\t\t
let {exp, computed} = view.store;
\n\t\t\t
if (exp) {\n
\t\t\t\t
view.store.exp = (await compile(exp)).code;
\n\t\t\t
}
\n\t\t\t
if (computed) {\n
\t\t\t\t
for (let item of computed) {\n
\t\t\t\t\t
if (item.script) {\n
\t\t\t\t\t\t
item.script = (await compile(item.script)).code;
\n\t\t\t\t\t
}
\n\t\t\t\t
}
\n\t\t\t
}
\n\t\t
}
\n\t
}
\n\n\t
const
{
\n\t\tprocessScriptContent,\n\t\tscriptsContent,\n\t\tcustomScriptContent,\n\t
}
= await divideCode(newData, {\n
\t\t
debug,
\n\t\t
uglify, compile,
\n\t\t
getPackages,
\n\t\t
dependencies: data.dependencies,
\n\t
});
\n\n\t
return {\n
\t\t
data: newData,
\n\t\t
processScriptContent,
\n\t\t
scriptsContent,
\n\t\t
customScriptContent,
\n\t
};
\n
}
\n\n
const unusedFields = ['design'];
\n\n
function deleteUnusedData(processes) {\n
\t
for (let process of processes) {\n
\t\t
if (process.sub) {\n
\t\t\t
for (let uuid in process.sub) {\n
\t\t\t\t
let subProcess = process.sub[uuid];
\n\t\t\t\t
for (let field of unusedFields) {\n
\t\t\t\t\t
if (subProcess.hasOwnProperty(field)) {\n
\t\t\t\t\t\t
delete subProcess[field];
\n\t\t\t\t\t
}
\n\t\t\t\t
}
\n\t\t\t
}
\n\t\t
}
\n\t\t
if (process.metas && process.metas.length > 0)
{
\n\t\t\tdeleteUnusedData(process.metas);\n\t\t}\n\t}\n
}
\n\n
function pageTemplate(tpl, options, version, analyseResult, libraryScriptElMap) {\n
\t
const params = {\n
\t\t
version,
\n\t\t
libraries: libraryScriptElMap,
\n\t
};
\n\t
for (let field of replaceFields) {\n
\t\t
params[field] = options[field];
\n\t
}
\n\n\t
options.newTpl = fillTemplate(options.tpl, params, analyseResult);
\n
}
\n
"
],
"names"
:
[
"generateLibraryScriptEl"
,
"generateJsScriptEl"
,
"fillTemplate"
,
"divideCode"
],
"mappings"
:
";;;;;;;;;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,CAAC;MACzB;KACD;IACD;GACD;EACD,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;GAC9C,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;GAChC;EACD;CACD;;AAED,SAAS,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE;CAC/E,MAAM,MAAM,GAAG;EACd,OAAO;EACP,SAAS,EAAE,kBAAkB;EAC7B,CAAC;CACF,KAAK,IAAI,KAAK,IAAI,aAAa,EAAE;EAChC,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;EAC/B;;CAED,OAAO,CAAC,MAAM,GAAGD,gCAAY,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;CAClE;;;;;"
}
\ No newline at end of file
{
"version"
:
3
,
"file"
:
"index.js"
,
"sources"
:
[
"../src/code-process.js"
,
"../src/index.js"
],
"sourcesContent"
:
[
"/**
\n
* Created by rockyl on 2019-11-30.
\n
*/
\n\n
import ts from 'typescript';
\n
import UglifyJS from 'uglify-js';
\n\n
export async function compile(source, debug = false) {\n
\t
let output = ts.transpileModule(source, {\n
\t\t
compilerOptions:
{
}\n\t
}
);
\n\n\t
const result = {\n
\t\t
code: output.outputText,
\n\t
};
\n\t
/*if (map) {\n
\t\t
result.sourcemap = map.mappings;
\n\t
}*/
\n\t
return result;
\n
}
\n\n
export function uglify(source) {\n
\t
const uglifyResult = UglifyJS.minify(source, {});
\n\t
if (uglifyResult.error) {\n
\t\t
throw new Error(uglifyResult.error);
\n\t
} else {\n
\t\t
return uglifyResult.code;
\n\t
}
\n
}"
,
"/**
\n
* Created by rockyl on 2019-11-13.
\n
*
\n
* 项目打包
\n
*/
\n\n
import {uglify, compile} from
\"
./code-process
\"
;
\n
import
{
divideCode
}
from 'zeroing-code-divider';
\n
import {generateLibraryScriptEl, fillTemplate, generateJsScriptEl, generateJsScriptBodyEl} from 'zeroing-template-fill';
\n\n
const replaceFields = ['pageTitle', 'containerId'];
\n
const TAG = 'zeroing-pack';
\n\n
export async function pack(data, options) {\n
\t
let dependencies = data.dependencies;
\n\t
let getPackages = options.getPackages;
\n\n\t
const {libraryScriptElMap, analyseResult} = await generateLibraryScriptEl(data.options.tpl, dependencies, getPackages, '//yun.duiba.com.cn/editor/zeroing/libs/', options.debug);
\n\n\t
let version = Date.now() + Math.floor(Math.random() * 1000);
\n\t
pageTemplate(data, data.options, version, analyseResult, libraryScriptElMap);
\n\t
const newData = await packData(data, options);
\n\n\t
return {\n
\t\t
version,
\n\t\t
data: newData,
\n\t
}
\n
}
\n\n
export function fillTpl(data, params, mix) {\n
\t
const
{
options
}
= data;
\n\t
if (mix) {\n
\t\t
let code = 'var adsComplete=false;ga.showBanner(function()
{
adsComplete=true
}
,' + params.scripts.map(item => `'${item}'`).join(',') + ');';
\n\t\t
params.scripts = generateJsScriptBodyEl(code);
\n\t
} else {\n
\t\t
params.scripts = params.scripts.map(item => generateJsScriptEl(item)).join('
\\
n')
\n\t
}
\n\t
let tpl = fillTemplate(options.newTpl, params);
\n\n\t
delete options.newTpl;
\n\t
delete options.tpl;
\n\t
delete options.projectxConfig;
\n\t
delete options.pxEnv;
\n\n\t
return tpl;
\n
}
\n\n
async function packData(data, {debug, mix, packedAssets, getPackages}) {\n
\t
let newData = {};
\n\t
newData.options = data.options;
\n\t
newData.views = data.views;
\n\t
newData.assets = packedAssets || data.assets;
\n\t
newData.dataMapping = data.dataMapping;
\n\t
newData.processes = data.processes;
\n\t
newData.customs = data.customs;
\n\n\t
deleteUnusedData(newData.processes);
\n\n\t
console.log(TAG, 'start');
\n\n\t
for (let view of newData.views) {\n
\t\t
if (view.store) {\n
\t\t\t
let {exp, computed} = view.store;
\n\t\t\t
if (exp) {\n
\t\t\t\t
view.store.exp = (await compile(exp)).code;
\n\t\t\t
}
\n\t\t\t
if (computed) {\n
\t\t\t\t
for (let item of computed) {\n
\t\t\t\t\t
if (item.script) {\n
\t\t\t\t\t\t
item.script = (await compile(item.script)).code;
\n\t\t\t\t\t
}
\n\t\t\t\t
}
\n\t\t\t
}
\n\t\t
}
\n\t
}
\n\n\t
const
{
\n\t\tprocessScriptContent,\n\t\tscriptsContent,\n\t\tcustomScriptContent,\n\t
}
= await divideCode(newData, {\n
\t\t
debug,
\n\t\t
mix,
\n\t\t
uglify, compile,
\n\t\t
getPackages,
\n\t\t
dependencies: data.dependencies,
\n\t
});
\n\n\t
return {\n
\t\t
data: newData,
\n\t\t
processScriptContent,
\n\t\t
scriptsContent,
\n\t\t
customScriptContent,
\n\t
};
\n
}
\n\n
const unusedFields = ['design'];
\n\n
function deleteUnusedData(processes) {\n
\t
for (let process of processes) {\n
\t\t
if (process.sub) {\n
\t\t\t
for (let uuid in process.sub) {\n
\t\t\t\t
let subProcess = process.sub[uuid];
\n\t\t\t\t
for (let field of unusedFields) {\n
\t\t\t\t\t
if (subProcess.hasOwnProperty(field)) {\n
\t\t\t\t\t\t
delete subProcess[field];
\n\t\t\t\t\t
}
\n\t\t\t\t
}
\n\t\t\t
}
\n\t\t
}
\n\t\t
if (process.metas && process.metas.length > 0)
{
\n\t\t\tdeleteUnusedData(process.metas);\n\t\t}\n\t}\n
}
\n\n
function pageTemplate(tpl, options, version, analyseResult, libraryScriptElMap) {\n
\t
const params = {\n
\t\t
version,
\n\t\t
libraries: libraryScriptElMap,
\n\t
};
\n\t
for (let field of replaceFields) {\n
\t\t
params[field] = options[field];
\n\t
}
\n\n\t
options.newTpl = fillTemplate(options.tpl, params, analyseResult);
\n
}
\n
"
],
"names"
:
[
"ts"
,
"UglifyJS"
,
"generateLibraryScriptEl"
,
"generateJsScriptBodyEl"
,
"generateJsScriptEl"
,
"fillTemplate"
,
"divideCode"
],
"mappings"
:
";;;;;;;;;;;;;;AAAA;AACA;AACA;AAIA;AACO,eAAe,OAAO,CAAC,MAAM,EAAE,KAAK,GAA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EAAE,kBAAkB;AAC/B,EAAE,CAAC;AACH,CAAC,KAAK,IAAI,KAAK,IAAI,aAAa,EAAE;AAClC,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;AACjC,EAAE;AACF;AACA,CAAC,OAAO,CAAC,MAAM,GAAGD,gCAAY,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;AACnE;;;;;"
}
\ No newline at end of file
dist/index.umd.js
View file @
4f9a7485
(
function
(
global
,
factory
)
{
typeof
exports
===
'object'
&&
typeof
module
!==
'undefined'
?
factory
(
exports
,
require
(
'typescript'
),
require
(
'uglify-js'
),
require
(
'zeroing-code-divider'
),
require
(
'zeroing-template-fill'
))
:
typeof
define
===
'function'
&&
define
.
amd
?
define
([
'exports'
,
'typescript'
,
'uglify-js'
,
'zeroing-code-divider'
,
'zeroing-template-fill'
],
factory
)
:
(
global
=
global
||
self
,
factory
(
global
[
'zeroing-pack'
]
=
{},
global
.
ts
,
global
.
UglifyJS
,
global
.
zeroingCodeDivider
,
global
.
zeroingTemplateFill
));
}(
this
,
function
(
exports
,
ts
,
UglifyJS
,
zeroingCodeDivider
,
zeroingTemplateFill
)
{
'use strict'
;
(
global
=
typeof
globalThis
!==
'undefined'
?
globalThis
:
global
||
self
,
factory
(
global
[
'zeroing-pack'
]
=
{},
global
.
ts
,
global
.
UglifyJS
,
global
.
zeroingCodeDivider
,
global
.
zeroingTemplateFill
));
}(
this
,
(
function
(
exports
,
ts
,
UglifyJS
,
zeroingCodeDivider
,
zeroingTemplateFill
)
{
'use strict'
;
ts
=
ts
&&
ts
.
hasOwnProperty
(
'default'
)
?
ts
[
'default'
]
:
ts
;
UglifyJS
=
UglifyJS
&&
UglifyJS
.
hasOwnProperty
(
'default'
)
?
UglifyJS
[
'default'
]
:
UglifyJS
;
function
_interopDefaultLegacy
(
e
)
{
return
e
&&
typeof
e
===
'object'
&&
'default'
in
e
?
e
:
{
'default'
:
e
};
}
var
ts__default
=
/*#__PURE__*/
_interopDefaultLegacy
(
ts
);
var
UglifyJS__default
=
/*#__PURE__*/
_interopDefaultLegacy
(
UglifyJS
);
/**
* Created by rockyl on 2019-11-30.
*/
async
function
compile
(
source
,
debug
=
false
)
{
let
output
=
ts
.
transpileModule
(
source
,
{
let
output
=
ts
__default
[
'default'
]
.
transpileModule
(
source
,
{
compilerOptions
:
{}
});
...
...
@@ -26,7 +28,7 @@
}
function
uglify
(
source
)
{
const
uglifyResult
=
UglifyJS
.
minify
(
source
,
{});
const
uglifyResult
=
UglifyJS
__default
[
'default'
]
.
minify
(
source
,
{});
if
(
uglifyResult
.
error
)
{
throw
new
Error
(
uglifyResult
.
error
);
}
else
{
...
...
@@ -59,9 +61,14 @@
}
}
function
fillTpl
(
data
,
params
)
{
function
fillTpl
(
data
,
params
,
mix
)
{
const
{
options
}
=
data
;
params
.
scripts
=
params
.
scripts
.
map
(
item
=>
zeroingTemplateFill
.
generateJsScriptEl
(
item
)).
join
(
'
\
n'
);
if
(
mix
)
{
let
code
=
'var adsComplete=false;ga.showBanner(function(){adsComplete=true},'
+
params
.
scripts
.
map
(
item
=>
`'
${
item
}
'`
).
join
(
','
)
+
');'
;
params
.
scripts
=
zeroingTemplateFill
.
generateJsScriptBodyEl
(
code
);
}
else
{
params
.
scripts
=
params
.
scripts
.
map
(
item
=>
zeroingTemplateFill
.
generateJsScriptEl
(
item
)).
join
(
'
\
n'
);
}
let
tpl
=
zeroingTemplateFill
.
fillTemplate
(
options
.
newTpl
,
params
);
delete
options
.
newTpl
;
...
...
@@ -72,7 +79,7 @@
return
tpl
;
}
async
function
packData
(
data
,
{
debug
,
packedAssets
,
getPackages
})
{
async
function
packData
(
data
,
{
debug
,
mix
,
packedAssets
,
getPackages
})
{
let
newData
=
{};
newData
.
options
=
data
.
options
;
newData
.
views
=
data
.
views
;
...
...
@@ -94,7 +101,7 @@
if
(
computed
)
{
for
(
let
item
of
computed
)
{
if
(
item
.
script
)
{
item
.
script
=
(
await
compile
(
item
.
script
)).
code
;
item
.
script
=
(
await
compile
(
item
.
script
)).
code
;
}
}
}
...
...
@@ -107,6 +114,7 @@
customScriptContent
,
}
=
await
zeroingCodeDivider
.
divideCode
(
newData
,
{
debug
,
mix
,
uglify
,
compile
,
getPackages
,
dependencies
:
data
.
dependencies
,
...
...
@@ -157,5 +165,5 @@
Object
.
defineProperty
(
exports
,
'__esModule'
,
{
value
:
true
});
}));
}))
)
;
//# sourceMappingURL=index.umd.js.map
dist/index.umd.js.map
View file @
4f9a7485
{
"version"
:
3
,
"file"
:
"index.umd.js"
,
"sources"
:
[
"../src/code-process.js"
,
"../src/index.js"
],
"sourcesContent"
:
[
"/**
\n
* Created by rockyl on 2019-11-30.
\n
*/
\n\n
import ts from 'typescript';
\n
import UglifyJS from 'uglify-js';
\n\n
export async function compile(source, debug = false) {\n
\t
let output = ts.transpileModule(source, {\n
\t\t
compilerOptions:
{
}\n\t
}
);
\n\n\t
const result = {\n
\t\t
code: output.outputText,
\n\t
};
\n\t
/*if (map) {\n
\t\t
result.sourcemap = map.mappings;
\n\t
}*/
\n\t
return result;
\n
}
\n\n
export function uglify(source) {\n
\t
const uglifyResult = UglifyJS.minify(source, {});
\n\t
if (uglifyResult.error) {\n
\t\t
throw new Error(uglifyResult.error);
\n\t
} else {\n
\t\t
return uglifyResult.code;
\n\t
}
\n
}"
,
"/**
\n
* Created by rockyl on 2019-11-13.
\n
*
\n
* 项目打包
\n
*/
\n\n
import {uglify, compile} from
\"
./code-process
\"
;
\n
import
{
divideCode
}
from 'zeroing-code-divider';
\n
import {generateLibraryScriptEl, fillTemplate, generateJsScriptEl} from 'zeroing-template-fill';
\n\n
const replaceFields = ['pageTitle', 'containerId'];
\n
const TAG = 'zeroing-pack';
\n\n
export async function pack(data, options) {\n
\t
let dependencies = data.dependencies;
\n\t
let getPackages = options.getPackages;
\n\n\t
const {libraryScriptElMap, analyseResult} = await generateLibraryScriptEl(data.options.tpl, dependencies, getPackages, '//yun.duiba.com.cn/editor/zeroing/libs/', options.debug);
\n\n\t
let version = Date.now() + Math.floor(Math.random() * 1000);
\n\t
pageTemplate(data, data.options, version, analyseResult, libraryScriptElMap);
\n\t
const newData = await packData(data, options);
\n\n\t
return {\n
\t\t
version,
\n\t\t
data: newData,
\n\t
}
\n
}
\n\n
export function fillTpl(data, params) {\n
\t
const
{
options
}
= data;
\n\t
params.scripts = params.scripts.map(item => generateJsScriptEl(item)).join('
\\
n');
\n\t
let tpl = fillTemplate(options.newTpl, params);
\n\n\t
delete options.newTpl;
\n\t
delete options.tpl;
\n\t
delete options.projectxConfig;
\n\t
delete options.pxEnv;
\n\n\t
return tpl;
\n
}
\n\n
async function packData(data, {debug, packedAssets, getPackages}) {\n
\t
let newData = {};
\n\t
newData.options = data.options;
\n\t
newData.views = data.views;
\n\t
newData.assets = packedAssets || data.assets;
\n\t
newData.dataMapping = data.dataMapping;
\n\t
newData.processes = data.processes;
\n\t
newData.customs = data.customs;
\n\n\t
deleteUnusedData(newData.processes);
\n\n\t
console.log(TAG, 'start');
\n\n\t
for (let view of newData.views) {\n
\t\t
if (view.store) {\n
\t\t\t
let {exp, computed} = view.store;
\n\t\t\t
if (exp) {\n
\t\t\t\t
view.store.exp = (await compile(exp)).code;
\n\t\t\t
}
\n\t\t\t
if (computed) {\n
\t\t\t\t
for (let item of computed) {\n
\t\t\t\t\t
if (item.script) {\n
\t\t\t\t\t\t
item.script = (await compile(item.script)).code;
\n\t\t\t\t\t
}
\n\t\t\t\t
}
\n\t\t\t
}
\n\t\t
}
\n\t
}
\n\n\t
const
{
\n\t\tprocessScriptContent,\n\t\tscriptsContent,\n\t\tcustomScriptContent,\n\t
}
= await divideCode(newData, {\n
\t\t
debug,
\n\t\t
uglify, compile,
\n\t\t
getPackages,
\n\t\t
dependencies: data.dependencies,
\n\t
});
\n\n\t
return {\n
\t\t
data: newData,
\n\t\t
processScriptContent,
\n\t\t
scriptsContent,
\n\t\t
customScriptContent,
\n\t
};
\n
}
\n\n
const unusedFields = ['design'];
\n\n
function deleteUnusedData(processes) {\n
\t
for (let process of processes) {\n
\t\t
if (process.sub) {\n
\t\t\t
for (let uuid in process.sub) {\n
\t\t\t\t
let subProcess = process.sub[uuid];
\n\t\t\t\t
for (let field of unusedFields) {\n
\t\t\t\t\t
if (subProcess.hasOwnProperty(field)) {\n
\t\t\t\t\t\t
delete subProcess[field];
\n\t\t\t\t\t
}
\n\t\t\t\t
}
\n\t\t\t
}
\n\t\t
}
\n\t\t
if (process.metas && process.metas.length > 0)
{
\n\t\t\tdeleteUnusedData(process.metas);\n\t\t}\n\t}\n
}
\n\n
function pageTemplate(tpl, options, version, analyseResult, libraryScriptElMap) {\n
\t
const params = {\n
\t\t
version,
\n\t\t
libraries: libraryScriptElMap,
\n\t
};
\n\t
for (let field of replaceFields) {\n
\t\t
params[field] = options[field];
\n\t
}
\n\n\t
options.newTpl = fillTemplate(options.tpl, params, analyseResult);
\n
}
\n
"
],
"names"
:
[
"generateLibraryScriptEl"
,
"generateJsScriptEl"
,
"fillTemplate"
,
"divideCode"
],
"mappings"
:
";;;;;;;;;CAAA;CACA;CACA;AACA,AAGA;AACA,CAAO,eAAe,OAAO,CAAC,MAAM,EAAE,KAAK,GAAG,KAAK,EAAE;CACrD,CAAC,IAAI,MAAM,GAAG,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE;CACzC,EAAE,eAAe,EAAE,EAAE;CACrB,EAAE,CAAC,CAAC;;CAEJ,CAAC,MAAM,MAAM,GAAG;CAChB,EAAE,IAAI,EAAE,MAAM,CAAC,UAAU;CACzB,EAAE,CAAC;CACH;CACA;CACA;CACA,CAAC,OAAO,MAAM,CAAC;CACf,CAAC;;AAED,CAAO,SAAS,MAAM,CAAC,MAAM,EAAE;CAC/B,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;CAClD,CAAC,IAAI,YAAY,CAAC,KAAK,EAAE;CACzB,EAAE,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CAC/B,MAAM;CACN,KAAK;CACL,IAAI;CACJ,GAAG;CACH,EAAE,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;CACjD,GAAG,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;CACnC,GAAG;CACH,EAAE;CACF,CAAC;;CAED,SAAS,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE;CAChF,CAAC,MAAM,MAAM,GAAG;CAChB,EAAE,OAAO;CACT,EAAE,SAAS,EAAE,kBAAkB;CAC/B,EAAE,CAAC;CACH,CAAC,KAAK,IAAI,KAAK,IAAI,aAAa,EAAE;CAClC,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;CACjC,EAAE;;CAEF,CAAC,OAAO,CAAC,MAAM,GAAGD,gCAAY,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;CACnE,CAAC;;;;;;;;;;;;;"
}
\ No newline at end of file
{
"version"
:
3
,
"file"
:
"index.umd.js"
,
"sources"
:
[
"../src/code-process.js"
,
"../src/index.js"
],
"sourcesContent"
:
[
"/**
\n
* Created by rockyl on 2019-11-30.
\n
*/
\n\n
import ts from 'typescript';
\n
import UglifyJS from 'uglify-js';
\n\n
export async function compile(source, debug = false) {\n
\t
let output = ts.transpileModule(source, {\n
\t\t
compilerOptions:
{
}\n\t
}
);
\n\n\t
const result = {\n
\t\t
code: output.outputText,
\n\t
};
\n\t
/*if (map) {\n
\t\t
result.sourcemap = map.mappings;
\n\t
}*/
\n\t
return result;
\n
}
\n\n
export function uglify(source) {\n
\t
const uglifyResult = UglifyJS.minify(source, {});
\n\t
if (uglifyResult.error) {\n
\t\t
throw new Error(uglifyResult.error);
\n\t
} else {\n
\t\t
return uglifyResult.code;
\n\t
}
\n
}"
,
"/**
\n
* Created by rockyl on 2019-11-13.
\n
*
\n
* 项目打包
\n
*/
\n\n
import {uglify, compile} from
\"
./code-process
\"
;
\n
import
{
divideCode
}
from 'zeroing-code-divider';
\n
import {generateLibraryScriptEl, fillTemplate, generateJsScriptEl, generateJsScriptBodyEl} from 'zeroing-template-fill';
\n\n
const replaceFields = ['pageTitle', 'containerId'];
\n
const TAG = 'zeroing-pack';
\n\n
export async function pack(data, options) {\n
\t
let dependencies = data.dependencies;
\n\t
let getPackages = options.getPackages;
\n\n\t
const {libraryScriptElMap, analyseResult} = await generateLibraryScriptEl(data.options.tpl, dependencies, getPackages, '//yun.duiba.com.cn/editor/zeroing/libs/', options.debug);
\n\n\t
let version = Date.now() + Math.floor(Math.random() * 1000);
\n\t
pageTemplate(data, data.options, version, analyseResult, libraryScriptElMap);
\n\t
const newData = await packData(data, options);
\n\n\t
return {\n
\t\t
version,
\n\t\t
data: newData,
\n\t
}
\n
}
\n\n
export function fillTpl(data, params, mix) {\n
\t
const
{
options
}
= data;
\n\t
if (mix) {\n
\t\t
let code = 'var adsComplete=false;ga.showBanner(function()
{
adsComplete=true
}
,' + params.scripts.map(item => `'${item}'`).join(',') + ');';
\n\t\t
params.scripts = generateJsScriptBodyEl(code);
\n\t
} else {\n
\t\t
params.scripts = params.scripts.map(item => generateJsScriptEl(item)).join('
\\
n')
\n\t
}
\n\t
let tpl = fillTemplate(options.newTpl, params);
\n\n\t
delete options.newTpl;
\n\t
delete options.tpl;
\n\t
delete options.projectxConfig;
\n\t
delete options.pxEnv;
\n\n\t
return tpl;
\n
}
\n\n
async function packData(data, {debug, mix, packedAssets, getPackages}) {\n
\t
let newData = {};
\n\t
newData.options = data.options;
\n\t
newData.views = data.views;
\n\t
newData.assets = packedAssets || data.assets;
\n\t
newData.dataMapping = data.dataMapping;
\n\t
newData.processes = data.processes;
\n\t
newData.customs = data.customs;
\n\n\t
deleteUnusedData(newData.processes);
\n\n\t
console.log(TAG, 'start');
\n\n\t
for (let view of newData.views) {\n
\t\t
if (view.store) {\n
\t\t\t
let {exp, computed} = view.store;
\n\t\t\t
if (exp) {\n
\t\t\t\t
view.store.exp = (await compile(exp)).code;
\n\t\t\t
}
\n\t\t\t
if (computed) {\n
\t\t\t\t
for (let item of computed) {\n
\t\t\t\t\t
if (item.script) {\n
\t\t\t\t\t\t
item.script = (await compile(item.script)).code;
\n\t\t\t\t\t
}
\n\t\t\t\t
}
\n\t\t\t
}
\n\t\t
}
\n\t
}
\n\n\t
const
{
\n\t\tprocessScriptContent,\n\t\tscriptsContent,\n\t\tcustomScriptContent,\n\t
}
= await divideCode(newData, {\n
\t\t
debug,
\n\t\t
mix,
\n\t\t
uglify, compile,
\n\t\t
getPackages,
\n\t\t
dependencies: data.dependencies,
\n\t
});
\n\n\t
return {\n
\t\t
data: newData,
\n\t\t
processScriptContent,
\n\t\t
scriptsContent,
\n\t\t
customScriptContent,
\n\t
};
\n
}
\n\n
const unusedFields = ['design'];
\n\n
function deleteUnusedData(processes) {\n
\t
for (let process of processes) {\n
\t\t
if (process.sub) {\n
\t\t\t
for (let uuid in process.sub) {\n
\t\t\t\t
let subProcess = process.sub[uuid];
\n\t\t\t\t
for (let field of unusedFields) {\n
\t\t\t\t\t
if (subProcess.hasOwnProperty(field)) {\n
\t\t\t\t\t\t
delete subProcess[field];
\n\t\t\t\t\t
}
\n\t\t\t\t
}
\n\t\t\t
}
\n\t\t
}
\n\t\t
if (process.metas && process.metas.length > 0)
{
\n\t\t\tdeleteUnusedData(process.metas);\n\t\t}\n\t}\n
}
\n\n
function pageTemplate(tpl, options, version, analyseResult, libraryScriptElMap) {\n
\t
const params = {\n
\t\t
version,
\n\t\t
libraries: libraryScriptElMap,
\n\t
};
\n\t
for (let field of replaceFields) {\n
\t\t
params[field] = options[field];
\n\t
}
\n\n\t
options.newTpl = fillTemplate(options.tpl, params, analyseResult);
\n
}
\n
"
],
"names"
:
[
"ts"
,
"UglifyJS"
,
"generateLibraryScriptEl"
,
"generateJsScriptBodyEl"
,
"generateJsScriptEl"
,
"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O,EAAE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE;CAChF,CAAC,MAAM,MAAM,GAAG;CAChB,EAAE,OAAO;CACT,EAAE,SAAS,EAAE,kBAAkB;CAC/B,EAAE,CAAC;CACH,CAAC,KAAK,IAAI,KAAK,IAAI,aAAa,EAAE;CAClC,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;CACjC,EAAE;AACF;CACA,CAAC,OAAO,CAAC,MAAM,GAAGD,gCAAY,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;CACnE;;;;;;;;;;;;;"
}
\ No newline at end of file
src/index.js
View file @
4f9a7485
...
...
@@ -6,7 +6,7 @@
import
{
uglify
,
compile
}
from
"./code-process"
;
import
{
divideCode
}
from
'zeroing-code-divider'
;
import
{
generateLibraryScriptEl
,
fillTemplate
,
generateJsScriptEl
}
from
'zeroing-template-fill'
;
import
{
generateLibraryScriptEl
,
fillTemplate
,
generateJsScriptEl
,
generateJsScriptBodyEl
}
from
'zeroing-template-fill'
;
const
replaceFields
=
[
'pageTitle'
,
'containerId'
];
const
TAG
=
'zeroing-pack'
;
...
...
@@ -27,9 +27,14 @@ export async function pack(data, options) {
}
}
export
function
fillTpl
(
data
,
params
)
{
export
function
fillTpl
(
data
,
params
,
mix
)
{
const
{
options
}
=
data
;
params
.
scripts
=
params
.
scripts
.
map
(
item
=>
generateJsScriptEl
(
item
)).
join
(
'
\
n'
);
if
(
mix
)
{
let
code
=
'var adsComplete=false;ga.showBanner(function(){adsComplete=true},'
+
params
.
scripts
.
map
(
item
=>
`'
${
item
}
'`
).
join
(
','
)
+
');'
;
params
.
scripts
=
generateJsScriptBodyEl
(
code
);
}
else
{
params
.
scripts
=
params
.
scripts
.
map
(
item
=>
generateJsScriptEl
(
item
)).
join
(
'
\
n'
)
}
let
tpl
=
fillTemplate
(
options
.
newTpl
,
params
);
delete
options
.
newTpl
;
...
...
@@ -40,7 +45,7 @@ export function fillTpl(data, params) {
return
tpl
;
}
async
function
packData
(
data
,
{
debug
,
packedAssets
,
getPackages
})
{
async
function
packData
(
data
,
{
debug
,
mix
,
packedAssets
,
getPackages
})
{
let
newData
=
{};
newData
.
options
=
data
.
options
;
newData
.
views
=
data
.
views
;
...
...
@@ -62,7 +67,7 @@ async function packData(data, {debug, packedAssets, getPackages}) {
if
(
computed
)
{
for
(
let
item
of
computed
)
{
if
(
item
.
script
)
{
item
.
script
=
(
await
compile
(
item
.
script
)).
code
;
item
.
script
=
(
await
compile
(
item
.
script
)).
code
;
}
}
}
...
...
@@ -75,6 +80,7 @@ async function packData(data, {debug, packedAssets, getPackages}) {
customScriptContent
,
}
=
await
divideCode
(
newData
,
{
debug
,
mix
,
uglify
,
compile
,
getPackages
,
dependencies
:
data
.
dependencies
,
...
...
yarn.lock
View file @
4f9a7485
...
...
@@ -4,8 +4,12 @@
camelcase@^5.3.1:
version "5.3.1"
resolved "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320"
integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==
resolved "https://registry.npm.taobao.org/camelcase/download/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320"
integrity sha1-48mzFWnhBoEd8kL3FXJaH0xJQyA=
"code-mix@http://gitlab2.dui88.com/laoqifeng/code-mix.git":
version "1.0.0"
resolved "http://gitlab2.dui88.com/laoqifeng/code-mix.git#b39b10d6dbe8796b7bb8ad0b0303dda5bd470166"
commander@~2.20.3:
version "2.20.3"
...
...
@@ -14,7 +18,7 @@ commander@~2.20.3:
"props-compute@http://gitlab2.dui88.com/laoqifeng/props-compute.git":
version "1.0.0"
resolved "http://gitlab2.dui88.com/laoqifeng/props-compute.git#
8ef14521dd1ed4148999b23871e93000a9d4fc88
"
resolved "http://gitlab2.dui88.com/laoqifeng/props-compute.git#
e293595fc82a9e38f989297bf549aafd1ab9b404
"
source-map@~0.6.1:
version "0.6.1"
...
...
@@ -36,12 +40,13 @@ uglify-js@^3.7.1:
"zeroing-code-divider@http://gitlab2.dui88.com/laoqifeng/zeroing-code-divider.git":
version "1.0.1"
resolved "http://gitlab2.dui88.com/laoqifeng/zeroing-code-divider.git#
2ab6ba47c6657c5f5fca63f99df09cafc80de6cd
"
resolved "http://gitlab2.dui88.com/laoqifeng/zeroing-code-divider.git#
33c2aa582d99010039d0f45cd19c9b3c4b591da6
"
dependencies:
code-mix "http://gitlab2.dui88.com/laoqifeng/code-mix.git"
props-compute "http://gitlab2.dui88.com/laoqifeng/props-compute.git"
"zeroing-template-fill@http://gitlab2.dui88.com/laoqifeng/zeroing-template-fill.git":
version "1.0.0"
resolved "http://gitlab2.dui88.com/laoqifeng/zeroing-template-fill.git#
2191ce9acc9d2ecdc7ab6510c6ca6c68339f47db
"
resolved "http://gitlab2.dui88.com/laoqifeng/zeroing-template-fill.git#
143e862639493dee94ab5973ab9895d116bdc7c5
"
dependencies:
camelcase "^5.3.1"
zeroing-pack.iml
View file @
4f9a7485
...
...
@@ -2,7 +2,10 @@
<module
type=
"WEB_MODULE"
version=
"4"
>
<component
name=
"NewModuleRootManager"
inherit-compiler-output=
"true"
>
<exclude-output
/>
<content
url=
"file://$MODULE_DIR$/../zeroing-pack"
/>
<content
url=
"file://$MODULE_DIR$"
>
<excludeFolder
url=
"file://$MODULE_DIR$/dist"
/>
</content>
<orderEntry
type=
"inheritedJdk"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
</component>
</module>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment