@fervid/napi 0.3.0 → 0.3.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.
Files changed (3) hide show
  1. package/index.d.ts +58 -0
  2. package/index.js +2 -1
  3. package/package.json +14 -14
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.0",
3
+ "version": "0.3.1",
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",
@@ -101,19 +101,19 @@
101
101
  "arrowParens": "always"
102
102
  },
103
103
  "optionalDependencies": {
104
- "@fervid/napi-win32-x64-msvc": "0.3.0",
105
- "@fervid/napi-darwin-x64": "0.3.0",
106
- "@fervid/napi-linux-x64-gnu": "0.3.0",
107
- "@fervid/napi-linux-x64-musl": "0.3.0",
108
- "@fervid/napi-linux-arm64-gnu": "0.3.0",
109
- "@fervid/napi-win32-ia32-msvc": "0.3.0",
110
- "@fervid/napi-linux-arm-gnueabihf": "0.3.0",
111
- "@fervid/napi-darwin-arm64": "0.3.0",
112
- "@fervid/napi-android-arm64": "0.3.0",
113
- "@fervid/napi-freebsd-x64": "0.3.0",
114
- "@fervid/napi-linux-arm64-musl": "0.3.0",
115
- "@fervid/napi-win32-arm64-msvc": "0.3.0",
116
- "@fervid/napi-android-arm-eabi": "0.3.0"
104
+ "@fervid/napi-win32-x64-msvc": "0.3.1",
105
+ "@fervid/napi-darwin-x64": "0.3.1",
106
+ "@fervid/napi-linux-x64-gnu": "0.3.1",
107
+ "@fervid/napi-linux-x64-musl": "0.3.1",
108
+ "@fervid/napi-linux-arm64-gnu": "0.3.1",
109
+ "@fervid/napi-win32-ia32-msvc": "0.3.1",
110
+ "@fervid/napi-linux-arm-gnueabihf": "0.3.1",
111
+ "@fervid/napi-darwin-arm64": "0.3.1",
112
+ "@fervid/napi-android-arm64": "0.3.1",
113
+ "@fervid/napi-freebsd-x64": "0.3.1",
114
+ "@fervid/napi-linux-arm64-musl": "0.3.1",
115
+ "@fervid/napi-win32-arm64-msvc": "0.3.1",
116
+ "@fervid/napi-android-arm-eabi": "0.3.1"
117
117
  },
118
118
  "packageManager": "yarn@4.4.1",
119
119
  "workspaces": [