bun-plugin-stx 0.2.96 → 0.2.98

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 (2) hide show
  1. package/dist/serve.js +73 -66
  2. package/package.json +1 -2
package/dist/serve.js CHANGED
@@ -16,26 +16,28 @@ import process19 from "process";
16
16
 
17
17
  // ../../node_modules/bunfig/dist/index.js
18
18
  import { existsSync, statSync } from "fs";
19
+ import { resolve } from "path";
20
+ import process from "process";
19
21
  import { existsSync as existsSync13, mkdirSync as mkdirSync4, readdirSync as readdirSync4, readFileSync, writeFileSync as writeFileSync7 } from "fs";
20
22
  import { homedir as homedir3 } from "os";
21
23
  import { dirname as dirname4, resolve as resolve12 } from "path";
22
24
  import process20 from "process";
23
- import { existsSync as existsSync2, statSync as statSync2 } from "fs";
25
+ import { existsSync as existsSync3, statSync as statSync2 } from "fs";
24
26
  import { existsSync as existsSync8, mkdirSync as mkdirSync3, readdirSync as readdirSync3, writeFileSync as writeFileSync5 } from "fs";
25
27
  import { homedir as homedir2 } from "os";
26
28
  import { dirname as dirname3, resolve as resolve7 } from "path";
27
29
  import process12 from "process";
28
30
  import { join as join3, relative as relative2, resolve as resolve4 } from "path";
29
31
  import process7 from "process";
30
- import { existsSync as existsSync3, mkdirSync as mkdirSync2, readdirSync as readdirSync2, writeFileSync as writeFileSync3 } from "fs";
32
+ import { existsSync as existsSync32, mkdirSync as mkdirSync2, readdirSync as readdirSync2, writeFileSync as writeFileSync3 } from "fs";
31
33
  import { homedir } from "os";
32
34
  import { dirname as dirname2, resolve as resolve3 } from "path";
33
35
  import process6 from "process";
34
36
  import { join, relative, resolve as resolve2 } from "path";
35
37
  import process2 from "process";
36
38
  import { existsSync as existsSync22, mkdirSync, readdirSync, writeFileSync } from "fs";
37
- import { dirname, resolve } from "path";
38
- import process from "process";
39
+ import { dirname, resolve as resolve5 } from "path";
40
+ import process3 from "process";
39
41
  import { Buffer } from "buffer";
40
42
  import { createCipheriv, createDecipheriv, randomBytes } from "crypto";
41
43
  import { closeSync, createReadStream, createWriteStream, existsSync as existsSync222, fsyncSync, openSync, writeFileSync as writeFileSync2 } from "fs";
@@ -45,7 +47,7 @@ import process5 from "process";
45
47
  import { pipeline } from "stream/promises";
46
48
  import { createGzip } from "zlib";
47
49
  import process4 from "process";
48
- import process3 from "process";
50
+ import process32 from "process";
49
51
  import { Buffer as Buffer2 } from "buffer";
50
52
  import { createCipheriv as createCipheriv2, createDecipheriv as createDecipheriv2, randomBytes as randomBytes2 } from "crypto";
51
53
  import { closeSync as closeSync2, createReadStream as createReadStream2, createWriteStream as createWriteStream2, existsSync as existsSync4, fsyncSync as fsyncSync2, openSync as openSync2, writeFileSync as writeFileSync4 } from "fs";
@@ -58,7 +60,7 @@ import process10 from "process";
58
60
  import process9 from "process";
59
61
  import process8 from "process";
60
62
  import { existsSync as existsSync5 } from "fs";
61
- import { resolve as resolve5 } from "path";
63
+ import { resolve as resolve52 } from "path";
62
64
  import { existsSync as existsSync7 } from "fs";
63
65
  import { existsSync as existsSync9, readdirSync as readdirSync5 } from "fs";
64
66
  import { extname, resolve as resolve8 } from "path";
@@ -319,6 +321,43 @@ class PerformanceMonitor {
319
321
  }
320
322
  var globalCache = new ConfigCache;
321
323
  var globalPerformanceMonitor = new PerformanceMonitor;
324
+ var CONFIG_FILE_EXTENSIONS = [
325
+ ".ts",
326
+ ".js",
327
+ ".mjs",
328
+ ".cjs",
329
+ ".json",
330
+ ".mts",
331
+ ".cts"
332
+ ];
333
+ function getConfigNamePatterns(options = {}) {
334
+ const { name = "", alias } = options;
335
+ const patterns = ["config", ".config"];
336
+ if (name)
337
+ patterns.push(name, `.${name}.config`, `${name}.config`, `.${name}`);
338
+ const aliases = alias === undefined ? [] : Array.isArray(alias) ? alias : [alias];
339
+ for (const alternative of aliases) {
340
+ if (!alternative)
341
+ continue;
342
+ patterns.push(alternative, `.${alternative}.config`, `${alternative}.config`, `.${alternative}`);
343
+ if (name)
344
+ patterns.push(`${name}.${alternative}.config`, `.${name}.${alternative}.config`);
345
+ }
346
+ return Array.from(new Set(patterns.filter(Boolean)));
347
+ }
348
+ function getConfigPaths(options) {
349
+ const patterns = getConfigNamePatterns(options);
350
+ return patterns.flatMap((pattern) => CONFIG_FILE_EXTENSIONS.map((extension) => resolve(options.directory, `${pattern}${extension}`)));
351
+ }
352
+ function getLocalConfigDirectories(options = {}) {
353
+ const cwd = resolve(options.cwd || process.cwd());
354
+ return Array.from(new Set([
355
+ cwd,
356
+ resolve(cwd, "config"),
357
+ resolve(cwd, ".config"),
358
+ options.configDir ? resolve(cwd, options.configDir) : undefined
359
+ ].filter((directory) => Boolean(directory))));
360
+ }
322
361
  var __defProp = Object.defineProperty;
323
362
  var __returnValue = (v) => v;
324
363
  function __exportSetter(name, newValue) {
@@ -456,7 +495,7 @@ class ConfigCache2 {
456
495
  }
457
496
  isFileModified(configPath, cachedTimestamp) {
458
497
  try {
459
- if (!existsSync2(configPath)) {
498
+ if (!existsSync3(configPath)) {
460
499
  return true;
461
500
  }
462
501
  const stats = statSync2(configPath);
@@ -478,7 +517,7 @@ class ConfigCache2 {
478
517
  }
479
518
  setWithFileCheck(configName, value, configPath, customTtl) {
480
519
  try {
481
- const stats = existsSync2(configPath) ? statSync2(configPath) : null;
520
+ const stats = existsSync3(configPath) ? statSync2(configPath) : null;
482
521
  const fileTimestamp = stats ? stats.mtime : new Date;
483
522
  this.set(configName, { value, fileTimestamp }, configPath, customTtl);
484
523
  } catch {
@@ -778,7 +817,7 @@ async function loadConfig({
778
817
  cwd,
779
818
  defaultConfig
780
819
  }) {
781
- const baseDir = cwd || process.cwd();
820
+ const baseDir = cwd || process3.cwd();
782
821
  const extensions = [".ts", ".js", ".mjs", ".cjs", ".json"];
783
822
  const configPaths = [
784
823
  `${name}.config`,
@@ -788,7 +827,7 @@ async function loadConfig({
788
827
  ];
789
828
  for (const configPath of configPaths) {
790
829
  for (const ext of extensions) {
791
- const fullPath = resolve(baseDir, `${configPath}${ext}`);
830
+ const fullPath = resolve5(baseDir, `${configPath}${ext}`);
792
831
  const config2 = await tryLoadConfig(fullPath, defaultConfig);
793
832
  if (config2 !== null) {
794
833
  return config2;
@@ -796,7 +835,7 @@ async function loadConfig({
796
835
  }
797
836
  }
798
837
  try {
799
- const pkgPath = resolve(baseDir, "package.json");
838
+ const pkgPath = resolve5(baseDir, "package.json");
800
839
  if (existsSync22(pkgPath)) {
801
840
  const pkg = await import(pkgPath);
802
841
  const pkgConfig = pkg[name];
@@ -833,24 +872,24 @@ async function loadConfig2() {
833
872
  }
834
873
  }
835
874
  function isBrowserProcess() {
836
- if (process3.env.NODE_ENV === "test" || process3.env.BUN_ENV === "test") {
875
+ if (process32.env.NODE_ENV === "test" || process32.env.BUN_ENV === "test") {
837
876
  return false;
838
877
  }
839
878
  return typeof window !== "undefined";
840
879
  }
841
880
  async function isServerProcess() {
842
- if (process3.env.NODE_ENV === "test" || process3.env.BUN_ENV === "test") {
881
+ if (process32.env.NODE_ENV === "test" || process32.env.BUN_ENV === "test") {
843
882
  return true;
844
883
  }
845
884
  if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
846
885
  return true;
847
886
  }
848
- if (typeof process3 !== "undefined") {
849
- const type = process3.type;
887
+ if (typeof process32 !== "undefined") {
888
+ const type = process32.type;
850
889
  if (type === "renderer" || type === "worker") {
851
890
  return false;
852
891
  }
853
- return !!(process3.versions && (process3.versions.node || process3.versions.bun));
892
+ return !!(process32.versions && (process32.versions.node || process32.versions.bun));
854
893
  }
855
894
  return false;
856
895
  }
@@ -2165,7 +2204,7 @@ function isObject2(item) {
2165
2204
  return Boolean(item && typeof item === "object" && !Array.isArray(item));
2166
2205
  }
2167
2206
  async function tryLoadConfig2(configPath, defaultConfig2, arrayStrategy = "replace") {
2168
- if (!existsSync3(configPath))
2207
+ if (!existsSync32(configPath))
2169
2208
  return null;
2170
2209
  try {
2171
2210
  const importedConfig = await import(configPath);
@@ -2336,7 +2375,7 @@ async function loadConfig3({
2336
2375
  }
2337
2376
  try {
2338
2377
  const pkgPath = resolve3(baseDir, "package.json");
2339
- if (existsSync3(pkgPath)) {
2378
+ if (existsSync32(pkgPath)) {
2340
2379
  const pkg = await import(pkgPath);
2341
2380
  let pkgConfig = pkg[name];
2342
2381
  if (!pkgConfig && alias) {
@@ -2627,7 +2666,7 @@ class Logger2 {
2627
2666
  const errorMessage = typeof error.message === "string" ? error.message : "Unknown error";
2628
2667
  console.error(`Network error during write attempt ${retries + 1}/${maxRetries}:`, errorMessage);
2629
2668
  const delay = backoffDelay * 2 ** retries;
2630
- await new Promise((resolve52) => setTimeout(resolve52, delay));
2669
+ await new Promise((resolve522) => setTimeout(resolve522, delay));
2631
2670
  retries++;
2632
2671
  continue;
2633
2672
  }
@@ -2655,7 +2694,7 @@ class Logger2 {
2655
2694
  }
2656
2695
  retries++;
2657
2696
  const delay = backoffDelay * 2 ** (retries - 1);
2658
- await new Promise((resolve52) => setTimeout(resolve52, delay));
2697
+ await new Promise((resolve522) => setTimeout(resolve522, delay));
2659
2698
  }
2660
2699
  }
2661
2700
  })();
@@ -2785,11 +2824,11 @@ class Logger2 {
2785
2824
  };
2786
2825
  }
2787
2826
  async compressData(data) {
2788
- return new Promise((resolve52, reject) => {
2827
+ return new Promise((resolve522, reject) => {
2789
2828
  const gzip = createGzip2();
2790
2829
  const chunks = [];
2791
2830
  gzip.on("data", (chunk2) => chunks.push(chunk2));
2792
- gzip.on("end", () => resolve52(Buffer2.from(Buffer2.concat(chunks))));
2831
+ gzip.on("end", () => resolve522(Buffer2.from(Buffer2.concat(chunks))));
2793
2832
  gzip.on("error", reject);
2794
2833
  gzip.write(data);
2795
2834
  gzip.end();
@@ -3478,7 +3517,7 @@ class Logger2 {
3478
3517
  if (isBrowserProcess2()) {
3479
3518
  return Promise.resolve(true);
3480
3519
  }
3481
- return new Promise((resolve52) => {
3520
+ return new Promise((resolve522) => {
3482
3521
  console.error(`${styles2.cyan("?")} ${message} (y/n) `);
3483
3522
  const onData = (data) => {
3484
3523
  const input = data.toString().trim().toLowerCase();
@@ -3490,7 +3529,7 @@ class Logger2 {
3490
3529
  } catch {}
3491
3530
  process11.stdin.pause();
3492
3531
  console.error("");
3493
- resolve52(input === "y" || input === "yes");
3532
+ resolve522(input === "y" || input === "yes");
3494
3533
  };
3495
3534
  try {
3496
3535
  if (typeof process11.stdin.setRawMode === "function") {
@@ -3656,7 +3695,7 @@ async function withErrorRecovery(fn, options = {}) {
3656
3695
  break;
3657
3696
  }
3658
3697
  if (retryDelay > 0) {
3659
- await new Promise((resolve52) => setTimeout(resolve52, retryDelay));
3698
+ await new Promise((resolve522) => setTimeout(resolve522, retryDelay));
3660
3699
  }
3661
3700
  }
3662
3701
  }
@@ -4184,7 +4223,7 @@ class ConfigFileLoader {
4184
4223
  const paths = [];
4185
4224
  for (const pattern of patterns) {
4186
4225
  for (const ext of this.extensions) {
4187
- paths.push(resolve5(directory, `${pattern}${ext}`));
4226
+ paths.push(resolve52(directory, `${pattern}${ext}`));
4188
4227
  }
4189
4228
  }
4190
4229
  return paths;
@@ -4221,7 +4260,7 @@ class ConfigFileLoader {
4221
4260
  const patterns = this.generateNamePatterns(configName || "", alias);
4222
4261
  for (const pattern of patterns) {
4223
4262
  for (const ext of this.extensions) {
4224
- const filePath = resolve5(directory, `${pattern}${ext}`);
4263
+ const filePath = resolve52(directory, `${pattern}${ext}`);
4225
4264
  if (await this.checkFileAccess(filePath)) {
4226
4265
  discoveredFiles.push(filePath);
4227
4266
  }
@@ -4233,7 +4272,7 @@ class ConfigFileLoader {
4233
4272
  const files = readdirSync32(directory);
4234
4273
  for (const file of files) {
4235
4274
  if (this.looksLikeConfigFile(file)) {
4236
- const filePath = resolve5(directory, file);
4275
+ const filePath = resolve52(directory, file);
4237
4276
  if (await this.checkFileAccess(filePath)) {
4238
4277
  discoveredFiles.push(filePath);
4239
4278
  }
@@ -5347,8 +5386,8 @@ var init_dist = __esm(async () => {
5347
5386
  isEquivalent: isEquivalent2,
5348
5387
  estimateMemoryUsage: estimateMemoryUsage2
5349
5388
  };
5350
- defaultConfigDir = resolve(process.cwd(), "config");
5351
- defaultGeneratedDir = resolve(process.cwd(), "src/generated");
5389
+ defaultConfigDir = resolve5(process3.cwd(), "config");
5390
+ defaultGeneratedDir = resolve5(process3.cwd(), "src/generated");
5352
5391
  defaultLogDirectory = process2.env.CLARITY_LOG_DIR || join(getProjectRoot(), "logs");
5353
5392
  defaultConfig = {
5354
5393
  level: "info",
@@ -7667,7 +7706,7 @@ function isObject4(item) {
7667
7706
  }
7668
7707
 
7669
7708
  class ConfigFileLoader2 {
7670
- extensions = [".ts", ".js", ".mjs", ".cjs", ".json", ".mts", ".cts"];
7709
+ extensions = CONFIG_FILE_EXTENSIONS;
7671
7710
  async loadFromPath(configPath, defaultConfig4, options = {}) {
7672
7711
  const {
7673
7712
  arrayStrategy = "replace",
@@ -7742,37 +7781,10 @@ class ConfigFileLoader2 {
7742
7781
  return null;
7743
7782
  }
7744
7783
  generateConfigPaths(configName, directory, alias) {
7745
- const patterns = this.generateNamePatterns(configName, alias);
7746
- const paths = [];
7747
- for (const pattern of patterns) {
7748
- for (const ext of this.extensions) {
7749
- paths.push(resolve10(directory, `${pattern}${ext}`));
7750
- }
7751
- }
7752
- return paths;
7784
+ return getConfigPaths({ name: configName, directory, alias });
7753
7785
  }
7754
7786
  generateNamePatterns(configName, alias) {
7755
- const patterns = [];
7756
- patterns.push("config", ".config");
7757
- if (configName) {
7758
- patterns.push(configName, `.${configName}.config`, `${configName}.config`, `.${configName}`);
7759
- }
7760
- const aliases = alias === undefined ? [] : Array.isArray(alias) ? alias : [alias];
7761
- for (const a of aliases) {
7762
- if (!a)
7763
- continue;
7764
- patterns.push(a, `.${a}.config`, `${a}.config`, `.${a}`);
7765
- if (configName) {
7766
- patterns.push(`${configName}.${a}.config`, `.${configName}.${a}.config`);
7767
- }
7768
- }
7769
- const seen = new Set;
7770
- return patterns.filter((p) => {
7771
- if (!p || seen.has(p))
7772
- return false;
7773
- seen.add(p);
7774
- return true;
7775
- });
7787
+ return getConfigNamePatterns({ name: configName, alias });
7776
7788
  }
7777
7789
  checkFileAccess(filePath) {
7778
7790
  return withErrorRecovery2(async () => {
@@ -8564,12 +8576,7 @@ class ConfigLoader2 {
8564
8576
  return keyParts.join("|");
8565
8577
  }
8566
8578
  getLocalDirectories(baseDir, configDir) {
8567
- return Array.from(new Set([
8568
- baseDir,
8569
- resolve12(baseDir, "config"),
8570
- resolve12(baseDir, ".config"),
8571
- configDir ? resolve12(baseDir, configDir) : undefined
8572
- ].filter(Boolean)));
8579
+ return getLocalConfigDirectories({ cwd: baseDir, configDir });
8573
8580
  }
8574
8581
  getAllSearchPaths(name, alias, baseDir, configDir) {
8575
8582
  const paths = [];
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "bun-plugin-stx",
3
3
  "type": "module",
4
- "sideEffects": false,
5
- "version": "0.2.96",
4
+ "version": "0.2.98",
6
5
  "description": "A Bun plugin that allows for using Laravel Blade-like syntax.",
7
6
  "author": "Chris Breuer <chris@stacksjs.org>",
8
7
  "license": "MIT",