akhaliq HF Staff commited on
Commit
6e5566d
·
1 Parent(s): 180e81b

update svelte

Browse files
Files changed (1) hide show
  1. app.py +36 -4
app.py CHANGED
@@ -339,9 +339,23 @@ SVELTE_SYSTEM_PROMPT = """You are an expert Svelte developer creating a modern S
339
 
340
  File selection policy (dynamic, model-decided):
341
  - Generate ONLY the files actually needed for the user's request.
342
- - MUST include src/App.svelte (entry component). Usually include src/app.css for global styles.
 
343
  - Add additional files when needed, e.g. src/lib/*.svelte, src/components/*.svelte, src/stores/*.ts, static/* assets, etc.
344
- - Base template files (package.json, vite.config.ts, tsconfig, svelte.config.js, src/main.ts, src/vite-env.d.ts) are provided by the template and should NOT be generated unless explicitly requested by the user.
 
 
 
 
 
 
 
 
 
 
 
 
 
345
 
346
  Output format (CRITICAL):
347
  - Return ONLY a series of file sections, each starting with a filename line:
@@ -373,9 +387,23 @@ SVELTE_SYSTEM_PROMPT_WITH_SEARCH = """You are an expert Svelte developer. You ha
373
 
374
  File selection policy (dynamic, model-decided):
375
  - Generate ONLY the files actually needed for the user's request.
376
- - MUST include src/App.svelte (entry component). Usually include src/app.css for global styles.
 
377
  - Add additional files when needed, e.g. src/lib/*.svelte, src/components/*.svelte, src/stores/*.ts, static/* assets, etc.
378
- - Base template files (package.json, vite.config.ts, tsconfig, svelte.config.js, src/main.ts, src/vite-env.d.ts) are provided by the template and should NOT be generated unless explicitly requested by the user.
 
 
 
 
 
 
 
 
 
 
 
 
 
379
 
380
  Output format (CRITICAL):
381
  - Return ONLY a series of file sections, each starting with a filename line:
@@ -7703,6 +7731,10 @@ with gr.Blocks(
7703
  if not isinstance(files, dict) or 'src/App.svelte' not in files or not files['src/App.svelte'].strip():
7704
  return gr.update(value="Error: Could not parse Svelte output (missing src/App.svelte). Please regenerate the code.", visible=True)
7705
 
 
 
 
 
7706
  # Ensure package.json includes any external npm deps used; overwrite template's package.json
7707
  try:
7708
  detected = infer_svelte_dependencies(files)
 
339
 
340
  File selection policy (dynamic, model-decided):
341
  - Generate ONLY the files actually needed for the user's request.
342
+ - MUST include src/App.svelte (entry component) and src/main.ts (entry point).
343
+ - Usually include src/app.css for global styles.
344
  - Add additional files when needed, e.g. src/lib/*.svelte, src/components/*.svelte, src/stores/*.ts, static/* assets, etc.
345
+ - Other base template files (package.json, vite.config.ts, tsconfig, svelte.config.js, src/vite-env.d.ts) are provided by the template and should NOT be generated unless explicitly requested by the user.
346
+
347
+ CRITICAL: Always generate src/main.ts with correct Svelte 5 syntax:
348
+ ```typescript
349
+ import './app.css'
350
+ import App from './App.svelte'
351
+
352
+ const app = new App({
353
+ target: document.getElementById('app')!,
354
+ })
355
+
356
+ export default app
357
+ ```
358
+ Do NOT use the old mount syntax: `import { mount } from 'svelte'` - this will cause build errors.
359
 
360
  Output format (CRITICAL):
361
  - Return ONLY a series of file sections, each starting with a filename line:
 
387
 
388
  File selection policy (dynamic, model-decided):
389
  - Generate ONLY the files actually needed for the user's request.
390
+ - MUST include src/App.svelte (entry component) and src/main.ts (entry point).
391
+ - Usually include src/app.css for global styles.
392
  - Add additional files when needed, e.g. src/lib/*.svelte, src/components/*.svelte, src/stores/*.ts, static/* assets, etc.
393
+ - Other base template files (package.json, vite.config.ts, tsconfig, svelte.config.js, src/vite-env.d.ts) are provided by the template and should NOT be generated unless explicitly requested by the user.
394
+
395
+ CRITICAL: Always generate src/main.ts with correct Svelte 5 syntax:
396
+ ```typescript
397
+ import './app.css'
398
+ import App from './App.svelte'
399
+
400
+ const app = new App({
401
+ target: document.getElementById('app')!,
402
+ })
403
+
404
+ export default app
405
+ ```
406
+ Do NOT use the old mount syntax: `import { mount } from 'svelte'` - this will cause build errors.
407
 
408
  Output format (CRITICAL):
409
  - Return ONLY a series of file sections, each starting with a filename line:
 
7731
  if not isinstance(files, dict) or 'src/App.svelte' not in files or not files['src/App.svelte'].strip():
7732
  return gr.update(value="Error: Could not parse Svelte output (missing src/App.svelte). Please regenerate the code.", visible=True)
7733
 
7734
+ # Validate that src/main.ts is generated (should be required now)
7735
+ if 'src/main.ts' not in files:
7736
+ return gr.update(value="Error: Missing src/main.ts file. Please regenerate the code to include the main entry point.", visible=True)
7737
+
7738
  # Ensure package.json includes any external npm deps used; overwrite template's package.json
7739
  try:
7740
  detected = infer_svelte_dependencies(files)