@foldkit/vite-plugin 0.19.0-canary.9f0cbc8e89bf → 0.19.0-canary.bcac99077100

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.
@@ -1,9 +1,13 @@
1
1
  import { type SourceMap } from 'magic-string';
2
2
  import { type Plugin } from 'vite';
3
+ type ViteCompatibleSourceMap = SourceMap & {
4
+ file: string;
5
+ sourcesContent: Array<string> | undefined;
6
+ };
3
7
  /** Result of {@link transformViewIdentity}: rewritten code plus a source map. */
4
8
  export type ViewIdentityTransformResult = Readonly<{
5
9
  code: string;
6
- map: SourceMap;
10
+ map: ViteCompatibleSourceMap;
7
11
  }>;
8
12
  /**
9
13
  * Brands the return value of every function in a module with that function's
@@ -60,4 +64,5 @@ export declare const transformViewIdentity: (code: string, id: string, root: str
60
64
  * whose own `foldkit` alias would otherwise swallow the subpath.
61
65
  */
62
66
  export declare const foldkitViewIdentity: () => Plugin;
67
+ export {};
63
68
  //# sourceMappingURL=viewIdentity.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"viewIdentity.d.ts","sourceRoot":"","sources":["../src/viewIdentity.ts"],"names":[],"mappings":"AAAA,OAAoB,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAA;AAI1D,OAAO,EAAE,KAAK,MAAM,EAAY,MAAM,MAAM,CAAA;AA6a5C,iFAAiF;AACjF,MAAM,MAAM,2BAA2B,GAAG,QAAQ,CAAC;IACjD,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,SAAS,CAAA;CACf,CAAC,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,qBAAqB,SAC1B,MAAM,MACR,MAAM,QACJ,MAAM,YACF,QAAQ,CAAC;IACjB,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC,CAAC,KACD,2BAA2B,GAAG,IAyChC,CAAA;AA8DD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,QAAO,MA0CtC,CAAA"}
1
+ {"version":3,"file":"viewIdentity.d.ts","sourceRoot":"","sources":["../src/viewIdentity.ts"],"names":[],"mappings":"AAAA,OAAoB,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAA;AAI1D,OAAO,EAAE,KAAK,MAAM,EAAY,MAAM,MAAM,CAAA;AAgb5C,KAAK,uBAAuB,GAAG,SAAS,GAAG;IACzC,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,CAAA;CAC1C,CAAA;AAwBD,iFAAiF;AACjF,MAAM,MAAM,2BAA2B,GAAG,QAAQ,CAAC;IACjD,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,uBAAuB,CAAA;CAC7B,CAAC,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,qBAAqB,SAC1B,MAAM,MACR,MAAM,QACJ,MAAM,YACF,QAAQ,CAAC;IACjB,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC,CAAC,KACD,2BAA2B,GAAG,IA2ChC,CAAA;AA8DD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,QAAO,MA0CtC,CAAA"}
@@ -280,6 +280,17 @@ const uniqueBrandAlias = (code) => {
280
280
  }
281
281
  }
282
282
  };
283
+ const isViteCompatibleSourceMap = (sourceMap) => sourceMap.sourcesContent === undefined ||
284
+ sourceMap.sourcesContent.every(content => content !== null);
285
+ const toViteCompatibleSourceMap = (sourceMap) => {
286
+ if (sourceMap.sourcesContent !== undefined) {
287
+ sourceMap.sourcesContent = sourceMap.sourcesContent.map(content => content ?? '');
288
+ }
289
+ if (isViteCompatibleSourceMap(sourceMap)) {
290
+ return sourceMap;
291
+ }
292
+ throw new Error('Failed to normalize the generated source map');
293
+ };
283
294
  /**
284
295
  * Brands the return value of every function in a module with that function's
285
296
  * identity via `brandViewResult` from `foldkit/brand`.
@@ -357,7 +368,7 @@ export const transformViewIdentity = (code, id, root, options) => {
357
368
  }
358
369
  return {
359
370
  code: sourceText.toString(),
360
- map: sourceText.generateMap({ hires: 'boundary' }),
371
+ map: toViteCompatibleSourceMap(sourceText.generateMap({ hires: 'boundary' })),
361
372
  };
362
373
  };
363
374
  // RESOLUTION
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foldkit/vite-plugin",
3
- "version": "0.19.0-canary.9f0cbc8e89bf",
3
+ "version": "0.19.0-canary.bcac99077100",
4
4
  "description": "Vite plugin for Foldkit hot module reloading with state preservation",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -17,24 +17,24 @@
17
17
  ],
18
18
  "peerDependencies": {
19
19
  "effect": "4.0.0-rc.112",
20
- "foldkit": "0.154.0-canary.9f0cbc8e89bf",
20
+ "foldkit": "0.154.0-canary.bcac99077100",
21
21
  "vite": "^7.0.0 || ^8.0.0"
22
22
  },
23
23
  "dependencies": {
24
- "magic-string": "^0.30.21",
24
+ "magic-string": "^1.2.3",
25
25
  "ws": "^8.21.3"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "^26.4.0",
29
29
  "@types/ws": "^8.18.1",
30
30
  "effect": "4.0.0-rc.112",
31
- "happy-dom": "^20.11.8",
31
+ "happy-dom": "^20.11.12",
32
32
  "rimraf": "^6.1.3",
33
33
  "typescript": "^7.0.2",
34
34
  "vite": "^8.2.2",
35
35
  "vite7": "npm:vite@^7.3.6",
36
36
  "vitest": "^4.1.11",
37
- "foldkit": "0.154.0-canary.9f0cbc8e89bf"
37
+ "foldkit": "0.154.0-canary.bcac99077100"
38
38
  },
39
39
  "keywords": [
40
40
  "vite",