Skip to content

Commit

Permalink
Bundle types
Browse files Browse the repository at this point in the history
  • Loading branch information
johngodley committed Aug 16, 2021
1 parent a363dcc commit 22ab658
Show file tree
Hide file tree
Showing 25 changed files with 331 additions and 10 deletions.
4 changes: 2 additions & 2 deletions build-browser/isolated-block-editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build-types/components/block-editor-contents/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ export type OnSelection = () => any;
/**
* Update callback
*/
export type OnUpdate = (blocks: object[]) => any;
export type OnUpdate = (blocks: object[], options?: object) => any;
//# sourceMappingURL=index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Updates the block doc with the local blocks block changes.
*
* @param {yjs.Map} yDocBlocks Blocks doc.
* @param {Array} blocks Updated blocks.
* @param {string} clientId Current clientId.
*/
export function updateBlocksDoc(yDocBlocks: yjs.Map<any>, blocks: any[], clientId?: string): void;
/**
* Updates the comments doc with the local comments changes.
*
* @param {yjs.Doc} commentsDoc comments doc.
* @param {Object} comments Updated comments.
*/
export function updateCommentsDoc(commentsDoc: yjs.Doc, comments?: any): void;
/**
* Updates the replies doc with the local replies changes.
*
* @param {yjs.Doc} repliesDoc replies doc.
* @param {Object} replies Updated replies.
*/
export function updateCommentRepliesDoc(repliesDoc: yjs.Doc, replies?: any): void;
/**
* Updates the post doc with the local post changes.
*
* @param {yjs.Doc} doc Shared doc.
* @param {Object} newPost Updated post.
*/
export function updatePostDoc(doc: yjs.Doc, newPost: any): void;
/**
* Converts the comments doc into a comment list.
*
* @param {yjs.Map} commentsDoc Comments doc.
* @return {Array} Comment list.
*/
export function commentsDocToArray(commentsDoc: yjs.Map<any>): any[];
/**
* Converts the block doc into a block list.
*
* @param {yjs.Map} yDocBlocks Block doc.
* @param {string} clientId Current block clientId.
* @return {Array} Block list.
*/
export function blocksDocToArray(yDocBlocks: yjs.Map<any>, clientId?: string): any[];
/**
* Converts the post doc into a post object.
*
* @param {yjs.Map} doc Shared doc.
* @return {Object} Post object.
*/
export function postDocToObject(doc: yjs.Map<any>): any;
import * as yjs from "yjs";
//# sourceMappingURL=yjs.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions build-types/components/block-editor-contents/use-yjs/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* @param {object} opts - Hook options
* @param {object[]} opts.blocks
* @param {OnUpdate} opts.onRemoteDataChange
* @param {CollaborationSettings} [opts.settings]
*/
export default function useYjs({ blocks, onRemoteDataChange, settings }: {
blocks: object[];
onRemoteDataChange: OnUpdate;
settings?: import("../../..").CollaborationSettings | undefined;
}): void;
export type IsoEditorSelection = {
selectionStart: object;
selectionEnd: object;
};
export type CollaborationSettings = import('../../..').CollaborationSettings;
export type CollaborationTransport = import('../../..').CollaborationTransport;
export type CollaborationTransportDocMessage = import('../../..').CollaborationTransportDocMessage;
export type CollaborationTransportSelectionMessage = import('../../..').CollaborationTransportSelectionMessage;
export type EditorSelection = import('../../..').EditorSelection;
export type OnUpdate = import('..').OnUpdate;
//# sourceMappingURL=index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions build-types/components/block-editor-contents/use-yjs/yjs-doc.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export function createDocument({ identity, applyDataChanges, getData, sendMessage, }: {
identity: any;
applyDataChanges: any;
getData: any;
sendMessage: any;
}): {
applyDataChanges(data: any): void;
connect(): void;
disconnect(): void;
startSharing(data: any): void;
receiveMessage({ protocol, messageType, origin, ...content }: {
[x: string]: any;
protocol: any;
messageType: any;
origin: any;
}): void;
onRemoteDataChange(listener: any): () => void;
onStateChange(listener: any): () => void;
getState(): string;
};
//# sourceMappingURL=yjs-doc.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
declare var _default: import("react").ForwardRefExoticComponent<Pick<any, string | number | symbol> & import("react").RefAttributes<any>>;
declare var _default: import("@wordpress/element/node_modules/@types/react").ForwardRefExoticComponent<Pick<any, string | number | symbol> & import("@wordpress/element/node_modules/@types/react").RefAttributes<any>>;
export default _default;
//# sourceMappingURL=redo.d.ts.map
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
declare var _default: import("react").ForwardRefExoticComponent<Pick<any, string | number | symbol> & import("react").RefAttributes<any>>;
declare var _default: import("@wordpress/element/node_modules/@types/react").ForwardRefExoticComponent<Pick<any, string | number | symbol> & import("@wordpress/element/node_modules/@types/react").RefAttributes<any>>;
export default _default;
//# sourceMappingURL=undo.d.ts.map
2 changes: 1 addition & 1 deletion build-types/components/default-settings/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions build-types/components/formats/collab-caret/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Applies given carets to the given record.
*
* @param {Object} record The record to apply carets to.
* @param {Array} carets The carets to apply.
* @return {Object} A record with the carets applied.
*/
export function applyCarets(record: any, carets?: any[]): any;
export namespace settings {
const title: string;
const tagName: string;
const className: string;
namespace attributes {
export const id: string;
const className_1: string;
export { className_1 as className };
}
function edit(): null;
function edit(): null;
function __experimentalGetPropsForEditableTreePreparation(select: any, { richTextIdentifier, blockClientId }: {
richTextIdentifier: any;
blockClientId: any;
}): {
carets: {
id: string;
label: any;
start: any;
end: any;
color: any;
}[];
};
function __experimentalGetPropsForEditableTreePreparation(select: any, { richTextIdentifier, blockClientId }: {
richTextIdentifier: any;
blockClientId: any;
}): {
carets: {
id: string;
label: any;
start: any;
end: any;
color: any;
}[];
};
function __experimentalCreatePrepareEditableTree({ carets }: {
carets: any;
}): (formats: any, text: any) => any;
function __experimentalCreatePrepareEditableTree({ carets }: {
carets: any;
}): (formats: any, text: any) => any;
}
export function registerFormatCollabCaret(): void;
//# sourceMappingURL=index.d.ts.map
1 change: 1 addition & 0 deletions build-types/components/formats/collab-caret/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

131 changes: 131 additions & 0 deletions build-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
* @typedef BlockEditorSettings
* @property {IsoSettings} [iso] - Isolated editor settings
* @property {EditorSettings} [editor] - Gutenberg editor settings
* @property {CollaborationSettings} [collab] - Real-time collaboration settings
*/
/**
* Gutenberg Editor Settings - this isn't the complete object, but just enough for linting here
Expand All @@ -52,6 +53,50 @@
* @property {null} templateLock
* @property {object[]} reusableBlocks
*/
/**
* Real-time collaboration settings
* @typedef CollaborationSettings
* @property {boolean} [enabled]
* @property {string} [channelId] Optional channel id to pass to transport.connect().
* @property {string} username Name displayed to peers. Required if collab is enabled.
* @property {string} [caretColor] Color of the caret indicator displayed to peers. If unspecified, a random color will be selected.
* @property {CollaborationTransport} transport Required if collab is enabled.
*/
/**
* Transport module for real-time collaboration
* @typedef CollaborationTransport
* @property {(message: CollaborationTransportDocMessage|CollaborationTransportSelectionMessage) => void} sendMessage
* @property {(options: CollaborationTransportConnectOpts) => Promise<{isFirstInChannel: boolean}>} connect
* @property {() => Promise<void>} disconnect
*
* @typedef CollaborationTransportConnectOpts
* @property {object} user
* @property {string} user.identity
* @property {string} user.name
* @property {string} [user.color] Color of the caret indicator displayed to peers.
* @property {(message: object) => void} onReceiveMessage Callback to run when a message is received.
* @property {(peers: AvailablePeer[]) => void} setAvailablePeers Callback to run when peers change.
* @property {string} [channelId]
*
* @typedef AvailablePeer
* @property {string} id
* @property {string} name
* @property {string} color
*
* @typedef CollaborationTransportDocMessage
* @property {string} identity
* @property {'doc'} type
* @property {object} message
*
* @typedef CollaborationTransportSelectionMessage
* @property {string} identity
* @property {'selection'} type
* @property {EditorSelection} selection
*
* @typedef EditorSelection
* @property {object} start
* @property {object} end
*/
/**
* Initialize Gutenberg
*/
Expand Down Expand Up @@ -182,6 +227,10 @@ export type BlockEditorSettings = {
* - Gutenberg editor settings
*/
editor?: EditorSettings | undefined;
/**
* - Real-time collaboration settings
*/
collab?: CollaborationSettings | undefined;
};
/**
* Gutenberg Editor Settings - this isn't the complete object, but just enough for linting here
Expand All @@ -196,6 +245,88 @@ export type EditorSettings = {
templateLock: null;
reusableBlocks: object[];
};
/**
* Real-time collaboration settings
*/
export type CollaborationSettings = {
enabled?: boolean | undefined;
/**
* Optional channel id to pass to transport.connect().
*/
channelId?: string | undefined;
/**
* Name displayed to peers. Required if collab is enabled.
*/
username: string;
/**
* Color of the caret indicator displayed to peers. If unspecified, a random color will be selected.
*/
caretColor?: string | undefined;
/**
* Required if collab is enabled.
*/
transport: CollaborationTransport;
};
/**
* Transport module for real-time collaboration
*/
export type CollaborationTransport = {
sendMessage: (message: CollaborationTransportDocMessage | CollaborationTransportSelectionMessage) => void;
connect: (options: CollaborationTransportConnectOpts) => Promise<{
isFirstInChannel: boolean;
}>;
disconnect: () => Promise<void>;
};
/**
* Transport module for real-time collaboration
*/
export type CollaborationTransportConnectOpts = {
user: {
identity: string;
name: string;
color?: string | undefined;
};
/**
* Callback to run when a message is received.
*/
onReceiveMessage: (message: object) => void;
/**
* Callback to run when peers change.
*/
setAvailablePeers: (peers: AvailablePeer[]) => void;
channelId?: string | undefined;
};
/**
* Transport module for real-time collaboration
*/
export type AvailablePeer = {
id: string;
name: string;
color: string;
};
/**
* Transport module for real-time collaboration
*/
export type CollaborationTransportDocMessage = {
identity: string;
type: 'doc';
message: object;
};
/**
* Transport module for real-time collaboration
*/
export type CollaborationTransportSelectionMessage = {
identity: string;
type: 'selection';
selection: EditorSelection;
};
/**
* Transport module for real-time collaboration
*/
export type EditorSelection = {
start: object;
end: object;
};
/**
* Save blocks callback
*/
Expand Down
2 changes: 1 addition & 1 deletion build-types/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions build-types/store/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ export default storeConfig;
declare function storeConfig(preferencesKey: any, defaultPreferences: any): {
reducer: any;
actions: {
setAvailablePeers: typeof import("./peers/actions").setAvailablePeers;
setPeerSelection: typeof import("./peers/actions").setPeerSelection;
toggleFeature(feature: string): {
type: string;
feature: string;
Expand Down Expand Up @@ -44,6 +46,11 @@ declare function storeConfig(preferencesKey: any, defaultPreferences: any): {
updateBlocksWithoutUndo(blocks: any[], options?: any): any;
};
selectors: {
/**
* WordPress dependencies
*/
getPeers(state: any): any;
hasPeers(state: any): boolean;
/**
* WordPress dependencies
*/
Expand Down
2 changes: 1 addition & 1 deletion build-types/store/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 22ab658

Please sign in to comment.