@styleflow.app/flowpress-astro-core 1.0.0-beta.1 → 1.0.0-beta.10
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/CHANGELOG.md +80 -1
- package/README.md +94 -3
- package/dist/astro/BaseLayout.astro +5 -1
- package/dist/astro/CompositionRenderer.astro +127 -0
- package/dist/astro/DefaultBlockAdapter.astro +35 -0
- package/dist/astro/DefaultTemplate.astro +6 -1
- package/dist/astro/GutenbergRenderer.astro +215 -55
- package/dist/astro/ThemeRuntime.astro +24 -0
- package/dist/astro/blocks/CarouselBlock.astro +198 -0
- package/dist/astro/blocks/CarouselItemBlock.astro +26 -0
- package/dist/astro/blocks/ColumnBlock.astro +2 -3
- package/dist/astro/blocks/FormBlock.astro +5 -5
- package/dist/astro/blocks/GridBlock.astro +2 -2
- package/dist/astro/blocks/HeroBlock.astro +2 -3
- package/dist/astro/blocks/ImageBlock.astro +2 -3
- package/dist/astro/blocks/ListItemFallback.astro +7 -5
- package/dist/astro/blocks/NumberSpinnerBlock.astro +24 -18
- package/dist/astro/blocks/SemanticElement.astro +35 -0
- package/dist/astro/blocks/SiteLogoBlock.astro +53 -0
- package/dist/astro/blocks/TextBlock.astro +27 -23
- package/dist/astro/blocks/ThemeToggleBlock.astro +23 -0
- package/dist/astro/blocks/helpers.d.ts +7 -0
- package/dist/astro/blocks/helpers.d.ts.map +1 -1
- package/dist/astro/blocks/helpers.js +51 -41
- package/dist/astro/blocks/helpers.js.map +1 -1
- package/dist/astro/blocks/helpers.ts +63 -45
- package/dist/block-renderers.d.ts +19 -2
- package/dist/block-renderers.d.ts.map +1 -1
- package/dist/block-renderers.js.map +1 -1
- package/dist/carousel.d.ts +22 -0
- package/dist/carousel.d.ts.map +1 -0
- package/dist/carousel.js +102 -0
- package/dist/carousel.js.map +1 -0
- package/dist/client.d.ts +2 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +31 -0
- package/dist/client.js.map +1 -1
- package/dist/composition.d.ts +14 -0
- package/dist/composition.d.ts.map +1 -0
- package/dist/composition.js +124 -0
- package/dist/composition.js.map +1 -0
- package/dist/default-blocks.d.ts +9 -0
- package/dist/default-blocks.d.ts.map +1 -0
- package/dist/default-blocks.js +54 -0
- package/dist/default-blocks.js.map +1 -0
- package/dist/env.d.ts +9 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +20 -0
- package/dist/env.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/links.d.ts +5 -0
- package/dist/links.d.ts.map +1 -0
- package/dist/links.js +32 -0
- package/dist/links.js.map +1 -0
- package/dist/media.d.ts +8 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +121 -0
- package/dist/media.js.map +1 -0
- package/dist/styleflow.d.ts +2 -0
- package/dist/styleflow.d.ts.map +1 -1
- package/dist/styleflow.js +47 -5
- package/dist/styleflow.js.map +1 -1
- package/dist/theme-runtime.d.ts +16 -0
- package/dist/theme-runtime.d.ts.map +1 -0
- package/dist/theme-runtime.js +77 -0
- package/dist/theme-runtime.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +84 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +9 -3
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AA2BA,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAGnC;IACA;IACA;IACA;IALX,YACE,OAAe,EACN,MAAe,EACf,MAAgC,EAChC,aAAsB,EACtB,QAAiB,EAC1B,KAAe;QAEf,KAAK,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QANnD,WAAM,GA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AAI;QAC9B,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC;QAChC,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC;KACjC,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAI,KAAgC,EAAE,QAAW;IACjE,IAAI,CAAC,KAAK;QAAE,OAAO,QAAQ,CAAC;IAC5B,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAM,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,QAAQ,CAAC;IAClB,CAAC;AACH,CAAC","sourcesContent":["import type {\n FlowpressCapabilities,\n FlowpressContent,\n FlowpressRoute\n} from \"./types.js\";\n\nexport interface FlowpressGraphqlIssue {\n message?: string;\n extensions?: {\n debugMessage?: string;\n category?: string;\n [key: string]: unknown;\n };\n}\n\ninterface GraphqlResponse<T> {\n data?: T;\n errors?: FlowpressGraphqlIssue[];\n}\n\nexport interface FlowpressClientOptions {\n endpoint: string;\n timeoutMs?: number;\n headers?: Record<string, string>;\n debug?: boolean;\n}\n\nexport class FlowpressGraphqlError extends Error {\n constructor(\n message: string,\n readonly status?: number,\n readonly errors?: FlowpressGraphqlIssue[],\n readonly operationName?: string,\n readonly endpoint?: string,\n cause?: unknown\n ) {\n super(message, cause === undefined ? undefined : { cause });\n this.name = \"FlowpressGraphqlError\";\n }\n}\n\nexport class FlowpressClient {\n readonly endpoint: string;\n readonly timeoutMs: number;\n readonly headers: Record<string, string>;\n readonly debug: boolean;\n\n constructor(options: FlowpressClientOptions) {\n const endpoint = options.endpoint.trim();\n if (!endpoint) {\n throw new Error(\"FlowPress GraphQL endpoint is required.\");\n }\n\n new URL(endpoint);\n this.endpoint = endpoint;\n this.timeoutMs = options.timeoutMs ?? 15_000;\n this.headers = { ...options.headers };\n this.debug = options.debug ?? false;\n }\n\n async request<T>(\n query: string,\n variables: Record<string, unknown> = {}\n ): Promise<T> {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeoutMs);\n const operationName = getOperationName(query);\n const safeEndpoint = sanitizeEndpoint(this.endpoint);\n\n try {\n let response: Response;\n try {\n response = await fetch(this.endpoint, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n ...this.headers\n },\n body: JSON.stringify({ query, variables }),\n signal: controller.signal\n });\n } catch (error) {\n const timedOut = controller.signal.aborted;\n const detail = error instanceof Error && error.message\n ? ` ${error.message}`\n : \"\";\n throw new FlowpressGraphqlError(\n timedOut\n ? `FlowPress GraphQL ${operationName} timed out after ${this.timeoutMs}ms at ${safeEndpoint}.`\n : `FlowPress GraphQL ${operationName} could not reach ${safeEndpoint}.${detail}`,\n undefined,\n undefined,\n operationName,\n safeEndpoint,\n error\n );\n }\n\n const body = await response.text();\n let payload: GraphqlResponse<T>;\n try {\n payload = JSON.parse(body) as GraphqlResponse<T>;\n } catch (error) {\n const contentType = response.headers.get(\"content-type\") || \"unknown content type\";\n throw new FlowpressGraphqlError(\n `FlowPress GraphQL ${operationName} returned ${response.status} `\n + `with ${contentType}, not JSON, from ${safeEndpoint}.`,\n response.status,\n undefined,\n operationName,\n safeEndpoint,\n error\n );\n }\n\n if (!response.ok || payload.errors?.length || payload.data === undefined) {\n const errors: FlowpressGraphqlIssue[] | undefined = payload.errors?.map(\n (error) => {\n if (this.debug) {\n return error;\n }\n return error.message ? { message: error.message } : {};\n }\n );\n const messages = errors\n ?.flatMap((error) => [\n error.message,\n this.debug ? error.extensions?.debugMessage : undefined\n ])\n .filter((message): message is string => Boolean(message));\n throw new FlowpressGraphqlError(\n messages?.join(\"; \")\n || `FlowPress GraphQL ${operationName} failed with ${response.status} at ${safeEndpoint}.`,\n response.status,\n errors,\n operationName,\n safeEndpoint\n );\n }\n\n return payload.data;\n } finally {\n clearTimeout(timer);\n }\n }\n\n async getCapabilities(): Promise<FlowpressCapabilities> {\n const data = await this.request<{ styleflowCapabilities: FlowpressCapabilities }>(\n `query FlowpressCapabilities {\n styleflowCapabilities {\n schemaVersion\n wpGraphql\n acfPro\n wpGraphqlAcf\n rankMath\n wpml\n woocommerce\n contactForm7\n defaultLocale\n locales { code slug homeUrl }\n features { id version enabled capabilities configJson }\n }\n }`\n );\n return {\n ...data.styleflowCapabilities,\n features: (data.styleflowCapabilities.features ?? []).map((feature) => {\n const wire = feature as typeof feature & { configJson?: string | null };\n let config: Record<string, unknown> = {};\n if (wire.configJson) {\n try {\n const parsed = JSON.parse(wire.configJson);\n if (parsed && typeof parsed === \"object\" && !Array.isArray(parsed)) {\n config = parsed as Record<string, unknown>;\n }\n } catch {\n config = {};\n }\n }\n return {\n id: feature.id,\n version: feature.version ?? null,\n enabled: feature.enabled,\n capabilities: feature.capabilities ?? [],\n config\n };\n })\n };\n }\n\n async getRoute(uri: string, locale?: string): Promise<FlowpressRoute | null> {\n const data = await this.request<{\n sfRouteByUri: (Omit<FlowpressRoute, \"seo\"> & {\n seo?: GraphqlSeo | null;\n }) | null;\n }>(\n `query FlowpressRoute($uri: String!, $locale: String) {\n sfRouteByUri(uri: $uri, locale: $locale) {\n uri status queryType locale isFrontPage isPostsPage frontPageMode\n postType taxonomy slug term databaseId termId authorNicename authorId\n pageTemplate mimeType postFormat templateCandidates\n content { loader databaseId termId }\n seo {\n title description canonicalUrl robots headHtml\n hreflang { locale url }\n jsonLd { raw }\n openGraph { title description image { url altText } }\n twitterMeta { title description image { url altText } }\n }\n }\n }`,\n { uri, locale: locale ?? null }\n );\n if (!data.sfRouteByUri) {\n return null;\n }\n return {\n ...data.sfRouteByUri,\n seo: normalizeGraphqlSeo(data.sfRouteByUri.seo)\n };\n }\n\n async getRoutes(locale?: string): Promise<FlowpressRoute[]> {\n const data = await this.request<{\n sfRoutes: Array<Omit<FlowpressRoute, \"seo\"> & {\n seo?: GraphqlSeo | null;\n }>;\n }>(\n `query FlowpressRoutes($locale: String) {\n sfRoutes(locale: $locale) {\n uri status queryType locale isFrontPage isPostsPage frontPageMode\n postType taxonomy slug term databaseId termId authorNicename authorId\n pageTemplate mimeType postFormat templateCandidates\n content { loader databaseId termId }\n seo {\n title description canonicalUrl robots headHtml\n hreflang { locale url }\n jsonLd { raw }\n openGraph { title description image { url altText } }\n twitterMeta { title description image { url altText } }\n }\n }\n }`,\n { locale: locale ?? null }\n );\n return data.sfRoutes.map((route) => ({\n ...route,\n seo: normalizeGraphqlSeo(route.seo)\n }));\n }\n\n async getContent(\n loader: string,\n variables: Record<string, unknown>\n ): Promise<FlowpressContent | null> {\n const data = await this.request<{\n sfContentByLoader: (Omit<FlowpressContent, \"contentBlocks\"> & {\n contentBlocksJson?: string | null;\n projectFieldsJson?: string | null;\n }) | null;\n }>(\n `query FlowpressContent(\n $loader: String!,\n $databaseId: Int,\n $termId: Int,\n $uri: String,\n $locale: String\n ) {\n sfContentByLoader(\n loader: $loader,\n databaseId: $databaseId,\n termId: $termId,\n uri: $uri,\n locale: $locale\n ) {\n title excerpt content contentBlocksJson projectFieldsJson\n }\n }`,\n {\n loader,\n databaseId: variables.databaseId ?? null,\n termId: variables.termId ?? null,\n uri: variables.uri ?? null,\n locale: variables.locale ?? null\n }\n );\n const content = data.sfContentByLoader;\n if (!content) {\n return null;\n }\n const { contentBlocksJson, projectFieldsJson, ...rest } = content;\n return {\n ...rest,\n contentBlocks: parseJson(contentBlocksJson, []),\n projectFields: parseJson(projectFieldsJson, {})\n };\n }\n}\n\nfunction getOperationName(query: string): string {\n return query.match(\n /\\b(?:query|mutation|subscription)\\s+([_A-Za-z][_0-9A-Za-z]*)/\n )?.[1] || \"AnonymousOperation\";\n}\n\nfunction sanitizeEndpoint(endpoint: string): string {\n const url = new URL(endpoint);\n url.username = \"\";\n url.password = \"\";\n url.search = \"\";\n url.hash = \"\";\n return url.toString();\n}\n\ninterface GraphqlSeo {\n title?: string | null;\n description?: string | null;\n canonicalUrl?: string | null;\n robots?: string[] | null;\n headHtml?: string | null;\n jsonLd?: { raw?: string | null } | null;\n openGraph?: GraphqlSocial | null;\n twitterMeta?: GraphqlSocial | null;\n hreflang?: Array<{ locale: string; url: string }> | null;\n}\n\ninterface GraphqlSocial {\n title?: string | null;\n description?: string | null;\n image?: { url: string; altText?: string | null } | null;\n}\n\nfunction normalizeGraphqlSeo(seo?: GraphqlSeo | null) {\n if (!seo) return null;\n const social = (value?: GraphqlSocial | null) => value\n ? {\n title: value.title ?? null,\n description: value.description ?? null,\n image: value.image\n ? { url: value.image.url, alt: value.image.altText ?? null }\n : null\n }\n : null;\n\n return {\n title: seo.title ?? null,\n description: seo.description ?? null,\n canonicalUrl: seo.canonicalUrl ?? null,\n robots: seo.robots ?? null,\n headHtml: seo.headHtml ?? null,\n jsonLd: parseJson(seo.jsonLd?.raw, null),\n hreflang: seo.hreflang ?? null,\n openGraph: social(seo.openGraph),\n twitter: social(seo.twitterMeta)\n };\n}\n\nfunction parseJson<T>(value: string | null | undefined, fallback: T): T {\n if (!value) return fallback;\n try {\n return JSON.parse(value) as T;\n } catch {\n return fallback;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AA4BA,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAGnC;IACA;IACA;IACA;IALX,YACE,OAAe,EACN,MAAe,EACf,MAAgC,EAChC,aAAsB,EACtB,QAAiB,EAC1B,KAAe;QAEf,KAAK,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QANnD,WAAM,GAAN,MAAM,CAAS;QACf,WAAM,GAAN,MAAM,CAA0B;QAChC,kBAAa,GAAb,aAAa,CAAS;QACtB,aAAQ,GAAR,QAAQ,CAAS;QAI1B,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AAED,MAAM,OAAO,eAAe;IACjB,QAAQ,CAAS;IACjB,SAAS,CAAS;IAClB,OAAO,CAAyB;IAChC,KAAK,CAAU;IAExB,YAAY,OAA+B;QAC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D,SAAS,EACT,SAAS,EACT,sBAAsB,EACtB,SAAS,EACT,KAAK,CACN,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import type {\n FlowpressCapabilities,\n FlowpressCompositionV1,\n FlowpressContent,\n FlowpressRoute\n} from \"./types.js\";\n\nexport interface FlowpressGraphqlIssue {\n message?: string;\n extensions?: {\n debugMessage?: string;\n category?: string;\n [key: string]: unknown;\n };\n}\n\ninterface GraphqlResponse<T> {\n data?: T;\n errors?: FlowpressGraphqlIssue[];\n}\n\nexport interface FlowpressClientOptions {\n endpoint: string;\n timeoutMs?: number;\n headers?: Record<string, string>;\n debug?: boolean;\n}\n\nexport class FlowpressGraphqlError extends Error {\n constructor(\n message: string,\n readonly status?: number,\n readonly errors?: FlowpressGraphqlIssue[],\n readonly operationName?: string,\n readonly endpoint?: string,\n cause?: unknown\n ) {\n super(message, cause === undefined ? undefined : { cause });\n this.name = \"FlowpressGraphqlError\";\n }\n}\n\nexport class FlowpressClient {\n readonly endpoint: string;\n readonly timeoutMs: number;\n readonly headers: Record<string, string>;\n readonly debug: boolean;\n\n constructor(options: FlowpressClientOptions) {\n const endpoint = options.endpoint.trim();\n if (!endpoint) {\n throw new Error(\"FlowPress GraphQL endpoint is required.\");\n }\n\n new URL(endpoint);\n this.endpoint = endpoint;\n this.timeoutMs = options.timeoutMs ?? 15_000;\n this.headers = { ...options.headers };\n this.debug = options.debug ?? false;\n }\n\n async request<T>(\n query: string,\n variables: Record<string, unknown> = {}\n ): Promise<T> {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeoutMs);\n const operationName = getOperationName(query);\n const safeEndpoint = sanitizeEndpoint(this.endpoint);\n\n try {\n let response: Response;\n try {\n response = await fetch(this.endpoint, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n ...this.headers\n },\n body: JSON.stringify({ query, variables }),\n signal: controller.signal\n });\n } catch (error) {\n const timedOut = controller.signal.aborted;\n const detail = error instanceof Error && error.message\n ? ` ${error.message}`\n : \"\";\n throw new FlowpressGraphqlError(\n timedOut\n ? `FlowPress GraphQL ${operationName} timed out after ${this.timeoutMs}ms at ${safeEndpoint}.`\n : `FlowPress GraphQL ${operationName} could not reach ${safeEndpoint}.${detail}`,\n undefined,\n undefined,\n operationName,\n safeEndpoint,\n error\n );\n }\n\n const body = await response.text();\n let payload: GraphqlResponse<T>;\n try {\n payload = JSON.parse(body) as GraphqlResponse<T>;\n } catch (error) {\n const contentType = response.headers.get(\"content-type\") || \"unknown content type\";\n throw new FlowpressGraphqlError(\n `FlowPress GraphQL ${operationName} returned ${response.status} `\n + `with ${contentType}, not JSON, from ${safeEndpoint}.`,\n response.status,\n undefined,\n operationName,\n safeEndpoint,\n error\n );\n }\n\n if (!response.ok || payload.errors?.length || payload.data === undefined) {\n const errors: FlowpressGraphqlIssue[] | undefined = payload.errors?.map(\n (error) => {\n if (this.debug) {\n return error;\n }\n return error.message ? { message: error.message } : {};\n }\n );\n const messages = errors\n ?.flatMap((error) => [\n error.message,\n this.debug ? error.extensions?.debugMessage : undefined\n ])\n .filter((message): message is string => Boolean(message));\n throw new FlowpressGraphqlError(\n messages?.join(\"; \")\n || `FlowPress GraphQL ${operationName} failed with ${response.status} at ${safeEndpoint}.`,\n response.status,\n errors,\n operationName,\n safeEndpoint\n );\n }\n\n return payload.data;\n } finally {\n clearTimeout(timer);\n }\n }\n\n async getCapabilities(): Promise<FlowpressCapabilities> {\n const data = await this.request<{ styleflowCapabilities: FlowpressCapabilities }>(\n `query FlowpressCapabilities {\n styleflowCapabilities {\n schemaVersion\n wpGraphql\n acfPro\n wpGraphqlAcf\n rankMath\n wpml\n woocommerce\n contactForm7\n defaultLocale\n locales { code slug homeUrl }\n features { id version enabled capabilities configJson }\n }\n }`\n );\n return {\n ...data.styleflowCapabilities,\n features: (data.styleflowCapabilities.features ?? []).map((feature) => {\n const wire = feature as typeof feature & { configJson?: string | null };\n let config: Record<string, unknown> = {};\n if (wire.configJson) {\n try {\n const parsed = JSON.parse(wire.configJson);\n if (parsed && typeof parsed === \"object\" && !Array.isArray(parsed)) {\n config = parsed as Record<string, unknown>;\n }\n } catch {\n config = {};\n }\n }\n return {\n id: feature.id,\n version: feature.version ?? null,\n enabled: feature.enabled,\n capabilities: feature.capabilities ?? [],\n config\n };\n })\n };\n }\n\n async getRoute(uri: string, locale?: string): Promise<FlowpressRoute | null> {\n const data = await this.request<{\n sfRouteByUri: (Omit<FlowpressRoute, \"seo\"> & {\n seo?: GraphqlSeo | null;\n }) | null;\n }>(\n `query FlowpressRoute($uri: String!, $locale: String) {\n sfRouteByUri(uri: $uri, locale: $locale) {\n uri status queryType locale isFrontPage isPostsPage frontPageMode\n postType taxonomy slug term databaseId termId authorNicename authorId\n pageTemplate mimeType postFormat templateCandidates\n content { loader databaseId termId }\n seo {\n title description canonicalUrl robots headHtml\n hreflang { locale url }\n jsonLd { raw }\n openGraph { title description image { url altText } }\n twitterMeta { title description image { url altText } }\n }\n }\n }`,\n { uri, locale: locale ?? null }\n );\n if (!data.sfRouteByUri) {\n return null;\n }\n return {\n ...data.sfRouteByUri,\n seo: normalizeGraphqlSeo(data.sfRouteByUri.seo)\n };\n }\n\n async getRoutes(locale?: string): Promise<FlowpressRoute[]> {\n const data = await this.request<{\n sfRoutes: Array<Omit<FlowpressRoute, \"seo\"> & {\n seo?: GraphqlSeo | null;\n }>;\n }>(\n `query FlowpressRoutes($locale: String) {\n sfRoutes(locale: $locale) {\n uri status queryType locale isFrontPage isPostsPage frontPageMode\n postType taxonomy slug term databaseId termId authorNicename authorId\n pageTemplate mimeType postFormat templateCandidates\n content { loader databaseId termId }\n seo {\n title description canonicalUrl robots headHtml\n hreflang { locale url }\n jsonLd { raw }\n openGraph { title description image { url altText } }\n twitterMeta { title description image { url altText } }\n }\n }\n }`,\n { locale: locale ?? null }\n );\n return data.sfRoutes.map((route) => ({\n ...route,\n seo: normalizeGraphqlSeo(route.seo)\n }));\n }\n\n async getContent(\n loader: string,\n variables: Record<string, unknown>\n ): Promise<FlowpressContent | null> {\n const data = await this.request<{\n sfContentByLoader: (Omit<FlowpressContent, \"contentBlocks\"> & {\n contentBlocksJson?: string | null;\n projectFieldsJson?: string | null;\n }) | null;\n }>(\n `query FlowpressContent(\n $loader: String!,\n $databaseId: Int,\n $termId: Int,\n $uri: String,\n $locale: String\n ) {\n sfContentByLoader(\n loader: $loader,\n databaseId: $databaseId,\n termId: $termId,\n uri: $uri,\n locale: $locale\n ) {\n title excerpt content contentBlocksJson projectFieldsJson\n }\n }`,\n {\n loader,\n databaseId: variables.databaseId ?? null,\n termId: variables.termId ?? null,\n uri: variables.uri ?? null,\n locale: variables.locale ?? null\n }\n );\n const content = data.sfContentByLoader;\n if (!content) {\n return null;\n }\n const { contentBlocksJson, projectFieldsJson, ...rest } = content;\n return {\n ...rest,\n contentBlocks: parseJson(contentBlocksJson, []),\n projectFields: parseJson(projectFieldsJson, {})\n };\n }\n\n async getComposition(uri: string, locale?: string): Promise<FlowpressCompositionV1 | null> {\n const data = await this.request<{\n sfCompositionByUri: null | {\n version: \"1\";\n sourceDigest: string;\n locale?: string | null;\n templateJson: string;\n blocksJson: string;\n stylesheetsJson: string;\n blockTypesJson: string;\n diagnosticsJson: string;\n routeJson: string;\n contentJson?: string | null;\n };\n }>(\n `query FlowpressComposition($uri: String!, $locale: String) {\n sfCompositionByUri(uri: $uri, locale: $locale) {\n version sourceDigest locale templateJson blocksJson stylesheetsJson blockTypesJson\n diagnosticsJson routeJson contentJson\n }\n }`,\n { uri, locale: locale ?? null }\n );\n const wire = data.sfCompositionByUri;\n if (!wire) return null;\n return {\n version: wire.version,\n sourceDigest: wire.sourceDigest,\n locale: wire.locale ?? null,\n template: parseRequiredJson(wire.templateJson, \"templateJson\"),\n blocks: parseRequiredJson(wire.blocksJson, \"blocksJson\"),\n stylesheets: parseRequiredJson(wire.stylesheetsJson, \"stylesheetsJson\"),\n blockTypes: parseRequiredJson(wire.blockTypesJson, \"blockTypesJson\"),\n diagnostics: parseRequiredJson(wire.diagnosticsJson, \"diagnosticsJson\"),\n route: parseRequiredJson(wire.routeJson, \"routeJson\"),\n content: parseJson(wire.contentJson, null)\n };\n }\n}\n\nfunction getOperationName(query: string): string {\n return query.match(\n /\\b(?:query|mutation|subscription)\\s+([_A-Za-z][_0-9A-Za-z]*)/\n )?.[1] || \"AnonymousOperation\";\n}\n\nfunction sanitizeEndpoint(endpoint: string): string {\n const url = new URL(endpoint);\n url.username = \"\";\n url.password = \"\";\n url.search = \"\";\n url.hash = \"\";\n return url.toString();\n}\n\ninterface GraphqlSeo {\n title?: string | null;\n description?: string | null;\n canonicalUrl?: string | null;\n robots?: string[] | null;\n headHtml?: string | null;\n jsonLd?: { raw?: string | null } | null;\n openGraph?: GraphqlSocial | null;\n twitterMeta?: GraphqlSocial | null;\n hreflang?: Array<{ locale: string; url: string }> | null;\n}\n\ninterface GraphqlSocial {\n title?: string | null;\n description?: string | null;\n image?: { url: string; altText?: string | null } | null;\n}\n\nfunction normalizeGraphqlSeo(seo?: GraphqlSeo | null) {\n if (!seo) return null;\n const social = (value?: GraphqlSocial | null) => value\n ? {\n title: value.title ?? null,\n description: value.description ?? null,\n image: value.image\n ? { url: value.image.url, alt: value.image.altText ?? null }\n : null\n }\n : null;\n\n return {\n title: seo.title ?? null,\n description: seo.description ?? null,\n canonicalUrl: seo.canonicalUrl ?? null,\n robots: seo.robots ?? null,\n headHtml: seo.headHtml ?? null,\n jsonLd: parseJson(seo.jsonLd?.raw, null),\n hreflang: seo.hreflang ?? null,\n openGraph: social(seo.openGraph),\n twitter: social(seo.twitterMeta)\n };\n}\n\nfunction parseJson<T>(value: string | null | undefined, fallback: T): T {\n if (!value) return fallback;\n try {\n return JSON.parse(value) as T;\n } catch {\n return fallback;\n }\n}\n\nfunction parseRequiredJson<T>(value: string, field: string): T {\n try {\n return JSON.parse(value) as T;\n } catch (error) {\n throw new FlowpressGraphqlError(\n `FlowPress composition field ${field} is not valid JSON.`,\n undefined,\n undefined,\n \"FlowpressComposition\",\n undefined,\n error\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FlowpressBlockAdapters } from "./block-renderers.js";
|
|
2
|
+
import type { FlowpressBlockAuthoringAttributes, FlowpressBlockHtmlProps, FlowpressBlockTypeDescriptor, FlowpressCompositionV1 } from "./types.js";
|
|
3
|
+
export declare function flowpressBlockHtmlProps(attributes: FlowpressBlockAuthoringAttributes): FlowpressBlockHtmlProps;
|
|
4
|
+
/** Structural logo visibility rules emitted once per composition. */
|
|
5
|
+
export declare function flowpressCompositionLogoStyles(composition: FlowpressCompositionV1): string;
|
|
6
|
+
export type FlowpressAdapterCompatibilityCode = "missing-adapter" | "draft-adapter" | "missing-descriptor" | "stale-adapter";
|
|
7
|
+
export interface FlowpressAdapterCompatibilityIssue {
|
|
8
|
+
code: FlowpressAdapterCompatibilityCode;
|
|
9
|
+
message: string;
|
|
10
|
+
command: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function flowpressBlockTypeDescriptors(composition: FlowpressCompositionV1): ReadonlyMap<string, FlowpressBlockTypeDescriptor>;
|
|
13
|
+
export declare function flowpressAdapterCompatibilityIssue(blockName: string, descriptors: ReadonlyMap<string, FlowpressBlockTypeDescriptor>, adapters: FlowpressBlockAdapters): FlowpressAdapterCompatibilityIssue | null;
|
|
14
|
+
//# sourceMappingURL=composition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composition.d.ts","sourceRoot":"","sources":["../src/composition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAEV,iCAAiC,EACjC,uBAAuB,EACvB,4BAA4B,EAC5B,sBAAsB,EACvB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,iCAAiC,GAC5C,uBAAuB,CAiCzB;AAiCD,qEAAqE;AACrE,wBAAgB,8BAA8B,CAC5C,WAAW,EAAE,sBAAsB,GAClC,MAAM,CAsBR;AAED,MAAM,MAAM,iCAAiC,GACzC,iBAAiB,GACjB,eAAe,GACf,oBAAoB,GACpB,eAAe,CAAC;AAEpB,MAAM,WAAW,kCAAkC;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,sBAAsB,GAClC,WAAW,CAAC,MAAM,EAAE,4BAA4B,CAAC,CAKnD;AAED,wBAAgB,kCAAkC,CAChD,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,4BAA4B,CAAC,EAC9D,QAAQ,EAAE,sBAAsB,GAC/B,kCAAkC,GAAG,IAAI,CAoC3C"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
export function flowpressBlockHtmlProps(attributes) {
|
|
2
|
+
const id = typeof attributes.anchor === "string" ? attributes.anchor.trim() : "";
|
|
3
|
+
const className = typeof attributes.className === "string"
|
|
4
|
+
? attributes.className.trim().replace(/\s+/g, " ")
|
|
5
|
+
: "";
|
|
6
|
+
const props = {
|
|
7
|
+
...(id ? { id } : {}),
|
|
8
|
+
...(className ? { class: className } : {})
|
|
9
|
+
};
|
|
10
|
+
const explicit = attributes.htmlAttributes;
|
|
11
|
+
if (explicit && typeof explicit === "object" && !Array.isArray(explicit)) {
|
|
12
|
+
for (const [name, value] of Object.entries(explicit)) {
|
|
13
|
+
const normalized = normalizeSupportedHtmlAttribute(name);
|
|
14
|
+
if (!normalized || normalized === "id" || normalized === "class")
|
|
15
|
+
continue;
|
|
16
|
+
if (["string", "number", "boolean"].includes(typeof value)) {
|
|
17
|
+
props[normalized] = value;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
for (const [attribute, htmlName] of [
|
|
22
|
+
["title", "title"],
|
|
23
|
+
["role", "role"],
|
|
24
|
+
["lang", "lang"],
|
|
25
|
+
["dir", "dir"],
|
|
26
|
+
["tabIndex", "tabindex"],
|
|
27
|
+
["ariaLabel", "aria-label"]
|
|
28
|
+
]) {
|
|
29
|
+
const value = attributes[attribute];
|
|
30
|
+
if (["string", "number", "boolean"].includes(typeof value)) {
|
|
31
|
+
props[htmlName] = value;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return props;
|
|
35
|
+
}
|
|
36
|
+
function normalizeSupportedHtmlAttribute(name) {
|
|
37
|
+
const normalized = name.trim().toLowerCase();
|
|
38
|
+
if (["title", "role", "lang", "dir", "tabindex", "hidden"].includes(normalized)) {
|
|
39
|
+
return normalized;
|
|
40
|
+
}
|
|
41
|
+
if (/^aria-[a-z0-9-]+$/.test(normalized))
|
|
42
|
+
return normalized;
|
|
43
|
+
if (/^data-[a-z0-9-]+$/.test(normalized)
|
|
44
|
+
&& !/^data-(?:color|surface|foreground|layout|text|interactive|styleflow|sf-)/.test(normalized)) {
|
|
45
|
+
return normalized;
|
|
46
|
+
}
|
|
47
|
+
return "";
|
|
48
|
+
}
|
|
49
|
+
function findLogoData(blocks) {
|
|
50
|
+
for (const block of blocks) {
|
|
51
|
+
if (block.name === "core/site-logo" && block.resolvedData) {
|
|
52
|
+
return block.resolvedData;
|
|
53
|
+
}
|
|
54
|
+
const nested = findLogoData(block.innerBlocks ?? []);
|
|
55
|
+
if (nested)
|
|
56
|
+
return nested;
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
/** Structural logo visibility rules emitted once per composition. */
|
|
61
|
+
export function flowpressCompositionLogoStyles(composition) {
|
|
62
|
+
const data = findLogoData(composition.blocks);
|
|
63
|
+
if (!data)
|
|
64
|
+
return "";
|
|
65
|
+
const fallback = data.fallback === "negative" ? "negative" : "positive";
|
|
66
|
+
const other = fallback === "positive" ? "negative" : "positive";
|
|
67
|
+
const lines = [
|
|
68
|
+
`:root{--flowpress-logo-${fallback}-display:block;--flowpress-logo-${other}-display:none}`,
|
|
69
|
+
".flowpress-site-logo__image--positive{display:var(--flowpress-logo-positive-display,none)}",
|
|
70
|
+
".flowpress-site-logo__image--negative{display:var(--flowpress-logo-negative-display,none)}"
|
|
71
|
+
];
|
|
72
|
+
for (const [theme, variant] of Object.entries(data.themeMap ?? {})) {
|
|
73
|
+
if (!/^[a-z0-9_-]+$/.test(theme))
|
|
74
|
+
continue;
|
|
75
|
+
const hidden = variant === "positive" ? "negative" : "positive";
|
|
76
|
+
lines.push(`[data-styleflow-theme="${theme}"]{--flowpress-logo-${variant}-display:block;--flowpress-logo-${hidden}-display:none}`);
|
|
77
|
+
}
|
|
78
|
+
lines.push('.flowpress-site-logo[data-flowpress-logo-override="positive"]{--flowpress-logo-positive-display:block;--flowpress-logo-negative-display:none}', '.flowpress-site-logo[data-flowpress-logo-override="negative"]{--flowpress-logo-positive-display:none;--flowpress-logo-negative-display:block}');
|
|
79
|
+
return lines.join("\n");
|
|
80
|
+
}
|
|
81
|
+
export function flowpressBlockTypeDescriptors(composition) {
|
|
82
|
+
return new Map(composition.blockTypes.map((descriptor) => [
|
|
83
|
+
descriptor.blockName,
|
|
84
|
+
descriptor
|
|
85
|
+
]));
|
|
86
|
+
}
|
|
87
|
+
export function flowpressAdapterCompatibilityIssue(blockName, descriptors, adapters) {
|
|
88
|
+
const adapter = adapters[blockName];
|
|
89
|
+
if (!adapter) {
|
|
90
|
+
const command = `pnpm cms:block-adapter ${blockName}`;
|
|
91
|
+
return {
|
|
92
|
+
code: "missing-adapter",
|
|
93
|
+
message: `Missing FlowPress block adapter for "${blockName}". Run ${command}.`,
|
|
94
|
+
command
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
if (adapter.status !== "ready") {
|
|
98
|
+
const command = `pnpm cms:block-adapter:approve ${blockName}`;
|
|
99
|
+
return {
|
|
100
|
+
code: "draft-adapter",
|
|
101
|
+
message: `FlowPress block adapter for "${blockName}" is draft. Run ${command}.`,
|
|
102
|
+
command
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
const descriptor = descriptors.get(blockName);
|
|
106
|
+
if (!descriptor) {
|
|
107
|
+
const command = "pnpm cms:block-adapters:check";
|
|
108
|
+
return {
|
|
109
|
+
code: "missing-descriptor",
|
|
110
|
+
message: `WordPress did not provide a block type descriptor for "${blockName}". Run ${command}.`,
|
|
111
|
+
command
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
if (descriptor.fingerprint !== adapter.fingerprint) {
|
|
115
|
+
const command = `pnpm cms:block-adapter ${blockName} --refresh-schema`;
|
|
116
|
+
return {
|
|
117
|
+
code: "stale-adapter",
|
|
118
|
+
message: `FlowPress block adapter for "${blockName}" has a stale schema fingerprint. Run ${command}.`,
|
|
119
|
+
command
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=composition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composition.js","sourceRoot":"","sources":["../src/composition.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,uBAAuB,CACrC,UAA6C;IAE7C,MAAM,EAAE,GAAG,OAAO,UAAU,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACjF,MAAM,SAAS,GAAG,OAAO,UAAU,CAAC,SAAS,KAAK,QAAQ;QACxD,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;QAClD,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,KAAK,GAA4B;QACrC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrB,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,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;QAC/B,MAAM,OAAO,GAAG,kCAAkC,SAAS,EAAE,CAAC;QAC9D,OAAO;YACL,IAAI,EAAE,eAAe;YACrB,OAAO,EAAE,gCAAgC,SAAS,mBAAmB,OAAO,GAAG;YAC/E,OAAO;SACR,CAAC;IACJ,CAAC;IACD,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC9C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,OAAO,GAAG,+BAA+B,CAAC;QAChD,OAAO;YACL,IAAI,EAAE,oBAAoB;YAC1B,OAAO,EAAE,0DAA0D,SAAS,UAAU,OAAO,GAAG;YAChG,OAAO;SACR,CAAC;IACJ,CAAC;IACD,IAAI,UAAU,CAAC,WAAW,KAAK,OAAO,CAAC,WAAW,EAAE,CAAC;QACnD,MAAM,OAAO,GAAG,0BAA0B,SAAS,mBAAmB,CAAC;QACvE,OAAO;YACL,IAAI,EAAE,eAAe;YACrB,OAAO,EAAE,gCAAgC,SAAS,yCAAyC,OAAO,GAAG;YACrG,OAAO;SACR,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { FlowpressBlockAdapters } from \"./block-renderers.js\";\nimport type {\n FlowpressBlock,\n FlowpressBlockAuthoringAttributes,\n FlowpressBlockHtmlProps,\n FlowpressBlockTypeDescriptor,\n FlowpressCompositionV1\n} from \"./types.js\";\n\nexport function flowpressBlockHtmlProps(\n attributes: FlowpressBlockAuthoringAttributes\n): FlowpressBlockHtmlProps {\n const id = typeof attributes.anchor === \"string\" ? attributes.anchor.trim() : \"\";\n const className = typeof attributes.className === \"string\"\n ? attributes.className.trim().replace(/\\s+/g, \" \")\n : \"\";\n const props: FlowpressBlockHtmlProps = {\n ...(id ? { id } : {}),\n ...(className ? { class: className } : {})\n };\n const explicit = attributes.htmlAttributes;\n if (explicit && typeof explicit === \"object\" && !Array.isArray(explicit)) {\n for (const [name, value] of Object.entries(explicit)) {\n const normalized = normalizeSupportedHtmlAttribute(name);\n if (!normalized || normalized === \"id\" || normalized === \"class\") continue;\n if ([\"string\", \"number\", \"boolean\"].includes(typeof value)) {\n props[normalized] = value as string | number | boolean;\n }\n }\n }\n for (const [attribute, htmlName] of [\n [\"title\", \"title\"],\n [\"role\", \"role\"],\n [\"lang\", \"lang\"],\n [\"dir\", \"dir\"],\n [\"tabIndex\", \"tabindex\"],\n [\"ariaLabel\", \"aria-label\"]\n ] as const) {\n const value = attributes[attribute];\n if ([\"string\", \"number\", \"boolean\"].includes(typeof value)) {\n props[htmlName] = value as string | number | boolean;\n }\n }\n return props;\n}\n\nfunction normalizeSupportedHtmlAttribute(name: string): string {\n const normalized = name.trim().toLowerCase();\n if ([\"title\", \"role\", \"lang\", \"dir\", \"tabindex\", \"hidden\"].includes(normalized)) {\n return normalized;\n }\n if (/^aria-[a-z0-9-]+$/.test(normalized)) return normalized;\n if (\n /^data-[a-z0-9-]+$/.test(normalized)\n && !/^data-(?:color|surface|foreground|layout|text|interactive|styleflow|sf-)/.test(normalized)\n ) {\n return normalized;\n }\n return \"\";\n}\n\ntype LogoResolvedData = {\n themeMap?: Record<string, \"positive\" | \"negative\">;\n fallback?: \"positive\" | \"negative\";\n};\n\nfunction findLogoData(blocks: FlowpressBlock[]): LogoResolvedData | null {\n for (const block of blocks) {\n if (block.name === \"core/site-logo\" && block.resolvedData) {\n return block.resolvedData as LogoResolvedData;\n }\n const nested = findLogoData(block.innerBlocks ?? []);\n if (nested) return nested;\n }\n return null;\n}\n\n/** Structural logo visibility rules emitted once per composition. */\nexport function flowpressCompositionLogoStyles(\n composition: FlowpressCompositionV1\n): string {\n const data = findLogoData(composition.blocks);\n if (!data) return \"\";\n const fallback = data.fallback === \"negative\" ? \"negative\" : \"positive\";\n const other = fallback === \"positive\" ? \"negative\" : \"positive\";\n const lines = [\n `:root{--flowpress-logo-${fallback}-display:block;--flowpress-logo-${other}-display:none}`,\n \".flowpress-site-logo__image--positive{display:var(--flowpress-logo-positive-display,none)}\",\n \".flowpress-site-logo__image--negative{display:var(--flowpress-logo-negative-display,none)}\"\n ];\n for (const [theme, variant] of Object.entries(data.themeMap ?? {})) {\n if (!/^[a-z0-9_-]+$/.test(theme)) continue;\n const hidden = variant === \"positive\" ? \"negative\" : \"positive\";\n lines.push(\n `[data-styleflow-theme=\"${theme}\"]{--flowpress-logo-${variant}-display:block;--flowpress-logo-${hidden}-display:none}`\n );\n }\n lines.push(\n '.flowpress-site-logo[data-flowpress-logo-override=\"positive\"]{--flowpress-logo-positive-display:block;--flowpress-logo-negative-display:none}',\n '.flowpress-site-logo[data-flowpress-logo-override=\"negative\"]{--flowpress-logo-positive-display:none;--flowpress-logo-negative-display:block}'\n );\n return lines.join(\"\\n\");\n}\n\nexport type FlowpressAdapterCompatibilityCode =\n | \"missing-adapter\"\n | \"draft-adapter\"\n | \"missing-descriptor\"\n | \"stale-adapter\";\n\nexport interface FlowpressAdapterCompatibilityIssue {\n code: FlowpressAdapterCompatibilityCode;\n message: string;\n command: string;\n}\n\nexport function flowpressBlockTypeDescriptors(\n composition: FlowpressCompositionV1\n): ReadonlyMap<string, FlowpressBlockTypeDescriptor> {\n return new Map(composition.blockTypes.map((descriptor) => [\n descriptor.blockName,\n descriptor\n ]));\n}\n\nexport function flowpressAdapterCompatibilityIssue(\n blockName: string,\n descriptors: ReadonlyMap<string, FlowpressBlockTypeDescriptor>,\n adapters: FlowpressBlockAdapters\n): FlowpressAdapterCompatibilityIssue | null {\n const adapter = adapters[blockName];\n if (!adapter) {\n const command = `pnpm cms:block-adapter ${blockName}`;\n return {\n code: \"missing-adapter\",\n message: `Missing FlowPress block adapter for \"${blockName}\". Run ${command}.`,\n command\n };\n }\n if (adapter.status !== \"ready\") {\n const command = `pnpm cms:block-adapter:approve ${blockName}`;\n return {\n code: \"draft-adapter\",\n message: `FlowPress block adapter for \"${blockName}\" is draft. Run ${command}.`,\n command\n };\n }\n const descriptor = descriptors.get(blockName);\n if (!descriptor) {\n const command = \"pnpm cms:block-adapters:check\";\n return {\n code: \"missing-descriptor\",\n message: `WordPress did not provide a block type descriptor for \"${blockName}\". Run ${command}.`,\n command\n };\n }\n if (descriptor.fingerprint !== adapter.fingerprint) {\n const command = `pnpm cms:block-adapter ${blockName} --refresh-schema`;\n return {\n code: \"stale-adapter\",\n message: `FlowPress block adapter for \"${blockName}\" has a stale schema fingerprint. Run ${command}.`,\n command\n };\n }\n return null;\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const FLOWPRESS_DEFAULT_BLOCK_CATALOG_VERSION: "1";
|
|
2
|
+
export interface FlowpressDefaultBlockCatalogEntry {
|
|
3
|
+
blockName: string;
|
|
4
|
+
template: "DefaultBlockAdapter.astro";
|
|
5
|
+
}
|
|
6
|
+
export declare const flowpressDefaultBlockCatalog: readonly FlowpressDefaultBlockCatalogEntry[];
|
|
7
|
+
export declare function hasFlowpressDefaultBlockAdapter(blockName: string): boolean;
|
|
8
|
+
export declare function createFlowpressDefaultBlockAdapterSource(blockName: string): string;
|
|
9
|
+
//# sourceMappingURL=default-blocks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-blocks.d.ts","sourceRoot":"","sources":["../src/default-blocks.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uCAAuC,EAAG,GAAY,CAAC;AAEpE,MAAM,WAAW,iCAAiC;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,2BAA2B,CAAC;CACvC;AAoCD,eAAO,MAAM,4BAA4B,EAAE,SAAS,iCAAiC,EACE,CAAC;AAIxF,wBAAgB,+BAA+B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAE1E;AAED,wBAAgB,wCAAwC,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAalF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export const FLOWPRESS_DEFAULT_BLOCK_CATALOG_VERSION = "1";
|
|
2
|
+
const blockNames = [
|
|
3
|
+
"core/group",
|
|
4
|
+
"core/heading",
|
|
5
|
+
"core/list",
|
|
6
|
+
"core/list-item",
|
|
7
|
+
"core/paragraph",
|
|
8
|
+
"core/quote",
|
|
9
|
+
"sf/accordion-item",
|
|
10
|
+
"sf/button",
|
|
11
|
+
"sf/card",
|
|
12
|
+
"sf/carousel",
|
|
13
|
+
"sf/carousel-item",
|
|
14
|
+
"sf/chip",
|
|
15
|
+
"sf/code",
|
|
16
|
+
"sf/column",
|
|
17
|
+
"sf/content-list",
|
|
18
|
+
"sf/form",
|
|
19
|
+
"sf/gallery",
|
|
20
|
+
"sf/grid",
|
|
21
|
+
"sf/heading",
|
|
22
|
+
"sf/hero",
|
|
23
|
+
"sf/icon",
|
|
24
|
+
"sf/image",
|
|
25
|
+
"sf/map",
|
|
26
|
+
"sf/number-spinner",
|
|
27
|
+
"sf/quote",
|
|
28
|
+
"sf/rich-text",
|
|
29
|
+
"sf/section",
|
|
30
|
+
"sf/template",
|
|
31
|
+
"sf/term-list",
|
|
32
|
+
"sf/video",
|
|
33
|
+
"sf/video-youtube"
|
|
34
|
+
];
|
|
35
|
+
export const flowpressDefaultBlockCatalog = blockNames.map((blockName) => ({ blockName, template: "DefaultBlockAdapter.astro" }));
|
|
36
|
+
const supported = new Set(blockNames);
|
|
37
|
+
export function hasFlowpressDefaultBlockAdapter(blockName) {
|
|
38
|
+
return supported.has(blockName);
|
|
39
|
+
}
|
|
40
|
+
export function createFlowpressDefaultBlockAdapterSource(blockName) {
|
|
41
|
+
if (!hasFlowpressDefaultBlockAdapter(blockName)) {
|
|
42
|
+
throw new Error(`FlowPress has no official default adapter for ${blockName}.`);
|
|
43
|
+
}
|
|
44
|
+
return `---
|
|
45
|
+
import DefaultBlockAdapter from "@styleflow.app/flowpress-astro-core/DefaultBlockAdapter.astro";
|
|
46
|
+
import type { FlowpressBlockRendererProps } from "@styleflow.app/flowpress-astro-core";
|
|
47
|
+
|
|
48
|
+
const props = Astro.props as FlowpressBlockRendererProps;
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
<DefaultBlockAdapter {...props} />
|
|
52
|
+
`;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=default-blocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-blocks.js","sourceRoot":"","sources":["../src/default-blocks.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uCAAuC,GAAG,GAAY,CAAC;AAOpE,MAAM,UAAU,GAAG;IACjB,YAAY;IACZ,cAAc;IACd,WAAW;IACX,gBAAgB;IAChB,gBAAgB;IAChB,YAAY;IACZ,mBAAmB;IACnB,WAAW;IACX,SAAS;IACT,aAAa;IACb,kBAAkB;IAClB,SAAS;IACT,SAAS;IACT,WAAW;IACX,iBAAiB;IACjB,SAAS;IACT,YAAY;IACZ,SAAS;IACT,YAAY;IACZ,SAAS;IACT,SAAS;IACT,UAAU;IACV,QAAQ;IACR,mBAAmB;IACnB,UAAU;IACV,cAAc;IACd,YAAY;IACZ,aAAa;IACb,cAAc;IACd,UAAU;IACV,kBAAkB;CACV,CAAC;AAEX,MAAM,CAAC,MAAM,4BAA4B,GACvC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,2BAA2B,EAAE,CAAC,CAAC,CAAC;AAExF,MAAM,SAAS,GAAG,IAAI,GAAG,CAAS,UAAU,CAAC,CAAC;AAE9C,MAAM,UAAU,+BAA+B,CAAC,SAAiB;IAC/D,OAAO,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,wCAAwC,CAAC,SAAiB;IACxE,IAAI,CAAC,+BAA+B,CAAC,SAAS,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,iDAAiD,SAAS,GAAG,CAAC,CAAC;IACjF,CAAC;IACD,OAAO;;;;;;;;CAQR,CAAC;AACF,CAAC","sourcesContent":["export const FLOWPRESS_DEFAULT_BLOCK_CATALOG_VERSION = \"1\" as const;\n\nexport interface FlowpressDefaultBlockCatalogEntry {\n blockName: string;\n template: \"DefaultBlockAdapter.astro\";\n}\n\nconst blockNames = [\n \"core/group\",\n \"core/heading\",\n \"core/list\",\n \"core/list-item\",\n \"core/paragraph\",\n \"core/quote\",\n \"sf/accordion-item\",\n \"sf/button\",\n \"sf/card\",\n \"sf/carousel\",\n \"sf/carousel-item\",\n \"sf/chip\",\n \"sf/code\",\n \"sf/column\",\n \"sf/content-list\",\n \"sf/form\",\n \"sf/gallery\",\n \"sf/grid\",\n \"sf/heading\",\n \"sf/hero\",\n \"sf/icon\",\n \"sf/image\",\n \"sf/map\",\n \"sf/number-spinner\",\n \"sf/quote\",\n \"sf/rich-text\",\n \"sf/section\",\n \"sf/template\",\n \"sf/term-list\",\n \"sf/video\",\n \"sf/video-youtube\"\n] as const;\n\nexport const flowpressDefaultBlockCatalog: readonly FlowpressDefaultBlockCatalogEntry[] =\n blockNames.map((blockName) => ({ blockName, template: \"DefaultBlockAdapter.astro\" }));\n\nconst supported = new Set<string>(blockNames);\n\nexport function hasFlowpressDefaultBlockAdapter(blockName: string): boolean {\n return supported.has(blockName);\n}\n\nexport function createFlowpressDefaultBlockAdapterSource(blockName: string): string {\n if (!hasFlowpressDefaultBlockAdapter(blockName)) {\n throw new Error(`FlowPress has no official default adapter for ${blockName}.`);\n }\n return `---\nimport DefaultBlockAdapter from \"@styleflow.app/flowpress-astro-core/DefaultBlockAdapter.astro\";\nimport type { FlowpressBlockRendererProps } from \"@styleflow.app/flowpress-astro-core\";\n\nconst props = Astro.props as FlowpressBlockRendererProps;\n---\n\n<DefaultBlockAdapter {...props} />\n`;\n}\n"]}
|
package/dist/env.d.ts
CHANGED
|
@@ -6,8 +6,17 @@ export interface FlowpressEnvironment {
|
|
|
6
6
|
outputMode: AstroOutputMode;
|
|
7
7
|
siteUrl: string;
|
|
8
8
|
backendUrl: string;
|
|
9
|
+
mediaUrl: string;
|
|
9
10
|
graphqlUrl: string;
|
|
10
11
|
localAstroPort: number;
|
|
11
12
|
}
|
|
13
|
+
export interface FlowpressMediaRemotePattern {
|
|
14
|
+
protocol: "http" | "https";
|
|
15
|
+
hostname: string;
|
|
16
|
+
port?: string;
|
|
17
|
+
pathname: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function resolveFlowpressMediaUrl(env: NodeJS.ProcessEnv): string;
|
|
20
|
+
export declare function flowpressMediaRemotePattern(env: NodeJS.ProcessEnv): FlowpressMediaRemotePattern;
|
|
12
21
|
export declare function readFlowpressEnvironment(env?: NodeJS.ProcessEnv): FlowpressEnvironment;
|
|
13
22
|
//# sourceMappingURL=env.d.ts.map
|
package/dist/env.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAElD,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,eAAe,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;CACxB;AA0BD,wBAAgB,wBAAwB,CACtC,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,oBAAoB,
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAElD,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,eAAe,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,CAQvE;AAED,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,MAAM,CAAC,UAAU,GACrB,2BAA2B,CAS7B;AA0BD,wBAAgB,wBAAwB,CACtC,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,oBAAoB,CAuBtB"}
|
package/dist/env.js
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
export function resolveFlowpressMediaUrl(env) {
|
|
2
|
+
const key = env.FLOWPRESS_MEDIA?.trim() ? "FLOWPRESS_MEDIA" : "BACKEND_URL";
|
|
3
|
+
const value = validUrl(required(env, key), key);
|
|
4
|
+
const url = new URL(value);
|
|
5
|
+
if (url.username || url.password || url.search || url.hash) {
|
|
6
|
+
throw new Error(`${key} must not contain credentials, query, or fragment.`);
|
|
7
|
+
}
|
|
8
|
+
return url.toString().replace(/\/+$/, "");
|
|
9
|
+
}
|
|
10
|
+
export function flowpressMediaRemotePattern(env) {
|
|
11
|
+
const url = new URL(resolveFlowpressMediaUrl(env));
|
|
12
|
+
const basePath = url.pathname.replace(/\/+$/, "");
|
|
13
|
+
return {
|
|
14
|
+
protocol: url.protocol.slice(0, -1),
|
|
15
|
+
hostname: url.hostname,
|
|
16
|
+
...(url.port ? { port: url.port } : {}),
|
|
17
|
+
pathname: basePath ? `${basePath}/**` : "/**"
|
|
18
|
+
};
|
|
19
|
+
}
|
|
1
20
|
function required(env, key) {
|
|
2
21
|
const value = env[key]?.trim();
|
|
3
22
|
if (!value) {
|
|
@@ -32,6 +51,7 @@ export function readFlowpressEnvironment(env = process.env) {
|
|
|
32
51
|
outputMode,
|
|
33
52
|
siteUrl: validUrl(required(env, "SITE_URL"), "SITE_URL"),
|
|
34
53
|
backendUrl: validUrl(required(env, "BACKEND_URL"), "BACKEND_URL"),
|
|
54
|
+
mediaUrl: resolveFlowpressMediaUrl(env),
|
|
35
55
|
graphqlUrl: validUrl(required(env, "BACKEND_GRAPHQL_URL"), "BACKEND_GRAPHQL_URL"),
|
|
36
56
|
localAstroPort: port(required(env, "LOCAL_ASTRO_PORT"), "LOCAL_ASTRO_PORT")
|
|
37
57
|
};
|
package/dist/env.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAqBA,MAAM,UAAU,wBAAwB,CAAC,GAAsB;IAC7D,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,aAAa,CAAC;IAC5E,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAChD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IAC3B,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;QAC3D,MAAM,IAAI,KAAK,CAAC,GAAG,GAAG,oDAAoD,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,MAA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Name: string;\n projectSlug: string;\n outputMode: AstroOutputMode;\n siteUrl: string;\n backendUrl: string;\n mediaUrl: string;\n graphqlUrl: string;\n localAstroPort: number;\n}\n\nexport interface FlowpressMediaRemotePattern {\n protocol: \"http\" | \"https\";\n hostname: string;\n port?: string;\n pathname: string;\n}\n\nexport function resolveFlowpressMediaUrl(env: NodeJS.ProcessEnv): string {\n const key = env.FLOWPRESS_MEDIA?.trim() ? \"FLOWPRESS_MEDIA\" : \"BACKEND_URL\";\n const value = validUrl(required(env, key), key);\n const url = new URL(value);\n if (url.username || url.password || url.search || url.hash) {\n throw new Error(`${key} must not contain credentials, query, or fragment.`);\n }\n return url.toString().replace(/\\/+$/, \"\");\n}\n\nexport function flowpressMediaRemotePattern(\n env: NodeJS.ProcessEnv\n): FlowpressMediaRemotePattern {\n const url = new URL(resolveFlowpressMediaUrl(env));\n const basePath = url.pathname.replace(/\\/+$/, \"\");\n return {\n protocol: url.protocol.slice(0, -1) as \"http\" | \"https\",\n hostname: url.hostname,\n ...(url.port ? { port: url.port } : {}),\n pathname: basePath ? `${basePath}/**` : \"/**\"\n };\n}\n\nfunction required(env: NodeJS.ProcessEnv, key: string): string {\n const value = env[key]?.trim();\n if (!value) {\n throw new Error(`Missing required environment variable ${key}.`);\n }\n return value;\n}\n\nfunction validUrl(value: string, key: string): string {\n try {\n return new URL(value).toString().replace(/\\/$/, \"\");\n } catch {\n throw new Error(`${key} must be an absolute URL.`);\n }\n}\n\nfunction port(value: string, key: string): number {\n const parsed = Number.parseInt(value, 10);\n if (!Number.isInteger(parsed) || parsed < 1 || parsed > 65_535) {\n throw new Error(`${key} must be a valid TCP port.`);\n }\n return parsed;\n}\n\nexport function readFlowpressEnvironment(\n env: NodeJS.ProcessEnv = process.env\n): FlowpressEnvironment {\n const outputMode = required(env, \"ASTRO_OUTPUT_MODE\");\n if (outputMode !== \"static\" && outputMode !== \"server\") {\n throw new Error(\"ASTRO_OUTPUT_MODE must be static or server.\");\n }\n\n return {\n appEnv: required(env, \"APP_ENV\"),\n projectName: required(env, \"PROJECT_NAME\"),\n projectSlug: required(env, \"PROJECT_SLUG\"),\n outputMode,\n siteUrl: validUrl(required(env, \"SITE_URL\"), \"SITE_URL\"),\n backendUrl: validUrl(required(env, \"BACKEND_URL\"), \"BACKEND_URL\"),\n mediaUrl: resolveFlowpressMediaUrl(env),\n graphqlUrl: validUrl(\n required(env, \"BACKEND_GRAPHQL_URL\"),\n \"BACKEND_GRAPHQL_URL\"\n ),\n localAstroPort: port(\n required(env, \"LOCAL_ASTRO_PORT\"),\n \"LOCAL_ASTRO_PORT\"\n )\n };\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
export * from "./client.js";
|
|
2
|
+
export * from "./carousel.js";
|
|
2
3
|
export * from "./block-renderers.js";
|
|
4
|
+
export * from "./composition.js";
|
|
5
|
+
export * from "./default-blocks.js";
|
|
3
6
|
export * from "./env.js";
|
|
7
|
+
export * from "./links.js";
|
|
8
|
+
export * from "./media.js";
|
|
4
9
|
export * from "./number-spinner.js";
|
|
5
10
|
export * from "./styleflow.js";
|
|
6
11
|
export * from "./style-classes.js";
|
|
7
12
|
export * from "./template-hierarchy.js";
|
|
13
|
+
export * from "./theme-runtime.js";
|
|
8
14
|
export * from "./types.js";
|
|
9
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
export * from "./client.js";
|
|
2
|
+
export * from "./carousel.js";
|
|
2
3
|
export * from "./block-renderers.js";
|
|
4
|
+
export * from "./composition.js";
|
|
5
|
+
export * from "./default-blocks.js";
|
|
3
6
|
export * from "./env.js";
|
|
7
|
+
export * from "./links.js";
|
|
8
|
+
export * from "./media.js";
|
|
4
9
|
export * from "./number-spinner.js";
|
|
5
10
|
export * from "./styleflow.js";
|
|
6
11
|
export * from "./style-classes.js";
|
|
7
12
|
export * from "./template-hierarchy.js";
|
|
13
|
+
export * from "./theme-runtime.js";
|
|
8
14
|
export * from "./types.js";
|
|
9
15
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,YAAY,CAAC","sourcesContent":["export * from \"./client.js\";\nexport * from \"./block-renderers.js\";\nexport * from \"./env.js\";\nexport * from \"./number-spinner.js\";\nexport * from \"./styleflow.js\";\nexport * from \"./style-classes.js\";\nexport * from \"./template-hierarchy.js\";\nexport * from \"./types.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC","sourcesContent":["export * from \"./client.js\";\nexport * from \"./carousel.js\";\nexport * from \"./block-renderers.js\";\nexport * from \"./composition.js\";\nexport * from \"./default-blocks.js\";\nexport * from \"./env.js\";\nexport * from \"./links.js\";\nexport * from \"./media.js\";\nexport * from \"./number-spinner.js\";\nexport * from \"./styleflow.js\";\nexport * from \"./style-classes.js\";\nexport * from \"./template-hierarchy.js\";\nexport * from \"./theme-runtime.js\";\nexport * from \"./types.js\";\n"]}
|
package/dist/links.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FlowpressLinkValue } from "./types.js";
|
|
2
|
+
export declare function flowpressLinkValue(value: unknown): FlowpressLinkValue | null;
|
|
3
|
+
/** Return only a browser-safe, resolved href. A bare # always fails closed. */
|
|
4
|
+
export declare function flowpressLinkHref(value: unknown): string;
|
|
5
|
+
//# sourceMappingURL=links.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AASrD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,kBAAkB,GAAG,IAAI,CAa5E;AAED,+EAA+E;AAC/E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAOxD"}
|
package/dist/links.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const VALID_HREF = /^(?:\/(?!\/)|#[^#\s]+$|https?:\/\/|mailto:|tel:)/i;
|
|
2
|
+
const FAILED_RESOLUTIONS = new Set([
|
|
3
|
+
"missing_translation",
|
|
4
|
+
"missing_entity",
|
|
5
|
+
"invalid"
|
|
6
|
+
]);
|
|
7
|
+
export function flowpressLinkValue(value) {
|
|
8
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
9
|
+
return null;
|
|
10
|
+
const candidate = value;
|
|
11
|
+
return {
|
|
12
|
+
kind: String(candidate.kind ?? "custom"),
|
|
13
|
+
type: String(candidate.type ?? "custom"),
|
|
14
|
+
id: typeof candidate.id === "number" || typeof candidate.id === "string"
|
|
15
|
+
? candidate.id
|
|
16
|
+
: null,
|
|
17
|
+
url: typeof candidate.url === "string" ? candidate.url : null,
|
|
18
|
+
opensInNewTab: Boolean(candidate.opensInNewTab),
|
|
19
|
+
resolution: String(candidate.resolution ?? "legacy_raw")
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/** Return only a browser-safe, resolved href. A bare # always fails closed. */
|
|
23
|
+
export function flowpressLinkHref(value) {
|
|
24
|
+
const relation = flowpressLinkValue(value);
|
|
25
|
+
if (relation && FAILED_RESOLUTIONS.has(relation.resolution))
|
|
26
|
+
return "";
|
|
27
|
+
const href = typeof value === "string"
|
|
28
|
+
? value.trim()
|
|
29
|
+
: String(relation?.url ?? "").trim();
|
|
30
|
+
return href !== "#" && VALID_HREF.test(href) ? href : "";
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=links.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"links.js","sourceRoot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,IAAI,EAAE;QACd,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACvC,OAAO,IAAI,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;AAC3D,CAAC","sourcesContent":["import type { FlowpressLinkValue } from \"./types.js\";\n\nconst VALID_HREF = /^(?:\\/(?!\\/)|#[^#\\s]+$|https?:\\/\\/|mailto:|tel:)/i;\nconst FAILED_RESOLUTIONS = new Set([\n \"missing_translation\",\n \"missing_entity\",\n \"invalid\"\n]);\n\nexport function flowpressLinkValue(value: unknown): FlowpressLinkValue | null {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return null;\n const candidate = value as Partial<FlowpressLinkValue>;\n return {\n kind: String(candidate.kind ?? \"custom\"),\n type: String(candidate.type ?? \"custom\"),\n id: typeof candidate.id === \"number\" || typeof candidate.id === \"string\"\n ? candidate.id\n : null,\n url: typeof candidate.url === \"string\" ? candidate.url : null,\n opensInNewTab: Boolean(candidate.opensInNewTab),\n resolution: String(candidate.resolution ?? \"legacy_raw\") as FlowpressLinkValue[\"resolution\"]\n };\n}\n\n/** Return only a browser-safe, resolved href. A bare # always fails closed. */\nexport function flowpressLinkHref(value: unknown): string {\n const relation = flowpressLinkValue(value);\n if (relation && FAILED_RESOLUTIONS.has(relation.resolution)) return \"\";\n const href = typeof value === \"string\"\n ? value.trim()\n : String(relation?.url ?? \"\").trim();\n return href !== \"#\" && VALID_HREF.test(href) ? href : \"\";\n}\n"]}
|
package/dist/media.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const FLOWPRESS_UPLOADS_PREFIX = "/app/uploads/";
|
|
2
|
+
export declare const FLOWPRESS_MEDIA_PREFIX = "/media/";
|
|
3
|
+
export declare function isFlowpressUploadPath(pathname: string): boolean;
|
|
4
|
+
export declare function isFlowpressMediaPath(pathname: string): boolean;
|
|
5
|
+
export declare function rewriteFlowpressBackendUrl(value: string, backendUrl: string, frontendOrigin?: string): string;
|
|
6
|
+
export declare function proxyFlowpressUpload(request: Request, backendUrl: string, fetchImpl?: typeof fetch): Promise<Response>;
|
|
7
|
+
export declare function proxyFlowpressMedia(request: Request, mediaUrl: string, fetchImpl?: typeof fetch): Promise<Response>;
|
|
8
|
+
//# sourceMappingURL=media.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,kBAAkB,CAAC;AACxD,eAAO,MAAM,sBAAsB,YAAY,CAAC;AAwBhD,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAG/D;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAG9D;AAED,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,cAAc,SAAK,GAClB,MAAM,CASR;AAuDD,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,EAClB,SAAS,GAAE,OAAO,KAAa,GAC9B,OAAO,CAAC,QAAQ,CAAC,CAMnB;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,SAAS,GAAE,OAAO,KAAa,GAC9B,OAAO,CAAC,QAAQ,CAAC,CAMnB"}
|