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

meadow-provider-offline

v1.0.1

Published

Offline-capable Meadow provider with browser-side SQLite and IPC routing.

Readme

Meadow Provider Offline

Offline-capable Meadow provider with browser-side SQLite and transparent RestClient interception

Meadow Provider Offline turns any Fable/Meadow application into an offline-capable one without changing a single line of application code. It wraps the existing Fable RestClient, intercepts requests whose URLs match registered Meadow entity prefixes, and routes them through an in-process Orator IPC layer backed by an in-memory SQLite database (via sql.js WASM, or a native bridge on mobile). Requests that don't match meadow entities pass through to the real HTTP client, preserving auth, external API calls, and anything else your app already does.

The whole system follows the pict-sessionmanager interception pattern -- a connect(restClient) call wraps the client, a disconnect() call restores it. Your models, views, and controllers keep calling getJSON and putJSON with the same URLs they've always used; the provider figures out which ones to handle locally.

Features

  • RestClient Interception -- wraps the existing Fable RestClient rather than replacing it; non-meadow requests pass through unmodified
  • In-Memory SQLite -- browser-side data persistence via sql.js WASM and meadow-connection-sqlite-browser
  • Full Meadow CRUD -- Create, Read, Reads, Update, Delete, and Count endpoints work identically to the server
  • Dirty Record Tracking -- tracks local mutations with intelligent coalescing (create + delete = no-op, create + update = create with latest data)
  • Proactive Data Seeding -- load server data into SQLite before going offline, or inject data from native app wrappers
  • Cache-Through Mode -- GET requests that fall through to the network cache their results locally for next time, never overwriting unsynced dirty records
  • Negative ID Assignment -- offline creates get negative IDs that are remapped to server-assigned positive IDs after sync
  • Native Bridge -- swap sql.js for a native SQLite bridge function, eliminating WASM entirely on mobile
  • Binary / Blob Storage -- offline storage for images, videos, and files via IndexedDB (or a delegate for iOS WKWebView)
  • Connect / Disconnect Pattern -- reversible interception, same approach as pict-sessionmanager
  • First-Class Fable Service -- standard lifecycle, logging, and service manager integration

Quick Start

const libFable = require('fable');
const libMeadowProviderOffline = require('meadow-provider-offline');

const _Fable = new libFable(
    {
        Product: 'MyApp',
        ProductVersion: '1.0.0'
    });

// Register and instantiate the offline provider
_Fable.serviceManager.addServiceType('MeadowProviderOffline', libMeadowProviderOffline);
const tmpOffline = _Fable.serviceManager.instantiateServiceProvider('MeadowProviderOffline',
    {
        SessionDataSource: 'None',
        DefaultSessionObject:
        {
            CustomerID: 1,
            SessionID: 'browser-offline',
            DeviceID: 'Browser',
            UserID: 1,
            UserRole: 'Administrator',
            UserRoleIndex: 255,
            LoggedIn: true
        }
    });

// Initialize (async -- sets up SQLite + Orator IPC)
tmpOffline.initializeAsync((pError) =>
{
    if (pError) { throw pError; }

    // Add entities from Meadow package schema objects
    tmpOffline.addEntity(bookSchema, (pBookError) =>
    {
        tmpOffline.addEntity(authorSchema, (pAuthorError) =>
        {
            // Start intercepting RestClient requests
            tmpOffline.connect(_Fable.RestClient);

            // Seed data (e.g., fetched from server before going offline)
            tmpOffline.seedEntity('Book', bookRecords);
            tmpOffline.seedEntity('Author', authorRecords);

            // Now RestClient.getJSON('/1.0/Books/0/10') routes through
            // IPC -> SQLite instead of HTTP
        });
    });
});

Installation

npm install meadow-provider-offline

How It Works

Normal flow:     getJSON -> executeJSONRequest -> preRequest -> libSimpleGet -> HTTP
Intercepted:     getJSON -> executeJSONRequest (WRAPPED) -> check URL prefix
                   ├── Match   -> Orator IPC -> meadow-endpoints -> SQLite -> callback
                   └── No match -> original executeJSONRequest -> HTTP as normal

The wrapper function replaces RestClient.executeJSONRequest in place and closes over the original. When a request comes in, the interceptor normalises the URL, checks it against the registered entity prefixes, and either routes the request through the in-process Orator IPC server or forwards to the wrapped function. disconnect() restores the original reference, leaving no trace.

Architecture

MeadowProviderOffline (Orchestrator)
  ├── DataCacheManager       -- SQLite via meadow-connection-sqlite-browser
  ├── IPCOratorManager       -- In-process Orator IPC server + meadow-endpoints
  ├── RestClientInterceptor  -- URL matching and request routing
  ├── DirtyRecordTracker     -- Mutation log with coalescing
  └── BlobStoreManager       -- IndexedDB binary storage (or delegate)

Each sub-service is a fable service provider in its own right. You can access any of them via accessors on the main provider (dirtyTracker, dataCacheManager, ipcOratorManager, restClientInterceptor, blobStore).

Documentation

Full documentation lives in the docs folder and is served via pict-docuserve:

Related Packages

License

MIT

Contributing

Pull requests are welcome. For details on our code of conduct, contribution process, and testing requirements, see the Retold Contributing Guide.