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

@dgcode/html-service

v0.1.25

Published

mocked class for google apps script's HtmlService and google.script api

Downloads

4

Readme

@dgcode/html-service

mocked class for google apps script's HtmlService and google.script api

Install

$ npm install @dgcode/html-service

Usage

@dgcode/html-service serves two purposes (which can be used independently):

  • provide a non-functional class (merely useable as type definition) for Google Apps Script's server-side HtmlService API;
  • provide a semi-functional wrapper for Google Apps Script's client-side google.script API.

HtmlService

To get started:

import { HtmlService } from '@dgcode/html-service'

This exposes an object with methods that mirror Google's HtmlService API without any real implementation - when run in Node.

The main purpose of this object is to provide type completion in your favorite IDE, and to seamlessly resolve to the actual HtmlService instance from Google when bundling and publishing your code to Google Apps Script with gscript.

google.script

To get started:

import { google } from '@dgcode/html-service';

The google object provides the 4 major APIs from Google's client-side tools:

Note that the google variable imported here is completely separate from the global google object when you run your script in an Apps Script HTML file. The imported google object will try to mirror as many methods as possible from the global object and execute them when available.

tl;dr: Always import { google } ... from this library and let it handle the tasks for you, regardless of the development environment.

google.script.run

To run a method defined in your server-side code, you can use the helper function .call as below:

| With @dgcode/html-service | The native ("Google") way | |------------------------------------------------------|-----------------------------------------------| | google.script.run.call('someMethod', ...arguments) | google.script.run.someMethod(...arguments) |

For example, if a global foo(number) function was implemented on the server-side, then the client-side script would look like:

import { google } from '@dgcode/html-service';

google.script.run
  .withSuccessHandler(res => {...})
  .withFailureHandler(err => {...})
  .call('foo', 5);

License

MIT