rolldown-string 0.2.0 → 0.2.1

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/dist/index.d.ts CHANGED
@@ -7,8 +7,8 @@ type RolldownString = ObjectIntersection<MagicString, BindingMagicString>;
7
7
  declare function rolldownString(code: string, id: string, meta?: any): RolldownString;
8
8
  type Awaitable<T> = T | Promise<T>;
9
9
  type HandlerReturn = string | MagicString | BindingMagicString | RolldownString | void | undefined;
10
- type Handler<Meta> = (s: RolldownString, id: string, meta: Meta) => Awaitable<HandlerReturn>;
11
- declare function withMagicString<Meta>(handler: Handler<Meta>): (code: string, id: string, meta: Meta) => Awaitable<CodeTransform | undefined>;
10
+ type Handler<Args extends any[], This> = (this: This, s: RolldownString, id: string, ...args: Args) => Awaitable<HandlerReturn>;
11
+ declare function withMagicString<Args extends any[], This>(handler: Handler<Args, This>): (this: This, code: string, id: string, ...args: Args) => Awaitable<CodeTransform | undefined>;
12
12
  /**
13
13
  * The result of code transformation.
14
14
  */
package/dist/index.js CHANGED
@@ -5,9 +5,9 @@ function rolldownString(code, id, meta) {
5
5
  return meta?.magicString || new MagicString(code, { filename: id });
6
6
  }
7
7
  function withMagicString(handler) {
8
- return (code, id, meta) => {
9
- const s = rolldownString(code, id, meta);
10
- const res = handler(s, id, meta);
8
+ return function(code, id, ...args) {
9
+ const s = rolldownString(code, id, args.at(-1));
10
+ const res = handler.call(this, s, id, ...args);
11
11
  const callback = (res$1) => {
12
12
  if (typeof res$1 === "string") return { code: res$1 };
13
13
  return generateTransform(res$1 || s, id, !!res$1);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rolldown-string",
3
3
  "type": "module",
4
- "version": "0.2.0",
4
+ "version": "0.2.1",
5
5
  "description": "A compatibility layer for magic-string to work with Rolldown and other bundlers.",
6
6
  "author": "Kevin Deng <sxzz@sxzz.moe>",
7
7
  "license": "MIT",
@@ -43,13 +43,14 @@
43
43
  "@sxzz/eslint-config": "^7.4.3",
44
44
  "@sxzz/prettier-config": "^2.2.6",
45
45
  "@sxzz/test-utils": "^0.5.14",
46
- "@types/node": "^24.10.4",
47
- "@typescript/native-preview": "7.0.0-dev.20251214.1",
46
+ "@types/node": "^25.0.2",
47
+ "@typescript/native-preview": "7.0.0-dev.20251215.1",
48
48
  "bumpp": "^10.3.2",
49
49
  "eslint": "^9.39.2",
50
+ "magic-string-ast": "^1.0.3",
50
51
  "prettier": "^3.7.4",
51
52
  "rolldown": "1.0.0-beta.54",
52
- "tsdown": "^0.17.4",
53
+ "tsdown": "^0.18.0",
53
54
  "typescript": "^5.9.3",
54
55
  "vitest": "^4.0.15"
55
56
  },