create-mercato-app 0.6.4-develop.3944.1.4100aa7fbe → 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.3944.1.4100aa7fbe",
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",
@@ -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}</>