@sv-pierre/words 0.0.0-stage → 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 SikandarJODD
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,74 @@
1
- # Temporary Holding Version
1
+ # @sv-pierre/words
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Unofficial Svelte 5 wrapper for [`@pierre/words`](https://github.com/pierrecomputer/pierre/tree/main/packages/words).
4
+
5
+ Render static or streaming Markdown with fast DOM updates. This project is not maintained or endorsed by Pierre.
6
+
7
+ ## Installation
8
+
9
+ ```sh
10
+ pnpm add @sv-pierre/words
11
+ ```
12
+
13
+ ## Features
14
+
15
+ - Static and streaming Markdown
16
+ - CommonMark, GFM, tables, task lists, and footnotes
17
+ - Updates only the changed DOM
18
+ - Optional code highlighting
19
+ - Math and CJK support
20
+ - Code controls, line numbers, and streaming effects
21
+
22
+ ## Usage
23
+
24
+ ```svelte
25
+ <script lang="ts">
26
+ import { Markdown } from '@sv-pierre/words';
27
+ </script>
28
+
29
+ <Markdown source="# Hello, **Svelte**" />
30
+ ```
31
+
32
+ ## More examples
33
+
34
+ ### Streaming
35
+
36
+ Pass the full text received so far. Set `streaming` to `false` when the stream ends.
37
+
38
+ ```svelte
39
+ <Markdown {source} {streaming} animated caret="block" />
40
+ ```
41
+
42
+ ### Code highlighting
43
+
44
+ ```svelte
45
+ <script lang="ts">
46
+ import { Markdown, markdownPlugins } from '@sv-pierre/words';
47
+ </script>
48
+
49
+ <Markdown {source} options={{ plugins: markdownPlugins }} />
50
+ ```
51
+
52
+ ### Renderer options
53
+
54
+ ```svelte
55
+ <Markdown
56
+ {source}
57
+ options={{
58
+ math: true,
59
+ cjk: true,
60
+ lineNumbers: true,
61
+ disallowedElements: ['img']
62
+ }}
63
+ />
64
+ ```
65
+
66
+ See the [`@pierre/words` docs](https://diffs.com/docs#words) for all renderer options.
67
+
68
+ ## Credits
69
+
70
+ Built on [Pierre Words](https://github.com/pierrecomputer/pierre/tree/main/packages/words) and [Pierre Highlights](https://github.com/pierrecomputer/pierre/tree/main/packages/highlights).
71
+
72
+ ## License
73
+
74
+ [MIT](LICENSE)
@@ -0,0 +1,3 @@
1
+ export declare const markdownPlugins: {
2
+ code: import("@pierre/words/html").CodeHighlighterPlugin;
3
+ };
@@ -0,0 +1,9 @@
1
+ import { createHighlightsPlugin } from '@pierre/words/highlights';
2
+ import dark from '@pierre/highlights/themes/pierre-dark';
3
+ import light from '@pierre/highlights/themes/pierre-light';
4
+ export const markdownPlugins = {
5
+ code: createHighlightsPlugin({
6
+ themes: { light, dark },
7
+ defaultColor: 'light-dark()'
8
+ })
9
+ };
@@ -0,0 +1,2 @@
1
+ export { default as Markdown } from './markdown.svelte';
2
+ export { markdownPlugins } from './highlights.js';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { default as Markdown } from './markdown.svelte';
2
+ export { markdownPlugins } from './highlights.js';
@@ -0,0 +1,61 @@
1
+ <script lang="ts">
2
+ import { createDomRenderer, type AnimateOptions, type HtmlOptions } from '@pierre/words/html';
3
+ import '@pierre/words/styles.css';
4
+ import type { Action } from 'svelte/action';
5
+ import { fromAction } from 'svelte/attachments';
6
+
7
+ type Props = {
8
+ source?: string;
9
+ streaming?: boolean;
10
+ parseIncomplete?: boolean;
11
+ animated?: boolean | AnimateOptions;
12
+ caret?: 'block' | 'circle';
13
+ options?: HtmlOptions;
14
+ class?: string;
15
+ };
16
+
17
+ type MarkdownState = Omit<Props, 'class'>;
18
+
19
+ let {
20
+ source = '',
21
+ streaming = false,
22
+ parseIncomplete = true,
23
+ animated = false,
24
+ caret,
25
+ options = {},
26
+ class: className
27
+ }: Props = $props();
28
+
29
+ const markdown: Action<HTMLDivElement, MarkdownState> = (node, initial) => {
30
+ const renderer = createDomRenderer(node);
31
+ renderer.connect();
32
+
33
+ function render(state: MarkdownState) {
34
+ const active = state.streaming ?? false;
35
+ const incomplete = active && (state.parseIncomplete ?? true);
36
+
37
+ renderer.configure(state.options ?? {});
38
+ renderer.update(state.source ?? '', incomplete, active, state.animated ?? false, state.caret);
39
+ }
40
+
41
+ render(initial);
42
+
43
+ return {
44
+ update: render,
45
+ destroy: () => renderer.disconnect()
46
+ };
47
+ };
48
+ </script>
49
+
50
+ <div
51
+ data-markdown="root"
52
+ class={className}
53
+ {@attach fromAction(markdown, () => ({
54
+ source,
55
+ streaming,
56
+ parseIncomplete,
57
+ animated,
58
+ caret,
59
+ options
60
+ }))}
61
+ ></div>
@@ -0,0 +1,14 @@
1
+ import { type AnimateOptions, type HtmlOptions } from '@pierre/words/html';
2
+ import '@pierre/words/styles.css';
3
+ type Props = {
4
+ source?: string;
5
+ streaming?: boolean;
6
+ parseIncomplete?: boolean;
7
+ animated?: boolean | AnimateOptions;
8
+ caret?: 'block' | 'circle';
9
+ options?: HtmlOptions;
10
+ class?: string;
11
+ };
12
+ declare const Markdown: import("svelte").Component<Props, {}, "">;
13
+ type Markdown = ReturnType<typeof Markdown>;
14
+ export default Markdown;
package/package.json CHANGED
@@ -1,6 +1,92 @@
1
1
  {
2
2
  "name": "@sv-pierre/words",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "A Svelte 5 wrapper for @pierre/words",
5
+ "author": "SikandarJODD",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/SikandarJODD/sv-pierre.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/SikandarJODD/sv-pierre/issues"
13
+ },
14
+ "homepage": "https://github.com/SikandarJODD/sv-pierre#readme",
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "keywords": [
19
+ "svelte",
20
+ "svelte5",
21
+ "markdown",
22
+ "streaming",
23
+ "syntax-highlighting"
24
+ ],
25
+ "files": [
26
+ "dist",
27
+ "!dist/**/*.test.*",
28
+ "!dist/**/*.spec.*"
29
+ ],
30
+ "type": "module",
31
+ "sideEffects": [
32
+ "**/*.css"
33
+ ],
34
+ "types": "./dist/index.d.ts",
35
+ "svelte": "./dist/index.js",
36
+ "imports": {
37
+ "#lib": "./src/lib/index.js",
38
+ "#lib/*": "./src/lib/*"
39
+ },
40
+ "exports": {
41
+ ".": {
42
+ "types": "./dist/index.d.ts",
43
+ "svelte": "./dist/index.js"
44
+ }
45
+ },
46
+ "devDependencies": {
47
+ "@eslint/js": "^10.0.1",
48
+ "@playwright/test": "^1.65.1",
49
+ "@sveltejs/adapter-static": "^4.0.1",
50
+ "@sveltejs/kit": "^3.2.0",
51
+ "@sveltejs/package": "^3.0.2",
52
+ "@sveltejs/vite-plugin-svelte": "^7.3.1",
53
+ "@types/node": "^24",
54
+ "@vitest/browser-playwright": "^5.1.0",
55
+ "eslint": "^10.15.0",
56
+ "eslint-config-prettier": "^10.1.8",
57
+ "eslint-plugin-svelte": "^3.24.1",
58
+ "globals": "^17.14.0",
59
+ "mode-watcher": "^1.1.0",
60
+ "playwright": "^1.65.1",
61
+ "prettier": "^3.10.1",
62
+ "prettier-plugin-svelte": "^4.1.1",
63
+ "publint": "^0.3.25",
64
+ "runed": "^0.38.0",
65
+ "svelte": "^5.57.3",
66
+ "svelte-check": "^4.7.8",
67
+ "typescript": "^6.0.3",
68
+ "typescript-eslint": "^8.72.2",
69
+ "vite": "^8.3.8",
70
+ "vitest": "^5.1.0",
71
+ "vitest-browser-svelte": "^3.1.0"
72
+ },
73
+ "peerDependencies": {
74
+ "svelte": "^5.0.0"
75
+ },
76
+ "dependencies": {
77
+ "@pierre/highlights": "^0.5.1",
78
+ "@pierre/words": "^0.2.2"
79
+ },
80
+ "scripts": {
81
+ "dev": "vite dev",
82
+ "build": "vite build && pnpm run prepack",
83
+ "preview": "vite preview",
84
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
85
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
86
+ "lint": "prettier --check . && eslint .",
87
+ "format": "prettier --write .",
88
+ "test:unit": "vitest",
89
+ "test": "npm run test:unit -- --run && npm run test:e2e",
90
+ "test:e2e": "playwright install && playwright test"
91
+ }
6
92
  }