Skip to content

Commit d0acdba

Browse files
authored
Inferno - update to v8 (#29318)
1 parent 2814b91 commit d0acdba

File tree

14 files changed

+187
-171
lines changed

14 files changed

+187
-171
lines changed

apps/demos/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
"fs-extra": "11.1.1",
5151
"globalize": "1.7.0",
5252
"html-react-parser": "1.4.14",
53-
"inferno": "^7.4.9",
54-
"inferno-create-element": "7.4.11",
53+
"inferno": "catalog:",
54+
"inferno-create-element": "catalog:",
5555
"jquery": "3.6.3",
5656
"jspdf": "2.5.2",
5757
"jspdf-autotable": "3.8.3",

apps/react-storybook/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"dependencies": {
1414
"devextreme": "workspace:~",
1515
"devextreme-react": "workspace:~",
16-
"inferno": "^7.4.9",
16+
"inferno": "catalog:",
1717
"html-react-parser": "^5.2.2"
1818
},
1919
"devDependencies": {

packages/devextreme-angular/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
"dependencies": {
8888
"@angular-devkit/schematics": "17.3.11",
8989
"devextreme-schematics": "*",
90-
"inferno-server": "7.4.11"
90+
"inferno-server": "catalog:"
9191
},
9292
"schematics": "./schematics/collection.json",
9393
"publishConfig": {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import type { Inferno } from 'inferno';
2+
3+
declare global {
4+
// eslint-disable-next-line @typescript-eslint/no-namespace
5+
namespace JSX {
6+
type Element = Inferno.InfernoElement;
7+
}
8+
}

packages/devextreme/js/__internal/core/r1/component_wrapper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ export class ComponentWrapper extends DOMComponent<ComponentWrapperProps> {
234234
super._dispose();
235235
}
236236

237-
get elementAttr(): HTMLAttributes<unknown> {
237+
get elementAttr(): Record<string, unknown> {
238238
const element = this.$element()[0];
239239
if (!this._elementAttr) {
240240
const { attributes } = element;
@@ -356,7 +356,7 @@ export class ComponentWrapper extends DOMComponent<ComponentWrapperProps> {
356356
...this.elementAttr,
357357
...elementAttr,
358358
className: [
359-
...(this.elementAttr.class ?? '').split(' '),
359+
...(this.elementAttr.class as string ?? '').split(' '),
360360
...(elementAttr?.class ?? '').split(' '),
361361
]
362362
.filter((c, i, a) => c && a.indexOf(c) === i)

packages/devextreme/js/__internal/core/r1/runtime/inferno/base_component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
22
/* eslint-disable @typescript-eslint/explicit-function-return-type */
33
/* eslint-disable @typescript-eslint/no-explicit-any */
4-
/* eslint-disable spellcheck/spell-checker */
4+
55
/* eslint-disable max-classes-per-file */
6-
import { Component, findDOMfromVNode } from 'inferno';
6+
import { Component, findDOMFromVNode } from 'inferno';
77

88
import type { InfernoEffect } from './effect';
99
import { InfernoEffectHost } from './effect_host';
@@ -134,7 +134,7 @@ export class InfernoWrapperComponent<
134134
}
135135

136136
componentDidMount(): void {
137-
const el = findDOMfromVNode(this.$LI, true) as ElementWithCustomClassesData;
137+
const el = findDOMFromVNode(this.$LI, true) as ElementWithCustomClassesData;
138138
this.vDomElement = el;
139139
super.componentDidMount();
140140
el.dxClasses = el.dxClasses || {

packages/devextreme/js/__internal/core/r1/runtime/inferno/mocked/hydrate.ts

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/* eslint-disable simple-import-sort/imports */
2121
/* eslint-disable @typescript-eslint/consistent-type-imports */
2222
import {
23-
_CI, _HI, _M, _MCCC, _ME, _MFCC, _MP, _MR, EMPTY_OBJ, render, VNode, _RFC as renderFunctionalComponent,
23+
_CI, _HI, _M, _MCCC, _ME, _MFCC, _MP, _MR, EMPTY_OBJ, render, VNode, _RFC as renderFunctionalComponent, AnimationQueues,
2424
} from 'inferno';
2525
import {
2626
isFunction, isInvalid, isNull, isNullOrUndef, throwError,
@@ -63,7 +63,7 @@ function isSamePropsInnerHTML(dom: Element, props: any): boolean {
6363
return Boolean(props && props.dangerouslySetInnerHTML && props.dangerouslySetInnerHTML.__html && isSameInnerHTML(dom, props.dangerouslySetInnerHTML.__html));
6464
}
6565

66-
function hydrateComponent(vNode: VNode, parentDOM: Element, dom: Element, context: any, isSVG: boolean, isClass: boolean, lifecycle: Function[]) {
66+
function hydrateComponent(vNode: VNode, parentDOM: Element, dom: Element, context: any, isSVG: boolean, isClass: boolean, lifecycle: (() => void)[], animations: AnimationQueues) {
6767
const type = vNode.type as Function;
6868
const ref = vNode.ref;
6969
const props = vNode.props || EMPTY_OBJ;
@@ -73,19 +73,19 @@ function hydrateComponent(vNode: VNode, parentDOM: Element, dom: Element, contex
7373
const instance = _CI(vNode, type, props, context, isSVG, lifecycle);
7474
const input = instance.$LI;
7575

76-
currentNode = hydrateVNode(input, parentDOM, dom, instance.$CX, isSVG, lifecycle);
77-
_MCCC(ref, instance, lifecycle);
76+
currentNode = hydrateVNode(input, parentDOM, dom, instance.$CX, isSVG, lifecycle, animations);
77+
_MCCC(ref, instance, lifecycle, animations);
7878
} else {
7979
const input = _HI(renderFunctionalComponent(vNode, context));
80-
currentNode = hydrateVNode(input, parentDOM, dom, context, isSVG, lifecycle);
80+
currentNode = hydrateVNode(input, parentDOM, dom, context, isSVG, lifecycle, animations);
8181
vNode.children = input;
82-
_MFCC(vNode, lifecycle);
82+
_MFCC(vNode, lifecycle, animations);
8383
}
8484

8585
return currentNode;
8686
}
8787

88-
function hydrateChildren(parentVNode: VNode, parentNode: any, currentNode: any, context: any, isSVG: boolean, lifecycle: Function[]) {
88+
function hydrateChildren(parentVNode: VNode, parentNode: any, currentNode: any, context: any, isSVG: boolean, lifecycle: (() => void)[], animations: AnimationQueues) {
8989
const childFlags = parentVNode.childFlags as unknown as ChildFlags;
9090
const children = parentVNode.children;
9191
const props = parentVNode.props;
@@ -94,9 +94,9 @@ function hydrateChildren(parentVNode: VNode, parentNode: any, currentNode: any,
9494
if (childFlags !== ChildFlags.HasInvalidChildren) {
9595
if (childFlags === ChildFlags.HasVNodeChildren) {
9696
if (isNull(currentNode)) {
97-
_M(children as VNode, parentNode, context, isSVG, null, lifecycle);
97+
_M(children as VNode, parentNode, context, isSVG, null, lifecycle, animations);
9898
} else {
99-
currentNode = hydrateVNode(children as VNode, parentNode, currentNode as Element, context, isSVG, lifecycle);
99+
currentNode = hydrateVNode(children as VNode, parentNode, currentNode as Element, context, isSVG, lifecycle, animations);
100100
currentNode = currentNode ? currentNode.nextSibling : null;
101101
}
102102
} else if (childFlags === ChildFlags.HasTextChildren) {
@@ -115,9 +115,9 @@ function hydrateChildren(parentVNode: VNode, parentNode: any, currentNode: any,
115115
const child = (children as VNode[])[i];
116116

117117
if (isNull(currentNode) || (prevVNodeIsTextNode && (child.flags & VNodeFlags.Text) > 0)) {
118-
_M(child as VNode, parentNode, context, isSVG, currentNode, lifecycle);
118+
_M(child as VNode, parentNode, context, isSVG, currentNode, lifecycle, animations);
119119
} else {
120-
currentNode = hydrateVNode(child as VNode, parentNode, currentNode as Element, context, isSVG, lifecycle);
120+
currentNode = hydrateVNode(child as VNode, parentNode, currentNode as Element, context, isSVG, lifecycle, animations);
121121
currentNode = currentNode ? currentNode.nextSibling : null;
122122
}
123123

@@ -144,23 +144,23 @@ function hydrateChildren(parentVNode: VNode, parentNode: any, currentNode: any,
144144
}
145145
}
146146

147-
function hydrateElement(vNode: VNode, parentDOM: Element, dom: Element, context: Object, isSVG: boolean, lifecycle: Function[]) {
147+
function hydrateElement(vNode: VNode, parentDOM: Element, dom: Element, context, isSVG: boolean, lifecycle: (() => void)[], animations: AnimationQueues) {
148148
const props = vNode.props;
149149
const className = vNode.className;
150150
const flags = vNode.flags;
151151
const ref = vNode.ref;
152152

153153
isSVG = isSVG || (flags & VNodeFlags.SvgElement) > 0;
154154
if (dom.nodeType !== 1) {
155-
_ME(vNode, null, context, isSVG, null, lifecycle);
155+
_ME(vNode, null, context, isSVG, null, lifecycle, animations);
156156
parentDOM.replaceChild(vNode.dom as Element, dom);
157157
} else {
158158
vNode.dom = dom;
159159

160-
hydrateChildren(vNode, dom, dom.firstChild, context, isSVG, lifecycle);
160+
hydrateChildren(vNode, dom, dom.firstChild, context, isSVG, lifecycle, animations);
161161

162162
if (!isNull(props)) {
163-
_MP(vNode, flags, props, dom, isSVG);
163+
_MP(vNode, flags, props, dom, isSVG, animations);
164164
}
165165
if (isNullOrUndef(className)) {
166166
if (dom.className !== '') {
@@ -192,7 +192,7 @@ function hydrateText(vNode: VNode, parentDOM: Element, dom: Element) {
192192
return vNode.dom;
193193
}
194194

195-
function hydrateFragment(vNode: VNode, parentDOM: Element, dom: Element, context: any, isSVG: boolean, lifecycle: Function[]): Element {
195+
function hydrateFragment(vNode: VNode, parentDOM: Element, dom: Element, context: any, isSVG: boolean, lifecycle: (() => void)[], animations: AnimationQueues): Element {
196196
const children = vNode.children;
197197

198198
if ((vNode.childFlags as unknown as ChildFlags) === ChildFlags.HasVNodeChildren) {
@@ -201,19 +201,19 @@ function hydrateFragment(vNode: VNode, parentDOM: Element, dom: Element, context
201201
return (children as VNode).dom as Element;
202202
}
203203

204-
hydrateChildren(vNode, parentDOM, dom, context, isSVG, lifecycle);
204+
hydrateChildren(vNode, parentDOM, dom, context, isSVG, lifecycle, animations);
205205

206206
return findLastDOMFromVNode((children as VNode[])[(children as VNode[]).length - 1]) as Element;
207207
}
208208

209-
function hydrateVNode(vNode: VNode, parentDOM: Element, currentDom: Element, context: Object, isSVG: boolean, lifecycle: Function[]): Element | null {
209+
function hydrateVNode(vNode: VNode, parentDOM: Element, currentDom: Element, context: Object, isSVG: boolean, lifecycle: (() => void)[], animations: AnimationQueues): Element | null {
210210
const flags = (vNode.flags |= VNodeFlags.InUse);
211211

212212
if (flags & VNodeFlags.Component) {
213-
return hydrateComponent(vNode, parentDOM, currentDom, context, isSVG, (flags & VNodeFlags.ComponentClass) > 0, lifecycle);
213+
return hydrateComponent(vNode, parentDOM, currentDom, context, isSVG, (flags & VNodeFlags.ComponentClass) > 0, lifecycle, animations);
214214
}
215215
if (flags & VNodeFlags.Element) {
216-
return hydrateElement(vNode, parentDOM, currentDom, context, isSVG, lifecycle);
216+
return hydrateElement(vNode, parentDOM, currentDom, context, isSVG, lifecycle, animations);
217217
}
218218
if (flags & VNodeFlags.Text) {
219219
return hydrateText(vNode, parentDOM, currentDom);
@@ -222,24 +222,25 @@ function hydrateVNode(vNode: VNode, parentDOM: Element, currentDom: Element, con
222222
return (vNode.dom = currentDom);
223223
}
224224
if (flags & VNodeFlags.Fragment) {
225-
return hydrateFragment(vNode, parentDOM, currentDom, context, isSVG, lifecycle);
225+
return hydrateFragment(vNode, parentDOM, currentDom, context, isSVG, lifecycle, animations);
226226
}
227227

228228
throwError();
229229

230230
return null;
231231
}
232232

233-
export function hydrate(input: any, parentDOM: Element, callback?: Function) {
233+
export function hydrate(input: any, parentDOM: Element, callback?: () => void) {
234234
let dom = parentDOM.firstChild as Element;
235235

236236
if (isNull(dom)) {
237237
render(input, parentDOM, callback);
238238
} else {
239-
const lifecycle: Function[] = [];
239+
const lifecycle: (() => void)[] = [];
240+
const animations = new AnimationQueues();
240241

241242
if (!isInvalid(input)) {
242-
dom = hydrateVNode(input, parentDOM, dom, {}, false, lifecycle) as Element;
243+
dom = hydrateVNode(input, parentDOM, dom, {}, false, lifecycle, animations) as Element;
243244
}
244245
// clear any other DOM nodes, there should be only a single entry for the root
245246
while (dom && (dom = dom.nextSibling as Element)) {

packages/devextreme/js/__internal/core/r1/template_wrapper.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import type { FunctionTemplate } from '@js/core/templates/function_template';
77
import { replaceWith } from '@js/core/utils/dom';
88
import { isDefined } from '@js/core/utils/type';
99
import { InfernoComponent, InfernoEffect } from '@ts/core/r1/runtime/inferno/index';
10-
// eslint-disable-next-line spellcheck/spell-checker
11-
import { findDOMfromVNode } from 'inferno';
10+
import { findDOMFromVNode } from 'inferno';
1211

1312
import { shallowEquals } from './utils/shallow_equals';
1413

@@ -113,8 +112,7 @@ export class TemplateWrapper extends InfernoComponent<TemplateWrapperProps> {
113112
}
114113

115114
renderTemplate(): () => void {
116-
// eslint-disable-next-line spellcheck/spell-checker
117-
const node = findDOMfromVNode(this.$LI, true);
115+
const node = findDOMFromVNode(this.$LI, true);
118116

119117
/* istanbul ignore next */
120118
if (!node?.parentNode) {

packages/devextreme/js/__internal/core/r1/types.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import type * as CSS from 'csstype';
2-
import type { Component, StatelessComponent, VNode } from 'inferno';
2+
import type {
3+
ComponentType, VNode,
4+
} from 'inferno';
35

46
import type { TemplateModel } from './template_wrapper';
57

@@ -24,9 +26,6 @@ export interface PropsWithChildren {
2426
children?: JSX.Element | (JSX.Element | undefined | false | null)[];
2527
}
2628

27-
// TODO: replace by import from inferno after update to inferno 8
28-
export type ComponentType<P = {}> = typeof Component<P> | StatelessComponent<P>;
29-
3029
export interface RefObject<T> {
3130
current: T | null;
3231
}

packages/devextreme/js/__internal/scheduler/r1/components/base/row.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ export class Row extends BaseInfernoComponent<RowProps> {
4747
hasLeftVirtualCell
4848
&& leftVirtualCellCount != null
4949
&& splitNumber(leftVirtualCellCount, MAX_COL_SPAN).map(
50-
// @ts-ignore
51-
(colSpan, index) => <VirtualCell
52-
className={`left-virtual-cell-${index}`}
50+
(colSpan) => <VirtualCell
51+
// TODO: do we need this?
52+
// className={`left-virtual-cell-${index}`}
5353
width={leftVirtualCellWidth * (colSpan / leftVirtualCellCount)}
5454
colSpan={colSpan}
5555
isHeaderCell={isHeaderRow ?? VirtualCellDefaultProps.isHeaderCell}
@@ -61,9 +61,9 @@ export class Row extends BaseInfernoComponent<RowProps> {
6161
hasRightVirtualCell
6262
&& rightVirtualCellCount != null
6363
&& splitNumber(rightVirtualCellCount, MAX_COL_SPAN).map(
64-
// @ts-ignore
65-
(colSpan, index) => <VirtualCell
66-
className={`right-virtual-cell-${index}`}
64+
(colSpan) => <VirtualCell
65+
// TODO: do we need this?
66+
// className={`right-virtual-cell-${index}`}
6767
width={rightVirtualCellWidth * (colSpan / rightVirtualCellCount)}
6868
colSpan={colSpan}
6969
isHeaderCell={isHeaderRow ?? VirtualCellDefaultProps.isHeaderCell}

0 commit comments

Comments
 (0)