@gxp-dev/tools 2.0.39 → 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.39",
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,55 +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
- resolveId(source) {
215
- // Only handle @layouts/ imports
216
- if (!source.startsWith("@layouts/")) return null;
217
-
218
- const fileName = source.replace("@layouts/", "");
219
- const localFile = path.resolve(layoutsDir, fileName);
220
-
221
- // If the file exists locally, let Vite resolve it normally
222
- if (fs.existsSync(localFile)) return null;
223
-
224
- // Return a virtual module ID for the missing file
225
- return `\0gxp-layout-fallback:${fileName}`;
226
- },
227
- load(id) {
228
- if (!id.startsWith("\0gxp-layout-fallback:")) return null;
229
-
230
- const fileName = id.replace("\0gxp-layout-fallback:", "");
231
- console.log(`⚡ [GxP] Serving fallback for missing layout: ${fileName}`);
232
-
233
- // CSS files get empty content
234
- if (fileName.endsWith(".css")) {
235
- return "/* GxP fallback: no local AdditionalStyling.css */";
236
- }
237
-
238
- // Vue layout components get a passthrough slot wrapper
239
- if (fileName.endsWith(".vue")) {
240
- return `
241
- <template><slot /></template>
242
- <script setup>
243
- defineOptions({ inheritAttrs: false });
244
- defineProps({
245
- usrLang: { type: String, default: "" },
246
- portalSettings: { type: Object, default: () => ({}) },
247
- portalLanguage: { type: Object, default: () => ({}) },
248
- portalNavigation: { type: Array, default: () => ([]) },
249
- portalAssets: { type: Object, default: () => ({}) },
250
- });
251
- </script>`;
252
- }
253
-
254
- return "";
255
- },
256
- };
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
+ }
257
219
 
258
220
  // Determine if HTTPS is enabled
259
221
  const useHttps = getHttpsConfig(env) !== false;
@@ -287,8 +249,6 @@ defineProps({
287
249
  },
288
250
  plugins: [
289
251
  runtimeFilesPlugin,
290
- // Layout fallback must run before vue() to resolve missing @layouts/ imports
291
- layoutFallbackPlugin,
292
252
  // Source tracker must run BEFORE vue() to transform templates before compilation
293
253
  gxpSourceTrackerPlugin(),
294
254
  vue(),
@@ -434,7 +394,7 @@ defineProps({
434
394
  // Client project's source directory
435
395
  "@": path.resolve(process.cwd(), "src"),
436
396
  // Theme layouts in client project
437
- "@layouts": path.resolve(process.cwd(), "theme-layouts"),
397
+ "@layouts": layoutsDir,
438
398
  // GxP Toolkit runtime (PortalContainer, etc.) - from node_modules
439
399
  "@gx-runtime": runtimeDir,
440
400
  // Ensure single Vue and Pinia instances
@@ -146,41 +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
- resolveId(source) {
154
- if (!source.startsWith("@layouts/")) return null;
155
- const fileName = source.replace("@layouts/", "");
156
- const localFile = path.resolve(layoutsDir, fileName);
157
- if (fs.existsSync(localFile)) return null;
158
- return `\0gxp-layout-fallback:${fileName}`;
159
- },
160
- load(id) {
161
- if (!id.startsWith("\0gxp-layout-fallback:")) return null;
162
- const fileName = id.replace("\0gxp-layout-fallback:", "");
163
- console.log(`⚡ [GxP] Serving fallback for missing layout: ${fileName}`);
164
- if (fileName.endsWith(".css")) {
165
- return "/* GxP fallback: no local AdditionalStyling.css */";
166
- }
167
- if (fileName.endsWith(".vue")) {
168
- return `
169
- <template><slot /></template>
170
- <script setup>
171
- defineOptions({ inheritAttrs: false });
172
- defineProps({
173
- usrLang: { type: String, default: "" },
174
- portalSettings: { type: Object, default: () => ({}) },
175
- portalLanguage: { type: Object, default: () => ({}) },
176
- portalNavigation: { type: Array, default: () => ([]) },
177
- portalAssets: { type: Object, default: () => ({}) },
178
- });
179
- </script>`;
180
- }
181
- return "";
182
- },
183
- };
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
+ }
184
160
 
185
161
  // Determine if HTTPS is enabled
186
162
  const useHttps = getHttpsConfig(env) !== false;
@@ -211,8 +187,6 @@ defineProps({
211
187
  ),
212
188
  },
213
189
  plugins: [
214
- // Layout fallback must run before vue() to resolve missing @layouts/ imports
215
- layoutFallbackPlugin,
216
190
  // Source tracker must come before vue() to transform templates before compilation
217
191
  ...(gxpSourceTrackerPlugin ? [gxpSourceTrackerPlugin()] : []),
218
192
  vue(),
@@ -349,7 +323,7 @@ defineProps({
349
323
  // Client project's source directory
350
324
  "@": path.resolve(process.cwd(), "src"),
351
325
  // Theme layouts in client project
352
- "@layouts": path.resolve(process.cwd(), "theme-layouts"),
326
+ "@layouts": layoutsDir,
353
327
  // GxP Toolkit runtime (PortalContainer, etc.) - from node_modules
354
328
  "@gx-runtime": path.resolve(toolkitPath, "runtime"),
355
329
  // Ensure single Vue and Pinia instances