Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next Version & Plugin system #30

Closed
7 tasks done
axe312ger opened this issue Mar 9, 2018 · 8 comments
Closed
7 tasks done

Next Version & Plugin system #30

axe312ger opened this issue Mar 9, 2018 · 8 comments
Assignees
Milestone

Comments

@axe312ger
Copy link
Owner

axe312ger commented Mar 9, 2018

As discussed via PM on twitter with @technopagan and @efegurkan, we should rewrite sqip to be a plugin based system.

This step could be used to refactor the codebase, here is my proposal:

Todo

Possible plugins

If you skip the plugins configuration, we just apply the current defaults to achieve simple blurred svg previews.

Current config:

const sqip = require('sqip');

const result =  sqip({
    filename: './input.jpg',
    numberOfPrimitives: 10,
    mode: 3,
    blur: 8
});

New plugin config:

const sqip = require('sqip');

const result =  sqip({
    filename: './input.jpg',
    plugins: [
      sqip.primitive({
        numberOfPrimitives: 10,
        mode: 3
        // just pass everything to primitive
      }),
      // Add blur if you need it
      sqip.blur({
        factor: 8
        // maybe allow other blur types?
      })
      // Blend in shapes over time (Would be my first plugin)
      sqip.loadingAnimation({
        ease: 'easeIn',
        duration: 3000
      })
    ]
});

The progress of this is tracked in the next branch. PR: #35

@axe312ger axe312ger added this to the 1.0.0 milestone Mar 11, 2018
@axe312ger axe312ger changed the title Plugin system Proposal: Next Version - Plugin system Mar 11, 2018
@efegurkan
Copy link
Collaborator

efegurkan commented Mar 12, 2018

First of all thank you @axe312ger solid plan.

Since we are planning to become a more complex project with these additions. We should also add tests to these plan as well. It should be simple to write unit tests for most of the code and the plugin system would actually help us on there.

For the integration tests, as far as I remember (see #8) primitive will not generate the same result always. Not sure how to approach there exactly. In theory if we mock primitive, we can have some integration tests to test parts that does not include primitive.

@axe312ger
Copy link
Owner Author

Thanks Efe, you are very welcome.

I agree with the tests. I'd go for jest since it gives really good DX :)

We could use cheerio for checking the primitive output. Just count the shapes and see if the type of shapes matches the given mode. At least on a minimal level as it is not our job to ensure primitive is working properly.

@axe312ger axe312ger changed the title Proposal: Next Version - Plugin system Next Version & Plugin system Apr 17, 2018
@axe312ger
Copy link
Owner Author

After #36 is done, the async API can be done with upgrading all dependencies (only svgo missing atm since it is async online since v1)

Straight afterwards we can start creating the plugin api, extracing the blur and make our own plugins. Can't wait to add my svg loading animation plugin 😏

@axe312ger
Copy link
Owner Author

Argh, just realised I will need to implement babel to make proper readably async code for node v6.

I guess there is no way around, I really don't want to nest/chain all the promised. async await is great and is available as soon node v8 gets into LTS... sooo... one year of babel.. I guess we can life with it 😅

@efegurkan
Copy link
Collaborator

Hey Benedikt, I personally wouldn't mind babel stuff. 👍

@axe312ger
Copy link
Owner Author

axe312ger commented Jun 20, 2018 via email

@maxnordlund
Copy link
Contributor

I'm so excited for this, gonna make my life a lot easier 😄 Also, since almost a year has passed node 6 is going bye-bye 🎉

But since babel is already in, let's not add more work to the pile. Thank you for this lovely library ❤️

@axe312ger axe312ger removed this from the 1.0.0 milestone Jun 19, 2019
@axe312ger axe312ger self-assigned this Jun 19, 2019
@axe312ger axe312ger added this to the 1.0.0 milestone Jun 19, 2019
@axe312ger
Copy link
Owner Author

Closed in favor of #90

@maxnordlund you are very welcome to test our new v1 alpha :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants