@lynx-js/react-rsbuild-plugin-canary 1.0.0-canary-20250918-9c8321cb → 1.0.0-canary-20260116-ce265e8f

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