|
60 | 60 | let defaultTokens; |
61 | 61 | let theme; |
62 | 62 |
|
63 | | - // Get the base URL from the current location (similar to how set-content.ts works) |
| 63 | + // Get the base URL from the current location |
64 | 64 | const baseUrl = window.location.origin; |
65 | 65 |
|
66 | | - console.info(`Attempting to load theme tokens for ${themeName} with palette ${paletteName}`); |
67 | | - console.info(`Base URL: ${baseUrl}`); |
68 | | - console.info(`Current location: ${window.location.href}`); |
69 | | - |
70 | | - // First try the base URL path (matches how set-content.ts imports Ionic) |
| 66 | + // First try the base URL path |
71 | 67 | try { |
72 | | - const importPath = `${baseUrl}/dist/themes/${themeName}/default.tokens.js`; |
73 | | - console.info(`Trying import path: ${importPath}`); |
74 | | - defaultTokens = await import(importPath); |
| 68 | + defaultTokens = await import(`${baseUrl}/dist/themes/${themeName}/default.tokens.js`); |
75 | 69 | theme = defaultTokens.defaultTheme; |
76 | 70 | } catch (baseUrlError) { |
77 | | - console.warn(`Failed to load from ${baseUrl}/dist/themes/${themeName}/default.tokens.js, trying relative paths:`, baseUrlError); |
78 | | - |
79 | | - // Try the relative dist path (matches how test files import Ionic) |
| 71 | + // Try relative dist path |
80 | 72 | try { |
81 | 73 | defaultTokens = await import(`../../../../../dist/themes/${themeName}/default.tokens.js`); |
82 | 74 | theme = defaultTokens.defaultTheme; |
83 | 75 | } catch (relativeDistError) { |
84 | | - console.warn(`Failed to load from ../../../../../dist/themes/${themeName}/default.tokens.js, trying absolute paths:`, relativeDistError); |
85 | | - |
86 | 76 | // Try absolute dist path |
87 | 77 | try { |
88 | 78 | defaultTokens = await import(`/dist/themes/${themeName}/default.tokens.js`); |
89 | 79 | theme = defaultTokens.defaultTheme; |
90 | 80 | } catch (absoluteDistError) { |
91 | | - console.warn(`Failed to load from /dist/themes/${themeName}/default.tokens.js, trying simple relative path:`, absoluteDistError); |
| 81 | + // All import attempts failed |
92 | 82 | } |
93 | 83 | } |
94 | 84 | } |
|
109 | 99 | const themeUtilsPaths = [ |
110 | 100 | `${baseUrl}/dist/themes/utils/theme.js`, |
111 | 101 | '../../../../../dist/themes/utils/theme.js', |
112 | | - '/dist/themes/utils/theme.js', |
113 | | - './themes/utils/theme.js' |
| 102 | + '/dist/themes/utils/theme.js' |
114 | 103 | ]; |
115 | 104 |
|
116 | | - let themeUtilsLoaded = false; |
117 | 105 | for (const path of themeUtilsPaths) { |
118 | 106 | try { |
119 | 107 | const themeModule = await import(path); |
120 | 108 | themeModule.applyGlobalTheme(theme); |
121 | | - themeUtilsLoaded = true; |
122 | 109 | break; |
123 | 110 | } catch (error) { |
124 | 111 | // Continue to next path |
125 | 112 | } |
126 | 113 | } |
127 | | - |
128 | | - if (!themeUtilsLoaded) { |
129 | | - console.warn('Could not reapply theme - theme module not found in any path'); |
130 | | - } |
131 | 114 | } |
132 | | - |
133 | | - console.info(`Loaded ${themeName} theme with palette ${paletteName}:`, theme); |
134 | 115 | } catch (error) { |
135 | 116 | console.warn(`Failed to load theme tokens for ${themeName}:`, error); |
| 117 | + throw new Error(`Could not load theme tokens for ${themeName} from any path`); |
136 | 118 | } |
137 | 119 | } |
138 | 120 |
|
|
0 commit comments