cargo anneal verify on the code.
+ cargo run.
+ cargo build.
+ cargo test.
+ {children}
+);
+
+const HirAside: React.FC = () => (
+ cdylib crate type, but the source code
+ does not specify an explicit crate type. Selecting this option will change the code to specify{' '}
+ cdylib.
+ {children}
+); + +export default ChannelMenu; diff --git a/anneal/v1/playground/rust-anneal-playground/ui/frontend/ConfigElement.module.css b/anneal/v1/playground/rust-anneal-playground/ui/frontend/ConfigElement.module.css new file mode 100644 index 0000000000..b9369292cd --- /dev/null +++ b/anneal/v1/playground/rust-anneal-playground/ui/frontend/ConfigElement.module.css @@ -0,0 +1,73 @@ +.container { + display: flex; + align-items: center; +} + +.name { + flex: 1; +} + +.notDefault { + composes: name; + color: var(--header-tint); + font-weight: 600; +} + +.value { + flex: 1; +} + +.select { + width: 100%; + background: var(--button-secondary-bg-color); + border-color: var(--button-secondary-border-color); + color: var(--button-secondary-color); + + & option { + background-color: var(--button-secondary-bg-color-top); + border-color: var(--button-secondary-border-color); + color: var(--button-secondary-color); + } +} + +.toggle { + display: grid; + grid-template-columns: 1fr 1fr; + + & label { + cursor: pointer; + padding: 0 1em; + color: #777; + font-weight: 600; + text-align: center; + text-transform: uppercase; + border: 1px solid transparent; + + &:hover { + background: hsl(208deg 100% 43% / 10%); + } + + &:first-of-type { + border-radius: var(--header-border-radius) 0 0 var(--header-border-radius); + border-right-width: 0; + } + + &:last-of-type { + border-radius: 0 var(--header-border-radius) var(--header-border-radius) 0; + border-left-width: 0; + } + } + + & input { + display: none; + + &:checked + label { + background: var(--header-tint); + color: #fff; + } + + &:not(:checked) + label { + border-color: #bbb; + } + } +} diff --git a/anneal/v1/playground/rust-anneal-playground/ui/frontend/ConfigElement.tsx b/anneal/v1/playground/rust-anneal-playground/ui/frontend/ConfigElement.tsx new file mode 100644 index 0000000000..02f5ce67dd --- /dev/null +++ b/anneal/v1/playground/rust-anneal-playground/ui/frontend/ConfigElement.tsx @@ -0,0 +1,90 @@ +import React, { type JSX } from 'react'; + +import MenuItem from './MenuItem'; + +import * as styles from './ConfigElement.module.css'; + +interface EitherProps+ The playground is an open source project. + If you have any suggestions for features, issues with the + implementation, or just want to read the code for yourself, + you are invited to participate! +
+ ++ This playground is modeled after the original + Rust playground, and we owe a great debt to every contributor to + that project. +
+ ++ This playground was created by Jake Goulding, + part of Integer 32. +
+ +
+
+
+
+
+
+ The playground provides the top 100 most downloaded crates
+ from crates.io, the crates from
+ the Rust Cookbook, and all
+ of their dependencies. To use a crate, add the appropriate
+ {' '}
+ extern crate foo line to the code, or, since
+ {' '}
+ Rust Edition 2018, just
+ {' '}
+ use any item from that crate.
+
+ See the complete list of crates to know + what’s available. +
++ rustfmt is a tool for formatting Rust code + according to the Rust style guidelines. Click on the Format + {' '} + button in the Tools menu to automatically reformat your code. +
+ ++ Clippy is a collection of lints to catch common + mistakes and improve your Rust code. Click on the Clippy + {' '} + button in the Tools menu to see possible improvements to your + code. +
+ ++ Miri is an interpreter for Rust’s mid-level intermediate + representation (MIR) and can be used to detect certain kinds of undefined behavior + in your unsafe Rust code. Click on the Miri button in + the Tools menu to check. +
+ ++ Once you have some code worth saving or sharing, click on the + {' '} + Share button. This will create a + {' '} + GitHub Gist. You will also be provided with + a URL to load that Gist back into the playground. +
+
+ If you have a web page with Rust code that you’d like to
+ show in action, you can link to the playground with the
+ Rust code in the query parameter code. Make sure to
+ escape any special characters. Keep the code short, as URLs have
+ limitations on the maximum length.
+
{linkExample}
+
+ If your code contains the #[test] attribute and does not
+ contain a main method, cargo test will be
+ executed instead of cargo run.
+
+ If your code contains the #![crate_type="lib"] attribute,
+ {' '}
+ cargo build will be executed instead of cargo
+ run.
+
+ Instead of executing the code, you can also see intermediate + output of the compiler as x86_64 assembly, LLVM IR, Rust MIR, or + WebAssembly. This is often used in conjunction with the + {' '} + mode set to “Release” to see how the + compiler has chosen to optimize some specific piece of code. +
+ ++ Rust has two primary compilation modes: Debug and + {' '} + Release. Debug compiles code faster while Release + performs more aggressive optimizations. +
+ ++ You can choose which mode to compile in using the Mode + {' '} + menu. +
++ Rust releases new stable versions every 6 + weeks. Between these stable releases, beta versions of the + next stable release are made available. In addition, builds containing + experimental features are produced nightly. +
+ ++ You can choose which channel to compile with using the + {' '} + Channel menu. +
++ The Ajax.org Cloud9 Editor (Ace) is used to + provide a better interface for editing code. Ace comes with + several keybinding options (such as Emacs and Vim) as well as many + themes. +
+ ++ You may choose to use the Monaco editor instead. + This editor is used in VS Code and may be more familiar to people who + use VS Code. +
+ ++ You may also disable Ace and Monaco completely, falling back to a + simple HTML text area. +
+ ++ These options can be configured via the Config menu. +
++ The most recently entered code will be automatically saved in your browser’s + {' '} + local storage. This allows you to recover + your last work even if you close the browser. +
+ ++ Local storage is a singleton resource, so if you use multiple windows, + only the most recently saved code will be persisted. +
++ To prevent the playground from being used to attack other computers and + to ensure it is available for everyone to use, some limitations + are enforced. +
+ +{children}
+);
+
+export default Help;
diff --git a/anneal/v1/playground/rust-anneal-playground/ui/frontend/HelpExample.module.css b/anneal/v1/playground/rust-anneal-playground/ui/frontend/HelpExample.module.css
new file mode 100644
index 0000000000..b2e573b3d3
--- /dev/null
+++ b/anneal/v1/playground/rust-anneal-playground/ui/frontend/HelpExample.module.css
@@ -0,0 +1,21 @@
+.container {
+ position: relative;
+}
+
+.loadExample {
+ position: absolute;
+ top: 0;
+ right: 0;
+ visibility: hidden;
+ opacity: 0;
+ transition: all 0.5s;
+ cursor: pointer;
+ border: none;
+ border-bottom-left-radius: 0.5em;
+ background: rgb(255 255 255 / 80%);
+}
+
+.container:hover .loadExample {
+ visibility: visible;
+ opacity: 1;
+}
diff --git a/anneal/v1/playground/rust-anneal-playground/ui/frontend/HelpExample.tsx b/anneal/v1/playground/rust-anneal-playground/ui/frontend/HelpExample.tsx
new file mode 100644
index 0000000000..423287440c
--- /dev/null
+++ b/anneal/v1/playground/rust-anneal-playground/ui/frontend/HelpExample.tsx
@@ -0,0 +1,35 @@
+import React, { useCallback } from 'react';
+import root from 'react-shadow';
+
+import Prism from './Prism';
+import * as actions from './actions';
+import { useAppDispatch } from './hooks';
+
+import * as styles from './HelpExample.module.css';
+import prismOverrides from './prismjs-overrides.css';
+import prismTheme from 'prismjs/themes/prism-okaidia.css';
+
+export interface HelpExampleProps {
+ code: string;
+}
+
+const HelpExample: React.FC+ {children} +
+); + +export default MenuAside; diff --git a/anneal/v1/playground/rust-anneal-playground/ui/frontend/MenuGroup.module.css b/anneal/v1/playground/rust-anneal-playground/ui/frontend/MenuGroup.module.css new file mode 100644 index 0000000000..55bbc159da --- /dev/null +++ b/anneal/v1/playground/rust-anneal-playground/ui/frontend/MenuGroup.module.css @@ -0,0 +1,22 @@ +.container { + padding: 0.75em 1em 0; + width: 27em; + line-height: normal; + + &:last-child { + padding-bottom: 0.75em; + } +} + +.title { + margin: 0; + border-bottom: 1px solid var(--header-main-border); + padding-bottom: 10px; + font-weight: 700; + font-size: var(--secondary-font-size); + text-transform: uppercase; +} + +.content { + padding: 1em 0.25em; +} diff --git a/anneal/v1/playground/rust-anneal-playground/ui/frontend/MenuGroup.tsx b/anneal/v1/playground/rust-anneal-playground/ui/frontend/MenuGroup.tsx new file mode 100644 index 0000000000..43394e307d --- /dev/null +++ b/anneal/v1/playground/rust-anneal-playground/ui/frontend/MenuGroup.tsx @@ -0,0 +1,19 @@ +import React from 'react'; + +import * as styles from './MenuGroup.module.css'; + +interface MenuGroupProps { + children: React.ReactNode; + title: string; +} + +const MenuGroup: React.FC+ {children} + + Copied! +
+ ); +}; + +const Links: React.FC = () => { + 'use memo'; + + const codeUrl = useAppSelector(selectors.codeUrlSelector); + const gistUrl = useAppSelector((state) => state.output.gist.url); + const permalink = useAppSelector(selectors.permalinkSelector); + const urloUrl = useAppSelector(selectors.urloUrlSelector); + const textChanged = useAppSelector(selectors.textChangedSinceShareSelector); + + return ( + <> +{children}
+ #[unsafe(no_mangle)] attribute to
+ {'\n'}
+ functions you want to see {name} for. Generic functions
+ {'\n'}
+ only generate {name} when concrete types are provided.
+
+
+ {children}
+
+
+ );
+};
+
+export default Prism;
diff --git a/anneal/v1/playground/rust-anneal-playground/ui/frontend/Router.tsx b/anneal/v1/playground/rust-anneal-playground/ui/frontend/Router.tsx
new file mode 100644
index 0000000000..3d75de197c
--- /dev/null
+++ b/anneal/v1/playground/rust-anneal-playground/ui/frontend/Router.tsx
@@ -0,0 +1,109 @@
+import React from 'react';
+import { Reducer, UnknownAction } from '@reduxjs/toolkit';
+
+import { createBrowserHistory as createHistory, Path, Location } from 'history';
+import { createRouter, PlainOrThunk, RouterObject, StoreArg } from './uss-router';
+import UssRouter from './uss-router/Router';
+
+import qs from 'qs';
+import Route from 'route-parser';
+
+import * as actions from './actions';
+import { State } from './reducers';
+import { Channel, Edition, Mode, Page } from './types';
+
+const homeRoute = new Route('/');
+const helpRoute = new Route('/help');
+
+interface Substate {
+ page: Page;
+ configuration: {
+ channel: Channel;
+ mode: Mode;
+ edition: Edition;
+ };
+ output: {
+ gist: {
+ id?: string;
+ }
+ }
+}
+
+const stateSelector = ({ page, configuration: { channel, mode, edition}, output }: State): Substate => ({
+ page,
+ configuration: {
+ channel,
+ mode,
+ edition,
+ },
+ output: {
+ gist: {
+ id: output.gist.id,
+ },
+ },
+});
+
+const stateToLocation = ({ page, configuration, output }: Substate): Partial(payload: P, sequenceNumber: number) => ({ + payload, + meta: { + websocket: true, + sequenceNumber, + }, +}); + +const sequenceNumberMatches = +
(whenMatch: (state: Draft ) => {
+ const {
+ payload,
+ meta: { sequenceNumber },
+ } = action;
+
+ if (sequenceNumber === state.sequenceNumber) {
+ whenMatch(state, payload);
+ }
+ };
+
+const slice = createSlice({
+ name: 'output/execute',
+ initialState,
+ reducers: {
+ wsExecuteRequest: {
+ reducer: (state, action: WsPayloadAction = PayloadAction<
+ P,
+ T,
+ { sequenceNumber: number }
+>;
+
+export const createWebsocketResponseAction = (type: T) => {
+ function actionCreator(): WsPayloadAction {
+ throw 'Should never be executed by JS';
+ }
+ actionCreator.type = type;
+ actionCreator.match = function (action: unknown): action is WsPayloadAction {
+ return isAction(action) && action.type === type;
+ };
+
+ return actionCreator;
+};
+
+export const createWebsocketResponseSchema = (
+ creator: { type: T },
+ payload: P,
+) =>
+ z.object({
+ type: z.literal(creator.type),
+ payload,
+ meta: z.object({
+ // deliberately omitting `websocket` to avoid sending the server's
+ // responses back to the server infinitely
+ sequenceNumber: z.number(),
+ }),
+ });
+
+export const createWebsocketResponse =