@teleporthq/teleport-shared 0.43.74 → 0.43.75

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 (70) hide show
  1. package/__tests__/_fixtures/rich-text/README.md +6 -0
  2. package/__tests__/_fixtures/rich-text/help-accept-an-invitation.html +50 -0
  3. package/__tests__/_fixtures/rich-text/help-activate-an-appsumo-license.html +44 -0
  4. package/__tests__/_fixtures/rich-text/help-add-custom-code-to-your-site.html +61 -0
  5. package/__tests__/_fixtures/rich-text/help-connect-a-custom-domain.html +106 -0
  6. package/__tests__/_fixtures/rich-text/help-custom-animations-with-code.html +69 -0
  7. package/__tests__/_fixtures/rich-text/help-generate-a-store.html +78 -0
  8. package/__tests__/_fixtures/rich-text/help-keyboard-shortcuts.html +417 -0
  9. package/__tests__/_fixtures/rich-text/help-prompting-tips.html +82 -0
  10. package/__tests__/_fixtures/rich-text/help-sitemap-robots-and-llms-txt.html +82 -0
  11. package/__tests__/_fixtures/rich-text/help-use-a-csv-file-or-static-data.html +61 -0
  12. package/__tests__/_helpers/rich-text-content-runtime-emitter.ts +117 -0
  13. package/__tests__/utils/content-tables.ts +69 -0
  14. package/__tests__/utils/rich-text-content-runtime-module.ts +115 -0
  15. package/__tests__/utils/rich-text-content.ts +131 -0
  16. package/dist/cjs/index.d.ts +4 -1
  17. package/dist/cjs/index.d.ts.map +1 -1
  18. package/dist/cjs/index.js +7 -1
  19. package/dist/cjs/index.js.map +1 -1
  20. package/dist/cjs/tsconfig.tsbuildinfo +1 -1
  21. package/dist/cjs/utils/content-tables.d.ts +78 -0
  22. package/dist/cjs/utils/content-tables.d.ts.map +1 -0
  23. package/dist/cjs/utils/content-tables.js +123 -0
  24. package/dist/cjs/utils/content-tables.js.map +1 -0
  25. package/dist/cjs/utils/rich-text-content-codegen.d.ts +20 -0
  26. package/dist/cjs/utils/rich-text-content-codegen.d.ts.map +1 -0
  27. package/dist/cjs/utils/rich-text-content-codegen.js +55 -0
  28. package/dist/cjs/utils/rich-text-content-codegen.js.map +1 -0
  29. package/dist/cjs/utils/rich-text-content-runtime-source.d.ts +2 -0
  30. package/dist/cjs/utils/rich-text-content-runtime-source.d.ts.map +1 -0
  31. package/dist/cjs/utils/rich-text-content-runtime-source.js +591 -0
  32. package/dist/cjs/utils/rich-text-content-runtime-source.js.map +1 -0
  33. package/dist/cjs/utils/rich-text-content.d.ts +150 -0
  34. package/dist/cjs/utils/rich-text-content.d.ts.map +1 -0
  35. package/dist/cjs/utils/rich-text-content.js +649 -0
  36. package/dist/cjs/utils/rich-text-content.js.map +1 -0
  37. package/dist/cjs/utils/table-access.d.ts.map +1 -1
  38. package/dist/cjs/utils/table-access.js +5 -7
  39. package/dist/cjs/utils/table-access.js.map +1 -1
  40. package/dist/esm/index.d.ts +4 -1
  41. package/dist/esm/index.d.ts.map +1 -1
  42. package/dist/esm/index.js +4 -1
  43. package/dist/esm/index.js.map +1 -1
  44. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  45. package/dist/esm/utils/content-tables.d.ts +78 -0
  46. package/dist/esm/utils/content-tables.d.ts.map +1 -0
  47. package/dist/esm/utils/content-tables.js +114 -0
  48. package/dist/esm/utils/content-tables.js.map +1 -0
  49. package/dist/esm/utils/rich-text-content-codegen.d.ts +20 -0
  50. package/dist/esm/utils/rich-text-content-codegen.d.ts.map +1 -0
  51. package/dist/esm/utils/rich-text-content-codegen.js +50 -0
  52. package/dist/esm/utils/rich-text-content-codegen.js.map +1 -0
  53. package/dist/esm/utils/rich-text-content-runtime-source.d.ts +2 -0
  54. package/dist/esm/utils/rich-text-content-runtime-source.d.ts.map +1 -0
  55. package/dist/esm/utils/rich-text-content-runtime-source.js +588 -0
  56. package/dist/esm/utils/rich-text-content-runtime-source.js.map +1 -0
  57. package/dist/esm/utils/rich-text-content.d.ts +150 -0
  58. package/dist/esm/utils/rich-text-content.d.ts.map +1 -0
  59. package/dist/esm/utils/rich-text-content.js +613 -0
  60. package/dist/esm/utils/rich-text-content.js.map +1 -0
  61. package/dist/esm/utils/table-access.d.ts.map +1 -1
  62. package/dist/esm/utils/table-access.js +5 -7
  63. package/dist/esm/utils/table-access.js.map +1 -1
  64. package/package.json +3 -3
  65. package/src/index.ts +6 -0
  66. package/src/utils/content-tables.ts +151 -0
  67. package/src/utils/rich-text-content-codegen.ts +52 -0
  68. package/src/utils/rich-text-content-runtime-source.ts +587 -0
  69. package/src/utils/rich-text-content.ts +677 -0
  70. package/src/utils/table-access.ts +4 -2
@@ -7,6 +7,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
7
7
  }
8
8
  return to.concat(ar || Array.prototype.slice.call(from));
9
9
  };
10
+ import { CONTENT_COMMENTS_TABLES } from './content-tables';
10
11
  /**
11
12
  * Which store tables a browser may touch through the generated data routes.
12
13
  *
@@ -58,7 +59,7 @@ export var MONEY_TABLES = [
58
59
  'teleport_product_files',
59
60
  'teleport_license_keys',
60
61
  ];
61
- export var CUSTOMER_RECORD_TABLES = [
62
+ export var CUSTOMER_RECORD_TABLES = __spreadArray(__spreadArray([
62
63
  'users',
63
64
  'teleport_orders',
64
65
  'teleport_order_items',
@@ -83,11 +84,8 @@ export var CUSTOMER_RECORD_TABLES = [
83
84
  'teleport_product_reviews',
84
85
  // A push subscription is a capability: whoever holds the endpoint and its
85
86
  // keys can notify that device. Only the app's push routes read the table.
86
- 'teleport_push_subscriptions',
87
- // A comment is public once approved, but the row carries the commenter's
88
- // email and the comments still waiting for approval; the post page reads
89
- // the approved ones server-side, public columns only.
90
- 'teleport_blog_comments',
87
+ 'teleport_push_subscriptions'
88
+ ], CONTENT_COMMENTS_TABLES, true), [
91
89
  // What visitors told the AI assistant, and the merchant's private knowledge
92
90
  // base it answers from: the assistant reads them in its own server
93
91
  // segments, the admin lists them with its session.
@@ -95,7 +93,7 @@ export var CUSTOMER_RECORD_TABLES = [
95
93
  'teleport_ai_chat_documents',
96
94
  'teleport_ai_chat_conversations',
97
95
  'teleport_ai_chat_messages',
98
- ];
96
+ ], false);
99
97
  export var PROTECTED_TABLES = __spreadArray(__spreadArray([], MONEY_TABLES, true), CUSTOMER_RECORD_TABLES, true);
100
98
  export var WRITE_PROTECTED_TABLES = ['teleport_discounts'];
101
99
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"table-access.js","sourceRoot":"","sources":["../../../src/utils/table-access.ts"],"names":[],"mappings":";;;;;;;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,CAAC,IAAM,YAAY,GAA0B;IACjD,qBAAqB;IACrB,iCAAiC;IACjC,mBAAmB;IACnB,8BAA8B;IAC9B,uEAAuE;IACvE,sEAAsE;IACtE,0DAA0D;IAC1D,sBAAsB;IACtB,0EAA0E;IAC1E,qEAAqE;IACrE,uBAAuB;IACvB,wEAAwE;IACxE,qEAAqE;IACrE,yDAAyD;IACzD,wBAAwB;IACxB,uBAAuB;CACxB,CAAA;AAED,MAAM,CAAC,IAAM,sBAAsB,GAA0B;IAC3D,OAAO;IACP,iBAAiB;IACjB,sBAAsB;IACtB,mBAAmB;IACnB,wBAAwB;IACxB,iBAAiB;IACjB,oBAAoB;IACpB,yBAAyB;IACzB,8BAA8B;IAC9B,mCAAmC;IACnC,0BAA0B;IAC1B,eAAe;IACf,qBAAqB;IACrB,qBAAqB;IACrB,8EAA8E;IAC9E,gEAAgE;IAChE,wBAAwB;IACxB,oBAAoB;IACpB,uEAAuE;IACvE,qEAAqE;IACrE,6BAA6B;IAC7B,0BAA0B;IAC1B,0EAA0E;IAC1E,0EAA0E;IAC1E,6BAA6B;IAC7B,yEAAyE;IACzE,yEAAyE;IACzE,sDAAsD;IACtD,wBAAwB;IACxB,4EAA4E;IAC5E,mEAAmE;IACnE,mDAAmD;IACnD,oCAAoC;IACpC,4BAA4B;IAC5B,gCAAgC;IAChC,2BAA2B;CAC5B,CAAA;AAED,MAAM,CAAC,IAAM,gBAAgB,mCAA8B,YAAY,SAAK,sBAAsB,OAAC,CAAA;AA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AAS,CAAC,8BAA8B,CAAC,6CAC3D,IAAI,CAAC,SAAS,CAAC,sBAAsB,CAAC,29VA6PpE,CAAA;AACD,CAAC,CAAA"}
1
+ {"version":3,"file":"table-access.js","sourceRoot":"","sources":["../../../src/utils/table-access.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,CAAC,IAAM,YAAY,GAA0B;IACjD,qBAAqB;IACrB,iCAAiC;IACjC,mBAAmB;IACnB,8BAA8B;IAC9B,uEAAuE;IACvE,sEAAsE;IACtE,0DAA0D;IAC1D,sBAAsB;IACtB,0EAA0E;IAC1E,qEAAqE;IACrE,uBAAuB;IACvB,wEAAwE;IACxE,qEAAqE;IACrE,yDAAyD;IACzD,wBAAwB;IACxB,uBAAuB;CACxB,CAAA;AAED,MAAM,CAAC,IAAM,sBAAsB;IACjC,OAAO;IACP,iBAAiB;IACjB,sBAAsB;IACtB,mBAAmB;IACnB,wBAAwB;IACxB,iBAAiB;IACjB,oBAAoB;IACpB,yBAAyB;IACzB,8BAA8B;IAC9B,mCAAmC;IACnC,0BAA0B;IAC1B,eAAe;IACf,qBAAqB;IACrB,qBAAqB;IACrB,8EAA8E;IAC9E,gEAAgE;IAChE,wBAAwB;IACxB,oBAAoB;IACpB,uEAAuE;IACvE,qEAAqE;IACrE,6BAA6B;IAC7B,0BAA0B;IAC1B,0EAA0E;IAC1E,0EAA0E;IAC1E,6BAA6B;GAK1B,uBAAuB;IAC1B,4EAA4E;IAC5E,mEAAmE;IACnE,mDAAmD;IACnD,oCAAoC;IACpC,4BAA4B;IAC5B,gCAAgC;IAChC,2BAA2B;SAC5B,CAAA;AAED,MAAM,CAAC,IAAM,gBAAgB,mCAA8B,YAAY,SAAK,sBAAsB,OAAC,CAAA;AAEnG,MAAM,CAAC,IAAM,sBAAsB,GAA0B,CAAC,oBAAoB,CA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C,sBAAsB,CAAC,29VA6PpE,CAAA;AACD,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teleporthq/teleport-shared",
3
- "version": "0.43.74",
3
+ "version": "0.43.75",
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.71",
28
+ "@teleporthq/teleport-types": "^0.43.75",
29
29
  "jss": "^10.0.0",
30
30
  "jss-preset-default": "^10.0.0"
31
31
  },
32
- "gitHead": "ba42bebcf5037a88ca40e2f0714cc476a7aa1f82"
32
+ "gitHead": "4bc0af8166575b4af971f39e63228ce2eefce661"
33
33
  }
package/src/index.ts CHANGED
@@ -20,12 +20,15 @@ import * as ProductOptions from './utils/product-options'
20
20
  import * as CartLinePricing from './utils/cart-line-pricing'
21
21
  import * as CartCurrency from './utils/cart-currency'
22
22
  import * as TableAccess from './utils/table-access'
23
+ import * as ContentTables from './utils/content-tables'
23
24
  import * as SessionCookieResolver from './utils/session-cookie-resolver'
24
25
  import * as SubscriptionAccess from './utils/subscription-access'
25
26
  import * as FontPreconnect from './utils/font-preconnect'
26
27
  import * as EmailDate from './utils/email-date'
27
28
  import * as RichTextEmbeds from './utils/rich-text-embeds'
28
29
  import * as RichTextEmbedsCodegen from './utils/rich-text-embeds-codegen'
30
+ import * as RichTextContent from './utils/rich-text-content'
31
+ import * as RichTextContentCodegen from './utils/rich-text-content-codegen'
29
32
  import * as DataCache from './cache'
30
33
  import * as PageRevalidate from './page-revalidate'
31
34
  import * as ScrollSceneRuntime from './scroll-scene'
@@ -58,12 +61,15 @@ export {
58
61
  CartLinePricing,
59
62
  CartCurrency,
60
63
  TableAccess,
64
+ ContentTables,
61
65
  SessionCookieResolver,
62
66
  SubscriptionAccess,
63
67
  FontPreconnect,
64
68
  EmailDate,
65
69
  RichTextEmbeds,
66
70
  RichTextEmbedsCodegen,
71
+ RichTextContent,
72
+ RichTextContentCodegen,
67
73
  DataCache,
68
74
  PageRevalidate,
69
75
  ScrollSceneRuntime,
@@ -0,0 +1,151 @@
1
+ /**
2
+ * The content presets — the Blog, and every feature built like it — and the
3
+ * tables each one keeps. The ONE list the editor and the generators read: the
4
+ * editor's `ContentPreset` is built on these entries, the generated site's
5
+ * read routes, view models and feeds recognise a content table through
6
+ * `contentTableRole`. A preset added here and nowhere else is caught by the
7
+ * editor's wiring test; a table named anywhere else is a copy that drifts.
8
+ */
9
+
10
+ export type ContentPresetKey = 'blog' | 'help'
11
+
12
+ export type ContentTableRole = 'posts' | 'comments'
13
+
14
+ export interface ContentTables {
15
+ key: ContentPresetKey
16
+ /** The rows the preset publishes: one per post / article. */
17
+ posts: string
18
+ /** Reader comments under a post, when the preset takes them. */
19
+ comments: string | null
20
+ /**
21
+ * Whether a post without a picture is shown with the grey "No image" stand-in.
22
+ * Off for a preset whose posts are text: its cards and post page close up
23
+ * instead of drawing an empty grey box on every article.
24
+ */
25
+ pictureStandIn: boolean
26
+ }
27
+
28
+ export const CONTENT_TABLES: ReadonlyArray<ContentTables> = [
29
+ {
30
+ key: 'blog',
31
+ posts: 'teleport_blog_posts',
32
+ comments: 'teleport_blog_comments',
33
+ pictureStandIn: true,
34
+ },
35
+ // The Help Center: articles at /help/<slug>, no reader comments, and a text
36
+ // article shows no picture at all rather than a stand-in.
37
+ { key: 'help', posts: 'teleport_help_articles', comments: null, pictureStandIn: false },
38
+ ]
39
+
40
+ export const CONTENT_POSTS_TABLES: ReadonlyArray<string> = CONTENT_TABLES.map(
41
+ (tables) => tables.posts
42
+ )
43
+
44
+ export const CONTENT_COMMENTS_TABLES: ReadonlyArray<string> = CONTENT_TABLES.map(
45
+ (tables) => tables.comments
46
+ ).filter((table): table is string => table !== null)
47
+
48
+ export const contentTablesByKey = (key: ContentPresetKey): ContentTables => {
49
+ const tables = CONTENT_TABLES.find((entry) => entry.key === key)
50
+ if (!tables) {
51
+ throw new Error(`No content preset is registered under "${key}"`)
52
+ }
53
+ return tables
54
+ }
55
+
56
+ /** Which preset a table belongs to and what it holds there; null for any other table. */
57
+ export const contentTableRole = (
58
+ tableName: string
59
+ ): { key: ContentPresetKey; role: ContentTableRole } | null => {
60
+ for (const tables of CONTENT_TABLES) {
61
+ if (tableName === tables.posts) {
62
+ return { key: tables.key, role: 'posts' }
63
+ }
64
+ if (tableName === tables.comments) {
65
+ return { key: tables.key, role: 'comments' }
66
+ }
67
+ }
68
+ return null
69
+ }
70
+
71
+ export const isContentPostsTable = (tableName: string): boolean =>
72
+ contentTableRole(tableName)?.role === 'posts'
73
+
74
+ export interface VisitorRowPolicy {
75
+ /** SQL every browser read of the table is narrowed with. */
76
+ predicate: string
77
+ /** Keys never served to a browser, wherever they sit in a row (raw and transformed names). */
78
+ hiddenColumns: ReadonlyArray<string>
79
+ }
80
+
81
+ /**
82
+ * What a visitor is served of a posts table: ONLY `published` rows — drafts,
83
+ * scheduled and archived posts are the author's (the editor's post statuses in
84
+ * `blog-post-status.ts`) — and never the author's email address.
85
+ */
86
+ export const CONTENT_POSTS_VISITOR_ROW_POLICY: VisitorRowPolicy = {
87
+ predicate: "status = 'published'",
88
+ hiddenColumns: ['author_email', 'authorEmail'],
89
+ }
90
+
91
+ /**
92
+ * What a browser is served of the tables whose unpublished rows sit beside the
93
+ * public ones. Read by both route families of a generated site — the per-table
94
+ * read routes (teleport-plugin-next-data-source) and the workflow data API
95
+ * (teleport-plugin-next-workflows) — so no reader can disagree about what a
96
+ * visitor sees.
97
+ */
98
+ export const VISITOR_ROW_POLICIES: Readonly<Record<string, VisitorRowPolicy>> = {
99
+ ...Object.fromEntries(
100
+ CONTENT_POSTS_TABLES.map((table) => [table, CONTENT_POSTS_VISITOR_ROW_POLICY])
101
+ ),
102
+ // The storefront sells `active` products; a draft or inactive one is the
103
+ // merchant's, spelled in any case the admin form stored it in.
104
+ teleport_products: {
105
+ predicate: "LOWER(TRIM(status)) = 'active'",
106
+ hiddenColumns: [],
107
+ },
108
+ }
109
+
110
+ /* ------------------------------------------------------------------------ */
111
+ /* Category pages */
112
+ /* ------------------------------------------------------------------------ */
113
+
114
+ /**
115
+ * The generated module a preset's category page reads from — one function
116
+ * resolves the category at a slug with its published posts for
117
+ * `getStaticProps`, the other lists every category's slug for
118
+ * `getStaticPaths`. The editor names them on the page's UIDL (an external
119
+ * resource with a local dependency), the Next generator emits them; both read
120
+ * the names from here, so neither can misspell the other.
121
+ */
122
+ export const CONTENT_CATEGORY_PAGES_MODULE = '@/content-category-pages'
123
+
124
+ const presetPascalCase = (key: ContentPresetKey): string =>
125
+ key.charAt(0).toUpperCase() + key.slice(1)
126
+
127
+ /** `resolveHelpCategoryPage`: `{ data: category | null }` for a slug. */
128
+ export const contentCategoryPageResolverName = (key: ContentPresetKey): string =>
129
+ `resolve${presetPascalCase(key)}CategoryPage`
130
+
131
+ /** `listHelpCategoryPaths`: `{ data: [{ slug }] }`, every category of the tree. */
132
+ export const contentCategoryPathsListerName = (key: ContentPresetKey): string =>
133
+ `list${presetPascalCase(key)}CategoryPaths`
134
+
135
+ /* ------------------------------------------------------------------------ */
136
+ /* The live site index */
137
+ /* ------------------------------------------------------------------------ */
138
+
139
+ /**
140
+ * Where the generated site serves a preset's live sitemap: its published posts,
141
+ * read from the table on request, so a post published after the last publish
142
+ * is listed too. The editor's own `sitemap.xml` names it from its sitemap
143
+ * index; both sides read the address from here.
144
+ */
145
+ export const contentSitemapPath = (key: ContentPresetKey): string => `/sitemap-${key}.xml`
146
+
147
+ /** The site's list for language models: its pages, then each preset's posts by category. */
148
+ export const LLMS_TXT_PATH = '/llms.txt'
149
+
150
+ /** Every published post of the presets, in full, as Markdown. */
151
+ export const LLMS_FULL_TXT_PATH = '/llms-full.txt'
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Code-generation half of the rich-text content contract. Kept apart from
3
+ * `rich-text-content.ts` on purpose: that module is imported by the studio
4
+ * editor and the canvas renderer, which are browser bundles. Only the project
5
+ * generator imports this file.
6
+ */
7
+ import { RICH_TEXT_CONTENT_RUNTIME_MODULE_SOURCE } from './rich-text-content-runtime-source'
8
+
9
+ /**
10
+ * `components/rich-text-content.js` for the generated project: the converter
11
+ * its rich-text editor runs on the way in and out, and the protected block's
12
+ * helpers. A STRING committed beside this file for the same reason the embed
13
+ * runtime is (`generateEmbedRuntimeModuleSource`): the generator runs inside a
14
+ * minified bundle where `Function.prototype.toString` prints renamed code.
15
+ * `__tests__/utils/rich-text-content-runtime-module.ts` fails when the string
16
+ * drifts from `rich-text-content.ts` and regenerates it with
17
+ * UPDATE_RICH_TEXT_CONTENT_RUNTIME=1.
18
+ */
19
+ export function generateRichTextContentRuntimeModuleSource(): string {
20
+ return RICH_TEXT_CONTENT_RUNTIME_MODULE_SOURCE
21
+ }
22
+
23
+ const RENDER_TIME_NAMES = [
24
+ 'QUILL_LIST_ITEM_ATTR',
25
+ 'escapeRichTextText',
26
+ 'buildCodeBlockHtml',
27
+ 'normalizeLegacyRichTextHtml',
28
+ 'rebuildQuillListHtml',
29
+ 'rebuildQuillCodeBlockHtml',
30
+ 'mergeBlockquoteLines',
31
+ ]
32
+
33
+ /**
34
+ * The string-only half of the contract as plain declarations, for the data
35
+ * modules a generated page runs in `getStaticProps`: a post stored before the
36
+ * contract (the studio's flat list lines, the admin panel's no-break spaces)
37
+ * renders as stored HTML would, without waiting for its next save. Cut from
38
+ * the committed runtime module, so it can never drift from it.
39
+ */
40
+ export function generateLegacyRichTextNormalizerCode(): string {
41
+ const chunks = RICH_TEXT_CONTENT_RUNTIME_MODULE_SOURCE.split(/\n\n(?=export )/)
42
+ const picked = RENDER_TIME_NAMES.map((name) => {
43
+ const chunk = chunks.find((candidate) =>
44
+ new RegExp(`^export (?:var|function) ${name}\\b`).test(candidate)
45
+ )
46
+ if (!chunk) {
47
+ throw new Error(`Rich-text content runtime has no ${name} to cut for the data module`)
48
+ }
49
+ return chunk.replace(/^export /, '').replace(/\n$/, '')
50
+ })
51
+ return picked.join('\n\n')
52
+ }