@dxos/react-ui-syntax-highlighter 0.7.1 → 0.7.2-staging.6d26b2a
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.
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var node_exports = {};
|
|
30
|
+
__export(node_exports, {
|
|
31
|
+
SyntaxHighlighter: () => SyntaxHighlighter
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(node_exports);
|
|
34
|
+
var import_react = __toESM(require("react"));
|
|
35
|
+
var import_light_async = __toESM(require("react-syntax-highlighter/dist/esm/light-async"));
|
|
36
|
+
var import_a11y_dark = __toESM(require("react-syntax-highlighter/dist/esm/styles/hljs/a11y-dark"));
|
|
37
|
+
var import_a11y_light = __toESM(require("react-syntax-highlighter/dist/esm/styles/hljs/a11y-light"));
|
|
38
|
+
var import_react_ui = require("@dxos/react-ui");
|
|
39
|
+
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
40
|
+
var zeroWidthSpace = "\u200B";
|
|
41
|
+
var SyntaxHighlighter = ({ classNames, fallback = zeroWidthSpace, children, ...props }) => {
|
|
42
|
+
const { themeMode } = (0, import_react_ui.useThemeContext)();
|
|
43
|
+
return /* @__PURE__ */ import_react.default.createElement(import_light_async.default, {
|
|
44
|
+
className: (0, import_react_ui_theme.mx)("w-full", classNames),
|
|
45
|
+
style: themeMode === "dark" ? import_a11y_dark.default : import_a11y_light.default,
|
|
46
|
+
...props
|
|
47
|
+
}, children || fallback);
|
|
48
|
+
};
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
SyntaxHighlighter
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/SyntaxHighlighter.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\nimport { type SyntaxHighlighterProps as NativeSyntaxHighlighterProps } from 'react-syntax-highlighter';\n// Lightweight version will load specific language parsers asynchronously.\n// Using `light-async` version directly from dist to avoid any chance of the heavy one being loaded.\n// eslint-disable-next-line no-restricted-imports\nimport NativeSyntaxHighlighter from 'react-syntax-highlighter/dist/esm/light-async';\n// eslint-disable-next-line no-restricted-imports\nimport styleDark from 'react-syntax-highlighter/dist/esm/styles/hljs/a11y-dark';\n// eslint-disable-next-line no-restricted-imports\nimport styleLight from 'react-syntax-highlighter/dist/esm/styles/hljs/a11y-light';\n\nimport { type ThemedClassName, useThemeContext } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nconst zeroWidthSpace = '\\u200b';\n\nexport type SyntaxHighlighterProps = ThemedClassName<\n NativeSyntaxHighlighterProps & {\n fallback?: string;\n }\n>;\n\n/**\n * https://github.com/react-syntax-highlighter/react-syntax-highlighter\n */\nexport const SyntaxHighlighter = ({\n classNames,\n fallback = zeroWidthSpace,\n children,\n ...props\n}: SyntaxHighlighterProps) => {\n const { themeMode } = useThemeContext();\n return (\n <NativeSyntaxHighlighter\n className={mx('w-full', classNames)}\n style={themeMode === 'dark' ? styleDark : styleLight}\n {...props}\n >\n {/* Non-empty fallback prevents collapse. */}\n {children || fallback}\n </NativeSyntaxHighlighter>\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mBAAkB;AAKlB,yBAAoC;AAEpC,uBAAsB;AAEtB,wBAAuB;AAEvB,sBAAsD;AACtD,4BAAmB;AAEnB,IAAMA,iBAAiB;AAWhB,IAAMC,oBAAoB,CAAC,EAChCC,YACAC,WAAWH,gBACXI,UACA,GAAGC,MAAAA,MACoB;AACvB,QAAM,EAAEC,UAAS,QAAKC,iCAAAA;AACtB,SACE,6BAAAC,QAAA,cAACC,mBAAAA,SAAAA;IACCC,eAAWC,0BAAG,UAAUT,UAAAA;IACxBU,OAAON,cAAc,SAASO,iBAAAA,UAAYC,kBAAAA;IACzC,GAAGT;KAGHD,YAAYD,QAAAA;AAGnB;",
|
|
6
|
+
"names": ["zeroWidthSpace", "SyntaxHighlighter", "classNames", "fallback", "children", "props", "themeMode", "useThemeContext", "React", "NativeSyntaxHighlighter", "className", "mx", "style", "styleDark", "styleLight"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"packages/ui/react-ui-syntax-highlighter/src/SyntaxHighlighter.tsx":{"bytes":4650,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"react-syntax-highlighter/dist/esm/light-async","kind":"import-statement","external":true},{"path":"react-syntax-highlighter/dist/esm/styles/hljs/a11y-dark","kind":"import-statement","external":true},{"path":"react-syntax-highlighter/dist/esm/styles/hljs/a11y-light","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-syntax-highlighter/src/index.ts":{"bytes":536,"imports":[{"path":"packages/ui/react-ui-syntax-highlighter/src/SyntaxHighlighter.tsx","kind":"import-statement","original":"./SyntaxHighlighter"}],"format":"esm"}},"outputs":{"packages/ui/react-ui-syntax-highlighter/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":2380},"packages/ui/react-ui-syntax-highlighter/dist/lib/node/index.cjs":{"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"react-syntax-highlighter/dist/esm/light-async","kind":"import-statement","external":true},{"path":"react-syntax-highlighter/dist/esm/styles/hljs/a11y-dark","kind":"import-statement","external":true},{"path":"react-syntax-highlighter/dist/esm/styles/hljs/a11y-light","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true}],"exports":["SyntaxHighlighter"],"entryPoint":"packages/ui/react-ui-syntax-highlighter/src/index.ts","inputs":{"packages/ui/react-ui-syntax-highlighter/src/SyntaxHighlighter.tsx":{"bytesInOutput":751},"packages/ui/react-ui-syntax-highlighter/src/index.ts":{"bytesInOutput":0}},"bytes":887}}}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// packages/ui/react-ui-syntax-highlighter/src/SyntaxHighlighter.tsx
|
|
4
|
+
import React from "react";
|
|
5
|
+
import NativeSyntaxHighlighter from "react-syntax-highlighter/dist/esm/light-async";
|
|
6
|
+
import styleDark from "react-syntax-highlighter/dist/esm/styles/hljs/a11y-dark";
|
|
7
|
+
import styleLight from "react-syntax-highlighter/dist/esm/styles/hljs/a11y-light";
|
|
8
|
+
import { useThemeContext } from "@dxos/react-ui";
|
|
9
|
+
import { mx } from "@dxos/react-ui-theme";
|
|
10
|
+
var zeroWidthSpace = "\u200B";
|
|
11
|
+
var SyntaxHighlighter = ({ classNames, fallback = zeroWidthSpace, children, ...props }) => {
|
|
12
|
+
const { themeMode } = useThemeContext();
|
|
13
|
+
return /* @__PURE__ */ React.createElement(NativeSyntaxHighlighter, {
|
|
14
|
+
className: mx("w-full", classNames),
|
|
15
|
+
style: themeMode === "dark" ? styleDark : styleLight,
|
|
16
|
+
...props
|
|
17
|
+
}, children || fallback);
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
SyntaxHighlighter
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/SyntaxHighlighter.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\nimport { type SyntaxHighlighterProps as NativeSyntaxHighlighterProps } from 'react-syntax-highlighter';\n// Lightweight version will load specific language parsers asynchronously.\n// Using `light-async` version directly from dist to avoid any chance of the heavy one being loaded.\n// eslint-disable-next-line no-restricted-imports\nimport NativeSyntaxHighlighter from 'react-syntax-highlighter/dist/esm/light-async';\n// eslint-disable-next-line no-restricted-imports\nimport styleDark from 'react-syntax-highlighter/dist/esm/styles/hljs/a11y-dark';\n// eslint-disable-next-line no-restricted-imports\nimport styleLight from 'react-syntax-highlighter/dist/esm/styles/hljs/a11y-light';\n\nimport { type ThemedClassName, useThemeContext } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nconst zeroWidthSpace = '\\u200b';\n\nexport type SyntaxHighlighterProps = ThemedClassName<\n NativeSyntaxHighlighterProps & {\n fallback?: string;\n }\n>;\n\n/**\n * https://github.com/react-syntax-highlighter/react-syntax-highlighter\n */\nexport const SyntaxHighlighter = ({\n classNames,\n fallback = zeroWidthSpace,\n children,\n ...props\n}: SyntaxHighlighterProps) => {\n const { themeMode } = useThemeContext();\n return (\n <NativeSyntaxHighlighter\n className={mx('w-full', classNames)}\n style={themeMode === 'dark' ? styleDark : styleLight}\n {...props}\n >\n {/* Non-empty fallback prevents collapse. */}\n {children || fallback}\n </NativeSyntaxHighlighter>\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;AAIA,OAAOA,WAAW;AAKlB,OAAOC,6BAA6B;AAEpC,OAAOC,eAAe;AAEtB,OAAOC,gBAAgB;AAEvB,SAA+BC,uBAAuB;AACtD,SAASC,UAAU;AAEnB,IAAMC,iBAAiB;AAWhB,IAAMC,oBAAoB,CAAC,EAChCC,YACAC,WAAWH,gBACXI,UACA,GAAGC,MAAAA,MACoB;AACvB,QAAM,EAAEC,UAAS,IAAKC,gBAAAA;AACtB,SACE,sBAAA,cAACC,yBAAAA;IACCC,WAAWC,GAAG,UAAUR,UAAAA;IACxBS,OAAOL,cAAc,SAASM,YAAYC;IACzC,GAAGR;KAGHD,YAAYD,QAAAA;AAGnB;",
|
|
6
|
+
"names": ["React", "NativeSyntaxHighlighter", "styleDark", "styleLight", "useThemeContext", "mx", "zeroWidthSpace", "SyntaxHighlighter", "classNames", "fallback", "children", "props", "themeMode", "useThemeContext", "NativeSyntaxHighlighter", "className", "mx", "style", "styleDark", "styleLight"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"packages/ui/react-ui-syntax-highlighter/src/SyntaxHighlighter.tsx":{"bytes":4650,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"react-syntax-highlighter/dist/esm/light-async","kind":"import-statement","external":true},{"path":"react-syntax-highlighter/dist/esm/styles/hljs/a11y-dark","kind":"import-statement","external":true},{"path":"react-syntax-highlighter/dist/esm/styles/hljs/a11y-light","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-syntax-highlighter/src/index.ts":{"bytes":536,"imports":[{"path":"packages/ui/react-ui-syntax-highlighter/src/SyntaxHighlighter.tsx","kind":"import-statement","original":"./SyntaxHighlighter"}],"format":"esm"}},"outputs":{"packages/ui/react-ui-syntax-highlighter/dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":2382},"packages/ui/react-ui-syntax-highlighter/dist/lib/node-esm/index.mjs":{"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"react-syntax-highlighter/dist/esm/light-async","kind":"import-statement","external":true},{"path":"react-syntax-highlighter/dist/esm/styles/hljs/a11y-dark","kind":"import-statement","external":true},{"path":"react-syntax-highlighter/dist/esm/styles/hljs/a11y-light","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true}],"exports":["SyntaxHighlighter"],"entryPoint":"packages/ui/react-ui-syntax-highlighter/src/index.ts","inputs":{"packages/ui/react-ui-syntax-highlighter/src/SyntaxHighlighter.tsx":{"bytesInOutput":751},"packages/ui/react-ui-syntax-highlighter/src/index.ts":{"bytesInOutput":0}},"bytes":980}}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-syntax-highlighter",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2-staging.6d26b2a",
|
|
4
4
|
"description": "A syntax highlighter wrapper.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
12
|
"types": "./dist/types/src/index.d.ts",
|
|
13
|
-
"browser": "./dist/lib/browser/index.mjs"
|
|
13
|
+
"browser": "./dist/lib/browser/index.mjs",
|
|
14
|
+
"node": "./dist/lib/node-esm/index.mjs"
|
|
14
15
|
}
|
|
15
16
|
},
|
|
16
17
|
"types": "dist/types/src/index.d.ts",
|
|
@@ -31,15 +32,15 @@
|
|
|
31
32
|
"react": "~18.2.0",
|
|
32
33
|
"react-dom": "~18.2.0",
|
|
33
34
|
"vite": "5.4.7",
|
|
34
|
-
"@dxos/react-ui": "0.7.
|
|
35
|
-
"@dxos/storybook-utils": "0.7.
|
|
36
|
-
"@dxos/react-ui-theme": "0.7.
|
|
35
|
+
"@dxos/react-ui": "0.7.2-staging.6d26b2a",
|
|
36
|
+
"@dxos/storybook-utils": "0.7.2-staging.6d26b2a",
|
|
37
|
+
"@dxos/react-ui-theme": "0.7.2-staging.6d26b2a"
|
|
37
38
|
},
|
|
38
39
|
"peerDependencies": {
|
|
39
40
|
"react": "~18.2.0",
|
|
40
41
|
"react-dom": "~18.2.0",
|
|
41
|
-
"@dxos/react-ui
|
|
42
|
-
"@dxos/react-ui": "0.7.
|
|
42
|
+
"@dxos/react-ui": "0.7.2-staging.6d26b2a",
|
|
43
|
+
"@dxos/react-ui-theme": "0.7.2-staging.6d26b2a"
|
|
43
44
|
},
|
|
44
45
|
"publishConfig": {
|
|
45
46
|
"access": "public"
|