Wondering what’s next for npm?Check out our public roadmap! »

@dg1com/kina-tools

1.5.1 • Public • Published

Kina tools for generating Kina Url from JS

How to make it shine

  1. npm install
  2. npm run build

Build generate 2 versions of lib for usage in node & browser (web)

After updating this lib next things needs to be checked:

  • Sirius dependency
  • CakeMonster core Lib

Usages

In Browser

<script type="application/javascript" src="KinaTools.js"></script>
KinaTools.createUrl(parameters);

In Node

import KinaTools from '@dg1com/kina-tools'
KinaTools.createUrl(parameters)

Lib usage

KinaTools has two main functionalities:

  • To return parameters according to the forwarded URL getParametersFromUrl(url)
  • To create appropriate URL depending on forwarded parameters. class initUrl(domain, client, clientRegion, resourcesDomain, fileId, fileName, actions) method: addActions(actions: String[] | Object[]) → returns url {String} actions parameter: Array of actions in the following format
const actions = [
   {
      "resize":{
         "width":35,
         "height":45,
         "aspectRatio":true,
         "minSize":true
      }
    
    },
   {
      "crop":{
         "points":[
            34,
            56,
            67,
            87
         ],
         "zoom":1.45     
       }
    
    },
   "original",
   "optimize",
   {
      "subDirectory":"0-15"
    },
   {
      "imageQuality":"90"
   },
   "fileinfo",
   {
      "format": "png"
   }
]

const parameters = {
        actions : actions,
        clientId: <clientValue>,
        domain  : <clientDomain>,
        fileId  : <fileId>,
        fileName: <fileName>
    }

const url = KinaTools.createUrl(parameters)

User need to replace values which are in "<>" brackets.

Actions are optional.

Install

npm i @dg1com/kina-tools

DownloadsWeekly Downloads

13

Version

1.5.1

License

MIT

Unpacked Size

164 kB

Total Files

48

Last publish

Collaborators

  • avatar