@lona/serialization
TypeScript icon, indicating that this package has built-in type declarations

0.7.0 • Public • Published

Lona Serialization

Build and Test

Convert Lona files between JSON, and source code (Swift + MDX).

Overview

Lona token files are typically stored as MDX (Markdown with embedded React components).

Token files support a special kind of code block, marked with the language "tokens", that contains Lona token definitions. These definitions can be stored as JSON, or (a small subset of) Swift. This utility converts between the different formats.

API

convertDocument: (String, Format) -> String

Supported formats: 'json', 'source'

Example: Convert a .md document to JSON

import { convertDocument } from '@lona/serialization'

const lonaDocument = '...' // source code of a Lona document

const lonaJson = convertDocument(lonaDocument, 'json')

convertLogic: (String, Format) -> String

Supported formats: 'json', 'source'

Example: Convert a .tokens file to JSON

import { convertLogic } from '@lona/serialization'

const lonaTokens = '...' // source code of a Lona tokens file

const lonaJson = serialization.convertLogic(lonaTokens, 'json')

Readme

Keywords

none

Package Sidebar

Install

npm i @lona/serialization

Weekly Downloads

1

Version

0.7.0

License

MIT

Unpacked Size

1.76 MB

Total Files

521

Last publish

Collaborators

  • dabbott
  • mathieudutour