-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from zextras/devel-to-release-20240628
Devel to release 20240628
- Loading branch information
Showing
102 changed files
with
10,946 additions
and
6,082 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v18 | ||
v20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@zextras/carbonio-ui-preview](./carbonio-ui-preview.md) > [usePreview](./carbonio-ui-preview.usepreview.md) | ||
|
||
## usePreview() function | ||
|
||
Util hook to quick access to the preview functions | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
usePreview: () => PreviewManagerContextType | ||
``` | ||
**Returns:** | ||
|
||
[PreviewManagerContextType](./carbonio-ui-preview.previewmanagercontexttype.md) | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# Migration guide | ||
|
||
## From 1 to 2 | ||
|
||
With version 2 the react-pdf dependency is upgraded from v7 to v9. | ||
This version includes pdfjs as esm module. | ||
|
||
In order to upgrade from @zextras/carbonio-ui-preview v1 to v2 the following changes might be required. | ||
|
||
If you face some errors while upgrading, check also the migration guide from react-pdf: | ||
- https://github.com/wojtekmaj/react-pdf/wiki/Upgrade-guide-from-version-7.x-to-8.x | ||
- https://github.com/wojtekmaj/react-pdf/wiki/Upgrade-guide-from-version-8.x-to-9.x | ||
|
||
### Webpack | ||
|
||
If you use webpack to bundle your application, you will need to add an alias for the new React JSX transform | ||
inside webpack configurations. | ||
|
||
```ts | ||
// webpack.config.ts | ||
import webpack from 'webpack'; | ||
const config: webpack.Configuration = { | ||
// other configs | ||
resolve: { | ||
alias: { | ||
'react/jsx-runtime': 'react/jsx-runtime.js' | ||
} | ||
} | ||
}; | ||
|
||
export default config; | ||
``` | ||
|
||
### Jest | ||
|
||
#### Configure jest to transpile also esm modules | ||
|
||
@zextras/carbonio-ui-preview and pdfjs-dist are full esm modules. | ||
This means that you need to configure jest to correctly interpret them. | ||
You can do it either enabling jest [esm experimental support](https://jestjs.io/docs/ecmascript-modules), | ||
or using the [transformIgnorePatterns configuration](https://jestjs.io/docs/configuration#transformignorepatterns-arraystring). | ||
|
||
Since @zextras/carbonio-ui-preview now uses the module version of pdfjs worker, you will also need to add the mjs extension | ||
to the [transform configuration](https://jestjs.io/docs/configuration#transform-objectstring-pathtotransformer--pathtotransformer-object). | ||
|
||
Your jest config should look like this: | ||
|
||
```ts | ||
// jest.config.ts | ||
import type {Config} from 'jest'; | ||
|
||
const config: Config = { | ||
transform: { | ||
'^.+\\.[t|j]sx?$': ['babel-jest', { configFile: 'your custom config file - optional' }], | ||
'\\.mjs?$': ['babel-jest', { configFile: 'your custom config file - optional' }], | ||
// other transformers | ||
}, | ||
transformIgnorePatterns: [ | ||
// ignore all node_modules except the one in the array | ||
`/node_modules/(?!(${['@zextras/carbonio-ui-preview', 'pdfjs-dist'].join('|')}))`, | ||
'\\.pnp\\.[^\\/]+$' | ||
] | ||
}; | ||
|
||
export default config; | ||
``` | ||
|
||
#### Add the required polyfills in node versions < 22 | ||
|
||
If you run node in version previous to 22, you will need to polyfill some functions. | ||
|
||
You can simply import the required polyfills in the setup file. | ||
|
||
```ts | ||
// jest.config.ts | ||
import type {Config} from 'jest'; | ||
|
||
const config: Config = { | ||
// ... | ||
setupFilesAfterEnv: ['jest-env-setup.ts'], | ||
// ... | ||
}; | ||
|
||
export default config; | ||
``` | ||
|
||
```ts | ||
// jest-env-setup.ts | ||
|
||
import 'core-js/proposals/promise-with-resolvers'; | ||
// other imports | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.