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

@prismicio/richtext

Package Overview
Dependencies
Maintainers
18
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prismicio/richtext - npm Package Compare versions

Comparing version 2.0.0-alpha.1 to 2.0.0-alpha.2

7

CHANGELOG.md

@@ -5,2 +5,9 @@ # Changelog

## [2.0.0-alpha.2](https://github.com/prismicio/prismic-richtext/compare/v2.0.0-alpha.1...v2.0.0-alpha.2) (2021-06-25)
### Features
* allow to specify serializer function children type for composeSerializer function ([b8de3a2](https://github.com/prismicio/prismic-richtext/commit/b8de3a240b6f6c932d07855bf1b184f8a51ae181))
## [2.0.0-alpha.1](https://github.com/prismicio/prismic-richtext/compare/v2.0.0-alpha.0...v2.0.0-alpha.1) (2021-06-25)

@@ -7,0 +14,0 @@

9

dist/index.d.ts

@@ -9,6 +9,7 @@ import * as _prismicio_types from '@prismicio/types';

* @typeParam ReturnType - Return type of the function serializer
* @typeParam ChildrenType - Type of children, defaults to provided ReturnType
*
* @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}
*/
declare type RichTextFunctionSerializer<ReturnType> = (type: RichTextNodeType, node: RTAnyNode, text: string | undefined, children: ReturnType[], key: string) => ReturnType;
declare type RichTextFunctionSerializer<ReturnType, ChildrenType = ReturnType> = (type: RichTextNodeType, node: RTAnyNode, text: string | undefined, children: ChildrenType[], key: string) => ReturnType;
/**

@@ -114,3 +115,3 @@ * Map serializer's tag function serializer, can be helpful for typing those handlers

*/
declare const serialize: <SerializerReturnType>(richTextField: RichTextField, serializer: RichTextFunctionSerializer<SerializerReturnType>) => SerializerReturnType[];
declare const serialize: <SerializerReturnType>(richTextField: RichTextField, serializer: RichTextFunctionSerializer<SerializerReturnType, SerializerReturnType>) => SerializerReturnType[];

@@ -131,3 +132,3 @@ /**

*/
declare const wrapMapSerializer: <SerializerReturnType>(mapSerializer: RichTextMapSerializer<SerializerReturnType>) => RichTextFunctionSerializer<SerializerReturnType | null>;
declare const wrapMapSerializer: <SerializerReturnType>(mapSerializer: RichTextMapSerializer<SerializerReturnType>) => RichTextFunctionSerializer<SerializerReturnType | null, SerializerReturnType | null>;

@@ -151,3 +152,3 @@ /**

*/
declare const composeSerializers: <SerializerReturnType>(serializers_0: RichTextFunctionSerializer<SerializerReturnType> | RichTextFunctionSerializer<SerializerReturnType | null>, ...serializers_1: (RichTextFunctionSerializer<SerializerReturnType> | RichTextFunctionSerializer<SerializerReturnType | null>)[]) => (type: _prismicio_types.RichTextNodeType, node: _prismicio_types.RTAnyNode, text: string | undefined, children: SerializerReturnType[], key: string) => SerializerReturnType;
declare const composeSerializers: <SerializerReturnType>(serializers_0: RichTextFunctionSerializer<SerializerReturnType, SerializerReturnType> | RichTextFunctionSerializer<SerializerReturnType | null, SerializerReturnType>, ...serializers_1: (RichTextFunctionSerializer<SerializerReturnType, SerializerReturnType> | RichTextFunctionSerializer<SerializerReturnType | null, SerializerReturnType>)[]) => (type: _prismicio_types.RichTextNodeType, node: _prismicio_types.RTAnyNode, text: string | undefined, children: SerializerReturnType[], key: string) => NonNullable<SerializerReturnType>;

@@ -154,0 +155,0 @@ /**

{
"name": "@prismicio/richtext",
"version": "2.0.0-alpha.1",
"version": "2.0.0-alpha.2",
"description": "A parser and serializer for Prismic's Rich Text format",

@@ -5,0 +5,0 @@ "keywords": [

@@ -25,7 +25,13 @@ import { RichTextError } from "./RichTextError";

| RichTextFunctionSerializer<SerializerReturnType>
| RichTextFunctionSerializer<SerializerReturnType | null>
| RichTextFunctionSerializer<
SerializerReturnType | null,
SerializerReturnType
>
),
...(
| RichTextFunctionSerializer<SerializerReturnType>
| RichTextFunctionSerializer<SerializerReturnType | null>
| RichTextFunctionSerializer<
SerializerReturnType | null,
SerializerReturnType
>
)[]

@@ -36,8 +42,9 @@ ]

...args: Parameters<RichTextFunctionSerializer<SerializerReturnType>>
): SerializerReturnType => {
): NonNullable<SerializerReturnType> => {
for (let i = 0; i < serializers.length; i++) {
const res = serializers[i](...args);
if (res !== null) {
return res;
if (res != null) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return res!;
}

@@ -44,0 +51,0 @@ }

@@ -31,10 +31,14 @@ import {

* @typeParam ReturnType - Return type of the function serializer
* @typeParam ChildrenType - Type of children, defaults to provided ReturnType
*
* @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}
*/
export type RichTextFunctionSerializer<ReturnType> = (
export type RichTextFunctionSerializer<
ReturnType,
ChildrenType = ReturnType,
> = (
type: RichTextNodeType,
node: RTAnyNode,
text: string | undefined,
children: ReturnType[],
children: ChildrenType[],
key: string,

@@ -41,0 +45,0 @@ ) => ReturnType;

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