gemi 0.52.0 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/index.js +2 -2
- package/dist/app/index.js.map +1 -1
- package/dist/bin/gemi.js +1456 -5
- package/dist/bin/gemi.js.map +9 -5
- package/dist/broadcasting/index.js +1 -1
- package/dist/bun/plugin.js +2 -2
- package/dist/bun/plugin.js.map +1 -1
- package/dist/bun/preload.js +2 -2
- package/dist/bun/preload.js.map +1 -1
- package/dist/{chunk-msz8rngs.js → chunk-004bcmsa.js} +2 -2
- package/dist/chunk-004bcmsa.js.map +10 -0
- package/dist/chunk-07t0dmdg.js +4 -0
- package/dist/{chunk-faa987e4.js.map → chunk-07t0dmdg.js.map} +2 -2
- package/dist/{chunk-4t6a82fh.js → chunk-0weeq0ke.js} +2 -2
- package/dist/{chunk-4t6a82fh.js.map → chunk-0weeq0ke.js.map} +1 -1
- package/dist/chunk-113khwbw.js +5 -0
- package/dist/{chunk-2qn472j4.js.map → chunk-113khwbw.js.map} +1 -1
- package/dist/{chunk-tmk4zfz9.js → chunk-1sh6kqjn.js} +3 -3
- package/dist/{chunk-tmk4zfz9.js.map → chunk-1sh6kqjn.js.map} +1 -1
- package/dist/{chunk-2gw6cyyj.js → chunk-1snh7yc4.js} +2 -2
- package/dist/{chunk-2gw6cyyj.js.map → chunk-1snh7yc4.js.map} +1 -1
- package/dist/chunk-26r8dcxd.js +6 -0
- package/dist/{chunk-hbycemy5.js.map → chunk-26r8dcxd.js.map} +2 -2
- package/dist/{chunk-ebcgdv00.js → chunk-2pt6kyn9.js} +3 -3
- package/dist/{chunk-ebcgdv00.js.map → chunk-2pt6kyn9.js.map} +1 -1
- package/dist/{chunk-jdfe4dmh.js → chunk-2zmz3pjk.js} +3 -3
- package/dist/{chunk-jdfe4dmh.js.map → chunk-2zmz3pjk.js.map} +1 -1
- package/dist/{chunk-zhsaz9cr.js → chunk-3bw1jk21.js} +1 -1
- package/dist/chunk-4qkzdyj7.js +4 -0
- package/dist/{chunk-4e61qbp4.js.map → chunk-4qkzdyj7.js.map} +1 -1
- package/dist/{chunk-d1ahbza9.js → chunk-50vm7x98.js} +3 -3
- package/dist/{chunk-d1ahbza9.js.map → chunk-50vm7x98.js.map} +1 -1
- package/dist/{chunk-qyaqg07q.js → chunk-6j1z2cqt.js} +2 -2
- package/dist/{chunk-qyaqg07q.js.map → chunk-6j1z2cqt.js.map} +1 -1
- package/dist/chunk-6rhebm18.js +5 -0
- package/dist/chunk-6rhebm18.js.map +10 -0
- package/dist/{chunk-rq770c71.js → chunk-71m47kad.js} +2 -2
- package/dist/{chunk-rq770c71.js.map → chunk-71m47kad.js.map} +1 -1
- package/dist/{chunk-0h3jr9d9.js → chunk-7f5ad759.js} +2 -2
- package/dist/{chunk-8p6rqegw.js.map → chunk-7f5ad759.js.map} +1 -1
- package/dist/{chunk-qj4mmner.js → chunk-85av4ncy.js} +2 -2
- package/dist/{chunk-qj4mmner.js.map → chunk-85av4ncy.js.map} +1 -1
- package/dist/{chunk-23g7qdpg.js → chunk-9taz1h3t.js} +3 -3
- package/dist/{chunk-23g7qdpg.js.map → chunk-9taz1h3t.js.map} +1 -1
- package/dist/{chunk-ppt296ye.js → chunk-agabw2w1.js} +2 -2
- package/dist/{chunk-ppt296ye.js.map → chunk-agabw2w1.js.map} +1 -1
- package/dist/{chunk-092pj2j2.js → chunk-bb3zvxsf.js} +3 -3
- package/dist/{chunk-092pj2j2.js.map → chunk-bb3zvxsf.js.map} +1 -1
- package/dist/{chunk-h7jv3ame.js → chunk-br8ten26.js} +2 -2
- package/dist/{chunk-h7jv3ame.js.map → chunk-br8ten26.js.map} +1 -1
- package/dist/{chunk-4e61qbp4.js → chunk-bzhtymvv.js} +2 -2
- package/dist/{chunk-0h3jr9d9.js.map → chunk-bzhtymvv.js.map} +1 -1
- package/dist/{chunk-68w225rv.js → chunk-c0wcsmpj.js} +2 -2
- package/dist/{chunk-68w225rv.js.map → chunk-c0wcsmpj.js.map} +1 -1
- package/dist/{chunk-xsmt86n3.js → chunk-c22vcxty.js} +2 -2
- package/dist/{chunk-xsmt86n3.js.map → chunk-c22vcxty.js.map} +1 -1
- package/dist/{chunk-a0sy9f9x.js → chunk-c2pv3ah8.js} +2 -2
- package/dist/{chunk-a0sy9f9x.js.map → chunk-c2pv3ah8.js.map} +2 -2
- package/dist/{chunk-q09mmr05.js → chunk-cz3szqhq.js} +2 -2
- package/dist/{chunk-q09mmr05.js.map → chunk-cz3szqhq.js.map} +1 -1
- package/dist/{chunk-69w4egkg.js → chunk-dwx2y7br.js} +4 -4
- package/dist/{chunk-69w4egkg.js.map → chunk-dwx2y7br.js.map} +1 -1
- package/dist/{chunk-2sfz64xh.js → chunk-dxw8k6f1.js} +2 -2
- package/dist/{chunk-2sfz64xh.js.map → chunk-dxw8k6f1.js.map} +1 -1
- package/dist/chunk-e3mggavt.js +5 -0
- package/dist/chunk-e3mggavt.js.map +11 -0
- package/dist/{chunk-j1knf8gv.js → chunk-efsk1wy0.js} +3 -3
- package/dist/{chunk-j1knf8gv.js.map → chunk-efsk1wy0.js.map} +1 -1
- package/dist/{chunk-t4n25km9.js → chunk-f13f68c0.js} +2 -2
- package/dist/{chunk-t4n25km9.js.map → chunk-f13f68c0.js.map} +1 -1
- package/dist/{chunk-vv72kw74.js → chunk-f418jh9k.js} +2 -2
- package/dist/{chunk-vv72kw74.js.map → chunk-f418jh9k.js.map} +1 -1
- package/dist/chunk-f4e7fh95.js +17 -0
- package/dist/chunk-f4e7fh95.js.map +14 -0
- package/dist/{chunk-ewgv1j8q.js → chunk-fcqc3e3r.js} +2 -2
- package/dist/{chunk-ewgv1j8q.js.map → chunk-fcqc3e3r.js.map} +1 -1
- package/dist/{chunk-3y9nf09k.js → chunk-g5tj10p8.js} +2 -2
- package/dist/{chunk-3y9nf09k.js.map → chunk-g5tj10p8.js.map} +1 -1
- package/dist/chunk-gn9zjgep.js +5 -0
- package/dist/chunk-gn9zjgep.js.map +10 -0
- package/dist/{chunk-5s45prj5.js → chunk-h7mcwfg5.js} +4 -4
- package/dist/{chunk-5s45prj5.js.map → chunk-h7mcwfg5.js.map} +1 -1
- package/dist/chunk-hk067634.js +4 -0
- package/dist/{chunk-vnjvd82s.js.map → chunk-hk067634.js.map} +2 -2
- package/dist/{chunk-qx6sahe0.js → chunk-hrrmxreg.js} +2 -2
- package/dist/{chunk-qx6sahe0.js.map → chunk-hrrmxreg.js.map} +1 -1
- package/dist/{chunk-p22rkf1g.js → chunk-jb022m7n.js} +2 -2
- package/dist/{chunk-p22rkf1g.js.map → chunk-jb022m7n.js.map} +1 -1
- package/dist/chunk-jb2nst6v.js +4 -0
- package/dist/{chunk-6scjrbw7.js.map → chunk-jb2nst6v.js.map} +2 -2
- package/dist/{chunk-kxzwem3g.js → chunk-jdgvdddd.js} +2 -2
- package/dist/{chunk-kxzwem3g.js.map → chunk-jdgvdddd.js.map} +1 -1
- package/dist/{chunk-2yth3kk2.js → chunk-jp4pf3yt.js} +4 -4
- package/dist/{chunk-2yth3kk2.js.map → chunk-jp4pf3yt.js.map} +1 -1
- package/dist/{chunk-0tbwn6er.js → chunk-k14dmqwh.js} +3 -3
- package/dist/{chunk-0tbwn6er.js.map → chunk-k14dmqwh.js.map} +1 -1
- package/dist/{chunk-1ce7veh9.js → chunk-k8endm5j.js} +3 -3
- package/dist/{chunk-1ce7veh9.js.map → chunk-k8endm5j.js.map} +1 -1
- package/dist/chunk-kkkqyvwv.js +81 -0
- package/dist/{chunk-km6x37ws.js.map → chunk-kkkqyvwv.js.map} +5 -5
- package/dist/{chunk-cmq5t8p9.js → chunk-kv2ep453.js} +3 -3
- package/dist/{chunk-cmq5t8p9.js.map → chunk-kv2ep453.js.map} +1 -1
- package/dist/{chunk-z4q1ty6w.js → chunk-kz39hphm.js} +3 -3
- package/dist/{chunk-z4q1ty6w.js.map → chunk-kz39hphm.js.map} +1 -1
- package/dist/{chunk-kaxvw75w.js → chunk-ms8qd7da.js} +3 -3
- package/dist/{chunk-kaxvw75w.js.map → chunk-ms8qd7da.js.map} +1 -1
- package/dist/{chunk-ttzkn1qd.js → chunk-n1tkn8gv.js} +2 -2
- package/dist/{chunk-ttzkn1qd.js.map → chunk-n1tkn8gv.js.map} +1 -1
- package/dist/chunk-nncwsdzz.js +5 -0
- package/dist/chunk-nncwsdzz.js.map +10 -0
- package/dist/{chunk-et0j6jx8.js → chunk-pgjk5ft3.js} +3 -3
- package/dist/{chunk-et0j6jx8.js.map → chunk-pgjk5ft3.js.map} +1 -1
- package/dist/{chunk-tztqkat2.js → chunk-r06rxn19.js} +2 -2
- package/dist/{chunk-tztqkat2.js.map → chunk-r06rxn19.js.map} +1 -1
- package/dist/chunk-r9z5rrk0.js +4 -0
- package/dist/{chunk-1ab1ptq5.js.map → chunk-r9z5rrk0.js.map} +2 -2
- package/dist/{chunk-h5g05qwb.js → chunk-s6e7cvek.js} +2 -2
- package/dist/{chunk-h5g05qwb.js.map → chunk-s6e7cvek.js.map} +1 -1
- package/dist/{chunk-53e48ce8.js → chunk-sqp7kn7h.js} +3 -3
- package/dist/{chunk-53e48ce8.js.map → chunk-sqp7kn7h.js.map} +1 -1
- package/dist/{chunk-mt2755rs.js → chunk-w6gb9gc5.js} +3 -3
- package/dist/{chunk-mt2755rs.js.map → chunk-w6gb9gc5.js.map} +1 -1
- package/dist/{chunk-ha7n1c94.js → chunk-xxw0gz4q.js} +2 -2
- package/dist/{chunk-ha7n1c94.js.map → chunk-xxw0gz4q.js.map} +1 -1
- package/dist/chunk-ywr2vd5r.js +5 -0
- package/dist/{chunk-f29vd5mc.js.map → chunk-ywr2vd5r.js.map} +2 -2
- package/dist/{chunk-38ma6gg3.js → chunk-zckj6bs6.js} +3 -3
- package/dist/{chunk-38ma6gg3.js.map → chunk-zckj6bs6.js.map} +1 -1
- package/dist/chunks/ThemeProvider-Bk1eZymb.js +2901 -0
- package/dist/chunks/ThemeProvider-Bk1eZymb.js.map +1 -0
- package/dist/client/ComponentContext.d.ts.map +1 -1
- package/dist/client/DictionarySinkContext.d.ts +10 -0
- package/dist/client/DictionarySinkContext.d.ts.map +1 -0
- package/dist/client/Mutation.d.ts +1 -1
- package/dist/client/Mutation.d.ts.map +1 -1
- package/dist/client/ThemeProvider.d.ts +7 -0
- package/dist/client/ThemeProvider.d.ts.map +1 -1
- package/dist/client/createRoot.d.ts.map +1 -1
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +242 -2629
- package/dist/client/index.js.map +1 -1
- package/dist/client/useDictionary.d.ts +34 -0
- package/dist/client/useDictionary.d.ts.map +1 -0
- package/dist/client/useDictionary.test-d.d.ts +2 -0
- package/dist/client/useDictionary.test-d.d.ts.map +1 -0
- package/dist/client/useIsNavigationPending.d.ts.map +1 -1
- package/dist/client/useMutate.d.ts.map +1 -1
- package/dist/client/useTranslator.d.ts +8 -0
- package/dist/client/useTranslator.d.ts.map +1 -1
- package/dist/config/index.js +1 -1
- package/dist/console/run.js +2 -2
- package/dist/console/run.js.map +1 -1
- package/dist/container/index.js +2 -2
- package/dist/container/index.js.map +1 -1
- package/dist/database/index.js +2 -2
- package/dist/database/index.js.map +1 -1
- package/dist/email/index.js +2 -2
- package/dist/email/index.js.map +1 -1
- package/dist/facades/Lang.d.ts.map +1 -1
- package/dist/facades/index.js +2 -2
- package/dist/facades/index.js.map +1 -1
- package/dist/foundation/index.js +2 -2
- package/dist/foundation/index.js.map +1 -1
- package/dist/http/index.js +2 -2
- package/dist/http/index.js.map +1 -1
- package/dist/i18n/Dictionary.d.ts +7 -0
- package/dist/i18n/Dictionary.d.ts.map +1 -1
- package/dist/i18n/Translator.d.ts +12 -0
- package/dist/i18n/Translator.d.ts.map +1 -1
- package/dist/i18n/config.d.ts +6 -0
- package/dist/i18n/config.d.ts.map +1 -1
- package/dist/i18n/defineDictionary.d.ts +65 -0
- package/dist/i18n/defineDictionary.d.ts.map +1 -0
- package/dist/i18n/dictionaryRegistry.d.ts +85 -0
- package/dist/i18n/dictionaryRegistry.d.ts.map +1 -0
- package/dist/i18n/dictionaryRuntime.d.ts +16 -0
- package/dist/i18n/dictionaryRuntime.d.ts.map +1 -0
- package/dist/i18n/dictionaryRuntime.js +4 -0
- package/dist/i18n/dictionaryRuntime.js.map +9 -0
- package/dist/i18n/dictionaryShape.d.ts +66 -0
- package/dist/i18n/dictionaryShape.d.ts.map +1 -0
- package/dist/i18n/dictionarySink.d.ts +31 -0
- package/dist/i18n/dictionarySink.d.ts.map +1 -0
- package/dist/i18n/index.d.ts +3 -0
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/index.js +2 -2
- package/dist/i18n/index.js.map +5 -4
- package/dist/i18n/translate.d.ts +21 -0
- package/dist/i18n/translate.d.ts.map +1 -0
- package/dist/internal/gemiExternals.d.ts +1 -1
- package/dist/internal/gemiExternals.d.ts.map +1 -1
- package/dist/kernel/index.js +2 -2
- package/dist/kernel/index.js.map +2 -2
- package/dist/orm/index.js +2 -2
- package/dist/orm/index.js.map +2 -2
- package/dist/server/index.js +2 -2
- package/dist/server/index.js.map +1 -1
- package/dist/services/index.js +4 -4
- package/dist/services/index.js.map +2 -2
- package/dist/services/router/ViewRouteDispatcher.d.ts.map +1 -1
- package/dist/services/router/streamQueryInjection.d.ts +9 -1
- package/dist/services/router/streamQueryInjection.d.ts.map +1 -1
- package/dist/support/index.js +2 -2
- package/dist/support/index.js.map +1 -1
- package/dist/testing/Page.d.ts +166 -0
- package/dist/testing/Page.d.ts.map +1 -0
- package/dist/testing/index.d.ts +3 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +352 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/utils/Subject.d.ts.map +1 -1
- package/dist/utils/variantKey.d.ts +19 -0
- package/dist/utils/variantKey.d.ts.map +1 -0
- package/dist/vite/__vite-browser-external-S5EYS4bz.mjs +7 -0
- package/dist/vite/api_vite-DSBC5Nzy.mjs +5 -0
- package/dist/vite/browser-DFEUWTkA.mjs +6086 -0
- package/dist/vite/build-C0lmnz6d.mjs +5326 -0
- package/dist/vite/index.mjs +1349 -1
- package/dist/vite/lib-TT6NqN6b.mjs +363 -0
- package/dist/vite/lib-U4DF62jt.mjs +48846 -0
- package/dist/vite/main-Drp2rSLR.mjs +2123 -0
- package/dist/vite/node-BgyIm-M7.mjs +17799 -0
- package/dist/vite/node-yGkKTK1d.mjs +789 -0
- package/dist/vite/postcss-hCXrlC4m.mjs +3515 -0
- package/dist/vite/postcss-import-rYEe0OKc.mjs +448 -0
- package/dist/vite/prompt--dNycKSZ-BmZ8jzP_.mjs +889 -0
- package/dist/vite/rolldown-runtime-B4lejLz5.mjs +37 -0
- package/package.json +4 -1
- package/dist/chunk-1ab1ptq5.js +0 -4
- package/dist/chunk-2qn472j4.js +0 -5
- package/dist/chunk-6scjrbw7.js +0 -4
- package/dist/chunk-88pq4gmf.js +0 -5
- package/dist/chunk-88pq4gmf.js.map +0 -10
- package/dist/chunk-8p6rqegw.js +0 -4
- package/dist/chunk-f29vd5mc.js +0 -5
- package/dist/chunk-faa987e4.js +0 -4
- package/dist/chunk-hbycemy5.js +0 -6
- package/dist/chunk-km6x37ws.js +0 -81
- package/dist/chunk-msz8rngs.js.map +0 -10
- package/dist/chunk-vnjvd82s.js +0 -4
- package/dist/chunk-xw44bwnh.js +0 -5
- package/dist/chunk-xw44bwnh.js.map +0 -11
- /package/dist/{chunk-zhsaz9cr.js.map → chunk-3bw1jk21.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewRouteDispatcher.d.ts","sourceRoot":"","sources":["../../../services/router/ViewRouteDispatcher.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAIzC,OAAO,EAEL,KAAK,cAAc,EAEpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAA2B,KAAK,eAAe,EAAE,MAAM,UAAU,CAAC;AAUzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"ViewRouteDispatcher.d.ts","sourceRoot":"","sources":["../../../services/router/ViewRouteDispatcher.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAIzC,OAAO,EAEL,KAAK,cAAc,EAEpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAA2B,KAAK,eAAe,EAAE,MAAM,UAAU,CAAC;AAUzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AA2GxD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAE/C,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,MAAM,EAAE,QAc9D;AAED,qBAAa,mBAAmB;IAC9B,MAAM,CAAC,KAAK,SAAiB;IAE7B,cAAc,EAAE,cAAc,CAAM;IACpC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAM;IAC7C,0FAA0F;IAC1F,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAM;IACnD,aAAa,EAAE,aAAa,CAAM;IAClC,iBAAiB,EAAE,MAAM,EAAE,CAAM;IACjC,IAAI,EAAE,GAAG,CAAQ;IACjB;;;;;;;OAOG;IACH,OAAO,CAAC,aAAa,CAAgC;IAErD;;;;;;;;;OASG;IACH,OAAO,CAAC,YAAY,CAGhB;IAEJ,OAAO,CAAC,QAAQ,CAAC,KAAK,CAKpB;IAEF,8CAA8C;IAC9C,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;gBAEvB,MAAM,EAAE,eAAe;IA2B7B,YAAY,CAAC,GAAG,EAAE,WAAW;IAanC;;;;;;;;;;OAUG;IACH,OAAO,CAAC,cAAc;IAatB,0BAA0B;IAC1B,OAAO,CAAC,kBAAkB;YA0CZ,MAAM;IA6Xd,iBAAiB,CAAC,GAAG,EAAE,OAAO,gCA1SZ;QACpB,SAAS,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAC3C,aAAa,EAAE,GAAG,CAAC;QACnB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;QAC5B,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACtC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC3B;;;;WAIG;QACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAClC;;;;;;;;;;;WAWG;QACH,WAAW,CAAC,EAAE;YAAE,MAAM,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,EAAE,CAAA;SAAE,CAAC;QACpD;;;WAGG;QACH,qBAAqB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;KAClD;CAqoBJ"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DictionarySink, DictionaryUse } from "../../i18n/dictionarySink";
|
|
1
2
|
import type { ServerQueryEntry, ServerQueryStore } from "./ServerQueryStore";
|
|
2
3
|
/**
|
|
3
4
|
* `</script>`-safe (and `<!--`-safe) JSON for inlining into an HTML script
|
|
@@ -6,6 +7,13 @@ import type { ServerQueryEntry, ServerQueryStore } from "./ServerQueryStore";
|
|
|
6
7
|
*/
|
|
7
8
|
export declare function htmlSafeJson(value: unknown): string;
|
|
8
9
|
export declare function queryPayloadScript(entry: ServerQueryEntry): string;
|
|
10
|
+
/**
|
|
11
|
+
* The same trick for a `defineDictionary` dictionary a segment just rendered
|
|
12
|
+
* with. It rides the same queue as query payloads, so it lands ahead of the
|
|
13
|
+
* reveal chunk for the segment that used it and hydration never re-fetches
|
|
14
|
+
* strings the document already carries.
|
|
15
|
+
*/
|
|
16
|
+
export declare function dictionaryPayloadScript(use: DictionaryUse): string;
|
|
9
17
|
/**
|
|
10
18
|
* The injector sits at the end of the response pipe, so it is the one place
|
|
11
19
|
* that knows when the body's first byte goes out and when the body actually
|
|
@@ -52,6 +60,6 @@ export interface StreamLifecycleHooks {
|
|
|
52
60
|
* begins can't push a script in front of `<!doctype html>`. (Those are
|
|
53
61
|
* normally in the `__GEMI_DATA__` snapshot anyway and skipped here.)
|
|
54
62
|
*/
|
|
55
|
-
export declare function injectQueryPayloads(source: ReadableStream<Uint8Array>, store: ServerQueryStore, hooks?: StreamLifecycleHooks): ReadableStream<Uint8Array>;
|
|
63
|
+
export declare function injectQueryPayloads(source: ReadableStream<Uint8Array>, store: ServerQueryStore, hooks?: StreamLifecycleHooks, dictionaries?: DictionarySink): ReadableStream<Uint8Array>;
|
|
56
64
|
export declare function isBotUserAgent(userAgent: string | null): boolean;
|
|
57
65
|
//# sourceMappingURL=streamQueryInjection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamQueryInjection.d.ts","sourceRoot":"","sources":["../../../services/router/streamQueryInjection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE7E;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAKnD;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAKlE;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,EAClC,KAAK,EAAE,gBAAgB,EACvB,KAAK,GAAE,oBAAyB,
|
|
1
|
+
{"version":3,"file":"streamQueryInjection.d.ts","sourceRoot":"","sources":["../../../services/router/streamQueryInjection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE7E;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAKnD;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAKlE;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAGlE;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,EAClC,KAAK,EAAE,gBAAgB,EACvB,KAAK,GAAE,oBAAyB,EAChC,YAAY,CAAC,EAAE,cAAc,GAC5B,cAAc,CAAC,UAAU,CAAC,CA4E5B;AAUD,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAGhE"}
|
package/dist/support/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Fb as S,Gb as U,Hb as V,Ib as W}from"../chunk-xxw0gz4q.js";import{Lb as Y}from"../chunk-n1tkn8gv.js";import{Se as R}from"../chunk-g5tj10p8.js";import{_e as F,af as q}from"../chunk-w6gb9gc5.js";import"../chunk-6j1z2cqt.js";import"../chunk-7f5ad759.js";class v{static token;async boot(){}static inject(){if(!this.token)throw Error(`Service [${this.name}] does not declare a \`static token\`, so the container has no key to resolve it by.`);try{return q(this)}catch(x){throw Error(`Could not inject [${this.name}]. Services are constructed when the kernel boots, so `+"inject() only works from code that runs after that \u2014 a constructor default or a method "+`body, never module top level. Check that [${this.name}] is listed in \`services\` on your Kernel.`,{cause:x})}}static with(x){let f=new this;for(let[C,g]of Object.entries(x))if(g!==void 0)f[C]=g;return f}}import{readdir as H}from"fs/promises";import{join as J,parse as z}from"path";var L=[".ts",".tsx",".js",".mjs",".jsx"];function M(x={}){let f={};for(let[C,g]of Object.entries(x))f[C]=B(g);return new F(f)}async function Q(x,f=new F){let C=[];try{C=await H(x)}catch(D){return f}let g=C.filter((D)=>{let{ext:P,name:j}=z(D);return L.includes(P)&&!j.startsWith(".")}).sort();for(let D of g){let{name:P}=z(D),j=await import(J(x,D));f.set(P,B(j))}return f}function B(x){if(x&&typeof x==="object"&&"default"in x)return x.default;return x}export{R as withDefaults,S as sourceFiles,W as projectRoot,Q as loadConfigFrom,V as discoverClasses,M as createConfigRepository,Y as ServiceProvider,v as Service,F as Repository,U as DiscoveryError};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
4
|
+
//# debugId=EB864E0AAF5EC59B64756E2164756E21
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
"import { readdir } from \"node:fs/promises\";\nimport { join, parse } from \"node:path\";\n\nimport { Repository } from \"./Repository\";\n\nconst CONFIG_EXTENSIONS = [\".ts\", \".tsx\", \".js\", \".mjs\", \".jsx\"];\n\n// Builds a Repository from an already-imported map of config modules. The map\n// key becomes the top-level config key, so `{ mail: mailModule }` is readable\n// as `config.get(\"mail.driver\")`. Each entry may be either the module namespace\n// (its `default` export is unwrapped) or the config object itself.\nexport function createConfigRepository(\n modules: Record<string, any> = {},\n): Repository {\n const items: Record<string, any> = {};\n\n for (const [key, mod] of Object.entries(modules)) {\n items[key] = unwrap(mod);\n }\n\n return new Repository(items);\n}\n\n// Reads every config module in an app's `app/config` directory into a\n// Repository. The file's basename is the top-level key: `app/config/mail.ts`\n// populates `mail.*`. A missing directory yields an empty Repository so apps\n// that declare no config still boot.\nexport async function loadConfigFrom(\n directory: string,\n repository = new Repository(),\n): Promise<Repository> {\n let entries: string[] = [];\n\n try {\n entries = await readdir(directory);\n } catch (err) {\n return repository;\n }\n\n const files = entries\n .filter((entry) => {\n const { ext, name } = parse(entry);\n return CONFIG_EXTENSIONS.includes(ext) && !name.startsWith(\".\");\n })\n .sort();\n\n for (const file of files) {\n const { name } = parse(file);\n const mod = await import(join(directory, file));\n repository.set(name, unwrap(mod));\n }\n\n return repository;\n}\n\nfunction unwrap(mod: any) {\n if (mod && typeof mod === \"object\" && \"default\" in mod) {\n return mod.default;\n }\n return mod;\n}\n"
|
|
7
7
|
],
|
|
8
8
|
"mappings": ";2RAgCO,CAAe,JAAQ,EAOrB,OAMD,AAAI,EAAkB,QAmBrB,OAAS,EAKX,CACH,GAAI,CAAC,KAAK,MACR,MAAU,MACR,YAAY,KAAK,0FACnB,EAGF,GAAI,CACF,OAAO,EAAI,IAAuB,EAClC,MAAO,EAAO,CACd,MAAU,MACR,qBAAqB,KAAK,6DACxB,+FACA,6CAA6C,KAAK,kDAEpD,CAAE,OAAM,CACV,SAoBG,KAAuB,CAAoB,EAA0B,CAC1E,IAAM,EAAW,IAAI,KACrB,QAAY,EAAK,KAAU,OAAO,QAAQ,CAAS,EACjD,GAAI,IAAU,OAAW,EAAS,GAAO,EAE3C,OAAO,EAEX,CChHA,kBAAS,oBACT,eAAS,WAAM,aAIf,IAAM,EAAoB,CAAC,MAAO,OAAQ,MAAO,OAAQ,MAAM,EAMxD,SAAS,CAAsB,CACpC,EAA+B,CAAC,EACpB,CACZ,IAAM,EAA6B,CAAC,EAEpC,QAAY,EAAK,KAAQ,OAAO,QAAQ,CAAO,EAC7C,EAAM,GAAO,EAAO,CAAG,EAGzB,OAAO,IAAI,EAAW,CAAK,EAO7B,eAAsB,CAAc,CAClC,EACA,EAAa,IAAI,EACI,CACrB,IAAI,EAAoB,CAAC,EAEzB,GAAI,CACF,EAAU,MAAM,EAAQ,CAAS,EACjC,MAAO,EAAK,CACZ,OAAO,EAGT,IAAM,EAAQ,EACX,OAAO,CAAC,IAAU,CACjB,IAAQ,MAAK,QAAS,EAAM,CAAK,EACjC,OAAO,EAAkB,SAAS,CAAG,GAAK,CAAC,EAAK,WAAW,GAAG,EAC/D,EACA,KAAK,EAER,QAAW,KAAQ,EAAO,CACxB,IAAQ,QAAS,EAAM,CAAI,EACrB,EAAM,MAAa,SAAK,EAAW,CAAI,GAC7C,EAAW,IAAI,EAAM,EAAO,CAAG,CAAC,EAGlC,OAAO,EAGT,SAAS,CAAM,CAAC,EAAU,CACxB,GAAI,GAAO,OAAO,IAAQ,UAAY,YAAa,EACjD,OAAO,EAAI,QAEb,OAAO",
|
|
9
|
-
"debugId": "
|
|
9
|
+
"debugId": "EB864E0AAF5EC59B64756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { type ComponentType, type PropsWithChildren, type ReactNode } from "react";
|
|
2
|
+
import { type FallbackProps } from "react-error-boundary";
|
|
3
|
+
import type { User } from "../auth/types";
|
|
4
|
+
import { type QueryConfig } from "../client/QueryManagerContext";
|
|
5
|
+
import type { Breadcrumb } from "../client/useBreadcrumbs";
|
|
6
|
+
/**
|
|
7
|
+
* A dictionary as `Dictionary.create` produces it: a name and a
|
|
8
|
+
* `{ key: { locale: string } }` map.
|
|
9
|
+
*
|
|
10
|
+
* Typed structurally rather than as `Dictionary<T>` for two reasons. It keeps
|
|
11
|
+
* `gemi/testing` from importing `gemi/i18n` — a server entry, which reaches the
|
|
12
|
+
* `Lang` facade and through it the container. And it means an object literal of
|
|
13
|
+
* the same shape is accepted, so a test never *has* to import the app's
|
|
14
|
+
* dictionaries at all.
|
|
15
|
+
*
|
|
16
|
+
* Only `name` and `dictionary` are read — both plain data. `Dictionary`'s
|
|
17
|
+
* server-only methods (`render`, `reference`, which throw once `window` is
|
|
18
|
+
* defined) are never called from here.
|
|
19
|
+
*/
|
|
20
|
+
export interface PageDictionary {
|
|
21
|
+
name: string;
|
|
22
|
+
dictionary: Record<string, Record<string, string>>;
|
|
23
|
+
}
|
|
24
|
+
export interface PageProps {
|
|
25
|
+
/**
|
|
26
|
+
* The URL the view is mounted at. A template (`/app/:orgId/chat`) is resolved
|
|
27
|
+
* against `params`, so the same string can be pasted from the router.
|
|
28
|
+
*/
|
|
29
|
+
pathname?: string;
|
|
30
|
+
/** Route params, as the router would have parsed them out of `pathname`. */
|
|
31
|
+
params?: Record<string, string>;
|
|
32
|
+
/** `"?tab=recent"`, `"tab=recent"`, or `{ tab: "recent" }`. */
|
|
33
|
+
searchParams?: string | Record<string, string | number | boolean>;
|
|
34
|
+
hash?: string;
|
|
35
|
+
/** The locale `useTranslator` and `useLocale` report. */
|
|
36
|
+
locale?: string;
|
|
37
|
+
/**
|
|
38
|
+
* The app's default locale. Links and `useNavigate` omit the locale segment
|
|
39
|
+
* for it, so leaving this equal to `locale` (the default) keeps hrefs
|
|
40
|
+
* unprefixed — set it to seed a page being viewed in a non-default locale.
|
|
41
|
+
*/
|
|
42
|
+
defaultLocale?: string;
|
|
43
|
+
supportedLocales?: string[];
|
|
44
|
+
/**
|
|
45
|
+
* Dictionaries the components under test translate against — the app's own,
|
|
46
|
+
* or literals of the same shape.
|
|
47
|
+
*
|
|
48
|
+
* Note what importing the app's costs: `app/i18n/index.ts` imports
|
|
49
|
+
* `gemi/i18n`, a server entry, so the test file pulls the container and
|
|
50
|
+
* `node:async_hooks` into its module graph. Nothing there runs (and nothing
|
|
51
|
+
* here calls it), so it is fine under any runner that has Node builtins —
|
|
52
|
+
* vitest, `bun test` — and not under one that renders in a real browser. Use
|
|
53
|
+
* `translations` there, which is the shape the client actually receives.
|
|
54
|
+
*/
|
|
55
|
+
dictionaries?: PageDictionary[];
|
|
56
|
+
/**
|
|
57
|
+
* Translations for the current locale, already resolved: dictionary name →
|
|
58
|
+
* key → string. This is the shape the server serializes onto the page, so it
|
|
59
|
+
* is what the client reads at runtime — and it imports nothing.
|
|
60
|
+
*
|
|
61
|
+
* ```tsx
|
|
62
|
+
* <Page translations={{ Chat: { greeting: "Hello {{name}}" } }}>
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* Merged over `dictionaries`, so the two compose: seed from the app's real
|
|
66
|
+
* dictionary and override the one key a test is about.
|
|
67
|
+
*/
|
|
68
|
+
translations?: Record<string, Record<string, string>>;
|
|
69
|
+
/**
|
|
70
|
+
* Data `useQuery` finds already cached, keyed by API path — the path passed
|
|
71
|
+
* to `useQuery`, without the `/api` prefix the client adds when it fetches.
|
|
72
|
+
* A key may carry a query string (`"/lists?page=2"`) to seed one search
|
|
73
|
+
* variant.
|
|
74
|
+
*
|
|
75
|
+
* The cache is keyed by the *resolved* path, so a key's `:params` are
|
|
76
|
+
* resolved against the page's `params` — and a key naming one the page does
|
|
77
|
+
* not carry is an error, naming the key. That case is common enough to be
|
|
78
|
+
* worth the loud failure: a query often takes its params from the call site
|
|
79
|
+
* rather than the route (`useQuery("/orgs/:orgId/lists", { params: { orgId } })`
|
|
80
|
+
* with `orgId` in component state), and the right seed for it is the resolved
|
|
81
|
+
* path, `"/orgs/abc/lists"`.
|
|
82
|
+
*
|
|
83
|
+
* Seeded at mount only: a component that mutates or refetches its data owns
|
|
84
|
+
* the cache from then on.
|
|
85
|
+
*/
|
|
86
|
+
queryData?: Record<string, unknown>;
|
|
87
|
+
/** App-wide `useQuery` defaults, as `createRoot` threads them. */
|
|
88
|
+
queryConfig?: QueryConfig;
|
|
89
|
+
/**
|
|
90
|
+
* What `useUser()` reports. Defaults to `null` — an anonymous visitor — and
|
|
91
|
+
* either way the hook resolves from here without issuing a request.
|
|
92
|
+
*/
|
|
93
|
+
user?: Partial<User> | null;
|
|
94
|
+
/** What `useBreadcrumbs()` returns, in order. */
|
|
95
|
+
breadcrumbs?: Breadcrumb[];
|
|
96
|
+
/**
|
|
97
|
+
* The theme `useTheme()` starts on. The app reads a visitor's stored choice
|
|
98
|
+
* out of `localStorage`; a test has no session to have made one in, so this
|
|
99
|
+
* seeds it without writing to storage. `setTheme` works from either.
|
|
100
|
+
*/
|
|
101
|
+
theme?: "light" | "dark" | "system";
|
|
102
|
+
/**
|
|
103
|
+
* Fallback for the `Suspense` boundary wrapped around the children — the
|
|
104
|
+
* stand-in for the view's own `Loading` export, which the real router
|
|
105
|
+
* supplies. Defaults to `null`.
|
|
106
|
+
*/
|
|
107
|
+
fallback?: ReactNode;
|
|
108
|
+
/**
|
|
109
|
+
* Renders in place of the children when one throws, mirroring a view's
|
|
110
|
+
* `Error` export. Without it a thrown render (an errored suspense query,
|
|
111
|
+
* say) propagates out of `render()` and fails the test, which is usually
|
|
112
|
+
* what you want.
|
|
113
|
+
*/
|
|
114
|
+
errorFallback?: ComponentType<FallbackProps>;
|
|
115
|
+
/**
|
|
116
|
+
* Called when something navigates — a `Link` click, `useNavigate().push`.
|
|
117
|
+
* The navigation is reported, not performed: `<Page>` renders one route and
|
|
118
|
+
* does not re-resolve the tree, so `useLocation()` keeps reporting the
|
|
119
|
+
* pathname it was given.
|
|
120
|
+
*/
|
|
121
|
+
onNavigate?: (href: string, action: "push" | "replace") => void;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Mounts a component with the inputs a view normally arrives with — route
|
|
125
|
+
* params, the current locale and its dictionaries, prefetched query data, the
|
|
126
|
+
* signed-in user — so a unit test can assert what it renders rather than only
|
|
127
|
+
* its empty state.
|
|
128
|
+
*
|
|
129
|
+
* ```tsx
|
|
130
|
+
* import { render, screen } from "@testing-library/react";
|
|
131
|
+
* import { Page } from "gemi/testing";
|
|
132
|
+
*
|
|
133
|
+
* render(
|
|
134
|
+
* <Page
|
|
135
|
+
* pathname="/app/:orgId/chat"
|
|
136
|
+
* params={{ orgId: "abc" }}
|
|
137
|
+
* queryData={{ "/organizations/:orgId/messages": [{ id: 1, body: "hi" }] }}
|
|
138
|
+
* dictionaries={[ChatDictionary]}
|
|
139
|
+
* >
|
|
140
|
+
* <OrgChat />
|
|
141
|
+
* </Page>,
|
|
142
|
+
* );
|
|
143
|
+
*
|
|
144
|
+
* expect(screen.getByText("hi")).toBeDefined();
|
|
145
|
+
* ```
|
|
146
|
+
*
|
|
147
|
+
* It is a plain component, so it composes with any renderer — Testing
|
|
148
|
+
* Library's `render`, `react-test-renderer`, or `renderToString`.
|
|
149
|
+
*
|
|
150
|
+
* Two things it does not do.
|
|
151
|
+
*
|
|
152
|
+
* It does not route: there is no view tree and no route manifest behind it, so
|
|
153
|
+
* a navigation is reported through `onNavigate` rather than resolved. To
|
|
154
|
+
* assert the page *after* one, render a second `<Page>`.
|
|
155
|
+
*
|
|
156
|
+
* And under `renderToString` it renders the server's own no-data branch for an
|
|
157
|
+
* *unseeded* query rather than suspending — deliberately, because suspending
|
|
158
|
+
* there is the streaming server's job: `createRoot` threads the request's
|
|
159
|
+
* `ServerQueryStore` through `ServerQueryContext`, and that store is what runs
|
|
160
|
+
* the route handler. A harness has no request and no handler to run, so there
|
|
161
|
+
* is nothing to suspend on. Seeded queries render their data on the server
|
|
162
|
+
* exactly as they do in the browser; unseeded ones behave as a route with no
|
|
163
|
+
* `Query.prefetch` does, framework warning included.
|
|
164
|
+
*/
|
|
165
|
+
export declare const Page: (props: PropsWithChildren<PageProps>) => import("react/jsx-runtime").JSX.Element;
|
|
166
|
+
//# sourceMappingURL=Page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Page.d.ts","sourceRoot":"","sources":["../../testing/Page.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGzE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAI1C,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,+BAA+B,CAAC;AAYvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAM3D;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACpD;AAED,MAAM,WAAW,SAAS;IACxB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4EAA4E;IAC5E,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,+DAA+D;IAC/D,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;IAClE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B;;;;;;;;;;OAUG;IACH,YAAY,CAAC,EAAE,cAAc,EAAE,CAAC;IAChC;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACtD;;;;;;;;;;;;;;;;OAgBG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,kEAAkE;IAClE,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC5B,iDAAiD;IACjD,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;IACpC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;IAC7C;;;;;OAKG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;CACjE;AA6ID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,eAAO,MAAM,IAAI,GAAI,OAAO,iBAAiB,CAAC,SAAS,CAAC,4CA4PvD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { A as createMemoryHistory, F as applyParams, L as QueryManagerContext, N as RouteStateProvider, O as ProgressManager, P as toVariantKey, R as QueryManagerProvider, T as ServerDataContext, V as Subject, a as m, c as ClientRouterContext, k as Action, o as RouteTransitionProvider, r as WebSocketContext, t as ThemeProvider, w as I18nProvider } from "../chunks/ThemeProvider-Bk1eZymb.js";
|
|
2
|
+
import { Suspense, useContext, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region testing/Page.tsx
|
|
5
|
+
/** `"?a=b"` (or `""`) from any of the shapes `searchParams` accepts. */
|
|
6
|
+
function toSearchString(search) {
|
|
7
|
+
if (!search) return "";
|
|
8
|
+
const query = typeof search === "string" ? search.replace(/^\?/, "") : new URLSearchParams(Object.entries(search).map(([key, value]) => [key, String(value)])).toString();
|
|
9
|
+
return query ? `?${query}` : "";
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The `:params` a seed key needs supplied. Wildcards (`:rest*`) are excluded —
|
|
13
|
+
* `applyParams` drops those when missing, which is a resolution rather than a
|
|
14
|
+
* failure.
|
|
15
|
+
*
|
|
16
|
+
* Optional params (`:id?`) cannot reach here at all: a key is split at its
|
|
17
|
+
* first `?` to separate the search string, so `"/lists/:folderId?"` arrives as
|
|
18
|
+
* the path `/lists/:folderId`. Seed the resolved path for those.
|
|
19
|
+
*/
|
|
20
|
+
function requiredParamsOf(path) {
|
|
21
|
+
return Array.from(path.matchAll(/:([^/]+)/g), ([, name]) => name).filter((name) => !name.endsWith("*"));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Fails a `queryData` key whose `:params` the page does not carry, saying so
|
|
25
|
+
* in terms of the key.
|
|
26
|
+
*
|
|
27
|
+
* Without this the two documented runners disagree, and neither is legible.
|
|
28
|
+
* `applyParams` throws `Missing parameter: orgId` under `import.meta.env.DEV`
|
|
29
|
+
* (vitest) — a router-utility stack trace out of `<Page>`'s render, before
|
|
30
|
+
* anything mounts, naming nothing that appears in the test. Under `bun test`
|
|
31
|
+
* that flag is falsy, so it logs and seeds the literal `/orgs/undefined/lists`
|
|
32
|
+
* instead: the seed misses, the query goes to the network, and the assertion
|
|
33
|
+
* runs against a loading state.
|
|
34
|
+
*
|
|
35
|
+
* The case is common because a query's params often come from the call site
|
|
36
|
+
* rather than the route — `useQuery("/orgs/:orgId/lists", { params: { orgId } })`
|
|
37
|
+
* with `orgId` in component state. The cache is keyed by the *resolved* path,
|
|
38
|
+
* so the way out is to seed that path directly.
|
|
39
|
+
*/
|
|
40
|
+
function resolveSeedPath(key, rawPath, params) {
|
|
41
|
+
const missing = requiredParamsOf(rawPath).filter((name) => params[name] === void 0);
|
|
42
|
+
if (missing.length > 0) throw new Error(`[gemi] <Page> cannot resolve the queryData key "${key}": no value for ${missing.map((name) => `:${name}`).join(", ")}. The query cache is keyed by the resolved path, so either add ${missing.map((name) => `\`${name}\``).join(", ")} to the page's \`params\`, or seed the resolved path (e.g. "${applyParams(rawPath, Object.fromEntries(missing.map((name) => [name, "123"])))}") — which is what a query taking its params from component state reads under.`);
|
|
43
|
+
return applyParams(rawPath, params);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* `queryData` in the shape the query cache seeds from: `{ [path]: { [variant]:
|
|
47
|
+
* data } }`, the same payload `Query.prefetch` puts on a server-rendered page.
|
|
48
|
+
*/
|
|
49
|
+
function toPrefetchedData(queryData, params, warned) {
|
|
50
|
+
const prefetchedData = {};
|
|
51
|
+
for (const [key, data] of Object.entries(queryData)) {
|
|
52
|
+
const [rawPath, rawSearch = ""] = key.split("?");
|
|
53
|
+
if (rawPath.startsWith("/api/") && !warned.has(key)) {
|
|
54
|
+
warned.add(key);
|
|
55
|
+
console.warn(`[gemi] queryData key "${key}" starts with /api. useQuery is keyed by the path you pass it — the /api prefix is added when it fetches — so this entry seeds a path no query reads.`);
|
|
56
|
+
}
|
|
57
|
+
const path = resolveSeedPath(key, rawPath, params);
|
|
58
|
+
prefetchedData[path] = {
|
|
59
|
+
...prefetchedData[path],
|
|
60
|
+
[toVariantKey(rawSearch)]: data
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return prefetchedData;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* `{ [locale]: { [dictionary]: { [key]: string } } }` — the payload
|
|
67
|
+
* `Translator` serializes onto the page, which is the only form the client
|
|
68
|
+
* ever sees. `dictionaries` are transposed into it (they are keyed the other
|
|
69
|
+
* way round, by key then locale); `translations` is already in it and lands
|
|
70
|
+
* under `locale`, last, so it wins.
|
|
71
|
+
*/
|
|
72
|
+
function toClientDictionary(dictionaries, locales, locale, translations) {
|
|
73
|
+
const clientDictionary = {};
|
|
74
|
+
for (const supported of locales) clientDictionary[supported] ??= {};
|
|
75
|
+
for (const { name, dictionary } of dictionaries) for (const [key, byLocale] of Object.entries(dictionary ?? {})) for (const [dictLocale, translation] of Object.entries(byLocale ?? {})) {
|
|
76
|
+
clientDictionary[dictLocale] ??= {};
|
|
77
|
+
clientDictionary[dictLocale][name] ??= {};
|
|
78
|
+
clientDictionary[dictLocale][name][key] = translation;
|
|
79
|
+
}
|
|
80
|
+
for (const [name, keys] of Object.entries(translations)) {
|
|
81
|
+
clientDictionary[locale] ??= {};
|
|
82
|
+
clientDictionary[locale][name] = {
|
|
83
|
+
...clientDictionary[locale][name],
|
|
84
|
+
...keys
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return clientDictionary;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Mounts a component with the inputs a view normally arrives with — route
|
|
91
|
+
* params, the current locale and its dictionaries, prefetched query data, the
|
|
92
|
+
* signed-in user — so a unit test can assert what it renders rather than only
|
|
93
|
+
* its empty state.
|
|
94
|
+
*
|
|
95
|
+
* ```tsx
|
|
96
|
+
* import { render, screen } from "@testing-library/react";
|
|
97
|
+
* import { Page } from "gemi/testing";
|
|
98
|
+
*
|
|
99
|
+
* render(
|
|
100
|
+
* <Page
|
|
101
|
+
* pathname="/app/:orgId/chat"
|
|
102
|
+
* params={{ orgId: "abc" }}
|
|
103
|
+
* queryData={{ "/organizations/:orgId/messages": [{ id: 1, body: "hi" }] }}
|
|
104
|
+
* dictionaries={[ChatDictionary]}
|
|
105
|
+
* >
|
|
106
|
+
* <OrgChat />
|
|
107
|
+
* </Page>,
|
|
108
|
+
* );
|
|
109
|
+
*
|
|
110
|
+
* expect(screen.getByText("hi")).toBeDefined();
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
113
|
+
* It is a plain component, so it composes with any renderer — Testing
|
|
114
|
+
* Library's `render`, `react-test-renderer`, or `renderToString`.
|
|
115
|
+
*
|
|
116
|
+
* Two things it does not do.
|
|
117
|
+
*
|
|
118
|
+
* It does not route: there is no view tree and no route manifest behind it, so
|
|
119
|
+
* a navigation is reported through `onNavigate` rather than resolved. To
|
|
120
|
+
* assert the page *after* one, render a second `<Page>`.
|
|
121
|
+
*
|
|
122
|
+
* And under `renderToString` it renders the server's own no-data branch for an
|
|
123
|
+
* *unseeded* query rather than suspending — deliberately, because suspending
|
|
124
|
+
* there is the streaming server's job: `createRoot` threads the request's
|
|
125
|
+
* `ServerQueryStore` through `ServerQueryContext`, and that store is what runs
|
|
126
|
+
* the route handler. A harness has no request and no handler to run, so there
|
|
127
|
+
* is nothing to suspend on. Seeded queries render their data on the server
|
|
128
|
+
* exactly as they do in the browser; unseeded ones behave as a route with no
|
|
129
|
+
* `Query.prefetch` does, framework warning included.
|
|
130
|
+
*/
|
|
131
|
+
var Page = (props) => {
|
|
132
|
+
const { children, pathname: routePath = "/", params = {}, searchParams, hash = "", locale = "en-US", defaultLocale = locale, dictionaries = [], translations = {}, queryData = {}, queryConfig, user = null, breadcrumbs = [], theme, fallback = null, errorFallback, onNavigate } = props;
|
|
133
|
+
const supportedLocales = useMemo(() => Array.from(/* @__PURE__ */ new Set([
|
|
134
|
+
...props.supportedLocales ?? [],
|
|
135
|
+
defaultLocale,
|
|
136
|
+
locale
|
|
137
|
+
])), [
|
|
138
|
+
props.supportedLocales,
|
|
139
|
+
defaultLocale,
|
|
140
|
+
locale
|
|
141
|
+
]);
|
|
142
|
+
const pathname = applyParams(routePath, params) || "/";
|
|
143
|
+
const search = toSearchString(searchParams);
|
|
144
|
+
const urlLocaleSegment = locale === defaultLocale ? null : locale;
|
|
145
|
+
const dictionary = useMemo(() => toClientDictionary(dictionaries, supportedLocales, locale, translations), [
|
|
146
|
+
dictionaries,
|
|
147
|
+
supportedLocales,
|
|
148
|
+
locale,
|
|
149
|
+
translations
|
|
150
|
+
]);
|
|
151
|
+
const warnedRef = useRef(/* @__PURE__ */ new Set());
|
|
152
|
+
const prefetchedData = useMemo(() => {
|
|
153
|
+
const seeded = toPrefetchedData(queryData, params, warnedRef.current);
|
|
154
|
+
seeded["/auth/me"] ??= { "": user ?? null };
|
|
155
|
+
return seeded;
|
|
156
|
+
}, [
|
|
157
|
+
queryData,
|
|
158
|
+
params,
|
|
159
|
+
user
|
|
160
|
+
]);
|
|
161
|
+
const { breadcrumbViews, breadcrumbsCache, breadcrumbsRecord } = useMemo(() => {
|
|
162
|
+
const views = breadcrumbs.map((_, index) => `breadcrumb-${index}`);
|
|
163
|
+
const cache = new Map(breadcrumbs.map((breadcrumb, index) => [`${views[index]}:${pathname}`, breadcrumb]));
|
|
164
|
+
return {
|
|
165
|
+
breadcrumbViews: views,
|
|
166
|
+
breadcrumbsCache: cache,
|
|
167
|
+
breadcrumbsRecord: Object.fromEntries(cache)
|
|
168
|
+
};
|
|
169
|
+
}, [breadcrumbs, pathname]);
|
|
170
|
+
const [isNavigatingSubject] = useState(() => new Subject(false));
|
|
171
|
+
const [progressManager] = useState(() => new ProgressManager(isNavigatingSubject));
|
|
172
|
+
const [history] = useState(() => createMemoryHistory({ initialEntries: [`${pathname}${search}${hash}`] }));
|
|
173
|
+
const routeState = useMemo(() => ({
|
|
174
|
+
views: [],
|
|
175
|
+
params,
|
|
176
|
+
search,
|
|
177
|
+
state: {},
|
|
178
|
+
pathname,
|
|
179
|
+
hash,
|
|
180
|
+
action: null,
|
|
181
|
+
routePath,
|
|
182
|
+
locale: urlLocaleSegment,
|
|
183
|
+
data: {},
|
|
184
|
+
i18n: {
|
|
185
|
+
currentLocale: locale,
|
|
186
|
+
dictionary,
|
|
187
|
+
supportedLocales
|
|
188
|
+
},
|
|
189
|
+
prefetchedData,
|
|
190
|
+
breadcrumbs: breadcrumbsRecord,
|
|
191
|
+
appId: "test"
|
|
192
|
+
}), [
|
|
193
|
+
params,
|
|
194
|
+
search,
|
|
195
|
+
pathname,
|
|
196
|
+
hash,
|
|
197
|
+
routePath,
|
|
198
|
+
urlLocaleSegment,
|
|
199
|
+
locale,
|
|
200
|
+
dictionary,
|
|
201
|
+
supportedLocales,
|
|
202
|
+
prefetchedData,
|
|
203
|
+
breadcrumbsRecord
|
|
204
|
+
]);
|
|
205
|
+
const [routerSubject] = useState(() => new Subject(routeState));
|
|
206
|
+
const onNavigateRef = useRef(onNavigate);
|
|
207
|
+
onNavigateRef.current = onNavigate;
|
|
208
|
+
const listeningRef = useRef(false);
|
|
209
|
+
if (!listeningRef.current) {
|
|
210
|
+
listeningRef.current = true;
|
|
211
|
+
history.listen(({ location, action }) => {
|
|
212
|
+
const href = `${location.pathname}${location.search}${location.hash}`;
|
|
213
|
+
onNavigateRef.current?.(href, action === Action.Replace ? "replace" : "push");
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
const serverData = useMemo(() => ({
|
|
217
|
+
routeManifest: {},
|
|
218
|
+
pageData: {},
|
|
219
|
+
breadcrumbs: breadcrumbsRecord,
|
|
220
|
+
prefetchedData,
|
|
221
|
+
router: {
|
|
222
|
+
pathname,
|
|
223
|
+
params,
|
|
224
|
+
currentPath: routePath,
|
|
225
|
+
is404: false,
|
|
226
|
+
searchParams: search,
|
|
227
|
+
urlLocaleSegment
|
|
228
|
+
},
|
|
229
|
+
i18n: {
|
|
230
|
+
dictionary,
|
|
231
|
+
currentLocale: locale,
|
|
232
|
+
supportedLocales,
|
|
233
|
+
defaultLocale
|
|
234
|
+
},
|
|
235
|
+
componentTree: [],
|
|
236
|
+
auth: { user },
|
|
237
|
+
__csrf: "test-csrf-token",
|
|
238
|
+
cssManifest: {},
|
|
239
|
+
modulePreloadManifest: {},
|
|
240
|
+
meta: {},
|
|
241
|
+
appId: "test"
|
|
242
|
+
}), [
|
|
243
|
+
breadcrumbsRecord,
|
|
244
|
+
prefetchedData,
|
|
245
|
+
pathname,
|
|
246
|
+
params,
|
|
247
|
+
routePath,
|
|
248
|
+
search,
|
|
249
|
+
urlLocaleSegment,
|
|
250
|
+
dictionary,
|
|
251
|
+
locale,
|
|
252
|
+
supportedLocales,
|
|
253
|
+
defaultLocale,
|
|
254
|
+
user
|
|
255
|
+
]);
|
|
256
|
+
const [viewEntriesSubject] = useState(() => new Subject([]));
|
|
257
|
+
const routerContext = useMemo(() => ({
|
|
258
|
+
viewEntriesSubject,
|
|
259
|
+
history,
|
|
260
|
+
updatePageData: () => {},
|
|
261
|
+
getPageData: () => ({}),
|
|
262
|
+
getScrollPosition: () => 0,
|
|
263
|
+
getViewPathsFromPathname: () => breadcrumbViews,
|
|
264
|
+
getRoutePathnameFromHref: (href) => href,
|
|
265
|
+
isNavigatingSubject,
|
|
266
|
+
setNavigationAbortController: () => {},
|
|
267
|
+
progressManager,
|
|
268
|
+
fetchRouteCSS: async () => {},
|
|
269
|
+
preloadRouteModules: () => {},
|
|
270
|
+
prefetchRoute: async () => {},
|
|
271
|
+
takePrefetched: () => null,
|
|
272
|
+
clearPrefetchCache: () => {},
|
|
273
|
+
breadcrumbsCache,
|
|
274
|
+
routerSubject,
|
|
275
|
+
urlLocaleSegment
|
|
276
|
+
}), [
|
|
277
|
+
viewEntriesSubject,
|
|
278
|
+
history,
|
|
279
|
+
breadcrumbViews,
|
|
280
|
+
isNavigatingSubject,
|
|
281
|
+
progressManager,
|
|
282
|
+
breadcrumbsCache,
|
|
283
|
+
routerSubject,
|
|
284
|
+
urlLocaleSegment
|
|
285
|
+
]);
|
|
286
|
+
const [websocket] = useState(() => ({
|
|
287
|
+
subscribe: async () => {},
|
|
288
|
+
unsubscribe: async () => {},
|
|
289
|
+
broadcast: () => {}
|
|
290
|
+
}));
|
|
291
|
+
return /* @__PURE__ */ jsx(ThemeProvider, {
|
|
292
|
+
theme,
|
|
293
|
+
children: /* @__PURE__ */ jsx(ServerDataContext.Provider, {
|
|
294
|
+
value: serverData,
|
|
295
|
+
children: /* @__PURE__ */ jsx(I18nProvider, { children: /* @__PURE__ */ jsx(WebSocketContext.Provider, {
|
|
296
|
+
value: websocket,
|
|
297
|
+
children: /* @__PURE__ */ jsx(QueryManagerProvider, {
|
|
298
|
+
queryConfig,
|
|
299
|
+
children: /* @__PURE__ */ jsx(ClientRouterContext.Provider, {
|
|
300
|
+
value: routerContext,
|
|
301
|
+
children: /* @__PURE__ */ jsx(RouteTransitionProvider, {
|
|
302
|
+
isPending: false,
|
|
303
|
+
isFetching: false,
|
|
304
|
+
transitionPath: ["", pathname],
|
|
305
|
+
children: /* @__PURE__ */ jsx(RouteStateProvider, {
|
|
306
|
+
state: routeState,
|
|
307
|
+
children: /* @__PURE__ */ jsx(Boundary, {
|
|
308
|
+
errorFallback,
|
|
309
|
+
fallback,
|
|
310
|
+
resetKey: pathname,
|
|
311
|
+
children
|
|
312
|
+
})
|
|
313
|
+
})
|
|
314
|
+
})
|
|
315
|
+
})
|
|
316
|
+
})
|
|
317
|
+
}) })
|
|
318
|
+
})
|
|
319
|
+
});
|
|
320
|
+
};
|
|
321
|
+
/**
|
|
322
|
+
* The `Suspense` boundary every view renders inside, and — when the test
|
|
323
|
+
* supplies a fallback for it — the error boundary too.
|
|
324
|
+
*
|
|
325
|
+
* `onReset={clearErrors}` is the part that has to be here rather than inline
|
|
326
|
+
* above: it needs `QueryManagerContext`, and it is what makes a view's real
|
|
327
|
+
* `Error` export testable. A fallback whose "Try again" calls
|
|
328
|
+
* `resetErrorBoundary()` re-renders the child, and `useQuery` reads the
|
|
329
|
+
* failure still stored on the `QueryResource` and throws it straight back —
|
|
330
|
+
* so without this the fallback never goes away and the retry path that works
|
|
331
|
+
* in the app cannot be exercised. `ClientRouter`'s own boundary wires exactly
|
|
332
|
+
* this pair.
|
|
333
|
+
*/
|
|
334
|
+
var Boundary = (props) => {
|
|
335
|
+
const { errorFallback: ErrorFallback, fallback, resetKey, children } = props;
|
|
336
|
+
const { clearErrors } = useContext(QueryManagerContext);
|
|
337
|
+
const content = /* @__PURE__ */ jsx(Suspense, {
|
|
338
|
+
fallback,
|
|
339
|
+
children
|
|
340
|
+
});
|
|
341
|
+
if (!ErrorFallback) return content;
|
|
342
|
+
return /* @__PURE__ */ jsx(m, {
|
|
343
|
+
FallbackComponent: ErrorFallback,
|
|
344
|
+
resetKeys: [resetKey],
|
|
345
|
+
onReset: clearErrors,
|
|
346
|
+
children: content
|
|
347
|
+
});
|
|
348
|
+
};
|
|
349
|
+
//#endregion
|
|
350
|
+
export { Page };
|
|
351
|
+
|
|
352
|
+
//# sourceMappingURL=index.js.map
|