Skip to content

manuscript - do not cloneDeep Kv. create safeCloneDeep#12384

Merged
cderv merged 5 commits intomainfrom
bugfix/12380
Mar 26, 2025
Merged

manuscript - do not cloneDeep Kv. create safeCloneDeep#12384
cderv merged 5 commits intomainfrom
bugfix/12380

Conversation

@cscheid
Copy link
Copy Markdown
Member

@cscheid cscheid commented Mar 26, 2025

Closes #12380.

@cscheid
Copy link
Copy Markdown
Member Author

cscheid commented Mar 26, 2025

(Thanks @cderv!)

@cscheid cscheid requested a review from Copilot March 26, 2025 14:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new safeCloneDeep function that leverages an object’s own cloning method, when available, to avoid a full deep clone on certain objects such as cache instances. The changes replace all usages of ld.cloneDeep with safeCloneDeep and explicitly implement a Cloneable interface on relevant classes.

  • Added safeCloneDeep function in src/core/safe-clone-deep.ts.
  • Updated Sass cache classes and ProjectCacheImpl to implement Cloneable, with clone methods returning the original object.
  • Replaced ld.cloneDeep with safeCloneDeep in notebook contributor files and revised error handling in SCSS parsing.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/core/safe-clone-deep.ts Introduces safeCloneDeep to use an object’s own .clone() method when available
src/core/sass/add-css-vars.ts Adds SCSSParsingError and updates error handling using safeCloneDeep
src/core/sass.ts Adjusts error handling logic to selectively catch SCSSParsingError
src/core/sass/cache.ts Implements Cloneable on SassCache with a clone method returning the current instance
src/core/cache/cache.ts Implements Cloneable on ProjectCacheImpl with a clone method returning the current instance
src/render/notebook/notebook-contributor-ipynb.ts Replaces ld.cloneDeep with safeCloneDeep for cloning executedFile objects
src/render/notebook/notebook-contributor-html.ts Replaces ld.cloneDeep with safeCloneDeep and applies type assertions
src/render/notebook/notebook-contributor-jats.ts Replaces ld.cloneDeep with safeCloneDeep for cloning executedFile objects
src/render/notebook/notebook-contributor-qmd.ts Replaces ld.cloneDeep with safeCloneDeep for cloning executedFile objects
Comments suppressed due to low confidence (1)

src/core/sass/cache.ts:23

  • The clone() method implementation returns 'this', which means it is not actually creating a deep copy. If this behavior is intentional for performance reasons, please add a clarifying comment to prevent potential misuse.
clone() {

Comment thread src/core/cache/cache.ts
@cderv
Copy link
Copy Markdown
Member

cderv commented Mar 26, 2025

There is an issue with epub in book

❯ quarto render docs\project\book\index.qmd --to epub
Check file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/quarto.ts
[1/4] index.qmd
[2/4] intro.qmd
[3/4] summary.qmd
[4/4] references.qmd

ERROR: TypeError: Cannot read private member #rid from an object whose class did not declare it

Not happening in html 🤷

So changing all cloneDeep, will probably fix it.

@cderv
Copy link
Copy Markdown
Member

cderv commented Mar 26, 2025

I think I found the one

@cderv
Copy link
Copy Markdown
Member

cderv commented Mar 26, 2025

And this broke everything because of typechecking working 🤦‍♂️ I am on it

cderv added 2 commits March 26, 2025 18:41
- unused import
- foundBrand is a const now
@cderv
Copy link
Copy Markdown
Member

cderv commented Mar 26, 2025

@cscheid safeCloneDeep needs to handle Maps (for fileInformationCache). I also added Sets support.

for epub book output for example.
@cderv cderv merged commit 521960c into main Mar 26, 2025
49 of 52 checks passed
@cderv cderv deleted the bugfix/12380 branch March 26, 2025 19:08
@cscheid
Copy link
Copy Markdown
Member Author

cscheid commented Mar 26, 2025

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Project cache error for notebooks in manuscript project

3 participants