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

@shapeshift-labs/frontier-triggers

v0.1.1

Published

Capability-gated event trigger registry and deterministic event-to-action orchestration for Frontier apps and games.

Readme

@shapeshift-labs/frontier-triggers

Capability-gated event trigger registry and deterministic event-to-action orchestration for Frontier apps and games. The package lets game, DOM, state, route, and custom runtime systems emit scoped event facts, then evaluates declarative trigger rules that can reject, schedule, dispatch, consume, replay, and inspect downstream actions without taking a hard dependency on those higher-level packages.

API Shape

import { createTriggerRuntime } from '@shapeshift-labs/frontier-triggers';

const runtime = createTriggerRuntime({
  actions,
  scheduler,
  eventLog,
  capabilities: ['game.room.enter', 'inventory.write']
});

runtime.register({
  id: 'room.enter.grant-key',
  event: 'game.room.enter',
  scope: { kind: 'world', id: 'demo-world' },
  subjects: [{ kind: 'entity', role: 'player' }],
  requires: ['inventory.write'],
  when: [
    { path: 'payload.roomId', equals: 'crypt' },
    { path: 'state.flags.cryptKeyGranted', exists: false }
  ],
  oncePer: (event) => event.subject ?? event.id,
  cooldownMs: 250,
  action: {
    id: 'inventory.add',
    lane: 'gameplay',
    key: (event) => 'inventory:' + event.subject
  },
  input: (event) => ({ itemId: 'crypt-key', sourceEvent: event.id }),
  emits: ['inventory.changed'],
  tags: ['gameplay']
});

const result = runtime.require({
  type: 'game.room.enter',
  source: 'inkwell.runtime',
  subject: 'player:local',
  scope: { kind: 'world', id: 'demo-world' },
  subjects: [{ kind: 'entity', id: 'player-local', role: 'player' }],
  payload: { roomId: 'crypt' }
});

if (!result.accepted) {
  console.log(result.rejection?.code);
}

Design Notes

frontier-triggers does not detect collisions, DOM clicks, room transitions, physics, network messages, or state diffs itself. Those systems emit event facts. This package owns the high-level trigger layer that decides whether a matching rule may fire and how its downstream action should be represented.

  • Events use CloudEvents-style routing fields: id, type, source, subject, timestamp, plus Frontier-specific scope, subjects, payload, causeId, and tick.
  • Trigger rules can match event type patterns, source, world/app/DOM/game scopes, one or more entity subjects, arbitrary runtime custom events, and JSON-path-like state or payload conditions.
  • Capability gates are first-class. Missing capabilities produce structured missing-capability rejections; callers can use runtime.require(...) when they need a hard accept/reject result.
  • Outcomes are records, not callback side effects. Every emit returns matched, scheduled, completed, rejected, and failed outcomes with stable rejection codes.
  • Scheduling and action dispatch are structural adapters. A mutation action registry, direct scheduler, game runtime, DOM host, or test harness can be passed in without becoming a dependency.
  • Action bindings can emit follow-up event facts with emit. Cascaded events inherit source, actor, scope, subject, subjects, and tick by default, carry causeId provenance back to the parent event, and are returned in result.records/result.cascaded.
  • once, oncePer, cooldownMs, exclusive, and consume provide common game/event-bus controls while staying deterministic and snapshot-friendly.
  • maxCascadeDepth bounds recursive trigger chains. When a loop would exceed the configured depth, the runtime records a structured cascade-depth rejection instead of recursing forever.
  • snapshot() and restore() capture once/cooldown gates and optional history for rewindable runtimes. replay() re-emits event facts through the same matching rules.
  • Event-log integration appends trigger emit records using the frontier-event-log shape by default, or raw records for simple custom sinks.
  • inspect(), registryGraph(), and impact() expose trigger, event, capability, subject, action, and runtime record relationships for Frontier inspection and AI review flows.

App And Game Use

The same event grammar covers game events such as game.room.enter, game.room.exit, physics.collision.start, physics.collision.end, player.jump, and DOM/app events such as dom.click, route.enter, form.submit, or any runtime-defined custom event.

Actions can trigger downstream rules without leaving the runtime:

runtime.register({
  id: 'collision.damage',
  event: 'physics.collision.start',
  action: {
    id: 'player.damage',
    mode: 'dispatch',
    input: { amount: 1 },
    emit: { type: 'player.damaged', payload: { amount: 1 } }
  }
});

runtime.register({
  id: 'damage.toast',
  event: 'player.damaged',
  action: { id: 'ui.toast', mode: 'dispatch', input: { text: 'Ouch' } }
});

const result = runtime.require({ type: 'physics.collision.start' });
console.log(result.records.map((record) => record.event.type));

Related Packages

The published Frontier package family is generated from one shared package catalog so READMEs stay in sync across packages:

Package source repositories:

Install

npm install @shapeshift-labs/frontier-triggers

Benchmarks

Run the package-local benchmark with:

npm run bench

Frontier-only package measurements cover trigger registration, scoped matching, capability rejection, action scheduling, replay, and registry graph generation using package-local fixtures only. They do not include competitor comparisons.