diff --git a/CHANGELOG.md b/CHANGELOG.md index c09fa6b2f..3582bf13d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # rollup changelog +## 4.24.0 + +_2024-10-02_ + +### Features + +- Support preserving and transpiling JSX syntax (#5668) + +### Pull Requests + +- [#5668](https://github.com/rollup/rollup/pull/5668): Introduce JSX support (@lukastaegert, @Martin-Idel, @felixhuttmann, @AlexDroll, @tiptr) + ## 4.23.0 _2024-10-01_ diff --git a/browser/package.json b/browser/package.json index 4c6d456d7..ba17d092d 100644 --- a/browser/package.json +++ b/browser/package.json @@ -1,6 +1,6 @@ { "name": "@rollup/browser", - "version": "4.23.0", + "version": "4.24.0", "description": "Next-generation ES module bundler browser build", "main": "dist/rollup.browser.js", "module": "dist/es/rollup.browser.js", diff --git a/browser/src/path.ts b/browser/src/path.ts index bc72123e1..65b1d4a12 100644 --- a/browser/src/path.ts +++ b/browser/src/path.ts @@ -85,3 +85,7 @@ export function resolve(...paths: string[]): string { return resolvedParts.join('/'); } + +// Used for running the browser build locally in Vite +export const win32 = {}; +export const posix = {}; diff --git a/browser/src/wasm.ts b/browser/src/wasm.ts index c663b8ebd..afc48773f 100644 --- a/browser/src/wasm.ts +++ b/browser/src/wasm.ts @@ -5,7 +5,8 @@ import { parse } from '../../wasm/bindings_wasm.js'; export async function parseAsync( code: string, allowReturnOutsideFunction: boolean, + jsx: boolean, _signal?: AbortSignal | undefined | null ) { - return parse(code, allowReturnOutsideFunction); + return parse(code, allowReturnOutsideFunction, jsx); } diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 2b8c43c89..bf0f0811f 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -7,6 +7,7 @@ import replaceBrowserModules from '../../build-plugins/replace-browser-modules'; import '../declarations.d'; import { examplesPlugin } from './create-examples'; import { renderMermaidGraphsPlugin } from './mermaid'; +import { replacePathPicomatch } from './replace-path-picomatch'; import { transposeTables } from './transpose-tables'; import { buildEnd, callback, transformPageData } from './verify-anchors'; @@ -157,7 +158,10 @@ export default defineConfig({ title: 'Rollup 中文文档', transformPageData, vite: { + optimizeDeps: { exclude: ['@rollup/pluginutils'] }, plugins: [ + replacePathPicomatch(), + replaceBrowserModules(), renderMermaidGraphsPlugin(), replaceBrowserModules(), { diff --git a/docs/.vitepress/replace-path-picomatch.ts b/docs/.vitepress/replace-path-picomatch.ts new file mode 100644 index 000000000..16cd7871b --- /dev/null +++ b/docs/.vitepress/replace-path-picomatch.ts @@ -0,0 +1,22 @@ +import path from 'path'; +import type { Plugin } from 'vite'; + +export function replacePathPicomatch(): Plugin { + return { + enforce: 'pre', + load(id) { + if (id === 'picomatch') { + return 'export default {}'; + } + }, + name: 'replace-picomatch', + resolveId(source) { + if (source === 'picomatch') { + return { id: 'picomatch' }; + } + if (source === 'path') { + return path.resolve(__dirname, '../../browser/src/path.ts'); + } + } + }; +} diff --git a/docs/configuration-options/index.md b/docs/configuration-options/index.md index 902167281..a0009f23a 100755 --- a/docs/configuration-options/index.md +++ b/docs/configuration-options/index.md @@ -12,7 +12,7 @@ title: 配置选项 | | | | --: | :-- | -| 类型: | `(string \| RegExp)[]\| RegExp\| string\| (id: string, parentId: string, isResolved: boolean) => boolean` | +| 类型: | `(string \| RegExp)[] \| RegExp \| string \| (id: string, parentId: string, isResolved: boolean) => boolean` | | CLI: | `-e`/`--external ` | 该选项用于匹配需要排除在 bundle 外部的模块,它的值可以是一个接收模块 `id` 参数并返回 `true` (表示外部依赖)或 `false` (表示非外部依赖)的函数,也可以是一个模块 ID 数组或者正则表达式。除此之外,它还可以只是单个的模块 ID 或正则表达式。被匹配的模块 ID 应该满足以下条件之一: @@ -85,10 +85,10 @@ console.log(x); ### input {#input} -| | | -| -----: | :------------------------------------------------------ | -| 类型: | `string \| string []\| { [entryName: string]: string }` | -| CLI: | `-i`/`--input ` | +| | | +| -----: | :------------------------------------------------------- | +| 类型: | `string \| string [] \| { [entryName: string]: string }` | +| CLI: | `-i`/`--input ` | 该选项用于指定 bundle 的入口文件(例如,你的 `main.js`,`app.js` 或 `index.js` 文件)。如果值为一个入口文件的数组或一个将名称映射到入口文件的对象,那么它们将被打包到单独的输出 chunks。除非使用 [`output.file`](#output-file) 选项,否则生成的 chunk 名称将遵循 [`output.entryFileNames`](#output-entryfilenames) 选项设置。当该选项的值为对象形式时,对象的属性名将作为文件名中的 `[name]`,而对于值为数组形式,数组的值将作为入口文件名。 @@ -169,7 +169,183 @@ rollup main=src/entry1.js other=src/entry2.js --format es rollup "main entry"="src/entry 1.js" "src/other entry.js" --format es ``` -### output.dir {#output-dir} +### jsx + +| | | +| -----: | :--------------------------------- | +| 类型: | `false \| JsxPreset \| JsxOptions` | +| CLI: | `--jsx `/`--no-jsx` | +| 默认: | `false` | + +```typescript +type JsxPreset = 'react' | 'react-jsx' | 'preserve' | 'preserve-react'; + +type JsxOptions = + | { + mode: 'preserve'; + factory: string | null; + fragment: string | null; + importSource: string | null; + preset: JsxPreset | null; + } + | { + mode: 'classic'; + factory: string; + fragment: string; + importSource: string | null; + preset: JsxPreset | null; + } + | { + mode: 'automatic'; + factory: string; + importSource: string; + jsxImportSource: string; + preset: JsxPreset | null; + }; +``` + +允许 Rollup 处理 JSX 语法,可以根据 [`jsx.mode`](#jsx-mode) 保留或转换它。如果设置为 `false`,遇到 JSX 语法时将抛出错误。你也可以选择一个预设,将所有选项一起设置: + +- `"react"`:将 JSX 转译为 `React.createElement` 调用,其中 `React` 是从 `"react"` 默认导入的。这与在 TypeScript 编译器选项中设置 `"jsx": "react"` 类似。 + ```js + ({ + mode: 'classic', + factory: 'React.createElement', + fragment: 'React.Fragment', + importSource: 'react' + }); + ``` +- `"react-jsx"`:将使用 React 17 引入的新版优化后的 React 转换,类似于在 TypeScript 编译器选项中设置 `"jsx": "react-jsx"`。 + ```js + ({ + mode: 'automatic', + factory: 'React.createElement', + importSource: 'react', + jsxImportSource: 'react/jsx-runtime' + }); + ``` +- `"preserve"`:将在输出中保留 JSX。这仍然会去屑优化掉未使用的 JSX 代码,并且如果在输出中存在冲突,可能会重命名 JSX 标识符。 + ```js + ({ + mode: 'preserve', + factory: null, + fragment: null, + importSource: null + }); + ``` +- `"preserve-react"`:将在输出中保留 JSX,但确保 `"react"` 的默认导出作为名为 `React` 的变量在作用域中。 + ```js + ({ + mode: 'preserve', + factory: 'React.createElement', + fragment: 'React.Fragment', + importSource: 'react' + }); + ``` + +#### jsx.mode + +| | | +| -----: | :--------------------------------------- | +| 类型: | `"preserve" \| "classic" \| "automatic"` | +| CLI: | `--jsx.mode ` | +| 默认: | `"classic"` | + +该选项将决定如何处理 JSX: + +- `"preserve"`:将在输出中保持 JSX 语法。 +- `"classic"`:将执行 JSX 转换,因为旧版本的 React 或其他框架(例如 [Preact](https://preactjs.com))需要它。例如,以下是你如何为 Preact 配置 jsx 的方法: + + ```js + ({ + mode: 'classic', + factory: 'h', + fragment: 'Fragment', + importSource: 'preact' + }); + ``` + + 将执行以下转换: + + ```jsx + // 输入 + console.log(
hello
); + + // 输出 + import { h } from 'preact'; + console.log(/*#__PURE__*/ h('div', null, 'hello')); + ``` + +- `"automatic"`:将使用 React 17 引入的 [新版 JSX 转换](https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html) 执行 JSX 转换。在此模式下,Rollup 将尝试从 [`jsx.jsxImportSource`](#jsx-jsximportsource) 导入工具函数来转换 JSX。由于存在某些边界情况,当 [使用 `key` 属性和扩展属性](https://github.com/facebook/react/issues/20031#issuecomment-710346866) 时,此模式可能仍会回退到使用 `"classic"` 转换形式。为此,你仍然可以指定 `jsx.importSource`,`jsx.factory` 和 `jsx.fragment` 来配置 `"classic"` 模式。 + +#### jsx.factory + +| | | +| -----: | :-------------------------------- | +| 类型: | `string \| null` | +| CLI: | `--jsx.factory ` | +| 默认: | `"React.createElement"` or `null` | + +该选项为 Rollup 在 `"classic"` 模式或 `"automatic"` 模式的回退中用来创建 JSX 元素的函数。对于 React,这通常是 `React.createElement`,对于其他框架,则可能为 `h`。在 `"preserve"` 模式下,如果指定了 [`jsx.importSource`](#jsx-importsource),则将确保工厂函数在作用域中,否则同名的全局变量不会被局部变量覆盖。只有在 `"preserve"` 模式下,才可以将此值设置为 `null`,在这种情况下,Rollup 不会注意保持任何特定的工厂函数在作用域中。 + +如果值包含 `"."`,例如 `React.createElement`,并且指定了 `jsx.importSource`,Rollup 将假定左侧部分(例如 `React`)指的是 `jsx.importSource` 的默认导出。否则,Rollup 将假定它是一个命名导出。 + +#### jsx.fragment + +| | | +| -----: | :--------------------------- | +| 类型: | `string \| null` | +| CLI: | `--jsx.fragment ` | +| 默认: | `"React.Fragment"` or `null` | + +Rollup 用来创建 JSX 片段的元素函数。对于 React,这通常是 `React.Fragment`,对于其他框架,则是 `Fragment`。在 `"preserve"` 模式下,如果指定了 [`jsx.importSource`](#jsx-importsource),则将确保片段在作用域中,否则同名的全局变量不会被局部变量覆盖。只有在 `"preserve"` 模式下,才可以将此值设置为 `null`,在这种情况下,Rollup 不会注意保持任何特定的片段函数在作用域中。 + +如果值包含 `"."`,例如 `React.Fragment`,并且指定了 `jsx.importSource`,Rollup 将假定左边的部分(例如 `React`)指的是 `jsx.importSource` 的默认导出。否则,Rollup 将假定它是一个命名导出。 + +#### jsx.importSource + +| | | +| -----: | :----------------------------- | +| 类型: | `string \| null` | +| CLI: | `--jsx.importSource ` | +| 默认: | `null` | + +从哪里导入元素工厂函数及片段元素。如果设为 `null`,Rollup 将假定 [`jsx.factory`](#jsx-factory) 和 [`jsx.fragment`](#jsx-fragment) 指的是全局变量,并确保它们不会被同名的本地变量覆盖。 + +#### jsx.jsxImportSource + +| | | +| -----: | :-------------------------------- | +| 类型: | `string` | +| CLI: | `--jsx.jsxImportSource ` | +| 默认: | `"react/jsx-runtime"` | + +当使用 `"automatic"` 模式时,将指定从哪里导入进行该转换所需的 `jsx`、`jsxs` 和 `Fragment` 辅助函数。这些是无法从全局变量获取的。 + +#### jsx.preset + +| | | +| -----: | :--------------------- | +| 类型: | JsxPreset | +| CLI: | `--jsx.preset ` | + +允许选择上述预设中的一个,同时覆盖一些选项。 + +```js twoslash +// ---cut-start--- +/** @type {import('rollup').RollupOptions} */ +// ---cut-end--- +export default { + jsx: { + preset: 'react', + importSource: 'preact', + factory: 'h' + } + // ... +}; +``` + +### output.dir | | | | -----: | :--------------------- | @@ -208,7 +384,7 @@ rollup "main entry"="src/entry 1.js" "src/other entry.js" --format es | | | | --: | :-- | -| 类型: | `{ [id: string]: string }\| ((id: string) => string)` | +| 类型: | `{ [id: string]: string } \| ((id: string) => string)` | | CLI: | `-g`/`--globals ` | 该选项用于在 `umd` / `iife` bundle 中,使用 `id: variableName` 键值对指定外部依赖。例如,在这样的情况下: @@ -428,7 +604,7 @@ buildWithCache() | | | | -----: | :--------------------- | | 类型: | `LogLevel \| "silent"` | -| CLI: | `--logLevel ` | +| CLI: | `--logLevel ` | | 默认: | `"info"` | 该选项决定哪些日志将被处理。查看 [`onLog`](#onlog) 以了解可用的日志级别。默认的 `logLevel` 为 `"info"`,这意味着 info 和 warning 日志将被处理,而 debug 日志将被忽略,这意味着它们既不会传递给插件 [`onLog`](../plugin-development/index.md#onlog) 钩子,也不会传递给 `onLog` 选项或打印到控制台。 @@ -439,7 +615,7 @@ buildWithCache() | | | | --: | :-- | -| 类型: | `boolean\| "ifRelativeSource"` | +| 类型: | `boolean \| "ifRelativeSource"` | | CLI: | `--makeAbsoluteExternalsRelative`/`--no-makeAbsoluteExternalsRelative` | | 默认: | `"ifRelativeSource"` | @@ -469,7 +645,7 @@ buildWithCache() | | | | --: | :-- | -| Type: | `(level: LogLevel, log: RollupLog, defaultHandler: LogOrStringHandler) => void;` | +| 类型: | `(level: LogLevel, log: RollupLog, defaultHandler: LogOrStringHandler) => void;` | ```typescript type LogLevel = 'warn' | 'info' | 'debug'; @@ -566,11 +742,11 @@ export default { ### output.assetFileNames {#output-assetfilenames} -| | | -| -----: | :--------------------------------------------------- | -| 类型: | `string\| ((assetInfo: PreRenderedAsset) => string)` | -| CLI: | `--assetFileNames ` | -| 默认: | `"assets/[name]-[hash][extname]"` | +| | | +| -----: | :---------------------------------------------------- | +| 类型: | `string \| ((assetInfo: PreRenderedAsset) => string)` | +| CLI: | `--assetFileNames ` | +| 默认: | `"assets/[name]-[hash][extname]"` | ```typescript interface PreRenderedAsset { @@ -594,7 +770,7 @@ interface PreRenderedAsset { | | | | --: | :-- | -| 类型: | `string \| ((chunk: RenderedChunk) => string\| Promise)` | +| 类型: | `string \| ((chunk: RenderedChunk) => string \| Promise)` | | CLI: | `--banner`/`--footer ` | 查看 [`renderChunk`](../plugin-development/index.md#renderchunk) 钩子以了解 `RenderedChunk` 类型。 @@ -758,7 +934,7 @@ Promise.resolve() | | | | --: | :-- | -| 类型: | `"es5" \| "es2015"\| { arrowFunctions?: boolean, constBindings?: boolean, objectShorthand?: boolean, preset?: "es5"\| "es2015", reservedNamesAsProps?: boolean, symbols?: boolean }` | +| 类型: | `"es5" \| "es2015" \| { arrowFunctions?: boolean, constBindings?: boolean, objectShorthand?: boolean, preset?: "es5" \| "es2015", reservedNamesAsProps?: boolean, symbols?: boolean }` | | CLI: | `--generatedCode ` | | 默认: | `"es5"` | @@ -980,7 +1156,7 @@ exports.foo = foo; | | | | --: | :-- | -| 类型: | `"compat" \| "auto"\| "esModule"\| "default"\| "defaultOnly"\| ((id: string) => "compat"\| "auto"\| "esModule"\| "default"\| "defaultOnly")` | +| 类型: | `"compat" \| "auto" \| "esModule" \| "default" \| "defaultOnly" \| ((id: string) => "compat" \| "auto" \| "esModule" \| "default" \| "defaultOnly")` | | CLI: | `--interop ` | | 默认: | `"default"` | @@ -1241,7 +1417,7 @@ import('external2').then(console.log); | | | | --: | :-- | -| 类型: | `string \| ((chunk: RenderedChunk) => string\| Promise)` | +| 类型: | `string \| ((chunk: RenderedChunk) => string \| Promise)` | | CLI: | `--intro`/`--outro ` | 除了在特定格式中代码不同外,该选项功能和 [`output.banner/output.footer`](#output-banner-output-footer) 类似。 @@ -1553,7 +1729,7 @@ export default { | | | | -----: | :---------------------------------- | -| 类型: | `boolean \| 'inline'\| 'hidden'` | +| 类型: | `boolean \| 'inline' \| 'hidden'` | | CLI: | `-m`/`--sourcemap`/`--no-sourcemap` | | 默认: | `false` | @@ -1594,7 +1770,7 @@ export default { | | | | -----: | :---------------------------------------------------- | | 类型: | `string \| ((chunkInfo: PreRenderedChunk) => string)` | -| CLI: | `--sourcemapFileNames ` | +| CLI: | `--sourcemapFileNames ` | 查看 [`output.chunkFileNames`](#output-chunkfilenames) 以了解 `PreRenderedChunk` 类型。 @@ -1696,7 +1872,7 @@ export default { | | | | --: | :-- | -| 类型: | `"strict" \| "allow-extension" \| "exports-only"\| false` | +| 类型: | `"strict" \| "allow-extension" \| "exports-only" \| false` | | CLI: | `--preserveEntrySignatures `/`--no-preserveEntrySignatures` | | 默认: | `"exports-only"` | @@ -1975,11 +2151,11 @@ export default { ### output.exports {#output-exports} -| | | -| -----: | :--------------------------------------- | -| 类型: | `"auto" \| "default"\| "named"\| "none"` | -| CLI: | `--exports ` | -| 默认: | `'auto'` | +| | | +| -----: | :----------------------------------------- | +| 类型: | `"auto" \| "default" \| "named" \| "none"` | +| CLI: | `--exports ` | +| 默认: | `'auto'` | 该选项用于指定导出模式。默认是 `auto`,指根据 `input` 模块导出推测你的意图: @@ -2232,7 +2408,7 @@ export const x = 'next to original'; | | | | -----: | :--------------------------------------------------- | | 类型: | `boolean \| TreeshakingPreset \| TreeshakingOptions` | -| CLI: | `--treeshake`/`--no-treeshake` | +| CLI: | `--treeshake `/`--no-treeshake` | | 默认: | `true` | ```typescript @@ -2398,7 +2574,7 @@ styled().div(); // 去除 | | | | --: | :-- | -| 类型: | `boolean\| "no-external"\| string[]\| (id: string, external: boolean) => boolean` | +| 类型: | `boolean \| "no-external" \| string[] \| (id: string, external: boolean) => boolean` | | CLI: | `--treeshake.moduleSideEffects`/`--no-treeshake.moduleSideEffects`/`--treeshake.moduleSideEffects no-external` | | 默认: | `true` | @@ -2486,10 +2662,10 @@ console.log(foo); #### treeshake.preset {#treeshake-preset} -| | | -| -----: | :--------------------------------------- | -| 类型: | `"smallest" \| "safest"\| "recommended"` | -| CLI: | `--treeshake `
| +| | | +| -----: | :---------------------------------------- | +| 类型: | `"smallest" \| "safest" \| "recommended"` | +| CLI: | `--treeshake `
| 该选项可以选择上面列出的预设之一,同时覆盖一些选项。 @@ -2510,7 +2686,7 @@ export default { | | | | --: | :-- | -| 类型: | `boolean\| 'always'` | +| 类型: | `boolean \| 'always'` | | CLI: | `--treeshake.propertyReadSideEffects`/`--no-treeshake.propertyReadSideEffects` | | 默认: | `true` | @@ -2631,7 +2807,7 @@ const element = angular.element; | | | | ----: | :---------------------------------- | | 类型: | `number` | -| CLI: | `--experimentalMinChunkSize ` | +| CLI: | `--experimentalMinChunkSize ` | | 默认: | `1` | 该选项用于为代码分割设置一个以字节为单位的最小 chunk 大小。当该值设置为默认值 `1` 时,Rollup 将尝试将不包含代码(仅包含导入和重新导出)的块合并到其他 chunk 中。仅当合并不会改变任何入口加载时执行的副作用时,才会执行合并。对于值为 `1` 的情况,仅允许执行不增加任何入口加载的代码量的合并。 @@ -2733,10 +2909,10 @@ export default [ ### watch.exclude {#watch-exclude} -| | | -| -----: | :--------------------------------------- | -| 类型: | `string \| RegExp\| (string\| RegExp)[]` | -| CLI: | `--watch.exclude ` | +| | | +| -----: | :----------------------------------------- | +| 类型: | `string \| RegExp \| (string \| RegExp)[]` | +| CLI: | `--watch.exclude ` | 该选项用于指定不需要被 watch 的文件: @@ -2755,10 +2931,10 @@ export default { ### watch.include {#watch-include} -| | | -| -----: | :--------------------------------------- | -| 类型: | `string \| RegExp\| (string\| RegExp)[]` | -| CLI: | `--watch.include ` | +| | | +| -----: | :----------------------------------------- | +| 类型: | `string \| RegExp \| (string \| RegExp)[]` | +| CLI: | `--watch.include ` | 该选项用于限制只能对指定文件进行观察。请注意,该选项只过滤模块图中的文件,不允许添加额外的观察文件: diff --git a/docs/repl/examples/00/example.json b/docs/repl/examples/00/example.json index fc26cd645..85411ac64 100644 --- a/docs/repl/examples/00/example.json +++ b/docs/repl/examples/00/example.json @@ -1,6 +1,9 @@ { - "title": "除屑优化(Tree-shaking)", + "title": "具名导出(Named exports)", "options": { - "treeshake": true + "output": { + "exports": "auto", + "esModule": "if-default-prop" + } } } diff --git a/docs/repl/examples/00/modules/main.js b/docs/repl/examples/00/modules/main.js index 285f90bcc..7ec206be2 100644 --- a/docs/repl/examples/00/modules/main.js +++ b/docs/repl/examples/00/modules/main.js @@ -1,4 +1,17 @@ -// 除屑优化 -import { cube } from './maths.js'; +// 具名导出 +// 有很多种方法可以从 ES2015 模块中 +// 导出绑定 +export var foo = 1; -console.log(cube(5)); // 125 +export function bar() { + // 在生成 CommonJS 时 + // 尝试将此更改为 `foo++` + return foo; +} + +function baz() { + return bar(); +} + +export * from './qux'; +export { baz }; diff --git a/docs/repl/examples/01/modules/qux.js b/docs/repl/examples/00/modules/qux.js similarity index 100% rename from docs/repl/examples/01/modules/qux.js rename to docs/repl/examples/00/modules/qux.js diff --git a/docs/repl/examples/01/example.json b/docs/repl/examples/01/example.json index 85411ac64..fc26cd645 100644 --- a/docs/repl/examples/01/example.json +++ b/docs/repl/examples/01/example.json @@ -1,9 +1,6 @@ { - "title": "具名导出(Named exports)", + "title": "除屑优化(Tree-shaking)", "options": { - "output": { - "exports": "auto", - "esModule": "if-default-prop" - } + "treeshake": true } } diff --git a/docs/repl/examples/01/modules/main.js b/docs/repl/examples/01/modules/main.js index 7ec206be2..285f90bcc 100644 --- a/docs/repl/examples/01/modules/main.js +++ b/docs/repl/examples/01/modules/main.js @@ -1,17 +1,4 @@ -// 具名导出 -// 有很多种方法可以从 ES2015 模块中 -// 导出绑定 -export var foo = 1; +// 除屑优化 +import { cube } from './maths.js'; -export function bar() { - // 在生成 CommonJS 时 - // 尝试将此更改为 `foo++` - return foo; -} - -function baz() { - return bar(); -} - -export * from './qux'; -export { baz }; +console.log(cube(5)); // 125 diff --git a/docs/repl/examples/00/modules/maths.js b/docs/repl/examples/01/modules/maths.js similarity index 100% rename from docs/repl/examples/00/modules/maths.js rename to docs/repl/examples/01/modules/maths.js diff --git a/docs/repl/examples/07/example.json b/docs/repl/examples/07/example.json index 8eb33b9ed..303986a52 100644 --- a/docs/repl/examples/07/example.json +++ b/docs/repl/examples/07/example.json @@ -1,10 +1,10 @@ { - "title": "多个入口模块", - "entryModules": ["main.js", "otherEntry.js"], - "options": { - "output": { - "minifyInternalExports": false, - "preserveModules": false - } - } + "title": "多个入口模块", + "entryModules": ["main.js", "otherEntry.js"], + "options": { + "output": { + "minifyInternalExports": false, + "preserveModules": false + } + } } diff --git a/docs/repl/examples/08/example.json b/docs/repl/examples/08/example.json new file mode 100644 index 000000000..f085d76c5 --- /dev/null +++ b/docs/repl/examples/08/example.json @@ -0,0 +1,8 @@ +{ + "title": "JSX", + "options": { + "jsx": { + "mode": "preserve" + } + } +} diff --git a/docs/repl/examples/08/modules/main.js b/docs/repl/examples/08/modules/main.js new file mode 100644 index 000000000..e9744cbb6 --- /dev/null +++ b/docs/repl/examples/08/modules/main.js @@ -0,0 +1,6 @@ +// JSX SUPPORT +// Try different jsx.mode and see how it is transformed +import './other.js'; +const Foo = ({ world }) =>
Hello {world}!
; + +console.log(); diff --git a/docs/repl/examples/08/modules/other.js b/docs/repl/examples/08/modules/other.js new file mode 100644 index 000000000..724d561c1 --- /dev/null +++ b/docs/repl/examples/08/modules/other.js @@ -0,0 +1,2 @@ +const Foo = () =>
This is deconflicted!
; +console.log(); diff --git a/docs/repl/stores/options.ts b/docs/repl/stores/options.ts index 0f1fd0371..b8207c94e 100644 --- a/docs/repl/stores/options.ts +++ b/docs/repl/stores/options.ts @@ -114,6 +114,7 @@ export const useOptions = defineStore('options2', () => { return value != null && interopFormats.has(value); }); const externalImports = computed(() => rollupOutputStore.output?.externalImports || []); + const isJsxEnabled = computed(() => optionJsx.value.value === true); const isTreeshakeEnabled = computed(() => [undefined, true].includes(optionTreeshake.value.value as any) ); @@ -375,6 +376,39 @@ export const useOptions = defineStore('options2', () => { defaultValue: false, name: 'shimMissingExports' }); + const optionJsx = getSelect({ + defaultValue: false, + name: 'jsx', + options: () => [false, true, 'preserve', 'preserve-react', 'react', 'react-jsx'] + }); + const optionJsxFactory = getString({ + available: isJsxEnabled, + name: 'jsx.factory' + }); + const optionJsxFragment = getString({ + available: computed(() => isJsxEnabled.value && optionJsxMode.value.value !== 'automatic'), + name: 'jsx.fragment' + }); + const optionJsxImportSource = getString({ + available: isJsxEnabled, + name: 'jsx.importSource' + }); + const optionJsxJsxImportSource = getString({ + available: computed(() => isJsxEnabled.value && optionJsxMode.value.value === 'automatic'), + name: 'jsx.jsxImportSource' + }); + const optionJsxMode = getSelect({ + available: isJsxEnabled, + defaultValue: 'classic', + name: 'jsx.mode', + options: () => ['classic', 'automatic', 'preserve'] + }); + const optionJsxPreset = getSelect({ + available: isJsxEnabled, + defaultValue: null, + name: 'jsx.preset', + options: () => [null, 'preserve', 'preserve-react', 'react', 'react-jsx'] + }); const optionTreeshake = getSelect({ defaultValue: true, name: 'treeshake', @@ -422,6 +456,13 @@ export const useOptions = defineStore('options2', () => { const optionList: OptionType[] = [ optionContext, optionExperimentalLogSideEffects, + optionJsx, + optionJsxMode, + optionJsxFactory, + optionJsxFragment, + optionJsxImportSource, + optionJsxJsxImportSource, + optionJsxPreset, optionOutputAmdAutoId, optionOutputAmdBasePath, optionOutputAmdDefine, @@ -511,7 +552,8 @@ export const useOptions = defineStore('options2', () => { while ((key = path.shift())) { subOptions = subOptions?.[key]; } - value.value = name === 'treeshake' && typeof subOptions === 'object' ? true : subOptions; + value.value = + ['jsx', 'treeshake'].includes(name) && typeof subOptions === 'object' ? true : subOptions; } } }; @@ -652,7 +694,7 @@ function getOptionsObject(options: Ref): Ref { let key: string | undefined; let subOptions: any = object; while ((key = path.shift())) { - // Special logic to handle treeshake option + // Special logic to handle jsx/treeshake option if (subOptions[key] === true) { subOptions[key] = {}; } diff --git a/docs/repl/stores/rollup.ts b/docs/repl/stores/rollup.ts index e79140a32..fb2d84df2 100644 --- a/docs/repl/stores/rollup.ts +++ b/docs/repl/stores/rollup.ts @@ -117,6 +117,7 @@ export const useRollup = defineStore('rollup', () => { instance }; } catch (error) { + console.error(error); loaded.value = { error: error as Error, instance: null diff --git a/native.d.ts b/native.d.ts index 0085313ac..0047a3ee4 100644 --- a/native.d.ts +++ b/native.d.ts @@ -3,8 +3,8 @@ /* auto-generated by NAPI-RS */ -export declare function parse(code: string, allowReturnOutsideFunction: boolean): Buffer -export declare function parseAsync(code: string, allowReturnOutsideFunction: boolean, signal?: AbortSignal | undefined | null): Promise +export declare function parse(code: string, allowReturnOutsideFunction: boolean, jsx: boolean): Buffer +export declare function parseAsync(code: string, allowReturnOutsideFunction: boolean, jsx: boolean, signal?: AbortSignal | undefined | null): Promise export declare function xxhashBase64Url(input: Uint8Array): string export declare function xxhashBase36(input: Uint8Array): string export declare function xxhashBase16(input: Uint8Array): string diff --git a/package-lock.json b/package-lock.json index 7ce0abdcf..b8aac0a7c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rollup", - "version": "4.23.0", + "version": "4.24.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rollup", - "version": "4.23.0", + "version": "4.24.0", "license": "MIT", "dependencies": { "@types/estree": "1.0.6" @@ -20,7 +20,7 @@ "@codemirror/language": "^6.10.3", "@codemirror/search": "^6.5.6", "@codemirror/state": "^6.4.1", - "@codemirror/view": "^6.33.0", + "@codemirror/view": "^6.34.1", "@eslint/js": "^9.11.1", "@inquirer/prompts": "^6.0.1", "@jridgewell/sourcemap-codec": "^1.5.0", @@ -35,14 +35,15 @@ "@rollup/plugin-terser": "^0.4.4", "@rollup/plugin-typescript": "^12.1.0", "@rollup/pluginutils": "^5.1.2", - "@shikijs/vitepress-twoslash": "^1.18.0", + "@shikijs/vitepress-twoslash": "^1.21.0", "@types/mocha": "^10.0.8", - "@types/node": "^18.19.50", + "@types/node": "^18.19.54", "@types/semver": "^7.5.8", "@types/yargs-parser": "^21.0.3", "@vue/language-server": "^2.1.6", "acorn": "^8.12.1", "acorn-import-assertions": "^1.9.0", + "acorn-jsx": "^5.3.2", "buble": "^0.20.0", "builtin-modules": "^4.0.0", "chokidar": "^3.6.0", @@ -72,13 +73,13 @@ "nodemon": "^3.1.7", "npm-audit-resolver": "^3.0.0-RC.0", "nyc": "^17.1.0", - "pinia": "^2.2.2", + "pinia": "^2.2.3", "prettier": "^3.3.3", "prettier-plugin-organize-imports": "^4.1.0", "pretty-bytes": "^6.1.1", "pretty-ms": "^9.1.0", "requirejs": "^2.3.7", - "rollup": "^4.22.4", + "rollup": "^4.22.5", "rollup-plugin-license": "^3.5.3", "rollup-plugin-string": "^3.0.0", "semver": "^7.6.3", @@ -87,13 +88,13 @@ "source-map": "^0.7.4", "source-map-support": "^0.5.21", "systemjs": "^6.15.1", - "terser": "^5.33.0", + "terser": "^5.34.1", "tslib": "^2.7.0", "typescript": "^5.6.2", - "typescript-eslint": "^8.7.0", - "vite": "^5.4.7", + "typescript-eslint": "^8.8.0", + "vite": "^5.4.8", "vitepress": "^1.3.4", - "vue": "^3.5.8", + "vue": "^3.5.10", "vue-tsc": "^2.1.6", "wasm-pack": "^0.13.0", "yargs-parser": "^21.1.1" @@ -254,9 +255,9 @@ } }, "node_modules/@algolia/client-common": { - "version": "5.6.1", - "resolved": "https://registry.npmjs.org/@algolia/client-common/-/client-common-5.6.1.tgz", - "integrity": "sha512-4MGqXqiAyqsUJw+KamKWZO2Gxn9iMpc05vC0vy8+iQRjKRZEDB1a+3Da6CnkWzXa162pJb7a/chDAAKA9rye8A==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@algolia/client-common/-/client-common-5.7.0.tgz", + "integrity": "sha512-hrYlN9yNQukmNj8bBlw9PCXi9jmRQqNUXaG6MXH1aDabjO6YD1WPVqTvaELbIBgTbDJzCn0R2owms0uaxQkjUg==", "dev": true, "license": "MIT", "peer": true, @@ -288,17 +289,17 @@ } }, "node_modules/@algolia/client-search": { - "version": "5.6.1", - "resolved": "https://registry.npmjs.org/@algolia/client-search/-/client-search-5.6.1.tgz", - "integrity": "sha512-HloeR0Ef29vf2yJc1lhjw1OYial3YgB0f3TQaqqMlSnM/IkAw9TnX1IOYLurnI91apMKggFpA9t8lRp7TGEKEg==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@algolia/client-search/-/client-search-5.7.0.tgz", + "integrity": "sha512-0Frfjt4oxvVP2qsTQAjwdaG5SvJ3TbHBkBrS6M7cG5RDrgHqOrhBnBGCFT+YO3CeNK54r+d57oB1VcD2F1lHuQ==", "dev": true, "license": "MIT", "peer": true, "dependencies": { - "@algolia/client-common": "5.6.1", - "@algolia/requester-browser-xhr": "5.6.1", - "@algolia/requester-fetch": "5.6.1", - "@algolia/requester-node-http": "5.6.1" + "@algolia/client-common": "5.7.0", + "@algolia/requester-browser-xhr": "5.7.0", + "@algolia/requester-fetch": "5.7.0", + "@algolia/requester-node-http": "5.7.0" }, "engines": { "node": ">= 14.0.0" @@ -385,14 +386,14 @@ } }, "node_modules/@algolia/requester-browser-xhr": { - "version": "5.6.1", - "resolved": "https://registry.npmjs.org/@algolia/requester-browser-xhr/-/requester-browser-xhr-5.6.1.tgz", - "integrity": "sha512-tY1RW60sGF9sMpxbd8j53IqLLwnkNhrAarVhFfNZzDZNvI8WyzG78W5ZD/SFvtkgNPPSav3T/3LpBT8xBpzbGw==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@algolia/requester-browser-xhr/-/requester-browser-xhr-5.7.0.tgz", + "integrity": "sha512-ohtIp+lyTGM3agrHyedC3w7ijfdUvSN6wmGuKqUezrNzd0nCkFoLW0OINlyv1ODrTEVnL8PAM/Zqubjafxd/Ww==", "dev": true, "license": "MIT", "peer": true, "dependencies": { - "@algolia/client-common": "5.6.1" + "@algolia/client-common": "5.7.0" }, "engines": { "node": ">= 14.0.0" @@ -406,28 +407,28 @@ "license": "MIT" }, "node_modules/@algolia/requester-fetch": { - "version": "5.6.1", - "resolved": "https://registry.npmjs.org/@algolia/requester-fetch/-/requester-fetch-5.6.1.tgz", - "integrity": "sha512-4TvR5IodrH+o+ji4ka+VBufWY0GfHr43nFqnDTStabtjspfo4rlcV16x534vvnbfp694oBxrz0SO/Ny8VemvXg==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@algolia/requester-fetch/-/requester-fetch-5.7.0.tgz", + "integrity": "sha512-Eg8cBhNg2QNnDDldyK77aXvg3wIc5qnpCDCAJXQ2oaqZwwvvYaTgnP1ofznNG6+klri4Fk1YAaC9wyDBhByWIA==", "dev": true, "license": "MIT", "peer": true, "dependencies": { - "@algolia/client-common": "5.6.1" + "@algolia/client-common": "5.7.0" }, "engines": { "node": ">= 14.0.0" } }, "node_modules/@algolia/requester-node-http": { - "version": "5.6.1", - "resolved": "https://registry.npmjs.org/@algolia/requester-node-http/-/requester-node-http-5.6.1.tgz", - "integrity": "sha512-K7tlss87aq6UnWnU8+fPIe+Is9Mvyqwzysp6Ty/HpQ7YNKUU7opgkMOVKxzTwt3fm40NfNX4ENvVKHoYABL6vw==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@algolia/requester-node-http/-/requester-node-http-5.7.0.tgz", + "integrity": "sha512-8BDssYEkcp1co06KtHO9b37H+5zVM/h+5kyesJb2C2EHFO3kgzLHWl/JyXOVtYlKQBkmdObYOI0s6JaXRy2yQA==", "dev": true, "license": "MIT", "peer": true, "dependencies": { - "@algolia/client-common": "5.6.1" + "@algolia/client-common": "5.7.0" }, "engines": { "node": ">= 14.0.0" @@ -484,13 +485,13 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.24.7.tgz", - "integrity": "sha512-BcYH1CVJBO9tvyIZ2jVeXgSIMvGZ2FDRvDdOIVQyuklNKSsx+eppDEBq/g47Ayw+RqNFE+URvOShmf+f/qwAlA==", + "version": "7.25.7", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.25.7.tgz", + "integrity": "sha512-0xZJFNE5XMpENsgfHYTw8FbX4kv53mFLn2i3XPoq69LyhYSCBJtitaHx9QnsVTrsogI4Z3+HtEfZ2/GFPOtf5g==", "dev": true, "license": "MIT", "dependencies": { - "@babel/highlight": "^7.24.7", + "@babel/highlight": "^7.25.7", "picocolors": "^1.0.0" }, "engines": { @@ -498,9 +499,9 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.25.4", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.25.4.tgz", - "integrity": "sha512-+LGRog6RAsCJrrrg/IO6LGmpphNe5DiK30dGjCoxxeGv49B10/3XYGxPsAwrDlMFcFEvdAUavDT8r9k/hSyQqQ==", + "version": "7.25.7", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.25.7.tgz", + "integrity": "sha512-9ickoLz+hcXCeh7jrcin+/SLWm+GkxE2kTvoYyp38p4WkdFXfQJxDFGWp/YHjiKLPx06z2A7W8XKuqbReXDzsw==", "dev": true, "license": "MIT", "engines": { @@ -508,22 +509,22 @@ } }, "node_modules/@babel/core": { - "version": "7.25.2", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.25.2.tgz", - "integrity": "sha512-BBt3opiCOxUr9euZ5/ro/Xv8/V7yJ5bjYMqG/C1YAo8MIKAnumZalCN+msbci3Pigy4lIQfPUpfMM27HMGaYEA==", + "version": "7.25.7", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.25.7.tgz", + "integrity": "sha512-yJ474Zv3cwiSOO9nXJuqzvwEeM+chDuQ8GJirw+pZ91sCGCyOZ3dJkVE09fTV0VEVzXyLWhh3G/AolYTPX7Mow==", "dev": true, "license": "MIT", "dependencies": { "@ampproject/remapping": "^2.2.0", - "@babel/code-frame": "^7.24.7", - "@babel/generator": "^7.25.0", - "@babel/helper-compilation-targets": "^7.25.2", - "@babel/helper-module-transforms": "^7.25.2", - "@babel/helpers": "^7.25.0", - "@babel/parser": "^7.25.0", - "@babel/template": "^7.25.0", - "@babel/traverse": "^7.25.2", - "@babel/types": "^7.25.2", + "@babel/code-frame": "^7.25.7", + "@babel/generator": "^7.25.7", + "@babel/helper-compilation-targets": "^7.25.7", + "@babel/helper-module-transforms": "^7.25.7", + "@babel/helpers": "^7.25.7", + "@babel/parser": "^7.25.7", + "@babel/template": "^7.25.7", + "@babel/traverse": "^7.25.7", + "@babel/types": "^7.25.7", "convert-source-map": "^2.0.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", @@ -546,44 +547,31 @@ "license": "MIT" }, "node_modules/@babel/generator": { - "version": "7.25.6", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.25.6.tgz", - "integrity": "sha512-VPC82gr1seXOpkjAAKoLhP50vx4vGNlF4msF64dSFq1P8RfB+QAuJWGHPXXPc8QyfVWwwB/TNNU4+ayZmHNbZw==", + "version": "7.25.7", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.25.7.tgz", + "integrity": "sha512-5Dqpl5fyV9pIAD62yK9P7fcA768uVPUyrQmqpqstHWgMma4feF1x/oFysBCVZLY5wJ2GkMUCdsNDnGZrPoR6rA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/types": "^7.25.6", + "@babel/types": "^7.25.7", "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.25", - "jsesc": "^2.5.1" + "jsesc": "^3.0.2" }, "engines": { "node": ">=6.9.0" } }, - "node_modules/@babel/generator/node_modules/jsesc": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", - "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", - "dev": true, - "license": "MIT", - "bin": { - "jsesc": "bin/jsesc" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.25.2", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.25.2.tgz", - "integrity": "sha512-U2U5LsSaZ7TAt3cfaymQ8WHh0pxvdHoEk6HVpaexxixjyEquMh0L0YNJNM6CTGKMXV1iksi0iZkGw4AcFkPaaw==", + "version": "7.25.7", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.25.7.tgz", + "integrity": "sha512-DniTEax0sv6isaw6qSQSfV4gVRNtw2rte8HHM45t9ZR0xILaufBRNkpMifCRiAPyvL4ACD6v0gfCwCmtOQaV4A==", "dev": true, "license": "MIT", "dependencies": { - "@babel/compat-data": "^7.25.2", - "@babel/helper-validator-option": "^7.24.8", - "browserslist": "^4.23.1", + "@babel/compat-data": "^7.25.7", + "@babel/helper-validator-option": "^7.25.7", + "browserslist": "^4.24.0", "lru-cache": "^5.1.1", "semver": "^6.3.1" }, @@ -592,30 +580,30 @@ } }, "node_modules/@babel/helper-module-imports": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.24.7.tgz", - "integrity": "sha512-8AyH3C+74cgCVVXow/myrynrAGv+nTVg5vKu2nZph9x7RcRwzmh0VFallJuFTZ9mx6u4eSdXZfcOzSqTUm0HCA==", + "version": "7.25.7", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.25.7.tgz", + "integrity": "sha512-o0xCgpNmRohmnoWKQ0Ij8IdddjyBFE4T2kagL/x6M3+4zUgc+4qTOUBoNe4XxDskt1HPKO007ZPiMgLDq2s7Kw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/traverse": "^7.24.7", - "@babel/types": "^7.24.7" + "@babel/traverse": "^7.25.7", + "@babel/types": "^7.25.7" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-module-transforms": { - "version": "7.25.2", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.25.2.tgz", - "integrity": "sha512-BjyRAbix6j/wv83ftcVJmBt72QtHI56C7JXZoG2xATiLpmoC7dpd8WnkikExHDVPpi/3qCmO6WY1EaXOluiecQ==", + "version": "7.25.7", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.25.7.tgz", + "integrity": "sha512-k/6f8dKG3yDz/qCwSM+RKovjMix563SLxQFo0UhRNo239SP6n9u5/eLtKD6EAjwta2JHJ49CsD8pms2HdNiMMQ==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-module-imports": "^7.24.7", - "@babel/helper-simple-access": "^7.24.7", - "@babel/helper-validator-identifier": "^7.24.7", - "@babel/traverse": "^7.25.2" + "@babel/helper-module-imports": "^7.25.7", + "@babel/helper-simple-access": "^7.25.7", + "@babel/helper-validator-identifier": "^7.25.7", + "@babel/traverse": "^7.25.7" }, "engines": { "node": ">=6.9.0" @@ -625,23 +613,23 @@ } }, "node_modules/@babel/helper-simple-access": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.24.7.tgz", - "integrity": "sha512-zBAIvbCMh5Ts+b86r/CjU+4XGYIs+R1j951gxI3KmmxBMhCg4oQMsv6ZXQ64XOm/cvzfU1FmoCyt6+owc5QMYg==", + "version": "7.25.7", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.25.7.tgz", + "integrity": "sha512-FPGAkJmyoChQeM+ruBGIDyrT2tKfZJO8NcxdC+CWNJi7N8/rZpSxK7yvBJ5O/nF1gfu5KzN7VKG3YVSLFfRSxQ==", "dev": true, "license": "MIT", "dependencies": { - "@babel/traverse": "^7.24.7", - "@babel/types": "^7.24.7" + "@babel/traverse": "^7.25.7", + "@babel/types": "^7.25.7" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-string-parser": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.24.8.tgz", - "integrity": "sha512-pO9KhhRcuUyGnJWwyEgnRJTSIZHiT+vMD0kPeD+so0l7mxkMT19g3pjY9GTnHySck/hDzq+dtW/4VgnMkippsQ==", + "version": "7.25.7", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.7.tgz", + "integrity": "sha512-CbkjYdsJNHFk8uqpEkpCvRs3YRp9tY6FmFY7wLMSYuGYkrdUi7r2lc4/wqsvlHoMznX3WJ9IP8giGPq68T/Y6g==", "dev": true, "license": "MIT", "engines": { @@ -649,9 +637,9 @@ } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.24.7.tgz", - "integrity": "sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==", + "version": "7.25.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.7.tgz", + "integrity": "sha512-AM6TzwYqGChO45oiuPqwL2t20/HdMC1rTPAesnBCgPCSF1x3oN9MVUwQV2iyz4xqWrctwK5RNC8LV22kaQCNYg==", "dev": true, "license": "MIT", "engines": { @@ -659,9 +647,9 @@ } }, "node_modules/@babel/helper-validator-option": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.24.8.tgz", - "integrity": "sha512-xb8t9tD1MHLungh/AIoWYN+gVHaB9kwlu8gffXGSt3FFEIT7RjS+xWbc2vUD1UTZdIpKj/ab3rdqJ7ufngyi2Q==", + "version": "7.25.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.25.7.tgz", + "integrity": "sha512-ytbPLsm+GjArDYXJ8Ydr1c/KJuutjF2besPNbIZnZ6MKUxi/uTA22t2ymmA4WFjZFpjiAMO0xuuJPqK2nvDVfQ==", "dev": true, "license": "MIT", "engines": { @@ -669,27 +657,27 @@ } }, "node_modules/@babel/helpers": { - "version": "7.25.6", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.25.6.tgz", - "integrity": "sha512-Xg0tn4HcfTijTwfDwYlvVCl43V6h4KyVVX2aEm4qdO/PC6L2YvzLHFdmxhoeSA3eslcE6+ZVXHgWwopXYLNq4Q==", + "version": "7.25.7", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.25.7.tgz", + "integrity": "sha512-Sv6pASx7Esm38KQpF/U/OXLwPPrdGHNKoeblRxgZRLXnAtnkEe4ptJPDtAZM7fBLadbc1Q07kQpSiGQ0Jg6tRA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/template": "^7.25.0", - "@babel/types": "^7.25.6" + "@babel/template": "^7.25.7", + "@babel/types": "^7.25.7" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/highlight": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.24.7.tgz", - "integrity": "sha512-EStJpq4OuY8xYfhGVXngigBJRWxftKX9ksiGDnmlY3o7B/V7KIAc9X4oiK87uPJSc/vs5L869bem5fhZa8caZw==", + "version": "7.25.7", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.25.7.tgz", + "integrity": "sha512-iYyACpW3iW8Fw+ZybQK+drQre+ns/tKpXbNESfrhNnPLIklLbXr7MYJ6gPEd0iETGLOK+SxMjVvKb/ffmk+FEw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-validator-identifier": "^7.24.7", + "@babel/helper-validator-identifier": "^7.25.7", "chalk": "^2.4.2", "js-tokens": "^4.0.0", "picocolors": "^1.0.0" @@ -760,13 +748,13 @@ } }, "node_modules/@babel/parser": { - "version": "7.25.6", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.6.tgz", - "integrity": "sha512-trGdfBdbD0l1ZPmcJ83eNxB9rbEax4ALFTF7fN386TMYbeCQbyme5cOEXQhbGXKebwGaB/J52w1mrklMcbgy6Q==", + "version": "7.25.7", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.7.tgz", + "integrity": "sha512-aZn7ETtQsjjGG5HruveUK06cU3Hljuhd9Iojm4M8WWv3wLE6OkE5PWbDUkItmMgegmccaITudyuW5RPYrYlgWw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/types": "^7.25.6" + "@babel/types": "^7.25.7" }, "bin": { "parser": "bin/babel-parser.js" @@ -776,32 +764,32 @@ } }, "node_modules/@babel/template": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.25.0.tgz", - "integrity": "sha512-aOOgh1/5XzKvg1jvVz7AVrx2piJ2XBi227DHmbY6y+bM9H2FlN+IfecYu4Xl0cNiiVejlsCri89LUsbj8vJD9Q==", + "version": "7.25.7", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.25.7.tgz", + "integrity": "sha512-wRwtAgI3bAS+JGU2upWNL9lSlDcRCqD05BZ1n3X2ONLH1WilFP6O1otQjeMK/1g0pvYcXC7b/qVUB1keofjtZA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.24.7", - "@babel/parser": "^7.25.0", - "@babel/types": "^7.25.0" + "@babel/code-frame": "^7.25.7", + "@babel/parser": "^7.25.7", + "@babel/types": "^7.25.7" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.25.6", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.6.tgz", - "integrity": "sha512-9Vrcx5ZW6UwK5tvqsj0nGpp/XzqthkT0dqIc9g1AdtygFToNtTF67XzYS//dm+SAK9cp3B9R4ZO/46p63SCjlQ==", + "version": "7.25.7", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.7.tgz", + "integrity": "sha512-jatJPT1Zjqvh/1FyJs6qAHL+Dzb7sTb+xr7Q+gM1b+1oBsMsQQ4FkVKb6dFlJvLlVssqkRzV05Jzervt9yhnzg==", "dev": true, "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.24.7", - "@babel/generator": "^7.25.6", - "@babel/parser": "^7.25.6", - "@babel/template": "^7.25.0", - "@babel/types": "^7.25.6", + "@babel/code-frame": "^7.25.7", + "@babel/generator": "^7.25.7", + "@babel/parser": "^7.25.7", + "@babel/template": "^7.25.7", + "@babel/types": "^7.25.7", "debug": "^4.3.1", "globals": "^11.1.0" }, @@ -820,14 +808,14 @@ } }, "node_modules/@babel/types": { - "version": "7.25.6", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.6.tgz", - "integrity": "sha512-/l42B1qxpG6RdfYf343Uw1vmDjeNhneUXtzhojE7pDgfpEypmRhI6j1kr17XCVv4Cgl9HdAiQY2x0GwKm7rWCw==", + "version": "7.25.7", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.7.tgz", + "integrity": "sha512-vwIVdXG+j+FOpkwqHRcBgHLYNL7XMkufrlaFvL9o6Ai9sJn9+PdyIL5qa0XzTZw084c+u9LOls53eoZWP/W5WQ==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-string-parser": "^7.24.8", - "@babel/helper-validator-identifier": "^7.24.7", + "@babel/helper-string-parser": "^7.25.7", + "@babel/helper-validator-identifier": "^7.25.7", "to-fast-properties": "^2.0.0" }, "engines": { @@ -980,9 +968,9 @@ "license": "MIT" }, "node_modules/@codemirror/view": { - "version": "6.34.0", - "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.34.0.tgz", - "integrity": "sha512-2vKJ79tOcVfgPYVJM2XjcL1BH5Bsl7/tgn9ilBj3XWeCS5kTRy/NE4FHEj4aMylOl/D3IPNsmZH0WPlB+DyIdA==", + "version": "6.34.1", + "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.34.1.tgz", + "integrity": "sha512-t1zK/l9UiRqwUNPm+pdIT0qzJlzuVckbTEMVNFhfWkGiBQClstzg+78vedCvLSX0xJEZ6lwZbPpnljL7L6iwMQ==", "dev": true, "license": "MIT", "dependencies": { @@ -992,33 +980,33 @@ } }, "node_modules/@docsearch/css": { - "version": "3.6.1", - "resolved": "https://registry.npmjs.org/@docsearch/css/-/css-3.6.1.tgz", - "integrity": "sha512-VtVb5DS+0hRIprU2CO6ZQjK2Zg4QU5HrDM1+ix6rT0umsYvFvatMAnf97NHZlVWDaaLlx7GRfR/7FikANiM2Fg==", + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/@docsearch/css/-/css-3.6.2.tgz", + "integrity": "sha512-vKNZepO2j7MrYBTZIGXvlUOIR+v9KRf70FApRgovWrj3GTs1EITz/Xb0AOlm1xsQBp16clVZj1SY/qaOJbQtZw==", "dev": true, "license": "MIT" }, "node_modules/@docsearch/js": { - "version": "3.6.1", - "resolved": "https://registry.npmjs.org/@docsearch/js/-/js-3.6.1.tgz", - "integrity": "sha512-erI3RRZurDr1xES5hvYJ3Imp7jtrXj6f1xYIzDzxiS7nNBufYWPbJwrmMqWC5g9y165PmxEmN9pklGCdLi0Iqg==", + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/@docsearch/js/-/js-3.6.2.tgz", + "integrity": "sha512-pS4YZF+VzUogYrkblCucQ0Oy2m8Wggk8Kk7lECmZM60hTbaydSIhJTTiCrmoxtBqV8wxORnOqcqqOfbmkkQEcA==", "dev": true, "license": "MIT", "dependencies": { - "@docsearch/react": "3.6.1", + "@docsearch/react": "3.6.2", "preact": "^10.0.0" } }, "node_modules/@docsearch/react": { - "version": "3.6.1", - "resolved": "https://registry.npmjs.org/@docsearch/react/-/react-3.6.1.tgz", - "integrity": "sha512-qXZkEPvybVhSXj0K7U3bXc233tk5e8PfhoZ6MhPOiik/qUQxYC+Dn9DnoS7CxHQQhHfCvTiN0eY9M12oRghEXw==", + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/@docsearch/react/-/react-3.6.2.tgz", + "integrity": "sha512-rtZce46OOkVflCQH71IdbXSFK+S8iJZlUF56XBW5rIgx/eG5qoomC7Ag3anZson1bBac/JFQn7XOBfved/IMRA==", "dev": true, "license": "MIT", "dependencies": { "@algolia/autocomplete-core": "1.9.3", "@algolia/autocomplete-preset-algolia": "1.9.3", - "@docsearch/css": "3.6.1", + "@docsearch/css": "3.6.2", "algoliasearch": "^4.19.1" }, "peerDependencies": { @@ -1047,6 +1035,7 @@ "resolved": "https://registry.npmjs.org/@emmetio/abbreviation/-/abbreviation-2.3.3.tgz", "integrity": "sha512-mgv58UrU3rh4YgbE/TzgLQwJ3pFsHHhCLqY20aJq+9comytTXUDNGG/SMtSeMJdkpxgXSXunBGLD8Boka3JyVA==", "dev": true, + "license": "MIT", "dependencies": { "@emmetio/scanner": "^1.0.4" } @@ -1056,6 +1045,7 @@ "resolved": "https://registry.npmjs.org/@emmetio/css-abbreviation/-/css-abbreviation-2.1.8.tgz", "integrity": "sha512-s9yjhJ6saOO/uk1V74eifykk2CBYi01STTK3WlXWGOepyKa23ymJ053+DNQjpFcy1ingpaO7AxCcwLvHFY9tuw==", "dev": true, + "license": "MIT", "dependencies": { "@emmetio/scanner": "^1.0.4" } @@ -1065,6 +1055,7 @@ "resolved": "https://registry.npmjs.org/@emmetio/css-parser/-/css-parser-0.4.0.tgz", "integrity": "sha512-z7wkxRSZgrQHXVzObGkXG+Vmj3uRlpM11oCZ9pbaz0nFejvCDmAiNDpY75+wgXOcffKpj4rzGtwGaZxfJKsJxw==", "dev": true, + "license": "MIT", "dependencies": { "@emmetio/stream-reader": "^2.2.0", "@emmetio/stream-reader-utils": "^0.1.0" @@ -1075,6 +1066,7 @@ "resolved": "https://registry.npmjs.org/@emmetio/html-matcher/-/html-matcher-1.3.0.tgz", "integrity": "sha512-NTbsvppE5eVyBMuyGfVu2CRrLvo7J4YHb6t9sBFLyY03WYhXET37qA4zOYUjBWFCRHO7pS1B9khERtY0f5JXPQ==", "dev": true, + "license": "ISC", "dependencies": { "@emmetio/scanner": "^1.0.0" } @@ -1083,19 +1075,22 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/@emmetio/scanner/-/scanner-1.0.4.tgz", "integrity": "sha512-IqRuJtQff7YHHBk4G8YZ45uB9BaAGcwQeVzgj/zj8/UdOhtQpEIupUhSk8dys6spFIWVZVeK20CzGEnqR5SbqA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@emmetio/stream-reader": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/@emmetio/stream-reader/-/stream-reader-2.2.0.tgz", "integrity": "sha512-fXVXEyFA5Yv3M3n8sUGT7+fvecGrZP4k6FnWWMSZVQf69kAq0LLpaBQLGcPR30m3zMmKYhECP4k/ZkzvhEW5kw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@emmetio/stream-reader-utils": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/@emmetio/stream-reader-utils/-/stream-reader-utils-0.1.0.tgz", "integrity": "sha512-ZsZ2I9Vzso3Ho/pjZFsmmZ++FWeEd/txqybHTm4OgaZzdS8V9V/YYWQwg5TC38Z7uLWUV1vavpLLbjJtKubR1A==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@esbuild/aix-ppc64": { "version": "0.21.5", @@ -1542,6 +1537,30 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, + "node_modules/@eslint/config-array/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/@eslint/config-array/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/@eslint/core": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.6.0.tgz", @@ -1576,6 +1595,17 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/@eslint/eslintrc/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, "node_modules/@eslint/eslintrc/node_modules/globals": { "version": "14.0.0", "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", @@ -1589,6 +1619,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/@eslint/eslintrc/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/@eslint/js": { "version": "9.11.1", "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.11.1.tgz", @@ -1756,9 +1799,9 @@ } }, "node_modules/@inquirer/core/node_modules/@types/node": { - "version": "22.7.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.3.tgz", - "integrity": "sha512-qXKfhXXqGTyBskvWEzJZPUxSslAiLaB6JGP1ic/XTH9ctGgzdgYguuLP1C601aRTSDNlLb0jbKqXjZ48GNraSA==", + "version": "22.7.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.4.tgz", + "integrity": "sha512-y+NPi1rFzDs1NdQHHToqeiX2TIS79SWEAw9GYhkkx8bD0ChpfqC+n2j5OXOCpzfojBEBt6DnEnnG9MY0zk1XLg==", "dev": true, "license": "MIT", "dependencies": { @@ -2066,7 +2109,8 @@ "version": "0.2.2", "resolved": "https://registry.npmjs.org/@johnsoncodehk/pug-beautify/-/pug-beautify-0.2.2.tgz", "integrity": "sha512-qqNS/YD0Nck5wtQLCPHAfGVgWbbGafxSPjNh0ekYPFSNNqnDH2kamnduzYly8IiADmeVx/MfAE1njMEjVeHTMA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.5", @@ -2141,9 +2185,9 @@ "optional": true }, "node_modules/@lezer/common": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.2.1.tgz", - "integrity": "sha512-yemX0ZD2xS/73llMZIK6KplkjIjf2EvAHcinDi/TfJ9hS25G0388+ClHt6/3but0oOxinTcQHJLDXh6w1crzFQ==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.2.2.tgz", + "integrity": "sha512-Z+R3hN6kXbgBWAuejUNPihylAL1Z5CaFqnIe0nTX8Ej+XlIy3EGtXxn6WtLMO+os2hRkQvm2yvaGMYliUzlJaw==", "dev": true, "license": "MIT" }, @@ -2559,9 +2603,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.22.4.tgz", - "integrity": "sha512-Fxamp4aEZnfPOcGA8KSNEohV8hX7zVHOemC8jVBoBUHu5zpJK/Eu3uJwt6BMgy9fkvzxDaurgj96F/NiLukF2w==", + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.24.0.tgz", + "integrity": "sha512-Q6HJd7Y6xdB48x8ZNVDOqsbh2uByBhgK8PiQgPhwkIw/HC/YX5Ghq2mQY5sRMZWHb3VsFkWooUVOZHKr7DmDIA==", "cpu": [ "arm" ], @@ -2573,9 +2617,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.22.4.tgz", - "integrity": "sha512-VXoK5UMrgECLYaMuGuVTOx5kcuap1Jm8g/M83RnCHBKOqvPPmROFJGQaZhGccnsFtfXQ3XYa4/jMCJvZnbJBdA==", + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.24.0.tgz", + "integrity": "sha512-ijLnS1qFId8xhKjT81uBHuuJp2lU4x2yxa4ctFPtG+MqEE6+C5f/+X/bStmxapgmwLwiL3ih122xv8kVARNAZA==", "cpu": [ "arm64" ], @@ -2587,9 +2631,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.22.4.tgz", - "integrity": "sha512-xMM9ORBqu81jyMKCDP+SZDhnX2QEVQzTcC6G18KlTQEzWK8r/oNZtKuZaCcHhnsa6fEeOBionoyl5JsAbE/36Q==", + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.24.0.tgz", + "integrity": "sha512-bIv+X9xeSs1XCk6DVvkO+S/z8/2AMt/2lMqdQbMrmVpgFvXlmde9mLcbQpztXm1tajC3raFDqegsH18HQPMYtA==", "cpu": [ "arm64" ], @@ -2601,9 +2645,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.22.4.tgz", - "integrity": "sha512-aJJyYKQwbHuhTUrjWjxEvGnNNBCnmpHDvrb8JFDbeSH3m2XdHcxDd3jthAzvmoI8w/kSjd2y0udT+4okADsZIw==", + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.24.0.tgz", + "integrity": "sha512-X6/nOwoFN7RT2svEQWUsW/5C/fYMBe4fnLK9DQk4SX4mgVBiTA9h64kjUYPvGQ0F/9xwJ5U5UfTbl6BEjaQdBQ==", "cpu": [ "x64" ], @@ -2615,9 +2659,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.22.4.tgz", - "integrity": "sha512-j63YtCIRAzbO+gC2L9dWXRh5BFetsv0j0va0Wi9epXDgU/XUi5dJKo4USTttVyK7fGw2nPWK0PbAvyliz50SCQ==", + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.24.0.tgz", + "integrity": "sha512-0KXvIJQMOImLCVCz9uvvdPgfyWo93aHHp8ui3FrtOP57svqrF/roSSR5pjqL2hcMp0ljeGlU4q9o/rQaAQ3AYA==", "cpu": [ "arm" ], @@ -2629,9 +2673,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.22.4.tgz", - "integrity": "sha512-dJnWUgwWBX1YBRsuKKMOlXCzh2Wu1mlHzv20TpqEsfdZLb3WoJW2kIEsGwLkroYf24IrPAvOT/ZQ2OYMV6vlrg==", + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.24.0.tgz", + "integrity": "sha512-it2BW6kKFVh8xk/BnHfakEeoLPv8STIISekpoF+nBgWM4d55CZKc7T4Dx1pEbTnYm/xEKMgy1MNtYuoA8RFIWw==", "cpu": [ "arm" ], @@ -2643,9 +2687,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.22.4.tgz", - "integrity": "sha512-AdPRoNi3NKVLolCN/Sp4F4N1d98c4SBnHMKoLuiG6RXgoZ4sllseuGioszumnPGmPM2O7qaAX/IJdeDU8f26Aw==", + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.24.0.tgz", + "integrity": "sha512-i0xTLXjqap2eRfulFVlSnM5dEbTVque/3Pi4g2y7cxrs7+a9De42z4XxKLYJ7+OhE3IgxvfQM7vQc43bwTgPwA==", "cpu": [ "arm64" ], @@ -2657,9 +2701,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.22.4.tgz", - "integrity": "sha512-Gl0AxBtDg8uoAn5CCqQDMqAx22Wx22pjDOjBdmG0VIWX3qUBHzYmOKh8KXHL4UpogfJ14G4wk16EQogF+v8hmA==", + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.24.0.tgz", + "integrity": "sha512-9E6MKUJhDuDh604Qco5yP/3qn3y7SLXYuiC0Rpr89aMScS2UAmK1wHP2b7KAa1nSjWJc/f/Lc0Wl1L47qjiyQw==", "cpu": [ "arm64" ], @@ -2671,9 +2715,9 @@ ] }, "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.22.4.tgz", - "integrity": "sha512-3aVCK9xfWW1oGQpTsYJJPF6bfpWfhbRnhdlyhak2ZiyFLDaayz0EP5j9V1RVLAAxlmWKTDfS9wyRyY3hvhPoOg==", + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.24.0.tgz", + "integrity": "sha512-2XFFPJ2XMEiF5Zi2EBf4h73oR1V/lycirxZxHZNc93SqDN/IWhYYSYj8I9381ikUFXZrz2v7r2tOVk2NBwxrWw==", "cpu": [ "ppc64" ], @@ -2685,9 +2729,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.22.4.tgz", - "integrity": "sha512-ePYIir6VYnhgv2C5Xe9u+ico4t8sZWXschR6fMgoPUK31yQu7hTEJb7bCqivHECwIClJfKgE7zYsh1qTP3WHUA==", + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.24.0.tgz", + "integrity": "sha512-M3Dg4hlwuntUCdzU7KjYqbbd+BLq3JMAOhCKdBE3TcMGMZbKkDdJ5ivNdehOssMCIokNHFOsv7DO4rlEOfyKpg==", "cpu": [ "riscv64" ], @@ -2699,9 +2743,9 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.22.4.tgz", - "integrity": "sha512-GqFJ9wLlbB9daxhVlrTe61vJtEY99/xB3C8e4ULVsVfflcpmR6c8UZXjtkMA6FhNONhj2eA5Tk9uAVw5orEs4Q==", + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.24.0.tgz", + "integrity": "sha512-mjBaoo4ocxJppTorZVKWFpy1bfFj9FeCMJqzlMQGjpNPY9JwQi7OuS1axzNIk0nMX6jSgy6ZURDZ2w0QW6D56g==", "cpu": [ "s390x" ], @@ -2713,9 +2757,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.22.4.tgz", - "integrity": "sha512-87v0ol2sH9GE3cLQLNEy0K/R0pz1nvg76o8M5nhMR0+Q+BBGLnb35P0fVz4CQxHYXaAOhE8HhlkaZfsdUOlHwg==", + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.24.0.tgz", + "integrity": "sha512-ZXFk7M72R0YYFN5q13niV0B7G8/5dcQ9JDp8keJSfr3GoZeXEoMHP/HlvqROA3OMbMdfr19IjCeNAnPUG93b6A==", "cpu": [ "x64" ], @@ -2727,9 +2771,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.22.4.tgz", - "integrity": "sha512-UV6FZMUgePDZrFjrNGIWzDo/vABebuXBhJEqrHxrGiU6HikPy0Z3LfdtciIttEUQfuDdCn8fqh7wiFJjCNwO+g==", + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.24.0.tgz", + "integrity": "sha512-w1i+L7kAXZNdYl+vFvzSZy8Y1arS7vMgIy8wusXJzRrPyof5LAb02KGr1PD2EkRcl73kHulIID0M501lN+vobQ==", "cpu": [ "x64" ], @@ -2741,9 +2785,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.22.4.tgz", - "integrity": "sha512-BjI+NVVEGAXjGWYHz/vv0pBqfGoUH0IGZ0cICTn7kB9PyjrATSkX+8WkguNjWoj2qSr1im/+tTGRaY+4/PdcQw==", + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.24.0.tgz", + "integrity": "sha512-VXBrnPWgBpVDCVY6XF3LEW0pOU51KbaHhccHw6AS6vBWIC60eqsH19DAeeObl+g8nKAz04QFdl/Cefta0xQtUQ==", "cpu": [ "arm64" ], @@ -2755,9 +2799,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.22.4.tgz", - "integrity": "sha512-SiWG/1TuUdPvYmzmYnmd3IEifzR61Tragkbx9D3+R8mzQqDBz8v+BvZNDlkiTtI9T15KYZhP0ehn3Dld4n9J5g==", + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.24.0.tgz", + "integrity": "sha512-xrNcGDU0OxVcPTH/8n/ShH4UevZxKIO6HJFK0e15XItZP2UcaiLFd5kiX7hJnqCbSztUF8Qot+JWBC/QXRPYWQ==", "cpu": [ "ia32" ], @@ -2769,9 +2813,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.22.4.tgz", - "integrity": "sha512-j8pPKp53/lq9lMXN57S8cFz0MynJk8OWNuUnXct/9KCpKU7DgU3bYMJhwWmcqC0UU29p8Lr0/7KEVcaM6bf47Q==", + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.24.0.tgz", + "integrity": "sha512-fbMkAF7fufku0N2dE5TBXcNlg0pt0cJue4xBRE2Qc5Vqikxr4VCgKj/ht6SMdFcOacVA9rqF70APJ8RN/4vMJw==", "cpu": [ "x64" ], @@ -2783,69 +2827,69 @@ ] }, "node_modules/@shikijs/core": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.20.0.tgz", - "integrity": "sha512-KlO3iE0THzSdYkzDFugt8SHe6FR3qNYTkmpbdW1d6xo8juQkMjybxAw/cBi2npL2eb2F4PbbnSs5Z9tDusfvyg==", + "version": "1.21.0", + "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.21.0.tgz", + "integrity": "sha512-zAPMJdiGuqXpZQ+pWNezQAk5xhzRXBNiECFPcJLtUdsFM3f//G95Z15EHTnHchYycU8kIIysqGgxp8OVSj1SPQ==", "dev": true, "license": "MIT", "dependencies": { - "@shikijs/engine-javascript": "1.20.0", - "@shikijs/engine-oniguruma": "1.20.0", - "@shikijs/types": "1.20.0", + "@shikijs/engine-javascript": "1.21.0", + "@shikijs/engine-oniguruma": "1.21.0", + "@shikijs/types": "1.21.0", "@shikijs/vscode-textmate": "^9.2.2", "@types/hast": "^3.0.4", "hast-util-to-html": "^9.0.3" } }, "node_modules/@shikijs/engine-javascript": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-1.20.0.tgz", - "integrity": "sha512-ZUMo758uduM0Tfgzi/kd+0IKMbNdumCxxWjY36uf1DIs2Qyg9HIq3vA1Wfa/vc6HE7tHWFpANRi3mv7UzJ68MQ==", + "version": "1.21.0", + "resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-1.21.0.tgz", + "integrity": "sha512-jxQHNtVP17edFW4/0vICqAVLDAxmyV31MQJL4U/Kg+heQALeKYVOWo0sMmEZ18FqBt+9UCdyqGKYE7bLRtk9mg==", "dev": true, "license": "MIT", "dependencies": { - "@shikijs/types": "1.20.0", + "@shikijs/types": "1.21.0", "@shikijs/vscode-textmate": "^9.2.2", "oniguruma-to-js": "0.4.3" } }, "node_modules/@shikijs/engine-oniguruma": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-1.20.0.tgz", - "integrity": "sha512-MQ40WkVTZk7by33ces4PGK6XNFSo6PYvKTSAr2kTWdRNhFmOcnaX+1XzvFwB26eySXR7U74t91czZ1qJkEgxTA==", + "version": "1.21.0", + "resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-1.21.0.tgz", + "integrity": "sha512-AIZ76XocENCrtYzVU7S4GY/HL+tgHGbVU+qhiDyNw1qgCA5OSi4B4+HY4BtAoJSMGuD/L5hfTzoRVbzEm2WTvg==", "dev": true, "license": "MIT", "dependencies": { - "@shikijs/types": "1.20.0", + "@shikijs/types": "1.21.0", "@shikijs/vscode-textmate": "^9.2.2" } }, "node_modules/@shikijs/transformers": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/@shikijs/transformers/-/transformers-1.20.0.tgz", - "integrity": "sha512-TNS5KAErbNIOm1QqabuVaU77NOs5xWfpjpnqME059SA8yddr3mN5ZNAeCI+4QAAnNqZd8RKXjp+9hw66f5ak/A==", + "version": "1.21.0", + "resolved": "https://registry.npmjs.org/@shikijs/transformers/-/transformers-1.21.0.tgz", + "integrity": "sha512-aA+XGGSzipcvqdsOYL8l6Q2RYiMuJNdhdt9eZnkJmW+wjSOixN/I7dBq3fISwvEMDlawrtuXM3eybLCEC+Fjlg==", "dev": true, "license": "MIT", "dependencies": { - "shiki": "1.20.0" + "shiki": "1.21.0" } }, "node_modules/@shikijs/twoslash": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/@shikijs/twoslash/-/twoslash-1.20.0.tgz", - "integrity": "sha512-NGaZgluqyo/P8r35/y82lhGtHjQaDlFTpmRzl/T+aNMshatcOsTvMN9uVWSNy83di1VGTxhH4ruX0xUsOAgdtg==", + "version": "1.21.0", + "resolved": "https://registry.npmjs.org/@shikijs/twoslash/-/twoslash-1.21.0.tgz", + "integrity": "sha512-91HTpoIsx6vsJZ0DE1fs/jNeEAL5xJ5hWMVPUSp3iGHxOLH59nGrOcsjSgv4lKaxeE2i6VFvnPANQ5q8I5k2AQ==", "dev": true, "license": "MIT", "dependencies": { - "@shikijs/core": "1.20.0", - "@shikijs/types": "1.20.0", - "twoslash": "^0.2.11" + "@shikijs/core": "1.21.0", + "@shikijs/types": "1.21.0", + "twoslash": "^0.2.12" } }, "node_modules/@shikijs/types": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/@shikijs/types/-/types-1.20.0.tgz", - "integrity": "sha512-y+EaDvU2K6/GaXOKXxJaGnr1XtmZMF7MfS0pSEDdxEq66gCtKsLwQvVwoQFdp7R7dLlNAro3ijEE19sMZ0pzqg==", + "version": "1.21.0", + "resolved": "https://registry.npmjs.org/@shikijs/types/-/types-1.21.0.tgz", + "integrity": "sha512-tzndANDhi5DUndBtpojEq/42+dpUF2wS7wdCDQaFtIXm3Rd1QkrcVgSSRLOvEwexekihOXfbYJINW37g96tJRw==", "dev": true, "license": "MIT", "dependencies": { @@ -2854,9 +2898,9 @@ } }, "node_modules/@shikijs/vitepress-twoslash": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/@shikijs/vitepress-twoslash/-/vitepress-twoslash-1.20.0.tgz", - "integrity": "sha512-9/BqSp1yF0QQ5jVXX/KbIVnwaw+14NJfcw4r1RAWIVykDUvXKO16dSmdV4UlRVh6VyrtF2EFdoFCvVnllrKccQ==", + "version": "1.21.0", + "resolved": "https://registry.npmjs.org/@shikijs/vitepress-twoslash/-/vitepress-twoslash-1.21.0.tgz", + "integrity": "sha512-/B/edWFxZ6Tdfj0Jj+jxJOKsHRd89NZ57tK0E68kvaWbbnBw3UaLCixDL+SvdeGFMov2uN1URXgCdBQTR6daZg==", "dev": true, "license": "MIT", "dependencies": { @@ -2865,10 +2909,10 @@ "mdast-util-from-markdown": "^2.0.1", "mdast-util-gfm": "^3.0.0", "mdast-util-to-hast": "^13.2.0", - "shiki": "1.20.0", - "twoslash": "^0.2.11", - "twoslash-vue": "^0.2.11", - "vue": "^3.5.9" + "shiki": "1.21.0", + "twoslash": "^0.2.12", + "twoslash-vue": "^0.2.12", + "vue": "^3.5.10" } }, "node_modules/@shikijs/vscode-textmate": { @@ -2916,19 +2960,6 @@ "@types/ms": "*" } }, - "node_modules/@types/eslint": { - "version": "9.6.1", - "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-9.6.1.tgz", - "integrity": "sha512-FXx2pKgId/WyYo2jXw63kk7/+TY7u7AziEJxJAnSFzHlqTAS3Ync6SvgYAN/k4/PQpnnVuzoMuVnByKK2qp0ag==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "@types/estree": "*", - "@types/json-schema": "*" - } - }, "node_modules/@types/estree": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", @@ -3047,9 +3078,9 @@ } }, "node_modules/@types/node": { - "version": "18.19.53", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.53.tgz", - "integrity": "sha512-GLxgUgHhDKO1Edw9Q0lvMbiO/IQXJwJlMaqxSGBXMpPy8uhkCs2iiPFaB2Q/gmobnFkckD3rqTBMVjXdwq+nKg==", + "version": "18.19.54", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.54.tgz", + "integrity": "sha512-+BRgt0G5gYjTvdLac9sIeE0iZcJxi4Jc4PV5EUzqi+88jmQLr+fRZdv2tCTV7IHKSGxM6SaLoOXQWWUiLUItMw==", "dev": true, "license": "MIT", "dependencies": { @@ -3129,17 +3160,17 @@ } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.7.0.tgz", - "integrity": "sha512-RIHOoznhA3CCfSTFiB6kBGLQtB/sox+pJ6jeFu6FxJvqL8qRxq/FfGO/UhsGgQM9oGdXkV4xUgli+dt26biB6A==", + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.8.0.tgz", + "integrity": "sha512-wORFWjU30B2WJ/aXBfOm1LX9v9nyt9D3jsSOxC3cCaTQGCW5k4jNpmjFv3U7p/7s4yvdjHzwtv2Sd2dOyhjS0A==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/regexpp": "^4.10.0", - "@typescript-eslint/scope-manager": "8.7.0", - "@typescript-eslint/type-utils": "8.7.0", - "@typescript-eslint/utils": "8.7.0", - "@typescript-eslint/visitor-keys": "8.7.0", + "@typescript-eslint/scope-manager": "8.8.0", + "@typescript-eslint/type-utils": "8.8.0", + "@typescript-eslint/utils": "8.8.0", + "@typescript-eslint/visitor-keys": "8.8.0", "graphemer": "^1.4.0", "ignore": "^5.3.1", "natural-compare": "^1.4.0", @@ -3163,16 +3194,16 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.7.0.tgz", - "integrity": "sha512-lN0btVpj2unxHlNYLI//BQ7nzbMJYBVQX5+pbNXvGYazdlgYonMn4AhhHifQ+J4fGRYA/m1DjaQjx+fDetqBOQ==", + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.8.0.tgz", + "integrity": "sha512-uEFUsgR+tl8GmzmLjRqz+VrDv4eoaMqMXW7ruXfgThaAShO9JTciKpEsB+TvnfFfbg5IpujgMXVV36gOJRLtZg==", "dev": true, "license": "BSD-2-Clause", "dependencies": { - "@typescript-eslint/scope-manager": "8.7.0", - "@typescript-eslint/types": "8.7.0", - "@typescript-eslint/typescript-estree": "8.7.0", - "@typescript-eslint/visitor-keys": "8.7.0", + "@typescript-eslint/scope-manager": "8.8.0", + "@typescript-eslint/types": "8.8.0", + "@typescript-eslint/typescript-estree": "8.8.0", + "@typescript-eslint/visitor-keys": "8.8.0", "debug": "^4.3.4" }, "engines": { @@ -3192,14 +3223,14 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.7.0.tgz", - "integrity": "sha512-87rC0k3ZlDOuz82zzXRtQ7Akv3GKhHs0ti4YcbAJtaomllXoSO8hi7Ix3ccEvCd824dy9aIX+j3d2UMAfCtVpg==", + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.8.0.tgz", + "integrity": "sha512-EL8eaGC6gx3jDd8GwEFEV091210U97J0jeEHrAYvIYosmEGet4wJ+g0SYmLu+oRiAwbSA5AVrt6DxLHfdd+bUg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.7.0", - "@typescript-eslint/visitor-keys": "8.7.0" + "@typescript-eslint/types": "8.8.0", + "@typescript-eslint/visitor-keys": "8.8.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -3210,14 +3241,14 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.7.0.tgz", - "integrity": "sha512-tl0N0Mj3hMSkEYhLkjREp54OSb/FI6qyCzfiiclvJvOqre6hsZTGSnHtmFLDU8TIM62G7ygEa1bI08lcuRwEnQ==", + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.8.0.tgz", + "integrity": "sha512-IKwJSS7bCqyCeG4NVGxnOP6lLT9Okc3Zj8hLO96bpMkJab+10HIfJbMouLrlpyOr3yrQ1cA413YPFiGd1mW9/Q==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/typescript-estree": "8.7.0", - "@typescript-eslint/utils": "8.7.0", + "@typescript-eslint/typescript-estree": "8.8.0", + "@typescript-eslint/utils": "8.8.0", "debug": "^4.3.4", "ts-api-utils": "^1.3.0" }, @@ -3235,9 +3266,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.7.0.tgz", - "integrity": "sha512-LLt4BLHFwSfASHSF2K29SZ+ZCsbQOM+LuarPjRUuHm+Qd09hSe3GCeaQbcCr+Mik+0QFRmep/FyZBO6fJ64U3w==", + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.8.0.tgz", + "integrity": "sha512-QJwc50hRCgBd/k12sTykOJbESe1RrzmX6COk8Y525C9l7oweZ+1lw9JiU56im7Amm8swlz00DRIlxMYLizr2Vw==", "dev": true, "license": "MIT", "engines": { @@ -3249,14 +3280,14 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.7.0.tgz", - "integrity": "sha512-MC8nmcGHsmfAKxwnluTQpNqceniT8SteVwd2voYlmiSWGOtjvGXdPl17dYu2797GVscK30Z04WRM28CrKS9WOg==", + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.8.0.tgz", + "integrity": "sha512-ZaMJwc/0ckLz5DaAZ+pNLmHv8AMVGtfWxZe/x2JVEkD5LnmhWiQMMcYT7IY7gkdJuzJ9P14fRy28lUrlDSWYdw==", "dev": true, "license": "BSD-2-Clause", "dependencies": { - "@typescript-eslint/types": "8.7.0", - "@typescript-eslint/visitor-keys": "8.7.0", + "@typescript-eslint/types": "8.8.0", + "@typescript-eslint/visitor-keys": "8.8.0", "debug": "^4.3.4", "fast-glob": "^3.3.2", "is-glob": "^4.0.3", @@ -3277,43 +3308,17 @@ } } }, - "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", - "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/@typescript-eslint/utils": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.7.0.tgz", - "integrity": "sha512-ZbdUdwsl2X/s3CiyAu3gOlfQzpbuG3nTWKPoIvAu1pu5r8viiJvv2NPN2AqArL35NCYtw/lrPPfM4gxrMLNLPw==", + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.8.0.tgz", + "integrity": "sha512-QE2MgfOTem00qrlPgyByaCHay9yb1+9BjnMFnSFkUKQfu7adBXDTnCAivURnuPPAG/qiB+kzKkZKmKfaMT0zVg==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/scope-manager": "8.7.0", - "@typescript-eslint/types": "8.7.0", - "@typescript-eslint/typescript-estree": "8.7.0" + "@typescript-eslint/scope-manager": "8.8.0", + "@typescript-eslint/types": "8.8.0", + "@typescript-eslint/typescript-estree": "8.8.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -3327,13 +3332,13 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.7.0.tgz", - "integrity": "sha512-b1tx0orFCCh/THWPQa2ZwWzvOeyzzp36vkJYOpVg0u8UVOIsfVrnuC9FqAw9gRKn+rG2VmWQ/zDJZzkxUnj/XQ==", + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.8.0.tgz", + "integrity": "sha512-8mq51Lx6Hpmd7HnA2fcHQo3YgfX1qbccxQOgZcb4tvasu//zXRaA1j5ZRFeCw/VRAdFi4mRM9DnZw0Nu0Q2d1g==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.7.0", + "@typescript-eslint/types": "8.8.0", "eslint-visitor-keys": "^3.4.3" }, "engines": { @@ -3406,6 +3411,7 @@ "resolved": "https://registry.npmjs.org/@volar/language-server/-/language-server-2.4.5.tgz", "integrity": "sha512-l5PswE0JzCtstTlwBUpikeSa3lNUBJhTuWtj9KclZTGi2Uex4RcqGOhTiDsUUtvdv/hEuYCxGq1EdJJPlQsD/g==", "dev": true, + "license": "MIT", "dependencies": { "@volar/language-core": "2.4.5", "@volar/language-service": "2.4.5", @@ -3423,6 +3429,7 @@ "resolved": "https://registry.npmjs.org/@volar/language-service/-/language-service-2.4.5.tgz", "integrity": "sha512-xiFlL0aViGg6JhwAXyohPrdlID13uom8WQg6DWYaV8ob8RRy+zoLlBUI8SpQctwlWEO9poyrYK01revijAwkcw==", "dev": true, + "license": "MIT", "dependencies": { "@volar/language-core": "2.4.5", "vscode-languageserver-protocol": "^3.17.5", @@ -3442,6 +3449,7 @@ "resolved": "https://registry.npmjs.org/@volar/test-utils/-/test-utils-2.4.5.tgz", "integrity": "sha512-/fpjMt5tdGuUlPyWRQr0daq0lkc9XFtnD1VmNJ0N72Q96Lke0JLWWFeywg1gbLFZjy64PHJ7R8l5cdueMGFBDg==", "dev": true, + "license": "MIT", "dependencies": { "@volar/language-core": "2.4.5", "@volar/language-server": "2.4.5", @@ -3466,6 +3474,7 @@ "resolved": "https://registry.npmjs.org/@vscode/emmet-helper/-/emmet-helper-2.9.3.tgz", "integrity": "sha512-rB39LHWWPQYYlYfpv9qCoZOVioPCftKXXqrsyqN1mTWZM6dTnONT63Db+03vgrBbHzJN45IrgS/AGxw9iiqfEw==", "dev": true, + "license": "MIT", "dependencies": { "emmet": "^2.4.3", "jsonc-parser": "^2.3.0", @@ -3478,51 +3487,53 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-2.1.2.tgz", "integrity": "sha512-8TEXQxlldWAuIODdukIb+TR5s+9Ds40eSJrw+1iDDA9IFORPjMELarNQE3myz5XIkWWpdprmJjm1/SxMlWOC8A==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@vscode/l10n": { "version": "0.0.18", "resolved": "https://registry.npmjs.org/@vscode/l10n/-/l10n-0.0.18.tgz", "integrity": "sha512-KYSIHVmslkaCDyw013pphY+d7x1qV8IZupYfeIfzNA+nsaWHbn5uPuQRvdRFsa9zFzGeudPuoGoZ1Op4jrJXIQ==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@vue/compiler-core": { - "version": "3.5.9", - "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.9.tgz", - "integrity": "sha512-KE1sCdwqSKq0CQ/ltg3XnlMTKeinjegIkuFsuq9DKvNPmqLGdmI51ChZdGBBRXIvEYTLm8X/JxOuBQ1HqF/+PA==", + "version": "3.5.11", + "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.11.tgz", + "integrity": "sha512-PwAdxs7/9Hc3ieBO12tXzmTD+Ln4qhT/56S+8DvrrZ4kLDn4Z/AMUr8tXJD0axiJBS0RKIoNaR0yMuQB9v9Udg==", "dev": true, "license": "MIT", "dependencies": { "@babel/parser": "^7.25.3", - "@vue/shared": "3.5.9", + "@vue/shared": "3.5.11", "entities": "^4.5.0", "estree-walker": "^2.0.2", "source-map-js": "^1.2.0" } }, "node_modules/@vue/compiler-dom": { - "version": "3.5.9", - "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.9.tgz", - "integrity": "sha512-gEAURwPo902AsJF50vl59VaWR+Cx6cX9SoqLYHu1jq9hDbmQlXvpZyYNIIbxa2JTJ+FD/oBQweVUwuTQv79KTg==", + "version": "3.5.11", + "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.11.tgz", + "integrity": "sha512-pyGf8zdbDDRkBrEzf8p7BQlMKNNF5Fk/Cf/fQ6PiUz9at4OaUfyXW0dGJTo2Vl1f5U9jSLCNf0EZJEogLXoeew==", "dev": true, "license": "MIT", "dependencies": { - "@vue/compiler-core": "3.5.9", - "@vue/shared": "3.5.9" + "@vue/compiler-core": "3.5.11", + "@vue/shared": "3.5.11" } }, "node_modules/@vue/compiler-sfc": { - "version": "3.5.9", - "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.9.tgz", - "integrity": "sha512-kp9qawcTXakYm0TN6YAwH24IurSywoXh4fWhRbLu0at4UVyo994bhEzJlQn82eiyqtut4GjkQodSfn8drFbpZQ==", + "version": "3.5.11", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.11.tgz", + "integrity": "sha512-gsbBtT4N9ANXXepprle+X9YLg2htQk1sqH/qGJ/EApl+dgpUBdTv3yP7YlR535uHZY3n6XaR0/bKo0BgwwDniw==", "dev": true, "license": "MIT", "dependencies": { "@babel/parser": "^7.25.3", - "@vue/compiler-core": "3.5.9", - "@vue/compiler-dom": "3.5.9", - "@vue/compiler-ssr": "3.5.9", - "@vue/shared": "3.5.9", + "@vue/compiler-core": "3.5.11", + "@vue/compiler-dom": "3.5.11", + "@vue/compiler-ssr": "3.5.11", + "@vue/shared": "3.5.11", "estree-walker": "^2.0.2", "magic-string": "^0.30.11", "postcss": "^8.4.47", @@ -3530,14 +3541,14 @@ } }, "node_modules/@vue/compiler-ssr": { - "version": "3.5.9", - "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.9.tgz", - "integrity": "sha512-fb1g2mQv32QzIei76rlXRTz08Grw+ZzBXSQfHo4StGFutm/flyebw3dGJkexKwcU3GjX9s5fIGjEv/cjO8j8Yw==", + "version": "3.5.11", + "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.11.tgz", + "integrity": "sha512-P4+GPjOuC2aFTk1Z4WANvEhyOykcvEd5bIj2KVNGKGfM745LaXGr++5njpdBTzVz5pZifdlR1kpYSJJpIlSePA==", "dev": true, "license": "MIT", "dependencies": { - "@vue/compiler-dom": "3.5.9", - "@vue/shared": "3.5.9" + "@vue/compiler-dom": "3.5.11", + "@vue/shared": "3.5.11" } }, "node_modules/@vue/compiler-vue2": { @@ -3609,37 +3620,12 @@ } } }, - "node_modules/@vue/language-core/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/@vue/language-core/node_modules/minimatch": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", - "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/@vue/language-server": { "version": "2.1.6", "resolved": "https://registry.npmjs.org/@vue/language-server/-/language-server-2.1.6.tgz", "integrity": "sha512-xRtugvuwFs9KqJ5JMmO9q2b5IrhNLaj/+iqrnBEfWPFRCsywzFABrZFgI7huqsndSdO5uiBkkOkJVcruB0ULFw==", "dev": true, + "license": "MIT", "dependencies": { "@volar/language-core": "~2.4.1", "@volar/language-server": "~2.4.1", @@ -3659,6 +3645,7 @@ "resolved": "https://registry.npmjs.org/@vue/language-service/-/language-service-2.1.6.tgz", "integrity": "sha512-FZ3Fn0MslS/fdBm0U2A/JUmq0HBtvkm/6OcHfw23mE7olm0yCAOV0i8xKqqbrwZeSDoEfk48zzTSEE9Zj6RmBg==", "dev": true, + "license": "MIT", "dependencies": { "@volar/language-core": "~2.4.1", "@volar/language-service": "~2.4.1", @@ -3683,57 +3670,57 @@ } }, "node_modules/@vue/reactivity": { - "version": "3.5.9", - "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.9.tgz", - "integrity": "sha512-88ApgNZ6yPYpyYkTfXzcbWk6O8+LrPRIpa/U4AdeTzpfRUO+EUt5jemnTBVSlAUNmlYY96xa5feUNEq+BouLog==", + "version": "3.5.11", + "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.11.tgz", + "integrity": "sha512-Nqo5VZEn8MJWlCce8XoyVqHZbd5P2NH+yuAaFzuNSR96I+y1cnuUiq7xfSG+kyvLSiWmaHTKP1r3OZY4mMD50w==", "dev": true, "license": "MIT", "dependencies": { - "@vue/shared": "3.5.9" + "@vue/shared": "3.5.11" } }, "node_modules/@vue/runtime-core": { - "version": "3.5.9", - "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.9.tgz", - "integrity": "sha512-YAeP0zNkjSl5mEc1NxOg9qoAhLNbREElHAhfYbMXT57oF0ixehEEJWBhg2uvVxslCGh23JhpEAyMvJrJHW9WGg==", + "version": "3.5.11", + "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.11.tgz", + "integrity": "sha512-7PsxFGqwfDhfhh0OcDWBG1DaIQIVOLgkwA5q6MtkPiDFjp5gohVnJEahSktwSFLq7R5PtxDKy6WKURVN1UDbzA==", "dev": true, "license": "MIT", "dependencies": { - "@vue/reactivity": "3.5.9", - "@vue/shared": "3.5.9" + "@vue/reactivity": "3.5.11", + "@vue/shared": "3.5.11" } }, "node_modules/@vue/runtime-dom": { - "version": "3.5.9", - "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.9.tgz", - "integrity": "sha512-5Oq/5oenpB9lw94moKvOHqBDEaMSyDmcu2HS8AtAT6/pwdo/t9fR9aVtLh6FzYGGqZR9yRfoHAN6P7goblq1aA==", + "version": "3.5.11", + "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.11.tgz", + "integrity": "sha512-GNghjecT6IrGf0UhuYmpgaOlN7kxzQBhxWEn08c/SQDxv1yy4IXI1bn81JgEpQ4IXjRxWtPyI8x0/7TF5rPfYQ==", "dev": true, "license": "MIT", "dependencies": { - "@vue/reactivity": "3.5.9", - "@vue/runtime-core": "3.5.9", - "@vue/shared": "3.5.9", + "@vue/reactivity": "3.5.11", + "@vue/runtime-core": "3.5.11", + "@vue/shared": "3.5.11", "csstype": "^3.1.3" } }, "node_modules/@vue/server-renderer": { - "version": "3.5.9", - "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.9.tgz", - "integrity": "sha512-tbuUsZfMWGazR9LXLNiiDSTwkO8K9sLyR70diY+FbQmKmh7236PPz4jkTxymelV8D89IJUGtbfe4VdmpHkmuxg==", + "version": "3.5.11", + "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.11.tgz", + "integrity": "sha512-cVOwYBxR7Wb1B1FoxYvtjJD8X/9E5nlH4VSkJy2uMA1MzYNdzAAB//l8nrmN9py/4aP+3NjWukf9PZ3TeWULaA==", "dev": true, "license": "MIT", "dependencies": { - "@vue/compiler-ssr": "3.5.9", - "@vue/shared": "3.5.9" + "@vue/compiler-ssr": "3.5.11", + "@vue/shared": "3.5.11" }, "peerDependencies": { - "vue": "3.5.9" + "vue": "3.5.11" } }, "node_modules/@vue/shared": { - "version": "3.5.9", - "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.9.tgz", - "integrity": "sha512-8wiT/m0mnsLhTME0mPgc57jv+4TipRBSAAmheUdYgiOaO6AobZPNOmm87ub4np65VVDgLcWxc+Edc++5Wyz1uA==", + "version": "3.5.11", + "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.11.tgz", + "integrity": "sha512-W8GgysJVnFo81FthhzurdRAWP/byq3q2qIw70e0JWblzVhjgOMiC2GyovXrZTFQJnFVryYaKGP3Tc9vYzYm6PQ==", "dev": true, "license": "MIT" }, @@ -3742,6 +3729,7 @@ "resolved": "https://registry.npmjs.org/@vue/typescript-plugin/-/typescript-plugin-2.1.6.tgz", "integrity": "sha512-FGwinnIuwZPELbRPZmtA+G4YyLT+lxjGSZQpNvgrzvy3MZBJZzm4UU87DIA7Lb2xbbYpTMAM6P6TAWwioCNZIg==", "dev": true, + "license": "MIT", "dependencies": { "@volar/typescript": "~2.4.1", "@vue/language-core": "2.1.6", @@ -4389,14 +4377,13 @@ "license": "ISC" }, "node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, "license": "MIT", "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" + "balanced-match": "^1.0.0" } }, "node_modules/braces": { @@ -4644,6 +4631,7 @@ "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", "dev": true, + "license": "MIT", "dependencies": { "es-define-property": "^1.0.0", "es-errors": "^1.3.0", @@ -4679,9 +4667,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001664", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001664.tgz", - "integrity": "sha512-AmE7k4dXiNKQipgn7a2xg558IRqPN3jMQY/rOsbxDhrd0tyChwbITBfiwtnqz8bi2M5mIWbxAYBvk7W7QBUS2g==", + "version": "1.0.30001666", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001666.tgz", + "integrity": "sha512-gD14ICmoV5ZZM1OdzPWmpx+q4GyefaK06zi8hmfHV5xe4/2nOQX3+Dw5o+fSqOws2xVwL9j+anOPFwHzdEdV4g==", "dev": true, "funding": [ { @@ -4761,6 +4749,7 @@ "resolved": "https://registry.npmjs.org/character-parser/-/character-parser-2.2.0.tgz", "integrity": "sha512-+UqJQjFEFaTAs3bNsF2j2kEN1baG/zghZbdqoYEDxGZtJo9LBzl1A+m0D4n3qKx8N2FNv8/Xp6yV9mQmBuptaw==", "dev": true, + "license": "MIT", "dependencies": { "is-regex": "^1.0.3" } @@ -4836,9 +4825,9 @@ } }, "node_modules/chromium-bidi": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.6.5.tgz", - "integrity": "sha512-RuLrmzYrxSb0s9SgpB+QN5jJucPduZQ/9SIe76MDxYJuecPW5mxMdacJ1f4EtgiV+R0p3sCkznTMvH0MPGFqjA==", + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.8.0.tgz", + "integrity": "sha512-uJydbGdTw0DEUjhoogGveneJVWX/9YuqkWePzMmkBYwtdAqo5d3J/ovNKFr+/2hWXYmYCr6it8mSSTIj6SS6Ug==", "dev": true, "license": "Apache-2.0", "peer": true, @@ -4933,60 +4922,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/cli-truncate/node_modules/ansi-regex": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", - "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" - } - }, - "node_modules/cli-truncate/node_modules/emoji-regex": { - "version": "10.4.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.4.0.tgz", - "integrity": "sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==", - "dev": true, - "license": "MIT" - }, - "node_modules/cli-truncate/node_modules/string-width": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", - "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "emoji-regex": "^10.3.0", - "get-east-asian-width": "^1.0.0", - "strip-ansi": "^7.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/cli-truncate/node_modules/strip-ansi": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", - "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^6.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, "node_modules/cli-width": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-4.1.0.tgz", @@ -6142,6 +6077,7 @@ "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", "dev": true, + "license": "MIT", "dependencies": { "es-define-property": "^1.0.0", "es-errors": "^1.3.0", @@ -6243,16 +6179,16 @@ } }, "node_modules/dompurify": { - "version": "3.1.7", - "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.1.7.tgz", - "integrity": "sha512-VaTstWtsneJY8xzy7DekmYWEOZcmzIe3Qb3zPd4STve1OBTa+e+WmS1ITQec1fZYXI3HCsOZZiSMpG6oxoWMWQ==", + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.1.6.tgz", + "integrity": "sha512-cTOAhc36AalkjtBpfG6O8JimdTMWNXjiePT2xQH/ppBGi/4uIpmj8eKyIkMJErXWARyINV/sB38yf8JCLF5pbQ==", "dev": true, "license": "(MPL-2.0 OR Apache-2.0)" }, "node_modules/electron-to-chromium": { - "version": "1.5.29", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.29.tgz", - "integrity": "sha512-PF8n2AlIhCKXQ+gTpiJi0VhcHDb69kYX4MtCiivctc2QD3XuNZ/XIOlbGzt7WAjjEev0TtaH6Cu3arZExm5DOw==", + "version": "1.5.32", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.32.tgz", + "integrity": "sha512-M+7ph0VGBQqqpTT2YrabjNKSQ2fEl9PVx6AK3N558gDH9NO8O6XN9SXXFWRo9u9PbEg/bWq+tjXQr+eXmxubCw==", "dev": true, "license": "ISC" }, @@ -6261,11 +6197,25 @@ "resolved": "https://registry.npmjs.org/emmet/-/emmet-2.4.11.tgz", "integrity": "sha512-23QPJB3moh/U9sT4rQzGgeyyGIrcM+GH5uVYg2C6wZIxAIJq7Ng3QLT79tl8FUwDXhyq9SusfknOrofAKqvgyQ==", "dev": true, + "license": "MIT", + "workspaces": [ + "./packages/scanner", + "./packages/abbreviation", + "./packages/css-abbreviation", + "./" + ], "dependencies": { "@emmetio/abbreviation": "^2.3.3", "@emmetio/css-abbreviation": "^2.1.8" } }, + "node_modules/emoji-regex": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.4.0.tgz", + "integrity": "sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==", + "dev": true, + "license": "MIT" + }, "node_modules/end-of-stream": { "version": "1.4.4", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", @@ -6336,6 +6286,7 @@ "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", "dev": true, + "license": "MIT", "dependencies": { "get-intrinsic": "^1.2.4" }, @@ -6348,6 +6299,7 @@ "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.4" } @@ -6667,9 +6619,9 @@ } }, "node_modules/eslint-scope": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.0.2.tgz", - "integrity": "sha512-6E4xmrTw5wtxnLA5wYL3WDfhZ/1bUBGOXV0zQvVRDOtrR8D0p6W7fs3JweNYhwRYeGvd/1CKX2se0/2s7Q/nJA==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.1.0.tgz", + "integrity": "sha512-14dSvlhaVhKKsa9Fx1l8A17s7ah7Ef7wCakJ10LYk6+GYmP9yDti2oq2SEwcyndt6knfcZyhyxwY3i9yL78EQw==", "dev": true, "license": "BSD-2-Clause", "dependencies": { @@ -6684,9 +6636,9 @@ } }, "node_modules/eslint-visitor-keys": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", - "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.1.0.tgz", + "integrity": "sha512-Q7lok0mqMUSf5a/AdAZkA5a/gHcO6snwQClVNNvFKCAVlxXucdU8pKydU5ZVZjBx5xr37vGbFFWtLQYreLzrZg==", "dev": true, "license": "Apache-2.0", "engines": { @@ -6712,6 +6664,17 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/eslint/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, "node_modules/eslint/node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -6762,12 +6725,25 @@ "node": ">=10.13.0" } }, - "node_modules/eslint/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "node_modules/eslint/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, - "license": "MIT", + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/eslint/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -6776,15 +6752,15 @@ } }, "node_modules/espree": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-10.1.0.tgz", - "integrity": "sha512-M1M6CpiE6ffoigIOWYO9UDP8TMUw9kqb21tf+08IgDYjCsOvCuDt4jQcZmoYxx+w7zlKw9/N0KXfto+I8/FrXA==", + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.2.0.tgz", + "integrity": "sha512-upbkBJbckcCNBDBDXEbuhjbP68n+scUd3k/U2EkyM9nw+I/jPiL4cLF/Al06CF96wRltFda16sxDFrxsI1v0/g==", "dev": true, "license": "BSD-2-Clause", "dependencies": { "acorn": "^8.12.0", "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^4.0.0" + "eslint-visitor-keys": "^4.1.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -7020,9 +6996,9 @@ } }, "node_modules/fdir": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.3.0.tgz", - "integrity": "sha512-QOnuT+BOtivR77wYvCWHfGt9s4Pz1VIMbD463vegT5MLqNXy8rYFT/lPVEqf/bhYeT6qmqrNHhsX+rWwe3rOCQ==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.0.tgz", + "integrity": "sha512-3oB133prH1o4j/L5lLW7uOCF1PlD+/It2L0eL/iAqWMB91RBbqTewABqxhj0ibBd90EEmWZq7ntIWzVaWcXTGQ==", "dev": true, "license": "MIT", "peerDependencies": { @@ -7390,6 +7366,7 @@ "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", "dev": true, + "license": "MIT", "dependencies": { "es-errors": "^1.3.0", "function-bind": "^1.1.2", @@ -7474,6 +7451,27 @@ "dev": true, "license": "MIT" }, + "node_modules/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/glob-parent": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", @@ -7487,10 +7485,23 @@ "node": ">= 6" } }, + "node_modules/glob/node_modules/minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/globals": { - "version": "15.9.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-15.9.0.tgz", - "integrity": "sha512-SmSKyLLKFbSr6rptvP8izbyxJL4ILwqO9Jg23UA0sDlGlu58V59D1//I3vlc0KJphVdUR7vMjHIplYnzBxorQA==", + "version": "15.10.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.10.0.tgz", + "integrity": "sha512-tqFIbz83w4Y5TCbtgjZjApohbuh7K9BxGYFm7ifwDR240tvdb7P9x+/9VvUKlmkPoiknoJtanI8UOrqxS3a7lQ==", "dev": true, "license": "MIT", "engines": { @@ -7505,6 +7516,7 @@ "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", "dev": true, + "license": "MIT", "dependencies": { "get-intrinsic": "^1.1.3" }, @@ -7548,6 +7560,7 @@ "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", "dev": true, + "license": "MIT", "dependencies": { "es-define-property": "^1.0.0" }, @@ -7560,6 +7573,7 @@ "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz", "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.4" }, @@ -7572,6 +7586,7 @@ "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.4" }, @@ -7584,6 +7599,7 @@ "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", "dev": true, + "license": "MIT", "dependencies": { "has-symbols": "^1.0.3" }, @@ -7996,6 +8012,7 @@ "resolved": "https://registry.npmjs.org/is-expression/-/is-expression-4.0.0.tgz", "integrity": "sha512-zMIXX63sxzG3XrkHkrAPvm/OVZVSCPNkwMHU8oTX7/U3AL78I0QXCEICXUM13BIa8TYGZ68PiTKfQz3yaTNr4A==", "dev": true, + "license": "MIT", "dependencies": { "acorn": "^7.1.1", "object-assign": "^4.1.1" @@ -8006,6 +8023,7 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", "dev": true, + "license": "MIT", "bin": { "acorn": "bin/acorn" }, @@ -8101,6 +8119,7 @@ "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", "integrity": "sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.2", "has-tostringtag": "^1.0.0" @@ -8419,7 +8438,8 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-2.3.1.tgz", "integrity": "sha512-H8jvkz1O50L3dMZCsLqiuB2tA7muqbSg1AtGEkN0leAqGjsUzDJir3Zwr02BhqdcITPg3ei3mZ+HjMocAknhhg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/jsonfile": { "version": "6.1.0", @@ -8578,9 +8598,9 @@ } }, "node_modules/listr2": { - "version": "8.2.4", - "resolved": "https://registry.npmjs.org/listr2/-/listr2-8.2.4.tgz", - "integrity": "sha512-opevsywziHd3zHCVQGAj8zu+Z3yHNkkoYhWIGnq54RrCVwLz0MozotJEDnKsIBLvkfLGN6BLOyAeRrYI0pKA4g==", + "version": "8.2.5", + "resolved": "https://registry.npmjs.org/listr2/-/listr2-8.2.5.tgz", + "integrity": "sha512-iyAZCeyD+c1gPyE9qpFu8af0Y+MRtmKOncdGoA2S5EY8iFq99dmmvkNnHiWo+pj0s7yH7l3KPIgee77tKpXPWQ==", "dev": true, "license": "MIT", "dependencies": { @@ -8608,31 +8628,6 @@ "url": "https://github.com/chalk/ansi-regex?sponsor=1" } }, - "node_modules/listr2/node_modules/emoji-regex": { - "version": "10.4.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.4.0.tgz", - "integrity": "sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==", - "dev": true, - "license": "MIT" - }, - "node_modules/listr2/node_modules/string-width": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", - "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "emoji-regex": "^10.3.0", - "get-east-asian-width": "^1.0.0", - "strip-ansi": "^7.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/listr2/node_modules/strip-ansi": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", @@ -8867,13 +8862,6 @@ "url": "https://github.com/chalk/ansi-regex?sponsor=1" } }, - "node_modules/log-update/node_modules/emoji-regex": { - "version": "10.4.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.4.0.tgz", - "integrity": "sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==", - "dev": true, - "license": "MIT" - }, "node_modules/log-update/node_modules/is-fullwidth-code-point": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-5.0.0.tgz", @@ -8907,24 +8895,6 @@ "url": "https://github.com/chalk/slice-ansi?sponsor=1" } }, - "node_modules/log-update/node_modules/string-width": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", - "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "emoji-regex": "^10.3.0", - "get-east-asian-width": "^1.0.0", - "strip-ansi": "^7.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/log-update/node_modules/strip-ansi": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", @@ -9051,6 +9021,30 @@ "node": "6.* || 8.* || >= 10.*" } }, + "node_modules/matcher-collection/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/matcher-collection/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/mdast-util-find-and-replace": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/mdast-util-find-and-replace/-/mdast-util-find-and-replace-3.0.1.tgz", @@ -9316,9 +9310,9 @@ } }, "node_modules/mermaid": { - "version": "11.2.1", - "resolved": "https://registry.npmjs.org/mermaid/-/mermaid-11.2.1.tgz", - "integrity": "sha512-F8TEaLVVyxTUmvKswVFyOkjPrlJA5h5vNR1f7ZnSWSpqxgEZG1hggtn/QCa7znC28bhlcrNh10qYaIiill7q4A==", + "version": "11.3.0", + "resolved": "https://registry.npmjs.org/mermaid/-/mermaid-11.3.0.tgz", + "integrity": "sha512-fFmf2gRXLtlGzug4wpIGN+rQdZ30M8IZEB1D3eZkXNqC7puhqeURBcD/9tbwXsqBO+A6Nzzo3MSSepmnw5xSeg==", "dev": true, "license": "MIT", "dependencies": { @@ -9332,7 +9326,7 @@ "d3-sankey": "^0.12.3", "dagre-d3-es": "7.0.10", "dayjs": "^1.11.10", - "dompurify": "^3.0.11", + "dompurify": "^3.0.11 <3.1.7", "katex": "^0.16.9", "khroma": "^2.1.0", "lodash-es": "^4.17.21", @@ -9893,16 +9887,19 @@ } }, "node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", "dev": true, "license": "ISC", "dependencies": { - "brace-expansion": "^1.1.7" + "brace-expansion": "^2.0.1" }, "engines": { - "node": "*" + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, "node_modules/minimist": { @@ -9915,6 +9912,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/minipass": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=8" + } + }, "node_modules/minisearch": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/minisearch/-/minisearch-7.1.0.tgz", @@ -10041,16 +10048,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/mocha/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, "node_modules/mocha/node_modules/cliui": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", @@ -10090,27 +10087,6 @@ "dev": true, "license": "MIT" }, - "node_modules/mocha/node_modules/glob": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", - "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", - "deprecated": "Glob versions prior to v9 are no longer supported", - "dev": true, - "license": "ISC", - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^5.0.1", - "once": "^1.3.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/mocha/node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -10316,6 +10292,17 @@ "url": "https://opencollective.com/nodemon" } }, + "node_modules/nodemon/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, "node_modules/nodemon/node_modules/has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -10326,6 +10313,19 @@ "node": ">=4" } }, + "node_modules/nodemon/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/nodemon/node_modules/supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -10535,6 +10535,17 @@ "node": ">=18" } }, + "node_modules/nyc/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, "node_modules/nyc/node_modules/cliui": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", @@ -10613,6 +10624,19 @@ "node": ">=8" } }, + "node_modules/nyc/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/nyc/node_modules/p-limit": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", @@ -10723,6 +10747,7 @@ "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.10.0" } @@ -11075,9 +11100,9 @@ } }, "node_modules/pinia": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/pinia/-/pinia-2.2.2.tgz", - "integrity": "sha512-ja2XqFWZC36mupU4z1ZzxeTApV7DOw44cV4dhQ9sGwun+N89v/XP7+j7q6TanS1u1tdbK4r+1BUx7heMaIdagA==", + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/pinia/-/pinia-2.2.4.tgz", + "integrity": "sha512-K7ZhpMY9iJ9ShTC0cR2+PnxdQRuwVIsXDO/WIEV/RnMC/vmSoKDTKW/exNQYPI+4ij10UjXqdNiEHwn47McANQ==", "dev": true, "license": "MIT", "dependencies": { @@ -11461,13 +11486,15 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/pug-error/-/pug-error-2.1.0.tgz", "integrity": "sha512-lv7sU9e5Jk8IeUheHata6/UThZ7RK2jnaaNztxfPYUY+VxZyk/ePVaNZ/vwmH8WqGvDz3LrNYt/+gA55NDg6Pg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/pug-lexer": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/pug-lexer/-/pug-lexer-5.0.1.tgz", "integrity": "sha512-0I6C62+keXlZPZkOJeVam9aBLVP2EnbeDw3An+k0/QlqdwH6rv8284nko14Na7c0TtqtogfWXcRoFE4O4Ff20w==", "dev": true, + "license": "MIT", "dependencies": { "character-parser": "^2.2.0", "is-expression": "^4.0.0", @@ -11479,6 +11506,7 @@ "resolved": "https://registry.npmjs.org/pug-parser/-/pug-parser-6.0.0.tgz", "integrity": "sha512-ukiYM/9cH6Cml+AOl5kETtM9NR3WulyVP2y4HOU45DyMim1IeP/OOiyEWRr6qk5I5klpsBnbuHpwKmTx6WURnw==", "dev": true, + "license": "MIT", "dependencies": { "pug-error": "^2.0.0", "token-stream": "1.0.0" @@ -11507,19 +11535,19 @@ } }, "node_modules/puppeteer": { - "version": "23.4.1", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-23.4.1.tgz", - "integrity": "sha512-+wWfWTkQ8L9IB/3OVGSUp37c0eQ5za/85KdX+LAq2wTZkMdocgYGMCs+/91e2f/RXIYzve4x/uGxN8zG2sj8+w==", + "version": "23.5.0", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-23.5.0.tgz", + "integrity": "sha512-jnUx5M0YtFva7vXr39qqsxgB46JiwXJavuM1Hgsqbd9WWiGTEUt9klGpTxyHi+ZQf3NUgleDhNsnI10IK8Ebsg==", "dev": true, "hasInstallScript": true, "license": "Apache-2.0", "peer": true, "dependencies": { "@puppeteer/browsers": "2.4.0", - "chromium-bidi": "0.6.5", + "chromium-bidi": "0.8.0", "cosmiconfig": "^9.0.0", "devtools-protocol": "0.0.1342118", - "puppeteer-core": "23.4.1", + "puppeteer-core": "23.5.0", "typed-query-selector": "^2.12.0" }, "bin": { @@ -11530,15 +11558,15 @@ } }, "node_modules/puppeteer-core": { - "version": "23.4.1", - "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-23.4.1.tgz", - "integrity": "sha512-uCxGtn8VE9PlKhdFJX/zZySi9K3Ufr3qUZe28jxJoZUqiMJOi+SFh2zhiFDSjWqZIDkc0FtnaCC+rewW3MYXmg==", + "version": "23.5.0", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-23.5.0.tgz", + "integrity": "sha512-+5ed+625GuQ2emRHqYec8khT9LP14FWzv8hYl0HiM6hnnlNzdVU9uDJIPHeCPLIWxq15ost9MeF8kBk4R3eiFw==", "dev": true, "license": "Apache-2.0", "peer": true, "dependencies": { "@puppeteer/browsers": "2.4.0", - "chromium-bidi": "0.6.5", + "chromium-bidi": "0.8.0", "debug": "^4.3.7", "devtools-protocol": "0.0.1342118", "typed-query-selector": "^2.12.0", @@ -11784,9 +11812,9 @@ } }, "node_modules/regex": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/regex/-/regex-4.3.2.tgz", - "integrity": "sha512-kK/AA3A9K6q2js89+VMymcboLOlF5lZRCYJv3gzszXFHBr6kO6qLGzbm+UIugBEV8SMMKCTR59txoY6ctRHYVw==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/regex/-/regex-4.3.3.tgz", + "integrity": "sha512-r/AadFO7owAq1QJVeZ/nq9jNS1vyZt+6t1p/E59B56Rn2GCya+gr1KSyOzNL/er+r+B7phv5jG2xU2Nz1YkmJg==", "dev": true, "license": "MIT" }, @@ -11886,7 +11914,8 @@ "version": "0.7.0", "resolved": "https://registry.npmjs.org/request-light/-/request-light-0.7.0.tgz", "integrity": "sha512-lMbBMrDoxgsyO+yB3sDcrDuX85yYt7sS8BfQd11jtbW/z5ZWgLZRcEGLsLoYw7I0WSUGQBs8CC8ScIxkTX1+6Q==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/require-directory": { "version": "2.1.1", @@ -12015,6 +12044,17 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/rimraf/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, "node_modules/rimraf/node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", @@ -12037,6 +12077,19 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/rimraf/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/robust-predicates": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/robust-predicates/-/robust-predicates-3.0.2.tgz", @@ -12045,13 +12098,13 @@ "license": "Unlicense" }, "node_modules/rollup": { - "version": "4.22.4", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.22.4.tgz", - "integrity": "sha512-vD8HJ5raRcWOyymsR6Z3o6+RzfEPCnVLMFJ6vRslO1jt4LO6dUo5Qnpg7y4RkZFM2DMe3WUirkI5c16onjrc6A==", + "version": "4.24.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.24.0.tgz", + "integrity": "sha512-DOmrlGSXNk1DM0ljiQA+i+o0rSLhtii1je5wgk60j49d1jHT5YYttBv1iWOnYSTG+fZZESUOSNiAl89SIet+Cg==", "dev": true, "license": "MIT", "dependencies": { - "@types/estree": "1.0.5" + "@types/estree": "1.0.6" }, "bin": { "rollup": "dist/bin/rollup" @@ -12061,22 +12114,22 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.22.4", - "@rollup/rollup-android-arm64": "4.22.4", - "@rollup/rollup-darwin-arm64": "4.22.4", - "@rollup/rollup-darwin-x64": "4.22.4", - "@rollup/rollup-linux-arm-gnueabihf": "4.22.4", - "@rollup/rollup-linux-arm-musleabihf": "4.22.4", - "@rollup/rollup-linux-arm64-gnu": "4.22.4", - "@rollup/rollup-linux-arm64-musl": "4.22.4", - "@rollup/rollup-linux-powerpc64le-gnu": "4.22.4", - "@rollup/rollup-linux-riscv64-gnu": "4.22.4", - "@rollup/rollup-linux-s390x-gnu": "4.22.4", - "@rollup/rollup-linux-x64-gnu": "4.22.4", - "@rollup/rollup-linux-x64-musl": "4.22.4", - "@rollup/rollup-win32-arm64-msvc": "4.22.4", - "@rollup/rollup-win32-ia32-msvc": "4.22.4", - "@rollup/rollup-win32-x64-msvc": "4.22.4", + "@rollup/rollup-android-arm-eabi": "4.24.0", + "@rollup/rollup-android-arm64": "4.24.0", + "@rollup/rollup-darwin-arm64": "4.24.0", + "@rollup/rollup-darwin-x64": "4.24.0", + "@rollup/rollup-linux-arm-gnueabihf": "4.24.0", + "@rollup/rollup-linux-arm-musleabihf": "4.24.0", + "@rollup/rollup-linux-arm64-gnu": "4.24.0", + "@rollup/rollup-linux-arm64-musl": "4.24.0", + "@rollup/rollup-linux-powerpc64le-gnu": "4.24.0", + "@rollup/rollup-linux-riscv64-gnu": "4.24.0", + "@rollup/rollup-linux-s390x-gnu": "4.24.0", + "@rollup/rollup-linux-x64-gnu": "4.24.0", + "@rollup/rollup-linux-x64-musl": "4.24.0", + "@rollup/rollup-win32-arm64-msvc": "4.24.0", + "@rollup/rollup-win32-ia32-msvc": "4.24.0", + "@rollup/rollup-win32-x64-msvc": "4.24.0", "fsevents": "~2.3.2" } }, @@ -12118,21 +12171,6 @@ } } }, - "node_modules/rollup-plugin-license/node_modules/picomatch": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", - "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, "node_modules/rollup-plugin-string": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/rollup-plugin-string/-/rollup-plugin-string-3.0.0.tgz", @@ -12160,13 +12198,6 @@ "dev": true, "license": "MIT" }, - "node_modules/rollup/node_modules/@types/estree": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", - "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", - "dev": true, - "license": "MIT" - }, "node_modules/roughjs": { "version": "4.6.6", "resolved": "https://registry.npmjs.org/roughjs/-/roughjs-4.6.6.tgz", @@ -12292,6 +12323,7 @@ "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", "dev": true, + "license": "MIT", "dependencies": { "define-data-property": "^1.1.4", "es-errors": "^1.3.0", @@ -12355,6 +12387,17 @@ "node": ">=4" } }, + "node_modules/shelljs/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, "node_modules/shelljs/node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", @@ -12377,17 +12420,30 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/shelljs/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/shiki": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-1.20.0.tgz", - "integrity": "sha512-MZJJ1PCFsQB1Piq+25wiz0a75yUv8Q3/fzy7SzRx5ONdjdtGdyiKwYn8vb/FnK5kjS0voWGnPpjG16POauUR+g==", + "version": "1.21.0", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-1.21.0.tgz", + "integrity": "sha512-apCH5BoWTrmHDPGgg3RF8+HAAbEL/CdbYr8rMw7eIrdhCkZHdVGat5mMNlRtd1erNG01VPMIKHNQ0Pj2HMAiog==", "dev": true, "license": "MIT", "dependencies": { - "@shikijs/core": "1.20.0", - "@shikijs/engine-javascript": "1.20.0", - "@shikijs/engine-oniguruma": "1.20.0", - "@shikijs/types": "1.20.0", + "@shikijs/core": "1.21.0", + "@shikijs/engine-javascript": "1.21.0", + "@shikijs/engine-oniguruma": "1.21.0", + "@shikijs/types": "1.21.0", "@shikijs/vscode-textmate": "^9.2.2", "@types/hast": "^3.0.4" } @@ -12771,6 +12827,53 @@ "node": ">=0.6.19" } }, + "node_modules/string-width": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^10.3.0", + "get-east-asian-width": "^1.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/string-width/node_modules/ansi-regex": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", + "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/string-width/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, "node_modules/stringify-entities": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-4.0.4.tgz", @@ -12982,16 +13085,6 @@ "streamx": "^2.15.0" } }, - "node_modules/tar/node_modules/minipass": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", - "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=8" - } - }, "node_modules/tar/node_modules/yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", @@ -13000,9 +13093,9 @@ "license": "ISC" }, "node_modules/terser": { - "version": "5.34.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.34.0.tgz", - "integrity": "sha512-y5NUX+U9HhVsK/zihZwoq4r9dICLyV2jXGOriDAVOeKhq3LKVjgJbGO90FisozXLlJfvjHqgckGmJFBb9KYoWQ==", + "version": "5.34.1", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.34.1.tgz", + "integrity": "sha512-FsJZ7iZLd/BXkz+4xrRTGJ26o/6VTjQytUk8b8OxkwcD2I+79VPJlz7qss1+zE7h8GNIScFqXcDyJ/KqBYZFVA==", "dev": true, "license": "BSD-2-Clause", "dependencies": { @@ -13040,6 +13133,17 @@ "node": ">=8" } }, + "node_modules/test-exclude/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, "node_modules/test-exclude/node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", @@ -13062,6 +13166,19 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/test-exclude/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/text-decoder": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/text-decoder/-/text-decoder-1.2.0.tgz", @@ -13148,7 +13265,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/token-stream/-/token-stream-1.0.0.tgz", "integrity": "sha512-VSsyNPPW74RpHwR8Fc21uubwHY7wMDeJLys2IX5zJNih+OnAnaifKHo+1LHT7DAdloQ7apeaaWg8l7qnf/TnEg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/touch": { "version": "3.1.1", @@ -13212,36 +13330,36 @@ "license": "0BSD" }, "node_modules/twoslash": { - "version": "0.2.11", - "resolved": "https://registry.npmjs.org/twoslash/-/twoslash-0.2.11.tgz", - "integrity": "sha512-392Qkcu5sD2hROLZ+XPywChreDGJ8Yu5nnK/Moxfti/R39q0Q39MaV7iHjz92B5qucyjsQFnKMdYIzafX5T8dg==", + "version": "0.2.12", + "resolved": "https://registry.npmjs.org/twoslash/-/twoslash-0.2.12.tgz", + "integrity": "sha512-tEHPASMqi7kqwfJbkk7hc/4EhlrKCSLcur+TcvYki3vhIfaRMXnXjaYFgXpoZRbT6GdprD4tGuVBEmTpUgLBsw==", "dev": true, "license": "MIT", "dependencies": { "@typescript/vfs": "^1.6.0", - "twoslash-protocol": "0.2.11" + "twoslash-protocol": "0.2.12" }, "peerDependencies": { "typescript": "*" } }, "node_modules/twoslash-protocol": { - "version": "0.2.11", - "resolved": "https://registry.npmjs.org/twoslash-protocol/-/twoslash-protocol-0.2.11.tgz", - "integrity": "sha512-rp+nkOWbKfJnBTDZtnIaBGjnU+4CaMhqu6db2UU7byU96rH8X4hao4BOxYw6jdZc85Lhv5pOfcjgfHeQyLzndQ==", + "version": "0.2.12", + "resolved": "https://registry.npmjs.org/twoslash-protocol/-/twoslash-protocol-0.2.12.tgz", + "integrity": "sha512-5qZLXVYfZ9ABdjqbvPc4RWMr7PrpPaaDSeaYY55vl/w1j6H6kzsWK/urAEIXlzYlyrFmyz1UbwIt+AA0ck+wbg==", "dev": true, "license": "MIT" }, "node_modules/twoslash-vue": { - "version": "0.2.11", - "resolved": "https://registry.npmjs.org/twoslash-vue/-/twoslash-vue-0.2.11.tgz", - "integrity": "sha512-wBwIwG0PRuv5V+1DD4Zno1j6MnaCbaY/ELops7oKSoMBTIQL720iRXppyldVVoYvti2caUA97T36XhZXHpjQyA==", + "version": "0.2.12", + "resolved": "https://registry.npmjs.org/twoslash-vue/-/twoslash-vue-0.2.12.tgz", + "integrity": "sha512-kxH60DLn2QBcN2wjqxgMDkyRgmPXsytv7fJIlsyFMDPSkm1/lMrI/UMrNAshNaRHcI+hv8x3h/WBgcvlb2RNAQ==", "dev": true, "license": "MIT", "dependencies": { "@vue/language-core": "~2.1.6", - "twoslash": "0.2.11", - "twoslash-protocol": "0.2.11" + "twoslash": "0.2.12", + "twoslash-protocol": "0.2.12" }, "funding": { "url": "https://github.com/sponsors/antfu" @@ -13320,20 +13438,21 @@ "resolved": "https://registry.npmjs.org/typescript-auto-import-cache/-/typescript-auto-import-cache-0.3.3.tgz", "integrity": "sha512-ojEC7+Ci1ij9eE6hp8Jl9VUNnsEKzztktP5gtYNRMrTmfXVwA1PITYYAkpxCvvupdSYa/Re51B6KMcv1CTZEUA==", "dev": true, + "license": "MIT", "dependencies": { "semver": "^7.3.8" } }, "node_modules/typescript-eslint": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.7.0.tgz", - "integrity": "sha512-nEHbEYJyHwsuf7c3V3RS7Saq+1+la3i0ieR3qP0yjqWSzVmh8Drp47uOl9LjbPANac4S7EFSqvcYIKXUUwIfIQ==", + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.8.0.tgz", + "integrity": "sha512-BjIT/VwJ8+0rVO01ZQ2ZVnjE1svFBiRczcpr1t1Yxt7sT25VSbPfrJtDsQ8uQTy2pilX5nI9gwxhUyLULNentw==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/eslint-plugin": "8.7.0", - "@typescript-eslint/parser": "8.7.0", - "@typescript-eslint/utils": "8.7.0" + "@typescript-eslint/eslint-plugin": "8.8.0", + "@typescript-eslint/parser": "8.8.0", + "@typescript-eslint/utils": "8.8.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -13509,9 +13628,9 @@ } }, "node_modules/update-browserslist-db": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.0.tgz", - "integrity": "sha512-EdRAaAyk2cUE1wOf2DkEhzxqOQvFOoRJFNS6NeyJ01Gp2beMRpBAINjM2iDXE3KCuKhwnvHIQCJm6ThL2Z+HzQ==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.1.tgz", + "integrity": "sha512-R8UzCaa9Az+38REPiJ1tXlImTJXlVfgHZsglwBD/k6nj76ctsH1E3q4doGrukiLQd3sGQYu56r5+lo5r94l29A==", "dev": true, "funding": [ { @@ -13529,8 +13648,8 @@ ], "license": "MIT", "dependencies": { - "escalade": "^3.1.2", - "picocolors": "^1.0.1" + "escalade": "^3.2.0", + "picocolors": "^1.1.0" }, "bin": { "update-browserslist-db": "cli.js" @@ -13741,6 +13860,7 @@ "resolved": "https://registry.npmjs.org/volar-service-css/-/volar-service-css-0.0.62.tgz", "integrity": "sha512-JwNyKsH3F8PuzZYuqPf+2e+4CTU8YoyUHEHVnoXNlrLe7wy9U3biomZ56llN69Ris7TTy/+DEX41yVxQpM4qvg==", "dev": true, + "license": "MIT", "dependencies": { "vscode-css-languageservice": "^6.3.0", "vscode-languageserver-textdocument": "^1.0.11", @@ -13760,6 +13880,7 @@ "resolved": "https://registry.npmjs.org/volar-service-emmet/-/volar-service-emmet-0.0.62.tgz", "integrity": "sha512-U4dxWDBWz7Pi4plpbXf4J4Z/ss6kBO3TYrACxWNsE29abu75QzVS0paxDDhI6bhqpbDFXlpsDhZ9aXVFpnfGRQ==", "dev": true, + "license": "MIT", "dependencies": { "@emmetio/css-parser": "^0.4.0", "@emmetio/html-matcher": "^1.3.0", @@ -13780,6 +13901,7 @@ "resolved": "https://registry.npmjs.org/volar-service-html/-/volar-service-html-0.0.62.tgz", "integrity": "sha512-Zw01aJsZRh4GTGUjveyfEzEqpULQUdQH79KNEiKVYHZyuGtdBRYCHlrus1sueSNMxwwkuF5WnOHfvBzafs8yyQ==", "dev": true, + "license": "MIT", "dependencies": { "vscode-html-languageservice": "^5.3.0", "vscode-languageserver-textdocument": "^1.0.11", @@ -13799,6 +13921,7 @@ "resolved": "https://registry.npmjs.org/volar-service-json/-/volar-service-json-0.0.62.tgz", "integrity": "sha512-Ot+jP+/LzKcaGF7nzrn+gwpzAleb4ej5buO05M8KxfwfODte7o1blARKRoJ3Nv7ls0DBM38Dd5vjzvA9c/9Jtg==", "dev": true, + "license": "MIT", "dependencies": { "vscode-json-languageservice": "^5.4.0", "vscode-uri": "^3.0.8" @@ -13817,6 +13940,7 @@ "resolved": "https://registry.npmjs.org/volar-service-pug/-/volar-service-pug-0.0.62.tgz", "integrity": "sha512-C0/O8uGnRfijWKE0zFXxJ/o7BbLebzretsEaiMkvBDIxm5oe7HRDzQr6CgknV/WVgiohZ74v+0CwBPl2YmcPUQ==", "dev": true, + "license": "MIT", "dependencies": { "@volar/language-service": "~2.4.0", "muggle-string": "^0.4.1", @@ -13832,6 +13956,7 @@ "resolved": "https://registry.npmjs.org/volar-service-pug-beautify/-/volar-service-pug-beautify-0.0.62.tgz", "integrity": "sha512-dAFNuNEwTnnVthYoNJhoStwhf/PojzglwCrdhOb2nBegTG3xXMWRFmQzb0JfIlt2wq2wfUq5j+JJswgSD3KluQ==", "dev": true, + "license": "MIT", "dependencies": { "@johnsoncodehk/pug-beautify": "^0.2.2" }, @@ -13849,6 +13974,7 @@ "resolved": "https://registry.npmjs.org/volar-service-typescript/-/volar-service-typescript-0.0.62.tgz", "integrity": "sha512-p7MPi71q7KOsH0eAbZwPBiKPp9B2+qrdHAd6VY5oTo9BUXatsOAdakTm9Yf0DUj6uWBAaOT01BSeVOPwucMV1g==", "dev": true, + "license": "MIT", "dependencies": { "path-browserify": "^1.0.1", "semver": "^7.6.2", @@ -13871,6 +13997,7 @@ "resolved": "https://registry.npmjs.org/volar-service-typescript-twoslash-queries/-/volar-service-typescript-twoslash-queries-0.0.62.tgz", "integrity": "sha512-KxFt4zydyJYYI0kFAcWPTh4u0Ha36TASPZkAnNY784GtgajerUqM80nX/W1d0wVhmcOFfAxkVsf/Ed+tiYU7ng==", "dev": true, + "license": "MIT", "dependencies": { "vscode-uri": "^3.0.8" }, @@ -13888,6 +14015,7 @@ "resolved": "https://registry.npmjs.org/vscode-css-languageservice/-/vscode-css-languageservice-6.3.1.tgz", "integrity": "sha512-1BzTBuJfwMc3A0uX4JBdJgoxp74cjj4q2mDJdp49yD/GuAq4X0k5WtK6fNcMYr+FfJ9nqgR6lpfCSZDkARJ5qQ==", "dev": true, + "license": "MIT", "dependencies": { "@vscode/l10n": "^0.0.18", "vscode-languageserver-textdocument": "^1.0.12", @@ -13900,6 +14028,7 @@ "resolved": "https://registry.npmjs.org/vscode-html-languageservice/-/vscode-html-languageservice-5.3.1.tgz", "integrity": "sha512-ysUh4hFeW/WOWz/TO9gm08xigiSsV/FOAZ+DolgJfeLftna54YdmZ4A+lIn46RbdO3/Qv5QHTn1ZGqmrXQhZyA==", "dev": true, + "license": "MIT", "dependencies": { "@vscode/l10n": "^0.0.18", "vscode-languageserver-textdocument": "^1.0.12", @@ -13912,6 +14041,7 @@ "resolved": "https://registry.npmjs.org/vscode-json-languageservice/-/vscode-json-languageservice-5.4.1.tgz", "integrity": "sha512-5czFGNyVPxz3ZJYl8R3a3SuIj5gjhmGF4Wv05MRPvD4DEnHK6b8km4VbNMJNHBlTCh7A0aHzUbPVzo+0C18mCA==", "dev": true, + "license": "MIT", "dependencies": { "@vscode/l10n": "^0.0.18", "jsonc-parser": "^3.3.1", @@ -13924,7 +14054,8 @@ "version": "3.3.1", "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.3.1.tgz", "integrity": "sha512-HUgH65KyejrUFPvHFPbqOY0rsFip3Bo5wb4ngvdi1EpCYWUQDC5V+Y7mZws+DLkr4M//zQJoanu1SP+87Dv1oQ==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/vscode-jsonrpc": { "version": "8.2.0", @@ -13978,7 +14109,8 @@ "version": "5.2.0", "resolved": "https://registry.npmjs.org/vscode-nls/-/vscode-nls-5.2.0.tgz", "integrity": "sha512-RAaHx7B14ZU04EU31pT+rKz2/zSl7xMsfIZuo8pd+KZO6PXtQmpevpq3vxvWNcrGbdmhM/rr5Uw5Mz+NBfhVng==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/vscode-uri": { "version": "3.0.8", @@ -13988,17 +14120,17 @@ "license": "MIT" }, "node_modules/vue": { - "version": "3.5.9", - "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.9.tgz", - "integrity": "sha512-nHzQhZ5cjFKynAY2beAm7XtJ5C13VKAFTLTgRYXy+Id1KEKBeiK6hO2RcW1hUjdbHMadz1YzxyHgQigOC54wug==", + "version": "3.5.11", + "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.11.tgz", + "integrity": "sha512-/8Wurrd9J3lb72FTQS7gRMNQD4nztTtKPmuDuPuhqXmmpD6+skVjAeahNpVzsuky6Sy9gy7wn8UadqPtt9SQIg==", "dev": true, "license": "MIT", "dependencies": { - "@vue/compiler-dom": "3.5.9", - "@vue/compiler-sfc": "3.5.9", - "@vue/runtime-dom": "3.5.9", - "@vue/server-renderer": "3.5.9", - "@vue/shared": "3.5.9" + "@vue/compiler-dom": "3.5.11", + "@vue/compiler-sfc": "3.5.11", + "@vue/runtime-dom": "3.5.11", + "@vue/server-renderer": "3.5.11", + "@vue/shared": "3.5.11" }, "peerDependencies": { "typescript": "*" @@ -14133,6 +14265,30 @@ "node": "10.* || >= 12.*" } }, + "node_modules/walk-sync/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/walk-sync/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/wasm-pack": { "version": "0.13.0", "resolved": "https://registry.npmjs.org/wasm-pack/-/wasm-pack-0.13.0.tgz", diff --git a/package.json b/package.json index 19b248575..fafa4eca1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rollup", - "version": "4.23.0", + "version": "4.24.0", "description": "Next-generation ES module bundler", "main": "dist/rollup.js", "module": "dist/es/rollup.js", @@ -120,7 +120,7 @@ "@codemirror/language": "^6.10.3", "@codemirror/search": "^6.5.6", "@codemirror/state": "^6.4.1", - "@codemirror/view": "^6.33.0", + "@codemirror/view": "^6.34.1", "@eslint/js": "^9.11.1", "@inquirer/prompts": "^6.0.1", "@jridgewell/sourcemap-codec": "^1.5.0", @@ -135,14 +135,15 @@ "@rollup/plugin-terser": "^0.4.4", "@rollup/plugin-typescript": "^12.1.0", "@rollup/pluginutils": "^5.1.2", - "@shikijs/vitepress-twoslash": "^1.18.0", + "@shikijs/vitepress-twoslash": "^1.21.0", "@types/mocha": "^10.0.8", - "@types/node": "^18.19.50", + "@types/node": "^18.19.54", "@types/semver": "^7.5.8", "@types/yargs-parser": "^21.0.3", "@vue/language-server": "^2.1.6", "acorn": "^8.12.1", "acorn-import-assertions": "^1.9.0", + "acorn-jsx": "^5.3.2", "buble": "^0.20.0", "builtin-modules": "^4.0.0", "chokidar": "^3.6.0", @@ -172,13 +173,13 @@ "nodemon": "^3.1.7", "npm-audit-resolver": "^3.0.0-RC.0", "nyc": "^17.1.0", - "pinia": "^2.2.2", + "pinia": "^2.2.3", "prettier": "^3.3.3", "prettier-plugin-organize-imports": "^4.1.0", "pretty-bytes": "^6.1.1", "pretty-ms": "^9.1.0", "requirejs": "^2.3.7", - "rollup": "^4.22.4", + "rollup": "^4.22.5", "rollup-plugin-license": "^3.5.3", "rollup-plugin-string": "^3.0.0", "semver": "^7.6.3", @@ -187,13 +188,13 @@ "source-map": "^0.7.4", "source-map-support": "^0.5.21", "systemjs": "^6.15.1", - "terser": "^5.33.0", + "terser": "^5.34.1", "tslib": "^2.7.0", "typescript": "^5.6.2", - "typescript-eslint": "^8.7.0", - "vite": "^5.4.7", + "typescript-eslint": "^8.8.0", + "vite": "^5.4.8", "vitepress": "^1.3.4", - "vue": "^3.5.8", + "vue": "^3.5.10", "vue-tsc": "^2.1.6", "wasm-pack": "^0.13.0", "yargs-parser": "^21.1.1" diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 4412ef0ff..0c32cb26e 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -57,7 +57,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -148,9 +148,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.18" +version = "1.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62ac837cdb5cb22e10a256099b4fc502b1dfe560cb282963a974d7abd80e476" +checksum = "812acba72f0a070b003d3697490d2b55b837230ae7c6c6497f05cc2ddbb8d938" dependencies = [ "shlex", ] @@ -177,7 +177,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f" dependencies = [ "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -193,7 +193,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ "cfg-if", - "hashbrown", + "hashbrown 0.14.5", "lock_api", "once_cell", "parking_lot_core", @@ -250,7 +250,7 @@ checksum = "e8d8947525c49c73130b5a7187b55b027b6b78fe60268d9f4c283ed690698cb1" dependencies = [ "proc-macro2", "swc_macros_common", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -282,6 +282,12 @@ dependencies = [ "allocator-api2", ] +[[package]] +name = "hashbrown" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" + [[package]] name = "hermit-abi" version = "0.3.9" @@ -294,7 +300,7 @@ version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dae404c0c5d4e95d4858876ab02eecd6a196bb8caa42050dfa809938833fc412" dependencies = [ - "hashbrown", + "hashbrown 0.14.5", "new_debug_unreachable", "once_cell", "phf", @@ -320,12 +326,12 @@ checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed" [[package]] name = "indexmap" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.15.0", ] [[package]] @@ -337,7 +343,7 @@ dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -443,7 +449,7 @@ dependencies = [ "napi-derive-backend", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -458,7 +464,7 @@ dependencies = [ "quote", "regex", "semver 1.0.23", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -517,9 +523,12 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1" +dependencies = [ + "portable-atomic", +] [[package]] name = "outref" @@ -615,7 +624,7 @@ dependencies = [ "phf_shared", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -633,6 +642,12 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +[[package]] +name = "portable-atomic" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" + [[package]] name = "proc-macro2" version = "1.0.86" @@ -709,18 +724,18 @@ checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" [[package]] name = "redox_syscall" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "355ae415ccd3a04315d3f8246e86d67689ea74d88d915576e1589a351062a13b" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags", ] [[package]] name = "regex" -version = "1.10.6" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", @@ -730,9 +745,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", @@ -741,9 +756,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rustc-hash" @@ -822,7 +837,7 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -928,17 +943,17 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] name = "swc_allocator" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adc8bd3075d1c6964010333fae9ddcd91ad422a4f8eb8b3206a9b2b6afb4209e" +checksum = "7016ee7a5186d6a80e381aa1926e0f3c7b06eaf444745ff7af3632e978eb8dc5" dependencies = [ "bumpalo", - "hashbrown", + "hashbrown 0.14.5", "ptr_meta", "rustc-hash", "triomphe", @@ -946,9 +961,9 @@ dependencies = [ [[package]] name = "swc_atoms" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0963b5f4cb08353dd4a386c7b5ee1c99d5a097722cdbc6a522efb2aeb91aad71" +checksum = "26cbf6019321add3a50377aaa4e06767a97a115084895289e10be000db207faf" dependencies = [ "hstr", "once_cell", @@ -972,9 +987,9 @@ dependencies = [ [[package]] name = "swc_common" -version = "0.40.0" +version = "0.40.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95fca87acdd34580b59a6f6686dfe72bcc7bad4b7abb7e6728e8e3fd4ecb1d7c" +checksum = "f355465eaed1104244ce918b7ffb77ceb109aabeb74b04b98acae85683b0215b" dependencies = [ "ahash", "ast_node", @@ -1049,14 +1064,14 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] name = "swc_ecma_ast" -version = "0.121.0" +version = "0.121.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1628b2c0c6349c1960b007fda04e0c1537480e0d0b1405305ef5846b752aa7a8" +checksum = "db7e1b73c85ff968404867505646b3c6f26e4661e4fc831593b9e182fa59ddd4" dependencies = [ "bitflags", "is-macro", @@ -1072,9 +1087,9 @@ dependencies = [ [[package]] name = "swc_ecma_codegen" -version = "0.158.0" +version = "0.158.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aef555943803034f0e0fd98ddfe72f1c3454f2c68a897075eb29bc63d4e930" +checksum = "1953878c2f44d796ff4ee8bde727890d24fe3bed9a86a23be4c4ef9ad79b6a6c" dependencies = [ "memchr", "num-bigint", @@ -1099,14 +1114,14 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] name = "swc_ecma_minifier" -version = "0.208.0" +version = "0.208.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c65d350bcb52551bd71df44084ab69a21fa2cf41216c7677d16d75e490d9ef51" +checksum = "67d0fec4e2a4a00c1605f6baa2845cc05b4059c1bf9a6e45377c8ae67f04207d" dependencies = [ "arrayvec", "indexmap", @@ -1139,9 +1154,9 @@ dependencies = [ [[package]] name = "swc_ecma_parser" -version = "0.152.0" +version = "0.152.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ef96894fa0fb3fba233ede22a75a7ddd8b7f0727a40aa8d1028b5dd25013d2e" +checksum = "a4cfd7930abe18c6829d4adedb5249e1b9fa68e8e786c6636250637992ba0466" dependencies = [ "either", "new_debug_unreachable", @@ -1191,14 +1206,14 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] name = "swc_ecma_transforms_optimization" -version = "0.212.0" +version = "0.212.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "454df4c54d0ff859b10e33168c9101f805ca8ee0deb11b71b0380fa6ce844438" +checksum = "0b2722095aef7b6de79b170c8c4e3c885576c5394e7a20328fdc51e880d6257b" dependencies = [ "dashmap", "indexmap", @@ -1277,7 +1292,7 @@ checksum = "63db0adcff29d220c3d151c5b25c0eabe7e32dd936212b84cdaa1392e3130497" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1300,7 +1315,7 @@ checksum = "f486687bfb7b5c560868f69ed2d458b880cebc9babebcb67e49f31b55c5bf847" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1335,9 +1350,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.77" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -1384,7 +1399,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1414,21 +1429,21 @@ checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" [[package]] name = "unicode-bidi" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" +checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" [[package]] name = "unicode-id" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1b6def86329695390197b82c1e244a54a131ceb66c996f2088a3876e2ae083f" +checksum = "10103c57044730945224467c09f71a4db0071c123a0648cc3e818913bde6b561" [[package]] name = "unicode-id-start" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc3882f69607a2ac8cc4de3ee7993d8f68bb06f2974271195065b3bd07f2edea" +checksum = "97e2a3c5fc9de285c0e805d98eba666adb4b2d9e1049ce44821ff7707cc34e91" [[package]] name = "unicode-ident" @@ -1438,18 +1453,18 @@ checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-width" @@ -1508,7 +1523,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "wasm-bindgen-shared", ] @@ -1530,7 +1545,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1654,5 +1669,5 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] diff --git a/rust/bindings_napi/src/lib.rs b/rust/bindings_napi/src/lib.rs index 219334231..92e4cf9c1 100644 --- a/rust/bindings_napi/src/lib.rs +++ b/rust/bindings_napi/src/lib.rs @@ -12,6 +12,7 @@ static ALLOC: mimalloc_rust::GlobalMiMalloc = mimalloc_rust::GlobalMiMalloc; pub struct ParseTask { pub code: String, pub allow_return_outside_function: bool, + pub jsx: bool, } #[napi] @@ -20,7 +21,14 @@ impl Task for ParseTask { type JsValue = Buffer; fn compute(&mut self) -> Result { - Ok(parse_ast(self.code.clone(), self.allow_return_outside_function).into()) + Ok( + parse_ast( + self.code.clone(), + self.allow_return_outside_function, + self.jsx, + ) + .into(), + ) } fn resolve(&mut self, _env: Env, output: Self::Output) -> Result { @@ -29,20 +37,22 @@ impl Task for ParseTask { } #[napi] -pub fn parse(code: String, allow_return_outside_function: bool) -> Buffer { - parse_ast(code, allow_return_outside_function).into() +pub fn parse(code: String, allow_return_outside_function: bool, jsx: bool) -> Buffer { + parse_ast(code, allow_return_outside_function, jsx).into() } #[napi] pub fn parse_async( code: String, allow_return_outside_function: bool, + jsx: bool, signal: Option, ) -> AsyncTask { AsyncTask::with_optional_signal( ParseTask { code, allow_return_outside_function, + jsx, }, signal, ) diff --git a/rust/bindings_wasm/src/lib.rs b/rust/bindings_wasm/src/lib.rs index 23e0f0d65..197809bae 100644 --- a/rust/bindings_wasm/src/lib.rs +++ b/rust/bindings_wasm/src/lib.rs @@ -3,8 +3,8 @@ use parse_ast::parse_ast; use wasm_bindgen::prelude::*; #[wasm_bindgen] -pub fn parse(code: String, allow_return_outside_function: bool) -> Vec { - parse_ast(code, allow_return_outside_function) +pub fn parse(code: String, allow_return_outside_function: bool, jsx: bool) -> Vec { + parse_ast(code, allow_return_outside_function, jsx) } #[wasm_bindgen(js_name=xxhashBase64Url)] diff --git a/rust/parse_ast/Cargo.toml b/rust/parse_ast/Cargo.toml index 9a6007b00..98a43982b 100644 --- a/rust/parse_ast/Cargo.toml +++ b/rust/parse_ast/Cargo.toml @@ -7,9 +7,9 @@ edition = "2021" [dependencies] anyhow = "1.0.89" -swc_atoms = "1.0.0" +swc_atoms = "1.0.1" swc_compiler_base = "0.23.0" -swc_common = { version = "0.40.0", features = ["ahash", "parking_lot"] } -swc_ecma_ast = "0.121.0" -swc_ecma_parser = "0.152.0" +swc_common = { version = "0.40.1", features = ["ahash", "parking_lot"] } +swc_ecma_ast = "0.121.1" +swc_ecma_parser = "0.152.1" parking_lot = "0.12.3" diff --git a/rust/parse_ast/src/ast_nodes/array_expression.rs b/rust/parse_ast/src/ast_nodes/array_expression.rs index ea999b5d4..57bfe1f79 100644 --- a/rust/parse_ast/src/ast_nodes/array_expression.rs +++ b/rust/parse_ast/src/ast_nodes/array_expression.rs @@ -6,7 +6,7 @@ use crate::convert_ast::converter::ast_constants::{ use crate::convert_ast::converter::AstConverter; impl<'a> AstConverter<'a> { - pub fn store_array_expression(&mut self, array_literal: &ArrayLit) { + pub(crate) fn store_array_expression(&mut self, array_literal: &ArrayLit) { let end_position = self.add_type_and_start( &TYPE_ARRAY_EXPRESSION, &array_literal.span, diff --git a/rust/parse_ast/src/ast_nodes/array_pattern.rs b/rust/parse_ast/src/ast_nodes/array_pattern.rs index 90997dda1..913be2007 100644 --- a/rust/parse_ast/src/ast_nodes/array_pattern.rs +++ b/rust/parse_ast/src/ast_nodes/array_pattern.rs @@ -6,7 +6,7 @@ use crate::convert_ast::converter::ast_constants::{ use crate::convert_ast::converter::AstConverter; impl<'a> AstConverter<'a> { - pub fn store_array_pattern(&mut self, array_pattern: &ArrayPat) { + pub(crate) fn store_array_pattern(&mut self, array_pattern: &ArrayPat) { let end_position = self.add_type_and_start( &TYPE_ARRAY_PATTERN, &array_pattern.span, diff --git a/rust/parse_ast/src/ast_nodes/arrow_function_expression.rs b/rust/parse_ast/src/ast_nodes/arrow_function_expression.rs index c737e4580..44fd2d76c 100644 --- a/rust/parse_ast/src/ast_nodes/arrow_function_expression.rs +++ b/rust/parse_ast/src/ast_nodes/arrow_function_expression.rs @@ -10,7 +10,7 @@ use crate::convert_ast::converter::{convert_annotation, AstConverter}; use crate::store_arrow_function_expression_flags; impl<'a> AstConverter<'a> { - pub fn store_arrow_function_expression(&mut self, arrow_expression: &ArrowExpr) { + pub(crate) fn store_arrow_function_expression(&mut self, arrow_expression: &ArrowExpr) { let end_position = self.add_type_and_start( &TYPE_ARROW_FUNCTION_EXPRESSION, &arrow_expression.span, diff --git a/rust/parse_ast/src/ast_nodes/assignment_expression.rs b/rust/parse_ast/src/ast_nodes/assignment_expression.rs index 1b159de3e..4a696977d 100644 --- a/rust/parse_ast/src/ast_nodes/assignment_expression.rs +++ b/rust/parse_ast/src/ast_nodes/assignment_expression.rs @@ -10,7 +10,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_assignment_expression; impl<'a> AstConverter<'a> { - pub fn store_assignment_expression(&mut self, assignment_expression: &AssignExpr) { + pub(crate) fn store_assignment_expression(&mut self, assignment_expression: &AssignExpr) { store_assignment_expression!( self, span => assignment_expression.span, diff --git a/rust/parse_ast/src/ast_nodes/assignment_pattern.rs b/rust/parse_ast/src/ast_nodes/assignment_pattern.rs index 05a0c8a26..3e26ccfaa 100644 --- a/rust/parse_ast/src/ast_nodes/assignment_pattern.rs +++ b/rust/parse_ast/src/ast_nodes/assignment_pattern.rs @@ -8,7 +8,7 @@ use crate::convert_ast::converter::ast_constants::{ use crate::convert_ast::converter::AstConverter; impl<'a> AstConverter<'a> { - pub fn store_assignment_pattern_and_get_left_position( + pub(crate) fn store_assignment_pattern_and_get_left_position( &mut self, span: &Span, left: PatternOrIdentifier, @@ -37,7 +37,7 @@ impl<'a> AstConverter<'a> { left_position } - pub fn convert_assignment_pattern(&mut self, assignment_pattern: &AssignPat) { + pub(crate) fn convert_assignment_pattern(&mut self, assignment_pattern: &AssignPat) { self.store_assignment_pattern_and_get_left_position( &assignment_pattern.span, PatternOrIdentifier::Pattern(&assignment_pattern.left), @@ -46,7 +46,7 @@ impl<'a> AstConverter<'a> { } } -pub enum PatternOrIdentifier<'a> { +pub(crate) enum PatternOrIdentifier<'a> { Pattern(&'a Pat), Identifier(&'a Ident), } diff --git a/rust/parse_ast/src/ast_nodes/await_expression.rs b/rust/parse_ast/src/ast_nodes/await_expression.rs index 820a7c9d1..950ec79f2 100644 --- a/rust/parse_ast/src/ast_nodes/await_expression.rs +++ b/rust/parse_ast/src/ast_nodes/await_expression.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_await_expression; impl<'a> AstConverter<'a> { - pub fn store_await_expression(&mut self, await_expression: &AwaitExpr) { + pub(crate) fn store_await_expression(&mut self, await_expression: &AwaitExpr) { store_await_expression!( self, span => await_expression.span, diff --git a/rust/parse_ast/src/ast_nodes/binary_expression.rs b/rust/parse_ast/src/ast_nodes/binary_expression.rs index 9cd97046d..e4e17702b 100644 --- a/rust/parse_ast/src/ast_nodes/binary_expression.rs +++ b/rust/parse_ast/src/ast_nodes/binary_expression.rs @@ -14,7 +14,7 @@ use crate::convert_ast::converter::string_constants::{ use crate::convert_ast::converter::AstConverter; impl<'a> AstConverter<'a> { - pub fn store_binary_expression(&mut self, binary_expression: &BinExpr) { + pub(crate) fn store_binary_expression(&mut self, binary_expression: &BinExpr) { let end_position = self.add_type_and_start( match binary_expression.op { BinaryOp::LogicalOr | BinaryOp::LogicalAnd | BinaryOp::NullishCoalescing => { diff --git a/rust/parse_ast/src/ast_nodes/block_statement.rs b/rust/parse_ast/src/ast_nodes/block_statement.rs index fec1816c0..dcee9b291 100644 --- a/rust/parse_ast/src/ast_nodes/block_statement.rs +++ b/rust/parse_ast/src/ast_nodes/block_statement.rs @@ -6,7 +6,11 @@ use crate::convert_ast::converter::ast_constants::{ use crate::convert_ast::converter::AstConverter; impl<'a> AstConverter<'a> { - pub fn store_block_statement(&mut self, block_statement: &BlockStmt, check_directive: bool) { + pub(crate) fn store_block_statement( + &mut self, + block_statement: &BlockStmt, + check_directive: bool, + ) { let end_position = self.add_type_and_start( &TYPE_BLOCK_STATEMENT, &block_statement.span, diff --git a/rust/parse_ast/src/ast_nodes/break_statement.rs b/rust/parse_ast/src/ast_nodes/break_statement.rs index ef54b723d..c92c4133f 100644 --- a/rust/parse_ast/src/ast_nodes/break_statement.rs +++ b/rust/parse_ast/src/ast_nodes/break_statement.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_break_statement; impl<'a> AstConverter<'a> { - pub fn store_break_statement(&mut self, break_statement: &BreakStmt) { + pub(crate) fn store_break_statement(&mut self, break_statement: &BreakStmt) { store_break_statement!( self, span => break_statement.span, diff --git a/rust/parse_ast/src/ast_nodes/call_expression.rs b/rust/parse_ast/src/ast_nodes/call_expression.rs index e8d3c5265..e5dff9ea9 100644 --- a/rust/parse_ast/src/ast_nodes/call_expression.rs +++ b/rust/parse_ast/src/ast_nodes/call_expression.rs @@ -10,7 +10,7 @@ use crate::convert_ast::converter::{convert_annotation, AstConverter}; use crate::store_call_expression_flags; impl<'a> AstConverter<'a> { - pub fn store_call_expression( + pub(crate) fn store_call_expression( &mut self, span: &Span, is_optional: bool, @@ -70,7 +70,7 @@ impl<'a> AstConverter<'a> { self.add_end(end_position, span); } - pub fn convert_optional_call( + pub(crate) fn convert_optional_call( &mut self, optional_call: &OptCall, is_optional: bool, @@ -86,7 +86,7 @@ impl<'a> AstConverter<'a> { } } -pub enum StoredCallee<'a> { +pub(crate) enum StoredCallee<'a> { Expression(&'a Expr), Super(&'a Super), } diff --git a/rust/parse_ast/src/ast_nodes/catch_clause.rs b/rust/parse_ast/src/ast_nodes/catch_clause.rs index 78e85906e..903233765 100644 --- a/rust/parse_ast/src/ast_nodes/catch_clause.rs +++ b/rust/parse_ast/src/ast_nodes/catch_clause.rs @@ -7,7 +7,7 @@ use crate::convert_ast::converter::ast_constants::{ use crate::convert_ast::converter::AstConverter; impl<'a> AstConverter<'a> { - pub fn store_catch_clause(&mut self, catch_clause: &CatchClause) { + pub(crate) fn store_catch_clause(&mut self, catch_clause: &CatchClause) { let end_position = self.add_type_and_start( &TYPE_CATCH_CLAUSE, &catch_clause.span, diff --git a/rust/parse_ast/src/ast_nodes/chain_expression.rs b/rust/parse_ast/src/ast_nodes/chain_expression.rs index 4d29a797f..f034d8cd5 100644 --- a/rust/parse_ast/src/ast_nodes/chain_expression.rs +++ b/rust/parse_ast/src/ast_nodes/chain_expression.rs @@ -6,7 +6,7 @@ use crate::convert_ast::converter::ast_constants::{ use crate::convert_ast::converter::AstConverter; impl<'a> AstConverter<'a> { - pub fn store_chain_expression( + pub(crate) fn store_chain_expression( &mut self, optional_chain_expression: &OptChainExpr, is_chained: bool, diff --git a/rust/parse_ast/src/ast_nodes/class_body.rs b/rust/parse_ast/src/ast_nodes/class_body.rs index 7d187e604..696ce2434 100644 --- a/rust/parse_ast/src/ast_nodes/class_body.rs +++ b/rust/parse_ast/src/ast_nodes/class_body.rs @@ -6,7 +6,7 @@ use crate::convert_ast::converter::ast_constants::{ use crate::convert_ast::converter::AstConverter; impl<'a> AstConverter<'a> { - pub fn store_class_body(&mut self, class_members: &[ClassMember], start: u32, end: u32) { + pub(crate) fn store_class_body(&mut self, class_members: &[ClassMember], start: u32, end: u32) { let end_position = self.add_type_and_explicit_start(&TYPE_CLASS_BODY, start, CLASS_BODY_RESERVED_BYTES); let class_members_filtered: Vec<&ClassMember> = class_members diff --git a/rust/parse_ast/src/ast_nodes/class_declaration.rs b/rust/parse_ast/src/ast_nodes/class_declaration.rs index 73cdd733e..7b79633f8 100644 --- a/rust/parse_ast/src/ast_nodes/class_declaration.rs +++ b/rust/parse_ast/src/ast_nodes/class_declaration.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::ast_constants::TYPE_CLASS_DECLARATION; use crate::convert_ast::converter::AstConverter; impl<'a> AstConverter<'a> { - pub fn store_class_declaration(&mut self, class_declaration: &ClassDecl) { + pub(crate) fn store_class_declaration(&mut self, class_declaration: &ClassDecl) { self.store_class_node( &TYPE_CLASS_DECLARATION, Some(&class_declaration.ident), diff --git a/rust/parse_ast/src/ast_nodes/class_expression.rs b/rust/parse_ast/src/ast_nodes/class_expression.rs index c5515fe1e..dea6030d8 100644 --- a/rust/parse_ast/src/ast_nodes/class_expression.rs +++ b/rust/parse_ast/src/ast_nodes/class_expression.rs @@ -3,7 +3,11 @@ use swc_ecma_ast::ClassExpr; use crate::convert_ast::converter::AstConverter; impl<'a> AstConverter<'a> { - pub fn store_class_expression(&mut self, class_expression: &ClassExpr, node_type: &[u8; 4]) { + pub(crate) fn store_class_expression( + &mut self, + class_expression: &ClassExpr, + node_type: &[u8; 4], + ) { self.store_class_node( node_type, class_expression.ident.as_ref(), diff --git a/rust/parse_ast/src/ast_nodes/conditional_expression.rs b/rust/parse_ast/src/ast_nodes/conditional_expression.rs index 402d14981..13333943e 100644 --- a/rust/parse_ast/src/ast_nodes/conditional_expression.rs +++ b/rust/parse_ast/src/ast_nodes/conditional_expression.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_conditional_expression; impl<'a> AstConverter<'a> { - pub fn store_conditional_expression(&mut self, conditional_expression: &CondExpr) { + pub(crate) fn store_conditional_expression(&mut self, conditional_expression: &CondExpr) { store_conditional_expression!( self, span => conditional_expression.span, diff --git a/rust/parse_ast/src/ast_nodes/continue_statement.rs b/rust/parse_ast/src/ast_nodes/continue_statement.rs index 6614f7910..6d652d290 100644 --- a/rust/parse_ast/src/ast_nodes/continue_statement.rs +++ b/rust/parse_ast/src/ast_nodes/continue_statement.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_continue_statement; impl<'a> AstConverter<'a> { - pub fn store_continue_statement(&mut self, continue_statement: &ContinueStmt) { + pub(crate) fn store_continue_statement(&mut self, continue_statement: &ContinueStmt) { store_continue_statement!( self, span => continue_statement.span, diff --git a/rust/parse_ast/src/ast_nodes/debugger_statement.rs b/rust/parse_ast/src/ast_nodes/debugger_statement.rs index ac3ea4680..5b35df24b 100644 --- a/rust/parse_ast/src/ast_nodes/debugger_statement.rs +++ b/rust/parse_ast/src/ast_nodes/debugger_statement.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_debugger_statement; impl<'a> AstConverter<'a> { - pub fn store_debugger_statement(&mut self, debugger_statement: &DebuggerStmt) { + pub(crate) fn store_debugger_statement(&mut self, debugger_statement: &DebuggerStmt) { store_debugger_statement!(self, span => debugger_statement.span); } } diff --git a/rust/parse_ast/src/ast_nodes/decorator.rs b/rust/parse_ast/src/ast_nodes/decorator.rs index 128fb730d..61bdc265b 100644 --- a/rust/parse_ast/src/ast_nodes/decorator.rs +++ b/rust/parse_ast/src/ast_nodes/decorator.rs @@ -1,9 +1,10 @@ +use swc_ecma_ast::Decorator; + use crate::convert_ast::converter::AstConverter; use crate::store_decorator; -use swc_ecma_ast::Decorator; impl<'a> AstConverter<'a> { - pub fn store_decorator(&mut self, decorator: &Decorator) { + pub(crate) fn store_decorator(&mut self, decorator: &Decorator) { store_decorator!(self, span => decorator.span, expression=>[decorator.expr, convert_expression]); } } diff --git a/rust/parse_ast/src/ast_nodes/directive.rs b/rust/parse_ast/src/ast_nodes/directive.rs index 6290f3151..ed7bf34d9 100644 --- a/rust/parse_ast/src/ast_nodes/directive.rs +++ b/rust/parse_ast/src/ast_nodes/directive.rs @@ -5,7 +5,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_directive; impl<'a> AstConverter<'a> { - pub fn store_directive(&mut self, expression_statement: &ExprStmt, directive: &JsWord) { + pub(crate) fn store_directive(&mut self, expression_statement: &ExprStmt, directive: &JsWord) { store_directive!( self, span => expression_statement.span, diff --git a/rust/parse_ast/src/ast_nodes/do_while_statement.rs b/rust/parse_ast/src/ast_nodes/do_while_statement.rs index 01cb24d33..bf00756cc 100644 --- a/rust/parse_ast/src/ast_nodes/do_while_statement.rs +++ b/rust/parse_ast/src/ast_nodes/do_while_statement.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_do_while_statement; impl<'a> AstConverter<'a> { - pub fn store_do_while_statement(&mut self, do_while_statement: &DoWhileStmt) { + pub(crate) fn store_do_while_statement(&mut self, do_while_statement: &DoWhileStmt) { store_do_while_statement!( self, span => do_while_statement.span, diff --git a/rust/parse_ast/src/ast_nodes/empty_statement.rs b/rust/parse_ast/src/ast_nodes/empty_statement.rs index 22d9d147b..9206fbe3a 100644 --- a/rust/parse_ast/src/ast_nodes/empty_statement.rs +++ b/rust/parse_ast/src/ast_nodes/empty_statement.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_empty_statement; impl<'a> AstConverter<'a> { - pub fn store_empty_statement(&mut self, empty_statement: &EmptyStmt) { + pub(crate) fn store_empty_statement(&mut self, empty_statement: &EmptyStmt) { store_empty_statement!(self, span => empty_statement.span); } } diff --git a/rust/parse_ast/src/ast_nodes/export_all_declaration.rs b/rust/parse_ast/src/ast_nodes/export_all_declaration.rs index 57a8c2efe..fd0ac5c1c 100644 --- a/rust/parse_ast/src/ast_nodes/export_all_declaration.rs +++ b/rust/parse_ast/src/ast_nodes/export_all_declaration.rs @@ -9,7 +9,7 @@ use crate::convert_ast::converter::ast_constants::{ use crate::convert_ast::converter::AstConverter; impl<'a> AstConverter<'a> { - pub fn store_export_all_declaration( + pub(crate) fn store_export_all_declaration( &mut self, span: &Span, source: &Str, @@ -39,7 +39,7 @@ impl<'a> AstConverter<'a> { self.add_end(end_position, span); } - pub fn convert_export_all(&mut self, export_all: &ExportAll) { + pub(crate) fn convert_export_all(&mut self, export_all: &ExportAll) { self.store_export_all_declaration(&export_all.span, &export_all.src, &export_all.with, None); } } diff --git a/rust/parse_ast/src/ast_nodes/export_default_declaration.rs b/rust/parse_ast/src/ast_nodes/export_default_declaration.rs index d1c557b4f..c673e2904 100644 --- a/rust/parse_ast/src/ast_nodes/export_default_declaration.rs +++ b/rust/parse_ast/src/ast_nodes/export_default_declaration.rs @@ -8,7 +8,7 @@ use crate::convert_ast::converter::ast_constants::{ use crate::convert_ast::converter::AstConverter; impl<'a> AstConverter<'a> { - pub fn store_export_default_declaration( + pub(crate) fn store_export_default_declaration( &mut self, span: &Span, expression: StoredDefaultExportExpression, @@ -42,7 +42,7 @@ impl<'a> AstConverter<'a> { self.add_end(end_position, span); } - pub fn convert_export_default_declaration( + pub(crate) fn convert_export_default_declaration( &mut self, export_default_declaration: &ExportDefaultDecl, ) { @@ -62,7 +62,7 @@ impl<'a> AstConverter<'a> { ); } - pub fn convert_export_default_expression( + pub(crate) fn convert_export_default_expression( &mut self, export_default_expression: &ExportDefaultExpr, ) { @@ -73,7 +73,7 @@ impl<'a> AstConverter<'a> { } } -pub enum StoredDefaultExportExpression<'a> { +pub(crate) enum StoredDefaultExportExpression<'a> { Expression(&'a Expr), Class(&'a ClassExpr), Function(&'a FnExpr), diff --git a/rust/parse_ast/src/ast_nodes/export_named_declaration.rs b/rust/parse_ast/src/ast_nodes/export_named_declaration.rs index c195afdc0..73cd62eeb 100644 --- a/rust/parse_ast/src/ast_nodes/export_named_declaration.rs +++ b/rust/parse_ast/src/ast_nodes/export_named_declaration.rs @@ -9,7 +9,7 @@ use crate::convert_ast::converter::ast_constants::{ use crate::convert_ast::converter::AstConverter; impl<'a> AstConverter<'a> { - pub fn store_export_named_declaration( + pub(crate) fn store_export_named_declaration( &mut self, span: &Span, specifiers: &[ExportSpecifier], diff --git a/rust/parse_ast/src/ast_nodes/export_specifier.rs b/rust/parse_ast/src/ast_nodes/export_specifier.rs index adb8c09cf..5319746cd 100644 --- a/rust/parse_ast/src/ast_nodes/export_specifier.rs +++ b/rust/parse_ast/src/ast_nodes/export_specifier.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_export_specifier; impl<'a> AstConverter<'a> { - pub fn store_export_specifier(&mut self, export_named_specifier: &ExportNamedSpecifier) { + pub(crate) fn store_export_specifier(&mut self, export_named_specifier: &ExportNamedSpecifier) { store_export_specifier!( self, span => &export_named_specifier.span, diff --git a/rust/parse_ast/src/ast_nodes/expression_statement.rs b/rust/parse_ast/src/ast_nodes/expression_statement.rs index 7fed6d836..b71d13f2a 100644 --- a/rust/parse_ast/src/ast_nodes/expression_statement.rs +++ b/rust/parse_ast/src/ast_nodes/expression_statement.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_expression_statement; impl<'a> AstConverter<'a> { - pub fn store_expression_statement(&mut self, expression_statement: &ExprStmt) { + pub(crate) fn store_expression_statement(&mut self, expression_statement: &ExprStmt) { store_expression_statement!( self, span => &expression_statement.span, diff --git a/rust/parse_ast/src/ast_nodes/for_in_statement.rs b/rust/parse_ast/src/ast_nodes/for_in_statement.rs index 72bf9e3dd..8a584c8f4 100644 --- a/rust/parse_ast/src/ast_nodes/for_in_statement.rs +++ b/rust/parse_ast/src/ast_nodes/for_in_statement.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_for_in_statement; impl<'a> AstConverter<'a> { - pub fn store_for_in_statement(&mut self, for_in_statement: &ForInStmt) { + pub(crate) fn store_for_in_statement(&mut self, for_in_statement: &ForInStmt) { store_for_in_statement!( self, span => &for_in_statement.span, diff --git a/rust/parse_ast/src/ast_nodes/for_of_statement.rs b/rust/parse_ast/src/ast_nodes/for_of_statement.rs index a57e69cfe..eb27dd7e0 100644 --- a/rust/parse_ast/src/ast_nodes/for_of_statement.rs +++ b/rust/parse_ast/src/ast_nodes/for_of_statement.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::{store_for_of_statement, store_for_of_statement_flags}; impl<'a> AstConverter<'a> { - pub fn store_for_of_statement(&mut self, for_of_statement: &ForOfStmt) { + pub(crate) fn store_for_of_statement(&mut self, for_of_statement: &ForOfStmt) { store_for_of_statement!( self, span => &for_of_statement.span, diff --git a/rust/parse_ast/src/ast_nodes/for_statement.rs b/rust/parse_ast/src/ast_nodes/for_statement.rs index 1d16325e7..fd797ee70 100644 --- a/rust/parse_ast/src/ast_nodes/for_statement.rs +++ b/rust/parse_ast/src/ast_nodes/for_statement.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_for_statement; impl<'a> AstConverter<'a> { - pub fn store_for_statement(&mut self, for_statement: &ForStmt) { + pub(crate) fn store_for_statement(&mut self, for_statement: &ForStmt) { store_for_statement!( self, span => &for_statement.span, diff --git a/rust/parse_ast/src/ast_nodes/identifier.rs b/rust/parse_ast/src/ast_nodes/identifier.rs index a92658dc1..c42b21574 100644 --- a/rust/parse_ast/src/ast_nodes/identifier.rs +++ b/rust/parse_ast/src/ast_nodes/identifier.rs @@ -6,7 +6,7 @@ use crate::convert_ast::converter::ast_constants::{ use crate::convert_ast::converter::AstConverter; impl<'a> AstConverter<'a> { - pub fn store_identifier(&mut self, start: u32, end: u32, name: &str) { + pub(crate) fn store_identifier(&mut self, start: u32, end: u32, name: &str) { let end_position = self.add_type_and_explicit_start(&TYPE_IDENTIFIER, start, IDENTIFIER_RESERVED_BYTES); // name @@ -15,18 +15,18 @@ impl<'a> AstConverter<'a> { self.add_explicit_end(end_position, end); } - pub fn convert_binding_identifier(&mut self, binding_identifier: &BindingIdent) { + pub(crate) fn convert_binding_identifier(&mut self, binding_identifier: &BindingIdent) { self.convert_identifier(&binding_identifier.id); } - pub fn convert_identifier(&mut self, identifier: &Ident) { + pub(crate) fn convert_identifier(&mut self, identifier: &Ident) { self.store_identifier( identifier.span.lo.0 - 1, identifier.span.hi.0 - 1, &identifier.sym, ); } - pub fn convert_identifier_name(&mut self, identifier: &IdentName) { + pub(crate) fn convert_identifier_name(&mut self, identifier: &IdentName) { self.store_identifier( identifier.span.lo.0 - 1, identifier.span.hi.0 - 1, diff --git a/rust/parse_ast/src/ast_nodes/if_statement.rs b/rust/parse_ast/src/ast_nodes/if_statement.rs index e093372cb..c8dcb86f3 100644 --- a/rust/parse_ast/src/ast_nodes/if_statement.rs +++ b/rust/parse_ast/src/ast_nodes/if_statement.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_if_statement; impl<'a> AstConverter<'a> { - pub fn store_if_statement(&mut self, if_statement: &IfStmt) { + pub(crate) fn store_if_statement(&mut self, if_statement: &IfStmt) { store_if_statement!( self, span => &if_statement.span, diff --git a/rust/parse_ast/src/ast_nodes/import_attribute.rs b/rust/parse_ast/src/ast_nodes/import_attribute.rs index 829ab14bf..fc1842961 100644 --- a/rust/parse_ast/src/ast_nodes/import_attribute.rs +++ b/rust/parse_ast/src/ast_nodes/import_attribute.rs @@ -8,7 +8,7 @@ use crate::convert_ast::converter::ast_constants::{ use crate::convert_ast::converter::AstConverter; impl<'a> AstConverter<'a> { - pub fn store_import_attribute(&mut self, key_value_property: &KeyValueProp) { + pub(crate) fn store_import_attribute(&mut self, key_value_property: &KeyValueProp) { // type let end_position = self.add_type_and_start( &TYPE_IMPORT_ATTRIBUTE, @@ -25,7 +25,7 @@ impl<'a> AstConverter<'a> { self.add_end(end_position, &key_value_property.span()); } - pub fn store_import_attributes( + pub(crate) fn store_import_attributes( &mut self, with: &Option>, reference_position: usize, diff --git a/rust/parse_ast/src/ast_nodes/import_declaration.rs b/rust/parse_ast/src/ast_nodes/import_declaration.rs index af58998c6..99890338d 100644 --- a/rust/parse_ast/src/ast_nodes/import_declaration.rs +++ b/rust/parse_ast/src/ast_nodes/import_declaration.rs @@ -7,7 +7,7 @@ use crate::convert_ast::converter::ast_constants::{ use crate::convert_ast::converter::AstConverter; impl<'a> AstConverter<'a> { - pub fn store_import_declaration(&mut self, import_declaration: &ImportDecl) { + pub(crate) fn store_import_declaration(&mut self, import_declaration: &ImportDecl) { let end_position = self.add_type_and_start( &TYPE_IMPORT_DECLARATION, &import_declaration.span, diff --git a/rust/parse_ast/src/ast_nodes/import_default_specifier.rs b/rust/parse_ast/src/ast_nodes/import_default_specifier.rs index 689bd5f4e..70c8d5bb7 100644 --- a/rust/parse_ast/src/ast_nodes/import_default_specifier.rs +++ b/rust/parse_ast/src/ast_nodes/import_default_specifier.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_import_default_specifier; impl<'a> AstConverter<'a> { - pub fn store_import_default_specifier( + pub(crate) fn store_import_default_specifier( &mut self, import_default_specifier: &ImportDefaultSpecifier, ) { diff --git a/rust/parse_ast/src/ast_nodes/import_expression.rs b/rust/parse_ast/src/ast_nodes/import_expression.rs index 2232b0f5d..19cff3f0d 100644 --- a/rust/parse_ast/src/ast_nodes/import_expression.rs +++ b/rust/parse_ast/src/ast_nodes/import_expression.rs @@ -8,7 +8,7 @@ use crate::convert_ast::converter::ast_constants::{ use crate::convert_ast::converter::AstConverter; impl<'a> AstConverter<'a> { - pub fn store_import_expression(&mut self, span: &Span, arguments: &[ExprOrSpread]) { + pub(crate) fn store_import_expression(&mut self, span: &Span, arguments: &[ExprOrSpread]) { let end_position = self.add_type_and_start( &TYPE_IMPORT_EXPRESSION, span, diff --git a/rust/parse_ast/src/ast_nodes/import_namespace_specifier.rs b/rust/parse_ast/src/ast_nodes/import_namespace_specifier.rs index f7ffe93f3..0128b0e5c 100644 --- a/rust/parse_ast/src/ast_nodes/import_namespace_specifier.rs +++ b/rust/parse_ast/src/ast_nodes/import_namespace_specifier.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_import_namespace_specifier; impl<'a> AstConverter<'a> { - pub fn store_import_namespace_specifier( + pub(crate) fn store_import_namespace_specifier( &mut self, import_namespace_specifier: &ImportStarAsSpecifier, ) { diff --git a/rust/parse_ast/src/ast_nodes/import_specifier.rs b/rust/parse_ast/src/ast_nodes/import_specifier.rs index 1d02bf067..3c1627022 100644 --- a/rust/parse_ast/src/ast_nodes/import_specifier.rs +++ b/rust/parse_ast/src/ast_nodes/import_specifier.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_import_specifier; impl<'a> AstConverter<'a> { - pub fn store_import_specifier(&mut self, import_named_specifier: &ImportNamedSpecifier) { + pub(crate) fn store_import_specifier(&mut self, import_named_specifier: &ImportNamedSpecifier) { store_import_specifier!( self, span => &import_named_specifier.span, diff --git a/rust/parse_ast/src/ast_nodes/jsx_attribute.rs b/rust/parse_ast/src/ast_nodes/jsx_attribute.rs new file mode 100644 index 000000000..1e36f231e --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_attribute.rs @@ -0,0 +1,15 @@ +use swc_ecma_ast::JSXAttr; + +use crate::convert_ast::converter::AstConverter; +use crate::store_jsx_attribute; + +impl<'a> AstConverter<'a> { + pub(crate) fn store_jsx_attribute(&mut self, jsx_attribute: &JSXAttr) { + store_jsx_attribute!( + self, + span => jsx_attribute.span, + name => [jsx_attribute.name, convert_jsx_attribute_name], + value => [jsx_attribute.value, convert_jsx_attribute_value] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_closing_element.rs b/rust/parse_ast/src/ast_nodes/jsx_closing_element.rs new file mode 100644 index 000000000..c5281e50d --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_closing_element.rs @@ -0,0 +1,14 @@ +use swc_ecma_ast::JSXClosingElement; + +use crate::convert_ast::converter::AstConverter; +use crate::store_jsx_closing_element; + +impl<'a> AstConverter<'a> { + pub(crate) fn store_jsx_closing_element(&mut self, jsx_closing_element: &JSXClosingElement) { + store_jsx_closing_element!( + self, + span => jsx_closing_element.span, + name => [jsx_closing_element.name, convert_jsx_element_name] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_closing_fragment.rs b/rust/parse_ast/src/ast_nodes/jsx_closing_fragment.rs new file mode 100644 index 000000000..650df600f --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_closing_fragment.rs @@ -0,0 +1,13 @@ +use swc_ecma_ast::JSXClosingFragment; + +use crate::convert_ast::converter::AstConverter; +use crate::store_jsx_closing_fragment; + +impl<'a> AstConverter<'a> { + pub(crate) fn store_jsx_closing_fragment(&mut self, jsx_closing_fragment: &JSXClosingFragment) { + store_jsx_closing_fragment!( + self, + span => jsx_closing_fragment.span + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_element.rs b/rust/parse_ast/src/ast_nodes/jsx_element.rs new file mode 100644 index 000000000..6a425940f --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_element.rs @@ -0,0 +1,16 @@ +use swc_ecma_ast::JSXElement; + +use crate::convert_ast::converter::AstConverter; +use crate::store_jsx_element; + +impl<'a> AstConverter<'a> { + pub(crate) fn store_jsx_element(&mut self, jsx_element: &JSXElement) { + store_jsx_element!( + self, + span => jsx_element.span, + openingElement => [jsx_element.opening, store_jsx_opening_element], + children => [jsx_element.children, convert_jsx_element_child], + closingElement => [jsx_element.closing, store_jsx_closing_element] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_empty_expression.rs b/rust/parse_ast/src/ast_nodes/jsx_empty_expression.rs new file mode 100644 index 000000000..5b33e034e --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_empty_expression.rs @@ -0,0 +1,16 @@ +use crate::convert_ast::converter::ast_constants::{ + JSX_EMPTY_EXPRESSION_RESERVED_BYTES, TYPE_JSX_EMPTY_EXPRESSION, +}; +use crate::convert_ast::converter::AstConverter; + +impl<'a> AstConverter<'a> { + pub(crate) fn store_jsx_empty_expression(&mut self, start: u32, end: u32) { + let end_position = self.add_type_and_explicit_start( + &TYPE_JSX_EMPTY_EXPRESSION, + start, + JSX_EMPTY_EXPRESSION_RESERVED_BYTES, + ); + // end + self.add_explicit_end(end_position, end); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_expression_container.rs b/rust/parse_ast/src/ast_nodes/jsx_expression_container.rs new file mode 100644 index 000000000..d1dc186e0 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_expression_container.rs @@ -0,0 +1,31 @@ +use swc_ecma_ast::{JSXExpr, JSXExprContainer}; + +use crate::convert_ast::converter::ast_constants::{ + JSX_EXPRESSION_CONTAINER_EXPRESSION_OFFSET, JSX_EXPRESSION_CONTAINER_RESERVED_BYTES, + TYPE_JSX_EXPRESSION_CONTAINER, +}; +use crate::convert_ast::converter::AstConverter; + +impl<'a> AstConverter<'a> { + pub(crate) fn store_jsx_expression_container(&mut self, jsx_expr_container: &JSXExprContainer) { + let end_position = self.add_type_and_start( + &TYPE_JSX_EXPRESSION_CONTAINER, + &jsx_expr_container.span, + JSX_EXPRESSION_CONTAINER_RESERVED_BYTES, + false, + ); + // expression + self.update_reference_position(end_position + JSX_EXPRESSION_CONTAINER_EXPRESSION_OFFSET); + match &jsx_expr_container.expr { + JSXExpr::Expr(expression) => { + self.convert_expression(expression); + } + JSXExpr::JSXEmptyExpr(jsx_empty_expr) => { + // The span does not consider the size of the container, hence we use the container span + self.store_jsx_empty_expression(jsx_expr_container.span.lo.0, jsx_empty_expr.span.hi.0 - 1); + } + } + // end + self.add_end(end_position, &jsx_expr_container.span); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_fragment.rs b/rust/parse_ast/src/ast_nodes/jsx_fragment.rs new file mode 100644 index 000000000..0d7a19ded --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_fragment.rs @@ -0,0 +1,16 @@ +use swc_ecma_ast::JSXFragment; + +use crate::convert_ast::converter::AstConverter; +use crate::store_jsx_fragment; + +impl<'a> AstConverter<'a> { + pub(crate) fn store_jsx_fragment(&mut self, jsx_fragment: &JSXFragment) { + store_jsx_fragment!( + self, + span => jsx_fragment.span, + openingFragment => [jsx_fragment.opening, store_jsx_opening_fragment], + children => [jsx_fragment.children, convert_jsx_element_child], + closingFragment => [jsx_fragment.closing, store_jsx_closing_fragment] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_identifier.rs b/rust/parse_ast/src/ast_nodes/jsx_identifier.rs new file mode 100644 index 000000000..0a3ba71c6 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_identifier.rs @@ -0,0 +1,14 @@ +use swc_common::Span; + +use crate::convert_ast::converter::AstConverter; +use crate::store_jsx_identifier; + +impl<'a> AstConverter<'a> { + pub(crate) fn store_jsx_identifier(&mut self, span: &Span, name: &str) { + store_jsx_identifier!( + self, + span => span, + name => name + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_member_expression.rs b/rust/parse_ast/src/ast_nodes/jsx_member_expression.rs new file mode 100644 index 000000000..b31460e0b --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_member_expression.rs @@ -0,0 +1,29 @@ +use swc_ecma_ast::JSXMemberExpr; + +use crate::convert_ast::converter::ast_constants::{ + JSX_MEMBER_EXPRESSION_OBJECT_OFFSET, JSX_MEMBER_EXPRESSION_PROPERTY_OFFSET, + JSX_MEMBER_EXPRESSION_RESERVED_BYTES, TYPE_JSX_MEMBER_EXPRESSION, +}; +use crate::convert_ast::converter::AstConverter; + +impl<'a> AstConverter<'a> { + pub(crate) fn store_jsx_member_expression(&mut self, jsx_member_expression: &JSXMemberExpr) { + let end_position = self.add_type_and_start( + &TYPE_JSX_MEMBER_EXPRESSION, + &jsx_member_expression.span, + JSX_MEMBER_EXPRESSION_RESERVED_BYTES, + false, + ); + // object + self.update_reference_position(end_position + JSX_MEMBER_EXPRESSION_OBJECT_OFFSET); + self.convert_jsx_object(&jsx_member_expression.obj); + // property + self.update_reference_position(end_position + JSX_MEMBER_EXPRESSION_PROPERTY_OFFSET); + self.store_jsx_identifier( + &jsx_member_expression.prop.span, + &jsx_member_expression.prop.sym, + ); + // end + self.add_end(end_position, &jsx_member_expression.span); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_namespaced_name.rs b/rust/parse_ast/src/ast_nodes/jsx_namespaced_name.rs new file mode 100644 index 000000000..ed61746af --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_namespaced_name.rs @@ -0,0 +1,29 @@ +use swc_ecma_ast::JSXNamespacedName; + +use crate::convert_ast::converter::ast_constants::{ + JSX_NAMESPACED_NAME_NAMESPACE_OFFSET, JSX_NAMESPACED_NAME_NAME_OFFSET, + JSX_NAMESPACED_NAME_RESERVED_BYTES, TYPE_JSX_NAMESPACED_NAME, +}; +use crate::convert_ast::converter::AstConverter; + +impl<'a> AstConverter<'a> { + pub(crate) fn store_jsx_namespaced_name(&mut self, jsx_namespaced_name: &JSXNamespacedName) { + let end_position = self.add_type_and_start( + &TYPE_JSX_NAMESPACED_NAME, + &jsx_namespaced_name.ns.span, + JSX_NAMESPACED_NAME_RESERVED_BYTES, + false, + ); + // namespace + self.update_reference_position(end_position + JSX_NAMESPACED_NAME_NAMESPACE_OFFSET); + self.store_jsx_identifier(&jsx_namespaced_name.ns.span, &jsx_namespaced_name.ns.sym); + // name + self.update_reference_position(end_position + JSX_NAMESPACED_NAME_NAME_OFFSET); + self.store_jsx_identifier( + &jsx_namespaced_name.name.span, + &jsx_namespaced_name.name.sym, + ); + // end + self.add_end(end_position, &jsx_namespaced_name.name.span); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_opening_element.rs b/rust/parse_ast/src/ast_nodes/jsx_opening_element.rs new file mode 100644 index 000000000..1bd4b1025 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_opening_element.rs @@ -0,0 +1,43 @@ +use swc_common::Spanned; +use swc_ecma_ast::JSXOpeningElement; + +use crate::convert_ast::converter::ast_constants::{ + JSX_OPENING_ELEMENT_ATTRIBUTES_OFFSET, JSX_OPENING_ELEMENT_NAME_OFFSET, + JSX_OPENING_ELEMENT_RESERVED_BYTES, TYPE_JSX_OPENING_ELEMENT, +}; +use crate::convert_ast::converter::AstConverter; +use crate::store_jsx_opening_element_flags; + +impl<'a> AstConverter<'a> { + pub(crate) fn store_jsx_opening_element(&mut self, jsx_opening_element: &JSXOpeningElement) { + let end_position = self.add_type_and_start( + &TYPE_JSX_OPENING_ELEMENT, + &jsx_opening_element.span, + JSX_OPENING_ELEMENT_RESERVED_BYTES, + false, + ); + // flags + store_jsx_opening_element_flags!( + self, + end_position, + selfClosing => jsx_opening_element.self_closing + ); + // name + self.update_reference_position(end_position + JSX_OPENING_ELEMENT_NAME_OFFSET); + self.convert_jsx_element_name(&jsx_opening_element.name); + // attributes + let mut previous_element_end = jsx_opening_element.name.span().hi.0; + self.convert_item_list_with_state( + &jsx_opening_element.attrs, + &mut previous_element_end, + end_position + JSX_OPENING_ELEMENT_ATTRIBUTES_OFFSET, + |ast_converter, jsx_attribute, previous_end| { + ast_converter.convert_jsx_attribute_or_spread(jsx_attribute, *previous_end); + *previous_end = jsx_attribute.span().hi.0; + true + }, + ); + // end + self.add_end(end_position, &jsx_opening_element.span); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_opening_fragment.rs b/rust/parse_ast/src/ast_nodes/jsx_opening_fragment.rs new file mode 100644 index 000000000..acb52da45 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_opening_fragment.rs @@ -0,0 +1,13 @@ +use swc_ecma_ast::JSXOpeningFragment; + +use crate::convert_ast::converter::AstConverter; +use crate::store_jsx_opening_fragment; + +impl<'a> AstConverter<'a> { + pub(crate) fn store_jsx_opening_fragment(&mut self, jsx_opening_fragment: &JSXOpeningFragment) { + store_jsx_opening_fragment!( + self, + span => jsx_opening_fragment.span + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_spread_attribute.rs b/rust/parse_ast/src/ast_nodes/jsx_spread_attribute.rs new file mode 100644 index 000000000..86eb4dfcd --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_spread_attribute.rs @@ -0,0 +1,32 @@ +use swc_common::Spanned; +use swc_ecma_ast::SpreadElement; + +use crate::convert_ast::converter::analyze_code::find_first_occurrence_outside_comment; +use crate::convert_ast::converter::ast_constants::{ + JSX_SPREAD_ATTRIBUTE_ARGUMENT_OFFSET, JSX_SPREAD_ATTRIBUTE_RESERVED_BYTES, + TYPE_JSX_SPREAD_ATTRIBUTE, +}; +use crate::convert_ast::converter::AstConverter; + +impl<'a> AstConverter<'a> { + pub(crate) fn store_jsx_spread_attribute( + &mut self, + spread_element: &SpreadElement, + previous_element_end: u32, + ) { + let end_position = self.add_type_and_explicit_start( + &TYPE_JSX_SPREAD_ATTRIBUTE, + find_first_occurrence_outside_comment(self.code, b'{', previous_element_end), + JSX_SPREAD_ATTRIBUTE_RESERVED_BYTES, + ); + // argument + self.update_reference_position(end_position + JSX_SPREAD_ATTRIBUTE_ARGUMENT_OFFSET); + self.convert_expression(&spread_element.expr); + // end + self.add_explicit_end( + end_position, + find_first_occurrence_outside_comment(self.code, b'}', spread_element.expr.span().hi.0 - 1) + + 1, + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_spread_child.rs b/rust/parse_ast/src/ast_nodes/jsx_spread_child.rs new file mode 100644 index 000000000..b65bc4961 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_spread_child.rs @@ -0,0 +1,14 @@ +use swc_ecma_ast::JSXSpreadChild; + +use crate::convert_ast::converter::AstConverter; +use crate::store_jsx_spread_child; + +impl<'a> AstConverter<'a> { + pub(crate) fn store_jsx_spread_child(&mut self, jsx_spread_child: &JSXSpreadChild) { + store_jsx_spread_child!( + self, + span => jsx_spread_child.span, + expression => [jsx_spread_child.expr, convert_expression] + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/jsx_text.rs b/rust/parse_ast/src/ast_nodes/jsx_text.rs new file mode 100644 index 000000000..6bf72a1e3 --- /dev/null +++ b/rust/parse_ast/src/ast_nodes/jsx_text.rs @@ -0,0 +1,15 @@ +use swc_ecma_ast::JSXText; + +use crate::convert_ast::converter::AstConverter; +use crate::store_jsx_text; + +impl<'a> AstConverter<'a> { + pub(crate) fn store_jsx_text(&mut self, jsx_text: &JSXText) { + store_jsx_text!( + self, + span => jsx_text.span, + value => &jsx_text.value, + raw => &jsx_text.raw + ); + } +} diff --git a/rust/parse_ast/src/ast_nodes/labeled_statement.rs b/rust/parse_ast/src/ast_nodes/labeled_statement.rs index 0f2bd3cd0..f2a8dc44b 100644 --- a/rust/parse_ast/src/ast_nodes/labeled_statement.rs +++ b/rust/parse_ast/src/ast_nodes/labeled_statement.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_labeled_statement; impl<'a> AstConverter<'a> { - pub fn store_labeled_statement(&mut self, labeled_statement: &LabeledStmt) { + pub(crate) fn store_labeled_statement(&mut self, labeled_statement: &LabeledStmt) { store_labeled_statement!( self, span => &labeled_statement.span, diff --git a/rust/parse_ast/src/ast_nodes/literal_big_int.rs b/rust/parse_ast/src/ast_nodes/literal_big_int.rs index 5a98704fd..2ca27c3aa 100644 --- a/rust/parse_ast/src/ast_nodes/literal_big_int.rs +++ b/rust/parse_ast/src/ast_nodes/literal_big_int.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_literal_big_int; impl<'a> AstConverter<'a> { - pub fn store_literal_bigint(&mut self, bigint: &BigInt) { + pub(crate) fn store_literal_bigint(&mut self, bigint: &BigInt) { store_literal_big_int!( self, span => &bigint.span, diff --git a/rust/parse_ast/src/ast_nodes/literal_boolean.rs b/rust/parse_ast/src/ast_nodes/literal_boolean.rs index 9c84f9dfb..41e22f75c 100644 --- a/rust/parse_ast/src/ast_nodes/literal_boolean.rs +++ b/rust/parse_ast/src/ast_nodes/literal_boolean.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::{store_literal_boolean, store_literal_boolean_flags}; impl<'a> AstConverter<'a> { - pub fn store_literal_boolean(&mut self, literal: &Bool) { + pub(crate) fn store_literal_boolean(&mut self, literal: &Bool) { store_literal_boolean!( self, span => &literal.span, diff --git a/rust/parse_ast/src/ast_nodes/literal_null.rs b/rust/parse_ast/src/ast_nodes/literal_null.rs index 9c46f838c..541007ff3 100644 --- a/rust/parse_ast/src/ast_nodes/literal_null.rs +++ b/rust/parse_ast/src/ast_nodes/literal_null.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_literal_null; impl<'a> AstConverter<'a> { - pub fn store_literal_null(&mut self, literal: &Null) { + pub(crate) fn store_literal_null(&mut self, literal: &Null) { store_literal_null!( self, span => &literal.span diff --git a/rust/parse_ast/src/ast_nodes/literal_number.rs b/rust/parse_ast/src/ast_nodes/literal_number.rs index 64cc5fa32..6c8d9aa3d 100644 --- a/rust/parse_ast/src/ast_nodes/literal_number.rs +++ b/rust/parse_ast/src/ast_nodes/literal_number.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_literal_number; impl<'a> AstConverter<'a> { - pub fn store_literal_number(&mut self, literal: &Number) { + pub(crate) fn store_literal_number(&mut self, literal: &Number) { store_literal_number!( self, span => &literal.span, diff --git a/rust/parse_ast/src/ast_nodes/literal_reg_exp.rs b/rust/parse_ast/src/ast_nodes/literal_reg_exp.rs index 3e730e4f4..f731d3efb 100644 --- a/rust/parse_ast/src/ast_nodes/literal_reg_exp.rs +++ b/rust/parse_ast/src/ast_nodes/literal_reg_exp.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_literal_reg_exp; impl<'a> AstConverter<'a> { - pub fn store_literal_regex(&mut self, regex: &Regex) { + pub(crate) fn store_literal_regex(&mut self, regex: &Regex) { store_literal_reg_exp!( self, span => ®ex.span, diff --git a/rust/parse_ast/src/ast_nodes/literal_string.rs b/rust/parse_ast/src/ast_nodes/literal_string.rs index 0b475512e..373db0b5a 100644 --- a/rust/parse_ast/src/ast_nodes/literal_string.rs +++ b/rust/parse_ast/src/ast_nodes/literal_string.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_literal_string; impl<'a> AstConverter<'a> { - pub fn store_literal_string(&mut self, literal: &Str) { + pub(crate) fn store_literal_string(&mut self, literal: &Str) { store_literal_string!( self, span => &literal.span, diff --git a/rust/parse_ast/src/ast_nodes/member_expression.rs b/rust/parse_ast/src/ast_nodes/member_expression.rs index 8f9ed9124..6b0b23db2 100644 --- a/rust/parse_ast/src/ast_nodes/member_expression.rs +++ b/rust/parse_ast/src/ast_nodes/member_expression.rs @@ -12,7 +12,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_member_expression_flags; impl<'a> AstConverter<'a> { - pub fn store_member_expression( + pub(crate) fn store_member_expression( &mut self, span: &Span, is_optional: bool, @@ -63,7 +63,7 @@ impl<'a> AstConverter<'a> { self.add_end(end_position, span); } - pub fn convert_member_expression( + pub(crate) fn convert_member_expression( &mut self, member_expression: &MemberExpr, is_optional: bool, @@ -82,7 +82,7 @@ impl<'a> AstConverter<'a> { ); } - pub fn convert_super_property(&mut self, super_property: &SuperPropExpr) { + pub(crate) fn convert_super_property(&mut self, super_property: &SuperPropExpr) { self.store_member_expression( &super_property.span, false, @@ -98,13 +98,13 @@ impl<'a> AstConverter<'a> { } } -pub enum MemberOrSuperProp<'a> { +pub(crate) enum MemberOrSuperProp<'a> { Identifier(&'a IdentName), PrivateName(&'a PrivateName), Computed(&'a ComputedPropName), } -pub enum ExpressionOrSuper<'a> { +pub(crate) enum ExpressionOrSuper<'a> { Expression(&'a Expr), Super(&'a Super), } diff --git a/rust/parse_ast/src/ast_nodes/meta_property.rs b/rust/parse_ast/src/ast_nodes/meta_property.rs index 209886668..35d4d8260 100644 --- a/rust/parse_ast/src/ast_nodes/meta_property.rs +++ b/rust/parse_ast/src/ast_nodes/meta_property.rs @@ -7,7 +7,7 @@ use crate::convert_ast::converter::ast_constants::{ use crate::convert_ast::converter::AstConverter; impl<'a> AstConverter<'a> { - pub fn store_meta_property(&mut self, meta_property_expression: &MetaPropExpr) { + pub(crate) fn store_meta_property(&mut self, meta_property_expression: &MetaPropExpr) { let end_position = self.add_type_and_start( &TYPE_META_PROPERTY, &meta_property_expression.span, diff --git a/rust/parse_ast/src/ast_nodes/method_definition.rs b/rust/parse_ast/src/ast_nodes/method_definition.rs index e7fd91e2f..fd5b8d021 100644 --- a/rust/parse_ast/src/ast_nodes/method_definition.rs +++ b/rust/parse_ast/src/ast_nodes/method_definition.rs @@ -17,7 +17,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_method_definition_flags; impl<'a> AstConverter<'a> { - pub fn store_method_definition( + pub(crate) fn store_method_definition( &mut self, span: &Span, kind: &MethodKind, @@ -81,7 +81,7 @@ impl<'a> AstConverter<'a> { self.add_end(end_position, span); } - pub fn convert_constructor(&mut self, constructor: &Constructor) { + pub(crate) fn convert_constructor(&mut self, constructor: &Constructor) { let end_position = self.add_type_and_start( &TYPE_METHOD_DEFINITION, &constructor.span, @@ -130,7 +130,7 @@ impl<'a> AstConverter<'a> { self.add_end(end_position, &constructor.span); } - pub fn convert_method(&mut self, method: &ClassMethod) { + pub(crate) fn convert_method(&mut self, method: &ClassMethod) { self.store_method_definition( &method.span, &method.kind, @@ -141,7 +141,7 @@ impl<'a> AstConverter<'a> { ); } - pub fn convert_private_method(&mut self, private_method: &PrivateMethod) { + pub(crate) fn convert_private_method(&mut self, private_method: &PrivateMethod) { self.store_method_definition( &private_method.span, &private_method.kind, @@ -153,7 +153,7 @@ impl<'a> AstConverter<'a> { } } -pub enum PropOrPrivateName<'a> { +pub(crate) enum PropOrPrivateName<'a> { PropName(&'a PropName), PrivateName(&'a PrivateName), } diff --git a/rust/parse_ast/src/ast_nodes/mod.rs b/rust/parse_ast/src/ast_nodes/mod.rs index 2284cc3e0..ab7560659 100644 --- a/rust/parse_ast/src/ast_nodes/mod.rs +++ b/rust/parse_ast/src/ast_nodes/mod.rs @@ -1,81 +1,96 @@ -pub mod array_expression; -pub mod array_pattern; -pub mod arrow_function_expression; -pub mod assignment_expression; -pub mod assignment_pattern; -pub mod await_expression; -pub mod binary_expression; -pub mod block_statement; -pub mod break_statement; -pub mod call_expression; -pub mod catch_clause; -pub mod chain_expression; -pub mod class_body; -pub mod class_declaration; -pub mod class_expression; -pub mod conditional_expression; -pub mod continue_statement; -pub mod debugger_statement; -pub mod decorator; -pub mod directive; -pub mod do_while_statement; -pub mod empty_statement; -pub mod export_all_declaration; -pub mod export_default_declaration; -pub mod export_named_declaration; -pub mod export_specifier; -pub mod expression_statement; -pub mod for_in_statement; -pub mod for_of_statement; -pub mod for_statement; -pub mod function_declaration; -pub mod function_expression; -pub mod identifier; -pub mod if_statement; -pub mod import_attribute; -pub mod import_declaration; -pub mod import_default_specifier; -pub mod import_expression; -pub mod import_namespace_specifier; -pub mod import_specifier; -pub mod labeled_statement; -pub mod literal_big_int; -pub mod literal_boolean; -pub mod literal_null; -pub mod literal_number; -pub mod literal_reg_exp; -pub mod literal_string; -pub mod logical_expression; -pub mod member_expression; -pub mod meta_property; -pub mod method_definition; -pub mod new_expression; -pub mod object_expression; -pub mod object_pattern; -pub mod panic_error; -pub mod parse_error; -pub mod private_identifier; -pub mod program; -pub mod property; -pub mod property_definition; -pub mod rest_element; -pub mod return_statement; -pub mod sequence_expression; -pub mod shared; -pub mod spread_element; -pub mod static_block; -pub mod super_element; -pub mod switch_case; -pub mod switch_statement; -pub mod tagged_template_expression; -pub mod template_element; -pub mod template_literal; -pub mod this_expression; -pub mod throw_statement; -pub mod try_statement; -pub mod unary_expression; -pub mod update_expression; -pub mod variable_declaration; -pub mod variable_declarator; -pub mod while_statement; -pub mod yield_expression; +pub(crate) mod array_expression; +pub(crate) mod array_pattern; +pub(crate) mod arrow_function_expression; +pub(crate) mod assignment_expression; +pub(crate) mod assignment_pattern; +pub(crate) mod await_expression; +pub(crate) mod binary_expression; +pub(crate) mod block_statement; +pub(crate) mod break_statement; +pub(crate) mod call_expression; +pub(crate) mod catch_clause; +pub(crate) mod chain_expression; +pub(crate) mod class_body; +pub(crate) mod class_declaration; +pub(crate) mod class_expression; +pub(crate) mod conditional_expression; +pub(crate) mod continue_statement; +pub(crate) mod debugger_statement; +pub(crate) mod decorator; +pub(crate) mod directive; +pub(crate) mod do_while_statement; +pub(crate) mod empty_statement; +pub(crate) mod export_all_declaration; +pub(crate) mod export_default_declaration; +pub(crate) mod export_named_declaration; +pub(crate) mod export_specifier; +pub(crate) mod expression_statement; +pub(crate) mod for_in_statement; +pub(crate) mod for_of_statement; +pub(crate) mod for_statement; +pub(crate) mod function_declaration; +pub(crate) mod function_expression; +pub(crate) mod identifier; +pub(crate) mod if_statement; +pub(crate) mod import_attribute; +pub(crate) mod import_declaration; +pub(crate) mod import_default_specifier; +pub(crate) mod import_expression; +pub(crate) mod import_namespace_specifier; +pub(crate) mod import_specifier; +pub(crate) mod jsx_attribute; +pub(crate) mod jsx_closing_element; +pub(crate) mod jsx_closing_fragment; +pub(crate) mod jsx_element; +pub(crate) mod jsx_empty_expression; +pub(crate) mod jsx_expression_container; +pub(crate) mod jsx_fragment; +pub(crate) mod jsx_identifier; +pub(crate) mod jsx_member_expression; +pub(crate) mod jsx_namespaced_name; +pub(crate) mod jsx_opening_element; +pub(crate) mod jsx_opening_fragment; +pub(crate) mod jsx_spread_attribute; +pub(crate) mod jsx_spread_child; +pub(crate) mod jsx_text; +pub(crate) mod labeled_statement; +pub(crate) mod literal_big_int; +pub(crate) mod literal_boolean; +pub(crate) mod literal_null; +pub(crate) mod literal_number; +pub(crate) mod literal_reg_exp; +pub(crate) mod literal_string; +pub(crate) mod logical_expression; +pub(crate) mod member_expression; +pub(crate) mod meta_property; +pub(crate) mod method_definition; +pub(crate) mod new_expression; +pub(crate) mod object_expression; +pub(crate) mod object_pattern; +pub(crate) mod panic_error; +pub(crate) mod parse_error; +pub(crate) mod private_identifier; +pub(crate) mod program; +pub(crate) mod property; +pub(crate) mod property_definition; +pub(crate) mod rest_element; +pub(crate) mod return_statement; +pub(crate) mod sequence_expression; +pub(crate) mod shared; +pub(crate) mod spread_element; +pub(crate) mod static_block; +pub(crate) mod super_element; +pub(crate) mod switch_case; +pub(crate) mod switch_statement; +pub(crate) mod tagged_template_expression; +pub(crate) mod template_element; +pub(crate) mod template_literal; +pub(crate) mod this_expression; +pub(crate) mod throw_statement; +pub(crate) mod try_statement; +pub(crate) mod unary_expression; +pub(crate) mod update_expression; +pub(crate) mod variable_declaration; +pub(crate) mod variable_declarator; +pub(crate) mod while_statement; +pub(crate) mod yield_expression; diff --git a/rust/parse_ast/src/ast_nodes/new_expression.rs b/rust/parse_ast/src/ast_nodes/new_expression.rs index 9b16a35bf..20a01e21e 100644 --- a/rust/parse_ast/src/ast_nodes/new_expression.rs +++ b/rust/parse_ast/src/ast_nodes/new_expression.rs @@ -8,7 +8,7 @@ use crate::convert_ast::converter::ast_constants::{ use crate::convert_ast::converter::{convert_annotation, AstConverter}; impl<'a> AstConverter<'a> { - pub fn store_new_expression(&mut self, new_expression: &NewExpr) { + pub(crate) fn store_new_expression(&mut self, new_expression: &NewExpr) { let end_position = self.add_type_and_start( &TYPE_NEW_EXPRESSION, &new_expression.span, diff --git a/rust/parse_ast/src/ast_nodes/object_expression.rs b/rust/parse_ast/src/ast_nodes/object_expression.rs index 72e07f702..647ac19be 100644 --- a/rust/parse_ast/src/ast_nodes/object_expression.rs +++ b/rust/parse_ast/src/ast_nodes/object_expression.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_object_expression; impl<'a> AstConverter<'a> { - pub fn store_object_expression(&mut self, object_literal: &ObjectLit) { + pub(crate) fn store_object_expression(&mut self, object_literal: &ObjectLit) { store_object_expression!( self, span => &object_literal.span, diff --git a/rust/parse_ast/src/ast_nodes/object_pattern.rs b/rust/parse_ast/src/ast_nodes/object_pattern.rs index 22a958bd9..16b3dc1ff 100644 --- a/rust/parse_ast/src/ast_nodes/object_pattern.rs +++ b/rust/parse_ast/src/ast_nodes/object_pattern.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_object_pattern; impl<'a> AstConverter<'a> { - pub fn store_object_pattern(&mut self, object_pattern: &ObjectPat) { + pub(crate) fn store_object_pattern(&mut self, object_pattern: &ObjectPat) { store_object_pattern!( self, span => &object_pattern.span, diff --git a/rust/parse_ast/src/ast_nodes/panic_error.rs b/rust/parse_ast/src/ast_nodes/panic_error.rs index d53ae8bf5..bf290bcb4 100644 --- a/rust/parse_ast/src/ast_nodes/panic_error.rs +++ b/rust/parse_ast/src/ast_nodes/panic_error.rs @@ -3,7 +3,7 @@ use crate::convert_ast::converter::ast_constants::{ }; use crate::convert_ast::converter::{convert_string, update_reference_position}; -pub fn get_panic_error_buffer(message: &str) -> Vec { +pub(crate) fn get_panic_error_buffer(message: &str) -> Vec { // type let mut buffer = TYPE_PANIC_ERROR.to_vec(); // reserve for start and end even though they are unused diff --git a/rust/parse_ast/src/ast_nodes/parse_error.rs b/rust/parse_ast/src/ast_nodes/parse_error.rs index 440624a77..220265460 100644 --- a/rust/parse_ast/src/ast_nodes/parse_error.rs +++ b/rust/parse_ast/src/ast_nodes/parse_error.rs @@ -3,7 +3,7 @@ use crate::convert_ast::converter::ast_constants::{ }; use crate::convert_ast::converter::update_reference_position; -pub fn get_parse_error_buffer(error_buffer: &[u8], utf_16_pos: &u32) -> Vec { +pub(crate) fn get_parse_error_buffer(error_buffer: &[u8], utf_16_pos: &u32) -> Vec { // type let mut buffer = TYPE_PARSE_ERROR.to_vec(); // start diff --git a/rust/parse_ast/src/ast_nodes/private_identifier.rs b/rust/parse_ast/src/ast_nodes/private_identifier.rs index d1797c9a7..2ae38cd4d 100644 --- a/rust/parse_ast/src/ast_nodes/private_identifier.rs +++ b/rust/parse_ast/src/ast_nodes/private_identifier.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_private_identifier; impl<'a> AstConverter<'a> { - pub fn store_private_identifier(&mut self, private_name: &PrivateName) { + pub(crate) fn store_private_identifier(&mut self, private_name: &PrivateName) { store_private_identifier!( self, span => &private_name.span, diff --git a/rust/parse_ast/src/ast_nodes/program.rs b/rust/parse_ast/src/ast_nodes/program.rs index 60c34485c..f83106328 100644 --- a/rust/parse_ast/src/ast_nodes/program.rs +++ b/rust/parse_ast/src/ast_nodes/program.rs @@ -6,7 +6,7 @@ use crate::convert_ast::converter::ast_constants::{ use crate::convert_ast::converter::{convert_annotation, AstConverter}; impl<'a> AstConverter<'a> { - pub fn store_program(&mut self, body: ModuleItemsOrStatements) { + pub(crate) fn store_program(&mut self, body: ModuleItemsOrStatements) { let end_position = self.add_type_and_explicit_start(&TYPE_PROGRAM, 0u32, PROGRAM_RESERVED_BYTES); // body @@ -71,7 +71,7 @@ impl<'a> AstConverter<'a> { } } - pub fn convert_program(&mut self, node: &Program) { + pub(crate) fn convert_program(&mut self, node: &Program) { match node { Program::Module(module) => { self.store_program(ModuleItemsOrStatements::ModuleItems(&module.body)); @@ -83,7 +83,7 @@ impl<'a> AstConverter<'a> { } } -pub enum ModuleItemsOrStatements<'a> { +pub(crate) enum ModuleItemsOrStatements<'a> { ModuleItems(&'a Vec), Statements(&'a Vec), } diff --git a/rust/parse_ast/src/ast_nodes/property.rs b/rust/parse_ast/src/ast_nodes/property.rs index f2c9b866d..fda028829 100644 --- a/rust/parse_ast/src/ast_nodes/property.rs +++ b/rust/parse_ast/src/ast_nodes/property.rs @@ -15,7 +15,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_property_flags; impl<'a> AstConverter<'a> { - pub fn convert_property(&mut self, property: &Prop) { + pub(crate) fn convert_property(&mut self, property: &Prop) { match property { Prop::Getter(getter_property) => self.convert_getter_property(getter_property), Prop::KeyValue(key_value_property) => self.convert_key_value_property(key_value_property), @@ -26,7 +26,7 @@ impl<'a> AstConverter<'a> { } } - pub fn convert_assignment_pattern_property( + pub(crate) fn convert_assignment_pattern_property( &mut self, assignment_pattern_property: &AssignPatProp, ) { @@ -37,7 +37,7 @@ impl<'a> AstConverter<'a> { ); } - pub fn convert_key_value_pattern_property( + pub(crate) fn convert_key_value_pattern_property( &mut self, key_value_pattern_property: &KeyValuePatProp, ) { @@ -242,7 +242,7 @@ impl<'a> AstConverter<'a> { } #[derive(Spanned)] -pub enum PatternOrExpression<'a> { +pub(crate) enum PatternOrExpression<'a> { Pattern(&'a Pat), Expression(&'a Expr), } diff --git a/rust/parse_ast/src/ast_nodes/property_definition.rs b/rust/parse_ast/src/ast_nodes/property_definition.rs index 24d8c89d3..4ef508d72 100644 --- a/rust/parse_ast/src/ast_nodes/property_definition.rs +++ b/rust/parse_ast/src/ast_nodes/property_definition.rs @@ -10,7 +10,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_property_definition_flags; impl<'a> AstConverter<'a> { - pub fn store_property_definition( + pub(crate) fn store_property_definition( &mut self, span: &Span, is_computed: bool, @@ -53,7 +53,7 @@ impl<'a> AstConverter<'a> { self.add_end(end_position, span); } - pub fn convert_class_property(&mut self, class_property: &ClassProp) { + pub(crate) fn convert_class_property(&mut self, class_property: &ClassProp) { self.store_property_definition( &class_property.span, matches!(&class_property.key, PropName::Computed(_)), @@ -64,7 +64,7 @@ impl<'a> AstConverter<'a> { ); } - pub fn convert_private_property(&mut self, private_property: &PrivateProp) { + pub(crate) fn convert_private_property(&mut self, private_property: &PrivateProp) { self.store_property_definition( &private_property.span, false, diff --git a/rust/parse_ast/src/ast_nodes/rest_element.rs b/rust/parse_ast/src/ast_nodes/rest_element.rs index 2bf6d1fe6..9176410c2 100644 --- a/rust/parse_ast/src/ast_nodes/rest_element.rs +++ b/rust/parse_ast/src/ast_nodes/rest_element.rs @@ -6,7 +6,7 @@ use crate::convert_ast::converter::ast_constants::{ use crate::convert_ast::converter::AstConverter; impl<'a> AstConverter<'a> { - pub fn store_rest_element(&mut self, rest_pattern: &RestPat) { + pub(crate) fn store_rest_element(&mut self, rest_pattern: &RestPat) { let end_position = self.add_type_and_start( &TYPE_REST_ELEMENT, &rest_pattern.dot3_token, diff --git a/rust/parse_ast/src/ast_nodes/return_statement.rs b/rust/parse_ast/src/ast_nodes/return_statement.rs index 5a0870bd5..0e41a910b 100644 --- a/rust/parse_ast/src/ast_nodes/return_statement.rs +++ b/rust/parse_ast/src/ast_nodes/return_statement.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_return_statement; impl<'a> AstConverter<'a> { - pub fn store_return_statement(&mut self, return_statement: &ReturnStmt) { + pub(crate) fn store_return_statement(&mut self, return_statement: &ReturnStmt) { store_return_statement!( self, span => return_statement.span, diff --git a/rust/parse_ast/src/ast_nodes/sequence_expression.rs b/rust/parse_ast/src/ast_nodes/sequence_expression.rs index fa69c151e..f179cdbf3 100644 --- a/rust/parse_ast/src/ast_nodes/sequence_expression.rs +++ b/rust/parse_ast/src/ast_nodes/sequence_expression.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_sequence_expression; impl<'a> AstConverter<'a> { - pub fn store_sequence_expression(&mut self, sequence_expression: &SeqExpr) { + pub(crate) fn store_sequence_expression(&mut self, sequence_expression: &SeqExpr) { store_sequence_expression!( self, span => &sequence_expression.span, diff --git a/rust/parse_ast/src/ast_nodes/shared/class_node.rs b/rust/parse_ast/src/ast_nodes/shared/class_node.rs index 67d6fa32b..068b7aaba 100644 --- a/rust/parse_ast/src/ast_nodes/shared/class_node.rs +++ b/rust/parse_ast/src/ast_nodes/shared/class_node.rs @@ -9,7 +9,7 @@ use crate::convert_ast::converter::ast_constants::{ use crate::convert_ast::converter::AstConverter; impl<'a> AstConverter<'a> { - pub fn store_class_node( + pub(crate) fn store_class_node( &mut self, node_type: &[u8; 4], identifier: Option<&Ident>, diff --git a/rust/parse_ast/src/ast_nodes/shared/function_node.rs b/rust/parse_ast/src/ast_nodes/shared/function_node.rs index 34d868e5f..665411e72 100644 --- a/rust/parse_ast/src/ast_nodes/shared/function_node.rs +++ b/rust/parse_ast/src/ast_nodes/shared/function_node.rs @@ -31,7 +31,7 @@ impl<'a> AstConverter<'a> { } #[allow(clippy::too_many_arguments)] - pub fn store_function_node( + pub(crate) fn store_function_node( &mut self, node_type: &[u8; 4], start: u32, diff --git a/rust/parse_ast/src/ast_nodes/spread_element.rs b/rust/parse_ast/src/ast_nodes/spread_element.rs index 8bd63a7bb..0a6b9dfbd 100644 --- a/rust/parse_ast/src/ast_nodes/spread_element.rs +++ b/rust/parse_ast/src/ast_nodes/spread_element.rs @@ -7,7 +7,7 @@ use crate::convert_ast::converter::ast_constants::{ use crate::convert_ast::converter::AstConverter; impl<'a> AstConverter<'a> { - pub fn store_spread_element(&mut self, dot_span: &Span, argument: &Expr) { + pub(crate) fn store_spread_element(&mut self, dot_span: &Span, argument: &Expr) { let end_position = self.add_type_and_start( &TYPE_SPREAD_ELEMENT, dot_span, @@ -21,7 +21,7 @@ impl<'a> AstConverter<'a> { self.add_end(end_position, &argument.span()); } - pub fn convert_spread_element(&mut self, spread_element: &SpreadElement) { + pub(crate) fn convert_spread_element(&mut self, spread_element: &SpreadElement) { self.store_spread_element(&spread_element.dot3_token, &spread_element.expr); } } diff --git a/rust/parse_ast/src/ast_nodes/static_block.rs b/rust/parse_ast/src/ast_nodes/static_block.rs index 43d858cc3..4b0e7d461 100644 --- a/rust/parse_ast/src/ast_nodes/static_block.rs +++ b/rust/parse_ast/src/ast_nodes/static_block.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_static_block; impl<'a> AstConverter<'a> { - pub fn store_static_block(&mut self, static_block: &StaticBlock) { + pub(crate) fn store_static_block(&mut self, static_block: &StaticBlock) { store_static_block!( self, span => &static_block.span, diff --git a/rust/parse_ast/src/ast_nodes/super_element.rs b/rust/parse_ast/src/ast_nodes/super_element.rs index cb5df0820..1ca9c6676 100644 --- a/rust/parse_ast/src/ast_nodes/super_element.rs +++ b/rust/parse_ast/src/ast_nodes/super_element.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_super_element; impl<'a> AstConverter<'a> { - pub fn store_super_element(&mut self, super_token: &Super) { + pub(crate) fn store_super_element(&mut self, super_token: &Super) { store_super_element!( self, span => &super_token.span diff --git a/rust/parse_ast/src/ast_nodes/switch_case.rs b/rust/parse_ast/src/ast_nodes/switch_case.rs index e1a278674..3cd92797c 100644 --- a/rust/parse_ast/src/ast_nodes/switch_case.rs +++ b/rust/parse_ast/src/ast_nodes/switch_case.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_switch_case; impl<'a> AstConverter<'a> { - pub fn store_switch_case(&mut self, switch_case: &SwitchCase) { + pub(crate) fn store_switch_case(&mut self, switch_case: &SwitchCase) { store_switch_case!( self, span => &switch_case.span, diff --git a/rust/parse_ast/src/ast_nodes/switch_statement.rs b/rust/parse_ast/src/ast_nodes/switch_statement.rs index 2c6ba5684..3dd18303d 100644 --- a/rust/parse_ast/src/ast_nodes/switch_statement.rs +++ b/rust/parse_ast/src/ast_nodes/switch_statement.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_switch_statement; impl<'a> AstConverter<'a> { - pub fn store_switch_statement(&mut self, switch_statement: &SwitchStmt) { + pub(crate) fn store_switch_statement(&mut self, switch_statement: &SwitchStmt) { store_switch_statement!( self, span => &switch_statement.span, diff --git a/rust/parse_ast/src/ast_nodes/tagged_template_expression.rs b/rust/parse_ast/src/ast_nodes/tagged_template_expression.rs index c7cdcacfa..ac7fdbc01 100644 --- a/rust/parse_ast/src/ast_nodes/tagged_template_expression.rs +++ b/rust/parse_ast/src/ast_nodes/tagged_template_expression.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_tagged_template_expression; impl<'a> AstConverter<'a> { - pub fn store_tagged_template_expression(&mut self, tagged_template: &TaggedTpl) { + pub(crate) fn store_tagged_template_expression(&mut self, tagged_template: &TaggedTpl) { store_tagged_template_expression!( self, span => &tagged_template.span, diff --git a/rust/parse_ast/src/ast_nodes/template_element.rs b/rust/parse_ast/src/ast_nodes/template_element.rs index 3b9d385fb..ee9339475 100644 --- a/rust/parse_ast/src/ast_nodes/template_element.rs +++ b/rust/parse_ast/src/ast_nodes/template_element.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::{store_template_element, store_template_element_flags}; impl<'a> AstConverter<'a> { - pub fn store_template_element(&mut self, template_element: &TplElement) { + pub(crate) fn store_template_element(&mut self, template_element: &TplElement) { store_template_element!( self, span => &template_element.span, diff --git a/rust/parse_ast/src/ast_nodes/template_literal.rs b/rust/parse_ast/src/ast_nodes/template_literal.rs index 6548615a8..a584df678 100644 --- a/rust/parse_ast/src/ast_nodes/template_literal.rs +++ b/rust/parse_ast/src/ast_nodes/template_literal.rs @@ -7,7 +7,7 @@ use crate::convert_ast::converter::ast_constants::{ use crate::convert_ast::converter::AstConverter; impl<'a> AstConverter<'a> { - pub fn store_template_literal(&mut self, template_literal: &Tpl) { + pub(crate) fn store_template_literal(&mut self, template_literal: &Tpl) { let end_position = self.add_type_and_start( &TYPE_TEMPLATE_LITERAL, &template_literal.span, diff --git a/rust/parse_ast/src/ast_nodes/this_expression.rs b/rust/parse_ast/src/ast_nodes/this_expression.rs index 37c0a8b86..0e65f17bc 100644 --- a/rust/parse_ast/src/ast_nodes/this_expression.rs +++ b/rust/parse_ast/src/ast_nodes/this_expression.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_this_expression; impl<'a> AstConverter<'a> { - pub fn store_this_expression(&mut self, this_expression: &ThisExpr) { + pub(crate) fn store_this_expression(&mut self, this_expression: &ThisExpr) { store_this_expression!(self, span => this_expression.span); } } diff --git a/rust/parse_ast/src/ast_nodes/throw_statement.rs b/rust/parse_ast/src/ast_nodes/throw_statement.rs index 32fe92397..0d154da68 100644 --- a/rust/parse_ast/src/ast_nodes/throw_statement.rs +++ b/rust/parse_ast/src/ast_nodes/throw_statement.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_throw_statement; impl<'a> AstConverter<'a> { - pub fn store_throw_statement(&mut self, throw_statement: &ThrowStmt) { + pub(crate) fn store_throw_statement(&mut self, throw_statement: &ThrowStmt) { store_throw_statement!( self, span => &throw_statement.span, diff --git a/rust/parse_ast/src/ast_nodes/try_statement.rs b/rust/parse_ast/src/ast_nodes/try_statement.rs index a5985f285..537433327 100644 --- a/rust/parse_ast/src/ast_nodes/try_statement.rs +++ b/rust/parse_ast/src/ast_nodes/try_statement.rs @@ -7,7 +7,7 @@ use crate::convert_ast::converter::ast_constants::{ use crate::convert_ast::converter::AstConverter; impl<'a> AstConverter<'a> { - pub fn store_try_statement(&mut self, try_statement: &TryStmt) { + pub(crate) fn store_try_statement(&mut self, try_statement: &TryStmt) { let end_position = self.add_type_and_start( &TYPE_TRY_STATEMENT, &try_statement.span, diff --git a/rust/parse_ast/src/ast_nodes/unary_expression.rs b/rust/parse_ast/src/ast_nodes/unary_expression.rs index 291410285..34f5c9a81 100644 --- a/rust/parse_ast/src/ast_nodes/unary_expression.rs +++ b/rust/parse_ast/src/ast_nodes/unary_expression.rs @@ -7,7 +7,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_unary_expression; impl<'a> AstConverter<'a> { - pub fn store_unary_expression(&mut self, unary_expression: &UnaryExpr) { + pub(crate) fn store_unary_expression(&mut self, unary_expression: &UnaryExpr) { store_unary_expression!( self, span => &unary_expression.span, diff --git a/rust/parse_ast/src/ast_nodes/update_expression.rs b/rust/parse_ast/src/ast_nodes/update_expression.rs index cbf59a3f5..5886609c8 100644 --- a/rust/parse_ast/src/ast_nodes/update_expression.rs +++ b/rust/parse_ast/src/ast_nodes/update_expression.rs @@ -5,7 +5,7 @@ use crate::convert_ast::converter::AstConverter; use crate::{store_update_expression, store_update_expression_flags}; impl<'a> AstConverter<'a> { - pub fn store_update_expression(&mut self, update_expression: &UpdateExpr) { + pub(crate) fn store_update_expression(&mut self, update_expression: &UpdateExpr) { store_update_expression!( self, span => &update_expression.span, diff --git a/rust/parse_ast/src/ast_nodes/variable_declaration.rs b/rust/parse_ast/src/ast_nodes/variable_declaration.rs index 65108c331..9dc4760d8 100644 --- a/rust/parse_ast/src/ast_nodes/variable_declaration.rs +++ b/rust/parse_ast/src/ast_nodes/variable_declaration.rs @@ -11,7 +11,7 @@ use crate::convert_ast::converter::string_constants::{ use crate::convert_ast::converter::AstConverter; impl<'a> AstConverter<'a> { - pub fn store_variable_declaration(&mut self, variable_declaration: &VariableDeclaration) { + pub(crate) fn store_variable_declaration(&mut self, variable_declaration: &VariableDeclaration) { let (kind, span, decls): (&[u8; 4], Span, &Vec) = match variable_declaration { VariableDeclaration::Var(value) => ( match value.kind { @@ -55,7 +55,7 @@ impl<'a> AstConverter<'a> { } } -pub enum VariableDeclaration<'a> { +pub(crate) enum VariableDeclaration<'a> { Var(&'a VarDecl), Using(&'a UsingDecl), } diff --git a/rust/parse_ast/src/ast_nodes/variable_declarator.rs b/rust/parse_ast/src/ast_nodes/variable_declarator.rs index d7d421197..317b1b29e 100644 --- a/rust/parse_ast/src/ast_nodes/variable_declarator.rs +++ b/rust/parse_ast/src/ast_nodes/variable_declarator.rs @@ -8,7 +8,7 @@ use crate::convert_ast::converter::ast_constants::{ use crate::convert_ast::converter::AstConverter; impl<'a> AstConverter<'a> { - pub fn store_variable_declarator(&mut self, variable_declarator: &VarDeclarator) { + pub(crate) fn store_variable_declarator(&mut self, variable_declarator: &VarDeclarator) { let end_position = self.add_type_and_start( &TYPE_VARIABLE_DECLARATOR, &variable_declarator.span, diff --git a/rust/parse_ast/src/ast_nodes/while_statement.rs b/rust/parse_ast/src/ast_nodes/while_statement.rs index d13525355..42e00184b 100644 --- a/rust/parse_ast/src/ast_nodes/while_statement.rs +++ b/rust/parse_ast/src/ast_nodes/while_statement.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::store_while_statement; impl<'a> AstConverter<'a> { - pub fn store_while_statement(&mut self, while_statement: &WhileStmt) { + pub(crate) fn store_while_statement(&mut self, while_statement: &WhileStmt) { store_while_statement!( self, span => &while_statement.span, diff --git a/rust/parse_ast/src/ast_nodes/yield_expression.rs b/rust/parse_ast/src/ast_nodes/yield_expression.rs index dbd4d3f9a..960653113 100644 --- a/rust/parse_ast/src/ast_nodes/yield_expression.rs +++ b/rust/parse_ast/src/ast_nodes/yield_expression.rs @@ -4,7 +4,7 @@ use crate::convert_ast::converter::AstConverter; use crate::{store_yield_expression, store_yield_expression_flags}; impl<'a> AstConverter<'a> { - pub fn store_yield_expression(&mut self, yield_expression: &YieldExpr) { + pub(crate) fn store_yield_expression(&mut self, yield_expression: &YieldExpr) { store_yield_expression!( self, span => yield_expression.span, diff --git a/rust/parse_ast/src/convert_ast.rs b/rust/parse_ast/src/convert_ast.rs index e7d6154cd..9b9b10860 100644 --- a/rust/parse_ast/src/convert_ast.rs +++ b/rust/parse_ast/src/convert_ast.rs @@ -1,2 +1,2 @@ -pub mod annotations; -pub mod converter; +pub(crate) mod annotations; +pub(crate) mod converter; diff --git a/rust/parse_ast/src/convert_ast/annotations.rs b/rust/parse_ast/src/convert_ast/annotations.rs index a5c61b835..0ac6f3116 100644 --- a/rust/parse_ast/src/convert_ast/annotations.rs +++ b/rust/parse_ast/src/convert_ast/annotations.rs @@ -4,12 +4,12 @@ use swc_common::comments::{Comment, Comments}; use swc_common::BytePos; #[derive(Default)] -pub struct SequentialComments { +pub(crate) struct SequentialComments { annotations: RefCell>, } impl SequentialComments { - pub fn add_comment(&self, comment: Comment) { + pub(crate) fn add_comment(&self, comment: Comment) { if comment.text.starts_with('#') && comment.text.contains("sourceMappingURL=") { self.annotations.borrow_mut().push(AnnotationWithType { comment, @@ -55,7 +55,7 @@ impl SequentialComments { }); } - pub fn take_annotations(self) -> Vec { + pub(crate) fn take_annotations(self) -> Vec { self.annotations.take() } } @@ -127,19 +127,19 @@ impl Comments for SequentialComments { } #[derive(Debug)] -pub struct AnnotationWithType { - pub comment: Comment, - pub kind: CommentKind, +pub(crate) struct AnnotationWithType { + pub(crate) comment: Comment, + pub(crate) kind: CommentKind, } #[derive(Clone, Debug)] -pub enum CommentKind { +pub(crate) enum CommentKind { Annotation(AnnotationKind), Comment, } #[derive(Clone, PartialEq, Debug)] -pub enum AnnotationKind { +pub(crate) enum AnnotationKind { Pure, NoSideEffects, SourceMappingUrl, diff --git a/rust/parse_ast/src/convert_ast/converter.rs b/rust/parse_ast/src/convert_ast/converter.rs index b5d55d155..c736feb13 100644 --- a/rust/parse_ast/src/convert_ast/converter.rs +++ b/rust/parse_ast/src/convert_ast/converter.rs @@ -1,7 +1,8 @@ use swc_common::Span; use swc_ecma_ast::{ AssignTarget, AssignTargetPat, CallExpr, Callee, ClassMember, Decl, ExportSpecifier, Expr, - ExprOrSpread, ForHead, ImportSpecifier, Lit, ModuleDecl, ModuleExportName, ModuleItem, + ExprOrSpread, ForHead, ImportSpecifier, JSXAttrName, JSXAttrOrSpread, JSXAttrValue, + JSXElementChild, JSXElementName, JSXObject, Lit, ModuleDecl, ModuleExportName, ModuleItem, NamedExport, ObjectPatProp, OptChainBase, ParenExpr, Pat, Program, PropName, PropOrSpread, SimpleAssignTarget, Stmt, VarDeclOrExpr, }; @@ -20,20 +21,20 @@ use crate::convert_ast::converter::utf16_positions::{ }; pub(crate) mod analyze_code; -pub mod string_constants; +pub(crate) mod string_constants; mod utf16_positions; -pub mod ast_constants; +pub(crate) mod ast_constants; mod ast_macros; -pub struct AstConverter<'a> { - pub buffer: Vec, - pub code: &'a [u8], - pub index_converter: Utf8ToUtf16ByteIndexConverterAndAnnotationHandler<'a>, +pub(crate) struct AstConverter<'a> { + pub(crate) buffer: Vec, + pub(crate) code: &'a [u8], + pub(crate) index_converter: Utf8ToUtf16ByteIndexConverterAndAnnotationHandler<'a>, } impl<'a> AstConverter<'a> { - pub fn new(code: &'a str, annotations: &'a [AnnotationWithType]) -> Self { + pub(crate) fn new(code: &'a str, annotations: &'a [AnnotationWithType]) -> Self { Self { // This is just a wild guess and should be revisited from time to time buffer: Vec::with_capacity(20 * code.len()), @@ -42,14 +43,14 @@ impl<'a> AstConverter<'a> { } } - pub fn convert_ast_to_buffer(mut self, node: &Program) -> Vec { + pub(crate) fn convert_ast_to_buffer(mut self, node: &Program) -> Vec { self.convert_program(node); self.buffer.shrink_to_fit(); self.buffer } // === helpers - pub fn add_type_and_start( + pub(crate) fn add_type_and_start( &mut self, node_type: &[u8; 4], span: &Span, @@ -89,7 +90,7 @@ impl<'a> AstConverter<'a> { end_position } - pub fn add_end(&mut self, end_position: usize, span: &Span) { + pub(crate) fn add_end(&mut self, end_position: usize, span: &Span) { self.buffer[end_position..end_position + 4].copy_from_slice( &self .index_converter @@ -103,7 +104,7 @@ impl<'a> AstConverter<'a> { .copy_from_slice(&self.index_converter.convert(end, false).to_ne_bytes()); } - pub fn convert_item_list( + pub(crate) fn convert_item_list( &mut self, item_list: &[T], reference_position: usize, @@ -135,7 +136,7 @@ impl<'a> AstConverter<'a> { } } - pub fn convert_item_list_with_state( + pub(crate) fn convert_item_list_with_state( &mut self, item_list: &[T], state: &mut S, @@ -174,14 +175,14 @@ impl<'a> AstConverter<'a> { convert_string(&mut self.buffer, string); } - pub fn update_reference_position(&mut self, reference_position: usize) { + pub(crate) fn update_reference_position(&mut self, reference_position: usize) { let insert_position = (self.buffer.len() as u32) >> 2; self.buffer[reference_position..reference_position + 4] .copy_from_slice(&insert_position.to_ne_bytes()); } // === shared enums - pub fn convert_call_expression( + pub(crate) fn convert_call_expression( &mut self, call_expression: &CallExpr, is_optional: bool, @@ -275,7 +276,7 @@ impl<'a> AstConverter<'a> { } } - pub fn convert_expression(&mut self, expression: &Expr) { + pub(crate) fn convert_expression(&mut self, expression: &Expr) { match expression { Expr::Array(array_literal) => { self.store_array_expression(array_literal); @@ -362,8 +363,12 @@ impl<'a> AstConverter<'a> { Expr::JSXMember(_) => unimplemented!("Cannot convert Expr::JSXMember"), Expr::JSXNamespacedName(_) => unimplemented!("Cannot convert Expr::JSXNamespacedName"), Expr::JSXEmpty(_) => unimplemented!("Cannot convert Expr::JSXEmpty"), - Expr::JSXElement(_) => unimplemented!("Cannot convert Expr::JSXElement"), - Expr::JSXFragment(_) => unimplemented!("Cannot convert Expr::JSXFragment"), + Expr::JSXElement(jsx_element) => { + self.store_jsx_element(jsx_element); + } + Expr::JSXFragment(jsx_fragment) => { + self.store_jsx_fragment(jsx_fragment); + } Expr::TsTypeAssertion(_) => unimplemented!("Cannot convert Expr::TsTypeAssertion"), Expr::TsConstAssertion(_) => unimplemented!("Cannot convert Expr::TsConstAssertion"), Expr::TsNonNull(_) => unimplemented!("Cannot convert Expr::TsNonNull"), @@ -374,7 +379,7 @@ impl<'a> AstConverter<'a> { } } - pub fn convert_expression_or_spread(&mut self, expression_or_spread: &ExprOrSpread) { + pub(crate) fn convert_expression_or_spread(&mut self, expression_or_spread: &ExprOrSpread) { match expression_or_spread.spread { Some(spread_span) => self.store_spread_element(&spread_span, &expression_or_spread.expr), None => { @@ -411,6 +416,88 @@ impl<'a> AstConverter<'a> { } } + pub(crate) fn convert_jsx_attribute_name(&mut self, jsx_attribute_name: &JSXAttrName) { + match jsx_attribute_name { + JSXAttrName::Ident(identifier) => { + self.store_jsx_identifier(&identifier.span, &identifier.sym); + } + JSXAttrName::JSXNamespacedName(jsx_namespaced_name) => { + self.store_jsx_namespaced_name(jsx_namespaced_name); + } + } + } + + pub(crate) fn convert_jsx_attribute_or_spread( + &mut self, + jsx_attribute_or_spread: &JSXAttrOrSpread, + previous_element_end: u32, + ) { + match jsx_attribute_or_spread { + JSXAttrOrSpread::JSXAttr(jsx_attribute) => { + self.store_jsx_attribute(jsx_attribute); + } + JSXAttrOrSpread::SpreadElement(spread_element) => { + self.store_jsx_spread_attribute(spread_element, previous_element_end); + } + } + } + + pub(crate) fn convert_jsx_attribute_value(&mut self, jsx_attribute_value: &JSXAttrValue) { + match jsx_attribute_value { + JSXAttrValue::Lit(literal) => self.convert_literal(literal), + JSXAttrValue::JSXExprContainer(expression_container) => { + self.store_jsx_expression_container(expression_container) + } + JSXAttrValue::JSXElement(jsx_element) => self.store_jsx_element(jsx_element), + JSXAttrValue::JSXFragment(jsx_fragment) => self.store_jsx_fragment(jsx_fragment), + } + } + + pub(crate) fn convert_jsx_element_child(&mut self, jsx_element_child: &JSXElementChild) { + match jsx_element_child { + JSXElementChild::JSXText(jsx_text) => { + self.store_jsx_text(jsx_text); + } + JSXElementChild::JSXExprContainer(jsx_expr_container) => { + self.store_jsx_expression_container(jsx_expr_container); + } + JSXElementChild::JSXSpreadChild(jsx_spread_child) => { + self.store_jsx_spread_child(jsx_spread_child); + } + JSXElementChild::JSXFragment(jsx_fragment) => { + self.store_jsx_fragment(jsx_fragment); + } + JSXElementChild::JSXElement(jsx_element) => { + self.store_jsx_element(jsx_element); + } + } + } + + pub(crate) fn convert_jsx_element_name(&mut self, jsx_element_name: &JSXElementName) { + match jsx_element_name { + JSXElementName::Ident(identifier) => { + self.store_jsx_identifier(&identifier.span, &identifier.sym) + } + JSXElementName::JSXMemberExpr(jsx_member_expression) => { + self.store_jsx_member_expression(jsx_member_expression); + } + JSXElementName::JSXNamespacedName(_jsx_namespaced_name) => { + unimplemented!("JSXElementName::JSXNamespacedName") + } + } + } + + pub(crate) fn convert_jsx_object(&mut self, jsx_object: &JSXObject) { + match jsx_object { + JSXObject::JSXMemberExpr(jsx_member_expression) => { + self.store_jsx_member_expression(jsx_member_expression); + } + JSXObject::Ident(identifier) => { + self.store_jsx_identifier(&identifier.span, &identifier.sym); + } + } + } + fn convert_literal(&mut self, literal: &Lit) { match literal { Lit::BigInt(bigint_literal) => self.store_literal_bigint(bigint_literal), @@ -429,7 +516,7 @@ impl<'a> AstConverter<'a> { Lit::Str(string_literal) => { self.store_literal_string(string_literal); } - Lit::JSXText(_) => unimplemented!("Lit::JSXText"), + Lit::JSXText(_) => unimplemented!("Lit::JsxText"), } } @@ -515,7 +602,7 @@ impl<'a> AstConverter<'a> { self.convert_expression(&parenthesized_expression.expr); } - pub fn convert_pattern(&mut self, pattern: &Pat) { + pub(crate) fn convert_pattern(&mut self, pattern: &Pat) { match pattern { Pat::Array(array_pattern) => { self.store_array_pattern(array_pattern); @@ -537,7 +624,7 @@ impl<'a> AstConverter<'a> { } } - pub fn convert_pattern_or_expression(&mut self, pattern_or_expression: &AssignTarget) { + pub(crate) fn convert_pattern_or_expression(&mut self, pattern_or_expression: &AssignTarget) { match pattern_or_expression { AssignTarget::Pat(assignment_target_pattern) => { self.convert_assignment_target_pattern(assignment_target_pattern); @@ -617,7 +704,7 @@ impl<'a> AstConverter<'a> { } } - pub fn convert_statement(&mut self, statement: &Stmt) { + pub(crate) fn convert_statement(&mut self, statement: &Stmt) { match statement { Stmt::Break(break_statement) => self.store_break_statement(break_statement), Stmt::Block(block_statement) => self.store_block_statement(block_statement, false), @@ -656,7 +743,7 @@ impl<'a> AstConverter<'a> { } } -pub fn convert_annotation(buffer: &mut Vec, annotation: &ConvertedAnnotation) { +pub(crate) fn convert_annotation(buffer: &mut Vec, annotation: &ConvertedAnnotation) { // start buffer.extend_from_slice(&annotation.start.to_ne_bytes()); // end @@ -669,7 +756,7 @@ pub fn convert_annotation(buffer: &mut Vec, annotation: &ConvertedAnnotation }); } -pub fn convert_string(buffer: &mut Vec, string: &str) { +pub(crate) fn convert_string(buffer: &mut Vec, string: &str) { let length = string.len(); let additional_length = ((length + 3) & !3) - length; buffer.extend_from_slice(&(length as u32).to_ne_bytes()); @@ -677,7 +764,7 @@ pub fn convert_string(buffer: &mut Vec, string: &str) { buffer.resize(buffer.len() + additional_length, 0); } -pub fn update_reference_position(buffer: &mut [u8], reference_position: usize) { +pub(crate) fn update_reference_position(buffer: &mut [u8], reference_position: usize) { let insert_position = (buffer.len() as u32) >> 2; buffer[reference_position..reference_position + 4] .copy_from_slice(&insert_position.to_ne_bytes()); diff --git a/rust/parse_ast/src/convert_ast/converter/analyze_code.rs b/rust/parse_ast/src/convert_ast/converter/analyze_code.rs index d2fb985df..2aa770a98 100644 --- a/rust/parse_ast/src/convert_ast/converter/analyze_code.rs +++ b/rust/parse_ast/src/convert_ast/converter/analyze_code.rs @@ -1,4 +1,8 @@ -pub fn find_first_occurrence_outside_comment(code: &[u8], search_byte: u8, start: u32) -> u32 { +pub(crate) fn find_first_occurrence_outside_comment( + code: &[u8], + search_byte: u8, + start: u32, +) -> u32 { let mut search_pos = start as usize; let mut comment_type = CommentType::None; loop { diff --git a/rust/parse_ast/src/convert_ast/converter/ast_constants.rs b/rust/parse_ast/src/convert_ast/converter/ast_constants.rs index 72f6335f8..add6ddf81 100644 --- a/rust/parse_ast/src/convert_ast/converter/ast_constants.rs +++ b/rust/parse_ast/src/convert_ast/converter/ast_constants.rs @@ -24,20 +24,26 @@ pub const TYPE_IDENTIFIER: [u8; 4] = 34u32.to_ne_bytes(); pub const TYPE_IMPORT_ATTRIBUTE: [u8; 4] = 36u32.to_ne_bytes(); pub const TYPE_IMPORT_DECLARATION: [u8; 4] = 37u32.to_ne_bytes(); pub const TYPE_IMPORT_EXPRESSION: [u8; 4] = 39u32.to_ne_bytes(); -pub const TYPE_LOGICAL_EXPRESSION: [u8; 4] = 49u32.to_ne_bytes(); -pub const TYPE_MEMBER_EXPRESSION: [u8; 4] = 50u32.to_ne_bytes(); -pub const TYPE_META_PROPERTY: [u8; 4] = 51u32.to_ne_bytes(); -pub const TYPE_METHOD_DEFINITION: [u8; 4] = 52u32.to_ne_bytes(); -pub const TYPE_NEW_EXPRESSION: [u8; 4] = 53u32.to_ne_bytes(); -pub const TYPE_PROGRAM: [u8; 4] = 57u32.to_ne_bytes(); -pub const TYPE_PROPERTY: [u8; 4] = 58u32.to_ne_bytes(); -pub const TYPE_PROPERTY_DEFINITION: [u8; 4] = 59u32.to_ne_bytes(); -pub const TYPE_REST_ELEMENT: [u8; 4] = 60u32.to_ne_bytes(); -pub const TYPE_SPREAD_ELEMENT: [u8; 4] = 63u32.to_ne_bytes(); -pub const TYPE_TEMPLATE_LITERAL: [u8; 4] = 70u32.to_ne_bytes(); -pub const TYPE_TRY_STATEMENT: [u8; 4] = 73u32.to_ne_bytes(); -pub const TYPE_VARIABLE_DECLARATION: [u8; 4] = 76u32.to_ne_bytes(); -pub const TYPE_VARIABLE_DECLARATOR: [u8; 4] = 77u32.to_ne_bytes(); +pub const TYPE_JSX_EMPTY_EXPRESSION: [u8; 4] = 46u32.to_ne_bytes(); +pub const TYPE_JSX_EXPRESSION_CONTAINER: [u8; 4] = 47u32.to_ne_bytes(); +pub const TYPE_JSX_MEMBER_EXPRESSION: [u8; 4] = 50u32.to_ne_bytes(); +pub const TYPE_JSX_NAMESPACED_NAME: [u8; 4] = 51u32.to_ne_bytes(); +pub const TYPE_JSX_OPENING_ELEMENT: [u8; 4] = 52u32.to_ne_bytes(); +pub const TYPE_JSX_SPREAD_ATTRIBUTE: [u8; 4] = 54u32.to_ne_bytes(); +pub const TYPE_LOGICAL_EXPRESSION: [u8; 4] = 64u32.to_ne_bytes(); +pub const TYPE_MEMBER_EXPRESSION: [u8; 4] = 65u32.to_ne_bytes(); +pub const TYPE_META_PROPERTY: [u8; 4] = 66u32.to_ne_bytes(); +pub const TYPE_METHOD_DEFINITION: [u8; 4] = 67u32.to_ne_bytes(); +pub const TYPE_NEW_EXPRESSION: [u8; 4] = 68u32.to_ne_bytes(); +pub const TYPE_PROGRAM: [u8; 4] = 72u32.to_ne_bytes(); +pub const TYPE_PROPERTY: [u8; 4] = 73u32.to_ne_bytes(); +pub const TYPE_PROPERTY_DEFINITION: [u8; 4] = 74u32.to_ne_bytes(); +pub const TYPE_REST_ELEMENT: [u8; 4] = 75u32.to_ne_bytes(); +pub const TYPE_SPREAD_ELEMENT: [u8; 4] = 78u32.to_ne_bytes(); +pub const TYPE_TEMPLATE_LITERAL: [u8; 4] = 85u32.to_ne_bytes(); +pub const TYPE_TRY_STATEMENT: [u8; 4] = 88u32.to_ne_bytes(); +pub const TYPE_VARIABLE_DECLARATION: [u8; 4] = 91u32.to_ne_bytes(); +pub const TYPE_VARIABLE_DECLARATOR: [u8; 4] = 92u32.to_ne_bytes(); pub const PANIC_ERROR_RESERVED_BYTES: usize = 8; pub const PANIC_ERROR_MESSAGE_OFFSET: usize = 4; @@ -125,6 +131,26 @@ pub const IMPORT_EXPRESSION_RESERVED_BYTES: usize = 12; pub const IMPORT_EXPRESSION_SOURCE_OFFSET: usize = 4; pub const IMPORT_EXPRESSION_OPTIONS_OFFSET: usize = 8; +pub const JSX_EMPTY_EXPRESSION_RESERVED_BYTES: usize = 4; + +pub const JSX_EXPRESSION_CONTAINER_RESERVED_BYTES: usize = 8; +pub const JSX_EXPRESSION_CONTAINER_EXPRESSION_OFFSET: usize = 4; + +pub const JSX_MEMBER_EXPRESSION_RESERVED_BYTES: usize = 12; +pub const JSX_MEMBER_EXPRESSION_OBJECT_OFFSET: usize = 4; +pub const JSX_MEMBER_EXPRESSION_PROPERTY_OFFSET: usize = 8; + +pub const JSX_NAMESPACED_NAME_RESERVED_BYTES: usize = 12; +pub const JSX_NAMESPACED_NAME_NAMESPACE_OFFSET: usize = 4; +pub const JSX_NAMESPACED_NAME_NAME_OFFSET: usize = 8; + +pub const JSX_OPENING_ELEMENT_RESERVED_BYTES: usize = 16; +pub const JSX_OPENING_ELEMENT_NAME_OFFSET: usize = 8; +pub const JSX_OPENING_ELEMENT_ATTRIBUTES_OFFSET: usize = 12; + +pub const JSX_SPREAD_ATTRIBUTE_RESERVED_BYTES: usize = 8; +pub const JSX_SPREAD_ATTRIBUTE_ARGUMENT_OFFSET: usize = 4; + pub const MEMBER_EXPRESSION_RESERVED_BYTES: usize = 16; pub const MEMBER_EXPRESSION_OBJECT_OFFSET: usize = 8; pub const MEMBER_EXPRESSION_PROPERTY_OFFSET: usize = 12; diff --git a/rust/parse_ast/src/convert_ast/converter/ast_macros.rs b/rust/parse_ast/src/convert_ast/converter/ast_macros.rs index 9270789b4..84fff18bf 100644 --- a/rust/parse_ast/src/convert_ast/converter/ast_macros.rs +++ b/rust/parse_ast/src/convert_ast/converter/ast_macros.rs @@ -315,11 +315,145 @@ macro_rules! store_import_specifier { }; } +#[macro_export] +macro_rules! store_jsx_attribute { + ($self:expr, span => $span:expr, name => [$name_value:expr, $name_converter:ident], value => [$value_value:expr, $value_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&42u32.to_ne_bytes(), &$span, 12, false); + // name + $self.update_reference_position(end_position + 4); + $self.$name_converter(&$name_value); + // value + if let Some(value) = $value_value.as_ref() { + $self.update_reference_position(end_position + 8); + $self.$value_converter(value); + } + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_jsx_closing_element { + ($self:expr, span => $span:expr, name => [$name_value:expr, $name_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&43u32.to_ne_bytes(), &$span, 8, false); + // name + $self.update_reference_position(end_position + 4); + $self.$name_converter(&$name_value); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_jsx_closing_fragment { + ($self:expr, span => $span:expr) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&44u32.to_ne_bytes(), &$span, 4, false); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_jsx_element { + ($self:expr, span => $span:expr, openingElement => [$openingElement_value:expr, $openingElement_converter:ident], children => [$children_value:expr, $children_converter:ident], closingElement => [$closingElement_value:expr, $closingElement_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&45u32.to_ne_bytes(), &$span, 16, false); + // openingElement + $self.update_reference_position(end_position + 4); + $self.$openingElement_converter(&$openingElement_value); + // children + $self.convert_item_list(&$children_value, end_position + 8, |ast_converter, node| { + ast_converter.$children_converter(node); + true + }); + // closingElement + if let Some(value) = $closingElement_value.as_ref() { + $self.update_reference_position(end_position + 12); + $self.$closingElement_converter(value); + } + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_jsx_fragment { + ($self:expr, span => $span:expr, openingFragment => [$openingFragment_value:expr, $openingFragment_converter:ident], children => [$children_value:expr, $children_converter:ident], closingFragment => [$closingFragment_value:expr, $closingFragment_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&48u32.to_ne_bytes(), &$span, 16, false); + // openingFragment + $self.update_reference_position(end_position + 4); + $self.$openingFragment_converter(&$openingFragment_value); + // children + $self.convert_item_list(&$children_value, end_position + 8, |ast_converter, node| { + ast_converter.$children_converter(node); + true + }); + // closingFragment + $self.update_reference_position(end_position + 12); + $self.$closingFragment_converter(&$closingFragment_value); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_jsx_identifier { + ($self:expr, span => $span:expr, name => $name_value:expr) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&49u32.to_ne_bytes(), &$span, 8, false); + // name + $self.convert_string($name_value, end_position + 4); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_jsx_opening_fragment { + ($self:expr, span => $span:expr) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&53u32.to_ne_bytes(), &$span, 4, false); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_jsx_spread_child { + ($self:expr, span => $span:expr, expression => [$expression_value:expr, $expression_converter:ident]) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&55u32.to_ne_bytes(), &$span, 8, false); + // expression + $self.update_reference_position(end_position + 4); + $self.$expression_converter(&$expression_value); + // end + $self.add_end(end_position, &$span); + }; +} + +#[macro_export] +macro_rules! store_jsx_text { + ($self:expr, span => $span:expr, value => $value_value:expr, raw => $raw_value:expr) => { + let _: &mut AstConverter = $self; + let end_position = $self.add_type_and_start(&56u32.to_ne_bytes(), &$span, 12, false); + // value + $self.convert_string($value_value, end_position + 4); + // raw + $self.convert_string($raw_value, end_position + 8); + // end + $self.add_end(end_position, &$span); + }; +} + #[macro_export] macro_rules! store_labeled_statement { ($self:expr, span => $span:expr, label => [$label_value:expr, $label_converter:ident], body => [$body_value:expr, $body_converter:ident]) => { let _: &mut AstConverter = $self; - let end_position = $self.add_type_and_start(&42u32.to_ne_bytes(), &$span, 12, false); + let end_position = $self.add_type_and_start(&57u32.to_ne_bytes(), &$span, 12, false); // label $self.update_reference_position(end_position + 4); $self.$label_converter(&$label_value); @@ -335,7 +469,7 @@ macro_rules! store_labeled_statement { macro_rules! store_literal_big_int { ($self:expr, span => $span:expr, bigint => $bigint_value:expr, raw => $raw_value:expr) => { let _: &mut AstConverter = $self; - let end_position = $self.add_type_and_start(&43u32.to_ne_bytes(), &$span, 12, false); + let end_position = $self.add_type_and_start(&58u32.to_ne_bytes(), &$span, 12, false); // bigint $self.convert_string($bigint_value, end_position + 4); // raw @@ -350,7 +484,7 @@ macro_rules! store_literal_boolean { ($self:expr, span => $span:expr, value => $value_value:expr) => { let _: &mut AstConverter = $self; let end_position = $self.add_type_and_start( - &44u32.to_ne_bytes(), + &59u32.to_ne_bytes(), &$span, 8, false, @@ -366,7 +500,7 @@ macro_rules! store_literal_boolean { macro_rules! store_literal_null { ($self:expr, span => $span:expr) => { let _: &mut AstConverter = $self; - let end_position = $self.add_type_and_start(&45u32.to_ne_bytes(), &$span, 4, false); + let end_position = $self.add_type_and_start(&60u32.to_ne_bytes(), &$span, 4, false); // end $self.add_end(end_position, &$span); }; @@ -376,7 +510,7 @@ macro_rules! store_literal_null { macro_rules! store_literal_number { ($self:expr, span => $span:expr, raw => $raw_value:expr, value => $value_value:expr) => { let _: &mut AstConverter = $self; - let end_position = $self.add_type_and_start(&46u32.to_ne_bytes(), &$span, 16, false); + let end_position = $self.add_type_and_start(&61u32.to_ne_bytes(), &$span, 16, false); // raw if let Some(value) = $raw_value.as_ref() { $self.convert_string(value, end_position + 4); @@ -393,7 +527,7 @@ macro_rules! store_literal_number { macro_rules! store_literal_reg_exp { ($self:expr, span => $span:expr, flags => $flags_value:expr, pattern => $pattern_value:expr) => { let _: &mut AstConverter = $self; - let end_position = $self.add_type_and_start(&47u32.to_ne_bytes(), &$span, 12, false); + let end_position = $self.add_type_and_start(&62u32.to_ne_bytes(), &$span, 12, false); // flags $self.convert_string($flags_value, end_position + 4); // pattern @@ -407,7 +541,7 @@ macro_rules! store_literal_reg_exp { macro_rules! store_literal_string { ($self:expr, span => $span:expr, value => $value_value:expr, raw => $raw_value:expr) => { let _: &mut AstConverter = $self; - let end_position = $self.add_type_and_start(&48u32.to_ne_bytes(), &$span, 12, false); + let end_position = $self.add_type_and_start(&63u32.to_ne_bytes(), &$span, 12, false); // value $self.convert_string($value_value, end_position + 4); // raw @@ -423,7 +557,7 @@ macro_rules! store_literal_string { macro_rules! store_object_expression { ($self:expr, span => $span:expr, properties => [$properties_value:expr, $properties_converter:ident]) => { let _: &mut AstConverter = $self; - let end_position = $self.add_type_and_start(&54u32.to_ne_bytes(), &$span, 8, false); + let end_position = $self.add_type_and_start(&69u32.to_ne_bytes(), &$span, 8, false); // properties $self.convert_item_list( &$properties_value, @@ -442,7 +576,7 @@ macro_rules! store_object_expression { macro_rules! store_object_pattern { ($self:expr, span => $span:expr, properties => [$properties_value:expr, $properties_converter:ident]) => { let _: &mut AstConverter = $self; - let end_position = $self.add_type_and_start(&55u32.to_ne_bytes(), &$span, 8, false); + let end_position = $self.add_type_and_start(&70u32.to_ne_bytes(), &$span, 8, false); // properties $self.convert_item_list( &$properties_value, @@ -461,7 +595,7 @@ macro_rules! store_object_pattern { macro_rules! store_private_identifier { ($self:expr, span => $span:expr, name => $name_value:expr) => { let _: &mut AstConverter = $self; - let end_position = $self.add_type_and_start(&56u32.to_ne_bytes(), &$span, 8, false); + let end_position = $self.add_type_and_start(&71u32.to_ne_bytes(), &$span, 8, false); // name $self.convert_string($name_value, end_position + 4); // end @@ -473,7 +607,7 @@ macro_rules! store_private_identifier { macro_rules! store_return_statement { ($self:expr, span => $span:expr, argument => [$argument_value:expr, $argument_converter:ident]) => { let _: &mut AstConverter = $self; - let end_position = $self.add_type_and_start(&61u32.to_ne_bytes(), &$span, 8, false); + let end_position = $self.add_type_and_start(&76u32.to_ne_bytes(), &$span, 8, false); // argument if let Some(value) = $argument_value.as_ref() { $self.update_reference_position(end_position + 4); @@ -488,7 +622,7 @@ macro_rules! store_return_statement { macro_rules! store_sequence_expression { ($self:expr, span => $span:expr, expressions => [$expressions_value:expr, $expressions_converter:ident]) => { let _: &mut AstConverter = $self; - let end_position = $self.add_type_and_start(&62u32.to_ne_bytes(), &$span, 8, false); + let end_position = $self.add_type_and_start(&77u32.to_ne_bytes(), &$span, 8, false); // expressions $self.convert_item_list( &$expressions_value, @@ -507,7 +641,7 @@ macro_rules! store_sequence_expression { macro_rules! store_static_block { ($self:expr, span => $span:expr, body => [$body_value:expr, $body_converter:ident]) => { let _: &mut AstConverter = $self; - let end_position = $self.add_type_and_start(&64u32.to_ne_bytes(), &$span, 8, false); + let end_position = $self.add_type_and_start(&79u32.to_ne_bytes(), &$span, 8, false); // body $self.convert_item_list(&$body_value, end_position + 4, |ast_converter, node| { ast_converter.$body_converter(node); @@ -522,7 +656,7 @@ macro_rules! store_static_block { macro_rules! store_super_element { ($self:expr, span => $span:expr) => { let _: &mut AstConverter = $self; - let end_position = $self.add_type_and_start(&65u32.to_ne_bytes(), &$span, 4, false); + let end_position = $self.add_type_and_start(&80u32.to_ne_bytes(), &$span, 4, false); // end $self.add_end(end_position, &$span); }; @@ -532,7 +666,7 @@ macro_rules! store_super_element { macro_rules! store_switch_case { ($self:expr, span => $span:expr, test => [$test_value:expr, $test_converter:ident], consequent => [$consequent_value:expr, $consequent_converter:ident]) => { let _: &mut AstConverter = $self; - let end_position = $self.add_type_and_start(&66u32.to_ne_bytes(), &$span, 12, false); + let end_position = $self.add_type_and_start(&81u32.to_ne_bytes(), &$span, 12, false); // test if let Some(value) = $test_value.as_ref() { $self.update_reference_position(end_position + 4); @@ -556,7 +690,7 @@ macro_rules! store_switch_case { macro_rules! store_switch_statement { ($self:expr, span => $span:expr, discriminant => [$discriminant_value:expr, $discriminant_converter:ident], cases => [$cases_value:expr, $cases_converter:ident]) => { let _: &mut AstConverter = $self; - let end_position = $self.add_type_and_start(&67u32.to_ne_bytes(), &$span, 12, false); + let end_position = $self.add_type_and_start(&82u32.to_ne_bytes(), &$span, 12, false); // discriminant $self.update_reference_position(end_position + 4); $self.$discriminant_converter(&$discriminant_value); @@ -574,7 +708,7 @@ macro_rules! store_switch_statement { macro_rules! store_tagged_template_expression { ($self:expr, span => $span:expr, tag => [$tag_value:expr, $tag_converter:ident], quasi => [$quasi_value:expr, $quasi_converter:ident]) => { let _: &mut AstConverter = $self; - let end_position = $self.add_type_and_start(&68u32.to_ne_bytes(), &$span, 12, false); + let end_position = $self.add_type_and_start(&83u32.to_ne_bytes(), &$span, 12, false); // tag $self.update_reference_position(end_position + 4); $self.$tag_converter(&$tag_value); @@ -591,7 +725,7 @@ macro_rules! store_template_element { ($self:expr, span => $span:expr, tail => $tail_value:expr, cooked => $cooked_value:expr, raw => $raw_value:expr) => { let _: &mut AstConverter = $self; let end_position = $self.add_type_and_start( - &69u32.to_ne_bytes(), + &84u32.to_ne_bytes(), &$span, 16, false, @@ -613,7 +747,7 @@ macro_rules! store_template_element { macro_rules! store_this_expression { ($self:expr, span => $span:expr) => { let _: &mut AstConverter = $self; - let end_position = $self.add_type_and_start(&71u32.to_ne_bytes(), &$span, 4, false); + let end_position = $self.add_type_and_start(&86u32.to_ne_bytes(), &$span, 4, false); // end $self.add_end(end_position, &$span); }; @@ -623,7 +757,7 @@ macro_rules! store_this_expression { macro_rules! store_throw_statement { ($self:expr, span => $span:expr, argument => [$argument_value:expr, $argument_converter:ident]) => { let _: &mut AstConverter = $self; - let end_position = $self.add_type_and_start(&72u32.to_ne_bytes(), &$span, 8, false); + let end_position = $self.add_type_and_start(&87u32.to_ne_bytes(), &$span, 8, false); // argument $self.update_reference_position(end_position + 4); $self.$argument_converter(&$argument_value); @@ -636,7 +770,7 @@ macro_rules! store_throw_statement { macro_rules! store_unary_expression { ($self:expr, span => $span:expr, operator => $operator_value:expr, argument => [$argument_value:expr, $argument_converter:ident]) => { let _: &mut AstConverter = $self; - let end_position = $self.add_type_and_start(&74u32.to_ne_bytes(), &$span, 12, false); + let end_position = $self.add_type_and_start(&89u32.to_ne_bytes(), &$span, 12, false); // operator let operator_position = end_position + 4; $self.buffer[operator_position..operator_position + 4].copy_from_slice($operator_value); @@ -653,7 +787,7 @@ macro_rules! store_update_expression { ($self:expr, span => $span:expr, prefix => $prefix_value:expr, operator => $operator_value:expr, argument => [$argument_value:expr, $argument_converter:ident]) => { let _: &mut AstConverter = $self; let end_position = $self.add_type_and_start( - &75u32.to_ne_bytes(), + &90u32.to_ne_bytes(), &$span, 16, false, @@ -675,7 +809,7 @@ macro_rules! store_update_expression { macro_rules! store_while_statement { ($self:expr, span => $span:expr, test => [$test_value:expr, $test_converter:ident], body => [$body_value:expr, $body_converter:ident]) => { let _: &mut AstConverter = $self; - let end_position = $self.add_type_and_start(&78u32.to_ne_bytes(), &$span, 12, false); + let end_position = $self.add_type_and_start(&93u32.to_ne_bytes(), &$span, 12, false); // test $self.update_reference_position(end_position + 4); $self.$test_converter(&$test_value); @@ -692,7 +826,7 @@ macro_rules! store_yield_expression { ($self:expr, span => $span:expr, delegate => $delegate_value:expr, argument => [$argument_value:expr, $argument_converter:ident]) => { let _: &mut AstConverter = $self; let end_position = $self.add_type_and_start( - &79u32.to_ne_bytes(), + &94u32.to_ne_bytes(), &$span, 12, false, @@ -774,6 +908,20 @@ macro_rules! store_function_declaration_flags { }; } +#[macro_export] +macro_rules! store_jsx_opening_element_flags { + ($self:expr, $end_position:expr, selfClosing => $selfClosing_value:expr) => { + let _: &mut AstConverter = $self; + let _: usize = $end_position; + let mut flags = 0u32; + if $selfClosing_value { + flags |= 1; + } + let flags_position = $end_position + 4; + $self.buffer[flags_position..flags_position + 4].copy_from_slice(&flags.to_ne_bytes()); + }; +} + #[macro_export] macro_rules! store_literal_boolean_flags { ($self:expr, $end_position:expr, value => $value_value:expr) => { diff --git a/rust/parse_ast/src/convert_ast/converter/utf16_positions.rs b/rust/parse_ast/src/convert_ast/converter/utf16_positions.rs index 0d963b523..7dccfe05e 100644 --- a/rust/parse_ast/src/convert_ast/converter/utf16_positions.rs +++ b/rust/parse_ast/src/convert_ast/converter/utf16_positions.rs @@ -4,7 +4,7 @@ use std::str::Chars; use crate::convert_ast::annotations::CommentKind::Annotation; use crate::convert_ast::annotations::{AnnotationKind, AnnotationWithType}; -pub struct Utf8ToUtf16ByteIndexConverterAndAnnotationHandler<'a> { +pub(crate) struct Utf8ToUtf16ByteIndexConverterAndAnnotationHandler<'a> { current_utf8_index: u32, current_utf16_index: u32, character_iterator: Chars<'a>, @@ -17,14 +17,14 @@ pub struct Utf8ToUtf16ByteIndexConverterAndAnnotationHandler<'a> { } #[derive(Debug)] -pub struct ConvertedAnnotation { - pub start: u32, - pub end: u32, - pub kind: AnnotationKind, +pub(crate) struct ConvertedAnnotation { + pub(crate) start: u32, + pub(crate) end: u32, + pub(crate) kind: AnnotationKind, } impl<'a> Utf8ToUtf16ByteIndexConverterAndAnnotationHandler<'a> { - pub fn new(code: &'a str, annotations: &'a [AnnotationWithType]) -> Self { + pub(crate) fn new(code: &'a str, annotations: &'a [AnnotationWithType]) -> Self { let mut annotation_iterator = annotations.iter(); let current_annotation = annotation_iterator.next(); Self { @@ -62,7 +62,7 @@ impl<'a> Utf8ToUtf16ByteIndexConverterAndAnnotationHandler<'a> { /// non-whitespace from the annotation, `keep_annotations_for_next` will /// prevent annotations from being invalidated when the next position is /// converted. - pub fn convert(&mut self, utf8_index: u32, keep_annotations_for_next: bool) -> u32 { + pub(crate) fn convert(&mut self, utf8_index: u32, keep_annotations_for_next: bool) -> u32 { if self.current_utf8_index > utf8_index { panic!( "Cannot convert positions backwards: {} < {}", @@ -108,7 +108,10 @@ impl<'a> Utf8ToUtf16ByteIndexConverterAndAnnotationHandler<'a> { self.current_utf16_index } - pub fn take_collected_annotations(&mut self, kind: AnnotationKind) -> Vec { + pub(crate) fn take_collected_annotations( + &mut self, + kind: AnnotationKind, + ) -> Vec { let mut relevant_annotations = Vec::new(); for annotation in self.collected_annotations.drain(..) { if annotation.kind == kind { @@ -120,18 +123,18 @@ impl<'a> Utf8ToUtf16ByteIndexConverterAndAnnotationHandler<'a> { relevant_annotations } - pub fn add_collected_annotations(&mut self, annotations: Vec) { + pub(crate) fn add_collected_annotations(&mut self, annotations: Vec) { self.collected_annotations.extend(annotations); self.keep_annotations = true; } - pub fn invalidate_collected_annotations(&mut self) { + pub(crate) fn invalidate_collected_annotations(&mut self) { self .invalid_annotations .append(&mut self.collected_annotations); } - pub fn take_invalid_annotations(&mut self) -> Vec { + pub(crate) fn take_invalid_annotations(&mut self) -> Vec { std::mem::take(&mut self.invalid_annotations) } } diff --git a/rust/parse_ast/src/error_emit.rs b/rust/parse_ast/src/error_emit.rs index 63ad66da2..3a738704c 100644 --- a/rust/parse_ast/src/error_emit.rs +++ b/rust/parse_ast/src/error_emit.rs @@ -24,7 +24,7 @@ impl Write for Writer { } } -pub struct ErrorEmitter { +pub(crate) struct ErrorEmitter { wr: Box, } @@ -44,7 +44,7 @@ impl Emitter for ErrorEmitter { } } -pub fn try_with_handler(code: &str, op: F) -> Result> +pub(crate) fn try_with_handler(code: &str, op: F) -> Result> where F: FnOnce(&Handler) -> Result, { diff --git a/rust/parse_ast/src/lib.rs b/rust/parse_ast/src/lib.rs index 6ffe5074d..ff8790a93 100644 --- a/rust/parse_ast/src/lib.rs +++ b/rust/parse_ast/src/lib.rs @@ -17,7 +17,7 @@ mod ast_nodes; mod convert_ast; mod error_emit; -pub fn parse_ast(code: String, allow_return_outside_function: bool) -> Vec { +pub fn parse_ast(code: String, allow_return_outside_function: bool, jsx: bool) -> Vec { let cm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let target = EsVersion::EsNext; let syntax = Syntax::Es(EsSyntax { @@ -25,6 +25,7 @@ pub fn parse_ast(code: String, allow_return_outside_function: bool) -> Vec { import_attributes: true, explicit_resource_management: true, decorators: true, + jsx, ..Default::default() }); diff --git a/scripts/ast-types.js b/scripts/ast-types.js index fbfa8f807..2483f27b8 100644 --- a/scripts/ast-types.js +++ b/scripts/ast-types.js @@ -23,6 +23,7 @@ * For encoded non-JavaScript AST nodes like TypeScript or JSX, we try to follow * the format of typescript-eslint, which can be derived from their playground * https://typescript-eslint.io/play/#showAST=es&fileType=.tsx + * For JSX, see also https://github.com/facebook/jsx/blob/main/AST.md */ /** @typedef {"Node"|"OptionalNode"|"NodeList"|"Annotations"|"InvalidAnnotations"|"String"|"FixedString"|"OptionalString"|"Float"} FieldType */ @@ -388,6 +389,98 @@ export const AST_NODES = { imported: 'local' } }, + JSXAttribute: { + estreeType: 'any', + fields: [ + ['name', 'Node'], + ['value', 'OptionalNode'] + ] + }, + JSXClosingElement: { + estreeType: 'any', + fields: [['name', 'Node']] + }, + JSXClosingFragment: { + estreeType: 'any', + fields: [] + }, + JSXElement: { + estreeType: 'any', + fields: [ + ['openingElement', 'Node'], + ['children', 'NodeList'], + ['closingElement', 'OptionalNode'] + ] + }, + JSXEmptyExpression: { + estreeType: 'any', + useMacro: false + }, + JSXExpressionContainer: { + estreeType: 'any', + fields: [['expression', 'Node']], + useMacro: false + }, + JSXFragment: { + estreeType: 'any', + fields: [ + ['openingFragment', 'Node'], + ['children', 'NodeList'], + ['closingFragment', 'Node'] + ] + }, + JSXIdentifier: { + estreeType: 'any', + fields: [['name', 'String']] + }, + JSXMemberExpression: { + estreeType: 'any', + fields: [ + ['object', 'Node'], + ['property', 'Node'] + ], + useMacro: false + }, + JSXNamespacedName: { + estreeType: 'any', + fields: [ + ['namespace', 'Node'], + ['name', 'Node'] + ], + useMacro: false + }, + JSXOpeningElement: { + estreeType: 'any', + fields: [ + ['name', 'Node'], + ['attributes', 'NodeList'] + ], + flags: ['selfClosing'], + useMacro: false + }, + JSXOpeningFragment: { + additionalFields: { + attributes: '[]', + selfClosing: 'false' + }, + estreeType: 'any' + }, + JSXSpreadAttribute: { + estreeType: 'any', + fields: [['argument', 'Node']], + useMacro: false + }, + JSXSpreadChild: { + estreeType: 'any', + fields: [['expression', 'Node']] + }, + JSXText: { + estreeType: 'any', + fields: [ + ['value', 'String'], + ['raw', 'String'] + ] + }, LabeledStatement: { fields: [ ['label', 'Node'], diff --git a/scripts/generate-buffer-parsers.js b/scripts/generate-buffer-parsers.js index 3292aa272..d6f9ce6e6 100644 --- a/scripts/generate-buffer-parsers.js +++ b/scripts/generate-buffer-parsers.js @@ -1,6 +1,6 @@ import { writeFile } from 'node:fs/promises'; import { astNodeNamesWithFieldOrder } from './ast-types.js'; -import { firstLetterLowercase, generateNotEditFilesComment, lintTsFile } from './helpers.js'; +import { firstLettersLowercase, generateNotEditFilesComment, lintTsFile } from './helpers.js'; const notEditFilesComment = generateNotEditFilesComment(import.meta.url); @@ -60,7 +60,7 @@ const jsConverters = astNodeNamesWithFieldOrder.map(({ name, fields, node, origi parameters.push('position, buffer'); } } - return `function ${firstLetterLowercase(name)} (${parameters.join(', ')}) { + return `function ${firstLettersLowercase(name)} (${parameters.join(', ')}) { ${definitions.join('')}}`; }); diff --git a/scripts/generate-buffer-to-ast.js b/scripts/generate-buffer-to-ast.js index 6199e15ab..4a0b971da 100644 --- a/scripts/generate-buffer-to-ast.js +++ b/scripts/generate-buffer-to-ast.js @@ -1,6 +1,6 @@ import { writeFile } from 'node:fs/promises'; import { astNodeNamesWithFieldOrder } from './ast-types.js'; -import { firstLetterLowercase, generateNotEditFilesComment, lintTsFile } from './helpers.js'; +import { firstLettersLowercase, generateNotEditFilesComment, lintTsFile } from './helpers.js'; const notEditFilesComment = generateNotEditFilesComment(import.meta.url); @@ -38,7 +38,7 @@ const jsConverters = astNodeNamesWithFieldOrder.map(({ name, fields, node, origi ...getFixedProperties(node), ...Object.entries(node.additionalFields || []).map(([key, value]) => `${key}: ${value}`) ]; - return `function ${firstLetterLowercase(name)} (position, buffer): ${name}Node { + return `function ${firstLettersLowercase(name)} (position, buffer): ${name}Node { ${definitions.join('')}return { type: '${node.astType || name}', start: buffer[position], diff --git a/scripts/helpers.js b/scripts/helpers.js index 9e1d90160..246f97579 100644 --- a/scripts/helpers.js +++ b/scripts/helpers.js @@ -99,11 +99,14 @@ export function lintRustFile(file) { } /** + * Replace the first letters with lowercase while maintaining camel casing * @param {string} string * @returns {string} */ -export function firstLetterLowercase(string) { - return string[0].toLowerCase() + string.slice(1); +export function firstLettersLowercase(string) { + return string.replace(/^[A-Z]+/, match => + match.length === 1 ? match.toLowerCase() : match.slice(0, -1).toLowerCase() + match.slice(-1) + ); } /** @@ -111,7 +114,7 @@ export function firstLetterLowercase(string) { * @returns {string} */ export function toSnakeCase(string) { - return string.replace(/(? void; addImport: (node: ImportDeclaration) => void; addImportMeta: (node: MetaProperty) => void; + addImportSource: (importSource: string) => void; code: string; deoptimizationTracker: PathTracker; error: (properties: RollupLog, pos: number) => never; fileName: string; getExports: () => string[]; + getImportedJsxFactoryVariable: (baseName: string, pos: number, importSource: string) => Variable; getModuleExecIndex: () => number; getModuleName: () => string; getNodeConstructor: (name: string) => typeof NodeBase; @@ -869,11 +872,13 @@ export default class Module { addExport: this.addExport.bind(this), addImport: this.addImport.bind(this), addImportMeta: this.addImportMeta.bind(this), + addImportSource: this.addImportSource.bind(this), code, // Only needed for debugging deoptimizationTracker: this.graph.deoptimizationTracker, error: this.error.bind(this), fileName, // Needed for warnings getExports: this.getExports.bind(this), + getImportedJsxFactoryVariable: this.getImportedJsxFactoryVariable.bind(this), getModuleExecIndex: () => this.execIndex, getModuleName: this.basename.bind(this), getNodeConstructor: (name: string) => nodeConstructors[name] || nodeConstructors.UnknownNode, @@ -906,7 +911,7 @@ export default class Module { } else { // Measuring asynchronous code does not provide reasonable results timeEnd('generate ast', 3); - const astBuffer = await parseAsync(code, false); + const astBuffer = await parseAsync(code, false, this.options.jsx !== false); timeStart('generate ast', 3); this.ast = convertProgram(astBuffer, programParent, this.scope); // Make lazy and apply LRU cache to not hog the memory @@ -1147,6 +1152,12 @@ export default class Module { } } + private addImportSource(importSource: string): void { + if (importSource && !this.sourcesWithAttributes.has(importSource)) { + this.sourcesWithAttributes.set(importSource, EMPTY_OBJECT); + } + } + private addImportMeta(node: MetaProperty): void { this.importMetas.push(node); } @@ -1233,6 +1244,20 @@ export default class Module { } } + private getImportedJsxFactoryVariable( + baseName: string, + nodeStart: number, + importSource: string + ): Variable { + const { id } = this.resolvedIds[importSource!]; + const module = this.graph.modulesById.get(id)!; + const [variable] = module.getVariableForExportName(baseName); + if (!variable) { + return this.error(logMissingJsxExport(baseName, id, this.id), nodeStart); + } + return variable; + } + private getVariableFromNamespaceReexports( name: string, importerForSideEffects?: Module, @@ -1386,7 +1411,7 @@ export default class Module { private tryParse() { try { - return parseAst(this.info.code!); + return parseAst(this.info.code!, { jsx: this.options.jsx !== false }); } catch (error_: any) { return this.error(logModuleParseError(error_, this.id), error_.pos); } diff --git a/src/ast/bufferParsers.ts b/src/ast/bufferParsers.ts index b197bd23e..0c270c3ff 100644 --- a/src/ast/bufferParsers.ts +++ b/src/ast/bufferParsers.ts @@ -48,6 +48,21 @@ import ImportDefaultSpecifier from './nodes/ImportDefaultSpecifier'; import ImportExpression from './nodes/ImportExpression'; import ImportNamespaceSpecifier from './nodes/ImportNamespaceSpecifier'; import ImportSpecifier from './nodes/ImportSpecifier'; +import JSXAttribute from './nodes/JSXAttribute'; +import JSXClosingElement from './nodes/JSXClosingElement'; +import JSXClosingFragment from './nodes/JSXClosingFragment'; +import JSXElement from './nodes/JSXElement'; +import JSXEmptyExpression from './nodes/JSXEmptyExpression'; +import JSXExpressionContainer from './nodes/JSXExpressionContainer'; +import JSXFragment from './nodes/JSXFragment'; +import JSXIdentifier from './nodes/JSXIdentifier'; +import JSXMemberExpression from './nodes/JSXMemberExpression'; +import JSXNamespacedName from './nodes/JSXNamespacedName'; +import JSXOpeningElement from './nodes/JSXOpeningElement'; +import JSXOpeningFragment from './nodes/JSXOpeningFragment'; +import JSXSpreadAttribute from './nodes/JSXSpreadAttribute'; +import JSXSpreadChild from './nodes/JSXSpreadChild'; +import JSXText from './nodes/JSXText'; import LabeledStatement from './nodes/LabeledStatement'; import Literal from './nodes/Literal'; import LogicalExpression from './nodes/LogicalExpression'; @@ -141,6 +156,21 @@ const nodeTypeStrings = [ 'ImportExpression', 'ImportNamespaceSpecifier', 'ImportSpecifier', + 'JSXAttribute', + 'JSXClosingElement', + 'JSXClosingFragment', + 'JSXElement', + 'JSXEmptyExpression', + 'JSXExpressionContainer', + 'JSXFragment', + 'JSXIdentifier', + 'JSXMemberExpression', + 'JSXNamespacedName', + 'JSXOpeningElement', + 'JSXOpeningFragment', + 'JSXSpreadAttribute', + 'JSXSpreadChild', + 'JSXText', 'LabeledStatement', 'Literal', 'Literal', @@ -224,6 +254,21 @@ const nodeConstructors: (typeof NodeBase)[] = [ ImportExpression, ImportNamespaceSpecifier, ImportSpecifier, + JSXAttribute, + JSXClosingElement, + JSXClosingFragment, + JSXElement, + JSXEmptyExpression, + JSXExpressionContainer, + JSXFragment, + JSXIdentifier, + JSXMemberExpression, + JSXNamespacedName, + JSXOpeningElement, + JSXOpeningFragment, + JSXSpreadAttribute, + JSXSpreadChild, + JSXText, LabeledStatement, Literal, Literal, @@ -563,6 +608,74 @@ const bufferParsers: ((node: any, position: number, buffer: AstBuffer) => void)[ node.imported = importedPosition === 0 ? node.local : convertNode(node, scope, importedPosition, buffer); }, + function jsxAttribute(node: JSXAttribute, position, buffer) { + const { scope } = node; + node.name = convertNode(node, scope, buffer[position], buffer); + const valuePosition = buffer[position + 1]; + node.value = valuePosition === 0 ? null : convertNode(node, scope, valuePosition, buffer); + }, + function jsxClosingElement(node: JSXClosingElement, position, buffer) { + const { scope } = node; + node.name = convertNode(node, scope, buffer[position], buffer); + }, + function jsxClosingFragment() {}, + function jsxElement(node: JSXElement, position, buffer) { + const { scope } = node; + node.openingElement = convertNode(node, scope, buffer[position], buffer); + node.children = convertNodeList(node, scope, buffer[position + 1], buffer); + const closingElementPosition = buffer[position + 2]; + node.closingElement = + closingElementPosition === 0 + ? null + : convertNode(node, scope, closingElementPosition, buffer); + }, + function jsxEmptyExpression() {}, + function jsxExpressionContainer(node: JSXExpressionContainer, position, buffer) { + const { scope } = node; + node.expression = convertNode(node, scope, buffer[position], buffer); + }, + function jsxFragment(node: JSXFragment, position, buffer) { + const { scope } = node; + node.openingFragment = convertNode(node, scope, buffer[position], buffer); + node.children = convertNodeList(node, scope, buffer[position + 1], buffer); + node.closingFragment = convertNode(node, scope, buffer[position + 2], buffer); + }, + function jsxIdentifier(node: JSXIdentifier, position, buffer) { + node.name = buffer.convertString(buffer[position]); + }, + function jsxMemberExpression(node: JSXMemberExpression, position, buffer) { + const { scope } = node; + node.object = convertNode(node, scope, buffer[position], buffer); + node.property = convertNode(node, scope, buffer[position + 1], buffer); + }, + function jsxNamespacedName(node: JSXNamespacedName, position, buffer) { + const { scope } = node; + node.namespace = convertNode(node, scope, buffer[position], buffer); + node.name = convertNode(node, scope, buffer[position + 1], buffer); + }, + function jsxOpeningElement(node: JSXOpeningElement, position, buffer) { + const { scope } = node; + const flags = buffer[position]; + node.selfClosing = (flags & 1) === 1; + node.name = convertNode(node, scope, buffer[position + 1], buffer); + node.attributes = convertNodeList(node, scope, buffer[position + 2], buffer); + }, + function jsxOpeningFragment(node: JSXOpeningFragment) { + node.attributes = []; + node.selfClosing = false; + }, + function jsxSpreadAttribute(node: JSXSpreadAttribute, position, buffer) { + const { scope } = node; + node.argument = convertNode(node, scope, buffer[position], buffer); + }, + function jsxSpreadChild(node: JSXSpreadChild, position, buffer) { + const { scope } = node; + node.expression = convertNode(node, scope, buffer[position], buffer); + }, + function jsxText(node: JSXText, position, buffer) { + node.value = buffer.convertString(buffer[position]); + node.raw = buffer.convertString(buffer[position + 1]); + }, function labeledStatement(node: LabeledStatement, position, buffer) { const { scope } = node; node.label = convertNode(node, scope, buffer[position], buffer); diff --git a/src/ast/childNodeKeys.ts b/src/ast/childNodeKeys.ts index e6ab43b65..2658d723d 100644 --- a/src/ast/childNodeKeys.ts +++ b/src/ast/childNodeKeys.ts @@ -41,6 +41,21 @@ export const childNodeKeys: Record = { ImportExpression: ['source', 'options'], ImportNamespaceSpecifier: ['local'], ImportSpecifier: ['imported', 'local'], + JSXAttribute: ['name', 'value'], + JSXClosingElement: ['name'], + JSXClosingFragment: [], + JSXElement: ['openingElement', 'children', 'closingElement'], + JSXEmptyExpression: [], + JSXExpressionContainer: ['expression'], + JSXFragment: ['openingFragment', 'children', 'closingFragment'], + JSXIdentifier: [], + JSXMemberExpression: ['object', 'property'], + JSXNamespacedName: ['namespace', 'name'], + JSXOpeningElement: ['name', 'attributes'], + JSXOpeningFragment: [], + JSXSpreadAttribute: ['argument'], + JSXSpreadChild: ['expression'], + JSXText: [], LabeledStatement: ['label', 'body'], Literal: [], LogicalExpression: ['left', 'right'], diff --git a/src/ast/nodes/Identifier.ts b/src/ast/nodes/Identifier.ts index 771526ef8..c513e800b 100644 --- a/src/ast/nodes/Identifier.ts +++ b/src/ast/nodes/Identifier.ts @@ -1,57 +1,23 @@ import isReference, { type NodeWithFieldDefinition } from 'is-reference'; import type MagicString from 'magic-string'; -import type { NormalizedTreeshakingOptions } from '../../rollup/types'; import { BLANK } from '../../utils/blank'; -import { logIllegalImportReassignment } from '../../utils/logs'; -import { PureFunctionKey } from '../../utils/pureFunctions'; import type { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; -import { markModuleAndImpureDependenciesAsExecuted } from '../../utils/traverseStaticDependencies'; -import type { DeoptimizableEntity } from '../DeoptimizableEntity'; -import type { HasEffectsContext, InclusionContext } from '../ExecutionContext'; -import type { NodeInteraction, NodeInteractionCalled } from '../NodeInteractions'; -import { - INTERACTION_ACCESSED, - INTERACTION_ASSIGNED, - INTERACTION_CALLED, - NODE_INTERACTION_UNKNOWN_ACCESS -} from '../NodeInteractions'; import type FunctionScope from '../scopes/FunctionScope'; -import { EMPTY_PATH, type ObjectPath, type PathTracker } from '../utils/PathTracker'; -import GlobalVariable from '../variables/GlobalVariable'; -import LocalVariable from '../variables/LocalVariable'; +import type LocalVariable from '../variables/LocalVariable'; import type Variable from '../variables/Variable'; import * as NodeType from './NodeType'; -import { Flag, isFlagSet, setFlag } from './shared/BitFlags'; -import { - type ExpressionEntity, - type LiteralValueOrUnknown, - UNKNOWN_EXPRESSION -} from './shared/Expression'; -import { NodeBase } from './shared/Node'; +import { type ExpressionEntity } from './shared/Expression'; +import IdentifierBase from './shared/IdentifierBase'; import type { PatternNode } from './shared/Pattern'; import type { VariableKind } from './shared/VariableKinds'; -import type SpreadElement from './SpreadElement'; export type IdentifierWithVariable = Identifier & { variable: Variable }; -const tdzVariableKinds = new Set(['class', 'const', 'let', 'var', 'using', 'await using']); - -export default class Identifier extends NodeBase implements PatternNode { - declare name: string; - declare type: NodeType.tIdentifier; +export default class Identifier extends IdentifierBase implements PatternNode { + name!: string; + type!: NodeType.tIdentifier; variable: Variable | null = null; - private get isTDZAccess(): boolean | null { - if (!isFlagSet(this.flags, Flag.tdzAccessDefined)) { - return null; - } - return isFlagSet(this.flags, Flag.tdzAccess); - } - private set isTDZAccess(value: boolean) { - this.flags = setFlag(this.flags, Flag.tdzAccessDefined, true); - this.flags = setFlag(this.flags, Flag.tdzAccess, value); - } - addExportedVariables( variables: Variable[], exportNamesByVariable: ReadonlyMap @@ -61,12 +27,11 @@ export default class Identifier extends NodeBase implements PatternNode { } } - private isReferenceVariable = false; bind(): void { if (!this.variable && isReference(this, this.parent as NodeWithFieldDefinition)) { this.variable = this.scope.findVariable(this.name); this.variable.addReference(this); - this.isReferenceVariable = true; + this.isVariableReference = true; } } @@ -108,150 +73,6 @@ export default class Identifier extends NodeBase implements PatternNode { return [(this.variable = variable)]; } - deoptimizeArgumentsOnInteractionAtPath( - interaction: NodeInteraction, - path: ObjectPath, - recursionTracker: PathTracker - ): void { - this.variable!.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker); - } - - deoptimizePath(path: ObjectPath): void { - if (path.length === 0 && !this.scope.contains(this.name)) { - this.disallowImportReassignment(); - } - // We keep conditional chaining because an unknown Node could have an - // Identifier as property that might be deoptimized by default - this.variable?.deoptimizePath(path); - } - - getLiteralValueAtPath( - path: ObjectPath, - recursionTracker: PathTracker, - origin: DeoptimizableEntity - ): LiteralValueOrUnknown { - return this.getVariableRespectingTDZ()!.getLiteralValueAtPath(path, recursionTracker, origin); - } - - getReturnExpressionWhenCalledAtPath( - path: ObjectPath, - interaction: NodeInteractionCalled, - recursionTracker: PathTracker, - origin: DeoptimizableEntity - ): [expression: ExpressionEntity, isPure: boolean] { - const [expression, isPure] = - this.getVariableRespectingTDZ()!.getReturnExpressionWhenCalledAtPath( - path, - interaction, - recursionTracker, - origin - ); - return [expression, isPure || this.isPureFunction(path)]; - } - - hasEffects(context: HasEffectsContext): boolean { - if (!this.deoptimized) this.applyDeoptimizations(); - if (this.isPossibleTDZ() && this.variable!.kind !== 'var') { - return true; - } - return ( - (this.scope.context.options.treeshake as NormalizedTreeshakingOptions) - .unknownGlobalSideEffects && - this.variable instanceof GlobalVariable && - !this.isPureFunction(EMPTY_PATH) && - this.variable.hasEffectsOnInteractionAtPath( - EMPTY_PATH, - NODE_INTERACTION_UNKNOWN_ACCESS, - context - ) - ); - } - - hasEffectsOnInteractionAtPath( - path: ObjectPath, - interaction: NodeInteraction, - context: HasEffectsContext - ): boolean { - switch (interaction.type) { - case INTERACTION_ACCESSED: { - return ( - this.variable !== null && - !this.isPureFunction(path) && - this.getVariableRespectingTDZ()!.hasEffectsOnInteractionAtPath(path, interaction, context) - ); - } - case INTERACTION_ASSIGNED: { - return ( - path.length > 0 ? this.getVariableRespectingTDZ() : this.variable - )!.hasEffectsOnInteractionAtPath(path, interaction, context); - } - case INTERACTION_CALLED: { - return ( - !this.isPureFunction(path) && - this.getVariableRespectingTDZ()!.hasEffectsOnInteractionAtPath(path, interaction, context) - ); - } - } - } - - include(): void { - if (!this.deoptimized) this.applyDeoptimizations(); - if (!this.included) { - this.included = true; - if (this.variable !== null) { - this.scope.context.includeVariableInModule(this.variable); - } - } - } - - includeCallArguments( - context: InclusionContext, - parameters: readonly (ExpressionEntity | SpreadElement)[] - ): void { - this.variable!.includeCallArguments(context, parameters); - } - - isPossibleTDZ(): boolean { - // return cached value to avoid issues with the next tree-shaking pass - const cachedTdzAccess = this.isTDZAccess; - if (cachedTdzAccess !== null) return cachedTdzAccess; - - if ( - !( - this.variable instanceof LocalVariable && - this.variable.kind && - tdzVariableKinds.has(this.variable.kind) && - // We ignore modules that did not receive a treeshaking pass yet as that - // causes many false positives due to circular dependencies or disabled - // moduleSideEffects. - this.variable.module.hasTreeShakingPassStarted - ) - ) { - return (this.isTDZAccess = false); - } - - let decl_id; - if ( - this.variable.declarations && - this.variable.declarations.length === 1 && - (decl_id = this.variable.declarations[0] as any) && - this.start < decl_id.start && - closestParentFunctionOrProgram(this) === closestParentFunctionOrProgram(decl_id) - ) { - // a variable accessed before its declaration - // in the same function or at top level of module - return (this.isTDZAccess = true); - } - - if (!this.variable.initReached) { - // Either a const/let TDZ violation or - // var use before declaration was encountered. - return (this.isTDZAccess = true); - } - - return (this.isTDZAccess = false); - } - markDeclarationReached(): void { this.variable!.initReached = true; } @@ -283,59 +104,4 @@ export default class Identifier extends NodeBase implements PatternNode { } } } - - private disallowImportReassignment(): never { - return this.scope.context.error( - logIllegalImportReassignment(this.name, this.scope.context.module.id), - this.start - ); - } - - protected applyDeoptimizations(): void { - this.deoptimized = true; - if (this.variable instanceof LocalVariable) { - // When accessing a variable from a module without side effects, this - // means we use an export of that module and therefore need to potentially - // include it in the bundle. - if (!this.variable.module.isExecuted) { - markModuleAndImpureDependenciesAsExecuted(this.variable.module); - } - this.variable.consolidateInitializers(); - this.scope.context.requestTreeshakingPass(); - } - if (this.isReferenceVariable) { - this.variable!.addUsedPlace(this); - this.scope.context.requestTreeshakingPass(); - } - } - - private getVariableRespectingTDZ(): ExpressionEntity | null { - if (this.isPossibleTDZ()) { - return UNKNOWN_EXPRESSION; - } - return this.variable; - } - - private isPureFunction(path: ObjectPath) { - let currentPureFunction = this.scope.context.manualPureFunctions[this.name]; - for (const segment of path) { - if (currentPureFunction) { - if (currentPureFunction[PureFunctionKey]) { - return true; - } - currentPureFunction = currentPureFunction[segment as string]; - } else { - return false; - } - } - return currentPureFunction?.[PureFunctionKey] as boolean; - } -} - -function closestParentFunctionOrProgram(node: any): any { - while (node && !/^Program|Function/.test(node.type)) { - node = node.parent; - } - // one of: ArrowFunctionExpression, FunctionDeclaration, FunctionExpression or Program - return node; } diff --git a/src/ast/nodes/JSXAttribute.ts b/src/ast/nodes/JSXAttribute.ts new file mode 100644 index 000000000..b16287d9d --- /dev/null +++ b/src/ast/nodes/JSXAttribute.ts @@ -0,0 +1,38 @@ +import type MagicString from 'magic-string'; +import { BLANK } from '../../utils/blank'; +import { stringifyObjectKeyIfNeeded } from '../../utils/identifierHelpers'; +import type { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; +import type JSXElement from './JSXElement'; +import type JSXExpressionContainer from './JSXExpressionContainer'; +import type JSXFragment from './JSXFragment'; +import JSXIdentifier from './JSXIdentifier'; +import type JSXNamespacedName from './JSXNamespacedName'; +import type Literal from './Literal'; +import type * as NodeType from './NodeType'; +import { NodeBase } from './shared/Node'; + +export default class JSXAttribute extends NodeBase { + type!: NodeType.tJSXAttribute; + name!: JSXIdentifier | JSXNamespacedName; + value!: Literal | JSXExpressionContainer | JSXElement | JSXFragment | null; + + render(code: MagicString, options: RenderOptions, { jsxMode }: NodeRenderOptions = BLANK): void { + super.render(code, options); + if ((['classic', 'automatic'] as (string | undefined)[]).includes(jsxMode)) { + const { name, value } = this; + const key = + name instanceof JSXIdentifier ? name.name : `${name.namespace.name}:${name.name.name}`; + if (!(jsxMode === 'automatic' && key === 'key')) { + const safeKey = stringifyObjectKeyIfNeeded(key); + if (key !== safeKey) { + code.overwrite(name.start, name.end, safeKey, { contentOnly: true }); + } + if (value) { + code.overwrite(name.end, value.start, ': ', { contentOnly: true }); + } else { + code.appendLeft(name.end, ': true'); + } + } + } + } +} diff --git a/src/ast/nodes/JSXClosingElement.ts b/src/ast/nodes/JSXClosingElement.ts new file mode 100644 index 000000000..8fdd45009 --- /dev/null +++ b/src/ast/nodes/JSXClosingElement.ts @@ -0,0 +1,10 @@ +import type JSXIdentifier from './JSXIdentifier'; +import type JSXMemberExpression from './JSXMemberExpression'; +import type JSXNamespacedName from './JSXNamespacedName'; +import type * as NodeType from './NodeType'; +import JSXClosingBase from './shared/JSXClosingBase'; + +export default class JSXClosingElement extends JSXClosingBase { + type!: NodeType.tJSXClosingElement; + name!: JSXIdentifier | JSXMemberExpression | JSXNamespacedName; +} diff --git a/src/ast/nodes/JSXClosingFragment.ts b/src/ast/nodes/JSXClosingFragment.ts new file mode 100644 index 000000000..a562f09de --- /dev/null +++ b/src/ast/nodes/JSXClosingFragment.ts @@ -0,0 +1,6 @@ +import type * as NodeType from './NodeType'; +import JSXClosingBase from './shared/JSXClosingBase'; + +export default class JSXClosingFragment extends JSXClosingBase { + type!: NodeType.tJSXClosingFragment; +} diff --git a/src/ast/nodes/JSXElement.ts b/src/ast/nodes/JSXElement.ts new file mode 100644 index 000000000..cd5ab4f44 --- /dev/null +++ b/src/ast/nodes/JSXElement.ts @@ -0,0 +1,249 @@ +import type MagicString from 'magic-string'; +import type { NormalizedJsxOptions } from '../../rollup/types'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import JSXAttribute from './JSXAttribute'; +import type JSXClosingElement from './JSXClosingElement'; +import type JSXOpeningElement from './JSXOpeningElement'; +import JSXSpreadAttribute from './JSXSpreadAttribute'; +import type * as NodeType from './NodeType'; +import JSXElementBase from './shared/JSXElementBase'; +import type { JSXChild, JsxMode } from './shared/jsxHelpers'; + +export default class JSXElement extends JSXElementBase { + type!: NodeType.tJSXElement; + openingElement!: JSXOpeningElement; + closingElement!: JSXClosingElement | null; + children!: JSXChild[]; + + render(code: MagicString, options: RenderOptions): void { + switch (this.jsxMode.mode) { + case 'classic': { + this.renderClassicMode(code, options); + break; + } + case 'automatic': { + this.renderAutomaticMode(code, options); + break; + } + default: { + super.render(code, options); + } + } + } + + protected getRenderingMode(): JsxMode { + const jsx = this.scope.context.options.jsx as NormalizedJsxOptions; + const { mode, factory, importSource } = jsx; + if (mode === 'automatic') { + // In the case there is a key after a spread attribute, we fall back to + // classic mode, see https://github.com/facebook/react/issues/20031#issuecomment-710346866 + // for reasoning. + let hasSpread = false; + for (const attribute of this.openingElement.attributes) { + if (attribute instanceof JSXSpreadAttribute) { + hasSpread = true; + } else if (hasSpread && attribute.name.name === 'key') { + return { factory, importSource, mode: 'classic' }; + } + } + } + return super.getRenderingMode(); + } + + private renderClassicMode(code: MagicString, options: RenderOptions) { + const { + snippets: { getPropertyAccess }, + useOriginalName + } = options; + const { + closingElement, + end, + factory, + factoryVariable, + openingElement: { end: openingEnd, selfClosing } + } = this; + const [, ...nestedName] = factory!.split('.'); + const { firstAttribute, hasAttributes, hasSpread, inObject, previousEnd } = + this.renderAttributes( + code, + options, + [factoryVariable!.getName(getPropertyAccess, useOriginalName), ...nestedName].join('.'), + false + ); + + this.wrapAttributes( + code, + inObject, + hasAttributes, + hasSpread, + firstAttribute, + 'null', + previousEnd + ); + + this.renderChildren(code, options, openingEnd); + + if (selfClosing) { + code.appendLeft(end, ')'); + } else { + closingElement!.render(code, options); + } + } + + private renderAutomaticMode(code: MagicString, options: RenderOptions) { + const { + snippets: { getPropertyAccess }, + useOriginalName + } = options; + const { + closingElement, + end, + factoryVariable, + openingElement: { end: openindEnd, selfClosing } + } = this; + let { firstAttribute, hasAttributes, hasSpread, inObject, keyAttribute, previousEnd } = + this.renderAttributes( + code, + options, + factoryVariable!.getName(getPropertyAccess, useOriginalName), + true + ); + + const { firstChild, hasMultipleChildren, childrenEnd } = this.renderChildren( + code, + options, + openindEnd + ); + + if (firstChild) { + code.prependRight(firstChild.start, `children: ${hasMultipleChildren ? '[' : ''}`); + if (!inObject) { + code.prependRight(firstChild.start, '{ '); + inObject = true; + } + previousEnd = closingElement!.start; + if (hasMultipleChildren) { + code.appendLeft(previousEnd, ']'); + } + } + + this.wrapAttributes( + code, + inObject, + hasAttributes || !!firstChild, + hasSpread, + firstAttribute || firstChild, + '{}', + childrenEnd + ); + + if (keyAttribute) { + const { value } = keyAttribute; + // This will appear to the left of the moved code... + code.appendLeft(childrenEnd, ', '); + if (value) { + code.move(value.start, value.end, childrenEnd); + } else { + code.appendLeft(childrenEnd, 'true'); + } + } + + if (selfClosing) { + // Moving the key attribute will also move the parenthesis to the right position + code.appendLeft(keyAttribute?.value?.end || end, ')'); + } else { + closingElement!.render(code, options); + } + } + + private renderAttributes( + code: MagicString, + options: RenderOptions, + factoryName: string, + extractKeyAttribute: boolean + ): { + firstAttribute: JSXAttribute | JSXSpreadAttribute | JSXChild | null; + hasAttributes: boolean; + hasSpread: boolean; + inObject: boolean; + keyAttribute: JSXAttribute | null; + previousEnd: number; + } { + const { + jsxMode: { mode }, + openingElement + } = this; + const { + attributes, + end: openingEnd, + start: openingStart, + name: { start: nameStart, end: nameEnd } + } = openingElement; + code.update(openingStart, nameStart, `/*#__PURE__*/${factoryName}(`); + openingElement.render(code, options, { jsxMode: mode }); + let keyAttribute: JSXAttribute | null = null; + let hasSpread = false; + let inObject = false; + let previousEnd = nameEnd; + let hasAttributes = false; + let firstAttribute: JSXAttribute | JSXSpreadAttribute | null = null; + for (const attribute of attributes) { + if (attribute instanceof JSXAttribute) { + if (extractKeyAttribute && attribute.name.name === 'key') { + keyAttribute = attribute; + code.remove(previousEnd, attribute.value?.start || attribute.end); + continue; + } + code.appendLeft(previousEnd, ','); + if (!inObject) { + code.prependRight(attribute.start, '{ '); + inObject = true; + } + hasAttributes = true; + } else { + if (inObject) { + if (hasAttributes) { + code.appendLeft(previousEnd, ' '); + } + code.appendLeft(previousEnd, '},'); + inObject = false; + } else { + code.appendLeft(previousEnd, ','); + } + hasSpread = true; + } + previousEnd = attribute.end; + if (!firstAttribute) { + firstAttribute = attribute; + } + } + code.remove(attributes.at(-1)?.end || previousEnd, openingEnd); + return { firstAttribute, hasAttributes, hasSpread, inObject, keyAttribute, previousEnd }; + } + + private wrapAttributes( + code: MagicString, + inObject: boolean, + hasAttributes: boolean, + hasSpread: boolean, + firstAttribute: JSXAttribute | JSXSpreadAttribute | JSXChild | null, + missingAttributesFallback: string, + attributesEnd: number + ) { + if (inObject) { + code.appendLeft(attributesEnd, ' }'); + } + if (hasSpread) { + if (hasAttributes) { + const { start } = firstAttribute!; + if (firstAttribute instanceof JSXSpreadAttribute) { + code.prependRight(start, '{}, '); + } + code.prependRight(start, 'Object.assign('); + code.appendLeft(attributesEnd, ')'); + } + } else if (!hasAttributes) { + code.appendLeft(attributesEnd, `, ${missingAttributesFallback}`); + } + } +} diff --git a/src/ast/nodes/JSXEmptyExpression.ts b/src/ast/nodes/JSXEmptyExpression.ts new file mode 100644 index 000000000..87d3b29a1 --- /dev/null +++ b/src/ast/nodes/JSXEmptyExpression.ts @@ -0,0 +1,6 @@ +import type * as NodeType from './NodeType'; +import { NodeBase } from './shared/Node'; + +export default class JSXEmptyExpression extends NodeBase { + type!: NodeType.tJSXEmptyExpression; +} diff --git a/src/ast/nodes/JSXExpressionContainer.ts b/src/ast/nodes/JSXExpressionContainer.ts new file mode 100644 index 000000000..d4b001629 --- /dev/null +++ b/src/ast/nodes/JSXExpressionContainer.ts @@ -0,0 +1,21 @@ +import type MagicString from 'magic-string'; +import type { NormalizedJsxOptions } from '../../rollup/types'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import type JSXEmptyExpression from './JSXEmptyExpression'; +import type * as NodeType from './NodeType'; +import type { ExpressionNode } from './shared/Node'; +import { NodeBase } from './shared/Node'; + +export default class JSXExpressionContainer extends NodeBase { + type!: NodeType.tJSXExpressionContainer; + expression!: ExpressionNode | JSXEmptyExpression; + + render(code: MagicString, options: RenderOptions): void { + const { mode } = this.scope.context.options.jsx as NormalizedJsxOptions; + if (mode !== 'preserve') { + code.remove(this.start, this.expression.start); + code.remove(this.expression.end, this.end); + } + this.expression.render(code, options); + } +} diff --git a/src/ast/nodes/JSXFragment.ts b/src/ast/nodes/JSXFragment.ts new file mode 100644 index 000000000..a239459c8 --- /dev/null +++ b/src/ast/nodes/JSXFragment.ts @@ -0,0 +1,83 @@ +import type MagicString from 'magic-string'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import type JSXClosingFragment from './JSXClosingFragment'; +import type JSXOpeningFragment from './JSXOpeningFragment'; +import type * as NodeType from './NodeType'; +import JSXElementBase from './shared/JSXElementBase'; +import type { JSXChild } from './shared/jsxHelpers'; + +export default class JSXFragment extends JSXElementBase { + type!: NodeType.tJSXElement; + openingFragment!: JSXOpeningFragment; + children!: JSXChild[]; + closingFragment!: JSXClosingFragment; + + render(code: MagicString, options: RenderOptions): void { + switch (this.jsxMode.mode) { + case 'classic': { + this.renderClassicMode(code, options); + break; + } + case 'automatic': { + this.renderAutomaticMode(code, options); + break; + } + default: { + super.render(code, options); + } + } + } + + private renderClassicMode(code: MagicString, options: RenderOptions) { + const { + snippets: { getPropertyAccess }, + useOriginalName + } = options; + const { closingFragment, factory, factoryVariable, openingFragment, start } = this; + const [, ...nestedName] = factory!.split('.'); + openingFragment.render(code, options); + code.prependRight( + start, + `/*#__PURE__*/${[ + factoryVariable!.getName(getPropertyAccess, useOriginalName), + ...nestedName + ].join('.')}(` + ); + code.appendLeft(openingFragment.end, ', null'); + + this.renderChildren(code, options, openingFragment.end); + + closingFragment.render(code, options); + } + + private renderAutomaticMode(code: MagicString, options: RenderOptions) { + const { + snippets: { getPropertyAccess }, + useOriginalName + } = options; + const { closingFragment, factoryVariable, openingFragment, start } = this; + openingFragment.render(code, options); + code.prependRight( + start, + `/*#__PURE__*/${factoryVariable!.getName(getPropertyAccess, useOriginalName)}(` + ); + + const { firstChild, hasMultipleChildren, childrenEnd } = this.renderChildren( + code, + options, + openingFragment.end + ); + + if (firstChild) { + code.prependRight(firstChild.start, `{ children: ${hasMultipleChildren ? '[' : ''}`); + if (hasMultipleChildren) { + code.appendLeft(closingFragment.start, ']'); + } + code.appendLeft(childrenEnd, ' }'); + } else { + code.appendLeft(openingFragment.end, ', {}'); + } + + closingFragment.render(code, options); + } +} diff --git a/src/ast/nodes/JSXIdentifier.ts b/src/ast/nodes/JSXIdentifier.ts new file mode 100644 index 000000000..f75763283 --- /dev/null +++ b/src/ast/nodes/JSXIdentifier.ts @@ -0,0 +1,74 @@ +import type MagicString from 'magic-string'; +import type { NormalizedJsxOptions } from '../../rollup/types'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import type JSXMemberExpression from './JSXMemberExpression'; +import type * as NodeType from './NodeType'; +import IdentifierBase from './shared/IdentifierBase'; + +const enum IdentifierType { + Reference, + NativeElementName, + Other +} + +export default class JSXIdentifier extends IdentifierBase { + type!: NodeType.tJSXIdentifier; + name!: string; + + private isNativeElement = false; + + bind(): void { + const type = this.getType(); + if (type === IdentifierType.Reference) { + this.variable = this.scope.findVariable(this.name); + this.variable.addReference(this); + } else if (type === IdentifierType.NativeElementName) { + this.isNativeElement = true; + } + } + + render( + code: MagicString, + { snippets: { getPropertyAccess }, useOriginalName }: RenderOptions + ): void { + if (this.variable) { + const name = this.variable.getName(getPropertyAccess, useOriginalName); + + if (name !== this.name) { + code.overwrite(this.start, this.end, name, { + contentOnly: true, + storeName: true + }); + } + } else if ( + this.isNativeElement && + (this.scope.context.options.jsx as NormalizedJsxOptions).mode !== 'preserve' + ) { + code.update(this.start, this.end, JSON.stringify(this.name)); + } + } + + private getType(): IdentifierType { + switch (this.parent.type) { + case 'JSXOpeningElement': + case 'JSXClosingElement': { + return this.name.startsWith(this.name.charAt(0).toUpperCase()) + ? IdentifierType.Reference + : IdentifierType.NativeElementName; + } + case 'JSXMemberExpression': { + return (this.parent as JSXMemberExpression).object === this + ? IdentifierType.Reference + : IdentifierType.Other; + } + case 'JSXAttribute': + case 'JSXNamespacedName': { + return IdentifierType.Other; + } + default: { + /* istanbul ignore next */ + throw new Error(`Unexpected parent node type for JSXIdentifier: ${this.parent.type}`); + } + } + } +} diff --git a/src/ast/nodes/JSXMemberExpression.ts b/src/ast/nodes/JSXMemberExpression.ts new file mode 100644 index 000000000..1212066f3 --- /dev/null +++ b/src/ast/nodes/JSXMemberExpression.ts @@ -0,0 +1,9 @@ +import type JSXIdentifier from './JSXIdentifier'; +import type * as NodeType from './NodeType'; +import { NodeBase } from './shared/Node'; + +export default class JSXMemberExpression extends NodeBase { + type!: NodeType.tJSXMemberExpression; + object!: JSXMemberExpression | JSXIdentifier; + property!: JSXIdentifier; +} diff --git a/src/ast/nodes/JSXNamespacedName.ts b/src/ast/nodes/JSXNamespacedName.ts new file mode 100644 index 000000000..5172b2a47 --- /dev/null +++ b/src/ast/nodes/JSXNamespacedName.ts @@ -0,0 +1,9 @@ +import type JSXIdentifier from './JSXIdentifier'; +import type * as NodeType from './NodeType'; +import { NodeBase } from './shared/Node'; + +export default class JSXNamespacedName extends NodeBase { + type!: NodeType.tJSXNamespacedName; + name!: JSXIdentifier; + namespace!: JSXIdentifier; +} diff --git a/src/ast/nodes/JSXOpeningElement.ts b/src/ast/nodes/JSXOpeningElement.ts new file mode 100644 index 000000000..a7a57f06a --- /dev/null +++ b/src/ast/nodes/JSXOpeningElement.ts @@ -0,0 +1,30 @@ +import type MagicString from 'magic-string'; +import type { NormalizedJsxOptions } from '../../rollup/types'; +import type { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers'; +import type JSXAttribute from './JSXAttribute'; +import type JSXIdentifier from './JSXIdentifier'; +import type JSXMemberExpression from './JSXMemberExpression'; +import type JSXNamespacedName from './JSXNamespacedName'; +import type JSXSpreadAttribute from './JSXSpreadAttribute'; +import type * as NodeType from './NodeType'; +import { NodeBase } from './shared/Node'; + +export default class JSXOpeningElement extends NodeBase { + type!: NodeType.tJSXOpeningElement; + name!: JSXIdentifier | JSXMemberExpression | JSXNamespacedName; + attributes!: (JSXAttribute | JSXSpreadAttribute)[]; + selfClosing!: boolean; + + render( + code: MagicString, + options: RenderOptions, + { + jsxMode = (this.scope.context.options.jsx as NormalizedJsxOptions).mode + }: NodeRenderOptions = {} + ): void { + this.name.render(code, options); + for (const attribute of this.attributes) { + attribute.render(code, options, { jsxMode }); + } + } +} diff --git a/src/ast/nodes/JSXOpeningFragment.ts b/src/ast/nodes/JSXOpeningFragment.ts new file mode 100644 index 000000000..6d50740c1 --- /dev/null +++ b/src/ast/nodes/JSXOpeningFragment.ts @@ -0,0 +1,60 @@ +import type MagicString from 'magic-string'; +import type { NormalizedJsxOptions } from '../../rollup/types'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import type { InclusionContext } from '../ExecutionContext'; +import type Variable from '../variables/Variable'; +import type * as NodeType from './NodeType'; +import { getAndIncludeFactoryVariable } from './shared/jsxHelpers'; +import { type IncludeChildren, NodeBase } from './shared/Node'; + +export default class JSXOpeningFragment extends NodeBase { + type!: NodeType.tJSXOpeningElement; + attributes!: never[]; + selfClosing!: false; + + private fragment: string | null = null; + private fragmentVariable: Variable | null = null; + + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + if (!this.included) { + const jsx = this.scope.context.options.jsx as NormalizedJsxOptions; + if (jsx.mode === 'automatic') { + this.fragment = 'Fragment'; + this.fragmentVariable = getAndIncludeFactoryVariable( + 'Fragment', + false, + jsx.jsxImportSource, + this + ); + } else { + const { fragment, importSource, mode } = jsx; + if (fragment != null) { + this.fragment = fragment; + this.fragmentVariable = getAndIncludeFactoryVariable( + fragment, + mode === 'preserve', + importSource, + this + ); + } + } + } + super.include(context, includeChildrenRecursively); + } + + render(code: MagicString, options: RenderOptions): void { + const { mode } = this.scope.context.options.jsx as NormalizedJsxOptions; + if (mode !== 'preserve') { + const { + snippets: { getPropertyAccess }, + useOriginalName + } = options; + const [, ...nestedFragment] = this.fragment!.split('.'); + const fragment = [ + this.fragmentVariable!.getName(getPropertyAccess, useOriginalName), + ...nestedFragment + ].join('.'); + code.update(this.start, this.end, fragment); + } + } +} diff --git a/src/ast/nodes/JSXSpreadAttribute.ts b/src/ast/nodes/JSXSpreadAttribute.ts new file mode 100644 index 000000000..96f846a6c --- /dev/null +++ b/src/ast/nodes/JSXSpreadAttribute.ts @@ -0,0 +1,20 @@ +import type MagicString from 'magic-string'; +import type { NormalizedJsxOptions } from '../../rollup/types'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import type * as NodeType from './NodeType'; +import type { ExpressionNode } from './shared/Node'; +import { NodeBase } from './shared/Node'; + +export default class JSXSpreadAttribute extends NodeBase { + type!: NodeType.tJSXSpreadAttribute; + argument!: ExpressionNode; + + render(code: MagicString, options: RenderOptions): void { + this.argument.render(code, options); + const { mode } = this.scope.context.options.jsx as NormalizedJsxOptions; + if (mode !== 'preserve') { + code.overwrite(this.start, this.argument.start, '', { contentOnly: true }); + code.overwrite(this.argument.end, this.end, '', { contentOnly: true }); + } + } +} diff --git a/src/ast/nodes/JSXSpreadChild.ts b/src/ast/nodes/JSXSpreadChild.ts new file mode 100644 index 000000000..f831e5826 --- /dev/null +++ b/src/ast/nodes/JSXSpreadChild.ts @@ -0,0 +1,20 @@ +import type MagicString from 'magic-string'; +import type { NormalizedJsxOptions } from '../../rollup/types'; +import type { RenderOptions } from '../../utils/renderHelpers'; +import type * as NodeType from './NodeType'; +import type { ExpressionNode } from './shared/Node'; +import { NodeBase } from './shared/Node'; + +export default class JSXSpreadChild extends NodeBase { + type!: NodeType.tJSXSpreadChild; + expression!: ExpressionNode; + + render(code: MagicString, options: RenderOptions): void { + super.render(code, options); + const { mode } = this.scope.context.options.jsx as NormalizedJsxOptions; + if (mode !== 'preserve') { + code.overwrite(this.start, this.expression.start, '...', { contentOnly: true }); + code.overwrite(this.expression.end, this.end, '', { contentOnly: true }); + } + } +} diff --git a/src/ast/nodes/JSXText.ts b/src/ast/nodes/JSXText.ts new file mode 100644 index 000000000..59e905cda --- /dev/null +++ b/src/ast/nodes/JSXText.ts @@ -0,0 +1,19 @@ +import type MagicString from 'magic-string'; +import type { NormalizedJsxOptions } from '../../rollup/types'; +import type * as NodeType from './NodeType'; +import { NodeBase } from './shared/Node'; + +export default class JSXText extends NodeBase { + type!: NodeType.tJSXText; + value!: string; + raw!: string; + + render(code: MagicString) { + const { mode } = this.scope.context.options.jsx as NormalizedJsxOptions; + if (mode !== 'preserve') { + code.overwrite(this.start, this.end, JSON.stringify(this.value), { + contentOnly: true + }); + } + } +} diff --git a/src/ast/nodes/NodeType.ts b/src/ast/nodes/NodeType.ts index f3dfbb7d7..65ef0e1a1 100644 --- a/src/ast/nodes/NodeType.ts +++ b/src/ast/nodes/NodeType.ts @@ -40,6 +40,21 @@ export type tImportDefaultSpecifier = 'ImportDefaultSpecifier'; export type tImportExpression = 'ImportExpression'; export type tImportNamespaceSpecifier = 'ImportNamespaceSpecifier'; export type tImportSpecifier = 'ImportSpecifier'; +export type tJSXAttribute = 'JSXAttribute'; +export type tJSXClosingElement = 'JSXClosingElement'; +export type tJSXClosingFragment = 'JSXClosingFragment'; +export type tJSXElement = 'JSXElement'; +export type tJSXEmptyExpression = 'JSXEmptyExpression'; +export type tJSXExpressionContainer = 'JSXExpressionContainer'; +export type tJSXFragment = 'JSXFragment'; +export type tJSXIdentifier = 'JSXIdentifier'; +export type tJSXMemberExpression = 'JSXMemberExpression'; +export type tJSXNamespacedName = 'JSXNamespacedName'; +export type tJSXOpeningElement = 'JSXOpeningElement'; +export type tJSXOpeningFragment = 'JSXOpeningFragment'; +export type tJSXSpreadAttribute = 'JSXSpreadAttribute'; +export type tJSXSpreadChild = 'JSXSpreadChild'; +export type tJSXText = 'JSXText'; export type tLabeledStatement = 'LabeledStatement'; export type tLiteral = 'Literal'; export type tLogicalExpression = 'LogicalExpression'; @@ -115,6 +130,21 @@ export const ImportDefaultSpecifier: tImportDefaultSpecifier = 'ImportDefaultSpe export const ImportExpression: tImportExpression = 'ImportExpression'; export const ImportNamespaceSpecifier: tImportNamespaceSpecifier = 'ImportNamespaceSpecifier'; export const ImportSpecifier: tImportSpecifier = 'ImportSpecifier'; +export const JSXAttribute: tJSXAttribute = 'JSXAttribute'; +export const JSXClosingElement: tJSXClosingElement = 'JSXClosingElement'; +export const JSXClosingFragment: tJSXClosingFragment = 'JSXClosingFragment'; +export const JSXElement: tJSXElement = 'JSXElement'; +export const JSXEmptyExpression: tJSXEmptyExpression = 'JSXEmptyExpression'; +export const JSXExpressionContainer: tJSXExpressionContainer = 'JSXExpressionContainer'; +export const JSXFragment: tJSXFragment = 'JSXFragment'; +export const JSXIdentifier: tJSXIdentifier = 'JSXIdentifier'; +export const JSXMemberExpression: tJSXMemberExpression = 'JSXMemberExpression'; +export const JSXNamespacedName: tJSXNamespacedName = 'JSXNamespacedName'; +export const JSXOpeningElement: tJSXOpeningElement = 'JSXOpeningElement'; +export const JSXOpeningFragment: tJSXOpeningFragment = 'JSXOpeningFragment'; +export const JSXSpreadAttribute: tJSXSpreadAttribute = 'JSXSpreadAttribute'; +export const JSXSpreadChild: tJSXSpreadChild = 'JSXSpreadChild'; +export const JSXText: tJSXText = 'JSXText'; export const LabeledStatement: tLabeledStatement = 'LabeledStatement'; export const Literal: tLiteral = 'Literal'; export const LogicalExpression: tLogicalExpression = 'LogicalExpression'; diff --git a/src/ast/nodes/index.ts b/src/ast/nodes/index.ts index 56ef603ba..2ef83573c 100644 --- a/src/ast/nodes/index.ts +++ b/src/ast/nodes/index.ts @@ -40,6 +40,21 @@ import ImportDefaultSpecifier from './ImportDefaultSpecifier'; import ImportExpression from './ImportExpression'; import ImportNamespaceSpecifier from './ImportNamespaceSpecifier'; import ImportSpecifier from './ImportSpecifier'; +import JSXAttribute from './JSXAttribute'; +import JSXClosingElement from './JSXClosingElement'; +import JSXClosingFragment from './JSXClosingFragment'; +import JSXElement from './JSXElement'; +import JSXEmptyExpression from './JSXEmptyExpression'; +import JSXExpressionContainer from './JSXExpressionContainer'; +import JSXFragment from './JSXFragment'; +import JSXIdentifier from './JSXIdentifier'; +import JSXMemberExpression from './JSXMemberExpression'; +import JSXNamespacedName from './JSXNamespacedName'; +import JSXOpeningElement from './JSXOpeningElement'; +import JSXOpeningFragment from './JSXOpeningFragment'; +import JSXSpreadAttribute from './JSXSpreadAttribute'; +import JSXSpreadChild from './JSXSpreadChild'; +import JSXText from './JSXText'; import LabeledStatement from './LabeledStatement'; import Literal from './Literal'; import LogicalExpression from './LogicalExpression'; @@ -118,6 +133,21 @@ export const nodeConstructors: Record = { ImportExpression, ImportNamespaceSpecifier, ImportSpecifier, + JSXAttribute, + JSXClosingElement, + JSXClosingFragment, + JSXElement, + JSXEmptyExpression, + JSXExpressionContainer, + JSXFragment, + JSXIdentifier, + JSXMemberExpression, + JSXNamespacedName, + JSXOpeningElement, + JSXOpeningFragment, + JSXSpreadAttribute, + JSXSpreadChild, + JSXText, LabeledStatement, Literal, LogicalExpression, diff --git a/src/ast/nodes/shared/IdentifierBase.ts b/src/ast/nodes/shared/IdentifierBase.ts new file mode 100644 index 000000000..684d7f2de --- /dev/null +++ b/src/ast/nodes/shared/IdentifierBase.ts @@ -0,0 +1,243 @@ +import type { NormalizedTreeshakingOptions } from '../../../rollup/types'; +import { logIllegalImportReassignment } from '../../../utils/logs'; +import { PureFunctionKey } from '../../../utils/pureFunctions'; +import { markModuleAndImpureDependenciesAsExecuted } from '../../../utils/traverseStaticDependencies'; +import type { DeoptimizableEntity } from '../../DeoptimizableEntity'; +import type { HasEffectsContext, InclusionContext } from '../../ExecutionContext'; +import type { NodeInteraction, NodeInteractionCalled } from '../../NodeInteractions'; +import { + INTERACTION_ACCESSED, + INTERACTION_ASSIGNED, + INTERACTION_CALLED, + NODE_INTERACTION_UNKNOWN_ACCESS +} from '../../NodeInteractions'; +import type { ObjectPath, PathTracker } from '../../utils/PathTracker'; +import { EMPTY_PATH } from '../../utils/PathTracker'; +import GlobalVariable from '../../variables/GlobalVariable'; +import LocalVariable from '../../variables/LocalVariable'; +import type Variable from '../../variables/Variable'; +import type SpreadElement from '../SpreadElement'; +import { Flag, isFlagSet, setFlag } from './BitFlags'; +import type { ExpressionEntity, LiteralValueOrUnknown } from './Expression'; +import { UNKNOWN_EXPRESSION } from './Expression'; +import { NodeBase } from './Node'; + +const tdzVariableKinds = new Set(['class', 'const', 'let', 'var', 'using', 'await using']); + +export default class IdentifierBase extends NodeBase { + name!: string; + variable: Variable | null = null; + + protected isVariableReference = false; + + private get isTDZAccess(): boolean | null { + if (!isFlagSet(this.flags, Flag.tdzAccessDefined)) { + return null; + } + return isFlagSet(this.flags, Flag.tdzAccess); + } + + private set isTDZAccess(value: boolean) { + this.flags = setFlag(this.flags, Flag.tdzAccessDefined, true); + this.flags = setFlag(this.flags, Flag.tdzAccess, value); + } + + deoptimizeArgumentsOnInteractionAtPath( + interaction: NodeInteraction, + path: ObjectPath, + recursionTracker: PathTracker + ): void { + this.variable!.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker); + } + + deoptimizePath(path: ObjectPath): void { + if (path.length === 0 && !this.scope.contains(this.name)) { + this.disallowImportReassignment(); + } + // We keep conditional chaining because an unknown Node could have an + // Identifier as property that might be deoptimized by default + this.variable?.deoptimizePath(path); + } + + getLiteralValueAtPath( + path: ObjectPath, + recursionTracker: PathTracker, + origin: DeoptimizableEntity + ): LiteralValueOrUnknown { + return this.getVariableRespectingTDZ()!.getLiteralValueAtPath(path, recursionTracker, origin); + } + + getReturnExpressionWhenCalledAtPath( + path: ObjectPath, + interaction: NodeInteractionCalled, + recursionTracker: PathTracker, + origin: DeoptimizableEntity + ): [expression: ExpressionEntity, isPure: boolean] { + const [expression, isPure] = + this.getVariableRespectingTDZ()!.getReturnExpressionWhenCalledAtPath( + path, + interaction, + recursionTracker, + origin + ); + return [expression, isPure || this.isPureFunction(path)]; + } + + hasEffects(context: HasEffectsContext): boolean { + if (!this.deoptimized) this.applyDeoptimizations(); + if (this.isPossibleTDZ() && this.variable!.kind !== 'var') { + return true; + } + return ( + (this.scope.context.options.treeshake as NormalizedTreeshakingOptions) + .unknownGlobalSideEffects && + this.variable instanceof GlobalVariable && + !this.isPureFunction(EMPTY_PATH) && + this.variable.hasEffectsOnInteractionAtPath( + EMPTY_PATH, + NODE_INTERACTION_UNKNOWN_ACCESS, + context + ) + ); + } + + hasEffectsOnInteractionAtPath( + path: ObjectPath, + interaction: NodeInteraction, + context: HasEffectsContext + ): boolean { + switch (interaction.type) { + case INTERACTION_ACCESSED: { + return ( + this.variable !== null && + !this.isPureFunction(path) && + this.getVariableRespectingTDZ()!.hasEffectsOnInteractionAtPath(path, interaction, context) + ); + } + case INTERACTION_ASSIGNED: { + return ( + path.length > 0 ? this.getVariableRespectingTDZ() : this.variable + )!.hasEffectsOnInteractionAtPath(path, interaction, context); + } + case INTERACTION_CALLED: { + return ( + !this.isPureFunction(path) && + this.getVariableRespectingTDZ()!.hasEffectsOnInteractionAtPath(path, interaction, context) + ); + } + } + } + + include(): void { + if (!this.deoptimized) this.applyDeoptimizations(); + if (!this.included) { + this.included = true; + if (this.variable !== null) { + this.scope.context.includeVariableInModule(this.variable); + } + } + } + + includeCallArguments( + context: InclusionContext, + parameters: readonly (ExpressionEntity | SpreadElement)[] + ): void { + this.variable!.includeCallArguments(context, parameters); + } + + isPossibleTDZ(): boolean { + // return cached value to avoid issues with the next tree-shaking pass + const cachedTdzAccess = this.isTDZAccess; + if (cachedTdzAccess !== null) return cachedTdzAccess; + + if ( + !( + this.variable instanceof LocalVariable && + this.variable.kind && + tdzVariableKinds.has(this.variable.kind) && + // We ignore modules that did not receive a treeshaking pass yet as that + // causes many false positives due to circular dependencies or disabled + // moduleSideEffects. + this.variable.module.hasTreeShakingPassStarted + ) + ) { + return (this.isTDZAccess = false); + } + + let decl_id; + if ( + this.variable.declarations && + this.variable.declarations.length === 1 && + (decl_id = this.variable.declarations[0] as any) && + this.start < decl_id.start && + closestParentFunctionOrProgram(this) === closestParentFunctionOrProgram(decl_id) + ) { + // a variable accessed before its declaration + // in the same function or at top level of module + return (this.isTDZAccess = true); + } + + if (!this.variable.initReached) { + // Either a const/let TDZ violation or + // var use before declaration was encountered. + return (this.isTDZAccess = true); + } + + return (this.isTDZAccess = false); + } + + protected applyDeoptimizations(): void { + this.deoptimized = true; + if (this.variable instanceof LocalVariable) { + // When accessing a variable from a module without side effects, this + // means we use an export of that module and therefore need to potentially + // include it in the bundle. + if (!this.variable.module.isExecuted) { + markModuleAndImpureDependenciesAsExecuted(this.variable.module); + } + this.variable.consolidateInitializers(); + this.scope.context.requestTreeshakingPass(); + } + if (this.isVariableReference) { + this.variable!.addUsedPlace(this); + this.scope.context.requestTreeshakingPass(); + } + } + + private disallowImportReassignment(): never { + return this.scope.context.error( + logIllegalImportReassignment(this.name, this.scope.context.module.id), + this.start + ); + } + + private getVariableRespectingTDZ(): ExpressionEntity | null { + if (this.isPossibleTDZ()) { + return UNKNOWN_EXPRESSION; + } + return this.variable; + } + + private isPureFunction(path: ObjectPath) { + let currentPureFunction = this.scope.context.manualPureFunctions[this.name]; + for (const segment of path) { + if (currentPureFunction) { + if (currentPureFunction[PureFunctionKey]) { + return true; + } + currentPureFunction = currentPureFunction[segment as string]; + } else { + return false; + } + } + return currentPureFunction?.[PureFunctionKey] as boolean; + } +} + +function closestParentFunctionOrProgram(node: any): any { + while (node && !/^Program|Function/.test(node.type)) { + node = node.parent; + } + // one of: ArrowFunctionExpression, FunctionDeclaration, FunctionExpression or Program + return node; +} diff --git a/src/ast/nodes/shared/JSXClosingBase.ts b/src/ast/nodes/shared/JSXClosingBase.ts new file mode 100644 index 000000000..9cb69e19b --- /dev/null +++ b/src/ast/nodes/shared/JSXClosingBase.ts @@ -0,0 +1,15 @@ +import type MagicString from 'magic-string'; +import type { NormalizedJsxOptions } from '../../../rollup/types'; +import type { RenderOptions } from '../../../utils/renderHelpers'; +import { NodeBase } from './Node'; + +export default class JSXClosingBase extends NodeBase { + render(code: MagicString, options: RenderOptions): void { + const { mode } = this.scope.context.options.jsx as NormalizedJsxOptions; + if (mode !== 'preserve') { + code.overwrite(this.start, this.end, ')', { contentOnly: true }); + } else { + super.render(code, options); + } + } +} diff --git a/src/ast/nodes/shared/JSXElementBase.ts b/src/ast/nodes/shared/JSXElementBase.ts new file mode 100644 index 000000000..6f8b08e79 --- /dev/null +++ b/src/ast/nodes/shared/JSXElementBase.ts @@ -0,0 +1,84 @@ +import type MagicString from 'magic-string'; +import type { NormalizedJsxOptions } from '../../../rollup/types'; +import { getRenderedJsxChildren } from '../../../utils/jsx'; +import type { RenderOptions } from '../../../utils/renderHelpers'; +import type { InclusionContext } from '../../ExecutionContext'; +import type Variable from '../../variables/Variable'; +import JSXEmptyExpression from '../JSXEmptyExpression'; +import JSXExpressionContainer from '../JSXExpressionContainer'; +import type { JSXChild, JsxMode } from './jsxHelpers'; +import { getAndIncludeFactoryVariable } from './jsxHelpers'; +import type { IncludeChildren } from './Node'; +import { NodeBase } from './Node'; + +export default class JSXElementBase extends NodeBase { + children!: JSXChild[]; + + protected factoryVariable: Variable | null = null; + protected factory: string | null = null; + protected declare jsxMode: JsxMode; + + initialise() { + super.initialise(); + const { importSource } = (this.jsxMode = this.getRenderingMode()); + if (importSource) { + this.scope.context.addImportSource(importSource); + } + } + + include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) { + if (!this.included) { + const { factory, importSource, mode } = this.jsxMode; + if (factory) { + this.factory = factory; + this.factoryVariable = getAndIncludeFactoryVariable( + factory, + mode === 'preserve', + importSource, + this + ); + } + } + super.include(context, includeChildrenRecursively); + } + + protected applyDeoptimizations() {} + + protected getRenderingMode(): JsxMode { + const jsx = this.scope.context.options.jsx as NormalizedJsxOptions; + const { mode, factory, importSource } = jsx; + if (mode === 'automatic') { + return { + factory: getRenderedJsxChildren(this.children) > 1 ? 'jsxs' : 'jsx', + importSource: jsx.jsxImportSource, + mode + }; + } + return { factory, importSource, mode }; + } + + protected renderChildren(code: MagicString, options: RenderOptions, openingEnd: number) { + const { children } = this; + let hasMultipleChildren = false; + let childrenEnd = openingEnd; + let firstChild: JSXChild | null = null; + for (const child of children) { + if ( + child instanceof JSXExpressionContainer && + child.expression instanceof JSXEmptyExpression + ) { + code.remove(childrenEnd, child.end); + } else { + code.appendLeft(childrenEnd, ', '); + child.render(code, options); + if (firstChild) { + hasMultipleChildren = true; + } else { + firstChild = child; + } + } + childrenEnd = child.end; + } + return { childrenEnd, firstChild, hasMultipleChildren }; + } +} diff --git a/src/ast/nodes/shared/jsxHelpers.ts b/src/ast/nodes/shared/jsxHelpers.ts new file mode 100644 index 000000000..bdbdfe8ef --- /dev/null +++ b/src/ast/nodes/shared/jsxHelpers.ts @@ -0,0 +1,52 @@ +import LocalVariable from '../../variables/LocalVariable'; +import type Variable from '../../variables/Variable'; +import type JSXElement from '../JSXElement'; +import type JSXExpressionContainer from '../JSXExpressionContainer'; +import type JSXFragment from '../JSXFragment'; +import type JSXOpeningElement from '../JSXOpeningElement'; +import type JSXOpeningFragment from '../JSXOpeningFragment'; +import type JSXSpreadChild from '../JSXSpreadChild'; +import type JSXText from '../JSXText'; +import type JSXElementBase from './JSXElementBase'; + +export type JsxMode = + | { + mode: 'preserve' | 'classic'; + factory: string | null; + importSource: string | null; + } + | { mode: 'automatic'; factory: string; importSource: string }; +export type JSXChild = JSXText | JSXExpressionContainer | JSXElement | JSXFragment | JSXSpreadChild; + +export function getAndIncludeFactoryVariable( + factory: string, + preserve: boolean, + importSource: string | null, + node: JSXElementBase | JSXOpeningElement | JSXOpeningFragment +): Variable { + const [baseName, nestedName] = factory.split('.'); + let factoryVariable: Variable; + if (importSource) { + factoryVariable = node.scope.context.getImportedJsxFactoryVariable( + nestedName ? 'default' : baseName, + node.start, + importSource + ); + if (preserve) { + // This pretends we are accessing an included global variable of the same name + const globalVariable = node.scope.findGlobal(baseName); + globalVariable.include(); + // This excludes this variable from renaming + factoryVariable.globalName = baseName; + } + } else { + factoryVariable = node.scope.findGlobal(baseName); + } + node.scope.context.includeVariableInModule(factoryVariable); + if (factoryVariable instanceof LocalVariable) { + factoryVariable.consolidateInitializers(); + factoryVariable.addUsedPlace(node); + node.scope.context.requestTreeshakingPass(); + } + return factoryVariable; +} diff --git a/src/ast/scopes/ChildScope.ts b/src/ast/scopes/ChildScope.ts index d13f83af4..50d6afa27 100644 --- a/src/ast/scopes/ChildScope.ts +++ b/src/ast/scopes/ChildScope.ts @@ -106,6 +106,12 @@ export default class ChildScope extends Scope { return (this.parent as ChildScope).findLexicalBoundary(); } + findGlobal(name: string): Variable { + const variable = this.parent.findVariable(name); + this.accessedOutsideVariables.set(name, variable); + return variable; + } + findVariable(name: string): Variable { const knownVariable = this.variables.get(name) || this.accessedOutsideVariables.get(name); if (knownVariable) { diff --git a/src/ast/variables/ExportDefaultVariable.ts b/src/ast/variables/ExportDefaultVariable.ts index 70810936e..baed0873c 100644 --- a/src/ast/variables/ExportDefaultVariable.ts +++ b/src/ast/variables/ExportDefaultVariable.ts @@ -3,6 +3,7 @@ import ClassDeclaration from '../nodes/ClassDeclaration'; import type ExportDefaultDeclaration from '../nodes/ExportDefaultDeclaration'; import FunctionDeclaration from '../nodes/FunctionDeclaration'; import Identifier, { type IdentifierWithVariable } from '../nodes/Identifier'; +import type IdentifierBase from '../nodes/shared/IdentifierBase'; import type { NodeBase } from '../nodes/shared/Node'; import LocalVariable from './LocalVariable'; import UndefinedVariable from './UndefinedVariable'; @@ -32,7 +33,7 @@ export default class ExportDefaultVariable extends LocalVariable { } } - addReference(identifier: Identifier): void { + addReference(identifier: IdentifierBase): void { if (!this.hasId) { this.name = identifier.name; } diff --git a/src/ast/variables/ExternalVariable.ts b/src/ast/variables/ExternalVariable.ts index 529802a7c..0775fc036 100644 --- a/src/ast/variables/ExternalVariable.ts +++ b/src/ast/variables/ExternalVariable.ts @@ -1,7 +1,7 @@ import type ExternalModule from '../../ExternalModule'; import type { NodeInteraction } from '../NodeInteractions'; import { INTERACTION_ACCESSED } from '../NodeInteractions'; -import type Identifier from '../nodes/Identifier'; +import type IdentifierBase from '../nodes/shared/IdentifierBase'; import type { ObjectPath } from '../utils/PathTracker'; import Variable from './Variable'; @@ -16,7 +16,7 @@ export default class ExternalVariable extends Variable { this.isNamespace = name === '*'; } - addReference(identifier: Identifier): void { + addReference(identifier: IdentifierBase): void { this.referenced = true; if (this.name === 'default' || this.name === '*') { this.module.suggestName(identifier.name); diff --git a/src/ast/variables/NamespaceVariable.ts b/src/ast/variables/NamespaceVariable.ts index dc5efceea..6085c435b 100644 --- a/src/ast/variables/NamespaceVariable.ts +++ b/src/ast/variables/NamespaceVariable.ts @@ -6,9 +6,9 @@ import { getSystemExportStatement } from '../../utils/systemJsRendering'; import type { HasEffectsContext } from '../ExecutionContext'; import type { NodeInteraction } from '../NodeInteractions'; import { INTERACTION_ASSIGNED, INTERACTION_CALLED } from '../NodeInteractions'; -import type Identifier from '../nodes/Identifier'; import type { LiteralValueOrUnknown } from '../nodes/shared/Expression'; import { deoptimizeInteraction, UnknownValue } from '../nodes/shared/Expression'; +import type IdentifierBase from '../nodes/shared/IdentifierBase'; import type ChildScope from '../scopes/ChildScope'; import type { ObjectPath, PathTracker } from '../utils/PathTracker'; import { SymbolToStringTag } from '../utils/PathTracker'; @@ -22,7 +22,7 @@ export default class NamespaceVariable extends Variable { private memberVariables: Record | null = null; private mergedNamespaces: readonly Variable[] = []; private referencedEarly = false; - private references: Identifier[] = []; + private references: IdentifierBase[] = []; constructor(context: AstContext) { super(context.getModuleName()); @@ -30,7 +30,7 @@ export default class NamespaceVariable extends Variable { this.module = context.module; } - addReference(identifier: Identifier): void { + addReference(identifier: IdentifierBase): void { this.references.push(identifier); this.name = identifier.name; } diff --git a/src/ast/variables/Variable.ts b/src/ast/variables/Variable.ts index 0cd2e40dd..2b8a1924f 100644 --- a/src/ast/variables/Variable.ts +++ b/src/ast/variables/Variable.ts @@ -5,9 +5,9 @@ import type { HasEffectsContext } from '../ExecutionContext'; import type { NodeInteraction } from '../NodeInteractions'; import { INTERACTION_ACCESSED } from '../NodeInteractions'; import type CallExpression from '../nodes/CallExpression'; -import type Identifier from '../nodes/Identifier'; import * as NodeType from '../nodes/NodeType'; import { ExpressionEntity } from '../nodes/shared/Expression'; +import type IdentifierBase from '../nodes/shared/IdentifierBase'; import type { NodeBase } from '../nodes/shared/Node'; import type { VariableKind } from '../nodes/shared/VariableKinds'; import type { ObjectPath } from '../utils/PathTracker'; @@ -15,6 +15,7 @@ import type { ObjectPath } from '../utils/PathTracker'; export default class Variable extends ExpressionEntity { alwaysRendered = false; forbiddenNames: Set | null = null; + globalName: string | null = null; initReached = false; isId = false; // both NamespaceVariable and ExternalVariable can be namespaces @@ -39,7 +40,7 @@ export default class Variable extends ExpressionEntity { * Binds identifiers that reference this variable to this variable. * Necessary to be able to change variable names. */ - addReference(_identifier: Identifier): void {} + addReference(_identifier: IdentifierBase): void {} private onlyFunctionCallUsed = true; /** @@ -84,6 +85,9 @@ export default class Variable extends ExpressionEntity { getPropertyAccess: (name: string) => string, useOriginalName?: RenderOptions['useOriginalName'] ): string { + if (this.globalName) { + return this.globalName; + } if (useOriginalName?.(this)) { return this.name; } @@ -103,10 +107,10 @@ export default class Variable extends ExpressionEntity { } /** - * Marks this variable as being part of the bundle, which is usually the case when one of - * its identifiers becomes part of the bundle. Returns true if it has not been included - * previously. - * Once a variable is included, it should take care all its declarations are included. + * Marks this variable as being part of the bundle, which is usually the case + * when one of its identifiers becomes part of the bundle. Returns true if it + * has not been included previously. Once a variable is included, it should + * take care all its declarations are included. */ include(): void { this.included = true; diff --git a/src/rollup/types.d.ts b/src/rollup/types.d.ts index 20a0488dd..8dfbd7eb6 100644 --- a/src/rollup/types.d.ts +++ b/src/rollup/types.d.ts @@ -220,7 +220,7 @@ type LoggingFunctionWithPosition = ( export type ParseAst = ( input: string, - options?: { allowReturnOutsideFunction?: boolean } + options?: { allowReturnOutsideFunction?: boolean; jsx?: boolean } ) => ProgramNode; // declare AbortSignal here for environments without DOM lib or @types/node @@ -231,7 +231,7 @@ declare global { export type ParseAstAsync = ( input: string, - options?: { allowReturnOutsideFunction?: boolean; signal?: AbortSignal } + options?: { allowReturnOutsideFunction?: boolean; jsx?: boolean; signal?: AbortSignal } ) => Promise; export interface PluginContext extends MinimalPluginContext { @@ -523,6 +523,38 @@ export interface Plugin extends OutputPlugin, Partial { api?: A; } +export type JsxPreset = 'react' | 'react-jsx' | 'preserve' | 'preserve-react'; + +export type NormalizedJsxOptions = + | NormalizedJsxPreserveOptions + | NormalizedJsxClassicOptions + | NormalizedJsxAutomaticOptions; + +interface NormalizedJsxPreserveOptions { + factory: string | null; + fragment: string | null; + importSource: string | null; + mode: 'preserve'; +} + +interface NormalizedJsxClassicOptions { + factory: string; + fragment: string; + importSource: string | null; + mode: 'classic'; +} + +interface NormalizedJsxAutomaticOptions { + factory: string; + importSource: string | null; + jsxImportSource: string; + mode: 'automatic'; +} + +export type JsxOptions = Partial & { + preset?: JsxPreset; +}; + export type TreeshakingPreset = 'smallest' | 'safest' | 'recommended'; export interface NormalizedTreeshakingOptions { @@ -545,6 +577,7 @@ interface ManualChunkMeta { getModuleIds: () => IterableIterator; getModuleInfo: GetModuleInfo; } + export type GetManualChunk = (id: string, meta: ManualChunkMeta) => string | NullValue; export type ExternalOption = @@ -592,6 +625,7 @@ export interface InputOptions { experimentalLogSideEffects?: boolean; external?: ExternalOption; input?: InputOption; + jsx?: false | JsxPreset | JsxOptions; logLevel?: LogLevelOption; makeAbsoluteExternalsRelative?: boolean | 'ifRelativeSource'; maxParallelFileOps?: number; @@ -619,6 +653,7 @@ export interface NormalizedInputOptions { experimentalLogSideEffects: boolean; external: IsExternal; input: string[] | Record; + jsx: false | NormalizedJsxOptions; logLevel: LogLevelOption; makeAbsoluteExternalsRelative: boolean | 'ifRelativeSource'; maxParallelFileOps: number; diff --git a/src/utils/bufferToAst.ts b/src/utils/bufferToAst.ts index bf870cc1d..20523a842 100644 --- a/src/utils/bufferToAst.ts +++ b/src/utils/bufferToAst.ts @@ -450,6 +450,139 @@ const nodeConverters: ((position: number, buffer: AstBuffer) => any)[] = [ local }; }, + function jsxAttribute(position, buffer): JSXAttributeNode { + const valuePosition = buffer[position + 3]; + return { + type: 'JSXAttribute', + start: buffer[position], + end: buffer[position + 1], + name: convertNode(buffer[position + 2], buffer), + value: valuePosition === 0 ? null : convertNode(valuePosition, buffer) + }; + }, + function jsxClosingElement(position, buffer): JSXClosingElementNode { + return { + type: 'JSXClosingElement', + start: buffer[position], + end: buffer[position + 1], + name: convertNode(buffer[position + 2], buffer) + }; + }, + function jsxClosingFragment(position, buffer): JSXClosingFragmentNode { + return { + type: 'JSXClosingFragment', + start: buffer[position], + end: buffer[position + 1] + }; + }, + function jsxElement(position, buffer): JSXElementNode { + const closingElementPosition = buffer[position + 4]; + return { + type: 'JSXElement', + start: buffer[position], + end: buffer[position + 1], + openingElement: convertNode(buffer[position + 2], buffer), + children: convertNodeList(buffer[position + 3], buffer), + closingElement: + closingElementPosition === 0 ? null : convertNode(closingElementPosition, buffer) + }; + }, + function jsxEmptyExpression(position, buffer): JSXEmptyExpressionNode { + return { + type: 'JSXEmptyExpression', + start: buffer[position], + end: buffer[position + 1] + }; + }, + function jsxExpressionContainer(position, buffer): JSXExpressionContainerNode { + return { + type: 'JSXExpressionContainer', + start: buffer[position], + end: buffer[position + 1], + expression: convertNode(buffer[position + 2], buffer) + }; + }, + function jsxFragment(position, buffer): JSXFragmentNode { + return { + type: 'JSXFragment', + start: buffer[position], + end: buffer[position + 1], + openingFragment: convertNode(buffer[position + 2], buffer), + children: convertNodeList(buffer[position + 3], buffer), + closingFragment: convertNode(buffer[position + 4], buffer) + }; + }, + function jsxIdentifier(position, buffer): JSXIdentifierNode { + return { + type: 'JSXIdentifier', + start: buffer[position], + end: buffer[position + 1], + name: buffer.convertString(buffer[position + 2]) + }; + }, + function jsxMemberExpression(position, buffer): JSXMemberExpressionNode { + return { + type: 'JSXMemberExpression', + start: buffer[position], + end: buffer[position + 1], + object: convertNode(buffer[position + 2], buffer), + property: convertNode(buffer[position + 3], buffer) + }; + }, + function jsxNamespacedName(position, buffer): JSXNamespacedNameNode { + return { + type: 'JSXNamespacedName', + start: buffer[position], + end: buffer[position + 1], + namespace: convertNode(buffer[position + 2], buffer), + name: convertNode(buffer[position + 3], buffer) + }; + }, + function jsxOpeningElement(position, buffer): JSXOpeningElementNode { + const flags = buffer[position + 2]; + return { + type: 'JSXOpeningElement', + start: buffer[position], + end: buffer[position + 1], + selfClosing: (flags & 1) === 1, + name: convertNode(buffer[position + 3], buffer), + attributes: convertNodeList(buffer[position + 4], buffer) + }; + }, + function jsxOpeningFragment(position, buffer): JSXOpeningFragmentNode { + return { + type: 'JSXOpeningFragment', + start: buffer[position], + end: buffer[position + 1], + attributes: [], + selfClosing: false + }; + }, + function jsxSpreadAttribute(position, buffer): JSXSpreadAttributeNode { + return { + type: 'JSXSpreadAttribute', + start: buffer[position], + end: buffer[position + 1], + argument: convertNode(buffer[position + 2], buffer) + }; + }, + function jsxSpreadChild(position, buffer): JSXSpreadChildNode { + return { + type: 'JSXSpreadChild', + start: buffer[position], + end: buffer[position + 1], + expression: convertNode(buffer[position + 2], buffer) + }; + }, + function jsxText(position, buffer): JSXTextNode { + return { + type: 'JSXText', + start: buffer[position], + end: buffer[position + 1], + value: buffer.convertString(buffer[position + 2]), + raw: buffer.convertString(buffer[position + 3]) + }; + }, function labeledStatement(position, buffer): LabeledStatementNode { return { type: 'LabeledStatement', @@ -895,6 +1028,21 @@ export type ImportExpressionNode = RollupAstNode< >; export type ImportNamespaceSpecifierNode = RollupAstNode; export type ImportSpecifierNode = RollupAstNode; +export type JSXAttributeNode = RollupAstNode; +export type JSXClosingElementNode = RollupAstNode; +export type JSXClosingFragmentNode = RollupAstNode; +export type JSXElementNode = RollupAstNode; +export type JSXEmptyExpressionNode = RollupAstNode; +export type JSXExpressionContainerNode = RollupAstNode; +export type JSXFragmentNode = RollupAstNode; +export type JSXIdentifierNode = RollupAstNode; +export type JSXMemberExpressionNode = RollupAstNode; +export type JSXNamespacedNameNode = RollupAstNode; +export type JSXOpeningElementNode = RollupAstNode; +export type JSXOpeningFragmentNode = RollupAstNode; +export type JSXSpreadAttributeNode = RollupAstNode; +export type JSXSpreadChildNode = RollupAstNode; +export type JSXTextNode = RollupAstNode; export type LabeledStatementNode = RollupAstNode; export type LiteralBigIntNode = RollupAstNode; export type LiteralBooleanNode = RollupAstNode; diff --git a/src/utils/jsx.ts b/src/utils/jsx.ts new file mode 100644 index 000000000..978cc0ba2 --- /dev/null +++ b/src/utils/jsx.ts @@ -0,0 +1,20 @@ +import type JSXElement from '../ast/nodes/JSXElement'; +import JSXEmptyExpression from '../ast/nodes/JSXEmptyExpression'; +import JSXExpressionContainer from '../ast/nodes/JSXExpressionContainer'; +import type JSXFragment from '../ast/nodes/JSXFragment'; +import type JSXSpreadChild from '../ast/nodes/JSXSpreadChild'; +import type JSXText from '../ast/nodes/JSXText'; + +export function getRenderedJsxChildren( + children: (JSXText | JSXExpressionContainer | JSXElement | JSXFragment | JSXSpreadChild)[] +) { + let renderedChildren = 0; + for (const child of children) { + if ( + !(child instanceof JSXExpressionContainer && child.expression instanceof JSXEmptyExpression) + ) { + renderedChildren++; + } + } + return renderedChildren; +} diff --git a/src/utils/logs.ts b/src/utils/logs.ts index 2274103f6..7c09d04a1 100644 --- a/src/utils/logs.ts +++ b/src/utils/logs.ts @@ -18,6 +18,7 @@ import { URL_AVOIDING_EVAL, URL_BUNDLE_CONFIG_AS_CJS, URL_CONFIGURATION_FILES, + URL_JSX, URL_NAME_IS_NOT_EXPORTED, URL_OUTPUT_DIR, URL_OUTPUT_EXPORTS, @@ -154,6 +155,7 @@ const ADDON_ERROR = 'ADDON_ERROR', MISSING_EXTERNAL_CONFIG = 'MISSING_EXTERNAL_CONFIG', MISSING_GLOBAL_NAME = 'MISSING_GLOBAL_NAME', MISSING_IMPLICIT_DEPENDANT = 'MISSING_IMPLICIT_DEPENDANT', + MISSING_JSX_EXPORT = 'MISSING_JSX_EXPORT', MISSING_NAME_OPTION_FOR_IIFE_EXPORT = 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT', MISSING_NODE_BUILTINS = 'MISSING_NODE_BUILTINS', MISSING_OPTION = 'MISSING_OPTION', @@ -770,6 +772,17 @@ export function logImplicitDependantIsNotIncluded(module: Module): RollupLog { }; } +export function logMissingJsxExport(name: string, exporter: string, importer: string): RollupLog { + return { + code: MISSING_JSX_EXPORT, + exporter, + id: importer, + message: `Export "${name}" is not defined in module "${relativeId(exporter)}" even though it is needed in "${relativeId(importer)}" to provide JSX syntax. Please check your "jsx" option.`, + names: [name], + url: getRollupUrl(URL_JSX) + }; +} + export function logMissingNameOptionForIifeExport(): RollupLog { return { code: MISSING_NAME_OPTION_FOR_IIFE_EXPORT, diff --git a/src/utils/options/mergeOptions.ts b/src/utils/options/mergeOptions.ts index 0e78b2374..29d7ff0e8 100644 --- a/src/utils/options/mergeOptions.ts +++ b/src/utils/options/mergeOptions.ts @@ -11,12 +11,13 @@ import type { import { ensureArray } from '../ensureArray'; import { getLogger } from '../logger'; import { LOGLEVEL_INFO } from '../logging'; -import { URL_OUTPUT_GENERATEDCODE, URL_TREESHAKE } from '../urls'; +import { URL_JSX, URL_OUTPUT_GENERATEDCODE, URL_TREESHAKE } from '../urls'; import type { CommandConfigObject } from './normalizeInputOptions'; import { generatedCodePresets, type GenericConfigObject, getOnLog, + jsxPresets, normalizePluginOption, objectifyOption, objectifyOptionWithPresets, @@ -134,6 +135,12 @@ function mergeInputOptions( experimentalLogSideEffects: getOption('experimentalLogSideEffects'), external: getExternal(config, overrides), input: getOption('input') || [], + jsx: getObjectOption( + config, + overrides, + 'jsx', + objectifyOptionWithPresets(jsxPresets, 'jsx', URL_JSX, 'false, ') + ), logLevel: getOption('logLevel'), makeAbsoluteExternalsRelative: getOption('makeAbsoluteExternalsRelative'), maxParallelFileOps: getOption('maxParallelFileOps'), @@ -172,7 +179,7 @@ const getObjectOption = ( overrides: T, name: keyof T, objectifyValue = objectifyOption -) => { +): any => { const commandOption = normalizeObjectOptionValue(overrides[name], objectifyValue); const configOption = normalizeObjectOptionValue(config[name], objectifyValue); if (commandOption !== undefined) { diff --git a/src/utils/options/normalizeInputOptions.ts b/src/utils/options/normalizeInputOptions.ts index 0342b71d8..85127200c 100644 --- a/src/utils/options/normalizeInputOptions.ts +++ b/src/utils/options/normalizeInputOptions.ts @@ -11,10 +11,11 @@ import { getLogger } from '../logger'; import { LOGLEVEL_INFO } from '../logging'; import { error, logInvalidOption } from '../logs'; import { resolve } from '../path'; -import { URL_TREESHAKE, URL_TREESHAKE_MODULESIDEEFFECTS } from '../urls'; +import { URL_JSX, URL_TREESHAKE, URL_TREESHAKE_MODULESIDEEFFECTS } from '../urls'; import { getOnLog, getOptionWithPreset, + jsxPresets, normalizePluginOption, treeshakePresets, warnUnknownOptions @@ -50,6 +51,7 @@ export async function normalizeInputOptions( experimentalLogSideEffects: config.experimentalLogSideEffects || false, external: getIdMatcher(config.external), input: getInput(config), + jsx: getJsx(config), logLevel, makeAbsoluteExternalsRelative: config.makeAbsoluteExternalsRelative ?? 'ifRelativeSource', maxParallelFileOps, @@ -114,6 +116,59 @@ const getInput = (config: InputOptions): NormalizedInputOptions['input'] => { return configInput == null ? [] : typeof configInput === 'string' ? [configInput] : configInput; }; +const getJsx = (config: InputOptions): NormalizedInputOptions['jsx'] => { + const configJsx = config.jsx; + if (!configJsx) return false; + const configWithPreset = getOptionWithPreset(configJsx, jsxPresets, 'jsx', URL_JSX, 'false, '); + const { factory, importSource, mode } = configWithPreset; + switch (mode) { + case 'automatic': { + return { + factory: factory || 'React.createElement', + importSource: importSource || 'react', + jsxImportSource: configWithPreset.jsxImportSource || 'react/jsx-runtime', + mode: 'automatic' + }; + } + case 'preserve': { + if (importSource && !(factory || configWithPreset.fragment)) { + error( + logInvalidOption( + 'jsx', + URL_JSX, + 'when preserving JSX and specifying an importSource, you also need to specify a factory or fragment' + ) + ); + } + return { + factory: factory || null, + fragment: configWithPreset.fragment || null, + importSource: importSource || null, + mode: 'preserve' + }; + } + // case 'classic': + default: { + if (mode && mode !== 'classic') { + error( + logInvalidOption( + 'jsx.mode', + URL_JSX, + 'mode must be "automatic", "classic" or "preserve"', + mode + ) + ); + } + return { + factory: factory || 'React.createElement', + fragment: configWithPreset.fragment || 'React.Fragment', + importSource: importSource || null, + mode: 'classic' + }; + } + } +}; + const getMaxParallelFileOps = ( config: InputOptions ): NormalizedInputOptions['maxParallelFileOps'] => { diff --git a/src/utils/options/options.ts b/src/utils/options/options.ts index 2fe3cea1a..a459e4dfe 100644 --- a/src/utils/options/options.ts +++ b/src/utils/options/options.ts @@ -5,6 +5,7 @@ import type { LogLevelOption, NormalizedGeneratedCodeOptions, NormalizedInputOptions, + NormalizedJsxOptions, NormalizedOutputOptions, NormalizedTreeshakingOptions, OutputOptions, @@ -136,6 +137,35 @@ export const treeshakePresets: { } }; +export const jsxPresets: { + [key in NonNullable['preset']>]: NormalizedJsxOptions; +} = { + preserve: { + factory: null, + fragment: null, + importSource: null, + mode: 'preserve' + }, + 'preserve-react': { + factory: 'React.createElement', + fragment: 'React.Fragment', + importSource: 'react', + mode: 'preserve' + }, + react: { + factory: 'React.createElement', + fragment: 'React.Fragment', + importSource: 'react', + mode: 'classic' + }, + 'react-jsx': { + factory: 'React.createElement', + importSource: 'react', + jsxImportSource: 'react/jsx-runtime', + mode: 'automatic' + } +}; + export const generatedCodePresets: { [key in NonNullable< ObjectValue['preset'] @@ -159,7 +189,8 @@ export const generatedCodePresets: { type ObjectOptionWithPresets = | Partial - | Partial; + | Partial + | Partial; export const objectifyOption = (value: unknown): Record => value && typeof value === 'object' ? (value as Record) : {}; @@ -197,7 +228,7 @@ export const getOptionWithPreset = ( optionName: string, urlSnippet: string, additionalValues: string -): Record => { +): T => { const presetName: string | undefined = (value as any)?.preset; if (presetName) { const preset = presets[presetName]; @@ -214,7 +245,7 @@ export const getOptionWithPreset = ( ); } } - return objectifyOptionWithPresets(presets, optionName, urlSnippet, additionalValues)(value); + return objectifyOptionWithPresets(presets, optionName, urlSnippet, additionalValues)(value) as T; }; export const normalizePluginOption: { diff --git a/src/utils/parseAst.ts b/src/utils/parseAst.ts index 75e90c6f0..4300ad847 100644 --- a/src/utils/parseAst.ts +++ b/src/utils/parseAst.ts @@ -3,10 +3,12 @@ import type { ParseAst, ParseAstAsync } from '../rollup/types'; import { convertProgram } from './bufferToAst'; import { getAstBuffer } from './getAstBuffer'; -export const parseAst: ParseAst = (input, { allowReturnOutsideFunction = false } = {}) => - convertProgram(getAstBuffer(parse(input, allowReturnOutsideFunction))); +export const parseAst: ParseAst = ( + input, + { allowReturnOutsideFunction = false, jsx = false } = {} +) => convertProgram(getAstBuffer(parse(input, allowReturnOutsideFunction, jsx))); export const parseAstAsync: ParseAstAsync = async ( input, - { allowReturnOutsideFunction = false, signal } = {} -) => convertProgram(getAstBuffer(await parseAsync(input, allowReturnOutsideFunction, signal))); + { allowReturnOutsideFunction = false, jsx = false, signal } = {} +) => convertProgram(getAstBuffer(await parseAsync(input, allowReturnOutsideFunction, jsx, signal))); diff --git a/src/utils/parseImportAttributes.ts b/src/utils/parseImportAttributes.ts index 2ec6fe227..0775a8ab0 100644 --- a/src/utils/parseImportAttributes.ts +++ b/src/utils/parseImportAttributes.ts @@ -65,7 +65,9 @@ const getPropertyKey = (property: Property | SpreadElement | ImportAttribute): L ); }; -export function getAttributesFromImportExportDeclaration(attributes: ImportAttribute[]) { +export function getAttributesFromImportExportDeclaration( + attributes: ImportAttribute[] +): Record { return attributes?.length ? Object.fromEntries( attributes.map(assertion => [getPropertyKey(assertion), assertion.value.value]) diff --git a/src/utils/renderHelpers.ts b/src/utils/renderHelpers.ts index e0b2c2fc1..28613d3df 100644 --- a/src/utils/renderHelpers.ts +++ b/src/utils/renderHelpers.ts @@ -2,8 +2,8 @@ import type MagicString from 'magic-string'; import type { Node, StatementNode } from '../ast/nodes/shared/Node'; import type Variable from '../ast/variables/Variable'; import type { InternalModuleFormat } from '../rollup/types'; -import type { PluginDriver } from './PluginDriver'; import type { GenerateCodeSnippets } from './generateCodeSnippets'; +import type { PluginDriver } from './PluginDriver'; import { treeshakeNode } from './treeshakeNode'; export interface RenderOptions { @@ -23,6 +23,7 @@ export interface NodeRenderOptions { isCalleeOfRenderedParent?: boolean; isNoStatement?: boolean; isShorthandProperty?: boolean; + jsxMode?: 'preserve' | 'classic' | 'automatic'; preventASI?: boolean; /* Indicates if the direct parent of an element changed. Necessary for determining the "this" context of callees. */ diff --git a/src/utils/urls.ts b/src/utils/urls.ts index 13dc372c4..3b94e774b 100644 --- a/src/utils/urls.ts +++ b/src/utils/urls.ts @@ -8,6 +8,7 @@ export const URL_SOURCEMAP_IS_LIKELY_TO_BE_INCORRECT = 'troubleshooting/#warning-sourcemap-is-likely-to-be-incorrect'; // configuration-options +export const URL_JSX = 'configuration-options/#jsx'; export const URL_MAXPARALLELFILEOPS = 'configuration-options/#maxparallelfileops'; export const URL_OUTPUT_AMD_ID = 'configuration-options/#output-amd-id'; export const URL_OUTPUT_AMD_BASEPATH = 'configuration-options/#output-amd-basepath'; diff --git a/test/cli/samples/jsx/_config.js b/test/cli/samples/jsx/_config.js new file mode 100644 index 000000000..a837513c0 --- /dev/null +++ b/test/cli/samples/jsx/_config.js @@ -0,0 +1,4 @@ +module.exports = defineTest({ + description: 'supports jsx presets via CLI', + command: 'rollup -i main.js --jsx react --external react' +}); diff --git a/test/cli/samples/jsx/_expected.js b/test/cli/samples/jsx/_expected.js new file mode 100644 index 000000000..abf18f99b --- /dev/null +++ b/test/cli/samples/jsx/_expected.js @@ -0,0 +1,3 @@ +import react from 'react'; + +console.log(/*#__PURE__*/react.createElement("div", null, "Hello, world!")); diff --git a/test/cli/samples/jsx/main.js b/test/cli/samples/jsx/main.js new file mode 100644 index 000000000..877d1e6d9 --- /dev/null +++ b/test/cli/samples/jsx/main.js @@ -0,0 +1,2 @@ +import React from 'react'; +console.log(
Hello, world!
); diff --git a/test/form/samples/jsx/preserves-jsx-attributes/_config.js b/test/form/samples/jsx/preserves-jsx-attributes/_config.js new file mode 100644 index 000000000..741ed769f --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-attributes/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'preserves JSX with string attributes output', + options: { + external: ['react'], + jsx: 'preserve' + } +}); diff --git a/test/form/samples/jsx/preserves-jsx-attributes/_expected.js b/test/form/samples/jsx/preserves-jsx-attributes/_expected.js new file mode 100644 index 000000000..652f26186 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-attributes/_expected.js @@ -0,0 +1,21 @@ +const Foo$2 = () => {}; +const value$2 = 'value 1'; +console.log(Foo$2, value$2); + +const Foo$1 = () => {}; +const value$1 = 'value 2'; +console.log(Foo$1, value$1); + +const Foo = () => {}; +const value = 'value 3'; +console.log(Foo, value); + +const result = + fragment=<> +/>; + +export { result }; diff --git a/test/form/samples/jsx/preserves-jsx-attributes/dep1.js b/test/form/samples/jsx/preserves-jsx-attributes/dep1.js new file mode 100644 index 000000000..7e4f005d5 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-attributes/dep1.js @@ -0,0 +1,3 @@ +export const Foo = () => {}; +export const value = 'value 1'; +console.log(Foo, value); diff --git a/test/form/samples/jsx/preserves-jsx-attributes/dep2.js b/test/form/samples/jsx/preserves-jsx-attributes/dep2.js new file mode 100644 index 000000000..697b13977 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-attributes/dep2.js @@ -0,0 +1,3 @@ +export const Foo = () => {}; +export const value = 'value 2'; +console.log(Foo, value); diff --git a/test/form/samples/jsx/preserves-jsx-attributes/dep3.js b/test/form/samples/jsx/preserves-jsx-attributes/dep3.js new file mode 100644 index 000000000..d80368ea8 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-attributes/dep3.js @@ -0,0 +1,3 @@ +export const Foo = () => {}; +export const value = 'value 3'; +console.log(Foo, value); diff --git a/test/form/samples/jsx/preserves-jsx-attributes/main.js b/test/form/samples/jsx/preserves-jsx-attributes/main.js new file mode 100644 index 000000000..2297bc014 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-attributes/main.js @@ -0,0 +1,11 @@ +import './dep1.js'; +import { Foo, value } from './dep2.js'; +import './dep3.js'; + +export const result = + fragment=<> +/>; diff --git a/test/form/samples/jsx/preserves-jsx-child/_config.js b/test/form/samples/jsx/preserves-jsx-child/_config.js new file mode 100644 index 000000000..6eb31e379 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-child/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'preserves JSX children', + options: { + external: ['react'], + jsx: 'preserve' + } +}); diff --git a/test/form/samples/jsx/preserves-jsx-child/_expected.js b/test/form/samples/jsx/preserves-jsx-child/_expected.js new file mode 100644 index 000000000..151374d5c --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-child/_expected.js @@ -0,0 +1,8 @@ +const Foo$2 = 'wrong Foo 1'; +console.log(Foo$2); + +const Foo$1 = () => {}; +console.log(); + +const Foo = 'wrong Foo 2'; +console.log(Foo); diff --git a/test/form/samples/jsx/preserves-jsx-child/jsx.js b/test/form/samples/jsx/preserves-jsx-child/jsx.js new file mode 100644 index 000000000..ed02421e9 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-child/jsx.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +console.log(); diff --git a/test/form/samples/jsx/preserves-jsx-child/main.js b/test/form/samples/jsx/preserves-jsx-child/main.js new file mode 100644 index 000000000..dfccae859 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-child/main.js @@ -0,0 +1,3 @@ +import "./other1.js"; +import "./jsx.js"; +import "./other2.js"; diff --git a/test/form/samples/jsx/preserves-jsx-child/other1.js b/test/form/samples/jsx/preserves-jsx-child/other1.js new file mode 100644 index 000000000..297f5dfcc --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-child/other1.js @@ -0,0 +1,2 @@ +const Foo = 'wrong Foo 1'; +console.log(Foo); diff --git a/test/form/samples/jsx/preserves-jsx-child/other2.js b/test/form/samples/jsx/preserves-jsx-child/other2.js new file mode 100644 index 000000000..e274d4042 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-child/other2.js @@ -0,0 +1,2 @@ +const Foo = 'wrong Foo 2'; +console.log(Foo); diff --git a/test/form/samples/jsx/preserves-jsx-closing/_config.js b/test/form/samples/jsx/preserves-jsx-closing/_config.js new file mode 100644 index 000000000..b5f1855f6 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-closing/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'preserves JSX closing element', + options: { + external: ['react'], + jsx: 'preserve' + } +}); diff --git a/test/form/samples/jsx/preserves-jsx-closing/_expected.js b/test/form/samples/jsx/preserves-jsx-closing/_expected.js new file mode 100644 index 000000000..7b202a3cf --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-closing/_expected.js @@ -0,0 +1,4 @@ +const Foo = () => {}; +const result = ; + +export { result }; diff --git a/test/form/samples/jsx/preserves-jsx-closing/main.js b/test/form/samples/jsx/preserves-jsx-closing/main.js new file mode 100644 index 000000000..9c2716421 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-closing/main.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +export const result = ; diff --git a/test/form/samples/jsx/preserves-jsx-empty-expression/_config.js b/test/form/samples/jsx/preserves-jsx-empty-expression/_config.js new file mode 100644 index 000000000..1563f6005 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-empty-expression/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'preserves JSX output', + options: { + external: ['react'], + jsx: 'preserve' + } +}); diff --git a/test/form/samples/jsx/preserves-jsx-empty-expression/_expected.js b/test/form/samples/jsx/preserves-jsx-empty-expression/_expected.js new file mode 100644 index 000000000..f450ad4b6 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-empty-expression/_expected.js @@ -0,0 +1,4 @@ +const Foo = () => {}; +const result = {/*Wohoo*/}; + +export { result }; diff --git a/test/form/samples/jsx/preserves-jsx-empty-expression/main.js b/test/form/samples/jsx/preserves-jsx-empty-expression/main.js new file mode 100644 index 000000000..d37a6f194 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-empty-expression/main.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +export const result = {/*Wohoo*/}; diff --git a/test/form/samples/jsx/preserves-jsx-expression/_config.js b/test/form/samples/jsx/preserves-jsx-expression/_config.js new file mode 100644 index 000000000..5d94a4146 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-expression/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'preserves JSX expressions', + options: { + external: ['react'], + jsx: 'preserve' + } +}); diff --git a/test/form/samples/jsx/preserves-jsx-expression/_expected.js b/test/form/samples/jsx/preserves-jsx-expression/_expected.js new file mode 100644 index 000000000..09dcebdd9 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-expression/_expected.js @@ -0,0 +1,13 @@ +const element$2 = 'element 1'; +console.log(element$2); + +const element$1 = 'element 2'; +console.log(element$1); + +const element = 'element 3'; +console.log(element); + +const Foo = () => {}; +const result = {'test' + element$1}; + +export { result }; diff --git a/test/form/samples/jsx/preserves-jsx-expression/dep1.js b/test/form/samples/jsx/preserves-jsx-expression/dep1.js new file mode 100644 index 000000000..dd37912cc --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-expression/dep1.js @@ -0,0 +1,2 @@ +export const element = 'element 1'; +console.log(element); diff --git a/test/form/samples/jsx/preserves-jsx-expression/dep2.js b/test/form/samples/jsx/preserves-jsx-expression/dep2.js new file mode 100644 index 000000000..a9713f489 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-expression/dep2.js @@ -0,0 +1,2 @@ +export const element = 'element 2'; +console.log(element); diff --git a/test/form/samples/jsx/preserves-jsx-expression/dep3.js b/test/form/samples/jsx/preserves-jsx-expression/dep3.js new file mode 100644 index 000000000..de220a408 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-expression/dep3.js @@ -0,0 +1,2 @@ +export const element = 'element 3'; +console.log(element); diff --git a/test/form/samples/jsx/preserves-jsx-expression/main.js b/test/form/samples/jsx/preserves-jsx-expression/main.js new file mode 100644 index 000000000..910b32479 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-expression/main.js @@ -0,0 +1,6 @@ +import "./dep1.js"; +import { element } from "./dep2.js"; +import "./dep3.js"; + +const Foo = () => {}; +export const result = {'test' + element}; diff --git a/test/form/samples/jsx/preserves-jsx-fragment/_config.js b/test/form/samples/jsx/preserves-jsx-fragment/_config.js new file mode 100644 index 000000000..1563f6005 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-fragment/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'preserves JSX output', + options: { + external: ['react'], + jsx: 'preserve' + } +}); diff --git a/test/form/samples/jsx/preserves-jsx-fragment/_expected.js b/test/form/samples/jsx/preserves-jsx-fragment/_expected.js new file mode 100644 index 000000000..594a20cbd --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-fragment/_expected.js @@ -0,0 +1,4 @@ +const Foo = () => {}; +const result = <>; + +export { result }; diff --git a/test/form/samples/jsx/preserves-jsx-fragment/main.js b/test/form/samples/jsx/preserves-jsx-fragment/main.js new file mode 100644 index 000000000..14a6baf46 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-fragment/main.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +export const result = <>; diff --git a/test/form/samples/jsx/preserves-jsx-member-expression/_config.js b/test/form/samples/jsx/preserves-jsx-member-expression/_config.js new file mode 100644 index 000000000..2b51fdc72 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-member-expression/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'preserves JSX member expressions', + options: { + external: ['react'], + jsx: 'preserve' + } +}); diff --git a/test/form/samples/jsx/preserves-jsx-member-expression/_expected.js b/test/form/samples/jsx/preserves-jsx-member-expression/_expected.js new file mode 100644 index 000000000..e4db00ef4 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-member-expression/_expected.js @@ -0,0 +1,9 @@ +const obj = { + Foo: () => {}, + bar: { Baz: () => {} } +}; + +const result1 = ; +const result2 = ; + +export { result1, result2 }; diff --git a/test/form/samples/jsx/preserves-jsx-member-expression/main.js b/test/form/samples/jsx/preserves-jsx-member-expression/main.js new file mode 100644 index 000000000..04e40c09d --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-member-expression/main.js @@ -0,0 +1,7 @@ +const obj = { + Foo: () => {}, + bar: { Baz: () => {} } +}; + +export const result1 = ; +export const result2 = ; diff --git a/test/form/samples/jsx/preserves-jsx-self-closing/_config.js b/test/form/samples/jsx/preserves-jsx-self-closing/_config.js new file mode 100644 index 000000000..a94325994 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-self-closing/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'preserves self-closing JSX elements', + options: { + jsx: 'preserve' + } +}); diff --git a/test/form/samples/jsx/preserves-jsx-self-closing/_expected.js b/test/form/samples/jsx/preserves-jsx-self-closing/_expected.js new file mode 100644 index 000000000..5764a03cb --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-self-closing/_expected.js @@ -0,0 +1,4 @@ +const Foo = () => {}; +const result = ; + +export { result }; diff --git a/test/form/samples/jsx/preserves-jsx-self-closing/main.js b/test/form/samples/jsx/preserves-jsx-self-closing/main.js new file mode 100644 index 000000000..1e56ff702 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-self-closing/main.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +export const result = ; diff --git a/test/form/samples/jsx/preserves-jsx-spread-attribute/_config.js b/test/form/samples/jsx/preserves-jsx-spread-attribute/_config.js new file mode 100644 index 000000000..5554b4720 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-spread-attribute/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'preserves JSX spread attributes', + options: { + external: ['react'], + jsx: 'preserve' + } +}); diff --git a/test/form/samples/jsx/preserves-jsx-spread-attribute/_expected.js b/test/form/samples/jsx/preserves-jsx-spread-attribute/_expected.js new file mode 100644 index 000000000..382aa99a5 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-spread-attribute/_expected.js @@ -0,0 +1,20 @@ +const obj$2 = { value1: true }; +console.log(obj$2); + +const obj$1 = { value2: true }; +console.log(obj$1); + +const obj = { value3: true }; +console.log(obj); + +const Foo = () => {}; +const result1 = ; +const result2 = ; +const result3 = ; + +export { result1, result2, result3 }; diff --git a/test/form/samples/jsx/preserves-jsx-spread-attribute/dep1.js b/test/form/samples/jsx/preserves-jsx-spread-attribute/dep1.js new file mode 100644 index 000000000..658d5636c --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-spread-attribute/dep1.js @@ -0,0 +1,2 @@ +export const obj = { value1: true }; +console.log(obj); diff --git a/test/form/samples/jsx/preserves-jsx-spread-attribute/dep2.js b/test/form/samples/jsx/preserves-jsx-spread-attribute/dep2.js new file mode 100644 index 000000000..bdbe905d0 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-spread-attribute/dep2.js @@ -0,0 +1,2 @@ +export const obj = { value2: true }; +console.log(obj); diff --git a/test/form/samples/jsx/preserves-jsx-spread-attribute/dep3.js b/test/form/samples/jsx/preserves-jsx-spread-attribute/dep3.js new file mode 100644 index 000000000..f18273863 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-spread-attribute/dep3.js @@ -0,0 +1,2 @@ +export const obj = { value3: true }; +console.log(obj); diff --git a/test/form/samples/jsx/preserves-jsx-spread-attribute/main.js b/test/form/samples/jsx/preserves-jsx-spread-attribute/main.js new file mode 100644 index 000000000..22953c476 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-spread-attribute/main.js @@ -0,0 +1,13 @@ +import './dep1.js'; +import { obj } from './dep2.js'; +import './dep3.js'; + +const Foo = () => {}; +export const result1 = ; +export const result2 = ; +export const result3 = ; diff --git a/test/form/samples/jsx/preserves-jsx-spread-child/_config.js b/test/form/samples/jsx/preserves-jsx-spread-child/_config.js new file mode 100644 index 000000000..e846a8043 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-spread-child/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'preserves JSX spread children', + options: { + external: ['react'], + jsx: 'preserve' + }, + // apparently, acorn-jsx does not support spread children + verifyAst: false +}); diff --git a/test/form/samples/jsx/preserves-jsx-spread-child/_expected.js b/test/form/samples/jsx/preserves-jsx-spread-child/_expected.js new file mode 100644 index 000000000..139d1277c --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-spread-child/_expected.js @@ -0,0 +1,14 @@ +const spread$2 = ['spread 1']; +console.log(spread$2); + +const spread$1 = ['spread 2']; +console.log(spread$1); + +const spread = ['spread 3']; +console.log(spread); + +const Foo = () => {}; +const element = {...spread$1}; +const fragment = <>{...spread$1}; + +export { element, fragment }; diff --git a/test/form/samples/jsx/preserves-jsx-spread-child/dep1.js b/test/form/samples/jsx/preserves-jsx-spread-child/dep1.js new file mode 100644 index 000000000..53572b805 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-spread-child/dep1.js @@ -0,0 +1,2 @@ +export const spread = ['spread 1']; +console.log(spread); diff --git a/test/form/samples/jsx/preserves-jsx-spread-child/dep2.js b/test/form/samples/jsx/preserves-jsx-spread-child/dep2.js new file mode 100644 index 000000000..bbea244bc --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-spread-child/dep2.js @@ -0,0 +1,2 @@ +export const spread = ['spread 2']; +console.log(spread); diff --git a/test/form/samples/jsx/preserves-jsx-spread-child/dep3.js b/test/form/samples/jsx/preserves-jsx-spread-child/dep3.js new file mode 100644 index 000000000..666d48094 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-spread-child/dep3.js @@ -0,0 +1,2 @@ +export const spread = ['spread 3']; +console.log(spread); diff --git a/test/form/samples/jsx/preserves-jsx-spread-child/main.js b/test/form/samples/jsx/preserves-jsx-spread-child/main.js new file mode 100644 index 000000000..10e217564 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-spread-child/main.js @@ -0,0 +1,6 @@ +import './dep1.js'; +import { spread } from './dep2.js'; +import './dep3.js'; +const Foo = () => {}; +export const element = {...spread}; +export const fragment = <>{...spread}; diff --git a/test/form/samples/jsx/preserves-jsx-text/_config.js b/test/form/samples/jsx/preserves-jsx-text/_config.js new file mode 100644 index 000000000..74acdb423 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-text/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'preserves JSX text', + options: { + external: ['react'], + jsx: 'preserve' + } +}); diff --git a/test/form/samples/jsx/preserves-jsx-text/_expected.js b/test/form/samples/jsx/preserves-jsx-text/_expected.js new file mode 100644 index 000000000..3e62794eb --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-text/_expected.js @@ -0,0 +1,5 @@ +const Foo = () => {}; +const element = some&\text; +const fragment = <>other&\text; + +export { element, fragment }; diff --git a/test/form/samples/jsx/preserves-jsx-text/main.js b/test/form/samples/jsx/preserves-jsx-text/main.js new file mode 100644 index 000000000..e8e2d9955 --- /dev/null +++ b/test/form/samples/jsx/preserves-jsx-text/main.js @@ -0,0 +1,3 @@ +const Foo = () => {}; +export const element = some&\text; +export const fragment = <>other&\text; diff --git a/test/form/samples/jsx/preserves-native-elements/_config.js b/test/form/samples/jsx/preserves-native-elements/_config.js new file mode 100644 index 000000000..d64ae8ee7 --- /dev/null +++ b/test/form/samples/jsx/preserves-native-elements/_config.js @@ -0,0 +1,6 @@ +module.exports = defineTest({ + description: 'preserves native JSX elements', + options: { + jsx: 'preserve' + } +}); diff --git a/test/form/samples/jsx/preserves-native-elements/_expected.js b/test/form/samples/jsx/preserves-native-elements/_expected.js new file mode 100644 index 000000000..c0427dd88 --- /dev/null +++ b/test/form/samples/jsx/preserves-native-elements/_expected.js @@ -0,0 +1,10 @@ +const div$1 = 'wrong div 1'; +const span$1 = 'wrong span 1'; +console.log(div$1, span$1); + +console.log(
); +console.log(
); + +const div = 'wrong div 2'; +const span = 'wrong span 2'; +console.log(div, span); diff --git a/test/form/samples/jsx/preserves-native-elements/jsx.js b/test/form/samples/jsx/preserves-native-elements/jsx.js new file mode 100644 index 000000000..02159671a --- /dev/null +++ b/test/form/samples/jsx/preserves-native-elements/jsx.js @@ -0,0 +1,5 @@ +const div = 'wrong div'; +const span = 'wrong span'; + +console.log(
); +console.log(
); diff --git a/test/form/samples/jsx/preserves-native-elements/main.js b/test/form/samples/jsx/preserves-native-elements/main.js new file mode 100644 index 000000000..dfccae859 --- /dev/null +++ b/test/form/samples/jsx/preserves-native-elements/main.js @@ -0,0 +1,3 @@ +import "./other1.js"; +import "./jsx.js"; +import "./other2.js"; diff --git a/test/form/samples/jsx/preserves-native-elements/other1.js b/test/form/samples/jsx/preserves-native-elements/other1.js new file mode 100644 index 000000000..d607c512a --- /dev/null +++ b/test/form/samples/jsx/preserves-native-elements/other1.js @@ -0,0 +1,3 @@ +const div = 'wrong div 1'; +const span = 'wrong span 1'; +console.log(div, span); diff --git a/test/form/samples/jsx/preserves-native-elements/other2.js b/test/form/samples/jsx/preserves-native-elements/other2.js new file mode 100644 index 000000000..25f1a5e7a --- /dev/null +++ b/test/form/samples/jsx/preserves-native-elements/other2.js @@ -0,0 +1,3 @@ +const div = 'wrong div 2'; +const span = 'wrong span 2'; +console.log(div, span); diff --git a/test/form/samples/jsx/preserves-react-global/_config.js b/test/form/samples/jsx/preserves-react-global/_config.js new file mode 100644 index 000000000..c694db349 --- /dev/null +++ b/test/form/samples/jsx/preserves-react-global/_config.js @@ -0,0 +1,10 @@ +module.exports = defineTest({ + description: 'preserves React variable when preserving JSX output', + options: { + jsx: { + factory: 'React.createElement', + fragmentFactory: 'React.Fragment', + mode: 'preserve' + } + } +}); diff --git a/test/form/samples/jsx/preserves-react-global/_expected.js b/test/form/samples/jsx/preserves-react-global/_expected.js new file mode 100644 index 000000000..62f669e68 --- /dev/null +++ b/test/form/samples/jsx/preserves-react-global/_expected.js @@ -0,0 +1,10 @@ +const Foo$2 = () => {}; +const React$2 = () => {}; +console.log(Foo$2, React$2); + +const Foo$1 = () => {}; +console.log(); + +const Foo = () => {}; +const React$1 = () => {}; +console.log(Foo, React$1); diff --git a/test/form/samples/jsx/preserves-react-global/jsx.js b/test/form/samples/jsx/preserves-react-global/jsx.js new file mode 100644 index 000000000..4b5671bbb --- /dev/null +++ b/test/form/samples/jsx/preserves-react-global/jsx.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +console.log(); diff --git a/test/form/samples/jsx/preserves-react-global/main.js b/test/form/samples/jsx/preserves-react-global/main.js new file mode 100644 index 000000000..dfccae859 --- /dev/null +++ b/test/form/samples/jsx/preserves-react-global/main.js @@ -0,0 +1,3 @@ +import "./other1.js"; +import "./jsx.js"; +import "./other2.js"; diff --git a/test/form/samples/jsx/preserves-react-global/other1.js b/test/form/samples/jsx/preserves-react-global/other1.js new file mode 100644 index 000000000..dc7480c22 --- /dev/null +++ b/test/form/samples/jsx/preserves-react-global/other1.js @@ -0,0 +1,3 @@ +const Foo = () => {}; +const React = () => {}; +console.log(Foo, React); diff --git a/test/form/samples/jsx/preserves-react-global/other2.js b/test/form/samples/jsx/preserves-react-global/other2.js new file mode 100644 index 000000000..dc7480c22 --- /dev/null +++ b/test/form/samples/jsx/preserves-react-global/other2.js @@ -0,0 +1,3 @@ +const Foo = () => {}; +const React = () => {}; +console.log(Foo, React); diff --git a/test/form/samples/jsx/preserves-react-internal/_config.js b/test/form/samples/jsx/preserves-react-internal/_config.js new file mode 100644 index 000000000..4601d0902 --- /dev/null +++ b/test/form/samples/jsx/preserves-react-internal/_config.js @@ -0,0 +1,11 @@ +const path = require('node:path'); + +module.exports = defineTest({ + description: 'preserves internal React variable when preserving JSX output', + options: { + jsx: { + importSource: path.join(__dirname, 'react.js'), + preset: 'preserve-react' + } + } +}); diff --git a/test/form/samples/jsx/preserves-react-internal/_expected.js b/test/form/samples/jsx/preserves-react-internal/_expected.js new file mode 100644 index 000000000..1d4e574bb --- /dev/null +++ b/test/form/samples/jsx/preserves-react-internal/_expected.js @@ -0,0 +1,16 @@ +const Foo$2 = () => {}; +const React$2 = () => {}; +console.log(Foo$2, React$2); + +var React = { + createElement() { + console.log('createElement'); + } +}; + +const Foo$1 = () => {}; +console.log(); + +const Foo = () => {}; +const React$1 = () => {}; +console.log(Foo, React$1); diff --git a/test/form/samples/jsx/preserves-react-internal/jsx.js b/test/form/samples/jsx/preserves-react-internal/jsx.js new file mode 100644 index 000000000..4b5671bbb --- /dev/null +++ b/test/form/samples/jsx/preserves-react-internal/jsx.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +console.log(); diff --git a/test/form/samples/jsx/preserves-react-internal/main.js b/test/form/samples/jsx/preserves-react-internal/main.js new file mode 100644 index 000000000..dfccae859 --- /dev/null +++ b/test/form/samples/jsx/preserves-react-internal/main.js @@ -0,0 +1,3 @@ +import "./other1.js"; +import "./jsx.js"; +import "./other2.js"; diff --git a/test/form/samples/jsx/preserves-react-internal/other1.js b/test/form/samples/jsx/preserves-react-internal/other1.js new file mode 100644 index 000000000..dc7480c22 --- /dev/null +++ b/test/form/samples/jsx/preserves-react-internal/other1.js @@ -0,0 +1,3 @@ +const Foo = () => {}; +const React = () => {}; +console.log(Foo, React); diff --git a/test/form/samples/jsx/preserves-react-internal/other2.js b/test/form/samples/jsx/preserves-react-internal/other2.js new file mode 100644 index 000000000..dc7480c22 --- /dev/null +++ b/test/form/samples/jsx/preserves-react-internal/other2.js @@ -0,0 +1,3 @@ +const Foo = () => {}; +const React = () => {}; +console.log(Foo, React); diff --git a/test/form/samples/jsx/preserves-react-internal/react.js b/test/form/samples/jsx/preserves-react-internal/react.js new file mode 100644 index 000000000..62d368130 --- /dev/null +++ b/test/form/samples/jsx/preserves-react-internal/react.js @@ -0,0 +1,5 @@ +export default { + createElement() { + console.log('createElement'); + } +}; diff --git a/test/form/samples/jsx/preserves-react/_config.js b/test/form/samples/jsx/preserves-react/_config.js new file mode 100644 index 000000000..ca4145a5e --- /dev/null +++ b/test/form/samples/jsx/preserves-react/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'preserves React variable when preserving JSX output', + options: { + external: ['react'], + jsx: 'preserve-react' + } +}); diff --git a/test/form/samples/jsx/preserves-react/_expected.js b/test/form/samples/jsx/preserves-react/_expected.js new file mode 100644 index 000000000..62586a3c8 --- /dev/null +++ b/test/form/samples/jsx/preserves-react/_expected.js @@ -0,0 +1,12 @@ +import React from 'react'; + +const Foo$2 = () => {}; +const React$2 = () => {}; +console.log(Foo$2, React$2); + +const Foo$1 = () => {}; +console.log(); + +const Foo = () => {}; +const React$1 = () => {}; +console.log(Foo, React$1); diff --git a/test/form/samples/jsx/preserves-react/jsx.js b/test/form/samples/jsx/preserves-react/jsx.js new file mode 100644 index 000000000..bb22f6edd --- /dev/null +++ b/test/form/samples/jsx/preserves-react/jsx.js @@ -0,0 +1,4 @@ +import React from "react"; + +const Foo = () => {}; +console.log(); diff --git a/test/form/samples/jsx/preserves-react/main.js b/test/form/samples/jsx/preserves-react/main.js new file mode 100644 index 000000000..dfccae859 --- /dev/null +++ b/test/form/samples/jsx/preserves-react/main.js @@ -0,0 +1,3 @@ +import "./other1.js"; +import "./jsx.js"; +import "./other2.js"; diff --git a/test/form/samples/jsx/preserves-react/other1.js b/test/form/samples/jsx/preserves-react/other1.js new file mode 100644 index 000000000..dc7480c22 --- /dev/null +++ b/test/form/samples/jsx/preserves-react/other1.js @@ -0,0 +1,3 @@ +const Foo = () => {}; +const React = () => {}; +console.log(Foo, React); diff --git a/test/form/samples/jsx/preserves-react/other2.js b/test/form/samples/jsx/preserves-react/other2.js new file mode 100644 index 000000000..dc7480c22 --- /dev/null +++ b/test/form/samples/jsx/preserves-react/other2.js @@ -0,0 +1,3 @@ +const Foo = () => {}; +const React = () => {}; +console.log(Foo, React); diff --git a/test/form/samples/jsx/transpiles-automatic-with-defaults/_config.js b/test/form/samples/jsx/transpiles-automatic-with-defaults/_config.js new file mode 100644 index 000000000..77000dc39 --- /dev/null +++ b/test/form/samples/jsx/transpiles-automatic-with-defaults/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX for react', + options: { + external: ['react', 'react/jsx-runtime'], + jsx: { mode: 'automatic' } + } +}); diff --git a/test/form/samples/jsx/transpiles-automatic-with-defaults/_expected.js b/test/form/samples/jsx/transpiles-automatic-with-defaults/_expected.js new file mode 100644 index 000000000..4181ccce6 --- /dev/null +++ b/test/form/samples/jsx/transpiles-automatic-with-defaults/_expected.js @@ -0,0 +1,11 @@ +import { jsx, Fragment, jsxs } from 'react/jsx-runtime'; +import react from 'react'; + +const Foo = () => {}; +const obj = { key: '2' }; + +console.log(/*#__PURE__*/jsx(Foo, {})); +console.log(/*#__PURE__*/jsx(Fragment, { children: /*#__PURE__*/jsx(Foo, {}) })); +console.log(/*#__PURE__*/jsxs(Foo, { children: [/*#__PURE__*/jsx(Foo, {}), /*#__PURE__*/jsx(Foo, {})] })); +console.log(/*#__PURE__*/jsxs(Fragment, { children: [/*#__PURE__*/jsx(Foo, {}), /*#__PURE__*/jsx(Foo, {})] })); +console.log(/*#__PURE__*/react.createElement(Foo, Object.assign({}, obj, { key: "1" }))); diff --git a/test/form/samples/jsx/transpiles-automatic-with-defaults/main.js b/test/form/samples/jsx/transpiles-automatic-with-defaults/main.js new file mode 100644 index 000000000..13f357d5f --- /dev/null +++ b/test/form/samples/jsx/transpiles-automatic-with-defaults/main.js @@ -0,0 +1,8 @@ +const Foo = () => {}; +const obj = { key: '2' }; + +console.log(); +console.log(<>); +console.log(); +console.log(<>); +console.log(); diff --git a/test/form/samples/jsx/transpiles-classic-with-defaults/_config.js b/test/form/samples/jsx/transpiles-classic-with-defaults/_config.js new file mode 100644 index 000000000..61589a991 --- /dev/null +++ b/test/form/samples/jsx/transpiles-classic-with-defaults/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX for react', + options: { + external: ['react', 'react/jsx-runtime'], + jsx: { mode: 'classic' } + } +}); diff --git a/test/form/samples/jsx/transpiles-classic-with-defaults/_expected.js b/test/form/samples/jsx/transpiles-classic-with-defaults/_expected.js new file mode 100644 index 000000000..758900d85 --- /dev/null +++ b/test/form/samples/jsx/transpiles-classic-with-defaults/_expected.js @@ -0,0 +1,8 @@ +const Foo = () => {}; +const obj = { key: '2' }; + +console.log(/*#__PURE__*/React.createElement(Foo, null)); +console.log(/*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Foo, null))); +console.log(/*#__PURE__*/React.createElement(Foo, null, /*#__PURE__*/React.createElement(Foo, null), /*#__PURE__*/React.createElement(Foo, null))); +console.log(/*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Foo, null), /*#__PURE__*/React.createElement(Foo, null))); +console.log(/*#__PURE__*/React.createElement(Foo, Object.assign({}, obj, { key: "1" }))); diff --git a/test/form/samples/jsx/transpiles-classic-with-defaults/main.js b/test/form/samples/jsx/transpiles-classic-with-defaults/main.js new file mode 100644 index 000000000..13f357d5f --- /dev/null +++ b/test/form/samples/jsx/transpiles-classic-with-defaults/main.js @@ -0,0 +1,8 @@ +const Foo = () => {}; +const obj = { key: '2' }; + +console.log(); +console.log(<>); +console.log(); +console.log(<>); +console.log(); diff --git a/test/form/samples/jsx/transpiles-empty-fragment/_config.js b/test/form/samples/jsx/transpiles-empty-fragment/_config.js new file mode 100644 index 000000000..d9c8a8452 --- /dev/null +++ b/test/form/samples/jsx/transpiles-empty-fragment/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX for react', + options: { + external: ['react', 'react/jsx-runtime'], + jsx: 'react-jsx' + } +}); diff --git a/test/form/samples/jsx/transpiles-empty-fragment/_expected.js b/test/form/samples/jsx/transpiles-empty-fragment/_expected.js new file mode 100644 index 000000000..5fd112f7f --- /dev/null +++ b/test/form/samples/jsx/transpiles-empty-fragment/_expected.js @@ -0,0 +1,3 @@ +import { jsx, Fragment } from 'react/jsx-runtime'; + +console.log(/*#__PURE__*/jsx(Fragment, {})); diff --git a/test/form/samples/jsx/transpiles-empty-fragment/main.js b/test/form/samples/jsx/transpiles-empty-fragment/main.js new file mode 100644 index 000000000..f6957f2d7 --- /dev/null +++ b/test/form/samples/jsx/transpiles-empty-fragment/main.js @@ -0,0 +1 @@ +console.log(<>); diff --git a/test/form/samples/jsx/transpiles-jsx-attributes/_config.js b/test/form/samples/jsx/transpiles-jsx-attributes/_config.js new file mode 100644 index 000000000..6eec3cae0 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-attributes/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX with string attributes output', + options: { + external: ['react'], + jsx: 'react' + } +}); diff --git a/test/form/samples/jsx/transpiles-jsx-attributes/_expected.js b/test/form/samples/jsx/transpiles-jsx-attributes/_expected.js new file mode 100644 index 000000000..f058ee679 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-attributes/_expected.js @@ -0,0 +1,22 @@ +import react from 'react'; + +const Foo$2 = () => {}; +const value$2 = 'value 1'; +console.log(Foo$2, value$2); + +const Foo$1 = () => {}; +const value$1 = 'value 2'; +console.log(Foo$1, value$1); + +const Foo = () => {}; +const value = 'value 3'; +console.log(Foo, value); + +const result = /*#__PURE__*/react.createElement(Foo$1, + { bar: true, + "baz:foo": "string", + "quux-nix": value$1, + element: /*#__PURE__*/react.createElement(Foo$1, null), + fragment: /*#__PURE__*/react.createElement(react.Fragment, null) }); + +export { result }; diff --git a/test/form/samples/jsx/transpiles-jsx-attributes/dep1.js b/test/form/samples/jsx/transpiles-jsx-attributes/dep1.js new file mode 100644 index 000000000..7e4f005d5 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-attributes/dep1.js @@ -0,0 +1,3 @@ +export const Foo = () => {}; +export const value = 'value 1'; +console.log(Foo, value); diff --git a/test/form/samples/jsx/transpiles-jsx-attributes/dep2.js b/test/form/samples/jsx/transpiles-jsx-attributes/dep2.js new file mode 100644 index 000000000..697b13977 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-attributes/dep2.js @@ -0,0 +1,3 @@ +export const Foo = () => {}; +export const value = 'value 2'; +console.log(Foo, value); diff --git a/test/form/samples/jsx/transpiles-jsx-attributes/dep3.js b/test/form/samples/jsx/transpiles-jsx-attributes/dep3.js new file mode 100644 index 000000000..d80368ea8 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-attributes/dep3.js @@ -0,0 +1,3 @@ +export const Foo = () => {}; +export const value = 'value 3'; +console.log(Foo, value); diff --git a/test/form/samples/jsx/transpiles-jsx-attributes/main.js b/test/form/samples/jsx/transpiles-jsx-attributes/main.js new file mode 100644 index 000000000..2297bc014 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-attributes/main.js @@ -0,0 +1,11 @@ +import './dep1.js'; +import { Foo, value } from './dep2.js'; +import './dep3.js'; + +export const result = + fragment=<> +/>; diff --git a/test/form/samples/jsx/transpiles-jsx-child/_config.js b/test/form/samples/jsx/transpiles-jsx-child/_config.js new file mode 100644 index 000000000..66790a159 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-child/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX children', + options: { + external: ['react'], + jsx: 'react' + } +}); diff --git a/test/form/samples/jsx/transpiles-jsx-child/_expected.js b/test/form/samples/jsx/transpiles-jsx-child/_expected.js new file mode 100644 index 000000000..4bd347ce5 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-child/_expected.js @@ -0,0 +1,6 @@ +import react from 'react'; + +const Foo = () => {}; +const result = /*#__PURE__*/react.createElement(Foo, null, /*#__PURE__*/react.createElement(Foo, null)); + +export { result }; diff --git a/test/form/samples/jsx/transpiles-jsx-child/main.js b/test/form/samples/jsx/transpiles-jsx-child/main.js new file mode 100644 index 000000000..c863c74f6 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-child/main.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +export const result = ; diff --git a/test/form/samples/jsx/transpiles-jsx-closing/_config.js b/test/form/samples/jsx/transpiles-jsx-closing/_config.js new file mode 100644 index 000000000..719ece5be --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-closing/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX closing element', + options: { + external: ['react'], + jsx: 'react' + } +}); diff --git a/test/form/samples/jsx/transpiles-jsx-closing/_expected.js b/test/form/samples/jsx/transpiles-jsx-closing/_expected.js new file mode 100644 index 000000000..1a5486061 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-closing/_expected.js @@ -0,0 +1,6 @@ +import react from 'react'; + +const Foo = () => {}; +const result = /*#__PURE__*/react.createElement(Foo, null); + +export { result }; diff --git a/test/form/samples/jsx/transpiles-jsx-closing/main.js b/test/form/samples/jsx/transpiles-jsx-closing/main.js new file mode 100644 index 000000000..9c2716421 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-closing/main.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +export const result = ; diff --git a/test/form/samples/jsx/transpiles-jsx-empty-expression/_config.js b/test/form/samples/jsx/transpiles-jsx-empty-expression/_config.js new file mode 100644 index 000000000..154660bc4 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-empty-expression/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX output', + options: { + external: ['react'], + jsx: 'react' + } +}); diff --git a/test/form/samples/jsx/transpiles-jsx-empty-expression/_expected.js b/test/form/samples/jsx/transpiles-jsx-empty-expression/_expected.js new file mode 100644 index 000000000..1a5486061 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-empty-expression/_expected.js @@ -0,0 +1,6 @@ +import react from 'react'; + +const Foo = () => {}; +const result = /*#__PURE__*/react.createElement(Foo, null); + +export { result }; diff --git a/test/form/samples/jsx/transpiles-jsx-empty-expression/main.js b/test/form/samples/jsx/transpiles-jsx-empty-expression/main.js new file mode 100644 index 000000000..d37a6f194 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-empty-expression/main.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +export const result = {/*Wohoo*/}; diff --git a/test/form/samples/jsx/transpiles-jsx-expression/_config.js b/test/form/samples/jsx/transpiles-jsx-expression/_config.js new file mode 100644 index 000000000..217e03f57 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-expression/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX expressions', + options: { + external: ['react'], + jsx: 'react' + } +}); diff --git a/test/form/samples/jsx/transpiles-jsx-expression/_expected.js b/test/form/samples/jsx/transpiles-jsx-expression/_expected.js new file mode 100644 index 000000000..3a792d735 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-expression/_expected.js @@ -0,0 +1,15 @@ +import react from 'react'; + +const element$2 = 'element 1'; +console.log(element$2); + +const element$1 = 'element 2'; +console.log(element$1); + +const element = 'element 3'; +console.log(element); + +const Foo = () => {}; +const result = /*#__PURE__*/react.createElement(Foo, null, 'test' + element$1); + +export { result }; diff --git a/test/form/samples/jsx/transpiles-jsx-expression/dep1.js b/test/form/samples/jsx/transpiles-jsx-expression/dep1.js new file mode 100644 index 000000000..dd37912cc --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-expression/dep1.js @@ -0,0 +1,2 @@ +export const element = 'element 1'; +console.log(element); diff --git a/test/form/samples/jsx/transpiles-jsx-expression/dep2.js b/test/form/samples/jsx/transpiles-jsx-expression/dep2.js new file mode 100644 index 000000000..a9713f489 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-expression/dep2.js @@ -0,0 +1,2 @@ +export const element = 'element 2'; +console.log(element); diff --git a/test/form/samples/jsx/transpiles-jsx-expression/dep3.js b/test/form/samples/jsx/transpiles-jsx-expression/dep3.js new file mode 100644 index 000000000..de220a408 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-expression/dep3.js @@ -0,0 +1,2 @@ +export const element = 'element 3'; +console.log(element); diff --git a/test/form/samples/jsx/transpiles-jsx-expression/main.js b/test/form/samples/jsx/transpiles-jsx-expression/main.js new file mode 100644 index 000000000..910b32479 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-expression/main.js @@ -0,0 +1,6 @@ +import "./dep1.js"; +import { element } from "./dep2.js"; +import "./dep3.js"; + +const Foo = () => {}; +export const result = {'test' + element}; diff --git a/test/form/samples/jsx/transpiles-jsx-fragment/_config.js b/test/form/samples/jsx/transpiles-jsx-fragment/_config.js new file mode 100644 index 000000000..154660bc4 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-fragment/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX output', + options: { + external: ['react'], + jsx: 'react' + } +}); diff --git a/test/form/samples/jsx/transpiles-jsx-fragment/_expected.js b/test/form/samples/jsx/transpiles-jsx-fragment/_expected.js new file mode 100644 index 000000000..c9a08b770 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-fragment/_expected.js @@ -0,0 +1,6 @@ +import react from 'react'; + +const Foo = () => {}; +const result = /*#__PURE__*/react.createElement(Foo, null, /*#__PURE__*/react.createElement(react.Fragment, null)); + +export { result }; diff --git a/test/form/samples/jsx/transpiles-jsx-fragment/main.js b/test/form/samples/jsx/transpiles-jsx-fragment/main.js new file mode 100644 index 000000000..14a6baf46 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-fragment/main.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +export const result = <>; diff --git a/test/form/samples/jsx/transpiles-jsx-member-expression/_config.js b/test/form/samples/jsx/transpiles-jsx-member-expression/_config.js new file mode 100644 index 000000000..dfd4b69c2 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-member-expression/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX member expressions', + options: { + external: ['react'], + jsx: 'react' + } +}); diff --git a/test/form/samples/jsx/transpiles-jsx-member-expression/_expected.js b/test/form/samples/jsx/transpiles-jsx-member-expression/_expected.js new file mode 100644 index 000000000..7549595c5 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-member-expression/_expected.js @@ -0,0 +1,11 @@ +import react from 'react'; + +const obj = { + Foo: () => {}, + bar: { Baz: () => {} } +}; + +const result1 = /*#__PURE__*/react.createElement(obj.Foo, null); +const result2 = /*#__PURE__*/react.createElement(obj.bar.Baz, null); + +export { result1, result2 }; diff --git a/test/form/samples/jsx/transpiles-jsx-member-expression/main.js b/test/form/samples/jsx/transpiles-jsx-member-expression/main.js new file mode 100644 index 000000000..04e40c09d --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-member-expression/main.js @@ -0,0 +1,7 @@ +const obj = { + Foo: () => {}, + bar: { Baz: () => {} } +}; + +export const result1 = ; +export const result2 = ; diff --git a/test/form/samples/jsx/transpiles-jsx-self-closing/_config.js b/test/form/samples/jsx/transpiles-jsx-self-closing/_config.js new file mode 100644 index 000000000..ec1eb81a5 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-self-closing/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles self-closing JSX elements', + options: { + external: ['react'], + jsx: 'react' + } +}); diff --git a/test/form/samples/jsx/transpiles-jsx-self-closing/_expected.js b/test/form/samples/jsx/transpiles-jsx-self-closing/_expected.js new file mode 100644 index 000000000..1a5486061 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-self-closing/_expected.js @@ -0,0 +1,6 @@ +import react from 'react'; + +const Foo = () => {}; +const result = /*#__PURE__*/react.createElement(Foo, null); + +export { result }; diff --git a/test/form/samples/jsx/transpiles-jsx-self-closing/main.js b/test/form/samples/jsx/transpiles-jsx-self-closing/main.js new file mode 100644 index 000000000..1e56ff702 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-self-closing/main.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +export const result = ; diff --git a/test/form/samples/jsx/transpiles-jsx-spread-attribute/_config.js b/test/form/samples/jsx/transpiles-jsx-spread-attribute/_config.js new file mode 100644 index 000000000..edcac60d1 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-spread-attribute/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX spread attributes', + options: { + external: ['react'], + jsx: 'react' + } +}); diff --git a/test/form/samples/jsx/transpiles-jsx-spread-attribute/_expected.js b/test/form/samples/jsx/transpiles-jsx-spread-attribute/_expected.js new file mode 100644 index 000000000..4329ca938 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-spread-attribute/_expected.js @@ -0,0 +1,21 @@ +import react from 'react'; + +const obj$2 = { value1: true }; +console.log(obj$2); + +const obj$1 = { value2: true }; +console.log(obj$1); + +const obj = { value3: true }; +console.log(obj); + +const Foo = () => {}; +const result1 = /*#__PURE__*/react.createElement(Foo, obj$1); +const result2 = /*#__PURE__*/react.createElement(Foo, Object.assign({}, obj$1, { prop: true })); +const result3 = /*#__PURE__*/react.createElement(Foo, + Object.assign({ prop1: true, + prop2: true }, + obj$1, + obj$1)); + +export { result1, result2, result3 }; diff --git a/test/form/samples/jsx/transpiles-jsx-spread-attribute/dep1.js b/test/form/samples/jsx/transpiles-jsx-spread-attribute/dep1.js new file mode 100644 index 000000000..658d5636c --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-spread-attribute/dep1.js @@ -0,0 +1,2 @@ +export const obj = { value1: true }; +console.log(obj); diff --git a/test/form/samples/jsx/transpiles-jsx-spread-attribute/dep2.js b/test/form/samples/jsx/transpiles-jsx-spread-attribute/dep2.js new file mode 100644 index 000000000..bdbe905d0 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-spread-attribute/dep2.js @@ -0,0 +1,2 @@ +export const obj = { value2: true }; +console.log(obj); diff --git a/test/form/samples/jsx/transpiles-jsx-spread-attribute/dep3.js b/test/form/samples/jsx/transpiles-jsx-spread-attribute/dep3.js new file mode 100644 index 000000000..f18273863 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-spread-attribute/dep3.js @@ -0,0 +1,2 @@ +export const obj = { value3: true }; +console.log(obj); diff --git a/test/form/samples/jsx/transpiles-jsx-spread-attribute/main.js b/test/form/samples/jsx/transpiles-jsx-spread-attribute/main.js new file mode 100644 index 000000000..22953c476 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-spread-attribute/main.js @@ -0,0 +1,13 @@ +import './dep1.js'; +import { obj } from './dep2.js'; +import './dep3.js'; + +const Foo = () => {}; +export const result1 = ; +export const result2 = ; +export const result3 = ; diff --git a/test/form/samples/jsx/transpiles-jsx-spread-child/_config.js b/test/form/samples/jsx/transpiles-jsx-spread-child/_config.js new file mode 100644 index 000000000..cc06baae2 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-spread-child/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'transpiles JSX spread children', + options: { + external: ['react'], + jsx: 'react' + }, + // apparently, acorn-jsx does not support spread children + verifyAst: false +}); diff --git a/test/form/samples/jsx/transpiles-jsx-spread-child/_expected.js b/test/form/samples/jsx/transpiles-jsx-spread-child/_expected.js new file mode 100644 index 000000000..9a1f05f7f --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-spread-child/_expected.js @@ -0,0 +1,16 @@ +import react from 'react'; + +const spread$2 = ['spread 1']; +console.log(spread$2); + +const spread$1 = ['spread 2']; +console.log(spread$1); + +const spread = ['spread 3']; +console.log(spread); + +const Foo = () => {}; +const element = /*#__PURE__*/react.createElement(Foo, null, ...spread$1); +const fragment = /*#__PURE__*/react.createElement(react.Fragment, null, ...spread$1); + +export { element, fragment }; diff --git a/test/form/samples/jsx/transpiles-jsx-spread-child/dep1.js b/test/form/samples/jsx/transpiles-jsx-spread-child/dep1.js new file mode 100644 index 000000000..53572b805 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-spread-child/dep1.js @@ -0,0 +1,2 @@ +export const spread = ['spread 1']; +console.log(spread); diff --git a/test/form/samples/jsx/transpiles-jsx-spread-child/dep2.js b/test/form/samples/jsx/transpiles-jsx-spread-child/dep2.js new file mode 100644 index 000000000..bbea244bc --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-spread-child/dep2.js @@ -0,0 +1,2 @@ +export const spread = ['spread 2']; +console.log(spread); diff --git a/test/form/samples/jsx/transpiles-jsx-spread-child/dep3.js b/test/form/samples/jsx/transpiles-jsx-spread-child/dep3.js new file mode 100644 index 000000000..666d48094 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-spread-child/dep3.js @@ -0,0 +1,2 @@ +export const spread = ['spread 3']; +console.log(spread); diff --git a/test/form/samples/jsx/transpiles-jsx-spread-child/main.js b/test/form/samples/jsx/transpiles-jsx-spread-child/main.js new file mode 100644 index 000000000..10e217564 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-spread-child/main.js @@ -0,0 +1,6 @@ +import './dep1.js'; +import { spread } from './dep2.js'; +import './dep3.js'; +const Foo = () => {}; +export const element = {...spread}; +export const fragment = <>{...spread}; diff --git a/test/form/samples/jsx/transpiles-jsx-text/_config.js b/test/form/samples/jsx/transpiles-jsx-text/_config.js new file mode 100644 index 000000000..d3fcf6b79 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-text/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX text', + options: { + external: ['react'], + jsx: 'react' + } +}); diff --git a/test/form/samples/jsx/transpiles-jsx-text/_expected.js b/test/form/samples/jsx/transpiles-jsx-text/_expected.js new file mode 100644 index 000000000..52f72067d --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-text/_expected.js @@ -0,0 +1,7 @@ +import react from 'react'; + +const Foo = () => {}; +const element = /*#__PURE__*/react.createElement(Foo, null, "some&\\text"); +const fragment = /*#__PURE__*/react.createElement(react.Fragment, null, "other&\\text"); + +export { element, fragment }; diff --git a/test/form/samples/jsx/transpiles-jsx-text/main.js b/test/form/samples/jsx/transpiles-jsx-text/main.js new file mode 100644 index 000000000..e8e2d9955 --- /dev/null +++ b/test/form/samples/jsx/transpiles-jsx-text/main.js @@ -0,0 +1,3 @@ +const Foo = () => {}; +export const element = some&\text; +export const fragment = <>other&\text; diff --git a/test/form/samples/jsx/transpiles-native-elements/_config.js b/test/form/samples/jsx/transpiles-native-elements/_config.js new file mode 100644 index 000000000..52b1628b5 --- /dev/null +++ b/test/form/samples/jsx/transpiles-native-elements/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'preserves native JSX elements', + options: { + external: ['react'], + jsx: 'react' + } +}); diff --git a/test/form/samples/jsx/transpiles-native-elements/_expected.js b/test/form/samples/jsx/transpiles-native-elements/_expected.js new file mode 100644 index 000000000..fa8253556 --- /dev/null +++ b/test/form/samples/jsx/transpiles-native-elements/_expected.js @@ -0,0 +1,12 @@ +import react from 'react'; + +const div$1 = 'wrong div 1'; +const span$1 = 'wrong span 1'; +console.log(div$1, span$1); + +console.log(/*#__PURE__*/react.createElement("div", null)); +console.log(/*#__PURE__*/react.createElement("div", null, /*#__PURE__*/react.createElement("span", null))); + +const div = 'wrong div 2'; +const span = 'wrong span 2'; +console.log(div, span); diff --git a/test/form/samples/jsx/transpiles-native-elements/jsx.js b/test/form/samples/jsx/transpiles-native-elements/jsx.js new file mode 100644 index 000000000..02159671a --- /dev/null +++ b/test/form/samples/jsx/transpiles-native-elements/jsx.js @@ -0,0 +1,5 @@ +const div = 'wrong div'; +const span = 'wrong span'; + +console.log(
); +console.log(
); diff --git a/test/form/samples/jsx/transpiles-native-elements/main.js b/test/form/samples/jsx/transpiles-native-elements/main.js new file mode 100644 index 000000000..dfccae859 --- /dev/null +++ b/test/form/samples/jsx/transpiles-native-elements/main.js @@ -0,0 +1,3 @@ +import "./other1.js"; +import "./jsx.js"; +import "./other2.js"; diff --git a/test/form/samples/jsx/transpiles-native-elements/other1.js b/test/form/samples/jsx/transpiles-native-elements/other1.js new file mode 100644 index 000000000..d607c512a --- /dev/null +++ b/test/form/samples/jsx/transpiles-native-elements/other1.js @@ -0,0 +1,3 @@ +const div = 'wrong div 1'; +const span = 'wrong span 1'; +console.log(div, span); diff --git a/test/form/samples/jsx/transpiles-native-elements/other2.js b/test/form/samples/jsx/transpiles-native-elements/other2.js new file mode 100644 index 000000000..25f1a5e7a --- /dev/null +++ b/test/form/samples/jsx/transpiles-native-elements/other2.js @@ -0,0 +1,3 @@ +const div = 'wrong div 2'; +const span = 'wrong span 2'; +console.log(div, span); diff --git a/test/form/samples/jsx/transpiles-react-global/_config.js b/test/form/samples/jsx/transpiles-react-global/_config.js new file mode 100644 index 000000000..3af41f24e --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-global/_config.js @@ -0,0 +1,9 @@ +module.exports = defineTest({ + description: 'transpiles JSX for react', + options: { + jsx: { + factory: 'React.createElement', + fragmentFactory: 'React.Fragment' + } + } +}); diff --git a/test/form/samples/jsx/transpiles-react-global/_expected.js b/test/form/samples/jsx/transpiles-react-global/_expected.js new file mode 100644 index 000000000..0dab4df90 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-global/_expected.js @@ -0,0 +1,10 @@ +const Foo$2 = 'wrong Foo 1'; +const React$2 = 'wrong React 1'; +console.log(Foo$2, React$2); + +const Foo$1 = () => {}; +console.log(/*#__PURE__*/React.createElement(Foo$1, null)); + +const Foo = 'wrong Foo 2'; +const React$1 = 'wrong React 2'; +console.log(Foo, React$1); diff --git a/test/form/samples/jsx/transpiles-react-global/jsx.js b/test/form/samples/jsx/transpiles-react-global/jsx.js new file mode 100644 index 000000000..4b5671bbb --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-global/jsx.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +console.log(); diff --git a/test/form/samples/jsx/transpiles-react-global/main.js b/test/form/samples/jsx/transpiles-react-global/main.js new file mode 100644 index 000000000..dfccae859 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-global/main.js @@ -0,0 +1,3 @@ +import "./other1.js"; +import "./jsx.js"; +import "./other2.js"; diff --git a/test/form/samples/jsx/transpiles-react-global/other1.js b/test/form/samples/jsx/transpiles-react-global/other1.js new file mode 100644 index 000000000..7b5145191 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-global/other1.js @@ -0,0 +1,3 @@ +const Foo = 'wrong Foo 1'; +const React = 'wrong React 1'; +console.log(Foo, React); diff --git a/test/form/samples/jsx/transpiles-react-global/other2.js b/test/form/samples/jsx/transpiles-react-global/other2.js new file mode 100644 index 000000000..10b37745b --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-global/other2.js @@ -0,0 +1,3 @@ +const Foo = 'wrong Foo 2'; +const React = 'wrong React 2'; +console.log(Foo, React); diff --git a/test/form/samples/jsx/transpiles-react-internal/_config.js b/test/form/samples/jsx/transpiles-react-internal/_config.js new file mode 100644 index 000000000..4a1583e82 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-internal/_config.js @@ -0,0 +1,10 @@ +const path = require('node:path'); +module.exports = defineTest({ + description: 'transpiles JSX for react', + options: { + jsx: { + importSource: path.join(__dirname, 'react.js'), + preset: 'react' + } + } +}); diff --git a/test/form/samples/jsx/transpiles-react-internal/_expected.js b/test/form/samples/jsx/transpiles-react-internal/_expected.js new file mode 100644 index 000000000..0e6ceaa7c --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-internal/_expected.js @@ -0,0 +1,16 @@ +const Foo$2 = 'wrong Foo 1'; +const React$1 = 'wrong React 1'; +console.log(Foo$2, React$1); + +var react = { + createElement() { + console.log('createElement'); + } +}; + +const Foo$1 = () => {}; +console.log(/*#__PURE__*/react.createElement(Foo$1, null)); + +const Foo = 'wrong Foo 2'; +const React = 'wrong React 2'; +console.log(Foo, React); diff --git a/test/form/samples/jsx/transpiles-react-internal/jsx.js b/test/form/samples/jsx/transpiles-react-internal/jsx.js new file mode 100644 index 000000000..4b5671bbb --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-internal/jsx.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +console.log(); diff --git a/test/form/samples/jsx/transpiles-react-internal/main.js b/test/form/samples/jsx/transpiles-react-internal/main.js new file mode 100644 index 000000000..dfccae859 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-internal/main.js @@ -0,0 +1,3 @@ +import "./other1.js"; +import "./jsx.js"; +import "./other2.js"; diff --git a/test/form/samples/jsx/transpiles-react-internal/other1.js b/test/form/samples/jsx/transpiles-react-internal/other1.js new file mode 100644 index 000000000..7b5145191 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-internal/other1.js @@ -0,0 +1,3 @@ +const Foo = 'wrong Foo 1'; +const React = 'wrong React 1'; +console.log(Foo, React); diff --git a/test/form/samples/jsx/transpiles-react-internal/other2.js b/test/form/samples/jsx/transpiles-react-internal/other2.js new file mode 100644 index 000000000..10b37745b --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-internal/other2.js @@ -0,0 +1,3 @@ +const Foo = 'wrong Foo 2'; +const React = 'wrong React 2'; +console.log(Foo, React); diff --git a/test/form/samples/jsx/transpiles-react-internal/react.js b/test/form/samples/jsx/transpiles-react-internal/react.js new file mode 100644 index 000000000..62d368130 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-internal/react.js @@ -0,0 +1,5 @@ +export default { + createElement() { + console.log('createElement'); + } +}; diff --git a/test/form/samples/jsx/transpiles-react-jsx/_config.js b/test/form/samples/jsx/transpiles-react-jsx/_config.js new file mode 100644 index 000000000..d9c8a8452 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-jsx/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX for react', + options: { + external: ['react', 'react/jsx-runtime'], + jsx: 'react-jsx' + } +}); diff --git a/test/form/samples/jsx/transpiles-react-jsx/_expected.js b/test/form/samples/jsx/transpiles-react-jsx/_expected.js new file mode 100644 index 000000000..53b7d3dba --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-jsx/_expected.js @@ -0,0 +1,78 @@ +import { jsx as jsx$2, Fragment, jsxs as jsxs$2 } from 'react/jsx-runtime'; +import react from 'react'; + +const Foo$2 = 'wrong Foo 1'; +const obj$2 = 'wrong obj 1'; +const jsx$1 = 'wrong jsx 1'; +const jsxs$1 = 'wrong jsxs 1'; +console.log(Foo$2, obj$2, jsx$1, jsxs$1); + +const Foo$1 = () => {}; +const obj$1 = { key: '2' }; + +// jsx +console.log(/*#__PURE__*/jsx$2(Foo$1, {})); +console.log(/*#__PURE__*/jsx$2(Foo$1, { x: true })); +console.log(/*#__PURE__*/jsx$2(Foo$1, { x: "1" })); +console.log(/*#__PURE__*/jsx$2(Foo$1, { x: "1" })); +console.log(/*#__PURE__*/jsx$2(Foo$1, {}, true)); +console.log(/*#__PURE__*/jsx$2(Foo$1, {}, "1")); +console.log(/*#__PURE__*/jsx$2(Foo$1, {}, "1")); +console.log(/*#__PURE__*/jsx$2(Foo$1, obj$1)); +console.log(/*#__PURE__*/jsx$2(Foo$1, Object.assign({}, obj$1, { x: "1" }))); +console.log(/*#__PURE__*/jsx$2(Foo$1, obj$1, "1")); +console.log(/*#__PURE__*/jsx$2(Foo$1, obj$1, true)); +console.log(/*#__PURE__*/jsx$2(Foo$1, Object.assign({ x: "1", y: "1" }, obj$1, obj$1))); +console.log(/*#__PURE__*/jsx$2(Foo$1, Object.assign({ x: "1", y: "1" }, obj$1, obj$1), "1")); +console.log(/*#__PURE__*/jsx$2(Foo$1, Object.assign({ x: "1", y: "1" }, obj$1, obj$1), true)); + +console.log(/*#__PURE__*/jsx$2(Foo$1, {})); +console.log(/*#__PURE__*/jsx$2(Foo$1, { x: "1" })); +console.log(/*#__PURE__*/jsx$2(Foo$1, {}, "1")); +console.log(/*#__PURE__*/jsx$2(Foo$1, {}, true)); + +console.log(/*#__PURE__*/jsx$2(Foo$1, { children: /*#__PURE__*/jsx$2(Foo$1, {}) })); +console.log(/*#__PURE__*/jsx$2(Foo$1, { x: "1", children: /*#__PURE__*/jsx$2(Foo$1, {}) })); +console.log(/*#__PURE__*/jsx$2(Foo$1, { children: /*#__PURE__*/jsx$2(Foo$1, {}) }, "1")); +console.log(/*#__PURE__*/jsx$2(Foo$1, { children: /*#__PURE__*/jsx$2(Foo$1, {}) }, true)); +console.log(/*#__PURE__*/jsx$2(Foo$1, Object.assign({}, obj$1, { children: /*#__PURE__*/jsx$2(Foo$1, {}) }))); +console.log(/*#__PURE__*/jsx$2(Foo$1, Object.assign({}, obj$1, { x: "1", children: /*#__PURE__*/jsx$2(Foo$1, {}) }))); +console.log(/*#__PURE__*/jsx$2(Foo$1, Object.assign({}, obj$1, { children: /*#__PURE__*/jsx$2(Foo$1, {}) }), "1")); +console.log(/*#__PURE__*/jsx$2(Foo$1, Object.assign({}, obj$1, { children: /*#__PURE__*/jsx$2(Foo$1, {}) }), true)); +console.log(/*#__PURE__*/jsx$2(Foo$1, Object.assign({ x: "1", y: "1" }, obj$1, obj$1, { children: /*#__PURE__*/jsx$2(Foo$1, {}) }))); +console.log(/*#__PURE__*/jsx$2(Foo$1, Object.assign({ x: "1", y: "1" }, obj$1, obj$1, { children: /*#__PURE__*/jsx$2(Foo$1, {}) }), "1")); +console.log(/*#__PURE__*/jsx$2(Foo$1, Object.assign({ x: "1", y: "1" }, obj$1, obj$1, { children: /*#__PURE__*/jsx$2(Foo$1, {}) }), true)); + +console.log(/*#__PURE__*/jsx$2(Foo$1, { children: /*#__PURE__*/jsx$2(Foo$1, {}) })); + +console.log(/*#__PURE__*/jsx$2(Fragment, {})); +console.log(/*#__PURE__*/jsx$2(Fragment, { children: /*#__PURE__*/jsx$2(Foo$1, {}) })); + +// jsxs +console.log(/*#__PURE__*/jsxs$2(Foo$1, { children: [/*#__PURE__*/jsx$2(Foo$1, {}), /*#__PURE__*/jsx$2(Foo$1, {})] })); +console.log(/*#__PURE__*/jsxs$2(Foo$1, { x: "1", children: [/*#__PURE__*/jsx$2(Foo$1, {}), /*#__PURE__*/jsx$2(Foo$1, {})] })); +console.log(/*#__PURE__*/jsxs$2(Foo$1, { children: [/*#__PURE__*/jsx$2(Foo$1, {}), /*#__PURE__*/jsx$2(Foo$1, {})] }, "1")); +console.log(/*#__PURE__*/jsxs$2(Foo$1, { children: [/*#__PURE__*/jsx$2(Foo$1, {}), /*#__PURE__*/jsx$2(Foo$1, {})] }, true)); +console.log(/*#__PURE__*/jsxs$2(Foo$1, Object.assign({}, obj$1, { children: [/*#__PURE__*/jsx$2(Foo$1, {}), /*#__PURE__*/jsx$2(Foo$1, {})] }))); +console.log(/*#__PURE__*/jsxs$2(Foo$1, Object.assign({}, obj$1, { x: "1", children: [/*#__PURE__*/jsx$2(Foo$1, {}), /*#__PURE__*/jsx$2(Foo$1, {})] }))); +console.log(/*#__PURE__*/jsxs$2(Foo$1, Object.assign({}, obj$1, { children: [/*#__PURE__*/jsx$2(Foo$1, {}), /*#__PURE__*/jsx$2(Foo$1, {})] }), "1")); +console.log(/*#__PURE__*/jsxs$2(Foo$1, Object.assign({}, obj$1, { children: [/*#__PURE__*/jsx$2(Foo$1, {}), /*#__PURE__*/jsx$2(Foo$1, {})] }), true)); +console.log(/*#__PURE__*/jsxs$2(Foo$1, Object.assign({ x: "1", y: "1" }, obj$1, obj$1, { children: [/*#__PURE__*/jsx$2(Foo$1, {}), /*#__PURE__*/jsx$2(Foo$1, {})] }))); +console.log(/*#__PURE__*/jsxs$2(Foo$1, Object.assign({ x: "1", y: "1" }, obj$1, obj$1, { children: [/*#__PURE__*/jsx$2(Foo$1, {}), /*#__PURE__*/jsx$2(Foo$1, {})] }), "1")); +console.log(/*#__PURE__*/jsxs$2(Foo$1, Object.assign({ x: "1", y: "1" }, obj$1, obj$1, { children: [/*#__PURE__*/jsx$2(Foo$1, {}), /*#__PURE__*/jsx$2(Foo$1, {})] }), true)); + +console.log(/*#__PURE__*/jsxs$2(Fragment, { children: [/*#__PURE__*/jsx$2(Foo$1, {}), /*#__PURE__*/jsx$2(Foo$1, {})] })); + +// createElement +console.log(/*#__PURE__*/react.createElement(Foo$1, Object.assign({}, obj$1, { key: "1" }))); +console.log(/*#__PURE__*/react.createElement(Foo$1, Object.assign({}, obj$1, { key: true }))); +console.log(/*#__PURE__*/react.createElement(Foo$1, Object.assign({}, obj$1, obj$1, { x: "1", key: "1", y: "1" }))); +console.log(/*#__PURE__*/react.createElement(Foo$1, Object.assign({}, obj$1, obj$1, { x: "1", key: true, y: "1" }))); +console.log(/*#__PURE__*/react.createElement(Foo$1, Object.assign({}, obj$1, { key: "1" }))); +console.log(/*#__PURE__*/react.createElement(Foo$1, Object.assign({}, obj$1, { key: "1" }), /*#__PURE__*/jsx$2(Foo$1, {}))); + +const Foo = 'wrong Foo 2'; +const obj = 'wrong obj 2'; +const jsx = 'wrong jsx 2'; +const jsxs = 'wrong jsxs 2'; +console.log(Foo, obj, jsx, jsxs); diff --git a/test/form/samples/jsx/transpiles-react-jsx/jsx.js b/test/form/samples/jsx/transpiles-react-jsx/jsx.js new file mode 100644 index 000000000..e3346bf63 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-jsx/jsx.js @@ -0,0 +1,63 @@ +const Foo = () => {}; +const obj = { key: '2' }; + +// jsx +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); + +console.log(); +console.log(); +console.log(); +console.log(); + +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); + +console.log({/* comment */}{/* comment */}); + +console.log(<>); +console.log(<>); + +// jsxs +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); + +console.log(<>); + +// createElement +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); +console.log(); diff --git a/test/form/samples/jsx/transpiles-react-jsx/main.js b/test/form/samples/jsx/transpiles-react-jsx/main.js new file mode 100644 index 000000000..dfccae859 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-jsx/main.js @@ -0,0 +1,3 @@ +import "./other1.js"; +import "./jsx.js"; +import "./other2.js"; diff --git a/test/form/samples/jsx/transpiles-react-jsx/other1.js b/test/form/samples/jsx/transpiles-react-jsx/other1.js new file mode 100644 index 000000000..9514c12c8 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-jsx/other1.js @@ -0,0 +1,5 @@ +const Foo = 'wrong Foo 1'; +const obj = 'wrong obj 1'; +const jsx = 'wrong jsx 1'; +const jsxs = 'wrong jsxs 1'; +console.log(Foo, obj, jsx, jsxs); diff --git a/test/form/samples/jsx/transpiles-react-jsx/other2.js b/test/form/samples/jsx/transpiles-react-jsx/other2.js new file mode 100644 index 000000000..802e2216e --- /dev/null +++ b/test/form/samples/jsx/transpiles-react-jsx/other2.js @@ -0,0 +1,5 @@ +const Foo = 'wrong Foo 2'; +const obj = 'wrong obj 2'; +const jsx = 'wrong jsx 2'; +const jsxs = 'wrong jsxs 2'; +console.log(Foo, obj, jsx, jsxs); diff --git a/test/form/samples/jsx/transpiles-react/_config.js b/test/form/samples/jsx/transpiles-react/_config.js new file mode 100644 index 000000000..4b546d0fd --- /dev/null +++ b/test/form/samples/jsx/transpiles-react/_config.js @@ -0,0 +1,7 @@ +module.exports = defineTest({ + description: 'transpiles JSX for react', + options: { + external: ['react'], + jsx: 'react' + } +}); diff --git a/test/form/samples/jsx/transpiles-react/_expected.js b/test/form/samples/jsx/transpiles-react/_expected.js new file mode 100644 index 000000000..c588a7020 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react/_expected.js @@ -0,0 +1,12 @@ +import react from 'react'; + +const Foo$2 = 'wrong Foo 1'; +const React$1 = 'wrong React 1'; +console.log(Foo$2, React$1); + +const Foo$1 = () => {}; +console.log(/*#__PURE__*/react.createElement(Foo$1, null)); + +const Foo = 'wrong Foo 2'; +const React = 'wrong React 2'; +console.log(Foo, React); diff --git a/test/form/samples/jsx/transpiles-react/jsx.js b/test/form/samples/jsx/transpiles-react/jsx.js new file mode 100644 index 000000000..4b5671bbb --- /dev/null +++ b/test/form/samples/jsx/transpiles-react/jsx.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +console.log(); diff --git a/test/form/samples/jsx/transpiles-react/main.js b/test/form/samples/jsx/transpiles-react/main.js new file mode 100644 index 000000000..dfccae859 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react/main.js @@ -0,0 +1,3 @@ +import "./other1.js"; +import "./jsx.js"; +import "./other2.js"; diff --git a/test/form/samples/jsx/transpiles-react/other1.js b/test/form/samples/jsx/transpiles-react/other1.js new file mode 100644 index 000000000..7b5145191 --- /dev/null +++ b/test/form/samples/jsx/transpiles-react/other1.js @@ -0,0 +1,3 @@ +const Foo = 'wrong Foo 1'; +const React = 'wrong React 1'; +console.log(Foo, React); diff --git a/test/form/samples/jsx/transpiles-react/other2.js b/test/form/samples/jsx/transpiles-react/other2.js new file mode 100644 index 000000000..10b37745b --- /dev/null +++ b/test/form/samples/jsx/transpiles-react/other2.js @@ -0,0 +1,3 @@ +const Foo = 'wrong Foo 2'; +const React = 'wrong React 2'; +console.log(Foo, React); diff --git a/test/function/samples/jsx/missing-jsx-export/_config.js b/test/function/samples/jsx/missing-jsx-export/_config.js new file mode 100644 index 000000000..5c33d183a --- /dev/null +++ b/test/function/samples/jsx/missing-jsx-export/_config.js @@ -0,0 +1,34 @@ +const path = require('node:path'); + +const ID_REACT_JSX = path.join(__dirname, 'react-jsx.js'); +const ID_MAIN = path.join(__dirname, 'main.js'); + +module.exports = defineTest({ + description: 'throws when the JSX factory is not exported', + options: { + jsx: { + jsxImportSource: ID_REACT_JSX, + preset: 'react-jsx' + } + }, + error: { + code: 'MISSING_JSX_EXPORT', + exporter: ID_REACT_JSX, + frame: ` + 1: const Foo = () => {}; + 2: console.log(); + ^`, + id: ID_MAIN, + loc: { + column: 12, + file: ID_MAIN, + line: 2 + }, + message: + 'main.js (2:12): Export "jsx" is not defined in module "react-jsx.js" even though it is needed in "main.js" to provide JSX syntax. Please check your "jsx" option.', + names: ['jsx'], + pos: 34, + url: 'https://rollupjs.org/configuration-options/#jsx', + watchFiles: [ID_MAIN, ID_REACT_JSX] + } +}); diff --git a/test/function/samples/jsx/missing-jsx-export/_expected.js b/test/function/samples/jsx/missing-jsx-export/_expected.js new file mode 100644 index 000000000..0e6ceaa7c --- /dev/null +++ b/test/function/samples/jsx/missing-jsx-export/_expected.js @@ -0,0 +1,16 @@ +const Foo$2 = 'wrong Foo 1'; +const React$1 = 'wrong React 1'; +console.log(Foo$2, React$1); + +var react = { + createElement() { + console.log('createElement'); + } +}; + +const Foo$1 = () => {}; +console.log(/*#__PURE__*/react.createElement(Foo$1, null)); + +const Foo = 'wrong Foo 2'; +const React = 'wrong React 2'; +console.log(Foo, React); diff --git a/test/function/samples/jsx/missing-jsx-export/main.js b/test/function/samples/jsx/missing-jsx-export/main.js new file mode 100644 index 000000000..4b5671bbb --- /dev/null +++ b/test/function/samples/jsx/missing-jsx-export/main.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +console.log(); diff --git a/test/function/samples/jsx/missing-jsx-export/react-jsx.js b/test/function/samples/jsx/missing-jsx-export/react-jsx.js new file mode 100644 index 000000000..0245cde6d --- /dev/null +++ b/test/function/samples/jsx/missing-jsx-export/react-jsx.js @@ -0,0 +1 @@ +export default 'actually we need jsx'; diff --git a/test/function/samples/jsx/unknown-mode/_config.js b/test/function/samples/jsx/unknown-mode/_config.js new file mode 100644 index 000000000..c143e864c --- /dev/null +++ b/test/function/samples/jsx/unknown-mode/_config.js @@ -0,0 +1,14 @@ +module.exports = defineTest({ + description: 'throws when using an unknown jsx mode', + options: { + jsx: { + mode: 'does-not-exist' + } + }, + error: { + code: 'INVALID_OPTION', + message: + 'Invalid value "does-not-exist" for option "jsx.mode" - mode must be "automatic", "classic" or "preserve".', + url: 'https://rollupjs.org/configuration-options/#jsx' + } +}); diff --git a/test/function/samples/jsx/unknown-mode/_expected.js b/test/function/samples/jsx/unknown-mode/_expected.js new file mode 100644 index 000000000..0e6ceaa7c --- /dev/null +++ b/test/function/samples/jsx/unknown-mode/_expected.js @@ -0,0 +1,16 @@ +const Foo$2 = 'wrong Foo 1'; +const React$1 = 'wrong React 1'; +console.log(Foo$2, React$1); + +var react = { + createElement() { + console.log('createElement'); + } +}; + +const Foo$1 = () => {}; +console.log(/*#__PURE__*/react.createElement(Foo$1, null)); + +const Foo = 'wrong Foo 2'; +const React = 'wrong React 2'; +console.log(Foo, React); diff --git a/test/function/samples/jsx/unknown-mode/jsx.js b/test/function/samples/jsx/unknown-mode/jsx.js new file mode 100644 index 000000000..e4c7f5128 --- /dev/null +++ b/test/function/samples/jsx/unknown-mode/jsx.js @@ -0,0 +1 @@ +export default 'unused'; diff --git a/test/function/samples/jsx/unknown-mode/main.js b/test/function/samples/jsx/unknown-mode/main.js new file mode 100644 index 000000000..4b5671bbb --- /dev/null +++ b/test/function/samples/jsx/unknown-mode/main.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +console.log(); diff --git a/test/function/samples/jsx/unnecessary-import-source/_config.js b/test/function/samples/jsx/unnecessary-import-source/_config.js new file mode 100644 index 000000000..b6019d293 --- /dev/null +++ b/test/function/samples/jsx/unnecessary-import-source/_config.js @@ -0,0 +1,19 @@ +const path = require('node:path'); + +const ID_JSX = path.join(__dirname, 'jsx.js'); + +module.exports = defineTest({ + description: 'throws when preserving JSX syntax with an unnecessary import source', + options: { + jsx: { + importSource: ID_JSX, + mode: 'preserve' + } + }, + error: { + code: 'INVALID_OPTION', + message: + 'Invalid value for option "jsx" - when preserving JSX and specifying an importSource, you also need to specify a factory or fragment.', + url: 'https://rollupjs.org/configuration-options/#jsx' + } +}); diff --git a/test/function/samples/jsx/unnecessary-import-source/_expected.js b/test/function/samples/jsx/unnecessary-import-source/_expected.js new file mode 100644 index 000000000..0e6ceaa7c --- /dev/null +++ b/test/function/samples/jsx/unnecessary-import-source/_expected.js @@ -0,0 +1,16 @@ +const Foo$2 = 'wrong Foo 1'; +const React$1 = 'wrong React 1'; +console.log(Foo$2, React$1); + +var react = { + createElement() { + console.log('createElement'); + } +}; + +const Foo$1 = () => {}; +console.log(/*#__PURE__*/react.createElement(Foo$1, null)); + +const Foo = 'wrong Foo 2'; +const React = 'wrong React 2'; +console.log(Foo, React); diff --git a/test/function/samples/jsx/unnecessary-import-source/jsx.js b/test/function/samples/jsx/unnecessary-import-source/jsx.js new file mode 100644 index 000000000..e4c7f5128 --- /dev/null +++ b/test/function/samples/jsx/unnecessary-import-source/jsx.js @@ -0,0 +1 @@ +export default 'unused'; diff --git a/test/function/samples/jsx/unnecessary-import-source/main.js b/test/function/samples/jsx/unnecessary-import-source/main.js new file mode 100644 index 000000000..4b5671bbb --- /dev/null +++ b/test/function/samples/jsx/unnecessary-import-source/main.js @@ -0,0 +1,2 @@ +const Foo = () => {}; +console.log(); diff --git a/test/function/samples/options-hook/_config.js b/test/function/samples/options-hook/_config.js index 72badede7..ef6bdc039 100644 --- a/test/function/samples/options-hook/_config.js +++ b/test/function/samples/options-hook/_config.js @@ -15,6 +15,7 @@ module.exports = defineTest({ experimentalCacheExpiry: 10, experimentalLogSideEffects: false, input: ['used'], + jsx: false, logLevel: 'info', makeAbsoluteExternalsRelative: 'ifRelativeSource', maxParallelFileOps: 20, diff --git a/test/misc/optionList.js b/test/misc/optionList.js index 7ba1fee57..72caf132d 100644 --- a/test/misc/optionList.js +++ b/test/misc/optionList.js @@ -1,6 +1,6 @@ exports.input = - 'cache, context, experimentalCacheExpiry, experimentalLogSideEffects, external, input, logLevel, makeAbsoluteExternalsRelative, maxParallelFileOps, moduleContext, onLog, onwarn, perf, plugins, preserveEntrySignatures, preserveSymlinks, shimMissingExports, strictDeprecations, treeshake, watch'; + 'cache, context, experimentalCacheExpiry, experimentalLogSideEffects, external, input, jsx, logLevel, makeAbsoluteExternalsRelative, maxParallelFileOps, moduleContext, onLog, onwarn, perf, plugins, preserveEntrySignatures, preserveSymlinks, shimMissingExports, strictDeprecations, treeshake, watch'; exports.flags = - 'amd, assetFileNames, banner, bundleConfigAsCjs, c, cache, chunkFileNames, compact, config, configPlugin, context, d, dir, dynamicImportInCjs, e, entryFileNames, environment, esModule, experimentalCacheExpiry, experimentalLogSideEffects, experimentalMinChunkSize, exports, extend, external, externalImportAssertions, externalImportAttributes, externalLiveBindings, f, failAfterWarnings, file, filterLogs, footer, forceExit, format, freeze, g, generatedCode, globals, h, hashCharacters, hoistTransitiveImports, i, importAttributesKey, indent, inlineDynamicImports, input, interop, intro, logLevel, m, makeAbsoluteExternalsRelative, manualChunks, maxParallelFileOps, minifyInternalExports, moduleContext, n, name, noConflict, o, onLog, onwarn, outro, p, paths, perf, plugin, plugins, preserveEntrySignatures, preserveModules, preserveModulesRoot, preserveSymlinks, reexportProtoFromExternal, sanitizeFileName, shimMissingExports, silent, sourcemap, sourcemapBaseUrl, sourcemapExcludeSources, sourcemapFile, sourcemapFileNames, stdin, strict, strictDeprecations, systemNullSetters, treeshake, v, validate, virtualDirname, w, waitForBundleInput, watch'; + 'amd, assetFileNames, banner, bundleConfigAsCjs, c, cache, chunkFileNames, compact, config, configPlugin, context, d, dir, dynamicImportInCjs, e, entryFileNames, environment, esModule, experimentalCacheExpiry, experimentalLogSideEffects, experimentalMinChunkSize, exports, extend, external, externalImportAssertions, externalImportAttributes, externalLiveBindings, f, failAfterWarnings, file, filterLogs, footer, forceExit, format, freeze, g, generatedCode, globals, h, hashCharacters, hoistTransitiveImports, i, importAttributesKey, indent, inlineDynamicImports, input, interop, intro, jsx, logLevel, m, makeAbsoluteExternalsRelative, manualChunks, maxParallelFileOps, minifyInternalExports, moduleContext, n, name, noConflict, o, onLog, onwarn, outro, p, paths, perf, plugin, plugins, preserveEntrySignatures, preserveModules, preserveModulesRoot, preserveSymlinks, reexportProtoFromExternal, sanitizeFileName, shimMissingExports, silent, sourcemap, sourcemapBaseUrl, sourcemapExcludeSources, sourcemapFile, sourcemapFileNames, stdin, strict, strictDeprecations, systemNullSetters, treeshake, v, validate, virtualDirname, w, waitForBundleInput, watch'; exports.output = 'amd, assetFileNames, banner, chunkFileNames, compact, dir, dynamicImportInCjs, entryFileNames, esModule, experimentalMinChunkSize, exports, extend, externalImportAssertions, externalImportAttributes, externalLiveBindings, file, footer, format, freeze, generatedCode, globals, hashCharacters, hoistTransitiveImports, importAttributesKey, indent, inlineDynamicImports, interop, intro, manualChunks, minifyInternalExports, name, noConflict, outro, paths, plugins, preserveModules, preserveModulesRoot, reexportProtoFromExternal, sanitizeFileName, sourcemap, sourcemapBaseUrl, sourcemapExcludeSources, sourcemapFile, sourcemapFileNames, sourcemapIgnoreList, sourcemapPathTransform, strict, systemNullSetters, validate, virtualDirname'; diff --git a/test/utils.js b/test/utils.js index 43f1dcb75..85b09394f 100644 --- a/test/utils.js +++ b/test/utils.js @@ -23,6 +23,7 @@ const path = require('node:path'); const { platform, version } = require('node:process'); const { Parser } = require('acorn'); const { importAssertions } = require('acorn-import-assertions'); +const jsx = require('acorn-jsx'); const fixturify = require('fixturify'); if (!globalThis.defineTest) { @@ -454,7 +455,7 @@ exports.replaceDirectoryInStringifiedObject = function replaceDirectoryInStringi /** @type {boolean} */ exports.hasEsBuild = existsSync(path.join(__dirname, '../dist/es')); -const acornParser = Parser.extend(importAssertions); +const acornParser = Parser.extend(importAssertions, jsx()); exports.verifyAstPlugin = { name: 'verify-ast', @@ -489,6 +490,11 @@ const replaceStringifyValues = (key, value) => { const { decorators, ...rest } = value; return rest; } + case 'JSXText': { + // raw text is encoded differently in acorn + const { raw, ...nonRawProperties } = value; + return nonRawProperties; + } } return key.startsWith('_') diff --git a/wasm/bindings_wasm.d.ts b/wasm/bindings_wasm.d.ts index 8bd3e23c9..2c00d9fee 100644 --- a/wasm/bindings_wasm.d.ts +++ b/wasm/bindings_wasm.d.ts @@ -3,9 +3,10 @@ /** * @param {string} code * @param {boolean} allow_return_outside_function +* @param {boolean} jsx * @returns {Uint8Array} */ -export function parse(code: string, allow_return_outside_function: boolean): Uint8Array; +export function parse(code: string, allow_return_outside_function: boolean, jsx: boolean): Uint8Array; /** * @param {Uint8Array} input * @returns {string} @@ -26,7 +27,7 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl export interface InitOutput { readonly memory: WebAssembly.Memory; - readonly parse: (a: number, b: number, c: number, d: number) => void; + readonly parse: (a: number, b: number, c: number, d: number, e: number) => void; readonly xxhashBase64Url: (a: number, b: number) => void; readonly xxhashBase36: (a: number, b: number) => void; readonly xxhashBase16: (a: number, b: number) => void; diff --git a/wasm/bindings_wasm_bg.wasm.d.ts b/wasm/bindings_wasm_bg.wasm.d.ts index d9dad8cd6..7e56b53ff 100644 --- a/wasm/bindings_wasm_bg.wasm.d.ts +++ b/wasm/bindings_wasm_bg.wasm.d.ts @@ -1,7 +1,7 @@ /* tslint:disable */ /* eslint-disable */ export const memory: WebAssembly.Memory; -export function parse(a: number, b: number, c: number, d: number): void; +export function parse(a: number, b: number, c: number, d: number, e: number): void; export function xxhashBase64Url(a: number, b: number): void; export function xxhashBase36(a: number, b: number): void; export function xxhashBase16(a: number, b: number): void;