@slate-collaborate/types
Advanced tools
Comparing version 0.0.22 to 0.0.23
export declare type AccessMode = "read" | "read-write"; | ||
export declare const AccessMode: { | ||
isAccessMode: (value: any) => value is AccessMode; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AccessMode = void 0; | ||
exports.AccessMode = { | ||
isAccessMode: (value) => { | ||
return value === "read" || value === "read-write"; | ||
} | ||
}; |
@@ -10,2 +10,5 @@ import { UserInfo } from "./UserInfo"; | ||
}; | ||
export declare const DocumentApplyOperation: { | ||
isDocumentApplyOperation: (value: any) => value is DocumentApplyOperation; | ||
}; | ||
export declare type DocumentSessionStartedOperation = { | ||
@@ -17,2 +20,5 @@ type: "session-started"; | ||
}; | ||
export declare const DocumentSessionStartedOperation: { | ||
isDocumentSessionStartedOperation: (value: any) => value is DocumentSessionStartedOperation; | ||
}; | ||
export declare type DocumentSessionStoppedOperation = { | ||
@@ -24,2 +30,8 @@ type: "session-stopped"; | ||
}; | ||
export declare const DocumentSessionStoppedOperation: { | ||
isDocumentSessionStoppedOperation: (value: any) => value is DocumentSessionStoppedOperation; | ||
}; | ||
export declare type DocumentOperation = DocumentApplyOperation | DocumentSessionStartedOperation | DocumentSessionStoppedOperation; | ||
export declare const DocumentOperation: { | ||
isDocumentOperation: (value: any) => value is DocumentOperation; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DocumentOperation = exports.DocumentSessionStoppedOperation = exports.DocumentSessionStartedOperation = exports.DocumentApplyOperation = void 0; | ||
const slate_value_type_1 = require("../slate-value-type"); | ||
const AccessMode_1 = require("./AccessMode"); | ||
const SessionId_1 = require("./SessionId"); | ||
exports.DocumentApplyOperation = { | ||
isDocumentApplyOperation: (value) => { | ||
if (value === undefined || value === null || typeof value !== "object") | ||
return false; | ||
if (value.type !== "apply") | ||
return false; | ||
if (!SessionId_1.SessionId.isSessionId(value.sessionId)) | ||
return false; | ||
if (!Array.isArray(value.operations)) | ||
return false; | ||
if (!value.operations.every(slate_value_type_1.SlateOperation.isSlateOperation)) | ||
return false; | ||
return true; | ||
} | ||
}; | ||
exports.DocumentSessionStartedOperation = { | ||
isDocumentSessionStartedOperation: (value) => { | ||
if (value === undefined || value === null || typeof value !== "object") | ||
return false; | ||
if (!SessionId_1.SessionId.isSessionId(value.sessionId)) | ||
return false; | ||
if (!AccessMode_1.AccessMode.isAccessMode(value.accessMode)) | ||
return false; | ||
return true; | ||
} | ||
}; | ||
exports.DocumentSessionStoppedOperation = { | ||
isDocumentSessionStoppedOperation: (value) => { | ||
if (value === undefined || value === null || typeof value !== "object") | ||
return false; | ||
if (!SessionId_1.SessionId.isSessionId(value.sessionId)) | ||
return false; | ||
if (!AccessMode_1.AccessMode.isAccessMode(value.accessMode)) | ||
return false; | ||
return true; | ||
} | ||
}; | ||
exports.DocumentOperation = { | ||
isDocumentOperation: (value) => { | ||
if (value === undefined || value === null || typeof value !== "object") | ||
return false; | ||
switch (value.type) { | ||
case "apply": return exports.DocumentApplyOperation.isDocumentApplyOperation(value); | ||
case "session-started": return exports.DocumentSessionStartedOperation.isDocumentSessionStartedOperation(value); | ||
case "session-stopped": return exports.DocumentSessionStoppedOperation.isDocumentSessionStoppedOperation(value); | ||
default: return false; | ||
} | ||
} | ||
}; |
export declare type DocumentRevision = number; | ||
export declare const DocumentRevision: { | ||
isDocumentRevision: (value: any) => value is number; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DocumentRevision = void 0; | ||
exports.DocumentRevision = { | ||
isDocumentRevision: (value) => { | ||
return typeof value === "number"; | ||
} | ||
}; |
export declare type SessionId = string; | ||
export declare const SessionId: { | ||
isSessionId: (value: any) => value is string; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SessionId = void 0; | ||
exports.SessionId = { | ||
isSessionId: (value) => { | ||
return !(value === undefined || value === null || typeof value !== "string" || value.length === 0); | ||
} | ||
}; |
@@ -1,4 +0,4 @@ | ||
export type { SlateValue } from "./SlateValue"; | ||
export * from "./SlateValue"; | ||
export type { SlateSelection } from "./SlateSelection"; | ||
export type { SlateOperation } from "./SlateOperation"; | ||
export * from "./SlateOperation"; | ||
export * from "./SlateValueType"; |
@@ -13,2 +13,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./SlateValue"), exports); | ||
__exportStar(require("./SlateOperation"), exports); | ||
__exportStar(require("./SlateValueType"), exports); |
@@ -77,1 +77,4 @@ import { Node } from "./SlateValue"; | ||
export declare type SlateOperation = SelectionOperation | NodeOperation | TextOperation; | ||
export declare const SlateOperation: { | ||
isSlateOperation: (value: any) => value is SlateOperation; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SlateOperation = void 0; | ||
exports.SlateOperation = { | ||
isSlateOperation: (value) => { | ||
if (value === undefined || value === null || typeof value !== "object") | ||
return false; | ||
switch (value.type) { | ||
case "set_selection": | ||
case "insert_node": | ||
case "merge_node": | ||
case "move_node": | ||
case "remove_node": | ||
case "set_node": | ||
case "split_node": | ||
case "insert_text": | ||
case "remove_text": | ||
return true; | ||
} | ||
return false; | ||
} | ||
}; |
@@ -12,7 +12,12 @@ export declare type Text = { | ||
declare function isText(node: Node): node is Text; | ||
declare function isNode(value: any): value is Node; | ||
export declare const Node: { | ||
isElement: typeof isElement; | ||
isText: typeof isText; | ||
isNode: typeof isNode; | ||
}; | ||
export declare type SlateValue = Node[]; | ||
export declare const SlateValue: { | ||
isSlateValue: (value: any) => value is SlateValue; | ||
}; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Node = void 0; | ||
exports.SlateValue = exports.Node = void 0; | ||
function isElement(node) { | ||
@@ -10,5 +10,16 @@ return node.children !== undefined; | ||
} | ||
function isNode(value) { | ||
if (value === undefined || value === null) | ||
return false; | ||
return isElement(value) || isText(value); | ||
} | ||
exports.Node = { | ||
isElement, | ||
isText | ||
isText, | ||
isNode | ||
}; | ||
exports.SlateValue = { | ||
isSlateValue: (value) => { | ||
return Array.isArray(value) && value.every(exports.Node.isNode); | ||
} | ||
}; |
export declare type AccessMode = "read" | "read-write"; | ||
export declare const AccessMode: { | ||
isAccessMode: (value: any) => value is AccessMode; | ||
}; |
@@ -10,2 +10,5 @@ import { UserInfo } from "./UserInfo"; | ||
}; | ||
export declare const DocumentApplyOperation: { | ||
isDocumentApplyOperation: (value: any) => value is DocumentApplyOperation; | ||
}; | ||
export declare type DocumentSessionStartedOperation = { | ||
@@ -17,2 +20,5 @@ type: "session-started"; | ||
}; | ||
export declare const DocumentSessionStartedOperation: { | ||
isDocumentSessionStartedOperation: (value: any) => value is DocumentSessionStartedOperation; | ||
}; | ||
export declare type DocumentSessionStoppedOperation = { | ||
@@ -24,2 +30,8 @@ type: "session-stopped"; | ||
}; | ||
export declare const DocumentSessionStoppedOperation: { | ||
isDocumentSessionStoppedOperation: (value: any) => value is DocumentSessionStoppedOperation; | ||
}; | ||
export declare type DocumentOperation = DocumentApplyOperation | DocumentSessionStartedOperation | DocumentSessionStoppedOperation; | ||
export declare const DocumentOperation: { | ||
isDocumentOperation: (value: any) => value is DocumentOperation; | ||
}; |
export declare type DocumentRevision = number; | ||
export declare const DocumentRevision: { | ||
isDocumentRevision: (value: any) => value is number; | ||
}; |
export declare type SessionId = string; | ||
export declare const SessionId: { | ||
isSessionId: (value: any) => value is string; | ||
}; |
@@ -1,4 +0,4 @@ | ||
export type { SlateValue } from "./SlateValue"; | ||
export * from "./SlateValue"; | ||
export type { SlateSelection } from "./SlateSelection"; | ||
export type { SlateOperation } from "./SlateOperation"; | ||
export * from "./SlateOperation"; | ||
export * from "./SlateValueType"; |
@@ -0,1 +1,3 @@ | ||
export * from "./SlateValue"; | ||
export * from "./SlateOperation"; | ||
export * from "./SlateValueType"; |
@@ -77,1 +77,4 @@ import { Node } from "./SlateValue"; | ||
export declare type SlateOperation = SelectionOperation | NodeOperation | TextOperation; | ||
export declare const SlateOperation: { | ||
isSlateOperation: (value: any) => value is SlateOperation; | ||
}; |
@@ -12,7 +12,12 @@ export declare type Text = { | ||
declare function isText(node: Node): node is Text; | ||
declare function isNode(value: any): value is Node; | ||
export declare const Node: { | ||
isElement: typeof isElement; | ||
isText: typeof isText; | ||
isNode: typeof isNode; | ||
}; | ||
export declare type SlateValue = Node[]; | ||
export declare const SlateValue: { | ||
isSlateValue: (value: any) => value is SlateValue; | ||
}; | ||
export {}; |
@@ -7,5 +7,16 @@ function isElement(node) { | ||
} | ||
function isNode(value) { | ||
if (value === undefined || value === null) | ||
return false; | ||
return isElement(value) || isText(value); | ||
} | ||
export const Node = { | ||
isElement, | ||
isText | ||
isText, | ||
isNode | ||
}; | ||
export const SlateValue = { | ||
isSlateValue: (value) => { | ||
return Array.isArray(value) && value.every(Node.isNode); | ||
} | ||
}; |
{ | ||
"name": "@slate-collaborate/types", | ||
"version": "0.0.22", | ||
"version": "0.0.23", | ||
"main": "dist/cjs/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/cjs/index.d.ts", |
329140
7630