Commit 7f47b3d7 authored by rockyl's avatar rockyl

init

parent e301b761
{"id":"svga","url":"svga.bbb584f45f3ee647d0611653cb854c5d5bb8fb47.js"}
\ No newline at end of file
{"id":"svga","url":"svga.min.7c72732a9d648931449e0a98ee3974bf1cebf067.js","url_dbg":"svga.cfb325090b121cc3241616b34fca39c0100f4eab.js"}
\ No newline at end of file
......@@ -4,7 +4,6 @@
"main": "index.js",
"license": "MIT",
"devDependencies": {
"dts-bundle": "^0.7.3",
"glob": "^7.1.6",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
......@@ -12,7 +11,8 @@
"rollup-plugin-typescript": "^1.0.1",
"rollup-plugin-typescript2": "^0.25.2",
"rollup-plugin-uglify": "^6.0.3",
"typescript": "^2.7.2"
"typescript": "^2.7.2",
"dts-bundle-generator": "^4.3.0"
},
"dependencies": {
"protobufjs": "^6.8.8",
......@@ -21,12 +21,15 @@
},
"scripts": {
"dev": "rollup -c -m -w",
"declare": "node scripts/declare.js src/svga/index.ts",
"rollup": "rollup -c -o dist/svga.js",
"rollup:prod": "rollup -c -o dist/svga.js --environment BUILD:production",
"rollup:debug": "rollup -c -m ",
"preprocess": "node scripts/pre-process.js svga dist/svga.js",
"build": "rm -rf dist&&yarn rollup:prod && yarn preprocess && ali-oss-publish -c oss.config.js -e dist",
"build:debug": "rm -rf dist&&yarn rollup && yarn preprocess && ali-oss-publish -c oss.config.js -e dist"
"build": "rollup -c -o dist/svga.js",
"build:prod": "rollup -c -o dist/svga.min.js --environment BUILD:production",
"preprocess:prod": "node scripts/pre-process.js svga dist/svga.min.js prod",
"preprocess:debug": "node scripts/pre-process.js svga dist/svga.js",
"pack:prod": "yarn build:prod && yarn preprocess:prod",
"pack:debug": "yarn build && yarn preprocess:debug",
"upload": "ali-oss-publish -c oss.config.js -e dist",
"publish": "rm -rf dist && yarn pack:debug && yarn pack:prod && yarn upload",
"token": "uglifyjs -m -c -o px-token.min.js px-token.js",
"dts": "dts-bundle-generator -o types.d.ts src/index.ts"
}
}
......@@ -6,7 +6,7 @@ const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
const [_, __, id, fileName] = process.argv;
const [_, __, id, fileName, isProd] = process.argv;
const stream = fs.createReadStream(fileName);
const fsHash = crypto.createHash('sha1');
......@@ -26,10 +26,16 @@ function loadComplete(md5) {
const newFileName = fileName.substr(0, extIndex + 1) + md5 + fileName.substr(extIndex);
fs.renameSync(fileName, newFileName);
let manifest = {
let manifest;
if (fs.existsSync('manifest.json')) {
manifest = JSON.parse(fs.readFileSync('manifest.json', 'utf-8'));
} else {
manifest = {
id,
url: path.basename(newFileName),
};
}
manifest[isProd ? 'url' : 'url_dbg'] = path.basename(newFileName);
fs.writeFileSync('manifest.json', JSON.stringify(manifest));
}
......@@ -31,18 +31,13 @@ export class Svga extends MovieClip {
if (value.indexOf(assetScheme) === 0) {
let uuid = value.replace(assetScheme, '');
let mv = engine.globalLoader.get(uuid);
engine.globalLoader['loadSvga'](engine["assetResolver"](uuid))
.then(mv => {
this.children.length=0
this.init(mv);
this._dataInitialized();
this.mouseChildren=false;
});
needLoad = false;
}
}
if(needLoad){
if(this._source && needLoad){
engine.globalLoader['loadSvga'](value)
.then(mv => {
this.init(mv);
......@@ -59,6 +54,31 @@ export class Svga extends MovieClip {
}
})
}
clone(withEvents?: boolean, withScripts?: boolean): any {
let target = new Svga();
const originConfig = this['__originConfig'];
const {name, properties, events, scripts} = originConfig;
target.name = name;
target['__originConfig'] = originConfig;
engine.injectProperties(target, properties);
if (withScripts) {
if (scripts && scripts.length > 0) {
for (let scriptConfig of scripts) {
engine.instantiateScript(target, scriptConfig);
}
}
}
if (withEvents) {
if (events) {
target['eventsProxy'].start(events);
}
}
return target;
}
}
engine.registerNodeType('svga', Svga);
......
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