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
Expand all
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
This diff is collapsed.
Click to expand it.
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
This diff is collapsed.
Click to expand it.
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
This diff is collapsed.
Click to expand it.
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