@lionrapid/core 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/auto-translator.d.ts.map +1 -1
- package/dist/browser/auto-translator.js +15 -4
- package/dist/browser/auto-translator.js.map +1 -1
- package/dist/browser/block-extractor.d.ts.map +1 -1
- package/dist/browser/block-extractor.js +6 -0
- package/dist/browser/block-extractor.js.map +1 -1
- package/dist/browser/editor/editor-api.d.ts +31 -1
- package/dist/browser/editor/editor-api.d.ts.map +1 -1
- package/dist/browser/editor/editor-api.js +43 -1
- package/dist/browser/editor/editor-api.js.map +1 -1
- package/dist/browser/editor/editor-init.js +25 -0
- package/dist/browser/editor/editor-init.js.map +1 -1
- package/dist/browser/editor/editor-styles.d.ts +1 -1
- package/dist/browser/editor/editor-styles.d.ts.map +1 -1
- package/dist/browser/editor/editor-styles.js +55 -0
- package/dist/browser/editor/editor-styles.js.map +1 -1
- package/dist/browser/editor/live-preview.d.ts.map +1 -1
- package/dist/browser/editor/live-preview.js +20 -3
- package/dist/browser/editor/live-preview.js.map +1 -1
- package/dist/browser/editor/sidebar.d.ts +20 -1
- package/dist/browser/editor/sidebar.d.ts.map +1 -1
- package/dist/browser/editor/sidebar.js +147 -9
- package/dist/browser/editor/sidebar.js.map +1 -1
- package/dist/browser/lionrapid.auto.dev.js +125 -311
- package/dist/browser/lionrapid.auto.dev.js.map +3 -3
- package/dist/browser/lionrapid.auto.js +125 -311
- package/dist/browser/lionrapid.auto.js.map +3 -3
- package/dist/browser/lionrapid.auto.min.js +3 -3
- package/dist/browser/lionrapid.auto.min.js.map +4 -4
- package/dist/browser/lionrapid.editor.js +274 -181
- package/dist/browser/lionrapid.editor.js.map +3 -3
- package/dist/browser/lionrapid.editor.min.js +58 -3
- package/dist/browser/lionrapid.editor.min.js.map +4 -4
- package/dist/browser/lionrapid.esm.js +108 -294
- package/dist/browser/lionrapid.esm.js.map +3 -3
- package/dist/browser/lionrapid.esm.min.js +2 -2
- package/dist/browser/lionrapid.esm.min.js.map +4 -4
- package/dist/browser/lionrapid.iife.dev.js +108 -294
- package/dist/browser/lionrapid.iife.dev.js.map +3 -3
- package/dist/browser/lionrapid.iife.js +108 -294
- package/dist/browser/lionrapid.iife.js.map +3 -3
- package/dist/browser/lionrapid.iife.min.js +2 -2
- package/dist/browser/lionrapid.iife.min.js.map +4 -4
- package/dist/browser/lionrapid.umd.js +108 -294
- package/dist/browser/lionrapid.umd.js.map +3 -3
- package/dist/browser/lionrapid.umd.min.js +2 -2
- package/dist/browser/lionrapid.umd.min.js.map +4 -4
- package/dist/browser/markup-parser.d.ts +9 -5
- package/dist/browser/markup-parser.d.ts.map +1 -1
- package/dist/browser/markup-parser.js +19 -23
- package/dist/browser/markup-parser.js.map +1 -1
- package/dist/content/canonical-tag.d.ts +34 -0
- package/dist/content/canonical-tag.d.ts.map +1 -0
- package/dist/content/canonical-tag.js +57 -0
- package/dist/content/canonical-tag.js.map +1 -0
- package/dist/content/index.d.ts +1 -4
- package/dist/content/index.d.ts.map +1 -1
- package/dist/content/index.js +3 -1
- package/dist/content/index.js.map +1 -1
- package/dist/content/parser/MarkupParser.d.ts +9 -49
- package/dist/content/parser/MarkupParser.d.ts.map +1 -1
- package/dist/content/parser/MarkupParser.js +37 -157
- package/dist/content/parser/MarkupParser.js.map +1 -1
- package/dist/content/serializer/HTMLSerializer.d.ts +10 -43
- package/dist/content/serializer/HTMLSerializer.d.ts.map +1 -1
- package/dist/content/serializer/HTMLSerializer.js +29 -69
- package/dist/content/serializer/HTMLSerializer.js.map +1 -1
- package/dist/content/types.d.ts +21 -12
- package/dist/content/types.d.ts.map +1 -1
- package/dist/content/validator/ContentValidator.d.ts +2 -2
- package/dist/content/validator/ContentValidator.js +2 -2
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/lionRapid.d.ts +1 -1
- package/dist/lionRapid.js +4 -4
- package/dist/lionRapid.js.map +1 -1
- package/dist/repositories/network-repository.d.ts +14 -0
- package/dist/repositories/network-repository.d.ts.map +1 -1
- package/dist/repositories/network-repository.js +26 -4
- package/dist/repositories/network-repository.js.map +1 -1
- package/package.json +1 -1
- package/dist/content/safe-href.d.ts +0 -22
- package/dist/content/safe-href.d.ts.map +0 -1
- package/dist/content/safe-href.js +0 -48
- package/dist/content/safe-href.js.map +0 -1
- package/dist/content/style-mapper/DefaultStyleMapper.d.ts +0 -59
- package/dist/content/style-mapper/DefaultStyleMapper.d.ts.map +0 -1
- package/dist/content/style-mapper/DefaultStyleMapper.js +0 -132
- package/dist/content/style-mapper/DefaultStyleMapper.js.map +0 -1
- package/dist/content/style-mapper/IStyleMapper.d.ts +0 -50
- package/dist/content/style-mapper/IStyleMapper.d.ts.map +0 -1
- package/dist/content/style-mapper/IStyleMapper.js +0 -6
- package/dist/content/style-mapper/IStyleMapper.js.map +0 -1
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* DOM-based Markup Parser
|
|
2
|
+
* DOM-based Markup Parser (raw-only)
|
|
3
3
|
*
|
|
4
|
-
* Converts a block element's childNodes into ContentUnit
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Converts a block element's childNodes into ContentUnit by walking the
|
|
5
|
+
* DOM. Every inline element becomes an indexed tag whose style is the
|
|
6
|
+
* verbatim opening tag in canonical form (see content/canonical-tag.ts).
|
|
7
|
+
*
|
|
8
|
+
* Mirrors the regex-based parser in `content/parser/MarkupParser.ts` and
|
|
9
|
+
* the edge proxy parser, producing byte-identical text + styles for the
|
|
10
|
+
* same source so translation keys match across boundaries.
|
|
7
11
|
*/
|
|
8
12
|
import type { ContentUnit } from '../content/types.js';
|
|
9
13
|
/**
|
|
10
|
-
* Parse a block element into ContentUnit using DOM walking
|
|
14
|
+
* Parse a block element into ContentUnit using DOM walking.
|
|
11
15
|
*/
|
|
12
16
|
export declare function parseBlockElement(element: Element): ContentUnit;
|
|
13
17
|
//# sourceMappingURL=markup-parser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markup-parser.d.ts","sourceRoot":"","sources":["../../src/browser/markup-parser.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"markup-parser.d.ts","sourceRoot":"","sources":["../../src/browser/markup-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGvD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CA4C/D"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* DOM-based Markup Parser
|
|
2
|
+
* DOM-based Markup Parser (raw-only)
|
|
3
3
|
*
|
|
4
|
-
* Converts a block element's childNodes into ContentUnit
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Converts a block element's childNodes into ContentUnit by walking the
|
|
5
|
+
* DOM. Every inline element becomes an indexed tag whose style is the
|
|
6
|
+
* verbatim opening tag in canonical form (see content/canonical-tag.ts).
|
|
7
|
+
*
|
|
8
|
+
* Mirrors the regex-based parser in `content/parser/MarkupParser.ts` and
|
|
9
|
+
* the edge proxy parser, producing byte-identical text + styles for the
|
|
10
|
+
* same source so translation keys match across boundaries.
|
|
7
11
|
*/
|
|
8
|
-
import {
|
|
9
|
-
const styleMapper = new DefaultStyleMapper();
|
|
12
|
+
import { serializeOpeningTag, VOID_TAGS } from '../content/canonical-tag.js';
|
|
10
13
|
/**
|
|
11
|
-
* Parse a block element into ContentUnit using DOM walking
|
|
14
|
+
* Parse a block element into ContentUnit using DOM walking.
|
|
12
15
|
*/
|
|
13
16
|
export function parseBlockElement(element) {
|
|
14
17
|
const styles = {};
|
|
@@ -22,30 +25,23 @@ export function parseBlockElement(element) {
|
|
|
22
25
|
}
|
|
23
26
|
const el = node;
|
|
24
27
|
const tag = el.tagName.toLowerCase();
|
|
25
|
-
// Collect attributes
|
|
28
|
+
// Collect attributes preserving source insertion order.
|
|
26
29
|
const attrs = {};
|
|
27
30
|
for (let i = 0; i < el.attributes.length; i++) {
|
|
28
31
|
const attr = el.attributes[i];
|
|
29
32
|
attrs[attr.name.toLowerCase()] = attr.value;
|
|
30
33
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
styles[String(idx)] = styleList;
|
|
37
|
-
let inner = '';
|
|
38
|
-
for (let i = 0; i < node.childNodes.length; i++) {
|
|
39
|
-
inner += walk(node.childNodes[i]);
|
|
40
|
-
}
|
|
41
|
-
return `<${idx}>${inner}</${idx}>`;
|
|
34
|
+
tagIndex++;
|
|
35
|
+
const idx = tagIndex;
|
|
36
|
+
styles[String(idx)] = [`raw:${serializeOpeningTag(tag, attrs)}`];
|
|
37
|
+
if (VOID_TAGS.has(tag)) {
|
|
38
|
+
return `<${idx}/>`;
|
|
42
39
|
}
|
|
43
|
-
|
|
44
|
-
let result = '';
|
|
40
|
+
let inner = '';
|
|
45
41
|
for (let i = 0; i < node.childNodes.length; i++) {
|
|
46
|
-
|
|
42
|
+
inner += walk(node.childNodes[i]);
|
|
47
43
|
}
|
|
48
|
-
return
|
|
44
|
+
return `<${idx}>${inner}</${idx}>`;
|
|
49
45
|
}
|
|
50
46
|
let text = '';
|
|
51
47
|
for (let i = 0; i < element.childNodes.length; i++) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markup-parser.js","sourceRoot":"","sources":["../../src/browser/markup-parser.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"markup-parser.js","sourceRoot":"","sources":["../../src/browser/markup-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE7E;;GAEG;AACH,MAAM,UAAU,iB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CAAC;YAChD,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,IAAI,GAAG,IAAI,KAAK,KAAK,GAAG,GAAG,CAAC;IACrC,CAAC;IAED,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACnD,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical opening-tag format for ContentUnit `raw:` styles.
|
|
3
|
+
*
|
|
4
|
+
* All four parsers (edge, core HTML walker, core DOM walker, PHP) must
|
|
5
|
+
* produce byte-identical output for the same source element. Rules:
|
|
6
|
+
* - tag name lowercased
|
|
7
|
+
* - attribute names lowercased
|
|
8
|
+
* - attribute values always wrapped in double-quotes
|
|
9
|
+
* - attribute insertion order preserved from source
|
|
10
|
+
* - boolean attrs emitted as `attr=""`
|
|
11
|
+
* - void elements use the same form (no self-closing slash, no close tag emitted)
|
|
12
|
+
*
|
|
13
|
+
* Attribute values are stored byte-for-byte as captured from the source
|
|
14
|
+
* (the source's own entity encoding is preserved — already valid HTML).
|
|
15
|
+
* The serializer only re-escapes `"` → `"` so the chosen double-quote
|
|
16
|
+
* delimiter stays well-formed when the source used single quotes.
|
|
17
|
+
*/
|
|
18
|
+
export declare const VOID_TAGS: Set<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Build the canonical opening tag string. Used by parsers to produce
|
|
21
|
+
* the `raw:<...>` style content.
|
|
22
|
+
*/
|
|
23
|
+
export declare function serializeOpeningTag(tagName: string, attrs: Record<string, string>): string;
|
|
24
|
+
/**
|
|
25
|
+
* Extract the tag name from a canonical opening tag string.
|
|
26
|
+
* `<span class="x">` → `span`. Returns lowercase.
|
|
27
|
+
*/
|
|
28
|
+
export declare function extractTagName(rawOpenTag: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Return the raw opening tag (the portion after `raw:`) from a style array,
|
|
31
|
+
* or null if no `raw:` style is present.
|
|
32
|
+
*/
|
|
33
|
+
export declare function readRawStyle(styles: string[]): string | null;
|
|
34
|
+
//# sourceMappingURL=canonical-tag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical-tag.d.ts","sourceRoot":"","sources":["../../src/content/canonical-tag.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,eAAO,MAAM,SAAS,aAGpB,CAAC;AAMH;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,MAAM,CAQR;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAGzD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAK5D"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical opening-tag format for ContentUnit `raw:` styles.
|
|
3
|
+
*
|
|
4
|
+
* All four parsers (edge, core HTML walker, core DOM walker, PHP) must
|
|
5
|
+
* produce byte-identical output for the same source element. Rules:
|
|
6
|
+
* - tag name lowercased
|
|
7
|
+
* - attribute names lowercased
|
|
8
|
+
* - attribute values always wrapped in double-quotes
|
|
9
|
+
* - attribute insertion order preserved from source
|
|
10
|
+
* - boolean attrs emitted as `attr=""`
|
|
11
|
+
* - void elements use the same form (no self-closing slash, no close tag emitted)
|
|
12
|
+
*
|
|
13
|
+
* Attribute values are stored byte-for-byte as captured from the source
|
|
14
|
+
* (the source's own entity encoding is preserved — already valid HTML).
|
|
15
|
+
* The serializer only re-escapes `"` → `"` so the chosen double-quote
|
|
16
|
+
* delimiter stays well-formed when the source used single quotes.
|
|
17
|
+
*/
|
|
18
|
+
export const VOID_TAGS = new Set([
|
|
19
|
+
'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',
|
|
20
|
+
'link', 'meta', 'param', 'source', 'track', 'wbr',
|
|
21
|
+
]);
|
|
22
|
+
function escapeAttrValue(value) {
|
|
23
|
+
return value.replace(/"/g, '"');
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Build the canonical opening tag string. Used by parsers to produce
|
|
27
|
+
* the `raw:<...>` style content.
|
|
28
|
+
*/
|
|
29
|
+
export function serializeOpeningTag(tagName, attrs) {
|
|
30
|
+
const tag = tagName.toLowerCase();
|
|
31
|
+
let result = `<${tag}`;
|
|
32
|
+
for (const [name, value] of Object.entries(attrs)) {
|
|
33
|
+
result += ` ${name.toLowerCase()}="${escapeAttrValue(value)}"`;
|
|
34
|
+
}
|
|
35
|
+
result += '>';
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Extract the tag name from a canonical opening tag string.
|
|
40
|
+
* `<span class="x">` → `span`. Returns lowercase.
|
|
41
|
+
*/
|
|
42
|
+
export function extractTagName(rawOpenTag) {
|
|
43
|
+
const end = rawOpenTag.search(/[\s>]/);
|
|
44
|
+
return rawOpenTag.slice(1, end === -1 ? rawOpenTag.length : end).toLowerCase();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Return the raw opening tag (the portion after `raw:`) from a style array,
|
|
48
|
+
* or null if no `raw:` style is present.
|
|
49
|
+
*/
|
|
50
|
+
export function readRawStyle(styles) {
|
|
51
|
+
for (const s of styles) {
|
|
52
|
+
if (s.startsWith('raw:'))
|
|
53
|
+
return s.slice(4);
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=canonical-tag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical-tag.js","sourceRoot":"","sources":["../../src/content/canonical-tag.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC;IAC/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO;IAC1D,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK;CAClD,CAAC,CAAC;AAEH,SAAS,eAAe,CAAC,KAAa;IACpC,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACvC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAAe,EACf,KAA6B;IAE7B,MAAM,GAAG,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAClC,IAAI,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;IACvB,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,IAAI,IAAI,CAAC,WAAW,EAAE,KAAK,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC;IACjE,CAAC;IACD,MAAM,IAAI,GAAG,CAAC;IACd,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,UAAkB;IAC/C,MAAM,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACvC,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;AACjF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,MAAgB;IAC3C,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,IAAI,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC;YAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/content/index.d.ts
CHANGED
|
@@ -9,12 +9,9 @@
|
|
|
9
9
|
export type { ContentUnit } from './types.js';
|
|
10
10
|
export type { IParser } from './parser/IParser.js';
|
|
11
11
|
export { MarkupParser } from './parser/MarkupParser.js';
|
|
12
|
-
export type { MarkupParserOptions } from './parser/MarkupParser.js';
|
|
13
12
|
export type { ISerializer } from './serializer/ISerializer.js';
|
|
14
13
|
export { HTMLSerializer } from './serializer/HTMLSerializer.js';
|
|
15
|
-
export type { HTMLSerializerOptions } from './serializer/HTMLSerializer.js';
|
|
16
14
|
export type { IValidator, ValidationResult, ValidationError, ValidationWarning, ValidationErrorCode, ValidationWarningCode, } from './validator/IValidator.js';
|
|
17
15
|
export { ContentValidator } from './validator/ContentValidator.js';
|
|
18
|
-
export
|
|
19
|
-
export { DefaultStyleMapper } from './style-mapper/DefaultStyleMapper.js';
|
|
16
|
+
export { VOID_TAGS, serializeOpeningTag, extractTagName, readRawStyle, } from './canonical-tag.js';
|
|
20
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/content/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAG9C,YAAY,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/content/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAG9C,YAAY,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGxD,YAAY,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAGhE,YAAY,EACV,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAInE,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,cAAc,EACd,YAAY,GACb,MAAM,oBAAoB,CAAC"}
|
package/dist/content/index.js
CHANGED
|
@@ -9,5 +9,7 @@
|
|
|
9
9
|
export { MarkupParser } from './parser/MarkupParser.js';
|
|
10
10
|
export { HTMLSerializer } from './serializer/HTMLSerializer.js';
|
|
11
11
|
export { ContentValidator } from './validator/ContentValidator.js';
|
|
12
|
-
|
|
12
|
+
// Canonical raw-tag helpers — used by all parsers/serializers (core, edge,
|
|
13
|
+
// react, php) so they produce byte-identical output for the same source.
|
|
14
|
+
export { VOID_TAGS, serializeOpeningTag, extractTagName, readRawStyle, } from './canonical-tag.js';
|
|
13
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/content/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/content/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAIxD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAWhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,2EAA2E;AAC3E,yEAAyE;AACzE,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,cAAc,EACd,YAAY,GACb,MAAM,oBAAoB,CAAC"}
|
|
@@ -1,67 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Markup parser
|
|
2
|
+
* Markup parser — converts HTML strings to ContentUnit (raw-only).
|
|
3
|
+
*
|
|
4
|
+
* Every inline element becomes an indexed tag whose style is the verbatim
|
|
5
|
+
* opening tag in canonical form (see canonical-tag.ts). No element-to-
|
|
6
|
+
* semantic-style mapping — wrappers round-trip exactly.
|
|
7
|
+
*
|
|
3
8
|
* @module content/parser/MarkupParser
|
|
4
9
|
*/
|
|
5
10
|
import type { IParser } from './IParser.js';
|
|
6
11
|
import type { ContentUnit } from '../types.js';
|
|
7
|
-
import type { IStyleMapper } from '../style-mapper/IStyleMapper.js';
|
|
8
|
-
/**
|
|
9
|
-
* Configuration options for MarkupParser
|
|
10
|
-
*/
|
|
11
|
-
export interface MarkupParserOptions {
|
|
12
|
-
/**
|
|
13
|
-
* Custom style mapper for element ↔ style conversion
|
|
14
|
-
* Defaults to DefaultStyleMapper
|
|
15
|
-
*/
|
|
16
|
-
styleMapper?: IStyleMapper;
|
|
17
|
-
}
|
|
18
12
|
/**
|
|
19
|
-
* Parser that converts HTML markup strings to ContentUnit
|
|
20
|
-
*
|
|
21
|
-
* Transforms inline HTML elements into indexed tags with style mapping:
|
|
22
|
-
* - `<b>bold</b>` → text: `<1>bold</1>`, styles: `{"1": ["bold"]}`
|
|
23
|
-
* - `<a href="/url">link</a>` → styles: `{"1": ["hyperlink:/url"]}`
|
|
13
|
+
* Parser that converts HTML markup strings to ContentUnit (raw-only).
|
|
24
14
|
*
|
|
25
15
|
* @example
|
|
26
16
|
* ```typescript
|
|
27
17
|
* const parser = new MarkupParser();
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* // → { text: "Read our <1>Terms</1>.", styles: {"1": ["bold"]} }
|
|
31
|
-
*
|
|
32
|
-
* const nested = parser.parse('<b>bold <i>and italic</i></b>');
|
|
33
|
-
* // → { text: "<1>bold <2>and italic</2></1>", styles: {"1": ["bold"], "2": ["italic"]} }
|
|
18
|
+
* parser.parse('Read our <b>Terms</b>.');
|
|
19
|
+
* // → { text: 'Read our <1>Terms</1>.', styles: { '1': ['raw:<b>'] } }
|
|
34
20
|
* ```
|
|
35
21
|
*/
|
|
36
22
|
export declare class MarkupParser implements IParser<string> {
|
|
37
|
-
private readonly styleMapper;
|
|
38
|
-
constructor(options?: MarkupParserOptions);
|
|
39
|
-
/**
|
|
40
|
-
* Parse HTML string into ContentUnit
|
|
41
|
-
*
|
|
42
|
-
* Handles two input formats:
|
|
43
|
-
* 1. HTML tags: `<b>text</b>` → converts to indexed `<1>text</1>` with styles
|
|
44
|
-
* 2. Already indexed: `<1>text</1>` → passes through as-is (from server)
|
|
45
|
-
*
|
|
46
|
-
* @param input - HTML string with inline elements or already indexed
|
|
47
|
-
* @returns ContentUnit with indexed tags and styles
|
|
48
|
-
*/
|
|
49
23
|
parse(input: string): ContentUnit;
|
|
50
|
-
/**
|
|
51
|
-
* Match an HTML tag at the given position
|
|
52
|
-
*/
|
|
53
24
|
private matchTag;
|
|
54
|
-
/**
|
|
55
|
-
* Parse HTML attributes string into key-value pairs
|
|
56
|
-
*/
|
|
57
25
|
private parseAttributes;
|
|
58
|
-
/**
|
|
59
|
-
* Find matching opening tag in the stack
|
|
60
|
-
*/
|
|
61
|
-
private findMatchingOpenTag;
|
|
62
|
-
/**
|
|
63
|
-
* Find the closing tag index for a given opening tag
|
|
64
|
-
*/
|
|
65
|
-
private findClosingTagIndex;
|
|
66
26
|
}
|
|
67
27
|
//# sourceMappingURL=MarkupParser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkupParser.d.ts","sourceRoot":"","sources":["../../../src/content/parser/MarkupParser.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"MarkupParser.d.ts","sourceRoot":"","sources":["../../../src/content/parser/MarkupParser.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAY/C;;;;;;;;;GASG;AACH,qBAAa,YAAa,YAAW,OAAO,CAAC,MAAM,CAAC;IAClD,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW;IA6DjC,OAAO,CAAC,QAAQ;IA2BhB,OAAO,CAAC,eAAe;CAYxB"}
|
|
@@ -1,162 +1,85 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Markup parser
|
|
2
|
+
* Markup parser — converts HTML strings to ContentUnit (raw-only).
|
|
3
|
+
*
|
|
4
|
+
* Every inline element becomes an indexed tag whose style is the verbatim
|
|
5
|
+
* opening tag in canonical form (see canonical-tag.ts). No element-to-
|
|
6
|
+
* semantic-style mapping — wrappers round-trip exactly.
|
|
7
|
+
*
|
|
3
8
|
* @module content/parser/MarkupParser
|
|
4
9
|
*/
|
|
5
|
-
import {
|
|
10
|
+
import { serializeOpeningTag, VOID_TAGS } from '../canonical-tag.js';
|
|
6
11
|
/**
|
|
7
|
-
* Parser that converts HTML markup strings to ContentUnit
|
|
8
|
-
*
|
|
9
|
-
* Transforms inline HTML elements into indexed tags with style mapping:
|
|
10
|
-
* - `<b>bold</b>` → text: `<1>bold</1>`, styles: `{"1": ["bold"]}`
|
|
11
|
-
* - `<a href="/url">link</a>` → styles: `{"1": ["hyperlink:/url"]}`
|
|
12
|
+
* Parser that converts HTML markup strings to ContentUnit (raw-only).
|
|
12
13
|
*
|
|
13
14
|
* @example
|
|
14
15
|
* ```typescript
|
|
15
16
|
* const parser = new MarkupParser();
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* // → { text: "Read our <1>Terms</1>.", styles: {"1": ["bold"]} }
|
|
19
|
-
*
|
|
20
|
-
* const nested = parser.parse('<b>bold <i>and italic</i></b>');
|
|
21
|
-
* // → { text: "<1>bold <2>and italic</2></1>", styles: {"1": ["bold"], "2": ["italic"]} }
|
|
17
|
+
* parser.parse('Read our <b>Terms</b>.');
|
|
18
|
+
* // → { text: 'Read our <1>Terms</1>.', styles: { '1': ['raw:<b>'] } }
|
|
22
19
|
* ```
|
|
23
20
|
*/
|
|
24
21
|
export class MarkupParser {
|
|
25
|
-
styleMapper;
|
|
26
|
-
constructor(options = {}) {
|
|
27
|
-
this.styleMapper = options.styleMapper ?? new DefaultStyleMapper();
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Parse HTML string into ContentUnit
|
|
31
|
-
*
|
|
32
|
-
* Handles two input formats:
|
|
33
|
-
* 1. HTML tags: `<b>text</b>` → converts to indexed `<1>text</1>` with styles
|
|
34
|
-
* 2. Already indexed: `<1>text</1>` → passes through as-is (from server)
|
|
35
|
-
*
|
|
36
|
-
* @param input - HTML string with inline elements or already indexed
|
|
37
|
-
* @returns ContentUnit with indexed tags and styles
|
|
38
|
-
*/
|
|
39
22
|
parse(input) {
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (hasIndexedTags) {
|
|
44
|
-
// Input already has indexed tags - pass through without style mapping
|
|
45
|
-
// The styles will come from component children in Trans, not from server
|
|
46
|
-
return {
|
|
47
|
-
text: input,
|
|
48
|
-
styles: {}, // Empty - styles determined by children
|
|
49
|
-
};
|
|
23
|
+
// Already indexed tags from server pass through unchanged.
|
|
24
|
+
if (/<\/?[0-9]+>/.test(input)) {
|
|
25
|
+
return { text: input, styles: {} };
|
|
50
26
|
}
|
|
51
27
|
const styles = {};
|
|
52
28
|
let tagIndex = 0;
|
|
53
|
-
// Stack to track open tags and their indices
|
|
54
29
|
const tagStack = [];
|
|
55
|
-
// Result text being built
|
|
56
30
|
let result = '';
|
|
57
31
|
let pos = 0;
|
|
58
32
|
while (pos < input.length) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (!tagMatch) {
|
|
62
|
-
// No more tags, append rest of string
|
|
33
|
+
const tag = this.matchTag(input, pos);
|
|
34
|
+
if (!tag) {
|
|
63
35
|
result += input.slice(pos);
|
|
64
36
|
break;
|
|
65
37
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const stackIndex = tagStack.findIndex((t) => t.index === matchingOpen);
|
|
75
|
-
if (stackIndex !== -1) {
|
|
76
|
-
tagStack.splice(stackIndex, 1);
|
|
38
|
+
result += input.slice(pos, tag.startIndex);
|
|
39
|
+
if (tag.isClosing) {
|
|
40
|
+
let matchIdx = null;
|
|
41
|
+
for (let i = tagStack.length - 1; i >= 0; i--) {
|
|
42
|
+
if (tagStack[i].tag === tag.tag.toLowerCase()) {
|
|
43
|
+
matchIdx = tagStack[i].index;
|
|
44
|
+
tagStack.splice(i, 1);
|
|
45
|
+
break;
|
|
77
46
|
}
|
|
78
47
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
result += input.slice(tagMatch.startIndex, tagMatch.endIndex);
|
|
48
|
+
if (matchIdx !== null) {
|
|
49
|
+
result += `</${matchIdx}>`;
|
|
82
50
|
}
|
|
51
|
+
// Stray close — drop.
|
|
83
52
|
}
|
|
84
|
-
else
|
|
85
|
-
|
|
53
|
+
else {
|
|
54
|
+
const tagName = tag.tag.toLowerCase();
|
|
55
|
+
const isVoid = VOID_TAGS.has(tagName);
|
|
56
|
+
const isSelfClosing = tag.isSelfClosing || isVoid;
|
|
86
57
|
tagIndex++;
|
|
87
|
-
|
|
88
|
-
if (
|
|
89
|
-
styles[String(tagIndex)] = styleList;
|
|
58
|
+
styles[String(tagIndex)] = [`raw:${serializeOpeningTag(tagName, tag.attrs)}`];
|
|
59
|
+
if (isSelfClosing) {
|
|
90
60
|
result += `<${tagIndex}/>`;
|
|
91
61
|
}
|
|
92
|
-
// If no styles mapped, skip the tag entirely
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
// Opening tag
|
|
96
|
-
const styleList = this.styleMapper.mapElementToStyles(tagMatch.tag, tagMatch.attrs);
|
|
97
|
-
if (styleList.length > 0) {
|
|
98
|
-
tagIndex++;
|
|
99
|
-
styles[String(tagIndex)] = styleList;
|
|
100
|
-
result += `<${tagIndex}>`;
|
|
101
|
-
tagStack.push({ tag: tagMatch.tag.toLowerCase(), index: tagIndex });
|
|
102
|
-
}
|
|
103
62
|
else {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const closingIndex = this.findClosingTagIndex(input, tagMatch.endIndex, tagMatch.tag);
|
|
107
|
-
if (closingIndex !== -1) {
|
|
108
|
-
// Recursively parse content
|
|
109
|
-
const innerContent = input.slice(tagMatch.endIndex, closingIndex);
|
|
110
|
-
const innerUnit = this.parse(innerContent);
|
|
111
|
-
// Merge inner styles (adjusting indices based on current tagIndex)
|
|
112
|
-
const baseIndex = tagIndex;
|
|
113
|
-
for (const [key, value] of Object.entries(innerUnit.styles)) {
|
|
114
|
-
const adjustedKey = String(baseIndex + parseInt(key, 10));
|
|
115
|
-
styles[adjustedKey] = value;
|
|
116
|
-
}
|
|
117
|
-
// Adjust result and indices
|
|
118
|
-
result += innerUnit.text.replace(/<(\/?)\d+>/g, (match, slash) => {
|
|
119
|
-
const num = parseInt(match.replace(/[</>]/g, ''), 10);
|
|
120
|
-
return `<${slash}${baseIndex + num}>`;
|
|
121
|
-
});
|
|
122
|
-
// Move position past closing tag
|
|
123
|
-
const closingMatch = this.matchTag(input, closingIndex);
|
|
124
|
-
pos = closingMatch ? closingMatch.endIndex : closingIndex;
|
|
125
|
-
// Adjust tagIndex to account for inner tags
|
|
126
|
-
const maxInnerIndex = Object.keys(innerUnit.styles).length > 0
|
|
127
|
-
? Math.max(...Object.keys(innerUnit.styles).map(Number))
|
|
128
|
-
: 0;
|
|
129
|
-
tagIndex = baseIndex + maxInnerIndex;
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
63
|
+
result += `<${tagIndex}>`;
|
|
64
|
+
tagStack.push({ tag: tagName, index: tagIndex });
|
|
132
65
|
}
|
|
133
66
|
}
|
|
134
|
-
pos =
|
|
67
|
+
pos = tag.endIndex;
|
|
135
68
|
}
|
|
136
|
-
// Handle unclosed tags (add closing tags in reverse order)
|
|
137
69
|
while (tagStack.length > 0) {
|
|
138
70
|
const unclosed = tagStack.pop();
|
|
139
71
|
result += `</${unclosed.index}>`;
|
|
140
72
|
}
|
|
141
|
-
return {
|
|
142
|
-
text: result,
|
|
143
|
-
styles,
|
|
144
|
-
};
|
|
73
|
+
return { text: result, styles };
|
|
145
74
|
}
|
|
146
|
-
/**
|
|
147
|
-
* Match an HTML tag at the given position
|
|
148
|
-
*/
|
|
149
75
|
matchTag(input, startPos) {
|
|
150
|
-
// Find next '<' from startPos
|
|
151
76
|
const tagStart = input.indexOf('<', startPos);
|
|
152
77
|
if (tagStart === -1)
|
|
153
78
|
return null;
|
|
154
|
-
// Match tag pattern: <tagname attrs> or </tagname> or <tagname/>
|
|
155
79
|
const tagPattern = /^<(\/?)([a-zA-Z][a-zA-Z0-9]*)((?:\s+[a-zA-Z][a-zA-Z0-9-]*(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*)\s*(\/?)>/;
|
|
156
80
|
const remaining = input.slice(tagStart);
|
|
157
81
|
const match = remaining.match(tagPattern);
|
|
158
82
|
if (!match) {
|
|
159
|
-
// Not a valid tag, skip this '<' and try again
|
|
160
83
|
if (tagStart + 1 < input.length) {
|
|
161
84
|
return this.matchTag(input, tagStart + 1);
|
|
162
85
|
}
|
|
@@ -172,60 +95,17 @@ export class MarkupParser {
|
|
|
172
95
|
endIndex: tagStart + fullMatch.length,
|
|
173
96
|
};
|
|
174
97
|
}
|
|
175
|
-
/**
|
|
176
|
-
* Parse HTML attributes string into key-value pairs
|
|
177
|
-
*/
|
|
178
98
|
parseAttributes(attrsString) {
|
|
179
99
|
const attrs = {};
|
|
180
100
|
if (!attrsString.trim())
|
|
181
101
|
return attrs;
|
|
182
|
-
// Match attribute patterns: name="value" or name='value' or name=value or name
|
|
183
102
|
const attrPattern = /([a-zA-Z][a-zA-Z0-9-]*)(?:=(?:"([^"]*)"|'([^']*)'|([^\s>]*)))?/g;
|
|
184
103
|
let match;
|
|
185
104
|
while ((match = attrPattern.exec(attrsString)) !== null) {
|
|
186
105
|
const [, name, doubleQuoted, singleQuoted, unquoted] = match;
|
|
187
|
-
|
|
188
|
-
attrs[name.toLowerCase()] = value;
|
|
106
|
+
attrs[name.toLowerCase()] = doubleQuoted ?? singleQuoted ?? unquoted ?? '';
|
|
189
107
|
}
|
|
190
108
|
return attrs;
|
|
191
109
|
}
|
|
192
|
-
/**
|
|
193
|
-
* Find matching opening tag in the stack
|
|
194
|
-
*/
|
|
195
|
-
findMatchingOpenTag(stack, tagName) {
|
|
196
|
-
// Search from end of stack (most recent)
|
|
197
|
-
for (let i = stack.length - 1; i >= 0; i--) {
|
|
198
|
-
if (stack[i].tag === tagName) {
|
|
199
|
-
return stack[i].index;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
return null;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Find the closing tag index for a given opening tag
|
|
206
|
-
*/
|
|
207
|
-
findClosingTagIndex(input, startPos, tagName) {
|
|
208
|
-
const lowerTag = tagName.toLowerCase();
|
|
209
|
-
let depth = 1;
|
|
210
|
-
let pos = startPos;
|
|
211
|
-
while (pos < input.length && depth > 0) {
|
|
212
|
-
const tagMatch = this.matchTag(input, pos);
|
|
213
|
-
if (!tagMatch)
|
|
214
|
-
break;
|
|
215
|
-
if (tagMatch.tag.toLowerCase() === lowerTag) {
|
|
216
|
-
if (tagMatch.isClosing) {
|
|
217
|
-
depth--;
|
|
218
|
-
if (depth === 0) {
|
|
219
|
-
return tagMatch.startIndex;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
else if (!tagMatch.isSelfClosing) {
|
|
223
|
-
depth++;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
pos = tagMatch.endIndex;
|
|
227
|
-
}
|
|
228
|
-
return -1;
|
|
229
|
-
}
|
|
230
110
|
}
|
|
231
111
|
//# sourceMappingURL=MarkupParser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkupParser.js","sourceRoot":"","sources":["../../../src/content/parser/MarkupParser.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"MarkupParser.js","sourceRoot":"","sources":["../../../src/content/parser/MarkupParser.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAWrE;;;;;;;;;GASG;AACH,MAAM,OAAO,YAAY;IACvB,KAAK,CAAC,KAAa;QACjB,2DAA2D;QAC3D,IAAI,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9B,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;QACrC,CAAC;QAED,MAAM,MAAM,GAA6B,EAAE,CAAC;QAC5C,IAAI,QAAQ,GAAG,CAAC,CAAC;QACjB,MAAM,QAAQ,GAA0C,EAAE,CAAC;QAC3D,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,IAAI,GAAG,GAAG,CAAC,CAAC;QAEZ,OAAO,GAAG,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;YAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YACtC,IAAI,CAAC,GAAG,EAAE,CAAC;gBACT,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gB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