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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@1campus/gadget-sdk

v0.1.0

Published

1Campus Gadget SDK — TypeScript type definitions and utilities

Readme

@1campus/gadget-sdk

TypeScript type definitions for the 1Campus Gadget API.

提供全域 gadget 變數的完整型別定義,讓 gadget 開發者在 IDE 中享有 intellisense、型別檢查與 JSDoc 文件提示。

安裝

# pnpm
pnpm add -D @1campus/gadget-sdk

# npm
npm install -D @1campus/gadget-sdk

# yarn
yarn add -D @1campus/gadget-sdk

設定

tsconfig.jsontypes 加入 @1campus/gadget-sdk

{
  "compilerOptions": {
    "types": ["@1campus/gadget-sdk"]
  }
}

或在程式碼中加入 triple-slash directive:

/// <reference types="@1campus/gadget-sdk" />

使用範例

取得當前角色

const role = gadget.getRole();
console.log(`Current role: ${role}`); // teacher / student / parent / admin

呼叫 DSA Service

const contract = gadget.getContract('1campus.mobile.v2.teacher');

contract.send({
  service: 'classroom.GetStudents',
  body: '<Request><Type>Class</Type><UID>1446</UID></Request>',
  result: (response, error) => {
    if (error) {
      console.error('呼叫失敗', error);
      return;
    }
    console.log('學生資料', response);
  }
});

取得 Application 資訊

const app = gadget.getApplication();
console.log(`accessPoint: ${app.accessPoint}`); // 例如 dev.sh_d

讀取自訂 params

// gadget 設定中的 params JSON
const myConfig = gadget.params['myConfigKey'];

已支援 API

| API | 說明 | |-----|------| | getContract(name) | 取得指定 contract 的 DSA connection | | connect(ap, acc, pwd) | 直接連線到指定 accesspoint | | getApplication() | 取得 { accessPoint } | | getRole() | 取得當前角色 | | params | 開發者自訂參數 |

其他 API(如 getUserInfogetPreference 等)在型別定義中標註為 Not supported in current version,呼叫時會顯示 console.warn。

發佈到 npm

# 1. 更新 package.json 的 version

# 2. 預覽發佈內容
cd gadget-sdk
npm pack --dry-run

# 3. 產生 Granular Access Token(因為 @1campus org 強制要求 2FA)
#    去 https://www.npmjs.com/settings/<username>/tokens
#    → Generate New Token → Granular Access Token
#    → Packages: Read and write
#    → 勾選 "Allow publishing with this token without 2FA"

# 4. 發佈
npm publish --access public --registry https://registry.npmjs.org/ --//registry.npmjs.org/:_authToken=<你的token>

# 5. 發佈完成後去 npmjs 網頁刪掉該 token(一次性使用)

License

MIT