@supernova-studio/client 0.47.61 → 0.47.63

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supernova-studio/client",
3
- "version": "0.47.61",
3
+ "version": "0.47.63",
4
4
  "description": "Supernova Data Models",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.js",
package/src/utils/hash.ts CHANGED
@@ -38,13 +38,23 @@ function prepareObject(obj: any): any {
38
38
  return sortedObj;
39
39
  }
40
40
 
41
- export function generateHash(input: object | string): string {
41
+ export function generateHash(input: object | string, debug = false): string {
42
42
  if (typeof input === "object") {
43
- return hash(JSON.stringify(prepareObject(input)));
43
+ const sanitized = JSON.stringify(prepareObject(input));
44
+ if (debug) {
45
+ console.log("Hashing sanitized string:");
46
+ console.log(sanitized);
47
+ }
48
+ return hash(sanitized);
44
49
  } else {
45
50
  try {
46
51
  const obj = JSON.parse(input);
47
- return hash(JSON.stringify(prepareObject(obj)));
52
+ const sanitized = JSON.stringify(prepareObject(obj));
53
+ if (debug) {
54
+ console.log("Hashing sanitized string:");
55
+ console.log(sanitized);
56
+ }
57
+ return hash(sanitized);
48
58
  } catch {
49
59
  return hash(input);
50
60
  }
@@ -267,11 +267,10 @@ function parseAsRichText(
267
267
  id: id,
268
268
  type: "Block",
269
269
 
270
- ...(variantId && { variantId: variantId }),
271
-
272
270
  data: {
273
271
  packageId: definition.id,
274
272
  indentLevel: 0,
273
+ ...(variantId && { variantId: variantId }),
275
274
  items: [
276
275
  {
277
276
  id: id,
@@ -528,6 +527,7 @@ function parseAsTableCell(prosemirrorNode: ProsemirrorNode): PageBlockItemTableC
528
527
  const columnWidthArray = getProsemirrorAttribute(prosemirrorNode, "colwidth", z.array(z.number()).optional());
529
528
  if (columnWidthArray) {
530
529
  columnWidth = columnWidthArray[0];
530
+ columnWidth = Math.round(columnWidth * 100) / 100;
531
531
  }
532
532
 
533
533
  const tableNodes = (prosemirrorNode.content ?? []).map(parseAsTableNode).filter(nonNullFilter);
@@ -249,10 +249,8 @@ export class FrontendVersionRoomYDoc {
249
249
  //
250
250
 
251
251
  notifyDocumentationPageContentUpdated(pageId: string, content: DocumentationPageEditorModel) {
252
- const pageContentHash = generatePageContentHash(content);
252
+ const pageContentHash = generatePageContentHash(content, this.debug);
253
253
  if (this.debug) {
254
- console.log("Hashed:");
255
- console.log(JSON.stringify(content));
256
254
  console.log(`Will set page content hash: '${pageId}' : '${pageContentHash}'`);
257
255
  }
258
256
 
@@ -1,6 +1,6 @@
1
1
  import { generateHash } from "../../utils";
2
2
  import { DocumentationPageEditorModel } from "../docs-editor";
3
3
 
4
- export function generatePageContentHash(content: DocumentationPageEditorModel) {
5
- return generateHash(content);
4
+ export function generatePageContentHash(content: DocumentationPageEditorModel, debug = false) {
5
+ return generateHash(content, debug);
6
6
  }