@primeui-devkit/lit-markdown 0.1.0-beta.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/LICENSE.md +45 -0
- package/README.md +19 -0
- package/THIRD-PARTY-NOTICES.txt +36 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +1 -0
- package/package.json +53 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# PrimeUI License
|
|
2
|
+
|
|
3
|
+
This package is part of **PrimeUI**, a family of commercial UI libraries by PrimeTek Informatics.
|
|
4
|
+
|
|
5
|
+
## How PrimeUI May Be Used
|
|
6
|
+
|
|
7
|
+
PrimeUI may be used under one of two licenses. You choose the one that applies to you based on eligibility.
|
|
8
|
+
|
|
9
|
+
### Community License (Free)
|
|
10
|
+
|
|
11
|
+
Free for organizations that meet all of the following criteria:
|
|
12
|
+
|
|
13
|
+
- Less than $1,000,000 USD in annual gross revenue
|
|
14
|
+
- Fewer than 5 developers
|
|
15
|
+
- Fewer than 10 employees
|
|
16
|
+
- Less than $3,000,000 USD in venture capital or outside funding
|
|
17
|
+
|
|
18
|
+
Individuals, students, non-profits, and non-commercial open source projects also qualify.
|
|
19
|
+
|
|
20
|
+
The Community License provides full access to the core libraries and supports up to 4 developers. It requires annual renewal by confirming continued eligibility.
|
|
21
|
+
|
|
22
|
+
### Commercial License (Paid)
|
|
23
|
+
|
|
24
|
+
For organizations that do not qualify for the Community License.
|
|
25
|
+
|
|
26
|
+
Licensed per developer, perpetual, with one year of updates included. Renewal is optional and extends access to new versions. The Commercial Suite also includes PrimeBlocks, Theme Designer, all PrimeUI Pro components, and Premium Support.
|
|
27
|
+
|
|
28
|
+
## License Key
|
|
29
|
+
|
|
30
|
+
A valid license key is required to use this software. License verification is performed offline, with no telemetry and no remote connection. A missing, invalid, or expired key may cause the software to display a license notice.
|
|
31
|
+
|
|
32
|
+
## Full Terms
|
|
33
|
+
|
|
34
|
+
The complete license terms, eligibility details, and renewal information are available at:
|
|
35
|
+
|
|
36
|
+
- Community License: <https://primeui.dev/licenses/community>
|
|
37
|
+
- Commercial License: <https://primeui.dev/licenses/commercial>
|
|
38
|
+
|
|
39
|
+
## Restrictions
|
|
40
|
+
|
|
41
|
+
This software is distributed as a compiled package. You may not reverse-engineer, decompile, or extract its source code, redistribute it as a component library or development tool, or remove its license mechanisms. Redistributing the software so that third parties can develop with it requires a separate OEM License. See the full terms for details.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
© 2026 PrimeTek Informatics. All rights reserved.
|
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @primeui-devkit/lit-markdown
|
|
2
|
+
|
|
3
|
+
Lit renderer for the markdown AST. Renders into light DOM so shared prose
|
|
4
|
+
styles apply; heading anchors, code copy button and table scroll wrapper are
|
|
5
|
+
built in.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { defineLitMarkdown } from '@primeui-devkit/lit-markdown';
|
|
9
|
+
|
|
10
|
+
defineLitMarkdown(); // registers <lit-markdown>
|
|
11
|
+
|
|
12
|
+
const el = document.createElement('lit-markdown');
|
|
13
|
+
el.tree = tree; // pre-parsed MarkdownTree (or set el.markdown for runtime parse)
|
|
14
|
+
el.components = { 'demo-viewer': (props, children) => myDemoNode(props) };
|
|
15
|
+
document.body.append(el);
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The DOM rebuilds only when `tree`/`markdown`/`components` references change,
|
|
19
|
+
so stateful custom-rendered children survive unrelated updates.
|
|
@@ -0,0 +1,36 @@
|
|
|
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.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { MarkdownTree } from '@primeui-devkit/markdown-core';
|
|
2
|
+
import { ReactiveElement } from 'lit';
|
|
3
|
+
|
|
4
|
+
type MdNode = string | MdElementNode;
|
|
5
|
+
type MdElementNode = [string, Record<string, unknown>, ...MdNode[]];
|
|
6
|
+
/** A custom renderer receives the node's props and already-rendered children and returns a DOM node it owns. */
|
|
7
|
+
type LitComponentRenderer = (props: Record<string, unknown>, children: DocumentFragment, node: MdElementNode) => Node;
|
|
8
|
+
declare function renderNode(node: MdNode, components: Record<string, LitComponentRenderer>): Node;
|
|
9
|
+
declare function renderTree(tree: MarkdownTree, components?: Record<string, LitComponentRenderer>): DocumentFragment;
|
|
10
|
+
/**
|
|
11
|
+
* <lit-markdown> — renders a pre-parsed tree (or parses `markdown` at runtime).
|
|
12
|
+
* Light DOM on purpose: the shared prose.css and host styles apply directly.
|
|
13
|
+
* The DOM is rebuilt ONLY when tree/markdown/components references change, so
|
|
14
|
+
* stateful custom-rendered children survive unrelated re-renders.
|
|
15
|
+
*/
|
|
16
|
+
declare class LitMarkdown extends ReactiveElement {
|
|
17
|
+
#private;
|
|
18
|
+
static properties: {
|
|
19
|
+
tree: {
|
|
20
|
+
attribute: boolean;
|
|
21
|
+
};
|
|
22
|
+
markdown: {
|
|
23
|
+
type: StringConstructor;
|
|
24
|
+
};
|
|
25
|
+
components: {
|
|
26
|
+
attribute: boolean;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
tree: MarkdownTree | null;
|
|
30
|
+
markdown: string;
|
|
31
|
+
components: Record<string, LitComponentRenderer>;
|
|
32
|
+
constructor();
|
|
33
|
+
protected createRenderRoot(): this;
|
|
34
|
+
protected update(changed: Map<string, unknown>): void;
|
|
35
|
+
}
|
|
36
|
+
declare function defineLitMarkdown(tagName?: string): void;
|
|
37
|
+
|
|
38
|
+
export { type LitComponentRenderer, LitMarkdown, defineLitMarkdown, renderNode, renderTree };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {ReactiveElement}from'lit';var u=new Set(["h1","h2","h3","h4","h5","h6"]),f=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>',h='<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 g(n,r){for(let[e,t]of Object.entries(r))t==null||typeof t=="function"||typeof t=="object"||(typeof t=="boolean"?t&&n.setAttribute(e,""):n.setAttribute(e,String(t)));}function w(n,r,e){let t=document.createElement(n);t.className=`prose-${n}`;let c=typeof r.id=="string"?r.id:null;if(c){t.id=c;let s=document.createElement("a");s.href=`#${c}`,s.className="prose-heading-link";let o=document.createElement("span");o.className="prose-heading-anchor",o.textContent="#",s.append(o,e),t.append(s);}else t.append(e);return t}function k(n,r){let e=document.createElement("div");e.className="prose-pre";let t=typeof n.filename=="string"?n.filename:"",c=t.replace(":line-numbers","");if(c){let i=document.createElement("div");i.className="prose-pre-filename",i.innerHTML="<span></span>",i.querySelector("span").textContent=c,e.append(i);}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 i=typeof n.code=="string"?n.code:"";i&&(await navigator.clipboard.writeText(i),o.innerHTML=h,o.title="Copied",setTimeout(()=>{o.innerHTML=p,o.title="Copy Code";},2e3));}),s.append(o),e.append(s);let a=document.createElement("pre");return t.includes(":line-numbers")&&(a.className="prose-pre-line-numbers"),a.append(r),e.append(a),e}function E(n){let r=document.createElement("div");r.className="prose-table-scroll";let e=document.createElement("table");return e.className="prose-table",e.append(n),r.append(e),r}function l(n,r){if(typeof n=="string")return document.createTextNode(n);let[e,t={},...c]=n,s=document.createDocumentFragment();for(let i of c)s.append(l(i,r));let o=r[e];if(o)return o(t,s,n);if(u.has(e))return w(e,t,s);if(e==="pre")return k(t,s);if(e==="table")return E(s);let a=document.createElement(e);return g(a,t),f.has(e)&&a.classList.add(`prose-${e}`),a.append(s),a}function b(n,r={}){let e=document.createDocumentFragment();for(let t of n.nodes||[])e.append(l(t,r));return e}var d=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(t=>t.parseMarkdown(this.markdown)).then(t=>{e===this.#e&&(this.tree=t);});return}(r.has("tree")||r.has("components"))&&(this.replaceChildren(),this.tree&&(this.classList.add("prose"),this.append(b(this.tree,this.components))));}};function y(n="lit-markdown"){customElements.get(n)||customElements.define(n,d);}export{d as LitMarkdown,y as defineLitMarkdown,l as renderNode,b as renderTree};
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@primeui-devkit/lit-markdown",
|
|
3
|
+
"version": "0.1.0-beta.1",
|
|
4
|
+
"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
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"LICENSE.md",
|
|
16
|
+
"THIRD-PARTY-NOTICES.txt",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@primeui-devkit/markdown-core": "0.1.0-beta.1"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"lit": "^3.0.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"cross-env": "^10.1.0",
|
|
28
|
+
"lit": "^3.0.0",
|
|
29
|
+
"tsup": "^8.5.1",
|
|
30
|
+
"typescript": "~6.0.0",
|
|
31
|
+
"vitest": "4.1.10",
|
|
32
|
+
"@primeui-devkit/bundler": "0.0.0",
|
|
33
|
+
"@primeui-devkit/test-config": "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"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "pnpm run build:package",
|
|
47
|
+
"build:package": "pnpm run test && tsup",
|
|
48
|
+
"type:check": "tsc --noEmit",
|
|
49
|
+
"test": "cross-env NODE_ENV=test vitest run --passWithNoTests",
|
|
50
|
+
"test:watch": "vitest --watch --passWithNoTests",
|
|
51
|
+
"test:coverage": "vitest run --coverage --passWithNoTests"
|
|
52
|
+
}
|
|
53
|
+
}
|