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

@perceptimagery/sprie-widget-cal

v1.0.0-cal

Published

`Version : 0.1.1017`

Downloads

7

Readme

@perceptimagery/sprie-widget

Version : 0.1.1017

Quick Start

Make sure you acquire apikey from Sprie and have a product registered and catalogued by Sprie beforehand.

<!-- STEP 1. Load React CDN Scripts -->
<script src="https://cdn.jsdelivr.net/npm/@perceptimagery/sprie-widget"></script>


<!-- STEP 2. Load Sprie SDK -->
<script src="https://cdn.jsdelivr.net/npm/@perceptimagery/sprie-widget"></script>


<!-- STEP 3. Intialize  -->
<script>
SprieSDK.Init({ apiKey:"xxx-xxx-xxx" });
</script>


<!-- STEP 6. Trigger -->
<button onclick="SprieSDK.Load('product-sku');"> Preview </button>

SDK Reference

Sprie SDK is built on React and is released as umd library which depends on react libs (must be loaded from external cdn). To support both react projects and vanilla JS projects, SprieSDK lib has a Loader object which has following methods to run the react SDK as native vanilla SDK.

Methods

  1. Init ({apiKey})
  2. Load (sku)
  3. Check (sku)
  4. CheckBatch (skuArray)
  5. UnmountAll ( )
  6. GetSprieLink ( sku )
  7. HideWidget ( )

Init ( {apiKey } )

SprieSDK.Init( {apiKey:'xxx-xxx-xxx'} ); Must be called only once for apikey authentication. N.B. Must not be called every time product is loaded.

Params
  1. apiKey : string - apiKey received from Sprie Cloud

Load ( sku )

SprieSDK.Load( 'your-product-sku' ); Call everytime you want to load a new asset on AR on Sprie. Only SKU should be provided.

CheckSKU ( sku )

SprieSDK.Check( 'your-product-sku' ); (optional). Can be called to check if the product is registered with Sprie or not. For bulk assets, refer to CheckBatch. Should be used after authentication is done. Response : {<sku>:<boolean>}
Response Example : {"centena-bert-stone":true}

CheckSKUBatch ( skuArray )

SprieSDK.CheckSKUBatch( ['your-product-sku', 'your-product-sku2'] ); (optional). Can be called to check if an array of product skus is registered with Sprie or not. Should be used after authentication is done. Response : [{<sku>:<boolean>]}
Response Example :

[
    { "your-product-sku":true }, // this sku exists
    { "your-product-sku2": false} // this doesn't
]

UnmountAll ( )

SprieSDK.UnmountAll( ); Removes current instance of SprieSDK from website. This action is stateless, which means, refreshing the page will re-mount it again.

GetSprieLink (sku)

SprieSDK.GetSprieLink (sku)
Fetches the share link of the product (with the product page), typically to share it via an app, or show a QR code. this link appends sprie-sku query param with the given sku which helps sprie-widget to open automatically.

HideWidget ( )

SprieSDK.HideWidget ( );
Hides the widget as well as the widget icon.

Events

All Events are based on CustomEvent or Event. You can find the respective data for particular event by standard event.detail.[field].

Auth

  1. SprieEvent:onAuthLoading ({isLoading: boolean}) - ✅
  2. SprieEvent:onAuthOk () - ✅
  3. SprieEvent:onAuthErr ({err: string}) - ✅
  4. SprieEvent:onSDKReady () - ✅
  5. SprieEvent:onSDKErr ({err: string}) - ✅

IO

  1. SprieEvent:onCameraAllowed ( ) - ✅
  2. SprieEvent:onCameraDenied ( ) - ✅
  3. SprieEvent:onCameraError ({err: string}) - ✅

Assets

  1. SprieEvent:onAssetCart ({sku: string}) - ✅
  2. SprieEvent:onAssetWishlist ({sku : string}) - ✅
  3. SprieEvent:onAssetLoading ({sku: string, isLoading: boolean}) - ✅
  4. SprieEvent:onAssetLoadOk ({sku: string}) - ✅
  5. SprieEvent:onAssetLoadErr ({sku: string, err: string}) - ✅
  6. SprieEvent:onCheckAssetSKU ({[sku]:boolean}) - ✅ . e.g. Response : {'your-product-sku':true} // if it already exists
  7. SprieEvent:onCheckAssetSKUBatch ({[sku]:boolean, ...}) - ✅ . e.g. Response : {'your-product-sku':true, 'sku-2':false}

Widget

  1. SprieEvent:onWidgetMinimised ( ) - ✅

Events Example

<script>
    SprieSDK.Init({ apiKey:"xxx-xxx-xxx" });
    document.addEventListener("SprieEvent:onAssetCart", function (e) {
        alert("Added to cart " + e.detail.sku);
    });

    document.addEventListener("SprieEvent:onCameraDenied", function (e) {
        alert("Camera Denied!");
    });

    document.addEventListener("SprieEvent:onCameraError", function (e) {
        alert("Camera Error : " + e.detail.err);
    });
</script>

Advanced Examples

Check particular SKU before rendering the preview trigger button

This code checks the sku with Sprie Network and hides/shows a preview button based on the result. The checking code can return a promise and triggers a convinient event as well (where promises are not supported). This check method must be called only after authentication is successful otherwise unauthenticated API calls will return inconsistent result.

<script>
    const sku = 'my-precious-sku'; 
    let showPreviewButton = false;
    const onAuthDone = function (){
        
        SprieSDK.CheckSKU(sku);
    }

    const onCheckSKU = function (e){
        const result = e.detail; // {'my-precious-sku':true}
        if(result && Object.keys(result)[0]===sku){
            showPreviewButton = result[sku];
        }
    }

    document.addEventListener("SprieEvent:onAuthOk", onAuthDone);
    document.addEventListener("SprieEvent:onCheckAssetSKU", onCheckSKU);

    SprieSDK.Init({ apiKey:"xxx-xxx-xxx" });
</script>

Check array of SKUs on product list page

Similar to CheckSKU method. but takes an array of skus. This method is in alpha. Expect future changes.

<script>
    const arrSku = ['my-precious-sku','my-secondary-sku']; 
    let validSkus = [];
    const onAuthDone = function (){
        SprieSDK.CheckSKUBatch(arrSku);
    }

    const onCheckSKUBatch = function (e){
        const result = e.detail; // [{ 'my-precious-sku':true, 'my-secondary-sku':false }]
        validSkus = Object.keys(result).map(x=>x).filter(x=>result[x]).map(x=>x); // validSkus=['my-precious-sku'];
    }

    document.addEventListener("SprieEvent:onAuthOk", onAuthDone);
    document.addEventListener("SprieEvent:onCheckAssetSKUBatch", onCheckSKUBatch);

    SprieSDK.Init({ apiKey:"xxx-xxx-xxx" });
</script>

Hide widget on minimise

This code hides the widget on receiving the onWidgetMinimised event callback

<script>
     document.addEventListener("SprieEvent:onWidgetMinimised", function () {
        SprieSDK.HideWidget();
     });
</script>

Customize Widget

  • offset: Set possition of the widget
    • h-offset: Move offset by setting up right side position value.
    • v-offset: Move offset by setting up buttom side position value.
  • size: Chnage height width of widget
    • height: Set height of widget
    • width: Set width of widget
    • vertex: Set the corner radius in pixel
  • actionButton :
    • enabled: Includ the button which wants to show/hide
      • share
      • fav
      • cart
      • link
      • snapshot
    • radius: Change the value of corner redius in pixel
    • position: Position of the action buttons (left/right),
    • innerPosition: Position of icon inside button (left/right/center),
    • backgroundColor: Set color of action button background,
    • hoverColor: Set color of action button hover,
    • borderColor: Set color of the action button border,
    • fontHoverColor: Set font color on hover of the action button
  • tooltip:
  • backgroundColor: Set color of tooltip background,
  • typography: Set fontfamily of tooltip ,
  • fontColor": Set font color on tooltip,
  • shadowColor": Set shadow color on tooltip,
  • borderColor": Set border color on tooltip,
  • closeButton:
  • buttonColor: Set button color on tooltip,
  • backgroundColor: Set color of close button background,
  • radius: Set border of the close button border,
  • position: Position of the action buttons (left/right),
  • header:
  • backgroundColor: Set color of header background
  • bodybackgroundColor: Set color of body background
  • title:
  • fontColor: Set font color on title,
  • typography: Set fontfamily of title,
  • shadowColor: Set shadow color of title
  • subTitle:
  • fontColor": Set font color on subtitle,
  • typography":Set fontfamily of subtitle,
  • shadowColor": Set shadow color of subtitle
  • loader:
  • backgroundcolor: Set color of the loader background
  • radius: Set border of the loader dot point border
  • variantStack:
  • position: Position of the variant Stack (center),
  • innerPosition: Position of variant Stack inside (left/right),
  • activeVariantColor": Set active variant color of selected variant
  • productStack:
  • activeProductColor: Set active product color of selected product,
  • activeProductBorder: Set active product border of selected product,
  • radius: Set border of the product stack border,
  • fontColor: Set font color on product title,
  • shadowColor: Set shadow color on product title,
  • typography: Set font fontfamily product title,
  • borderColor: Set border color on product,
  • arrowColor: Set arrow color on slider arrow
  • WidgetSize: Chnage height width of widget
  • height: Set height of widget
  • width: Set width of widget
  • vertex: Set the corner radius in pixel
  • chatHeadImage: Set the image path of the head button
  • button: Set widget button shape (round/square/default)
  • position: Set position of wideget (buttom-right/buttom-left)
  • backgroundColor: Set color of the widget button background,
  • buttonColor": Set color of the button widget button,

Sample Customize Payload

{
    "offset": {
        "h-offset": 3,
        "v-offset": 10
    },
    "size": {
        "height": "60vh",
        "width": "50vw",
        "vertex": "20px"
    },
    "actionButton": {
        "enabled": {
            "share": true,
            "fav": true,
            "cart": true,
            "link": true,
            "snapshot": true
        },
        "icons": "static",
        "radius": "100%",
        "position": "left",
        "innerPosition": "center",
        "backgroundColor": "#2d2c4c",
        "hoverColor": "#d3d3d3",
        "borderColor": "#000000",
        "fontHoverColor": "#000000"
    },
    "tooltip": {
        "backgroundColor": "#000000",
        "typography": "default",
        "fontColor": "#fff",
        "shadowColor": "#ffffff",
        "borderColor": "#000000"
    },
    "closeButton": {
        "buttonColor": "#000000",
        "backgroundColor": "#2cffa7",
        "radius": "100%",
        "position": "buttom-right"
    },
    "header": {
        "backgroundColor": "#2cffa7",
        "bodybackgroundColor": "#f9f3f1"
    },
    "title": {
        "fontColor": "#2d2c4c",
        "typography": "default",
        "shadowColor": "#f9f3f1"
    },
    "subTitle": {
        "fontColor": "#2d2c4c",
        "typography": "default",
        "shadowColor": "#f9f3f1"
    },
    "loader": {
        "backgroundcolor": "#2cffa7",
        "radius": "8px"
    },
    "VariantStack": {
        "position": "center",
        "innerPosition": "left",
        "activeVariantColor": "#000000"
    },
    "ProductStack": {
        "activeProductColor": "#e1e1e1",
        "activeProductBorder": "#00000000",
        "radius": "100%",
        "fontColor": "#2d2c4c",
        "shadowColor": "#ffffff",
        "typography": "default",
        "borderColor": "#aaa",
        "arrowColor": "#2cffa7"
    },
    "widgetSize": {
        "height": "60vh",
        "width": "50vw",
        "vertex": "20px"
    },
    "button": "default",
    "chatHeadImage": "https://sprie-jarvis-public.s3.eu-west-2.amazonaws.com/chatheadimage.png",
    "position": "bottom-right",
    "backgroundColor": "#000000",
    "buttonColor": "#000000",
     "apiVersion": "1",
    "widgetVersion": "1"
}

Test update version

https://cdn.jsdelivr.net/npm/@perceptimagery/sprie-widget