API Reference
Package Exports
@snapfill/core provides two entry points:
Main Entry (@snapfill/core)
Functions for direct use in a web page — tree-shakeable, no side effects:
- Form Detection —
scanForFields,classifyByAutocomplete,classifyByRegex - Form Filling —
fillForm,fillElement - Cart Detection —
detectCart,extractFromJsonLd, etc. - Types —
AutofillFieldType,AutofillMappings,AutofillMessage, etc. - Constants —
AUTOCOMPLETE_MAP,REGEX_PATTERNS,TYPE_MAP
Injectable Entry (@snapfill/core/injectable)
Pre-built script strings for WebView injection:
- Injectable Scripts —
snapfillScript,buildFillScript,fillScriptTemplate
Usage Patterns
Pattern 1: WebView Injection
Use the injectable entry to inject scripts into a WebView and communicate via messages. Best for native apps (React Native, Android, iOS).
ts
import { snapfillScript, buildFillScript } from '@snapfill/core/injectable';Pattern 2: Direct Web Use
Use the main entry for direct DOM access in a web page or browser extension. Functions are tree-shakeable.
ts
import { scanForFields, fillForm } from '@snapfill/core';