dumi 2.3.0-beta.7 → 2.3.0-beta.8

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.
Files changed (40) hide show
  1. package/compiled/crates/swc_plugin_react_demo.wasm +0 -0
  2. package/dist/assetParsers/BaseParser.d.ts +55 -0
  3. package/dist/assetParsers/BaseParser.js +126 -0
  4. package/dist/assetParsers/atom.d.ts +18 -27
  5. package/dist/assetParsers/atom.js +84 -110
  6. package/dist/assetParsers/block.d.ts +2 -0
  7. package/dist/assetParsers/block.js +29 -16
  8. package/dist/assetParsers/utils.d.ts +79 -0
  9. package/dist/assetParsers/utils.js +112 -0
  10. package/dist/client/pages/Demo/index.js +11 -5
  11. package/dist/client/theme-api/DumiDemo/index.js +12 -4
  12. package/dist/client/theme-api/context.d.ts +1 -2
  13. package/dist/client/theme-api/index.d.ts +1 -1
  14. package/dist/client/theme-api/types.d.ts +12 -5
  15. package/dist/client/theme-api/useLiveDemo.js +114 -46
  16. package/dist/client/theme-api/useRenderer.d.ts +5 -0
  17. package/dist/client/theme-api/useRenderer.js +88 -0
  18. package/dist/constants.d.ts +2 -0
  19. package/dist/constants.js +13 -0
  20. package/dist/features/compile/index.js +15 -13
  21. package/dist/features/parser.js +9 -5
  22. package/dist/index.d.ts +3 -2
  23. package/dist/index.js +3 -0
  24. package/dist/loaders/markdown/index.js +24 -5
  25. package/dist/loaders/markdown/transformer/index.d.ts +11 -2
  26. package/dist/loaders/markdown/transformer/index.js +3 -0
  27. package/dist/loaders/markdown/transformer/rehypeDemo.js +22 -7
  28. package/dist/techStacks/react.js +6 -23
  29. package/dist/techStacks/utils.d.ts +18 -0
  30. package/dist/techStacks/utils.js +85 -0
  31. package/dist/types.d.ts +26 -3
  32. package/dist/utils.d.ts +2 -1
  33. package/dist/utils.js +2 -2
  34. package/package.json +7 -3
  35. package/tech-stack-utils.d.ts +12 -0
  36. package/tech-stack-utils.js +9 -0
  37. package/theme-default/builtins/API/index.d.ts +1 -0
  38. package/theme-default/builtins/API/index.js +12 -6
  39. package/theme-default/builtins/Previewer/index.less +1 -0
  40. package/theme-default/builtins/SourceCode/index.js +3 -2
@@ -74,7 +74,7 @@ var HANDLERS = {
74
74
  var signatures = 'oneOf' in signature ? signature.oneOf : [signature];
75
75
  return signatures.map(function (signature) {
76
76
  return "".concat(signature.isAsync ? 'async ' : '', "(").concat(signature.arguments.map(function (arg) {
77
- return "".concat(arg.key, ": ").concat(_this2.toString(arg));
77
+ return "".concat(arg.key).concat(arg.hasQuestionToken ? '?' : '', ": ").concat(_this2.toString(arg));
78
78
  }).join(', '), ") => ").concat(_this2.toString(signature.returnType));
79
79
  }).join(' | ');
80
80
  },
@@ -112,7 +112,6 @@ var APIType = function APIType(prop) {
112
112
  return /*#__PURE__*/React.createElement("code", null, type);
113
113
  };
114
114
  var API = function API(props) {
115
- var _definition$propsConf;
116
115
  var _useRouteMeta = useRouteMeta(),
117
116
  frontmatter = _useRouteMeta.frontmatter;
118
117
  var _useAtomAssets = useAtomAssets(),
@@ -121,6 +120,13 @@ var API = function API(props) {
121
120
  var intl = useIntl();
122
121
  if (!id) throw new Error('`id` properties if required for API component!');
123
122
  var definition = components === null || components === void 0 ? void 0 : components[id];
123
+ var properties = {};
124
+ var type = (props.type || 'props').toLowerCase();
125
+ if (definition) {
126
+ var _definition$key;
127
+ var key = "".concat(type, "Config");
128
+ properties = ((_definition$key = definition[key]) === null || _definition$key === void 0 ? void 0 : _definition$key.properties) || {};
129
+ }
124
130
  return /*#__PURE__*/React.createElement("div", {
125
131
  className: "markdown"
126
132
  }, /*#__PURE__*/React.createElement(Table, null, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, intl.formatMessage({
@@ -129,16 +135,16 @@ var API = function API(props) {
129
135
  id: 'api.component.description'
130
136
  })), /*#__PURE__*/React.createElement("th", null, intl.formatMessage({
131
137
  id: 'api.component.type'
132
- })), /*#__PURE__*/React.createElement("th", null, intl.formatMessage({
138
+ })), props.type === 'props' && /*#__PURE__*/React.createElement("th", null, intl.formatMessage({
133
139
  id: 'api.component.default'
134
- })))), /*#__PURE__*/React.createElement("tbody", null, definition && (_definition$propsConf = definition.propsConfig) !== null && _definition$propsConf !== void 0 && _definition$propsConf.properties ? Object.entries(definition.propsConfig.properties).map(function (_ref4) {
135
- var _definition$propsConf2;
140
+ })))), /*#__PURE__*/React.createElement("tbody", null, Object.keys(properties).length ? Object.entries(properties).map(function (_ref4) {
141
+ var _definition$propsConf;
136
142
  var _ref5 = _slicedToArray(_ref4, 2),
137
143
  name = _ref5[0],
138
144
  prop = _ref5[1];
139
145
  return /*#__PURE__*/React.createElement("tr", {
140
146
  key: name
141
- }, /*#__PURE__*/React.createElement("td", null, name), /*#__PURE__*/React.createElement("td", null, prop.description || '--'), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement(APIType, prop)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("code", null, (_definition$propsConf2 = definition.propsConfig.required) !== null && _definition$propsConf2 !== void 0 && _definition$propsConf2.includes(name) ? intl.formatMessage({
147
+ }, /*#__PURE__*/React.createElement("td", null, name), /*#__PURE__*/React.createElement("td", null, prop.description || '--'), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement(APIType, prop)), props.type === 'props' && /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("code", null, (_definition$propsConf = definition.propsConfig.required) !== null && _definition$propsConf !== void 0 && _definition$propsConf.includes(name) ? intl.formatMessage({
142
148
  id: 'api.component.required'
143
149
  }) : JSON.stringify(prop.default) || '--')));
144
150
  }) : /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
@@ -136,6 +136,7 @@
136
136
  text-overflow: ellipsis;
137
137
  background: lighten(@c-error, 51%);
138
138
  box-sizing: border-box;
139
+ overflow: hidden;
139
140
 
140
141
  @{dark-selector} & {
141
142
  @color: lighten(desaturate(@c-error, 20%), 5%);
@@ -20,7 +20,8 @@ import "./index.less";
20
20
  */
21
21
  var SIMILAR_DSL = {
22
22
  acss: 'css',
23
- axml: 'markup'
23
+ axml: 'markup',
24
+ vue: 'markup'
24
25
  };
25
26
  var SourceCode = function SourceCode(props) {
26
27
  var _props$children = props.children,
@@ -47,7 +48,7 @@ var SourceCode = function SourceCode(props) {
47
48
  }
48
49
  }, [lang, children]);
49
50
  var code = /*#__PURE__*/React.createElement(Highlight, _extends({}, defaultProps, {
50
- code: children,
51
+ code: props.textarea ? children : children.trim(),
51
52
  language: SIMILAR_DSL[lang] || lang,
52
53
  theme: undefined
53
54
  }), function (_ref) {