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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@larcjs/core-types

v2.0.0

Published

TypeScript type definitions for @larcjs/core

Readme

@larcjs/core-types

TypeScript type definitions for @larcjs/core.

Installation

npm install @larcjs/core
npm install -D @larcjs/core-types

Usage

Import types alongside your LARC code:

import { PanClient } from '@larcjs/core/pan-client.mjs';
import type { PanMessage, SubscribeOptions } from '@larcjs/core-types';

const client = new PanClient();

// Fully typed!
client.subscribe<{ userId: number }>('user.updated', (msg: PanMessage) => {
  console.log(msg.data.userId); // TypeScript knows this is a number
});

Why Separate Type Packages?

LARC follows a zero-build philosophy. The core packages are pure JavaScript with no dependencies or build step required. TypeScript support is opt-in via separate type packages.

Benefits:

  • Zero-build users never download unnecessary type files
  • Types can evolve independently from runtime code
  • Keeps core packages lean and fast
  • TypeScript users get full type safety

Available Types

Message Types

import type {
  PanMessage,
  SubscribeOptions,
  RequestOptions
} from '@larcjs/core-types';

interface PanMessage<T = any> {
  topic: string;
  data: T;
  id?: string;
  ts?: number;
  retain?: boolean;
  replyTo?: string;
  correlationId?: string;
  headers?: Record<string, string>;
}

Subscription Types

import type {
  MessageHandler,
  UnsubscribeFunction
} from '@larcjs/core-types';

type MessageHandler<T = any> = (message: PanMessage<T>) => void;
type UnsubscribeFunction = () => void;

Configuration Types

import type { AutoloadConfig } from '@larcjs/core-types';

interface AutoloadConfig {
  baseUrl?: string | null;
  componentsPath?: string;
  extension?: string;
  rootMargin?: number;
  componentPaths?: Record<string, string>;
  // ... more options
}

Component Types

import type { PanClient, PanBus } from '@larcjs/core-types';

// PanClient class with full type definitions
const client: PanClient = new PanClient();

// PanBus element type
const bus: PanBus = document.querySelector('pan-bus')!;

Examples

Basic Pub/Sub with Types

import { PanClient } from '@larcjs/core/pan-client.mjs';
import type { PanMessage } from '@larcjs/core-types';

interface UserData {
  id: number;
  name: string;
  email: string;
}

const client = new PanClient();

// Publish with typed data
client.publish<UserData>({
  topic: 'user.updated',
  data: {
    id: 123,
    name: 'Alice',
    email: '[email protected]'
  }
});

// Subscribe with typed handler
client.subscribe<UserData>('user.updated', (msg: PanMessage<UserData>) => {
  console.log(`User ${msg.data.name} updated`);
  // TypeScript knows msg.data has id, name, email
});

Request/Reply Pattern

import { PanClient } from '@larcjs/core/pan-client.mjs';
import type { PanMessage, RequestOptions } from '@larcjs/core-types';

interface GetUserRequest {
  id: number;
}

interface GetUserResponse {
  id: number;
  name: string;
  email: string;
}

const client = new PanClient();

async function getUser(id: number): Promise<GetUserResponse> {
  const response = await client.request<GetUserRequest, GetUserResponse>(
    'users.get',
    { id },
    { timeoutMs: 5000 }
  );

  return response.data;
}

// Usage
const user = await getUser(123);
console.log(user.name); // TypeScript knows user has name, email, id

Auto-Cleanup with AbortController

import { PanClient } from '@larcjs/core/pan-client.mjs';
import type { SubscribeOptions } from '@larcjs/core-types';

const client = new PanClient();
const controller = new AbortController();

const opts: SubscribeOptions = {
  retained: true,
  signal: controller.signal
};

client.subscribe('events.*', (msg) => {
  console.log('Event:', msg);
}, opts);

// Later: automatically unsubscribes
controller.abort();

Type-Only Imports

Use import type to import types without importing runtime code:

// This adds NO runtime code
import type {
  PanMessage,
  PanClient,
  SubscribeOptions
} from '@larcjs/core-types';

// This is the actual runtime import
import { PanClient as PanClientImpl } from '@larcjs/core/pan-client.mjs';

const client: PanClient = new PanClientImpl();

VS Code IntelliSense

Even if you're writing plain JavaScript, you'll get autocomplete and type hints in VS Code when @larcjs/core-types is installed:

// JavaScript file
import { PanClient } from '@larcjs/core/pan-client.mjs';

const client = new PanClient();
client.pub // VS Code suggests "publish"
client.publish({ // VS Code shows parameter hints
  topic: '',
  data: {}
});

License

MIT

Links