@lynx-js/react-rsbuild-plugin 0.16.3 → 0.17.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/dist/index.js CHANGED
@@ -1 +1,1384 @@
1
- export { LAYERS, pluginReactLynx } from "./208.js";
1
+ import { createRequire } from "node:module";
2
+ import { pluginReactAlias } from "@lynx-js/react-alias-rsbuild-plugin";
3
+ import { LAYERS, ReactWebpackPlugin } from "@lynx-js/react-webpack-plugin";
4
+ import { LynxEncodePlugin, LynxTemplatePlugin, WebEncodePlugin } from "@lynx-js/template-webpack-plugin";
5
+ import node_path from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+ import { RuntimeWrapperWebpackPlugin } from "@lynx-js/runtime-wrapper-webpack-plugin";
8
+ import { ReactRefreshRspackPlugin } from "@lynx-js/react-refresh-webpack-plugin";
9
+ const DETECT_IMPORT_ERROR = 'react:detect-import-error';
10
+ const ALIAS_BACKGROUND_ONLY_MAIN = 'react:alias-background-only-main';
11
+ const ALIAS_BACKGROUND_ONLY_BACKGROUND = 'react:alias-background-only-background';
12
+ function applyBackgroundOnly(api) {
13
+ api.modifyBundlerChain(async (chain, { rspack })=>{
14
+ const __dirname = node_path.dirname(fileURLToPath(import.meta.url));
15
+ const { getImportResolver, getMainThreadResolver } = await import("./resolve.js");
16
+ const resolve = getImportResolver(rspack);
17
+ const resolveMainThread = getMainThreadResolver(rspack);
18
+ const [backgroundOnly, backgroundOnlyMainThread] = await Promise.all([
19
+ resolve('background-only'),
20
+ resolveMainThread('background-only')
21
+ ]);
22
+ chain.module.rule(ALIAS_BACKGROUND_ONLY_MAIN).issuerLayer(LAYERS.MAIN_THREAD).resolve.alias.set('background-only$', backgroundOnlyMainThread);
23
+ chain.module.rule(ALIAS_BACKGROUND_ONLY_BACKGROUND).issuerLayer(LAYERS.BACKGROUND).resolve.alias.set('background-only$', backgroundOnly);
24
+ chain.module.rule(DETECT_IMPORT_ERROR).test(backgroundOnlyMainThread).issuerLayer(LAYERS.MAIN_THREAD).use(DETECT_IMPORT_ERROR).loader(node_path.resolve(__dirname, 'loaders/invalid-import-error-loader')).options({
25
+ message: '\'background-only\' cannot be imported from a main-thread module.'
26
+ });
27
+ });
28
+ }
29
+ function applyCSS(api, options) {
30
+ const { enableRemoveCSSScope, enableCSSSelector, enableCSSInvalidation, targetSdkVersion } = options;
31
+ api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>mergeRsbuildConfig(config, {
32
+ output: {
33
+ injectStyles: false
34
+ }
35
+ }));
36
+ const __dirname = node_path.dirname(fileURLToPath(import.meta.url));
37
+ api.modifyBundlerChain(async (chain, { CHAIN_ID })=>{
38
+ const { CssExtractRspackPlugin } = await import("@lynx-js/css-extract-webpack-plugin");
39
+ const cssRules = [
40
+ CHAIN_ID.RULE.CSS,
41
+ CHAIN_ID.RULE.SASS,
42
+ CHAIN_ID.RULE.LESS,
43
+ CHAIN_ID.RULE.STYLUS
44
+ ];
45
+ cssRules.filter((rule)=>chain.module.rules.has(rule)).forEach((ruleName)=>{
46
+ const rule = chain.module.rule(ruleName);
47
+ const mainRuleName = ruleName === CHAIN_ID.RULE.CSS ? CHAIN_ID.ONE_OF.CSS_MAIN : ruleName;
48
+ const mainRule = rule.oneOf(mainRuleName);
49
+ const parentRuleEntries = rule.entries();
50
+ removeLightningCSS(mainRule);
51
+ mainRule.issuerLayer(LAYERS.BACKGROUND).use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader(CssExtractRspackPlugin.loader).end();
52
+ const uses = mainRule.uses.entries() ?? {};
53
+ const ruleEntries = mainRule.entries();
54
+ const cssLoader = uses[CHAIN_ID.USE.CSS];
55
+ if (!cssLoader) return;
56
+ const cssLoaderRule = cssLoader.entries();
57
+ const mainThreadLayerRule = chain.module.rule(`${ruleName}:${LAYERS.MAIN_THREAD}`).test(parentRuleEntries.test).merge(ruleEntries).issuerLayer(LAYERS.MAIN_THREAD);
58
+ if (void 0 !== parentRuleEntries.dependency) mainThreadLayerRule.merge({
59
+ dependency: parentRuleEntries.dependency
60
+ });
61
+ mainThreadLayerRule.use(CHAIN_ID.USE.IGNORE_CSS).loader(node_path.resolve(__dirname, './loaders/ignore-css-loader')).end().uses.merge(uses).delete(CHAIN_ID.USE.MINI_CSS_EXTRACT).delete(CHAIN_ID.USE.LIGHTNINGCSS).delete(CHAIN_ID.USE.CSS).end().use(CHAIN_ID.USE.CSS).after(CHAIN_ID.USE.IGNORE_CSS).merge(cssLoaderRule).options(normalizeCssLoaderOptions(cssLoaderRule.options, true)).end();
62
+ });
63
+ cssRules.filter((rule)=>rule && chain.module.rules.has(rule)).forEach((ruleName)=>{
64
+ const inlineRuleName = ruleName === CHAIN_ID.RULE.CSS ? CHAIN_ID.ONE_OF.CSS_INLINE : `${ruleName}-inline`;
65
+ const inlineRule = chain.module.rule(ruleName).oneOf(inlineRuleName);
66
+ removeLightningCSS(inlineRule);
67
+ });
68
+ function removeLightningCSS(rule) {
69
+ if (rule.uses.has(CHAIN_ID.USE.LIGHTNINGCSS)) rule.uses.delete(CHAIN_ID.USE.LIGHTNINGCSS);
70
+ }
71
+ chain.plugin(CHAIN_ID.PLUGIN.MINI_CSS_EXTRACT).tap(([options])=>[
72
+ {
73
+ ...options,
74
+ enableRemoveCSSScope: enableRemoveCSSScope ?? true,
75
+ enableCSSSelector,
76
+ enableCSSInvalidation,
77
+ targetSdkVersion,
78
+ cssPlugins: []
79
+ }
80
+ ]).init((_, args)=>new CssExtractRspackPlugin(...args)).end().end();
81
+ chain.module.when(void 0 === enableRemoveCSSScope, (module)=>module.rule('lynx.css.scoped').test(/\.css$/).resourceQuery({
82
+ and: [
83
+ /cssId/
84
+ ]
85
+ }).sideEffects(false));
86
+ });
87
+ }
88
+ const normalizeCssLoaderOptions = (options, exportOnlyLocals)=>{
89
+ if (options.modules && exportOnlyLocals) {
90
+ let { modules } = options;
91
+ modules = true === modules ? {
92
+ exportOnlyLocals: true
93
+ } : 'string' == typeof modules ? {
94
+ mode: modules,
95
+ exportOnlyLocals: true
96
+ } : {
97
+ ...modules,
98
+ exportOnlyLocals: true
99
+ };
100
+ return {
101
+ ...options,
102
+ modules
103
+ };
104
+ }
105
+ return options;
106
+ };
107
+ const PLUGIN_NAME_REACT = 'lynx:react';
108
+ const PLUGIN_NAME_TEMPLATE = 'lynx:template';
109
+ const PLUGIN_NAME_RUNTIME_WRAPPER = 'lynx:runtime-wrapper';
110
+ const PLUGIN_NAME_WEB = 'lynx:web';
111
+ const DEFAULT_DIST_PATH_INTERMEDIATE = '.rspeedy';
112
+ const DEFAULT_FILENAME_HASH = '.[contenthash:8]';
113
+ const EMPTY_HASH = '';
114
+ function applyEntry(api, options) {
115
+ const { compat, customCSSInheritanceList, debugInfoOutside, defaultDisplayLinear, enableAccessibilityElement, enableCSSInheritance, enableCSSInvalidation, enableCSSSelector, enableNewGesture, enableRemoveCSSScope, firstScreenSyncTiming, globalPropsMode, enableSSR, removeDescendantSelectorScope, targetSdkVersion, extractStr: originalExtractStr, experimental_isLazyBundle } = options;
116
+ api.modifyBundlerChain(async (chain, { environment, isDev, isProd })=>{
117
+ const mainThreadChunks = [];
118
+ const rsbuildConfig = api.getRsbuildConfig();
119
+ const userConfig = api.getRsbuildConfig('original');
120
+ const chunkSplitStrategy = userConfig.performance?.chunkSplit?.strategy;
121
+ const enableChunkSplitting = void 0 === userConfig.splitChunks ? chunkSplitStrategy ? 'all-in-one' !== chunkSplitStrategy : false !== rsbuildConfig.splitChunks : false !== rsbuildConfig.splitChunks;
122
+ const rspeedyConfig = 'rspeedy' === api.context.callerName ? api.useExposed(Symbol.for('rspeedy.api'))?.config : void 0;
123
+ const isRspeedy = 'rspeedy' === api.context.callerName;
124
+ if (isRspeedy) {
125
+ const entries = chain.entryPoints.entries() ?? {};
126
+ const isLynx = 'lynx' === environment.name || environment.name.startsWith('lynx-');
127
+ const isWeb = 'web' === environment.name || environment.name.startsWith('web-');
128
+ const { hmr, liveReload } = environment.config.dev ?? {};
129
+ const enabledHMR = isDev && !isWeb && false !== hmr;
130
+ const enabledLiveReload = isDev && !isWeb && false !== liveReload;
131
+ chain.entryPoints.clear();
132
+ Object.entries(entries).forEach(([entryName, entryPoint])=>{
133
+ const { imports } = getChunks(entryName, entryPoint.values());
134
+ const bundleFilename = 'object' == typeof rspeedyConfig?.output?.filename ? rspeedyConfig.output.filename.bundle ?? rspeedyConfig.output.filename.template : rspeedyConfig?.output?.filename;
135
+ let templateFilename;
136
+ let lazyBundleFilename;
137
+ if ('function' == typeof bundleFilename) {
138
+ templateFilename = bundleFilename({
139
+ lazyBundle: false,
140
+ entryName,
141
+ platform: environment.name
142
+ });
143
+ lazyBundleFilename = bundleFilename({
144
+ lazyBundle: true,
145
+ entryName: void 0,
146
+ platform: environment.name
147
+ }).replaceAll('[platform]', environment.name);
148
+ } else templateFilename = bundleFilename ?? '[name].[platform].bundle';
149
+ const mainThreadEntry = `${entryName}__main-thread`;
150
+ const mainThreadName = node_path.posix.join(isLynx ? DEFAULT_DIST_PATH_INTERMEDIATE : '', `${entryName}/main-thread.js`);
151
+ const backgroundName = node_path.posix.join(isLynx ? DEFAULT_DIST_PATH_INTERMEDIATE : '', getBackgroundFilename(entryName, environment.config, isProd, experimental_isLazyBundle));
152
+ const backgroundEntry = entryName;
153
+ mainThreadChunks.push(mainThreadName);
154
+ chain.entry(mainThreadEntry).add({
155
+ layer: LAYERS.MAIN_THREAD,
156
+ import: imports,
157
+ filename: mainThreadName
158
+ }).when(enabledHMR, (entry)=>{
159
+ const require = createRequire(import.meta.url);
160
+ entry.prepend({
161
+ layer: LAYERS.MAIN_THREAD,
162
+ import: require.resolve('@lynx-js/css-extract-webpack-plugin/runtime/hotModuleReplacement.lepus.cjs')
163
+ });
164
+ }).end().entry(backgroundEntry).add({
165
+ layer: LAYERS.BACKGROUND,
166
+ import: imports,
167
+ filename: backgroundName
168
+ }).when(enabledHMR, (entry)=>{
169
+ entry.prepend({
170
+ layer: LAYERS.BACKGROUND,
171
+ import: '@rspack/core/hot/dev-server'
172
+ }).prepend({
173
+ layer: LAYERS.BACKGROUND,
174
+ import: '@lynx-js/react/refresh'
175
+ });
176
+ }).when(enabledHMR || enabledLiveReload, (entry)=>{
177
+ entry.prepend({
178
+ layer: LAYERS.BACKGROUND,
179
+ import: '@lynx-js/webpack-dev-transport/client'
180
+ });
181
+ }).end().plugin(`${PLUGIN_NAME_TEMPLATE}-${entryName}`).use(LynxTemplatePlugin, [
182
+ {
183
+ dsl: 'react_nodiff',
184
+ chunks: [
185
+ mainThreadEntry,
186
+ backgroundEntry
187
+ ],
188
+ filename: templateFilename.replaceAll('[name]', entryName).replaceAll('[platform]', environment.name),
189
+ ...lazyBundleFilename ? {
190
+ lazyBundleFilename
191
+ } : {},
192
+ intermediate: node_path.posix.join(DEFAULT_DIST_PATH_INTERMEDIATE, entryName),
193
+ customCSSInheritanceList,
194
+ debugInfoOutside,
195
+ defaultDisplayLinear,
196
+ enableA11y: true,
197
+ enableAccessibilityElement,
198
+ enableCSSInheritance,
199
+ enableCSSInvalidation,
200
+ enableCSSSelector,
201
+ enableNewGesture,
202
+ enableRemoveCSSScope: enableRemoveCSSScope ?? true,
203
+ removeDescendantSelectorScope,
204
+ targetSdkVersion,
205
+ experimental_isLazyBundle,
206
+ cssPlugins: []
207
+ }
208
+ ]).end();
209
+ });
210
+ if (isLynx) {
211
+ let inlineScripts;
212
+ inlineScripts = experimental_isLazyBundle ? true : environment.config.output?.inlineScripts ?? !enableChunkSplitting;
213
+ chain.plugin(PLUGIN_NAME_RUNTIME_WRAPPER).use(RuntimeWrapperWebpackPlugin, [
214
+ {
215
+ injectVars (vars) {
216
+ const UNUSED_VARS = new Set([
217
+ 'Card',
218
+ 'Component',
219
+ 'ReactLynx',
220
+ 'Behavior'
221
+ ]);
222
+ return vars.map((name)=>{
223
+ if (UNUSED_VARS.has(name)) return `__${name}`;
224
+ return name;
225
+ });
226
+ },
227
+ targetSdkVersion,
228
+ test: /^(?!.*main-thread(?:\.[A-Fa-f0-9]*)?\.js$).*\.js$/,
229
+ experimental_isLazyBundle
230
+ }
231
+ ]).end().plugin(`${LynxEncodePlugin.name}`).use(LynxEncodePlugin, [
232
+ {
233
+ inlineScripts
234
+ }
235
+ ]).end();
236
+ }
237
+ if (isWeb) chain.plugin(PLUGIN_NAME_WEB).use(WebEncodePlugin, []).end();
238
+ }
239
+ let extractStr = originalExtractStr;
240
+ if (enableChunkSplitting && originalExtractStr) {
241
+ (api.logger ?? console).warn('`extractStr` is changed to `false` because it is only supported when chunk splitting is disabled, please set `splitChunks` to `false` to use `extractStr.`');
242
+ extractStr = false;
243
+ }
244
+ const { resolve } = api.useExposed(Symbol.for('@lynx-js/react/internal:resolve'));
245
+ chain.plugin(PLUGIN_NAME_REACT).after(PLUGIN_NAME_TEMPLATE).use(ReactWebpackPlugin, [
246
+ {
247
+ disableCreateSelectorQueryIncompatibleWarning: compat?.disableCreateSelectorQueryIncompatibleWarning ?? false,
248
+ firstScreenSyncTiming,
249
+ globalPropsMode,
250
+ enableSSR,
251
+ mainThreadChunks,
252
+ extractStr,
253
+ experimental_isLazyBundle,
254
+ experimental_useElementTemplate: options.experimental_useElementTemplate,
255
+ profile: getDefaultProfile(),
256
+ workletRuntimePath: await resolve(`@lynx-js/react/${isDev ? 'worklet-dev-runtime' : 'worklet-runtime'}`)
257
+ }
258
+ ]);
259
+ function getDefaultProfile() {
260
+ const environmentProfile = rspeedyConfig?.environments?.[environment.name]?.performance?.profile;
261
+ if (void 0 !== environmentProfile) return environmentProfile;
262
+ const userProfile = rspeedyConfig?.performance?.profile;
263
+ if (void 0 !== userProfile) return userProfile;
264
+ if (isDebug()) return true;
265
+ }
266
+ });
267
+ }
268
+ const isDebug = ()=>{
269
+ if (!process.env['DEBUG']) return false;
270
+ const values = process.env['DEBUG'].toLocaleLowerCase().split(',');
271
+ return [
272
+ 'rspeedy',
273
+ '*'
274
+ ].some((key)=>values.includes(key));
275
+ };
276
+ function getChunks(entryName, entryValue) {
277
+ const chunks = [
278
+ entryName
279
+ ];
280
+ const imports = [];
281
+ for (const item of entryValue){
282
+ if ('string' == typeof item) {
283
+ imports.push(item);
284
+ continue;
285
+ }
286
+ if (Array.isArray(item)) {
287
+ imports.push(...imports);
288
+ continue;
289
+ }
290
+ const { dependOn } = item;
291
+ if (Array.isArray(item.import)) imports.push(...item.import);
292
+ else imports.push(item.import);
293
+ if (dependOn) if ('string' == typeof dependOn) chunks.unshift(dependOn);
294
+ else chunks.unshift(...dependOn);
295
+ }
296
+ return {
297
+ chunks,
298
+ imports
299
+ };
300
+ }
301
+ function getBackgroundFilename(entryName, config, isProd, experimental_isLazyBundle) {
302
+ const { filename } = config.output;
303
+ if ('string' == typeof filename.js) return filename.js.replaceAll('[name]', entryName).replaceAll('.js', '/background.js');
304
+ return `${entryName}/background${getHash(config, isProd, experimental_isLazyBundle)}.js`;
305
+ }
306
+ function getHash(config, isProd, experimental_isLazyBundle) {
307
+ if ('string' == typeof config.output?.filenameHash) return config.output.filenameHash ? `.[${config.output.filenameHash}]` : EMPTY_HASH;
308
+ if (config.output?.filenameHash === false) return EMPTY_HASH;
309
+ if (isProd || experimental_isLazyBundle) return DEFAULT_FILENAME_HASH;
310
+ return EMPTY_HASH;
311
+ }
312
+ function applyGenerator(api, options) {
313
+ api.modifyBundlerChain({
314
+ order: 'pre',
315
+ handler: (chain)=>{
316
+ const rule = chain.module.rule("react:json-parse").test(/\.json$/).type('json').generator({
317
+ JSONParse: false
318
+ });
319
+ if (!options.extractStr) rule.issuerLayer(LAYERS.MAIN_THREAD);
320
+ }
321
+ });
322
+ }
323
+ function applyLazy(api) {
324
+ api.modifyBundlerChain((chain)=>{
325
+ chain.output.library({
326
+ type: 'commonjs'
327
+ });
328
+ });
329
+ }
330
+ const MAIN_THREAD_ENV_INCLUDE = [
331
+ 'transform-nullish-coalescing-operator',
332
+ 'transform-optional-chaining',
333
+ 'transform-export-namespace-from',
334
+ 'transform-logical-assignment-operators',
335
+ 'transform-numeric-separator',
336
+ 'transform-class-properties',
337
+ 'transform-class-static-block',
338
+ 'transform-private-methods',
339
+ 'transform-private-property-in-object'
340
+ ];
341
+ const MAIN_THREAD_ENV_TARGETS = {
342
+ chrome: '120'
343
+ };
344
+ function getLoaderOptions(api, options, isMainThread = false) {
345
+ const { output } = api.getRsbuildConfig();
346
+ const inlineSourcesContent = output?.sourceMap === true || !(output?.sourceMap === false || output?.sourceMap?.js === false || output?.sourceMap?.js?.includes('nosources'));
347
+ const { compat, enableRemoveCSSScope, shake, defineDCE, engineVersion, enableUiSourceMap, experimental_isLazyBundle, experimental_useElementTemplate } = options;
348
+ return {
349
+ compat,
350
+ enableRemoveCSSScope,
351
+ isDynamicComponent: experimental_isLazyBundle,
352
+ inlineSourcesContent,
353
+ defineDCE,
354
+ engineVersion,
355
+ experimental_useElementTemplate,
356
+ ...isMainThread ? {
357
+ enableUiSourceMap,
358
+ shake
359
+ } : {}
360
+ };
361
+ }
362
+ const TESTING_RULE_NAME = 'react:testing';
363
+ function applyTestingLoaders(api, options) {
364
+ api.modifyBundlerChain((chain, { CHAIN_ID })=>{
365
+ const rule = chain.module.rule(CHAIN_ID.RULE.JS).oneOf(CHAIN_ID.ONE_OF.JS_MAIN);
366
+ rule.use(TESTING_RULE_NAME).loader(ReactWebpackPlugin.loaders.TESTING).options(getLoaderOptions(api, options)).end();
367
+ });
368
+ }
369
+ function applyLoaders(api, options) {
370
+ api.modifyBundlerChain((chain, { CHAIN_ID })=>{
371
+ const rule = chain.module.rule(CHAIN_ID.RULE.JS);
372
+ const jsMainRule = rule.oneOf(CHAIN_ID.ONE_OF.JS_MAIN);
373
+ const type = jsMainRule.get('type');
374
+ const uses = jsMainRule.uses.entries() ?? {};
375
+ jsMainRule.uses.clear();
376
+ const backgroundRule = jsMainRule.oneOf(LAYERS.BACKGROUND);
377
+ backgroundRule.issuerLayer(LAYERS.BACKGROUND).when(void 0 !== type, (rule)=>{
378
+ rule.type(type);
379
+ }).uses.merge(uses).end().use(LAYERS.BACKGROUND).loader(ReactWebpackPlugin.loaders.BACKGROUND).options(getLoaderOptions(api, options)).end();
380
+ const mainThreadRule = jsMainRule.oneOf(LAYERS.MAIN_THREAD);
381
+ mainThreadRule.issuerLayer(LAYERS.MAIN_THREAD).when(void 0 !== type, (rule)=>{
382
+ rule.type(type);
383
+ }).uses.merge(uses).end().when(void 0 !== uses[CHAIN_ID.USE.SWC], (rule)=>{
384
+ rule.uses.delete(CHAIN_ID.USE.SWC);
385
+ const swcLoaderRule = uses[CHAIN_ID.USE.SWC].entries();
386
+ const swcLoaderOptions = swcLoaderRule.options;
387
+ const jsc = {
388
+ ...swcLoaderOptions.jsc
389
+ };
390
+ delete jsc['target'];
391
+ rule.use(CHAIN_ID.USE.SWC).merge(swcLoaderRule).options({
392
+ ...swcLoaderOptions,
393
+ jsc,
394
+ env: {
395
+ ...swcLoaderOptions.env,
396
+ targets: MAIN_THREAD_ENV_TARGETS,
397
+ include: [
398
+ 'transform-block-scoping',
399
+ ...MAIN_THREAD_ENV_INCLUDE
400
+ ]
401
+ }
402
+ });
403
+ }).use(LAYERS.MAIN_THREAD).loader(ReactWebpackPlugin.loaders.MAIN_THREAD).options(getLoaderOptions(api, options, true)).end();
404
+ });
405
+ }
406
+ function applyNodeEnv(api) {
407
+ api.modifyEnvironmentConfig((userConfig, { mergeEnvironmentConfig })=>mergeEnvironmentConfig(userConfig, {
408
+ tools: {
409
+ rspack: {
410
+ optimization: {
411
+ nodeEnv: process.env['NODE_ENV'] ?? false
412
+ }
413
+ }
414
+ }
415
+ }));
416
+ }
417
+ function applyOptimizeBundleSize(api, options) {
418
+ api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>{
419
+ const optimizeBundleSize = options.optimizeBundleSize;
420
+ const optimizeBackground = 'boolean' == typeof optimizeBundleSize ? optimizeBundleSize : optimizeBundleSize?.background;
421
+ const optimizeMainThread = 'boolean' == typeof optimizeBundleSize ? optimizeBundleSize : optimizeBundleSize?.mainThread;
422
+ if (optimizeBackground || optimizeMainThread) {
423
+ const minifyConfig = {};
424
+ if (optimizeBackground) minifyConfig['backgroundOptions'] = {
425
+ minimizerOptions: {
426
+ compress: {
427
+ pure_funcs: [
428
+ 'lynx.registerDataProcessors'
429
+ ]
430
+ }
431
+ }
432
+ };
433
+ if (optimizeMainThread) minifyConfig['mainThreadOptions'] = {
434
+ minimizerOptions: {
435
+ compress: {
436
+ pure_funcs: [
437
+ 'NativeModules.call',
438
+ 'lynx.getJSModule'
439
+ ]
440
+ }
441
+ }
442
+ };
443
+ return mergeRsbuildConfig(config, {
444
+ output: {
445
+ minify: minifyConfig
446
+ }
447
+ });
448
+ }
449
+ return config;
450
+ });
451
+ }
452
+ const PLUGIN_NAME_REACT_REFRESH = 'lynx:react:refresh';
453
+ function applyRefresh(api) {
454
+ api.modifyBundlerChain(async (chain, { isProd, CHAIN_ID, environment })=>{
455
+ if (!isProd && environment.config.dev?.hmr !== false) await Promise.all([
456
+ applyRefreshRules(api, chain, CHAIN_ID, ReactRefreshRspackPlugin)
457
+ ]);
458
+ });
459
+ }
460
+ async function applyRefreshRules(api, chain, CHAIN_ID, ReactRefreshPlugin) {
461
+ const { resolve } = api.useExposed(Symbol.for('@lynx-js/react/internal:resolve'));
462
+ const [reactRuntime, refresh, workletRuntime] = await Promise.all([
463
+ resolve('@lynx-js/react/package.json'),
464
+ resolve('@lynx-js/react/refresh'),
465
+ resolve('@lynx-js/react/worklet-runtime')
466
+ ]);
467
+ chain.resolve.alias.set('@lynx-js/react/refresh$', refresh);
468
+ chain.plugin(PLUGIN_NAME_REACT_REFRESH).before(CHAIN_ID.PLUGIN.HMR).use(ReactRefreshPlugin).end().module.rule('react:refresh').issuerLayer(LAYERS.BACKGROUND).before(CHAIN_ID.RULE.JS).test(/\.[jt]sx$/).exclude.add(/node_modules/).add(node_path.dirname(reactRuntime)).add(node_path.dirname(refresh)).add(node_path.dirname(workletRuntime)).add(ReactRefreshPlugin.loader).end().use('ReactRefresh').loader(ReactRefreshPlugin.loader).options({}).end().end().end().end();
469
+ }
470
+ const isPlainObject = (obj)=>null !== obj && 'object' == typeof obj && '[object Object]' === Object.prototype.toString.call(obj);
471
+ const applySplitChunksRule = (api)=>{
472
+ api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>{
473
+ const userConfig = api.getRsbuildConfig('original');
474
+ const chunkSplitStrategy = userConfig.performance?.chunkSplit?.strategy;
475
+ if (void 0 === userConfig.splitChunks && ('all-in-one' === chunkSplitStrategy || !chunkSplitStrategy)) return mergeRsbuildConfig(config, {
476
+ splitChunks: false
477
+ });
478
+ return config;
479
+ });
480
+ api.modifyBundlerChain((chain, { environment })=>{
481
+ const { config } = environment;
482
+ const userConfig = api.getRsbuildConfig('original');
483
+ const isSplitByExperience = void 0 === userConfig.splitChunks ? userConfig.performance?.chunkSplit?.strategy === 'split-by-experience' : isPlainObject(config.splitChunks) && 'default' === config.splitChunks.preset;
484
+ if (!isSplitByExperience) return;
485
+ const currentConfig = chain.optimization.splitChunks.values();
486
+ if (!isPlainObject(currentConfig)) return;
487
+ const extraGroups = {};
488
+ extraGroups['preact'] = {
489
+ name: 'lib-preact',
490
+ test: /node_modules[\\/](.*?[\\/])?(?:(?:internal-)?preact|(?:internal-)?preact[\\/]compat|(?:internal-)?preact[\\/]hooks|(?:internal-)?preact[\\/]jsx-runtime)[\\/]/,
491
+ priority: 0
492
+ };
493
+ chain.optimization.splitChunks({
494
+ ...currentConfig,
495
+ cacheGroups: {
496
+ ...currentConfig.cacheGroups,
497
+ ...extraGroups
498
+ }
499
+ });
500
+ });
501
+ api.modifyRspackConfig((rspackConfig)=>{
502
+ if (!rspackConfig.optimization) return rspackConfig;
503
+ if (!rspackConfig.optimization.splitChunks) return rspackConfig;
504
+ rspackConfig.optimization.splitChunks.chunks = function(chunk) {
505
+ return !chunk.name?.includes('__main-thread');
506
+ };
507
+ return rspackConfig;
508
+ });
509
+ };
510
+ function applySWC(api) {
511
+ api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>mergeRsbuildConfig({
512
+ tools: {
513
+ swc: {
514
+ jsc: {
515
+ transform: {
516
+ useDefineForClassFields: false,
517
+ optimizer: {
518
+ simplify: true
519
+ }
520
+ },
521
+ parser: {
522
+ syntax: "typescript",
523
+ tsx: false,
524
+ decorators: true
525
+ }
526
+ }
527
+ }
528
+ }
529
+ }, config));
530
+ }
531
+ function applyUseSyncExternalStore(api) {
532
+ api.modifyBundlerChain(async (chain, { rspack })=>{
533
+ const { getImportResolver } = await import("./resolve.js");
534
+ const resolve = getImportResolver(rspack);
535
+ const useSyncExternalStoreEntries = [
536
+ 'use-sync-external-store',
537
+ 'use-sync-external-store/with-selector',
538
+ 'use-sync-external-store/with-selector.js',
539
+ 'use-sync-external-store/shim',
540
+ 'use-sync-external-store/shim/with-selector',
541
+ 'use-sync-external-store/shim/with-selector.js'
542
+ ];
543
+ await Promise.all(useSyncExternalStoreEntries.map((key)=>{
544
+ const entry = key.endsWith('.js') ? key.replace('.js', '') : key;
545
+ return resolve(`@lynx-js/${entry}`).then((value)=>{
546
+ chain.resolve.alias.set(`${key}$`, value);
547
+ });
548
+ }));
549
+ });
550
+ }
551
+ const _accessExpressionAsString = (str)=>variable(str) ? `.${str}` : `[${JSON.stringify(str)}]`;
552
+ const variable = (str)=>false === reserved(str) && /^[a-zA-Z_$][a-zA-Z_$0-9]*$/g.test(str);
553
+ const reserved = (str)=>RESERVED.has(str);
554
+ const RESERVED = new Set([
555
+ "break",
556
+ "case",
557
+ "catch",
558
+ "class",
559
+ "const",
560
+ "continue",
561
+ "debugger",
562
+ "default",
563
+ "delete",
564
+ "do",
565
+ "else",
566
+ "enum",
567
+ "export",
568
+ "extends",
569
+ "false",
570
+ "finally",
571
+ "for",
572
+ "function",
573
+ "if",
574
+ "import",
575
+ "in",
576
+ "instanceof",
577
+ "new",
578
+ "null",
579
+ "return",
580
+ "super",
581
+ "switch",
582
+ "this",
583
+ "throw",
584
+ "true",
585
+ "try",
586
+ "typeof",
587
+ "var",
588
+ "void",
589
+ "while",
590
+ "with"
591
+ ]);
592
+ class TypeGuardError extends Error {
593
+ method;
594
+ path;
595
+ expected;
596
+ value;
597
+ description;
598
+ fake_expected_typed_value_;
599
+ constructor(props){
600
+ super(props.message || `Error on ${props.method}(): invalid type${props.path ? ` on ${props.path}` : ""}, expect to be ${props.expected}`);
601
+ const proto = new.target.prototype;
602
+ if (Object.setPrototypeOf) Object.setPrototypeOf(this, proto);
603
+ else this.__proto__ = proto;
604
+ this.method = props.method;
605
+ this.path = props.path;
606
+ this.expected = props.expected;
607
+ this.value = props.value;
608
+ if (props.description || void 0 === props.value) this.description = props.description ?? [
609
+ "The value at this path is `undefined`.",
610
+ "",
611
+ `Please fill the \`${props.expected}\` typed value next time.`
612
+ ].join("\n");
613
+ }
614
+ }
615
+ const _assertGuard = (exceptionable, props, factory)=>{
616
+ if (true === exceptionable) if (factory) throw factory(props);
617
+ else throw new TypeGuardError(props);
618
+ return false;
619
+ };
620
+ const validateConfig = (()=>{
621
+ const _io0 = (input, _exceptionable = true)=>(void 0 === input.enableUiSourceMap || "boolean" == typeof input.enableUiSourceMap) && (void 0 === input.compat || "object" == typeof input.compat && null !== input.compat && false === Array.isArray(input.compat) && _io1(input.compat, _exceptionable)) && (void 0 === input.customCSSInheritanceList || Array.isArray(input.customCSSInheritanceList) && input.customCSSInheritanceList.every((elem, _index1)=>"string" == typeof elem)) && (void 0 === input.debugInfoOutside || "boolean" == typeof input.debugInfoOutside) && (void 0 === input.defaultDisplayLinear || "boolean" == typeof input.defaultDisplayLinear) && (void 0 === input.enableAccessibilityElement || "boolean" == typeof input.enableAccessibilityElement) && (void 0 === input.enableCSSInheritance || "boolean" == typeof input.enableCSSInheritance) && (void 0 === input.enableCSSInvalidation || "boolean" == typeof input.enableCSSInvalidation) && (void 0 === input.enableCSSSelector || "boolean" == typeof input.enableCSSSelector) && (void 0 === input.enableNewGesture || "boolean" == typeof input.enableNewGesture) && (void 0 === input.enableRemoveCSSScope || "boolean" == typeof input.enableRemoveCSSScope) && (void 0 === input.firstScreenSyncTiming || "immediately" === input.firstScreenSyncTiming || "jsReady" === input.firstScreenSyncTiming) && (void 0 === input.enableSSR || "boolean" == typeof input.enableSSR) && (void 0 === input.removeDescendantSelectorScope || "boolean" == typeof input.removeDescendantSelectorScope) && (void 0 === input.shake || "object" == typeof input.shake && null !== input.shake && false === Array.isArray(input.shake) && _io4(input.shake, _exceptionable)) && (void 0 === input.defineDCE || "object" == typeof input.defineDCE && null !== input.defineDCE && false === Array.isArray(input.defineDCE) && _io5(input.defineDCE, _exceptionable)) && (void 0 === input.engineVersion || "string" == typeof input.engineVersion) && (void 0 === input.targetSdkVersion || "string" == typeof input.targetSdkVersion) && (void 0 === input.globalPropsMode || "reactive" === input.globalPropsMode || "event" === input.globalPropsMode) && null !== input.extractStr && (void 0 === input.extractStr || "boolean" == typeof input.extractStr || "object" == typeof input.extractStr && null !== input.extractStr && false === Array.isArray(input.extractStr) && _io7(input.extractStr, _exceptionable)) && (void 0 === input.experimental_isLazyBundle || "boolean" == typeof input.experimental_isLazyBundle) && (void 0 === input.experimental_useElementTemplate || "boolean" == typeof input.experimental_useElementTemplate) && null !== input.optimizeBundleSize && (void 0 === input.optimizeBundleSize || "boolean" == typeof input.optimizeBundleSize || "object" == typeof input.optimizeBundleSize && null !== input.optimizeBundleSize && false === Array.isArray(input.optimizeBundleSize) && _io8(input.optimizeBundleSize, _exceptionable)) && (0 === Object.keys(input).length || Object.keys(input).every((key)=>{
622
+ if ([
623
+ "enableUiSourceMap",
624
+ "compat",
625
+ "customCSSInheritanceList",
626
+ "debugInfoOutside",
627
+ "defaultDisplayLinear",
628
+ "enableAccessibilityElement",
629
+ "enableCSSInheritance",
630
+ "enableCSSInvalidation",
631
+ "enableCSSSelector",
632
+ "enableNewGesture",
633
+ "enableRemoveCSSScope",
634
+ "firstScreenSyncTiming",
635
+ "enableSSR",
636
+ "removeDescendantSelectorScope",
637
+ "shake",
638
+ "defineDCE",
639
+ "engineVersion",
640
+ "targetSdkVersion",
641
+ "globalPropsMode",
642
+ "extractStr",
643
+ "experimental_isLazyBundle",
644
+ "experimental_useElementTemplate",
645
+ "optimizeBundleSize"
646
+ ].some((prop)=>key === prop)) return true;
647
+ const value = input[key];
648
+ if (void 0 === value) return true;
649
+ return false;
650
+ }));
651
+ const _io1 = (input, _exceptionable = true)=>(void 0 === input.componentsPkg || Array.isArray(input.componentsPkg) && input.componentsPkg.every((elem, _index2)=>"string" == typeof elem)) && (void 0 === input.oldRuntimePkg || Array.isArray(input.oldRuntimePkg) && input.oldRuntimePkg.every((elem, _index3)=>"string" == typeof elem)) && (void 0 === input.newRuntimePkg || "string" == typeof input.newRuntimePkg) && (void 0 === input.additionalComponentAttributes || Array.isArray(input.additionalComponentAttributes) && input.additionalComponentAttributes.every((elem, _index4)=>"string" == typeof elem)) && null !== input.addComponentElement && (void 0 === input.addComponentElement || "boolean" == typeof input.addComponentElement || "object" == typeof input.addComponentElement && null !== input.addComponentElement && _io2(input.addComponentElement, _exceptionable)) && (void 0 === input.simplifyCtorLikeReactLynx2 || "boolean" == typeof input.simplifyCtorLikeReactLynx2) && (void 0 === input.removeComponentAttrRegex || "string" == typeof input.removeComponentAttrRegex) && (void 0 === input.disableDeprecatedWarning || "boolean" == typeof input.disableDeprecatedWarning) && null !== input.darkMode && (void 0 === input.darkMode || "boolean" == typeof input.darkMode || "object" == typeof input.darkMode && null !== input.darkMode && _io3(input.darkMode, _exceptionable)) && (void 0 === input.disableCreateSelectorQueryIncompatibleWarning || "boolean" == typeof input.disableCreateSelectorQueryIncompatibleWarning) && (0 === Object.keys(input).length || Object.keys(input).every((key)=>{
652
+ if ([
653
+ "componentsPkg",
654
+ "oldRuntimePkg",
655
+ "newRuntimePkg",
656
+ "additionalComponentAttributes",
657
+ "addComponentElement",
658
+ "simplifyCtorLikeReactLynx2",
659
+ "removeComponentAttrRegex",
660
+ "disableDeprecatedWarning",
661
+ "darkMode",
662
+ "disableCreateSelectorQueryIncompatibleWarning"
663
+ ].some((prop)=>key === prop)) return true;
664
+ const value = input[key];
665
+ if (void 0 === value) return true;
666
+ return false;
667
+ }));
668
+ const _io2 = (input, _exceptionable = true)=>"boolean" == typeof input.compilerOnly && (1 === Object.keys(input).length || Object.keys(input).every((key)=>{
669
+ if ([
670
+ "compilerOnly"
671
+ ].some((prop)=>key === prop)) return true;
672
+ const value = input[key];
673
+ if (void 0 === value) return true;
674
+ return false;
675
+ }));
676
+ const _io3 = (input, _exceptionable = true)=>"string" == typeof input.themeExpr && (1 === Object.keys(input).length || Object.keys(input).every((key)=>{
677
+ if ([
678
+ "themeExpr"
679
+ ].some((prop)=>key === prop)) return true;
680
+ const value = input[key];
681
+ if (void 0 === value) return true;
682
+ return false;
683
+ }));
684
+ const _io4 = (input, _exceptionable = true)=>(void 0 === input.pkgName || Array.isArray(input.pkgName) && input.pkgName.every((elem, _index5)=>"string" == typeof elem)) && (void 0 === input.retainProp || Array.isArray(input.retainProp) && input.retainProp.every((elem, _index6)=>"string" == typeof elem)) && (void 0 === input.removeCall || Array.isArray(input.removeCall) && input.removeCall.every((elem, _index7)=>"string" == typeof elem)) && (void 0 === input.removeCallParams || Array.isArray(input.removeCallParams) && input.removeCallParams.every((elem, _index8)=>"string" == typeof elem)) && (0 === Object.keys(input).length || Object.keys(input).every((key)=>{
685
+ if ([
686
+ "pkgName",
687
+ "retainProp",
688
+ "removeCall",
689
+ "removeCallParams"
690
+ ].some((prop)=>key === prop)) return true;
691
+ const value = input[key];
692
+ if (void 0 === value) return true;
693
+ return false;
694
+ }));
695
+ const _io5 = (input, _exceptionable = true)=>(void 0 === input.define || "object" == typeof input.define && null !== input.define && false === Array.isArray(input.define) && _io6(input.define, _exceptionable)) && (0 === Object.keys(input).length || Object.keys(input).every((key)=>{
696
+ if ([
697
+ "define"
698
+ ].some((prop)=>key === prop)) return true;
699
+ const value = input[key];
700
+ if (void 0 === value) return true;
701
+ return false;
702
+ }));
703
+ const _io6 = (input, _exceptionable = true)=>Object.keys(input).every((key)=>{
704
+ const value = input[key];
705
+ if (void 0 === value) return true;
706
+ return "string" == typeof value;
707
+ });
708
+ const _io7 = (input, _exceptionable = true)=>(void 0 === input.strLength || "number" == typeof input.strLength) && (0 === Object.keys(input).length || Object.keys(input).every((key)=>{
709
+ if ([
710
+ "strLength"
711
+ ].some((prop)=>key === prop)) return true;
712
+ const value = input[key];
713
+ if (void 0 === value) return true;
714
+ return false;
715
+ }));
716
+ const _io8 = (input, _exceptionable = true)=>(void 0 === input.mainThread || "boolean" == typeof input.mainThread) && (void 0 === input.background || "boolean" == typeof input.background) && (0 === Object.keys(input).length || Object.keys(input).every((key)=>{
717
+ if ([
718
+ "mainThread",
719
+ "background"
720
+ ].some((prop)=>key === prop)) return true;
721
+ const value = input[key];
722
+ if (void 0 === value) return true;
723
+ return false;
724
+ }));
725
+ const _ao0 = (input, _path, _exceptionable = true)=>(void 0 === input.enableUiSourceMap || "boolean" == typeof input.enableUiSourceMap || _assertGuard(_exceptionable, {
726
+ method: "typia.createAssertEquals",
727
+ path: _path + ".enableUiSourceMap",
728
+ expected: "(boolean | undefined)",
729
+ value: input.enableUiSourceMap
730
+ }, _errorFactory)) && (void 0 === input.compat || ("object" == typeof input.compat && null !== input.compat && false === Array.isArray(input.compat) || _assertGuard(_exceptionable, {
731
+ method: "typia.createAssertEquals",
732
+ path: _path + ".compat",
733
+ expected: "(Partial<CompatVisitorConfig> & { disableCreateSelectorQueryIncompatibleWarning?: boolean; } | undefined)",
734
+ value: input.compat
735
+ }, _errorFactory)) && _ao1(input.compat, _path + ".compat", _exceptionable) || _assertGuard(_exceptionable, {
736
+ method: "typia.createAssertEquals",
737
+ path: _path + ".compat",
738
+ expected: "(Partial<CompatVisitorConfig> & { disableCreateSelectorQueryIncompatibleWarning?: boolean; } | undefined)",
739
+ value: input.compat
740
+ }, _errorFactory)) && (void 0 === input.customCSSInheritanceList || (Array.isArray(input.customCSSInheritanceList) || _assertGuard(_exceptionable, {
741
+ method: "typia.createAssertEquals",
742
+ path: _path + ".customCSSInheritanceList",
743
+ expected: "(Array<string> | undefined)",
744
+ value: input.customCSSInheritanceList
745
+ }, _errorFactory)) && input.customCSSInheritanceList.every((elem, _index9)=>"string" == typeof elem || _assertGuard(_exceptionable, {
746
+ method: "typia.createAssertEquals",
747
+ path: _path + ".customCSSInheritanceList[" + _index9 + "]",
748
+ expected: "string",
749
+ value: elem
750
+ }, _errorFactory)) || _assertGuard(_exceptionable, {
751
+ method: "typia.createAssertEquals",
752
+ path: _path + ".customCSSInheritanceList",
753
+ expected: "(Array<string> | undefined)",
754
+ value: input.customCSSInheritanceList
755
+ }, _errorFactory)) && (void 0 === input.debugInfoOutside || "boolean" == typeof input.debugInfoOutside || _assertGuard(_exceptionable, {
756
+ method: "typia.createAssertEquals",
757
+ path: _path + ".debugInfoOutside",
758
+ expected: "(boolean | undefined)",
759
+ value: input.debugInfoOutside
760
+ }, _errorFactory)) && (void 0 === input.defaultDisplayLinear || "boolean" == typeof input.defaultDisplayLinear || _assertGuard(_exceptionable, {
761
+ method: "typia.createAssertEquals",
762
+ path: _path + ".defaultDisplayLinear",
763
+ expected: "(boolean | undefined)",
764
+ value: input.defaultDisplayLinear
765
+ }, _errorFactory)) && (void 0 === input.enableAccessibilityElement || "boolean" == typeof input.enableAccessibilityElement || _assertGuard(_exceptionable, {
766
+ method: "typia.createAssertEquals",
767
+ path: _path + ".enableAccessibilityElement",
768
+ expected: "(boolean | undefined)",
769
+ value: input.enableAccessibilityElement
770
+ }, _errorFactory)) && (void 0 === input.enableCSSInheritance || "boolean" == typeof input.enableCSSInheritance || _assertGuard(_exceptionable, {
771
+ method: "typia.createAssertEquals",
772
+ path: _path + ".enableCSSInheritance",
773
+ expected: "(boolean | undefined)",
774
+ value: input.enableCSSInheritance
775
+ }, _errorFactory)) && (void 0 === input.enableCSSInvalidation || "boolean" == typeof input.enableCSSInvalidation || _assertGuard(_exceptionable, {
776
+ method: "typia.createAssertEquals",
777
+ path: _path + ".enableCSSInvalidation",
778
+ expected: "(boolean | undefined)",
779
+ value: input.enableCSSInvalidation
780
+ }, _errorFactory)) && (void 0 === input.enableCSSSelector || "boolean" == typeof input.enableCSSSelector || _assertGuard(_exceptionable, {
781
+ method: "typia.createAssertEquals",
782
+ path: _path + ".enableCSSSelector",
783
+ expected: "(boolean | undefined)",
784
+ value: input.enableCSSSelector
785
+ }, _errorFactory)) && (void 0 === input.enableNewGesture || "boolean" == typeof input.enableNewGesture || _assertGuard(_exceptionable, {
786
+ method: "typia.createAssertEquals",
787
+ path: _path + ".enableNewGesture",
788
+ expected: "(boolean | undefined)",
789
+ value: input.enableNewGesture
790
+ }, _errorFactory)) && (void 0 === input.enableRemoveCSSScope || "boolean" == typeof input.enableRemoveCSSScope || _assertGuard(_exceptionable, {
791
+ method: "typia.createAssertEquals",
792
+ path: _path + ".enableRemoveCSSScope",
793
+ expected: "(boolean | undefined)",
794
+ value: input.enableRemoveCSSScope
795
+ }, _errorFactory)) && (void 0 === input.firstScreenSyncTiming || "immediately" === input.firstScreenSyncTiming || "jsReady" === input.firstScreenSyncTiming || _assertGuard(_exceptionable, {
796
+ method: "typia.createAssertEquals",
797
+ path: _path + ".firstScreenSyncTiming",
798
+ expected: "(\"immediately\" | \"jsReady\" | undefined)",
799
+ value: input.firstScreenSyncTiming
800
+ }, _errorFactory)) && (void 0 === input.enableSSR || "boolean" == typeof input.enableSSR || _assertGuard(_exceptionable, {
801
+ method: "typia.createAssertEquals",
802
+ path: _path + ".enableSSR",
803
+ expected: "(boolean | undefined)",
804
+ value: input.enableSSR
805
+ }, _errorFactory)) && (void 0 === input.removeDescendantSelectorScope || "boolean" == typeof input.removeDescendantSelectorScope || _assertGuard(_exceptionable, {
806
+ method: "typia.createAssertEquals",
807
+ path: _path + ".removeDescendantSelectorScope",
808
+ expected: "(boolean | undefined)",
809
+ value: input.removeDescendantSelectorScope
810
+ }, _errorFactory)) && (void 0 === input.shake || ("object" == typeof input.shake && null !== input.shake && false === Array.isArray(input.shake) || _assertGuard(_exceptionable, {
811
+ method: "typia.createAssertEquals",
812
+ path: _path + ".shake",
813
+ expected: "(Partial<ShakeVisitorConfig> | undefined)",
814
+ value: input.shake
815
+ }, _errorFactory)) && _ao4(input.shake, _path + ".shake", _exceptionable) || _assertGuard(_exceptionable, {
816
+ method: "typia.createAssertEquals",
817
+ path: _path + ".shake",
818
+ expected: "(Partial<ShakeVisitorConfig> | undefined)",
819
+ value: input.shake
820
+ }, _errorFactory)) && (void 0 === input.defineDCE || ("object" == typeof input.defineDCE && null !== input.defineDCE && false === Array.isArray(input.defineDCE) || _assertGuard(_exceptionable, {
821
+ method: "typia.createAssertEquals",
822
+ path: _path + ".defineDCE",
823
+ expected: "(Partial<DefineDceVisitorConfig> | undefined)",
824
+ value: input.defineDCE
825
+ }, _errorFactory)) && _ao5(input.defineDCE, _path + ".defineDCE", _exceptionable) || _assertGuard(_exceptionable, {
826
+ method: "typia.createAssertEquals",
827
+ path: _path + ".defineDCE",
828
+ expected: "(Partial<DefineDceVisitorConfig> | undefined)",
829
+ value: input.defineDCE
830
+ }, _errorFactory)) && (void 0 === input.engineVersion || "string" == typeof input.engineVersion || _assertGuard(_exceptionable, {
831
+ method: "typia.createAssertEquals",
832
+ path: _path + ".engineVersion",
833
+ expected: "(string | undefined)",
834
+ value: input.engineVersion
835
+ }, _errorFactory)) && (void 0 === input.targetSdkVersion || "string" == typeof input.targetSdkVersion || _assertGuard(_exceptionable, {
836
+ method: "typia.createAssertEquals",
837
+ path: _path + ".targetSdkVersion",
838
+ expected: "(string | undefined)",
839
+ value: input.targetSdkVersion
840
+ }, _errorFactory)) && (void 0 === input.globalPropsMode || "reactive" === input.globalPropsMode || "event" === input.globalPropsMode || _assertGuard(_exceptionable, {
841
+ method: "typia.createAssertEquals",
842
+ path: _path + ".globalPropsMode",
843
+ expected: "(\"event\" | \"reactive\" | undefined)",
844
+ value: input.globalPropsMode
845
+ }, _errorFactory)) && (null !== input.extractStr || _assertGuard(_exceptionable, {
846
+ method: "typia.createAssertEquals",
847
+ path: _path + ".extractStr",
848
+ expected: "(Partial<ExtractStrConfig> | boolean | undefined)",
849
+ value: input.extractStr
850
+ }, _errorFactory)) && (void 0 === input.extractStr || "boolean" == typeof input.extractStr || ("object" == typeof input.extractStr && null !== input.extractStr && false === Array.isArray(input.extractStr) || _assertGuard(_exceptionable, {
851
+ method: "typia.createAssertEquals",
852
+ path: _path + ".extractStr",
853
+ expected: "(Partial<ExtractStrConfig> | boolean | undefined)",
854
+ value: input.extractStr
855
+ }, _errorFactory)) && _ao7(input.extractStr, _path + ".extractStr", _exceptionable) || _assertGuard(_exceptionable, {
856
+ method: "typia.createAssertEquals",
857
+ path: _path + ".extractStr",
858
+ expected: "(Partial<ExtractStrConfig> | boolean | undefined)",
859
+ value: input.extractStr
860
+ }, _errorFactory)) && (void 0 === input.experimental_isLazyBundle || "boolean" == typeof input.experimental_isLazyBundle || _assertGuard(_exceptionable, {
861
+ method: "typia.createAssertEquals",
862
+ path: _path + ".experimental_isLazyBundle",
863
+ expected: "(boolean | undefined)",
864
+ value: input.experimental_isLazyBundle
865
+ }, _errorFactory)) && (void 0 === input.experimental_useElementTemplate || "boolean" == typeof input.experimental_useElementTemplate || _assertGuard(_exceptionable, {
866
+ method: "typia.createAssertEquals",
867
+ path: _path + ".experimental_useElementTemplate",
868
+ expected: "(boolean | undefined)",
869
+ value: input.experimental_useElementTemplate
870
+ }, _errorFactory)) && (null !== input.optimizeBundleSize || _assertGuard(_exceptionable, {
871
+ method: "typia.createAssertEquals",
872
+ path: _path + ".optimizeBundleSize",
873
+ expected: "(__type | boolean | undefined)",
874
+ value: input.optimizeBundleSize
875
+ }, _errorFactory)) && (void 0 === input.optimizeBundleSize || "boolean" == typeof input.optimizeBundleSize || ("object" == typeof input.optimizeBundleSize && null !== input.optimizeBundleSize && false === Array.isArray(input.optimizeBundleSize) || _assertGuard(_exceptionable, {
876
+ method: "typia.createAssertEquals",
877
+ path: _path + ".optimizeBundleSize",
878
+ expected: "(__type | boolean | undefined)",
879
+ value: input.optimizeBundleSize
880
+ }, _errorFactory)) && _ao8(input.optimizeBundleSize, _path + ".optimizeBundleSize", _exceptionable) || _assertGuard(_exceptionable, {
881
+ method: "typia.createAssertEquals",
882
+ path: _path + ".optimizeBundleSize",
883
+ expected: "(__type | boolean | undefined)",
884
+ value: input.optimizeBundleSize
885
+ }, _errorFactory)) && (0 === Object.keys(input).length || false === _exceptionable || Object.keys(input).every((key)=>{
886
+ if ([
887
+ "enableUiSourceMap",
888
+ "compat",
889
+ "customCSSInheritanceList",
890
+ "debugInfoOutside",
891
+ "defaultDisplayLinear",
892
+ "enableAccessibilityElement",
893
+ "enableCSSInheritance",
894
+ "enableCSSInvalidation",
895
+ "enableCSSSelector",
896
+ "enableNewGesture",
897
+ "enableRemoveCSSScope",
898
+ "firstScreenSyncTiming",
899
+ "enableSSR",
900
+ "removeDescendantSelectorScope",
901
+ "shake",
902
+ "defineDCE",
903
+ "engineVersion",
904
+ "targetSdkVersion",
905
+ "globalPropsMode",
906
+ "extractStr",
907
+ "experimental_isLazyBundle",
908
+ "experimental_useElementTemplate",
909
+ "optimizeBundleSize"
910
+ ].some((prop)=>key === prop)) return true;
911
+ const value = input[key];
912
+ if (void 0 === value) return true;
913
+ return _assertGuard(_exceptionable, {
914
+ method: "typia.createAssertEquals",
915
+ path: _path + _accessExpressionAsString(key),
916
+ expected: "undefined",
917
+ value: value
918
+ }, _errorFactory);
919
+ }));
920
+ const _ao1 = (input, _path, _exceptionable = true)=>(void 0 === input.componentsPkg || (Array.isArray(input.componentsPkg) || _assertGuard(_exceptionable, {
921
+ method: "typia.createAssertEquals",
922
+ path: _path + ".componentsPkg",
923
+ expected: "(Array<string> | undefined)",
924
+ value: input.componentsPkg
925
+ }, _errorFactory)) && input.componentsPkg.every((elem, _index10)=>"string" == typeof elem || _assertGuard(_exceptionable, {
926
+ method: "typia.createAssertEquals",
927
+ path: _path + ".componentsPkg[" + _index10 + "]",
928
+ expected: "string",
929
+ value: elem
930
+ }, _errorFactory)) || _assertGuard(_exceptionable, {
931
+ method: "typia.createAssertEquals",
932
+ path: _path + ".componentsPkg",
933
+ expected: "(Array<string> | undefined)",
934
+ value: input.componentsPkg
935
+ }, _errorFactory)) && (void 0 === input.oldRuntimePkg || (Array.isArray(input.oldRuntimePkg) || _assertGuard(_exceptionable, {
936
+ method: "typia.createAssertEquals",
937
+ path: _path + ".oldRuntimePkg",
938
+ expected: "(Array<string> | undefined)",
939
+ value: input.oldRuntimePkg
940
+ }, _errorFactory)) && input.oldRuntimePkg.every((elem, _index11)=>"string" == typeof elem || _assertGuard(_exceptionable, {
941
+ method: "typia.createAssertEquals",
942
+ path: _path + ".oldRuntimePkg[" + _index11 + "]",
943
+ expected: "string",
944
+ value: elem
945
+ }, _errorFactory)) || _assertGuard(_exceptionable, {
946
+ method: "typia.createAssertEquals",
947
+ path: _path + ".oldRuntimePkg",
948
+ expected: "(Array<string> | undefined)",
949
+ value: input.oldRuntimePkg
950
+ }, _errorFactory)) && (void 0 === input.newRuntimePkg || "string" == typeof input.newRuntimePkg || _assertGuard(_exceptionable, {
951
+ method: "typia.createAssertEquals",
952
+ path: _path + ".newRuntimePkg",
953
+ expected: "(string | undefined)",
954
+ value: input.newRuntimePkg
955
+ }, _errorFactory)) && (void 0 === input.additionalComponentAttributes || (Array.isArray(input.additionalComponentAttributes) || _assertGuard(_exceptionable, {
956
+ method: "typia.createAssertEquals",
957
+ path: _path + ".additionalComponentAttributes",
958
+ expected: "(Array<string> | undefined)",
959
+ value: input.additionalComponentAttributes
960
+ }, _errorFactory)) && input.additionalComponentAttributes.every((elem, _index12)=>"string" == typeof elem || _assertGuard(_exceptionable, {
961
+ method: "typia.createAssertEquals",
962
+ path: _path + ".additionalComponentAttributes[" + _index12 + "]",
963
+ expected: "string",
964
+ value: elem
965
+ }, _errorFactory)) || _assertGuard(_exceptionable, {
966
+ method: "typia.createAssertEquals",
967
+ path: _path + ".additionalComponentAttributes",
968
+ expected: "(Array<string> | undefined)",
969
+ value: input.additionalComponentAttributes
970
+ }, _errorFactory)) && (null !== input.addComponentElement || _assertGuard(_exceptionable, {
971
+ method: "typia.createAssertEquals",
972
+ path: _path + ".addComponentElement",
973
+ expected: "(AddComponentElementConfig | boolean | undefined)",
974
+ value: input.addComponentElement
975
+ }, _errorFactory)) && (void 0 === input.addComponentElement || "boolean" == typeof input.addComponentElement || ("object" == typeof input.addComponentElement && null !== input.addComponentElement || _assertGuard(_exceptionable, {
976
+ method: "typia.createAssertEquals",
977
+ path: _path + ".addComponentElement",
978
+ expected: "(AddComponentElementConfig | boolean | undefined)",
979
+ value: input.addComponentElement
980
+ }, _errorFactory)) && _ao2(input.addComponentElement, _path + ".addComponentElement", _exceptionable) || _assertGuard(_exceptionable, {
981
+ method: "typia.createAssertEquals",
982
+ path: _path + ".addComponentElement",
983
+ expected: "(AddComponentElementConfig | boolean | undefined)",
984
+ value: input.addComponentElement
985
+ }, _errorFactory)) && (void 0 === input.simplifyCtorLikeReactLynx2 || "boolean" == typeof input.simplifyCtorLikeReactLynx2 || _assertGuard(_exceptionable, {
986
+ method: "typia.createAssertEquals",
987
+ path: _path + ".simplifyCtorLikeReactLynx2",
988
+ expected: "(boolean | undefined)",
989
+ value: input.simplifyCtorLikeReactLynx2
990
+ }, _errorFactory)) && (void 0 === input.removeComponentAttrRegex || "string" == typeof input.removeComponentAttrRegex || _assertGuard(_exceptionable, {
991
+ method: "typia.createAssertEquals",
992
+ path: _path + ".removeComponentAttrRegex",
993
+ expected: "(string | undefined)",
994
+ value: input.removeComponentAttrRegex
995
+ }, _errorFactory)) && (void 0 === input.disableDeprecatedWarning || "boolean" == typeof input.disableDeprecatedWarning || _assertGuard(_exceptionable, {
996
+ method: "typia.createAssertEquals",
997
+ path: _path + ".disableDeprecatedWarning",
998
+ expected: "(boolean | undefined)",
999
+ value: input.disableDeprecatedWarning
1000
+ }, _errorFactory)) && (null !== input.darkMode || _assertGuard(_exceptionable, {
1001
+ method: "typia.createAssertEquals",
1002
+ path: _path + ".darkMode",
1003
+ expected: "(DarkModeConfig | boolean | undefined)",
1004
+ value: input.darkMode
1005
+ }, _errorFactory)) && (void 0 === input.darkMode || "boolean" == typeof input.darkMode || ("object" == typeof input.darkMode && null !== input.darkMode || _assertGuard(_exceptionable, {
1006
+ method: "typia.createAssertEquals",
1007
+ path: _path + ".darkMode",
1008
+ expected: "(DarkModeConfig | boolean | undefined)",
1009
+ value: input.darkMode
1010
+ }, _errorFactory)) && _ao3(input.darkMode, _path + ".darkMode", _exceptionable) || _assertGuard(_exceptionable, {
1011
+ method: "typia.createAssertEquals",
1012
+ path: _path + ".darkMode",
1013
+ expected: "(DarkModeConfig | boolean | undefined)",
1014
+ value: input.darkMode
1015
+ }, _errorFactory)) && (void 0 === input.disableCreateSelectorQueryIncompatibleWarning || "boolean" == typeof input.disableCreateSelectorQueryIncompatibleWarning || _assertGuard(_exceptionable, {
1016
+ method: "typia.createAssertEquals",
1017
+ path: _path + ".disableCreateSelectorQueryIncompatibleWarning",
1018
+ expected: "(boolean | undefined)",
1019
+ value: input.disableCreateSelectorQueryIncompatibleWarning
1020
+ }, _errorFactory)) && (0 === Object.keys(input).length || false === _exceptionable || Object.keys(input).every((key)=>{
1021
+ if ([
1022
+ "componentsPkg",
1023
+ "oldRuntimePkg",
1024
+ "newRuntimePkg",
1025
+ "additionalComponentAttributes",
1026
+ "addComponentElement",
1027
+ "simplifyCtorLikeReactLynx2",
1028
+ "removeComponentAttrRegex",
1029
+ "disableDeprecatedWarning",
1030
+ "darkMode",
1031
+ "disableCreateSelectorQueryIncompatibleWarning"
1032
+ ].some((prop)=>key === prop)) return true;
1033
+ const value = input[key];
1034
+ if (void 0 === value) return true;
1035
+ return _assertGuard(_exceptionable, {
1036
+ method: "typia.createAssertEquals",
1037
+ path: _path + _accessExpressionAsString(key),
1038
+ expected: "undefined",
1039
+ value: value
1040
+ }, _errorFactory);
1041
+ }));
1042
+ const _ao2 = (input, _path, _exceptionable = true)=>("boolean" == typeof input.compilerOnly || _assertGuard(_exceptionable, {
1043
+ method: "typia.createAssertEquals",
1044
+ path: _path + ".compilerOnly",
1045
+ expected: "boolean",
1046
+ value: input.compilerOnly
1047
+ }, _errorFactory)) && (1 === Object.keys(input).length || false === _exceptionable || Object.keys(input).every((key)=>{
1048
+ if ([
1049
+ "compilerOnly"
1050
+ ].some((prop)=>key === prop)) return true;
1051
+ const value = input[key];
1052
+ if (void 0 === value) return true;
1053
+ return _assertGuard(_exceptionable, {
1054
+ method: "typia.createAssertEquals",
1055
+ path: _path + _accessExpressionAsString(key),
1056
+ expected: "undefined",
1057
+ value: value
1058
+ }, _errorFactory);
1059
+ }));
1060
+ const _ao3 = (input, _path, _exceptionable = true)=>("string" == typeof input.themeExpr || _assertGuard(_exceptionable, {
1061
+ method: "typia.createAssertEquals",
1062
+ path: _path + ".themeExpr",
1063
+ expected: "string",
1064
+ value: input.themeExpr
1065
+ }, _errorFactory)) && (1 === Object.keys(input).length || false === _exceptionable || Object.keys(input).every((key)=>{
1066
+ if ([
1067
+ "themeExpr"
1068
+ ].some((prop)=>key === prop)) return true;
1069
+ const value = input[key];
1070
+ if (void 0 === value) return true;
1071
+ return _assertGuard(_exceptionable, {
1072
+ method: "typia.createAssertEquals",
1073
+ path: _path + _accessExpressionAsString(key),
1074
+ expected: "undefined",
1075
+ value: value
1076
+ }, _errorFactory);
1077
+ }));
1078
+ const _ao4 = (input, _path, _exceptionable = true)=>(void 0 === input.pkgName || (Array.isArray(input.pkgName) || _assertGuard(_exceptionable, {
1079
+ method: "typia.createAssertEquals",
1080
+ path: _path + ".pkgName",
1081
+ expected: "(Array<string> | undefined)",
1082
+ value: input.pkgName
1083
+ }, _errorFactory)) && input.pkgName.every((elem, _index13)=>"string" == typeof elem || _assertGuard(_exceptionable, {
1084
+ method: "typia.createAssertEquals",
1085
+ path: _path + ".pkgName[" + _index13 + "]",
1086
+ expected: "string",
1087
+ value: elem
1088
+ }, _errorFactory)) || _assertGuard(_exceptionable, {
1089
+ method: "typia.createAssertEquals",
1090
+ path: _path + ".pkgName",
1091
+ expected: "(Array<string> | undefined)",
1092
+ value: input.pkgName
1093
+ }, _errorFactory)) && (void 0 === input.retainProp || (Array.isArray(input.retainProp) || _assertGuard(_exceptionable, {
1094
+ method: "typia.createAssertEquals",
1095
+ path: _path + ".retainProp",
1096
+ expected: "(Array<string> | undefined)",
1097
+ value: input.retainProp
1098
+ }, _errorFactory)) && input.retainProp.every((elem, _index14)=>"string" == typeof elem || _assertGuard(_exceptionable, {
1099
+ method: "typia.createAssertEquals",
1100
+ path: _path + ".retainProp[" + _index14 + "]",
1101
+ expected: "string",
1102
+ value: elem
1103
+ }, _errorFactory)) || _assertGuard(_exceptionable, {
1104
+ method: "typia.createAssertEquals",
1105
+ path: _path + ".retainProp",
1106
+ expected: "(Array<string> | undefined)",
1107
+ value: input.retainProp
1108
+ }, _errorFactory)) && (void 0 === input.removeCall || (Array.isArray(input.removeCall) || _assertGuard(_exceptionable, {
1109
+ method: "typia.createAssertEquals",
1110
+ path: _path + ".removeCall",
1111
+ expected: "(Array<string> | undefined)",
1112
+ value: input.removeCall
1113
+ }, _errorFactory)) && input.removeCall.every((elem, _index15)=>"string" == typeof elem || _assertGuard(_exceptionable, {
1114
+ method: "typia.createAssertEquals",
1115
+ path: _path + ".removeCall[" + _index15 + "]",
1116
+ expected: "string",
1117
+ value: elem
1118
+ }, _errorFactory)) || _assertGuard(_exceptionable, {
1119
+ method: "typia.createAssertEquals",
1120
+ path: _path + ".removeCall",
1121
+ expected: "(Array<string> | undefined)",
1122
+ value: input.removeCall
1123
+ }, _errorFactory)) && (void 0 === input.removeCallParams || (Array.isArray(input.removeCallParams) || _assertGuard(_exceptionable, {
1124
+ method: "typia.createAssertEquals",
1125
+ path: _path + ".removeCallParams",
1126
+ expected: "(Array<string> | undefined)",
1127
+ value: input.removeCallParams
1128
+ }, _errorFactory)) && input.removeCallParams.every((elem, _index16)=>"string" == typeof elem || _assertGuard(_exceptionable, {
1129
+ method: "typia.createAssertEquals",
1130
+ path: _path + ".removeCallParams[" + _index16 + "]",
1131
+ expected: "string",
1132
+ value: elem
1133
+ }, _errorFactory)) || _assertGuard(_exceptionable, {
1134
+ method: "typia.createAssertEquals",
1135
+ path: _path + ".removeCallParams",
1136
+ expected: "(Array<string> | undefined)",
1137
+ value: input.removeCallParams
1138
+ }, _errorFactory)) && (0 === Object.keys(input).length || false === _exceptionable || Object.keys(input).every((key)=>{
1139
+ if ([
1140
+ "pkgName",
1141
+ "retainProp",
1142
+ "removeCall",
1143
+ "removeCallParams"
1144
+ ].some((prop)=>key === prop)) return true;
1145
+ const value = input[key];
1146
+ if (void 0 === value) return true;
1147
+ return _assertGuard(_exceptionable, {
1148
+ method: "typia.createAssertEquals",
1149
+ path: _path + _accessExpressionAsString(key),
1150
+ expected: "undefined",
1151
+ value: value
1152
+ }, _errorFactory);
1153
+ }));
1154
+ const _ao5 = (input, _path, _exceptionable = true)=>(void 0 === input.define || ("object" == typeof input.define && null !== input.define && false === Array.isArray(input.define) || _assertGuard(_exceptionable, {
1155
+ method: "typia.createAssertEquals",
1156
+ path: _path + ".define",
1157
+ expected: "(Record<string, string> | undefined)",
1158
+ value: input.define
1159
+ }, _errorFactory)) && _ao6(input.define, _path + ".define", _exceptionable) || _assertGuard(_exceptionable, {
1160
+ method: "typia.createAssertEquals",
1161
+ path: _path + ".define",
1162
+ expected: "(Record<string, string> | undefined)",
1163
+ value: input.define
1164
+ }, _errorFactory)) && (0 === Object.keys(input).length || false === _exceptionable || Object.keys(input).every((key)=>{
1165
+ if ([
1166
+ "define"
1167
+ ].some((prop)=>key === prop)) return true;
1168
+ const value = input[key];
1169
+ if (void 0 === value) return true;
1170
+ return _assertGuard(_exceptionable, {
1171
+ method: "typia.createAssertEquals",
1172
+ path: _path + _accessExpressionAsString(key),
1173
+ expected: "undefined",
1174
+ value: value
1175
+ }, _errorFactory);
1176
+ }));
1177
+ const _ao6 = (input, _path, _exceptionable = true)=>false === _exceptionable || Object.keys(input).every((key)=>{
1178
+ const value = input[key];
1179
+ if (void 0 === value) return true;
1180
+ return "string" == typeof value || _assertGuard(_exceptionable, {
1181
+ method: "typia.createAssertEquals",
1182
+ path: _path + _accessExpressionAsString(key),
1183
+ expected: "string",
1184
+ value: value
1185
+ }, _errorFactory);
1186
+ });
1187
+ const _ao7 = (input, _path, _exceptionable = true)=>(void 0 === input.strLength || "number" == typeof input.strLength || _assertGuard(_exceptionable, {
1188
+ method: "typia.createAssertEquals",
1189
+ path: _path + ".strLength",
1190
+ expected: "(number | undefined)",
1191
+ value: input.strLength
1192
+ }, _errorFactory)) && (0 === Object.keys(input).length || false === _exceptionable || Object.keys(input).every((key)=>{
1193
+ if ([
1194
+ "strLength"
1195
+ ].some((prop)=>key === prop)) return true;
1196
+ const value = input[key];
1197
+ if (void 0 === value) return true;
1198
+ return _assertGuard(_exceptionable, {
1199
+ method: "typia.createAssertEquals",
1200
+ path: _path + _accessExpressionAsString(key),
1201
+ expected: "undefined",
1202
+ value: value
1203
+ }, _errorFactory);
1204
+ }));
1205
+ const _ao8 = (input, _path, _exceptionable = true)=>(void 0 === input.mainThread || "boolean" == typeof input.mainThread || _assertGuard(_exceptionable, {
1206
+ method: "typia.createAssertEquals",
1207
+ path: _path + ".mainThread",
1208
+ expected: "(boolean | undefined)",
1209
+ value: input.mainThread
1210
+ }, _errorFactory)) && (void 0 === input.background || "boolean" == typeof input.background || _assertGuard(_exceptionable, {
1211
+ method: "typia.createAssertEquals",
1212
+ path: _path + ".background",
1213
+ expected: "(boolean | undefined)",
1214
+ value: input.background
1215
+ }, _errorFactory)) && (0 === Object.keys(input).length || false === _exceptionable || Object.keys(input).every((key)=>{
1216
+ if ([
1217
+ "mainThread",
1218
+ "background"
1219
+ ].some((prop)=>key === prop)) return true;
1220
+ const value = input[key];
1221
+ if (void 0 === value) return true;
1222
+ return _assertGuard(_exceptionable, {
1223
+ method: "typia.createAssertEquals",
1224
+ path: _path + _accessExpressionAsString(key),
1225
+ expected: "undefined",
1226
+ value: value
1227
+ }, _errorFactory);
1228
+ }));
1229
+ const __is = (input, _exceptionable = true)=>void 0 === input || "object" == typeof input && null !== input && false === Array.isArray(input) && _io0(input, true);
1230
+ let _errorFactory;
1231
+ return (input, errorFactory = ({ path, expected, value })=>{
1232
+ if ('undefined' === expected) {
1233
+ const errorMessage = `Unknown property: \`${path}\` in the configuration of pluginReactLynx. If you are trying to set a Lynx config, use \`pluginLynxConfig\` (the Lynx Config rsbuild plugin) instead.`;
1234
+ return new Error(errorMessage);
1235
+ }
1236
+ return new Error([
1237
+ `Invalid config on pluginReactLynx: \`${path}\`.`,
1238
+ ` - Expect to be ${expected}`,
1239
+ ` - Got: ${whatIs(value)}`,
1240
+ ''
1241
+ ].join('\n'));
1242
+ })=>{
1243
+ if (false === __is(input)) {
1244
+ _errorFactory = errorFactory;
1245
+ ((input, _path, _exceptionable = true)=>void 0 === input || ("object" == typeof input && null !== input && false === Array.isArray(input) || _assertGuard(true, {
1246
+ method: "typia.createAssertEquals",
1247
+ path: _path + "",
1248
+ expected: "(PluginReactLynxOptions | undefined)",
1249
+ value: input
1250
+ }, _errorFactory)) && _ao0(input, _path + "", true) || _assertGuard(true, {
1251
+ method: "typia.createAssertEquals",
1252
+ path: _path + "",
1253
+ expected: "(PluginReactLynxOptions | undefined)",
1254
+ value: input
1255
+ }, _errorFactory))(input, "$input", true);
1256
+ }
1257
+ return input;
1258
+ };
1259
+ })();
1260
+ function whatIs(value) {
1261
+ return Object.prototype.toString.call(value).replace(/^\[object\s+([a-z]+)\]$/i, '$1').toLowerCase();
1262
+ }
1263
+ function pluginReactLynx(userOptions) {
1264
+ validateConfig(userOptions);
1265
+ const engineVersion = userOptions?.engineVersion ?? userOptions?.targetSdkVersion ?? '3.2';
1266
+ const defaultOptions = {
1267
+ compat: void 0,
1268
+ customCSSInheritanceList: void 0,
1269
+ debugInfoOutside: true,
1270
+ defaultDisplayLinear: true,
1271
+ enableAccessibilityElement: false,
1272
+ enableCSSInheritance: false,
1273
+ enableCSSInvalidation: true,
1274
+ enableCSSSelector: true,
1275
+ enableNewGesture: false,
1276
+ enableRemoveCSSScope: true,
1277
+ firstScreenSyncTiming: 'immediately',
1278
+ enableSSR: false,
1279
+ removeDescendantSelectorScope: true,
1280
+ shake: void 0,
1281
+ defineDCE: void 0,
1282
+ targetSdkVersion: '',
1283
+ engineVersion: '',
1284
+ extractStr: false,
1285
+ globalPropsMode: 'reactive',
1286
+ experimental_isLazyBundle: false,
1287
+ experimental_useElementTemplate: false,
1288
+ optimizeBundleSize: false,
1289
+ enableUiSourceMap: false
1290
+ };
1291
+ const resolvedOptions = Object.assign(defaultOptions, userOptions, {
1292
+ targetSdkVersion: engineVersion,
1293
+ engineVersion
1294
+ });
1295
+ return [
1296
+ pluginReactAlias({
1297
+ lazy: resolvedOptions.experimental_isLazyBundle,
1298
+ elementTemplate: resolvedOptions.experimental_useElementTemplate,
1299
+ LAYERS: LAYERS
1300
+ }),
1301
+ {
1302
+ name: 'lynx:react',
1303
+ pre: [
1304
+ 'lynx:rsbuild:plugin-api',
1305
+ 'lynx:config'
1306
+ ],
1307
+ setup (api) {
1308
+ const isRslib = 'rslib' === api.context.callerName;
1309
+ const isRstest = 'rstest' === api.context.callerName;
1310
+ const exposedConfig = api.useExposed(Symbol.for('lynx.config'));
1311
+ if (exposedConfig) Object.keys(defaultOptions).forEach((key)=>{
1312
+ if (Object.hasOwn(exposedConfig.config, key)) Object.assign(resolvedOptions, {
1313
+ [key]: exposedConfig.config[key]
1314
+ });
1315
+ });
1316
+ if (!isRstest) applyCSS(api, resolvedOptions);
1317
+ applyEntry(api, resolvedOptions);
1318
+ applyBackgroundOnly(api);
1319
+ applyGenerator(api, resolvedOptions);
1320
+ if (isRstest) applyTestingLoaders(api, resolvedOptions);
1321
+ else applyLoaders(api, resolvedOptions);
1322
+ applyRefresh(api);
1323
+ applySplitChunksRule(api);
1324
+ applySWC(api);
1325
+ applyUseSyncExternalStore(api);
1326
+ if (isRslib) applyNodeEnv(api);
1327
+ api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>{
1328
+ const userConfig = api.getRsbuildConfig('original');
1329
+ if (void 0 === userConfig.source?.include) config = mergeRsbuildConfig(config, {
1330
+ source: {
1331
+ include: [
1332
+ /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/
1333
+ ]
1334
+ }
1335
+ });
1336
+ config = mergeRsbuildConfig({
1337
+ tools: {
1338
+ rspack: {
1339
+ output: {
1340
+ iife: false
1341
+ }
1342
+ }
1343
+ }
1344
+ }, config);
1345
+ config = mergeRsbuildConfig({
1346
+ resolve: {
1347
+ dedupe: [
1348
+ 'react-compiler-runtime'
1349
+ ]
1350
+ }
1351
+ }, config);
1352
+ return config;
1353
+ });
1354
+ if (resolvedOptions.optimizeBundleSize) applyOptimizeBundleSize(api, resolvedOptions);
1355
+ if (resolvedOptions.experimental_isLazyBundle) applyLazy(api);
1356
+ api.expose(Symbol.for('LAYERS'), LAYERS);
1357
+ api.expose(Symbol.for('LynxTemplatePlugin'), {
1358
+ LynxTemplatePlugin: {
1359
+ getLynxTemplatePluginHooks: LynxTemplatePlugin.getLynxTemplatePluginHooks.bind(LynxTemplatePlugin)
1360
+ }
1361
+ });
1362
+ const require = createRequire(import.meta.url);
1363
+ const { version } = require('../package.json');
1364
+ const webpackPluginPath = require.resolve('@lynx-js/react-webpack-plugin');
1365
+ api.logger?.debug(`Using @lynx-js/react-webpack-plugin v${version} at ${webpackPluginPath}`);
1366
+ }
1367
+ },
1368
+ {
1369
+ name: 'lynx:react:css-minify-guard',
1370
+ enforce: 'post',
1371
+ setup (api) {
1372
+ if (false !== resolvedOptions.enableRemoveCSSScope) return;
1373
+ api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>mergeRsbuildConfig(config, {
1374
+ output: {
1375
+ minify: {
1376
+ css: false
1377
+ }
1378
+ }
1379
+ }));
1380
+ }
1381
+ }
1382
+ ];
1383
+ }
1384
+ export { LAYERS, pluginReactLynx };