@shop-on/theme-contract 0.5.0 → 0.6.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/ai-files.d.ts +18 -0
- package/dist/ai-files.js +47 -0
- package/dist/block-allowlist.d.ts +27 -0
- package/dist/block-allowlist.js +21 -0
- package/dist/closest-scope.d.ts +51 -0
- package/dist/closest-scope.js +66 -0
- package/dist/editor-tools/apply.d.ts +85 -0
- package/dist/editor-tools/apply.js +544 -0
- package/dist/editor-tools/args.d.ts +153 -0
- package/dist/editor-tools/args.js +145 -0
- package/dist/editor-tools/coerce.d.ts +43 -0
- package/dist/editor-tools/coerce.js +200 -0
- package/dist/editor-tools/digest.d.ts +75 -0
- package/dist/editor-tools/digest.js +99 -0
- package/dist/editor-tools/index.d.ts +21 -0
- package/dist/editor-tools/index.js +24 -0
- package/dist/editor-tools/recipes.d.ts +122 -0
- package/dist/editor-tools/recipes.js +192 -0
- package/dist/fonts.d.ts +9 -0
- package/dist/fonts.js +11 -0
- package/dist/google-fonts.generated.d.ts +7 -0
- package/dist/google-fonts.generated.js +753 -0
- package/dist/index.d.ts +14 -5
- package/dist/index.js +14 -5
- package/dist/link-url.d.ts +9 -0
- package/dist/link-url.js +33 -0
- package/dist/metafield-binding.d.ts +89 -9
- package/dist/metafield-binding.js +254 -43
- package/dist/ops.d.ts +85 -0
- package/dist/ops.js +442 -0
- package/dist/richtext.d.ts +23 -0
- package/dist/richtext.js +115 -1
- package/dist/schemas.d.ts +325 -0
- package/dist/schemas.js +57 -7
- package/dist/section-scope.d.ts +17 -0
- package/dist/section-scope.js +22 -0
- package/dist/store-path.d.ts +9 -0
- package/dist/store-path.js +13 -1
- package/dist/template-limits.d.ts +34 -0
- package/dist/template-limits.js +71 -0
- package/dist/video-url.d.ts +10 -0
- package/dist/video-url.js +36 -0
- package/package.json +8 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import { BlockDefinition, BlockSchema, LayoutGroupDef, SchemaSetting, SectionGroup, SectionGroupData, SectionPreset, SectionSchema, SettingBinding, SettingBindings, SettingValue, SettingsData, SettingsSchema, SettingsSchemaSection, Template, TemplateBlock, TemplateSection } from "./schemas.js";
|
|
1
|
+
import { BlockDefinition, BlockSchema, CLOSEST_RESOURCES, ClosestOverlays, ClosestResource, LayoutGroupDef, ProviderDecl, Provides, SchemaSetting, SectionGroup, SectionGroupData, SectionPreset, SectionSchema, SettingBinding, SettingBindings, SettingValue, SettingsData, SettingsSchema, SettingsSchemaSection, THEME_FED, Template, TemplateBlock, TemplateSection } from "./schemas.js";
|
|
2
|
+
import { EntryDoc, MAX_BATCH_BYTES, MAX_BATCH_OPS, MAX_PATH_DEPTH, MAX_SEGMENT_LENGTH, Op, OpBatch, OpBatchBody, OpBatchBodySchema, OpReset, OpSchema, ThemeDocument, TouchedEntries, applyOps, chunkOps, diffDocument, invertOps, touchedEntries } from "./ops.js";
|
|
3
|
+
import { ClosestScope, PICKER_RESOURCES, Providers, ScopeLink, closestScopeAt, providersOf } from "./closest-scope.js";
|
|
4
|
+
import { RICHTEXT_ALLOWED_TAGS, RICHTEXT_FIELD_TAGS, RICHTEXT_SANITIZE_CONFIG, RichTextPurifier, RichtextTag, hasRichText, registerRichTextHooks, stripInlineTokenSentinels } from "./richtext.js";
|
|
2
5
|
import { BLOCK_PATH_SEPARATOR, blockPathsEqual, isBlockPathPrefix, joinBlockPath, normalizeBlockPath, resolveContainerAtPath, splitBlockPath } from "./block-path.js";
|
|
3
6
|
import { EDITOR_COMMANDS, EditorCommand, EditorKeyInput, editorCommand, isEditorCommand, shortcutKey, undoHotkey } from "./editor-keys.js";
|
|
4
7
|
import { APP_BLOCK_WILDCARD, CollectedTypes, MAX_APP_BLOCK_CONTAINER_DEPTH, SeedMissingStaticsReport, SelectedSection, TemplateShape, acceptsAppBlocks, buildBlockInstance, buildSectionInstance, buildStaticChildren, collectTypes, defaultSettings, seedMissingStatics, selectRenderableChildren, selectRenderableSections, staticBlockId, staticChildId, stripStaticFromBlockOrder } from "./document.js";
|
|
5
8
|
import { MAX_PALETTE_COLORS, MIN_PALETTE_COLORS, PALETTE_FALLBACK_COLOR, PALETTE_GROUP_TYPE, PALETTE_PREFIX, PALETTE_REF_PREFIX, PaletteColor, comparePaletteIds, hasPaletteRefs, paletteKey, paletteRef, paletteValues, parsePalette, parsePaletteRef, resolvePaletteRefs, resolvePaletteValue, resolveThemeSettingsPalette } from "./color-palette.js";
|
|
6
9
|
import { FieldSource, ResolverCtx, ResolverScope, ResolverShape, ResolverSpec, SKIP, Skip, buildDisabledAncestorSet, buildParentMap, resolveField, walkBlocks, walkSections } from "./resolvers.js";
|
|
7
|
-
import { ARTICLE_ATTRIBUTE_KEYS, ArticleAttributeKey, BLOG_ATTRIBUTE_KEYS, BlogAttributeKey, COLLECTION_ATTRIBUTE_KEYS, COLLECTION_INLINE_ATTRIBUTE_KEYS, CollectionAttributeBindingSources, CollectionAttributeKey, CollectionInlineAttributeKey, InlineSegment, InlineSources, PAGE_ATTRIBUTE_KEYS, PRODUCT_ATTRIBUTE_KEYS, PageAttributeKey, ProductAttributeKey, WholeValueBindingOpts, applyCollectionAttributeBindings, applyInlineSources, applyMetafieldBindings, applyMetaobjectFieldBindings, collectCollectionAttributeBindings, collectMetaobjectEntryIds, collectTraversedEntryIds, decodeStorefrontMetafield, encodeSourceToken, escapeInertHtmlText, metafieldDefinitionFitsSetting, metafieldTypeSupportsInlineToken, metafieldTypeToSettingTypes, parseSourceDescriptor, serializeSourceDescriptor, settingTypeSupportsBinding, splitInlineTokens,
|
|
10
|
+
import { ARTICLE_ATTRIBUTE_KEYS, ArticleAttributeKey, BLOG_ATTRIBUTE_KEYS, BlogAttributeKey, COLLECTION_ATTRIBUTE_KEYS, COLLECTION_INLINE_ATTRIBUTE_KEYS, ClosestItemSources, ClosestLookup, CollectionAttributeBindingSources, CollectionAttributeKey, CollectionInlineAttributeKey, InlineSegment, InlineSources, PAGE_ATTRIBUTE_KEYS, PRODUCT_ATTRIBUTE_KEYS, PageAttributeKey, ProductAttributeKey, RESOURCE_METAFIELD_SOURCES, ROUTE_METAFIELD_RESOURCE, ROUTE_METAFIELD_SOURCES, ResourceMetafieldBinding, ResourceMetafieldSource, RouteMetafieldSource, WholeValueBindingOpts, applyClosestBindings, applyCollectionAttributeBindings, applyInlineSources, applyMetafieldBindings, applyMetaobjectFieldBindings, closestResourceOf, collectCollectionAttributeBindings, collectMetaobjectEntryIds, collectTraversedEntryIds, decodeStorefrontMetafield, encodeSourceToken, escapeInertHtmlText, isClosestSink, isResourceMetafieldBinding, isResourceMetafieldSource, metafieldDefinitionFitsSetting, metafieldTypeSupportsInlineToken, metafieldTypeToSettingTypes, nodeSourceDescriptors, parseSourceDescriptor, routeTwin, serializeSourceDescriptor, settingTypeSupportsBinding, splitInlineTokens, templateReferencesSource } from "./metafield-binding.js";
|
|
8
11
|
import { metaobjectGid, metaobjectIdFromGid } from "./metaobject-gid.js";
|
|
9
|
-
import { RICHTEXT_ALLOWED_TAGS, RichtextTag } from "./richtext.js";
|
|
10
12
|
import { isNodeIdToken, nodeGid } from "./node-id.js";
|
|
11
|
-
import { INSTALL_ID_RE, STORE_SLUG_RE } from "./store-path.js";
|
|
12
|
-
|
|
13
|
+
import { DRAFT_SEEDED_KEY, INSTALL_ID_RE, STORE_SLUG_RE, invalidTemplateId } from "./store-path.js";
|
|
14
|
+
import { MAX_BLOCKS_PER_TEMPLATE, MAX_BLOCK_NESTING_DEPTH, MAX_ENTRY_BYTES, MAX_SECTIONS_PER_TEMPLATE, countBlocksInBlock, countNestedBlocks, maxBlockDepth, maxDepthOfBlock, maxDepthOfBlockSchema, templateCounts } from "./template-limits.js";
|
|
15
|
+
import { isSectionAddableInGroup, isSectionAllowedInGroup, isSectionEnabledOnTemplate, templateMatches } from "./section-scope.js";
|
|
16
|
+
import { allowedChildBlockTypes } from "./block-allowlist.js";
|
|
17
|
+
import { NormalizedUrl, normalizeCustomUrl } from "./link-url.js";
|
|
18
|
+
import { VideoProvider, isAcceptedVideoUrl, parseVideoUrl } from "./video-url.js";
|
|
19
|
+
import { GOOGLE_FONTS, GoogleFontEntry } from "./google-fonts.generated.js";
|
|
20
|
+
import { SYSTEM_FONT_FAMILIES, isCatalogFontFamily } from "./fonts.js";
|
|
21
|
+
export { APP_BLOCK_WILDCARD, ARTICLE_ATTRIBUTE_KEYS, ArticleAttributeKey, BLOCK_PATH_SEPARATOR, BLOG_ATTRIBUTE_KEYS, BlockDefinition, BlockSchema, BlogAttributeKey, CLOSEST_RESOURCES, COLLECTION_ATTRIBUTE_KEYS, COLLECTION_INLINE_ATTRIBUTE_KEYS, ClosestItemSources, ClosestLookup, ClosestOverlays, ClosestResource, ClosestScope, CollectedTypes, CollectionAttributeBindingSources, CollectionAttributeKey, CollectionInlineAttributeKey, DRAFT_SEEDED_KEY, EDITOR_COMMANDS, EditorCommand, EditorKeyInput, EntryDoc, FieldSource, GOOGLE_FONTS, type GoogleFontEntry, INSTALL_ID_RE, InlineSegment, InlineSources, LayoutGroupDef, MAX_APP_BLOCK_CONTAINER_DEPTH, MAX_BATCH_BYTES, MAX_BATCH_OPS, MAX_BLOCKS_PER_TEMPLATE, MAX_BLOCK_NESTING_DEPTH, MAX_ENTRY_BYTES, MAX_PALETTE_COLORS, MAX_PATH_DEPTH, MAX_SECTIONS_PER_TEMPLATE, MAX_SEGMENT_LENGTH, MIN_PALETTE_COLORS, NormalizedUrl, Op, OpBatch, OpBatchBody, OpBatchBodySchema, OpReset, OpSchema, PAGE_ATTRIBUTE_KEYS, PALETTE_FALLBACK_COLOR, PALETTE_GROUP_TYPE, PALETTE_PREFIX, PALETTE_REF_PREFIX, PICKER_RESOURCES, PRODUCT_ATTRIBUTE_KEYS, PageAttributeKey, PaletteColor, ProductAttributeKey, ProviderDecl, Providers, Provides, RESOURCE_METAFIELD_SOURCES, RICHTEXT_ALLOWED_TAGS, RICHTEXT_FIELD_TAGS, RICHTEXT_SANITIZE_CONFIG, ROUTE_METAFIELD_RESOURCE, ROUTE_METAFIELD_SOURCES, ResolverCtx, ResolverScope, ResolverShape, ResolverSpec, ResourceMetafieldBinding, ResourceMetafieldSource, RichTextPurifier, RichtextTag, RouteMetafieldSource, SKIP, STORE_SLUG_RE, SYSTEM_FONT_FAMILIES, SchemaSetting, ScopeLink, SectionGroup, SectionGroupData, SectionPreset, SectionSchema, SeedMissingStaticsReport, SelectedSection, SettingBinding, SettingBindings, SettingValue, SettingsData, SettingsSchema, SettingsSchemaSection, Skip, THEME_FED, Template, TemplateBlock, TemplateSection, TemplateShape, ThemeDocument, TouchedEntries, VideoProvider, WholeValueBindingOpts, acceptsAppBlocks, allowedChildBlockTypes, applyClosestBindings, applyCollectionAttributeBindings, applyInlineSources, applyMetafieldBindings, applyMetaobjectFieldBindings, applyOps, blockPathsEqual, buildBlockInstance, buildDisabledAncestorSet, buildParentMap, buildSectionInstance, buildStaticChildren, chunkOps, closestResourceOf, closestScopeAt, collectCollectionAttributeBindings, collectMetaobjectEntryIds, collectTraversedEntryIds, collectTypes, comparePaletteIds, countBlocksInBlock, countNestedBlocks, decodeStorefrontMetafield, defaultSettings, diffDocument, editorCommand, encodeSourceToken, escapeInertHtmlText, hasPaletteRefs, hasRichText, invalidTemplateId, invertOps, isAcceptedVideoUrl, isBlockPathPrefix, isCatalogFontFamily, isClosestSink, isEditorCommand, isNodeIdToken, isResourceMetafieldBinding, isResourceMetafieldSource, isSectionAddableInGroup, isSectionAllowedInGroup, isSectionEnabledOnTemplate, joinBlockPath, maxBlockDepth, maxDepthOfBlock, maxDepthOfBlockSchema, metafieldDefinitionFitsSetting, metafieldTypeSupportsInlineToken, metafieldTypeToSettingTypes, metaobjectGid, metaobjectIdFromGid, nodeGid, nodeSourceDescriptors, normalizeBlockPath, normalizeCustomUrl, paletteKey, paletteRef, paletteValues, parsePalette, parsePaletteRef, parseSourceDescriptor, parseVideoUrl, providersOf, registerRichTextHooks, resolveContainerAtPath, resolveField, resolvePaletteRefs, resolvePaletteValue, resolveThemeSettingsPalette, routeTwin, seedMissingStatics, selectRenderableChildren, selectRenderableSections, serializeSourceDescriptor, settingTypeSupportsBinding, shortcutKey, splitBlockPath, splitInlineTokens, staticBlockId, staticChildId, stripInlineTokenSentinels, stripStaticFromBlockOrder, templateCounts, templateMatches, templateReferencesSource, touchedEntries, undoHotkey, walkBlocks, walkSections };
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import { BlockDefinition, BlockSchema, SchemaSetting, SectionGroup, SectionPreset, SectionSchema, SettingBinding, SettingBindings, SettingsData, SettingsSchema, SettingsSchemaSection, Template, TemplateBlock, TemplateSection } from "./schemas.js";
|
|
1
|
+
import { BlockDefinition, BlockSchema, CLOSEST_RESOURCES, ClosestResource, ProviderDecl, Provides, SchemaSetting, SectionGroup, SectionPreset, SectionSchema, SettingBinding, SettingBindings, SettingsData, SettingsSchema, SettingsSchemaSection, THEME_FED, Template, TemplateBlock, TemplateSection } from "./schemas.js";
|
|
2
2
|
import { BLOCK_PATH_SEPARATOR, blockPathsEqual, isBlockPathPrefix, joinBlockPath, normalizeBlockPath, resolveContainerAtPath, splitBlockPath } from "./block-path.js";
|
|
3
3
|
import { EDITOR_COMMANDS, editorCommand, isEditorCommand, shortcutKey, undoHotkey } from "./editor-keys.js";
|
|
4
4
|
import { APP_BLOCK_WILDCARD, MAX_APP_BLOCK_CONTAINER_DEPTH, acceptsAppBlocks, buildBlockInstance, buildSectionInstance, buildStaticChildren, collectTypes, defaultSettings, seedMissingStatics, selectRenderableChildren, selectRenderableSections, staticBlockId, staticChildId, stripStaticFromBlockOrder } from "./document.js";
|
|
5
5
|
import { MAX_PALETTE_COLORS, MIN_PALETTE_COLORS, PALETTE_FALLBACK_COLOR, PALETTE_GROUP_TYPE, PALETTE_PREFIX, PALETTE_REF_PREFIX, comparePaletteIds, hasPaletteRefs, paletteKey, paletteRef, paletteValues, parsePalette, parsePaletteRef, resolvePaletteRefs, resolvePaletteValue, resolveThemeSettingsPalette } from "./color-palette.js";
|
|
6
6
|
import { SKIP, buildDisabledAncestorSet, buildParentMap, resolveField, walkBlocks, walkSections } from "./resolvers.js";
|
|
7
7
|
import { metaobjectGid, metaobjectIdFromGid } from "./metaobject-gid.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { RICHTEXT_ALLOWED_TAGS, RICHTEXT_FIELD_TAGS, RICHTEXT_SANITIZE_CONFIG, hasRichText, registerRichTextHooks, stripInlineTokenSentinels } from "./richtext.js";
|
|
9
|
+
import { ARTICLE_ATTRIBUTE_KEYS, BLOG_ATTRIBUTE_KEYS, COLLECTION_ATTRIBUTE_KEYS, COLLECTION_INLINE_ATTRIBUTE_KEYS, PAGE_ATTRIBUTE_KEYS, PRODUCT_ATTRIBUTE_KEYS, RESOURCE_METAFIELD_SOURCES, ROUTE_METAFIELD_RESOURCE, ROUTE_METAFIELD_SOURCES, applyClosestBindings, applyCollectionAttributeBindings, applyInlineSources, applyMetafieldBindings, applyMetaobjectFieldBindings, closestResourceOf, collectCollectionAttributeBindings, collectMetaobjectEntryIds, collectTraversedEntryIds, decodeStorefrontMetafield, encodeSourceToken, escapeInertHtmlText, isClosestSink, isResourceMetafieldBinding, isResourceMetafieldSource, metafieldDefinitionFitsSetting, metafieldTypeSupportsInlineToken, metafieldTypeToSettingTypes, nodeSourceDescriptors, parseSourceDescriptor, routeTwin, serializeSourceDescriptor, settingTypeSupportsBinding, splitInlineTokens, templateReferencesSource } from "./metafield-binding.js";
|
|
10
|
+
import { PICKER_RESOURCES, closestScopeAt, providersOf } from "./closest-scope.js";
|
|
10
11
|
import { isNodeIdToken, nodeGid } from "./node-id.js";
|
|
11
|
-
import { INSTALL_ID_RE, STORE_SLUG_RE } from "./store-path.js";
|
|
12
|
-
|
|
12
|
+
import { DRAFT_SEEDED_KEY, INSTALL_ID_RE, STORE_SLUG_RE, invalidTemplateId } from "./store-path.js";
|
|
13
|
+
import { MAX_BATCH_BYTES, MAX_BATCH_OPS, MAX_PATH_DEPTH, MAX_SEGMENT_LENGTH, OpBatchBodySchema, OpSchema, applyOps, chunkOps, diffDocument, invertOps, touchedEntries } from "./ops.js";
|
|
14
|
+
import { MAX_BLOCKS_PER_TEMPLATE, MAX_BLOCK_NESTING_DEPTH, MAX_ENTRY_BYTES, MAX_SECTIONS_PER_TEMPLATE, countBlocksInBlock, countNestedBlocks, maxBlockDepth, maxDepthOfBlock, maxDepthOfBlockSchema, templateCounts } from "./template-limits.js";
|
|
15
|
+
import { isSectionAddableInGroup, isSectionAllowedInGroup, isSectionEnabledOnTemplate, templateMatches } from "./section-scope.js";
|
|
16
|
+
import { allowedChildBlockTypes } from "./block-allowlist.js";
|
|
17
|
+
import { normalizeCustomUrl } from "./link-url.js";
|
|
18
|
+
import { isAcceptedVideoUrl, parseVideoUrl } from "./video-url.js";
|
|
19
|
+
import { GOOGLE_FONTS } from "./google-fonts.generated.js";
|
|
20
|
+
import { SYSTEM_FONT_FAMILIES, isCatalogFontFamily } from "./fonts.js";
|
|
21
|
+
export { APP_BLOCK_WILDCARD, ARTICLE_ATTRIBUTE_KEYS, BLOCK_PATH_SEPARATOR, BLOG_ATTRIBUTE_KEYS, BlockDefinition, BlockSchema, CLOSEST_RESOURCES, COLLECTION_ATTRIBUTE_KEYS, COLLECTION_INLINE_ATTRIBUTE_KEYS, ClosestResource, DRAFT_SEEDED_KEY, EDITOR_COMMANDS, GOOGLE_FONTS, INSTALL_ID_RE, MAX_APP_BLOCK_CONTAINER_DEPTH, MAX_BATCH_BYTES, MAX_BATCH_OPS, MAX_BLOCKS_PER_TEMPLATE, MAX_BLOCK_NESTING_DEPTH, MAX_ENTRY_BYTES, MAX_PALETTE_COLORS, MAX_PATH_DEPTH, MAX_SECTIONS_PER_TEMPLATE, MAX_SEGMENT_LENGTH, MIN_PALETTE_COLORS, OpBatchBodySchema, OpSchema, PAGE_ATTRIBUTE_KEYS, PALETTE_FALLBACK_COLOR, PALETTE_GROUP_TYPE, PALETTE_PREFIX, PALETTE_REF_PREFIX, PICKER_RESOURCES, PRODUCT_ATTRIBUTE_KEYS, ProviderDecl, Provides, RESOURCE_METAFIELD_SOURCES, RICHTEXT_ALLOWED_TAGS, RICHTEXT_FIELD_TAGS, RICHTEXT_SANITIZE_CONFIG, ROUTE_METAFIELD_RESOURCE, ROUTE_METAFIELD_SOURCES, SKIP, STORE_SLUG_RE, SYSTEM_FONT_FAMILIES, SchemaSetting, SectionGroup, SectionPreset, SectionSchema, SettingBinding, SettingBindings, SettingsData, SettingsSchema, SettingsSchemaSection, THEME_FED, Template, TemplateBlock, TemplateSection, acceptsAppBlocks, allowedChildBlockTypes, applyClosestBindings, applyCollectionAttributeBindings, applyInlineSources, applyMetafieldBindings, applyMetaobjectFieldBindings, applyOps, blockPathsEqual, buildBlockInstance, buildDisabledAncestorSet, buildParentMap, buildSectionInstance, buildStaticChildren, chunkOps, closestResourceOf, closestScopeAt, collectCollectionAttributeBindings, collectMetaobjectEntryIds, collectTraversedEntryIds, collectTypes, comparePaletteIds, countBlocksInBlock, countNestedBlocks, decodeStorefrontMetafield, defaultSettings, diffDocument, editorCommand, encodeSourceToken, escapeInertHtmlText, hasPaletteRefs, hasRichText, invalidTemplateId, invertOps, isAcceptedVideoUrl, isBlockPathPrefix, isCatalogFontFamily, isClosestSink, isEditorCommand, isNodeIdToken, isResourceMetafieldBinding, isResourceMetafieldSource, isSectionAddableInGroup, isSectionAllowedInGroup, isSectionEnabledOnTemplate, joinBlockPath, maxBlockDepth, maxDepthOfBlock, maxDepthOfBlockSchema, metafieldDefinitionFitsSetting, metafieldTypeSupportsInlineToken, metafieldTypeToSettingTypes, metaobjectGid, metaobjectIdFromGid, nodeGid, nodeSourceDescriptors, normalizeBlockPath, normalizeCustomUrl, paletteKey, paletteRef, paletteValues, parsePalette, parsePaletteRef, parseSourceDescriptor, parseVideoUrl, providersOf, registerRichTextHooks, resolveContainerAtPath, resolveField, resolvePaletteRefs, resolvePaletteValue, resolveThemeSettingsPalette, routeTwin, seedMissingStatics, selectRenderableChildren, selectRenderableSections, serializeSourceDescriptor, settingTypeSupportsBinding, shortcutKey, splitBlockPath, splitInlineTokens, staticBlockId, staticChildId, stripInlineTokenSentinels, stripStaticFromBlockOrder, templateCounts, templateMatches, templateReferencesSource, touchedEntries, undoHotkey, walkBlocks, walkSections };
|
package/dist/link-url.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region src/link-url.ts
|
|
2
|
+
const SCHEME = /^([a-z][a-z0-9+.-]*):/i;
|
|
3
|
+
const LINK_SCHEMES = /* @__PURE__ */ new Set([
|
|
4
|
+
"http",
|
|
5
|
+
"https",
|
|
6
|
+
"mailto",
|
|
7
|
+
"tel"
|
|
8
|
+
]);
|
|
9
|
+
function normalizeCustomUrl(raw) {
|
|
10
|
+
const trimmed = raw.trim();
|
|
11
|
+
if (!trimmed) return { ok: false };
|
|
12
|
+
if (trimmed.includes("\\")) return { ok: false };
|
|
13
|
+
if (trimmed.startsWith("//")) return {
|
|
14
|
+
ok: true,
|
|
15
|
+
url: `https:${trimmed}`
|
|
16
|
+
};
|
|
17
|
+
if (trimmed.startsWith("/") || trimmed.startsWith("#")) return {
|
|
18
|
+
ok: true,
|
|
19
|
+
url: trimmed
|
|
20
|
+
};
|
|
21
|
+
const scheme = SCHEME.exec(trimmed);
|
|
22
|
+
if (scheme && !scheme[1].includes(".")) return LINK_SCHEMES.has(scheme[1].toLowerCase()) ? {
|
|
23
|
+
ok: true,
|
|
24
|
+
url: trimmed
|
|
25
|
+
} : { ok: false };
|
|
26
|
+
if (/\s/.test(trimmed) || !trimmed.includes(".")) return { ok: false };
|
|
27
|
+
return {
|
|
28
|
+
ok: true,
|
|
29
|
+
url: `https://${trimmed}`
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { normalizeCustomUrl };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SettingBinding, SettingValue } from "./schemas.js";
|
|
1
|
+
import { ClosestResource, SettingBinding, SettingValue } from "./schemas.js";
|
|
2
2
|
//#region src/metafield-binding.d.ts
|
|
3
3
|
export declare const metafieldTypeToSettingTypes: Record<string, readonly string[]>;
|
|
4
4
|
/** True if a setting of this `type` can be bound to a metafield in v1. */
|
|
@@ -20,13 +20,37 @@ export interface WholeValueBindingOpts {
|
|
|
20
20
|
value: string;
|
|
21
21
|
}>>;
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
export declare const ROUTE_METAFIELD_SOURCES: readonly ["collection_metafield", "page_metafield", "blog_metafield", "article_metafield"];
|
|
24
|
+
export type RouteMetafieldSource = (typeof ROUTE_METAFIELD_SOURCES)[number];
|
|
25
|
+
/** The route resource each source reads — the key of that resource on the
|
|
26
|
+
* loader's request and the editor's template families. */
|
|
27
|
+
export declare const ROUTE_METAFIELD_RESOURCE: {
|
|
28
|
+
readonly collection_metafield: "collection";
|
|
29
|
+
readonly page_metafield: "page";
|
|
30
|
+
readonly blog_metafield: "blog";
|
|
31
|
+
readonly article_metafield: "article";
|
|
32
|
+
};
|
|
33
|
+
export declare const RESOURCE_METAFIELD_SOURCES: readonly ["product_metafield", "collection_metafield", "page_metafield", "blog_metafield", "article_metafield"];
|
|
34
|
+
export type ResourceMetafieldSource = (typeof RESOURCE_METAFIELD_SOURCES)[number];
|
|
35
|
+
/** True for a binding/descriptor that reads a route resource's metafield. */
|
|
36
|
+
export declare function isResourceMetafieldSource(source: string): source is ResourceMetafieldSource;
|
|
37
|
+
export type ResourceMetafieldBinding = Extract<SettingBinding, {
|
|
38
|
+
source: ResourceMetafieldSource;
|
|
39
|
+
}>;
|
|
40
|
+
/** True for a binding that reads a route resource's metafield. */
|
|
41
|
+
export declare function isResourceMetafieldBinding(binding: SettingBinding): binding is ResourceMetafieldBinding;
|
|
42
|
+
/** Overlay resolved resource-metafield values onto a template's settings — for
|
|
43
|
+
* each binding of `opts.source` (default `product_metafield`),
|
|
44
|
+
* `metafields["namespace.key"]`. The caller passes the route resource's map
|
|
45
|
+
* (the PDP's product, or the collection, page, blog or article a template
|
|
46
|
+
* renders); other sources are
|
|
47
|
+
* skipped. See applyWholeValueBindings. */
|
|
26
48
|
export declare function applyMetafieldBindings(template: unknown, metafields: Record<string, {
|
|
27
49
|
type: string;
|
|
28
50
|
value: string;
|
|
29
|
-
}>, opts?: WholeValueBindingOpts
|
|
51
|
+
}>, opts?: WholeValueBindingOpts & {
|
|
52
|
+
source?: ResourceMetafieldSource;
|
|
53
|
+
}): void;
|
|
30
54
|
/** Whole-value sibling for `metaobject_field` bindings — `metaobjectFields[entry][key]`.
|
|
31
55
|
* Runs on every template (the entry is pinned, not the route product). */
|
|
32
56
|
export declare function applyMetaobjectFieldBindings(template: unknown, metaobjectFields: Record<string, Record<string, {
|
|
@@ -50,8 +74,6 @@ export declare function applyCollectionAttributeBindings(template: unknown, sour
|
|
|
50
74
|
* sidecars. The loader fetches the description HTML only when this includes
|
|
51
75
|
* `description` (an inline description token resolves to "" and needs nothing). */
|
|
52
76
|
export declare function collectCollectionAttributeBindings(template: unknown): string[];
|
|
53
|
-
/** Strip inline-token sentinel delimiters from a string. */
|
|
54
|
-
export declare function stripInlineTokenSentinels(value: string): string;
|
|
55
77
|
export declare const PRODUCT_ATTRIBUTE_KEYS: readonly ["title", "vendor", "price"];
|
|
56
78
|
export type ProductAttributeKey = (typeof PRODUCT_ATTRIBUTE_KEYS)[number];
|
|
57
79
|
export declare const COLLECTION_ATTRIBUTE_KEYS: readonly ["title", "description"];
|
|
@@ -96,9 +118,14 @@ export interface InlineSources {
|
|
|
96
118
|
value: string;
|
|
97
119
|
}>>;
|
|
98
120
|
collectionAttributes?: Record<string, string | null | undefined>;
|
|
121
|
+
routeMetafields?: Partial<Record<RouteMetafieldSource, Record<string, {
|
|
122
|
+
type: string;
|
|
123
|
+
value: string;
|
|
124
|
+
}>>>;
|
|
99
125
|
pageAttributes?: Record<string, string | null | undefined>;
|
|
100
126
|
blogAttributes?: Record<string, string | null | undefined>;
|
|
101
127
|
articleAttributes?: Record<string, string | null | undefined>;
|
|
128
|
+
closest?: ClosestLookup;
|
|
102
129
|
}
|
|
103
130
|
/** Strip inline-token sentinels THEN HTML-escape — the full "make inert for an
|
|
104
131
|
* HTML sink" transform. The single source of truth for both the `inline_richtext`
|
|
@@ -115,10 +142,62 @@ export declare function escapeInertHtmlText(value: string): string;
|
|
|
115
142
|
* applyMetafieldBindings — a setting carries either a whole-value binding or
|
|
116
143
|
* inline tokens, never both. */
|
|
117
144
|
export declare function applyInlineSources(template: unknown, sources: InlineSources): void;
|
|
145
|
+
/** The route arm a closest arm mirrors (same payload, `source` swapped), or
|
|
146
|
+
* null for a binding that is not a closest arm. */
|
|
147
|
+
export declare function routeTwin(binding: SettingBinding): SettingBinding | null;
|
|
148
|
+
/** The resource a closest arm resolves against, or null for any other arm. */
|
|
149
|
+
export declare function closestResourceOf(binding: SettingBinding): ClosestResource | null;
|
|
150
|
+
/** One in-scope item as the resolvers read it, the same shape for every
|
|
151
|
+
* resource: `attributes` keyed by the resource's `*_ATTRIBUTE_KEYS`, plus the
|
|
152
|
+
* product's `metafields` ("ns.key" → wire field) and the collection's
|
|
153
|
+
* `descriptionHtml` (whole-value `richtext` only). */
|
|
154
|
+
export interface ClosestItemSources {
|
|
155
|
+
attributes: Record<string, string | null | undefined>;
|
|
156
|
+
metafields?: Record<string, {
|
|
157
|
+
type: string;
|
|
158
|
+
value: string;
|
|
159
|
+
}>;
|
|
160
|
+
descriptionHtml?: string | null;
|
|
161
|
+
}
|
|
162
|
+
/** The loader's answer to "what does this node resolve `closest_<resource>`
|
|
163
|
+
* against": a single item (a picker's, or the route's) per resource, and at
|
|
164
|
+
* most one `each` scope — the nearest list, whose item id the block mount
|
|
165
|
+
* carries. `singleAt` answers null for the `each` resource, so the shared copy
|
|
166
|
+
* blanks it and only the per-item overlays resolve it. */
|
|
167
|
+
export interface ClosestLookup {
|
|
168
|
+
singleAt(node: unknown, resource: ClosestResource): ClosestItemSources | null;
|
|
169
|
+
eachAt(node: unknown): {
|
|
170
|
+
resource: ClosestResource;
|
|
171
|
+
items: ReadonlyArray<{
|
|
172
|
+
id: string;
|
|
173
|
+
sources: ClosestItemSources;
|
|
174
|
+
}>;
|
|
175
|
+
} | null;
|
|
176
|
+
}
|
|
177
|
+
/** True when a setting of `settingType` may carry a closest binding. */
|
|
178
|
+
export declare function isClosestSink(settingType: string): boolean;
|
|
179
|
+
/** Resolve every whole-value `closest_<resource>_*` binding on ONE node against
|
|
180
|
+
* ONE item, writing into `into` (a per-item overlay) or, by default, the node's
|
|
181
|
+
* own settings (a single scope). Other resources' arms and the route twins are
|
|
182
|
+
* untouched. A known sink is required — the schema's (`sinkTypeAt`) or the
|
|
183
|
+
* stamp's — and it must be one of the text / color / url sinks; the product
|
|
184
|
+
* metafield then goes through `resolveBoundValue` exactly as its twin does,
|
|
185
|
+
* and the collection description through the same inert-HTML path as
|
|
186
|
+
* `applyCollectionAttributeBindings`. The attribute arms are inline-only. */
|
|
187
|
+
export declare function applyClosestBindings(node: unknown, resource: ClosestResource, item: ClosestItemSources, opts?: Pick<WholeValueBindingOpts, "serializeRichText" | "sinkTypeAt">, into?: Record<string, unknown>): void;
|
|
188
|
+
/** Every source descriptor ONE node references — its `bindings` sidecar and
|
|
189
|
+
* the inline tokens in its string settings (both forms). The per-node half of
|
|
190
|
+
* `iterSourceDescriptors`, exported for the loader's closest-needs walk, which
|
|
191
|
+
* must attribute each descriptor to the node's own scope. */
|
|
192
|
+
export declare function nodeSourceDescriptors(node: unknown): Generator<SettingBinding>;
|
|
118
193
|
/** Distinct numeric metaobject entry ids PINNED anywhere in the template — via
|
|
119
194
|
* `metaobject_field` sidecar bindings AND inline tokens. The theme loader fetches
|
|
120
195
|
* exactly these before building the `metaobjectFields` map for the render passes. */
|
|
121
196
|
export declare function collectMetaobjectEntryIds(template: unknown): string[];
|
|
197
|
+
/** True when the template references `source` anywhere — a `bindings` sidecar
|
|
198
|
+
* or an inline token of either form. The loader asks this before fetching a
|
|
199
|
+
* resource's metafields, so a template that binds none makes no request. */
|
|
200
|
+
export declare function templateReferencesSource(template: unknown, source: SettingBinding["source"]): boolean;
|
|
122
201
|
/** Distinct numeric entry ids reached by field-bearing `product_metafield`
|
|
123
202
|
* descriptors (bindings + both token forms). Unlike pinned entries these vary per
|
|
124
203
|
* product, so the resolved `metafields` map (keyed `"ns.key"`, the shape
|
|
@@ -126,9 +205,10 @@ export declare function collectMetaobjectEntryIds(template: unknown): string[];
|
|
|
126
205
|
* dereference each METAOBJECT_REFERENCE value to its entry GID. Shares both
|
|
127
206
|
* resolve-time gates (`FIELD_KEY_RE` + `metaobjectRefEntryId`) with
|
|
128
207
|
* `traverseMetaobjectReference` so the fetched set is exactly the resolvable
|
|
129
|
-
* set.
|
|
208
|
+
* set. `source` names whose map `metafields` is (default the route product's);
|
|
209
|
+
* empty when that resource is absent from the load. */
|
|
130
210
|
export declare function collectTraversedEntryIds(template: unknown, metafields: Record<string, {
|
|
131
211
|
type: string;
|
|
132
212
|
value: string;
|
|
133
|
-
}
|
|
213
|
+
}>, source?: ResourceMetafieldSource): string[];
|
|
134
214
|
//#endregion
|