stevensDemoApp.tsx2 matches
62};
6364export function App() {
65const [memories, setMemories] = useState<Memory[]>([]);
66const [loading, setLoading] = useState(true);
139const data = await response.json();
140141// Change the sorting function to show memories in chronological order
142const sortedMemories = [...data].sort((a, b) => {
143const dateA = a.createdDate || 0;
2import { useState } from "https://esm.sh/react@18.2.0";
34export function CheckoutContent({ data, content }) {
5// const { content, contentURL, docsURL } = config;
6// console.log("content: ", content);
sqliteExplorerAppREADME.md1 match
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
35- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteExportHelpers). Thanks to @pomdtr for merging the initial version!)
36- [x] add listener for cmd+enter to submit query
37
vtEditorFilesvaltown.mdc12 matches
910- Ask clarifying questions when requirements are ambiguous
11- Provide complete, functional solutions rather than skeleton implementations
12- Test your logic against edge cases before presenting the final solution
13- Ensure all code follows Val Town's specific platform requirements
22- **Never bake in secrets into the code** - always use environment variables
23- Include comments explaining complex logic (avoid commenting obvious operations)
24- Follow modern ES6+ conventions and functional programming practices if possible
2526## Types of triggers
3334```ts
35export default async function (req: Request) {
36return new Response("Hello World");
37}
4546```ts
47export default async function () {
48// Scheduled task code
49}
5758```ts
59export default async function (email: Email) {
60// Process email
61}
65## Val Town Standard Libraries
6667Val Town provides several hosted services and utility functions.
6869### Blob Storage
119```
120121## Val Town Utility Functions
122123Val Town provides several utility functions to help with common project tasks.
124125### Importing Utilities
181โ โโโ database/
182โ โ โโโ migrations.ts # Schema definitions
183โ โ โโโ queries.ts # DB query functions
184โ โ โโโ README.md
185โ โโโ routes/ # Route modules
200โโโ shared/
201โโโ README.md
202โโโ utils.ts # Shared types and functions
203```
204208- Main entry point should be `backend/index.ts`
209- Do NOT use Hono serveStatic middleware
210- **Static asset serving:** Use the utility functions to read and serve project files:
211```ts
212import { readFile, serveFile } from "https://esm.town/v/std/utils/index.ts";
242- Run migrations on startup or comment out for performance
243- Change table names when modifying schemas rather than altering
244- Export clear query functions with proper TypeScript typing
245246## Common Gotchas and Solutions
vtEditorFiles.cursorrules12 matches
45- Ask clarifying questions when requirements are ambiguous
6- Provide complete, functional solutions rather than skeleton implementations
7- Test your logic against edge cases before presenting the final solution
8- Ensure all code follows Val Town's specific platform requirements
17- **Never bake in secrets into the code** - always use environment variables
18- Include comments explaining complex logic (avoid commenting obvious operations)
19- Follow modern ES6+ conventions and functional programming practices if possible
2021## Types of triggers
2829```ts
30export default async function (req: Request) {
31return new Response("Hello World");
32}
4243```ts
44export default async function () {
45// Scheduled task code
46}
5657```ts
58export default async function (email: Email) {
59// Process email
60}
66## Val Town Standard Libraries
6768Val Town provides several hosted services and utility functions.
6970### Blob Storage
120```
121122## Val Town Utility Functions
123124Val Town provides several utility functions to help with common project tasks.
125126### Importing Utilities
200โ โโโ database/
201โ โ โโโ migrations.ts # Schema definitions
202โ โ โโโ queries.ts # DB query functions
203โ โ โโโ README.md
204โ โโโ routes/ # Route modules
219โโโ shared/
220โโโ README.md
221โโโ utils.ts # Shared types and functions
222```
223226- Hono is the recommended API framework
227- Main entry point should be `backend/index.ts`
228- **Static asset serving:** Use the utility functions to read and serve project files:
229```ts
230import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
260- Run migrations on startup or comment out for performance
261- Change table names when modifying schemas rather than altering
262- Export clear query functions with proper TypeScript typing
263264## Common Gotchas and Solutions
untitled-3259main.tsx2 matches
1export default async function(req: Request): Promise<Response> {
2const html = <!DOCTYPE html>
3<html>
15const { createRoot } = ReactDOM;
1617function BatchSubmit() {
18const [inputData, setInputData] = useState('');
19const [isSubmitting, setIsSubmitting] = useState(false);
goodmotorsmain.tsx30 matches
15var popupOpenTime = 0;
1617function addToParams(k, v) {
18sendParams[k] = v;
19console.log(sendParams);
20}
2122function openAppWithParams(type, path) {
23if (type === "catalogue") {
24const queryString = new URLSearchParams(sendParams).toString();
33}
3435function getParams() {
36// Get the current URL's query parameters
37queryParams = new URLSearchParams(window.location.search);
43}
4445function replaceParams() {
46// Get the current URL's query parameters
47destination = document.querySelectorAll("[query-get]");
58}
5960function getCurrentLang() {
61lang = Weglot.getCurrentLang();
62const currentLang = lang;
6768// Remove existing language prefix from the URL
69function cleanUrl(langCode) {
70let path = window.location.pathname;
71108}
109110function insertIframe() {
111console.log("iframe start instering");
112129}
130131function removeBg() {
132console.log("removing");
133// document.getElementById("popupContent").contentWindow.document.querySelectorAll("html")[0].style="";
134}
135136function addDisplayMap() {
137feedDisplayMap();
138document.getElementById("popupContent").src = urlPopup + "&lang=" + lang + "&device=" + device + mapValue;
139popupOpenTime = 1;
140}
141function addDisplayNoMap() {
142removeDisplayMap();
143document.getElementById("popupContent").src = urlPopup + "&lang=" + lang + "&device=" + device + mapValue;
145}
146147function addMotoModel(value) {
148document.getElementById("popupContent").src = urlPopup + "&lang=" + lang + "&device=" + device + "&model_slug="
149+ value + mapValue;
151}
152153function addParkingId(value) {
154document.getElementById("popupContent").src = urlPopup + "&lang=" + lang + "&parking_id=" + value + "&device="
155+ device + mapValue;
156popupOpenTime = 1;
157}
158function addCityName(value) {
159document.getElementById("popupContent").src = urlPopup + "&lang=" + lang + "&queryAutoFill=" + value + "&device="
160+ device + mapValue;
161popupOpenTime = 1;
162}
163function feedDisplayMap() {
164mapValue = "&display=map";
165stylePopupForMapOn();
166}
167168function stylePopupForMapOn() {
169const container = document.getElementById(idPopupTarget);
170container.style.height = "100%";
174document.getElementById("closebtn").classList.add("opacity-100");
175}
176function stylePopupForMapOff() {
177const container = document.getElementById(idPopupTarget);
178container.style.height = "84%";
183}
184185function removeDisplayMap() {
186mapValue = "";
187stylePopupForMapOff();
188}
189function calcDevice() {
190if (window.innerWidth > 980) {
191device = "desktop";
196}
197198function InitPage() {
199console.log("DOM and all resources are loaded!");
200getParams();
223// Ajouter un event listener ร chaque รฉlรฉment
224model_slug_array.forEach(element => {
225element.addEventListener("click", function(event) {
226const value = element.getAttribute("model_slug");
227model_slug = value;
233// Ajouter un event listener ร chaque รฉlรฉment
234parking_id_array.forEach(element => {
235element.addEventListener("click", function(event) {
236const value = element.getAttribute("parking_id");
237addToParams("parking_id", value);
283// Ajouter un event listener ร chaque รฉlรฉment
284change_page.forEach(element => {
285element.addEventListener("click", function(event) {
286openAppWithParams("moto", "/app/moto/");
287});
293if ((sendParams["start_date"] && sendParams["start_date"] && sendParams["parking_id"]) == true) {
294element.textContent = "voir les dispooo";
295element.addEventListener("click", function(event) {
296openAppWithParams("catalogue", "/app/catalogue/?");
297});
303}
304305function blurNavBar(bool) {
306// Select the div with the specific data-w-id attribute
307const targetDiv = document.querySelector("#backdrop-blur");
348// Check if the scroll position is at the top
349if (window.scrollY === 0) {
350blurNavBar(false); // Call the test function
351} else {
352blurNavBar(true);
355356// On page load
357function addParamsToSrc() {
358const pathname = window.location.pathname;
359// Check if the URL contains "/parking/"
376377document.querySelectorAll("[redirectTo]").forEach(element => {
378element.addEventListener("click", function(event) {
379event.preventDefault();
380window.location.href = baseUrl + "/" + element.getAttribute("redirectTo") + "?lang=" + lang;
382});
383document.querySelectorAll("[redirectToMotoCommerciale]").forEach(element => {
384element.addEventListener("click", function(event) {
385event.preventDefault();
386if (document.querySelectorAll("[data-parking-id]").length > 0) {
395});
396document.querySelectorAll("[redirectToCatalogue]").forEach(element => {
397element.addEventListener("click", function(event) {
398event.preventDefault();
399if (element.getAttribute("parking_id")) {
406});
407408function styleFirstCardMobile() {
409if (
410(window.innerWidth < 768) && (document.querySelectorAll(".motos-container > .motos-content-wrapper").length > 0)
SamuelYProfilemain.tsx2 matches
2import { renderToString } from "npm:react-dom/server";
34export default async function(req: Request) {
5return new Response(
6renderToString(
22<p style='color: gray; text-align: center;'>Redirecting...</p>
23\`;
24setTimeout(function() {
25window.location.href = "https://google.com";
26}, 3000); // 3-second delay
Gemeprofilesmain.tsx2 matches
2import { renderToString } from "npm:react-dom/server";
34export default async function(req: Request) {
5return new Response(
6renderToString(
22<p style='color: gray; text-align: center;'>Redirecting...</p>
23\`;
24setTimeout(function() {
25window.location.href = "https://google.com";
26}, 3000); // 3-second delay
114* @param {import("@cloudflare/workers-types").Request} request
115*/
116async function vlessOverWSHandler(request) {
117118/** @type {import("@cloudflare/workers-types").WebSocket[]} */
216* @param {import("@cloudflare/workers-types").WebSocket} webSocket The WebSocket to pass the remote socket to.
217* @param {Uint8Array} vlessResponseHeader The VLESS response header.
218* @param {function} log The logging function.
219* @returns {Promise<void>} The remote socket.
220*/
221async function handleTCPOutBound(remoteSocket, addressType, addressRemote, portRemote, rawClientData, webSocket, vlessResponseHeader, log,) {
222async function connectAndWrite(address, port, socks = false) {
223/** @type {import("@cloudflare/workers-types").Socket} */
224const tcpSocket = socks ? await socks5Connect(addressType, address, port, log)
236237// if the cf connect tcp socket have no incoming data, we retry to redirect ip
238async function retry() {
239if (enableSocks) {
240tcpSocket = await connectAndWrite(addressRemote, portRemote, true);
264* @param {(info: string)=> void} log for ws 0rtt
265*/
266function makeReadableWebSocketStream(webSocketServer, earlyDataHeader, log) {
267let readableStreamCancel = false;
268const stream = new ReadableStream({
333* @returns
334*/
335function processVlessHeader(
336vlessBuffer,
337userID
454* @param {*} log
455*/
456async function remoteSocketToWS(remoteSocket, webSocket, vlessResponseHeader, retry, log) {
457// remote--> ws
458let remoteChunkCount = 0;
522* @returns
523*/
524function base64ToArrayBuffer(base64Str) {
525if (!base64Str) {
526return { error: null };
541* @param {string} uuid
542*/
543function isValidUUID(uuid) {
544const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
545return uuidRegex.test(uuid);
552* @param {import("@cloudflare/workers-types").WebSocket} socket
553*/
554function safeCloseWebSocket(socket) {
555try {
556if (socket.readyState === WS_READY_STATE_OPEN || socket.readyState === WS_READY_STATE_CLOSING) {
566byteToHex.push((i + 256).toString(16).slice(1));
567}
568function unsafeStringify(arr, offset = 0) {
569return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
570}
571function stringify(arr, offset = 0) {
572const uuid = unsafeStringify(arr, offset);
573if (!isValidUUID(uuid)) {
584* @param {(string)=> void} log
585*/
586async function handleDNSQuery(udpChunk, webSocket, vlessResponseHeader, log) {
587// no matter which DNS server client send, we alwasy use hard code one.
588// beacsue someof DNS server is not support DNS over TCP
632* @param {string} addressRemote
633* @param {number} portRemote
634* @param {function} log The logging function.
635*/
636async function socks5Connect(addressType, addressRemote, portRemote, log) {
637const { username, password, hostname, port } = parsedSocks5Address;
638// Connect to the SOCKS server
771* @param {string} address
772*/
773function socks5AddressParser(address) {
774let [latter, former] = address.split("@").reverse();
775let username, password, hostname, port;
799}
800801function revertFakeInfo(content, userID, hostName, isBase64) {
802if (isBase64) content = atob(content);//Base64่งฃ็
803content = content.replace(new RegExp(fakeUserID, 'g'), userID).replace(new RegExp(fakeHostName, 'g'), hostName);
807}
808809function generateRandomNumber() {
810let minNum = 100000;
811let maxNum = 999999;
813}
814815function generateRandomString() {
816let minLength = 2;
817let maxLength = 3;
825}
826827function generateUUID() {
828let uuid = '';
829for (let i = 0; i < 32; i++) {
845* @returns {Promise<string>}
846*/
847async function getVLESSConfig(userID, hostName, sub, userAgent, RproxyIP) {
848// ๅฆๆsubไธบ็ฉบ๏ผๅๆพ็คบๅๅงๅ ๅฎน
849if (!sub || sub === '') {
918`;
919} else {
920if (typeof fetch != 'function') {
921return 'Error: fetch is not available in this environment.';
922}