@markii/host 0.17.0-next.3 → 0.17.0-next.5

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 (55) hide show
  1. package/README.md +34 -1
  2. package/dist/browser-worker.classic.js +640 -0
  3. package/dist/browser-worker.js +19 -19
  4. package/dist/browser.d.ts +1 -1
  5. package/dist/browser.js +10 -3
  6. package/dist/conformance/host/05-export-html-pack-directive/expected.json +2 -0
  7. package/dist/conformance/host/06-install-pack-then-render/expected.json +6 -1
  8. package/dist/conformance/host/17-export-linked-set/expected.json +17 -0
  9. package/dist/conformance/host/17-export-linked-set/files/second.mk.md +3 -0
  10. package/dist/conformance/host/17-export-linked-set/note.mk.md +4 -0
  11. package/dist/conformance/host/17-export-linked-set/scenario.json +6 -0
  12. package/dist/conformance/host/README.md +17 -12
  13. package/dist/diagnostics/render-diagnostics.d.ts +1 -1
  14. package/dist/export/note-export.d.ts +1 -1
  15. package/dist/host/adapter.d.ts +13 -3
  16. package/dist/host/cascade-export-behavior.d.ts +24 -8
  17. package/dist/host/cascade-export-behavior.js +61 -1
  18. package/dist/host/conformance-runner.d.ts +3 -4
  19. package/dist/host/conformance-runner.js +58 -8
  20. package/dist/host/create-host.d.ts +65 -8
  21. package/dist/host/create-host.js +54 -23
  22. package/dist/host/export-behavior.d.ts +2 -1
  23. package/dist/host/export-behavior.js +1 -1
  24. package/dist/host/labels.d.ts +5 -14
  25. package/dist/host/labels.js +8 -22
  26. package/dist/host/pack-archive.d.ts +4 -10
  27. package/dist/host/pack-archive.js +11 -14
  28. package/dist/host/pack-install.d.ts +10 -21
  29. package/dist/host/pack-install.js +22 -16
  30. package/dist/host/pack-trust-behavior.js +1 -1
  31. package/dist/host/run-behavior.d.ts +4 -0
  32. package/dist/host/run-behavior.js +9 -1
  33. package/dist/host/terminal-packs.d.ts +1 -1
  34. package/dist/html-engine.js +4 -4
  35. package/dist/index.d.ts +19 -81
  36. package/dist/index.js +19 -62
  37. package/dist/internal.d.ts +28 -0
  38. package/dist/internal.js +31 -0
  39. package/dist/node-fs.d.ts +0 -3
  40. package/dist/node-fs.js +1 -21
  41. package/dist/node-worker.d.ts +8 -0
  42. package/dist/node-worker.js +36 -15
  43. package/dist/node.d.ts +1 -2
  44. package/dist/node.js +4 -3
  45. package/dist/packs/discover.d.ts +2 -0
  46. package/dist/packs/discover.js +1 -0
  47. package/dist/run/bundle-run.d.ts +1 -1
  48. package/dist/run/bundle-run.js +1 -1
  49. package/dist/run/net-bridge.js +7 -5
  50. package/dist/run/net-pinning.d.ts +2 -0
  51. package/dist/run/net-pinning.js +17 -3
  52. package/dist/run/net-provider.js +23 -12
  53. package/dist/run/net-refusal.d.ts +4 -0
  54. package/dist/run/net-refusal.js +24 -0
  55. package/package.json +28 -12
@@ -6,7 +6,7 @@
6
6
  * discovers the authorized packs and reads each one's `terminal.js` text
7
7
  * through this module; the host then hands the text to the engine's own
8
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":
9
+ * for the failures in between (docs/hosts.md's "clean is not silent":
10
10
  * a failure reaches the diagnostics surface and the note shows the pack's
11
11
  * components as a failed pack).
12
12
  *
@@ -1,9 +1,9 @@
1
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
2
+ * The `@markii/host/html-engine` entry: the `@markii/html`-backed
3
+ * `HtmlExportEngine`. Kept out of the main and `/node` entries (it is the
4
+ * one module that needs the optional `@markii/html` peer); a host that
4
5
  * exports HTML builds it here and hands it to `createMarkiiHost`'s
5
- * `htmlEngine` option or to `buildNoteExport`. Reached through
6
- * `@markii/host/node`.
6
+ * `htmlEngine` option or to `buildNoteExport`.
7
7
  */
8
8
  import { escapeHtml, exportHtmlDocument, renderMarkToHtml } from '@markii/html';
9
9
  import { defaultHtmlRegistry } from '@markii/html/components';
package/dist/index.d.ts CHANGED
@@ -1,95 +1,33 @@
1
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';
2
+ export type { RunJob, RunResult, RunFailure, SpawnRunOptions, SpawnRunRequest, } from './run/run-host.js';
6
3
  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';
4
+ export type { RunOnceOptions, RunOnceResult } from './run/run-flow.js';
5
+ export type { GrantMemento, PromptHost, PromptManyHosts, PromptUnknownHosts, Thenable, } from './run/grant-flow.js';
6
+ export type { BuildBundleSnapshotOptions, BundleSnapshotResult, } from './run/bundle-run.js';
7
+ export { buildBundleSnapshot } from './run/bundle-run.js';
18
8
  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';
9
+ export type { HtmlExportEngine, ExportBodyRenderer, ExportBodyResult, ExportPackStylesheet, ExportRenderInfo, StaticExportReason, } from './export/note-export.js';
27
10
  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';
11
+ export type { PinPolicy } from './run/net-pinning.js';
41
12
  export type { PackModulesMap } from './run/lua-resolver.js';
42
- export { createPackModuleResolver } from './run/lua-resolver.js';
43
13
  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';
14
+ export { discoverPacks } from './packs/discover.js';
52
15
  export type { BuildRenderRegistryResult, DuplicateComposedName, PackRegistryEngine, QueuedPackRegistration, } from './packs/pack-render-registry.js';
53
16
  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
17
  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
18
  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
19
  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';
20
+ export { installPackMessage } from './host/pack-install.js';
21
+ export type { PackDiscoveryIo } from './host/pack-load.js';
22
+ export type { TerminalPackScript } from './host/terminal-packs.js';
82
23
  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
24
  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';
25
+ export { disablePackMessage, enablePackMessage, } from './host/pack-trust-behavior.js';
26
+ export { removePackMessage } from './host/pack-remove.js';
27
+ export { exportResultMessage } from './host/export-behavior.js';
28
+ export { cascadeResultMessage } from './host/cascade-export-behavior.js';
29
+ export type { CascadeLinkResolver, CascadeTruncation, } from './export/cascade.js';
30
+ export type { CascadeExportedNote, UnreadableCascadeNote, } from './host/cascade-export-behavior.js';
93
31
  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';
32
+ export type { CompleteOutcome, EditorPositionRequest, ExportLinkedSetOutcome, ExportLinkedSetRequest, ExportOutcome, ExportRequest, HoverOutcome, InsertComponentRequest, InstallPackOutcome, InstallPackRequest, LoadPacksOutcome, LoadTerminalPacksOutcome, MarkiiHost, MarkiiHostOptions, OpenOutcome, OpenRequest, RemovePackResult, DisablePackResult, EnablePackResult, InstalledPacksOutcome, RunOutcome, RunRequest, Unsupported, } from './host/create-host.js';
33
+ export { netRefusal } from './run/net-refusal.js';
package/dist/index.js CHANGED
@@ -1,69 +1,26 @@
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).
1
+ // @markii/host: the main entry. It carries what a host author needs to
2
+ // write a host against `createMarkiiHost`: the factory, the adapter and its
3
+ // capability groups, the request and outcome types, the labels type, the
4
+ // outcome wording helpers, bundle snapshots and pack discovery.
5
+ //
3
6
  // Environment-neutral: nothing reachable from this entry imports `node:*`,
4
7
  // `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`. See AGENTS.md's repo-layout entry for
8
- // `packages/markii-host` for the module-by-module breakdown.
8
+ // (`src/neutral-entries.probe.test.ts` bundles it for a browser to prove it).
9
+ // What needs Node lives in `./node.ts`; this repository's own apps reach the
10
+ // lower-level helpers through `./internal.ts`, which carries no semver
11
+ // promise. The editor seam is `@markii/stdlib/editor`, imported directly.
9
12
  //
10
13
  // This is the security-critical layer (tier gating, the grant model,
11
- // DNS/address pinning, the terminatable-isolate watchdog) — a second,
12
- // drifting copy of any of this is the one outcome to avoid, which is why
13
- // it lives here instead of inside `apps/vscode`.
14
- export { mergeArrivingValue } from './values-merge.js';
15
- export { isRunProgress } from './run/run-progress.js';
16
- export { spawnRun } from './run/run-host.js';
17
- export { createBrowserIsolate } from './run/browser-isolate.js';
18
- export { isNetBridgeRequest, serveNetRequest } from './run/net-bridge.js';
19
- export { MAX_CACHE_SNAPSHOT_BYTES, MAX_VALUES_SNAPSHOT_BYTES, cacheStorageKeyFor, isCacheSnapshotShape, mergePersistedValues, readPersistedValues, runOnce, serializeCacheSnapshotIfSmallEnough, valuesStorageKeyFor, } from './run/run-flow.js';
20
- export { ALLOW_LABEL, DONT_ALLOW_LABEL, MAX_HOST_PROMPTS, UNKNOWN_HOSTS_PROMPT_MESSAGE, clearGrantForDocument, hostPromptMessage, isSafeHostForPrompt, manyHostsPromptMessage, resolveStoredGrant, runGrantFlow, } from './run/grant-flow.js';
21
- 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';
22
- export { BUNDLE_EXTENSION, DEFAULT_BUNDLE_DOCUMENT_PATH, LEGACY_BUNDLE_EXTENSION, isBundleName, resolveBundleDocumentPath, } from './run/bundle-document.js';
23
- export { isRunTrace, lastRunStorageKeyFor, readLastRunTrace, writeLastRunTrace, } from './run/run-trace.js';
24
- export { extractRunRequirements } from './run/script-requirements.js';
25
- export { createSnapshotStorage } from './run/snapshot-storage.js';
26
- export { staleValuesForRehydration } from './run/stale-values.js';
27
- 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';
28
- export { EMBEDDABLE_IMAGE_EXTENSIONS, EMPTY_IMAGE_REPORT, MAX_EMBEDDED_IMAGE_BYTES, embedImagesInHtml, encodeBase64, isEmbeddableImageSrc, mimeTypeForImageSrc, toImageDataUri, } from './export/image-embed.js';
29
- export { extractNoteLinks, isLocalNoteTarget, maskCodeRegions, rewriteNoteLinks, } from './export/note-links.js';
30
- export { CASCADE_INDEX_FILE_NAME, DEFAULT_CASCADE_MAX_DEPTH, DEFAULT_CASCADE_MAX_NOTES, assignCascadeFileNames, rewriteCascadeLinks, walkNoteCascade, } from './export/cascade.js';
31
- export { buildCascadeArchive, cascadeDiagnosticLines, cascadeReasonOf, cascadeResultMessage, countedNoun, } from './host/cascade-export-behavior.js';
32
- export { zipExportArchive } from './export/export-zip.js';
33
- export { pinHostAddress, pinnedLookup } from './run/net-pinning.js';
34
- export { classifyIpAddress, describeScope, isRestrictedScope, } from './run/ip-address.js';
35
- export { createPackModuleResolver } from './run/lua-resolver.js';
36
- export { componentsWithoutEngineView, declaredPackComponents, discoverPacks, installedNamespaces, } from './packs/discover.js';
37
- export { loadPackModules } from './packs/pack-scripts.js';
38
- export { relativePackEntries, resolvePackPaths } from './packs/pack-paths.js';
39
- export { formatPackDiagnosticLines, skippedPackCount, } from './packs/pack-diagnostics.js';
40
- export { PREBUILT_SCRIPT_FILENAME, PREBUILT_STYLESHEET_FILENAME, PREBUILT_TERMINAL_SCRIPT_FILENAME, emptyWebviewScript, prebuiltScriptPathFor, prebuiltStylesheetPathFor, prebuiltTerminalScriptPathFor, resolvePrebuiltPack, } from './packs/prebuilt.js';
14
+ // address pinning, the terminatable-isolate watchdog): one copy lives here
15
+ // so no app grows a drifting second one.
16
+ export { buildBundleSnapshot } from './run/bundle-run.js';
17
+ export { discoverPacks } from './packs/discover.js';
41
18
  export { buildRenderRegistry } from './packs/pack-render-registry.js';
42
- export { componentSkeleton, offsetToLineColumn } from '@markii/stdlib/editor';
43
- export { LAYOUT_WRAPPER_NAMES } from '@markii/stdlib/editor';
44
19
  export { buildComponentCatalog } from './insert/component-catalog.js';
45
- export { completionAt, componentDocumentation, formatComponentDocumentation, hoverAt, } from '@markii/stdlib/editor';
46
- export { closesOpenContainerFence, enclosingContainerFences, fenceExtensionEdits, insertedContainerColonCount, } from '@markii/stdlib/editor';
47
- // Render-time diagnostics: one event from either renderer's `onDiagnostic`
48
- // option becomes the one line both hosts write to their diagnostics
49
- // surface.
50
- export { createRenderDiagnosticCollector, createRenderDiagnosticReporter, renderDiagnosticLine, } from './diagnostics/render-diagnostics.js';
51
- export { BROWSER_ISOLATE_ENTRY } from './host/adapter.js';
52
- export { CLI_LABELS, OBSIDIAN_LABELS, VSCODE_LABELS, packsNotInstalledLabel, } from './host/labels.js';
53
- export { scheduledRefreshNotStartedLine, scriptsDisabledConfirmationText, scriptsDisabledDiagnosticLine, scriptsDisabledNotice, scriptsDisabledNoticeText, scriptsEnabledConfirmationText, } from './host/script-execution.js';
54
- export { MIN_REFRESH_INTERVAL_SECONDS, parseRefreshIntervalSeconds, refreshIntervalMsFromSeconds, refreshIntervalValidationMessage, } from './host/refresh-interval.js';
55
- export { promptsFromAdapter, runViaAdapter, spawnRunViaAdapter, RUN_TIMEOUT_MS as HOST_RUN_TIMEOUT_MS, } from './host/run-behavior.js';
56
- export { formatRunFailureLines, runDiagnosticLines, } from './host/run-diagnostics.js';
57
- export { describeArchiveError, writeArchiveContents, } from './host/pack-archive.js';
58
- export { installConsentMessage, installPackDiagnosticLines, installPackFromArchive, installPackMessage, installReplaceConfirmMessage, } from './host/pack-install.js';
59
- export { discoverConfiguredPacks, loadPacksViaAdapter, packDiscoveryIoFromAdapter, } from './host/pack-load.js';
60
- export { prebuiltShadowLine } from './packs/pack-diagnostics.js';
61
- export { packHasTerminalViews, readTerminalPackScripts, terminalScriptMissingLine, terminalScriptNamespaceMismatchLine, terminalScriptRejectedLine, terminalScriptUnreadableLine, } from './host/terminal-packs.js';
62
- export { DEFAULT_PACK_TRUST_LIST, MAX_TRUSTED_PACKS, PACK_TRUST_STORAGE_KEY, isPackTrusted, normalizePackTrustList, trustPack, untrustPack, } from './packs/pack-trust.js';
63
- export { disablePackMessage, enablePackMessage, notEnabledPackDiagnosticLine, selectEnabledPacks, } from './host/pack-trust-behavior.js';
64
- export { removePackDiagnosticLine, removePackMessage, removePackViaAdapter, } from './host/pack-remove.js';
65
- export { mdPlainFromSource } from './host/export/md-plain.js';
66
- export { buildExportDocument, exportDefaultFileName, exportDiagnosticLines, exportNoteFileViaAdapter, exportResultMessage, fileNameOf, formatByteSize, imageEmbedDiagnosticLines, renderEngineDiagnosticLine, } from './host/export-behavior.js';
67
- export { LAYOUT_ORIGIN_TAG, STANDARD_ORIGIN_TAG, completeAtViaEditor, completionOriginTag, completionPlanAt, createCatalogCache, hoverAtViaEditor, hoverDocumentationText, insertComponentPlan, isContainerCompletionItem, } from './host/editor-behavior.js';
20
+ export { installPackMessage } from './host/pack-install.js';
21
+ export { disablePackMessage, enablePackMessage, } from './host/pack-trust-behavior.js';
22
+ export { removePackMessage } from './host/pack-remove.js';
23
+ export { exportResultMessage } from './host/export-behavior.js';
24
+ export { cascadeResultMessage } from './host/cascade-export-behavior.js';
68
25
  export { createMarkiiHost } from './host/create-host.js';
69
- export { joinPath, dirnamePath, isAbsolutePath } from './path-util.js';
26
+ export { netRefusal } from './run/net-refusal.js';
@@ -0,0 +1,28 @@
1
+ export { mergeArrivingValue } from './values-merge.js';
2
+ export { isRunProgress } from './run/run-progress.js';
3
+ export { isNetBridgeRequest, serveNetRequest } from './run/net-bridge.js';
4
+ export type { NetBridgeReply } from './run/net-bridge.js';
5
+ export { MAX_VALUES_SNAPSHOT_BYTES, readPersistedValues, runOnce, valuesStorageKeyFor, } from './run/run-flow.js';
6
+ export { ALLOW_LABEL, DONT_ALLOW_LABEL, clearGrantForDocument, } from './run/grant-flow.js';
7
+ export { decodeBundleCacheFromStorage, encodeBundleCacheForStorage, withPersistedCache, } from './run/bundle-run.js';
8
+ export { isBundleName, resolveBundleDocumentPath, } from './run/bundle-document.js';
9
+ export { readLastRunTrace } from './run/run-trace.js';
10
+ export { staleValuesForRehydration } from './run/stale-values.js';
11
+ export { MARK_EXTENSION, buildNoteHtmlExport, composeNoteHtmlExport, noteHasScripts, exportBaseName, exportedSiblingPath, } from './export/note-export.js';
12
+ export { EMPTY_IMAGE_REPORT, MAX_EMBEDDED_IMAGE_BYTES, embedImagesInHtml, } from './export/image-embed.js';
13
+ export { cascadeDiagnosticLines } from './host/cascade-export-behavior.js';
14
+ export { componentsWithoutEngineView, declaredPackComponents, installedNamespaces, } from './packs/discover.js';
15
+ export { loadPackModules } from './packs/pack-scripts.js';
16
+ export { relativePackEntries, resolvePackPaths } from './packs/pack-paths.js';
17
+ export { formatPackDiagnosticLines, skippedPackCount, prebuiltShadowLine, } from './packs/pack-diagnostics.js';
18
+ export type { PackPathExists } from './packs/prebuilt.js';
19
+ export { PREBUILT_SCRIPT_FILENAME, PREBUILT_STYLESHEET_FILENAME, PREBUILT_TERMINAL_SCRIPT_FILENAME, emptyWebviewScript, resolvePrebuiltPack, } from './packs/prebuilt.js';
20
+ export { createRenderDiagnosticCollector, createRenderDiagnosticReporter, } from './diagnostics/render-diagnostics.js';
21
+ export { packsNotInstalledLabel } from './host/labels.js';
22
+ export { scheduledRefreshNotStartedLine, scriptsDisabledConfirmationText, scriptsDisabledDiagnosticLine, scriptsDisabledNotice, scriptsDisabledNoticeText, scriptsEnabledConfirmationText, } from './host/script-execution.js';
23
+ export { MIN_REFRESH_INTERVAL_SECONDS, parseRefreshIntervalSeconds, refreshIntervalMsFromSeconds, refreshIntervalValidationMessage, } from './host/refresh-interval.js';
24
+ export { discoverConfiguredPacks } from './host/pack-load.js';
25
+ export { packHasTerminalViews, terminalScriptNamespaceMismatchLine, terminalScriptRejectedLine, } from './host/terminal-packs.js';
26
+ export { mdPlainFromSource } from './host/export/md-plain.js';
27
+ export { exportDefaultFileName, fileNameOf } from './host/export-behavior.js';
28
+ export { completionOriginTag, isContainerCompletionItem, } from './host/editor-behavior.js';
@@ -0,0 +1,31 @@
1
+ // @markii/host/internal: the lower-level helpers this repository's own apps
2
+ // and `@markii/pack-build` build on. It carries NO semver promise: a name
3
+ // here can change or disappear in any release. An outside host should use
4
+ // the main entry. Environment-neutral like the main entry
5
+ // (`src/neutral-entries.probe.test.ts` bundles it for a browser).
6
+ export { mergeArrivingValue } from './values-merge.js';
7
+ export { isRunProgress } from './run/run-progress.js';
8
+ export { isNetBridgeRequest, serveNetRequest } from './run/net-bridge.js';
9
+ export { MAX_VALUES_SNAPSHOT_BYTES, readPersistedValues, runOnce, valuesStorageKeyFor, } from './run/run-flow.js';
10
+ export { ALLOW_LABEL, DONT_ALLOW_LABEL, clearGrantForDocument, } from './run/grant-flow.js';
11
+ export { decodeBundleCacheFromStorage, encodeBundleCacheForStorage, withPersistedCache, } from './run/bundle-run.js';
12
+ export { isBundleName, resolveBundleDocumentPath, } from './run/bundle-document.js';
13
+ export { readLastRunTrace } from './run/run-trace.js';
14
+ export { staleValuesForRehydration } from './run/stale-values.js';
15
+ export { MARK_EXTENSION, buildNoteHtmlExport, composeNoteHtmlExport, noteHasScripts, exportBaseName, exportedSiblingPath, } from './export/note-export.js';
16
+ export { EMPTY_IMAGE_REPORT, MAX_EMBEDDED_IMAGE_BYTES, embedImagesInHtml, } from './export/image-embed.js';
17
+ export { cascadeDiagnosticLines } from './host/cascade-export-behavior.js';
18
+ export { componentsWithoutEngineView, declaredPackComponents, installedNamespaces, } from './packs/discover.js';
19
+ export { loadPackModules } from './packs/pack-scripts.js';
20
+ export { relativePackEntries, resolvePackPaths } from './packs/pack-paths.js';
21
+ export { formatPackDiagnosticLines, skippedPackCount, prebuiltShadowLine, } from './packs/pack-diagnostics.js';
22
+ export { PREBUILT_SCRIPT_FILENAME, PREBUILT_STYLESHEET_FILENAME, PREBUILT_TERMINAL_SCRIPT_FILENAME, emptyWebviewScript, resolvePrebuiltPack, } from './packs/prebuilt.js';
23
+ export { createRenderDiagnosticCollector, createRenderDiagnosticReporter, } from './diagnostics/render-diagnostics.js';
24
+ export { packsNotInstalledLabel } from './host/labels.js';
25
+ export { scheduledRefreshNotStartedLine, scriptsDisabledConfirmationText, scriptsDisabledDiagnosticLine, scriptsDisabledNotice, scriptsDisabledNoticeText, scriptsEnabledConfirmationText, } from './host/script-execution.js';
26
+ export { MIN_REFRESH_INTERVAL_SECONDS, parseRefreshIntervalSeconds, refreshIntervalMsFromSeconds, refreshIntervalValidationMessage, } from './host/refresh-interval.js';
27
+ export { discoverConfiguredPacks } from './host/pack-load.js';
28
+ export { packHasTerminalViews, terminalScriptNamespaceMismatchLine, terminalScriptRejectedLine, } from './host/terminal-packs.js';
29
+ export { mdPlainFromSource } from './host/export/md-plain.js';
30
+ export { exportDefaultFileName, fileNameOf } from './host/export-behavior.js';
31
+ export { completionOriginTag, isContainerCompletionItem, } from './host/editor-behavior.js';
package/dist/node-fs.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import type { ArchiveExtractFs } from './host/pack-archive.js';
2
1
  import type { PackDiscoveryIo } from './host/pack-load.js';
3
2
  import type { PackDirectoryLister, PackFileReader } from './packs/discover.js';
4
3
  import type { PackScriptsReader } from './packs/pack-scripts.js';
@@ -8,7 +7,5 @@ export declare function createNodeDirectoryLister(): PackDirectoryLister;
8
7
  export declare function createNodeFileReader(): PackFileReader;
9
8
  /** The real, Node-backed `PackScriptsReader`. */
10
9
  export declare function createNodeReader(): PackScriptsReader;
11
- /** The real, Node-backed `ArchiveExtractFs`. */
12
- export declare function createNodeArchiveExtractFs(): ArchiveExtractFs;
13
10
  /** Pack discovery's reads over the real file system. */
14
11
  export declare function createNodePackDiscoveryIo(): PackDiscoveryIo;
package/dist/node-fs.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * extraction filesystem. Reached only through `@markii/host/node`; nothing
6
6
  * in the main entry imports this module.
7
7
  */
8
- import { mkdir, readFile, readdir, rm, writeFile } from 'node:fs/promises';
8
+ import { readFile, readdir } from 'node:fs/promises';
9
9
  /** The real, Node-backed `PackDirectoryLister`. Never rejects: an unreadable, missing or non-directory path resolves `[]`. */
10
10
  export function createNodeDirectoryLister() {
11
11
  return async (absoluteDir) => {
@@ -41,26 +41,6 @@ export function createNodeReader() {
41
41
  readFile: (absolutePath) => readText(absolutePath),
42
42
  };
43
43
  }
44
- /** The real, Node-backed `ArchiveExtractFs`. */
45
- export function createNodeArchiveExtractFs() {
46
- return {
47
- removeDirectory: async (absolutePath) => {
48
- try {
49
- await rm(absolutePath, { recursive: true, force: true });
50
- }
51
- catch {
52
- // Quiet: the write that follows fails loudly on its own if the
53
- // path is genuinely unusable.
54
- }
55
- },
56
- makeDirectory: async (absolutePath) => {
57
- await mkdir(absolutePath, { recursive: true });
58
- },
59
- writeFile: async (absolutePath, bytes) => {
60
- await writeFile(absolutePath, bytes);
61
- },
62
- };
63
- }
64
44
  /** Pack discovery's reads over the real file system. */
65
45
  export function createNodePackDiscoveryIo() {
66
46
  return {
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The `@markii/host/node-worker` entry: the worker_threads isolate a Node
3
+ * host spawns by file path. Bundling this file produces the one
4
+ * self-contained worker (`dist/node-worker.js` for the package, a host's
5
+ * own `dist/run/worker.js` for an app that embeds it). It has no exports:
6
+ * loading it starts the worker's message loop.
7
+ */
8
+ import './run/worker-entry.js';
@@ -6072,6 +6072,12 @@ import * as http from "node:http";
6072
6072
  import * as https from "node:https";
6073
6073
  import * as dns from "node:dns";
6074
6074
 
6075
+ // src/run/net-refusal.ts
6076
+ var NET_REFUSAL = /* @__PURE__ */ Symbol.for("markii.net.refusal");
6077
+ function netRefusal(error) {
6078
+ return Object.assign(error, { [NET_REFUSAL]: true });
6079
+ }
6080
+
6075
6081
  // src/run/ip-address.ts
6076
6082
  function isIPv4(value2) {
6077
6083
  const parts = value2.split(".");
@@ -6257,29 +6263,43 @@ async function pinHostAddress(hostname, policy, lookup) {
6257
6263
  try {
6258
6264
  addresses = await lookup(hostname);
6259
6265
  } catch {
6260
- return { ok: false, reason: `host "${hostname}" could not be resolved` };
6266
+ return {
6267
+ ok: false,
6268
+ kind: "unresolved",
6269
+ reason: `host "${hostname}" could not be resolved`
6270
+ };
6261
6271
  }
6262
6272
  if (addresses.length === 0) {
6263
- return { ok: false, reason: `host "${hostname}" resolved to no address` };
6273
+ return {
6274
+ ok: false,
6275
+ kind: "unresolved",
6276
+ reason: `host "${hostname}" resolved to no address`
6277
+ };
6264
6278
  }
6265
6279
  for (const candidate of addresses) {
6266
6280
  const scope2 = classifyIpAddress(candidate.address);
6267
6281
  if (scope2 === void 0) {
6268
6282
  return {
6269
6283
  ok: false,
6284
+ kind: "refused",
6270
6285
  reason: `host "${hostname}" resolved to an unusable address`
6271
6286
  };
6272
6287
  }
6273
6288
  if (isRestrictedScope(scope2) && !policy.allowRestrictedAddresses) {
6274
6289
  return {
6275
6290
  ok: false,
6291
+ kind: "refused",
6276
6292
  reason: `host "${hostname}" resolves to ${describeScope(scope2)}`
6277
6293
  };
6278
6294
  }
6279
6295
  }
6280
6296
  const chosen = addresses[0];
6281
6297
  if (chosen === void 0) {
6282
- return { ok: false, reason: `host "${hostname}" resolved to no address` };
6298
+ return {
6299
+ ok: false,
6300
+ kind: "unresolved",
6301
+ reason: `host "${hostname}" resolved to no address`
6302
+ };
6283
6303
  }
6284
6304
  const scope = classifyIpAddress(chosen.address) ?? "reserved";
6285
6305
  return {
@@ -6396,12 +6416,12 @@ function issueRequest(url, method, body, pinned, maxFetchBytes, denial, signal)
6396
6416
  }
6397
6417
  );
6398
6418
  req.on("error", (err) => {
6399
- settleReject(denial(`request failed: ${describeThrown2(err)}`));
6419
+ settleReject(new Error(`request failed: ${describeThrown2(err)}`));
6400
6420
  });
6401
6421
  if (signal !== void 0) {
6402
6422
  const onAbort = () => {
6403
6423
  req.destroy();
6404
- settleReject(denial("the run has ended"));
6424
+ settleReject(new Error("the run has ended"));
6405
6425
  };
6406
6426
  if (signal.aborted) onAbort();
6407
6427
  else signal.addEventListener("abort", onAbort, { once: true });
@@ -6412,6 +6432,7 @@ function issueRequest(url, method, body, pinned, maxFetchBytes, denial, signal)
6412
6432
  }
6413
6433
  function createNetProvider(allowlist, maxFetchBytes, policy, denial, lookup = defaultHostLookup, signal) {
6414
6434
  const allowed = new Set(allowlist.map((host) => host.toLowerCase()));
6435
+ const refuse = (message) => netRefusal(denial(message));
6415
6436
  async function fetchAllowed(startUrl, method, body) {
6416
6437
  let currentUrl = startUrl;
6417
6438
  for (let hop = 0; hop <= MAX_REDIRECTS; hop++) {
@@ -6419,24 +6440,24 @@ function createNetProvider(allowlist, maxFetchBytes, policy, denial, lookup = de
6419
6440
  try {
6420
6441
  parsed = new URL(currentUrl);
6421
6442
  } catch {
6422
- throw denial(`"${currentUrl}" is not a valid URL`);
6443
+ throw refuse(`"${currentUrl}" is not a valid URL`);
6423
6444
  }
6424
6445
  if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
6425
- throw denial(`scheme "${parsed.protocol}" is not allowed`);
6446
+ throw refuse(`scheme "${parsed.protocol}" is not allowed`);
6426
6447
  }
6427
6448
  if (parsed.username !== "" || parsed.password !== "") {
6428
- throw denial(
6449
+ throw refuse(
6429
6450
  `URL "${currentUrl}" embeds credentials, which is not allowed`
6430
6451
  );
6431
6452
  }
6432
- if (signal?.aborted) throw denial("the run has ended");
6453
+ if (signal?.aborted) throw new Error("the run has ended");
6433
6454
  const host = parsed.hostname.toLowerCase();
6434
6455
  if (!allowed.has(host)) {
6435
- throw denial(`host "${host}" is not on the run's allowlist`);
6456
+ throw refuse(`host "${host}" is not on the run's allowlist`);
6436
6457
  }
6437
6458
  const pinResult = await pinHostAddress(host, policy, lookup);
6438
6459
  if (!pinResult.ok) {
6439
- throw denial(pinResult.reason);
6460
+ throw pinResult.kind === "unresolved" ? new Error(pinResult.reason) : refuse(pinResult.reason);
6440
6461
  }
6441
6462
  const response = await issueRequest(
6442
6463
  parsed,
@@ -6444,17 +6465,17 @@ function createNetProvider(allowlist, maxFetchBytes, policy, denial, lookup = de
6444
6465
  body,
6445
6466
  pinResult.pinned,
6446
6467
  maxFetchBytes,
6447
- denial,
6468
+ refuse,
6448
6469
  signal
6449
6470
  );
6450
6471
  if (response.status >= 300 && response.status < 400) {
6451
6472
  if (!response.location) {
6452
- throw denial("redirect response carried no Location header");
6473
+ throw refuse("redirect response carried no Location header");
6453
6474
  }
6454
6475
  try {
6455
6476
  currentUrl = new URL(response.location, currentUrl).toString();
6456
6477
  } catch {
6457
- throw denial(
6478
+ throw refuse(
6458
6479
  "redirect response carried an unparseable Location header"
6459
6480
  );
6460
6481
  }
@@ -6462,7 +6483,7 @@ function createNetProvider(allowlist, maxFetchBytes, policy, denial, lookup = de
6462
6483
  }
6463
6484
  return { status: response.status, body: response.body };
6464
6485
  }
6465
- throw denial(`exceeded ${MAX_REDIRECTS} redirects`);
6486
+ throw refuse(`exceeded ${MAX_REDIRECTS} redirects`);
6466
6487
  }
6467
6488
  return {
6468
6489
  get: (url) => fetchAllowed(url, "GET", void 0),
package/dist/node.d.ts CHANGED
@@ -2,5 +2,4 @@ export type { SpawnRunOptions } from './run/run-host.js';
2
2
  export type { NodeHostIsolateOptions } from './run/node-isolate.js';
3
3
  export { createNodeHostIsolate, workerThreadIsolate, } from './run/node-isolate.js';
4
4
  export { createNetProvider } from './run/net-provider.js';
5
- export { createNodeArchiveExtractFs, createNodeDirectoryLister, createNodeFileReader, createNodePackDiscoveryIo, createNodeReader as createNodePackScriptsReader, } from './node-fs.js';
6
- export { createHtmlExportEngine } from './html-engine.js';
5
+ export { createNodeDirectoryLister, createNodeFileReader, createNodePackDiscoveryIo, createNodeReader as createNodePackScriptsReader, } from './node-fs.js';
package/dist/node.js CHANGED
@@ -4,10 +4,11 @@
4
4
  // The main entry (`./index.ts`) is environment-neutral. This entry adds:
5
5
  // - the worker_threads isolate and the pinned network provider (`node:*`);
6
6
  // - the Node-backed file-system seams the neutral code takes by injection;
7
- // - the `@markii/html`-backed static export engine;
7
+ //
8
+ // The `@markii/html`-backed static export engine is its own entry,
9
+ // `@markii/host/html-engine`, so importing this one needs no optional peer.
8
10
  //
9
11
  // A Node host imports from both entries. No browser bundle imports this one.
10
12
  export { createNodeHostIsolate, workerThreadIsolate, } from './run/node-isolate.js';
11
13
  export { createNetProvider } from './run/net-provider.js';
12
- export { createNodeArchiveExtractFs, createNodeDirectoryLister, createNodeFileReader, createNodePackDiscoveryIo, createNodeReader as createNodePackScriptsReader, } from './node-fs.js';
13
- export { createHtmlExportEngine } from './html-engine.js';
14
+ export { createNodeDirectoryLister, createNodeFileReader, createNodePackDiscoveryIo, createNodeReader as createNodePackScriptsReader, } from './node-fs.js';
@@ -30,6 +30,8 @@ export interface DiscoveredPack {
30
30
  /** The configured folder this pack was discovered in (absolute path, as given). */
31
31
  readonly folder: string;
32
32
  readonly manifest: PackManifest;
33
+ /** The exact text of the pack's `pack.json`, as read. A compiled script registers this text unchanged. Discovery always sets it; it is absent only on a pack a host assembled by hand. */
34
+ readonly manifestText?: string;
33
35
  /** Local component name -> absolute path to its declared source file (`manifest.components[name]`, resolved against `folder`). Informational: what a host consumes them for (bundling, `import()`, or locating the pack's prebuilt registration script) is that host's own concern. */
34
36
  readonly componentPaths: Readonly<Record<string, string>>;
35
37
  /** Engine id -> (local component name -> absolute source path), for every engine any component declares a source for. `componentPaths` is the `react` slice of this. A terminal build (`ansi`) reads its slice here. */
@@ -102,6 +102,7 @@ async function tryLoadPackAt(folder, readFile) {
102
102
  pack: {
103
103
  folder,
104
104
  manifest: result.manifest,
105
+ manifestText: text,
105
106
  componentPaths,
106
107
  componentPathsByEngine,
107
108
  scriptsDir: joinPath(folder, 'scripts'),
@@ -141,7 +141,7 @@ export declare function manifestNetHosts(manifest: BundleManifest): string[];
141
141
  *
142
142
  * A mismatch between the two is not silently absorbed: this pure function
143
143
  * returns one diagnostics line per mismatched host, in both directions, for
144
- * the host's diagnostics surface (docs/integration.md) — never the rendered
144
+ * the host's diagnostics surface (docs/hosts.md) — never the rendered
145
145
  * page. Wording lives here, the one place both apps' adapters read it from,
146
146
  * so it can never drift between VS Code's output channel and Obsidian's
147
147
  * console/notice surface.
@@ -142,7 +142,7 @@ export function manifestNetHosts(manifest) {
142
142
  *
143
143
  * A mismatch between the two is not silently absorbed: this pure function
144
144
  * returns one diagnostics line per mismatched host, in both directions, for
145
- * the host's diagnostics surface (docs/integration.md) — never the rendered
145
+ * the host's diagnostics surface (docs/hosts.md) — never the rendered
146
146
  * page. Wording lives here, the one place both apps' adapters read it from,
147
147
  * so it can never drift between VS Code's output channel and Obsidian's
148
148
  * console/notice surface.
@@ -1,3 +1,4 @@
1
+ import { isNetRefusal } from './net-refusal.js';
1
2
  export function isNetBridgeRequest(value) {
2
3
  if (typeof value !== 'object' || value === null)
3
4
  return false;
@@ -49,11 +50,12 @@ export async function serveNetRequest(request, provider, post) {
49
50
  id: request.id,
50
51
  ok: false,
51
52
  error: error instanceof Error ? error.message : String(error),
52
- // Everything the host's provider refuses IS a policy denial: the
53
- // provider's own failures are allowlist, redirect, size, and pinning
54
- // refusals. Marking them so keeps the worker's classification
55
- // identical to the in-worker case.
56
- denied: true,
53
+ // A policy refusal (allowlist, redirect, size, address range) is
54
+ // marked by the provider and crosses as a denial, so the worker
55
+ // classifies it exactly as it would in-worker. A transport failure
56
+ // (DNS, connection, timeout, abort) is unmarked and crosses as an
57
+ // ordinary failure with its reason. Both reach the script as errors.
58
+ denied: isNetRefusal(error),
57
59
  });
58
60
  }
59
61
  }
@@ -40,6 +40,8 @@ export type PinResult = {
40
40
  } | {
41
41
  ok: false;
42
42
  reason: string;
43
+ /** `unresolved`: the name did not resolve (a transport failure). `refused`: the address policy refused it. */
44
+ kind: 'unresolved' | 'refused';
43
45
  };
44
46
  export interface PinPolicy {
45
47
  /**