amis sdk 生成调整

This commit is contained in:
liaoxuezhi 2019-08-05 16:54:39 +08:00
parent 9dbdb2dbe4
commit ee13626904
12 changed files with 520 additions and 525 deletions

1
.gitignore vendored
View File

@ -12,6 +12,7 @@ _site
node_modules
/dist
/lib
/sdk
/public
/gh-pages
/.vscode

View File

@ -37,33 +37,6 @@ function prefixCss(code, prefix) {
}
}
function replaceSrc(code) {
var cssAst = css.parse(code);
let count = 0;
replaceNode(cssAst);
return css.stringify(cssAst);
function replaceDeclaration(sel) {
if (sel.property == 'src' && ~sel.value.indexOf('url')) {
sel.value = sel.value.replace(/\/sdk/g, '.');
}
return sel;
}
function replaceNode(node) {
// font-awesome的在 1 个 declarations中 bootstrap 的字体路径在 58 declarations中后续的就不再遍历了直接返回
if (count >= 58) return node;
if (node.declarations) {
count++;
node.declarations = node.declarations.map(replaceDeclaration);
} else if (node.stylesheet) {
node.stylesheet.rules.forEach(replaceNode);
} else if (node.rules) {
node.rules.forEach(replaceNode);
}
}
}
function unicodeJs(str) {
return str.replace(/([\u4E00-\u9FA5]|[\uFE30-\uFFA0]|[\u2019])/g, function(_, value){
return '\\u' + value.charCodeAt(0).toString(16);
@ -73,7 +46,8 @@ function unicodeJs(str) {
module.exports = function (ret, pack, settings, opt) {
var root = fis.project.getProjectPath();
var tpl = ret.pkg['/examples/embed.tpl'];
var tpl = ret.pkg['/examples/sdk-placeholder.html'];
tpl.skiped = true;
if (tpl && tpl._fromCache && caches[tpl.id]) {
tpl.setContent(caches[tpl.id]);
@ -104,6 +78,38 @@ module.exports = function (ret, pack, settings, opt) {
if (script && !body.trim() && rSrcHref.test(attrs)) {
all = '';
let src = RegExp.$2;
let file = resource.getFileByUrl(src);
if (!file) {
file = resource.getFileByUrl(fis.util(path.join(path.dirname(tpl.release), src)));
}
if (!file) {
file = mapping[src];
}
if (file) {
file.skiped = true;
let contents = file.getContent();
if (/_map\.js$/.test(file.subpath)) {
contents = `(function() {
var d = '';
try {
throw new Error()
} catch (e) {
d = (/((?:https?|file)\:.*)$/.test(e.stack) && RegExp.$1).replace(/\\/[^\\/]*$/, '');
}
${contents.replace(/\"url\"\s*\:\s*('|")(\.\/.*)\1/g, function(_, quote, value) {
return `"url": d + ${quote}${value.substring(1)}${quote}`;
})}
})()`;
}
jsContents += contents + ';\n';
}
} else if (script && !rScriptType.test(attrs) || rScriptType.test(attrs) && ~['text/javascript', 'application/javascript'].indexOf(RegExp.$2.toLowerCase())) {
entryJs += ';' + body;
all = '';
@ -120,11 +126,9 @@ module.exports = function (ret, pack, settings, opt) {
}
if (file && (file.filename === 'font-awesome' || file.filename === 'bootstrap')) {
let content = replaceSrc(file.getContent())
cssContents += '\n' + content;
} else {
file && (cssContents += '\n' + file.getContent());
if (file) {
cssContents += '\n' + file.getContent();
file.skiped = true;
}
all = '';
} else if (style && sbody.trim()) {
@ -135,142 +139,18 @@ module.exports = function (ret, pack, settings, opt) {
return all;
});
(function (file, ret) { // tpl ret
var resource = createResource(ret, file, {});
var asyncJsContents = '';
file.requires.forEach(function(id) {
resource.add(id);
});
file.asyncs.forEach(function(id) {
resource.add(id, true);
});
var loaded = resource.loaded;
var res = {};
var pkg = {};
Object.keys(loaded).forEach(function (id) {
if (!/\.(jsx|tsx|js|ts)?$/.test(id)) {
return;
}
var file = resource.getFileById(id);
var isAsync = loaded[id];
if (file) {
if (isAsync) {
asyncJsContents += ';/*!' +id+ '*/\n' + file.getContent();
var node = resource.getNode(id);
if (node.type !== 'js') {
return;
}
var item = {
type: node.type
};
if (node.deps) {
// 过滤掉不是 js 的文件依赖。
var deps = node.deps.filter(function(id) {
if (resource.loaded[id] !== false) {
var dep = resource.getFileById(id);
if (dep) {
return dep.isJsLike;
}
}
return false;
});
if (deps.length) {
deps.forEach(function(v, k) {
var dep = resource.getFileById(v);
if (dep && dep.moduleId) {
deps[k] = dep.moduleId;
} else {
deps[k] = v.replace(/\.(es6|jsx|tsx|ts|coffee)$/g, '.js');
}
});
item.deps = deps;
}
}
var moduleId = node.extras && node.extras.moduleId || file && file.moduleId || id.replace(/\.js$/i, '');
res[moduleId] = item;
} else {
jsContents += ';/*!' +id+ '*/\n' + file.getContent();
}
}
});
var modjs = resource.getFileByUrl('/examples/mod.js');
var resouceMap = '';
var asyncPkgs = {};
if (asyncJsContents) {
asyncJsContents = asyncJsContents.replace(rSourceMap, '');
asyncJsContents = unicodeJs(asyncJsContents);
let asyncJsFile = fis.file(root + '/sdk/', tpl.filename + '_aio_async.js');
asyncJsFile.setContent(asyncJsContents);
ret.pkg[asyncJsFile.subpath] = asyncJsFile;
Object.keys(res).forEach(function (moduleId) {
res[moduleId].pkg = 'paio';
});
pkg['paio'] = {
uri: asyncJsFile.filename + '.js',
type: 'js'
};
asyncPkgs = {res: res, pkg: pkg};
}
resouceMap = `(function(){
var dirname = '';
try {
throw new Error()
} catch (e) {
const stackPath = e.stack.substring(0, e.stack.indexOf('embed'));
const rgx = /(?<=.)(http|https|file).*/;
dirname = (rgx.exec(stackPath)||[])[0] || '';
}
var config = ${JSON.stringify(asyncPkgs)};
var pkg = config.pkg;
Object.keys(pkg).forEach(function(key){
if (pkg[key].uri) {
pkg[key].uri = dirname + pkg[key].uri;
}
});
amis.require.resourceMap(config);
})();`;
jsContents = modjs.getContent() + '\n' + resouceMap + '\n' + jsContents;
})(tpl, ret);
jsContents = jsContents.replace(rSourceMap, '');
jsContents = unicodeJs(jsContents);
let jsFile = fis.file(root + '/sdk/', tpl.filename + '_aio.js');
let jsFile = fis.file(root, 'sdk.js');
jsFile.setContent(jsContents);
ret.pkg[jsFile.subpath] = jsFile;
cssContents = prefixCss(cssContents, '.amis-scope');
let cssFile = fis.file(root + '/sdk/', tpl.filename + '_aio.css');
let cssFile = fis.file(root, 'sdk.css');
cssFile.setContent(cssContents);
ret.pkg[cssFile.subpath] = cssFile;
entryJs = entryJs.replace(/[\r\n]/g, '').replace(/"/g, '\\"');
contents = "(function(css, js) {"+entryJs+"})('" + cssFile.getUrl() +"', '" + jsFile.getUrl() + "')";
contents += '\n// jsurl=' + jsFile.getUrl();
contents += '\n// cssurl=' + cssFile.getUrl();
tpl.setContent(contents);
// tpl.setContent(contents);
caches[tpl.id] = contents;
};

View File

@ -1,6 +1,5 @@
const __moduleId = (str: string) => '';
import './openUtils';
const mapping: {
[propName: string]: any;
@ -14,7 +13,6 @@ const mapping: {
'react-select': __moduleId('react-select'),
'react-cropper': __moduleId('react-cropper'),
'react-dropzone': __moduleId('react-dropzone'),
'aui': __moduleId('amis'),
'react-bootstrap': __moduleId('react-bootstrap'),
'classnames': __moduleId('classnames'),
'axios': __moduleId('axios'),
@ -26,11 +24,8 @@ const mapping: {
'zrender': __moduleId('zrender'),
'sortablejs': __moduleId('sortablejs'),
'history': __moduleId('history'),
'@fex/aui': __moduleId('amis'),
'@fex/amis-renderer': __moduleId('amis'),
'amis/utils': __moduleId('./openUtils'),
'amis/util': __moduleId('./openUtils'),
'amis/embed': __moduleId('../embed.tsx'),
'amis': __moduleId('../src'),
'amis/embed': __moduleId('./embed.tsx'),
'prop-types': __moduleId('prop-types'),
'async': __moduleId('async'),
'qs': __moduleId('qs'),

View File

@ -12,7 +12,6 @@ var define;
(function (global) {
var amis = window.amis || {};
// 避免重复加载而导致已定义模块丢失
if (require) {
return;
@ -285,8 +284,4 @@ var define;
require.timeout = 5000;
amis.require = require;
amis.define = define;
window.amis = amis;
})(this);

292
examples/sdk-mod.js Normal file
View File

@ -0,0 +1,292 @@
/**
* @file: mod.js
* @author fis
* ver: 1.0.13
* update: 2016/01/27
* https://github.com/fex-team/mod
*/
var require;
/* eslint-disable no-unused-vars */
var define;
(function (global) {
var amis = window.amis || {};
// 避免重复加载而导致已定义模块丢失
if (require) {
return;
}
var head = document.getElementsByTagName('head')[0];
var loadingMap = {};
var factoryMap = {};
var modulesMap = {};
var scriptsMap = {};
var resMap = {};
var pkgMap = {};
var createScripts = function (queues, onerror) {
var docFrag = document.createDocumentFragment();
for (var i = 0, len = queues.length; i < len; i++) {
var id = queues[i].id;
var url = queues[i].url;
if (url in scriptsMap) {
continue;
}
scriptsMap[url] = true;
var script = document.createElement('script');
if (onerror) {
(function (script, id) {
var tid = setTimeout(function () {
onerror(id);
}, require.timeout);
script.onerror = function () {
clearTimeout(tid);
onerror(id);
};
var onload = function () {
clearTimeout(tid);
};
if ('onload' in script) {
script.onload = onload;
}
else {
script.onreadystatechange = function () {
if (this.readyState === 'loaded' || this.readyState === 'complete') {
onload();
}
};
}
})(script, id);
}
script.type = 'text/javascript';
script.src = url;
docFrag.appendChild(script);
}
head.appendChild(docFrag);
};
var loadScripts = function (ids, callback, onerror) {
var queues = [];
for (var i = 0, len = ids.length; i < len; i++) {
var id = ids[i];
var queue = loadingMap[id] || (loadingMap[id] = []);
queue.push(callback);
//
// resource map query
//
var res = resMap[id] || resMap[id + '.js'] || {};
var pkg = res.pkg;
var url;
if (pkg) {
url = pkgMap[pkg].url || pkgMap[pkg].uri;
}
else {
url = res.url || res.uri || id;
}
queues.push({
id: id,
url: url
});
}
createScripts(queues, onerror);
};
define = function (id, factory) {
id = id.replace(/\.js$/i, '');
factoryMap[id] = factory;
var queue = loadingMap[id];
if (queue) {
for (var i = 0, n = queue.length; i < n; i++) {
queue[i]();
}
delete loadingMap[id];
}
};
require = function (id) {
// compatible with require([dep, dep2...]) syntax.
if (id && id.splice) {
return require.async.apply(this, arguments);
}
id = require.alias(id);
var mod = modulesMap[id];
if (mod) {
return mod.exports;
}
//
// init module
//
var factory = factoryMap[id];
if (!factory) {
throw '[ModJS] Cannot find module `' + id + '`';
}
mod = modulesMap[id] = {
exports: {}
};
//
// factory: function OR value
//
var ret = (typeof factory === 'function') ? factory.apply(mod, [require, mod.exports, mod]) : factory;
if (ret) {
mod.exports = ret;
}
return mod.exports;
};
require.async = function (names, onload, onerror) {
if (typeof names === 'string') {
names = [names];
}
var needMap = {};
var needNum = 0;
var needLoad = [];
function findNeed(depArr) {
var child;
for (var i = 0, n = depArr.length; i < n; i++) {
//
// skip loading or loaded
//
var dep = require.alias(depArr[i]);
if (dep in needMap) {
continue;
}
needMap[dep] = true;
if (dep in factoryMap) {
// check whether loaded resource's deps is loaded or not
child = resMap[dep] || resMap[dep + '.js'];
if (child && 'deps' in child) {
findNeed(child.deps);
}
continue;
}
needLoad.push(dep);
needNum++;
child = resMap[dep] || resMap[dep + '.js'];
if (child && 'deps' in child) {
findNeed(child.deps);
}
}
}
function updateNeed() {
if (0 === needNum--) {
var args = [];
for (var i = 0, n = names.length; i < n; i++) {
args[i] = require(names[i]);
}
onload && onload.apply(global, args);
}
}
findNeed(names);
loadScripts(needLoad, updateNeed, onerror);
updateNeed();
};
require.ensure = function (names, callback) {
require.async(names, function () {
callback && callback.call(this, require);
});
};
require.resourceMap = function (obj) {
var k;
var col;
// merge `res` & `pkg` fields
col = obj.res;
for (k in col) {
if (col.hasOwnProperty(k)) {
resMap[k] = col[k];
}
}
col = obj.pkg;
for (k in col) {
if (col.hasOwnProperty(k)) {
pkgMap[k] = col[k];
}
}
};
require.loadJs = function (url) {
if (url in scriptsMap) {
return;
}
scriptsMap[url] = true;
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
head.appendChild(script);
};
require.loadCss = function (cfg) {
if (cfg.content) {
var sty = document.createElement('style');
sty.type = 'text/css';
if (sty.styleSheet) { // IE
sty.styleSheet.cssText = cfg.content;
}
else {
sty.innerHTML = cfg.content;
}
head.appendChild(sty);
}
else if (cfg.url) {
var link = document.createElement('link');
link.href = cfg.url;
link.rel = 'stylesheet';
link.type = 'text/css';
head.appendChild(link);
}
};
require.alias = function (id) {
return id.replace(/\.js$/i, '');
};
require.timeout = 5000;
amis.require = require;
amis.define = define;
window.amis = amis;
})(this);

View File

@ -15,11 +15,10 @@
<!--STYLE_PLACEHOLDER-->
</head>
<body>
<script src="./mod.js"></script>
<script data-loader src="./sdk-mod.js"></script>
<script>
/* @require "./embed.tsx" */
/* @require "./utils/loader" */
/* @require "./static/loader" */
/* @require "./loader" */
(function (w) {
var amis = w.amis || {};
amis.resource = {

View File

@ -1,260 +0,0 @@
/**
* @file mod-sandbox.js.
* @author liyong18@baidu.com
*/
/* eslint-disable */
(function (global) {
var require, define;
var amis = window.amis || {};
// 避免重复加载而导致已定义模块丢失
var head = document.getElementsByTagName('head')[0];
var loadingMap = {};
var factoryMap = {};
var modulesMap = {};
var scriptsMap = {};
var resMap = {};
var pkgMap = {};
var createScripts = function (queues, onerror) {
var docFrag = document.createDocumentFragment();
for (var i = 0, len = queues.length; i < len; i++) {
var id = queues[i].id;
var url = queues[i].url;
if (url in scriptsMap) {
continue;
}
scriptsMap[url] = true;
var script = document.createElement('script');
if (onerror) {
(function (script, id) {
var tid = setTimeout(function () {
onerror(id);
}, require.timeout);
script.onerror = function () {
clearTimeout(tid);
onerror(id);
};
var onload = function () {
clearTimeout(tid);
};
if ('onload' in script) {
script.onload = onload;
}
else {
script.onreadystatechange = function () {
if (this.readyState === 'loaded' || this.readyState === 'complete') {
onload();
}
};
}
})(script, id);
}
script.type = 'text/javascript';
script.src = url;
docFrag.appendChild(script);
}
head.appendChild(docFrag);
};
var loadScripts = function (ids, callback, onerror) {
var queues = [];
for (var i = 0, len = ids.length; i < len; i++) {
var id = ids[i];
var queue = loadingMap[id] || (loadingMap[id] = []);
queue.push(callback);
//
// resource map query
//
var res = resMap[id] || resMap[id + '.js'] || {};
var pkg = res.pkg;
var url;
if (pkg) {
url = pkgMap[pkg].url || pkgMap[pkg].uri;
}
else {
url = res.url || res.uri || id;
}
queues.push({
id: id,
url: url
});
}
createScripts(queues, onerror);
};
define = function (id, factory) {
id = id.replace(/\.js$/i, '');
factoryMap[id] = factory;
var queue = loadingMap[id];
if (queue) {
for (var i = 0, n = queue.length; i < n; i++) {
queue[i]();
}
delete loadingMap[id];
}
};
require = function (id) {
// compatible with require([dep, dep2...]) syntax.
if (id && id.splice) {
return require.async.apply(this, arguments);
}
id = require.alias(id);
var mod = modulesMap[id];
if (mod) {
return mod.exports;
}
//
// init module
//
var factory = factoryMap[id];
if (!factory) {
throw '[ModJS] Cannot find module `' + id + '`';
}
mod = modulesMap[id] = {
exports: {}
};
//
// factory: function OR value
//
var ret = (typeof factory === 'function') ? factory.apply(mod, [require, mod.exports, mod]) : factory;
if (ret) {
mod.exports = ret;
}
return mod.exports;
};
require.async = function (names, onload, onerror) {
if (typeof names === 'string') {
names = [names];
}
var needMap = {};
var needNum = 0;
var needLoad = [];
function findNeed(depArr) {
var child;
for (var i = 0, n = depArr.length; i < n; i++) {
//
// skip loading or loaded
//
var dep = require.alias(depArr[i]);
if (dep in needMap) {
continue;
}
needMap[dep] = true;
if (dep in factoryMap) {
// check whether loaded resource's deps is loaded or not
child = resMap[dep] || resMap[dep + '.js'];
if (child && 'deps' in child) {
findNeed(child.deps);
}
continue;
}
needLoad.push(dep);
needNum++;
child = resMap[dep] || resMap[dep + '.js'];
if (child && 'deps' in child) {
findNeed(child.deps);
}
}
}
function updateNeed() {
if (0 === needNum--) {
var args = [];
for (var i = 0, n = names.length; i < n; i++) {
args[i] = require(names[i]);
}
onload && onload.apply(global, args);
}
}
findNeed(names);
loadScripts(needLoad, updateNeed, onerror);
updateNeed();
};
require.ensure = function (names, callback) {
require.async(names, function () {
callback && callback.call(this, require);
});
};
require.resourceMap = function (obj) {
var k;
var col;
// merge `res` & `pkg` fields
col = obj.res;
for (k in col) {
if (col.hasOwnProperty(k)) {
resMap[k] = col[k];
}
}
col = obj.pkg;
for (k in col) {
if (col.hasOwnProperty(k)) {
pkgMap[k] = col[k];
}
}
};
require.loadJs = function (url) {
if (url in scriptsMap) {
return;
}
scriptsMap[url] = true;
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
head.appendChild(script);
};
require.alias = function (id) {
return id.replace(/\.js$/i, '');
};
require.timeout = 5000;
amis.require = require;
amis.define = define;
window.amis = amis;
// window.require = window.require || require;
})(this);

View File

@ -1,3 +0,0 @@
import * as amis from '../../src/index';
export default amis;

View File

@ -1,40 +0,0 @@
import {
wrapFetcher,
filter
} from '../../src/index';
import axios from 'axios';
export const fetch = wrapFetcher(({
url,
method,
data,
config
}:any) => {
config = config || {};
if (method !== 'post' && method !== 'put' && method !== 'patch') {
if (data) {
config.params = data;
}
return (axios as any)[method](url, config);
} else if (data && data instanceof FormData) {
// config.headers = config.headers || {};
// config.headers['Content-Type'] = 'multipart/form-data';
} else if (data
&& typeof data !== 'string'
&& !(data instanceof Blob)
&& !(data instanceof ArrayBuffer)
) {
data = JSON.stringify(data);
config.headers = config.headers || {};
config.headers['Content-Type'] = 'application/json';
}
return (axios as any)[method](url, data, config);
});
export {
filter
};

View File

@ -111,27 +111,6 @@ fis.match('/node_modules/monaco-editor/min/**/loader.js', {
}
});
fis.match('{/node_modules/font-awesome/fonts/(*), /node_modules/bootstrap/dist/fonts/(*)}', {
release: '/sdk/$1'
});
fis.match('**.{js,jsx,ts,tsx}', {
moduleId: function (m, path) {
return fis.util.md5('amis' + path);
}
});
fis.match('::package', {
postpackager: [
fis.plugin('loader', {
useInlineMap: false,
resourceType: 'mod'
}),
require('./build/embed-packager')
]
});
fis.hook('node_modules', {
shimProcess: false,
shimGlobal: false,
@ -141,26 +120,6 @@ fis.hook('commonjs', {
extList: ['.js', '.jsx', '.tsx', '.ts']
});
fis.match('monaco-editor/**.js', {
isMod: false,
standard: null,
packTo: null
});
fis.on('compile:optimizer', function (file) {
if (file.isJsLike && file.isMod) {
var contents = file.getContent();
if (typeof contents === 'string' && contents.substring(0, 7) === 'define(') {
contents = 'amis.' + contents;
contents = contents.replace('function(require, exports, module)', 'function(require, exports, module, define)');
file.setContent(contents);
}
}
});
fis
.media('dev')
.match('/node_modules/**.js', {
@ -267,6 +226,180 @@ if (fis.project.currentMedia() === 'publish') {
});
// publishEnv.unhook('node_modules');
publishEnv.hook('relative');
} else if (fis.project.currentMedia() === 'publish-sdk') {
const env = fis.media('publish-sdk');
env.get('project.ignore').push(
'sdk/**'
);
env.set('project.files', [
'examples/sdk-placeholder.html'
]);
env.match('/{examples,scss}/(**)', {
release: '/$1',
});
env.match('*.map', {
release: false
});
env.match('/node_modules/(**)', {
release: '/thirds/$1'
});
env.match('/node_modules/(*)/dist/(**)', {
release: '/thirds/$1/$2'
});
env.match('/node_modules/monaco-editor/min/(**)', {
release: '/thirds/monaco-editor/$1'
});
env.match('*.scss', {
parser: fis.plugin('node-sass', {
sourceMap: false
})
});
env.match('{*.ts,*.jsx,*.tsx,/src/**.js,/src/**.ts}', {
parser: [fis.plugin('typescript', {
importHelpers: true,
esModuleInterop: true,
experimentalDecorators: true,
sourceMap: false
}),
function (content) {
return content.replace(/\b[a-zA-Z_0-9$]+\.__uri\s*\(/g, '__uri(')
}],
preprocessor: fis.plugin('js-require-css'),
isMod: true,
rExt: '.js'
});
env.match('/examples/sdk-mod.js', {
isMod: false
});
env.match('*.{js,jsx,ts,tsx}', {
optimizer: fis.plugin('uglify-js'),
moduleId: function (m, path) {
return fis.util.md5('amis-sdk' + path);
},
});
env.match('src/components/Editor.tsx', {
release: '/ide.js'
});
env.match('::package', {
packager: fis.plugin('deps-pack', {
'sdk.js': [
'examples/mod.js',
'/node_modules/**.js',
'examples/embed.tsx',
'examples/embed.tsx:deps',
'!monaco-editor/**',
'!flv.js/**',
'!hls.js/**',
'!froala-editor/**',
'!src/components/RichText.tsx',
'!jquery/**',
'!zrender/**',
'!echarts/**',
'!docsearch.js/**',
],
'rich-text.js': [
'src/components/RichText.tsx',
'froala-editor/**',
'jquery/**',
],
'echarts.js': [
'zrender/**',
'echarts/**',
]
}),
postpackager: [
fis.plugin('loader', {
useInlineMap: false,
resourceType: 'mod'
}),
require('./build/embed-packager')
]
});
env.match('monaco-editor/**.js', {
isMod: false,
standard: null,
optimizer: null,
packTo: null
});
fis.on('compile:optimizer', function (file) {
if (file.isJsLike && file.isMod) {
var contents = file.getContent();
if (file.subpath === '/src/components/Editor.tsx') {
contents = contents.replace(/function\snoJsExt\(raw\)\s\{/, function() {
return `var _path = '';
try {
throw new Error()
} catch (e) {
_path = (/((?:https?|file)\:.*)$/.test(e.stack) && RegExp.$1).replace(/\\/[^\\/]*$/, '');
}
function noJsExt(raw) {`;
})
.replace(/('|")(\.\/thirds.*?)\1/g, function(_, quote, value) {
return `_path + ${quote}${value.substring(1)}${quote}`;
});
}
if (typeof contents === 'string' && contents.substring(0, 7) === 'define(') {
contents = 'amis.' + contents;
contents = contents.replace('function(require, exports, module)', 'function(require, exports, module, define)');
file.setContent(contents);
}
}
});
env.match('/examples/loader.ts', {
isMod: false
});
env.match('*', {
domain: '.',
deploy: [
fis.plugin('skip-packed'),
function(_, modified, total, callback) {
var i = modified.length - 1;
var file;
while ((file = modified[i--])) {
if (file.skiped || /\.map$/.test(file.subpath)) {
modified.splice(i + 1, 1);
}
}
i = total.length - 1;
while ((file = total[i--])) {
if (file.skiped || /\.map$/.test(file.subpath)) {
total.splice(i + 1, 1);
}
}
callback();
},
fis.plugin('local-deliver', {
to: './sdk'
})
]
});
} else if (fis.project.currentMedia() === 'gh-pages') {
const ghPages = fis.media('gh-pages');

View File

@ -72,11 +72,7 @@
"sortablejs": "1.7.0",
"tslib": "^1.9.3",
"uncontrollable": "4.1.0",
"video-react": "0.9.4",
"redux": "^3.7.2",
"css": "2.2.1",
"es6-symbol": "3.1.1",
"copy-to-clipboard": "3.0.8"
"video-react": "0.9.4"
},
"devDependencies": {
"@types/async": "^2.0.45",
@ -134,7 +130,11 @@
"react-testing-library": "6.0.4",
"strip-json-comments": "^2.0.1",
"ts-jest": "^24.0.0",
"typescript": "^3.3.4000"
"typescript": "^3.3.4000",
"redux": "^3.7.2",
"css": "2.2.1",
"es6-symbol": "3.1.1",
"copy-to-clipboard": "3.0.8"
},
"jest": {
"testEnvironment": "jsdom",

View File

@ -7,6 +7,9 @@ rm -rf output
fis3 release publish -c
rm -rf lib/node_modules
# 生成 sdk
rm -rf sdk && fis3 release publish-sdk -c
# 生成 .d.ts 文件
tsc --allowJs --declaration || true