nginx-lint-plugin 0.10.3 → 0.10.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/wasm/parser/parser.core.wasm +0 -0
- package/wasm/parser/parser.d.ts +1 -0
- package/wasm/parser/parser.js +220 -7
package/README.md
CHANGED
|
@@ -122,7 +122,7 @@ The WIT definition file is bundled with this package, so `jco componentize` can
|
|
|
122
122
|
"test": "tsc && node --test dist/plugin.test.js"
|
|
123
123
|
},
|
|
124
124
|
"dependencies": {
|
|
125
|
-
"nginx-lint-plugin": "^0.10.
|
|
125
|
+
"nginx-lint-plugin": "^0.10.5"
|
|
126
126
|
},
|
|
127
127
|
"devDependencies": {
|
|
128
128
|
"@bytecodealliance/componentize-js": "^0.19",
|
package/package.json
CHANGED
|
Binary file
|
package/wasm/parser/parser.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export type ParseOutput = import('./interfaces/nginx-lint-plugin-parser-types.js
|
|
|
3
3
|
export type * as NginxLintPluginDataTypes300 from './interfaces/nginx-lint-plugin-data-types.js'; // import nginx-lint:plugin/data-types@3.0.0
|
|
4
4
|
export type * as NginxLintPluginParserTypes300 from './interfaces/nginx-lint-plugin-parser-types.js'; // import nginx-lint:plugin/parser-types@3.0.0
|
|
5
5
|
export function parseConfig(source: string, includeContext: Array<string>): ParseOutput;
|
|
6
|
+
export type Result<T, E> = { tag: 'ok', val: T } | { tag: 'err', val: E };
|
package/wasm/parser/parser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use
|
|
1
|
+
"use components";
|
|
2
2
|
|
|
3
3
|
function promiseWithResolvers() {
|
|
4
4
|
if (Promise.withResolvers) {
|
|
@@ -13,6 +13,9 @@ function promiseWithResolvers() {
|
|
|
13
13
|
return { promise, resolve, reject };
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
+
const symbolDispose = Symbol.dispose || Symbol.for('dispose');
|
|
17
|
+
const symbolAsyncIterator = Symbol.asyncIterator;
|
|
18
|
+
const symbolIterator = Symbol.iterator;
|
|
16
19
|
|
|
17
20
|
const _debugLog = (...args) => {
|
|
18
21
|
if (!globalThis?.process?.env?.JCO_DEBUG) { return; }
|
|
@@ -107,7 +110,7 @@ async function _clearCurrentTask(args) {
|
|
|
107
110
|
const { taskID, componentIdx } = args;
|
|
108
111
|
|
|
109
112
|
const meta = CURRENT_TASK_META[componentIdx];
|
|
110
|
-
if (!meta) { throw new Error(`missing current task meta for component idx [${componentIdx}]`); }
|
|
113
|
+
if (!meta) { throw new Error(`missing current task meta for component idx [${componentIdx}]n`); }
|
|
111
114
|
|
|
112
115
|
if (meta.taskID !== taskID) {
|
|
113
116
|
throw new Error(`task ID [${meta.taskID}] != requested ID [${taskID}]`);
|
|
@@ -215,13 +218,54 @@ const _coinFlip = () => { return Math.random() > 0.5; };
|
|
|
215
218
|
let SCOPE_ID = 0;
|
|
216
219
|
const I32_MIN = -2_147_483_648;
|
|
217
220
|
const I32_MAX = 2_147_483_647;
|
|
221
|
+
|
|
222
|
+
function _isValidNumericPrimitive(ty, v) {
|
|
223
|
+
if (v === undefined || v === null) { return false; }
|
|
224
|
+
switch (ty) {
|
|
225
|
+
case 'bool':
|
|
226
|
+
return v === 0 || v === 1;
|
|
227
|
+
break;
|
|
228
|
+
case 'u8':
|
|
229
|
+
return v >= 0 && v <= 255;
|
|
230
|
+
break;
|
|
231
|
+
case 's8':
|
|
232
|
+
return v >= -128 && v <= 127;
|
|
233
|
+
break;
|
|
234
|
+
case 'u16':
|
|
235
|
+
return v >= 0 && v <= 65535;
|
|
236
|
+
break;
|
|
237
|
+
case 's16':
|
|
238
|
+
return v >= -32768 && v <= 32767;
|
|
239
|
+
case 'u32':
|
|
240
|
+
return v >= 0 && v <= 4_294_967_295;
|
|
241
|
+
case 's32':
|
|
242
|
+
return v >= -2_147_483_648 && v <= 2_147_483_647;
|
|
243
|
+
case 'u64':
|
|
244
|
+
return typeof v === 'bigint' && v >= 0 && v <= 18_446_744_073_709_551_615n;
|
|
245
|
+
case 's64':
|
|
246
|
+
return typeof v === 'bigint' && v >= -9223372036854775808n && v <= 9223372036854775807n;
|
|
247
|
+
break;
|
|
248
|
+
case 'f32':
|
|
249
|
+
case 'f64': return typeof v === 'number';
|
|
250
|
+
default:
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
return true;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function _requireValidNumericPrimitive(ty, v) {
|
|
257
|
+
if (v === undefined || v === null || !_isValidNumericPrimitive(ty, v)) {
|
|
258
|
+
throw new TypeError(`invalid ${ty} value [${v}]`);
|
|
259
|
+
}
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
218
262
|
const _typeCheckValidI32 = (n) => typeof n === 'number' && n >= I32_MIN && n <= I32_MAX;
|
|
219
263
|
|
|
220
264
|
const _typeCheckAsyncFn= (f) => {
|
|
221
265
|
return f instanceof ASYNC_FN_CTOR;
|
|
222
266
|
};
|
|
223
267
|
|
|
224
|
-
const ASYNC_FN_CTOR = (async () => {}).constructor;
|
|
268
|
+
let RESOURCE_CALL_BORROWS = [];const ASYNC_FN_CTOR = (async () => {}).constructor;
|
|
225
269
|
|
|
226
270
|
function clearCurrentTask(componentIdx, taskID) {
|
|
227
271
|
_debugLog('[clearCurrentTask()] args', { componentIdx, taskID });
|
|
@@ -510,6 +554,7 @@ class AsyncSubtask {
|
|
|
510
554
|
realloc,
|
|
511
555
|
vals: [subtaskValue],
|
|
512
556
|
storagePtr: resultPtr,
|
|
557
|
+
stringEncoding: callMetadata.stringEncoding,
|
|
513
558
|
});
|
|
514
559
|
}
|
|
515
560
|
}
|
|
@@ -699,6 +744,7 @@ resultCountOrAsync,
|
|
|
699
744
|
resultPtr,
|
|
700
745
|
returnFn,
|
|
701
746
|
startFn,
|
|
747
|
+
stringEncoding,
|
|
702
748
|
}
|
|
703
749
|
});
|
|
704
750
|
|
|
@@ -864,7 +910,8 @@ function _asyncStartCall(args, callee, paramCount, resultCount, flags) {
|
|
|
864
910
|
memory: callerMemory,
|
|
865
911
|
vals: [res],
|
|
866
912
|
storagePtr: subtaskCallMeta.resultPtr,
|
|
867
|
-
componentIdx: callerComponentIdx
|
|
913
|
+
componentIdx: callerComponentIdx,
|
|
914
|
+
stringEncoding: subtaskCallMeta.stringEncoding,
|
|
868
915
|
});
|
|
869
916
|
|
|
870
917
|
});
|
|
@@ -2154,9 +2201,48 @@ class ComponentAsyncState {
|
|
|
2154
2201
|
return new Waitable({ target: args?.target, });
|
|
2155
2202
|
}
|
|
2156
2203
|
|
|
2204
|
+
createReadableStreamEnd(args) {
|
|
2205
|
+
_debugLog('[ComponentAsyncState#createStreamEnd()] args', args);
|
|
2206
|
+
const { tableIdx, elemMeta, hostInjectFn } = args;
|
|
2207
|
+
|
|
2208
|
+
const { table: localStreamTable, componentIdx } = STREAM_TABLES[tableIdx];
|
|
2209
|
+
if (!localStreamTable) {
|
|
2210
|
+
throw new Error(`missing global stream table lookup for table [${tableIdx}] while creating stream`);
|
|
2211
|
+
}
|
|
2212
|
+
if (componentIdx !== this.#componentIdx) {
|
|
2213
|
+
throw new Error('component idx mismatch while creating stream');
|
|
2214
|
+
}
|
|
2215
|
+
|
|
2216
|
+
const waitable = this.createWaitable();
|
|
2217
|
+
const streamEnd = new StreamReadableEnd({
|
|
2218
|
+
tableIdx,
|
|
2219
|
+
elemMeta,
|
|
2220
|
+
hostInjectFn,
|
|
2221
|
+
pendingBufferMeta: {},
|
|
2222
|
+
target: `stream read end (lowered, @init)`,
|
|
2223
|
+
waitable,
|
|
2224
|
+
});
|
|
2225
|
+
|
|
2226
|
+
streamEnd.setWaitableIdx(this.handles.insert(streamEnd));
|
|
2227
|
+
streamEnd.setHandle(localStreamTable.insert(streamEnd));
|
|
2228
|
+
if (streamEnd.streamTableIdx() !== tableIdx) {
|
|
2229
|
+
throw new Error("unexpectedly mismatched stream table");
|
|
2230
|
+
}
|
|
2231
|
+
const streamEndWaitableIdx = streamEnd.waitableIdx();
|
|
2232
|
+
const streamEndHandle = streamEnd.handle();
|
|
2233
|
+
waitable.setTarget(`waitable for stream read end (lowered, waitable [${streamEndWaitableIdx}])`);
|
|
2234
|
+
streamEnd.setTarget(`stream read end (lowered, waitable [${streamEndWaitableIdx}])`);
|
|
2235
|
+
|
|
2236
|
+
return {
|
|
2237
|
+
waitableIdx: streamEndWaitableIdx,
|
|
2238
|
+
handle: streamEndHandle,
|
|
2239
|
+
streamEnd,
|
|
2240
|
+
};
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2157
2243
|
createStream(args) {
|
|
2158
2244
|
_debugLog('[ComponentAsyncState#createStream()] args', args);
|
|
2159
|
-
const { tableIdx, elemMeta } = args;
|
|
2245
|
+
const { tableIdx, elemMeta, hostInjectFn } = args;
|
|
2160
2246
|
if (tableIdx === undefined) { throw new Error("missing table idx while adding stream"); }
|
|
2161
2247
|
if (elemMeta === undefined) { throw new Error("missing element metadata while adding stream"); }
|
|
2162
2248
|
|
|
@@ -2173,10 +2259,10 @@ class ComponentAsyncState {
|
|
|
2173
2259
|
|
|
2174
2260
|
const stream = new InternalStream({
|
|
2175
2261
|
tableIdx,
|
|
2176
|
-
componentIdx: this.#componentIdx,
|
|
2177
2262
|
elemMeta,
|
|
2178
2263
|
readWaitable,
|
|
2179
2264
|
writeWaitable,
|
|
2265
|
+
hostInjectFn,
|
|
2180
2266
|
});
|
|
2181
2267
|
stream.setGlobalStreamMapRep(STREAMS.insert(stream));
|
|
2182
2268
|
|
|
@@ -2201,17 +2287,21 @@ class ComponentAsyncState {
|
|
|
2201
2287
|
readEnd.setTarget(`stream read end (waitable [${readEndWaitableIdx}])`);
|
|
2202
2288
|
|
|
2203
2289
|
return {
|
|
2290
|
+
writeEnd,
|
|
2204
2291
|
writeEndWaitableIdx,
|
|
2205
2292
|
writeEndHandle,
|
|
2206
2293
|
readEndWaitableIdx,
|
|
2207
2294
|
readEndHandle,
|
|
2295
|
+
readEnd,
|
|
2208
2296
|
};
|
|
2209
2297
|
}
|
|
2210
2298
|
|
|
2211
2299
|
getStreamEnd(args) {
|
|
2212
2300
|
_debugLog('[ComponentAsyncState#getStreamEnd()] args', args);
|
|
2213
2301
|
const { tableIdx, streamEndHandle, streamEndWaitableIdx } = args;
|
|
2214
|
-
if (tableIdx === undefined) {
|
|
2302
|
+
if (tableIdx === undefined) {
|
|
2303
|
+
throw new Error('missing table idx while getting stream end');
|
|
2304
|
+
}
|
|
2215
2305
|
|
|
2216
2306
|
const { table, componentIdx } = STREAM_TABLES[tableIdx];
|
|
2217
2307
|
const cstate = getOrCreateAsyncState(componentIdx);
|
|
@@ -2298,6 +2388,127 @@ class ComponentAsyncState {
|
|
|
2298
2388
|
|
|
2299
2389
|
return streamEnd;
|
|
2300
2390
|
}
|
|
2391
|
+
|
|
2392
|
+
createFuture(args) {
|
|
2393
|
+
_debugLog('[ComponentAsyncState#createFuture()] args', args);
|
|
2394
|
+
const { tableIdx, elemMeta, hostInjectFn } = args;
|
|
2395
|
+
if (tableIdx === undefined) { throw new Error("missing table idx while adding future"); }
|
|
2396
|
+
if (elemMeta === undefined) { throw new Error("missing element metadata while adding future"); }
|
|
2397
|
+
|
|
2398
|
+
const { table: futureTable, componentIdx } = FUTURE_TABLES[tableIdx];
|
|
2399
|
+
if (!futureTable) {
|
|
2400
|
+
throw new Error(`missing global future table lookup for table [${tableIdx}] while creating future`);
|
|
2401
|
+
}
|
|
2402
|
+
if (componentIdx !== this.#componentIdx) {
|
|
2403
|
+
throw new Error('component idx mismatch while creating future');
|
|
2404
|
+
}
|
|
2405
|
+
|
|
2406
|
+
const readWaitable = this.createWaitable();
|
|
2407
|
+
const writeWaitable = this.createWaitable();
|
|
2408
|
+
|
|
2409
|
+
const future = new InternalFuture({
|
|
2410
|
+
tableIdx,
|
|
2411
|
+
componentIdx: this.#componentIdx,
|
|
2412
|
+
elemMeta,
|
|
2413
|
+
readWaitable,
|
|
2414
|
+
writeWaitable,
|
|
2415
|
+
hostInjectFn,
|
|
2416
|
+
});
|
|
2417
|
+
future.setGlobalFutureMapRep(FUTURES.insert(future));
|
|
2418
|
+
|
|
2419
|
+
const writeEnd = future.writeEnd();
|
|
2420
|
+
writeEnd.setWaitableIdx(this.handles.insert(writeEnd));
|
|
2421
|
+
writeEnd.setHandle(futureTable.insert(writeEnd));
|
|
2422
|
+
if (writeEnd.futureTableIdx() !== tableIdx) { throw new Error("unexpectedly mismatched future table"); }
|
|
2423
|
+
|
|
2424
|
+
const writeEndWaitableIdx = writeEnd.waitableIdx();
|
|
2425
|
+
const writeEndHandle = writeEnd.handle();
|
|
2426
|
+
writeWaitable.setTarget(`waitable for future write end (waitable [${writeEndWaitableIdx}])`);
|
|
2427
|
+
writeEnd.setTarget(`future write end (waitable [${writeEndWaitableIdx}])`);
|
|
2428
|
+
|
|
2429
|
+
const readEnd = future.readEnd();
|
|
2430
|
+
readEnd.setWaitableIdx(this.handles.insert(readEnd));
|
|
2431
|
+
readEnd.setHandle(futureTable.insert(readEnd));
|
|
2432
|
+
if (readEnd.futureTableIdx() !== tableIdx) { throw new Error("unexpectedly mismatched future table"); }
|
|
2433
|
+
|
|
2434
|
+
const readEndWaitableIdx = readEnd.waitableIdx();
|
|
2435
|
+
const readEndHandle = readEnd.handle();
|
|
2436
|
+
readWaitable.setTarget(`waitable for read end (waitable [${readEndWaitableIdx}])`);
|
|
2437
|
+
readEnd.setTarget(`future read end (waitable [${readEndWaitableIdx}])`);
|
|
2438
|
+
|
|
2439
|
+
return {
|
|
2440
|
+
writeEnd,
|
|
2441
|
+
writeEndWaitableIdx,
|
|
2442
|
+
writeEndHandle,
|
|
2443
|
+
readEndWaitableIdx,
|
|
2444
|
+
readEndHandle,
|
|
2445
|
+
readEnd,
|
|
2446
|
+
};
|
|
2447
|
+
}
|
|
2448
|
+
|
|
2449
|
+
getFutureEnd(args) {
|
|
2450
|
+
_debugLog('[ComponentAsyncState#getFutureEnd()] args', args);
|
|
2451
|
+
const { tableIdx, futureEndHandle, futureEndWaitableIdx } = args;
|
|
2452
|
+
if (tableIdx === undefined) {
|
|
2453
|
+
throw new Error('missing table idx while getting future end');
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
const { table, componentIdx } = FUTURE_TABLES[tableIdx];
|
|
2457
|
+
const cstate = getOrCreateAsyncState(componentIdx);
|
|
2458
|
+
|
|
2459
|
+
let futureEnd;
|
|
2460
|
+
if (futureEndWaitableIdx !== undefined) {
|
|
2461
|
+
futureEnd = cstate.handles.get(futureEndWaitableIdx);
|
|
2462
|
+
} else if (futureEndHandle !== undefined) {
|
|
2463
|
+
if (!table) { throw new Error(`missing/invalid table [${tableIdx}] while getting future end`); }
|
|
2464
|
+
futureEnd = table.get(futureEndHandle);
|
|
2465
|
+
} else {
|
|
2466
|
+
throw new TypeError("must specify either waitable idx or handle to retrieve future");
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2469
|
+
if (!futureEnd) {
|
|
2470
|
+
throw new Error(`missing future end (tableIdx [${tableIdx}], handle [${futureEndHandle}], waitableIdx [${futureEndWaitableIdx}])`);
|
|
2471
|
+
}
|
|
2472
|
+
if (tableIdx && futureEnd.futureTableIdx() !== tableIdx) {
|
|
2473
|
+
throw new Error(`future end table idx [${futureEnd.futureTableIdx()}] does not match [${tableIdx}]`);
|
|
2474
|
+
}
|
|
2475
|
+
|
|
2476
|
+
return futureEnd;
|
|
2477
|
+
}
|
|
2478
|
+
|
|
2479
|
+
removeFutureEndFromTable(args) {
|
|
2480
|
+
_debugLog('[ComponentAsyncState#removeFutureEndFromTable()] args', args);
|
|
2481
|
+
|
|
2482
|
+
const { tableIdx, futureWaitableIdx } = args;
|
|
2483
|
+
if (tableIdx === undefined) { throw new Error("missing table idx while removing future end"); }
|
|
2484
|
+
if (futureWaitableIdx === undefined) {
|
|
2485
|
+
throw new Error("missing future end waitable idx while removing future end");
|
|
2486
|
+
}
|
|
2487
|
+
|
|
2488
|
+
const { table, componentIdx } = FUTURE_TABLES[tableIdx];
|
|
2489
|
+
if (!table) { throw new Error(`missing/invalid table [${tableIdx}] while removing future end`); }
|
|
2490
|
+
|
|
2491
|
+
const cstate = getOrCreateAsyncState(componentIdx);
|
|
2492
|
+
|
|
2493
|
+
const futureEnd = cstate.handles.get(futureWaitableIdx);
|
|
2494
|
+
if (!futureEnd) {
|
|
2495
|
+
throw new Error(`missing future end (handle [${futureWaitableIdx}], table [${tableIdx}])`);
|
|
2496
|
+
}
|
|
2497
|
+
const handle = futureEnd.handle();
|
|
2498
|
+
|
|
2499
|
+
let removed = cstate.handles.remove(futureWaitableIdx);
|
|
2500
|
+
if (!removed) {
|
|
2501
|
+
throw new Error(`failed to remove futureEnd from handles (waitable idx [${futureWaitableIdx}]), component [${componentIdx}])`);
|
|
2502
|
+
}
|
|
2503
|
+
|
|
2504
|
+
removed = table.remove(handle);
|
|
2505
|
+
if (!removed) {
|
|
2506
|
+
throw new Error(`failed to remove futureEnd from table (handle [${handle}]), table [${tableIdx}], component [${componentIdx}])`);
|
|
2507
|
+
}
|
|
2508
|
+
|
|
2509
|
+
return futureEnd;
|
|
2510
|
+
}
|
|
2511
|
+
|
|
2301
2512
|
}
|
|
2302
2513
|
|
|
2303
2514
|
const isNode = typeof process !== 'undefined' && process.versions && process.versions.node;
|
|
@@ -2318,6 +2529,8 @@ class ComponentError extends Error {
|
|
|
2318
2529
|
}
|
|
2319
2530
|
}
|
|
2320
2531
|
|
|
2532
|
+
const isLE = new Uint8Array(new Uint16Array([1]).buffer)[0] === 1;
|
|
2533
|
+
|
|
2321
2534
|
function throwInvalidBool() {
|
|
2322
2535
|
throw new TypeError('invalid variant discriminant for bool');
|
|
2323
2536
|
}
|