@smoothbricks/lmao 0.2.2 → 0.2.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/dist/allocator.wasm +0 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/lib/JsBufferStrategy.d.ts +4 -3
- package/dist/lib/JsBufferStrategy.d.ts.map +1 -1
- package/dist/lib/JsBufferStrategy.js +18 -11
- package/dist/lib/arrow/lease.d.ts +10 -0
- package/dist/lib/arrow/lease.d.ts.map +1 -0
- package/dist/lib/arrow/lease.js +33 -0
- package/dist/lib/arrow/utils.d.ts +3 -4
- package/dist/lib/arrow/utils.d.ts.map +1 -1
- package/dist/lib/arrow/utils.js +12 -13
- package/dist/lib/arrow/vocabularyDictionary.d.ts +21 -0
- package/dist/lib/arrow/vocabularyDictionary.d.ts.map +1 -0
- package/dist/lib/arrow/vocabularyDictionary.js +95 -0
- package/dist/lib/bufferStrategy.d.ts +3 -2
- package/dist/lib/bufferStrategy.d.ts.map +1 -1
- package/dist/lib/cloudflare/traceRows.d.ts.map +1 -1
- package/dist/lib/cloudflare/traceRows.js +3 -2
- package/dist/lib/codegen/evaluatorGenerator.d.ts.map +1 -1
- package/dist/lib/codegen/evaluatorGenerator.js +12 -11
- package/dist/lib/codegen/fixedPositionWriterGenerator.d.ts +44 -82
- package/dist/lib/codegen/fixedPositionWriterGenerator.d.ts.map +1 -1
- package/dist/lib/codegen/fixedPositionWriterGenerator.js +223 -162
- package/dist/lib/codegen/spanLoggerClosureMaterializer.d.ts +63 -0
- package/dist/lib/codegen/spanLoggerClosureMaterializer.d.ts.map +1 -0
- package/dist/lib/codegen/spanLoggerClosureMaterializer.js +447 -0
- package/dist/lib/codegen/spanLoggerGenerator.d.ts +36 -19
- package/dist/lib/codegen/spanLoggerGenerator.d.ts.map +1 -1
- package/dist/lib/codegen/spanLoggerGenerator.js +164 -158
- package/dist/lib/convertToArrow.d.ts +7 -2
- package/dist/lib/convertToArrow.d.ts.map +1 -1
- package/dist/lib/convertToArrow.js +499 -285
- package/dist/lib/defineOpContext.js +1 -1
- package/dist/lib/enumMetadata.d.ts +19 -0
- package/dist/lib/enumMetadata.d.ts.map +1 -0
- package/dist/lib/enumMetadata.js +86 -0
- package/dist/lib/flushScheduler.d.ts.map +1 -1
- package/dist/lib/flushScheduler.js +13 -4
- package/dist/lib/library.d.ts +16 -98
- package/dist/lib/library.d.ts.map +1 -1
- package/dist/lib/library.js +32 -525
- package/dist/lib/logBinding.d.ts +21 -27
- package/dist/lib/logBinding.d.ts.map +1 -1
- package/dist/lib/op.d.ts +30 -30
- package/dist/lib/op.d.ts.map +1 -1
- package/dist/lib/op.js +15 -22
- package/dist/lib/opContext/createOpGroup.d.ts +1 -1
- package/dist/lib/opContext/createOpGroup.d.ts.map +1 -1
- package/dist/lib/opContext/createOpGroup.js +22 -29
- package/dist/lib/opContext/defineOp.d.ts +4 -4
- package/dist/lib/opContext/defineOp.d.ts.map +1 -1
- package/dist/lib/opContext/defineOp.js +53 -10
- package/dist/lib/opContext/opGroupTypes.d.ts +2 -2
- package/dist/lib/opContext/opTypes.d.ts +1 -1
- package/dist/lib/opContext/opTypes.d.ts.map +1 -1
- package/dist/lib/opContext/spanContextTypes.d.ts +29 -14
- package/dist/lib/opContext/spanContextTypes.d.ts.map +1 -1
- package/dist/lib/opContext/types.d.ts +4 -4
- package/dist/lib/opContext/types.d.ts.map +1 -1
- package/dist/lib/physicalLayoutPlan.d.ts +89 -0
- package/dist/lib/physicalLayoutPlan.d.ts.map +1 -0
- package/dist/lib/physicalLayoutPlan.js +442 -0
- package/dist/lib/resolveMessage.d.ts +9 -0
- package/dist/lib/resolveMessage.d.ts.map +1 -0
- package/dist/lib/resolveMessage.js +63 -0
- package/dist/lib/result.d.ts +5 -7
- package/dist/lib/result.d.ts.map +1 -1
- package/dist/lib/result.js +19 -26
- package/dist/lib/runtimeHint.d.ts +35 -0
- package/dist/lib/runtimeHint.d.ts.map +1 -0
- package/dist/lib/runtimeHint.js +79 -0
- package/dist/lib/schema/types.d.ts +1 -1
- package/dist/lib/schema/types.d.ts.map +1 -1
- package/dist/lib/span-buffer/aot/v1.d.ts +2 -0
- package/dist/lib/span-buffer/aot/v1.d.ts.map +1 -0
- package/dist/lib/span-buffer/aot/v1.js +24 -0
- package/dist/lib/spanBuffer.d.ts +33 -4
- package/dist/lib/spanBuffer.d.ts.map +1 -1
- package/dist/lib/spanBuffer.js +583 -91
- package/dist/lib/spanBufferStats.d.ts +1 -1
- package/dist/lib/spanBufferStats.d.ts.map +1 -1
- package/dist/lib/spanContext.d.ts +27 -51
- package/dist/lib/spanContext.d.ts.map +1 -1
- package/dist/lib/spanContext.js +822 -344
- package/dist/lib/sqlite/sqlite-common.d.ts.map +1 -1
- package/dist/lib/sqlite/sqlite-common.js +20 -21
- package/dist/lib/testing/bun-harness.d.ts +8 -3
- package/dist/lib/testing/bun-harness.d.ts.map +1 -1
- package/dist/lib/testing/bun-harness.js +30 -18
- package/dist/lib/testing/extractFacts.d.ts +1 -1
- package/dist/lib/testing/extractFacts.d.ts.map +1 -1
- package/dist/lib/testing/extractFacts.js +55 -63
- package/dist/lib/testing/facts.d.ts +1 -1
- package/dist/lib/testing/facts.d.ts.map +1 -1
- package/dist/lib/testing/queryable-span.d.ts +1 -1
- package/dist/lib/testing/queryable-span.d.ts.map +1 -1
- package/dist/lib/testing/queryable-span.js +26 -28
- package/dist/lib/testing/span-query.d.ts.map +1 -1
- package/dist/lib/testing/span-query.js +19 -22
- package/dist/lib/testing/stdio-replay.d.ts.map +1 -1
- package/dist/lib/testing/stdio-replay.js +19 -8
- package/dist/lib/threadId.d.ts.map +1 -1
- package/dist/lib/threadId.js +6 -3
- package/dist/lib/traceRoot.d.ts +30 -8
- package/dist/lib/traceRoot.d.ts.map +1 -1
- package/dist/lib/traceRoot.es.d.ts +17 -15
- package/dist/lib/traceRoot.es.d.ts.map +1 -1
- package/dist/lib/traceRoot.es.js +68 -34
- package/dist/lib/traceRoot.js +11 -0
- package/dist/lib/traceRoot.node.d.ts +17 -19
- package/dist/lib/traceRoot.node.d.ts.map +1 -1
- package/dist/lib/traceRoot.node.js +66 -38
- package/dist/lib/traceTopology.d.ts +42 -0
- package/dist/lib/traceTopology.d.ts.map +1 -0
- package/dist/lib/traceTopology.js +260 -0
- package/dist/lib/tracer.d.ts +9 -5
- package/dist/lib/tracer.d.ts.map +1 -1
- package/dist/lib/tracer.js +65 -71
- package/dist/lib/tracers/ArrayQueueTracer.d.ts +1 -1
- package/dist/lib/tracers/ArrayQueueTracer.js +1 -1
- package/dist/lib/tracers/StdioTracer.d.ts.map +1 -1
- package/dist/lib/tracers/StdioTracer.js +15 -13
- package/dist/lib/tracers/TestTracer.d.ts +4 -6
- package/dist/lib/tracers/TestTracer.d.ts.map +1 -1
- package/dist/lib/tracers/TestTracer.js +6 -8
- package/dist/lib/types.d.ts +49 -32
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/vocabularyRegistry.d.ts +25 -0
- package/dist/lib/vocabularyRegistry.d.ts.map +1 -0
- package/dist/lib/vocabularyRegistry.js +372 -0
- package/dist/lib/wasm/WasmBufferStrategy.d.ts +6 -10
- package/dist/lib/wasm/WasmBufferStrategy.d.ts.map +1 -1
- package/dist/lib/wasm/WasmBufferStrategy.js +44 -37
- package/dist/lib/wasm/wasmAllocator.d.ts +27 -22
- package/dist/lib/wasm/wasmAllocator.d.ts.map +1 -1
- package/dist/lib/wasm/wasmAllocator.js +66 -44
- package/dist/lib/wasm/wasmPhysicalLayout.d.ts +67 -0
- package/dist/lib/wasm/wasmPhysicalLayout.d.ts.map +1 -0
- package/dist/lib/wasm/wasmPhysicalLayout.js +179 -0
- package/dist/lib/wasm/wasmSpanBuffer.d.ts +79 -31
- package/dist/lib/wasm/wasmSpanBuffer.d.ts.map +1 -1
- package/dist/lib/wasm/wasmSpanBuffer.js +442 -272
- package/dist/lib/wasm/wasmTraceRoot.d.ts +24 -22
- package/dist/lib/wasm/wasmTraceRoot.d.ts.map +1 -1
- package/dist/lib/wasm/wasmTraceRoot.js +110 -71
- package/dist/vocabulary/register/v1.d.ts +2 -0
- package/dist/vocabulary/register/v1.d.ts.map +1 -0
- package/dist/vocabulary/register/v1.js +1 -0
- package/dist/wasm.d.ts +5 -0
- package/dist/wasm.d.ts.map +1 -0
- package/dist/wasm.js +4 -0
- package/package.json +54 -6
- package/src/index.ts +1 -0
- package/src/lib/JsBufferStrategy.ts +27 -9
- package/src/lib/__tests__/arrow-builder-integration/arrow-conversion.test.ts +335 -37
- package/src/lib/__tests__/arrow-builder-integration/binary-arrow-conversion.test.ts +97 -26
- package/src/lib/__tests__/arrow-builder-integration/binary-comparison.test.ts +75 -15
- package/src/lib/__tests__/arrow-builder-integration/binary-format-compliance.test.ts +30 -6
- package/src/lib/__tests__/arrow-builder-integration/buffer-chaining.test.ts +18 -21
- package/src/lib/__tests__/arrow-builder-integration/foundation.test.ts +5 -2
- package/src/lib/__tests__/arrow-builder-integration/integration.test.ts +25 -7
- package/src/lib/__tests__/arrow-builder-integration/lazy-columns.test.ts +3 -2
- package/src/lib/__tests__/buffer-overflow.test.ts +24 -18
- package/src/lib/__tests__/capability-span-context.test.ts +505 -0
- package/src/lib/__tests__/capacity-tuning.test.ts +5 -3
- package/src/lib/__tests__/eager-columns.test.ts +345 -0
- package/src/lib/__tests__/enum-metadata-aot.test.ts +153 -0
- package/src/lib/__tests__/enum-metadata.test.ts +177 -0
- package/src/lib/__tests__/fixtures/empty-vocabulary-runtime.fixture.ts +15 -0
- package/src/lib/__tests__/flushScheduler.test.ts +5 -1
- package/src/lib/__tests__/identity-view.property.test.ts +179 -0
- package/src/lib/__tests__/library.test.ts +19 -235
- package/src/lib/__tests__/message-buffer-families.test.ts +878 -0
- package/src/lib/__tests__/nested-library-tasks.test.ts +14 -15
- package/src/lib/__tests__/op-metadata.test.ts +1 -1
- package/src/lib/__tests__/op-type-safety.test.ts +5 -16
- package/src/lib/__tests__/physical-layout-plan.test.ts +333 -0
- package/src/lib/__tests__/remap-descriptor-integration.test.ts +381 -0
- package/src/lib/__tests__/root-context-construction.test.ts +414 -0
- package/src/lib/__tests__/span-auto-runtime.test.ts +386 -0
- package/src/lib/__tests__/span-buffer-segment-stats.test.ts +221 -0
- package/src/lib/__tests__/span-lifecycle.test.ts +53 -25
- package/src/lib/__tests__/spanbuffer-materializer-parity.test.ts +266 -0
- package/src/lib/__tests__/sync-async-trace.test.ts +24 -23
- package/src/lib/__tests__/tag-writer-aot.test.ts +214 -0
- package/src/lib/__tests__/test-helpers.ts +67 -12
- package/src/lib/__tests__/threadId.test.ts +62 -0
- package/src/lib/__tests__/timestamp.test.ts +221 -93
- package/src/lib/__tests__/traceTopology.property.test.ts +383 -0
- package/src/lib/__tests__/type-narrowing.test.ts +63 -0
- package/src/lib/__tests__/vocabulary-dense-decoding.test.ts +405 -0
- package/src/lib/__tests__/vocabularyRegistry.test.ts +313 -0
- package/src/lib/arrow/lease.ts +43 -0
- package/src/lib/arrow/utils.ts +10 -14
- package/src/lib/arrow/vocabularyDictionary.ts +123 -0
- package/src/lib/bufferStrategy.ts +9 -1
- package/src/lib/cloudflare/traceRows.ts +3 -2
- package/src/lib/codegen/__tests__/evaluatorGenerator.test.ts +21 -141
- package/src/lib/codegen/__tests__/fixedPositionWriter-parity.test.ts +273 -0
- package/src/lib/codegen/__tests__/fixedPositionWriter-uint64.test.ts +61 -34
- package/src/lib/codegen/__tests__/nullBitmap.test.ts +33 -37
- package/src/lib/codegen/__tests__/spanLoggerGenerator.test.ts +34 -18
- package/src/lib/codegen/__tests__/spanLoggerMaterializerParity.test.ts +503 -0
- package/src/lib/codegen/evaluatorGenerator.ts +18 -13
- package/src/lib/codegen/fixedPositionWriterGenerator.ts +329 -245
- package/src/lib/codegen/spanLoggerClosureMaterializer.ts +598 -0
- package/src/lib/codegen/spanLoggerGenerator.ts +241 -177
- package/src/lib/convertToArrow.ts +598 -311
- package/src/lib/defineOpContext.ts +1 -1
- package/src/lib/enumMetadata.ts +121 -0
- package/src/lib/flushScheduler.ts +11 -5
- package/src/lib/library.ts +37 -595
- package/src/lib/logBinding.ts +21 -27
- package/src/lib/op.ts +75 -18
- package/src/lib/opContext/__tests__/retry.test.ts +27 -21
- package/src/lib/opContext/createOpGroup.ts +33 -31
- package/src/lib/opContext/defineOp.ts +88 -11
- package/src/lib/opContext/opGroupTypes.ts +2 -2
- package/src/lib/opContext/opTypes.ts +1 -1
- package/src/lib/opContext/spanContextTypes.ts +98 -17
- package/src/lib/opContext/types.ts +7 -3
- package/src/lib/physicalLayoutPlan.ts +598 -0
- package/src/lib/resolveMessage.ts +67 -0
- package/src/lib/result.ts +20 -33
- package/src/lib/runtimeHint.ts +98 -0
- package/src/lib/schema/__tests__/featureFlags.test.ts +2 -1
- package/src/lib/schema/builder.ts +1 -1
- package/src/lib/schema/types.ts +1 -1
- package/src/lib/span-buffer/aot/v1.ts +26 -0
- package/src/lib/spanBuffer.ts +658 -92
- package/src/lib/spanBufferStats.ts +1 -1
- package/src/lib/spanContext.ts +1350 -861
- package/src/lib/sqlite/sqlite-common.ts +20 -31
- package/src/lib/testing/__tests__/topology-traversal.test.ts +174 -0
- package/src/lib/testing/__tests__/vitest-harness.test.ts +2 -1
- package/src/lib/testing/bun-harness.ts +94 -43
- package/src/lib/testing/extractFacts.ts +64 -78
- package/src/lib/testing/facts.ts +1 -1
- package/src/lib/testing/queryable-span.ts +23 -30
- package/src/lib/testing/span-query.ts +16 -20
- package/src/lib/testing/stdio-replay.ts +25 -8
- package/src/lib/testing/vitest-harness.ts +1 -1
- package/src/lib/threadId.ts +6 -3
- package/src/lib/traceRoot.es.ts +77 -42
- package/src/lib/traceRoot.node.ts +75 -46
- package/src/lib/traceRoot.ts +41 -14
- package/src/lib/traceTopology.ts +279 -0
- package/src/lib/tracer.ts +109 -98
- package/src/lib/tracers/ArrayQueueTracer.ts +1 -1
- package/src/lib/tracers/StdioTracer.ts +15 -13
- package/src/lib/tracers/TestTracer.ts +6 -8
- package/src/lib/tracers/__tests__/ArrayQueueTracer.test.ts +15 -10
- package/src/lib/tracers/__tests__/TestTracer.test.ts +23 -13
- package/src/lib/types.ts +64 -33
- package/src/lib/vocabularyRegistry.ts +439 -0
- package/src/lib/wasm/WasmBufferStrategy.ts +56 -48
- package/src/lib/wasm/__tests__/WasmBufferStrategy.test.ts +215 -11
- package/src/lib/wasm/__tests__/allocatorFreeBlockClamp.test.ts +86 -0
- package/src/lib/wasm/__tests__/wasm-identity-view.test.ts +311 -0
- package/src/lib/wasm/__tests__/wasm-integration.test.ts +417 -44
- package/src/lib/wasm/__tests__/wasm-message-buffer-families.test.ts +588 -0
- package/src/lib/wasm/__tests__/wasmAllocator.test.ts +100 -668
- package/src/lib/wasm/__tests__/wasmSpanBuffer.test.ts +419 -63
- package/src/lib/wasm/__tests__/wasmTraceRoot.test.ts +24 -29
- package/src/lib/wasm/__tests__/wasmTracer.test.ts.disabled +2 -2
- package/src/lib/wasm/wasmAllocator.ts +131 -96
- package/src/lib/wasm/wasmPhysicalLayout.ts +309 -0
- package/src/lib/wasm/wasmSpanBuffer.ts +597 -341
- package/src/lib/wasm/wasmTraceRoot.ts +140 -78
- package/src/vocabulary/register/v1.ts +1 -0
- package/src/wasm.ts +19 -0
- package/src/lib/__tests__/remapped-buffer-view-integration.test.ts +0 -319
- package/src/lib/__tests__/remapped-buffer-view.test.ts +0 -635
- package/src/lib/wasm/allocator.zig +0 -948
|
@@ -1,64 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Fixed-position TagWriter and ResultWriter classes.
|
|
3
|
+
*
|
|
4
|
+
* TagWriter uses source-authored constructors and schema-driven prototype methods so
|
|
5
|
+
* Hermes can compile the implementation ahead of time. ResultWriter selects between a
|
|
6
|
+
* compiled renderer (new Function, string-codegen runtimes) and a closure-composed
|
|
7
|
+
* materializer (workerd-safe, no eval) via activeMaterializerMode().
|
|
3
8
|
*
|
|
4
9
|
* These classes provide fluent setter methods that write to a fixed position in a SpanBuffer:
|
|
5
10
|
* - TagWriter: writes to position 0 (span-start row) via ctx.tag.userId("123")
|
|
6
11
|
* - ResultWriter: writes to position 1 (result row) via ctx.ok(data).userId("123")
|
|
7
12
|
*
|
|
8
|
-
* Both share the same codegen since they only differ in:
|
|
9
|
-
* 1. The fixed position (0 vs 1)
|
|
10
|
-
* 2. ResultWriter has additional _result/_error properties
|
|
11
|
-
*
|
|
12
13
|
* WHY Fixed Positions:
|
|
13
14
|
* - Row 0: span-start entry (written at span creation, attributes set via ctx.tag)
|
|
14
15
|
* - Row 1: span-end entry (written at ctx.ok()/ctx.err(), attributes set via fluent API)
|
|
15
16
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* - Fluent chaining: ctx.tag.userId("123").requestId("abc")
|
|
19
|
-
* - Zero allocation: returns same object reference
|
|
17
|
+
* Each wrapper stores only the SpanContext state identity. Setters write through
|
|
18
|
+
* `state._spanBuffer` to their embedded row and return the same wrapper for fluent chaining.
|
|
20
19
|
*/
|
|
21
|
-
import { bufferHelpers } from '@smoothbricks/arrow-builder';
|
|
22
|
-
import {
|
|
20
|
+
import { activeMaterializerMode, bufferHelpers } from '@smoothbricks/arrow-builder';
|
|
21
|
+
import { resolveEnumLookupDescriptor } from '../enumMetadata.js';
|
|
23
22
|
function isTagWriterConstructor(value) {
|
|
24
23
|
return typeof value === 'function';
|
|
25
24
|
}
|
|
26
25
|
function isResultWriterConstructor(value) {
|
|
27
26
|
return typeof value === 'function';
|
|
28
27
|
}
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
*/
|
|
33
|
-
function generateEnumMapping(fieldName, enumValues) {
|
|
34
|
-
const cases = enumValues.map((value, index) => ` case ${JSON.stringify(value)}: return ${index};`).join('\n');
|
|
35
|
-
return `
|
|
36
|
-
function getEnumIndex_${fieldName}(value) {
|
|
37
|
-
switch(value) {
|
|
38
|
-
${cases}
|
|
39
|
-
default: return 0;
|
|
40
|
-
}
|
|
41
|
-
}`;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Generate setter method code for a single attribute.
|
|
45
|
-
* Calls this._buffer.columnName(this._pos, value) and returns this.
|
|
46
|
-
*/
|
|
47
|
-
function generateSetterMethod(fieldName, schema, hasEnumMapping) {
|
|
48
|
-
const columnName = fieldName;
|
|
49
|
-
const lmaoType = getSchemaType(schema);
|
|
50
|
-
if (lmaoType === 'enum' && hasEnumMapping) {
|
|
51
|
-
return `
|
|
52
|
-
${fieldName}(value) {
|
|
53
|
-
this._buffer.${columnName}(this._pos, getEnumIndex_${fieldName}(value));
|
|
54
|
-
return this;
|
|
55
|
-
}`;
|
|
56
|
-
}
|
|
57
|
-
// All other types: direct pass-through to buffer setter
|
|
58
|
-
// The buffer's setter handles null bitmap and storage details
|
|
28
|
+
/** Generate a state-bound setter for one schema attribute and literal row. */
|
|
29
|
+
function generateSetterMethod(fieldName, enumEncoderName, position) {
|
|
30
|
+
const value = enumEncoderName ? `${enumEncoderName}(value)` : 'value';
|
|
59
31
|
return `
|
|
60
32
|
${fieldName}(value) {
|
|
61
|
-
this.
|
|
33
|
+
this._state._spanBuffer.${fieldName}(${position}, ${value});
|
|
62
34
|
return this;
|
|
63
35
|
}`;
|
|
64
36
|
}
|
|
@@ -66,13 +38,13 @@ function generateSetterMethod(fieldName, schema, hasEnumMapping) {
|
|
|
66
38
|
* Generate with() method code - bulk attribute setting.
|
|
67
39
|
* UNROLLED per-column code for zero Object.entries overhead.
|
|
68
40
|
*/
|
|
69
|
-
function generateWithMethod(schemaFields,
|
|
41
|
+
function generateWithMethod(schemaFields, enumEncoderNames, position) {
|
|
70
42
|
const columnWrites = schemaFields.map(([fieldName]) => {
|
|
71
|
-
const
|
|
72
|
-
const valueExpr =
|
|
43
|
+
const enumEncoderName = enumEncoderNames[fieldName];
|
|
44
|
+
const valueExpr = enumEncoderName ? `${enumEncoderName}(attributes.${fieldName})` : `attributes.${fieldName}`;
|
|
73
45
|
return `
|
|
74
46
|
if ('${fieldName}' in attributes && attributes.${fieldName} !== null && attributes.${fieldName} !== undefined) {
|
|
75
|
-
this.
|
|
47
|
+
this._state._spanBuffer.${fieldName}(${position}, ${valueExpr});
|
|
76
48
|
}`;
|
|
77
49
|
});
|
|
78
50
|
return `
|
|
@@ -91,37 +63,19 @@ function generateWithMethod(schemaFields, enumFieldNames) {
|
|
|
91
63
|
* @param extension - Optional extension for constructor code, methods, params
|
|
92
64
|
* @returns JavaScript code string for the class
|
|
93
65
|
*/
|
|
94
|
-
export function generateFixedPositionWriterClass(schema, position, className, extension) {
|
|
66
|
+
export function generateFixedPositionWriterClass(schema, position, className, extension, eagerColumns = [], enumLookup = resolveEnumLookupDescriptor(schema)) {
|
|
95
67
|
const schemaFields = schema._columns;
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
// Generate setter methods
|
|
108
|
-
const setterMethods = schemaFields.map(([fieldName, fieldSchema]) => generateSetterMethod(fieldName, fieldSchema, enumFieldNames.has(fieldName)));
|
|
109
|
-
// Generate with() method
|
|
110
|
-
const withMethod = generateWithMethod(schemaFields, enumFieldNames);
|
|
111
|
-
// Build constructor signature
|
|
112
|
-
const constructorSignature = extension?.constructorParams ? `buffer, ${extension.constructorParams}` : 'buffer';
|
|
113
|
-
// Build constructor body
|
|
114
|
-
// Generated structure: assigns _buffer and _pos, then runs extension constructor code if provided
|
|
115
|
-
const constructorBody = [' this._buffer = buffer;', ` this._pos = ${position};`];
|
|
116
|
-
if (extension?.constructorCode) {
|
|
117
|
-
constructorBody.push('');
|
|
118
|
-
// Extension constructor code runs after _buffer/_pos assignment
|
|
119
|
-
const extensionLines = extension.constructorCode
|
|
120
|
-
.trim()
|
|
121
|
-
.split('\n')
|
|
122
|
-
.map((line) => ` ${line.trim()}`);
|
|
123
|
-
constructorBody.push(...extensionLines);
|
|
124
|
-
}
|
|
68
|
+
void eagerColumns;
|
|
69
|
+
const enumEncoderNames = Object.create(null);
|
|
70
|
+
const enumEncoderBindings = enumLookup.ordered.map(({ fieldName }, index) => {
|
|
71
|
+
const encoderName = `encodeEnum${index}`;
|
|
72
|
+
enumEncoderNames[fieldName] = encoderName;
|
|
73
|
+
return ` const ${encoderName} = enumLookup.byField[${JSON.stringify(fieldName)}].encode;`;
|
|
74
|
+
});
|
|
75
|
+
const setterMethods = schemaFields.map(([fieldName]) => generateSetterMethod(fieldName, enumEncoderNames[fieldName], position));
|
|
76
|
+
const withMethod = generateWithMethod(schemaFields, enumEncoderNames, position);
|
|
77
|
+
const constructorSignature = 'state';
|
|
78
|
+
const constructorBody = [' this._state = state;'];
|
|
125
79
|
// Build extension methods (additional methods injected by the caller)
|
|
126
80
|
const extensionMethods = extension?.methods
|
|
127
81
|
? '\n' +
|
|
@@ -131,15 +85,10 @@ export function generateFixedPositionWriterClass(schema, position, className, ex
|
|
|
131
85
|
.map((line) => ` ${line}`)
|
|
132
86
|
.join('\n')
|
|
133
87
|
: '';
|
|
134
|
-
// Generated class
|
|
135
|
-
// - constructor: assigns _buffer, _pos, then extension code
|
|
136
|
-
// - with(): bulk attribute setting method
|
|
137
|
-
// - Individual setter methods for each schema field
|
|
138
|
-
// - Extension methods (if any)
|
|
88
|
+
// Generated class stores only `_state`; every method embeds its fixed row literal.
|
|
139
89
|
const classCode = `
|
|
140
90
|
'use strict';
|
|
141
|
-
|
|
142
|
-
${enumMappings.join('\n')}
|
|
91
|
+
${enumEncoderBindings.join('\n')}
|
|
143
92
|
|
|
144
93
|
class ${className} {
|
|
145
94
|
constructor(${constructorSignature}) {
|
|
@@ -168,26 +117,100 @@ const tagWriterClassCache = new WeakMap();
|
|
|
168
117
|
* Cache for ResultWriter classes (position 1).
|
|
169
118
|
*/
|
|
170
119
|
const resultWriterClassCache = new WeakMap();
|
|
120
|
+
/** Invoke one schema-specific SpanBuffer setter without generating source. */
|
|
121
|
+
function writeFixedField(writer, fieldName, position, value) {
|
|
122
|
+
const buffer = writer._state._spanBuffer;
|
|
123
|
+
const columnWriter = Reflect.get(buffer, fieldName);
|
|
124
|
+
if (typeof columnWriter !== 'function') {
|
|
125
|
+
throw new TypeError(`SpanBuffer column writer ${JSON.stringify(fieldName)} is not callable`);
|
|
126
|
+
}
|
|
127
|
+
columnWriter.call(buffer, position, value);
|
|
128
|
+
}
|
|
129
|
+
/** Preserve the generated writer's schema order and enum-binding semantics. */
|
|
130
|
+
function createFixedFieldPlans(schema, enumLookup) {
|
|
131
|
+
const enumFieldNames = new Set();
|
|
132
|
+
for (const { fieldName } of enumLookup.ordered)
|
|
133
|
+
enumFieldNames.add(fieldName);
|
|
134
|
+
return schema._columns.map(([fieldName]) => {
|
|
135
|
+
if (!enumFieldNames.has(fieldName))
|
|
136
|
+
return { fieldName, encode: undefined };
|
|
137
|
+
const descriptor = enumLookup.byField[fieldName];
|
|
138
|
+
if (!descriptor) {
|
|
139
|
+
throw new TypeError(`Enum lookup for ${JSON.stringify(fieldName)} is missing`);
|
|
140
|
+
}
|
|
141
|
+
return { fieldName, encode: descriptor.encode };
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/** Compiled class members are non-enumerable; every closure-installed member must match. */
|
|
145
|
+
function asClassMemberDescriptor(descriptor) {
|
|
146
|
+
descriptor.enumerable = false;
|
|
147
|
+
return descriptor;
|
|
148
|
+
}
|
|
149
|
+
/** Create a class-method descriptor whose function name is the schema field name. */
|
|
150
|
+
function createFieldSetterDescriptor(plan, position) {
|
|
151
|
+
const encode = plan.encode;
|
|
152
|
+
const methods = encode
|
|
153
|
+
? {
|
|
154
|
+
[plan.fieldName](value) {
|
|
155
|
+
writeFixedField(this, plan.fieldName, position, encode(value));
|
|
156
|
+
return this;
|
|
157
|
+
},
|
|
158
|
+
}
|
|
159
|
+
: {
|
|
160
|
+
[plan.fieldName](value) {
|
|
161
|
+
writeFixedField(this, plan.fieldName, position, value);
|
|
162
|
+
return this;
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
const descriptor = Object.getOwnPropertyDescriptor(methods, plan.fieldName);
|
|
166
|
+
if (!descriptor)
|
|
167
|
+
throw new Error(`Failed to create writer setter ${JSON.stringify(plan.fieldName)}`);
|
|
168
|
+
return asClassMemberDescriptor(descriptor);
|
|
169
|
+
}
|
|
170
|
+
/** Install the schema-specific fluent API with class-member-equivalent descriptors. */
|
|
171
|
+
function installFixedWriterMethods(prototype, plans, position) {
|
|
172
|
+
const bulkMethods = {
|
|
173
|
+
with(attributes) {
|
|
174
|
+
for (const plan of plans) {
|
|
175
|
+
if (plan.fieldName in attributes &&
|
|
176
|
+
attributes[plan.fieldName] !== null &&
|
|
177
|
+
attributes[plan.fieldName] !== undefined) {
|
|
178
|
+
const value = attributes[plan.fieldName];
|
|
179
|
+
writeFixedField(this, plan.fieldName, position, plan.encode ? plan.encode(value) : value);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return this;
|
|
183
|
+
},
|
|
184
|
+
uint64_value(value) {
|
|
185
|
+
this._state._spanBuffer.uint64_value(position, value);
|
|
186
|
+
return this;
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
const withDescriptor = Object.getOwnPropertyDescriptor(bulkMethods, 'with');
|
|
190
|
+
if (!withDescriptor)
|
|
191
|
+
throw new Error('Failed to create writer.with');
|
|
192
|
+
Object.defineProperty(prototype, 'with', asClassMemberDescriptor(withDescriptor));
|
|
193
|
+
for (const plan of plans) {
|
|
194
|
+
Object.defineProperty(prototype, plan.fieldName, createFieldSetterDescriptor(plan, position));
|
|
195
|
+
}
|
|
196
|
+
const uint64Descriptor = Object.getOwnPropertyDescriptor(bulkMethods, 'uint64_value');
|
|
197
|
+
if (!uint64Descriptor)
|
|
198
|
+
throw new Error('Failed to create writer.uint64_value');
|
|
199
|
+
Object.defineProperty(prototype, 'uint64_value', asClassMemberDescriptor(uint64Descriptor));
|
|
200
|
+
}
|
|
171
201
|
// ============================================================================
|
|
172
202
|
// TagWriter API
|
|
173
203
|
// ============================================================================
|
|
174
|
-
/**
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
};
|
|
185
|
-
/**
|
|
186
|
-
* Generate TagWriter class code for a schema.
|
|
187
|
-
* TagWriter writes to position 0 (span-start row).
|
|
188
|
-
*/
|
|
189
|
-
export function generateTagWriterClass(schema) {
|
|
190
|
-
return generateFixedPositionWriterClass(schema, 0, 'GeneratedTagWriter', tagWriterExtension);
|
|
204
|
+
/** Build one source-authored constructor for an existing TagWriter cache key. */
|
|
205
|
+
function createStaticTagWriterConstructor(schema, enumLookup) {
|
|
206
|
+
class GeneratedTagWriter {
|
|
207
|
+
_state;
|
|
208
|
+
constructor(state) {
|
|
209
|
+
this._state = state;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
installFixedWriterMethods(GeneratedTagWriter.prototype, createFixedFieldPlans(schema, enumLookup), 0);
|
|
213
|
+
return GeneratedTagWriter;
|
|
191
214
|
}
|
|
192
215
|
/**
|
|
193
216
|
* Get or create a cached TagWriter class for a schema.
|
|
@@ -195,113 +218,151 @@ export function generateTagWriterClass(schema) {
|
|
|
195
218
|
* @param schema - Tag attribute schema
|
|
196
219
|
* @returns TagWriter class constructor
|
|
197
220
|
*/
|
|
198
|
-
export function getTagWriterClass(schema) {
|
|
199
|
-
|
|
221
|
+
export function getTagWriterClass(schema, eagerColumns = [], enumLookup = resolveEnumLookupDescriptor(schema)) {
|
|
222
|
+
const cacheKey = eagerColumns.join('\u0000');
|
|
223
|
+
let classes = tagWriterClassCache.get(schema);
|
|
224
|
+
let WriterClass = classes?.get(cacheKey);
|
|
200
225
|
if (!WriterClass) {
|
|
201
|
-
|
|
202
|
-
// Compile with new Function()
|
|
203
|
-
const factory = new Function('helpers', classCode);
|
|
204
|
-
WriterClass = factory(bufferHelpers);
|
|
226
|
+
WriterClass = createStaticTagWriterConstructor(schema, enumLookup);
|
|
205
227
|
if (!isTagWriterConstructor(WriterClass)) {
|
|
206
|
-
throw new Error('Failed to
|
|
228
|
+
throw new Error('Failed to create TagWriter constructor');
|
|
207
229
|
}
|
|
208
|
-
|
|
230
|
+
classes ??= new Map();
|
|
231
|
+
classes.set(cacheKey, WriterClass);
|
|
232
|
+
tagWriterClassCache.set(schema, classes);
|
|
209
233
|
}
|
|
210
234
|
if (!isTagWriterConstructor(WriterClass)) {
|
|
211
235
|
throw new Error('Invalid cached TagWriter constructor');
|
|
212
236
|
}
|
|
213
237
|
return WriterClass;
|
|
214
238
|
}
|
|
215
|
-
/**
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
* @param schema - Tag attribute schema
|
|
219
|
-
* @param buffer - SpanBuffer to write to
|
|
220
|
-
* @returns TagWriter instance bound to position 0
|
|
221
|
-
*/
|
|
222
|
-
export function createTagWriter(schema, buffer) {
|
|
223
|
-
const WriterClass = getTagWriterClass(schema);
|
|
224
|
-
return new WriterClass(buffer);
|
|
239
|
+
/** Create a TagWriter bound to an existing SpanContext writer state. */
|
|
240
|
+
export function createTagWriter(schema, state) {
|
|
241
|
+
return new (getTagWriterClass(schema))(state);
|
|
225
242
|
}
|
|
226
243
|
// ============================================================================
|
|
227
244
|
// ResultWriter API
|
|
228
245
|
// ============================================================================
|
|
229
|
-
/**
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
constructorParams: 'resultOrError, isError',
|
|
237
|
-
constructorCode: `
|
|
238
|
-
this._isError = isError;
|
|
239
|
-
if (isError) {
|
|
240
|
-
this._error = resultOrError;
|
|
241
|
-
this._result = undefined;
|
|
242
|
-
} else {
|
|
243
|
-
this._result = resultOrError;
|
|
244
|
-
this._error = undefined;
|
|
245
|
-
}
|
|
246
|
-
`,
|
|
247
|
-
methods: `
|
|
246
|
+
/** Result-row system setters, specialized once for the plan's message layout family. */
|
|
247
|
+
function createResultWriterExtension(messageLayoutFamily) {
|
|
248
|
+
const messageWrite = messageLayoutFamily === 'static-only'
|
|
249
|
+
? 'this._state._spanBuffer._terminalMessage = text;'
|
|
250
|
+
: 'this._state._spanBuffer.message_values[1] = text;';
|
|
251
|
+
return {
|
|
252
|
+
methods: `
|
|
248
253
|
message(text) {
|
|
249
|
-
|
|
254
|
+
${messageWrite}
|
|
250
255
|
return this;
|
|
251
256
|
}
|
|
252
257
|
|
|
253
258
|
line(lineNumber) {
|
|
254
|
-
this.
|
|
259
|
+
this._state._spanBuffer.line(1, lineNumber);
|
|
255
260
|
return this;
|
|
256
261
|
}
|
|
257
262
|
|
|
258
263
|
uint64_value(value) {
|
|
259
|
-
this.
|
|
264
|
+
this._state._spanBuffer.uint64_value(1, value);
|
|
260
265
|
return this;
|
|
261
266
|
}
|
|
262
267
|
`,
|
|
263
|
-
};
|
|
268
|
+
};
|
|
269
|
+
}
|
|
264
270
|
/**
|
|
265
271
|
* Generate ResultWriter class code for a schema.
|
|
266
272
|
* ResultWriter writes to position 1 (result row).
|
|
267
273
|
*/
|
|
268
|
-
export function generateResultWriterClass(schema) {
|
|
269
|
-
return generateFixedPositionWriterClass(schema, 1, 'GeneratedResultWriter',
|
|
274
|
+
export function generateResultWriterClass(schema, messageLayoutFamily = 'mixed', _messagePhysicalLayout = 'current', eagerColumns = [], enumLookup = resolveEnumLookupDescriptor(schema)) {
|
|
275
|
+
return generateFixedPositionWriterClass(schema, 1, 'GeneratedResultWriter', createResultWriterExtension(messageLayoutFamily), eagerColumns, enumLookup);
|
|
276
|
+
}
|
|
277
|
+
/** Result-row message lane accessor for mixed/dynamic layouts. */
|
|
278
|
+
function messageLaneOf(buffer) {
|
|
279
|
+
const lane = buffer.message_values;
|
|
280
|
+
if (lane === undefined) {
|
|
281
|
+
throw new TypeError('SpanBuffer has no message_values lane for the result row');
|
|
282
|
+
}
|
|
283
|
+
return lane;
|
|
284
|
+
}
|
|
285
|
+
/** Install result-row system setters mirroring createResultWriterExtension without source text. */
|
|
286
|
+
function installResultSystemMethods(prototype, messageLayoutFamily) {
|
|
287
|
+
const methods = messageLayoutFamily === 'static-only'
|
|
288
|
+
? {
|
|
289
|
+
message(text) {
|
|
290
|
+
this._state._spanBuffer._terminalMessage = text;
|
|
291
|
+
return this;
|
|
292
|
+
},
|
|
293
|
+
}
|
|
294
|
+
: {
|
|
295
|
+
message(text) {
|
|
296
|
+
messageLaneOf(this._state._spanBuffer)[1] = text;
|
|
297
|
+
return this;
|
|
298
|
+
},
|
|
299
|
+
};
|
|
300
|
+
const messageDescriptor = Object.getOwnPropertyDescriptor(methods, 'message');
|
|
301
|
+
if (!messageDescriptor)
|
|
302
|
+
throw new Error('Failed to create ResultWriter.message');
|
|
303
|
+
Object.defineProperty(prototype, 'message', asClassMemberDescriptor(messageDescriptor));
|
|
304
|
+
const lineMethods = {
|
|
305
|
+
line(lineNumber) {
|
|
306
|
+
this._state._spanBuffer.line(1, lineNumber);
|
|
307
|
+
return this;
|
|
308
|
+
},
|
|
309
|
+
};
|
|
310
|
+
const lineDescriptor = Object.getOwnPropertyDescriptor(lineMethods, 'line');
|
|
311
|
+
if (!lineDescriptor)
|
|
312
|
+
throw new Error('Failed to create ResultWriter.line');
|
|
313
|
+
Object.defineProperty(prototype, 'line', asClassMemberDescriptor(lineDescriptor));
|
|
314
|
+
}
|
|
315
|
+
/** Assemble a ResultWriter class from closures (workerd-safe: no string codegen). */
|
|
316
|
+
function createClosureResultWriterConstructor(schema, messageLayoutFamily, enumLookup) {
|
|
317
|
+
class GeneratedResultWriter {
|
|
318
|
+
_state;
|
|
319
|
+
constructor(state) {
|
|
320
|
+
this._state = state;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
installFixedWriterMethods(GeneratedResultWriter.prototype, createFixedFieldPlans(schema, enumLookup), 1);
|
|
324
|
+
installResultSystemMethods(GeneratedResultWriter.prototype, messageLayoutFamily);
|
|
325
|
+
return GeneratedResultWriter;
|
|
326
|
+
}
|
|
327
|
+
/** Compile the rendered result-writer source with new Function (string-codegen runtimes only). */
|
|
328
|
+
function compileResultWriterClass(schema, messageLayoutFamily, messagePhysicalLayout, eagerColumns, enumLookup) {
|
|
329
|
+
const classCode = generateResultWriterClass(schema, messageLayoutFamily, messagePhysicalLayout, eagerColumns, enumLookup).trim();
|
|
330
|
+
const factory = new Function('helpers', 'enumLookup', classCode);
|
|
331
|
+
return factory(bufferHelpers, enumLookup);
|
|
270
332
|
}
|
|
271
333
|
/**
|
|
272
334
|
* Get or create a cached ResultWriter class for a schema.
|
|
273
335
|
*
|
|
336
|
+
* Selects the compiled or closure-composed materializer via activeMaterializerMode();
|
|
337
|
+
* cache keys are mode-prefixed so an override flip never returns the wrong kind.
|
|
338
|
+
*
|
|
274
339
|
* @param schema - Tag attribute schema
|
|
275
340
|
* @returns ResultWriter class constructor
|
|
276
341
|
*/
|
|
277
|
-
export function getResultWriterClass(schema) {
|
|
278
|
-
|
|
342
|
+
export function getResultWriterClass(schema, messageLayoutFamily = 'mixed', messagePhysicalLayout = 'current', eagerColumns = [], enumLookup = resolveEnumLookupDescriptor(schema)) {
|
|
343
|
+
const mode = activeMaterializerMode();
|
|
344
|
+
const cacheKey = `${mode}:${messageLayoutFamily}:${messagePhysicalLayout}:${eagerColumns.join('\u0000')}`;
|
|
345
|
+
let familyClasses = resultWriterClassCache.get(schema);
|
|
346
|
+
let WriterClass = familyClasses?.get(cacheKey);
|
|
279
347
|
if (!WriterClass) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
348
|
+
WriterClass =
|
|
349
|
+
mode === 'compiled'
|
|
350
|
+
? compileResultWriterClass(schema, messageLayoutFamily, messagePhysicalLayout, eagerColumns, enumLookup)
|
|
351
|
+
: createClosureResultWriterConstructor(schema, messageLayoutFamily, enumLookup);
|
|
284
352
|
if (!isResultWriterConstructor(WriterClass)) {
|
|
285
353
|
throw new Error('Failed to generate ResultWriter constructor');
|
|
286
354
|
}
|
|
287
|
-
|
|
355
|
+
familyClasses ??= new Map();
|
|
356
|
+
familyClasses.set(cacheKey, WriterClass);
|
|
357
|
+
resultWriterClassCache.set(schema, familyClasses);
|
|
288
358
|
}
|
|
289
359
|
if (!isResultWriterConstructor(WriterClass)) {
|
|
290
360
|
throw new Error('Invalid cached ResultWriter constructor');
|
|
291
361
|
}
|
|
292
362
|
return WriterClass;
|
|
293
363
|
}
|
|
294
|
-
/**
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
* @param schema - Tag attribute schema
|
|
298
|
-
* @param buffer - SpanBuffer to write to
|
|
299
|
-
* @param resultOrError - The result value or error
|
|
300
|
-
* @param isError - Whether this is an error result
|
|
301
|
-
* @returns ResultWriter instance bound to position 1
|
|
302
|
-
*/
|
|
303
|
-
export function createResultWriter(schema, buffer, resultOrError, isError) {
|
|
304
|
-
const WriterClass = getResultWriterClass(schema);
|
|
305
|
-
return new WriterClass(buffer, resultOrError, isError);
|
|
364
|
+
/** Create a ResultWriter bound to an existing SpanContext writer state. */
|
|
365
|
+
export function createResultWriter(schema, state) {
|
|
366
|
+
return new (getResultWriterClass(schema, state._spanBuffer._messageLayoutFamily, state._spanBuffer._messagePhysicalLayout))(state);
|
|
306
367
|
}
|
|
307
368
|
//#endregion smoo/lmao!n/codegen-architecture
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Closure-composed (no-eval) materializer for state-bound SpanLogger classes.
|
|
3
|
+
*
|
|
4
|
+
* Production workerd forbids code generation from strings (EvalError), so the
|
|
5
|
+
* compiled renderer in spanLoggerGenerator.ts cannot run there. This module
|
|
6
|
+
* assembles the SAME class shape from per-field closures instead of source
|
|
7
|
+
* text, mirroring arrow-builder's closureMaterializers.ts:
|
|
8
|
+
* - one shared prototype per schema/config plan,
|
|
9
|
+
* - methods installed with { value, writable: true, configurable: true, enumerable: false },
|
|
10
|
+
* - accessors installed with { get, configurable: true, enumerable: false },
|
|
11
|
+
* - constructors assign instance properties in the same order (V8 hidden classes).
|
|
12
|
+
*
|
|
13
|
+
* Every closure body mirrors the compiled class member it replaces, including
|
|
14
|
+
* evaluation order (append -> message write -> fields), guard conditions, and
|
|
15
|
+
* thrown error messages that callers observe.
|
|
16
|
+
*/
|
|
17
|
+
import type { SchemaType } from '@smoothbricks/arrow-builder';
|
|
18
|
+
import type { SchemaEnumLookupDescriptor } from '../enumMetadata.js';
|
|
19
|
+
import type { MessageLayoutFamily, MessagePhysicalLayout } from '../runtimeHint.js';
|
|
20
|
+
import type { VocabularyGeneration } from '../vocabularyRegistry.js';
|
|
21
|
+
/** Structural type of SPAN_LOGGER_HELPERS (kept local to avoid an import cycle). */
|
|
22
|
+
export interface SpanLoggerRuntimeHelpers {
|
|
23
|
+
normalizeOperationalTemplate: (template: string) => string;
|
|
24
|
+
setNullBit: (bitmap: Uint8Array, idx: number) => void;
|
|
25
|
+
decodeVocabularyMessage: (generation: VocabularyGeneration, denseIndex: number) => string;
|
|
26
|
+
fillNullBitmapRange: (bitmap: Uint8Array, startIdx: number, endIdx: number) => void;
|
|
27
|
+
fillBooleanBitmapRange: (bitmap: Uint8Array, startIdx: number, endIdx: number, value: boolean) => void;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* How a schema column's storage is allocated and guarded (mirrors
|
|
31
|
+
* arrow-builder's ColumnAccessMode for the state-bound writer surface):
|
|
32
|
+
* - eager: allocated in the buffer constructor, no null bitmap
|
|
33
|
+
* - preallocated: allocated in the buffer constructor WITH a null bitmap
|
|
34
|
+
* - lazy: allocated on first public-getter access
|
|
35
|
+
*/
|
|
36
|
+
export type SpanLoggerColumnMode = 'eager' | 'preallocated' | 'lazy';
|
|
37
|
+
/** One schema column of the SpanLogger plan. */
|
|
38
|
+
export interface SpanLoggerColumnPlan {
|
|
39
|
+
readonly name: string;
|
|
40
|
+
readonly schemaType: SchemaType | undefined;
|
|
41
|
+
readonly mode: SpanLoggerColumnMode;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Pure-data description of one generated SpanLogger class, shared by the
|
|
45
|
+
* compiled renderer and this closure materializer. `helpers`/`enumLookup` are
|
|
46
|
+
* the same stable singletons the compiled path injects via `new Function`
|
|
47
|
+
* parameters (extension.dependencies).
|
|
48
|
+
*/
|
|
49
|
+
export interface SpanLoggerPlan {
|
|
50
|
+
readonly columns: readonly SpanLoggerColumnPlan[];
|
|
51
|
+
readonly messageLayoutFamily: MessageLayoutFamily;
|
|
52
|
+
readonly messagePhysicalLayout: MessagePhysicalLayout;
|
|
53
|
+
readonly helpers: SpanLoggerRuntimeHelpers;
|
|
54
|
+
readonly enumLookup: SchemaEnumLookupDescriptor;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Materialize a state-bound SpanLogger class from a plan without string
|
|
58
|
+
* codegen. Same observable behavior as the compiled renderer. Returned as
|
|
59
|
+
* `unknown` to flow through the same constructor type guard as the compiled
|
|
60
|
+
* factory (isSpanLoggerConstructor).
|
|
61
|
+
*/
|
|
62
|
+
export declare function materializeSpanLoggerClass(plan: SpanLoggerPlan): unknown;
|
|
63
|
+
//# sourceMappingURL=spanLoggerClosureMaterializer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spanLoggerClosureMaterializer.d.ts","sourceRoot":"","sources":["../../../src/lib/codegen/spanLoggerClosureMaterializer.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAUpF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAMrE,oFAAoF;AACpF,MAAM,WAAW,wBAAwB;IACvC,4BAA4B,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;IAC3D,UAAU,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACtD,uBAAuB,EAAE,CAAC,UAAU,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC;IAC1F,mBAAmB,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACpF,sBAAsB,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACxG;AAED;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,cAAc,GAAG,MAAM,CAAC;AAErE,gDAAgD;AAChD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,CAAC;IAC5C,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;CACrC;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAClD,QAAQ,CAAC,mBAAmB,EAAE,mBAAmB,CAAC;IAClD,QAAQ,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;IACtD,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC;IAC3C,QAAQ,CAAC,UAAU,EAAE,0BAA0B,CAAC;CACjD;AA4LD;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAiPxE"}
|