unpeek 2.0.0 → 4.0.0

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 (120) hide show
  1. package/README.md +57 -21
  2. package/README.tr.md +65 -29
  3. package/dist/adapters/esbuild.cjs +13 -0
  4. package/dist/adapters/esbuild.d.cts +13 -0
  5. package/dist/adapters/esbuild.d.ts +11 -0
  6. package/dist/adapters/esbuild.js +13 -0
  7. package/dist/adapters/next/adapter.cjs +43 -0
  8. package/dist/{next → adapters/next}/adapter.d.cts +4 -4
  9. package/dist/{next → adapters/next}/adapter.d.ts +4 -4
  10. package/dist/adapters/next/adapter.js +43 -0
  11. package/dist/adapters/next/index.cjs +16 -0
  12. package/dist/adapters/next/index.d.cts +53 -0
  13. package/dist/adapters/next/index.d.ts +53 -0
  14. package/dist/adapters/next/index.js +16 -0
  15. package/dist/adapters/rollup.cjs +13 -0
  16. package/dist/adapters/rollup.d.cts +13 -0
  17. package/dist/adapters/rollup.d.ts +11 -0
  18. package/dist/adapters/rollup.js +13 -0
  19. package/dist/adapters/rspack.cjs +13 -0
  20. package/dist/adapters/rspack.d.cts +13 -0
  21. package/dist/adapters/rspack.d.ts +11 -0
  22. package/dist/adapters/rspack.js +13 -0
  23. package/dist/adapters/vite.cjs +13 -0
  24. package/dist/adapters/vite.d.cts +13 -0
  25. package/dist/adapters/vite.d.ts +11 -0
  26. package/dist/adapters/vite.js +13 -0
  27. package/dist/adapters/webpack.cjs +13 -0
  28. package/dist/adapters/webpack.d.cts +13 -0
  29. package/dist/adapters/webpack.d.ts +11 -0
  30. package/dist/adapters/webpack.js +13 -0
  31. package/dist/browser.cjs +8 -5
  32. package/dist/browser.d.cts +44 -3
  33. package/dist/browser.d.ts +44 -3
  34. package/dist/browser.js +10 -7
  35. package/dist/{chunk-5QD6FZPB.js → chunk-2JU3V7HW.js} +75 -43
  36. package/dist/chunk-3LWXEJU6.cjs +1054 -0
  37. package/dist/chunk-4FNZNIBW.js +7391 -0
  38. package/dist/chunk-7HXLHLLQ.cjs +503 -0
  39. package/dist/chunk-ADKRENAP.js +1054 -0
  40. package/dist/chunk-EN6QVR6P.js +89 -0
  41. package/dist/chunk-HHC7BUCK.js +503 -0
  42. package/dist/chunk-KLYFNMKS.cjs +7391 -0
  43. package/dist/chunk-L6BOM5VS.cjs +40 -0
  44. package/dist/{chunk-OOXSZTRV.js → chunk-LA6J3BT3.js} +26 -1
  45. package/dist/chunk-URPPSTHZ.cjs +89 -0
  46. package/dist/chunk-VG4Y26ZN.cjs +429 -0
  47. package/dist/{chunk-GZB7PFLY.js → chunk-W77DAC3H.js} +46 -64
  48. package/dist/chunk-X6EETCO6.cjs +352 -0
  49. package/dist/chunk-YCRMTXOE.js +429 -0
  50. package/dist/{chunk-GAVI2C44.cjs → chunk-ZG7BIAUI.cjs} +80 -48
  51. package/dist/cli/index.js +9861 -32
  52. package/dist/{types-BBSRUEab.d.cts → config-Y6JwVGwX.d.cts} +58 -86
  53. package/dist/{types-BBSRUEab.d.ts → config-Y6JwVGwX.d.ts} +58 -86
  54. package/dist/config.cjs +4 -16
  55. package/dist/config.d.cts +1 -12
  56. package/dist/config.d.ts +1 -12
  57. package/dist/config.js +5 -17
  58. package/dist/index-0O1WSfVP.d.ts +52 -0
  59. package/dist/index-COVHErnx.d.cts +52 -0
  60. package/dist/index.cjs +437 -9
  61. package/dist/index.d.cts +9 -17
  62. package/dist/index.d.ts +9 -17
  63. package/dist/index.js +438 -10
  64. package/dist/plugins/unplugin.cjs +21 -0
  65. package/dist/plugins/unplugin.d.cts +17 -0
  66. package/dist/plugins/unplugin.d.ts +15 -0
  67. package/dist/{bundler → plugins}/unplugin.js +6 -5
  68. package/dist/types-CMtZnV8C.d.ts +112 -0
  69. package/dist/types-D93PuOOl.d.cts +112 -0
  70. package/package.json +48 -52
  71. package/dist/ast/index.cjs +0 -17
  72. package/dist/ast/index.d.cts +0 -18
  73. package/dist/ast/index.d.ts +0 -18
  74. package/dist/ast/index.js +0 -17
  75. package/dist/bundler/unplugin.cjs +0 -20
  76. package/dist/bundler/unplugin.d.cts +0 -16
  77. package/dist/bundler/unplugin.d.ts +0 -14
  78. package/dist/chunk-24K5NDXH.cjs +0 -370
  79. package/dist/chunk-27HR647Q.js +0 -190
  80. package/dist/chunk-4TDLLEEU.cjs +0 -15
  81. package/dist/chunk-5LCMI2TL.js +0 -575
  82. package/dist/chunk-5M6Z7ZFT.cjs +0 -83
  83. package/dist/chunk-6N6S6WTQ.cjs +0 -423
  84. package/dist/chunk-7YVEHJVM.cjs +0 -575
  85. package/dist/chunk-J5CGNZDM.cjs +0 -190
  86. package/dist/chunk-KQWNFKT2.js +0 -423
  87. package/dist/chunk-LXP73HJC.cjs +0 -4532
  88. package/dist/chunk-R6EBIR3T.cjs +0 -14
  89. package/dist/chunk-S4S2WXGC.js +0 -14
  90. package/dist/chunk-UMPUYLLZ.js +0 -4532
  91. package/dist/chunk-X5MKMFMX.js +0 -83
  92. package/dist/cli/index.cjs +0 -324
  93. package/dist/cli/index.d.cts +0 -22
  94. package/dist/cli/index.d.ts +0 -22
  95. package/dist/esbuild.cjs +0 -15
  96. package/dist/esbuild.d.cts +0 -11
  97. package/dist/esbuild.d.ts +0 -11
  98. package/dist/esbuild.js +0 -13
  99. package/dist/next/adapter.cjs +0 -31
  100. package/dist/next/adapter.js +0 -31
  101. package/dist/next/index.cjs +0 -18
  102. package/dist/next/index.d.cts +0 -42
  103. package/dist/next/index.d.ts +0 -42
  104. package/dist/next/index.js +0 -18
  105. package/dist/rollup.cjs +0 -15
  106. package/dist/rollup.d.cts +0 -11
  107. package/dist/rollup.d.ts +0 -11
  108. package/dist/rollup.js +0 -13
  109. package/dist/runtime/index.cjs +0 -17
  110. package/dist/runtime/index.d.cts +0 -36
  111. package/dist/runtime/index.d.ts +0 -36
  112. package/dist/runtime/index.js +0 -17
  113. package/dist/vite.cjs +0 -15
  114. package/dist/vite.d.cts +0 -11
  115. package/dist/vite.d.ts +0 -11
  116. package/dist/vite.js +0 -13
  117. package/dist/webpack.cjs +0 -15
  118. package/dist/webpack.d.cts +0 -11
  119. package/dist/webpack.d.ts +0 -11
  120. package/dist/webpack.js +0 -13
@@ -1,8 +1,11 @@
1
+ import {
2
+ PRESETS
3
+ } from "./chunk-EN6QVR6P.js";
1
4
  import {
2
5
  UnpeekError
3
- } from "./chunk-S4S2WXGC.js";
6
+ } from "./chunk-LA6J3BT3.js";
4
7
 
5
- // src/config.ts
8
+ // src/internal/config.ts
6
9
  import fs, { existsSync, readFileSync } from "fs";
7
10
  import { extname, join, resolve } from "path";
8
11
  import { pathToFileURL } from "url";
@@ -16,6 +19,8 @@ var CONFIG_CANDIDATES = [
16
19
  var DEFAULT_CONFIG = {
17
20
  framework: void 0,
18
21
  target: "browser",
22
+ tier: "Tier 2",
23
+ coldFlow: true,
19
24
  outDir: void 0,
20
25
  extensions: [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs"],
21
26
  publicDirs: ["public", "static"],
@@ -32,6 +37,10 @@ var DEFAULT_CONFIG = {
32
37
  excludeComponents: [],
33
38
  maxPipelineCallers: 2
34
39
  },
40
+ critical: {
41
+ include: [],
42
+ annotation: "@unpeek-critical"
43
+ },
35
44
  vault: {
36
45
  minStringLength: 4,
37
46
  customDirectives: [],
@@ -43,7 +52,7 @@ var DEFAULT_CONFIG = {
43
52
  polymorphicDecoys: true
44
53
  },
45
54
  mangler: {
46
- minLength: 3,
55
+ minLength: 1,
47
56
  reservedIdentifiers: [],
48
57
  excludePrefixes: [],
49
58
  excludePatterns: []
@@ -83,6 +92,9 @@ function toRegExpArray(val) {
83
92
  }
84
93
  return result;
85
94
  }
95
+ function clonePatterns(patterns) {
96
+ return patterns ? [...patterns] : void 0;
97
+ }
86
98
  function normalizeConfig(raw) {
87
99
  if (!isRecord(raw)) {
88
100
  return {};
@@ -112,15 +124,22 @@ function normalizeConfig(raw) {
112
124
  }
113
125
  return result;
114
126
  }
115
- function mergeUnpeekConfig(base, override) {
116
- if (!override) {
117
- return { ...base };
118
- }
127
+ function mergeTwoConfigs(base, override) {
128
+ const mergedCriticalInclude = override.critical?.include || base.critical?.include ? Array.from(
129
+ /* @__PURE__ */ new Set([
130
+ ...base.critical?.include ?? [],
131
+ ...override.critical?.include ?? []
132
+ ])
133
+ ) : void 0;
119
134
  return {
120
135
  ...base,
121
136
  framework: override.framework ?? base.framework,
122
137
  target: override.target ?? base.target,
138
+ profile: override.profile ?? base.profile,
139
+ tier: override.tier ?? base.tier,
140
+ coldFlow: override.coldFlow ?? base.coldFlow,
123
141
  outDir: override.outDir ?? base.outDir,
142
+ scrubPaths: override.scrubPaths ?? base.scrubPaths,
124
143
  extensions: override.extensions ? [...override.extensions] : base.extensions ? [...base.extensions] : void 0,
125
144
  publicDirs: override.publicDirs ? [...override.publicDirs] : base.publicDirs ? [...base.publicDirs] : void 0,
126
145
  filter: {
@@ -156,6 +175,11 @@ function mergeUnpeekConfig(base, override) {
156
175
  override.hotPath?.excludeComponents
157
176
  )
158
177
  },
178
+ critical: base.critical || override.critical ? {
179
+ include: mergedCriticalInclude,
180
+ annotation: override.critical?.annotation ?? base.critical?.annotation ?? "@unpeek-critical",
181
+ maxFunctionsPerChunk: override.critical?.maxFunctionsPerChunk ?? base.critical?.maxFunctionsPerChunk
182
+ } : void 0,
159
183
  vault: {
160
184
  minStringLength: override.vault?.minStringLength ?? base.vault?.minStringLength ?? 4,
161
185
  customDirectives: mergeStringArrays(
@@ -168,13 +192,15 @@ function mergeUnpeekConfig(base, override) {
168
192
  ),
169
193
  cssFramework: override.vault?.cssFramework ?? base.vault?.cssFramework ?? "tailwind",
170
194
  semanticAnchors: {
171
- patterns: override.vault?.semanticAnchors?.patterns ? [...override.vault.semanticAnchors.patterns] : base.vault?.semanticAnchors?.patterns,
195
+ patterns: clonePatterns(override.vault?.semanticAnchors?.patterns) ?? clonePatterns(base.vault?.semanticAnchors?.patterns),
172
196
  excludeUiClasses: override.vault?.semanticAnchors?.excludeUiClasses ?? base.vault?.semanticAnchors?.excludeUiClasses ?? true
173
197
  },
174
- polymorphicDecoys: override.vault?.polymorphicDecoys ?? base.vault?.polymorphicDecoys ?? true
198
+ polymorphicDecoys: override.vault?.polymorphicDecoys ?? base.vault?.polymorphicDecoys ?? true,
199
+ fragmented: override.vault?.fragmented ?? base.vault?.fragmented,
200
+ fragmentCount: override.vault?.fragmentCount ?? base.vault?.fragmentCount
175
201
  },
176
202
  mangler: {
177
- minLength: override.mangler?.minLength ?? base.mangler?.minLength ?? 3,
203
+ minLength: override.mangler?.minLength ?? base.mangler?.minLength ?? 1,
178
204
  reservedIdentifiers: mergeStringArrays(
179
205
  base.mangler?.reservedIdentifiers,
180
206
  override.mangler?.reservedIdentifiers
@@ -183,7 +209,7 @@ function mergeUnpeekConfig(base, override) {
183
209
  base.mangler?.excludePrefixes,
184
210
  override.mangler?.excludePrefixes
185
211
  ),
186
- excludePatterns: override.mangler?.excludePatterns ? [...override.mangler.excludePatterns] : base.mangler?.excludePatterns
212
+ excludePatterns: clonePatterns(override.mangler?.excludePatterns) ?? clonePatterns(base.mangler?.excludePatterns)
187
213
  },
188
214
  shield: {
189
215
  detectHeadless: override.shield?.detectHeadless ?? base.shield?.detectHeadless ?? false,
@@ -203,6 +229,13 @@ function mergeUnpeekConfig(base, override) {
203
229
  }
204
230
  };
205
231
  }
232
+ function mergeUnpeekConfig(base, override) {
233
+ if (!override) {
234
+ return { ...base };
235
+ }
236
+ const effectiveBase = override.profile ? mergeTwoConfigs(base, PRESETS[override.profile]) : base;
237
+ return mergeTwoConfigs(effectiveBase, override);
238
+ }
206
239
  function findConfigFile(cwd = process.cwd()) {
207
240
  const root = cwd ? resolve(cwd) : process.cwd();
208
241
  for (const filename of CONFIG_CANDIDATES) {
@@ -307,64 +340,13 @@ async function loadUnpeekConfig(cwd = process.cwd(), explicitConfig) {
307
340
  const baseConfig = mergeUnpeekConfig(DEFAULT_CONFIG, parsedConfig);
308
341
  return explicitConfig ? mergeUnpeekConfig(baseConfig, explicitConfig) : baseConfig;
309
342
  }
310
- function resolveUnpeekConfigSync(cwd = process.cwd(), explicitConfig) {
311
- const root = cwd ? resolve(cwd) : process.cwd();
312
- const configPath = findConfigFile(root);
313
- let parsedConfig = {};
314
- if (configPath) {
315
- const ext = extname(configPath).toLowerCase();
316
- if (ext === ".json") {
317
- let content;
318
- try {
319
- content = readFileSync(configPath, "utf8");
320
- } catch (err) {
321
- throw new UnpeekError(
322
- "ERR_CONFIG_LOAD",
323
- `Failed to read configuration at "${configPath}": ${formatErr(err)}`,
324
- { cause: err }
325
- );
326
- }
327
- parsedConfig = parseJsonConfig(content, configPath);
328
- } else {
329
- let raw;
330
- try {
331
- const req = createRequire(configPath);
332
- raw = unwrapDefaultExport(req(configPath));
333
- if (typeof raw === "function") {
334
- raw = raw();
335
- }
336
- } catch (err) {
337
- const errCode = isRecord(err) ? err.code : void 0;
338
- if (errCode === "ERR_REQUIRE_ESM") {
339
- throw new UnpeekError(
340
- "ERR_CONFIG_LOAD",
341
- `Synchronous loading of ESM configuration "${configPath}" is not supported by Node.js require(). Use loadUnpeekConfig() or CommonJS/JSON config format instead.`,
342
- { cause: err }
343
- );
344
- }
345
- throw new UnpeekError(
346
- "ERR_CONFIG_LOAD",
347
- `Failed to load configuration at "${configPath}": ${formatErr(err)}`,
348
- { cause: err }
349
- );
350
- }
351
- parsedConfig = validateAndNormalizeConfig(raw ?? {}, configPath);
352
- }
353
- }
354
- const baseConfig = mergeUnpeekConfig(DEFAULT_CONFIG, parsedConfig);
355
- return explicitConfig ? mergeUnpeekConfig(baseConfig, explicitConfig) : baseConfig;
356
- }
343
+
344
+ // src/config.ts
357
345
  function defineConfig(config) {
358
346
  return config;
359
347
  }
360
348
 
361
349
  export {
362
- CONFIG_CANDIDATES,
363
- DEFAULT_CONFIG,
364
- normalizeConfig,
365
- mergeUnpeekConfig,
366
- findConfigFile,
367
350
  loadUnpeekConfig,
368
- resolveUnpeekConfigSync,
369
351
  defineConfig
370
352
  };
@@ -0,0 +1,352 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunkURPPSTHZcjs = require('./chunk-URPPSTHZ.cjs');
4
+
5
+
6
+ var _chunkL6BOM5VScjs = require('./chunk-L6BOM5VS.cjs');
7
+
8
+ // src/internal/config.ts
9
+ var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
10
+ var _path = require('path');
11
+ var _url = require('url');
12
+ var _module = require('module');
13
+ var CONFIG_CANDIDATES = [
14
+ "unpeek.config.js",
15
+ "unpeek.config.mjs",
16
+ "unpeek.config.cjs",
17
+ "unpeek.config.json"
18
+ ];
19
+ var DEFAULT_CONFIG = {
20
+ framework: void 0,
21
+ target: "browser",
22
+ tier: "Tier 2",
23
+ coldFlow: true,
24
+ outDir: void 0,
25
+ extensions: [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs"],
26
+ publicDirs: ["public", "static"],
27
+ filter: {
28
+ include: [],
29
+ exclude: ["node_modules/**", "**/*.test.*", "**/*.spec.*"]
30
+ },
31
+ hotPath: {
32
+ customAnimationCalls: [],
33
+ importSources: {},
34
+ customHooks: [],
35
+ arrayHofMethods: [],
36
+ hocWrappers: [],
37
+ excludeComponents: [],
38
+ maxPipelineCallers: 2
39
+ },
40
+ critical: {
41
+ include: [],
42
+ annotation: "@unpeek-critical"
43
+ },
44
+ vault: {
45
+ minStringLength: 4,
46
+ customDirectives: [],
47
+ reservedProps: [],
48
+ cssFramework: "tailwind",
49
+ semanticAnchors: {
50
+ excludeUiClasses: true
51
+ },
52
+ polymorphicDecoys: true
53
+ },
54
+ mangler: {
55
+ minLength: 1,
56
+ reservedIdentifiers: [],
57
+ excludePrefixes: [],
58
+ excludePatterns: []
59
+ },
60
+ shield: {
61
+ detectHeadless: false,
62
+ deterrentMode: "passive"
63
+ },
64
+ sourcemaps: {
65
+ keepPrivate: true,
66
+ vaultDir: ".unpeek-maps",
67
+ stripComments: true
68
+ },
69
+ next: {},
70
+ vite: {}
71
+ };
72
+ function mergeStringArrays(a, b) {
73
+ return Array.from(/* @__PURE__ */ new Set([..._nullishCoalesce(a, () => ( [])), ..._nullishCoalesce(b, () => ( []))]));
74
+ }
75
+ function isRecord(val) {
76
+ return typeof val === "object" && val !== null && !Array.isArray(val);
77
+ }
78
+ function toRegExp(val) {
79
+ if (!val) return void 0;
80
+ if (val instanceof RegExp) return val;
81
+ if (typeof val === "string") {
82
+ return new RegExp(val);
83
+ }
84
+ return void 0;
85
+ }
86
+ function toRegExpArray(val) {
87
+ if (!Array.isArray(val)) return void 0;
88
+ const result = [];
89
+ for (const item of val) {
90
+ const rx = toRegExp(item);
91
+ if (rx) result.push(rx);
92
+ }
93
+ return result;
94
+ }
95
+ function clonePatterns(patterns) {
96
+ return patterns ? [...patterns] : void 0;
97
+ }
98
+ function normalizeConfig(raw) {
99
+ if (!isRecord(raw)) {
100
+ return {};
101
+ }
102
+ const result = { ...raw };
103
+ if (isRecord(raw.hotPath)) {
104
+ result.hotPath = {
105
+ ...raw.hotPath,
106
+ hookPattern: toRegExp(raw.hotPath.hookPattern),
107
+ eventHandlerRegex: toRegExp(raw.hotPath.eventHandlerRegex)
108
+ };
109
+ }
110
+ if (isRecord(raw.vault)) {
111
+ result.vault = {
112
+ ...raw.vault,
113
+ semanticAnchors: isRecord(raw.vault.semanticAnchors) ? {
114
+ ...raw.vault.semanticAnchors,
115
+ patterns: toRegExpArray(raw.vault.semanticAnchors.patterns)
116
+ } : void 0
117
+ };
118
+ }
119
+ if (isRecord(raw.mangler)) {
120
+ result.mangler = {
121
+ ...raw.mangler,
122
+ excludePatterns: toRegExpArray(raw.mangler.excludePatterns)
123
+ };
124
+ }
125
+ return result;
126
+ }
127
+ function mergeTwoConfigs(base, override) {
128
+ const mergedCriticalInclude = _optionalChain([override, 'access', _ => _.critical, 'optionalAccess', _2 => _2.include]) || _optionalChain([base, 'access', _3 => _3.critical, 'optionalAccess', _4 => _4.include]) ? Array.from(
129
+ /* @__PURE__ */ new Set([
130
+ ..._nullishCoalesce(_optionalChain([base, 'access', _5 => _5.critical, 'optionalAccess', _6 => _6.include]), () => ( [])),
131
+ ..._nullishCoalesce(_optionalChain([override, 'access', _7 => _7.critical, 'optionalAccess', _8 => _8.include]), () => ( []))
132
+ ])
133
+ ) : void 0;
134
+ return {
135
+ ...base,
136
+ framework: _nullishCoalesce(override.framework, () => ( base.framework)),
137
+ target: _nullishCoalesce(override.target, () => ( base.target)),
138
+ profile: _nullishCoalesce(override.profile, () => ( base.profile)),
139
+ tier: _nullishCoalesce(override.tier, () => ( base.tier)),
140
+ coldFlow: _nullishCoalesce(override.coldFlow, () => ( base.coldFlow)),
141
+ outDir: _nullishCoalesce(override.outDir, () => ( base.outDir)),
142
+ scrubPaths: _nullishCoalesce(override.scrubPaths, () => ( base.scrubPaths)),
143
+ extensions: override.extensions ? [...override.extensions] : base.extensions ? [...base.extensions] : void 0,
144
+ publicDirs: override.publicDirs ? [...override.publicDirs] : base.publicDirs ? [...base.publicDirs] : void 0,
145
+ filter: {
146
+ include: _optionalChain([override, 'access', _9 => _9.filter, 'optionalAccess', _10 => _10.include]) ? [...override.filter.include] : _optionalChain([base, 'access', _11 => _11.filter, 'optionalAccess', _12 => _12.include]) ? [...base.filter.include] : [],
147
+ exclude: _optionalChain([override, 'access', _13 => _13.filter, 'optionalAccess', _14 => _14.exclude]) ? [...override.filter.exclude] : _optionalChain([base, 'access', _15 => _15.filter, 'optionalAccess', _16 => _16.exclude]) ? [...base.filter.exclude] : []
148
+ },
149
+ hotPath: {
150
+ customAnimationCalls: mergeStringArrays(
151
+ _optionalChain([base, 'access', _17 => _17.hotPath, 'optionalAccess', _18 => _18.customAnimationCalls]),
152
+ _optionalChain([override, 'access', _19 => _19.hotPath, 'optionalAccess', _20 => _20.customAnimationCalls])
153
+ ),
154
+ importSources: {
155
+ ..._nullishCoalesce(_optionalChain([base, 'access', _21 => _21.hotPath, 'optionalAccess', _22 => _22.importSources]), () => ( {})),
156
+ ..._nullishCoalesce(_optionalChain([override, 'access', _23 => _23.hotPath, 'optionalAccess', _24 => _24.importSources]), () => ( {}))
157
+ },
158
+ hookPattern: _nullishCoalesce(_optionalChain([override, 'access', _25 => _25.hotPath, 'optionalAccess', _26 => _26.hookPattern]), () => ( _optionalChain([base, 'access', _27 => _27.hotPath, 'optionalAccess', _28 => _28.hookPattern]))),
159
+ customHooks: mergeStringArrays(
160
+ _optionalChain([base, 'access', _29 => _29.hotPath, 'optionalAccess', _30 => _30.customHooks]),
161
+ _optionalChain([override, 'access', _31 => _31.hotPath, 'optionalAccess', _32 => _32.customHooks])
162
+ ),
163
+ arrayHofMethods: mergeStringArrays(
164
+ _optionalChain([base, 'access', _33 => _33.hotPath, 'optionalAccess', _34 => _34.arrayHofMethods]),
165
+ _optionalChain([override, 'access', _35 => _35.hotPath, 'optionalAccess', _36 => _36.arrayHofMethods])
166
+ ),
167
+ eventHandlerRegex: _nullishCoalesce(_optionalChain([override, 'access', _37 => _37.hotPath, 'optionalAccess', _38 => _38.eventHandlerRegex]), () => ( _optionalChain([base, 'access', _39 => _39.hotPath, 'optionalAccess', _40 => _40.eventHandlerRegex]))),
168
+ maxPipelineCallers: _nullishCoalesce(_nullishCoalesce(_optionalChain([override, 'access', _41 => _41.hotPath, 'optionalAccess', _42 => _42.maxPipelineCallers]), () => ( _optionalChain([base, 'access', _43 => _43.hotPath, 'optionalAccess', _44 => _44.maxPipelineCallers]))), () => ( 2)),
169
+ hocWrappers: mergeStringArrays(
170
+ _optionalChain([base, 'access', _45 => _45.hotPath, 'optionalAccess', _46 => _46.hocWrappers]),
171
+ _optionalChain([override, 'access', _47 => _47.hotPath, 'optionalAccess', _48 => _48.hocWrappers])
172
+ ),
173
+ excludeComponents: mergeStringArrays(
174
+ _optionalChain([base, 'access', _49 => _49.hotPath, 'optionalAccess', _50 => _50.excludeComponents]),
175
+ _optionalChain([override, 'access', _51 => _51.hotPath, 'optionalAccess', _52 => _52.excludeComponents])
176
+ )
177
+ },
178
+ critical: base.critical || override.critical ? {
179
+ include: mergedCriticalInclude,
180
+ annotation: _nullishCoalesce(_nullishCoalesce(_optionalChain([override, 'access', _53 => _53.critical, 'optionalAccess', _54 => _54.annotation]), () => ( _optionalChain([base, 'access', _55 => _55.critical, 'optionalAccess', _56 => _56.annotation]))), () => ( "@unpeek-critical")),
181
+ maxFunctionsPerChunk: _nullishCoalesce(_optionalChain([override, 'access', _57 => _57.critical, 'optionalAccess', _58 => _58.maxFunctionsPerChunk]), () => ( _optionalChain([base, 'access', _59 => _59.critical, 'optionalAccess', _60 => _60.maxFunctionsPerChunk])))
182
+ } : void 0,
183
+ vault: {
184
+ minStringLength: _nullishCoalesce(_nullishCoalesce(_optionalChain([override, 'access', _61 => _61.vault, 'optionalAccess', _62 => _62.minStringLength]), () => ( _optionalChain([base, 'access', _63 => _63.vault, 'optionalAccess', _64 => _64.minStringLength]))), () => ( 4)),
185
+ customDirectives: mergeStringArrays(
186
+ _optionalChain([base, 'access', _65 => _65.vault, 'optionalAccess', _66 => _66.customDirectives]),
187
+ _optionalChain([override, 'access', _67 => _67.vault, 'optionalAccess', _68 => _68.customDirectives])
188
+ ),
189
+ reservedProps: mergeStringArrays(
190
+ _optionalChain([base, 'access', _69 => _69.vault, 'optionalAccess', _70 => _70.reservedProps]),
191
+ _optionalChain([override, 'access', _71 => _71.vault, 'optionalAccess', _72 => _72.reservedProps])
192
+ ),
193
+ cssFramework: _nullishCoalesce(_nullishCoalesce(_optionalChain([override, 'access', _73 => _73.vault, 'optionalAccess', _74 => _74.cssFramework]), () => ( _optionalChain([base, 'access', _75 => _75.vault, 'optionalAccess', _76 => _76.cssFramework]))), () => ( "tailwind")),
194
+ semanticAnchors: {
195
+ patterns: _nullishCoalesce(clonePatterns(_optionalChain([override, 'access', _77 => _77.vault, 'optionalAccess', _78 => _78.semanticAnchors, 'optionalAccess', _79 => _79.patterns])), () => ( clonePatterns(_optionalChain([base, 'access', _80 => _80.vault, 'optionalAccess', _81 => _81.semanticAnchors, 'optionalAccess', _82 => _82.patterns])))),
196
+ excludeUiClasses: _nullishCoalesce(_nullishCoalesce(_optionalChain([override, 'access', _83 => _83.vault, 'optionalAccess', _84 => _84.semanticAnchors, 'optionalAccess', _85 => _85.excludeUiClasses]), () => ( _optionalChain([base, 'access', _86 => _86.vault, 'optionalAccess', _87 => _87.semanticAnchors, 'optionalAccess', _88 => _88.excludeUiClasses]))), () => ( true))
197
+ },
198
+ polymorphicDecoys: _nullishCoalesce(_nullishCoalesce(_optionalChain([override, 'access', _89 => _89.vault, 'optionalAccess', _90 => _90.polymorphicDecoys]), () => ( _optionalChain([base, 'access', _91 => _91.vault, 'optionalAccess', _92 => _92.polymorphicDecoys]))), () => ( true)),
199
+ fragmented: _nullishCoalesce(_optionalChain([override, 'access', _93 => _93.vault, 'optionalAccess', _94 => _94.fragmented]), () => ( _optionalChain([base, 'access', _95 => _95.vault, 'optionalAccess', _96 => _96.fragmented]))),
200
+ fragmentCount: _nullishCoalesce(_optionalChain([override, 'access', _97 => _97.vault, 'optionalAccess', _98 => _98.fragmentCount]), () => ( _optionalChain([base, 'access', _99 => _99.vault, 'optionalAccess', _100 => _100.fragmentCount])))
201
+ },
202
+ mangler: {
203
+ minLength: _nullishCoalesce(_nullishCoalesce(_optionalChain([override, 'access', _101 => _101.mangler, 'optionalAccess', _102 => _102.minLength]), () => ( _optionalChain([base, 'access', _103 => _103.mangler, 'optionalAccess', _104 => _104.minLength]))), () => ( 1)),
204
+ reservedIdentifiers: mergeStringArrays(
205
+ _optionalChain([base, 'access', _105 => _105.mangler, 'optionalAccess', _106 => _106.reservedIdentifiers]),
206
+ _optionalChain([override, 'access', _107 => _107.mangler, 'optionalAccess', _108 => _108.reservedIdentifiers])
207
+ ),
208
+ excludePrefixes: mergeStringArrays(
209
+ _optionalChain([base, 'access', _109 => _109.mangler, 'optionalAccess', _110 => _110.excludePrefixes]),
210
+ _optionalChain([override, 'access', _111 => _111.mangler, 'optionalAccess', _112 => _112.excludePrefixes])
211
+ ),
212
+ excludePatterns: _nullishCoalesce(clonePatterns(_optionalChain([override, 'access', _113 => _113.mangler, 'optionalAccess', _114 => _114.excludePatterns])), () => ( clonePatterns(_optionalChain([base, 'access', _115 => _115.mangler, 'optionalAccess', _116 => _116.excludePatterns]))))
213
+ },
214
+ shield: {
215
+ detectHeadless: _nullishCoalesce(_nullishCoalesce(_optionalChain([override, 'access', _117 => _117.shield, 'optionalAccess', _118 => _118.detectHeadless]), () => ( _optionalChain([base, 'access', _119 => _119.shield, 'optionalAccess', _120 => _120.detectHeadless]))), () => ( false)),
216
+ deterrentMode: _nullishCoalesce(_nullishCoalesce(_optionalChain([override, 'access', _121 => _121.shield, 'optionalAccess', _122 => _122.deterrentMode]), () => ( _optionalChain([base, 'access', _123 => _123.shield, 'optionalAccess', _124 => _124.deterrentMode]))), () => ( "passive"))
217
+ },
218
+ sourcemaps: {
219
+ keepPrivate: _nullishCoalesce(_nullishCoalesce(_optionalChain([override, 'access', _125 => _125.sourcemaps, 'optionalAccess', _126 => _126.keepPrivate]), () => ( _optionalChain([base, 'access', _127 => _127.sourcemaps, 'optionalAccess', _128 => _128.keepPrivate]))), () => ( true)),
220
+ vaultDir: _nullishCoalesce(_nullishCoalesce(_optionalChain([override, 'access', _129 => _129.sourcemaps, 'optionalAccess', _130 => _130.vaultDir]), () => ( _optionalChain([base, 'access', _131 => _131.sourcemaps, 'optionalAccess', _132 => _132.vaultDir]))), () => ( ".unpeek-maps")),
221
+ stripComments: _nullishCoalesce(_nullishCoalesce(_optionalChain([override, 'access', _133 => _133.sourcemaps, 'optionalAccess', _134 => _134.stripComments]), () => ( _optionalChain([base, 'access', _135 => _135.sourcemaps, 'optionalAccess', _136 => _136.stripComments]))), () => ( true))
222
+ },
223
+ next: {
224
+ distDir: _nullishCoalesce(_optionalChain([override, 'access', _137 => _137.next, 'optionalAccess', _138 => _138.distDir]), () => ( _optionalChain([base, 'access', _139 => _139.next, 'optionalAccess', _140 => _140.distDir])))
225
+ },
226
+ vite: {
227
+ outDir: _nullishCoalesce(_optionalChain([override, 'access', _141 => _141.vite, 'optionalAccess', _142 => _142.outDir]), () => ( _optionalChain([base, 'access', _143 => _143.vite, 'optionalAccess', _144 => _144.outDir]))),
228
+ assetsDir: _nullishCoalesce(_optionalChain([override, 'access', _145 => _145.vite, 'optionalAccess', _146 => _146.assetsDir]), () => ( _optionalChain([base, 'access', _147 => _147.vite, 'optionalAccess', _148 => _148.assetsDir])))
229
+ }
230
+ };
231
+ }
232
+ function mergeUnpeekConfig(base, override) {
233
+ if (!override) {
234
+ return { ...base };
235
+ }
236
+ const effectiveBase = override.profile ? mergeTwoConfigs(base, _chunkURPPSTHZcjs.PRESETS[override.profile]) : base;
237
+ return mergeTwoConfigs(effectiveBase, override);
238
+ }
239
+ function findConfigFile(cwd = process.cwd()) {
240
+ const root = cwd ? _path.resolve.call(void 0, cwd) : process.cwd();
241
+ for (const filename of CONFIG_CANDIDATES) {
242
+ const candidate = _path.join.call(void 0, root, filename);
243
+ if (_fs.existsSync.call(void 0, candidate)) {
244
+ return candidate;
245
+ }
246
+ }
247
+ return null;
248
+ }
249
+ function formatErr(err) {
250
+ return err instanceof Error ? err.message : String(err);
251
+ }
252
+ function unwrapDefaultExport(raw) {
253
+ if (isRecord(raw) && "default" in raw && !("framework" in raw) && !("vault" in raw) && !("hotPath" in raw) && !("shield" in raw)) {
254
+ return raw.default;
255
+ }
256
+ return raw;
257
+ }
258
+ function validateAndNormalizeConfig(raw, configPath) {
259
+ if (raw === void 0) {
260
+ return {};
261
+ }
262
+ if (!isRecord(raw)) {
263
+ throw new (0, _chunkL6BOM5VScjs.UnpeekError)(
264
+ "ERR_CONFIG_INVALID",
265
+ `Configuration at "${configPath}" must export or contain a JSON object.`
266
+ );
267
+ }
268
+ try {
269
+ return normalizeConfig(raw);
270
+ } catch (err) {
271
+ if (err instanceof _chunkL6BOM5VScjs.UnpeekError) throw err;
272
+ throw new (0, _chunkL6BOM5VScjs.UnpeekError)(
273
+ "ERR_CONFIG_INVALID",
274
+ `Invalid configuration at "${configPath}": ${formatErr(err)}`,
275
+ { cause: err }
276
+ );
277
+ }
278
+ }
279
+ function parseJsonConfig(content, configPath) {
280
+ let parsed;
281
+ try {
282
+ parsed = JSON.parse(content);
283
+ } catch (err) {
284
+ throw new (0, _chunkL6BOM5VScjs.UnpeekError)(
285
+ "ERR_CONFIG_INVALID",
286
+ `Failed to parse JSON configuration at "${configPath}": ${formatErr(err)}`,
287
+ { cause: err }
288
+ );
289
+ }
290
+ return validateAndNormalizeConfig(parsed, configPath);
291
+ }
292
+ async function loadUnpeekConfig(cwd = process.cwd(), explicitConfig) {
293
+ const root = cwd ? _path.resolve.call(void 0, cwd) : process.cwd();
294
+ const configPath = findConfigFile(root);
295
+ let parsedConfig = {};
296
+ if (configPath) {
297
+ const ext = _path.extname.call(void 0, configPath).toLowerCase();
298
+ if (ext === ".json") {
299
+ let content;
300
+ try {
301
+ content = await _fs2.default.promises.readFile(configPath, "utf8");
302
+ } catch (err) {
303
+ throw new (0, _chunkL6BOM5VScjs.UnpeekError)(
304
+ "ERR_CONFIG_LOAD",
305
+ `Failed to read configuration at "${configPath}": ${formatErr(err)}`,
306
+ { cause: err }
307
+ );
308
+ }
309
+ parsedConfig = parseJsonConfig(content, configPath);
310
+ } else {
311
+ let raw;
312
+ try {
313
+ const fileUrl = _url.pathToFileURL.call(void 0, configPath).href;
314
+ const mod = await Promise.resolve().then(() => _interopRequireWildcard(require(fileUrl)));
315
+ raw = isRecord(mod) && "default" in mod ? mod.default : mod;
316
+ if (typeof raw === "function") {
317
+ raw = await raw();
318
+ }
319
+ raw = unwrapDefaultExport(raw);
320
+ } catch (importErr) {
321
+ try {
322
+ const req = _module.createRequire.call(void 0, configPath);
323
+ let cjsRaw = req(configPath);
324
+ cjsRaw = unwrapDefaultExport(cjsRaw);
325
+ if (typeof cjsRaw === "function") {
326
+ cjsRaw = await cjsRaw();
327
+ }
328
+ raw = cjsRaw;
329
+ } catch (e) {
330
+ throw new (0, _chunkL6BOM5VScjs.UnpeekError)(
331
+ "ERR_CONFIG_LOAD",
332
+ `Failed to load configuration at "${configPath}": ${formatErr(importErr)}`,
333
+ { cause: importErr }
334
+ );
335
+ }
336
+ }
337
+ parsedConfig = validateAndNormalizeConfig(_nullishCoalesce(raw, () => ( {})), configPath);
338
+ }
339
+ }
340
+ const baseConfig = mergeUnpeekConfig(DEFAULT_CONFIG, parsedConfig);
341
+ return explicitConfig ? mergeUnpeekConfig(baseConfig, explicitConfig) : baseConfig;
342
+ }
343
+
344
+ // src/config.ts
345
+ function defineConfig(config) {
346
+ return config;
347
+ }
348
+
349
+
350
+
351
+
352
+ exports.loadUnpeekConfig = loadUnpeekConfig; exports.defineConfig = defineConfig;