create-middag-ui 0.15.3 → 0.15.4

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/cli.js CHANGED
@@ -32,6 +32,7 @@ import {
32
32
  scaffoldFreeAdapters,
33
33
  scaffoldFreeApp,
34
34
  scaffoldFreeRegister,
35
+ scaffoldProAdapters,
35
36
  scaffoldHostEntry,
36
37
  scaffoldHostThemeCSS,
37
38
  scaffoldHostViteConfig,
@@ -213,9 +214,9 @@ if (isPro) {
213
214
  pro.scaffoldMockEntities(targetDir);
214
215
  pro.scaffoldMockPageContracts(targetDir);
215
216
  pro.scaffoldMockRoutes(targetDir);
216
- // Inertia mock adapters — required by vite.config.ts aliases for dev server.
217
- // Both PRO and FREE need these so @inertiajs/* imports resolve in dev mode.
218
- scaffoldFreeAdapters(targetDir);
217
+ // PRO Inertia adapters — re-export from @middag-io/react/mock so usePage()
218
+ // shares the same React context as MockPageProvider (no context mismatch).
219
+ scaffoldProAdapters(targetDir);
219
220
  success("PRO: using MockProductShell from @middag-io/react/mock");
220
221
  } catch {
221
222
  // npm version — PRO file excluded, fall back to FREE
package/lib/scaffold.js CHANGED
@@ -1131,6 +1131,39 @@ export { router };
1131
1131
  }
1132
1132
  }
1133
1133
 
1134
+ /**
1135
+ * Scaffold PRO adapters: thin re-exports from @middag-io/react/mock.
1136
+ *
1137
+ * PRO uses MockPageProvider from the lib, so usePage() must read from the
1138
+ * same React context. These adapters delegate to the lib mock instead of
1139
+ * defining their own context (which would cause context mismatch).
1140
+ */
1141
+ export function scaffoldProAdapters(targetDir) {
1142
+ ensureDir(join(targetDir, "src", "adapters"));
1143
+
1144
+ const corePath = join(targetDir, "src", "adapters", "inertia-core.ts");
1145
+ if (!skipIfExists(corePath, "src/adapters/inertia-core.ts")) {
1146
+ writeFile(corePath, `/**
1147
+ * Mock @inertiajs/core — PRO re-export from @middag-io/react/mock.
1148
+ * Shares the same navigate function as MockProductShell.
1149
+ */
1150
+ export { router, setMockNavigate } from "@middag-io/react/mock";
1151
+ `, "src/adapters/inertia-core.ts (PRO)");
1152
+ }
1153
+
1154
+ const reactPath = join(targetDir, "src", "adapters", "inertia-react.ts");
1155
+ if (!skipIfExists(reactPath, "src/adapters/inertia-react.ts")) {
1156
+ writeFile(reactPath, `/**
1157
+ * Mock @inertiajs/react — PRO re-export from @middag-io/react/mock.
1158
+ * Shares the same React context as MockPageProvider so usePage()
1159
+ * returns the data set by the mock shell.
1160
+ */
1161
+ export { usePage, Head, Link } from "@middag-io/react/mock";
1162
+ export { router } from "./inertia-core";
1163
+ `, "src/adapters/inertia-react.ts (PRO)");
1164
+ }
1165
+ }
1166
+
1134
1167
  /**
1135
1168
  * Scaffold FREE DevShell: src/shells/DevShell.tsx.
1136
1169
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-middag-ui",
3
- "version": "0.15.3",
3
+ "version": "0.15.4",
4
4
  "type": "module",
5
5
  "description": "Bootstrap a MIDDAG React UI layer in your Moodle or WordPress plugin",
6
6
  "bin": {