@teleporthq/teleport-shared 0.43.71 → 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.
- package/__tests__/_fixtures/rich-text/README.md +6 -0
- package/__tests__/_fixtures/rich-text/help-accept-an-invitation.html +50 -0
- package/__tests__/_fixtures/rich-text/help-activate-an-appsumo-license.html +44 -0
- package/__tests__/_fixtures/rich-text/help-add-custom-code-to-your-site.html +61 -0
- package/__tests__/_fixtures/rich-text/help-connect-a-custom-domain.html +106 -0
- package/__tests__/_fixtures/rich-text/help-custom-animations-with-code.html +69 -0
- package/__tests__/_fixtures/rich-text/help-generate-a-store.html +78 -0
- package/__tests__/_fixtures/rich-text/help-keyboard-shortcuts.html +417 -0
- package/__tests__/_fixtures/rich-text/help-prompting-tips.html +82 -0
- package/__tests__/_fixtures/rich-text/help-sitemap-robots-and-llms-txt.html +82 -0
- package/__tests__/_fixtures/rich-text/help-use-a-csv-file-or-static-data.html +61 -0
- package/__tests__/_helpers/rich-text-content-runtime-emitter.ts +117 -0
- package/__tests__/function-sources.ts +30 -0
- package/__tests__/utils/content-tables.ts +69 -0
- package/__tests__/utils/rich-text-content-runtime-module.ts +115 -0
- package/__tests__/utils/rich-text-content.ts +131 -0
- package/dist/cjs/index.d.ts +4 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +7 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/page-transition/index.d.ts +1 -0
- package/dist/cjs/page-transition/index.d.ts.map +1 -1
- package/dist/cjs/page-transition/index.js +1 -0
- package/dist/cjs/page-transition/index.js.map +1 -1
- package/dist/cjs/page-transition/variant-sources.generated.d.ts +7 -0
- package/dist/cjs/page-transition/variant-sources.generated.d.ts.map +1 -0
- package/dist/cjs/page-transition/variant-sources.generated.js +14 -0
- package/dist/cjs/page-transition/variant-sources.generated.js.map +1 -0
- package/dist/cjs/scroll-scene/engine-source.d.ts.map +1 -1
- package/dist/cjs/scroll-scene/engine-source.js +2 -5
- package/dist/cjs/scroll-scene/engine-source.js.map +1 -1
- package/dist/cjs/scroll-scene/helper-sources.generated.d.ts +9 -0
- package/dist/cjs/scroll-scene/helper-sources.generated.d.ts.map +1 -0
- package/dist/cjs/scroll-scene/helper-sources.generated.js +16 -0
- package/dist/cjs/scroll-scene/helper-sources.generated.js.map +1 -0
- package/dist/cjs/scroll-scene/index.d.ts +1 -0
- package/dist/cjs/scroll-scene/index.d.ts.map +1 -1
- package/dist/cjs/scroll-scene/index.js +3 -1
- package/dist/cjs/scroll-scene/index.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/cjs/utils/content-tables.d.ts +78 -0
- package/dist/cjs/utils/content-tables.d.ts.map +1 -0
- package/dist/cjs/utils/content-tables.js +123 -0
- package/dist/cjs/utils/content-tables.js.map +1 -0
- package/dist/cjs/utils/rich-text-content-codegen.d.ts +20 -0
- package/dist/cjs/utils/rich-text-content-codegen.d.ts.map +1 -0
- package/dist/cjs/utils/rich-text-content-codegen.js +55 -0
- package/dist/cjs/utils/rich-text-content-codegen.js.map +1 -0
- package/dist/cjs/utils/rich-text-content-runtime-source.d.ts +2 -0
- package/dist/cjs/utils/rich-text-content-runtime-source.d.ts.map +1 -0
- package/dist/cjs/utils/rich-text-content-runtime-source.js +591 -0
- package/dist/cjs/utils/rich-text-content-runtime-source.js.map +1 -0
- package/dist/cjs/utils/rich-text-content.d.ts +150 -0
- package/dist/cjs/utils/rich-text-content.d.ts.map +1 -0
- package/dist/cjs/utils/rich-text-content.js +649 -0
- package/dist/cjs/utils/rich-text-content.js.map +1 -0
- package/dist/cjs/utils/table-access.d.ts.map +1 -1
- package/dist/cjs/utils/table-access.js +5 -7
- package/dist/cjs/utils/table-access.js.map +1 -1
- package/dist/esm/index.d.ts +4 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +4 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/page-transition/index.d.ts +1 -0
- package/dist/esm/page-transition/index.d.ts.map +1 -1
- package/dist/esm/page-transition/index.js +1 -0
- package/dist/esm/page-transition/index.js.map +1 -1
- package/dist/esm/page-transition/variant-sources.generated.d.ts +7 -0
- package/dist/esm/page-transition/variant-sources.generated.d.ts.map +1 -0
- package/dist/esm/page-transition/variant-sources.generated.js +11 -0
- package/dist/esm/page-transition/variant-sources.generated.js.map +1 -0
- package/dist/esm/scroll-scene/engine-source.d.ts.map +1 -1
- package/dist/esm/scroll-scene/engine-source.js +2 -5
- package/dist/esm/scroll-scene/engine-source.js.map +1 -1
- package/dist/esm/scroll-scene/helper-sources.generated.d.ts +9 -0
- package/dist/esm/scroll-scene/helper-sources.generated.d.ts.map +1 -0
- package/dist/esm/scroll-scene/helper-sources.generated.js +13 -0
- package/dist/esm/scroll-scene/helper-sources.generated.js.map +1 -0
- package/dist/esm/scroll-scene/index.d.ts +1 -0
- package/dist/esm/scroll-scene/index.d.ts.map +1 -1
- package/dist/esm/scroll-scene/index.js +1 -0
- package/dist/esm/scroll-scene/index.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/utils/content-tables.d.ts +78 -0
- package/dist/esm/utils/content-tables.d.ts.map +1 -0
- package/dist/esm/utils/content-tables.js +114 -0
- package/dist/esm/utils/content-tables.js.map +1 -0
- package/dist/esm/utils/rich-text-content-codegen.d.ts +20 -0
- package/dist/esm/utils/rich-text-content-codegen.d.ts.map +1 -0
- package/dist/esm/utils/rich-text-content-codegen.js +50 -0
- package/dist/esm/utils/rich-text-content-codegen.js.map +1 -0
- package/dist/esm/utils/rich-text-content-runtime-source.d.ts +2 -0
- package/dist/esm/utils/rich-text-content-runtime-source.d.ts.map +1 -0
- package/dist/esm/utils/rich-text-content-runtime-source.js +588 -0
- package/dist/esm/utils/rich-text-content-runtime-source.js.map +1 -0
- package/dist/esm/utils/rich-text-content.d.ts +150 -0
- package/dist/esm/utils/rich-text-content.d.ts.map +1 -0
- package/dist/esm/utils/rich-text-content.js +613 -0
- package/dist/esm/utils/rich-text-content.js.map +1 -0
- package/dist/esm/utils/table-access.d.ts.map +1 -1
- package/dist/esm/utils/table-access.js +5 -7
- package/dist/esm/utils/table-access.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +6 -0
- package/src/page-transition/index.ts +1 -0
- package/src/page-transition/variant-sources.generated.ts +14 -0
- package/src/scroll-scene/engine-source.ts +7 -10
- package/src/scroll-scene/helper-sources.generated.ts +18 -0
- package/src/scroll-scene/index.ts +1 -0
- package/src/utils/content-tables.ts +151 -0
- package/src/utils/rich-text-content-codegen.ts +52 -0
- package/src/utils/rich-text-content-runtime-source.ts +587 -0
- package/src/utils/rich-text-content.ts +677 -0
- package/src/utils/table-access.ts +4 -2
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prints `components/rich-text-content.js` from the live functions in
|
|
3
|
+
* `src/utils/rich-text-content.ts`, the way `embed-runtime-emitter.ts` prints
|
|
4
|
+
* the embed runtime: test-only, with the result committed as the string in
|
|
5
|
+
* `src/utils/rich-text-content-runtime-source.ts` that the generator ships.
|
|
6
|
+
* `__tests__/utils/rich-text-content-runtime-module.ts` compares the two and
|
|
7
|
+
* rewrites the committed copy when run with UPDATE_RICH_TEXT_CONTENT_RUNTIME=1.
|
|
8
|
+
*/
|
|
9
|
+
import * as RichTextContent from '../../src/utils/rich-text-content'
|
|
10
|
+
|
|
11
|
+
const CONSTANT_NAMES = [
|
|
12
|
+
'PROTECTED_BLOCK_CLASS',
|
|
13
|
+
'PROTECTED_BLOCK_ATTR',
|
|
14
|
+
'PROTECTED_BLOCK_BLOT_NAME',
|
|
15
|
+
'PROTECTED_BLOCK_KINDS',
|
|
16
|
+
'CALLOUT_CLASS',
|
|
17
|
+
'CALLOUT_KIND_ATTR',
|
|
18
|
+
'CALLOUT_KINDS',
|
|
19
|
+
'RICH_TEXT_EMBED_CLASS',
|
|
20
|
+
'RICH_TEXT_IMAGE_CLASS',
|
|
21
|
+
'QUILL_LIST_ITEM_ATTR',
|
|
22
|
+
'QUILL_INDENT_CLASS_PREFIX',
|
|
23
|
+
'RICH_TEXT_INLINE_TAGS',
|
|
24
|
+
'RICH_TEXT_BLOCK_TAGS',
|
|
25
|
+
] as const
|
|
26
|
+
|
|
27
|
+
/** Every exported function, in source order: they only ever call each other and the constants. */
|
|
28
|
+
const FUNCTION_NAMES = [
|
|
29
|
+
'parseRichTextFragment',
|
|
30
|
+
'escapeRichTextText',
|
|
31
|
+
'escapeRichTextAttribute',
|
|
32
|
+
'isProtectedBlockKind',
|
|
33
|
+
'buildProtectedBlockHtml',
|
|
34
|
+
'readProtectedBlockValue',
|
|
35
|
+
'isCalloutKind',
|
|
36
|
+
'buildCalloutHtml',
|
|
37
|
+
'buildCodeBlockHtml',
|
|
38
|
+
'hasClass',
|
|
39
|
+
'isRichTextInlineNode',
|
|
40
|
+
'isBlankTextNode',
|
|
41
|
+
'isRichTextBlockElement',
|
|
42
|
+
'stripInterBlockWhitespace',
|
|
43
|
+
'unwrapSingleParagraphListItems',
|
|
44
|
+
'isExternalWebLink',
|
|
45
|
+
'normalizeLinkTargets',
|
|
46
|
+
'wrapBareBlockquoteContent',
|
|
47
|
+
'serializeRichTextNode',
|
|
48
|
+
'readInlineHtml',
|
|
49
|
+
'isQuillSimpleList',
|
|
50
|
+
'flattenListForQuill',
|
|
51
|
+
'isQuillSimpleBlockquote',
|
|
52
|
+
'blockquoteLinesForQuill',
|
|
53
|
+
'protectedKindForElement',
|
|
54
|
+
'toEditorHtml',
|
|
55
|
+
'fromEditorHtml',
|
|
56
|
+
'toCanonicalRichTextHtml',
|
|
57
|
+
'trimEmptyEdgeParagraphs',
|
|
58
|
+
'normalizeLegacyRichTextHtml',
|
|
59
|
+
'rebuildQuillListHtml',
|
|
60
|
+
'rebuildQuillCodeBlockHtml',
|
|
61
|
+
'mergeBlockquoteLines',
|
|
62
|
+
] as const
|
|
63
|
+
|
|
64
|
+
const bindRuntimeConstantReferences = (source: string, names: readonly string[]): string =>
|
|
65
|
+
names.reduce((acc, name) => acc.replace(new RegExp(`\\bexports\\.${name}\\b`, 'g'), name), source)
|
|
66
|
+
|
|
67
|
+
const RUNTIME_MODULE_HEADER = `/**
|
|
68
|
+
* Rich-text content: the stored form of a post body and the form the editor
|
|
69
|
+
* holds. Generated from @teleporthq/teleport-shared; edit it there.
|
|
70
|
+
*
|
|
71
|
+
* Stored HTML is plain: nested lists, tables with header rows, code blocks,
|
|
72
|
+
* callouts. The editor gets lists as Quill's lines and every block Quill has
|
|
73
|
+
* no blot for wrapped in a protected block it treats as one unit, and writes
|
|
74
|
+
* stored HTML back through fromEditorHtml.
|
|
75
|
+
*/
|
|
76
|
+
`
|
|
77
|
+
|
|
78
|
+
export function emitRichTextContentRuntimeModuleSourceFromFunctions(): string {
|
|
79
|
+
const module = RichTextContent as unknown as Record<string, unknown>
|
|
80
|
+
const declarations = CONSTANT_NAMES.map(
|
|
81
|
+
(name) => `export var ${name} = ${JSON.stringify(module[name], null, 2)}`
|
|
82
|
+
)
|
|
83
|
+
const missing = FUNCTION_NAMES.filter((name) => typeof module[name] !== 'function')
|
|
84
|
+
const unlisted = Object.keys(module).filter(
|
|
85
|
+
(name) =>
|
|
86
|
+
typeof module[name] === 'function' &&
|
|
87
|
+
(FUNCTION_NAMES as readonly string[]).indexOf(name) === -1
|
|
88
|
+
)
|
|
89
|
+
if (missing.length || unlisted.length) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
`Rich-text content runtime: functions missing ${JSON.stringify(
|
|
92
|
+
missing
|
|
93
|
+
)}, unlisted ${JSON.stringify(unlisted)}`
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
const functions = FUNCTION_NAMES.map(
|
|
97
|
+
(name) =>
|
|
98
|
+
`export ${bindRuntimeConstantReferences(
|
|
99
|
+
(module[name] as () => void).toString(),
|
|
100
|
+
CONSTANT_NAMES
|
|
101
|
+
)}`
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
const source = `${RUNTIME_MODULE_HEADER}\n${declarations.join('\n\n')}\n\n${functions.join(
|
|
105
|
+
'\n\n'
|
|
106
|
+
)}\n`
|
|
107
|
+
|
|
108
|
+
const leaked = source.match(/\bexports\.[A-Za-z_$][\w$]*/g)
|
|
109
|
+
if (leaked) {
|
|
110
|
+
throw new Error(
|
|
111
|
+
`Rich-text content runtime cannot be emitted: unresolved module references ${leaked.join(
|
|
112
|
+
', '
|
|
113
|
+
)}`
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
return source
|
|
117
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as path from 'path'
|
|
2
|
+
import { MANIFEST, renderSources } from '../../../scripts/function-sources'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The runtime helpers that ship as text inside generated projects are derived
|
|
6
|
+
* from their typed sources by scripts/function-sources.js. A generated module
|
|
7
|
+
* that is older than its source would ship yesterday's helper; this fails
|
|
8
|
+
* until `node scripts/function-sources.js` has been run again.
|
|
9
|
+
*/
|
|
10
|
+
describe('generated helper sources', () => {
|
|
11
|
+
const root = path.resolve(__dirname, '../../..')
|
|
12
|
+
|
|
13
|
+
for (const entry of MANIFEST) {
|
|
14
|
+
it(`${entry.output} is current`, () => {
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
16
|
+
const generated = require(path.join(root, entry.output))[entry.exportName]
|
|
17
|
+
expect(generated).toEqual(Object.fromEntries(renderSources(entry)))
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
it('carries every helper under its own name, so the emitted text calls them by name', () => {
|
|
22
|
+
for (const entry of MANIFEST) {
|
|
23
|
+
for (const [name, text] of renderSources(entry)) {
|
|
24
|
+
expect(
|
|
25
|
+
text.startsWith(`function ${name}(`) || text.startsWith(`async function ${name}(`)
|
|
26
|
+
).toBe(true)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
})
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CONTENT_COMMENTS_TABLES,
|
|
3
|
+
CONTENT_POSTS_TABLES,
|
|
4
|
+
CONTENT_POSTS_VISITOR_ROW_POLICY,
|
|
5
|
+
CONTENT_TABLES,
|
|
6
|
+
VISITOR_ROW_POLICIES,
|
|
7
|
+
contentTableRole,
|
|
8
|
+
contentTablesByKey,
|
|
9
|
+
isContentPostsTable,
|
|
10
|
+
} from '../../src/utils/content-tables'
|
|
11
|
+
import { CUSTOMER_RECORD_TABLES } from '../../src/utils/table-access'
|
|
12
|
+
|
|
13
|
+
describe('content tables', () => {
|
|
14
|
+
it('registers the Blog with its posts and comments tables', () => {
|
|
15
|
+
expect(contentTablesByKey('blog')).toEqual({
|
|
16
|
+
key: 'blog',
|
|
17
|
+
posts: 'teleport_blog_posts',
|
|
18
|
+
comments: 'teleport_blog_comments',
|
|
19
|
+
pictureStandIn: true,
|
|
20
|
+
})
|
|
21
|
+
expect(CONTENT_POSTS_TABLES).toContain('teleport_blog_posts')
|
|
22
|
+
expect(CONTENT_COMMENTS_TABLES).toContain('teleport_blog_comments')
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('registers the Help Center with an articles table and no comments', () => {
|
|
26
|
+
expect(contentTablesByKey('help')).toEqual({
|
|
27
|
+
key: 'help',
|
|
28
|
+
posts: 'teleport_help_articles',
|
|
29
|
+
comments: null,
|
|
30
|
+
// Text articles: one without a picture shows none, not a grey stand-in.
|
|
31
|
+
pictureStandIn: false,
|
|
32
|
+
})
|
|
33
|
+
expect(contentTableRole('teleport_help_articles')).toEqual({ key: 'help', role: 'posts' })
|
|
34
|
+
expect(CONTENT_COMMENTS_TABLES).not.toContain('teleport_help_comments')
|
|
35
|
+
expect(VISITOR_ROW_POLICIES.teleport_help_articles).toBe(CONTENT_POSTS_VISITOR_ROW_POLICY)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it('tells a content table apart from any other table, with its role', () => {
|
|
39
|
+
expect(contentTableRole('teleport_blog_posts')).toEqual({ key: 'blog', role: 'posts' })
|
|
40
|
+
expect(contentTableRole('teleport_blog_comments')).toEqual({ key: 'blog', role: 'comments' })
|
|
41
|
+
expect(contentTableRole('teleport_products')).toBeNull()
|
|
42
|
+
// A custom table named like a posts table is not one: the exact name decides.
|
|
43
|
+
expect(contentTableRole('blog_posts')).toBeNull()
|
|
44
|
+
expect(isContentPostsTable('teleport_blog_posts')).toBe(true)
|
|
45
|
+
expect(isContentPostsTable('teleport_blog_comments')).toBe(false)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('keeps every table name unique across presets and roles', () => {
|
|
49
|
+
const names = CONTENT_TABLES.flatMap((tables) =>
|
|
50
|
+
[tables.posts, tables.comments].filter((table): table is string => table !== null)
|
|
51
|
+
)
|
|
52
|
+
expect(new Set(names).size).toBe(names.length)
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('serves a visitor only published rows of every posts table, never the author email', () => {
|
|
56
|
+
for (const table of CONTENT_POSTS_TABLES) {
|
|
57
|
+
expect(VISITOR_ROW_POLICIES[table]).toBe(CONTENT_POSTS_VISITOR_ROW_POLICY)
|
|
58
|
+
}
|
|
59
|
+
expect(CONTENT_POSTS_VISITOR_ROW_POLICY.predicate).toBe("status = 'published'")
|
|
60
|
+
expect(CONTENT_POSTS_VISITOR_ROW_POLICY.hiddenColumns).toEqual(['author_email', 'authorEmail'])
|
|
61
|
+
expect(VISITOR_ROW_POLICIES.teleport_products.predicate).toBe("LOWER(TRIM(status)) = 'active'")
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('keeps every comments table a customer record: a browser never lists one', () => {
|
|
65
|
+
for (const table of CONTENT_COMMENTS_TABLES) {
|
|
66
|
+
expect(CUSTOMER_RECORD_TABLES).toContain(table)
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
})
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { parse } from '@babel/parser'
|
|
2
|
+
import { writeFileSync } from 'fs'
|
|
3
|
+
import { join } from 'path'
|
|
4
|
+
import { format, resolveConfig } from 'prettier'
|
|
5
|
+
import { RichTextContentCodegen } from '../../src'
|
|
6
|
+
import { emitRichTextContentRuntimeModuleSourceFromFunctions } from '../_helpers/rich-text-content-runtime-emitter'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The generated project gets `components/rich-text-content.js`, emitted from
|
|
10
|
+
* the very functions in `src/utils/rich-text-content.ts`. These tests keep that
|
|
11
|
+
* safe: the committed string is the one printed from the source, it parses as
|
|
12
|
+
* a module, and it evaluates with nothing left dangling.
|
|
13
|
+
*/
|
|
14
|
+
const SOURCE = RichTextContentCodegen.generateRichTextContentRuntimeModuleSource()
|
|
15
|
+
|
|
16
|
+
const COMMITTED_SOURCE_PATH = join(__dirname, '../../src/utils/rich-text-content-runtime-source.ts')
|
|
17
|
+
|
|
18
|
+
const writeCommittedSource = (source: string): void => {
|
|
19
|
+
const lines = source.split('\n').map((line) => ` ${JSON.stringify(line)},`)
|
|
20
|
+
const text = [
|
|
21
|
+
'// GENERATED from src/utils/rich-text-content.ts — do not edit by hand. Regenerate with',
|
|
22
|
+
'// UPDATE_RICH_TEXT_CONTENT_RUNTIME=1 npx jest packages/teleport-shared/__tests__/utils/rich-text-content-runtime-module.ts',
|
|
23
|
+
'// (see generateRichTextContentRuntimeModuleSource for why this is a string).',
|
|
24
|
+
'/* tslint:disable:no-invalid-template-strings -- the lines are JavaScript source */',
|
|
25
|
+
'export const RICH_TEXT_CONTENT_RUNTIME_MODULE_SOURCE = [',
|
|
26
|
+
...lines,
|
|
27
|
+
"].join('\\n')",
|
|
28
|
+
'',
|
|
29
|
+
].join('\n')
|
|
30
|
+
const options = resolveConfig.sync(COMMITTED_SOURCE_PATH) || {}
|
|
31
|
+
writeFileSync(COMMITTED_SOURCE_PATH, format(text, { ...options, parser: 'typescript' }))
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const loadRuntime = (): Record<string, (...args: never[]) => unknown> => {
|
|
35
|
+
const exportedNames = Array.from(
|
|
36
|
+
SOURCE.matchAll(/^export (?:var|function) ([A-Za-z_$][\w$]*)/gm)
|
|
37
|
+
).map((match) => match[1])
|
|
38
|
+
const body = `${SOURCE.replace(/^export /gm, '')}\nreturn { ${exportedNames.join(', ')} }`
|
|
39
|
+
// eslint-disable-next-line no-new-func
|
|
40
|
+
return new Function(body)() as Record<string, (...args: never[]) => unknown>
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
describe('the emitted rich-text content module', () => {
|
|
44
|
+
it('is the module printed from the source functions', () => {
|
|
45
|
+
const fresh = emitRichTextContentRuntimeModuleSourceFromFunctions()
|
|
46
|
+
if (process.env.UPDATE_RICH_TEXT_CONTENT_RUNTIME) {
|
|
47
|
+
writeCommittedSource(fresh)
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
// Fails after a change to rich-text-content.ts: regenerate the committed
|
|
51
|
+
// string with UPDATE_RICH_TEXT_CONTENT_RUNTIME=1 (command at the top of that file).
|
|
52
|
+
expect(SOURCE).toBe(fresh)
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('parses as an ES module', () => {
|
|
56
|
+
expect(() => parse(SOURCE, { sourceType: 'module' })).not.toThrow()
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('carries no reference the module itself does not declare', () => {
|
|
60
|
+
expect(SOURCE).not.toContain('exports.')
|
|
61
|
+
expect(() => loadRuntime()).not.toThrow()
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('answers the string-only questions exactly as the source module does', () => {
|
|
65
|
+
const runtime = loadRuntime()
|
|
66
|
+
const studio =
|
|
67
|
+
'<ol><li data-list="bullet"><span class="ql-ui" contenteditable="false"></span>one</li>' +
|
|
68
|
+
'<li data-list="ordered" class="ql-indent-1"><span class="ql-ui" contenteditable="false"></span>two</li></ol>'
|
|
69
|
+
expect(runtime.normalizeLegacyRichTextHtml(studio as never)).toBe(
|
|
70
|
+
'<ul><li>one<ol><li>two</li></ol></li></ul>'
|
|
71
|
+
)
|
|
72
|
+
expect(runtime.buildCodeBlockHtml('js' as never, 'a < b' as never)).toBe(
|
|
73
|
+
'<pre><code class="language-js">a < b</code></pre>'
|
|
74
|
+
)
|
|
75
|
+
expect(runtime.buildProtectedBlockHtml('table' as never, '<table></table>' as never)).toBe(
|
|
76
|
+
'<div class="tq-protected" data-tq-protected="table" contenteditable="false"><table></table></div>'
|
|
77
|
+
)
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it('exports every helper the generated editor imports', () => {
|
|
81
|
+
const runtime = loadRuntime()
|
|
82
|
+
;[
|
|
83
|
+
'PROTECTED_BLOCK_BLOT_NAME',
|
|
84
|
+
'PROTECTED_BLOCK_CLASS',
|
|
85
|
+
'buildProtectedBlockHtml',
|
|
86
|
+
'readProtectedBlockValue',
|
|
87
|
+
'toEditorHtml',
|
|
88
|
+
'fromEditorHtml',
|
|
89
|
+
].forEach((name) => {
|
|
90
|
+
expect(runtime[name]).toBeDefined()
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
describe('the render-time normalizer cut for the data modules', () => {
|
|
96
|
+
const code = RichTextContentCodegen.generateLegacyRichTextNormalizerCode()
|
|
97
|
+
|
|
98
|
+
it('is plain declarations that evaluate on their own, without a DOM', () => {
|
|
99
|
+
expect(code).not.toContain('export ')
|
|
100
|
+
expect(code).not.toContain('DOMParser')
|
|
101
|
+
// eslint-disable-next-line no-new-func
|
|
102
|
+
const normalize = new Function(`${code}\nreturn normalizeLegacyRichTextHtml`)() as (
|
|
103
|
+
html: string
|
|
104
|
+
) => string
|
|
105
|
+
expect(
|
|
106
|
+
normalize(
|
|
107
|
+
'<ol><li data-list="bullet"><span class="ql-ui" contenteditable="false"></span>one</li></ol><p>a b</p>'
|
|
108
|
+
)
|
|
109
|
+
).toBe('<ul><li>one</li></ul><p>a b</p>')
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it('parses as a script', () => {
|
|
113
|
+
expect(() => parse(code, { sourceType: 'script' })).not.toThrow()
|
|
114
|
+
})
|
|
115
|
+
})
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { RichTextEmbeds } from '../../src'
|
|
2
|
+
import {
|
|
3
|
+
RICH_TEXT_EMBED_CLASS,
|
|
4
|
+
buildCalloutHtml,
|
|
5
|
+
buildCodeBlockHtml,
|
|
6
|
+
buildProtectedBlockHtml,
|
|
7
|
+
mergeBlockquoteLines,
|
|
8
|
+
normalizeLegacyRichTextHtml,
|
|
9
|
+
rebuildQuillListHtml,
|
|
10
|
+
trimEmptyEdgeParagraphs,
|
|
11
|
+
} from '../../src/utils/rich-text-content'
|
|
12
|
+
|
|
13
|
+
// The DOM half of the contract (`toEditorHtml`, `fromEditorHtml`, the help-center
|
|
14
|
+
// round trips) is covered in teleport-gui, whose test runner has a DOM — this
|
|
15
|
+
// repo's jest runs in a node environment. What runs here is the string-only
|
|
16
|
+
// half, the part a generated page runs where there is no DOM.
|
|
17
|
+
|
|
18
|
+
describe('the shared constants', () => {
|
|
19
|
+
it('names the embed figure the way the embed contract does', () => {
|
|
20
|
+
expect(RICH_TEXT_EMBED_CLASS).toBe(RichTextEmbeds.EMBED_CLASS_NAME)
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
describe('the stored markup builders', () => {
|
|
25
|
+
it('escapes code and names its language', () => {
|
|
26
|
+
expect(buildCodeBlockHtml('html', '<div>\n x\n</div>')).toBe(
|
|
27
|
+
'<pre><code class="language-html"><div>\n x\n</div></code></pre>'
|
|
28
|
+
)
|
|
29
|
+
expect(buildCodeBlockHtml('plain', 'a')).toBe('<pre><code>a</code></pre>')
|
|
30
|
+
expect(buildCodeBlockHtml('c++', 'a')).toBe('<pre><code class="language-c++">a</code></pre>')
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('writes a callout and a protected wrapper in their one spelling', () => {
|
|
34
|
+
expect(buildCalloutHtml('warning', '<p>Careful.</p>')).toBe(
|
|
35
|
+
'<aside class="tq-callout" data-kind="warning"><p>Careful.</p></aside>'
|
|
36
|
+
)
|
|
37
|
+
expect(buildProtectedBlockHtml('table', '<table></table>')).toBe(
|
|
38
|
+
'<div class="tq-protected" data-tq-protected="table" contenteditable="false"><table></table></div>'
|
|
39
|
+
)
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
describe('normalizeLegacyRichTextHtml', () => {
|
|
44
|
+
it('turns what the studio form stored for a list into real lists', () => {
|
|
45
|
+
const studio =
|
|
46
|
+
'<ol><li data-list="bullet"><span class="ql-ui" contenteditable="false"></span>bullet one</li>' +
|
|
47
|
+
'<li data-list="bullet"><span class="ql-ui" contenteditable="false"></span>bullet two</li>' +
|
|
48
|
+
'<li data-list="ordered"><span class="ql-ui" contenteditable="false"></span>number one</li>' +
|
|
49
|
+
'<li data-list="ordered"><span class="ql-ui" contenteditable="false"></span>number two</li></ol>' +
|
|
50
|
+
'<blockquote>quoted</blockquote><p>plain</p>'
|
|
51
|
+
expect(normalizeLegacyRichTextHtml(studio)).toBe(
|
|
52
|
+
'<ul><li>bullet one</li><li>bullet two</li></ul><ol><li>number one</li><li>number two</li></ol>' +
|
|
53
|
+
'<blockquote><p>quoted</p></blockquote><p>plain</p>'
|
|
54
|
+
)
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('rebuilds nesting from the indent classes', () => {
|
|
58
|
+
const studio =
|
|
59
|
+
'<ol><li data-list="ordered">Step one</li>' +
|
|
60
|
+
'<li data-list="bullet" class="ql-indent-1">detail a</li>' +
|
|
61
|
+
'<li data-list="bullet" class="ql-indent-1">detail b</li>' +
|
|
62
|
+
'<li data-list="ordered">Step two</li></ol>'
|
|
63
|
+
expect(normalizeLegacyRichTextHtml(studio)).toBe(
|
|
64
|
+
'<ol><li>Step one<ul><li>detail a</li><li>detail b</li></ul></li><li>Step two</li></ol>'
|
|
65
|
+
)
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('merges the quote lines the studio stored into one quote of paragraphs', () => {
|
|
69
|
+
expect(
|
|
70
|
+
normalizeLegacyRichTextHtml('<blockquote>one</blockquote><blockquote>two</blockquote>')
|
|
71
|
+
).toBe('<blockquote><p>one</p><p>two</p></blockquote>')
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
it('turns what the admin panel stored into plain spaces and a real code block', () => {
|
|
75
|
+
const admin =
|
|
76
|
+
'<ul><li>bullet one</li><li>bullet two</li></ul>' +
|
|
77
|
+
'<p>Run <strong>npm install</strong> first.</p>' +
|
|
78
|
+
'<pre data-language="plain">\n<div>\nx\n</div>\n</pre>'
|
|
79
|
+
expect(normalizeLegacyRichTextHtml(admin)).toBe(
|
|
80
|
+
'<ul><li>bullet one</li><li>bullet two</li></ul>' +
|
|
81
|
+
'<p>Run <strong>npm install</strong> first.</p>' +
|
|
82
|
+
'<pre><code><div>\nx\n</div></code></pre>'
|
|
83
|
+
)
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
it('keeps a no-break space that stands next to another space', () => {
|
|
87
|
+
expect(normalizeLegacyRichTextHtml('<p>a b</p>')).toBe('<p>a b</p>')
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
it("turns the studio's code-block lines into one pre", () => {
|
|
91
|
+
const studio =
|
|
92
|
+
'<div class="ql-code-block-container" spellcheck="false">' +
|
|
93
|
+
'<div class="ql-code-block" data-language="javascript">const a = 1</div>' +
|
|
94
|
+
'<div class="ql-code-block" data-language="javascript"><br></div>' +
|
|
95
|
+
'<div class="ql-code-block" data-language="javascript"> return a</div></div><p>after</p>'
|
|
96
|
+
expect(normalizeLegacyRichTextHtml(studio)).toBe(
|
|
97
|
+
'<pre><code class="language-javascript">const a = 1\n\n return a</code></pre><p>after</p>'
|
|
98
|
+
)
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
it('leaves stored HTML as it is', () => {
|
|
102
|
+
const stored =
|
|
103
|
+
'<h2 id="a">A</h2><p>Text with <code>code</code>.</p>' +
|
|
104
|
+
'<ol><li>a<ul><li>b</li></ul></li></ol>' +
|
|
105
|
+
'<blockquote><p>x</p></blockquote><blockquote><p>y</p></blockquote>' +
|
|
106
|
+
'<pre><code class="language-js">let a = 1</code></pre>' +
|
|
107
|
+
'<aside class="tq-callout" data-kind="tip"><p>Tip.</p></aside>' +
|
|
108
|
+
'<table><thead><tr><th>H</th></tr></thead><tbody><tr><td>1</td></tr></tbody></table>'
|
|
109
|
+
expect(normalizeLegacyRichTextHtml(stored)).toBe(stored)
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it('reads a deeper first line as the top level', () => {
|
|
113
|
+
expect(
|
|
114
|
+
rebuildQuillListHtml(
|
|
115
|
+
'<li data-list="bullet" class="ql-indent-2">a</li><li data-list="bullet">b</li>'
|
|
116
|
+
)
|
|
117
|
+
).toBe('<ul><li>a</li><li>b</li></ul>')
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
it('leaves a run of stored quotes alone', () => {
|
|
121
|
+
const run = '<blockquote><p>a</p></blockquote><blockquote><p>b</p></blockquote>'
|
|
122
|
+
expect(mergeBlockquoteLines(run)).toBe(run)
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
it('drops the empty paragraphs Quill adds at either end, and keeps one in the middle', () => {
|
|
126
|
+
expect(trimEmptyEdgeParagraphs('<p><br></p><p>a</p><p><br></p><p>b</p><p><br></p>')).toBe(
|
|
127
|
+
'<p>a</p><p><br></p><p>b</p>'
|
|
128
|
+
)
|
|
129
|
+
expect(trimEmptyEdgeParagraphs('<p></p><h2>x</h2>')).toBe('<h2>x</h2>')
|
|
130
|
+
})
|
|
131
|
+
})
|
package/dist/cjs/index.d.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';
|
|
@@ -34,5 +37,5 @@ import * as PageTransition from './page-transition';
|
|
|
34
37
|
import * as StateBindings from './state-bindings';
|
|
35
38
|
import * as WebPush from './utils/web-push';
|
|
36
39
|
import * as InlineScriptErrorGuard from './utils/inline-script-error-guard';
|
|
37
|
-
export { Constants, StringUtils, UIDLUtils, GenericUtils, LocalImports, JSIdentifiers, ASTScope, ASTStatementOrder, ASTEffectCleanup, RoutePaths, LayoutTopology, HtmlContentModel, StyleDeclarations, StorefrontTax, ProductDiscounts, ProductRatings, RegionalPricing, DiscountEngine, ProductOptions, CartLinePricing, CartCurrency, TableAccess, SessionCookieResolver, SubscriptionAccess, FontPreconnect, EmailDate, RichTextEmbeds, RichTextEmbedsCodegen, DataCache, PageRevalidate, ScrollSceneRuntime, MotionRuntime, PageTransition, StateBindings, WebPush, InlineScriptErrorGuard, };
|
|
40
|
+
export { Constants, StringUtils, UIDLUtils, GenericUtils, LocalImports, JSIdentifiers, ASTScope, ASTStatementOrder, ASTEffectCleanup, RoutePaths, LayoutTopology, HtmlContentModel, StyleDeclarations, StorefrontTax, ProductDiscounts, ProductRatings, RegionalPricing, DiscountEngine, ProductOptions, CartLinePricing, CartCurrency, TableAccess, ContentTables, SessionCookieResolver, SubscriptionAccess, FontPreconnect, EmailDate, RichTextEmbeds, RichTextEmbedsCodegen, RichTextContent, RichTextContentCodegen, DataCache, PageRevalidate, ScrollSceneRuntime, MotionRuntime, PageTransition, StateBindings, WebPush, InlineScriptErrorGuard, };
|
|
38
41
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,WAAW,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,YAAY,MAAM,iBAAiB,CAAA;AAC/C,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAA;AACrD,OAAO,KAAK,aAAa,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAA;AAC7C,OAAO,KAAK,iBAAiB,MAAM,6BAA6B,CAAA;AAChE,OAAO,KAAK,gBAAgB,MAAM,4BAA4B,CAAA;AAC9D,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,cAAc,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,gBAAgB,MAAM,4BAA4B,CAAA;AAC9D,OAAO,KAAK,iBAAiB,MAAM,4BAA4B,CAAA;AAC/D,OAAO,KAAK,aAAa,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,gBAAgB,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,cAAc,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,eAAe,MAAM,0BAA0B,CAAA;AAC3D,OAAO,KAAK,cAAc,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,cAAc,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,e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A;AACzD,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,cAAc,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,qBAAqB,MAAM,kCAAkC,CAAA;AACzE,OAAO,KAAK,eAAe,MAAM,2BAA2B,CAAA;AAC5D,OAAO,KAAK,sBAAsB,MAAM,mCAAmC,CAAA;AAC3E,OAAO,KAAK,SAAS,MAAM,SAAS,CAAA;AACpC,OAAO,KAAK,cAAc,MAAM,mBAAmB,CAAA;AACnD,OAAO,KAAK,kBAAkB,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,aAAa,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,cAAc,MAAM,mBAAmB,CAAA;AACnD,OAAO,KAAK,aAAa,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,sBAAsB,MAAM,mCAAmC,CAAA;AAE3E,OAAO,EACL,SAAS,EACT,WAAW,EACX,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,cAAc,EACd,cAAc,EACd,eAAe,EACf,YAAY,EACZ,WAAW,EACX,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,SAAS,EACT,cAAc,EACd,qBAAqB,EACrB,eAAe,EACf,sBAAsB,EACtB,SAAS,EACT,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,aAAa,EACb,OAAO,EACP,sBAAsB,GACvB,CAAA"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.InlineScriptErrorGuard = exports.WebPush = exports.StateBindings = exports.PageTransition = exports.MotionRuntime = exports.ScrollSceneRuntime = exports.PageRevalidate = exports.DataCache = exports.RichTextEmbedsCodegen = exports.RichTextEmbeds = exports.EmailDate = exports.FontPreconnect = exports.SubscriptionAccess = exports.SessionCookieResolver = exports.TableAccess = exports.CartCurrency = exports.CartLinePricing = exports.ProductOptions = exports.DiscountEngine = exports.RegionalPricing = exports.ProductRatings = exports.ProductDiscounts = exports.StorefrontTax = exports.StyleDeclarations = exports.HtmlContentModel = exports.LayoutTopology = exports.RoutePaths = exports.ASTEffectCleanup = exports.ASTStatementOrder = exports.ASTScope = exports.JSIdentifiers = exports.LocalImports = exports.GenericUtils = exports.UIDLUtils = exports.StringUtils = exports.Constants = void 0;
|
|
26
|
+
exports.InlineScriptErrorGuard = exports.WebPush = exports.StateBindings = exports.PageTransition = exports.MotionRuntime = exports.ScrollSceneRuntime = exports.PageRevalidate = exports.DataCache = exports.RichTextContentCodegen = exports.RichTextContent = exports.RichTextEmbedsCodegen = exports.RichTextEmbeds = exports.EmailDate = exports.FontPreconnect = exports.SubscriptionAccess = exports.SessionCookieResolver = exports.ContentTables = exports.TableAccess = exports.CartCurrency = exports.CartLinePricing = exports.ProductOptions = exports.DiscountEngine = exports.RegionalPricing = exports.ProductRatings = exports.ProductDiscounts = exports.StorefrontTax = exports.StyleDeclarations = exports.HtmlContentModel = exports.LayoutTopology = exports.RoutePaths = exports.ASTEffectCleanup = exports.ASTStatementOrder = exports.ASTScope = exports.JSIdentifiers = exports.LocalImports = exports.GenericUtils = exports.UIDLUtils = exports.StringUtils = exports.Constants = void 0;
|
|
27
27
|
var Constants = __importStar(require("./constants"));
|
|
28
28
|
exports.Constants = Constants;
|
|
29
29
|
var StringUtils = __importStar(require("./utils/string-utils"));
|
|
@@ -68,6 +68,8 @@ var CartCurrency = __importStar(require("./utils/cart-currency"));
|
|
|
68
68
|
exports.CartCurrency = CartCurrency;
|
|
69
69
|
var TableAccess = __importStar(require("./utils/table-access"));
|
|
70
70
|
exports.TableAccess = TableAccess;
|
|
71
|
+
var ContentTables = __importStar(require("./utils/content-tables"));
|
|
72
|
+
exports.ContentTables = ContentTables;
|
|
71
73
|
var SessionCookieResolver = __importStar(require("./utils/session-cookie-resolver"));
|
|
72
74
|
exports.SessionCookieResolver = SessionCookieResolver;
|
|
73
75
|
var SubscriptionAccess = __importStar(require("./utils/subscription-access"));
|
|
@@ -80,6 +82,10 @@ var RichTextEmbeds = __importStar(require("./utils/rich-text-embeds"));
|
|
|
80
82
|
exports.RichTextEmbeds = RichTextEmbeds;
|
|
81
83
|
var RichTextEmbedsCodegen = __importStar(require("./utils/rich-text-embeds-codegen"));
|
|
82
84
|
exports.RichTextEmbedsCodegen = RichTextEmbedsCodegen;
|
|
85
|
+
var RichTextContent = __importStar(require("./utils/rich-text-content"));
|
|
86
|
+
exports.RichTextContent = RichTextContent;
|
|
87
|
+
var RichTextContentCodegen = __importStar(require("./utils/rich-text-content-codegen"));
|
|
88
|
+
exports.RichTextContentCodegen = RichTextContentCodegen;
|
|
83
89
|
var DataCache = __importStar(require("./cache"));
|
|
84
90
|
exports.DataCache = DataCache;
|
|
85
91
|
var PageRevalidate = __importStar(require("./page-revalidate"));
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAwC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAwC;AAyCtC,8BAAS;AAxCX,gEAAmD;AAyCjD,kCAAW;AAxCb,4DAA+C;AAyC7C,8BAAS;AAxCX,4DAA+C;AAyC7C,oCAAY;AAxCd,kEAAqD;AAyCnD,oCAAY;AAxCd,oEAAuD;AAyCrD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c,gBAAgB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/page-transition/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,6BAA6B,CAAA;AAC3C,cAAc,uBAAuB,CAAA;AACrC,cAAc,gBAAgB,CAAA"}
|
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./variants"), exports);
|
|
18
|
+
__exportStar(require("./variant-sources.generated"), exports);
|
|
18
19
|
__exportStar(require("./view-transition-css"), exports);
|
|
19
20
|
__exportStar(require("./morph-source"), exports);
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/page-transition/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,wDAAqC;AACrC,iDAA8B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/page-transition/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,8DAA2C;AAC3C,wDAAqC;AACrC,iDAA8B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variant-sources.generated.d.ts","sourceRoot":"","sources":["../../../src/page-transition/variant-sources.generated.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,8BAA8B;;;;;CAS1C,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PAGE_TRANSITION_HELPER_SOURCES = void 0;
|
|
4
|
+
// Generated by scripts/function-sources.js from variants.ts. Do not edit:
|
|
5
|
+
// `node scripts/function-sources.js` rewrites it, and its drift test fails until it is current.
|
|
6
|
+
/* tslint:disable */
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
exports.PAGE_TRANSITION_HELPER_SOURCES = {
|
|
9
|
+
reversePageTransitionPreset: "function reversePageTransitionPreset(preset) {\n var pairs = {\n 'slide-up': 'slide-down',\n 'slide-down': 'slide-up',\n 'slide-left': 'slide-right',\n 'slide-right': 'slide-left',\n 'zoom-in': 'zoom-out',\n 'zoom-out': 'zoom-in',\n 'wipe-down': 'wipe-up',\n 'wipe-up': 'wipe-down',\n 'wipe-left': 'wipe-right',\n 'wipe-right': 'wipe-left',\n stack: 'unstack',\n unstack: 'stack',\n };\n return pairs[preset] || preset;\n}",
|
|
10
|
+
pageTransitionVariants: "function pageTransitionVariants(preset, slidePx, context, options, custom) {\n var reverse = context ? context.reverse : false;\n var originX = context ? context.originX : '50%';\n var originY = context ? context.originY : '50%';\n var name = reverse ? reversePageTransitionPreset(preset) : preset;\n var bold = options\n ? options.distance === 'bold' || options.depth === 'bold' || options.amount === 'bold'\n : false;\n var near = bold ? slidePx * 4 : slidePx;\n var far = near * 2;\n var blurPx = options && options.softness === 'heavy' ? 28 : 12;\n var shrink = bold ? 0.85 : 0.94;\n var zoomOut = bold ? 0.85 : 0.96;\n var zoomIn = bold ? 1.15 : 1.04;\n if (name === 'custom') {\n var c = custom || {\n arrive: { opacity: 0, x: 0, y: 24, scale: 1, blur: 0 },\n leave: { opacity: 0, x: 0, y: -24, scale: 1, blur: 0 },\n };\n return {\n initial: {\n opacity: c.arrive.opacity,\n x: c.arrive.x,\n y: c.arrive.y,\n scale: c.arrive.scale,\n filter: 'blur(' + c.arrive.blur + 'px)',\n },\n animate: { opacity: 1, x: 0, y: 0, scale: 1, filter: 'blur(0px)' },\n exit: {\n opacity: c.leave.opacity,\n x: c.leave.x,\n y: c.leave.y,\n scale: c.leave.scale,\n filter: 'blur(' + c.leave.blur + 'px)',\n },\n };\n }\n if (name === 'fade') {\n return { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 } };\n }\n if (name === 'crossfade') {\n return {\n initial: { opacity: 0, scale: 1.02 },\n animate: { opacity: 1, scale: 1 },\n exit: { opacity: 0, scale: 0.98 },\n };\n }\n if (name === 'blur') {\n return {\n initial: { opacity: 0, filter: 'blur(' + blurPx + 'px)' },\n animate: { opacity: 1, filter: 'blur(0px)' },\n exit: { opacity: 0, filter: 'blur(' + blurPx + 'px)' },\n };\n }\n if (name === 'slide-up') {\n return {\n initial: { opacity: 0, y: near },\n animate: { opacity: 1, y: 0 },\n exit: { opacity: 0, y: -near },\n };\n }\n if (name === 'slide-down') {\n return {\n initial: { opacity: 0, y: -near },\n animate: { opacity: 1, y: 0 },\n exit: { opacity: 0, y: near },\n };\n }\n if (name === 'slide-left') {\n return {\n initial: { opacity: 0, x: far },\n animate: { opacity: 1, x: 0 },\n exit: { opacity: 0, x: -far },\n };\n }\n if (name === 'slide-right') {\n return {\n initial: { opacity: 0, x: -far },\n animate: { opacity: 1, x: 0 },\n exit: { opacity: 0, x: far },\n };\n }\n if (name === 'stack') {\n return {\n initial: { opacity: 0, y: far },\n animate: { opacity: 1, y: 0, scale: 1 },\n exit: { opacity: 0, scale: shrink },\n };\n }\n if (name === 'unstack') {\n return {\n initial: { opacity: 0, scale: shrink },\n animate: { opacity: 1, y: 0, scale: 1 },\n exit: { opacity: 0, y: far },\n };\n }\n if (name === 'zoom-in') {\n return {\n initial: { opacity: 0, scale: zoomOut },\n animate: { opacity: 1, scale: 1 },\n exit: { opacity: 0, scale: zoomIn },\n };\n }\n if (name === 'zoom-out') {\n return {\n initial: { opacity: 0, scale: zoomIn },\n animate: { opacity: 1, scale: 1 },\n exit: { opacity: 0, scale: zoomOut },\n };\n }\n if (name === 'wipe-down') {\n return {\n initial: { clipPath: 'inset(0 0 100% 0)' },\n animate: { clipPath: 'inset(0 0 0% 0)' },\n exit: { clipPath: 'inset(100% 0 0 0)' },\n };\n }\n if (name === 'wipe-up') {\n return {\n initial: { clipPath: 'inset(100% 0 0 0)' },\n animate: { clipPath: 'inset(0% 0 0 0)' },\n exit: { clipPath: 'inset(0 0 100% 0)' },\n };\n }\n if (name === 'wipe-left') {\n return {\n initial: { clipPath: 'inset(0 0 0 100%)' },\n animate: { clipPath: 'inset(0 0 0 0%)' },\n exit: { clipPath: 'inset(0 100% 0 0)' },\n };\n }\n if (name === 'wipe-right') {\n return {\n initial: { clipPath: 'inset(0 100% 0 0)' },\n animate: { clipPath: 'inset(0 0% 0 0)' },\n exit: { clipPath: 'inset(0 0 0 100%)' },\n };\n }\n if (name === 'circle') {\n var at = ' at ' + originX + ' ' + originY + ')';\n return {\n initial: { clipPath: 'circle(0%' + at },\n animate: { clipPath: 'circle(150%' + at },\n exit: { clipPath: 'circle(0%' + at },\n };\n }\n if (name === 'cover' || name === 'curtain') {\n return { initial: { opacity: 1 }, animate: { opacity: 1 }, exit: { opacity: 0.999 } };\n }\n return null;\n}",
|
|
11
|
+
pageTransitionCover: "function pageTransitionCover(preset) {\n if (preset === 'cover') {\n return [{ from: { y: '100%' }, cover: { y: '0%' }, away: { y: '-100%' } }];\n }\n if (preset === 'curtain') {\n return [\n { from: { x: '-100%' }, cover: { x: '0%' }, away: { x: '-100%' }, side: 'left' },\n { from: { x: '100%' }, cover: { x: '0%' }, away: { x: '100%' }, side: 'right' },\n ];\n }\n return null;\n}",
|
|
12
|
+
pageTransitionSkipPattern: "function pageTransitionSkipPattern(route) {\n var escaped = route.replace(/[.*+?^$()|{}\\\\]/g, '\\\\$&');\n return new RegExp('^' + escaped.replace(/\\[[^\\]]+\\]/g, '[^/]+') + '/?$');\n}",
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=variant-sources.generated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variant-sources.generated.js","sourceRoot":"","sources":["../../../src/page-transition/variant-sources.generated.ts"],"names":[],"mappings":";;;AAAA,0EAA0E;AAC1E,gGAAgG;AAChG,oBAAoB;AACpB,oBAAoB;AACP,QAAA,8BAA8B,GAAG;IAC5C,2BAA2B,EACzB,qgBAAqgB;IACvgB,sBAAsB,EACpB,2mKAA2mK;IAC7mK,mBAAmB,EACjB,2bAA2b;IAC7b,yBAAyB,EACvB,oMAAoM;CACvM,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine-source.d.ts","sourceRoot":"","sources":["../../../src/scroll-scene/engine-source.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"engine-source.d.ts","sourceRoot":"","sources":["../../../src/scroll-scene/engine-source.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,uBAAuB,QAAO,MAoTzC,CAAA"}
|