comark-solid 0.1.0 → 0.2.0-next.1

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/README.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  Solid renderer for [Comark](https://comark.dev).
4
4
 
5
+ > [!WARNING]
6
+ > **Pre-release: Solid 2.0 RC**
7
+ >
8
+ > This package targets the Solid 2.0 RC versions of `solid-js` and `@solidjs/web`. Solid 2.0 is not stable yet, so bugs and compatibility issues may occur.
9
+
5
10
  ## Installation
6
11
 
7
12
  ```bash
@@ -12,20 +17,13 @@ npm install comark-solid comark
12
17
 
13
18
  Parses Markdown strings and renders them directly.
14
19
 
15
- String input is parsed asynchronously. Wrap the component in Solid's `Suspense` to show a fallback while parsing.
16
-
17
20
  ```tsx
18
21
  import { Markdown } from "comark-solid";
19
- import { Suspense } from "solid-js";
20
22
 
21
23
  const markdown = "# Hello World";
22
24
 
23
25
  export default function App() {
24
- return (
25
- <Suspense fallback={<div>Loading...</div>}>
26
- <Markdown value={markdown} />
27
- </Suspense>
28
- );
26
+ return <Markdown value={markdown} />;
29
27
  }
30
28
  ```
31
29
 
package/dist/index.d.ts CHANGED
@@ -104,7 +104,7 @@ interface MarkdownProps extends Omit<MarkdownDocumentProps, "value"> {
104
104
  * @example
105
105
  * ```tsx
106
106
  * import { Markdown } from "comark-solid";
107
- * import { Suspense } from "solid-js";
107
+ * import { Loading } from "solid-js";
108
108
  * import { CustomHeading } from "./CustomHeading";
109
109
  *
110
110
  * const components = {
@@ -113,12 +113,12 @@ interface MarkdownProps extends Omit<MarkdownDocumentProps, "value"> {
113
113
  *
114
114
  * export default function App() {
115
115
  * return (
116
- * <Suspense fallback={<div>Loading...</div>}>
116
+ * <Loading fallback={<div>Loading...</div>}>
117
117
  * <Markdown
118
118
  * value={source}
119
119
  * components={components}
120
120
  * />
121
- * </Suspense>
121
+ * </Loading>
122
122
  * );
123
123
  * }
124
124
  * ```
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { Dynamic, className, createComponent, effect, insert, mergeProps, template } from "solid-js/web";
1
+ import { className, createComponent, dynamic, effect, insert, mergeProps, readShallow, template } from "@solidjs/web";
2
2
  import { parseMarkdown } from "comark";
3
3
  import { isMarkdownDocument, resolveAttributes } from "comark/utils";
4
- import { Show, Suspense, createMemo, createResource, mergeProps as mergeProps$1 } from "solid-js";
4
+ import { Loading, createMemo, merge } from "solid-js";
5
5
  //#region src/utils/ast.ts
6
6
  function getTag(node) {
7
7
  if (Array.isArray(node) && node.length >= 1 && typeof node[0] === "string") return node[0];
@@ -17,7 +17,7 @@ function getChildren(node) {
17
17
  }
18
18
  //#endregion
19
19
  //#region src/components/MarkdownDocument.tsx
20
- var _tmpl$ = /*#__PURE__*/ template(`<div>`);
20
+ var _tmpl$ = /* @__PURE__ */ template(`<div>`);
21
21
  const DEFAULT_LOCAL_CONTEXT = {
22
22
  parent: void 0,
23
23
  renderData: {
@@ -81,22 +81,24 @@ function createNodeRenderer(components) {
81
81
  ...context.renderData,
82
82
  props
83
83
  } : context.renderData);
84
- return createComponent(Suspense, {
84
+ const CustomComponent = dynamic(() => component);
85
+ return createComponent(Loading, {
85
86
  fallback: null,
86
87
  get children() {
87
- return createComponent(Dynamic, mergeProps({ component }, props, slots));
88
+ return createComponent(CustomComponent, mergeProps(props, slots));
88
89
  }
89
90
  });
90
91
  }
91
92
  function renderNativeElement(element, context) {
92
93
  const { tag, node } = element;
93
94
  const props = resolveProps(node, context.renderData);
94
- if (VOID_ELEMENTS.has(tag)) return createComponent(Dynamic, mergeProps({ component: tag }, props));
95
+ const Component = dynamic(() => tag);
96
+ if (VOID_ELEMENTS.has(tag)) return createComponent(Component, props);
95
97
  const children = getChildren(node).map((child) => renderNode(child, {
96
98
  ...context,
97
99
  parent: node
98
100
  })).filter(Boolean);
99
- return createComponent(Dynamic, mergeProps({ component: tag }, props, { children }));
101
+ return createComponent(Component, mergeProps(props, { children }));
100
102
  }
101
103
  function partitionIntoSlots(node, childRenderData) {
102
104
  const defaultSlot = [];
@@ -150,7 +152,7 @@ function createNodeRenderer(components) {
150
152
  * ```
151
153
  */
152
154
  const MarkdownDocument = (_props) => {
153
- const props = mergeProps$1({
155
+ const props = merge({
154
156
  components: {},
155
157
  data: {},
156
158
  class: void 0
@@ -170,12 +172,12 @@ const MarkdownDocument = (_props) => {
170
172
  })).filter(Boolean);
171
173
  });
172
174
  const wrapperClass = createMemo(() => ["comark-content", props.class].map((cls) => cls?.trim()).filter(Boolean).join(" "));
173
- return (() => {
174
- var _el$ = _tmpl$();
175
- insert(_el$, renderedNodes);
176
- effect(() => className(_el$, wrapperClass()));
177
- return _el$;
178
- })();
175
+ var _el$ = _tmpl$();
176
+ insert(_el$, renderedNodes);
177
+ effect(() => readShallow(wrapperClass()), (_v$, _$p) => {
178
+ className(_el$, _v$, _$p);
179
+ });
180
+ return _el$;
179
181
  };
180
182
  //#endregion
181
183
  //#region src/components/Markdown.tsx
@@ -190,7 +192,7 @@ const MarkdownDocument = (_props) => {
190
192
  * @example
191
193
  * ```tsx
192
194
  * import { Markdown } from "comark-solid";
193
- * import { Suspense } from "solid-js";
195
+ * import { Loading } from "solid-js";
194
196
  * import { CustomHeading } from "./CustomHeading";
195
197
  *
196
198
  * const components = {
@@ -199,44 +201,38 @@ const MarkdownDocument = (_props) => {
199
201
  *
200
202
  * export default function App() {
201
203
  * return (
202
- * <Suspense fallback={<div>Loading...</div>}>
204
+ * <Loading fallback={<div>Loading...</div>}>
203
205
  * <Markdown
204
206
  * value={source}
205
207
  * components={components}
206
208
  * />
207
- * </Suspense>
209
+ * </Loading>
208
210
  * );
209
211
  * }
210
212
  * ```
211
213
  */
212
214
  const Markdown = (_props) => {
213
- const props = mergeProps$1({
215
+ const props = merge({
214
216
  components: {},
215
217
  data: {}
216
218
  }, _props);
217
- const [parsed] = createResource(() => typeof props.value === "string" ? [props.value, props.options] : null, ([value, options]) => parseMarkdown(value, options));
218
219
  const document = createMemo(() => {
219
220
  const value = props.value;
220
- return isMarkdownDocument(value) ? value : parsed();
221
+ return isMarkdownDocument(value) ? value : parseMarkdown(value, props.options);
221
222
  });
222
- return createComponent(Show, {
223
- get when() {
223
+ return createComponent(MarkdownDocument, {
224
+ get value() {
224
225
  return document();
225
226
  },
226
- children: (value) => createComponent(MarkdownDocument, {
227
- get value() {
228
- return value();
229
- },
230
- get components() {
231
- return props.components;
232
- },
233
- get data() {
234
- return props.data;
235
- },
236
- get ["class"]() {
237
- return props.class;
238
- }
239
- })
227
+ get components() {
228
+ return props.components;
229
+ },
230
+ get data() {
231
+ return props.data;
232
+ },
233
+ get "class"() {
234
+ return props.class;
235
+ }
240
236
  });
241
237
  };
242
238
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "comark-solid",
3
- "version": "0.1.0",
3
+ "version": "0.2.0-next.1",
4
4
  "description": "Solid renderer for Comark.",
5
5
  "keywords": [
6
6
  "comark",
@@ -31,24 +31,27 @@
31
31
  "./package.json": "./package.json"
32
32
  },
33
33
  "publishConfig": {
34
- "access": "public"
34
+ "access": "public",
35
+ "tag": "next"
35
36
  },
36
37
  "devDependencies": {
37
- "@solidjs/testing-library": "^0.8.10",
38
+ "@solidjs/testing-library": "^1.0.0-beta.3",
39
+ "@solidjs/vite-plugin": "^3.0.0-next.47",
40
+ "@solidjs/web": "2.0.0-rc.13",
38
41
  "@testing-library/jest-dom": "^7.0.1",
39
42
  "bumpp": "^11.1.0",
40
43
  "comark": "^0.6.2",
41
- "eslint-plugin-solid": "~0.18.0",
44
+ "eslint-plugin-solid": "~0.18.1",
42
45
  "jsdom": "^30.0.1",
43
- "solid-js": "^1.9.15",
46
+ "solid-js": "2.0.0-rc.13",
44
47
  "typescript": "^7.0.2",
45
48
  "vite": "npm:@voidzero-dev/vite-plus-core@0.3.0",
46
- "vite-plugin-solid": "^2.11.14",
47
49
  "vite-plus": "0.3.0"
48
50
  },
49
51
  "peerDependencies": {
52
+ "@solidjs/web": "^2.0.0-rc.6",
50
53
  "comark": "^0.6.2",
51
- "solid-js": "^1.9.0"
54
+ "solid-js": "^2.0.0-rc.6"
52
55
  },
53
56
  "devEngines": {
54
57
  "packageManager": {