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

@yury.stepanov.work/vss-web-extension-sdk

v5.140.0

Published

Visual Studio Team Services web extension JavaScript library and types.

Downloads

1

Readme

Visual Studio Services Web Extension SDK

Overview

Client SDK and TypeScript declare files for developing Visual Studio Team Services Extensions.

The core SDK script, VSS.SDK.js, enables web extensions to communicate to the host Team Services frame and to perform operations like initializing, notifying extension is loaded or getting context about the current page.

A previous version of the SDK was named vss-sdk. Make sure to switch to the new vss-web-extension-sdk name.

Get the SDK

  1. Download and install Node.js
  2. Run npm install vss-web-extension-sdk from the root of your extension project

This will place VSS.SDK.js and VSS.SDK.min.js in node_modules/vss-web-extension-sdk/lib/

Include the SDK script on your page

If you are developing a web extension, you will need to reference the SDK script from your HTML pages. For example:

<script src="lib/VSS.SDK.min.js"></script>

To ensure the SDK script is packaged with your extension, update your extension manifest (typically vss-extension.json) and add a new entry to files:

{       
	"files": [{
		"path": "node_modules/vss-web-extension-sdk/lib",
		"addressable": true,
		"packagePath": "lib"
	}]
}

Note: setting packagePath is optional, but results in a simpler path for referencing the SDK script from your HTML pages. Not setting a part name would have required you to reference the full path in your <script> tag (src="node_modules/vss-web-extension-sdk/lib/VSS.SDK.min.js")

Use the SDK

From your web extension's HTML page, include and initialize the VSS SDK like this:

<script>

  // Initialize
  VSS.init({
    usePlatformScripts: true, 
    usePlatformStyles: true
  });

  // Register callback to get called when initial handshake completed
  VSS.ready(function() {
    // Start using VSS
  });

</script>

Full API reference of VSS.SDK.js can be found at Core Client SDK page.

Types

Type definitions are provided for:

  • UI controls and client services (see typings/vss.d.ts)
  • REST clients and contracts for Build, Work, and Code (see typings/tfs.d.ts)
  • REST clients and contracts for Release Management (see typings/rmo.d.ts)

Dependency graph:

Dependency Graph

Consuming the types

From a TypeScript 2.5 or later project:

  • Set "moduleResolution": "node" in your tsconfig.json project file

See TypeScript Module Resolution for more details.

Alternatively, you can explicitly reference the types at the top of your TypeScript file(s):

    /// <reference types="vss-web-extension-sdk" />

Organizing your web extension project

If you are developing a web extension for Visual Studio Team Service using TypeScript, we recommend the following organization:

Project structure

 |-- src
     |-- app.ts
     |-- some-module
         |-- a.ts
         |-- b.ts
 |-- static
     |-- css
         |-- main.css
     |-- images
         |-- logo.png
     |-- app.html
 |-- vss-extension.json
 |-- package.json
 |-- tsconfig.json
  1. Place TypeScript source files in src
  2. Place static content (CSS, images, HTML, etc) in static
    • This simplifes the process of packaging all necessary static content in your

TypeScript project file (tsconfig.json)

Defines the options for compiling your TypeScript files.

{
    "compilerOptions": {
        "module": "amd",
        "moduleResolution": "node",
        "target": "es5",
        "rootDir": "src/",
        "outDir": "dist/",
        "types": [
            "vss-web-extension-sdk"
        ]	
    }
}
  1. After compiling (tsc -p .), resulting .js files are placed in dist. For example, dist/app.js.

  2. If your code directly uses types from other @types modules, you will want to include the module(s) in your package.json and add them to the types array. See @types.

Learn more about tsconfig.json

NPM package manifest (package.json)

Declares the libraries (like the vss-web-extension-sdk) required to compile, package, and use your extension.

{
  /* other details like ID, version, etc are omitted */
  
  "scripts": {
    "build": "tsc -p .",
    "postbuild": "npm run package",
    "package": "tfx extension create",
    "gallery-publish": "tfx extension publish --rev-version",
    "clean": "rimraf ./dist && rimraf ./*.vsix"
  },
  "devDependencies": {
    "rimraf": "^2.5.4",
    "tfx-cli": "^0.3.45",
    "typescript": "^2.1.4"
  },
  "dependencies": {
    "@types/jquery": "^2.0.34",
    "@types/q": "0.0.32",
    "vss-web-extension-sdk": "^5.127.0"
  }
}
  1. scripts provides a convenient way to define common operations that you want to perform on your project, like compiling and packaging.
    • For example, to build (compile) and package your extension, run: npm run build. This runs build and postbuild. If you make a change that doesn't require compiling, you can package by simply running npm run package.
    • To package and publish directly to the Marketplace on build, change the postbuild script to run the gallery-publish script (instead of package). You can then run npm run build -- --token xxxxxx (where xxxx is you personal access token for publishing to the Marketplace) to build, package, and publish your extension.
  2. The dependencies on the @types for jquery and q are only necessary if your TypeScript code is directly referencing either of these types.

Learn more about package.json

Extension manifest (vss-extension.json)

{
    /* details omitted */
    "files": [
        {
            "path": "dist",
            "addressable": true
        },
        {
            "path": "static",
            "addressable": true
        },
        {
            "path": "node_modules/vss-web-extension-sdk/lib",
            "addressable": true,
            "packagePath": "lib"
        }
    ],
    "contributions": [
        {
            "id": "my-hub",
            "type": "ms.vss-web.hub",
            "properties": {
                "name": "Hub",
                "uri": "static/app.html"
            }
        }
    ]
}
  1. The compiled JavaScript files (placed into dist by your tsconfig.json) will be packaged into the dist folder of the extension package.

  2. The VSS SDK scripts will be packaged into the lib folder of the extension package.

Learn more about the extension manifest.

HTML page

<head>
   <script src="../lib/VSS.SDK.min.js"></script>
   <!-- 
        Alternatively, if the packagePath attribute is not set for this file in your extension manifest (see above), do this:
         <script src="../node_modules/vss-web-extension-sdk/lib/VSS.SDK.min.js"></script>
   -->
</head>

<body>

 <script type="text/javascript">

  // Initialize the VSS sdk
  VSS.init({
      usePlatformScripts: true,
      usePlatformStyles: true
  });

  VSS.require(["dist/app"], function (app) { 
      ...
  });

 </script>

</body>

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.