@u1f992/vivliostyle-index 0.2.5 → 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/README.md +230 -24
- package/dist/document-renderer.d.ts +7 -0
- package/dist/document-renderer.d.ts.map +1 -0
- package/dist/document-renderer.js +86 -0
- package/dist/document-renderer.js.map +1 -0
- package/dist/file-system.d.ts +11 -0
- package/dist/file-system.d.ts.map +1 -0
- package/dist/file-system.js +93 -0
- package/dist/file-system.js.map +1 -0
- package/dist/html.d.ts +4 -0
- package/dist/html.d.ts.map +1 -0
- package/dist/html.js +9 -0
- package/dist/html.js.map +1 -0
- package/dist/id.d.ts +5 -0
- package/dist/id.d.ts.map +1 -0
- package/dist/id.js +30 -0
- package/dist/id.js.map +1 -0
- package/dist/index-builder.d.ts +15 -0
- package/dist/index-builder.d.ts.map +1 -0
- package/dist/index-builder.js +138 -0
- package/dist/index-builder.js.map +1 -0
- package/dist/index-state.d.ts +29 -0
- package/dist/index-state.d.ts.map +1 -0
- package/dist/index-state.js +95 -0
- package/dist/index-state.js.map +1 -0
- package/dist/index.d.ts +45 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +53 -117
- package/dist/index.js.map +1 -1
- package/dist/instruction.d.ts +37 -0
- package/dist/instruction.d.ts.map +1 -0
- package/dist/instruction.js +267 -0
- package/dist/instruction.js.map +1 -0
- package/dist/location.d.ts +2 -0
- package/dist/location.d.ts.map +1 -0
- package/dist/location.js +17 -0
- package/dist/location.js.map +1 -0
- package/dist/messages.d.ts +24 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +114 -0
- package/dist/messages.js.map +1 -0
- package/dist/model.d.ts +77 -36
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +112 -29
- package/dist/model.js.map +1 -1
- package/dist/platform.d.ts +4 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/platform.js +13 -0
- package/dist/platform.js.map +1 -0
- package/dist/profile.d.ts +11 -0
- package/dist/profile.d.ts.map +1 -0
- package/dist/profile.js +17 -0
- package/dist/profile.js.map +1 -0
- package/dist/render.d.ts +175 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +285 -0
- package/dist/render.js.map +1 -0
- package/dist/sort.d.ts +22 -16
- package/dist/sort.d.ts.map +1 -1
- package/dist/sort.js +91 -53
- package/dist/sort.js.map +1 -1
- package/dist/source-snapshot.d.ts +21 -0
- package/dist/source-snapshot.d.ts.map +1 -0
- package/dist/source-snapshot.js +76 -0
- package/dist/source-snapshot.js.map +1 -0
- package/dist/target.d.ts +9 -0
- package/dist/target.d.ts.map +1 -0
- package/dist/target.js +17 -0
- package/dist/target.js.map +1 -0
- package/dist/template.d.ts +4 -0
- package/dist/template.d.ts.map +1 -0
- package/dist/template.js +15 -0
- package/dist/template.js.map +1 -0
- package/package.json +21 -12
- package/dist/command/expand.d.ts +0 -5
- package/dist/command/expand.d.ts.map +0 -1
- package/dist/command/expand.js +0 -189
- package/dist/command/expand.js.map +0 -1
- package/dist/command/insert-page.d.ts +0 -5
- package/dist/command/insert-page.d.ts.map +0 -1
- package/dist/command/insert-page.js +0 -29
- package/dist/command/insert-page.js.map +0 -1
- package/dist/command/insert-range.d.ts +0 -21
- package/dist/command/insert-range.d.ts.map +0 -1
- package/dist/command/insert-range.js +0 -64
- package/dist/command/insert-range.js.map +0 -1
- package/dist/command/insert-reference.d.ts +0 -4
- package/dist/command/insert-reference.d.ts.map +0 -1
- package/dist/command/insert-reference.js +0 -48
- package/dist/command/insert-reference.js.map +0 -1
- package/dist/command.d.ts +0 -25
- package/dist/command.d.ts.map +0 -1
- package/dist/command.js +0 -151
- package/dist/command.js.map +0 -1
- package/dist/resolve.d.ts +0 -3
- package/dist/resolve.d.ts.map +0 -1
- package/dist/resolve.js +0 -95
- package/dist/resolve.js.map +0 -1
- package/dist/util.d.ts +0 -10
- package/dist/util.d.ts.map +0 -1
- package/dist/util.js +0 -27
- package/dist/util.js.map +0 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { applyPageInstruction, applyRangeInstruction, applyXrefInstruction, } from "./instruction.js";
|
|
2
|
+
import { addMessage, messages } from "./messages.js";
|
|
3
|
+
import { addressKey, createIndexBuilder, finalizeIndex, labelInvalidXrefs, } from "./model.js";
|
|
4
|
+
import { identityTemplate } from "./template.js";
|
|
5
|
+
const attachmentAddressKey = (attachment) => addressKey(attachment.instruction.address);
|
|
6
|
+
function ensurePendingIndex(pendingIndexes, attachment) {
|
|
7
|
+
const pendingIndex = pendingIndexes.get(attachment.targetKey);
|
|
8
|
+
if (pendingIndex) {
|
|
9
|
+
pendingIndex.sourcePaths.add(attachment.sourcePath);
|
|
10
|
+
pendingIndex.attachments.push(attachment);
|
|
11
|
+
return pendingIndex;
|
|
12
|
+
}
|
|
13
|
+
const created = {
|
|
14
|
+
target: attachment.target,
|
|
15
|
+
builder: createIndexBuilder(),
|
|
16
|
+
sourcePaths: new Set([attachment.sourcePath]),
|
|
17
|
+
attachments: [attachment],
|
|
18
|
+
xrefValidations: [],
|
|
19
|
+
};
|
|
20
|
+
pendingIndexes.set(attachment.targetKey, created);
|
|
21
|
+
return created;
|
|
22
|
+
}
|
|
23
|
+
function applyAttachment(builder, attachment, rangePairings) {
|
|
24
|
+
const { instruction } = attachment;
|
|
25
|
+
if (instruction.type === "page") {
|
|
26
|
+
applyPageInstruction(builder, instruction, attachment.locationHref);
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
if (instruction.type === "range-start") {
|
|
30
|
+
const rangeEnd = rangePairings.endsByStart.get(attachment);
|
|
31
|
+
if (rangeEnd !== undefined) {
|
|
32
|
+
applyRangeInstruction(builder, instruction, attachment.locationHref, rangeEnd.locationHref);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
applyPageInstruction(builder, { type: "page", address: instruction.address, template: instruction.template }, attachment.locationHref, "unmatched-range-start");
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
if (instruction.type === "range-end") {
|
|
40
|
+
if (!rangePairings.pairedEnds.has(attachment)) {
|
|
41
|
+
applyPageInstruction(builder, { type: "page", address: instruction.address, template: identityTemplate }, attachment.locationHref, "unmatched-range-end");
|
|
42
|
+
}
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
applyXrefInstruction(builder, instruction);
|
|
46
|
+
return {
|
|
47
|
+
reportingPath: attachment.sourcePath,
|
|
48
|
+
target: instruction.target,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function validateXrefs(builder, validations, messagesByDocument) {
|
|
52
|
+
const unresolvedXrefs = labelInvalidXrefs(builder);
|
|
53
|
+
for (const { reportingPath, target } of validations) {
|
|
54
|
+
const unresolvedXref = unresolvedXrefs.get(addressKey(target));
|
|
55
|
+
if (unresolvedXref !== undefined) {
|
|
56
|
+
addMessage(messagesByDocument, reportingPath, messages.invalidXref(unresolvedXref));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function pairRanges(pendingIndex, messagesByDocument) {
|
|
61
|
+
const startsByAddress = new Map();
|
|
62
|
+
const endsByStart = new Map();
|
|
63
|
+
const pairedEnds = new Set();
|
|
64
|
+
for (const attachment of pendingIndex.attachments) {
|
|
65
|
+
if (attachment.instruction.type === "range-start") {
|
|
66
|
+
const starts = startsByAddress.get(attachmentAddressKey(attachment)) ?? [];
|
|
67
|
+
starts.push(attachment);
|
|
68
|
+
startsByAddress.set(attachmentAddressKey(attachment), starts);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (attachment.instruction.type !== "range-end") {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const starts = startsByAddress.get(attachmentAddressKey(attachment));
|
|
75
|
+
const start = starts?.pop();
|
|
76
|
+
if (start === undefined) {
|
|
77
|
+
addMessage(messagesByDocument, attachment.sourcePath, messages.unmatchedRangeEnd(pendingIndex.target, attachment.instruction.address));
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const rangeEnd = attachment;
|
|
81
|
+
endsByStart.set(start, rangeEnd);
|
|
82
|
+
pairedEnds.add(rangeEnd);
|
|
83
|
+
}
|
|
84
|
+
for (const starts of startsByAddress.values()) {
|
|
85
|
+
for (const start of starts) {
|
|
86
|
+
addMessage(messagesByDocument, start.sourcePath, messages.unmatchedRangeStart(pendingIndex.target, start.instruction.address));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return { endsByStart, pairedEnds };
|
|
90
|
+
}
|
|
91
|
+
export function buildIndexes(entryPaths, sources) {
|
|
92
|
+
const entryPathSet = new Set(entryPaths);
|
|
93
|
+
const pendingIndexes = new Map();
|
|
94
|
+
const messagesByDocument = new Map();
|
|
95
|
+
for (const [sourcePath, snapshot] of sources) {
|
|
96
|
+
messagesByDocument.set(sourcePath, [...snapshot.messages]);
|
|
97
|
+
if (!entryPathSet.has(sourcePath) && snapshot.attachments.length !== 0) {
|
|
98
|
+
addMessage(messagesByDocument, sourcePath, messages.documentNotInEntries(sourcePath));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
for (const entryPath of entryPaths) {
|
|
102
|
+
const snapshot = sources.get(entryPath);
|
|
103
|
+
if (!snapshot) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
for (const attachment of snapshot.attachments) {
|
|
107
|
+
ensurePendingIndex(pendingIndexes, attachment);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const indexes = new Map();
|
|
111
|
+
for (const [targetKey, pendingIndex] of pendingIndexes) {
|
|
112
|
+
const { target, builder, sourcePaths, attachments, xrefValidations } = pendingIndex;
|
|
113
|
+
const rangePairings = pairRanges(pendingIndex, messagesByDocument);
|
|
114
|
+
for (const attachment of attachments) {
|
|
115
|
+
const validation = applyAttachment(builder, attachment, rangePairings);
|
|
116
|
+
if (validation) {
|
|
117
|
+
xrefValidations.push(validation);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
validateXrefs(builder, xrefValidations, messagesByDocument);
|
|
121
|
+
const builtIndex = {
|
|
122
|
+
target,
|
|
123
|
+
index: finalizeIndex(builder),
|
|
124
|
+
sourcePaths: [...sourcePaths],
|
|
125
|
+
};
|
|
126
|
+
indexes.set(targetKey, builtIndex);
|
|
127
|
+
}
|
|
128
|
+
for (const { target, sourcePaths } of indexes.values()) {
|
|
129
|
+
if (entryPathSet.has(target.path)) {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
for (const sourcePath of sourcePaths) {
|
|
133
|
+
addMessage(messagesByDocument, sourcePath, messages.targetNotInEntries(target));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return { indexes, messages: messagesByDocument };
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=index-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-builder.js","sourceRoot":"","sources":["../src/index-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAyB,MAAM,eAAe,CAAC;AAC5E,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,aAAa,EACb,iBAAiB,GAIlB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAmCjD,MAAM,oBAAoB,GAAG,CAAC,UAAsB,EAAU,EAAE,CAC9D,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AAE7C,SAAS,kBAAkB,CACzB,cAA4C,EAC5C,UAAsB;IAEtB,MAAM,YAAY,GAAG,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IAC9D,IAAI,YAAY,EAAE,CAAC;QACjB,YAAY,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC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AAC,YAAY,EAAE,kBAAkB,CAAC,CAAC;QACnE,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;YACrC,MAAM,UAAU,GAAG,eAAe,CAAC,OAAO,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;YACvE,IAAI,UAAU,EAAE,CAAC;gBACf,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;QACD,aAAa,CAAC,OAAO,EAAE,eAAe,EAAE,kBAAkB,CAAC,CAAC;QAC5D,MAAM,UAAU,GAAe;YAC7B,MAAM;YACN,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC;YAC7B,WAAW,EAAE,CAAC,GAAG,WAAW,CAAC;SAC9B,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;QACvD,IAAI,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YAClC,SAAS;QACX,CAAC;QACD,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;YACrC,UAAU,CAAC,kBAAkB,EAAE,UAAU,EAAE,QAAQ,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC;QAClF,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type * as hast from "hast";
|
|
2
|
+
import type * as unified from "unified";
|
|
3
|
+
import type { FileSystem } from "./file-system.ts";
|
|
4
|
+
import { type BuiltIndex } from "./index-builder.ts";
|
|
5
|
+
import type { MessageArguments } from "./messages.ts";
|
|
6
|
+
import { type SourceSnapshot } from "./source-snapshot.ts";
|
|
7
|
+
import type { TargetKey } from "./target.ts";
|
|
8
|
+
export type EntryProcessorInput = {
|
|
9
|
+
path: string;
|
|
10
|
+
contents: string;
|
|
11
|
+
};
|
|
12
|
+
export type CreateEntryProcessor = (input: Readonly<EntryProcessorInput>) => unified.Processor;
|
|
13
|
+
export type IndexState = Readonly<{
|
|
14
|
+
entryPaths: readonly string[];
|
|
15
|
+
entryPathSet: ReadonlySet<string>;
|
|
16
|
+
updatedPaths: ReadonlySet<string>;
|
|
17
|
+
sources: ReadonlyMap<string, SourceSnapshot>;
|
|
18
|
+
indexes: ReadonlyMap<TargetKey, BuiltIndex>;
|
|
19
|
+
messages: ReadonlyMap<string, readonly MessageArguments[]>;
|
|
20
|
+
}>;
|
|
21
|
+
export type UpdateResult = Readonly<{
|
|
22
|
+
state: IndexState;
|
|
23
|
+
affectedPaths: ReadonlySet<string>;
|
|
24
|
+
entryProcessorMismatch: boolean;
|
|
25
|
+
}>;
|
|
26
|
+
export declare function createIndexState(entryPaths: readonly string[], fileSystem: Readonly<FileSystem>, createEntryProcessor: CreateEntryProcessor): IndexState;
|
|
27
|
+
export declare function updateIndexState(state: IndexState, documentPath: string, root: hast.Root): UpdateResult;
|
|
28
|
+
export declare function messagesFor(state: IndexState, documentPath: string): readonly MessageArguments[];
|
|
29
|
+
//# sourceMappingURL=index-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-state.d.ts","sourceRoot":"","sources":["../src/index-state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,IAAI,MAAM,MAAM,CAAC;AAElC,OAAO,KAAK,KAAK,OAAO,MAAM,SAAS,CAAC;AAGxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAClF,O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0 +1,95 @@
|
|
|
1
|
+
import deepEqual from "deep-equal";
|
|
2
|
+
import { fromHtml } from "hast-util-from-html";
|
|
3
|
+
import { buildIndexes } from "./index-builder.js";
|
|
4
|
+
import { collectSourceSnapshot } from "./source-snapshot.js";
|
|
5
|
+
function readEntry(fileSystem, entryPath) {
|
|
6
|
+
try {
|
|
7
|
+
return fileSystem.readFileSync(entryPath);
|
|
8
|
+
}
|
|
9
|
+
catch (cause) {
|
|
10
|
+
throw new Error(`cannot read entry ${entryPath}. entry paths resolve against entryContext, which defaults to the current working directory.`, { cause });
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function sourceSnapshotsEqual(previous, current) {
|
|
14
|
+
return previous !== undefined && deepEqual(previous, current, { strict: true });
|
|
15
|
+
}
|
|
16
|
+
function affectedDocumentPaths(previous, current) {
|
|
17
|
+
const targetPaths = new Set([...(previous?.attachments ?? []), ...current.attachments].map((attachment) => attachment.target.path));
|
|
18
|
+
return targetPaths;
|
|
19
|
+
}
|
|
20
|
+
function documentsWithChangedMessages(previous, current) {
|
|
21
|
+
const changed = new Set();
|
|
22
|
+
for (const documentPath of new Set([...previous.keys(), ...current.keys()])) {
|
|
23
|
+
if (!deepEqual(previous.get(documentPath) ?? [], current.get(documentPath) ?? [], {
|
|
24
|
+
strict: true,
|
|
25
|
+
})) {
|
|
26
|
+
changed.add(documentPath);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return changed;
|
|
30
|
+
}
|
|
31
|
+
function rebuild(state) {
|
|
32
|
+
const { indexes, messages } = buildIndexes(state.entryPaths, state.sources);
|
|
33
|
+
return { ...state, indexes, messages };
|
|
34
|
+
}
|
|
35
|
+
const creatingProcessors = new WeakSet();
|
|
36
|
+
export function createIndexState(entryPaths, fileSystem, createEntryProcessor) {
|
|
37
|
+
if (creatingProcessors.has(createEntryProcessor)) {
|
|
38
|
+
throw new Error("the entry processor reached the index plugin that invoked it. createEntryProcessor must return a processor without the index plugin.");
|
|
39
|
+
}
|
|
40
|
+
const entryPathSet = new Set(entryPaths);
|
|
41
|
+
const uniqueEntryPaths = [...entryPathSet];
|
|
42
|
+
creatingProcessors.add(createEntryProcessor);
|
|
43
|
+
const sources = new Map();
|
|
44
|
+
try {
|
|
45
|
+
for (const entryPath of uniqueEntryPaths) {
|
|
46
|
+
const contents = readEntry(fileSystem, entryPath);
|
|
47
|
+
const input = { path: entryPath, contents };
|
|
48
|
+
const processor = createEntryProcessor(input);
|
|
49
|
+
const html = processor.processSync(input).toString();
|
|
50
|
+
sources.set(entryPath, collectSourceSnapshot(fromHtml(html), entryPath));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
creatingProcessors.delete(createEntryProcessor);
|
|
55
|
+
}
|
|
56
|
+
return rebuild({
|
|
57
|
+
entryPaths: uniqueEntryPaths,
|
|
58
|
+
entryPathSet,
|
|
59
|
+
updatedPaths: new Set(),
|
|
60
|
+
sources,
|
|
61
|
+
indexes: new Map(),
|
|
62
|
+
messages: new Map(),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
export function updateIndexState(state, documentPath, root) {
|
|
66
|
+
const previous = state.sources.get(documentPath);
|
|
67
|
+
const current = collectSourceSnapshot(root, documentPath);
|
|
68
|
+
const firstUpdate = !state.updatedPaths.has(documentPath);
|
|
69
|
+
const visited = firstUpdate
|
|
70
|
+
? { ...state, updatedPaths: new Set(state.updatedPaths).add(documentPath) }
|
|
71
|
+
: state;
|
|
72
|
+
if (sourceSnapshotsEqual(previous, current)) {
|
|
73
|
+
return { state: visited, affectedPaths: new Set(), entryProcessorMismatch: false };
|
|
74
|
+
}
|
|
75
|
+
const sources = new Map(state.sources).set(documentPath, current);
|
|
76
|
+
const rebuilt = rebuild({ ...visited, sources });
|
|
77
|
+
// The host runs the plugin identically with and without a file watcher.
|
|
78
|
+
// A first update is indistinguishable from the only pass of a one-shot
|
|
79
|
+
// build, where touching an affected document has no consumer.
|
|
80
|
+
const affectedPaths = firstUpdate
|
|
81
|
+
? new Set()
|
|
82
|
+
: new Set([
|
|
83
|
+
...affectedDocumentPaths(previous, current),
|
|
84
|
+
...documentsWithChangedMessages(state.messages, rebuilt.messages),
|
|
85
|
+
]);
|
|
86
|
+
return {
|
|
87
|
+
state: rebuilt,
|
|
88
|
+
affectedPaths,
|
|
89
|
+
entryProcessorMismatch: firstUpdate && previous !== undefined,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
export function messagesFor(state, documentPath) {
|
|
93
|
+
return state.messages.get(documentPath) ?? [];
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=index-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-state.js","sourceRoot":"","sources":["../src/index-state.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAK/C,OAAO,EAAE,YAAY,EAAmB,MAAM,oBAAoB,CAAC;AAEnE,OAAO,EAAE,qBAAqB,EAAuB,MAAM,sBAAsB,CAAC;AAyBlF,SAAS,SAAS,CAAC,UAAgC,EAAE,SAAiB;IACpE,IAAI,CAAC;QACH,OAAO,UAAU,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,qBAAqB,SAAS,8FAA8F,EAC5H,EAAE,KAAK,EAAE,CACV,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,oBAAoB,CAC3B,QAAoC,EACpC,OAAuB;IAEvB,OAAO,QAAQ,KAAK,SAAS,IAAI,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;AAClF,CAAC;AAED,SAAS,qBAAqB,CAC5B,QAAoC,EACpC,OAAuB;IAEvB,MAAM,WAAW,GAAG,IAAI,GAAG,CACzB,CAAC,GAAG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@@
|
|
|
1
1
|
import type * as unified from "unified";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
export type
|
|
10
|
-
|
|
2
|
+
import { type FileSystem } from "./file-system.ts";
|
|
3
|
+
import { type CreateEntryProcessor } from "./index-state.ts";
|
|
4
|
+
import { type Profiles } from "./profile.ts";
|
|
5
|
+
export { nodeFileSystem } from "./file-system.ts";
|
|
6
|
+
export type { FileSystem } from "./file-system.ts";
|
|
7
|
+
export { InstructionSyntaxError, parseInstruction } from "./instruction.ts";
|
|
8
|
+
export type { ParsedInstruction } from "./instruction.ts";
|
|
9
|
+
export type { EntryProcessorInput } from "./index-state.ts";
|
|
10
|
+
export type { Entry, EntryAddress, Group, Index, IndexError, Key, Locator, LocatorError, Subentry, Xref, XrefError, XrefType, } from "./model.ts";
|
|
11
|
+
export type { CreateRenderer, EntryListRenderer, EntryRenderer, GroupListRenderer, GroupRenderer, HeadingRenderer, IndexRenderer, LocationRenderer, LocatorListRenderer, LocatorRenderer, SubentryListRenderer, SubentryRenderer, XrefPreferredListRenderer, XrefPreferredRenderer, XrefPreferredTargetRenderer, XrefRelatedListRenderer, XrefRelatedRenderer, XrefRelatedTargetRenderer, XrefRenderer, XrefTargetRenderer, } from "./render.ts";
|
|
12
|
+
export { defaultRenderer } from "./render.ts";
|
|
13
|
+
export { defaultProfile } from "./profile.ts";
|
|
14
|
+
export type { IndexProfile, Profiles, ResolvedIndexProfile } from "./profile.ts";
|
|
15
|
+
export { byKeys, byListedOrder, byLocales, defaultComparator } from "./sort.ts";
|
|
16
|
+
export type { CreateIndexComparator, CreateKeyComparator, EntryComparator, IndexComparator, KeyComparator, ListedKey, } from "./sort.ts";
|
|
17
|
+
export type { Target } from "./target.ts";
|
|
18
|
+
export type CreateIndexPluginOptions = {
|
|
19
|
+
entry: readonly string[];
|
|
11
20
|
entryContext?: string;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
21
|
+
profiles?: Profiles;
|
|
22
|
+
fileSystem?: Readonly<FileSystem>;
|
|
23
|
+
};
|
|
24
|
+
export type IndexPluginOptions = {
|
|
25
|
+
/**
|
|
26
|
+
* Creates the processor used to read every configured entry before the host processes it.
|
|
27
|
+
*
|
|
28
|
+
* This option exists because of a design limitation: when the host processes an index target,
|
|
29
|
+
* documents that the host will process after that target have not yet produced their transformed
|
|
30
|
+
* trees. The plugin needs their index data to render the target, so it processes every configured
|
|
31
|
+
* entry in advance.
|
|
32
|
+
*
|
|
33
|
+
* The returned processor must reproduce the transformation that the host will later apply, but
|
|
34
|
+
* without this plugin, and must read document metadata in the same way. Including this plugin
|
|
35
|
+
* would invoke it recursively.
|
|
36
|
+
*
|
|
37
|
+
* The plugin obtains this factory while the host is processing one document, then uses it for
|
|
38
|
+
* every entry. A host may supply different processor options for each entry. The factory must
|
|
39
|
+
* account for those options or rely only on differences that do not change the collected index
|
|
40
|
+
* data. For example, Vivliostyle CLI supplies each manuscript with `style`, `title`, and
|
|
41
|
+
* `language` options.
|
|
42
|
+
*
|
|
43
|
+
* @see https://github.com/vivliostyle/vivliostyle-cli/blob/v11.1.0/src/processor/compile.ts#L195-L212
|
|
44
|
+
*/
|
|
45
|
+
createEntryProcessor: CreateEntryProcessor;
|
|
17
46
|
};
|
|
18
|
-
export declare
|
|
47
|
+
export declare function createIndexPlugin({ entry: entries, entryContext, profiles, fileSystem, }: Readonly<CreateIndexPluginOptions>): unified.Plugin<[Readonly<IndexPluginOptions>]>;
|
|
48
|
+
export declare const logMessages: unified.Plugin;
|
|
19
49
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],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AAW,CAAC;AAChF,YAAY,EACV,qBAAqB,EACrB,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,aAAa,EACb,SAAS,GACV,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;;;;;;;;;;;;;;;;;OAmBG;IACH,oBAAoB,EAAE,oBAAoB,CAAC;CAC5C,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EAAE,OAAO,EACd,YAAY,EACZ,QAAa,EACb,UAA2B,GAC5B,EAAE,QAAQ,CAAC,wBAAwB,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAmCrF;AAED,eAAO,MAAM,WAAW,EAAE,OAAO,CAAC,MAgBjC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,127 +1,63 @@
|
|
|
1
|
-
import { fromHtml } from "hast-util-from-html";
|
|
2
|
-
import { getAttribute } from "hast-util-get-attribute";
|
|
3
|
-
import { selectAll } from "hast-util-select";
|
|
4
|
-
import fs from "node:fs";
|
|
5
1
|
import upath from "upath";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export {
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
function processEntry(root, indexes, relPath) {
|
|
29
|
-
selectAll("[data-index]", root)
|
|
30
|
-
.map((elem) => ({
|
|
31
|
-
elem,
|
|
32
|
-
data: getAttribute(elem, "data-index") ??
|
|
33
|
-
throwError([
|
|
34
|
-
"data === null: won't happen. it's likely a bug in selectAll() or getAttribute()",
|
|
35
|
-
]),
|
|
36
|
-
}))
|
|
37
|
-
.map(({ elem, data }) => ({
|
|
38
|
-
elem,
|
|
39
|
-
data,
|
|
40
|
-
cmd: [insertPage, insertRangeStart, insertRangeEnd, insertReference].find((cmd) => test(cmd, data)),
|
|
41
|
-
}))
|
|
42
|
-
.filter((obj) => !!obj.cmd)
|
|
43
|
-
.forEach(({ elem, data, cmd }) => run(cmd,
|
|
44
|
-
// @ts-expect-error branded
|
|
45
|
-
data, indexes, root, elem, relPath));
|
|
46
|
-
}
|
|
47
|
-
export const index = ({ entryProcessor, entryContext, indexEntryMap, comparators, log, }) => {
|
|
48
|
-
log ??= () => { };
|
|
49
|
-
const ctx = upath.resolve(process.cwd(), entryContext ?? ".");
|
|
50
|
-
const normalizedIndexEntryMap = new Map(Object.entries(indexEntryMap).map(([index, entries]) => [
|
|
51
|
-
upath.resolve(ctx, index),
|
|
52
|
-
entries.map((ent) => typeof ent === "string"
|
|
53
|
-
? { entryPath: upath.resolve(ctx, ent), ignoreUpdate: false }
|
|
54
|
-
: {
|
|
55
|
-
entryPath: upath.resolve(ctx, ent.path),
|
|
56
|
-
ignoreUpdate: ent.ignoreUpdate,
|
|
57
|
-
}),
|
|
58
|
-
]));
|
|
59
|
-
const entryIndexMap = normalizedIndexEntryMap.entries().reduce((map, [indexPath, entries]) => {
|
|
60
|
-
entries.forEach(({ entryPath, ignoreUpdate }) => {
|
|
61
|
-
if (!map.has(entryPath)) {
|
|
62
|
-
map.set(entryPath, []);
|
|
63
|
-
}
|
|
64
|
-
map.get(entryPath).push({ indexPath, ignoreUpdate });
|
|
65
|
-
});
|
|
66
|
-
return map;
|
|
67
|
-
}, new Map());
|
|
68
|
-
return (tree, file) => {
|
|
69
|
-
const root = tree;
|
|
2
|
+
import { renderDocumentIndexes } from "./document-renderer.js";
|
|
3
|
+
import { nodeFileSystem } from "./file-system.js";
|
|
4
|
+
import { createIndexState, messagesFor, updateIndexState, } from "./index-state.js";
|
|
5
|
+
import { emitMessages, messages } from "./messages.js";
|
|
6
|
+
import { workingDirectory } from "./platform.js";
|
|
7
|
+
import { resolveProfiles } from "./profile.js";
|
|
8
|
+
export { nodeFileSystem } from "./file-system.js";
|
|
9
|
+
export { InstructionSyntaxError, parseInstruction } from "./instruction.js";
|
|
10
|
+
export { defaultRenderer } from "./render.js";
|
|
11
|
+
export { defaultProfile } from "./profile.js";
|
|
12
|
+
export { byKeys, byListedOrder, byLocales, defaultComparator } from "./sort.js";
|
|
13
|
+
export function createIndexPlugin({ entry: entries, entryContext, profiles = {}, fileSystem = nodeFileSystem, }) {
|
|
14
|
+
const cwd = workingDirectory();
|
|
15
|
+
// Vivliostyle CLI also resolves an omitted entryContext against the working directory:
|
|
16
|
+
// https://github.com/vivliostyle/vivliostyle-cli/blob/v11.1.0/src/config/resolve.ts#L627-L632
|
|
17
|
+
const context = upath.resolve(cwd, entryContext ?? ".");
|
|
18
|
+
const entryPaths = entries.map((entry) => upath.resolve(context, entry));
|
|
19
|
+
let state;
|
|
20
|
+
const profilesByName = resolveProfiles(profiles);
|
|
21
|
+
return ({ createEntryProcessor }) => (tree, file) => {
|
|
70
22
|
const rawPath = file.path;
|
|
71
23
|
if (typeof rawPath === "undefined") {
|
|
72
|
-
|
|
24
|
+
file.message(...messages.anonymousFile);
|
|
73
25
|
return;
|
|
74
26
|
}
|
|
75
|
-
const
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
.
|
|
83
|
-
|
|
84
|
-
touchSync(indexPath);
|
|
85
|
-
});
|
|
27
|
+
const documentPath = upath.resolve(cwd, rawPath);
|
|
28
|
+
const root = tree;
|
|
29
|
+
state ??= createIndexState(entryPaths, fileSystem, createEntryProcessor);
|
|
30
|
+
const updated = updateIndexState(state, documentPath, root);
|
|
31
|
+
state = updated.state;
|
|
32
|
+
for (const targetPath of updated.affectedPaths) {
|
|
33
|
+
if (targetPath !== documentPath && state.entryPathSet.has(targetPath)) {
|
|
34
|
+
fileSystem.touchSync(targetPath);
|
|
35
|
+
}
|
|
86
36
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const indexes = [];
|
|
90
|
-
const baseDir = upath.dirname(filePath);
|
|
91
|
-
dependsOn
|
|
92
|
-
.map(({ entryPath }) => ({
|
|
93
|
-
entryPath,
|
|
94
|
-
contents: fs.readFileSync(entryPath, {
|
|
95
|
-
encoding: "utf-8",
|
|
96
|
-
}),
|
|
97
|
-
}))
|
|
98
|
-
.map(({ entryPath, contents }) => ({
|
|
99
|
-
entryPath,
|
|
100
|
-
root: fromHtml(entryProcessor
|
|
101
|
-
.processSync({
|
|
102
|
-
contents,
|
|
103
|
-
path: entryPath,
|
|
104
|
-
})
|
|
105
|
-
.toString()),
|
|
106
|
-
}))
|
|
107
|
-
.forEach(({ entryPath, root }) => processEntry(root, indexes, filePath === entryPath
|
|
108
|
-
? null
|
|
109
|
-
: upath.relative(baseDir, upath.changeExt(entryPath, ".html"))));
|
|
110
|
-
deleteRangeStore(indexes);
|
|
111
|
-
const resolved = sort(resolve(indexes), comparators);
|
|
112
|
-
selectAll("[data-index]", root)
|
|
113
|
-
.map((elem) => ({
|
|
114
|
-
elem,
|
|
115
|
-
data: getAttribute(elem, "data-index") ??
|
|
116
|
-
throwError([
|
|
117
|
-
"data === null: won't happen. it's likely a bug in selectAll() or getAttribute()",
|
|
118
|
-
]),
|
|
119
|
-
}))
|
|
120
|
-
.filter(({ data }) => test(expand, data))
|
|
121
|
-
.forEach(({ elem, data }) => run(expand,
|
|
122
|
-
// @ts-expect-error branded
|
|
123
|
-
data, resolved, root, elem, null));
|
|
37
|
+
if (updated.entryProcessorMismatch) {
|
|
38
|
+
file.message(...messages.entryProcessorMismatch(documentPath));
|
|
124
39
|
}
|
|
40
|
+
emitMessages(file, messagesFor(state, documentPath));
|
|
41
|
+
renderDocumentIndexes(root, documentPath, state.indexes, profilesByName, file);
|
|
125
42
|
};
|
|
43
|
+
}
|
|
44
|
+
export const logMessages = () => (_tree, file) => {
|
|
45
|
+
for (const message of file.messages) {
|
|
46
|
+
const location = [message.file, message.line ?? 1, message.column ?? 1]
|
|
47
|
+
.filter((part) => part !== undefined && part !== "")
|
|
48
|
+
.join(":");
|
|
49
|
+
const origin = [message.source, message.ruleId].filter(Boolean).join(":");
|
|
50
|
+
const report = `${location}: ${message.reason}`;
|
|
51
|
+
const output = origin === "" ? report : `${report} (${origin})`;
|
|
52
|
+
if (message.fatal === true) {
|
|
53
|
+
console.error(output);
|
|
54
|
+
}
|
|
55
|
+
else if (message.fatal === false) {
|
|
56
|
+
console.warn(output);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
console.info(output);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
126
62
|
};
|
|
127
63
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAmB,MAAM,kBAAkB,CAAC;AACnE,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,gBAAgB,GAGjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EA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,CAAC,GAAG,CAAC,CAAC;QACb,MAAM,MAAM,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1E,MAAM,MAAM,GAAG,GAAG,QAAQ,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC;QAChD,MAAM,MAAM,GAAG,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,KAAK,MAAM,GAAG,CAAC;QAChE,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YAC3B,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACxB,CAAC;aAAM,IAAI,OAAO,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC;YACnC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type EntryAddress, type IndexBuilder, type LocatorError, type XrefType } from "./model.ts";
|
|
2
|
+
export type ParsedInstruction = Readonly<{
|
|
3
|
+
type: "page";
|
|
4
|
+
address: EntryAddress;
|
|
5
|
+
template: string;
|
|
6
|
+
}> | Readonly<{
|
|
7
|
+
type: "range-start";
|
|
8
|
+
address: EntryAddress;
|
|
9
|
+
template: string;
|
|
10
|
+
}> | Readonly<{
|
|
11
|
+
type: "range-end";
|
|
12
|
+
address: EntryAddress;
|
|
13
|
+
}> | Readonly<{
|
|
14
|
+
type: XrefType;
|
|
15
|
+
address: EntryAddress;
|
|
16
|
+
target: EntryAddress;
|
|
17
|
+
template: string;
|
|
18
|
+
}>;
|
|
19
|
+
export declare class InstructionSyntaxError extends SyntaxError {
|
|
20
|
+
readonly offset: number;
|
|
21
|
+
constructor(input: string, offset: number, reason: string);
|
|
22
|
+
}
|
|
23
|
+
export declare function parseInstruction(source: string): ParsedInstruction;
|
|
24
|
+
type PageInstruction = Extract<ParsedInstruction, {
|
|
25
|
+
type: "page";
|
|
26
|
+
}>;
|
|
27
|
+
type RangeInstruction = Extract<ParsedInstruction, {
|
|
28
|
+
type: "range-start";
|
|
29
|
+
}>;
|
|
30
|
+
type XrefInstruction = Extract<ParsedInstruction, {
|
|
31
|
+
type: XrefType;
|
|
32
|
+
}>;
|
|
33
|
+
export declare function applyPageInstruction(builder: IndexBuilder, instruction: PageInstruction, locationHref: string, error?: LocatorError): void;
|
|
34
|
+
export declare function applyRangeInstruction(builder: IndexBuilder, instruction: RangeInstruction, startHref: string, endHref: string): void;
|
|
35
|
+
export declare function applyXrefInstruction(builder: IndexBuilder, instruction: XrefInstruction): void;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=instruction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instruction.d.ts","sourceRoot":"","sources":["../src/instruction.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,YAAY,EACjB,KAAK,YAAY,EAEjB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,YAAY,CAAC;AAGpB,MAAM,MAAM,iBAAiB,GACzB,QAAQ,CAAC;IACP,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,YAAY,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC,GACF,QAAQ,CAAC;IACP,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,EAAE,YAAY,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC,GACF,QAAQ,CAAC;IACP,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,YAAY,CAAC;CACvB,CAAC,GACF,QAAQ,CAAC;IACP,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,YAAY,CAAC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