@scriptc/cli-darwin-arm64 0.2.1 → 0.2.2

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 (118) hide show
  1. package/dist/THIRD_PARTY_NOTICES +1 -1
  2. package/dist/bin/scriptc +0 -0
  3. package/dist/bin/scriptc.json +1 -1
  4. package/dist/lib/declarations/scriptc-node-fallback.d.ts +59 -4
  5. package/dist/lib/llvm/bin/scriptc-llvm-codegen +0 -0
  6. package/dist/lib/llvm/package.json +1 -1
  7. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_async.o +0 -0
  8. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_async_dyn.o +0 -0
  9. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_bytes.o +0 -0
  10. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_bytes_io.o +0 -0
  11. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_crypto_async.o +0 -0
  12. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_dyn_invoke.o +0 -0
  13. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_file_handle.o +0 -0
  14. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_json.o +0 -0
  15. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_lib.o +0 -0
  16. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_qs.o +0 -0
  17. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_regex.o +0 -0
  18. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/default/scr_url.o +0 -0
  19. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_async.o +0 -0
  20. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_async_dyn.o +0 -0
  21. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_bytes.o +0 -0
  22. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_bytes_io.o +0 -0
  23. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_crypto_async.o +0 -0
  24. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_dyn_invoke.o +0 -0
  25. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_file_handle.o +0 -0
  26. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_island.o +0 -0
  27. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_json.o +0 -0
  28. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_lib.o +0 -0
  29. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_qs.o +0 -0
  30. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_regex.o +0 -0
  31. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_url.o +0 -0
  32. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic/scr_web.o +0 -0
  33. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/dynamic-text-decoder-legacy/scr_bytes.o +0 -0
  34. package/dist/lib/runtime-darwin-arm64/artifacts/dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
  35. package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_bytes.o +0 -0
  36. package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_bytes_io.o +0 -0
  37. package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_dyn_invoke.o +0 -0
  38. package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_json.o +0 -0
  39. package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_lib.o +0 -0
  40. package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_regex.o +0 -0
  41. package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/default/scr_url.o +0 -0
  42. package/dist/lib/runtime-darwin-arm64/artifacts/library-dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
  43. package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_bytes.o +0 -0
  44. package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_bytes_io.o +0 -0
  45. package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_dyn_invoke.o +0 -0
  46. package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_json.o +0 -0
  47. package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_lib.o +0 -0
  48. package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_regex.o +0 -0
  49. package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/default/scr_url.o +0 -0
  50. package/dist/lib/runtime-darwin-arm64/artifacts/library-release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
  51. package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_bytes.o +0 -0
  52. package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_bytes_io.o +0 -0
  53. package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_dyn_invoke.o +0 -0
  54. package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_json.o +0 -0
  55. package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_lib.o +0 -0
  56. package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_regex.o +0 -0
  57. package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/default/scr_url.o +0 -0
  58. package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
  59. package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_bytes.o +0 -0
  60. package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_bytes_io.o +0 -0
  61. package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_dyn_invoke.o +0 -0
  62. package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_json.o +0 -0
  63. package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_lib.o +0 -0
  64. package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_regex.o +0 -0
  65. package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/default/scr_url.o +0 -0
  66. package/dist/lib/runtime-darwin-arm64/artifacts/library-thread-release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
  67. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_async.o +0 -0
  68. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_async_dyn.o +0 -0
  69. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_bytes.o +0 -0
  70. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_bytes_io.o +0 -0
  71. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_crypto_async.o +0 -0
  72. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_dyn_invoke.o +0 -0
  73. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_file_handle.o +0 -0
  74. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_json.o +0 -0
  75. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_lib.o +0 -0
  76. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_qs.o +0 -0
  77. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_regex.o +0 -0
  78. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/default/scr_url.o +0 -0
  79. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_async.o +0 -0
  80. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_async_dyn.o +0 -0
  81. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_bytes.o +0 -0
  82. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_bytes_io.o +0 -0
  83. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_crypto_async.o +0 -0
  84. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_dyn_invoke.o +0 -0
  85. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_file_handle.o +0 -0
  86. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_island.o +0 -0
  87. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_json.o +0 -0
  88. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_lib.o +0 -0
  89. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_qs.o +0 -0
  90. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_regex.o +0 -0
  91. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_url.o +0 -0
  92. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic/scr_web.o +0 -0
  93. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/dynamic-text-decoder-legacy/scr_bytes.o +0 -0
  94. package/dist/lib/runtime-darwin-arm64/artifacts/release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
  95. package/dist/lib/runtime-darwin-arm64/package.json +1 -1
  96. package/dist/lib/runtime-darwin-arm64/runtime-pack.json +177 -177
  97. package/dist/lib/runtime-sources/package.json +1 -1
  98. package/dist/lib/runtime-sources/src/scr_abort.c +5 -0
  99. package/dist/lib/runtime-sources/src/scr_async.c +12 -4
  100. package/dist/lib/runtime-sources/src/scr_async_dyn.c +118 -24
  101. package/dist/lib/runtime-sources/src/scr_bytes.c +226 -0
  102. package/dist/lib/runtime-sources/src/scr_bytes_io.c +52 -5
  103. package/dist/lib/runtime-sources/src/scr_crypto_async.c +22 -2
  104. package/dist/lib/runtime-sources/src/scr_dyn_invoke.c +181 -43
  105. package/dist/lib/runtime-sources/src/scr_fetch.c +45 -1
  106. package/dist/lib/runtime-sources/src/scr_file_handle.c +31 -0
  107. package/dist/lib/runtime-sources/src/scr_island.c +1188 -392
  108. package/dist/lib/runtime-sources/src/scr_island_manifest.h +11 -9
  109. package/dist/lib/runtime-sources/src/scr_json.c +449 -52
  110. package/dist/lib/runtime-sources/src/scr_json.test.ts +1 -0
  111. package/dist/lib/runtime-sources/src/scr_lib.c +816 -34
  112. package/dist/lib/runtime-sources/src/scr_qs.c +10 -0
  113. package/dist/lib/runtime-sources/src/scr_regex.c +42 -5
  114. package/dist/lib/runtime-sources/src/scr_runtime.h +67 -8
  115. package/dist/lib/runtime-sources/src/scr_text_decoder_labels.h +12 -12
  116. package/dist/lib/runtime-sources/src/scr_url.c +34 -7
  117. package/dist/lib/runtime-sources/src/scr_web.c +129 -26
  118. package/package.json +1 -1
@@ -460,6 +460,12 @@ static void qs_stringify_value(QsBuf *b, const ScrDyn *v) {
460
460
 
461
461
  ScrStr *scr_qs_stringify(const ScrDyn *obj, const ScrStr *sep,
462
462
  const ScrStr *eq) {
463
+ if (obj && obj->kind == SCR_DYN_TYPED_REF) {
464
+ ScrDyn *view = scr_dyn_typed_ref_materialize(obj);
465
+ ScrStr *result = view && !scr_exc_pending() ? scr_qs_stringify(view, sep, eq) : NULL;
466
+ scr_dyn_release(view);
467
+ return result;
468
+ }
463
469
  const char *sep_b = (sep && sep->len) ? sep->data : "&";
464
470
  size_t sep_len = (sep && sep->len) ? sep->len : 1;
465
471
  const char *eq_b = (eq && eq->len) ? eq->data : "=";
@@ -475,6 +481,9 @@ ScrStr *scr_qs_stringify(const ScrDyn *obj, const ScrStr *sep,
475
481
  const ScrStr *k = kd->v.str;
476
482
  const ScrDyn *v = scr_dyn_obj_get(obj, k->data, k->len);
477
483
  if (!v) continue; /* unreachable: keys came from the object */
484
+ ScrDyn *view = v->kind == SCR_DYN_TYPED_REF ? scr_dyn_typed_ref_materialize(v) : NULL;
485
+ if (view) v = view;
486
+ if (scr_exc_pending()) { scr_dyn_release(view); scr_dyn_release(keys); free(fields.data); return NULL; }
478
487
  ScrStr *ks = scr_str_encode_uri_component((ScrStr *)k);
479
488
  if (v->kind == SCR_DYN_ARR) {
480
489
  for (size_t j = 0; j < v->v.arr.len; j++) {
@@ -490,6 +499,7 @@ ScrStr *scr_qs_stringify(const ScrDyn *obj, const ScrStr *sep,
490
499
  qs_stringify_value(&fields, v);
491
500
  }
492
501
  scr_str_release(ks);
502
+ scr_dyn_release(view);
493
503
  }
494
504
  scr_dyn_release(keys);
495
505
  return qb_take(&fields);
@@ -439,8 +439,8 @@ static int scr_regex_start(ScrRegex *re, int len) {
439
439
  /* re.exec(s): a fresh string[] of [whole match, ...captures], or NULL
440
440
  * for no match (the compiler wraps the `string[] | null` union). Global
441
441
  * and sticky regexes start at lastIndex, set it to the match end, and
442
- * reset it on failure. Nonparticipating captures retain the documented
443
- * empty-string representation. */
442
+ * reset it on failure. Nonparticipating captures are present undefined
443
+ * elements, distinct from participating empty captures and array holes. */
444
444
  ScrArr *scr_regex_exec(ScrStr *s, ScrRegex *re) {
445
445
  uint8_t *bc = scr_regex_bc(re);
446
446
  bool stateful = (lre_get_flags(bc) & (LRE_FLAG_GLOBAL | LRE_FLAG_STICKY)) != 0;
@@ -462,7 +462,7 @@ ScrArr *scr_regex_exec(ScrStr *s, ScrRegex *re) {
462
462
  for (int k = 0; k < count; k++) {
463
463
  const uint8_t *cs = capture[2 * k], *ce = capture[2 * k + 1];
464
464
  if (cs == NULL || ce == NULL) {
465
- scr_arr_push_ref(out, scr_str_new("", 0));
465
+ scr_arr_set_undefined(out, (double)out->len);
466
466
  } else {
467
467
  scr_arr_push_ref(
468
468
  out, scr_str_from_utf16(u, (int)((cs - ubase) >> 1), (int)((ce - ubase) >> 1)));
@@ -525,7 +525,7 @@ double scr_regex_search(ScrStr *s, ScrRegex *re) {
525
525
  }
526
526
 
527
527
  /* matchAll(re): every match as its honest slice string[] (whole match +
528
- * captures, nonparticipating = "" — match()'s rule) drained EAGERLY into
528
+ * captures, nonparticipating = undefined — match()'s rule) drained EAGERLY into
529
529
  * a fresh string[][]. The lazy iterator is unobservable across the
530
530
  * lowered surface: strings are immutable and the spec clones the regex at
531
531
  * the call, so nothing can perturb the drain. Non-global regexes throw
@@ -559,7 +559,7 @@ static ScrArr *scr_regex_match_all_core(ScrStr *s, ScrRegex *re, ScrArr *indices
559
559
  for (int k = 0; k < capture_count; k++) {
560
560
  const uint8_t *cs = capture[2 * k], *ce = capture[2 * k + 1];
561
561
  if (cs == NULL || ce == NULL) {
562
- scr_arr_push_ref(row, scr_str_new("", 0));
562
+ scr_arr_set_undefined(row, (double)row->len);
563
563
  } else {
564
564
  scr_arr_push_ref(
565
565
  row, scr_str_from_utf16(u, (int)((cs - ubase) >> 1), (int)((ce - ubase) >> 1)));
@@ -923,6 +923,43 @@ static ScrStr *scr_str_case_conv(const ScrStr *s, int to_lower) {
923
923
  ScrStr *scr_str_to_lower(const ScrStr *s) { return scr_str_case_conv(s, 1); }
924
924
  ScrStr *scr_str_to_upper(const ScrStr *s) { return scr_str_case_conv(s, 0); }
925
925
 
926
+ static void *scr_normalize_realloc(void *opaque, void *ptr, size_t size) {
927
+ (void)opaque;
928
+ if (!size) { free(ptr); return NULL; }
929
+ return realloc(ptr, size);
930
+ }
931
+
932
+ ScrStr *scr_str_normalize(const ScrStr *s, const ScrStr *form) {
933
+ UnicodeNormalizationEnum mode;
934
+ if (form->len == 3 && !memcmp(form->data, "NFC", 3)) mode = UNICODE_NFC;
935
+ else if (form->len == 3 && !memcmp(form->data, "NFD", 3)) mode = UNICODE_NFD;
936
+ else if (form->len == 4 && !memcmp(form->data, "NFKC", 4)) mode = UNICODE_NFKC;
937
+ else if (form->len == 4 && !memcmp(form->data, "NFKD", 4)) mode = UNICODE_NFKD;
938
+ else {
939
+ static const char message[] = "The normalization form should be one of NFC, NFD, NFKC, NFKD.";
940
+ scr_throw_error(SCR_ERR_RANGE, scr_str_new(message, sizeof message - 1));
941
+ return NULL;
942
+ }
943
+ if (s->len > INT32_MAX / sizeof(uint32_t)) scr_regex_oom();
944
+ uint32_t *input = malloc((s->len + 1) * sizeof(uint32_t));
945
+ if (!input) scr_regex_oom();
946
+ int length = 0;
947
+ for (size_t offset = 0; offset < s->len;) {
948
+ size_t step;
949
+ input[length++] = scr_case_decode(s->data + offset, &step);
950
+ offset += step;
951
+ }
952
+ uint32_t *output = NULL;
953
+ int count = unicode_normalize(&output, input, length, mode, NULL, scr_normalize_realloc);
954
+ free(input);
955
+ if (count < 0) scr_regex_oom();
956
+ ScrJsonBuf buffer;
957
+ scr_jb_init(&buffer);
958
+ for (int i = 0; i < count; i++) scr_case_put_cp(&buffer, output[i]);
959
+ free(output);
960
+ return scr_jb_finish(&buffer);
961
+ }
962
+
926
963
  /* ── assert.match / assert.doesNotMatch ──────────────────────────────────
927
964
  * Lives here because it needs the matcher. Assertion matching follows
928
965
  * RegExp.test, including global and sticky lastIndex transitions. */
@@ -522,6 +522,13 @@ struct ScrDyn *scr_dyn_class_base_prototype(struct ScrDyn *constructor);
522
522
  struct ScrDyn *scr_dyn_class_inherit(struct ScrDyn *constructor, struct ScrDyn *base);
523
523
  void scr_dyn_class_super(struct ScrDyn *constructor, struct ScrDyn *receiver, struct ScrDyn *arguments);
524
524
  struct ScrDyn *scr_dyn_assign_prototype(struct ScrDyn *target, struct ScrDyn *sources, struct ScrDyn *protected_keys);
525
+ struct ScrDyn *scr_dyn_bag_get(struct ScrDyn *bag, ScrStr *key, struct ScrDyn *receiver);
526
+ struct ScrDyn *scr_dyn_reflect_get(struct ScrDyn *target, struct ScrDyn *key, struct ScrDyn *receiver);
527
+ bool scr_dyn_reflect_set(struct ScrDyn *target, struct ScrDyn *key, struct ScrDyn *value, struct ScrDyn *receiver);
528
+ bool scr_dyn_reflect_define(struct ScrDyn *receiver, struct ScrDyn *key, struct ScrDyn *value);
529
+ bool scr_dyn_abstract_eq(const struct ScrDyn *left, const struct ScrDyn *right);
530
+ int scr_dyn_function_kind(const struct ScrDyn *value);
531
+ void scr_dyn_bag_set(struct ScrDyn *bag, ScrStr *key, struct ScrDyn *value, struct ScrDyn *receiver);
525
532
  /* The keyed-write miss on a fixed-shape record: throws the catchable
526
533
  * TypeError naming the key (JS would add the property — the documented
527
534
  * monomorphic-struct divergence). scr_object.c. */
@@ -772,6 +779,7 @@ ScrStr *scr_str_trim(ScrStr *s);
772
779
  * sets the regex link flag for case-conversion sites). Borrow s; +1. */
773
780
  ScrStr *scr_str_to_lower(const ScrStr *s);
774
781
  ScrStr *scr_str_to_upper(const ScrStr *s);
782
+ ScrStr *scr_str_normalize(const ScrStr *s, const ScrStr *form);
775
783
 
776
784
  /* charAt(i): 1-code-unit string; out of range → empty string. Half of an
777
785
  * astral pair → U+FFFD (divergence, see above). Returns +1. */
@@ -904,6 +912,12 @@ void scr_qs_parse_into(ScrMap *out, const ScrStr *qs, const ScrStr *sep,
904
912
  * Borrows config; returns +1, or NULL with a Node-coded TypeError pending. */
905
913
  struct ScrDyn *scr_util_parse_args(const struct ScrDyn *config);
906
914
 
915
+ /* Node 24's dotenv grammar, shared by util.parseEnv and process.loadEnvFile.
916
+ * Arguments are borrowed; parseEnv returns a fresh ordinary object (+1).
917
+ * Validation and file failures leave a coded exception pending. */
918
+ struct ScrDyn *scr_util_parse_env(const struct ScrDyn *content);
919
+ void scr_process_load_env_file(const struct ScrDyn *path);
920
+
907
921
  /* querystring.stringify — Node's stringify over a borrowed dyn value (the
908
922
  * frontend dynFroms the typed record; JS-world dyn values pass straight
909
923
  * through). Non-object dyn values answer "" like Node; object keys iterate in
@@ -1545,7 +1559,7 @@ typedef struct ScrClosure {
1545
1559
  * (like the dyn→closure edge): a cycle through it is merely never
1546
1560
  * collected. */
1547
1561
  ScrBox *props;
1548
- uint32_t function_kind; /* low bits: 0 ordinary, 1 generator, 2 async, 3 async generator; bit 2: ordinary own prototype */
1562
+ uint32_t function_kind; /* low bits: 0 ordinary, 1 generator, 2 async, 3 async generator; bit 2: ordinary own prototype; bit 3: checked callable adapter in caps[0] */
1549
1563
  ScrBox *caps[];
1550
1564
  } ScrClosure;
1551
1565
 
@@ -2599,6 +2613,8 @@ ScrStats *scr_fs_lstat(ScrStr *path); /* +1, or throws; NO follow (lstat) */
2599
2613
  ScrStats *scr_fs_fstat(double fd); /* +1, or throws */
2600
2614
  void scr_fs_fchmod(double fd, double mode);
2601
2615
  void scr_fs_fsync(double fd);
2616
+ void scr_fs_fdatasync(double fd);
2617
+ void scr_fs_ftruncate(double fd, double length);
2602
2618
  void scr_fs_link(ScrStr *source, ScrStr *dest);
2603
2619
  ScrStats *scr_stats_retain(ScrStats *s);
2604
2620
  void scr_stats_release(ScrStats *s);
@@ -3053,22 +3069,33 @@ ScrBytes *scr_crypto_random_fill_rest(ScrBytes *bytes, double offset);
3053
3069
  double scr_crypto_random_int(double min, double max);
3054
3070
  ScrBytes *scr_crypto_pbkdf2(ScrBytes *password, ScrBytes *salt,
3055
3071
  double iterations, double keylen, ScrStr *digest);
3056
- typedef void (*ScrCryptoBytesFn)(ScrClosure *cb, ScrBytes *value /* moves */);
3057
- void scr_crypto_defer_bytes(ScrBytes *value /* moves */, ScrClosure *cb /* moves */,
3072
+ ScrBytes *scr_crypto_hkdf_bytes(ScrStr *digest, ScrBytes *ikm, ScrBytes *salt,
3073
+ ScrBytes *info, double keylen);
3074
+ ScrDyn *scr_crypto_hkdf(ScrStr *digest, ScrBytes *ikm, ScrBytes *salt,
3075
+ ScrBytes *info, double keylen);
3076
+ ScrBytes *scr_crypto_scrypt(ScrBytes *password, ScrBytes *salt, double keylen, ScrDyn *options);
3077
+ ScrBytes *scr_crypto_scrypt_derive(ScrBytes *password, ScrBytes *salt, double keylen,
3078
+ double n, double r, double p, double maxmem);
3079
+ typedef void (*ScrCryptoBytesFn)(ScrClosure *cb, ScrError *error /* borrowed */, ScrBytes *value /* moves */);
3080
+ void scr_crypto_defer_bytes(ScrBytes *value /* moves */, ScrError *error /* moves */, ScrClosure *cb /* moves */,
3058
3081
  ScrCryptoBytesFn fn);
3059
3082
  void scr_crypto_random_bytes_async(double size, ScrClosure *cb /* moves */,
3060
3083
  ScrCryptoBytesFn fn);
3061
3084
  void scr_crypto_pbkdf2_async(ScrBytes *password, ScrBytes *salt,
3062
3085
  double iterations, double keylen, ScrStr *digest,
3063
3086
  ScrClosure *cb /* moves */, ScrCryptoBytesFn fn);
3064
- /* One-shot raw digest/HMAC by algorithm name ("md5" | "sha1" | "sha256")
3087
+ void scr_crypto_hkdf_async(ScrStr *digest, ScrBytes *ikm, ScrBytes *salt,
3088
+ ScrBytes *info, double keylen, ScrClosure *cb, ScrCryptoBytesFn fn);
3089
+ void scr_crypto_scrypt_async(ScrBytes *password, ScrBytes *salt, double keylen,
3090
+ ScrDyn *options, ScrClosure *cb, ScrCryptoBytesFn fn);
3091
+ /* One-shot raw digest/HMAC by algorithm name ("md5", "sha1", and SHA-2)
3065
3092
  * — the island crypto shim's bridge (scr_island.c host hooks). Digest
3066
- * bytes into out (≥32); returns the digest length, 0 for an unknown
3093
+ * bytes into out (≥64); returns the digest length, 0 for an unknown
3067
3094
  * algorithm. */
3068
3095
  size_t scr_crypto_digest_raw(const char *alg, const unsigned char *data, size_t len,
3069
- unsigned char out[32]);
3096
+ unsigned char out[64]);
3070
3097
  size_t scr_crypto_hmac_raw(const char *alg, const unsigned char *key, size_t keylen,
3071
- const unsigned char *data, size_t len, unsigned char out[32]);
3098
+ const unsigned char *data, size_t len, unsigned char out[64]);
3072
3099
  /* The composed `new crypto.X509Certificate(data).fingerprint` read (the
3073
3100
  * handle never materializes): the SHA-1 of the DER, uppercase
3074
3101
  * colon-separated — PEM or raw-DER input; anything else throws Node's
@@ -3129,6 +3156,9 @@ ScrStr *scr_path_win32_to_namespaced_path(ScrStr *path);
3129
3156
  * The pair behind spawn's fd-stdio form. */
3130
3157
  double scr_fs_open(ScrStr *path, ScrStr *flags);
3131
3158
  double scr_fs_open_numeric(ScrStr *path, double flags, double mode);
3159
+ /* Engine callers supply the target OS's flags, rather than the frontend's
3160
+ * portable constant mask. Argument validation happens before this seam. */
3161
+ double scr_fs_open_native(ScrStr *path, double flags, double mode);
3132
3162
  ScrFileHandle *scr_file_handle_open(ScrStr *path, ScrStr *flags, double mode);
3133
3163
  ScrFileHandle *scr_file_handle_retain(ScrFileHandle *h);
3134
3164
  void scr_file_handle_release(ScrFileHandle *h);
@@ -3136,6 +3166,12 @@ void *scr_file_handle_retain_v(void *p);
3136
3166
  void scr_file_handle_release_v(void *p);
3137
3167
  double scr_file_handle_fd(ScrFileHandle *h);
3138
3168
  void scr_file_handle_close(ScrFileHandle *h);
3169
+ ScrPromise *scr_file_handle_sync_promise(ScrFileHandle *h);
3170
+ ScrPromise *scr_file_handle_datasync_promise(ScrFileHandle *h);
3171
+ ScrPromise *scr_file_handle_truncate_promise(ScrFileHandle *h, double length);
3172
+ ScrPromise *scr_file_handle_chmod_promise(ScrFileHandle *h, double mode);
3173
+ double scr_file_handle_readv(ScrFileHandle *h, ScrArr *buffers, double position);
3174
+ double scr_file_handle_writev(ScrFileHandle *h, ScrArr *buffers, double position);
3139
3175
  double scr_file_handle_read(ScrFileHandle *h, ScrBytes *buf, double offset,
3140
3176
  double length, double position, bool length_default);
3141
3177
  double scr_file_handle_write_bytes(ScrFileHandle *h, ScrBytes *buf,
@@ -3159,6 +3195,11 @@ double scr_fs_write_sync(double fd, ScrBytes *buf, double offset, double length,
3159
3195
  double position);
3160
3196
  double scr_fs_write_str_sync(double fd, ScrStr *data, double position,
3161
3197
  ScrStr *encoding);
3198
+ double scr_fs_readv_sync(double fd, ScrArr *buffers, double position);
3199
+ double scr_fs_writev_sync(double fd, ScrArr *buffers, double position);
3200
+ /* Unlike scalar readSync's zero-length fast path, a nonempty vector of
3201
+ * empty views still tests the descriptor and positioned-read capability. */
3202
+ double scr_fs_read_zero(double fd, double position);
3162
3203
  void scr_fs_close(double fd);
3163
3204
 
3164
3205
  /* ── WHATWG URL (scr_url.c) ──────────────────────────────────────────
@@ -3177,6 +3218,10 @@ typedef struct ScrUrl ScrUrl;
3177
3218
 
3178
3219
  ScrUrl *scr_url_new(ScrStr *input); /* +1, or throws */
3179
3220
  ScrUrl *scr_url_new_base(ScrStr *input, ScrStr *base); /* +1, or throws */
3221
+ bool scr_url_can_parse(ScrStr *input);
3222
+ bool scr_url_can_parse_base(ScrStr *input, ScrStr *base);
3223
+ ScrDyn *scr_url_parse(ScrStr *input); /* +1 native URL or null; invalid URLs do not throw */
3224
+ ScrDyn *scr_url_parse_base(ScrStr *input, ScrStr *base);
3180
3225
  ScrUrl *scr_url_retain(ScrUrl *u);
3181
3226
  void scr_url_release(ScrUrl *u);
3182
3227
  void *scr_url_retain_v(void *p);
@@ -3607,7 +3652,7 @@ struct ScrDyn {
3607
3652
  ScrBigInt *bigint; /* owned (SCR_DYN_BIGINT) */
3608
3653
  /* Callbacks keep the optional symbol unit out of symbol-free binaries. */
3609
3654
  struct { ScrSym *value; void (*release)(ScrSym *); ScrStr *(*render)(ScrSym *); ScrStr *(*description)(ScrSym *); } symbol;
3610
- struct { size_t len; size_t cap; ScrDyn **items; struct ScrDyn *properties; bool sealed; bool frozen; } arr; /* owned */
3655
+ struct { size_t len; size_t cap; ScrDyn **items; struct ScrDyn *properties; bool sealed; bool frozen; unsigned char *presence; } arr; /* owned; NULL presence means dense */
3611
3656
  struct {
3612
3657
  size_t len;
3613
3658
  size_t cap;
@@ -3781,6 +3826,7 @@ ScrSym *scr_sym_well_known(ScrStr *name);
3781
3826
  ScrDyn *scr_dyn_symbol_get(const ScrDyn *value, const ScrStr *key);
3782
3827
  ScrDyn *scr_dyn_symbol_key_get(const ScrDyn *value, const ScrDyn *key, bool optional);
3783
3828
  void scr_dyn_symbol_key_set(ScrDyn *value, ScrDyn *key, ScrDyn *stored);
3829
+ void scr_dyn_symbol_key_placeholder(ScrDyn *value, ScrDyn *key);
3784
3830
  bool scr_dyn_has_key_computed(const ScrDyn *value, const ScrDyn *key);
3785
3831
  bool scr_dyn_has_own_computed(const ScrDyn *value, const ScrDyn *key);
3786
3832
  bool scr_dyn_property_is_enumerable_computed(const ScrDyn *value, const ScrDyn *key);
@@ -3793,6 +3839,9 @@ ScrDyn *scr_dyn_increment(const ScrDyn *value, bool increment);
3793
3839
  ScrDyn *scr_dyn_symbol_ref(ScrSym *value, void (*release)(ScrSym *), ScrStr *(*render)(ScrSym *), ScrStr *(*description)(ScrSym *));
3794
3840
  ScrDyn *scr_dyn_new_str(ScrStr *s);
3795
3841
  ScrDyn *scr_dyn_new_arr(void);
3842
+ ScrDyn *scr_dyn_array_constructor(void);
3843
+ bool scr_dyn_arr_has_index(const ScrDyn *arr, size_t index);
3844
+ void scr_dyn_arr_push_hole(ScrDyn *arr);
3796
3845
  ScrDyn *scr_dyn_new_obj(void);
3797
3846
  ScrDyn *scr_dyn_iterator(const ScrDyn *value, const ScrStr *spell);
3798
3847
  ScrDyn *scr_dyn_iterator_optional(const ScrDyn *value);
@@ -3823,6 +3872,7 @@ bool scr_dyn_is_extensible(ScrDyn *object);
3823
3872
  ScrDyn *scr_dyn_seal(ScrDyn *object);
3824
3873
  bool scr_dyn_is_sealed(const ScrDyn *object);
3825
3874
  ScrDyn *scr_dyn_proxy_new(const ScrDyn *target, const ScrDyn *handler);
3875
+ bool scr_dyn_is_callable(const ScrDyn *value);
3826
3876
  ScrDyn *scr_dyn_proxy_get(const ScrDyn *proxy, const ScrStr *key);
3827
3877
  bool scr_dyn_proxy_has(const ScrDyn *proxy, const ScrStr *key);
3828
3878
  ScrDyn *scr_dyn_own_descriptor(const ScrDyn *value, const ScrStr *key);
@@ -3969,6 +4019,7 @@ bool scr_dyn_number_coerce_js(const ScrDyn *d, double *out);
3969
4019
  double scr_dyn_number_coerce(const ScrDyn *d);
3970
4020
  double scr_dyn_number_constructor(const ScrDyn *d);
3971
4021
  ScrBigInt *scr_dyn_bigint_constructor(const ScrDyn *d);
4022
+ ScrBigInt *scr_dyn_bigint_coerce(const ScrDyn *d);
3972
4023
  ScrDyn *scr_dyn_add(const ScrDyn *left, const ScrDyn *right); /* borrowed; +1 or NULL/pending */
3973
4024
  ScrDyn *scr_dyn_arithmetic(const ScrDyn *left, const ScrDyn *right, const ScrStr *operation);
3974
4025
  bool scr_dyn_compare(const ScrDyn *left, const ScrDyn *right, const ScrStr *operation);
@@ -4045,6 +4096,7 @@ ScrDyn *scr_dyn_fn_get(const ScrDyn *d, const char *key, size_t key_len);
4045
4096
  * Returns the target (+1, JS's return), or NULL with a pending catchable
4046
4097
  * TypeError (non-object target/descriptor — Node's messages). */
4047
4098
  ScrDyn *scr_dyn_define_props(ScrDyn *target, ScrDyn *descs);
4099
+ ScrDyn *scr_dyn_define_prototype_props(ScrDyn *target, ScrDyn *descs, ScrDyn *protected_keys);
4048
4100
  /* Boxes a closure as a callable dyn value. Ownership of `clo` MOVES in
4049
4101
  * (callers retain first when they keep their own reference); `sig`/`name`
4050
4102
  * must be static literals (the box never frees them; name may be NULL). */
@@ -4185,6 +4237,7 @@ ScrDyn *scr_dyn_new_promise_adapting(ScrPromise *src,
4185
4237
  void (*adapt)(ScrPromise *dst, ScrPromise *src));
4186
4238
  /* BORROWED peek at the boxed promise; NULL when d is not a promise box. */
4187
4239
  ScrPromise *scr_dyn_promise_of(const ScrDyn *d);
4240
+ ScrPromise *scr_dyn_promise_all(const ScrDyn *entries);
4188
4241
 
4189
4242
  /* ── island values in the checked-dynamic tree (SCR_DYN_JSVAL) ─────────────────────────
4190
4243
  * Engine routing ops for JSVAL nodes, installed by the gated constructor
@@ -4513,6 +4566,7 @@ void scr_promise_rethrow_top_level(ScrPromise *p);
4513
4566
  * payload as a dyn value (+1; void fulfillments answer the undefined
4514
4567
  * value), or NULL with the rejection re-thrown into the awaiter. */
4515
4568
  ScrDyn *scr_await_dyn(ScrPromise *p);
4569
+ ScrDyn *scr_await_dyn_value_settled(ScrDyn *value);
4516
4570
  void scr_promise_resolve_dyn(ScrPromise *destination, ScrDyn *value);
4517
4571
  /* `await v` over a checked-dynamic VALUE: dyn promises adopt, everything
4518
4572
  * else takes JS's one-hop non-thenable await and answers itself (+1). */
@@ -5821,6 +5875,11 @@ ScrStr *scr_bytes_to_str_checked_range(const ScrBytes *b, const ScrStr *enc, dou
5821
5875
  * stripped. Borrows; +1; never throws. */
5822
5876
  ScrStr *scr_text_decode(const ScrBytes *b);
5823
5877
  double scr_text_decoder_encoding(const ScrDyn *label);
5878
+ ScrStr *scr_text_decoder_name(double encoding);
5879
+ ScrDyn *scr_text_encode_into(const ScrDyn *source, const ScrDyn *destination);
5880
+ bool scr_buffer_is_ascii(const ScrDyn *input);
5881
+ bool scr_buffer_is_utf8(const ScrDyn *input);
5882
+ ScrBytes *scr_buffer_transcode(const ScrDyn *source, const ScrDyn *from, const ScrDyn *to);
5824
5883
  ScrBytes *scr_bytes_buffer_source(const ScrDyn *value);
5825
5884
  ScrStr *scr_text_decode_buffer_source(const ScrDyn *value);
5826
5885
  ScrStr *scr_text_decode_options(const ScrBytes *b, bool fatal, bool ignore_bom);
@@ -72,18 +72,18 @@ static const struct { const char *label; int encoding; } scr_td_labels[] = {
72
72
  {"iso_8859-7:1987", 6},
73
73
  {"sun_eu_greek", 6},
74
74
  {"csiso88598e", 7},
75
- {"csiso88598i", 7},
75
+ {"csiso88598i", 36},
76
76
  {"csisolatinhebrew", 7},
77
77
  {"hebrew", 7},
78
78
  {"iso-8859-8", 7},
79
79
  {"iso-8859-8-e", 7},
80
- {"iso-8859-8-i", 7},
80
+ {"iso-8859-8-i", 36},
81
81
  {"iso-ir-138", 7},
82
82
  {"iso8859-8", 7},
83
83
  {"iso88598", 7},
84
84
  {"iso_8859-8", 7},
85
85
  {"iso_8859-8:1988", 7},
86
- {"logical", 7},
86
+ {"logical", 36},
87
87
  {"visual", 7},
88
88
  {"csisolatin6", 8},
89
89
  {"iso-8859-10", 8},
@@ -184,16 +184,16 @@ static const struct { const char *label; int encoding; } scr_td_labels[] = {
184
184
  {"utf-16le", 28},
185
185
  {"unicodefffe", 29},
186
186
  {"utf-16be", 29},
187
- {"chinese", 30},
188
- {"csgb2312", 30},
189
- {"csiso58gb231280", 30},
187
+ {"chinese", 37},
188
+ {"csgb2312", 37},
189
+ {"csiso58gb231280", 37},
190
190
  {"gb18030", 30},
191
- {"gb2312", 30},
192
- {"gb_2312", 30},
193
- {"gb_2312-80", 30},
194
- {"gbk", 30},
195
- {"iso-ir-58", 30},
196
- {"x-gbk", 30},
191
+ {"gb2312", 37},
192
+ {"gb_2312", 37},
193
+ {"gb_2312-80", 37},
194
+ {"gbk", 37},
195
+ {"iso-ir-58", 37},
196
+ {"x-gbk", 37},
197
197
  {"big5", 31},
198
198
  {"big5-hkscs", 31},
199
199
  {"cn-big5", 31},
@@ -763,6 +763,33 @@ ScrStr *scr_url_protocol(ScrUrl *u) {
763
763
  return ub_take(&b);
764
764
  }
765
765
 
766
+ /* Input conversion is the caller's responsibility. Only parser errors are
767
+ * suppressed: user toString errors must still escape the public factories. */
768
+ static ScrUrl *url_try_parse(ScrStr *input, ScrStr *base) {
769
+ ScrUrl *u = base ? scr_url_new_base(input, base) : scr_url_new(input);
770
+ if (!u) scr_exc_clear();
771
+ return u;
772
+ }
773
+
774
+ bool scr_url_can_parse_base(ScrStr *input, ScrStr *base) {
775
+ ScrUrl *u = url_try_parse(input, base);
776
+ bool valid = u != NULL;
777
+ scr_url_release(u);
778
+ return valid;
779
+ }
780
+
781
+ bool scr_url_can_parse(ScrStr *input) { return scr_url_can_parse_base(input, NULL); }
782
+
783
+ ScrDyn *scr_url_parse_base(ScrStr *input, ScrStr *base) {
784
+ ScrUrl *u = url_try_parse(input, base);
785
+ if (!u) return scr_dyn_new_null();
786
+ ScrDyn *value = scr_dyn_native_url(u);
787
+ scr_url_release(u);
788
+ return value;
789
+ }
790
+
791
+ ScrDyn *scr_url_parse(ScrStr *input) { return scr_url_parse_base(input, NULL); }
792
+
766
793
  ScrStr *scr_url_pathname(ScrUrl *u) { return scr_str_retain(u->path); }
767
794
 
768
795
  /* WHATWG host getter: host[:port] — the port only when non-default (the
@@ -872,7 +899,7 @@ static int hex_val(char c) {
872
899
  * letter otherwise. The public wrappers below select by TARGET. */
873
900
  static ScrStr *scr_url_to_path_impl(ScrUrl *u, bool win32) {
874
901
  if (!(u->scheme->len == 4 && memcmp(u->scheme->data, "file", 4) == 0)) {
875
- scr_throw_error_msg(SCR_ERR_TYPE, "The URL must be of scheme file", 30);
902
+ scr_throw_error_msg_code(SCR_ERR_TYPE, "The URL must be of scheme file", 30, "ERR_INVALID_URL_SCHEME");
876
903
  return NULL;
877
904
  }
878
905
  const char *p = u->path->data;
@@ -884,8 +911,8 @@ static ScrStr *scr_url_to_path_impl(ScrUrl *u, bool win32) {
884
911
  char c1 = p[n + 1];
885
912
  int third = (n + 2 < len ? (unsigned char)p[n + 2] : 0) | 0x20;
886
913
  if ((c1 == '2' && third == 'f') || (c1 == '5' && third == 'c')) {
887
- scr_throw_error_msg(SCR_ERR_TYPE,
888
- "File URL path must not include encoded \\ or / characters", 56);
914
+ scr_throw_error_msg_code(SCR_ERR_TYPE,
915
+ "File URL path must not include encoded \\ or / characters", 56, "ERR_INVALID_FILE_URL_PATH");
889
916
  return NULL;
890
917
  }
891
918
  }
@@ -916,7 +943,7 @@ static ScrStr *scr_url_to_path_impl(ScrUrl *u, bool win32) {
916
943
  char drive_sep = plen > 2 ? pp[2] : 0;
917
944
  if (letter < 'a' || letter > 'z' || drive_sep != ':') {
918
945
  free(out.data);
919
- scr_throw_error_msg(SCR_ERR_TYPE, "File URL path must be absolute", 30);
946
+ scr_throw_error_msg_code(SCR_ERR_TYPE, "File URL path must be absolute", 30, "ERR_INVALID_FILE_URL_PATH");
920
947
  return NULL;
921
948
  }
922
949
  /* pathname.slice(1): the leading backslash drops. */
@@ -938,7 +965,7 @@ static ScrStr *scr_url_to_path_impl(ScrUrl *u, bool win32) {
938
965
  #endif
939
966
  char msg[96];
940
967
  int mlen = snprintf(msg, sizeof msg, "File URL host must be \"localhost\" or empty on %s", plat);
941
- scr_throw_error_msg(SCR_ERR_TYPE, msg, (size_t)mlen);
968
+ scr_throw_error_msg_code(SCR_ERR_TYPE, msg, (size_t)mlen, "ERR_INVALID_FILE_URL_HOST");
942
969
  return NULL;
943
970
  }
944
971
  for (size_t i = 0; i < len; i++) {
@@ -948,8 +975,8 @@ static ScrStr *scr_url_to_path_impl(ScrUrl *u, bool win32) {
948
975
  if (hi >= 0 && lo >= 0) {
949
976
  unsigned char decoded = (unsigned char)((hi << 4) | lo);
950
977
  if (decoded == '/') {
951
- scr_throw_error_msg(SCR_ERR_TYPE,
952
- "File URL path must not include encoded / characters", 51);
978
+ scr_throw_error_msg_code(SCR_ERR_TYPE,
979
+ "File URL path must not include encoded / characters", 51, "ERR_INVALID_FILE_URL_PATH");
953
980
  return NULL;
954
981
  }
955
982
  i += 2;