@c9up/chronos 0.1.13 → 0.1.14

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c9up/chronos",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "Chronos — advanced date/time and recurrence engine (TypeScript + Rust N-API)",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -26,10 +26,11 @@
26
26
  "wasm"
27
27
  ],
28
28
  "devDependencies": {
29
- "@biomejs/biome": "^2.4.10",
30
- "@types/node": "^22.19.15",
31
- "typescript": "^6.0.2",
32
- "vitest": "^4.1.2"
29
+ "@biomejs/biome": "^2.5.12",
30
+ "@types/node": "^22.20.1",
31
+ "@vitest/coverage-v8": "4.1.11",
32
+ "typescript": "^6.0.3",
33
+ "vitest": "4.1.11"
33
34
  },
34
35
  "engines": {
35
36
  "node": ">=22.0.0"
@@ -49,8 +50,8 @@
49
50
  "test": "vitest run",
50
51
  "test:rust": "cargo test",
51
52
  "test:napi": "node scripts/verify-napi.mjs",
52
- "build:wasm": "wasm-pack build --target web crates/chronos-engine-wasm --out-dir ../../wasm",
53
- "lint": "biome check src/",
53
+ "build:wasm": "wasm-pack build --target web crates/chronos-engine-wasm --out-dir ../../wasm && node scripts/clean-wasm-pack-meta.mjs",
54
+ "lint": "biome check src/ tests/",
54
55
  "test:coverage": "vitest run --coverage",
55
56
  "typecheck": "tsc --noEmit"
56
57
  }
@@ -0,0 +1,32 @@
1
+ import { existsSync, rmSync } from 'node:fs'
2
+ import { dirname, join } from 'node:path'
3
+ import { fileURLToPath } from 'node:url'
4
+
5
+ // Removes the package metadata `wasm-pack` writes into its output directory.
6
+ //
7
+ // `wasm-pack build` treats its out-dir as a publishable package of its own and
8
+ // scaffolds one: a `package.json`, and a `.gitignore` whose entire content is
9
+ // `*`. Ours is not a package — it is a directory inside this one, listed in
10
+ // `files`.
11
+ //
12
+ // The `.gitignore` is the damaging half. npm honours a .gitignore nested INSIDE
13
+ // a published directory even when `files` lists that directory, so a single `*`
14
+ // silently strips every artifact from the tarball — the built .js and .wasm, and
15
+ // the committed .d.ts stub with them. The package then publishes green and every
16
+ // browser consumer gets the engine-missing error. Measured here: with the file
17
+ // present `npm pack --dry-run` reports zero wasm/ entries, without it, three.
18
+ //
19
+ // Runs right after wasm-pack, before anything packs.
20
+
21
+ const wasmDir = join(dirname(fileURLToPath(import.meta.url)), '..', 'wasm')
22
+
23
+ // Only what wasm-pack scaffolds. The artifacts and the committed .d.ts stay.
24
+ const generated = ['.gitignore', 'package.json', 'README.md', 'LICENSE']
25
+
26
+ for (const name of generated) {
27
+ const path = join(wasmDir, name)
28
+ if (existsSync(path)) {
29
+ rmSync(path)
30
+ console.log(`[wasm] removed generated wasm/${name}`)
31
+ }
32
+ }
@@ -1,5 +1,5 @@
1
1
  import { copyFileSync, existsSync } from 'node:fs'
2
- import { dirname, join } from 'node:path'
2
+ import { dirname, join, resolve } from 'node:path'
3
3
  import { arch, env, platform } from 'node:process'
4
4
  import { fileURLToPath } from 'node:url'
5
5
 
@@ -20,16 +20,24 @@ const hostSuffixMap = {
20
20
  'darwin-x64': 'darwin-x64', 'darwin-arm64': 'darwin-arm64', 'win32-x64': 'win32-x64-msvc',
21
21
  }
22
22
 
23
+ // Cargo writes its artifacts under CARGO_TARGET_DIR when that is set — a
24
+ // shared cache, a CI mount — so they are not under this package's `target/` at
25
+ // all. A relative value is resolved against the directory cargo ran in, which
26
+ // is this package root.
27
+ const targetDir = env.CARGO_TARGET_DIR
28
+ ? resolve(root, env.CARGO_TARGET_DIR)
29
+ : join(root, 'target')
30
+
23
31
  const triple = env.CARGO_BUILD_TARGET ?? ''
24
32
  let suffix, os, releaseDir
25
33
  if (triple) {
26
34
  const entry = tripleMap[triple]
27
35
  if (!entry) throw new Error(`${TAG} unsupported CARGO_BUILD_TARGET: ${triple}`)
28
36
  suffix = entry.suffix; os = entry.os
29
- releaseDir = join(root, 'target', triple, 'release')
37
+ releaseDir = join(targetDir, triple, 'release')
30
38
  } else {
31
39
  suffix = hostSuffixMap[`${platform}-${arch}`]; os = platform
32
- releaseDir = join(root, 'target', 'release')
40
+ releaseDir = join(targetDir, 'release')
33
41
  if (!suffix) throw new Error(`${TAG} unsupported platform/arch: ${platform}-${arch}`)
34
42
  }
35
43
 
@@ -1,3 +1,4 @@
1
+ import { execFileSync } from 'node:child_process'
1
2
  import { existsSync, statSync } from 'node:fs'
2
3
  import { dirname, join } from 'node:path'
3
4
  import { fileURLToPath } from 'node:url'
@@ -24,4 +25,31 @@ for (const name of required) {
24
25
  }
25
26
  }
26
27
 
27
- console.log('[chronos:wasm] browser artifacts present')
28
+ // Present on disk is NOT the same question as present in the package, and it is
29
+ // the weaker one. `wasm-pack` writes a `.gitignore` of `*` into its out-dir, and
30
+ // npm honours a .gitignore nested inside a published directory even when `files`
31
+ // lists that directory — so every check above can pass while the tarball ships
32
+ // nothing. That is exactly how 0.1.13 went out: green gate, empty wasm/.
33
+ //
34
+ // So ask the packer. `--ignore-scripts` keeps this from re-entering
35
+ // prepublishOnly, which is what invoked us.
36
+ const packed = JSON.parse(
37
+ execFileSync('npm', ['pack', '--dry-run', '--json', '--ignore-scripts'], {
38
+ cwd: join(here, '..'),
39
+ encoding: 'utf-8',
40
+ stdio: ['ignore', 'pipe', 'ignore'],
41
+ }),
42
+ )[0]
43
+
44
+ const shipped = new Set(packed.files.map((f) => f.path))
45
+ for (const name of required) {
46
+ if (!shipped.has(`wasm/${name}`)) {
47
+ throw new Error(
48
+ `[chronos:wasm] wasm/${name} is on disk but NOT in the tarball — something is excluding it ` +
49
+ `(a .gitignore or .npmignore nested in wasm/ will do this even though "wasm" is in package.json files). ` +
50
+ `Run \`node scripts/clean-wasm-pack-meta.mjs\` after wasm-pack.`,
51
+ )
52
+ }
53
+ }
54
+
55
+ console.log(`[chronos:wasm] browser artifacts present and in the tarball (${shipped.size} files)`)
@@ -0,0 +1,92 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export function add(iso: string, amount: bigint, unit: string): string;
5
+
6
+ export function add_in_zone(utc_iso: string, amount: bigint, unit: string, zone: string): string;
7
+
8
+ export function calendar_parts(iso: string): any;
9
+
10
+ export function diff(a_iso: string, b_iso: string, unit: string): number;
11
+
12
+ export function diff_in_zone(a_utc: string, b_utc: string, unit: string, zone: string): number;
13
+
14
+ export function end_of(iso: string, unit: string): string;
15
+
16
+ export function end_of_in_zone(utc_iso: string, unit: string, zone: string): string;
17
+
18
+ export function format(iso: string, pattern: string): string;
19
+
20
+ export function from_local(naive_iso: string, zone: string): string;
21
+
22
+ export function parse_http(input: string): string;
23
+
24
+ export function parse_rfc2822(input: string): string;
25
+
26
+ export function parse_sql(input: string): string;
27
+
28
+ export function rrule_expand(start_iso: string, rrule: string, limit: number): any;
29
+
30
+ export function start_of(iso: string, unit: string): string;
31
+
32
+ export function start_of_in_zone(utc_iso: string, unit: string, zone: string): string;
33
+
34
+ export function to_zone(utc_iso: string, zone: string): any;
35
+
36
+ export function validate_timezone(zone: string): string;
37
+
38
+ export function zone_offset(utc_iso: string, zone: string): number;
39
+
40
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
41
+
42
+ export interface InitOutput {
43
+ readonly memory: WebAssembly.Memory;
44
+ readonly add: (a: number, b: number, c: bigint, d: number, e: number) => [number, number, number, number];
45
+ readonly add_in_zone: (a: number, b: number, c: bigint, d: number, e: number, f: number, g: number) => [number, number, number, number];
46
+ readonly calendar_parts: (a: number, b: number) => [number, number, number];
47
+ readonly diff: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
48
+ readonly diff_in_zone: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number];
49
+ readonly end_of: (a: number, b: number, c: number, d: number) => [number, number, number, number];
50
+ readonly end_of_in_zone: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
51
+ readonly format: (a: number, b: number, c: number, d: number) => [number, number, number, number];
52
+ readonly from_local: (a: number, b: number, c: number, d: number) => [number, number, number, number];
53
+ readonly parse_http: (a: number, b: number) => [number, number, number, number];
54
+ readonly parse_rfc2822: (a: number, b: number) => [number, number, number, number];
55
+ readonly parse_sql: (a: number, b: number) => [number, number, number, number];
56
+ readonly rrule_expand: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
57
+ readonly start_of: (a: number, b: number, c: number, d: number) => [number, number, number, number];
58
+ readonly start_of_in_zone: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
59
+ readonly to_zone: (a: number, b: number, c: number, d: number) => [number, number, number];
60
+ readonly validate_timezone: (a: number, b: number) => [number, number, number, number];
61
+ readonly zone_offset: (a: number, b: number, c: number, d: number) => [number, number, number];
62
+ readonly __wbindgen_exn_store: (a: number) => void;
63
+ readonly __externref_table_alloc: () => number;
64
+ readonly __wbindgen_externrefs: WebAssembly.Table;
65
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
66
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
67
+ readonly __externref_table_dealloc: (a: number) => void;
68
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
69
+ readonly __wbindgen_start: () => void;
70
+ }
71
+
72
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
73
+
74
+ /**
75
+ * Instantiates the given `module`, which can either be bytes or
76
+ * a precompiled `WebAssembly.Module`.
77
+ *
78
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
79
+ *
80
+ * @returns {InitOutput}
81
+ */
82
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
83
+
84
+ /**
85
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
86
+ * for everything else, calls `WebAssembly.instantiate` directly.
87
+ *
88
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
89
+ *
90
+ * @returns {Promise<InitOutput>}
91
+ */
92
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,688 @@
1
+ /* @ts-self-types="./chronos_engine_wasm.d.ts" */
2
+
3
+ /**
4
+ * @param {string} iso
5
+ * @param {bigint} amount
6
+ * @param {string} unit
7
+ * @returns {string}
8
+ */
9
+ export function add(iso, amount, unit) {
10
+ let deferred4_0;
11
+ let deferred4_1;
12
+ try {
13
+ const ptr0 = passStringToWasm0(iso, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
14
+ const len0 = WASM_VECTOR_LEN;
15
+ const ptr1 = passStringToWasm0(unit, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
16
+ const len1 = WASM_VECTOR_LEN;
17
+ const ret = wasm.add(ptr0, len0, amount, ptr1, len1);
18
+ var ptr3 = ret[0];
19
+ var len3 = ret[1];
20
+ if (ret[3]) {
21
+ ptr3 = 0; len3 = 0;
22
+ throw takeFromExternrefTable0(ret[2]);
23
+ }
24
+ deferred4_0 = ptr3;
25
+ deferred4_1 = len3;
26
+ return getStringFromWasm0(ptr3, len3);
27
+ } finally {
28
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
29
+ }
30
+ }
31
+
32
+ /**
33
+ * @param {string} utc_iso
34
+ * @param {bigint} amount
35
+ * @param {string} unit
36
+ * @param {string} zone
37
+ * @returns {string}
38
+ */
39
+ export function add_in_zone(utc_iso, amount, unit, zone) {
40
+ let deferred5_0;
41
+ let deferred5_1;
42
+ try {
43
+ const ptr0 = passStringToWasm0(utc_iso, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
44
+ const len0 = WASM_VECTOR_LEN;
45
+ const ptr1 = passStringToWasm0(unit, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
46
+ const len1 = WASM_VECTOR_LEN;
47
+ const ptr2 = passStringToWasm0(zone, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
48
+ const len2 = WASM_VECTOR_LEN;
49
+ const ret = wasm.add_in_zone(ptr0, len0, amount, ptr1, len1, ptr2, len2);
50
+ var ptr4 = ret[0];
51
+ var len4 = ret[1];
52
+ if (ret[3]) {
53
+ ptr4 = 0; len4 = 0;
54
+ throw takeFromExternrefTable0(ret[2]);
55
+ }
56
+ deferred5_0 = ptr4;
57
+ deferred5_1 = len4;
58
+ return getStringFromWasm0(ptr4, len4);
59
+ } finally {
60
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
61
+ }
62
+ }
63
+
64
+ /**
65
+ * @param {string} iso
66
+ * @returns {any}
67
+ */
68
+ export function calendar_parts(iso) {
69
+ const ptr0 = passStringToWasm0(iso, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
70
+ const len0 = WASM_VECTOR_LEN;
71
+ const ret = wasm.calendar_parts(ptr0, len0);
72
+ if (ret[2]) {
73
+ throw takeFromExternrefTable0(ret[1]);
74
+ }
75
+ return takeFromExternrefTable0(ret[0]);
76
+ }
77
+
78
+ /**
79
+ * @param {string} a_iso
80
+ * @param {string} b_iso
81
+ * @param {string} unit
82
+ * @returns {number}
83
+ */
84
+ export function diff(a_iso, b_iso, unit) {
85
+ const ptr0 = passStringToWasm0(a_iso, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
86
+ const len0 = WASM_VECTOR_LEN;
87
+ const ptr1 = passStringToWasm0(b_iso, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
88
+ const len1 = WASM_VECTOR_LEN;
89
+ const ptr2 = passStringToWasm0(unit, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
90
+ const len2 = WASM_VECTOR_LEN;
91
+ const ret = wasm.diff(ptr0, len0, ptr1, len1, ptr2, len2);
92
+ if (ret[2]) {
93
+ throw takeFromExternrefTable0(ret[1]);
94
+ }
95
+ return ret[0];
96
+ }
97
+
98
+ /**
99
+ * @param {string} a_utc
100
+ * @param {string} b_utc
101
+ * @param {string} unit
102
+ * @param {string} zone
103
+ * @returns {number}
104
+ */
105
+ export function diff_in_zone(a_utc, b_utc, unit, zone) {
106
+ const ptr0 = passStringToWasm0(a_utc, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
107
+ const len0 = WASM_VECTOR_LEN;
108
+ const ptr1 = passStringToWasm0(b_utc, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
109
+ const len1 = WASM_VECTOR_LEN;
110
+ const ptr2 = passStringToWasm0(unit, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
111
+ const len2 = WASM_VECTOR_LEN;
112
+ const ptr3 = passStringToWasm0(zone, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
113
+ const len3 = WASM_VECTOR_LEN;
114
+ const ret = wasm.diff_in_zone(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
115
+ if (ret[2]) {
116
+ throw takeFromExternrefTable0(ret[1]);
117
+ }
118
+ return ret[0];
119
+ }
120
+
121
+ /**
122
+ * @param {string} iso
123
+ * @param {string} unit
124
+ * @returns {string}
125
+ */
126
+ export function end_of(iso, unit) {
127
+ let deferred4_0;
128
+ let deferred4_1;
129
+ try {
130
+ const ptr0 = passStringToWasm0(iso, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
131
+ const len0 = WASM_VECTOR_LEN;
132
+ const ptr1 = passStringToWasm0(unit, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
133
+ const len1 = WASM_VECTOR_LEN;
134
+ const ret = wasm.end_of(ptr0, len0, ptr1, len1);
135
+ var ptr3 = ret[0];
136
+ var len3 = ret[1];
137
+ if (ret[3]) {
138
+ ptr3 = 0; len3 = 0;
139
+ throw takeFromExternrefTable0(ret[2]);
140
+ }
141
+ deferred4_0 = ptr3;
142
+ deferred4_1 = len3;
143
+ return getStringFromWasm0(ptr3, len3);
144
+ } finally {
145
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
146
+ }
147
+ }
148
+
149
+ /**
150
+ * @param {string} utc_iso
151
+ * @param {string} unit
152
+ * @param {string} zone
153
+ * @returns {string}
154
+ */
155
+ export function end_of_in_zone(utc_iso, unit, zone) {
156
+ let deferred5_0;
157
+ let deferred5_1;
158
+ try {
159
+ const ptr0 = passStringToWasm0(utc_iso, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
160
+ const len0 = WASM_VECTOR_LEN;
161
+ const ptr1 = passStringToWasm0(unit, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
162
+ const len1 = WASM_VECTOR_LEN;
163
+ const ptr2 = passStringToWasm0(zone, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
164
+ const len2 = WASM_VECTOR_LEN;
165
+ const ret = wasm.end_of_in_zone(ptr0, len0, ptr1, len1, ptr2, len2);
166
+ var ptr4 = ret[0];
167
+ var len4 = ret[1];
168
+ if (ret[3]) {
169
+ ptr4 = 0; len4 = 0;
170
+ throw takeFromExternrefTable0(ret[2]);
171
+ }
172
+ deferred5_0 = ptr4;
173
+ deferred5_1 = len4;
174
+ return getStringFromWasm0(ptr4, len4);
175
+ } finally {
176
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
177
+ }
178
+ }
179
+
180
+ /**
181
+ * @param {string} iso
182
+ * @param {string} pattern
183
+ * @returns {string}
184
+ */
185
+ export function format(iso, pattern) {
186
+ let deferred4_0;
187
+ let deferred4_1;
188
+ try {
189
+ const ptr0 = passStringToWasm0(iso, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
190
+ const len0 = WASM_VECTOR_LEN;
191
+ const ptr1 = passStringToWasm0(pattern, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
192
+ const len1 = WASM_VECTOR_LEN;
193
+ const ret = wasm.format(ptr0, len0, ptr1, len1);
194
+ var ptr3 = ret[0];
195
+ var len3 = ret[1];
196
+ if (ret[3]) {
197
+ ptr3 = 0; len3 = 0;
198
+ throw takeFromExternrefTable0(ret[2]);
199
+ }
200
+ deferred4_0 = ptr3;
201
+ deferred4_1 = len3;
202
+ return getStringFromWasm0(ptr3, len3);
203
+ } finally {
204
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
205
+ }
206
+ }
207
+
208
+ /**
209
+ * @param {string} naive_iso
210
+ * @param {string} zone
211
+ * @returns {string}
212
+ */
213
+ export function from_local(naive_iso, zone) {
214
+ let deferred4_0;
215
+ let deferred4_1;
216
+ try {
217
+ const ptr0 = passStringToWasm0(naive_iso, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
218
+ const len0 = WASM_VECTOR_LEN;
219
+ const ptr1 = passStringToWasm0(zone, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
220
+ const len1 = WASM_VECTOR_LEN;
221
+ const ret = wasm.from_local(ptr0, len0, ptr1, len1);
222
+ var ptr3 = ret[0];
223
+ var len3 = ret[1];
224
+ if (ret[3]) {
225
+ ptr3 = 0; len3 = 0;
226
+ throw takeFromExternrefTable0(ret[2]);
227
+ }
228
+ deferred4_0 = ptr3;
229
+ deferred4_1 = len3;
230
+ return getStringFromWasm0(ptr3, len3);
231
+ } finally {
232
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
233
+ }
234
+ }
235
+
236
+ /**
237
+ * @param {string} input
238
+ * @returns {string}
239
+ */
240
+ export function parse_http(input) {
241
+ let deferred3_0;
242
+ let deferred3_1;
243
+ try {
244
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
245
+ const len0 = WASM_VECTOR_LEN;
246
+ const ret = wasm.parse_http(ptr0, len0);
247
+ var ptr2 = ret[0];
248
+ var len2 = ret[1];
249
+ if (ret[3]) {
250
+ ptr2 = 0; len2 = 0;
251
+ throw takeFromExternrefTable0(ret[2]);
252
+ }
253
+ deferred3_0 = ptr2;
254
+ deferred3_1 = len2;
255
+ return getStringFromWasm0(ptr2, len2);
256
+ } finally {
257
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
258
+ }
259
+ }
260
+
261
+ /**
262
+ * @param {string} input
263
+ * @returns {string}
264
+ */
265
+ export function parse_rfc2822(input) {
266
+ let deferred3_0;
267
+ let deferred3_1;
268
+ try {
269
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
270
+ const len0 = WASM_VECTOR_LEN;
271
+ const ret = wasm.parse_rfc2822(ptr0, len0);
272
+ var ptr2 = ret[0];
273
+ var len2 = ret[1];
274
+ if (ret[3]) {
275
+ ptr2 = 0; len2 = 0;
276
+ throw takeFromExternrefTable0(ret[2]);
277
+ }
278
+ deferred3_0 = ptr2;
279
+ deferred3_1 = len2;
280
+ return getStringFromWasm0(ptr2, len2);
281
+ } finally {
282
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
283
+ }
284
+ }
285
+
286
+ /**
287
+ * @param {string} input
288
+ * @returns {string}
289
+ */
290
+ export function parse_sql(input) {
291
+ let deferred3_0;
292
+ let deferred3_1;
293
+ try {
294
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
295
+ const len0 = WASM_VECTOR_LEN;
296
+ const ret = wasm.parse_sql(ptr0, len0);
297
+ var ptr2 = ret[0];
298
+ var len2 = ret[1];
299
+ if (ret[3]) {
300
+ ptr2 = 0; len2 = 0;
301
+ throw takeFromExternrefTable0(ret[2]);
302
+ }
303
+ deferred3_0 = ptr2;
304
+ deferred3_1 = len2;
305
+ return getStringFromWasm0(ptr2, len2);
306
+ } finally {
307
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
308
+ }
309
+ }
310
+
311
+ /**
312
+ * @param {string} start_iso
313
+ * @param {string} rrule
314
+ * @param {number} limit
315
+ * @returns {any}
316
+ */
317
+ export function rrule_expand(start_iso, rrule, limit) {
318
+ const ptr0 = passStringToWasm0(start_iso, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
319
+ const len0 = WASM_VECTOR_LEN;
320
+ const ptr1 = passStringToWasm0(rrule, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
321
+ const len1 = WASM_VECTOR_LEN;
322
+ const ret = wasm.rrule_expand(ptr0, len0, ptr1, len1, limit);
323
+ if (ret[2]) {
324
+ throw takeFromExternrefTable0(ret[1]);
325
+ }
326
+ return takeFromExternrefTable0(ret[0]);
327
+ }
328
+
329
+ /**
330
+ * @param {string} iso
331
+ * @param {string} unit
332
+ * @returns {string}
333
+ */
334
+ export function start_of(iso, unit) {
335
+ let deferred4_0;
336
+ let deferred4_1;
337
+ try {
338
+ const ptr0 = passStringToWasm0(iso, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
339
+ const len0 = WASM_VECTOR_LEN;
340
+ const ptr1 = passStringToWasm0(unit, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
341
+ const len1 = WASM_VECTOR_LEN;
342
+ const ret = wasm.start_of(ptr0, len0, ptr1, len1);
343
+ var ptr3 = ret[0];
344
+ var len3 = ret[1];
345
+ if (ret[3]) {
346
+ ptr3 = 0; len3 = 0;
347
+ throw takeFromExternrefTable0(ret[2]);
348
+ }
349
+ deferred4_0 = ptr3;
350
+ deferred4_1 = len3;
351
+ return getStringFromWasm0(ptr3, len3);
352
+ } finally {
353
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
354
+ }
355
+ }
356
+
357
+ /**
358
+ * @param {string} utc_iso
359
+ * @param {string} unit
360
+ * @param {string} zone
361
+ * @returns {string}
362
+ */
363
+ export function start_of_in_zone(utc_iso, unit, zone) {
364
+ let deferred5_0;
365
+ let deferred5_1;
366
+ try {
367
+ const ptr0 = passStringToWasm0(utc_iso, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
368
+ const len0 = WASM_VECTOR_LEN;
369
+ const ptr1 = passStringToWasm0(unit, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
370
+ const len1 = WASM_VECTOR_LEN;
371
+ const ptr2 = passStringToWasm0(zone, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
372
+ const len2 = WASM_VECTOR_LEN;
373
+ const ret = wasm.start_of_in_zone(ptr0, len0, ptr1, len1, ptr2, len2);
374
+ var ptr4 = ret[0];
375
+ var len4 = ret[1];
376
+ if (ret[3]) {
377
+ ptr4 = 0; len4 = 0;
378
+ throw takeFromExternrefTable0(ret[2]);
379
+ }
380
+ deferred5_0 = ptr4;
381
+ deferred5_1 = len4;
382
+ return getStringFromWasm0(ptr4, len4);
383
+ } finally {
384
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
385
+ }
386
+ }
387
+
388
+ /**
389
+ * @param {string} utc_iso
390
+ * @param {string} zone
391
+ * @returns {any}
392
+ */
393
+ export function to_zone(utc_iso, zone) {
394
+ const ptr0 = passStringToWasm0(utc_iso, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
395
+ const len0 = WASM_VECTOR_LEN;
396
+ const ptr1 = passStringToWasm0(zone, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
397
+ const len1 = WASM_VECTOR_LEN;
398
+ const ret = wasm.to_zone(ptr0, len0, ptr1, len1);
399
+ if (ret[2]) {
400
+ throw takeFromExternrefTable0(ret[1]);
401
+ }
402
+ return takeFromExternrefTable0(ret[0]);
403
+ }
404
+
405
+ /**
406
+ * @param {string} zone
407
+ * @returns {string}
408
+ */
409
+ export function validate_timezone(zone) {
410
+ let deferred3_0;
411
+ let deferred3_1;
412
+ try {
413
+ const ptr0 = passStringToWasm0(zone, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
414
+ const len0 = WASM_VECTOR_LEN;
415
+ const ret = wasm.validate_timezone(ptr0, len0);
416
+ var ptr2 = ret[0];
417
+ var len2 = ret[1];
418
+ if (ret[3]) {
419
+ ptr2 = 0; len2 = 0;
420
+ throw takeFromExternrefTable0(ret[2]);
421
+ }
422
+ deferred3_0 = ptr2;
423
+ deferred3_1 = len2;
424
+ return getStringFromWasm0(ptr2, len2);
425
+ } finally {
426
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
427
+ }
428
+ }
429
+
430
+ /**
431
+ * @param {string} utc_iso
432
+ * @param {string} zone
433
+ * @returns {number}
434
+ */
435
+ export function zone_offset(utc_iso, zone) {
436
+ const ptr0 = passStringToWasm0(utc_iso, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
437
+ const len0 = WASM_VECTOR_LEN;
438
+ const ptr1 = passStringToWasm0(zone, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
439
+ const len1 = WASM_VECTOR_LEN;
440
+ const ret = wasm.zone_offset(ptr0, len0, ptr1, len1);
441
+ if (ret[2]) {
442
+ throw takeFromExternrefTable0(ret[1]);
443
+ }
444
+ return ret[0];
445
+ }
446
+ function __wbg_get_imports() {
447
+ const import0 = {
448
+ __proto__: null,
449
+ __wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
450
+ throw new Error(getStringFromWasm0(arg0, arg1));
451
+ },
452
+ __wbg_new_116be93542d39019: function() {
453
+ const ret = new Array();
454
+ return ret;
455
+ },
456
+ __wbg_new_ebe3e0f6837f0879: function() {
457
+ const ret = new Object();
458
+ return ret;
459
+ },
460
+ __wbg_push_adb0107829f02d75: function(arg0, arg1) {
461
+ const ret = arg0.push(arg1);
462
+ return ret;
463
+ },
464
+ __wbg_set_8155bb79a948541b: function() { return handleError(function (arg0, arg1, arg2) {
465
+ const ret = Reflect.set(arg0, arg1, arg2);
466
+ return ret;
467
+ }, arguments); },
468
+ __wbindgen_cast_0000000000000001: function(arg0) {
469
+ // Cast intrinsic for `F64 -> Externref`.
470
+ const ret = arg0;
471
+ return ret;
472
+ },
473
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
474
+ // Cast intrinsic for `Ref(String) -> Externref`.
475
+ const ret = getStringFromWasm0(arg0, arg1);
476
+ return ret;
477
+ },
478
+ __wbindgen_init_externref_table: function() {
479
+ const table = wasm.__wbindgen_externrefs;
480
+ const offset = table.grow(4);
481
+ table.set(0, undefined);
482
+ table.set(offset + 0, undefined);
483
+ table.set(offset + 1, null);
484
+ table.set(offset + 2, true);
485
+ table.set(offset + 3, false);
486
+ },
487
+ };
488
+ return {
489
+ __proto__: null,
490
+ "./chronos_engine_wasm_bg.js": import0,
491
+ };
492
+ }
493
+
494
+ function addToExternrefTable0(obj) {
495
+ const idx = wasm.__externref_table_alloc();
496
+ wasm.__wbindgen_externrefs.set(idx, obj);
497
+ return idx;
498
+ }
499
+
500
+ function getStringFromWasm0(ptr, len) {
501
+ return decodeText(ptr >>> 0, len);
502
+ }
503
+
504
+ let cachedUint8ArrayMemory0 = null;
505
+ function getUint8ArrayMemory0() {
506
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
507
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
508
+ }
509
+ return cachedUint8ArrayMemory0;
510
+ }
511
+
512
+ function handleError(f, args) {
513
+ try {
514
+ return f.apply(this, args);
515
+ } catch (e) {
516
+ const idx = addToExternrefTable0(e);
517
+ wasm.__wbindgen_exn_store(idx);
518
+ }
519
+ }
520
+
521
+ function passStringToWasm0(arg, malloc, realloc) {
522
+ if (realloc === undefined) {
523
+ const buf = cachedTextEncoder.encode(arg);
524
+ const ptr = malloc(buf.length, 1) >>> 0;
525
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
526
+ WASM_VECTOR_LEN = buf.length;
527
+ return ptr;
528
+ }
529
+
530
+ let len = arg.length;
531
+ let ptr = malloc(len, 1) >>> 0;
532
+
533
+ const mem = getUint8ArrayMemory0();
534
+
535
+ let offset = 0;
536
+
537
+ for (; offset < len; offset++) {
538
+ const code = arg.charCodeAt(offset);
539
+ if (code > 0x7F) break;
540
+ mem[ptr + offset] = code;
541
+ }
542
+ if (offset !== len) {
543
+ if (offset !== 0) {
544
+ arg = arg.slice(offset);
545
+ }
546
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
547
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
548
+ const ret = cachedTextEncoder.encodeInto(arg, view);
549
+
550
+ offset += ret.written;
551
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
552
+ }
553
+
554
+ WASM_VECTOR_LEN = offset;
555
+ return ptr;
556
+ }
557
+
558
+ function takeFromExternrefTable0(idx) {
559
+ const value = wasm.__wbindgen_externrefs.get(idx);
560
+ wasm.__externref_table_dealloc(idx);
561
+ return value;
562
+ }
563
+
564
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
565
+ cachedTextDecoder.decode();
566
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
567
+ let numBytesDecoded = 0;
568
+ function decodeText(ptr, len) {
569
+ numBytesDecoded += len;
570
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
571
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
572
+ cachedTextDecoder.decode();
573
+ numBytesDecoded = len;
574
+ }
575
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
576
+ }
577
+
578
+ const cachedTextEncoder = new TextEncoder();
579
+
580
+ if (!('encodeInto' in cachedTextEncoder)) {
581
+ cachedTextEncoder.encodeInto = function (arg, view) {
582
+ const buf = cachedTextEncoder.encode(arg);
583
+ view.set(buf);
584
+ return {
585
+ read: arg.length,
586
+ written: buf.length
587
+ };
588
+ };
589
+ }
590
+
591
+ let WASM_VECTOR_LEN = 0;
592
+
593
+ let wasmModule, wasmInstance, wasm;
594
+ function __wbg_finalize_init(instance, module) {
595
+ wasmInstance = instance;
596
+ wasm = instance.exports;
597
+ wasmModule = module;
598
+ cachedUint8ArrayMemory0 = null;
599
+ wasm.__wbindgen_start();
600
+ return wasm;
601
+ }
602
+
603
+ async function __wbg_load(module, imports) {
604
+ if (typeof Response === 'function' && module instanceof Response) {
605
+ if (!module.ok) {
606
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
607
+ }
608
+
609
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
610
+ try {
611
+ return await WebAssembly.instantiateStreaming(module, imports);
612
+ } catch (e) {
613
+ const validResponse = expectedResponseType(module.type);
614
+
615
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
616
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
617
+
618
+ } else { throw e; }
619
+ }
620
+ }
621
+
622
+ const bytes = await module.arrayBuffer();
623
+ return await WebAssembly.instantiate(bytes, imports);
624
+ } else {
625
+ const instance = await WebAssembly.instantiate(module, imports);
626
+
627
+ if (instance instanceof WebAssembly.Instance) {
628
+ return { instance, module };
629
+ } else {
630
+ return instance;
631
+ }
632
+ }
633
+
634
+ function expectedResponseType(type) {
635
+ switch (type) {
636
+ case 'basic': case 'cors': case 'default': return true;
637
+ }
638
+ return false;
639
+ }
640
+ }
641
+
642
+ function initSync(module) {
643
+ if (wasm !== undefined) return wasm;
644
+
645
+
646
+ if (module !== undefined) {
647
+ if (Object.getPrototypeOf(module) === Object.prototype) {
648
+ ({module} = module)
649
+ } else {
650
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
651
+ }
652
+ }
653
+
654
+ const imports = __wbg_get_imports();
655
+ if (!(module instanceof WebAssembly.Module)) {
656
+ module = new WebAssembly.Module(module);
657
+ }
658
+ const instance = new WebAssembly.Instance(module, imports);
659
+ return __wbg_finalize_init(instance, module);
660
+ }
661
+
662
+ async function __wbg_init(module_or_path) {
663
+ if (wasm !== undefined) return wasm;
664
+
665
+
666
+ if (module_or_path !== undefined) {
667
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
668
+ ({module_or_path} = module_or_path)
669
+ } else {
670
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
671
+ }
672
+ }
673
+
674
+ if (module_or_path === undefined) {
675
+ module_or_path = new URL('chronos_engine_wasm_bg.wasm', import.meta.url);
676
+ }
677
+ const imports = __wbg_get_imports();
678
+
679
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
680
+ module_or_path = fetch(module_or_path);
681
+ }
682
+
683
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
684
+
685
+ return __wbg_finalize_init(instance, module);
686
+ }
687
+
688
+ export { initSync, __wbg_init as default };
Binary file
@@ -0,0 +1,29 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const add: (a: number, b: number, c: bigint, d: number, e: number) => [number, number, number, number];
5
+ export const add_in_zone: (a: number, b: number, c: bigint, d: number, e: number, f: number, g: number) => [number, number, number, number];
6
+ export const calendar_parts: (a: number, b: number) => [number, number, number];
7
+ export const diff: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
8
+ export const diff_in_zone: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number];
9
+ export const end_of: (a: number, b: number, c: number, d: number) => [number, number, number, number];
10
+ export const end_of_in_zone: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
11
+ export const format: (a: number, b: number, c: number, d: number) => [number, number, number, number];
12
+ export const from_local: (a: number, b: number, c: number, d: number) => [number, number, number, number];
13
+ export const parse_http: (a: number, b: number) => [number, number, number, number];
14
+ export const parse_rfc2822: (a: number, b: number) => [number, number, number, number];
15
+ export const parse_sql: (a: number, b: number) => [number, number, number, number];
16
+ export const rrule_expand: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
17
+ export const start_of: (a: number, b: number, c: number, d: number) => [number, number, number, number];
18
+ export const start_of_in_zone: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
19
+ export const to_zone: (a: number, b: number, c: number, d: number) => [number, number, number];
20
+ export const validate_timezone: (a: number, b: number) => [number, number, number, number];
21
+ export const zone_offset: (a: number, b: number, c: number, d: number) => [number, number, number];
22
+ export const __wbindgen_exn_store: (a: number) => void;
23
+ export const __externref_table_alloc: () => number;
24
+ export const __wbindgen_externrefs: WebAssembly.Table;
25
+ export const __wbindgen_malloc: (a: number, b: number) => number;
26
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
27
+ export const __externref_table_dealloc: (a: number) => void;
28
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
29
+ export const __wbindgen_start: () => void;