alizarin 0.2.1-alpha.83
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.txt +661 -0
- package/README.md +160 -0
- package/dist/_wasm.d.ts +23 -0
- package/dist/alizarin.full.js +799 -0
- package/dist/alizarin.full.js.map +1 -0
- package/dist/alizarin.inline-full.js +4 -0
- package/dist/alizarin.inline.js +4 -0
- package/dist/alizarin.js +47 -0
- package/dist/alizarin.js.map +1 -0
- package/dist/alizarin_bg.wasm +0 -0
- package/dist/backend.d.ts +74 -0
- package/dist/cards.d.ts +21 -0
- package/dist/client.d.ts +86 -0
- package/dist/collectionMutator.d.ts +155 -0
- package/dist/csvModelLoader.d.ts +59 -0
- package/dist/full.d.ts +3 -0
- package/dist/graphManager.d.ts +259 -0
- package/dist/interfaces.d.ts +145 -0
- package/dist/main-r-MmUiQf.js +12355 -0
- package/dist/main-r-MmUiQf.js.map +1 -0
- package/dist/main.d.ts +28 -0
- package/dist/nodeConfig.d.ts +61 -0
- package/dist/pseudos.d.ts +118 -0
- package/dist/rdm.d.ts +68 -0
- package/dist/renderers.d.ts +65 -0
- package/dist/semantic.d.ts +35 -0
- package/dist/static-types.d.ts +172 -0
- package/dist/staticStore.d.ts +60 -0
- package/dist/tracing/index.d.ts +172 -0
- package/dist/utils.d.ts +43 -0
- package/dist/validation/index.d.ts +734 -0
- package/dist/validation/index.js +1194 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/validators/graphLoading.d.ts +69 -0
- package/dist/validation/validators/index.d.ts +1 -0
- package/dist/viewModels/BooleanViewModel.d.ts +17 -0
- package/dist/viewModels/ConceptListViewModel.d.ts +15 -0
- package/dist/viewModels/ConceptValueViewModel.d.ts +28 -0
- package/dist/viewModels/DateViewModel.d.ts +16 -0
- package/dist/viewModels/DomainValueListViewModel.d.ts +15 -0
- package/dist/viewModels/DomainValueViewModel.d.ts +17 -0
- package/dist/viewModels/EDTFViewModel.d.ts +13 -0
- package/dist/viewModels/GeoJSONViewModel.d.ts +26 -0
- package/dist/viewModels/NodeViewModel.d.ts +15 -0
- package/dist/viewModels/NonLocalizedStringViewModel.d.ts +13 -0
- package/dist/viewModels/NumberViewModel.d.ts +14 -0
- package/dist/viewModels/ResourceInstanceListViewModel.d.ts +25 -0
- package/dist/viewModels/ResourceInstanceViewModel.d.ts +62 -0
- package/dist/viewModels/StringViewModel.d.ts +17 -0
- package/dist/viewModels/UrlViewModel.d.ts +22 -0
- package/dist/viewModels/cacheEntries.d.ts +73 -0
- package/dist/viewModels/getViewModel.d.ts +4 -0
- package/dist/viewModels/index.d.ts +20 -0
- package/dist/viewModels/types.d.ts +15 -0
- package/dist/viewModels.d.ts +1 -0
- package/dist/wasmTiming.d.ts +11 -0
- package/package.json +93 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified tracing infrastructure for Alizarin
|
|
3
|
+
*
|
|
4
|
+
* This module provides a consistent tracing API that works across:
|
|
5
|
+
* - Browser (via Performance API)
|
|
6
|
+
* - Node.js (via perf_hooks)
|
|
7
|
+
* - Rust/WASM (via web-sys Performance API, bridged through here)
|
|
8
|
+
*
|
|
9
|
+
* The API is designed to be compatible with OpenTelemetry semantics,
|
|
10
|
+
* making it easy to upgrade to full OTel later if needed.
|
|
11
|
+
*/
|
|
12
|
+
export interface SpanAttributes {
|
|
13
|
+
[key: string]: string | number | boolean | undefined;
|
|
14
|
+
}
|
|
15
|
+
export interface SpanContext {
|
|
16
|
+
traceId: string;
|
|
17
|
+
spanId: string;
|
|
18
|
+
parentSpanId?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface SpanData {
|
|
21
|
+
name: string;
|
|
22
|
+
context: SpanContext;
|
|
23
|
+
startTime: number;
|
|
24
|
+
endTime?: number;
|
|
25
|
+
duration?: number;
|
|
26
|
+
attributes: SpanAttributes;
|
|
27
|
+
status: 'ok' | 'error' | 'unset';
|
|
28
|
+
events: SpanEvent[];
|
|
29
|
+
}
|
|
30
|
+
export interface SpanEvent {
|
|
31
|
+
name: string;
|
|
32
|
+
timestamp: number;
|
|
33
|
+
attributes?: SpanAttributes;
|
|
34
|
+
}
|
|
35
|
+
export type SpanExporter = (spans: SpanData[]) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Span class - represents a unit of work
|
|
38
|
+
*/
|
|
39
|
+
export declare class Span {
|
|
40
|
+
private data;
|
|
41
|
+
private ended;
|
|
42
|
+
private tracer;
|
|
43
|
+
constructor(name: string, tracer: Tracer, parentContext?: SpanContext, attributes?: SpanAttributes);
|
|
44
|
+
get context(): SpanContext;
|
|
45
|
+
get name(): string;
|
|
46
|
+
setAttribute(key: string, value: string | number | boolean): this;
|
|
47
|
+
setAttributes(attributes: SpanAttributes): this;
|
|
48
|
+
addEvent(name: string, attributes?: SpanAttributes): this;
|
|
49
|
+
setStatus(status: 'ok' | 'error', message?: string): this;
|
|
50
|
+
recordException(error: Error): this;
|
|
51
|
+
end(): void;
|
|
52
|
+
getData(): SpanData;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Tracer class - creates spans and manages export
|
|
56
|
+
*/
|
|
57
|
+
export declare class Tracer {
|
|
58
|
+
private name;
|
|
59
|
+
private version?;
|
|
60
|
+
private exporters;
|
|
61
|
+
private pendingSpans;
|
|
62
|
+
private batchSize;
|
|
63
|
+
private flushIntervalMs;
|
|
64
|
+
private flushTimer?;
|
|
65
|
+
constructor(name: string, version?: string);
|
|
66
|
+
/**
|
|
67
|
+
* Add an exporter to receive completed spans
|
|
68
|
+
*/
|
|
69
|
+
addExporter(exporter: SpanExporter): this;
|
|
70
|
+
/**
|
|
71
|
+
* Start a new span
|
|
72
|
+
*/
|
|
73
|
+
startSpan(name: string, attributes?: SpanAttributes): Span;
|
|
74
|
+
/**
|
|
75
|
+
* Start a span and make it the active span
|
|
76
|
+
*/
|
|
77
|
+
startActiveSpan<T>(name: string, fn: (span: Span) => T, attributes?: SpanAttributes): T;
|
|
78
|
+
startActiveSpan<T>(name: string, attributes: SpanAttributes, fn: (span: Span) => T): T;
|
|
79
|
+
/**
|
|
80
|
+
* Called when a span ends
|
|
81
|
+
*/
|
|
82
|
+
onSpanEnd(spanData: SpanData): void;
|
|
83
|
+
/**
|
|
84
|
+
* Flush pending spans to exporters
|
|
85
|
+
*/
|
|
86
|
+
flush(): void;
|
|
87
|
+
/**
|
|
88
|
+
* Get the current active span
|
|
89
|
+
*/
|
|
90
|
+
getCurrentSpan(): Span | undefined;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get a tracer instance
|
|
94
|
+
*/
|
|
95
|
+
export declare function getTracer(name: string, version?: string): Tracer;
|
|
96
|
+
/**
|
|
97
|
+
* Add a global exporter
|
|
98
|
+
*/
|
|
99
|
+
export declare function addGlobalExporter(exporter: SpanExporter): void;
|
|
100
|
+
/**
|
|
101
|
+
* Flush all pending spans
|
|
102
|
+
*/
|
|
103
|
+
export declare function flushAll(): void;
|
|
104
|
+
/**
|
|
105
|
+
* Console exporter - logs spans to console
|
|
106
|
+
*/
|
|
107
|
+
export declare function consoleExporter(spans: SpanData[]): void;
|
|
108
|
+
/**
|
|
109
|
+
* Summary exporter - aggregates timing stats like the old system
|
|
110
|
+
*/
|
|
111
|
+
export declare class SummaryExporter {
|
|
112
|
+
private stats;
|
|
113
|
+
export: (spans: SpanData[]) => void;
|
|
114
|
+
getSummary(): Map<string, {
|
|
115
|
+
count: number;
|
|
116
|
+
totalMs: number;
|
|
117
|
+
avgMs: number;
|
|
118
|
+
minMs: number;
|
|
119
|
+
maxMs: number;
|
|
120
|
+
}>;
|
|
121
|
+
printSummary(label?: string): void;
|
|
122
|
+
reset(): void;
|
|
123
|
+
/**
|
|
124
|
+
* Merge external timing stats into this summary
|
|
125
|
+
* @param stats Map or object with timing stats in the format {count, totalMs, minMs, maxMs}
|
|
126
|
+
* @param prefix Optional prefix to add to all stat names (e.g., "rust:" or "alizarin:")
|
|
127
|
+
*/
|
|
128
|
+
mergeStats(stats: Map<string, {
|
|
129
|
+
count: number;
|
|
130
|
+
totalMs: number;
|
|
131
|
+
minMs: number;
|
|
132
|
+
maxMs: number;
|
|
133
|
+
}> | Record<string, {
|
|
134
|
+
count: number;
|
|
135
|
+
totalMs: number;
|
|
136
|
+
minMs: number;
|
|
137
|
+
maxMs: number;
|
|
138
|
+
}>, prefix?: string): void;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Bridge for collecting performance entries from WASM
|
|
142
|
+
*
|
|
143
|
+
* The Rust code can use web-sys to call performance.mark() and performance.measure(),
|
|
144
|
+
* and this function collects those entries and converts them to spans.
|
|
145
|
+
*/
|
|
146
|
+
export declare function collectWasmPerformanceEntries(tracer: Tracer): void;
|
|
147
|
+
/**
|
|
148
|
+
* Decorator-style helper for timing a function
|
|
149
|
+
*/
|
|
150
|
+
export declare function traced<T extends (...args: any[]) => any>(name: string, fn: T, tracer?: Tracer): T;
|
|
151
|
+
/**
|
|
152
|
+
* Time a block of code
|
|
153
|
+
*/
|
|
154
|
+
export declare function timed<T>(name: string, fn: () => T | Promise<T>, tracer?: Tracer): Promise<T>;
|
|
155
|
+
/**
|
|
156
|
+
* Register the Rust timing getter (called from main.ts after WASM init)
|
|
157
|
+
*/
|
|
158
|
+
export declare function registerRustTimingGetter(getter: () => Map<string, any>): void;
|
|
159
|
+
/**
|
|
160
|
+
* Register the alizarin JS timing getter (called from main.ts)
|
|
161
|
+
*/
|
|
162
|
+
export declare function registerAlizarinTimingGetter(getter: () => any): void;
|
|
163
|
+
/**
|
|
164
|
+
* Register the detailed WASM timing getter (called from main.ts)
|
|
165
|
+
*/
|
|
166
|
+
export declare function registerWasmTimingGetter(getter: () => Map<string, any>): void;
|
|
167
|
+
/**
|
|
168
|
+
* Collect all timing stats from Rust/WASM and alizarin JS into a SummaryExporter
|
|
169
|
+
*
|
|
170
|
+
* @param exporter The SummaryExporter to merge stats into
|
|
171
|
+
*/
|
|
172
|
+
export declare function collectAllTimings(exporter: SummaryExporter): void;
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { IStringKeyedObject, IInstanceWrapper } from "./interfaces";
|
|
2
|
+
import type { StaticGraph, StaticNode, StaticResourceDescriptors } from "./static-types";
|
|
3
|
+
declare function getCurrentLanguage(): string;
|
|
4
|
+
declare function setCurrentLanguage(lang: string): void;
|
|
5
|
+
/**
|
|
6
|
+
* Slugify a string safely for use in file paths
|
|
7
|
+
* Removes/replaces dangerous characters and limits length
|
|
8
|
+
*/
|
|
9
|
+
declare function slugify(name: string, maxLength?: number, useUnderscoreForHyphen?: boolean): string;
|
|
10
|
+
declare class AttrPromise<T> extends Promise<T> implements IStringKeyedObject {
|
|
11
|
+
[key: string | symbol]: any;
|
|
12
|
+
[Symbol.toPrimitive]: undefined;
|
|
13
|
+
constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason: any) => void) => void);
|
|
14
|
+
}
|
|
15
|
+
declare function generateUuidv5(group: [type: string, id?: string], key: string | string[]): string;
|
|
16
|
+
declare const DESCRIPTOR_FUNCTION_ID = "60000000-0000-0000-0000-000000000001";
|
|
17
|
+
/**
|
|
18
|
+
* Builds resource descriptors using string templates and node values.
|
|
19
|
+
*
|
|
20
|
+
* Descriptors are metadata fields (like "name", "description", "map_popup") that are
|
|
21
|
+
* dynamically generated by substituting node values into string templates.
|
|
22
|
+
*
|
|
23
|
+
* Template format: "The <Node Name> in <Another Node>" where placeholders like
|
|
24
|
+
* <Node Name> are replaced with actual values from the resource's tiles.
|
|
25
|
+
*
|
|
26
|
+
* @param graph - The graph definition containing descriptor configuration
|
|
27
|
+
* @param nodes - Map of node IDs to node objects for value lookup
|
|
28
|
+
* @param wrapper - IInstanceWrapper for retrieving pseudo values from Rust
|
|
29
|
+
* @returns Promise resolving to StaticResourceDescriptors with populated fields
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* // Given a descriptor config with template: "The <Title> from <Year>"
|
|
33
|
+
* // And a resource with Title="Rome" and Year="100 AD"
|
|
34
|
+
* // Returns descriptors with populated field: "The Rome from 100 AD"
|
|
35
|
+
*/
|
|
36
|
+
declare function buildResourceDescriptors(graph: StaticGraph, nodes: Map<string, StaticNode>, wrapper: IInstanceWrapper<any>): Promise<StaticResourceDescriptors>;
|
|
37
|
+
/**
|
|
38
|
+
* Serialize a Map<string, any> to a simple object for passing to WASM
|
|
39
|
+
* Converts values to Option<bool>: Some(true)=truthy, Some(false)=false, None=undefined
|
|
40
|
+
* This avoids expensive JsValue iteration and type checking in Rust
|
|
41
|
+
*/
|
|
42
|
+
declare function serializeValuesMap(map: Map<string, any>): Record<string, boolean | null>;
|
|
43
|
+
export { slugify, AttrPromise, getCurrentLanguage, generateUuidv5, setCurrentLanguage, buildResourceDescriptors, DESCRIPTOR_FUNCTION_ID, serializeValuesMap };
|