一键导入
client-modules
Use when setting up or working with Pocopine's managed .client.ts modules for importing npm SDKs (Firebase, analytics, etc.) with typed Rust facades
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when setting up or working with Pocopine's managed .client.ts modules for importing npm SDKs (Firebase, analytics, etc.) with typed Rust facades
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when turning a Claude Design (or any mockup/design) into a well-structured pocopine app — choosing app architecture (a store plus layout/leaf components), translating inline styles into Pine Stylekit, wiring icons and resizable regions, and verifying the result.
Use when working with the pocopine Pine icons feature — the `icon!` proc macro for compile-time Rust SVG embedding, or the `<pine-icon>` template primitive with `register_icons!` for tree-shaking-friendly template rendering.
Use when building styles with Pine Stylekit, the Pocopine-native utility-CSS compiler, or working with @theme tokens and CSS generation in Rust/WASM projects
Use when building enter/leave transitions, layout animations, stagger effects, or spring-physics motion in pocopine components
Use when implementing authentication in pocopine apps — JWT verification, credentials, OAuth providers, session management, or guards
Use when defining background jobs, enqueueing work, configuring workers, or troubleshooting job execution in pocopine apps
| name | client-modules |
| description | Use when setting up or working with Pocopine's managed .client.ts modules for importing npm SDKs (Firebase, analytics, etc.) with typed Rust facades |
Use Pocopine's managed .client.ts modules to import npm SDKs (Firebase, Stripe, analytics) without breaking the ".poco is templates, .rs is logic" contract. The CLI owns TypeScript tooling, type-checking, and bundling; the #[client_module] macro reads explicit types from your .client.ts file and generates a typed Rust facade.
File layout — put .client.ts files under src/:
src/Firebase.client.ts registers as module name firebasesrc/FirebaseAuth.client.ts registers as firebase-auth (kebab case)Rust macro — #[pocopine::client_module(...)]:
#[pocopine::client_module("Firebase.client.ts")]
pub mod client {
use super::bindings::FirebaseUser;
}
Attributes:
#[pocopine::client_module("path.client.ts")] — required file path (relative to the module)#[pocopine::client_module(file = "...", name = "override")] — explicit module name (otherwise derived from filename)Generated facade methods (per .client.ts signature):
Module::required() — returns Result<Module, Error> (fails if module not found)Module::optional() — returns Result<Option<Module>, Error> (graceful None)module.call_async::<T>(method_name) — call async function, get Result<T, Error>module.subscribe::<T>(scope, method_name, handler) — subscribe to callback-based method, auto-unsubscribe on scope dropTypeScript contract — .client.ts default export:
export default {
async methodName(): Promise<ReturnType> { ... },
onEventName(callback: (value: EventType) => void): () => void { ... },
};
Async methods must have explicit Promise<T> return type. Subscription methods must have a callback parameter with explicit callback type. Both convert to snake_case Rust method names (signIn → sign_in, onAuthStateChanged → on_auth_state_changed).
Type binding — use pocopine-ts-rs to generate .ts bindings from Rust DTOs:
#[derive(serde::Deserialize)]
#[cfg_attr(test, derive(pocopine_ts_rs::TS))]
#[cfg_attr(test, ts(export, export_to = "../src/firebase/bindings.ts"))]
#[serde(rename_all = "camelCase")]
pub struct FirebaseUser { pub token: String, pub uid: String, ... }
Run cargo test -p your-app export_bindings to refresh bindings.ts.
CLI commands:
pocopine js init — create/update package.json with esbuild and TypeScriptpocopine js install — install npm packages (respects existing lock file: pnpm/npm/yarn/bun)pocopine js add firebase — add package and update package.jsonpocopine js add -D typescript@latest — add dev dependenciespocopine build / pocopine dev — auto-install missing deps, type-check, bundleFirebase Auth adapter (from examples/keep/src/firebase/):
// Firebase.client.ts
import { initializeApp } from "firebase/app";
import { getAuth, signInWithPopup, onAuthStateChanged } from "firebase/auth";
import type { FirebaseAuthUser } from "./bindings";
type AuthStateCallback = (user: FirebaseAuthUser | null) => void;
type Unsubscribe = () => void;
const auth = getAuth(initializeApp({ projectId: "my-project" }));
export default {
async signIn(): Promise<FirebaseAuthUser | null> {
const credential = await signInWithPopup(auth, provider);
return userPayload(credential.user);
},
onAuthStateChanged(callback: AuthStateCallback): Unsubscribe {
return onAuthStateChanged(auth, async (user) => {
callback(await userPayload(user));
});
},
};
Rust facade (from examples/keep/src/firebase/mod.rs):
#[pocopine::client_module("Firebase.client.ts")]
pub mod client {
use super::bindings::FirebaseAuthUser;
}
Usage in app plugins (from examples/keep/src/firebase/auth.rs):
#[cfg(target_arch = "wasm32")]
impl KeepFirebaseAuth {
pub async fn sign_in(&self) -> Result<Option<FirebaseAuthUser>, String> {
let module = crate::firebase::client::required()?;
module.sign_in().await.map_err(|err| err.to_string())
}
pub fn subscribe(
&self,
scope: ScopeId,
mut handler: impl FnMut(Result<Option<FirebaseAuthUser>, String>) + 'static,
) -> Result<(), String> {
let module = crate::firebase::client::required()?;
module.on_auth_state_changed(scope, move |result| {
handler(result.map_err(|err| err.to_string()));
})
}
}
.client.js — typed .client.ts only; untyped JS rejects at compile time (use DiscoveryPolicy::TypedOnly).client.jsx and .client.tsx are explicitly rejected() => void unsubscribe returns are detected by namesignIn() becomes sign_in(), onAuthStateChanged() becomes on_auth_state_changed() in Rust.client.ts changes rebuild the bundle; package.json changes rerun install and rebundlepocopine doctor warns; determinism breaks/docs/client-modules.md — contract, compilation pipeline, commands, dev moderfcs/rfc-037-js-bridge.md — design, motivation, author surface (Phase 1 shipped)crates/pocopine-client-codegen/src/lib.rs — facade extraction, discovery, and entry generationcrates/pocopine-macros/src/lib.rs — #[client_module] expansion and method code generationcrates/pocopine-ts-rs/src/lib.rs — Rust → TypeScript DTO type generation (#[derive(TS)])examples/keep/src/firebase/ — complete Firebase Auth integration with CLI and store