@mui/internal-docs-infra 0.1.1-alpha.18 → 0.1.1-alpha.19
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/CodeHighlighter/CodeErrorHandler.d.ts +4 -0
- package/CodeHighlighter/CodeErrorHandler.d.ts.map +1 -0
- package/CodeHighlighter/CodeErrorHandler.js +25 -0
- package/CodeHighlighter/CodeHighlighter.d.ts.map +1 -1
- package/CodeHighlighter/CodeHighlighter.js +31 -33
- package/CodeHighlighter/CodeHighlighterClient.d.ts.map +1 -1
- package/CodeHighlighter/CodeHighlighterClient.js +94 -35
- package/CodeHighlighter/CodeHighlighterContext.d.ts +1 -0
- package/CodeHighlighter/CodeHighlighterContext.d.ts.map +1 -1
- package/CodeHighlighter/types.d.ts +85 -3
- package/CodeHighlighter/types.d.ts.map +1 -1
- package/package.json +34 -9
- package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.d.ts.map +1 -1
- package/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.js +2 -3
- package/useErrors/ErrorsContext.d.ts +6 -0
- package/useErrors/ErrorsContext.d.ts.map +1 -0
- package/useErrors/ErrorsContext.js +7 -0
- package/useErrors/index.d.ts +1 -0
- package/useErrors/index.d.ts.map +1 -0
- package/useErrors/index.js +1 -0
- package/useErrors/useErrors.d.ts +5 -0
- package/useErrors/useErrors.d.ts.map +1 -0
- package/useErrors/useErrors.js +7 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeErrorHandler.d.ts","sourceRoot":"","sources":["../../src/CodeHighlighter/CodeErrorHandler.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,wBAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,EAAE,iBAAiB,2CAgB7D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
var _div, _span;
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { useErrors } from "../useErrors/index.js";
|
|
6
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
export function CodeErrorHandler(_ref) {
|
|
8
|
+
var errors = _ref.errors;
|
|
9
|
+
var context = useErrors();
|
|
10
|
+
errors = context.errors || errors;
|
|
11
|
+
if (!errors || errors.length === 0) {
|
|
12
|
+
return _div || (_div = /*#__PURE__*/_jsx("div", {
|
|
13
|
+
children: "An error occurred, but details were not provided."
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
17
|
+
children: [_span || (_span = /*#__PURE__*/_jsx("span", {
|
|
18
|
+
children: "Error occurred when highlighting code: "
|
|
19
|
+
})), errors.map(function (error, index) {
|
|
20
|
+
return /*#__PURE__*/_jsx("div", {
|
|
21
|
+
children: error.message
|
|
22
|
+
}, index);
|
|
23
|
+
})]
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeHighlighter.d.ts","sourceRoot":"","sources":["../../src/CodeHighlighter/CodeHighlighter.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,oBAAoB,EAMrB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"CodeHighlighter.d.ts","sourceRoot":"","sources":["../../src/CodeHighlighter/CodeHighlighter.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,oBAAoB,EAMrB,MAAM,SAAS,CAAC;AAoXjB,wBAAgB,eAAe,CAAC,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,2CAwI3E"}
|
|
@@ -13,18 +13,13 @@ import { CodeHighlighterClient } from "./CodeHighlighterClient.js";
|
|
|
13
13
|
import { maybeInitialData } from "./maybeInitialData.js";
|
|
14
14
|
import { hasAllVariants } from "./hasAllVariants.js";
|
|
15
15
|
import { getFileNameFromUrl } from "../pipeline/loaderUtils/getFileNameFromUrl.js";
|
|
16
|
+
import { CodeErrorHandler } from "./CodeErrorHandler.js";
|
|
16
17
|
|
|
17
18
|
// Common props shared across helper functions
|
|
18
|
-
import {
|
|
19
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
20
|
var DEFAULT_HIGHLIGHT_AT = 'stream';
|
|
20
21
|
var DEBUG = false; // Set to true for debugging purposes
|
|
21
22
|
|
|
22
|
-
function HighlightErrorHandler(_ref) {
|
|
23
|
-
var error = _ref.error;
|
|
24
|
-
return /*#__PURE__*/_jsxs("div", {
|
|
25
|
-
children: ["Error: ", error.message]
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
23
|
function createClientProps(props) {
|
|
29
24
|
var highlightAt = props.highlightAt === 'stream' ? 'init' : props.highlightAt;
|
|
30
25
|
var contentProps = _objectSpread({
|
|
@@ -35,6 +30,7 @@ function createClientProps(props) {
|
|
|
35
30
|
url: props.url,
|
|
36
31
|
variantType: props.variantType
|
|
37
32
|
}, props.contentProps || {});
|
|
33
|
+
var ErrorHandler = props.ErrorHandler || CodeErrorHandler;
|
|
38
34
|
return {
|
|
39
35
|
url: props.url,
|
|
40
36
|
code: props.code,
|
|
@@ -46,13 +42,17 @@ function createClientProps(props) {
|
|
|
46
42
|
initialVariant: props.initialVariant,
|
|
47
43
|
defaultVariant: props.defaultVariant,
|
|
48
44
|
highlightAt: highlightAt || 'init',
|
|
49
|
-
fallback: props.fallback,
|
|
50
45
|
skipFallback: props.skipFallback,
|
|
51
46
|
controlled: props.controlled,
|
|
52
47
|
name: props.name,
|
|
53
48
|
slug: props.slug,
|
|
54
49
|
// Use processedGlobalsCode if available, otherwise fall back to raw globalsCode
|
|
55
50
|
globalsCode: props.processedGlobalsCode || props.globalsCode,
|
|
51
|
+
// Note: it is important that we render components before passing them to the client
|
|
52
|
+
// otherwise we will get an error because functions can't be serialized
|
|
53
|
+
// On the client, in order to send data to these components, we have to set context
|
|
54
|
+
fallback: props.fallback,
|
|
55
|
+
errorHandler: /*#__PURE__*/_jsx(ErrorHandler, {}),
|
|
56
56
|
children: /*#__PURE__*/_jsx(props.Content, _objectSpread({}, contentProps))
|
|
57
57
|
};
|
|
58
58
|
}
|
|
@@ -65,7 +65,7 @@ function _CodeSourceLoader() {
|
|
|
65
65
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
66
66
|
while (1) switch (_context2.prev = _context2.next) {
|
|
67
67
|
case 0:
|
|
68
|
-
ErrorHandler = props.ErrorHandler ||
|
|
68
|
+
ErrorHandler = props.ErrorHandler || CodeErrorHandler; // Start with the loaded code from precompute, or load it if needed
|
|
69
69
|
loadedCode = props.code || props.precompute;
|
|
70
70
|
if (loadedCode) {
|
|
71
71
|
_context2.next = 16;
|
|
@@ -76,7 +76,7 @@ function _CodeSourceLoader() {
|
|
|
76
76
|
break;
|
|
77
77
|
}
|
|
78
78
|
return _context2.abrupt("return", /*#__PURE__*/_jsx(ErrorHandler, {
|
|
79
|
-
|
|
79
|
+
errors: [new Error('No code provided and "loadCodeMeta" function is not defined')]
|
|
80
80
|
}));
|
|
81
81
|
case 5:
|
|
82
82
|
if (props.url) {
|
|
@@ -84,7 +84,7 @@ function _CodeSourceLoader() {
|
|
|
84
84
|
break;
|
|
85
85
|
}
|
|
86
86
|
return _context2.abrupt("return", /*#__PURE__*/_jsx(ErrorHandler, {
|
|
87
|
-
|
|
87
|
+
errors: [new Error('URL is required when loading code with "loadCodeMeta"')]
|
|
88
88
|
}));
|
|
89
89
|
case 7:
|
|
90
90
|
_context2.prev = 7;
|
|
@@ -98,7 +98,7 @@ function _CodeSourceLoader() {
|
|
|
98
98
|
_context2.prev = 13;
|
|
99
99
|
_context2.t0 = _context2["catch"](7);
|
|
100
100
|
return _context2.abrupt("return", /*#__PURE__*/_jsx(ErrorHandler, {
|
|
101
|
-
|
|
101
|
+
errors: [new Error("Failed to load code from URL: ".concat(props.url, ". Error: ").concat(JSON.stringify(_context2.t0)))]
|
|
102
102
|
}));
|
|
103
103
|
case 16:
|
|
104
104
|
// TODO: if props.variant is provided, we should only load that variant
|
|
@@ -116,12 +116,12 @@ function _CodeSourceLoader() {
|
|
|
116
116
|
break;
|
|
117
117
|
}
|
|
118
118
|
return _context2.abrupt("return", /*#__PURE__*/_jsx(ErrorHandler, {
|
|
119
|
-
|
|
119
|
+
errors: [new Error('loadCodeMeta function is required when globalsCode contains string URLs')]
|
|
120
120
|
}));
|
|
121
121
|
case 21:
|
|
122
122
|
// Load all string URLs in parallel, keep Code objects as-is
|
|
123
123
|
globalsPromises = props.globalsCode.map(/*#__PURE__*/function () {
|
|
124
|
-
var
|
|
124
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(globalItem) {
|
|
125
125
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
126
126
|
while (1) switch (_context.prev = _context.next) {
|
|
127
127
|
case 0:
|
|
@@ -150,7 +150,7 @@ function _CodeSourceLoader() {
|
|
|
150
150
|
}, _callee, null, [[1, 7]]);
|
|
151
151
|
}));
|
|
152
152
|
return function (_x4) {
|
|
153
|
-
return
|
|
153
|
+
return _ref.apply(this, arguments);
|
|
154
154
|
};
|
|
155
155
|
}());
|
|
156
156
|
_context2.prev = 22;
|
|
@@ -164,7 +164,7 @@ function _CodeSourceLoader() {
|
|
|
164
164
|
_context2.prev = 28;
|
|
165
165
|
_context2.t1 = _context2["catch"](22);
|
|
166
166
|
return _context2.abrupt("return", /*#__PURE__*/_jsx(ErrorHandler, {
|
|
167
|
-
|
|
167
|
+
errors: [_context2.t1]
|
|
168
168
|
}));
|
|
169
169
|
case 31:
|
|
170
170
|
variantNames = Object.keys(props.components || loadedCode || {});
|
|
@@ -231,9 +231,7 @@ function _CodeSourceLoader() {
|
|
|
231
231
|
break;
|
|
232
232
|
}
|
|
233
233
|
return _context2.abrupt("return", /*#__PURE__*/_jsx(ErrorHandler, {
|
|
234
|
-
|
|
235
|
-
return err.message;
|
|
236
|
-
}).join('\n ')))
|
|
234
|
+
errors: errors
|
|
237
235
|
}));
|
|
238
236
|
case 41:
|
|
239
237
|
clientProps = createClientProps(_objectSpread(_objectSpread({}, props), {}, {
|
|
@@ -250,14 +248,14 @@ function _CodeSourceLoader() {
|
|
|
250
248
|
return _CodeSourceLoader.apply(this, arguments);
|
|
251
249
|
}
|
|
252
250
|
function renderCodeHighlighter(props) {
|
|
253
|
-
var ErrorHandler = props.ErrorHandler ||
|
|
251
|
+
var ErrorHandler = props.ErrorHandler || CodeErrorHandler;
|
|
254
252
|
var code = props.code || props.precompute;
|
|
255
253
|
var variants = props.variants || Object.keys(props.components || code || {});
|
|
256
254
|
var allCodeVariantsLoaded = code && hasAllVariants(variants, code, true);
|
|
257
255
|
if (!allCodeVariantsLoaded) {
|
|
258
256
|
if (props.forceClient) {
|
|
259
257
|
return /*#__PURE__*/_jsx(ErrorHandler, {
|
|
260
|
-
|
|
258
|
+
errors: [new Error('Client only mode requires precomputed source code')]
|
|
261
259
|
});
|
|
262
260
|
}
|
|
263
261
|
return /*#__PURE__*/_jsx(CodeSourceLoader, _objectSpread({}, props));
|
|
@@ -326,13 +324,13 @@ function _CodeInitialSourceLoader() {
|
|
|
326
324
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
327
325
|
while (1) switch (_context4.prev = _context4.next) {
|
|
328
326
|
case 0:
|
|
329
|
-
ErrorHandler = props.ErrorHandler ||
|
|
327
|
+
ErrorHandler = props.ErrorHandler || CodeErrorHandler;
|
|
330
328
|
if (props.url) {
|
|
331
329
|
_context4.next = 3;
|
|
332
330
|
break;
|
|
333
331
|
}
|
|
334
332
|
return _context4.abrupt("return", /*#__PURE__*/_jsx(ErrorHandler, {
|
|
335
|
-
|
|
333
|
+
errors: [new Error('URL is required for loading initial source')]
|
|
336
334
|
}));
|
|
337
335
|
case 3:
|
|
338
336
|
_context4.next = 5;
|
|
@@ -348,7 +346,7 @@ function _CodeInitialSourceLoader() {
|
|
|
348
346
|
break;
|
|
349
347
|
}
|
|
350
348
|
return _context4.abrupt("return", /*#__PURE__*/_jsx(ErrorHandler, {
|
|
351
|
-
|
|
349
|
+
errors: [loaded.error]
|
|
352
350
|
}));
|
|
353
351
|
case 8:
|
|
354
352
|
code = loaded.code, initialFilename = loaded.initialFilename, initialSource = loaded.initialSource, initialExtraFiles = loaded.initialExtraFiles, processedGlobalsCode = loaded.processedGlobalsCode;
|
|
@@ -370,12 +368,12 @@ function _CodeInitialSourceLoader() {
|
|
|
370
368
|
}
|
|
371
369
|
export function CodeHighlighter(props) {
|
|
372
370
|
var _code, _props$components;
|
|
373
|
-
var ErrorHandler = props.ErrorHandler ||
|
|
371
|
+
var ErrorHandler = props.ErrorHandler || CodeErrorHandler;
|
|
374
372
|
|
|
375
373
|
// Validate mutually exclusive props
|
|
376
374
|
if (props.children && (props.code || props.precompute)) {
|
|
377
375
|
return /*#__PURE__*/_jsx(ErrorHandler, {
|
|
378
|
-
|
|
376
|
+
errors: [new Error('Cannot provide both "children" and "code" or "precompute" props')]
|
|
379
377
|
});
|
|
380
378
|
}
|
|
381
379
|
|
|
@@ -394,7 +392,7 @@ export function CodeHighlighter(props) {
|
|
|
394
392
|
var variants = props.variants || Object.keys(props.components || code || props.precompute || {});
|
|
395
393
|
if (variants.length === 0) {
|
|
396
394
|
return /*#__PURE__*/_jsx(ErrorHandler, {
|
|
397
|
-
|
|
395
|
+
errors: [new Error('No code or components provided')]
|
|
398
396
|
});
|
|
399
397
|
}
|
|
400
398
|
|
|
@@ -406,7 +404,7 @@ export function CodeHighlighter(props) {
|
|
|
406
404
|
variantCode = _Object$entries$_i[1];
|
|
407
405
|
if (_typeof(variantCode) === 'object' && variantCode != null && variantCode.extraFiles && Object.keys(variantCode.extraFiles).length > 0 && !variantCode.fileName && !variantCode.url) {
|
|
408
406
|
return /*#__PURE__*/_jsx(ErrorHandler, {
|
|
409
|
-
|
|
407
|
+
errors: [new Error("fileName or url is required for variant \"".concat(variantName, "\" when extraFiles are provided"))]
|
|
410
408
|
});
|
|
411
409
|
}
|
|
412
410
|
}
|
|
@@ -416,18 +414,18 @@ export function CodeHighlighter(props) {
|
|
|
416
414
|
if (props.highlightAt === 'stream') {
|
|
417
415
|
// if the user explicitly sets highlightAt to 'stream', we need a ContentLoading component
|
|
418
416
|
return /*#__PURE__*/_jsx(ErrorHandler, {
|
|
419
|
-
|
|
417
|
+
errors: [new Error('ContentLoading component is required for stream highlighting')]
|
|
420
418
|
});
|
|
421
419
|
}
|
|
422
420
|
return renderCodeHighlighter(_objectSpread(_objectSpread({}, props), {}, {
|
|
423
421
|
code: code
|
|
424
422
|
}));
|
|
425
423
|
}
|
|
426
|
-
var initialKey = props.initialVariant || props.variant || props.defaultVariant ||
|
|
424
|
+
var initialKey = props.initialVariant || props.variant || props.defaultVariant || variants[0];
|
|
427
425
|
var initial = (_code = code) == null ? void 0 : _code[initialKey];
|
|
428
426
|
if (!initial && !((_props$components = props.components) != null && _props$components[initialKey])) {
|
|
429
427
|
return /*#__PURE__*/_jsx(ErrorHandler, {
|
|
430
|
-
|
|
428
|
+
errors: [new Error("No code or component for variant \"".concat(initialKey, "\""))]
|
|
431
429
|
});
|
|
432
430
|
}
|
|
433
431
|
|
|
@@ -446,13 +444,13 @@ export function CodeHighlighter(props) {
|
|
|
446
444
|
if (props.forceClient) {
|
|
447
445
|
if (highlightAt === 'init') {
|
|
448
446
|
return /*#__PURE__*/_jsx(ErrorHandler, {
|
|
449
|
-
|
|
447
|
+
errors: [new Error('Client only mode with highlightAt: init requires precomputed and parsed source code')]
|
|
450
448
|
});
|
|
451
449
|
}
|
|
452
450
|
|
|
453
451
|
// TODO: send directly to client component?
|
|
454
452
|
return /*#__PURE__*/_jsx(ErrorHandler, {
|
|
455
|
-
|
|
453
|
+
errors: [new Error('Client only mode requires precomputed source code')]
|
|
456
454
|
});
|
|
457
455
|
}
|
|
458
456
|
return /*#__PURE__*/_jsx(CodeInitialSourceLoader, _objectSpread(_objectSpread({}, props), {}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeHighlighterClient.d.ts","sourceRoot":"","sources":["../../src/CodeHighlighter/CodeHighlighterClient.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAQ,0BAA0B,EAA+B,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"CodeHighlighterClient.d.ts","sourceRoot":"","sources":["../../src/CodeHighlighter/CodeHighlighterClient.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAQ,0BAA0B,EAA+B,MAAM,SAAS,CAAC;AAipBxF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,0BAA0B,2CA2OtE"}
|
|
@@ -6,9 +6,11 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
6
6
|
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
7
7
|
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
8
8
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
9
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
9
10
|
import * as React from 'react';
|
|
10
11
|
import { useCodeContext } from "../CodeProvider/CodeContext.js";
|
|
11
12
|
import { CodeHighlighterContext } from "./CodeHighlighterContext.js";
|
|
13
|
+
import { CodeErrorsContext } from "../useErrors/ErrorsContext.js";
|
|
12
14
|
import { maybeInitialData } from "./maybeInitialData.js";
|
|
13
15
|
import { loadFallbackCode } from "./loadFallbackCode.js";
|
|
14
16
|
import { hasAllVariants } from "./hasAllVariants.js";
|
|
@@ -37,7 +39,8 @@ function useInitialData(_ref) {
|
|
|
37
39
|
fallbackUsesAllVariants = _ref.fallbackUsesAllVariants,
|
|
38
40
|
isControlled = _ref.isControlled,
|
|
39
41
|
globalsCode = _ref.globalsCode,
|
|
40
|
-
setProcessedGlobalsCode = _ref.setProcessedGlobalsCode
|
|
42
|
+
setProcessedGlobalsCode = _ref.setProcessedGlobalsCode,
|
|
43
|
+
setErrors = _ref.setErrors;
|
|
41
44
|
var _useCodeContext = useCodeContext(),
|
|
42
45
|
sourceParser = _useCodeContext.sourceParser,
|
|
43
46
|
loadCodeMeta = _useCodeContext.loadCodeMeta,
|
|
@@ -56,7 +59,12 @@ function useInitialData(_ref) {
|
|
|
56
59
|
return;
|
|
57
60
|
}
|
|
58
61
|
if (!url) {
|
|
59
|
-
//
|
|
62
|
+
// URL is required for loading fallback data
|
|
63
|
+
var urlError = new Error('URL is required for loading fallback data when no initial code is provided');
|
|
64
|
+
console.error('CodeHighlighterClient: URL is required for loading fallback data', urlError);
|
|
65
|
+
setErrors(function (prev) {
|
|
66
|
+
return [].concat(_toConsumableArray(prev), [urlError]);
|
|
67
|
+
});
|
|
60
68
|
return;
|
|
61
69
|
}
|
|
62
70
|
|
|
@@ -81,7 +89,9 @@ function useInitialData(_ref) {
|
|
|
81
89
|
case 3:
|
|
82
90
|
loaded = _context.sent;
|
|
83
91
|
if ('error' in loaded) {
|
|
84
|
-
|
|
92
|
+
setErrors(function (prev) {
|
|
93
|
+
return [].concat(_toConsumableArray(prev), [loaded.error]);
|
|
94
|
+
});
|
|
85
95
|
} else {
|
|
86
96
|
setCode(loaded.code);
|
|
87
97
|
// Store processed globalsCode from loadFallbackCode result
|
|
@@ -95,7 +105,7 @@ function useInitialData(_ref) {
|
|
|
95
105
|
}
|
|
96
106
|
}, _callee);
|
|
97
107
|
}))();
|
|
98
|
-
}, [initialData, reason, isControlled, variantName, code, setCode, highlightAt, url, sourceParser, loadSource, loadVariantMeta, loadCodeMeta, fallbackUsesExtraFiles, fallbackUsesAllVariants, fileName, variants, globalsCode, setProcessedGlobalsCode]);
|
|
108
|
+
}, [initialData, reason, isControlled, variantName, code, setCode, highlightAt, url, sourceParser, loadSource, loadVariantMeta, loadCodeMeta, fallbackUsesExtraFiles, fallbackUsesAllVariants, fileName, variants, globalsCode, setProcessedGlobalsCode, setErrors]);
|
|
99
109
|
}
|
|
100
110
|
function useAllVariants(_ref3) {
|
|
101
111
|
var readyForContent = _ref3.readyForContent,
|
|
@@ -106,7 +116,8 @@ function useAllVariants(_ref3) {
|
|
|
106
116
|
setCode = _ref3.setCode,
|
|
107
117
|
processedGlobalsCode = _ref3.processedGlobalsCode,
|
|
108
118
|
globalsCode = _ref3.globalsCode,
|
|
109
|
-
setProcessedGlobalsCode = _ref3.setProcessedGlobalsCode
|
|
119
|
+
setProcessedGlobalsCode = _ref3.setProcessedGlobalsCode,
|
|
120
|
+
setErrors = _ref3.setErrors;
|
|
110
121
|
var _useCodeContext2 = useCodeContext(),
|
|
111
122
|
loadCodeMeta = _useCodeContext2.loadCodeMeta,
|
|
112
123
|
loadVariantMeta = _useCodeContext2.loadVariantMeta,
|
|
@@ -127,38 +138,39 @@ function useAllVariants(_ref3) {
|
|
|
127
138
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
128
139
|
while (1) switch (_context3.prev = _context3.next) {
|
|
129
140
|
case 0:
|
|
141
|
+
_context3.prev = 0;
|
|
130
142
|
loadedCode = code;
|
|
131
143
|
if (loadedCode) {
|
|
132
|
-
_context3.next =
|
|
144
|
+
_context3.next = 8;
|
|
133
145
|
break;
|
|
134
146
|
}
|
|
135
147
|
if (loadCodeMeta) {
|
|
136
|
-
_context3.next =
|
|
148
|
+
_context3.next = 5;
|
|
137
149
|
break;
|
|
138
150
|
}
|
|
139
151
|
throw new Error('"loadCodeMeta" function is required when no code is provided');
|
|
140
|
-
case
|
|
141
|
-
_context3.next =
|
|
152
|
+
case 5:
|
|
153
|
+
_context3.next = 7;
|
|
142
154
|
return loadCodeMeta(url);
|
|
143
|
-
case 6:
|
|
144
|
-
loadedCode = _context3.sent;
|
|
145
155
|
case 7:
|
|
156
|
+
loadedCode = _context3.sent;
|
|
157
|
+
case 8:
|
|
146
158
|
// Use the already-processed globalsCode from state, or process it if not available
|
|
147
159
|
globalsCodeObjects = [];
|
|
148
160
|
if (!processedGlobalsCode) {
|
|
149
|
-
_context3.next =
|
|
161
|
+
_context3.next = 13;
|
|
150
162
|
break;
|
|
151
163
|
}
|
|
152
164
|
// Use the already-processed globalsCode from state
|
|
153
165
|
globalsCodeObjects = processedGlobalsCode;
|
|
154
|
-
_context3.next =
|
|
166
|
+
_context3.next = 18;
|
|
155
167
|
break;
|
|
156
|
-
case
|
|
168
|
+
case 13:
|
|
157
169
|
if (!(globalsCode && globalsCode.length > 0)) {
|
|
158
|
-
_context3.next =
|
|
170
|
+
_context3.next = 18;
|
|
159
171
|
break;
|
|
160
172
|
}
|
|
161
|
-
_context3.next =
|
|
173
|
+
_context3.next = 16;
|
|
162
174
|
return Promise.all(globalsCode.map(/*#__PURE__*/function () {
|
|
163
175
|
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(item) {
|
|
164
176
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
@@ -187,12 +199,12 @@ function useAllVariants(_ref3) {
|
|
|
187
199
|
return _ref5.apply(this, arguments);
|
|
188
200
|
};
|
|
189
201
|
}()));
|
|
190
|
-
case
|
|
202
|
+
case 16:
|
|
191
203
|
globalsCodeObjects = _context3.sent;
|
|
192
204
|
// Store processed globalsCode in state for future use
|
|
193
205
|
setProcessedGlobalsCode(globalsCodeObjects);
|
|
194
|
-
case
|
|
195
|
-
_context3.next =
|
|
206
|
+
case 18:
|
|
207
|
+
_context3.next = 20;
|
|
196
208
|
return Promise.all(variants.map(function (name) {
|
|
197
209
|
// Resolve globalsCode for this specific variant
|
|
198
210
|
var globalsForVariant = globalsCodeObjects.map(function (codeObj) {
|
|
@@ -220,7 +232,7 @@ function useAllVariants(_ref3) {
|
|
|
220
232
|
};
|
|
221
233
|
});
|
|
222
234
|
}));
|
|
223
|
-
case
|
|
235
|
+
case 20:
|
|
224
236
|
result = _context3.sent;
|
|
225
237
|
resultCode = {};
|
|
226
238
|
errors = [];
|
|
@@ -240,17 +252,30 @@ function useAllVariants(_ref3) {
|
|
|
240
252
|
_iterator.f();
|
|
241
253
|
}
|
|
242
254
|
if (errors.length > 0) {
|
|
243
|
-
|
|
255
|
+
console.error('CodeHighlighterClient: Failed to load variants', errors);
|
|
256
|
+
// Add individual errors for specific error reporting
|
|
257
|
+
setErrors(function (prev) {
|
|
258
|
+
return [].concat(_toConsumableArray(prev), errors);
|
|
259
|
+
});
|
|
244
260
|
} else {
|
|
245
261
|
setCode(resultCode);
|
|
246
262
|
}
|
|
247
|
-
|
|
263
|
+
_context3.next = 32;
|
|
264
|
+
break;
|
|
265
|
+
case 28:
|
|
266
|
+
_context3.prev = 28;
|
|
267
|
+
_context3.t0 = _context3["catch"](0);
|
|
268
|
+
console.error('CodeHighlighterClient: Failed to load all variants', _context3.t0);
|
|
269
|
+
setErrors(function (prev) {
|
|
270
|
+
return [].concat(_toConsumableArray(prev), [_context3.t0 instanceof Error ? _context3.t0 : new Error(String(_context3.t0))]);
|
|
271
|
+
});
|
|
272
|
+
case 32:
|
|
248
273
|
case "end":
|
|
249
274
|
return _context3.stop();
|
|
250
275
|
}
|
|
251
|
-
}, _callee3);
|
|
276
|
+
}, _callee3, null, [[0, 28]]);
|
|
252
277
|
}))();
|
|
253
|
-
}, [readyForContent, isControlled, variants, url, code, setCode, loadSource, loadVariantMeta, loadCodeMeta, processedGlobalsCode, globalsCode, setProcessedGlobalsCode]);
|
|
278
|
+
}, [readyForContent, isControlled, variants, url, code, setCode, loadSource, loadVariantMeta, loadCodeMeta, processedGlobalsCode, globalsCode, setProcessedGlobalsCode, setErrors]);
|
|
254
279
|
return {
|
|
255
280
|
readyForContent: readyForContent
|
|
256
281
|
};
|
|
@@ -714,29 +739,47 @@ export function CodeHighlighterClient(props) {
|
|
|
714
739
|
code = _React$useState4[0],
|
|
715
740
|
setCode = _React$useState4[1];
|
|
716
741
|
|
|
742
|
+
// Sync code state with precompute prop changes (for hot-reload)
|
|
743
|
+
React.useEffect(function () {
|
|
744
|
+
if (_typeof(props.precompute) === 'object') {
|
|
745
|
+
setCode(props.precompute);
|
|
746
|
+
} else if (props.precompute === undefined) {
|
|
747
|
+
// Only reset to undefined if precompute is explicitly undefined
|
|
748
|
+
setCode(undefined);
|
|
749
|
+
}
|
|
750
|
+
}, [props.precompute]);
|
|
751
|
+
|
|
717
752
|
// State to store processed globalsCode to avoid duplicate loading
|
|
718
753
|
var _React$useState5 = React.useState(undefined),
|
|
719
754
|
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
720
755
|
processedGlobalsCode = _React$useState6[0],
|
|
721
756
|
setProcessedGlobalsCode = _React$useState6[1];
|
|
722
757
|
|
|
758
|
+
// Error state for handling various loading and processing errors
|
|
759
|
+
var _React$useState7 = React.useState([]),
|
|
760
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
761
|
+
errors = _React$useState8[0],
|
|
762
|
+
setErrors = _React$useState8[1];
|
|
763
|
+
var activeCode = controlledCode || props.code || code;
|
|
764
|
+
var variants = React.useMemo(function () {
|
|
765
|
+
return props.variants || Object.keys(props.components || activeCode || {});
|
|
766
|
+
}, [props.variants, props.components, activeCode]);
|
|
767
|
+
|
|
723
768
|
// TODO: if using props.variant, then the variant is controlled and we can't use our own state
|
|
724
769
|
// does props.variant make any sense instead of controlledSelection?.variant?
|
|
725
|
-
var _React$
|
|
726
|
-
variant: props.initialVariant || props.defaultVariant ||
|
|
770
|
+
var _React$useState9 = React.useState({
|
|
771
|
+
variant: props.initialVariant || props.defaultVariant || variants[0]
|
|
727
772
|
}),
|
|
728
|
-
_React$
|
|
729
|
-
selection = _React$
|
|
730
|
-
setSelection = _React$
|
|
773
|
+
_React$useState0 = _slicedToArray(_React$useState9, 2),
|
|
774
|
+
selection = _React$useState0[0],
|
|
775
|
+
setSelection = _React$useState0[1];
|
|
731
776
|
var variantName = (controlledSelection == null ? void 0 : controlledSelection.variant) || props.variant || selection.variant;
|
|
732
|
-
var activeCode = controlledCode || props.code || code;
|
|
733
777
|
var initialFilename;
|
|
734
778
|
if (_typeof(activeCode == null ? void 0 : activeCode[variantName]) === 'object') {
|
|
735
779
|
var variant = activeCode[variantName];
|
|
736
780
|
initialFilename = variant != null && variant.filesOrder ? variant.filesOrder[0] : variant == null ? void 0 : variant.fileName;
|
|
737
781
|
}
|
|
738
782
|
var fileName = (controlledSelection == null ? void 0 : controlledSelection.fileName) || props.fileName || initialFilename;
|
|
739
|
-
var variants = props.variants || Object.keys(props.components || activeCode || {});
|
|
740
783
|
var url = props.url,
|
|
741
784
|
highlightAt = props.highlightAt,
|
|
742
785
|
fallbackUsesExtraFiles = props.fallbackUsesExtraFiles,
|
|
@@ -753,7 +796,8 @@ export function CodeHighlighterClient(props) {
|
|
|
753
796
|
fallbackUsesAllVariants: fallbackUsesAllVariants,
|
|
754
797
|
isControlled: isControlled,
|
|
755
798
|
globalsCode: props.globalsCode,
|
|
756
|
-
setProcessedGlobalsCode: setProcessedGlobalsCode
|
|
799
|
+
setProcessedGlobalsCode: setProcessedGlobalsCode,
|
|
800
|
+
setErrors: setErrors
|
|
757
801
|
});
|
|
758
802
|
var readyForContent = React.useMemo(function () {
|
|
759
803
|
if (!code) {
|
|
@@ -786,7 +830,8 @@ export function CodeHighlighterClient(props) {
|
|
|
786
830
|
setCode: setCode,
|
|
787
831
|
processedGlobalsCode: processedGlobalsCode,
|
|
788
832
|
globalsCode: props.globalsCode,
|
|
789
|
-
setProcessedGlobalsCode: setProcessedGlobalsCode
|
|
833
|
+
setProcessedGlobalsCode: setProcessedGlobalsCode,
|
|
834
|
+
setErrors: setErrors
|
|
790
835
|
});
|
|
791
836
|
|
|
792
837
|
// Merge globalsCode with internal state code (fetched data) - this should be stable once ready
|
|
@@ -846,12 +891,26 @@ export function CodeHighlighterClient(props) {
|
|
|
846
891
|
components: controlledComponents || props.components,
|
|
847
892
|
availableTransforms: isControlled ? [] : availableTransforms,
|
|
848
893
|
url: props.url,
|
|
849
|
-
deferHighlight: deferHighlight
|
|
894
|
+
deferHighlight: deferHighlight,
|
|
895
|
+
setErrors: setErrors
|
|
850
896
|
};
|
|
851
|
-
}, [overlaidCode, controlledSetCode, selection, controlledSelection, controlledSetSelection, controlledComponents, props.components, isControlled, availableTransforms, props.url, deferHighlight]);
|
|
897
|
+
}, [overlaidCode, controlledSetCode, selection, controlledSelection, controlledSetSelection, controlledComponents, props.components, isControlled, availableTransforms, props.url, deferHighlight, setErrors]);
|
|
852
898
|
if (!props.variants && !props.components && !activeCode) {
|
|
853
899
|
throw new Error('CodeHighlighterClient requires either `variants`, `components`, or `code` to be provided.');
|
|
854
900
|
}
|
|
901
|
+
var errorsContextValue = React.useMemo(function () {
|
|
902
|
+
return {
|
|
903
|
+
errors: errors
|
|
904
|
+
};
|
|
905
|
+
}, [errors]);
|
|
906
|
+
|
|
907
|
+
// If there are errors and an errorHandler, show the errorHandler
|
|
908
|
+
if (errors.length > 0 && props.errorHandler) {
|
|
909
|
+
return /*#__PURE__*/_jsx(CodeErrorsContext.Provider, {
|
|
910
|
+
value: errorsContextValue,
|
|
911
|
+
children: props.errorHandler
|
|
912
|
+
});
|
|
913
|
+
}
|
|
855
914
|
var fallback = props.fallback;
|
|
856
915
|
if (fallback && !props.skipFallback && !activeCodeReady) {
|
|
857
916
|
return /*#__PURE__*/_jsx(CodeHighlighterFallbackContext.Provider, {
|
|
@@ -10,6 +10,7 @@ export interface CodeHighlighterContextType {
|
|
|
10
10
|
availableTransforms?: string[];
|
|
11
11
|
url?: string;
|
|
12
12
|
deferHighlight?: boolean;
|
|
13
|
+
setErrors?: React.Dispatch<React.SetStateAction<Error[]>>;
|
|
13
14
|
}
|
|
14
15
|
export declare const CodeHighlighterContext: React.Context<CodeHighlighterContextType | undefined>;
|
|
15
16
|
export declare function useCodeHighlighterContext(): CodeHighlighterContextType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeHighlighterContext.d.ts","sourceRoot":"","sources":["../../src/CodeHighlighter/CodeHighlighterContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,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AM,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC7C,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC3D;AAED,eAAO,MAAM,sBAAsB,uDAElC,CAAC;AAEF,wBAAgB,yBAAyB,+BAQxC;AAED,wBAAgB,iCAAiC,2CAEhD"}
|
|
@@ -4,7 +4,9 @@ export type Components = {
|
|
|
4
4
|
[key: string]: React.ReactNode;
|
|
5
5
|
};
|
|
6
6
|
type CodeMeta = {
|
|
7
|
+
/** Name of the file (e.g., 'Button.tsx') */
|
|
7
8
|
fileName?: string;
|
|
9
|
+
/** Flattened path for the file */
|
|
8
10
|
path?: string;
|
|
9
11
|
};
|
|
10
12
|
export type Transforms = Record<string, {
|
|
@@ -25,25 +27,48 @@ export interface HastRoot extends Root {
|
|
|
25
27
|
export type VariantSource = string | HastRoot | {
|
|
26
28
|
hastJson: string;
|
|
27
29
|
};
|
|
30
|
+
/**
|
|
31
|
+
* Additional files associated with a code variant.
|
|
32
|
+
* Can be either simple string content or objects with source and transformation options.
|
|
33
|
+
*/
|
|
28
34
|
export type VariantExtraFiles = {
|
|
29
35
|
[fileName: string]: string | {
|
|
36
|
+
/** Source content for this file */
|
|
30
37
|
source?: VariantSource;
|
|
38
|
+
/** Transformations that can be applied to this file */
|
|
31
39
|
transforms?: Transforms;
|
|
40
|
+
/** Skip generating source transformers for this file */
|
|
32
41
|
skipTransforms?: boolean;
|
|
42
|
+
/** Include metadata for this file */
|
|
33
43
|
metadata?: boolean;
|
|
44
|
+
/** File system path for this file */
|
|
34
45
|
path?: string;
|
|
35
46
|
};
|
|
36
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* Complete code variant definition with source, metadata, and configuration.
|
|
50
|
+
* Extends CodeMeta with all the information needed to display and process a code example.
|
|
51
|
+
*/
|
|
37
52
|
export type VariantCode = CodeMeta & {
|
|
53
|
+
/** Source URL where this variant originates */
|
|
38
54
|
url?: string;
|
|
55
|
+
/** Main source content for this variant */
|
|
39
56
|
source?: VariantSource;
|
|
57
|
+
/** Additional files associated with this variant */
|
|
40
58
|
extraFiles?: VariantExtraFiles;
|
|
59
|
+
/** Prefix for metadata keys, e.g. /src */
|
|
41
60
|
metadataPrefix?: string;
|
|
61
|
+
/** External module dependencies */
|
|
42
62
|
externals?: string[];
|
|
63
|
+
/** The name of the export for this variant's entrypoint */
|
|
43
64
|
namedExport?: string;
|
|
65
|
+
/** Order in which files should be displayed */
|
|
44
66
|
filesOrder?: string[];
|
|
67
|
+
/** Transformations that can be applied to the source */
|
|
45
68
|
transforms?: Transforms;
|
|
69
|
+
/** Whether all files in the variant are explicitly listed */
|
|
46
70
|
allFilesListed?: boolean;
|
|
71
|
+
/** Skip generating source transformers for this variant */
|
|
47
72
|
skipTransforms?: boolean;
|
|
48
73
|
};
|
|
49
74
|
export type Code = {
|
|
@@ -63,12 +88,22 @@ export type ControlledVariantCode = CodeMeta & {
|
|
|
63
88
|
export type ControlledCode = {
|
|
64
89
|
[key: string]: undefined | null | ControlledVariantCode;
|
|
65
90
|
};
|
|
91
|
+
/**
|
|
92
|
+
* Base props passed to Content components for rendering code examples.
|
|
93
|
+
* These props provide the necessary data for displaying code, previews, and metadata.
|
|
94
|
+
*/
|
|
66
95
|
type BaseContentProps = {
|
|
96
|
+
/** Display name for the code example, used for identification and titles */
|
|
67
97
|
name?: string;
|
|
98
|
+
/** URL-friendly identifier for deep linking and navigation */
|
|
68
99
|
slug?: string;
|
|
100
|
+
/** Code content with variants and metadata */
|
|
69
101
|
code?: Code;
|
|
102
|
+
/** Rendered React components for live preview alongside code */
|
|
70
103
|
components?: Components;
|
|
104
|
+
/** Source URL where the code content originates from */
|
|
71
105
|
url?: string;
|
|
106
|
+
/** What type of variants are available (e.g., a type `packageManager` when variants `npm` and `yarn` are available) */
|
|
72
107
|
variantType?: string;
|
|
73
108
|
};
|
|
74
109
|
export type ContentProps<T extends {}> = BaseContentProps & T;
|
|
@@ -86,34 +121,65 @@ export type BaseContentLoadingProps = ContentLoadingVariant & {
|
|
|
86
121
|
url?: string;
|
|
87
122
|
};
|
|
88
123
|
export type ContentLoadingProps<T extends {}> = BaseContentLoadingProps & T;
|
|
89
|
-
type
|
|
90
|
-
|
|
91
|
-
}
|
|
124
|
+
export type ErrorHandlerProps = {
|
|
125
|
+
errors?: Error[];
|
|
126
|
+
};
|
|
127
|
+
export type ErrorHandler = React.ComponentType<ErrorHandlerProps>;
|
|
128
|
+
/**
|
|
129
|
+
* Base props shared across all CodeHighlighter variants.
|
|
130
|
+
* Contains common configuration for code display, variants, and metadata.
|
|
131
|
+
*/
|
|
92
132
|
interface CodeHighlighterBaseProps {
|
|
133
|
+
/** Display name for the code example, used for identification and titles */
|
|
93
134
|
name?: string;
|
|
135
|
+
/** URL-friendly identifier for deep linking and navigation */
|
|
94
136
|
slug?: string;
|
|
137
|
+
/** Static code content with variants and metadata */
|
|
95
138
|
code?: Code;
|
|
139
|
+
/** Global static code snippets to inject, typically for styling or tooling */
|
|
96
140
|
globalsCode?: Array<Code | string>;
|
|
141
|
+
/** React components for live preview alongside code */
|
|
97
142
|
components?: Components;
|
|
143
|
+
/** What type of variants are available (e.g., a type `packageManager` when variants `npm` and `yarn` are available) */
|
|
98
144
|
variantType?: string;
|
|
145
|
+
/** Static variant names that should be fetched at runtime */
|
|
99
146
|
variants?: string[];
|
|
147
|
+
/** Currently selected variant name */
|
|
100
148
|
variant?: string;
|
|
149
|
+
/** Currently selected file name */
|
|
101
150
|
fileName?: string;
|
|
151
|
+
/** Default variant to show on first load */
|
|
102
152
|
initialVariant?: string;
|
|
153
|
+
/** Fallback variant when the requested variant is not available */
|
|
103
154
|
defaultVariant?: string;
|
|
155
|
+
/** Pre-computed code data from build-time optimization */
|
|
104
156
|
precompute?: Code;
|
|
157
|
+
/** Whether fallback content should include extra files */
|
|
105
158
|
fallbackUsesExtraFiles?: boolean;
|
|
159
|
+
/** Whether fallback content should include all variants */
|
|
106
160
|
fallbackUsesAllVariants?: boolean;
|
|
161
|
+
/** Source URL where the code content originates from */
|
|
107
162
|
url?: string;
|
|
163
|
+
/** Enable controlled mode for external code state management */
|
|
108
164
|
controlled?: boolean;
|
|
165
|
+
/** Raw code string for simple use cases */
|
|
109
166
|
children?: string;
|
|
110
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Props for the client-side CodeHighlighter component.
|
|
170
|
+
* Used when rendering happens in the browser with lazy loading and interactive features.
|
|
171
|
+
*/
|
|
111
172
|
export interface CodeHighlighterClientProps extends Omit<CodeHighlighterBaseProps, 'children'> {
|
|
173
|
+
/** The CodeContent component that renders the code display and syntax highlighting */
|
|
112
174
|
children: React.ReactNode;
|
|
175
|
+
/** Custom error display component for handling loading or parsing failures */
|
|
113
176
|
errorHandler?: React.ReactNode;
|
|
177
|
+
/** Loading placeholder shown while code is being processed */
|
|
114
178
|
fallback?: React.ReactNode;
|
|
179
|
+
/** Skip showing fallback content entirely */
|
|
115
180
|
skipFallback?: boolean;
|
|
116
181
|
/**
|
|
182
|
+
* When to perform syntax highlighting for performance optimization
|
|
117
183
|
* @default 'hydration'
|
|
118
184
|
*/
|
|
119
185
|
highlightAt?: 'init' | 'hydration' | 'idle';
|
|
@@ -151,20 +217,36 @@ export interface LoadFileOptions {
|
|
|
151
217
|
/** Side effects code to inject into extraFiles */
|
|
152
218
|
globalsCode?: Array<VariantCode | string>;
|
|
153
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* Main props for the CodeHighlighter component.
|
|
222
|
+
* Supports both build-time precomputation and runtime code loading with extensive customization options.
|
|
223
|
+
* Generic type T allows for custom props to be passed to Content and ContentLoading components.
|
|
224
|
+
*/
|
|
154
225
|
export interface CodeHighlighterProps<T extends {}> extends CodeHighlighterBaseProps {
|
|
226
|
+
/** Component to render the code content and preview */
|
|
155
227
|
Content: React.ComponentType<ContentProps<T>>;
|
|
228
|
+
/** Additional props passed to the Content component */
|
|
156
229
|
contentProps?: T;
|
|
230
|
+
/** Component to handle and display errors during code loading or processing */
|
|
157
231
|
ErrorHandler?: ErrorHandler;
|
|
232
|
+
/** Component to show while code is being loaded or processed */
|
|
158
233
|
ContentLoading?: React.ComponentType<ContentLoadingProps<T>>;
|
|
159
234
|
/**
|
|
235
|
+
* When to perform syntax highlighting and code processing
|
|
160
236
|
* @default 'stream'
|
|
161
237
|
*/
|
|
162
238
|
highlightAt?: 'init' | 'stream' | 'hydration' | 'idle';
|
|
239
|
+
/** Force client-side rendering even when server rendering is available */
|
|
163
240
|
forceClient?: boolean;
|
|
241
|
+
/** Function to load code metadata from a URL */
|
|
164
242
|
loadCodeMeta?: LoadCodeMeta;
|
|
243
|
+
/** Function to load specific variant metadata */
|
|
165
244
|
loadVariantMeta?: LoadVariantMeta;
|
|
245
|
+
/** Function to load raw source code and dependencies */
|
|
166
246
|
loadSource?: LoadSource;
|
|
247
|
+
/** Array of source transformers for code processing (e.g., TypeScript to JavaScript) */
|
|
167
248
|
sourceTransformers?: SourceTransformers;
|
|
249
|
+
/** Promise resolving to a source parser for syntax highlighting */
|
|
168
250
|
sourceParser?: Promise<ParseSource>;
|
|
169
251
|
}
|
|
170
252
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/CodeHighlighter/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,CAAA;CAAE,CAAC;AAE5D,KAAK,QAAQ,GAAG;IACd,QAAQ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c,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,MAAM,CAAC;IACvD,0EAA0E;IAC1E,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gDAAgD;IAChD,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,iDAAiD;IACjD,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,wDAAwD;IACxD,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,wFAAwF;IACxF,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,mEAAmE;IACnE,YAAY,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CACrC"}
|
package/package.json
CHANGED
|
@@ -1,19 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/internal-docs-infra",
|
|
3
|
-
"version": "0.1.1-alpha.
|
|
3
|
+
"version": "0.1.1-alpha.19",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "MUI Infra - internal documentation creation tools.",
|
|
6
6
|
"main": "./index.js",
|
|
7
|
+
"types": "./index.d.ts",
|
|
7
8
|
"exports": {
|
|
8
9
|
"./package.json": "./package.json",
|
|
9
|
-
".":
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./index.d.ts",
|
|
12
|
+
"default": "./index.js"
|
|
13
|
+
},
|
|
14
|
+
"./*": {
|
|
15
|
+
"types": "./*/index.d.ts",
|
|
16
|
+
"default": "./*/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./*/types": {
|
|
19
|
+
"types": "./*/types.d.ts",
|
|
20
|
+
"default": "./*/types.js"
|
|
21
|
+
},
|
|
22
|
+
"./*/errors": {
|
|
23
|
+
"types": "./*/errors.d.ts",
|
|
24
|
+
"default": "./*/errors.js"
|
|
25
|
+
},
|
|
26
|
+
"./pipeline": {
|
|
27
|
+
"types": "./pipeline/index.d.ts",
|
|
28
|
+
"default": "./pipeline/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./pipeline/*": {
|
|
31
|
+
"types": "./pipeline/*/index.d.ts",
|
|
32
|
+
"default": "./pipeline/*/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./pipeline/*/types": {
|
|
35
|
+
"types": "./pipeline/*/types.d.ts",
|
|
36
|
+
"default": "./pipeline/*/types.js"
|
|
37
|
+
},
|
|
38
|
+
"./pipeline/*/errors": {
|
|
39
|
+
"types": "./pipeline/*/errors.d.ts",
|
|
40
|
+
"default": "./pipeline/*/errors.js"
|
|
41
|
+
}
|
|
17
42
|
},
|
|
18
43
|
"keywords": [
|
|
19
44
|
"react",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadPrecomputedCodeHighlighter.d.ts","sourceRoot":"","sources":["../../../src/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.ts"],"names":[],"mappings":"AAiCA,UAAU,aAAa;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACxD,SAAS,IAAI,IAAI,CAAC;IAClB,QAAQ,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAChD;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"loadPrecomputedCodeHighlighter.d.ts","sourceRoot":"","sources":["../../../src/pipeline/loadPrecomputedCodeHighlighter/loadPrecomputedCodeHighlighter.ts"],"names":[],"mappings":"AAiCA,UAAU,aAAa;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACxD,SAAS,IAAI,IAAI,CAAC;IAClB,QAAQ,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAChD;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CA6If"}
|
|
@@ -150,9 +150,8 @@ function _loadPrecomputedCodeHighlighter() {
|
|
|
150
150
|
case 18:
|
|
151
151
|
_context.prev = 18;
|
|
152
152
|
_context.t0 = _context["catch"](8);
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
case 22:
|
|
153
|
+
throw new Error("Failed to load variant ".concat(variantName, " from ").concat(fileUrl, ": ").concat(_context.t0));
|
|
154
|
+
case 21:
|
|
156
155
|
case "end":
|
|
157
156
|
return _context.stop();
|
|
158
157
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorsContext.d.ts","sourceRoot":"","sources":["../../src/useErrors/ErrorsContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;CAClB;AAED,eAAO,MAAM,iBAAiB,8CAAgE,CAAC;AAE/F,wBAAgB,gBAAgB,kCAE/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./useErrors.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useErrors/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./useErrors.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useErrors.d.ts","sourceRoot":"","sources":["../../src/useErrors/useErrors.ts"],"names":[],"mappings":"AAEA,KAAK,MAAM,GAAG;IACZ,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;CAClB,CAAC;AAEF,wBAAgB,SAAS,IAAI,MAAM,CAIlC"}
|