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