Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Website demo fixes #214

Merged
merged 5 commits into from
Oct 11, 2023
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
2,922 changes: 1,503 additions & 1,419 deletions inst/editor-component-lib/dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion inst/editor-component-lib/dist/style.css

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion inst/editor/build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Shiny UI Editor</title>
<script type="module" crossorigin src="./assets/index-b2d1ab08.js"></script>
<script type="module" crossorigin src="./assets/index-f61903d1.js"></script>
<link rel="stylesheet" href="./assets/index-4c252521.css">
</head>

Expand Down
20 changes: 15 additions & 5 deletions inst/editor/src/EditorContainer/TSParserProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@ const TSParserContext = React.createContext<ParseAppFn>(() => {
*
* @param props.children Children for composition
*/
export function TSParserProvider({ children }: { children: React.ReactNode }) {
export function TSParserProvider({
children,
pathToTreeSitterWasm,
}: {
children: React.ReactNode;
/**
* Optional path to the treesitter wasm bundle. This is useful when we're embedding
*/
pathToTreeSitterWasm?: string;
}) {
const metaData = useMetaData();
const parseAppRef = React.useRef<ParseAppFn>(() => {
throw new Error("No parser set up yet");
Expand All @@ -43,13 +52,14 @@ export function TSParserProvider({ children }: { children: React.ReactNode }) {
);
}

const { language, path_to_ts_wasm } = metaData;
const { language, path_to_ts_wasm: pathToTSFromMeta } = metaData;
const parserInitOptions: ParserInitOptions = {};

if (path_to_ts_wasm) {
const pathToWasm = pathToTreeSitterWasm || pathToTSFromMeta;

if (pathToWasm) {
// If we're in a vscode extension we will have info on where to find the
// wasm bundle that we need to respect or else the parser will fail to load
const pathToWasm = path_to_ts_wasm;
parserInitOptions.locateFile = () => pathToWasm;
}

Expand All @@ -69,7 +79,7 @@ export function TSParserProvider({ children }: { children: React.ReactNode }) {
};

initializedParser.current = true;
}, [metaData]);
}, [metaData, pathToTreeSitterWasm]);

// This callback remains referentially the same so that the parser can be
// updated without triggering a whole app rerender
Expand Down
9 changes: 8 additions & 1 deletion inst/editor/src/SUE.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,16 @@ import { mergeClasses } from "./utils/mergeClasses";
export function SUE({
showMessages = true,
backendDispatch: { sendMsg, incomingMsgs, mode } = staticDispatchFromTree(),
pathToTreeSitterWasm,
}: {
backendDispatch?: BackendConnection;
showMessages?: boolean;
/**
* Optional path to the treesitter wasm bundle. This is useful when we're embedding
* the editor somewhere that doesn't have the luxury of the file being bundled into
* everything like it does with vite.
*/
pathToTreeSitterWasm?: string;
}) {
const dispatch: BackendConnection = showMessages
? {
Expand All @@ -46,7 +53,7 @@ export function SUE({
<ReduxProvider>
<ErrorBoundary fallbackRender={WholeAppErrorFallback}>
<BackendConnectionProvider {...dispatch}>
<TSParserProvider>
<TSParserProvider pathToTreeSitterWasm={pathToTreeSitterWasm}>
<EditorContainer />
<ToastContainer />
</TSParserProvider>
Expand Down
1,542 changes: 1,524 additions & 18 deletions inst/vscode-extension/build/extension.js

Large diffs are not rendered by default.

Loading