Skip to content

Commit 8462413

Browse files
authored
remove pings, fix input view types (#322)
1 parent 387b059 commit 8462413

File tree

4 files changed

+36
-28
lines changed

4 files changed

+36
-28
lines changed

packages/editor/src/runtime/executor/executionHosts/sandboxed/SandboxedExecutionHost.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ export default class SandboxedExecutionHost
293293

294294
private async pingFrame() {
295295
const result = await this.connectionMethods!.ping();
296-
console.log("received ping result", result);
296+
// console.log("received ping result", result);
297297
if (result !== "pong") {
298298
throw new Error("invalid ping response");
299299
}

packages/editor/src/runtime/executor/executionHosts/sandboxed/iframesandbox/FrameConnection.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { observable, runInAction } from "mobx";
33
import { AsyncMethodReturns, Connection, connectToParent } from "penpal";
44
import { lifecycle } from "vscode-lib";
55
import { CompiledCodeModel } from "../../../../../models/CompiledCodeModel";
6-
import { getTypeCellResolver } from "../../../resolver/resolver";
76
import { ModelOutput } from "../../../components/ModelOutput";
7+
import { getTypeCellResolver } from "../../../resolver/resolver";
88

9-
import { ModelReceiver } from "./ModelReceiver";
109
import type { VisualizersByPath } from "../../../../extensions/visualizer/VisualizerExtension";
11-
import { IframeBridgeMethods } from "./IframeBridgeMethods";
1210
import { HostBridgeMethods } from "../HostBridgeMethods";
11+
import { IframeBridgeMethods } from "./IframeBridgeMethods";
12+
import { ModelReceiver } from "./ModelReceiver";
1313

1414
let ENGINE_ID = 0;
1515

@@ -224,7 +224,7 @@ export class FrameConnection extends lifecycle.Disposable {
224224
});
225225
},
226226
ping: async () => {
227-
console.log("ping received, sending pong");
227+
// console.log("ping received, sending pong");
228228
return "pong";
229229
},
230230

packages/editor/src/runtime/executor/lib/exports.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default function getExposeGlobalVariables(id: string) {
99
return {
1010
// routing,
1111
// // DocumentView,
12-
Input: Input as any, // TODO
12+
Input,
1313
// namespace: id, // TODO: naming
1414
// open: (identifier: string | { owner: string; document: string }) => {
1515
// return DocConnection.load(identifier);

packages/editor/src/runtime/executor/lib/input/Input.tsx

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,38 @@
1+
import { getReactViewValue } from "@typecell-org/engine";
12
import { IObservableValue, isObservable, observable } from "mobx";
23
import * as React from "react";
3-
import { getReactViewValue, ReactView } from "@typecell-org/engine";
44
import ReactViewElement from "./ReactViewElement";
55

6+
// same as ReactView from typecell-org/engine, but define here so we don't import all types at runtime
7+
type TypeCellView<T> = React.ReactElement<{
8+
__tcObservable: T;
9+
}>;
10+
11+
type TextAreaType = React.ReactElement<
12+
React.DetailedHTMLProps<
13+
React.TextareaHTMLAttributes<HTMLTextAreaElement>,
14+
HTMLTextAreaElement
15+
>
16+
>;
17+
18+
type SelectType = React.ReactElement<
19+
React.DetailedHTMLProps<
20+
React.SelectHTMLAttributes<HTMLSelectElement>,
21+
HTMLSelectElement
22+
>
23+
>;
24+
25+
type InputType = React.ReactElement<
26+
React.DetailedHTMLProps<
27+
React.InputHTMLAttributes<HTMLInputElement>,
28+
HTMLInputElement
29+
>
30+
>;
31+
632
export function Input<T extends string | string[] | number = string>(
7-
el:
8-
| React.ReactElement<
9-
React.DetailedHTMLProps<
10-
React.InputHTMLAttributes<HTMLInputElement>,
11-
HTMLInputElement
12-
>
13-
>
14-
| React.ReactElement<
15-
React.DetailedHTMLProps<
16-
React.TextareaHTMLAttributes<HTMLTextAreaElement>,
17-
HTMLTextAreaElement
18-
>
19-
>
20-
| React.ReactElement<
21-
React.DetailedHTMLProps<
22-
React.SelectHTMLAttributes<HTMLSelectElement>,
23-
HTMLSelectElement
24-
>
25-
>,
26-
bindingOrDefaultValue?: T | ReactView<T>
27-
): ReactView<T extends string ? string : T> {
33+
el: TextAreaType | SelectType | InputType,
34+
bindingOrDefaultValue?: T | TypeCellView<T>
35+
): TypeCellView<T extends string ? string : T> {
2836
// don't use string literals
2937
if (el.type !== "input" && el.type !== "select" && el.type !== "textarea") {
3038
throw new Error("invalid element passed");

0 commit comments

Comments
 (0)