npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@happysanta/vk-sdk

v1.0.11

Published

JS SDK for VK

Downloads

16

Readme

@happysanta/vk-sdk

JS SDK для VK.

Установка

$ npm i @happysanta/vk-sdk

Настройка

В начале файла, который является отправной точкой приложения.

import VkSdk from "@happysanta/vk-sdk"

VkSdk.init()
    .then(() => {
        console.log('success')
        // Здесь рендерится основной компонент приложения
    })
    .catch(e => {
        console.log(e)
        // Здесь рендерится основной компонент с сообщением об ошибке
    })

Методы

apiVersion

Возвращает текущую версию API.

VkSdk.apiVersion

.getStartParams()

Возвращает набор начальных параметров (accessToken, apiId, groupId и т.д.).

VkSdk.getStartParams()

.resize(w, h)

| Parameter | Type | Required | | -----------|:---------:| ---------:| | w | number | yes | | h | number | yes |

Изменяет размеры фрейма.

VkSdk.resize(w, h)

.setLocation(location, fireEvent)

| Parameter | Type | Required | | -----------|:---------:| ---------:| | location | string | yes | | fireEvent | boolean | yes |

Изменяет хеш текущего адреса страницы, который записывается в адресной строке браузера после символа #. Используется для поддержки кнопок "назад" и "вперед" в браузере. Параметр fireEvent определяет, нужно ли вызывать событие onLocationChanged сразу после запуска метода.

VkSdk.setLocation(location, fireEvent = false)

.shareBox(url, image, text)

| Parameter | Type | Required | | -----------|:---------:| ---------:| | url | string | yes | | image | string | yes | | text | string | yes |

Публикует запись на стене. Параметр url — URL изображения для сниппета, image — URL изображения для сниппета, text — заголовок сниппета.

VkSdk.shareBox(url, image, text)

.addCallback(name, fn)

| Parameter | Type | Required | | -----------|:---------:| ---------:| | name | string | yes | | fn | function | yes |

Добавляет функцию fn в качестве обработчика события с названием name.

VkSdk.addCallback(name, fn)

.removeCallback()

Удаляет функцию из обработчика события.

VkSdk.removeCallback()

.getWindowHeightAndOffset(callback)

| Parameter | Type | Required | | -----------|:---------:| ---------:| | callback | function | yes |

Добавляет функцию callback с тремя параметрами (текущее положение прокрутки окна ВКонтакте, высота окна ВКонтакте в браузере, отступ от начала страницы до объекта с приложением.) в качестве обработчика события onScrollTop и вызывает это событие.

VkSdk.getWindowHeightAndOffset(callback)

.api(method, params, raw)

| Parameter | Type | Required | | -----------|:---------:| ---------:| | method | string | yes | | params | object | yes | | raw | boolean | no |

Вызывает метод API с названием method и набором параметров params.

VkSdk.api(method, params, raw = false)

.requestToken(scope)

| Parameter | Type | Required | | -----------|:---------:| ---------:| | scope | number | yes |

Запрашивает API ключ сообщества. Парметр scope — биютовая маска прав доступа.

VkSdk.requestToken(scope)

.showSettingsBox(scope)

| Parameter | Type | Required | | -----------|:---------:| ---------:| | scope | number | yes |

Запрашивает права доступа у пользователя. Парметр scope — биютовая маска прав доступа.

VkSdk.showSettingsBox(scope)

.setScroll(y)

| Parameter | Type | Required | | -----------|:---------:| ---------:| | y | number | yes |

Инициирует скроллинг окна браузера по вертикали. Параметр y задает смещение скролла относительно нулевой координаты окна.

VkSdk.setScroll(y)

.allowGroupMessage()

Запрашивает разрешение на отправку сообщений текущему пользователю.

VkSdk.allowGroupMessage()

.scrollTop(callback, time)

| Parameter | Type | Required | | -----------|:---------:| ---------:| | callback | function | yes | | time | number | yes |

??

VkSdk.scrollTop(callback, time = 100)

.getScrollPosition(callback)

| Parameter | Type | Required | | -----------|:---------:| ---------:| | callback | function | yes |

??

VkSdk.getScrollPosition(callback)

.callWithToken(method, params)

| Parameter | Type | Required | | -----------|:---------:| ---------:| | method | string | yes | | params | object | yes |

??

VkSdk.callWithToken(method, params)

.callToCode(call)

| Parameter | Type | Required | | -----------|:---------:| ---------:| | call | ? | yes |

??

VkSdk.callToCode(call)

.apiExecute(calls, onSuperFail, onAllCallback)

| Parameter | Type | Required | | --------------|:---------:| ---------:| | call | ? | yes | | onSuperFail | function | yes | | onAllCallback | function | yes |

??

VkSdk.apiExecute(calls, onSuperFail, onAllCallback)

.getLinkToApp(defaultGroupId)

| Parameter | Type | Required | | ---------------|:---------:| ---------:| | defaultGroupId | number | no |

Возвращает ссылку на приложение.

VkSdk.getLinkToApp(defaultGroupId = null)

.mobileShare(url, image, title)

| Parameter | Type | Required | | -----------|:---------:| ---------:| | url | string | yes | | image | string | yes | | title | string | yes |

Открывает оконо шаринга в мобильной версии приложения.

VkSdk.mobileShare(url, image, title)

.desktopShare(url, image, title)

| Parameter | Type | Required | | -----------|:---------:| ---------:| | url | string | yes | | image | string | yes | | title | string | yes |

Открывает оконо шаринга в десктопной версии приложения также как и скрипт https://vk.com/js/api/share.js

VkSdk.desktopShare(url, image, title)

._inlineShare(popup, surl, params, popupName, popupParams)

| Parameter | Type | Required | | ------------|:---------:| ---------:| | popup | ? | yes | | surl | ? | yes | | params | ? | yes | | popupName | ? | yes | | popupParams | ? | yes |

????

VkSdk._inlineShare(popup, surl, params, popupName, popupParams)

.setWidget(type, code)

| Parameter | Type | Required | | -----------|:---------:| ---------:| | type | string | yes | | code | string | yes |

Устанавливает виджета сообщества.

VkSdk.setWidget(type, code)
    .then( res => res ? console.log('Виджет установлен') : console log('Пользователь отказался от установле') )
    .catch( error => console.log('Cообщение об ошибке: ', error) )

Как обновить пакет в npm

Обновить код, в package.json изменить версию, затем:

$ npm adduser // нужно, если пользователь не авторизован
$ npm whoami // проверить авторизован ли пользователь
$ npm publish --access public // если пакет не приватный, иначе не опубликуется

License

MIT.