@teleporthq/teleport-shared 0.43.61 → 0.43.63

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.
Files changed (78) hide show
  1. package/__tests__/utils/font-preconnect.ts +62 -0
  2. package/__tests__/utils/rich-text-embeds-runtime-module.ts +124 -0
  3. package/__tests__/utils/rich-text-embeds.ts +254 -0
  4. package/dist/cjs/index.d.ts +6 -1
  5. package/dist/cjs/index.d.ts.map +1 -1
  6. package/dist/cjs/index.js +11 -1
  7. package/dist/cjs/index.js.map +1 -1
  8. package/dist/cjs/page-revalidate/api-route.d.ts +24 -0
  9. package/dist/cjs/page-revalidate/api-route.d.ts.map +1 -0
  10. package/dist/cjs/page-revalidate/api-route.js +30 -0
  11. package/dist/cjs/page-revalidate/api-route.js.map +1 -0
  12. package/dist/cjs/page-revalidate/constants.d.ts +22 -0
  13. package/dist/cjs/page-revalidate/constants.d.ts.map +1 -0
  14. package/dist/cjs/page-revalidate/constants.js +25 -0
  15. package/dist/cjs/page-revalidate/constants.js.map +1 -0
  16. package/dist/cjs/page-revalidate/index.d.ts +3 -0
  17. package/dist/cjs/page-revalidate/index.d.ts.map +1 -0
  18. package/dist/cjs/page-revalidate/index.js +19 -0
  19. package/dist/cjs/page-revalidate/index.js.map +1 -0
  20. package/dist/cjs/tsconfig.tsbuildinfo +1 -1
  21. package/dist/cjs/utils/font-preconnect.d.ts +40 -0
  22. package/dist/cjs/utils/font-preconnect.d.ts.map +1 -0
  23. package/dist/cjs/utils/font-preconnect.js +52 -0
  24. package/dist/cjs/utils/font-preconnect.js.map +1 -0
  25. package/dist/cjs/utils/product-ratings.d.ts +26 -0
  26. package/dist/cjs/utils/product-ratings.d.ts.map +1 -0
  27. package/dist/cjs/utils/product-ratings.js +30 -0
  28. package/dist/cjs/utils/product-ratings.js.map +1 -0
  29. package/dist/cjs/utils/rich-text-embeds-codegen.d.ts +9 -0
  30. package/dist/cjs/utils/rich-text-embeds-codegen.d.ts.map +1 -0
  31. package/dist/cjs/utils/rich-text-embeds-codegen.js +139 -0
  32. package/dist/cjs/utils/rich-text-embeds-codegen.js.map +1 -0
  33. package/dist/cjs/utils/rich-text-embeds.d.ts +251 -0
  34. package/dist/cjs/utils/rich-text-embeds.d.ts.map +1 -0
  35. package/dist/cjs/utils/rich-text-embeds.js +852 -0
  36. package/dist/cjs/utils/rich-text-embeds.js.map +1 -0
  37. package/dist/esm/index.d.ts +6 -1
  38. package/dist/esm/index.d.ts.map +1 -1
  39. package/dist/esm/index.js +6 -1
  40. package/dist/esm/index.js.map +1 -1
  41. package/dist/esm/page-revalidate/api-route.d.ts +24 -0
  42. package/dist/esm/page-revalidate/api-route.d.ts.map +1 -0
  43. package/dist/esm/page-revalidate/api-route.js +26 -0
  44. package/dist/esm/page-revalidate/api-route.js.map +1 -0
  45. package/dist/esm/page-revalidate/constants.d.ts +22 -0
  46. package/dist/esm/page-revalidate/constants.d.ts.map +1 -0
  47. package/dist/esm/page-revalidate/constants.js +22 -0
  48. package/dist/esm/page-revalidate/constants.js.map +1 -0
  49. package/dist/esm/page-revalidate/index.d.ts +3 -0
  50. package/dist/esm/page-revalidate/index.d.ts.map +1 -0
  51. package/dist/esm/page-revalidate/index.js +3 -0
  52. package/dist/esm/page-revalidate/index.js.map +1 -0
  53. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  54. package/dist/esm/utils/font-preconnect.d.ts +40 -0
  55. package/dist/esm/utils/font-preconnect.d.ts.map +1 -0
  56. package/dist/esm/utils/font-preconnect.js +48 -0
  57. package/dist/esm/utils/font-preconnect.js.map +1 -0
  58. package/dist/esm/utils/product-ratings.d.ts +26 -0
  59. package/dist/esm/utils/product-ratings.d.ts.map +1 -0
  60. package/dist/esm/utils/product-ratings.js +26 -0
  61. package/dist/esm/utils/product-ratings.js.map +1 -0
  62. package/dist/esm/utils/rich-text-embeds-codegen.d.ts +9 -0
  63. package/dist/esm/utils/rich-text-embeds-codegen.d.ts.map +1 -0
  64. package/dist/esm/utils/rich-text-embeds-codegen.js +134 -0
  65. package/dist/esm/utils/rich-text-embeds-codegen.js.map +1 -0
  66. package/dist/esm/utils/rich-text-embeds.d.ts +251 -0
  67. package/dist/esm/utils/rich-text-embeds.d.ts.map +1 -0
  68. package/dist/esm/utils/rich-text-embeds.js +822 -0
  69. package/dist/esm/utils/rich-text-embeds.js.map +1 -0
  70. package/package.json +3 -3
  71. package/src/index.ts +10 -0
  72. package/src/page-revalidate/api-route.ts +77 -0
  73. package/src/page-revalidate/constants.ts +24 -0
  74. package/src/page-revalidate/index.ts +2 -0
  75. package/src/utils/font-preconnect.ts +61 -0
  76. package/src/utils/product-ratings.ts +98 -0
  77. package/src/utils/rich-text-embeds-codegen.ts +216 -0
  78. package/src/utils/rich-text-embeds.ts +966 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rich-text-embeds.js","sourceRoot":"","sources":["../../../src/utils/rich-text-embeds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AA6BH,MAAM,CAAC,IAAM,gBAAgB,GAAG,UAAU,CAAA;AAC1C,MAAM,CAAC,IAAM,sBAAsB,GAAG,gBAAgB,CAAA;AACtD,MAAM,CAAC,IAAM,wBAAwB,GAAG,kBAAkB,CAAA;AAE1D,8EAA8E;AAC9E,MAAM,CAAC,IAAM,eAAe,GAAG,UAAU,CAAA;AAEzC,MAAM,CAAC,IAAM,UAAU,GAAG;IACxB,MAAM,EAAE,eAAe;IACvB,QAAQ,EAAE,wBAAwB;IAClC,GAAG,EAAE,mBAAmB;IACxB,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,oBAAoB;IAC1B,KAAK,EAAE,qBAAqB;IAC5B,KAAK,EAAE,qBAAqB;IAC5B,KAAK,EAAE,qBAAqB;IAC5B,OAAO,EAAE,uBAAuB;IAChC,OAAO,EAAE,uBAAuB;IAChC,kEAAkE;IAClE,SAAS,EAAE,yBAAyB;IACpC;;;;OAIG;IACH,OAAO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ACrD,IAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;QAC3B,KAAK,CAAC,eAAe,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;QAE3C,IAAM,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,CAAA;QACnC,IAAI,CAAC,KAAK,EAAE;YACV,SAAQ;SACT;QACD,IAAM,KAAK,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAA;QAC9C,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE;YAC5B,SAAQ;SACT;QACD,KAAK,CAAC,SAAS,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAA;KACjD;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teleporthq/teleport-shared",
3
- "version": "0.43.61",
3
+ "version": "0.43.63",
4
4
  "description": "A utility belt for the entire teleportHQ ecosystem",
5
5
  "author": "teleportHQ",
6
6
  "license": "MIT",
@@ -25,9 +25,9 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@babel/types": "^7.5.5",
28
- "@teleporthq/teleport-types": "^0.43.61",
28
+ "@teleporthq/teleport-types": "^0.43.63",
29
29
  "jss": "^10.0.0",
30
30
  "jss-preset-default": "^10.0.0"
31
31
  },
32
- "gitHead": "6a1dad51b4b659ffdd5002095c3e81d94427c422"
32
+ "gitHead": "2c7a1001dd77ae05f54ff41f44acfa9f89a156b4"
33
33
  }
package/src/index.ts CHANGED
@@ -13,8 +13,13 @@ import * as HtmlContentModel from './utils/html-content-model'
13
13
  import * as StyleDeclarations from './utils/style-declarations'
14
14
  import * as StorefrontTax from './utils/storefront-tax'
15
15
  import * as ProductDiscounts from './utils/product-discounts'
16
+ import * as ProductRatings from './utils/product-ratings'
17
+ import * as FontPreconnect from './utils/font-preconnect'
16
18
  import * as EmailDate from './utils/email-date'
19
+ import * as RichTextEmbeds from './utils/rich-text-embeds'
20
+ import * as RichTextEmbedsCodegen from './utils/rich-text-embeds-codegen'
17
21
  import * as DataCache from './cache'
22
+ import * as PageRevalidate from './page-revalidate'
18
23
 
19
24
  export {
20
25
  Constants,
@@ -32,6 +37,11 @@ export {
32
37
  StyleDeclarations,
33
38
  StorefrontTax,
34
39
  ProductDiscounts,
40
+ ProductRatings,
41
+ FontPreconnect,
35
42
  EmailDate,
43
+ RichTextEmbeds,
44
+ RichTextEmbedsCodegen,
36
45
  DataCache,
46
+ PageRevalidate,
37
47
  }
@@ -0,0 +1,77 @@
1
+ import { CACHE_SECRET_ENV } from '../cache/constants'
2
+ import { REVALIDATE_MAX_PATHS } from './constants'
3
+
4
+ /**
5
+ * `POST /api/tq-revalidate`
6
+ *
7
+ * Re-runs `getStaticProps` for each given path, so a row an admin just created,
8
+ * edited or deleted reaches the public URL immediately instead of at the end of
9
+ * the page's ISR window. `res.revalidate` is a Pages-Router API-route method, so
10
+ * this route is the only place in a generated project that can do it — which is
11
+ * why the workflow node calls it over HTTP rather than doing the work itself.
12
+ *
13
+ * Reuses the cache secret rather than minting a second one: both endpoints
14
+ * authorise the same actor (the app's own server, mid-workflow) and a project
15
+ * already has this secret provisioned.
16
+ *
17
+ * Fails CLOSED when no secret is configured, for the same reason the cache
18
+ * route does: an unauthenticated rebuild endpoint on every published site is a
19
+ * free way to make a project re-render its pages on demand.
20
+ *
21
+ * Each path is rebuilt inside its OWN try/catch. `res.revalidate` throws for a
22
+ * path that was never generated (a deleted row's URL, a slug that no longer
23
+ * resolves), and one such path must not cost the caller the rebuilds it asked
24
+ * for alongside it — so failures are collected and reported, never thrown.
25
+ */
26
+ export const generatePageRevalidateRoute = (): string => `import crypto from 'crypto'
27
+
28
+ const MAX_PATHS = ${REVALIDATE_MAX_PATHS}
29
+
30
+ function isAuthorized(req) {
31
+ const secret = process.env.${CACHE_SECRET_ENV}
32
+ const provided = req.headers['x-tq-cache-secret']
33
+ if (!secret || typeof provided !== 'string') {
34
+ return false
35
+ }
36
+ const a = Buffer.from(provided)
37
+ const b = Buffer.from(secret)
38
+ // timingSafeEqual throws on a length mismatch, so the length is compared first.
39
+ if (a.length !== b.length) {
40
+ return false
41
+ }
42
+ return crypto.timingSafeEqual(a, b)
43
+ }
44
+
45
+ export default async function handler(req, res) {
46
+ if (req.method !== 'POST') {
47
+ return res.status(405).json({ error: 'Method not allowed' })
48
+ }
49
+
50
+ if (!isAuthorized(req)) {
51
+ return res.status(401).json({ error: 'Unauthorized' })
52
+ }
53
+
54
+ const body = typeof req.body === 'string' ? JSON.parse(req.body) : req.body || {}
55
+ const paths = (Array.isArray(body.paths) ? body.paths : [])
56
+ .filter((path) => typeof path === 'string' && path.trim())
57
+ .map((path) => (path.trim().charAt(0) === '/' ? path.trim() : '/' + path.trim()))
58
+ .slice(0, MAX_PATHS)
59
+
60
+ const revalidated = []
61
+ const failed = []
62
+
63
+ for (const path of paths) {
64
+ try {
65
+ await res.revalidate(path)
66
+ revalidated.push(path)
67
+ } catch (error) {
68
+ // A path that was never statically generated throws here. That is the
69
+ // normal case for a page whose row was just deleted, so it is reported
70
+ // rather than raised.
71
+ failed.push(path)
72
+ }
73
+ }
74
+
75
+ return res.status(200).json({ ok: true, revalidated, failed })
76
+ }
77
+ `
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Shared constants for the generated page-revalidation route.
3
+ *
4
+ * Lives in `teleport-shared` because two generators agree on them — the Next
5
+ * project plugin that emits the route and the `page-revalidate` workflow node
6
+ * that calls it — and a mismatch would be a 404 the node reports only as a
7
+ * warning, so nothing would ever fail loudly.
8
+ */
9
+
10
+ /** Emitted API route, relative to the generated project root. */
11
+ export const REVALIDATE_API_DIR = ['pages', 'api']
12
+ export const REVALIDATE_ROUTE = 'tq-revalidate'
13
+
14
+ /** The path the workflow node POSTs to. Kept beside the emitted route's name. */
15
+ export const REVALIDATE_ROUTE_PATH = '/api/tq-revalidate'
16
+
17
+ /**
18
+ * One request may not rebuild more than this many pages.
19
+ *
20
+ * Each path re-runs `getStaticProps`, so an unbounded list is an unbounded
21
+ * serverless invocation triggered by whatever the workflow put in the config.
22
+ * Every wiring the platform generates asks for one or two paths.
23
+ */
24
+ export const REVALIDATE_MAX_PATHS = 20
@@ -0,0 +1,2 @@
1
+ export * from './constants'
2
+ export * from './api-route'
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Preconnect hints for the font hosts a project's stylesheet links point at.
3
+ *
4
+ * ## Why this is worth a `<link>`
5
+ *
6
+ * A Google Fonts stylesheet is a two-hop dependency: the browser fetches the CSS
7
+ * from `fonts.googleapis.com`, parses it, and only THEN discovers the font files
8
+ * on `fonts.gstatic.com` — a second origin, needing its own DNS lookup, TCP
9
+ * handshake and TLS negotiation, all of it starting after the CSS has already
10
+ * come back. On a mobile connection that chain routinely costs a few hundred
11
+ * milliseconds of invisible or fallback text.
12
+ *
13
+ * Two `preconnect` hints in the head let both handshakes run in parallel with
14
+ * the CSS request instead of after it. It is the single cheapest font
15
+ * optimisation there is: two tags, no behaviour change, nothing to configure.
16
+ *
17
+ * ## Why `crossorigin` matters on the gstatic hint
18
+ *
19
+ * Font files are fetched in CORS mode. A preconnect without `crossorigin` opens
20
+ * a connection in the wrong mode, the browser cannot reuse it for the font
21
+ * request, and it opens a SECOND one — so the hint costs a connection instead of
22
+ * saving one. The stylesheet itself is a normal same-mode request and takes the
23
+ * plain hint.
24
+ */
25
+
26
+ /** One preconnect hint: an origin, and whether it needs CORS mode. */
27
+ export interface FontPreconnectHint {
28
+ href: string
29
+ crossorigin: boolean
30
+ }
31
+
32
+ const GOOGLE_FONTS_STYLESHEET_HOST = 'fonts.googleapis.com'
33
+ const GOOGLE_FONTS_FILE_HOST = 'fonts.gstatic.com'
34
+
35
+ /**
36
+ * The hints a project needs, in head order, or an empty list when it loads no
37
+ * fonts from a known host.
38
+ *
39
+ * Deliberately conservative: a preconnect to an origin the page never uses wastes
40
+ * a connection, so this only answers for hosts whose two-hop behaviour is known.
41
+ * A self-hosted font, or a font already inlined as `@font-face`, needs nothing —
42
+ * its files come from an origin the browser has connected to anyway.
43
+ */
44
+ export const resolveFontPreconnectHints = (
45
+ assetPaths: ReadonlyArray<string | undefined>
46
+ ): FontPreconnectHint[] => {
47
+ const usesGoogleFonts = assetPaths.some(
48
+ (path) => typeof path === 'string' && path.includes(GOOGLE_FONTS_STYLESHEET_HOST)
49
+ )
50
+
51
+ if (!usesGoogleFonts) {
52
+ return []
53
+ }
54
+
55
+ return [
56
+ { href: `https://${GOOGLE_FONTS_STYLESHEET_HOST}`, crossorigin: false },
57
+ // CORS mode — see the note above; without it the connection is not reusable
58
+ // for the font files and the hint becomes a cost rather than a saving.
59
+ { href: `https://${GOOGLE_FONTS_FILE_HOST}`, crossorigin: true },
60
+ ]
61
+ }
@@ -0,0 +1,98 @@
1
+ /**
2
+ * The aggregate-rating rule, as ES5 source for embedding into generated runtime
3
+ * code (the data-source product transform) that cannot import from this package.
4
+ *
5
+ * ⚠️ SECOND MIRROR. The editor/canvas copy is teleport-gui's
6
+ * `features/e-commerce/utils/product-ratings.ts`, and the two must agree exactly
7
+ * or the canvas shows one rating and the deployed store shows another — the
8
+ * divergence class that hid the variant picker for a whole release. The GUI's
9
+ * `utils/__tests__/product-rating-parity.spec.ts` and this package's
10
+ * `__tests__/product-ratings.test.ts` run the SAME fixture table against their
11
+ * respective copies.
12
+ *
13
+ * Three rules the whole feature rests on (stated in full in the GUI copy):
14
+ *
15
+ * - Only APPROVED reviews count. The predicate lives in the SQL, never here.
16
+ * - "No reviews" and "we could not look" both render as NOTHING — never as
17
+ * "0.0 ★☆☆☆☆", which reads as a product everyone hated.
18
+ * - The label and the stars round from the SAME number: one decimal for the
19
+ * label, that value snapped to the nearest half for the stars.
20
+ *
21
+ * Everything is prefixed `__pr` so the block can be concatenated into any
22
+ * generated module without colliding with its locals — it is emitted alongside
23
+ * the `__pd` discount helpers and the storefront-tax helpers.
24
+ */
25
+ export const generateProductRatingHelperCode = (): string => `
26
+ // ── Aggregate product ratings ────────────────────────────────────────────────
27
+ // Turns the batched COUNT/AVG of a product's APPROVED reviews into the fields
28
+ // the card and the details page bind: a one-decimal label, a count, a
29
+ // 'true'/'false' gate and five per-slot fill states.
30
+ //
31
+ // Strings throughout (except the two numbers) to match the storefront's
32
+ // string-equality convention: rendering conditions compare operands as TEXT and
33
+ // a bound text node prints its value verbatim.
34
+ var __PR_MAX_STARS = 5;
35
+
36
+ // Mean rounded to one decimal, clamped to the 1-5 scale. Clamping is not
37
+ // paranoia: \`rating\` is a plain integer column and an import or a hand-written
38
+ // UPDATE can put a 7 in it, which would ask for a star slot that does not exist.
39
+ function __prRoundAverage(average) {
40
+ var raw = Number(average);
41
+ if (!isFinite(raw) || !(raw > 0)) return 0;
42
+ var clamped = Math.min(__PR_MAX_STARS, raw);
43
+ return Math.round(clamped * 10) / 10;
44
+ }
45
+
46
+ // The value the STARS are drawn from: the label average snapped to the nearest
47
+ // half, so the stars can never disagree with the number printed beside them.
48
+ function __prHalfStar(roundedAverage) {
49
+ return Math.round(roundedAverage * 2) / 2;
50
+ }
51
+
52
+ // Fill state of one 1-based slot. At 4.5: slots 1-4 full, slot 5 half.
53
+ function __prStarFill(slot, halfSnapped) {
54
+ if (halfSnapped >= slot) return 'full';
55
+ if (halfSnapped >= slot - 0.5) return 'half';
56
+ return 'empty';
57
+ }
58
+
59
+ // Every product carries these keys; this is the "no reviews" answer, and it is
60
+ // also what a FAILED lookup returns — the two are deliberately indistinguishable.
61
+ function __prEmptyRatingFields() {
62
+ return {
63
+ ratingAverage: 0,
64
+ ratingCount: 0,
65
+ ratingAverageLabel: '',
66
+ ratingCountLabel: '',
67
+ hasRatings: 'false',
68
+ ratingStar1: 'empty',
69
+ ratingStar2: 'empty',
70
+ ratingStar3: 'empty',
71
+ ratingStar4: 'empty',
72
+ ratingStar5: 'empty'
73
+ };
74
+ }
75
+
76
+ function __prBuildRatingFields(aggregate) {
77
+ var rawCount = aggregate ? Number(aggregate.count) : 0;
78
+ var count = isFinite(rawCount) ? Math.max(0, Math.trunc(rawCount)) : 0;
79
+ var average = __prRoundAverage(aggregate ? aggregate.average : 0);
80
+
81
+ // A count with no usable average (every row NULL) is not a rating anyone can
82
+ // read, so it degrades to "no reviews" rather than to zero stars.
83
+ if (count <= 0 || average <= 0) return __prEmptyRatingFields();
84
+
85
+ var half = __prHalfStar(average);
86
+ return {
87
+ ratingAverage: average,
88
+ ratingCount: count,
89
+ ratingAverageLabel: average.toFixed(1),
90
+ ratingCountLabel: String(count),
91
+ hasRatings: 'true',
92
+ ratingStar1: __prStarFill(1, half),
93
+ ratingStar2: __prStarFill(2, half),
94
+ ratingStar3: __prStarFill(3, half),
95
+ ratingStar4: __prStarFill(4, half),
96
+ ratingStar5: __prStarFill(5, half)
97
+ };
98
+ }`
@@ -0,0 +1,216 @@
1
+ /**
2
+ * Code-generation helpers for the rich-text embed contract.
3
+ *
4
+ * Kept apart from `rich-text-embeds.ts` on purpose: that module is imported by
5
+ * the studio editor and the canvas renderer, which are BROWSER bundles, and the
6
+ * function registry below holds a live reference to every helper so that none
7
+ * of them can be tree-shaken. Only the project generator imports this file.
8
+ */
9
+ import {
10
+ CUSTOM_EMBED_PROVIDER_ID,
11
+ DEFAULT_EMBED_ALIGN,
12
+ DEFAULT_EMBED_SANDBOX_LEVEL,
13
+ DEFAULT_EMBED_WIDTH,
14
+ EMBED_ALIGNMENTS,
15
+ EMBED_ATTR,
16
+ EMBED_BLOT_NAME,
17
+ EMBED_CAPTION_CLASS_NAME,
18
+ EMBED_CAPTION_STYLE,
19
+ EMBED_CLASS_NAME,
20
+ EMBED_FRAME_CLASS_NAME,
21
+ EMBED_HEIGHT_MESSAGE_TYPE,
22
+ EMBED_INITIAL_HEIGHT,
23
+ EMBED_MAX_HEIGHT,
24
+ EMBED_MIN_HEIGHT,
25
+ EMBED_PROVIDERS,
26
+ EMBED_SANDBOX_DOC_HEAD,
27
+ EMBED_SANDBOX_DOC_TAIL,
28
+ EMBED_SANDBOX_FLAGS_STRICT,
29
+ EMBED_SANDBOX_FLAGS_TRUSTED,
30
+ EMBED_TOKEN_PLACEHOLDER,
31
+ GENERIC_EMBED_PROVIDER_ID,
32
+ WIDESCREEN_EMBED_RATIO,
33
+ applyEmbedTemplate,
34
+ buildEmbedElementHtml,
35
+ buildEmbedFrameChildren,
36
+ buildEmbedHtmlFromUrl,
37
+ buildEmbedSandboxDocument,
38
+ clampEmbedWidth,
39
+ createEmbedToken,
40
+ createEmbedValue,
41
+ decodeEmbedCode,
42
+ embedBlockStyle,
43
+ embedFrameStyle,
44
+ encodeEmbedCode,
45
+ escapeEmbedAttribute,
46
+ escapeEmbedText,
47
+ findEmbedFrame,
48
+ isSafeEmbedUrl,
49
+ normalizeEmbedAlign,
50
+ normalizeEmbedsForStorage,
51
+ parseEmbedHeightMessage,
52
+ readEmbedValueFromElement,
53
+ readEncodedEmbedCode,
54
+ resolveEmbedMode,
55
+ resolveEmbedProvider,
56
+ resolveEmbedSandboxFlags,
57
+ } from './rich-text-embeds'
58
+
59
+ /**
60
+ * The provider registry as a JavaScript literal, so the component the Next
61
+ * generator writes is built from THIS array rather than a hand-copied one.
62
+ * Regexes are re-created from their source and flags because `JSON.stringify`
63
+ * flattens a `RegExp` to `{}`.
64
+ */
65
+ export function serializeEmbedProvidersForRuntime(): string {
66
+ const entries = EMBED_PROVIDERS.map((provider) => {
67
+ const patterns = provider.patterns
68
+ .map(
69
+ (pattern) =>
70
+ `new RegExp(${JSON.stringify(pattern.source)}, ${JSON.stringify(pattern.flags)})`
71
+ )
72
+ .join(', ')
73
+ return (
74
+ `{ id: ${JSON.stringify(provider.id)}, label: ${JSON.stringify(provider.label)}, ` +
75
+ `patterns: [${patterns}], template: ${JSON.stringify(provider.template)}, ` +
76
+ `ratio: ${provider.ratio === null ? 'null' : String(provider.ratio)} }`
77
+ )
78
+ })
79
+ return `[\n ${entries.join(',\n ')}\n]`
80
+ }
81
+
82
+ /* ── The generated runtime module ───────────────────────────────────────────
83
+ *
84
+ * The exported project needs these same helpers at runtime: its rich-text
85
+ * editor builds embeds with them and its activator mounts them. Rather than
86
+ * hand-copying the logic into a code-generator template — where it would drift
87
+ * from this file the first time a provider is added — the module is EMITTED
88
+ * from the very functions above: the constants are serialized, the functions
89
+ * are printed with `Function.prototype.toString`, and the result is written to
90
+ * the generated project as `components/embed-runtime.js`.
91
+ *
92
+ * Two rules keep that safe, and `__tests__/utils/rich-text-embeds.ts` pins both:
93
+ * - every emitted function may only reference other emitted functions and the
94
+ * constants below, never a module-private helper or an import;
95
+ * - the emitted module must parse and behave identically to this one.
96
+ */
97
+
98
+ /**
99
+ * Every function the generated editor and activator reach — the ones they
100
+ * import, plus everything those call in turn. Deliberately not the whole of
101
+ * `rich-text-embeds`: the editor overlay helpers belong to the studio, and an
102
+ * export nothing calls is dead weight in every generated project.
103
+ */
104
+ const RUNTIME_EXPORTS: Array<(...args: never[]) => unknown> = [
105
+ isSafeEmbedUrl,
106
+ resolveEmbedProvider,
107
+ applyEmbedTemplate,
108
+ buildEmbedHtmlFromUrl,
109
+ resolveEmbedMode,
110
+ clampEmbedWidth,
111
+ normalizeEmbedAlign,
112
+ escapeEmbedAttribute,
113
+ escapeEmbedText,
114
+ encodeEmbedCode,
115
+ decodeEmbedCode,
116
+ createEmbedValue,
117
+ embedBlockStyle,
118
+ embedFrameStyle,
119
+ buildEmbedElementHtml,
120
+ buildEmbedFrameChildren,
121
+ findEmbedFrame,
122
+ readEmbedValueFromElement,
123
+ readEncodedEmbedCode,
124
+ normalizeEmbedsForStorage,
125
+ resolveEmbedSandboxFlags,
126
+ buildEmbedSandboxDocument,
127
+ parseEmbedHeightMessage,
128
+ createEmbedToken,
129
+ ]
130
+
131
+ interface RuntimeConstant {
132
+ name: string
133
+ literal: string
134
+ }
135
+
136
+ const runtimeConstant = (name: string, literal: string): RuntimeConstant => ({ name, literal })
137
+
138
+ /**
139
+ * TypeScript's CommonJS emit rewrites every reference to an exported CONSTANT
140
+ * as `exports.NAME` (exported functions keep their bare names, which is why
141
+ * they can call each other). The generator runs against that CommonJS build, so
142
+ * printed function bodies arrive carrying `exports.` prefixes that mean nothing
143
+ * in the emitted module — where each constant is re-declared as a plain
144
+ * top-level binding of the same name. Rewriting them back is therefore exact,
145
+ * not a heuristic: only names this module emits are rewritten, and
146
+ * `generateEmbedRuntimeModuleSource` asserts nothing module-scoped is left.
147
+ */
148
+ const bindRuntimeConstantReferences = (source: string, names: string[]): string =>
149
+ names.reduce((acc, name) => acc.replace(new RegExp(`\\bexports\\.${name}\\b`, 'g'), name), source)
150
+
151
+ export function generateEmbedRuntimeModuleSource(): string {
152
+ const constants: RuntimeConstant[] = [
153
+ runtimeConstant('EMBED_CLASS_NAME', JSON.stringify(EMBED_CLASS_NAME)),
154
+ runtimeConstant('EMBED_FRAME_CLASS_NAME', JSON.stringify(EMBED_FRAME_CLASS_NAME)),
155
+ runtimeConstant('EMBED_CAPTION_CLASS_NAME', JSON.stringify(EMBED_CAPTION_CLASS_NAME)),
156
+ runtimeConstant('EMBED_BLOT_NAME', JSON.stringify(EMBED_BLOT_NAME)),
157
+ runtimeConstant('EMBED_ATTR', JSON.stringify(EMBED_ATTR, null, 2)),
158
+ runtimeConstant('EMBED_ALIGNMENTS', JSON.stringify(EMBED_ALIGNMENTS)),
159
+ runtimeConstant('CUSTOM_EMBED_PROVIDER_ID', JSON.stringify(CUSTOM_EMBED_PROVIDER_ID)),
160
+ runtimeConstant('GENERIC_EMBED_PROVIDER_ID', JSON.stringify(GENERIC_EMBED_PROVIDER_ID)),
161
+ runtimeConstant('DEFAULT_EMBED_WIDTH', String(DEFAULT_EMBED_WIDTH)),
162
+ runtimeConstant('DEFAULT_EMBED_ALIGN', JSON.stringify(DEFAULT_EMBED_ALIGN)),
163
+ runtimeConstant('DEFAULT_EMBED_SANDBOX_LEVEL', JSON.stringify(DEFAULT_EMBED_SANDBOX_LEVEL)),
164
+ runtimeConstant('WIDESCREEN_EMBED_RATIO', String(WIDESCREEN_EMBED_RATIO)),
165
+ runtimeConstant('EMBED_CAPTION_STYLE', JSON.stringify(EMBED_CAPTION_STYLE)),
166
+ runtimeConstant('EMBED_PROVIDERS', serializeEmbedProvidersForRuntime()),
167
+ runtimeConstant('EMBED_SANDBOX_FLAGS_STRICT', JSON.stringify(EMBED_SANDBOX_FLAGS_STRICT)),
168
+ runtimeConstant('EMBED_SANDBOX_FLAGS_TRUSTED', JSON.stringify(EMBED_SANDBOX_FLAGS_TRUSTED)),
169
+ runtimeConstant('EMBED_HEIGHT_MESSAGE_TYPE', JSON.stringify(EMBED_HEIGHT_MESSAGE_TYPE)),
170
+ runtimeConstant('EMBED_TOKEN_PLACEHOLDER', JSON.stringify(EMBED_TOKEN_PLACEHOLDER)),
171
+ runtimeConstant('EMBED_MIN_HEIGHT', String(EMBED_MIN_HEIGHT)),
172
+ runtimeConstant('EMBED_MAX_HEIGHT', String(EMBED_MAX_HEIGHT)),
173
+ runtimeConstant('EMBED_INITIAL_HEIGHT', String(EMBED_INITIAL_HEIGHT)),
174
+ runtimeConstant('EMBED_SANDBOX_DOC_HEAD', JSON.stringify(EMBED_SANDBOX_DOC_HEAD)),
175
+ runtimeConstant('EMBED_SANDBOX_DOC_TAIL', JSON.stringify(EMBED_SANDBOX_DOC_TAIL)),
176
+ // `createEmbedToken` closes over this counter.
177
+ runtimeConstant('embedTokenCounter', '0'),
178
+ ]
179
+
180
+ const names = constants.map((entry) => entry.name)
181
+ const declarations = constants.map((entry) => `export var ${entry.name} = ${entry.literal}`)
182
+ const functions = RUNTIME_EXPORTS.map(
183
+ (fn) => `export ${bindRuntimeConstantReferences(fn.toString(), names)}`
184
+ )
185
+
186
+ const source = `${RUNTIME_MODULE_HEADER}\n${declarations.join('\n\n')}\n\n${functions.join(
187
+ '\n\n'
188
+ )}\n`
189
+
190
+ // An `exports.` reference that survived means a function reached for a
191
+ // constant left off the list above. That crashes every generated project at
192
+ // runtime, so it fails here instead. (Import leakage is covered by the
193
+ // emitted module being evaluated in this package's tests — this module has
194
+ // no imports, and must not gain any.)
195
+ const leaked = source.match(/\bexports\.[A-Za-z_$][\w$]*/g)
196
+ if (leaked) {
197
+ throw new Error(
198
+ `Embed runtime module cannot be emitted: unresolved module references ${leaked.join(', ')}`
199
+ )
200
+ }
201
+
202
+ return source
203
+ }
204
+
205
+ const RUNTIME_MODULE_HEADER = `/**
206
+ * Code embeds inside rich-text content — the shape the editor writes and the
207
+ * page reads back. Generated from @teleporthq/teleport-shared; edit it there.
208
+ *
209
+ * An embed is stored inside the content HTML as a <figure class="tq-embed">.
210
+ * Passive markup (a provider iframe) lives in the figure as real children, so
211
+ * it renders server-side with no JavaScript. Markup that can execute — a
212
+ * <script>, an on* handler, a javascript: URL — is base64-encoded onto the
213
+ * element instead, and mounted at runtime inside a sandboxed iframe so it can
214
+ * never reach this page.
215
+ */
216
+ `