@salla.sa/twilight-theme-engine 1.0.35 → 1.0.37
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/dist/{AddToCartForm-PNZBIPJU.js → AddToCartForm-BAXWUVBW.js} +3 -3
- package/dist/{AddToCartForm-PNZBIPJU.js.map → AddToCartForm-BAXWUVBW.js.map} +1 -1
- package/dist/{BlogAuthorPage-FTVPPHHS.js → BlogAuthorPage-C7ENIUKC.js} +16 -15
- package/dist/BlogAuthorPage-C7ENIUKC.js.map +1 -0
- package/dist/{BlogCategoryPage-TJFW7DDI.js → BlogCategoryPage-QODJTKFE.js} +16 -15
- package/dist/BlogCategoryPage-QODJTKFE.js.map +1 -0
- package/dist/{BlogPage-RD4JUGKY.js → BlogPage-N5BKRIWD.js} +14 -13
- package/dist/BlogPage-N5BKRIWD.js.map +1 -0
- package/dist/{BlogSinglePage-DVZX3WVW.js → BlogSinglePage-HVSCXCCV.js} +14 -13
- package/dist/BlogSinglePage-HVSCXCCV.js.map +1 -0
- package/dist/{BlogTagPage-UON2ASKW.js → BlogTagPage-YXYYHD5S.js} +16 -15
- package/dist/BlogTagPage-YXYYHD5S.js.map +1 -0
- package/dist/{BrandsPage-R4KTDEG3.js → BrandsPage-UP3HKHGR.js} +14 -13
- package/dist/BrandsPage-UP3HKHGR.js.map +1 -0
- package/dist/{Breadcrumb-YNVX6ZXO.js → Breadcrumb-5464BOGG.js} +14 -13
- package/dist/Breadcrumb-5464BOGG.js.map +1 -0
- package/dist/{CartItem-6P4AB6LQ.js → CartItem-TARZW35A.js} +14 -13
- package/dist/CartItem-TARZW35A.js.map +1 -0
- package/dist/{CartSummary-A25PNJSY.js → CartSummary-2KSBKQM7.js} +14 -13
- package/dist/CartSummary-2KSBKQM7.js.map +1 -0
- package/dist/{Copyright-J6O4JUG7.js → Copyright-2D7W6OS4.js} +3 -3
- package/dist/{Copyright-J6O4JUG7.js.map → Copyright-2D7W6OS4.js.map} +1 -1
- package/dist/{CustomerLayout-JNUTNHBA.js → CustomerLayout-Z3JGXMO7.js} +14 -13
- package/dist/CustomerLayout-Z3JGXMO7.js.map +1 -0
- package/dist/{Footer-GR7WW7UA.js → Footer-DFZFOH5E.js} +14 -13
- package/dist/{Footer-GR7WW7UA.js.map → Footer-DFZFOH5E.js.map} +1 -1
- package/dist/{Header-2CTHBDYE.js → Header-CF5TQMWR.js} +6 -6
- package/dist/{Header-2CTHBDYE.js.map → Header-CF5TQMWR.js.map} +1 -1
- package/dist/{LoyaltyPage-EHRGBXF6.js → LoyaltyPage-TOXOPXEU.js} +15 -14
- package/dist/LoyaltyPage-TOXOPXEU.js.map +1 -0
- package/dist/{MainMenu-TFUVK4W7.js → MainMenu-6VTPCMMJ.js} +7 -7
- package/dist/{MainMenu-TFUVK4W7.js.map → MainMenu-6VTPCMMJ.js.map} +1 -1
- package/dist/{MasterLayout-ODH7CFAU.js → MasterLayout-PQ2XGL6A.js} +14 -13
- package/dist/{MasterLayout-ODH7CFAU.js.map → MasterLayout-PQ2XGL6A.js.map} +1 -1
- package/dist/{MobileMenu-5OJEI2CQ.js → MobileMenu-UWDB2BHQ.js} +15 -14
- package/dist/MobileMenu-UWDB2BHQ.js.map +1 -0
- package/dist/{NotificationsPage-U4ULROLR.js → NotificationsPage-3WUAFRTU.js} +14 -13
- package/dist/NotificationsPage-3WUAFRTU.js.map +1 -0
- package/dist/{OrderSinglePage-O2ODTG33.js → OrderSinglePage-T2UE2EJI.js} +15 -14
- package/dist/OrderSinglePage-T2UE2EJI.js.map +1 -0
- package/dist/{OrdersPage-72RXJGSH.js → OrdersPage-762O24YK.js} +15 -14
- package/dist/OrdersPage-762O24YK.js.map +1 -0
- package/dist/{PageSingle-7Y4WJAA6.js → PageSingle-Y6IVAY3E.js} +3 -3
- package/dist/{PageSingle-7Y4WJAA6.js.map → PageSingle-Y6IVAY3E.js.map} +1 -1
- package/dist/{ProductDetails-GYCTNAWE.js → ProductDetails-7G7QOLTB.js} +3 -3
- package/dist/{ProductDetails-GYCTNAWE.js.map → ProductDetails-7G7QOLTB.js.map} +1 -1
- package/dist/{ProfilePage-GVYL5NVL.js → ProfilePage-H2JWTJJY.js} +14 -13
- package/dist/ProfilePage-H2JWTJJY.js.map +1 -0
- package/dist/{SeoCartWidget-KHDAMXBG.js → SeoCartWidget-XYWATIV3.js} +14 -13
- package/dist/SeoCartWidget-XYWATIV3.js.map +1 -0
- package/dist/{SettingsPage-ZCLDJNHY.js → SettingsPage-WQX22FTS.js} +14 -13
- package/dist/SettingsPage-WQX22FTS.js.map +1 -0
- package/dist/{StoreClosedNotification-6O34WQJV.js → StoreClosedNotification-TL4XY6OS.js} +15 -14
- package/dist/{StoreClosedNotification-6O34WQJV.js.map → StoreClosedNotification-TL4XY6OS.js.map} +1 -1
- package/dist/{TestimonialsPage-Y3DCS2RB.js → TestimonialsPage-PWVTHBOS.js} +3 -3
- package/dist/{TestimonialsPage-Y3DCS2RB.js.map → TestimonialsPage-PWVTHBOS.js.map} +1 -1
- package/dist/{ThankYouPage-MPF4V5T3.js → ThankYouPage-C573J2KJ.js} +14 -13
- package/dist/ThankYouPage-C573J2KJ.js.map +1 -0
- package/dist/{WalletPage-XVEZKUCP.js → WalletPage-7JE6PELL.js} +15 -14
- package/dist/WalletPage-7JE6PELL.js.map +1 -0
- package/dist/{WishlistPage-MALKVYV4.js → WishlistPage-XTQ6IRG7.js} +15 -14
- package/dist/WishlistPage-XTQ6IRG7.js.map +1 -0
- package/dist/api/apps.js +4 -4
- package/dist/api/brands.js +5 -5
- package/dist/api/cart.js +5 -5
- package/dist/api/category.js +5 -5
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +3 -3
- package/dist/api/home.js +4 -4
- package/dist/api/loyalty.js +5 -5
- package/dist/api/menu.js +4 -4
- package/dist/api/notification.js +4 -4
- package/dist/api/order.js +5 -5
- package/dist/api/page.js +5 -5
- package/dist/api/product.js +5 -5
- package/dist/api/profile.js +3 -3
- package/dist/api/store.d.ts.map +1 -1
- package/dist/api/store.js +4 -4
- package/dist/api/translations.js +4 -4
- package/dist/api/user.js +4 -4
- package/dist/api/wishlist.js +4 -4
- package/dist/{chunk-QOK3ANNB.js → chunk-2AGMXJVP.js} +4 -4
- package/dist/{chunk-QOK3ANNB.js.map → chunk-2AGMXJVP.js.map} +1 -1
- package/dist/{chunk-Z2BE6MDB.js → chunk-2KZORZZN.js} +14 -6
- package/dist/chunk-2KZORZZN.js.map +1 -0
- package/dist/{chunk-BOOOVZS4.js → chunk-4PLGRQAS.js} +4 -4
- package/dist/{chunk-BOOOVZS4.js.map → chunk-4PLGRQAS.js.map} +1 -1
- package/dist/{chunk-DLDDKPRN.js → chunk-5FH6E2FQ.js} +16 -20
- package/dist/chunk-5FH6E2FQ.js.map +1 -0
- package/dist/{chunk-VBXAGCNI.js → chunk-5R5IGGI3.js} +5 -5
- package/dist/{chunk-VBXAGCNI.js.map → chunk-5R5IGGI3.js.map} +1 -1
- package/dist/{chunk-FQGCCV4T.js → chunk-5TRRUV7N.js} +3 -3
- package/dist/{chunk-FQGCCV4T.js.map → chunk-5TRRUV7N.js.map} +1 -1
- package/dist/{chunk-Q56S25OH.js → chunk-63WNORBK.js} +6 -6
- package/dist/{chunk-Q56S25OH.js.map → chunk-63WNORBK.js.map} +1 -1
- package/dist/chunk-6IATCGID.js +7 -0
- package/dist/chunk-6IATCGID.js.map +1 -0
- package/dist/{chunk-LG556DIE.js → chunk-6KI2QCPL.js} +3 -3
- package/dist/{chunk-LG556DIE.js.map → chunk-6KI2QCPL.js.map} +1 -1
- package/dist/{chunk-GQ7IBJ55.js → chunk-6MGDRMZM.js} +4 -4
- package/dist/{chunk-GQ7IBJ55.js.map → chunk-6MGDRMZM.js.map} +1 -1
- package/dist/{chunk-5ACY5CD3.js → chunk-6XWMNQ52.js} +10 -4
- package/dist/chunk-6XWMNQ52.js.map +1 -0
- package/dist/{chunk-WXOABH6J.js → chunk-AZ5HAIYQ.js} +26 -11
- package/dist/chunk-AZ5HAIYQ.js.map +1 -0
- package/dist/chunk-BK4VEUF3.js +14 -0
- package/dist/{chunk-IN5RFJF2.js.map → chunk-BK4VEUF3.js.map} +1 -1
- package/dist/{chunk-L6UGY2OB.js → chunk-BWIESZJK.js} +3 -3
- package/dist/{chunk-L6UGY2OB.js.map → chunk-BWIESZJK.js.map} +1 -1
- package/dist/{chunk-Z2P4M6T6.js → chunk-CCCKRNO4.js} +3 -3
- package/dist/{chunk-Z2P4M6T6.js.map → chunk-CCCKRNO4.js.map} +1 -1
- package/dist/{chunk-RQHOAA7U.js → chunk-CZS4ZHQK.js} +3 -3
- package/dist/{chunk-RQHOAA7U.js.map → chunk-CZS4ZHQK.js.map} +1 -1
- package/dist/{chunk-TXYT42AU.js → chunk-E5EH32L7.js} +3 -3
- package/dist/{chunk-TXYT42AU.js.map → chunk-E5EH32L7.js.map} +1 -1
- package/dist/{chunk-6EBQ27KE.js → chunk-EFHSAWDQ.js} +23 -15
- package/dist/chunk-EFHSAWDQ.js.map +1 -0
- package/dist/{chunk-T3I4T3XB.js → chunk-FKOBOGLQ.js} +7 -7
- package/dist/{chunk-T3I4T3XB.js.map → chunk-FKOBOGLQ.js.map} +1 -1
- package/dist/{chunk-Y5FBDMFV.js → chunk-JBXTU5NM.js} +22 -12
- package/dist/chunk-JBXTU5NM.js.map +1 -0
- package/dist/{chunk-OOYJHQLQ.js → chunk-KFH3OBFW.js} +4 -4
- package/dist/{chunk-OOYJHQLQ.js.map → chunk-KFH3OBFW.js.map} +1 -1
- package/dist/{chunk-LXIEAZZJ.js → chunk-KLTQ2UST.js} +3 -3
- package/dist/{chunk-LXIEAZZJ.js.map → chunk-KLTQ2UST.js.map} +1 -1
- package/dist/{chunk-6JLVUQWD.js → chunk-MCYEMXFY.js} +4 -4
- package/dist/{chunk-6JLVUQWD.js.map → chunk-MCYEMXFY.js.map} +1 -1
- package/dist/{chunk-C4S4VXWW.js → chunk-ME727LL4.js} +3 -3
- package/dist/{chunk-C4S4VXWW.js.map → chunk-ME727LL4.js.map} +1 -1
- package/dist/{chunk-NTOIR3NK.js → chunk-NX6BEOXW.js} +4 -4
- package/dist/{chunk-NTOIR3NK.js.map → chunk-NX6BEOXW.js.map} +1 -1
- package/dist/{chunk-FPQAYFHZ.js → chunk-OGGWNPF3.js} +3 -3
- package/dist/{chunk-FPQAYFHZ.js.map → chunk-OGGWNPF3.js.map} +1 -1
- package/dist/{chunk-STHBBSK2.js → chunk-QG2Q6HB5.js} +3 -3
- package/dist/{chunk-STHBBSK2.js.map → chunk-QG2Q6HB5.js.map} +1 -1
- package/dist/{chunk-CBQKQCKI.js → chunk-RBISDOPR.js} +4 -4
- package/dist/{chunk-CBQKQCKI.js.map → chunk-RBISDOPR.js.map} +1 -1
- package/dist/{chunk-57RYHNW2.js → chunk-RIZOT5FN.js} +3 -3
- package/dist/{chunk-57RYHNW2.js.map → chunk-RIZOT5FN.js.map} +1 -1
- package/dist/{chunk-47C6C2NN.js → chunk-TMR7TZMB.js} +4 -4
- package/dist/{chunk-47C6C2NN.js.map → chunk-TMR7TZMB.js.map} +1 -1
- package/dist/{chunk-5IEQLAAY.js → chunk-ULQMJUO2.js} +4 -4
- package/dist/{chunk-5IEQLAAY.js.map → chunk-ULQMJUO2.js.map} +1 -1
- package/dist/{chunk-6BVPVYLN.js → chunk-VZHYSYKG.js} +4 -4
- package/dist/{chunk-6BVPVYLN.js.map → chunk-VZHYSYKG.js.map} +1 -1
- package/dist/{chunk-EV4JSMFZ.js → chunk-X26WB7AG.js} +3 -3
- package/dist/{chunk-EV4JSMFZ.js.map → chunk-X26WB7AG.js.map} +1 -1
- package/dist/{chunk-E3J2RXBS.js → chunk-XLGVT7QF.js} +3 -3
- package/dist/{chunk-E3J2RXBS.js.map → chunk-XLGVT7QF.js.map} +1 -1
- package/dist/{chunk-XBLA5RFR.js → chunk-XLVAVCUV.js} +5 -5
- package/dist/{chunk-XBLA5RFR.js.map → chunk-XLVAVCUV.js.map} +1 -1
- package/dist/{chunk-GCAIIFF3.js → chunk-XTOXFAP7.js} +3 -3
- package/dist/{chunk-GCAIIFF3.js.map → chunk-XTOXFAP7.js.map} +1 -1
- package/dist/{chunk-B4SPJFNB.js → chunk-YOA3UVDE.js} +4 -4
- package/dist/{chunk-B4SPJFNB.js.map → chunk-YOA3UVDE.js.map} +1 -1
- package/dist/{chunk-HYESKIWZ.js → chunk-ZNWNJZSM.js} +4 -4
- package/dist/{chunk-HYESKIWZ.js.map → chunk-ZNWNJZSM.js.map} +1 -1
- package/dist/{chunk-MY3ZH5BA.js → chunk-ZZA7L3RI.js} +6 -6
- package/dist/{chunk-MY3ZH5BA.js.map → chunk-ZZA7L3RI.js.map} +1 -1
- package/dist/components/cart/index.js +1 -1
- package/dist/components/common/index.js +1 -1
- package/dist/components/drawer/index.js +12 -11
- package/dist/components/home/index.js +15 -14
- package/dist/components/layout/index.js +5 -5
- package/dist/components/product/index.js +13 -12
- package/dist/components/store/index.js +14 -13
- package/dist/components/store/index.js.map +1 -1
- package/dist/document-class-5BBGX5LN.js +24 -0
- package/dist/{document-class-BQBALA53.js.map → document-class-5BBGX5LN.js.map} +1 -1
- package/dist/hooks/index.js +12 -11
- package/dist/hooks/registerDefaultHooks.d.ts.map +1 -1
- package/dist/hooks/useGtm.js +12 -11
- package/dist/hooks/useMoney.js +12 -11
- package/dist/hooks/useStore.js +12 -11
- package/dist/hooks/useUser.js +5 -5
- package/dist/index.js +12 -11
- package/dist/index.js.map +1 -1
- package/dist/{navigation-B6TEUWEK.js → navigation-D7QS3NK2.js} +4 -4
- package/dist/{navigation-B6TEUWEK.js.map → navigation-D7QS3NK2.js.map} +1 -1
- package/dist/{navigation-RYSVWICZ.js → navigation-DQNNT2LY.js} +5 -5
- package/dist/{navigation-RYSVWICZ.js.map → navigation-DQNNT2LY.js.map} +1 -1
- package/dist/{not-found-OPY73PW5.js → not-found-QM2L2D7P.js} +14 -13
- package/dist/not-found-QM2L2D7P.js.map +1 -0
- package/dist/providers/index.js +12 -11
- package/dist/routes/account/orders.js +6 -6
- package/dist/routes/account.js +14 -14
- package/dist/routes/blog.js +10 -10
- package/dist/routes/brands.js +6 -6
- package/dist/routes/cart.js +20 -19
- package/dist/routes/cart.js.map +1 -1
- package/dist/routes/home.js +17 -16
- package/dist/routes/index.js +3 -3
- package/dist/routes/loyalty.js +6 -6
- package/dist/routes/page.js +6 -6
- package/dist/routes/product-listing.js +17 -16
- package/dist/routes/product-listing.js.map +1 -1
- package/dist/routes/product.js +15 -14
- package/dist/routes/product.js.map +1 -1
- package/dist/routes/root/head.d.ts.map +1 -1
- package/dist/routes/seo-redirects.js +3 -3
- package/dist/routes/testimonials.js +2 -2
- package/dist/routes/thank-you.js +6 -6
- package/dist/skeleton.js +17 -16
- package/dist/tanstack/middleware/twilight.d.ts.map +1 -1
- package/dist/tanstack.js +17 -15
- package/dist/tanstack.js.map +1 -1
- package/dist/twilight/context.d.ts +22 -5
- package/dist/twilight/context.d.ts.map +1 -1
- package/dist/utils/cookies.d.ts +46 -6
- package/dist/utils/cookies.d.ts.map +1 -1
- package/dist/utils/fast-checkout.d.ts +4 -0
- package/dist/utils/fast-checkout.d.ts.map +1 -0
- package/dist/utils/index.js +4 -4
- package/dist/utils/runtime-env.d.ts +13 -0
- package/dist/utils/runtime-env.d.ts.map +1 -1
- package/dist/utils/theme-version.d.ts +33 -0
- package/dist/utils/theme-version.d.ts.map +1 -0
- package/dist/vite/index.js +2 -2
- package/package.json +1 -1
- package/dist/BlogAuthorPage-FTVPPHHS.js.map +0 -1
- package/dist/BlogCategoryPage-TJFW7DDI.js.map +0 -1
- package/dist/BlogPage-RD4JUGKY.js.map +0 -1
- package/dist/BlogSinglePage-DVZX3WVW.js.map +0 -1
- package/dist/BlogTagPage-UON2ASKW.js.map +0 -1
- package/dist/BrandsPage-R4KTDEG3.js.map +0 -1
- package/dist/Breadcrumb-YNVX6ZXO.js.map +0 -1
- package/dist/CartItem-6P4AB6LQ.js.map +0 -1
- package/dist/CartSummary-A25PNJSY.js.map +0 -1
- package/dist/CustomerLayout-JNUTNHBA.js.map +0 -1
- package/dist/LoyaltyPage-EHRGBXF6.js.map +0 -1
- package/dist/MobileMenu-5OJEI2CQ.js.map +0 -1
- package/dist/NotificationsPage-U4ULROLR.js.map +0 -1
- package/dist/OrderSinglePage-O2ODTG33.js.map +0 -1
- package/dist/OrdersPage-72RXJGSH.js.map +0 -1
- package/dist/ProfilePage-GVYL5NVL.js.map +0 -1
- package/dist/SeoCartWidget-KHDAMXBG.js.map +0 -1
- package/dist/SettingsPage-ZCLDJNHY.js.map +0 -1
- package/dist/ThankYouPage-MPF4V5T3.js.map +0 -1
- package/dist/WalletPage-XVEZKUCP.js.map +0 -1
- package/dist/WishlistPage-MALKVYV4.js.map +0 -1
- package/dist/chunk-5ACY5CD3.js.map +0 -1
- package/dist/chunk-6EBQ27KE.js.map +0 -1
- package/dist/chunk-DLDDKPRN.js.map +0 -1
- package/dist/chunk-IN5RFJF2.js +0 -14
- package/dist/chunk-WXOABH6J.js.map +0 -1
- package/dist/chunk-Y5FBDMFV.js.map +0 -1
- package/dist/chunk-Z2BE6MDB.js.map +0 -1
- package/dist/document-class-BQBALA53.js +0 -23
- package/dist/not-found-OPY73PW5.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/twilight/ensure-context.ts","../src/tanstack/head.ts"],"names":[],"mappings":";;;AAiBA,SAAS,aAAa,MAAA,EAAuE;AAC3F,EAAA,MAAM,WAAW,MAAA,EAAQ,QAAA;AACzB,EAAA,OAAO,WAAY,QAAA,GAA4B,MAAA;AACjD;AAEA,SAAS,UAAA,CAAW,QAA6C,GAAA,EAAiC;AAChG,EAAA,MAAM,KAAA,GAAQ,SAAS,GAAG,CAAA;AAC1B,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,GAAQ,KAAA,GAAQ,MAAA;AACtD;AAEA,SAAS,aAAa,MAAA,EAAuE;AAC3F,EAAA,MAAM,WAAW,MAAA,EAAQ,YA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aAAA,EAAe,OAAO,EAAC;AAC5C,MAAA,MAAM,KAAA;AAAA,IACR;AAAA,EACF,CAAA;AACF","file":"chunk-FQGCCV4T.js","sourcesContent":["import type { StoreContext } from '../api/store';\nimport type { AppSnippet, AppSettings } from '../api/apps';\nimport { hasTwilightSettings, updateTwilightContext } from './context';\n\n/**\n * The slice of a router match we can recover store settings from.\n *\n * TanStack resolves `match.context` (which spreads `__beforeLoadContext` over the\n * parent context) immediately before it invokes `route.options.head()`, so both\n * fields are populated by the time any head function runs — including during\n * client hydration, when the twilight module store may still be empty.\n */\nexport interface TwilightContextMatch {\n context?: Record<string, unknown>;\n __beforeLoadContext?: Record<string, unknown>;\n}\n\nfunction readSettings(source: Record<string, unknown> | undefined): StoreContext | undefined {\n const settings = source?.settings;\n return settings ? (settings as StoreContext) : undefined;\n}\n\nfunction readString(source: Record<string, unknown> | undefined, key: string): string | undefined {\n const value = source?.[key];\n return typeof value === 'string' && value ? value : undefined;\n}\n\nfunction readSnippets(source: Record<string, unknown> | undefined): AppSnippet[] | undefined {\n const snippets = source?.appsSnippets;\n return Array.isArray(snippets) ? (snippets as AppSnippet[]) : undefined;\n}\n\nfunction readAppSettings(source: Record<string, unknown> | undefined): AppSettings | undefined {\n const settings = source?.appsSettings as AppSettings | undefined;\n return settings && typeof settings === 'object' && 'apps' in settings ? settings : undefined;\n}\n\n/**\n * Seeds the twilight module store from the router matches when it is empty.\n *\n * Head functions read store settings through `getTwilightContext()`, whose\n * `settings` getter **throws** a `SettingsError` when the store has not been\n * populated. TanStack re-runs every matched route's head function during client\n * hydration, and a throw there aborts hydration outright: React then discards\n * the server-rendered tree and re-renders from scratch, which blanks the page.\n *\n * `hydrateTwilightContext` normally populates the store first, but it is a\n * single best-effort pass — if it bails (missing root match, missing settings,\n * or a duplicated module instance holding a different store) every head\n * function downstream throws. Seeding from the match TanStack already resolved\n * removes that dependency at the point of use.\n *\n * @returns whether the store has settings after the attempt.\n */\nexport function ensureTwilightContextFromMatches(\n matches: readonly TwilightContextMatch[] | undefined\n): boolean {\n if (hasTwilightSettings()) return true;\n\n const rootMatch = matches?.[0];\n if (!rootMatch) return false;\n\n const beforeLoadCtx = rootMatch.__beforeLoadContext;\n const matchCtx = rootMatch.context;\n\n const settings = readSettings(beforeLoadCtx) ?? readSettings(matchCtx);\n const locale = readString(beforeLoadCtx, 'locale') ?? readString(matchCtx, 'locale');\n if (!settings || !locale) return false;\n\n const authToken =\n readString(beforeLoadCtx, 'authToken') ?? readString(matchCtx, 'authToken') ?? null;\n const appsSnippets = readSnippets(beforeLoadCtx) ?? readSnippets(matchCtx);\n const appsSettings = readAppSettings(beforeLoadCtx) ?? readAppSettings(matchCtx);\n\n updateTwilightContext({ settings, locale, authToken, appsSnippets, appsSettings });\n return true;\n}\n","import type { HeadDescriptor, OpenGraphImage } from '../utils/head';\nimport type { TwilightContext } from '../twilight/context';\nimport { getTwilightContext } from '../twilight/context';\nimport type { TwilightContextMatch } from '../twilight/ensure-context';\nimport { ensureTwilightContextFromMatches } from '../twilight/ensure-context';\nimport { SettingsError } from '../utils/errors';\n\ntype OgImagesInput = string | OpenGraphImage | Array<string | OpenGraphImage> | undefined;\n\nfunction normalizeOgImages(images: OgImagesInput): OpenGraphImage[] {\n if (!images) return [];\n const arr = Array.isArray(images) ? images : [images];\n return arr.map((img) => (typeof img === 'string' ? { url: img } : img));\n}\n\nexport function tanstackHeadAdapter(descriptor: HeadDescriptor) {\n const meta: Array<Record<string, unknown>> = [];\n const links: Array<Record<string, unknown>> = [];\n const scripts: Array<Record<string, unknown>> = [];\n const styles: Record<string, unknown>[] = [];\n\n if (descriptor.title) meta.push({ title: descriptor.title });\n if (descriptor.description) meta.push({ name: 'description', content: descriptor.description });\n\n if (descriptor.keywords) {\n const kw = Array.isArray(descriptor.keywords)\n ? descriptor.keywords.join(', ')\n : descriptor.keywords;\n meta.push({ name: 'keywords', content: kw });\n }\n\n if (descriptor.robots) meta.push({ name: 'robots', content: descriptor.robots });\n\n // Open Graph\n const og = descriptor.openGraph;\n if (og) {\n if (og.siteName) meta.push({ property: 'og:site_name', content: og.siteName });\n if (og.type) meta.push({ property: 'og:type', content: og.type });\n if (og.title) meta.push({ property: 'og:title', content: og.title });\n if (og.description) meta.push({ property: 'og:description', content: og.description });\n if (og.url) meta.push({ property: 'og:url', content: og.url });\n if (og.locale) meta.push({ property: 'og:locale', content: og.locale });\n for (const alt of og.alternateLocale ?? []) {\n meta.push({ property: 'og:locale:alternate', content: alt });\n }\n for (const img of normalizeOgImages(og.images)) {\n meta.push({ property: 'og:image', content: img.url });\n if (img.width != null) meta.push({ property: 'og:image:width', content: String(img.width) });\n if (img.height != null)\n meta.push({ property: 'og:image:height', content: String(img.height) });\n if (img.alt) meta.push({ property: 'og:image:alt', content: img.alt });\n }\n if (og.publishedTime)\n meta.push({ property: 'article:published_time', content: og.publishedTime });\n if (og.modifiedTime) meta.push({ property: 'article:modified_time', content: og.modifiedTime });\n }\n\n // Twitter Card\n const tw = descriptor.twitter;\n if (tw) {\n if (tw.card) meta.push({ name: 'twitter:card', content: tw.card });\n if (tw.title) meta.push({ name: 'twitter:title', content: tw.title });\n if (tw.description) meta.push({ name: 'twitter:description', content: tw.description });\n if (tw.site) meta.push({ name: 'twitter:site', content: tw.site });\n if (tw.creator) meta.push({ name: 'twitter:creator', content: tw.creator });\n if (tw.url) meta.push({ name: 'twitter:url', content: tw.url });\n const twImages = tw.images ? (Array.isArray(tw.images) ? tw.images : [tw.images]) : [];\n for (const img of twImages) {\n meta.push({ name: 'twitter:image', content: img });\n }\n }\n\n // Canonical\n if (descriptor.canonical) links.push({ rel: 'canonical', href: descriptor.canonical });\n\n // hreflang alternates (React requires camelCase: hrefLang)\n for (const alt of descriptor.alternateLanguages ?? []) {\n links.push({ rel: 'alternate', hrefLang: alt.hreflang, href: alt.href });\n }\n\n // JSON-LD\n if (descriptor.jsonLd) {\n scripts.push({ type: 'application/ld+json', children: JSON.stringify(descriptor.jsonLd) });\n }\n\n // Escape hatches\n for (const m of descriptor.meta ?? []) {\n const { httpEquiv, ...rest } = m as typeof m & { httpEquiv?: string };\n meta.push(httpEquiv ? { httpEquiv, ...rest } : rest);\n }\n for (const l of descriptor.links ?? []) links.push(l);\n for (const s of descriptor.styles ?? []) styles.push(s as unknown as Record<string, unknown>);\n\n // Import maps must be emitted before module scripts that rely on bare specifiers.\n for (const im of descriptor.importMap ?? []) {\n scripts.push({ type: 'importmap', children: JSON.stringify(im) });\n }\n for (const s of descriptor.scripts ?? []) scripts.push(s);\n\n return { meta, links, styles, scripts };\n}\n\n// ============================================================================\n// withHead - Simplified head callback wrapper for TanStack Router\n// ============================================================================\n\n/**\n * Minimal shape we need from TanStack Router's AssetFnContextOptions.\n * `loaderData` feeds the route's own head function; `matches` is the recovery\n * source for store settings when the twilight module store is not populated yet\n * (see `ensureTwilightContextFromMatches`).\n */\ntype HeadContext = {\n loaderData?: unknown;\n matches?: readonly TwilightContextMatch[];\n};\n\n/**\n * Wraps a route module's head function for TanStack Router.\n *\n * @example\n * ```typescript\n * head: withHead(Offers)\n * head: withHead(Product, (result, ctx) => ({\n * ...result,\n * title: `${result.title} | ${ctx.settings?.store?.name}`,\n * }))\n * ```\n */\nexport function withHead<T>(\n route: { head: (ctx: TwilightContext, data: T) => HeadDescriptor },\n extend?: (result: HeadDescriptor, _ctx: TwilightContext, data: T) => HeadDescriptor\n): (_ctx: Record<string, unknown>) => Record<string, unknown> {\n return (ctx: HeadContext) => {\n const loaderData = ctx.loaderData;\n\n if (!loaderData) return {};\n\n // TanStack re-runs every matched route's head() during client hydration,\n // where the twilight module store can still be empty. Recover it from the\n // match context TanStack has already resolved before giving up.\n ensureTwilightContextFromMatches(ctx.matches);\n\n try {\n const context = getTwilightContext();\n const result = route.head(context, loaderData as T);\n const finalResult = extend ? extend(result, context, loaderData as T) : result;\n\n return tanstackHeadAdapter(finalResult);\n } catch (error) {\n // A head function must never throw: TanStack surfaces the throw as a\n // hydration error, React then discards the server-rendered tree and the\n // storefront renders blank. Dropping this route's head tags degrades\n // gracefully — the server-rendered ones stay in the document.\n if (error instanceof SettingsError) return {};\n throw error;\n }\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/twilight/ensure-context.ts","../src/tanstack/head.ts"],"names":[],"mappings":";;;AAiBA,SAAS,aAAa,MAAA,EAAuE;AAC3F,EAAA,MAAM,WAAW,MAAA,EAAQ,QAAA;AACzB,EAAA,OAAO,WAAY,QAAA,GAA4B,MAAA;AACjD;AAEA,SAAS,UAAA,CAAW,QAA6C,GAAA,EAAiC;AAChG,EAAA,MAAM,KAAA,GAAQ,SAAS,GAAG,CAAA;AAC1B,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,GAAQ,KAAA,GAAQ,MAAA;AACtD;AAEA,SAAS,aAAa,MAAA,EAAuE;AAC3F,EAAA,MAAM,WAAW,MAAA,EAAQ,YAAA;AACzB,EAAA,OAAO,KAAA,CAAM,OAAA,CAAQ,QAAQ,CAAA,GAAK,QAAA,GAA4B,MAAA;AAChE;AAEA,SAAS,gBAAgB,MAAA,EAAsE;AAC7F,EAAA,MAAM,WAAW,MAAA,EAAQ,YAAA;AACzB,EAAA,OAAO,YAAY,OAAO,QAAA,KAAa,QAAA,IAAY,MAAA,IAAU,WAAW,QAAA,GAAW,MAAA;AACrF;AAmBO,SAAS,iCACd,OAAA,EACS;AACT,EAAA,IAAI,mBAAA,IAAuB,OAAO,IAAA;AAElC,EAAA,MAAM,SAAA,GAAY,UAAU,CAAC,CAAA;AAC7B,EAAA,IAAI,CAAC,WAAW,OAAO,KAAA;AAEvB,EAAA,MAAM,gBAAgB,SAAA,CAAU,mBAAA;AAChC,EAAA,MAAM,WAAW,SAAA,CAAU,OAAA;AAE3B,EAAA,MAAM,QAAA,GAAW,YAAA,CAAa,aAAa,CAAA,IAAK,aAAa,QAAQ,CAAA;AACrE,EAAA,MAAM,SAAS,UAAA,CAAW,aAAA,EAAe,QAAQ,CAAA,IAAK,UAAA,CAAW,UAAU,QAA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AAS,QAAA,CACd,OACA,MAAA,EAC4D;AAC5D,EAAA,OAAO,CAAC,GAAA,KAAqB;AAC3B,IAAA,MAAM,aAAa,GAAA,CAAI,UAAA;AAEvB,IAAA,IAAI,CAAC,UAAA,EAAY,OAAO,EAAC;AAKzB,IAAA,gCAAA,CAAiC,IAAI,OAAO,CAAA;AAE5C,IAAA,IAAI;AACF,MAAA,MAAM,UAAU,kBAAA,EAAmB;AACnC,MAAA,MAAM,MAAA,GAAS,KAAA,CAAM,IAAA,CAAK,OAAA,EAAS,UAAe,CAAA;AAClD,MAAA,MAAM,cAAc,MAAA,GAAS,MAAA,CAAO,MAAA,EAAQ,OAAA,EAAS,UAAe,CAAA,GAAI,MAAA;AAExE,MAAA,OAAO,oBAAoB,WAAW,CAAA;AAAA,IACxC,SAAS,KAAA,EAAO;AAKd,MAAA,IAAI,KAAA,YAAiB,aAAA,EAAe,OAAO,EAAC;AAC5C,MAAA,MAAM,KAAA;AAAA,IACR;AAAA,EACF,CAAA;AACF","file":"chunk-5TRRUV7N.js","sourcesContent":["import type { StoreContext } from '../api/store';\nimport type { AppSnippet, AppSettings } from '../api/apps';\nimport { hasTwilightSettings, updateTwilightContext } from './context';\n\n/**\n * The slice of a router match we can recover store settings from.\n *\n * TanStack resolves `match.context` (which spreads `__beforeLoadContext` over the\n * parent context) immediately before it invokes `route.options.head()`, so both\n * fields are populated by the time any head function runs — including during\n * client hydration, when the twilight module store may still be empty.\n */\nexport interface TwilightContextMatch {\n context?: Record<string, unknown>;\n __beforeLoadContext?: Record<string, unknown>;\n}\n\nfunction readSettings(source: Record<string, unknown> | undefined): StoreContext | undefined {\n const settings = source?.settings;\n return settings ? (settings as StoreContext) : undefined;\n}\n\nfunction readString(source: Record<string, unknown> | undefined, key: string): string | undefined {\n const value = source?.[key];\n return typeof value === 'string' && value ? value : undefined;\n}\n\nfunction readSnippets(source: Record<string, unknown> | undefined): AppSnippet[] | undefined {\n const snippets = source?.appsSnippets;\n return Array.isArray(snippets) ? (snippets as AppSnippet[]) : undefined;\n}\n\nfunction readAppSettings(source: Record<string, unknown> | undefined): AppSettings | undefined {\n const settings = source?.appsSettings as AppSettings | undefined;\n return settings && typeof settings === 'object' && 'apps' in settings ? settings : undefined;\n}\n\n/**\n * Seeds the twilight module store from the router matches when it is empty.\n *\n * Head functions read store settings through `getTwilightContext()`, whose\n * `settings` getter **throws** a `SettingsError` when the store has not been\n * populated. TanStack re-runs every matched route's head function during client\n * hydration, and a throw there aborts hydration outright: React then discards\n * the server-rendered tree and re-renders from scratch, which blanks the page.\n *\n * `hydrateTwilightContext` normally populates the store first, but it is a\n * single best-effort pass — if it bails (missing root match, missing settings,\n * or a duplicated module instance holding a different store) every head\n * function downstream throws. Seeding from the match TanStack already resolved\n * removes that dependency at the point of use.\n *\n * @returns whether the store has settings after the attempt.\n */\nexport function ensureTwilightContextFromMatches(\n matches: readonly TwilightContextMatch[] | undefined\n): boolean {\n if (hasTwilightSettings()) return true;\n\n const rootMatch = matches?.[0];\n if (!rootMatch) return false;\n\n const beforeLoadCtx = rootMatch.__beforeLoadContext;\n const matchCtx = rootMatch.context;\n\n const settings = readSettings(beforeLoadCtx) ?? readSettings(matchCtx);\n const locale = readString(beforeLoadCtx, 'locale') ?? readString(matchCtx, 'locale');\n if (!settings || !locale) return false;\n\n const authToken =\n readString(beforeLoadCtx, 'authToken') ?? readString(matchCtx, 'authToken') ?? null;\n const appsSnippets = readSnippets(beforeLoadCtx) ?? readSnippets(matchCtx);\n const appsSettings = readAppSettings(beforeLoadCtx) ?? readAppSettings(matchCtx);\n\n updateTwilightContext({ settings, locale, authToken, appsSnippets, appsSettings });\n return true;\n}\n","import type { HeadDescriptor, OpenGraphImage } from '../utils/head';\nimport type { TwilightContext } from '../twilight/context';\nimport { getTwilightContext } from '../twilight/context';\nimport type { TwilightContextMatch } from '../twilight/ensure-context';\nimport { ensureTwilightContextFromMatches } from '../twilight/ensure-context';\nimport { SettingsError } from '../utils/errors';\n\ntype OgImagesInput = string | OpenGraphImage | Array<string | OpenGraphImage> | undefined;\n\nfunction normalizeOgImages(images: OgImagesInput): OpenGraphImage[] {\n if (!images) return [];\n const arr = Array.isArray(images) ? images : [images];\n return arr.map((img) => (typeof img === 'string' ? { url: img } : img));\n}\n\nexport function tanstackHeadAdapter(descriptor: HeadDescriptor) {\n const meta: Array<Record<string, unknown>> = [];\n const links: Array<Record<string, unknown>> = [];\n const scripts: Array<Record<string, unknown>> = [];\n const styles: Record<string, unknown>[] = [];\n\n if (descriptor.title) meta.push({ title: descriptor.title });\n if (descriptor.description) meta.push({ name: 'description', content: descriptor.description });\n\n if (descriptor.keywords) {\n const kw = Array.isArray(descriptor.keywords)\n ? descriptor.keywords.join(', ')\n : descriptor.keywords;\n meta.push({ name: 'keywords', content: kw });\n }\n\n if (descriptor.robots) meta.push({ name: 'robots', content: descriptor.robots });\n\n // Open Graph\n const og = descriptor.openGraph;\n if (og) {\n if (og.siteName) meta.push({ property: 'og:site_name', content: og.siteName });\n if (og.type) meta.push({ property: 'og:type', content: og.type });\n if (og.title) meta.push({ property: 'og:title', content: og.title });\n if (og.description) meta.push({ property: 'og:description', content: og.description });\n if (og.url) meta.push({ property: 'og:url', content: og.url });\n if (og.locale) meta.push({ property: 'og:locale', content: og.locale });\n for (const alt of og.alternateLocale ?? []) {\n meta.push({ property: 'og:locale:alternate', content: alt });\n }\n for (const img of normalizeOgImages(og.images)) {\n meta.push({ property: 'og:image', content: img.url });\n if (img.width != null) meta.push({ property: 'og:image:width', content: String(img.width) });\n if (img.height != null)\n meta.push({ property: 'og:image:height', content: String(img.height) });\n if (img.alt) meta.push({ property: 'og:image:alt', content: img.alt });\n }\n if (og.publishedTime)\n meta.push({ property: 'article:published_time', content: og.publishedTime });\n if (og.modifiedTime) meta.push({ property: 'article:modified_time', content: og.modifiedTime });\n }\n\n // Twitter Card\n const tw = descriptor.twitter;\n if (tw) {\n if (tw.card) meta.push({ name: 'twitter:card', content: tw.card });\n if (tw.title) meta.push({ name: 'twitter:title', content: tw.title });\n if (tw.description) meta.push({ name: 'twitter:description', content: tw.description });\n if (tw.site) meta.push({ name: 'twitter:site', content: tw.site });\n if (tw.creator) meta.push({ name: 'twitter:creator', content: tw.creator });\n if (tw.url) meta.push({ name: 'twitter:url', content: tw.url });\n const twImages = tw.images ? (Array.isArray(tw.images) ? tw.images : [tw.images]) : [];\n for (const img of twImages) {\n meta.push({ name: 'twitter:image', content: img });\n }\n }\n\n // Canonical\n if (descriptor.canonical) links.push({ rel: 'canonical', href: descriptor.canonical });\n\n // hreflang alternates (React requires camelCase: hrefLang)\n for (const alt of descriptor.alternateLanguages ?? []) {\n links.push({ rel: 'alternate', hrefLang: alt.hreflang, href: alt.href });\n }\n\n // JSON-LD\n if (descriptor.jsonLd) {\n scripts.push({ type: 'application/ld+json', children: JSON.stringify(descriptor.jsonLd) });\n }\n\n // Escape hatches\n for (const m of descriptor.meta ?? []) {\n const { httpEquiv, ...rest } = m as typeof m & { httpEquiv?: string };\n meta.push(httpEquiv ? { httpEquiv, ...rest } : rest);\n }\n for (const l of descriptor.links ?? []) links.push(l);\n for (const s of descriptor.styles ?? []) styles.push(s as unknown as Record<string, unknown>);\n\n // Import maps must be emitted before module scripts that rely on bare specifiers.\n for (const im of descriptor.importMap ?? []) {\n scripts.push({ type: 'importmap', children: JSON.stringify(im) });\n }\n for (const s of descriptor.scripts ?? []) scripts.push(s);\n\n return { meta, links, styles, scripts };\n}\n\n// ============================================================================\n// withHead - Simplified head callback wrapper for TanStack Router\n// ============================================================================\n\n/**\n * Minimal shape we need from TanStack Router's AssetFnContextOptions.\n * `loaderData` feeds the route's own head function; `matches` is the recovery\n * source for store settings when the twilight module store is not populated yet\n * (see `ensureTwilightContextFromMatches`).\n */\ntype HeadContext = {\n loaderData?: unknown;\n matches?: readonly TwilightContextMatch[];\n};\n\n/**\n * Wraps a route module's head function for TanStack Router.\n *\n * @example\n * ```typescript\n * head: withHead(Offers)\n * head: withHead(Product, (result, ctx) => ({\n * ...result,\n * title: `${result.title} | ${ctx.settings?.store?.name}`,\n * }))\n * ```\n */\nexport function withHead<T>(\n route: { head: (ctx: TwilightContext, data: T) => HeadDescriptor },\n extend?: (result: HeadDescriptor, _ctx: TwilightContext, data: T) => HeadDescriptor\n): (_ctx: Record<string, unknown>) => Record<string, unknown> {\n return (ctx: HeadContext) => {\n const loaderData = ctx.loaderData;\n\n if (!loaderData) return {};\n\n // TanStack re-runs every matched route's head() during client hydration,\n // where the twilight module store can still be empty. Recover it from the\n // match context TanStack has already resolved before giving up.\n ensureTwilightContextFromMatches(ctx.matches);\n\n try {\n const context = getTwilightContext();\n const result = route.head(context, loaderData as T);\n const finalResult = extend ? extend(result, context, loaderData as T) : result;\n\n return tanstackHeadAdapter(finalResult);\n } catch (error) {\n // A head function must never throw: TanStack surfaces the throw as a\n // hydration error, React then discards the server-rendered tree and the\n // storefront renders blank. Dropping this route's head tags degrades\n // gracefully — the server-rendered ones stay in the document.\n if (error instanceof SettingsError) return {};\n throw error;\n }\n };\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useIsHome } from './chunk-
|
|
1
|
+
import { useIsHome } from './chunk-XLGVT7QF.js';
|
|
2
2
|
import { useTranslation } from './chunk-TYNZ5B2B.js';
|
|
3
3
|
import { HookSlot } from './chunk-Q7VWURUR.js';
|
|
4
|
-
import { Image } from './chunk-
|
|
4
|
+
import { Image } from './chunk-CZS4ZHQK.js';
|
|
5
5
|
import { useTwilight } from './chunk-DF6FBKDN.js';
|
|
6
6
|
import { lazy, useState } from 'react';
|
|
7
7
|
import { SallaAdvertisement } from '@salla.sa/twilight-components-react/advertisement';
|
|
@@ -13,9 +13,9 @@ import { SallaSearch } from '@salla.sa/twilight-components-react/search';
|
|
|
13
13
|
import { SallaUserMenu } from '@salla.sa/twilight-components-react/user-menu';
|
|
14
14
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
15
15
|
|
|
16
|
-
var LazyMainMenu = lazy(() => import('./MainMenu-
|
|
16
|
+
var LazyMainMenu = lazy(() => import('./MainMenu-6VTPCMMJ.js').then((m) => ({ default: m.MainMenu })));
|
|
17
17
|
var LazyMobileMenu = lazy(
|
|
18
|
-
() => import('./MobileMenu-
|
|
18
|
+
() => import('./MobileMenu-UWDB2BHQ.js').then((m) => ({ default: m.MobileMenu }))
|
|
19
19
|
);
|
|
20
20
|
function Header(_props) {
|
|
21
21
|
const { currency, theme, store } = useTwilight();
|
|
@@ -120,5 +120,5 @@ function Header(_props) {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
export { Header };
|
|
123
|
-
//# sourceMappingURL=chunk-
|
|
124
|
-
//# sourceMappingURL=chunk-
|
|
123
|
+
//# sourceMappingURL=chunk-63WNORBK.js.map
|
|
124
|
+
//# sourceMappingURL=chunk-63WNORBK.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/navigation/lazy.ts","../src/components/layout/Header.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAMO,IAAM,YAAA,GAAe,IAAA,CAAK,MAAM,OAAO,wBAAY,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,QAAA,GAAW,CAAC,CAAA;AAE3F,IAAM,cAAA,GAAiB,IAAA;AAAA,EAAK,MACjC,OAAO,0BAAc,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,UAAA,EAAW,CAAE;AAChE,CAAA;ACUO,SAAS,OAAO,MAAA,EAAqB;AAC1C,EAAA,MAAM,EAAE,QAAA,EAAU,KAAA,EAAO,KAAA,KAAU,WAAA,EAAY;AAC/C,EAAA,MAAM,EAAE,MAAA,EAAQ,YAAA,EAAa,GAAI,cAAA,EAAe;AAChD,EAAA,MAAM,QAAA,GAAW,KAAA,EAAO,QAAA,IAAY,EAAC;AACrC,EAAA,MAAM,CAAC,gBAAA,EAAkB,mBAAmB,CAAA,GAAI,S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AA,EAAA,EAAI,WAAU,cAAA,EACb,QAAA,kBAAA,GAAA;AAAA,gBAAC,KAAA;AAAA,gBAAA;AAAA,kBACC,KAAK,KAAA,EAAO,IAAA;AAAA,kBACZ,GAAA,EAAK,CAAA,EAAG,KAAA,EAAO,IAAA,IAAQ,OAAO,CAAA,KAAA,CAAA;AAAA,kBAC9B,QAAA,EAAQ,IAAA;AAAA,kBACR,KAAA,EAAO,GAAA;AAAA,kBACP,MAAA,EAAQ;AAAA;AAAA,eACV,EACF,CAAA;AAAA,kCACC,UAAA,EAAA,EAAW,SAAA,EAAU,SAAA,EAAW,QAAA,EAAA,KAAA,EAAO,QAAQ,OAAA,EAAQ;AAAA,aAAA,EAC1D,CAAA;AAAA,gCACC,YAAA,EAAA,EAAS;AAAA,WAAA,EACZ,CAAA;AAAA,0BACA,IAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,sCAAA,EACb,QAAA,EAAA;AAAA,4BAAA,GAAA,CAAC,iBAAc,UAAA,EAAU,IAAA,EAAC,UAAA,EAAU,IAAA,EAAC,WAAU,YAAA,EAAa,CAAA;AAAA,4BAC5D,GAAA,CAAC,gBAAA,EAAA,EAAiB,SAAA,EAAU,8BAAA,EAC1B,QAAA,kBAAA,GAAA,CAAC,OAAE,IAAA,EAAK,MAAA,EAAO,SAAA,EAAU,0CAAA,EAA2C,CAAA,EACtE;AAAA,WAAA,EACF;AAAA,SAAA,EACF,GACF,CAAA,EACF;AAAA;AAAA,KACF;AAAA,oBAGA,GAAA,CAAC,kBAAW,MAAA,EAAQ,gBAAA,EAAkB,SAAS,MAAM,mBAAA,CAAoB,KAAK,CAAA,EAAG,CAAA;AAAA,oBACjF,GAAA,CAAC,QAAA,EAAA,EAAS,IAAA,EAAK,YAAA,EAAa;AAAA,GAAA,EAC9B,CAAA;AAEJ","file":"chunk-Q56S25OH.js","sourcesContent":["import { lazy } from 'react';\n\n/**\n * Lazy-loaded navigation components\n * Use these for code-splitting navigation sections\n */\nexport const LazyMainMenu = lazy(() => import('./MainMenu').then((m) => ({ default: m.MainMenu })));\n\nexport const LazyMobileMenu = lazy(() =>\n import('./MobileMenu').then((m) => ({ default: m.MobileMenu }))\n);\n","import { useState } from 'react';\nimport { useIsHome } from '../../providers/NavigationProvider';\nimport { SallaAdvertisement } from '@salla.sa/twilight-components-react/advertisement';\nimport { SallaCartSummary } from '@salla.sa/twilight-components-react/cart-summary';\nimport { SallaContacts } from '@salla.sa/twilight-components-react/contacts';\nimport { SallaLocalizationModal } from '@salla.sa/twilight-components-react/localization-modal';\nimport { SallaMenu } from '@salla.sa/twilight-components-react/menu';\nimport { SallaSearch } from '@salla.sa/twilight-components-react/search';\nimport { SallaUserMenu } from '@salla.sa/twilight-components-react/user-menu';\nimport { useTwilight } from '../../providers/twilight-context';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport { HookSlot } from '../../hooks/HookSlot';\nimport { MainMenu, MobileMenu } from '../navigation';\nimport { Image } from '../common';\nimport type { Cart } from '../../types';\n\ninterface HeaderProps {\n cart?: Cart;\n}\n\nexport function Header(_props: HeaderProps) {\n const { currency, theme, store } = useTwilight();\n const { locale, languageName } = useTranslation();\n const settings = theme?.settings || {};\n const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);\n\n // Check if we're on homepage\n const isHomepage = useIsHome();\n\n const StoreTitle = isHomepage ? 'h1' : 'span';\n\n return (\n <header className=\"store-header\" suppressHydrationWarning>\n <HookSlot name=\"header:start\" />\n <div className=\"advertisement-slot\">\n <SallaAdvertisement />\n </div>\n {/* Top Nav */}\n <div className={`top-navbar${settings.topnav_is_dark ? ' top-navbar--dark' : ''}`}>\n <div className=\"container flex justify-between\">\n <div className=\"flex-1 flex items-center gap-2\">\n {/* Footer Menu */}\n {settings.important_links && <SallaMenu source=\"footer\" topnav />}\n\n {/* Language & Currency */}\n <div className=\"header-buttons\">\n {(store?.settings?.is_multilingual || store?.settings?.currencies_enabled) && (\n <>\n <button\n type=\"button\"\n onClick={() => window.salla?.event.dispatch('localization::open')}\n className=\"btn--rounded-gray basis-0\"\n >\n <span>{languageName}</span>\n <span className=\"mx-1.5\">|</span>\n <span className={`flag iti__flag iti__${store?.country.toLowerCase()}`}></span>\n\n <span>\n {store?.settings?.use_sar_symbol && currency?.code === 'SAR' ? (\n <i className=\"sicon-sar\"></i>\n ) : (\n <>{currency?.symbol}</>\n )}\n </span>\n </button>\n {/* TODO:: support switch the lang without hit the web API, by set it in the sdk and local storage */}\n {/* TODO:: Support switch the curency without hit the web API, by set it in the sdk and local storage */}\n <SallaLocalizationModal\n language={locale}\n currency={currency?.code || 'SAR'}\n suppressHydrationWarning\n />\n </>\n )}\n </div>\n\n {/* Scopes / Branches */}\n {store?.scope && (\n <button\n type=\"button\"\n className=\"btn--rounded-gray\"\n onClick={() =>\n window.salla?.event.dispatch('scopes::open', {\n mode: 'default',\n })\n }\n >\n <i className=\"sicon-location rtl:ml-1 ltr:mr-1\"></i>\n {store.scope.name}\n </button>\n )}\n\n {/* Search bar */}\n <div className=\"header-search flex-1\">\n {/* todo:: use a search icon insted with open the search popup */}\n <SallaSearch inline oval height={36} />\n </div>\n </div>\n\n <SallaContacts contacts={store?.contacts} contactsTitle=\"N/A\" isHeader />\n </div>\n </div>\n\n {/* Main Nav */}\n <div\n id=\"mainnav\"\n className={`main-nav-container shadow-default bg-white flex items-center relative z-50${settings.header_is_sticky ? ' sticky top-0' : ''}`}\n >\n <div className=\"inner bg-inherit w-full\">\n <div className=\"container\">\n <div className=\"flex items-stretch justify-between relative\">\n <div className=\"flex items-center\">\n <a\n className=\"lg:hidden mburger mburger--collapse leading-none rtl:ml-4 ltr:mr-4\"\n href=\"#mobile-menu\"\n aria-label=\"Open-menu\"\n onClick={(e) => {\n e.preventDefault();\n setIsMobileMenuOpen(true);\n }}\n >\n <i className=\"sicon-menu text-primary text-2xl\"></i>\n </a>\n <a className=\"navbar-brand\" href={store?.url || '/'}>\n <div className=\"logo-wrapper\">\n <Image\n src={store?.logo}\n alt={`${store?.name || 'Store'} logo`}\n priority\n width={120}\n height={48}\n />\n </div>\n <StoreTitle className=\"sr-only\">{store?.name || 'Store'}</StoreTitle>\n </a>\n <MainMenu />\n </div>\n <div className=\"flex items-center justify-end my-2.5\">\n <SallaUserMenu avatarOnly showHeader className=\"header-btn\" />\n <SallaCartSummary className=\"ml-4 rtl:ml-[unset] rtl:mr-4\">\n <i slot=\"icon\" className=\"header-btn__icon icon sicon-shopping-bag\"></i>\n </SallaCartSummary>\n </div>\n </div>\n </div>\n </div>\n </div>\n\n {/* Mobile Menu */}\n <MobileMenu isOpen={isMobileMenuOpen} onClose={() => setIsMobileMenuOpen(false)} />\n <HookSlot name=\"header:end\" />\n </header>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/navigation/lazy.ts","../src/components/layout/Header.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAMO,IAAM,YAAA,GAAe,IAAA,CAAK,MAAM,OAAO,wBAAY,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,QAAA,GAAW,CAAC,CAAA;AAE3F,IAAM,cAAA,GAAiB,IAAA;AAAA,EAAK,MACjC,OAAO,0BAAc,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,UAAA,EAAW,CAAE;AAChE,CAAA;ACUO,SAAS,OAAO,MAAA,EAAqB;AAC1C,EAAA,MAAM,EAAE,QAAA,EAAU,KAAA,EAAO,KAAA,KAAU,WAAA,EAAY;AAC/C,EAAA,MAAM,EAAE,MAAA,EAAQ,YAAA,EAAa,GAAI,cAAA,EAAe;AAChD,EAAA,MAAM,QAAA,GAAW,KAAA,EAAO,QAAA,IAAY,EAAC;AACrC,EAAA,MAAM,CAAC,gBAAA,EAAkB,mBAAmB,CAAA,GAAI,SAAS,KAAK,CAAA;AAG9D,EAAA,MAAM,aAAa,SAAA,EAAU;AAE7B,EAAA,MAAM,UAAA,GAAa,aA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A,kBACC,KAAK,KAAA,EAAO,IAAA;AAAA,kBACZ,GAAA,EAAK,CAAA,EAAG,KAAA,EAAO,IAAA,IAAQ,OAAO,CAAA,KAAA,CAAA;AAAA,kBAC9B,QAAA,EAAQ,IAAA;AAAA,kBACR,KAAA,EAAO,GAAA;AAAA,kBACP,MAAA,EAAQ;AAAA;AAAA,eACV,EACF,CAAA;AAAA,kCACC,UAAA,EAAA,EAAW,SAAA,EAAU,SAAA,EAAW,QAAA,EAAA,KAAA,EAAO,QAAQ,OAAA,EAAQ;AAAA,aAAA,EAC1D,CAAA;AAAA,gCACC,YAAA,EAAA,EAAS;AAAA,WAAA,EACZ,CAAA;AAAA,0BACA,IAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,sCAAA,EACb,QAAA,EAAA;AAAA,4BAAA,GAAA,CAAC,iBAAc,UAAA,EAAU,IAAA,EAAC,UAAA,EAAU,IAAA,EAAC,WAAU,YAAA,EAAa,CAAA;AAAA,4BAC5D,GAAA,CAAC,gBAAA,EAAA,EAAiB,SAAA,EAAU,8BAAA,EAC1B,QAAA,kBAAA,GAAA,CAAC,OAAE,IAAA,EAAK,MAAA,EAAO,SAAA,EAAU,0CAAA,EAA2C,CAAA,EACtE;AAAA,WAAA,EACF;AAAA,SAAA,EACF,GACF,CAAA,EACF;AAAA;AAAA,KACF;AAAA,oBAGA,GAAA,CAAC,kBAAW,MAAA,EAAQ,gBAAA,EAAkB,SAAS,MAAM,mBAAA,CAAoB,KAAK,CAAA,EAAG,CAAA;AAAA,oBACjF,GAAA,CAAC,QAAA,EAAA,EAAS,IAAA,EAAK,YAAA,EAAa;AAAA,GAAA,EAC9B,CAAA;AAEJ","file":"chunk-63WNORBK.js","sourcesContent":["import { lazy } from 'react';\n\n/**\n * Lazy-loaded navigation components\n * Use these for code-splitting navigation sections\n */\nexport const LazyMainMenu = lazy(() => import('./MainMenu').then((m) => ({ default: m.MainMenu })));\n\nexport const LazyMobileMenu = lazy(() =>\n import('./MobileMenu').then((m) => ({ default: m.MobileMenu }))\n);\n","import { useState } from 'react';\nimport { useIsHome } from '../../providers/NavigationProvider';\nimport { SallaAdvertisement } from '@salla.sa/twilight-components-react/advertisement';\nimport { SallaCartSummary } from '@salla.sa/twilight-components-react/cart-summary';\nimport { SallaContacts } from '@salla.sa/twilight-components-react/contacts';\nimport { SallaLocalizationModal } from '@salla.sa/twilight-components-react/localization-modal';\nimport { SallaMenu } from '@salla.sa/twilight-components-react/menu';\nimport { SallaSearch } from '@salla.sa/twilight-components-react/search';\nimport { SallaUserMenu } from '@salla.sa/twilight-components-react/user-menu';\nimport { useTwilight } from '../../providers/twilight-context';\nimport { useTranslation } from '../../providers/I18nProvider';\nimport { HookSlot } from '../../hooks/HookSlot';\nimport { MainMenu, MobileMenu } from '../navigation';\nimport { Image } from '../common';\nimport type { Cart } from '../../types';\n\ninterface HeaderProps {\n cart?: Cart;\n}\n\nexport function Header(_props: HeaderProps) {\n const { currency, theme, store } = useTwilight();\n const { locale, languageName } = useTranslation();\n const settings = theme?.settings || {};\n const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);\n\n // Check if we're on homepage\n const isHomepage = useIsHome();\n\n const StoreTitle = isHomepage ? 'h1' : 'span';\n\n return (\n <header className=\"store-header\" suppressHydrationWarning>\n <HookSlot name=\"header:start\" />\n <div className=\"advertisement-slot\">\n <SallaAdvertisement />\n </div>\n {/* Top Nav */}\n <div className={`top-navbar${settings.topnav_is_dark ? ' top-navbar--dark' : ''}`}>\n <div className=\"container flex justify-between\">\n <div className=\"flex-1 flex items-center gap-2\">\n {/* Footer Menu */}\n {settings.important_links && <SallaMenu source=\"footer\" topnav />}\n\n {/* Language & Currency */}\n <div className=\"header-buttons\">\n {(store?.settings?.is_multilingual || store?.settings?.currencies_enabled) && (\n <>\n <button\n type=\"button\"\n onClick={() => window.salla?.event.dispatch('localization::open')}\n className=\"btn--rounded-gray basis-0\"\n >\n <span>{languageName}</span>\n <span className=\"mx-1.5\">|</span>\n <span className={`flag iti__flag iti__${store?.country.toLowerCase()}`}></span>\n\n <span>\n {store?.settings?.use_sar_symbol && currency?.code === 'SAR' ? (\n <i className=\"sicon-sar\"></i>\n ) : (\n <>{currency?.symbol}</>\n )}\n </span>\n </button>\n {/* TODO:: support switch the lang without hit the web API, by set it in the sdk and local storage */}\n {/* TODO:: Support switch the curency without hit the web API, by set it in the sdk and local storage */}\n <SallaLocalizationModal\n language={locale}\n currency={currency?.code || 'SAR'}\n suppressHydrationWarning\n />\n </>\n )}\n </div>\n\n {/* Scopes / Branches */}\n {store?.scope && (\n <button\n type=\"button\"\n className=\"btn--rounded-gray\"\n onClick={() =>\n window.salla?.event.dispatch('scopes::open', {\n mode: 'default',\n })\n }\n >\n <i className=\"sicon-location rtl:ml-1 ltr:mr-1\"></i>\n {store.scope.name}\n </button>\n )}\n\n {/* Search bar */}\n <div className=\"header-search flex-1\">\n {/* todo:: use a search icon insted with open the search popup */}\n <SallaSearch inline oval height={36} />\n </div>\n </div>\n\n <SallaContacts contacts={store?.contacts} contactsTitle=\"N/A\" isHeader />\n </div>\n </div>\n\n {/* Main Nav */}\n <div\n id=\"mainnav\"\n className={`main-nav-container shadow-default bg-white flex items-center relative z-50${settings.header_is_sticky ? ' sticky top-0' : ''}`}\n >\n <div className=\"inner bg-inherit w-full\">\n <div className=\"container\">\n <div className=\"flex items-stretch justify-between relative\">\n <div className=\"flex items-center\">\n <a\n className=\"lg:hidden mburger mburger--collapse leading-none rtl:ml-4 ltr:mr-4\"\n href=\"#mobile-menu\"\n aria-label=\"Open-menu\"\n onClick={(e) => {\n e.preventDefault();\n setIsMobileMenuOpen(true);\n }}\n >\n <i className=\"sicon-menu text-primary text-2xl\"></i>\n </a>\n <a className=\"navbar-brand\" href={store?.url || '/'}>\n <div className=\"logo-wrapper\">\n <Image\n src={store?.logo}\n alt={`${store?.name || 'Store'} logo`}\n priority\n width={120}\n height={48}\n />\n </div>\n <StoreTitle className=\"sr-only\">{store?.name || 'Store'}</StoreTitle>\n </a>\n <MainMenu />\n </div>\n <div className=\"flex items-center justify-end my-2.5\">\n <SallaUserMenu avatarOnly showHeader className=\"header-btn\" />\n <SallaCartSummary className=\"ml-4 rtl:ml-[unset] rtl:mr-4\">\n <i slot=\"icon\" className=\"header-btn__icon icon sicon-shopping-bag\"></i>\n </SallaCartSummary>\n </div>\n </div>\n </div>\n </div>\n </div>\n\n {/* Mobile Menu */}\n <MobileMenu isOpen={isMobileMenuOpen} onClose={() => setIsMobileMenuOpen(false)} />\n <HookSlot name=\"header:end\" />\n </header>\n );\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// src/utils/fast-checkout.ts
|
|
2
|
+
var FAST_CHECKOUT_SCRIPT_ID = "fast-checkout-js";
|
|
3
|
+
var FAST_CHECKOUT_SCRIPT_URL = "https://cdn.assets.salla.network/mini-checkout/widget/widget.esm.js?v=0.0.9";
|
|
4
|
+
|
|
5
|
+
export { FAST_CHECKOUT_SCRIPT_ID, FAST_CHECKOUT_SCRIPT_URL };
|
|
6
|
+
//# sourceMappingURL=chunk-6IATCGID.js.map
|
|
7
|
+
//# sourceMappingURL=chunk-6IATCGID.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/fast-checkout.ts"],"names":[],"mappings":";AACO,IAAM,uBAAA,GAA0B;AAChC,IAAM,wBAAA,GACX","file":"chunk-6IATCGID.js","sourcesContent":["/** `salla-add-product-button` only renders its quick-buy widget when a script with this id exists. */\nexport const FAST_CHECKOUT_SCRIPT_ID = 'fast-checkout-js';\nexport const FAST_CHECKOUT_SCRIPT_URL =\n 'https://cdn.assets.salla.network/mini-checkout/widget/widget.esm.js?v=0.0.9';\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { escapeForInlineScript } from './chunk-
|
|
1
|
+
import { escapeForInlineScript } from './chunk-JBXTU5NM.js';
|
|
2
2
|
|
|
3
3
|
// src/utils/app-scope.ts
|
|
4
4
|
var isBrowser = typeof window !== "undefined";
|
|
@@ -132,5 +132,5 @@ function renderThemeHookSlotsScript(names = getRegisteredThemeHookSlots()) {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
export { applyAppScopeMocks, applyThemeHookSlots, installAppScope, registerThemeHookSlots, renderAppScopeInstallScript, renderThemeHookSlotsScript };
|
|
135
|
-
//# sourceMappingURL=chunk-
|
|
136
|
-
//# sourceMappingURL=chunk-
|
|
135
|
+
//# sourceMappingURL=chunk-6KI2QCPL.js.map
|
|
136
|
+
//# sourceMappingURL=chunk-6KI2QCPL.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/app-scope.ts","../src/utils/theme-hook-slots.ts"],"names":[],"mappings":";;;AAGA,IAAM,SAAA,GAAY,OAAO,MAAA,KAAW,WAAA;AA2B7B,IAAM,qBAAA,GAAgD,CAAC,CAAA,EAAG,MAAA,KAAW;AAC1E,EAAA,MAAM,QAAA,GAAW,CAAC,GAAA,KAChB,OAAO,QAAQ,QAAA,IAAY,GAAA,CAAI,OAAA,CAAQ,MAAM,CAAA,KAAM,CAAA;AACrD,EAAA,MAAM,SAAA,GAAY,CAAC,GAAA,KAAwB,GAAA,CAAI,MAAM,CAAC,CAAA;AACtD,EAAA,MAAM,YAAY,MAA+B,CAAA,CAAE,KAAA,IAAS,CAAA,CAAE,SAAS,EAAC;AACxE,EAAA,MAAM,UAAA,GAAa,MAChB,SAAA,EAAU,CAAE,UAAsC,EAAC;AACtD,EAAA,MAAM,WAAA,GAAc,CAAC,GAAA,EAA8B,IAAA,KAAmC;AACpF,IAAA,MAAM,MAAA,GAAS,IAAI,IAAc,CAAA;AACjC,IAAA,OAAO,OAAO,MAAA,KAAW,UAAA,GAAa,MAAA,CAAO,IAAA,CAAK,GAAG,CAAA,GAAI,MAAA;AAAA,EAC3D,CAAA;AAEA,EAAA,MAAM,cAAA,GAAiB,CAAC,OAAA,KAA8B;AACpD,IAAA,MAAM,MAAA,GAAS,MAAqB,MAA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AAC1C,EAAA,IAAI,OAAO,MAAA,KAAW,WAAA,IAAe,UAAA,CAAW,SAAS,CAAA,EAAG;AAC5D,EAAA,IAAI,SAAA,MAAe,UAAA,EAAY;AAE/B,EAAA,UAAA,GAAa,IAAA;AACb,EAAA,MAAA,CAAO,gBAAA,CAAiB,uBAAuB,MAAM,KAAK,WAAU,EAAG,EAAE,IAAA,EAAM,IAAA,EAAM,CAAA;AACvF;AAGO,SAAS,2BAAA,GAAwC;AACtD,EAAA,OAAO,CAAC,GAAG,UAAU,CAAA;AACvB;AAeO,SAAS,0BAAA,CAA2B,KAAA,GAAkB,2BAAA,EAA4B,EAAG;AAC1F,EAAA,IAAI,CAAC,KAAA,CAAM,MAAA,EAAQ,OAAO,IAAA;AAC1B,EAAA,MAAM,IAAA,GAAO,qBAAA,CAAsB,IAAA,CAAK,SAAA,CAAU,KAAK,CAAC,CAAA;AACxD,EAAA,OACE,wUASM,IAAI,CAAA,EAAA,CAAA;AAEd","file":"chunk-LG556DIE.js","sourcesContent":["import type { SallaSDK } from '../types/salla-sdk';\nimport { escapeForInlineScript } from './inline-script';\n\nconst isBrowser = typeof window !== 'undefined';\n\n/** One app's private `app.*` bag, keyed without the `app.` prefix (`app.color` → `color`). */\nexport type AppConfigBag = Record<string, unknown>;\n\n/** One public `app.*` bucket per app, keyed by appScopeId. Everything else is read from the\n * real `salla.config` at runtime. */\nexport interface AppScopeContexts {\n apps: Record<string, AppConfigBag>;\n}\n\n/** Builds the `scopeId → sandboxed SDK` factory over a live bucket bag. */\nexport type AppScopeFactoryBuilder = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n w: any,\n appCtx: Record<string, AppConfigBag>\n) => (scopeId: string) => SallaSDK;\n\n/**\n * The sandbox itself: proxies that resolve `app.*` against the app's own bucket and pass\n * everything else through to the real SDK.\n *\n * MUST stay self-contained (only `Object`/`Proxy` and its two arguments): it is serialized via\n * `.toString()` next to {@link appScopeBootstrap} and handed in as an argument, so anything it\n * closed over at module scope would be undefined in the inline head copy. Split out from the\n * bootstrap purely to keep both halves reviewable.\n */\nexport const createAppScopeFactory: AppScopeFactoryBuilder = (w, appCtx) => {\n const isAppKey = (key: unknown): key is string =>\n typeof key === 'string' && key.indexOf('app.') === 0;\n const bucketKey = (key: string): string => key.slice(4);\n const realSalla = (): Record<string, unknown> => w.salla || w.Salla || {};\n const realConfig = (): Record<string, unknown> =>\n (realSalla().config as Record<string, unknown>) || {};\n const passthrough = (obj: Record<string, unknown>, prop: string | symbol): unknown => {\n const member = obj[prop as string];\n return typeof member === 'function' ? member.bind(obj) : member;\n };\n\n const createAppScope = (scopeId: string): SallaSDK => {\n const bucket = (): AppConfigBag => (appCtx[scopeId] = appCtx[scopeId] || {});\n\n const getConfig = (key: string, fallback?: unknown): unknown => {\n if (isAppKey(key)) {\n const sub = bucketKey(key);\n const b = bucket();\n // `app.*` miss returns the caller default, never the real config — a missing app\n // setting must not resolve to a same-named global.\n return sub in b ? b[sub] : fallback;\n }\n const cfg = realConfig();\n return typeof cfg.get === 'function'\n ? (cfg.get as (k: string, d?: unknown) => unknown)(key, fallback)\n : fallback;\n };\n\n const setConfig = (key: string, value: unknown): unknown => {\n if (isAppKey(key)) {\n bucket()[bucketKey(key)] = value;\n return value;\n }\n const cfg = realConfig();\n return typeof cfg.set === 'function'\n ? (cfg.set as (k: string, v: unknown) => unknown)(key, value)\n : value;\n };\n\n const hasConfig = (key: string): boolean =>\n isAppKey(key) ? bucketKey(key) in bucket() : key in realConfig();\n\n const configProxy = new Proxy({} as Record<string, unknown>, {\n get(_t, prop) {\n if (prop === 'get') return getConfig;\n if (prop === 'set') return setConfig;\n if (prop === 'has') return hasConfig;\n if (isAppKey(prop)) return getConfig(prop);\n return passthrough(realConfig(), prop);\n },\n set(_t, prop, value) {\n setConfig(prop as string, value);\n return true;\n },\n has(_t, prop) {\n return hasConfig(prop as string);\n },\n });\n\n return new Proxy({} as Record<string, unknown>, {\n get(_t, prop) {\n return prop === 'config' ? configProxy : passthrough(realSalla(), prop);\n },\n set(_t, prop, value) {\n // Reassigning `salla.config` wholesale would escape the sandbox; swallow it.\n if (prop === 'config') return true;\n realSalla()[prop as string] = value;\n return true;\n },\n }) as unknown as SallaSDK;\n };\n\n return createAppScope;\n};\n\n/**\n * Installs `window.Salla.appScope`, seeded with `contexts` and sandboxed by `makeFactory`.\n *\n * MUST stay self-contained (only `window`/`Object` and its arguments): it's serialized via\n * `.toString()` and inlined into the SSR head so the factory exists at parse time — before the\n * SDK init/hydration a CDN snippet's `onReady` races, else it throws `Salla.appScope is not a\n * function`. `makeFactory` is passed in rather than imported for exactly that reason. Also\n * called directly by `installAppScope` (tests/fallback).\n *\n * Idempotent: the factory is first-write-wins, while buckets are merged per scope (also\n * first-write-wins) so a later call can seed scopes the first one had no data for. `appCtx` is\n * closure-private (namespacing, not security: buckets are public-only and the boundary is\n * server-side).\n */\nexport function appScopeBootstrap(\n contexts: AppScopeContexts,\n makeFactory: AppScopeFactoryBuilder\n): void {\n if (typeof window === 'undefined') return;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const w = window as any;\n const Salla = (w.Salla = w.Salla || {});\n if (Salla.appScope) {\n // Already installed (normally by the inline head copy). The factory is first-write-wins,\n // but buckets are not: the head may have installed with none of them — the settings\n // endpoint can fail or lag behind the snippets one — so hand them to the existing install.\n if (Salla.__appScopeSeed) Salla.__appScopeSeed(contexts);\n return;\n }\n\n // Live bag + pristine snapshot (for mock overlays). Copy, don't alias: a snippet may\n // `config.set('app.x')` and the payload can be a cached response.\n const appCtx: Record<string, AppConfigBag> = {};\n const base: Record<string, AppConfigBag> = {};\n // Which scopes already got their real bucket, so a later seed can't overwrite one.\n const seeded: Record<string, boolean> = {};\n const seed = (next: AppScopeContexts): void => {\n const bags = (next && next.apps) || {};\n Object.keys(bags).forEach((scopeId) => {\n if (seeded[scopeId]) return;\n seeded[scopeId] = true;\n appCtx[scopeId] = Object.assign({}, appCtx[scopeId] || {}, bags[scopeId] || {});\n base[scopeId] = Object.assign({}, appCtx[scopeId]);\n });\n };\n seed(contexts);\n\n const createAppScope = makeFactory(w, appCtx);\n Salla.appScope = (scopeId: string): SallaSDK => createAppScope(scopeId);\n\n // Fill in buckets for scopes not seeded yet (first-write-wins per scope). Lets the head\n // install the factory unconditionally — at parse time, before any snippet's onReady — and\n // still pick up buckets that only the client managed to fetch.\n Salla.__appScopeSeed = (next: AppScopeContexts): void => seed(next);\n\n // Overlay preview mocks onto an app's pristine baseline, so fields the partner did not mock\n // keep their real values. Returns false for an unknown scope or before install.\n Salla.__appScopeMock = (scopeId: string, mocks: AppConfigBag): boolean => {\n if (!(scopeId in base)) return false;\n appCtx[scopeId] = Object.assign({}, base[scopeId], mocks);\n return true;\n };\n}\n\n/** Overlay preview mocks onto one app's bucket (over its pristine values). Delegates to the\n * bootstrap's `__appScopeMock`, so it works for both install paths. False if unknown/uninstalled. */\nexport function applyAppScopeMocks(appScopeId: string, mocks: AppConfigBag): boolean {\n if (!isBrowser) return false;\n const mock = (window.Salla as unknown as { __appScopeMock?: MockApplier } | undefined)\n ?.__appScopeMock;\n return mock?.(appScopeId, mocks) ?? false;\n}\n\ntype MockApplier = (appScopeId: string, mocks: AppConfigBag) => boolean;\n\n/** Serialize the installer into an inline `<script>` body seeded with `contexts` — both halves\n * via `.toString()`, hence their self-contained requirement. See `rootHead`. */\nexport function renderAppScopeInstallScript(contexts: AppScopeContexts): string {\n // Bucket values are partner-set, so escape the JSON seed against a `</script>` breakout.\n // The function sources have no `<`, so they need no escaping.\n const json = escapeForInlineScript(JSON.stringify(contexts));\n return `(${appScopeBootstrap.toString()})(${json},${createAppScopeFactory.toString()});`;\n}\n\n/** Install `Salla.appScope` on the client, or seed buckets into the inline SSR head copy that\n * already installed it. No-op on the server. Fallback for unseeded loads + the unit-test entry\n * point. */\nexport function installAppScope(contexts: AppScopeContexts): void {\n if (!isBrowser) return;\n appScopeBootstrap(contexts, createAppScopeFactory);\n}\n","import { escapeForInlineScript } from './inline-script';\n\nconst registered = new Set<string>();\n\nlet retryArmed = false;\n\n/**\n * Declare hook slots the theme renders itself so apps may mount into them.\n *\n * The SDK rejects `mount()` for any name absent from its `_themeSlots` whitelist, so a theme\n * rendering its own `<salla-hook>` must register the name. Call at module scope; the engine\n * applies the names via {@link applyThemeHookSlots}.\n */\nexport function registerThemeHookSlots(...names: string[]): void {\n for (const name of names) registered.add(name);\n}\n\n/** Push the registered names in. Returns false if the SDK hasn't exposed the list yet. */\nfunction pushSlots(): boolean {\n const slots = window.salla?.hooks?._themeSlots;\n if (!Array.isArray(slots)) return false;\n for (const name of registered) if (!slots.includes(name)) slots.push(name);\n return true;\n}\n\n/**\n * Push every registered slot name into the SDK whitelist. Idempotent. Engine-only.\n *\n * The SDK's hooks module may attach after this runs, so a first no-op falls back to a\n * one-shot retry on `twilight::initiated` — still before apps mount from their own onReady.\n *\n * This is only the late backstop: the whitelist is primarily seeded at parse time by the\n * inline head script from {@link renderThemeHookSlotsScript}, because an app's snippet\n * registers its `onReady` callback before React ever hydrates.\n */\nexport function applyThemeHookSlots(): void {\n if (typeof window === 'undefined' || registered.size === 0) return;\n if (pushSlots() || retryArmed) return;\n\n retryArmed = true;\n window.addEventListener('twilight::initiated', () => void pushSlots(), { once: true });\n}\n\n/** The slot names registered so far. Read by `rootHead` when rendering the inline script. */\nexport function getRegisteredThemeHookSlots(): string[] {\n return [...registered];\n}\n\n/**\n * Serialize the whitelist push into an inline head `<script>` body, so the slots are\n * registered at parse time.\n *\n * Ordering is the whole point: CDN snippets are parser-inserted `<script defer>` tags in the\n * body, so an app's `Salla.onReady` callback is registered long before React hydrates and runs\n * {@link applyThemeHookSlots}. Whichever `twilight::initiated` listener was added first runs\n * first, so the push must be armed from the head — otherwise the SDK rejects the app's\n * `hooks.mount()` with \"Hook <name> is not allowed\" and the app never renders.\n *\n * Returns null when the theme registered no slots. Kept self-contained (only `window`) since\n * it ships as raw source, not as a bundled module.\n */\nexport function renderThemeHookSlotsScript(names: string[] = getRegisteredThemeHookSlots()) {\n if (!names.length) return null;\n const json = escapeForInlineScript(JSON.stringify(names));\n return (\n `(function(names){` +\n `var w=window;` +\n `function push(){` +\n `var h=w.salla&&w.salla.hooks;var slots=h&&h._themeSlots;` +\n `if(!Array.isArray(slots))return false;` +\n `for(var i=0;i<names.length;i++)if(slots.indexOf(names[i])<0)slots.push(names[i]);` +\n `return true}` +\n `if(push())return;` +\n `w.addEventListener('twilight::initiated',function(){push()},{once:true})` +\n `})(${json});`\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/app-scope.ts","../src/utils/theme-hook-slots.ts"],"names":[],"mappings":";;;AAGA,IAAM,SAAA,GAAY,OAAO,MAAA,KAAW,WAAA;AA2B7B,IAAM,qBAAA,GAAgD,CAAC,CAAA,EAAG,MAAA,KAAW;AAC1E,EAAA,MAAM,QAAA,GAAW,CAAC,GAAA,KAChB,OAAO,QAAQ,QAAA,IAAY,GAAA,CAAI,OAAA,CAAQ,MAAM,CAAA,KAAM,CAAA;AACrD,EAAA,MAAM,SAAA,GAAY,CAAC,GAAA,KAAwB,GAAA,CAAI,MAAM,CAAC,CAAA;AACtD,EAAA,MAAM,YAAY,MAA+B,CAAA,CAAE,KAAA,IAAS,CAAA,CAAE,SAAS,EAAC;AACxE,EAAA,MAAM,UAAA,GAAa,MAChB,SAAA,EAAU,CAAE,UAAsC,EAAC;AACtD,EAAA,MAAM,WAAA,GAAc,CAAC,GAAA,EAA8B,IAAA,KAAmC;AACpF,IAAA,MAAM,MAAA,GAAS,IAAI,IAAc,CAAA;AACjC,IAAA,OAAO,OAAO,MAAA,KAAW,UAAA,GAAa,MAAA,CAAO,IAAA,CAAK,GAAG,CAAA,GAAI,MAAA;AAAA,EAC3D,CAAA;AAEA,EAAA,MAAM,cAAA,GAAiB,CAAC,OAAA,KAA8B;AACpD,IAAA,MAAM,MAAA,GAAS,MAAqB,MAAA,CAAO,OAAO,IAAI,MAAA,CAAO,OAAO,KAAK,EAAC;AAE1E,IAAA,MAAM,SA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,EAAG;AAC5D,EAAA,IAAI,SAAA,MAAe,UAAA,EAAY;AAE/B,EAAA,UAAA,GAAa,IAAA;AACb,EAAA,MAAA,CAAO,gBAAA,CAAiB,uBAAuB,MAAM,KAAK,WAAU,EAAG,EAAE,IAAA,EAAM,IAAA,EAAM,CAAA;AACvF;AAGO,SAAS,2BAAA,GAAwC;AACtD,EAAA,OAAO,CAAC,GAAG,UAAU,CAAA;AACvB;AAeO,SAAS,0BAAA,CAA2B,KAAA,GAAkB,2BAAA,EAA4B,EAAG;AAC1F,EAAA,IAAI,CAAC,KAAA,CAAM,MAAA,EAAQ,OAAO,IAAA;AAC1B,EAAA,MAAM,IAAA,GAAO,qBAAA,CAAsB,IAAA,CAAK,SAAA,CAAU,KAAK,CAAC,CAAA;AACxD,EAAA,OACE,wUASM,IAAI,CAAA,EAAA,CAAA;AAEd","file":"chunk-6KI2QCPL.js","sourcesContent":["import type { SallaSDK } from '../types/salla-sdk';\nimport { escapeForInlineScript } from './inline-script';\n\nconst isBrowser = typeof window !== 'undefined';\n\n/** One app's private `app.*` bag, keyed without the `app.` prefix (`app.color` → `color`). */\nexport type AppConfigBag = Record<string, unknown>;\n\n/** One public `app.*` bucket per app, keyed by appScopeId. Everything else is read from the\n * real `salla.config` at runtime. */\nexport interface AppScopeContexts {\n apps: Record<string, AppConfigBag>;\n}\n\n/** Builds the `scopeId → sandboxed SDK` factory over a live bucket bag. */\nexport type AppScopeFactoryBuilder = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n w: any,\n appCtx: Record<string, AppConfigBag>\n) => (scopeId: string) => SallaSDK;\n\n/**\n * The sandbox itself: proxies that resolve `app.*` against the app's own bucket and pass\n * everything else through to the real SDK.\n *\n * MUST stay self-contained (only `Object`/`Proxy` and its two arguments): it is serialized via\n * `.toString()` next to {@link appScopeBootstrap} and handed in as an argument, so anything it\n * closed over at module scope would be undefined in the inline head copy. Split out from the\n * bootstrap purely to keep both halves reviewable.\n */\nexport const createAppScopeFactory: AppScopeFactoryBuilder = (w, appCtx) => {\n const isAppKey = (key: unknown): key is string =>\n typeof key === 'string' && key.indexOf('app.') === 0;\n const bucketKey = (key: string): string => key.slice(4);\n const realSalla = (): Record<string, unknown> => w.salla || w.Salla || {};\n const realConfig = (): Record<string, unknown> =>\n (realSalla().config as Record<string, unknown>) || {};\n const passthrough = (obj: Record<string, unknown>, prop: string | symbol): unknown => {\n const member = obj[prop as string];\n return typeof member === 'function' ? member.bind(obj) : member;\n };\n\n const createAppScope = (scopeId: string): SallaSDK => {\n const bucket = (): AppConfigBag => (appCtx[scopeId] = appCtx[scopeId] || {});\n\n const getConfig = (key: string, fallback?: unknown): unknown => {\n if (isAppKey(key)) {\n const sub = bucketKey(key);\n const b = bucket();\n // `app.*` miss returns the caller default, never the real config — a missing app\n // setting must not resolve to a same-named global.\n return sub in b ? b[sub] : fallback;\n }\n const cfg = realConfig();\n return typeof cfg.get === 'function'\n ? (cfg.get as (k: string, d?: unknown) => unknown)(key, fallback)\n : fallback;\n };\n\n const setConfig = (key: string, value: unknown): unknown => {\n if (isAppKey(key)) {\n bucket()[bucketKey(key)] = value;\n return value;\n }\n const cfg = realConfig();\n return typeof cfg.set === 'function'\n ? (cfg.set as (k: string, v: unknown) => unknown)(key, value)\n : value;\n };\n\n const hasConfig = (key: string): boolean =>\n isAppKey(key) ? bucketKey(key) in bucket() : key in realConfig();\n\n const configProxy = new Proxy({} as Record<string, unknown>, {\n get(_t, prop) {\n if (prop === 'get') return getConfig;\n if (prop === 'set') return setConfig;\n if (prop === 'has') return hasConfig;\n if (isAppKey(prop)) return getConfig(prop);\n return passthrough(realConfig(), prop);\n },\n set(_t, prop, value) {\n setConfig(prop as string, value);\n return true;\n },\n has(_t, prop) {\n return hasConfig(prop as string);\n },\n });\n\n return new Proxy({} as Record<string, unknown>, {\n get(_t, prop) {\n return prop === 'config' ? configProxy : passthrough(realSalla(), prop);\n },\n set(_t, prop, value) {\n // Reassigning `salla.config` wholesale would escape the sandbox; swallow it.\n if (prop === 'config') return true;\n realSalla()[prop as string] = value;\n return true;\n },\n }) as unknown as SallaSDK;\n };\n\n return createAppScope;\n};\n\n/**\n * Installs `window.Salla.appScope`, seeded with `contexts` and sandboxed by `makeFactory`.\n *\n * MUST stay self-contained (only `window`/`Object` and its arguments): it's serialized via\n * `.toString()` and inlined into the SSR head so the factory exists at parse time — before the\n * SDK init/hydration a CDN snippet's `onReady` races, else it throws `Salla.appScope is not a\n * function`. `makeFactory` is passed in rather than imported for exactly that reason. Also\n * called directly by `installAppScope` (tests/fallback).\n *\n * Idempotent: the factory is first-write-wins, while buckets are merged per scope (also\n * first-write-wins) so a later call can seed scopes the first one had no data for. `appCtx` is\n * closure-private (namespacing, not security: buckets are public-only and the boundary is\n * server-side).\n */\nexport function appScopeBootstrap(\n contexts: AppScopeContexts,\n makeFactory: AppScopeFactoryBuilder\n): void {\n if (typeof window === 'undefined') return;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const w = window as any;\n const Salla = (w.Salla = w.Salla || {});\n if (Salla.appScope) {\n // Already installed (normally by the inline head copy). The factory is first-write-wins,\n // but buckets are not: the head may have installed with none of them — the settings\n // endpoint can fail or lag behind the snippets one — so hand them to the existing install.\n if (Salla.__appScopeSeed) Salla.__appScopeSeed(contexts);\n return;\n }\n\n // Live bag + pristine snapshot (for mock overlays). Copy, don't alias: a snippet may\n // `config.set('app.x')` and the payload can be a cached response.\n const appCtx: Record<string, AppConfigBag> = {};\n const base: Record<string, AppConfigBag> = {};\n // Which scopes already got their real bucket, so a later seed can't overwrite one.\n const seeded: Record<string, boolean> = {};\n const seed = (next: AppScopeContexts): void => {\n const bags = (next && next.apps) || {};\n Object.keys(bags).forEach((scopeId) => {\n if (seeded[scopeId]) return;\n seeded[scopeId] = true;\n appCtx[scopeId] = Object.assign({}, appCtx[scopeId] || {}, bags[scopeId] || {});\n base[scopeId] = Object.assign({}, appCtx[scopeId]);\n });\n };\n seed(contexts);\n\n const createAppScope = makeFactory(w, appCtx);\n Salla.appScope = (scopeId: string): SallaSDK => createAppScope(scopeId);\n\n // Fill in buckets for scopes not seeded yet (first-write-wins per scope). Lets the head\n // install the factory unconditionally — at parse time, before any snippet's onReady — and\n // still pick up buckets that only the client managed to fetch.\n Salla.__appScopeSeed = (next: AppScopeContexts): void => seed(next);\n\n // Overlay preview mocks onto an app's pristine baseline, so fields the partner did not mock\n // keep their real values. Returns false for an unknown scope or before install.\n Salla.__appScopeMock = (scopeId: string, mocks: AppConfigBag): boolean => {\n if (!(scopeId in base)) return false;\n appCtx[scopeId] = Object.assign({}, base[scopeId], mocks);\n return true;\n };\n}\n\n/** Overlay preview mocks onto one app's bucket (over its pristine values). Delegates to the\n * bootstrap's `__appScopeMock`, so it works for both install paths. False if unknown/uninstalled. */\nexport function applyAppScopeMocks(appScopeId: string, mocks: AppConfigBag): boolean {\n if (!isBrowser) return false;\n const mock = (window.Salla as unknown as { __appScopeMock?: MockApplier } | undefined)\n ?.__appScopeMock;\n return mock?.(appScopeId, mocks) ?? false;\n}\n\ntype MockApplier = (appScopeId: string, mocks: AppConfigBag) => boolean;\n\n/** Serialize the installer into an inline `<script>` body seeded with `contexts` — both halves\n * via `.toString()`, hence their self-contained requirement. See `rootHead`. */\nexport function renderAppScopeInstallScript(contexts: AppScopeContexts): string {\n // Bucket values are partner-set, so escape the JSON seed against a `</script>` breakout.\n // The function sources have no `<`, so they need no escaping.\n const json = escapeForInlineScript(JSON.stringify(contexts));\n return `(${appScopeBootstrap.toString()})(${json},${createAppScopeFactory.toString()});`;\n}\n\n/** Install `Salla.appScope` on the client, or seed buckets into the inline SSR head copy that\n * already installed it. No-op on the server. Fallback for unseeded loads + the unit-test entry\n * point. */\nexport function installAppScope(contexts: AppScopeContexts): void {\n if (!isBrowser) return;\n appScopeBootstrap(contexts, createAppScopeFactory);\n}\n","import { escapeForInlineScript } from './inline-script';\n\nconst registered = new Set<string>();\n\nlet retryArmed = false;\n\n/**\n * Declare hook slots the theme renders itself so apps may mount into them.\n *\n * The SDK rejects `mount()` for any name absent from its `_themeSlots` whitelist, so a theme\n * rendering its own `<salla-hook>` must register the name. Call at module scope; the engine\n * applies the names via {@link applyThemeHookSlots}.\n */\nexport function registerThemeHookSlots(...names: string[]): void {\n for (const name of names) registered.add(name);\n}\n\n/** Push the registered names in. Returns false if the SDK hasn't exposed the list yet. */\nfunction pushSlots(): boolean {\n const slots = window.salla?.hooks?._themeSlots;\n if (!Array.isArray(slots)) return false;\n for (const name of registered) if (!slots.includes(name)) slots.push(name);\n return true;\n}\n\n/**\n * Push every registered slot name into the SDK whitelist. Idempotent. Engine-only.\n *\n * The SDK's hooks module may attach after this runs, so a first no-op falls back to a\n * one-shot retry on `twilight::initiated` — still before apps mount from their own onReady.\n *\n * This is only the late backstop: the whitelist is primarily seeded at parse time by the\n * inline head script from {@link renderThemeHookSlotsScript}, because an app's snippet\n * registers its `onReady` callback before React ever hydrates.\n */\nexport function applyThemeHookSlots(): void {\n if (typeof window === 'undefined' || registered.size === 0) return;\n if (pushSlots() || retryArmed) return;\n\n retryArmed = true;\n window.addEventListener('twilight::initiated', () => void pushSlots(), { once: true });\n}\n\n/** The slot names registered so far. Read by `rootHead` when rendering the inline script. */\nexport function getRegisteredThemeHookSlots(): string[] {\n return [...registered];\n}\n\n/**\n * Serialize the whitelist push into an inline head `<script>` body, so the slots are\n * registered at parse time.\n *\n * Ordering is the whole point: CDN snippets are parser-inserted `<script defer>` tags in the\n * body, so an app's `Salla.onReady` callback is registered long before React hydrates and runs\n * {@link applyThemeHookSlots}. Whichever `twilight::initiated` listener was added first runs\n * first, so the push must be armed from the head — otherwise the SDK rejects the app's\n * `hooks.mount()` with \"Hook <name> is not allowed\" and the app never renders.\n *\n * Returns null when the theme registered no slots. Kept self-contained (only `window`) since\n * it ships as raw source, not as a bundled module.\n */\nexport function renderThemeHookSlotsScript(names: string[] = getRegisteredThemeHookSlots()) {\n if (!names.length) return null;\n const json = escapeForInlineScript(JSON.stringify(names));\n return (\n `(function(names){` +\n `var w=window;` +\n `function push(){` +\n `var h=w.salla&&w.salla.hooks;var slots=h&&h._themeSlots;` +\n `if(!Array.isArray(slots))return false;` +\n `for(var i=0;i<names.length;i++)if(slots.indexOf(names[i])<0)slots.push(names[i]);` +\n `return true}` +\n `if(push())return;` +\n `w.addEventListener('twilight::initiated',function(){push()},{once:true})` +\n `})(${json});`\n );\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { user } from './chunk-
|
|
2
|
-
import { getTwilightContext } from './chunk-
|
|
1
|
+
import { user } from './chunk-RIZOT5FN.js';
|
|
2
|
+
import { getTwilightContext } from './chunk-6XWMNQ52.js';
|
|
3
3
|
import { useQuery } from '@tanstack/react-query';
|
|
4
4
|
|
|
5
5
|
function useUser() {
|
|
@@ -13,5 +13,5 @@ function useUser() {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export { useUser };
|
|
16
|
-
//# sourceMappingURL=chunk-
|
|
17
|
-
//# sourceMappingURL=chunk-
|
|
16
|
+
//# sourceMappingURL=chunk-6MGDRMZM.js.map
|
|
17
|
+
//# sourceMappingURL=chunk-6MGDRMZM.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/useUser.ts"],"names":[],"mappings":";;;;AAUO,SAAS,OAAA,GAAyB;AACvC,EAAA,MAAM,KAAA,GAAQ,oBAAmB,CAAE,SAAA;AAEnC,EAAA,MAAM,QAAQ,QAAA,CAAS;AAAA,IACrB,GAAG,IAAA,CAAK,OAAA,CAAQ,OAAA,EAAQ;AAAA,IACxB,OAAA,EAAS,CAAC,CAAC,KAAA;AAAA,IACX,eAAA,EAAiB;AAAA,GAClB,CAAA;AAED,EAAA,OAAO,EAAE,GAAG,KAAA,EAAO,UAAA,EAAY,CAAC,CAAC,KAAA,EAAM;AACzC","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useUser.ts"],"names":[],"mappings":";;;;AAUO,SAAS,OAAA,GAAyB;AACvC,EAAA,MAAM,KAAA,GAAQ,oBAAmB,CAAE,SAAA;AAEnC,EAAA,MAAM,QAAQ,QAAA,CAAS;AAAA,IACrB,GAAG,IAAA,CAAK,OAAA,CAAQ,OAAA,EAAQ;AAAA,IACxB,OAAA,EAAS,CAAC,CAAC,KAAA;AAAA,IACX,eAAA,EAAiB;AAAA,GAClB,CAAA;AAED,EAAA,OAAO,EAAE,GAAG,KAAA,EAAO,UAAA,EAAY,CAAC,CAAC,KAAA,EAAM;AACzC","file":"chunk-6MGDRMZM.js","sourcesContent":["import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { getTwilightContext } from '../twilight/context';\nimport { user } from '../api/user';\nimport type { User } from '../types';\n\nexport type UseUserReturn = UseQueryResult<User | null> & {\n /** True when an auth token exists (regardless of query state). */\n isLoggedIn: boolean;\n};\n\nexport function useUser(): UseUserReturn {\n const token = getTwilightContext().authToken;\n\n const query = useQuery({\n ...user.queries.current(),\n enabled: !!token,\n placeholderData: null,\n });\n\n return { ...query, isLoggedIn: !!token };\n}\n"]}
|
|
@@ -51,6 +51,7 @@ var DEFAULT_DATA = {
|
|
|
51
51
|
authToken: null,
|
|
52
52
|
scope: null,
|
|
53
53
|
storeId: null,
|
|
54
|
+
versionId: null,
|
|
54
55
|
requestHost: null,
|
|
55
56
|
i18n: void 0,
|
|
56
57
|
page: void 0
|
|
@@ -88,6 +89,8 @@ function mergeIntoStore(store, partial) {
|
|
|
88
89
|
store.scope = partial.scopeId == null ? null : { id: partial.scopeId };
|
|
89
90
|
if ("storeId" in partial && partial.storeId !== void 0)
|
|
90
91
|
store.storeId = partial.storeId ?? null;
|
|
92
|
+
if ("versionId" in partial && partial.versionId !== void 0)
|
|
93
|
+
store.versionId = partial.versionId ?? null;
|
|
91
94
|
if ("requestHost" in partial && partial.requestHost !== void 0)
|
|
92
95
|
store.requestHost = partial.requestHost ?? null;
|
|
93
96
|
if ("i18n" in partial && partial.i18n != null) store.i18n = partial.i18n;
|
|
@@ -128,9 +131,9 @@ function hasTwilightSettings() {
|
|
|
128
131
|
function getRequestStore() {
|
|
129
132
|
try {
|
|
130
133
|
const data = getTwilightStore();
|
|
131
|
-
return { storeId: data.storeId, requestHost: data.requestHost };
|
|
134
|
+
return { storeId: data.storeId, versionId: data.versionId, requestHost: data.requestHost };
|
|
132
135
|
} catch {
|
|
133
|
-
return { storeId: null, requestHost: null };
|
|
136
|
+
return { storeId: null, versionId: null, requestHost: null };
|
|
134
137
|
}
|
|
135
138
|
}
|
|
136
139
|
function getTwilightContext() {
|
|
@@ -164,6 +167,9 @@ function getTwilightContext() {
|
|
|
164
167
|
get storeId() {
|
|
165
168
|
return data.storeId;
|
|
166
169
|
},
|
|
170
|
+
get versionId() {
|
|
171
|
+
return data.versionId;
|
|
172
|
+
},
|
|
167
173
|
get requestHost() {
|
|
168
174
|
return data.requestHost;
|
|
169
175
|
},
|
|
@@ -193,5 +199,5 @@ function getTwilightContext() {
|
|
|
193
199
|
}
|
|
194
200
|
|
|
195
201
|
export { SettingsError, createI18nInstance, getRequestStore, getTwilightContext, hasTwilightSettings, runWithTwilightContext, subscribeTwilight, updateTwilightContext };
|
|
196
|
-
//# sourceMappingURL=chunk-
|
|
197
|
-
//# sourceMappingURL=chunk-
|
|
202
|
+
//# sourceMappingURL=chunk-6XWMNQ52.js.map
|
|
203
|
+
//# sourceMappingURL=chunk-6XWMNQ52.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/errors.ts","../src/providers/i18n-factory.ts","../src/twilight/context.ts"],"names":[],"mappings":";;;;;;AAAO,IAAM,aAAA,GAAN,cAA4B,KAAA,CAAM;AAAA,EACvC,YAAY,OAAA,EAAkB;AAC5B,IAAA,KAAA,CAAM,WAAW,qCAAqC,CAAA;AACtD,IAAA,IAAA,CAAK,IAAA,GAAO,eAAA;AAAA,EACd;AACF;ACOO,SAAS,kBAAA,CACd,MAAA,EACA,YAAA,EACA,iBAAA,EACc;AACd,EAAA,MAAM,WAAW,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;AACT,MAAA,IAAI,CAAC,KAAK,IAAA,EAAM;AACd,QAAA,MAAM,eAAe,IAAA,CAAK,WAAA,EAAa,YAAA,CAAa,CAAC,cAAc,CAAC,CAAA;AAEpE,QAAA,IAAA,CAAK,IAAA,GAAO,kBAAA,CAAmB,IAAA,CAAK,MAAA,EAAQ,YAAY,CAAA;AAAA,MAC1D;AACA,MAAA,OAAO,IAAA,CAAK,IAAA;AAAA,IACd,CAAA;AAAA,IACA,IAAI,GAAA,GAAM;AACR,MAAA,OAAO,eAAA,CAAgB,IAAA,CAAK,MAAM,CAAA,CAAE,GAAA;AAAA,IACtC,CAAA;AAAA,IACA,IAAI,IAAA,GAAO;AACT,MAAA,OAAO,IAAA,CAAK,IAAA;AAAA,IACd,CAAA;AAAA,IACA,IAAI,YAAA,GAAe;AACjB,MAAA,OAAO,IAAA,CAAK,YAAA;AAAA,IACd,CAAA;AAAA,IACA,IAAI,YAAA,GAAe;AACjB,MAAA,OAAO,IAAA,CAAK,YAAA;AAAA,IACd,CAAA;AAAA,IACA,IAAI,MAAA,GAAS;AACX,MAAA,OAAO,IAAA,CAAK,MAAA;AAAA,IACd;AAAA,GACF;AACF","file":"chunk-6XWMNQ52.js","sourcesContent":["export class SettingsError extends Error {\n constructor(message?: string) {\n super(message ?? 'Store settings could not be loaded.');\n this.name = 'SettingsError';\n }\n}\n","import { createInstance, type i18n as I18nInstance } from 'i18next';\nimport { initReactI18next } from 'react-i18next';\n\nexport type TranslationMessages = Record<string, Record<string, string>>;\n\n/**\n * Creates a new i18next instance for the given locale.\n *\n * @param locale - Active locale code, e.g. `'ar'`\n * @param translations - App translations from the Salla API (store-specific)\n * @param themeTranslations - Bundled theme translations (static defaults)\n */\nexport function createI18nInstance(\n locale: string,\n translations?: TranslationMessages,\n themeTranslations?: TranslationMessages\n): I18nInstance {\n const instance = createInstance();\n const transKey = `${locale}.trans`;\n\n instance.use(initReactI18next).init({\n lng: locale,\n fallbackLng: locale,\n ns: ['app', 'theme'],\n defaultNS: 'app',\n fallbackNS: 'theme',\n resources: {\n [locale]: {\n app: translations?.[transKey] ?? {},\n theme: themeTranslations?.[transKey] ?? {},\n },\n },\n interpolation: { escapeValue: false },\n react: { useSuspense: false },\n keySeparator: '.',\n nsSeparator: false,\n });\n\n return instance;\n}\n\n/**\n * Creates i18n instance for testing\n * @param locale - Locale code (default: 'ar')\n * @param translations - Optional translations\n */\nexport function createTestI18n(locale = 'ar', translations?: TranslationMessages): I18nInstance {\n return createI18nInstance(locale, translations);\n}\n","import type { QueryClient } from '@tanstack/react-query';\nimport type { i18n } from 'i18next';\nimport type { StoreContext } from '../api/store';\nimport type { AppSnippet, AppSettings } from '../api/apps';\nimport { FALLBACK_LOCALE, getLanguageInfo } from '../providers/locale-constants';\nimport type { TranslationMessages } from '../providers/i18n-factory';\nimport { createI18nInstance } from '../providers/i18n-factory';\nimport { SettingsError } from '../utils/errors';\nimport type { ActiveScope } from '../utils/cookies';\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface TwilightLocation<TSearch = Record<string, unknown>> {\n href: string;\n pathname: string;\n search: TSearch;\n searchStr: string;\n state: Record<string, unknown>;\n hash: string;\n}\n\nexport interface PageContext {\n slug: string;\n id?: string | number;\n title: string;\n url?: string;\n parent?: { id: string | number; name: string; url: string } | null;\n breadcrumbs?: { name: string; url: string }[];\n}\n\nexport interface TwilightContext {\n queryClient: QueryClient;\n settings: StoreContext;\n locale: string;\n routeId: string;\n location: TwilightLocation;\n authToken: string | null;\n /**\n * The selected market and, once bullet delivery confirmed one, its branch\n * allocation — the full object the SDK sends as `s-scope-*` headers. Seeded from\n * the `scope` cookie on the server; see {@link ActiveScope}.\n */\n scope: ActiveScope | null;\n /** `scope.id`, kept for callers that only need the market. */\n scopeId: string | null;\n /**\n * Which store this request is for, when something other than the hostname says\n * so — the `?storeId=` a preview was opened with, or the cookie remembering it.\n *\n * Null on a live storefront, where the hostname is the answer and there is\n * nothing to carry. See {@link resolveRequestStoreId}.\n */\n storeId: string | null;\n /**\n * Which version of the theme's settings this request asked for — the\n * `?versionId=` an editor preview or a local dev session was opened with, or\n * the cookie remembering it.\n *\n * Null on an ordinary storefront visit, which is the common case: nothing\n * named a version, so the store's live one is what the API answers with. See\n * {@link resolveRequestVersionId}.\n */\n versionId: string | null;\n /**\n * The host this request arrived on, captured server-side.\n *\n * A theme worker is deployed with no vars and no bindings, so the request is\n * the only thing that knows which storefront it is serving. On the client this\n * is `window.location.host`; on the server nothing else has it.\n */\n requestHost: string | null;\n i18n: i18n;\n dir: 'ltr' | 'rtl';\n page?: PageContext;\n /** Installed apps' snippets, fetched in rootBeforeLoad so AppsSnippets can render CDN\n * <script> tags during SSR (React Query isn't dehydrated here, so useQuery has no SSR data). */\n appsSnippets?: AppSnippet[];\n /** Per-app public `app.*` buckets, fetched in rootBeforeLoad so rootHead can install the\n * `Salla.appScope` factory inline at parse time — ahead of the snippets' onReady callbacks. */\n appsSettings?: AppSettings;\n extras?: Record<string, unknown>;\n}\n\n// ============================================================================\n// Internal Store\n// ============================================================================\n\nconst DEFAULT_LOCATION: TwilightLocation = {\n href: '',\n pathname: '',\n search: {},\n searchStr: '',\n state: {},\n hash: '',\n};\n\ninterface ContextData {\n queryClient: QueryClient;\n settings: StoreContext | null;\n locale: string;\n routeId: string;\n location: TwilightLocation;\n authToken: string | null;\n scope: ActiveScope | null;\n storeId: string | null;\n versionId: string | null;\n requestHost: string | null;\n i18n?: i18n;\n page?: PageContext;\n appsSnippets?: AppSnippet[];\n appsSettings?: AppSettings;\n extras?: Record<string, unknown>;\n}\n\nconst DEFAULT_DATA: ContextData = {\n queryClient: null as unknown as QueryClient,\n settings: null,\n locale: FALLBACK_LOCALE,\n routeId: '',\n location: { ...DEFAULT_LOCATION },\n authToken: null,\n scope: null,\n storeId: null,\n versionId: null,\n requestHost: null,\n i18n: undefined,\n page: undefined,\n};\n\n// ============================================================================\n// Storage: AsyncLocalStorage (server) or module-level store (client)\n// ============================================================================\n\ntype AsyncLocalStore<T> = { getStore(): T | undefined; run(val: T, fn: () => unknown): unknown };\n\n// Initialize ALS at module load time for SSR — no race condition\nlet _als: AsyncLocalStore<ContextData> | null = null;\nif (typeof window === 'undefined') {\n try {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { AsyncLocalStorage } = require('node:async_hooks') as {\n AsyncLocalStorage: new <T>() => AsyncLocalStore<T>;\n };\n _als = new AsyncLocalStorage<ContextData>();\n } catch {\n _als = null;\n }\n}\n\nconst clientStore: ContextData = { ...DEFAULT_DATA };\n\nfunction getTwilightStore(): ContextData {\n if (_als) {\n const store = _als.getStore();\n if (!store)\n throw new Error('[Twilight] No request context. Wrap with runWithTwilightContext().');\n return store;\n }\n return clientStore;\n}\n\nfunction writableStore(): ContextData {\n if (_als) {\n const store = _als.getStore();\n if (store) return store;\n }\n return clientStore;\n}\n\nfunction mergeIntoStore(store: ContextData, partial: Partial<TwilightContext>): void {\n if ('queryClient' in partial && partial.queryClient) store.queryClient = partial.queryClient;\n if ('settings' in partial && partial.settings != null) store.settings = partial.settings;\n if ('locale' in partial && partial.locale != null) store.locale = partial.locale;\n if ('routeId' in partial && partial.routeId != null) store.routeId = partial.routeId;\n if ('location' in partial && partial.location != null)\n store.location = { ...store.location, ...partial.location };\n if ('authToken' in partial && partial.authToken !== undefined)\n store.authToken = partial.authToken ?? null;\n if ('scope' in partial && partial.scope !== undefined) store.scope = partial.scope ?? null;\n else if ('scopeId' in partial && partial.scopeId !== undefined)\n store.scope = partial.scopeId == null ? null : { id: partial.scopeId };\n if ('storeId' in partial && partial.storeId !== undefined)\n store.storeId = partial.storeId ?? null;\n if ('versionId' in partial && partial.versionId !== undefined)\n store.versionId = partial.versionId ?? null;\n if ('requestHost' in partial && partial.requestHost !== undefined)\n store.requestHost = partial.requestHost ?? null;\n if ('i18n' in partial && partial.i18n != null) store.i18n = partial.i18n;\n if ('page' in partial) store.page = partial.page;\n if ('appsSnippets' in partial) store.appsSnippets = partial.appsSnippets;\n if ('appsSettings' in partial) store.appsSettings = partial.appsSettings;\n if ('extras' in partial) store.extras = partial.extras;\n}\n\n// ============================================================================\n// Public API\n// ============================================================================\n\nexport function runWithTwilightContext<T>(partial: Partial<TwilightContext>, fn: () => T): T {\n if (_als) {\n const data: ContextData = { ...DEFAULT_DATA };\n mergeIntoStore(data, partial);\n return _als.run(data, fn) as T;\n }\n mergeIntoStore(clientStore, partial);\n return fn();\n}\n\n// Client-only subscription so React consumers (useRouteId/useIsHome/…) re-render\n// when navigation mutates the module store. Mirrors hooks/useWishlist.ts.\nconst listeners = new Set<() => void>();\n\nexport function subscribeTwilight(listener: () => void): () => void {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n}\n\nexport function updateTwilightContext(partial: Partial<TwilightContext>): void {\n mergeIntoStore(getTwilightStore(), partial);\n // Server uses AsyncLocalStorage and has no React subscribers; notify on client only.\n if (typeof window !== 'undefined') {\n for (const listener of listeners) listener();\n }\n}\n\n/**\n * Whether store settings are available, without throwing.\n *\n * `getTwilightContext().settings` throws a `SettingsError` when the store is\n * empty, which is fatal inside a head function during hydration. Callers that\n * need to *test* availability must use this instead of a try/catch around the\n * getter. Returns false when there is no request context at all (server-side\n * calls outside `runWithTwilightContext`).\n */\nexport function hasTwilightSettings(): boolean {\n try {\n return getTwilightStore().settings != null;\n } catch {\n return false;\n }\n}\n\n/** What a request addressed, as opposed to what it is. */\nexport interface RequestAddressing {\n storeId: string | null;\n versionId: string | null;\n requestHost: string | null;\n}\n\n/**\n * What this request named and the host it arrived on, without throwing.\n *\n * Separate from {@link getTwilightContext} because store identity is read while\n * deciding *what to fetch* — before there is a context worth having — and on the\n * server outside a request the getter throws. A caller asking \"which store?\" has\n * a sane answer for \"none named\"; it has none for an exception.\n *\n * The version rides along rather than getting an accessor of its own: it is read\n * at the same moment, for the same reason, and by the same callers, and a second\n * copy of this try/catch would be a second thing to remember to widen.\n */\nexport function getRequestStore(): RequestAddressing {\n try {\n const data = getTwilightStore();\n return { storeId: data.storeId, versionId: data.versionId, requestHost: data.requestHost };\n } catch {\n return { storeId: null, versionId: null, requestHost: null };\n }\n}\n\nexport function getTwilightContext(): TwilightContext {\n const data = getTwilightStore();\n return {\n get queryClient() {\n return data.queryClient;\n },\n get settings() {\n if (!data.settings) throw new SettingsError();\n return data.settings;\n },\n get locale() {\n return data.locale;\n },\n get routeId() {\n return data.routeId;\n },\n get location() {\n return data.location;\n },\n get authToken() {\n return data.authToken;\n },\n get scope() {\n return data.scope;\n },\n get scopeId() {\n return data.scope?.id ?? null;\n },\n get storeId() {\n return data.storeId;\n },\n get versionId() {\n return data.versionId;\n },\n get requestHost() {\n return data.requestHost;\n },\n get i18n() {\n if (!data.i18n) {\n const translations = data.queryClient?.getQueryData(['translations']) as\n TranslationMessages | undefined;\n data.i18n = createI18nInstance(data.locale, translations);\n }\n return data.i18n;\n },\n get dir() {\n return getLanguageInfo(data.locale).dir;\n },\n get page() {\n return data.page;\n },\n get appsSnippets() {\n return data.appsSnippets;\n },\n get appsSettings() {\n return data.appsSettings;\n },\n get extras() {\n return data.extras;\n },\n };\n}\n\n/** @internal Reset store for testing */\nexport function resetForTesting(): void {\n Object.assign(writableStore(), { ...DEFAULT_DATA });\n}\n"]}
|
|
@@ -1,9 +1,27 @@
|
|
|
1
|
-
import { AUTH_TOKEN_COOKIE_NAME, extractTokenFromCookies, getStoreIdentifier, readSdkScope, extractScopeFromCookies } from './chunk-
|
|
2
|
-
import { getTwilightContext } from './chunk-
|
|
1
|
+
import { AUTH_TOKEN_COOKIE_NAME, extractTokenFromCookies, getStoreIdentifier, readSdkScope, extractScopeFromCookies, getInjectedRuntimeEnv } from './chunk-JBXTU5NM.js';
|
|
2
|
+
import { getTwilightContext, getRequestStore } from './chunk-6XWMNQ52.js';
|
|
3
3
|
import ky from 'ky';
|
|
4
4
|
import { createIsomorphicFn } from '@tanstack/react-start';
|
|
5
5
|
import { getCookie } from '@tanstack/react-start/server';
|
|
6
6
|
|
|
7
|
+
// src/utils/theme-version.ts
|
|
8
|
+
function requestedThemeVersionId() {
|
|
9
|
+
const { versionId } = getRequestStore();
|
|
10
|
+
if (versionId) return versionId;
|
|
11
|
+
return getInjectedRuntimeEnv().versionId || null;
|
|
12
|
+
}
|
|
13
|
+
function resolveThemeVersionId() {
|
|
14
|
+
const requested = requestedThemeVersionId();
|
|
15
|
+
if (requested) return requested;
|
|
16
|
+
try {
|
|
17
|
+
const profileId = getTwilightContext().settings?.theme?.profile?.id;
|
|
18
|
+
return profileId != null ? String(profileId) : null;
|
|
19
|
+
} catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// src/api/client.ts
|
|
7
25
|
var readFallbackToken = createIsomorphicFn().server(() => {
|
|
8
26
|
try {
|
|
9
27
|
return getCookie(AUTH_TOKEN_COOKIE_NAME) ?? null;
|
|
@@ -81,12 +99,9 @@ var api = ky.extend({
|
|
|
81
99
|
if (!request.headers.get(API_HEADERS.STORE_IDENTIFIER)) {
|
|
82
100
|
request.headers.set(API_HEADERS.STORE_IDENTIFIER, getStoreIdentifier());
|
|
83
101
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
request.headers.set(API_HEADERS.VERSION_ID, String(profileId));
|
|
88
|
-
}
|
|
89
|
-
} catch {
|
|
102
|
+
const versionId = resolveThemeVersionId();
|
|
103
|
+
if (versionId) {
|
|
104
|
+
request.headers.set(API_HEADERS.VERSION_ID, versionId);
|
|
90
105
|
}
|
|
91
106
|
const token = authToken ?? readFallbackToken();
|
|
92
107
|
if (token) {
|
|
@@ -110,6 +125,6 @@ var cdn = ky.extend({
|
|
|
110
125
|
timeout: 5e3
|
|
111
126
|
});
|
|
112
127
|
|
|
113
|
-
export { STORE_IDENTIFIER_HEADER, api, cdn, getActiveScope, getActiveScopeId, getAuthToken };
|
|
114
|
-
//# sourceMappingURL=chunk-
|
|
115
|
-
//# sourceMappingURL=chunk-
|
|
128
|
+
export { STORE_IDENTIFIER_HEADER, api, cdn, getActiveScope, getActiveScopeId, getAuthToken, requestedThemeVersionId };
|
|
129
|
+
//# sourceMappingURL=chunk-AZ5HAIYQ.js.map
|
|
130
|
+
//# sourceMappingURL=chunk-AZ5HAIYQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/theme-version.ts","../src/api/client.ts"],"names":[],"mappings":";;;;;;;AAoCO,SAAS,uBAAA,GAAyC;AACvD,EAAA,MAAM,EAAE,SAAA,EAAU,GAAI,eAAA,EAAgB;AACtC,EAAA,IAAI,WAAW,OAAO,SAAA;AAEtB,EAAA,OAAO,qBAAA,GAAwB,SAAA,IAAa,IAAA;AAC9C;AAkBO,SAAS,qBAAA,GAAuC;AACrD,EAAA,MAAM,YAAY,uBAAA,EAAwB;AAC1C,EAAA,IAAI,WAAW,OAAO,SAAA;AAEtB,EAAA,IAAI;AACF,IAAA,MAAM,SAAA,GAAY,kBAAA,EAAmB,CAAE,QAAA,EAAU,OAAO,OAAA,EAAS,EAAA;AACjE,IAAA,OAAO,SAAA,IAAa,IAAA,GAAO,MAAA,CAAO,SAAS,CAAA,GAAI,IAAA;AAAA,EACjD,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;;;AC9CA,IAAM,iBAAA,GAAoB,kBAAA,EAAmB,CAC1C,MAAA,CAAO,MAAqB;AAC3B,EAAA,IAAI;AACF,IAAA,OAAO,SAAA,CAAU,sBAAsB,CAAA,IAAK,IAAA;AAAA,EAC9C,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF,CAAC,CAAA,CACA,OAAO,MAAqB;AAC3B,EAAA,MAAM,UAAA,GACJ,OAAO,QAAA,KAAa,WAAA,GAChB,wBAAwB,QAAA,CAAS,MAAA,EAAQ,sBAAsB,CAAA,GAC/D,IAAA;AACN,EAAA,IAAI,YAAY,OAAO,UAAA;AACvB,EAAA,MAAM,UAAU,OAAO,MAAA,KAAW,WAAA,GAAc,MA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,aAAa,CAAA;AAAA,QAC5E;AAAA,MACF;AAAA;AACF;AAEJ,CAAC;AAEM,IAAM,GAAA,GAAM,GAAG,MAAA,CAAO;AAAA,EAC3B,MAAA,EAAQ,2BAAA;AAAA,EACR,OAAA,EAAS;AACX,CAAC","file":"chunk-AZ5HAIYQ.js","sourcesContent":["/**\n * @fileoverview Which version of the theme's settings to render — the one answer,\n * in one place.\n *\n * A merchant's theme settings are versioned. An ordinary storefront visit names\n * no version and gets the live one; the API decides, and reports it back as\n * `theme.profile.id`. Two surfaces need a different one, and both address it in\n * the URL of an iframe:\n *\n * - the merchant's theme editor at `s.salla.sa/themes/editor/…`, which shows a\n * draft version beside the controls that are editing it;\n * - a partner running the theme locally, whose dev server is the iframe.\n *\n * Written as a module of its own rather than inline at the one call site,\n * because `store-identity.ts` exists for exactly this reason: the identifier a\n * request resolved and the identifier it sent were two different values for\n * days, in two files, and every test passed. A second implementation of this is\n * the bug, not a refactor away from one.\n */\nimport { getRequestStore, getTwilightContext } from '../twilight/context';\nimport { getInjectedRuntimeEnv } from './runtime-env';\n\n/**\n * The version this request asked for, or null when it asked for none.\n *\n * Deliberately excludes the version the *settings* name. This is the answer to\n * \"what did the caller address?\", and it has to be available before any settings\n * exist — React Query keys are built from it, and a key that means one thing\n * during SSR and another after hydration is how a page refetches everything it\n * was just handed.\n *\n * 1. what the request named, seeded by `twilightMiddleware` on a host permitted\n * to name one;\n * 2. what SSR resolved and published into the head, which is all the browser has\n * once the dispatcher has stripped `?versionId=` from the URL.\n */\nexport function requestedThemeVersionId(): string | null {\n const { versionId } = getRequestStore();\n if (versionId) return versionId;\n\n return getInjectedRuntimeEnv().versionId || null;\n}\n\n/**\n * The version every Salla API call is answered with — what goes in `s-version-id`.\n *\n * The requested version outranks the settings, because a request that named one\n * is the only reason this is ever anything but the live version: falling back to\n * the settings there would let the first answer overwrite the question.\n *\n * The settings' own `theme.profile.id` stays as the fallback, unchanged. It is\n * what this header has always carried, and on an ordinary storefront it still\n * is — it keeps the rest of a page's calls pinned to the version the settings\n * call resolved, rather than letting a version go live mid-render.\n *\n * Reading the settings is guarded because `getTwilightContext().settings` throws\n * a `SettingsError` when they have not loaded — which is the normal state on the\n * very first call, the settings call itself.\n */\nexport function resolveThemeVersionId(): string | null {\n const requested = requestedThemeVersionId();\n if (requested) return requested;\n\n try {\n const profileId = getTwilightContext().settings?.theme?.profile?.id;\n return profileId != null ? String(profileId) : null;\n } catch {\n return null;\n }\n}\n","import ky from 'ky';\nimport { createIsomorphicFn } from '@tanstack/react-start';\nimport { getCookie } from '@tanstack/react-start/server';\nimport { getStoreIdentifier } from '../utils/sdk-helpers';\nimport { resolveThemeVersionId } from '../utils/theme-version';\n// import { getInjectedRuntimeEnv, readEnv } from '../utils/runtime-env';\nimport { getTwilightContext } from '../twilight/context';\nimport {\n AUTH_TOKEN_COOKIE_NAME,\n extractScopeFromCookies,\n extractTokenFromCookies,\n readSdkScope,\n type ActiveScope,\n} from '../utils/cookies';\n\n// The twilight module store doesn't reliably carry authToken into every scope: on the\n// SERVER workerd has no AsyncLocalStorage, and on BOTH sides this api client can live in a\n// different module instance than the one rootBeforeLoad populates (engine subpath import vs\n// engine-internal relative import). So `getTwilightContext().authToken` is often null even\n// for logged-in users → API calls (orders/customer/…) return `token_not_provided` (400).\n// Read the token directly from the request cookie (server) or document.cookie / salla.storage\n// (client) as a fallback. The server-only import is stripped from the client bundle by\n// createIsomorphicFn.\nconst readFallbackToken = createIsomorphicFn()\n .server((): string | null => {\n try {\n return getCookie(AUTH_TOKEN_COOKIE_NAME) ?? null;\n } catch {\n return null;\n }\n })\n .client((): string | null => {\n const fromCookie =\n typeof document !== 'undefined'\n ? extractTokenFromCookies(document.cookie, AUTH_TOKEN_COOKIE_NAME)\n : null;\n if (fromCookie) return fromCookie;\n const storage = typeof window !== 'undefined' ? window.salla?.storage : undefined;\n const fromStorage =\n typeof storage?.get === 'function' ? storage.get(AUTH_TOKEN_COOKIE_NAME) : null;\n if (typeof fromStorage === 'string' && fromStorage) return fromStorage;\n // `?token=` webview injection lands only on the SDK's axios instance\n const fromSdkApi = typeof window !== 'undefined' ? window.salla?.api?.token : undefined;\n return typeof fromSdkApi === 'string' && fromSdkApi ? fromSdkApi : null;\n });\n\n/**\n * The auth token as the api client sees it: twilight context first, cookie/storage fallback.\n * Use this (not `getTwilightContext().authToken`, which is often null for logged-in users —\n * see the note above) to decide whether an authenticated-only query should run.\n */\nexport const getAuthToken = (): string | null =>\n getTwilightContext().authToken ?? readFallbackToken();\n\nconst API_HEADERS = {\n ACCEPT: 'accept',\n ACCEPT_LANGUAGE: 'accept-language',\n APP_OS: 's-app-os',\n APP_VERSION: 's-app-version',\n RAY: 's-ray',\n SOURCE: 's-source',\n THEME_TYPE: 's-theme-type',\n STORE_API_VERSION: 's-store-api-version',\n REQUESTED_WITH: 'x-requested-with',\n CF_PROXY_WHITELIST: 's-cf-proxy-whitelist-id',\n STORE_IDENTIFIER: 'store-identifier',\n AUTHORIZATION: 'Authorization',\n VERSION_ID: 's-version-id',\n SCOPE_ID: 's-scope-id',\n SCOPE_TYPE: 's-scope-type',\n SCOPE_ALLOCATION_TYPE: 's-scope-allocation-type',\n SCOPE_ALLOCATION_ID: 's-scope-allocation-id',\n} as const;\n\n/**\n * The header every Salla API call is answered by store.\n *\n * Exported because a caller that already knows which store it is asking about\n * must be able to say so on the request itself — see `store.settings`. Without\n * it the only way to name a store is the ambient resolver, and \"the identifier\n * I checked\" and \"the identifier that was sent\" become two different things.\n */\nexport const STORE_IDENTIFIER_HEADER = API_HEADERS.STORE_IDENTIFIER;\n\n/**\n * Active scope: the market plus its branch allocation, as the SDK stores it. On the\n * client it comes from `salla.storage.get('scope')`; before the SDK hydrates storage\n * it falls back to the `scope` cookie the theme mirrors that selection into (see\n * writeScopeCookie), then to the scope twilightMiddleware seeded from the same\n * cookie on the server. Requests vary by the `s-scope-*` headers, so React Query\n * keys must include this to avoid serving another branch's cached categories/products.\n *\n * The cookie step matters for hydration: the SDK is not guaranteed to have\n * populated `salla.storage` by the time the client rebuilds a dehydrated query\n * key, and without it the client would compute null against a scoped SSR key.\n */\nexport const getActiveScope = (): ActiveScope | null => {\n // `!== undefined`, not `!= null`: a null here is the SDK authoritatively saying \"no branch\n // selected\", which must beat a cookie left over from the previous selection. Only a\n // not-yet-ready storage API (undefined) falls through to the cookie.\n const fromStorage = readSdkScope();\n if (fromStorage !== undefined) return fromStorage;\n\n if (typeof document !== 'undefined') {\n const fromCookie = extractScopeFromCookies(document.cookie);\n if (fromCookie != null) return fromCookie;\n }\n\n try {\n return getTwilightContext().scope;\n } catch {\n return null;\n }\n};\n\n/** {@link getActiveScope} reduced to the market id. */\nexport const getActiveScopeId = (): string | null => getActiveScope()?.id ?? null;\n\nconst sharedHeaders = (locale: string) => ({\n [API_HEADERS.ACCEPT]: 'application/json' as const,\n [API_HEADERS.ACCEPT_LANGUAGE]: locale,\n [API_HEADERS.APP_OS]: 'browser',\n [API_HEADERS.APP_VERSION]: '2.14.363',\n [API_HEADERS.RAY]: '50',\n [API_HEADERS.SOURCE]: 'twilight',\n [API_HEADERS.THEME_TYPE]: 'react',\n [API_HEADERS.STORE_API_VERSION]: 'swoole',\n [API_HEADERS.REQUESTED_WITH]: 'XMLHttpRequest',\n [API_HEADERS.CF_PROXY_WHITELIST]: '019a2f78-a64c-7edb-proxy-whitelist-id-9a3a-17afda90f03a',\n});\n\n/**\n * Store API base. `VITE_API_URL` override points a preview at a branch backend; unset → prod\n * `api.salla.dev`. Resolution order matters: the value the SSR worker resolved (published into\n * the head, since worker `vars` are server-only `process.env` and never reach the browser\n * bundle) wins, so the hydrated client keeps talking to the backend that rendered the page.\n */\n\n// const STORE_API_BASE = getInjectedRuntimeEnv().apiBase || readEnv('VITE_API_URL') || 'https://api.salla.dev/store/v1';\n\nexport const api = ky.extend({\n prefix: 'https://api.salla.dev/store/v1', // TODO: check env\n timeout: 8000,\n hooks: {\n beforeRequest: [\n ({ request }) => {\n const { locale, authToken } = getTwilightContext();\n const headers = sharedHeaders(locale);\n for (const [key, value] of Object.entries(headers)) {\n request.headers.set(key, value);\n }\n // Only when the caller did not say. `headers.set` here would otherwise\n // overwrite a per-request identifier with the ambient one, which is a\n // silent way to answer a question about one store with another's data.\n if (!request.headers.get(API_HEADERS.STORE_IDENTIFIER)) {\n request.headers.set(API_HEADERS.STORE_IDENTIFIER, getStoreIdentifier());\n }\n\n // The version the request asked for, else the one the settings named.\n // Absent means \"whatever is live\", which is what an ordinary storefront\n // visit wants — so a null is left off rather than sent empty.\n const versionId = resolveThemeVersionId();\n if (versionId) {\n request.headers.set(API_HEADERS.VERSION_ID, versionId);\n }\n\n const token = authToken ?? readFallbackToken();\n if (token) {\n request.headers.set(API_HEADERS.AUTHORIZATION, `Bearer ${token}`);\n }\n\n // The same four the SDK's own client sends. The API resolves stock per\n // allocation: id alone asks about the market, not the branch the shopper chose.\n const scope = getActiveScope();\n if (scope) {\n request.headers.set(API_HEADERS.SCOPE_ID, scope.id);\n if (scope.type) request.headers.set(API_HEADERS.SCOPE_TYPE, scope.type);\n if (scope.allocation_type)\n request.headers.set(API_HEADERS.SCOPE_ALLOCATION_TYPE, scope.allocation_type);\n if (scope.allocation_id)\n request.headers.set(API_HEADERS.SCOPE_ALLOCATION_ID, scope.allocation_id);\n }\n },\n ],\n },\n});\n\nexport const cdn = ky.extend({\n prefix: 'https://cdn.salla.network',\n timeout: 5000,\n});\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { lazy } from 'react';
|
|
2
|
+
|
|
3
|
+
// src/components/cart/lazy.ts
|
|
4
|
+
var LazyCartItem = lazy(() => import('./CartItem-TARZW35A.js').then((m) => ({ default: m.CartItem })));
|
|
5
|
+
var LazyCartSummary = lazy(
|
|
6
|
+
() => import('./CartSummary-2KSBKQM7.js').then((m) => ({ default: m.CartSummary }))
|
|
7
|
+
);
|
|
8
|
+
var LazySeoCartWidget = lazy(
|
|
9
|
+
() => import('./SeoCartWidget-XYWATIV3.js').then((m) => ({ default: m.SeoCartWidget }))
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export { LazyCartItem, LazyCartSummary, LazySeoCartWidget };
|
|
13
|
+
//# sourceMappingURL=chunk-BK4VEUF3.js.map
|
|
14
|
+
//# sourceMappingURL=chunk-BK4VEUF3.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/cart/lazy.ts"],"names":[],"mappings":";;;AAMO,IAAM,YAAA,GAAe,IAAA,CAAK,MAAM,OAAO,wBAAY,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,QAAA,GAAW,CAAC;AAE3F,IAAM,eAAA,GAAkB,IAAA;AAAA,EAAK,MAClC,OAAO,2BAAe,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,WAAA,EAAY,CAAE;AAClE;AAEO,IAAM,iBAAA,GAAoB,IAAA;AAAA,EAAK,MACpC,OAAO,6BAAiB,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,aAAA,EAAc,CAAE;AACtE","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/components/cart/lazy.ts"],"names":[],"mappings":";;;AAMO,IAAM,YAAA,GAAe,IAAA,CAAK,MAAM,OAAO,wBAAY,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,QAAA,GAAW,CAAC;AAE3F,IAAM,eAAA,GAAkB,IAAA;AAAA,EAAK,MAClC,OAAO,2BAAe,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,WAAA,EAAY,CAAE;AAClE;AAEO,IAAM,iBAAA,GAAoB,IAAA;AAAA,EAAK,MACpC,OAAO,6BAAiB,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,MAAO,EAAE,OAAA,EAAS,CAAA,CAAE,aAAA,EAAc,CAAE;AACtE","file":"chunk-BK4VEUF3.js","sourcesContent":["import { lazy } from 'react';\n\n/**\n * Lazy-loaded cart components\n * Use these for code-splitting cart sections\n */\nexport const LazyCartItem = lazy(() => import('./CartItem').then((m) => ({ default: m.CartItem })));\n\nexport const LazyCartSummary = lazy(() =>\n import('./CartSummary').then((m) => ({ default: m.CartSummary }))\n);\n\nexport const LazySeoCartWidget = lazy(() =>\n import('./SeoCartWidget').then((m) => ({ default: m.SeoCartWidget }))\n);\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { configureNavigation, UnauthorizedError, NavigationProvider } from './chunk-
|
|
1
|
+
import { configureNavigation, UnauthorizedError, NavigationProvider } from './chunk-XLGVT7QF.js';
|
|
2
2
|
import { isLocale } from './chunk-T72DAX7R.js';
|
|
3
3
|
import { LinkProvider } from './chunk-BYMOPN2S.js';
|
|
4
4
|
import { useParams, Link, redirect, notFound, useNavigate } from '@tanstack/react-router';
|
|
@@ -85,5 +85,5 @@ function TanStackNavigationProvider({ children }) {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
export { NavigationSetup, TanStackLinkAdapter, TanStackNavigationProvider, createTanStackLinkAdapter };
|
|
88
|
-
//# sourceMappingURL=chunk-
|
|
89
|
-
//# sourceMappingURL=chunk-
|
|
88
|
+
//# sourceMappingURL=chunk-BWIESZJK.js.map
|
|
89
|
+
//# sourceMappingURL=chunk-BWIESZJK.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/tanstack/link.tsx","../src/tanstack/navigation.tsx"],"names":["TanStackLink","tanstackNotFound","tanstackRedirect","useParams"],"mappings":";;;;;;;AAWO,SAAS,mBAAA,CAAoB,aAAqB,MAAA,EAAiB;AACxE,EAAA,IAAI,CAAC,MAAA,IAAU,CAAC,WAAA,CAAY,UAAA,CAAW,GAAG,CAAA,IAAK,WAAA,CAAY,UAAA,CAAW,IAAI,CAAA,EAAG,OAAO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,EAAE,EAAA,EAAI,OAAA,EAAS,IAAA,EAAM,OAAA,EAAS,CAAA;AAAA,MAEzF,QAAA,kBAAA,GAAA,CAAC,YAAA,EAAA,EAAa,OAAA,EAAS,mBAAA,EAAsB,QAAA,EAAS;AAAA;AAAA,GACxD;AAEJ","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/tanstack/link.tsx","../src/tanstack/navigation.tsx"],"names":["TanStackLink","tanstackNotFound","tanstackRedirect","useParams"],"mappings":";;;;;;;AAWO,SAAS,mBAAA,CAAoB,aAAqB,MAAA,EAAiB;AACxE,EAAA,IAAI,CAAC,MAAA,IAAU,CAAC,WAAA,CAAY,UAAA,CAAW,GAAG,CAAA,IAAK,WAAA,CAAY,UAAA,CAAW,IAAI,CAAA,EAAG,OAAO,WAAA;AACpF,EAAA,MAAM,YAAA,GAAe,WAAA,CAAY,KAAA,CAAM,GAAG,CAAA,CAAE,CAAC,CAAA,EAAG,KAAA,CAAM,MAAM,CAAA,CAAE,CAAC,CAAA;AAC/D,EAAA,IAAI,QAAA,CAAS,YAAY,CAAA,EAAG,OAAO,WAAA;AACnC,EAAA,OAAO,WAAA,KAAgB,MAAM,CAAA,CAAA,EAAI,MAAM,KAAK,CAAA,CAAA,EAAI,MAAM,GAAG,WAAW,CAAA,CAAA;AACtE;AAMO,IAAM,mBAAA,GAAsB,UAAA;AAAA,EACjC,CACE;AAAA,IACE,EAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,SAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,MAAA;AAAA,IACA,GAAA;AAAA,IACA,OAAA;AAAA,IACA,OAAA;AAAA,IACA,OAAA;AAAA,IACA,YAAA,EAAc,SAAA;AAAA,IACd,GAAG;AAAA,KAEL,GAAA,KACG;AACH,IAAA,MAAM,EAAE,MAAA,EAAO,GAAI,UAAU,EAAE,MAAA,EAAQ,OAAO,CAAA;AAC9C,IAAA,MAAM,WAAA,GAAc,mBAAA,CA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,mBAAA,CAAoB,EAAA,EAAI,MAAM,CAAA,EAAG,OAAA,EAAS,IAAA,EAAM,SAAS,CAAA;AAAA,IAC1E,CAAC,UAAU,MAAM;AAAA,GACnB;AAEA,EAAA,uBACE,GAAA,CAAC,sBAAmB,QAAA,EAAU,UAAA,EAC5B,8BAAC,YAAA,EAAA,EAAa,OAAA,EAAS,mBAAA,EAAsB,QAAA,EAAS,CAAA,EACxD,CAAA;AAEJ;AAGO,SAAS,0BAAA,CAA2B,EAAE,QAAA,EAAS,EAA4B;AAChF,EAAA,MAAM,WAAW,WAAA,EAAY;AAC7B,EAAA,uBACE,GAAA;AAAA,IAAC,kBAAA;AAAA,IAAA;AAAA,MACC,QAAA,EAAU,CAAC,EAAA,EAAY,IAAA,KAA2B,QAAA,CAAS,EAAE,EAAA,EAAI,OAAA,EAAS,IAAA,EAAM,OAAA,EAAS,CAAA;AAAA,MAEzF,QAAA,kBAAA,GAAA,CAAC,YAAA,EAAA,EAAa,OAAA,EAAS,mBAAA,EAAsB,QAAA,EAAS;AAAA;AAAA,GACxD;AAEJ","file":"chunk-BWIESZJK.js","sourcesContent":["import { forwardRef, createElement } from 'react';\nimport { Link as TanStackLink, useParams } from '@tanstack/react-router';\nimport { isLocale } from '../providers/locale-constants';\nimport type { BaseLinkProps } from '../components/common/Link.types';\n\n/**\n * Routes live under an optional `/{-$locale}` param, so a bare `to=\"/brands\"`\n * resolves with the locale omitted and the $locale loader bounces the user to\n * the fallback locale. Prefix the current locale onto internal paths that\n * don't already carry one.\n */\nexport function localizeDestination(destination: string, locale?: string) {\n if (!locale || !destination.startsWith('/') || destination.startsWith('//')) return destination;\n const firstSegment = destination.split('/')[1]?.split(/[?#]/)[0];\n if (isLocale(firstSegment)) return destination;\n return destination === '/' ? `/${locale}` : `/${locale}${destination}`;\n}\n\n/**\n * TanStack Router Link adapter.\n * Translates framework-agnostic props to TanStack Router Link props.\n */\nexport const TanStackLinkAdapter = forwardRef<HTMLAnchorElement, BaseLinkProps>(\n (\n {\n to,\n href,\n children,\n className,\n style,\n title,\n target,\n rel,\n onClick,\n preload,\n replace,\n 'aria-label': ariaLabel,\n ...rest\n },\n ref\n ) => {\n const { locale } = useParams({ strict: false }) as { locale?: string };\n const destination = localizeDestination(to ?? href ?? '/', locale);\n\n return createElement(\n TanStackLink,\n {\n ref,\n to: destination,\n className,\n style,\n title,\n target,\n rel,\n onClick,\n preload: preload === 'intent' ? 'intent' : undefined,\n replace,\n 'aria-label': ariaLabel,\n ...(rest as Record<string, unknown>),\n },\n children\n );\n }\n);\n\nTanStackLinkAdapter.displayName = 'TanStackLinkAdapter';\n\n/**\n * Create a TanStack Router Link adapter component.\n */\nexport function createTanStackLinkAdapter() {\n return TanStackLinkAdapter;\n}\n","import {\n useNavigate,\n useParams,\n redirect as tanstackRedirect,\n notFound as tanstackNotFound,\n} from '@tanstack/react-router';\nimport {\n NavigationProvider,\n configureNavigation,\n type NavigateOptions,\n} from '../providers/NavigationProvider';\nimport { LinkProvider } from '../providers/LinkProvider';\nimport { TanStackLinkAdapter, localizeDestination } from './link';\nimport { useCallback, type ReactNode } from 'react';\nimport { UnauthorizedError } from '../providers/NavigationProvider';\n\nconfigureNavigation({\n notFound: (message?: string) => {\n throw tanstackNotFound({ data: message });\n },\n redirect: (path: string, opts?: { replace?: boolean }) => {\n throw tanstackRedirect({ to: path, replace: opts?.replace });\n },\n unauthorized: (message?: string) => {\n throw new UnauthorizedError(message);\n },\n});\n\n/**\n * TanStack navigation setup - wraps children with NavigationProvider and LinkProvider.\n * Called by TwilightProvider when client.framework === 'tanstack'.\n */\nexport function NavigationSetup({ children }: { children: ReactNode }) {\n const navigate = useNavigate();\n const { locale } = useParams({ strict: false }) as { locale?: string };\n const navigateFn = useCallback(\n (to: string, opts?: NavigateOptions) =>\n navigate({ to: localizeDestination(to, locale), replace: opts?.replace }),\n [navigate, locale]\n );\n\n return (\n <NavigationProvider navigate={navigateFn}>\n <LinkProvider adapter={TanStackLinkAdapter}>{children}</LinkProvider>\n </NavigationProvider>\n );\n}\n\n/** @deprecated Use NavigationSetup instead */\nexport function TanStackNavigationProvider({ children }: { children: ReactNode }) {\n const navigate = useNavigate();\n return (\n <NavigationProvider\n navigate={(to: string, opts?: NavigateOptions) => navigate({ to, replace: opts?.replace })}\n >\n <LinkProvider adapter={TanStackLinkAdapter}>{children}</LinkProvider>\n </NavigationProvider>\n );\n}\n"]}
|