@veryfront/ext-content-mdx 0.1.1186 → 0.1.1189
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/esm/_dnt.polyfills.d.ts +6 -6
- package/esm/_dnt.polyfills.d.ts.map +1 -1
- package/esm/deno.d.ts +18 -0
- package/esm/deno.js +30 -9
- package/esm/src/config/defaults.d.ts +31 -24
- package/esm/src/config/defaults.d.ts.map +1 -1
- package/esm/src/config/defaults.js +25 -18
- package/esm/src/errors/diagnostic-policy.d.ts +35 -0
- package/esm/src/errors/diagnostic-policy.d.ts.map +1 -0
- package/esm/src/errors/diagnostic-policy.js +100 -0
- package/esm/src/errors/error-registry/boundary.d.ts +2 -0
- package/esm/src/errors/error-registry/boundary.d.ts.map +1 -1
- package/esm/src/errors/error-registry/boundary.js +8 -0
- package/esm/src/errors/error-registry/config.d.ts.map +1 -1
- package/esm/src/errors/error-registry/config.js +3 -3
- package/esm/src/errors/error-registry/deploy.js +1 -1
- package/esm/src/errors/error-registry/server.d.ts +2 -0
- package/esm/src/errors/error-registry/server.d.ts.map +1 -1
- package/esm/src/errors/error-registry/server.js +8 -0
- package/esm/src/errors/error-registry-helpers.d.ts +11 -2
- package/esm/src/errors/error-registry-helpers.d.ts.map +1 -1
- package/esm/src/errors/error-registry-helpers.js +70 -1
- package/esm/src/errors/error-registry.d.ts +85 -73
- package/esm/src/errors/error-registry.d.ts.map +1 -1
- package/esm/src/errors/error-registry.js +2 -14
- package/esm/src/errors/types.d.ts +44 -5
- package/esm/src/errors/types.d.ts.map +1 -1
- package/esm/src/errors/types.js +148 -24
- package/esm/src/errors/veryfront-error.d.ts +25 -2
- package/esm/src/errors/veryfront-error.d.ts.map +1 -1
- package/esm/src/errors/veryfront-error.js +638 -28
- package/esm/src/observability/limits.d.ts +20 -0
- package/esm/src/observability/limits.d.ts.map +1 -0
- package/esm/src/observability/limits.js +19 -0
- package/esm/src/observability/telemetry-error.d.ts +22 -0
- package/esm/src/observability/telemetry-error.d.ts.map +1 -0
- package/esm/src/observability/telemetry-error.js +377 -0
- package/esm/src/observability/tracing/api-shim.d.ts +39 -0
- package/esm/src/observability/tracing/api-shim.d.ts.map +1 -1
- package/esm/src/observability/tracing/api-shim.js +196 -69
- package/esm/src/observability/tracing/context-callback.d.ts +14 -0
- package/esm/src/observability/tracing/context-callback.d.ts.map +1 -0
- package/esm/src/observability/tracing/context-callback.js +111 -0
- package/esm/src/observability/tracing/otlp-setup.d.ts.map +1 -1
- package/esm/src/observability/tracing/otlp-setup.js +190 -46
- package/esm/src/platform/adapters/base.d.ts +51 -7
- package/esm/src/platform/adapters/base.d.ts.map +1 -1
- package/esm/src/platform/adapters/base.js +4 -2
- package/esm/src/platform/adapters/bounded-file-read.d.ts +9 -0
- package/esm/src/platform/adapters/bounded-file-read.d.ts.map +1 -1
- package/esm/src/platform/adapters/bounded-file-read.js +11 -5
- package/esm/src/platform/adapters/file-snapshot-error.d.ts +2 -0
- package/esm/src/platform/adapters/file-snapshot-error.d.ts.map +1 -1
- package/esm/src/platform/adapters/file-snapshot-error.js +2 -0
- package/esm/src/platform/adapters/file-system-capabilities.d.ts +74 -0
- package/esm/src/platform/adapters/file-system-capabilities.d.ts.map +1 -0
- package/esm/src/platform/adapters/file-system-capabilities.js +508 -0
- package/esm/src/platform/adapters/native-file-system-provenance.d.ts +6 -0
- package/esm/src/platform/adapters/native-file-system-provenance.d.ts.map +1 -0
- package/esm/src/platform/adapters/native-file-system-provenance.js +15 -0
- package/esm/src/platform/adapters/runtime/deno/filesystem-adapter.d.ts +45 -0
- package/esm/src/platform/adapters/runtime/deno/filesystem-adapter.d.ts.map +1 -0
- package/esm/src/platform/adapters/runtime/deno/filesystem-adapter.js +291 -0
- package/esm/src/platform/adapters/runtime/shared/node-filesystem-adapter.d.ts +71 -0
- package/esm/src/platform/adapters/runtime/shared/node-filesystem-adapter.d.ts.map +1 -0
- package/esm/src/platform/adapters/runtime/shared/node-filesystem-adapter.js +471 -0
- package/esm/src/platform/adapters/runtime/shared/shared-watcher.d.ts +16 -0
- package/esm/src/platform/adapters/runtime/shared/shared-watcher.d.ts.map +1 -0
- package/esm/src/platform/adapters/runtime/shared/shared-watcher.js +140 -0
- package/esm/src/platform/adapters/runtime/shared/temp-dir.d.ts +2 -0
- package/esm/src/platform/adapters/runtime/shared/temp-dir.d.ts.map +1 -0
- package/esm/src/platform/adapters/runtime/shared/temp-dir.js +10 -0
- package/esm/src/platform/adapters/runtime/shared/watcher-queue.d.ts +5 -0
- package/esm/src/platform/adapters/runtime/shared/watcher-queue.d.ts.map +1 -0
- package/esm/src/platform/adapters/runtime/shared/watcher-queue.js +75 -0
- package/esm/src/platform/compat/abort-signal.d.ts +20 -0
- package/esm/src/platform/compat/abort-signal.d.ts.map +1 -0
- package/esm/src/platform/compat/abort-signal.js +64 -0
- package/esm/src/platform/compat/constants.d.ts +2 -2
- package/esm/src/platform/compat/constants.d.ts.map +1 -1
- package/esm/src/platform/compat/constants.js +2 -2
- package/esm/src/platform/compat/error-introspection.d.ts +37 -0
- package/esm/src/platform/compat/error-introspection.d.ts.map +1 -0
- package/esm/src/platform/compat/error-introspection.js +258 -0
- package/esm/src/platform/compat/fs.d.ts +29 -8
- package/esm/src/platform/compat/fs.d.ts.map +1 -1
- package/esm/src/platform/compat/fs.js +123 -57
- package/esm/src/platform/compat/native-brand-checks.d.ts +14 -0
- package/esm/src/platform/compat/native-brand-checks.d.ts.map +1 -0
- package/esm/src/platform/compat/native-brand-checks.js +68 -0
- package/esm/src/platform/compat/not-found-error.d.ts +8 -3
- package/esm/src/platform/compat/not-found-error.d.ts.map +1 -1
- package/esm/src/platform/compat/not-found-error.js +164 -31
- package/esm/src/platform/compat/path/security.d.ts.map +1 -1
- package/esm/src/platform/compat/path/security.js +3 -5
- package/esm/src/platform/compat/process/command.d.ts +24 -1
- package/esm/src/platform/compat/process/command.d.ts.map +1 -1
- package/esm/src/platform/compat/process/command.js +393 -78
- package/esm/src/platform/compat/process/env.d.ts +11 -0
- package/esm/src/platform/compat/process/env.d.ts.map +1 -1
- package/esm/src/platform/compat/process/env.js +28 -38
- package/esm/src/platform/compat/process/global-error.d.ts +19 -0
- package/esm/src/platform/compat/process/global-error.d.ts.map +1 -0
- package/esm/src/platform/compat/process/global-error.js +57 -0
- package/esm/src/platform/compat/process/lifecycle.d.ts +10 -3
- package/esm/src/platform/compat/process/lifecycle.d.ts.map +1 -1
- package/esm/src/platform/compat/process/lifecycle.js +74 -23
- package/esm/src/platform/compat/process/project-env-contract.d.ts +19 -0
- package/esm/src/platform/compat/process/project-env-contract.d.ts.map +1 -0
- package/esm/src/platform/compat/process/project-env-contract.js +19 -0
- package/esm/src/platform/compat/runtime.d.ts +14 -5
- package/esm/src/platform/compat/runtime.d.ts.map +1 -1
- package/esm/src/platform/compat/runtime.js +34 -9
- package/esm/src/platform/compat/std/front-matter-yaml.d.ts +12 -0
- package/esm/src/platform/compat/std/front-matter-yaml.d.ts.map +1 -1
- package/esm/src/platform/compat/std/front-matter-yaml.js +35 -3
- package/esm/src/platform/compat/temp-directory-prefix.d.ts +8 -0
- package/esm/src/platform/compat/temp-directory-prefix.d.ts.map +1 -0
- package/esm/src/platform/compat/temp-directory-prefix.js +15 -0
- package/esm/src/utils/abort.d.ts +10 -0
- package/esm/src/utils/abort.d.ts.map +1 -0
- package/esm/src/utils/abort.js +35 -0
- package/esm/src/utils/constants/build.d.ts +3 -0
- package/esm/src/utils/constants/build.d.ts.map +1 -1
- package/esm/src/utils/constants/build.js +5 -1
- package/esm/src/utils/constants/cache.d.ts +21 -0
- package/esm/src/utils/constants/cache.d.ts.map +1 -1
- package/esm/src/utils/constants/cache.js +101 -39
- package/esm/src/utils/constants/css.d.ts +20 -0
- package/esm/src/utils/constants/css.d.ts.map +1 -0
- package/esm/src/utils/constants/css.js +19 -0
- package/esm/src/utils/constants/limits.d.ts +4 -0
- package/esm/src/utils/constants/limits.d.ts.map +1 -1
- package/esm/src/utils/constants/limits.js +4 -0
- package/esm/src/utils/constants/project-identity.d.ts +5 -0
- package/esm/src/utils/constants/project-identity.d.ts.map +1 -0
- package/esm/src/utils/constants/project-identity.js +4 -0
- package/esm/src/utils/constants/retry.d.ts +18 -0
- package/esm/src/utils/constants/retry.d.ts.map +1 -1
- package/esm/src/utils/constants/retry.js +18 -0
- package/esm/src/utils/constants/security.d.ts +4 -0
- package/esm/src/utils/constants/security.d.ts.map +1 -1
- package/esm/src/utils/constants/security.js +4 -0
- package/esm/src/utils/index.d.ts +3 -1
- package/esm/src/utils/index.d.ts.map +1 -1
- package/esm/src/utils/index.js +3 -1
- package/esm/src/utils/logger/core.d.ts +5 -0
- package/esm/src/utils/logger/core.d.ts.map +1 -1
- package/esm/src/utils/logger/core.js +67 -2
- package/esm/src/utils/logger/redact.d.ts +36 -13
- package/esm/src/utils/logger/redact.d.ts.map +1 -1
- package/esm/src/utils/logger/redact.js +573 -83
- package/esm/src/utils/parallel.d.ts.map +1 -1
- package/esm/src/utils/parallel.js +11 -1
- package/esm/src/utils/project-identity.d.ts +11 -0
- package/esm/src/utils/project-identity.d.ts.map +1 -0
- package/esm/src/utils/project-identity.js +69 -0
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +3 -3
- package/esm/src/platform/adapters/runtime/shared/native-file-capabilities.d.ts +0 -33
- package/esm/src/platform/adapters/runtime/shared/native-file-capabilities.d.ts.map +0 -1
- package/esm/src/platform/adapters/runtime/shared/native-file-capabilities.js +0 -205
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-system-capabilities.d.ts","sourceRoot":"","sources":["../../../../src/src/platform/adapters/file-system-capabilities.ts"],"names":[],"mappings":"AA8EA,KAAK,UAAU,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;AACxD,KAAK,iBAAiB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC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qB,CA4DvB"}
|
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
import { isProxyWithoutHooks } from "../compat/error-introspection.js";
|
|
2
|
+
const apply = Reflect.apply;
|
|
3
|
+
const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
4
|
+
const getPrototypeOf = Object.getPrototypeOf;
|
|
5
|
+
const objectHasOwnProperty = Object.prototype.hasOwnProperty;
|
|
6
|
+
const createObject = Object.create;
|
|
7
|
+
const freezeObject = Object.freeze;
|
|
8
|
+
const isArray = Array.isArray;
|
|
9
|
+
const numberIsSafeInteger = Number.isSafeInteger;
|
|
10
|
+
const universalObjectPrototype = Object.prototype;
|
|
11
|
+
const NativeUint8Array = Uint8Array;
|
|
12
|
+
const typedArrayPrototype = getPrototypeOf(NativeUint8Array.prototype);
|
|
13
|
+
const typedArrayBufferGetter = requireIntrinsicGetter(typedArrayPrototype, "buffer", "Uint8Array buffer");
|
|
14
|
+
const typedArrayByteLengthGetter = requireIntrinsicGetter(typedArrayPrototype, "byteLength", "Uint8Array byteLength");
|
|
15
|
+
const typedArrayByteOffsetGetter = requireIntrinsicGetter(typedArrayPrototype, "byteOffset", "Uint8Array byte offset");
|
|
16
|
+
const typedArrayNameGetter = requireIntrinsicGetter(typedArrayPrototype, Symbol.toStringTag, "Uint8Array name");
|
|
17
|
+
const arrayBufferByteLengthGetter = requireIntrinsicGetter(ArrayBuffer.prototype, "byteLength", "ArrayBuffer byteLength");
|
|
18
|
+
const arrayBufferResizableGetter = getOwnPropertyDescriptor(ArrayBuffer.prototype, "resizable")?.get;
|
|
19
|
+
const setBytes = NativeUint8Array.prototype.set;
|
|
20
|
+
const ABSENT_CAPABILITY = Symbol("absent filesystem capability");
|
|
21
|
+
const INVALID_CAPABILITY = Symbol("invalid filesystem capability");
|
|
22
|
+
const LEGACY_CAPABILITY_KEYS = [
|
|
23
|
+
"readFileBytes",
|
|
24
|
+
"readFileBytesBounded",
|
|
25
|
+
"readFileBytesWithinLimit",
|
|
26
|
+
"writeFileBytes",
|
|
27
|
+
"maxWholeFileReadBytes",
|
|
28
|
+
];
|
|
29
|
+
const BOUNDED_TEXT_CAPABILITY_KEYS = [
|
|
30
|
+
"readFileBytes",
|
|
31
|
+
"readFileBytesWithinLimit",
|
|
32
|
+
"maxWholeFileReadBytes",
|
|
33
|
+
];
|
|
34
|
+
const BYTE_READ_CAPABILITY_KEYS = [
|
|
35
|
+
"readFileBytes",
|
|
36
|
+
"readFileBytesBounded",
|
|
37
|
+
"readFileBytesWithinLimit",
|
|
38
|
+
"maxWholeFileReadBytes",
|
|
39
|
+
];
|
|
40
|
+
const SNAPSHOT_CAPABILITY_KEYS = ["readFileSnapshotWithinLimit"];
|
|
41
|
+
const EXCLUSIVE_CREATE_CAPABILITY_KEYS = ["createFileBytesExclusive"];
|
|
42
|
+
const GENERATION_CAPABILITY_KEYS = ["getSourceSnapshotVersion"];
|
|
43
|
+
const VIRTUAL_READ_CAPABILITY_KEYS = [
|
|
44
|
+
"readFileBytes",
|
|
45
|
+
"readFileBytesWithinLimit",
|
|
46
|
+
"maxWholeFileReadBytes",
|
|
47
|
+
];
|
|
48
|
+
function hasOwn(value, key) {
|
|
49
|
+
return apply(objectHasOwnProperty, value, [key]);
|
|
50
|
+
}
|
|
51
|
+
function requireIntrinsicGetter(target, property, name) {
|
|
52
|
+
const descriptor = getOwnPropertyDescriptor(target, property);
|
|
53
|
+
const getter = descriptor !== undefined && hasOwn(descriptor, "get") ? descriptor.get : undefined;
|
|
54
|
+
if (typeof getter !== "function") {
|
|
55
|
+
throw new TypeError(`Required ${name} intrinsic is unavailable`);
|
|
56
|
+
}
|
|
57
|
+
return getter;
|
|
58
|
+
}
|
|
59
|
+
function invalidCapability(label, detail, cause) {
|
|
60
|
+
return cause === undefined
|
|
61
|
+
? new TypeError(`${label} ${detail}`)
|
|
62
|
+
: new TypeError(`${label} ${detail}`, { cause });
|
|
63
|
+
}
|
|
64
|
+
function requireCapabilityObject(value, label) {
|
|
65
|
+
if (typeof value !== "object" ||
|
|
66
|
+
value === null ||
|
|
67
|
+
isProxyWithoutHooks(value) ||
|
|
68
|
+
isArray(value)) {
|
|
69
|
+
throw invalidCapability(label, "must be a non-array, non-Proxy object");
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function captureDataProperties(value, label, keys, invalidFieldPolicy = "reject") {
|
|
73
|
+
const properties = createObject(null);
|
|
74
|
+
const resolved = createObject(null);
|
|
75
|
+
let remaining = keys.length;
|
|
76
|
+
let owner = value;
|
|
77
|
+
const seen = new Set();
|
|
78
|
+
for (let depth = 0; owner !== null && depth < 64; depth++) {
|
|
79
|
+
if (owner === universalObjectPrototype) {
|
|
80
|
+
owner = null;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
if (isProxyWithoutHooks(owner)) {
|
|
84
|
+
throw invalidCapability(label, "capabilities must not use a Proxy");
|
|
85
|
+
}
|
|
86
|
+
if (seen.has(owner)) {
|
|
87
|
+
throw invalidCapability(label, "capabilities have an invalid prototype chain");
|
|
88
|
+
}
|
|
89
|
+
seen.add(owner);
|
|
90
|
+
let parent;
|
|
91
|
+
try {
|
|
92
|
+
parent = getPrototypeOf(owner);
|
|
93
|
+
}
|
|
94
|
+
catch (cause) {
|
|
95
|
+
throw invalidCapability(label, "capabilities could not be inspected safely", cause);
|
|
96
|
+
}
|
|
97
|
+
// A foreign realm's Object.prototype is identified by its terminal
|
|
98
|
+
// position rather than by local identity and is never adapter authority.
|
|
99
|
+
if (owner !== value && parent === null) {
|
|
100
|
+
owner = null;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
for (let index = 0; index < keys.length; index++) {
|
|
104
|
+
const key = keys[index];
|
|
105
|
+
if (resolved[key])
|
|
106
|
+
continue;
|
|
107
|
+
let descriptor;
|
|
108
|
+
try {
|
|
109
|
+
descriptor = getOwnPropertyDescriptor(owner, key);
|
|
110
|
+
}
|
|
111
|
+
catch (cause) {
|
|
112
|
+
throw invalidCapability(label, "capabilities could not be inspected safely", cause);
|
|
113
|
+
}
|
|
114
|
+
if (descriptor === undefined)
|
|
115
|
+
continue;
|
|
116
|
+
resolved[key] = true;
|
|
117
|
+
remaining--;
|
|
118
|
+
if (!hasOwn(descriptor, "value")) {
|
|
119
|
+
if (invalidFieldPolicy === "reject") {
|
|
120
|
+
throw invalidCapability(label, key === "maxWholeFileReadBytes"
|
|
121
|
+
? `${key} must be a data property`
|
|
122
|
+
: `${key} must be a data-property method`);
|
|
123
|
+
}
|
|
124
|
+
properties[key] = INVALID_CAPABILITY;
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
properties[key] = descriptor.value;
|
|
128
|
+
}
|
|
129
|
+
if (remaining === 0) {
|
|
130
|
+
owner = null;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
owner = parent;
|
|
134
|
+
}
|
|
135
|
+
if (owner !== null && remaining > 0) {
|
|
136
|
+
throw invalidCapability(label, "capability prototype chain is too deep");
|
|
137
|
+
}
|
|
138
|
+
for (let index = 0; index < keys.length; index++) {
|
|
139
|
+
const key = keys[index];
|
|
140
|
+
if (!resolved[key])
|
|
141
|
+
properties[key] = ABSENT_CAPABILITY;
|
|
142
|
+
}
|
|
143
|
+
return freezeObject(properties);
|
|
144
|
+
}
|
|
145
|
+
function requireOptionalMethod(candidate, label, key, allowExplicitUndefined = true) {
|
|
146
|
+
if (candidate === ABSENT_CAPABILITY ||
|
|
147
|
+
(allowExplicitUndefined && candidate === undefined))
|
|
148
|
+
return undefined;
|
|
149
|
+
if (typeof candidate !== "function" || isProxyWithoutHooks(candidate)) {
|
|
150
|
+
throw invalidCapability(label, `${key} must be a non-Proxy function`);
|
|
151
|
+
}
|
|
152
|
+
return candidate;
|
|
153
|
+
}
|
|
154
|
+
function getUint8ArrayByteLength(value) {
|
|
155
|
+
if (typeof value !== "object" || value === null)
|
|
156
|
+
return undefined;
|
|
157
|
+
try {
|
|
158
|
+
if (apply(typedArrayNameGetter, value, []) !== "Uint8Array")
|
|
159
|
+
return undefined;
|
|
160
|
+
const byteLength = apply(typedArrayByteLengthGetter, value, []);
|
|
161
|
+
return typeof byteLength === "number" && numberIsSafeInteger(byteLength) && byteLength >= 0
|
|
162
|
+
? byteLength
|
|
163
|
+
: undefined;
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Admit an untrusted byte result before copying it into an immutable-size,
|
|
171
|
+
* tightly allocated ArrayBuffer. The maximum is checked from the intrinsic
|
|
172
|
+
* Uint8Array byte length before allocating the defensive copy.
|
|
173
|
+
*/
|
|
174
|
+
export function copyFixedUint8ArrayWithinLimit(value, maximumBytes, label) {
|
|
175
|
+
if (!numberIsSafeInteger(maximumBytes) || maximumBytes <= 0) {
|
|
176
|
+
throw new RangeError(`${label} maximum must be a positive safe integer`);
|
|
177
|
+
}
|
|
178
|
+
const byteLength = getUint8ArrayByteLength(value);
|
|
179
|
+
if (byteLength === undefined) {
|
|
180
|
+
throw new TypeError(`${label} reader returned invalid bytes`);
|
|
181
|
+
}
|
|
182
|
+
// Size overflow is a RangeError across the bounded-read surface; a malformed
|
|
183
|
+
// or dishonest result type stays a TypeError. Boundaries that present a
|
|
184
|
+
// different class to their own callers normalize this cause themselves.
|
|
185
|
+
if (byteLength > maximumBytes) {
|
|
186
|
+
throw new RangeError(`${label} exceeds ${maximumBytes} bytes`);
|
|
187
|
+
}
|
|
188
|
+
let buffer;
|
|
189
|
+
let resizable = false;
|
|
190
|
+
try {
|
|
191
|
+
buffer = apply(typedArrayBufferGetter, value, []);
|
|
192
|
+
apply(arrayBufferByteLengthGetter, buffer, []);
|
|
193
|
+
resizable = arrayBufferResizableGetter !== undefined &&
|
|
194
|
+
apply(arrayBufferResizableGetter, buffer, []) === true;
|
|
195
|
+
}
|
|
196
|
+
catch (cause) {
|
|
197
|
+
throw new TypeError(`${label} reader must return bytes backed by a fixed ArrayBuffer`, {
|
|
198
|
+
cause,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
if (resizable) {
|
|
202
|
+
throw new TypeError(`${label} reader must return bytes backed by a fixed ArrayBuffer`);
|
|
203
|
+
}
|
|
204
|
+
const copy = new NativeUint8Array(byteLength);
|
|
205
|
+
try {
|
|
206
|
+
apply(setBytes, copy, [value]);
|
|
207
|
+
}
|
|
208
|
+
catch (cause) {
|
|
209
|
+
throw new TypeError(`${label} reader returned invalid bytes`, { cause });
|
|
210
|
+
}
|
|
211
|
+
let copyByteLength;
|
|
212
|
+
let copyByteOffset;
|
|
213
|
+
let copyBuffer;
|
|
214
|
+
let copyBufferByteLength;
|
|
215
|
+
try {
|
|
216
|
+
copyByteLength = apply(typedArrayByteLengthGetter, copy, []);
|
|
217
|
+
copyByteOffset = apply(typedArrayByteOffsetGetter, copy, []);
|
|
218
|
+
copyBuffer = apply(typedArrayBufferGetter, copy, []);
|
|
219
|
+
copyBufferByteLength = apply(arrayBufferByteLengthGetter, copyBuffer, []);
|
|
220
|
+
}
|
|
221
|
+
catch (cause) {
|
|
222
|
+
throw new TypeError(`${label} could not allocate a fixed byte copy`, { cause });
|
|
223
|
+
}
|
|
224
|
+
if (copyByteLength !== byteLength ||
|
|
225
|
+
copyByteOffset !== 0 ||
|
|
226
|
+
copyBufferByteLength !== byteLength) {
|
|
227
|
+
throw new TypeError(`${label} could not allocate a tight fixed byte copy`);
|
|
228
|
+
}
|
|
229
|
+
return copy;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Extract the ArrayBuffer from an admitted tight fixed Uint8Array without
|
|
233
|
+
* consulting mutable global constructors or configurable typed-array getters.
|
|
234
|
+
*/
|
|
235
|
+
export function getFixedUint8ArrayBuffer(value, label) {
|
|
236
|
+
const byteLength = getUint8ArrayByteLength(value);
|
|
237
|
+
if (byteLength === undefined) {
|
|
238
|
+
throw new TypeError(`${label} must be a Uint8Array`);
|
|
239
|
+
}
|
|
240
|
+
let byteOffset;
|
|
241
|
+
let buffer;
|
|
242
|
+
let bufferByteLength;
|
|
243
|
+
let resizable = false;
|
|
244
|
+
try {
|
|
245
|
+
byteOffset = apply(typedArrayByteOffsetGetter, value, []);
|
|
246
|
+
buffer = apply(typedArrayBufferGetter, value, []);
|
|
247
|
+
bufferByteLength = apply(arrayBufferByteLengthGetter, buffer, []);
|
|
248
|
+
resizable = arrayBufferResizableGetter !== undefined &&
|
|
249
|
+
apply(arrayBufferResizableGetter, buffer, []) === true;
|
|
250
|
+
}
|
|
251
|
+
catch (cause) {
|
|
252
|
+
throw new TypeError(`${label} must use a tight fixed ArrayBuffer`, { cause });
|
|
253
|
+
}
|
|
254
|
+
if (byteOffset !== 0 || bufferByteLength !== byteLength || resizable) {
|
|
255
|
+
throw new TypeError(`${label} must use a tight fixed ArrayBuffer`);
|
|
256
|
+
}
|
|
257
|
+
return buffer;
|
|
258
|
+
}
|
|
259
|
+
/** Read the intrinsic byte length only after verifying a tight fixed buffer. */
|
|
260
|
+
export function getFixedUint8ArrayByteLength(value, label) {
|
|
261
|
+
const byteLength = getUint8ArrayByteLength(value);
|
|
262
|
+
if (byteLength === undefined) {
|
|
263
|
+
throw new TypeError(`${label} must be a Uint8Array`);
|
|
264
|
+
}
|
|
265
|
+
getFixedUint8ArrayBuffer(value, label);
|
|
266
|
+
return byteLength;
|
|
267
|
+
}
|
|
268
|
+
function copyExclusiveCreateBytes(content, label) {
|
|
269
|
+
const byteLength = getUint8ArrayByteLength(content);
|
|
270
|
+
if (byteLength === undefined) {
|
|
271
|
+
throw invalidCapability(label, "create content must be a Uint8Array");
|
|
272
|
+
}
|
|
273
|
+
return copyFixedUint8ArrayWithinLimit(content, byteLength === 0 ? 1 : byteLength, `${label} create content`);
|
|
274
|
+
}
|
|
275
|
+
function requirePositiveByteLimit(value, label) {
|
|
276
|
+
if (!numberIsSafeInteger(value) || value <= 0) {
|
|
277
|
+
throw new RangeError(`${label} must be a positive safe integer`);
|
|
278
|
+
}
|
|
279
|
+
return value;
|
|
280
|
+
}
|
|
281
|
+
function requireGeneration(value, label) {
|
|
282
|
+
if (!numberIsSafeInteger(value) || value < 0) {
|
|
283
|
+
throw invalidCapability(label, "generation must be a non-negative safe integer");
|
|
284
|
+
}
|
|
285
|
+
return value;
|
|
286
|
+
}
|
|
287
|
+
function captureWholeFileReader(value, properties, label, defensiveResults, allowExplicitUndefined) {
|
|
288
|
+
const rawReadFileBytes = requireOptionalMethod(properties.readFileBytes, label, "readFileBytes", allowExplicitUndefined);
|
|
289
|
+
const ceilingCandidate = properties.maxWholeFileReadBytes;
|
|
290
|
+
const ceiling = ceilingCandidate === ABSENT_CAPABILITY ||
|
|
291
|
+
(allowExplicitUndefined && ceilingCandidate === undefined)
|
|
292
|
+
? undefined
|
|
293
|
+
: ceilingCandidate;
|
|
294
|
+
if (ceiling !== undefined && (!numberIsSafeInteger(ceiling) || ceiling <= 0)) {
|
|
295
|
+
throw invalidCapability(label, "maxWholeFileReadBytes must be a positive safe integer");
|
|
296
|
+
}
|
|
297
|
+
if (ceiling !== undefined && rawReadFileBytes === undefined) {
|
|
298
|
+
throw invalidCapability(label, "maxWholeFileReadBytes requires readFileBytes");
|
|
299
|
+
}
|
|
300
|
+
if (ceiling === undefined || rawReadFileBytes === undefined)
|
|
301
|
+
return undefined;
|
|
302
|
+
const maximumBytes = ceiling;
|
|
303
|
+
const read = defensiveResults
|
|
304
|
+
? async (path) => {
|
|
305
|
+
const result = await apply(rawReadFileBytes, value, [path]);
|
|
306
|
+
return copyFixedUint8ArrayWithinLimit(result, maximumBytes, `${label} whole-file`);
|
|
307
|
+
}
|
|
308
|
+
: (path) => apply(rawReadFileBytes, value, [path]);
|
|
309
|
+
const captured = createObject(null);
|
|
310
|
+
captured.maximumBytes = maximumBytes;
|
|
311
|
+
captured.read = read;
|
|
312
|
+
return freezeObject(captured);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Preserve the broad legacy capture temporarily for its scheduled consumers.
|
|
316
|
+
* Bounded text passes the narrow purpose so writer and prefix fields are never
|
|
317
|
+
* inspected.
|
|
318
|
+
*/
|
|
319
|
+
export function captureFileSystemCapabilities(value, label = "Filesystem", purpose = "legacy") {
|
|
320
|
+
requireCapabilityObject(value, label);
|
|
321
|
+
const keys = purpose === "bounded-text"
|
|
322
|
+
? BOUNDED_TEXT_CAPABILITY_KEYS
|
|
323
|
+
: purpose === "byte-read"
|
|
324
|
+
? BYTE_READ_CAPABILITY_KEYS
|
|
325
|
+
: LEGACY_CAPABILITY_KEYS;
|
|
326
|
+
const properties = captureDataProperties(value, label, keys);
|
|
327
|
+
const rawReadFileBytes = requireOptionalMethod(properties.readFileBytes, label, "readFileBytes");
|
|
328
|
+
const rawBoundedReader = purpose === "bounded-text"
|
|
329
|
+
? undefined
|
|
330
|
+
: requireOptionalMethod(properties.readFileBytesBounded, label, "readFileBytesBounded");
|
|
331
|
+
const rawExactReader = requireOptionalMethod(properties.readFileBytesWithinLimit, label, "readFileBytesWithinLimit");
|
|
332
|
+
const rawWriter = purpose !== "legacy" ? undefined : requireOptionalMethod(properties.writeFileBytes, label, "writeFileBytes");
|
|
333
|
+
const readFileBytes = rawReadFileBytes === undefined
|
|
334
|
+
? undefined
|
|
335
|
+
: (path) => apply(rawReadFileBytes, value, [path]);
|
|
336
|
+
const readFileBytesBounded = rawBoundedReader === undefined
|
|
337
|
+
? undefined
|
|
338
|
+
: (path, byteLimit) => apply(rawBoundedReader, value, [path, byteLimit]);
|
|
339
|
+
const readFileBytesWithinLimit = rawExactReader === undefined
|
|
340
|
+
? undefined
|
|
341
|
+
: (path, byteLimit) => apply(rawExactReader, value, [path, byteLimit]);
|
|
342
|
+
const writeFileBytes = rawWriter === undefined
|
|
343
|
+
? undefined
|
|
344
|
+
: (path, content) => apply(rawWriter, value, [path, content]);
|
|
345
|
+
const wholeFileReader = captureWholeFileReader(value, properties, label, false, true);
|
|
346
|
+
const captured = createObject(null);
|
|
347
|
+
if (readFileBytes !== undefined)
|
|
348
|
+
captured.readFileBytes = readFileBytes;
|
|
349
|
+
if (readFileBytesBounded !== undefined)
|
|
350
|
+
captured.readFileBytesBounded = readFileBytesBounded;
|
|
351
|
+
if (readFileBytesWithinLimit !== undefined) {
|
|
352
|
+
captured.readFileBytesWithinLimit = readFileBytesWithinLimit;
|
|
353
|
+
}
|
|
354
|
+
if (writeFileBytes !== undefined)
|
|
355
|
+
captured.writeFileBytes = writeFileBytes;
|
|
356
|
+
if (wholeFileReader !== undefined)
|
|
357
|
+
captured.wholeFileReader = wholeFileReader;
|
|
358
|
+
return freezeObject(captured);
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Capture the established byte-reader surface while defensively admitting
|
|
362
|
+
* every result. New purpose-specific code should prefer the narrower capture
|
|
363
|
+
* functions above.
|
|
364
|
+
*/
|
|
365
|
+
export function captureByteReadCapabilities(value, label = "Filesystem") {
|
|
366
|
+
const capabilities = captureFileSystemCapabilities(value, label, "byte-read");
|
|
367
|
+
const captured = createObject(null);
|
|
368
|
+
if (capabilities.readFileBytes !== undefined) {
|
|
369
|
+
captured.unbounded = async (path) => copyFixedUint8ArrayWithinLimit(await capabilities.readFileBytes(path), Number.MAX_SAFE_INTEGER, `${label} whole-file`);
|
|
370
|
+
}
|
|
371
|
+
if (capabilities.wholeFileReader !== undefined) {
|
|
372
|
+
const rawWhole = capabilities.wholeFileReader;
|
|
373
|
+
const whole = createObject(null);
|
|
374
|
+
whole.maximumBytes = rawWhole.maximumBytes;
|
|
375
|
+
whole.read = async (path) => copyFixedUint8ArrayWithinLimit(await rawWhole.read(path), rawWhole.maximumBytes, `${label} whole-file`);
|
|
376
|
+
captured.whole = freezeObject(whole);
|
|
377
|
+
}
|
|
378
|
+
if (capabilities.readFileBytesBounded !== undefined) {
|
|
379
|
+
captured.prefix = async (path, byteLimit) => {
|
|
380
|
+
const limit = requirePositiveByteLimit(byteLimit, `${label} prefix byte limit`);
|
|
381
|
+
return copyFixedUint8ArrayWithinLimit(await capabilities.readFileBytesBounded(path, limit), limit, `${label} prefix`);
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
if (capabilities.readFileBytesWithinLimit !== undefined) {
|
|
385
|
+
captured.exact = async (path, byteLimit) => {
|
|
386
|
+
const limit = requirePositiveByteLimit(byteLimit, `${label} exact byte limit`);
|
|
387
|
+
return copyFixedUint8ArrayWithinLimit(await capabilities.readFileBytesWithinLimit(path, limit), limit, `${label} exact`);
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
return freezeObject(captured);
|
|
391
|
+
}
|
|
392
|
+
function admitQuarantinedMethod(candidate) {
|
|
393
|
+
if (candidate === ABSENT_CAPABILITY ||
|
|
394
|
+
candidate === INVALID_CAPABILITY ||
|
|
395
|
+
candidate === undefined ||
|
|
396
|
+
typeof candidate !== "function" ||
|
|
397
|
+
isProxyWithoutHooks(candidate)) {
|
|
398
|
+
return undefined;
|
|
399
|
+
}
|
|
400
|
+
return candidate;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Capture legacy byte capabilities after genuine snapshot authority has been
|
|
404
|
+
* proven independently. Malformed optional fields are omitted one at a time;
|
|
405
|
+
* unsafe object or prototype provenance still rejects the adapter.
|
|
406
|
+
*/
|
|
407
|
+
export function captureLegacyFileSystemCapabilitiesForSnapshot(value, label = "Filesystem") {
|
|
408
|
+
requireCapabilityObject(value, label);
|
|
409
|
+
const properties = captureDataProperties(value, label, LEGACY_CAPABILITY_KEYS, "quarantine");
|
|
410
|
+
const rawReadFileBytes = admitQuarantinedMethod(properties.readFileBytes);
|
|
411
|
+
const rawBoundedReader = admitQuarantinedMethod(properties.readFileBytesBounded);
|
|
412
|
+
const rawExactReader = admitQuarantinedMethod(properties.readFileBytesWithinLimit);
|
|
413
|
+
const rawWriter = admitQuarantinedMethod(properties.writeFileBytes);
|
|
414
|
+
const ceilingCandidate = properties.maxWholeFileReadBytes;
|
|
415
|
+
const maximumBytes = numberIsSafeInteger(ceilingCandidate) &&
|
|
416
|
+
ceilingCandidate > 0
|
|
417
|
+
? ceilingCandidate
|
|
418
|
+
: undefined;
|
|
419
|
+
const captured = createObject(null);
|
|
420
|
+
if (rawReadFileBytes !== undefined) {
|
|
421
|
+
const readFileBytes = (path) => apply(rawReadFileBytes, value, [path]);
|
|
422
|
+
captured.readFileBytes = readFileBytes;
|
|
423
|
+
if (maximumBytes !== undefined) {
|
|
424
|
+
const wholeFileReader = createObject(null);
|
|
425
|
+
wholeFileReader.maximumBytes = maximumBytes;
|
|
426
|
+
wholeFileReader.read = readFileBytes;
|
|
427
|
+
captured.wholeFileReader = freezeObject(wholeFileReader);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
if (rawBoundedReader !== undefined) {
|
|
431
|
+
captured.readFileBytesBounded = (path, byteLimit) => apply(rawBoundedReader, value, [path, byteLimit]);
|
|
432
|
+
}
|
|
433
|
+
if (rawExactReader !== undefined) {
|
|
434
|
+
captured.readFileBytesWithinLimit = (path, byteLimit) => apply(rawExactReader, value, [path, byteLimit]);
|
|
435
|
+
}
|
|
436
|
+
if (rawWriter !== undefined) {
|
|
437
|
+
captured.writeFileBytes = (path, content) => apply(rawWriter, value, [path, content]);
|
|
438
|
+
}
|
|
439
|
+
return freezeObject(captured);
|
|
440
|
+
}
|
|
441
|
+
export function captureSnapshotReadCapability(value, label = "Filesystem", allowExplicitUndefined = false) {
|
|
442
|
+
requireCapabilityObject(value, label);
|
|
443
|
+
const properties = captureDataProperties(value, label, SNAPSHOT_CAPABILITY_KEYS);
|
|
444
|
+
const rawReader = requireOptionalMethod(properties.readFileSnapshotWithinLimit, label, "readFileSnapshotWithinLimit", allowExplicitUndefined);
|
|
445
|
+
if (rawReader === undefined)
|
|
446
|
+
return undefined;
|
|
447
|
+
const captured = createObject(null);
|
|
448
|
+
captured.read = async (path, containmentRoot, byteLimit) => {
|
|
449
|
+
requirePositiveByteLimit(byteLimit, `${label} snapshot byte limit`);
|
|
450
|
+
const result = await apply(rawReader, value, [path, containmentRoot, byteLimit]);
|
|
451
|
+
return copyFixedUint8ArrayWithinLimit(result, byteLimit, `${label} snapshot`);
|
|
452
|
+
};
|
|
453
|
+
return freezeObject(captured);
|
|
454
|
+
}
|
|
455
|
+
export function captureExclusiveCreateCapability(value, label = "Filesystem") {
|
|
456
|
+
requireCapabilityObject(value, label);
|
|
457
|
+
const properties = captureDataProperties(value, label, EXCLUSIVE_CREATE_CAPABILITY_KEYS);
|
|
458
|
+
const rawCreator = requireOptionalMethod(properties.createFileBytesExclusive, label, "createFileBytesExclusive", false);
|
|
459
|
+
if (rawCreator === undefined)
|
|
460
|
+
return undefined;
|
|
461
|
+
const captured = createObject(null);
|
|
462
|
+
captured.create = (path, content) => {
|
|
463
|
+
const fixedContent = copyExclusiveCreateBytes(content, label);
|
|
464
|
+
return apply(rawCreator, value, [path, fixedContent]);
|
|
465
|
+
};
|
|
466
|
+
return freezeObject(captured);
|
|
467
|
+
}
|
|
468
|
+
export function captureStaticReadCapabilities(value, label = "Filesystem") {
|
|
469
|
+
requireCapabilityObject(value, label);
|
|
470
|
+
const snapshot = captureSnapshotReadCapability(value, label);
|
|
471
|
+
const captured = createObject(null);
|
|
472
|
+
if (snapshot !== undefined)
|
|
473
|
+
captured.snapshot = snapshot;
|
|
474
|
+
// Virtual readers are authority only behind an explicit own data marker.
|
|
475
|
+
// An absent, inherited, or accessor marker leaves unrelated fields unobserved.
|
|
476
|
+
const semantics = getOwnPropertyDescriptor(value, "symlinkSemantics");
|
|
477
|
+
if (semantics === undefined ||
|
|
478
|
+
!hasOwn(semantics, "value") ||
|
|
479
|
+
semantics.value !== "none") {
|
|
480
|
+
return freezeObject(captured);
|
|
481
|
+
}
|
|
482
|
+
const generationProperties = captureDataProperties(value, label, GENERATION_CAPABILITY_KEYS);
|
|
483
|
+
const rawGeneration = requireOptionalMethod(generationProperties.getSourceSnapshotVersion, label, "getSourceSnapshotVersion", false);
|
|
484
|
+
if (rawGeneration === undefined)
|
|
485
|
+
return freezeObject(captured);
|
|
486
|
+
const readerProperties = captureDataProperties(value, label, VIRTUAL_READ_CAPABILITY_KEYS);
|
|
487
|
+
const rawExactReader = requireOptionalMethod(readerProperties.readFileBytesWithinLimit, label, "readFileBytesWithinLimit", false);
|
|
488
|
+
const whole = captureWholeFileReader(value, readerProperties, label, true, false);
|
|
489
|
+
const virtual = createObject(null);
|
|
490
|
+
virtual.generation = async () => {
|
|
491
|
+
const result = await apply(rawGeneration, value, []);
|
|
492
|
+
return requireGeneration(result, label);
|
|
493
|
+
};
|
|
494
|
+
if (rawExactReader !== undefined) {
|
|
495
|
+
virtual.exact = async (path, byteLimit) => {
|
|
496
|
+
requirePositiveByteLimit(byteLimit, `${label} exact byte limit`);
|
|
497
|
+
const result = await apply(rawExactReader, value, [path, byteLimit]);
|
|
498
|
+
return copyFixedUint8ArrayWithinLimit(result, byteLimit, `${label} exact`);
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
if (whole !== undefined)
|
|
502
|
+
virtual.whole = whole;
|
|
503
|
+
if (virtual.exact === undefined && virtual.whole === undefined) {
|
|
504
|
+
return freezeObject(captured);
|
|
505
|
+
}
|
|
506
|
+
captured.virtual = freezeObject(virtual);
|
|
507
|
+
return freezeObject(captured);
|
|
508
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FileSystemAdapter } from "./base.js";
|
|
2
|
+
/** Register a directly constructed built-in adapter backed by the host filesystem. */
|
|
3
|
+
export declare function markNativeFileSystemAdapter(adapter: FileSystemAdapter): void;
|
|
4
|
+
/** Return true only for the exact built-in adapter object registered at construction. */
|
|
5
|
+
export declare function isNativeFileSystemAdapter(adapter: FileSystemAdapter): boolean;
|
|
6
|
+
//# sourceMappingURL=native-file-system-provenance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-file-system-provenance.d.ts","sourceRoot":"","sources":["../../../../src/src/platform/adapters/native-file-system-provenance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAWnD,sFAAsF;AACtF,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAE5E;AAED,yFAAyF;AACzF,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAMT"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const IntrinsicWeakSet = WeakSet;
|
|
2
|
+
const ReflectApply = Reflect.apply;
|
|
3
|
+
const WeakSetPrototypeAdd = IntrinsicWeakSet.prototype.add;
|
|
4
|
+
const WeakSetPrototypeHas = IntrinsicWeakSet.prototype.has;
|
|
5
|
+
// Exact-object provenance only. Wrappers and proxies must not inherit this
|
|
6
|
+
// classification because they may translate paths into a non-native namespace.
|
|
7
|
+
const nativeFileSystemAdapters = new IntrinsicWeakSet();
|
|
8
|
+
/** Register a directly constructed built-in adapter backed by the host filesystem. */
|
|
9
|
+
export function markNativeFileSystemAdapter(adapter) {
|
|
10
|
+
ReflectApply(WeakSetPrototypeAdd, nativeFileSystemAdapters, [adapter]);
|
|
11
|
+
}
|
|
12
|
+
/** Return true only for the exact built-in adapter object registered at construction. */
|
|
13
|
+
export function isNativeFileSystemAdapter(adapter) {
|
|
14
|
+
return ReflectApply(WeakSetPrototypeHas, nativeFileSystemAdapters, [adapter]);
|
|
15
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { DirEntry, FileInfo, FileSystemAdapter, FileWatcher, WatchOptions } from "../../base.js";
|
|
2
|
+
import { type NodeFileSystemCapabilityOptions } from "../shared/node-filesystem-adapter.js";
|
|
3
|
+
interface DenoCreateFile {
|
|
4
|
+
write(content: Uint8Array): Promise<number>;
|
|
5
|
+
close(): void;
|
|
6
|
+
}
|
|
7
|
+
interface DenoCreateRuntime {
|
|
8
|
+
open(path: string, options: {
|
|
9
|
+
write: true;
|
|
10
|
+
createNew: true;
|
|
11
|
+
}): Promise<DenoCreateFile>;
|
|
12
|
+
}
|
|
13
|
+
interface DenoFileSystemCapabilityOptions extends NodeFileSystemCapabilityOptions {
|
|
14
|
+
/** Test seam for Deno createNew availability and partial write failures. */
|
|
15
|
+
readonly denoCreateRuntime?: DenoCreateRuntime | null;
|
|
16
|
+
}
|
|
17
|
+
export declare class DenoFileSystemAdapter implements FileSystemAdapter {
|
|
18
|
+
constructor(options?: DenoFileSystemCapabilityOptions);
|
|
19
|
+
readFile(path: string): Promise<string>;
|
|
20
|
+
readFileBytes(path: string): Promise<Uint8Array>;
|
|
21
|
+
readFileBytesBounded(path: string, byteLimit: number): Promise<Uint8Array>;
|
|
22
|
+
readFileBytesWithinLimit(path: string, byteLimit: number): Promise<Uint8Array>;
|
|
23
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
24
|
+
writeFileBytes(path: string, content: Uint8Array): Promise<void>;
|
|
25
|
+
rename(from: string, to: string): Promise<void>;
|
|
26
|
+
exists(path: string): Promise<boolean>;
|
|
27
|
+
readDir(path: string): AsyncIterable<DirEntry>;
|
|
28
|
+
stat(path: string): Promise<FileInfo>;
|
|
29
|
+
lstat(path: string): Promise<FileInfo>;
|
|
30
|
+
realPath(path: string): Promise<string>;
|
|
31
|
+
mkdir(path: string, options?: {
|
|
32
|
+
recursive?: boolean;
|
|
33
|
+
}): Promise<void>;
|
|
34
|
+
remove(path: string, options?: {
|
|
35
|
+
recursive?: boolean;
|
|
36
|
+
}): Promise<void>;
|
|
37
|
+
makeTempDir(prefix: string): Promise<string>;
|
|
38
|
+
watch(paths: string | string[], options?: WatchOptions): FileWatcher;
|
|
39
|
+
}
|
|
40
|
+
export interface DenoFileSystemAdapter {
|
|
41
|
+
readFileSnapshotWithinLimit?(path: string, containmentRoot: string, byteLimit: number): Promise<Uint8Array>;
|
|
42
|
+
createFileBytesExclusive?(path: string, content: Uint8Array): Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=filesystem-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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