w-md2docx 1.0.0 → 1.0.2

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/docs/index.html CHANGED
@@ -29,7 +29,7 @@
29
29
  <nav >
30
30
 
31
31
 
32
- <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#ApiServer">ApiServer</a></li><li><a href="global.html#WMd2docx">WMd2docx</a></li><li><a href="global.html#checkDocxReady">checkDocxReady</a></li><li><a href="global.html#cleanWorkDir">cleanWorkDir</a></li><li><a href="global.html#cvMdTo">cvMdTo</a></li><li><a href="global.html#cvMdToDocx">cvMdToDocx</a></li><li><a href="global.html#getFpExe">getFpExe</a></li><li><a href="global.html#getQueueSize">getQueueSize</a></li><li><a href="global.html#health">health</a></li><li><a href="global.html#readAssets">readAssets</a></li><li><a href="global.html#resolveAssetPaths">resolveAssetPaths</a></li><li><a href="global.html#retryBusy">retryBusy</a></li><li><a href="global.html#runExclusive">runExclusive</a></li><li><a href="global.html#scanAssetPaths">scanAssetPaths</a></li><li><a href="global.html#toErrText">toErrText</a></li><li><a href="global.html#toSafeName">toSafeName</a></li><li><a href="global.html#transErrAsset">transErrAsset</a></li><li><a href="global.html#writeAssets">writeAssets</a></li></ul>
32
+ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#WMd2docx">WMd2docx</a></li><li><a href="global.html#checkDocxReady">checkDocxReady</a></li><li><a href="global.html#cleanWorkDir">cleanWorkDir</a></li><li><a href="global.html#cvMdTo">cvMdTo</a></li><li><a href="global.html#cvMdToDocx">cvMdToDocx</a></li><li><a href="global.html#getFpExe">getFpExe</a></li><li><a href="global.html#getQueueSize">getQueueSize</a></li><li><a href="global.html#health">health</a></li><li><a href="global.html#readAssets">readAssets</a></li><li><a href="global.html#resolveAssetPaths">resolveAssetPaths</a></li><li><a href="global.html#retryBusy">retryBusy</a></li><li><a href="global.html#rmApiServer">rmApiServer</a></li><li><a href="global.html#runExclusive">runExclusive</a></li><li><a href="global.html#scanAssetPaths">scanAssetPaths</a></li><li><a href="global.html#toErrText">toErrText</a></li><li><a href="global.html#toSafeName">toSafeName</a></li><li><a href="global.html#transErrAsset">transErrAsset</a></li><li><a href="global.html#writeAssets">writeAssets</a></li></ul>
33
33
 
34
34
  </nav>
35
35
 
@@ -71,7 +71,7 @@
71
71
  <br class="clear">
72
72
 
73
73
  <footer>
74
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Tue Sep 01 2026 16:40:03 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
74
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Wed Sep 02 2026 16:38:11 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
75
75
  </footer>
76
76
 
77
77
  <script>prettyPrint();</script>
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
 
5
5
  <meta charset="utf-8">
6
- <title>ApiClient.mjs - Documentation</title>
6
+ <title>rmApiClient.mjs - Documentation</title>
7
7
 
8
8
 
9
9
  <script src="scripts/prettify/prettify.js"></script>
@@ -29,13 +29,13 @@
29
29
  <nav >
30
30
 
31
31
 
32
- <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#ApiServer">ApiServer</a></li><li><a href="global.html#WMd2docx">WMd2docx</a></li><li><a href="global.html#checkDocxReady">checkDocxReady</a></li><li><a href="global.html#cleanWorkDir">cleanWorkDir</a></li><li><a href="global.html#cvMdTo">cvMdTo</a></li><li><a href="global.html#cvMdToDocx">cvMdToDocx</a></li><li><a href="global.html#getFpExe">getFpExe</a></li><li><a href="global.html#getQueueSize">getQueueSize</a></li><li><a href="global.html#health">health</a></li><li><a href="global.html#readAssets">readAssets</a></li><li><a href="global.html#resolveAssetPaths">resolveAssetPaths</a></li><li><a href="global.html#retryBusy">retryBusy</a></li><li><a href="global.html#runExclusive">runExclusive</a></li><li><a href="global.html#scanAssetPaths">scanAssetPaths</a></li><li><a href="global.html#toErrText">toErrText</a></li><li><a href="global.html#toSafeName">toSafeName</a></li><li><a href="global.html#transErrAsset">transErrAsset</a></li><li><a href="global.html#writeAssets">writeAssets</a></li></ul>
32
+ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#WMd2docx">WMd2docx</a></li><li><a href="global.html#checkDocxReady">checkDocxReady</a></li><li><a href="global.html#cleanWorkDir">cleanWorkDir</a></li><li><a href="global.html#cvMdTo">cvMdTo</a></li><li><a href="global.html#cvMdToDocx">cvMdToDocx</a></li><li><a href="global.html#getFpExe">getFpExe</a></li><li><a href="global.html#getQueueSize">getQueueSize</a></li><li><a href="global.html#health">health</a></li><li><a href="global.html#readAssets">readAssets</a></li><li><a href="global.html#resolveAssetPaths">resolveAssetPaths</a></li><li><a href="global.html#retryBusy">retryBusy</a></li><li><a href="global.html#rmApiServer">rmApiServer</a></li><li><a href="global.html#runExclusive">runExclusive</a></li><li><a href="global.html#scanAssetPaths">scanAssetPaths</a></li><li><a href="global.html#toErrText">toErrText</a></li><li><a href="global.html#toSafeName">toSafeName</a></li><li><a href="global.html#transErrAsset">transErrAsset</a></li><li><a href="global.html#writeAssets">writeAssets</a></li></ul>
33
33
 
34
34
  </nav>
35
35
 
36
36
  <div id="main">
37
37
 
38
- <h1 class="page-title">ApiClient.mjs</h1>
38
+ <h1 class="page-title">rmApiClient.mjs</h1>
39
39
 
40
40
 
41
41
 
@@ -61,7 +61,7 @@ import fsIsFile from 'wsemi/src/fsIsFile.mjs'
61
61
  import { toErrText } from './utils.mjs'
62
62
 
63
63
 
64
- //hostDef, portDef: 服務位置預設值(與 ApiServer 預設埠一致)
64
+ //hostDef, portDef: 服務位置預設值(與 rmApiServer 預設埠一致)
65
65
  let hostDef = '127.0.0.1'
66
66
  let portDef = 22000
67
67
 
@@ -227,7 +227,7 @@ function readAssets(md, dirMd) {
227
227
  /**
228
228
  * 將本機Markdown檔送至轉檔服務,取回並寫出Html與(或)Docx
229
229
  *
230
- * 供無Microsoft Word之機器產製docx:讀取本機md與其引用之圖片,送至ApiServer轉檔後寫回本機。連線層失敗會自動重試;逾時與HTTP錯誤不重試。
230
+ * 供無Microsoft Word之機器產製docx:讀取本機md與其引用之圖片,送至rmApiServer轉檔後寫回本機。連線層失敗會自動重試;逾時與HTTP錯誤不重試。
231
231
  *
232
232
  * @param {Object} [opt={}] 輸入設定物件,預設{}
233
233
  * @param {String} [opt.host='127.0.0.1'] 輸入服務主機位址(ip或網域)字串,未給則取環境變數WMD2DOCX_HOST,再無則用'127.0.0.1',預設'127.0.0.1'
@@ -248,7 +248,7 @@ function readAssets(md, dirMd) {
248
248
  * @returns {Promise} 回傳Promise,resolve回傳結果物件{ms,nAssets,template,[html],[docx]},其中html與docx為{fp,size},reject回傳錯誤訊息
249
249
  * @example
250
250
  *
251
- * import { cvMdTo } from 'w-md2docx/src/ApiClient.mjs'
251
+ * import { cvMdTo } from 'w-md2docx/src/rmApiClient.mjs'
252
252
  *
253
253
  * let r = await cvMdTo({
254
254
  * host: '127.0.0.1',
@@ -457,7 +457,7 @@ async function cvMdTo(opt = {}) {
457
457
  * @returns {Promise} 回傳Promise,resolve回傳服務端回傳之狀態物件,reject回傳錯誤訊息
458
458
  * @example
459
459
  *
460
- * import { health } from 'w-md2docx/src/ApiClient.mjs'
460
+ * import { health } from 'w-md2docx/src/rmApiClient.mjs'
461
461
  *
462
462
  * let r = await health({ host: '127.0.0.1', port: 22000 })
463
463
  * console.log(r)
@@ -502,7 +502,7 @@ async function health(opt = {}) {
502
502
  }
503
503
 
504
504
 
505
- let ApiClient = {
505
+ let rmApiClient = {
506
506
  cvMdTo,
507
507
  health,
508
508
  scanAssetPaths,
@@ -511,7 +511,7 @@ let ApiClient = {
511
511
 
512
512
 
513
513
  export { cvMdTo, health, scanAssetPaths, readAssets }
514
- export default ApiClient
514
+ export default rmApiClient
515
515
  </code></pre>
516
516
  </article>
517
517
  </section>
@@ -526,7 +526,7 @@ export default ApiClient
526
526
  <br class="clear">
527
527
 
528
528
  <footer>
529
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Tue Sep 01 2026 16:40:03 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
529
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Wed Sep 02 2026 16:38:11 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
530
530
  </footer>
531
531
 
532
532
  <script>prettyPrint();</script>
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
 
5
5
  <meta charset="utf-8">
6
- <title>ApiServer.mjs - Documentation</title>
6
+ <title>rmApiServer.mjs - Documentation</title>
7
7
 
8
8
 
9
9
  <script src="scripts/prettify/prettify.js"></script>
@@ -29,13 +29,13 @@
29
29
  <nav >
30
30
 
31
31
 
32
- <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#ApiServer">ApiServer</a></li><li><a href="global.html#WMd2docx">WMd2docx</a></li><li><a href="global.html#checkDocxReady">checkDocxReady</a></li><li><a href="global.html#cleanWorkDir">cleanWorkDir</a></li><li><a href="global.html#cvMdTo">cvMdTo</a></li><li><a href="global.html#cvMdToDocx">cvMdToDocx</a></li><li><a href="global.html#getFpExe">getFpExe</a></li><li><a href="global.html#getQueueSize">getQueueSize</a></li><li><a href="global.html#health">health</a></li><li><a href="global.html#readAssets">readAssets</a></li><li><a href="global.html#resolveAssetPaths">resolveAssetPaths</a></li><li><a href="global.html#retryBusy">retryBusy</a></li><li><a href="global.html#runExclusive">runExclusive</a></li><li><a href="global.html#scanAssetPaths">scanAssetPaths</a></li><li><a href="global.html#toErrText">toErrText</a></li><li><a href="global.html#toSafeName">toSafeName</a></li><li><a href="global.html#transErrAsset">transErrAsset</a></li><li><a href="global.html#writeAssets">writeAssets</a></li></ul>
32
+ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#WMd2docx">WMd2docx</a></li><li><a href="global.html#checkDocxReady">checkDocxReady</a></li><li><a href="global.html#cleanWorkDir">cleanWorkDir</a></li><li><a href="global.html#cvMdTo">cvMdTo</a></li><li><a href="global.html#cvMdToDocx">cvMdToDocx</a></li><li><a href="global.html#getFpExe">getFpExe</a></li><li><a href="global.html#getQueueSize">getQueueSize</a></li><li><a href="global.html#health">health</a></li><li><a href="global.html#readAssets">readAssets</a></li><li><a href="global.html#resolveAssetPaths">resolveAssetPaths</a></li><li><a href="global.html#retryBusy">retryBusy</a></li><li><a href="global.html#rmApiServer">rmApiServer</a></li><li><a href="global.html#runExclusive">runExclusive</a></li><li><a href="global.html#scanAssetPaths">scanAssetPaths</a></li><li><a href="global.html#toErrText">toErrText</a></li><li><a href="global.html#toSafeName">toSafeName</a></li><li><a href="global.html#transErrAsset">transErrAsset</a></li><li><a href="global.html#writeAssets">writeAssets</a></li></ul>
33
33
 
34
34
  </nav>
35
35
 
36
36
  <div id="main">
37
37
 
38
- <h1 class="page-title">ApiServer.mjs</h1>
38
+ <h1 class="page-title">rmApiServer.mjs</h1>
39
39
 
40
40
 
41
41
 
@@ -121,16 +121,16 @@ function isInputError(msg) {
121
121
  * @returns {Promise} 回傳Promise,resolve回傳{server,settings,getState,stop},其中server為hapi實例,getState為取環境狀態之async函數,stop為停止服務之async函數,reject回傳錯誤訊息
122
122
  * @example
123
123
  *
124
- * import ApiServer from 'w-md2docx/src/ApiServer.mjs'
124
+ * import rmApiServer from 'w-md2docx/src/rmApiServer.mjs'
125
125
  *
126
- * let { server, settings } = await ApiServer({
126
+ * let { server, settings } = await rmApiServer({
127
127
  * port: 22000,
128
128
  * token: '',
129
129
  * })
130
130
  * console.log(`listening on ${server.info.uri}`, settings)
131
131
  *
132
132
  */
133
- async function ApiServer(opt = {}) {
133
+ async function rmApiServer(opt = {}) {
134
134
 
135
135
  //port (0 為由系統自動配置, 供測試等場景避免撞埠; 實際埠號由 server.info.port 取得)
136
136
  let port = get(opt, 'port', null)
@@ -488,7 +488,7 @@ async function ApiServer(opt = {}) {
488
488
  }
489
489
 
490
490
 
491
- export default ApiServer
491
+ export default rmApiServer
492
492
  </code></pre>
493
493
  </article>
494
494
  </section>
@@ -503,7 +503,7 @@ export default ApiServer
503
503
  <br class="clear">
504
504
 
505
505
  <footer>
506
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Tue Sep 01 2026 16:40:03 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
506
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Wed Sep 02 2026 16:38:11 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
507
507
  </footer>
508
508
 
509
509
  <script>prettyPrint();</script>
@@ -29,7 +29,7 @@
29
29
  <nav >
30
30
 
31
31
 
32
- <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#ApiServer">ApiServer</a></li><li><a href="global.html#WMd2docx">WMd2docx</a></li><li><a href="global.html#checkDocxReady">checkDocxReady</a></li><li><a href="global.html#cleanWorkDir">cleanWorkDir</a></li><li><a href="global.html#cvMdTo">cvMdTo</a></li><li><a href="global.html#cvMdToDocx">cvMdToDocx</a></li><li><a href="global.html#getFpExe">getFpExe</a></li><li><a href="global.html#getQueueSize">getQueueSize</a></li><li><a href="global.html#health">health</a></li><li><a href="global.html#readAssets">readAssets</a></li><li><a href="global.html#resolveAssetPaths">resolveAssetPaths</a></li><li><a href="global.html#retryBusy">retryBusy</a></li><li><a href="global.html#runExclusive">runExclusive</a></li><li><a href="global.html#scanAssetPaths">scanAssetPaths</a></li><li><a href="global.html#toErrText">toErrText</a></li><li><a href="global.html#toSafeName">toSafeName</a></li><li><a href="global.html#transErrAsset">transErrAsset</a></li><li><a href="global.html#writeAssets">writeAssets</a></li></ul>
32
+ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#WMd2docx">WMd2docx</a></li><li><a href="global.html#checkDocxReady">checkDocxReady</a></li><li><a href="global.html#cleanWorkDir">cleanWorkDir</a></li><li><a href="global.html#cvMdTo">cvMdTo</a></li><li><a href="global.html#cvMdToDocx">cvMdToDocx</a></li><li><a href="global.html#getFpExe">getFpExe</a></li><li><a href="global.html#getQueueSize">getQueueSize</a></li><li><a href="global.html#health">health</a></li><li><a href="global.html#readAssets">readAssets</a></li><li><a href="global.html#resolveAssetPaths">resolveAssetPaths</a></li><li><a href="global.html#retryBusy">retryBusy</a></li><li><a href="global.html#rmApiServer">rmApiServer</a></li><li><a href="global.html#runExclusive">runExclusive</a></li><li><a href="global.html#scanAssetPaths">scanAssetPaths</a></li><li><a href="global.html#toErrText">toErrText</a></li><li><a href="global.html#toSafeName">toSafeName</a></li><li><a href="global.html#transErrAsset">transErrAsset</a></li><li><a href="global.html#writeAssets">writeAssets</a></li></ul>
33
33
 
34
34
  </nav>
35
35
 
@@ -507,7 +507,7 @@ export {
507
507
  <br class="clear">
508
508
 
509
509
  <footer>
510
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Tue Sep 01 2026 16:40:03 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
510
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Wed Sep 02 2026 16:38:11 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
511
511
  </footer>
512
512
 
513
513
  <script>prettyPrint();</script>
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "w-md2docx",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "main": "dist/w-md2docx.umd.js",
5
5
  "dependencies": {
6
6
  "@hapi/hapi": "^21.4.10",
7
- "w-html2docx": "^1.0.23",
8
- "w-md2html": "^1.0.47",
9
- "wsemi": "^1.8.80"
7
+ "w-html2docx": "^1.0.24",
8
+ "w-md2html": "^1.0.48",
9
+ "wsemi": "^1.8.81"
10
10
  },
11
11
  "devDependencies": {
12
12
  "w-package-tools": "^1.1.15"
@@ -29,4 +29,4 @@
29
29
  ],
30
30
  "author": "yuda-lyu(semisphere)",
31
31
  "license": "MIT"
32
- }
32
+ }
package/script.txt CHANGED
@@ -3,7 +3,6 @@ node toolg/modifyReadme.mjs
3
3
 
4
4
  node toolg/cleanFolder.mjs
5
5
  ./node_modules/.bin/jsdoc -c .jsdoc
6
- node toolg/gDocsExams.mjs
7
6
 
8
7
  node toolg/gDistRollup.mjs
9
8
 
package/src/WMd2docx.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  import cvMdToDocx from './cvMdToDocx.mjs'
2
2
  import cvMdTo from './cvMdTo.mjs'
3
- import ApiServer from './ApiServer.mjs'
4
- import ApiClient from './ApiClient.mjs'
3
+ import rmApiServer from './rmApiServer.mjs'
4
+ import rmApiClient from './rmApiClient.mjs'
5
5
 
6
6
 
7
7
  /**
8
8
  * Markdown轉Docx工具集
9
9
  *
10
- * 匯整四個入口:cvMdToDocx(md檔轉docx檔)、cvMdTo(md內容轉html/docx之base64)、ApiServer(hapi轉檔服務)、ApiClient(呼叫轉檔服務之用戶端)。
10
+ * 匯整四個入口:cvMdToDocx(md檔轉docx檔)、cvMdTo(md內容轉html/docx之base64)、rmApiServer(hapi轉檔服務)、rmApiClient(呼叫轉檔服務之用戶端)。
11
11
  *
12
12
  * @example
13
13
  *
@@ -21,8 +21,8 @@ import ApiClient from './ApiClient.mjs'
21
21
  let WMd2docx = {
22
22
  cvMdToDocx,
23
23
  cvMdTo,
24
- ApiServer,
25
- ApiClient,
24
+ rmApiServer,
25
+ rmApiClient,
26
26
  }
27
27
 
28
28
 
@@ -14,7 +14,7 @@ import fsIsFile from 'wsemi/src/fsIsFile.mjs'
14
14
  import { toErrText } from './utils.mjs'
15
15
 
16
16
 
17
- //hostDef, portDef: 服務位置預設值(與 ApiServer 預設埠一致)
17
+ //hostDef, portDef: 服務位置預設值(與 rmApiServer 預設埠一致)
18
18
  let hostDef = '127.0.0.1'
19
19
  let portDef = 22000
20
20
 
@@ -180,7 +180,7 @@ function readAssets(md, dirMd) {
180
180
  /**
181
181
  * 將本機Markdown檔送至轉檔服務,取回並寫出Html與(或)Docx
182
182
  *
183
- * 供無Microsoft Word之機器產製docx:讀取本機md與其引用之圖片,送至ApiServer轉檔後寫回本機。連線層失敗會自動重試;逾時與HTTP錯誤不重試。
183
+ * 供無Microsoft Word之機器產製docx:讀取本機md與其引用之圖片,送至rmApiServer轉檔後寫回本機。連線層失敗會自動重試;逾時與HTTP錯誤不重試。
184
184
  *
185
185
  * @param {Object} [opt={}] 輸入設定物件,預設{}
186
186
  * @param {String} [opt.host='127.0.0.1'] 輸入服務主機位址(ip或網域)字串,未給則取環境變數WMD2DOCX_HOST,再無則用'127.0.0.1',預設'127.0.0.1'
@@ -201,7 +201,7 @@ function readAssets(md, dirMd) {
201
201
  * @returns {Promise} 回傳Promise,resolve回傳結果物件{ms,nAssets,template,[html],[docx]},其中html與docx為{fp,size},reject回傳錯誤訊息
202
202
  * @example
203
203
  *
204
- * import { cvMdTo } from 'w-md2docx/src/ApiClient.mjs'
204
+ * import { cvMdTo } from 'w-md2docx/src/rmApiClient.mjs'
205
205
  *
206
206
  * let r = await cvMdTo({
207
207
  * host: '127.0.0.1',
@@ -410,7 +410,7 @@ async function cvMdTo(opt = {}) {
410
410
  * @returns {Promise} 回傳Promise,resolve回傳服務端回傳之狀態物件,reject回傳錯誤訊息
411
411
  * @example
412
412
  *
413
- * import { health } from 'w-md2docx/src/ApiClient.mjs'
413
+ * import { health } from 'w-md2docx/src/rmApiClient.mjs'
414
414
  *
415
415
  * let r = await health({ host: '127.0.0.1', port: 22000 })
416
416
  * console.log(r)
@@ -455,7 +455,7 @@ async function health(opt = {}) {
455
455
  }
456
456
 
457
457
 
458
- let ApiClient = {
458
+ let rmApiClient = {
459
459
  cvMdTo,
460
460
  health,
461
461
  scanAssetPaths,
@@ -464,4 +464,4 @@ let ApiClient = {
464
464
 
465
465
 
466
466
  export { cvMdTo, health, scanAssetPaths, readAssets }
467
- export default ApiClient
467
+ export default rmApiClient
@@ -74,16 +74,16 @@ function isInputError(msg) {
74
74
  * @returns {Promise} 回傳Promise,resolve回傳{server,settings,getState,stop},其中server為hapi實例,getState為取環境狀態之async函數,stop為停止服務之async函數,reject回傳錯誤訊息
75
75
  * @example
76
76
  *
77
- * import ApiServer from 'w-md2docx/src/ApiServer.mjs'
77
+ * import rmApiServer from 'w-md2docx/src/rmApiServer.mjs'
78
78
  *
79
- * let { server, settings } = await ApiServer({
79
+ * let { server, settings } = await rmApiServer({
80
80
  * port: 22000,
81
81
  * token: '',
82
82
  * })
83
83
  * console.log(`listening on ${server.info.uri}`, settings)
84
84
  *
85
85
  */
86
- async function ApiServer(opt = {}) {
86
+ async function rmApiServer(opt = {}) {
87
87
 
88
88
  //port (0 為由系統自動配置, 供測試等場景避免撞埠; 實際埠號由 server.info.port 取得)
89
89
  let port = get(opt, 'port', null)
@@ -441,4 +441,4 @@ async function ApiServer(opt = {}) {
441
441
  }
442
442
 
443
443
 
444
- export default ApiServer
444
+ export default rmApiServer
@@ -1,11 +1,11 @@
1
1
  import fs from 'fs'
2
2
  import path from 'path'
3
3
  import assert from 'assert'
4
- import ApiServer from '../src/ApiServer.mjs'
5
- import ApiClient, { cvMdTo, health, scanAssetPaths, readAssets } from '../src/ApiClient.mjs'
4
+ import rmApiServer from '../src/rmApiServer.mjs'
5
+ import rmApiClient, { cvMdTo, health, scanAssetPaths, readAssets } from '../src/rmApiClient.mjs'
6
6
 
7
7
 
8
- describe('ApiClient', function() {
8
+ describe('rmApiClient', function() {
9
9
 
10
10
  describe('scanAssetPaths(純函數)', function() {
11
11
 
@@ -48,7 +48,7 @@ describe('ApiClient', function() {
48
48
 
49
49
  describe('readAssets(讀本機檔)', function() {
50
50
 
51
- let fdTmp = path.resolve('./tmp/zt_ApiClient_ra')
51
+ let fdTmp = path.resolve('./tmp/zt_rmApiClient_ra')
52
52
 
53
53
  before(function() {
54
54
  fs.mkdirSync(path.resolve(fdTmp, 'pics'), { recursive: true })
@@ -81,9 +81,9 @@ describe('ApiClient', function() {
81
81
 
82
82
  })
83
83
 
84
- describe('cvMdTo/health(對接ApiServer, html路徑不需Word)', function() {
84
+ describe('cvMdTo/health(對接rmApiServer, html路徑不需Word)', function() {
85
85
 
86
- let fdTmp = path.resolve('./tmp/zt_ApiClient')
86
+ let fdTmp = path.resolve('./tmp/zt_rmApiClient')
87
87
  let dirWork = path.resolve(fdTmp, 'work')
88
88
  let token = 'tk-client'
89
89
  let srv = null
@@ -94,7 +94,7 @@ describe('ApiClient', function() {
94
94
 
95
95
  before(async function() {
96
96
  fs.mkdirSync(fdTmp, { recursive: true })
97
- srv = await ApiServer({ port: 0, host, token, dirWork })
97
+ srv = await rmApiServer({ port: 0, host, token, dirWork })
98
98
  port = srv.server.info.port
99
99
  url = `http://${host}:${port}`
100
100
  })
@@ -107,8 +107,8 @@ describe('ApiClient', function() {
107
107
  })
108
108
 
109
109
  it('default export匯整四函數', function() {
110
- assert.strict.deepEqual(Object.keys(ApiClient), ['cvMdTo', 'health', 'scanAssetPaths', 'readAssets'])
111
- assert.strict.equal(ApiClient.cvMdTo, cvMdTo)
110
+ assert.strict.deepEqual(Object.keys(rmApiClient), ['cvMdTo', 'health', 'scanAssetPaths', 'readAssets'])
111
+ assert.strict.equal(rmApiClient.cvMdTo, cvMdTo)
112
112
  })
113
113
 
114
114
  it('health', async function() {
@@ -131,7 +131,7 @@ describe('ApiClient', function() {
131
131
  }
132
132
  })
133
133
 
134
- it('host/port與環境變數皆未給時預設127.0.0.1:22000(與ApiServer預設埠一致)', async function() {
134
+ it('host/port與環境變數皆未給時預設127.0.0.1:22000(與rmApiServer預設埠一致)', async function() {
135
135
  await assert.rejects(health({ token, timeoutMs: 3000 }), (e) => /^Unable to connect to the conversion service http:\/\/127\.0\.0\.1:22000: /.test(e) || /^Invalid response from the conversion service http:\/\/127\.0\.0\.1:22000/.test(e))
136
136
  })
137
137
 
@@ -1,13 +1,13 @@
1
1
  import fs from 'fs'
2
2
  import path from 'path'
3
3
  import assert from 'assert'
4
- import ApiServer from '../src/ApiServer.mjs'
4
+ import rmApiServer from '../src/rmApiServer.mjs'
5
5
 
6
6
 
7
- //ApiServer: 直打HTTP端點(不經UI); docx相關以html路徵替代, 不需Word
8
- describe('ApiServer', function() {
7
+ //rmApiServer: 直打HTTP端點(不經UI); docx相關以html路徵替代, 不需Word
8
+ describe('rmApiServer', function() {
9
9
 
10
- let fdTmp = path.resolve('./tmp/zt_ApiServer')
10
+ let fdTmp = path.resolve('./tmp/zt_rmApiServer')
11
11
  let dirWork = path.resolve(fdTmp, 'work')
12
12
  let token = 'tk-test'
13
13
  let svgB64 = fs.readFileSync('./test/cocktail.svg').toString('base64')
@@ -24,7 +24,7 @@ describe('ApiServer', function() {
24
24
 
25
25
  before(async function() {
26
26
  fs.mkdirSync(fdTmp, { recursive: true })
27
- srv = await ApiServer({ port: 0, host: '127.0.0.1', token, dirWork }) //port 0 由系統配置, 避免並行測試撞埠
27
+ srv = await rmApiServer({ port: 0, host: '127.0.0.1', token, dirWork }) //port 0 由系統配置, 避免並行測試撞埠
28
28
  url = `http://127.0.0.1:${srv.server.info.port}`
29
29
  })
30
30
 
@@ -169,7 +169,7 @@ describe('ApiServer', function() {
169
169
  })
170
170
 
171
171
  it('opt非法值採預設; autoStart=false不啟動', async function() {
172
- let s2 = await ApiServer({ port: 'x', host: '', token: 5, maxMb: -1, templateDef: '', autoStart: false, dirWork: path.resolve(fdTmp, 'work2') })
172
+ let s2 = await rmApiServer({ port: 'x', host: '', token: 5, maxMb: -1, templateDef: '', autoStart: false, dirWork: path.resolve(fdTmp, 'work2') })
173
173
  assert.strict.equal(s2.settings.port, 22000)
174
174
  assert.strict.equal(s2.settings.host, '0.0.0.0')
175
175
  assert.strict.equal(s2.settings.token, '')
@@ -180,7 +180,7 @@ describe('ApiServer', function() {
180
180
  })
181
181
 
182
182
  it('stop後不再回應', async function() {
183
- let s3 = await ApiServer({ port: 0, host: '127.0.0.1', dirWork: path.resolve(fdTmp, 'work3') })
183
+ let s3 = await rmApiServer({ port: 0, host: '127.0.0.1', dirWork: path.resolve(fdTmp, 'work3') })
184
184
  let u3 = `http://127.0.0.1:${s3.server.info.port}`
185
185
  let res = await fetch(`${u3}/api/health`)
186
186
  assert.strict.equal(res.status, 200) //無token時不需標頭
@@ -28,7 +28,7 @@ async function rp() {
28
28
  'marked-highlight': 'marked-highlight', //w-md2html
29
29
  'dompurify': 'dompurify', //w-md2html
30
30
  'jsdom': 'jsdom', //w-md2html(動態載入)
31
- '@hapi/hapi': '@hapi/hapi', //ApiServer
31
+ '@hapi/hapi': '@hapi/hapi', //rmApiServer
32
32
  },
33
33
  external: [
34
34
  'path',
@@ -45,7 +45,7 @@ async function rp() {
45
45
  'marked-highlight', //w-md2html
46
46
  'dompurify', //w-md2html
47
47
  'jsdom', //w-md2html(動態載入)
48
- '@hapi/hapi', //ApiServer
48
+ '@hapi/hapi', //rmApiServer
49
49
  ],
50
50
  })
51
51
 
@@ -1,51 +0,0 @@
1
- import fs from 'fs'
2
- import _ from 'lodash-es'
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, urlc
18
- let url = `https://cdn.jsdelivr.net/npm/w-md2docx@${pks.version}/dist/w-md2docx.umd.js`
19
- let urlc = `https://cdn.jsdelivr.net/npm/w-md2docx@${pks.version}/dist/md2html.umd.js`
20
-
21
- //mkdirSync
22
- if (!fs.existsSync(fdTar)) {
23
- fs.mkdirSync(fdTar)
24
- }
25
-
26
- //getFiles
27
- let ltfs = getFiles(fdSrc)
28
-
29
- _.each(ltfs, function(v) {
30
-
31
- //fn
32
- let fn = fdSrc + v
33
-
34
- //c
35
- let c = fs.readFileSync(fn, 'utf8')
36
-
37
- //replace
38
- let r
39
- r = `../dist/w-md2docx.umd.js`
40
- c = c.replace(r, url)
41
- r = `../dist/md2html.umd.js`
42
- c = c.replace(r, urlc)
43
-
44
- //write
45
- //console.log(c)
46
- fs.writeFileSync(fdTar + v, c, 'utf8')
47
-
48
- })
49
-
50
- }
51
- main()