@mdxeditor/editor 1.14.3 → 2.0.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/dist/MDXEditor.js +19 -25
- package/dist/RealmWithPlugins.js +36 -0
- package/dist/directive-editors/GenericDirectiveEditor.js +7 -4
- package/dist/index.d.ts +2590 -62
- package/dist/index.js +138 -66
- package/dist/jsx-editors/GenericJsxEditor.js +12 -9
- package/dist/plugins/codeblock/CodeBlockNode.js +5 -5
- package/dist/plugins/codeblock/index.js +37 -63
- package/dist/plugins/codemirror/CodeMirrorEditor.js +3 -2
- package/dist/plugins/codemirror/index.js +28 -45
- package/dist/plugins/core/GenericHTMLNode.js +9 -1
- package/dist/plugins/core/MdastHTMLNode.js +0 -1
- package/dist/plugins/core/NestedLexicalEditor.js +11 -10
- package/dist/plugins/core/PropertyPopover.js +3 -2
- package/dist/plugins/core/SharedHistoryPlugin.js +3 -3
- package/dist/plugins/core/index.js +426 -385
- package/dist/plugins/core/ui/DownshiftAutoComplete.js +3 -2
- package/dist/plugins/core/ui/PopoverUtils.js +3 -2
- package/dist/plugins/diff-source/DiffSourceWrapper.js +3 -4
- package/dist/plugins/diff-source/DiffViewer.js +7 -7
- package/dist/plugins/diff-source/SourceEditor.js +6 -6
- package/dist/plugins/diff-source/index.js +17 -52
- package/dist/plugins/directives/DirectiveNode.js +28 -5
- package/dist/plugins/directives/index.js +36 -43
- package/dist/plugins/frontmatter/FrontmatterEditor.js +20 -16
- package/dist/plugins/frontmatter/index.js +51 -62
- package/dist/plugins/headings/index.js +43 -49
- package/dist/plugins/image/ImageDialog.js +11 -7
- package/dist/plugins/image/ImageEditor.js +10 -7
- package/dist/plugins/image/ImageNode.js +27 -5
- package/dist/plugins/image/index.js +65 -72
- package/dist/plugins/jsx/LexicalJsxNode.js +3 -2
- package/dist/plugins/jsx/index.js +48 -60
- package/dist/plugins/link/index.js +15 -20
- package/dist/plugins/link-dialog/LinkDialog.js +17 -16
- package/dist/plugins/link-dialog/index.js +194 -216
- package/dist/plugins/lists/index.js +50 -65
- package/dist/plugins/markdown-shortcut/index.js +12 -15
- package/dist/plugins/quote/index.js +11 -19
- package/dist/plugins/sandpack/SandpackEditor.js +3 -2
- package/dist/plugins/sandpack/index.js +34 -50
- package/dist/plugins/sandpack/useCodeMirrorRef.js +7 -6
- package/dist/plugins/table/TableEditor.js +12 -13
- package/dist/plugins/table/TableNode.js +28 -0
- package/dist/plugins/table/index.js +32 -39
- package/dist/plugins/thematic-break/index.js +19 -32
- package/dist/plugins/toolbar/components/BlockTypeSelect.js +9 -8
- package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.js +4 -4
- package/dist/plugins/toolbar/components/ChangeAdmonitionType.js +3 -2
- package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.js +5 -5
- package/dist/plugins/toolbar/components/CodeToggle.js +4 -3
- package/dist/plugins/toolbar/components/CreateLink.js +6 -4
- package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.js +5 -5
- package/dist/plugins/toolbar/components/InsertAdmonition.js +5 -3
- package/dist/plugins/toolbar/components/InsertCodeBlock.js +5 -3
- package/dist/plugins/toolbar/components/InsertFrontmatter.js +6 -5
- package/dist/plugins/toolbar/components/InsertImage.js +6 -5
- package/dist/plugins/toolbar/components/InsertSandpack.js +5 -4
- package/dist/plugins/toolbar/components/InsertTable.js +5 -3
- package/dist/plugins/toolbar/components/InsertThematicBreak.js +6 -4
- package/dist/plugins/toolbar/components/ListsToggle.js +5 -4
- package/dist/plugins/toolbar/components/ShowSandpackInfo.js +9 -4
- package/dist/plugins/toolbar/components/UndoRedo.js +3 -3
- package/dist/plugins/toolbar/index.js +15 -31
- package/dist/plugins/toolbar/primitives/DialogButton.js +23 -24
- package/dist/plugins/toolbar/primitives/TooltipWrap.js +3 -2
- package/dist/plugins/toolbar/primitives/select.js +5 -4
- package/dist/plugins/toolbar/primitives/toolbar.js +10 -4
- package/dist/style.css +935 -571
- package/dist/styles/globals.css.js +1 -4
- package/dist/styles/lexical-theme.module.css.js +25 -19
- package/dist/styles/ui.module.css.js +103 -103
- package/package.json +64 -317
- package/dist/FormatConstants.d.ts +0 -9
- package/dist/MDXEditor.d.ts +0 -103
- package/dist/directive-editors/AdmonitionDirectiveDescriptor.d.ts +0 -17
- package/dist/directive-editors/GenericDirectiveEditor.d.ts +0 -8
- package/dist/exportMarkdownFromLexical.d.ts +0 -138
- package/dist/gurx/index.d.ts +0 -3
- package/dist/gurx/react.d.ts +0 -152
- package/dist/gurx/react.js +0 -206
- package/dist/gurx/realm.d.ts +0 -148
- package/dist/gurx/realm.js +0 -489
- package/dist/gurx/realmFactory.d.ts +0 -79
- package/dist/gurx/realmFactory.js +0 -32
- package/dist/importMarkdownToLexical.d.ts +0 -101
- package/dist/jsx-editors/GenericJsxEditor.d.ts +0 -8
- package/dist/plugins/codeblock/CodeBlockNode.d.ts +0 -100
- package/dist/plugins/codeblock/CodeBlockVisitor.d.ts +0 -4
- package/dist/plugins/codeblock/MdastCodeVisitor.d.ts +0 -3
- package/dist/plugins/codeblock/index.d.ts +0 -787
- package/dist/plugins/codemirror/CodeMirrorEditor.d.ts +0 -3
- package/dist/plugins/codemirror/index.d.ts +0 -1038
- package/dist/plugins/core/GenericHTMLNode.d.ts +0 -38
- package/dist/plugins/core/Icon.d.ts +0 -6
- package/dist/plugins/core/LexicalGenericHTMLNodeVisitor.d.ts +0 -4
- package/dist/plugins/core/LexicalLinebreakVisitor.d.ts +0 -4
- package/dist/plugins/core/LexicalParagraphVisitor.d.ts +0 -4
- package/dist/plugins/core/LexicalRootVisitor.d.ts +0 -4
- package/dist/plugins/core/LexicalTextVisitor.d.ts +0 -5
- package/dist/plugins/core/MdastBreakVisitor.d.ts +0 -3
- package/dist/plugins/core/MdastFormattingVisitor.d.ts +0 -4
- package/dist/plugins/core/MdastHTMLNode.d.ts +0 -13
- package/dist/plugins/core/MdastHTMLVisitor.d.ts +0 -3
- package/dist/plugins/core/MdastInlineCodeVisitor.d.ts +0 -3
- package/dist/plugins/core/MdastParagraphVisitor.d.ts +0 -3
- package/dist/plugins/core/MdastRootVisitor.d.ts +0 -3
- package/dist/plugins/core/MdastTextVisitor.d.ts +0 -3
- package/dist/plugins/core/NestedLexicalEditor.d.ts +0 -92
- package/dist/plugins/core/PropertyPopover.d.ts +0 -23
- package/dist/plugins/core/SharedHistoryPlugin.d.ts +0 -2
- package/dist/plugins/core/index.d.ts +0 -583
- package/dist/plugins/core/ui/DownshiftAutoComplete.d.ts +0 -15
- package/dist/plugins/core/ui/PopoverUtils.d.ts +0 -4
- package/dist/plugins/diff-source/DiffSourceWrapper.d.ts +0 -4
- package/dist/plugins/diff-source/DiffViewer.d.ts +0 -2
- package/dist/plugins/diff-source/SourceEditor.d.ts +0 -4
- package/dist/plugins/diff-source/index.d.ts +0 -725
- package/dist/plugins/directives/DirectiveNode.d.ts +0 -51
- package/dist/plugins/directives/DirectiveVisitor.d.ts +0 -4
- package/dist/plugins/directives/MdastDirectiveVisitor.d.ts +0 -3
- package/dist/plugins/directives/index.d.ts +0 -773
- package/dist/plugins/frontmatter/FrontmatterEditor.d.ts +0 -6
- package/dist/plugins/frontmatter/FrontmatterNode.d.ts +0 -35
- package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.d.ts +0 -4
- package/dist/plugins/frontmatter/MdastFrontmatterVisitor.d.ts +0 -3
- package/dist/plugins/frontmatter/index.d.ts +0 -717
- package/dist/plugins/headings/LexicalHeadingVisitor.d.ts +0 -4
- package/dist/plugins/headings/MdastHeadingVisitor.d.ts +0 -3
- package/dist/plugins/headings/index.d.ts +0 -707
- package/dist/plugins/image/ImageDialog.d.ts +0 -2
- package/dist/plugins/image/ImageEditor.d.ts +0 -10
- package/dist/plugins/image/ImageNode.d.ts +0 -65
- package/dist/plugins/image/ImageResizer.d.ts +0 -18
- package/dist/plugins/image/LexicalImageVisitor.d.ts +0 -4
- package/dist/plugins/image/MdastImageVisitor.d.ts +0 -6
- package/dist/plugins/image/index.d.ts +0 -804
- package/dist/plugins/jsx/LexicalJsxNode.d.ts +0 -54
- package/dist/plugins/jsx/LexicalJsxVisitor.d.ts +0 -4
- package/dist/plugins/jsx/MdastMdxJsEsmVisitor.d.ts +0 -3
- package/dist/plugins/jsx/MdastMdxJsxElementVisitor.d.ts +0 -3
- package/dist/plugins/jsx/index.d.ts +0 -779
- package/dist/plugins/link/AutoLinkPlugin.d.ts +0 -9
- package/dist/plugins/link/LexicalLinkVisitor.d.ts +0 -4
- package/dist/plugins/link/MdastLinkVisitor.d.ts +0 -3
- package/dist/plugins/link/index.d.ts +0 -101
- package/dist/plugins/link-dialog/LinkDialog.d.ts +0 -16
- package/dist/plugins/link-dialog/index.d.ts +0 -670
- package/dist/plugins/lists/LexicalListItemVisitor.d.ts +0 -4
- package/dist/plugins/lists/LexicalListVisitor.d.ts +0 -4
- package/dist/plugins/lists/MdastListItemVisitor.d.ts +0 -3
- package/dist/plugins/lists/MdastListVisitor.d.ts +0 -3
- package/dist/plugins/lists/index.d.ts +0 -703
- package/dist/plugins/markdown-shortcut/index.d.ts +0 -80
- package/dist/plugins/quote/LexicalQuoteVisitor.d.ts +0 -4
- package/dist/plugins/quote/MdastBlockQuoteVisitor.d.ts +0 -3
- package/dist/plugins/quote/index.d.ts +0 -480
- package/dist/plugins/sandpack/SandpackEditor.d.ts +0 -7
- package/dist/plugins/sandpack/index.d.ts +0 -1077
- package/dist/plugins/sandpack/useCodeMirrorRef.d.ts +0 -4
- package/dist/plugins/table/LexicalTableVisitor.d.ts +0 -4
- package/dist/plugins/table/MdastTableVisitor.d.ts +0 -3
- package/dist/plugins/table/TableEditor.d.ts +0 -21
- package/dist/plugins/table/TableNode.d.ts +0 -52
- package/dist/plugins/table/index.d.ts +0 -704
- package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.d.ts +0 -4
- package/dist/plugins/thematic-break/MdastThematicBreakVisitor.d.ts +0 -3
- package/dist/plugins/thematic-break/index.d.ts +0 -693
- package/dist/plugins/toolbar/components/BlockTypeSelect.d.ts +0 -6
- package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.d.ts +0 -5
- package/dist/plugins/toolbar/components/ChangeAdmonitionType.d.ts +0 -6
- package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.d.ts +0 -7
- package/dist/plugins/toolbar/components/CodeToggle.d.ts +0 -6
- package/dist/plugins/toolbar/components/CreateLink.d.ts +0 -6
- package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.d.ts +0 -18
- package/dist/plugins/toolbar/components/InsertAdmonition.d.ts +0 -6
- package/dist/plugins/toolbar/components/InsertCodeBlock.d.ts +0 -7
- package/dist/plugins/toolbar/components/InsertFrontmatter.d.ts +0 -6
- package/dist/plugins/toolbar/components/InsertImage.d.ts +0 -6
- package/dist/plugins/toolbar/components/InsertSandpack.d.ts +0 -6
- package/dist/plugins/toolbar/components/InsertTable.d.ts +0 -6
- package/dist/plugins/toolbar/components/InsertThematicBreak.d.ts +0 -6
- package/dist/plugins/toolbar/components/KitchenSinkToolbar.d.ts +0 -7
- package/dist/plugins/toolbar/components/ListsToggle.d.ts +0 -7
- package/dist/plugins/toolbar/components/ShowSandpackInfo.d.ts +0 -7
- package/dist/plugins/toolbar/components/UndoRedo.d.ts +0 -5
- package/dist/plugins/toolbar/index.d.ts +0 -564
- package/dist/plugins/toolbar/primitives/DialogButton.d.ts +0 -40
- package/dist/plugins/toolbar/primitives/TooltipWrap.d.ts +0 -8
- package/dist/plugins/toolbar/primitives/select.d.ts +0 -50
- package/dist/plugins/toolbar/primitives/toolbar.d.ts +0 -163
- package/dist/styles/lexicalTheme.d.ts +0 -2
- package/dist/utils/detectMac.d.ts +0 -3
- package/dist/utils/fp.d.ts +0 -47
- package/dist/utils/isPartOftheEditorUI.d.ts +0 -1
- package/dist/utils/lexicalHelpers.d.ts +0 -11
- package/dist/utils/makeHslTransparent.d.ts +0 -1
- package/dist/utils/mergeStyleAttributes.d.ts +0 -1
- package/dist/utils/uuid4.d.ts +0 -1
- package/dist/utils/voidEmitter.d.ts +0 -14
- package/dist/utils/whitespaceConversion.d.ts +0 -2
- package/dist/utils/whitespaceConversion.js +0 -9
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { LexicalNode, RootNode as LexicalRootNode } from 'lexical';
|
|
2
|
-
import * as Mdast from 'mdast';
|
|
3
|
-
import { Options as ToMarkdownOptions } from 'mdast-util-to-markdown';
|
|
4
|
-
import type { JsxComponentDescriptor } from './plugins/jsx';
|
|
5
|
-
export type { Options as ToMarkdownOptions } from 'mdast-util-to-markdown';
|
|
6
|
-
/**
|
|
7
|
-
* A set of covenience utilities to manipulate the mdast tree when processing lexical nodes.
|
|
8
|
-
*/
|
|
9
|
-
export interface LexicalVisitActions<T extends LexicalNode> {
|
|
10
|
-
/**
|
|
11
|
-
* Iterate over the immediate children of a lexical node with the given mdast node as a parent.
|
|
12
|
-
*/
|
|
13
|
-
visitChildren(node: T, mdastParent: Mdast.Parent): void;
|
|
14
|
-
/**
|
|
15
|
-
* Create a new mdast node with the given type, and props.
|
|
16
|
-
* Iterate over the immediate children of the current lexical node with the new mdast node as a parent.
|
|
17
|
-
* @param hasChildren - true by default. Pass false to skip iterating over the lexical node children.
|
|
18
|
-
*/
|
|
19
|
-
addAndStepInto(type: string, props?: Record<string, unknown>, hasChildren?: boolean): void;
|
|
20
|
-
/**
|
|
21
|
-
* Append a new mdast node to a parent node.
|
|
22
|
-
* @param parentNode - the mdast parent node to append the new node to.
|
|
23
|
-
* @param node - the mdast node to append.
|
|
24
|
-
*/
|
|
25
|
-
appendToParent<T extends Mdast.Parent>(parentNode: T, node: T['children'][number]): T['children'][number] | Mdast.Root;
|
|
26
|
-
/**
|
|
27
|
-
* Used when processing JSX nodes so that later, the correct import statement can be added to the document.
|
|
28
|
-
* @param componentName - the name of the component that has to be imported.
|
|
29
|
-
* @see {@link JsxComponentDescriptor}
|
|
30
|
-
*/
|
|
31
|
-
registerReferredComponent(componentName: string): void;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* The params passed to the {@link LexicalExportVisitor.visitLexicalNode} method.
|
|
35
|
-
*/
|
|
36
|
-
export interface LexicalNodeVisitParams<T extends LexicalNode> {
|
|
37
|
-
/**
|
|
38
|
-
* The lexical node that is being visited.
|
|
39
|
-
*/
|
|
40
|
-
lexicalNode: T;
|
|
41
|
-
/**
|
|
42
|
-
* The mdast parent node that the result of the lexical node conversion should be appended to.
|
|
43
|
-
*/
|
|
44
|
-
mdastParent: Mdast.Parent;
|
|
45
|
-
/**
|
|
46
|
-
* A set of actions that can be used to manipulate the mdast tree.
|
|
47
|
-
* These are "convenience" utilities that avoid the repetitive boilerplate of creating mdast nodes.
|
|
48
|
-
*/
|
|
49
|
-
actions: LexicalVisitActions<T>;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Implement this interface in order to process mdast node(s) into a lexical tree.
|
|
53
|
-
* This is part of the process that converts the editor contents to markdown.
|
|
54
|
-
*/
|
|
55
|
-
export interface LexicalExportVisitor<LN extends LexicalNode, UN extends Mdast.Content> {
|
|
56
|
-
/**
|
|
57
|
-
* Return true if the given node is of the type that this visitor can process.
|
|
58
|
-
* You can safely use the node type guard functions (as in $isParagraphNode, $isLinkNode, etc.) here.
|
|
59
|
-
*/
|
|
60
|
-
testLexicalNode?(lexicalNode: LexicalNode): lexicalNode is LN;
|
|
61
|
-
/**
|
|
62
|
-
* Process the given node and manipulate the mdast tree accordingly.
|
|
63
|
-
* @see {@link LexicalNodeVisitParams} and {@link LexicalVisitActions} for more information.
|
|
64
|
-
*/
|
|
65
|
-
visitLexicalNode?(params: LexicalNodeVisitParams<LN>): void;
|
|
66
|
-
/**
|
|
67
|
-
* Return true if the current node should be joined with the previous node.
|
|
68
|
-
* This is necessary due to some inconsistencies between the lexical tree and the mdast tree when it comes to formatting.
|
|
69
|
-
*/
|
|
70
|
-
shouldJoin?(prevNode: Mdast.Content, currentNode: UN): boolean;
|
|
71
|
-
/**
|
|
72
|
-
* Join the current node with the previous node, returning the resulting new node
|
|
73
|
-
* For this to be called by the tree walk, shouldJoin must return true.
|
|
74
|
-
*/
|
|
75
|
-
join?<T extends Mdast.Content>(prevNode: T, currentNode: T): T;
|
|
76
|
-
/**
|
|
77
|
-
* Default 0, optional, sets the priority of the visitor. The higher the number, the earlier it will be called.
|
|
78
|
-
*/
|
|
79
|
-
priority?: number;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* The "any" type for LexicalExportVisitor.
|
|
83
|
-
* @internal
|
|
84
|
-
*/
|
|
85
|
-
export type LexicalVisitor = LexicalExportVisitor<LexicalNode, Mdast.Content>;
|
|
86
|
-
/**
|
|
87
|
-
* @internal
|
|
88
|
-
*/
|
|
89
|
-
export interface ExportLexicalTreeOptions {
|
|
90
|
-
root: LexicalRootNode;
|
|
91
|
-
visitors: LexicalVisitor[];
|
|
92
|
-
jsxComponentDescriptors: JsxComponentDescriptor[];
|
|
93
|
-
jsxIsAvailable: boolean;
|
|
94
|
-
addImportStatements?: boolean;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* @internal
|
|
98
|
-
*/
|
|
99
|
-
export declare function exportLexicalTreeToMdast({ root, visitors, jsxComponentDescriptors, jsxIsAvailable, addImportStatements }: ExportLexicalTreeOptions): Mdast.Root;
|
|
100
|
-
/**
|
|
101
|
-
* @internal
|
|
102
|
-
*/
|
|
103
|
-
export type ToMarkdownExtension = NonNullable<ToMarkdownOptions['extensions']>[number];
|
|
104
|
-
/**
|
|
105
|
-
* @internal
|
|
106
|
-
*/
|
|
107
|
-
export interface ExportMarkdownFromLexicalOptions extends ExportLexicalTreeOptions {
|
|
108
|
-
visitors: LexicalVisitor[];
|
|
109
|
-
/**
|
|
110
|
-
* the markdown extensions to use
|
|
111
|
-
*/
|
|
112
|
-
toMarkdownExtensions: ToMarkdownExtension[];
|
|
113
|
-
/**
|
|
114
|
-
* The options to pass to `toMarkdown`
|
|
115
|
-
*/
|
|
116
|
-
toMarkdownOptions: ToMarkdownOptions;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Configures how the lexical tree is converted to a mdast tree and then to markdown.
|
|
120
|
-
*/
|
|
121
|
-
export interface LexicalConvertOptions {
|
|
122
|
-
/**
|
|
123
|
-
* The visitors to use when processing the lexical tree
|
|
124
|
-
*/
|
|
125
|
-
visitors?: LexicalVisitor[];
|
|
126
|
-
/**
|
|
127
|
-
* the markdown extensions to use
|
|
128
|
-
*/
|
|
129
|
-
toMarkdownExtensions?: ToMarkdownExtension[];
|
|
130
|
-
/**
|
|
131
|
-
* The options to pass to `toMarkdown`
|
|
132
|
-
*/
|
|
133
|
-
toMarkdownOptions?: ToMarkdownOptions;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* @internal
|
|
137
|
-
*/
|
|
138
|
-
export declare function exportMarkdownFromLexical({ root, toMarkdownOptions, toMarkdownExtensions, visitors, jsxComponentDescriptors, jsxIsAvailable }: ExportMarkdownFromLexicalOptions): string;
|
package/dist/gurx/index.d.ts
DELETED
package/dist/gurx/react.d.ts
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { RealmNode } from './realm';
|
|
3
|
-
import type { ValuesForKeys, TypedRealm, System, RealmFactory, ValueForKey, SystemKeys, SystemDict, AnySystemSpec, SystemOfSpecs } from './realmFactory';
|
|
4
|
-
/**
|
|
5
|
-
* Describes the mapping between the system streams and the component properties.
|
|
6
|
-
* Each property uses the keys as the names of the properties and the values as the corresponding stream names.
|
|
7
|
-
* @typeParam SS - the type of the system.
|
|
8
|
-
*/
|
|
9
|
-
export interface SystemPropsMap<Sys extends System, K = keyof Sys, D = {
|
|
10
|
-
[name: string]: K;
|
|
11
|
-
}> {
|
|
12
|
-
/**
|
|
13
|
-
* Specifies the required component properties.
|
|
14
|
-
*/
|
|
15
|
-
required?: D;
|
|
16
|
-
/**
|
|
17
|
-
* Specifies the optional component properties.
|
|
18
|
-
*/
|
|
19
|
-
optional?: D;
|
|
20
|
-
/**
|
|
21
|
-
* Specifies the component methods, if any. Streams are converted to methods with a single argument.
|
|
22
|
-
* When invoked, the method publishes the value of the argument to the specified stream.
|
|
23
|
-
*/
|
|
24
|
-
methods?: D;
|
|
25
|
-
/**
|
|
26
|
-
* Specifies the component "event" properties, if any.
|
|
27
|
-
* Event properties accept callback functions which get executed when the stream emits a new value.
|
|
28
|
-
*/
|
|
29
|
-
events?: D;
|
|
30
|
-
}
|
|
31
|
-
type StringKeys<T> = Extract<keyof T, string>;
|
|
32
|
-
/** @internal */
|
|
33
|
-
export type PropsFromPropMap<Sys extends System, Map extends SystemPropsMap<Sys>> = {
|
|
34
|
-
[K in StringKeys<Map['required']>]: Map['required'][K] extends string ? Sys[Map['required'][K]] extends RealmNode<infer R> ? R : never : never;
|
|
35
|
-
} & {
|
|
36
|
-
[K in StringKeys<Map['optional']>]?: Map['optional'][K] extends string ? Sys[Map['optional'][K]] extends RealmNode<infer R> ? R : never : never;
|
|
37
|
-
} & {
|
|
38
|
-
[K in StringKeys<Map['events']>]?: Map['events'][K] extends string ? Sys[Map['events'][K]] extends RealmNode<infer R> ? (value: R) => void : never : never;
|
|
39
|
-
};
|
|
40
|
-
/** @internal */
|
|
41
|
-
export type MethodsFromPropMap<Sys extends System, Map extends SystemPropsMap<Sys>> = {
|
|
42
|
-
[K in StringKeys<Map['methods']>]: Map['methods'][K] extends string ? Sys[Map['methods'][K]] extends RealmNode<infer R> ? (value: R) => void : never : never;
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* @internal
|
|
46
|
-
* Used to correctly specify type refs for system components.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```tsx
|
|
50
|
-
* const s = system(() => { return { a: statefulStream(0) } })
|
|
51
|
-
* const { Component } = systemToComponent(s)
|
|
52
|
-
*
|
|
53
|
-
* const App = () => {
|
|
54
|
-
* const ref = useRef<RefHandle<typeof Component>>()
|
|
55
|
-
* return <Component ref={ref} />
|
|
56
|
-
* }
|
|
57
|
-
* ```
|
|
58
|
-
*
|
|
59
|
-
* @typeParam T - the type of the component
|
|
60
|
-
*/
|
|
61
|
-
export type RefHandle<T> = T extends React.ForwardRefExoticComponent<React.RefAttributes<infer Handle>> ? Handle : never;
|
|
62
|
-
/**
|
|
63
|
-
* Converts a system spec to React component by mapping the system streams to component properties, events and methods. Returns hooks for querying and modifying
|
|
64
|
-
* the system streams from the component's child components.
|
|
65
|
-
* @param realmFactory - The return value from a [[system]] call.
|
|
66
|
-
* @param map - The streams to props / events / methods mapping Check [[SystemPropsMap]] for more details.
|
|
67
|
-
* @param Root - The optional React component to render. By default, the resulting component renders nothing, acting as a logical wrapper for its children.
|
|
68
|
-
* @returns an object containing the following:
|
|
69
|
-
* - `Component`: the React component.
|
|
70
|
-
* - `useEmitterValue`: a hook that lets child components use values emitted from the specified output stream.
|
|
71
|
-
* - `useEmitter`: a hook that calls the provided callback whenever the specified stream emits a value.
|
|
72
|
-
* - `usePublisher`: a hook which lets child components publish values to the specified stream.
|
|
73
|
-
* <hr />
|
|
74
|
-
*/
|
|
75
|
-
export declare function realmFactoryToComponent<RootComp, RF extends RealmFactory<Sys>, Sys extends System = RF extends RealmFactory<infer S> ? S : never, Realm extends TypedRealm<Sys> = TypedRealm<Sys>, M extends SystemPropsMap<Sys> = SystemPropsMap<Sys>>(realmFactory: RF, map: M, Root?: RootComp): {
|
|
76
|
-
useRealmContext: () => TypedRealm<Sys>;
|
|
77
|
-
useEmitter: <K extends Extract<keyof Sys, string>>(key: K, callback: (value: ValueForKey<Sys, K>) => void) => void;
|
|
78
|
-
useEmitterValues: <K_1 extends SystemKeys<Sys>>(...keys: K_1) => ValuesForKeys<Sys, K_1>;
|
|
79
|
-
usePubKeys: () => (values: SystemDict<Sys>) => void;
|
|
80
|
-
usePublisher: <K_2 extends keyof Sys>(key: K_2) => (value: ValueForKey<Sys, K_2>) => void;
|
|
81
|
-
Component: React.ForwardRefExoticComponent<React.PropsWithoutRef<{ [K_3 in Extract<keyof M["required"], string>]: M["required"][K_3] extends string ? Sys[M["required"][K_3]] extends RealmNode<infer R> ? R : never : never; } & { [K_4 in Extract<keyof M["optional"], string>]?: (M["optional"][K_4] extends string ? Sys[M["optional"][K_4]] extends RealmNode<infer R_1> ? R_1 : never : never) | undefined; } & { [K_5 in Extract<keyof M["events"], string>]?: (M["events"][K_5] extends string ? Sys[M["events"][K_5]] extends RealmNode<infer R_2> ? (value: R_2) => void : never : never) | undefined; } & (RootComp extends React.ComponentType<infer RP> ? RP : {
|
|
82
|
-
children?: React.ReactNode;
|
|
83
|
-
})> & React.RefAttributes<MethodsFromPropMap<Sys, M>>>;
|
|
84
|
-
};
|
|
85
|
-
/** @internal */
|
|
86
|
-
export declare function sysHooks<Sys extends System>(): {
|
|
87
|
-
useRealmContext: () => TypedRealm<Sys>;
|
|
88
|
-
useEmitter: <K extends Extract<keyof Sys, string>>(key: K, callback: (value: ValueForKey<Sys, K>) => void) => void;
|
|
89
|
-
useEmitterValues: <K_1 extends SystemKeys<Sys>>(...keys: K_1) => ValuesForKeys<Sys, K_1>;
|
|
90
|
-
usePubKeys: () => (values: SystemDict<Sys>) => void;
|
|
91
|
-
usePublisher: <K_2 extends keyof Sys>(key: K_2) => (value: ValueForKey<Sys, K_2>) => void;
|
|
92
|
-
};
|
|
93
|
-
type SystemAndDependencies<Spec extends AnySystemSpec> = SystemOfSpecs<[Spec]> & SystemOfSpecs<Spec['dependencies']>;
|
|
94
|
-
/**
|
|
95
|
-
* The parameters of a plugin declaration. THe best way to understand what each one does is to examine the source code of the existing plugins.
|
|
96
|
-
*/
|
|
97
|
-
export interface RealmPluginParams<Spec extends AnySystemSpec, Params extends object> {
|
|
98
|
-
/**
|
|
99
|
-
* The id of the plugin. Used to declare conditional features that are activated only if the plugin is present.
|
|
100
|
-
*/
|
|
101
|
-
id: string;
|
|
102
|
-
/**
|
|
103
|
-
* The ids of the plugins that this plugin depends on. The plugin will not be activated if any of the dependencies is not present.
|
|
104
|
-
*/
|
|
105
|
-
dependencies?: string[];
|
|
106
|
-
/**
|
|
107
|
-
* The system spec of the plugin. Construct one using {@link system}.
|
|
108
|
-
*/
|
|
109
|
-
systemSpec: Spec;
|
|
110
|
-
/**
|
|
111
|
-
* The callback is executed every time the react component is re-rendered.
|
|
112
|
-
*/
|
|
113
|
-
applyParamsToSystem?: (realm: TypedRealm<SystemAndDependencies<Spec>>, props: Params) => void;
|
|
114
|
-
/**
|
|
115
|
-
* Executed when the component mounts. Use this to register import/export visitors, add lexical nodes to the editor, etc.
|
|
116
|
-
* @param realm - the realm instance
|
|
117
|
-
* @param params - the parameters passed to the plugin in the component declaration
|
|
118
|
-
* @param pluginIds - the ids of all the plugins that are present in the component declaration
|
|
119
|
-
*/
|
|
120
|
-
init?: (realm: TypedRealm<SystemAndDependencies<Spec>>, params: Params, pluginIds: string[]) => void;
|
|
121
|
-
}
|
|
122
|
-
/** @internal */
|
|
123
|
-
export interface PluginConstructor<Spec extends AnySystemSpec, Params extends object> {
|
|
124
|
-
(params?: Params): {
|
|
125
|
-
pluginParams?: Params;
|
|
126
|
-
} & RealmPluginParams<Spec, Params>;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Declares a new MDXEditor plugin.
|
|
130
|
-
*/
|
|
131
|
-
export declare function realmPlugin<Spec extends AnySystemSpec, Params extends object>(params: RealmPluginParams<Spec, Params>): readonly [PluginConstructor<Spec, Params>, {
|
|
132
|
-
useRealmContext: () => TypedRealm<SystemAndDependencies<Spec>>;
|
|
133
|
-
useEmitter: <K extends Extract<keyof (Spec extends AnySystemSpec ? {} & ReturnType<Spec["constructor"]> : never), string> | Extract<keyof SystemOfSpecs<Spec["dependencies"]>, string>>(key: K, callback: (value: ValueForKey<SystemAndDependencies<Spec>, K>) => void) => void;
|
|
134
|
-
useEmitterValues: <K_1 extends SystemKeys<SystemAndDependencies<Spec>>>(...keys: K_1) => ValuesForKeys<SystemAndDependencies<Spec>, K_1>;
|
|
135
|
-
usePubKeys: () => (values: SystemDict<SystemAndDependencies<Spec>>) => void;
|
|
136
|
-
usePublisher: <K_2 extends keyof (Spec extends AnySystemSpec ? {} & ReturnType<Spec["constructor"]> : never) | keyof SystemOfSpecs<Spec["dependencies"]>>(key: K_2) => (value: ValueForKey<SystemAndDependencies<Spec>, K_2>) => void;
|
|
137
|
-
}];
|
|
138
|
-
/** @internal */
|
|
139
|
-
export declare const RealmPluginInitializer: <P extends ({
|
|
140
|
-
pluginParams?: any;
|
|
141
|
-
} & RealmPluginParams<AnySystemSpec, any>)[]>({ plugins, children }: {
|
|
142
|
-
plugins: P;
|
|
143
|
-
children?: React.ReactNode;
|
|
144
|
-
}) => React.FunctionComponentElement<React.ProviderProps<TypedRealm<any>>>;
|
|
145
|
-
/** @internal */
|
|
146
|
-
export declare function useHasPlugin(id: string): boolean;
|
|
147
|
-
/** @internal */
|
|
148
|
-
export declare const RequirePlugin: React.FC<{
|
|
149
|
-
id: string;
|
|
150
|
-
children: React.ReactNode;
|
|
151
|
-
}>;
|
|
152
|
-
export {};
|
package/dist/gurx/react.js
DELETED
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import React__default, { useEffect } from "react";
|
|
2
|
-
import { tap, always } from "../utils/fp.js";
|
|
3
|
-
import { realmFactory } from "./realmFactory.js";
|
|
4
|
-
function omit(keys, obj) {
|
|
5
|
-
const result = {};
|
|
6
|
-
const index = {};
|
|
7
|
-
let idx = 0;
|
|
8
|
-
const len = keys.length;
|
|
9
|
-
while (idx < len) {
|
|
10
|
-
index[keys[idx]] = 1;
|
|
11
|
-
idx += 1;
|
|
12
|
-
}
|
|
13
|
-
for (const prop in obj) {
|
|
14
|
-
if (!Object.prototype.hasOwnProperty.call(index, prop)) {
|
|
15
|
-
result[prop] = obj[prop];
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return result;
|
|
19
|
-
}
|
|
20
|
-
const useIsomorphicLayoutEffect = typeof document !== "undefined" ? React__default.useLayoutEffect : React__default.useEffect;
|
|
21
|
-
const GurxContext = React__default.createContext(void 0);
|
|
22
|
-
function realmFactoryToComponent(realmFactory2, map, Root) {
|
|
23
|
-
const requiredPropNames = Object.keys(map.required || {});
|
|
24
|
-
const optionalPropNames = Object.keys(map.optional || {});
|
|
25
|
-
const methodNames = Object.keys(map.methods || {});
|
|
26
|
-
const eventNames = Object.keys(map.events || {});
|
|
27
|
-
const Context = GurxContext;
|
|
28
|
-
function applyPropsToRealm(realm, props) {
|
|
29
|
-
const toBePublished = {};
|
|
30
|
-
for (const requiredPropName of requiredPropNames) {
|
|
31
|
-
const nodeName = map.required[requiredPropName];
|
|
32
|
-
toBePublished[nodeName] = props[requiredPropName];
|
|
33
|
-
}
|
|
34
|
-
for (const optionalPropName of optionalPropNames) {
|
|
35
|
-
const value = props[optionalPropName];
|
|
36
|
-
if (value !== void 0) {
|
|
37
|
-
const nodeName = map.optional[optionalPropName];
|
|
38
|
-
toBePublished[nodeName] = value;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
realm.pubKeys(toBePublished);
|
|
42
|
-
}
|
|
43
|
-
function buildMethods(realm) {
|
|
44
|
-
return methodNames.reduce((acc, methodName) => {
|
|
45
|
-
const nodeName = map.methods[methodName];
|
|
46
|
-
acc[methodName] = (value) => {
|
|
47
|
-
realm.pubKey(nodeName, value);
|
|
48
|
-
};
|
|
49
|
-
return acc;
|
|
50
|
-
}, {});
|
|
51
|
-
}
|
|
52
|
-
const Component = React__default.forwardRef((props, ref) => {
|
|
53
|
-
const realm = React__default.useMemo(() => {
|
|
54
|
-
return tap(realmFactory2(), (realm2) => applyPropsToRealm(realm2, props));
|
|
55
|
-
}, []);
|
|
56
|
-
useIsomorphicLayoutEffect(() => {
|
|
57
|
-
applyPropsToRealm(realm, props);
|
|
58
|
-
realm.resetSingletonSubs();
|
|
59
|
-
for (const eventName of eventNames) {
|
|
60
|
-
if (eventName in props) {
|
|
61
|
-
realm.singletonSubKey(map.events[eventName], props[eventName]);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return () => {
|
|
65
|
-
realm.resetSingletonSubs();
|
|
66
|
-
};
|
|
67
|
-
}, [props]);
|
|
68
|
-
React__default.useImperativeHandle(ref, always(buildMethods(realm)));
|
|
69
|
-
const children = props.children;
|
|
70
|
-
return React__default.createElement(
|
|
71
|
-
Context.Provider,
|
|
72
|
-
{ value: realm },
|
|
73
|
-
Root ? React__default.createElement(
|
|
74
|
-
Root,
|
|
75
|
-
omit([...requiredPropNames, ...optionalPropNames, ...eventNames], props),
|
|
76
|
-
children
|
|
77
|
-
) : children
|
|
78
|
-
);
|
|
79
|
-
});
|
|
80
|
-
Component.displayName = "Gurx Component";
|
|
81
|
-
return {
|
|
82
|
-
Component,
|
|
83
|
-
...sysHooks()
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
function sysHooks() {
|
|
87
|
-
const Context = GurxContext;
|
|
88
|
-
const usePublisher = (key) => {
|
|
89
|
-
const realm = React__default.useContext(Context);
|
|
90
|
-
return React__default.useCallback(
|
|
91
|
-
(value) => {
|
|
92
|
-
realm.pubKey(key, value);
|
|
93
|
-
},
|
|
94
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
95
|
-
[key, realm]
|
|
96
|
-
);
|
|
97
|
-
};
|
|
98
|
-
const useEmitterValues = (...keys) => {
|
|
99
|
-
const realm = React__default.useContext(Context);
|
|
100
|
-
const [values, setValues] = React__default.useState(() => realm.getKeyValues(keys));
|
|
101
|
-
useEffect(
|
|
102
|
-
() => realm == null ? void 0 : realm.subKeys(keys, (newValues) => {
|
|
103
|
-
const setter = () => {
|
|
104
|
-
if (keys.length === 1) {
|
|
105
|
-
newValues = [newValues];
|
|
106
|
-
}
|
|
107
|
-
for (let i = 0; i < keys.length; i++) {
|
|
108
|
-
if (newValues[i] !== values[i]) {
|
|
109
|
-
setValues(newValues);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
setter();
|
|
114
|
-
}),
|
|
115
|
-
[keys, realm, values]
|
|
116
|
-
);
|
|
117
|
-
return values;
|
|
118
|
-
};
|
|
119
|
-
const usePubKeys = () => {
|
|
120
|
-
return React__default.useContext(Context).pubKeys;
|
|
121
|
-
};
|
|
122
|
-
const useEmitter = (key, callback) => {
|
|
123
|
-
const realm = React__default.useContext(Context);
|
|
124
|
-
useIsomorphicLayoutEffect(() => realm.subKey(key, callback), [callback]);
|
|
125
|
-
};
|
|
126
|
-
const useRealmContext = () => {
|
|
127
|
-
return React__default.useContext(Context);
|
|
128
|
-
};
|
|
129
|
-
return {
|
|
130
|
-
useRealmContext,
|
|
131
|
-
useEmitter,
|
|
132
|
-
useEmitterValues,
|
|
133
|
-
usePubKeys,
|
|
134
|
-
usePublisher
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
const UsedPluginsContext = React__default.createContext(/* @__PURE__ */ new Set());
|
|
138
|
-
function realmPlugin(params) {
|
|
139
|
-
const plugin = (pluginParams) => {
|
|
140
|
-
return {
|
|
141
|
-
systemSpec: params.systemSpec,
|
|
142
|
-
pluginParams,
|
|
143
|
-
applyParamsToSystem: params.applyParamsToSystem,
|
|
144
|
-
init: params.init,
|
|
145
|
-
id: params.id,
|
|
146
|
-
dependencies: params.dependencies
|
|
147
|
-
};
|
|
148
|
-
};
|
|
149
|
-
return [plugin, sysHooks()];
|
|
150
|
-
}
|
|
151
|
-
const RealmPluginInitializer = function({
|
|
152
|
-
plugins,
|
|
153
|
-
children
|
|
154
|
-
}) {
|
|
155
|
-
const validPlugins = React__default.useMemo(() => {
|
|
156
|
-
const availablePlugins = plugins.map((plugin) => plugin.id);
|
|
157
|
-
const validPlugins2 = plugins.filter((plugin) => {
|
|
158
|
-
if (plugin.dependencies) {
|
|
159
|
-
if (plugin.dependencies.some((dep) => !availablePlugins.includes(dep))) {
|
|
160
|
-
console.warn("MDXEditor plugin", plugin.id, "has some missing dependencies", plugin.dependencies, ", skipping");
|
|
161
|
-
return false;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return true;
|
|
165
|
-
});
|
|
166
|
-
return validPlugins2;
|
|
167
|
-
}, [plugins]);
|
|
168
|
-
const realm = React__default.useMemo(() => {
|
|
169
|
-
const specs = validPlugins.map((plugin) => plugin.systemSpec);
|
|
170
|
-
const pluginIds = validPlugins.map((plugin) => plugin.id);
|
|
171
|
-
const realm2 = realmFactory(...specs);
|
|
172
|
-
validPlugins.forEach((plugin) => {
|
|
173
|
-
var _a, _b;
|
|
174
|
-
(_a = plugin.init) == null ? void 0 : _a.call(plugin, realm2, plugin.pluginParams, pluginIds);
|
|
175
|
-
(_b = plugin.applyParamsToSystem) == null ? void 0 : _b.call(plugin, realm2, plugin.pluginParams);
|
|
176
|
-
});
|
|
177
|
-
return realm2;
|
|
178
|
-
}, []);
|
|
179
|
-
React__default.useEffect(() => {
|
|
180
|
-
validPlugins.forEach((plugin) => {
|
|
181
|
-
var _a;
|
|
182
|
-
(_a = plugin.applyParamsToSystem) == null ? void 0 : _a.call(plugin, realm, plugin.pluginParams);
|
|
183
|
-
});
|
|
184
|
-
}, [realm, validPlugins]);
|
|
185
|
-
const Context = GurxContext;
|
|
186
|
-
return React__default.createElement(
|
|
187
|
-
Context.Provider,
|
|
188
|
-
{ value: realm },
|
|
189
|
-
React__default.createElement(UsedPluginsContext.Provider, { value: new Set(plugins.map((plugin) => plugin.id)) }, children)
|
|
190
|
-
);
|
|
191
|
-
};
|
|
192
|
-
function useHasPlugin(id) {
|
|
193
|
-
const usedPlugins = React__default.useContext(UsedPluginsContext);
|
|
194
|
-
return usedPlugins.has(id);
|
|
195
|
-
}
|
|
196
|
-
const RequirePlugin = ({ id, children }) => {
|
|
197
|
-
return useHasPlugin(id) ? React__default.createElement(React__default.Fragment, {}, children) : null;
|
|
198
|
-
};
|
|
199
|
-
export {
|
|
200
|
-
RealmPluginInitializer,
|
|
201
|
-
RequirePlugin,
|
|
202
|
-
realmFactoryToComponent,
|
|
203
|
-
realmPlugin,
|
|
204
|
-
sysHooks,
|
|
205
|
-
useHasPlugin
|
|
206
|
-
};
|
package/dist/gurx/realm.d.ts
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { LongTuple } from './realmFactory';
|
|
2
|
-
/** @internal */
|
|
3
|
-
export type NodeKey = string;
|
|
4
|
-
/** @internal */
|
|
5
|
-
export interface RealmNode<_T = unknown> {
|
|
6
|
-
key: NodeKey;
|
|
7
|
-
toString(): string;
|
|
8
|
-
}
|
|
9
|
-
/** @internal */
|
|
10
|
-
type RN<T = unknown> = RealmNode<T>;
|
|
11
|
-
/** @internal **/
|
|
12
|
-
export type Subscription<T = any> = (value: T) => unknown;
|
|
13
|
-
/** @internal */
|
|
14
|
-
export type UnsubscribeHandle = () => void;
|
|
15
|
-
type ProjectionFunc<T extends unknown[] = unknown[]> = (done: (...values: unknown[]) => void) => (...args: T) => void;
|
|
16
|
-
/** @internal */
|
|
17
|
-
export interface RealmProjection<T extends unknown[] = unknown[]> {
|
|
18
|
-
sources: Set<NodeKey>;
|
|
19
|
-
pulls: Set<NodeKey>;
|
|
20
|
-
sink: NodeKey;
|
|
21
|
-
map: ProjectionFunc<T>;
|
|
22
|
-
}
|
|
23
|
-
/** @internal */
|
|
24
|
-
export interface RealmProjectionSpec<T extends unknown[] = unknown[]> {
|
|
25
|
-
sources: RealmNode[];
|
|
26
|
-
pulls?: RealmNode[];
|
|
27
|
-
sink: RealmNode;
|
|
28
|
-
map: ProjectionFunc<T>;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* A function which determines if two values are equal.
|
|
32
|
-
* Implement custom comparators when the distinctUntilChanged operator needs to work on non-primitive objects.
|
|
33
|
-
* @returns true if values should be considered equal.
|
|
34
|
-
*/
|
|
35
|
-
export interface Comparator<T = any> {
|
|
36
|
-
(current: T, next: T): boolean;
|
|
37
|
-
}
|
|
38
|
-
type NodesFromValuesRec<T extends unknown[], Acc extends unknown[]> = T extends [infer Head, ...infer Tail] ? NodesFromValuesRec<Tail, [...Acc, Head extends unknown ? RealmNode<Head> : never]> : Acc;
|
|
39
|
-
/** @internal */
|
|
40
|
-
export type NodesFromValues<T extends unknown[]> = T extends unknown[] ? NodesFromValuesRec<T, []> : never;
|
|
41
|
-
/**
|
|
42
|
-
* A comparator function to determine if two values are equal. Used by distinctUntilChanged operator.
|
|
43
|
-
*/
|
|
44
|
-
export declare function defaultComparator<T>(current: T, next: T): boolean;
|
|
45
|
-
declare class SetMap<T> {
|
|
46
|
-
map: Map<string, Set<T>>;
|
|
47
|
-
getOrCreate(key: NodeKey): Set<T>;
|
|
48
|
-
get(key: NodeKey): Set<T> | undefined;
|
|
49
|
-
use(key: NodeKey, cb: (value: Set<T>) => unknown): void;
|
|
50
|
-
delete(key: NodeKey): boolean;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* @internal
|
|
54
|
-
*/
|
|
55
|
-
export declare class RefCount {
|
|
56
|
-
map: Map<NodeKey, number>;
|
|
57
|
-
constructor(map?: Map<string, number>);
|
|
58
|
-
clone(): RefCount;
|
|
59
|
-
increment(key: NodeKey): void;
|
|
60
|
-
decrement(key: NodeKey, ifZero: () => void): void;
|
|
61
|
-
}
|
|
62
|
-
/** @internal */
|
|
63
|
-
export type RealmGraph = SetMap<RealmProjection>;
|
|
64
|
-
/** @internal */
|
|
65
|
-
export declare function realm(): {
|
|
66
|
-
combine: {
|
|
67
|
-
<T1>(nodes_0: RN<T1>): RN<T1>;
|
|
68
|
-
<T1_1, T2>(nodes_0: RN<T1_1>, nodes_1: RN<T2>): RN<[T1_1, T2]>;
|
|
69
|
-
<T1_2, T2_1, T3>(nodes_0: RN<T1_2>, nodes_1: RN<T2_1>, nodes_2: RN<T3>): RN<[T1_2, T2_1, T3]>;
|
|
70
|
-
<T1_3, T2_2, T3_1, T4>(nodes_0: RN<T1_3>, nodes_1: RN<T2_2>, nodes_2: RN<T3_1>, nodes_3: RN<T4>): RN<[T1_3, T2_2, T3_1, T4]>;
|
|
71
|
-
<T1_4, T2_3, T3_2, T4_1, T5>(nodes_0: RN<T1_4>, nodes_1: RN<T2_3>, nodes_2: RN<T3_2>, nodes_3: RN<T4_1>, nodes_4: RN<T5>): RN<[T1_4, T2_3, T3_2, T4_1, T5]>;
|
|
72
|
-
<T1_5, T2_4, T3_3, T4_2, T5_1, T6>(nodes_0: RN<T1_5>, nodes_1: RN<T2_4>, nodes_2: RN<T3_3>, nodes_3: RN<T4_2>, nodes_4: RN<T5_1>, nodes_5: RN<T6>): RN<[T1_5, T2_4, T3_3, T4_2, T5_1, T6]>;
|
|
73
|
-
<T1_6, T2_5, T3_4, T4_3, T5_2, T6_1, T7>(nodes_0: RN<T1_6>, nodes_1: RN<T2_5>, nodes_2: RN<T3_4>, nodes_3: RN<T4_3>, nodes_4: RN<T5_2>, nodes_5: RN<T6_1>, nodes_6: RN<T7>): RN<[T1_6, T2_5, T3_4, T4_3, T5_2, T6_1, T7]>;
|
|
74
|
-
<T1_7, T2_6, T3_5, T4_4, T5_3, T6_2, T7_1, T8>(nodes_0: RN<T1_7>, nodes_1: RN<T2_6>, nodes_2: RN<T3_5>, nodes_3: RN<T4_4>, nodes_4: RN<T5_3>, nodes_5: RN<T6_2>, nodes_6: RN<T7_1>, nodes_7: RN<T8>): RN<[T1_7, T2_6, T3_5, T4_4, T5_3, T6_2, T7_1, T8]>;
|
|
75
|
-
<T1_8, T2_7, T3_6, T4_5, T5_4, T6_3, T7_2, T8_1, T9>(nodes_0: RN<T1_8>, nodes_1: RN<T2_7>, nodes_2: RN<T3_6>, nodes_3: RN<T4_5>, nodes_4: RN<T5_4>, nodes_5: RN<T6_3>, nodes_6: RN<T7_2>, nodes_7: RN<T8_1>, nodes_8: RN<T9>): RN<[T1_8, T2_7, T3_6, T4_5, T5_4, T6_3, T7_2, T8_1, T9]>;
|
|
76
|
-
<T1_9, T2_8, T3_7, T4_6, T5_5, T6_4, T7_3, T8_2, T9_1, T10>(nodes_0: RN<T1_9>, nodes_1: RN<T2_8>, nodes_2: RN<T3_7>, nodes_3: RN<T4_6>, nodes_4: RN<T5_5>, nodes_5: RN<T6_4>, nodes_6: RN<T7_3>, nodes_7: RN<T8_2>, nodes_8: RN<T9_1>, nodes_9: RN<T10>): RN<[T1_9, T2_8, T3_7, T4_6, T5_5, T6_4, T7_3, T8_2, T9_1, T10]>;
|
|
77
|
-
<T1_10, T2_9, T3_8, T4_7, T5_6, T6_5, T7_4, T8_3, T9_2, T10_1, T11>(nodes_0: RN<T1_10>, nodes_1: RN<T2_9>, nodes_2: RN<T3_8>, nodes_3: RN<T4_7>, nodes_4: RN<T5_6>, nodes_5: RN<T6_5>, nodes_6: RN<T7_4>, nodes_7: RN<T8_3>, nodes_8: RN<T9_2>, nodes_9: RN<T10_1>, nodes_10: RN<T11>): RN<[T1_10, T2_9, T3_8, T4_7, T5_6, T6_5, T7_4, T8_3, T9_2, T10_1, T11]>;
|
|
78
|
-
<T1_11, T2_10, T3_9, T4_8, T5_7, T6_6, T7_5, T8_4, T9_3, T10_2, T11_1, T12, T13>(nodes_0: RN<T1_11>, nodes_1: RN<T2_10>, nodes_2: RN<T3_9>, nodes_3: RN<T4_8>, nodes_4: RN<T5_7>, nodes_5: RN<T6_6>, nodes_6: RN<T7_5>, nodes_7: RN<T8_4>, nodes_8: RN<T9_3>, nodes_9: RN<T10_2>, nodes_10: RN<T11_1>, nodes_11: RN<T12>, nodes_12: RN<T13>): RN<[T1_11, T2_10, T3_9, T4_8, T5_7, T6_6, T7_5, T8_4, T9_3, T10_2, T11_1, T12, T13]>;
|
|
79
|
-
<T1_12, T2_11, T3_10, T4_9, T5_8, T6_7, T7_6, T8_5, T9_4, T10_3, T11_2, T12_1, T13_1, T14>(nodes_0: RN<T1_12>, nodes_1: RN<T2_11>, nodes_2: RN<T3_10>, nodes_3: RN<T4_9>, nodes_4: RN<T5_8>, nodes_5: RN<T6_7>, nodes_6: RN<T7_6>, nodes_7: RN<T8_5>, nodes_8: RN<T9_4>, nodes_9: RN<T10_3>, nodes_10: RN<T11_2>, nodes_11: RN<T12_1>, nodes_12: RN<T13_1>, nodes_13: RN<T14>): RN<[T1_12, T2_11, T3_10, T4_9, T5_8, T6_7, T7_6, T8_5, T9_4, T10_3, T11_2, T12_1, T13_1, T14]>;
|
|
80
|
-
<T1_13, T2_12, T3_11, T4_10, T5_9, T6_8, T7_7, T8_6, T9_5, T10_4, T11_3, T12_2, T13_2, T14_1, T15>(nodes_0: RN<T1_13>, nodes_1: RN<T2_12>, nodes_2: RN<T3_11>, nodes_3: RN<T4_10>, nodes_4: RN<T5_9>, nodes_5: RN<T6_8>, nodes_6: RN<T7_7>, nodes_7: RN<T8_6>, nodes_8: RN<T9_5>, nodes_9: RN<T10_4>, nodes_10: RN<T11_3>, nodes_11: RN<T12_2>, nodes_12: RN<T13_2>, nodes_13: RN<T14_1>, nodes_14: RN<T15>): RN<[T1_13, T2_12, T3_11, T4_10, T5_9, T6_8, T7_7, T8_6, T9_5, T10_4, T11_3, T12_2, T13_2, T14_1, T15]>;
|
|
81
|
-
<T1_14, T2_13, T3_12, T4_11, T5_10, T6_9, T7_8, T8_7, T9_6, T10_5, T11_4, T12_3, T13_3, T14_2, T15_1, T16>(nodes_0: RN<T1_14>, nodes_1: RN<T2_13>, nodes_2: RN<T3_12>, nodes_3: RN<T4_11>, nodes_4: RN<T5_10>, nodes_5: RN<T6_9>, nodes_6: RN<T7_8>, nodes_7: RN<T8_7>, nodes_8: RN<T9_6>, nodes_9: RN<T10_5>, nodes_10: RN<T11_4>, nodes_11: RN<T12_3>, nodes_12: RN<T13_3>, nodes_13: RN<T14_2>, nodes_14: RN<T15_1>, nodes_15: RN<T16>): RN<[T1_14, T2_13, T3_12, T4_11, T5_10, T6_9, T7_8, T8_7, T9_6, T10_5, T11_4, T12_3, T13_3, T14_2, T15_1, T16]>;
|
|
82
|
-
};
|
|
83
|
-
connect: <T extends unknown[] = unknown[]>({ sources, pulls, map, sink: { key: sink } }: RealmProjectionSpec<T>) => void;
|
|
84
|
-
derive: <T_1>(source: RealmNode<T_1>, initial: T_1) => RealmNode<T_1>;
|
|
85
|
-
getKeyValue: (key: string) => unknown;
|
|
86
|
-
getValue: <T_2>(node: RN<T_2>) => T_2;
|
|
87
|
-
getKeyValues: (keys: string[]) => unknown[];
|
|
88
|
-
label: (newLabels: Record<string, RealmNode<unknown>>) => void;
|
|
89
|
-
labels: Record<string, RealmNode<unknown>>;
|
|
90
|
-
link: <T_3>(source: RealmNode<T_3>, sink: RealmNode<T_3>) => void;
|
|
91
|
-
node: <T_4>(value?: symbol | T_4, distinct?: boolean | Comparator<T_4>) => RealmNode<T_4>;
|
|
92
|
-
o: {
|
|
93
|
-
delayWithMicrotask: <I>() => (source: RealmNode<I>) => RealmNode<I>;
|
|
94
|
-
debounceTime: <I_1>(delay: number) => (source: RealmNode<I_1>) => RealmNode<I_1>;
|
|
95
|
-
filter: <I_2, O_1 = I_2>(predicate: (value: I_2) => boolean) => (source: RealmNode<I_2>) => RealmNode<O_1>;
|
|
96
|
-
map: <I_3, O_2>(mapFunction: (value: I_3) => O_2) => (source: RealmNode<I_3>) => RealmNode<O_2>;
|
|
97
|
-
mapTo: <I_4, O_3>(value: O_3) => (source: RealmNode<I_4>) => RealmNode<O_3>;
|
|
98
|
-
onNext: <I_5, O_4>(bufNode: RN<O_4>) => (source: RealmNode<I_5>) => RealmNode<[I_5, O_4]>;
|
|
99
|
-
scan: <I_6, O_5>(accumulator: (current: O_5, value: I_6) => O_5, seed: O_5) => (source: RealmNode<I_6>) => RealmNode<O_5>;
|
|
100
|
-
throttleTime: <I_7>(delay: number) => (source: RealmNode<I_7>) => RealmNode<I_7>;
|
|
101
|
-
withLatestFrom: {
|
|
102
|
-
<I_8, T1_15>(nodes_0: RN<T1_15>): (source: RN<I_8>) => RN<[I_8, T1_15]>;
|
|
103
|
-
<I_9, T1_16, T2_14>(nodes_0: RN<T1_16>, nodes_1: RN<T2_14>): (source: RN<I_9>) => RN<[I_9, T1_16, T2_14]>;
|
|
104
|
-
<I_10, T1_17, T2_15, T3_13>(nodes_0: RN<T1_17>, nodes_1: RN<T2_15>, nodes_2: RN<T3_13>): (source: RN<I_10>) => RN<[I_10, T1_17, T2_15, T3_13]>;
|
|
105
|
-
<I_11, T1_18, T2_16, T3_14, T4_12>(nodes_0: RN<T1_18>, nodes_1: RN<T2_16>, nodes_2: RN<T3_14>, nodes_3: RN<T4_12>): (source: RN<I_11>) => RN<[I_11, T1_18, T2_16, T3_14, T4_12]>;
|
|
106
|
-
<I_12, T1_19, T2_17, T3_15, T4_13, T5_11>(nodes_0: RN<T1_19>, nodes_1: RN<T2_17>, nodes_2: RN<T3_15>, nodes_3: RN<T4_13>, nodes_4: RN<T5_11>): (source: RN<I_12>) => RN<[I_12, T1_19, T2_17, T3_15, T4_13, T5_11]>;
|
|
107
|
-
<I_13, T1_20, T2_18, T3_16, T4_14, T5_12, T6_10>(nodes_0: RN<T1_20>, nodes_1: RN<T2_18>, nodes_2: RN<T3_16>, nodes_3: RN<T4_14>, nodes_4: RN<T5_12>, nodes_5: RN<T6_10>): (source: RN<I_13>) => RN<[I_13, T1_20, T2_18, T3_16, T4_14, T5_12, T6_10]>;
|
|
108
|
-
<I_14, T1_21, T2_19, T3_17, T4_15, T5_13, T6_11, T7_9>(nodes_0: RN<T1_21>, nodes_1: RN<T2_19>, nodes_2: RN<T3_17>, nodes_3: RN<T4_15>, nodes_4: RN<T5_13>, nodes_5: RN<T6_11>, nodes_6: RN<T7_9>): (source: RN<I_14>) => RN<[I_14, T1_21, T2_19, T3_17, T4_15, T5_13, T6_11, T7_9]>;
|
|
109
|
-
<I_15, T1_22, T2_20, T3_18, T4_16, T5_14, T6_12, T7_10, T8_8>(nodes_0: RN<T1_22>, nodes_1: RN<T2_20>, nodes_2: RN<T3_18>, nodes_3: RN<T4_16>, nodes_4: RN<T5_14>, nodes_5: RN<T6_12>, nodes_6: RN<T7_10>, nodes_7: RN<T8_8>): (source: RN<I_15>) => RN<[I_15, T1_22, T2_20, T3_18, T4_16, T5_14, T6_12, T7_10, T8_8]>;
|
|
110
|
-
};
|
|
111
|
-
once: <I_16>() => (source: RealmNode<I_16>) => RealmNode<I_16>;
|
|
112
|
-
passOnlyAfterNodeHasEmittedBefore: <I_17>(starterNode: RN<unknown>, durationNode: RN<number>) => (source: RealmNode<I_17>) => RealmNode<I_17>;
|
|
113
|
-
};
|
|
114
|
-
pipe: {
|
|
115
|
-
<T_5>(s: RealmNode<T_5>): RealmNode<T_5>;
|
|
116
|
-
<T_6, O1>(s: RealmNode<T_6>, o1: (source: RealmNode<T_6>) => RealmNode<O1>): RealmNode<O1>;
|
|
117
|
-
<T_7, O1_1, O2>(s: RealmNode<T_7>, o_0: (source: RealmNode<T_7>) => RealmNode<O1_1>, o_1: (source: RealmNode<O1_1>) => RealmNode<O2>): RealmNode<O2>;
|
|
118
|
-
<T_8, O1_2, O2_1, O3>(s: RealmNode<T_8>, o_0: (source: RealmNode<T_8>) => RealmNode<O1_2>, o_1: (source: RealmNode<O1_2>) => RealmNode<O2_1>, o_2: (source: RealmNode<O2_1>) => RealmNode<O3>): RealmNode<O3>;
|
|
119
|
-
<T_9, O1_3, O2_2, O3_1, O4>(s: RealmNode<T_9>, o_0: (source: RealmNode<T_9>) => RealmNode<O1_3>, o_1: (source: RealmNode<O1_3>) => RealmNode<O2_2>, o_2: (source: RealmNode<O2_2>) => RealmNode<O3_1>, o_3: (source: RealmNode<O3_1>) => RealmNode<O4>): RealmNode<O4>;
|
|
120
|
-
<T_10, O1_4, O2_3, O3_2, O4_1, O5>(s: RealmNode<T_10>, o_0: (source: RealmNode<T_10>) => RealmNode<O1_4>, o_1: (source: RealmNode<O1_4>) => RealmNode<O2_3>, o_2: (source: RealmNode<O2_3>) => RealmNode<O3_2>, o_3: (source: RealmNode<O3_2>) => RealmNode<O4_1>, o_4: (source: RealmNode<O4_1>) => RealmNode<O5>): RealmNode<O5>;
|
|
121
|
-
<T_11, O1_5, O2_4, O3_3, O4_2, O5_1, O6>(s: RealmNode<T_11>, o_0: (source: RealmNode<T_11>) => RealmNode<O1_5>, o_1: (source: RealmNode<O1_5>) => RealmNode<O2_4>, o_2: (source: RealmNode<O2_4>) => RealmNode<O3_3>, o_3: (source: RealmNode<O3_3>) => RealmNode<O4_2>, o_4: (source: RealmNode<O4_2>) => RealmNode<O5_1>, o_5: (source: RealmNode<O5_1>) => RealmNode<O6>): RealmNode<O6>;
|
|
122
|
-
<T_12, O1_6, O2_5, O3_4, O4_3, O5_2, O6_1, O7>(s: RealmNode<T_12>, o_0: (source: RealmNode<T_12>) => RealmNode<O1_6>, o_1: (source: RealmNode<O1_6>) => RealmNode<O2_5>, o_2: (source: RealmNode<O2_5>) => RealmNode<O3_4>, o_3: (source: RealmNode<O3_4>) => RealmNode<O4_3>, o_4: (source: RealmNode<O4_3>) => RealmNode<O5_2>, o_5: (source: RealmNode<O5_2>) => RealmNode<O6_1>, o_6: (source: RealmNode<O6_1>) => RealmNode<O7>): RealmNode<O7>;
|
|
123
|
-
};
|
|
124
|
-
pub: {
|
|
125
|
-
<T1_23>(args_0: RN<T1_23>, args_1: T1_23): void;
|
|
126
|
-
<T1_24, T2_21>(args_0: RN<T1_24>, args_1: T1_24, args_2: RN<T2_21>, args_3: T2_21): void;
|
|
127
|
-
<T1_25, T2_22, T3_19>(args_0: RN<T1_25>, args_1: T1_25, args_2: RN<T2_22>, args_3: T2_22, args_4: RN<T3_19>, args_5: T3_19): void;
|
|
128
|
-
<T1_26, T2_23, T3_20, T4_17>(args_0: RN<T1_26>, args_1: T1_26, args_2: RN<T2_23>, args_3: T2_23, args_4: RN<T3_20>, args_5: T3_20, args_6: T4_17): void;
|
|
129
|
-
};
|
|
130
|
-
pubIn: (values: Record<NodeKey, unknown>) => void;
|
|
131
|
-
pubKey: (key: string, value: unknown) => void;
|
|
132
|
-
pubKeys: (values: Record<string, unknown>) => void;
|
|
133
|
-
resetSingletonSubs: () => void;
|
|
134
|
-
singletonSub: <T_13>({ key }: RealmNode<T_13>, subscription: Subscription<T_13> | undefined) => UnsubscribeHandle;
|
|
135
|
-
singletonSubKey: <T_14>(key: string, subscription: Subscription<T_14> | undefined) => UnsubscribeHandle;
|
|
136
|
-
spread: <T_15 extends LongTuple<unknown>>(source: RealmNode<T_15>, initialValues: T_15) => NodesFromValues<T_15>;
|
|
137
|
-
sub: {
|
|
138
|
-
<T1_27>(args_0: RN<T1_27>, args_1: Subscription<T1_27>): UnsubscribeHandle;
|
|
139
|
-
<T1_28, T2_24>(args_0: RN<T1_28>, args_1: RN<T2_24>, args_2: Subscription<[T1_28, T2_24]>): UnsubscribeHandle;
|
|
140
|
-
<T1_29, T2_25, T3_21>(args_0: RN<T1_29>, args_1: RN<T2_25>, args_2: RN<T3_21>, args_3: Subscription<[T1_29, T2_25, T3_21]>): UnsubscribeHandle;
|
|
141
|
-
};
|
|
142
|
-
subKey: (key: string, subscription: Subscription<unknown>) => UnsubscribeHandle;
|
|
143
|
-
subKeys: (keys: string[], subscription: Subscription<unknown>) => UnsubscribeHandle;
|
|
144
|
-
};
|
|
145
|
-
/** @internal */
|
|
146
|
-
export interface Realm extends ReturnType<typeof realm> {
|
|
147
|
-
}
|
|
148
|
-
export {};
|