@mui/internal-docs-infra 0.2.0-alpha.1 → 0.2.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/esm/CodeHighlighter/CodeHighlighter.js +54 -39
- package/esm/CodeHighlighter/CodeHighlighterClient.js +77 -33
- package/esm/CodeHighlighter/errors.js +1 -1
- package/esm/CodeHighlighter/loadFallbackCode.js +6 -2
- package/esm/CodeHighlighter/loadVariant.js +64 -22
- package/esm/CodeHighlighter/maybeInitialData.d.ts +2 -2
- package/esm/CodeHighlighter/maybeInitialData.js +2 -2
- package/esm/CodeHighlighter/transformSource.js +57 -17
- package/esm/CodeHighlighter/types.d.ts +20 -3
- package/esm/abstractCreateDemo/abstractCreateDemo.d.ts +4 -2
- package/esm/abstractCreateDemo/abstractCreateDemo.js +2 -1
- package/esm/pipeline/hastUtils/hastUtils.d.ts +6 -0
- package/esm/pipeline/hastUtils/hastUtils.js +20 -0
- package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts +3 -1
- package/esm/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +2 -1
- package/esm/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.d.ts +6 -4
- package/esm/pipeline/loadPrecomputedCodeHighlighter/parseCreateFactoryCall.js +443 -258
- package/esm/pipeline/loadServerSource/loadServerSource.js +59 -19
- package/esm/pipeline/loaderUtils/index.d.ts +1 -1
- package/esm/pipeline/loaderUtils/index.js +1 -1
- package/esm/pipeline/loaderUtils/parseImportsAndComments.d.ts +91 -0
- package/esm/pipeline/loaderUtils/parseImportsAndComments.js +1329 -0
- package/esm/pipeline/loaderUtils/processRelativeImports.d.ts +8 -3
- package/esm/pipeline/loaderUtils/processRelativeImports.js +237 -118
- package/esm/pipeline/loaderUtils/resolveModulePath.d.ts +7 -3
- package/esm/pipeline/loaderUtils/resolveModulePath.js +3 -3
- package/esm/pipeline/loaderUtils/resolveModulePathWithFs.d.ts +4 -0
- package/esm/pipeline/loaderUtils/rewriteImports.d.ts +12 -5
- package/esm/pipeline/loaderUtils/rewriteImports.js +56 -26
- package/esm/pipeline/transformHtmlCodePrecomputed/index.d.ts +2 -0
- package/esm/pipeline/transformHtmlCodePrecomputed/index.js +4 -0
- package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.d.ts +13 -0
- package/esm/pipeline/transformHtmlCodePrecomputed/transformHtmlCodePrecomputed.js +415 -0
- package/esm/pipeline/transformMarkdownCode/transformMarkdownCode.js +304 -47
- package/esm/useCode/Pre.js +5 -0
- package/esm/useCode/useFileNavigation.js +4 -0
- package/esm/withDocsInfra/withDocsInfra.d.ts +12 -1
- package/esm/withDocsInfra/withDocsInfra.js +34 -6
- package/package.json +6 -4
- package/esm/pipeline/loaderUtils/parseImports.d.ts +0 -19
- package/esm/pipeline/loaderUtils/parseImports.js +0 -306
- package/esm/pipeline/transformHtmlCode/index.d.ts +0 -2
- package/esm/pipeline/transformHtmlCode/index.js +0 -4
- package/esm/pipeline/transformHtmlCode/transformHtmlCode.d.ts +0 -13
- package/esm/pipeline/transformHtmlCode/transformHtmlCode.js +0 -300
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
import _regenerator from "@babel/runtime/helpers/esm/regenerator";
|
|
2
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
5
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
6
|
+
import { visit } from 'unist-util-visit';
|
|
7
|
+
import { loadVariant } from "../../CodeHighlighter/loadVariant.js";
|
|
8
|
+
import { createParseSource } from "../parseSource/index.js";
|
|
9
|
+
import { TypescriptToJavascriptTransformer } from "../transformTypescriptToJavascript/index.js";
|
|
10
|
+
/**
|
|
11
|
+
* Maps common language class names to file extensions
|
|
12
|
+
* Only includes languages that have corresponding grammars in parseSource/grammars.ts
|
|
13
|
+
*/
|
|
14
|
+
var LANGUAGE_TO_EXTENSION = {
|
|
15
|
+
// JavaScript
|
|
16
|
+
javascript: 'js',
|
|
17
|
+
js: 'js',
|
|
18
|
+
// TypeScript
|
|
19
|
+
typescript: 'ts',
|
|
20
|
+
ts: 'ts',
|
|
21
|
+
// TSX/JSX
|
|
22
|
+
tsx: 'tsx',
|
|
23
|
+
jsx: 'jsx',
|
|
24
|
+
// Maps to .jsx but uses tsx grammar
|
|
25
|
+
|
|
26
|
+
// JSON
|
|
27
|
+
json: 'json',
|
|
28
|
+
// Markdown
|
|
29
|
+
markdown: 'md',
|
|
30
|
+
md: 'md',
|
|
31
|
+
// MDX
|
|
32
|
+
mdx: 'mdx',
|
|
33
|
+
// HTML
|
|
34
|
+
html: 'html',
|
|
35
|
+
// CSS
|
|
36
|
+
css: 'css',
|
|
37
|
+
// Shell
|
|
38
|
+
shell: 'sh',
|
|
39
|
+
bash: 'sh',
|
|
40
|
+
sh: 'sh',
|
|
41
|
+
// YAML
|
|
42
|
+
yaml: 'yaml',
|
|
43
|
+
yml: 'yaml'
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Extracts the language from className attribute
|
|
48
|
+
*/
|
|
49
|
+
function extractLanguageFromClassName(className) {
|
|
50
|
+
if (!className) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Handle array of class names (HAST format)
|
|
55
|
+
var classString = Array.isArray(className) ? className.join(' ') : className;
|
|
56
|
+
var match = classString.match(/(?:^|\s)language-(\w+)(?:\s|$)/);
|
|
57
|
+
return match ? match[1] : null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Gets the filename from data-filename attribute or derives it from language
|
|
62
|
+
* Returns undefined if no explicit filename and no recognizable language
|
|
63
|
+
*/
|
|
64
|
+
function getFileName(codeElement) {
|
|
65
|
+
var _codeElement$properti, _codeElement$properti2;
|
|
66
|
+
// Check for explicit data-filename attribute
|
|
67
|
+
var dataFilename = (_codeElement$properti = codeElement.properties) == null ? void 0 : _codeElement$properti.dataFilename;
|
|
68
|
+
if (dataFilename && typeof dataFilename === 'string') {
|
|
69
|
+
return dataFilename;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Extract language from className
|
|
73
|
+
var className = (_codeElement$properti2 = codeElement.properties) == null ? void 0 : _codeElement$properti2.className;
|
|
74
|
+
var language = extractLanguageFromClassName(className);
|
|
75
|
+
if (language && LANGUAGE_TO_EXTENSION[language]) {
|
|
76
|
+
return "index.".concat(LANGUAGE_TO_EXTENSION[language]);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Return undefined instead of a fallback - let the system handle gracefully
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Extracts text content from HAST nodes
|
|
85
|
+
*/
|
|
86
|
+
function extractTextContent(node) {
|
|
87
|
+
if (node.type === 'text') {
|
|
88
|
+
return node.value;
|
|
89
|
+
}
|
|
90
|
+
if (node.type === 'element' && node.children) {
|
|
91
|
+
return node.children.map(function (child) {
|
|
92
|
+
return extractTextContent(child);
|
|
93
|
+
}).join('');
|
|
94
|
+
}
|
|
95
|
+
return '';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Extracts code elements and filenames from semantic HTML structure
|
|
100
|
+
* Handles both section/figure/dl and standalone dl structures
|
|
101
|
+
*/
|
|
102
|
+
function extractCodeFromSemanticStructure(element) {
|
|
103
|
+
var results = [];
|
|
104
|
+
if (element.tagName === 'section') {
|
|
105
|
+
// Handle section with multiple figures
|
|
106
|
+
var figures = element.children.filter(function (child) {
|
|
107
|
+
return child.type === 'element' && child.tagName === 'figure';
|
|
108
|
+
});
|
|
109
|
+
var _iterator = _createForOfIteratorHelper(figures),
|
|
110
|
+
_step;
|
|
111
|
+
try {
|
|
112
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
113
|
+
var figure = _step.value;
|
|
114
|
+
// Extract variant name from figcaption
|
|
115
|
+
var variantName = void 0;
|
|
116
|
+
var figcaption = figure.children.find(function (child) {
|
|
117
|
+
return child.type === 'element' && child.tagName === 'figcaption';
|
|
118
|
+
});
|
|
119
|
+
if (figcaption && figcaption.children[0] && figcaption.children[0].type === 'text') {
|
|
120
|
+
variantName = figcaption.children[0].value.replace(' variant', '');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Find dl element in figure
|
|
124
|
+
var dl = figure.children.find(function (child) {
|
|
125
|
+
return child.type === 'element' && child.tagName === 'dl';
|
|
126
|
+
});
|
|
127
|
+
if (dl) {
|
|
128
|
+
var extracted = extractFromDl(dl);
|
|
129
|
+
if (extracted) {
|
|
130
|
+
results.push({
|
|
131
|
+
codeElement: extracted.codeElement,
|
|
132
|
+
filename: extracted.filename,
|
|
133
|
+
variantName: variantName || extracted.variantName
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
} catch (err) {
|
|
139
|
+
_iterator.e(err);
|
|
140
|
+
} finally {
|
|
141
|
+
_iterator.f();
|
|
142
|
+
}
|
|
143
|
+
} else if (element.tagName === 'dl') {
|
|
144
|
+
// Handle standalone dl
|
|
145
|
+
var _extracted = extractFromDl(element);
|
|
146
|
+
if (_extracted) {
|
|
147
|
+
results.push(_extracted);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return results;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Extracts code element and filename from a dl element
|
|
155
|
+
*/
|
|
156
|
+
function extractFromDl(dl) {
|
|
157
|
+
// Find dt for filename and dd for code
|
|
158
|
+
var filename;
|
|
159
|
+
var codeElement;
|
|
160
|
+
var _iterator2 = _createForOfIteratorHelper(dl.children),
|
|
161
|
+
_step2;
|
|
162
|
+
try {
|
|
163
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
164
|
+
var child = _step2.value;
|
|
165
|
+
if (child.type === 'element') {
|
|
166
|
+
if (child.tagName === 'dt') {
|
|
167
|
+
// Extract filename from dt > code
|
|
168
|
+
var codeInDt = child.children.find(function (dtChild) {
|
|
169
|
+
return dtChild.type === 'element' && dtChild.tagName === 'code';
|
|
170
|
+
});
|
|
171
|
+
if (codeInDt && codeInDt.children[0] && codeInDt.children[0].type === 'text') {
|
|
172
|
+
filename = codeInDt.children[0].value;
|
|
173
|
+
}
|
|
174
|
+
} else if (child.tagName === 'dd') {
|
|
175
|
+
// Extract code from dd > pre > code
|
|
176
|
+
var pre = child.children.find(function (ddChild) {
|
|
177
|
+
return ddChild.type === 'element' && ddChild.tagName === 'pre';
|
|
178
|
+
});
|
|
179
|
+
if (pre) {
|
|
180
|
+
var code = pre.children.find(function (preChild) {
|
|
181
|
+
return preChild.type === 'element' && preChild.tagName === 'code';
|
|
182
|
+
});
|
|
183
|
+
if (code) {
|
|
184
|
+
codeElement = code;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
} catch (err) {
|
|
191
|
+
_iterator2.e(err);
|
|
192
|
+
} finally {
|
|
193
|
+
_iterator2.f();
|
|
194
|
+
}
|
|
195
|
+
if (codeElement) {
|
|
196
|
+
var _codeElement$properti3;
|
|
197
|
+
// Extract variant name from data-variant if available
|
|
198
|
+
var variantName = (_codeElement$properti3 = codeElement.properties) == null ? void 0 : _codeElement$properti3.dataVariant;
|
|
199
|
+
return {
|
|
200
|
+
codeElement: codeElement,
|
|
201
|
+
filename: filename,
|
|
202
|
+
variantName: variantName
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Rehype plugin that transforms semantic HTML code structures to use loadVariant
|
|
210
|
+
*
|
|
211
|
+
* This plugin:
|
|
212
|
+
* 1. Finds section and dl elements in the HTML AST
|
|
213
|
+
* 2. Extracts code elements from the semantic structure (figure/dl/dd/pre/code)
|
|
214
|
+
* 3. Creates variants from multiple code elements or single Default variant
|
|
215
|
+
* 4. Uses loadVariant to process each variant
|
|
216
|
+
* 5. Stores the combined precompute data on the root element
|
|
217
|
+
* 6. Clears all code element contents and replaces with error message
|
|
218
|
+
*/
|
|
219
|
+
export var transformHtmlCodePrecomputed = function transformHtmlCodePrecomputed() {
|
|
220
|
+
return /*#__PURE__*/function () {
|
|
221
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(tree) {
|
|
222
|
+
var transformPromises, sourceParser, sourceTransformers;
|
|
223
|
+
return _regenerator().w(function (_context3) {
|
|
224
|
+
while (1) switch (_context3.n) {
|
|
225
|
+
case 0:
|
|
226
|
+
transformPromises = []; // Get the source parser and transformers
|
|
227
|
+
sourceParser = createParseSource();
|
|
228
|
+
sourceTransformers = [TypescriptToJavascriptTransformer];
|
|
229
|
+
visit(tree, 'element', function (node) {
|
|
230
|
+
var _node$properties;
|
|
231
|
+
var extractedElements = [];
|
|
232
|
+
|
|
233
|
+
// Handle basic pre > code structure from standard markdown
|
|
234
|
+
if (node.tagName === 'pre' && node.children && node.children.length > 0 && !((_node$properties = node.properties) != null && _node$properties.dataPrecompute) // Don't process if already processed
|
|
235
|
+
) {
|
|
236
|
+
// Look for direct code element in pre
|
|
237
|
+
var codeElement = node.children.find(function (child) {
|
|
238
|
+
return child.type === 'element' && child.tagName === 'code';
|
|
239
|
+
});
|
|
240
|
+
if (codeElement) {
|
|
241
|
+
// Extract filename from data-filename or derive from language class
|
|
242
|
+
var filename = getFileName(codeElement);
|
|
243
|
+
extractedElements = [{
|
|
244
|
+
codeElement: codeElement,
|
|
245
|
+
filename: filename,
|
|
246
|
+
variantName: undefined // Basic pre > code doesn't have variants
|
|
247
|
+
}];
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
// Look for section elements (multi-variant) or dl elements (single variant)
|
|
251
|
+
else if ((node.tagName === 'section' || node.tagName === 'dl') && node.children && node.children.length > 0) {
|
|
252
|
+
// Extract code elements from semantic structure
|
|
253
|
+
extractedElements = extractCodeFromSemanticStructure(node);
|
|
254
|
+
}
|
|
255
|
+
if (extractedElements.length > 0) {
|
|
256
|
+
var transformPromise = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
257
|
+
var variants, _codeElement$properti4, _extractedElements$, _codeElement, _filename, sourceCode, variant, derivedFilename, processedCode, variantPromises, variantResults, _iterator3, _step3, result, _t;
|
|
258
|
+
return _regenerator().w(function (_context2) {
|
|
259
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
260
|
+
case 0:
|
|
261
|
+
_context2.p = 0;
|
|
262
|
+
// Create variants from extracted elements
|
|
263
|
+
variants = {};
|
|
264
|
+
if (extractedElements.length === 1) {
|
|
265
|
+
// Single element - use "Default" as variant name
|
|
266
|
+
_extractedElements$ = extractedElements[0], _codeElement = _extractedElements$.codeElement, _filename = _extractedElements$.filename;
|
|
267
|
+
sourceCode = extractTextContent(_codeElement);
|
|
268
|
+
variant = {
|
|
269
|
+
source: sourceCode,
|
|
270
|
+
skipTransforms: !((_codeElement$properti4 = _codeElement.properties) != null && _codeElement$properti4.dataTransform)
|
|
271
|
+
}; // Add filename if available (prefer explicit filename over derived)
|
|
272
|
+
if (_filename) {
|
|
273
|
+
variant.fileName = _filename;
|
|
274
|
+
} else {
|
|
275
|
+
derivedFilename = getFileName(_codeElement);
|
|
276
|
+
if (derivedFilename) {
|
|
277
|
+
variant.fileName = derivedFilename;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
variants.Default = variant;
|
|
281
|
+
} else {
|
|
282
|
+
// Multiple elements - use variant names
|
|
283
|
+
extractedElements.forEach(function (_ref3, index) {
|
|
284
|
+
var _codeElement$properti5;
|
|
285
|
+
var codeElement = _ref3.codeElement,
|
|
286
|
+
filename = _ref3.filename,
|
|
287
|
+
variantName = _ref3.variantName;
|
|
288
|
+
var sourceCode = extractTextContent(codeElement);
|
|
289
|
+
|
|
290
|
+
// Determine variant name
|
|
291
|
+
var finalVariantName = variantName || "Variant ".concat(index + 1);
|
|
292
|
+
var variant = {
|
|
293
|
+
source: sourceCode,
|
|
294
|
+
skipTransforms: !((_codeElement$properti5 = codeElement.properties) != null && _codeElement$properti5.dataTransform)
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
// Add filename if available (prefer explicit filename over derived)
|
|
298
|
+
if (filename) {
|
|
299
|
+
variant.fileName = filename;
|
|
300
|
+
} else {
|
|
301
|
+
var _derivedFilename = getFileName(codeElement);
|
|
302
|
+
if (_derivedFilename) {
|
|
303
|
+
variant.fileName = _derivedFilename;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
variants[finalVariantName] = variant;
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// Process each variant with loadVariant
|
|
311
|
+
processedCode = {};
|
|
312
|
+
variantPromises = Object.entries(variants).map(/*#__PURE__*/function () {
|
|
313
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref4) {
|
|
314
|
+
var _ref6, variantName, variantData, result;
|
|
315
|
+
return _regenerator().w(function (_context) {
|
|
316
|
+
while (1) switch (_context.n) {
|
|
317
|
+
case 0:
|
|
318
|
+
_ref6 = _slicedToArray(_ref4, 2), variantName = _ref6[0], variantData = _ref6[1];
|
|
319
|
+
if (!(variantData && _typeof(variantData) === 'object')) {
|
|
320
|
+
_context.n = 2;
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
323
|
+
_context.n = 1;
|
|
324
|
+
return loadVariant(undefined,
|
|
325
|
+
// url - not needed for inline code
|
|
326
|
+
variantName, variantData, {
|
|
327
|
+
sourceParser: sourceParser,
|
|
328
|
+
loadSource: undefined,
|
|
329
|
+
// loadSource - not needed since we have the data
|
|
330
|
+
loadVariantMeta: undefined,
|
|
331
|
+
// loadVariantMeta - not needed since we have the data
|
|
332
|
+
sourceTransformers: sourceTransformers,
|
|
333
|
+
disableTransforms: variantData.skipTransforms || false,
|
|
334
|
+
// TODO: output option
|
|
335
|
+
output: 'hastGzip'
|
|
336
|
+
});
|
|
337
|
+
case 1:
|
|
338
|
+
result = _context.v;
|
|
339
|
+
return _context.a(2, {
|
|
340
|
+
variantName: variantName,
|
|
341
|
+
processedVariant: result.code
|
|
342
|
+
});
|
|
343
|
+
case 2:
|
|
344
|
+
return _context.a(2, null);
|
|
345
|
+
}
|
|
346
|
+
}, _callee);
|
|
347
|
+
}));
|
|
348
|
+
return function (_x2) {
|
|
349
|
+
return _ref5.apply(this, arguments);
|
|
350
|
+
};
|
|
351
|
+
}());
|
|
352
|
+
_context2.n = 1;
|
|
353
|
+
return Promise.all(variantPromises);
|
|
354
|
+
case 1:
|
|
355
|
+
variantResults = _context2.v;
|
|
356
|
+
_iterator3 = _createForOfIteratorHelper(variantResults);
|
|
357
|
+
try {
|
|
358
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
359
|
+
result = _step3.value;
|
|
360
|
+
if (result) {
|
|
361
|
+
processedCode[result.variantName] = result.processedVariant;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// Clear all code element contents
|
|
366
|
+
} catch (err) {
|
|
367
|
+
_iterator3.e(err);
|
|
368
|
+
} finally {
|
|
369
|
+
_iterator3.f();
|
|
370
|
+
}
|
|
371
|
+
extractedElements.forEach(function (_ref7) {
|
|
372
|
+
var codeElement = _ref7.codeElement;
|
|
373
|
+
codeElement.children = [];
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
// Replace the semantic structure with a <pre> element
|
|
377
|
+
node.tagName = 'pre';
|
|
378
|
+
node.children = [{
|
|
379
|
+
type: 'text',
|
|
380
|
+
value: 'Error: expected pre tag with precomputed data to be handled by the CodeHighlighter component'
|
|
381
|
+
}];
|
|
382
|
+
|
|
383
|
+
// Set the precompute data on the pre element directly on properties for immediate HTML serialization
|
|
384
|
+
if (!node.properties) {
|
|
385
|
+
node.properties = {};
|
|
386
|
+
}
|
|
387
|
+
node.properties.dataPrecompute = JSON.stringify(processedCode);
|
|
388
|
+
_context2.n = 3;
|
|
389
|
+
break;
|
|
390
|
+
case 2:
|
|
391
|
+
_context2.p = 2;
|
|
392
|
+
_t = _context2.v;
|
|
393
|
+
console.warn('Failed to transform code block:', _t);
|
|
394
|
+
case 3:
|
|
395
|
+
return _context2.a(2);
|
|
396
|
+
}
|
|
397
|
+
}, _callee2, null, [[0, 2]]);
|
|
398
|
+
}))();
|
|
399
|
+
transformPromises.push(transformPromise);
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
// Wait for all transformations to complete
|
|
404
|
+
_context3.n = 1;
|
|
405
|
+
return Promise.all(transformPromises);
|
|
406
|
+
case 1:
|
|
407
|
+
return _context3.a(2);
|
|
408
|
+
}
|
|
409
|
+
}, _callee3);
|
|
410
|
+
}));
|
|
411
|
+
return function (_x) {
|
|
412
|
+
return _ref.apply(this, arguments);
|
|
413
|
+
};
|
|
414
|
+
}();
|
|
415
|
+
};
|