@primeui-devkit/lit-markdown 0.1.0-rc.2 → 0.1.0-rc.3

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
@@ -14,6 +14,3 @@ el.tree = tree; // pre-parsed MarkdownTree (or set el.markdown for runtime parse
14
14
  el.components = { 'demo-viewer': (props, children) => myDemoNode(props) };
15
15
  document.body.append(el);
16
16
  ```
17
-
18
- The DOM rebuilds only when `tree`/`markdown`/`components` references change,
19
- so stateful custom-rendered children survive unrelated updates.
package/dist/index.d.ts CHANGED
@@ -2,10 +2,17 @@ import { MarkdownTree } from '@primeui-devkit/markdown-core';
2
2
  import { ReactiveElement } from 'lit';
3
3
 
4
4
  type MdNode = string | MdElementNode;
5
- type MdElementNode = [string, Record<string, unknown>, ...MdNode[]];
5
+ type MdElementNode = [string | null, Record<string, unknown>, ...MdNode[]];
6
+ /** What `:prefixed` bindings resolve against: the page's frontmatter and meta, and the parent's props. */
7
+ type RenderData = {
8
+ frontmatter: Record<string, unknown>;
9
+ meta: Record<string, unknown>;
10
+ data: Record<string, unknown>;
11
+ props: Record<string, unknown>;
12
+ };
6
13
  /** A custom renderer receives the node's props and already-rendered children and returns a DOM node it owns. */
7
14
  type LitComponentRenderer = (props: Record<string, unknown>, children: DocumentFragment, node: MdElementNode) => Node;
8
- declare function renderNode(node: MdNode, components: Record<string, LitComponentRenderer>): Node;
15
+ declare function renderNode(node: MdNode, components: Record<string, LitComponentRenderer>, renderData?: RenderData): Node;
9
16
  declare function renderTree(tree: MarkdownTree, components?: Record<string, LitComponentRenderer>): DocumentFragment;
10
17
  /**
11
18
  * <lit-markdown> — renders a pre-parsed tree (or parses `markdown` at runtime).
@@ -35,4 +42,5 @@ declare class LitMarkdown extends ReactiveElement {
35
42
  }
36
43
  declare function defineLitMarkdown(tagName?: string): void;
37
44
 
38
- export { type LitComponentRenderer, LitMarkdown, defineLitMarkdown, renderNode, renderTree };
45
+ export { LitMarkdown, defineLitMarkdown, renderNode, renderTree };
46
+ export type { LitComponentRenderer };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import {ReactiveElement}from'lit';var f=new Set(["h1","h2","h3","h4","h5","h6"]),h=new Set(["p","a","blockquote","code","em","strong","hr","img","li","ol","ul","table","thead","tbody","tr","th","td"]),p='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>',g='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M20 6 9 17l-5-5"/></svg>';function w(t,r){for(let[e,n]of Object.entries(r)){if(Array.isArray(n)){let i=n.filter(Boolean).join(" ");i&&t.setAttribute(e,i);continue}n==null||typeof n=="function"||typeof n=="object"||(typeof n=="boolean"?n&&t.setAttribute(e,""):t.setAttribute(e,String(n)));}}function k(t,r,e){let n=document.createElement(t);n.className=`prose-${t}`;let i=typeof r.id=="string"?r.id:null;if(i){n.id=i;let s=document.createElement("a");s.href=`#${i}`,s.className="prose-heading-link";let o=document.createElement("span");o.className="prose-heading-anchor",o.textContent="#",s.append(o,e),n.append(s);}else n.append(e);return n}function y(t,r){let e=document.createElement("div");e.className="prose-pre";let n=typeof t.filename=="string"?t.filename:"",i=n.replace(":line-numbers","");if(i){let c=document.createElement("div");c.className="prose-pre-filename",c.innerHTML="<span></span>",c.querySelector("span").textContent=i,e.append(c);}let s=document.createElement("div");s.className="prose-pre-actions";let o=document.createElement("button");o.type="button",o.className="prose-pre-copy",o.title="Copy Code",o.innerHTML=p,o.addEventListener("click",async()=>{let c=typeof t.code=="string"?t.code:"";c&&(await navigator.clipboard.writeText(c),o.innerHTML=g,o.title="Copied",setTimeout(()=>{o.innerHTML=p,o.title="Copy Code";},2e3));}),s.append(o),e.append(s);let a=document.createElement("pre"),d=Array.isArray(t.class)?t.class.filter(Boolean).join(" "):typeof t.class=="string"?t.class:"";return a.className=[d,n.includes(":line-numbers")?"prose-pre-line-numbers":""].filter(Boolean).join(" "),a.append(r),e.append(a),e}function b(t){let r=document.createElement("div");r.className="prose-table-scroll";let e=document.createElement("table");return e.className="prose-table",e.append(t),r.append(e),r}function m(t,r){if(typeof t=="string")return document.createTextNode(t);let[e,n={},...i]=t,s=document.createDocumentFragment();for(let d of i)s.append(m(d,r));let o=r[e];if(o)return o(n,s,t);if(f.has(e))return k(e,n,s);if(e==="pre")return y(n,s);if(e==="table")return b(s);let a=document.createElement(e);return w(a,n),h.has(e)&&a.classList.add(`prose-${e}`),a.append(s),a}function E(t,r={}){let e=document.createDocumentFragment();for(let n of t.nodes||[])e.append(m(n,r));return e}var l=class extends ReactiveElement{static properties={tree:{attribute:false},markdown:{type:String},components:{attribute:false}};#e=0;constructor(){super(),this.tree=null,this.markdown="",this.components={};}createRenderRoot(){return this}update(r){if(super.update(r),r.has("markdown")&&this.markdown){let e=++this.#e;import('@primeui-devkit/markdown-core').then(n=>n.parseMarkdown(this.markdown)).then(n=>{e===this.#e&&(this.tree=n);});return}(r.has("tree")||r.has("components"))&&(this.replaceChildren(),this.tree&&(this.classList.add("prose"),this.append(E(this.tree,this.components))));}};function M(t="lit-markdown"){customElements.get(t)||customElements.define(t,l);}export{l as LitMarkdown,M as defineLitMarkdown,m as renderNode,E as renderTree};
1
+ import{resolveAttributes as e}from"@primeui-devkit/markdown-core";import{ReactiveElement as t}from"lit";const n=/* @__PURE__ */ new Set([`h1`,`h2`,`h3`,`h4`,`h5`,`h6`]),r=/* @__PURE__ */ new Set([`p`,`a`,`blockquote`,`code`,`em`,`strong`,`hr`,`img`,`li`,`ol`,`ul`,`table`,`thead`,`tbody`,`tr`,`th`,`td`]),i=`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>`;function a(t,n,r){for(let[i,a]of Object.entries(e(n,r,{parseJson:!0}))){if(Array.isArray(a)){let e=a.filter(Boolean).join(` `);e&&t.setAttribute(i,e);continue}a!=null&&typeof a!=`function`&&typeof a!=`object`&&(typeof a==`boolean`?a&&t.setAttribute(i,``):t.setAttribute(i,String(a)))}}function o(e,t,n){let r=document.createElement(e);r.className=`prose-${e}`;let i=typeof t.id==`string`?t.id:null;if(i){r.id=i;let e=document.createElement(`a`);e.href=`#${i}`,e.className=`prose-heading-link`;let t=document.createElement(`span`);t.className=`prose-heading-anchor`,t.textContent=`#`,e.append(t,n),r.append(e)}else r.append(n);return r}function s(e,t){let n=document.createElement(`div`);n.className=`prose-pre`;let r=typeof e.filename==`string`?e.filename:``,a=r.replace(`:line-numbers`,``);if(a){let e=document.createElement(`div`);e.className=`prose-pre-filename`,e.innerHTML=`<span></span>`,e.querySelector(`span`).textContent=a,n.append(e)}let o=document.createElement(`div`);o.className=`prose-pre-actions`;let s=document.createElement(`button`);s.type=`button`,s.className=`prose-pre-copy`,s.title=`Copy Code`,s.innerHTML=i,s.addEventListener(`click`,async()=>{let t=typeof e.code==`string`?e.code:``;t&&(await navigator.clipboard.writeText(t),s.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M20 6 9 17l-5-5"/></svg>`,s.title=`Copied`,setTimeout(()=>{s.innerHTML=i,s.title=`Copy Code`},2e3))}),o.append(s),n.append(o);let c=document.createElement(`pre`);return c.className=[Array.isArray(e.class)?e.class.filter(Boolean).join(` `):typeof e.class==`string`?e.class:``,r.includes(`:line-numbers`)?`prose-pre-line-numbers`:``].filter(Boolean).join(` `),c.append(t),n.append(c),n}function c(e){let t=document.createElement(`div`);t.className=`prose-table-scroll`;let n=document.createElement(`table`);return n.className=`prose-table`,n.append(e),t.append(n),t}function l(e,t,i=u()){if(typeof e==`string`)return document.createTextNode(e);let[d,f={},...p]=e;if(d===null)return document.createDocumentFragment();let m=document.createDocumentFragment();for(let e of p)m.append(l(e,t,{...i,props:f}));let h=t[d];if(h)return h(f,m,e);if(n.has(d))return o(d,f,m);if(d===`pre`)return s(f,m);if(d===`table`)return c(m);let g=document.createElement(d);return a(g,f,i),r.has(d)&&g.classList.add(`prose-${d}`),g.append(m),g}const u=()=>({frontmatter:{},meta:{},data:{},props:{}});function d(e,t={}){let n=document.createDocumentFragment(),{frontmatter:r={},meta:i={}}=e,a={frontmatter:r,meta:i,data:{},props:{}};for(let r of e.nodes||[])n.append(l(r,t,a));return n}var f=class extends t{static properties={tree:{attribute:!1},markdown:{type:String},components:{attribute:!1}};#e=0;constructor(){super(),this.tree=null,this.markdown=``,this.components={}}createRenderRoot(){return this}update(e){if(super.update(e),e.has(`markdown`)&&this.markdown){let e=++this.#e;import(`@primeui-devkit/markdown-core`).then(e=>e.parseMarkdown(this.markdown)).then(t=>{e===this.#e&&(this.tree=t)});return}(e.has(`tree`)||e.has(`components`))&&(this.replaceChildren(),this.tree&&(this.classList.add(`prose`),this.append(d(this.tree,this.components))))}};function p(e=`lit-markdown`){customElements.get(e)||customElements.define(e,f)}export{f as LitMarkdown,p as defineLitMarkdown,l as renderNode,d as renderTree};
package/package.json CHANGED
@@ -1,50 +1,61 @@
1
1
  {
2
2
  "name": "@primeui-devkit/lit-markdown",
3
- "version": "0.1.0-rc.2",
3
+ "version": "0.1.0-rc.3",
4
+ "author": "PrimeTek Informatics",
4
5
  "description": "Lit renderer for the PrimeUI DevKit markdown AST with built-in prose behaviors: heading anchors, code copy button and table scroll wrapper. Renders into light DOM so shared prose styles apply.",
5
6
  "license": "SEE LICENSE IN LICENSE.md",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/primefaces/primeui-devkit.git",
10
+ "directory": "packages/markdown/lit-markdown"
11
+ },
12
+ "bugs": {
13
+ "url": "https://support.primeui.dev"
14
+ },
6
15
  "type": "module",
16
+ "main": "./dist/index.js",
17
+ "module": "./dist/index.js",
18
+ "types": "./dist/index.d.ts",
7
19
  "exports": {
8
20
  ".": {
9
21
  "types": "./dist/index.d.ts",
10
- "import": "./dist/index.js"
11
- }
22
+ "import": "./dist/index.js",
23
+ "default": "./dist/index.js"
24
+ },
25
+ "./package.json": "./package.json"
26
+ },
27
+ "publishConfig": {
28
+ "access": "public"
12
29
  },
30
+ "sideEffects": false,
13
31
  "files": [
14
32
  "dist",
15
33
  "LICENSE.md",
16
- "THIRD-PARTY-NOTICES.txt",
17
34
  "README.md"
18
35
  ],
19
- "sideEffects": false,
20
36
  "dependencies": {
21
- "@primeui-devkit/markdown-core": "0.1.0-rc.2"
37
+ "@primeui-devkit/markdown-core": "0.1.0-rc.3"
22
38
  },
23
39
  "peerDependencies": {
24
40
  "lit": "^3.0.0"
25
41
  },
26
42
  "devDependencies": {
27
43
  "cross-env": "^10.1.0",
44
+ "jsdom": "^30.0.1",
28
45
  "lit": "^3.0.0",
29
- "tsup": "^8.5.1",
30
46
  "typescript": "~6.0.0",
31
- "vitest": "4.1.10",
32
- "@primeui-devkit/test-config": "0.0.0",
33
- "@primeui-devkit/bundler": "0.0.0",
34
- "@primeui-devkit/ts-config": "0.0.0"
35
- },
36
- "types": "./dist/index.d.ts",
37
- "module": "./dist/index.js",
38
- "author": "PrimeTek Informatics",
39
- "bugs": {
40
- "url": "https://support.primeui.dev"
47
+ "vitest": "4.1.11",
48
+ "@primeui-devkit/test-config": "0.1.0-rc.1",
49
+ "@primeui-devkit/cli": "0.1.0-rc.1",
50
+ "@primeui-devkit/ts-config": "0.1.0-rc.1",
51
+ "@primeui-devkit/bundle": "0.1.0-rc.1"
41
52
  },
42
- "publishConfig": {
43
- "access": "public"
53
+ "engines": {
54
+ "node": ">=22.18.0"
44
55
  },
45
56
  "scripts": {
46
57
  "build": "pnpm run build:package",
47
- "build:package": "pnpm run test && tsup",
58
+ "build:package": "pnpm run test && devkit bundle build",
48
59
  "type:check": "tsc --noEmit",
49
60
  "test": "cross-env NODE_ENV=test vitest run --passWithNoTests",
50
61
  "test:watch": "vitest --watch --passWithNoTests",
@@ -1,36 +0,0 @@
1
- # Third-Party Notices
2
-
3
- This package uses the following third-party open source software.
4
- Each is provided under its own license, reproduced below.
5
-
6
- ---
7
-
8
- ## comark
9
-
10
- Copyright (c) 2026 Comark team and contributors
11
-
12
- The markdown parsing engine used (via @primeui-devkit/markdown-core) by this package (https://github.com/comarkdown/comark).
13
-
14
- Licensed under the MIT License.
15
-
16
- MIT License
17
-
18
- Copyright (c) 2026 Comark team and contributors
19
-
20
- Permission is hereby granted, free of charge, to any person obtaining a copy
21
- of this software and associated documentation files (the "Software"), to deal
22
- in the Software without restriction, including without limitation the rights
23
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
24
- copies of the Software, and to permit persons to whom the Software is
25
- furnished to do so, subject to the following conditions:
26
-
27
- The above copyright notice and this permission notice shall be included in all
28
- copies or substantial portions of the Software.
29
-
30
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36
- SOFTWARE.