@markii/host 0.0.0-stage → 0.17.0-next.2

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.
Files changed (193) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +19 -2
  3. package/dist/browser-worker.js +639 -0
  4. package/dist/browser.d.ts +57 -0
  5. package/dist/browser.js +167 -0
  6. package/dist/conformance/host/01-plain-open/expected.json +5 -0
  7. package/dist/conformance/host/01-plain-open/note.mk.md +8 -0
  8. package/dist/conformance/host/01-plain-open/scenario.json +6 -0
  9. package/dist/conformance/host/02-run-manual-grant-accepted/expected.json +16 -0
  10. package/dist/conformance/host/02-run-manual-grant-accepted/note.mk.md +5 -0
  11. package/dist/conformance/host/02-run-manual-grant-accepted/scenario.json +14 -0
  12. package/dist/conformance/host/03-run-manual-grant-refused/expected.json +18 -0
  13. package/dist/conformance/host/03-run-manual-grant-refused/note.mk.md +5 -0
  14. package/dist/conformance/host/03-run-manual-grant-refused/scenario.json +14 -0
  15. package/dist/conformance/host/04-run-auto-write-denied/expected.json +16 -0
  16. package/dist/conformance/host/04-run-auto-write-denied/note.mk.md +10 -0
  17. package/dist/conformance/host/04-run-auto-write-denied/scenario.json +13 -0
  18. package/dist/conformance/host/05-export-html-pack-directive/expected.json +14 -0
  19. package/dist/conformance/host/05-export-html-pack-directive/note.mk.md +8 -0
  20. package/dist/conformance/host/05-export-html-pack-directive/scenario.json +6 -0
  21. package/dist/conformance/host/06-install-pack-then-render/expected.json +18 -0
  22. package/dist/conformance/host/06-install-pack-then-render/files/ana-1.0.0/pack.json +13 -0
  23. package/dist/conformance/host/06-install-pack-then-render/files/ana-1.0.0/webview.js +1 -0
  24. package/dist/conformance/host/06-install-pack-then-render/note.mk.md +5 -0
  25. package/dist/conformance/host/06-install-pack-then-render/scenario.json +15 -0
  26. package/dist/conformance/host/07-complete-in-directive/expected.json +14 -0
  27. package/dist/conformance/host/07-complete-in-directive/note.mk.md +3 -0
  28. package/dist/conformance/host/07-complete-in-directive/scenario.json +6 -0
  29. package/dist/conformance/host/08-hover-standard-component/expected.json +5 -0
  30. package/dist/conformance/host/08-hover-standard-component/note.mk.md +5 -0
  31. package/dist/conformance/host/08-hover-standard-component/scenario.json +6 -0
  32. package/dist/conformance/host/09-insert-skeleton/expected.json +5 -0
  33. package/dist/conformance/host/09-insert-skeleton/note.mk.md +4 -0
  34. package/dist/conformance/host/09-insert-skeleton/scenario.json +6 -0
  35. package/dist/conformance/host/10-scripts-disabled/expected.json +11 -0
  36. package/dist/conformance/host/10-scripts-disabled/note.mk.md +5 -0
  37. package/dist/conformance/host/10-scripts-disabled/scenario.json +9 -0
  38. package/dist/conformance/host/11-complete-closing-fence/expected.json +5 -0
  39. package/dist/conformance/host/11-complete-closing-fence/note.mk.md +5 -0
  40. package/dist/conformance/host/11-complete-closing-fence/scenario.json +12 -0
  41. package/dist/conformance/host/12-complete-nested-container/expected.json +5 -0
  42. package/dist/conformance/host/12-complete-nested-container/note.mk.md +5 -0
  43. package/dist/conformance/host/12-complete-nested-container/scenario.json +12 -0
  44. package/dist/conformance/host/13-install-pack-declined/expected.json +12 -0
  45. package/dist/conformance/host/13-install-pack-declined/files/ana-1.0.0/pack.json +13 -0
  46. package/dist/conformance/host/13-install-pack-declined/files/ana-1.0.0/webview.js +1 -0
  47. package/dist/conformance/host/13-install-pack-declined/note.mk.md +5 -0
  48. package/dist/conformance/host/13-install-pack-declined/scenario.json +10 -0
  49. package/dist/conformance/host/14-remove-pack/expected.json +14 -0
  50. package/dist/conformance/host/14-remove-pack/files/ana-1.0.0/pack.json +13 -0
  51. package/dist/conformance/host/14-remove-pack/files/ana-1.0.0/webview.js +1 -0
  52. package/dist/conformance/host/14-remove-pack/note.mk.md +5 -0
  53. package/dist/conformance/host/14-remove-pack/scenario.json +11 -0
  54. package/dist/conformance/host/15-load-packs-engine-views/expected.json +19 -0
  55. package/dist/conformance/host/15-load-packs-engine-views/files/duo-1.0.0/pack.json +9 -0
  56. package/dist/conformance/host/15-load-packs-engine-views/files/duo-1.0.0/webview.js +1 -0
  57. package/dist/conformance/host/15-load-packs-engine-views/note.mk.md +9 -0
  58. package/dist/conformance/host/15-load-packs-engine-views/scenario.json +10 -0
  59. package/dist/conformance/host/16-pack-trust/expected.json +37 -0
  60. package/dist/conformance/host/16-pack-trust/files/ana-1.0.0/pack.json +12 -0
  61. package/dist/conformance/host/16-pack-trust/files/ana-1.0.0/webview.js +1 -0
  62. package/dist/conformance/host/16-pack-trust/files/sneaky-1.0.0/pack.json +12 -0
  63. package/dist/conformance/host/16-pack-trust/files/sneaky-1.0.0/webview.js +1 -0
  64. package/dist/conformance/host/16-pack-trust/note.mk.md +5 -0
  65. package/dist/conformance/host/16-pack-trust/scenario.json +26 -0
  66. package/dist/conformance/host/README.md +221 -0
  67. package/dist/conformance.d.ts +2 -0
  68. package/dist/conformance.js +5 -0
  69. package/dist/diagnostics/render-diagnostics.d.ts +41 -0
  70. package/dist/diagnostics/render-diagnostics.js +46 -0
  71. package/dist/export/cascade.d.ts +98 -0
  72. package/dist/export/cascade.js +159 -0
  73. package/dist/export/export-zip.d.ts +19 -0
  74. package/dist/export/export-zip.js +38 -0
  75. package/dist/export/image-embed.d.ts +126 -0
  76. package/dist/export/image-embed.js +274 -0
  77. package/dist/export/note-export.d.ts +332 -0
  78. package/dist/export/note-export.js +366 -0
  79. package/dist/export/note-links.d.ts +83 -0
  80. package/dist/export/note-links.js +241 -0
  81. package/dist/glue.wasm +0 -0
  82. package/dist/host/adapter.d.ts +223 -0
  83. package/dist/host/adapter.js +9 -0
  84. package/dist/host/cascade-export-behavior.d.ts +120 -0
  85. package/dist/host/cascade-export-behavior.js +151 -0
  86. package/dist/host/conformance-runner.d.ts +156 -0
  87. package/dist/host/conformance-runner.js +634 -0
  88. package/dist/host/create-host.d.ts +253 -0
  89. package/dist/host/create-host.js +329 -0
  90. package/dist/host/editor-behavior.d.ts +157 -0
  91. package/dist/host/editor-behavior.js +227 -0
  92. package/dist/host/export/md-plain.d.ts +15 -0
  93. package/dist/host/export/md-plain.js +125 -0
  94. package/dist/host/export-behavior.d.ts +113 -0
  95. package/dist/host/export-behavior.js +257 -0
  96. package/dist/host/labels.d.ts +24 -0
  97. package/dist/host/labels.js +32 -0
  98. package/dist/host/pack-archive.d.ts +30 -0
  99. package/dist/host/pack-archive.js +68 -0
  100. package/dist/host/pack-install.d.ts +88 -0
  101. package/dist/host/pack-install.js +189 -0
  102. package/dist/host/pack-load.d.ts +72 -0
  103. package/dist/host/pack-load.js +57 -0
  104. package/dist/host/pack-remove.d.ts +21 -0
  105. package/dist/host/pack-remove.js +65 -0
  106. package/dist/host/pack-trust-behavior.d.ts +79 -0
  107. package/dist/host/pack-trust-behavior.js +262 -0
  108. package/dist/host/refresh-interval.d.ts +39 -0
  109. package/dist/host/refresh-interval.js +61 -0
  110. package/dist/host/run-behavior.d.ts +89 -0
  111. package/dist/host/run-behavior.js +168 -0
  112. package/dist/host/run-diagnostics.d.ts +26 -0
  113. package/dist/host/run-diagnostics.js +43 -0
  114. package/dist/host/script-execution.d.ts +72 -0
  115. package/dist/host/script-execution.js +68 -0
  116. package/dist/host/terminal-packs.d.ts +39 -0
  117. package/dist/host/terminal-packs.js +51 -0
  118. package/dist/html-engine.d.ts +2 -0
  119. package/dist/html-engine.js +29 -0
  120. package/dist/index.d.ts +95 -0
  121. package/dist/index.js +70 -0
  122. package/dist/insert/component-catalog.d.ts +23 -0
  123. package/dist/insert/component-catalog.js +96 -0
  124. package/dist/node-fs.d.ts +14 -0
  125. package/dist/node-fs.js +70 -0
  126. package/dist/node.d.ts +5 -0
  127. package/dist/node.js +13 -0
  128. package/dist/package.json +3 -0
  129. package/dist/packs/discover.d.ts +119 -0
  130. package/dist/packs/discover.js +266 -0
  131. package/dist/packs/pack-diagnostics.d.ts +81 -0
  132. package/dist/packs/pack-diagnostics.js +105 -0
  133. package/dist/packs/pack-paths.d.ts +53 -0
  134. package/dist/packs/pack-paths.js +106 -0
  135. package/dist/packs/pack-render-registry.d.ts +83 -0
  136. package/dist/packs/pack-render-registry.js +182 -0
  137. package/dist/packs/pack-scripts.d.ts +20 -0
  138. package/dist/packs/pack-scripts.js +96 -0
  139. package/dist/packs/pack-trust.d.ts +57 -0
  140. package/dist/packs/pack-trust.js +111 -0
  141. package/dist/packs/prebuilt.d.ts +49 -0
  142. package/dist/packs/prebuilt.js +97 -0
  143. package/dist/path-util.d.ts +24 -0
  144. package/dist/path-util.js +82 -0
  145. package/dist/run/browser-isolate.d.ts +45 -0
  146. package/dist/run/browser-isolate.js +81 -0
  147. package/dist/run/bundle-document.d.ts +29 -0
  148. package/dist/run/bundle-document.js +40 -0
  149. package/dist/run/bundle-run.d.ts +188 -0
  150. package/dist/run/bundle-run.js +232 -0
  151. package/dist/run/grant-flow.d.ts +232 -0
  152. package/dist/run/grant-flow.js +390 -0
  153. package/dist/run/ip-address.d.ts +41 -0
  154. package/dist/run/ip-address.js +255 -0
  155. package/dist/run/isolate.d.ts +57 -0
  156. package/dist/run/isolate.js +22 -0
  157. package/dist/run/lua-resolver.d.ts +21 -0
  158. package/dist/run/lua-resolver.js +63 -0
  159. package/dist/run/net-bridge-worker.d.ts +26 -0
  160. package/dist/run/net-bridge-worker.js +66 -0
  161. package/dist/run/net-bridge.d.ts +56 -0
  162. package/dist/run/net-bridge.js +59 -0
  163. package/dist/run/net-pinning.d.ts +82 -0
  164. package/dist/run/net-pinning.js +137 -0
  165. package/dist/run/net-provider.d.ts +70 -0
  166. package/dist/run/net-provider.js +289 -0
  167. package/dist/run/node-isolate.d.ts +30 -0
  168. package/dist/run/node-isolate.js +117 -0
  169. package/dist/run/run-flow.d.ts +187 -0
  170. package/dist/run/run-flow.js +323 -0
  171. package/dist/run/run-host.d.ts +107 -0
  172. package/dist/run/run-host.js +241 -0
  173. package/dist/run/run-job.d.ts +130 -0
  174. package/dist/run/run-job.js +279 -0
  175. package/dist/run/run-progress.d.ts +55 -0
  176. package/dist/run/run-progress.js +42 -0
  177. package/dist/run/run-trace.d.ts +44 -0
  178. package/dist/run/run-trace.js +36 -0
  179. package/dist/run/script-requirements.d.ts +98 -0
  180. package/dist/run/script-requirements.js +212 -0
  181. package/dist/run/snapshot-storage.d.ts +25 -0
  182. package/dist/run/snapshot-storage.js +31 -0
  183. package/dist/run/stale-values.d.ts +25 -0
  184. package/dist/run/stale-values.js +32 -0
  185. package/dist/run/worker-entry-browser.d.ts +42 -0
  186. package/dist/run/worker-entry-browser.js +77 -0
  187. package/dist/run/worker-entry.d.ts +1 -0
  188. package/dist/run/worker-entry.js +96 -0
  189. package/dist/values-failure.d.ts +17 -0
  190. package/dist/values-failure.js +1 -0
  191. package/dist/values-merge.d.ts +39 -0
  192. package/dist/values-merge.js +33 -0
  193. package/package.json +84 -4
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The lines a host's diagnostics surface gets for one run's script
3
+ * failures (GitHub issue #37), moved here from
4
+ * `apps/vscode/src/run-diagnostics.ts` so Obsidian gains the same
5
+ * behavior instead of writing its own copy (it previously wrote each
6
+ * failure to its console ad hoc; VS Code showed them only as value-marker
7
+ * tooltips and the run marker, which a hidden or collapsed marker can
8
+ * bury). This is the "second home" AGENTS.md's "clean is not silent" rule
9
+ * requires: one line per failed script, with its name, its failure kind,
10
+ * and the same short reason the tooltip carries. No failures, no lines:
11
+ * the surface stays quiet on a clean run.
12
+ */
13
+ export function formatRunFailureLines(failures) {
14
+ return failures.map((failure) => `${failure.name} (${failure.kind}): ${failure.message}`);
15
+ }
16
+ /**
17
+ * Every diagnostics line one completed run owes the host's surface, in
18
+ * the order they are written: a header and one indented line per failed
19
+ * script (the "second home" of each failure, `formatRunFailureLines`),
20
+ * then a header and the lines of any net-declaration mismatch. A clean
21
+ * run with agreeing declarations returns no lines, so an empty surface
22
+ * still means nothing went wrong.
23
+ */
24
+ export function runDiagnosticLines(trigger, result) {
25
+ const lines = [];
26
+ const failureLines = formatRunFailureLines(result.failureDetails);
27
+ if (failureLines.length > 0) {
28
+ lines.push(`${trigger} run finished with ${String(failureLines.length)} script failure(s):`);
29
+ for (const line of failureLines)
30
+ lines.push(` ${line}`);
31
+ }
32
+ if (result.netDeclarationDiagnostics.length > 0) {
33
+ lines.push(`${trigger} run: net declaration mismatch:`);
34
+ for (const line of result.netDeclarationDiagnostics) {
35
+ lines.push(` ${line}`);
36
+ }
37
+ }
38
+ return lines;
39
+ }
40
+ /** The one line a run that threw (rather than returning failures) owes the diagnostics surface. */
41
+ export function runCrashDiagnosticLine(trigger, detail) {
42
+ return `${trigger} run failed before it could report: ${detail}`;
43
+ }
@@ -0,0 +1,72 @@
1
+ /**
2
+ * The device-level script-execution switch and every sentence it can
3
+ * produce, merged from `apps/vscode/src/script-execution.ts` and
4
+ * `apps/obsidian/src/script-execution.ts` (survey finding A4: same file
5
+ * name, same four exports, doc comments sharing the same "WHAT IT IS /
6
+ * WHY DEVICE-LOCAL / WHY THE WORDING LIVES HERE" structure, differing
7
+ * only in a handful of words).
8
+ *
9
+ * WHAT IT IS. A single off switch for the Run path. When it is on, no
10
+ * trigger runs a note's scripts: not a manual run press, not run-on-open,
11
+ * not the scheduled-refresh timer. It sits on top of the existing
12
+ * guarantees rather than replacing any of them: the tier gate, the grant
13
+ * model, and the isolate are unchanged, and turning it on never touches a
14
+ * stored grant. Turning it back off leaves the same grants in place, so
15
+ * nothing is silently re-authorized either.
16
+ *
17
+ * WHY DEVICE-LOCAL. It decides whether code runs, so every host persists
18
+ * it outside anything that syncs or travels with a shared file: never
19
+ * VS Code's workspace-shared settings, never Obsidian's vault-synced
20
+ * `saveData`. Each app's own storage-boundary test is the executable half
21
+ * of that rule.
22
+ *
23
+ * WHY THE WORDING LIVES HERE. The files that wire this switch to a real
24
+ * UI (`preview-panel.ts`, `view.tsx`, `main.ts`) import their host's
25
+ * platform module and are therefore not unit-testable, so every
26
+ * user-visible string and every decision about which surface a blocked
27
+ * trigger reaches lives in this plain, host-labeled module instead.
28
+ *
29
+ * Pure and dependency-free: re-exported from `../browser.ts` as well as
30
+ * `../index.ts`.
31
+ */
32
+ import type { RunTrigger } from '@markii/runtime';
33
+ import type { HostLabels } from './adapter.js';
34
+ /**
35
+ * What a blocked MANUAL run says. Two short sentences: what happened, and
36
+ * where to change it. The reason is the whole message, so nothing is
37
+ * hidden behind a diagnostics lookup for the one trigger a user is
38
+ * actively watching.
39
+ */
40
+ export declare function scriptsDisabledNoticeText(labels: HostLabels): string;
41
+ /** What the toggle command says once script execution is off. */
42
+ export declare function scriptsDisabledConfirmationText(labels: HostLabels): string;
43
+ /** What the toggle command says once script execution is on again. Says what did NOT change, since the honest answer to "did this re-grant anything" is no. */
44
+ export declare function scriptsEnabledConfirmationText(labels: HostLabels): string;
45
+ /**
46
+ * The notice a blocked run shows, or `undefined` for a trigger that shows
47
+ * none.
48
+ *
49
+ * Only `'manual'` gets a popup or notice. An `'auto'` run happens on every
50
+ * preview open and a `'scheduled'` one happens on a timer, so notifying
51
+ * for those would be a drip of identical notices reporting a state the
52
+ * user set themselves. They are not silent, though:
53
+ * `scriptsDisabledDiagnosticLine` below writes every blocked trigger to
54
+ * this host's designated diagnostics surface, so "why did my dashboard
55
+ * stop refreshing" has an answer that does not require developer tools.
56
+ */
57
+ export declare function scriptsDisabledNotice(trigger: RunTrigger, labels: HostLabels): string | undefined;
58
+ /**
59
+ * The diagnostics-surface line for one blocked run, whatever its trigger.
60
+ * A blocked `'scheduled'` run also says that the preview's refresh timer
61
+ * was stopped: leaving a timer ticking against a closed door would write
62
+ * this same line every interval for as long as the preview stayed open.
63
+ *
64
+ * Names this host's own setting when it has one (`labels.settingName`),
65
+ * so the same sentence still reads correctly from any host's diagnostics
66
+ * surface while telling a VS Code user exactly which setting to flip back.
67
+ * Any sink-specific prefix, such as a `[markii]` console tag, is the
68
+ * adapter's own `diagnostics(line)` call's job to add, never baked in here.
69
+ */
70
+ export declare function scriptsDisabledDiagnosticLine(trigger: RunTrigger, labels: HostLabels): string;
71
+ /** The diagnostics-surface line for a preview that opens with a refresh interval configured but script execution off, so the timer is never started. */
72
+ export declare function scheduledRefreshNotStartedLine(labels: HostLabels): string;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * What a blocked MANUAL run says. Two short sentences: what happened, and
3
+ * where to change it. The reason is the whole message, so nothing is
4
+ * hidden behind a diagnostics lookup for the one trigger a user is
5
+ * actively watching.
6
+ */
7
+ export function scriptsDisabledNoticeText(labels) {
8
+ return `Markii: script execution is off on ${labels.deviceNoun}. Turn it on in the Markii settings to run this note.`;
9
+ }
10
+ /** What the toggle command says once script execution is off. */
11
+ export function scriptsDisabledConfirmationText(labels) {
12
+ return `Markii: script execution turned OFF on ${labels.deviceNoun}. No note runs its scripts until you turn it back on.`;
13
+ }
14
+ /** What the toggle command says once script execution is on again. Says what did NOT change, since the honest answer to "did this re-grant anything" is no. */
15
+ export function scriptsEnabledConfirmationText(labels) {
16
+ return `Markii: script execution turned ON for ${labels.deviceNoun}. Your existing grants are unchanged, so a note still prompts for any host it has not been granted.`;
17
+ }
18
+ /**
19
+ * The notice a blocked run shows, or `undefined` for a trigger that shows
20
+ * none.
21
+ *
22
+ * Only `'manual'` gets a popup or notice. An `'auto'` run happens on every
23
+ * preview open and a `'scheduled'` one happens on a timer, so notifying
24
+ * for those would be a drip of identical notices reporting a state the
25
+ * user set themselves. They are not silent, though:
26
+ * `scriptsDisabledDiagnosticLine` below writes every blocked trigger to
27
+ * this host's designated diagnostics surface, so "why did my dashboard
28
+ * stop refreshing" has an answer that does not require developer tools.
29
+ */
30
+ export function scriptsDisabledNotice(trigger, labels) {
31
+ return trigger === 'manual' ? scriptsDisabledNoticeText(labels) : undefined;
32
+ }
33
+ /**
34
+ * The clause naming why script execution is off, with the exact setting a
35
+ * user would toggle when this host has one (`labels.settingName`) — this
36
+ * is the diagnostics surface, the FULL-DETAIL home for a failure
37
+ * (AGENTS.md: "could a user, without opening developer tools ... discover
38
+ * that this failed and why?"), so it names the switch, not just the
39
+ * state. A host with no single named setting (a command or toggle
40
+ * instead) gets the plain sentence.
41
+ */
42
+ function scriptExecutionOffClause(labels) {
43
+ return labels.settingName === undefined
44
+ ? `script execution is off on ${labels.deviceNoun}`
45
+ : `script execution is off on ${labels.deviceNoun} (${labels.settingName})`;
46
+ }
47
+ /**
48
+ * The diagnostics-surface line for one blocked run, whatever its trigger.
49
+ * A blocked `'scheduled'` run also says that the preview's refresh timer
50
+ * was stopped: leaving a timer ticking against a closed door would write
51
+ * this same line every interval for as long as the preview stayed open.
52
+ *
53
+ * Names this host's own setting when it has one (`labels.settingName`),
54
+ * so the same sentence still reads correctly from any host's diagnostics
55
+ * surface while telling a VS Code user exactly which setting to flip back.
56
+ * Any sink-specific prefix, such as a `[markii]` console tag, is the
57
+ * adapter's own `diagnostics(line)` call's job to add, never baked in here.
58
+ */
59
+ export function scriptsDisabledDiagnosticLine(trigger, labels) {
60
+ const blocked = `run (${trigger}) blocked: ${scriptExecutionOffClause(labels)}.`;
61
+ return trigger === 'scheduled'
62
+ ? `${blocked} This preview's scheduled refresh was stopped; reopen the preview to resume it.`
63
+ : blocked;
64
+ }
65
+ /** The diagnostics-surface line for a preview that opens with a refresh interval configured but script execution off, so the timer is never started. */
66
+ export function scheduledRefreshNotStartedLine(labels) {
67
+ return `scheduled refresh not started: ${scriptExecutionOffClause(labels)}.`;
68
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * The host-neutral half of loading TERMINAL packs (`terminal.js`, the
3
+ * prebuilt terminal registration module beside `webview.js`). A host that
4
+ * runs the terminal engine (`@markii/ansi`, which this package never
5
+ * depends on) calls `createMarkiiHost`'s `loadTerminalPacks`, which
6
+ * discovers the authorized packs and reads each one's `terminal.js` text
7
+ * through this module; the host then hands the text to the engine's own
8
+ * `loadTerminalPackScript`. Everything here is the one home of the wording
9
+ * for the failures in between (docs/integration.md's "clean is not silent":
10
+ * a failure reaches the diagnostics surface and the note shows the pack's
11
+ * components as a failed pack).
12
+ *
13
+ * SECURITY: a terminal pack runs inside the host's own process with that
14
+ * process's full privileges. Nothing here widens who may reach it: the
15
+ * caller names the packs, and `HostPackSource.authorizedFolders()` is the
16
+ * only way a folder becomes a candidate (never a note, a bundle, the
17
+ * working directory, or an environment variable).
18
+ */
19
+ import type { DiscoveredPack } from '../packs/discover.js';
20
+ import type { HostAdapter } from './adapter.js';
21
+ /** One pack's `terminal.js` text, ready for the terminal engine's loader. */
22
+ export interface TerminalPackScript {
23
+ readonly namespace: string;
24
+ readonly folder: string;
25
+ readonly text: string;
26
+ }
27
+ export interface ReadTerminalScriptsResult {
28
+ readonly scripts: readonly TerminalPackScript[];
29
+ /** One line per pack that names `ansi` sources but whose `terminal.js` could not be read. */
30
+ readonly problems: readonly string[];
31
+ }
32
+ /** Whether a discovered pack names at least one terminal (`ansi`) source. */
33
+ export declare function packHasTerminalViews(pack: DiscoveredPack): boolean;
34
+ export declare function terminalScriptMissingLine(namespace: string): string;
35
+ export declare function terminalScriptUnreadableLine(namespace: string, reason: string): string;
36
+ export declare function terminalScriptRejectedLine(namespace: string, reason: string): string;
37
+ export declare function terminalScriptNamespaceMismatchLine(namespace: string, claimed: string): string;
38
+ /** Reads each terminal-capable pack's `terminal.js`. Never throws. */
39
+ export declare function readTerminalPackScripts(adapter: Pick<HostAdapter, 'exists' | 'readFile'>, packs: readonly DiscoveredPack[]): Promise<ReadTerminalScriptsResult>;
@@ -0,0 +1,51 @@
1
+ import { prebuiltTerminalScriptPathFor } from '../packs/prebuilt.js';
2
+ /** Whether a discovered pack names at least one terminal (`ansi`) source. */
3
+ export function packHasTerminalViews(pack) {
4
+ return Object.keys(pack.componentPathsByEngine?.['ansi'] ?? {}).length > 0;
5
+ }
6
+ export function terminalScriptMissingLine(namespace) {
7
+ return `Pack "${namespace}" names terminal views but ships no terminal.js; its components read as a failed pack in the note.`;
8
+ }
9
+ export function terminalScriptUnreadableLine(namespace, reason) {
10
+ return `Pack "${namespace}" has a terminal.js that could not be read (${reason}); its components read as a failed pack in the note.`;
11
+ }
12
+ export function terminalScriptRejectedLine(namespace, reason) {
13
+ return `Pack "${namespace}" was not loaded: ${reason}. Its components read as a failed pack in the note.`;
14
+ }
15
+ export function terminalScriptNamespaceMismatchLine(namespace, claimed) {
16
+ return `Pack "${namespace}" was not loaded: its terminal.js registers the namespace "${claimed}", which does not match its pack.json. Its components read as a failed pack in the note.`;
17
+ }
18
+ /** Reads each terminal-capable pack's `terminal.js`. Never throws. */
19
+ export async function readTerminalPackScripts(adapter, packs) {
20
+ const scripts = [];
21
+ const problems = [];
22
+ for (const pack of packs) {
23
+ if (!packHasTerminalViews(pack))
24
+ continue;
25
+ const namespace = pack.manifest.name;
26
+ const scriptPath = prebuiltTerminalScriptPathFor(pack.folder);
27
+ let present;
28
+ try {
29
+ present = await adapter.exists(scriptPath);
30
+ }
31
+ catch {
32
+ present = false;
33
+ }
34
+ if (!present) {
35
+ problems.push(terminalScriptMissingLine(namespace));
36
+ continue;
37
+ }
38
+ try {
39
+ const bytes = await adapter.readFile(scriptPath);
40
+ scripts.push({
41
+ namespace,
42
+ folder: pack.folder,
43
+ text: new TextDecoder().decode(bytes),
44
+ });
45
+ }
46
+ catch (err) {
47
+ problems.push(terminalScriptUnreadableLine(namespace, err instanceof Error ? err.message : String(err)));
48
+ }
49
+ }
50
+ return { scripts, problems };
51
+ }
@@ -0,0 +1,2 @@
1
+ import type { HtmlExportEngine } from './export/note-export.js';
2
+ export declare function createHtmlExportEngine(): HtmlExportEngine;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The `@markii/html`-backed `HtmlExportEngine`. Kept out of the main entry
3
+ * (it is the one module that carries the static HTML renderer); a host that
4
+ * exports HTML builds it here and hands it to `createMarkiiHost`'s
5
+ * `htmlEngine` option or to `buildNoteExport`. Reached through
6
+ * `@markii/host/node`.
7
+ */
8
+ import { escapeHtml, exportHtmlDocument, renderMarkToHtml } from '@markii/html';
9
+ import { defaultHtmlRegistry } from '@markii/html/components';
10
+ export function createHtmlExportEngine() {
11
+ return {
12
+ renderBody: (text, store, diagnostics) => renderMarkToHtml(text, defaultHtmlRegistry, store, undefined, {
13
+ ...(diagnostics.unavailableComponents !== undefined
14
+ ? { unavailableComponents: diagnostics.unavailableComponents }
15
+ : {}),
16
+ ...(diagnostics.onDiagnostic !== undefined
17
+ ? { onDiagnostic: diagnostics.onDiagnostic }
18
+ : {}),
19
+ }),
20
+ composeDocument: (bodyHtml, options) => exportHtmlDocument(bodyHtml, {
21
+ title: options.title,
22
+ extraCss: options.extraCss,
23
+ ...(options.docClassName !== undefined
24
+ ? { docClassName: options.docClassName }
25
+ : {}),
26
+ }),
27
+ escapeHtml,
28
+ };
29
+ }
@@ -0,0 +1,95 @@
1
+ export type { ValuesFailure } from './values-failure.js';
2
+ export { mergeArrivingValue } from './values-merge.js';
3
+ export type { RunJob, RunResult, RunFailure, RunProgress, SpawnRunOptions, SpawnRunRequest, } from './run/run-host.js';
4
+ export { isRunProgress } from './run/run-progress.js';
5
+ export { spawnRun } from './run/run-host.js';
6
+ export type { IsolateSpawner, RunIsolate, SpawnIsolateOptions, } from './run/isolate.js';
7
+ export { createBrowserIsolate } from './run/browser-isolate.js';
8
+ export type { BrowserIsolateOptions, WorkerLike, } from './run/browser-isolate.js';
9
+ export { isNetBridgeRequest, serveNetRequest } from './run/net-bridge.js';
10
+ export type { NetBridgeReply, NetBridgeRequest } from './run/net-bridge.js';
11
+ export type { CacheSnapshot, RunOnceOptions, RunOnceResult, } from './run/run-flow.js';
12
+ export { MAX_CACHE_SNAPSHOT_BYTES, MAX_VALUES_SNAPSHOT_BYTES, cacheStorageKeyFor, isCacheSnapshotShape, mergePersistedValues, readPersistedValues, runOnce, serializeCacheSnapshotIfSmallEnough, valuesStorageKeyFor, } from './run/run-flow.js';
13
+ export type { GrantFlowOptions, GrantFlowRequirements, GrantFlowResult, GrantMemento, PromptHost, PromptManyHosts, PromptUnknownHosts, Thenable, } from './run/grant-flow.js';
14
+ export { ALLOW_LABEL, DONT_ALLOW_LABEL, MAX_HOST_PROMPTS, UNKNOWN_HOSTS_PROMPT_MESSAGE, clearGrantForDocument, hostPromptMessage, isSafeHostForPrompt, manyHostsPromptMessage, resolveStoredGrant, runGrantFlow, } from './run/grant-flow.js';
15
+ export type { BuildBundleSnapshotOptions, BundleSnapshotResult, EncodedBundleCache, } from './run/bundle-run.js';
16
+ export { DEFAULT_MAX_BUNDLE_SNAPSHOT_BYTES, DEFAULT_MAX_BUNDLE_SNAPSHOT_FILE_BYTES, MAX_PERSISTED_BUNDLE_CACHE_BYTES, buildBundleSnapshot, bundleModulesFromSnapshot, cacheFilesFrom, decodeBundleCacheFromStorage, encodeBundleCacheForStorage, manifestBundleFsGrants, manifestNetHosts, netDeclarationDiagnostics, withPersistedCache, } from './run/bundle-run.js';
17
+ export { BUNDLE_EXTENSION, DEFAULT_BUNDLE_DOCUMENT_PATH, LEGACY_BUNDLE_EXTENSION, isBundleName, resolveBundleDocumentPath, } from './run/bundle-document.js';
18
+ export type { RunTrace } from './run/run-trace.js';
19
+ export { isRunTrace, lastRunStorageKeyFor, readLastRunTrace, writeLastRunTrace, } from './run/run-trace.js';
20
+ export type { RunRequirements } from './run/script-requirements.js';
21
+ export { extractRunRequirements } from './run/script-requirements.js';
22
+ export type { SnapshotStorage } from './run/snapshot-storage.js';
23
+ export { createSnapshotStorage } from './run/snapshot-storage.js';
24
+ export { staleValuesForRehydration } from './run/stale-values.js';
25
+ export type { HtmlExportEngine, CascadeIndexEntry, ComposeNoteHtmlExportOptions, ExportBodyRenderer, ExportBodyResult, ExportExtension, ExportPackStylesheet, ExportRenderInfo, NoteExportBuildRequest, NoteExportDocument, NoteHtmlExportOptions, StaticExportReason, } from './export/note-export.js';
26
+ export { EXPORT_HIDE_SCRIPT_BLOCKS_CLASS, EXPORT_PAGE_CSS, FALLBACK_EXPORT_BASE_NAME, MARK_EXTENSION, buildCascadeIndexHtml, buildNoteExport, buildNoteHtmlExport, composeNoteHtmlExport, noteHasScripts, exportBaseName, exportDocumentTitle, exportedFileName, exportedSiblingPath, packStylesheetsCss, } from './export/note-export.js';
27
+ export type { EmbeddedImageReport, ExportImageReader, ExportImageResult, ImageSkipReason, SkippedImage, } from './export/image-embed.js';
28
+ export { EMBEDDABLE_IMAGE_EXTENSIONS, EMPTY_IMAGE_REPORT, MAX_EMBEDDED_IMAGE_BYTES, embedImagesInHtml, encodeBase64, isEmbeddableImageSrc, mimeTypeForImageSrc, toImageDataUri, } from './export/image-embed.js';
29
+ export type { NoteLink, NoteLinkTargetResolver } from './export/note-links.js';
30
+ export { extractNoteLinks, isLocalNoteTarget, maskCodeRegions, rewriteNoteLinks, } from './export/note-links.js';
31
+ export type { CascadeLinkResolver, CascadeNote, CascadeNoteReader, CascadeTruncation, CascadeWalkOptions, CascadeWalkResult, } from './export/cascade.js';
32
+ export { CASCADE_INDEX_FILE_NAME, DEFAULT_CASCADE_MAX_DEPTH, DEFAULT_CASCADE_MAX_NOTES, assignCascadeFileNames, rewriteCascadeLinks, walkNoteCascade, } from './export/cascade.js';
33
+ export type { CascadeArchiveRequest, CascadeArchiveResult, CascadeExportOutcome, CascadeExportedNote, UnreadableCascadeNote, } from './host/cascade-export-behavior.js';
34
+ export { buildCascadeArchive, cascadeDiagnosticLines, cascadeReasonOf, cascadeResultMessage, countedNoun, } from './host/cascade-export-behavior.js';
35
+ export type { ExportArchiveEntry } from './export/export-zip.js';
36
+ export { zipExportArchive } from './export/export-zip.js';
37
+ export type { HostLookup, PinnedAddress, PinPolicy, PinResult, ResolvedAddress, } from './run/net-pinning.js';
38
+ export { pinHostAddress, pinnedLookup } from './run/net-pinning.js';
39
+ export type { AddressScope } from './run/ip-address.js';
40
+ export { classifyIpAddress, describeScope, isRestrictedScope, } from './run/ip-address.js';
41
+ export type { PackModulesMap } from './run/lua-resolver.js';
42
+ export { createPackModuleResolver } from './run/lua-resolver.js';
43
+ export type { DiscoveredPack, DiscoverPacksResult, EngineUnsupportedPack, PackDirectoryLister, SkippedPackFolder, } from './packs/discover.js';
44
+ export { componentsWithoutEngineView, declaredPackComponents, discoverPacks, installedNamespaces, } from './packs/discover.js';
45
+ export type { PackScriptsReader } from './packs/pack-scripts.js';
46
+ export { loadPackModules } from './packs/pack-scripts.js';
47
+ export { relativePackEntries, resolvePackPaths } from './packs/pack-paths.js';
48
+ export type { PackDiagnosticsContext, PackDiagnosticsPack, PackDiagnosticsSkippedFolder, } from './packs/pack-diagnostics.js';
49
+ export { formatPackDiagnosticLines, skippedPackCount, } from './packs/pack-diagnostics.js';
50
+ export type { PackPathExists, PrebuiltPackResolution, } from './packs/prebuilt.js';
51
+ export { PREBUILT_SCRIPT_FILENAME, PREBUILT_STYLESHEET_FILENAME, PREBUILT_TERMINAL_SCRIPT_FILENAME, emptyWebviewScript, prebuiltScriptPathFor, prebuiltStylesheetPathFor, prebuiltTerminalScriptPathFor, resolvePrebuiltPack, } from './packs/prebuilt.js';
52
+ export type { BuildRenderRegistryResult, DuplicateComposedName, PackRegistryEngine, QueuedPackRegistration, } from './packs/pack-render-registry.js';
53
+ export { buildRenderRegistry } from './packs/pack-render-registry.js';
54
+ export type { ComponentSkeleton, LineColumn } from '@markii/stdlib/editor';
55
+ export { componentSkeleton, offsetToLineColumn } from '@markii/stdlib/editor';
56
+ export { LAYOUT_WRAPPER_NAMES } from '@markii/stdlib/editor';
57
+ export type { InsertableComponent } from '@markii/stdlib/editor';
58
+ export type { PackComponentAttribute } from '@markii/pack';
59
+ export { buildComponentCatalog } from './insert/component-catalog.js';
60
+ export type { CompletionContext, CompletionContextKind, CompletionItem, CompletionItemKind, ComponentDocumentation, HoverInfo, } from '@markii/stdlib/editor';
61
+ export { completionAt, componentDocumentation, formatComponentDocumentation, hoverAt, } from '@markii/stdlib/editor';
62
+ export type { EnclosingContainerFence, FenceLineEdit, } from '@markii/stdlib/editor';
63
+ export { closesOpenContainerFence, enclosingContainerFences, fenceExtensionEdits, insertedContainerColonCount, } from '@markii/stdlib/editor';
64
+ export { createRenderDiagnosticCollector, createRenderDiagnosticReporter, renderDiagnosticLine, } from './diagnostics/render-diagnostics.js';
65
+ export type { HostAdapter, HostDirEntry, HostEditor, HostExportCapabilities, HostExportFormat, HostIsolate, HostLabels, HostPackSource, HostPromptRequest, HostTextEdit, } from './host/adapter.js';
66
+ export { BROWSER_ISOLATE_ENTRY } from './host/adapter.js';
67
+ export { CLI_LABELS, OBSIDIAN_LABELS, VSCODE_LABELS, packsNotInstalledLabel, } from './host/labels.js';
68
+ export { scheduledRefreshNotStartedLine, scriptsDisabledConfirmationText, scriptsDisabledDiagnosticLine, scriptsDisabledNotice, scriptsDisabledNoticeText, scriptsEnabledConfirmationText, } from './host/script-execution.js';
69
+ export { MIN_REFRESH_INTERVAL_SECONDS, parseRefreshIntervalSeconds, refreshIntervalMsFromSeconds, refreshIntervalValidationMessage, } from './host/refresh-interval.js';
70
+ export { promptsFromAdapter, runViaAdapter, spawnRunViaAdapter, RUN_TIMEOUT_MS as HOST_RUN_TIMEOUT_MS, } from './host/run-behavior.js';
71
+ export type { RunViaAdapterRequest, RunViaAdapterResult, } from './host/run-behavior.js';
72
+ export { formatRunFailureLines, runDiagnosticLines, } from './host/run-diagnostics.js';
73
+ export type { ArchiveExtractFs } from './host/pack-archive.js';
74
+ export { describeArchiveError, writeArchiveContents, } from './host/pack-archive.js';
75
+ export type { InstallPackFromArchiveOptions, PackDirectoryExists, } from './host/pack-install.js';
76
+ export { installConsentMessage, installPackDiagnosticLines, installPackFromArchive, installPackMessage, installReplaceConfirmMessage, } from './host/pack-install.js';
77
+ export type { LoadPacksResult, PackDiscoveryIo } from './host/pack-load.js';
78
+ export { discoverConfiguredPacks, loadPacksViaAdapter, packDiscoveryIoFromAdapter, } from './host/pack-load.js';
79
+ export { prebuiltShadowLine } from './packs/pack-diagnostics.js';
80
+ export type { ReadTerminalScriptsResult, TerminalPackScript, } from './host/terminal-packs.js';
81
+ export { packHasTerminalViews, readTerminalPackScripts, terminalScriptMissingLine, terminalScriptNamespaceMismatchLine, terminalScriptRejectedLine, terminalScriptUnreadableLine, } from './host/terminal-packs.js';
82
+ export type { RemovePackOutcome } from './host/pack-remove.js';
83
+ export type { PackTrustEntry, PackTrustList } from './packs/pack-trust.js';
84
+ export { DEFAULT_PACK_TRUST_LIST, MAX_TRUSTED_PACKS, PACK_TRUST_STORAGE_KEY, isPackTrusted, normalizePackTrustList, trustPack, untrustPack, } from './packs/pack-trust.js';
85
+ export type { DisablePackOutcome, EnabledPack, EnablePackOutcome, InstalledPacksListing, } from './host/pack-trust-behavior.js';
86
+ export { disablePackMessage, enablePackMessage, notEnabledPackDiagnosticLine, selectEnabledPacks, } from './host/pack-trust-behavior.js';
87
+ export { removePackDiagnosticLine, removePackMessage, removePackViaAdapter, } from './host/pack-remove.js';
88
+ export { mdPlainFromSource } from './host/export/md-plain.js';
89
+ export type { ExportHtmlDocumentRequest, NoteFileExportOutcome, } from './host/export-behavior.js';
90
+ export { buildExportDocument, exportDefaultFileName, exportDiagnosticLines, exportNoteFileViaAdapter, exportResultMessage, fileNameOf, formatByteSize, imageEmbedDiagnosticLines, renderEngineDiagnosticLine, } from './host/export-behavior.js';
91
+ export type { CatalogCache, CompletionPlan, InsertComponentEdit, InsertComponentPlan, } from './host/editor-behavior.js';
92
+ export { LAYOUT_ORIGIN_TAG, STANDARD_ORIGIN_TAG, completeAtViaEditor, completionOriginTag, completionPlanAt, createCatalogCache, hoverAtViaEditor, hoverDocumentationText, insertComponentPlan, isContainerCompletionItem, } from './host/editor-behavior.js';
93
+ export { createMarkiiHost } from './host/create-host.js';
94
+ export type { CompleteOutcome, EditorPositionRequest, ExportOutcome, ExportRequest, HoverOutcome, InsertComponentRequest, InstallPackOutcome, InstallPackRequest, LoadPacksOutcome, LoadTerminalPacksOutcome, MarkiiHost, MarkiiHostOptions, OpenOutcome, OpenRequest, RemovePackResult, DisablePackResult, EnablePackResult, InstalledPacksOutcome, RunOutcome, RunRequest, Unsupported, } from './host/create-host.js';
95
+ export { joinPath, dirnamePath, isAbsolutePath } from './path-util.js';
package/dist/index.js ADDED
@@ -0,0 +1,70 @@
1
+ // @markii/host: the shared, host-neutral script-running layer for Markii
2
+ // hosts (`apps/vscode`, and any future host such as an Obsidian plugin).
3
+ // Environment-neutral: nothing reachable from this entry imports `node:*`,
4
+ // `esbuild-wasm`, `@markii/react` or `@markii/html` at runtime
5
+ // (`apps/vscode/src/browser-entry.probe.test.ts` bundles it for a browser to
6
+ // prove it). What needs Node lives in `./node.ts`, published as
7
+ // `@markii/host/node`. Private workspace package: never published,
8
+ // never added to `build:dist`. See AGENTS.md's repo-layout entry for
9
+ // `packages/markii-host` for the module-by-module breakdown.
10
+ //
11
+ // This is the security-critical layer (tier gating, the grant model,
12
+ // DNS/address pinning, the terminatable-isolate watchdog) — a second,
13
+ // drifting copy of any of this is the one outcome to avoid, which is why
14
+ // it lives here instead of inside `apps/vscode`.
15
+ export { mergeArrivingValue } from './values-merge.js';
16
+ export { isRunProgress } from './run/run-progress.js';
17
+ export { spawnRun } from './run/run-host.js';
18
+ export { createBrowserIsolate } from './run/browser-isolate.js';
19
+ export { isNetBridgeRequest, serveNetRequest } from './run/net-bridge.js';
20
+ export { MAX_CACHE_SNAPSHOT_BYTES, MAX_VALUES_SNAPSHOT_BYTES, cacheStorageKeyFor, isCacheSnapshotShape, mergePersistedValues, readPersistedValues, runOnce, serializeCacheSnapshotIfSmallEnough, valuesStorageKeyFor, } from './run/run-flow.js';
21
+ export { ALLOW_LABEL, DONT_ALLOW_LABEL, MAX_HOST_PROMPTS, UNKNOWN_HOSTS_PROMPT_MESSAGE, clearGrantForDocument, hostPromptMessage, isSafeHostForPrompt, manyHostsPromptMessage, resolveStoredGrant, runGrantFlow, } from './run/grant-flow.js';
22
+ export { DEFAULT_MAX_BUNDLE_SNAPSHOT_BYTES, DEFAULT_MAX_BUNDLE_SNAPSHOT_FILE_BYTES, MAX_PERSISTED_BUNDLE_CACHE_BYTES, buildBundleSnapshot, bundleModulesFromSnapshot, cacheFilesFrom, decodeBundleCacheFromStorage, encodeBundleCacheForStorage, manifestBundleFsGrants, manifestNetHosts, netDeclarationDiagnostics, withPersistedCache, } from './run/bundle-run.js';
23
+ export { BUNDLE_EXTENSION, DEFAULT_BUNDLE_DOCUMENT_PATH, LEGACY_BUNDLE_EXTENSION, isBundleName, resolveBundleDocumentPath, } from './run/bundle-document.js';
24
+ export { isRunTrace, lastRunStorageKeyFor, readLastRunTrace, writeLastRunTrace, } from './run/run-trace.js';
25
+ export { extractRunRequirements } from './run/script-requirements.js';
26
+ export { createSnapshotStorage } from './run/snapshot-storage.js';
27
+ export { staleValuesForRehydration } from './run/stale-values.js';
28
+ export { EXPORT_HIDE_SCRIPT_BLOCKS_CLASS, EXPORT_PAGE_CSS, FALLBACK_EXPORT_BASE_NAME, MARK_EXTENSION, buildCascadeIndexHtml, buildNoteExport, buildNoteHtmlExport, composeNoteHtmlExport, noteHasScripts, exportBaseName, exportDocumentTitle, exportedFileName, exportedSiblingPath, packStylesheetsCss, } from './export/note-export.js';
29
+ export { EMBEDDABLE_IMAGE_EXTENSIONS, EMPTY_IMAGE_REPORT, MAX_EMBEDDED_IMAGE_BYTES, embedImagesInHtml, encodeBase64, isEmbeddableImageSrc, mimeTypeForImageSrc, toImageDataUri, } from './export/image-embed.js';
30
+ export { extractNoteLinks, isLocalNoteTarget, maskCodeRegions, rewriteNoteLinks, } from './export/note-links.js';
31
+ export { CASCADE_INDEX_FILE_NAME, DEFAULT_CASCADE_MAX_DEPTH, DEFAULT_CASCADE_MAX_NOTES, assignCascadeFileNames, rewriteCascadeLinks, walkNoteCascade, } from './export/cascade.js';
32
+ export { buildCascadeArchive, cascadeDiagnosticLines, cascadeReasonOf, cascadeResultMessage, countedNoun, } from './host/cascade-export-behavior.js';
33
+ export { zipExportArchive } from './export/export-zip.js';
34
+ export { pinHostAddress, pinnedLookup } from './run/net-pinning.js';
35
+ export { classifyIpAddress, describeScope, isRestrictedScope, } from './run/ip-address.js';
36
+ export { createPackModuleResolver } from './run/lua-resolver.js';
37
+ export { componentsWithoutEngineView, declaredPackComponents, discoverPacks, installedNamespaces, } from './packs/discover.js';
38
+ export { loadPackModules } from './packs/pack-scripts.js';
39
+ export { relativePackEntries, resolvePackPaths } from './packs/pack-paths.js';
40
+ export { formatPackDiagnosticLines, skippedPackCount, } from './packs/pack-diagnostics.js';
41
+ export { PREBUILT_SCRIPT_FILENAME, PREBUILT_STYLESHEET_FILENAME, PREBUILT_TERMINAL_SCRIPT_FILENAME, emptyWebviewScript, prebuiltScriptPathFor, prebuiltStylesheetPathFor, prebuiltTerminalScriptPathFor, resolvePrebuiltPack, } from './packs/prebuilt.js';
42
+ export { buildRenderRegistry } from './packs/pack-render-registry.js';
43
+ export { componentSkeleton, offsetToLineColumn } from '@markii/stdlib/editor';
44
+ export { LAYOUT_WRAPPER_NAMES } from '@markii/stdlib/editor';
45
+ export { buildComponentCatalog } from './insert/component-catalog.js';
46
+ export { completionAt, componentDocumentation, formatComponentDocumentation, hoverAt, } from '@markii/stdlib/editor';
47
+ export { closesOpenContainerFence, enclosingContainerFences, fenceExtensionEdits, insertedContainerColonCount, } from '@markii/stdlib/editor';
48
+ // Render-time diagnostics: one event from either renderer's `onDiagnostic`
49
+ // option becomes the one line both hosts write to their diagnostics
50
+ // surface.
51
+ export { createRenderDiagnosticCollector, createRenderDiagnosticReporter, renderDiagnosticLine, } from './diagnostics/render-diagnostics.js';
52
+ export { BROWSER_ISOLATE_ENTRY } from './host/adapter.js';
53
+ export { CLI_LABELS, OBSIDIAN_LABELS, VSCODE_LABELS, packsNotInstalledLabel, } from './host/labels.js';
54
+ export { scheduledRefreshNotStartedLine, scriptsDisabledConfirmationText, scriptsDisabledDiagnosticLine, scriptsDisabledNotice, scriptsDisabledNoticeText, scriptsEnabledConfirmationText, } from './host/script-execution.js';
55
+ export { MIN_REFRESH_INTERVAL_SECONDS, parseRefreshIntervalSeconds, refreshIntervalMsFromSeconds, refreshIntervalValidationMessage, } from './host/refresh-interval.js';
56
+ export { promptsFromAdapter, runViaAdapter, spawnRunViaAdapter, RUN_TIMEOUT_MS as HOST_RUN_TIMEOUT_MS, } from './host/run-behavior.js';
57
+ export { formatRunFailureLines, runDiagnosticLines, } from './host/run-diagnostics.js';
58
+ export { describeArchiveError, writeArchiveContents, } from './host/pack-archive.js';
59
+ export { installConsentMessage, installPackDiagnosticLines, installPackFromArchive, installPackMessage, installReplaceConfirmMessage, } from './host/pack-install.js';
60
+ export { discoverConfiguredPacks, loadPacksViaAdapter, packDiscoveryIoFromAdapter, } from './host/pack-load.js';
61
+ export { prebuiltShadowLine } from './packs/pack-diagnostics.js';
62
+ export { packHasTerminalViews, readTerminalPackScripts, terminalScriptMissingLine, terminalScriptNamespaceMismatchLine, terminalScriptRejectedLine, terminalScriptUnreadableLine, } from './host/terminal-packs.js';
63
+ export { DEFAULT_PACK_TRUST_LIST, MAX_TRUSTED_PACKS, PACK_TRUST_STORAGE_KEY, isPackTrusted, normalizePackTrustList, trustPack, untrustPack, } from './packs/pack-trust.js';
64
+ export { disablePackMessage, enablePackMessage, notEnabledPackDiagnosticLine, selectEnabledPacks, } from './host/pack-trust-behavior.js';
65
+ export { removePackDiagnosticLine, removePackMessage, removePackViaAdapter, } from './host/pack-remove.js';
66
+ export { mdPlainFromSource } from './host/export/md-plain.js';
67
+ export { buildExportDocument, exportDefaultFileName, exportDiagnosticLines, exportNoteFileViaAdapter, exportResultMessage, fileNameOf, formatByteSize, imageEmbedDiagnosticLines, renderEngineDiagnosticLine, } from './host/export-behavior.js';
68
+ export { LAYOUT_ORIGIN_TAG, STANDARD_ORIGIN_TAG, completeAtViaEditor, completionOriginTag, completionPlanAt, createCatalogCache, hoverAtViaEditor, hoverDocumentationText, insertComponentPlan, isContainerCompletionItem, } from './host/editor-behavior.js';
69
+ export { createMarkiiHost } from './host/create-host.js';
70
+ export { joinPath, dirnamePath, isAbsolutePath } from './path-util.js';
@@ -0,0 +1,23 @@
1
+ import { LAYOUT_WRAPPER_NAMES } from '@markii/stdlib/editor';
2
+ import type { InsertableComponent } from '@markii/stdlib/editor';
3
+ import type { DiscoveredPack } from '../packs/discover.js';
4
+ export { LAYOUT_WRAPPER_NAMES };
5
+ export type { InsertableComponent };
6
+ /**
7
+ * Builds the full insert catalog: `@markii/stdlib/editor`'s standard-set
8
+ * list, then each pack's components (in the order `packs` is given, each
9
+ * pack's own local names sorted alphabetically). A host renders a picker's
10
+ * sections straight off this order — standard section, layout section,
11
+ * then one section per pack — without needing to re-sort or re-group the
12
+ * result itself.
13
+ *
14
+ * A pack component whose composed directive name collides with the
15
+ * standard set or with an earlier pack's entry is skipped, so the returned
16
+ * list never has two entries with the same `directiveName`.
17
+ *
18
+ * `engine`, when given, keeps only the pack components that have a source
19
+ * for that engine (the host's renderer): a component without one renders
20
+ * as the unknown fallback there, so it is not offered. Omitted, every
21
+ * declared component is listed.
22
+ */
23
+ export declare function buildComponentCatalog(packs: readonly DiscoveredPack[], engine?: string): readonly InsertableComponent[];
@@ -0,0 +1,96 @@
1
+ /**
2
+ * "Insert Component" (GitHub issue #17, slice 1): the PACK-AWARE half of
3
+ * the insert catalog. `@markii/stdlib/editor`'s `standardComponentCatalog`
4
+ * (GitHub issue #41) is the standard-set half — every `@markii/stdlib`
5
+ * standard component, with no dependency on `@markii/pack` at all — and
6
+ * this module composes it with one entry per component every currently
7
+ * discovered pack declares. This split is why `@markii/stdlib` can stay at
8
+ * zero dependencies while a pack-less host (or a third-party editor
9
+ * integration that never imports `@markii/pack`) still gets the full
10
+ * standard-set catalog for free.
11
+ *
12
+ * Host-neutral and pure: no `vscode`, no `obsidian`, no filesystem access
13
+ * of its own (packs are handed in already discovered, via
14
+ * `@markii/host`'s own `discoverPacks`/`DiscoveredPack`).
15
+ *
16
+ * Never throws. A malformed pack (an empty or missing `components` map, or
17
+ * a local name that fails `@markii/pack`'s namespace validation) simply
18
+ * contributes nothing — the same cleanliness posture as `./discover.ts`.
19
+ * A pack component's declared attribute metadata (`pack.json`'s optional
20
+ * `attributes` list, issue #27 slice 4) is carried through untouched;
21
+ * `@markii/pack`'s `packComponents` has already dropped anything malformed
22
+ * in it, so this module never re-validates it.
23
+ */
24
+ import { composeDirectiveName, packComponents, packComponentsForEngine, } from '@markii/pack';
25
+ import { LAYOUT_WRAPPER_NAMES, standardComponentCatalog, } from '@markii/stdlib/editor';
26
+ export { LAYOUT_WRAPPER_NAMES };
27
+ /**
28
+ * One pack's contribution to the catalog: its declared components
29
+ * (`@markii/pack`'s `packComponents`, sorted alphabetically by local name
30
+ * for determinism), each composed into a directive name via
31
+ * `@markii/pack`'s `composeDirectiveName`. A local name that fails
32
+ * composition (an invalid namespace or local-name shape) is skipped —
33
+ * never thrown. `taken` is a set of directive names already claimed (by
34
+ * the standard set, or by an earlier pack) that this pack must not collide
35
+ * with; a colliding name is skipped and `taken` is left unchanged for it
36
+ * (first entry keeps the name).
37
+ */
38
+ function packCatalogEntries(pack, taken, engine) {
39
+ const all = engine === undefined
40
+ ? packComponents(pack.manifest)
41
+ : packComponentsForEngine(pack.manifest, engine);
42
+ const listings = [...all].sort((a, b) => a.localName < b.localName ? -1 : a.localName > b.localName ? 1 : 0);
43
+ const entries = [];
44
+ for (const listing of listings) {
45
+ const composed = composeDirectiveName(pack.manifest.name, listing.localName);
46
+ if (!composed.ok)
47
+ continue;
48
+ if (taken.has(composed.name))
49
+ continue;
50
+ taken.add(composed.name);
51
+ entries.push({
52
+ directiveName: composed.name,
53
+ kind: listing.kind ?? 'container',
54
+ source: 'pack',
55
+ group: 'pack',
56
+ packName: pack.manifest.name,
57
+ ...(listing.description !== undefined
58
+ ? { description: listing.description }
59
+ : {}),
60
+ requiredAttributes: (listing.attributes ?? [])
61
+ .filter((attribute) => attribute.required === true)
62
+ .map((attribute) => attribute.name),
63
+ ...(listing.attributes !== undefined
64
+ ? { attributes: listing.attributes }
65
+ : {}),
66
+ kindDeclared: listing.kind !== undefined,
67
+ });
68
+ }
69
+ return entries;
70
+ }
71
+ /**
72
+ * Builds the full insert catalog: `@markii/stdlib/editor`'s standard-set
73
+ * list, then each pack's components (in the order `packs` is given, each
74
+ * pack's own local names sorted alphabetically). A host renders a picker's
75
+ * sections straight off this order — standard section, layout section,
76
+ * then one section per pack — without needing to re-sort or re-group the
77
+ * result itself.
78
+ *
79
+ * A pack component whose composed directive name collides with the
80
+ * standard set or with an earlier pack's entry is skipped, so the returned
81
+ * list never has two entries with the same `directiveName`.
82
+ *
83
+ * `engine`, when given, keeps only the pack components that have a source
84
+ * for that engine (the host's renderer): a component without one renders
85
+ * as the unknown fallback there, so it is not offered. Omitted, every
86
+ * declared component is listed.
87
+ */
88
+ export function buildComponentCatalog(packs, engine) {
89
+ const standard = standardComponentCatalog();
90
+ const taken = new Set(standard.map((entry) => entry.directiveName));
91
+ const packEntries = [];
92
+ for (const pack of packs) {
93
+ packEntries.push(...packCatalogEntries(pack, taken, engine));
94
+ }
95
+ return [...standard, ...packEntries];
96
+ }
@@ -0,0 +1,14 @@
1
+ import type { ArchiveExtractFs } from './host/pack-archive.js';
2
+ import type { PackDiscoveryIo } from './host/pack-load.js';
3
+ import type { PackDirectoryLister, PackFileReader } from './packs/discover.js';
4
+ import type { PackScriptsReader } from './packs/pack-scripts.js';
5
+ /** The real, Node-backed `PackDirectoryLister`. Never rejects: an unreadable, missing or non-directory path resolves `[]`. */
6
+ export declare function createNodeDirectoryLister(): PackDirectoryLister;
7
+ /** The real, Node-backed `PackFileReader`. Never rejects: an unreadable or missing path resolves `undefined`. */
8
+ export declare function createNodeFileReader(): PackFileReader;
9
+ /** The real, Node-backed `PackScriptsReader`. */
10
+ export declare function createNodeReader(): PackScriptsReader;
11
+ /** The real, Node-backed `ArchiveExtractFs`. */
12
+ export declare function createNodeArchiveExtractFs(): ArchiveExtractFs;
13
+ /** Pack discovery's reads over the real file system. */
14
+ export declare function createNodePackDiscoveryIo(): PackDiscoveryIo;