@upupming/react-rsbuild-plugin 0.0.0-stage → 0.22.2-genui.20261113.2

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