@gxp-dev/tools 2.0.40 → 2.0.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gxp-dev/tools",
3
- "version": "2.0.40",
3
+ "version": "2.0.41",
4
4
  "description": "Dev tools to create platform plugins",
5
5
  "type": "commonjs",
6
6
  "publishConfig": {
@@ -0,0 +1 @@
1
+ /* GxP Fallback: No project-level AdditionalStyling.css found */
@@ -0,0 +1,14 @@
1
+ <template>
2
+ <slot />
3
+ </template>
4
+
5
+ <script setup>
6
+ defineOptions({ inheritAttrs: false });
7
+ defineProps({
8
+ usrLang: { type: String, default: "" },
9
+ portalSettings: { type: Object, default: () => ({}) },
10
+ portalLanguage: { type: Object, default: () => ({}) },
11
+ portalNavigation: { type: Array, default: () => [] },
12
+ portalAssets: { type: Object, default: () => ({}) },
13
+ });
14
+ </script>
@@ -0,0 +1,14 @@
1
+ <template>
2
+ <slot />
3
+ </template>
4
+
5
+ <script setup>
6
+ defineOptions({ inheritAttrs: false });
7
+ defineProps({
8
+ usrLang: { type: String, default: "" },
9
+ portalSettings: { type: Object, default: () => ({}) },
10
+ portalLanguage: { type: Object, default: () => ({}) },
11
+ portalNavigation: { type: Array, default: () => [] },
12
+ portalAssets: { type: Object, default: () => ({}) },
13
+ });
14
+ </script>
@@ -0,0 +1,14 @@
1
+ <template>
2
+ <slot />
3
+ </template>
4
+
5
+ <script setup>
6
+ defineOptions({ inheritAttrs: false });
7
+ defineProps({
8
+ usrLang: { type: String, default: "" },
9
+ portalSettings: { type: Object, default: () => ({}) },
10
+ portalLanguage: { type: Object, default: () => ({}) },
11
+ portalNavigation: { type: Array, default: () => [] },
12
+ portalAssets: { type: Object, default: () => ({}) },
13
+ });
14
+ </script>
@@ -205,61 +205,17 @@ export default defineConfig(({ mode }) => {
205
205
  },
206
206
  };
207
207
 
208
- // Fallback plugin for missing @layouts files
209
- // When a project doesn't have theme-layouts/, serve minimal fallbacks
210
- // so PortalContainer.vue imports don't break
211
- const layoutsDir = path.resolve(process.cwd(), "theme-layouts");
212
- const layoutFallbackPlugin = {
213
- name: "gxp-layout-fallback",
214
- enforce: "pre",
215
- resolveId(source) {
216
- // Handle @layouts/ alias imports
217
- if (source.startsWith("@layouts/")) {
218
- const fileName = source.replace("@layouts/", "");
219
- const localFile = path.resolve(layoutsDir, fileName);
220
- if (fs.existsSync(localFile)) return null;
221
- return `\0gxp-layout-fallback:${fileName}`;
222
- }
223
-
224
- // Handle already-resolved absolute paths to theme-layouts/
225
- if (source.startsWith(layoutsDir + "/")) {
226
- if (fs.existsSync(source)) return null;
227
- const fileName = source.replace(layoutsDir + "/", "");
228
- return `\0gxp-layout-fallback:${fileName}`;
229
- }
230
-
231
- return null;
232
- },
233
- load(id) {
234
- if (!id.startsWith("\0gxp-layout-fallback:")) return null;
235
-
236
- const fileName = id.replace("\0gxp-layout-fallback:", "");
237
- console.log(`⚡ [GxP] Serving fallback for missing layout: ${fileName}`);
238
-
239
- // CSS files get empty content
240
- if (fileName.endsWith(".css")) {
241
- return "/* GxP fallback: no local AdditionalStyling.css */";
242
- }
243
-
244
- // Vue layout components get a passthrough slot wrapper
245
- if (fileName.endsWith(".vue")) {
246
- return `
247
- <template><slot /></template>
248
- <script setup>
249
- defineOptions({ inheritAttrs: false });
250
- defineProps({
251
- usrLang: { type: String, default: "" },
252
- portalSettings: { type: Object, default: () => ({}) },
253
- portalLanguage: { type: Object, default: () => ({}) },
254
- portalNavigation: { type: Array, default: () => ([]) },
255
- portalAssets: { type: Object, default: () => ({}) },
256
- });
257
- </script>`;
258
- }
259
-
260
- return "";
261
- },
262
- };
208
+ // Resolve @layouts: use project's theme-layouts/ if it exists,
209
+ // otherwise fall back to toolkit's runtime/fallback-layouts/
210
+ const projectLayoutsDir = path.resolve(process.cwd(), "theme-layouts");
211
+ const fallbackLayoutsDir = path.resolve(runtimeDir, "fallback-layouts");
212
+ const layoutsDir = fs.existsSync(projectLayoutsDir) ? projectLayoutsDir : fallbackLayoutsDir;
213
+
214
+ if (layoutsDir === fallbackLayoutsDir) {
215
+ console.log("📐 Layouts: using toolkit fallbacks (no theme-layouts/ directory)");
216
+ } else {
217
+ console.log("📐 Layouts: using project theme-layouts/");
218
+ }
263
219
 
264
220
  // Determine if HTTPS is enabled
265
221
  const useHttps = getHttpsConfig(env) !== false;
@@ -293,8 +249,6 @@ defineProps({
293
249
  },
294
250
  plugins: [
295
251
  runtimeFilesPlugin,
296
- // Layout fallback must run before vue() to resolve missing @layouts/ imports
297
- layoutFallbackPlugin,
298
252
  // Source tracker must run BEFORE vue() to transform templates before compilation
299
253
  gxpSourceTrackerPlugin(),
300
254
  vue(),
@@ -440,7 +394,7 @@ defineProps({
440
394
  // Client project's source directory
441
395
  "@": path.resolve(process.cwd(), "src"),
442
396
  // Theme layouts in client project
443
- "@layouts": path.resolve(process.cwd(), "theme-layouts"),
397
+ "@layouts": layoutsDir,
444
398
  // GxP Toolkit runtime (PortalContainer, etc.) - from node_modules
445
399
  "@gx-runtime": runtimeDir,
446
400
  // Ensure single Vue and Pinia instances
@@ -146,49 +146,17 @@ export default defineConfig(({ mode }) => {
146
146
  // Find the toolkit path for runtime imports
147
147
  const toolkitPath = findToolkitPath();
148
148
 
149
- // Fallback plugin for missing @layouts files
150
- const layoutsDir = path.resolve(process.cwd(), "theme-layouts");
151
- const layoutFallbackPlugin = {
152
- name: "gxp-layout-fallback",
153
- enforce: "pre",
154
- resolveId(source) {
155
- if (source.startsWith("@layouts/")) {
156
- const fileName = source.replace("@layouts/", "");
157
- const localFile = path.resolve(layoutsDir, fileName);
158
- if (fs.existsSync(localFile)) return null;
159
- return `\0gxp-layout-fallback:${fileName}`;
160
- }
161
- if (source.startsWith(layoutsDir + "/")) {
162
- if (fs.existsSync(source)) return null;
163
- const fileName = source.replace(layoutsDir + "/", "");
164
- return `\0gxp-layout-fallback:${fileName}`;
165
- }
166
- return null;
167
- },
168
- load(id) {
169
- if (!id.startsWith("\0gxp-layout-fallback:")) return null;
170
- const fileName = id.replace("\0gxp-layout-fallback:", "");
171
- console.log(`⚡ [GxP] Serving fallback for missing layout: ${fileName}`);
172
- if (fileName.endsWith(".css")) {
173
- return "/* GxP fallback: no local AdditionalStyling.css */";
174
- }
175
- if (fileName.endsWith(".vue")) {
176
- return `
177
- <template><slot /></template>
178
- <script setup>
179
- defineOptions({ inheritAttrs: false });
180
- defineProps({
181
- usrLang: { type: String, default: "" },
182
- portalSettings: { type: Object, default: () => ({}) },
183
- portalLanguage: { type: Object, default: () => ({}) },
184
- portalNavigation: { type: Array, default: () => ([]) },
185
- portalAssets: { type: Object, default: () => ({}) },
186
- });
187
- </script>`;
188
- }
189
- return "";
190
- },
191
- };
149
+ // Resolve @layouts: use project's theme-layouts/ if it exists,
150
+ // otherwise fall back to toolkit's runtime/fallback-layouts/
151
+ const projectLayoutsDir = path.resolve(process.cwd(), "theme-layouts");
152
+ const fallbackLayoutsDir = path.resolve(toolkitPath, "runtime", "fallback-layouts");
153
+ const layoutsDir = fs.existsSync(projectLayoutsDir) ? projectLayoutsDir : fallbackLayoutsDir;
154
+
155
+ if (layoutsDir === fallbackLayoutsDir) {
156
+ console.log("📐 Layouts: using toolkit fallbacks (no theme-layouts/ directory)");
157
+ } else {
158
+ console.log("📐 Layouts: using project theme-layouts/");
159
+ }
192
160
 
193
161
  // Determine if HTTPS is enabled
194
162
  const useHttps = getHttpsConfig(env) !== false;
@@ -219,8 +187,6 @@ defineProps({
219
187
  ),
220
188
  },
221
189
  plugins: [
222
- // Layout fallback must run before vue() to resolve missing @layouts/ imports
223
- layoutFallbackPlugin,
224
190
  // Source tracker must come before vue() to transform templates before compilation
225
191
  ...(gxpSourceTrackerPlugin ? [gxpSourceTrackerPlugin()] : []),
226
192
  vue(),
@@ -357,7 +323,7 @@ defineProps({
357
323
  // Client project's source directory
358
324
  "@": path.resolve(process.cwd(), "src"),
359
325
  // Theme layouts in client project
360
- "@layouts": path.resolve(process.cwd(), "theme-layouts"),
326
+ "@layouts": layoutsDir,
361
327
  // GxP Toolkit runtime (PortalContainer, etc.) - from node_modules
362
328
  "@gx-runtime": path.resolve(toolkitPath, "runtime"),
363
329
  // Ensure single Vue and Pinia instances