@openedges/pkl-napi 0.0.0-stage → 0.32.0-rc.3
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/LICENSE +190 -0
- package/NOTICE +84 -0
- package/README.md +68 -2
- package/THIRD-PARTY-NOTICES.md +335 -0
- package/dist/index.cjs +2606 -0
- package/dist/index.d.ts +534 -0
- package/dist/index.mjs +38 -0
- package/native/pkl_napi.darwin-arm64.node +0 -0
- package/native/pkl_napi.darwin-x64.node +0 -0
- package/native/pkl_napi.linux-arm64-gnu.node +0 -0
- package/native/pkl_napi.linux-arm64-musl.node +0 -0
- package/native/pkl_napi.linux-x64-gnu.node +0 -0
- package/native/pkl_napi.linux-x64-musl.node +0 -0
- package/native/pkl_napi.win32-x64.node +0 -0
- package/package.json +69 -4
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
export const PKL_VERSION: "0.32.0";
|
|
2
|
+
|
|
3
|
+
export interface PklCapabilities {
|
|
4
|
+
vfs: boolean;
|
|
5
|
+
asyncModuleLoader: boolean;
|
|
6
|
+
asyncResourceLoader: boolean;
|
|
7
|
+
nativeFs: boolean;
|
|
8
|
+
nativeHttp: boolean;
|
|
9
|
+
externalReaders: boolean;
|
|
10
|
+
modulePathJar: boolean;
|
|
11
|
+
projectResolution: boolean;
|
|
12
|
+
packageCache: boolean;
|
|
13
|
+
formatter: boolean;
|
|
14
|
+
repl: boolean;
|
|
15
|
+
schema: boolean;
|
|
16
|
+
analyzeImports: boolean;
|
|
17
|
+
bigint64: boolean;
|
|
18
|
+
uint8ArrayBytes: boolean;
|
|
19
|
+
clock64Bit: boolean;
|
|
20
|
+
platform: string;
|
|
21
|
+
runtime: "wasm-browser" | "wasm-node" | "napi-node";
|
|
22
|
+
arch: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function capabilities(): PklCapabilities;
|
|
26
|
+
|
|
27
|
+
export type PklErrorKind =
|
|
28
|
+
| "evaluation"
|
|
29
|
+
| "security"
|
|
30
|
+
| "timeout"
|
|
31
|
+
| "closed"
|
|
32
|
+
| "cancelled"
|
|
33
|
+
| "configuration"
|
|
34
|
+
| "decode"
|
|
35
|
+
| "io"
|
|
36
|
+
| "invalid-argument"
|
|
37
|
+
| "capability-unavailable";
|
|
38
|
+
|
|
39
|
+
export class PklError extends Error {
|
|
40
|
+
readonly kind: PklErrorKind;
|
|
41
|
+
readonly code: PklErrorKind;
|
|
42
|
+
readonly capability?: keyof PklCapabilities;
|
|
43
|
+
constructor(message: string, kind?: PklErrorKind, capability?: keyof PklCapabilities);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export class ModuleSource {
|
|
47
|
+
readonly uri: string;
|
|
48
|
+
readonly contents?: string;
|
|
49
|
+
constructor(uri: string, contents?: string);
|
|
50
|
+
static text(text: string, uri?: string): ModuleSource;
|
|
51
|
+
static uri(uri: string): ModuleSource;
|
|
52
|
+
static path(path: string): ModuleSource;
|
|
53
|
+
static modulePath(path: string): ModuleSource;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export class PklDuration {
|
|
57
|
+
readonly value: number;
|
|
58
|
+
readonly unit: string;
|
|
59
|
+
constructor(value: number, unit: string);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export class PklDataSize {
|
|
63
|
+
readonly value: number;
|
|
64
|
+
readonly unit: string;
|
|
65
|
+
constructor(value: number, unit: string);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export class PklPair<A = PklValue, B = PklValue> {
|
|
69
|
+
readonly first: A;
|
|
70
|
+
readonly second: B;
|
|
71
|
+
constructor(first: A, second: B);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export class PklRegex {
|
|
75
|
+
readonly pattern: string;
|
|
76
|
+
constructor(pattern: string);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export class PklObject {
|
|
80
|
+
readonly className: string;
|
|
81
|
+
readonly moduleUri: string;
|
|
82
|
+
readonly properties: Record<string, PklValue>;
|
|
83
|
+
readonly entries: Map<PklValue, PklValue>;
|
|
84
|
+
readonly elements: PklValue[];
|
|
85
|
+
constructor(
|
|
86
|
+
className: string,
|
|
87
|
+
moduleUri: string,
|
|
88
|
+
properties?: Record<string, PklValue>,
|
|
89
|
+
entries?: Map<PklValue, PklValue>,
|
|
90
|
+
elements?: PklValue[],
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export class PklClass {
|
|
95
|
+
readonly name: string;
|
|
96
|
+
readonly moduleUri: string;
|
|
97
|
+
constructor(name: string, moduleUri: string);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export class PklTypeAlias {
|
|
101
|
+
readonly name: string;
|
|
102
|
+
readonly moduleUri: string;
|
|
103
|
+
constructor(name: string, moduleUri: string);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export class PklIntSeq {
|
|
107
|
+
readonly start: bigint;
|
|
108
|
+
readonly end: bigint;
|
|
109
|
+
readonly step: bigint;
|
|
110
|
+
constructor(start: bigint, end: bigint, step: bigint);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export class PklFunction {
|
|
114
|
+
constructor();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export class PklReference {
|
|
118
|
+
readonly domain: PklValue;
|
|
119
|
+
readonly data: PklValue;
|
|
120
|
+
readonly path: PklValue[];
|
|
121
|
+
constructor(domain: PklValue, data: PklValue, path?: PklValue[]);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export type PklValue =
|
|
125
|
+
| null
|
|
126
|
+
| boolean
|
|
127
|
+
| bigint
|
|
128
|
+
| number
|
|
129
|
+
| string
|
|
130
|
+
| Uint8Array
|
|
131
|
+
| PklValue[]
|
|
132
|
+
| Set<PklValue>
|
|
133
|
+
| Map<PklValue, PklValue>
|
|
134
|
+
| PklDuration
|
|
135
|
+
| PklDataSize
|
|
136
|
+
| PklPair
|
|
137
|
+
| PklRegex
|
|
138
|
+
| PklObject
|
|
139
|
+
| PklClass
|
|
140
|
+
| PklTypeAlias
|
|
141
|
+
| PklIntSeq
|
|
142
|
+
| PklFunction
|
|
143
|
+
| PklReference;
|
|
144
|
+
|
|
145
|
+
export interface StackFrame {
|
|
146
|
+
moduleUri: string;
|
|
147
|
+
memberName: string | null;
|
|
148
|
+
sourceLines: string[];
|
|
149
|
+
startLine: number;
|
|
150
|
+
startColumn: number;
|
|
151
|
+
endLine: number;
|
|
152
|
+
endColumn: number;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export interface PathElement {
|
|
156
|
+
name: string;
|
|
157
|
+
isDirectory: boolean;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface ModuleReader {
|
|
161
|
+
scheme: string;
|
|
162
|
+
isLocal?: boolean;
|
|
163
|
+
isGlobbable?: boolean;
|
|
164
|
+
hasHierarchicalUris?: boolean;
|
|
165
|
+
isCached?: boolean;
|
|
166
|
+
read(uri: string): string | Promise<string>;
|
|
167
|
+
listElements?(uri: string): PathElement[] | Promise<PathElement[]>;
|
|
168
|
+
hasElement?(uri: string): boolean | Promise<boolean>;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export interface ResourceReader {
|
|
172
|
+
scheme: string;
|
|
173
|
+
isGlobbable?: boolean;
|
|
174
|
+
hasHierarchicalUris?: boolean;
|
|
175
|
+
read(
|
|
176
|
+
uri: string,
|
|
177
|
+
): Uint8Array | string | null | undefined | Promise<Uint8Array | string | null | undefined>;
|
|
178
|
+
listElements?(uri: string): PathElement[] | Promise<PathElement[]>;
|
|
179
|
+
hasElement?(uri: string): boolean | Promise<boolean>;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export interface SecurityManager {
|
|
183
|
+
checkResolveModule?(uri: string): void | Promise<void>;
|
|
184
|
+
checkImportModule?(importingUri: string, importedUri: string): void | Promise<void>;
|
|
185
|
+
checkReadResource?(uri: string): void | Promise<void>;
|
|
186
|
+
checkResolveResource?(uri: string): void | Promise<void>;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export interface Logger {
|
|
190
|
+
trace?(msg: string, frame?: StackFrame): void | Promise<void>;
|
|
191
|
+
warn?(msg: string, frame?: StackFrame): void | Promise<void>;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export interface HttpOptions {
|
|
195
|
+
caCertificates?: (string | Uint8Array)[];
|
|
196
|
+
caCertificateFiles?: string[];
|
|
197
|
+
caCertificatePems?: (string | Uint8Array)[];
|
|
198
|
+
proxy?: { address?: string; noProxy?: string[] };
|
|
199
|
+
rewrites?: Record<string, string>;
|
|
200
|
+
headers?: Record<string, Record<string, string>>;
|
|
201
|
+
testPort?: number;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export interface ExternalReaderSpec {
|
|
205
|
+
executable: string;
|
|
206
|
+
arguments?: string[];
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export interface EvaluatorOptions {
|
|
210
|
+
allowedModules?: string[];
|
|
211
|
+
allowedResources?: string[];
|
|
212
|
+
rootDir?: string;
|
|
213
|
+
workingDir?: string;
|
|
214
|
+
properties?: Record<string, string> | Map<string, string>;
|
|
215
|
+
env?: Record<string, string> | Map<string, string>;
|
|
216
|
+
outputFormat?: string;
|
|
217
|
+
traceMode?: "compact" | "pretty";
|
|
218
|
+
powerAssertions?: boolean;
|
|
219
|
+
color?: boolean | "never" | "auto" | "always";
|
|
220
|
+
timeoutMs?: number | bigint;
|
|
221
|
+
signal?: AbortSignal;
|
|
222
|
+
logger?: Logger;
|
|
223
|
+
frameTransformer?: (frame: StackFrame) => StackFrame | Promise<StackFrame>;
|
|
224
|
+
securityManager?: SecurityManager;
|
|
225
|
+
moduleReaders?: ModuleReader[];
|
|
226
|
+
resourceReaders?: ResourceReader[];
|
|
227
|
+
modulePaths?: string[];
|
|
228
|
+
projectDir?: string;
|
|
229
|
+
project?: Project;
|
|
230
|
+
cacheDir?: string | null;
|
|
231
|
+
noCache?: boolean;
|
|
232
|
+
testMode?: boolean;
|
|
233
|
+
http?: HttpOptions;
|
|
234
|
+
externalModuleReaders?: Record<string, ExternalReaderSpec>;
|
|
235
|
+
externalResourceReaders?: Record<string, ExternalReaderSpec>;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export interface CallOptions {
|
|
239
|
+
timeoutMs?: number | bigint;
|
|
240
|
+
signal?: AbortSignal;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export interface TestOptions extends CallOptions {
|
|
244
|
+
overwrite?: boolean;
|
|
245
|
+
reporter?: "spec" | "minimal" | "junit";
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export interface SourceLocation {
|
|
249
|
+
startLine: number;
|
|
250
|
+
endLine: number;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export interface TypeParameter {
|
|
254
|
+
name: string;
|
|
255
|
+
variance: "invariant" | "covariant" | "contravariant";
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export interface PClassInfo {
|
|
259
|
+
moduleName: string;
|
|
260
|
+
simpleName: string;
|
|
261
|
+
qualifiedName: string;
|
|
262
|
+
displayName: string;
|
|
263
|
+
moduleUri: string;
|
|
264
|
+
isModuleClass: boolean;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export interface TypeAliasInfo {
|
|
268
|
+
moduleName: string;
|
|
269
|
+
simpleName: string;
|
|
270
|
+
qualifiedName: string;
|
|
271
|
+
displayName: string;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export type PType =
|
|
275
|
+
| { kind: "unknown" }
|
|
276
|
+
| { kind: "nothing" }
|
|
277
|
+
| { kind: "module" }
|
|
278
|
+
| { kind: "stringLiteral"; literal: string }
|
|
279
|
+
| { kind: "class"; classInfo: PClassInfo; typeArguments: PType[] }
|
|
280
|
+
| { kind: "nullable"; baseType: PType }
|
|
281
|
+
| { kind: "union"; elementTypes: PType[] }
|
|
282
|
+
| { kind: "function"; parameterTypes: PType[]; returnType: PType }
|
|
283
|
+
| { kind: "constrained"; baseType: PType; constraints: string[] }
|
|
284
|
+
| { kind: "alias"; aliasInfo: TypeAliasInfo; typeArguments: PType[]; aliasedType: PType }
|
|
285
|
+
| { kind: "typeVariable"; typeParameter: TypeParameter };
|
|
286
|
+
|
|
287
|
+
export interface PClassProperty {
|
|
288
|
+
name: string;
|
|
289
|
+
simpleName: string;
|
|
290
|
+
moduleName: string;
|
|
291
|
+
docComment: string | null;
|
|
292
|
+
sourceLocation: SourceLocation;
|
|
293
|
+
modifiers: string[];
|
|
294
|
+
annotations: PklObject[];
|
|
295
|
+
type: PType;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export interface PClassMethod {
|
|
299
|
+
name: string;
|
|
300
|
+
simpleName: string;
|
|
301
|
+
moduleName: string;
|
|
302
|
+
docComment: string | null;
|
|
303
|
+
sourceLocation: SourceLocation;
|
|
304
|
+
modifiers: string[];
|
|
305
|
+
annotations: PklObject[];
|
|
306
|
+
typeParameters: TypeParameter[];
|
|
307
|
+
parameters: Record<string, PType>;
|
|
308
|
+
returnType: PType;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export interface PClassSchema extends PClassInfo {
|
|
312
|
+
docComment: string | null;
|
|
313
|
+
sourceLocation: SourceLocation;
|
|
314
|
+
modifiers: string[];
|
|
315
|
+
annotations: PklObject[];
|
|
316
|
+
typeParameters: TypeParameter[];
|
|
317
|
+
superclass: PClassInfo | null;
|
|
318
|
+
supertype: PType | null;
|
|
319
|
+
properties: Record<string, PClassProperty>;
|
|
320
|
+
allProperties: Record<string, PClassProperty>;
|
|
321
|
+
methods: Record<string, PClassMethod>;
|
|
322
|
+
allMethods: Record<string, PClassMethod>;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export interface TypeAliasSchema extends TypeAliasInfo {
|
|
326
|
+
docComment: string | null;
|
|
327
|
+
sourceLocation: SourceLocation;
|
|
328
|
+
modifiers: string[];
|
|
329
|
+
annotations: PklObject[];
|
|
330
|
+
typeParameters: TypeParameter[];
|
|
331
|
+
aliasedType: PType;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export interface ModuleSchema {
|
|
335
|
+
moduleUri: string;
|
|
336
|
+
moduleName: string;
|
|
337
|
+
shortModuleName: string;
|
|
338
|
+
isAmend: boolean;
|
|
339
|
+
isExtend: boolean;
|
|
340
|
+
docComment: string | null;
|
|
341
|
+
annotations: PklObject[];
|
|
342
|
+
supermodule: ModuleSchema | null;
|
|
343
|
+
moduleClass: PClassSchema;
|
|
344
|
+
classes: Record<string, PClassSchema>;
|
|
345
|
+
allClasses: Record<string, PClassSchema>;
|
|
346
|
+
typeAliases: Record<string, TypeAliasSchema>;
|
|
347
|
+
allTypeAliases: Record<string, TypeAliasSchema>;
|
|
348
|
+
imports: Record<string, string>;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export interface TestFailure {
|
|
352
|
+
kind: string;
|
|
353
|
+
message: string;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export interface TestError {
|
|
357
|
+
message: string;
|
|
358
|
+
rendered: string;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export interface TestResult {
|
|
362
|
+
name: string;
|
|
363
|
+
totalAsserts: number;
|
|
364
|
+
failed: boolean;
|
|
365
|
+
isExampleWritten: boolean;
|
|
366
|
+
failures: TestFailure[];
|
|
367
|
+
errors: TestError[];
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
export interface TestSectionResults {
|
|
371
|
+
name: "facts" | "examples";
|
|
372
|
+
failed: boolean;
|
|
373
|
+
totalTests: number;
|
|
374
|
+
totalFailures: number;
|
|
375
|
+
totalAsserts: number;
|
|
376
|
+
results: TestResult[];
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
export interface TestResults {
|
|
380
|
+
moduleName: string;
|
|
381
|
+
displayUri: string;
|
|
382
|
+
failed: boolean;
|
|
383
|
+
totalTests: number;
|
|
384
|
+
totalFailures: number;
|
|
385
|
+
totalAsserts: number;
|
|
386
|
+
totalAssertsFailed: number;
|
|
387
|
+
facts: TestSectionResults;
|
|
388
|
+
examples: TestSectionResults;
|
|
389
|
+
logs: string;
|
|
390
|
+
error: TestError | null;
|
|
391
|
+
rendered: string;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export interface ProjectPackageInfo {
|
|
395
|
+
name: string;
|
|
396
|
+
baseUri: string;
|
|
397
|
+
version: string;
|
|
398
|
+
uri: string;
|
|
399
|
+
packageZipUrl: string;
|
|
400
|
+
description: string | null;
|
|
401
|
+
authors: string[];
|
|
402
|
+
website: string | null;
|
|
403
|
+
documentation: string | null;
|
|
404
|
+
sourceCode: string | null;
|
|
405
|
+
sourceCodeUrlScheme: string | null;
|
|
406
|
+
license: string | null;
|
|
407
|
+
issueTracker: string | null;
|
|
408
|
+
apiTests: string[];
|
|
409
|
+
exclude: string[];
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
export interface ProjectEvaluatorSettings {
|
|
413
|
+
allowedModules: string[] | null;
|
|
414
|
+
allowedResources: string[] | null;
|
|
415
|
+
rootDir: string | null;
|
|
416
|
+
moduleCacheDir: string | null;
|
|
417
|
+
noCache: boolean | null;
|
|
418
|
+
traceMode: string | null;
|
|
419
|
+
color: string | null;
|
|
420
|
+
timeoutMs: bigint | null;
|
|
421
|
+
env: Record<string, string> | null;
|
|
422
|
+
externalProperties: Record<string, string> | null;
|
|
423
|
+
modulePath: string[] | null;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
export class Project {
|
|
427
|
+
readonly projectDir: string;
|
|
428
|
+
readonly projectFileUri: string;
|
|
429
|
+
readonly projectBaseUri: string;
|
|
430
|
+
readonly package: ProjectPackageInfo | null;
|
|
431
|
+
readonly evaluatorSettings: ProjectEvaluatorSettings | null;
|
|
432
|
+
readonly tests: string[];
|
|
433
|
+
static load(
|
|
434
|
+
dirOrFile: string,
|
|
435
|
+
options?: {
|
|
436
|
+
env?: Record<string, string> | Map<string, string>;
|
|
437
|
+
properties?: Record<string, string> | Map<string, string>;
|
|
438
|
+
},
|
|
439
|
+
): Promise<Project>;
|
|
440
|
+
static loadSync(
|
|
441
|
+
dirOrFile: string,
|
|
442
|
+
options?: {
|
|
443
|
+
env?: Record<string, string> | Map<string, string>;
|
|
444
|
+
properties?: Record<string, string> | Map<string, string>;
|
|
445
|
+
},
|
|
446
|
+
): Project;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
export class Evaluator {
|
|
450
|
+
readonly isClosed: boolean;
|
|
451
|
+
evaluateOutputText(source: ModuleSource, options?: CallOptions): Promise<string>;
|
|
452
|
+
evaluateOutputTextSync(source: ModuleSource, options?: CallOptions): string;
|
|
453
|
+
evaluateOutputBytes(source: ModuleSource, options?: CallOptions): Promise<Uint8Array>;
|
|
454
|
+
evaluateOutputBytesSync(source: ModuleSource, options?: CallOptions): Uint8Array;
|
|
455
|
+
evaluateOutputFiles(source: ModuleSource, options?: CallOptions): Promise<Map<string, Uint8Array>>;
|
|
456
|
+
evaluateOutputFilesSync(source: ModuleSource, options?: CallOptions): Map<string, Uint8Array>;
|
|
457
|
+
evaluateOutputValue(source: ModuleSource, options?: CallOptions): Promise<PklValue>;
|
|
458
|
+
evaluateOutputValueSync(source: ModuleSource, options?: CallOptions): PklValue;
|
|
459
|
+
evaluateExpression(source: ModuleSource, expr: string, options?: CallOptions): Promise<string>;
|
|
460
|
+
evaluateExpressionSync(source: ModuleSource, expr: string, options?: CallOptions): string;
|
|
461
|
+
evaluateExpressionValue(
|
|
462
|
+
source: ModuleSource,
|
|
463
|
+
expr: string,
|
|
464
|
+
options?: CallOptions,
|
|
465
|
+
): Promise<PklValue>;
|
|
466
|
+
evaluateExpressionValueSync(source: ModuleSource, expr: string, options?: CallOptions): PklValue;
|
|
467
|
+
evaluateExpressionPklBinary(
|
|
468
|
+
source: ModuleSource,
|
|
469
|
+
expr: string,
|
|
470
|
+
options?: CallOptions,
|
|
471
|
+
): Promise<Uint8Array>;
|
|
472
|
+
evaluateExpressionPklBinarySync(
|
|
473
|
+
source: ModuleSource,
|
|
474
|
+
expr: string,
|
|
475
|
+
options?: CallOptions,
|
|
476
|
+
): Uint8Array;
|
|
477
|
+
evaluateSchema(source: ModuleSource, options?: CallOptions): Promise<ModuleSchema>;
|
|
478
|
+
evaluateSchemaSync(source: ModuleSource, options?: CallOptions): ModuleSchema;
|
|
479
|
+
evaluateTest(source: ModuleSource, options?: TestOptions): Promise<TestResults>;
|
|
480
|
+
evaluateTestSync(source: ModuleSource, options?: TestOptions): TestResults;
|
|
481
|
+
cancel(): void;
|
|
482
|
+
close(): Promise<void>;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
export function createEvaluator(options?: EvaluatorOptions): Promise<Evaluator>;
|
|
486
|
+
export function createEvaluatorSync(options?: EvaluatorOptions): Evaluator;
|
|
487
|
+
|
|
488
|
+
export interface ReplResponse {
|
|
489
|
+
kind: "evalSuccess" | "evalError" | "incompleteInput" | "invalidRequest" | "internalError";
|
|
490
|
+
result?: string;
|
|
491
|
+
message?: string;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
export class ReplSession {
|
|
495
|
+
readonly isClosed: boolean;
|
|
496
|
+
eval(input: string, options?: { force?: boolean; id?: string }): Promise<ReplResponse[]>;
|
|
497
|
+
load(uriOrSource: string | ModuleSource, options?: { id?: string }): Promise<ReplResponse[]>;
|
|
498
|
+
reset(options?: { id?: string }): Promise<void>;
|
|
499
|
+
complete(prefix: string, options?: { id?: string }): Promise<string[]>;
|
|
500
|
+
close(): Promise<void>;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
export function createRepl(options?: EvaluatorOptions): Promise<ReplSession>;
|
|
504
|
+
|
|
505
|
+
export interface ImportGraph {
|
|
506
|
+
imports: Record<string, string[]>;
|
|
507
|
+
resolvedImports: Record<string, string>;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
export function analyzeImportGraph(
|
|
511
|
+
uris: (string | ModuleSource)[],
|
|
512
|
+
options?: EvaluatorOptions,
|
|
513
|
+
): Promise<ImportGraph>;
|
|
514
|
+
|
|
515
|
+
export function format(source: string, options?: { grammarVersion?: 1 | 2 }): string;
|
|
516
|
+
export function decodePklBinary(bytes: Uint8Array): PklValue;
|
|
517
|
+
export function monotonicClockMs(): bigint;
|
|
518
|
+
|
|
519
|
+
export function roundtripValue<T extends PklValue>(val: T): PklValue;
|
|
520
|
+
export function roundtripInteger(val: bigint): bigint;
|
|
521
|
+
export function roundtripBytes(val: Uint8Array): Uint8Array;
|
|
522
|
+
export function roundtripString(val: string): string;
|
|
523
|
+
|
|
524
|
+
export interface ConversionBenchmarkResult {
|
|
525
|
+
iterations: number;
|
|
526
|
+
elapsedMs: number;
|
|
527
|
+
nativeElapsedMs: number;
|
|
528
|
+
perIterationUs: number;
|
|
529
|
+
nativePerIterationUs: number;
|
|
530
|
+
lastValue: PklValue;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
export function measureConversion(iterations?: number): ConversionBenchmarkResult;
|
|
534
|
+
export function measureConversion(value: PklValue, iterations?: number): ConversionBenchmarkResult;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
const require = createRequire(import.meta.url);
|
|
4
|
+
const pkg = require("./index.cjs");
|
|
5
|
+
|
|
6
|
+
export const {
|
|
7
|
+
PKL_VERSION,
|
|
8
|
+
capabilities,
|
|
9
|
+
PklError,
|
|
10
|
+
ModuleSource,
|
|
11
|
+
PklDuration,
|
|
12
|
+
PklDataSize,
|
|
13
|
+
PklPair,
|
|
14
|
+
PklRegex,
|
|
15
|
+
PklObject,
|
|
16
|
+
PklClass,
|
|
17
|
+
PklTypeAlias,
|
|
18
|
+
PklIntSeq,
|
|
19
|
+
PklFunction,
|
|
20
|
+
PklReference,
|
|
21
|
+
Evaluator,
|
|
22
|
+
Project,
|
|
23
|
+
ReplSession,
|
|
24
|
+
createEvaluator,
|
|
25
|
+
createEvaluatorSync,
|
|
26
|
+
createRepl,
|
|
27
|
+
analyzeImportGraph,
|
|
28
|
+
format,
|
|
29
|
+
decodePklBinary,
|
|
30
|
+
monotonicClockMs,
|
|
31
|
+
roundtripValue,
|
|
32
|
+
roundtripInteger,
|
|
33
|
+
roundtripBytes,
|
|
34
|
+
roundtripString,
|
|
35
|
+
measureConversion,
|
|
36
|
+
} = pkg;
|
|
37
|
+
|
|
38
|
+
export default pkg;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,71 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openedges/pkl-napi",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.32.0-rc.3",
|
|
4
|
+
"description": "Node.js N-API bindings for the shared pure-Rust Apple Pkl 0.32.0 engine",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/openedges/pkl-rs.git",
|
|
9
|
+
"directory": "packages/pkl-napi"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/openedges/pkl-rs/tree/main/packages/pkl-napi#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/openedges/pkl-rs/issues"
|
|
14
|
+
},
|
|
15
|
+
"main": "./dist/index.cjs",
|
|
16
|
+
"module": "./dist/index.mjs",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.mjs",
|
|
22
|
+
"require": "./dist/index.cjs"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"native",
|
|
28
|
+
"README.md",
|
|
29
|
+
"LICENSE",
|
|
30
|
+
"NOTICE",
|
|
31
|
+
"THIRD-PARTY-NOTICES.md"
|
|
32
|
+
],
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=18.0.0"
|
|
35
|
+
},
|
|
36
|
+
"os": [
|
|
37
|
+
"darwin",
|
|
38
|
+
"linux",
|
|
39
|
+
"win32"
|
|
40
|
+
],
|
|
41
|
+
"cpu": [
|
|
42
|
+
"arm64",
|
|
43
|
+
"x64"
|
|
44
|
+
],
|
|
45
|
+
"pklPlatformSupport": {
|
|
46
|
+
"runtime": "napi-node",
|
|
47
|
+
"napiVersion": 8,
|
|
48
|
+
"linuxGlibcMinimum": "2.28",
|
|
49
|
+
"targets": [
|
|
50
|
+
"darwin-arm64",
|
|
51
|
+
"darwin-x64",
|
|
52
|
+
"linux-x64-gnu",
|
|
53
|
+
"linux-arm64-gnu",
|
|
54
|
+
"linux-x64-musl",
|
|
55
|
+
"linux-arm64-musl",
|
|
56
|
+
"win32-x64-msvc"
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "node ./scripts/build.mjs",
|
|
61
|
+
"test": "node ./test/run.mjs"
|
|
62
|
+
},
|
|
63
|
+
"keywords": [
|
|
64
|
+
"pkl",
|
|
65
|
+
"apple-pkl",
|
|
66
|
+
"configuration",
|
|
67
|
+
"napi",
|
|
68
|
+
"rust",
|
|
69
|
+
"nodejs"
|
|
70
|
+
]
|
|
71
|
+
}
|