create-mercato-app 0.6.4-develop.3938.1.c97dbde799 → 0.6.4-develop.3949.1.adc3d0b3b1

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": "create-mercato-app",
3
- "version": "0.6.4-develop.3938.1.c97dbde799",
3
+ "version": "0.6.4-develop.3949.1.adc3d0b3b1",
4
4
  "type": "module",
5
5
  "description": "Create a new Open Mercato application",
6
6
  "main": "./dist/index.js",
@@ -50,6 +50,12 @@ function parseEnvBooleanToken(value) {
50
50
  return null
51
51
  }
52
52
 
53
+ function parsePositiveIntegerEnv(value) {
54
+ if (typeof value !== 'string') return null
55
+ const parsed = Number.parseInt(value.trim(), 10)
56
+ return Number.isFinite(parsed) && parsed >= 0 ? parsed : null
57
+ }
58
+
53
59
  function resolveAutoSpawnEnabled(env, legacyName, aliasedName) {
54
60
  const legacy = parseEnvBooleanToken(env[legacyName])
55
61
  if (legacy !== null) return legacy
@@ -87,9 +93,11 @@ const splashChildStateFile = process.env.OM_DEV_SPLASH_CHILD_STATE_FILE?.trim()
87
93
  const splashMode = process.env.OM_DEV_SPLASH_MODE?.trim() || 'dev'
88
94
  const setupSplashMode = splashMode === 'setup'
89
95
  const startupSplashPhase = setupSplashMode ? 'Project setup is in progress...' : 'Installation and first compilation is in progress...'
90
- const runtimeProgressTotal = setupSplashMode ? 5 : 4
91
- const runtimeProgressCurrent = setupSplashMode ? 4 : 0
92
- const runtimeReadyProgressCurrent = setupSplashMode ? 5 : 4
96
+ const configuredRuntimeProgressTotal = parsePositiveIntegerEnv(process.env.OM_DEV_SPLASH_STAGE_TOTAL)
97
+ const configuredRuntimeProgressCurrent = parsePositiveIntegerEnv(process.env.OM_DEV_SPLASH_STAGE_CURRENT)
98
+ const runtimeProgressTotal = configuredRuntimeProgressTotal ?? (setupSplashMode ? 5 : 4)
99
+ const runtimeProgressCurrent = configuredRuntimeProgressCurrent ?? (setupSplashMode ? 4 : 0)
100
+ const runtimeReadyProgressCurrent = Math.max(runtimeProgressCurrent, runtimeProgressTotal)
93
101
  const children = new Set()
94
102
  let shuttingDown = false
95
103
  let logsVisible = false
@@ -489,6 +497,7 @@ function spawnMercato(args) {
489
497
  ...process.env,
490
498
  OM_CLI_QUIET: rawPassthrough ? process.env.OM_CLI_QUIET : '1',
491
499
  DOTENV_CONFIG_QUIET: rawPassthrough ? process.env.DOTENV_CONFIG_QUIET : 'true',
500
+ ...(!rawPassthrough ? { OM_DEV_SPLASH_RUNTIME_WRAPPER: '1' } : {}),
492
501
  },
493
502
  ...resolvedSpawn.spawnOptions,
494
503
  })
@@ -1582,6 +1591,35 @@ function classifyServerLine(line) {
1582
1591
  }
1583
1592
  }
1584
1593
 
1594
+ const runtimeRestartMatch = line.match(/^\[server\] Detected (.+?)\. Restarting app runtime\.\.\.$/)
1595
+ if (runtimeRestartMatch) {
1596
+ const reason = runtimeRestartMatch[1]
1597
+ return {
1598
+ type: 'status',
1599
+ message: `🔄 Restarting app runtime: ${reason}`,
1600
+ splashPhase: 'App runtime is restarting',
1601
+ splashDetail: `Reason: ${reason}`,
1602
+ ready: false,
1603
+ activity: `App runtime restart: ${reason}`,
1604
+ progressCurrent: runtimeProgressCurrent,
1605
+ progressLabel: 'Restarting app runtime',
1606
+ }
1607
+ }
1608
+
1609
+ if (line === '[server] Detected corrupted Turbopack dev cache. Clearing .mercato/next/dev and restarting Next.js once...') {
1610
+ const reason = 'corrupted Turbopack dev cache'
1611
+ return {
1612
+ type: 'status',
1613
+ message: `🔄 Restarting Next.js dev server: ${reason}`,
1614
+ splashPhase: 'App runtime is restarting',
1615
+ splashDetail: `Reason: ${reason}`,
1616
+ ready: false,
1617
+ activity: `Next.js restart: ${reason}`,
1618
+ progressCurrent: runtimeProgressCurrent,
1619
+ progressLabel: 'Restarting app runtime',
1620
+ }
1621
+ }
1622
+
1585
1623
  const localMatch = line.match(/^- Local:\s*(.+)$/)
1586
1624
  if (localMatch) {
1587
1625
  return {
@@ -1721,9 +1759,10 @@ async function runClassicRuntime() {
1721
1759
  shutdown(initialGenerateExitCode)
1722
1760
  }
1723
1761
 
1724
- // Default ('in-process'): `mercato server dev` runs the structural
1725
- // regeneration watcher in-process. Set OM_DEV_GENERATE_WATCH_MODE=legacy
1726
- // to fall back to spawning the dedicated sidecar Node process.
1762
+ // Default ('in-process'): `mercato server dev` owns the structural
1763
+ // regeneration watcher in-process, so we no longer spawn the dedicated
1764
+ // sidecar. Saves ~190 MB of resident RSS by collapsing one Node process.
1765
+ // Opt back into the sidecar with OM_DEV_GENERATE_WATCH_MODE=legacy.
1727
1766
  const watchers = []
1728
1767
  if (generateWatchMode === 'legacy') {
1729
1768
  watchers.push(['Generator watch (legacy sidecar)', spawnMercato(['generate', 'watch', '--skip-initial'])])
@@ -1751,6 +1790,11 @@ installLogToggle()
1751
1790
  initializeRuntimeSummary()
1752
1791
  printRuntimePackagesSummary()
1753
1792
 
1793
+ // Default ('in-process'): `mercato server dev` runs the structural
1794
+ // regeneration watcher in-process — see packages/cli/src/lib/in-process-generate-watcher.ts
1795
+ // — so the orchestrator no longer spawns a dedicated `mercato generate watch`
1796
+ // sidecar. Saves ~190 MB of resident RSS by eliminating one Node process.
1797
+ // Set OM_DEV_GENERATE_WATCH_MODE=legacy to opt back into the sidecar.
1754
1798
  const sidecarWatch = generateWatchMode === 'legacy'
1755
1799
  ? startFilteredChild(['generate', 'watch', '--skip-initial'], 'Generator watch (legacy sidecar)', classifyWatchLine)
1756
1800
  : null
@@ -492,7 +492,7 @@ function resolveSplashLocaleConfig() {
492
492
  return splashLocaleConfig
493
493
  }
494
494
 
495
- function buildSplashChildEnv() {
495
+ function buildSplashChildEnv(options = {}) {
496
496
  const childEnv = devLogTeeDisabled
497
497
  ? {}
498
498
  : {
@@ -508,6 +508,8 @@ function buildSplashChildEnv() {
508
508
  ...childEnv,
509
509
  OM_DEV_SPLASH_CHILD_STATE_FILE: splashChildStateFile,
510
510
  OM_DEV_SPLASH_MODE: splashMode,
511
+ ...(Number.isFinite(options.stageCurrent) ? { OM_DEV_SPLASH_STAGE_CURRENT: String(options.stageCurrent) } : {}),
512
+ ...(Number.isFinite(options.stageTotal) ? { OM_DEV_SPLASH_STAGE_TOTAL: String(options.stageTotal) } : {}),
511
513
  }
512
514
  }
513
515
 
@@ -528,8 +530,8 @@ function applyLocalDevBackgroundServiceDefaults(childEnv) {
528
530
  return env
529
531
  }
530
532
 
531
- function buildAppDevEnv() {
532
- return applyLocalDevBackgroundServiceDefaults(buildSplashChildEnv() ?? {})
533
+ function buildAppDevEnv(options = {}) {
534
+ return applyLocalDevBackgroundServiceDefaults(buildSplashChildEnv(options) ?? {})
533
535
  }
534
536
 
535
537
  function launchStandaloneDev(options = {}) {
@@ -566,7 +568,7 @@ function launchStandaloneDev(options = {}) {
566
568
 
567
569
  const app = spawnCommand(process.execPath, runtimeArgs, {
568
570
  stdio: 'inherit',
569
- env: buildAppDevEnv(),
571
+ env: buildAppDevEnv({ stageCurrent, stageTotal }),
570
572
  })
571
573
 
572
574
  app.on('close', (code) => {
@@ -1615,7 +1617,7 @@ function launchMonorepoAppDev() {
1615
1617
  })
1616
1618
  const app = spawnCommand(yarnCommand, appArgs, {
1617
1619
  stdio: 'inherit',
1618
- env: buildAppDevEnv(),
1620
+ env: buildAppDevEnv({ stageCurrent, stageTotal }),
1619
1621
  })
1620
1622
 
1621
1623
  app.on('close', (code, signal) => {
@@ -1,7 +1,6 @@
1
1
  @import "tailwindcss";
2
2
  @import "tw-animate-css";
3
3
  @import "react-big-calendar/lib/css/react-big-calendar.css";
4
- @import "@xyflow/react/dist/style.css";
5
4
  @import "../../.mercato/generated/module-package-sources.css";
6
5
 
7
6
  /*
@@ -1,51 +1,77 @@
1
1
  "use client"
2
2
 
3
3
  import * as React from 'react'
4
- import { injectionWidgetEntries } from '@/.mercato/generated/injection-widgets.generated'
5
- // Side-effect: registers translatable fields for client-side TranslationManager
4
+ // Side-effect imports: these register types/components on import, so they
5
+ // MUST stay top-level to be available during the first paint.
6
6
  import '@/.mercato/generated/translations-fields.generated'
7
- import { injectionTables } from '@/.mercato/generated/injection-tables.generated'
8
- import { enabledModuleIds } from '@/.mercato/generated/enabled-module-ids.generated'
7
+ import '@/.mercato/generated/messages.client.generated'
8
+ import '@/.mercato/generated/payments.client.generated'
9
+
9
10
  import { registerCoreInjectionWidgets, registerCoreInjectionTables, registerEnabledModuleIds } from '@open-mercato/core/modules/widgets/lib/injection'
10
11
  import { registerInjectionWidgets } from '@open-mercato/ui/backend/injection/widgetRegistry'
11
- import { dashboardWidgetEntries } from '@/.mercato/generated/dashboard-widgets.generated'
12
12
  import { registerDashboardWidgets } from '@open-mercato/ui/backend/dashboard/widgetRegistry'
13
- import { notificationHandlerEntries } from '@/.mercato/generated/notification-handlers.generated'
14
13
  import { registerNotificationHandlers } from '@open-mercato/shared/lib/notifications/handler-registry'
15
- // Side-effect: registers translatable fields for client-side TranslationManager
16
- import '@/.mercato/generated/translations-fields.generated'
17
- // Side-effect: configures message UI component and object type registries on the client.
18
- import '@/.mercato/generated/messages.client.generated'
19
- // Side-effect: registers provider-owned payment renderer widgets on the client.
20
- import '@/.mercato/generated/payments.client.generated'
21
14
 
22
15
  let _clientBootstrapped = false
16
+ let _bootstrapPromise: Promise<void> | null = null
23
17
 
24
- function clientBootstrap() {
18
+ async function clientBootstrap(): Promise<void> {
25
19
  if (_clientBootstrapped) return
26
- _clientBootstrapped = true
20
+ if (_bootstrapPromise) return _bootstrapPromise
21
+
22
+ _bootstrapPromise = (async () => {
23
+ try {
24
+ // Defer generated registry barrels to a dynamic import so each barrel
25
+ // becomes its own lazy chunk in Turbopack. Routes that mount this
26
+ // provider but never use injection/dashboard/notification registries
27
+ // still get the chunks compiled, but no longer during initial page
28
+ // parse — the first paint is no longer blocked on registering every
29
+ // module's client widgets.
30
+ const [
31
+ injectionWidgets,
32
+ injectionTables,
33
+ enabledModuleIds,
34
+ dashboardWidgets,
35
+ notificationHandlers,
36
+ ] = await Promise.all([
37
+ import('@/.mercato/generated/injection-widgets.generated'),
38
+ import('@/.mercato/generated/injection-tables.generated'),
39
+ import('@/.mercato/generated/enabled-module-ids.generated'),
40
+ import('@/.mercato/generated/dashboard-widgets.generated'),
41
+ import('@/.mercato/generated/notification-handlers.generated'),
42
+ ])
27
43
 
28
- // Register injection widgets
29
- registerInjectionWidgets(injectionWidgetEntries)
30
- registerCoreInjectionWidgets(injectionWidgetEntries)
31
- registerCoreInjectionTables(injectionTables)
32
- registerEnabledModuleIds(enabledModuleIds)
44
+ registerInjectionWidgets(injectionWidgets.injectionWidgetEntries)
45
+ registerCoreInjectionWidgets(injectionWidgets.injectionWidgetEntries)
46
+ registerCoreInjectionTables(injectionTables.injectionTables)
47
+ registerEnabledModuleIds(enabledModuleIds.enabledModuleIds)
48
+ registerDashboardWidgets(dashboardWidgets.dashboardWidgetEntries)
49
+ registerNotificationHandlers(notificationHandlers.notificationHandlerEntries)
33
50
 
34
- // Register dashboard widgets
35
- registerDashboardWidgets(dashboardWidgetEntries)
51
+ _clientBootstrapped = true
52
+ } catch (err) {
53
+ // A lazy registry chunk failed to load (e.g. a stale chunk after a
54
+ // deploy). Clear the cached promise so the next render retries instead
55
+ // of leaving every client registry empty forever — otherwise dashboard
56
+ // widget cards would wait on registration indefinitely with no error.
57
+ _bootstrapPromise = null
58
+ console.error('[ClientBootstrap] Failed to register client registries; will retry on next render', err)
59
+ }
60
+ })()
36
61
 
37
- // Register notification handlers for client-side reactive effects
38
- registerNotificationHandlers(notificationHandlerEntries)
62
+ return _bootstrapPromise
39
63
  }
40
64
 
41
65
  export function ClientBootstrapProvider({ children }: { children: React.ReactNode }) {
42
66
  React.useEffect(() => {
43
- clientBootstrap()
67
+ void clientBootstrap()
44
68
  }, [])
45
69
 
46
- // Also bootstrap synchronously on first render for SSR hydration
70
+ // Fire-and-forget on the very first client render so any consumer that
71
+ // reads registries during the same paint as this provider mounts still
72
+ // sees them populated by microtask flush. The promise is cached.
47
73
  if (typeof window !== 'undefined' && !_clientBootstrapped) {
48
- clientBootstrap()
74
+ void clientBootstrap()
49
75
  }
50
76
 
51
77
  return <>{children}</>