@pradip1995/storefront-registry 1.0.0

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 ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@pradip1995/storefront-registry",
3
+ "version": "1.0.0",
4
+ "description": "Payload-style component registry for Medusa storefront themes",
5
+ "license": "MIT",
6
+ "publishConfig": {
7
+ "access": "public",
8
+ "registry": "https://registry.npmjs.org/"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/SmartByteLabs/medusa-storefront-kit.git",
13
+ "directory": "packages/storefront-registry"
14
+ },
15
+ "sideEffects": false,
16
+ "files": [
17
+ "src"
18
+ ],
19
+ "exports": {
20
+ ".": "./src/index.ts",
21
+ "./storefront.config": "./src/storefront.config.ts",
22
+ "./resolve-component": "./src/resolve-component.ts",
23
+ "./types": "./src/types.ts",
24
+ "./blocks": "./src/blocks/index.ts",
25
+ "./blocks/home": "./src/blocks/home.blocks.ts",
26
+ "./components": "./src/components/index.ts",
27
+ "./components/product-card": "./src/components/product-card.tsx"
28
+ },
29
+ "peerDependencies": {
30
+ "react": ">=19",
31
+ "@pradip1995/commerce-core": "1.0.0"
32
+ },
33
+ "devDependencies": {
34
+ "@types/react": "^19",
35
+ "eslint": "^8.57.0",
36
+ "react": "19.0.3",
37
+ "typescript": "^5.7.2",
38
+ "@pradip1995/commerce-core": "1.0.0"
39
+ },
40
+ "scripts": {
41
+ "typecheck": "tsc --noEmit",
42
+ "lint": "tsc --noEmit"
43
+ }
44
+ }
@@ -0,0 +1,3 @@
1
+ export { storefrontConfig } from "../storefront.config"
2
+
3
+ export type { HomeBlockType } from "../storefront.config"
@@ -0,0 +1 @@
1
+ export * from "./home.blocks"
@@ -0,0 +1,2 @@
1
+ export { default as ProductCard } from "./product-card"
2
+ export type { ProductCardProps, ProductCardRating } from "./product-card"
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Theme-aware ProductCard — stable import for modules and controllers.
3
+ * Implementation: src/theme/<brand>/slots/product/ProductCard/
4
+ * Switch themes via tsconfig @theme path + storefront.config.ts (no import changes).
5
+ */
6
+ export { default } from "@theme/slots/product/ProductCard"
7
+ export type { ProductCardProps, ProductCardRating } from "@core/types/product-card"
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ export { storefrontConfig } from "./storefront.config"
2
+ export type { HomeBlockType } from "./storefront.config"
3
+ export { resolveComponent } from "./resolve-component"
4
+ export type { ComponentPath, BlockConfig, SlotConfig, ResolvedComponent } from "./types"
@@ -0,0 +1,46 @@
1
+ import type { ComponentPath, ResolvedComponent } from "./types"
2
+
3
+ /**
4
+ * Static import map for Next.js bundler compatibility (Payload-style path resolution).
5
+ * Add new theme components here when registering in storefront.config.ts.
6
+ */
7
+ const componentImportMap: Record<ComponentPath, () => Promise<ResolvedComponent>> = {
8
+ "blocks/home/Hero": () => import("@theme/blocks/home/Hero"),
9
+ "blocks/home/ShopByAge": () => import("@theme/blocks/home/ShopByAge"),
10
+ "blocks/home/ShopByCategory": () => import("@theme/blocks/home/ShopByCategory"),
11
+ "blocks/home/WhyChooseUs": () => import("@theme/blocks/home/WhyChooseUs"),
12
+ "blocks/home/NewArrivals": () => import("@theme/blocks/home/NewArrivals"),
13
+ "blocks/home/LovedByMoms": () => import("@theme/blocks/home/LovedByMoms"),
14
+ "blocks/home/Testimonials": () => import("@theme/blocks/home/Testimonials"),
15
+ "blocks/home/Features": () => import("@theme/blocks/home/Features"),
16
+ "slots/layout/Nav": () => import("@theme/slots/layout/Nav"),
17
+ "slots/layout/Footer": () => import("@theme/slots/layout/Footer"),
18
+ "slots/layout/PromoBar": () => import("@theme/slots/layout/PromoBar"),
19
+ "slots/product/ProductCard": () => import("@theme/slots/product/ProductCard"),
20
+ "slots/product/ProductActions": () => import("@theme/slots/product/ProductActions"),
21
+ "slots/product/ProductInfo": () => import("@theme/slots/product/ProductInfo"),
22
+ "slots/cart/CartItem": () =>
23
+ import("@theme/slots/cart/CartItem") as Promise<ResolvedComponent>,
24
+ "slots/cart/CartSummary": () =>
25
+ import("@theme/slots/cart/CartSummary") as Promise<ResolvedComponent>,
26
+ "slots/account/LoginTemplate": () => import("@theme/slots/account/LoginTemplate"),
27
+ "slots/account/Login": () => import("@theme/slots/account/Login"),
28
+ "slots/account/Register": () => import("@theme/slots/account/Register"),
29
+ "slots/account/ForgotPassword": () => import("@theme/slots/account/ForgotPassword"),
30
+ "slots/order/OrderDetails": () => import("@theme/slots/order/OrderDetails"),
31
+ "slots/checkout/CheckoutForm": () => import("@theme/slots/checkout/CheckoutForm"),
32
+ "slots/checkout/CheckoutSummary": () =>
33
+ import("@theme/slots/checkout/CheckoutSummary"),
34
+ }
35
+
36
+ export async function resolveComponent(path: ComponentPath) {
37
+ const loader = componentImportMap[path]
38
+
39
+ if (!loader) {
40
+ throw new Error(
41
+ `Component not found in import map: "${path}". Register it in registry/resolve-component.ts`
42
+ )
43
+ }
44
+
45
+ return loader()
46
+ }
@@ -0,0 +1,49 @@
1
+ export const storefrontConfig = {
2
+ theme: "chocomelon",
3
+ baseDir: "theme/chocomelon",
4
+
5
+ slots: {
6
+ layout: {
7
+ Nav: "slots/layout/Nav",
8
+ Footer: "slots/layout/Footer",
9
+ PromoBar: "slots/layout/PromoBar",
10
+ },
11
+ product: {
12
+ ProductCard: "slots/product/ProductCard",
13
+ ProductActions: "slots/product/ProductActions",
14
+ ProductInfo: "slots/product/ProductInfo",
15
+ },
16
+ cart: {
17
+ CartItem: "slots/cart/CartItem",
18
+ CartSummary: "slots/cart/CartSummary",
19
+ },
20
+ account: {
21
+ LoginTemplate: "slots/account/LoginTemplate",
22
+ Login: "slots/account/Login",
23
+ Register: "slots/account/Register",
24
+ ForgotPassword: "slots/account/ForgotPassword",
25
+ },
26
+ order: {
27
+ OrderDetails: "slots/order/OrderDetails",
28
+ },
29
+ checkout: {
30
+ CheckoutForm: "slots/checkout/CheckoutForm",
31
+ CheckoutSummary: "slots/checkout/CheckoutSummary",
32
+ },
33
+ },
34
+
35
+ blocks: {
36
+ home: [
37
+ { blockType: "hero", component: "blocks/home/Hero" },
38
+ { blockType: "shopByAge", component: "blocks/home/ShopByAge" },
39
+ { blockType: "shopByCategory", component: "blocks/home/ShopByCategory" },
40
+ { blockType: "whyChooseUs", component: "blocks/home/WhyChooseUs" },
41
+ { blockType: "newArrivals", component: "blocks/home/NewArrivals" },
42
+ { blockType: "lovedByMoms", component: "blocks/home/LovedByMoms" },
43
+ { blockType: "testimonials", component: "blocks/home/Testimonials" },
44
+ { blockType: "features", component: "blocks/home/Features" },
45
+ ],
46
+ },
47
+ } as const
48
+
49
+ export type HomeBlockType = (typeof storefrontConfig.blocks.home)[number]["blockType"]
package/src/types.ts ADDED
@@ -0,0 +1,14 @@
1
+ import type { ComponentType } from "react"
2
+
3
+ export type ComponentPath = string
4
+
5
+ export type BlockConfig<T extends string = string> = {
6
+ blockType: T
7
+ component: ComponentPath
8
+ }
9
+
10
+ export type SlotConfig = Record<string, ComponentPath>
11
+
12
+ export type ResolvedComponent = {
13
+ default: ComponentType<Record<string, unknown>>
14
+ }