@opentui/core 0.4.3 → 0.4.5

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 (47) hide show
  1. package/audio-stream/demuxer.d.ts +19 -0
  2. package/audio-stream/icy/demuxer.d.ts +21 -0
  3. package/audio-stream/icy/metadata.d.ts +1 -0
  4. package/audio.d.ts +201 -1
  5. package/chunk-bun-t2myhmwd.js +16382 -0
  6. package/chunk-bun-t2myhmwd.js.map +62 -0
  7. package/chunk-bun-tkm837n2.js +10047 -0
  8. package/chunk-bun-tkm837n2.js.map +32 -0
  9. package/{index-xt9f071j.js → chunk-node-51kpf0mz.js} +4 -3
  10. package/{index-xt9f071j.js.map → chunk-node-51kpf0mz.js.map} +3 -3
  11. package/{index-d5xqskty.js → chunk-node-q0cwyvm9.js} +576 -325
  12. package/chunk-node-q0cwyvm9.js.map +61 -0
  13. package/index.bun.js +13086 -0
  14. package/index.bun.js.map +39 -0
  15. package/index.d.ts +4 -0
  16. package/{index.js → index.node.js} +1440 -64
  17. package/{index.js.map → index.node.js.map} +41 -6
  18. package/lib/tree-sitter/default-parser-assets.bun.d.ts +1 -0
  19. package/lib/tree-sitter/default-parsers.d.ts +1 -0
  20. package/lib/tree-sitter/parsers-config.d.ts +2 -2
  21. package/lib/tree-sitter/types.d.ts +1 -0
  22. package/lib/tree-sitter/update-assets.js +124 -58
  23. package/lib/tree-sitter/update-assets.js.map +3 -3
  24. package/node-asset-target.d.ts +12 -0
  25. package/node-assets.d.ts +7 -0
  26. package/node-assets.js +261 -0
  27. package/node-assets.js.map +16 -0
  28. package/package.json +23 -13
  29. package/parser.worker.js +3350 -188
  30. package/parser.worker.js.map +18 -12
  31. package/platform/assets.d.ts +5 -0
  32. package/platform/runtime-assets.bun.d.ts +4 -0
  33. package/platform/runtime-assets.node.d.ts +4 -0
  34. package/platform/runtime.d.ts +5 -1
  35. package/renderables/text-table-width.d.ts +1 -0
  36. package/runtime-plugin.js +2 -2
  37. package/runtime-plugin.js.map +1 -1
  38. package/testing/bun-test-node.d.ts +1 -0
  39. package/testing.bun.js +1005 -0
  40. package/testing.bun.js.map +18 -0
  41. package/testing.js +2 -2
  42. package/yoga.bun.js +194 -0
  43. package/yoga.bun.js.map +9 -0
  44. package/yoga.js +1 -1
  45. package/zig-structs.d.ts +47 -0
  46. package/zig.d.ts +38 -2
  47. package/index-d5xqskty.js.map +0 -58
@@ -1,4 +1,3 @@
1
- import { createRequire } from "node:module";
2
1
  var __create = Object.create;
3
2
  var __getProtoOf = Object.getPrototypeOf;
4
3
  var __defProp = Object.defineProperty;
@@ -43,7 +42,6 @@ var __export = (target, all) => {
43
42
  set: __exportSetter.bind(all, name)
44
43
  });
45
44
  };
46
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
47
45
 
48
46
  // ../../node_modules/.bun/emoji-regex@10.6.0/node_modules/emoji-regex/index.js
49
47
  var require_emoji_regex = __commonJS((exports, module) => {
@@ -151,7 +149,7 @@ __export(exports_yoga, {
151
149
  });
152
150
 
153
151
  // src/platform/ffi.ts
154
- import { createRequire as createRequire2 } from "node:module";
152
+ import { createRequire } from "node:module";
155
153
  import { fileURLToPath } from "node:url";
156
154
  var FFIType = {
157
155
  char: "char",
@@ -202,6 +200,17 @@ var POINTER_NEGATIVE = "Pointer must be non-negative";
202
200
  var POINTER_OFFSET_NEGATIVE = "Pointer offset must be non-negative";
203
201
  var POINTER_OFFSET_UNSAFE = "Pointer offset must be a safe integer";
204
202
  var POINTER_UNSAFE = "Pointer exceeds safe integer range";
203
+ var arrayBufferByteLength = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength")?.get;
204
+ function isArrayBuffer(value) {
205
+ if (value === null || typeof value !== "object" || arrayBufferByteLength == null)
206
+ return false;
207
+ try {
208
+ arrayBufferByteLength.call(value);
209
+ return true;
210
+ } catch {
211
+ return false;
212
+ }
213
+ }
205
214
  function unavailable(cause) {
206
215
  throw new Error(FFI_UNAVAILABLE, { cause });
207
216
  }
@@ -220,7 +229,7 @@ function createUnsupportedBackend(cause) {
220
229
  };
221
230
  }
222
231
  var isBun = typeof process !== "undefined" && typeof process.versions === "object" && process.versions !== null && typeof process.versions.bun === "string";
223
- var requireModule = createRequire2(import.meta.url);
232
+ var requireModule = createRequire(import.meta.url);
224
233
  var backend = loadBackend();
225
234
  function loadBackend() {
226
235
  if (isBun) {
@@ -429,7 +438,7 @@ function toNodePointerArgument(value) {
429
438
  return toBigIntPointer(value);
430
439
  }
431
440
  if (ArrayBuffer.isView(value)) {
432
- if (!(value.buffer instanceof ArrayBuffer)) {
441
+ if (!isArrayBuffer(value.buffer)) {
433
442
  throw new TypeError(NODE_PTR_VALUE);
434
443
  }
435
444
  if (value.byteLength === 0) {
@@ -437,7 +446,7 @@ function toNodePointerArgument(value) {
437
446
  }
438
447
  return value;
439
448
  }
440
- if (value instanceof ArrayBuffer) {
449
+ if (isArrayBuffer(value)) {
441
450
  if (value.byteLength === 0) {
442
451
  return 0n;
443
452
  }
@@ -447,12 +456,12 @@ function toNodePointerArgument(value) {
447
456
  }
448
457
  function toNodeSourcePointer(nodeFfi, value) {
449
458
  if (ArrayBuffer.isView(value)) {
450
- if (!(value.buffer instanceof ArrayBuffer)) {
459
+ if (!isArrayBuffer(value.buffer)) {
451
460
  throw new TypeError(NODE_PTR_VALUE);
452
461
  }
453
462
  return nodeFfi.getRawPointer(value.buffer) + BigInt(value.byteOffset);
454
463
  }
455
- if (value instanceof ArrayBuffer) {
464
+ if (isArrayBuffer(value)) {
456
465
  return nodeFfi.getRawPointer(value);
457
466
  }
458
467
  throw new TypeError(NODE_PTR_VALUE);
@@ -559,8 +568,8 @@ var toArrayBuffer = backend.toArrayBuffer;
559
568
  // src/platform/runtime.ts
560
569
  import { existsSync } from "node:fs";
561
570
  import { mkdir, writeFile as writeFileNode } from "node:fs/promises";
562
- import { dirname, isAbsolute, resolve } from "node:path";
563
- import { fileURLToPath as fileURLToPath2 } from "node:url";
571
+ import { dirname, isAbsolute as isAbsolute2, resolve } from "node:path";
572
+ import { fileURLToPath as fileURLToPath3 } from "node:url";
564
573
 
565
574
  // ../../node_modules/.bun/ansi-regex@6.2.2/node_modules/ansi-regex/index.js
566
575
  function ansiRegex({ onlyFirst = false } = {}) {
@@ -654,6 +663,231 @@ function stringWidth(string, options = {}) {
654
663
  return width;
655
664
  }
656
665
 
666
+ // src/platform/assets.ts
667
+ import { statSync } from "node:fs";
668
+ import { isAbsolute, join } from "node:path";
669
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
670
+
671
+ // src/lib/singleton.ts
672
+ var singletonCacheSymbol = Symbol.for("@opentui/core/singleton");
673
+ function singleton(key, factory) {
674
+ const bag = globalThis[singletonCacheSymbol] ??= {};
675
+ if (!(key in bag)) {
676
+ bag[key] = factory();
677
+ }
678
+ return bag[key];
679
+ }
680
+ function getSingleton(key) {
681
+ const bag = globalThis[singletonCacheSymbol];
682
+ return bag?.[key];
683
+ }
684
+ function destroySingleton(key) {
685
+ const bag = globalThis[singletonCacheSymbol];
686
+ if (bag && key in bag) {
687
+ delete bag[key];
688
+ }
689
+ }
690
+
691
+ // src/lib/env.ts
692
+ var envRegistry = singleton("env-registry", () => ({}));
693
+ function registerEnvVar(config) {
694
+ const existing = envRegistry[config.name];
695
+ if (existing) {
696
+ if (existing.description !== config.description || existing.type !== config.type || existing.default !== config.default) {
697
+ throw new Error(`Environment variable "${config.name}" is already registered with different configuration. ` + `Existing: ${JSON.stringify(existing)}, New: ${JSON.stringify(config)}`);
698
+ }
699
+ return;
700
+ }
701
+ envRegistry[config.name] = config;
702
+ }
703
+ function normalizeBoolean(value) {
704
+ const lowerValue = value.toLowerCase();
705
+ return ["true", "1", "on", "yes"].includes(lowerValue);
706
+ }
707
+ function parseEnvValue(config) {
708
+ const envValue = process.env[config.name];
709
+ if (envValue === undefined && config.default !== undefined) {
710
+ return config.default;
711
+ }
712
+ if (envValue === undefined) {
713
+ throw new Error(`Required environment variable ${config.name} is not set. ${config.description}`);
714
+ }
715
+ switch (config.type) {
716
+ case "boolean":
717
+ return typeof envValue === "boolean" ? envValue : normalizeBoolean(envValue);
718
+ case "number":
719
+ const numValue = Number(envValue);
720
+ if (isNaN(numValue)) {
721
+ throw new Error(`Environment variable ${config.name} must be a valid number, got: ${envValue}`);
722
+ }
723
+ return numValue;
724
+ case "string":
725
+ default:
726
+ return envValue;
727
+ }
728
+ }
729
+
730
+ class EnvStore {
731
+ parsedValues = new Map;
732
+ get(key) {
733
+ if (this.parsedValues.has(key)) {
734
+ return this.parsedValues.get(key);
735
+ }
736
+ if (!(key in envRegistry)) {
737
+ throw new Error(`Environment variable ${key} is not registered.`);
738
+ }
739
+ try {
740
+ const value = parseEnvValue(envRegistry[key]);
741
+ this.parsedValues.set(key, value);
742
+ return value;
743
+ } catch (error) {
744
+ throw new Error(`Failed to parse env var ${key}: ${error instanceof Error ? error.message : String(error)}`);
745
+ }
746
+ }
747
+ has(key) {
748
+ return key in envRegistry;
749
+ }
750
+ clearCache() {
751
+ this.parsedValues.clear();
752
+ }
753
+ }
754
+ var envStore = singleton("env-store", () => new EnvStore);
755
+ function clearEnvCache() {
756
+ envStore.clearCache();
757
+ }
758
+ function generateEnvMarkdown() {
759
+ const configs = Object.values(envRegistry);
760
+ if (configs.length === 0) {
761
+ return `# Environment Variables
762
+
763
+ No environment variables registered.
764
+ `;
765
+ }
766
+ let markdown = `# Environment Variables
767
+
768
+ `;
769
+ for (const config of configs) {
770
+ markdown += `## ${config.name}
771
+
772
+ `;
773
+ markdown += `${config.description}
774
+
775
+ `;
776
+ markdown += `**Type:** \`${config.type || "string"}\`
777
+ `;
778
+ if (config.default !== undefined) {
779
+ const defaultValue = typeof config.default === "string" ? `"${config.default}"` : String(config.default);
780
+ markdown += `**Default:** \`${defaultValue}\`
781
+ `;
782
+ } else {
783
+ markdown += `**Default:** *Required*
784
+ `;
785
+ }
786
+ markdown += `
787
+ `;
788
+ }
789
+ return markdown;
790
+ }
791
+ function generateEnvColored() {
792
+ const configs = Object.values(envRegistry);
793
+ if (configs.length === 0) {
794
+ return `\x1B[1;36mEnvironment Variables\x1B[0m
795
+
796
+ No environment variables registered.
797
+ `;
798
+ }
799
+ let output = `\x1B[1;36mEnvironment Variables\x1B[0m
800
+
801
+ `;
802
+ for (const config of configs) {
803
+ output += `\x1B[1;33m${config.name}\x1B[0m
804
+ `;
805
+ output += `${config.description}
806
+ `;
807
+ output += `\x1B[32mType:\x1B[0m \x1B[36m${config.type || "string"}\x1B[0m
808
+ `;
809
+ if (config.default !== undefined) {
810
+ const defaultValue = typeof config.default === "string" ? `"${config.default}"` : String(config.default);
811
+ output += `\x1B[32mDefault:\x1B[0m \x1B[35m${defaultValue}\x1B[0m
812
+ `;
813
+ } else {
814
+ output += `\x1B[32mDefault:\x1B[0m \x1B[31mRequired\x1B[0m
815
+ `;
816
+ }
817
+ output += `
818
+ `;
819
+ }
820
+ return output;
821
+ }
822
+ var env = new Proxy({}, {
823
+ get(target, prop) {
824
+ if (typeof prop !== "string") {
825
+ return;
826
+ }
827
+ return envStore.get(prop);
828
+ },
829
+ has(target, prop) {
830
+ return envStore.has(prop);
831
+ },
832
+ ownKeys() {
833
+ return Object.keys(envRegistry);
834
+ },
835
+ getOwnPropertyDescriptor(target, prop) {
836
+ if (envStore.has(prop)) {
837
+ return {
838
+ enumerable: true,
839
+ configurable: true,
840
+ get: () => envStore.get(prop)
841
+ };
842
+ }
843
+ return;
844
+ }
845
+ });
846
+
847
+ // src/platform/assets.ts
848
+ registerEnvVar({
849
+ name: "OTUI_ASSET_ROOT",
850
+ description: "Absolute directory containing relocatable OpenTUI runtime assets",
851
+ type: "string",
852
+ default: ""
853
+ });
854
+ function resolveAssetPath(key, fallback) {
855
+ validateAssetKey(key);
856
+ const configuredPath = resolveAssetRootPath(key);
857
+ if (configuredPath !== undefined) {
858
+ return configuredPath;
859
+ }
860
+ if (fallback === undefined) {
861
+ throw new Error(`OpenTUI asset ${JSON.stringify(key)} has no package-relative fallback`);
862
+ }
863
+ const value = typeof fallback === "function" ? fallback() : fallback;
864
+ return value instanceof URL ? fileURLToPath2(value) : value;
865
+ }
866
+ function resolveAssetRootPath(key) {
867
+ validateAssetKey(key);
868
+ const root = process.env.OTUI_ASSET_ROOT;
869
+ if (!root) {
870
+ return;
871
+ }
872
+ if (!isAbsolute(root)) {
873
+ throw new Error(`OTUI_ASSET_ROOT must be an absolute directory, got ${JSON.stringify(root)}`);
874
+ }
875
+ const assetPath = join(root, key);
876
+ let isFile = false;
877
+ try {
878
+ isFile = statSync(assetPath).isFile();
879
+ } catch {}
880
+ if (!isFile) {
881
+ throw new Error(`Missing OpenTUI asset ${JSON.stringify(key)} at ${JSON.stringify(assetPath)}`);
882
+ }
883
+ return assetPath;
884
+ }
885
+ function validateAssetKey(key) {
886
+ if (key.length === 0 || isAbsolute(key) || key.includes("\\") || key.split("/").includes("..")) {
887
+ throw new Error(`Invalid OpenTUI asset key: ${JSON.stringify(key)}`);
888
+ }
889
+ }
890
+
657
891
  // src/platform/runtime.ts
658
892
  var TEXT_ENCODER = new TextEncoder;
659
893
  var bun = globalThis.Bun;
@@ -661,33 +895,46 @@ var sleep = bun?.sleep ?? standardSleep;
661
895
  var stringWidth2 = bun?.stringWidth ?? stringWidth;
662
896
  var stripANSI = bun?.stripANSI ?? stripAnsi;
663
897
  var writeFile = bun?.write ?? writeFilePortable;
664
- async function resolveBundledFilePath(loadBundledFile, fallbackPath, metaUrl) {
898
+ async function resolveBundledFilePath(key, loadBundledFile, fallbackPath, metaUrl, options = {}) {
899
+ if (options.useAssetRoot ?? true) {
900
+ const configuredPath = resolveAssetRootPath(key);
901
+ if (configuredPath !== undefined) {
902
+ return configuredPath;
903
+ }
904
+ }
665
905
  if (!bun) {
666
906
  const path = resolveFallbackFilePath(fallbackPath, metaUrl);
667
907
  if (existsSync(path)) {
668
908
  return path;
669
909
  }
670
- return await loadBundledFilePath(loadBundledFile, metaUrl) ?? path;
910
+ return await loadBundledFilePath(loadBundledFile, metaUrl, options.loadBundledFileFallback ?? false) ?? path;
671
911
  }
672
912
  return normalizeLoadedFilePath((await loadBundledFile()).default, metaUrl);
673
913
  }
674
914
  function resolveFallbackFilePath(fallbackPath, metaUrl) {
675
915
  const path = typeof fallbackPath === "function" ? fallbackPath() : fallbackPath;
676
- return fileURLToPath2(path instanceof URL ? path : new URL(path, metaUrl));
916
+ return fileURLToPath3(path instanceof URL ? path : new URL(path, metaUrl));
677
917
  }
678
918
  function normalizeLoadedFilePath(loadedPath, baseUrl) {
679
919
  if (loadedPath.startsWith("file:")) {
680
- return fileURLToPath2(loadedPath);
920
+ return fileURLToPath3(loadedPath);
681
921
  }
682
- if (isAbsolute(loadedPath)) {
922
+ if (isAbsolute2(loadedPath)) {
683
923
  return loadedPath;
684
924
  }
685
- return resolve(dirname(fileURLToPath2(baseUrl)), loadedPath);
925
+ return resolve(dirname(fileURLToPath3(baseUrl)), loadedPath);
686
926
  }
687
- async function loadBundledFilePath(loadBundledFile, metaUrl) {
927
+ async function loadBundledFilePath(loadBundledFile, metaUrl, loadBundledFileFallback) {
688
928
  const specifier = extractBundledImportSpecifier(loadBundledFile);
689
929
  if (!specifier) {
690
- return;
930
+ if (!loadBundledFileFallback) {
931
+ return;
932
+ }
933
+ try {
934
+ return normalizeLoadedFilePath((await loadBundledFile()).default, metaUrl);
935
+ } catch {
936
+ return;
937
+ }
691
938
  }
692
939
  try {
693
940
  const moduleUrl = new URL(specifier, metaUrl);
@@ -706,7 +953,7 @@ function standardSleep(msOrDate) {
706
953
  return new Promise((resolve2) => setTimeout(resolve2, ms));
707
954
  }
708
955
  async function writeFilePortable(destination, data, options) {
709
- const destinationPath = destination instanceof URL ? fileURLToPath2(destination) : destination;
956
+ const destinationPath = destination instanceof URL ? fileURLToPath3(destination) : destination;
710
957
  if (options?.createPath) {
711
958
  await mkdir(dirname(destinationPath), { recursive: true });
712
959
  }
@@ -5895,181 +6142,6 @@ class ASCIIFontSelectionHelper {
5895
6142
  return previousSelection?.start !== this.localSelection?.start || previousSelection?.end !== this.localSelection?.end;
5896
6143
  }
5897
6144
  }
5898
- // src/lib/singleton.ts
5899
- var singletonCacheSymbol = Symbol.for("@opentui/core/singleton");
5900
- function singleton(key, factory) {
5901
- const bag = globalThis[singletonCacheSymbol] ??= {};
5902
- if (!(key in bag)) {
5903
- bag[key] = factory();
5904
- }
5905
- return bag[key];
5906
- }
5907
- function getSingleton(key) {
5908
- const bag = globalThis[singletonCacheSymbol];
5909
- return bag?.[key];
5910
- }
5911
- function destroySingleton(key) {
5912
- const bag = globalThis[singletonCacheSymbol];
5913
- if (bag && key in bag) {
5914
- delete bag[key];
5915
- }
5916
- }
5917
-
5918
- // src/lib/env.ts
5919
- var envRegistry = singleton("env-registry", () => ({}));
5920
- function registerEnvVar(config) {
5921
- const existing = envRegistry[config.name];
5922
- if (existing) {
5923
- if (existing.description !== config.description || existing.type !== config.type || existing.default !== config.default) {
5924
- throw new Error(`Environment variable "${config.name}" is already registered with different configuration. ` + `Existing: ${JSON.stringify(existing)}, New: ${JSON.stringify(config)}`);
5925
- }
5926
- return;
5927
- }
5928
- envRegistry[config.name] = config;
5929
- }
5930
- function normalizeBoolean(value) {
5931
- const lowerValue = value.toLowerCase();
5932
- return ["true", "1", "on", "yes"].includes(lowerValue);
5933
- }
5934
- function parseEnvValue(config) {
5935
- const envValue = process.env[config.name];
5936
- if (envValue === undefined && config.default !== undefined) {
5937
- return config.default;
5938
- }
5939
- if (envValue === undefined) {
5940
- throw new Error(`Required environment variable ${config.name} is not set. ${config.description}`);
5941
- }
5942
- switch (config.type) {
5943
- case "boolean":
5944
- return typeof envValue === "boolean" ? envValue : normalizeBoolean(envValue);
5945
- case "number":
5946
- const numValue = Number(envValue);
5947
- if (isNaN(numValue)) {
5948
- throw new Error(`Environment variable ${config.name} must be a valid number, got: ${envValue}`);
5949
- }
5950
- return numValue;
5951
- case "string":
5952
- default:
5953
- return envValue;
5954
- }
5955
- }
5956
-
5957
- class EnvStore {
5958
- parsedValues = new Map;
5959
- get(key) {
5960
- if (this.parsedValues.has(key)) {
5961
- return this.parsedValues.get(key);
5962
- }
5963
- if (!(key in envRegistry)) {
5964
- throw new Error(`Environment variable ${key} is not registered.`);
5965
- }
5966
- try {
5967
- const value = parseEnvValue(envRegistry[key]);
5968
- this.parsedValues.set(key, value);
5969
- return value;
5970
- } catch (error) {
5971
- throw new Error(`Failed to parse env var ${key}: ${error instanceof Error ? error.message : String(error)}`);
5972
- }
5973
- }
5974
- has(key) {
5975
- return key in envRegistry;
5976
- }
5977
- clearCache() {
5978
- this.parsedValues.clear();
5979
- }
5980
- }
5981
- var envStore = singleton("env-store", () => new EnvStore);
5982
- function clearEnvCache() {
5983
- envStore.clearCache();
5984
- }
5985
- function generateEnvMarkdown() {
5986
- const configs = Object.values(envRegistry);
5987
- if (configs.length === 0) {
5988
- return `# Environment Variables
5989
-
5990
- No environment variables registered.
5991
- `;
5992
- }
5993
- let markdown = `# Environment Variables
5994
-
5995
- `;
5996
- for (const config of configs) {
5997
- markdown += `## ${config.name}
5998
-
5999
- `;
6000
- markdown += `${config.description}
6001
-
6002
- `;
6003
- markdown += `**Type:** \`${config.type || "string"}\`
6004
- `;
6005
- if (config.default !== undefined) {
6006
- const defaultValue = typeof config.default === "string" ? `"${config.default}"` : String(config.default);
6007
- markdown += `**Default:** \`${defaultValue}\`
6008
- `;
6009
- } else {
6010
- markdown += `**Default:** *Required*
6011
- `;
6012
- }
6013
- markdown += `
6014
- `;
6015
- }
6016
- return markdown;
6017
- }
6018
- function generateEnvColored() {
6019
- const configs = Object.values(envRegistry);
6020
- if (configs.length === 0) {
6021
- return `\x1B[1;36mEnvironment Variables\x1B[0m
6022
-
6023
- No environment variables registered.
6024
- `;
6025
- }
6026
- let output = `\x1B[1;36mEnvironment Variables\x1B[0m
6027
-
6028
- `;
6029
- for (const config of configs) {
6030
- output += `\x1B[1;33m${config.name}\x1B[0m
6031
- `;
6032
- output += `${config.description}
6033
- `;
6034
- output += `\x1B[32mType:\x1B[0m \x1B[36m${config.type || "string"}\x1B[0m
6035
- `;
6036
- if (config.default !== undefined) {
6037
- const defaultValue = typeof config.default === "string" ? `"${config.default}"` : String(config.default);
6038
- output += `\x1B[32mDefault:\x1B[0m \x1B[35m${defaultValue}\x1B[0m
6039
- `;
6040
- } else {
6041
- output += `\x1B[32mDefault:\x1B[0m \x1B[31mRequired\x1B[0m
6042
- `;
6043
- }
6044
- output += `
6045
- `;
6046
- }
6047
- return output;
6048
- }
6049
- var env = new Proxy({}, {
6050
- get(target, prop) {
6051
- if (typeof prop !== "string") {
6052
- return;
6053
- }
6054
- return envStore.get(prop);
6055
- },
6056
- has(target, prop) {
6057
- return envStore.has(prop);
6058
- },
6059
- ownKeys() {
6060
- return Object.keys(envRegistry);
6061
- },
6062
- getOwnPropertyDescriptor(target, prop) {
6063
- if (envStore.has(prop)) {
6064
- return {
6065
- enumerable: true,
6066
- configurable: true,
6067
- get: () => envStore.get(prop)
6068
- };
6069
- }
6070
- return;
6071
- }
6072
- });
6073
6145
  // src/lib/stdin-parser.ts
6074
6146
  import { Buffer as Buffer3 } from "node:buffer";
6075
6147
  var DEFAULT_TIMEOUT_MS = 20;
@@ -7832,92 +7904,151 @@ class ProcessQueue {
7832
7904
  }
7833
7905
  }
7834
7906
 
7907
+ // src/node-asset-target.ts
7908
+ var NATIVE_FILE_NAMES = {
7909
+ darwin: "libopentui.dylib",
7910
+ linux: "libopentui.so",
7911
+ win32: "opentui.dll"
7912
+ };
7913
+ function getNativeAssetDescriptor(target) {
7914
+ if (!Object.hasOwn(NATIVE_FILE_NAMES, target.platform) || target.arch !== "arm64" && target.arch !== "x64") {
7915
+ throw new Error(`Unsupported OpenTUI Node asset target: ${String(target.platform)}-${String(target.arch)}`);
7916
+ }
7917
+ if (target.libc !== undefined && target.libc !== "glibc" && target.libc !== "musl") {
7918
+ throw new Error(`Unsupported libc for OpenTUI Node assets: ${String(target.libc)}`);
7919
+ }
7920
+ if (target.platform !== "linux" && target.libc !== undefined) {
7921
+ throw new Error(`OpenTUI Node asset target libc is only supported on Linux, got ${target.platform}`);
7922
+ }
7923
+ const libcSuffix = target.platform === "linux" && target.libc === "musl" ? "-musl" : "";
7924
+ const packageName = `@opentui/core-${target.platform}-${target.arch}${libcSuffix}`;
7925
+ const fileName = NATIVE_FILE_NAMES[target.platform];
7926
+ return {
7927
+ key: `${packageName}/${fileName}`,
7928
+ packageName,
7929
+ fileName
7930
+ };
7931
+ }
7932
+ function getCurrentNodeAssetTarget() {
7933
+ const libc = process.env.OPENTUI_LIBC;
7934
+ if (process.platform === "linux" && libc !== undefined && libc !== "" && libc !== "glibc" && libc !== "musl") {
7935
+ throw new Error(`On Linux, OPENTUI_LIBC must be unset, empty, "glibc", or "musl", got ${JSON.stringify(libc)}`);
7936
+ }
7937
+ return {
7938
+ platform: process.platform,
7939
+ arch: process.arch,
7940
+ ...process.platform === "linux" && libc === "musl" ? { libc } : {}
7941
+ };
7942
+ }
7943
+
7944
+ // src/platform/runtime-assets.node.ts
7945
+ var CORE_ASSET_PREFIX = "@opentui/core/";
7946
+ var PARSER_WORKER_ASSET_KEY = `${CORE_ASSET_PREFIX}parser.worker.js`;
7947
+ var TREE_SITTER_WASM_ASSET_KEY = "web-tree-sitter/tree-sitter.wasm";
7948
+ function resolveDefaultParserAsset(relativePath, fallbackPath) {
7949
+ return Promise.resolve(resolveAssetPath(`${CORE_ASSET_PREFIX}${relativePath}`, fallbackPath));
7950
+ }
7951
+ function resolveDefaultTreeSitterWorkerPath(fallbackPath) {
7952
+ return resolveAssetPath(PARSER_WORKER_ASSET_KEY, fallbackPath);
7953
+ }
7954
+ function resolveTreeSitterWasm() {
7955
+ return Promise.resolve(resolveAssetPath(TREE_SITTER_WASM_ASSET_KEY, () => new URL(import.meta.resolve(TREE_SITTER_WASM_ASSET_KEY))));
7956
+ }
7957
+ async function resolveNativeLibraryPath() {
7958
+ const asset = getNativeAssetDescriptor(getCurrentNodeAssetTarget());
7959
+ const configuredPath = resolveAssetRootPath(asset.key);
7960
+ if (configuredPath !== undefined) {
7961
+ return configuredPath;
7962
+ }
7963
+ const specifier = asset.packageName;
7964
+ return (await import(specifier)).default;
7965
+ }
7966
+
7835
7967
  // src/lib/tree-sitter/default-parsers.ts
7836
- var _cachedParsers;
7837
- function getParsers() {
7838
- if (!_cachedParsers) {
7839
- _cachedParsers = loadParsers();
7840
- }
7841
- return _cachedParsers;
7842
- }
7843
- async function loadParsers() {
7844
- const javascript_highlights = await resolveBundledFilePath(() => import("./assets/javascript/highlights.scm", { with: { type: "file" } }), "./assets/javascript/highlights.scm", import.meta.url);
7845
- const javascript_language = await resolveBundledFilePath(() => import("./assets/javascript/tree-sitter-javascript.wasm", { with: { type: "file" } }), "./assets/javascript/tree-sitter-javascript.wasm", import.meta.url);
7846
- const typescript_highlights = await resolveBundledFilePath(() => import("./assets/typescript/highlights.scm", { with: { type: "file" } }), "./assets/typescript/highlights.scm", import.meta.url);
7847
- const typescript_language = await resolveBundledFilePath(() => import("./assets/typescript/tree-sitter-typescript.wasm", { with: { type: "file" } }), "./assets/typescript/tree-sitter-typescript.wasm", import.meta.url);
7848
- const markdown_highlights = await resolveBundledFilePath(() => import("./assets/markdown/highlights.scm", { with: { type: "file" } }), "./assets/markdown/highlights.scm", import.meta.url);
7849
- const markdown_language = await resolveBundledFilePath(() => import("./assets/markdown/tree-sitter-markdown.wasm", { with: { type: "file" } }), "./assets/markdown/tree-sitter-markdown.wasm", import.meta.url);
7850
- const markdown_injections = await resolveBundledFilePath(() => import("./assets/markdown/injections.scm", { with: { type: "file" } }), "./assets/markdown/injections.scm", import.meta.url);
7851
- const markdown_inline_highlights = await resolveBundledFilePath(() => import("./assets/markdown_inline/highlights.scm", { with: { type: "file" } }), "./assets/markdown_inline/highlights.scm", import.meta.url);
7852
- const markdown_inline_language = await resolveBundledFilePath(() => import("./assets/markdown_inline/tree-sitter-markdown_inline.wasm", { with: { type: "file" } }), "./assets/markdown_inline/tree-sitter-markdown_inline.wasm", import.meta.url);
7853
- const zig_highlights = await resolveBundledFilePath(() => import("./assets/zig/highlights.scm", { with: { type: "file" } }), "./assets/zig/highlights.scm", import.meta.url);
7854
- const zig_language = await resolveBundledFilePath(() => import("./assets/zig/tree-sitter-zig.wasm", { with: { type: "file" } }), "./assets/zig/tree-sitter-zig.wasm", import.meta.url);
7855
- return [
7856
- {
7857
- filetype: "javascript",
7858
- aliases: ["javascriptreact"],
7859
- queries: {
7860
- highlights: [javascript_highlights]
7861
- },
7862
- wasm: javascript_language
7863
- },
7864
- {
7865
- filetype: "typescript",
7866
- aliases: ["typescriptreact"],
7867
- queries: {
7868
- highlights: [typescript_highlights]
7869
- },
7870
- wasm: typescript_language
7871
- },
7872
- {
7873
- filetype: "markdown",
7874
- queries: {
7875
- highlights: [markdown_highlights],
7876
- injections: [markdown_injections]
7877
- },
7878
- wasm: markdown_language,
7879
- injectionMapping: {
7880
- nodeTypes: {
7881
- inline: "markdown_inline",
7882
- pipe_table_cell: "markdown_inline"
7883
- },
7884
- infoStringMap: {
7885
- javascript: "javascript",
7886
- js: "javascript",
7887
- jsx: "javascriptreact",
7888
- javascriptreact: "javascriptreact",
7889
- typescript: "typescript",
7890
- ts: "typescript",
7891
- tsx: "typescriptreact",
7892
- typescriptreact: "typescriptreact",
7893
- markdown: "markdown",
7894
- md: "markdown"
7895
- }
7968
+ var defaultParserDescriptors = [
7969
+ {
7970
+ filetype: "javascript",
7971
+ aliases: ["javascriptreact"],
7972
+ queries: { highlights: ["assets/javascript/highlights.scm"] },
7973
+ wasm: "assets/javascript/tree-sitter-javascript.wasm"
7974
+ },
7975
+ {
7976
+ filetype: "typescript",
7977
+ aliases: ["typescriptreact"],
7978
+ queries: { highlights: ["assets/typescript/highlights.scm"] },
7979
+ wasm: "assets/typescript/tree-sitter-typescript.wasm"
7980
+ },
7981
+ {
7982
+ filetype: "markdown",
7983
+ queries: {
7984
+ highlights: ["assets/markdown/highlights.scm"],
7985
+ injections: ["assets/markdown/injections.scm"]
7986
+ },
7987
+ wasm: "assets/markdown/tree-sitter-markdown.wasm",
7988
+ injectionMapping: {
7989
+ nodeTypes: { inline: "markdown_inline", pipe_table_cell: "markdown_inline" },
7990
+ infoStringMap: {
7991
+ javascript: "javascript",
7992
+ js: "javascript",
7993
+ jsx: "javascriptreact",
7994
+ javascriptreact: "javascriptreact",
7995
+ typescript: "typescript",
7996
+ ts: "typescript",
7997
+ tsx: "typescriptreact",
7998
+ typescriptreact: "typescriptreact",
7999
+ markdown: "markdown",
8000
+ md: "markdown"
7896
8001
  }
7897
- },
7898
- {
7899
- filetype: "markdown_inline",
7900
- queries: {
7901
- highlights: [markdown_inline_highlights]
7902
- },
7903
- wasm: markdown_inline_language
7904
- },
7905
- {
7906
- filetype: "zig",
7907
- queries: {
7908
- highlights: [zig_highlights]
7909
- },
7910
- wasm: zig_language
7911
8002
  }
7912
- ];
8003
+ },
8004
+ {
8005
+ filetype: "markdown_inline",
8006
+ queries: { highlights: ["assets/markdown_inline/highlights.scm"] },
8007
+ wasm: "assets/markdown_inline/tree-sitter-markdown_inline.wasm"
8008
+ },
8009
+ {
8010
+ filetype: "zig",
8011
+ queries: { highlights: ["assets/zig/highlights.scm"] },
8012
+ wasm: "assets/zig/tree-sitter-zig.wasm"
8013
+ }
8014
+ ];
8015
+ var defaultParserAssetPaths = [
8016
+ ...new Set(defaultParserDescriptors.flatMap((parser) => [
8017
+ ...parser.queries.highlights,
8018
+ parser.wasm,
8019
+ ...parser.queries.injections ?? []
8020
+ ]))
8021
+ ];
8022
+ var cachedParsers;
8023
+ function getParsers() {
8024
+ cachedParsers ??= Promise.all(defaultParserDescriptors.map(resolveDefaultParser));
8025
+ return cachedParsers;
8026
+ }
8027
+ async function resolveDefaultParser(parser) {
8028
+ const queries = {
8029
+ highlights: await Promise.all(parser.queries.highlights.map(resolveParserAsset))
8030
+ };
8031
+ if (parser.queries.injections) {
8032
+ queries.injections = await Promise.all(parser.queries.injections.map(resolveParserAsset));
8033
+ }
8034
+ return {
8035
+ filetype: parser.filetype,
8036
+ ...parser.aliases ? { aliases: [...parser.aliases] } : {},
8037
+ queries,
8038
+ wasm: await resolveParserAsset(parser.wasm),
8039
+ ...parser.injectionMapping ? { injectionMapping: parser.injectionMapping } : {}
8040
+ };
8041
+ }
8042
+ function resolveParserAsset(relativePath) {
8043
+ return resolveDefaultParserAsset(relativePath, new URL(`./${relativePath}`, import.meta.url));
7913
8044
  }
7914
8045
 
7915
8046
  // src/lib/tree-sitter/client.ts
7916
- import { resolve as resolve2, isAbsolute as isAbsolute2, parse } from "path";
8047
+ import { resolve as resolve2, isAbsolute as isAbsolute3, parse } from "path";
7917
8048
  import { existsSync as existsSync2 } from "fs";
7918
8049
 
7919
8050
  // src/lib/bunfs.ts
7920
- import { basename, join } from "node:path";
8051
+ import { basename, join as join2 } from "node:path";
7921
8052
  function isBunfsPath(path) {
7922
8053
  return path.includes("$bunfs") || /^B:[\\/]~BUN/i.test(path);
7923
8054
  }
@@ -7925,7 +8056,7 @@ function getBunfsRootPath() {
7925
8056
  return process.platform === "win32" ? "B:\\~BUN\\root" : "/$bunfs/root";
7926
8057
  }
7927
8058
  function normalizeBunfsPath(fileName) {
7928
- return join(getBunfsRootPath(), basename(fileName));
8059
+ return join2(getBunfsRootPath(), basename(fileName));
7929
8060
  }
7930
8061
 
7931
8062
  // src/platform/worker.ts
@@ -8312,8 +8443,8 @@ class TreeSitterClient extends EventEmitter2 {
8312
8443
  if (typeof OTUI_TREE_SITTER_WORKER_PATH !== "undefined") {
8313
8444
  return OTUI_TREE_SITTER_WORKER_PATH;
8314
8445
  }
8315
- let workerPath = new URL("./parser.worker.js", import.meta.url).href;
8316
- if (!existsSync2(resolve2(import.meta.dirname, "parser.worker.js"))) {
8446
+ let workerPath = resolveDefaultTreeSitterWorkerPath(new URL("./parser.worker.js", import.meta.url));
8447
+ if (!process.env.OTUI_ASSET_ROOT && !existsSync2(workerPath)) {
8317
8448
  workerPath = new URL("./parser.worker.ts", import.meta.url).href;
8318
8449
  }
8319
8450
  return workerPath;
@@ -8390,6 +8521,8 @@ class TreeSitterClient extends EventEmitter2 {
8390
8521
  }
8391
8522
  }
8392
8523
  async initializeClient(generation, worker) {
8524
+ const treeSitterWasmPath = await resolveTreeSitterWasm();
8525
+ this.assertCurrentInitialization(generation, worker);
8393
8526
  await new Promise((resolve3, reject) => {
8394
8527
  const timeoutMs = this.options.initTimeout ?? 1e4;
8395
8528
  const timeoutId = setTimeout(() => {
@@ -8401,7 +8534,8 @@ class TreeSitterClient extends EventEmitter2 {
8401
8534
  this.initializeResolvers = { resolve: resolve3, reject, timeoutId };
8402
8535
  this.sendWorkerMessage({
8403
8536
  type: "INIT",
8404
- dataPath: this.options.dataPath
8537
+ dataPath: this.options.dataPath,
8538
+ treeSitterWasmPath
8405
8539
  });
8406
8540
  });
8407
8541
  this.assertCurrentInitialization(generation, worker);
@@ -8427,7 +8561,7 @@ class TreeSitterClient extends EventEmitter2 {
8427
8561
  if (isBunfsPath(path)) {
8428
8562
  return normalizeBunfsPath(parse(path).base);
8429
8563
  }
8430
- if (!isAbsolute2(path)) {
8564
+ if (!isAbsolute3(path)) {
8431
8565
  return resolve2(path);
8432
8566
  }
8433
8567
  return path;
@@ -11761,6 +11895,33 @@ var ReserveInfoStruct = defineStruct([
11761
11895
  len: value.len
11762
11896
  })
11763
11897
  });
11898
+ var NativeAudioStreamFormat = {
11899
+ Mp3: 1,
11900
+ Flac: 2
11901
+ };
11902
+ var NativeAudioStreamState = {
11903
+ Initializing: 0,
11904
+ Buffering: 1,
11905
+ Playing: 2,
11906
+ Ended: 3,
11907
+ Failed: 4,
11908
+ Cancelled: 5,
11909
+ Reconnecting: 6
11910
+ };
11911
+ var NativeAudioStreamStateNames = [
11912
+ "initializing",
11913
+ "buffering",
11914
+ "playing",
11915
+ "ended",
11916
+ "errored",
11917
+ "disposed",
11918
+ "reconnecting"
11919
+ ];
11920
+ var NativeAudioStreamCloseReason = {
11921
+ PreserveNativeTerminal: 0,
11922
+ TransportError: 1,
11923
+ Disposed: 2
11924
+ };
11764
11925
  var AudioCreateOptionsStruct = defineStruct([
11765
11926
  ["sampleRate", "u32", { default: 48000 }],
11766
11927
  ["playbackChannels", "u32", { default: 2 }]
@@ -11788,6 +11949,29 @@ var AudioVoiceOptionsStruct = defineStruct([
11788
11949
  ["loop", "bool_u8", { default: false }],
11789
11950
  ["groupId", "u32", { default: 0 }]
11790
11951
  ]);
11952
+ var AudioStreamCreateOptionsStruct = defineStruct([
11953
+ ["capacityMs", "u32"],
11954
+ ["startupMs", "u32"],
11955
+ ["resumeMs", "u32"],
11956
+ ["volume", "f32"],
11957
+ ["pan", "f32"],
11958
+ ["groupId", "u32"],
11959
+ ["maxProbeBytes", "u32"],
11960
+ ["format", "u32"]
11961
+ ]);
11962
+ var AudioStreamStatsStruct = defineStruct([
11963
+ ["bytesReceived", "u64"],
11964
+ ["framesDecoded", "u64"],
11965
+ ["framesPlayed", "u64"],
11966
+ ["state", "u32"],
11967
+ ["sampleRate", "u32"],
11968
+ ["channels", "u32"],
11969
+ ["bufferedFrames", "u32"],
11970
+ ["capacityFrames", "u32"],
11971
+ ["underruns", "u32"],
11972
+ ["errorCode", "i32"],
11973
+ ["readyGeneration", "u32"]
11974
+ ]);
11791
11975
  var AudioStatsStruct = defineStruct([
11792
11976
  ["soundsLoaded", "u32"],
11793
11977
  ["voicesActive", "u32"],
@@ -11798,57 +11982,27 @@ var AudioStatsStruct = defineStruct([
11798
11982
  ]);
11799
11983
 
11800
11984
  // src/zig.ts
11985
+ var NativeAudioStreamState2 = NativeAudioStreamState;
11986
+ var NativeAudioStreamCloseReason2 = NativeAudioStreamCloseReason;
11987
+ var NativeAudioStreamFormat2 = NativeAudioStreamFormat;
11801
11988
  registerEnvVar({
11802
11989
  name: "OPENTUI_LIBC",
11803
11990
  description: "Select Linux native libc package. Supported values: glibc, musl.",
11804
11991
  type: "string",
11805
11992
  default: ""
11806
11993
  });
11807
- function validateLinuxLibcOverride() {
11808
- const libc = process.env.OPENTUI_LIBC;
11809
- if (libc === undefined || libc === "" || libc === "glibc" || libc === "musl")
11810
- return;
11811
- throw new Error(`On Linux, OPENTUI_LIBC must be unset, empty, "glibc", or "musl", got "${libc}"`);
11812
- }
11813
- async function resolveNativePackage() {
11814
- if (process.platform === "darwin") {
11815
- if (process.arch === "x64")
11816
- return await import("@opentui/core-darwin-x64");
11817
- if (process.arch === "arm64")
11818
- return await import("@opentui/core-darwin-arm64");
11819
- }
11820
- if (process.platform === "linux") {
11821
- validateLinuxLibcOverride();
11822
- if (process.arch === "x64") {
11823
- if (process.env.OPENTUI_LIBC === "musl") {
11824
- return await import("@opentui/core-linux-x64-musl");
11825
- } else {
11826
- return await import("@opentui/core-linux-x64");
11827
- }
11828
- }
11829
- if (process.arch === "arm64") {
11830
- if (process.env.OPENTUI_LIBC === "musl") {
11831
- return await import("@opentui/core-linux-arm64-musl");
11832
- } else {
11833
- return await import("@opentui/core-linux-arm64");
11834
- }
11835
- }
11994
+ var targetLibPath;
11995
+ var targetLibError;
11996
+ try {
11997
+ targetLibPath = await resolveNativeLibraryPath();
11998
+ if (isBunfsPath(targetLibPath)) {
11999
+ targetLibPath = targetLibPath.replace("../", "");
11836
12000
  }
11837
- if (process.platform === "win32") {
11838
- if (process.arch === "x64")
11839
- return await import("@opentui/core-win32-x64");
11840
- if (process.arch === "arm64")
11841
- return await import("@opentui/core-win32-arm64");
12001
+ if (!existsSync3(targetLibPath)) {
12002
+ throw new Error(`OpenTUI native library does not exist at ${JSON.stringify(targetLibPath)}`);
11842
12003
  }
11843
- throw new Error(`opentui is not supported on the current platform: ${process.platform}-${process.arch}`);
11844
- }
11845
- var nativePackage = await resolveNativePackage();
11846
- var targetLibPath = nativePackage.default;
11847
- if (isBunfsPath(targetLibPath)) {
11848
- targetLibPath = targetLibPath.replace("../", "");
11849
- }
11850
- if (!existsSync3(targetLibPath)) {
11851
- throw new Error(`opentui is not supported on the current platform: ${process.platform}-${process.arch}`);
12004
+ } catch (error) {
12005
+ targetLibError = error instanceof Error ? error : new Error(String(error));
11852
12006
  }
11853
12007
  registerEnvVar({
11854
12008
  name: "OTUI_DEBUG_FFI",
@@ -11911,6 +12065,9 @@ function toSafeFFIU32Length(value, label) {
11911
12065
  }
11912
12066
  return value;
11913
12067
  }
12068
+ function isFFIU32(value) {
12069
+ return Number.isInteger(value) && value >= 0 && value <= MAX_FFI_U32;
12070
+ }
11914
12071
  function ptrOrNull(value) {
11915
12072
  return value.byteLength === 0 ? null : ptr(value);
11916
12073
  }
@@ -11922,6 +12079,9 @@ function optionalRgbaPtr(value) {
11922
12079
  }
11923
12080
  function getOpenTUILib(libPath) {
11924
12081
  const resolvedLibPath = libPath || targetLibPath;
12082
+ if (!resolvedLibPath) {
12083
+ throw targetLibError ?? new Error(`OpenTUI is not supported on the current platform: ${process.platform}-${process.arch}`);
12084
+ }
11925
12085
  const rawSymbols = dlopen(resolvedLibPath, {
11926
12086
  setLogCallback: {
11927
12087
  args: ["ptr"],
@@ -13159,6 +13319,42 @@ function getOpenTUILib(libPath) {
13159
13319
  args: ["u32"],
13160
13320
  returns: "i32"
13161
13321
  },
13322
+ audioCreateStream: {
13323
+ args: ["u32", "ptr", "ptr"],
13324
+ returns: "i32"
13325
+ },
13326
+ audioWriteStream: {
13327
+ args: ["u32", "u32", "ptr", "u32"],
13328
+ returns: "i32"
13329
+ },
13330
+ audioEndStream: {
13331
+ args: ["u32", "u32"],
13332
+ returns: "i32"
13333
+ },
13334
+ audioRestartStream: {
13335
+ args: ["u32", "u32"],
13336
+ returns: "i32"
13337
+ },
13338
+ audioSetStreamVolume: {
13339
+ args: ["u32", "u32", "f32"],
13340
+ returns: "i32"
13341
+ },
13342
+ audioSetStreamPan: {
13343
+ args: ["u32", "u32", "f32"],
13344
+ returns: "i32"
13345
+ },
13346
+ audioSetStreamGroup: {
13347
+ args: ["u32", "u32", "u32"],
13348
+ returns: "i32"
13349
+ },
13350
+ audioGetStreamStats: {
13351
+ args: ["u32", "u32", "ptr"],
13352
+ returns: "i32"
13353
+ },
13354
+ audioCloseStream: {
13355
+ args: ["u32", "u32", "u32", "ptr"],
13356
+ returns: "i32"
13357
+ },
13162
13358
  audioLoad: {
13163
13359
  args: ["u32", "ptr", "u32", "ptr"],
13164
13360
  returns: "i32"
@@ -13373,10 +13569,10 @@ function convertToDebugSymbols(symbols) {
13373
13569
  const medianWidth = Math.max(medHeader.length, ...allStats.map((s) => s.median.toFixed(2).length));
13374
13570
  const p90Width = Math.max(p90Header.length, ...allStats.map((s) => s.p90.toFixed(2).length));
13375
13571
  const p99Width = Math.max(p99Header.length, ...allStats.map((s) => s.p99.toFixed(2).length));
13376
- lines.push(`${nameHeader.padEnd(nameWidth)} | ${callsHeader.padStart(countWidth)} | ${totalHeader.padStart(totalWidth)} | ${avgHeader.padStart(avgWidth)} | ${minHeader.padStart(statWidthMin)} | ${maxHeader.padStart(statWidthMax)} | ${medHeader.padStart(medianWidth)} | ${p90Header.padStart(p90Width)} | ${p99Header.padStart(p99Width)}`);
13572
+ lines.push(`${nameHeader.padEnd(nameWidth)} | ` + `${callsHeader.padStart(countWidth)} | ` + `${totalHeader.padStart(totalWidth)} | ` + `${avgHeader.padStart(avgWidth)} | ` + `${minHeader.padStart(statWidthMin)} | ` + `${maxHeader.padStart(statWidthMax)} | ` + `${medHeader.padStart(medianWidth)} | ` + `${p90Header.padStart(p90Width)} | ` + `${p99Header.padStart(p99Width)}`);
13377
13573
  lines.push(`${"-".repeat(nameWidth)}-+-${"-".repeat(countWidth)}-+-${"-".repeat(totalWidth)}-+-${"-".repeat(avgWidth)}-+-${"-".repeat(statWidthMin)}-+-${"-".repeat(statWidthMax)}-+-${"-".repeat(medianWidth)}-+-${"-".repeat(p90Width)}-+-${"-".repeat(p99Width)}`);
13378
13574
  allStats.forEach((stat) => {
13379
- lines.push(`${stat.name.padEnd(nameWidth)} | ${String(stat.count).padStart(countWidth)} | ${stat.total.toFixed(2).padStart(totalWidth)} | ${stat.average.toFixed(2).padStart(avgWidth)} | ${stat.min.toFixed(2).padStart(statWidthMin)} | ${stat.max.toFixed(2).padStart(statWidthMax)} | ${stat.median.toFixed(2).padStart(medianWidth)} | ${stat.p90.toFixed(2).padStart(p90Width)} | ${stat.p99.toFixed(2).padStart(p99Width)}`);
13575
+ lines.push(`${stat.name.padEnd(nameWidth)} | ` + `${String(stat.count).padStart(countWidth)} | ` + `${stat.total.toFixed(2).padStart(totalWidth)} | ` + `${stat.average.toFixed(2).padStart(avgWidth)} | ` + `${stat.min.toFixed(2).padStart(statWidthMin)} | ` + `${stat.max.toFixed(2).padStart(statWidthMax)} | ` + `${stat.median.toFixed(2).padStart(medianWidth)} | ` + `${stat.p90.toFixed(2).padStart(p90Width)} | ` + `${stat.p99.toFixed(2).padStart(p99Width)}`);
13380
13576
  });
13381
13577
  }
13382
13578
  lines.push("-------------------------------------------------------------------------------------------------------------------------");
@@ -14913,7 +15109,12 @@ class FFIRenderLib {
14913
15109
  this.opentui.symbols.audioClearPlaybackDeviceSelection(engine);
14914
15110
  }
14915
15111
  audioStart(engine, options) {
14916
- const optionsBuffer = options == null ? null : AudioStartOptionsStruct.pack(options);
15112
+ let optionsBuffer;
15113
+ try {
15114
+ optionsBuffer = options == null ? null : AudioStartOptionsStruct.pack(options);
15115
+ } catch {
15116
+ return -1;
15117
+ }
14917
15118
  return this.opentui.symbols.audioStart(engine, optionsBuffer ? ptr(optionsBuffer) : null);
14918
15119
  }
14919
15120
  audioStartMixer(engine) {
@@ -14922,6 +15123,52 @@ class FFIRenderLib {
14922
15123
  audioStop(engine) {
14923
15124
  return this.opentui.symbols.audioStop(engine);
14924
15125
  }
15126
+ audioCreateStream(engine, options) {
15127
+ if (!isFFIU32(options.groupId) || options.format !== NativeAudioStreamFormat2.Mp3 && options.format !== NativeAudioStreamFormat2.Flac) {
15128
+ return { status: -1, streamId: null };
15129
+ }
15130
+ const optionsBuffer = AudioStreamCreateOptionsStruct.pack(options);
15131
+ const outBuffer = new ArrayBuffer(4);
15132
+ const status = this.opentui.symbols.audioCreateStream(engine, optionsBuffer, outBuffer);
15133
+ if (status !== 0)
15134
+ return { status, streamId: null };
15135
+ return { status, streamId: new Uint32Array(outBuffer)[0] ?? null };
15136
+ }
15137
+ audioWriteStream(engine, streamId, data) {
15138
+ const dataLength = toSafeFFIU32Length(data.byteLength, "Audio stream data length");
15139
+ return this.opentui.symbols.audioWriteStream(engine, streamId, dataLength === 0 ? null : data, dataLength);
15140
+ }
15141
+ audioEndStream(engine, streamId) {
15142
+ return this.opentui.symbols.audioEndStream(engine, streamId);
15143
+ }
15144
+ audioRestartStream(engine, streamId) {
15145
+ return this.opentui.symbols.audioRestartStream(engine, streamId);
15146
+ }
15147
+ audioSetStreamVolume(engine, streamId, volume) {
15148
+ return this.opentui.symbols.audioSetStreamVolume(engine, streamId, volume);
15149
+ }
15150
+ audioSetStreamPan(engine, streamId, pan) {
15151
+ return this.opentui.symbols.audioSetStreamPan(engine, streamId, pan);
15152
+ }
15153
+ audioSetStreamGroup(engine, streamId, groupId) {
15154
+ if (!isFFIU32(groupId))
15155
+ return -1;
15156
+ return this.opentui.symbols.audioSetStreamGroup(engine, streamId, groupId);
15157
+ }
15158
+ audioGetStreamStats(engine, streamId) {
15159
+ const outBuffer = new ArrayBuffer(AudioStreamStatsStruct.size);
15160
+ const status = this.opentui.symbols.audioGetStreamStats(engine, streamId, outBuffer);
15161
+ if (status !== 0)
15162
+ return null;
15163
+ return AudioStreamStatsStruct.unpack(outBuffer);
15164
+ }
15165
+ audioCloseStream(engine, streamId, reason) {
15166
+ const outBuffer = new ArrayBuffer(AudioStreamStatsStruct.size);
15167
+ const status = this.opentui.symbols.audioCloseStream(engine, streamId, reason, outBuffer);
15168
+ if (status !== 0)
15169
+ return { status, stats: null };
15170
+ return { status, stats: AudioStreamStatsStruct.unpack(outBuffer) };
15171
+ }
14925
15172
  audioLoad(engine, data) {
14926
15173
  const outBuffer = new ArrayBuffer(4);
14927
15174
  const dataLength = toSafeFFIU32Length(data.byteLength, "Audio data length");
@@ -14936,6 +15183,8 @@ class FFIRenderLib {
14936
15183
  return this.opentui.symbols.audioUnload(engine, soundId);
14937
15184
  }
14938
15185
  audioPlay(engine, soundId, options) {
15186
+ if (options?.groupId !== undefined && !isFFIU32(options.groupId))
15187
+ return { status: -1, voiceId: null };
14939
15188
  const outBuffer = new ArrayBuffer(4);
14940
15189
  const optionsBuffer = options ? AudioVoiceOptionsStruct.pack(options) : null;
14941
15190
  const status = this.opentui.symbols.audioPlay(engine, soundId, optionsBuffer ? ptr(optionsBuffer) : null, ptr(outBuffer));
@@ -14949,6 +15198,8 @@ class FFIRenderLib {
14949
15198
  return this.opentui.symbols.audioStopVoice(engine, voiceId);
14950
15199
  }
14951
15200
  audioSetVoiceGroup(engine, voiceId, groupId) {
15201
+ if (!isFFIU32(groupId))
15202
+ return -1;
14952
15203
  return this.opentui.symbols.audioSetVoiceGroup(engine, voiceId, groupId);
14953
15204
  }
14954
15205
  audioCreateGroup(engine, name) {
@@ -16104,7 +16355,7 @@ var Yoga = {
16104
16355
  };
16105
16356
  var yoga_default = Yoga;
16106
16357
 
16107
- export { toArrayBuffer, sleep, stringWidth2 as stringWidth, DEFAULT_FOREGROUND_RGB, DEFAULT_BACKGROUND_RGB, normalizeIndexedColorIndex, ansi256IndexToRgb, RGBA, normalizeColorValue, hexToRgb, rgbToHex, hsvToRgb, parseColor, isValidBorderStyle, parseBorderStyle, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, ATTRIBUTE_BASE_BITS, ATTRIBUTE_BASE_MASK, getBaseAttributes, DebugOverlayCorner, TargetChannel, createTextAttributes, attributesWithLink, getLinkId, visualizeRenderableTree, isStyledText, StyledText, stringToStyledText, black, red, green, yellow, blue, magenta, cyan, white, brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bold, italic, underline, strikethrough, dim, reverse, blink, fg, bg, link, t, hastToStyledText, SystemClock, nonAlphanumericKeys, terminalNamedSingleStrokeKeys, parseKeypress, LinearScrollAccel, MacOSScrollAccel, parseAlign, parseAlignItems, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, singleton, envRegistry, registerEnvVar, clearEnvCache, generateEnvMarkdown, generateEnvColored, env, StdinParser, treeSitterToTextChunks, treeSitterToStyledText, addDefaultParsers, TreeSitterClient, DataPathsManager, getDataPaths, extensionToFiletype, basenameToFiletype, extToFiletype, pathToFiletype, infoStringToFiletype, getTreeSitterClient, destroyTreeSitterClient, ExtmarksController, createExtmarksController, TerminalPalette, createTerminalPalette, normalizeTerminalPalette, buildTerminalPaletteSignature, decodePasteBytes, stripAnsiSequences, ClipboardTarget, Clipboard, detectLinks, OptimizedBuffer, TextBuffer, SpanInfoStruct, LogLevel2 as LogLevel, NativeMeasureTargetKind, setRenderLibPath, resolveRenderLib, Align, BoxSizing, Dimension, Direction, Display, Edge, Errata, ExperimentalFeature, FlexDirection, Gutter, Justify, LogLevel as LogLevel1, MeasureMode, NodeType, Overflow, PositionType, Unit, Wrap, ALIGN_AUTO, ALIGN_FLEX_START, ALIGN_CENTER, ALIGN_FLEX_END, ALIGN_STRETCH, ALIGN_BASELINE, ALIGN_SPACE_BETWEEN, ALIGN_SPACE_AROUND, ALIGN_SPACE_EVENLY, BOX_SIZING_BORDER_BOX, BOX_SIZING_CONTENT_BOX, DIMENSION_WIDTH, DIMENSION_HEIGHT, DIRECTION_INHERIT, DIRECTION_LTR, DIRECTION_RTL, DISPLAY_FLEX, DISPLAY_NONE, DISPLAY_CONTENTS, EDGE_LEFT, EDGE_TOP, EDGE_RIGHT, EDGE_BOTTOM, EDGE_START, EDGE_END, EDGE_HORIZONTAL, EDGE_VERTICAL, EDGE_ALL, ERRATA_NONE, ERRATA_STRETCH_FLEX_BASIS, ERRATA_ABSOLUTE_POSITION_WITHOUT_INSETS_EXCLUDES_PADDING, ERRATA_ABSOLUTE_PERCENT_AGAINST_INNER_SIZE, ERRATA_ALL, ERRATA_CLASSIC, EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS, FLEX_DIRECTION_COLUMN, FLEX_DIRECTION_COLUMN_REVERSE, FLEX_DIRECTION_ROW, FLEX_DIRECTION_ROW_REVERSE, GUTTER_COLUMN, GUTTER_ROW, GUTTER_ALL, JUSTIFY_FLEX_START, JUSTIFY_CENTER, JUSTIFY_FLEX_END, JUSTIFY_SPACE_BETWEEN, JUSTIFY_SPACE_AROUND, JUSTIFY_SPACE_EVENLY, LOG_LEVEL_ERROR, LOG_LEVEL_WARN, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_VERBOSE, LOG_LEVEL_FATAL, MEASURE_MODE_UNDEFINED, MEASURE_MODE_EXACTLY, MEASURE_MODE_AT_MOST, NODE_TYPE_DEFAULT, NODE_TYPE_TEXT, OVERFLOW_VISIBLE, OVERFLOW_HIDDEN, OVERFLOW_SCROLL, POSITION_TYPE_STATIC, POSITION_TYPE_RELATIVE, POSITION_TYPE_ABSOLUTE, UNIT_UNDEFINED, UNIT_POINT, UNIT_PERCENT, UNIT_AUTO, WRAP_NO_WRAP, WRAP_WRAP, WRAP_WRAP_REVERSE, Config, Node, exports_yoga, yoga_default };
16358
+ export { toArrayBuffer, singleton, envRegistry, registerEnvVar, clearEnvCache, generateEnvMarkdown, generateEnvColored, env, sleep, stringWidth2 as stringWidth, resolveBundledFilePath, DEFAULT_FOREGROUND_RGB, DEFAULT_BACKGROUND_RGB, normalizeIndexedColorIndex, ansi256IndexToRgb, RGBA, normalizeColorValue, hexToRgb, rgbToHex, hsvToRgb, parseColor, isValidBorderStyle, parseBorderStyle, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, ATTRIBUTE_BASE_BITS, ATTRIBUTE_BASE_MASK, getBaseAttributes, DebugOverlayCorner, TargetChannel, createTextAttributes, attributesWithLink, getLinkId, visualizeRenderableTree, isStyledText, StyledText, stringToStyledText, black, red, green, yellow, blue, magenta, cyan, white, brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bold, italic, underline, strikethrough, dim, reverse, blink, fg, bg, link, t, hastToStyledText, SystemClock, nonAlphanumericKeys, terminalNamedSingleStrokeKeys, parseKeypress, LinearScrollAccel, MacOSScrollAccel, parseAlign, parseAlignItems, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, StdinParser, treeSitterToTextChunks, treeSitterToStyledText, addDefaultParsers, TreeSitterClient, DataPathsManager, getDataPaths, extensionToFiletype, basenameToFiletype, extToFiletype, pathToFiletype, infoStringToFiletype, getTreeSitterClient, destroyTreeSitterClient, ExtmarksController, createExtmarksController, TerminalPalette, createTerminalPalette, normalizeTerminalPalette, buildTerminalPaletteSignature, decodePasteBytes, stripAnsiSequences, ClipboardTarget, Clipboard, detectLinks, OptimizedBuffer, TextBuffer, SpanInfoStruct, NativeAudioStreamFormat, NativeAudioStreamState, NativeAudioStreamStateNames, NativeAudioStreamCloseReason, NativeAudioStreamState2 as NativeAudioStreamState1, NativeAudioStreamCloseReason2 as NativeAudioStreamCloseReason1, NativeAudioStreamFormat2 as NativeAudioStreamFormat1, LogLevel2 as LogLevel, NativeMeasureTargetKind, setRenderLibPath, resolveRenderLib, Align, BoxSizing, Dimension, Direction, Display, Edge, Errata, ExperimentalFeature, FlexDirection, Gutter, Justify, LogLevel as LogLevel1, MeasureMode, NodeType, Overflow, PositionType, Unit, Wrap, ALIGN_AUTO, ALIGN_FLEX_START, ALIGN_CENTER, ALIGN_FLEX_END, ALIGN_STRETCH, ALIGN_BASELINE, ALIGN_SPACE_BETWEEN, ALIGN_SPACE_AROUND, ALIGN_SPACE_EVENLY, BOX_SIZING_BORDER_BOX, BOX_SIZING_CONTENT_BOX, DIMENSION_WIDTH, DIMENSION_HEIGHT, DIRECTION_INHERIT, DIRECTION_LTR, DIRECTION_RTL, DISPLAY_FLEX, DISPLAY_NONE, DISPLAY_CONTENTS, EDGE_LEFT, EDGE_TOP, EDGE_RIGHT, EDGE_BOTTOM, EDGE_START, EDGE_END, EDGE_HORIZONTAL, EDGE_VERTICAL, EDGE_ALL, ERRATA_NONE, ERRATA_STRETCH_FLEX_BASIS, ERRATA_ABSOLUTE_POSITION_WITHOUT_INSETS_EXCLUDES_PADDING, ERRATA_ABSOLUTE_PERCENT_AGAINST_INNER_SIZE, ERRATA_ALL, ERRATA_CLASSIC, EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS, FLEX_DIRECTION_COLUMN, FLEX_DIRECTION_COLUMN_REVERSE, FLEX_DIRECTION_ROW, FLEX_DIRECTION_ROW_REVERSE, GUTTER_COLUMN, GUTTER_ROW, GUTTER_ALL, JUSTIFY_FLEX_START, JUSTIFY_CENTER, JUSTIFY_FLEX_END, JUSTIFY_SPACE_BETWEEN, JUSTIFY_SPACE_AROUND, JUSTIFY_SPACE_EVENLY, LOG_LEVEL_ERROR, LOG_LEVEL_WARN, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_VERBOSE, LOG_LEVEL_FATAL, MEASURE_MODE_UNDEFINED, MEASURE_MODE_EXACTLY, MEASURE_MODE_AT_MOST, NODE_TYPE_DEFAULT, NODE_TYPE_TEXT, OVERFLOW_VISIBLE, OVERFLOW_HIDDEN, OVERFLOW_SCROLL, POSITION_TYPE_STATIC, POSITION_TYPE_RELATIVE, POSITION_TYPE_ABSOLUTE, UNIT_UNDEFINED, UNIT_POINT, UNIT_PERCENT, UNIT_AUTO, WRAP_NO_WRAP, WRAP_WRAP, WRAP_WRAP_REVERSE, Config, Node, exports_yoga, yoga_default };
16108
16359
 
16109
- //# debugId=FC7AC9CF38562F8A64756E2164756E21
16110
- //# sourceMappingURL=index-d5xqskty.js.map
16360
+ //# debugId=F036A274BA18217764756E2164756E21
16361
+ //# sourceMappingURL=chunk-node-q0cwyvm9.js.map