Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@readapt/settings

Package Overview
Dependencies
Maintainers
3
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@readapt/settings - npm Package Compare versions

Comparing version 1.4.4 to 1.5.0

18

dist/readapt-settings.esm.js

@@ -253,4 +253,18 @@ const fontFamilyOptions = [

const frSettings = language === 'fr' ? { liaisonsActive: false, liaisonsOpacity: opacityOptions[0].value } : {};
return Object.assign({ language, fontFamily: fontFamilyOptions[0].value, fontSize: fontSizeOptions[0].value, letterSpacing: letterSpacingOptions[0].value, wordSpacing: wordSpacingOptions[0].value, lineSpacing: lineSpacingOptions[0].value, syllableActive: false, syllableOpacity: opacityOptions[0].value, silentLetterActive: false, silentLetterOpacity: opacityOptions[0].value, shadeAlternateLinesActive: false, shadeAlternateLinesOpacity: opacityOptions[0].value, phonemesActive: true, phonemes: buildDefaultPhonemeSettings(language), lettersActive: true, letters: buildDefaultLetterSettings(language) }, frSettings);
return Object.assign({ language, fontFamily: fontFamilyOptions[0].value, fontSize: fontSizeOptions[0].value, letterSpacing: letterSpacingOptions[0].value, wordSpacing: wordSpacingOptions[0].value, lineSpacing: lineSpacingOptions[0].value, syllableActive: false, syllableOpacity: opacityOptions[0].value, silentLetterActive: false, silentLetterOpacity: silentLetterOpacityOptions[0].value, shadeAlternateLinesActive: false, shadeAlternateLinesOpacity: opacityOptions[0].value, phonemesActive: true, phonemes: buildDefaultPhonemeSettings(language), lettersActive: true, letters: buildDefaultLetterSettings(language) }, frSettings);
};
const overrideDefaultColoredItems = (defaultColoredItems, overrides) => defaultColoredItems.map((item) => {
const overridden = overrides.find(({ value }) => item.value === value);
return overridden ? overridden : item;
});
const overrideDefaultLetters = (lang, overrides) => {
const letterOptions = getLangConfig(lang).letterOptions;
const lettersSettings = buildDefaultColoredItems(letterOptions);
return overrideDefaultColoredItems(lettersSettings, overrides);
};
const overrideDefaultPhonemes = (lang, overrides) => {
const phonemesOptions = getLangConfig(lang).phonemeOptions;
const phonemesSettings = buildDefaultColoredItems(phonemesOptions);
return overrideDefaultColoredItems(phonemesSettings, overrides);
};

@@ -268,2 +282,2 @@ /**

export { buildDefaultProfiles, buildDefaultSettings, colors, fontFamilyOptions, fontSizeOptions, getLangConfig, languageOptions, letterSpacingOptions, lineSpacingOptions, opacityOptions, silentLetterOpacityOptions, thicknessOptions, wordSpacingOptions };
export { buildDefaultProfiles, buildDefaultSettings, colors, fontFamilyOptions, fontSizeOptions, getLangConfig, languageOptions, letterSpacingOptions, lineSpacingOptions, opacityOptions, overrideDefaultLetters, overrideDefaultPhonemes, silentLetterOpacityOptions, thicknessOptions, wordSpacingOptions };

@@ -257,4 +257,18 @@ 'use strict';

const frSettings = language === 'fr' ? { liaisonsActive: false, liaisonsOpacity: opacityOptions[0].value } : {};
return Object.assign({ language, fontFamily: fontFamilyOptions[0].value, fontSize: fontSizeOptions[0].value, letterSpacing: letterSpacingOptions[0].value, wordSpacing: wordSpacingOptions[0].value, lineSpacing: lineSpacingOptions[0].value, syllableActive: false, syllableOpacity: opacityOptions[0].value, silentLetterActive: false, silentLetterOpacity: opacityOptions[0].value, shadeAlternateLinesActive: false, shadeAlternateLinesOpacity: opacityOptions[0].value, phonemesActive: true, phonemes: buildDefaultPhonemeSettings(language), lettersActive: true, letters: buildDefaultLetterSettings(language) }, frSettings);
return Object.assign({ language, fontFamily: fontFamilyOptions[0].value, fontSize: fontSizeOptions[0].value, letterSpacing: letterSpacingOptions[0].value, wordSpacing: wordSpacingOptions[0].value, lineSpacing: lineSpacingOptions[0].value, syllableActive: false, syllableOpacity: opacityOptions[0].value, silentLetterActive: false, silentLetterOpacity: silentLetterOpacityOptions[0].value, shadeAlternateLinesActive: false, shadeAlternateLinesOpacity: opacityOptions[0].value, phonemesActive: true, phonemes: buildDefaultPhonemeSettings(language), lettersActive: true, letters: buildDefaultLetterSettings(language) }, frSettings);
};
const overrideDefaultColoredItems = (defaultColoredItems, overrides) => defaultColoredItems.map((item) => {
const overridden = overrides.find(({ value }) => item.value === value);
return overridden ? overridden : item;
});
const overrideDefaultLetters = (lang, overrides) => {
const letterOptions = getLangConfig(lang).letterOptions;
const lettersSettings = buildDefaultColoredItems(letterOptions);
return overrideDefaultColoredItems(lettersSettings, overrides);
};
const overrideDefaultPhonemes = (lang, overrides) => {
const phonemesOptions = getLangConfig(lang).phonemeOptions;
const phonemesSettings = buildDefaultColoredItems(phonemesOptions);
return overrideDefaultColoredItems(phonemesSettings, overrides);
};

@@ -282,4 +296,6 @@ /**

exports.opacityOptions = opacityOptions;
exports.overrideDefaultLetters = overrideDefaultLetters;
exports.overrideDefaultPhonemes = overrideDefaultPhonemes;
exports.silentLetterOpacityOptions = silentLetterOpacityOptions;
exports.thicknessOptions = thicknessOptions;
exports.wordSpacingOptions = wordSpacingOptions;

6

dist/types/defaultSettings.d.ts

@@ -1,4 +0,6 @@

import { Language, Settings } from './models';
import { ColoredItem, Language, Settings } from './models';
declare const buildDefaultSettings: (language: Language) => Settings;
export { buildDefaultSettings };
declare const overrideDefaultLetters: (lang: Language, overrides: ColoredItem[]) => ColoredItem[];
declare const overrideDefaultPhonemes: (lang: Language, overrides: ColoredItem[]) => ColoredItem[];
export { buildDefaultSettings, overrideDefaultLetters, overrideDefaultPhonemes };
//# sourceMappingURL=defaultSettings.d.ts.map
/**
* Represents a Phoneme or Letter to be colored
*/
import { ColorOption } from '../options/colors';
export interface ColoredItem {
key: string;
value: string;
color?: string;
color?: ColorOption;
bold: boolean;

@@ -9,0 +10,0 @@ active: boolean;

@@ -1,5 +0,5 @@

export interface Option {
value: string;
export interface Option<T extends string> {
value: T;
text: string;
}
//# sourceMappingURL=option.d.ts.map
import { Language } from './language';
import { ColoredItem } from './coloredItem';
import { ColorOption, FontFamilyOption, FontSizeOption, LetterSpacingOption, LineSpacingOption, OpacityOption, SilentLetterOpacityOption, WordSpacingOption } from '../options';
export interface Settings {
language: Language;
fontFamily: string;
fontSize: string;
letterSpacing: string;
wordSpacing: string;
lineSpacing: string;
syllableColor1?: string;
syllableColor2?: string;
fontFamily: FontFamilyOption;
fontSize: FontSizeOption;
letterSpacing: LetterSpacingOption;
wordSpacing: WordSpacingOption;
lineSpacing: LineSpacingOption;
syllableColor1?: ColorOption;
syllableColor2?: ColorOption;
syllableActive: boolean;
syllableOpacity: string;
silentLetterOpacity: string;
syllableOpacity: OpacityOption;
silentLetterOpacity: SilentLetterOpacityOption;
silentLetterActive: boolean;
shadeAlternateLinesOpacity: string;
shadeAlternateLinesOpacity: OpacityOption;
shadeAlternateLinesActive: boolean;
liaisonsOpacity?: string;
liaisonsOpacity?: OpacityOption;
liaisonsActive?: boolean;

@@ -20,0 +21,0 @@ phonemesActive: boolean;

@@ -1,2 +0,3 @@

export declare const colors: string[];
export declare const colors: readonly ["#5fa2ce", "#76b7b2", "#b07aa1", "#fc7d0b", "#a3cce9", "#c85200", "#7b848f", "#59a14f", "#ff9da7", "#edc948", "#9c755f", "#ffbc79"];
export declare type ColorOption = typeof colors[number];
//# sourceMappingURL=colors.d.ts.map
import { Option } from '../models';
export declare const fontFamilyOptions: Option[];
export declare type FontFamilyOption = 'inherit' | 'Arial' | 'OpenDyslexic' | 'Luciole';
export declare const fontFamilyOptions: Option<FontFamilyOption>[];
//# sourceMappingURL=fontFamilyOptions.d.ts.map
import { Option } from '../models';
export declare const fontSizeOptions: Option[];
export declare type FontSizeOption = 'inherit' | '140%' | '170%' | '200%';
export declare const fontSizeOptions: Option<FontSizeOption>[];
//# sourceMappingURL=fontSizeOptions.d.ts.map

@@ -1,11 +0,11 @@

export { fontFamilyOptions } from './fontFamilyOptions';
export { fontSizeOptions } from './fontSizeOptions';
export { languageOptions } from './languageOptions';
export { letterSpacingOptions } from './letterSpacingOptions';
export { lineSpacingOptions } from './lineSpacingOptions';
export { opacityOptions } from './opacityOptions';
export { thicknessOptions } from './thicknessOptions';
export { silentLetterOpacityOptions } from './silentLetterOpacityOptions';
export { wordSpacingOptions } from './wordSpacingOptions';
export { colors } from './colors';
export * from './fontFamilyOptions';
export * from './fontSizeOptions';
export * from './languageOptions';
export * from './letterSpacingOptions';
export * from './lineSpacingOptions';
export * from './opacityOptions';
export * from './thicknessOptions';
export * from './silentLetterOpacityOptions';
export * from './wordSpacingOptions';
export * from './colors';
//# sourceMappingURL=index.d.ts.map

@@ -1,3 +0,3 @@

import { Option } from '../models';
export declare const languageOptions: Option[];
import { Language, Option } from '../models';
export declare const languageOptions: Option<Language>[];
//# sourceMappingURL=languageOptions.d.ts.map
import { Option } from '../models';
export declare const letterSpacingOptions: Option[];
export declare type LetterSpacingOption = 'inherit' | '2px' | '3.5px' | '5px';
export declare const letterSpacingOptions: Option<LetterSpacingOption>[];
//# sourceMappingURL=letterSpacingOptions.d.ts.map
import { Option } from '../models';
export declare const lineSpacingOptions: Option[];
export declare type LineSpacingOption = 'inherit' | '2.1' | '2.55' | '3';
export declare const lineSpacingOptions: Option<LineSpacingOption>[];
//# sourceMappingURL=lineSpacingOptions.d.ts.map
import { Option } from '../models';
export declare const opacityOptions: Option[];
export declare type OpacityOption = '33' | '66' | '99' | 'CC' | 'FF';
export declare const opacityOptions: Option<OpacityOption>[];
//# sourceMappingURL=opacityOptions.d.ts.map
import { Option } from '../models';
export declare const silentLetterOpacityOptions: Option[];
export declare type SilentLetterOpacityOption = '0.2' | '0.4' | '0.5' | '0.6' | '0.8';
export declare const silentLetterOpacityOptions: Option<SilentLetterOpacityOption>[];
//# sourceMappingURL=silentLetterOpacityOptions.d.ts.map
import { Option } from '../models';
export declare const thicknessOptions: Option[];
export declare type ThicknessOption = '1' | '2' | '3';
export declare const thicknessOptions: Option<ThicknessOption>[];
//# sourceMappingURL=thicknessOptions.d.ts.map
import { Option } from '../models';
export declare const wordSpacingOptions: Option[];
export declare type WordSpacingOption = 'inherit' | '2px' | '3.5px' | '5px';
export declare const wordSpacingOptions: Option<WordSpacingOption>[];
//# sourceMappingURL=wordSpacingOptions.d.ts.map
{
"name": "@readapt/settings",
"version": "1.4.4",
"version": "1.5.0",
"main": "dist/readapt-settings.js",

@@ -24,3 +24,3 @@ "module": "dist/readapt-settings.esm.js",

],
"gitHead": "3cd52559ca1c4d25c7bdef8309fbe27168656dbb"
"gitHead": "749a03ec8c071e43ed7a9c8a5ae9ada6f14cf9a3"
}
# @readapt/settings
Readapt adaptations are based on a settings profile. This package contains Settings models, type definitions and a few
utility functions to easily build Settings in order to adapt text.
## Installation
1. Install `@readapt/settings` package:
```bash
npm install @readapt/settings
```
## How to build settings?
Use `buildDefaultSettings()` to build default settings
```typescript
import { buildDefaultSettings } from '@readapt/settings'
const defaultSettings = buildDefaultSettings('en')
```
Then you can customize it using available options. For example:
```typescript
import { colors, lineSpacingOptions, opacityOptions, silentLetterOpacityOptions, overrideDefaultLetters } from '@readapt/settings'
const mySettings = {
...defaultSettingsEn,
shadeAlternateLinesActive: true,
shadeAlternateLinesOpacity: opacityOptions[1].value,
silentLetterActive: true,
silentLetterOpacity: silentLetterOpacityOptions[2].value,
lineSpacing: lineSpacingOptions[1].value,
letters: overrideDefaultLetters('en', [
{ key: '2', value: 'd', bold: false, color: colors[0], active: true },
{ key: '8', value: 'm', bold: false, color: colors[1], active: true },
{ key: '7', value: 'n', bold: false, color: colors[2], active: true },
{ key: '3', value: 'p', bold: false, color: colors[3], active: true },
{ key: '1', value: 'b', bold: false, color: colors[4], active: true },
{ key: '24', value: 'w', bold: false, color: colors[7], active: true },
{ key: '19', value: 'u', bold: false, color: colors[8], active: true },
{ key: '4', value: 'q', bold: false, color: colors[11], active: true }
])
}
```
Each Option is typed to easily know available values. Explore our source code to check all available options.
`overrideDefaultLetters()` and `overrideDefaultPhonemes()` are two methods to easily customize letters and phonemes.
`getLangConfig()` returns available phonemes and letters for each language.
import { ColoredItem, ColoredOption, Language, Settings } from './models'
import { fontFamilyOptions, fontSizeOptions, letterSpacingOptions, lineSpacingOptions, opacityOptions, wordSpacingOptions } from './options'
import {
fontFamilyOptions,
fontSizeOptions,
letterSpacingOptions,
lineSpacingOptions,
opacityOptions,
silentLetterOpacityOptions,
wordSpacingOptions
} from './options'
import { getLangConfig } from './langConfig'

@@ -15,3 +23,3 @@

const buildDefaultColoredItems = (options: ColoredOption[]) =>
const buildDefaultColoredItems = (options: ColoredOption[]): ColoredItem[] =>
options.map(({ key, value }) => ({

@@ -37,3 +45,3 @@ key,

silentLetterActive: false,
silentLetterOpacity: opacityOptions[0].value,
silentLetterOpacity: silentLetterOpacityOptions[0].value,
shadeAlternateLinesActive: false,

@@ -49,2 +57,22 @@ shadeAlternateLinesOpacity: opacityOptions[0].value,

export { buildDefaultSettings }
const overrideDefaultColoredItems = (defaultColoredItems: ColoredItem[], overrides: ColoredItem[]): ColoredItem[] =>
defaultColoredItems.map((item) => {
const overridden = overrides.find(({ value }) => item.value === value)
return overridden ? overridden : item
})
const overrideDefaultLetters = (lang: Language, overrides: ColoredItem[]): ColoredItem[] => {
const letterOptions = getLangConfig(lang).letterOptions
const lettersSettings = buildDefaultColoredItems(letterOptions)
return overrideDefaultColoredItems(lettersSettings, overrides)
}
const overrideDefaultPhonemes = (lang: Language, overrides: ColoredItem[]): ColoredItem[] => {
const phonemesOptions = getLangConfig(lang).phonemeOptions
const phonemesSettings = buildDefaultColoredItems(phonemesOptions)
return overrideDefaultColoredItems(phonemesSettings, overrides)
}
export { buildDefaultSettings, overrideDefaultLetters, overrideDefaultPhonemes }
/**
* Represents a Phoneme or Letter to be colored
*/
import { ColorOption } from '../options/colors'
export interface ColoredItem {
key: string
value: string
color?: string
color?: ColorOption
bold: boolean
active: boolean
}

@@ -1,4 +0,4 @@

export interface Option {
value: string
export interface Option<T extends string> {
value: T
text: string
}
import { Language } from './language'
import { ColoredItem } from './coloredItem'
import {
ColorOption,
FontFamilyOption,
FontSizeOption,
LetterSpacingOption,
LineSpacingOption,
OpacityOption,
SilentLetterOpacityOption,
WordSpacingOption
} from '../options'
export interface Settings {
language: Language
fontFamily: string
fontSize: string
letterSpacing: string
wordSpacing: string
lineSpacing: string
syllableColor1?: string
syllableColor2?: string
fontFamily: FontFamilyOption
fontSize: FontSizeOption
letterSpacing: LetterSpacingOption
wordSpacing: WordSpacingOption
lineSpacing: LineSpacingOption
syllableColor1?: ColorOption
syllableColor2?: ColorOption
syllableActive: boolean
syllableOpacity: string
silentLetterOpacity: string
syllableOpacity: OpacityOption
silentLetterOpacity: SilentLetterOpacityOption
silentLetterActive: boolean
shadeAlternateLinesOpacity: string
shadeAlternateLinesOpacity: OpacityOption
shadeAlternateLinesActive: boolean
liaisonsOpacity?: string
liaisonsOpacity?: OpacityOption
liaisonsActive?: boolean

@@ -21,0 +31,0 @@ phonemesActive: boolean

@@ -1,2 +0,2 @@

export const colors: string[] = [
export const colors = [
'#5fa2ce',

@@ -14,2 +14,4 @@ '#76b7b2',

'#ffbc79'
]
] as const
export type ColorOption = typeof colors[number]
import { Option } from '../models'
export const fontFamilyOptions: Option[] = [
export type FontFamilyOption = 'inherit' | 'Arial' | 'OpenDyslexic' | 'Luciole'
export const fontFamilyOptions: Option<FontFamilyOption>[] = [
{ value: 'inherit', text: 'Default' },

@@ -5,0 +7,0 @@ { value: 'Arial', text: 'Arial' },

import { Option } from '../models'
export const fontSizeOptions: Option[] = [
export type FontSizeOption = 'inherit' | '140%' | '170%' | '200%'
export const fontSizeOptions: Option<FontSizeOption>[] = [
{ value: 'inherit', text: 'DEFAULT' },

@@ -5,0 +7,0 @@ { value: '140%', text: 'MEDIUM' },

@@ -1,10 +0,10 @@

export { fontFamilyOptions } from './fontFamilyOptions'
export { fontSizeOptions } from './fontSizeOptions'
export { languageOptions } from './languageOptions'
export { letterSpacingOptions } from './letterSpacingOptions'
export { lineSpacingOptions } from './lineSpacingOptions'
export { opacityOptions } from './opacityOptions'
export { thicknessOptions } from './thicknessOptions'
export { silentLetterOpacityOptions } from './silentLetterOpacityOptions'
export { wordSpacingOptions } from './wordSpacingOptions'
export { colors } from './colors'
export * from './fontFamilyOptions'
export * from './fontSizeOptions'
export * from './languageOptions'
export * from './letterSpacingOptions'
export * from './lineSpacingOptions'
export * from './opacityOptions'
export * from './thicknessOptions'
export * from './silentLetterOpacityOptions'
export * from './wordSpacingOptions'
export * from './colors'

@@ -1,6 +0,6 @@

import { Option } from '../models'
import { Language, Option } from '../models'
export const languageOptions: Option[] = [
export const languageOptions: Option<Language>[] = [
{ value: 'en', text: 'English' },
{ value: 'fr', text: 'French' }
]
import { Option } from '../models'
export const letterSpacingOptions: Option[] = [
export type LetterSpacingOption = 'inherit' | '2px' | '3.5px' | '5px'
export const letterSpacingOptions: Option<LetterSpacingOption>[] = [
{ value: 'inherit', text: 'DEFAULT' },

@@ -5,0 +7,0 @@ { value: '2px', text: 'MEDIUM' },

import { Option } from '../models'
export const lineSpacingOptions: Option[] = [
export type LineSpacingOption = 'inherit' | '2.1' | '2.55' | '3'
export const lineSpacingOptions: Option<LineSpacingOption>[] = [
{ value: 'inherit', text: 'DEFAULT' },

@@ -5,0 +7,0 @@ { value: '2.1', text: 'MEDIUM' },

import { Option } from '../models'
export const opacityOptions: Option[] = [
export type OpacityOption = '33' | '66' | '99' | 'CC' | 'FF'
export const opacityOptions: Option<OpacityOption>[] = [
{ value: '33', text: '1' },

@@ -5,0 +7,0 @@ { value: '66', text: '2' },

import { Option } from '../models'
export const silentLetterOpacityOptions: Option[] = [
export type SilentLetterOpacityOption = '0.2' | '0.4' | '0.5' | '0.6' | '0.8'
export const silentLetterOpacityOptions: Option<SilentLetterOpacityOption>[] = [
{ value: '0.2', text: '1' },

@@ -5,0 +7,0 @@ { value: '0.4', text: '2' },

import { Option } from '../models'
export const thicknessOptions: Option[] = [
export type ThicknessOption = '1' | '2' | '3'
export const thicknessOptions: Option<ThicknessOption>[] = [
{ value: '1', text: '1' },

@@ -5,0 +7,0 @@ { value: '2', text: '2' },

import { Option } from '../models'
export const wordSpacingOptions: Option[] = [
export type WordSpacingOption = 'inherit' | '2px' | '3.5px' | '5px'
export const wordSpacingOptions: Option<WordSpacingOption>[] = [
{ value: 'inherit', text: 'DEFAULT' },

@@ -5,0 +7,0 @@ { value: '2px', text: 'MEDIUM' },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc