@@ -74,6 +74,7 @@ import LZString from 'lz-string';
7474import {
7575 PLAYGROUND_PRESETS ,
7676 DEFAULT_PLAYGROUND_CONFIG ,
77+ DEFAULT_INLINE_VARS_CONFIG ,
7778 type PlaygroundConfig
7879} from ' ../presets' ;
7980import PlaygroundToolbar from ' ./PlaygroundToolbar.vue' ;
@@ -113,17 +114,30 @@ const transformedCode = ref<string>('');
113114const copiedLink = ref <boolean >(false );
114115const copiedCode = ref <boolean >(false );
115116
116- const config = ref <PlaygroundConfig >({ ... DEFAULT_PLAYGROUND_CONFIG });
117+ const config = ref <PlaygroundConfig >({
118+ ... DEFAULT_PLAYGROUND_CONFIG ,
119+ inlineVars: { ... DEFAULT_INLINE_VARS_CONFIG }
120+ });
117121
118122const hasCustomConfig = computed <boolean >(() => {
123+ const iv = config .value .inlineVars || DEFAULT_INLINE_VARS_CONFIG ;
124+ const isInlineVarsCustom =
125+ iv .properties !== DEFAULT_INLINE_VARS_CONFIG .properties ||
126+ iv .generics !== DEFAULT_INLINE_VARS_CONFIG .generics ||
127+ iv .callables !== DEFAULT_INLINE_VARS_CONFIG .callables ||
128+ iv .scalars !== DEFAULT_INLINE_VARS_CONFIG .scalars ||
129+ iv .arrays !== DEFAULT_INLINE_VARS_CONFIG .arrays ||
130+ iv .objects !== DEFAULT_INLINE_VARS_CONFIG .objects ;
131+
119132 return (
120133 config .value .enabled !== DEFAULT_PLAYGROUND_CONFIG .enabled ||
121134 config .value .ignoreTraceDepth !== DEFAULT_PLAYGROUND_CONFIG .ignoreTraceDepth ||
122135 config .value .arrayValidation !== DEFAULT_PLAYGROUND_CONFIG .arrayValidation ||
123136 config .value .strictReturnGenericInvariance !== DEFAULT_PLAYGROUND_CONFIG .strictReturnGenericInvariance ||
124137 config .value .respectNativeNullability !== DEFAULT_PLAYGROUND_CONFIG .respectNativeNullability ||
125138 config .value .respectIgnoreTags !== DEFAULT_PLAYGROUND_CONFIG .respectIgnoreTags ||
126- config .value .magicPropertyReads !== DEFAULT_PLAYGROUND_CONFIG .magicPropertyReads
139+ config .value .magicPropertyReads !== DEFAULT_PLAYGROUND_CONFIG .magicPropertyReads ||
140+ isInlineVarsCustom
127141 );
128142});
129143
@@ -140,6 +154,7 @@ function handleWindowResize() {
140154 windowWidth .value = window .innerWidth ;
141155}
142156
157+ // Global shortcut handler (Ctrl+Enter / Cmd+Enter anywhere on page)
143158function handleGlobalKeyDown(e : KeyboardEvent ) {
144159 if ((e .ctrlKey || e .metaKey ) && e .key === ' Enter' ) {
145160 e .preventDefault ();
@@ -182,7 +197,14 @@ onMounted(() => {
182197 if (savedConfig ) {
183198 const parsed = JSON .parse (savedConfig );
184199 if (parsed && typeof parsed === ' object' ) {
185- config .value = { ... DEFAULT_PLAYGROUND_CONFIG , ... parsed };
200+ config .value = {
201+ ... DEFAULT_PLAYGROUND_CONFIG ,
202+ ... parsed ,
203+ inlineVars: {
204+ ... DEFAULT_INLINE_VARS_CONFIG ,
205+ ... (parsed .inlineVars || {})
206+ }
207+ };
186208 }
187209 }
188210 } catch {}
@@ -204,7 +226,14 @@ onMounted(() => {
204226 snippetTitle .value = parsed .title ;
205227 }
206228 if (parsed .config ) {
207- config .value = { ... DEFAULT_PLAYGROUND_CONFIG , ... parsed .config };
229+ config .value = {
230+ ... DEFAULT_PLAYGROUND_CONFIG ,
231+ ... parsed .config ,
232+ inlineVars: {
233+ ... DEFAULT_INLINE_VARS_CONFIG ,
234+ ... (parsed .config .inlineVars || {})
235+ }
236+ };
208237 }
209238 selectedPresetId .value = ' custom' ;
210239 restoredFromHash = true ;
@@ -306,7 +335,10 @@ watch(config, (newConf) => {
306335}, { deep: true });
307336
308337function resetConfig() {
309- config .value = { ... DEFAULT_PLAYGROUND_CONFIG };
338+ config .value = {
339+ ... DEFAULT_PLAYGROUND_CONFIG ,
340+ inlineVars: { ... DEFAULT_INLINE_VARS_CONFIG }
341+ };
310342}
311343
312344function toggleLayoutPosition() {
@@ -354,10 +386,18 @@ function onSelectPreset(presetId: string) {
354386 code .value = matched .code ;
355387 snippetTitle .value = matched .name ;
356388 if (matched .config ) {
357- config .value = { ... DEFAULT_PLAYGROUND_CONFIG , ... matched .config };
389+ config .value = {
390+ ... DEFAULT_PLAYGROUND_CONFIG ,
391+ ... matched .config ,
392+ inlineVars: {
393+ ... DEFAULT_INLINE_VARS_CONFIG ,
394+ ... (matched .config .inlineVars || {})
395+ }
396+ };
358397 }
359398 viewMode .value = ' source' ;
360399
400+ // Clear URL hash when switching to an official preset
361401 if (window .location .hash ) {
362402 history .replaceState (null , ' ' , window .location .pathname + window .location .search );
363403 }
@@ -371,7 +411,7 @@ function onSelectPreset(presetId: string) {
371411
372412function runCode() {
373413 const now = performance .now ();
374- if (now - lastRunTimestamp < 150 ) return ;
414+ if (now - lastRunTimestamp < 150 ) return ; // Debounce rapid key triggers
375415 lastRunTimestamp = now ;
376416
377417 const activeWorker = worker ;
0 commit comments