oxc/wasm/parser
renovate[bot] 8cf9cf9919
chore(deps): update npm packages (#5392)
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [axios](https://axios-http.com)
([source](https://togithub.com/axios/axios)) | [`1.7.5` ->
`1.7.7`](https://renovatebot.com/diffs/npm/axios/1.7.5/1.7.7) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/axios/1.7.7?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/axios/1.7.7?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/axios/1.7.5/1.7.7?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/axios/1.7.5/1.7.7?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| [pnpm](https://pnpm.io) ([source](https://togithub.com/pnpm/pnpm)) |
[`9.8.0` -> `9.9.0`](https://renovatebot.com/diffs/npm/pnpm/9.8.0/9.9.0)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/pnpm/9.9.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/pnpm/9.9.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/pnpm/9.8.0/9.9.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/pnpm/9.8.0/9.9.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>axios/axios (axios)</summary>

###
[`v1.7.7`](https://togithub.com/axios/axios/blob/HEAD/CHANGELOG.md#177-2024-08-31)

[Compare
Source](https://togithub.com/axios/axios/compare/v1.7.6...v1.7.7)

##### Bug Fixes

- **fetch:** fix stream handling in Safari by fallback to using a stream
reader instead of an async iterator;
([#&#8203;6584](https://togithub.com/axios/axios/issues/6584))
([d198085](d1980854fe))
- **http:** fixed support for IPv6 literal strings in url
([#&#8203;5731](https://togithub.com/axios/axios/issues/5731))
([364993f](364993f0d8))

##### Contributors to this release

- <img
src="https://avatars.githubusercontent.com/u/10539109?v&#x3D;4&amp;s&#x3D;18"
alt="avatar" width="18"/> [Rishi556](https://togithub.com/Rishi556
"+39/-1 (#&#8203;5731 )")
- <img
src="https://avatars.githubusercontent.com/u/12586868?v&#x3D;4&amp;s&#x3D;18"
alt="avatar" width="18"/> [Dmitriy
Mozgovoy](https://togithub.com/DigitalBrainJS "+27/-7 (#&#8203;6584 )")

###
[`v1.7.6`](https://togithub.com/axios/axios/blob/HEAD/CHANGELOG.md#176-2024-08-30)

[Compare
Source](https://togithub.com/axios/axios/compare/v1.7.5...v1.7.6)

##### Bug Fixes

- **fetch:** fix content length calculation for FormData payload;
([#&#8203;6524](https://togithub.com/axios/axios/issues/6524))
([085f568](085f56861a))
- **fetch:** optimize signals composing logic;
([#&#8203;6582](https://togithub.com/axios/axios/issues/6582))
([df9889b](df9889b83c))

##### Contributors to this release

- <img
src="https://avatars.githubusercontent.com/u/12586868?v&#x3D;4&amp;s&#x3D;18"
alt="avatar" width="18"/> [Dmitriy
Mozgovoy](https://togithub.com/DigitalBrainJS "+98/-46 (#&#8203;6582 )")
- <img
src="https://avatars.githubusercontent.com/u/3534453?v&#x3D;4&amp;s&#x3D;18"
alt="avatar" width="18"/> [Jacques
Germishuys](https://togithub.com/jacquesg "+5/-1 (#&#8203;6524 )")
- <img
src="https://avatars.githubusercontent.com/u/53894505?v&#x3D;4&amp;s&#x3D;18"
alt="avatar" width="18"/> [kuroino721](https://togithub.com/kuroino721
"+3/-1 (#&#8203;6575 )")

</details>

<details>
<summary>pnpm/pnpm (pnpm)</summary>

### [`v9.9.0`](https://togithub.com/pnpm/pnpm/compare/v9.8.0...v9.9.0)

[Compare Source](https://togithub.com/pnpm/pnpm/compare/v9.8.0...v9.9.0)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 10am on monday" in timezone
Asia/Shanghai, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://togithub.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/oxc-project/oxc).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC41Ni4wIiwidXBkYXRlZEluVmVyIjoiMzguNTYuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-01 19:31:44 +00:00
..
src refactor(wasm): add source_type for parser, replace class options with plain object (#5217) 2024-08-26 15:08:35 +08:00
.gitignore feat: setup wasm parser for npm (#2221) 2024-01-30 21:40:10 +08:00
Cargo.toml chore: format wasm/parser/Cargo.toml 2024-03-14 17:25:53 +08:00
CHANGELOG.md chore: regenerate changelogs with commit id and author 2024-06-07 01:22:28 +08:00
package.json chore(deps): update npm packages (#5392) 2024-09-01 19:31:44 +00:00
pnpm-lock.yaml chore: pin pnpm version & upgrade lockfile version (#5200) 2024-08-25 22:57:33 +08:00
README.md Publish @oxc-parser/wasm with web and node builds (#2916) 2024-04-08 15:47:02 +08:00
test-node.mjs Publish @oxc-parser/wasm with web and node builds (#2916) 2024-04-08 15:47:02 +08:00

About

Experimental wasm package for the oxc parser, with full TypeScript typings support.

This package is built with different wasm-pack's target builds:

  • wasm-pack build --target web for bundler (webpack / vite) consumption.
  • wasm-pack build --target nodejs for node.js

And exports the files as

"main": "./node/oxc_parser_wasm.js",
"browser": "./web/oxc_parser_wasm.js",
"types": "./node/oxc_parser_wasm.d.ts",

Checkout oxc-parser for usage in node.js via napi bindings.

Source code: https://github.com/oxc-project/oxc/tree/main/wasm/parser

Usage

import initWasm, { parseSync } from "@oxc-parser/wasm";

async function main() {
  await initWasm();

  const code = "let foo";
  const result = parseSync(code, { sourceFilename: "test.ts" });
  console.log(result);
}

main();

Notes

UTF8 vs UTF16 byte offsets

The span value returned from the ASTs and diagnostics is in UTF8 byte offsets. Converting to UTF16 byte offsets:

let sourceTextUtf8 = new TextEncoder().encode(sourceText);

const convertToUtf8 = (sourceTextUtf8, d) => {
  return new TextDecoder().decode(sourceTextUtf8.slice(0, d)).length;
}

const diagnostics = result.errors.map((d) => ({
    from: convertToUtf8(sourceTextUtf8, d.start),
    to: convertToUtf8(sourceTextUtf8, d.end),
    severity: d.severity.toLowerCase(),
    message: d.message,
}));

Vite

wasm-pack build --target web is used for the wasm build.

You may need something like https://github.com/nshen/vite-plugin-wasm-pack to get it working with vite, otherwise vite will load the wasm file as a HTML file causing a CompileError: WebAssembly.instantiate(): expected magic word error.