@kromatv/sdk 0.1.40-canary.1 → 0.1.40-canary.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 (111) hide show
  1. package/dist/cli.js +1116 -116
  2. package/package.json +2 -7
  3. package/rust/kroma-db/Cargo.toml +1 -1
  4. package/rust/kroma-domain/Cargo.toml +1 -1
  5. package/rust/kroma-http/Cargo.toml +1 -1
  6. package/rust/kroma-module-host/Cargo.toml +1 -1
  7. package/rust/kroma-module-macros/Cargo.toml +1 -1
  8. package/rust/kroma-module-manifest/Cargo.toml +1 -1
  9. package/rust/kroma-module-runtime/Cargo.toml +1 -1
  10. package/rust/kroma-module-sdk/Cargo.toml +1 -1
  11. package/rust/kroma-primitives/Cargo.toml +1 -1
  12. package/rust/kroma-testing/Cargo.toml +1 -1
  13. package/tsconfig.module.json +6 -0
  14. package/types/react-native/Libraries/ActionSheetIOS/ActionSheetIOS.d.ts +87 -0
  15. package/types/react-native/Libraries/Alert/Alert.d.ts +94 -0
  16. package/types/react-native/Libraries/Animated/Animated.d.ts +635 -0
  17. package/types/react-native/Libraries/Animated/Easing.d.ts +37 -0
  18. package/types/react-native/Libraries/Animated/useAnimatedColor.d.ts +15 -0
  19. package/types/react-native/Libraries/Animated/useAnimatedValue.d.ts +15 -0
  20. package/types/react-native/Libraries/Animated/useAnimatedValueXY.d.ts +15 -0
  21. package/types/react-native/Libraries/AppState/AppState.d.ts +58 -0
  22. package/types/react-native/Libraries/BatchedBridge/NativeModules.d.ts +25 -0
  23. package/types/react-native/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +181 -0
  24. package/types/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.d.ts +86 -0
  25. package/types/react-native/Libraries/Components/Button.d.ts +42 -0
  26. package/types/react-native/Libraries/Components/Clipboard/Clipboard.d.ts +28 -0
  27. package/types/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.d.ts +141 -0
  28. package/types/react-native/Libraries/Components/Keyboard/Keyboard.d.ts +109 -0
  29. package/types/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.d.ts +46 -0
  30. package/types/react-native/Libraries/Components/LayoutConformance/LayoutConformance.d.ts +21 -0
  31. package/types/react-native/Libraries/Components/Pressable/Pressable.d.ts +181 -0
  32. package/types/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.d.ts +83 -0
  33. package/types/react-native/Libraries/Components/RefreshControl/RefreshControl.d.ts +87 -0
  34. package/types/react-native/Libraries/Components/SafeAreaView/SafeAreaView.d.ts +33 -0
  35. package/types/react-native/Libraries/Components/ScrollView/ScrollView.d.ts +961 -0
  36. package/types/react-native/Libraries/Components/StatusBar/StatusBar.d.ts +142 -0
  37. package/types/react-native/Libraries/Components/Switch/Switch.d.ts +118 -0
  38. package/types/react-native/Libraries/Components/TV/TVParallaxProperties.d.ts +42 -0
  39. package/types/react-native/Libraries/Components/TextInput/InputAccessoryView.d.ts +34 -0
  40. package/types/react-native/Libraries/Components/TextInput/TextInput.d.ts +1076 -0
  41. package/types/react-native/Libraries/Components/ToastAndroid/ToastAndroid.d.ts +109 -0
  42. package/types/react-native/Libraries/Components/Touchable/Touchable.d.ts +90 -0
  43. package/types/react-native/Libraries/Components/Touchable/TouchableHighlight.d.ts +62 -0
  44. package/types/react-native/Libraries/Components/Touchable/TouchableNativeFeedback.d.ts +114 -0
  45. package/types/react-native/Libraries/Components/Touchable/TouchableOpacity.d.ts +81 -0
  46. package/types/react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.d.ts +151 -0
  47. package/types/react-native/Libraries/Components/View/View.d.ts +29 -0
  48. package/types/react-native/Libraries/Components/View/ViewAccessibility.d.ts +419 -0
  49. package/types/react-native/Libraries/Components/View/ViewPropTypes.d.ts +271 -0
  50. package/types/react-native/Libraries/Core/registerCallableModule.d.ts +16 -0
  51. package/types/react-native/Libraries/EventEmitter/NativeEventEmitter.d.ts +63 -0
  52. package/types/react-native/Libraries/EventEmitter/RCTDeviceEventEmitter.d.ts +29 -0
  53. package/types/react-native/Libraries/EventEmitter/RCTNativeAppEventEmitter.d.ts +32 -0
  54. package/types/react-native/Libraries/Image/Image.d.ts +389 -0
  55. package/types/react-native/Libraries/Image/ImageResizeMode.d.ts +56 -0
  56. package/types/react-native/Libraries/Image/ImageSource.d.ts +79 -0
  57. package/types/react-native/Libraries/Interaction/InteractionManager.d.ts +87 -0
  58. package/types/react-native/Libraries/Interaction/PanResponder.d.ts +202 -0
  59. package/types/react-native/Libraries/LayoutAnimation/LayoutAnimation.d.ts +84 -0
  60. package/types/react-native/Libraries/Linking/Linking.d.ts +61 -0
  61. package/types/react-native/Libraries/Lists/FlatList.d.ts +248 -0
  62. package/types/react-native/Libraries/Lists/SectionList.d.ts +271 -0
  63. package/types/react-native/Libraries/LogBox/LogBox.d.ts +28 -0
  64. package/types/react-native/Libraries/Modal/Modal.d.ts +122 -0
  65. package/types/react-native/Libraries/NativeComponent/NativeComponentRegistry.d.ts +98 -0
  66. package/types/react-native/Libraries/Performance/Systrace.d.ts +66 -0
  67. package/types/react-native/Libraries/PermissionsAndroid/PermissionsAndroid.d.ts +163 -0
  68. package/types/react-native/Libraries/PushNotificationIOS/PushNotificationIOS.d.ts +295 -0
  69. package/types/react-native/Libraries/ReactNative/AppRegistry.d.ts +121 -0
  70. package/types/react-native/Libraries/ReactNative/I18nManager.d.ts +25 -0
  71. package/types/react-native/Libraries/ReactNative/IPerformanceLogger.d.ts +51 -0
  72. package/types/react-native/Libraries/ReactNative/RendererProxy.d.ts +20 -0
  73. package/types/react-native/Libraries/ReactNative/RootTag.d.ts +13 -0
  74. package/types/react-native/Libraries/ReactNative/UIManager.d.ts +114 -0
  75. package/types/react-native/Libraries/ReactNative/requireNativeComponent.d.ts +23 -0
  76. package/types/react-native/Libraries/Settings/Settings.d.ts +18 -0
  77. package/types/react-native/Libraries/Share/Share.d.ts +80 -0
  78. package/types/react-native/Libraries/StyleSheet/PlatformColorValueTypes.d.ts +18 -0
  79. package/types/react-native/Libraries/StyleSheet/PlatformColorValueTypesIOS.d.ts +25 -0
  80. package/types/react-native/Libraries/StyleSheet/StyleSheet.d.ts +130 -0
  81. package/types/react-native/Libraries/StyleSheet/StyleSheetTypes.d.ts +666 -0
  82. package/types/react-native/Libraries/StyleSheet/processColor.d.ts +16 -0
  83. package/types/react-native/Libraries/Text/Text.d.ts +230 -0
  84. package/types/react-native/Libraries/TurboModule/RCTExport.d.ts +12 -0
  85. package/types/react-native/Libraries/TurboModule/TurboModuleRegistry.d.ts +13 -0
  86. package/types/react-native/Libraries/Types/CodegenTypesNamespace.d.ts +45 -0
  87. package/types/react-native/Libraries/Types/CoreEventTypes.d.ts +293 -0
  88. package/types/react-native/Libraries/Utilities/Appearance.d.ts +51 -0
  89. package/types/react-native/Libraries/Utilities/BackHandler.d.ts +44 -0
  90. package/types/react-native/Libraries/Utilities/DevSettings.d.ts +32 -0
  91. package/types/react-native/Libraries/Utilities/Dimensions.d.ts +79 -0
  92. package/types/react-native/Libraries/Utilities/PixelRatio.d.ts +64 -0
  93. package/types/react-native/Libraries/Utilities/Platform.d.ts +108 -0
  94. package/types/react-native/Libraries/Utilities/codegenNativeCommands.d.ts +18 -0
  95. package/types/react-native/Libraries/Utilities/codegenNativeComponent.d.ts +28 -0
  96. package/types/react-native/Libraries/Vibration/Vibration.d.ts +43 -0
  97. package/types/react-native/Libraries/vendor/core/ErrorUtils.d.ts +15 -0
  98. package/types/react-native/Libraries/vendor/emitter/EventEmitter.d.ts +164 -0
  99. package/types/react-native/src/private/devsupport/devmenu/DevMenu.d.ts +20 -0
  100. package/types/react-native/src/types/globals.d.ts +699 -0
  101. package/types/react-native/types/index.d.ts +167 -0
  102. package/types/react-native/types/modules/BatchedBridge.d.ts +32 -0
  103. package/types/react-native/types/modules/Codegen.d.ts +80 -0
  104. package/types/react-native/types/modules/Devtools.d.ts +46 -0
  105. package/types/react-native/types/private/TimerMixin.d.ts +19 -0
  106. package/types/react-native/types/private/Utilities.d.ts +10 -0
  107. package/types/react-native/types/public/DeprecatedPropertiesAlias.d.ts +185 -0
  108. package/types/react-native/types/public/Insets.d.ts +15 -0
  109. package/types/react-native/types/public/ReactNativeRenderer.d.ts +144 -0
  110. package/types/react-native/types/public/ReactNativeTVTypes.d.ts +234 -0
  111. package/types/react-native/types/public/ReactNativeTypes.d.ts +252 -0
package/dist/cli.js CHANGED
@@ -20680,6 +20680,29 @@ var init_src = __esm(() => {
20680
20680
  init_spec();
20681
20681
  });
20682
20682
 
20683
+ // src/exec.ts
20684
+ import { spawn } from "child_process";
20685
+ function exec2(command, args, options) {
20686
+ return new Promise((resolve, reject) => {
20687
+ const child = spawn(command, args, {
20688
+ cwd: options.cwd,
20689
+ env: options.env ?? process.env,
20690
+ stdio: options.quiet ? ["ignore", "pipe", "pipe"] : "inherit"
20691
+ });
20692
+ let stdout2 = "";
20693
+ let stderr = "";
20694
+ child.stdout?.on("data", (chunk) => {
20695
+ stdout2 += chunk.toString();
20696
+ });
20697
+ child.stderr?.on("data", (chunk) => {
20698
+ stderr += chunk.toString();
20699
+ });
20700
+ child.on("error", reject);
20701
+ child.on("close", (code) => resolve({ exitCode: code ?? 1, stdout: stdout2, stderr }));
20702
+ });
20703
+ }
20704
+ var init_exec = () => {};
20705
+
20683
20706
  // ../module-sdk/src/shared.ts
20684
20707
  function sharedKey(specifier) {
20685
20708
  if (specifier === PUBLIC_NAME)
@@ -20752,8 +20775,7 @@ function versions2(cwd) {
20752
20775
  return {
20753
20776
  sdk,
20754
20777
  server: server ?? sdk,
20755
- rustChannel: channel ?? "1.98.0",
20756
- reactNative: own2.kroma.reactNative
20778
+ rustChannel: channel ?? "1.98.0"
20757
20779
  };
20758
20780
  }
20759
20781
  function repoRoot(cwd) {
@@ -20857,11 +20879,10 @@ function packageJsonFor(a2, v) {
20857
20879
  },
20858
20880
  peerDependencies: { react: "^19.2.8" },
20859
20881
  devDependencies: {
20860
- ...a2.inRepo ? {} : { react: "^19.2.8", "react-native": v.reactNative },
20882
+ ...a2.inRepo ? {} : { react: "^19.2.8" },
20861
20883
  "@types/react": "^19.2.18",
20862
20884
  typescript: "^7.0.2"
20863
- },
20864
- ...a2.inRepo ? {} : { overrides: { "react-native": v.reactNative } }
20885
+ }
20865
20886
  };
20866
20887
  }
20867
20888
  function tsconfigFor(a2, depth) {
@@ -20880,11 +20901,8 @@ var init_plan = __esm(() => {
20880
20901
  init_src();
20881
20902
  init_zod();
20882
20903
  OWN_NAMES = new Set(["@kroma/cli", PUBLIC_NAME]);
20883
- CLI_ROOT = packageRoot(import.meta.dir);
20884
- PackageJson = exports_external.object({
20885
- version: exports_external.string(),
20886
- kroma: exports_external.object({ reactNative: exports_external.string() })
20887
- });
20904
+ CLI_ROOT = packageRoot(import.meta.dirname);
20905
+ PackageJson = exports_external.object({ version: exports_external.string() });
20888
20906
  });
20889
20907
 
20890
20908
  // src/scaffold/render.ts
@@ -20931,9 +20949,8 @@ var exports_create = {};
20931
20949
  __export(exports_create, {
20932
20950
  createCommand: () => createCommand
20933
20951
  });
20934
- import { existsSync as existsSync2, mkdirSync as mkdirSync2, readdirSync as readdirSync2, writeFileSync as writeFileSync2 } from "fs";
20952
+ import { existsSync as existsSync2, mkdirSync as mkdirSync2, readdirSync as readdirSync2, rmSync, writeFileSync as writeFileSync2 } from "fs";
20935
20953
  import { join as join3, relative as relative2, resolve } from "path";
20936
- var {$ } = globalThis.Bun;
20937
20954
  function isKind(v) {
20938
20955
  return v === "full" || v === "server" || v === "ui";
20939
20956
  }
@@ -20945,7 +20962,7 @@ function idIssue(id) {
20945
20962
  }
20946
20963
  function titleOf(id) {
20947
20964
  const slug = slugOf(id);
20948
- return slug.charAt(0).toUpperCase() + slug.slice(1).replace(/-/g, " ");
20965
+ return slug.charAt(0).toUpperCase() + slug.slice(1).replaceAll("-", " ");
20949
20966
  }
20950
20967
  async function answer(value) {
20951
20968
  if (isCancel(value))
@@ -20987,23 +21004,18 @@ function write(target, rel, value) {
20987
21004
  writeFileSync2(join3(target, rel), `${JSON.stringify(value, null, 2)}
20988
21005
  `);
20989
21006
  }
20990
- async function createCommand(options) {
20991
- const cwd = options.cwd ?? process.cwd();
20992
- const a2 = await ask(options, cwd);
20993
- const repo = a2.inRepo ? repoRoot(cwd) : null;
21007
+ function targetFor(options, id, cwd, repo) {
20994
21008
  const explicit = options.dir && !isBareId(options.dir) ? resolve(cwd, options.dir) : null;
20995
- const target = explicit ?? (repo ? join3(repo, "modules", a2.id) : join3(cwd, a2.id));
20996
- if (existsSync2(target) && readdirSync2(target).length > 0) {
20997
- throw new Error(`${target} exists and is not empty`);
20998
- }
20999
- mkdirSync2(target, { recursive: true });
21009
+ return explicit ?? (repo ? join3(repo, "modules", id) : join3(cwd, id));
21010
+ }
21011
+ function scaffold(a2, target, repo, cwd) {
21000
21012
  const v = versions2(cwd);
21001
21013
  const vars = templateVars(a2, v);
21002
21014
  const written = [];
21003
21015
  for (const tree of treesFor(a2.kind)) {
21004
21016
  for (const rel of renderTree(tree, target, vars)) {
21005
21017
  if (a2.inRepo && skipInRepo(rel)) {
21006
- await $`rm -f ${join3(target, rel)}`.quiet();
21018
+ rmSync(join3(target, rel), { force: true });
21007
21019
  continue;
21008
21020
  }
21009
21021
  written.push(rel);
@@ -21014,38 +21026,55 @@ async function createCommand(options) {
21014
21026
  const pkg = packageJsonFor(a2, v);
21015
21027
  if (pkg) {
21016
21028
  write(target, "package.json", pkg);
21017
- write(target, "tsconfig.json", tsconfigFor(a2, repo ? relative2(repo, target).split("/").length : 0));
21029
+ const depth = repo ? relative2(repo, target).split("/").length : 0;
21030
+ write(target, "tsconfig.json", tsconfigFor(a2, depth));
21018
21031
  written.push("package.json", "tsconfig.json");
21019
21032
  }
21033
+ return { written, hasPackage: pkg !== null };
21034
+ }
21035
+ async function install(quiet, inRepo, cwd) {
21036
+ const s = quiet ? null : spinner();
21037
+ s?.start(inRepo ? "bun install (workspace links)" : "bun install");
21038
+ const result = await exec2("bun", ["install"], { cwd, quiet: true });
21039
+ if (result.exitCode !== 0) {
21040
+ s?.stop("bun install failed");
21041
+ console.error(result.stderr);
21042
+ return false;
21043
+ }
21044
+ s?.stop("installed");
21045
+ return true;
21046
+ }
21047
+ function nextSteps(where, inRepo) {
21048
+ return [
21049
+ ...where === "." ? [] : [`cd ${where}`],
21050
+ ...inRepo ? [] : ["bunx kroma login http://localhost:4040"],
21051
+ "bunx kroma dev"
21052
+ ].join(`
21053
+ `);
21054
+ }
21055
+ async function createCommand(options) {
21056
+ const cwd = options.cwd ?? process.cwd();
21057
+ const a2 = await ask(options, cwd);
21058
+ const repo = a2.inRepo ? repoRoot(cwd) : null;
21059
+ const target = targetFor(options, a2.id, cwd, repo);
21060
+ if (existsSync2(target) && readdirSync2(target).length > 0) {
21061
+ throw new Error(`${target} exists and is not empty`);
21062
+ }
21063
+ mkdirSync2(target, { recursive: true });
21064
+ const { written, hasPackage } = scaffold(a2, target, repo, cwd);
21020
21065
  const where = relative2(cwd, target) || ".";
21021
- if (options.yes) {
21066
+ const quiet = options.yes === true;
21067
+ if (quiet)
21022
21068
  console.log(`created ${a2.id} in ${where} (${written.length} files)`);
21023
- } else {
21069
+ else
21024
21070
  log.success(`${a2.id} in ${where}`);
21025
- }
21026
- const install = options.install !== false && pkg !== null;
21027
- if (install) {
21028
- const s = options.yes ? null : spinner();
21029
- s?.start(a2.inRepo ? "bun install (workspace links)" : "bun install");
21030
- const result = await $`bun install`.cwd(repo ?? target).quiet().nothrow();
21031
- if (result.exitCode !== 0) {
21032
- s?.stop("bun install failed");
21033
- console.error(result.stderr.toString());
21034
- return 1;
21035
- }
21036
- s?.stop("installed");
21037
- }
21038
- const next = [
21039
- ...where === "." ? [] : [`cd ${where}`],
21040
- ...a2.inRepo ? [] : ["bunx kroma login http://localhost:4040"],
21041
- a2.inRepo ? "bunx kroma dev" : "bunx kroma dev"
21042
- ];
21043
- if (options.yes) {
21044
- console.log(next.join(`
21045
- `));
21071
+ const wanted = options.install !== false && hasPackage;
21072
+ if (wanted && !await install(quiet, a2.inRepo, repo ?? target))
21073
+ return 1;
21074
+ if (quiet) {
21075
+ console.log(nextSteps(where, a2.inRepo));
21046
21076
  } else {
21047
- note(next.join(`
21048
- `), "next");
21077
+ note(nextSteps(where, a2.inRepo), "next");
21049
21078
  outro("done");
21050
21079
  }
21051
21080
  return 0;
@@ -21054,6 +21083,7 @@ var KINDS;
21054
21083
  var init_create = __esm(() => {
21055
21084
  init_dist4();
21056
21085
  init_src();
21086
+ init_exec();
21057
21087
  init_plan();
21058
21088
  init_render();
21059
21089
  init_style();
@@ -21078,6 +21108,7 @@ function byCodeUnit2(a2, b) {
21078
21108
  // src/bundle/tar.ts
21079
21109
  import { readdirSync as readdirSync3, readFileSync as readFileSync3, statSync } from "fs";
21080
21110
  import { join as join4 } from "path";
21111
+ import { gunzipSync, zstdDecompressSync } from "zlib";
21081
21112
  function octal(value, width) {
21082
21113
  return `${value.toString(8).padStart(width - 1, "0")}\x00`;
21083
21114
  }
@@ -21158,10 +21189,10 @@ function tarRead(tar, wanted) {
21158
21189
  }
21159
21190
  function toTar(buf) {
21160
21191
  if (buf[0] === 40 && buf[1] === 181 && buf[2] === 47 && buf[3] === 253) {
21161
- return Bun.zstdDecompressSync(buf);
21192
+ return new Uint8Array(zstdDecompressSync(buf));
21162
21193
  }
21163
21194
  if (buf[0] === 31 && buf[1] === 139) {
21164
- return Bun.gunzipSync(buf);
21195
+ return new Uint8Array(gunzipSync(buf));
21165
21196
  }
21166
21197
  return buf;
21167
21198
  }
@@ -21169,23 +21200,26 @@ var BLOCK = 512;
21169
21200
  var init_tar = () => {};
21170
21201
 
21171
21202
  // src/bundle/pack.ts
21203
+ import { createHash } from "crypto";
21172
21204
  import {
21173
21205
  copyFileSync,
21174
21206
  cpSync,
21175
21207
  existsSync as existsSync3,
21176
21208
  mkdirSync as mkdirSync3,
21177
21209
  readFileSync as readFileSync4,
21178
- rmSync,
21210
+ rmSync as rmSync2,
21179
21211
  writeFileSync as writeFileSync3
21180
21212
  } from "fs";
21181
21213
  import { join as join5 } from "path";
21214
+ import { constants, zstdCompressSync } from "zlib";
21182
21215
  function bundleName(id, hasBinary, target) {
21183
- return `${id}${hasBinary && target ? `-${target}` : ""}.kmod`;
21216
+ const suffix = hasBinary && target ? `-${target}` : "";
21217
+ return `${id}${suffix}.kmod`;
21184
21218
  }
21185
21219
  function stage(input2) {
21186
21220
  const { project, binPath, feDir } = input2;
21187
21221
  const staging = join5(project.dir, ".bundle");
21188
- rmSync(staging, { recursive: true, force: true });
21222
+ rmSync2(staging, { recursive: true, force: true });
21189
21223
  mkdirSync3(staging, { recursive: true });
21190
21224
  const entries = ["module.json"];
21191
21225
  copyFileSync(join5(project.dir, "module.json"), join5(staging, "module.json"));
@@ -21212,17 +21246,17 @@ function packBundle(input2) {
21212
21246
  const file2 = bundleName(project.manifest.id, binPath !== null, target);
21213
21247
  const kmod = join5(outDir, file2);
21214
21248
  const tar = deterministicTar(staging, entries);
21215
- rmSync(staging, { recursive: true, force: true });
21249
+ rmSync2(staging, { recursive: true, force: true });
21216
21250
  const stamp = `${kmod}.tarsha`;
21217
- const tarSha = Bun.SHA256.hash(tar, "hex");
21251
+ const tarSha = sha256(tar);
21218
21252
  if (existsSync3(kmod) && existsSync3(stamp) && readFileSync4(stamp, "utf8").trim() === tarSha) {
21219
21253
  return { path: kmod, file: file2, changed: false };
21220
21254
  }
21221
- const bytes = Bun.zstdCompressSync(tar, { level: 19 });
21255
+ const bytes = zstd(tar, 19);
21222
21256
  writeFileSync3(kmod, bytes);
21223
21257
  writeFileSync3(stamp, `${tarSha}
21224
21258
  `);
21225
- writeFileSync3(`${kmod}.sha256`, `${Bun.SHA256.hash(bytes, "hex")} ${file2}
21259
+ writeFileSync3(`${kmod}.sha256`, `${sha256(bytes)} ${file2}
21226
21260
  `);
21227
21261
  return { path: kmod, file: file2, changed: true };
21228
21262
  }
@@ -21233,10 +21267,11 @@ function packForDev(input2) {
21233
21267
  const file2 = bundleName(project.manifest.id, binPath !== null, target);
21234
21268
  const kmod = join5(outDir, file2);
21235
21269
  const tar = deterministicTar(staging, entries);
21236
- rmSync(staging, { recursive: true, force: true });
21237
- writeFileSync3(kmod, Bun.zstdCompressSync(tar, { level: 1 }));
21270
+ rmSync2(staging, { recursive: true, force: true });
21271
+ writeFileSync3(kmod, zstd(tar, 1));
21238
21272
  return { path: kmod, file: file2, changed: true };
21239
21273
  }
21274
+ var sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex"), zstd = (bytes, level) => zstdCompressSync(bytes, { params: { [constants.ZSTD_c_compressionLevel]: level } });
21240
21275
  var init_pack = __esm(() => {
21241
21276
  init_tar();
21242
21277
  });
@@ -21244,7 +21279,6 @@ var init_pack = __esm(() => {
21244
21279
  // src/cargo.ts
21245
21280
  import { existsSync as existsSync4 } from "fs";
21246
21281
  import { join as join6 } from "path";
21247
- var {$: $2 } = globalThis.Bun;
21248
21282
  function targetDir(cwd, projects) {
21249
21283
  const env = process.env.KMOD_TARGET_DIR?.trim();
21250
21284
  if (env)
@@ -21267,8 +21301,11 @@ function cargoBuild(bin, features, target, profile, dir) {
21267
21301
  return { args, binPath };
21268
21302
  }
21269
21303
  async function cargo(cwd, args, dir, quiet = false) {
21270
- const run = $2`cargo ${args}`.cwd(cwd).env({ ...process.env, CARGO_TARGET_DIR: dir }).nothrow();
21271
- const result = quiet ? await run.quiet() : await run;
21304
+ const result = await exec2("cargo", args, {
21305
+ cwd,
21306
+ env: { ...process.env, CARGO_TARGET_DIR: dir },
21307
+ quiet
21308
+ });
21272
21309
  return result.exitCode;
21273
21310
  }
21274
21311
  async function buildSidecar(project, dir, options) {
@@ -21286,7 +21323,9 @@ async function buildSidecar(project, dir, options) {
21286
21323
  }
21287
21324
  return binPath;
21288
21325
  }
21289
- var init_cargo = () => {};
21326
+ var init_cargo = __esm(() => {
21327
+ init_exec();
21328
+ });
21290
21329
 
21291
21330
  // ../../node_modules/.bun/es-module-lexer@2.3.1/node_modules/es-module-lexer/dist/lexer.js
21292
21331
  function parse6(C2, g = "@") {
@@ -22498,7 +22537,7 @@ var init_magic_string_es = __esm(() => {
22498
22537
  // src/fe/remote-plugin.ts
22499
22538
  import { dirname as dirname3, relative as relative3 } from "path";
22500
22539
  function posix(path) {
22501
- return path.split("\\").join("/");
22540
+ return path.replaceAll("\\", "/");
22502
22541
  }
22503
22542
  function relativeImport(from, to) {
22504
22543
  const rel = posix(relative3(dirname3(from), to));
@@ -22507,47 +22546,63 @@ function relativeImport(from, to) {
22507
22546
  function clean(id) {
22508
22547
  return id.split("?", 1)[0] ?? id;
22509
22548
  }
22549
+ function splitAs(field) {
22550
+ const words = field.split(" ").filter(Boolean);
22551
+ const as = words.indexOf("as");
22552
+ if (as < 0)
22553
+ return [words.join(""), undefined];
22554
+ return [words.slice(0, as).join(""), words.slice(as + 1).join("")];
22555
+ }
22556
+ function fieldsOf(braces) {
22557
+ return braces.slice(1, -1).split(",").map((s) => s.trim()).filter(Boolean).map(splitAs);
22558
+ }
22510
22559
  function pattern(braces) {
22511
- const fields = braces.slice(1, -1).split(",").map((s) => s.trim()).filter(Boolean).map((s) => {
22512
- const [name, alias] = s.split(/\s+as\s+/);
22513
- return alias ? `${name}: ${alias}` : String(name);
22514
- });
22560
+ const fields = fieldsOf(braces).map(([name, alias]) => alias ? `${name}: ${alias}` : name);
22515
22561
  return `{ ${fields.join(", ")} }`;
22516
22562
  }
22563
+ function takeBraces(clause) {
22564
+ const open2 = clause.indexOf("{");
22565
+ const close = clause.indexOf("}");
22566
+ if (open2 < 0 || close < open2)
22567
+ return [null, clause];
22568
+ return [clause.slice(open2, close + 1), `${clause.slice(0, open2)}${clause.slice(close + 1)}`];
22569
+ }
22570
+ function takeNamespace(clause) {
22571
+ const star = clause.indexOf("*");
22572
+ if (star < 0)
22573
+ return [null, clause];
22574
+ const [, ns] = splitAs(clause.slice(star + 1).split(",")[0] ?? "");
22575
+ const rest = clause.slice(0, star) + clause.slice(star + 1).split(",").slice(1).join(",");
22576
+ return [ns ?? null, rest];
22577
+ }
22517
22578
  function rewriteImport(statement, key, tmp) {
22518
22579
  const take = `const ${tmp} = ${HELPER_FN}(${JSON.stringify(key)});`;
22519
- if (/^import\s*['"]/.test(statement))
22580
+ const afterImport = statement.slice("import".length).trimStart();
22581
+ if (afterImport.startsWith("'") || afterImport.startsWith('"')) {
22520
22582
  return `${HELPER_FN}(${JSON.stringify(key)});`;
22521
- const clause = /^import\s+([\s\S]*?)\s*from\s*['"]/.exec(statement)?.[1];
22522
- if (clause === undefined)
22583
+ }
22584
+ const fromAt = statement.lastIndexOf(" from ");
22585
+ if (!statement.startsWith("import") || fromAt < 0)
22523
22586
  throw new Error(`cannot rewrite: ${statement}`);
22524
22587
  const lines = [take];
22525
- let rest = clause.trim();
22526
- const braces = /\{[^}]*\}/.exec(rest)?.[0];
22527
- if (braces) {
22588
+ const [braces, afterBraces] = takeBraces(statement.slice("import".length, fromAt).trim());
22589
+ if (braces)
22528
22590
  lines.push(`const ${pattern(braces)} = ${tmp};`);
22529
- rest = rest.replace(braces, "");
22530
- }
22531
- const ns = /\*\s+as\s+(\w+)/.exec(rest)?.[1];
22532
- if (ns) {
22591
+ const [ns, afterNs] = takeNamespace(afterBraces);
22592
+ if (ns)
22533
22593
  lines.push(`const ${ns} = ${tmp};`);
22534
- rest = rest.replace(/\*\s+as\s+\w+/, "");
22535
- }
22536
- const def = rest.replace(/,/g, "").trim();
22594
+ const def = afterNs.replaceAll(",", "").trim();
22537
22595
  if (def)
22538
22596
  lines.push(`const ${def} = ${tmp}.default;`);
22539
22597
  return lines.join(" ");
22540
22598
  }
22541
22599
  function rewriteReexport(statement, key, tmp) {
22542
22600
  const take = `const ${tmp} = ${HELPER_FN}(${JSON.stringify(key)});`;
22543
- const braces = /\{[^}]*\}/.exec(statement)?.[0];
22601
+ const [braces] = takeBraces(statement);
22544
22602
  if (!braces) {
22545
22603
  throw new Error(`\`export * from '${key}'\` is not supported for a package the host provides`);
22546
22604
  }
22547
- const fields = braces.slice(1, -1).split(",").map((s) => s.trim()).filter(Boolean).map((s) => {
22548
- const [name, alias] = s.split(/\s+as\s+/);
22549
- return `export const ${alias ?? name} = ${tmp}.${name};`;
22550
- });
22605
+ const fields = fieldsOf(braces).map(([name, alias]) => `export const ${alias ?? name} = ${tmp}.${name};`);
22551
22606
  return [take, ...fields].join(" ");
22552
22607
  }
22553
22608
  function kromaRemote(options) {
@@ -22638,16 +22693,17 @@ ${entry2.code}`;
22638
22693
  };
22639
22694
  return [manifest, shared];
22640
22695
  }
22641
- var HELPER = "virtual:kroma-shared", RESOLVED_HELPER, HELPER_FN = "__kroma_shared", OPTIONS_ONLY_CALL, LINK_STYLES, SCRIPT;
22696
+ var HELPER = "virtual:kroma-shared", RESOLVED_HELPER, HELPER_FN = "__kroma_shared", OPTIONS_ONLY_CALL, STYLES_HREF, LINK_STYLES, SCRIPT;
22642
22697
  var init_remote_plugin = __esm(() => {
22643
22698
  init_shared();
22644
22699
  init_lexer();
22645
22700
  init_magic_string_es();
22646
22701
  RESOLVED_HELPER = `\x00${HELPER}`;
22647
22702
  OPTIONS_ONLY_CALL = /\bdefineModule\s*\(\s*\{/;
22703
+ STYLES_HREF = JSON.stringify(`./${REMOTE_STYLES}`);
22648
22704
  LINK_STYLES = [
22649
22705
  "(function () {",
22650
- ` var href = new URL(${JSON.stringify(`./${REMOTE_STYLES}`)}, import.meta.url).href;`,
22706
+ ` var href = new URL(${STYLES_HREF}, import.meta.url).href;`,
22651
22707
  ` if (document.querySelector('link[href="' + href + '"]')) return;`,
22652
22708
  " var link = document.createElement('link');",
22653
22709
  " link.rel = 'stylesheet';",
@@ -22707,6 +22763,922 @@ var init_build2 = __esm(() => {
22707
22763
  init_remote_plugin();
22708
22764
  });
22709
22765
 
22766
+ // ../../node_modules/.bun/smol-toml@1.8.0/node_modules/smol-toml/dist/date.js
22767
+ var DATE_TIME_RE, TomlDate;
22768
+ var init_date = __esm(() => {
22769
+ /*!
22770
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
22771
+ * SPDX-License-Identifier: BSD-3-Clause
22772
+ *
22773
+ * Redistribution and use in source and binary forms, with or without
22774
+ * modification, are permitted provided that the following conditions are met:
22775
+ *
22776
+ * 1. Redistributions of source code must retain the above copyright notice, this
22777
+ * list of conditions and the following disclaimer.
22778
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
22779
+ * this list of conditions and the following disclaimer in the
22780
+ * documentation and/or other materials provided with the distribution.
22781
+ * 3. Neither the name of the copyright holder nor the names of its contributors
22782
+ * may be used to endorse or promote products derived from this software without
22783
+ * specific prior written permission.
22784
+ *
22785
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22786
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22787
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22788
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22789
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22790
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22791
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22792
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22793
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22794
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22795
+ */
22796
+ DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
22797
+ TomlDate = class TomlDate extends Date {
22798
+ #hasDate = false;
22799
+ #hasTime = false;
22800
+ #offset = null;
22801
+ constructor(date5) {
22802
+ let hasDate = true;
22803
+ let hasTime = true;
22804
+ let offset = "Z";
22805
+ if (typeof date5 === "string") {
22806
+ let match = date5.match(DATE_TIME_RE);
22807
+ if (match) {
22808
+ if (!match[1]) {
22809
+ hasDate = false;
22810
+ date5 = `0000-01-01T${date5}`;
22811
+ }
22812
+ hasTime = !!match[2];
22813
+ hasTime && date5[10] === " " && (date5 = date5.replace(" ", "T"));
22814
+ if (match[2] && +match[2] > 23) {
22815
+ date5 = "";
22816
+ } else {
22817
+ offset = match[3] || null;
22818
+ date5 = date5.toUpperCase();
22819
+ if (!offset && hasTime)
22820
+ date5 += "Z";
22821
+ }
22822
+ } else {
22823
+ date5 = "";
22824
+ }
22825
+ }
22826
+ super(date5);
22827
+ if (!isNaN(this.getTime())) {
22828
+ this.#hasDate = hasDate;
22829
+ this.#hasTime = hasTime;
22830
+ this.#offset = offset;
22831
+ }
22832
+ }
22833
+ isDateTime() {
22834
+ return this.#hasDate && this.#hasTime;
22835
+ }
22836
+ isLocal() {
22837
+ return !this.#hasDate || !this.#hasTime || !this.#offset;
22838
+ }
22839
+ isDate() {
22840
+ return this.#hasDate && !this.#hasTime;
22841
+ }
22842
+ isTime() {
22843
+ return this.#hasTime && !this.#hasDate;
22844
+ }
22845
+ isValid() {
22846
+ return this.#hasDate || this.#hasTime;
22847
+ }
22848
+ toISOString() {
22849
+ let iso = super.toISOString();
22850
+ if (this.isDate())
22851
+ return iso.slice(0, 10);
22852
+ if (this.isTime())
22853
+ return iso.slice(11, 23);
22854
+ if (this.#offset === null)
22855
+ return iso.slice(0, -1);
22856
+ if (this.#offset === "Z")
22857
+ return iso;
22858
+ let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
22859
+ offset = this.#offset[0] === "-" ? offset : -offset;
22860
+ let offsetDate = new Date(this.getTime() - offset * 60000);
22861
+ return offsetDate.toISOString().slice(0, -1) + this.#offset;
22862
+ }
22863
+ static wrapAsOffsetDateTime(jsDate, offset = "Z") {
22864
+ let date5 = new TomlDate(jsDate);
22865
+ date5.#offset = offset;
22866
+ return date5;
22867
+ }
22868
+ static wrapAsLocalDateTime(jsDate) {
22869
+ let date5 = new TomlDate(jsDate);
22870
+ date5.#offset = null;
22871
+ return date5;
22872
+ }
22873
+ static wrapAsLocalDate(jsDate) {
22874
+ let date5 = new TomlDate(jsDate);
22875
+ date5.#hasTime = false;
22876
+ date5.#offset = null;
22877
+ return date5;
22878
+ }
22879
+ static wrapAsLocalTime(jsDate) {
22880
+ let date5 = new TomlDate(jsDate);
22881
+ date5.#hasDate = false;
22882
+ date5.#offset = null;
22883
+ return date5;
22884
+ }
22885
+ };
22886
+ });
22887
+
22888
+ // ../../node_modules/.bun/smol-toml@1.8.0/node_modules/smol-toml/dist/error.js
22889
+ function getLineColFromPtr(string4, ptr) {
22890
+ let lines = string4.slice(0, ptr).split(/\r\n|\n|\r/g);
22891
+ return [lines.length, lines.pop().length + 1];
22892
+ }
22893
+ function makeCodeBlock(string4, line, column) {
22894
+ let lines = string4.split(/\r\n|\n|\r/g);
22895
+ let codeblock = "";
22896
+ let numberLen = (Math.log10(line + 1) | 0) + 1;
22897
+ for (let i2 = line - 1;i2 <= line + 1; i2++) {
22898
+ let l2 = lines[i2 - 1];
22899
+ if (!l2)
22900
+ continue;
22901
+ codeblock += i2.toString().padEnd(numberLen, " ");
22902
+ codeblock += ": ";
22903
+ codeblock += l2;
22904
+ codeblock += `
22905
+ `;
22906
+ if (i2 === line) {
22907
+ codeblock += " ".repeat(numberLen + column + 2);
22908
+ codeblock += `^
22909
+ `;
22910
+ }
22911
+ }
22912
+ return codeblock;
22913
+ }
22914
+ var TomlError;
22915
+ var init_error = __esm(() => {
22916
+ /*!
22917
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
22918
+ * SPDX-License-Identifier: BSD-3-Clause
22919
+ *
22920
+ * Redistribution and use in source and binary forms, with or without
22921
+ * modification, are permitted provided that the following conditions are met:
22922
+ *
22923
+ * 1. Redistributions of source code must retain the above copyright notice, this
22924
+ * list of conditions and the following disclaimer.
22925
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
22926
+ * this list of conditions and the following disclaimer in the
22927
+ * documentation and/or other materials provided with the distribution.
22928
+ * 3. Neither the name of the copyright holder nor the names of its contributors
22929
+ * may be used to endorse or promote products derived from this software without
22930
+ * specific prior written permission.
22931
+ *
22932
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22933
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22934
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22935
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22936
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22937
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22938
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22939
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22940
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22941
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22942
+ */
22943
+ TomlError = class TomlError extends Error {
22944
+ line;
22945
+ column;
22946
+ codeblock;
22947
+ constructor(message, options) {
22948
+ const [line, column] = getLineColFromPtr(options.toml, options.ptr);
22949
+ const codeblock = makeCodeBlock(options.toml, line, column);
22950
+ super(`Invalid TOML document: ${message}
22951
+
22952
+ ${codeblock}`, options);
22953
+ this.line = line;
22954
+ this.column = column;
22955
+ this.codeblock = codeblock;
22956
+ }
22957
+ };
22958
+ });
22959
+
22960
+ // ../../node_modules/.bun/smol-toml@1.8.0/node_modules/smol-toml/dist/util.js
22961
+ function indexOfNewline(str, start = 0) {
22962
+ let idx = str.indexOf(`
22963
+ `, start);
22964
+ if (str.charCodeAt(idx - 1) === 13)
22965
+ idx--;
22966
+ return idx;
22967
+ }
22968
+ function skipComment(ctx) {
22969
+ for (;ctx.p < ctx.s.length; ctx.p++) {
22970
+ let c2 = ctx.s.charCodeAt(ctx.p);
22971
+ if (c2 === 10)
22972
+ break;
22973
+ if (c2 === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) {
22974
+ ctx.p++;
22975
+ break;
22976
+ }
22977
+ if (c2 < 32 && c2 !== 9 || c2 === 127) {
22978
+ throw new TomlError("control characters are not allowed in comments", {
22979
+ toml: ctx.s,
22980
+ ptr: ctx.p
22981
+ });
22982
+ }
22983
+ }
22984
+ }
22985
+ function skipVoid(ctx, banNewLines, banComments) {
22986
+ let c2;
22987
+ while (true) {
22988
+ while ((c2 = ctx.s.charCodeAt(ctx.p)) === 32 || c2 === 9 || !banNewLines && (c2 === 10 || c2 === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10))
22989
+ ctx.p++;
22990
+ if (banComments || c2 !== 35)
22991
+ break;
22992
+ skipComment(ctx);
22993
+ }
22994
+ }
22995
+ function skipUntil(ctx, sep, end) {
22996
+ let ptr = ctx.p;
22997
+ if (!end) {
22998
+ ptr = indexOfNewline(ctx.s, ptr);
22999
+ ctx.p = ptr < 0 ? ctx.s.length : ptr;
23000
+ return;
23001
+ }
23002
+ for (;ctx.p < ctx.s.length; ctx.p++) {
23003
+ let c2 = ctx.s.charCodeAt(ctx.p);
23004
+ if (c2 === 35) {
23005
+ skipComment(ctx);
23006
+ } else if (c2 === end || c2 === sep) {
23007
+ return;
23008
+ }
23009
+ }
23010
+ throw new TomlError("cannot find end of structure", {
23011
+ toml: ctx.s,
23012
+ ptr
23013
+ });
23014
+ }
23015
+ var init_util2 = __esm(() => {
23016
+ init_error();
23017
+ /*!
23018
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
23019
+ * SPDX-License-Identifier: BSD-3-Clause
23020
+ *
23021
+ * Redistribution and use in source and binary forms, with or without
23022
+ * modification, are permitted provided that the following conditions are met:
23023
+ *
23024
+ * 1. Redistributions of source code must retain the above copyright notice, this
23025
+ * list of conditions and the following disclaimer.
23026
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
23027
+ * this list of conditions and the following disclaimer in the
23028
+ * documentation and/or other materials provided with the distribution.
23029
+ * 3. Neither the name of the copyright holder nor the names of its contributors
23030
+ * may be used to endorse or promote products derived from this software without
23031
+ * specific prior written permission.
23032
+ *
23033
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23034
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23035
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23036
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23037
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23038
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23039
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23040
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23041
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23042
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23043
+ */
23044
+ });
23045
+
23046
+ // ../../node_modules/.bun/smol-toml@1.8.0/node_modules/smol-toml/dist/primitive.js
23047
+ function parseString(ctx) {
23048
+ let start = ctx.p;
23049
+ let c2 = ctx.s.charCodeAt(ctx.p++);
23050
+ let first = c2;
23051
+ let isLiteral = c2 === 39;
23052
+ let isMultiline = c2 === ctx.s.charCodeAt(ctx.p) && c2 === ctx.s.charCodeAt(ctx.p + 1);
23053
+ if (isMultiline) {
23054
+ if ((c2 = ctx.s.charCodeAt(ctx.p += 2)) === 10)
23055
+ ctx.p++;
23056
+ else if (c2 === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)
23057
+ ctx.p += 2;
23058
+ }
23059
+ let parsed = "";
23060
+ let sliceStart = ctx.p;
23061
+ let state = 0;
23062
+ for (;ctx.p < ctx.s.length; ctx.p++) {
23063
+ c2 = ctx.s.charCodeAt(ctx.p);
23064
+ if (isMultiline && (c2 === 10 || c2 === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)) {
23065
+ state = state && 3;
23066
+ } else if (c2 < 32 && c2 !== 9 || c2 === 127) {
23067
+ throw new TomlError("control characters are not allowed in strings", {
23068
+ toml: ctx.s,
23069
+ ptr: ctx.p
23070
+ });
23071
+ } else if ((!state || state === 3) && c2 === first && (!isMultiline || ctx.s.charCodeAt(ctx.p + 1) === first && ctx.s.charCodeAt(ctx.p + 2) === first)) {
23072
+ if (isMultiline) {
23073
+ if (ctx.s.charCodeAt(ctx.p + 3) === first)
23074
+ ctx.p++;
23075
+ if (ctx.s.charCodeAt(ctx.p + 3) === first)
23076
+ ctx.p++;
23077
+ }
23078
+ if (!state)
23079
+ parsed += ctx.s.slice(sliceStart, ctx.p);
23080
+ ctx.p += isMultiline ? 3 : 1;
23081
+ return parsed;
23082
+ } else if (!state) {
23083
+ if (!isLiteral && c2 === 92) {
23084
+ parsed += ctx.s.slice(sliceStart, sliceStart = ctx.p);
23085
+ state = 1;
23086
+ }
23087
+ } else if (state === 1) {
23088
+ if (c2 === 120 || c2 === 117 || c2 === 85) {
23089
+ let value = 0;
23090
+ let len = c2 === 120 ? 2 : c2 === 117 ? 4 : 8;
23091
+ for (let j = 0;j < len; j++, ctx.p++) {
23092
+ let hex3 = ctx.s.charCodeAt(ctx.p + 1);
23093
+ let digit = hex3 >= 48 && hex3 <= 57 ? hex3 - 48 : hex3 >= 65 && hex3 <= 70 ? hex3 - 65 + 10 : hex3 >= 97 && hex3 <= 102 ? hex3 - 97 + 10 : -1;
23094
+ if (digit < 0)
23095
+ throw new TomlError("invalid non-hex character in unicode escape", { toml: ctx.s, ptr: ctx.p + 1 });
23096
+ value = value << 4 | digit;
23097
+ }
23098
+ if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) {
23099
+ throw new TomlError("invalid unicode escape", { toml: ctx.s, ptr: ctx.p });
23100
+ }
23101
+ parsed += String.fromCodePoint(value);
23102
+ sliceStart = ctx.p + 1;
23103
+ state = 0;
23104
+ } else if (c2 === 32 || c2 === 9) {
23105
+ state = 2;
23106
+ } else {
23107
+ if (c2 === 98)
23108
+ parsed += "\b";
23109
+ else if (c2 === 116)
23110
+ parsed += "\t";
23111
+ else if (c2 === 110)
23112
+ parsed += `
23113
+ `;
23114
+ else if (c2 === 102)
23115
+ parsed += "\f";
23116
+ else if (c2 === 114)
23117
+ parsed += "\r";
23118
+ else if (c2 === 101)
23119
+ parsed += "\x1B";
23120
+ else if (c2 === 34)
23121
+ parsed += '"';
23122
+ else if (c2 === 92)
23123
+ parsed += "\\";
23124
+ else
23125
+ throw new TomlError("unrecognized escape sequence", { toml: ctx.s, ptr: ctx.p });
23126
+ sliceStart = ctx.p + 1;
23127
+ state = 0;
23128
+ }
23129
+ } else if (c2 !== 32 && c2 !== 9) {
23130
+ if (state === 2) {
23131
+ throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
23132
+ toml: ctx.s,
23133
+ ptr: sliceStart
23134
+ });
23135
+ }
23136
+ state = !isLiteral && c2 === 92 ? 1 : 0;
23137
+ sliceStart = ctx.p;
23138
+ }
23139
+ }
23140
+ throw new TomlError("unfinished string", { toml: ctx.s, ptr: start });
23141
+ }
23142
+ function sliceAndTrimEndOf(ctx, start, end) {
23143
+ let value = ctx.s.slice(start, end);
23144
+ let commentIdx = value.indexOf("#");
23145
+ if (commentIdx > 0) {
23146
+ skipComment({ s: value, p: commentIdx, d: 0 });
23147
+ value = value.slice(0, commentIdx);
23148
+ }
23149
+ return value.trimEnd();
23150
+ }
23151
+ function parseValue(ctx, integersAsBigInt, end) {
23152
+ let ptr = ctx.p;
23153
+ let err = { toml: ctx.s, ptr };
23154
+ skipUntil(ctx, 44, end);
23155
+ let value = sliceAndTrimEndOf(ctx, ptr, ctx.p);
23156
+ if (!value)
23157
+ throw new TomlError("incomplete declaration: value expected", err);
23158
+ if (value === "-inf")
23159
+ return -Infinity;
23160
+ if (value === "inf" || value === "+inf")
23161
+ return Infinity;
23162
+ if (value === "nan" || value === "+nan" || value === "-nan")
23163
+ return NaN;
23164
+ if (value === "-0")
23165
+ return integersAsBigInt ? 0n : 0;
23166
+ let isInt = INT_REGEX.test(value);
23167
+ if (isInt || FLOAT_REGEX.test(value)) {
23168
+ if (LEADING_ZERO.test(value)) {
23169
+ throw new TomlError("leading zeroes are not allowed", err);
23170
+ }
23171
+ value = value.replace(/_/g, "");
23172
+ let numeric = +value;
23173
+ if (isNaN(numeric)) {
23174
+ throw new TomlError("invalid number", err);
23175
+ }
23176
+ if (isInt) {
23177
+ if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
23178
+ throw new TomlError("integer value cannot be represented losslessly", err);
23179
+ }
23180
+ if (isInt || integersAsBigInt === true)
23181
+ numeric = BigInt(value);
23182
+ }
23183
+ return numeric;
23184
+ }
23185
+ const date5 = new TomlDate(value);
23186
+ if (!date5.isValid())
23187
+ throw new TomlError("invalid value", err);
23188
+ return date5;
23189
+ }
23190
+ var INT_REGEX, FLOAT_REGEX, LEADING_ZERO;
23191
+ var init_primitive = __esm(() => {
23192
+ init_date();
23193
+ init_error();
23194
+ init_util2();
23195
+ /*!
23196
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
23197
+ * SPDX-License-Identifier: BSD-3-Clause
23198
+ *
23199
+ * Redistribution and use in source and binary forms, with or without
23200
+ * modification, are permitted provided that the following conditions are met:
23201
+ *
23202
+ * 1. Redistributions of source code must retain the above copyright notice, this
23203
+ * list of conditions and the following disclaimer.
23204
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
23205
+ * this list of conditions and the following disclaimer in the
23206
+ * documentation and/or other materials provided with the distribution.
23207
+ * 3. Neither the name of the copyright holder nor the names of its contributors
23208
+ * may be used to endorse or promote products derived from this software without
23209
+ * specific prior written permission.
23210
+ *
23211
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23212
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23213
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23214
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23215
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23216
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23217
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23218
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23219
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23220
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23221
+ */
23222
+ INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
23223
+ FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
23224
+ LEADING_ZERO = /^[+-]?0[0-9_]/;
23225
+ });
23226
+
23227
+ // ../../node_modules/.bun/smol-toml@1.8.0/node_modules/smol-toml/dist/extract.js
23228
+ function extractValue(ctx, end, integersAsBigInt) {
23229
+ let ptr = ctx.p;
23230
+ let c2 = ctx.s.charCodeAt(ptr);
23231
+ if (c2 === 91 || c2 === 123) {
23232
+ if (!ctx.d--) {
23233
+ throw new TomlError("document contains excessively nested structures. aborting.", {
23234
+ toml: ctx.s,
23235
+ ptr
23236
+ });
23237
+ }
23238
+ let value = c2 === 91 ? parseArray(ctx, integersAsBigInt) : parseInlineTable(ctx, integersAsBigInt);
23239
+ ctx.d++;
23240
+ return value;
23241
+ }
23242
+ if (c2 === 34 || c2 === 39) {
23243
+ return parseString(ctx);
23244
+ }
23245
+ if (c2 === 116) {
23246
+ if (ctx.s.charCodeAt(++ctx.p) !== 114 || ctx.s.charCodeAt(++ctx.p) !== 117 || ctx.s.charCodeAt(++ctx.p) !== 101)
23247
+ throw new TomlError("invalid value", { toml: ctx.s, ptr });
23248
+ ctx.p++;
23249
+ return true;
23250
+ }
23251
+ if (c2 === 102) {
23252
+ if (ctx.s.charCodeAt(++ctx.p) !== 97 || ctx.s.charCodeAt(++ctx.p) !== 108 || ctx.s.charCodeAt(++ctx.p) !== 115 || ctx.s.charCodeAt(++ctx.p) !== 101)
23253
+ throw new TomlError("invalid value", { toml: ctx.s, ptr });
23254
+ ctx.p++;
23255
+ return false;
23256
+ }
23257
+ return parseValue(ctx, integersAsBigInt, end);
23258
+ }
23259
+ var init_extract = __esm(() => {
23260
+ init_primitive();
23261
+ init_struct();
23262
+ init_error();
23263
+ /*!
23264
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
23265
+ * SPDX-License-Identifier: BSD-3-Clause
23266
+ *
23267
+ * Redistribution and use in source and binary forms, with or without
23268
+ * modification, are permitted provided that the following conditions are met:
23269
+ *
23270
+ * 1. Redistributions of source code must retain the above copyright notice, this
23271
+ * list of conditions and the following disclaimer.
23272
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
23273
+ * this list of conditions and the following disclaimer in the
23274
+ * documentation and/or other materials provided with the distribution.
23275
+ * 3. Neither the name of the copyright holder nor the names of its contributors
23276
+ * may be used to endorse or promote products derived from this software without
23277
+ * specific prior written permission.
23278
+ *
23279
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23280
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23281
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23282
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23283
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23284
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23285
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23286
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23287
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23288
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23289
+ */
23290
+ });
23291
+
23292
+ // ../../node_modules/.bun/smol-toml@1.8.0/node_modules/smol-toml/dist/struct.js
23293
+ function parseKey(ctx, end = "=") {
23294
+ let start = ctx.p;
23295
+ let dot = start - 1;
23296
+ let parsed = [];
23297
+ let endPtr = ctx.s.indexOf(end, start);
23298
+ if (endPtr < 0) {
23299
+ throw new TomlError("incomplete key-value: cannot find end of key", {
23300
+ toml: ctx.s,
23301
+ ptr: start
23302
+ });
23303
+ }
23304
+ do {
23305
+ let c2 = ctx.s.charCodeAt(ctx.p = ++dot);
23306
+ if (c2 !== 32 && c2 !== 9) {
23307
+ if (c2 === 34 || c2 === 39) {
23308
+ if (c2 === ctx.s.charCodeAt(ctx.p + 1) && c2 === ctx.s.charCodeAt(ctx.p + 2)) {
23309
+ throw new TomlError("multiline strings are not allowed in keys", {
23310
+ toml: ctx.s,
23311
+ ptr: ctx.p
23312
+ });
23313
+ }
23314
+ let part = parseString(ctx);
23315
+ dot = ctx.s.indexOf(".", ctx.p);
23316
+ let strEnd = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
23317
+ let newLine = indexOfNewline(strEnd);
23318
+ if (newLine > -1) {
23319
+ throw new TomlError("newlines are not allowed in keys", {
23320
+ toml: ctx.s,
23321
+ ptr: newLine
23322
+ });
23323
+ }
23324
+ if (strEnd.trimStart()) {
23325
+ throw new TomlError("found extra tokens after the string part", {
23326
+ toml: ctx.s,
23327
+ ptr: ctx.p
23328
+ });
23329
+ }
23330
+ if (endPtr < ctx.p) {
23331
+ endPtr = ctx.s.indexOf(end, ctx.p);
23332
+ if (endPtr < 0) {
23333
+ throw new TomlError("incomplete key-value: cannot find end of key", {
23334
+ toml: ctx.s,
23335
+ ptr: start
23336
+ });
23337
+ }
23338
+ }
23339
+ parsed.push(part);
23340
+ } else {
23341
+ dot = ctx.s.indexOf(".", ctx.p);
23342
+ let part = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
23343
+ if (!KEY_PART_RE.test(part)) {
23344
+ throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
23345
+ toml: ctx.s,
23346
+ ptr: ctx.p
23347
+ });
23348
+ }
23349
+ parsed.push(part.trimEnd());
23350
+ }
23351
+ }
23352
+ } while (dot + 1 && dot < endPtr);
23353
+ ctx.p = endPtr + 1;
23354
+ skipVoid(ctx, true, true);
23355
+ return parsed;
23356
+ }
23357
+ function parseInlineTable(ctx, integersAsBigInt) {
23358
+ let res = {};
23359
+ let seen = new Set;
23360
+ let c2;
23361
+ ctx.p++;
23362
+ while (ctx.p < ctx.s.length) {
23363
+ skipVoid(ctx);
23364
+ if ((c2 = ctx.s.charCodeAt(ctx.p)) === 125) {
23365
+ ctx.p++;
23366
+ return res;
23367
+ }
23368
+ let k;
23369
+ let t2 = res;
23370
+ let hasOwn = false;
23371
+ let p = ctx.p;
23372
+ let key = parseKey(ctx);
23373
+ for (let i2 = 0;i2 < key.length; i2++) {
23374
+ if (i2)
23375
+ t2 = hasOwn ? t2[k] : t2[k] = {};
23376
+ k = key[i2];
23377
+ if ((hasOwn = Object.hasOwn(t2, k)) && (typeof t2[k] !== "object" || seen.has(t2[k]))) {
23378
+ throw new TomlError("trying to redefine an already defined value", {
23379
+ toml: ctx.s,
23380
+ ptr: p
23381
+ });
23382
+ }
23383
+ if (!hasOwn && k === "__proto__") {
23384
+ Object.defineProperty(t2, k, { enumerable: true, configurable: true, writable: true });
23385
+ }
23386
+ }
23387
+ if (hasOwn) {
23388
+ throw new TomlError("trying to redefine an already defined value", {
23389
+ toml: ctx.s,
23390
+ ptr: ctx.p
23391
+ });
23392
+ }
23393
+ let value = extractValue(ctx, 125, integersAsBigInt);
23394
+ seen.add(t2[k] = value);
23395
+ skipVoid(ctx);
23396
+ if ((c2 = ctx.s.charCodeAt(ctx.p++)) === 125) {
23397
+ return res;
23398
+ }
23399
+ if (c2 !== 44) {
23400
+ throw new TomlError("expected comma or end of structure", { toml: ctx.s, ptr: ctx.p - 1 });
23401
+ }
23402
+ }
23403
+ throw new TomlError("unfinished table encountered", {
23404
+ toml: ctx.s,
23405
+ ptr: ctx.p
23406
+ });
23407
+ }
23408
+ function parseArray(ctx, integersAsBigInt) {
23409
+ let res = [];
23410
+ let c2;
23411
+ ctx.p++;
23412
+ while (ctx.p < ctx.s.length) {
23413
+ skipVoid(ctx);
23414
+ if ((c2 = ctx.s.charCodeAt(ctx.p)) === 93) {
23415
+ ctx.p++;
23416
+ return res;
23417
+ }
23418
+ res.push(extractValue(ctx, 93, integersAsBigInt));
23419
+ skipVoid(ctx);
23420
+ if ((c2 = ctx.s.charCodeAt(ctx.p++)) === 93) {
23421
+ return res;
23422
+ }
23423
+ if (c2 !== 44) {
23424
+ throw new TomlError("expected comma or end of structure", { toml: ctx.s, ptr: ctx.p - 1 });
23425
+ }
23426
+ }
23427
+ throw new TomlError("unfinished array encountered", {
23428
+ toml: ctx.s,
23429
+ ptr: ctx.p
23430
+ });
23431
+ }
23432
+ var KEY_PART_RE;
23433
+ var init_struct = __esm(() => {
23434
+ init_primitive();
23435
+ init_extract();
23436
+ init_util2();
23437
+ init_error();
23438
+ /*!
23439
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
23440
+ * SPDX-License-Identifier: BSD-3-Clause
23441
+ *
23442
+ * Redistribution and use in source and binary forms, with or without
23443
+ * modification, are permitted provided that the following conditions are met:
23444
+ *
23445
+ * 1. Redistributions of source code must retain the above copyright notice, this
23446
+ * list of conditions and the following disclaimer.
23447
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
23448
+ * this list of conditions and the following disclaimer in the
23449
+ * documentation and/or other materials provided with the distribution.
23450
+ * 3. Neither the name of the copyright holder nor the names of its contributors
23451
+ * may be used to endorse or promote products derived from this software without
23452
+ * specific prior written permission.
23453
+ *
23454
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23455
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23456
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23457
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23458
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23459
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23460
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23461
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23462
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23463
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23464
+ */
23465
+ KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
23466
+ });
23467
+
23468
+ // ../../node_modules/.bun/smol-toml@1.8.0/node_modules/smol-toml/dist/parse.js
23469
+ function peekTable(key, table, meta3, type) {
23470
+ let t2 = table;
23471
+ let m = meta3;
23472
+ let k;
23473
+ let hasOwn = false;
23474
+ let state;
23475
+ for (let i2 = 0;i2 < key.length; i2++) {
23476
+ if (i2) {
23477
+ t2 = hasOwn ? t2[k] : t2[k] = {};
23478
+ m = (state = m[k]).c;
23479
+ if (type === 0 && (state.t === 1 || state.t === 2)) {
23480
+ return null;
23481
+ }
23482
+ if (state.t === 2) {
23483
+ let l2 = t2.length - 1;
23484
+ t2 = t2[l2];
23485
+ m = m[l2].c;
23486
+ }
23487
+ }
23488
+ k = key[i2];
23489
+ if ((hasOwn = Object.hasOwn(t2, k)) && m[k]?.t === 0 && m[k]?.d) {
23490
+ return null;
23491
+ }
23492
+ if (!hasOwn) {
23493
+ if (k === "__proto__") {
23494
+ Object.defineProperty(t2, k, { enumerable: true, configurable: true, writable: true });
23495
+ Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
23496
+ }
23497
+ m[k] = {
23498
+ t: i2 < key.length - 1 && type === 2 ? 3 : type,
23499
+ d: false,
23500
+ i: 0,
23501
+ c: {}
23502
+ };
23503
+ }
23504
+ }
23505
+ state = m[k];
23506
+ if (state.t !== type && !(type === 1 && state.t === 3)) {
23507
+ return null;
23508
+ }
23509
+ if (type === 2) {
23510
+ if (!state.d) {
23511
+ state.d = true;
23512
+ t2[k] = [];
23513
+ }
23514
+ t2[k].push(t2 = {});
23515
+ state.c[state.i++] = state = { t: 1, d: false, i: 0, c: {} };
23516
+ }
23517
+ if (state.d) {
23518
+ return null;
23519
+ }
23520
+ state.d = true;
23521
+ if (type === 1) {
23522
+ t2 = hasOwn ? t2[k] : t2[k] = {};
23523
+ } else if (type === 0 && hasOwn) {
23524
+ return null;
23525
+ }
23526
+ return [k, t2, state.c];
23527
+ }
23528
+ function parse7(toml, { maxDepth = 1000, integersAsBigInt } = {}) {
23529
+ let ctx = { s: toml, p: 0, d: maxDepth };
23530
+ let res = {};
23531
+ let meta3 = {};
23532
+ let tmp;
23533
+ let tbl = res;
23534
+ let m = meta3;
23535
+ skipVoid(ctx);
23536
+ while (ctx.p < toml.length) {
23537
+ if (toml.charCodeAt(ctx.p) === 91) {
23538
+ let isTableArray = toml.charCodeAt(++ctx.p) === 91;
23539
+ tmp = ctx.p += +isTableArray;
23540
+ let k = parseKey(ctx, "]");
23541
+ if (isTableArray) {
23542
+ if (toml.charCodeAt(ctx.p - 1) !== 93) {
23543
+ throw new TomlError("expected end of table declaration", {
23544
+ toml,
23545
+ ptr: ctx.p - 1
23546
+ });
23547
+ }
23548
+ ctx.p++;
23549
+ }
23550
+ let p = peekTable(k, res, meta3, isTableArray ? 2 : 1);
23551
+ if (!p) {
23552
+ throw new TomlError("trying to redefine an already defined table or value", {
23553
+ toml,
23554
+ ptr: tmp
23555
+ });
23556
+ }
23557
+ m = p[2];
23558
+ tbl = p[1];
23559
+ } else {
23560
+ tmp = ctx.p;
23561
+ let k = parseKey(ctx);
23562
+ let p = peekTable(k, tbl, m, 0);
23563
+ if (!p) {
23564
+ throw new TomlError("trying to redefine an already defined table or value", {
23565
+ toml,
23566
+ ptr: tmp
23567
+ });
23568
+ }
23569
+ p[1][p[0]] = extractValue(ctx, undefined, integersAsBigInt);
23570
+ }
23571
+ skipVoid(ctx, true);
23572
+ if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 10 && tmp !== 13) {
23573
+ throw new TomlError("each key-value declaration must be followed by an end-of-line", {
23574
+ toml,
23575
+ ptr: ctx.p
23576
+ });
23577
+ }
23578
+ skipVoid(ctx);
23579
+ }
23580
+ return res;
23581
+ }
23582
+ var init_parse3 = __esm(() => {
23583
+ init_struct();
23584
+ init_extract();
23585
+ init_util2();
23586
+ init_error();
23587
+ /*!
23588
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
23589
+ * SPDX-License-Identifier: BSD-3-Clause
23590
+ *
23591
+ * Redistribution and use in source and binary forms, with or without
23592
+ * modification, are permitted provided that the following conditions are met:
23593
+ *
23594
+ * 1. Redistributions of source code must retain the above copyright notice, this
23595
+ * list of conditions and the following disclaimer.
23596
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
23597
+ * this list of conditions and the following disclaimer in the
23598
+ * documentation and/or other materials provided with the distribution.
23599
+ * 3. Neither the name of the copyright holder nor the names of its contributors
23600
+ * may be used to endorse or promote products derived from this software without
23601
+ * specific prior written permission.
23602
+ *
23603
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23604
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23605
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23606
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23607
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23608
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23609
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23610
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23611
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23612
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23613
+ */
23614
+ });
23615
+
23616
+ // ../../node_modules/.bun/smol-toml@1.8.0/node_modules/smol-toml/dist/stringify.js
23617
+ var init_stringify = __esm(() => {
23618
+ /*!
23619
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
23620
+ * SPDX-License-Identifier: BSD-3-Clause
23621
+ *
23622
+ * Redistribution and use in source and binary forms, with or without
23623
+ * modification, are permitted provided that the following conditions are met:
23624
+ *
23625
+ * 1. Redistributions of source code must retain the above copyright notice, this
23626
+ * list of conditions and the following disclaimer.
23627
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
23628
+ * this list of conditions and the following disclaimer in the
23629
+ * documentation and/or other materials provided with the distribution.
23630
+ * 3. Neither the name of the copyright holder nor the names of its contributors
23631
+ * may be used to endorse or promote products derived from this software without
23632
+ * specific prior written permission.
23633
+ *
23634
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23635
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23636
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23637
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23638
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23639
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23640
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23641
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23642
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23643
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23644
+ */
23645
+ });
23646
+
23647
+ // ../../node_modules/.bun/smol-toml@1.8.0/node_modules/smol-toml/dist/index.js
23648
+ var init_dist5 = __esm(() => {
23649
+ init_parse3();
23650
+ init_stringify();
23651
+ init_date();
23652
+ init_error();
23653
+ /*!
23654
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
23655
+ * SPDX-License-Identifier: BSD-3-Clause
23656
+ *
23657
+ * Redistribution and use in source and binary forms, with or without
23658
+ * modification, are permitted provided that the following conditions are met:
23659
+ *
23660
+ * 1. Redistributions of source code must retain the above copyright notice, this
23661
+ * list of conditions and the following disclaimer.
23662
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
23663
+ * this list of conditions and the following disclaimer in the
23664
+ * documentation and/or other materials provided with the distribution.
23665
+ * 3. Neither the name of the copyright holder nor the names of its contributors
23666
+ * may be used to endorse or promote products derived from this software without
23667
+ * specific prior written permission.
23668
+ *
23669
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23670
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23671
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23672
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23673
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23674
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23675
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23676
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23677
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23678
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23679
+ */
23680
+ });
23681
+
22710
23682
  // src/project.ts
22711
23683
  import { existsSync as existsSync5, readdirSync as readdirSync4, readFileSync as readFileSync5, statSync as statSync2 } from "fs";
22712
23684
  import { isAbsolute, join as join8, resolve as resolve2 } from "path";
@@ -22715,7 +23687,7 @@ function readServer(dir) {
22715
23687
  const cargoPath = join8(serverDir, "Cargo.toml");
22716
23688
  if (!existsSync5(cargoPath))
22717
23689
  return null;
22718
- const cargo2 = CargoManifest.parse(Bun.TOML.parse(readFileSync5(cargoPath, "utf8")));
23690
+ const cargo2 = CargoManifest.parse(parse7(readFileSync5(cargoPath, "utf8")));
22719
23691
  return {
22720
23692
  dir: serverDir,
22721
23693
  crate: cargo2.package.name,
@@ -22728,7 +23700,10 @@ function readFrontend(dir) {
22728
23700
  return entry ? { dir: join8(dir, "ui"), entry } : null;
22729
23701
  }
22730
23702
  function issues(error61) {
22731
- return error61.issues.map((i2) => ` ${i2.path.length ? `${i2.path.join(".")}: ` : ""}${i2.message}`).join(`
23703
+ return error61.issues.map((i2) => {
23704
+ const at = i2.path.length ? `${i2.path.join(".")}: ` : "";
23705
+ return ` ${at}${i2.message}`;
23706
+ }).join(`
22732
23707
  `);
22733
23708
  }
22734
23709
  function openProject(dir) {
@@ -22771,6 +23746,7 @@ function findProjects(dirs, cwd = process.cwd()) {
22771
23746
  var AuthoredManifest, CargoManifest, UI_ENTRIES;
22772
23747
  var init_project = __esm(() => {
22773
23748
  init_src();
23749
+ init_dist5();
22774
23750
  init_zod();
22775
23751
  AuthoredManifest = Manifest.strict().refine((m) => m.schemaVersion === MODULE_SCHEMA_VERSION, {
22776
23752
  message: `schemaVersion must be ${MODULE_SCHEMA_VERSION}`
@@ -22786,7 +23762,7 @@ var init_project = __esm(() => {
22786
23762
  });
22787
23763
 
22788
23764
  // src/config.ts
22789
- import { existsSync as existsSync6, mkdirSync as mkdirSync4, readFileSync as readFileSync6, writeFileSync as writeFileSync4 } from "fs";
23765
+ import { chmodSync, existsSync as existsSync6, mkdirSync as mkdirSync4, readFileSync as readFileSync6, writeFileSync as writeFileSync4 } from "fs";
22790
23766
  import { homedir } from "os";
22791
23767
  import { dirname as dirname4, join as join9 } from "path";
22792
23768
  function configPath() {
@@ -22809,10 +23785,14 @@ function writeConfig(config2, path = configPath()) {
22809
23785
  mkdirSync4(dirname4(path), { recursive: true });
22810
23786
  writeFileSync4(path, `${JSON.stringify(config2, null, 2)}
22811
23787
  `, { mode: 384 });
23788
+ chmodSync(path, 384);
22812
23789
  }
22813
23790
  function normalizeServer(url2) {
22814
- const withScheme = /^https?:\/\//.test(url2) ? url2 : `http://${url2}`;
22815
- return withScheme.replace(/\/+$/, "");
23791
+ const withScheme = url2.startsWith("http://") || url2.startsWith("https://") ? url2 : `http://${url2}`;
23792
+ let end = withScheme.length;
23793
+ while (end > 0 && withScheme[end - 1] === "/")
23794
+ end -= 1;
23795
+ return withScheme.slice(0, end);
22816
23796
  }
22817
23797
  var Config;
22818
23798
  var init_config = __esm(() => {
@@ -22827,8 +23807,8 @@ var init_config = __esm(() => {
22827
23807
  import { readFileSync as readFileSync7 } from "fs";
22828
23808
  function resolveServer(options) {
22829
23809
  const config2 = readConfig();
22830
- const url2 = normalizeServer(options.server ?? process.env.KROMA_SERVER ?? config2.defaultServer ?? DEFAULT_SERVER);
22831
- const token = options.token ?? process.env.KROMA_TOKEN ?? config2.servers[url2]?.token;
23810
+ const url2 = normalizeServer(options.server || process.env.KROMA_SERVER || config2.defaultServer || DEFAULT_SERVER);
23811
+ const token = options.token || process.env.KROMA_TOKEN || config2.servers[url2]?.token;
22832
23812
  if (!token) {
22833
23813
  throw new Error(`no token for ${url2}: run \`kroma login ${url2}\`, or pass --token / set KROMA_TOKEN (an account with settings.manage)`);
22834
23814
  }
@@ -22942,7 +23922,8 @@ var init_build3 = __esm(() => {
22942
23922
  // src/commands/dev.ts
22943
23923
  var exports_dev = {};
22944
23924
  __export(exports_dev, {
22945
- devCommand: () => devCommand
23925
+ devCommand: () => devCommand,
23926
+ partOf: () => partOf
22946
23927
  });
22947
23928
  import { existsSync as existsSync7, watch } from "fs";
22948
23929
  import { join as join11, relative as relative4 } from "path";
@@ -23076,11 +24057,27 @@ var init_dev = __esm(() => {
23076
24057
  var exports_check = {};
23077
24058
  __export(exports_check, {
23078
24059
  checkCommand: () => checkCommand,
23079
- importProblems: () => importProblems
24060
+ importProblems: () => importProblems,
24061
+ specifierOf: () => specifierOf
23080
24062
  });
23081
24063
  import { existsSync as existsSync8, readdirSync as readdirSync5, readFileSync as readFileSync8 } from "fs";
23082
24064
  import { dirname as dirname5, join as join12, relative as relative5 } from "path";
23083
- var {$: $3 } = globalThis.Bun;
24065
+ function specifierOf(line) {
24066
+ const t2 = line.trim();
24067
+ if (!t2.startsWith("import") && !t2.startsWith("export"))
24068
+ return null;
24069
+ const end = Math.max(t2.lastIndexOf("'"), t2.lastIndexOf('"'));
24070
+ if (end < 0)
24071
+ return null;
24072
+ const quote = t2[end] ?? "'";
24073
+ const start = t2.lastIndexOf(quote, end - 1);
24074
+ if (start < 0)
24075
+ return null;
24076
+ const before = t2.slice(0, start).trimEnd();
24077
+ if (!before.endsWith(" from") && before !== "import")
24078
+ return null;
24079
+ return t2.slice(start + 1, end);
24080
+ }
23084
24081
  function sources(dir) {
23085
24082
  if (!existsSync8(dir))
23086
24083
  return [];
@@ -23089,8 +24086,11 @@ function sources(dir) {
23089
24086
  function importProblems(file2, code, projectDir) {
23090
24087
  const out = [];
23091
24088
  const label = relative5(projectDir, file2);
23092
- for (const m of code.matchAll(IMPORT)) {
23093
- const spec = m[1] ?? m[2] ?? "";
24089
+ for (const line of code.split(`
24090
+ `)) {
24091
+ const spec = specifierOf(line);
24092
+ if (spec === null)
24093
+ continue;
23094
24094
  if (spec.startsWith("#ui/")) {
23095
24095
  out.push(`${label}: '${spec}' is the kit's private alias; import from '@kroma/ui/kit'`);
23096
24096
  } else if (spec.startsWith(".")) {
@@ -23109,7 +24109,7 @@ async function checkTs(project) {
23109
24109
  const problems = sources(join12(project.ui.dir, "src")).flatMap((f) => importProblems(f, readFileSync8(f, "utf8"), project.dir));
23110
24110
  if (!tsconfigDir)
23111
24111
  return [...problems, `${project.manifest.id}: no tsconfig.json beside the frontend`];
23112
- const tsc = await $3`bun x tsc --noEmit -p ${tsconfigDir}`.cwd(tsconfigDir).nothrow();
24112
+ const tsc = await exec2("bun", ["x", "tsc", "--noEmit", "-p", tsconfigDir], { cwd: tsconfigDir });
23113
24113
  if (tsc.exitCode !== 0)
23114
24114
  problems.push(`${project.manifest.id}: tsc failed`);
23115
24115
  return problems;
@@ -23138,8 +24138,9 @@ ${style.bold(project.manifest.id)}`);
23138
24138
  }
23139
24139
  }
23140
24140
  if (problems.length > 0) {
24141
+ const count = `${problems.length} problem(s)`;
23141
24142
  console.error(`
23142
- ${style.red(`${problems.length} problem(s)`)}`);
24143
+ ${style.red(count)}`);
23143
24144
  for (const p of problems)
23144
24145
  console.error(` - ${p}`);
23145
24146
  return 1;
@@ -23148,12 +24149,11 @@ ${style.red(`${problems.length} problem(s)`)}`);
23148
24149
  ${style.green("every check passed")} (${projects.length} module(s))`);
23149
24150
  return 0;
23150
24151
  }
23151
- var IMPORT;
23152
24152
  var init_check = __esm(() => {
23153
24153
  init_cargo();
24154
+ init_exec();
23154
24155
  init_project();
23155
24156
  init_style();
23156
- IMPORT = /^\s*(?:import|export)\b[^'"]*?from\s*['"]([^'"]+)['"]|^\s*import\s*['"]([^'"]+)['"]/gm;
23157
24157
  });
23158
24158
 
23159
24159
  // src/commands/install.ts
@@ -23208,10 +24208,10 @@ async function ask2(label, given, secret) {
23208
24208
  return answer2;
23209
24209
  }
23210
24210
  async function loginCommand(options) {
23211
- const url2 = normalizeServer(options.server ?? process.env.KROMA_SERVER ?? DEFAULT_SERVER);
24211
+ const url2 = normalizeServer(options.server || process.env.KROMA_SERVER || DEFAULT_SERVER);
23212
24212
  intro(`sign in to ${url2}`);
23213
- const email3 = await ask2("email or username", options.email ?? process.env.KROMA_EMAIL, false);
23214
- const password2 = await ask2("password", options.password ?? process.env.KROMA_PASSWORD, true);
24213
+ const email3 = await ask2("email or username", options.email || process.env.KROMA_EMAIL, false);
24214
+ const password2 = await ask2("password", options.password || process.env.KROMA_PASSWORD, true);
23215
24215
  const res = await fetch(`${url2}/api/auth/login`, {
23216
24216
  method: "POST",
23217
24217
  headers: { "content-type": "application/json" },
@@ -23306,7 +24306,7 @@ var init_cargo2 = __esm(() => {
23306
24306
  });
23307
24307
 
23308
24308
  // src/bundle/read.ts
23309
- import { createHash } from "crypto";
24309
+ import { createHash as createHash2 } from "crypto";
23310
24310
  import { existsSync as existsSync11, readdirSync as readdirSync7, readFileSync as readFileSync9 } from "fs";
23311
24311
  import { join as join15 } from "path";
23312
24312
  function iconDataUri(tar) {
@@ -23323,7 +24323,7 @@ function iconDataUri(tar) {
23323
24323
  function readBundle(path) {
23324
24324
  const file2 = path.split("/").pop() ?? path;
23325
24325
  const bytes = readFileSync9(path);
23326
- const tar = toTar(new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength));
24326
+ const tar = toTar(bytes);
23327
24327
  const manifestBytes = tarRead(tar, "module.json");
23328
24328
  if (!manifestBytes) {
23329
24329
  console.warn(` ! ${file2}: no module.json inside, skipped`);
@@ -23347,8 +24347,8 @@ function readBundle(path) {
23347
24347
  file: file2,
23348
24348
  path,
23349
24349
  size: bytes.length,
23350
- sha256: createHash("sha256").update(bytes).digest("hex"),
23351
- contentHash: createHash("sha256").update(tar).digest("hex"),
24350
+ sha256: createHash2("sha256").update(bytes).digest("hex"),
24351
+ contentHash: createHash2("sha256").update(tar).digest("hex"),
23352
24352
  icon: iconDataUri(tar)
23353
24353
  };
23354
24354
  }
@@ -25028,7 +26028,7 @@ var init_hono = __esm(() => {
25028
26028
  });
25029
26029
 
25030
26030
  // ../../node_modules/.bun/hono@4.13.2/node_modules/hono/dist/index.js
25031
- var init_dist5 = __esm(() => {
26031
+ var init_dist6 = __esm(() => {
25032
26032
  init_hono();
25033
26033
  init_context();
25034
26034
  });
@@ -25097,7 +26097,7 @@ var REGISTRY_NAME = "KROMA modules (local)", origin = (url2) => new URL(url2).or
25097
26097
  }), schemaNamed = (name) => SCHEMA_NAMES.find((candidate) => candidate === name.replace(/\.json$/, ""));
25098
26098
  var init_serve = __esm(() => {
25099
26099
  init_src();
25100
- init_dist5();
26100
+ init_dist6();
25101
26101
  init_read();
25102
26102
  init_registry();
25103
26103
  });
@@ -25981,7 +26981,7 @@ var check2 = defineCommand({
25981
26981
  },
25982
26982
  run: ({ args }) => exitAfter(Promise.resolve().then(() => (init_check(), exports_check)).then((m) => m.checkCommand({ dirs: list(args._), rust: args.rust !== false, ts: args.ts !== false })))
25983
26983
  });
25984
- var install = defineCommand({
26984
+ var install2 = defineCommand({
25985
26985
  meta: { name: "install", description: "Upload a packed .kmod to a running server." },
25986
26986
  args: {
25987
26987
  id: {
@@ -26121,6 +27121,6 @@ var release = defineCommand({
26121
27121
  });
26122
27122
  var main = defineCommand({
26123
27123
  meta: { name: "kroma", description: "Build KROMA modules." },
26124
- subCommands: { create, dev, build: build2, check: check2, install, login, plan, cargo: cargo2, registry: registry2, serve, release }
27124
+ subCommands: { create, dev, build: build2, check: check2, install: install2, login, plan, cargo: cargo2, registry: registry2, serve, release }
26125
27125
  });
26126
27126
  runMain(main);