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

@vue-airport/plugins-base

v2.0.0

Published

Base plugins for vue-airport (activeItem, debounce, history)

Readme

@vue-airport/plugins-base

npm version License: MIT

Base plugin collection for vue-airport - A generic check-in system for Vue 3 component registration patterns.

📖 Documentation

Full documentation is available at: https://benoitlahoz.github.io/vue-airport

✨ Plugins Included

  • 🎯 Active Item - Manage active/selected items in your desk
  • 📜 History - Track all check-in/check-out/update operations
  • ⏱️ Debounce - Debounce event notifications for batch processing

📦 Installation

# npm
npm install vue-airport @vue-airport/plugins-base

# yarn
yarn add vue-airport @vue-airport/plugins-base

# pnpm
pnpm add vue-airport @vue-airport/plugins-base

# bun
bun add vue-airport @vue-airport/plugins-base

🚀 Usage

Active Item Plugin

Track and manage the currently active/selected item in your desk.

<script setup lang="ts">
import { useCheckIn } from 'vue-airport';
import { createActiveItemPlugin } from '@vue-airport/plugins-base';

interface TabItem {
  label: string;
  content: string;
}

const { createDesk } = useCheckIn<TabItem>();
const { desk } = createDesk('tabs', {
  plugins: [createActiveItemPlugin()]
});

// Set active item
desk.setActive('tab-1');

// Get active item
const activeItem = desk.getActive();

// Check if has active
console.log(desk.hasActive); // true

// Clear active
desk.clearActive();

// Listen to active changes
desk.on('active-changed', ({ id, data }) => {
  console.log('Active item changed:', id, data);
});
</script>

API:

  • desk.setActive(id) - Set active item by ID
  • desk.getActive() - Get current active item
  • desk.clearActive() - Clear active selection
  • desk.hasActive - Computed boolean indicating if there's an active item
  • desk.activeId - Ref containing the active item ID

History Plugin

Track all operations performed on the desk with timestamps.

<script setup lang="ts">
import { useCheckIn } from 'vue-airport';
import { createHistoryPlugin, type HistoryEntry } from '@vue-airport/plugins-base';

interface Item {
  title: string;
}

const { createDesk } = useCheckIn<Item>();
const { desk } = createDesk('items', {
  plugins: [
    createHistoryPlugin({
      maxHistory: 100 // Keep last 100 operations
    })
  ]
});

// Perform operations (automatically tracked)
desk.checkIn('item-1', { title: 'First' });
desk.update('item-1', { title: 'Updated' });
desk.checkOut('item-1');

// Get full history
const history = desk.getHistory();

// Get last N operations
const recent = desk.getLastHistory(10);

// Filter by action type
const checkIns = desk.getHistoryByAction('check-in');
const checkOuts = desk.getHistoryByAction('check-out');
const updates = desk.getHistoryByAction('update');

// Clear history
desk.clearHistory();
</script>

API:

  • desk.getHistory() - Get all history entries
  • desk.getLastHistory(n) - Get last N history entries
  • desk.getHistoryByAction(action) - Filter history by action type
  • desk.clearHistory() - Clear all history

History Entry:

interface HistoryEntry<T> {
  action: 'check-in' | 'check-out' | 'update';
  id: string | number;
  data?: T;
  timestamp: number;
}

Debounce Plugin

Debounce event notifications for batch processing.

<script setup lang="ts">
import { useCheckIn } from 'vue-airport';
import { createDebouncePlugin } from '@vue-airport/plugins-base';

interface SearchResult {
  query: string;
  results: string[];
}

const { createDesk } = useCheckIn<SearchResult>();
const { desk } = createDesk('search', {
  plugins: [
    createDebouncePlugin({
      checkInDelay: 500,    // Debounce check-in events by 500ms
      checkOutDelay: 300,   // Debounce check-out events by 300ms
      maxWait: 2000,        // Force invoke after 2s max
    })
  ]
});

// Listen to debounced events
desk.onDebouncedCheckIn?.((id, data) => {
  console.log('Debounced check-in:', id, data);
  // This will only fire after 500ms of inactivity
  // or after 2s max (maxWait)
});

desk.onDebouncedCheckOut?.((id) => {
  console.log('Debounced check-out:', id);
});

// Rapid check-ins (only last batch will trigger callback)
desk.checkIn('result-1', { query: 'a', results: [] });
desk.checkIn('result-2', { query: 'ab', results: [] });
desk.checkIn('result-3', { query: 'abc', results: [] });
// onDebouncedCheckIn will fire once with all 3

// Manual control
desk.flushPendingCheckIns?.();   // Force process pending check-ins
desk.flushPendingCheckOuts?.();  // Force process pending check-outs
desk.cancelPendingCheckIns?.();  // Cancel pending check-ins
desk.cancelPendingCheckOuts?.(); // Cancel pending check-outs

// Get pending count
const pendingCheckIns = desk.getPendingCheckInCount?.();
const pendingCheckOuts = desk.getPendingCheckOutCount?.();
</script>

API:

  • desk.onDebouncedCheckIn(callback) - Set callback for debounced check-ins
  • desk.onDebouncedCheckOut(callback) - Set callback for debounced check-outs
  • desk.flushPendingCheckIns() - Force process pending check-ins
  • desk.flushPendingCheckOuts() - Force process pending check-outs
  • desk.cancelPendingCheckIns() - Cancel pending check-ins
  • desk.cancelPendingCheckOuts() - Cancel pending check-outs
  • desk.getPendingCheckInCount() - Get pending check-in count
  • desk.getPendingCheckOutCount() - Get pending check-out count

🔌 Combining Plugins

You can use multiple plugins together. For validation, please use @vue-airport/plugins-validation:

<script setup lang="ts">
import { useCheckIn } from 'vue-airport';
import {
  createActiveItemPlugin,
  createHistoryPlugin,
  createDebouncePlugin
} from '@vue-airport/plugins-base';
import { createValidationPlugin } from '@vue-airport/plugins-validation';

const { createDesk } = useCheckIn<MyData>();
const { desk } = createDesk('my-desk', {
  plugins: [
    createActiveItemPlugin(),
    createValidationPlugin({ required: ['name'] }),
    createHistoryPlugin({ maxHistory: 50 }),
    createDebouncePlugin({ checkInDelay: 300 })
  ]
});
</script>

🛠️ Creating Custom Plugins

You can create your own plugins following the plugin API:

import type { CheckInPlugin, DeskCore } from 'vue-airport';

export const createMyPlugin = <T = unknown>(): CheckInPlugin<T> => ({
  name: 'my-plugin',
  version: '1.0.0',

  install: (desk: DeskCore<T>) => {
    // Initialize plugin state
    return () => {
      // Cleanup when desk is destroyed
    };
  },

  methods: {
    myMethod(desk: DeskCore<T>, ...args: any[]) {
      // Add custom methods to desk
    }
  },

  computed: {
    myComputed: (desk: DeskCore<T>) => {
      // Add computed properties
      return computed(() => /* ... */);
    }
  },

  onCheckIn(id, data, desk) {
    // Called when item checks in
  },

  onCheckOut(id, desk) {
    // Called when item checks out
  },

  onUpdate(id, data, desk) {
    // Called when item updates
  },

  beforeCheckIn(id, data, desk) {
    // Called before check-in, can prevent it by returning false
    return true;
  }
});

📄 License

MIT © Benoit Lahoz

🔗 Links