diff --git a/doccache.zst b/doccache.zst deleted file mode 100644 index d1f4c029..00000000 Binary files a/doccache.zst and /dev/null differ diff --git a/import_map.json b/import_map.json index 240da94c..c56ca257 100644 --- a/import_map.json +++ b/import_map.json @@ -1,9 +1,9 @@ { "imports": { "deco-sites/std/": "./", - "$live/": "https://denopkg.com/deco-cx/live@1.25.6/", + "$live/": "https://denopkg.com/deco-cx/live@1.29.2/", "partytown/": "https://deno.land/x/partytown@0.3.4/", - "$fresh/": "https://denopkg.com/deco-cx/fresh@1.3.3/", + "$fresh/": "https://denopkg.com/deco-cx/fresh@1.3.6/", "preact": "https://esm.sh/preact@10.15.1", "preact/": "https://esm.sh/preact@10.15.1/", "preact-render-to-string": "https://esm.sh/*preact-render-to-string@6.1.0", diff --git a/live.gen.ts b/live.gen.ts index 6b478d5d..b8191f58 100644 --- a/live.gen.ts +++ b/live.gen.ts @@ -64,8 +64,11 @@ import * as $$$24 from "./loaders/nuvemShop/nuvemShopProductList.ts"; import * as $$$25 from "./loaders/nuvemShop/nuvemShopProductListingPage.ts"; import * as $$$26 from "./loaders/x/image.ts"; import * as $$$27 from "./loaders/x/redirectsFromCsv.ts"; -import * as $$$28 from "./loaders/x/redirects.ts"; -import * as $$$29 from "./loaders/x/font.ts"; +import * as $$$28 from "./loaders/x/extension.ts"; +import * as $$$29 from "./loaders/x/redirects.ts"; +import * as $$$30 from "./loaders/x/font.ts"; +import * as $$$31 from "./loaders/x/productExt.ts"; +import * as $$$32 from "./loaders/x/productDetailsExt.ts"; import * as $$$$0 from "./routes/404.tsx"; import * as $$$$1 from "./routes/styles.css.ts"; import * as $$$$2 from "./routes/_app.tsx"; @@ -214,9 +217,12 @@ const manifest = { "deco-sites/std/loaders/vtex/proxy.ts": $$$11, "deco-sites/std/loaders/vtex/user.ts": $$$17, "deco-sites/std/loaders/vtex/wishlist.ts": $$$9, - "deco-sites/std/loaders/x/font.ts": $$$29, + "deco-sites/std/loaders/x/extension.ts": $$$28, + "deco-sites/std/loaders/x/font.ts": $$$30, "deco-sites/std/loaders/x/image.ts": $$$26, - "deco-sites/std/loaders/x/redirects.ts": $$$28, + "deco-sites/std/loaders/x/productDetailsExt.ts": $$$32, + "deco-sites/std/loaders/x/productExt.ts": $$$31, + "deco-sites/std/loaders/x/redirects.ts": $$$29, "deco-sites/std/loaders/x/redirectsFromCsv.ts": $$$27, }, "routes": { @@ -281,6 +287,7 @@ const manifest = { "deco-sites/std/actions/vtex/wishlist/addItem.ts": $$$$$$$$$$$15, "deco-sites/std/actions/vtex/wishlist/removeItem.ts": $$$$$$$$$$$14, }, + "name": "deco-sites/std", "pages": { "$live/pages/LivePage.tsx": i1$$$0, }, diff --git a/loaders/x/extension.ts b/loaders/x/extension.ts new file mode 100644 index 00000000..acd5be96 --- /dev/null +++ b/loaders/x/extension.ts @@ -0,0 +1,25 @@ +import { PromiseOrValue } from "$live/engine/core/utils.ts"; + +/** + * @title The type extension. + */ +export type ExtensionOf = (value: T) => PromiseOrValue; + +export interface Props { + /** + * @title Data + * @description Here comes your products or anything that can be extensible. + */ + data: T; + /** + * @title The data Extensions + */ + extensions: ExtensionOf[]; +} + +export default async function Extended( + { data, extensions }: Props, +): Promise { + await Promise.all(extensions.map((ext) => ext(data))); + return data; +} diff --git a/loaders/x/productDetailsExt.ts b/loaders/x/productDetailsExt.ts new file mode 100644 index 00000000..1df25ca6 --- /dev/null +++ b/loaders/x/productDetailsExt.ts @@ -0,0 +1,11 @@ +import { ProductDetailsPage } from "../../commerce/types.ts"; +import { default as extend, Props } from "./extension.ts"; + +/** + * @title Extend your products + */ +export default function ProductExt( + props: Props, +): Promise { + return extend(props); +} diff --git a/loaders/x/productExt.ts b/loaders/x/productExt.ts new file mode 100644 index 00000000..d05c3232 --- /dev/null +++ b/loaders/x/productExt.ts @@ -0,0 +1,11 @@ +import { Product } from "deco-sites/std/commerce/types.ts"; +import { default as extend, Props } from "./extension.ts"; + +/** + * @title Extend your products + */ +export default function ProductExt( + props: Props, +): Promise { + return extend(props); +}