unpeek 3.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.
- package/README.md +27 -13
- package/README.tr.md +37 -23
- package/dist/adapters/esbuild.cjs +5 -5
- package/dist/adapters/esbuild.d.cts +3 -1
- package/dist/adapters/esbuild.d.ts +2 -2
- package/dist/adapters/esbuild.js +5 -3
- package/dist/adapters/next/adapter.cjs +7 -6
- package/dist/adapters/next/adapter.d.cts +1 -1
- package/dist/adapters/next/adapter.d.ts +1 -1
- package/dist/adapters/next/adapter.js +6 -5
- package/dist/adapters/next/index.cjs +7 -6
- package/dist/adapters/next/index.js +6 -5
- package/dist/adapters/rollup.cjs +5 -5
- package/dist/adapters/rollup.d.cts +3 -1
- package/dist/adapters/rollup.d.ts +2 -2
- package/dist/adapters/rollup.js +5 -3
- package/dist/adapters/rspack.cjs +5 -4
- package/dist/adapters/rspack.d.cts +1 -1
- package/dist/adapters/rspack.d.ts +1 -1
- package/dist/adapters/rspack.js +3 -2
- package/dist/adapters/vite.cjs +5 -5
- package/dist/adapters/vite.d.cts +3 -1
- package/dist/adapters/vite.d.ts +2 -2
- package/dist/adapters/vite.js +5 -3
- package/dist/adapters/webpack.cjs +5 -5
- package/dist/adapters/webpack.d.cts +3 -1
- package/dist/adapters/webpack.d.ts +2 -2
- package/dist/adapters/webpack.js +5 -3
- package/dist/browser.cjs +3 -3
- package/dist/browser.d.cts +20 -17
- package/dist/browser.d.ts +20 -17
- package/dist/browser.js +2 -2
- package/dist/{chunk-BPRSCRUZ.js → chunk-2JU3V7HW.js} +6 -3
- package/dist/chunk-3LWXEJU6.cjs +1054 -0
- package/dist/{chunk-IZIWDJRF.js → chunk-4FNZNIBW.js} +2675 -651
- package/dist/chunk-7HXLHLLQ.cjs +503 -0
- package/dist/chunk-ADKRENAP.js +1054 -0
- package/dist/{chunk-FCF2EGPM.js → chunk-EN6QVR6P.js} +12 -3
- package/dist/chunk-HHC7BUCK.js +503 -0
- package/dist/{chunk-IAD5DV3D.cjs → chunk-KLYFNMKS.cjs} +2812 -788
- package/dist/{chunk-IEBVL5BT.cjs → chunk-URPPSTHZ.cjs} +12 -3
- package/dist/chunk-VG4Y26ZN.cjs +429 -0
- package/dist/{chunk-IICVBTR2.js → chunk-W77DAC3H.js} +22 -3
- package/dist/{chunk-ONM2CSTU.cjs → chunk-X6EETCO6.cjs} +64 -45
- package/dist/chunk-YCRMTXOE.js +429 -0
- package/dist/{chunk-6TDCSIRZ.cjs → chunk-ZG7BIAUI.cjs} +9 -6
- package/dist/cli/index.js +3693 -1141
- package/dist/{config-CfXY_iDD.d.ts → config-Y6JwVGwX.d.cts} +15 -1
- package/dist/{config-CfXY_iDD.d.cts → config-Y6JwVGwX.d.ts} +15 -1
- package/dist/config.cjs +3 -3
- package/dist/config.d.cts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +2 -2
- package/dist/{index-CjRTNPlj.d.cts → index-0O1WSfVP.d.ts} +7 -1
- package/dist/{index-Cm1IloVm.d.ts → index-COVHErnx.d.cts} +7 -1
- package/dist/index.cjs +65 -264
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +59 -258
- package/dist/plugins/unplugin.cjs +4 -3
- package/dist/plugins/unplugin.js +3 -2
- package/dist/{types-DYQIzGf6.d.cts → types-CMtZnV8C.d.ts} +3 -3
- package/dist/{types-ZHAFdOd3.d.ts → types-D93PuOOl.d.cts} +3 -3
- package/package.json +1 -1
- package/dist/chunk-APWMNVAZ.js +0 -764
- package/dist/chunk-DUK2SECY.js +0 -83
- package/dist/chunk-I6GXEHFR.cjs +0 -764
- package/dist/chunk-RXUY3MPH.cjs +0 -83
|
@@ -1,6 +1,6 @@
|
|
|
1
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
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkURPPSTHZcjs = require('./chunk-URPPSTHZ.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkL6BOM5VScjs = require('./chunk-L6BOM5VS.cjs');
|
|
@@ -19,6 +19,8 @@ var CONFIG_CANDIDATES = [
|
|
|
19
19
|
var DEFAULT_CONFIG = {
|
|
20
20
|
framework: void 0,
|
|
21
21
|
target: "browser",
|
|
22
|
+
tier: "Tier 2",
|
|
23
|
+
coldFlow: true,
|
|
22
24
|
outDir: void 0,
|
|
23
25
|
extensions: [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs"],
|
|
24
26
|
publicDirs: ["public", "static"],
|
|
@@ -35,6 +37,10 @@ var DEFAULT_CONFIG = {
|
|
|
35
37
|
excludeComponents: [],
|
|
36
38
|
maxPipelineCallers: 2
|
|
37
39
|
},
|
|
40
|
+
critical: {
|
|
41
|
+
include: [],
|
|
42
|
+
annotation: "@unpeek-critical"
|
|
43
|
+
},
|
|
38
44
|
vault: {
|
|
39
45
|
minStringLength: 4,
|
|
40
46
|
customDirectives: [],
|
|
@@ -46,7 +52,7 @@ var DEFAULT_CONFIG = {
|
|
|
46
52
|
polymorphicDecoys: true
|
|
47
53
|
},
|
|
48
54
|
mangler: {
|
|
49
|
-
minLength:
|
|
55
|
+
minLength: 1,
|
|
50
56
|
reservedIdentifiers: [],
|
|
51
57
|
excludePrefixes: [],
|
|
52
58
|
excludePatterns: []
|
|
@@ -119,94 +125,107 @@ function normalizeConfig(raw) {
|
|
|
119
125
|
return result;
|
|
120
126
|
}
|
|
121
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;
|
|
122
134
|
return {
|
|
123
135
|
...base,
|
|
124
136
|
framework: _nullishCoalesce(override.framework, () => ( base.framework)),
|
|
125
137
|
target: _nullishCoalesce(override.target, () => ( base.target)),
|
|
126
138
|
profile: _nullishCoalesce(override.profile, () => ( base.profile)),
|
|
139
|
+
tier: _nullishCoalesce(override.tier, () => ( base.tier)),
|
|
140
|
+
coldFlow: _nullishCoalesce(override.coldFlow, () => ( base.coldFlow)),
|
|
127
141
|
outDir: _nullishCoalesce(override.outDir, () => ( base.outDir)),
|
|
128
142
|
scrubPaths: _nullishCoalesce(override.scrubPaths, () => ( base.scrubPaths)),
|
|
129
143
|
extensions: override.extensions ? [...override.extensions] : base.extensions ? [...base.extensions] : void 0,
|
|
130
144
|
publicDirs: override.publicDirs ? [...override.publicDirs] : base.publicDirs ? [...base.publicDirs] : void 0,
|
|
131
145
|
filter: {
|
|
132
|
-
include: _optionalChain([override, 'access',
|
|
133
|
-
exclude: _optionalChain([override, 'access',
|
|
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] : []
|
|
134
148
|
},
|
|
135
149
|
hotPath: {
|
|
136
150
|
customAnimationCalls: mergeStringArrays(
|
|
137
|
-
_optionalChain([base, 'access',
|
|
138
|
-
_optionalChain([override, 'access',
|
|
151
|
+
_optionalChain([base, 'access', _17 => _17.hotPath, 'optionalAccess', _18 => _18.customAnimationCalls]),
|
|
152
|
+
_optionalChain([override, 'access', _19 => _19.hotPath, 'optionalAccess', _20 => _20.customAnimationCalls])
|
|
139
153
|
),
|
|
140
154
|
importSources: {
|
|
141
|
-
..._nullishCoalesce(_optionalChain([base, 'access',
|
|
142
|
-
..._nullishCoalesce(_optionalChain([override, 'access',
|
|
155
|
+
..._nullishCoalesce(_optionalChain([base, 'access', _21 => _21.hotPath, 'optionalAccess', _22 => _22.importSources]), () => ( {})),
|
|
156
|
+
..._nullishCoalesce(_optionalChain([override, 'access', _23 => _23.hotPath, 'optionalAccess', _24 => _24.importSources]), () => ( {}))
|
|
143
157
|
},
|
|
144
|
-
hookPattern: _nullishCoalesce(_optionalChain([override, 'access',
|
|
158
|
+
hookPattern: _nullishCoalesce(_optionalChain([override, 'access', _25 => _25.hotPath, 'optionalAccess', _26 => _26.hookPattern]), () => ( _optionalChain([base, 'access', _27 => _27.hotPath, 'optionalAccess', _28 => _28.hookPattern]))),
|
|
145
159
|
customHooks: mergeStringArrays(
|
|
146
|
-
_optionalChain([base, 'access',
|
|
147
|
-
_optionalChain([override, 'access',
|
|
160
|
+
_optionalChain([base, 'access', _29 => _29.hotPath, 'optionalAccess', _30 => _30.customHooks]),
|
|
161
|
+
_optionalChain([override, 'access', _31 => _31.hotPath, 'optionalAccess', _32 => _32.customHooks])
|
|
148
162
|
),
|
|
149
163
|
arrayHofMethods: mergeStringArrays(
|
|
150
|
-
_optionalChain([base, 'access',
|
|
151
|
-
_optionalChain([override, 'access',
|
|
164
|
+
_optionalChain([base, 'access', _33 => _33.hotPath, 'optionalAccess', _34 => _34.arrayHofMethods]),
|
|
165
|
+
_optionalChain([override, 'access', _35 => _35.hotPath, 'optionalAccess', _36 => _36.arrayHofMethods])
|
|
152
166
|
),
|
|
153
|
-
eventHandlerRegex: _nullishCoalesce(_optionalChain([override, 'access',
|
|
154
|
-
maxPipelineCallers: _nullishCoalesce(_nullishCoalesce(_optionalChain([override, 'access',
|
|
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)),
|
|
155
169
|
hocWrappers: mergeStringArrays(
|
|
156
|
-
_optionalChain([base, 'access',
|
|
157
|
-
_optionalChain([override, 'access',
|
|
170
|
+
_optionalChain([base, 'access', _45 => _45.hotPath, 'optionalAccess', _46 => _46.hocWrappers]),
|
|
171
|
+
_optionalChain([override, 'access', _47 => _47.hotPath, 'optionalAccess', _48 => _48.hocWrappers])
|
|
158
172
|
),
|
|
159
173
|
excludeComponents: mergeStringArrays(
|
|
160
|
-
_optionalChain([base, 'access',
|
|
161
|
-
_optionalChain([override, 'access',
|
|
174
|
+
_optionalChain([base, 'access', _49 => _49.hotPath, 'optionalAccess', _50 => _50.excludeComponents]),
|
|
175
|
+
_optionalChain([override, 'access', _51 => _51.hotPath, 'optionalAccess', _52 => _52.excludeComponents])
|
|
162
176
|
)
|
|
163
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,
|
|
164
183
|
vault: {
|
|
165
|
-
minStringLength: _nullishCoalesce(_nullishCoalesce(_optionalChain([override, 'access',
|
|
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)),
|
|
166
185
|
customDirectives: mergeStringArrays(
|
|
167
|
-
_optionalChain([base, 'access',
|
|
168
|
-
_optionalChain([override, 'access',
|
|
186
|
+
_optionalChain([base, 'access', _65 => _65.vault, 'optionalAccess', _66 => _66.customDirectives]),
|
|
187
|
+
_optionalChain([override, 'access', _67 => _67.vault, 'optionalAccess', _68 => _68.customDirectives])
|
|
169
188
|
),
|
|
170
189
|
reservedProps: mergeStringArrays(
|
|
171
|
-
_optionalChain([base, 'access',
|
|
172
|
-
_optionalChain([override, 'access',
|
|
190
|
+
_optionalChain([base, 'access', _69 => _69.vault, 'optionalAccess', _70 => _70.reservedProps]),
|
|
191
|
+
_optionalChain([override, 'access', _71 => _71.vault, 'optionalAccess', _72 => _72.reservedProps])
|
|
173
192
|
),
|
|
174
|
-
cssFramework: _nullishCoalesce(_nullishCoalesce(_optionalChain([override, 'access',
|
|
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")),
|
|
175
194
|
semanticAnchors: {
|
|
176
|
-
patterns: _nullishCoalesce(clonePatterns(_optionalChain([override, 'access',
|
|
177
|
-
excludeUiClasses: _nullishCoalesce(_nullishCoalesce(_optionalChain([override, 'access',
|
|
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))
|
|
178
197
|
},
|
|
179
|
-
polymorphicDecoys: _nullishCoalesce(_nullishCoalesce(_optionalChain([override, 'access',
|
|
180
|
-
fragmented: _nullishCoalesce(_optionalChain([override, 'access',
|
|
181
|
-
fragmentCount: _nullishCoalesce(_optionalChain([override, 'access',
|
|
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])))
|
|
182
201
|
},
|
|
183
202
|
mangler: {
|
|
184
|
-
minLength: _nullishCoalesce(_nullishCoalesce(_optionalChain([override, 'access',
|
|
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)),
|
|
185
204
|
reservedIdentifiers: mergeStringArrays(
|
|
186
|
-
_optionalChain([base, 'access',
|
|
187
|
-
_optionalChain([override, 'access',
|
|
205
|
+
_optionalChain([base, 'access', _105 => _105.mangler, 'optionalAccess', _106 => _106.reservedIdentifiers]),
|
|
206
|
+
_optionalChain([override, 'access', _107 => _107.mangler, 'optionalAccess', _108 => _108.reservedIdentifiers])
|
|
188
207
|
),
|
|
189
208
|
excludePrefixes: mergeStringArrays(
|
|
190
|
-
_optionalChain([base, 'access',
|
|
191
|
-
_optionalChain([override, 'access',
|
|
209
|
+
_optionalChain([base, 'access', _109 => _109.mangler, 'optionalAccess', _110 => _110.excludePrefixes]),
|
|
210
|
+
_optionalChain([override, 'access', _111 => _111.mangler, 'optionalAccess', _112 => _112.excludePrefixes])
|
|
192
211
|
),
|
|
193
|
-
excludePatterns: _nullishCoalesce(clonePatterns(_optionalChain([override, 'access',
|
|
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]))))
|
|
194
213
|
},
|
|
195
214
|
shield: {
|
|
196
|
-
detectHeadless: _nullishCoalesce(_nullishCoalesce(_optionalChain([override, 'access',
|
|
197
|
-
deterrentMode: _nullishCoalesce(_nullishCoalesce(_optionalChain([override, 'access',
|
|
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"))
|
|
198
217
|
},
|
|
199
218
|
sourcemaps: {
|
|
200
|
-
keepPrivate: _nullishCoalesce(_nullishCoalesce(_optionalChain([override, 'access',
|
|
201
|
-
vaultDir: _nullishCoalesce(_nullishCoalesce(_optionalChain([override, 'access',
|
|
202
|
-
stripComments: _nullishCoalesce(_nullishCoalesce(_optionalChain([override, 'access',
|
|
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))
|
|
203
222
|
},
|
|
204
223
|
next: {
|
|
205
|
-
distDir: _nullishCoalesce(_optionalChain([override, 'access',
|
|
224
|
+
distDir: _nullishCoalesce(_optionalChain([override, 'access', _137 => _137.next, 'optionalAccess', _138 => _138.distDir]), () => ( _optionalChain([base, 'access', _139 => _139.next, 'optionalAccess', _140 => _140.distDir])))
|
|
206
225
|
},
|
|
207
226
|
vite: {
|
|
208
|
-
outDir: _nullishCoalesce(_optionalChain([override, 'access',
|
|
209
|
-
assetsDir: _nullishCoalesce(_optionalChain([override, 'access',
|
|
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])))
|
|
210
229
|
}
|
|
211
230
|
};
|
|
212
231
|
}
|
|
@@ -214,7 +233,7 @@ function mergeUnpeekConfig(base, override) {
|
|
|
214
233
|
if (!override) {
|
|
215
234
|
return { ...base };
|
|
216
235
|
}
|
|
217
|
-
const effectiveBase = override.profile ? mergeTwoConfigs(base,
|
|
236
|
+
const effectiveBase = override.profile ? mergeTwoConfigs(base, _chunkURPPSTHZcjs.PRESETS[override.profile]) : base;
|
|
218
237
|
return mergeTwoConfigs(effectiveBase, override);
|
|
219
238
|
}
|
|
220
239
|
function findConfigFile(cwd = process.cwd()) {
|
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
import {
|
|
2
|
+
chainSourceMaps,
|
|
3
|
+
computeDeterministicDebugId,
|
|
4
|
+
extractDebugId,
|
|
5
|
+
flattenSourceMapSections,
|
|
6
|
+
replaceOrAppendDebugId,
|
|
7
|
+
shiftSourceMapLines,
|
|
8
|
+
stripDebugIdComments,
|
|
9
|
+
stripSourceMapComments
|
|
10
|
+
} from "./chunk-ADKRENAP.js";
|
|
11
|
+
import {
|
|
12
|
+
computeFnv1aHash,
|
|
13
|
+
deriveWindowKeySymbol,
|
|
14
|
+
generateRuntimeShield,
|
|
15
|
+
transformJavaScript
|
|
16
|
+
} from "./chunk-4FNZNIBW.js";
|
|
17
|
+
|
|
18
|
+
// src/plugins/unplugin.ts
|
|
19
|
+
import fs from "fs";
|
|
20
|
+
import path from "path";
|
|
21
|
+
import { createUnplugin } from "unplugin";
|
|
22
|
+
var ENTRY_CHUNK_PATTERN = /(?:^|\/)(?:webpack|main|index|runtime|turbopack|pages\/_app|pages\/index)(?:[-._/]|$)/i;
|
|
23
|
+
var SW_OR_WORKBOX_PATTERN = /(?:^|\/)(?:sw|service-worker|workbox-[^/]+)\.(?:js|mjs|cjs)$|\.worker\.min\.(?:js|mjs|cjs)$/i;
|
|
24
|
+
function isSupportedJsAsset(fileName) {
|
|
25
|
+
const clean = fileName.replace(/\\/g, "/").split("?")[0].split("#")[0].toLowerCase();
|
|
26
|
+
return clean.endsWith(".js") || clean.endsWith(".mjs") || clean.endsWith(".cjs");
|
|
27
|
+
}
|
|
28
|
+
function isExcludedClientAsset(fileName, config) {
|
|
29
|
+
const norm = fileName.replace(/\\/g, "/").split("?")[0].split("#")[0];
|
|
30
|
+
if (norm.includes("server/") || norm.includes("ssr/") || norm.includes("node_modules/")) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
if (config?.target !== "worker" && SW_OR_WORKBOX_PATTERN.test(norm)) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
function createWebpackRawSource(sources, content) {
|
|
39
|
+
if (sources && typeof sources.RawSource === "function") {
|
|
40
|
+
return new sources.RawSource(content);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
source: () => content,
|
|
44
|
+
buffer: () => Buffer.from(content, "utf8"),
|
|
45
|
+
size: () => Buffer.byteLength(content, "utf8"),
|
|
46
|
+
map: () => null,
|
|
47
|
+
sourceAndMap: () => ({ source: content, map: null }),
|
|
48
|
+
updateHash: (hash) => {
|
|
49
|
+
hash.update(content);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
var unpeekPlugin = createUnplugin((options = {}) => {
|
|
54
|
+
const config = options.config;
|
|
55
|
+
const baseSeed = typeof options.seed === "number" ? options.seed : Math.floor(Math.random() * 2147483647) || 322420463;
|
|
56
|
+
const deterrentMode = options.deterrentMode ?? config?.shield?.deterrentMode ?? "passive";
|
|
57
|
+
const detectHeadless = options.detectHeadless ?? config?.shield?.detectHeadless ?? false;
|
|
58
|
+
const injectRuntimeShield = options.injectRuntimeShield ?? true;
|
|
59
|
+
const minStringLength = options.minStringLength ?? config?.vault?.minStringLength ?? 4;
|
|
60
|
+
const aggressive = options.aggressive ?? false;
|
|
61
|
+
const masterSym = deriveWindowKeySymbol(baseSeed);
|
|
62
|
+
const masterShield = injectRuntimeShield ? generateRuntimeShield({
|
|
63
|
+
seed: baseSeed,
|
|
64
|
+
deterrentMode,
|
|
65
|
+
detectHeadless,
|
|
66
|
+
windowKeySymbol: masterSym
|
|
67
|
+
}) : void 0;
|
|
68
|
+
const transformChunk = (rawCode, fileName, isEntry, inputMap, requestMap = false) => {
|
|
69
|
+
const normalizedFileName = fileName.replace(/\\/g, "/").split("?")[0].split("#")[0];
|
|
70
|
+
if (!isSupportedJsAsset(normalizedFileName) || isExcludedClientAsset(normalizedFileName, config)) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
const fileDebugId = extractDebugId(rawCode);
|
|
74
|
+
const shouldStripComments = config?.sourcemaps?.stripComments !== false;
|
|
75
|
+
let codeToTransform = rawCode;
|
|
76
|
+
if (shouldStripComments && rawCode.includes("sourceMappingURL=")) {
|
|
77
|
+
codeToTransform = stripSourceMapComments(rawCode).code;
|
|
78
|
+
}
|
|
79
|
+
const shouldInjectShield = injectRuntimeShield && isEntry;
|
|
80
|
+
const chunkSeed = computeFnv1aHash(fileName, baseSeed);
|
|
81
|
+
const transformOptions = {
|
|
82
|
+
seed: chunkSeed,
|
|
83
|
+
minStringLength,
|
|
84
|
+
filename: fileName,
|
|
85
|
+
injectRuntimeShield: shouldInjectShield,
|
|
86
|
+
skipShieldPreamble: true,
|
|
87
|
+
shieldCoupled: injectRuntimeShield,
|
|
88
|
+
windowKeySymbol: masterSym,
|
|
89
|
+
expectedDelta: masterShield?.expectedDelta,
|
|
90
|
+
deterrentMode,
|
|
91
|
+
detectHeadless,
|
|
92
|
+
aggressive,
|
|
93
|
+
config
|
|
94
|
+
};
|
|
95
|
+
transformOptions.generateMap = requestMap || Boolean(inputMap);
|
|
96
|
+
transformOptions.rootDir = process.cwd();
|
|
97
|
+
const result = transformJavaScript(codeToTransform, transformOptions);
|
|
98
|
+
let finalCode = result.code;
|
|
99
|
+
let preambleLineOffset = 0;
|
|
100
|
+
const integrityCheckFnName = masterShield && "integrityCheckFnName" in masterShield ? masterShield.integrityCheckFnName : void 0;
|
|
101
|
+
if (shouldInjectShield && masterShield?.preambleCode && !finalCode.includes("(function _u$") && (!integrityCheckFnName || !finalCode.includes(integrityCheckFnName)) && !finalCode.startsWith(masterShield.preambleCode)) {
|
|
102
|
+
const prefix = `${masterShield.preambleCode}
|
|
103
|
+
`;
|
|
104
|
+
preambleLineOffset = (prefix.match(/\n/g) ?? []).length;
|
|
105
|
+
finalCode = `${prefix}${finalCode}`;
|
|
106
|
+
}
|
|
107
|
+
const rawTransformMap = result.sourceMap;
|
|
108
|
+
const shiftedTransformMap = rawTransformMap ? shiftSourceMapLines(rawTransformMap, preambleLineOffset) : void 0;
|
|
109
|
+
let composedMap = null;
|
|
110
|
+
if (shiftedTransformMap && inputMap) {
|
|
111
|
+
composedMap = chainSourceMaps(shiftedTransformMap, inputMap);
|
|
112
|
+
} else if (shiftedTransformMap) {
|
|
113
|
+
composedMap = shiftedTransformMap;
|
|
114
|
+
} else if (inputMap) {
|
|
115
|
+
composedMap = flattenSourceMapSections(inputMap);
|
|
116
|
+
}
|
|
117
|
+
const inputMapDebugId = inputMap?.debugId ?? inputMap?.debug_id;
|
|
118
|
+
const hadDebugId = Boolean(fileDebugId || inputMapDebugId || result.debugId);
|
|
119
|
+
if (hadDebugId) {
|
|
120
|
+
const codeWithoutDebugId = stripDebugIdComments(finalCode);
|
|
121
|
+
const mintedDebugId = computeDeterministicDebugId(
|
|
122
|
+
codeWithoutDebugId,
|
|
123
|
+
composedMap?.mappings ?? ""
|
|
124
|
+
);
|
|
125
|
+
finalCode = replaceOrAppendDebugId(codeWithoutDebugId, mintedDebugId);
|
|
126
|
+
if (composedMap) {
|
|
127
|
+
composedMap.debugId = mintedDebugId;
|
|
128
|
+
delete composedMap.debug_id;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (composedMap) {
|
|
132
|
+
if (!Object.prototype.hasOwnProperty.call(composedMap, "toString")) {
|
|
133
|
+
Object.defineProperty(composedMap, "toString", {
|
|
134
|
+
enumerable: false,
|
|
135
|
+
configurable: true,
|
|
136
|
+
value() {
|
|
137
|
+
return JSON.stringify(this);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
code: finalCode,
|
|
144
|
+
map: composedMap
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
const renderChunkHandler = (code, chunk) => {
|
|
148
|
+
const normalizedFileName = chunk.fileName.replace(/\\/g, "/").split("?")[0].split("#")[0];
|
|
149
|
+
const isEntry = chunk.isEntry !== void 0 ? chunk.isEntry : ENTRY_CHUNK_PATTERN.test(normalizedFileName);
|
|
150
|
+
const res = transformChunk(code, chunk.fileName, isEntry, void 0, true);
|
|
151
|
+
if (!res) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
code: res.code,
|
|
156
|
+
map: res.map ?? null
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
const attachWebpackLikeProcessAssets = (compiler, framework) => {
|
|
160
|
+
compiler.hooks.thisCompilation.tap("unpeek", (compilation) => {
|
|
161
|
+
const stage = (framework === "rspack" ? compiler.rspack?.Compilation?.PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE : compiler.webpack?.Compilation?.PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE) ?? 700;
|
|
162
|
+
compilation.hooks.processAssets.tap(
|
|
163
|
+
{ name: "unpeek", stage },
|
|
164
|
+
(assets) => {
|
|
165
|
+
const entryFiles = /* @__PURE__ */ new Set();
|
|
166
|
+
if (compilation.entrypoints && typeof compilation.entrypoints.values === "function") {
|
|
167
|
+
for (const ep of compilation.entrypoints.values()) {
|
|
168
|
+
if (ep && typeof ep.getFiles === "function") {
|
|
169
|
+
for (const f of ep.getFiles()) {
|
|
170
|
+
entryFiles.add(String(f).replace(/\\/g, "/").split("?")[0]);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (compilation.chunks) {
|
|
176
|
+
for (const chunk of compilation.chunks) {
|
|
177
|
+
const chunkIsEntry = typeof chunk.hasRuntime === "function" && chunk.hasRuntime() || typeof chunk.canBeInitial === "function" && chunk.canBeInitial();
|
|
178
|
+
if (chunkIsEntry && chunk.files) {
|
|
179
|
+
for (const f of chunk.files) {
|
|
180
|
+
entryFiles.add(String(f).replace(/\\/g, "/").split("?")[0]);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
const sources = (framework === "rspack" ? compiler.rspack?.sources : compiler.webpack?.sources) ?? compiler.webpack?.sources ?? compiler.rspack?.sources;
|
|
186
|
+
for (const assetName of Object.keys(assets)) {
|
|
187
|
+
const normalizedName = assetName.replace(/\\/g, "/").split("?")[0];
|
|
188
|
+
if (!isSupportedJsAsset(normalizedName) || isExcludedClientAsset(normalizedName, config)) {
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
const existingAsset = typeof compilation.getAsset === "function" ? compilation.getAsset(assetName) : { source: assets[assetName] };
|
|
192
|
+
const sourceObj = existingAsset?.source ?? assets[assetName];
|
|
193
|
+
if (!sourceObj) continue;
|
|
194
|
+
const rawContent = typeof sourceObj.source === "function" ? sourceObj.source() : sourceObj;
|
|
195
|
+
const code = Buffer.isBuffer(rawContent) ? rawContent.toString("utf8") : String(rawContent);
|
|
196
|
+
const mapAssetName = `${assetName}.map`;
|
|
197
|
+
const mapSourceObj = assets[mapAssetName];
|
|
198
|
+
let inputMap;
|
|
199
|
+
if (mapSourceObj) {
|
|
200
|
+
try {
|
|
201
|
+
const rawMap = typeof mapSourceObj.source === "function" ? mapSourceObj.source() : mapSourceObj;
|
|
202
|
+
const mapStr = Buffer.isBuffer(rawMap) ? rawMap.toString("utf8") : String(rawMap);
|
|
203
|
+
inputMap = JSON.parse(mapStr);
|
|
204
|
+
} catch {
|
|
205
|
+
}
|
|
206
|
+
} else if (typeof sourceObj.map === "function") {
|
|
207
|
+
try {
|
|
208
|
+
const m = sourceObj.map();
|
|
209
|
+
if (m && typeof m === "object") {
|
|
210
|
+
inputMap = m;
|
|
211
|
+
}
|
|
212
|
+
} catch {
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
const isEntry = entryFiles.size > 0 ? entryFiles.has(normalizedName) || ENTRY_CHUNK_PATTERN.test(normalizedName) : ENTRY_CHUNK_PATTERN.test(normalizedName);
|
|
216
|
+
const res = transformChunk(code, assetName, isEntry, inputMap, Boolean(inputMap));
|
|
217
|
+
if (!res) continue;
|
|
218
|
+
const newSource = createWebpackRawSource(sources, res.code);
|
|
219
|
+
if (typeof compilation.updateAsset === "function") {
|
|
220
|
+
compilation.updateAsset(assetName, newSource);
|
|
221
|
+
} else {
|
|
222
|
+
assets[assetName] = newSource;
|
|
223
|
+
}
|
|
224
|
+
if (res.map && mapSourceObj) {
|
|
225
|
+
const newMapSource = createWebpackRawSource(sources, JSON.stringify(res.map));
|
|
226
|
+
if (typeof compilation.updateAsset === "function") {
|
|
227
|
+
compilation.updateAsset(mapAssetName, newMapSource);
|
|
228
|
+
} else {
|
|
229
|
+
assets[mapAssetName] = newMapSource;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
);
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
return {
|
|
238
|
+
name: "unpeek",
|
|
239
|
+
enforce: "post",
|
|
240
|
+
// Preserved at top-level for direct unpeekPlugin.raw() unit test compatibility and Rollup
|
|
241
|
+
renderChunk: renderChunkHandler,
|
|
242
|
+
rollup: {
|
|
243
|
+
renderChunk: renderChunkHandler
|
|
244
|
+
},
|
|
245
|
+
vite: {
|
|
246
|
+
enforce: "post",
|
|
247
|
+
apply: "build",
|
|
248
|
+
renderChunk: void 0,
|
|
249
|
+
config(userConfig) {
|
|
250
|
+
if (config?.target === "worker") {
|
|
251
|
+
return void 0;
|
|
252
|
+
}
|
|
253
|
+
const existingWorkerPlugins = userConfig?.worker?.plugins;
|
|
254
|
+
return {
|
|
255
|
+
worker: {
|
|
256
|
+
plugins: () => {
|
|
257
|
+
const resolved = typeof existingWorkerPlugins === "function" ? existingWorkerPlugins() : Array.isArray(existingWorkerPlugins) ? existingWorkerPlugins : [];
|
|
258
|
+
const flat = (Array.isArray(resolved) ? resolved : [resolved]).flat(Infinity).filter(Boolean);
|
|
259
|
+
if (flat.some((p) => p && p.name === "unpeek")) {
|
|
260
|
+
return flat;
|
|
261
|
+
}
|
|
262
|
+
return [
|
|
263
|
+
...flat,
|
|
264
|
+
vitePlugin({
|
|
265
|
+
...options,
|
|
266
|
+
seed: baseSeed,
|
|
267
|
+
config: {
|
|
268
|
+
...config ?? {},
|
|
269
|
+
target: "worker"
|
|
270
|
+
}
|
|
271
|
+
})
|
|
272
|
+
];
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
},
|
|
277
|
+
generateBundle(_outputOptions, bundle) {
|
|
278
|
+
for (const [fileName, item] of Object.entries(bundle)) {
|
|
279
|
+
if (!item || item.type !== "chunk") continue;
|
|
280
|
+
const normalizedFileName = fileName.replace(/\\/g, "/").split("?")[0].split("#")[0];
|
|
281
|
+
if (!isSupportedJsAsset(normalizedFileName) || isExcludedClientAsset(normalizedFileName, config)) {
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
const mapAssetKey = `${fileName}.map`;
|
|
285
|
+
const mapAsset = bundle[mapAssetKey];
|
|
286
|
+
let inputMap = item.map && typeof item.map === "object" ? item.map : void 0;
|
|
287
|
+
if (!inputMap && mapAsset && mapAsset.type === "asset") {
|
|
288
|
+
try {
|
|
289
|
+
const rawMapStr = typeof mapAsset.source === "string" ? mapAsset.source : Buffer.from(mapAsset.source).toString("utf8");
|
|
290
|
+
inputMap = JSON.parse(rawMapStr);
|
|
291
|
+
} catch {
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
const isEntry = typeof item.isEntry === "boolean" ? item.isEntry : ENTRY_CHUNK_PATTERN.test(normalizedFileName);
|
|
295
|
+
const res = transformChunk(item.code, fileName, isEntry, inputMap, Boolean(inputMap));
|
|
296
|
+
if (!res) continue;
|
|
297
|
+
item.code = res.code;
|
|
298
|
+
if (res.map) {
|
|
299
|
+
item.map = res.map;
|
|
300
|
+
if (mapAsset && mapAsset.type === "asset") {
|
|
301
|
+
mapAsset.source = JSON.stringify(res.map);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
webpack(compiler) {
|
|
308
|
+
attachWebpackLikeProcessAssets(compiler, "webpack");
|
|
309
|
+
},
|
|
310
|
+
rspack(compiler) {
|
|
311
|
+
attachWebpackLikeProcessAssets(compiler, "rspack");
|
|
312
|
+
},
|
|
313
|
+
esbuild: {
|
|
314
|
+
config(buildOptions) {
|
|
315
|
+
buildOptions.metafile = true;
|
|
316
|
+
},
|
|
317
|
+
setup(build) {
|
|
318
|
+
build.onEnd(async (result) => {
|
|
319
|
+
const workDir = build.initialOptions.absWorkingDir ?? process.cwd();
|
|
320
|
+
const entryOutputs = /* @__PURE__ */ new Set();
|
|
321
|
+
if (result.metafile?.outputs) {
|
|
322
|
+
for (const [outKey, meta] of Object.entries(result.metafile.outputs)) {
|
|
323
|
+
if (meta && meta.entryPoint) {
|
|
324
|
+
entryOutputs.add(path.resolve(workDir, outKey));
|
|
325
|
+
entryOutputs.add(outKey.replace(/\\/g, "/"));
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
if (Array.isArray(result.outputFiles) && result.outputFiles.length > 0) {
|
|
330
|
+
const mapFilesByPath = /* @__PURE__ */ new Map();
|
|
331
|
+
for (const outFile of result.outputFiles) {
|
|
332
|
+
if (outFile.path.endsWith(".map")) {
|
|
333
|
+
mapFilesByPath.set(outFile.path, outFile);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
const jsOutCount = result.outputFiles.filter((f) => isSupportedJsAsset(f.path)).length;
|
|
337
|
+
for (const outFile of result.outputFiles) {
|
|
338
|
+
const normPath = outFile.path.replace(/\\/g, "/");
|
|
339
|
+
if (!isSupportedJsAsset(normPath) || isExcludedClientAsset(normPath, config)) {
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
const mapFile = mapFilesByPath.get(`${outFile.path}.map`);
|
|
343
|
+
let inputMap;
|
|
344
|
+
if (mapFile) {
|
|
345
|
+
try {
|
|
346
|
+
inputMap = JSON.parse(mapFile.text);
|
|
347
|
+
} catch {
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
const relFromWork = path.relative(workDir, outFile.path).replace(/\\/g, "/");
|
|
351
|
+
const isEntry = entryOutputs.size > 0 ? entryOutputs.has(outFile.path) || entryOutputs.has(relFromWork) || ENTRY_CHUNK_PATTERN.test(relFromWork) : ENTRY_CHUNK_PATTERN.test(relFromWork) || jsOutCount === 1;
|
|
352
|
+
const res = transformChunk(
|
|
353
|
+
outFile.text,
|
|
354
|
+
relFromWork || path.basename(outFile.path),
|
|
355
|
+
isEntry,
|
|
356
|
+
inputMap,
|
|
357
|
+
Boolean(inputMap)
|
|
358
|
+
);
|
|
359
|
+
if (!res) continue;
|
|
360
|
+
outFile.contents = Buffer.from(res.code, "utf8");
|
|
361
|
+
if (res.map && mapFile) {
|
|
362
|
+
mapFile.contents = Buffer.from(JSON.stringify(res.map), "utf8");
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
const diskOutputs = /* @__PURE__ */ new Set();
|
|
368
|
+
if (result.metafile?.outputs) {
|
|
369
|
+
for (const outKey of Object.keys(result.metafile.outputs)) {
|
|
370
|
+
const abs = path.resolve(workDir, outKey);
|
|
371
|
+
if (isSupportedJsAsset(abs)) {
|
|
372
|
+
diskOutputs.add(abs);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
} else if (build.initialOptions.outfile) {
|
|
376
|
+
const abs = path.resolve(workDir, build.initialOptions.outfile);
|
|
377
|
+
if (isSupportedJsAsset(abs)) {
|
|
378
|
+
diskOutputs.add(abs);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
const diskArr = Array.from(diskOutputs);
|
|
382
|
+
for (const absPath of diskArr) {
|
|
383
|
+
const relFromWork = path.relative(workDir, absPath).replace(/\\/g, "/");
|
|
384
|
+
if (isExcludedClientAsset(relFromWork, config)) continue;
|
|
385
|
+
if (!fs.existsSync(absPath)) continue;
|
|
386
|
+
const code = fs.readFileSync(absPath, "utf8");
|
|
387
|
+
const mapPath = `${absPath}.map`;
|
|
388
|
+
let inputMap;
|
|
389
|
+
if (fs.existsSync(mapPath)) {
|
|
390
|
+
try {
|
|
391
|
+
inputMap = JSON.parse(fs.readFileSync(mapPath, "utf8"));
|
|
392
|
+
} catch {
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
const isEntry = entryOutputs.size > 0 ? entryOutputs.has(absPath) || entryOutputs.has(relFromWork) || ENTRY_CHUNK_PATTERN.test(relFromWork) : ENTRY_CHUNK_PATTERN.test(relFromWork) || diskArr.length === 1;
|
|
396
|
+
const res = transformChunk(
|
|
397
|
+
code,
|
|
398
|
+
relFromWork || path.basename(absPath),
|
|
399
|
+
isEntry,
|
|
400
|
+
inputMap,
|
|
401
|
+
Boolean(inputMap)
|
|
402
|
+
);
|
|
403
|
+
if (!res) continue;
|
|
404
|
+
fs.writeFileSync(absPath, res.code, "utf8");
|
|
405
|
+
if (res.map && fs.existsSync(mapPath)) {
|
|
406
|
+
fs.writeFileSync(mapPath, JSON.stringify(res.map), "utf8");
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
});
|
|
414
|
+
var vitePlugin = unpeekPlugin.vite;
|
|
415
|
+
var webpackPlugin = unpeekPlugin.webpack;
|
|
416
|
+
var rollupPlugin = unpeekPlugin.rollup;
|
|
417
|
+
var esbuildPlugin = unpeekPlugin.esbuild;
|
|
418
|
+
var rspackPlugin = unpeekPlugin.rspack;
|
|
419
|
+
var unplugin_default = unpeekPlugin;
|
|
420
|
+
|
|
421
|
+
export {
|
|
422
|
+
unpeekPlugin,
|
|
423
|
+
vitePlugin,
|
|
424
|
+
webpackPlugin,
|
|
425
|
+
rollupPlugin,
|
|
426
|
+
esbuildPlugin,
|
|
427
|
+
rspackPlugin,
|
|
428
|
+
unplugin_default
|
|
429
|
+
};
|