shopify 5.0.0 → 5.0.1
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/{analytics-VKKJNJ62.js → analytics-RSUIYNLC.js} +1 -1
- package/dist/analytics-V2SDYXQJ.js +1 -0
- package/dist/bootstrap.js +1 -1
- package/dist/{chunk-NK2MGR6A.js → chunk-2AW3KBTP.js} +1 -1
- package/dist/{chunk-BCYTZ7LM.js → chunk-2CJQQQW4.js} +1 -1
- package/dist/{chunk-EITIW5OX.js → chunk-2M4BKFYF.js} +1 -1
- package/dist/chunk-2M535QQJ.js +6 -0
- package/dist/{chunk-5TB52UUV.js → chunk-2NZ7GDDR.js} +1 -1
- package/dist/{chunk-YVY32DNA.js → chunk-2QQ7EBJD.js} +1 -1
- package/dist/chunk-2RFCYZMG.js +47 -0
- package/dist/{chunk-S67I4E7M.js → chunk-2S5NPJEJ.js} +1 -1
- package/dist/{chunk-YVVU4J5O.js → chunk-2TPLPZA2.js} +1 -1
- package/dist/{chunk-C3KEDG33.js → chunk-2YGPWG3I.js} +1 -1
- package/dist/{chunk-TTEF7GTX.js → chunk-32O27NE3.js} +1 -1
- package/dist/{chunk-24NUJTIH.js → chunk-364BVGRY.js} +1 -1
- package/dist/{chunk-BJPDJIS4.js → chunk-36TZ447N.js} +1 -1
- package/dist/{chunk-5UWMXOHM.js → chunk-37P5YOP2.js} +1 -1
- package/dist/{chunk-4CRBTSVP.js → chunk-3G2PEYPI.js} +1 -1
- package/dist/{chunk-EXFBZPZS.js → chunk-3JACWBUC.js} +1 -1
- package/dist/{chunk-53BG3NLH.js → chunk-43HKFLOU.js} +1 -1
- package/dist/chunk-46JYM3GH.js +1 -0
- package/dist/{chunk-XITZIDCL.js → chunk-4EDE3UH7.js} +1 -1
- package/dist/{chunk-G6ZMSWEU.js → chunk-4GQEXVDT.js} +1 -1
- package/dist/{chunk-SNNZ4U2W.js → chunk-4IUXLUFD.js} +1 -1
- package/dist/{chunk-ULD7CIOY.js → chunk-4QZ6OBXL.js} +1 -1
- package/dist/{chunk-YKS7MH3F.js → chunk-4SDCXKYR.js} +1 -1
- package/dist/{chunk-VB7YQMAM.js → chunk-56GKTWFF.js} +1 -1
- package/dist/{chunk-Q66CI37F.js → chunk-5AQ5JT2V.js} +1 -1
- package/dist/{chunk-Q2SZCZE7.js → chunk-5AWELO3D.js} +1 -1
- package/dist/{chunk-VHUD3CBC.js → chunk-5D4FNAAD.js} +1 -1
- package/dist/{chunk-46MSIQ6Z.js → chunk-5TWYJQQO.js} +1 -1
- package/dist/{chunk-OGWPS55W.js → chunk-5XOEMYEQ.js} +1 -1
- package/dist/{chunk-MR2AUT7Q.js → chunk-5YUDEPEY.js} +1 -1
- package/dist/{chunk-CCQNP5YR.js → chunk-5YXYYQBX.js} +1 -1
- package/dist/{chunk-P33TONYG.js → chunk-63UKZLPC.js} +1 -1
- package/dist/chunk-6JZC6UKY.js +20 -0
- package/dist/{chunk-7QUZWCJZ.js → chunk-6Y6A2QGK.js} +1 -1
- package/dist/{chunk-M7LPHCP2.js → chunk-75LAVRRL.js} +2 -2
- package/dist/{chunk-AJMDF3QC.js → chunk-7AWAOPLA.js} +1 -1
- package/dist/{chunk-AXC2MHHO.js → chunk-7NYCJG2U.js} +1 -1
- package/dist/{chunk-6DXP7PQ7.js → chunk-7U2MTK6I.js} +1 -1
- package/dist/{chunk-JEA3C7ON.js → chunk-7XAEI4XT.js} +1 -1
- package/dist/{chunk-TPSA4JN5.js → chunk-A7LBGXWG.js} +1 -1
- package/dist/{chunk-2CMEKSI7.js → chunk-ADVLRSSO.js} +1 -1
- package/dist/{chunk-3LVCG4JB.js → chunk-AIEVQSI3.js} +1 -1
- package/dist/{chunk-M4BVLMPH.js → chunk-AOBE6HN6.js} +1 -1
- package/dist/{chunk-PSSYLJG4.js → chunk-AQ34X5B3.js} +1 -1
- package/dist/{chunk-43KLFFP7.js → chunk-B2VE7WOX.js} +1 -1
- package/dist/{chunk-L7MSPGDS.js → chunk-B4ISKIXN.js} +1 -1
- package/dist/{chunk-EMSF57ZB.js → chunk-BB7GAZP6.js} +1 -1
- package/dist/chunk-BNTOGZLY.js +1 -0
- package/dist/chunk-BU3JQM3W.js +1 -0
- package/dist/{chunk-LHKVXJPX.js → chunk-C3LL5CZA.js} +1 -1
- package/dist/{chunk-GFVKTWFT.js → chunk-C4EKNOLY.js} +1 -1
- package/dist/{chunk-5NEGOQT6.js → chunk-CFUZ6574.js} +1 -1
- package/dist/{chunk-NB4BRW3H.js → chunk-CKVVJ4XO.js} +1 -1
- package/dist/{chunk-VWH3VPYI.js → chunk-CNPBDSDL.js} +1 -1
- package/dist/{chunk-U25W35TX.js → chunk-CWR3IFXD.js} +1 -1
- package/dist/{chunk-VW6QS7DO.js → chunk-CX3ANDPI.js} +1 -1
- package/dist/{chunk-GB6E3ATN.js → chunk-CXPYOLGM.js} +1 -1
- package/dist/{chunk-FWB3GLMW.js → chunk-D4LFWIFE.js} +1 -1
- package/dist/{chunk-PZUGDE7N.js → chunk-DM7BTMFP.js} +1 -1
- package/dist/{chunk-GRGFA26K.js → chunk-DSKAIC7O.js} +1 -1
- package/dist/{chunk-M5TGCSUK.js → chunk-DTRENW4Q.js} +1 -1
- package/dist/{chunk-EGCWR5AS.js → chunk-DVW7NDVD.js} +1 -1
- package/dist/{chunk-YGYEM6QO.js → chunk-E3CTHNQS.js} +1 -1
- package/dist/{chunk-6BNKBCCU.js → chunk-EA5XVQJT.js} +1 -1
- package/dist/{chunk-XM7YUXTF.js → chunk-EH22T4FI.js} +2 -2
- package/dist/{chunk-XNNKLUTN.js → chunk-ETXBF6Q7.js} +1 -1
- package/dist/{chunk-AYL6KBPE.js → chunk-EXTVC33U.js} +1 -1
- package/dist/{chunk-J6TW43TG.js → chunk-F3OM2YO6.js} +1 -1
- package/dist/{chunk-X7HVAVSZ.js → chunk-FHNJLON5.js} +1 -1
- package/dist/{chunk-SFPXYHHL.js → chunk-FK5OFLSJ.js} +1 -1
- package/dist/{chunk-NDKSG4CC.js → chunk-FNWXMCSD.js} +1 -1
- package/dist/{chunk-KKPOOIE4.js → chunk-FPOZMNT2.js} +1 -1
- package/dist/{chunk-HIRTL45Q.js → chunk-FS5PZCZ3.js} +1 -1
- package/dist/{chunk-Q5MEFIMV.js → chunk-FTHVOIK7.js} +1 -1
- package/dist/chunk-FVRI7ZKE.js +103 -0
- package/dist/{chunk-CIK5BF7V.js → chunk-GCKGQFV7.js} +1 -1
- package/dist/{chunk-PEVIRAMR.js → chunk-GGJUPL4W.js} +1 -1
- package/dist/{chunk-R7EMV77H.js → chunk-GHU6YEXH.js} +1 -1
- package/dist/{chunk-WGUOLSMG.js → chunk-GNPIKPHB.js} +1 -1
- package/dist/{chunk-3A3DZVEJ.js → chunk-GSGCSBRN.js} +1 -1
- package/dist/{chunk-PIAD3F6M.js → chunk-H57KYDEI.js} +1 -1
- package/dist/{chunk-GAMC2BNY.js → chunk-HNU6R7RT.js} +1 -1
- package/dist/{chunk-UOS2XLGG.js → chunk-HP2ZAAY7.js} +1 -1
- package/dist/{chunk-IEQ4UOH3.js → chunk-HPT3UXZ5.js} +1 -1
- package/dist/chunk-HT66BOEC.js +8 -0
- package/dist/{chunk-4ARCB6DT.js → chunk-HXNGLDMU.js} +1 -1
- package/dist/{chunk-BVSKBX7T.js → chunk-IAL6IQYW.js} +1 -1
- package/dist/{chunk-4RDFMBRG.js → chunk-IULZYDCI.js} +1 -1
- package/dist/{chunk-UIQL5ZF3.js → chunk-IWTOC6DG.js} +1 -1
- package/dist/{chunk-2ORRV7GH.js → chunk-IY5EI5V2.js} +1 -1
- package/dist/{chunk-ZT5WFUKJ.js → chunk-J3UXIC23.js} +1 -1
- package/dist/{chunk-Q2XRITUG.js → chunk-J5DUFSR4.js} +1 -1
- package/dist/{chunk-2VSNFOKD.js → chunk-J7BTC45S.js} +1 -1
- package/dist/{chunk-SL3VBI62.js → chunk-JMVK2BIB.js} +1 -1
- package/dist/{chunk-X2H6I2WW.js → chunk-JUTULEWW.js} +1 -1
- package/dist/{chunk-KGRIYAMA.js → chunk-K3YALQBQ.js} +1 -1
- package/dist/{chunk-SFQEHDJY.js → chunk-KGASGUDQ.js} +1 -1
- package/dist/{chunk-LDU5T3DN.js → chunk-KLYGMYXV.js} +1 -1
- package/dist/{chunk-7WPUV7GY.js → chunk-KNQXCU3Y.js} +1 -1
- package/dist/{chunk-C7V755IT.js → chunk-KOTZSPZA.js} +1 -1
- package/dist/{chunk-DJAZBPYA.js → chunk-KT5QQOES.js} +1 -1
- package/dist/{chunk-4SS6DXC7.js → chunk-KVF55INC.js} +1 -1
- package/dist/{chunk-MXJAH2GW.js → chunk-L6VONMA2.js} +1 -1
- package/dist/{chunk-GXORLBVN.js → chunk-LENSEW2F.js} +1 -1
- package/dist/{chunk-7UOA4DI7.js → chunk-LGXNXAQA.js} +1 -1
- package/dist/{chunk-ZYQ2XWC5.js → chunk-LR4J4KYJ.js} +1 -1
- package/dist/{chunk-QN3774QI.js → chunk-LWMKZJ4M.js} +1 -1
- package/dist/{chunk-I4OVLRQR.js → chunk-M2KX3PXA.js} +1 -1
- package/dist/{chunk-D7NB7YR6.js → chunk-M73IECPW.js} +1 -1
- package/dist/{chunk-4TI7U2PN.js → chunk-M7NLCGCP.js} +1 -1
- package/dist/chunk-MHWETFNT.js +1 -0
- package/dist/{chunk-CCMDZX35.js → chunk-MMUGP3WP.js} +1 -1
- package/dist/{chunk-LMQGNECW.js → chunk-MNWT2SQO.js} +1 -1
- package/dist/{chunk-R2BDABJD.js → chunk-MS7DTL4U.js} +1 -1
- package/dist/{chunk-OVWUGAEU.js → chunk-MU2X7NGF.js} +1 -1
- package/dist/{chunk-GCNA3HXH.js → chunk-MXXMIPUN.js} +1 -1
- package/dist/{chunk-POKY4RWR.js → chunk-MZCIRMZJ.js} +1 -1
- package/dist/{chunk-PGLWZMJU.js → chunk-MZWPIFAM.js} +1 -1
- package/dist/{chunk-H4V55Y3Z.js → chunk-NCPZVARH.js} +83 -83
- package/dist/{chunk-3G4HJO72.js → chunk-NJVNGEOU.js} +1 -1
- package/dist/{chunk-CEIJKJOF.js → chunk-NMECLRGK.js} +1 -1
- package/dist/{chunk-UVRKTMF7.js → chunk-NMLLRFZF.js} +1 -1
- package/dist/chunk-NPB753M3.js +1 -0
- package/dist/{chunk-ZAA2DXK5.js → chunk-NUCDRKDW.js} +1 -1
- package/dist/{chunk-UZROQRLX.js → chunk-OH7BQZQ7.js} +1 -1
- package/dist/{chunk-ZQDDRIBA.js → chunk-OLKLHVHA.js} +4 -4
- package/dist/{chunk-7MVWDCI3.js → chunk-OPVXPDOQ.js} +1 -1
- package/dist/{chunk-IWEKM5Y3.js → chunk-OQUXGAF2.js} +1 -1
- package/dist/{chunk-IUTZIN2T.js → chunk-OUMERKRE.js} +1 -1
- package/dist/{chunk-5OMJFPQW.js → chunk-OYGIQDME.js} +1 -1
- package/dist/{chunk-KSDU4YOB.js → chunk-P5W5RVE6.js} +1 -1
- package/dist/{chunk-PYIICTLX.js → chunk-PNZURX3S.js} +1 -1
- package/dist/{chunk-UK6576EO.js → chunk-PRKJVU4Y.js} +1 -1
- package/dist/{chunk-DFQ4WTET.js → chunk-PVASYKSJ.js} +1 -1
- package/dist/{chunk-CW2T7EOQ.js → chunk-PXFPVGWV.js} +1 -1
- package/dist/{chunk-7LAKWAKX.js → chunk-Q2ORJEB2.js} +1 -1
- package/dist/{chunk-XKRJKUA7.js → chunk-QBE6XVU3.js} +1 -1
- package/dist/{chunk-N2RFDHRY.js → chunk-QGWC23HQ.js} +1 -1
- package/dist/{chunk-GQNOVEKP.js → chunk-QVVQUJQL.js} +1 -1
- package/dist/{chunk-WMAFG2JD.js → chunk-QX3T6G5X.js} +1 -1
- package/dist/{chunk-VMMUJN4T.js → chunk-QYFU363G.js} +1 -1
- package/dist/{chunk-7NSK77WG.js → chunk-RDXLDCMI.js} +1 -1
- package/dist/{chunk-JYMDWR25.js → chunk-REDUS6EW.js} +1 -1
- package/dist/{chunk-FNLECT7B.js → chunk-RFZNFTVM.js} +1 -1
- package/dist/{chunk-LWCTKI4Z.js → chunk-RIG66DIQ.js} +3 -3
- package/dist/{chunk-YTUDXZLN.js → chunk-RNUEPPVN.js} +1 -1
- package/dist/{chunk-RFGEM5JC.js → chunk-RWTAPWLJ.js} +1 -1
- package/dist/{chunk-WFWISGLS.js → chunk-T5YVYVSW.js} +1 -1
- package/dist/{chunk-WJSUIUBW.js → chunk-TTBNFGCW.js} +1 -1
- package/dist/{chunk-OQ5CLM2H.js → chunk-UDPYSL3M.js} +1 -1
- package/dist/{chunk-KDPQXURV.js → chunk-ULMNNGGX.js} +1 -1
- package/dist/{chunk-T2IUXXCT.js → chunk-URCH4ITT.js} +1 -1
- package/dist/{chunk-NOH63WC6.js → chunk-UU2R56LN.js} +1 -1
- package/dist/{chunk-CVVQQLCF.js → chunk-V2FCZC7U.js} +1 -1
- package/dist/{chunk-CZ22VZDA.js → chunk-V654BMS7.js} +108 -108
- package/dist/{chunk-7IFE4UQY.js → chunk-V7H7ITCF.js} +1 -1
- package/dist/{chunk-MYAIWSOO.js → chunk-VG2AESTZ.js} +1 -1
- package/dist/{chunk-XTREQ4A2.js → chunk-VXD26GIG.js} +1 -1
- package/dist/{chunk-QKVVJXWS.js → chunk-VXL5FBE7.js} +1 -1
- package/dist/{chunk-I6FRVYGE.js → chunk-W7S6SYBM.js} +1 -1
- package/dist/{chunk-HCZG7YJ6.js → chunk-WAY723TL.js} +1 -1
- package/dist/chunk-WFOU5M4H.js +16 -0
- package/dist/{chunk-BWRNXCVN.js → chunk-WGOSE3RL.js} +1 -1
- package/dist/{chunk-KJQDS5HI.js → chunk-WQ6W725N.js} +1 -1
- package/dist/{chunk-52FDK2LC.js → chunk-WQOPLNDH.js} +1 -1
- package/dist/{chunk-4GCI2YCZ.js → chunk-X4A5D3PZ.js} +1 -1
- package/dist/{chunk-2DID73ML.js → chunk-X7DCL5LT.js} +1 -1
- package/dist/{chunk-RVQV6G5M.js → chunk-XDXHSGDL.js} +1 -1
- package/dist/{chunk-OX7UVDSU.js → chunk-XKKKMV46.js} +1 -1
- package/dist/{chunk-FDXHQZTO.js → chunk-XRVJJG6W.js} +16 -16
- package/dist/chunk-XV6XCOTG.js +319 -0
- package/dist/{chunk-M3ACZWMR.js → chunk-XYFYQWKW.js} +1 -1
- package/dist/{chunk-UWMZ5CSB.js → chunk-XZLM4HLO.js} +1 -1
- package/dist/{chunk-FFHH5LOR.js → chunk-YCUEDZDA.js} +1 -1
- package/dist/{chunk-XBQDMGUN.js → chunk-YFRI75U4.js} +1 -1
- package/dist/{chunk-XMODGI45.js → chunk-YQ63ZFYT.js} +1 -1
- package/dist/{chunk-4GOJQKY5.js → chunk-YXIFSIRX.js} +1 -1
- package/dist/{chunk-MDRVCBDO.js → chunk-ZBVHPC6W.js} +1 -1
- package/dist/{chunk-IQVRP7CT.js → chunk-ZHHTQRWU.js} +1 -1
- package/dist/{chunk-Z5SILNH2.js → chunk-ZTZGDZCE.js} +1 -1
- package/dist/{chunk-OQU3HLAE.js → chunk-ZVEBXHEY.js} +1 -1
- package/dist/cli/commands/app/build.js +1 -1
- package/dist/cli/commands/app/bulk/cancel.js +1 -1
- package/dist/cli/commands/app/bulk/execute.js +1 -1
- package/dist/cli/commands/app/bulk/status.js +1 -1
- package/dist/cli/commands/app/config/link.js +1 -1
- package/dist/cli/commands/app/config/pull.js +1 -1
- package/dist/cli/commands/app/config/use.js +1 -1
- package/dist/cli/commands/app/config/validate.js +1 -1
- package/dist/cli/commands/app/demo/watcher.js +1 -1
- package/dist/cli/commands/app/deploy.js +1 -1
- package/dist/cli/commands/app/dev/clean.js +1 -1
- package/dist/cli/commands/app/dev.js +1 -1
- package/dist/cli/commands/app/env/pull.js +1 -1
- package/dist/cli/commands/app/env/show.js +1 -1
- package/dist/cli/commands/app/execute.js +1 -1
- package/dist/cli/commands/app/function/build.js +1 -1
- package/dist/cli/commands/app/function/info.js +1 -1
- package/dist/cli/commands/app/function/replay.js +1 -1
- package/dist/cli/commands/app/function/run.js +1 -1
- package/dist/cli/commands/app/function/schema.js +1 -1
- package/dist/cli/commands/app/function/typegen.js +1 -1
- package/dist/cli/commands/app/generate/extension.js +1 -1
- package/dist/cli/commands/app/graphiql.js +1 -1
- package/dist/cli/commands/app/import/channel-config.js +1 -1
- package/dist/cli/commands/app/import/custom-data-definitions.js +1 -1
- package/dist/cli/commands/app/import/dashboard-extensions.js +1 -1
- package/dist/cli/commands/app/import-custom-data-definitions.js +1 -1
- package/dist/cli/commands/app/import-extensions.js +1 -1
- package/dist/cli/commands/app/info.js +1 -1
- package/dist/cli/commands/app/init.js +1 -1
- package/dist/cli/commands/app/logs.js +1 -1
- package/dist/cli/commands/app/release.js +1 -1
- package/dist/cli/commands/app/security/check.js +1 -1
- package/dist/cli/commands/app/security/clean.js +1 -1
- package/dist/cli/commands/app/security/instructions.js +1 -1
- package/dist/cli/commands/app/security/record.js +1 -1
- package/dist/cli/commands/app/security/review.js +1 -1
- package/dist/cli/commands/app/subscription-migrations/cancel.js +1 -1
- package/dist/cli/commands/app/subscription-migrations/list.js +1 -1
- package/dist/cli/commands/app/subscription-migrations/schedule.js +1 -1
- package/dist/cli/commands/app/subscription-migrations/status.js +1 -1
- package/dist/cli/commands/app/subscription-migrations/unschedule.js +1 -1
- package/dist/cli/commands/app/versions/list.js +1 -1
- package/dist/cli/commands/app/webhook/trigger.js +1 -1
- package/dist/cli/commands/auth/login.js +1 -1
- package/dist/cli/commands/auth/logout.js +1 -1
- package/dist/cli/commands/cache/clear.js +1 -1
- package/dist/cli/commands/config/autoupgrade/off.js +1 -1
- package/dist/cli/commands/config/autoupgrade/on.js +1 -1
- package/dist/cli/commands/config/autoupgrade/status.js +1 -1
- package/dist/cli/commands/debug/command-flags.js +1 -1
- package/dist/cli/commands/doc/fetch.js +1 -1
- package/dist/cli/commands/doc/search.js +1 -1
- package/dist/cli/commands/docs/generate.js +1 -1
- package/dist/cli/commands/doctor-release/doctor-release.js +1 -1
- package/dist/cli/commands/doctor-release/theme/index.js +1 -1
- package/dist/cli/commands/help.js +1 -1
- package/dist/cli/commands/kitchen-sink/async.js +1 -1
- package/dist/cli/commands/kitchen-sink/index.js +1 -1
- package/dist/cli/commands/kitchen-sink/prompts.js +1 -1
- package/dist/cli/commands/kitchen-sink/static.js +1 -1
- package/dist/cli/commands/notifications/generate.js +1 -1
- package/dist/cli/commands/notifications/list.js +1 -1
- package/dist/cli/commands/organization/list.js +1 -1
- package/dist/cli/commands/search.js +1 -1
- package/dist/cli/commands/send-analytics.js +1 -1
- package/dist/cli/commands/theme/check.js +1 -1
- package/dist/cli/commands/theme/console.js +1 -1
- package/dist/cli/commands/theme/delete.js +1 -1
- package/dist/cli/commands/theme/dev.js +1 -1
- package/dist/cli/commands/theme/duplicate.js +1 -1
- package/dist/cli/commands/theme/info.js +1 -1
- package/dist/cli/commands/theme/init.js +1 -1
- package/dist/cli/commands/theme/language-server.js +1 -1
- package/dist/cli/commands/theme/list.js +1 -1
- package/dist/cli/commands/theme/metafields/pull.js +1 -1
- package/dist/cli/commands/theme/open.js +1 -1
- package/dist/cli/commands/theme/package.js +1 -1
- package/dist/cli/commands/theme/preview.js +1 -1
- package/dist/cli/commands/theme/profile.js +1 -1
- package/dist/cli/commands/theme/publish.js +1 -1
- package/dist/cli/commands/theme/pull.js +1 -1
- package/dist/cli/commands/theme/push.js +1 -1
- package/dist/cli/commands/theme/rename.js +1 -1
- package/dist/cli/commands/theme/share.js +1 -1
- package/dist/cli/commands/upgrade.js +1 -1
- package/dist/cli/commands/version.js +1 -1
- package/dist/cli/help.js +1 -1
- package/dist/{command-json-schema-2UMKY7MY.js → command-json-schema-6EGXCM4B.js} +1 -1
- package/dist/command-registry.js +1 -1
- package/dist/{conf-store-RI3TL6I4.js → conf-store-E7ELDWBA.js} +1 -1
- package/dist/{custom-oclif-loader-IZCKN67O.js → custom-oclif-loader-FKFZJPHF.js} +1 -1
- package/dist/{deprecations-IFVUXXDB.js → deprecations-RNGBHZYB.js} +1 -1
- package/dist/dist-VHIZZDYK.js +1 -0
- package/dist/dist-WXI5YQYP.js +1 -0
- package/dist/{environments-CYMEN7NV.js → environments-WZJ6MRTH.js} +1 -1
- package/dist/{error-IL6WQMSW.js → error-IFB626JA.js} +1 -1
- package/dist/error-handler-OVJYVIOZ.js +1 -0
- package/dist/{fs-AINFLJ2E.js → fs-7UOUHJDO.js} +1 -1
- package/dist/hooks/did-you-mean.js +1 -1
- package/dist/hooks/hydrogen-init.js +1 -1
- package/dist/hooks/postrun.js +1 -1
- package/dist/hooks/prerun.js +1 -1
- package/dist/hooks/public-metadata.js +1 -1
- package/dist/hooks/sensitive-metadata.js +1 -1
- package/dist/hooks/tunnel-provider.js +1 -1
- package/dist/hooks/tunnel-start.js +1 -1
- package/dist/index.js +12 -12
- package/dist/{is-global-2VLKV46Q.js → is-global-XW3CVHLK.js} +1 -1
- package/dist/{json-error-HZB5YIHV.js → json-error-C2U7ZLCG.js} +1 -1
- package/dist/{local-KOZETREJ.js → local-KA3IWOZ6.js} +1 -1
- package/dist/{metadata-IBPHZB7N.js → metadata-6JI7HF5B.js} +1 -1
- package/dist/{node-package-manager-DXSRNEDC.js → node-package-manager-X3QIEMMX.js} +1 -1
- package/dist/{notifications-system-XA3EBOGJ.js → notifications-system-OXGLT2R4.js} +1 -1
- package/dist/{os-X73O7BAB.js → os-NORIEVMI.js} +1 -1
- package/dist/{output-3OYXK3Z5.js → output-K3JTLRJD.js} +1 -1
- package/dist/{system-JWYYT4PM.js → system-LTHR2T7L.js} +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/{ui-PCG5D6RZ.js → ui-MYUBVKCK.js} +1 -1
- package/dist/upgrade-MFTWBXL3.js +1 -0
- package/dist/version-BNGPPAUU.js +1 -0
- package/dist/{version-7DGU2KYH.js → version-RCGFWSB4.js} +1 -1
- package/dist/{workerd-MQZ3NKJI.js → workerd-ISSXMKIH.js} +1 -1
- package/oclif.manifest.json +6 -3
- package/package.json +7 -7
- package/dist/analytics-Q6QDIDYT.js +0 -1
- package/dist/chunk-3C6VLJ5D.js +0 -319
- package/dist/chunk-43R5VGKT.js +0 -1
- package/dist/chunk-4C2DAX5T.js +0 -1
- package/dist/chunk-7RPFJZLP.js +0 -1
- package/dist/chunk-DNMXVMJM.js +0 -47
- package/dist/chunk-IUP7POIE.js +0 -6
- package/dist/chunk-JDR6UVZA.js +0 -8
- package/dist/chunk-JOJV5E2K.js +0 -1
- package/dist/chunk-LVLAOBJM.js +0 -103
- package/dist/chunk-PMHP57MH.js +0 -20
- package/dist/chunk-WDFCOZAY.js +0 -16
- package/dist/chunk-ZGV3HNEV.js +0 -1
- package/dist/dist-4H2B7BMN.js +0 -1
- package/dist/dist-QNWOGQN3.js +0 -1
- package/dist/error-handler-74HKA23T.js +0 -1
- package/dist/upgrade-7U2TUNC4.js +0 -1
- package/dist/version-SXQTRBXB.js +0 -1
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import{a as Yt}from"./chunk-UOHNRH6E.js";import{b as zr}from"./chunk-QKVVJXWS.js";import{a as Yr}from"./chunk-YKS7MH3F.js";import{a as Jr}from"./chunk-7WPUV7GY.js";import{a as Qr}from"./chunk-53BG3NLH.js";import{a as Mr}from"./chunk-AYL6KBPE.js";import{a as Or,b as Nr,c as Wr,d as qr}from"./chunk-PYIICTLX.js";import{a as Kr}from"./chunk-SL3VBI62.js";import{a as Hr}from"./chunk-4GCI2YCZ.js";import{a as jr}from"./chunk-Z5SILNH2.js";import{a as Vr}from"./chunk-HIRTL45Q.js";import{a as Gr}from"./chunk-ZYQ2XWC5.js";import{a as Br}from"./chunk-CCMDZX35.js";import{a as br}from"./chunk-PMHP57MH.js";import{a as Ir}from"./chunk-5NEGOQT6.js";import{a as Tr}from"./chunk-5UWMXOHM.js";import{a as Cr}from"./chunk-M4BVLMPH.js";import{g as _r}from"./chunk-LVLAOBJM.js";import{a as ct}from"./chunk-BCYTZ7LM.js";import{c as it,n as lt}from"./chunk-DNMXVMJM.js";import{a as kr}from"./chunk-RFGEM5JC.js";import{a as $r}from"./chunk-SFPXYHHL.js";import{a as Ar}from"./chunk-N2RFDHRY.js";import{b as Ur,g as Fe,j as at,u as Rr}from"./chunk-5TB52UUV.js";import{a as Dr}from"./chunk-GCNA3HXH.js";import{a as _o,b as Lo,c as Co,d as ko}from"./chunk-U25W35TX.js";import{d as Fr}from"./chunk-UWMZ5CSB.js";import{a as Er,b as Sr,c as Ao,d as Io,e as dt,f as To,g as $o}from"./chunk-3G4HJO72.js";import{a as M,b as st}from"./chunk-SFQEHDJY.js";import{a as gr,b as wr,d as ke,f as yr,m as $e,n as B,s as j,u as vr,v as Pr,w as xr}from"./chunk-Q7BOSHWX.js";import{a as hr}from"./chunk-R7EMV77H.js";import{a as Fo,b as Do,c as Mo,d as ft,e as Oo,f as No,g as Wo,h as qo,i as Ho,j as jo,k as Go,l as Bo,m as Ko,n as Vo,o as zo,p as mt}from"./chunk-MXJAH2GW.js";import{a as Po,b as ut,c as oe,d as xo}from"./chunk-PEVIRAMR.js";import{a as Eo,b as So,c as bo,d as Uo,e as Ro}from"./chunk-EMSF57ZB.js";import{a as Zr}from"./chunk-YVY32DNA.js";import{a as vo}from"./chunk-UVRKTMF7.js";import{a as yo}from"./chunk-ZGV3HNEV.js";import{a as Xr}from"./chunk-FWB3GLMW.js";import{Aa as Oe,L as po,Ma as wo,N as uo,P as re,Z as fo,_ as ho,i as eo,ia as go,j as G,k as to,n as oo,p as ls,t as pt,u as no,v as so,w as ao,x as io,y as co,z as lo,za as Me}from"./chunk-3C6VLJ5D.js";import{D as ro,oa as mo,r as De,w as de}from"./chunk-WDFCOZAY.js";import{a as Lr}from"./chunk-D7NB7YR6.js";import{d as dr}from"./chunk-UOS2XLGG.js";import{a as z}from"./chunk-IQVRP7CT.js";import{M as Bt,_ as ee,aa as Kt,c as Wt,h as qt,j as Ht,m as jt,o as Gt,p as Se,ta as Vt,u as be}from"./chunk-H4V55Y3Z.js";import{b as fr,c as mr,e as Ce}from"./chunk-Q2SZCZE7.js";import{B as pe,I as Te,M as sr,O as _e,T as Le,U as ue,V as nt,W as ir,Y as cr,a as Nt,d as D,e as Ue,f as tt,g as F,h as N,j as Re,k as Ae,l as Jt,m as Qt,n as Xt,o as Zt,p as er,q as tr,r as rt,s as ot,t as rr,u as or,w as nr,z as Ie}from"./chunk-CZ22VZDA.js";import{b as le,d as Ee,j as Mt,m as Ot}from"./chunk-335BUVBP.js";import{a as ge}from"./chunk-BN7ZXAZJ.js";import{a as cs}from"./chunk-7UNQOKZW.js";import{d as zt}from"./chunk-X7HVAVSZ.js";import{h as T,j as ar,k as te}from"./chunk-2VSNFOKD.js";import{a as Ne}from"./chunk-FFHH5LOR.js";import{Aa as Ct,Ba as kt,Bb as y,Cb as k,Da as $t,Hb as ur,Ma as xe,P as Xe,Sa as O,Va as ce,_a as Ft,bb as Dt,la as C,qb as R,sb as I,ta as Pe,va as Z,xa as Ze,ya as Lt,yb as V}from"./chunk-LWCTKI4Z.js";import{b as A,c as ae,d as ie,j as et}from"./chunk-FZCGRIOM.js";import{e as lr,g as pr}from"./chunk-3A3DZVEJ.js";import{b as is}from"./chunk-YTUUU33R.js";import{a as At}from"./chunk-JD5P5RAJ.js";import{c as U,e as Qe,f as It,h as we,i as ye,j as ve,n as Tt,o as _t}from"./chunk-IWTNUJGY.js";import{e as X,g as u}from"./chunk-VKWPEFWQ.js";u();u();u();u();u();u();var ps=300*1e3,us='The host theme could not be created to host your theme app extension. Please try again or use the "--theme" flag to use an existing theme as the host theme.';async function Yo(t,e,r=Date.now()){for(;await ds(t,e,r););}async function ds(t,e,r){let o=await Fe(t,e);if(!o||fs(o,r))throw new T(us);return await ue(3),o.processing}function fs(t,e){return t.processing&&Date.now()-e>=ps}var ms="https://codeload.github.com/Shopify/dawn/zip/refs/tags/v15.0.0",hs="https://cdn.shopify.com/theme-store/uhrdefhlndzaoyrgylhto59sx2i7.jpg",ht=3,We=class extends Ar{context="App Ext. Host";devPreview;constructor(e,r={devPreview:!1}){super(e),this.themeId=Or(e.storeFqdn),this.devPreview=r.devPreview}async findOrCreate(){let e=await this.fetch();return e??=this.devPreview?await this.createHostTheme():await this.create(),e}setTheme(e){Nr(this.adminSession.storeFqdn,e)}removeTheme(){Wr(this.adminSession.storeFqdn)}async createHostTheme(){let e={role:Ur,name:this.generateThemeName(this.context),src:ms};for(let o=0;o<ht;o++){y(`Attempt ${o}/${ht}: Creating theme with name "${e.name}" and role "${e.role}"`);try{let n=await at(e,this.adminSession);if(n)return this.setTheme(n.id.toString()),y(`Waiting for theme with id "${n.id}" to be processed`),await Yo(n.id,this.adminSession),n;throw new Error}catch(n){if(n instanceof ar||Rr(n))throw n;y(`Failed to create theme with name "${e.name}" and role "${e.role}". Retrying...`)}}y(`Theme creation failed after ${ht} retries. Creating theme using fallback theme zip`);let r=await at({...e,src:hs},this.adminSession);if(!r)throw y("Theme creation failed. Exiting process."),new te(`Could not create theme with name "${e.name}" and role "${e.role}"`);return r}};u();var gs={"theme:init":Dr,"theme:check":br,"theme:console":Ir,"theme:delete":Tr,"theme:dev":Cr,"theme:duplicate":kr,"theme:info":$r,"theme:language-server":Mr,"theme:list":qr,"theme:metafields:pull":Kr,"theme:open":Hr,"theme:package":jr,"theme:profile":Gr,"theme:publish":Br,"theme:preview":Vr,"theme:pull":zr,"theme:push":Yr,"theme:rename":Jr,"theme:share":Qr},Ii=gs;async function Jo(t){let{remoteApp:e,localApp:r}=t,n=r.allExtensions.filter(x=>x.isThemeExtension);if(n.length===0)return;let s=n[0].directory,i=t.themeExtensionPort??9293,[l,f]=await Promise.all([Bt(t.storeFqdn),vs(e)]),c=l.storeFqdn,[p,h]=await Promise.all([lt(l),it(l)]),g=h?await ct(t.storePassword,c,p):void 0,d=await ys(l,t.theme),m=d.id.toString();return Ie({headline:"The theme app extension development server is ready.",orderedNextSteps:!0,nextSteps:[[{link:{label:"Install your app in your development store",url:f}}],[{link:{label:"Setup your theme app extension in the host theme",url:`https://${c}/admin/themes/${m}/editor`}}],["Preview your theme app extension at",{link:{label:`http://127.0.0.1:${i}`,url:`http://127.0.0.1:${i}`}}]]}),{type:"theme-app-extensions",prefix:"theme-extensions",function:ws,options:{theme:d,adminSession:l,storefrontPassword:g,crawlerSignatureHeaders:p,themeExtensionDirectory:s,themeExtensionPort:i}}}var ws=async(t,{theme:e,adminSession:r,storefrontPassword:o,crawlerSignatureHeaders:n,themeExtensionDirectory:a,themeExtensionPort:s})=>{await(await _r(e,{adminSession:r,storefrontPassword:o,crawlerSignatureHeaders:n,themeExtensionDirectory:a,themeExtensionPort:s})).start()};async function ys(t,e){let r;if(e)y(`Fetching theme with provided id ${e}`),r=await Fe(parseInt(e,10),t);else{let o=new We(t,{devPreview:!0});await Te([{title:"Configuring host theme for theme app extension",task:async()=>{y("Finding or creating host theme for theme app extensions"),r=await o.findOrCreate()}}])}if(!r)throw new T("Could not find or create a host theme for theme app extensions");return r}async function vs(t){return t.developerPlatformClient?.clientName===mo.AppManagement?`https://${await Se()}/?organization_id=${t.organizationId}&no_redirect=true&redirect=/oauth/redirect_from_developer_dashboard?client_id%3D${t.apiKey}`:`https://${await Gt()}/${t.organizationId}/apps/${t.id}/test`}u();u();u();u();u();u();async function Ps(t){let e=U(t.directory,"locales");return ce([U(e,"*.json")])}async function Qo(t,e){let r=await Ps(t);if(!r.length)return{localization:void 0,status:""};let o=e.currentLocalizationPayload??{defaultLocale:"en",translations:{},lastUpdated:0},n="success";try{await Promise.all(r.map(async a=>{let[s,...i]=a.split("/").pop().split(".");if(s)return i[0]==="default"&&(o.defaultLocale=s),xs(s,a,o,t,e)})),o.lastUpdated=Date.now(),y(`Parsed locales for extension ${t.handle} at ${t.directory}`,e.stdout)}catch{n="error"}return{localization:o,status:n}}async function xs(t,e,r,o,n){let a;try{a=await C(e),r.translations[t]=JSON.parse(a)}catch(s){let i=`Error parsing ${t} locale for ${o.handle} at ${e}: ${s.message}`;throw k(i,n.stderr),new Error(i)}}u();function qe(t,e){switch(t){case"checkout_ui_extension":return{url:e.checkoutCartUrl};case"checkout_post_purchase":return{url:e.checkoutCartUrl};case"product_subscription":return{url:e.subscriptionProductUrl??""};default:return{url:""}}}var gt=".js.map";async function ne(t,e,r,o){return D({outputPrefix:t.outputPrefix},async()=>{o?.clear();let n=t.getOutputPathForDirectory(e),a=`${r.url}/extensions/${t.devUUID}`,{localization:s,status:i}=await Qo(t,r),l=await to(t),f=t.outputRelativePath?we(n):n,c=await Es(t,a,f,o),p=null;return"metafields"in t.configuration&&Array.isArray(t.configuration.metafields)&&t.configuration.metafields.length>0&&(p=Xo(t.configuration.metafields)),{assets:{main:fe(c)&&c[0]?.assets?.main?c[0].assets.main:{name:"main",url:`${a}/assets/${t.outputFileName}`,lastUpdated:await xe(n)??0}},supportedFeatures:{runsOffline:t.configuration.supported_features?.runs_offline??!1},capabilities:{blockProgress:t.configuration.capabilities?.block_progress??!1,networkAccess:t.configuration.capabilities?.network_access??!1,apiAccess:t.configuration.capabilities?.api_access??!1,collectBuyerConsent:{smsMarketing:t.configuration.capabilities?.collect_buyer_consent?.sms_marketing??!1,customerPrivacy:t.configuration.capabilities?.collect_buyer_consent?.customer_privacy??!1},iframe:{sources:t.configuration.capabilities?.iframe?.sources??[]}},development:{...r.currentDevelopmentPayload,resource:qe(t.type,r),root:{url:a},hidden:r.currentDevelopmentPayload?.hidden??!1,localizationStatus:i,status:r.currentDevelopmentPayload?.status??"success",...r.currentDevelopmentPayload??{status:"success"}},extensionPoints:c,localization:s??null,metafields:p,type:t.type,externalType:t.externalType,uuid:t.devUUID,surface:t.surface,version:l?.version,title:t.name,handle:t.handle,name:t.name,description:t.configuration.description,apiVersion:t.configuration.api_version,approvalScopes:r.grantedScopes,settings:t.configuration.settings}})}async function Es(t,e,r,o){let n=t.configuration,a=n.extension_points??n.targeting;if(t.type==="checkout_post_purchase"&&(a=[{target:"purchase.post.render"}]),fe(a)){let s=await Ss(r);return Promise.all(a.map(async i=>{let{target:l,resource:f}=i,c="metafields"in i?Xo(i.metafields??[]):void 0,p={...i,...c?{metafields:c}:{},surface:Oe(l),root:{url:`${e}/${l}`},resource:f||{url:""}},h=s?.[l];if(!h)return p;let d=await Ts(h,{target:l,extensionPoint:i,url:e,extension:t,buildDirectory:r,resolver:o});return{...p,...d}}))}return a}async function Ss(t){try{let e=U(t,"manifest.json"),r=await C(e);return JSON.parse(r)}catch(e){if(e instanceof SyntaxError)throw new Error(`Invalid manifest.json in ${t}: ${e.message}`);return null}}async function bs({target:t,extensionPoint:e,url:r,extension:o,resolver:n},a,s){let i=`${t}/${a}`,l=e[a];if(typeof l=="string"){let g=await He(a,i,typeof s=="string"?s:l,r,o,n,typeof s=="string"?l:void 0);return{assets:{[g.name]:g}}}let c=e.build_manifest?.assets?.[a];if(c?.filepath){let p=await He(a,i,c.filepath,r,o,n,c.module);return{assets:{[p.name]:p}}}return{}}async function Us({target:t,url:e,buildDirectory:r,resolver:o},n,a){if(a.length===0)return{};for(let i of a)o?.set(`${t}/${i}`,i);let s=await Promise.all(a.map(async i=>await xe(U(r,i))??0));return{assets:{[n]:{name:n,url:`${e}/assets/${t}/`,lastUpdated:Math.max(...s)}}}}async function Rs({target:t,extensionPoint:e,url:r,extension:o,resolver:n},a){return e.intents?{intents:await Promise.all(e.intents.map(async(i,l)=>{let f=i.schema,c=a[l]?.schema,p=typeof c=="string"?c:f,h=typeof c=="string"?f:void 0;return{...i,schema:await He("schema",`${t}/intents/${l}/schema`,p,r,o,n,h)}}))}:{}}async function As({target:t,url:e,extension:r,resolver:o},n,a){let s=await He(n,`${t}/${n}`,a,e,r,o);return await Is(t,a,r,o),{assets:{[s.name]:s}}}async function Is(t,e,r,o){if(!o)return;let n=`${e}.map`;n.endsWith(gt)&&await O(U(r.directory,n))&&o.set(`${t}/${ye(n)}`,n)}async function Ts(t,e){return(await Promise.all(Object.keys(t).map(async o=>{let n=t[o];return _s(o,n)?Rs(e,n):Ls(o,n)?As(e,o,n):Cs(o,n)?Us(e,o,n):bs(e,o,n)}))).reduce((o,n)=>({...o,...n,assets:{...o.assets,...n.assets}}),{})}function Xo(t){return t.map(e=>({namespace:e.namespace,key:e.key,...e.owner_type===void 0?{}:{ownerType:e.owner_type.replaceAll("_","")}}))}function fe(t){return Array.isArray(t)&&t.every(e=>typeof e=="object")}async function He(t,e,r,o,n,a,s){let i=`${e}${ve(r)}`;return a?.set(i,r),{name:t,url:`${o}/assets/${i}`,lastUpdated:await xe(U(n.directory,s??r))??0}}function _s(t,e){return t==="intents"&&Array.isArray(e)}function Ls(t,e){return(t==="main"||t==="should_render")&&typeof e=="string"}function Cs(t,e){return t==="assets"&&Array.isArray(e)&&e.every(r=>typeof r=="string")}import{EventEmitter as ks}from"events";var me;(function(t){t.Update="PayloadUpdatedEvent:UPDATE"})(me||(me={}));async function Zo(t,e,r){return{app:{title:t.appName,apiKey:t.apiKey,url:Ao(t.storeFqdn,t.apiKey),mobileUrl:To(t.storeFqdn,t.apiKey)},appId:t.id,version:t.manifestVersion,root:{url:new URL("/extensions",t.url).toString()},socket:{url:t.websocketURL},devConsole:{url:new URL("/extensions/dev-console",t.url).toString()},store:t.storeFqdn,extensions:await Promise.all(t.extensions.filter(n=>n.isPreviewable).map(n=>ne(n,e,t,r&&wt(r,n.devUUID))))}}function wt(t,e){let r=t.get(e);return r||(r=new Map,t.set(e,r)),r}var je=class extends ks{options;rawPayload;assetResolvers;constructor(e,r,o=new Map){super(),this.rawPayload=e,this.options=r,this.assetResolvers=o}getAssetResolver(e){return this.assetResolvers.get(e)}getConnectedPayload(){let e=this.getRawPayload();return{app:e.app,appId:e.appId,store:e.store,extensions:e.extensions}}getRawPayloadFilteredByExtensionIds(e){return{...this.rawPayload,extensions:this.rawPayload.extensions.filter(r=>e.includes(r.uuid))}}getRawPayload(){return this.rawPayload}updateApp(e){this.rawPayload=ee(this.rawPayload,{app:e}),this.emitUpdate([])}updateExtensions(e){let r=this.rawPayload.extensions.map(o=>{let n=e.find(a=>a.uuid===o.uuid);if(n){if(fe(n.extensionPoints)&&fe(o.extensionPoints)){let a=n.extensionPoints.reduce((l,f)=>({...l,[f.target]:f}),{});o.extensionPoints=ee(o.extensionPoints,n.extensionPoints,l=>l.map(f=>{let c=a[f.target];return c?ee(f,c,(p,h)=>h):f}));let{extensionPoints:s,...i}=n;return ee(o,i)}return ee(o,n)}return o});this.rawPayload={...this.rawPayload,extensions:r},this.emitUpdate(e.map(o=>o.uuid))}async updateExtension(e,r,o,n){let a=this.rawPayload.extensions,s=a.findIndex(i=>i.uuid===e.devUUID);if(s===-1){y(I`Could not updateExtension() for extension with uuid: ${e.devUUID}`,r.stderr);return}a[s]=await ne(e,o,{...this.options,currentDevelopmentPayload:n??{status:a[s]?.development.status},currentLocalizationPayload:a[s]?.localization},wt(this.assetResolvers,e.devUUID)),this.rawPayload.extensions=a,this.emitUpdate([e.devUUID])}deleteExtension(e){let r=this.rawPayload.extensions.findIndex(o=>o.uuid===e.devUUID);r!==-1&&(this.rawPayload.extensions.splice(r,1),this.assetResolvers.delete(e.devUUID),this.emitUpdate([e.devUUID]))}async addExtension(e,r){this.rawPayload.extensions.push(await ne(e,r,this.options,wt(this.assetResolvers,e.devUUID))),this.emitUpdate([e.devUUID])}emitUpdate(e){this.emit(me.Update,e)}};u();u();var Y;(function(t){t.Update="update",t.Dispatch="dispatch",t.Log="log"})(Y||(Y={}));function en(t,e){return(r,o,n)=>{r.url==="/extensions"&&(y("Upgrading HTTP request to a websocket connection",e.stdout),t.handleUpgrade(r,o,n,$s(t,e)))}}function $s(t,e){return r=>{y("Websocket connection successfully established",e.stdout);let o={event:"connected",data:e.payloadStore.getConnectedPayload(),version:e.manifestVersion};y(I`Sending connected payload: ${R.json(o)}`,e.stdout),r.send(JSON.stringify(o)),r.on("message",Ns(t,e))}}function Fs(t){try{let e=JSON.parse(t);if(!Array.isArray(e))return t;let r=e.map(o=>typeof o=="object"&&o!==null?R.json(o).output():String(o)).join(" ");return I`${r}`.value}catch(e){if(e instanceof SyntaxError)return t;throw e}}var Ds={debug:t=>R.gray(t),warn:t=>R.yellow(t),error:t=>R.errorText(t)};function Ms({type:t,message:e}){let r=Fs(e);switch(t){case"debug":case"warn":case"error":return I`${Ds[t](t.toUpperCase())}: ${r}`.value;case"log":case"info":return r;default:return`${t.toUpperCase()}: ${r}`}}function Os(t,e){D({outputPrefix:t.extensionName,stripAnsi:!1},()=>{e.stdout.write(Ms(t))})}function Ns(t,e){return r=>{let o=JSON.parse(r.toString()),{event:n,data:a}=o;if(y(I`Received websocket message with event type ${n} and data:
|
|
2
|
-
${R.json(
|
|
3
|
-
`,e.stdout),n===Y.Update){let
|
|
1
|
+
import{a as Yt}from"./chunk-UOHNRH6E.js";import{b as zr}from"./chunk-VXL5FBE7.js";import{a as Yr}from"./chunk-4SDCXKYR.js";import{a as Jr}from"./chunk-KNQXCU3Y.js";import{a as Qr}from"./chunk-43HKFLOU.js";import{a as Mr}from"./chunk-EXTVC33U.js";import{a as Or,b as Nr,c as Wr,d as qr}from"./chunk-PNZURX3S.js";import{a as Kr}from"./chunk-JMVK2BIB.js";import{a as Hr}from"./chunk-X4A5D3PZ.js";import{a as jr}from"./chunk-ZTZGDZCE.js";import{a as Vr}from"./chunk-FS5PZCZ3.js";import{a as Gr}from"./chunk-LR4J4KYJ.js";import{a as Br}from"./chunk-MMUGP3WP.js";import{a as br}from"./chunk-6JZC6UKY.js";import{a as Tr}from"./chunk-CFUZ6574.js";import{a as Ir}from"./chunk-37P5YOP2.js";import{a as Cr}from"./chunk-AOBE6HN6.js";import{g as _r}from"./chunk-FVRI7ZKE.js";import{a as ct}from"./chunk-2CJQQQW4.js";import{c as it,o as lt}from"./chunk-2RFCYZMG.js";import{a as kr}from"./chunk-RWTAPWLJ.js";import{a as $r}from"./chunk-FK5OFLSJ.js";import{a as Ar}from"./chunk-QGWC23HQ.js";import{b as Ur,g as Fe,j as at,u as Rr}from"./chunk-2NZ7GDDR.js";import{a as Dr}from"./chunk-MXXMIPUN.js";import{a as _o,b as Lo,c as Co,d as ko}from"./chunk-CWR3IFXD.js";import{d as Fr}from"./chunk-XZLM4HLO.js";import{a as Er,b as Sr,c as Ao,d as To,e as dt,f as Io,g as $o}from"./chunk-NJVNGEOU.js";import{a as M,b as st}from"./chunk-KGASGUDQ.js";import{a as gr,b as wr,d as ke,f as yr,m as $e,n as B,s as j,u as vr,v as Pr,w as xr}from"./chunk-Q7BOSHWX.js";import{a as hr}from"./chunk-GHU6YEXH.js";import{a as Fo,b as Do,c as Mo,d as ft,e as Oo,f as No,g as Wo,h as qo,i as Ho,j as jo,k as Go,l as Bo,m as Ko,n as Vo,o as zo,p as mt}from"./chunk-L6VONMA2.js";import{a as Po,b as ut,c as oe,d as xo}from"./chunk-GGJUPL4W.js";import{a as Eo,b as So,c as bo,d as Uo,e as Ro}from"./chunk-BB7GAZP6.js";import{a as Zr}from"./chunk-2QQ7EBJD.js";import{a as vo}from"./chunk-NMLLRFZF.js";import{a as yo}from"./chunk-NPB753M3.js";import{a as Xr}from"./chunk-D4LFWIFE.js";import{Aa as Oe,L as po,Ma as wo,N as uo,P as re,Z as fo,_ as ho,i as eo,ia as go,j as G,k as to,n as oo,p as ls,t as pt,u as no,v as so,w as ao,x as io,y as co,z as lo,za as Me}from"./chunk-XV6XCOTG.js";import{E as ro,pa as mo,s as De,x as de}from"./chunk-WFOU5M4H.js";import{a as Lr}from"./chunk-M73IECPW.js";import{d as dr}from"./chunk-HP2ZAAY7.js";import{a as z}from"./chunk-ZHHTQRWU.js";import{M as Bt,_ as ee,aa as Kt,c as Wt,h as qt,j as Ht,m as jt,o as Gt,p as Se,ta as Vt,u as be}from"./chunk-NCPZVARH.js";import{b as fr,c as mr,e as Ce}from"./chunk-5AWELO3D.js";import{B as pe,I as Ie,M as sr,O as _e,T as Le,U as ue,V as nt,W as ir,Y as cr,a as Nt,d as D,e as Ue,f as tt,g as F,h as N,j as Re,k as Ae,l as Jt,m as Qt,n as Xt,o as Zt,p as er,q as tr,r as rt,s as ot,t as rr,u as or,w as nr,z as Te}from"./chunk-V654BMS7.js";import{b as le,d as Ee,j as Mt,m as Ot}from"./chunk-335BUVBP.js";import{a as ge}from"./chunk-BN7ZXAZJ.js";import{a as cs}from"./chunk-7UNQOKZW.js";import{d as zt}from"./chunk-FHNJLON5.js";import{h as I,j as ar,k as te}from"./chunk-J7BTC45S.js";import{a as Ne}from"./chunk-YCUEDZDA.js";import{Aa as Ct,Ba as kt,Bb as y,Cb as k,Da as $t,Hb as ur,Ma as xe,P as Xe,Sa as O,Va as ce,_a as Ft,bb as Dt,la as C,qb as R,sb as T,ta as Pe,va as Z,xa as Ze,ya as Lt,yb as V}from"./chunk-RIG66DIQ.js";import{b as A,c as ae,d as ie,j as et}from"./chunk-FZCGRIOM.js";import{e as lr,g as pr}from"./chunk-GSGCSBRN.js";import{b as is}from"./chunk-YTUUU33R.js";import{a as At}from"./chunk-JD5P5RAJ.js";import{c as U,e as Qe,f as Tt,h as we,i as ye,j as ve,n as It,o as _t}from"./chunk-IWTNUJGY.js";import{e as X,g as u}from"./chunk-VKWPEFWQ.js";u();u();u();u();u();u();var ps=300*1e3,us='The host theme could not be created to host your theme app extension. Please try again or use the "--theme" flag to use an existing theme as the host theme.';async function Yo(t,e,r=Date.now()){for(;await ds(t,e,r););}async function ds(t,e,r){let o=await Fe(t,e);if(!o||fs(o,r))throw new I(us);return await ue(3),o.processing}function fs(t,e){return t.processing&&Date.now()-e>=ps}var ms="https://codeload.github.com/Shopify/dawn/zip/refs/tags/v15.0.0",hs="https://cdn.shopify.com/theme-store/uhrdefhlndzaoyrgylhto59sx2i7.jpg",ht=3,We=class extends Ar{context="App Ext. Host";devPreview;constructor(e,r={devPreview:!1}){super(e),this.themeId=Or(e.storeFqdn),this.devPreview=r.devPreview}async findOrCreate(){let e=await this.fetch();return e??=this.devPreview?await this.createHostTheme():await this.create(),e}setTheme(e){Nr(this.adminSession.storeFqdn,e)}removeTheme(){Wr(this.adminSession.storeFqdn)}async createHostTheme(){let e={role:Ur,name:this.generateThemeName(this.context),src:ms};for(let o=0;o<ht;o++){y(`Attempt ${o}/${ht}: Creating theme with name "${e.name}" and role "${e.role}"`);try{let n=await at(e,this.adminSession);if(n)return this.setTheme(n.id.toString()),y(`Waiting for theme with id "${n.id}" to be processed`),await Yo(n.id,this.adminSession),n;throw new Error}catch(n){if(n instanceof ar||Rr(n))throw n;y(`Failed to create theme with name "${e.name}" and role "${e.role}". Retrying...`)}}y(`Theme creation failed after ${ht} retries. Creating theme using fallback theme zip`);let r=await at({...e,src:hs},this.adminSession);if(!r)throw y("Theme creation failed. Exiting process."),new te(`Could not create theme with name "${e.name}" and role "${e.role}"`);return r}};u();var gs={"theme:init":Dr,"theme:check":br,"theme:console":Tr,"theme:delete":Ir,"theme:dev":Cr,"theme:duplicate":kr,"theme:info":$r,"theme:language-server":Mr,"theme:list":qr,"theme:metafields:pull":Kr,"theme:open":Hr,"theme:package":jr,"theme:profile":Gr,"theme:publish":Br,"theme:preview":Vr,"theme:pull":zr,"theme:push":Yr,"theme:rename":Jr,"theme:share":Qr},Ti=gs;async function Jo(t){let{remoteApp:e,localApp:r}=t,n=r.allExtensions.filter(x=>x.isThemeExtension);if(n.length===0)return;let a=n[0].directory,i=t.themeExtensionPort??9293,[l,f]=await Promise.all([Bt(t.storeFqdn),vs(e)]),c=l.storeFqdn,[p,h]=await Promise.all([lt(l),it(l)]),g=h?await ct(t.storePassword,c,p):void 0,d=await ys(l,t.theme),m=d.id.toString();return Te({headline:"The theme app extension development server is ready.",orderedNextSteps:!0,nextSteps:[[{link:{label:"Install your app in your development store",url:f}}],[{link:{label:"Setup your theme app extension in the host theme",url:`https://${c}/admin/themes/${m}/editor`}}],["Preview your theme app extension at",{link:{label:`http://127.0.0.1:${i}`,url:`http://127.0.0.1:${i}`}}]]}),{type:"theme-app-extensions",prefix:"theme-extensions",function:ws,options:{theme:d,adminSession:l,storefrontPassword:g,crawlerSignatureHeaders:p,themeExtensionDirectory:a,themeExtensionPort:i}}}var ws=async(t,{theme:e,adminSession:r,storefrontPassword:o,crawlerSignatureHeaders:n,themeExtensionDirectory:s,themeExtensionPort:a})=>{await(await _r(e,{adminSession:r,storefrontPassword:o,crawlerSignatureHeaders:n,themeExtensionDirectory:s,themeExtensionPort:a})).start()};async function ys(t,e){let r;if(e)y(`Fetching theme with provided id ${e}`),r=await Fe(parseInt(e,10),t);else{let o=new We(t,{devPreview:!0});await Ie([{title:"Configuring host theme for theme app extension",task:async()=>{y("Finding or creating host theme for theme app extensions"),r=await o.findOrCreate()}}])}if(!r)throw new I("Could not find or create a host theme for theme app extensions");return r}async function vs(t){return t.developerPlatformClient?.clientName===mo.AppManagement?`https://${await Se()}/?organization_id=${t.organizationId}&no_redirect=true&redirect=/oauth/redirect_from_developer_dashboard?client_id%3D${t.apiKey}`:`https://${await Gt()}/${t.organizationId}/apps/${t.id}/test`}u();u();u();u();u();u();async function Ps(t){let e=U(t.directory,"locales");return ce([U(e,"*.json")])}async function Qo(t,e){let r=await Ps(t);if(!r.length)return{localization:void 0,status:""};let o=e.currentLocalizationPayload??{defaultLocale:"en",translations:{},lastUpdated:0},n="success";try{await Promise.all(r.map(async s=>{let[a,...i]=s.split("/").pop().split(".");if(a)return i[0]==="default"&&(o.defaultLocale=a),xs(a,s,o,t,e)})),o.lastUpdated=Date.now(),y(`Parsed locales for extension ${t.handle} at ${t.directory}`,e.stdout)}catch{n="error"}return{localization:o,status:n}}async function xs(t,e,r,o,n){let s;try{s=await C(e),r.translations[t]=JSON.parse(s)}catch(a){let i=`Error parsing ${t} locale for ${o.handle} at ${e}: ${a.message}`;throw k(i,n.stderr),new Error(i)}}u();function qe(t,e){switch(t){case"checkout_ui_extension":return{url:e.checkoutCartUrl};case"checkout_post_purchase":return{url:e.checkoutCartUrl};case"product_subscription":return{url:e.subscriptionProductUrl??""};default:return{url:""}}}var gt=".js.map";async function ne(t,e,r,o){return D({outputPrefix:t.outputPrefix},async()=>{o?.clear();let n=t.getOutputPathForDirectory(e),s=`${r.url}/extensions/${t.devUUID}`,{localization:a,status:i}=await Qo(t,r),l=await to(t),f=t.outputRelativePath?we(n):n,c=await Es(t,s,f,o),p=null;return"metafields"in t.configuration&&Array.isArray(t.configuration.metafields)&&t.configuration.metafields.length>0&&(p=Xo(t.configuration.metafields)),{assets:{main:fe(c)&&c[0]?.assets?.main?c[0].assets.main:{name:"main",url:`${s}/assets/${t.outputFileName}`,lastUpdated:await xe(n)??0}},supportedFeatures:{runsOffline:t.configuration.supported_features?.runs_offline??!1},capabilities:{blockProgress:t.configuration.capabilities?.block_progress??!1,networkAccess:t.configuration.capabilities?.network_access??!1,apiAccess:t.configuration.capabilities?.api_access??!1,collectBuyerConsent:{smsMarketing:t.configuration.capabilities?.collect_buyer_consent?.sms_marketing??!1,customerPrivacy:t.configuration.capabilities?.collect_buyer_consent?.customer_privacy??!1},iframe:{sources:t.configuration.capabilities?.iframe?.sources??[]}},development:{...r.currentDevelopmentPayload,resource:qe(t.type,r),root:{url:s},hidden:r.currentDevelopmentPayload?.hidden??!1,localizationStatus:i,status:r.currentDevelopmentPayload?.status??"success",...r.currentDevelopmentPayload??{status:"success"}},extensionPoints:c,localization:a??null,metafields:p,type:t.type,externalType:t.externalType,uuid:t.devUUID,surface:t.surface,version:l?.version,title:t.name,handle:t.handle,name:t.name,description:t.configuration.description,apiVersion:t.configuration.api_version,approvalScopes:r.grantedScopes,settings:t.configuration.settings}})}async function Es(t,e,r,o){let n=t.configuration,s=n.extension_points??n.targeting;if(t.type==="checkout_post_purchase"&&(s=[{target:"purchase.post.render"}]),fe(s)){let a=await Ss(r);return Promise.all(s.map(async i=>{let{target:l,resource:f}=i,c="metafields"in i?Xo(i.metafields??[]):void 0,p={...i,...c?{metafields:c}:{},surface:Oe(l),root:{url:`${e}/${l}`},resource:f||{url:""}},h=a?.[l];if(!h)return p;let d=await Is(h,{target:l,extensionPoint:i,url:e,extension:t,buildDirectory:r,resolver:o});return{...p,...d}}))}return s}async function Ss(t){try{let e=U(t,"manifest.json"),r=await C(e);return JSON.parse(r)}catch(e){if(e instanceof SyntaxError)throw new Error(`Invalid manifest.json in ${t}: ${e.message}`);return null}}async function bs({target:t,extensionPoint:e,url:r,extension:o,resolver:n},s,a){let i=`${t}/${s}`,l=e[s];if(typeof l=="string"){let g=await He(s,i,typeof a=="string"?a:l,r,o,n,typeof a=="string"?l:void 0);return{assets:{[g.name]:g}}}let c=e.build_manifest?.assets?.[s];if(c?.filepath){let p=await He(s,i,c.filepath,r,o,n,c.module);return{assets:{[p.name]:p}}}return{}}async function Us({target:t,url:e,buildDirectory:r,resolver:o},n,s){if(s.length===0)return{};for(let i of s)o?.set(`${t}/${i}`,i);let a=await Promise.all(s.map(async i=>await xe(U(r,i))??0));return{assets:{[n]:{name:n,url:`${e}/assets/${t}/`,lastUpdated:Math.max(...a)}}}}async function Rs({target:t,extensionPoint:e,url:r,extension:o,resolver:n},s){return e.intents?{intents:await Promise.all(e.intents.map(async(i,l)=>{let f=i.schema,c=s[l]?.schema,p=typeof c=="string"?c:f,h=typeof c=="string"?f:void 0;return{...i,schema:await He("schema",`${t}/intents/${l}/schema`,p,r,o,n,h)}}))}:{}}async function As({target:t,url:e,extension:r,resolver:o},n,s){let a=await He(n,`${t}/${n}`,s,e,r,o);return await Ts(t,s,r,o),{assets:{[a.name]:a}}}async function Ts(t,e,r,o){if(!o)return;let n=`${e}.map`;n.endsWith(gt)&&await O(U(r.directory,n))&&o.set(`${t}/${ye(n)}`,n)}async function Is(t,e){return(await Promise.all(Object.keys(t).map(async o=>{let n=t[o];return _s(o,n)?Rs(e,n):Ls(o,n)?As(e,o,n):Cs(o,n)?Us(e,o,n):bs(e,o,n)}))).reduce((o,n)=>({...o,...n,assets:{...o.assets,...n.assets}}),{})}function Xo(t){return t.map(e=>({namespace:e.namespace,key:e.key,...e.owner_type===void 0?{}:{ownerType:e.owner_type.replaceAll("_","")}}))}function fe(t){return Array.isArray(t)&&t.every(e=>typeof e=="object")}async function He(t,e,r,o,n,s,a){let i=`${e}${ve(r)}`;return s?.set(i,r),{name:t,url:`${o}/assets/${i}`,lastUpdated:await xe(U(n.directory,a??r))??0}}function _s(t,e){return t==="intents"&&Array.isArray(e)}function Ls(t,e){return(t==="main"||t==="should_render")&&typeof e=="string"}function Cs(t,e){return t==="assets"&&Array.isArray(e)&&e.every(r=>typeof r=="string")}import{EventEmitter as ks}from"events";var me;(function(t){t.Update="PayloadUpdatedEvent:UPDATE"})(me||(me={}));async function Zo(t,e,r){return{app:{title:t.appName,apiKey:t.apiKey,url:Ao(t.storeFqdn,t.apiKey),mobileUrl:Io(t.storeFqdn,t.apiKey)},appId:t.id,version:t.manifestVersion,root:{url:new URL("/extensions",t.url).toString()},socket:{url:t.websocketURL},devConsole:{url:new URL("/extensions/dev-console",t.url).toString()},store:t.storeFqdn,extensions:await Promise.all(t.extensions.filter(n=>n.isPreviewable).map(n=>ne(n,e,t,r&&wt(r,n.devUUID))))}}function wt(t,e){let r=t.get(e);return r||(r=new Map,t.set(e,r)),r}var je=class extends ks{options;rawPayload;assetResolvers;constructor(e,r,o=new Map){super(),this.rawPayload=e,this.options=r,this.assetResolvers=o}getAssetResolver(e){return this.assetResolvers.get(e)}getConnectedPayload(){let e=this.getRawPayload();return{app:e.app,appId:e.appId,store:e.store,extensions:e.extensions}}getRawPayloadFilteredByExtensionIds(e){return{...this.rawPayload,extensions:this.rawPayload.extensions.filter(r=>e.includes(r.uuid))}}getRawPayload(){return this.rawPayload}updateApp(e){this.rawPayload=ee(this.rawPayload,{app:e}),this.emitUpdate([])}updateExtensions(e){let r=this.rawPayload.extensions.map(o=>{let n=e.find(s=>s.uuid===o.uuid);if(n){if(fe(n.extensionPoints)&&fe(o.extensionPoints)){let s=n.extensionPoints.reduce((l,f)=>({...l,[f.target]:f}),{});o.extensionPoints=ee(o.extensionPoints,n.extensionPoints,l=>l.map(f=>{let c=s[f.target];return c?ee(f,c,(p,h)=>h):f}));let{extensionPoints:a,...i}=n;return ee(o,i)}return ee(o,n)}return o});this.rawPayload={...this.rawPayload,extensions:r},this.emitUpdate(e.map(o=>o.uuid))}async updateExtension(e,r,o,n){let s=this.rawPayload.extensions,a=s.findIndex(i=>i.uuid===e.devUUID);if(a===-1){y(T`Could not updateExtension() for extension with uuid: ${e.devUUID}`,r.stderr);return}s[a]=await ne(e,o,{...this.options,currentDevelopmentPayload:n??{status:s[a]?.development.status},currentLocalizationPayload:s[a]?.localization},wt(this.assetResolvers,e.devUUID)),this.rawPayload.extensions=s,this.emitUpdate([e.devUUID])}deleteExtension(e){let r=this.rawPayload.extensions.findIndex(o=>o.uuid===e.devUUID);r!==-1&&(this.rawPayload.extensions.splice(r,1),this.assetResolvers.delete(e.devUUID),this.emitUpdate([e.devUUID]))}async addExtension(e,r){this.rawPayload.extensions.push(await ne(e,r,this.options,wt(this.assetResolvers,e.devUUID))),this.emitUpdate([e.devUUID])}emitUpdate(e){this.emit(me.Update,e)}};u();u();var Y;(function(t){t.Update="update",t.Dispatch="dispatch",t.Log="log"})(Y||(Y={}));function en(t,e){return(r,o,n)=>{r.url==="/extensions"&&(y("Upgrading HTTP request to a websocket connection",e.stdout),t.handleUpgrade(r,o,n,$s(t,e)))}}function $s(t,e){return r=>{y("Websocket connection successfully established",e.stdout);let o={event:"connected",data:e.payloadStore.getConnectedPayload(),version:e.manifestVersion};y(T`Sending connected payload: ${R.json(o)}`,e.stdout),r.send(JSON.stringify(o)),r.on("message",Ns(t,e))}}function Fs(t){try{let e=JSON.parse(t);if(!Array.isArray(e))return t;let r=e.map(o=>typeof o=="object"&&o!==null?R.json(o).output():String(o)).join(" ");return T`${r}`.value}catch(e){if(e instanceof SyntaxError)return t;throw e}}var Ds={debug:t=>R.gray(t),warn:t=>R.yellow(t),error:t=>R.errorText(t)};function Ms({type:t,message:e}){let r=Fs(e);switch(t){case"debug":case"warn":case"error":return T`${Ds[t](t.toUpperCase())}: ${r}`.value;case"log":case"info":return r;default:return`${t.toUpperCase()}: ${r}`}}function Os(t,e){D({outputPrefix:t.extensionName,stripAnsi:!1},()=>{e.stdout.write(Ms(t))})}function Ns(t,e){return r=>{let o=JSON.parse(r.toString()),{event:n,data:s}=o;if(y(T`Received websocket message with event type ${n} and data:
|
|
2
|
+
${R.json(s)}
|
|
3
|
+
`,e.stdout),n===Y.Update){let a=e.payloadStore.getRawPayload().app.apiKey,i=s.app?.apiKey;if(s.app){if(a!==i)return;e.payloadStore.updateApp(s.app)}s.extensions&&e.payloadStore.updateExtensions(s.extensions)}else if(n===Y.Dispatch){let a=Ws(o,e);rn(t,a,e)}else n===Y.Log&&Os(s,e)}}function tn(t,e){return r=>{let o={event:Y.Update,version:e.manifestVersion,data:{...e.payloadStore.getRawPayloadFilteredByExtensionIds(r)}};y(T`Sending websocket update event to the websocket clients:
|
|
4
4
|
${R.json(o)}
|
|
5
|
-
`,e.stdout),rn(t,o,e)}}function rn(t,e,r){y(
|
|
5
|
+
`,e.stdout),rn(t,o,e)}}function rn(t,e,r){y(T`Sending websocket with event type ${e.event} and data:
|
|
6
6
|
${R.json(e.data)}
|
|
7
|
-
`,r.stdout);let o=JSON.stringify(e);t.clients.forEach(n=>n.send(o))}function Ws(t,e){let r=e.payloadStore.getRawPayload();return{...t,version:e.manifestVersion,data:{...t.data,extensions:[],store:r.store,app:r.app}}}var qs=10;function on(t){let e=new Yt.default({noServer:!0,clientTracking:!0}),r=Hs(e);return t.httpServer.on("upgrade",en(e,t)),t.payloadStore.on(me.Update,tn(e,t)),{close:()=>{e.close(),clearInterval(r)}}}function Hs(t){return setInterval(()=>{t.clients.forEach(e=>{e.readyState<2&&e.ping()})},qs*1e3)}u();u();u();function nn(t,e){let{url:r}=qe(t.type,e);if(t.surface==="checkout"&&r){let o=new URL(`https://${e.storeFqdn}/`);return o.pathname=r,o.searchParams.append("dev",`${e.url}/extensions`),o.toString()}else{let o=new URL(`https://${e.storeFqdn}/`);return o.pathname="admin/extensions-dev",o.searchParams.append("url",Ge(t,e)),o.toString()}}function sn(t,e,r){let o=Oe(t),n=new URL(`https://${r.storeFqdn}/`);switch(o){case"checkout":n.pathname=r.checkoutCartUrl,n.searchParams.append("dev",`${r.url}/extensions`);break;case"post_purchase":if(n.pathname=r.checkoutCartUrl,n.searchParams.set("script_url",`${r.url}/extensions/${e.devUUID}/assets/${e.localIdentifier}.js`),n.searchParams.set("post_purchase_dev_api_key",r.apiKey),e.devUUID&&r.websocketURL&&(n.searchParams.set("uuid",e.devUUID),n.searchParams.set("socket_url",r.websocketURL)),"metafields"in e.configuration){let a={config:{metafields:e.configuration.metafields}};n.searchParams.set("config",JSON.stringify(a))}break;case"admin":n.pathname="admin/extensions-dev",n.searchParams.append("url",Ge(e,r)),n.searchParams.append("target",t);break;case"customer-accounts":n=js(e,r,t);break;default:return}return n.toString()}function js(t,e,r=""){let o=`${e.url}/extensions`,n=e.storeId,a="shopify.com",s=new URL(`https://${a}/${n}/account/extensions-development`);return s.searchParams.append("origin",o),s.searchParams.append("extensionId",t.devUUID),s.searchParams.append("source","CUSTOMER_ACCOUNT_EXTENSION"),s.searchParams.append("appId",e.id??""),r!==""&&s.searchParams.append("target",r),s}function Ge(t,e){let r=new URL(e.url);return r.pathname=`/extensions/${t.devUUID}`,r.toString()}function H(t,e){wr(t,gr(e))}u();var yt=class extends te{constructor(e){super(`Couldn't find template ${e.template} for extension surface ${e.extensionSurface}`)}};async function an(t){let e=await Gs(t),r=await C(e);return hr(r,t.data)}async function Gs(t){let e=await Bs(),r=[];t.extensionSurface&&r.push(U(e,`${t.extensionSurface}/${t.template}.html.liquid`)),r.push(U(e,`${t.template}.html.liquid`));let o=await ce(r);if(o.length===0)throw new yt(t);return o[0]}async function Bs(){return await Ft("templates/ui-extensions/html",{type:"directory",cwd:_t(import.meta.url)})}var cn=j(t=>{B(t,"Access-Control-Allow-Origin","*"),B(t,"Access-Control-Allow-Methods","GET, OPTIONS"),B(t,"Access-Control-Allow-Headers","Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, ngrok-skip-browser-warning")}),ln=j(t=>{B(t,"Cache-Control","no-cache")}),vt=j(async t=>$e(t,"/extensions",307));async function Ks(t,e){let{filePath:r}=e;if(!await O(r))return H(t,{statusCode:404,statusMessage:`Not Found: ${r}`});if(await $t(r)&&(r+=r.endsWith("/")?"index.html":"/index.html",!await O(r)))return H(t,{statusCode:404,statusMessage:`Not Found: ${r}`});let o=await C(r,{}),n={".ico":"image/x-icon",".html":"text/html",".js":"text/javascript",".json":"application/json",".map":"application/json",".wasm":"application/wasm",".css":"text/css",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".wav":"audio/wav",".mp3":"audio/mpeg",".svg":"image/svg+xml",".pdf":"application/pdf",".doc":"application/msword"},a=ve(r),s=n[a]||"text/plain";return B(t,"Content-Type",s),o}function pn({getExtensions:t,payloadStore:e}){return j(async r=>{let{extensionId:o,assetPath:n=""}=ke(r),a=t().find(h=>h.devUUID===o);if(!a)return H(r,{statusCode:404,statusMessage:`Extension with id ${o} not found`});let i=e.getAssetResolver(a.devUUID)?.get(n),l=i??n,f=l.endsWith(gt);if(f&&i===void 0)return H(r,{statusCode:404,statusMessage:"Not Found"});let c=Qe(f?a.directory:oo(a.outputPath)),p=Qe(U(c,l));return Tt(c,p)?Ks(r,{filePath:p}):H(r,{statusCode:404,statusMessage:"Not Found"})})}function Pt({payloadStore:t}){return j(e=>(B(e,"content-type","application/json"),t.getRawPayload()))}function un({devOptions:t}){return j(e=>{y(`UI extensions server received a ${e.method} request to URL ${e.path}`,t.stdout)})}function xt({devOptions:t,getExtensions:e}){return j(async r=>{let{extensionId:o}=ke(r),n=e().find(i=>i.devUUID===o);if(!n)return H(r,{statusCode:404,statusMessage:`Extension with id ${o} not found`});if(yr(r,"accept")?.startsWith("text/html")){if(n.type==="checkout_post_purchase")return an({data:{url:Ge(n,t)},template:"index",extensionSurface:"post_purchase"});{let i=nn(n,t);return $e(r,i,307)}}let s=t.appWatcher.buildOutputPath;return B(r,"content-type","application/json"),{app:{apiKey:t.apiKey},version:t.manifestVersion,root:{url:new URL("/extensions",t.url).toString()},socket:{url:se(t.url)},devConsole:{url:new URL("/extensions/dev-console",t.url).toString()},store:t.storeFqdn,extension:await ne(n,s,t)}})}function dn({devOptions:t,getExtensions:e}){return j(async r=>{let{extensionId:o,extensionPointTarget:n=""}=ke(r),a=e().find(i=>i.devUUID===o);if(!a)return H(r,{statusCode:404,statusMessage:`Extension with id ${o} not found`});if(a.configuration.type!=="checkout_post_purchase"&&!a.hasExtensionPointTarget(n))return H(r,{statusCode:404,statusMessage:`Extension with id ${o} has not configured the "${n}" extension target`});let s=sn(n,a,t);return s?$e(r,s,307):H(r,{statusCode:404,statusMessage:`Redirect url can't be constructed for extension with id ${o} and extension target "${n}"`})})}import{createServer as Vs}from"http";function fn(t){let e=vr(),r=Pr();e.use(un(t)),e.use(cn),e.use(ln),r.use("/extensions/dev-console",vt),r.use("/extensions/:extensionId",xt(t)),r.use("/extensions/:extensionId/",xt(t)),r.use("/extensions/:extensionId/:extensionPointTarget",dn(t)),r.use("/extensions/:extensionId/assets/**:assetPath",pn(t)),r.use("/extensions",Pt(t)),r.use("/extensions/",Pt(t)),r.use("/",vt),e.use(r);let o=Vs(xr(e));return o.listen(t.devOptions.port,"localhost"),o}async function mn(t){let e={...t,websocketURL:se(t.url)},r=e.appWatcher.buildOutputPath,o=new Map,n=await Zo(e,r,o),a=new je(n,e,o),s=e.extensions.filter(p=>p.isPreviewable),i=()=>s;y("Setting up the UI extensions HTTP server...",e.stdout);let l=fn({devOptions:e,payloadStore:a,getExtensions:i});y("Setting up the UI extensions Websocket server...",e.stdout);let f=on({...e,httpServer:l,payloadStore:a});y("Setting up the UI extensions bundler and file watching...",e.stdout);let c=async({appWasReloaded:p,app:h,extensionEvents:g})=>{p&&(s=h.allExtensions.filter(d=>d.isPreviewable));for(let d of g){if(!d.extension.isPreviewable)continue;let m=d.buildResult?.status==="ok"?"success":"error",x=d.buildResult?.status==="error"?{message:d.buildResult.error,file:d.buildResult.file}:void 0;switch(d.type){case oe.Created:if(e.extensions.push(d.extension),!e.checkoutCartUrl){let S=await Me(e.extensions,e.storeFqdn);e.checkoutCartUrl=S}await a.addExtension(d.extension,r);break;case oe.Updated:await a.updateExtension(d.extension,e,r,{status:m,error:x});break;case oe.Deleted:e.extensions=e.extensions.filter(S=>S.devUUID!==d.extension.devUUID),await a.deleteExtension(d.extension);break}}};e.appWatcher.onEvent(c).onStart(c),e.signal.addEventListener("abort",()=>{y("Closing the UI extensions dev server..."),f.close(),l.close()})}function se(t){let e=new URL("/extensions",t);return e.protocol="wss:",e.toString()}var zs="3",Ys=async({stderr:t,stdout:e,abortSignal:r},{apiKey:o,storeFqdn:n,storeId:a,subscriptionProductUrl:s,port:i,cartUrl:l,proxyUrl:f,appName:c,appDotEnvFile:p,appId:h,grantedScopes:g,allExtensions:d,appDirectory:m,appWatcher:x})=>{await mn({appName:c,appDotEnvFile:p,appDirectory:m,id:h,extensions:d,stdout:e,stderr:t,signal:r,url:f,port:i,storeFqdn:be(n),storeId:a,apiKey:o,grantedScopes:g,checkoutCartUrl:l,subscriptionProductUrl:s,manifestVersion:zs,appWatcher:x})};async function hn({allExtensions:t,storeFqdn:e,checkoutCartUrl:r,...o}){let n=t.filter(s=>s.isPreviewable),a=await Me(n,e,r);return{prefix:"extensions",type:"previewable-extension",function:Ys,options:{pathPrefix:"/extensions",port:-1,storeFqdn:e,allExtensions:t,cartUrl:a,...o}}}u();u();function J(t){let e=t.find(o=>re(o,G.Frontend)),r=t.find(o=>re(o,G.Backend));return{frontendConfig:e,backendConfig:r}}u();async function gn(t){let r={topic:"app/uninstalled",api_version:(await _o(t.developerPlatformClient,t.organizationId))[1],address:t.address,delivery_method:ko.LOCALHOST,shared_secret:t.sharedSecret},o=await Lo(t.developerPlatformClient,r,t.organizationId);t.stdout.write("Sending APP_UNINSTALLED webhook to app server"),await ue(3);let n=await Js(t,o);return t.stdout.write(n?"APP_UNINSTALLED webhook delivered":"APP_UNINSTALLED webhook delivery failed"),n}async function Js(t,e){let r=0;for(;r<3;){try{return await Co(t.address,e.samplePayload,JSON.stringify({...JSON.parse(e.headers),"X-Shopify-Shop-Domain":t.storeFqdn}))}catch(o){if(o instanceof qt&&o.code==="ECONNREFUSED")r<3&&(t.stdout.write("App isn't responding yet, retrying in 5 seconds"),await ue(5));else throw o}r++}return t.stdout.write("App hasn't started in time, giving up"),!1}var Qs=async({stdout:t},e)=>{await gn({stdout:t,developerPlatformClient:e.developerPlatformClient,address:`http://localhost:${e.deliveryPort}${e.webhooksPath}`,sharedSecret:e.apiSecret,storeFqdn:e.storeFqdn,organizationId:e.organizationId})};function wn({webs:t,remoteAppUpdated:e,backendPort:r,frontendPort:o,organizationId:n,...a}){let{backendConfig:s,frontendConfig:i}=J(t),l=t.map(({configuration:c})=>c.webhooks_path).find(c=>c)??"/api/webhooks";if(l&&e&&(i??s))return{type:"send-webhook",prefix:"webhooks",function:Qs,options:{deliveryPort:s?r:o,webhooksPath:l,organizationId:n,...a}}}u();async function yn(t){return{type:"graphiql",prefix:"graphiql",options:t,function:Xs}}var Xs=async({stdout:t,abortSignal:e},r)=>{let o=$o({apiKey:r.apiKey,apiSecret:r.apiSecret,storeFqdn:r.storeFqdn}),n=Sr({stdout:t,port:r.port,storeFqdn:r.storeFqdn,key:r.key,tokenProvider:o,appContext:{appName:r.appName,appUrl:r.appUrl,apiSecret:r.apiSecret}});e.addEventListener("abort",()=>{n.close()})};u();async function Pn({webs:t,proxyUrl:e,frontendPort:r,backendPort:o,apiKey:n,apiSecret:a,scopes:s}){let{frontendConfig:i}=J(t),l=i?.configuration.hmr_server?await M():void 0,f=void 0,c=t.map(async p=>{let h=await Zs({web:p,frontendPort:r,backendPort:o}),g=l&&p.configuration.roles.includes(G.Frontend)?{port:l,httpPaths:p.configuration.hmr_server.http_paths}:void 0;return{type:"web",prefix:p.configuration.name??["web",...p.configuration.roles].join("-"),function:ea,options:{port:h,portFromConfig:p.configuration.port,apiKey:n,apiSecret:a,hostname:e,backendPort:o,frontendServerPort:r,directory:p.directory,devCommand:p.configuration.commands.dev,preDevCommand:p.configuration.commands.predev,scopes:s,shopCustomDomain:f,hmrServerOptions:g,roles:p.configuration.roles}}});return Promise.all(c)}async function Zs({web:t,frontendPort:e,backendPort:r}){return re(t,G.Frontend)?e:re(t,G.Backend)?r:M()}async function ea({stdout:t,stderr:e,abortSignal:r},{port:o,apiKey:n,apiSecret:a,hostname:s,backendPort:i,frontendServerPort:l,directory:f,devCommand:c,preDevCommand:p,scopes:h,shopCustomDomain:g,hmrServerOptions:d}){let m=d?.port,x={SHOPIFY_API_KEY:n,SHOPIFY_API_SECRET:a,HOST:s,SCOPES:h,NODE_ENV:"development",...g&&{SHOP_CUSTOM_DOMAIN:g},BACKEND_PORT:`${i}`,FRONTEND_PORT:`${l}`,...m&&{HMR_SERVER_PORT:`${m}`},APP_URL:s,APP_ENV:"development",REMIX_DEV_ORIGIN:s},S={signal:r,directory:f,port:o,env:x,stdout:t,stderr:e};p&&(t.write(`Running pre-dev command: "${p}"`),await vn({...S,command:p,showOutput:lr()})),await vn({...S,command:c,showOutput:!0})}async function vn({command:t,signal:e,directory:r,port:o,env:n,showOutput:a,stdout:s,stderr:i}){let l=t.split("&&").map(f=>f.trim())??[];for(let f of l){let[c,...p]=f.split(" ");c?.length!==0&&await Le(c,p,{cwd:r,stdout:a?s:void 0,stderr:i,signal:e,env:{...n,PORT:`${o}`,SERVER_PORT:`${o}`}})}}u();u();u();var Be=class{stdout;constructor(e){this.stdout=e}async info(e){await this.log(e)}async warning(e){await this.log(I`${R.yellow(e)}`.value)}async success(e){await this.log(I`${R.green(e)}`.value)}async debug(e){y(e,this.stdout)}async error(e,r){let o=R.errorText("\u274C Error"),n=R.errorText(`\u2514 ${e}`);await this.log(I`${o}`.value,r),await this.log(I`${n}`.value,r)}async logUserErrors(e,r){if(typeof e=="string")await this.error(e);else if(e instanceof Error)await this.error(e.message);else{let o=e.map(n=>{let a=n.on?n.on[0]:void 0,s=r.find(i=>i.uid===a?.user_identifier);return{error:n.message,prefix:s?.handle??"app-preview"}});await this.logMultipleErrors(o)}}async logExtensionEvents(e){let r=e.extensionEvents.filter(n=>n.extension.isAppConfigExtension),o=e.extensionEvents.filter(n=>!n.extension.isAppConfigExtension);r.length&&await this.log("App config updated","app-config"),o.forEach(async n=>{let a=n.extension.handle,s=`Extension ${n.type}`;await this.log(s,a)})}async logExtensionUpdateMessages(e,r){if(!e||r.status==="remote-error"||r.status==="unknown-error")return;let o={status:r.status},n=e.extensionEvents??[],s=(await Promise.all(n.map(async l=>l.type===oe.Deleted?[]:(await l.extension.getDevSessionUpdateMessages(o))?.map(c=>({message:c,prefix:l.extension.handle}))??[]))).flat(),i=s.map((l,f)=>{let c=I`${R.gray(f===s.length-1?"\u2514 ":"\u2502 ")}${l.message}`.value;return this.log(c,l.prefix)});await Promise.all(i)}async logMultipleErrors(e){let r=R.errorText("\u274C Error");await this.log(I`${r}`.value,"app-preview");let o=e.map(n=>{let a=R.errorText(`\u2514 ${n.error}`);return this.log(I`${a}`.value,n.prefix)});await Promise.all(o)}async log(e,r){await D({outputPrefix:r??"app-preview",stripAnsi:!1},()=>{this.stdout.write(`${e}
|
|
8
|
-
`)})}};u();var Ke=class{processBatch;queue=[];processingPromise=void 0;constructor(e){this.processBatch=e}enqueue(e){this.queue.push(e),this.processingPromise??=this.startProcessing()}async waitForCompletion(){if(this.processingPromise)return this.processingPromise}async startProcessing(){try{for(;this.queue.length>0;){let e=[...this.queue];this.queue=[],await this.processBatch(e)}}finally{this.processingPromise=void 0}}};var Ve=class t{static async start(e,r){let o=new t(e,r);return await o.start(),o}statusManager;logger;options;appWatcher;bundlePath;appEventsProcessor;failedEvents=[];currentSessionState=null;constructor(e,r){this.statusManager=e.devSessionStatusManager,this.logger=new Be(r),this.options=e,this.appWatcher=e.appWatcher,this.bundlePath=e.appWatcher.buildOutputPath,this.appEventsProcessor=new Ke(o=>this.processEvents(o))}async start(){await this.logger.info(`Preparing dev preview on ${this.options.storeFqdn}`),this.statusManager.setMessage("LOADING"),this.appWatcher.onEvent(async e=>this.onEvent(e)).onStart(async e=>this.onStart(e)).onError(async e=>this.handleDevSessionResult({status:"unknown-error",error:e}))}async onEvent(e){await this.validateAppEvent(e)&&this.appEventsProcessor.enqueue(e)}async processEvents(e){let r=[...this.failedEvents,...e],o=this.consolidateAppEvents(r);if(this.failedEvents=[],!o)return;this.statusManager.setMessage("CHANGE_DETECTED"),this.updatePreviewURL(o),await this.logger.logExtensionEvents(o);let n=Po(),
|
|
9
|
-
`),c}};function ra(t){let e=new Date(t),r=e.getUTCFullYear(),o=(e.getUTCMonth()+1).toString().padStart(2,"0"),n=e.getUTCDate().toString().padStart(2,"0"),
|
|
7
|
+
`,r.stdout);let o=JSON.stringify(e);t.clients.forEach(n=>n.send(o))}function Ws(t,e){let r=e.payloadStore.getRawPayload();return{...t,version:e.manifestVersion,data:{...t.data,extensions:[],store:r.store,app:r.app}}}var qs=10;function on(t){let e=new Yt.default({noServer:!0,clientTracking:!0}),r=Hs(e);return t.httpServer.on("upgrade",en(e,t)),t.payloadStore.on(me.Update,tn(e,t)),{close:()=>{e.close(),clearInterval(r)}}}function Hs(t){return setInterval(()=>{t.clients.forEach(e=>{e.readyState<2&&e.ping()})},qs*1e3)}u();u();u();function nn(t,e){let{url:r}=qe(t.type,e);if(t.surface==="checkout"&&r){let o=new URL(`https://${e.storeFqdn}/`);return o.pathname=r,o.searchParams.append("dev",`${e.url}/extensions`),o.toString()}else{let o=new URL(`https://${e.storeFqdn}/`);return o.pathname="admin/extensions-dev",o.searchParams.append("url",Ge(t,e)),o.toString()}}function sn(t,e,r){let o=Oe(t),n=new URL(`https://${r.storeFqdn}/`);switch(o){case"checkout":n.pathname=r.checkoutCartUrl,n.searchParams.append("dev",`${r.url}/extensions`);break;case"post_purchase":if(n.pathname=r.checkoutCartUrl,n.searchParams.set("script_url",`${r.url}/extensions/${e.devUUID}/assets/${e.localIdentifier}.js`),n.searchParams.set("post_purchase_dev_api_key",r.apiKey),e.devUUID&&r.websocketURL&&(n.searchParams.set("uuid",e.devUUID),n.searchParams.set("socket_url",r.websocketURL)),"metafields"in e.configuration){let s={config:{metafields:e.configuration.metafields}};n.searchParams.set("config",JSON.stringify(s))}break;case"admin":n.pathname="admin/extensions-dev",n.searchParams.append("url",Ge(e,r)),n.searchParams.append("target",t);break;case"customer-accounts":n=js(e,r,t);break;default:return}return n.toString()}function js(t,e,r=""){let o=`${e.url}/extensions`,n=e.storeId,s="shopify.com",a=new URL(`https://${s}/${n}/account/extensions-development`);return a.searchParams.append("origin",o),a.searchParams.append("extensionId",t.devUUID),a.searchParams.append("source","CUSTOMER_ACCOUNT_EXTENSION"),a.searchParams.append("appId",e.id??""),r!==""&&a.searchParams.append("target",r),a}function Ge(t,e){let r=new URL(e.url);return r.pathname=`/extensions/${t.devUUID}`,r.toString()}function H(t,e){wr(t,gr(e))}u();var yt=class extends te{constructor(e){super(`Couldn't find template ${e.template} for extension surface ${e.extensionSurface}`)}};async function an(t){let e=await Gs(t),r=await C(e);return hr(r,t.data)}async function Gs(t){let e=await Bs(),r=[];t.extensionSurface&&r.push(U(e,`${t.extensionSurface}/${t.template}.html.liquid`)),r.push(U(e,`${t.template}.html.liquid`));let o=await ce(r);if(o.length===0)throw new yt(t);return o[0]}async function Bs(){return await Ft("templates/ui-extensions/html",{type:"directory",cwd:_t(import.meta.url)})}var cn=j(t=>{B(t,"Access-Control-Allow-Origin","*"),B(t,"Access-Control-Allow-Methods","GET, OPTIONS"),B(t,"Access-Control-Allow-Headers","Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, ngrok-skip-browser-warning")}),ln=j(t=>{B(t,"Cache-Control","no-cache")}),vt=j(async t=>$e(t,"/extensions",307));async function Ks(t,e){let{filePath:r}=e;if(!await O(r))return H(t,{statusCode:404,statusMessage:`Not Found: ${r}`});if(await $t(r)&&(r+=r.endsWith("/")?"index.html":"/index.html",!await O(r)))return H(t,{statusCode:404,statusMessage:`Not Found: ${r}`});let o=await C(r,{}),n={".ico":"image/x-icon",".html":"text/html",".js":"text/javascript",".json":"application/json",".map":"application/json",".wasm":"application/wasm",".css":"text/css",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".wav":"audio/wav",".mp3":"audio/mpeg",".svg":"image/svg+xml",".pdf":"application/pdf",".doc":"application/msword"},s=ve(r),a=n[s]||"text/plain";return B(t,"Content-Type",a),o}function pn({getExtensions:t,payloadStore:e}){return j(async r=>{let{extensionId:o,assetPath:n=""}=ke(r),s=t().find(h=>h.devUUID===o);if(!s)return H(r,{statusCode:404,statusMessage:`Extension with id ${o} not found`});let i=e.getAssetResolver(s.devUUID)?.get(n),l=i??n,f=l.endsWith(gt);if(f&&i===void 0)return H(r,{statusCode:404,statusMessage:"Not Found"});let c=Qe(f?s.directory:oo(s.outputPath)),p=Qe(U(c,l));return It(c,p)?Ks(r,{filePath:p}):H(r,{statusCode:404,statusMessage:"Not Found"})})}function Pt({payloadStore:t}){return j(e=>(B(e,"content-type","application/json"),t.getRawPayload()))}function un({devOptions:t}){return j(e=>{y(`UI extensions server received a ${e.method} request to URL ${e.path}`,t.stdout)})}function xt({devOptions:t,getExtensions:e}){return j(async r=>{let{extensionId:o}=ke(r),n=e().find(i=>i.devUUID===o);if(!n)return H(r,{statusCode:404,statusMessage:`Extension with id ${o} not found`});if(yr(r,"accept")?.startsWith("text/html")){if(n.type==="checkout_post_purchase")return an({data:{url:Ge(n,t)},template:"index",extensionSurface:"post_purchase"});{let i=nn(n,t);return $e(r,i,307)}}let a=t.appWatcher.buildOutputPath;return B(r,"content-type","application/json"),{app:{apiKey:t.apiKey},version:t.manifestVersion,root:{url:new URL("/extensions",t.url).toString()},socket:{url:se(t.url)},devConsole:{url:new URL("/extensions/dev-console",t.url).toString()},store:t.storeFqdn,extension:await ne(n,a,t)}})}function dn({devOptions:t,getExtensions:e}){return j(async r=>{let{extensionId:o,extensionPointTarget:n=""}=ke(r),s=e().find(i=>i.devUUID===o);if(!s)return H(r,{statusCode:404,statusMessage:`Extension with id ${o} not found`});if(s.configuration.type!=="checkout_post_purchase"&&!s.hasExtensionPointTarget(n))return H(r,{statusCode:404,statusMessage:`Extension with id ${o} has not configured the "${n}" extension target`});let a=sn(n,s,t);return a?$e(r,a,307):H(r,{statusCode:404,statusMessage:`Redirect url can't be constructed for extension with id ${o} and extension target "${n}"`})})}import{createServer as Vs}from"http";function fn(t){let e=vr(),r=Pr();e.use(un(t)),e.use(cn),e.use(ln),r.use("/extensions/dev-console",vt),r.use("/extensions/:extensionId",xt(t)),r.use("/extensions/:extensionId/",xt(t)),r.use("/extensions/:extensionId/:extensionPointTarget",dn(t)),r.use("/extensions/:extensionId/assets/**:assetPath",pn(t)),r.use("/extensions",Pt(t)),r.use("/extensions/",Pt(t)),r.use("/",vt),e.use(r);let o=Vs(xr(e));return o.listen(t.devOptions.port,"localhost"),o}async function mn(t){let e={...t,websocketURL:se(t.url)},r=e.appWatcher.buildOutputPath,o=new Map,n=await Zo(e,r,o),s=new je(n,e,o),a=e.extensions.filter(p=>p.isPreviewable),i=()=>a;y("Setting up the UI extensions HTTP server...",e.stdout);let l=fn({devOptions:e,payloadStore:s,getExtensions:i});y("Setting up the UI extensions Websocket server...",e.stdout);let f=on({...e,httpServer:l,payloadStore:s});y("Setting up the UI extensions bundler and file watching...",e.stdout);let c=async({appWasReloaded:p,app:h,extensionEvents:g})=>{p&&(a=h.allExtensions.filter(d=>d.isPreviewable));for(let d of g){if(!d.extension.isPreviewable)continue;let m=d.buildResult?.status==="ok"?"success":"error",x=d.buildResult?.status==="error"?{message:d.buildResult.error,file:d.buildResult.file}:void 0;switch(d.type){case oe.Created:if(e.extensions.push(d.extension),!e.checkoutCartUrl){let S=await Me(e.extensions,e.storeFqdn);e.checkoutCartUrl=S}await s.addExtension(d.extension,r);break;case oe.Updated:await s.updateExtension(d.extension,e,r,{status:m,error:x});break;case oe.Deleted:e.extensions=e.extensions.filter(S=>S.devUUID!==d.extension.devUUID),await s.deleteExtension(d.extension);break}}};e.appWatcher.onEvent(c).onStart(c),e.signal.addEventListener("abort",()=>{y("Closing the UI extensions dev server..."),f.close(),l.close()})}function se(t){let e=new URL("/extensions",t);return e.protocol="wss:",e.toString()}var zs="3",Ys=async({stderr:t,stdout:e,abortSignal:r},{apiKey:o,storeFqdn:n,storeId:s,subscriptionProductUrl:a,port:i,cartUrl:l,proxyUrl:f,appName:c,appDotEnvFile:p,appId:h,grantedScopes:g,allExtensions:d,appDirectory:m,appWatcher:x})=>{await mn({appName:c,appDotEnvFile:p,appDirectory:m,id:h,extensions:d,stdout:e,stderr:t,signal:r,url:f,port:i,storeFqdn:be(n),storeId:s,apiKey:o,grantedScopes:g,checkoutCartUrl:l,subscriptionProductUrl:a,manifestVersion:zs,appWatcher:x})};async function hn({allExtensions:t,storeFqdn:e,checkoutCartUrl:r,...o}){let n=t.filter(a=>a.isPreviewable),s=await Me(n,e,r);return{prefix:"extensions",type:"previewable-extension",function:Ys,options:{pathPrefix:"/extensions",port:-1,storeFqdn:e,allExtensions:t,cartUrl:s,...o}}}u();u();function J(t){let e=t.find(o=>re(o,G.Frontend)),r=t.find(o=>re(o,G.Backend));return{frontendConfig:e,backendConfig:r}}u();async function gn(t){let r={topic:"app/uninstalled",api_version:(await _o(t.developerPlatformClient,t.organizationId))[1],address:t.address,delivery_method:ko.LOCALHOST,shared_secret:t.sharedSecret},o=await Lo(t.developerPlatformClient,r,t.organizationId);t.stdout.write("Sending APP_UNINSTALLED webhook to app server"),await ue(3);let n=await Js(t,o);return t.stdout.write(n?"APP_UNINSTALLED webhook delivered":"APP_UNINSTALLED webhook delivery failed"),n}async function Js(t,e){let r=0;for(;r<3;){try{return await Co(t.address,e.samplePayload,JSON.stringify({...JSON.parse(e.headers),"X-Shopify-Shop-Domain":t.storeFqdn}))}catch(o){if(o instanceof qt&&o.code==="ECONNREFUSED")r<3&&(t.stdout.write("App isn't responding yet, retrying in 5 seconds"),await ue(5));else throw o}r++}return t.stdout.write("App hasn't started in time, giving up"),!1}var Qs=async({stdout:t},e)=>{await gn({stdout:t,developerPlatformClient:e.developerPlatformClient,address:`http://localhost:${e.deliveryPort}${e.webhooksPath}`,sharedSecret:e.apiSecret,storeFqdn:e.storeFqdn,organizationId:e.organizationId})};function wn({webs:t,remoteAppUpdated:e,backendPort:r,frontendPort:o,organizationId:n,...s}){let{backendConfig:a,frontendConfig:i}=J(t),l=t.map(({configuration:c})=>c.webhooks_path).find(c=>c)??"/api/webhooks";if(l&&e&&(i??a))return{type:"send-webhook",prefix:"webhooks",function:Qs,options:{deliveryPort:a?r:o,webhooksPath:l,organizationId:n,...s}}}u();async function yn(t){return{type:"graphiql",prefix:"graphiql",options:t,function:Xs}}var Xs=async({stdout:t,abortSignal:e},r)=>{let o=$o({apiKey:r.apiKey,apiSecret:r.apiSecret,storeFqdn:r.storeFqdn}),n=Sr({stdout:t,port:r.port,storeFqdn:r.storeFqdn,key:r.key,tokenProvider:o,appContext:{appName:r.appName,appUrl:r.appUrl,apiSecret:r.apiSecret}});e.addEventListener("abort",()=>{n.close()})};u();async function Pn({webs:t,proxyUrl:e,frontendPort:r,backendPort:o,apiKey:n,apiSecret:s,scopes:a}){let{frontendConfig:i}=J(t),l=i?.configuration.hmr_server?await M():void 0,f=void 0,c=t.map(async p=>{let h=await Zs({web:p,frontendPort:r,backendPort:o}),g=l&&p.configuration.roles.includes(G.Frontend)?{port:l,httpPaths:p.configuration.hmr_server.http_paths}:void 0;return{type:"web",prefix:p.configuration.name??["web",...p.configuration.roles].join("-"),function:ea,options:{port:h,portFromConfig:p.configuration.port,apiKey:n,apiSecret:s,hostname:e,backendPort:o,frontendServerPort:r,directory:p.directory,devCommand:p.configuration.commands.dev,preDevCommand:p.configuration.commands.predev,scopes:a,shopCustomDomain:f,hmrServerOptions:g,roles:p.configuration.roles}}});return Promise.all(c)}async function Zs({web:t,frontendPort:e,backendPort:r}){return re(t,G.Frontend)?e:re(t,G.Backend)?r:M()}async function ea({stdout:t,stderr:e,abortSignal:r},{port:o,apiKey:n,apiSecret:s,hostname:a,backendPort:i,frontendServerPort:l,directory:f,devCommand:c,preDevCommand:p,scopes:h,shopCustomDomain:g,hmrServerOptions:d}){let m=d?.port,x={SHOPIFY_API_KEY:n,SHOPIFY_API_SECRET:s,HOST:a,SCOPES:h,NODE_ENV:"development",...g&&{SHOP_CUSTOM_DOMAIN:g},BACKEND_PORT:`${i}`,FRONTEND_PORT:`${l}`,...m&&{HMR_SERVER_PORT:`${m}`},APP_URL:a,APP_ENV:"development",REMIX_DEV_ORIGIN:a},S={signal:r,directory:f,port:o,env:x,stdout:t,stderr:e};p&&(t.write(`Running pre-dev command: "${p}"`),await vn({...S,command:p,showOutput:lr()})),await vn({...S,command:c,showOutput:!0})}async function vn({command:t,signal:e,directory:r,port:o,env:n,showOutput:s,stdout:a,stderr:i}){let l=t.split("&&").map(f=>f.trim())??[];for(let f of l){let[c,...p]=f.split(" ");c?.length!==0&&await Le(c,p,{cwd:r,stdout:s?a:void 0,stderr:i,signal:e,env:{...n,PORT:`${o}`,SERVER_PORT:`${o}`}})}}u();u();u();var Be=class{stdout;constructor(e){this.stdout=e}async info(e){await this.log(e)}async warning(e){await this.log(T`${R.yellow(e)}`.value)}async success(e){await this.log(T`${R.green(e)}`.value)}async debug(e){y(e,this.stdout)}async error(e,r){let o=R.errorText("\u274C Error"),n=R.errorText(`\u2514 ${e}`);await this.log(T`${o}`.value,r),await this.log(T`${n}`.value,r)}async logUserErrors(e,r){if(typeof e=="string")await this.error(e);else if(e instanceof Error)await this.error(e.message);else{let o=e.map(n=>{let s=n.on?n.on[0]:void 0,a=r.find(i=>i.uid===s?.user_identifier);return{error:n.message,prefix:a?.handle??"app-preview"}});await this.logMultipleErrors(o)}}async logExtensionEvents(e){let r=e.extensionEvents.filter(n=>n.extension.isAppConfigExtension),o=e.extensionEvents.filter(n=>!n.extension.isAppConfigExtension);r.length&&await this.log("App config updated","app-config"),o.forEach(async n=>{let s=n.extension.handle,a=`Extension ${n.type}`;await this.log(a,s)})}async logExtensionUpdateMessages(e,r){if(!e||r.status==="remote-error"||r.status==="unknown-error")return;let o={status:r.status},n=e.extensionEvents??[],a=(await Promise.all(n.map(async l=>l.type===oe.Deleted?[]:(await l.extension.getDevSessionUpdateMessages(o))?.map(c=>({message:c,prefix:l.extension.handle}))??[]))).flat(),i=a.map((l,f)=>{let c=T`${R.gray(f===a.length-1?"\u2514 ":"\u2502 ")}${l.message}`.value;return this.log(c,l.prefix)});await Promise.all(i)}async logMultipleErrors(e){let r=R.errorText("\u274C Error");await this.log(T`${r}`.value,"app-preview");let o=e.map(n=>{let s=R.errorText(`\u2514 ${n.error}`);return this.log(T`${s}`.value,n.prefix)});await Promise.all(o)}async log(e,r){await D({outputPrefix:r??"app-preview",stripAnsi:!1},()=>{this.stdout.write(`${e}
|
|
8
|
+
`)})}};u();var Ke=class{processBatch;queue=[];processingPromise=void 0;constructor(e){this.processBatch=e}enqueue(e){this.queue.push(e),this.processingPromise??=this.startProcessing()}async waitForCompletion(){if(this.processingPromise)return this.processingPromise}async startProcessing(){try{for(;this.queue.length>0;){let e=[...this.queue];this.queue=[],await this.processBatch(e)}}finally{this.processingPromise=void 0}}};var Ve=class t{static async start(e,r){let o=new t(e,r);return await o.start(),o}statusManager;logger;options;appWatcher;bundlePath;appEventsProcessor;failedEvents=[];currentSessionState=null;constructor(e,r){this.statusManager=e.devSessionStatusManager,this.logger=new Be(r),this.options=e,this.appWatcher=e.appWatcher,this.bundlePath=e.appWatcher.buildOutputPath,this.appEventsProcessor=new Ke(o=>this.processEvents(o))}async start(){await this.logger.info(`Preparing dev preview on ${this.options.storeFqdn}`),this.statusManager.setMessage("LOADING"),this.appWatcher.onEvent(async e=>this.onEvent(e)).onStart(async e=>this.onStart(e)).onError(async e=>this.handleDevSessionResult({status:"unknown-error",error:e}))}async onEvent(e){await this.validateAppEvent(e)&&this.appEventsProcessor.enqueue(e)}async processEvents(e){let r=[...this.failedEvents,...e],o=this.consolidateAppEvents(r);if(this.failedEvents=[],!o)return;this.statusManager.setMessage("CHANGE_DETECTED"),this.updatePreviewURL(o),await this.logger.logExtensionEvents(o);let n=Po(),s=await this.bundleExtensionsAndUpload(o);await this.handleDevSessionResult(s,o),await this.logger.debug(`\u2705 Event handled [Network: ${ut(n)}ms - Total: ${ut(o.startTime)}ms]`)}consolidateAppEvents(e){if(e.length===0)return;if(e.length===1)return e[0];let r=e[0],o=e[e.length-1];if(!r||!o)return;let n=new Map;for(let a of e)for(let i of a.extensionEvents)n.set(i.extension.uid,i);return{app:o.app,path:o.path,extensionEvents:Array.from(n.values()),startTime:r.startTime,appWasReloaded:e.some(a=>a.appWasReloaded)}}async onStart(e){let r=this.parseBuildErrors(e);if(r.length)this.statusManager.setMessage("BUILD_ERROR",r.map(({prefix:o,error:n})=>`${o}: ${n}`)),await this.logger.logMultipleErrors(r),await setImmediate(()=>{let o=r.map(n=>n.prefix);throw new I(`Dev preview aborted, build errors detected in extensions: ${o}`)});else{let o=await this.bundleExtensionsAndUpload(e);await this.handleDevSessionResult(o,e)}}async validateAppEvent(e){if(!this.statusManager.status.isReady)return await this.logger.warning("Change detected, but dev preview is not ready yet."),!1;let r=this.parseBuildErrors(e);return r.length?(await this.logger.logMultipleErrors(r),this.statusManager.setMessage("BUILD_ERROR",r.map(({prefix:o,error:n})=>`${o}: ${n}`)),!1):e.extensionEvents.length===0?(this.statusManager.setMessage("READY"),!1):!0}parseBuildErrors(e){return e.extensionEvents.filter(o=>o.buildResult?.status==="error").map(o=>({error:o.buildResult?.status==="error"&&o.buildResult.error||"Build error. Please review your code and try again.",prefix:o.extension.handle}))}async handleDevSessionResult(e,r){if(e.status==="updated")await this.logger.success(`\u2705 Updated dev preview on ${this.options.storeFqdn}`),await this.logger.logExtensionUpdateMessages(r,e),await this.setUpdatedStatusMessage();else if(e.status==="created")this.statusManager.updateStatus({isReady:!0}),await this.logger.success("\u2705 Ready, watching for changes in your app "),await this.logger.logExtensionUpdateMessages(r,e),this.statusManager.setMessage("READY");else if(e.status==="remote-error"||e.status==="unknown-error"){let o=e.error instanceof Error?[e.error.message]:e.error.map(n=>n.message);await this.logger.logUserErrors(e.error,r?.app.allExtensions??[]),e.error instanceof Error&&e.error.cause==="validation-error"?this.statusManager.setMessage("VALIDATION_ERROR",o):(r&&this.failedEvents.push(r),this.statusManager.setMessage("REMOTE_ERROR",o))}!this.statusManager.status.isReady&&!pr()&&setImmediate(()=>{throw new I("Failed to start dev preview.")})}updatePreviewURL(e){let r=e.app.nonConfigExtensions.length>0;this.statusManager.updateStatus({previewURL:this.options.appPreviewURL,appEmbedded:e.app.configuration.embedded,hasExtensions:r})}async setUpdatedStatusMessage(){this.statusManager.setMessage("UPDATED"),setTimeout(async()=>{this.statusManager.status.statusMessage?.message==="Updated"&&this.statusManager.setMessage("READY")},2e3)}async bundleExtensionsAndUpload(e){try{let{manifest:r,inheritedModuleUids:o,assets:n}=await this.createManifest(e),s=await this.uploadAssetsIfNeeded(n,!this.statusManager.status.isReady),a=se(this.options.url);if(this.statusManager.status.isReady){let i={shopFqdn:this.options.storeFqdn,appId:this.options.appId,assetsUrl:s,manifest:r,inheritedModuleUids:o,unsafeValidation:this.options.unsafeValidation??!1};return this.devSessionUpdateWithRetry(i)}else{let i={shopFqdn:this.options.storeFqdn,appId:this.options.appId,assetsUrl:s,websocketUrl:a,unsafeValidation:this.options.unsafeValidation??!1};return this.devSessionCreateWithRetry(i)}}catch(r){if(r.statusCode===401)throw new I("Auth session expired. Please run `shopify app dev` again.");if(r instanceof Wt)throw r.response.status===401||r.response.status===403?new I("Auth session expired. Please run `shopify app dev` again."):(await this.logger.debug(JSON.stringify(r.response,null,2)),new I("Unknown error"));return r.code==="ETIMEDOUT"?{status:"unknown-error",error:new Error("Request timed out, please check your internet connection and try again.")}:{status:"unknown-error",error:r}}}async createManifest(e){let r=e.extensionEvents.filter(i=>i.type!=="deleted").map(i=>i.extension.uid);e.app.allExtensions.some(i=>i.type==="admin")&&!r.includes("admin")&&r.push("admin");let o=e.app.allExtensions.filter(i=>!r.includes(i.uid)).map(i=>i.uid),n=await e.app.manifest(void 0);await Eo(n,this.bundlePath),this.statusManager.status.isReady&&(n.modules=n.modules.filter(i=>r.includes(i.uid)));let s=await Dt(this.bundlePath),a=n.modules.map(i=>i.assets).filter(i=>s.includes(i));return{manifest:n,inheritedModuleUids:o,assets:a}}async uploadAssetsIfNeeded(e,r){if(!e.length&&!r)return;let o=U(we(this.bundlePath),`dev-bundle.${this.options.developerPlatformClient.bundleFormat}`),n=[...e.map(a=>`${a}/**`),...So];r&&n.push("manifest.json"),await bo(this.bundlePath,o,n);let s=await this.getSignedURLWithRetry();return await Uo(s,o),s}async getSignedURLWithRetry(){return Ro(this.options.developerPlatformClient,{apiKey:this.options.appId,organizationId:this.options.organizationId,id:this.options.appId})}async devSessionUpdateWithRetry(e){let r=await this.options.developerPlatformClient.devSessionUpdate(e),o=r.devSessionUpdate?.userErrors??[],n=r.devSessionUpdate?.warnings??[],s=r.devSessionUpdate?.devSession;if(s&&this.currentSessionState){let a=se(this.options.url),i=this.currentSessionState?.userId;if(s.websocketUrl!==a||s.user?.id!==i){let l=s.user?.email;await this.logger.error(`Another developer ${l?`(${l}) `:""}has taken ownership of this dev preview.`);let f=`Another user${l?` (${l})`:""} has taken ownership of this dev preview. Your preview is no longer active.`,c=["You can restart by running",{command:"shopify app dev"},"again."];throw new I(f,c)}this.currentSessionState={websocketUrl:s.websocketUrl,userId:s.user?.id??null,userEmail:s.user?.email??null}}return n.length>0&&await this.logWarnings(n),o.length?{status:"remote-error",error:o}:{status:"updated"}}async devSessionCreateWithRetry(e){let r=await this.options.developerPlatformClient.devSessionCreate(e),o=r.devSessionCreate?.userErrors??[],n=r.devSessionCreate?.warnings??[],s=r.devSessionCreate?.devSession;return s&&(this.currentSessionState={websocketUrl:s.websocketUrl,userId:s.user?.id??null,userEmail:s.user?.email??null}),n.length>0&&await this.logWarnings(n),o.length?{status:"remote-error",error:o}:{status:"created"}}async logWarnings(e){await Promise.all(e.map(r=>{let o=r.code==="SESSION_TAKEOVER"?`\u26A0\uFE0F ${r.message}`:r.message;return this.logger.warning(o)}))}};async function xn({app:t,apiKey:e,developerPlatformClient:r,...o}){return{type:"dev-session",prefix:"app-preview",function:ta,options:{app:t,apiKey:e,developerPlatformClient:r,...o}}}var ta=async({stdout:t},e)=>{await Ve.start(e,t)};u();u();u();var En=async({appLog:t,appLogPayload:e,stdout:r,storeName:o,logsDir:n})=>{let s=Ee().substring(0,6),i=`${ra(t.log_timestamp)}_${t.source_namespace}_${t.source}_${s}.json`,l=zo({appLog:t,appLogPayload:e,prettyPrint:!0,storeName:o}),f=U(n,i);try{return await Z(n),await Pe(f,l),{fullOutputPath:f,identifier:s}}catch(c){throw r.write(`Error while writing log to file: ${c}
|
|
9
|
+
`),c}};function ra(t){let e=new Date(t),r=e.getUTCFullYear(),o=(e.getUTCMonth()+1).toString().padStart(2,"0"),n=e.getUTCDate().toString().padStart(2,"0"),s=e.getUTCHours().toString().padStart(2,"0"),a=e.getUTCMinutes().toString().padStart(2,"0"),i=e.getUTCSeconds().toString().padStart(2,"0"),l=e.getUTCMilliseconds().toString().padStart(3,"0");return`${r}${o}${n}_${s}${a}${i}_${l}Z`}var ze=async({stdout:t,appLogsFetchInput:{jwtToken:e,cursor:r},developerPlatformClient:o,resubscribeCallback:n,storeName:s,organizationId:a,abortSignal:i,logsDir:l,consecutiveResubscribeFailures:f=0})=>{if(!i?.aborted)try{let c=e,p=Mo,h=f,g=await o.appLogs({jwtToken:e,cursor:r},a),{errors:d,status:m}=g;if(m===200){h=0;let{app_logs:S}=g;for(let v of S){let w=JSON.parse(v.payload);await D({outputPrefix:v.source,stripAnsi:!1},async()=>{v.log_type===Wo?(oa(v,w,t),w=new Fo(Do(w))):v.log_type.startsWith(qo)?na(v,w,t):t.write(JSON.stringify(w));let E=await En({appLog:v,appLogPayload:w,stdout:t,storeName:s,logsDir:l});t.write(T`${R.gray("\u2514 ")}${R.link("Open log file",`file://${E.fullOutputPath}`,`Log: ${E.fullOutputPath}`)} ${R.gray(`(${E.identifier})`)}\n`.value)})}}else{let S={errors:d.map(w=>({message:w,status:m}))},v=await Vo({response:S,onThrottle:w=>{k("Request throttled while polling app logs.",t),k(`Retrying in ${w/1e3} seconds.`,t)},onUnknownError:w=>{k("Error while polling app logs.",t),k(`Retrying in ${w/1e3} seconds.`,t)},onResubscribe:()=>n()});if(v.resubscribeResult==="failed"){if(h+=1,h>=Oo){k("App log streaming session has expired. Please restart your dev session.",t);return}}else v.resubscribeResult==="succeeded"&&(h=0);v.nextJwtToken&&(c=v.nextJwtToken),p=v.retryIntervalMs}let{cursor:x}=g;setTimeout(()=>{ze({stdout:t,appLogsFetchInput:{jwtToken:c,cursor:x??r},developerPlatformClient:o,resubscribeCallback:n,storeName:s,organizationId:a,abortSignal:i,logsDir:l,consecutiveResubscribeFailures:h}).catch(S=>{y(`Unexpected error during polling: ${S}}
|
|
10
10
|
`)})},p)}catch(c){k("Error while polling app logs.",t),k(`Retrying in ${ft/1e3} seconds.`,t),y(`${c}}
|
|
11
|
-
`),setTimeout(()=>{ze({stdout:t,appLogsFetchInput:{jwtToken:e,cursor:void 0},developerPlatformClient:o,resubscribeCallback:n,storeName:
|
|
11
|
+
`),setTimeout(()=>{ze({stdout:t,appLogsFetchInput:{jwtToken:e,cursor:void 0},developerPlatformClient:o,resubscribeCallback:n,storeName:s,organizationId:a,abortSignal:i,logsDir:l}).catch(p=>{y(`Unexpected error during polling: ${p}}
|
|
12
12
|
`)})},ft)}};function oa(t,e,r){let o=(e.fuel_consumed/No).toFixed(4);t.status==="success"?r.write(`Function export "${e.export}" executed successfully using ${o}M instructions.`):t.status==="failure"&&r.write(`\u274C Function export "${e.export}" failed to execute with error: ${e.error_type}`);let n=e.logs;n.length>0&&r.write(n.split(`
|
|
13
|
-
`).filter(Boolean).map(
|
|
14
|
-
`))}function na(t,e,r){t.log_type===Ho?r.write("Function network access response retrieved from cache."):t.log_type===jo?e.reason===Bo?r.write("Function network access request executing in background because there is no cached response."):e.reason===Ko&&r.write("Function network access request executing in background because the cached response is about to expire."):t.log_type===Go&&(t.status==="success"?r.write("Function network access request executed successfully."):t.status==="failure"&&r.write(`\u274C Function network access request failed to execute with error: ${e.error}.`))}function sa(t){return t.allExtensions.some(e=>e.isFunctionExtension)}async function Sn({developerPlatformClient:t,subscription:{shopIds:e,apiKey:r},storeName:o,organizationId:n,appWatcher:
|
|
13
|
+
`).filter(Boolean).map(s=>T`${R.gray("\u2502 ")}${s}`.value).join(`
|
|
14
|
+
`))}function na(t,e,r){t.log_type===Ho?r.write("Function network access response retrieved from cache."):t.log_type===jo?e.reason===Bo?r.write("Function network access request executing in background because there is no cached response."):e.reason===Ko&&r.write("Function network access request executing in background because the cached response is about to expire."):t.log_type===Go&&(t.status==="success"?r.write("Function network access request executed successfully."):t.status==="failure"&&r.write(`\u274C Function network access request failed to execute with error: ${e.error}.`))}function sa(t){return t.allExtensions.some(e=>e.isFunctionExtension)}async function Sn({developerPlatformClient:t,subscription:{shopIds:e,apiKey:r},storeName:o,organizationId:n,appWatcher:s,localApp:a}){return{type:"app-logs-subscribe",prefix:"app-logs",function:aa,options:{developerPlatformClient:t,appLogsSubscribeVariables:{shopIds:e,apiKey:r},storeName:o,organizationId:n,appWatcher:s,localApp:a}}}var aa=async({stdout:t,stderr:e,abortSignal:r},{developerPlatformClient:o,appLogsSubscribeVariables:n,storeName:s,organizationId:a,appWatcher:i,localApp:l})=>{async function f(c){let p=await mt(o,n,a,t),h=l.getLogsDir();await Z(h),await ze({stdout:t,appLogsFetchInput:{jwtToken:p},resubscribeCallback:()=>mt(o,n,a),developerPlatformClient:o,storeName:s,organizationId:a,abortSignal:c,logsDir:h})}try{let c=!1,p,h=async g=>{let d=sa(g.app);if(d&&!c){y("Function extensions detected, starting logs polling"),c=!0,p=new AbortController;try{await f(p.signal)}catch(m){y(`Failed to start function logs: ${m}`,e)}}else!d&&c&&(y("No function extensions detected, stopping logs polling"),c=!1,p?.abort(),p=void 0)};i.onStart(h).onEvent(h)}catch{}};u();async function bn(t){return{type:"app-watcher",prefix:"app-preview",options:t,function:ia}}var ia=async({stdout:t,stderr:e,abortSignal:r},o)=>{let{appWatcher:n}=o;await n.start({stdout:t,stderr:e,signal:r})};u();import{EventEmitter as ca}from"events";var la={BUILD_ERROR:{message:"Build error. Please review your code and try again",type:"error"},READY:{message:"Ready, watching for changes in your app",type:"success"},LOADING:{message:"Preparing dev preview",type:"loading"},UPDATED:{message:"Updated",type:"success"},VALIDATION_ERROR:{message:"Validation error in your app configuration",type:"error"},REMOTE_ERROR:{message:"Error updating dev preview",type:"error"},CHANGE_DETECTED:{message:"Change detected, updating dev preview",type:"loading"}},Ye=class extends ca{currentStatus={isReady:!1,previewURL:void 0,graphiqlURL:void 0,statusMessage:void 0};constructor(e){super(),e&&(this.currentStatus=e)}updateStatus(e){let r={...this.currentStatus,...e};Kt(this.currentStatus,r)||(this.currentStatus=r,this.emit("dev-session-update",r))}setMessage(e,r){let o=la[e],n=o.type==="success"?[]:r;this.updateStatus({statusMessage:o,...n?{errors:n}:{}})}get status(){return this.currentStatus}reset(){this.currentStatus={isReady:!1,previewURL:void 0,graphiqlURL:void 0,statusMessage:void 0}}};u();import*as Un from"http";import*as Rn from"https";function An(t){return"errors"in t&&Array.isArray(t.errors)}async function Tn(t,e,r,o){let s=(await import("./http-proxy-node16-D3JUYA5D.js")).default.createProxyServer(),a=ua(t,s,o),i=r?Rn.createServer(r,a):Un.createServer(a);return i.on("upgrade",pa(t,s,o)),e.addEventListener("abort",()=>{y("Closing reverse HTTP proxy"),i.close()}),{server:i}}function pa(t,e,r){return function(o,n,s){let a=In(t,o,!0);if(a)return e.ws(o,n,s,{target:a},i=>{D({outputPrefix:"proxy",stripAnsi:!1},()=>{let f=(An(i)?i.errors[i.errors.length-1]:void 0)??i;k(`Error forwarding websocket request: ${f.message}`,r),k(`\u2514 Unreachable target "${a}" for path: "${o.url}"`,r)})});n.destroy()}}function ua(t,e,r){return function(o,n){let s=In(t,o);if(s)return o.method==="OPTIONS"?(n.writeHead(204,{"Access-Control-Allow-Origin":o.headers.origin??"*","Access-Control-Allow-Methods":o.headers["access-control-request-method"]??"GET, POST, PUT, DELETE, PATCH, OPTIONS","Access-Control-Allow-Headers":o.headers["access-control-request-headers"]??"Content-Type, Authorization","Access-Control-Max-Age":"86400"}),n.end()):e.web(o,n,{target:s},a=>{D({outputPrefix:"proxy",stripAnsi:!1},()=>{let l=(An(a)?a.errors[a.errors.length-1]:void 0)??a;k(`Error forwarding web request: ${l.message}`,r),k(`\u2514 Unreachable target "${s}" for path: "${o.url}"`,r)})});y(T`
|
|
15
15
|
Reverse HTTP proxy error - Invalid path: ${o.url??""}
|
|
16
16
|
These are the allowed paths:
|
|
17
17
|
${R.json(JSON.stringify(t))}
|
|
18
|
-
`),n.statusCode=500,n.end(`Invalid path ${o.url}`)}}function
|
|
18
|
+
`),n.statusCode=500,n.end(`Invalid path ${o.url}`)}}function In(t,e,r=!1){let o=e.url??"/";for(let n in t)if(o.startsWith(n))return t[n];return r&&t.websocket?t.websocket:t.default}async function _n({localApp:t,remoteAppUpdated:e,developerPlatformClient:r,remoteApp:o,storeFqdn:n,storeId:s,commandOptions:a,network:i,graphiqlPort:l,graphiqlKey:f}){let c=o.apiKey,p=o.apiSecretKeys[0]?.secret??"",h=Mt(),g=!At(h[De.disableGraphiQLExplorer]),d=await uo(t),m=new xo(d,i.proxyUrl),x=await Se(),S=To(n,c,x),v=S,w=Er(f,p,n),E=g?`http://localhost:${l}/graphiql?key=${encodeURIComponent(w)}`:void 0,L=d.configuration.embedded,W=d.nonConfigExtensions.length>0,q=new Ye({isReady:!1,previewURL:v,graphiqlURL:E,appEmbedded:L,hasExtensions:W}),b=[...await Pn({webs:d.webs,proxyUrl:i.proxyUrl,frontendPort:i.frontendPort,backendPort:i.backendPort,apiKey:c,apiSecret:p,scopes:eo(d.configuration)}),g?await yn({appName:o.title,appUrl:S,port:l,apiKey:c,apiSecret:p,key:w,storeFqdn:n}):void 0,await hn({allExtensions:d.realExtensions,storeFqdn:n,storeId:s,apiKey:c,subscriptionProductUrl:a.subscriptionProductUrl,checkoutCartUrl:a.checkoutCartUrl,proxyUrl:i.proxyUrl,appName:d.name,appDotEnvFile:d.dotenv,grantedScopes:o.grantedScopes,appId:o.id,appDirectory:d.directory,appWatcher:m}),await xn({app:d,apiKey:c,developerPlatformClient:r,url:i.proxyUrl,appId:o.id,organizationId:o.organizationId,storeFqdn:n,appWatcher:m,appPreviewURL:S,devSessionStatusManager:q,unsafeValidation:a.unsafeValidation}),await Jo({remoteApp:o,localApp:d,storeFqdn:n,theme:a.theme,themeExtensionPort:a.themeExtensionPort,storePassword:a.storePassword}),wn({webs:d.webs,backendPort:i.backendPort,frontendPort:i.frontendPort,organizationId:o.organizationId,developerPlatformClient:r,storeFqdn:n,apiSecret:p,remoteAppUpdated:e}),await Sn({developerPlatformClient:r,subscription:{shopIds:[Number(s)],apiKey:c},storeName:n,organizationId:o.organizationId,localApp:t,appWatcher:m}),await bn({appWatcher:m})].filter(da);return{processes:await fa(b,i.proxyPort,i.reverseProxyCert),previewUrl:v,graphiqlUrl:E,devSessionStatusManager:q}}var da=t=>t!==void 0&&t!==!1;async function fa(t,e,r){let o=await Promise.all(t.map(async a=>{let i={};if(a.type==="web"&&a.options.roles.includes(G.Frontend)){let l=a.options.portFromConfig??a.options.port;i.default=`http://localhost:${l}`;let f=a.options.hmrServerOptions;f&&(i.websocket=`http://localhost:${f.port}`,f.httpPaths.forEach(c=>i[c]=`http://localhost:${f.port}`)),a.options.port=l}else if(a.type==="previewable-extension"){let l=await M();i[a.options.pathPrefix]=`http://localhost:${l}`,a.options.port=l}return{process:a,rules:i}})),n=o.map(({process:a})=>a),s=o.map(({rules:a})=>a).reduce((a,i)=>({...a,...i}),{});return Object.keys(s).length>0&&n.push({type:"proxy-server",prefix:"proxy",function:ma,options:{port:e,rules:s,localhostCert:r}}),n}var ma=async({abortSignal:t,stdout:e},{port:r,rules:o,localhostCert:n})=>{let{server:s}=await Tn(o,t,n,e);V(`Proxy server started on port ${r} ${n?`with certificate ${n.certPath}`:""}`,e),await s.listen(r,"localhost")};u();u();u();var _=X(tt(),1);var Ln=.9,Cn=({tabs:t,initialActiveTab:e})=>{let{stdout:r}=Jt(),{isRawModeSupported:o}=Re(),[n,s]=(0,_.useState)(e),[a,i]=(0,_.useState)(Math.floor(r.columns*Ln)),[l,f]=(0,_.useState)(!0),c=(0,_.useRef)(null);if(!n)throw new Error("No tabs provided");Ae((d,m)=>{(async()=>{if(m?.leftArrow||m?.rightArrow||m?.tab){let w=Object.entries(t).filter(([b,K])=>K.content),E=w.findIndex(([b])=>b===n);if(E===-1)return;let L=m?.leftArrow?-1:1,W=(E+L+w.length)%w.length,q=w[W];q&&s(q[0])}let S=t[d];if(S){S.action?await S.action():s(d);return}let v=t[n];if(v?.shortcuts){let w=v.shortcuts.find(E=>E.key===d);w&&(!w.condition||w.condition())&&await w.action()}})()},{isActive:!!o}),(0,_.useLayoutEffect)(()=>{let d=()=>{if(i(Math.floor(r.columns*Ln)),!c.current)return;let m=Qt(c.current);f(m.width<r.columns)};return r.on("resize",d),()=>{r.off("resize",d)}},[r]);let p=Object.entries(t).map(([d,m])=>({...m,inputKey:d,header:` (${d}) ${m.label} `})),h=p.filter(d=>!d.action),g=p.filter(d=>d.action);return _.default.createElement(_.default.Fragment,null,_.default.createElement(F,{paddingTop:0,width:a,flexDirection:"row",flexGrow:1,borderStyle:"single",borderBottom:!1,borderLeft:!1,borderRight:!1,borderTop:!0},_.default.createElement(F,{ref:c,flexDirection:"row",flexWrap:"nowrap",flexShrink:0,marginRight:3},_.default.createElement(N,{wrap:"truncate-end"},"\u2502",h.map(d=>_.default.createElement(_.default.Fragment,{key:d.inputKey},_.default.createElement(N,{bold:n===d.inputKey,inverse:n===d.inputKey,wrap:"truncate"},d.header),"\u2502")))),l&&_.default.createElement(F,{flexGrow:1,justifyContent:"flex-end"},g.map((d,m)=>_.default.createElement(N,{wrap:"truncate",key:d.inputKey},"(",d.inputKey,") ",d.label,m<g.length-1&&" \u2502 ")))),_.default.createElement(F,{flexDirection:"column",marginLeft:1,marginRight:1,marginTop:1},t[n]?.content))};var P=X(tt(),1);var ha=({message:t,type:e})=>e==="loading"?P.default.createElement(nr,{title:t}):P.default.createElement(N,null,e==="success"?"\u2705":"\u274C"," ",t),kn=({abortController:t,processes:e,devSessionStatusManager:r,shopFqdn:o,appURL:n,appName:s,organizationName:a,configPath:i,localURL:l,onAbort:f})=>{let{isRawModeSupported:c}=Re(),[p,h]=(0,P.useState)(void 0),[g,d]=(0,P.useState)(void 0),[m,x]=(0,P.useState)(r.status),[S,v]=(0,P.useState)(!1),{isAborted:w}=or(t.signal,async b=>{b&&d(typeof b=="string"?b:b.message),r.status.isReady?v(!0):(h("Shutting down dev ..."),await f()),Ne()}),E=(0,P.useMemo)(()=>e.map(b=>({...b,action:async(K,ns,ss)=>{try{return await b.action(K,ns,ss)}catch(as){t.abort(as)}}})),[e,t]);(0,P.useEffect)(()=>(r.on("dev-session-update",x),()=>{r.off("dev-session-update",x)}),[]),Ae((b,K)=>{Zt(b,K,()=>t.abort())},{isActive:!!c});let L=[{key:"p",shortcutLabel:"Open app preview",linkLabel:"Preview",url:m.previewURL,condition:()=>!!(m.isReady&&m.previewURL),action:async()=>{await z.addPublicMetadata(()=>({cmd_dev_preview_url_opened:!0})),m.previewURL&&await _e(m.previewURL)}},{key:"c",shortcutLabel:"Open Dev Console for extension previews",linkLabel:"Dev Console",url:dt(o),condition:()=>!!(m.isReady&&m.appEmbedded===!1&&m.hasExtensions),action:async()=>{await z.addPublicMetadata(()=>({cmd_dev_preview_url_opened:!0})),await _e(dt(o))}},{key:"g",shortcutLabel:"Open GraphiQL (Admin API)",linkLabel:"GraphiQL",url:m.graphiqlURL,condition:()=>!!(m.isReady&&m.graphiqlURL),action:async()=>{await z.addPublicMetadata(()=>({cmd_dev_graphiql_opened:!0})),m.graphiqlURL&&await _e(m.graphiqlURL)}}],W=L.filter(b=>b.condition?.()??!0),q={d:{label:"Dev status",shortcuts:L,content:P.default.createElement(P.default.Fragment,null,m.statusMessage&&P.default.createElement(ha,{message:m.statusMessage.message,type:m.statusMessage.type}),c&&W.length>0&&P.default.createElement(F,{marginTop:1,flexDirection:"column"},W.map(b=>P.default.createElement(N,{key:b.key},er.pointerSmall," ",P.default.createElement(N,{bold:!0},"(",b.key,")")," ",nt()&&b.url?P.default.createElement(rt,{url:b.url,label:b.shortcutLabel}):b.shortcutLabel))),P.default.createElement(F,{marginTop:c?1:0,flexDirection:"column"},p?P.default.createElement(N,null,p):P.default.createElement(P.default.Fragment,null,m.isReady&&!(c&&nt())&&P.default.createElement(P.default.Fragment,null,W.filter(b=>b.url).map(b=>P.default.createElement(N,{key:b.key},b.linkLabel," URL: ",P.default.createElement(rt,{url:b.url})))))))},a:{label:"App info",content:P.default.createElement(F,{flexDirection:"column"},P.default.createElement(ot,{tabularData:[["App:",s??""],["App URL:",n??""],["Local URL:",n?"":l??""],["Config:",i?.split("/").pop()??""],["Org:",a??""]].filter(([,b])=>b)}))},s:{label:"Store info",content:P.default.createElement(F,{flexDirection:"column"},P.default.createElement(ot,{tabularData:[["Dev store:",{link:{url:`https://${o}`}}],["Dev store admin:",{link:{url:`https://${o}/admin`}}],["Org:",a??""]].filter(([,b])=>b)}))},q:{label:"Quit",action:async()=>{t.abort()}}};return P.default.createElement(P.default.Fragment,null,P.default.createElement(tr,{processes:E,prefixColumnSize:ro,abortSignal:t.signal,keepRunningAfterProcessesResolve:!0,useAlternativeColorPalette:!0}),S&&P.default.createElement(F,{marginTop:1,flexDirection:"column"},P.default.createElement(rr,{type:"info",headline:`A preview of your development changes is still available on ${o}.`,body:["Run",{command:"shopify app dev clean"},"to restore the latest released version of your app."],link:{label:"Learn more about dev previews",url:"https://shopify.dev/beta/developer-dashboard/shopify-app-dev"}})),w?null:P.default.createElement(F,{paddingTop:1,flexDirection:"column",flexGrow:1},c?P.default.createElement(Cn,{tabs:q,initialActiveTab:"d"}):P.default.createElement(F,{marginY:1,paddingTop:0,flexDirection:"column",flexGrow:1,borderStyle:"single",borderBottom:!1,borderLeft:!1,borderRight:!1,borderTop:!0},q.d?.content)),g?P.default.createElement(F,{marginTop:1,flexDirection:"column"},P.default.createElement(N,{color:"red"},g)):null)};var Fn=X(tt(),1);import{Writable as Dn}from"stream";async function Mn({processes:t,previewUrl:e,app:r,abortController:o,graphiqlUrl:n,shopFqdn:s,devSessionStatusManager:a,appURL:i,appName:l,organizationName:f,configPath:c,localURL:p}){let h=()=>o.abort();process.on("shopify:signal",h);try{if(et()!=="json"&&ir())return await Xt(Fn.default.createElement(kn,{processes:t,abortController:o,devSessionStatusManager:a,shopFqdn:s,appURL:i,appName:l,organizationName:f,configPath:c,localURL:p,onAbort:async()=>{await r.developerPlatformClient.devSessionDelete({appId:r.id,shopFqdn:s})}}),{exitOnCtrlC:!1});await ga({processes:t,previewUrl:e,graphiqlUrl:n,abortController:o}),Ne()}finally{process.removeListener("shopify:signal",h)}}async function ga({processes:t,previewUrl:e,graphiqlUrl:r,abortController:o}){let n=et()==="json";n||(process.stdout.write(`
|
|
19
19
|
Preview URL: ${e}
|
|
20
20
|
`),r&&process.stdout.write(`GraphiQL URL (Admin API): ${r}
|
|
21
|
-
`));let{signal:
|
|
22
|
-
`)]):n,o)}})}u();function On(t){if(!t.length)return;let e=t.filter(n=>n.requested!==n.actual);if(e.length===0)return;if(e.length===1&&e[0]){let n=e[0];pe({headline:[`A random port will be used for ${n.for} because ${n?.requested} is not available.`],body:["If you want to use a specific port, you can choose a different one by setting the ",{command:n?.flagToRemedy}," flag."]});return}let r=Xe(e.map(n=>n.for)).join(" "),o=Xe(e.map(n=>({command:n.flagToRemedy})));pe({headline:[`Random ports will be used for ${r} because the requested ports are not available.`],body:["If you want to use specific ports, you can choose different ports using the",...o,"flags."]})}u();async function Nn(t,e){return e?e.includes("localhost")?"localhost":(await jt(t)).plugins.find(o=>e?.includes(o))??"custom":void 0}u();var Wn=X(cs(),1);var Q="v1.4.4",qn="FiloSottile/mkcert",Et=R.genericShellCommand("mkcert");async function wa(t,e,r,o){let n=e[De.mkcertBinaryPath];if(n)return n;let
|
|
23
|
-
`;try{await Je(n,c),e&&await Je(e,c)}catch(p){throw o(p),p}};return{opened:
|
|
21
|
+
`));let{signal:s}=o,a=()=>o.abort();process.once("SIGINT",a),process.once("SIGTERM",a);let i=()=>{},l=new Promise(c=>{i=c,s.addEventListener("abort",i,{once:!0}),s.aborted&&c()}),f=t.map(async c=>{let p=new Dn({write:(h,g,d)=>d()});return c.action(n?p:$n(process.stdout),n?p:$n(process.stderr),s)});try{await Promise.all([...f,l])}catch(c){if(!s.aborted)throw c}finally{o.abort(),await Promise.allSettled(f),s.removeEventListener("abort",i),process.removeListener("SIGINT",a),process.removeListener("SIGTERM",a)}}function $n(t){return new Dn({decodeStrings:!1,write(e,r,o){let n=typeof e=="string"?Buffer.from(e,r):e,s=typeof e=="string"&&n.length>0&&n[n.length-1]!==10;t.write(s?Buffer.concat([n,Buffer.from(`
|
|
22
|
+
`)]):n,o)}})}u();function On(t){if(!t.length)return;let e=t.filter(n=>n.requested!==n.actual);if(e.length===0)return;if(e.length===1&&e[0]){let n=e[0];pe({headline:[`A random port will be used for ${n.for} because ${n?.requested} is not available.`],body:["If you want to use a specific port, you can choose a different one by setting the ",{command:n?.flagToRemedy}," flag."]});return}let r=Xe(e.map(n=>n.for)).join(" "),o=Xe(e.map(n=>({command:n.flagToRemedy})));pe({headline:[`Random ports will be used for ${r} because the requested ports are not available.`],body:["If you want to use specific ports, you can choose different ports using the",...o,"flags."]})}u();async function Nn(t,e){return e?e.includes("localhost")?"localhost":(await jt(t)).plugins.find(o=>e?.includes(o))??"custom":void 0}u();var Wn=X(cs(),1);var Q="v1.4.4",qn="FiloSottile/mkcert",Et=R.genericShellCommand("mkcert");async function wa(t,e,r,o){let n=e[De.mkcertBinaryPath];if(n)return n;let a=U(t,r==="win32"?"mkcert.exe":"mkcert");if(await O(a))return a;let i=await(0,Wn.default)("mkcert",{nothrow:!0});return i?(y(T`Found ${Et} at ${R.path(i)}`),i):(await ya(a,r,o),a)}async function ya(t,e,r){let o;switch(e){case"darwin":o=r==="arm64"?`mkcert-${Q}-darwin-arm64`:`mkcert-${Q}-darwin-amd64`;break;case"linux":o=r==="arm64"?`mkcert-${Q}-linux-arm64`:`mkcert-${Q}-linux-amd64`;break;case"win32":o=`mkcert-${Q}-windows-amd64.exe`;break;default:throw new te(`Unsupported platform: ${e}`)}await Fr(qn,Q,o,t),y(T`${Et} saved to ${R.path(t)}`)}async function va(t){let e=U(t,"mkcert-LICENSE");if(await O(e))return;let r=`https://raw.githubusercontent.com/${qn}/refs/tags/${Q}/LICENSE`,o={headline:"Failed to download mkcert license.",body:["We tried to download the license for mkcert, but the request failed. You can ",{link:{url:r,label:"view the license here"}}]},n;try{if(n=await Ht(r),!n.ok)return o}catch{return o}let s=await n.text();await Pe(e,s)}async function Hn({appDirectory:t,forceInstall:e,env:r=process.env,platform:o=process.platform,arch:n=process.arch}){let s=U(".shopify","localhost-key.pem"),a=U(".shopify","localhost.pem"),i=U(t,s),l=U(t,a);if(await O(i)&&await O(l))return{keyContent:await C(i),certContent:await C(l),certPath:a};if(!(e??await fo()))throw new I(`Localhost certificate and key are required at ${a} and ${s}`);let c="",p;return await Ie([{title:"Finding or downloading mkcert binary",task:async()=>{let g=U(t,".shopify");c=await wa(g,r,o,n),p=await va(g),y(T`${Et} found at: ${R.path(c)}`)}}]),p&&Te(p),V(T`Generating self-signed certificate for localhost. You may be prompted for your password.`),await Le(c,["-install","-key-file",i,"-cert-file",l,"localhost"]),V(T`${R.successIcon()} Certificate generated at ${a}\n`),await cr()&&(pe({headline:"It looks like you're using WSL.",body:["Additional steps are required to configure certificate trust in Windows."],link:{label:"See Shopify CLI documentation",url:"https://shopify.dev/docs/apps/build/cli-for-apps/networking-options#localhost-based-development-with-windows-subsystem-for-linux-wsl"}}),V("\u{1F449} Press any key to continue"),await sr(),V("")),{keyContent:await C(i),certContent:await C(l),certPath:Tt(t,l)}}u();function jn(){let t=["Your app has extensions which need to be assigned",{command:"uid"},"identifiers."],e=["You must first map IDs to your existing extensions by running",{command:"shopify app deploy"},"interactively, without",{command:"--allow-updates"},"or",{command:"--allow-deletes"},", to finish the migration."],r={title:"Reference",body:{list:{items:[{link:{label:"Migrating from the Partner Dashboard",url:"https://shopify.dev/docs/apps/build/dev-dashboard/migrate-from-partners"}}]}}};throw new I(t,void 0,[e],[r])}u();u();import{createWriteStream as Pa}from"fs";import{Writable as xa}from"stream";import{finished as Ea}from"stream/promises";import{StringDecoder as Sa}from"string_decoder";import{once as ba}from"events";var he=ge({name:"DevInstanceLogEntry",schema:A.object({timestamp:ae,source:A.string().describe("What produced the line, for example a process prefix like web or extensions."),level:A.enum(["debug","info","warning","error"]).optional(),message:A.string()}).strict()});function Bn({logFile:t,logOutput:e,isActive:r,onError:o}){let n=Pa(t,{flags:"w",mode:384});n.on("error",o),e?.on("error",o);let s=ba(n,"open"),a=new Set,i=async l=>{if(!r())return;let f=he.validate({...l,timestamp:l.timestamp??ie(new Date)}),c=`${JSON.stringify(f)}
|
|
23
|
+
`;try{await Je(n,c),e&&await Je(e,c)}catch(p){throw o(p),p}};return{opened:s,log:i,tee:(l,{source:f,stringWritesAreMessages:c=!1})=>{let p=new Sa("utf8"),h="",g=f,d=async v=>{let w=v.split(/\r?\n/);h=w.pop()??"",await Promise.all(w.map(async E=>{let L=ur(E).trimEnd();L.length>0&&await i({source:g,message:L})}))},m=()=>d(`${h}${p.end()}
|
|
24
24
|
`),x=new St({decodeStrings:!c,write(v,w,E){let L=Ue()?.outputPrefix??f,W=c&&typeof v=="string",q=L!==g||W?m():Promise.resolve();g=L,Promise.all([q,Je(l,v,w),d(h+p.write(typeof v=="string"?Buffer.from(v,w):v)+(W?`
|
|
25
|
-
`:""))]).then(()=>E()).catch(E)},final(v){m().then(()=>v()).catch(v)}}),S=v=>x.destroy(v);return l.on("error",S),x.on("error",v=>o(v)),x.once("close",()=>{l.off("error",S)}),
|
|
26
|
-
`,{mode:384}),await Lt(r,t)}function $a(t){return t?.code==="ELOCKED"}function Fa({command:t,key:e}){let r=[t,e].filter(Boolean).join("-").toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^-+|-+$/g,""),o=le(JSON.stringify([t,e??""])).slice(0,4);return`${r}-${o}`}function Qn(t,e){let r=`shopify ${t.command}`;if(!e){let s=new T(`Another \`${r}\` is starting for this project.`,"Wait a few seconds and try again, or stop the other process first.");return s.code=Ut,s}let o=process.platform==="win32"?`taskkill /PID ${e.pid} /F`:`kill ${e.pid}`,n=Object.entries(e.details).filter(([,s])=>typeof s=="string"||typeof s=="number"||typeof s=="boolean").map(([s,i])=>[s,String(i)]),a=new T(`Another \`${r}\` is already running for this project.`,"Use the running instance, or stop it before starting a new one.",[["Read its output in",{filePath:e.logFile}],["Stop it with",{command:o}]],[{body:{tabularData:[["PID",String(e.pid)],["Started",e.startedAt],...n],firstColumnSubdued:!0}}]);return a.code=Ut,a.details={instance:e},a}function Zn({app:t,remoteApp:e,json:r=!1},o){return zn({command:"app dev",directory:t.directory,key:ye(t.configPath),details:{configPath:t.configPath,appName:e.title,clientId:e.apiKey},logOutput:r?process.stdout:void 0},o)}async function es(t){let e=await Da(t);await Ma(e);let{processes:r,graphiqlUrl:o,previewUrl:n,devSessionStatusManager:a}=await _n(e);await Na(e),await Ha({processes:r,previewUrl:n,graphiqlUrl:o,config:e,devSessionStatusManager:a})}async function Da(t){let{app:e,remoteApp:r,developerPlatformClient:o,store:n,specifications:a,tunnel:s}=t,i;if(s.mode==="auto"){let S=await M();i=await lo(t.commandConfig,S,"cloudflare")}let l=await ho(r,o,a,r.flags);r.configuration=l,go({app:e,remoteApp:r,selectedStore:n,cachedInfo:pt(t.directory),organization:t.organization,tunnelMode:s.mode}),e.configuration.build?.dev_store_url&&(e.configuration.build={...e.configuration.build,dev_store_url:n.shopDomain},await(await dr.read(e.configPath)).patch({build:{dev_store_url:n.shopDomain}})),!t.skipDependenciesInstallation&&!t.project.usesWorkspaces&&await Zr(t.project);let f=t.graphiqlPort??await M(de.graphiql),c=[{for:"GraphiQL",flagToRemedy:"--graphiql-port",requested:t.graphiqlPort??de.graphiql,actual:f}];s.mode==="use-localhost"&&c.push({for:"localhost",flagToRemedy:"--localhost-port",requested:s.requestedPort,actual:s.actualPort}),On(c);let{webs:p,...h}=await qa(e.directory,e.webs,f,s,i,r.configuration,t.installMkcert);e.webs=p;let g=e.configuration.build?.automatically_update_urls_on_dev,d=pt(t.directory)?.previousAppId,m=r.apiKey,x=await Wa(p,t.update,h,e,g,r,m);return{storeFqdn:n.shopDomain,storeId:n.shopId,remoteApp:r,remoteAppUpdated:r.apiKey!==d,localApp:e,developerPlatformClient:o,commandOptions:t,network:h,partnerUrlsUpdated:x,graphiqlPort:f,graphiqlKey:t.graphiqlKey}}async function Ma(t){await Oa(t)}async function Oa(t){let{developerPlatformClient:e,remoteApp:r}=t;(await e.appExtensionRegistrations(r)).app.extensionRegistrations.filter(n=>n.type.toLowerCase()!=="webhook_subscription").every(n=>n.id)||jn()}async function Na(t){no({directory:t.commandOptions.directory,previousAppId:t.remoteApp.apiKey}),await ja({devOptions:t.commandOptions,tunnelUrl:t.network.proxyUrl,shouldUpdateURLs:t.partnerUrlsUpdated,storeFqdn:t.storeFqdn}),await Vt({config:t.commandOptions.commandConfig,exitMode:"ok"})}async function Wa(t,e,r,o,n,a,s){let{backendConfig:i,frontendConfig:l}=J(t),f=!1;if((l??i)&&e){let c=ao(r.proxyUrl,t.map(({configuration:p})=>p.auth_callback_path).find(p=>p),o.configuration.app_proxy);f=await co({currentURLs:r.currentUrls,appDirectory:o.directory,cachedUpdateURLs:n,newApp:a.newApp,localApp:o,apiKey:s,newURLs:c}),f&&o.setDevApplicationURLs(c)}return f}async function qa(t,e,r,o,n,a,s){let{backendConfig:i,frontendConfig:l}=J(e);await Ga(e,r);let f=o.mode==="use-localhost"?{noTunnelUseLocalhost:!0,port:o.actualPort}:{noTunnelUseLocalhost:!1,tunnelUrl:o.mode==="custom"?o.url:void 0,tunnelClient:n},[{frontendUrl:c,frontendPort:p,usingLocalhost:h},g,d]=await Promise.all([so(f),Ot()??i?.configuration.port??M(),io(a)]),m=h?`${c}:${p}`:c,x=l?.configuration.port;l&&(x??=l===i?g:await M(),l.configuration.port=x),x=x??await M();let S;if(o.mode==="use-localhost"){let{keyContent:v,certContent:w,certPath:E}=await Hn({appDirectory:t,forceInstall:s});S={key:v,cert:w,certPath:E,port:o.actualPort}}return{proxyUrl:m,proxyPort:p,frontendPort:x,backendPort:g,currentUrls:d,webs:e,reverseProxyCert:S}}async function Ha({processes:t,previewUrl:e,graphiqlUrl:r,config:o,devSessionStatusManager:n}){let a=new Nt,s=o.commandOptions.devInstance,i=t.map(g=>({prefix:g.prefix,action:async(m,x,S)=>{let v=g.function,w=s?s.tee(m,{source:g.prefix,stringWritesAreMessages:!0}):m,E=s?s.tee(x,{source:g.prefix,stringWritesAreMessages:!0}):x;return v({stdout:w,stderr:E,abortSignal:S},g.options)}}));if(s){let g={storeFqdn:o.storeFqdn,previewUrl:e,graphiqlUrl:r,appUrl:o.localApp.devApplicationURLs?.applicationUrl,localUrl:o.network.proxyUrl};await s.update({status:"running",details:{...g,preview:Xn(n.status)}}),await s.log({source:"app dev",level:"info",message:`Preview URL: ${e}`}),r&&await s.log({source:"app dev",level:"info",message:`GraphiQL URL (Admin API): ${r}`})}let l=o.developerPlatformClient,f={id:o.remoteApp.id,developerPlatformClient:l},c,p=g=>{let d=[s?.update({details:{preview:Xn(g)}})],m=g.statusMessage;m&&(m.message!==c?.message||m.type!==c?.type)&&d.push(s?.log({source:"app dev",level:m.type==="error"?"error":"info",message:m.message})),c=m,Promise.all(d).catch(x=>{y(`Failed to save dev status: ${x.message}`)})};s&&(n.on("dev-session-update",p),p(n.status));let h=()=>a.abort(s?.abortSignal.reason);try{s?.abortSignal.throwIfAborted(),s?.abortSignal.addEventListener("abort",h,{once:!0}),await Mn({processes:i,previewUrl:e,graphiqlUrl:r,app:f,abortController:a,shopFqdn:o.storeFqdn,devSessionStatusManager:n,appURL:o.localApp.devApplicationURLs?.applicationUrl,appName:o.remoteApp.title,organizationName:o.commandOptions.organization.businessName,configPath:o.localApp.configPath,localURL:o.network.proxyUrl}),s?.abortSignal.throwIfAborted()}finally{s?.abortSignal.removeEventListener("abort",h),s&&n.off("dev-session-update",p)}}function Xn({isReady:t,statusMessage:e,errors:r}){let o=t?"ready":"starting";return t&&e?.type==="loading"&&(o="updating"),e?.type==="error"&&(o="error"),{state:o,message:e?.message??null,errors:r??[]}}async function ja(t){let e=await Nn(t.devOptions.commandConfig,t.tunnelUrl);await z.addPublicMetadata(()=>({cmd_dev_tunnel_type:e,cmd_dev_tunnel_custom_hash:e==="custom"?le(t.tunnelUrl):void 0,cmd_dev_urls_updated:t.shouldUpdateURLs,store_fqdn_hash:le(t.storeFqdn),store_domain:t.storeFqdn,cmd_app_dependency_installation_skipped:t.devOptions.skipDependenciesInstallation})),await z.addSensitiveMetadata(()=>({store_fqdn:t.storeFqdn,cmd_dev_tunnel_custom:e==="custom"?t.tunnelUrl:void 0}))}async function Ga(t,e){let r=t.map(n=>n.configuration.port).filter(n=>n),o=r.find((n,a)=>r.indexOf(n)!==a);if(o)throw new T(`Found port ${o} for multiple webs.`,"Please define a unique port for each web.");await Promise.all([...r.map(async n=>{if(!await st(n))throw new T(`Hard-coded port ${n} is not available, please choose a different one.`)}),(async()=>{if(!await st(e)){let a=`Port ${e} is not available for serving GraphiQL.`,s=["Choose a different port for the",{command:"--graphiql-port"},"flag."];throw new T(a,s)}})()])}u();var ts=A.object({state:A.enum(["starting","updating","ready","error"]),message:A.string().nullable(),errors:A.array(A.string())}).strict().describe("The CLI-reported preview state in the instance file; this is not a health check."),Ba=A.object({schemaVersion:A.literal(1),sessionId:A.string(),command:A.literal("app dev"),key:A.string().optional(),pid:A.number().int().positive(),status:A.enum(["starting","running"]),startedAt:ae,updatedAt:ae,directory:A.string(),logFile:A.string(),details:A.object({configPath:A.string(),appName:A.string(),clientId:A.string(),storeFqdn:A.string().optional(),previewUrl:A.string().optional(),graphiqlUrl:A.string().optional(),appUrl:A.string().optional(),localUrl:A.string().optional(),preview:ts.optional()}).strict()}).strict().describe("The instance JSON file under .shopify/dev/. This object is not emitted to stdout."),rs=ge({name:he.name,schema:he.schema,definitions:{DevInstance:Ba,DevPreview:ts}});u();async function os({useLocalhost:t,localhostPort:e,tunnelUrl:r}){if(r)return{mode:"custom",url:r};if(!t&&!e)return{mode:"auto"};let o=e??de.localhost,n=await M(o);if(e&&n!==o){let a=`Port ${e} is not available.`,s=["Choose a different port for the",{command:"--localhost-port"},"flag."];throw new T(a,s)}return{mode:"use-localhost",requestedPort:o,actualPort:n}}var $=X(is(),1);var Rt=class t extends yo{static get requiresSyncAnalytics(){return!0}static summary="Run the app.";static descriptionWithMarkdown="Builds and previews your app on a dev store, and watches for changes. [Read more about testing apps locally](https://shopify.dev/docs/apps/build/cli-for-apps/test-apps-locally).";static get jsonOutputSchema(){return rs}static description=this.descriptionForHelp();static flags={...fr,...Xr,...mr,"client-id":$.Flags.string({hidden:!1,description:"The Client ID of your app. Use with --config to run dev with that configuration for a different app than the one it is linked to.",env:"SHOPIFY_FLAG_CLIENT_ID"}),store:$.Flags.string({char:"s",description:"Store URL. Must be an existing development or Shopify Plus sandbox store.",env:"SHOPIFY_FLAG_STORE",parse:async e=>be(e)}),"skip-dependencies-installation":$.Flags.boolean({description:"Skips the installation of dependencies. Deprecated, use workspaces instead.",env:"SHOPIFY_FLAG_SKIP_DEPENDENCIES_INSTALLATION",default:!1}),"no-update":$.Flags.boolean({description:"Uses the app URL from the toml file instead an autogenerated URL for dev.",env:"SHOPIFY_FLAG_NO_UPDATE",default:!1}),"unsafe-validation":$.Flags.boolean({description:"Allow app dev to continue with warnings for eligible app version validation failures.",env:"SHOPIFY_FLAG_UNSAFE_VALIDATION",default:!1}),"subscription-product-url":$.Flags.string({description:'Resource URL for subscription UI extension. Format: "/products/{productId}"',env:"SHOPIFY_FLAG_SUBSCRIPTION_PRODUCT_URL"}),"checkout-cart-url":$.Flags.string({description:'Resource URL for checkout UI extension. Format: "/cart/{productVariantID}:{productQuantity}"',env:"SHOPIFY_FLAG_CHECKOUT_CART_URL"}),"tunnel-url":$.Flags.string({description:'Use a custom tunnel, it must be running before executing dev. Format: "https://my-tunnel-url:port".',env:"SHOPIFY_FLAG_TUNNEL_URL",exclusive:["tunnel"]}),"use-localhost":$.Flags.boolean({description:"Service entry point will listen to localhost. A tunnel won't be used. Will work for testing many app features, but not those that directly invoke your app (E.g: Webhooks)",env:"SHOPIFY_FLAG_USE_LOCALHOST",exclusive:["tunnel-url"]}),"install-mkcert":$.Flags.boolean({description:"Install and use mkcert to generate localhost certificates when --use-localhost is enabled without prompting.",env:"SHOPIFY_FLAG_INSTALL_MKCERT",dependsOn:["use-localhost"]}),"localhost-port":Ce({description:"Port to use for localhost.",env:"SHOPIFY_FLAG_LOCALHOST_PORT"}),theme:$.Flags.string({char:"t",description:"Theme ID or name of the theme app extension host theme.",env:"SHOPIFY_FLAG_THEME"}),"theme-app-extension-port":Ce({description:"Local port of the theme app extension development server.",env:"SHOPIFY_FLAG_THEME_APP_EXTENSION_PORT"}),"store-password":$.Flags.string({description:"The password for storefronts with password protection.",env:"SHOPIFY_FLAG_STORE_PASSWORD"}),notify:$.Flags.string({description:"The file path or URL. The file path is to a file that you want updated on idle. The URL path is where you want a webhook posted to report on file changes.",env:"SHOPIFY_FLAG_NOTIFY"}),"graphiql-port":Ce({hidden:!0,description:"Local port of the GraphiQL development server.",env:"SHOPIFY_FLAG_GRAPHIQL_PORT"}),"graphiql-key":$.Flags.string({hidden:!0,description:"Key used to authenticate GraphiQL requests. By default, a key is automatically derived from the app secret. Use this flag to override with a custom key.",env:"SHOPIFY_FLAG_GRAPHIQL_KEY"})};static analyticsStopCommand(){return"app dev stop"}async run(){let{flags:e}=await this.parse(t),r=await os({useLocalhost:e["use-localhost"]??!1,tunnelUrl:e["tunnel-url"],localhostPort:e["localhost-port"]});await zt(()=>({cmd_app_dependency_installation_skipped:e["skip-dependencies-installation"],cmd_app_reset_used:e.reset,cmd_dev_tunnel_type:r.mode})),await po(e.path);let o=await wo({directory:e.path,clientId:e["client-id"],forceRelink:e.reset,userProvidedConfigName:e.config});return Zn({...o,json:e.json},async n=>{let a=await vo({appContextResult:o,storeFqdn:e.store,forceReselectStore:e.reset,storeCreationMode:"selection-option"}),s={...o,store:a,directory:e.path,update:!e["no-update"],unsafeValidation:e["unsafe-validation"],skipDependenciesInstallation:e["skip-dependencies-installation"],commandConfig:this.config,subscriptionProductUrl:e["subscription-product-url"],checkoutCartUrl:e["checkout-cart-url"],theme:e.theme,themeExtensionPort:e["theme-app-extension-port"],storePassword:e["store-password"],notify:e.notify,graphiqlPort:e["graphiql-port"],graphiqlKey:e["graphiql-key"],installMkcert:e["install-mkcert"],tunnel:r,devInstance:n};return await es(s),{app:o.app}})}};export{Ii as a,Rt as b};
|
|
25
|
+
`:""))]).then(()=>E()).catch(E)},final(v){m().then(()=>v()).catch(v)}}),S=v=>x.destroy(v);return l.on("error",S),x.on("error",v=>o(v)),x.once("close",()=>{l.off("error",S)}),a.add(x),x},flush:()=>Promise.allSettled([...a].map(l=>Gn(l))),close:async()=>{try{await Gn(n),e&&!e.destroyed&&await Je(e,"")}finally{e?.off("error",o)}}}}var St=class extends xa{contexts=[];constructor(e){super({...e,write:(r,o,n)=>{D(this.contexts.shift()??{},()=>e.write.call(this,r,o,n))}})}write(e,r,o){return this.contexts.push(Ue()),typeof r=="string"?super.write(e,r,o):super.write(e,r??o)}end(e,r,o){return e!=null&&typeof e!="function"&&this.contexts.push(Ue()),typeof e=="function"?super.end(e):typeof r=="string"?super.end(e,r,o):super.end(e,r??o)}};async function Je(t,e,r="utf8"){await new Promise((o,n)=>{t.write(e,r,s=>s?n(s):o())})}async function Gn(t){let e=Ea(t,{cleanup:!0});t.end(),await e}var Vn=X(ls());import bt,{readFileSync as Ua}from"fs";import{mkdir as Ra,rmdir as Aa,writeFile as Ta}from"fs/promises";var Ut="dev_instance_already_running",Ia="dev",_a=15e3;function La(t){let e=U(t.directory,".shopify",Ia),r=Fa(t);return{folder:e,infoFile:U(e,`${r}.json`),lockFile:U(e,`${r}.lock`),logFile:U(e,`${r}.jsonl`)}}async function Ca(t){let e=La(t);await Lr(t.directory),await Z(e.folder);let r=`${e.lockFile}.acquire`;try{await Ra(r,{mode:448})}catch(o){if(o.code!=="EEXIST")throw o;let n=new I(`Another \`shopify ${t.command}\` is starting, or a previous startup was interrupted.`,"Wait for other starts to finish. If none is running, remove the startup lock below and try again.",[["Startup lock",{filePath:r}]]);throw n.code=Ut,n}try{return await ka(t,e)}catch(o){if(!$a(o))throw o;let n=await Jn(e.infoFile);throw Qn(t,n&&Yn(n.pid)?n:void 0)}finally{await Aa(r)}}async function zn(t,e){let r=await Ca(t);try{return await e(r)}finally{await r.release()}}async function ka(t,e){let r=await Jn(e.infoFile);if(r&&Yn(r.pid))throw Qn(t,r);let o=Ee(),n=new AbortController,s=!1,a=()=>{if(s)return!1;try{return JSON.parse(Ua(e.infoFile,"utf8")).sessionId===o}catch{return!1}},i=!1,l=w=>{if(!(i&&!a()))try{bt.rmdirSync(w)}catch(E){if(E.code!=="ENOENT")throw E}},f={realpath:!1,lockfilePath:e.lockFile,stale:_a,retries:0,onCompromised:w=>{s=!0,y(`The ${t.command} instance lock was compromised: ${w.message}`),n.abort(new I(`The ${t.command} instance lost its lock.`,"Start the command again."))},fs:{...bt,rmdir:(w,E)=>{if(i&&!a())return E(null);bt.rmdir(w,E)},rmdirSync:l}};r&&await kt(e.lockFile,{force:!0});let c=await Vn.default.lock(e.infoFile,f),p=ie(new Date),h={schemaVersion:1,sessionId:o,command:t.command,...t.key?{key:t.key}:{},pid:process.pid,status:"starting",startedAt:p,updatedAt:p,directory:t.directory,logFile:e.logFile,details:{...t.details??{}}},g=Promise.resolve(),d=!1,m=Bn({logFile:e.logFile,logOutput:t.logOutput,isActive:()=>!d&&!s,onError:w=>n.abort(w)}),x,S=()=>{!d&&a()&&(l(e.lockFile),Ct(e.infoFile))};process.once("exit",S);let v={info:h,paths:e,abortSignal:n.signal,update:async w=>{if(x||s)return;w.status&&(h.status=w.status),w.details&&(h.details={...h.details,...w.details}),h.updatedAt=ie(new Date);let E={...h,details:{...h.details}},L=g.then(async()=>{s||await Kn(e.infoFile,E)});g=L.catch(()=>{}),await L},log:m.log,tee:m.tee,release:()=>(x??=(async()=>{try{let E=(await m.flush()).find(L=>L.status==="rejected");if(await g,E?.status==="rejected")throw E.reason}finally{d=!0,process.removeListener("exit",S);try{await m.close()}finally{let w=a();await c().catch(E=>y(`Failed to release the dev instance lock: ${E.message}`)),w&&await Ze(e.infoFile).catch(()=>{})}}})(),x)};try{return await m.opened,await Kn(e.infoFile,h),i=!0,v}catch(w){throw await v.release().catch(E=>y(E.message)),await Ze(`${e.infoFile}.${o}.tmp`),w}}function Yn(t){if(!Number.isInteger(t)||t<=0)return!1;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}async function Jn(t){try{let e=JSON.parse(await C(t));return typeof e?.pid=="number"?e:void 0}catch{return}}async function Kn(t,e){let r=`${t}.${e.sessionId}.tmp`;await Ta(r,`${JSON.stringify(e,null,2)}
|
|
26
|
+
`,{mode:384}),await Lt(r,t)}function $a(t){return t?.code==="ELOCKED"}function Fa({command:t,key:e}){let r=[t,e].filter(Boolean).join("-").toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^-+|-+$/g,""),o=le(JSON.stringify([t,e??""])).slice(0,4);return`${r}-${o}`}function Qn(t,e){let r=`shopify ${t.command}`;if(!e){let a=new I(`Another \`${r}\` is starting for this project.`,"Wait a few seconds and try again, or stop the other process first.");return a.code=Ut,a}let o=process.platform==="win32"?`taskkill /PID ${e.pid} /F`:`kill ${e.pid}`,n=Object.entries(e.details).filter(([,a])=>typeof a=="string"||typeof a=="number"||typeof a=="boolean").map(([a,i])=>[a,String(i)]),s=new I(`Another \`${r}\` is already running for this project.`,"Use the running instance, or stop it before starting a new one.",[["Read its output in",{filePath:e.logFile}],["Stop it with",{command:o}]],[{body:{tabularData:[["PID",String(e.pid)],["Started",e.startedAt],...n],firstColumnSubdued:!0}}]);return s.code=Ut,s.details={instance:e},s}function Zn({app:t,remoteApp:e,json:r=!1},o){return zn({command:"app dev",directory:t.directory,key:ye(t.configPath),details:{configPath:t.configPath,appName:e.title,clientId:e.apiKey},logOutput:r?process.stdout:void 0},o)}async function es(t){let e=new Nt,r;try{if(t.tunnel.mode==="auto"){let l=await M();r=await lo(t.commandConfig,l,"cloudflare"),e.signal.addEventListener("abort",()=>r?.stopTunnel(),{once:!0})}let o=await Da(t,r);await Ma(o);let{processes:n,graphiqlUrl:s,previewUrl:a,devSessionStatusManager:i}=await _n(o);await Na(o),await Ha({processes:n,previewUrl:a,graphiqlUrl:s,config:o,devSessionStatusManager:i,abortController:e})}finally{e.abort()}}async function Da(t,e){let{app:r,remoteApp:o,developerPlatformClient:n,store:s,specifications:a,tunnel:i}=t,l=await ho(o,n,a,o.flags);o.configuration=l,go({app:r,remoteApp:o,selectedStore:s,cachedInfo:pt(t.directory),organization:t.organization,tunnelMode:i.mode}),r.configuration.build?.dev_store_url&&(r.configuration.build={...r.configuration.build,dev_store_url:s.shopDomain},await(await dr.read(r.configPath)).patch({build:{dev_store_url:s.shopDomain}})),!t.skipDependenciesInstallation&&!t.project.usesWorkspaces&&await Zr(t.project);let f=t.graphiqlPort??await M(de.graphiql),c=[{for:"GraphiQL",flagToRemedy:"--graphiql-port",requested:t.graphiqlPort??de.graphiql,actual:f}];i.mode==="use-localhost"&&c.push({for:"localhost",flagToRemedy:"--localhost-port",requested:i.requestedPort,actual:i.actualPort}),On(c);let{webs:p,...h}=await qa(r.directory,r.webs,f,i,e,o.configuration,t.installMkcert);r.webs=p;let g=r.configuration.build?.automatically_update_urls_on_dev,d=pt(t.directory)?.previousAppId,m=o.apiKey,x=await Wa(p,t.update,h,r,g,o,m);return{storeFqdn:s.shopDomain,storeId:s.shopId,remoteApp:o,remoteAppUpdated:o.apiKey!==d,localApp:r,developerPlatformClient:n,commandOptions:t,network:h,partnerUrlsUpdated:x,graphiqlPort:f,graphiqlKey:t.graphiqlKey}}async function Ma(t){await Oa(t)}async function Oa(t){let{developerPlatformClient:e,remoteApp:r}=t;(await e.appExtensionRegistrations(r)).app.extensionRegistrations.filter(n=>n.type.toLowerCase()!=="webhook_subscription").every(n=>n.id)||jn()}async function Na(t){no({directory:t.commandOptions.directory,previousAppId:t.remoteApp.apiKey}),await ja({devOptions:t.commandOptions,tunnelUrl:t.network.proxyUrl,shouldUpdateURLs:t.partnerUrlsUpdated,storeFqdn:t.storeFqdn}),await Vt({config:t.commandOptions.commandConfig,exitMode:"ok"})}async function Wa(t,e,r,o,n,s,a){let{backendConfig:i,frontendConfig:l}=J(t),f=!1;if((l??i)&&e){let c=ao(r.proxyUrl,t.map(({configuration:p})=>p.auth_callback_path).find(p=>p),o.configuration.app_proxy);f=await co({currentURLs:r.currentUrls,appDirectory:o.directory,cachedUpdateURLs:n,newApp:s.newApp,localApp:o,apiKey:a,newURLs:c}),f&&o.setDevApplicationURLs(c)}return f}async function qa(t,e,r,o,n,s,a){let{backendConfig:i,frontendConfig:l}=J(e);await Ga(e,r);let f=o.mode==="use-localhost"?{noTunnelUseLocalhost:!0,port:o.actualPort}:{noTunnelUseLocalhost:!1,tunnelUrl:o.mode==="custom"?o.url:void 0,tunnelClient:n},[{frontendUrl:c,frontendPort:p,usingLocalhost:h},g,d]=await Promise.all([so(f),Ot()??i?.configuration.port??M(),io(s)]),m=h?`${c}:${p}`:c,x=l?.configuration.port;l&&(x??=l===i?g:await M(),l.configuration.port=x),x=x??await M();let S;if(o.mode==="use-localhost"){let{keyContent:v,certContent:w,certPath:E}=await Hn({appDirectory:t,forceInstall:a});S={key:v,cert:w,certPath:E,port:o.actualPort}}return{proxyUrl:m,proxyPort:p,frontendPort:x,backendPort:g,currentUrls:d,webs:e,reverseProxyCert:S}}async function Ha({processes:t,previewUrl:e,graphiqlUrl:r,config:o,devSessionStatusManager:n,abortController:s}){let a=o.commandOptions.devInstance,i=t.map(g=>({prefix:g.prefix,action:async(m,x,S)=>{let v=g.function,w=a?a.tee(m,{source:g.prefix,stringWritesAreMessages:!0}):m,E=a?a.tee(x,{source:g.prefix,stringWritesAreMessages:!0}):x;return v({stdout:w,stderr:E,abortSignal:S},g.options)}}));if(a){let g={storeFqdn:o.storeFqdn,previewUrl:e,graphiqlUrl:r,appUrl:o.localApp.devApplicationURLs?.applicationUrl,localUrl:o.network.proxyUrl};await a.update({status:"running",details:{...g,preview:Xn(n.status)}}),await a.log({source:"app dev",level:"info",message:`Preview URL: ${e}`}),r&&await a.log({source:"app dev",level:"info",message:`GraphiQL URL (Admin API): ${r}`})}let l=o.developerPlatformClient,f={id:o.remoteApp.id,developerPlatformClient:l},c,p=g=>{let d=[a?.update({details:{preview:Xn(g)}})],m=g.statusMessage;m&&(m.message!==c?.message||m.type!==c?.type)&&d.push(a?.log({source:"app dev",level:m.type==="error"?"error":"info",message:m.message})),c=m,Promise.all(d).catch(x=>{y(`Failed to save dev status: ${x.message}`)})};a&&(n.on("dev-session-update",p),p(n.status));let h=()=>s.abort(a?.abortSignal.reason);try{a?.abortSignal.throwIfAborted(),a?.abortSignal.addEventListener("abort",h,{once:!0}),await Mn({processes:i,previewUrl:e,graphiqlUrl:r,app:f,abortController:s,shopFqdn:o.storeFqdn,devSessionStatusManager:n,appURL:o.localApp.devApplicationURLs?.applicationUrl,appName:o.remoteApp.title,organizationName:o.commandOptions.organization.businessName,configPath:o.localApp.configPath,localURL:o.network.proxyUrl}),a?.abortSignal.throwIfAborted()}finally{a?.abortSignal.removeEventListener("abort",h),a&&n.off("dev-session-update",p)}}function Xn({isReady:t,statusMessage:e,errors:r}){let o=t?"ready":"starting";return t&&e?.type==="loading"&&(o="updating"),e?.type==="error"&&(o="error"),{state:o,message:e?.message??null,errors:r??[]}}async function ja(t){let e=await Nn(t.devOptions.commandConfig,t.tunnelUrl);await z.addPublicMetadata(()=>({cmd_dev_tunnel_type:e,cmd_dev_tunnel_custom_hash:e==="custom"?le(t.tunnelUrl):void 0,cmd_dev_urls_updated:t.shouldUpdateURLs,store_fqdn_hash:le(t.storeFqdn),store_domain:t.storeFqdn,cmd_app_dependency_installation_skipped:t.devOptions.skipDependenciesInstallation})),await z.addSensitiveMetadata(()=>({store_fqdn:t.storeFqdn,cmd_dev_tunnel_custom:e==="custom"?t.tunnelUrl:void 0}))}async function Ga(t,e){let r=t.map(n=>n.configuration.port).filter(n=>n),o=r.find((n,s)=>r.indexOf(n)!==s);if(o)throw new I(`Found port ${o} for multiple webs.`,"Please define a unique port for each web.");await Promise.all([...r.map(async n=>{if(!await st(n))throw new I(`Hard-coded port ${n} is not available, please choose a different one.`)}),(async()=>{if(!await st(e)){let s=`Port ${e} is not available for serving GraphiQL.`,a=["Choose a different port for the",{command:"--graphiql-port"},"flag."];throw new I(s,a)}})()])}u();var ts=A.object({state:A.enum(["starting","updating","ready","error"]),message:A.string().nullable(),errors:A.array(A.string())}).strict().describe("The CLI-reported preview state in the instance file; this is not a health check."),Ba=A.object({schemaVersion:A.literal(1),sessionId:A.string(),command:A.literal("app dev"),key:A.string().optional(),pid:A.number().int().positive(),status:A.enum(["starting","running"]),startedAt:ae,updatedAt:ae,directory:A.string(),logFile:A.string(),details:A.object({configPath:A.string(),appName:A.string(),clientId:A.string(),storeFqdn:A.string().optional(),previewUrl:A.string().optional(),graphiqlUrl:A.string().optional(),appUrl:A.string().optional(),localUrl:A.string().optional(),preview:ts.optional()}).strict()}).strict().describe("The instance JSON file under .shopify/dev/. This object is not emitted to stdout."),rs=ge({name:he.name,schema:he.schema,definitions:{DevInstance:Ba,DevPreview:ts}});u();async function os({useLocalhost:t,localhostPort:e,tunnelUrl:r}){if(r)return{mode:"custom",url:r};if(!t&&!e)return{mode:"auto"};let o=e??de.localhost,n=await M(o);if(e&&n!==o){let s=`Port ${e} is not available.`,a=["Choose a different port for the",{command:"--localhost-port"},"flag."];throw new I(s,a)}return{mode:"use-localhost",requestedPort:o,actualPort:n}}var $=X(is(),1);var Rt=class t extends yo{static get requiresSyncAnalytics(){return!0}static summary="Run the app.";static descriptionWithMarkdown="Builds and previews your app on a dev store, and watches for changes. [Read more about testing apps locally](https://shopify.dev/docs/apps/build/cli-for-apps/test-apps-locally).";static get jsonOutputSchema(){return rs}static description=this.descriptionForHelp();static flags={...fr,...Xr,...mr,"client-id":$.Flags.string({hidden:!1,description:"The Client ID of your app. Use with --config to run dev with that configuration for a different app than the one it is linked to.",env:"SHOPIFY_FLAG_CLIENT_ID"}),store:$.Flags.string({char:"s",description:"Store URL. Must be an existing development or Shopify Plus sandbox store.",env:"SHOPIFY_FLAG_STORE",parse:async e=>be(e)}),"skip-dependencies-installation":$.Flags.boolean({description:"Skips the installation of dependencies. Deprecated, use workspaces instead.",env:"SHOPIFY_FLAG_SKIP_DEPENDENCIES_INSTALLATION",default:!1}),"no-update":$.Flags.boolean({description:"Uses the app URL from the toml file instead an autogenerated URL for dev.",env:"SHOPIFY_FLAG_NO_UPDATE",default:!1}),"unsafe-validation":$.Flags.boolean({description:"Allow app dev to continue with warnings for eligible app version validation failures.",env:"SHOPIFY_FLAG_UNSAFE_VALIDATION",default:!1}),"subscription-product-url":$.Flags.string({description:'Resource URL for subscription UI extension. Format: "/products/{productId}"',env:"SHOPIFY_FLAG_SUBSCRIPTION_PRODUCT_URL"}),"checkout-cart-url":$.Flags.string({description:'Resource URL for checkout UI extension. Format: "/cart/{productVariantID}:{productQuantity}"',env:"SHOPIFY_FLAG_CHECKOUT_CART_URL"}),"tunnel-url":$.Flags.string({description:'Use a custom tunnel, it must be running before executing dev. Format: "https://my-tunnel-url:port".',env:"SHOPIFY_FLAG_TUNNEL_URL",exclusive:["tunnel"]}),"use-localhost":$.Flags.boolean({description:"Service entry point will listen to localhost. A tunnel won't be used. Will work for testing many app features, but not those that directly invoke your app (E.g: Webhooks)",env:"SHOPIFY_FLAG_USE_LOCALHOST",exclusive:["tunnel-url"]}),"install-mkcert":$.Flags.boolean({description:"Install and use mkcert to generate localhost certificates when --use-localhost is enabled without prompting.",env:"SHOPIFY_FLAG_INSTALL_MKCERT",dependsOn:["use-localhost"]}),"localhost-port":Ce({description:"Port to use for localhost.",env:"SHOPIFY_FLAG_LOCALHOST_PORT"}),theme:$.Flags.string({char:"t",description:"Theme ID or name of the theme app extension host theme.",env:"SHOPIFY_FLAG_THEME"}),"theme-app-extension-port":Ce({description:"Local port of the theme app extension development server.",env:"SHOPIFY_FLAG_THEME_APP_EXTENSION_PORT"}),"store-password":$.Flags.string({description:"The password for storefronts with password protection.",env:"SHOPIFY_FLAG_STORE_PASSWORD"}),notify:$.Flags.string({description:"The file path or URL. The file path is to a file that you want updated on idle. The URL path is where you want a webhook posted to report on file changes.",env:"SHOPIFY_FLAG_NOTIFY"}),"graphiql-port":Ce({hidden:!0,description:"Local port of the GraphiQL development server.",env:"SHOPIFY_FLAG_GRAPHIQL_PORT"}),"graphiql-key":$.Flags.string({hidden:!0,description:"Key used to authenticate GraphiQL requests. By default, a key is automatically derived from the app secret. Use this flag to override with a custom key.",env:"SHOPIFY_FLAG_GRAPHIQL_KEY"})};static analyticsStopCommand(){return"app dev stop"}async run(){let{flags:e}=await this.parse(t),r=await os({useLocalhost:e["use-localhost"]??!1,tunnelUrl:e["tunnel-url"],localhostPort:e["localhost-port"]});await zt(()=>({cmd_app_dependency_installation_skipped:e["skip-dependencies-installation"],cmd_app_reset_used:e.reset,cmd_dev_tunnel_type:r.mode})),await po(e.path);let o=await wo({directory:e.path,clientId:e["client-id"],forceRelink:e.reset,userProvidedConfigName:e.config});return Zn({...o,json:e.json},async n=>{let s=await vo({appContextResult:o,storeFqdn:e.store,forceReselectStore:e.reset,storeCreationMode:"selection-option"}),a={...o,store:s,directory:e.path,update:!e["no-update"],unsafeValidation:e["unsafe-validation"],skipDependenciesInstallation:e["skip-dependencies-installation"],commandConfig:this.config,subscriptionProductUrl:e["subscription-product-url"],checkoutCartUrl:e["checkout-cart-url"],theme:e.theme,themeExtensionPort:e["theme-app-extension-port"],storePassword:e["store-password"],notify:e.notify,graphiqlPort:e["graphiql-port"],graphiqlKey:e["graphiql-key"],installMkcert:e["install-mkcert"],tunnel:r,devInstance:n};return await es(a),{app:o.app}})}};export{Ti as a,Rt as b};
|