Skip to content

Commit

Permalink
feat: Add detailed log
Browse files Browse the repository at this point in the history
feat:  Add detailed log
  • Loading branch information
drawcall committed Feb 3, 2024
1 parent 5596e8c commit 971688c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 8 deletions.
10 changes: 10 additions & 0 deletions lib/center/center.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const FFCreatorCenter = {
num: 0,
delay: 500,
state: 'free',
log: false,
temps: {},
progress: new Progress(),
event: new EventEmitter(),
Expand All @@ -53,6 +54,10 @@ const FFCreatorCenter = {
FFLogger.enable = true;
},

openCatchLog() {
this.log = true;
},

/**
* Add a production task
* @param {function} task - a production task
Expand Down Expand Up @@ -175,11 +180,16 @@ const FFCreatorCenter = {
this.initCreator(creator, taskObj);
}
} catch (error) {
if (this.log) console.log(error);
this.handlingError({ taskObj, error });
}
},

initCreator(creator, taskObj) {
if (creator.destroyed) {
return setTimeout(this.nextTask.bind(this), this.delay);
}

creator.inCenter = true;
creator.generateOutput();

Expand Down
15 changes: 9 additions & 6 deletions lib/core/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,15 @@ class Renderer extends FFBase {

destroy() {
// GLReset(this.gl)();
this.stream.destroy();
this.timeline.destroy();
this.synthesis.destroy();
this.removeCacheFiles();
this.removeAllListeners();
super.destroy();
try{
this.stream.destroy();
this.timeline.destroy();
this.synthesis.destroy();
this.removeCacheFiles();
this.removeAllListeners();
super.destroy();
}catch(e) {
}

this.stop = true;
this.gl = null;
Expand Down
3 changes: 3 additions & 0 deletions lib/creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class FFCreator extends FFCon {
this.inCenter = false;
this.conf = new Conf(conf);
this.loader = new Loader();
this.destroyed = false;

this.createApp();
this.createRenderer();
Expand Down Expand Up @@ -275,6 +276,7 @@ class FFCreator extends FFCon {
async start(delay = 25) {
await Utils.sleep(delay);
await this.checkDurationOfLegalTransitions();
if (this.destroyed) return;
this.addRenderEvent();
this.renderer.start();
}
Expand Down Expand Up @@ -408,6 +410,7 @@ class FFCreator extends FFCon {
this.destroyApp();
super.destroy();

this.destroyed = true;
this.conf = null;
this.loader = null;
this.display = null;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ffcreator",
"version": "7.2.2",
"version": "7.3.1",
"description": "FFCreator is a lightweight and flexible short video production library",
"main": "lib/index.js",
"types": "types/index.d.ts",
Expand Down
2 changes: 2 additions & 0 deletions types/lib/FFCreator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ declare namespace FFCreatorSpace {
*/
setCover(cover: string): void;

destroy():void;

/**
* Create new effect and add to effects object
* @param name the new effect name
Expand Down
2 changes: 1 addition & 1 deletion types/lib/FFEventer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ declare namespace FFCreatorSpace {
*/
bubble(eventer: unknown): void;

destory(): void;
destroy(): void;
}
}

0 comments on commit 971688c

Please sign in to comment.