@codecademy/workshop-client

中文文档
0.24.0发布于 2026/11/05ISCCommonJS近 30 天下载 2782

Client for propeller backend

原始使用文档
文档目录4 节
  1. Testing changes locally
  2. Starting a session
  3. Tracing
  4. Publishing the package

Workshop JavaScript Client Library

The Workshop Client library is installed in Codecademy web clients and provides access from those clients to code execution services (Propeller, previously known as Workshop). Propeller manages a persistent websocket connection allowing clients to sync user code, execute that code in a variety of server environments, run terminal commands, and perform other code/workspace management and execution actions.

Testing changes locally

  1. Check out both this repo and the Codecademy repo
  2. Run yarn build in the workshop-client directory
  3. Run yarn link in the workshop-client directory
  4. In the monorepo, run yarn link @codecademy/workshop-client
  5. Run (or re-run) yarn nx start learning-environment in the monorepo
  6. Verify that you can connect to the LE in your local branch. If you continue to make changes in the client, you'll need to re-yarn build and restart the LE application.

Starting a session

To start a session, create a client instance and connect to workshop.

import WorkshopSession from '@codecademy/workshop-client';

let session = new WorkshopSession({
  protocol: 'https',
  apiBase: 'effective-lamp.cc-propeller.cloud',
  workspaceSlug: 'my-workspace',
  jwt: 'my.user.jwt',
});

session
  .initialize()
  .then(() => {
    // Ready to use
  })
  .catch(error => {
    // Something went wrong
  });

Tracing

The client works with OpenTelemetry tracing, and needs @opentelemetry/api 1.x installed alongside it. Calls to Container API join whatever span is active when you call initialize() or delete():

  • Each request to Container API runs in that span's context. The app's fetch instrumentation then records it as a child span and sends traceparent, so Container API's spans join the same trace.
  • The socket handshake carries traceparent and tracestate as query parameters, because a browser can't set headers on a WebSocket handshake. Only the handshakes made while initialize() waits for the socket to open carry them. A reconnect after that starts a trace of its own.

The client saves the context when the call starts. In the browser, OpenTelemetry tracks the active span with zone.js, which loses it at the first native await, so requests sent later in the call would otherwise start traces of their own. With no tracing set up, the requests and the socket URL are unchanged.

Publishing the package

This package is automatically published when the version number changes

  • merge your PR into main
  • create a new PR that updates the version of the package in package.json. Base the version bump on all of the changes that will be added in this version.
  • merge the version PR into main
  • check the actions to see when the package is published

版本与发布记录

@codecademy/workshop-client 共发布 105 个版本,首次发布于 2016/03/25;过去 12 个月发布了 4 个版本。

版本发布日期距今
0.24.0latest2026/11/055 天前
0.23.22026/10/3110 天前
0.23.12026/10/3011 天前
0.23.02026/10/2912 天前
0.22.02024/10/092 年前
0.21.1-canary.02024/10/082 年前

其他发布通道:next → 0.6.4-0,beta → 0.9.0-beta2。

关于 @codecademy/workshop-client 的常见问题

@codecademy/workshop-client 是什么?

Client for propeller backend

如何安装 @codecademy/workshop-client?

在项目目录运行 npm install @codecademy/workshop-client,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@opentelemetry/api(^1.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@codecademy/workshop-client 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/codecademy__workshop-client 是否存在。

@codecademy/workshop-client 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@codecademy/workshop-client 可以商用吗?

@codecademy/workshop-client 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@codecademy/workshop-client 的下载量有多少?

根据 npm 官方下载统计,@codecademy/workshop-client 在 2026/10/10 – 2026/11/08 这 30 天内被下载 2,782 次,日均约 93 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@codecademy/workshop-client 还在维护吗?

最新版本 0.24.0 发布于 2026/11/05(5 天前);至今共发布 105 个版本,其中过去 12 个月发布了 4 个;首次发布于 2016/03/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。