@@ -481,17 +481,9 @@ function isWorkspaceManifestPreset(rawPreset) {
481481 return documentKind === "workspace-manifest" || schema === "html-js-gaming.project" ;
482482}
483483
484- function normalizeWorkspaceManifestToolKey ( rawKey ) {
485- const normalizedKey = normalizeTextValue ( rawKey ) . toLowerCase ( ) ;
486- if ( ! normalizedKey ) {
487- return "" ;
488- }
489- return normalizedKey ;
490- }
491-
492484function resolveWorkspaceManifestScopedToolPreset ( rawPreset , toolId ) {
493- const normalizedToolId = normalizeTextValue ( toolId ) . toLowerCase ( ) ;
494- if ( ! normalizedToolId ) {
485+ const directToolId = typeof toolId === "string" ? toolId : "" ;
486+ if ( ! directToolId ) {
495487 return null ;
496488 }
497489 const tools = rawPreset . tools && typeof rawPreset . tools === "object" && ! Array . isArray ( rawPreset . tools )
@@ -501,44 +493,33 @@ function resolveWorkspaceManifestScopedToolPreset(rawPreset, toolId) {
501493 return null ;
502494 }
503495
504- const candidateKeys = Object . keys ( tools ) . filter ( ( key ) => normalizeWorkspaceManifestToolKey ( key ) === normalizedToolId ) ;
505- if ( candidateKeys . length === 0 ) {
496+ const scopedPreset = tools [ directToolId ] ;
497+ if ( ! scopedPreset || typeof scopedPreset !== "object" || Array . isArray ( scopedPreset ) ) {
506498 return null ;
507499 }
508500
509- const exactKeyIndex = candidateKeys . findIndex ( ( key ) => normalizeTextValue ( key ) . toLowerCase ( ) === normalizedToolId ) ;
510- const orderedKeys = exactKeyIndex >= 0
511- ? [ candidateKeys [ exactKeyIndex ] , ...candidateKeys . filter ( ( _ , index ) => index !== exactKeyIndex ) ]
512- : candidateKeys ;
513- for ( const key of orderedKeys ) {
514- const scopedPreset = tools [ key ] ;
515- if ( ! scopedPreset || typeof scopedPreset !== "object" || Array . isArray ( scopedPreset ) ) {
516- continue ;
517- }
518- if ( normalizedToolId === "palette-browser" ) {
519- const isDirectPaletteDocument = normalizeTextValue ( scopedPreset . schema ) . toLowerCase ( ) === "html-js-gaming.palette"
520- && Array . isArray ( scopedPreset . swatches ) ;
521- if ( ! isDirectPaletteDocument ) {
522- console . warn ( `[tools.platform] workspace scoped preset rejected: key="${ key } " must be direct palette JSON for palette-browser.` ) ;
523- continue ;
524- }
525- return scopedPreset ;
526- }
527-
528- const payloadToolId = normalizeTextValue ( scopedPreset . tool ) . toLowerCase ( ) ;
529- if ( ! payloadToolId ) {
530- console . warn ( `[tools.platform] workspace scoped preset rejected: key="${ key } " is missing required "tool" field.` ) ;
531- continue ;
532- }
533- if ( payloadToolId !== normalizedToolId ) {
534- console . warn (
535- `[tools.platform] workspace scoped preset rejected: key="${ key } " expected tool="${ normalizedToolId } " but found tool="${ payloadToolId } ".`
536- ) ;
537- continue ;
501+ if ( directToolId === "palette-browser" ) {
502+ const isDirectPaletteDocument = scopedPreset . schema === "html-js-gaming.palette"
503+ && Array . isArray ( scopedPreset . swatches ) ;
504+ if ( ! isDirectPaletteDocument ) {
505+ console . warn ( `[tools.platform] workspace scoped preset rejected: key="${ directToolId } " must be direct palette JSON for palette-browser.` ) ;
506+ return null ;
538507 }
539508 return scopedPreset ;
540509 }
541- return null ;
510+
511+ const payloadToolId = typeof scopedPreset . tool === "string" ? scopedPreset . tool : "" ;
512+ if ( ! payloadToolId ) {
513+ console . warn ( `[tools.platform] workspace scoped preset rejected: key="${ directToolId } " is missing required "tool" field.` ) ;
514+ return null ;
515+ }
516+ if ( payloadToolId !== directToolId ) {
517+ console . warn (
518+ `[tools.platform] workspace scoped preset rejected: key="${ directToolId } " expected tool="${ directToolId } " but found tool="${ payloadToolId } ".`
519+ ) ;
520+ return null ;
521+ }
522+ return scopedPreset ;
542523}
543524
544525function selectWorkspaceScopedToolPreset ( rawPreset , toolId ) {
0 commit comments