@fervid/napi 0.1.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 +14 -0
  2. package/index.js +240 -0
  3. package/package.json +121 -0
package/index.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /* auto-generated by NAPI-RS */
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>
package/index.js ADDED
@@ -0,0 +1,240 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /* prettier-ignore */
4
+
5
+ /* auto-generated by NAPI-RS */
6
+
7
+ const { existsSync, readFileSync } = require('fs')
8
+ const { join } = require('path')
9
+
10
+ const { platform, arch } = process
11
+
12
+ let nativeBinding = null
13
+ let localFileExisted = false
14
+ let loadError = null
15
+
16
+ function isMusl() {
17
+ // For Node 10
18
+ if (!process.report || typeof process.report.getReport !== 'function') {
19
+ try {
20
+ const lddPath = require('child_process').execSync('which ldd').toString().trim()
21
+ return readFileSync(lddPath, 'utf8').includes('musl')
22
+ } catch (e) {
23
+ return true
24
+ }
25
+ } else {
26
+ const { glibcVersionRuntime } = process.report.getReport().header
27
+ return !glibcVersionRuntime
28
+ }
29
+ }
30
+
31
+ switch (platform) {
32
+ case 'android':
33
+ switch (arch) {
34
+ case 'arm64':
35
+ localFileExisted = existsSync(join(__dirname, 'napi.android-arm64.node'))
36
+ try {
37
+ if (localFileExisted) {
38
+ nativeBinding = require('./napi.android-arm64.node')
39
+ } else {
40
+ nativeBinding = require('@fervid/napi-android-arm64')
41
+ }
42
+ } catch (e) {
43
+ loadError = e
44
+ }
45
+ break
46
+ case 'arm':
47
+ localFileExisted = existsSync(join(__dirname, 'napi.android-arm-eabi.node'))
48
+ try {
49
+ if (localFileExisted) {
50
+ nativeBinding = require('./napi.android-arm-eabi.node')
51
+ } else {
52
+ nativeBinding = require('@fervid/napi-android-arm-eabi')
53
+ }
54
+ } catch (e) {
55
+ loadError = e
56
+ }
57
+ break
58
+ default:
59
+ throw new Error(`Unsupported architecture on Android ${arch}`)
60
+ }
61
+ break
62
+ case 'win32':
63
+ switch (arch) {
64
+ case 'x64':
65
+ localFileExisted = existsSync(join(__dirname, 'napi.win32-x64-msvc.node'))
66
+ try {
67
+ if (localFileExisted) {
68
+ nativeBinding = require('./napi.win32-x64-msvc.node')
69
+ } else {
70
+ nativeBinding = require('@fervid/napi-win32-x64-msvc')
71
+ }
72
+ } catch (e) {
73
+ loadError = e
74
+ }
75
+ break
76
+ case 'ia32':
77
+ localFileExisted = existsSync(join(__dirname, 'napi.win32-ia32-msvc.node'))
78
+ try {
79
+ if (localFileExisted) {
80
+ nativeBinding = require('./napi.win32-ia32-msvc.node')
81
+ } else {
82
+ nativeBinding = require('@fervid/napi-win32-ia32-msvc')
83
+ }
84
+ } catch (e) {
85
+ loadError = e
86
+ }
87
+ break
88
+ case 'arm64':
89
+ localFileExisted = existsSync(join(__dirname, 'napi.win32-arm64-msvc.node'))
90
+ try {
91
+ if (localFileExisted) {
92
+ nativeBinding = require('./napi.win32-arm64-msvc.node')
93
+ } else {
94
+ nativeBinding = require('@fervid/napi-win32-arm64-msvc')
95
+ }
96
+ } catch (e) {
97
+ loadError = e
98
+ }
99
+ break
100
+ default:
101
+ throw new Error(`Unsupported architecture on Windows: ${arch}`)
102
+ }
103
+ break
104
+ case 'darwin':
105
+ localFileExisted = existsSync(join(__dirname, 'napi.darwin-universal.node'))
106
+ try {
107
+ if (localFileExisted) {
108
+ nativeBinding = require('./napi.darwin-universal.node')
109
+ } else {
110
+ nativeBinding = require('@fervid/napi-darwin-universal')
111
+ }
112
+ break
113
+ } catch {}
114
+ switch (arch) {
115
+ case 'x64':
116
+ localFileExisted = existsSync(join(__dirname, 'napi.darwin-x64.node'))
117
+ try {
118
+ if (localFileExisted) {
119
+ nativeBinding = require('./napi.darwin-x64.node')
120
+ } else {
121
+ nativeBinding = require('@fervid/napi-darwin-x64')
122
+ }
123
+ } catch (e) {
124
+ loadError = e
125
+ }
126
+ break
127
+ case 'arm64':
128
+ localFileExisted = existsSync(join(__dirname, 'napi.darwin-arm64.node'))
129
+ try {
130
+ if (localFileExisted) {
131
+ nativeBinding = require('./napi.darwin-arm64.node')
132
+ } else {
133
+ nativeBinding = require('@fervid/napi-darwin-arm64')
134
+ }
135
+ } catch (e) {
136
+ loadError = e
137
+ }
138
+ break
139
+ default:
140
+ throw new Error(`Unsupported architecture on macOS: ${arch}`)
141
+ }
142
+ break
143
+ case 'freebsd':
144
+ if (arch !== 'x64') {
145
+ throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
146
+ }
147
+ localFileExisted = existsSync(join(__dirname, 'napi.freebsd-x64.node'))
148
+ try {
149
+ if (localFileExisted) {
150
+ nativeBinding = require('./napi.freebsd-x64.node')
151
+ } else {
152
+ nativeBinding = require('@fervid/napi-freebsd-x64')
153
+ }
154
+ } catch (e) {
155
+ loadError = e
156
+ }
157
+ break
158
+ case 'linux':
159
+ switch (arch) {
160
+ case 'x64':
161
+ if (isMusl()) {
162
+ localFileExisted = existsSync(join(__dirname, 'napi.linux-x64-musl.node'))
163
+ try {
164
+ if (localFileExisted) {
165
+ nativeBinding = require('./napi.linux-x64-musl.node')
166
+ } else {
167
+ nativeBinding = require('@fervid/napi-linux-x64-musl')
168
+ }
169
+ } catch (e) {
170
+ loadError = e
171
+ }
172
+ } else {
173
+ localFileExisted = existsSync(join(__dirname, 'napi.linux-x64-gnu.node'))
174
+ try {
175
+ if (localFileExisted) {
176
+ nativeBinding = require('./napi.linux-x64-gnu.node')
177
+ } else {
178
+ nativeBinding = require('@fervid/napi-linux-x64-gnu')
179
+ }
180
+ } catch (e) {
181
+ loadError = e
182
+ }
183
+ }
184
+ break
185
+ case 'arm64':
186
+ if (isMusl()) {
187
+ localFileExisted = existsSync(join(__dirname, 'napi.linux-arm64-musl.node'))
188
+ try {
189
+ if (localFileExisted) {
190
+ nativeBinding = require('./napi.linux-arm64-musl.node')
191
+ } else {
192
+ nativeBinding = require('@fervid/napi-linux-arm64-musl')
193
+ }
194
+ } catch (e) {
195
+ loadError = e
196
+ }
197
+ } else {
198
+ localFileExisted = existsSync(join(__dirname, 'napi.linux-arm64-gnu.node'))
199
+ try {
200
+ if (localFileExisted) {
201
+ nativeBinding = require('./napi.linux-arm64-gnu.node')
202
+ } else {
203
+ nativeBinding = require('@fervid/napi-linux-arm64-gnu')
204
+ }
205
+ } catch (e) {
206
+ loadError = e
207
+ }
208
+ }
209
+ break
210
+ case 'arm':
211
+ localFileExisted = existsSync(join(__dirname, 'napi.linux-arm-gnueabihf.node'))
212
+ try {
213
+ if (localFileExisted) {
214
+ nativeBinding = require('./napi.linux-arm-gnueabihf.node')
215
+ } else {
216
+ nativeBinding = require('@fervid/napi-linux-arm-gnueabihf')
217
+ }
218
+ } catch (e) {
219
+ loadError = e
220
+ }
221
+ break
222
+ default:
223
+ throw new Error(`Unsupported architecture on Linux: ${arch}`)
224
+ }
225
+ break
226
+ default:
227
+ throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
228
+ }
229
+
230
+ if (!nativeBinding) {
231
+ if (loadError) {
232
+ throw loadError
233
+ }
234
+ throw new Error(`Failed to load native binding`)
235
+ }
236
+
237
+ const { compileSync, compileAsync } = nativeBinding
238
+
239
+ module.exports.compileSync = compileSync
240
+ module.exports.compileAsync = compileAsync
package/package.json ADDED
@@ -0,0 +1,121 @@
1
+ {
2
+ "name": "@fervid/napi",
3
+ "version": "0.1.0",
4
+ "description": "All-in-One Vue compiler written in Rust",
5
+ "main": "index.js",
6
+ "repository": "git@github.com:phoenix-ru/fervid.git",
7
+ "license": "MIT",
8
+ "keywords": [
9
+ "napi-rs",
10
+ "NAPI",
11
+ "N-API",
12
+ "Rust",
13
+ "node-addon",
14
+ "node-addon-api",
15
+ "vue"
16
+ ],
17
+ "files": [
18
+ "index.d.ts",
19
+ "index.js"
20
+ ],
21
+ "napi": {
22
+ "name": "napi",
23
+ "triples": {
24
+ "defaults": true,
25
+ "additional": [
26
+ "x86_64-unknown-linux-musl",
27
+ "aarch64-unknown-linux-gnu",
28
+ "i686-pc-windows-msvc",
29
+ "armv7-unknown-linux-gnueabihf",
30
+ "aarch64-apple-darwin",
31
+ "aarch64-linux-android",
32
+ "x86_64-unknown-freebsd",
33
+ "aarch64-unknown-linux-musl",
34
+ "aarch64-pc-windows-msvc",
35
+ "armv7-linux-androideabi"
36
+ ]
37
+ }
38
+ },
39
+ "engines": {
40
+ "node": ">= 10"
41
+ },
42
+ "publishConfig": {
43
+ "registry": "https://registry.npmjs.org/",
44
+ "access": "public"
45
+ },
46
+ "scripts": {
47
+ "artifacts": "napi artifacts",
48
+ "bench": "node -r @swc-node/register benchmark/bench.ts",
49
+ "build": "napi build --platform --release --pipe \"prettier -w\"",
50
+ "build:debug": "napi build --platform --pipe \"prettier -w\"",
51
+ "format": "run-p format:prettier format:rs format:toml",
52
+ "format:prettier": "prettier . -w",
53
+ "format:toml": "taplo format",
54
+ "format:rs": "cargo fmt",
55
+ "lint": "eslint . -c ./.eslintrc.yml",
56
+ "prepublishOnly": "napi prepublish -t npm",
57
+ "test": "vitest",
58
+ "universal": "napi universal",
59
+ "version": "napi version"
60
+ },
61
+ "devDependencies": {
62
+ "@napi-rs/cli": "^2.16.5",
63
+ "@swc-node/register": "^1.6.8",
64
+ "@swc/core": "^1.3.96",
65
+ "@taplo/cli": "^0.5.2",
66
+ "@types/node": "^20.8.10",
67
+ "@typescript-eslint/eslint-plugin": "^6.9.1",
68
+ "@typescript-eslint/parser": "^6.9.1",
69
+ "@vue/compiler-sfc": "^3.3.8",
70
+ "benny": "^3.7.1",
71
+ "chalk": "^5.3.0",
72
+ "eslint": "^8.53.0",
73
+ "eslint-config-prettier": "^9.0.0",
74
+ "eslint-plugin-import": "^2.29.0",
75
+ "eslint-plugin-prettier": "^5.0.1",
76
+ "husky": "^8.0.3",
77
+ "kleur": "^4.1.5",
78
+ "lint-staged": "^14.0.1",
79
+ "npm-run-all": "^4.1.5",
80
+ "prettier": "^3.0.3",
81
+ "typescript": "^5.2.2",
82
+ "vitest": "^0.34.6"
83
+ },
84
+ "lint-staged": {
85
+ "*.@(js|ts|tsx)": [
86
+ "eslint -c .eslintrc.yml --fix"
87
+ ],
88
+ "*.@(js|ts|tsx|yml|yaml|md|json)": [
89
+ "prettier --write"
90
+ ],
91
+ "*.toml": [
92
+ "taplo format"
93
+ ]
94
+ },
95
+ "prettier": {
96
+ "printWidth": 120,
97
+ "semi": false,
98
+ "trailingComma": "all",
99
+ "singleQuote": true,
100
+ "arrowParens": "always"
101
+ },
102
+ "optionalDependencies": {
103
+ "@fervid/napi-win32-x64-msvc": "0.1.0",
104
+ "@fervid/napi-darwin-x64": "0.1.0",
105
+ "@fervid/napi-linux-x64-gnu": "0.1.0",
106
+ "@fervid/napi-linux-x64-musl": "0.1.0",
107
+ "@fervid/napi-linux-arm64-gnu": "0.1.0",
108
+ "@fervid/napi-win32-ia32-msvc": "0.1.0",
109
+ "@fervid/napi-linux-arm-gnueabihf": "0.1.0",
110
+ "@fervid/napi-darwin-arm64": "0.1.0",
111
+ "@fervid/napi-android-arm64": "0.1.0",
112
+ "@fervid/napi-freebsd-x64": "0.1.0",
113
+ "@fervid/napi-linux-arm64-musl": "0.1.0",
114
+ "@fervid/napi-win32-arm64-msvc": "0.1.0",
115
+ "@fervid/napi-android-arm-eabi": "0.1.0"
116
+ },
117
+ "packageManager": "yarn@4.0.2",
118
+ "workspaces": [
119
+ "npm/*"
120
+ ]
121
+ }