projectConverterDraftconverter.ts11 matches
1function generateProjectName(): string {
2return `val-project-${Date.now()}-${Math.random().toString(36).substring(2, 7)}`;
3}
45async function convertValToProject(input: string, apiToken: string): Promise<string> {
6try {
7const projectName = generateProjectName();
64}
6566function getUniqueDirectories(files: Array<{ path: string; content: string; type: string }>): string[] {
67const directories = new Set<string>();
6884}
8586function formatFileTree(files: Array<{ path: string; content: string; type: string }>): string {
87const tree: Record<string, any> = {};
88138}
139140async function createDirectory(projectId: string, directoryPath: string, apiToken: string): Promise<void> {
141const encodedPath = encodeURIComponent(directoryPath);
142const response = await fetch(`https://api.val.town/v1/projects/${projectId}/files/${encodedPath}`, {
155}
156157async function createFile(
158projectId: string,
159file: { path: string; content: string; type: string },
185}
186187function processInputToProjectStructure(input: string): {
188files: Array<{ path: string; content: string; type: string }>;
189logs: string[];
201202// Extract the App component
203const appMatch = input.match(/function App\(\) {([\s\S]*?)^}/m);
204const appContent = appMatch ? appMatch[0].trim() : "";
205284import { AppData } from "../../shared/types.ts";
285286function App() {
287const [data, setData] = useState([]);
288const [loading, setLoading] = useState(true);
289290useEffect(() => {
291async function fetchData() {
292try {
293// Example data - replace with your own data source
341const initialData = window.__INITIAL_DATA || {};
342343function renderApp() {
344createRoot(document.getElementById("root")).render(<App {...initialData} />);
345}
4const thisURL = parseProject(import.meta.url).links.self.latest;
56export async function notify(message: string) {
7await email({ subject: message, text: `Email sent from ${thisURL}` });
8}
honoStarterApp.tsx1 match
2import { useState } from "https://esm.sh/react@18.2.0";
34export function App() {
5const [clicked, setClicked] = useState(0);
6return (
37}
3839// Import the converter function dynamically
40const { convertValToProject } = await import("./converter.ts");
41
7const initialData = window.__INITIAL_DATA || {};
89function renderApp() {
10createRoot(document.getElementById("root")).render(<App {...initialData} />);
11}
projectConverterDraftApp.tsx1 match
3import { Todo } from "../../shared/types.ts";
45function App() {
6const [valCode, setValCode] = useState("");
7const [apiToken, setApiToken] = useState("");
1export default function server(request: Request): Response {
2return new Response(
3`<html>
hangman-js-1741727731307hangman.js7 matches
4* @author jelofsson
5**/
6var Hangman = (function () {
7'use strict';
811* @param {string} elId An ID used in this class and when rendering the DOM Elements
12*/
13function Hangman(elId) {
14// DOM is ready
15this.elId = elId;
24* Resets the hangman game
25*/
26Hangman.prototype.reset = function () {
27// Variables
28this.STOPPED = false;
42* @param {char} letter A letter guessed by our enduser
43*/
44Hangman.prototype.guess = function (letter) {
45letter = letter.charAt(0).toUpperCase();
4681* @param {HTML} content
82*/
83Hangman.prototype.showElementByIdWithContent = function (elId, content) {
84if (content !== null) {
85document.getElementById(elId).innerHTML = content;
93* @param {string} elClass DOM class
94*/
95Hangman.prototype.hideElementByClass = function (elClass) {
96var elements = document.getElementsByClassName(elClass), i;
97for (i = 0; i < elements.length; i++) {
103* The word but only with letters the user has guessed so far is visible
104*/
105Hangman.prototype.getGuessedfWord = function () {
106var result = "", i;
107for (i = 0; i < this.WORD.length; i++) {
tank-1741726962046tank.js4 matches
77}
7879function preload() {}
8081function setup(faceCount = 20) {
82createCanvas(windowWidth, windowHeight);
83console.log("setup");
96}
9798function draw() {
99background(0);
100var i;
106}
107108function setFaceCount() {
109faceCount = document.getElementById('faceCount').value;
110console.log(faceCount)
tank-1741726845008tank.js4 matches
77}
7879function preload() {}
8081function setup(faceCount = 20) {
82createCanvas(windowWidth, windowHeight);
83console.log("setup");
96}
9798function draw() {
99background(0);
100var i;
106}
107108function setFaceCount() {
109faceCount = document.getElementById('faceCount').value;
110console.log(faceCount)