@pathmx/core 0.5.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.md +172 -0
- package/README.md +111 -0
- package/actions/actions.ts +307 -0
- package/actions/draft.ts +105 -0
- package/actions/transaction.ts +164 -0
- package/assets.ts +149 -0
- package/authority/access.ts +820 -0
- package/authority/actors.ts +271 -0
- package/authority/agents.ts +95 -0
- package/authority/credentials.ts +144 -0
- package/authority/model.ts +71 -0
- package/authority/sharing.ts +89 -0
- package/browser-bundle.ts +61 -0
- package/canonical.ts +41 -0
- package/cli/dev.ts +134 -0
- package/cli/export.ts +74 -0
- package/cli/index.ts +52 -0
- package/cli/lint.ts +164 -0
- package/cli/mv.ts +30 -0
- package/cli/perms.ts +182 -0
- package/cli/plugin-packages.ts +159 -0
- package/cli/plugins.ts +95 -0
- package/cli/query.ts +225 -0
- package/cli/readme.md +95 -0
- package/cli/release.ts +75 -0
- package/cli/rm.ts +22 -0
- package/cli/serve.ts +100 -0
- package/cli/tree.ts +131 -0
- package/cli/update.ts +78 -0
- package/cli/utils.ts +53 -0
- package/core.ts +96 -0
- package/database.ts +189 -0
- package/dependencies.ts +60 -0
- package/dist/pathmx.js +1224 -0
- package/document.ts +194 -0
- package/environment.ts +110 -0
- package/environments/bun-plugins.ts +68 -0
- package/environments/bun-publish.ts +194 -0
- package/environments/bun.ts +223 -0
- package/globals.d.ts +14 -0
- package/graph.ts +153 -0
- package/host/compiler.ts +314 -0
- package/host/create.ts +66 -0
- package/host/engine.ts +630 -0
- package/host/plugin-host.ts +487 -0
- package/host/render.ts +102 -0
- package/host/response.ts +20 -0
- package/host/shell.html +15 -0
- package/host/source-sync.ts +254 -0
- package/html-attributes.ts +15 -0
- package/html.ts +48 -0
- package/icons/LICENSE +43 -0
- package/icons/lucide.ts +54 -0
- package/index.ts +75 -0
- package/invalidation.ts +85 -0
- package/log.ts +84 -0
- package/ops/href.ts +87 -0
- package/ops/index.ts +9 -0
- package/ops/move-source.ts +114 -0
- package/ops/plan.ts +47 -0
- package/ops/remove-source.ts +70 -0
- package/package.json +46 -0
- package/path.ts +75 -0
- package/pattern.ts +314 -0
- package/perf.ts +88 -0
- package/plugins/actor-path.ts +43 -0
- package/plugins/actor-profile.ts +55 -0
- package/plugins/agent-browsing.ts +183 -0
- package/plugins/app-component.ts +23 -0
- package/plugins/block-layout/index.ts +78 -0
- package/plugins/block-layout/theme.css +90 -0
- package/plugins/callout/index.ts +236 -0
- package/plugins/callout/theme.css +138 -0
- package/plugins/canonical-links.ts +144 -0
- package/plugins/code-highlight/client.ts +89 -0
- package/plugins/code-highlight/index.ts +147 -0
- package/plugins/code-highlight/theme.css +89 -0
- package/plugins/context.ts +131 -0
- package/plugins/datatype/Datatype[wdth,wght].woff2 +0 -0
- package/plugins/datatype/OFL.txt +96 -0
- package/plugins/datatype/index.ts +287 -0
- package/plugins/definition-list.ts +236 -0
- package/plugins/directive-definitions.ts +13 -0
- package/plugins/embedding/client.ts +88 -0
- package/plugins/embedding/index.ts +43 -0
- package/plugins/image/index.ts +68 -0
- package/plugins/image/theme.css +43 -0
- package/plugins/include.ts +119 -0
- package/plugins/index.ts +91 -0
- package/plugins/input/authoring.ts +236 -0
- package/plugins/input/config.ts +85 -0
- package/plugins/input/index.ts +359 -0
- package/plugins/input/model.ts +173 -0
- package/plugins/input/state.ts +272 -0
- package/plugins/layout.ts +313 -0
- package/plugins/literate/client.ts +208 -0
- package/plugins/literate/index.ts +742 -0
- package/plugins/math/index.ts +140 -0
- package/plugins/meta.ts +42 -0
- package/plugins/navigation/index.ts +158 -0
- package/plugins/navigation/model.ts +364 -0
- package/plugins/preset.ts +65 -0
- package/plugins/query/index.ts +322 -0
- package/plugins/rss/index.ts +46 -0
- package/plugins/runtime/actions.ts +62 -0
- package/plugins/runtime/client.ts +8 -0
- package/plugins/runtime/document.ts +506 -0
- package/plugins/runtime/error.ts +154 -0
- package/plugins/runtime/heading-links.ts +31 -0
- package/plugins/runtime/index.ts +104 -0
- package/plugins/runtime/live.ts +51 -0
- package/plugins/runtime/navigation.ts +113 -0
- package/plugins/runtime/pending.ts +53 -0
- package/plugins/runtime/publication.ts +19 -0
- package/plugins/runtime/start.ts +177 -0
- package/plugins/runtime/static-client.ts +6 -0
- package/plugins/runtime/static-live.ts +188 -0
- package/plugins/runtime/view-transition.ts +72 -0
- package/plugins/runtime/viewport.ts +110 -0
- package/plugins/schema.ts +24 -0
- package/plugins/scripts.ts +140 -0
- package/plugins/source-preview/client.ts +256 -0
- package/plugins/source-preview/index.ts +132 -0
- package/plugins/source-preview/model.ts +11 -0
- package/plugins/source-preview/preview.css +107 -0
- package/plugins/styles.ts +145 -0
- package/plugins/theme/components.ts +10 -0
- package/plugins/theme/foundation.css +358 -0
- package/plugins/theme/index.ts +333 -0
- package/plugins/theme/prose.css +284 -0
- package/plugins/theme/scheme.js +63 -0
- package/plugins/theme/toggle.css +44 -0
- package/plugins/theme/view-transition.css +68 -0
- package/plugins/toc/client.ts +146 -0
- package/plugins/toc/index.ts +232 -0
- package/plugins/toc/theme.css +172 -0
- package/plugins/types.ts +538 -0
- package/problem.ts +41 -0
- package/project.ts +6 -0
- package/publish/build.ts +402 -0
- package/publish/concurrent.ts +32 -0
- package/publish/identity.ts +63 -0
- package/publish/index.ts +11 -0
- package/publish/location.ts +167 -0
- package/publish/model.ts +58 -0
- package/publish/plan.ts +300 -0
- package/publish/validate.ts +150 -0
- package/query/candidate-index.ts +101 -0
- package/query/dependency-index.ts +99 -0
- package/query/fields.ts +216 -0
- package/query/invalidation.ts +48 -0
- package/query/kernel.ts +776 -0
- package/query/model.ts +79 -0
- package/repository.ts +374 -0
- package/runtime-profile.ts +34 -0
- package/schema/model.ts +92 -0
- package/schema/registry.ts +642 -0
- package/schema/standard.ts +226 -0
- package/server/context.ts +94 -0
- package/server/css-imports.ts +66 -0
- package/server/http.ts +333 -0
- package/server/page.ts +21 -0
- package/server/protocols.ts +12 -0
- package/server/representations.ts +66 -0
- package/server/router.ts +131 -0
- package/server/routes.ts +202 -0
- package/server/serve.ts +5 -0
- package/server/watch.ts +120 -0
- package/source/blocks.ts +71 -0
- package/source/format.ts +164 -0
- package/source/index.ts +67 -0
- package/source/interpolate.ts +63 -0
- package/source/markdown/blocks.ts +46 -0
- package/source/markdown/comments.ts +32 -0
- package/source/markdown/fences.ts +67 -0
- package/source/markdown/headings.ts +88 -0
- package/source/markdown/index.ts +34 -0
- package/source/markdown/inline-code.ts +6 -0
- package/source/markdown/links.ts +326 -0
- package/source/markdown/lists.ts +223 -0
- package/source/markdown/prose.ts +74 -0
- package/source/markdown/scan.ts +79 -0
- package/source/markdown/text.ts +82 -0
- package/source/meta.ts +87 -0
- package/source/source.ts +121 -0
- package/source/topmatter.ts +57 -0
- package/source/utils.ts +21 -0
- package/source-diagnostic.ts +63 -0
- package/text-file.ts +26 -0
- package/util.ts +35 -0
- package/view/components.ts +499 -0
- package/view/model.ts +91 -0
- package/view/projection.ts +162 -0
- package/view/session.ts +146 -0
- package/view/syntax.ts +372 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import "./theme.css"
|
|
2
|
+
import { checkIconSvg } from "../../icons/lucide.ts"
|
|
3
|
+
|
|
4
|
+
const RESET_MS = 2000
|
|
5
|
+
const timers = new WeakMap<Element, ReturnType<typeof setTimeout>>()
|
|
6
|
+
const idleIcons = new WeakMap<Element, string>()
|
|
7
|
+
|
|
8
|
+
function readCode(block: Element) {
|
|
9
|
+
const code = block.querySelector("pre code") ?? block.querySelector("pre")
|
|
10
|
+
let text = code?.textContent ?? ""
|
|
11
|
+
if (text.endsWith("\n")) text = text.slice(0, -1)
|
|
12
|
+
return text
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function execCommandCopy(text: string) {
|
|
16
|
+
const body = document.body
|
|
17
|
+
if (!body || typeof document.execCommand !== "function") return false
|
|
18
|
+
const area = document.createElement("textarea")
|
|
19
|
+
area.value = text
|
|
20
|
+
area.setAttribute("readonly", "")
|
|
21
|
+
area.style.position = "fixed"
|
|
22
|
+
area.style.opacity = "0"
|
|
23
|
+
body.appendChild(area)
|
|
24
|
+
let ok = false
|
|
25
|
+
try {
|
|
26
|
+
area.select()
|
|
27
|
+
ok = document.execCommand("copy")
|
|
28
|
+
} catch {
|
|
29
|
+
ok = false
|
|
30
|
+
}
|
|
31
|
+
body.removeChild(area)
|
|
32
|
+
return ok
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function copy(text: string) {
|
|
36
|
+
if (navigator.clipboard?.writeText) {
|
|
37
|
+
try {
|
|
38
|
+
await navigator.clipboard.writeText(text)
|
|
39
|
+
return true
|
|
40
|
+
} catch {
|
|
41
|
+
return execCommandCopy(text)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return execCommandCopy(text)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function showCopied(button: Element) {
|
|
48
|
+
let copyIcon = idleIcons.get(button)
|
|
49
|
+
if (!copyIcon) {
|
|
50
|
+
copyIcon = button.innerHTML
|
|
51
|
+
idleIcons.set(button, copyIcon)
|
|
52
|
+
}
|
|
53
|
+
button.innerHTML = checkIconSvg
|
|
54
|
+
button.classList.add("is-copied")
|
|
55
|
+
button.setAttribute("aria-label", "Copied")
|
|
56
|
+
const existing = timers.get(button)
|
|
57
|
+
if (existing) clearTimeout(existing)
|
|
58
|
+
timers.set(
|
|
59
|
+
button,
|
|
60
|
+
setTimeout(() => {
|
|
61
|
+
button.classList.remove("is-copied")
|
|
62
|
+
button.setAttribute("aria-label", "Copy code")
|
|
63
|
+
if (copyIcon) button.innerHTML = copyIcon
|
|
64
|
+
timers.delete(button)
|
|
65
|
+
}, RESET_MS),
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
declare global {
|
|
70
|
+
interface Window {
|
|
71
|
+
__pathmxCodeCopyInstalled?: boolean
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (!window.__pathmxCodeCopyInstalled) {
|
|
76
|
+
window.__pathmxCodeCopyInstalled = true
|
|
77
|
+
document.addEventListener("click", (event) => {
|
|
78
|
+
const target = event.target
|
|
79
|
+
if (!(target instanceof Element)) return
|
|
80
|
+
const button = target.closest(".pmx-code-copy")
|
|
81
|
+
const block = button?.closest(".pmx-code-block")
|
|
82
|
+
if (!button || !block) return
|
|
83
|
+
const text = readCode(block)
|
|
84
|
+
if (!text) return
|
|
85
|
+
void copy(text).then((ok) => {
|
|
86
|
+
if (ok) showCopied(button)
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import hljs from "highlight.js/lib/common"
|
|
2
|
+
import { isFenceClose, matchFenceOpen } from "../../source/index.ts"
|
|
3
|
+
import { decodeHtmlEntities, escapeHtml } from "../../util.ts"
|
|
4
|
+
import type { CompileContext, Plugin } from "../types.ts"
|
|
5
|
+
import { copyIconSvg } from "../../icons/lucide.ts"
|
|
6
|
+
|
|
7
|
+
type FenceMeta = {
|
|
8
|
+
noCopy: boolean
|
|
9
|
+
noSelect: boolean
|
|
10
|
+
steps?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const CODE_META_FLAGS = new Set(["no-copy", "no-select"])
|
|
14
|
+
const CODE_BLOCK = /<pre><code([^>]*)>([\s\S]*?)<\/code><\/pre>/g
|
|
15
|
+
const LANGUAGE = /\blanguage-([^"'\s]+)/
|
|
16
|
+
const PLAIN = new Set(["plain", "plaintext", "text"])
|
|
17
|
+
const CODE_STEPS = /^\[(\d+(?:-\d+)?(?:\|\d+(?:-\d+)?)*)\]$/
|
|
18
|
+
|
|
19
|
+
const clientEntry = new URL("./client.ts", import.meta.url)
|
|
20
|
+
|
|
21
|
+
function parseCodeInfo(info: string) {
|
|
22
|
+
const tokens = info.trim().split(/\s+/).filter(Boolean)
|
|
23
|
+
const lang = tokens[0]?.toLowerCase() ?? ""
|
|
24
|
+
const rest = tokens.slice(1)
|
|
25
|
+
const steps = rest
|
|
26
|
+
.find((token) => CODE_STEPS.test(token))
|
|
27
|
+
?.match(CODE_STEPS)?.[1]
|
|
28
|
+
return {
|
|
29
|
+
lang,
|
|
30
|
+
meta: {
|
|
31
|
+
noCopy: rest.includes("no-copy"),
|
|
32
|
+
noSelect: rest.includes("no-select"),
|
|
33
|
+
...(steps ? { steps } : {}),
|
|
34
|
+
} satisfies FenceMeta,
|
|
35
|
+
nextInfo: [
|
|
36
|
+
...tokens.slice(0, 1),
|
|
37
|
+
...rest.filter(
|
|
38
|
+
(token) => !CODE_META_FLAGS.has(token) && !CODE_STEPS.test(token),
|
|
39
|
+
),
|
|
40
|
+
].join(" "),
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function stripCodeFenceFlags(markdown: string) {
|
|
45
|
+
const lines = markdown.split(/\r?\n/)
|
|
46
|
+
const metaByFence: FenceMeta[] = []
|
|
47
|
+
let marker: string | undefined
|
|
48
|
+
|
|
49
|
+
for (let index = 0; index < lines.length; index++) {
|
|
50
|
+
const line = lines[index] ?? ""
|
|
51
|
+
if (marker) {
|
|
52
|
+
if (isFenceClose(line, marker)) marker = undefined
|
|
53
|
+
continue
|
|
54
|
+
}
|
|
55
|
+
const fence = matchFenceOpen(line)
|
|
56
|
+
if (!fence) continue
|
|
57
|
+
const parsed = parseCodeInfo(fence.info)
|
|
58
|
+
metaByFence.push(parsed.meta)
|
|
59
|
+
lines[index] = `${fence.indent}${fence.marker}${parsed.nextInfo}`
|
|
60
|
+
marker = fence.marker
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return { markdown: lines.join("\n"), metaByFence }
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function indexedFenceMeta(markdown: string, ctx: CompileContext) {
|
|
67
|
+
const authored = ctx.block?.body ?? ctx.source.body
|
|
68
|
+
if (markdown !== authored) return
|
|
69
|
+
return (ctx.block?.fences ?? ctx.source.fences).map(
|
|
70
|
+
(fence) => parseCodeInfo(fence.info).meta,
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function isPlainLanguage(lang: string) {
|
|
75
|
+
return PLAIN.has(lang.toLowerCase())
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function wrapCodeBlock(html: string, meta: FenceMeta) {
|
|
79
|
+
const attrs = [`class="pmx-code-block"`]
|
|
80
|
+
if (meta.noSelect) attrs.push(`data-code-select="false"`)
|
|
81
|
+
if (meta.steps) attrs.push(`data-pmx-code-steps="${escapeHtml(meta.steps)}"`)
|
|
82
|
+
const copyButton = meta.noCopy
|
|
83
|
+
? ""
|
|
84
|
+
: `<button class="pmx-code-copy" aria-label="Copy code">${copyIconSvg}</button>`
|
|
85
|
+
return `<div ${attrs.join(" ")}>${copyButton}${html}</div>`
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function highlightBlock(attrs: string, body: string) {
|
|
89
|
+
const lang = (attrs.match(LANGUAGE)?.[1] ?? "").toLowerCase()
|
|
90
|
+
if (!lang || isPlainLanguage(lang) || !hljs.getLanguage(lang)) {
|
|
91
|
+
return `<pre><code${attrs}>${body}</code></pre>`
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
const highlighted = hljs.highlight(decodeHtmlEntities(body), {
|
|
95
|
+
language: lang,
|
|
96
|
+
ignoreIllegals: true,
|
|
97
|
+
}).value
|
|
98
|
+
return `<pre><code class="hljs language-${escapeHtml(lang)}">${highlighted}</code></pre>`
|
|
99
|
+
} catch {
|
|
100
|
+
return `<pre><code${attrs}>${body}</code></pre>`
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function CodeHighlightPlugin(): Plugin {
|
|
105
|
+
const metaByContext = new WeakMap<CompileContext, FenceMeta[]>()
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
id: "code-highlight",
|
|
109
|
+
precompile(markdown, ctx) {
|
|
110
|
+
const indexed = indexedFenceMeta(markdown, ctx)
|
|
111
|
+
if (indexed) {
|
|
112
|
+
metaByContext.set(ctx, indexed)
|
|
113
|
+
if (
|
|
114
|
+
!indexed.some((meta) => meta.noCopy || meta.noSelect || meta.steps)
|
|
115
|
+
) {
|
|
116
|
+
return markdown
|
|
117
|
+
}
|
|
118
|
+
} else if (!markdown.includes("```") && !markdown.includes("~~~")) {
|
|
119
|
+
metaByContext.set(ctx, [])
|
|
120
|
+
return markdown
|
|
121
|
+
}
|
|
122
|
+
const parsed = stripCodeFenceFlags(markdown)
|
|
123
|
+
metaByContext.set(ctx, parsed.metaByFence)
|
|
124
|
+
return parsed.markdown
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
postcompile(html, ctx) {
|
|
128
|
+
if (!html.includes("<pre><code")) return html
|
|
129
|
+
const metaByFence = metaByContext.get(ctx) ?? []
|
|
130
|
+
let fenceIndex = 0
|
|
131
|
+
return html.replace(CODE_BLOCK, (match, attrs: string, body: string) => {
|
|
132
|
+
if (/\bhljs\b/.test(attrs)) return match
|
|
133
|
+
const meta = metaByFence[fenceIndex++] ?? {
|
|
134
|
+
noCopy: false,
|
|
135
|
+
noSelect: false,
|
|
136
|
+
}
|
|
137
|
+
return wrapCodeBlock(highlightBlock(attrs, body), meta)
|
|
138
|
+
})
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
async page(html, ctx) {
|
|
142
|
+
if (!html.includes("pmx-code-block")) return html
|
|
143
|
+
await ctx.addBrowserBundle(clientEntry, "code-highlight")
|
|
144
|
+
return html
|
|
145
|
+
},
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
.pmx-code-block {
|
|
2
|
+
position: relative;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.pmx-code-block pre {
|
|
6
|
+
margin: 0;
|
|
7
|
+
overflow: auto;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.pmx-code-block code {
|
|
11
|
+
display: block;
|
|
12
|
+
padding: 1rem 1.25rem;
|
|
13
|
+
font-family: var(--pmx-font-mono);
|
|
14
|
+
font-size: 0.875rem;
|
|
15
|
+
line-height: 1.5;
|
|
16
|
+
overflow-x: auto;
|
|
17
|
+
color: var(--pmx-code-fg);
|
|
18
|
+
background: var(--pmx-code-bg);
|
|
19
|
+
border-radius: var(--pmx-radius-lg);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.pmx-code-block[data-code-select="false"] {
|
|
23
|
+
user-select: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.pmx-code-copy {
|
|
27
|
+
position: absolute;
|
|
28
|
+
top: 0.5rem;
|
|
29
|
+
right: 0.5rem;
|
|
30
|
+
display: inline-flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
justify-content: center;
|
|
33
|
+
width: 1.75rem;
|
|
34
|
+
height: 1.75rem;
|
|
35
|
+
padding: 0;
|
|
36
|
+
border: 0;
|
|
37
|
+
border-radius: 0.35rem;
|
|
38
|
+
background: transparent;
|
|
39
|
+
color: inherit;
|
|
40
|
+
opacity: 0.55;
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.pmx-code-copy:hover,
|
|
45
|
+
.pmx-code-copy:focus-visible,
|
|
46
|
+
.pmx-code-copy.is-copied {
|
|
47
|
+
opacity: 1;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.hljs-comment,
|
|
51
|
+
.hljs-quote,
|
|
52
|
+
.hljs-meta {
|
|
53
|
+
color: var(--pmx-code-comment);
|
|
54
|
+
}
|
|
55
|
+
.hljs-keyword,
|
|
56
|
+
.hljs-selector-tag,
|
|
57
|
+
.hljs-deletion {
|
|
58
|
+
color: var(--pmx-code-keyword);
|
|
59
|
+
}
|
|
60
|
+
.hljs-string,
|
|
61
|
+
.hljs-addition,
|
|
62
|
+
.hljs-attr,
|
|
63
|
+
.hljs-attribute,
|
|
64
|
+
.hljs-link {
|
|
65
|
+
color: var(--pmx-code-string);
|
|
66
|
+
}
|
|
67
|
+
.hljs-number,
|
|
68
|
+
.hljs-literal,
|
|
69
|
+
.hljs-variable,
|
|
70
|
+
.hljs-template-variable,
|
|
71
|
+
.hljs-title,
|
|
72
|
+
.hljs-section,
|
|
73
|
+
.hljs-selector-id,
|
|
74
|
+
.hljs-built_in,
|
|
75
|
+
.hljs-type,
|
|
76
|
+
.hljs-symbol,
|
|
77
|
+
.hljs-bullet,
|
|
78
|
+
.hljs-name,
|
|
79
|
+
.hljs-tag,
|
|
80
|
+
.hljs-selector-class,
|
|
81
|
+
.hljs-punctuation {
|
|
82
|
+
color: var(--pmx-code-punctuation);
|
|
83
|
+
}
|
|
84
|
+
.hljs-emphasis {
|
|
85
|
+
font-style: italic;
|
|
86
|
+
}
|
|
87
|
+
.hljs-strong {
|
|
88
|
+
font-weight: 700;
|
|
89
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import type { Engine } from "../host/engine.ts"
|
|
2
|
+
import type { Log } from "../log.ts"
|
|
3
|
+
import type { SqlDatabase } from "../database.ts"
|
|
4
|
+
import type { Source, SourceBlock } from "../source/index.ts"
|
|
5
|
+
import type { DependencyContext } from "../dependencies.ts"
|
|
6
|
+
import type { HtmlRewriteRule } from "../environment.ts"
|
|
7
|
+
import type { Principal } from "../authority/model.ts"
|
|
8
|
+
import type { QueryRequest } from "../query/model.ts"
|
|
9
|
+
import type { SourceCapability } from "../authority/access.ts"
|
|
10
|
+
import { SourceDiagnosticError } from "../source-diagnostic.ts"
|
|
11
|
+
import type {
|
|
12
|
+
AppContext,
|
|
13
|
+
PluginContext,
|
|
14
|
+
PluginLog,
|
|
15
|
+
ServerGraph,
|
|
16
|
+
} from "./types.ts"
|
|
17
|
+
|
|
18
|
+
export function createPluginLog(log: Log, plugin: string): PluginLog {
|
|
19
|
+
const write =
|
|
20
|
+
(level: "debug" | "info" | "warn" | "error") =>
|
|
21
|
+
(message: string, context?: Record<string, unknown>) =>
|
|
22
|
+
log[level](`${plugin}.${message}`, context)
|
|
23
|
+
return Object.freeze({
|
|
24
|
+
debug: write("debug"),
|
|
25
|
+
info: write("info"),
|
|
26
|
+
warn: write("warn"),
|
|
27
|
+
error: write("error"),
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function graphContext(engine: Engine): ServerGraph {
|
|
32
|
+
return Object.freeze({
|
|
33
|
+
linksFrom: (path: string) => [...engine.graph.linksFrom(path)],
|
|
34
|
+
linksTo: (path: string) => [...engine.graph.linksTo(path)],
|
|
35
|
+
neighbors: (path: string) => engine.graph.neighbors(path),
|
|
36
|
+
backlinks: (path: string) => engine.graph.backlinks(path),
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function source(engine: Engine, idOrPath: string) {
|
|
41
|
+
return (
|
|
42
|
+
engine.resolve(idOrPath) ??
|
|
43
|
+
engine.repo.get(idOrPath) ??
|
|
44
|
+
engine.repo.atPath(idOrPath)
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** @internal Bind one Plugin's lifecycle resources to an Engine. */
|
|
49
|
+
export function createPluginContext(
|
|
50
|
+
plugin: string,
|
|
51
|
+
engine: Engine,
|
|
52
|
+
database?: SqlDatabase,
|
|
53
|
+
): PluginContext {
|
|
54
|
+
return Object.freeze({
|
|
55
|
+
plugin,
|
|
56
|
+
log: createPluginLog(engine.log, plugin),
|
|
57
|
+
runtime: engine.runtime,
|
|
58
|
+
database,
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** @internal Add request-independent application capabilities after setup. */
|
|
63
|
+
export function createAppContext(
|
|
64
|
+
context: PluginContext,
|
|
65
|
+
engine: Engine,
|
|
66
|
+
components: AppContext["components"],
|
|
67
|
+
): AppContext {
|
|
68
|
+
return Object.freeze({
|
|
69
|
+
...context,
|
|
70
|
+
schema: engine.schema,
|
|
71
|
+
query: Object.freeze({
|
|
72
|
+
prepare: (query: string, request?: QueryRequest<unknown>) =>
|
|
73
|
+
engine.queries.prepare(query, request),
|
|
74
|
+
}),
|
|
75
|
+
yaml: engine.environment.yaml,
|
|
76
|
+
sources: Object.freeze({
|
|
77
|
+
get: (idOrPath: string) => source(engine, idOrPath),
|
|
78
|
+
all: () => engine.repo.all(),
|
|
79
|
+
resolve: (pathname: string) => engine.resolve(pathname),
|
|
80
|
+
path: (value: string) => engine.repo.graphPath(value),
|
|
81
|
+
isPage: (candidate: Source) => engine.isPage(candidate),
|
|
82
|
+
builtPages: () => [...engine.pageCache.values()],
|
|
83
|
+
}),
|
|
84
|
+
graph: graphContext(engine),
|
|
85
|
+
actors: Object.freeze({
|
|
86
|
+
profile: (actorId: string) => engine.profiles.findById(actorId)?.profile,
|
|
87
|
+
homeActorId: (path: string) => engine.homeActorId(path),
|
|
88
|
+
}),
|
|
89
|
+
access: Object.freeze({
|
|
90
|
+
read: (principal: Principal, target: Source | string) =>
|
|
91
|
+
engine.readAccess(principal, target),
|
|
92
|
+
can: (
|
|
93
|
+
principal: Principal,
|
|
94
|
+
target: Source | string,
|
|
95
|
+
capability: SourceCapability,
|
|
96
|
+
) => engine.hasSourceCapability(principal, target, capability),
|
|
97
|
+
canEmbed: (container: string, dependency: string) =>
|
|
98
|
+
engine.canEmbed(container, dependency),
|
|
99
|
+
}),
|
|
100
|
+
assets: Object.freeze({
|
|
101
|
+
load: (url: URL) => engine.environment.loadAsset(url),
|
|
102
|
+
publish: (name: string, blob: Blob, contentType?: string) =>
|
|
103
|
+
engine.publishAsset(name, blob, contentType),
|
|
104
|
+
}),
|
|
105
|
+
html: Object.freeze({
|
|
106
|
+
rewrite: (html: string, rules: readonly HtmlRewriteRule[]) =>
|
|
107
|
+
engine.environment.rewriteHtml(html, rules),
|
|
108
|
+
}),
|
|
109
|
+
compile: Object.freeze({
|
|
110
|
+
block: (
|
|
111
|
+
source: Source,
|
|
112
|
+
block: SourceBlock,
|
|
113
|
+
dependencies?: DependencyContext,
|
|
114
|
+
options?: { id?: string },
|
|
115
|
+
) =>
|
|
116
|
+
engine.compileBlock(source, block, dependencies, options, "embedded"),
|
|
117
|
+
document: (source: Source, dependencies: DependencyContext) =>
|
|
118
|
+
engine.compileDocument(source, dependencies, context.plugin),
|
|
119
|
+
}),
|
|
120
|
+
components,
|
|
121
|
+
diagnostics: Object.freeze({
|
|
122
|
+
invalid(source: Source, message: string): never {
|
|
123
|
+
throw new SourceDiagnosticError({
|
|
124
|
+
source: source.path,
|
|
125
|
+
plugin: context.plugin,
|
|
126
|
+
message,
|
|
127
|
+
})
|
|
128
|
+
},
|
|
129
|
+
}),
|
|
130
|
+
})
|
|
131
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
Copyright 2026 The Datatype Project Authors (https://github.com/franktisellano/datatype)
|
|
2
|
+
|
|
3
|
+
This font includes glyphs from IBM Plex™ Mono:
|
|
4
|
+
Copyright 2017 IBM Corp. with Reserved Font Name "Plex"
|
|
5
|
+
|
|
6
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
7
|
+
This license is copied below, and is also available with a FAQ at:
|
|
8
|
+
https://openfontlicense.org
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
-----------------------------------------------------------
|
|
12
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
13
|
+
-----------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
PREAMBLE
|
|
16
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
17
|
+
development of collaborative font projects, to support the font creation
|
|
18
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
19
|
+
open framework in which fonts may be shared and improved in partnership
|
|
20
|
+
with others.
|
|
21
|
+
|
|
22
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
23
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
24
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
25
|
+
redistributed and/or sold with any software provided that any reserved
|
|
26
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
27
|
+
however, cannot be released under any other type of license. The
|
|
28
|
+
requirement for fonts to remain under this license does not apply
|
|
29
|
+
to any document created using the fonts or their derivatives.
|
|
30
|
+
|
|
31
|
+
DEFINITIONS
|
|
32
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
33
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
34
|
+
include source files, build scripts and documentation.
|
|
35
|
+
|
|
36
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
37
|
+
copyright statement(s).
|
|
38
|
+
|
|
39
|
+
"Original Version" refers to the collection of Font Software components as
|
|
40
|
+
distributed by the Copyright Holder(s).
|
|
41
|
+
|
|
42
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
43
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
44
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
45
|
+
new environment.
|
|
46
|
+
|
|
47
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
48
|
+
writer or other person who contributed to the Font Software.
|
|
49
|
+
|
|
50
|
+
PERMISSION & CONDITIONS
|
|
51
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
52
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
53
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
54
|
+
Software, subject to the following conditions:
|
|
55
|
+
|
|
56
|
+
1) Neither the Font Software nor any of its individual components,
|
|
57
|
+
in Original or Modified Versions, may be sold by itself.
|
|
58
|
+
|
|
59
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
60
|
+
redistributed and/or sold with any software, provided that each copy
|
|
61
|
+
contains the above copyright notice and this license. These can be
|
|
62
|
+
included either as stand-alone text files, human-readable headers or
|
|
63
|
+
in the appropriate machine-readable metadata fields within text or
|
|
64
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
65
|
+
|
|
66
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
67
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
68
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
69
|
+
presented to the users.
|
|
70
|
+
|
|
71
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
72
|
+
Software shall not be used to promote, endorse or advertise any
|
|
73
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
74
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
75
|
+
permission.
|
|
76
|
+
|
|
77
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
78
|
+
must be distributed entirely under this license, and must not be
|
|
79
|
+
distributed under any other license. The requirement for fonts to
|
|
80
|
+
remain under this license does not apply to any document created
|
|
81
|
+
using the Font Software.
|
|
82
|
+
|
|
83
|
+
TERMINATION
|
|
84
|
+
This license becomes null and void if any of the above conditions are
|
|
85
|
+
not met.
|
|
86
|
+
|
|
87
|
+
DISCLAIMER
|
|
88
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
89
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
90
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
91
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
92
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
93
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
94
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
95
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
96
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|