teptris 0.3.32 → 0.3.34

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/dist/teptris.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teptris",
3
- "version": "0.3.32",
3
+ "version": "0.3.34",
4
4
  "description": "TOML for JavaScript/TypeScript at libteptris speed (WebAssembly, no fallback) - version tracks the engine ({engine}.{iteration}; npm semver is 3-part)",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/index.js CHANGED
@@ -389,8 +389,31 @@ export function initApi(mod) {
389
389
  byte(3); i64(v); return;
390
390
  }
391
391
  if (typeof v === "string") {
392
+ // RFC 3339-SHAPED strings re-enter as datetimes. The literal
393
+ // rides as raw TEXT (writer op 0x0F, engine 0.3.27) and the
394
+ // ENGINE parses it at op decode - the JS regex field
395
+ // extraction is gone from the hot path (datetime_heavy was
396
+ // parseDateTime-bound). Output stays byte-identical: the
397
+ // writer emits canonical datetime text from the parsed
398
+ // fields. A shape-valid, calendar-invalid literal (2026-02-30)
399
+ // now errors loudly instead of re-entering as invalid TOML.
392
400
  if (maybeRfc3339(v) && RFC3339.test(v)) {
393
- writeDatetime(null, parseDateTime(v));
401
+ ensure(5 + v.length * 3);
402
+ buf[n++] = 15; /* W_DATETIME_TEXT */
403
+ let ascii = true;
404
+ for (let i = 0; i < v.length; i++) {
405
+ const c = v.charCodeAt(i);
406
+ if (c > 127) { ascii = false; break; }
407
+ buf[n + 4 + i] = c;
408
+ }
409
+ if (ascii) {
410
+ dv.setUint32(n, v.length, true);
411
+ n += 4 + v.length;
412
+ } else {
413
+ const { written } = utf8enc.encodeInto(v, buf.subarray(n + 4));
414
+ dv.setUint32(n, written, true);
415
+ n += 4 + written;
416
+ }
394
417
  return;
395
418
  }
396
419
  ensure(5 + v.length * 3);
@@ -501,7 +524,8 @@ export function initApi(mod) {
501
524
  const st = mod._teptris_wasm_dump_ops(ptr, n);
502
525
  mod._teptris_wasm_free(ptr);
503
526
  if (st !== 0) {
504
- throw new Error(`dump failed (status ${st})`);
527
+ throw new Error(`dump failed (status ${st}): ${
528
+ UTF8ToString(mod._teptris_wasm_last_error())}`);
505
529
  }
506
530
  return readOut(mod._teptris_wasm_toml());
507
531
  }
@@ -209,6 +209,8 @@ int teptris_wasm_dump_doc(void) {
209
209
  /* fused dumps: the JS side encodes one op-stream (writer grammar),
210
210
  * this builds TOML in one crossing - no per-value builder calls, no
211
211
  * DOM */
212
+
213
+
212
214
  EMSCRIPTEN_KEEPALIVE
213
215
  int teptris_wasm_dump_ops(const uint8_t *ops, size_t len) {
214
216
  teptris_writer *w = teptris_writer_new();
@@ -233,7 +235,6 @@ int teptris_wasm_dump_ops(const uint8_t *ops, size_t len) {
233
235
  return (int)st;
234
236
  }
235
237
 
236
-
237
238
  static int finish_with(void *b,
238
239
  teptris_status (*emit)(const teptris_document *,
239
240
  char **, size_t *)) {