@coorax/schema 0.0.0-canary.1
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/dist/base/classes/component.class.d.ts +23 -0
- package/dist/base/classes/container.class.d.ts +17 -0
- package/dist/base/classes/field.class.d.ts +15 -0
- package/dist/base/classes/tnode.class.d.ts +14 -0
- package/dist/base/index.d.ts +19 -0
- package/dist/base/types/components/components.d.ts +13 -0
- package/dist/base/types/container/container.d.ts +27 -0
- package/dist/base/types/container/division.types.d.ts +3 -0
- package/dist/base/types/container/section.types.d.ts +3 -0
- package/dist/base/types/container/ul-list.types.d.ts +3 -0
- package/dist/base/types/css.types.d.ts +23 -0
- package/dist/base/types/field/divider.types.d.ts +3 -0
- package/dist/base/types/field/field.blockquote.types.d.ts +4 -0
- package/dist/base/types/field/field.caption.types.d.ts +6 -0
- package/dist/base/types/field/field.code.types.d.ts +5 -0
- package/dist/base/types/field/field.d.ts +62 -0
- package/dist/base/types/field/field.document.types.d.ts +3 -0
- package/dist/base/types/field/field.image.types.d.ts +3 -0
- package/dist/base/types/field/field.link.types.d.ts +5 -0
- package/dist/base/types/field/field.media.types.d.ts +5 -0
- package/dist/base/types/field/field.text.types.d.ts +8 -0
- package/dist/base/types/field/field.video.types.d.ts +8 -0
- package/dist/base/types/field/fields.iframe.types.d.ts +7 -0
- package/dist/base/types/field/heading.types.d.ts +3 -0
- package/dist/base/types/field/paragraph.types.d.ts +3 -0
- package/dist/base/types/global.types.d.ts +26 -0
- package/dist/base/types/node/link.types.d.ts +3 -0
- package/dist/base/types/node/node.d.ts +24 -0
- package/dist/base/types/node/span.types.d.ts +3 -0
- package/dist/base/types/tree/tree.d.ts +24 -0
- package/dist/constants/field.constants.d.ts +1 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +1230 -0
- package/dist/services/code/code-themes.d.ts +5 -0
- package/dist/services/code/code-tokens.d.ts +5 -0
- package/dist/services/code/index.d.ts +3 -0
- package/dist/services/code/tokenizer.d.ts +7 -0
- package/dist/services/text-marks/index.d.ts +2 -0
- package/dist/services/text-marks/marks.types.d.ts +35 -0
- package/dist/services/text-marks/text.utils.d.ts +6 -0
- package/dist/services/ui/default-styles.d.ts +3 -0
- package/dist/services/ui/pseudo-styles.d.ts +22 -0
- package/dist/services/ui/style.types.d.ts +9 -0
- package/dist/utils/components.utils.d.ts +10 -0
- package/dist/utils/container.utils.d.ts +13 -0
- package/dist/utils/fields.utils.d.ts +33 -0
- package/dist/utils/global.utils.d.ts +47 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/tnode.utils.d.ts +9 -0
- package/dist/utils/tree.utils.d.ts +11 -0
- package/package.json +46 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CodeTokenType } from "./code-tokens";
|
|
2
|
+
export type CodeThemeName = "dark" | "light";
|
|
3
|
+
export type CodeTheme = Record<CodeTokenType, string>;
|
|
4
|
+
export declare const CODE_THEMES: Record<CodeThemeName, CodeTheme>;
|
|
5
|
+
export declare const CODE_THEME_NAMES: CodeThemeName[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CodeToken } from "./code-tokens";
|
|
2
|
+
/**
|
|
3
|
+
* Tokenizer générique (JS/TS/JSON). Garantie : la concaténation des `value`
|
|
4
|
+
* reconstruit exactement l'entrée (aucun caractère consommé deux fois ni perdu),
|
|
5
|
+
* ce qui préserve le mapping d'offsets du caret.
|
|
6
|
+
*/
|
|
7
|
+
export declare function tokenizeCode(input: string): CodeToken[];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { TextField } from "../../base";
|
|
2
|
+
import type { NodeCommonProps, PathToProp } from "../../base/types/global.types";
|
|
3
|
+
export interface MarkMap {
|
|
4
|
+
bold: {};
|
|
5
|
+
italic: {};
|
|
6
|
+
underline: {};
|
|
7
|
+
link: {
|
|
8
|
+
href: string;
|
|
9
|
+
};
|
|
10
|
+
code: {};
|
|
11
|
+
initial: {
|
|
12
|
+
style: NodeCommonProps["style"];
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export type MarkType = keyof MarkMap;
|
|
16
|
+
export type MarkAttrs<T extends MarkType = MarkType> = MarkMap[T];
|
|
17
|
+
export interface Mark<T extends MarkType = MarkType> {
|
|
18
|
+
type: T;
|
|
19
|
+
start: number;
|
|
20
|
+
end: number;
|
|
21
|
+
attrs?: MarkAttrs<T>;
|
|
22
|
+
}
|
|
23
|
+
export interface MarkSpec<T extends MarkType = MarkType> {
|
|
24
|
+
type: T;
|
|
25
|
+
attrs?: MarkAttrs<T>;
|
|
26
|
+
}
|
|
27
|
+
export interface MarkBehavior {
|
|
28
|
+
/** Un caractère tapé juste après la fin du mark l'étend-il ? */
|
|
29
|
+
inclusive: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface TextContent {
|
|
32
|
+
text: string;
|
|
33
|
+
marks: readonly Mark[];
|
|
34
|
+
}
|
|
35
|
+
export type FieldTextContentPath = PathToProp<TextField, TextContent>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CoraxCSSPseudos } from "../../base/types/css.types";
|
|
2
|
+
/** Hash FNV-1a (stable, sans dépendance) → base36. */
|
|
3
|
+
declare function hash(input: string): string;
|
|
4
|
+
type StyleSink = () => void;
|
|
5
|
+
/**
|
|
6
|
+
* Transforme un `pseudoStyle` en nom de classe déterministe (`corax-p-<hash>`)
|
|
7
|
+
* et enregistre la règle CSS associée dans le collector.
|
|
8
|
+
*
|
|
9
|
+
* Pur et sans DOM : utilisable en SSR. En client, l'injection dans le `<head>`
|
|
10
|
+
* est assurée par le driver via `setCoraxStyleSink`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function collectCoraxPseudoStyle(style?: CoraxCSSPseudos): string | undefined;
|
|
13
|
+
/** Renvoie tout le CSS généré (à injecter dans le `<head>` côté SSR). */
|
|
14
|
+
export declare function getCollectedStyles(): string;
|
|
15
|
+
/** Vide le collector (à appeler entre deux requêtes SSR). */
|
|
16
|
+
export declare function clearCollectedStyles(): void;
|
|
17
|
+
/**
|
|
18
|
+
* Branche un callback appelé dès qu'une nouvelle règle est générée (driver DOM).
|
|
19
|
+
* Flush immédiat l'état courant, puis renvoie un disposer.
|
|
20
|
+
*/
|
|
21
|
+
export declare function setCoraxStyleSink(fn: StyleSink): () => void;
|
|
22
|
+
export { hash as coraxStyleHash };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Block } from "../../base/types/tree/tree";
|
|
2
|
+
import type { NodeCommonProps } from "../../base/types/global.types";
|
|
3
|
+
type BlockStyles = {
|
|
4
|
+
[K in Block["type"]]: NodeCommonProps;
|
|
5
|
+
};
|
|
6
|
+
export interface StylesMap extends BlockStyles {
|
|
7
|
+
}
|
|
8
|
+
export type StyleName = keyof StylesMap;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Component } from "../base/types/components/components";
|
|
2
|
+
import type { Container, ContainerType } from "../base/types/container/container";
|
|
3
|
+
import type { OmitComponentsMethods } from "../base/types/global.types";
|
|
4
|
+
declare function NewComponent<T extends ContainerType = ContainerType>(container: Omit<Container<T>, "id" | "variant">, defaultValue?: Partial<Pick<Component, "count" | "createdAt" | "updatedAt">>): Component<T>;
|
|
5
|
+
declare function DeserializeComponent(component: OmitComponentsMethods<Component>): Component;
|
|
6
|
+
export declare const ComponentsUtils: {
|
|
7
|
+
NewComponent: typeof NewComponent;
|
|
8
|
+
DeserializeComponent: typeof DeserializeComponent;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Container, ContainerType } from "../base/types/container/container";
|
|
2
|
+
import type { OmitContainersMethods } from "../base/types/global.types";
|
|
3
|
+
declare function NewUlListContainer(defaultValue?: Partial<OmitContainersMethods<Container<"list">>>): Container<"list">;
|
|
4
|
+
declare function NewSectionContainer(defaultValue?: Partial<OmitContainersMethods<Container<"section">>>): Container<"section">;
|
|
5
|
+
declare function NewContainer<T extends ContainerType = ContainerType>(type: T, defaultValue?: Partial<OmitContainersMethods<Container<T>>>): Container;
|
|
6
|
+
declare function DeserializeContainer(container: OmitContainersMethods<Container>): Container;
|
|
7
|
+
export declare const ContainersUtils: {
|
|
8
|
+
NewContainer: typeof NewContainer;
|
|
9
|
+
DeserializeContainer: typeof DeserializeContainer;
|
|
10
|
+
NewUlListContainer: typeof NewUlListContainer;
|
|
11
|
+
NewSectionContainer: typeof NewSectionContainer;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Block } from "../base";
|
|
2
|
+
import type { Field, FieldTag, FieldType } from "../base/types/field/field";
|
|
3
|
+
import type { OmitFieldsMethods } from "../base/types/global.types";
|
|
4
|
+
export declare function isEditableField<T extends Field = Field>(block: Block): block is T;
|
|
5
|
+
export declare function isEditableType<T extends FieldType = FieldType>(type: T): boolean;
|
|
6
|
+
export declare function isMediaField<T extends Field = Field>(block: Block): block is T;
|
|
7
|
+
export declare function isMediaType<T extends FieldType = FieldType>(type: T): boolean;
|
|
8
|
+
export declare function getIframeSrc(value: string): string | null;
|
|
9
|
+
declare function NewTextField(defaultValue?: Partial<OmitFieldsMethods<Field<"text", FieldTag>>>): Field<"text">;
|
|
10
|
+
declare function NewHeadingField(defaultValue?: Partial<OmitFieldsMethods<Field<"heading", FieldTag>>>): Field<"heading">;
|
|
11
|
+
declare function NewImageField(defaultValue?: Partial<OmitFieldsMethods<Field<"image", FieldTag>>>): Field<"image">;
|
|
12
|
+
declare function NewIFrameField(defaultValue?: Partial<OmitFieldsMethods<Field<"iframe", FieldTag>>>): Field<"iframe">;
|
|
13
|
+
declare function NewLinkField(defaultValue?: Partial<OmitFieldsMethods<Field<"link", FieldTag>>>): Field<"link">;
|
|
14
|
+
declare function NewBlockquoteField(defaultValue?: Partial<OmitFieldsMethods<Field<"blockquote", FieldTag>>>): Field<"blockquote">;
|
|
15
|
+
declare function NewDividerField(defaultValue?: Partial<OmitFieldsMethods<Field<"divider", FieldTag>>>): Field<"divider">;
|
|
16
|
+
declare function NewCodeField(defaultValue?: Partial<OmitFieldsMethods<Field<"code", FieldTag>>>): Field<"code">;
|
|
17
|
+
declare function NewCaptionField(defaultValue?: Partial<OmitFieldsMethods<Field<"caption", FieldTag>>>): Field<"caption">;
|
|
18
|
+
declare function NewField<T extends FieldType = FieldType, A extends FieldTag = FieldTag>(type: T, defaultValue?: Partial<OmitFieldsMethods<Field<T, A>>>): Field;
|
|
19
|
+
declare function DeserializeField(field: OmitFieldsMethods<Field>): Field;
|
|
20
|
+
export declare const FieldsUtils: {
|
|
21
|
+
NewField: typeof NewField;
|
|
22
|
+
DeserializeField: typeof DeserializeField;
|
|
23
|
+
NewTextField: typeof NewTextField;
|
|
24
|
+
NewHeadingField: typeof NewHeadingField;
|
|
25
|
+
NewLinkField: typeof NewLinkField;
|
|
26
|
+
NewImageField: typeof NewImageField;
|
|
27
|
+
NewDividerField: typeof NewDividerField;
|
|
28
|
+
NewIFrameField: typeof NewIFrameField;
|
|
29
|
+
NewBlockquoteField: typeof NewBlockquoteField;
|
|
30
|
+
NewCodeField: typeof NewCodeField;
|
|
31
|
+
NewCaptionField: typeof NewCaptionField;
|
|
32
|
+
};
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
declare function generateRandomId(): string;
|
|
2
|
+
export type CustomID<T extends string> = `${T}:${string}-${string}-${string}-${string}-${string}`;
|
|
3
|
+
declare function generateId<T extends string>(prefix: T): CustomID<T>;
|
|
4
|
+
declare function generateFieldId(): `field:${string}-${string}-${string}-${string}-${string}`;
|
|
5
|
+
declare function generateTNodeId(): `tnode:${string}-${string}-${string}-${string}-${string}`;
|
|
6
|
+
declare function generateContainerId(): `container:${string}-${string}-${string}-${string}-${string}`;
|
|
7
|
+
declare function generateComponentId(): `component:${string}-${string}-${string}-${string}-${string}`;
|
|
8
|
+
declare function generateTreeId(): `tree:${string}-${string}-${string}-${string}-${string}`;
|
|
9
|
+
declare function generateSubscriberId(): `subscriber:${string}-${string}-${string}-${string}-${string}`;
|
|
10
|
+
declare function Capitalize(value: string): string;
|
|
11
|
+
type EntriesKeyValuePair<T extends object, K extends keyof T = keyof T> = [K, T[K]][];
|
|
12
|
+
/**
|
|
13
|
+
* Because the native `Object.entries` dont infer correctly
|
|
14
|
+
* the return type, the `keys` are always string.
|
|
15
|
+
* So now if you pass a `Record<Key, Value>`, the Key type
|
|
16
|
+
* will be inferred correctly
|
|
17
|
+
*
|
|
18
|
+
* @param obj `object`
|
|
19
|
+
* @returns `EntriesKeyValuePair<T>`
|
|
20
|
+
*/
|
|
21
|
+
declare function ObjectEntries<T extends object>(obj: T): EntriesKeyValuePair<T>;
|
|
22
|
+
export declare class CustomObject<T extends object> {
|
|
23
|
+
obj: T;
|
|
24
|
+
constructor(obj: T);
|
|
25
|
+
filter(predicate: (value: T[keyof T], key: keyof T) => boolean): CustomObject<Partial<T>>;
|
|
26
|
+
pick<K extends keyof T>(...keys: K[]): CustomObject<Pick<T, K>>;
|
|
27
|
+
get size(): number;
|
|
28
|
+
has<K extends keyof T>(key: K): boolean;
|
|
29
|
+
get keys(): (keyof T)[];
|
|
30
|
+
get<K extends keyof T>(key: K): T[K];
|
|
31
|
+
baseObject(): T;
|
|
32
|
+
}
|
|
33
|
+
export declare function areObjectsTheSame(objA: object, objB: object): boolean;
|
|
34
|
+
export declare const UTILS: {
|
|
35
|
+
generateRandomId: typeof generateRandomId;
|
|
36
|
+
generateId: typeof generateId;
|
|
37
|
+
generateContainerId: typeof generateContainerId;
|
|
38
|
+
generateFieldId: typeof generateFieldId;
|
|
39
|
+
generateTreeId: typeof generateTreeId;
|
|
40
|
+
generateSubscriberId: typeof generateSubscriberId;
|
|
41
|
+
generateComponentId: typeof generateComponentId;
|
|
42
|
+
Capitalize: typeof Capitalize;
|
|
43
|
+
generateTNodeId: typeof generateTNodeId;
|
|
44
|
+
ObjectEntries: typeof ObjectEntries;
|
|
45
|
+
isPlainObject: (v: unknown) => v is Record<string, unknown>;
|
|
46
|
+
};
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { OmitTNodesMethods } from "../base/types/global.types";
|
|
2
|
+
import type { TNode, TNodeType } from "../base/types/node/node";
|
|
3
|
+
declare function NewTNode<T extends TNodeType = TNodeType>(type: T, defaultValue?: Partial<OmitTNodesMethods<TNode<T>>>): TNode;
|
|
4
|
+
declare function DeserializeTNode(tnode: OmitTNodesMethods<TNode>): TNode;
|
|
5
|
+
export declare const TNodesUtils: {
|
|
6
|
+
NewTNode: typeof NewTNode;
|
|
7
|
+
DeserializeTNode: typeof DeserializeTNode;
|
|
8
|
+
};
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BlockId, CoraxTree, JSONTree } from "../base/types/tree/tree";
|
|
2
|
+
export declare function SerializeTree(tree: CoraxTree): JSONTree;
|
|
3
|
+
export declare function DeserializeTree(tree: JSONTree): CoraxTree;
|
|
4
|
+
export declare function GetDefaultTree(): CoraxTree;
|
|
5
|
+
export type TreeDiff = {
|
|
6
|
+
added: ReadonlySet<BlockId>;
|
|
7
|
+
removed: ReadonlySet<BlockId>;
|
|
8
|
+
changed: ReadonlySet<BlockId>;
|
|
9
|
+
orderChanged: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function coraxTreeDiffing(prev: CoraxTree, next: CoraxTree): TreeDiff;
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@coorax/schema",
|
|
3
|
+
"version": "0.0.0-canary.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"module": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"source": "./src/index.ts",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"lint": "oxlint",
|
|
25
|
+
"lint:fix": "oxlint --fix --max-warnings=0",
|
|
26
|
+
"fmt": "oxfmt",
|
|
27
|
+
"fmt:check": "oxfmt --check",
|
|
28
|
+
"typecheck": "tsc --noEmit",
|
|
29
|
+
"build:types": "tsc --emitDeclarationOnly",
|
|
30
|
+
"build:js": "bun build ./src/index.ts --outdir ./dist --target browser --external lodash",
|
|
31
|
+
"build": "bun run build:types && bun run build:js",
|
|
32
|
+
"prepublishOnly": "bun run build"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"lodash": "^4.18.1"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/lodash": "^4.17.27",
|
|
39
|
+
"csstype": "^3.2.3",
|
|
40
|
+
"oxfmt": "^0.71.0",
|
|
41
|
+
"oxlint": "^1.86.0",
|
|
42
|
+
"typescript": "~6.0.2",
|
|
43
|
+
"vite": "^8.3.0"
|
|
44
|
+
},
|
|
45
|
+
"packageManager": "bun@1.3.9"
|
|
46
|
+
}
|