@swc-next/core-binding-wasm 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swc-next/core-binding-wasm",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "The extensible Node.js API for SWC Next",
5
5
  "type": "module",
6
6
  "main": "./swc-next-core.node.mjs",
@@ -5,28 +5,8 @@ const langValues = ["js", "ts", "jsx", "tsx", "dts"];
5
5
 
6
6
  const sourceTypeValues = ["module", "script", "commonjs", "unambiguous"];
7
7
 
8
- export function langFromPath(path) {
9
- const call = getFunction("__swc_lang_from_path");
10
- if (typeof path !== "string") throw new TypeError("path must be a string");
11
- const result = (withEncodedString(
12
- path,
13
- (pathPointer) => call(pathPointer),
14
- )) >>> 0;
15
- return decodeEnum(result, langValues, "lang");
16
- }
17
-
18
- export function parseSync(source, sourceUtf16Len, options) {
19
- const call = getFunction("__swc_parse_sync");
20
- if (!(source instanceof Uint8Array)) throw new TypeError("source must be a Uint8Array");
21
- const resultPointer = (withEncodedBytes(
22
- source,
23
- (sourcePointer) => call(sourcePointer, encodeU32(sourceUtf16Len, "sourceUtf16Len"), encodeU32(options, "options")),
24
- )) >>> 0;
25
- return takeBytes(resultPointer);
26
- }
27
-
28
- export function printSync(header, spans, kinds, payloads, extra, strings, options) {
29
- const call = getFunction("__swc_print_sync");
8
+ export function generateSync(header, spans, kinds, payloads, extra, strings, options) {
9
+ const call = getFunction("__swc_generate_sync");
30
10
  if (!(header instanceof Uint8Array)) throw new TypeError("header must be a Uint8Array");
31
11
  if (!(spans instanceof Uint8Array)) throw new TypeError("spans must be a Uint8Array");
32
12
  if (!(kinds instanceof Uint8Array)) throw new TypeError("kinds must be a Uint8Array");
@@ -56,6 +36,26 @@ export function printSync(header, spans, kinds, payloads, extra, strings, option
56
36
  return decodeString(payload);
57
37
  }
58
38
 
39
+ export function langFromPath(path) {
40
+ const call = getFunction("__swc_lang_from_path");
41
+ if (typeof path !== "string") throw new TypeError("path must be a string");
42
+ const result = (withEncodedString(
43
+ path,
44
+ (pathPointer) => call(pathPointer),
45
+ )) >>> 0;
46
+ return decodeEnum(result, langValues, "lang");
47
+ }
48
+
49
+ export function parseSync(source, sourceUtf16Len, options) {
50
+ const call = getFunction("__swc_parse_sync");
51
+ if (!(source instanceof Uint8Array)) throw new TypeError("source must be a Uint8Array");
52
+ const resultPointer = (withEncodedBytes(
53
+ source,
54
+ (sourcePointer) => call(sourcePointer, encodeU32(sourceUtf16Len, "sourceUtf16Len"), encodeU32(options, "options")),
55
+ )) >>> 0;
56
+ return takeBytes(resultPointer);
57
+ }
58
+
59
59
  export function sourceTypeFromPath(path) {
60
60
  const call = getFunction("__swc_source_type_from_path");
61
61
  if (typeof path !== "string") throw new TypeError("path must be a string");
@@ -66,6 +66,20 @@ export function sourceTypeFromPath(path) {
66
66
  return decodeEnum(result, sourceTypeValues, "source type");
67
67
  }
68
68
 
69
+ export function transformSync(source, sourceUtf16Len, options) {
70
+ const call = getFunction("__swc_transform_sync");
71
+ if (!(source instanceof Uint8Array)) throw new TypeError("source must be a Uint8Array");
72
+ if (!(options instanceof Uint8Array)) throw new TypeError("options must be a Uint8Array");
73
+ const resultPointer = (withEncodedBytes(
74
+ source,
75
+ (sourcePointer) => withEncodedBytes(
76
+ options,
77
+ (optionsPointer) => call(sourcePointer, encodeU32(sourceUtf16Len, "sourceUtf16Len"), optionsPointer),
78
+ ),
79
+ )) >>> 0;
80
+ return takeBytes(resultPointer);
81
+ }
82
+
69
83
  function encodeU32(value, name) {
70
84
  if (!Number.isInteger(value) || value < 0 || value > 0xffffffff) {
71
85
  throw new TypeError(`${name} must be an unsigned 32-bit integer`);
@@ -3,7 +3,7 @@ import { initializeAsync } from "./swc-next-core.runtime.mjs";
3
3
 
4
4
  export * from "./swc-next-core.bridge.mjs";
5
5
 
6
- export const version = "0.6.0";
6
+ export const version = "0.7.0";
7
7
 
8
8
  export default function init() {
9
9
  return initializeAsync(() =>
@@ -7,7 +7,7 @@ initializeSync(wasm);
7
7
 
8
8
  export * from "./swc-next-core.bridge.mjs";
9
9
 
10
- export const version = "0.6.0";
10
+ export const version = "0.7.0";
11
11
 
12
12
  export default function init() {
13
13
  return Promise.resolve();
@@ -7,7 +7,7 @@ initializeSync(readFileSync(new URL("./swc-next-core.wasm", import.meta.url)));
7
7
 
8
8
  export * from "./swc-next-core.bridge.mjs";
9
9
 
10
- export const version = "0.6.0";
10
+ export const version = "0.7.0";
11
11
 
12
12
  export default function init() {
13
13
  return Promise.resolve();
@@ -1,6 +1,6 @@
1
1
  // Runtime support for generated SWC Next WebAssembly bindings.
2
2
  const textEncoder = new TextEncoder();
3
- const textDecoder = new TextDecoder();
3
+ const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true });
4
4
  let wasm;
5
5
  let initialization;
6
6
 
Binary file