@lynx-js/react-rsbuild-plugin 0.16.3 → 0.17.1

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