@poe-platform/safe-fs 0.1.817 → 0.1.819
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 +1 -1
- package/dist/safe-fs/contracts/filesystem.d.ts +9 -1
- package/dist/safe-fs/core.d.ts +1 -1
- package/dist/safe-fs/fs/capabilities.js +7 -4
- package/dist/safe-fs/fs/devices/index.d.ts +3 -1
- package/dist/safe-fs/fs/devices/index.js +7 -0
- package/dist/safe-fs/fs/devices/path.js +6 -0
- package/dist/safe-fs/fs/devices/plain-path.d.ts +2 -0
- package/dist/safe-fs/fs/devices/plain-path.js +3 -0
- package/dist/safe-fs/fs/memory/index.d.ts +2 -1
- package/dist/safe-fs/fs/memory/index.js +3 -0
- package/dist/safe-fs/fs/mount/index.d.ts +4 -1
- package/dist/safe-fs/fs/mount/index.js +56 -25
- package/dist/safe-fs/fs/overlay/index.d.ts +2 -1
- package/dist/safe-fs/fs/overlay/index.js +2 -0
- package/dist/safe-fs/fs/real/index.d.ts +3 -0
- package/dist/safe-fs/fs/real/index.js +110 -5
- package/dist/safe-fs/fs/scoped.js +2 -2
- package/dist/xml-ast/attributes.d.ts +69 -0
- package/dist/xml-ast/attributes.js +62 -0
- package/dist/xml-ast/frames.d.ts +40 -1
- package/dist/xml-ast/frames.js +42 -0
- package/dist/xml-ast/index.d.ts +33 -5
- package/dist/xml-ast/index.js +212 -64
- package/dist/xml-ast/source.d.ts +4 -0
- package/package.json +1 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { XmlSourceSpan } from "./source.js";
|
|
2
|
+
import type { XmlNamespaceScope } from "./frames.js";
|
|
3
|
+
export interface XmlAttributeRecord {
|
|
4
|
+
name: string;
|
|
5
|
+
prefix: string;
|
|
6
|
+
localName: string;
|
|
7
|
+
value: string;
|
|
8
|
+
next: number;
|
|
9
|
+
nameSource?: XmlSourceSpan;
|
|
10
|
+
localNameSource?: XmlSourceSpan;
|
|
11
|
+
prefixSource?: XmlSourceSpan;
|
|
12
|
+
source?: {
|
|
13
|
+
start: number;
|
|
14
|
+
end: number;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface XmlAttributeState {
|
|
18
|
+
reference: number;
|
|
19
|
+
first: number;
|
|
20
|
+
length: number;
|
|
21
|
+
size: number;
|
|
22
|
+
}
|
|
23
|
+
export type XmlAttributeRequest = {
|
|
24
|
+
attributeOperation: 'has' | 'expanded';
|
|
25
|
+
state: XmlAttributeState;
|
|
26
|
+
name: string;
|
|
27
|
+
nameSource?: XmlSourceSpan;
|
|
28
|
+
found?: boolean;
|
|
29
|
+
namespace?: {
|
|
30
|
+
scope: XmlNamespaceScope;
|
|
31
|
+
prefix: string;
|
|
32
|
+
prefixSource?: XmlSourceSpan;
|
|
33
|
+
};
|
|
34
|
+
} | {
|
|
35
|
+
attributeOperation: 'append';
|
|
36
|
+
state: XmlAttributeState;
|
|
37
|
+
attribute: Omit<XmlAttributeRecord, 'next'>;
|
|
38
|
+
result?: XmlAttributeState;
|
|
39
|
+
} | {
|
|
40
|
+
attributeOperation: 'read';
|
|
41
|
+
state: XmlAttributeState;
|
|
42
|
+
reference: number;
|
|
43
|
+
values: boolean;
|
|
44
|
+
result?: XmlAttributeRecord;
|
|
45
|
+
};
|
|
46
|
+
/** Buffered APIs use local collections; external parsing retains only a store
|
|
47
|
+
* handle and one current attribute. Hosts preserve order and last-value recovery. */
|
|
48
|
+
export declare class XmlAttributes {
|
|
49
|
+
private readonly external;
|
|
50
|
+
private state;
|
|
51
|
+
private readonly names;
|
|
52
|
+
private readonly records;
|
|
53
|
+
private readonly expandedNames;
|
|
54
|
+
constructor(external: boolean);
|
|
55
|
+
get length(): number;
|
|
56
|
+
get size(): number;
|
|
57
|
+
get first(): number;
|
|
58
|
+
has(name: string, nameSource?: XmlSourceSpan): Generator<XmlAttributeRequest, boolean, void>;
|
|
59
|
+
append(name: string, prefix: string, localName: string, value: string, source?: {
|
|
60
|
+
start: number;
|
|
61
|
+
end: number;
|
|
62
|
+
}, nameSource?: XmlSourceSpan, localNameSource?: XmlSourceSpan, prefixSource?: XmlSourceSpan): Generator<XmlAttributeRequest, void, void>;
|
|
63
|
+
read(reference: number, values: boolean): Generator<XmlAttributeRequest, XmlAttributeRecord, void>;
|
|
64
|
+
expanded(name: string, namespace?: {
|
|
65
|
+
scope: XmlNamespaceScope;
|
|
66
|
+
prefix: string;
|
|
67
|
+
prefixSource?: XmlSourceSpan;
|
|
68
|
+
}, nameSource?: XmlSourceSpan): Generator<XmlAttributeRequest, boolean, void>;
|
|
69
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/** Buffered APIs use local collections; external parsing retains only a store
|
|
2
|
+
* handle and one current attribute. Hosts preserve order and last-value recovery. */
|
|
3
|
+
export class XmlAttributes {
|
|
4
|
+
external;
|
|
5
|
+
state = { reference: 0, first: 0, length: 0, size: 0 };
|
|
6
|
+
names = new Map();
|
|
7
|
+
records = [];
|
|
8
|
+
expandedNames = new Set();
|
|
9
|
+
constructor(external) {
|
|
10
|
+
this.external = external;
|
|
11
|
+
}
|
|
12
|
+
get length() { return this.state.length; }
|
|
13
|
+
get size() { return this.state.size; }
|
|
14
|
+
get first() { return this.state.first; }
|
|
15
|
+
*has(name, nameSource) {
|
|
16
|
+
if (!this.length)
|
|
17
|
+
return false;
|
|
18
|
+
if (!this.external)
|
|
19
|
+
return this.names.has(name);
|
|
20
|
+
const request = { attributeOperation: 'has', state: this.state, name, ...(nameSource ? { nameSource } : {}) };
|
|
21
|
+
yield request;
|
|
22
|
+
if (request.found === undefined)
|
|
23
|
+
throw new TypeError('Incomplete XML attribute lookup');
|
|
24
|
+
return request.found;
|
|
25
|
+
}
|
|
26
|
+
*append(name, prefix, localName, value, source, nameSource, localNameSource, prefixSource) {
|
|
27
|
+
if (!this.external) {
|
|
28
|
+
this.names.set(name, value);
|
|
29
|
+
this.records.push({ name, prefix, localName });
|
|
30
|
+
this.state = { reference: 0, first: 1, length: this.records.length, size: this.names.size };
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const request = { attributeOperation: 'append', state: this.state, attribute: { name, prefix, localName, value, ...(source ? { source } : {}), ...(nameSource ? { nameSource } : {}), ...(localNameSource ? { localNameSource } : {}), ...(prefixSource ? { prefixSource } : {}) } };
|
|
34
|
+
yield request;
|
|
35
|
+
if (!request.result)
|
|
36
|
+
throw new TypeError('Incomplete XML attribute append');
|
|
37
|
+
this.state = request.result;
|
|
38
|
+
}
|
|
39
|
+
*read(reference, values) {
|
|
40
|
+
if (!this.external) {
|
|
41
|
+
const attribute = this.records[reference - 1];
|
|
42
|
+
return { ...attribute, value: values ? this.names.get(attribute.name) : '', next: reference < this.length ? reference + 1 : 0 };
|
|
43
|
+
}
|
|
44
|
+
const request = { attributeOperation: 'read', state: this.state, reference, values };
|
|
45
|
+
yield request;
|
|
46
|
+
if (!request.result)
|
|
47
|
+
throw new TypeError('Incomplete XML attribute read');
|
|
48
|
+
return request.result;
|
|
49
|
+
}
|
|
50
|
+
*expanded(name, namespace, nameSource) {
|
|
51
|
+
if (!this.external) {
|
|
52
|
+
const found = this.expandedNames.has(name);
|
|
53
|
+
this.expandedNames.add(name);
|
|
54
|
+
return found;
|
|
55
|
+
}
|
|
56
|
+
const request = { attributeOperation: 'expanded', state: this.state, name, ...(namespace ? { namespace } : {}), ...(nameSource ? { nameSource } : {}) };
|
|
57
|
+
yield request;
|
|
58
|
+
if (request.found === undefined)
|
|
59
|
+
throw new TypeError('Incomplete XML expanded attribute lookup');
|
|
60
|
+
return request.found;
|
|
61
|
+
}
|
|
62
|
+
}
|
package/dist/xml-ast/frames.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { XmlSourceStep, XmlSourceSpan } from './source.js';
|
|
2
|
+
import type { XmlContent, XmlElement, XmlName } from './index.js';
|
|
2
3
|
export interface XmlParserFrame {
|
|
3
4
|
element: XmlElement;
|
|
4
5
|
content: XmlContent[] | undefined;
|
|
5
6
|
name: string;
|
|
6
7
|
namespaces: Map<string, string>;
|
|
8
|
+
namespaceScope?: XmlNamespaceScope;
|
|
7
9
|
}
|
|
8
10
|
export type XmlFrameRequest = {
|
|
9
11
|
readonly frameOperation: 'push';
|
|
@@ -26,3 +28,40 @@ export declare class XmlFrames {
|
|
|
26
28
|
push(frame: XmlParserFrame): Generator<XmlFrameRequest, void, void>;
|
|
27
29
|
pop(): Generator<XmlFrameRequest, XmlParserFrame | undefined, void>;
|
|
28
30
|
}
|
|
31
|
+
/** A host-owned immutable namespace scope; count includes the built-in xml prefix. */
|
|
32
|
+
export interface XmlNamespaceScope {
|
|
33
|
+
readonly reference: number;
|
|
34
|
+
readonly size: number;
|
|
35
|
+
}
|
|
36
|
+
export type XmlNamespaceRequest = {
|
|
37
|
+
readonly namespaceOperation: 'reference';
|
|
38
|
+
readonly scope: XmlNamespaceScope;
|
|
39
|
+
readonly prefix: string;
|
|
40
|
+
readonly prefixSource?: XmlSourceSpan;
|
|
41
|
+
reference?: number;
|
|
42
|
+
complete?: true;
|
|
43
|
+
} | {
|
|
44
|
+
readonly namespaceOperation: 'has';
|
|
45
|
+
readonly scope: XmlNamespaceScope;
|
|
46
|
+
readonly prefix: string;
|
|
47
|
+
readonly prefixSource?: XmlSourceSpan;
|
|
48
|
+
found?: boolean;
|
|
49
|
+
} | {
|
|
50
|
+
readonly namespaceOperation: 'get';
|
|
51
|
+
readonly scope: XmlNamespaceScope;
|
|
52
|
+
readonly prefix: string;
|
|
53
|
+
readonly prefixSource?: XmlSourceSpan;
|
|
54
|
+
value?: string;
|
|
55
|
+
complete?: true;
|
|
56
|
+
} | {
|
|
57
|
+
readonly namespaceOperation: 'set';
|
|
58
|
+
readonly scope: XmlNamespaceScope;
|
|
59
|
+
readonly prefix: string;
|
|
60
|
+
readonly prefixSource?: XmlSourceSpan;
|
|
61
|
+
readonly value: string | Generator<XmlSourceStep | string, void, void>;
|
|
62
|
+
result?: XmlNamespaceScope;
|
|
63
|
+
};
|
|
64
|
+
export declare function namespaceValue(scope: Map<string, string> | XmlNamespaceScope, prefix: string, prefixSource?: XmlSourceSpan): Generator<XmlNamespaceRequest, string | undefined, void>;
|
|
65
|
+
export declare function namespaceMetadata(scope: Map<string, string> | XmlNamespaceScope, prefix: string, deferred?: boolean, prefixSource?: XmlSourceSpan): Generator<XmlNamespaceRequest, Pick<XmlName, 'namespace' | 'namespaceReference'>, void>;
|
|
66
|
+
export declare function hasNamespace(scope: Map<string, string> | XmlNamespaceScope, prefix: string, prefixSource?: XmlSourceSpan): Generator<XmlNamespaceRequest, boolean, void>;
|
|
67
|
+
export declare function bindNamespace(scope: Map<string, string> | XmlNamespaceScope, prefix: string, value: string | Generator<XmlSourceStep | string, void, void>, prefixSource?: XmlSourceSpan): Generator<XmlNamespaceRequest, Map<string, string> | XmlNamespaceScope, void>;
|
package/dist/xml-ast/frames.js
CHANGED
|
@@ -43,3 +43,45 @@ export class XmlFrames {
|
|
|
43
43
|
return frame;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
+
export function* namespaceValue(scope, prefix, prefixSource) {
|
|
47
|
+
if (scope instanceof Map)
|
|
48
|
+
return scope.get(prefix);
|
|
49
|
+
const request = { namespaceOperation: 'get', scope, prefix, ...(prefixSource ? { prefixSource } : {}) };
|
|
50
|
+
yield request;
|
|
51
|
+
if (!request.complete)
|
|
52
|
+
throw new TypeError('Incomplete XML namespace read');
|
|
53
|
+
return request.value;
|
|
54
|
+
}
|
|
55
|
+
export function* namespaceMetadata(scope, prefix, deferred = false, prefixSource) {
|
|
56
|
+
if (!deferred || scope instanceof Map)
|
|
57
|
+
return { namespace: (yield* namespaceValue(scope, prefix, prefixSource)) ?? '' };
|
|
58
|
+
if (prefix === 'xml')
|
|
59
|
+
return { namespace: 'http://www.w3.org/XML/1998/namespace' };
|
|
60
|
+
const request = { namespaceOperation: 'reference', scope, prefix, ...(prefixSource ? { prefixSource } : {}) };
|
|
61
|
+
yield request;
|
|
62
|
+
if (!request.complete)
|
|
63
|
+
throw new TypeError('Incomplete XML namespace reference lookup');
|
|
64
|
+
return { namespace: '', ...(request.reference === undefined ? {} : { namespaceReference: request.reference }) };
|
|
65
|
+
}
|
|
66
|
+
export function* hasNamespace(scope, prefix, prefixSource) {
|
|
67
|
+
if (scope instanceof Map)
|
|
68
|
+
return scope.has(prefix);
|
|
69
|
+
const request = { namespaceOperation: 'has', scope, prefix, ...(prefixSource ? { prefixSource } : {}) };
|
|
70
|
+
yield request;
|
|
71
|
+
if (request.found === undefined)
|
|
72
|
+
throw new TypeError('Incomplete XML namespace membership lookup');
|
|
73
|
+
return request.found;
|
|
74
|
+
}
|
|
75
|
+
export function* bindNamespace(scope, prefix, value, prefixSource) {
|
|
76
|
+
if (scope instanceof Map) {
|
|
77
|
+
if (typeof value !== 'string')
|
|
78
|
+
throw new TypeError('Streamed XML namespace values require external scopes');
|
|
79
|
+
scope.set(prefix, value);
|
|
80
|
+
return scope;
|
|
81
|
+
}
|
|
82
|
+
const request = { namespaceOperation: 'set', scope, prefix, value, ...(prefixSource ? { prefixSource } : {}) };
|
|
83
|
+
yield request;
|
|
84
|
+
if (!request.result)
|
|
85
|
+
throw new TypeError('Incomplete XML namespace update');
|
|
86
|
+
return request.result;
|
|
87
|
+
}
|
package/dist/xml-ast/index.d.ts
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export type {
|
|
1
|
+
import { type XmlAttributeRequest } from "./attributes.js";
|
|
2
|
+
export type { XmlAttributeRequest, XmlAttributeRecord, XmlAttributeState } from "./attributes.js";
|
|
3
|
+
import { type XmlNamespaceRequest, type XmlFrameRequest } from "./frames.js";
|
|
4
|
+
export type { XmlParserFrame, XmlFrameRequest, XmlNamespaceScope, XmlNamespaceRequest } from "./frames.js";
|
|
3
5
|
export { normalizeXmlChunks } from "./characters.js";
|
|
4
|
-
import { type XmlSourceStep } from "./source.js";
|
|
5
|
-
export type { XmlSourceRead, XmlSourceStep } from "./source.js";
|
|
6
|
+
import { type XmlSourceSpan, type XmlSourceStep } from "./source.js";
|
|
7
|
+
export type { XmlSourceRead, XmlSourceSpan, XmlSourceStep } from "./source.js";
|
|
6
8
|
import type { XmlStreamEvent } from "./stream.js";
|
|
7
9
|
export { XmlLimitError } from "./errors.js";
|
|
8
10
|
export interface XmlName {
|
|
9
11
|
readonly name: string;
|
|
12
|
+
readonly nameSource?: XmlSourceSpan;
|
|
13
|
+
readonly nameReference?: number;
|
|
14
|
+
readonly localNameSource?: XmlSourceSpan;
|
|
15
|
+
readonly localNameReference?: number;
|
|
16
|
+
readonly prefix?: string;
|
|
17
|
+
readonly prefixSource?: XmlSourceSpan;
|
|
18
|
+
readonly prefixReference?: number;
|
|
10
19
|
readonly namespace: string;
|
|
20
|
+
readonly namespaceReference?: number;
|
|
11
21
|
readonly localName: string;
|
|
12
22
|
}
|
|
13
23
|
export interface XmlAttribute extends XmlName {
|
|
@@ -19,6 +29,8 @@ export type XmlContent = XmlElement | {
|
|
|
19
29
|
} | {
|
|
20
30
|
readonly kind: "processing-instruction";
|
|
21
31
|
readonly target: string;
|
|
32
|
+
readonly targetSource?: XmlSourceSpan;
|
|
33
|
+
readonly targetReference?: number;
|
|
22
34
|
readonly text: string;
|
|
23
35
|
};
|
|
24
36
|
export interface XmlElement extends XmlName {
|
|
@@ -61,11 +73,27 @@ export interface XmlSourceLimits extends XmlStepLimits {
|
|
|
61
73
|
readonly fragmentContent?: boolean;
|
|
62
74
|
/** Store active parser frames through host-serviced requests. Requires retainTree: false. */
|
|
63
75
|
readonly storeFrames?: boolean;
|
|
76
|
+
/** Resolve namespace scopes through host-serviced requests. Requires retainTree: false. */
|
|
77
|
+
readonly storeNamespaces?: boolean;
|
|
78
|
+
/** Carry host namespace token references in event metadata. Requires stored namespaces. */
|
|
79
|
+
readonly deferNamespaces?: boolean;
|
|
80
|
+
/** Emit long processing-instruction targets as source spans. Requires fragmentContent. */
|
|
81
|
+
readonly deferContentNames?: boolean;
|
|
82
|
+
/** Defer long element names and, with external namespaces, their prefixes. */
|
|
83
|
+
readonly deferElementNames?: boolean;
|
|
84
|
+
/** Defer attribute names and namespace declaration prefixes to source spans. */
|
|
85
|
+
readonly deferAttributeNames?: boolean;
|
|
86
|
+
/** Store attribute collections through host requests and emit resolved attributes individually. */
|
|
87
|
+
readonly storeAttributes?: boolean;
|
|
88
|
+
readonly fragmentAttributes?: boolean;
|
|
89
|
+
readonly onAttribute?: (attribute: XmlAttribute, element: XmlElement, continuation?: boolean) => void;
|
|
64
90
|
}
|
|
65
|
-
export type XmlParseStep = XmlSourceStep | XmlFrameRequest;
|
|
91
|
+
export type XmlParseStep = XmlSourceStep | XmlFrameRequest | XmlNamespaceRequest | XmlAttributeRequest;
|
|
66
92
|
/** Parse a validated, BOM-free, line-normalized UTF-16 source via bounded read requests. */
|
|
67
93
|
export declare function parseXmlSourceSteps(length: number | undefined, limits?: XmlStepLimits & {
|
|
68
94
|
readonly storeFrames?: false;
|
|
95
|
+
readonly storeNamespaces?: false;
|
|
96
|
+
readonly storeAttributes?: false;
|
|
69
97
|
}): Generator<XmlSourceStep, XmlElement, void>;
|
|
70
98
|
export declare function parseXmlSourceSteps(length: number | undefined, limits: XmlSourceLimits): Generator<XmlParseStep, XmlElement, void>;
|
|
71
99
|
export declare function parseXmlSteps(input: string, limits?: XmlStepLimits): Generator<number, XmlElement, void>;
|