Skip to content

Commit

Permalink
revert structuredClone as it is not supported on proxy objects
Browse files Browse the repository at this point in the history
  • Loading branch information
AmruthPillai committed May 10, 2024
1 parent a102f62 commit c15d9f7
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
// unicorn
"unicorn/no-null": "off",
"unicorn/prevent-abbreviations": "off",
"unicorn/prefer-string-replace-all": "off"
"unicorn/prefer-string-replace-all": "off",
"unicorn/prefer-structured-clone": "off"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const CustomFieldsSection = ({ className }: Props) => {

const onChangeCustomField = (field: ICustomField) => {
const index = customFields.findIndex((item) => item.id === field.id);
const newCustomFields = structuredClone(customFields);
const newCustomFields = JSON.parse(JSON.stringify(customFields));
newCustomFields[index] = field;

setValue("basics.customFields", newCustomFields);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,15 @@ export const LayoutSection = () => {
};

const onAddPage = () => {
const layoutCopy = structuredClone(layout);
const layoutCopy = JSON.parse(JSON.stringify(layout));

layoutCopy.push([[], []]);

setValue("metadata.layout", layoutCopy);
};

const onRemovePage = (page: number) => {
const layoutCopy = structuredClone(layout);
const layoutCopy = JSON.parse(JSON.stringify(layout));

layoutCopy[0][0].push(...layoutCopy[page][0]); // Main
layoutCopy[0][1].push(...layoutCopy[page][1]); // Sidebar
Expand All @@ -182,7 +182,7 @@ export const LayoutSection = () => {
};

const onResetLayout = () => {
const layoutCopy = structuredClone(defaultMetadata.layout);
const layoutCopy = JSON.parse(JSON.stringify(defaultMetadata.layout));

// Loop through all pages and columns, and get any sections that start with "custom."
// These should be appended to the first page of the new layout.
Expand Down
6 changes: 3 additions & 3 deletions apps/client/src/stores/resume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const useResumeStore = create<ResumeStore>()(
state.resume.data = _set(state.resume.data, path, value);
}

void debouncedUpdateResume(structuredClone(state.resume));
void debouncedUpdateResume(JSON.parse(JSON.stringify(state.resume)));
});
},
addSection: () => {
Expand All @@ -51,7 +51,7 @@ export const useResumeStore = create<ResumeStore>()(
state.resume.data.metadata.layout[lastPageIndex][0].push(`custom.${section.id}`);
state.resume.data = _set(state.resume.data, `sections.custom.${section.id}`, section);

void debouncedUpdateResume(structuredClone(state.resume));
void debouncedUpdateResume(JSON.parse(JSON.stringify(state.resume)));
});
},
removeSection: (sectionId: SectionKey) => {
Expand All @@ -63,7 +63,7 @@ export const useResumeStore = create<ResumeStore>()(
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete state.resume.data.sections.custom[id];

void debouncedUpdateResume(structuredClone(state.resume));
void debouncedUpdateResume(JSON.parse(JSON.stringify(state.resume)));
});
}
},
Expand Down
2 changes: 1 addition & 1 deletion libs/parser/src/json-resume/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class JsonResumeParser implements Parser<Json, JsonResume> {
}

convert(data: JsonResume) {
const result = structuredClone(defaultResumeData);
const result = JSON.parse(JSON.stringify(defaultResumeData));

// Basics
result.basics.name = data.basics?.name ?? "";
Expand Down
2 changes: 1 addition & 1 deletion libs/parser/src/linkedin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class LinkedInParser implements Parser<JSZip, LinkedIn> {
}

convert(data: LinkedIn) {
const result = structuredClone(defaultResumeData);
const result = JSON.parse(JSON.stringify(defaultResumeData));

// Profile
if (data.Profile && data.Profile.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion libs/parser/src/reactive-resume-v3/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class ReactiveResumeV3Parser implements Parser<Json, ReactiveResumeV3> {
}

convert(data: ReactiveResumeV3) {
const result = structuredClone(defaultResumeData);
const result = JSON.parse(JSON.stringify(defaultResumeData));

// Basics
result.basics.name = data.basics.name ?? "";
Expand Down
2 changes: 1 addition & 1 deletion libs/utils/src/namespaces/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const moveItemInLayout = (
): string[][][] => {
try {
// Create a deep copy of the layout to avoid mutating the original array
const newLayout = structuredClone(layout);
const newLayout = JSON.parse(JSON.stringify(layout));

// Get the item from the current location
const item = newLayout[current.page][current.column][current.section];
Expand Down
2 changes: 1 addition & 1 deletion libs/utils/src/namespaces/tests/array.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describe("moveItemInLayout", () => {
[["item1"], ["item2"]],
[["item3"], ["item4"]],
];
const layoutCopy = structuredClone(layout);
const layoutCopy = JSON.parse(JSON.stringify(layout));
const current = { page: 0, column: 1, section: 0 };
const target = { page: 1, column: 0, section: 1 };

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@reactive-resume/source",
"description": "A free and open-source resume builder that simplifies the process of creating, updating, and sharing your resume.",
"version": "4.1.2",
"version": "4.1.3",
"license": "MIT",
"private": true,
"author": {
Expand Down

0 comments on commit c15d9f7

Please sign in to comment.