@mdxeditor/editor 0.10.1 → 0.11.1-alpha.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/README.md +4 -3
- package/dist/FormatConstants.d.ts +9 -0
- package/dist/FormatConstants.js +10 -0
- package/dist/MDXEditor.d.ts +60 -0
- package/dist/MDXEditor.js +105 -0
- package/dist/directive-editors/AdmonitionDirectiveDescriptor.d.ts +17 -0
- package/dist/directive-editors/AdmonitionDirectiveDescriptor.js +29 -0
- package/dist/directive-editors/GenericDirectiveEditor.d.ts +8 -0
- package/dist/directive-editors/GenericDirectiveEditor.js +32 -0
- package/dist/exportMarkdownFromLexical.d.ts +114 -0
- package/dist/exportMarkdownFromLexical.js +199 -0
- package/dist/gurx/index.d.ts +3 -0
- package/dist/gurx/react.d.ts +121 -0
- package/dist/gurx/react.js +198 -0
- package/dist/gurx/realm.d.ts +133 -0
- package/dist/gurx/realm.js +491 -0
- package/dist/gurx/realmFactory.d.ts +58 -0
- package/dist/gurx/realmFactory.js +32 -0
- package/dist/icons/add_column.svg.js +8 -0
- package/dist/icons/add_photo.svg.js +8 -0
- package/dist/icons/add_row.svg.js +8 -0
- package/dist/icons/arrow_drop_down.svg.js +8 -0
- package/dist/icons/arrow_right.svg.js +8 -0
- package/dist/icons/check.svg.js +8 -0
- package/dist/icons/close.svg.js +8 -0
- package/dist/icons/code.svg.js +8 -0
- package/dist/icons/content_copy.svg.js +8 -0
- package/dist/icons/delete.svg.js +8 -0
- package/dist/icons/delete_small.svg.js +8 -0
- package/dist/icons/deployed_code.svg.js +8 -0
- package/dist/icons/difference.svg.js +8 -0
- package/dist/icons/edit.svg.js +8 -0
- package/dist/icons/emergency_home.svg.js +8 -0
- package/dist/icons/format_align_center.svg.js +8 -0
- package/dist/icons/format_align_left.svg.js +8 -0
- package/dist/icons/format_align_right.svg.js +8 -0
- package/dist/icons/format_bold.svg.js +8 -0
- package/dist/icons/format_italic.svg.js +8 -0
- package/dist/icons/format_list_bulleted.svg.js +8 -0
- package/dist/icons/format_list_numbered.svg.js +8 -0
- package/dist/icons/format_underlined.svg.js +8 -0
- package/dist/icons/frame_source.svg.js +8 -0
- package/dist/icons/frontmatter.svg.js +8 -0
- package/dist/icons/horizontal_rule.svg.js +8 -0
- package/dist/icons/insert_col_left.svg.js +8 -0
- package/dist/icons/insert_col_right.svg.js +8 -0
- package/dist/icons/insert_row_above.svg.js +8 -0
- package/dist/icons/insert_row_below.svg.js +8 -0
- package/dist/icons/link.svg.js +8 -0
- package/dist/icons/link_off.svg.js +8 -0
- package/dist/icons/markdown.svg.js +8 -0
- package/dist/icons/more_horiz.svg.js +8 -0
- package/dist/icons/open_in_new.svg.js +8 -0
- package/dist/icons/redo.svg.js +8 -0
- package/dist/icons/rich_text.svg.js +8 -0
- package/dist/icons/settings.svg.js +8 -0
- package/dist/icons/table.svg.js +8 -0
- package/dist/icons/undo.svg.js +8 -0
- package/dist/importMarkdownToLexical.d.ts +84 -0
- package/dist/importMarkdownToLexical.js +65 -0
- package/dist/index.d.ts +53 -1105
- package/dist/index.js +170 -72
- package/dist/jsx-editors/GenericJsxEditor.d.ts +8 -0
- package/dist/jsx-editors/GenericJsxEditor.js +56 -0
- package/dist/node_modules/react-diff-view/style/index.css.js +4 -0
- package/dist/plugins/codeblock/CodeBlockNode.d.ts +99 -0
- package/dist/plugins/codeblock/CodeBlockNode.js +155 -0
- package/dist/plugins/codeblock/CodeBlockVisitor.d.ts +4 -0
- package/dist/plugins/codeblock/CodeBlockVisitor.js +14 -0
- package/dist/plugins/codeblock/MdastCodeVisitor.d.ts +3 -0
- package/dist/plugins/codeblock/MdastCodeVisitor.js +16 -0
- package/dist/plugins/codeblock/index.d.ts +616 -0
- package/dist/plugins/codeblock/index.js +73 -0
- package/dist/plugins/codemirror/CodeMirrorEditor.d.ts +3 -0
- package/dist/plugins/codemirror/CodeMirrorEditor.js +33 -0
- package/dist/plugins/codemirror/index.d.ts +799 -0
- package/dist/plugins/codemirror/index.js +62 -0
- package/dist/plugins/core/LexicalLinebreakVisitor.d.ts +4 -0
- package/dist/plugins/core/LexicalLinebreakVisitor.js +10 -0
- package/dist/plugins/core/LexicalParagraphVisitor.d.ts +4 -0
- package/dist/plugins/core/LexicalParagraphVisitor.js +10 -0
- package/dist/plugins/core/LexicalRootVisitor.d.ts +4 -0
- package/dist/plugins/core/LexicalRootVisitor.js +10 -0
- package/dist/plugins/core/LexicalTextVisitor.d.ts +5 -0
- package/dist/plugins/core/LexicalTextVisitor.js +85 -0
- package/dist/plugins/core/MdastFormattingVisitor.d.ts +4 -0
- package/dist/plugins/core/MdastFormattingVisitor.js +36 -0
- package/dist/plugins/core/MdastInlineCodeVisitor.d.ts +3 -0
- package/dist/plugins/core/MdastInlineCodeVisitor.js +11 -0
- package/dist/plugins/core/MdastParagraphVisitor.d.ts +3 -0
- package/dist/plugins/core/MdastParagraphVisitor.js +15 -0
- package/dist/plugins/core/MdastRootVisitor.d.ts +3 -0
- package/dist/plugins/core/MdastRootVisitor.js +9 -0
- package/dist/plugins/core/MdastTextVisitor.d.ts +3 -0
- package/dist/plugins/core/MdastTextVisitor.js +10 -0
- package/dist/plugins/core/NestedLexicalEditor.d.ts +96 -0
- package/dist/plugins/core/NestedLexicalEditor.js +181 -0
- package/dist/plugins/core/PropertyPopover.d.ts +23 -0
- package/dist/plugins/core/PropertyPopover.js +36 -0
- package/dist/plugins/core/SharedHistoryPlugin.d.ts +2 -0
- package/dist/plugins/core/SharedHistoryPlugin.js +10 -0
- package/dist/plugins/core/index.d.ts +423 -0
- package/dist/plugins/core/index.js +346 -0
- package/dist/plugins/core/ui/PopoverUtils.d.ts +4 -0
- package/dist/plugins/core/ui/PopoverUtils.js +17 -0
- package/dist/plugins/diff-source/DiffSourceWrapper.d.ts +4 -0
- package/dist/plugins/diff-source/DiffSourceWrapper.js +11 -0
- package/dist/plugins/diff-source/DiffViewer.d.ts +2 -0
- package/dist/plugins/diff-source/DiffViewer.js +18 -0
- package/dist/plugins/diff-source/SourceEditor.d.ts +2 -0
- package/dist/plugins/diff-source/SourceEditor.js +27 -0
- package/dist/plugins/diff-source/index.d.ts +543 -0
- package/dist/plugins/diff-source/index.js +55 -0
- package/dist/plugins/directives/DirectiveNode.d.ts +51 -0
- package/dist/plugins/directives/DirectiveNode.js +92 -0
- package/dist/plugins/directives/DirectiveVisitor.d.ts +4 -0
- package/dist/plugins/directives/DirectiveVisitor.js +10 -0
- package/dist/plugins/directives/MdastDirectiveVisitor.d.ts +3 -0
- package/dist/plugins/directives/MdastDirectiveVisitor.js +13 -0
- package/dist/plugins/directives/index.d.ts +602 -0
- package/dist/plugins/directives/index.js +53 -0
- package/dist/plugins/frontmatter/FrontmatterEditor.d.ts +6 -0
- package/dist/plugins/frontmatter/FrontmatterEditor.js +69 -0
- package/dist/plugins/frontmatter/FrontmatterNode.d.ts +35 -0
- package/dist/plugins/frontmatter/FrontmatterNode.js +71 -0
- package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.d.ts +4 -0
- package/dist/plugins/frontmatter/LexicalFrontmatterVisitor.js +10 -0
- package/dist/plugins/frontmatter/MdastFrontmatterVisitor.d.ts +3 -0
- package/dist/plugins/frontmatter/MdastFrontmatterVisitor.js +10 -0
- package/dist/plugins/frontmatter/index.d.ts +522 -0
- package/dist/plugins/frontmatter/index.js +53 -0
- package/dist/plugins/headings/LexicalHeadingVisitor.d.ts +4 -0
- package/dist/plugins/headings/LexicalHeadingVisitor.js +11 -0
- package/dist/plugins/headings/MdastHeadingVisitor.d.ts +3 -0
- package/dist/plugins/headings/MdastHeadingVisitor.js +10 -0
- package/dist/plugins/headings/index.d.ts +117 -0
- package/dist/plugins/headings/index.js +20 -0
- package/dist/plugins/image/ImageEditor.d.ts +9 -0
- package/dist/{ImageEditor-8db2f131.js → plugins/image/ImageEditor.js} +40 -52
- package/dist/plugins/image/ImageNode.d.ts +63 -0
- package/dist/plugins/image/ImageNode.js +136 -0
- package/dist/plugins/image/ImageResizer.d.ts +18 -0
- package/dist/plugins/image/ImageResizer.js +214 -0
- package/dist/plugins/image/LexicalImageVisitor.d.ts +4 -0
- package/dist/plugins/image/LexicalImageVisitor.js +36 -0
- package/dist/plugins/image/MdastImageVisitor.d.ts +6 -0
- package/dist/plugins/image/MdastImageVisitor.js +87 -0
- package/dist/plugins/image/index.d.ts +556 -0
- package/dist/plugins/image/index.js +249 -0
- package/dist/plugins/jsx/LexicalJsxNode.d.ts +54 -0
- package/dist/plugins/jsx/LexicalJsxNode.js +102 -0
- package/dist/plugins/jsx/LexicalJsxVisitor.d.ts +4 -0
- package/dist/plugins/jsx/LexicalJsxVisitor.js +12 -0
- package/dist/plugins/jsx/MdastMdxJsEsmVisitor.d.ts +3 -0
- package/dist/plugins/jsx/MdastMdxJsEsmVisitor.js +8 -0
- package/dist/plugins/jsx/MdastMdxJsxElementVisitor.d.ts +3 -0
- package/dist/plugins/jsx/MdastMdxJsxElementVisitor.js +12 -0
- package/dist/plugins/jsx/index.d.ts +598 -0
- package/dist/plugins/jsx/index.js +59 -0
- package/dist/plugins/link/LexicalLinkVisitor.d.ts +4 -0
- package/dist/plugins/link/LexicalLinkVisitor.js +10 -0
- package/dist/plugins/link/MdastLinkVisitor.d.ts +3 -0
- package/dist/plugins/link/MdastLinkVisitor.js +14 -0
- package/dist/plugins/link/index.d.ts +67 -0
- package/dist/plugins/link/index.js +22 -0
- package/dist/plugins/link-dialog/LinkDialog.d.ts +12 -0
- package/dist/plugins/link-dialog/LinkDialog.js +174 -0
- package/dist/plugins/link-dialog/index.d.ts +507 -0
- package/dist/plugins/link-dialog/index.js +242 -0
- package/dist/plugins/lists/LexicalListItemVisitor.d.ts +4 -0
- package/dist/plugins/lists/LexicalListItemVisitor.js +22 -0
- package/dist/plugins/lists/LexicalListVisitor.d.ts +4 -0
- package/dist/plugins/lists/LexicalListVisitor.js +13 -0
- package/dist/plugins/lists/MdastListItemVisitor.d.ts +3 -0
- package/dist/plugins/lists/MdastListItemVisitor.js +10 -0
- package/dist/plugins/lists/MdastListVisitor.d.ts +3 -0
- package/dist/plugins/lists/MdastListVisitor.js +18 -0
- package/dist/plugins/lists/index.d.ts +532 -0
- package/dist/plugins/lists/index.js +111 -0
- package/dist/plugins/markdown-shortcut/index.d.ts +62 -0
- package/dist/plugins/markdown-shortcut/index.js +34 -0
- package/dist/plugins/quote/LexicalQuoteVisitor.d.ts +4 -0
- package/dist/plugins/quote/LexicalQuoteVisitor.js +12 -0
- package/dist/plugins/quote/MdastBlockQuoteVisitor.d.ts +3 -0
- package/dist/plugins/quote/MdastBlockQuoteVisitor.js +10 -0
- package/dist/plugins/quote/index.d.ts +360 -0
- package/dist/plugins/quote/index.js +26 -0
- package/dist/plugins/sandpack/SandpackEditor.d.ts +7 -0
- package/dist/plugins/sandpack/SandpackEditor.js +35 -0
- package/dist/plugins/sandpack/index.d.ts +838 -0
- package/dist/plugins/sandpack/index.js +93 -0
- package/dist/plugins/sandpack/useCodeMirrorRef.d.ts +4 -0
- package/dist/{useCodeMirrorRef-5356dfa5.js → plugins/sandpack/useCodeMirrorRef.js} +22 -10
- package/dist/plugins/table/LexicalTableVisitor.d.ts +4 -0
- package/dist/plugins/table/LexicalTableVisitor.js +10 -0
- package/dist/plugins/table/MdastTableVisitor.d.ts +3 -0
- package/dist/plugins/table/MdastTableVisitor.js +10 -0
- package/dist/plugins/table/TableEditor.d.ts +21 -0
- package/dist/plugins/table/TableEditor.js +384 -0
- package/dist/plugins/table/TableNode.d.ts +52 -0
- package/dist/plugins/table/TableNode.js +147 -0
- package/dist/plugins/table/index.d.ts +522 -0
- package/dist/plugins/table/index.js +59 -0
- package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.d.ts +4 -0
- package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.js +10 -0
- package/dist/plugins/thematic-break/MdastThematicBreakVisitor.d.ts +3 -0
- package/dist/plugins/thematic-break/MdastThematicBreakVisitor.js +10 -0
- package/dist/plugins/thematic-break/index.d.ts +522 -0
- package/dist/plugins/thematic-break/index.js +39 -0
- package/dist/plugins/toolbar/components/BlockTypeSelect.d.ts +6 -0
- package/dist/plugins/toolbar/components/BlockTypeSelect.js +52 -0
- package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.d.ts +5 -0
- package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.js +35 -0
- package/dist/plugins/toolbar/components/ChangeAdmonitionType.d.ts +6 -0
- package/dist/plugins/toolbar/components/ChangeAdmonitionType.js +30 -0
- package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.d.ts +7 -0
- package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.js +32 -0
- package/dist/plugins/toolbar/components/CodeToggle.d.ts +6 -0
- package/dist/plugins/toolbar/components/CodeToggle.js +20 -0
- package/dist/plugins/toolbar/components/CreateLink.d.ts +6 -0
- package/dist/plugins/toolbar/components/CreateLink.js +11 -0
- package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.d.ts +18 -0
- package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.js +27 -0
- package/dist/plugins/toolbar/components/InsertAdmonition.d.ts +6 -0
- package/dist/plugins/toolbar/components/InsertAdmonition.js +29 -0
- package/dist/plugins/toolbar/components/InsertCodeBlock.d.ts +7 -0
- package/dist/plugins/toolbar/components/InsertCodeBlock.js +20 -0
- package/dist/plugins/toolbar/components/InsertFrontmatter.d.ts +6 -0
- package/dist/plugins/toolbar/components/InsertFrontmatter.js +11 -0
- package/dist/plugins/toolbar/components/InsertImage.d.ts +6 -0
- package/dist/plugins/toolbar/components/InsertImage.js +23 -0
- package/dist/plugins/toolbar/components/InsertSandpack.d.ts +6 -0
- package/dist/plugins/toolbar/components/InsertSandpack.js +13 -0
- package/dist/plugins/toolbar/components/InsertTable.d.ts +6 -0
- package/dist/plugins/toolbar/components/InsertTable.js +20 -0
- package/dist/plugins/toolbar/components/InsertThematicBreak.d.ts +6 -0
- package/dist/plugins/toolbar/components/InsertThematicBreak.js +11 -0
- package/dist/plugins/toolbar/components/KitchenSinkToolbar.d.ts +7 -0
- package/dist/plugins/toolbar/components/KitchenSinkToolbar.js +58 -0
- package/dist/plugins/toolbar/components/ListsToggle.d.ts +7 -0
- package/dist/plugins/toolbar/components/ListsToggle.js +23 -0
- package/dist/plugins/toolbar/components/ShowSandpackInfo.d.ts +7 -0
- package/dist/plugins/toolbar/components/ShowSandpackInfo.js +32 -0
- package/dist/plugins/toolbar/components/UndoRedo.d.ts +5 -0
- package/dist/plugins/toolbar/components/UndoRedo.js +59 -0
- package/dist/plugins/toolbar/index.d.ts +427 -0
- package/dist/plugins/toolbar/index.js +39 -0
- package/dist/plugins/toolbar/primitives/DialogButton.d.ts +40 -0
- package/dist/plugins/toolbar/primitives/DialogButton.js +115 -0
- package/dist/plugins/toolbar/primitives/TooltipWrap.d.ts +8 -0
- package/dist/plugins/toolbar/primitives/TooltipWrap.js +12 -0
- package/dist/plugins/toolbar/primitives/select.d.ts +50 -0
- package/dist/plugins/toolbar/primitives/select.js +44 -0
- package/dist/plugins/toolbar/primitives/toolbar.d.ts +160 -0
- package/dist/plugins/toolbar/primitives/toolbar.js +111 -0
- package/dist/style.css +556 -249
- package/dist/styles/globals.css.js +4 -0
- package/dist/styles/lexical-theme.module.css.js +53 -0
- package/dist/styles/lexicalTheme.d.ts +2 -0
- package/dist/styles/lexicalTheme.js +28 -0
- package/dist/styles/ui.module.css.js +254 -0
- package/dist/utils/detectMac.d.ts +2 -0
- package/dist/utils/detectMac.js +6 -0
- package/dist/utils/fp.d.ts +47 -0
- package/dist/utils/fp.js +14 -0
- package/dist/utils/isPartOftheEditorUI.d.ts +1 -0
- package/dist/utils/isPartOftheEditorUI.js +12 -0
- package/dist/utils/lexicalHelpers.d.ts +11 -0
- package/dist/utils/lexicalHelpers.js +49 -0
- package/dist/utils/uuid4.d.ts +1 -0
- package/dist/utils/uuid4.js +10 -0
- package/dist/utils/voidEmitter.d.ts +14 -0
- package/dist/utils/voidEmitter.js +15 -0
- package/package.json +261 -14
- package/dist/CodeBlockEditor-02116cba.js +0 -79
- package/dist/CodeBlockEditor-1c7b46dc.cjs +0 -1
- package/dist/FrontmatterEditor-37a4c091.cjs +0 -1
- package/dist/FrontmatterEditor-988a8fb6.js +0 -118
- package/dist/ImageEditor-524159e9.cjs +0 -1
- package/dist/JsxEditor-606e9d86.js +0 -108
- package/dist/JsxEditor-98a94a9d.cjs +0 -1
- package/dist/LeafDirectiveEditor-38a73f5c.js +0 -59
- package/dist/LeafDirectiveEditor-dfa1ce78.cjs +0 -1
- package/dist/SandpackEditor-90425f26.cjs +0 -1
- package/dist/SandpackEditor-c771b4d0.js +0 -100
- package/dist/SourceEditor-19eb2c9e.js +0 -64
- package/dist/SourceEditor-46ed1f77.cjs +0 -1
- package/dist/TableEditor-4a993dab.cjs +0 -1
- package/dist/TableEditor-c28b3ca2.js +0 -426
- package/dist/index-1ab1a12e.js +0 -4363
- package/dist/index-8217810f.cjs +0 -1
- package/dist/index.cjs +0 -1
- package/dist/useCodeMirrorRef-7055e7de.cjs +0 -1
|
@@ -0,0 +1,121 @@
|
|
|
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
|
+
* Used to correctly specify type refs for system components
|
|
46
|
+
*
|
|
47
|
+
* ```tsx
|
|
48
|
+
* const s = system(() => { return { a: statefulStream(0) } })
|
|
49
|
+
* const { Component } = systemToComponent(s)
|
|
50
|
+
*
|
|
51
|
+
* const App = () => {
|
|
52
|
+
* const ref = useRef<RefHandle<typeof Component>>()
|
|
53
|
+
* return <Component ref={ref} />
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @typeParam T the type of the component
|
|
58
|
+
*/
|
|
59
|
+
export type RefHandle<T> = T extends React.ForwardRefExoticComponent<React.RefAttributes<infer Handle>> ? Handle : never;
|
|
60
|
+
/**
|
|
61
|
+
* Converts a system spec to React component by mapping the system streams to component properties, events and methods. Returns hooks for querying and modifying
|
|
62
|
+
* the system streams from the component's child components.
|
|
63
|
+
* @param realmFactory The return value from a [[system]] call.
|
|
64
|
+
* @param map The streams to props / events / methods mapping Check [[SystemPropsMap]] for more details.
|
|
65
|
+
* @param Root The optional React component to render. By default, the resulting component renders nothing, acting as a logical wrapper for its children.
|
|
66
|
+
* @returns an object containing the following:
|
|
67
|
+
* - `Component`: the React component.
|
|
68
|
+
* - `useEmitterValue`: a hook that lets child components use values emitted from the specified output stream.
|
|
69
|
+
* - `useEmitter`: a hook that calls the provided callback whenever the specified stream emits a value.
|
|
70
|
+
* - `usePublisher`: a hook which lets child components publish values to the specified stream.
|
|
71
|
+
* <hr />
|
|
72
|
+
*/
|
|
73
|
+
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): {
|
|
74
|
+
useRealmContext: () => TypedRealm<Sys>;
|
|
75
|
+
useEmitter: <K extends Extract<keyof Sys, string>>(key: K, callback: (value: ValueForKey<Sys, K>) => void) => void;
|
|
76
|
+
useEmitterValues: <K_1 extends SystemKeys<Sys>>(...keys: K_1) => ValuesForKeys<Sys, K_1>;
|
|
77
|
+
usePubKeys: () => (values: SystemDict<Sys>) => void;
|
|
78
|
+
usePublisher: <K_2 extends keyof Sys>(key: K_2) => (value: ValueForKey<Sys, K_2>) => void;
|
|
79
|
+
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 : {
|
|
80
|
+
children?: React.ReactNode;
|
|
81
|
+
})> & React.RefAttributes<MethodsFromPropMap<Sys, M>>>;
|
|
82
|
+
};
|
|
83
|
+
export declare function sysHooks<Sys extends System>(): {
|
|
84
|
+
useRealmContext: () => TypedRealm<Sys>;
|
|
85
|
+
useEmitter: <K extends Extract<keyof Sys, string>>(key: K, callback: (value: ValueForKey<Sys, K>) => void) => void;
|
|
86
|
+
useEmitterValues: <K_1 extends SystemKeys<Sys>>(...keys: K_1) => ValuesForKeys<Sys, K_1>;
|
|
87
|
+
usePubKeys: () => (values: SystemDict<Sys>) => void;
|
|
88
|
+
usePublisher: <K_2 extends keyof Sys>(key: K_2) => (value: ValueForKey<Sys, K_2>) => void;
|
|
89
|
+
};
|
|
90
|
+
type SystemAndDependencies<Spec extends AnySystemSpec> = SystemOfSpecs<[Spec]> & SystemOfSpecs<Spec['dependencies']>;
|
|
91
|
+
export interface RealmPluginParams<Spec extends AnySystemSpec, Params extends object> {
|
|
92
|
+
id: string;
|
|
93
|
+
dependencies?: string[];
|
|
94
|
+
systemSpec: Spec;
|
|
95
|
+
applyParamsToSystem?: (realm: TypedRealm<SystemAndDependencies<Spec>>, props: Params) => void;
|
|
96
|
+
init?: (realm: TypedRealm<SystemAndDependencies<Spec>>, props: Params) => void;
|
|
97
|
+
}
|
|
98
|
+
export interface PluginConstructor<Spec extends AnySystemSpec, Params extends object> {
|
|
99
|
+
(params?: Params): {
|
|
100
|
+
pluginParams?: Params;
|
|
101
|
+
} & RealmPluginParams<Spec, Params>;
|
|
102
|
+
}
|
|
103
|
+
export declare function realmPlugin<Spec extends AnySystemSpec, Params extends object>(params: RealmPluginParams<Spec, Params>): readonly [PluginConstructor<Spec, Params>, {
|
|
104
|
+
useRealmContext: () => TypedRealm<SystemAndDependencies<Spec>>;
|
|
105
|
+
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;
|
|
106
|
+
useEmitterValues: <K_1 extends SystemKeys<SystemAndDependencies<Spec>>>(...keys: K_1) => ValuesForKeys<SystemAndDependencies<Spec>, K_1>;
|
|
107
|
+
usePubKeys: () => (values: SystemDict<SystemAndDependencies<Spec>>) => void;
|
|
108
|
+
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;
|
|
109
|
+
}];
|
|
110
|
+
export declare const RealmPluginInitializer: <P extends ({
|
|
111
|
+
pluginParams?: any;
|
|
112
|
+
} & RealmPluginParams<AnySystemSpec, any>)[]>({ plugins, children }: {
|
|
113
|
+
plugins: P;
|
|
114
|
+
children?: React.ReactNode;
|
|
115
|
+
}) => React.FunctionComponentElement<React.ProviderProps<TypedRealm<any>>>;
|
|
116
|
+
export declare function useHasPlugin(id: string): boolean;
|
|
117
|
+
export declare const RequirePlugin: React.FC<{
|
|
118
|
+
id: string;
|
|
119
|
+
children: React.ReactNode;
|
|
120
|
+
}>;
|
|
121
|
+
export {};
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import React__default 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
|
+
useIsomorphicLayoutEffect(
|
|
102
|
+
() => realm == null ? void 0 : realm.subKeys(keys, (newValues) => {
|
|
103
|
+
const setter = () => {
|
|
104
|
+
setValues(keys.length === 1 ? [newValues] : newValues);
|
|
105
|
+
};
|
|
106
|
+
setter();
|
|
107
|
+
}),
|
|
108
|
+
[keys]
|
|
109
|
+
);
|
|
110
|
+
return values;
|
|
111
|
+
};
|
|
112
|
+
const usePubKeys = () => {
|
|
113
|
+
return React__default.useContext(Context).pubKeys;
|
|
114
|
+
};
|
|
115
|
+
const useEmitter = (key, callback) => {
|
|
116
|
+
const realm = React__default.useContext(Context);
|
|
117
|
+
useIsomorphicLayoutEffect(() => realm.subKey(key, callback), [callback]);
|
|
118
|
+
};
|
|
119
|
+
const useRealmContext = () => {
|
|
120
|
+
return React__default.useContext(Context);
|
|
121
|
+
};
|
|
122
|
+
return {
|
|
123
|
+
useRealmContext,
|
|
124
|
+
useEmitter,
|
|
125
|
+
useEmitterValues,
|
|
126
|
+
usePubKeys,
|
|
127
|
+
usePublisher
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
const UsedPluginsContext = React__default.createContext(/* @__PURE__ */ new Set());
|
|
131
|
+
function realmPlugin(params) {
|
|
132
|
+
const plugin = (pluginParams) => {
|
|
133
|
+
return {
|
|
134
|
+
systemSpec: params.systemSpec,
|
|
135
|
+
pluginParams,
|
|
136
|
+
applyParamsToSystem: params.applyParamsToSystem,
|
|
137
|
+
init: params.init,
|
|
138
|
+
id: params.id,
|
|
139
|
+
dependencies: params.dependencies
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
return [plugin, sysHooks()];
|
|
143
|
+
}
|
|
144
|
+
const RealmPluginInitializer = function({
|
|
145
|
+
plugins,
|
|
146
|
+
children
|
|
147
|
+
}) {
|
|
148
|
+
const validPlugins = React__default.useMemo(() => {
|
|
149
|
+
const availablePlugins = plugins.map((plugin) => plugin.id);
|
|
150
|
+
const validPlugins2 = plugins.filter((plugin) => {
|
|
151
|
+
if (plugin.dependencies) {
|
|
152
|
+
if (plugin.dependencies.some((dep) => !availablePlugins.includes(dep))) {
|
|
153
|
+
console.warn("MDXEditor plugin", plugin.id, "has some missing dependencies", plugin.dependencies, ", skipping");
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return true;
|
|
158
|
+
});
|
|
159
|
+
return validPlugins2;
|
|
160
|
+
}, []);
|
|
161
|
+
const realm = React__default.useMemo(() => {
|
|
162
|
+
const specs = validPlugins.map((plugin) => plugin.systemSpec);
|
|
163
|
+
const realm2 = realmFactory(...specs);
|
|
164
|
+
validPlugins.forEach((plugin) => {
|
|
165
|
+
var _a, _b;
|
|
166
|
+
(_a = plugin.init) == null ? void 0 : _a.call(plugin, realm2, plugin.pluginParams);
|
|
167
|
+
(_b = plugin.applyParamsToSystem) == null ? void 0 : _b.call(plugin, realm2, plugin.pluginParams);
|
|
168
|
+
});
|
|
169
|
+
return realm2;
|
|
170
|
+
}, []);
|
|
171
|
+
React__default.useEffect(() => {
|
|
172
|
+
validPlugins.forEach((plugin) => {
|
|
173
|
+
var _a;
|
|
174
|
+
(_a = plugin.applyParamsToSystem) == null ? void 0 : _a.call(plugin, realm, plugin.pluginParams);
|
|
175
|
+
});
|
|
176
|
+
}, [realm, validPlugins]);
|
|
177
|
+
const Context = GurxContext;
|
|
178
|
+
return React__default.createElement(
|
|
179
|
+
Context.Provider,
|
|
180
|
+
{ value: realm },
|
|
181
|
+
React__default.createElement(UsedPluginsContext.Provider, { value: new Set(plugins.map((plugin) => plugin.id)) }, children)
|
|
182
|
+
);
|
|
183
|
+
};
|
|
184
|
+
function useHasPlugin(id) {
|
|
185
|
+
const usedPlugins = React__default.useContext(UsedPluginsContext);
|
|
186
|
+
return usedPlugins.has(id);
|
|
187
|
+
}
|
|
188
|
+
const RequirePlugin = ({ id, children }) => {
|
|
189
|
+
return useHasPlugin(id) ? React__default.createElement(React__default.Fragment, {}, children) : null;
|
|
190
|
+
};
|
|
191
|
+
export {
|
|
192
|
+
RealmPluginInitializer,
|
|
193
|
+
RequirePlugin,
|
|
194
|
+
realmFactoryToComponent,
|
|
195
|
+
realmPlugin,
|
|
196
|
+
sysHooks,
|
|
197
|
+
useHasPlugin
|
|
198
|
+
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { LongTuple } from './realmFactory';
|
|
2
|
+
export type NodeKey = string;
|
|
3
|
+
export interface RealmNode<T = unknown> {
|
|
4
|
+
key: NodeKey;
|
|
5
|
+
toString(): string;
|
|
6
|
+
}
|
|
7
|
+
/** @internal */
|
|
8
|
+
type RN<T = unknown> = RealmNode<T>;
|
|
9
|
+
export type Subscription<T = any> = (value: T) => unknown;
|
|
10
|
+
export type UnsubscribeHandle = () => void;
|
|
11
|
+
type ProjectionFunc<T extends unknown[] = unknown[]> = (done: (...values: unknown[]) => void) => (...args: T) => void;
|
|
12
|
+
export interface RealmProjection<T extends unknown[] = unknown[]> {
|
|
13
|
+
sources: Set<NodeKey>;
|
|
14
|
+
pulls: Set<NodeKey>;
|
|
15
|
+
sink: NodeKey;
|
|
16
|
+
map: ProjectionFunc<T>;
|
|
17
|
+
}
|
|
18
|
+
export interface RealmProjectionSpec<T extends unknown[] = unknown[]> {
|
|
19
|
+
sources: RealmNode[];
|
|
20
|
+
pulls?: RealmNode[];
|
|
21
|
+
sink: RealmNode;
|
|
22
|
+
map: ProjectionFunc<T>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A function which determines if two values are equal.
|
|
26
|
+
* Implement custom comparators when [[distinctUntilChanged]] needs to work on non-primitive objects.
|
|
27
|
+
* @returns true if values should be considered equal.
|
|
28
|
+
*/
|
|
29
|
+
export interface Comparator<T = any> {
|
|
30
|
+
(current: T, next: T): boolean;
|
|
31
|
+
}
|
|
32
|
+
type NodesFromValuesRec<T extends unknown[], Acc extends unknown[]> = T extends [infer Head, ...infer Tail] ? NodesFromValuesRec<Tail, [...Acc, Head extends unknown ? RealmNode<Head> : never]> : Acc;
|
|
33
|
+
export type NodesFromValues<T extends unknown[]> = T extends unknown[] ? NodesFromValuesRec<T, []> : never;
|
|
34
|
+
export declare function defaultComparator<T>(current: T, next: T): boolean;
|
|
35
|
+
declare class SetMap<T> {
|
|
36
|
+
map: Map<string, Set<T>>;
|
|
37
|
+
getOrCreate(key: NodeKey): Set<T>;
|
|
38
|
+
get(key: NodeKey): Set<T> | undefined;
|
|
39
|
+
use(key: NodeKey, cb: (value: Set<T>) => unknown): void;
|
|
40
|
+
delete(key: NodeKey): boolean;
|
|
41
|
+
}
|
|
42
|
+
export declare class RefCount {
|
|
43
|
+
map: Map<NodeKey, number>;
|
|
44
|
+
constructor(map?: Map<string, number>);
|
|
45
|
+
clone(): RefCount;
|
|
46
|
+
increment(key: NodeKey): void;
|
|
47
|
+
decrement(key: NodeKey, ifZero: () => void): void;
|
|
48
|
+
}
|
|
49
|
+
export type RealmGraph = SetMap<RealmProjection>;
|
|
50
|
+
export declare function realm(): {
|
|
51
|
+
combine: {
|
|
52
|
+
<T1>(nodes_0: RN<T1>): RN<T1>;
|
|
53
|
+
<T1_1, T2>(nodes_0: RN<T1_1>, nodes_1: RN<T2>): RN<[T1_1, T2]>;
|
|
54
|
+
<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]>;
|
|
55
|
+
<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]>;
|
|
56
|
+
<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]>;
|
|
57
|
+
<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]>;
|
|
58
|
+
<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]>;
|
|
59
|
+
<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]>;
|
|
60
|
+
<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]>;
|
|
61
|
+
<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]>;
|
|
62
|
+
<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]>;
|
|
63
|
+
<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]>;
|
|
64
|
+
<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]>;
|
|
65
|
+
<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]>;
|
|
66
|
+
<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]>;
|
|
67
|
+
};
|
|
68
|
+
connect: <T extends unknown[] = unknown[]>({ sources, pulls, map, sink: { key: sink } }: RealmProjectionSpec<T>) => void;
|
|
69
|
+
debug: () => void;
|
|
70
|
+
derive: <T_1>(source: RealmNode<T_1>, initial: T_1) => RealmNode<T_1>;
|
|
71
|
+
getKeyValue: (key: string) => unknown;
|
|
72
|
+
getValue: <T_2>(node: RN<T_2>) => T_2;
|
|
73
|
+
getKeyValues: (keys: string[]) => unknown[];
|
|
74
|
+
label: (newLabels: Record<string, RealmNode<unknown>>) => void;
|
|
75
|
+
labels: Record<string, RealmNode<unknown>>;
|
|
76
|
+
link: <T_3>(source: RealmNode<T_3>, sink: RealmNode<T_3>) => void;
|
|
77
|
+
node: <T_4>(value?: symbol | T_4, distinct?: boolean | Comparator<T_4>) => RealmNode<T_4>;
|
|
78
|
+
o: {
|
|
79
|
+
delayWithMicrotask: <I>() => (source: RealmNode<I>) => RealmNode<I>;
|
|
80
|
+
debounceTime: <I_1>(delay: number) => (source: RealmNode<I_1>) => RealmNode<I_1>;
|
|
81
|
+
filter: <I_2, O_1 = I_2>(predicate: (value: I_2) => boolean) => (source: RealmNode<I_2>) => RealmNode<O_1>;
|
|
82
|
+
map: <I_3, O_2>(mapFunction: (value: I_3) => O_2) => (source: RealmNode<I_3>) => RealmNode<O_2>;
|
|
83
|
+
mapTo: <I_4, O_3>(value: O_3) => (source: RealmNode<I_4>) => RealmNode<O_3>;
|
|
84
|
+
onNext: <I_5, O_4>(bufNode: RN<O_4>) => (source: RealmNode<I_5>) => RealmNode<[I_5, O_4]>;
|
|
85
|
+
scan: <I_6, O_5>(accumulator: (current: O_5, value: I_6) => O_5, seed: O_5) => (source: RealmNode<I_6>) => RealmNode<O_5>;
|
|
86
|
+
throttleTime: <I_7>(delay: number) => (source: RealmNode<I_7>) => RealmNode<I_7>;
|
|
87
|
+
withLatestFrom: {
|
|
88
|
+
<I_8, T1_15>(nodes_0: RN<T1_15>): (source: RN<I_8>) => RN<[I_8, T1_15]>;
|
|
89
|
+
<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]>;
|
|
90
|
+
<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]>;
|
|
91
|
+
<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]>;
|
|
92
|
+
<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]>;
|
|
93
|
+
<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]>;
|
|
94
|
+
<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]>;
|
|
95
|
+
<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]>;
|
|
96
|
+
};
|
|
97
|
+
once: <I_16>() => (source: RealmNode<I_16>) => RealmNode<I_16>;
|
|
98
|
+
passOnlyAfterNodeHasEmittedBefore: <I_17>(starterNode: RN<unknown>, durationNode: RN<number>) => (source: RealmNode<I_17>) => RealmNode<I_17>;
|
|
99
|
+
};
|
|
100
|
+
pipe: {
|
|
101
|
+
<T_5>(s: RealmNode<T_5>): RealmNode<T_5>;
|
|
102
|
+
<T_6, O1>(s: RealmNode<T_6>, o1: (source: RealmNode<T_6>) => RealmNode<O1>): RealmNode<O1>;
|
|
103
|
+
<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>;
|
|
104
|
+
<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>;
|
|
105
|
+
<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>;
|
|
106
|
+
<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>;
|
|
107
|
+
<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>;
|
|
108
|
+
<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>;
|
|
109
|
+
};
|
|
110
|
+
pub: {
|
|
111
|
+
<T1_23>(args_0: RN<T1_23>, args_1: T1_23): void;
|
|
112
|
+
<T1_24, T2_21>(args_0: RN<T1_24>, args_1: T1_24, args_2: RN<T2_21>, args_3: T2_21): void;
|
|
113
|
+
<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;
|
|
114
|
+
<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;
|
|
115
|
+
};
|
|
116
|
+
pubIn: (values: Record<NodeKey, unknown>) => void;
|
|
117
|
+
pubKey: (key: string, value: unknown) => void;
|
|
118
|
+
pubKeys: (values: Record<string, unknown>) => void;
|
|
119
|
+
resetSingletonSubs: () => void;
|
|
120
|
+
singletonSub: <T_13>({ key }: RealmNode<T_13>, subscription: Subscription<T_13>) => UnsubscribeHandle;
|
|
121
|
+
singletonSubKey: <T_14>(key: string, subscription: Subscription<T_14>) => UnsubscribeHandle;
|
|
122
|
+
spread: <T_15 extends LongTuple<unknown>>(source: RealmNode<T_15>, initialValues: T_15) => NodesFromValues<T_15>;
|
|
123
|
+
sub: {
|
|
124
|
+
<T1_27>(args_0: RN<T1_27>, args_1: Subscription<T1_27>): UnsubscribeHandle;
|
|
125
|
+
<T1_28, T2_24>(args_0: RN<T1_28>, args_1: RN<T2_24>, args_2: Subscription<[T1_28, T2_24]>): UnsubscribeHandle;
|
|
126
|
+
<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;
|
|
127
|
+
};
|
|
128
|
+
subKey: (key: string, subscription: Subscription<unknown>) => UnsubscribeHandle;
|
|
129
|
+
subKeys: (keys: string[], subscription: Subscription<unknown>) => UnsubscribeHandle;
|
|
130
|
+
};
|
|
131
|
+
export interface Realm extends ReturnType<typeof realm> {
|
|
132
|
+
}
|
|
133
|
+
export {};
|