html5-animation-video-renderer icon indicating copy to clipboard operation
html5-animation-video-renderer copied to clipboard

Multiple Issues - Make a simple lib

Open drveresh opened this issue 1 year ago • 5 comments

I tried several combinations but faced numerous issues as shown below, please make it as a plain lib and let us use it as a lib. The actual document and its code give conflicting ideas and are hard to run and test it.

Most of us want to use it as a lib/api, so don't make it or document it as a standalone command.

Also, I tried to give the local HTML file in the same path but didn't work.

drveresh avatar Sep 22 '22 03:09 drveresh

Hi @drveresh and thanks for your interest.

Creating a reusable library is out of the scope for this project right now, and I currently have no plans to do that.

However all of the logic you need is in a single render.js file, which is less than 400 lines long. Please feel free to copy it into your project and modify it according to your needs.

dtinth avatar Sep 22 '22 06:09 dtinth

I tried it, but it is not clear whether it should be used as a standalone CLI, constructor, method, or nested method, and not sure why express is there on top of it. I got errors like "renderer" is undefined (failing to refer from node_module/), not a function, etc.

I appreciate it if you could create or include one example here without express, it helps a lot of users.

drveresh avatar Sep 22 '22 06:09 drveresh

@drveresh You can delete the lines 296-342. Then you have a CLI without Express.

If you run into errors, please provide a reproduction case and paste an error message in your report, which would make it easier to help.

dtinth avatar Sep 22 '22 07:09 dtinth

@dtinth Thanks, but it is not for CLI. I want to call its methods programmatically like most names libs, like below:

const render = require("html5-animation-video-renderer");
console.log("BEGIN");

//<<<< If debug pointer is put here, then shows "'render' has no methods to call"; 

//render.render("./page1.html", "page.mp4"); //<<<< error: "undefined render" or "render not a function.."

/*render().render("./page1.html", "page.mp4").then(function (output) {
    console.error('Video created in:', output);  //<<<< Same error as above
});*/
console.log("END");

Here, several things are missing or may be you can please finish this program here? You may know what to call its methods.

drveresh avatar Sep 22 '22 11:09 drveresh

@drveresh I see. This project is a CLI and not a library. If you want to use it as a library, you can fork this project and turn it into a library by yourself. Here are some pointers for how to do that:

The main logic is in the main function:

https://github.com/dtinth/html5-animation-video-renderer/blob/23bdaad8e54eded9984568b046a5e05b37ea4373/render.js#L253-L294

You can start from there — extract the code into a new file that exports it as a reusable function, like lib/index.js. Then your IDE should complain about missing functions/variables. You can then move the required pieces over to the new library file.

dtinth avatar Oct 03 '22 01:10 dtinth