Commit 2191ce9a authored by rockyl's avatar rockyl

兼容混淆版本的引擎

parent 11f5cc42
......@@ -43,7 +43,7 @@ function fillTemplate(tpl, params, analyseResult) {
return tpl;
}
async function generateLibraryScriptEl(tpl, dependencies, getPackages, libraryPath) {
async function generateLibraryScriptEl(tpl, dependencies, getPackages, libraryPath, debug) {
let analyseResult = analyseTemplate(tpl);
let librariesHint = analyseResult.filter(item => item.field === 'libraries').map(item => item.subField);
......@@ -58,7 +58,8 @@ async function generateLibraryScriptEl(tpl, dependencies, getPackages, libraryPa
(await getPackages(schema, 0)).forEach(item => {
let itemObj = typeof item.data === 'string' ? JSON.parse(item.data) : item.data;
libraryScriptElMap[itemObj.id] = generateJsScriptEl(itemObj.url, libraryPath);
let urlField = debug && itemObj.url_dbg ? 'url_dbg' : 'url';
libraryScriptElMap[itemObj.id] = generateJsScriptEl(itemObj[urlField], libraryPath);
});
}
......
{"version":3,"file":"index.es.js","sources":["../src/index.js"],"sourcesContent":["/**\n * Created by rockyl on 2019-11-13.\n *\n * 模板填充\n */\n\nimport camelcase from 'camelcase'\n\nconst TAG = 'zeroing-template-fill';\n\nconst dynamicValueReg = /\\$[\\w|(\\.)]+\\$/g;\n\nexport function analyseTemplate(tpl) {\n\tlet result = [];\n\tlet matchResult = tpl.match(dynamicValueReg);\n\tfor (let matchItem of matchResult) {\n\t\tlet hint = matchItem.substr(1, matchItem.length - 2);\n\t\tlet arr = hint.split('.');\n\t\tlet field = camelcase(arr[0]);\n\n\t\tlet item = {\n\t\t\tsource: matchItem,\n\t\t\tfield,\n\t\t};\n\t\tif (arr[1] !== undefined) {\n\t\t\titem.subField = arr[1];\n\t\t}\n\t\tresult.push(item)\n\t}\n\treturn result;\n}\n\nexport function fillTemplate(tpl, params, analyseResult) {\n\tanalyseResult = analyseResult || analyseTemplate(tpl);\n\tfor (let item of analyseResult) {\n\t\tlet fieldData = params[item.field];\n\t\tif (fieldData && item.subField) {\n\t\t\tfieldData = fieldData[item.subField];\n\t\t}\n\t\tif (fieldData) {\n\t\t\ttpl = tpl.replace(item.source, fieldData);\n\t\t}\n\t}\n\n\treturn tpl;\n}\n\nexport async function generateLibraryScriptEl(tpl, dependencies, getPackages, libraryPath) {\n\tlet analyseResult = analyseTemplate(tpl);\n\tlet librariesHint = analyseResult.filter(item => item.field === 'libraries').map(item => item.subField);\n\n\tlet libraryScriptElMap = {};\n\tif (librariesHint.length > 0) {\n\t\tlet schema = {};\n\t\tfor (let libName of librariesHint) {\n\t\t\tif (dependencies[libName]) {\n\t\t\t\tschema[libName] = dependencies[libName];\n\t\t\t}\n\t\t}\n\n\t\t(await getPackages(schema, 0)).forEach(item => {\n\t\t\tlet itemObj = typeof item.data === 'string' ? JSON.parse(item.data) : item.data;\n\t\t\tlibraryScriptElMap[itemObj.id] = generateJsScriptEl(itemObj.url, libraryPath);\n\t\t});\n\t}\n\n\treturn {\n\t\tlibraryScriptElMap,\n\t\tanalyseResult,\n\t}\n}\n\nexport function generateJsScriptEl(file, path) {\n\tlet url = (path || '') + file;\n\treturn `<script crossorigin=\"anonymous\" src=\"${url}\"></script>`;\n}\n"],"names":[],"mappings":";;AAAA;;;;;AAKA,AAIA;AACA,MAAM,eAAe,GAAG,iBAAiB,CAAC;;AAE1C,AAAO,SAAS,eAAe,CAAC,GAAG,EAAE;CACpC,IAAI,MAAM,GAAG,EAAE,CAAC;CAChB,IAAI,WAAW,GAAG,GAAG,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;CAC7C,KAAK,IAAI,SAAS,IAAI,WAAW,EAAE;EAClC,IAAI,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;EACrD,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;EAC1B,IAAI,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;;EAE9B,IAAI,IAAI,GAAG;GACV,MAAM,EAAE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C1B,MAAM,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IACxC;GACD;;EAED,CAAC,MAAM,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,IAAI;GAC9C,IAAI,OAAO,GAAG,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;GAChF,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,kBAAkB,CAAC,OAAO,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;GAC9E,CAAC,CAAC;EACH;;CAED,OAAO;EACN,kBAAkB;EAClB,aAAa;EACb;CACD;;AAED,AAAO,SAAS,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE;CAC9C,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,EAAE,IAAI,IAAI,CAAC;CAC9B,OAAO,CAAC,qCAAqC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CAChE;;;;"}
\ No newline at end of file
{"version":3,"file":"index.es.js","sources":["../src/index.js"],"sourcesContent":["/**\n * Created by rockyl on 2019-11-13.\n *\n * 模板填充\n */\n\nimport camelcase from 'camelcase'\n\nconst TAG = 'zeroing-template-fill';\n\nconst dynamicValueReg = /\\$[\\w|(\\.)]+\\$/g;\n\nexport function analyseTemplate(tpl) {\n\tlet result = [];\n\tlet matchResult = tpl.match(dynamicValueReg);\n\tfor (let matchItem of matchResult) {\n\t\tlet hint = matchItem.substr(1, matchItem.length - 2);\n\t\tlet arr = hint.split('.');\n\t\tlet field = camelcase(arr[0]);\n\n\t\tlet item = {\n\t\t\tsource: matchItem,\n\t\t\tfield,\n\t\t};\n\t\tif (arr[1] !== undefined) {\n\t\t\titem.subField = arr[1];\n\t\t}\n\t\tresult.push(item)\n\t}\n\treturn result;\n}\n\nexport function fillTemplate(tpl, params, analyseResult) {\n\tanalyseResult = analyseResult || analyseTemplate(tpl);\n\tfor (let item of analyseResult) {\n\t\tlet fieldData = params[item.field];\n\t\tif (fieldData && item.subField) {\n\t\t\tfieldData = fieldData[item.subField];\n\t\t}\n\t\tif (fieldData) {\n\t\t\ttpl = tpl.replace(item.source, fieldData);\n\t\t}\n\t}\n\n\treturn tpl;\n}\n\nexport async function generateLibraryScriptEl(tpl, dependencies, getPackages, libraryPath, debug) {\n\tlet analyseResult = analyseTemplate(tpl);\n\tlet librariesHint = analyseResult.filter(item => item.field === 'libraries').map(item => item.subField);\n\n\tlet libraryScriptElMap = {};\n\tif (librariesHint.length > 0) {\n\t\tlet schema = {};\n\t\tfor (let libName of librariesHint) {\n\t\t\tif (dependencies[libName]) {\n\t\t\t\tschema[libName] = dependencies[libName];\n\t\t\t}\n\t\t}\n\n\t\t(await getPackages(schema, 0)).forEach(item => {\n\t\t\tlet itemObj = typeof item.data === 'string' ? JSON.parse(item.data) : item.data;\n\t\t\tlet urlField = debug && itemObj.url_dbg ? 'url_dbg' : 'url';\n\t\t\tlibraryScriptElMap[itemObj.id] = generateJsScriptEl(itemObj[urlField], libraryPath);\n\t\t});\n\t}\n\n\treturn {\n\t\tlibraryScriptElMap,\n\t\tanalyseResult,\n\t}\n}\n\nexport function generateJsScriptEl(file, path) {\n\tlet url = (path || '') + file;\n\treturn `<script crossorigin=\"anonymous\" src=\"${url}\"></script>`;\n}\n"],"names":[],"mappings":";;AAAA;;;;;AAKA,AAIA;AACA,MAAM,eAAe,GAAG,iBAAiB,CAAC;;AAE1C,AAAO,SAAS,eAAe,CAAC,GAAG,EAAE;CACpC,IAAI,MAAM,GAAG,EAAE,CAAC;CAChB,IAAI,WAAW,GAAG,GAAG,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;CAC7C,KAAK,IAAI,SAAS,IAAI,WAAW,EAAE;EAClC,IAAI,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,CAA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,IAAI,kBAAkB,GAAG,EAAE,CAAC;CAC5B,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;EAC7B,IAAI,MAAM,GAAG,EAAE,CAAC;EAChB,KAAK,IAAI,OAAO,IAAI,aAAa,EAAE;GAClC,IAAI,YAAY,CAAC,OAAO,CAAC,EAAE;IAC1B,MAAM,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IACxC;GACD;;EAED,CAAC,MAAM,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,IAAI;GAC9C,IAAI,OAAO,GAAG,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;GAChF,IAAI,QAAQ,GAAG,KAAK,IAAI,OAAO,CAAC,OAAO,GAAG,SAAS,GAAG,KAAK,CAAC;GAC5D,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,CAAC;GACpF,CAAC,CAAC;EACH;;CAED,OAAO;EACN,kBAAkB;EAClB,aAAa;EACb;CACD;;AAED,AAAO,SAAS,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE;CAC9C,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,EAAE,IAAI,IAAI,CAAC;CAC9B,OAAO,CAAC,qCAAqC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CAChE;;;;"}
\ No newline at end of file
......@@ -49,7 +49,7 @@ function fillTemplate(tpl, params, analyseResult) {
return tpl;
}
async function generateLibraryScriptEl(tpl, dependencies, getPackages, libraryPath) {
async function generateLibraryScriptEl(tpl, dependencies, getPackages, libraryPath, debug) {
let analyseResult = analyseTemplate(tpl);
let librariesHint = analyseResult.filter(item => item.field === 'libraries').map(item => item.subField);
......@@ -64,7 +64,8 @@ async function generateLibraryScriptEl(tpl, dependencies, getPackages, libraryPa
(await getPackages(schema, 0)).forEach(item => {
let itemObj = typeof item.data === 'string' ? JSON.parse(item.data) : item.data;
libraryScriptElMap[itemObj.id] = generateJsScriptEl(itemObj.url, libraryPath);
let urlField = debug && itemObj.url_dbg ? 'url_dbg' : 'url';
libraryScriptElMap[itemObj.id] = generateJsScriptEl(itemObj[urlField], libraryPath);
});
}
......
{"version":3,"file":"index.js","sources":["../src/index.js"],"sourcesContent":["/**\n * Created by rockyl on 2019-11-13.\n *\n * 模板填充\n */\n\nimport camelcase from 'camelcase'\n\nconst TAG = 'zeroing-template-fill';\n\nconst dynamicValueReg = /\\$[\\w|(\\.)]+\\$/g;\n\nexport function analyseTemplate(tpl) {\n\tlet result = [];\n\tlet matchResult = tpl.match(dynamicValueReg);\n\tfor (let matchItem of matchResult) {\n\t\tlet hint = matchItem.substr(1, matchItem.length - 2);\n\t\tlet arr = hint.split('.');\n\t\tlet field = camelcase(arr[0]);\n\n\t\tlet item = {\n\t\t\tsource: matchItem,\n\t\t\tfield,\n\t\t};\n\t\tif (arr[1] !== undefined) {\n\t\t\titem.subField = arr[1];\n\t\t}\n\t\tresult.push(item)\n\t}\n\treturn result;\n}\n\nexport function fillTemplate(tpl, params, analyseResult) {\n\tanalyseResult = analyseResult || analyseTemplate(tpl);\n\tfor (let item of analyseResult) {\n\t\tlet fieldData = params[item.field];\n\t\tif (fieldData && item.subField) {\n\t\t\tfieldData = fieldData[item.subField];\n\t\t}\n\t\tif (fieldData) {\n\t\t\ttpl = tpl.replace(item.source, fieldData);\n\t\t}\n\t}\n\n\treturn tpl;\n}\n\nexport async function generateLibraryScriptEl(tpl, dependencies, getPackages, libraryPath) {\n\tlet analyseResult = analyseTemplate(tpl);\n\tlet librariesHint = analyseResult.filter(item => item.field === 'libraries').map(item => item.subField);\n\n\tlet libraryScriptElMap = {};\n\tif (librariesHint.length > 0) {\n\t\tlet schema = {};\n\t\tfor (let libName of librariesHint) {\n\t\t\tif (dependencies[libName]) {\n\t\t\t\tschema[libName] = dependencies[libName];\n\t\t\t}\n\t\t}\n\n\t\t(await getPackages(schema, 0)).forEach(item => {\n\t\t\tlet itemObj = typeof item.data === 'string' ? JSON.parse(item.data) : item.data;\n\t\t\tlibraryScriptElMap[itemObj.id] = generateJsScriptEl(itemObj.url, libraryPath);\n\t\t});\n\t}\n\n\treturn {\n\t\tlibraryScriptElMap,\n\t\tanalyseResult,\n\t}\n}\n\nexport function generateJsScriptEl(file, path) {\n\tlet url = (path || '') + file;\n\treturn `<script crossorigin=\"anonymous\" src=\"${url}\"></script>`;\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;;AAKA,AAIA;AACA,MAAM,eAAe,GAAG,iBAAiB,CAAC;;AAE1C,AAAO,SAAS,eAAe,CAAC,GAAG,EAAE;CACpC,IAAI,MAAM,GAAG,EAAE,CAAC;CAChB,IAAI,WAAW,GAAG,GAAG,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;CAC7C,KAAK,IAAI,SAAS,IAAI,WAAW,EAAE;EAClC,IAAI,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;EACrD,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;EAC1B,IAAI,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;;EAE9B,IAAI,IAAI,GAAG;GACV,MAAM,EAAE,SAAS;GACjB,KAAK;GACL,CAAC;EACF,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE;GACzB,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;GACvB;EACD,MAAM,CAAC,IAAI,CAAC,IAAI,EAAC;EACjB;CACD,OAAO,MAAM,CAAC;CACd;;AAED,AAAO,SAAS,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,EAA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CAAC,IAAI,CAAC;GAChF,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,kBAAkB,CAAC,OAAO,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;GAC9E,CAAC,CAAC;EACH;;CAED,OAAO;EACN,kBAAkB;EAClB,aAAa;EACb;CACD;;AAED,AAAO,SAAS,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE;CAC9C,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,EAAE,IAAI,IAAI,CAAC;CAC9B,OAAO,CAAC,qCAAqC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CAChE;;;;;;;"}
\ No newline at end of file
{"version":3,"file":"index.js","sources":["../src/index.js"],"sourcesContent":["/**\n * Created by rockyl on 2019-11-13.\n *\n * 模板填充\n */\n\nimport camelcase from 'camelcase'\n\nconst TAG = 'zeroing-template-fill';\n\nconst dynamicValueReg = /\\$[\\w|(\\.)]+\\$/g;\n\nexport function analyseTemplate(tpl) {\n\tlet result = [];\n\tlet matchResult = tpl.match(dynamicValueReg);\n\tfor (let matchItem of matchResult) {\n\t\tlet hint = matchItem.substr(1, matchItem.length - 2);\n\t\tlet arr = hint.split('.');\n\t\tlet field = camelcase(arr[0]);\n\n\t\tlet item = {\n\t\t\tsource: matchItem,\n\t\t\tfield,\n\t\t};\n\t\tif (arr[1] !== undefined) {\n\t\t\titem.subField = arr[1];\n\t\t}\n\t\tresult.push(item)\n\t}\n\treturn result;\n}\n\nexport function fillTemplate(tpl, params, analyseResult) {\n\tanalyseResult = analyseResult || analyseTemplate(tpl);\n\tfor (let item of analyseResult) {\n\t\tlet fieldData = params[item.field];\n\t\tif (fieldData && item.subField) {\n\t\t\tfieldData = fieldData[item.subField];\n\t\t}\n\t\tif (fieldData) {\n\t\t\ttpl = tpl.replace(item.source, fieldData);\n\t\t}\n\t}\n\n\treturn tpl;\n}\n\nexport async function generateLibraryScriptEl(tpl, dependencies, getPackages, libraryPath, debug) {\n\tlet analyseResult = analyseTemplate(tpl);\n\tlet librariesHint = analyseResult.filter(item => item.field === 'libraries').map(item => item.subField);\n\n\tlet libraryScriptElMap = {};\n\tif (librariesHint.length > 0) {\n\t\tlet schema = {};\n\t\tfor (let libName of librariesHint) {\n\t\t\tif (dependencies[libName]) {\n\t\t\t\tschema[libName] = dependencies[libName];\n\t\t\t}\n\t\t}\n\n\t\t(await getPackages(schema, 0)).forEach(item => {\n\t\t\tlet itemObj = typeof item.data === 'string' ? JSON.parse(item.data) : item.data;\n\t\t\tlet urlField = debug && itemObj.url_dbg ? 'url_dbg' : 'url';\n\t\t\tlibraryScriptElMap[itemObj.id] = generateJsScriptEl(itemObj[urlField], libraryPath);\n\t\t});\n\t}\n\n\treturn {\n\t\tlibraryScriptElMap,\n\t\tanalyseResult,\n\t}\n}\n\nexport function generateJsScriptEl(file, path) {\n\tlet url = (path || '') + file;\n\treturn `<script crossorigin=\"anonymous\" src=\"${url}\"></script>`;\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;;AAKA,AAIA;AACA,MAAM,eAAe,GAAG,iBAAiB,CAAC;;AAE1C,AAAO,SAAS,eAAe,CAAC,GAAG,EAAE;CACpC,IAAI,MAAM,GAAG,EAAE,CAAC;CAChB,IAAI,WAAW,GAAG,GAAG,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;CAC7C,KAAK,IAAI,SAAS,IAAI,WAAW,EAAE;EAClC,IAAI,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;EACrD,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;EAC1B,IAAI,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;;EAE9B,IAAI,IAAI,GAAG;GACV,MAAM,EAAE,SAAS;GACjB,KAAK;GACL,CAAC;EACF,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE;G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D;;EAED,CAAC,MAAM,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,IAAI;GAC9C,IAAI,OAAO,GAAG,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;GAChF,IAAI,QAAQ,GAAG,KAAK,IAAI,OAAO,CAAC,OAAO,GAAG,SAAS,GAAG,KAAK,CAAC;GAC5D,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,CAAC;GACpF,CAAC,CAAC;EACH;;CAED,OAAO;EACN,kBAAkB;EAClB,aAAa;EACb;CACD;;AAED,AAAO,SAAS,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE;CAC9C,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,EAAE,IAAI,IAAI,CAAC;CAC9B,OAAO,CAAC,qCAAqC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CAChE;;;;;;;"}
\ No newline at end of file
......@@ -49,7 +49,7 @@
return tpl;
}
async function generateLibraryScriptEl(tpl, dependencies, getPackages, libraryPath) {
async function generateLibraryScriptEl(tpl, dependencies, getPackages, libraryPath, debug) {
let analyseResult = analyseTemplate(tpl);
let librariesHint = analyseResult.filter(item => item.field === 'libraries').map(item => item.subField);
......@@ -64,7 +64,8 @@
(await getPackages(schema, 0)).forEach(item => {
let itemObj = typeof item.data === 'string' ? JSON.parse(item.data) : item.data;
libraryScriptElMap[itemObj.id] = generateJsScriptEl(itemObj.url, libraryPath);
let urlField = debug && itemObj.url_dbg ? 'url_dbg' : 'url';
libraryScriptElMap[itemObj.id] = generateJsScriptEl(itemObj[urlField], libraryPath);
});
}
......
{"version":3,"file":"index.umd.js","sources":["../src/index.js"],"sourcesContent":["/**\n * Created by rockyl on 2019-11-13.\n *\n * 模板填充\n */\n\nimport camelcase from 'camelcase'\n\nconst TAG = 'zeroing-template-fill';\n\nconst dynamicValueReg = /\\$[\\w|(\\.)]+\\$/g;\n\nexport function analyseTemplate(tpl) {\n\tlet result = [];\n\tlet matchResult = tpl.match(dynamicValueReg);\n\tfor (let matchItem of matchResult) {\n\t\tlet hint = matchItem.substr(1, matchItem.length - 2);\n\t\tlet arr = hint.split('.');\n\t\tlet field = camelcase(arr[0]);\n\n\t\tlet item = {\n\t\t\tsource: matchItem,\n\t\t\tfield,\n\t\t};\n\t\tif (arr[1] !== undefined) {\n\t\t\titem.subField = arr[1];\n\t\t}\n\t\tresult.push(item)\n\t}\n\treturn result;\n}\n\nexport function fillTemplate(tpl, params, analyseResult) {\n\tanalyseResult = analyseResult || analyseTemplate(tpl);\n\tfor (let item of analyseResult) {\n\t\tlet fieldData = params[item.field];\n\t\tif (fieldData && item.subField) {\n\t\t\tfieldData = fieldData[item.subField];\n\t\t}\n\t\tif (fieldData) {\n\t\t\ttpl = tpl.replace(item.source, fieldData);\n\t\t}\n\t}\n\n\treturn tpl;\n}\n\nexport async function generateLibraryScriptEl(tpl, dependencies, getPackages, libraryPath) {\n\tlet analyseResult = analyseTemplate(tpl);\n\tlet librariesHint = analyseResult.filter(item => item.field === 'libraries').map(item => item.subField);\n\n\tlet libraryScriptElMap = {};\n\tif (librariesHint.length > 0) {\n\t\tlet schema = {};\n\t\tfor (let libName of librariesHint) {\n\t\t\tif (dependencies[libName]) {\n\t\t\t\tschema[libName] = dependencies[libName];\n\t\t\t}\n\t\t}\n\n\t\t(await getPackages(schema, 0)).forEach(item => {\n\t\t\tlet itemObj = typeof item.data === 'string' ? JSON.parse(item.data) : item.data;\n\t\t\tlibraryScriptElMap[itemObj.id] = generateJsScriptEl(itemObj.url, libraryPath);\n\t\t});\n\t}\n\n\treturn {\n\t\tlibraryScriptElMap,\n\t\tanalyseResult,\n\t}\n}\n\nexport function generateJsScriptEl(file, path) {\n\tlet url = (path || '') + file;\n\tretur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AG,kBAAkB,CAAC,OAAO,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;CACjF,GAAG,CAAC,CAAC;CACL,EAAE;;CAEF,CAAC,OAAO;CACR,EAAE,kBAAkB;CACpB,EAAE,aAAa;CACf,EAAE;CACF,CAAC;;AAED,CAAO,SAAS,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE;CAC/C,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,EAAE,IAAI,IAAI,CAAC;CAC/B,CAAC,OAAO,CAAC,qCAAqC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CACjE,CAAC;;;;;;;;;;;;;;;"}
\ No newline at end of file
{"version":3,"file":"index.umd.js","sources":["../src/index.js"],"sourcesContent":["/**\n * Created by rockyl on 2019-11-13.\n *\n * 模板填充\n */\n\nimport camelcase from 'camelcase'\n\nconst TAG = 'zeroing-template-fill';\n\nconst dynamicValueReg = /\\$[\\w|(\\.)]+\\$/g;\n\nexport function analyseTemplate(tpl) {\n\tlet result = [];\n\tlet matchResult = tpl.match(dynamicValueReg);\n\tfor (let matchItem of matchResult) {\n\t\tlet hint = matchItem.substr(1, matchItem.length - 2);\n\t\tlet arr = hint.split('.');\n\t\tlet field = camelcase(arr[0]);\n\n\t\tlet item = {\n\t\t\tsource: matchItem,\n\t\t\tfield,\n\t\t};\n\t\tif (arr[1] !== undefined) {\n\t\t\titem.subField = arr[1];\n\t\t}\n\t\tresult.push(item)\n\t}\n\treturn result;\n}\n\nexport function fillTemplate(tpl, params, analyseResult) {\n\tanalyseResult = analyseResult || analyseTemplate(tpl);\n\tfor (let item of analyseResult) {\n\t\tlet fieldData = params[item.field];\n\t\tif (fieldData && item.subField) {\n\t\t\tfieldData = fieldData[item.subField];\n\t\t}\n\t\tif (fieldData) {\n\t\t\ttpl = tpl.replace(item.source, fieldData);\n\t\t}\n\t}\n\n\treturn tpl;\n}\n\nexport async function generateLibraryScriptEl(tpl, dependencies, getPackages, libraryPath, debug) {\n\tlet analyseResult = analyseTemplate(tpl);\n\tlet librariesHint = analyseResult.filter(item => item.field === 'libraries').map(item => item.subField);\n\n\tlet libraryScriptElMap = {};\n\tif (librariesHint.length > 0) {\n\t\tlet schema = {};\n\t\tfor (let libName of librariesHint) {\n\t\t\tif (dependencies[libName]) {\n\t\t\t\tschema[libName] = dependencies[libName];\n\t\t\t}\n\t\t}\n\n\t\t(await getPackages(schema, 0)).forEach(item => {\n\t\t\tlet itemObj = typeof item.data === 'string' ? JSON.parse(item.data) : item.data;\n\t\t\tlet urlField = debug && itemObj.url_dbg ? 'url_dbg' : 'url';\n\t\t\tlibraryScriptElMap[itemObj.id] = generateJsScriptEl(itemObj[urlField], libraryPath);\n\t\t});\n\t}\n\n\treturn {\n\t\tlibraryScriptElMap,\n\t\tanalyseResult,\n\t}\n}\n\nexport function generateJsScriptEl(file, path) {\n\tlet url = (path || '') + file;\n\treturn `<script crossorigin=\"anonymous\" src=\"${url}\"></script>`;\n}\n"],"names":[],"mappings":";;;;;;;;CAAA;CACA;CACA;CACA;CACA;AACA,AAIA;CACA,MAAM,eAAe,GAAG,iBAAiB,CAAC;;AAE1C,CAAO,SAAS,eAAe,CAAC,GAAG,EAAE;CACrC,CAAC,IAAI,MAAM,GAAG,EAAE,CAAC;CACjB,CAAC,IAAI,WAAW,GAAG,GAAG,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;CAC9C,CAAC,KAAK,IAAI,SAAS,IAAI,WAAW,EAAE;CACpC,EAAE,IAAI,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;CACvD,EAAE,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;CAC5B,EAAE,IAAI,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;;CAEhC,EAAE,IAAI,IAAI,GAAG;CACb,GAAG,MAAM,EAAE,SAAS;CACpB,G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CAAC,MAAM,GAAG,CAAC,EAAE;CAC/B,EAAE,IAAI,MAAM,GAAG,EAAE,CAAC;CAClB,EAAE,KAAK,IAAI,OAAO,IAAI,aAAa,EAAE;CACrC,GAAG,IAAI,YAAY,CAAC,OAAO,CAAC,EAAE;CAC9B,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;CAC5C,IAAI;CACJ,GAAG;;CAEH,EAAE,CAAC,MAAM,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,IAAI;CACjD,GAAG,IAAI,OAAO,GAAG,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;CACnF,GAAG,IAAI,QAAQ,GAAG,KAAK,IAAI,OAAO,CAAC,OAAO,GAAG,SAAS,GAAG,KAAK,CAAC;CAC/D,GAAG,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,CAAC;CACvF,GAAG,CAAC,CAAC;CACL,EAAE;;CAEF,CAAC,OAAO;CACR,EAAE,kBAAkB;CACpB,EAAE,aAAa;CACf,EAAE;CACF,CAAC;;AAED,CAAO,SAAS,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE;CAC/C,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,EAAE,IAAI,IAAI,CAAC;CAC/B,CAAC,OAAO,CAAC,qCAAqC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CACjE,CAAC;;;;;;;;;;;;;;;"}
\ No newline at end of file
......@@ -45,7 +45,7 @@ export function fillTemplate(tpl, params, analyseResult) {
return tpl;
}
export async function generateLibraryScriptEl(tpl, dependencies, getPackages, libraryPath) {
export async function generateLibraryScriptEl(tpl, dependencies, getPackages, libraryPath, debug) {
let analyseResult = analyseTemplate(tpl);
let librariesHint = analyseResult.filter(item => item.field === 'libraries').map(item => item.subField);
......@@ -60,7 +60,8 @@ export async function generateLibraryScriptEl(tpl, dependencies, getPackages, li
(await getPackages(schema, 0)).forEach(item => {
let itemObj = typeof item.data === 'string' ? JSON.parse(item.data) : item.data;
libraryScriptElMap[itemObj.id] = generateJsScriptEl(itemObj.url, libraryPath);
let urlField = debug && itemObj.url_dbg ? 'url_dbg' : 'url';
libraryScriptElMap[itemObj.id] = generateJsScriptEl(itemObj[urlField], libraryPath);
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment