@@ -30,24 +30,18 @@ import {
3030import { resolveMode , validateCloudOnlyFlags } from '../utils/mode' ;
3131import { resolveViewport } from '../utils/size' ;
3232
33- const DEFAULT_RENDER_WAIT = 3 ;
3433const DEFAULT_TIMEOUT = 600 ;
3534
3635const VALID_PLATFORMS = [ 'win' , 'mac' , 'ios' , 'android' , 'linux' ] as const ;
36+ type CloudPlatform = 'mac' | 'win' ;
3737
3838export interface ConvertOptions {
3939 output ?: string ;
4040 mode : string ;
4141 format : string ;
4242 width ?: string ;
4343 platform ?: string ;
44- renderWait : string ;
45- rebuildSvg ?: boolean ;
46- rebuildChart ?: boolean ;
4744 embedFonts ?: boolean ;
48- mapMotion ?: boolean ;
49- webhook ?: string ;
50- retentionHours ?: string ;
5145 report ?: boolean ;
5246}
5347
@@ -63,45 +57,25 @@ function resolvePlatformOption(platform?: string): PlatformTarget {
6357 return platform as PlatformTarget ;
6458}
6559
66- function parsePositiveInt ( value : string , flag : string ) : number {
67- const n = parseInt ( value , 10 ) ;
68- if ( ! Number . isFinite ( n ) || n < 0 ) {
69- throw new Error ( `Invalid ${ flag } : ${ value } ` ) ;
70- }
71- return n ;
60+ function toCloudPlatform ( platform : PlatformTarget ) : CloudPlatform {
61+ return platform === 'mac' || platform === 'ios' ? 'mac' : 'win' ;
7262}
7363
7464function buildCloudParams (
75- ctx : Context ,
7665 options : ConvertOptions ,
77- platform : PlatformTarget ,
66+ platform : CloudPlatform ,
7867 viewport ?: { width : number ; height : number }
7968) : Record < string , unknown > {
80- const retentionHours = options . retentionHours
81- ? parsePositiveInt ( options . retentionHours , '--retention-hours' )
82- : ctx . config . retentionHours ;
83-
84- if ( retentionHours < 0 || retentionHours > 99 ) {
85- throw new Error ( '--retention-hours must be between 0 and 99' ) ;
86- }
87-
8869 const params : Record < string , unknown > = {
8970 needEmbedFonts : Boolean ( options . embedFonts ) ,
90- renderWait : parsePositiveInt ( options . renderWait , '--render-wait' ) ,
91- rebuildSvg : Boolean ( options . rebuildSvg ) ,
92- rebuildChart : Boolean ( options . rebuildChart ) ,
93- mapMotion : Boolean ( options . mapMotion ) ,
94- webhook : options . webhook ?? ctx . config . get ( 'webhook' ) ,
95- retentionHours,
71+ platform,
9672 } ;
9773
9874 if ( viewport ) {
9975 params . width = viewport . width ;
10076 params . height = viewport . height ;
10177 }
10278
103- params . platform = platform ;
104-
10579 return params ;
10680}
10781
@@ -177,41 +151,33 @@ async function runCloudConvert(
177151
178152 const deck = await ctx . getDeck ( ) ;
179153 const spaceId = ctx . config . get ( 'spaceId' ) ;
180- if ( ! spaceId ) {
181- throw new Error (
182- 'Space ID is missing. Run `deckhtml auth login` first or ensure your API key includes workspace context.'
183- ) ;
184- }
185154
186- const params = buildCloudParams ( ctx , options , platform , viewport ) ;
155+ const params = buildCloudParams ( options , toCloudPlatform ( platform ) , viewport ) ;
187156 const taskName = path . basename ( inputPaths [ 0 ] ! , path . extname ( inputPaths [ 0 ] ! ) ) ;
188157
158+ logVerbose ( ctx . verbose , ctx . quiet , `API base: ${ ctx . config . apiBase } ` ) ;
159+ logVerbose (
160+ ctx . verbose ,
161+ ctx . quiet ,
162+ spaceId ? `Space ID: ${ spaceId } ` : 'Space ID: auto (GET /user/self)'
163+ ) ;
189164 logProgress ( ctx . quiet , `Uploading ${ inputPaths . length } file(s)...` ) ;
190165
191- let task ;
192- if ( format === 'png' ) {
193- task = await deck . convertHtmlToPng ( {
194- spaceId,
195- files : inputPaths ,
196- name : taskName ,
197- params : params as never ,
198- upload : {
199- onProgress : ( p : number ) =>
200- logProgress ( ctx . quiet , `Uploading: ${ ( p * 100 ) . toFixed ( 1 ) } %` ) ,
201- } ,
202- } ) ;
203- } else {
204- task = await deck . convertHtmlToPptx ( {
205- spaceId,
206- files : inputPaths ,
207- name : taskName ,
208- params : params as never ,
209- upload : {
210- onProgress : ( p : number ) =>
211- logProgress ( ctx . quiet , `Uploading: ${ ( p * 100 ) . toFixed ( 1 ) } %` ) ,
212- } ,
213- } ) ;
214- }
166+ const taskInput = {
167+ ...( spaceId ? { spaceId } : { } ) ,
168+ files : inputPaths ,
169+ name : taskName ,
170+ params : params as never ,
171+ upload : {
172+ onProgress : ( p : number ) =>
173+ logProgress ( ctx . quiet , `Uploading: ${ ( p * 100 ) . toFixed ( 1 ) } %` ) ,
174+ } ,
175+ } ;
176+
177+ const task =
178+ format === 'png'
179+ ? await deck . convertHtmlToPng ( taskInput )
180+ : await deck . convertHtmlToPptx ( taskInput ) ;
215181
216182 logProgress ( ctx . quiet , `Task created: ${ task . id } ` ) ;
217183 logProgress ( ctx . quiet , 'Converting...' ) ;
@@ -271,19 +237,9 @@ export function registerConvertCommand(program: Command, ctx: Context): void {
271237 )
272238 . option (
273239 '--platform <platform>' ,
274- 'Target platform for generic font mapping: win, mac, ios, android, linux (default: current OS; script/lang auto-detected from text)'
275- )
276- . option (
277- '--render-wait <seconds>' ,
278- 'Per-page wait before capture (cloud)' ,
279- String ( DEFAULT_RENDER_WAIT )
240+ 'Target platform: local supports win, mac, ios, android, linux; cloud uses mac or win (ios→mac, others→win)'
280241 )
281- . option ( '--rebuild-svg' , 'Rebuild SVG objects (cloud only)' , false )
282- . option ( '--rebuild-chart' , 'Rebuild chart objects (cloud only)' , false )
283242 . option ( '--embed-fonts' , 'Embed fonts (cloud only)' , false )
284- . option ( '--map-motion' , 'Map animations (cloud only)' , false )
285- . option ( '--webhook <url>' , 'Callback URL (cloud)' )
286- . option ( '--retention-hours <n>' , 'Cloud file retention hours (0-99)' )
287243 . option ( '--report' , 'Generate conversion report next to output' , false )
288244 . action ( async ( inputs : string [ ] , options : ConvertOptions ) => {
289245 if ( inputs . length === 0 ) {
@@ -321,10 +277,7 @@ export function registerConvertCommand(program: Command, ctx: Context): void {
321277 ) ;
322278
323279 validateCloudOnlyFlags ( mode , {
324- rebuildSvg : options . rebuildSvg ,
325- rebuildChart : options . rebuildChart ,
326280 embedFonts : options . embedFonts ,
327- mapMotion : options . mapMotion ,
328281 } ) ;
329282
330283 const platform = resolvePlatformOption ( options . platform ) ;
0 commit comments