@valbuild/shared 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -0
- package/dist/declarations/src/index.d.ts +10 -0
- package/dist/declarations/src/internal/index.d.ts +2 -0
- package/dist/declarations/src/internal/mimeType/imageMimeType.d.ts +2 -0
- package/dist/declarations/src/internal/mimeType/index.d.ts +1 -0
- package/dist/declarations/src/internal/richtext/conversion/index.d.ts +3 -0
- package/dist/declarations/src/internal/richtext/conversion/lexicalToRichTextSource.d.ts +12 -0
- package/dist/declarations/src/internal/richtext/conversion/parseRichTextSource.d.ts +2 -0
- package/dist/declarations/src/internal/richtext/conversion/richTextSourceToLexical.d.ts +67 -0
- package/dist/valbuild-shared.cjs.d.ts +3 -0
- package/dist/valbuild-shared.cjs.d.ts.map +1 -0
- package/dist/valbuild-shared.cjs.dev.js +15 -0
- package/dist/valbuild-shared.cjs.js +7 -0
- package/dist/valbuild-shared.cjs.prod.js +15 -0
- package/dist/valbuild-shared.esm.js +11 -0
- package/internal/dist/valbuild-shared-internal.cjs.d.ts +2 -0
- package/internal/dist/valbuild-shared-internal.cjs.d.ts.map +1 -0
- package/internal/dist/valbuild-shared-internal.cjs.dev.js +1198 -0
- package/internal/dist/valbuild-shared-internal.cjs.js +7 -0
- package/internal/dist/valbuild-shared-internal.cjs.prod.js +1198 -0
- package/internal/dist/valbuild-shared-internal.esm.js +1166 -0
- package/internal/package.json +4 -0
- package/package.json +41 -0
package/README.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# Shared types and utils
|
2
|
+
|
3
|
+
This package contains internal Val types and utils that are shared between other packages.
|
4
|
+
|
5
|
+
Since Val has many runtimes (node, browser, QuickJS) and is bundled in different ways and executed different modes (client, SSR, RSC), we need to be careful about how code is bundled. This package gives us an extra place to put code that is shared between all platforms, but that can be run in all runtimes and bundlers.
|
6
|
+
|
7
|
+
## What is goes into this package?
|
8
|
+
|
9
|
+
Generally speaking, code that are shared between other packages belongs in this package. Specifically:
|
10
|
+
|
11
|
+
- Types and utility functions that does **NOT** belong in core because they:
|
12
|
+
1. is not required to execute Val files; or
|
13
|
+
1. have dependency on a lib
|
14
|
+
- Types and utility functions that does **NOT** semantically belong in any other package. Examples:
|
15
|
+
1. parser tools
|
16
|
+
1. API layer
|
17
|
+
|
18
|
+
See the rules to what does NOT belong in this package below.
|
19
|
+
|
20
|
+
## What **DOES NOT** go into this package?
|
21
|
+
|
22
|
+
- Any function / type that depends on a UI framework, even transitively (React, Lexical, NextJS, Vite...).
|
23
|
+
- Any function that cannot execute both on server-side and client-side.
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./imageMimeType.js";
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { RichTextSource, AnyRichTextOptions } from "@valbuild/core";
|
2
|
+
import { LexicalRootNode } from "./richTextSourceToLexical.js";
|
3
|
+
export declare function lexicalToRichTextSource(node: LexicalRootNode): Promise<RichTextSource<AnyRichTextOptions> & {
|
4
|
+
files: Record<string, string>;
|
5
|
+
}>;
|
6
|
+
declare const FORMAT_MAPPING: {
|
7
|
+
bold: number;
|
8
|
+
italic: number;
|
9
|
+
"line-through": number;
|
10
|
+
};
|
11
|
+
export declare function fromLexicalFormat(format: number): (keyof typeof FORMAT_MAPPING)[];
|
12
|
+
export {};
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import { AnyRichTextOptions, RichTextNode as ValRichTextNode, RichText } from "@valbuild/core";
|
2
|
+
export type LexicalTextNode = CommonLexicalProps & {
|
3
|
+
type: "text";
|
4
|
+
text: string;
|
5
|
+
format: "" | number;
|
6
|
+
};
|
7
|
+
type InlineNode = LexicalTextNode | LexicalLinkNode;
|
8
|
+
export type LexicalParagraphNode = CommonLexicalProps & {
|
9
|
+
type: "paragraph";
|
10
|
+
children: (InlineNode | LexicalLineBreakNode)[];
|
11
|
+
};
|
12
|
+
export type LexicalHeadingNode = CommonLexicalProps & {
|
13
|
+
type: "heading";
|
14
|
+
tag: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
|
15
|
+
children: InlineNode[];
|
16
|
+
};
|
17
|
+
export type LexicalListItemNode = CommonLexicalProps & {
|
18
|
+
type: "listitem";
|
19
|
+
children: (InlineNode | LexicalListNode | LexicalLineBreakNode)[];
|
20
|
+
};
|
21
|
+
export type LexicalListNode = CommonLexicalProps & {
|
22
|
+
type: "list";
|
23
|
+
listType: "bullet" | "number" | "checked";
|
24
|
+
direction: "ltr" | "rtl" | null;
|
25
|
+
children: LexicalListItemNode[];
|
26
|
+
};
|
27
|
+
export type LexicalImagePayload = {
|
28
|
+
src: string;
|
29
|
+
altText?: string;
|
30
|
+
height?: number;
|
31
|
+
width?: number;
|
32
|
+
};
|
33
|
+
export type LexicalImageNode = CommonLexicalProps & {
|
34
|
+
type: "image";
|
35
|
+
} & LexicalImagePayload;
|
36
|
+
export type LexicalLinkNode = CommonLexicalProps & {
|
37
|
+
type: "link";
|
38
|
+
url: string;
|
39
|
+
children: LexicalTextNode[];
|
40
|
+
};
|
41
|
+
export type LexicalLineBreakNode = CommonLexicalProps & {
|
42
|
+
type: "linebreak";
|
43
|
+
};
|
44
|
+
export type LexicalNode = LexicalTextNode | LexicalParagraphNode | LexicalHeadingNode | LexicalListItemNode | LexicalListNode | LexicalImageNode | LexicalLineBreakNode | LexicalLinkNode;
|
45
|
+
export type LexicalRootNode = {
|
46
|
+
type: "root";
|
47
|
+
children: (LexicalHeadingNode | LexicalParagraphNode | LexicalListNode)[];
|
48
|
+
version: 1;
|
49
|
+
format: "left" | "start" | "center" | "right" | "end" | "justify" | "";
|
50
|
+
direction: null | "ltr" | "rtl";
|
51
|
+
} & CommonLexicalProps;
|
52
|
+
export declare const COMMON_LEXICAL_PROPS: {
|
53
|
+
readonly version: 1;
|
54
|
+
readonly format: number | "";
|
55
|
+
readonly indent: 0;
|
56
|
+
readonly direction: "ltr" | "rtl" | null;
|
57
|
+
};
|
58
|
+
type CommonLexicalProps = typeof COMMON_LEXICAL_PROPS;
|
59
|
+
export declare function toLexicalNode(node: ValRichTextNode<AnyRichTextOptions>, useBreakNode?: boolean): LexicalNode;
|
60
|
+
export declare function richTextSourceToLexical(richtext: RichText<AnyRichTextOptions>): LexicalRootNode;
|
61
|
+
declare const FORMAT_MAPPING: {
|
62
|
+
bold: number;
|
63
|
+
italic: number;
|
64
|
+
"line-through": number;
|
65
|
+
};
|
66
|
+
export declare function toLexicalFormat(classes: (keyof typeof FORMAT_MAPPING)[]): number;
|
67
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"valbuild-shared.cjs.d.ts","sourceRoot":"","sources":["./declarations/src/index.d.ts"],"names":[],"mappings":"AAAA"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Val React **shared** types and utils.
|
7
|
+
*
|
8
|
+
* @remarks
|
9
|
+
* This package includes only internal entry points and should only be used by internal packages.
|
10
|
+
*
|
11
|
+
* @packageDocumentation
|
12
|
+
*/
|
13
|
+
var index = {};
|
14
|
+
|
15
|
+
exports["default"] = index;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Val React **shared** types and utils.
|
7
|
+
*
|
8
|
+
* @remarks
|
9
|
+
* This package includes only internal entry points and should only be used by internal packages.
|
10
|
+
*
|
11
|
+
* @packageDocumentation
|
12
|
+
*/
|
13
|
+
var index = {};
|
14
|
+
|
15
|
+
exports["default"] = index;
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"valbuild-shared-internal.cjs.d.ts","sourceRoot":"","sources":["../../dist/declarations/src/internal/index.d.ts"],"names":[],"mappings":"AAAA"}
|