rrule-rust 2.0.2 → 2.1.0-alpha.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 (42) hide show
  1. package/dist/browser/lib/browser.d.ts +1 -0
  2. package/dist/browser/lib/browser.js +1 -0
  3. package/dist/{lib → browser/lib}/index.d.ts +44 -40
  4. package/dist/browser/lib/index.js +369 -0
  5. package/dist/browser/lib/rrule-rust.wasi-browser.d.ts +6 -0
  6. package/dist/browser/lib/rrule-rust.wasi-browser.js +70 -0
  7. package/dist/browser/lib/rrule-rust.wasi.cjs +101 -0
  8. package/dist/browser/lib/rrule-rust.wasi.d.cts +1 -0
  9. package/dist/browser/lib/wasi-worker-browser.d.mts +1 -0
  10. package/dist/browser/lib/wasi-worker-browser.mjs +32 -0
  11. package/dist/browser/lib/wasi-worker.d.mts +1 -0
  12. package/dist/browser/lib/wasi-worker.mjs +63 -0
  13. package/dist/{rrule-set.js → browser/rrule-set.js} +3 -3
  14. package/dist/{rrule.js → browser/rrule.js} +3 -3
  15. package/dist/node/datetime.d.ts +55 -0
  16. package/dist/node/datetime.js +124 -0
  17. package/dist/node/index.d.ts +3 -0
  18. package/dist/node/index.js +19 -0
  19. package/dist/node/lib/browser.d.ts +1 -0
  20. package/dist/node/lib/browser.js +1 -0
  21. package/dist/node/lib/index.d.ts +82 -0
  22. package/dist/node/lib/index.js +369 -0
  23. package/dist/node/lib/rrule-rust.wasi-browser.d.ts +6 -0
  24. package/dist/node/lib/rrule-rust.wasi-browser.js +70 -0
  25. package/dist/node/lib/rrule-rust.wasi.cjs +101 -0
  26. package/dist/node/lib/rrule-rust.wasi.d.cts +1 -0
  27. package/dist/node/lib/wasi-worker-browser.d.mts +1 -0
  28. package/dist/node/lib/wasi-worker-browser.mjs +32 -0
  29. package/dist/node/lib/wasi-worker.d.mts +1 -0
  30. package/dist/node/lib/wasi-worker.mjs +63 -0
  31. package/dist/node/rrule-set.d.ts +68 -0
  32. package/dist/node/rrule-set.js +191 -0
  33. package/dist/node/rrule.d.ts +97 -0
  34. package/dist/node/rrule.js +175 -0
  35. package/package.json +54 -48
  36. package/dist/lib/index.js +0 -320
  37. /package/dist/{datetime.d.ts → browser/datetime.d.ts} +0 -0
  38. /package/dist/{datetime.js → browser/datetime.js} +0 -0
  39. /package/dist/{index.d.ts → browser/index.d.ts} +0 -0
  40. /package/dist/{index.js → browser/index.js} +0 -0
  41. /package/dist/{rrule-set.d.ts → browser/rrule-set.d.ts} +0 -0
  42. /package/dist/{rrule.d.ts → browser/rrule.d.ts} +0 -0
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from '@rrule-rust/lib-wasm32-wasi'
@@ -1,44 +1,5 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
-
4
1
  /* auto-generated by NAPI-RS */
5
-
6
- export enum Frequency {
7
- Yearly = 0,
8
- Monthly = 1,
9
- Weekly = 2,
10
- Daily = 3,
11
- Hourly = 4,
12
- Minutely = 5,
13
- Secondly = 6
14
- }
15
- export enum Month {
16
- January = 1,
17
- February = 2,
18
- March = 3,
19
- April = 4,
20
- May = 5,
21
- June = 6,
22
- July = 7,
23
- August = 8,
24
- September = 9,
25
- October = 10,
26
- November = 11,
27
- December = 12
28
- }
29
- export interface NWeekday {
30
- n?: number
31
- weekday: Weekday
32
- }
33
- export enum Weekday {
34
- Monday = 0,
35
- Tuesday = 1,
36
- Wednesday = 2,
37
- Thursday = 3,
38
- Friday = 4,
39
- Saturday = 5,
40
- Sunday = 6
41
- }
2
+ /* eslint-disable */
42
3
  export declare class RRule {
43
4
  constructor(frequency: Frequency, interval?: number | undefined | null, count?: number | undefined | null, weekstart?: Weekday | undefined | null, until?: number | undefined | null, byWeekday?: (readonly (NWeekday | Weekday)[]) | undefined | null, byHour?: (readonly number[]) | undefined | null, byMinute?: (readonly number[]) | undefined | null, bySecond?: (readonly number[]) | undefined | null, byMonthday?: (readonly number[]) | undefined | null, bySetpos?: (readonly number[]) | undefined | null, byMonth?: (readonly number[]) | undefined | null, byWeekno?: (readonly number[]) | undefined | null, byYearday?: (readonly number[]) | undefined | null)
44
5
  static parse(str: string): RRule
@@ -58,6 +19,7 @@ export declare class RRule {
58
19
  get until(): number | null
59
20
  toString(): string
60
21
  }
22
+
61
23
  export declare class RRuleSet {
62
24
  constructor(dtstart: number, tzid?: string | undefined | null, rrules?: (readonly RRule[]) | undefined | null, exrules?: (readonly RRule[]) | undefined | null, exdates?: (readonly number[]) | undefined | null, rdates?: (readonly number[]) | undefined | null)
63
25
  get tzid(): string | null
@@ -73,6 +35,48 @@ export declare class RRuleSet {
73
35
  toString(): string
74
36
  iterator(): RRuleSetIterator
75
37
  }
38
+
76
39
  export declare class RRuleSetIterator {
77
40
  next(): number | null
78
41
  }
42
+
43
+ export declare enum Frequency {
44
+ Yearly = 0,
45
+ Monthly = 1,
46
+ Weekly = 2,
47
+ Daily = 3,
48
+ Hourly = 4,
49
+ Minutely = 5,
50
+ Secondly = 6
51
+ }
52
+
53
+ export declare enum Month {
54
+ January = 1,
55
+ February = 2,
56
+ March = 3,
57
+ April = 4,
58
+ May = 5,
59
+ June = 6,
60
+ July = 7,
61
+ August = 8,
62
+ September = 9,
63
+ October = 10,
64
+ November = 11,
65
+ December = 12
66
+ }
67
+
68
+ export interface NWeekday {
69
+ n?: number
70
+ weekday: Weekday
71
+ }
72
+
73
+ export declare enum Weekday {
74
+ Monday = 0,
75
+ Tuesday = 1,
76
+ Wednesday = 2,
77
+ Thursday = 3,
78
+ Friday = 4,
79
+ Saturday = 5,
80
+ Sunday = 6
81
+ }
82
+
@@ -0,0 +1,369 @@
1
+ // prettier-ignore
2
+ /* eslint-disable */
3
+ /* auto-generated by NAPI-RS */
4
+
5
+ const { readFileSync } = require('fs')
6
+
7
+ let nativeBinding = null
8
+ const loadErrors = []
9
+
10
+ const isMusl = () => {
11
+ let musl = false
12
+ if (process.platform === 'linux') {
13
+ musl = isMuslFromFilesystem()
14
+ if (musl === null) {
15
+ musl = isMuslFromReport()
16
+ }
17
+ if (musl === null) {
18
+ musl = isMuslFromChildProcess()
19
+ }
20
+ }
21
+ return musl
22
+ }
23
+
24
+ const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
25
+
26
+ const isMuslFromFilesystem = () => {
27
+ try {
28
+ return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
29
+ } catch {
30
+ return null
31
+ }
32
+ }
33
+
34
+ const isMuslFromReport = () => {
35
+ const report = typeof process.report.getReport === 'function' ? process.report.getReport() : null
36
+ if (!report) {
37
+ return null
38
+ }
39
+ if (report.header && report.header.glibcVersionRuntime) {
40
+ return false
41
+ }
42
+ if (Array.isArray(report.sharedObjects)) {
43
+ if (report.sharedObjects.some(isFileMusl)) {
44
+ return true
45
+ }
46
+ }
47
+ return false
48
+ }
49
+
50
+ const isMuslFromChildProcess = () => {
51
+ try {
52
+ return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
53
+ } catch (e) {
54
+ // If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
55
+ return false
56
+ }
57
+ }
58
+
59
+ function requireNative() {
60
+ if (process.platform === 'android') {
61
+ if (process.arch === 'arm64') {
62
+ try {
63
+ return require('./rrule-rust.android-arm64.node')
64
+ } catch (e) {
65
+ loadErrors.push(e)
66
+ }
67
+ try {
68
+ return require('@rrule-rust/lib-android-arm64')
69
+ } catch (e) {
70
+ loadErrors.push(e)
71
+ }
72
+
73
+ } else if (process.arch === 'arm') {
74
+ try {
75
+ return require('./rrule-rust.android-arm-eabi.node')
76
+ } catch (e) {
77
+ loadErrors.push(e)
78
+ }
79
+ try {
80
+ return require('@rrule-rust/lib-android-arm-eabi')
81
+ } catch (e) {
82
+ loadErrors.push(e)
83
+ }
84
+
85
+ } else {
86
+ loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
87
+ }
88
+ } else if (process.platform === 'win32') {
89
+ if (process.arch === 'x64') {
90
+ try {
91
+ return require('./rrule-rust.win32-x64-msvc.node')
92
+ } catch (e) {
93
+ loadErrors.push(e)
94
+ }
95
+ try {
96
+ return require('@rrule-rust/lib-win32-x64-msvc')
97
+ } catch (e) {
98
+ loadErrors.push(e)
99
+ }
100
+
101
+ } else if (process.arch === 'ia32') {
102
+ try {
103
+ return require('./rrule-rust.win32-ia32-msvc.node')
104
+ } catch (e) {
105
+ loadErrors.push(e)
106
+ }
107
+ try {
108
+ return require('@rrule-rust/lib-win32-ia32-msvc')
109
+ } catch (e) {
110
+ loadErrors.push(e)
111
+ }
112
+
113
+ } else if (process.arch === 'arm64') {
114
+ try {
115
+ return require('./rrule-rust.win32-arm64-msvc.node')
116
+ } catch (e) {
117
+ loadErrors.push(e)
118
+ }
119
+ try {
120
+ return require('@rrule-rust/lib-win32-arm64-msvc')
121
+ } catch (e) {
122
+ loadErrors.push(e)
123
+ }
124
+
125
+ } else {
126
+ loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
127
+ }
128
+ } else if (process.platform === 'darwin') {
129
+ try {
130
+ return require('./rrule-rust.darwin-universal.node')
131
+ } catch (e) {
132
+ loadErrors.push(e)
133
+ }
134
+ try {
135
+ return require('@rrule-rust/lib-darwin-universal')
136
+ } catch (e) {
137
+ loadErrors.push(e)
138
+ }
139
+
140
+ if (process.arch === 'x64') {
141
+ try {
142
+ return require('./rrule-rust.darwin-x64.node')
143
+ } catch (e) {
144
+ loadErrors.push(e)
145
+ }
146
+ try {
147
+ return require('@rrule-rust/lib-darwin-x64')
148
+ } catch (e) {
149
+ loadErrors.push(e)
150
+ }
151
+
152
+ } else if (process.arch === 'arm64') {
153
+ try {
154
+ return require('./rrule-rust.darwin-arm64.node')
155
+ } catch (e) {
156
+ loadErrors.push(e)
157
+ }
158
+ try {
159
+ return require('@rrule-rust/lib-darwin-arm64')
160
+ } catch (e) {
161
+ loadErrors.push(e)
162
+ }
163
+
164
+ } else {
165
+ loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
166
+ }
167
+ } else if (process.platform === 'freebsd') {
168
+ if (process.arch === 'x64') {
169
+ try {
170
+ return require('./rrule-rust.freebsd-x64.node')
171
+ } catch (e) {
172
+ loadErrors.push(e)
173
+ }
174
+ try {
175
+ return require('@rrule-rust/lib-freebsd-x64')
176
+ } catch (e) {
177
+ loadErrors.push(e)
178
+ }
179
+
180
+ } else if (process.arch === 'arm64') {
181
+ try {
182
+ return require('./rrule-rust.freebsd-arm64.node')
183
+ } catch (e) {
184
+ loadErrors.push(e)
185
+ }
186
+ try {
187
+ return require('@rrule-rust/lib-freebsd-arm64')
188
+ } catch (e) {
189
+ loadErrors.push(e)
190
+ }
191
+
192
+ } else {
193
+ loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
194
+ }
195
+ } else if (process.platform === 'linux') {
196
+ if (process.arch === 'x64') {
197
+ if (isMusl()) {
198
+ try {
199
+ return require('./rrule-rust.linux-x64-musl.node')
200
+ } catch (e) {
201
+ loadErrors.push(e)
202
+ }
203
+ try {
204
+ return require('@rrule-rust/lib-linux-x64-musl')
205
+ } catch (e) {
206
+ loadErrors.push(e)
207
+ }
208
+
209
+ } else {
210
+ try {
211
+ return require('./rrule-rust.linux-x64-gnu.node')
212
+ } catch (e) {
213
+ loadErrors.push(e)
214
+ }
215
+ try {
216
+ return require('@rrule-rust/lib-linux-x64-gnu')
217
+ } catch (e) {
218
+ loadErrors.push(e)
219
+ }
220
+
221
+ }
222
+ } else if (process.arch === 'arm64') {
223
+ if (isMusl()) {
224
+ try {
225
+ return require('./rrule-rust.linux-arm64-musl.node')
226
+ } catch (e) {
227
+ loadErrors.push(e)
228
+ }
229
+ try {
230
+ return require('@rrule-rust/lib-linux-arm64-musl')
231
+ } catch (e) {
232
+ loadErrors.push(e)
233
+ }
234
+
235
+ } else {
236
+ try {
237
+ return require('./rrule-rust.linux-arm64-gnu.node')
238
+ } catch (e) {
239
+ loadErrors.push(e)
240
+ }
241
+ try {
242
+ return require('@rrule-rust/lib-linux-arm64-gnu')
243
+ } catch (e) {
244
+ loadErrors.push(e)
245
+ }
246
+
247
+ }
248
+ } else if (process.arch === 'arm') {
249
+ if (isMusl()) {
250
+ try {
251
+ return require('./rrule-rust.linux-arm-musleabihf.node')
252
+ } catch (e) {
253
+ loadErrors.push(e)
254
+ }
255
+ try {
256
+ return require('@rrule-rust/lib-linux-arm-musleabihf')
257
+ } catch (e) {
258
+ loadErrors.push(e)
259
+ }
260
+
261
+ } else {
262
+ try {
263
+ return require('./rrule-rust.linux-arm-gnueabihf.node')
264
+ } catch (e) {
265
+ loadErrors.push(e)
266
+ }
267
+ try {
268
+ return require('@rrule-rust/lib-linux-arm-gnueabihf')
269
+ } catch (e) {
270
+ loadErrors.push(e)
271
+ }
272
+
273
+ }
274
+ } else if (process.arch === 'riscv64') {
275
+ if (isMusl()) {
276
+ try {
277
+ return require('./rrule-rust.linux-riscv64-musl.node')
278
+ } catch (e) {
279
+ loadErrors.push(e)
280
+ }
281
+ try {
282
+ return require('@rrule-rust/lib-linux-riscv64-musl')
283
+ } catch (e) {
284
+ loadErrors.push(e)
285
+ }
286
+
287
+ } else {
288
+ try {
289
+ return require('./rrule-rust.linux-riscv64-gnu.node')
290
+ } catch (e) {
291
+ loadErrors.push(e)
292
+ }
293
+ try {
294
+ return require('@rrule-rust/lib-linux-riscv64-gnu')
295
+ } catch (e) {
296
+ loadErrors.push(e)
297
+ }
298
+
299
+ }
300
+ } else if (process.arch === 'ppc64') {
301
+ try {
302
+ return require('./rrule-rust.linux-ppc64-gnu.node')
303
+ } catch (e) {
304
+ loadErrors.push(e)
305
+ }
306
+ try {
307
+ return require('@rrule-rust/lib-linux-ppc64-gnu')
308
+ } catch (e) {
309
+ loadErrors.push(e)
310
+ }
311
+
312
+ } else if (process.arch === 's390x') {
313
+ try {
314
+ return require('./rrule-rust.linux-s390x-gnu.node')
315
+ } catch (e) {
316
+ loadErrors.push(e)
317
+ }
318
+ try {
319
+ return require('@rrule-rust/lib-linux-s390x-gnu')
320
+ } catch (e) {
321
+ loadErrors.push(e)
322
+ }
323
+
324
+ } else {
325
+ loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
326
+ }
327
+ } else {
328
+ loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
329
+ }
330
+ }
331
+
332
+ nativeBinding = requireNative()
333
+
334
+ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
335
+ try {
336
+ nativeBinding = require('./rrule-rust.wasi.cjs')
337
+ } catch (err) {
338
+ if (process.env.NAPI_RS_FORCE_WASI) {
339
+ loadErrors.push(err)
340
+ }
341
+ }
342
+ if (!nativeBinding) {
343
+ try {
344
+ nativeBinding = require('@rrule-rust/lib-wasm32-wasi')
345
+ } catch (err) {
346
+ if (process.env.NAPI_RS_FORCE_WASI) {
347
+ loadErrors.push(err)
348
+ }
349
+ }
350
+ }
351
+ }
352
+
353
+ if (!nativeBinding) {
354
+ if (loadErrors.length > 0) {
355
+ // TODO Link to documentation with potential fixes
356
+ // - The package owner could build/publish bindings for this arch
357
+ // - The user may need to bundle the correct files
358
+ // - The user may need to re-install node_modules to get new packages
359
+ throw new Error('Failed to load native binding', { cause: loadErrors })
360
+ }
361
+ throw new Error(`Failed to load native binding`)
362
+ }
363
+
364
+ module.exports.RRule = nativeBinding.RRule
365
+ module.exports.RRuleSet = nativeBinding.RRuleSet
366
+ module.exports.RRuleSetIterator = nativeBinding.RRuleSetIterator
367
+ module.exports.Frequency = nativeBinding.Frequency
368
+ module.exports.Month = nativeBinding.Month
369
+ module.exports.Weekday = nativeBinding.Weekday
@@ -0,0 +1,6 @@
1
+ export const RRule: any;
2
+ export const RRuleSet: any;
3
+ export const RRuleSetIterator: any;
4
+ export const Frequency: any;
5
+ export const Month: any;
6
+ export const Weekday: any;
@@ -0,0 +1,70 @@
1
+ import {
2
+ instantiateNapiModuleSync as __emnapiInstantiateNapiModuleSync,
3
+ getDefaultContext as __emnapiGetDefaultContext,
4
+ WASI as __WASI,
5
+ createOnMessage as __wasmCreateOnMessageForFsProxy,
6
+ } from '@napi-rs/wasm-runtime'
7
+
8
+ import __wasmUrl from './rrule-rust.wasm32-wasi.wasm?url'
9
+
10
+ const __wasi = new __WASI({
11
+ version: 'preview1',
12
+ })
13
+
14
+ const __emnapiContext = __emnapiGetDefaultContext()
15
+
16
+ const __sharedMemory = new WebAssembly.Memory({
17
+ initial: 4000,
18
+ maximum: 65536,
19
+ shared: true,
20
+ })
21
+
22
+ const __wasmFile = await fetch(__wasmUrl).then((res) => res.arrayBuffer())
23
+
24
+ const {
25
+ instance: __napiInstance,
26
+ module: __wasiModule,
27
+ napiModule: __napiModule,
28
+ } = __emnapiInstantiateNapiModuleSync(__wasmFile, {
29
+ context: __emnapiContext,
30
+ asyncWorkPoolSize: 4,
31
+ wasi: __wasi,
32
+ onCreateWorker() {
33
+ const worker = new Worker(new URL('./wasi-worker-browser.mjs', import.meta.url), {
34
+ type: 'module',
35
+ })
36
+
37
+ return worker
38
+ },
39
+ overwriteImports(importObject) {
40
+ importObject.env = {
41
+ ...importObject.env,
42
+ ...importObject.napi,
43
+ ...importObject.emnapi,
44
+ memory: __sharedMemory,
45
+ }
46
+ return importObject
47
+ },
48
+ beforeInit({ instance }) {
49
+ __napi_rs_initialize_modules(instance)
50
+ },
51
+ })
52
+
53
+ function __napi_rs_initialize_modules(__napiInstance) {
54
+ __napiInstance.exports['__napi_register__Frequency_0']?.()
55
+ __napiInstance.exports['__napi_register__Month_1']?.()
56
+ __napiInstance.exports['__napi_register__NWeekday_struct_2']?.()
57
+ __napiInstance.exports['__napi_register__RRule_struct_3']?.()
58
+ __napiInstance.exports['__napi_register__RRule_impl_21']?.()
59
+ __napiInstance.exports['__napi_register__RRuleSet_struct_22']?.()
60
+ __napiInstance.exports['__napi_register__RRuleSet_impl_36']?.()
61
+ __napiInstance.exports['__napi_register__RRuleSetIterator_struct_37']?.()
62
+ __napiInstance.exports['__napi_register__RRuleSetIterator_impl_39']?.()
63
+ __napiInstance.exports['__napi_register__Weekday_40']?.()
64
+ }
65
+ export const RRule = __napiModule.exports.RRule
66
+ export const RRuleSet = __napiModule.exports.RRuleSet
67
+ export const RRuleSetIterator = __napiModule.exports.RRuleSetIterator
68
+ export const Frequency = __napiModule.exports.Frequency
69
+ export const Month = __napiModule.exports.Month
70
+ export const Weekday = __napiModule.exports.Weekday
@@ -0,0 +1,101 @@
1
+ /* eslint-disable */
2
+ /* prettier-ignore */
3
+
4
+ /* auto-generated by NAPI-RS */
5
+
6
+ const __nodeFs = require('node:fs')
7
+ const __nodePath = require('node:path')
8
+ const { WASI: __nodeWASI } = require('node:wasi')
9
+ const { Worker } = require('node:worker_threads')
10
+
11
+ const {
12
+ instantiateNapiModuleSync: __emnapiInstantiateNapiModuleSync,
13
+ getDefaultContext: __emnapiGetDefaultContext,
14
+ createOnMessage: __wasmCreateOnMessageForFsProxy,
15
+ } = require('@napi-rs/wasm-runtime')
16
+
17
+ const __rootDir = __nodePath.parse(process.cwd()).root
18
+
19
+ const __wasi = new __nodeWASI({
20
+ version: 'preview1',
21
+ env: process.env,
22
+ preopens: {
23
+ [__rootDir]: __rootDir,
24
+ }
25
+ })
26
+
27
+ const __emnapiContext = __emnapiGetDefaultContext()
28
+
29
+ const __sharedMemory = new WebAssembly.Memory({
30
+ initial: 4000,
31
+ maximum: 65536,
32
+ shared: true,
33
+ })
34
+
35
+ let __wasmFilePath = __nodePath.join(__dirname, 'rrule-rust.wasm32-wasi.wasm')
36
+ const __wasmDebugFilePath = __nodePath.join(__dirname, 'rrule-rust.wasm32-wasi.debug.wasm')
37
+
38
+ if (__nodeFs.existsSync(__wasmDebugFilePath)) {
39
+ __wasmFilePath = __wasmDebugFilePath
40
+ } else if (!__nodeFs.existsSync(__wasmFilePath)) {
41
+ try {
42
+ __wasmFilePath = __nodePath.resolve('@rrule-rust/lib-wasm32-wasi')
43
+ } catch {
44
+ throw new Error('Cannot find rrule-rust.wasm32-wasi.wasm file, and @rrule-rust/lib-wasm32-wasi package is not installed.')
45
+ }
46
+ }
47
+
48
+ const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule } = __emnapiInstantiateNapiModuleSync(__nodeFs.readFileSync(__wasmFilePath), {
49
+ context: __emnapiContext,
50
+ asyncWorkPoolSize: (function() {
51
+ const threadsSizeFromEnv = Number(process.env.NAPI_RS_ASYNC_WORK_POOL_SIZE ?? process.env.UV_THREADPOOL_SIZE)
52
+ // NaN > 0 is false
53
+ if (threadsSizeFromEnv > 0) {
54
+ return threadsSizeFromEnv
55
+ } else {
56
+ return 4
57
+ }
58
+ })(),
59
+ wasi: __wasi,
60
+ onCreateWorker() {
61
+ const worker = new Worker(__nodePath.join(__dirname, 'wasi-worker.mjs'), {
62
+ env: process.env,
63
+ execArgv: ['--experimental-wasi-unstable-preview1'],
64
+ })
65
+ worker.onmessage = ({ data }) => {
66
+ __wasmCreateOnMessageForFsProxy(__nodeFs)(data)
67
+ }
68
+ return worker
69
+ },
70
+ overwriteImports(importObject) {
71
+ importObject.env = {
72
+ ...importObject.env,
73
+ ...importObject.napi,
74
+ ...importObject.emnapi,
75
+ memory: __sharedMemory,
76
+ }
77
+ return importObject
78
+ },
79
+ beforeInit({ instance }) {
80
+ __napi_rs_initialize_modules(instance)
81
+ }
82
+ })
83
+
84
+ function __napi_rs_initialize_modules(__napiInstance) {
85
+ __napiInstance.exports['__napi_register__Frequency_0']?.()
86
+ __napiInstance.exports['__napi_register__Month_1']?.()
87
+ __napiInstance.exports['__napi_register__NWeekday_struct_2']?.()
88
+ __napiInstance.exports['__napi_register__RRule_struct_3']?.()
89
+ __napiInstance.exports['__napi_register__RRule_impl_21']?.()
90
+ __napiInstance.exports['__napi_register__RRuleSet_struct_22']?.()
91
+ __napiInstance.exports['__napi_register__RRuleSet_impl_36']?.()
92
+ __napiInstance.exports['__napi_register__RRuleSetIterator_struct_37']?.()
93
+ __napiInstance.exports['__napi_register__RRuleSetIterator_impl_39']?.()
94
+ __napiInstance.exports['__napi_register__Weekday_40']?.()
95
+ }
96
+ module.exports.RRule = __napiModule.exports.RRule
97
+ module.exports.RRuleSet = __napiModule.exports.RRuleSet
98
+ module.exports.RRuleSetIterator = __napiModule.exports.RRuleSetIterator
99
+ module.exports.Frequency = __napiModule.exports.Frequency
100
+ module.exports.Month = __napiModule.exports.Month
101
+ module.exports.Weekday = __napiModule.exports.Weekday
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,32 @@
1
+ import { instantiateNapiModuleSync, MessageHandler, WASI } from '@napi-rs/wasm-runtime'
2
+
3
+ const handler = new MessageHandler({
4
+ onLoad({ wasmModule, wasmMemory }) {
5
+ const wasi = new WASI({
6
+ print: function () {
7
+ // eslint-disable-next-line no-console
8
+ console.log.apply(console, arguments)
9
+ },
10
+ printErr: function() {
11
+ // eslint-disable-next-line no-console
12
+ console.error.apply(console, arguments)
13
+ },
14
+ })
15
+ return instantiateNapiModuleSync(wasmModule, {
16
+ childThread: true,
17
+ wasi,
18
+ overwriteImports(importObject) {
19
+ importObject.env = {
20
+ ...importObject.env,
21
+ ...importObject.napi,
22
+ ...importObject.emnapi,
23
+ memory: wasmMemory,
24
+ }
25
+ },
26
+ })
27
+ },
28
+ })
29
+
30
+ globalThis.onmessage = function (e) {
31
+ handler.handle(e)
32
+ }
@@ -0,0 +1 @@
1
+ export {};