chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
import type { ActionDataState } from "reducers/entityReducers/actionsReducer";
|
|
|
|
|
import type { WidgetProps } from "widgets/BaseWidget";
|
|
|
|
|
import type { CanvasWidgetsReduxState } from "reducers/entityReducers/canvasWidgetsReducer";
|
|
|
|
|
import type { MetaState } from "reducers/entityReducers/metaReducer";
|
|
|
|
|
import type { Page } from "@appsmith/constants/ReduxActionConstants";
|
|
|
|
|
import type { AppDataState } from "reducers/entityReducers/appReducer";
|
|
|
|
|
import type { DependencyMap } from "utils/DynamicBindingUtils";
|
2021-03-30 05:29:03 +00:00
|
|
|
import { generateDataTreeAction } from "entities/DataTree/dataTreeAction";
|
2021-09-08 17:32:22 +00:00
|
|
|
import { generateDataTreeJSAction } from "entities/DataTree/dataTreeJSAction";
|
2021-03-30 05:29:03 +00:00
|
|
|
import { generateDataTreeWidget } from "entities/DataTree/dataTreeWidget";
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
import type { JSCollectionDataState } from "reducers/entityReducers/jsActionsReducer";
|
|
|
|
|
import type { AppTheme } from "entities/AppTheming";
|
2022-05-18 05:21:53 +00:00
|
|
|
import log from "loglevel";
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
import type { MetaWidgetsReduxState } from "reducers/entityReducers/metaWidgetsReducer";
|
|
|
|
|
import type { WidgetConfigProps } from "reducers/entityReducers/widgetConfigReducer";
|
|
|
|
|
import type {
|
2022-12-02 12:45:11 +00:00
|
|
|
ActionDispatcher,
|
|
|
|
|
ActionEntityConfig,
|
2023-03-20 11:04:02 +00:00
|
|
|
ActionEntity,
|
2022-12-02 12:45:11 +00:00
|
|
|
JSActionEntityConfig,
|
2023-03-20 11:04:02 +00:00
|
|
|
JSActionEntity,
|
2022-12-02 12:45:11 +00:00
|
|
|
WidgetConfig,
|
|
|
|
|
} from "./types";
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
import { ENTITY_TYPE, EvaluationSubstitutionType } from "./types";
|
2022-12-02 12:45:11 +00:00
|
|
|
|
2023-03-20 11:04:02 +00:00
|
|
|
export type UnEvalTreeEntityObject =
|
|
|
|
|
| ActionEntity
|
|
|
|
|
| JSActionEntity
|
|
|
|
|
| WidgetEntity;
|
|
|
|
|
|
|
|
|
|
export type UnEvalTreeEntity = UnEvalTreeEntityObject | AppsmithEntity | Page[];
|
|
|
|
|
|
|
|
|
|
export type UnEvalTree = {
|
|
|
|
|
[entityName: string]: UnEvalTreeEntity;
|
|
|
|
|
};
|
2020-02-18 10:41:52 +00:00
|
|
|
|
2023-03-20 11:04:02 +00:00
|
|
|
export interface WidgetEntity extends WidgetProps {
|
|
|
|
|
meta: Record<string, unknown>;
|
|
|
|
|
ENTITY_TYPE: ENTITY_TYPE.WIDGET;
|
2021-04-26 05:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
2023-03-20 11:04:02 +00:00
|
|
|
export type DataTreeEntityObject =
|
|
|
|
|
| ActionEntity
|
|
|
|
|
| JSActionEntity
|
|
|
|
|
| WidgetEntity
|
|
|
|
|
| AppsmithEntity;
|
|
|
|
|
|
|
|
|
|
export type DataTreeEntity = DataTreeEntityObject | Page[] | ActionDispatcher;
|
|
|
|
|
|
|
|
|
|
export type DataTree = {
|
|
|
|
|
[entityName: string]: DataTreeEntity;
|
|
|
|
|
};
|
2022-01-20 10:59:03 +00:00
|
|
|
|
2022-12-02 12:45:11 +00:00
|
|
|
export interface WidgetEntityConfig
|
|
|
|
|
extends Partial<WidgetProps>,
|
|
|
|
|
Omit<WidgetConfigProps, "widgetName" | "rows" | "columns">,
|
|
|
|
|
WidgetConfig {
|
|
|
|
|
defaultMetaProps: Array<string>;
|
|
|
|
|
type: string;
|
2023-07-08 14:07:26 +00:00
|
|
|
__setters?: Record<string, any>;
|
2020-02-18 10:41:52 +00:00
|
|
|
}
|
|
|
|
|
|
2023-03-20 11:04:02 +00:00
|
|
|
export interface AppsmithEntity extends Omit<AppDataState, "store"> {
|
2020-08-07 14:24:26 +00:00
|
|
|
ENTITY_TYPE: ENTITY_TYPE.APPSMITH;
|
2020-10-12 13:06:05 +00:00
|
|
|
store: Record<string, unknown>;
|
2022-05-04 09:45:57 +00:00
|
|
|
theme: AppTheme["properties"];
|
2020-08-07 14:24:26 +00:00
|
|
|
}
|
2022-12-02 12:45:11 +00:00
|
|
|
|
2020-03-19 03:25:52 +00:00
|
|
|
type DataTreeSeed = {
|
|
|
|
|
actions: ActionDataState;
|
2021-03-30 05:29:03 +00:00
|
|
|
editorConfigs: Record<string, any[]>;
|
2021-04-26 05:41:32 +00:00
|
|
|
pluginDependencyConfig: Record<string, DependencyMap>;
|
2020-03-19 03:25:52 +00:00
|
|
|
widgets: CanvasWidgetsReduxState;
|
|
|
|
|
widgetsMeta: MetaState;
|
2022-06-21 13:57:34 +00:00
|
|
|
pageList: Page[];
|
2020-08-14 07:43:01 +00:00
|
|
|
appData: AppDataState;
|
2021-09-08 17:32:22 +00:00
|
|
|
jsActions: JSCollectionDataState;
|
2022-05-04 09:45:57 +00:00
|
|
|
theme: AppTheme["properties"];
|
2023-02-14 16:07:31 +00:00
|
|
|
metaWidgets: MetaWidgetsReduxState;
|
2020-03-19 03:25:52 +00:00
|
|
|
};
|
|
|
|
|
|
2022-12-02 12:45:11 +00:00
|
|
|
export type DataTreeEntityConfig =
|
|
|
|
|
| WidgetEntityConfig
|
|
|
|
|
| ActionEntityConfig
|
2023-03-20 11:04:02 +00:00
|
|
|
| JSActionEntityConfig;
|
|
|
|
|
|
|
|
|
|
export type ConfigTree = {
|
|
|
|
|
[entityName: string]: DataTreeEntityConfig;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type unEvalAndConfigTree = {
|
|
|
|
|
unEvalTree: UnEvalTree;
|
|
|
|
|
configTree: ConfigTree;
|
|
|
|
|
};
|
2022-12-02 12:45:11 +00:00
|
|
|
|
2020-02-18 10:41:52 +00:00
|
|
|
export class DataTreeFactory {
|
2020-10-21 04:25:32 +00:00
|
|
|
static create({
|
|
|
|
|
actions,
|
|
|
|
|
appData,
|
2021-03-30 05:29:03 +00:00
|
|
|
editorConfigs,
|
2021-09-08 17:32:22 +00:00
|
|
|
jsActions,
|
2023-02-14 16:07:31 +00:00
|
|
|
metaWidgets,
|
2021-05-13 08:35:39 +00:00
|
|
|
pageList,
|
2021-04-26 05:41:32 +00:00
|
|
|
pluginDependencyConfig,
|
2022-05-04 09:45:57 +00:00
|
|
|
theme,
|
2021-05-13 08:35:39 +00:00
|
|
|
widgets,
|
|
|
|
|
widgetsMeta,
|
2023-03-20 11:04:02 +00:00
|
|
|
}: DataTreeSeed): unEvalAndConfigTree {
|
|
|
|
|
const dataTree: any = {};
|
|
|
|
|
const configTree: ConfigTree = {};
|
2022-05-18 05:21:53 +00:00
|
|
|
const start = performance.now();
|
|
|
|
|
const startActions = performance.now();
|
|
|
|
|
|
2020-12-24 04:32:25 +00:00
|
|
|
actions.forEach((action) => {
|
2021-03-30 05:29:03 +00:00
|
|
|
const editorConfig = editorConfigs[action.config.pluginId];
|
2021-04-26 05:41:32 +00:00
|
|
|
const dependencyConfig = pluginDependencyConfig[action.config.pluginId];
|
2023-03-20 11:04:02 +00:00
|
|
|
const { configEntity, unEvalEntity } = generateDataTreeAction(
|
2021-03-30 05:29:03 +00:00
|
|
|
action,
|
|
|
|
|
editorConfig,
|
2021-04-26 05:41:32 +00:00
|
|
|
dependencyConfig,
|
2020-04-17 16:15:09 +00:00
|
|
|
);
|
2023-03-20 11:04:02 +00:00
|
|
|
dataTree[action.config.name] = unEvalEntity;
|
|
|
|
|
configTree[action.config.name] = configEntity;
|
2021-03-30 05:29:03 +00:00
|
|
|
});
|
2022-05-18 05:21:53 +00:00
|
|
|
const endActions = performance.now();
|
|
|
|
|
|
|
|
|
|
const startJsActions = performance.now();
|
|
|
|
|
|
2021-09-08 17:32:22 +00:00
|
|
|
jsActions.forEach((js) => {
|
2023-03-20 11:04:02 +00:00
|
|
|
const { configEntity, unEvalEntity } = generateDataTreeJSAction(js);
|
|
|
|
|
dataTree[js.config.name] = unEvalEntity;
|
|
|
|
|
configTree[js.config.name] = configEntity;
|
2021-09-08 17:32:22 +00:00
|
|
|
});
|
2022-05-18 05:21:53 +00:00
|
|
|
const endJsActions = performance.now();
|
|
|
|
|
|
|
|
|
|
const startWidgets = performance.now();
|
|
|
|
|
|
2021-03-30 05:29:03 +00:00
|
|
|
Object.values(widgets).forEach((widget) => {
|
2023-03-20 11:04:02 +00:00
|
|
|
const { configEntity, unEvalEntity } = generateDataTreeWidget(
|
2021-02-16 10:29:08 +00:00
|
|
|
widget,
|
2023-02-07 12:00:06 +00:00
|
|
|
widgetsMeta[widget.metaWidgetId || widget.widgetId],
|
2021-02-16 10:29:08 +00:00
|
|
|
);
|
2023-03-20 11:04:02 +00:00
|
|
|
|
|
|
|
|
dataTree[widget.widgetName] = unEvalEntity;
|
|
|
|
|
configTree[widget.widgetName] = configEntity;
|
2020-02-18 10:41:52 +00:00
|
|
|
});
|
2022-05-18 05:21:53 +00:00
|
|
|
const endWidgets = performance.now();
|
2020-06-19 13:06:45 +00:00
|
|
|
|
2020-04-20 05:42:46 +00:00
|
|
|
dataTree.pageList = pageList;
|
2022-12-02 12:45:11 +00:00
|
|
|
|
2021-03-24 05:09:47 +00:00
|
|
|
dataTree.appsmith = {
|
|
|
|
|
...appData,
|
|
|
|
|
// combine both persistent and transient state with the transient state
|
|
|
|
|
// taking precedence in case the key is the same
|
2023-01-10 04:53:08 +00:00
|
|
|
store: appData.store,
|
2022-05-04 09:45:57 +00:00
|
|
|
theme,
|
2023-03-20 11:04:02 +00:00
|
|
|
} as AppsmithEntity;
|
|
|
|
|
(dataTree.appsmith as AppsmithEntity).ENTITY_TYPE = ENTITY_TYPE.APPSMITH;
|
2023-02-14 16:07:31 +00:00
|
|
|
|
|
|
|
|
const startMetaWidgets = performance.now();
|
|
|
|
|
|
|
|
|
|
Object.values(metaWidgets).forEach((widget) => {
|
2023-03-20 11:04:02 +00:00
|
|
|
const { configEntity, unEvalEntity } = generateDataTreeWidget(
|
2023-02-14 16:07:31 +00:00
|
|
|
widget,
|
|
|
|
|
widgetsMeta[widget.metaWidgetId || widget.widgetId],
|
|
|
|
|
);
|
2023-03-20 11:04:02 +00:00
|
|
|
dataTree[widget.widgetName] = unEvalEntity;
|
|
|
|
|
configTree[widget.widgetName] = configEntity;
|
2023-02-14 16:07:31 +00:00
|
|
|
});
|
|
|
|
|
const endMetaWidgets = performance.now();
|
|
|
|
|
|
2022-05-18 05:21:53 +00:00
|
|
|
const end = performance.now();
|
|
|
|
|
|
|
|
|
|
const out = {
|
|
|
|
|
total: end - start,
|
|
|
|
|
widgets: endWidgets - startWidgets,
|
|
|
|
|
actions: endActions - startActions,
|
|
|
|
|
jsActions: endJsActions - startJsActions,
|
2023-02-14 16:07:31 +00:00
|
|
|
metaWidgets: endMetaWidgets - startMetaWidgets,
|
2022-05-18 05:21:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
log.debug("### Create unevalTree timing", out);
|
2023-03-20 11:04:02 +00:00
|
|
|
return { unEvalTree: dataTree, configTree };
|
2020-02-18 10:41:52 +00:00
|
|
|
}
|
|
|
|
|
}
|
2022-12-02 12:45:11 +00:00
|
|
|
|
|
|
|
|
export { ENTITY_TYPE, EvaluationSubstitutionType };
|