Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/modern-cougars-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@triplex/editor-next": patch
"@triplex/server": patch
"@triplex/renderer": patch
"triplex-vsce": patch
---

Cleanup stale feature gates.
4 changes: 1 addition & 3 deletions apps/vscode/__tests__/selection-ast-path.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
* see this files license find the nearest LICENSE file up the source tree.
*/
import { expect } from "@playwright/test";
import { overrideFg, test } from "./utils/runner";

overrideFg("selection_ast_path", true);
import { test } from "./utils/runner";

test("focus custom component displays props", async ({ vsce }) => {
await vsce.codelens("Scene").click();
Expand Down
4 changes: 1 addition & 3 deletions apps/vscode/__tests__/transforms-immutable.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
* see this files license find the nearest LICENSE file up the source tree.
*/
import { expect } from "@playwright/test";
import { overrideFg, test } from "./utils/runner";

overrideFg("immutable_transform_controls", true);
import { test } from "./utils/runner";

test.describe(() => {
test.use({
Expand Down
8 changes: 4 additions & 4 deletions packages/@triplex/editor-next/src/features/app-root/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
*/
import { monitorForExternal } from "@atlaskit/pragmatic-drag-and-drop/external/adapter";
import { cn } from "@triplex/lib";
import { fg } from "@triplex/lib/fg";
import { useScreenView } from "@triplex/ux";
import { useEffect, useState } from "react";
import { preloadSubscription } from "../../hooks/ws";
import { AIChat } from "../ai-chat";
import { FloatingControls } from "../floating-controls";
import { Panels } from "../panels";
import { VSCodeDropZone } from "../vscode-drop-zone";
Expand Down Expand Up @@ -51,10 +49,12 @@ export function AppRoot() {
data-testid="scene"
id="scene"
src={`http://localhost:${window.triplex.env.ports.client}/scene`}
style={{ pointerEvents: "var(--canvas-pointer-events, auto)" /* can be used to disable pointer events on iframe */ }}
style={{
pointerEvents:
"var(--canvas-pointer-events, auto)" /* can be used to disable pointer events on iframe */,
}}
/>
</div>
{fg("ai_chat") && <AIChat />}
<VSCodeDropZone />
</div>
);
Expand Down
9 changes: 2 additions & 7 deletions packages/@triplex/editor-next/src/features/panels/element.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
} from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
import { compose, on, send } from "@triplex/bridge/host";
import { cn } from "@triplex/lib";
import { fg } from "@triplex/lib/fg";
import { type JsxElementPositions } from "@triplex/server";
import { bind } from "bind-event-listener";
import {
Expand Down Expand Up @@ -90,12 +89,8 @@ export function SceneElement(
const isSelected =
!isDragging &&
!!selected &&
(fg("selection_ast_path")
? selected.astPath === props.astPath && props.parentPath === selected.path
: "column" in selected &&
selected.column === props.column &&
selected.line === props.line &&
selected.path === props.parentPath);
selected.astPath === props.astPath &&
props.parentPath === selected.path;
const filter = useFilter((state) => state.filter);
const matches = matchesFilter(filter, props);
const isExpanded = isUserExpanded || !!filter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/
import { EraserIcon } from "@radix-ui/react-icons";
import { send } from "@triplex/bridge/host";
import { fg } from "@triplex/lib/fg";
import { PropInput } from "@triplex/ux/inputs";
import { useEffect, useReducer } from "react";
import * as Accordion from "../../components/accordion";
Expand Down Expand Up @@ -72,7 +71,7 @@ function SelectionPanelLoadable({ selected }: { selected: SceneSelected }) {
const props = useLazySubscription(
isPropsForComponent
? "/scene/:path/:exportName/props"
: selected.astPath && fg("selection_ast_path")
: selected.astPath
? "/scene/:path/object/:astPath"
: "/scene/:path/object/:line/:column",
selected,
Expand Down
26 changes: 10 additions & 16 deletions packages/@triplex/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
import { readFile } from "node:fs/promises";
import { Application, isHttpError, Router } from "@oakserver/oak";
import { fg, initFeatureGates } from "@triplex/lib/fg";
import { initFeatureGates } from "@triplex/lib/fg";
import { createForkLogger } from "@triplex/lib/log";
import { basename } from "@triplex/lib/path";
import { type FGEnvironment } from "@triplex/lib/types";
Expand Down Expand Up @@ -37,7 +37,6 @@ import {
deleteElement,
duplicate,
duplicateElement,
group,
groupElements,
insertCode,
move,
Expand Down Expand Up @@ -167,14 +166,10 @@ export async function createServer({
const body = await context.request.body({ type: "json" }).value;

const [ids, result] = await sourceFile.edit((source) => {
if (fg("selection_ast_path")) {
return groupElements(source, {
elements: body.elements,
tag: "group",
});
} else {
return group(source, { elements: body.elements, group: "group" });
}
return groupElements(source, {
elements: body.elements,
tag: "group",
});
});

context.response.body = { ...ids, ...result };
Expand Down Expand Up @@ -270,10 +265,9 @@ export async function createServer({
const sourceFile = project.getSourceFile(path);

const [ids, result] = await sourceFile.edit((source) => {
const jsxElement =
astPath && fg("selection_ast_path")
? getJsxElementFromAstPathOrThrow(source, astPath)[0]
: getJsxElementAtOrThrow(source, line, column);
const jsxElement = astPath
? getJsxElementFromAstPathOrThrow(source, astPath)[0]
: getJsxElementAtOrThrow(source, line, column);

const action = upsertProp(jsxElement, name, value);

Expand Down Expand Up @@ -314,7 +308,7 @@ export async function createServer({
const astPath = getParamOptional(context, "astPath");

const [ids, result] = await sourceFile.edit((source) => {
if (astPath && fg("selection_ast_path")) {
if (astPath) {
return duplicateElement(source, astPath);
} else {
return duplicate(source, Number(line), Number(column));
Expand All @@ -331,7 +325,7 @@ export async function createServer({
const astPath = getParamOptional(context, "astPath");

const [ids] = await sourceFile.edit((source) => {
if (astPath && fg("selection_ast_path")) {
if (astPath) {
deleteElement(getJsxElementFromAstPathOrThrow(source, astPath)[0]);
} else {
commentComponent(source, Number(line), Number(column));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* see this files license find the nearest LICENSE file up the source tree.
*/
import { useThree } from "@react-three/fiber";
import { fg } from "@triplex/lib/fg";
import { useContext, useLayoutEffect, useRef } from "react";
import { fitCameraToObjects } from "../../util/three";
import { CameraControlsContext } from "../camera-new/context";
Expand All @@ -25,10 +24,7 @@ export function FitCameraToScene({ resetKeys }: { resetKeys?: string[] }) {
}, [resetKey]);

useLayoutEffect(() => {
if (
!controls ||
(sceneHasBeenPositioned.current && fg("fit_to_camera_fix"))
) {
if (!controls || sceneHasBeenPositioned.current) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import { compose, on, type RendererElementProps } from "@triplex/bridge/client";
import { fg } from "@triplex/lib/fg";
import { useCallback, useEffect, useRef, useState } from "react";

function useForceRender() {
Expand Down Expand Up @@ -40,7 +39,7 @@ export function useTemporaryProps(
}
}),
on("request-set-element-prop", (data) => {
if (data.astPath === meta.astPath && fg("selection_ast_path")) {
if (data.astPath === meta.astPath) {
intermediateProps.current[data.propName] = data.propValue;
forceRender();
} else if (
Expand All @@ -54,7 +53,7 @@ export function useTemporaryProps(
}
}),
on("request-reset-prop", (data) => {
if (data.astPath === meta.astPath && fg("selection_ast_path")) {
if (data.astPath === meta.astPath) {
delete intermediateProps.current[data.propName];
forceRender();
} else if (
Expand Down
72 changes: 2 additions & 70 deletions packages/renderer/src/features/selection-three-fiber/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
import { useThree } from "@react-three/fiber";
import { compose, on, send } from "@triplex/bridge/client";
import { useEvent } from "@triplex/lib";
import { fg } from "@triplex/lib/fg";
import { useRevivableState } from "@triplex/lib/use-revivables";
import { useContext, useEffect, type ReactNode } from "react";
import { Camera } from "three";
import { HOVER_LAYER_INDEX, SELECTION_LAYER_INDEX } from "../../util/layers";
import { resolveElementMeta } from "../../util/meta";
import { encodeProps, fitCameraToObjects, strip } from "../../util/three";
import { encodeProps, fitCameraToObjects } from "../../util/three";
import { SwitchToComponentContext } from "../app/context";
import {
ActiveCameraContext,
Expand All @@ -34,7 +33,6 @@ import {
import { SelectionIndicator } from "./selection-indicator";
import { SelectionIndicatorLines } from "./selection-indicator-lines";
import { useActionsStore } from "./store";
import { TransformControls } from "./transform-controls";
import {
TransformControls as TransformControlsImmutable,
type TransformEvent,
Expand Down Expand Up @@ -313,54 +311,6 @@ export function ThreeFiberSelection({
}
});

const onCompleteTransformHandler = useEvent(() => {
if (!resolvedObject) {
return;
}

if (transform === "translate") {
const position = resolvedObject.object.position.toArray();

send("element-set-prop", {
astPath: resolvedObject.meta.astPath,
column: resolvedObject.meta.column,
line: resolvedObject.meta.line,
path: resolvedObject.meta.path,
propName: "position",
propValue: position.map(strip),
});

send("track", { actionId: "element_transform_translate" });
} else if (transform === "rotate") {
const rotation = resolvedObject.object.rotation.toArray();
rotation.pop();

send("element-set-prop", {
astPath: resolvedObject.meta.astPath,
column: resolvedObject.meta.column,
line: resolvedObject.meta.line,
path: resolvedObject.meta.path,
propName: "rotation",
propValue: rotation,
});

send("track", { actionId: "element_transform_rotate" });
} else if (transform === "scale") {
const scale = resolvedObject.object.scale.toArray();

send("element-set-prop", {
astPath: resolvedObject.meta.astPath,
column: resolvedObject.meta.column,
line: resolvedObject.meta.line,
path: resolvedObject.meta.path,
propName: "scale",
propValue: scale.map(strip),
});

send("track", { actionId: "element_transform_scale" });
}
});

return (
<SceneObjectContext.Provider value={true}>
<SceneObjectEventsContext.Provider
Expand All @@ -372,8 +322,7 @@ export function ThreeFiberSelection({
{!!resolvedObject &&
transform !== "none" &&
window.triplex.env.mode === "default" &&
Object.values(transforms).some(Boolean) &&
fg("immutable_transform_controls") && (
Object.values(transforms).some(Boolean) && (
<TransformControlsImmutable
enabled={
/^[a-z]/.test(resolvedObject.meta.name)
Expand All @@ -388,23 +337,6 @@ export function ThreeFiberSelection({
/>
)}

{!!resolvedObject &&
transform !== "none" &&
window.triplex.env.mode === "default" &&
!fg("immutable_transform_controls") && (
<TransformControls
enabled={
/^[a-z]/.test(resolvedObject.meta.name)
? true
: transforms[transform]
}
mode={transform}
object={resolvedObject.object}
onCompleteTransform={onCompleteTransformHandler}
space={space}
/>
)}

{window.triplex.env.mode === "webxr" &&
!!resolvedObject &&
transform !== "none" && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import { type TriplexMeta } from "@triplex/bridge/client";
import { fg } from "@triplex/lib/fg";
import {
Raycaster,
Vector2,
Expand Down Expand Up @@ -80,7 +79,7 @@ export const findObject3D = (
const meta = obj.__triplex;

if (
(meta.astPath === filter.astPath && fg("selection_ast_path")) ||
meta.astPath === filter.astPath ||
(meta.path === filter.path &&
meta.column === filter.column &&
meta.line === filter.line)
Expand All @@ -93,7 +92,7 @@ export const findObject3D = (
for (const parent of meta.parents) {
// Check the parents in the meta to see if they are a match and if so resolve the object.
if (
((parent.astPath === filter.astPath && fg("selection_ast_path")) ||
(parent.astPath === filter.astPath ||
(parent.path === filter.path &&
parent.column === filter.column &&
parent.line === filter.line)) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
type Instance,
} from "@react-three/fiber";
import { applyStepModifiers, useEvent, useStepModifiers } from "@triplex/lib";
import { fg } from "@triplex/lib/fg";
import {
Fragment,
useContext,
Expand Down Expand Up @@ -160,19 +159,13 @@ export function TransformControls({
return;
}

if (fg("transform_controls_read_from_props")) {
applyProps(placeholder as Instance["object"], {
position:
object.meta.props.current.position || defaultTransforms.position,
rotation:
object.meta.props.current.rotation || defaultTransforms.rotation,
scale: object.meta.props.current.scale || defaultTransforms.scale,
});
} else {
placeholder.position.copy(object.object.position);
placeholder.rotation.copy(object.object.rotation);
placeholder.scale.copy(object.object.scale);
}
applyProps(placeholder as Instance["object"], {
position:
object.meta.props.current.position || defaultTransforms.position,
rotation:
object.meta.props.current.rotation || defaultTransforms.rotation,
scale: object.meta.props.current.scale || defaultTransforms.scale,
});
});

return (
Expand Down
Loading
Loading