@f12io/maple-language-core
v0.0.9
Published
Editor-agnostic language tooling for the Maple CSS: region discovery, class extraction, and the class formatter shared by the VS Code extension and the Prettier plugin.
Maintainers
Readme
@f12io/maple-language-core
Editor-agnostic language tooling for Maple CSS Engine:
region discovery, class extraction, string grammar, and class formatting
logic. This package is the single source of truth consumed by the
Maple VS Code extension
and @f12io/prettier-plugin-maple.
What it provides
LanguageServiceRegistry.getService(languageId)— a language service forhtml,javascript(react),typescript(react),vue,svelte,php,razor,aspnetcorerazor, andtwig.service.collectRegions(text)— every maple region in a document (class attributes,className={...},clsx()/cva()arguments,/* maple */opt-in expressions, framework bindings), typed as raw class text or code expressions.service.extractClasses(text)— class instances with exact document offsets, interpolation-aware per language (JS template literals, C# interpolated strings, PHP blocks, Razor expressions).formatClasses/computeFormattingEdits/formatText— the layout engine: wraps class lists by property group, preserves ternary and concatenation structure, and upgrades string delimiters only when the host language allows multi-line strings.
Usage
import {
LanguageServiceRegistry,
formatText,
} from '@f12io/maple-language-core';
const service = LanguageServiceRegistry.getService('javascriptreact');
const instances = service.extractClasses(source);
const formatted = formatText(source, 'javascriptreact', 4);License
Released under the Root Source License (ROOT), an MIT-style permissive license with an additional distribution condition for systems that can recreate the source on demand. © f12.io
