feat(sqlrunner): SQL Live Blocks — esecutore SQL client-side per il Volume 3 - #7
Merged
Conversation
…dling
- FontAwesome library.add registrata solo in Root.tsx (era duplicata in MDXComponents)
- Helper clipboard condiviso (clipboard.ts) con errore propagato dal fallback;
usato da Toolbar e da "Spiegamelo facile"
- Editor PyRunner rifattorizzato a forwardRef + useImperativeHandle (via prop
handleRef non standard) + prop opzionale `language` per riuso con altri linguaggi
- coerceBool/coerceNumber estratti in coerce.ts (riusabili)
- PathContext: rimosso clearPath mai usato; fix hydration mismatch (useState
parte da {} come l'HTML server-side, localStorage letto nell'effect)
- remark pyrunner: logica estratta nella factory condivisa remark-live-fence.js
con warning a build time per meta numerici non validi
- plugins/pyrunner: warning se la directory degli esempi non esiste
- smartypants-guard: placeholder U+E000 (Private Use Area) al posto di "·"
- grid.py: bare except → except Exception con motivazione
- Toolbar: prop opzionali showResetDb/onResetDb (per SQLRunner)
- Riformattazione Prettier su file con violazioni pre-esistenti (lint ora verde)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…olume 3 Editor SQL interattivo in stile PyRunner, motore sql.js (SQLite WASM 1.14.1) self-hosted in static/sql-runner/ (no CDN: importScripts nei worker non supporta SRI) ed eseguito in un Web Worker statico. - Fence ```sql live``` via plugins/sqlrunner/remark.js (factory condivisa); meta: dataset, title, readonly, maxLines, maxRows, timeout, stateful, runOnMount, noExplain, explainPrompt - Sicurezza: worker + watchdog sul main thread (timeout → terminate + respawn), PRAGMA hard_heap_limit 64MiB, cap righe/byte applicato nel worker prima del postMessage, celle come text node React (no XSS), zero persistenza - Restore del DB dietro le quinte: snapshot seed (db.export()) per dataset; stateless (default) riapre dal seed a OGNI run → DROP/DELETE sempre ripristinati in modo invisibile; stateful mantiene il DB tra i run con bottone "Reset DB" e notice di ripristino dopo timeout - PRAGMA foreign_keys=ON per-connessione (didattica dei vincoli) - Lazy: worker/wasm/dataset scaricati solo al primo Esegui, zero peso sulle pagine senza SQL (verificato via Network) - Dataset seed biblioteca.sql (autori/libri/prestiti) + pagina di test docs/sqlrunner-test.mdx con 16 casi d'uso, verificati a video in light/dark Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Panoramica
Introduce SQL Live Blocks: blocchi di codice SQL interattivi in stile PyRunner, alimentati da SQLite (sql.js WASM) eseguito in un Web Worker. Progettato per il Volume 3 — Manuale dell'Archivista.
Funzionalità
```sql live** → componenteviaplugins/sqlrunner/remark.js(factory condivisaremark-live-fence.js` con PyRunner)static/sql-runner/(no CDN —importScriptsnei worker non supporta SRI); eseguito in un Web Worker statico dedicatodataset,title,readonly,maxLines,maxRows,timeout,stateful,runOnMount,noExplain,explainPromptdb.export()) per dataset; modalità stateless (default) riapre dal seed a ogniEsegui→ DROP/DELETE/UPDATE sempre ripristinati senza che lo studente se ne accorga; modalitàstatefulmantiene il DB tra i run con bottone "Reset DB" e notice di ripristino dopo timeoutPRAGMA hard_heap_limit 64MiB, cap righe/byte nel worker prima delpostMessage, celle renderizzate come text node React (no XSS), zero persistenza lato clientPRAGMA foreign_keys = ONper-connessione (per la didattica dei vincoli referenziali)Esegui— zero impatto sulle pagine senza SQL (verificato via Network tab)biblioteca.sql(tabelle autori/libri/prestiti con dati di esempio)docs/sqlrunner-test.mdxcon 16 casi d'uso (unlisted: true), verificati a video in light/dark modeRefactor code-health (incluso in questo branch)
Cleanup emersi dalla review, applicati prima del feat:
library.addduplicata rimossa daMDXComponentsclipboard.tscon error propagation; riusato da Toolbar e "Spiegamelo facile"forwardRef + useImperativeHandle; proplanguageopzionale per riuso con SQLRunnercoerce.tscoerceBool/coerceNumberestratti in file condivisoclearPathmai usato; fix hydration mismatch (localStorage letto nell'effect)remark-live-fence.js; warning build-time per meta numerici non validishowResetDb/onResetDbper SQLRunnergrid.pybare except→except ExceptionFile principali
src/theme/SQLRunner/index.tsxsrc/theme/SQLRunner/sqlBridge.tssrc/theme/SQLRunner/Output.tsxsrc/theme/SQLRunner/ResultTable.tsxsrc/theme/SQLRunner/styles.module.cssplugins/sqlrunner/remark.jsplugins/remark-live-fence.jsstatic/sql-runner/static/sql-datasets/archivista/biblioteca.sqldocs/sqlrunner-test.mdxscripts/sync-sql-wasm.mjsTest plan
sqlrunner-test.mdxverificata a video (16 casi d'uso: SELECT, JOIN, errori, restore, stateful, timeout, foreign keys, NULL, multi-statement, maxRows, runOnMount, JSX diretto)npm run build) senza errorinpm run lintverde dopo Prettier🤖 Generated with Claude Code