Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
import type { BuilderState } from "../state/builder-state";
import { bindExpressionToInstanceScope, findAvailableVariables } from "./data";
import { getExpressionWarnings } from "./expression-validation";
export const bindExpressionInput = (
state: Pick<BuilderState, "instances" | "dataSources">,
instanceId: string,
expression: string,
excludeVariableNames?: Iterable<string>
) => {
if (state.instances === undefined || state.dataSources === undefined) {
return expression;
}
return bindExpressionToInstanceScope({
expression,
instanceId,
instances: state.instances,
dataSources: state.dataSources,
excludeVariableNames,
});
};
export const getScopedExpressionWarnings = (
state: BuilderState,
instanceId: string,
path: string[],
expression: string,
allowAssignment = false,
additionalVariables: readonly string[] = []
) => {
if (state.instances === undefined || state.dataSources === undefined) {
return [];
}
const availableVariables = new Set(
findAvailableVariables({
startingInstanceId: instanceId,
instances: state.instances,
dataSources: state.dataSources,
}).map(({ name }) => name)
);
for (const name of additionalVariables) {
availableVariables.add(name);
}
return getExpressionWarnings({
expression,
availableVariables,
allowAssignment,
path,
instanceId,
});
};