@docusaurus/theme-live-codeblock 2.0.0-beta.20 → 2.0.0-beta.21
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/lib/custom-buble.js +11 -11
- package/lib/index.js +29 -36
- package/lib/theme/CodeBlock/index.d.ts +1 -0
- package/lib/theme/Playground/index.js +3 -3
- package/lib/validateThemeConfig.d.ts +1 -1
- package/lib/validateThemeConfig.js +13 -13
- package/package.json +12 -13
- package/src/theme/Playground/index.tsx +5 -4
- package/src/validateThemeConfig.ts +1 -1
package/lib/custom-buble.js
CHANGED
|
@@ -7,19 +7,19 @@
|
|
|
7
7
|
// fork of Buble which removes Buble's large dependency and weighs in
|
|
8
8
|
// at a smaller size of ~51kB
|
|
9
9
|
// https://github.com/FormidableLabs/react-live#what-bundle-size-can-i-expect
|
|
10
|
-
import {transform as bubleTransform} from '@philpl/buble';
|
|
10
|
+
import { transform as bubleTransform, } from '@philpl/buble';
|
|
11
11
|
// This file is designed to mimic what's written in
|
|
12
12
|
// https://github.com/kitten/buble/blob/mini/src/index.js, with custom transforms options,
|
|
13
13
|
// so that webpack can consume it correctly.
|
|
14
|
-
export {features} from '@philpl/buble';
|
|
14
|
+
export { features } from '@philpl/buble';
|
|
15
15
|
export function transform(source, options) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
return bubleTransform(source, {
|
|
17
|
+
...options,
|
|
18
|
+
transforms: {
|
|
19
|
+
asyncAwait: false,
|
|
20
|
+
classes: false,
|
|
21
|
+
getterSetter: false,
|
|
22
|
+
...options.transforms,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
25
|
}
|
package/lib/index.js
CHANGED
|
@@ -1,47 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
-
Object.defineProperty(exports,
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.validateThemeConfig = void 0;
|
|
10
|
-
const theme_translations_1 = require(
|
|
10
|
+
const theme_translations_1 = require("@docusaurus/theme-translations");
|
|
11
11
|
function themeLiveCodeblock(context) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
getThemePath() {
|
|
18
|
-
return '../lib/theme';
|
|
19
|
-
},
|
|
20
|
-
getTypeScriptThemePath() {
|
|
21
|
-
return '../src/theme';
|
|
22
|
-
},
|
|
23
|
-
getDefaultCodeTranslationMessages() {
|
|
24
|
-
return (0, theme_translations_1.readDefaultCodeTranslationMessages)({
|
|
25
|
-
locale: currentLocale,
|
|
26
|
-
name: 'theme-live-codeblock',
|
|
27
|
-
});
|
|
28
|
-
},
|
|
29
|
-
configureWebpack() {
|
|
30
|
-
return {
|
|
31
|
-
resolve: {
|
|
32
|
-
alias: {
|
|
33
|
-
buble: require.resolve('./custom-buble.js'),
|
|
34
|
-
},
|
|
12
|
+
const { i18n: { currentLocale }, } = context;
|
|
13
|
+
return {
|
|
14
|
+
name: 'docusaurus-theme-live-codeblock',
|
|
15
|
+
getThemePath() {
|
|
16
|
+
return '../lib/theme';
|
|
35
17
|
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
18
|
+
getTypeScriptThemePath() {
|
|
19
|
+
return '../src/theme';
|
|
20
|
+
},
|
|
21
|
+
getDefaultCodeTranslationMessages() {
|
|
22
|
+
return (0, theme_translations_1.readDefaultCodeTranslationMessages)({
|
|
23
|
+
locale: currentLocale,
|
|
24
|
+
name: 'theme-live-codeblock',
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
configureWebpack() {
|
|
28
|
+
return {
|
|
29
|
+
resolve: {
|
|
30
|
+
alias: {
|
|
31
|
+
buble: require.resolve('./custom-buble.js'),
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
};
|
|
39
37
|
}
|
|
40
38
|
exports.default = themeLiveCodeblock;
|
|
41
|
-
var validateThemeConfig_1 = require(
|
|
42
|
-
Object.defineProperty(exports,
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function () {
|
|
45
|
-
return validateThemeConfig_1.validateThemeConfig;
|
|
46
|
-
},
|
|
47
|
-
});
|
|
39
|
+
var validateThemeConfig_1 = require("./validateThemeConfig");
|
|
40
|
+
Object.defineProperty(exports, "validateThemeConfig", { enumerable: true, get: function () { return validateThemeConfig_1.validateThemeConfig; } });
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
+
/// <reference types="react" />
|
|
7
8
|
import { type Props } from '@theme-init/CodeBlock';
|
|
8
9
|
declare const _default: (props: Props) => JSX.Element;
|
|
9
10
|
export default _default;
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
|
-
import {LiveProvider, LiveEditor, LiveError, LivePreview} from 'react-live';
|
|
9
8
|
import clsx from 'clsx';
|
|
9
|
+
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
10
|
+
import {LiveProvider, LiveEditor, LiveError, LivePreview} from 'react-live';
|
|
10
11
|
import Translate from '@docusaurus/Translate';
|
|
11
12
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
12
13
|
import BrowserOnly from '@docusaurus/BrowserOnly';
|
|
13
14
|
import {usePrismTheme} from '@docusaurus/theme-common';
|
|
14
15
|
import styles from './styles.module.css';
|
|
15
|
-
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
16
16
|
function Header({children}) {
|
|
17
17
|
return <div className={clsx(styles.playgroundHeader)}>{children}</div>;
|
|
18
18
|
}
|
|
@@ -83,7 +83,7 @@ export default function Playground({children, transformCode, ...props}) {
|
|
|
83
83
|
{/* @ts-expect-error: type incompatibility with refs */}
|
|
84
84
|
<LiveProvider
|
|
85
85
|
code={children.replace(/\n$/, '')}
|
|
86
|
-
transformCode={transformCode
|
|
86
|
+
transformCode={transformCode ?? ((code) => `${code};`)}
|
|
87
87
|
theme={prismTheme}
|
|
88
88
|
{...props}>
|
|
89
89
|
{playgroundPosition === 'top' ? (
|
|
@@ -9,5 +9,5 @@ import type { ThemeConfig, ThemeConfigValidationContext } from '@docusaurus/type
|
|
|
9
9
|
export declare const DEFAULT_CONFIG: {
|
|
10
10
|
playgroundPosition: string;
|
|
11
11
|
};
|
|
12
|
-
export declare const Schema: Joi.ObjectSchema<
|
|
12
|
+
export declare const Schema: Joi.ObjectSchema<ThemeConfig>;
|
|
13
13
|
export declare function validateThemeConfig({ validate, themeConfig, }: ThemeConfigValidationContext<ThemeConfig>): ThemeConfig;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
-
Object.defineProperty(exports,
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.validateThemeConfig = exports.Schema = exports.DEFAULT_CONFIG = void 0;
|
|
10
|
-
const utils_validation_1 = require(
|
|
10
|
+
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
11
11
|
exports.DEFAULT_CONFIG = {
|
|
12
|
-
|
|
12
|
+
playgroundPosition: 'bottom',
|
|
13
13
|
};
|
|
14
14
|
exports.Schema = utils_validation_1.Joi.object({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
liveCodeBlock: utils_validation_1.Joi.object({
|
|
16
|
+
playgroundPosition: utils_validation_1.Joi.string()
|
|
17
|
+
.equal('top', 'bottom')
|
|
18
|
+
.default(exports.DEFAULT_CONFIG.playgroundPosition),
|
|
19
|
+
})
|
|
20
|
+
.label('themeConfig.liveCodeBlock')
|
|
21
|
+
.default(exports.DEFAULT_CONFIG),
|
|
22
22
|
});
|
|
23
|
-
function validateThemeConfig({validate, themeConfig}) {
|
|
24
|
-
|
|
23
|
+
function validateThemeConfig({ validate, themeConfig, }) {
|
|
24
|
+
return validate(exports.Schema, themeConfig);
|
|
25
25
|
}
|
|
26
26
|
exports.validateThemeConfig = validateThemeConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-live-codeblock",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.21",
|
|
4
4
|
"description": "Docusaurus live code block component.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/theme-live-codeblock.d.ts",
|
|
@@ -11,11 +11,10 @@
|
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
|
-
"build": "
|
|
15
|
-
"
|
|
16
|
-
"build:
|
|
17
|
-
"
|
|
18
|
-
"build:format": "prettier --config ../../.prettierrc --write \"lib/**/*.js\""
|
|
14
|
+
"build": "tsc --build && node ../../admin/scripts/copyUntypedFiles.js && prettier --config ../../.prettierrc --write \"lib/theme/**/*.js\"",
|
|
15
|
+
"watch": "run-p -c copy:watch build:watch",
|
|
16
|
+
"build:watch": "tsc --build --watch",
|
|
17
|
+
"copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch"
|
|
19
18
|
},
|
|
20
19
|
"repository": {
|
|
21
20
|
"type": "git",
|
|
@@ -24,10 +23,10 @@
|
|
|
24
23
|
},
|
|
25
24
|
"license": "MIT",
|
|
26
25
|
"dependencies": {
|
|
27
|
-
"@docusaurus/core": "2.0.0-beta.
|
|
28
|
-
"@docusaurus/theme-common": "2.0.0-beta.
|
|
29
|
-
"@docusaurus/theme-translations": "2.0.0-beta.
|
|
30
|
-
"@docusaurus/utils-validation": "2.0.0-beta.
|
|
26
|
+
"@docusaurus/core": "2.0.0-beta.21",
|
|
27
|
+
"@docusaurus/theme-common": "2.0.0-beta.21",
|
|
28
|
+
"@docusaurus/theme-translations": "2.0.0-beta.21",
|
|
29
|
+
"@docusaurus/utils-validation": "2.0.0-beta.21",
|
|
31
30
|
"@philpl/buble": "^0.19.7",
|
|
32
31
|
"clsx": "^1.1.1",
|
|
33
32
|
"fs-extra": "^10.1.0",
|
|
@@ -35,7 +34,7 @@
|
|
|
35
34
|
"tslib": "^2.4.0"
|
|
36
35
|
},
|
|
37
36
|
"devDependencies": {
|
|
38
|
-
"@docusaurus/types": "2.0.0-beta.
|
|
37
|
+
"@docusaurus/types": "2.0.0-beta.21",
|
|
39
38
|
"@types/buble": "^0.20.1"
|
|
40
39
|
},
|
|
41
40
|
"peerDependencies": {
|
|
@@ -43,7 +42,7 @@
|
|
|
43
42
|
"react-dom": "^16.8.4 || ^17.0.0"
|
|
44
43
|
},
|
|
45
44
|
"engines": {
|
|
46
|
-
"node": ">=14"
|
|
45
|
+
"node": ">=16.14"
|
|
47
46
|
},
|
|
48
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "69ac49fc6909517f13615ee40290c4bd00c39df4"
|
|
49
48
|
}
|
|
@@ -6,15 +6,16 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
|
-
import {LiveProvider, LiveEditor, LiveError, LivePreview} from 'react-live';
|
|
10
9
|
import clsx from 'clsx';
|
|
10
|
+
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
11
|
+
import {LiveProvider, LiveEditor, LiveError, LivePreview} from 'react-live';
|
|
11
12
|
import Translate from '@docusaurus/Translate';
|
|
12
13
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
13
14
|
import BrowserOnly from '@docusaurus/BrowserOnly';
|
|
14
15
|
import {usePrismTheme} from '@docusaurus/theme-common';
|
|
15
|
-
import styles from './styles.module.css';
|
|
16
|
-
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
17
16
|
import type {Props} from '@theme/Playground';
|
|
17
|
+
|
|
18
|
+
import styles from './styles.module.css';
|
|
18
19
|
import type {ThemeConfig} from '@docusaurus/theme-live-codeblock';
|
|
19
20
|
|
|
20
21
|
function Header({children}: {children: React.ReactNode}) {
|
|
@@ -97,7 +98,7 @@ export default function Playground({
|
|
|
97
98
|
{/* @ts-expect-error: type incompatibility with refs */}
|
|
98
99
|
<LiveProvider
|
|
99
100
|
code={children.replace(/\n$/, '')}
|
|
100
|
-
transformCode={transformCode
|
|
101
|
+
transformCode={transformCode ?? ((code) => `${code};`)}
|
|
101
102
|
theme={prismTheme}
|
|
102
103
|
{...props}>
|
|
103
104
|
{playgroundPosition === 'top' ? (
|