@@ -18,6 +18,10 @@ interface StackBlitzProject {
1818 } >
1919}
2020
21+ interface StackBlitzProjectResponse {
22+ project : StackBlitzProject
23+ }
24+
2125async function createZip ( options : Omit < DownloadOptions , 'outputPath' > ) : Promise < JSZip > {
2226 const {
2327 projectId,
@@ -31,7 +35,7 @@ async function createZip(options: Omit<DownloadOptions, 'outputPath'>): Promise<
3135 throw new Error ( 'Invalid project ID: must contain only alphanumeric characters, hyphens, and underscores' )
3236 }
3337
34- const url = `https://stackblitz.com/edit/ ${ projectId } `
38+ const url = `https://stackblitz.com/api/projects/ ${ projectId } ?include_files=true `
3539 if ( verbose ) {
3640 // eslint-disable-next-line no-console
3741 console . log ( `Fetching project: ${ url } ` )
@@ -48,18 +52,7 @@ async function createZip(options: Omit<DownloadOptions, 'outputPath'>): Promise<
4852 throw new Error ( `Failed to fetch project: ${ response . statusText } ` )
4953 }
5054
51- const html = await response . text ( )
52-
53- // Extract project data from the Redux store
54- const scriptMatch = html . match ( / < s c r i p t t y p e = " a p p l i c a t i o n \/ j s o n " d a t a - r e d u x - s t o r e = " " > ( [ \s \S ] * ?) < \/ s c r i p t > / )
55-
56- if ( ! scriptMatch || ! scriptMatch [ 1 ] ) {
57- throw new Error ( 'Could not find project data in page' )
58- }
59-
60- // Parse the JSON data
61- const reduxStore = JSON . parse ( scriptMatch [ 1 ] )
62- const projectData = reduxStore ?. project as StackBlitzProject | undefined
55+ const { project : projectData } = await response . json ( ) as StackBlitzProjectResponse
6356
6457 if ( ! projectData || ! projectData . appFiles ) {
6558 throw new Error ( 'No files found in project data' )
0 commit comments