@shop-on/theme-runtime 0.1.0 → 0.2.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/index.d.ts +4 -2
- package/dist/index.js +2 -1
- package/dist/product-variants/index.d.ts +2 -1
- package/dist/product-variants/index.js +2 -1
- package/dist/product-variants/stale-variant.d.ts +9 -0
- package/dist/product-variants/stale-variant.js +9 -0
- package/dist/template-types.d.ts +4 -0
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -12,12 +12,14 @@ import { isDefaultSingleVariant } from "./product-variants/is-default-single-var
|
|
|
12
12
|
import { isVariantSelectable } from "./product-variants/is-variant-selectable.js";
|
|
13
13
|
import { ResolvedVariant, resolveSelectedVariant } from "./product-variants/resolve-selected-variant.js";
|
|
14
14
|
import { selectionKey } from "./product-variants/selection-key.js";
|
|
15
|
+
import { ArticleSchemaSource, BlockInstance, BreadcrumbSchemaSource, ProductSchemaSource, SectionGroupConfig, TemplateJSON, TemplateSeoSource, WebsiteSchemaSource } from "./template-types.js";
|
|
16
|
+
import { staleVariantFlag } from "./product-variants/stale-variant.js";
|
|
15
17
|
import { SwatchSource, isSwatchOption, swatchSource } from "./product-variants/swatch-source.js";
|
|
16
18
|
import { VariantPriceRange, variantPriceRange } from "./product-variants/variant-price-range.js";
|
|
19
|
+
import "./product-variants/index.js";
|
|
17
20
|
import { productHref } from "./product-href.js";
|
|
18
21
|
import { isOnSale, savePercent } from "./sale.js";
|
|
19
22
|
import { BuildSeoHeadArgs, SEO_DESCRIPTION_MAX_LENGTH, SeoHead, buildSeoHead, canonicalPath, isNarrowedListing, truncateSeoDescription } from "./seo.js";
|
|
20
23
|
import { stripPostAuthParams } from "./strip-handoff-url.js";
|
|
21
|
-
import { ArticleSchemaSource, BlockInstance, BreadcrumbSchemaSource, ProductSchemaSource, SectionGroupConfig, TemplateJSON, TemplateSeoSource, WebsiteSchemaSource } from "./template-types.js";
|
|
22
24
|
import { thumbhashDataUrl } from "./thumbhash.js";
|
|
23
|
-
export { ArticleSchemaSource, BlockInstance, BreadcrumbSchemaSource, BuildSeoHeadArgs, Embed, EmbedKind, type LinkedMetafieldRef, type LinkedMetaobject, type LinkedMetaobjectField, Money, type OptionAvailability, PlayerEmbed, type ProductForVariantState, type ProductOption, type ProductOptionValue, ProductSchemaSource, type ProductVariant, type ResolvedVariant, SEO_DESCRIPTION_MAX_LENGTH, SectionGroupConfig, type SelectedOption, SeoHead, type SwatchSource, type SwatchVariant, TemplateJSON, TemplateSeoSource, type VariantPriceRange, type VariantState, WebsiteSchemaSource, buildAvailabilityIndex, buildSeoHead, buildVariantState, canonicalPath, currencySymbol, defaultPriceMaxBound, embedBackgroundSrc, escapeForScriptTag, findClosestVariant, formatMoney, formatMoneyWithCurrency, initials, isDefaultSingleVariant, isNarrowedListing, isOnSale, isSwatchOption, isVariantSelectable, pageCursor, parseEmbedUrl, productHref, resolveSelectedVariant, savePercent, selectionKey, stripPostAuthParams, swatchSource, thumbhashDataUrl, truncateSeoDescription, variantPriceRange };
|
|
25
|
+
export { ArticleSchemaSource, BlockInstance, BreadcrumbSchemaSource, BuildSeoHeadArgs, Embed, EmbedKind, type LinkedMetafieldRef, type LinkedMetaobject, type LinkedMetaobjectField, Money, type OptionAvailability, PlayerEmbed, type ProductForVariantState, type ProductOption, type ProductOptionValue, ProductSchemaSource, type ProductVariant, type ResolvedVariant, SEO_DESCRIPTION_MAX_LENGTH, SectionGroupConfig, type SelectedOption, SeoHead, type SwatchSource, type SwatchVariant, TemplateJSON, TemplateSeoSource, type VariantPriceRange, type VariantState, WebsiteSchemaSource, buildAvailabilityIndex, buildSeoHead, buildVariantState, canonicalPath, currencySymbol, defaultPriceMaxBound, embedBackgroundSrc, escapeForScriptTag, findClosestVariant, formatMoney, formatMoneyWithCurrency, initials, isDefaultSingleVariant, isNarrowedListing, isOnSale, isSwatchOption, isVariantSelectable, pageCursor, parseEmbedUrl, productHref, resolveSelectedVariant, savePercent, selectionKey, staleVariantFlag, stripPostAuthParams, swatchSource, thumbhashDataUrl, truncateSeoDescription, variantPriceRange };
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import { findClosestVariant } from "./product-variants/find-closest-variant.js";
|
|
|
11
11
|
import { isDefaultSingleVariant } from "./product-variants/is-default-single-variant.js";
|
|
12
12
|
import { isVariantSelectable } from "./product-variants/is-variant-selectable.js";
|
|
13
13
|
import { selectionKey } from "./product-variants/selection-key.js";
|
|
14
|
+
import { staleVariantFlag } from "./product-variants/stale-variant.js";
|
|
14
15
|
import { isSwatchOption, swatchSource } from "./product-variants/swatch-source.js";
|
|
15
16
|
import { variantPriceRange } from "./product-variants/variant-price-range.js";
|
|
16
17
|
import { productHref } from "./product-href.js";
|
|
@@ -18,4 +19,4 @@ import { isOnSale, savePercent } from "./sale.js";
|
|
|
18
19
|
import { SEO_DESCRIPTION_MAX_LENGTH, buildSeoHead, canonicalPath, isNarrowedListing, truncateSeoDescription } from "./seo.js";
|
|
19
20
|
import { stripPostAuthParams } from "./strip-handoff-url.js";
|
|
20
21
|
import { thumbhashDataUrl } from "./thumbhash.js";
|
|
21
|
-
export { SEO_DESCRIPTION_MAX_LENGTH, buildAvailabilityIndex, buildSeoHead, buildVariantState, canonicalPath, currencySymbol, defaultPriceMaxBound, embedBackgroundSrc, escapeForScriptTag, findClosestVariant, formatMoney, formatMoneyWithCurrency, initials, isDefaultSingleVariant, isNarrowedListing, isOnSale, isSwatchOption, isVariantSelectable, pageCursor, parseEmbedUrl, productHref, resolveSelectedVariant, savePercent, selectionKey, stripPostAuthParams, swatchSource, thumbhashDataUrl, truncateSeoDescription, variantPriceRange };
|
|
22
|
+
export { SEO_DESCRIPTION_MAX_LENGTH, buildAvailabilityIndex, buildSeoHead, buildVariantState, canonicalPath, currencySymbol, defaultPriceMaxBound, embedBackgroundSrc, escapeForScriptTag, findClosestVariant, formatMoney, formatMoneyWithCurrency, initials, isDefaultSingleVariant, isNarrowedListing, isOnSale, isSwatchOption, isVariantSelectable, pageCursor, parseEmbedUrl, productHref, resolveSelectedVariant, savePercent, selectionKey, staleVariantFlag, stripPostAuthParams, swatchSource, thumbhashDataUrl, truncateSeoDescription, variantPriceRange };
|
|
@@ -6,6 +6,7 @@ import { isDefaultSingleVariant } from "./is-default-single-variant.js";
|
|
|
6
6
|
import { isVariantSelectable } from "./is-variant-selectable.js";
|
|
7
7
|
import { ResolvedVariant, resolveSelectedVariant } from "./resolve-selected-variant.js";
|
|
8
8
|
import { selectionKey } from "./selection-key.js";
|
|
9
|
+
import { staleVariantFlag } from "./stale-variant.js";
|
|
9
10
|
import { SwatchSource, isSwatchOption, swatchSource } from "./swatch-source.js";
|
|
10
11
|
import { VariantPriceRange, variantPriceRange } from "./variant-price-range.js";
|
|
11
|
-
export { type LinkedMetafieldRef, type LinkedMetaobject, type LinkedMetaobjectField, type OptionAvailability, type ProductForVariantState, type ProductOption, type ProductOptionValue, type ProductVariant, type ResolvedVariant, type SelectedOption, type SwatchSource, type SwatchVariant, type VariantPriceRange, type VariantState, buildAvailabilityIndex, buildVariantState, findClosestVariant, isDefaultSingleVariant, isSwatchOption, isVariantSelectable, resolveSelectedVariant, selectionKey, swatchSource, variantPriceRange };
|
|
12
|
+
export { type LinkedMetafieldRef, type LinkedMetaobject, type LinkedMetaobjectField, type OptionAvailability, type ProductForVariantState, type ProductOption, type ProductOptionValue, type ProductVariant, type ResolvedVariant, type SelectedOption, type SwatchSource, type SwatchVariant, type VariantPriceRange, type VariantState, buildAvailabilityIndex, buildVariantState, findClosestVariant, isDefaultSingleVariant, isSwatchOption, isVariantSelectable, resolveSelectedVariant, selectionKey, staleVariantFlag, swatchSource, variantPriceRange };
|
|
@@ -5,6 +5,7 @@ import { findClosestVariant } from "./find-closest-variant.js";
|
|
|
5
5
|
import { isDefaultSingleVariant } from "./is-default-single-variant.js";
|
|
6
6
|
import { isVariantSelectable } from "./is-variant-selectable.js";
|
|
7
7
|
import { selectionKey } from "./selection-key.js";
|
|
8
|
+
import { staleVariantFlag } from "./stale-variant.js";
|
|
8
9
|
import { isSwatchOption, swatchSource } from "./swatch-source.js";
|
|
9
10
|
import { variantPriceRange } from "./variant-price-range.js";
|
|
10
|
-
export { buildAvailabilityIndex, buildVariantState, findClosestVariant, isDefaultSingleVariant, isSwatchOption, isVariantSelectable, resolveSelectedVariant, selectionKey, swatchSource, variantPriceRange };
|
|
11
|
+
export { buildAvailabilityIndex, buildVariantState, findClosestVariant, isDefaultSingleVariant, isSwatchOption, isVariantSelectable, resolveSelectedVariant, selectionKey, staleVariantFlag, swatchSource, variantPriceRange };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TemplateJSON } from "../template-types.js";
|
|
2
|
+
//#region src/product-variants/stale-variant.d.ts
|
|
3
|
+
/** The product page's flag for a `?variant=` that named no variant: spread
|
|
4
|
+
* onto the template a theme returns, and the shared PDP route redirects to the
|
|
5
|
+
* URL without it. Nothing when the param was absent or matched. */
|
|
6
|
+
export declare function staleVariantFlag(state: {
|
|
7
|
+
wasInvalidId: boolean;
|
|
8
|
+
} | null | undefined): Pick<TemplateJSON, "staleVariant">;
|
|
9
|
+
//#endregion
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/product-variants/stale-variant.ts
|
|
2
|
+
/** The product page's flag for a `?variant=` that named no variant: spread
|
|
3
|
+
* onto the template a theme returns, and the shared PDP route redirects to the
|
|
4
|
+
* URL without it. Nothing when the param was absent or matched. */
|
|
5
|
+
function staleVariantFlag(state) {
|
|
6
|
+
return state?.wasInvalidId ? { staleVariant: true } : {};
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { staleVariantFlag };
|
package/dist/template-types.d.ts
CHANGED
|
@@ -119,6 +119,10 @@ export interface TemplateJSON {
|
|
|
119
119
|
/** Set by `getProductTemplate` so the PDP route can render
|
|
120
120
|
* `<ProductJsonLd>`. Only present on product templates. */
|
|
121
121
|
productSchema?: ProductSchemaSource;
|
|
122
|
+
/** Set by `getProductTemplate` when the URL's `?variant=` names no variant
|
|
123
|
+
* of the product — a deleted one, an old share. The PDP route redirects to
|
|
124
|
+
* the same URL without it, so the page and its address agree. */
|
|
125
|
+
staleVariant?: true;
|
|
122
126
|
/** Set by `getArticleTemplate` so the article route can render
|
|
123
127
|
* `<ArticleJsonLd>`. Only present on article templates. */
|
|
124
128
|
articleSchema?: ArticleSchemaSource;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shop-on/theme-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"license": "SEE LICENSE IN dist/LICENSE.md",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"thumbhash": "0.1.1",
|
|
38
|
-
"@shop-on/theme-contract": "0.
|
|
38
|
+
"@shop-on/theme-contract": "0.2.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@types/node": "26.6.
|
|
41
|
+
"@types/node": "26.6.5",
|
|
42
42
|
"typescript": "7.0.2",
|
|
43
|
-
"vitest": "5.0.
|
|
43
|
+
"vitest": "5.0.5"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"check-types": "tsc --noEmit",
|
|
47
|
-
"test": "vitest run"
|
|
47
|
+
"test": "vitest run --maxWorkers=2"
|
|
48
48
|
}
|
|
49
49
|
}
|