chore: Moved tern server to worker (#18464)
* Fixes autocomplete on first page load.
This commit is contained in:
parent
49a98b5048
commit
abf54ec84f
|
|
@ -4,7 +4,7 @@ import {
|
||||||
FieldWrapper,
|
FieldWrapper,
|
||||||
} from "components/propertyControls/StyledControls";
|
} from "components/propertyControls/StyledControls";
|
||||||
import { InputText } from "components/propertyControls/InputTextControl";
|
import { InputText } from "components/propertyControls/InputTextControl";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export function TextView(props: TextViewProps) {
|
export function TextView(props: TextViewProps) {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import CodeMirror from "codemirror";
|
import CodeMirror from "codemirror";
|
||||||
import { DataTree, ENTITY_TYPE } from "entities/DataTree/dataTreeFactory";
|
import { DataTree, ENTITY_TYPE } from "entities/DataTree/dataTreeFactory";
|
||||||
import { AdditionalDynamicDataTree } from "utils/autocomplete/customTreeTypeDefCreator";
|
import { AdditionalDynamicDataTree } from "utils/autocomplete/customTreeTypeDefCreator";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
|
|
||||||
export enum EditorModes {
|
export enum EditorModes {
|
||||||
TEXT = "text/plain",
|
TEXT = "text/plain",
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import { HintHelper } from "components/editorComponents/CodeEditor/EditorConfig"
|
||||||
import {
|
import {
|
||||||
AutocompleteDataType,
|
AutocompleteDataType,
|
||||||
CommandsCompletion,
|
CommandsCompletion,
|
||||||
} from "utils/autocomplete/TernServer";
|
} from "utils/autocomplete/CodemirrorTernService";
|
||||||
import { generateQuickCommands } from "./generateQuickCommands";
|
import { generateQuickCommands } from "./generateQuickCommands";
|
||||||
import { Datasource } from "entities/Datasource";
|
import { Datasource } from "entities/Datasource";
|
||||||
import AnalyticsUtil from "utils/AnalyticsUtil";
|
import AnalyticsUtil from "utils/AnalyticsUtil";
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import React from "react";
|
||||||
import {
|
import {
|
||||||
AutocompleteDataType,
|
AutocompleteDataType,
|
||||||
CommandsCompletion,
|
CommandsCompletion,
|
||||||
} from "utils/autocomplete/TernServer";
|
} from "utils/autocomplete/CodemirrorTernService";
|
||||||
import ReactDOM from "react-dom";
|
import ReactDOM from "react-dom";
|
||||||
import sortBy from "lodash/sortBy";
|
import sortBy from "lodash/sortBy";
|
||||||
import { PluginType, SlashCommand, SlashCommandPayload } from "entities/Action";
|
import { PluginType, SlashCommand, SlashCommandPayload } from "entities/Action";
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import CodeMirror from "codemirror";
|
import CodeMirror from "codemirror";
|
||||||
import TernServer from "utils/autocomplete/TernServer";
|
import CodemirrorTernService from "utils/autocomplete/CodemirrorTernService";
|
||||||
import KeyboardShortcuts from "constants/KeyboardShortcuts";
|
import KeyboardShortcuts from "constants/KeyboardShortcuts";
|
||||||
import { HintHelper } from "components/editorComponents/CodeEditor/EditorConfig";
|
import { HintHelper } from "components/editorComponents/CodeEditor/EditorConfig";
|
||||||
import AnalyticsUtil from "utils/AnalyticsUtil";
|
import AnalyticsUtil from "utils/AnalyticsUtil";
|
||||||
|
|
@ -11,12 +11,12 @@ export const bindingHint: HintHelper = (editor) => {
|
||||||
// @ts-expect-error: Types are not available
|
// @ts-expect-error: Types are not available
|
||||||
...editor.options.extraKeys,
|
...editor.options.extraKeys,
|
||||||
[KeyboardShortcuts.CodeEditor.OpenAutocomplete]: (cm: CodeMirror.Editor) =>
|
[KeyboardShortcuts.CodeEditor.OpenAutocomplete]: (cm: CodeMirror.Editor) =>
|
||||||
checkIfCursorInsideBinding(cm) && TernServer.complete(cm),
|
checkIfCursorInsideBinding(cm) && CodemirrorTernService.complete(cm),
|
||||||
[KeyboardShortcuts.CodeEditor.ShowTypeAndInfo]: (cm: CodeMirror.Editor) => {
|
[KeyboardShortcuts.CodeEditor.ShowTypeAndInfo]: (cm: CodeMirror.Editor) => {
|
||||||
TernServer.showType(cm);
|
CodemirrorTernService.showType(cm);
|
||||||
},
|
},
|
||||||
[KeyboardShortcuts.CodeEditor.OpenDocsLink]: (cm: CodeMirror.Editor) => {
|
[KeyboardShortcuts.CodeEditor.OpenDocsLink]: (cm: CodeMirror.Editor) => {
|
||||||
TernServer.showDocs(cm);
|
CodemirrorTernService.showDocs(cm);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
|
|
@ -26,12 +26,12 @@ export const bindingHint: HintHelper = (editor) => {
|
||||||
additionalData,
|
additionalData,
|
||||||
): boolean => {
|
): boolean => {
|
||||||
if (additionalData && additionalData.blockCompletions) {
|
if (additionalData && additionalData.blockCompletions) {
|
||||||
TernServer.setEntityInformation({
|
CodemirrorTernService.setEntityInformation({
|
||||||
...entityInformation,
|
...entityInformation,
|
||||||
blockCompletions: additionalData.blockCompletions,
|
blockCompletions: additionalData.blockCompletions,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
TernServer.setEntityInformation(entityInformation);
|
CodemirrorTernService.setEntityInformation(entityInformation);
|
||||||
}
|
}
|
||||||
|
|
||||||
const entityType = entityInformation?.entityType;
|
const entityType = entityInformation?.entityType;
|
||||||
|
|
@ -43,7 +43,7 @@ export const bindingHint: HintHelper = (editor) => {
|
||||||
}
|
}
|
||||||
if (shouldShow) {
|
if (shouldShow) {
|
||||||
AnalyticsUtil.logEvent("AUTO_COMPLETE_SHOW", {});
|
AnalyticsUtil.logEvent("AUTO_COMPLETE_SHOW", {});
|
||||||
TernServer.complete(editor);
|
CodemirrorTernService.complete(editor);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// @ts-expect-error: Types are not available
|
// @ts-expect-error: Types are not available
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ import { Button } from "design-system";
|
||||||
import { getPluginIdToImageLocation } from "sagas/selectors";
|
import { getPluginIdToImageLocation } from "sagas/selectors";
|
||||||
import { ExpectedValueExample } from "utils/validation/common";
|
import { ExpectedValueExample } from "utils/validation/common";
|
||||||
import { getRecentEntityIds } from "selectors/globalSearchSelectors";
|
import { getRecentEntityIds } from "selectors/globalSearchSelectors";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import { Placement } from "@blueprintjs/popover2";
|
import { Placement } from "@blueprintjs/popover2";
|
||||||
import { getLintAnnotations, getLintTooltipDirection } from "./lintHelpers";
|
import { getLintAnnotations, getLintTooltipDirection } from "./lintHelpers";
|
||||||
import { executeCommandAction } from "actions/apiPaneActions";
|
import { executeCommandAction } from "actions/apiPaneActions";
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import {
|
||||||
EditorTheme,
|
EditorTheme,
|
||||||
} from "components/editorComponents/CodeEditor/EditorConfig";
|
} from "components/editorComponents/CodeEditor/EditorConfig";
|
||||||
import { Case, Classes, Icon, IconSize, Text, TextType } from "design-system";
|
import { Case, Classes, Icon, IconSize, Text, TextType } from "design-system";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import DynamicDropdownField from "./DynamicDropdownField";
|
import DynamicDropdownField from "./DynamicDropdownField";
|
||||||
import {
|
import {
|
||||||
DEFAULT_MULTI_PART_DROPDOWN_PLACEHOLDER,
|
DEFAULT_MULTI_PART_DROPDOWN_PLACEHOLDER,
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import {
|
||||||
import { Size, Category } from "design-system";
|
import { Size, Category } from "design-system";
|
||||||
import { AllChartData, ChartData } from "widgets/ChartWidget/constants";
|
import { AllChartData, ChartData } from "widgets/ChartWidget/constants";
|
||||||
import { generateReactKey } from "utils/generators";
|
import { generateReactKey } from "utils/generators";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import CodeEditor from "components/editorComponents/LazyCodeEditorWrapper";
|
import CodeEditor from "components/editorComponents/LazyCodeEditorWrapper";
|
||||||
|
|
||||||
const Wrapper = styled.div`
|
const Wrapper = styled.div`
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import styled from "styled-components";
|
||||||
import { Colors } from "constants/Colors";
|
import { Colors } from "constants/Colors";
|
||||||
import { Text, TextType } from "design-system";
|
import { Text, TextType } from "design-system";
|
||||||
import DynamicTextField from "components/editorComponents/form/fields/DynamicTextField";
|
import DynamicTextField from "components/editorComponents/form/fields/DynamicTextField";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
|
|
||||||
const VariableWrapper = styled.div`
|
const VariableWrapper = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import {
|
||||||
import { Classes, MultiSwitch } from "design-system";
|
import { Classes, MultiSwitch } from "design-system";
|
||||||
import { updateBodyContentType } from "actions/apiPaneActions";
|
import { updateBodyContentType } from "actions/apiPaneActions";
|
||||||
import { CodeEditorExpected } from "components/editorComponents/CodeEditor";
|
import { CodeEditorExpected } from "components/editorComponents/CodeEditor";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import { createMessage, API_PANE_NO_BODY } from "@appsmith/constants/messages";
|
import { createMessage, API_PANE_NO_BODY } from "@appsmith/constants/messages";
|
||||||
|
|
||||||
const PostBodyContainer = styled.div`
|
const PostBodyContainer = styled.div`
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ import { ENTITY_TYPE } from "entities/AppsmithConsole";
|
||||||
import LOG_TYPE from "entities/AppsmithConsole/logtype";
|
import LOG_TYPE from "entities/AppsmithConsole/logtype";
|
||||||
import { getExpectedValue } from "utils/validation/common";
|
import { getExpectedValue } from "utils/validation/common";
|
||||||
import { ControlData } from "components/propertyControls/BaseControl";
|
import { ControlData } from "components/propertyControls/BaseControl";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import { getSelectedAppTheme } from "selectors/appThemingSelectors";
|
import { getSelectedAppTheme } from "selectors/appThemingSelectors";
|
||||||
import { TooltipComponent } from "design-system";
|
import { TooltipComponent } from "design-system";
|
||||||
import { ReactComponent as ResetIcon } from "assets/icons/control/undo_2.svg";
|
import { ReactComponent as ResetIcon } from "assets/icons/control/undo_2.svg";
|
||||||
|
|
|
||||||
|
|
@ -216,7 +216,12 @@ function* evaluateTreeSaga(
|
||||||
isCreateFirstTree,
|
isCreateFirstTree,
|
||||||
);
|
);
|
||||||
|
|
||||||
yield fork(updateTernDefinitions, updatedDataTree, unEvalUpdates);
|
yield fork(
|
||||||
|
updateTernDefinitions,
|
||||||
|
updatedDataTree,
|
||||||
|
unEvalUpdates,
|
||||||
|
isCreateFirstTree,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
yield put(setDependencyMap(dependencies));
|
yield put(setDependencyMap(dependencies));
|
||||||
if (postEvalActions && postEvalActions.length) {
|
if (postEvalActions && postEvalActions.length) {
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ import { AppState } from "@appsmith/reducers";
|
||||||
import { getAppMode } from "selectors/applicationSelectors";
|
import { getAppMode } from "selectors/applicationSelectors";
|
||||||
import { APP_MODE } from "entities/App";
|
import { APP_MODE } from "entities/App";
|
||||||
import { dataTreeTypeDefCreator } from "utils/autocomplete/dataTreeTypeDefCreator";
|
import { dataTreeTypeDefCreator } from "utils/autocomplete/dataTreeTypeDefCreator";
|
||||||
import TernServer from "utils/autocomplete/TernServer";
|
import CodemirrorTernService from "utils/autocomplete/CodemirrorTernService";
|
||||||
import { selectFeatureFlags } from "selectors/usersSelectors";
|
import { selectFeatureFlags } from "selectors/usersSelectors";
|
||||||
import FeatureFlags from "entities/FeatureFlags";
|
import FeatureFlags from "entities/FeatureFlags";
|
||||||
import { JSAction } from "entities/JSCollection";
|
import { JSAction } from "entities/JSCollection";
|
||||||
|
|
@ -337,55 +337,36 @@ export function* postEvalActionDispatcher(actions: Array<AnyReduxAction>) {
|
||||||
// is accurate
|
// is accurate
|
||||||
export function* updateTernDefinitions(
|
export function* updateTernDefinitions(
|
||||||
dataTree: DataTree,
|
dataTree: DataTree,
|
||||||
updates?: DataTreeDiff[],
|
updates: DataTreeDiff[],
|
||||||
|
isCreateFirstTree: boolean,
|
||||||
) {
|
) {
|
||||||
let shouldUpdate: boolean;
|
const shouldUpdate: boolean =
|
||||||
// No updates, means it was a first Eval
|
isCreateFirstTree ||
|
||||||
if (!updates) {
|
some(updates, (update) => {
|
||||||
shouldUpdate = true;
|
if (update.event === DataTreeDiffEvent.NEW) return true;
|
||||||
} else if (updates.length === 0) {
|
if (update.event === DataTreeDiffEvent.DELETE) return true;
|
||||||
// update length is 0 means no significant updates
|
if (update.event === DataTreeDiffEvent.EDIT) return false;
|
||||||
shouldUpdate = false;
|
const { entityName } = getEntityNameAndPropertyPath(
|
||||||
} else {
|
update.payload.propertyPath,
|
||||||
// Only when new field is added or deleted, we want to re-create the def
|
);
|
||||||
shouldUpdate = some(updates, (update) => {
|
const entity = dataTree[entityName];
|
||||||
if (
|
if (!entity || !isWidget(entity)) return false;
|
||||||
update.event === DataTreeDiffEvent.NEW ||
|
return isWidgetPropertyNamePath(entity, update.payload.propertyPath);
|
||||||
update.event === DataTreeDiffEvent.DELETE
|
|
||||||
) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (update.event === DataTreeDiffEvent.NOOP) {
|
|
||||||
const { entityName } = getEntityNameAndPropertyPath(
|
|
||||||
update.payload.propertyPath,
|
|
||||||
);
|
|
||||||
const entity = dataTree[entityName];
|
|
||||||
if (entity && isWidget(entity)) {
|
|
||||||
// if widget property name is modified then update tern def
|
|
||||||
return isWidgetPropertyNamePath(entity, update.payload.propertyPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
if (shouldUpdate) {
|
if (!shouldUpdate) return;
|
||||||
const start = performance.now();
|
const start = performance.now();
|
||||||
// remove private widgets from dataTree used for autocompletion
|
// remove private widgets from dataTree used for autocompletion
|
||||||
const treeWithoutPrivateWidgets = getDataTreeWithoutPrivateWidgets(
|
const treeWithoutPrivateWidgets = getDataTreeWithoutPrivateWidgets(dataTree);
|
||||||
dataTree,
|
const featureFlags: FeatureFlags = yield select(selectFeatureFlags);
|
||||||
);
|
const { def, entityInfo } = dataTreeTypeDefCreator(
|
||||||
const featureFlags: FeatureFlags = yield select(selectFeatureFlags);
|
treeWithoutPrivateWidgets,
|
||||||
const { def, entityInfo } = dataTreeTypeDefCreator(
|
!!featureFlags.JS_EDITOR,
|
||||||
treeWithoutPrivateWidgets,
|
);
|
||||||
!!featureFlags.JS_EDITOR,
|
CodemirrorTernService.updateDef("DATA_TREE", def, entityInfo);
|
||||||
);
|
const end = performance.now();
|
||||||
TernServer.updateDef("DATA_TREE", def, entityInfo);
|
log.debug("Tern", { updates });
|
||||||
const end = performance.now();
|
log.debug("Tern definitions updated took ", (end - start).toFixed(2));
|
||||||
log.debug("Tern", { updates });
|
|
||||||
log.debug("Tern definitions updated took ", (end - start).toFixed(2));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function* handleJSFunctionExecutionErrorLog(
|
export function* handleJSFunctionExecutionErrorLog(
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import {
|
||||||
Completion,
|
Completion,
|
||||||
createCompletionHeader,
|
createCompletionHeader,
|
||||||
DataTreeDefEntityInformation,
|
DataTreeDefEntityInformation,
|
||||||
} from "./TernServer";
|
} from "./CodemirrorTernService";
|
||||||
|
|
||||||
interface AutocompleteRule {
|
interface AutocompleteRule {
|
||||||
computeScore(completion: Completion): number;
|
computeScore(completion: Completion): number;
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import { FieldEntityInformation } from "components/editorComponents/CodeEditor/E
|
||||||
import { ENTITY_TYPE } from "entities/DataTree/dataTreeFactory";
|
import { ENTITY_TYPE } from "entities/DataTree/dataTreeFactory";
|
||||||
import { AutocompleteSorter } from "./AutocompleteSortRules";
|
import { AutocompleteSorter } from "./AutocompleteSortRules";
|
||||||
import { getCompletionsForKeyword } from "./keywordCompletion";
|
import { getCompletionsForKeyword } from "./keywordCompletion";
|
||||||
|
import TernWorkerServer from "./TernWorkerService";
|
||||||
|
|
||||||
const DEFS: Def[] = [
|
const DEFS: Def[] = [
|
||||||
// @ts-expect-error: Types are not available
|
// @ts-expect-error: Types are not available
|
||||||
|
|
@ -129,7 +130,7 @@ export function typeToIcon(type: string, isKeyword: boolean) {
|
||||||
return cls + "completion " + cls + "completion-" + suffix;
|
return cls + "completion " + cls + "completion-" + suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
class TernServer {
|
class CodeMirrorTernService {
|
||||||
server: Server;
|
server: Server;
|
||||||
docs: TernDocs = Object.create(null);
|
docs: TernDocs = Object.create(null);
|
||||||
cachedArgHints: ArgHints | null = null;
|
cachedArgHints: ArgHints | null = null;
|
||||||
|
|
@ -139,12 +140,11 @@ class TernServer {
|
||||||
string,
|
string,
|
||||||
DataTreeDefEntityInformation
|
DataTreeDefEntityInformation
|
||||||
>();
|
>();
|
||||||
|
options: { async: boolean; defs: Def[] };
|
||||||
|
|
||||||
constructor() {
|
constructor(options: { async: boolean; defs: Def[] }) {
|
||||||
this.server = new tern.Server({
|
this.options = options;
|
||||||
async: true,
|
this.server = new TernWorkerServer(this);
|
||||||
defs: DEFS,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resetServer() {
|
resetServer() {
|
||||||
|
|
@ -846,4 +846,7 @@ export const createCompletionHeader = (name: string): Completion => ({
|
||||||
isHeader: true,
|
isHeader: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default new TernServer();
|
export default new CodeMirrorTernService({
|
||||||
|
async: true,
|
||||||
|
defs: DEFS,
|
||||||
|
});
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import TernServer, {
|
import CodemirrorTernService, {
|
||||||
AutocompleteDataType,
|
AutocompleteDataType,
|
||||||
Completion,
|
Completion,
|
||||||
createCompletionHeader,
|
createCompletionHeader,
|
||||||
DataTreeDefEntityInformation,
|
DataTreeDefEntityInformation,
|
||||||
} from "./TernServer";
|
} from "./CodemirrorTernService";
|
||||||
import { MockCodemirrorEditor } from "../../../test/__mocks__/CodeMirrorEditorMock";
|
import { MockCodemirrorEditor } from "../../../test/__mocks__/CodeMirrorEditorMock";
|
||||||
import { ENTITY_TYPE } from "entities/DataTree/dataTreeFactory";
|
import { ENTITY_TYPE } from "entities/DataTree/dataTreeFactory";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
|
|
@ -63,7 +63,9 @@ describe("Tern server", () => {
|
||||||
];
|
];
|
||||||
|
|
||||||
testCases.forEach((testCase) => {
|
testCases.forEach((testCase) => {
|
||||||
const { value } = TernServer.getFocusedDocValueAndPos(testCase.input);
|
const { value } = CodemirrorTernService.getFocusedDocValueAndPos(
|
||||||
|
testCase.input,
|
||||||
|
);
|
||||||
expect(value).toBe(testCase.expectedOutput);
|
expect(value).toBe(testCase.expectedOutput);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -125,13 +127,12 @@ describe("Tern server", () => {
|
||||||
];
|
];
|
||||||
|
|
||||||
testCases.forEach((testCase) => {
|
testCases.forEach((testCase) => {
|
||||||
const request = TernServer.buildRequest(testCase.input, {});
|
const request = CodemirrorTernService.buildRequest(testCase.input, {});
|
||||||
expect(request.query.end).toEqual(testCase.expectedOutput);
|
expect(request.query.end).toEqual(testCase.expectedOutput);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`Check whether the position is evaluated correctly for placing the selected
|
it(`Check whether the position is evaluated correctly for placing the selected autocomplete value`, () => {
|
||||||
autocomplete value`, () => {
|
|
||||||
const testCases = [
|
const testCases = [
|
||||||
{
|
{
|
||||||
input: {
|
input: {
|
||||||
|
|
@ -186,13 +187,18 @@ describe("Tern server", () => {
|
||||||
testCase.input.codeEditor.doc,
|
testCase.input.codeEditor.doc,
|
||||||
);
|
);
|
||||||
|
|
||||||
const value: any = TernServer.requestCallback(
|
const mockAddFile = jest.fn();
|
||||||
|
CodemirrorTernService.server.addFile = mockAddFile;
|
||||||
|
|
||||||
|
const value: any = CodemirrorTernService.requestCallback(
|
||||||
null,
|
null,
|
||||||
testCase.input.requestCallbackData,
|
testCase.input.requestCallbackData,
|
||||||
(MockCodemirrorEditor as unknown) as CodeMirror.Editor,
|
(MockCodemirrorEditor as unknown) as CodeMirror.Editor,
|
||||||
() => null,
|
() => null,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
expect(mockAddFile).toBeCalled();
|
||||||
|
|
||||||
expect(value.from).toEqual(testCase.expectedOutput);
|
expect(value.from).toEqual(testCase.expectedOutput);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -342,12 +348,12 @@ describe("Tern server sorting", () => {
|
||||||
];
|
];
|
||||||
|
|
||||||
it("shows best match results", () => {
|
it("shows best match results", () => {
|
||||||
TernServer.setEntityInformation({
|
CodemirrorTernService.setEntityInformation({
|
||||||
entityName: "sameEntity",
|
entityName: "sameEntity",
|
||||||
entityType: ENTITY_TYPE.WIDGET,
|
entityType: ENTITY_TYPE.WIDGET,
|
||||||
expectedType: AutocompleteDataType.OBJECT,
|
expectedType: AutocompleteDataType.OBJECT,
|
||||||
});
|
});
|
||||||
TernServer.defEntityInformation = defEntityInformation;
|
CodemirrorTernService.defEntityInformation = defEntityInformation;
|
||||||
const sortedCompletions = AutocompleteSorter.sort(
|
const sortedCompletions = AutocompleteSorter.sort(
|
||||||
_.shuffle(completions),
|
_.shuffle(completions),
|
||||||
{
|
{
|
||||||
|
|
|
||||||
82
app/client/src/utils/autocomplete/TernWorkerService.ts
Normal file
82
app/client/src/utils/autocomplete/TernWorkerService.ts
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
import { Def, Server } from "tern";
|
||||||
|
import { CallbackFn, TernWorkerAction } from "./types";
|
||||||
|
|
||||||
|
const ternWorker = new Worker(
|
||||||
|
new URL("../../workers/Tern/tern.worker.ts", import.meta.url),
|
||||||
|
{
|
||||||
|
name: "TernWorker",
|
||||||
|
type: "module",
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
function getFile(ts: any, name: string, c: CallbackFn) {
|
||||||
|
const buf = ts.docs[name];
|
||||||
|
if (buf) c(ts.docValue(ts, buf));
|
||||||
|
else if (ts.options.getFile) ts.options.getFile(name, c);
|
||||||
|
else c(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
type TernWorkerServerConstructor = {
|
||||||
|
(ts: any): void;
|
||||||
|
new (ts: any): Server;
|
||||||
|
};
|
||||||
|
|
||||||
|
function TernWorkerServer(this: any, ts: any) {
|
||||||
|
const worker = (ts.worker = ternWorker);
|
||||||
|
worker.postMessage({
|
||||||
|
type: TernWorkerAction.INIT,
|
||||||
|
defs: ts.options.defs,
|
||||||
|
plugins: ts.options.plugins,
|
||||||
|
scripts: ts.options.workerDeps,
|
||||||
|
});
|
||||||
|
let msgId = 0;
|
||||||
|
let pending: { [x: number]: CallbackFn } = {};
|
||||||
|
|
||||||
|
function send(data: any, c?: CallbackFn) {
|
||||||
|
if (c) {
|
||||||
|
data.id = ++msgId;
|
||||||
|
pending[msgId] = c;
|
||||||
|
}
|
||||||
|
worker.postMessage(data);
|
||||||
|
}
|
||||||
|
worker.onmessage = function(e) {
|
||||||
|
const data = e.data;
|
||||||
|
if (data.type == TernWorkerAction.GET_FILE) {
|
||||||
|
getFile(ts, data.name, function(err, text) {
|
||||||
|
send({
|
||||||
|
type: TernWorkerAction.GET_FILE,
|
||||||
|
err: String(err),
|
||||||
|
text: text,
|
||||||
|
id: data.id,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else if (data.type == TernWorkerAction.DEBUG) {
|
||||||
|
window.console.log(data.message);
|
||||||
|
} else if (data.id && pending[data.id]) {
|
||||||
|
pending[data.id](data.err, data.body);
|
||||||
|
delete pending[data.id];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
worker.onerror = function(e) {
|
||||||
|
for (const id in pending) pending[id](e);
|
||||||
|
pending = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
this.addFile = function(name: string, text: string) {
|
||||||
|
send({ type: TernWorkerAction.ADD_FILE, name: name, text: text });
|
||||||
|
};
|
||||||
|
this.delFile = function(name: string) {
|
||||||
|
send({ type: TernWorkerAction.DELETE_FILE, name: name });
|
||||||
|
};
|
||||||
|
this.request = function(body: any, c: CallbackFn) {
|
||||||
|
send({ type: TernWorkerAction.REQUEST, body: body }, c);
|
||||||
|
};
|
||||||
|
this.addDefs = function(defs: Def) {
|
||||||
|
send({ type: TernWorkerAction.ADD_DEF, defs });
|
||||||
|
};
|
||||||
|
this.deleteDefs = function(name: string) {
|
||||||
|
send({ type: TernWorkerAction.DELETE_DEF, name });
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TernWorkerServer as TernWorkerServerConstructor;
|
||||||
|
|
@ -5,7 +5,7 @@ import {
|
||||||
AdditionalDynamicDataTree,
|
AdditionalDynamicDataTree,
|
||||||
customTreeTypeDefCreator,
|
customTreeTypeDefCreator,
|
||||||
} from "./customTreeTypeDefCreator";
|
} from "./customTreeTypeDefCreator";
|
||||||
import TernServer from "./TernServer";
|
import CodemirrorTernService from "./CodemirrorTernService";
|
||||||
|
|
||||||
class CustomDef {
|
class CustomDef {
|
||||||
private static lastCustomDataDef: AdditionalDynamicDataTree | undefined;
|
private static lastCustomDataDef: AdditionalDynamicDataTree | undefined;
|
||||||
|
|
@ -16,7 +16,7 @@ class CustomDef {
|
||||||
if (!equal(CustomDef.lastCustomDataDef, customDataDef)) {
|
if (!equal(CustomDef.lastCustomDataDef, customDataDef)) {
|
||||||
const start = performance.now();
|
const start = performance.now();
|
||||||
|
|
||||||
TernServer.updateDef("customDataTree", customDataDef);
|
CodemirrorTernService.updateDef("customDataTree", customDataDef);
|
||||||
|
|
||||||
debug(
|
debug(
|
||||||
"Tern: updateDef for customDataTree took",
|
"Tern: updateDef for customDataTree took",
|
||||||
|
|
@ -28,7 +28,7 @@ class CustomDef {
|
||||||
}
|
}
|
||||||
} else if (CustomDef.lastCustomDataDef) {
|
} else if (CustomDef.lastCustomDataDef) {
|
||||||
const start = performance.now();
|
const start = performance.now();
|
||||||
TernServer.removeDef("customDataTree");
|
CodemirrorTernService.removeDef("customDataTree");
|
||||||
debug(
|
debug(
|
||||||
"Tern: removeDef for customDataTree took",
|
"Tern: removeDef for customDataTree took",
|
||||||
(performance.now() - start).toFixed(),
|
(performance.now() - start).toFixed(),
|
||||||
|
|
@ -40,7 +40,7 @@ class CustomDef {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is responsible for both add and remove def in TernServer for customDataTree.
|
* This method is responsible for both add and remove def in CodemirrorTernService for customDataTree.
|
||||||
*
|
*
|
||||||
* if customData is not defined then check if lastCustomDataDef was present and remove it.
|
* if customData is not defined then check if lastCustomDataDef was present and remove it.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import {
|
||||||
isTrueObject,
|
isTrueObject,
|
||||||
isWidget,
|
isWidget,
|
||||||
} from "workers/Evaluation/evaluationUtils";
|
} from "workers/Evaluation/evaluationUtils";
|
||||||
import { DataTreeDefEntityInformation } from "utils/autocomplete/TernServer";
|
import { DataTreeDefEntityInformation } from "utils/autocomplete/CodemirrorTernService";
|
||||||
|
|
||||||
export type ExtraDef = Record<string, Def | string>;
|
export type ExtraDef = Record<string, Def | string>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
|
|
||||||
export const PriorityOrder: Record<AutocompleteDataType, string[]> = {
|
export const PriorityOrder: Record<AutocompleteDataType, string[]> = {
|
||||||
STRING: ["selectedRow", "data", "text"],
|
STRING: ["selectedRow", "data", "text"],
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Completion } from "./TernServer";
|
import { Completion } from "./CodemirrorTernService";
|
||||||
|
|
||||||
export const getCompletionsForKeyword = (
|
export const getCompletionsForKeyword = (
|
||||||
completion: Completion,
|
completion: Completion,
|
||||||
|
|
|
||||||
12
app/client/src/utils/autocomplete/types.ts
Normal file
12
app/client/src/utils/autocomplete/types.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
export enum TernWorkerAction {
|
||||||
|
INIT = "INIT",
|
||||||
|
ADD_FILE = "ADD_FILE",
|
||||||
|
DELETE_FILE = "DELETE_FILE",
|
||||||
|
REQUEST = "REQUEST",
|
||||||
|
GET_FILE = "GET_FILE",
|
||||||
|
DELETE_DEF = "DELETE_DEF",
|
||||||
|
ADD_DEF = "ADD_DEF",
|
||||||
|
DEBUG = "DEBUG",
|
||||||
|
}
|
||||||
|
|
||||||
|
export type CallbackFn = (...args: any) => any;
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { RenderModes } from "constants/WidgetConstants";
|
import { RenderModes } from "constants/WidgetConstants";
|
||||||
import { ValidationTypes } from "constants/WidgetValidation";
|
import { ValidationTypes } from "constants/WidgetValidation";
|
||||||
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
||||||
import { AutocompleteDataType } from "./autocomplete/TernServer";
|
import { AutocompleteDataType } from "./autocomplete/CodemirrorTernService";
|
||||||
import {
|
import {
|
||||||
flattenObject,
|
flattenObject,
|
||||||
getLocale,
|
getLocale,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import { ValidationTypes } from "constants/WidgetValidation";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { sample } from "lodash";
|
import { sample } from "lodash";
|
||||||
import { CodeEditorExpected } from "components/editorComponents/CodeEditor";
|
import { CodeEditorExpected } from "components/editorComponents/CodeEditor";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
|
|
||||||
export const required = (value: any) => {
|
export const required = (value: any) => {
|
||||||
if (value === undefined || value === null || value === "") {
|
if (value === undefined || value === null || value === "") {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import { ValidationTypes } from "constants/WidgetValidation";
|
||||||
import Skeleton from "components/utils/Skeleton";
|
import Skeleton from "components/utils/Skeleton";
|
||||||
import { retryPromise } from "utils/AppsmithUtils";
|
import { retryPromise } from "utils/AppsmithUtils";
|
||||||
import ReactPlayer from "react-player";
|
import ReactPlayer from "react-player";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
|
|
||||||
const AudioComponent = lazy(() => retryPromise(() => import("../component")));
|
const AudioComponent = lazy(() => retryPromise(() => import("../component")));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { LabelPosition } from "components/constants";
|
import { LabelPosition } from "components/constants";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
||||||
import { Alignment } from "@blueprintjs/core";
|
import { Alignment } from "@blueprintjs/core";
|
||||||
import { ValidationTypes } from "constants/WidgetValidation";
|
import { ValidationTypes } from "constants/WidgetValidation";
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { TextSize, WidgetType } from "constants/WidgetConstants";
|
||||||
import { DerivedPropertiesMap } from "utils/WidgetFactory";
|
import { DerivedPropertiesMap } from "utils/WidgetFactory";
|
||||||
import BaseWidget, { WidgetProps, WidgetState } from "widgets/BaseWidget";
|
import BaseWidget, { WidgetProps, WidgetState } from "widgets/BaseWidget";
|
||||||
import { EventType } from "constants/AppsmithActionConstants/ActionConstants";
|
import { EventType } from "constants/AppsmithActionConstants/ActionConstants";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
||||||
import { Alignment } from "@blueprintjs/core";
|
import { Alignment } from "@blueprintjs/core";
|
||||||
import { GRID_DENSITY_MIGRATION_V1 } from "widgets/constants";
|
import { GRID_DENSITY_MIGRATION_V1 } from "widgets/constants";
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import * as React from "react";
|
||||||
|
|
||||||
import { ValidationTypes } from "constants/WidgetValidation";
|
import { ValidationTypes } from "constants/WidgetValidation";
|
||||||
import BaseWidget, { WidgetProps, WidgetState } from "widgets/BaseWidget";
|
import BaseWidget, { WidgetProps, WidgetState } from "widgets/BaseWidget";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import CircularProgressComponent, {
|
import CircularProgressComponent, {
|
||||||
CircularProgressComponentProps,
|
CircularProgressComponentProps,
|
||||||
} from "../component";
|
} from "../component";
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import {
|
||||||
CurrencyDropdownOptions,
|
CurrencyDropdownOptions,
|
||||||
getCountryCodeFromCurrencyCode,
|
getCountryCodeFromCurrencyCode,
|
||||||
} from "../component/CurrencyCodeDropdown";
|
} from "../component/CurrencyCodeDropdown";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import derivedProperties from "./parsedDerivedProperties";
|
import derivedProperties from "./parsedDerivedProperties";
|
||||||
import BaseInputWidget from "widgets/BaseInputWidget";
|
import BaseInputWidget from "widgets/BaseInputWidget";
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import {
|
||||||
import { DerivedPropertiesMap } from "utils/WidgetFactory";
|
import { DerivedPropertiesMap } from "utils/WidgetFactory";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { DatePickerType } from "../constants";
|
import { DatePickerType } from "../constants";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
|
|
||||||
function defaultDateValidation(
|
function defaultDateValidation(
|
||||||
value: unknown,
|
value: unknown,
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import DatePickerComponent from "../component";
|
||||||
|
|
||||||
import { ValidationTypes } from "constants/WidgetValidation";
|
import { ValidationTypes } from "constants/WidgetValidation";
|
||||||
import { DerivedPropertiesMap } from "utils/WidgetFactory";
|
import { DerivedPropertiesMap } from "utils/WidgetFactory";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
|
|
||||||
import derivedProperties from "./parseDerivedProperties";
|
import derivedProperties from "./parseDerivedProperties";
|
||||||
import { DatePickerType, TimePrecision } from "../constants";
|
import { DatePickerType, TimePrecision } from "../constants";
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import {
|
||||||
ValidationTypes,
|
ValidationTypes,
|
||||||
ValidationResponse,
|
ValidationResponse,
|
||||||
} from "constants/WidgetValidation";
|
} from "constants/WidgetValidation";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
|
|
||||||
export function documentUrlValidation(value: unknown): ValidationResponse {
|
export function documentUrlValidation(value: unknown): ValidationResponse {
|
||||||
// applied validations if value exist
|
// applied validations if value exist
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import {
|
||||||
ValidationTypes,
|
ValidationTypes,
|
||||||
} from "constants/WidgetValidation";
|
} from "constants/WidgetValidation";
|
||||||
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import { MinimumPopupRows, GRID_DENSITY_MIGRATION_V1 } from "widgets/constants";
|
import { MinimumPopupRows, GRID_DENSITY_MIGRATION_V1 } from "widgets/constants";
|
||||||
import { LabelPosition } from "components/constants";
|
import { LabelPosition } from "components/constants";
|
||||||
import { Alignment } from "@blueprintjs/core";
|
import { Alignment } from "@blueprintjs/core";
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import { InputType, InputTypes } from "../constants";
|
||||||
import { GRID_DENSITY_MIGRATION_V1 } from "widgets/constants";
|
import { GRID_DENSITY_MIGRATION_V1 } from "widgets/constants";
|
||||||
import { ISDCodeDropdownOptions } from "../component/ISDCodeDropdown";
|
import { ISDCodeDropdownOptions } from "../component/ISDCodeDropdown";
|
||||||
import { CurrencyDropdownOptions } from "../component/CurrencyCodeDropdown";
|
import { CurrencyDropdownOptions } from "../component/CurrencyCodeDropdown";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import {
|
import {
|
||||||
formatCurrencyNumber,
|
formatCurrencyNumber,
|
||||||
getDecimalSeparator,
|
getDecimalSeparator,
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import {
|
||||||
} from "@appsmith/constants/messages";
|
} from "@appsmith/constants/messages";
|
||||||
import { DerivedPropertiesMap } from "utils/WidgetFactory";
|
import { DerivedPropertiesMap } from "utils/WidgetFactory";
|
||||||
import { GRID_DENSITY_MIGRATION_V1, ICON_NAMES } from "widgets/constants";
|
import { GRID_DENSITY_MIGRATION_V1, ICON_NAMES } from "widgets/constants";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import BaseInputWidget from "widgets/BaseInputWidget";
|
import BaseInputWidget from "widgets/BaseInputWidget";
|
||||||
import { isNil, isNumber, merge, toString } from "lodash";
|
import { isNil, isNumber, merge, toString } from "lodash";
|
||||||
import derivedProperties from "./parsedDerivedProperties";
|
import derivedProperties from "./parsedDerivedProperties";
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { Alignment } from "@blueprintjs/core";
|
import { Alignment } from "@blueprintjs/core";
|
||||||
|
|
||||||
import generatePanelPropertyConfig from "./propertyConfig/generatePanelPropertyConfig";
|
import generatePanelPropertyConfig from "./propertyConfig/generatePanelPropertyConfig";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
||||||
import { JSONFormWidgetProps } from ".";
|
import { JSONFormWidgetProps } from ".";
|
||||||
import { ROOT_SCHEMA_KEY } from "../constants";
|
import { ROOT_SCHEMA_KEY } from "../constants";
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import {
|
||||||
} from "constants/WidgetValidation";
|
} from "constants/WidgetValidation";
|
||||||
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
||||||
import { get } from "lodash";
|
import { get } from "lodash";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import {
|
import {
|
||||||
ARRAY_ITEM_KEY,
|
ARRAY_ITEM_KEY,
|
||||||
FIELD_EXPECTING_OPTIONS,
|
FIELD_EXPECTING_OPTIONS,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import { CurrencyDropdownOptions } from "widgets/CurrencyInputWidget/component/CurrencyCodeDropdown";
|
import { CurrencyDropdownOptions } from "widgets/CurrencyInputWidget/component/CurrencyCodeDropdown";
|
||||||
import { FieldType, INPUT_TYPES } from "widgets/JSONFormWidget/constants";
|
import { FieldType, INPUT_TYPES } from "widgets/JSONFormWidget/constants";
|
||||||
import {
|
import {
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import {
|
||||||
ValidationResponse,
|
ValidationResponse,
|
||||||
ValidationTypes,
|
ValidationTypes,
|
||||||
} from "constants/WidgetValidation";
|
} from "constants/WidgetValidation";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import { JSONFormWidgetProps } from "../..";
|
import { JSONFormWidgetProps } from "../..";
|
||||||
|
|
||||||
export function defaultOptionValueValidation(
|
export function defaultOptionValueValidation(
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import {
|
||||||
ValidationTypes,
|
ValidationTypes,
|
||||||
} from "constants/WidgetValidation";
|
} from "constants/WidgetValidation";
|
||||||
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import { FieldType } from "widgets/JSONFormWidget/constants";
|
import { FieldType } from "widgets/JSONFormWidget/constants";
|
||||||
import { optionsCustomValidation } from "widgets/RadioGroupWidget/widget";
|
import { optionsCustomValidation } from "widgets/RadioGroupWidget/widget";
|
||||||
import {
|
import {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import {
|
||||||
ValidationTypes,
|
ValidationTypes,
|
||||||
} from "constants/WidgetValidation";
|
} from "constants/WidgetValidation";
|
||||||
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
|
|
||||||
export function defaultOptionValueValidation(
|
export function defaultOptionValueValidation(
|
||||||
inputValue: unknown,
|
inputValue: unknown,
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import { ListWidgetProps } from "../constants";
|
||||||
import { ValidationTypes } from "constants/WidgetValidation";
|
import { ValidationTypes } from "constants/WidgetValidation";
|
||||||
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
||||||
import { EVAL_VALUE_PATH } from "utils/DynamicBindingUtils";
|
import { EVAL_VALUE_PATH } from "utils/DynamicBindingUtils";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
|
|
||||||
export const PropertyPaneContentConfig = [
|
export const PropertyPaneContentConfig = [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import {
|
||||||
MapTypes,
|
MapTypes,
|
||||||
} from "../constants";
|
} from "../constants";
|
||||||
import { MapType } from "../component";
|
import { MapType } from "../component";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
|
|
||||||
const MapChartComponent = lazy(() =>
|
const MapChartComponent = lazy(() =>
|
||||||
retryPromise(() =>
|
retryPromise(() =>
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import { DefaultValueType } from "rc-tree-select/lib/interface";
|
||||||
import { Layers } from "constants/Layers";
|
import { Layers } from "constants/Layers";
|
||||||
import { CheckedStrategy } from "rc-tree-select/lib/utils/strategyUtil";
|
import { CheckedStrategy } from "rc-tree-select/lib/utils/strategyUtil";
|
||||||
import { GRID_DENSITY_MIGRATION_V1, MinimumPopupRows } from "widgets/constants";
|
import { GRID_DENSITY_MIGRATION_V1, MinimumPopupRows } from "widgets/constants";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import MultiTreeSelectComponent from "../component";
|
import MultiTreeSelectComponent from "../component";
|
||||||
import { LabelPosition } from "components/constants";
|
import { LabelPosition } from "components/constants";
|
||||||
import { Alignment } from "@blueprintjs/core";
|
import { Alignment } from "@blueprintjs/core";
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import {
|
||||||
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
||||||
import MultiSelectComponent from "../component";
|
import MultiSelectComponent from "../component";
|
||||||
import { Layers } from "constants/Layers";
|
import { Layers } from "constants/Layers";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import { MinimumPopupRows, GRID_DENSITY_MIGRATION_V1 } from "widgets/constants";
|
import { MinimumPopupRows, GRID_DENSITY_MIGRATION_V1 } from "widgets/constants";
|
||||||
import { LabelPosition } from "components/constants";
|
import { LabelPosition } from "components/constants";
|
||||||
import { Alignment } from "@blueprintjs/core";
|
import { Alignment } from "@blueprintjs/core";
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import { Layers } from "constants/Layers";
|
||||||
import { MinimumPopupRows, GRID_DENSITY_MIGRATION_V1 } from "widgets/constants";
|
import { MinimumPopupRows, GRID_DENSITY_MIGRATION_V1 } from "widgets/constants";
|
||||||
import { LabelPosition } from "components/constants";
|
import { LabelPosition } from "components/constants";
|
||||||
import { Alignment } from "@blueprintjs/core";
|
import { Alignment } from "@blueprintjs/core";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import { isAutoHeightEnabledForWidget } from "widgets/WidgetUtils";
|
import { isAutoHeightEnabledForWidget } from "widgets/WidgetUtils";
|
||||||
|
|
||||||
export function defaultOptionValueValidation(
|
export function defaultOptionValueValidation(
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { Alignment } from "@blueprintjs/core";
|
import { Alignment } from "@blueprintjs/core";
|
||||||
import { LabelPosition } from "components/constants";
|
import { LabelPosition } from "components/constants";
|
||||||
import { ValidationTypes } from "constants/WidgetValidation";
|
import { ValidationTypes } from "constants/WidgetValidation";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import { NumberSliderWidgetProps } from "..";
|
import { NumberSliderWidgetProps } from "..";
|
||||||
import {
|
import {
|
||||||
defaultValueValidation,
|
defaultValueValidation,
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import {
|
||||||
getCountryCode,
|
getCountryCode,
|
||||||
ISDCodeDropdownOptions,
|
ISDCodeDropdownOptions,
|
||||||
} from "../component/ISDCodeDropdown";
|
} from "../component/ISDCodeDropdown";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import BaseInputWidget from "widgets/BaseInputWidget";
|
import BaseInputWidget from "widgets/BaseInputWidget";
|
||||||
import derivedProperties from "./parsedDerivedProperties";
|
import derivedProperties from "./parsedDerivedProperties";
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import { Color } from "constants/Colors";
|
||||||
import BaseWidget, { WidgetProps, WidgetState } from "widgets/BaseWidget";
|
import BaseWidget, { WidgetProps, WidgetState } from "widgets/BaseWidget";
|
||||||
import TextComponent, { TextAlign } from "../component";
|
import TextComponent, { TextAlign } from "../component";
|
||||||
import { ContainerStyle } from "widgets/ContainerWidget/component";
|
import { ContainerStyle } from "widgets/ContainerWidget/component";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import { OverflowTypes } from "../constants";
|
import { OverflowTypes } from "../constants";
|
||||||
import WidgetStyleContainer from "components/designSystems/appsmith/WidgetStyleContainer";
|
import WidgetStyleContainer from "components/designSystems/appsmith/WidgetStyleContainer";
|
||||||
import { pick } from "lodash";
|
import { pick } from "lodash";
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { isArray, compact, isNumber } from "lodash";
|
||||||
import BaseWidget, { WidgetProps, WidgetState } from "../../BaseWidget";
|
import BaseWidget, { WidgetProps, WidgetState } from "../../BaseWidget";
|
||||||
import { TextSize, WidgetType } from "constants/WidgetConstants";
|
import { TextSize, WidgetType } from "constants/WidgetConstants";
|
||||||
import { GRID_DENSITY_MIGRATION_V1 } from "widgets/constants";
|
import { GRID_DENSITY_MIGRATION_V1 } from "widgets/constants";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import { EventType } from "constants/AppsmithActionConstants/ActionConstants";
|
import { EventType } from "constants/AppsmithActionConstants/ActionConstants";
|
||||||
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
||||||
import { RadioOption } from "../constants";
|
import { RadioOption } from "../constants";
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import { ValidationTypes } from "constants/WidgetValidation";
|
import { ValidationTypes } from "constants/WidgetValidation";
|
||||||
import { LabelPosition } from "components/constants";
|
import { LabelPosition } from "components/constants";
|
||||||
import { Alignment } from "@blueprintjs/core";
|
import { Alignment } from "@blueprintjs/core";
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import RateComponent from "../component";
|
||||||
import { ValidationTypes } from "constants/WidgetValidation";
|
import { ValidationTypes } from "constants/WidgetValidation";
|
||||||
import { DerivedPropertiesMap } from "utils/WidgetFactory";
|
import { DerivedPropertiesMap } from "utils/WidgetFactory";
|
||||||
import { EventType } from "constants/AppsmithActionConstants/ActionConstants";
|
import { EventType } from "constants/AppsmithActionConstants/ActionConstants";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
|
|
||||||
function validateDefaultRate(value: unknown, props: any, _: any) {
|
function validateDefaultRate(value: unknown, props: any, _: any) {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
||||||
import { MinimumPopupRows, GRID_DENSITY_MIGRATION_V1 } from "widgets/constants";
|
import { MinimumPopupRows, GRID_DENSITY_MIGRATION_V1 } from "widgets/constants";
|
||||||
import { LabelPosition } from "components/constants";
|
import { LabelPosition } from "components/constants";
|
||||||
import { Alignment } from "@blueprintjs/core";
|
import { Alignment } from "@blueprintjs/core";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import {
|
import {
|
||||||
findIndex,
|
findIndex,
|
||||||
isArray,
|
isArray,
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import {
|
||||||
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
||||||
import { DefaultValueType } from "rc-tree-select/lib/interface";
|
import { DefaultValueType } from "rc-tree-select/lib/interface";
|
||||||
import { Layers } from "constants/Layers";
|
import { Layers } from "constants/Layers";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import { GRID_DENSITY_MIGRATION_V1, MinimumPopupRows } from "widgets/constants";
|
import { GRID_DENSITY_MIGRATION_V1, MinimumPopupRows } from "widgets/constants";
|
||||||
import SingleSelectTreeComponent from "../component";
|
import SingleSelectTreeComponent from "../component";
|
||||||
import { LabelPosition } from "components/constants";
|
import { LabelPosition } from "components/constants";
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { get } from "lodash";
|
||||||
import { TableWidgetProps } from "../constants";
|
import { TableWidgetProps } from "../constants";
|
||||||
import { ValidationTypes } from "constants/WidgetValidation";
|
import { ValidationTypes } from "constants/WidgetValidation";
|
||||||
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import { PropertyPaneConfig } from "constants/PropertyControlConstants";
|
import { PropertyPaneConfig } from "constants/PropertyControlConstants";
|
||||||
import { ButtonVariantTypes } from "components/constants";
|
import { ButtonVariantTypes } from "components/constants";
|
||||||
import {
|
import {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import {
|
||||||
updateNumberColumnTypeTextAlignment,
|
updateNumberColumnTypeTextAlignment,
|
||||||
updateThemeStylesheetsInColumns,
|
updateThemeStylesheetsInColumns,
|
||||||
} from "../../propertyUtils";
|
} from "../../propertyUtils";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import { isColumnTypeEditable } from "../../utilities";
|
import { isColumnTypeEditable } from "../../utilities";
|
||||||
import { composePropertyUpdateHook } from "widgets/WidgetUtils";
|
import { composePropertyUpdateHook } from "widgets/WidgetUtils";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import {
|
||||||
updateNumberColumnTypeTextAlignment,
|
updateNumberColumnTypeTextAlignment,
|
||||||
updateThemeStylesheetsInColumns,
|
updateThemeStylesheetsInColumns,
|
||||||
} from "../../propertyUtils";
|
} from "../../propertyUtils";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import { composePropertyUpdateHook } from "widgets/WidgetUtils";
|
import { composePropertyUpdateHook } from "widgets/WidgetUtils";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { ValidationTypes } from "constants/WidgetValidation";
|
import { ValidationTypes } from "constants/WidgetValidation";
|
||||||
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import {
|
import {
|
||||||
InlineEditingSaveOptions,
|
InlineEditingSaveOptions,
|
||||||
TableWidgetProps,
|
TableWidgetProps,
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import { cloneDeep, get } from "lodash";
|
||||||
import { ValidationTypes } from "constants/WidgetValidation";
|
import { ValidationTypes } from "constants/WidgetValidation";
|
||||||
import { generateReactKey } from "utils/generators";
|
import { generateReactKey } from "utils/generators";
|
||||||
import { EVAL_VALUE_PATH } from "utils/DynamicBindingUtils";
|
import { EVAL_VALUE_PATH } from "utils/DynamicBindingUtils";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
|
|
||||||
class TabsMigratorWidget extends BaseWidget<
|
class TabsMigratorWidget extends BaseWidget<
|
||||||
TabsWidgetProps<TabContainerWidgetProps>,
|
TabsWidgetProps<TabContainerWidgetProps>,
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import {
|
||||||
} from "constants/WidgetValidation";
|
} from "constants/WidgetValidation";
|
||||||
import { EventType } from "constants/AppsmithActionConstants/ActionConstants";
|
import { EventType } from "constants/AppsmithActionConstants/ActionConstants";
|
||||||
import { TabContainerWidgetProps, TabsWidgetProps } from "../constants";
|
import { TabContainerWidgetProps, TabsWidgetProps } from "../constants";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import { WidgetProperties } from "selectors/propertyPaneSelectors";
|
import { WidgetProperties } from "selectors/propertyPaneSelectors";
|
||||||
import { WIDGET_PADDING } from "constants/WidgetConstants";
|
import { WIDGET_PADDING } from "constants/WidgetConstants";
|
||||||
import derivedProperties from "./parseDerivedProperties";
|
import derivedProperties from "./parseDerivedProperties";
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import { Color } from "constants/Colors";
|
||||||
import BaseWidget, { WidgetProps, WidgetState } from "widgets/BaseWidget";
|
import BaseWidget, { WidgetProps, WidgetState } from "widgets/BaseWidget";
|
||||||
import TextComponent, { TextAlign } from "../component";
|
import TextComponent, { TextAlign } from "../component";
|
||||||
import { ContainerStyle } from "widgets/ContainerWidget/component";
|
import { ContainerStyle } from "widgets/ContainerWidget/component";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import { OverflowTypes } from "../constants";
|
import { OverflowTypes } from "../constants";
|
||||||
import WidgetStyleContainer from "components/designSystems/appsmith/WidgetStyleContainer";
|
import WidgetStyleContainer from "components/designSystems/appsmith/WidgetStyleContainer";
|
||||||
import { pick } from "lodash";
|
import { pick } from "lodash";
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import { ValidationTypes } from "constants/WidgetValidation";
|
||||||
import Skeleton from "components/utils/Skeleton";
|
import Skeleton from "components/utils/Skeleton";
|
||||||
import { retryPromise } from "utils/AppsmithUtils";
|
import { retryPromise } from "utils/AppsmithUtils";
|
||||||
import ReactPlayer from "react-player";
|
import ReactPlayer from "react-player";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
import { ButtonBorderRadius } from "components/constants";
|
import { ButtonBorderRadius } from "components/constants";
|
||||||
|
|
||||||
const VideoComponent = lazy(() => retryPromise(() => import("../component")));
|
const VideoComponent = lazy(() => retryPromise(() => import("../component")));
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import { WidgetProps } from "widgets/BaseWidget";
|
||||||
import { RenderModes } from "constants/WidgetConstants";
|
import { RenderModes } from "constants/WidgetConstants";
|
||||||
import { ValidationTypes } from "constants/WidgetValidation";
|
import { ValidationTypes } from "constants/WidgetValidation";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/CodemirrorTernService";
|
||||||
|
|
||||||
const DUMMY_WIDGET: WidgetProps = {
|
const DUMMY_WIDGET: WidgetProps = {
|
||||||
bottomRow: 0,
|
bottomRow: 0,
|
||||||
|
|
|
||||||
57
app/client/src/workers/Tern/tern.worker.ts
Normal file
57
app/client/src/workers/Tern/tern.worker.ts
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
import tern, { Server, Def } from "tern";
|
||||||
|
import { CallbackFn, TernWorkerAction } from "utils/autocomplete/types";
|
||||||
|
|
||||||
|
let server: Server;
|
||||||
|
|
||||||
|
let nextId = 0;
|
||||||
|
const pending: { [x: number]: CallbackFn } = {};
|
||||||
|
|
||||||
|
self.onmessage = function(e) {
|
||||||
|
const data = e.data;
|
||||||
|
switch (data.type) {
|
||||||
|
case TernWorkerAction.INIT:
|
||||||
|
return startServer(data.defs, data.plugins, data.scripts);
|
||||||
|
case TernWorkerAction.ADD_FILE:
|
||||||
|
return server.addFile(data.name, data.text);
|
||||||
|
case TernWorkerAction.DELETE_FILE:
|
||||||
|
return server.delFile(data.name);
|
||||||
|
case TernWorkerAction.REQUEST:
|
||||||
|
return server.request(data.body, function(err, reqData) {
|
||||||
|
postMessage({ id: data.id, body: reqData, err: err && String(err) });
|
||||||
|
});
|
||||||
|
case TernWorkerAction.GET_FILE:
|
||||||
|
const c = pending[data.id];
|
||||||
|
delete pending[data.id];
|
||||||
|
return c(data.err, data.text);
|
||||||
|
case TernWorkerAction.DELETE_DEF:
|
||||||
|
return server.deleteDefs(data.name);
|
||||||
|
case TernWorkerAction.ADD_DEF:
|
||||||
|
return server.addDefs(data.defs);
|
||||||
|
default:
|
||||||
|
throw new Error("Unknown message type: " + data.type);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function getFile(file: string, c: CallbackFn) {
|
||||||
|
postMessage({ type: TernWorkerAction.GET_FILE, name: file, id: ++nextId });
|
||||||
|
pending[nextId] = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
function startServer(defs: Def[], plugins = {}, scripts?: string[]) {
|
||||||
|
//@ts-expect-error test
|
||||||
|
if (scripts) self.importScripts.apply(null, scripts);
|
||||||
|
|
||||||
|
server = new tern.Server({
|
||||||
|
getFile: getFile,
|
||||||
|
async: true,
|
||||||
|
defs: defs,
|
||||||
|
plugins: plugins,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
self.console = {
|
||||||
|
...self.console,
|
||||||
|
log: function(v) {
|
||||||
|
postMessage({ type: TernWorkerAction.DEBUG, message: v });
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
@ -353,7 +353,7 @@ Properties can be required to be validated when an Appsmith developer is allowed
|
||||||
- `expected` (required for `ValidationTypes.FUNCTION`, [CodeEditorExpected](https://github.com/appsmithorg/appsmith/blob/e772fd4ff96accfb94818fa9f0b58dc6851a1cf0/app/client/src/components/editorComponents/CodeEditor/index.tsx#L107)): A structure that describes the expected type, example and autocomplete data type.
|
- `expected` (required for `ValidationTypes.FUNCTION`, [CodeEditorExpected](https://github.com/appsmithorg/appsmith/blob/e772fd4ff96accfb94818fa9f0b58dc6851a1cf0/app/client/src/components/editorComponents/CodeEditor/index.tsx#L107)): A structure that describes the expected type, example and autocomplete data type.
|
||||||
- `type`(required, string): The type of the property to be shown to the Appsmith developer
|
- `type`(required, string): The type of the property to be shown to the Appsmith developer
|
||||||
- `example`(required, [ExpectedValueExample](https://github.com/appsmithorg/appsmith/blob/e772fd4ff96accfb94818fa9f0b58dc6851a1cf0/app/client/src/utils/validation/common.ts#L16)): An example of the value expected for the property.
|
- `example`(required, [ExpectedValueExample](https://github.com/appsmithorg/appsmith/blob/e772fd4ff96accfb94818fa9f0b58dc6851a1cf0/app/client/src/utils/validation/common.ts#L16)): An example of the value expected for the property.
|
||||||
- `autocompleteDataType`(required, [AutocompleteDataType](https://github.com/appsmithorg/appsmith/blob/e772fd4ff96accfb94818fa9f0b58dc6851a1cf0/app/client/src/utils/autocomplete/TernServer.ts#L64)): Describes how the auto-complete feature for this property should work.
|
- `autocompleteDataType`(required, [AutocompleteDataType](https://github.com/appsmithorg/appsmith/blob/e772fd4ff96accfb94818fa9f0b58dc6851a1cf0/app/client/src/utils/autocomplete/CodemirrorTernService.ts#L64)): Describes how the auto-complete feature for this property should work.
|
||||||
- `strict` (optional, boolean): If set to `true`, values in `ValidationTypes.TEXT`, will not be cast to a string before validating.
|
- `strict` (optional, boolean): If set to `true`, values in `ValidationTypes.TEXT`, will not be cast to a string before validating.
|
||||||
- `ignoreCase` (optional, boolean): If set to `true`, keys will be matched while ignoring case in `allowedKeys` parameter of the `ValidationTypes.OBJECT`.
|
- `ignoreCase` (optional, boolean): If set to `true`, keys will be matched while ignoring case in `allowedKeys` parameter of the `ValidationTypes.OBJECT`.
|
||||||
- `ValidationTypes.FUNCTION` is meant to be used sparingly, and as an escape hatch when the other `ValidationTypes` do not fit the requirements of validation.
|
- `ValidationTypes.FUNCTION` is meant to be used sparingly, and as an escape hatch when the other `ValidationTypes` do not fit the requirements of validation.
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ const extraLibraries = [
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
3. To make this show up in autocomplete of appsmith we will need to add this to the Tern server file `app/client/src/utils/autocomplete/TernServer.ts`
|
3. To make this show up in autocomplete of appsmith we will need to add this to the Tern server file `app/client/src/utils/autocomplete/CodemirrorTernService.ts`
|
||||||
- Add a new def file for your library usages [ref](https://ternjs.net/doc/manual.html#typedef) under `app/client/src/constants/defs/`
|
- Add a new def file for your library usages [ref](https://ternjs.net/doc/manual.html#typedef) under `app/client/src/constants/defs/`
|
||||||
- Import that file in the Tern Server file and add the def in the `DEFS` array right at the top of file
|
- Import that file in the Tern Server file and add the def in the `DEFS` array right at the top of file
|
||||||
```
|
```
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user