@markii/host 0.17.0-next.3 → 0.17.0-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/browser-worker.classic.js +640 -0
- package/dist/browser-worker.js +19 -19
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +10 -3
- package/dist/conformance/host/05-export-html-pack-directive/expected.json +2 -0
- package/dist/conformance/host/06-install-pack-then-render/expected.json +6 -1
- package/dist/conformance/host/README.md +4 -2
- package/dist/export/note-export.d.ts +1 -1
- package/dist/host/adapter.d.ts +4 -2
- package/dist/host/conformance-runner.d.ts +0 -3
- package/dist/host/conformance-runner.js +18 -6
- package/dist/host/create-host.d.ts +25 -5
- package/dist/host/create-host.js +34 -23
- package/dist/host/export-behavior.d.ts +2 -1
- package/dist/host/export-behavior.js +1 -1
- package/dist/host/labels.d.ts +5 -14
- package/dist/host/labels.js +8 -22
- package/dist/host/pack-archive.d.ts +4 -10
- package/dist/host/pack-archive.js +11 -14
- package/dist/host/pack-install.d.ts +10 -21
- package/dist/host/pack-install.js +22 -16
- package/dist/html-engine.js +4 -4
- package/dist/index.d.ts +15 -80
- package/dist/index.js +18 -62
- package/dist/internal.d.ts +30 -0
- package/dist/internal.js +31 -0
- package/dist/node-fs.d.ts +0 -3
- package/dist/node-fs.js +1 -21
- package/dist/node-worker.d.ts +8 -0
- package/dist/node-worker.js +36 -15
- package/dist/node.d.ts +1 -2
- package/dist/node.js +4 -3
- package/dist/packs/discover.d.ts +2 -0
- package/dist/packs/discover.js +1 -0
- package/dist/run/net-bridge.js +7 -5
- package/dist/run/net-pinning.d.ts +2 -0
- package/dist/run/net-pinning.js +17 -3
- package/dist/run/net-provider.js +23 -12
- package/dist/run/net-refusal.d.ts +4 -0
- package/dist/run/net-refusal.js +24 -0
- package/package.json +28 -12
|
@@ -39,7 +39,7 @@ function describeThrown(err) {
|
|
|
39
39
|
* assume yes.
|
|
40
40
|
*/
|
|
41
41
|
export async function installPackFromArchive(adapter, options) {
|
|
42
|
-
const { archiveBytes, archivePath, installRoot, exists,
|
|
42
|
+
const { archiveBytes, archivePath, installRoot, exists, removeFolder, reservedNamespaces, } = options;
|
|
43
43
|
const opened = await openPackArchive(archiveBytes);
|
|
44
44
|
if (!opened.ok) {
|
|
45
45
|
return {
|
|
@@ -49,7 +49,7 @@ export async function installPackFromArchive(adapter, options) {
|
|
|
49
49
|
}
|
|
50
50
|
const packName = opened.archive.manifest.name;
|
|
51
51
|
if (reservedNamespaces.has(packName)) {
|
|
52
|
-
return { kind: 'reserved', packName };
|
|
52
|
+
return { kind: 'reserved', namespace: packName };
|
|
53
53
|
}
|
|
54
54
|
let consented;
|
|
55
55
|
try {
|
|
@@ -65,7 +65,7 @@ export async function installPackFromArchive(adapter, options) {
|
|
|
65
65
|
return { kind: 'rejected', reason: describeThrown(err) };
|
|
66
66
|
}
|
|
67
67
|
if (!consented) {
|
|
68
|
-
return { kind: 'declined', step: 'consent', packName };
|
|
68
|
+
return { kind: 'declined', step: 'consent', namespace: packName };
|
|
69
69
|
}
|
|
70
70
|
const targetDir = joinPath(installRoot, packName);
|
|
71
71
|
let alreadyInstalled;
|
|
@@ -91,13 +91,14 @@ export async function installPackFromArchive(adapter, options) {
|
|
|
91
91
|
return { kind: 'rejected', reason: describeThrown(err) };
|
|
92
92
|
}
|
|
93
93
|
if (!proceed) {
|
|
94
|
-
return { kind: 'declined', step: 'replace', packName };
|
|
94
|
+
return { kind: 'declined', step: 'replace', namespace: packName };
|
|
95
95
|
}
|
|
96
96
|
replaced = true;
|
|
97
97
|
}
|
|
98
98
|
try {
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
if (alreadyInstalled)
|
|
100
|
+
await removeFolder(targetDir);
|
|
101
|
+
await writeArchiveContents(opened.archive, targetDir, (path, bytes) => adapter.writeFile(path, bytes));
|
|
101
102
|
}
|
|
102
103
|
catch (err) {
|
|
103
104
|
return {
|
|
@@ -106,7 +107,12 @@ export async function installPackFromArchive(adapter, options) {
|
|
|
106
107
|
};
|
|
107
108
|
}
|
|
108
109
|
await trustInstalledPack(adapter, packName, targetDir);
|
|
109
|
-
return {
|
|
110
|
+
return {
|
|
111
|
+
kind: 'installed',
|
|
112
|
+
namespace: packName,
|
|
113
|
+
installedDir: targetDir,
|
|
114
|
+
replaced,
|
|
115
|
+
};
|
|
110
116
|
}
|
|
111
117
|
/**
|
|
112
118
|
* The consent prompt's wording (AGENTS.md's product principles: "clean is
|
|
@@ -147,21 +153,21 @@ export function installReplaceConfirmMessage(packName) {
|
|
|
147
153
|
* `false`.
|
|
148
154
|
*/
|
|
149
155
|
export function installPackMessage(outcome, archivePath, labels, reloadsAutomatically = false) {
|
|
150
|
-
if (outcome.kind === 'rejected') {
|
|
156
|
+
if (outcome.kind === 'rejected' || outcome.kind === 'unsupported') {
|
|
151
157
|
return `Markii: could not install a pack from "${archivePath}". Open ${labels.diagnosticsSurface} for details.`;
|
|
152
158
|
}
|
|
153
159
|
if (outcome.kind === 'reserved') {
|
|
154
|
-
return `Markii: "${outcome.
|
|
160
|
+
return `Markii: "${outcome.namespace}" is built in and cannot be installed. Nothing was installed.`;
|
|
155
161
|
}
|
|
156
162
|
if (outcome.kind === 'declined') {
|
|
157
163
|
return outcome.step === 'consent'
|
|
158
|
-
? `Markii: install of "${outcome.
|
|
159
|
-
: `Markii: install of "${outcome.
|
|
164
|
+
? `Markii: install of "${outcome.namespace}" cancelled. Nothing was installed.`
|
|
165
|
+
: `Markii: install of "${outcome.namespace}" cancelled. The existing pack was kept.`;
|
|
160
166
|
}
|
|
161
167
|
const reloadSuffix = reloadsAutomatically ? ' Markii packs reloaded.' : '';
|
|
162
168
|
return outcome.replaced
|
|
163
|
-
? `Markii: reinstalled pack "${outcome.
|
|
164
|
-
: `Markii: installed pack "${outcome.
|
|
169
|
+
? `Markii: reinstalled pack "${outcome.namespace}".${reloadSuffix}`
|
|
170
|
+
: `Markii: installed pack "${outcome.namespace}".${reloadSuffix}`;
|
|
165
171
|
}
|
|
166
172
|
/** The full diagnostics-surface detail for one install attempt (AGENTS.md's "clean is not silent": the other of a failure's two homes). */
|
|
167
173
|
export function installPackDiagnosticLines(outcome, archivePath) {
|
|
@@ -172,15 +178,15 @@ export function installPackDiagnosticLines(outcome, archivePath) {
|
|
|
172
178
|
}
|
|
173
179
|
if (outcome.kind === 'reserved') {
|
|
174
180
|
return [
|
|
175
|
-
`Install pack from file refused "${archivePath}": pack "${outcome.
|
|
181
|
+
`Install pack from file refused "${archivePath}": pack "${outcome.namespace}" is a reserved namespace and cannot be installed.`,
|
|
176
182
|
];
|
|
177
183
|
}
|
|
178
184
|
if (outcome.kind === 'declined') {
|
|
179
185
|
return [
|
|
180
|
-
`Install pack from file cancelled for "${archivePath}" (pack "${outcome.
|
|
186
|
+
`Install pack from file cancelled for "${archivePath}" (pack "${outcome.namespace}") at the ${outcome.step} step; nothing was installed.`,
|
|
181
187
|
];
|
|
182
188
|
}
|
|
183
189
|
return [
|
|
184
|
-
`Install pack from file installed pack "${outcome.
|
|
190
|
+
`Install pack from file installed pack "${outcome.namespace}" from "${archivePath}" to ${outcome.installedDir}${outcome.replaced ? ' (replacing the previous install)' : ''}.`,
|
|
185
191
|
];
|
|
186
192
|
}
|
package/dist/html-engine.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `@markii/html
|
|
3
|
-
*
|
|
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`.
|
|
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,30 @@
|
|
|
1
1
|
export type { ValuesFailure } from './values-failure.js';
|
|
2
|
-
export {
|
|
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 {
|
|
8
|
-
export type {
|
|
9
|
-
export {
|
|
10
|
-
export
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
73
|
-
export type {
|
|
74
|
-
export {
|
|
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,
|
|
87
|
-
export {
|
|
88
|
-
export {
|
|
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';
|
|
93
28
|
export { createMarkiiHost } from './host/create-host.js';
|
|
94
29
|
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 {
|
|
30
|
+
export { netRefusal } from './run/net-refusal.js';
|
package/dist/index.js
CHANGED
|
@@ -1,69 +1,25 @@
|
|
|
1
|
-
// @markii/host: the
|
|
2
|
-
//
|
|
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
|
-
// (`
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
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
|
-
//
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
export {
|
|
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 {
|
|
46
|
-
export {
|
|
47
|
-
|
|
48
|
-
|
|
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';
|
|
68
24
|
export { createMarkiiHost } from './host/create-host.js';
|
|
69
|
-
export {
|
|
25
|
+
export { netRefusal } from './run/net-refusal.js';
|
|
@@ -0,0 +1,30 @@
|
|
|
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 type { CascadeLinkResolver, CascadeNoteReader, } from './export/cascade.js';
|
|
14
|
+
export type { CascadeArchiveRequest, CascadeExportOutcome, } from './host/cascade-export-behavior.js';
|
|
15
|
+
export { buildCascadeArchive, cascadeDiagnosticLines, cascadeReasonOf, cascadeResultMessage, } from './host/cascade-export-behavior.js';
|
|
16
|
+
export { componentsWithoutEngineView, declaredPackComponents, installedNamespaces, } from './packs/discover.js';
|
|
17
|
+
export { loadPackModules } from './packs/pack-scripts.js';
|
|
18
|
+
export { relativePackEntries, resolvePackPaths } from './packs/pack-paths.js';
|
|
19
|
+
export { formatPackDiagnosticLines, skippedPackCount, prebuiltShadowLine, } from './packs/pack-diagnostics.js';
|
|
20
|
+
export type { PackPathExists } from './packs/prebuilt.js';
|
|
21
|
+
export { PREBUILT_SCRIPT_FILENAME, PREBUILT_STYLESHEET_FILENAME, PREBUILT_TERMINAL_SCRIPT_FILENAME, emptyWebviewScript, resolvePrebuiltPack, } from './packs/prebuilt.js';
|
|
22
|
+
export { createRenderDiagnosticCollector, createRenderDiagnosticReporter, } from './diagnostics/render-diagnostics.js';
|
|
23
|
+
export { packsNotInstalledLabel } from './host/labels.js';
|
|
24
|
+
export { scheduledRefreshNotStartedLine, scriptsDisabledConfirmationText, scriptsDisabledDiagnosticLine, scriptsDisabledNotice, scriptsDisabledNoticeText, scriptsEnabledConfirmationText, } from './host/script-execution.js';
|
|
25
|
+
export { MIN_REFRESH_INTERVAL_SECONDS, parseRefreshIntervalSeconds, refreshIntervalMsFromSeconds, refreshIntervalValidationMessage, } from './host/refresh-interval.js';
|
|
26
|
+
export { discoverConfiguredPacks } from './host/pack-load.js';
|
|
27
|
+
export { packHasTerminalViews, terminalScriptNamespaceMismatchLine, terminalScriptRejectedLine, } from './host/terminal-packs.js';
|
|
28
|
+
export { mdPlainFromSource } from './host/export/md-plain.js';
|
|
29
|
+
export { exportDefaultFileName, fileNameOf } from './host/export-behavior.js';
|
|
30
|
+
export { completionOriginTag, isContainerCompletionItem, } from './host/editor-behavior.js';
|
package/dist/internal.js
ADDED
|
@@ -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 { buildCascadeArchive, cascadeDiagnosticLines, cascadeReasonOf, cascadeResultMessage, } 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 {
|
|
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';
|
package/dist/node-worker.js
CHANGED
|
@@ -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 {
|
|
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 {
|
|
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 {
|
|
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(
|
|
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(
|
|
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
|
|
6443
|
+
throw refuse(`"${currentUrl}" is not a valid URL`);
|
|
6423
6444
|
}
|
|
6424
6445
|
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
6425
|
-
throw
|
|
6446
|
+
throw refuse(`scheme "${parsed.protocol}" is not allowed`);
|
|
6426
6447
|
}
|
|
6427
6448
|
if (parsed.username !== "" || parsed.password !== "") {
|
|
6428
|
-
throw
|
|
6449
|
+
throw refuse(
|
|
6429
6450
|
`URL "${currentUrl}" embeds credentials, which is not allowed`
|
|
6430
6451
|
);
|
|
6431
6452
|
}
|
|
6432
|
-
if (signal?.aborted) throw
|
|
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
|
|
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
|
|
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
|
-
|
|
6468
|
+
refuse,
|
|
6448
6469
|
signal
|
|
6449
6470
|
);
|
|
6450
6471
|
if (response.status >= 300 && response.status < 400) {
|
|
6451
6472
|
if (!response.location) {
|
|
6452
|
-
throw
|
|
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
|
|
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
|
|
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 {
|
|
6
|
-
export { createHtmlExportEngine } from './html-engine.js';
|
|
5
|
+
export { createNodeDirectoryLister, createNodeFileReader, createNodePackDiscoveryIo, createNodeReader as createNodePackScriptsReader, } from './node-fs.js';
|