@fervid/napi 0.1.3 → 0.2.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.
Files changed (3) hide show
  1. package/index.d.ts +77 -9
  2. package/index.js +27 -3
  3. package/package.json +26 -26
package/index.d.ts CHANGED
@@ -3,12 +3,80 @@
3
3
 
4
4
  /* auto-generated by NAPI-RS */
5
5
 
6
- export interface CompileSyncOptions {
7
- isProd: boolean
8
- }
9
- export function compileSync(source: string, options?: CompileSyncOptions | undefined | null): string
10
- export function compileAsync(
11
- source: string,
12
- options?: CompileSyncOptions | undefined | null,
13
- signal?: AbortSignal | undefined | null,
14
- ): Promise<unknown>
6
+ export interface FervidJsCompilerOptions {
7
+ /** Apply production optimizations. Default: false */
8
+ isProduction?: boolean
9
+ /**
10
+ * TODO Support SSR
11
+ * Enable SSR. Default: false
12
+ */
13
+ ssr?: boolean
14
+ /**
15
+ * TODO Find a performant solution to source-maps
16
+ * TODO Implement source-maps
17
+ * Enable source maps
18
+ */
19
+ sourceMap?: boolean
20
+ /** Script compilation options */
21
+ script?: FervidJsCompilerOptionsScript
22
+ /** Template compilation options */
23
+ template?: FervidJsCompilerOptionsTemplate
24
+ /** Style compilation options */
25
+ style?: FervidJsCompilerOptionsStyle
26
+ /**
27
+ * TODO Regex handling logic is needed (plus sanitation)
28
+ * TODO Implement custom element mode (low priority)
29
+ * Transform Vue SFCs into custom elements.
30
+ * - `true`: all `*.vue` imports are converted into custom elements
31
+ * - `string | RegExp`: matched files are converted into custom elements
32
+ * Default: files ending with `.ce.vue`
33
+ */
34
+ customElement?: undefined
35
+ }
36
+ export interface FervidJsCompilerOptionsTemplate {}
37
+ export interface FervidJsCompilerOptionsScript {
38
+ /**
39
+ * Ignored
40
+ * Hoist <script setup> static constants.
41
+ * - Only enabled when one `<script setup>` exists.
42
+ * Default: true
43
+ */
44
+ hoistStatic?: boolean
45
+ }
46
+ export interface FervidJsCompilerOptionsStyle {
47
+ /** Ignored */
48
+ trim?: boolean
49
+ }
50
+ export interface CompileResult {
51
+ code: string
52
+ styles: Array<Style>
53
+ errors: Array<SerializedError>
54
+ customBlocks: Array<CustomBlock>
55
+ }
56
+ export interface Style {
57
+ code: string
58
+ isCompiled: boolean
59
+ lang: string
60
+ isScoped: boolean
61
+ }
62
+ export interface CustomBlock {
63
+ content: string
64
+ lo: number
65
+ hi: number
66
+ tagName: string
67
+ }
68
+ export interface SerializedError {
69
+ lo: number
70
+ hi: number
71
+ message: string
72
+ }
73
+ export type FervidJsCompiler = Compiler
74
+ /** Fervid: a compiler for Vue.js written in Rust */
75
+ export class Compiler {
76
+ isProduction: boolean
77
+ ssr: boolean
78
+ sourceMap: boolean
79
+ constructor(options?: FervidJsCompilerOptions | undefined | null)
80
+ compileSync(source: string): CompileResult
81
+ compileAsync(source: string, signal?: AbortSignal | undefined | null): Promise<unknown>
82
+ }
package/index.js CHANGED
@@ -219,6 +219,31 @@ switch (platform) {
219
219
  loadError = e
220
220
  }
221
221
  break
222
+ case 'riscv64':
223
+ if (isMusl()) {
224
+ localFileExisted = existsSync(join(__dirname, 'napi.linux-riscv64-musl.node'))
225
+ try {
226
+ if (localFileExisted) {
227
+ nativeBinding = require('./napi.linux-riscv64-musl.node')
228
+ } else {
229
+ nativeBinding = require('@fervid/napi-linux-riscv64-musl')
230
+ }
231
+ } catch (e) {
232
+ loadError = e
233
+ }
234
+ } else {
235
+ localFileExisted = existsSync(join(__dirname, 'napi.linux-riscv64-gnu.node'))
236
+ try {
237
+ if (localFileExisted) {
238
+ nativeBinding = require('./napi.linux-riscv64-gnu.node')
239
+ } else {
240
+ nativeBinding = require('@fervid/napi-linux-riscv64-gnu')
241
+ }
242
+ } catch (e) {
243
+ loadError = e
244
+ }
245
+ }
246
+ break
222
247
  default:
223
248
  throw new Error(`Unsupported architecture on Linux: ${arch}`)
224
249
  }
@@ -234,7 +259,6 @@ if (!nativeBinding) {
234
259
  throw new Error(`Failed to load native binding`)
235
260
  }
236
261
 
237
- const { compileSync, compileAsync } = nativeBinding
262
+ const { Compiler } = nativeBinding
238
263
 
239
- module.exports.compileSync = compileSync
240
- module.exports.compileAsync = compileAsync
264
+ module.exports.Compiler = Compiler
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fervid/napi",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "All-in-One Vue compiler written in Rust",
5
5
  "main": "index.js",
6
6
  "repository": "git@github.com:phoenix-ru/fervid.git",
@@ -59,27 +59,27 @@
59
59
  "version": "napi version"
60
60
  },
61
61
  "devDependencies": {
62
- "@napi-rs/cli": "^2.16.5",
62
+ "@napi-rs/cli": "^2.17.0",
63
63
  "@swc-node/register": "^1.6.8",
64
- "@swc/core": "^1.3.99",
64
+ "@swc/core": "^1.3.100",
65
65
  "@taplo/cli": "^0.5.2",
66
- "@types/node": "^20.10.0",
67
- "@typescript-eslint/eslint-plugin": "^6.13.0",
68
- "@typescript-eslint/parser": "^6.13.0",
69
- "@vue/compiler-sfc": "^3.3.9",
66
+ "@types/node": "^20.10.4",
67
+ "@typescript-eslint/eslint-plugin": "^6.14.0",
68
+ "@typescript-eslint/parser": "^6.14.0",
69
+ "@vue/compiler-sfc": "^3.3.11",
70
70
  "benny": "^3.7.1",
71
71
  "chalk": "^5.3.0",
72
- "eslint": "^8.54.0",
73
- "eslint-config-prettier": "^9.0.0",
74
- "eslint-plugin-import": "^2.29.0",
72
+ "eslint": "^8.55.0",
73
+ "eslint-config-prettier": "^9.1.0",
74
+ "eslint-plugin-import": "^2.29.1",
75
75
  "eslint-plugin-prettier": "^5.0.1",
76
76
  "husky": "^8.0.3",
77
77
  "kleur": "^4.1.5",
78
78
  "lint-staged": "^14.0.1",
79
79
  "npm-run-all": "^4.1.5",
80
- "prettier": "^3.1.0",
81
- "typescript": "^5.3.2",
82
- "vitest": "^0.34.6"
80
+ "prettier": "^3.1.1",
81
+ "typescript": "^5.3.3",
82
+ "vitest": "^1.0.4"
83
83
  },
84
84
  "lint-staged": {
85
85
  "*.@(js|ts|tsx)": [
@@ -100,19 +100,19 @@
100
100
  "arrowParens": "always"
101
101
  },
102
102
  "optionalDependencies": {
103
- "@fervid/napi-win32-x64-msvc": "0.1.3",
104
- "@fervid/napi-darwin-x64": "0.1.3",
105
- "@fervid/napi-linux-x64-gnu": "0.1.3",
106
- "@fervid/napi-linux-x64-musl": "0.1.3",
107
- "@fervid/napi-linux-arm64-gnu": "0.1.3",
108
- "@fervid/napi-win32-ia32-msvc": "0.1.3",
109
- "@fervid/napi-linux-arm-gnueabihf": "0.1.3",
110
- "@fervid/napi-darwin-arm64": "0.1.3",
111
- "@fervid/napi-android-arm64": "0.1.3",
112
- "@fervid/napi-freebsd-x64": "0.1.3",
113
- "@fervid/napi-linux-arm64-musl": "0.1.3",
114
- "@fervid/napi-win32-arm64-msvc": "0.1.3",
115
- "@fervid/napi-android-arm-eabi": "0.1.3"
103
+ "@fervid/napi-win32-x64-msvc": "0.2.0",
104
+ "@fervid/napi-darwin-x64": "0.2.0",
105
+ "@fervid/napi-linux-x64-gnu": "0.2.0",
106
+ "@fervid/napi-linux-x64-musl": "0.2.0",
107
+ "@fervid/napi-linux-arm64-gnu": "0.2.0",
108
+ "@fervid/napi-win32-ia32-msvc": "0.2.0",
109
+ "@fervid/napi-linux-arm-gnueabihf": "0.2.0",
110
+ "@fervid/napi-darwin-arm64": "0.2.0",
111
+ "@fervid/napi-android-arm64": "0.2.0",
112
+ "@fervid/napi-freebsd-x64": "0.2.0",
113
+ "@fervid/napi-linux-arm64-musl": "0.2.0",
114
+ "@fervid/napi-win32-arm64-msvc": "0.2.0",
115
+ "@fervid/napi-android-arm-eabi": "0.2.0"
116
116
  },
117
117
  "packageManager": "yarn@4.0.2",
118
118
  "workspaces": [