@rsvelte/vite-plugin-svelte-native 0.3.5 → 0.3.6

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/index.cjs CHANGED
@@ -4,36 +4,15 @@
4
4
 
5
5
  const { decodeEnvelope, decodeBatch } = require('./envelope.js');
6
6
  const { decodeParseEnvelope } = require('./parse-envelope.js');
7
+ const { resolveTriple } = require('./platform.cjs');
7
8
 
8
9
  const { platform, arch } = process;
9
10
 
10
- function resolveTriple() {
11
- if (platform === 'darwin') {
12
- if (arch === 'arm64') return 'darwin-arm64';
13
- if (arch === 'x64') return 'darwin-x64';
14
- } else if (platform === 'linux') {
15
- // Node 18+ exposes the runtime glibc version in the report header. An
16
- // empty value means we're on musl (Alpine, distroless, etc.).
17
- let isMusl = false;
18
- try {
19
- const header = process.report.getReport().header;
20
- isMusl = !header.glibcVersionRuntime;
21
- } catch {
22
- isMusl = false;
23
- }
24
- const libc = isMusl ? 'musl' : 'gnu';
25
- if (arch === 'x64') return `linux-x64-${libc}`;
26
- if (arch === 'arm64') return `linux-arm64-${libc}`;
27
- } else if (platform === 'win32') {
28
- if (arch === 'x64') return 'win32-x64-msvc';
29
- }
30
- return null;
31
- }
32
-
33
- const triple = resolveTriple();
11
+ const triple = resolveTriple(process);
34
12
  if (!triple) {
13
+ const muslHint = platform === 'linux' ? ' (musl/Alpine is not yet supported)' : '';
35
14
  throw new Error(
36
- `[@rsvelte/vite-plugin-svelte-native] Unsupported platform: ${platform}-${arch}. ` +
15
+ `[@rsvelte/vite-plugin-svelte-native] Unsupported platform: ${platform}-${arch}${muslHint}. ` +
37
16
  `Open an issue at https://github.com/baseballyama/rsvelte/issues if you'd like it supported.`,
38
17
  );
39
18
  }
@@ -284,6 +263,7 @@ module.exports.preprocess = binding.preprocess;
284
263
  module.exports.svelte2tsx = binding.svelte2tsx;
285
264
  module.exports.hmrDiff = binding.hmrDiff;
286
265
  module.exports.resolveId = binding.resolveId;
266
+ module.exports.buildInfo = binding.buildInfo;
287
267
  // Standalone parse surfaces. `parse` returns a JSON string (decode with
288
268
  // `JSON.parse`); `parseEnvelope` returns the raw-transfer Buffer that skips
289
269
  // `JSON.parse` entirely — decode it with `decodeParseEnvelope` (re-exported
package/index.d.ts CHANGED
@@ -101,6 +101,14 @@ export interface ModuleCompileOptions {
101
101
  warningFilter?: (warning: Warning) => boolean;
102
102
  }
103
103
 
104
+ /** Source revision embedded in the native addon at compile time. */
105
+ export interface BuildInfo {
106
+ commit: string;
107
+ dirty: boolean;
108
+ }
109
+
110
+ export function buildInfo(): BuildInfo;
111
+
104
112
  // ---------------------------------------------------------------------------
105
113
  // Diagnostics
106
114
  // ---------------------------------------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsvelte/vite-plugin-svelte-native",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "NAPI bindings to the rsvelte compiler — used by the @rsvelte vite-plugin-svelte shim",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -24,16 +24,17 @@
24
24
  "files": [
25
25
  "envelope.js",
26
26
  "parse-envelope.js",
27
+ "platform.cjs",
27
28
  "lib/bounds-check.js",
28
29
  "index.cjs",
29
30
  "index.d.ts"
30
31
  ],
31
32
  "optionalDependencies": {
32
- "@rsvelte/vite-plugin-svelte-native-darwin-arm64": "^0.3.5",
33
- "@rsvelte/vite-plugin-svelte-native-darwin-x64": "^0.3.5",
34
- "@rsvelte/vite-plugin-svelte-native-linux-arm64-gnu": "^0.3.5",
35
- "@rsvelte/vite-plugin-svelte-native-linux-x64-gnu": "^0.3.5",
36
- "@rsvelte/vite-plugin-svelte-native-win32-x64-msvc": "^0.3.5"
33
+ "@rsvelte/vite-plugin-svelte-native-darwin-arm64": "^0.3.6",
34
+ "@rsvelte/vite-plugin-svelte-native-darwin-x64": "^0.3.6",
35
+ "@rsvelte/vite-plugin-svelte-native-linux-arm64-gnu": "^0.3.6",
36
+ "@rsvelte/vite-plugin-svelte-native-linux-x64-gnu": "^0.3.6",
37
+ "@rsvelte/vite-plugin-svelte-native-win32-x64-msvc": "^0.3.6"
37
38
  },
38
39
  "publishConfig": {
39
40
  "access": "public"
package/platform.cjs ADDED
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ function resolveTriple(runtime) {
4
+ const { platform, arch } = runtime;
5
+ if (platform === 'darwin') {
6
+ if (arch === 'arm64') return 'darwin-arm64';
7
+ if (arch === 'x64') return 'darwin-x64';
8
+ } else if (platform === 'linux') {
9
+ let isMusl = false;
10
+ try {
11
+ isMusl = !runtime.report.getReport().header.glibcVersionRuntime;
12
+ } catch {}
13
+ if (isMusl) return null;
14
+ if (arch === 'x64') return 'linux-x64-gnu';
15
+ if (arch === 'arm64') return 'linux-arm64-gnu';
16
+ } else if (platform === 'win32' && arch === 'x64') {
17
+ return 'win32-x64-msvc';
18
+ }
19
+ return null;
20
+ }
21
+
22
+ module.exports = { resolveTriple };