microboard-temp 0.1.19 → 0.1.20

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.
@@ -2130,6 +2130,7 @@ __export(exports_browser, {
2130
2130
  parsersHTML: () => parsersHTML,
2131
2131
  omitDefaultProperties: () => omitDefaultProperties,
2132
2132
  messageRouter: () => messageRouter,
2133
+ itemValidators: () => itemValidators,
2133
2134
  itemFactories: () => itemFactories,
2134
2135
  isShallowSimilarTo: () => isShallowSimilarTo,
2135
2136
  isShallowEqualTo: () => isShallowEqualTo,
@@ -54982,6 +54983,166 @@ class Tools extends ToolContext {
54982
54983
  }
54983
54984
  }
54984
54985
 
54986
+ // src/Validators/Validators.ts
54987
+ function validateItemsMap(parsedObject) {
54988
+ if (typeof parsedObject !== "object" || parsedObject === null) {
54989
+ return false;
54990
+ }
54991
+ for (const key in parsedObject) {
54992
+ if (parsedObject.hasOwnProperty(key)) {
54993
+ const itemData = parsedObject[key];
54994
+ if (!validateItemData(itemData)) {
54995
+ return false;
54996
+ }
54997
+ }
54998
+ }
54999
+ return true;
55000
+ }
55001
+ var itemValidators = {
55002
+ Sticker: validateStickerData,
55003
+ Shape: validateShapeData,
55004
+ RichText: validateRichTextData,
55005
+ Connector: validateConnectorData,
55006
+ Image: validateImageItemData,
55007
+ Drawing: validateDrawingData,
55008
+ Frame: validateFrameData,
55009
+ Placeholder: validatePlaceholderData,
55010
+ AINode: validateAINodeData,
55011
+ Group: validateGroupData,
55012
+ Video: validateVideoItemData,
55013
+ Audio: validateAudioItemData
55014
+ };
55015
+ function validateItemData(itemData) {
55016
+ if (!itemData.hasOwnProperty("itemType") || typeof itemData.itemType !== "string") {
55017
+ return false;
55018
+ }
55019
+ const validator = itemValidators[itemData.itemType];
55020
+ return validator ? validator(itemData) : false;
55021
+ }
55022
+ function validateFrameData(frameData) {
55023
+ const isValid = frameData.hasOwnProperty("shapeType") && frameData.hasOwnProperty("backgroundColor") && frameData.hasOwnProperty("backgroundOpacity") && frameData.hasOwnProperty("borderColor") && frameData.hasOwnProperty("borderOpacity") && frameData.hasOwnProperty("borderStyle") && frameData.hasOwnProperty("borderWidth") && frameData.hasOwnProperty("transformation") && frameData.hasOwnProperty("text") && frameData.hasOwnProperty("children") && typeof frameData.shapeType === "string" && typeof frameData.backgroundColor === "string" && typeof frameData.backgroundOpacity === "number" && typeof frameData.borderColor === "string" && typeof frameData.borderOpacity === "number" && typeof frameData.borderStyle === "string" && typeof frameData.borderWidth === "number" && Array.isArray(frameData.children) && validateTransformationData(frameData.transformation) && validateRichTextData(frameData.text);
55024
+ return isValid;
55025
+ }
55026
+ function validateShapeData(shapeData) {
55027
+ const isValid = shapeData.hasOwnProperty("shapeType") && shapeData.hasOwnProperty("backgroundColor") && shapeData.hasOwnProperty("backgroundOpacity") && shapeData.hasOwnProperty("borderColor") && shapeData.hasOwnProperty("borderOpacity") && shapeData.hasOwnProperty("borderStyle") && shapeData.hasOwnProperty("borderWidth") && shapeData.hasOwnProperty("transformation") && shapeData.hasOwnProperty("text") && typeof shapeData.shapeType === "string" && typeof shapeData.backgroundColor === "string" && typeof shapeData.backgroundOpacity === "number" && typeof shapeData.borderColor === "string" && typeof shapeData.borderOpacity === "number" && typeof shapeData.borderStyle === "string" && typeof shapeData.borderWidth === "number" && validateTransformationData(shapeData.transformation) && validateRichTextData(shapeData.text);
55028
+ return isValid;
55029
+ }
55030
+ function validateStickerData(shapeData) {
55031
+ const isValid = shapeData.hasOwnProperty("itemType") && shapeData.hasOwnProperty("backgroundColor") && shapeData.hasOwnProperty("transformation") && shapeData.hasOwnProperty("text") && typeof shapeData.backgroundColor === "string" && validateTransformationData(shapeData.transformation) && validateRichTextData(shapeData.text);
55032
+ return isValid;
55033
+ }
55034
+ function validateTransformationData(transformationData) {
55035
+ const isValid = transformationData.hasOwnProperty("translateX") && transformationData.hasOwnProperty("translateY") && transformationData.hasOwnProperty("scaleX") && transformationData.hasOwnProperty("scaleY") && transformationData.hasOwnProperty("rotate") && typeof transformationData.translateX === "number" && typeof transformationData.translateY === "number" && typeof transformationData.scaleX === "number" && typeof transformationData.scaleY === "number" && typeof transformationData.rotate === "number";
55036
+ return isValid;
55037
+ }
55038
+ function validateRichTextData(richTextData) {
55039
+ const isValid = richTextData.hasOwnProperty("children") && Array.isArray(richTextData.children) && validateChildren(richTextData.children) && (typeof richTextData.verticalAlignment === "string" || richTextData.verticalAlignment === undefined) && (typeof richTextData.maxWidth === "number" || richTextData.maxWidth === undefined);
55040
+ return isValid;
55041
+ }
55042
+ function validateConnectorData(connectorData) {
55043
+ const isValid = connectorData.hasOwnProperty("startPoint") && connectorData.hasOwnProperty("endPoint") && connectorData.hasOwnProperty("startPointerStyle") && connectorData.hasOwnProperty("endPointerStyle") && connectorData.hasOwnProperty("lineStyle") && connectorData.hasOwnProperty("lineColor") && connectorData.hasOwnProperty("lineWidth") && connectorData.hasOwnProperty("transformation") && typeof connectorData.startPoint === "object" && typeof connectorData.endPoint === "object" && typeof connectorData.startPointerStyle === "string" && typeof connectorData.endPointerStyle === "string" && typeof connectorData.lineStyle === "string" && typeof connectorData.lineColor === "string" && typeof connectorData.lineWidth === "number" && validateTransformationData(connectorData.transformation);
55044
+ return isValid;
55045
+ }
55046
+ function validateChildren(children) {
55047
+ if (!Array.isArray(children)) {
55048
+ return false;
55049
+ }
55050
+ for (const child of children) {
55051
+ const isValidDescendant = validateDescendant(child);
55052
+ if (!isValidDescendant) {
55053
+ return false;
55054
+ }
55055
+ }
55056
+ return true;
55057
+ }
55058
+ function validateDescendant(descendant) {
55059
+ if (typeof descendant !== "object" || descendant === null) {
55060
+ return false;
55061
+ }
55062
+ switch (descendant.type) {
55063
+ case "paragraph":
55064
+ case "code_block":
55065
+ return validateParagraphNode(descendant);
55066
+ case "heading_one":
55067
+ case "heading_two":
55068
+ case "heading_three":
55069
+ case "heading_four":
55070
+ case "heading_five":
55071
+ return validateHeadingNode(descendant);
55072
+ case "block-quote":
55073
+ return validateBlockQuoteNode(descendant);
55074
+ case "ul_list":
55075
+ return validateBulletedListNode(descendant);
55076
+ case "ol_list":
55077
+ return validateNumberedListNode(descendant);
55078
+ case "list_item":
55079
+ return validateListItemNode(descendant);
55080
+ default:
55081
+ return false;
55082
+ }
55083
+ }
55084
+ function validateParagraphNode(node4) {
55085
+ return node4.hasOwnProperty("type") && node4.hasOwnProperty("children") && typeof node4.type === "string" && Array.isArray(node4.children) && node4.children.every((child) => validateTextNode(child));
55086
+ }
55087
+ function validateHeadingNode(node4) {
55088
+ return node4.hasOwnProperty("type") && node4.hasOwnProperty("children") && typeof node4.type === "string" && Array.isArray(node4.children) && node4.children.every((child) => validateTextNode(child));
55089
+ }
55090
+ function validateBlockQuoteNode(node4) {
55091
+ return node4.hasOwnProperty("type") && node4.hasOwnProperty("children") && typeof node4.type === "string" && Array.isArray(node4.children) && node4.children.every((child) => validateTextNode(child));
55092
+ }
55093
+ function validateBulletedListNode(node4) {
55094
+ return node4.hasOwnProperty("type") && node4.hasOwnProperty("children") && typeof node4.type === "string" && Array.isArray(node4.children) && node4.children.every((child) => validateListItemChild(child));
55095
+ }
55096
+ function validateNumberedListNode(node4) {
55097
+ return node4.hasOwnProperty("type") && node4.hasOwnProperty("children") && typeof node4.type === "string" && Array.isArray(node4.children) && node4.children.every((child) => validateListItemChild(child));
55098
+ }
55099
+ function validateListItemNode(node4) {
55100
+ return node4.hasOwnProperty("type") && node4.hasOwnProperty("children") && typeof node4.type === "string" && Array.isArray(node4.children) && node4.children.every((child) => validateListItemChild(child));
55101
+ }
55102
+ function validateListItemChild(child) {
55103
+ return validateTextNode(child) || validateBulletedListNode(child) || validateNumberedListNode(child);
55104
+ }
55105
+ function validateTextNode(node4) {
55106
+ return node4.hasOwnProperty("text") && typeof node4.text === "string";
55107
+ }
55108
+ function validateImageItemData(data) {
55109
+ const isValid = data.hasOwnProperty("transformation") && data.hasOwnProperty("storageLink") && typeof data.transformation === "object" && typeof data.storageLink === "string" && validateTransformationData(data.transformation);
55110
+ return isValid;
55111
+ }
55112
+ function validateVideoItemData(data) {
55113
+ const isValid = data.hasOwnProperty("transformation") && data.hasOwnProperty("url") && data.hasOwnProperty("isStorageUrl") && data.hasOwnProperty("previewUrl") && typeof data.transformation === "object" && typeof data.url === "string" && typeof data.previewUrl === "string" && typeof data.isStorageUrl === "boolean" && validateTransformationData(data.transformation);
55114
+ return isValid;
55115
+ }
55116
+ function validateAudioItemData(data) {
55117
+ const isValid = data.hasOwnProperty("transformation") && data.hasOwnProperty("url") && data.hasOwnProperty("extension") && typeof data.transformation === "object" && typeof data.url === "string" && typeof data.extension === "string" && validateTransformationData(data.transformation);
55118
+ return isValid;
55119
+ }
55120
+ function validateDrawingData(data) {
55121
+ if (!(data.hasOwnProperty("transformation") && data.hasOwnProperty("points") && typeof data.transformation === "object" && Array.isArray(data.points))) {
55122
+ return false;
55123
+ }
55124
+ for (const point7 of data.points) {
55125
+ if (!validatePointData(point7)) {
55126
+ return false;
55127
+ }
55128
+ }
55129
+ return true;
55130
+ }
55131
+ function validatePlaceholderData(data) {
55132
+ const isValid = data.hasOwnProperty("transformation") && data.hasOwnProperty("icon") && data.hasOwnProperty("miroData") && typeof data.transformation === "object" && typeof data.icon === "string" && typeof data.miroData === "object" && validateTransformationData(data.transformation);
55133
+ return isValid;
55134
+ }
55135
+ function validateAINodeData(data) {
55136
+ const isValid = data.hasOwnProperty("itemType") && data.hasOwnProperty("isUserRequest") && data.hasOwnProperty("transformation") && data.hasOwnProperty("text") && typeof data.isUserRequest === "boolean" && validateTransformationData(data.transformation);
55137
+ return isValid;
55138
+ }
55139
+ function validatePointData(data) {
55140
+ return data.hasOwnProperty("x") && data.hasOwnProperty("y") && typeof data.x === "number" && typeof data.y === "number";
55141
+ }
55142
+ function validateGroupData(groupData) {
55143
+ const isValid = groupData.hasOwnProperty("itemType") && groupData.hasOwnProperty("transformation") && groupData.hasOwnProperty("children") && Array.isArray(groupData.children) && validateTransformationData(groupData.transformation);
55144
+ return isValid;
55145
+ }
54985
55146
  // src/Items/RegisterItem.ts
54986
55147
  function registerItem({
54987
55148
  item,
@@ -54990,7 +55151,7 @@ function registerItem({
54990
55151
  }) {
54991
55152
  const { itemType } = defaultData2;
54992
55153
  itemFactories[itemType] = createItemFactory(item, defaultData2);
54993
- validators[itemType] = createItemValidator(defaultData2);
55154
+ itemValidators[itemType] = createItemValidator(defaultData2);
54994
55155
  registeredTools[toolData.name] = toolData.tool;
54995
55156
  itemCommandFactories[itemType] = createItemCommandFactory(itemType);
54996
55157
  }
@@ -62043,166 +62204,6 @@ class Board {
62043
62204
  this.presence.cleanup();
62044
62205
  }
62045
62206
  }
62046
- // src/Validators/Validators.ts
62047
- function validateItemsMap(parsedObject) {
62048
- if (typeof parsedObject !== "object" || parsedObject === null) {
62049
- return false;
62050
- }
62051
- for (const key in parsedObject) {
62052
- if (parsedObject.hasOwnProperty(key)) {
62053
- const itemData = parsedObject[key];
62054
- if (!validateItemData(itemData)) {
62055
- return false;
62056
- }
62057
- }
62058
- }
62059
- return true;
62060
- }
62061
- var itemValidators = {
62062
- Sticker: validateStickerData,
62063
- Shape: validateShapeData,
62064
- RichText: validateRichTextData,
62065
- Connector: validateConnectorData,
62066
- Image: validateImageItemData,
62067
- Drawing: validateDrawingData,
62068
- Frame: validateFrameData,
62069
- Placeholder: validatePlaceholderData,
62070
- AINode: validateAINodeData,
62071
- Group: validateGroupData,
62072
- Video: validateVideoItemData,
62073
- Audio: validateAudioItemData
62074
- };
62075
- function validateItemData(itemData) {
62076
- if (!itemData.hasOwnProperty("itemType") || typeof itemData.itemType !== "string") {
62077
- return false;
62078
- }
62079
- const validator = itemValidators[itemData.itemType];
62080
- return validator ? validator(itemData) : false;
62081
- }
62082
- function validateFrameData(frameData) {
62083
- const isValid = frameData.hasOwnProperty("shapeType") && frameData.hasOwnProperty("backgroundColor") && frameData.hasOwnProperty("backgroundOpacity") && frameData.hasOwnProperty("borderColor") && frameData.hasOwnProperty("borderOpacity") && frameData.hasOwnProperty("borderStyle") && frameData.hasOwnProperty("borderWidth") && frameData.hasOwnProperty("transformation") && frameData.hasOwnProperty("text") && frameData.hasOwnProperty("children") && typeof frameData.shapeType === "string" && typeof frameData.backgroundColor === "string" && typeof frameData.backgroundOpacity === "number" && typeof frameData.borderColor === "string" && typeof frameData.borderOpacity === "number" && typeof frameData.borderStyle === "string" && typeof frameData.borderWidth === "number" && Array.isArray(frameData.children) && validateTransformationData(frameData.transformation) && validateRichTextData(frameData.text);
62084
- return isValid;
62085
- }
62086
- function validateShapeData(shapeData) {
62087
- const isValid = shapeData.hasOwnProperty("shapeType") && shapeData.hasOwnProperty("backgroundColor") && shapeData.hasOwnProperty("backgroundOpacity") && shapeData.hasOwnProperty("borderColor") && shapeData.hasOwnProperty("borderOpacity") && shapeData.hasOwnProperty("borderStyle") && shapeData.hasOwnProperty("borderWidth") && shapeData.hasOwnProperty("transformation") && shapeData.hasOwnProperty("text") && typeof shapeData.shapeType === "string" && typeof shapeData.backgroundColor === "string" && typeof shapeData.backgroundOpacity === "number" && typeof shapeData.borderColor === "string" && typeof shapeData.borderOpacity === "number" && typeof shapeData.borderStyle === "string" && typeof shapeData.borderWidth === "number" && validateTransformationData(shapeData.transformation) && validateRichTextData(shapeData.text);
62088
- return isValid;
62089
- }
62090
- function validateStickerData(shapeData) {
62091
- const isValid = shapeData.hasOwnProperty("itemType") && shapeData.hasOwnProperty("backgroundColor") && shapeData.hasOwnProperty("transformation") && shapeData.hasOwnProperty("text") && typeof shapeData.backgroundColor === "string" && validateTransformationData(shapeData.transformation) && validateRichTextData(shapeData.text);
62092
- return isValid;
62093
- }
62094
- function validateTransformationData(transformationData) {
62095
- const isValid = transformationData.hasOwnProperty("translateX") && transformationData.hasOwnProperty("translateY") && transformationData.hasOwnProperty("scaleX") && transformationData.hasOwnProperty("scaleY") && transformationData.hasOwnProperty("rotate") && typeof transformationData.translateX === "number" && typeof transformationData.translateY === "number" && typeof transformationData.scaleX === "number" && typeof transformationData.scaleY === "number" && typeof transformationData.rotate === "number";
62096
- return isValid;
62097
- }
62098
- function validateRichTextData(richTextData) {
62099
- const isValid = richTextData.hasOwnProperty("children") && Array.isArray(richTextData.children) && validateChildren(richTextData.children) && (typeof richTextData.verticalAlignment === "string" || richTextData.verticalAlignment === undefined) && (typeof richTextData.maxWidth === "number" || richTextData.maxWidth === undefined);
62100
- return isValid;
62101
- }
62102
- function validateConnectorData(connectorData) {
62103
- const isValid = connectorData.hasOwnProperty("startPoint") && connectorData.hasOwnProperty("endPoint") && connectorData.hasOwnProperty("startPointerStyle") && connectorData.hasOwnProperty("endPointerStyle") && connectorData.hasOwnProperty("lineStyle") && connectorData.hasOwnProperty("lineColor") && connectorData.hasOwnProperty("lineWidth") && connectorData.hasOwnProperty("transformation") && typeof connectorData.startPoint === "object" && typeof connectorData.endPoint === "object" && typeof connectorData.startPointerStyle === "string" && typeof connectorData.endPointerStyle === "string" && typeof connectorData.lineStyle === "string" && typeof connectorData.lineColor === "string" && typeof connectorData.lineWidth === "number" && validateTransformationData(connectorData.transformation);
62104
- return isValid;
62105
- }
62106
- function validateChildren(children) {
62107
- if (!Array.isArray(children)) {
62108
- return false;
62109
- }
62110
- for (const child of children) {
62111
- const isValidDescendant = validateDescendant(child);
62112
- if (!isValidDescendant) {
62113
- return false;
62114
- }
62115
- }
62116
- return true;
62117
- }
62118
- function validateDescendant(descendant) {
62119
- if (typeof descendant !== "object" || descendant === null) {
62120
- return false;
62121
- }
62122
- switch (descendant.type) {
62123
- case "paragraph":
62124
- case "code_block":
62125
- return validateParagraphNode(descendant);
62126
- case "heading_one":
62127
- case "heading_two":
62128
- case "heading_three":
62129
- case "heading_four":
62130
- case "heading_five":
62131
- return validateHeadingNode(descendant);
62132
- case "block-quote":
62133
- return validateBlockQuoteNode(descendant);
62134
- case "ul_list":
62135
- return validateBulletedListNode(descendant);
62136
- case "ol_list":
62137
- return validateNumberedListNode(descendant);
62138
- case "list_item":
62139
- return validateListItemNode(descendant);
62140
- default:
62141
- return false;
62142
- }
62143
- }
62144
- function validateParagraphNode(node4) {
62145
- return node4.hasOwnProperty("type") && node4.hasOwnProperty("children") && typeof node4.type === "string" && Array.isArray(node4.children) && node4.children.every((child) => validateTextNode(child));
62146
- }
62147
- function validateHeadingNode(node4) {
62148
- return node4.hasOwnProperty("type") && node4.hasOwnProperty("children") && typeof node4.type === "string" && Array.isArray(node4.children) && node4.children.every((child) => validateTextNode(child));
62149
- }
62150
- function validateBlockQuoteNode(node4) {
62151
- return node4.hasOwnProperty("type") && node4.hasOwnProperty("children") && typeof node4.type === "string" && Array.isArray(node4.children) && node4.children.every((child) => validateTextNode(child));
62152
- }
62153
- function validateBulletedListNode(node4) {
62154
- return node4.hasOwnProperty("type") && node4.hasOwnProperty("children") && typeof node4.type === "string" && Array.isArray(node4.children) && node4.children.every((child) => validateListItemChild(child));
62155
- }
62156
- function validateNumberedListNode(node4) {
62157
- return node4.hasOwnProperty("type") && node4.hasOwnProperty("children") && typeof node4.type === "string" && Array.isArray(node4.children) && node4.children.every((child) => validateListItemChild(child));
62158
- }
62159
- function validateListItemNode(node4) {
62160
- return node4.hasOwnProperty("type") && node4.hasOwnProperty("children") && typeof node4.type === "string" && Array.isArray(node4.children) && node4.children.every((child) => validateListItemChild(child));
62161
- }
62162
- function validateListItemChild(child) {
62163
- return validateTextNode(child) || validateBulletedListNode(child) || validateNumberedListNode(child);
62164
- }
62165
- function validateTextNode(node4) {
62166
- return node4.hasOwnProperty("text") && typeof node4.text === "string";
62167
- }
62168
- function validateImageItemData(data) {
62169
- const isValid = data.hasOwnProperty("transformation") && data.hasOwnProperty("storageLink") && typeof data.transformation === "object" && typeof data.storageLink === "string" && validateTransformationData(data.transformation);
62170
- return isValid;
62171
- }
62172
- function validateVideoItemData(data) {
62173
- const isValid = data.hasOwnProperty("transformation") && data.hasOwnProperty("url") && data.hasOwnProperty("isStorageUrl") && data.hasOwnProperty("previewUrl") && typeof data.transformation === "object" && typeof data.url === "string" && typeof data.previewUrl === "string" && typeof data.isStorageUrl === "boolean" && validateTransformationData(data.transformation);
62174
- return isValid;
62175
- }
62176
- function validateAudioItemData(data) {
62177
- const isValid = data.hasOwnProperty("transformation") && data.hasOwnProperty("url") && data.hasOwnProperty("extension") && typeof data.transformation === "object" && typeof data.url === "string" && typeof data.extension === "string" && validateTransformationData(data.transformation);
62178
- return isValid;
62179
- }
62180
- function validateDrawingData(data) {
62181
- if (!(data.hasOwnProperty("transformation") && data.hasOwnProperty("points") && typeof data.transformation === "object" && Array.isArray(data.points))) {
62182
- return false;
62183
- }
62184
- for (const point7 of data.points) {
62185
- if (!validatePointData(point7)) {
62186
- return false;
62187
- }
62188
- }
62189
- return true;
62190
- }
62191
- function validatePlaceholderData(data) {
62192
- const isValid = data.hasOwnProperty("transformation") && data.hasOwnProperty("icon") && data.hasOwnProperty("miroData") && typeof data.transformation === "object" && typeof data.icon === "string" && typeof data.miroData === "object" && validateTransformationData(data.transformation);
62193
- return isValid;
62194
- }
62195
- function validateAINodeData(data) {
62196
- const isValid = data.hasOwnProperty("itemType") && data.hasOwnProperty("isUserRequest") && data.hasOwnProperty("transformation") && data.hasOwnProperty("text") && typeof data.isUserRequest === "boolean" && validateTransformationData(data.transformation);
62197
- return isValid;
62198
- }
62199
- function validatePointData(data) {
62200
- return data.hasOwnProperty("x") && data.hasOwnProperty("y") && typeof data.x === "number" && typeof data.y === "number";
62201
- }
62202
- function validateGroupData(groupData) {
62203
- const isValid = groupData.hasOwnProperty("itemType") && groupData.hasOwnProperty("transformation") && groupData.hasOwnProperty("children") && Array.isArray(groupData.children) && validateTransformationData(groupData.transformation);
62204
- return isValid;
62205
- }
62206
62207
  // src/Events/Merge.ts
62207
62208
  function areItemsTheSame(opA, opB) {
62208
62209
  if (opA.method === "transformMany" && opB.method === "transformMany") {