w-data-html-minify 1.0.0

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.
Files changed (62) hide show
  1. package/.editorconfig +9 -0
  2. package/.eslintignore +3 -0
  3. package/.eslintrc.js +55 -0
  4. package/.jsdoc +25 -0
  5. package/README.md +36 -0
  6. package/SECURITY.md +5 -0
  7. package/babel.config.js +15 -0
  8. package/dist/w-data-html-minify.umd.js +7 -0
  9. package/dist/w-data-html-minify.umd.js.map +1 -0
  10. package/docs/WDataHtmlMinify.mjs.html +134 -0
  11. package/docs/examples/ex-html-minify.html +94 -0
  12. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  13. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  14. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  15. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  16. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  17. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  18. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  19. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  20. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  21. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  22. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  23. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  24. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  25. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  26. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  27. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  28. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  29. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  30. package/docs/global.html +459 -0
  31. package/docs/htmlminifier.js.html +26278 -0
  32. package/docs/importHtmlminify.mjs.html +107 -0
  33. package/docs/index.html +84 -0
  34. package/docs/scripts/collapse.js +39 -0
  35. package/docs/scripts/commonNav.js +28 -0
  36. package/docs/scripts/linenumber.js +25 -0
  37. package/docs/scripts/nav.js +12 -0
  38. package/docs/scripts/polyfill.js +4 -0
  39. package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  40. package/docs/scripts/prettify/lang-css.js +2 -0
  41. package/docs/scripts/prettify/prettify.js +28 -0
  42. package/docs/scripts/search.js +99 -0
  43. package/docs/styles/jsdoc.css +776 -0
  44. package/docs/styles/prettify.css +80 -0
  45. package/examples/ex-html-minify.html +94 -0
  46. package/g.test.minify.mjs +15 -0
  47. package/package.json +31 -0
  48. package/src/WDataHtmlMinify.mjs +62 -0
  49. package/src/_convertHtmlminifierCode.mjs +24 -0
  50. package/src/_htmlminifierCoreBrowser.mjs +1 -0
  51. package/src/_importHtmlminifierBrowser.mjs +46 -0
  52. package/src/_importHtmlminifierNode.mjs +7 -0
  53. package/src/htmlminifier.js +26206 -0
  54. package/src/htmlminifier.min.js +7 -0
  55. package/src/importHtmlminify.mjs +35 -0
  56. package/src/rq.js +3 -0
  57. package/test/all.test.mjs +20 -0
  58. package/toolg/addVersion.mjs +4 -0
  59. package/toolg/cleanFolder.mjs +4 -0
  60. package/toolg/gDistRollup.mjs +46 -0
  61. package/toolg/gDocsExams.mjs +48 -0
  62. package/toolg/modifyReadme.mjs +4 -0
@@ -0,0 +1,35 @@
1
+ import isWindow from 'wsemi/src/isWindow.mjs'
2
+ import htmlminifierBrowser from './_importHtmlminifierBrowser.mjs'
3
+ import htmlminifierNode from './_importHtmlminifierNode.mjs'
4
+
5
+
6
+ /**
7
+ * 取得引用htmlminifier物件
8
+ *
9
+ * Unit Test: {@link https://github.com/yuda-lyu/w-data-html-minify/blob/master/test/importHtmlminify.test.mjs Github}
10
+ * @memberOf w-data-html-minify
11
+ * @returns {Object} 回傳htmlminifier物件
12
+ * @example
13
+ *
14
+ * let r = importHtmlminify
15
+ * console.log(r)
16
+ * // => [Function (anonymous)]
17
+ *
18
+ */
19
+ let htmlminifier = null
20
+ function protectShell() {
21
+
22
+ if (isWindow()) {
23
+ // console.log('use htmlminifierBrowser')
24
+ htmlminifier = htmlminifierBrowser
25
+ }
26
+ else {
27
+ // console.log('use htmlminifierNode')
28
+ htmlminifier = htmlminifierNode
29
+ }
30
+ // console.log('htmlminifier', htmlminifier)
31
+
32
+ }
33
+ protectShell()
34
+
35
+ export default htmlminifier
package/src/rq.js ADDED
@@ -0,0 +1,3 @@
1
+ let minify = require('html-minifier').minify
2
+
3
+ exports.minify = minify
@@ -0,0 +1,20 @@
1
+ import assert from 'assert'
2
+ import wdhm from '../src/WDataHtmlMinify.mjs'
3
+
4
+
5
+ describe('all', function() {
6
+
7
+ let hin = `
8
+ <html>
9
+ <head></head>
10
+ <body>abc</body>
11
+ </html>
12
+ `
13
+ let hout = `<html><head></head><body>abc</body></html>`
14
+
15
+ it(`should return ${hout} when input ${hin}`, function() {
16
+ let r = wdhm(hin)
17
+ assert.strict.deepEqual(hout, r)
18
+ })
19
+
20
+ })
@@ -0,0 +1,4 @@
1
+ import addVersion from 'w-package-tools/src/addVersion.mjs'
2
+
3
+
4
+ addVersion()
@@ -0,0 +1,4 @@
1
+ import cleanFolder from 'w-package-tools/src/cleanFolder.mjs'
2
+
3
+
4
+ cleanFolder('docs')
@@ -0,0 +1,46 @@
1
+ // import path from 'path'
2
+ import rollupFiles from 'w-package-tools/src/rollupFiles.mjs'
3
+
4
+
5
+ let fdSrc = './src'
6
+ let fdTar = './dist'
7
+
8
+
9
+ async function rp() {
10
+
11
+ await rollupFiles({ //rollupFiles預設會clean folder
12
+ fns: 'WDataHtmlMinify.mjs',
13
+ fdSrc,
14
+ fdTar,
15
+ nameDistType: 'kebabCase',
16
+ // bNodePolyfill: true,
17
+ // bMinify: false,
18
+ globals: {
19
+ 'html-minifier': 'html-minifier', //編譯給前端用的html-minifier為官方打包後js檔(轉b64再於前端載入), 不使用node版故需剔除
20
+ 'os': 'os',
21
+ 'http': 'http',
22
+ 'https': 'https',
23
+ 'url': 'url',
24
+ 'path': 'path',
25
+ 'fs': 'fs',
26
+ },
27
+ external: [
28
+ 'html-minifier',
29
+ 'os',
30
+ 'http',
31
+ 'https',
32
+ 'url',
33
+ 'path',
34
+ 'fs',
35
+ ],
36
+ })
37
+ .catch((err) => {
38
+ console.log(err)
39
+ })
40
+
41
+ }
42
+ rp()
43
+ .catch((err) => {
44
+ console.log(err)
45
+ })
46
+
@@ -0,0 +1,48 @@
1
+ import fs from 'fs'
2
+ import _ from 'lodash'
3
+ import getFiles from 'w-package-tools/src/getFiles.mjs'
4
+ import getPks from 'w-package-tools/src/getPks.mjs'
5
+
6
+
7
+ let fdSrc = './examples/'
8
+ let fdTar = './docs/examples/'
9
+
10
+
11
+ function main() {
12
+ //把example裡面cdn更換, 再複製到docs的example內, 作為日後發佈為靜態網站
13
+
14
+ //pks
15
+ let pks = getPks()
16
+
17
+ //url
18
+ let url = `https://cdn.jsdelivr.net/npm/w-data-html-minify@${pks.version}/dist/w-data-html-minify.umd.js`
19
+
20
+ //mkdirSync
21
+ if (!fs.existsSync(fdTar)) {
22
+ fs.mkdirSync(fdTar)
23
+ }
24
+
25
+ //getFiles
26
+ let ltfs = getFiles(fdSrc)
27
+
28
+ _.each(ltfs, function(v) {
29
+
30
+ //fn
31
+ let fn = fdSrc + v
32
+
33
+ //c
34
+ let c = fs.readFileSync(fn, 'utf8')
35
+
36
+ //replace
37
+ let r
38
+ r = `../dist/w-data-html-minify.umd.js`
39
+ c = c.replace(r, url)
40
+
41
+ //write
42
+ //console.log(c)
43
+ fs.writeFileSync(fdTar + v, c, 'utf8')
44
+
45
+ })
46
+
47
+ }
48
+ main()
@@ -0,0 +1,4 @@
1
+ import modifyReadme from 'w-package-tools/src/modifyReadme.mjs'
2
+
3
+
4
+ modifyReadme()