@lynx-js/react 0.123.1 → 0.123.3

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/package.json +1 -1
  3. package/runtime/lib/element-template/background/commit-hook.js +3 -0
  4. package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
  5. package/runtime/lib/element-template/prop-adapters/spread.js +11 -11
  6. package/runtime/lib/element-template/prop-adapters/spread.js.map +1 -1
  7. package/runtime/lib/element-template/protocol/types.d.ts +1 -0
  8. package/runtime/lib/shared/attribute-name.d.ts +3 -0
  9. package/runtime/lib/shared/attribute-name.js +91 -0
  10. package/runtime/lib/shared/attribute-name.js.map +1 -0
  11. package/runtime/lib/snapshot/lifecycle/patch/commit.js +3 -0
  12. package/runtime/lib/snapshot/lifecycle/patch/commit.js.map +1 -1
  13. package/runtime/lib/snapshot/lynx/portals.d.ts +25 -3
  14. package/runtime/lib/snapshot/lynx/portals.js +24 -1
  15. package/runtime/lib/snapshot/lynx/portals.js.map +1 -1
  16. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js +19 -0
  17. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js.map +1 -1
  18. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js +97 -65
  19. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -1
  20. package/runtime/lib/snapshot/snapshot/platformInfo.js +20 -9
  21. package/runtime/lib/snapshot/snapshot/platformInfo.js.map +1 -1
  22. package/runtime/lib/snapshot/snapshot/spread.js +27 -17
  23. package/runtime/lib/snapshot/snapshot/spread.js.map +1 -1
  24. package/runtime/lib/snapshot/snapshot/utils.js +8 -3
  25. package/runtime/lib/snapshot/snapshot/utils.js.map +1 -1
  26. package/runtime/lib/tsconfig.tsbuildinfo +1 -1
  27. package/testing-library/dist/env/index.js +37 -19
  28. package/testing-library/dist/index.d.ts +1 -0
  29. package/testing-library/dist/pure.js +1 -1
  30. package/testing-library/dist/rstest-config.js +1 -1
  31. package/transform/dist/wasm.cjs +1 -1
  32. package/transform/index.d.ts +63 -24
  33. /package/testing-library/dist/{0-@rstest/adapter-rsbuild.js → @rstest/adapter-rsbuild~0.js} +0 -0
  34. /package/testing-library/dist/{0-rslib-runtime.js → rslib-runtime-0.js} +0 -0
@@ -99,8 +99,7 @@ export interface CompatVisitorConfig {
99
99
  * @public
100
100
  * Specifies the list of component package names that need compatibility processing
101
101
  *
102
- * @remarks
103
- * Default value: `['@lynx-js/react-components']`
102
+ * @defaultValue `['@lynx-js/react-components']`
104
103
  *
105
104
  * @example
106
105
  *
@@ -124,8 +123,7 @@ export interface CompatVisitorConfig {
124
123
  * @public
125
124
  * Specifies the list of old runtime package names that need compatibility processing
126
125
  *
127
- * @remarks
128
- * Default value: `['@lynx-js/react-runtime']`
126
+ * @defaultValue `['@lynx-js/react-runtime']`
129
127
  *
130
128
  * @example
131
129
  *
@@ -149,8 +147,7 @@ export interface CompatVisitorConfig {
149
147
  * @public
150
148
  * Specifies the new runtime package name
151
149
  *
152
- * @remarks
153
- * Default value: `'@lynx-js/react'`
150
+ * @defaultValue `'@lynx-js/react'`
154
151
  *
155
152
  * @example
156
153
  *
@@ -174,11 +171,11 @@ export interface CompatVisitorConfig {
174
171
  * @public
175
172
  * Specifies additional component attributes list, these attributes will be passed to the wrapped `<view>` instead of the component.
176
173
  *
174
+ * @defaultValue `[]`
175
+ *
177
176
  * @remarks
178
177
  * This only takes effect when {@link CompatVisitorConfig.addComponentElement} is enabled.
179
178
  *
180
- * Default value: `[]`
181
- *
182
179
  * @example
183
180
  *
184
181
  * ```js
@@ -201,8 +198,7 @@ export interface CompatVisitorConfig {
201
198
  * @public
202
199
  * Controls whether to add wrapper elements for components
203
200
  *
204
- * @remarks
205
- * Default value: `false`
201
+ * @defaultValue `false`
206
202
  *
207
203
  * @example
208
204
  *
@@ -259,8 +255,7 @@ export interface CompatVisitorConfig {
259
255
  *
260
256
  * Instead, use `background-only` on class methods for explicit and maintainable behavior
261
257
  *
262
- * @remarks
263
- * Default value: `false`
258
+ * @defaultValue `false`
264
259
  *
265
260
  * @example
266
261
  *
@@ -288,8 +283,7 @@ export interface CompatVisitorConfig {
288
283
  *
289
284
  * If your code depends on this switch, when distributing it to other projects through npm packages or other means, you'll also need to enable this switch. This will lead to the proliferation of switches, which is not conducive to code reuse between different projects.
290
285
  *
291
- * @remarks
292
- * Default value: `None`
286
+ * @defaultValue `undefined`
293
287
  *
294
288
  * @example
295
289
  *
@@ -313,8 +307,7 @@ export interface CompatVisitorConfig {
313
307
  * @public
314
308
  * Whether to disable deprecated warnings
315
309
  *
316
- * @remarks
317
- * Default value: `false`
310
+ * @defaultValue `false`
318
311
  *
319
312
  * @example
320
313
  *
@@ -341,8 +334,7 @@ export interface CompatVisitorConfig {
341
334
  * @deprecated
342
335
  * Dark mode configuration
343
336
  *
344
- * @remarks
345
- * Default value: `None`
337
+ * @defaultValue `undefined`
346
338
  *
347
339
  * @example
348
340
  *
@@ -477,8 +469,7 @@ export interface ExtractStrConfig {
477
469
  * @public
478
470
  * The minimum length of string literals to be extracted.
479
471
  *
480
- * @remarks
481
- * Default value: `20`.
472
+ * @defaultValue `20`
482
473
  *
483
474
  * @example
484
475
  *
@@ -531,9 +522,11 @@ export interface ShakeVisitorConfig {
531
522
  * })
532
523
  * ```
533
524
  *
525
+ * @defaultValue `['@lynx-js/react-runtime']`
526
+ *
534
527
  * @remarks
535
- * Default value: `['@lynx-js/react-runtime']`
536
528
  * The provided values will be merged with the default values instead of replacing them.
529
+ *
537
530
  * @public
538
531
  */
539
532
  pkgName: Array<string>
@@ -556,8 +549,9 @@ export interface ShakeVisitorConfig {
556
549
  * })
557
550
  * ```
558
551
  *
552
+ * @defaultValue `['constructor', 'render', 'getDerivedStateFromProps', 'state', 'defaultDataProcessor', 'dataProcessors', 'contextType', 'defaultProps']`
553
+ *
559
554
  * @remarks
560
- * Default value: `['constructor', 'render', 'getDerivedStateFromProps', 'state', 'defaultDataProcessor', 'dataProcessors', 'contextType', 'defaultProps']`
561
555
  * The provided values will be merged with the default values instead of replacing them.
562
556
  *
563
557
  * @public
@@ -582,8 +576,9 @@ export interface ShakeVisitorConfig {
582
576
  * })
583
577
  * ```
584
578
  *
579
+ * @defaultValue `['useEffect', 'useLayoutEffect', '__runInJS', 'useLynxGlobalEventListener', 'useImperativeHandle']`
580
+ *
585
581
  * @remarks
586
- * Default value: `['useEffect', 'useLayoutEffect', '__runInJS', 'useLynxGlobalEventListener', 'useImperativeHandle']`
587
582
  * The provided values will be merged with the default values instead of replacing them.
588
583
  *
589
584
  * @public
@@ -608,8 +603,9 @@ export interface ShakeVisitorConfig {
608
603
  * })
609
604
  * ```
610
605
  *
606
+ * @defaultValue `[]`
607
+ *
611
608
  * @remarks
612
- * Default value: `[]`
613
609
  * The provided values will be merged with the default values instead of replacing them.
614
610
  *
615
611
  * @public
@@ -670,6 +666,35 @@ export interface WorkletVisitorConfig {
670
666
  target: 'LEPUS' | 'JS' | 'MIXED'
671
667
  runtimePkg: string
672
668
  }
669
+ /**
670
+ * Serializable rules for transforming builtin element attribute names.
671
+ *
672
+ * Exact entries in `rename` take precedence over `preserve`, followed by the
673
+ * fallback behavior selected by `mode`.
674
+ *
675
+ * @public
676
+ */
677
+ export interface TransformBuiltinAttributeNamesOptions {
678
+ /**
679
+ * The fallback behavior for attribute names not listed in `rename` or
680
+ * `preserve`.
681
+ *
682
+ * `'dash-case'` also applies the default React-style event mappings.
683
+ * `'mapping-only'` leaves all remaining names unchanged.
684
+ *
685
+ * @defaultValue `'dash-case'`
686
+ */
687
+ mode?: 'dash-case' | 'mapping-only'
688
+ /**
689
+ * Attribute names that should remain unchanged unless an exact `rename`
690
+ * entry is also present.
691
+ */
692
+ preserve?: ReadonlyArray<string>
693
+ /**
694
+ * Exact mappings from source attribute names to transformed attribute names.
695
+ */
696
+ rename?: Readonly<Record<string, string>>
697
+ }
673
698
  export interface TransformNodiffOptions {
674
699
  /**
675
700
  * @internal
@@ -699,6 +724,20 @@ export interface TransformNodiffOptions {
699
724
  directiveDCE: boolean | DirectiveDceVisitorConfig
700
725
  worklet: boolean | WorkletVisitorConfig
701
726
  dynamicImport?: boolean | DynamicImportVisitorConfig
727
+ /**
728
+ * Transform attribute names on Lynx builtin elements.
729
+ *
730
+ * `true` applies the default rule: `onClick` becomes `bindtap`,
731
+ * `onCatchTap` becomes `catchtap`, other `onXXX` names become `bindxxx`,
732
+ * and remaining camelCase names become dash-case. An object provides
733
+ * serializable custom rules.
734
+ * Explicit JSX attributes are transformed during compilation. Attributes
735
+ * supplied through JSX spreads are transformed by the runtime with the same
736
+ * rules.
737
+ *
738
+ * @experimental
739
+ */
740
+ experimental_transformBuiltinAttributeNames?: boolean | TransformBuiltinAttributeNamesOptions
702
741
  /** @internal */
703
742
  inject?: boolean | InjectVisitorConfig
704
743
  inputSourceMap?: string