@fervid/napi 0.3.0 → 0.4.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/index.d.ts +58 -0
- package/index.js +2 -1
- package/package.json +30 -30
package/index.d.ts
CHANGED
@@ -55,8 +55,18 @@ export interface FervidCompileOptions {
|
|
55
55
|
id: string
|
56
56
|
/** Filename is used for automatic component name inference and self-referential imports */
|
57
57
|
filename: string
|
58
|
+
/**
|
59
|
+
* Is the currently compiled file a custom element.
|
60
|
+
* To give more flexibility, this option only accepts a boolean, allowing to compute the value on the JS side,
|
61
|
+
* instead of relying on a hacky RegEx/JS function calls from the Fervid side.
|
62
|
+
*/
|
63
|
+
isCustomElement?: boolean
|
58
64
|
/** Generate a const instead of default export */
|
59
65
|
genDefaultAs?: string
|
66
|
+
/** Enable, disable or error on props destructure */
|
67
|
+
propsDestructure?: boolean | 'error'
|
68
|
+
/** Whether setup bindings need to be serialized */
|
69
|
+
outputSetupBindings?: boolean
|
60
70
|
}
|
61
71
|
export interface CompileResult {
|
62
72
|
code: string
|
@@ -64,6 +74,7 @@ export interface CompileResult {
|
|
64
74
|
errors: Array<SerializedError>
|
65
75
|
customBlocks: Array<CustomBlock>
|
66
76
|
sourceMap?: string
|
77
|
+
setupBindings?: Record<string, BindingTypes> | undefined
|
67
78
|
}
|
68
79
|
export interface Style {
|
69
80
|
code: string
|
@@ -82,6 +93,53 @@ export interface SerializedError {
|
|
82
93
|
hi: number
|
83
94
|
message: string
|
84
95
|
}
|
96
|
+
/**
|
97
|
+
* This is a copied enum from `fervid_core` with `napi` implementation to avoid littering the core crate.
|
98
|
+
*
|
99
|
+
* The type of a binding (or identifier) which is used to show where this binding came from,
|
100
|
+
* e.g. `Data` is for Options API `data()`, `SetupRef` if for `ref`s and `computed`s in Composition API.
|
101
|
+
*
|
102
|
+
* <https://github.com/vuejs/core/blob/020851e57d9a9f727c6ea07e9c1575430af02b73/packages/compiler-core/src/options.ts#L76>
|
103
|
+
*/
|
104
|
+
export const enum BindingTypes {
|
105
|
+
/** returned from data() */
|
106
|
+
DATA = 0,
|
107
|
+
/** declared as a prop */
|
108
|
+
PROPS = 1,
|
109
|
+
/**
|
110
|
+
* a local alias of a `<script setup>` destructured prop.
|
111
|
+
* the original is stored in __propsAliases of the bindingMetadata object.
|
112
|
+
*/
|
113
|
+
PROPS_ALIASED = 2,
|
114
|
+
/** a let binding (may or may not be a ref) */
|
115
|
+
SETUP_LET = 3,
|
116
|
+
/**
|
117
|
+
* a const binding that can never be a ref.
|
118
|
+
* these bindings don't need `unref()` calls when processed in inlined
|
119
|
+
* template expressions.
|
120
|
+
*/
|
121
|
+
SETUP_CONST = 4,
|
122
|
+
/** a const binding that does not need `unref()`, but may be mutated. */
|
123
|
+
SETUP_REACTIVE_CONST = 5,
|
124
|
+
/** a const binding that may be a ref */
|
125
|
+
SETUP_MAYBE_REF = 6,
|
126
|
+
/** bindings that are guaranteed to be refs */
|
127
|
+
SETUP_REF = 7,
|
128
|
+
/** declared by other options, e.g. computed, inject */
|
129
|
+
OPTIONS = 8,
|
130
|
+
/** a literal constant, e.g. 'foo', 1, true */
|
131
|
+
LITERAL_CONST = 9,
|
132
|
+
/** a `.vue` import or `defineComponent` call */
|
133
|
+
COMPONENT = 10,
|
134
|
+
/** an import which is not a `.vue` or `from 'vue'` */
|
135
|
+
IMPORTED = 11,
|
136
|
+
/** a variable from the template */
|
137
|
+
TEMPLATE_LOCAL = 12,
|
138
|
+
/** a variable in the global Javascript context, e.g. `Array` or `undefined` */
|
139
|
+
JS_GLOBAL = 13,
|
140
|
+
/** a non-resolved variable, presumably from the global Vue context */
|
141
|
+
UNRESOLVED = 14,
|
142
|
+
}
|
85
143
|
export type FervidJsCompiler = Compiler
|
86
144
|
/** Fervid: a compiler for Vue.js written in Rust */
|
87
145
|
export declare class Compiler {
|
package/index.js
CHANGED
@@ -284,6 +284,7 @@ if (!nativeBinding) {
|
|
284
284
|
throw new Error(`Failed to load native binding`)
|
285
285
|
}
|
286
286
|
|
287
|
-
const { Compiler } = nativeBinding
|
287
|
+
const { Compiler, BindingTypes } = nativeBinding
|
288
288
|
|
289
289
|
module.exports.Compiler = Compiler
|
290
|
+
module.exports.BindingTypes = BindingTypes
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fervid/napi",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.4.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",
|
@@ -45,6 +45,7 @@
|
|
45
45
|
},
|
46
46
|
"scripts": {
|
47
47
|
"artifacts": "napi artifacts",
|
48
|
+
"dev": "chmod +x watch.sh && cargo watch -w '../../crates' -i '*.js' -i '*.d.ts' -s './watch.sh'",
|
48
49
|
"bench": "node -r @swc-node/register benchmark/bench.ts",
|
49
50
|
"build": "napi build --platform --release --pipe \"prettier -w\"",
|
50
51
|
"build:debug": "napi build --platform --pipe \"prettier -w\"",
|
@@ -59,28 +60,27 @@
|
|
59
60
|
"version": "napi version"
|
60
61
|
},
|
61
62
|
"devDependencies": {
|
62
|
-
"@babel/parser": "^7.
|
63
|
+
"@babel/parser": "^7.27.1",
|
63
64
|
"@napi-rs/cli": "^2.18.4",
|
64
|
-
"@swc-node/register": "^1.10.
|
65
|
-
"@swc/core": "^1.
|
65
|
+
"@swc-node/register": "^1.10.10",
|
66
|
+
"@swc/core": "^1.11.24",
|
66
67
|
"@taplo/cli": "^0.7.0",
|
67
|
-
"@types/node": "^20.
|
68
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
69
|
-
"@typescript-eslint/parser": "^8.
|
70
|
-
"@vue/compiler-sfc": "^3.
|
68
|
+
"@types/node": "^20.17.32",
|
69
|
+
"@typescript-eslint/eslint-plugin": "^8.31.1",
|
70
|
+
"@typescript-eslint/parser": "^8.31.1",
|
71
|
+
"@vue/compiler-sfc": "^3.5.13",
|
71
72
|
"benny": "^3.7.1",
|
72
|
-
"chalk": "^5.
|
73
|
-
"eslint": "^9.
|
73
|
+
"chalk": "^5.4.1",
|
74
|
+
"eslint": "^9.25.1",
|
74
75
|
"eslint-config-prettier": "^9.1.0",
|
75
|
-
"eslint-plugin-import": "^2.
|
76
|
-
"eslint-plugin-prettier": "^5.2.
|
77
|
-
"husky": "^
|
76
|
+
"eslint-plugin-import": "^2.31.0",
|
77
|
+
"eslint-plugin-prettier": "^5.2.6",
|
78
|
+
"husky": "^9.1.7",
|
78
79
|
"kleur": "^4.1.5",
|
79
|
-
"lint-staged": "^15.
|
80
|
-
"
|
81
|
-
"prettier": "^3.2.5",
|
80
|
+
"lint-staged": "^15.5.1",
|
81
|
+
"prettier": "^3.5.3",
|
82
82
|
"typescript": "^5.5.4",
|
83
|
-
"vitest": "^
|
83
|
+
"vitest": "^3.1.2"
|
84
84
|
},
|
85
85
|
"lint-staged": {
|
86
86
|
"*.@(js|ts|tsx)": [
|
@@ -101,19 +101,19 @@
|
|
101
101
|
"arrowParens": "always"
|
102
102
|
},
|
103
103
|
"optionalDependencies": {
|
104
|
-
"@fervid/napi-win32-x64-msvc": "0.
|
105
|
-
"@fervid/napi-darwin-x64": "0.
|
106
|
-
"@fervid/napi-linux-x64-gnu": "0.
|
107
|
-
"@fervid/napi-linux-x64-musl": "0.
|
108
|
-
"@fervid/napi-linux-arm64-gnu": "0.
|
109
|
-
"@fervid/napi-win32-ia32-msvc": "0.
|
110
|
-
"@fervid/napi-linux-arm-gnueabihf": "0.
|
111
|
-
"@fervid/napi-darwin-arm64": "0.
|
112
|
-
"@fervid/napi-android-arm64": "0.
|
113
|
-
"@fervid/napi-freebsd-x64": "0.
|
114
|
-
"@fervid/napi-linux-arm64-musl": "0.
|
115
|
-
"@fervid/napi-win32-arm64-msvc": "0.
|
116
|
-
"@fervid/napi-android-arm-eabi": "0.
|
104
|
+
"@fervid/napi-win32-x64-msvc": "0.4.0",
|
105
|
+
"@fervid/napi-darwin-x64": "0.4.0",
|
106
|
+
"@fervid/napi-linux-x64-gnu": "0.4.0",
|
107
|
+
"@fervid/napi-linux-x64-musl": "0.4.0",
|
108
|
+
"@fervid/napi-linux-arm64-gnu": "0.4.0",
|
109
|
+
"@fervid/napi-win32-ia32-msvc": "0.4.0",
|
110
|
+
"@fervid/napi-linux-arm-gnueabihf": "0.4.0",
|
111
|
+
"@fervid/napi-darwin-arm64": "0.4.0",
|
112
|
+
"@fervid/napi-android-arm64": "0.4.0",
|
113
|
+
"@fervid/napi-freebsd-x64": "0.4.0",
|
114
|
+
"@fervid/napi-linux-arm64-musl": "0.4.0",
|
115
|
+
"@fervid/napi-win32-arm64-msvc": "0.4.0",
|
116
|
+
"@fervid/napi-android-arm-eabi": "0.4.0"
|
117
117
|
},
|
118
118
|
"packageManager": "yarn@4.4.1",
|
119
119
|
"workspaces": [
|